[clang] [CIR] Upstream global initialization for ComplexType (PR #141369)

Henrich Lauko via cfe-commits cfe-commits at lists.llvm.org
Sun May 25 11:02:12 PDT 2025


================
@@ -226,6 +227,42 @@ mlir::Value CIRAttrToValue::visitCirAttr(cir::IntAttr intAttr) {
       loc, converter->convertType(intAttr.getType()), intAttr.getValue());
 }
 
+/// FPAttr visitor.
+mlir::Value CIRAttrToValue::visitCirAttr(cir::FPAttr fltAttr) {
+  mlir::Location loc = parentOp->getLoc();
+  return rewriter.create<mlir::LLVM::ConstantOp>(
+      loc, converter->convertType(fltAttr.getType()), fltAttr.getValue());
+}
+
+/// ConstComplexAttr visitor.
+mlir::Value CIRAttrToValue::visitCirAttr(cir::ConstComplexAttr complexAttr) {
+  auto complexType = mlir::cast<cir::ComplexType>(complexAttr.getType());
+  auto complexElemTy = complexType.getElementType();
+  auto complexElemLLVMTy = converter->convertType(complexElemTy);
----------------
xlauko wrote:

```suggestion
  mlir::Type complexElemTy = complexType.getElementType();
  mlir::Type complexElemLLVMTy = converter->convertType(complexElemTy);
```

https://github.com/llvm/llvm-project/pull/141369


More information about the cfe-commits mailing list