370 Commits

Author SHA1 Message Date
Amr Hesham
1aa6b99801
[CIR] Implement AbstractConditionalOperator for ComplexType (#147090)
Implement AbstractConditionalOperator support for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-07-07 18:50:07 +02:00
Amr Hesham
3c76a054ac
[CIR] Implement functional cast to ComplexType (#147147)
Implement functional cast to ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-07-07 17:48:50 +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
Amr Hesham
1aa39690aa
[CIR] Upstream UnaryDeref support for ComplexType (#146757)
Upstream UnaryDeref support for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-07-03 19:16:43 +02:00
Amr Hesham
e93a34662f
[CIR] Upstream SubstNonTypeTemplateParmExpr support for ComplexType (#146755)
Upstream SubstNonTypeTemplateParmExpr support for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-07-03 17:50:21 +02:00
Amr Hesham
59d641a2da
[CIR] Upstream support for SubstNonTypeTemplateParmExpr (#146751)
Upstream support for SubstNonTypeTemplateParmExpr
2025-07-03 17:50:00 +02:00
Kazu Hirata
a244907922
[clang] Use range-based for loops (NFC) (#146811)
Note that LLVM Coding Standards discourages std::for_each and
llvm::for_each unless the callable object already exists.
2025-07-03 08:36:03 -07:00
Sirui Mu
4b9f622ca9
[CIR] Bit manipulation builtin functions (#146529)
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`.
2025-07-03 23:08:49 +08:00
Sirui Mu
23104a74e7
[CIR] Add nothrow attribute to the call operation (#145178)
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.
2025-07-03 22:54:15 +08: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
Amr Hesham
e9be5286e1
[CIR] Implement NotEqualOp for ComplexType (#146129)
This change adds support for the not equal operation for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-07-02 19:25:25 +02:00
Sirui Mu
1841b021c6
[CIR] Add OptInfo attribute (#146261)
This patch adds the `#cir.opt_info` attribute which holds module-level
optimization information.
2025-07-02 23:29:43 +08:00
Henrich Lauko
e288561e6b
[CIR] Clean up FPAttr (#146662)
- Adds CIR_ prefix to the definition
- Removes redundant builder and cleans up attribute creations

This mirrors incubator changes from https://github.com/llvm/clangir/pull/1726
2025-07-02 16:52:15 +02:00
Henrich Lauko
8dcdc0ff1f
[CIR] Clean up IntAttr (#146661)
- Add common CIR_ prefix
- Simplify printing/parsing
- Make it use IntTypeInterface

This mirrors incubator changes from https://github.com/llvm/clangir/pull/1725
2025-07-02 16:36:09 +02:00
Amr Hesham
6fafa46f8c
[CIR] Upstream PackIndexingExpr for ScalarExpr (#146239)
Upstream PackIndexingExpr for ScalarExpr
2025-07-01 20:59:53 +02:00
Amr Hesham
e11d354d64
[CIR] Upstream GenericSelectionExpr (#146211)
Upstream GenericSelectionExpr for ScalarExpr
2025-07-01 20:56:39 +02:00
Amr Hesham
67f1eb5c17
[CIR] Comma Operator for ComplexType (#146204)
This change adds support for the comma operator for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-07-01 20:55:58 +02:00
Amr Hesham
491c79f763
[CIR] Implement ArraySubscript for ComplexType (#146283)
Implement ArraySubscript for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-07-01 20:27:29 +02:00
Erich Keane
857815f3fa
[OpenACC][CIR] Implement 'rest' of update clause lowering (#146414)
This implements the async, wait, if, and if_present (as well as
    device_type, but that is a detail of async/wait) lowering. All of
these are implemented the same way they are for the compute constructs,
      so this is a pretty mild amount of changes.
2025-07-01 06:05:08 -07:00
Amr Hesham
f205e354ae
[CIR] Upstream GenericSelectionExpr for ComplexType (#146265)
Upstream the GenericSelectionExpr for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-06-30 22:25:01 +02:00
Erich Keane
125dbe103e
[OpenACC][CIR] 'update' construct lowering + a few clauses (#146378)
The 'update' construct has 3 'var-list' clauses, device, self, and host.
Each has a pretty simple data-operand type syntax in the IR, so this
patch implements them as well. At least one of those is required to be
present on an 'update', so we cannot do any lowering without them.

Note that 'self' and 'host' are aliases.
2025-06-30 11:24:17 -07:00
Erich Keane
a99fee6989
[OpenACC][CIR] Implement 'exit data' construct + clauses (#146167)
Similar to 'enter data', except the data clauses have a 'getdeviceptr'
operation before, so that they can properly use the 'exit' operation
correctly. While this is a touch awkward, it fits perfectly into the
existing infrastructure.

Same as with 'enter data', we had to add some add-functions for async
and wait.
2025-06-30 06:19:43 -07: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
Erich Keane
33d20828d1
[OpenACC][CIR] Implement enter-data + clause lowering (#146146)
'enter data' is a new construct type that requires one of the data
clauses, so we had to wait for all clauses to be ready before we could
commit this. Most of the clauses are simple, but there is a little bit
of work to get 'async' and 'wait' to have similar interfaces in the ACC
dialect, where helpers were added.
2025-06-27 13:47:42 -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
erichkeane
e4d8e06f83 [OpenACC][CIR] Implement present/deviceptr/attach lowering for data
These three are once again are IR clones of what the compute
IR looks like, so this patch is just adding the implementation and
writing sufficient tests.
2025-06-27 10:24:38 -07: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
3e9fd4966d
[CIR] Add support for constructor aliases (#145792)
This change adds support for handling the -mconstructor-aliases option
in CIR. Aliases are not yet correctly lowered to LLVM IR. That will be
implemented in a future change.
2025-06-27 09:43:05 -07:00
erichkeane
2557f99463 [OpenACC][CIR] Implement 'no_create' lowering for data
This lowering ends up being identical to 'create', except it is a
acc.nocreate for the start operation, and it doesn't permit modifier
list. This patch implements this by adding it to the list of permitted
handlers (along with compute), plus adds tests.
2025-06-27 09:27:59 -07:00
erichkeane
b76bc185a4 [OpenACC][CIR] Add copy/etc clause lowering for 'data'.
These work exactly the same way they do for compute constructs, so this
implements them identically and adds tests. The list of legal modifiers
is different, but that is all handled in Sema.
2025-06-27 08:51:46 -07:00
Henrich Lauko
07f1502b86
[CIR] Implement SizedTypeInterface to make isSized hookable (#146045)
Resolves issues pointed out in https://github.com/llvm/llvm-project/pull/143960/files#r2164047625 of needing to update sized list of types on each new type.

This mirrors incubator changes from https://github.com/llvm/clangir/pull/1714
2025-06-27 16:50:01 +02:00
Henrich Lauko
61c0a94a90
[CIR] Refactor type interfaces (#146044)
- 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
2025-06-27 16:47:58 +02:00
Erich Keane
3463aba45f
[OpenACC][CIR] Implement copyin/copyout/create lowering for compute/c… (#145976)
…ombined

This patch does the lowering of copyin (represented as a
    acc.copyin/acc.delete), copyout (acc.create/acc.copyin), and create
(acc.create/acc.delete).

Additionally, it found a few problems with #144806, so it fixes those as
well.
2025-06-27 07:25:58 -07:00
Amr Hesham
720d7e09b3
[CIR][NFC] Fix an unused variable warning (#145922)
This fixes a warning where a variable assigned in 'if' statement wasn't
referenced again.
2025-06-26 18:32:38 +02:00
Erich Keane
69bbf2135e
[OpenACC][CIR] Implement 'modifier-list' lowering (#145770)
Some of the 'data' clauses can have a 'modifier-list' which specifies
one of a few keywords from a list. This patch adds support for lowering
them following #144806.

We have to keep a separate enum from MLIR, since we have to keep
'always' around for semantic reasons, whereas the dialect doesn't
differentiate these.

This patch ensures we get these right for the only applicable clause so
far, which is 'copy'.
2025-06-26 09:25:59 -07:00
Amr Hesham
9d91b07e1e
[CIR] Implement EqualOp for ComplexType (#145769)
This change adds support for equal operation for ComplexType


https://github.com/llvm/llvm-project/issues/141365
2025-06-26 18:06:22 +02:00
Andy Kaylor
79da5fecdb
[CIR][NFC] Remove duplicate code (#145790)
This change removes a bit of code that was left as an artifact of a
previous "not yet implemented" state. The implementation is in place,
but the code to report an NYI diagnostic was left behind.
2025-06-25 14:44:33 -07:00
Andy Kaylor
1e45ea12db
[CIR] Add support for function linkage and visibility (#145600)
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.
2025-06-25 10:59:30 -07:00
Amr Hesham
1276a5b368
[CIR] Upstream support for builtin_vectorelements (#144877)
Add support for `__builtin_vectorelements`

Issue https://github.com/llvm/llvm-project/issues/136487
2025-06-25 19:40:21 +02:00
Amr Hesham
e4da49f018
[CIR] Upstream __imag__ for ComplexType (#144262)
This change adds support for `__imag__` for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-06-25 19:39:34 +02:00
Amr Hesham
9a7720ad2f
[CIR] Upstream __real__ for ComplexType (#144261)
This change adds support for __real__ for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-06-25 18:06:57 +02:00
Andres-Salamanca
280f60ed6d
[CIR] Fix NYI AAPCS bit-fields by skipping unsupported case (#145560)
This PR addresses the error mentioned in
https://github.com/llvm/llvm-project/pull/145067#issuecomment-3001104015,
which occurs on ARM when handling an unsupported bit-field case. The
patch removes the error and replaces it with an assert, marking the
missing feature.
2025-06-24 12:03:17 -07:00
Andres-Salamanca
8763d2968d
[CIR] Add support for bitfields in unions (#145096)
This PR introduces support for bitfields inside unions in CIR.
2025-06-24 10:17:58 -07:00
Sirui Mu
9291ad1c96
[CIR] Add support for __builtin_expect (#144726)
This patch adds support for the `__builtin_expect` and
`__builtin_expect_with_probability` builtin functions.
2025-06-24 10:17:12 -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
70bedc74b9
[CIR] Upstream ChooseExpr for ComplexType (#145163)
This change adds support for ChooseExpr for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-06-24 18:23:32 +02:00
Andres-Salamanca
2767ff4995
[CIR][NFC] Upstream computeVolatileBitfields (#145414)
This PR upstreams functionality for computing volatile bitfields when
the target follows the AAPCS ABI. The implementation matches the one in
the incubator, so no tests are included as the feature is not yet fully
implemented (NYI).
2025-06-24 09:38:02 -05:00
Andres-Salamanca
66214410c4
[CIR] Add support for DumpRecordLayouts (#145058)
This PR adds support for the `-fdump-record-layouts` flag.
2025-06-23 14:58:28 -05:00
Andres-Salamanca
f4d31cdee3
[CIR] Add bitfield offset calculation for big-endian targets (#145067)
This PR updates the bitfield offset calculation to correctly handle
big-endian architectures.
2025-06-23 14:20:26 -05: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