diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td +++ b/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. + + + ``` + 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 --- a/mlir/test/Dialect/SPIRV/Serialization/glsl-ops.mlir +++ b/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 } } diff --git a/mlir/test/Dialect/SPIRV/glslops.mlir b/mlir/test/Dialect/SPIRV/glslops.mlir --- a/mlir/test/Dialect/SPIRV/glslops.mlir +++ b/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 +}