Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions clang/lib/CIR/CodeGen/CIRGenExprConst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2052,25 +2052,24 @@ mlir::Attribute ConstantEmitter::tryEmitPrivate(const APValue &Value,
case APValue::ComplexFloat:
case APValue::ComplexInt: {
mlir::Type desiredType = CGM.convertType(DestType);
cir::ComplexType complexType =
mlir::dyn_cast<cir::ComplexType>(desiredType);
auto complexType = mlir::dyn_cast<cir::ComplexType>(desiredType);

mlir::Type complexElemTy = complexType.getElementType();
if (isa<cir::IntType>(complexElemTy)) {
llvm::APSInt real = Value.getComplexIntReal();
llvm::APSInt imag = Value.getComplexIntImag();
return builder.getAttr<cir::ComplexAttr>(
complexType, cir::IntAttr::get(complexElemTy, real),
cir::IntAttr::get(complexElemTy, imag));
const llvm::APSInt &real = Value.getComplexIntReal();
const llvm::APSInt &imag = Value.getComplexIntImag();
return cir::ComplexAttr::get(complexType,
cir::IntAttr::get(complexElemTy, real),
cir::IntAttr::get(complexElemTy, imag));
}

assert(isa<cir::FPTypeInterface>(complexElemTy) &&
"expected floating-point type");
llvm::APFloat real = Value.getComplexFloatReal();
llvm::APFloat imag = Value.getComplexFloatImag();
return builder.getAttr<cir::ComplexAttr>(
complexType, cir::FPAttr::get(complexElemTy, real),
cir::FPAttr::get(complexElemTy, imag));
const llvm::APFloat &real = Value.getComplexFloatReal();
const llvm::APFloat &imag = Value.getComplexFloatImag();
return cir::ComplexAttr::get(complexType,
cir::FPAttr::get(complexElemTy, real),
cir::FPAttr::get(complexElemTy, imag));
}
case APValue::FixedPoint:
case APValue::AddrLabelDiff:
Expand Down