@@ -2052,25 +2052,24 @@ mlir::Attribute ConstantEmitter::tryEmitPrivate(const APValue &Value,
20522052 case APValue::ComplexFloat:
20532053 case APValue::ComplexInt: {
20542054 mlir::Type desiredType = CGM.convertType (DestType);
2055- cir::ComplexType complexType =
2056- mlir::dyn_cast<cir::ComplexType>(desiredType);
2055+ auto complexType = mlir::dyn_cast<cir::ComplexType>(desiredType);
20572056
20582057 mlir::Type complexElemTy = complexType.getElementType ();
20592058 if (isa<cir::IntType>(complexElemTy)) {
2060- llvm::APSInt real = Value.getComplexIntReal ();
2061- llvm::APSInt imag = Value.getComplexIntImag ();
2062- return builder. getAttr < cir::ComplexAttr>(
2063- complexType, cir::IntAttr::get (complexElemTy, real),
2064- cir::IntAttr::get (complexElemTy, imag));
2059+ const llvm::APSInt & real = Value.getComplexIntReal ();
2060+ const llvm::APSInt & imag = Value.getComplexIntImag ();
2061+ return cir::ComplexAttr::get (complexType,
2062+ cir::IntAttr::get (complexElemTy, real),
2063+ cir::IntAttr::get (complexElemTy, imag));
20652064 }
20662065
20672066 assert (isa<cir::FPTypeInterface>(complexElemTy) &&
20682067 " expected floating-point type" );
2069- llvm::APFloat real = Value.getComplexFloatReal ();
2070- llvm::APFloat imag = Value.getComplexFloatImag ();
2071- return builder. getAttr < cir::ComplexAttr>(
2072- complexType, cir::FPAttr::get (complexElemTy, real),
2073- cir::FPAttr::get (complexElemTy, imag));
2068+ const llvm::APFloat & real = Value.getComplexFloatReal ();
2069+ const llvm::APFloat & imag = Value.getComplexFloatImag ();
2070+ return cir::ComplexAttr::get (complexType,
2071+ cir::FPAttr::get (complexElemTy, real),
2072+ cir::FPAttr::get (complexElemTy, imag));
20742073 }
20752074 case APValue::FixedPoint:
20762075 case APValue::AddrLabelDiff:
0 commit comments