@@ -1464,25 +1464,24 @@ mlir::Attribute ConstantEmitter::tryEmitPrivate(const APValue &value,
1464
1464
case APValue::ComplexInt:
1465
1465
case APValue::ComplexFloat: {
1466
1466
mlir::Type desiredType = cgm.convertType (destType);
1467
- cir::ComplexType complexType =
1468
- mlir::dyn_cast<cir::ComplexType>(desiredType);
1467
+ auto complexType = mlir::dyn_cast<cir::ComplexType>(desiredType);
1469
1468
1470
1469
mlir::Type complexElemTy = complexType.getElementType ();
1471
1470
if (isa<cir::IntType>(complexElemTy)) {
1472
- llvm::APSInt real = value.getComplexIntReal ();
1473
- llvm::APSInt imag = value.getComplexIntImag ();
1474
- return builder. getAttr < cir::ConstComplexAttr>(
1475
- complexType, cir::IntAttr::get (complexElemTy, real),
1476
- cir::IntAttr::get (complexElemTy, imag));
1471
+ const llvm::APSInt & real = value.getComplexIntReal ();
1472
+ const llvm::APSInt & imag = value.getComplexIntImag ();
1473
+ return cir::ConstComplexAttr::get (builder. getContext (), complexType,
1474
+ cir::IntAttr::get (complexElemTy, real),
1475
+ cir::IntAttr::get (complexElemTy, imag));
1477
1476
}
1478
1477
1479
1478
assert (isa<cir::FPTypeInterface>(complexElemTy) &&
1480
1479
" expected floating-point type" );
1481
- llvm::APFloat real = value.getComplexFloatReal ();
1482
- llvm::APFloat imag = value.getComplexFloatImag ();
1483
- return builder. getAttr < cir::ConstComplexAttr>(
1484
- complexType, cir::FPAttr::get (complexElemTy, real),
1485
- cir::FPAttr::get (complexElemTy, imag));
1480
+ const llvm::APFloat & real = value.getComplexFloatReal ();
1481
+ const llvm::APFloat & imag = value.getComplexFloatImag ();
1482
+ return cir::ConstComplexAttr::get (builder. getContext (), complexType,
1483
+ cir::FPAttr::get (complexElemTy, real),
1484
+ cir::FPAttr::get (complexElemTy, imag));
1486
1485
}
1487
1486
case APValue::FixedPoint:
1488
1487
case APValue::AddrLabelDiff:
0 commit comments