diff --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp --- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp +++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp @@ -1717,6 +1717,10 @@ using DivFOpLowering = VectorConvertToLLVMPattern; using ExpOpLowering = VectorConvertToLLVMPattern; using Exp2OpLowering = VectorConvertToLLVMPattern; +using FPExtOpLowering = VectorConvertToLLVMPattern; +using FPToSIOpLowering = VectorConvertToLLVMPattern; +using FPToUIOpLowering = VectorConvertToLLVMPattern; +using FPTruncOpLowering = VectorConvertToLLVMPattern; using FloorFOpLowering = VectorConvertToLLVMPattern; using FmaFOpLowering = VectorConvertToLLVMPattern; using Log10OpLowering = @@ -1729,6 +1733,7 @@ using OrOpLowering = VectorConvertToLLVMPattern; using PowFOpLowering = VectorConvertToLLVMPattern; using RemFOpLowering = VectorConvertToLLVMPattern; +using SIToFPOpLowering = VectorConvertToLLVMPattern; using SelectOpLowering = VectorConvertToLLVMPattern; using SignExtendIOpLowering = VectorConvertToLLVMPattern; @@ -1744,6 +1749,8 @@ using SqrtOpLowering = VectorConvertToLLVMPattern; using SubFOpLowering = VectorConvertToLLVMPattern; using SubIOpLowering = VectorConvertToLLVMPattern; +using TruncateIOpLowering = VectorConvertToLLVMPattern; +using UIToFPOpLowering = VectorConvertToLLVMPattern; using UnsignedDivIOpLowering = VectorConvertToLLVMPattern; using UnsignedRemIOpLowering = @@ -3112,41 +3119,6 @@ } }; -struct SIToFPLowering - : public OneToOneConvertToLLVMPattern { - using Super::Super; -}; - -struct UIToFPLowering - : public OneToOneConvertToLLVMPattern { - using Super::Super; -}; - -struct FPExtLowering - : public OneToOneConvertToLLVMPattern { - using Super::Super; -}; - -struct FPToSILowering - : public OneToOneConvertToLLVMPattern { - using Super::Super; -}; - -struct FPToUILowering - : public OneToOneConvertToLLVMPattern { - using Super::Super; -}; - -struct FPTruncLowering - : public OneToOneConvertToLLVMPattern { - using Super::Super; -}; - -struct TruncateIOpLowering - : public OneToOneConvertToLLVMPattern { - using Super::Super; -}; - // Base class for LLVM IR lowering terminator operations with successors. template struct OneToOneLLVMTerminatorLowering @@ -3908,10 +3880,10 @@ Log10OpLowering, Log1pOpLowering, Log2OpLowering, - FPExtLowering, - FPToSILowering, - FPToUILowering, - FPTruncLowering, + FPExtOpLowering, + FPToSIOpLowering, + FPToUIOpLowering, + FPTruncOpLowering, IndexCastOpLowering, MulFOpLowering, MulIOpLowering, @@ -3922,7 +3894,7 @@ RemFOpLowering, ReturnOpLowering, RsqrtOpLowering, - SIToFPLowering, + SIToFPOpLowering, SelectOpLowering, ShiftLeftOpLowering, SignExtendIOpLowering, @@ -3936,7 +3908,7 @@ SubFOpLowering, SubIOpLowering, TruncateIOpLowering, - UIToFPLowering, + UIToFPOpLowering, UnsignedDivIOpLowering, UnsignedRemIOpLowering, UnsignedShiftRightOpLowering, diff --git a/mlir/test/Conversion/StandardToLLVM/convert-nd-vector-to-llvmir.mlir b/mlir/test/Conversion/StandardToLLVM/convert-nd-vector-to-llvmir.mlir --- a/mlir/test/Conversion/StandardToLLVM/convert-nd-vector-to-llvmir.mlir +++ b/mlir/test/Conversion/StandardToLLVM/convert-nd-vector-to-llvmir.mlir @@ -47,3 +47,94 @@ %0 = zexti %arg0: vector<1x2x3xi32> to vector<1x2x3xi64> return } + +// CHECK-LABEL: @sitofp +func @sitofp_vector(%arg0 : vector<1x2x3xi32>) -> vector<1x2x3xf32> { + // CHECK: llvm.mlir.undef : !llvm.array<1 x array<2 x vector<3xf32>>> + // CHECK: llvm.extractvalue %{{.*}}[0, 0] : !llvm.array<1 x array<2 x vector<3xi32>>> + // CHECK: llvm.sitofp %{{.*}} : vector<3xi32> to vector<3xf32> + // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[0, 0] : !llvm.array<1 x array<2 x vector<3xf32>>> + // CHECK: llvm.extractvalue %{{.*}}[0, 1] : !llvm.array<1 x array<2 x vector<3xi32>>> + // CHECK: llvm.sitofp %{{.*}} : vector<3xi32> to vector<3xf32> + // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[0, 1] : !llvm.array<1 x array<2 x vector<3xf32>>> + %0 = sitofp %arg0: vector<1x2x3xi32> to vector<1x2x3xf32> + return %0 : vector<1x2x3xf32> +} + +// CHECK-LABEL: @uitofp +func @uitofp_vector(%arg0 : vector<1x2x3xi32>) -> vector<1x2x3xf32> { + // CHECK: llvm.mlir.undef : !llvm.array<1 x array<2 x vector<3xf32>>> + // CHECK: llvm.extractvalue %{{.*}}[0, 0] : !llvm.array<1 x array<2 x vector<3xi32>>> + // CHECK: llvm.uitofp %{{.*}} : vector<3xi32> to vector<3xf32> + // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[0, 0] : !llvm.array<1 x array<2 x vector<3xf32>>> + // CHECK: llvm.extractvalue %{{.*}}[0, 1] : !llvm.array<1 x array<2 x vector<3xi32>>> + // CHECK: llvm.uitofp %{{.*}} : vector<3xi32> to vector<3xf32> + // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[0, 1] : !llvm.array<1 x array<2 x vector<3xf32>>> + %0 = uitofp %arg0: vector<1x2x3xi32> to vector<1x2x3xf32> + return %0 : vector<1x2x3xf32> +} + +// CHECK-LABEL: @fptosi +func @fptosi_vector(%arg0 : vector<1x2x3xf32>) -> vector<1x2x3xi32> { + // CHECK: llvm.mlir.undef : !llvm.array<1 x array<2 x vector<3xi32>>> + // CHECK: llvm.extractvalue %{{.*}}[0, 0] : !llvm.array<1 x array<2 x vector<3xf32>>> + // CHECK: llvm.fptosi %{{.*}} : vector<3xf32> to vector<3xi32> + // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[0, 0] : !llvm.array<1 x array<2 x vector<3xi32>>> + // CHECK: llvm.extractvalue %{{.*}}[0, 1] : !llvm.array<1 x array<2 x vector<3xf32>>> + // CHECK: llvm.fptosi %{{.*}} : vector<3xf32> to vector<3xi32> + // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[0, 1] : !llvm.array<1 x array<2 x vector<3xi32>>> + %0 = fptosi %arg0: vector<1x2x3xf32> to vector<1x2x3xi32> + return %0 : vector<1x2x3xi32> +} + +// CHECK-LABEL: @fptoui +func @fptoui_vector(%arg0 : vector<1x2x3xf32>) -> vector<1x2x3xi32> { + // CHECK: llvm.mlir.undef : !llvm.array<1 x array<2 x vector<3xi32>>> + // CHECK: llvm.extractvalue %{{.*}}[0, 0] : !llvm.array<1 x array<2 x vector<3xf32>>> + // CHECK: llvm.fptoui %{{.*}} : vector<3xf32> to vector<3xi32> + // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[0, 0] : !llvm.array<1 x array<2 x vector<3xi32>>> + // CHECK: llvm.extractvalue %{{.*}}[0, 1] : !llvm.array<1 x array<2 x vector<3xf32>>> + // CHECK: llvm.fptoui %{{.*}} : vector<3xf32> to vector<3xi32> + // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[0, 1] : !llvm.array<1 x array<2 x vector<3xi32>>> + %0 = fptoui %arg0: vector<1x2x3xf32> to vector<1x2x3xi32> + return %0 : vector<1x2x3xi32> +} + +// CHECK-LABEL: @fpext +func @fpext_vector(%arg0 : vector<1x2x3xf16>) -> vector<1x2x3xf64> { + // CHECK: llvm.mlir.undef : !llvm.array<1 x array<2 x vector<3xf64>>> + // CHECK: llvm.extractvalue %{{.*}}[0, 0] : !llvm.array<1 x array<2 x vector<3xf16>>> + // CHECK: llvm.fpext %{{.*}} : vector<3xf16> to vector<3xf64> + // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[0, 0] : !llvm.array<1 x array<2 x vector<3xf64>>> + // CHECK: llvm.extractvalue %{{.*}}[0, 1] : !llvm.array<1 x array<2 x vector<3xf16>>> + // CHECK: llvm.fpext %{{.*}} : vector<3xf16> to vector<3xf64> + // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[0, 1] : !llvm.array<1 x array<2 x vector<3xf64>>> + %0 = fpext %arg0: vector<1x2x3xf16> to vector<1x2x3xf64> + return %0 : vector<1x2x3xf64> +} + +// CHECK-LABEL: @fptrunc +func @fptrunc_vector(%arg0 : vector<1x2x3xf64>) -> vector<1x2x3xf16> { + // CHECK: llvm.mlir.undef : !llvm.array<1 x array<2 x vector<3xf16>>> + // CHECK: llvm.extractvalue %{{.*}}[0, 0] : !llvm.array<1 x array<2 x vector<3xf64>>> + // CHECK: llvm.fptrunc %{{.*}} : vector<3xf64> to vector<3xf16> + // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[0, 0] : !llvm.array<1 x array<2 x vector<3xf16>>> + // CHECK: llvm.extractvalue %{{.*}}[0, 1] : !llvm.array<1 x array<2 x vector<3xf64>>> + // CHECK: llvm.fptrunc %{{.*}} : vector<3xf64> to vector<3xf16> + // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[0, 1] : !llvm.array<1 x array<2 x vector<3xf16>>> + %0 = fptrunc %arg0: vector<1x2x3xf64> to vector<1x2x3xf16> + return %0 : vector<1x2x3xf16> +} + +// CHECK-LABEL: @trunci +func @trunci_vector(%arg0 : vector<1x2x3xi64>) -> vector<1x2x3xi16> { + // CHECK: llvm.mlir.undef : !llvm.array<1 x array<2 x vector<3xi16>>> + // CHECK: llvm.extractvalue %{{.*}}[0, 0] : !llvm.array<1 x array<2 x vector<3xi64>>> + // CHECK: llvm.trunc %{{.*}} : vector<3xi64> to vector<3xi16> + // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[0, 0] : !llvm.array<1 x array<2 x vector<3xi16>>> + // CHECK: llvm.extractvalue %{{.*}}[0, 1] : !llvm.array<1 x array<2 x vector<3xi64>>> + // CHECK: llvm.trunc %{{.*}} : vector<3xi64> to vector<3xi16> + // CHECK: llvm.insertvalue %{{.*}}, %{{.*}}[0, 1] : !llvm.array<1 x array<2 x vector<3xi16>>> + %0 = trunci %arg0: vector<1x2x3xi64> to vector<1x2x3xi16> + return %0 : vector<1x2x3xi16> +}