@@ -613,6 +613,11 @@ void CIRGenFunction::buildStoreOfScalar(mlir::Value value, LValue lvalue,
613
613
lvalue.isNontemporal ());
614
614
}
615
615
616
+ void CIRGenFunction::buildStoreOfComplex (mlir::Location loc, mlir::Value value,
617
+ LValue lvalue) {
618
+ builder.createStore (loc, value, lvalue.getAddress ());
619
+ }
620
+
616
621
// / Given an expression that represents a value lvalue, this
617
622
// / method emits the address of the lvalue, then loads the result as an rvalue,
618
623
// / returning the rvalue.
@@ -975,7 +980,8 @@ LValue CIRGenFunction::buildBinaryOperatorLValue(const BinaryOperator *E) {
975
980
}
976
981
977
982
case TEK_Complex:
978
- assert (0 && " not implemented" );
983
+ return buildComplexAssignmentLValue (E);
984
+
979
985
case TEK_Aggregate:
980
986
assert (0 && " not implemented" );
981
987
}
@@ -1066,7 +1072,7 @@ RValue CIRGenFunction::buildAnyExpr(const Expr *E, AggValueSlot aggSlot,
1066
1072
case TEK_Scalar:
1067
1073
return RValue::get (buildScalarExpr (E));
1068
1074
case TEK_Complex:
1069
- assert ( 0 && " not implemented " );
1075
+ return RValue::getComplex ( buildComplexExpr (E) );
1070
1076
case TEK_Aggregate: {
1071
1077
if (!ignoreResult && aggSlot.isIgnored ())
1072
1078
aggSlot = CreateAggTemp (E->getType (), getLoc (E->getSourceRange ()),
@@ -1855,7 +1861,8 @@ void CIRGenFunction::buildAnyExprToMem(const Expr *E, Address Location,
1855
1861
// FIXME: This function should take an LValue as an argument.
1856
1862
switch (getEvaluationKind (E->getType ())) {
1857
1863
case TEK_Complex:
1858
- assert (0 && " NYI" );
1864
+ buildComplexExprIntoLValue (E, makeAddrLValue (Location, E->getType ()),
1865
+ /* isInit*/ false );
1859
1866
return ;
1860
1867
1861
1868
case TEK_Aggregate: {
@@ -2307,7 +2314,7 @@ RValue CIRGenFunction::convertTempToRValue(Address addr, clang::QualType type,
2307
2314
LValue lvalue = makeAddrLValue (addr, type, AlignmentSource::Decl);
2308
2315
switch (getEvaluationKind (type)) {
2309
2316
case TEK_Complex:
2310
- llvm_unreachable ( " NYI " );
2317
+ return RValue::getComplex ( buildLoadOfComplex (lvalue, loc) );
2311
2318
case TEK_Aggregate:
2312
2319
llvm_unreachable (" NYI" );
2313
2320
case TEK_Scalar:
@@ -2870,3 +2877,24 @@ LValue CIRGenFunction::buildPredefinedLValue(const PredefinedExpr *E) {
2870
2877
2871
2878
return buildStringLiteralLValue (SL);
2872
2879
}
2880
+
2881
+ mlir::Value CIRGenFunction::buildComplexPrePostIncDec (const UnaryOperator *E,
2882
+ LValue LV, bool isInc,
2883
+ bool isPre) {
2884
+ auto InVal = buildLoadOfComplex (LV, E->getExprLoc ());
2885
+
2886
+ auto Loc = getLoc (E->getSourceRange ());
2887
+ mlir::Value IncDecVal;
2888
+ if (isInc)
2889
+ IncDecVal = builder.create <mlir::cir::UnaryOp>(
2890
+ Loc, mlir::cir::UnaryOpKind::Inc, InVal);
2891
+ else
2892
+ IncDecVal = builder.create <mlir::cir::UnaryOp>(
2893
+ Loc, mlir::cir::UnaryOpKind::Dec, InVal);
2894
+
2895
+ buildStoreOfComplex (Loc, IncDecVal, LV);
2896
+ if (getLangOpts ().OpenMP )
2897
+ assert (!UnimplementedFeature::openMP ());
2898
+
2899
+ return isPre ? IncDecVal : InVal;
2900
+ }
0 commit comments