370 Commits

Author SHA1 Message Date
Andy Kaylor
a304e09fe7
[CIR] Handle expression with cleanups (#151600)
This adds code to handle expressions with cleanup, including
materializing a temporary object for the expression.
2025-08-01 11:38:35 -07:00
Andy Kaylor
96d1571a2f
[CIR] Add diagnostic for NYI AST visitor handlers (#151561)
A couple of handlers that were missing from the CIRGenerator AST visitor
allowed important features to be silently ignored during CIR generation.
This change adds these handlers with diagnostics to report that they are
not yet handled (except in the case where only debug information is
missed).
2025-08-01 09:29:00 -07:00
Erich Keane
25c07763f7
[OpenACC][CIR] Implement 'private' clause lowering. (#151360)
The private clause is the first with 'recipes', so a lot of
infrastructure is included here, including some MLIR dialect changes
that allow simple adding of a privatization. We'll likely get similar
for firstprivate and reduction.

Also, we have quite a bit of infrastructure in clause lowering to make
sure we have most cases we could think of covered.

At the moment, ONLY private is implemented, so all it requires is an
'init' segment (that doesn't call any copy operations), and potentially
a 'destroy' segment. However, actually calling 'init' functions on each
of the elements in them are not properly implemented, and will be in a
followup patch.

This patch implements all of that, and adds tests in a way that will be
useful for firstprivate as well.
2025-08-01 09:27:15 -07:00
Andy Kaylor
ba2edbd0c8
[CIR] Fix warnings related to unused variables in release builds (#151412)
This fixes a number of warnings in release builds due to variables that
were only being used in asserts. Some of these variables will later be
used in non-debug code, but for now they are unused in release builds.
2025-07-31 14:54:56 -07:00
Amr Hesham
03e54a148f
[CIR] Upstream MulOp for ComplexType (#150834)
This change adds support for mul op for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-07-31 19:16:42 +02:00
Andy Kaylor
3ca2050aa6
[CIR] Fix fallthrough warning (#151418)
This fixes a warning about an unannotated fallthrough.
2025-07-31 09:46:25 -07:00
Morris Hafner
8a5d363123
[CIR] Upstream support for function-level variable decompositions (#151073)
This implements support for structured bindings on a function scope
level. It does not add support for global structured bindings.
2025-07-31 17:34:41 +02:00
Andres-Salamanca
4005edd5c4
[CIR] Add ComputeVolatileBitfields Implementation (#151252)
This PR adds the implementation of the `ComputeVolatileBitfields`
function for the AAPCS ABI, following the rules described in [AAPCS64
§8.1.8.5 Volatile
Bit-fields](f52e1ad3f8/aapcs64/aapcs64.rst (8185volatile-bit-fields----preserving-number-and-width-of-container-accesses)).
When accessing a volatile bit-field either reading or writing the
compiler must perform a load or store using the access size that matches
the width of the declared type (i.e., the type of the container), rather
than the packed bit-field size.
For example, if a field is declared as `int`, it must read or write 32
bits, even if the bit-field is only 3 bits wide.
The `ComputeVolatileBitfields` function calculates the correct values
and offsets necessary for proper lowering of volatile bitfields.
Support for emitting calls to `get_bitfield` and `set_bitfield` with the
correct access size for volatile bitfields will be implemented in a
future PR.
2025-07-31 10:12:56 -05:00
Morris Hafner
77f8a9115e
[CIR] Support more declarations without any codegen (#151076)
This patch adds or completes support for a couple of top level
declaration types that don't emit any code: Most notably these include
Concepts, static_assert and type aliases.
2025-07-31 16:33:20 +02:00
Amr Hesham
953be42e40
[CIR] Upstream Unary Plus & Minus op for ComplexType (#150281)
This change adds support for Unary Plus & Minus op for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-07-30 21:18:35 +02:00
Morris Hafner
1132562bf3
[CIR] Add support for C++ conversion operators (#151066)
This fairly simple addition enables codegen for C++ conversion operators
2025-07-30 03:34:52 +02:00
jeremyd2019
a3228b6bf9
[Clang][Cygwin] Enable few conditions that are shared with MinGW (#149637)
The Cygwin target is generally very similar to the MinGW target. The
default auto-import behavior, the default calling convention, the
`.dll.a` import library extension, the `__GXX_TYPEINFO_EQUALITY_INLINE`
pre-define by `g++`, and the long double configuration.

Co-authored-by: Mateusz Mikuła <oss@mateuszmikula.dev>
2025-07-29 10:01:43 -07:00
Andy Kaylor
88620aee98
[CIR] Add support for array cleanups (#150499)
This adds support for array cleanups, including the ArrayDtor op.
2025-07-29 09:21:15 -07:00
Andy Kaylor
32779cd698
[CIR] Add proper handling for no prototype function calls (#150553)
This adds standard-comforming handling for calls to functions that were
declared in C source in the no prototype form.
2025-07-29 09:16:17 -07:00
Andres-Salamanca
a5db2c2844
[CIR] Add support for -ffine-grained-bitfield-accesses (#150687)
This PR adds support for `-ffine-grained-bitfield-accesses`. I reused
the tests from classic CodeGen, available here:

[c2c881fcc8/clang/test/CodeGenCXX/finegrain-bitfield-access.cpp)

We produce almost exactly the same codegen, except when returning a
variable: we emit an extra variable to hold the return value, whereas
classic CodeGen does not. Also, the GEP instructions use slightly
different syntax compared to classic CodeGen.
2025-07-29 10:31:40 -05:00
Sirui Mu
1249ab9a03
[CIR] Add bit ffs operation (#150997)
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`.
2025-07-29 20:45:13 +08:00
Amr Hesham
2762a079ee
[CIR] Implement LValueBitcast for ComplexType (#150668)
This change adds support for LValueBitcast for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-07-28 20:29:38 +02:00
Amr Hesham
cf1abe67b9
[CIR][NFC] Fix an unused variable warning (#150758)
This fixes a warning where a variable assigned in 'if' statement wasn't
referenced again.
2025-07-27 11:54:38 +02:00
Andy Kaylor
64704c6346
[CIR] Add support for C++ initializer lists (#150681)
This adds basic support for using C++ initializer lists to initialize
fields of a record.
2025-07-25 13:39:43 -07:00
Amr Hesham
b8277b49d9
[CIR] Upstream Support Init ComplexType from 1 size InitList (#150293)
This change adds support for init ComplexType from InitList with 1 size

https://github.com/llvm/llvm-project/issues/141365
2025-07-25 17:47:15 +02:00
Amr Hesham
1031f14e92
[CIR] Implement CK_LValueToRValueBitCast for ComplexType (#150296)
This change adds support for CK_LValueToRValueBitCast for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-07-24 22:23:30 +02:00
Andy Kaylor
7dc27267eb
[CIR] Unblock destructor alias handling (#150497)
This change removes a stale errorNYI message to allow destructor alias
handling. The error message was an artifact of the order in which
various parts of the implementation were upstreamed. Now that all the
parts are in place, all this needed was to remove the diagnostic and add
a test.
2025-07-24 12:18:52 -07:00
Andy Kaylor
47b5917348
[CIR] Add support for normal cleanups (#149948)
This change adds basic handling for normal cleanups. This is a very
minimal implemention. In particular, it uses a naive substitute for the
rich cleanup and EH stack handling that is present in classic codegen
and the CIR incubator. This is intended as a temporary implementation to
allow incremental progress. It is not expected to scale well enough to
be used in a production environment. It will be replaced with the full
EHScopeStack handling when such an implementation is needed.
2025-07-24 11:38:42 -07:00
Morris Hafner
3e9d369c5c
[CIR] Add support for array constructors (#149142)
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>
2025-07-24 17:15:34 +02:00
Amr Hesham
eb817c7950
[CIR] Upstream Cast kinds for ComplexType (#149717)
This change adds support for cast kinds for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-07-23 19:22:39 +02:00
Andres-Salamanca
97eec759e6
[CIR] Add support for binary operations on bitfield members (#149676)
This PR introduces support for binary operations on bitfield members.
2025-07-23 10:03:41 -05:00
Andy Kaylor
8f26a301bc
[CIR] Add complete destructor handling (#149552)
The initial implementation for emitting destructors emitted the complete
destructor body for both D1 and D2 destructors. This change updates the
code to have the D1 destructor call the D2 destructor.
2025-07-21 15:34:46 -07:00
Sirui Mu
3371b9111f
[CIR] Add assume_separate_storage operation (#149696)
This patch adds the `cir.assume_separate_storage` operation for the
`__builtin_assume_separate_storage` builtin function.
2025-07-21 22:21:44 +08:00
Amr Hesham
0aff1b6cdd
[CIR][NFC] Replace bool by cir::UnaryOpKind in emitComplexPrePostIncDec (#149566)
Replace bool by cir::UnaryOpKind in emitComplexPrePostIncDec
2025-07-19 15:19:42 +02:00
Amr Hesham
65bde89c9a
[CIR] Upstream CompoundLiteralExpr for Scalar (#148943)
Upstream CompoundLiteralExpr for Scalar as a prerequisite for
CompoundLiteralExpr for ComplexType
2025-07-19 15:13:36 +02:00
Andres-Salamanca
b02787d33f
[CIR] Fix alignment when lowering set/get bitfield operations (#148999)
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.
2025-07-18 16:13:34 -05:00
Amr Hesham
b84f72a7f5
[CIR] Upstream Unary Inc/Dec for ComplexType (#149162)
This change adds support for unary inc/dec operators for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-07-17 19:16:04 +02:00
Amr Hesham
84d65e9d19
[CIR] Upstream builtin_conj for ComplexType (#149170)
This change adds support for builtin_conj for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-07-17 18:00:32 +02:00
Amr Hesham
bd0f9dd86b
[CIR] Upstream unary not for ComplexType (#148857)
Upstream unary not for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-07-16 19:25:48 +02:00
Sirui Mu
8519143a9f
[CIR] Add rotate operation (#148426)
This patch adds `cir.rotate` operation for the `__builtin_rotateleft`
and `__builtin_rotateright` families of builtin calls.
2025-07-17 00:41:28 +08:00
Bogdan Vetrenko
a35b290c3c
[CIR][NFC] Fix typo in assertion message (Must) (#148704) 2025-07-15 18:27:14 +02:00
Andres-Salamanca
fdbd9c19c9
[CIR] Add support for unary operations on bitfield members (#148083)
This PR introduces support for unary operations on bitfield members.
Support for binary operations is planned for a future PR.
2025-07-14 12:57:38 -05:00
Amr Hesham
22b221d4b7
[CIR] Upstream ComplexImagPtrOp for ComplexType (#144236)
This change adds support for ComplexImagPtrOp for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-07-14 19:53:06 +02:00
Morris Hafner
f78d6caadc
[CIR] Add Minimal Destructor Definition Support (#144719)
This patch upstreams support for writing inline and out of line C++
destructor definitions. Calling a destructor implcitly or explicitly is
left for a future patch.

Because of that restriction complete destructors (D2 in Itanium
mangling) do not call into the base (D1) destructors yet but simply
behave like a base destructor. Deleting (D0) destructor support is not
part of this patch.

Destructor aliases aren't supported, either. Because of this compilation
with -mno-constructor-aliases may be required to avoid running into NYI
errors.
2025-07-14 19:02:00 +02:00
Amr Hesham
647f02a02a
[CIR] Implement SubOp for ComplexType (#148025)
This change adds support for SubOp for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-07-12 17:22:57 +02:00
Sirui Mu
265fb3605d
[CIR] Add bit reverse and byte reverse operations (#147200)
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.
2025-07-12 12:15:36 +08:00
Amr Hesham
ed8548796f
[CIR] Upstream ComplexRealPtrOp for ComplexType (#144235)
This change adds support for ComplexRealPtrOp for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-07-11 21:06:05 +02:00
Amr Hesham
44baef9843
[CIR] Use ZeroAttr as zeroinitializer for ComplexType (#148033)
Use ZeroAttr as a zeroinitializer for ComplexType, similar to what we
did in CXXScalarValueInitExpr

https://github.com/llvm/llvm-project/issues/141365
2025-07-11 19:57:21 +02:00
Andy Kaylor
13c897093f
[CIR] Add support for non-virtual base class initialization (#148080)
This change adds support for initializing non-virtual base classes
during the prologue of a derived class' constructor.
2025-07-11 09:57:15 -07:00
Andy Kaylor
b415db02e7
[CIR] Add handlers for 'using enum' and namespace alias (#148011)
These decl types don't require any code generation, though when debug
info is implemented, we will need to add handling for that. Until then,
we just need to have a handler so they don't generate an NYI error.
2025-07-10 16:16:37 -07:00
Andres-Salamanca
3d08a40959
[CIR] Upstream new SetBitfieldOp for handling C and C++ struct bitfields (#147609)
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.
2025-07-10 15:16:29 -05:00
Amr Hesham
dd1105bcea
[CIR] Implement AddOp for ComplexType (#147578)
This change adds support for AddOp for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-07-10 19:40:17 +02:00
Amr Hesham
54ec5217a0
[CIR] Upstream __builtin_cimag for ComplexType (#147808)
Upstream __builtin_cimag support for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-07-10 18:19:24 +02:00
Amr Hesham
ddfc13c191
[CIR] Upstream __builtin_creal for ComplexType (#146927)
Upstream `__builtin_creal` support for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-07-09 18:28:00 +02:00
Amr Hesham
bbefd33ae6
[CIR] Implement CXXScalarValueInitExpr for ComplexType (#147143)
Implement CXXScalarValueInitExpr support for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-07-08 17:36:40 +02:00