@@ -731,8 +731,9 @@ mlir::Value CirAttrToValue::visitCirAttr(cir::GlobalViewAttr globalAttr) {
731
731
}
732
732
auto resTy = addrOp.getType ();
733
733
auto eltTy = converter->convertType (sourceType);
734
- addrOp = rewriter.create <mlir::LLVM::GEPOp>(loc, resTy, eltTy, addrOp,
735
- indices, mlir::LLVM::GEPNoWrapFlags::inbounds);
734
+ addrOp = rewriter.create <mlir::LLVM::GEPOp>(
735
+ loc, resTy, eltTy, addrOp, indices,
736
+ mlir::LLVM::GEPNoWrapFlags::inbounds);
736
737
}
737
738
738
739
if (auto intTy = mlir::dyn_cast<cir::IntType>(globalAttr.getType ())) {
@@ -1205,8 +1206,9 @@ mlir::LogicalResult CIRToLLVMVTTAddrPointOpLowering::matchAndRewrite(
1205
1206
offsets.push_back (0 );
1206
1207
offsets.push_back (adaptor.getOffset ());
1207
1208
}
1208
- rewriter.replaceOpWithNewOp <mlir::LLVM::GEPOp>(op, resultType, eltType,
1209
- llvmAddr, offsets, mlir::LLVM::GEPNoWrapFlags::inbounds);
1209
+ rewriter.replaceOpWithNewOp <mlir::LLVM::GEPOp>(
1210
+ op, resultType, eltType, llvmAddr, offsets,
1211
+ mlir::LLVM::GEPNoWrapFlags::inbounds);
1210
1212
return mlir::success ();
1211
1213
}
1212
1214
@@ -1903,9 +1905,18 @@ mlir::LogicalResult CIRToLLVMConstantOpLowering::matchAndRewrite(
1903
1905
typeConverter->convertType (op.getType ()),
1904
1906
mlir::cast<cir::FPAttr>(op.getValue ()).getValue ());
1905
1907
} else if (auto complexTy = mlir::dyn_cast<cir::ComplexType>(op.getType ())) {
1908
+ mlir::Type complexElemTy = complexTy.getElementType ();
1909
+ mlir::Type complexElemLLVMTy = typeConverter->convertType (complexElemTy);
1910
+
1911
+ if (auto zeroInitAttr = mlir::dyn_cast<cir::ZeroAttr>(op.getValue ())) {
1912
+ mlir::TypedAttr zeroAttr = rewriter.getZeroAttr (complexElemLLVMTy);
1913
+ mlir::ArrayAttr array = rewriter.getArrayAttr ({zeroAttr, zeroAttr});
1914
+ rewriter.replaceOpWithNewOp <mlir::LLVM::ConstantOp>(
1915
+ op, getTypeConverter ()->convertType (op.getType ()), array);
1916
+ return mlir::success ();
1917
+ }
1918
+
1906
1919
auto complexAttr = mlir::cast<cir::ComplexAttr>(op.getValue ());
1907
- auto complexElemTy = complexTy.getElementType ();
1908
- auto complexElemLLVMTy = typeConverter->convertType (complexElemTy);
1909
1920
1910
1921
mlir::Attribute components[2 ];
1911
1922
if (mlir::isa<cir::IntType>(complexElemTy)) {
@@ -3881,8 +3892,9 @@ mlir::LogicalResult CIRToLLVMVTableAddrPointOpLowering::matchAndRewrite(
3881
3892
op.getAddressPointAttr ().getOffset ()};
3882
3893
3883
3894
assert (eltType && " Shouldn't ever be missing an eltType here" );
3884
- rewriter.replaceOpWithNewOp <mlir::LLVM::GEPOp>(op, targetType, eltType,
3885
- symAddr, offsets, mlir::LLVM::GEPNoWrapFlags::inbounds);
3895
+ rewriter.replaceOpWithNewOp <mlir::LLVM::GEPOp>(
3896
+ op, targetType, eltType, symAddr, offsets,
3897
+ mlir::LLVM::GEPNoWrapFlags::inbounds);
3886
3898
3887
3899
return mlir::success ();
3888
3900
}
@@ -3908,7 +3920,8 @@ mlir::LogicalResult CIRToLLVMVTableGetVirtualFnAddrOpLowering::matchAndRewrite(
3908
3920
llvm::SmallVector<mlir::LLVM::GEPArg> offsets =
3909
3921
llvm::SmallVector<mlir::LLVM::GEPArg>{op.getIndex ()};
3910
3922
rewriter.replaceOpWithNewOp <mlir::LLVM::GEPOp>(
3911
- op, targetType, eltType, adaptor.getVptr (), offsets, mlir::LLVM::GEPNoWrapFlags::inbounds);
3923
+ op, targetType, eltType, adaptor.getVptr (), offsets,
3924
+ mlir::LLVM::GEPNoWrapFlags::inbounds);
3912
3925
return mlir::success ();
3913
3926
}
3914
3927
@@ -4000,7 +4013,9 @@ mlir::LogicalResult CIRToLLVMInlineAsmOpLowering::matchAndRewrite(
4000
4013
op, llResTy, llvmOperands, op.getAsmStringAttr (), op.getConstraintsAttr (),
4001
4014
op.getSideEffectsAttr (),
4002
4015
/* is_align_stack*/ mlir::UnitAttr (),
4003
- /* tail_call_kind*/ mlir::LLVM::TailCallKindAttr::get (getContext (), mlir::LLVM::tailcallkind::TailCallKind::None),
4016
+ /* tail_call_kind*/
4017
+ mlir::LLVM::TailCallKindAttr::get (
4018
+ getContext (), mlir::LLVM::tailcallkind::TailCallKind::None),
4004
4019
mlir::LLVM::AsmDialectAttr::get (getContext (), llDialect),
4005
4020
rewriter.getArrayAttr (opAttrs));
4006
4021
0 commit comments