[PATCH] D80152: Added a TanOp to SPIR-V dialect GLSL ops
George Mitenkov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 18 13:00:56 PDT 2020
georgemitenkov created this revision.
georgemitenkov added reviewers: antiagainst, mravishankar.
Herald added subscribers: llvm-commits, jurahul, Kayjukh, frgossen, grosul1, bader, Joonsoo, stephenneuendorffer, liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, nicolasvasilache, shauheen, jpienaar, rriddle, mehdi_amini.
Herald added a project: LLVM.
Implemented tangent op from SPIR-V's GLSL extended instruction set. Added a round-trip and
serialization/deserialization tests for the op.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D80152
Files:
mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td
mlir/test/Dialect/SPIRV/Serialization/glsl-ops.mlir
mlir/test/Dialect/SPIRV/glslops.mlir
Index: mlir/test/Dialect/SPIRV/glslops.mlir
===================================================================
--- mlir/test/Dialect/SPIRV/glslops.mlir
+++ mlir/test/Dialect/SPIRV/glslops.mlir
@@ -139,3 +139,19 @@
%2 = spv.GLSL.Sin %arg0 : vector<3xf16>
return
}
+
+//===----------------------------------------------------------------------===//
+// spv.GLSL.Tan
+//===----------------------------------------------------------------------===//
+
+func @tan(%arg0 : f32) -> () {
+ // CHECK: spv.GLSL.Tan {{%.*}} : f32
+ %2 = spv.GLSL.Tan %arg0 : f32
+ return
+}
+
+func @tanvec(%arg0 : vector<3xf16>) -> () {
+ // CHECK: spv.GLSL.Tan {{%.*}} : vector<3xf16>
+ %2 = spv.GLSL.Tan %arg0 : vector<3xf16>
+ return
+}
Index: mlir/test/Dialect/SPIRV/Serialization/glsl-ops.mlir
===================================================================
--- mlir/test/Dialect/SPIRV/Serialization/glsl-ops.mlir
+++ mlir/test/Dialect/SPIRV/Serialization/glsl-ops.mlir
@@ -12,6 +12,8 @@
%3 = spv.GLSL.Cos %arg0 : f32
// CHECK: {{%.*}} = spv.GLSL.Sin {{%.*}} : f32
%4 = spv.GLSL.Sin %arg0 : f32
+ // CHECK: {{%.*}} = spv.GLSL.Tan {{%.*}} : f32
+ %5 = spv.GLSL.Tan %arg0 : f32
spv.Return
}
}
Index: mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td
===================================================================
--- mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td
+++ mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td
@@ -233,6 +233,38 @@
// -----
+def SPV_GLSLTanOp : SPV_GLSLUnaryArithmeticOp<"Tan", 15, SPV_Float16or32> {
+ let summary = "Tangent of operand in radians";
+
+ let description = [{
+ The standard trigonometric tangent of x radians.
+
+ The operand x must be a scalar or vector whose component type is 16-bit or
+ 32-bit floating-point.
+
+ Result Type and the type of x must be the same type. Results are computed
+ per component.
+
+ <!-- End of AutoGen section -->
+ ```
+ restricted-float-scalar-type ::= `f16` | `f32`
+ restricted-float-scalar-vector-type ::=
+ restricted-float-scalar-type |
+ `vector<` integer-literal `x` restricted-float-scalar-type `>`
+ tan-op ::= ssa-id `=` `spv.GLSL.Tan` ssa-use `:`
+ restricted-float-scalar-vector-type
+ ```
+ #### Example:
+
+ ```mlir
+ %2 = spv.GLSL.Tan %0 : f32
+ %3 = spv.GLSL.Tan %1 : vector<3xf16>
+ ```
+ }];
+}
+
+// -----
+
def SPV_GLSLExpOp : SPV_GLSLUnaryArithmeticOp<"Exp", 27, SPV_Float16or32> {
let summary = "Exponentiation of Operand 1";
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80152.264700.patch
Type: text/x-patch
Size: 2536 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200518/c26e55e8/attachment.bin>
More information about the llvm-commits
mailing list