This patch adds support for atomic loads and stores. Specifically, it
adds support for the following intrinsic calls:
- `__atomic_load` and `__atomic_store`;
- `__c11_atomic_load` and `__c11_atomic_store`.
This patch adds the constant attribute to cir.global, the appropriate
lowering to LLVM constant and updates the tests.
---------
Co-authored-by: Andy Kaylor <akaylor@nvidia.com>
If an array initializer list leaves eight or more elements that require
zero fill, we had been generating an individual zero element for every
one of them. This change instead follows the behavior of classic
codegen, which creates a constant structure with the specified elements
followed by a zero-initializer for the trailing zeros.
This change adds support for calling virtual functions. This includes
adding the cir.vtable.get_virtual_fn_addr operation to lookup the
address of the function being called from an object's vtable.
This adds ReturnAddrOp and FrameAddrOp that represent
__builtin_return_address and __builtin_frame_address and the respective
lowering to LLVM parts.
---------
Co-authored-by: Andy Kaylor <akaylor@nvidia.com>
The #cir.global_view attribute was initially added without support for
the optional index list. This change adds index list support. This is
used when the address of an array or structure member is used as an
initializer.
This patch does not include support for taking the address of a
structure or class member. That will be added later.
This change introduces the #cir.global_view attribute and adds support
for using that attribute to handle initializing a global variable with
the address of another global variable.
This does not yet include support for the optional list of indices to
get an offset from the base address. Those will be added in a follow-up
patch.
This patch adds the `cir.ffs` operation which corresponds to the
`__builtin_ffs` family of builtin functions.
This operation was not included in the previous PRs because the call to
`__builtin_ffs` would be transformed into a library call to `ffs`. At
the time of authoring this patch, this behavior has been changed and now
we can properly lower calls to `__builtin_ffs` to `cir.ffs`.
This patch adds the `#cir.poison` attribute which represents a poison
value. This patch also updates various operation folders to let them
propagate poison values from their inputs to their outputs.
This patch upstreams support for creating arrays of classes that require
calling a constructor.
* Adds the ArrayCtor operation
* New lowering pass for lowering ArrayCtor to a loop
---------
Co-authored-by: Andy Kaylor <akaylor@nvidia.com>
Co-authored-by: Henrich Lauko <xlauko@mail.muni.cz>
This PR fixes incorrect alignment when lowering `set` and `getBitField`
operations to LLVM IR. The issue occurred because during lowering, the
function was being called with an alignment of 0, which caused it to
default to the alignment of the packed member. For example, if the
bitfield was packed inside a `u64i`, it would use an alignment of 8.
With this change, the generated code now matches what the classic
codegen produces.
In the assembly format, I changed to be similar to how it's done in
loadOp. If there's a better approach, please feel free to point it out.
This patch adds support for the following two builtin functions:
- `__builtin_bswap`, represented by the `cir.byte_swap` operation.
- `__builtin_bitreverse`, represented by the `cir.bit.reverse`
operation.
This PR upstreams the `set_bitfield` operation used to assign values to
bitfield members in C and C++ struct types.
Handling of AAPCS-specific volatile bitfield semantics will be addressed
in a future PR.
This patch adds CIR support for the following families of bit
manipulation builtin functions:
- `__builtin_clrsb`, represented by the `cir.bit.clrsb` operation
- `__builtin_ctz`, represented by the `cir.bit.clz` operation
- `__builtin_clz`, represented by the `cir.bit.ctz` operation
- `__builtin_parity`, represented by the `cir.bit.parity` operation
- `__builtin_popcount`, represented by the `cir.bit.popcnt` operation
The `__builtin_ffs` builtin function is not included in this patch
because the current CIRGen would emit it as a library call to `@ffs`.
This patch adds extra function attributes to the `cir.call` operation.
The extra attributes now may contain a single `cir.nothrow` attribute
that indicates whether the callee throws.
This PR adds support for loading bit-field members from structs using
the `get_bitfield` operation.
It enables retrieving the address of the bitfield-packed member but does
**not** yet support volatile bitfields this will be addressed in a
future PR.
- Generalizes CIRFPTypeInterface files to CIRTypeInterfaces for future type interfaces additions.
- Renames CIRFPTypeInterface to FPTypeInterface.
- Fixes FPTypeInterface tablegen prefix.
This mirrors incubator changes from https://github.com/llvm/clangir/pull/1713
This change adds support for function linkage and visibility and related
attributes. Most of the test changes are generalizations to allow
'dso_local' to be accepted where we aren't specifically testing for it.
Some tests based on CIR inputs have been updated to add 'private' to
function declarations where required by newly supported interfaces.
The dso-local.c test has been updated to add specific tests for
dso_local being set correctly, and a new test, func-linkage.cpp tests
other linkage settings.
This change sets `comdat` correctly in CIR, but it is not yet applied to
functions when lowering to LLVM IR. That will be handled in a later
change.
The CIR handling of `dso_local` for globals was upstreamed without the
underscore, making it inconsistent with the incubator and LLVM IR. This
change restores the underscore.