[PATCH] D74151: Adding sin op in the GLSL extension

Lei Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 7 13:39:58 PST 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG9c1c825b7249: [mlir][spirv] Adding sin op in the GLSL extension (authored by NatashaKnk, committed by antiagainst).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74151/new/

https://reviews.llvm.org/D74151

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
@@ -107,3 +107,35 @@
   %2 = spv.GLSL.Sqrt %arg0 : vector<3xf16>
   return
 }
+
+//===----------------------------------------------------------------------===//
+// spv.GLSL.Cos
+//===----------------------------------------------------------------------===//
+
+func @cos(%arg0 : f32) -> () {
+  // CHECK: spv.GLSL.Cos {{%.*}} : f32
+  %2 = spv.GLSL.Cos %arg0 : f32
+  return
+}
+
+func @cosvec(%arg0 : vector<3xf16>) -> () {
+  // CHECK: spv.GLSL.Cos {{%.*}} : vector<3xf16>
+  %2 = spv.GLSL.Cos %arg0 : vector<3xf16>
+  return
+}
+
+//===----------------------------------------------------------------------===//
+// spv.GLSL.Sin
+//===----------------------------------------------------------------------===//
+
+func @sin(%arg0 : f32) -> () {
+  // CHECK: spv.GLSL.Sin {{%.*}} : f32
+  %2 = spv.GLSL.Sin %arg0 : f32
+  return
+}
+
+func @sinvec(%arg0 : vector<3xf16>) -> () {
+  // CHECK: spv.GLSL.Sin {{%.*}} : vector<3xf16>
+  %2 = spv.GLSL.Sin %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
@@ -8,6 +8,10 @@
     %1 = spv.GLSL.FMax %arg0, %arg1 : f32
     // CHECK: {{%.*}} = spv.GLSL.Sqrt {{%.*}} : f32
     %2 = spv.GLSL.Sqrt %arg0 : f32
+    // CHECK: {{%.*}} = spv.GLSL.Cos {{%.*}} : f32
+    %3 = spv.GLSL.Cos %arg0 : f32
+    // CHECK: {{%.*}} = spv.GLSL.Sin {{%.*}} : f32
+    %4 = spv.GLSL.Sin %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
@@ -200,6 +200,38 @@
 
 // -----
 
+def SPV_GLSLSinOp : SPV_GLSLUnaryArithmeticOp<"Sin", 13, SPV_Float16or32> {
+  let summary = "Sine of operand in radians";
+
+  let description = [{
+    The standard trigonometric sine 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.
+
+    ### Custom assembly format
+    ```
+    restricted-float-scalar-type ::=  `f16` | `f32`
+    restricted-float-scalar-vector-type ::=
+      restricted-float-scalar-type |
+      `vector<` integer-literal `x` restricted-float-scalar-type `>`
+    sin-op ::= ssa-id `=` `spv.GLSL.Sin` ssa-use `:`
+               restricted-float-scalar-vector-type
+    ```
+    For example:
+
+    ```
+    %2 = spv.GLSL.Sin %0 : f32
+    %3 = spv.GLSL.Sin %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: D74151.243277.patch
Type: text/x-patch
Size: 3071 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200207/86e68cb9/attachment.bin>


More information about the llvm-commits mailing list