[PATCH] D72137: [mlir][spirv] Add lowering for std.fpext, std.fptrunc, std.sitofp.
Lei Zhang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 7 18:30:38 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7e7f849a6d94: [mlir][spirv] Add lowering for std.fpext, std.fptrunc, std.sitofp. (authored by antiagainst).
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D72137?vs=236128&id=236739#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D72137/new/
https://reviews.llvm.org/D72137
Files:
mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRV.td
mlir/test/Conversion/StandardToSPIRV/std-to-spirv.mlir
Index: mlir/test/Conversion/StandardToSPIRV/std-to-spirv.mlir
===================================================================
--- mlir/test/Conversion/StandardToSPIRV/std-to-spirv.mlir
+++ mlir/test/Conversion/StandardToSPIRV/std-to-spirv.mlir
@@ -175,6 +175,28 @@
}
//===----------------------------------------------------------------------===//
+// std.fpext
+//===----------------------------------------------------------------------===//
+
+// CHECK-LABEL: @fpext
+func @fpext(%arg0 : f32) {
+ // CHECK: spv.FConvert
+ %0 = std.fpext %arg0 : f32 to f64
+ return
+}
+
+//===----------------------------------------------------------------------===//
+// std.fptrunc
+//===----------------------------------------------------------------------===//
+
+// CHECK-LABEL: @fptrunc
+func @fptrunc(%arg0 : f64) {
+ // CHECK: spv.FConvert
+ %0 = std.fptrunc %arg0 : f64 to f32
+ return
+}
+
+//===----------------------------------------------------------------------===//
// std.select
//===----------------------------------------------------------------------===//
@@ -185,3 +207,14 @@
%1 = select %0, %arg0, %arg1 : i32
return
}
+
+//===----------------------------------------------------------------------===//
+// std.sitofp
+//===----------------------------------------------------------------------===//
+
+// CHECK-LABEL: @sitofp
+func @sitofp(%arg0 : i32) {
+ // CHECK: spv.ConvertSToF
+ %0 = std.sitofp %arg0 : i32 to f32
+ return
+}
Index: mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRV.td
===================================================================
--- mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRV.td
+++ mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRV.td
@@ -20,6 +20,10 @@
Pat<(src SPV_ScalarOrVectorOf<type>:$l, SPV_ScalarOrVectorOf<type>:$r),
(tgt $l, $r)>;
+class UnaryOpPattern<Type type, Op src, Op tgt> :
+ Pat<(src type:$input),
+ (tgt $input)>;
+
def : BinaryOpPattern<SPV_Bool, AndOp, SPV_LogicalAndOp>;
def : BinaryOpPattern<SPV_Bool, OrOp, SPV_LogicalOrOp>;
def : BinaryOpPattern<SPV_Float, AddFOp, SPV_FAddOp>;
@@ -28,6 +32,10 @@
def : BinaryOpPattern<SPV_Float, RemFOp, SPV_FRemOp>;
def : BinaryOpPattern<SPV_Float, SubFOp, SPV_FSubOp>;
+def : UnaryOpPattern<SPV_Integer, SIToFPOp, SPV_ConvertSToFOp>;
+def : UnaryOpPattern<SPV_Float, FPExtOp, SPV_FConvertOp>;
+def : UnaryOpPattern<SPV_Float, FPTruncOp, SPV_FConvertOp>;
+
// Constant Op
// TODO(ravishankarm): Handle lowering other constant types.
def : Pat<(ConstantOp:$result $valueAttr),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72137.236739.patch
Type: text/x-patch
Size: 2566 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200108/a570d745/attachment.bin>
More information about the llvm-commits
mailing list