================
@@ -247,6 +280,179 @@ struct ConvertCIRToLLVMPass
StringRef getArgument() const override { return "cir-flat-to-llvm"; }
};
+mlir::Type CIRToLLVMCastOpLowering::convertTy(mlir::Type ty) const {
+ return getTypeConverter()->convertType(ty);
+}
+
+mlir::LogicalResult CIRToLLVMCastOpLowering::matchAndRewrite(
+ cir::CastOp castOp, OpAdaptor adaptor,
+ mlir::ConversionPatternRewriter &rewriter) const {
+ // For arithmetic conversions, LLVM IR uses the same instruction to convert
+ // both individual scalars and entire vectors. This lowering pass handles
+ // both situations.
+
+ switch (castOp.getKind()) {
+ case cir::CastKind::array_to_ptrdecay: {
+ const auto ptrTy = mlir::cast<cir::PointerType>(castOp.getType());
+ mlir::Value sourceValue = adaptor.getOperands().front();
+ mlir::Type targetType = convertTy(ptrTy);
+ mlir::Type elementTy = convertTypeForMemory(*getTypeConverter(),
dataLayout,
+ ptrTy.getPointee());
+ auto offset = llvm::SmallVector<mlir::LLVM::GEPArg>{0};
----------------
erichkeane wrote:
```suggestion
llvm::SmallVector<mlir::LLVM::GEPArg> offset{0};
```
https://github.com/llvm/llvm-project/pull/130690
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits