@@ -171,25 +171,6 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
171
171
CGF.getLoc (E->getExprLoc ()), Ty,
172
172
Builder.getAttr <mlir::cir::FPAttr>(Ty, E->getValue ()));
173
173
}
174
- mlir::Value VisitImaginaryLiteral (const ImaginaryLiteral *E) {
175
- auto Loc = CGF.getLoc (E->getExprLoc ());
176
- auto Ty = CGF.getCIRType (E->getType ()).cast <mlir::cir::ComplexType>();
177
- auto ElementTy = Ty.getElementTy ();
178
-
179
- mlir::TypedAttr Real = Builder.getZeroInitAttr (ElementTy);
180
- mlir::TypedAttr Imag;
181
- if (ElementTy.isa <mlir::cir::IntType>()) {
182
- auto RealValue = cast<IntegerLiteral>(E->getSubExpr ())->getValue ();
183
- Imag = mlir::cir::IntAttr::get (ElementTy, RealValue);
184
- } else if (ElementTy.isa <mlir::cir::CIRFPTypeInterface>()) {
185
- auto RealValue = cast<FloatingLiteral>(E->getSubExpr ())->getValue ();
186
- Imag = mlir::cir::FPAttr::get (ElementTy, RealValue);
187
- } else
188
- llvm_unreachable (" unexpected complex element type" );
189
-
190
- auto Attr = mlir::cir::ComplexAttr::get (Ty, Real, Imag);
191
- return Builder.getConstant (Loc, Attr);
192
- }
193
174
mlir::Value VisitCharacterLiteral (const CharacterLiteral *E) {
194
175
mlir::Type Ty = CGF.getCIRType (E->getType ());
195
176
auto loc = CGF.getLoc (E->getExprLoc ());
@@ -746,45 +727,9 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
746
727
Result.Loc = E->getSourceRange ();
747
728
// TODO: Result.FPFeatures
748
729
Result.E = E;
749
-
750
- buildComplexPromotion (Result);
751
-
752
730
return Result;
753
731
}
754
732
755
- // If any of the two operands of a binary operation is of complex type,
756
- // ensure both operands are promoted to complex type.
757
- void buildComplexPromotion (BinOpInfo &Info) {
758
- auto LHSTy = Info.LHS .getType ().dyn_cast <mlir::cir::ComplexType>();
759
- auto RHSTy = Info.RHS .getType ().dyn_cast <mlir::cir::ComplexType>();
760
- if (!LHSTy && !RHSTy)
761
- return ;
762
-
763
- if (LHSTy && RHSTy)
764
- return ;
765
-
766
- // We need to promote *Scalar to ComplexTy.
767
- mlir::Value *Scalar;
768
- mlir::cir::ComplexType ComplexTy;
769
- if (LHSTy) {
770
- Scalar = &Info.RHS ;
771
- ComplexTy = LHSTy;
772
- } else {
773
- Scalar = &Info.LHS ;
774
- ComplexTy = RHSTy;
775
- }
776
-
777
- mlir::cir::CastKind Kind;
778
- if (Scalar->getType ().isa <mlir::cir::IntType>())
779
- Kind = mlir::cir::CastKind::int_to_complex;
780
- else if (Scalar->getType ().isa <mlir::cir::CIRFPTypeInterface>())
781
- Kind = mlir::cir::CastKind::float_to_complex;
782
- else
783
- llvm_unreachable (" unexpected complex promotion candidate" );
784
-
785
- *Scalar = Builder.createCast (Kind, *Scalar, ComplexTy);
786
- }
787
-
788
733
mlir::Value buildMul (const BinOpInfo &Ops);
789
734
mlir::Value buildDiv (const BinOpInfo &Ops);
790
735
mlir::Value buildRem (const BinOpInfo &Ops);
@@ -808,9 +753,7 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
808
753
// codegen.
809
754
QualType getPromotionType (QualType Ty) {
810
755
if (auto *CT = Ty->getAs <ComplexType>()) {
811
- QualType ElementType = CT->getElementType ();
812
- if (ElementType.UseExcessPrecision (CGF.getContext ()))
813
- llvm_unreachable (" NYI" );
756
+ llvm_unreachable (" NYI" );
814
757
}
815
758
if (Ty.UseExcessPrecision (CGF.getContext ()))
816
759
llvm_unreachable (" NYI" );
@@ -820,8 +763,7 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
820
763
// Binary operators and binary compound assignment operators.
821
764
#define HANDLEBINOP (OP ) \
822
765
mlir::Value VisitBin##OP(const BinaryOperator *E) { \
823
- auto binOpInfo = buildBinOps (E); \
824
- return build##OP (binOpInfo); \
766
+ return build##OP (buildBinOps (E)); \
825
767
} \
826
768
mlir::Value VisitBin##OP##Assign(const CompoundAssignOperator *E) { \
827
769
return buildCompoundAssign (E, &ScalarExprEmitter::build##OP); \
@@ -1549,25 +1491,14 @@ mlir::Value ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
1549
1491
llvm_unreachable (" NYI" );
1550
1492
case CK_CopyAndAutoreleaseBlockObject:
1551
1493
llvm_unreachable (" NYI" );
1552
- case CK_IntegralRealToComplex: {
1553
- auto DestComplexTy = ConvertType (DestTy).cast <mlir::cir::ComplexType>();
1554
- auto Src = Visit (const_cast <Expr *>(E));
1555
- return Builder.createCast (mlir::cir::CastKind::int_to_complex, Src,
1556
- DestComplexTy);
1557
- }
1558
- case CK_FloatingRealToComplex: {
1559
- auto DestComplexTy = ConvertType (DestTy).cast <mlir::cir::ComplexType>();
1560
- auto Src = Visit (const_cast <Expr *>(E));
1561
- return Builder.createCast (mlir::cir::CastKind::float_to_complex, Src,
1562
- DestComplexTy);
1563
- }
1494
+ case CK_FloatingRealToComplex:
1495
+ llvm_unreachable (" NYI" );
1564
1496
case CK_FloatingComplexCast:
1497
+ llvm_unreachable (" NYI" );
1565
1498
case CK_IntegralComplexToFloatingComplex:
1566
- case CK_FloatingComplexToIntegralComplex: {
1567
- auto DestComplexTy = ConvertType (DestTy).cast <mlir::cir::ComplexType>();
1568
- auto Src = Visit (const_cast <Expr *>(E));
1569
- return Builder.createCast (mlir::cir::CastKind::complex, Src, DestComplexTy);
1570
- }
1499
+ llvm_unreachable (" NYI" );
1500
+ case CK_FloatingComplexToIntegralComplex:
1501
+ llvm_unreachable (" NYI" );
1571
1502
case CK_ConstructorConversion:
1572
1503
llvm_unreachable (" NYI" );
1573
1504
case CK_ToUnion:
@@ -1659,15 +1590,13 @@ mlir::Value ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
1659
1590
case CK_MemberPointerToBoolean:
1660
1591
llvm_unreachable (" NYI" );
1661
1592
case CK_FloatingComplexToReal:
1662
- case CK_IntegralComplexToReal: {
1663
- auto Src = Visit (const_cast <Expr *>(E));
1664
- return Builder.createComplexReal (CGF.getLoc (CE->getSourceRange ()), Src);
1665
- }
1593
+ llvm_unreachable (" NYI" );
1594
+ case CK_IntegralComplexToReal:
1595
+ llvm_unreachable (" NYI" );
1666
1596
case CK_FloatingComplexToBoolean:
1667
- case CK_IntegralComplexToBoolean: {
1668
- auto Src = Visit (const_cast <Expr *>(E));
1669
- return Builder.createComplexIsZero (CGF.getLoc (CE->getSourceRange ()), Src);
1670
- }
1597
+ llvm_unreachable (" NYI" );
1598
+ case CK_IntegralComplexToBoolean:
1599
+ llvm_unreachable (" NYI" );
1671
1600
case CK_ZeroToOCLOpaqueType:
1672
1601
llvm_unreachable (" NYI" );
1673
1602
case CK_IntToOCLSampler:
0 commit comments