1 //===- SPIRVGLSLOps.td - GLSL extended insts spec file -----*- tablegen -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This is the op definition spec of GLSL extension ops.
11 //===----------------------------------------------------------------------===//
13 #ifndef MLIR_DIALECT_SPIRV_IR_GLSL_OPS
14 #define MLIR_DIALECT_SPIRV_IR_GLSL_OPS
16 include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
17 include "mlir/Interfaces/SideEffectInterfaces.td"
19 //===----------------------------------------------------------------------===//
20 // SPIR-V GLSL 4.50 opcode specification.
21 //===----------------------------------------------------------------------===//
23 // Base class for all GLSL ops.
24 class SPV_GLSLOp<string mnemonic, int opcode, list<OpTrait> traits = []> :
25 SPV_ExtInstOp<mnemonic, "GLSL", "GLSL.std.450", opcode, traits>;
27 // Base class for GLSL unary ops.
28 class SPV_GLSLUnaryOp<string mnemonic, int opcode, Type resultType,
29 Type operandType, list<OpTrait> traits = []> :
30 SPV_GLSLOp<mnemonic, opcode, !listconcat([NoSideEffect], traits)> {
33 SPV_ScalarOrVectorOf<operandType>:$operand
37 SPV_ScalarOrVectorOf<resultType>:$result
40 let parser = [{ return parseUnaryOp(parser, result); }];
42 let printer = [{ return printUnaryOp(getOperation(), p); }];
44 let verifier = [{ return success(); }];
47 // Base class for GLSL Unary arithmetic ops where return type matches
49 class SPV_GLSLUnaryArithmeticOp<string mnemonic, int opcode, Type type,
50 list<OpTrait> traits = []> :
51 SPV_GLSLUnaryOp<mnemonic, opcode, type, type, traits>;
53 // Base class for GLSL binary ops.
54 class SPV_GLSLBinaryOp<string mnemonic, int opcode, Type resultType,
55 Type operandType, list<OpTrait> traits = []> :
56 SPV_GLSLOp<mnemonic, opcode, !listconcat([NoSideEffect], traits)> {
59 SPV_ScalarOrVectorOf<operandType>:$lhs,
60 SPV_ScalarOrVectorOf<operandType>:$rhs
64 SPV_ScalarOrVectorOf<resultType>:$result
67 let parser = [{ return impl::parseOneResultSameOperandTypeOp(parser, result); }];
69 let printer = [{ return impl::printOneResultOp(getOperation(), p); }];
71 let verifier = [{ return success(); }];
74 // Base class for GLSL Binary arithmetic ops where operand types and
75 // return type matches.
76 class SPV_GLSLBinaryArithmeticOp<string mnemonic, int opcode, Type type,
77 list<OpTrait> traits = []> :
78 SPV_GLSLBinaryOp<mnemonic, opcode, type, type, traits>;
80 // Base class for GLSL ternary ops.
81 class SPV_GLSLTernaryArithmeticOp<string mnemonic, int opcode, Type type,
82 list<OpTrait> traits = []> :
83 SPV_GLSLOp<mnemonic, opcode, !listconcat([NoSideEffect], traits)> {
86 SPV_ScalarOrVectorOf<type>:$x,
87 SPV_ScalarOrVectorOf<type>:$y,
88 SPV_ScalarOrVectorOf<type>:$z
92 SPV_ScalarOrVectorOf<type>:$result
95 let parser = [{ return impl::parseOneResultSameOperandTypeOp(parser, result); }];
97 let printer = [{ return impl::printOneResultOp(getOperation(), p); }];
99 let verifier = [{ return success(); }];
104 def SPV_GLSLFAbsOp : SPV_GLSLUnaryArithmeticOp<"FAbs", 4, SPV_Float> {
105 let summary = "Absolute value of operand";
108 Result is x if x >= 0; otherwise result is -x.
110 The operand x must be a scalar or vector whose component type is
113 Result Type and the type of x must be the same type. Results are computed
116 <!-- End of AutoGen section -->
118 float-scalar-vector-type ::= float-type |
119 `vector<` integer-literal `x` float-type `>`
120 abs-op ::= ssa-id `=` `spv.GLSL.FAbs` ssa-use `:`
121 float-scalar-vector-type
126 %2 = spv.GLSL.FAbs %0 : f32
127 %3 = spv.GLSL.FAbs %1 : vector<3xf16>
134 def SPV_GLSLSAbsOp : SPV_GLSLUnaryArithmeticOp<"SAbs", 5, SPV_Integer> {
135 let summary = "Absolute value of operand";
138 Result is x if x ≥ 0; otherwise result is -x, where x is interpreted as a
141 Result Type and the type of x must both be integer scalar or integer vector
142 types. Result Type and operand types must have the same number of components
143 with the same component width. Results are computed per component.
145 <!-- End of AutoGen section -->
147 integer-scalar-vector-type ::= integer-type |
148 `vector<` integer-literal `x` integer-type `>`
149 abs-op ::= ssa-id `=` `spv.GLSL.SAbs` ssa-use `:`
150 integer-scalar-vector-type
155 %2 = spv.GLSL.SAbs %0 : i32
156 %3 = spv.GLSL.SAbs %1 : vector<3xi16>
163 def SPV_GLSLCeilOp : SPV_GLSLUnaryArithmeticOp<"Ceil", 9, SPV_Float> {
164 let summary = "Rounds up to the next whole number";
167 Result is the value equal to the nearest whole number that is greater than
170 The operand x must be a scalar or vector whose component type is
173 Result Type and the type of x must be the same type. Results are computed
176 <!-- End of AutoGen section -->
178 float-scalar-vector-type ::= float-type |
179 `vector<` integer-literal `x` float-type `>`
180 ceil-op ::= ssa-id `=` `spv.GLSL.Ceil` ssa-use `:`
181 float-scalar-vector-type
186 %2 = spv.GLSL.Ceil %0 : f32
187 %3 = spv.GLSL.Ceil %1 : vector<3xf16>
194 def SPV_GLSLCosOp : SPV_GLSLUnaryArithmeticOp<"Cos", 14, SPV_Float16or32> {
195 let summary = "Cosine of operand in radians";
198 The standard trigonometric cosine of x radians.
200 The operand x must be a scalar or vector whose component type is 16-bit or
201 32-bit floating-point.
203 Result Type and the type of x must be the same type. Results are computed
206 <!-- End of AutoGen section -->
208 restricted-float-scalar-type ::= `f16` | `f32`
209 restricted-float-scalar-vector-type ::=
210 restricted-float-scalar-type |
211 `vector<` integer-literal `x` restricted-float-scalar-type `>`
212 cos-op ::= ssa-id `=` `spv.GLSL.Cos` ssa-use `:`
213 restricted-float-scalar-vector-type
218 %2 = spv.GLSL.Cos %0 : f32
219 %3 = spv.GLSL.Cos %1 : vector<3xf16>
226 def SPV_GLSLSinOp : SPV_GLSLUnaryArithmeticOp<"Sin", 13, SPV_Float16or32> {
227 let summary = "Sine of operand in radians";
230 The standard trigonometric sine of x radians.
232 The operand x must be a scalar or vector whose component type is 16-bit or
233 32-bit floating-point.
235 Result Type and the type of x must be the same type. Results are computed
238 <!-- End of AutoGen section -->
240 restricted-float-scalar-type ::= `f16` | `f32`
241 restricted-float-scalar-vector-type ::=
242 restricted-float-scalar-type |
243 `vector<` integer-literal `x` restricted-float-scalar-type `>`
244 sin-op ::= ssa-id `=` `spv.GLSL.Sin` ssa-use `:`
245 restricted-float-scalar-vector-type
250 %2 = spv.GLSL.Sin %0 : f32
251 %3 = spv.GLSL.Sin %1 : vector<3xf16>
258 def SPV_GLSLTanOp : SPV_GLSLUnaryArithmeticOp<"Tan", 15, SPV_Float16or32> {
259 let summary = "Tangent of operand in radians";
262 The standard trigonometric tangent of x radians.
264 The operand x must be a scalar or vector whose component type is 16-bit or
265 32-bit floating-point.
267 Result Type and the type of x must be the same type. Results are computed
270 <!-- End of AutoGen section -->
272 restricted-float-scalar-type ::= `f16` | `f32`
273 restricted-float-scalar-vector-type ::=
274 restricted-float-scalar-type |
275 `vector<` integer-literal `x` restricted-float-scalar-type `>`
276 tan-op ::= ssa-id `=` `spv.GLSL.Tan` ssa-use `:`
277 restricted-float-scalar-vector-type
282 %2 = spv.GLSL.Tan %0 : f32
283 %3 = spv.GLSL.Tan %1 : vector<3xf16>
290 def SPV_GLSLAsinOp : SPV_GLSLUnaryArithmeticOp<"Asin", 16, SPV_Float16or32> {
291 let summary = "Arc Sine of operand in radians";
294 The standard trigonometric arc sine of x radians.
296 Result is an angle, in radians, whose sine is x. The range of result values
297 is [-π / 2, π / 2]. Result is undefined if abs x > 1.
299 The operand x must be a scalar or vector whose component type is 16-bit or
300 32-bit floating-point.
302 Result Type and the type of x must be the same type. Results are computed
304 <!-- End of AutoGen section -->
306 restricted-float-scalar-type ::= `f16` | `f32`
307 restricted-float-scalar-vector-type ::=
308 restricted-float-scalar-type |
309 `vector<` integer-literal `x` restricted-float-scalar-type `>`
310 asin-op ::= ssa-id `=` `spv.GLSL.Asin` ssa-use `:`
311 restricted-float-scalar-vector-type
316 %2 = spv.GLSL.Asin %0 : f32
317 %3 = spv.GLSL.Asin %1 : vector<3xf16>
324 def SPV_GLSLAcosOp : SPV_GLSLUnaryArithmeticOp<"Acos", 17, SPV_Float16or32> {
325 let summary = "Arc Cosine of operand in radians";
328 The standard trigonometric arc cosine of x radians.
330 Result is an angle, in radians, whose cosine is x. The range of result
331 values is [0, π]. Result is undefined if abs x > 1.
333 The operand x must be a scalar or vector whose component type is 16-bit or
334 32-bit floating-point.
336 Result Type and the type of x must be the same type. Results are computed
338 <!-- End of AutoGen section -->
340 restricted-float-scalar-type ::= `f16` | `f32`
341 restricted-float-scalar-vector-type ::=
342 restricted-float-scalar-type |
343 `vector<` integer-literal `x` restricted-float-scalar-type `>`
344 acos-op ::= ssa-id `=` `spv.GLSL.Acos` ssa-use `:`
345 restricted-float-scalar-vector-type
350 %2 = spv.GLSL.Acos %0 : f32
351 %3 = spv.GLSL.Acos %1 : vector<3xf16>
358 def SPV_GLSLAtanOp : SPV_GLSLUnaryArithmeticOp<"Atan", 18, SPV_Float16or32> {
359 let summary = "Arc Tangent of operand in radians";
362 The standard trigonometric arc tangent of x radians.
364 Result is an angle, in radians, whose tangent is y_over_x. The range of
365 result values is [-π / 2, π / 2].
367 The operand x must be a scalar or vector whose component type is 16-bit or
368 32-bit floating-point.
370 Result Type and the type of x must be the same type. Results are computed
372 <!-- End of AutoGen section -->
374 restricted-float-scalar-type ::= `f16` | `f32`
375 restricted-float-scalar-vector-type ::=
376 restricted-float-scalar-type |
377 `vector<` integer-literal `x` restricted-float-scalar-type `>`
378 atan-op ::= ssa-id `=` `spv.GLSL.Atan` ssa-use `:`
379 restricted-float-scalar-vector-type
384 %2 = spv.GLSL.Atan %0 : f32
385 %3 = spv.GLSL.Atan %1 : vector<3xf16>
392 def SPV_GLSLExpOp : SPV_GLSLUnaryArithmeticOp<"Exp", 27, SPV_Float16or32> {
393 let summary = "Exponentiation of Operand 1";
396 Result is the natural exponentiation of x; e^x.
398 The operand x must be a scalar or vector whose component type is
399 16-bit or 32-bit floating-point.
401 Result Type and the type of x must be the same type. Results are
402 computed per component.";
404 <!-- End of AutoGen section -->
406 restricted-float-scalar-type ::= `f16` | `f32`
407 restricted-float-scalar-vector-type ::=
408 restricted-float-scalar-type |
409 `vector<` integer-literal `x` restricted-float-scalar-type `>`
410 exp-op ::= ssa-id `=` `spv.GLSL.Exp` ssa-use `:`
411 restricted-float-scalar-vector-type
416 %2 = spv.GLSL.Exp %0 : f32
417 %3 = spv.GLSL.Exp %1 : vector<3xf16>
424 def SPV_GLSLFloorOp : SPV_GLSLUnaryArithmeticOp<"Floor", 8, SPV_Float> {
425 let summary = "Rounds down to the next whole number";
428 Result is the value equal to the nearest whole number that is less than or
431 The operand x must be a scalar or vector whose component type is
434 Result Type and the type of x must be the same type. Results are computed
437 <!-- End of AutoGen section -->
439 float-scalar-vector-type ::= float-type |
440 `vector<` integer-literal `x` float-type `>`
441 floor-op ::= ssa-id `=` `spv.GLSL.Floor` ssa-use `:`
442 float-scalar-vector-type
447 %2 = spv.GLSL.Floor %0 : f32
448 %3 = spv.GLSL.Floor %1 : vector<3xf16>
455 def SPV_GLSLRoundOp: SPV_GLSLUnaryArithmeticOp<"Round", 1, SPV_Float> {
456 let summary = "Rounds to the whole number";
459 Result is the value equal to the nearest whole number.
461 The operand x must be a scalar or vector whose component type is
464 Result Type and the type of x must be the same type. Results are computed
467 <!-- End of AutoGen section -->
469 float-scalar-vector-type ::= float-type |
470 `vector<` integer-literal `x` float-type `>`
471 floor-op ::= ssa-id `=` `spv.GLSL.Round` ssa-use `:`
472 float-scalar-vector-type
477 %2 = spv.GLSL.Round %0 : f32
478 %3 = spv.GLSL.Round %1 : vector<3xf16>
485 def SPV_GLSLInverseSqrtOp : SPV_GLSLUnaryArithmeticOp<"InverseSqrt", 32, SPV_Float> {
486 let summary = "Reciprocal of sqrt(operand)";
489 Result is the reciprocal of sqrt x. Result is undefined if x <= 0.
491 The operand x must be a scalar or vector whose component type is
494 Result Type and the type of x must be the same type. Results are computed
497 <!-- End of AutoGen section -->
499 float-scalar-vector-type ::= float-type |
500 `vector<` integer-literal `x` float-type `>`
501 rsqrt-op ::= ssa-id `=` `spv.GLSL.InverseSqrt` ssa-use `:`
502 float-scalar-vector-type
507 %2 = spv.GLSL.InverseSqrt %0 : f32
508 %3 = spv.GLSL.InverseSqrt %1 : vector<3xf16>
515 def SPV_GLSLLogOp : SPV_GLSLUnaryArithmeticOp<"Log", 28, SPV_Float16or32> {
516 let summary = "Natural logarithm of the operand";
519 Result is the natural logarithm of x, i.e., the value y which satisfies the
520 equation x = ey. Result is undefined if x <= 0.
522 The operand x must be a scalar or vector whose component type is 16-bit or
523 32-bit floating-point.
525 Result Type and the type of x must be the same type. Results are computed
528 <!-- End of AutoGen section -->
530 restricted-float-scalar-type ::= `f16` | `f32`
531 restricted-float-scalar-vector-type ::=
532 restricted-float-scalar-type |
533 `vector<` integer-literal `x` restricted-float-scalar-type `>`
534 log-op ::= ssa-id `=` `spv.GLSL.Log` ssa-use `:`
535 restricted-float-scalar-vector-type
540 %2 = spv.GLSL.Log %0 : f32
541 %3 = spv.GLSL.Log %1 : vector<3xf16>
548 def SPV_GLSLFMaxOp : SPV_GLSLBinaryArithmeticOp<"FMax", 40, SPV_Float> {
549 let summary = "Return maximum of two floating-point operands";
552 Result is y if x < y; otherwise result is x. Which operand is the
553 result is undefined if one of the operands is a NaN.
555 The operands must all be a scalar or vector whose component type
558 Result Type and the type of all operands must be the same
559 type. Results are computed per component.
561 <!-- End of AutoGen section -->
563 float-scalar-vector-type ::= float-type |
564 `vector<` integer-literal `x` float-type `>`
565 fmax-op ::= ssa-id `=` `spv.GLSL.FMax` ssa-use `:`
566 float-scalar-vector-type
571 %2 = spv.GLSL.FMax %0, %1 : f32
572 %3 = spv.GLSL.FMax %0, %1 : vector<3xf16>
579 def SPV_GLSLSMaxOp : SPV_GLSLBinaryArithmeticOp<"SMax", 42, SPV_Integer> {
580 let summary = "Return maximum of two signed integer operands";
583 Result is y if x < y; otherwise result is x, where x and y are interpreted
586 Result Type and the type of x and y must both be integer scalar or integer
587 vector types. Result Type and operand types must have the same number of
588 components with the same component width. Results are computed per
591 <!-- End of AutoGen section -->
593 integer-scalar-vector-type ::= integer-type |
594 `vector<` integer-literal `x` integer-type `>`
595 smax-op ::= ssa-id `=` `spv.GLSL.SMax` ssa-use `:`
596 integer-scalar-vector-type
601 %2 = spv.GLSL.SMax %0, %1 : i32
602 %3 = spv.GLSL.SMax %0, %1 : vector<3xi16>
609 def SPV_GLSLFMinOp : SPV_GLSLBinaryArithmeticOp<"FMin", 37, SPV_Float> {
610 let summary = "Return minimum of two floating-point operands";
613 Result is y if y < x; otherwise result is x. Which operand is the result is
614 undefined if one of the operands is a NaN.
616 The operands must all be a scalar or vector whose component type is
619 Result Type and the type of all operands must be the same type. Results are
620 computed per component.
622 <!-- End of AutoGen section -->
624 float-scalar-vector-type ::= float-type |
625 `vector<` integer-literal `x` float-type `>`
626 fmin-op ::= ssa-id `=` `spv.GLSL.FMin` ssa-use `:`
627 float-scalar-vector-type
632 %2 = spv.GLSL.FMin %0, %1 : f32
633 %3 = spv.GLSL.FMin %0, %1 : vector<3xf16>
640 def SPV_GLSLSMinOp : SPV_GLSLBinaryArithmeticOp<"SMin", 39, SPV_Integer> {
641 let summary = "Return minimum of two signed integer operands";
644 Result is y if y < x; otherwise result is x, where x and y are interpreted
647 Result Type and the type of x and y must both be integer scalar or integer
648 vector types. Result Type and operand types must have the same number of
649 components with the same component width. Results are computed per
652 <!-- End of AutoGen section -->
654 integer-scalar-vector-type ::= integer-type |
655 `vector<` integer-literal `x` integer-type `>`
656 smin-op ::= ssa-id `=` `spv.GLSL.SMin` ssa-use `:`
657 integer-scalar-vector-type
662 %2 = spv.GLSL.SMin %0, %1 : i32
663 %3 = spv.GLSL.SMin %0, %1 : vector<3xi16>
670 def SPV_GLSLPowOp : SPV_GLSLBinaryArithmeticOp<"Pow", 26, SPV_Float16or32> {
671 let summary = "Return x raised to the y power of two operands";
674 Result is x raised to the y power; x^y.
676 Result is undefined if x = 0 and y ≤ 0.
678 The operand x and y must be a scalar or vector whose component type is
679 16-bit or 32-bit floating-point.
681 Result Type and the type of all operands must be the same type. Results are
682 computed per component.
684 <!-- End of AutoGen section -->
686 restricted-float-scalar-type ::= `f16` | `f32`
687 restricted-float-scalar-vector-type ::=
688 restricted-float-scalar-type |
689 `vector<` integer-literal `x` restricted-float-scalar-type `>`
690 pow-op ::= ssa-id `=` `spv.GLSL.Pow` ssa-use `:`
691 restricted-float-scalar-vector-type
696 %2 = spv.GLSL.Pow %0, %1 : f32
697 %3 = spv.GLSL.Pow %0, %1 : vector<3xf16>
704 def SPV_GLSLFSignOp : SPV_GLSLUnaryArithmeticOp<"FSign", 6, SPV_Float> {
705 let summary = "Returns the sign of the operand";
708 Result is 1.0 if x > 0, 0.0 if x = 0, or -1.0 if x < 0.
710 The operand x must be a scalar or vector whose component type is
713 Result Type and the type of x must be the same type. Results are computed
716 <!-- End of AutoGen section -->
718 float-scalar-vector-type ::= float-type |
719 `vector<` integer-literal `x` float-type `>`
720 sign-op ::= ssa-id `=` `spv.GLSL.FSign` ssa-use `:`
721 float-scalar-vector-type
726 %2 = spv.GLSL.FSign %0 : f32
727 %3 = spv.GLSL.FSign %1 : vector<3xf16>
734 def SPV_GLSLSSignOp : SPV_GLSLUnaryArithmeticOp<"SSign", 7, SPV_Integer> {
735 let summary = "Returns the sign of the operand";
738 Result is 1 if x > 0, 0 if x = 0, or -1 if x < 0, where x is interpreted as
741 Result Type and the type of x must both be integer scalar or integer vector
742 types. Result Type and operand types must have the same number of components
743 with the same component width. Results are computed per component.
745 <!-- End of AutoGen section -->
747 integer-scalar-vector-type ::= integer-type |
748 `vector<` integer-literal `x` integer-type `>`
749 sign-op ::= ssa-id `=` `spv.GLSL.SSign` ssa-use `:`
750 integer-scalar-vector-type
755 %2 = spv.GLSL.SSign %0 : i32
756 %3 = spv.GLSL.SSign %1 : vector<3xi16>
763 def SPV_GLSLSqrtOp : SPV_GLSLUnaryArithmeticOp<"Sqrt", 31, SPV_Float> {
764 let summary = "Returns the square root of the operand";
767 Result is the square root of x. Result is undefined if x < 0.
769 The operand x must be a scalar or vector whose component type is
772 Result Type and the type of x must be the same type. Results are computed
775 <!-- End of AutoGen section -->
777 float-scalar-vector-type ::= float-type |
778 `vector<` integer-literal `x` float-type `>`
779 sqrt-op ::= ssa-id `=` `spv.GLSL.Sqrt` ssa-use `:`
780 float-scalar-vector-type
785 %2 = spv.GLSL.Sqrt %0 : f32
786 %3 = spv.GLSL.Sqrt %1 : vector<3xf16>
793 def SPV_GLSLSinhOp : SPV_GLSLUnaryArithmeticOp<"Sinh", 19, SPV_Float16or32> {
794 let summary = "Hyperbolic sine of operand in radians";
797 Hyperbolic sine of x radians.
799 The operand x must be a scalar or vector whose component type is 16-bit or
800 32-bit floating-point.
802 Result Type and the type of x must be the same type. Results are computed
805 <!-- End of AutoGen section -->
807 restricted-float-scalar-type ::= `f16` | `f32`
808 restricted-float-scalar-vector-type ::=
809 restricted-float-scalar-type |
810 `vector<` integer-literal `x` restricted-float-scalar-type `>`
811 sinh-op ::= ssa-id `=` `spv.GLSL.Sinh` ssa-use `:`
812 restricted-float-scalar-vector-type
817 %2 = spv.GLSL.Sinh %0 : f32
818 %3 = spv.GLSL.Sinh %1 : vector<3xf16>
825 def SPV_GLSLCoshOp : SPV_GLSLUnaryArithmeticOp<"Cosh", 20, SPV_Float16or32> {
826 let summary = "Hyperbolic cosine of operand in radians";
829 Hyperbolic cosine of x radians.
831 The operand x must be a scalar or vector whose component type is 16-bit or
832 32-bit floating-point.
834 Result Type and the type of x must be the same type. Results are computed
837 <!-- End of AutoGen section -->
839 restricted-float-scalar-type ::= `f16` | `f32`
840 restricted-float-scalar-vector-type ::=
841 restricted-float-scalar-type |
842 `vector<` integer-literal `x` restricted-float-scalar-type `>`
843 cosh-op ::= ssa-id `=` `spv.GLSL.Cosh` ssa-use `:`
844 restricted-float-scalar-vector-type
849 %2 = spv.GLSL.Cosh %0 : f32
850 %3 = spv.GLSL.Cosh %1 : vector<3xf16>
857 def SPV_GLSLTanhOp : SPV_GLSLUnaryArithmeticOp<"Tanh", 21, SPV_Float16or32> {
858 let summary = "Hyperbolic tangent of operand in radians";
861 Hyperbolic tangent of x radians.
863 The operand x must be a scalar or vector whose component type is 16-bit or
864 32-bit floating-point.
866 Result Type and the type of x must be the same type. Results are computed
869 <!-- End of AutoGen section -->
871 restricted-float-scalar-type ::= `f16` | `f32`
872 restricted-float-scalar-vector-type ::=
873 restricted-float-scalar-type |
874 `vector<` integer-literal `x` restricted-float-scalar-type `>`
875 tanh-op ::= ssa-id `=` `spv.GLSL.Tanh` ssa-use `:`
876 restricted-float-scalar-vector-type
881 %2 = spv.GLSL.Tanh %0 : f32
882 %3 = spv.GLSL.Tanh %1 : vector<3xf16>
889 def SPV_GLSLFClampOp : SPV_GLSLTernaryArithmeticOp<"FClamp", 43, SPV_Float> {
890 let summary = "Clamp x between min and max values.";
893 Result is min(max(x, minVal), maxVal). The resulting value is undefined if
894 minVal > maxVal. The semantics used by min() and max() are those of FMin and
897 The operands must all be a scalar or vector whose component type is
900 Result Type and the type of all operands must be the same type. Results are
901 computed per component.
903 <!-- End of AutoGen section -->
905 fclamp-op ::= ssa-id `=` `spv.GLSL.FClamp` ssa-use, ssa-use, ssa-use `:`
906 float-scalar-vector-type
911 %2 = spv.GLSL.FClamp %x, %min, %max : f32
912 %3 = spv.GLSL.FClamp %x, %min, %max : vector<3xf16>
919 def SPV_GLSLUClampOp : SPV_GLSLTernaryArithmeticOp<"UClamp", 44, SPV_SignlessOrUnsignedInt> {
920 let summary = "Clamp x between min and max values.";
923 Result is min(max(x, minVal), maxVal), where x, minVal and maxVal are
924 interpreted as unsigned integers. The resulting value is undefined if
927 Result Type and the type of the operands must both be integer scalar or
928 integer vector types. Result Type and operand types must have the same number
929 of components with the same component width. Results are computed per
932 <!-- End of AutoGen section -->
934 uclamp-op ::= ssa-id `=` `spv.GLSL.UClamp` ssa-use, ssa-use, ssa-use `:`
935 unsgined-signless-scalar-vector-type
940 %2 = spv.GLSL.UClamp %x, %min, %max : i32
941 %3 = spv.GLSL.UClamp %x, %min, %max : vector<3xui16>
948 def SPV_GLSLSClampOp : SPV_GLSLTernaryArithmeticOp<"SClamp", 45, SPV_SignedInt> {
949 let summary = "Clamp x between min and max values.";
952 Result is min(max(x, minVal), maxVal), where x, minVal and maxVal are
953 interpreted as signed integers. The resulting value is undefined if
956 Result Type and the type of the operands must both be integer scalar or
957 integer vector types. Result Type and operand types must have the same number
958 of components with the same component width. Results are computed per
961 <!-- End of AutoGen section -->
963 uclamp-op ::= ssa-id `=` `spv.GLSL.UClamp` ssa-use, ssa-use, ssa-use `:`
964 sgined-scalar-vector-type
969 %2 = spv.GLSL.SClamp %x, %min, %max : si32
970 %3 = spv.GLSL.SClamp %x, %min, %max : vector<3xsi16>
975 #endif // MLIR_DIALECT_SPIRV_IR_GLSL_OPS