77 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
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
Erich Keane
b8f5cbb4ff
[OpenACC][CIR] 'cache' construct lowering (#146915)
The 'cache' construct is an interesting one, in that it doesn't take any
clauses, and is exclusively a collection of variables. Lowering wise,
  these just get added to the associated acc.loop.  This did require
  some work to ensure that the cache doesn't have 'vars' that aren't
  inside of the loop, but Sema is taking care of that with a warning.

Otherwise this is just a fairly simple amount of lowering, where each
'var' in the list creates an acc.cache, which is added to the acc.loop.
2025-07-07 08:35:05 -07:00
Andres-Salamanca
717899ce86
[CIR] Upstream get_bitfield operation to load bit-field members from structs (#145971)
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.
2025-07-02 18:05:19 -05:00
Andy Kaylor
32180cf9f9
[CIR] Upstream support for operator assign (#145979)
This adds support for assignment operators, including implicit operator
definitions.
2025-06-27 16:56:26 -07:00
Amr Hesham
f20ef8520d
[CIR][NFC] Fix init llvm::ArrayRef warning (#146147)
Fix init llvm::ArrayRef deprecation warning when initialized with
std::nullopt
2025-06-27 22:39:28 +02:00
Andy Kaylor
74cabdb806
[CIR] Add basic support for operator new (#145802)
This adds the code to handle operator new expressions in ClangIR.
2025-06-27 09:43:26 -07:00
Andy Kaylor
418b409df8
[CIR] Add support for member initialization from constructors (#144583)
Upstream the code to handle member variable initialization in a
constructor. At this point only simple scalar values (including members
of anonymous unions) are handled.
2025-06-24 10:05:48 -07:00
Amr Hesham
4a4582dd78
[CIR] Upstream BinAssign for ComplexType (#144868)
This change adds support for the BinAssign op and LValueToRValue for
ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-06-21 10:30:59 +02:00
Sirui Mu
8e157fdbb7
[CIR] Add support for __builtin_assume (#144376)
This patch adds support for the `__builtin_assume` builtin function.
2025-06-18 17:10:29 +08:00
Amr Hesham
6464066787
[CIR] Upstream CreateOp for ComplexType with folder (#143192)
This change adds support for the create op for ComplexType with folder
and support for empty init list

https://github.com/llvm/llvm-project/issues/141365
2025-06-14 13:26:03 +02:00
Andy Kaylor
24bbc82070
[CIR] Support for static variables (#143980)
This adds support for emitting static variables and their initializers.
2025-06-13 11:20:32 -07:00
Sirui Mu
8ba62fdb3d
[CIR] Function calls with aggregate arguments and return values (#143377)
This patch updates cir.call operation and allows function calls with
aggregate arguments and return values.

It seems that C++ class support is still at a minimum now. I tried to
make a call to a C++ function with an argument of aggregate type but it
failed because the initialization of C++ class / struct is NYI. I also
tried to inline this part of support into this patch, but the mixed
patch quickly blows in size and becomes unsuitable for review. Thus,
tests for calling functions with aggregate arguments are added only for
C for now.
2025-06-13 16:47:56 +08:00
Andy Kaylor
4a4035c86b
[CIR] Add support for delegating constructors (#143932)
This change adds the necessary support for handling delegating
constructors in ClangIR. The implementation is kept as small as possible
by not handling any other sort of initialization (members, base classes,
etc.). That will be added in a future commit.
2025-06-12 14:52:07 -07:00
Andy Kaylor
77834a40cf
[CIR] Upstream support for emitting constructors (#143639)
This change upstreams the code to emit simple constructor defintions.
2025-06-12 09:24:26 -07:00
Erich Keane
574f77a1ee
[OpenACC][CIR] Add parallelism determ. to all acc.loops (#143751)
PR #143720 adds a requirement to the ACC dialect that every acc.loop
must have a seq, independent, or auto attribute for the 'default'
device_type. The standard has rules for how this can be intuited:

orphan/parallel/parallel loop: independent
kernels/kernels loop: auto
serial/serial loop: seq, unless there is a gang/worker/vector, at which
point it should be 'auto'.

This patch implements all of this rule as a 'cleanup' step on the IR
generation for combined/loop operations. Note that the test impact is
much less since I inadvertently have my 'operation' terminating curley
matching the end curley from 'attribute' instead of the front of the
line, so I've added sufficient tests to ensure I captured the above.
2025-06-11 12:04:26 -07:00
Morris Hafner
8e4f0d8614
[CIR] Upstream minimal builtin function call support (#142981)
This patch adds all bits required to implement builtin function calls to
ClangIR. It doesn't actually implement any of the builtins except those
that fold to a constant ahead of CodeGen
(`__builtin_is_constant_evaluated()` being one example).
2025-06-11 18:24:46 +02:00
Andy Kaylor
b9329fe88e
[CIR] Upstream support for calling constructors (#143579)
This change adds support for calling C++ constructors. The support for
actually defining a constructor is still missing and will be added in a
later change.
2025-06-10 16:50:29 -07:00
Andy Kaylor
6559831025
[CIR] Add support for accessing members of base classes (#143195)
This change adds the support for accessing a member of a base class from
a derived class object.
2025-06-09 13:11:12 -07:00
Andy Kaylor
4ed0ff8756
[CIR] Add support for using enum constants (#143214)
Although support for declaring enums and using values whose type was an
enum was previously upstreamed, we didn't have support for referencing
the constant values declared in the enum. This change adds that support.
2025-06-09 09:19:31 -07:00
Morris Hafner
4b2cb118bc
[CIR] Upstream lowering of conditional operators to TernaryOp (#138156)
This patch adds visitors for BinLAnd, BinLOr and
AbstractConditionalOperator. Note that this patch still lacks visitation
of OpaqueValueExpr which is needed for the GNU ?: operator.

---------

Co-authored-by: Erich Keane <ekeane@nvidia.com>
2025-06-03 13:29:23 +02:00
Andy Kaylor
19dcec979c
[CIR] Support inline C++ member function definitions (#142484)
This change upstreams the code to support emitting inline C++ function
definitions, including the ASTConsumer handler for inline definitions
and the code to load the 'this' pointer.

This necessitates introducing the Itanium CXXABI class. No other CXXABI
subclasses are supported at this time. The Itanium CXXABI is used for
AppleARM64, which will require its own handler for a few special cases
(such as array cookies) later.
2025-06-02 17:13:19 -07:00
Sirui Mu
628a3f0a48
[CIR] Call to variadic functions (#141942) 2025-05-31 09:59:41 +08:00
Andy Kaylor
3ce74c3b40
[CIR] Upstream support for string literals (#140796)
This adds the minimal support needed to handle string literals.
2025-05-21 11:32:50 -07:00
Andy Kaylor
cbcfe667bb
[CIR] Upstream support for iterator-based range for loops (#140636)
This change adds handling for C++ member operator calls, implicit no-op
casts, and l-value call expressions. Together, these changes enable
handling of range for loops based on iterators.
2025-05-20 10:52:15 -07:00
Erich Keane
f171e05041
[NFC][OpenACC] Refactor clause emission- (#140586)
Having the whole clause emission be in a header file ended up being
pragmatic, but ended up being a sizable negative for a variety of
reasons. This patch moves it to its own .cpp file and makes
CIRGenFunction instead call into the visitor via a template instead.

This is possible because the valid list of construct kinds is quite
finite, and easy to enumerate.
2025-05-19 15:47:26 -07:00
Andy Kaylor
a0c515a9ef
[CIR] Upstream support for C++ member function calls (#140290)
This change adds the support needed to handle a C++ member function
call, including arranging the function type with an argument added for
the 'this' parameter. It was necessary to introduce the class to handle
the CXXABI, but at this time no target-specific subclasses have been
added.
2025-05-19 14:42:50 -07:00
Erich Keane
4c69f8248d
[OpenACC][CIR] Implement basic lowering for combined constructs (#139119)
Combined constructs are emitted a little oddly, in that they are the
first ones where there are two operations for a single construct. First,
the compute variant is emitted with 'combined(loop)', then the loop
operation is emitted with 'combined(<variant>)'. Each gets its own
normal terminator.

This patch does not yet implement clauses at all, since that is going to
require special attention to make sure we get the emitting of them
correct, since certain clauses go to different locations, and need their
insertion-points set correctly. So this patch sets it up so that we will
emit the 'not implemented' diagnostic for all clauses.
2025-05-09 05:35:17 -07:00
Andres-Salamanca
f74d893987
[CIR] Upstream support for switch statements case kinds (#138003)
This introduces support for the following cir::case kinds:
- `Equal`
- `AnyOf`
- `Range`
2025-05-07 12:28:35 -07:00
Sirui Mu
44c4b4cef9
[CIR] Upstream cir.call with scalar arguments (#136810)
This PR upstreams support for scalar arguments in `cir.call` operation.

Related to #132487 .
2025-05-02 10:04:48 +08:00
Andy Kaylor
a76936f1c0
[CIR] Upstream support for range-based for loops (#138176)
This upstreams the code needed to handle CXXForRangeStmt.
2025-05-01 14:47:20 -07:00
Andy Kaylor
df6d1cf4c2
[CIR] Upstream support for l-value references (#138001)
This adds basic support for handling reference values.
2025-04-30 14:51:45 -07:00
Andy Kaylor
7d91cf4bab
[CIR] Add support for compound assignment statements (#137740)
Compound assignment in C++ goes through a different path than the binary
assignment operators that were already handled for C. This change adds
the necessary handler to get this working with C++.
2025-04-29 11:31:04 -07:00
Andres-Salamanca
9d1f1c4c8b
[CIR] Upstream initial support for switch statements (#137106)
This introduces initial support for the switchOP, with caseOP of the
Equal kind. Support for additional case kinds such as AnyOf, Range, and
Default will be included in a future patch. Similarly, lowering to LLVM
IR and flattening of the switch are deferred and will be addressed in
subsequent updates.
2025-04-29 08:43:44 -07:00
erichkeane
80182a7d5d [OpenACC][CIR] Implement 'wait' directive lowering
This construct has a couple of 'intexprs' which are lowered the same way
as clauses, plus has a pair of simple clauses that needed lowering.
This patch does all of that.
2025-04-24 14:26:24 -07:00
Andy Kaylor
21bc23e35e
[CIR] Upstream support for accessing structure members (#136383)
This adds ClangIR support for accessing structure members. Access to
union members is deferred to a later change.
2025-04-22 13:36:27 -07:00
Sirui Mu
78857e7263
[CIR] cir.call with scalar return type (#135552)
This PR introduces support for calling functions with a scalar return
type to the upstream. This PR also includes an initial version of
`CIRGenTargetInfo` and related definitions which are essential for the
CIRGen of call ops.

Related to #132487 .
2025-04-17 22:38:37 +08:00
Andy Kaylor
abe3b90b3f
[CIR] Fix warnings, again! (#135284)
The calleeDecl var will be used in the near future, so I left it. At
least for clang, the [[maybe_unused]] attribute takes care of the
warnings related to that variable. The other warning was a simple lack
of return after errorNYI.
2025-04-11 10:57:08 -07:00
Morris Hafner
566c30e324
[CIR] Upstream binary assignments and comma (#135115)
This patch adds `VisitBinAssign` and `VisitBinComma` to the ClangIR
`ScalarExprEmitter` to enable assignments and the comma operator.

---------

Co-authored-by: Morris Hafner <mhafner@nvidia.com>
2025-04-11 10:26:29 -07:00