[clang] [CIR] Upstream CastOp and scalar conversions (PR #130690)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 12 14:47:22 PDT 2025
================
@@ -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());
+ auto sourceValue = adaptor.getOperands().front();
----------------
erichkeane wrote:
A LOT of uses of 'auto' in this function that don't match our coding standard.
https://github.com/llvm/llvm-project/pull/130690
More information about the cfe-commits
mailing list