[Mlir-commits] [mlir] 3f07cab - [mlir][StandardToLLVM] Add support for lowering FPToSIOp to LLVM.

Hanhan Wang llvmlistbot at llvm.org
Mon May 11 01:29:47 PDT 2020


Author: Hanhan Wang
Date: 2020-05-11T01:29:24-07:00
New Revision: 3f07cab3124d34e512c61f453b3ce157a263b81a

URL: https://github.com/llvm/llvm-project/commit/3f07cab3124d34e512c61f453b3ce157a263b81a
DIFF: https://github.com/llvm/llvm-project/commit/3f07cab3124d34e512c61f453b3ce157a263b81a.diff

LOG: [mlir][StandardToLLVM] Add support for lowering FPToSIOp to LLVM.

Summary: Depends On D79374

Differential Revision: https://reviews.llvm.org/D79455

Added: 
    

Modified: 
    mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
    mlir/test/Conversion/StandardToLLVM/convert-to-llvmir.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
index e9fd083b198e..bdaa989c65c7 100644
--- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
+++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
@@ -2304,6 +2304,11 @@ struct FPExtLowering
   using Super::Super;
 };
 
+struct FPToSILowering
+    : public OneToOneConvertToLLVMPattern<FPToSIOp, LLVM::FPToSIOp> {
+  using Super::Super;
+};
+
 struct FPTruncLowering
     : public OneToOneConvertToLLVMPattern<FPTruncOp, LLVM::FPTruncOp> {
   using Super::Super;
@@ -2975,6 +2980,7 @@ void mlir::populateStdToLLVMNonMemoryConversionPatterns(
       Log10OpLowering,
       Log2OpLowering,
       FPExtLowering,
+      FPToSILowering,
       FPTruncLowering,
       ImOpLowering,
       IndexCastOpLowering,

diff  --git a/mlir/test/Conversion/StandardToLLVM/convert-to-llvmir.mlir b/mlir/test/Conversion/StandardToLLVM/convert-to-llvmir.mlir
index cd16539edf02..9272e579e708 100644
--- a/mlir/test/Conversion/StandardToLLVM/convert-to-llvmir.mlir
+++ b/mlir/test/Conversion/StandardToLLVM/convert-to-llvmir.mlir
@@ -618,6 +618,20 @@ func @fpext_vector(%arg0 : vector<2xf16>, %arg1 : vector<2xf32>) {
   return
 }
 
+// Checking conversion of floating point to integer types.
+// CHECK-LABEL: @fptosi
+func @fptosi(%arg0 : f32, %arg1 : f64) {
+// CHECK-NEXT: = llvm.fptosi {{.*}} : !llvm.float to !llvm.i32
+  %0 = fptosi %arg0: f32 to i32
+// CHECK-NEXT: = llvm.fptosi {{.*}} : !llvm.float to !llvm.i64
+  %1 = fptosi %arg0: f32 to i64
+// CHECK-NEXT: = llvm.fptosi {{.*}} : !llvm.double to !llvm.i32
+  %2 = fptosi %arg1: f64 to i32
+// CHECK-NEXT: = llvm.fptosi {{.*}} : !llvm.double to !llvm.i64
+  %3 = fptosi %arg1: f64 to i64
+  return
+}
+
 // Checking conversion of integer types to floating point.
 // CHECK-LABEL: @fptrunc
 func @fptrunc(%arg0 : f32, %arg1 : f64) {


        


More information about the Mlir-commits mailing list