Skip to content

Commit 06a9a5d

Browse files
committed
[CIR] Backport Comma Operator for ComplexType
1 parent 80d52d7 commit 06a9a5d

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ class ComplexExprEmitter : public StmtVisitor<ComplexExprEmitter, mlir::Value> {
306306
return emitLoadOfLValue(LV, E->getExprLoc());
307307
};
308308
mlir::Value VisitBinComma(const BinaryOperator *E) {
309-
llvm_unreachable("NYI");
309+
CGF.emitIgnoredExpr(E->getLHS());
310+
return Visit(E->getRHS());
310311
}
311312

312313
mlir::Value

clang/test/CIR/CodeGen/complex.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,19 @@ void complex_functional_cast() {
1414

1515
// LLVM: %[[INIT:.*]] = alloca { i32, i32 }, i64 1, align 4
1616
// LLVM: store { i32, i32 } zeroinitializer, ptr %[[INIT]], align 4
17+
18+
void complex_comma_operator(int _Complex a, int _Complex b) {
19+
int _Complex c = (a, b);
20+
}
21+
22+
// CIR: %[[COMPLEX_A:.*]] = cir.alloca !cir.complex<!s32i>, !cir.ptr<!cir.complex<!s32i>>, ["a", init]
23+
// CIR: %[[COMPLEX_B:.*]] = cir.alloca !cir.complex<!s32i>, !cir.ptr<!cir.complex<!s32i>>, ["b", init]
24+
// CIR: %[[RESULT:.*]] = cir.alloca !cir.complex<!s32i>, !cir.ptr<!cir.complex<!s32i>>, ["c", init]
25+
// CIR: %[[TMP_B:.*]] = cir.load{{.*}} %[[COMPLEX_B]] : !cir.ptr<!cir.complex<!s32i>>, !cir.complex<!s32i>
26+
// CIR: cir.store{{.*}} %[[TMP_B]], %[[RESULT]] : !cir.complex<!s32i>, !cir.ptr<!cir.complex<!s32i>>
27+
28+
// LLVM: %[[COMPLEX_A:.*]] = alloca { i32, i32 }, i64 1, align 4
29+
// LLVM: %[[COMPLEX_B:.*]] = alloca { i32, i32 }, i64 1, align 4
30+
// LLVM: %[[RESULT:.*]] = alloca { i32, i32 }, i64 1, align 4
31+
// LLVM: %[[TMP_B:.*]] = load { i32, i32 }, ptr %[[COMPLEX_B]], align 4
32+
// LLVM: store { i32, i32 } %[[TMP_B]], ptr %[[RESULT]], align 4

0 commit comments

Comments
 (0)