63 Commits

Author SHA1 Message Date
Henrich Lauko
3bc216c29c
[CIR] Split CIR_UnaryOp into individual operations (#185280)
Split the monolithic cir.unary operation (which dispatched on a
UnaryOpKind enum) into four separate operations: cir.inc, cir.dec,
cir.minus, and cir.not.

Changes:
- Add CIR_UnaryOpInterface with getInput()/getResult() methods
- Add CIR_UnaryOp and CIR_UnaryOpWithOverflowFlag base classes
- Define IncOp, DecOp, MinusOp, NotOp with per-op folds
- Add Involution trait to NotOp for not(not(x)) -> x folding
- Replace createUnaryOp() with createInc/Dec/Minus/Not builders
- Split LLVM lowering into four separate patterns
- Split LoweringPrepare complex-type handling per unary op
- Update CIRCanonicalize and CIRSimplify for new op types
- Update all codegen files to use bool params instead of UnaryOpKind
- Remove CIR_UnaryOpKind enum and old CIR_UnaryOp definition

Assembly format change:
  cir.unary(inc, %x) nsw : !s32i, !s32i  ->  cir.inc nsw %x : !s32i
  cir.unary(not, %x) : !u32i, !u32i      ->  cir.not %x : !u32i
2026-03-14 23:50:43 +01:00
Henrich Lauko
e3baec4bfb
[CIR] Remove cir.unary(plus, ...) and emit nothing for unary plus (#185278)
Traditional codegen never emits any operation for unary plus — it just
visits the subexpression as a pure identity at the codegen level. Align
CIRGen with this behavior by removing Plus from UnaryOpKind entirely
and having VisitUnaryPlus directly visit the subexpression with the
appropriate promotion/demotion handling.
2026-03-14 20:54:44 +01:00
Amr Hesham
7891d90eb0
[CIR] Implement UserDefinedConversion for ComplexType (#185749)
Implement the UserDefinedConversion cast for ComplexType
2026-03-11 18:59:47 +01:00
Amr Hesham
fe7d245c18
[CIR][NFC] ComplexType visitStmt replace NYI with unreachable (#185178)
Replace errorNYI with llvm_unreachable in ComplexType visitStmt
2026-03-07 14:27:35 +01:00
Henrich Lauko
71f5e43bc6
[CIR] Fix operator-precedence bugs in assert conditions (#185119)
Due to && binding tighter than ||, asserts of the form
assert(A || B && "msg") always pass when A is true. Add
parentheses so the string message is properly attached:
assert((A || B) && "msg").
2026-03-07 08:07:21 +01:00
Amr Hesham
f305da7240
[CIR] Implement PackIndexingExpr for ComplexType (#184878)
Implement the PackIndexingExpr for ComplexType
2026-03-06 19:11:33 +01:00
Amr Hesham
3d086f573d
[CIR] Implement ImplicitValueInitExpr for ComplexType (#183836)
Implement ImplicitValueInitExpr for ComplexType
2026-02-28 16:16:56 +01:00
Andy Kaylor
c78f37fdeb
[CIR] Fix dominance problems with values defined in cleanup scopes (#183810)
We currently encounter dominance verification errors when a value is
defined inside a cleanup scope but used outside the scope. This occurs
when forceCleanup() is used to exit a cleanup scope while a variable is
holding a value that was created in the scope body. Classic codegen
solved this problem by passing a list of values to spill and reload to
forceCleanup(). This change implements that same solution for CIR.

I have also aligned the ScalarExprEmitter::VisitExprWithCleanups
implementation with that of classic codegen, eliminating an extra
lexical scope. This causes temporary allocas to be created at the next
higher existing lexical scope, but I think that's OK since they would be
hoisted there anyway by a later pass.
2026-02-27 15:31:07 -08:00
Ayokunle Amodu
a637cde428
[CIR][NFC] Update the constructor sites of CIRGenFPOptionsRAII (#182187)
As support for RAII FP options has been upstreamed (#179121), this patch
removes `CIRGenFPOptionsRAII` from the `MissingFeatures` list and
updates its expected constructor sites.
2026-02-24 09:49:13 -08:00
Amr Hesham
023bfa2013
[CIR] ExprWithCleanups for Complex expr (#178032)
Upstream support ExprWithCleanups for Complex expr
2026-01-27 17:30:46 +01:00
Amr Hesham
87ac5f2ec9
[CIR] Implement part of ConstantExpr support for ComplexType (#173102)
Implement part of the ConstantExpr support for the ComplexType
2025-12-20 19:28:43 +01:00
Amr Hesham
a94f01a6f8
[CIR] Implement StmtExpr for ComplexType (#171196)
Implement StmtExpr for ComplexType
2025-12-09 11:02:19 +01:00
Farzon Lotfi
dd1b4abfb7
[HLSL][Matrix] Add support for Matrix element and trunc Casts (#168915)
fixes #168737
fixes #168755

This change fixes adds support for Matrix truncations via the
ICK_HLSL_Matrix_Truncation enum. That ends up being most of the files
changed.

It also allows Matrix as an HLSL Elementwise cast as long as the cast
does not perform a shape transformation ie 3x2 to 2x3.

Tests for the new elementwise and truncation behavior were added. As
well as sema tests to make sure we error n the shape transformation
cast.

I am punting right now on the ConstExpr Matrix support. That will need
to be addressed later. Will file a seperate issue for that if reviewers
agree it can wait.
2025-12-02 19:02:25 -05:00
Amr Hesham
f240a73e83
[CIR] Upstream Load/Store Complex with volatile qualifier (#167216)
Upstream supporting Load/Store ops for Complex with volatile qualifier
2025-11-12 17:19:27 +01:00
Andy Kaylor
d46ef863d9
[CIR][NFC] Migrate more calls to free create functions (#164719)
This migrates some code that was calling the now-deprecated form of the
MLIR builder create function.
2025-10-22 15:43:05 -07:00
Jakub Kuderski
9a2e825c13
[clang][CIR][mlir] Migrate to free create functions. NFC. (#164656)
See
https://discourse.llvm.org/t/psa-opty-create-now-with-100-more-tab-complete/87339.

I plan to make these deprecated in
https://github.com/llvm/llvm-project/pull/164649.
2025-10-22 14:30:19 -04:00
Amr Hesham
aac8a0d041
[CIR] Implement VisitCXXDefaultArgExpr for ComplexType (#164079)
Implement CXXDefaultArgExpr support for ComplexType

Issue https://github.com/llvm/llvm-project/issues/141365
2025-10-20 18:58:47 +02:00
Amr Hesham
35c14c4cc3
[CIR] Implement AtomicExpr for ComplexType (#160563)
This change implements AtomicExpr for ComplexType

Issue: https://github.com/llvm/llvm-project/issues/141365
2025-09-25 19:15:34 +02:00
Amr Hesham
ac62c4af29
[CIR] Implement UnaryExtension support for ComplexType (#159913)
This change implements UnaryExtension for ComplexType

Issue: https://github.com/llvm/llvm-project/issues/141365
2025-09-23 16:50:24 +02:00
Amr Hesham
b4d274f3d9
[CIR] Implement OpaqueValueExpr for Complex in C (#158423)
This change adds support for the OpaqueValueExpr for Complex in C

Issue: https://github.com/llvm/llvm-project/issues/141365
2025-09-18 18:56:02 +02:00
Amr Hesham
2a3c9f917d
[CIR] Upstream VisitOpaqueValueExpr support for Complex & Scalar (#157331)
This change adds support for the OpaqueValueExpr for Complex & Scalar


Issue: https://github.com/llvm/llvm-project/issues/141365
2025-09-13 10:38:56 +02:00
Andy Kaylor
e1021bb9bd
[CIR] Implement CXX field default initialization (#157140)
This adds the code needed to handle default initialization for fields of
various types.
2025-09-05 13:19:43 -07:00
Amr Hesham
698a40d711
[CIR] Fix Complex emit promotion for Div op (#156963)
This change fixes emitting promotion type for div op

Issue: https://github.com/llvm/llvm-project/issues/141365
2025-09-05 20:22:58 +02:00
Amr Hesham
3e5f49af26
[CIR][NFC] Reorder GenExprComplex and add errors for unhandled visitors (#156241)
- Reorder the CIRGenExprComplex functions to be similar to OCG.
- Add errors for unhandled visitors.
- Rename the test file to be similar to `complex-mul-div`.

Issue: https://github.com/llvm/llvm-project/issues/141365
2025-09-02 18:44:03 +02:00
Amr Hesham
e78ac808d5
[CIR] Implement VAArgExpr for ComplexType (#156092)
This change adds support VAArgExpr for ComplexExpr

Issue: https://github.com/llvm/llvm-project/issues/141365
2025-08-30 18:18:32 +02:00
Amr Hesham
a8712072c8
[CIR] Complex Unary plus and minus with promoted type (#155486)
This change adds support for Complex unary plus and minus expressions
with promoted type

Issue: https://github.com/llvm/llvm-project/issues/141365
2025-08-29 20:34:13 +02:00
Amr Hesham
1123a930c6
[CIR] DivOp & CompoundAssignmentDiv between ComplexType and ScalarType (#155167)
This change adds support for DivOp and CompoundAssignmentDiv between
ComplexType and ScalarType

Issue: https://github.com/llvm/llvm-project/issues/141365
2025-08-29 19:00:48 +02:00
Amr Hesham
304ef65f7b
[CIR] Upstream DivOp for ComplexType (#153796)
This change adds support for the division operation between two complex
types

Issue: #141365
2025-08-23 08:39:48 +02:00
Amr Hesham
018c5ba161
[CIR] Implement MemberExpr with VarDecl for ComplexType (#154307)
This change adds support for MemberExpr with VarDecl ComplexType

Issue: https://github.com/llvm/llvm-project/issues/141365
2025-08-20 10:33:08 +02:00
Amr Hesham
5581e34bd9
[CIR] Implement MemberExpr support for ComplexType (#154027)
This change adds support for the MemberExpr ComplexType

Issue: https://github.com/llvm/llvm-project/issues/141365
2025-08-19 10:32:22 +02:00
Amr Hesham
475aa1b1a1
[CIR] CompoundAssignment from ComplexType to ScalarType (#152915)
This change adds support for the CompoundAssignment for ComplexType and
updates our approach for emitting bin op between Complex & Scalar

https://github.com/llvm/llvm-project/issues/141365
2025-08-12 18:01:31 +02:00
Amr Hesham
093395ca6b
[CIR] Mul CompoundAssignment support for ComplexType (#152354)
This change adds support for Mul CompoundAssignment for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-08-07 19:42:15 +02:00
Amr Hesham
ed9a552563
[CIR][NFC] Fix typo in ComplexRangeKind comment (#152535)
Fix typo in ComplexRangeKind comment

Catched in https://github.com/llvm/clangir/pull/1779
2025-08-07 18:55:59 +02:00
Amr Hesham
4c9bb65639
[CIR] Plus & Minus CompoundAssignment support for ComplexType (#150759)
This change adds support for Plus & Minus CompoundAssignment for
ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-08-06 18:13:48 +02: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
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
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
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
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
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
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
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
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
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
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