[Mlir-commits] [mlir] e984b7f - Added a TanOp to SPIR-V dialect GLSL ops
Lei Zhang
llvmlistbot at llvm.org
Tue May 19 06:15:40 PDT 2020
Author: George
Date: 2020-05-19T09:15:29-04:00
New Revision: e984b7f2a232cb799d6cf1e2f75a3162eca1267c
URL: https://github.com/llvm/llvm-project/commit/e984b7f2a232cb799d6cf1e2f75a3162eca1267c
DIFF: https://github.com/llvm/llvm-project/commit/e984b7f2a232cb799d6cf1e2f75a3162eca1267c.diff
LOG: Added a TanOp to SPIR-V dialect GLSL ops
Implemented tangent op from SPIR-V's GLSL extended instruction set.
Added a round-trip and serialization/deserialization tests for the op.
Differential Revision: https://reviews.llvm.org/D80152
Added:
Modified:
mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td
mlir/test/Dialect/SPIRV/Serialization/glsl-ops.mlir
mlir/test/Dialect/SPIRV/glslops.mlir
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td
index 68d6e2fbb34c..6064cc304359 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td
@@ -233,6 +233,38 @@ def SPV_GLSLSinOp : SPV_GLSLUnaryArithmeticOp<"Sin", 13, SPV_Float16or32> {
// -----
+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";
diff --git a/mlir/test/Dialect/SPIRV/Serialization/glsl-ops.mlir b/mlir/test/Dialect/SPIRV/Serialization/glsl-ops.mlir
index 6cca9f556317..b04195387f12 100644
--- a/mlir/test/Dialect/SPIRV/Serialization/glsl-ops.mlir
+++ b/mlir/test/Dialect/SPIRV/Serialization/glsl-ops.mlir
@@ -12,6 +12,8 @@ spv.module Logical GLSL450 requires #spv.vce<v1.0, [Shader], []> {
%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
}
}
diff --git a/mlir/test/Dialect/SPIRV/glslops.mlir b/mlir/test/Dialect/SPIRV/glslops.mlir
index 8e06df3d9eeb..1e7b18ef71ff 100644
--- a/mlir/test/Dialect/SPIRV/glslops.mlir
+++ b/mlir/test/Dialect/SPIRV/glslops.mlir
@@ -139,3 +139,19 @@ func @sinvec(%arg0 : vector<3xf16>) -> () {
%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
+}
More information about the Mlir-commits
mailing list