• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//===- SPIRVGLSLOps.td - GLSL extended insts spec file -----*- tablegen -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8//
9// This is the op definition spec of GLSL extension ops.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef SPIRV_GLSL_OPS
14#define SPIRV_GLSL_OPS
15
16include "mlir/Dialect/SPIRV/SPIRVBase.td"
17include "mlir/Interfaces/SideEffectInterfaces.td"
18
19//===----------------------------------------------------------------------===//
20// SPIR-V GLSL 4.50 opcode specification.
21//===----------------------------------------------------------------------===//
22
23// Base class for all GLSL ops.
24class SPV_GLSLOp<string mnemonic, int opcode, list<OpTrait> traits = []> :
25  SPV_ExtInstOp<mnemonic, "GLSL", "GLSL.std.450", opcode, traits>;
26
27// Base class for GLSL unary ops.
28class SPV_GLSLUnaryOp<string mnemonic, int opcode, Type resultType,
29                      Type operandType, list<OpTrait> traits = []> :
30  SPV_GLSLOp<mnemonic, opcode, !listconcat([NoSideEffect], traits)> {
31
32  let arguments = (ins
33    SPV_ScalarOrVectorOf<operandType>:$operand
34  );
35
36  let results = (outs
37    SPV_ScalarOrVectorOf<resultType>:$result
38  );
39
40  let parser = [{ return parseUnaryOp(parser, result); }];
41
42  let printer = [{ return printUnaryOp(getOperation(), p); }];
43
44  let verifier = [{ return success(); }];
45}
46
47// Base class for GLSL Unary arithmetic ops where return type matches
48// the operand type.
49class SPV_GLSLUnaryArithmeticOp<string mnemonic, int opcode, Type type,
50                                list<OpTrait> traits = []> :
51  SPV_GLSLUnaryOp<mnemonic, opcode, type, type, traits>;
52
53// Base class for GLSL binary ops.
54class SPV_GLSLBinaryOp<string mnemonic, int opcode, Type resultType,
55                        Type operandType, list<OpTrait> traits = []> :
56  SPV_GLSLOp<mnemonic, opcode, !listconcat([NoSideEffect], traits)> {
57
58  let arguments = (ins
59    SPV_ScalarOrVectorOf<operandType>:$lhs,
60    SPV_ScalarOrVectorOf<operandType>:$rhs
61  );
62
63  let results = (outs
64    SPV_ScalarOrVectorOf<resultType>:$result
65  );
66
67  let parser = [{ return impl::parseOneResultSameOperandTypeOp(parser, result); }];
68
69  let printer = [{ return impl::printOneResultOp(getOperation(), p); }];
70
71  let verifier = [{ return success(); }];
72}
73
74// Base class for GLSL Binary arithmetic ops where operand types and
75// return type matches.
76class SPV_GLSLBinaryArithmeticOp<string mnemonic, int opcode, Type type,
77                                 list<OpTrait> traits = []> :
78  SPV_GLSLBinaryOp<mnemonic, opcode, type, type, traits>;
79
80// -----
81
82def SPV_GLSLFAbsOp : SPV_GLSLUnaryArithmeticOp<"FAbs", 4, SPV_Float> {
83  let summary = "Absolute value of operand";
84
85  let description = [{
86    Result is x if x >= 0; otherwise result is -x.
87
88    The operand x must be a scalar or vector whose component type is
89    floating-point.
90
91    Result Type and the type of x must be the same type. Results are computed
92    per component.
93
94    <!-- End of AutoGen section -->
95    ```
96    float-scalar-vector-type ::= float-type |
97                                 `vector<` integer-literal `x` float-type `>`
98    abs-op ::= ssa-id `=` `spv.GLSL.FAbs` ssa-use `:`
99               float-scalar-vector-type
100    ```
101    #### Example:
102
103    ```mlir
104    %2 = spv.GLSL.FAbs %0 : f32
105    %3 = spv.GLSL.FAbs %1 : vector<3xf16>
106    ```
107  }];
108}
109
110// -----
111
112def SPV_GLSLSAbsOp : SPV_GLSLUnaryArithmeticOp<"SAbs", 5, SPV_Integer> {
113  let summary = "Absolute value of operand";
114
115  let description = [{
116    Result is x if x ≥ 0; otherwise result is -x, where x is interpreted as a
117    signed integer.
118
119    Result Type and the type of x must both be integer scalar or integer vector
120    types. Result Type and operand types must have the same number of components
121    with the same component width. Results are computed per component.
122
123    <!-- End of AutoGen section -->
124    ```
125    integer-scalar-vector-type ::= integer-type |
126                                   `vector<` integer-literal `x` integer-type `>`
127    abs-op ::= ssa-id `=` `spv.GLSL.SAbs` ssa-use `:`
128               integer-scalar-vector-type
129    ```
130    #### Example:
131
132    ```mlir
133    %2 = spv.GLSL.SAbs %0 : i32
134    %3 = spv.GLSL.SAbs %1 : vector<3xi16>
135    ```
136  }];
137}
138
139// -----
140
141def SPV_GLSLCeilOp : SPV_GLSLUnaryArithmeticOp<"Ceil", 9, SPV_Float> {
142  let summary = "Rounds up to the next whole number";
143
144  let description = [{
145    Result is the value equal to the nearest whole number that is greater than
146    or equal to x.
147
148    The operand x must be a scalar or vector whose component type is
149    floating-point.
150
151    Result Type and the type of x must be the same type. Results are computed
152    per component.
153
154    <!-- End of AutoGen section -->
155    ```
156    float-scalar-vector-type ::= float-type |
157                                 `vector<` integer-literal `x` float-type `>`
158    ceil-op ::= ssa-id `=` `spv.GLSL.Ceil` ssa-use `:`
159                float-scalar-vector-type
160    ```
161    #### Example:
162
163    ```mlir
164    %2 = spv.GLSL.Ceil %0 : f32
165    %3 = spv.GLSL.Ceil %1 : vector<3xf16>
166    ```
167  }];
168}
169
170// -----
171
172def SPV_GLSLCosOp : SPV_GLSLUnaryArithmeticOp<"Cos", 14, SPV_Float16or32> {
173  let summary = "Cosine of operand in radians";
174
175  let description = [{
176    The standard trigonometric cosine of x radians.
177
178    The operand x must be a scalar or vector whose component type is 16-bit or
179    32-bit floating-point.
180
181    Result Type and the type of x must be the same type. Results are computed
182    per component.
183
184    <!-- End of AutoGen section -->
185    ```
186    restricted-float-scalar-type ::=  `f16` | `f32`
187    restricted-float-scalar-vector-type ::=
188      restricted-float-scalar-type |
189      `vector<` integer-literal `x` restricted-float-scalar-type `>`
190    cos-op ::= ssa-id `=` `spv.GLSL.Cos` ssa-use `:`
191               restricted-float-scalar-vector-type
192    ```
193    #### Example:
194
195    ```mlir
196    %2 = spv.GLSL.Cos %0 : f32
197    %3 = spv.GLSL.Cos %1 : vector<3xf16>
198    ```
199  }];
200}
201
202// -----
203
204def SPV_GLSLSinOp : SPV_GLSLUnaryArithmeticOp<"Sin", 13, SPV_Float16or32> {
205  let summary = "Sine of operand in radians";
206
207  let description = [{
208    The standard trigonometric sine of x radians.
209
210    The operand x must be a scalar or vector whose component type is 16-bit or
211    32-bit floating-point.
212
213    Result Type and the type of x must be the same type. Results are computed
214    per component.
215
216    <!-- End of AutoGen section -->
217    ```
218    restricted-float-scalar-type ::=  `f16` | `f32`
219    restricted-float-scalar-vector-type ::=
220      restricted-float-scalar-type |
221      `vector<` integer-literal `x` restricted-float-scalar-type `>`
222    sin-op ::= ssa-id `=` `spv.GLSL.Sin` ssa-use `:`
223               restricted-float-scalar-vector-type
224    ```
225    #### Example:
226
227    ```mlir
228    %2 = spv.GLSL.Sin %0 : f32
229    %3 = spv.GLSL.Sin %1 : vector<3xf16>
230    ```
231  }];
232}
233
234// -----
235
236def SPV_GLSLTanOp : SPV_GLSLUnaryArithmeticOp<"Tan", 15, SPV_Float16or32> {
237  let summary = "Tangent of operand in radians";
238
239  let description = [{
240    The standard trigonometric tangent of x radians.
241
242    The operand x must be a scalar or vector whose component type is 16-bit or
243    32-bit floating-point.
244
245    Result Type and the type of x must be the same type. Results are computed
246    per component.
247
248    <!-- End of AutoGen section -->
249    ```
250    restricted-float-scalar-type ::=  `f16` | `f32`
251    restricted-float-scalar-vector-type ::=
252      restricted-float-scalar-type |
253      `vector<` integer-literal `x` restricted-float-scalar-type `>`
254    tan-op ::= ssa-id `=` `spv.GLSL.Tan` ssa-use `:`
255               restricted-float-scalar-vector-type
256    ```
257    #### Example:
258
259    ```mlir
260    %2 = spv.GLSL.Tan %0 : f32
261    %3 = spv.GLSL.Tan %1 : vector<3xf16>
262    ```
263  }];
264}
265
266// -----
267
268def SPV_GLSLAsinOp : SPV_GLSLUnaryArithmeticOp<"Asin", 16, SPV_Float16or32> {
269  let summary = "Arc Sine of operand in radians";
270
271  let description = [{
272    The standard trigonometric arc sine of x radians.
273
274    Result is an angle, in radians, whose sine is x. The range of result values
275    is [-π / 2, π / 2]. Result is undefined if abs x > 1.
276
277    The operand x must be a scalar or vector whose component type is 16-bit or
278    32-bit floating-point.
279
280    Result Type and the type of x must be the same type. Results are computed
281    per component.
282    <!-- End of AutoGen section -->
283    ```
284    restricted-float-scalar-type ::=  `f16` | `f32`
285    restricted-float-scalar-vector-type ::=
286      restricted-float-scalar-type |
287      `vector<` integer-literal `x` restricted-float-scalar-type `>`
288    asin-op ::= ssa-id `=` `spv.GLSL.Asin` ssa-use `:`
289                restricted-float-scalar-vector-type
290    ```
291    #### Example:
292
293    ```mlir
294    %2 = spv.GLSL.Asin %0 : f32
295    %3 = spv.GLSL.Asin %1 : vector<3xf16>
296    ```
297  }];
298}
299
300// -----
301
302def SPV_GLSLAcosOp : SPV_GLSLUnaryArithmeticOp<"Acos", 17, SPV_Float16or32> {
303  let summary = "Arc Cosine of operand in radians";
304
305  let description = [{
306    The standard trigonometric arc cosine of x radians.
307
308    Result is an angle, in radians, whose cosine is x. The range of result
309    values is [0, π]. Result is undefined if abs x > 1.
310
311    The operand x must be a scalar or vector whose component type is 16-bit or
312    32-bit floating-point.
313
314    Result Type and the type of x must be the same type. Results are computed
315    per component.
316    <!-- End of AutoGen section -->
317    ```
318    restricted-float-scalar-type ::=  `f16` | `f32`
319    restricted-float-scalar-vector-type ::=
320      restricted-float-scalar-type |
321      `vector<` integer-literal `x` restricted-float-scalar-type `>`
322    acos-op ::= ssa-id `=` `spv.GLSL.Acos` ssa-use `:`
323                restricted-float-scalar-vector-type
324    ```
325    #### Example:
326
327    ```mlir
328    %2 = spv.GLSL.Acos %0 : f32
329    %3 = spv.GLSL.Acos %1 : vector<3xf16>
330    ```
331  }];
332}
333
334// -----
335
336def SPV_GLSLAtanOp : SPV_GLSLUnaryArithmeticOp<"Atan", 18, SPV_Float16or32> {
337  let summary = "Arc Tangent of operand in radians";
338
339  let description = [{
340    The standard trigonometric arc tangent of x radians.
341
342    Result is an angle, in radians, whose tangent is y_over_x. The range of
343    result values is [-π / 2, π / 2].
344
345    The operand x must be a scalar or vector whose component type is 16-bit or
346    32-bit floating-point.
347
348    Result Type and the type of x must be the same type. Results are computed
349    per component.
350    <!-- End of AutoGen section -->
351    ```
352    restricted-float-scalar-type ::=  `f16` | `f32`
353    restricted-float-scalar-vector-type ::=
354      restricted-float-scalar-type |
355      `vector<` integer-literal `x` restricted-float-scalar-type `>`
356    atan-op ::= ssa-id `=` `spv.GLSL.Atan` ssa-use `:`
357                restricted-float-scalar-vector-type
358    ```
359    #### Example:
360
361    ```mlir
362    %2 = spv.GLSL.Atan %0 : f32
363    %3 = spv.GLSL.Atan %1 : vector<3xf16>
364    ```
365  }];
366}
367
368// -----
369
370def SPV_GLSLExpOp : SPV_GLSLUnaryArithmeticOp<"Exp", 27, SPV_Float16or32> {
371  let summary = "Exponentiation of Operand 1";
372
373  let description = [{
374    Result is the natural exponentiation of x; e^x.
375
376    The operand x must be a scalar or vector whose component type is
377    16-bit or 32-bit floating-point.
378
379    Result Type and the type of x must be the same type. Results are
380    computed per component.";
381
382    <!-- End of AutoGen section -->
383    ```
384    restricted-float-scalar-type ::=  `f16` | `f32`
385    restricted-float-scalar-vector-type ::=
386      restricted-float-scalar-type |
387      `vector<` integer-literal `x` restricted-float-scalar-type `>`
388    exp-op ::= ssa-id `=` `spv.GLSL.Exp` ssa-use `:`
389               restricted-float-scalar-vector-type
390    ```
391    #### Example:
392
393    ```mlir
394    %2 = spv.GLSL.Exp %0 : f32
395    %3 = spv.GLSL.Exp %1 : vector<3xf16>
396    ```
397  }];
398}
399
400// -----
401
402def SPV_GLSLFloorOp : SPV_GLSLUnaryArithmeticOp<"Floor", 8, SPV_Float> {
403  let summary = "Rounds down to the next whole number";
404
405  let description = [{
406    Result is the value equal to the nearest whole number that is less than or
407    equal to x.
408
409    The operand x must be a scalar or vector whose component type is
410    floating-point.
411
412    Result Type and the type of x must be the same type. Results are computed
413    per component.
414
415    <!-- End of AutoGen section -->
416    ```
417    float-scalar-vector-type ::= float-type |
418                                 `vector<` integer-literal `x` float-type `>`
419    floor-op ::= ssa-id `=` `spv.GLSL.Floor` ssa-use `:`
420                float-scalar-vector-type
421    ```
422    #### Example:
423
424    ```mlir
425    %2 = spv.GLSL.Floor %0 : f32
426    %3 = spv.GLSL.Floor %1 : vector<3xf16>
427    ```
428  }];
429}
430
431// -----
432
433def SPV_GLSLRoundOp: SPV_GLSLUnaryArithmeticOp<"Round", 1, SPV_Float> {
434  let summary = "Rounds to the whole number";
435
436  let description = [{
437    Result is the value equal to the nearest whole number.
438
439    The operand x must be a scalar or vector whose component type is
440    floating-point.
441
442    Result Type and the type of x must be the same type. Results are computed
443    per component.
444
445    <!-- End of AutoGen section -->
446    ```
447    float-scalar-vector-type ::= float-type |
448                                 `vector<` integer-literal `x` float-type `>`
449    floor-op ::= ssa-id `=` `spv.GLSL.Round` ssa-use `:`
450                float-scalar-vector-type
451    ```
452    #### Example:
453
454    ```mlir
455    %2 = spv.GLSL.Round %0 : f32
456    %3 = spv.GLSL.Round %1 : vector<3xf16>
457    ```
458  }];
459}
460
461// -----
462
463def SPV_GLSLInverseSqrtOp : SPV_GLSLUnaryArithmeticOp<"InverseSqrt", 32, SPV_Float> {
464  let summary = "Reciprocal of sqrt(operand)";
465
466  let description = [{
467    Result is the reciprocal of sqrt x. Result is undefined if x <= 0.
468
469    The operand x must be a scalar or vector whose component type is
470    floating-point.
471
472    Result Type and the type of x must be the same type. Results are computed
473    per component.
474
475    <!-- End of AutoGen section -->
476    ```
477    float-scalar-vector-type ::= float-type |
478                                 `vector<` integer-literal `x` float-type `>`
479    rsqrt-op ::= ssa-id `=` `spv.GLSL.InverseSqrt` ssa-use `:`
480                 float-scalar-vector-type
481    ```
482    #### Example:
483
484    ```mlir
485    %2 = spv.GLSL.InverseSqrt %0 : f32
486    %3 = spv.GLSL.InverseSqrt %1 : vector<3xf16>
487    ```
488  }];
489}
490
491// -----
492
493def SPV_GLSLLogOp : SPV_GLSLUnaryArithmeticOp<"Log", 28, SPV_Float16or32> {
494  let summary = "Natural logarithm of the operand";
495
496  let description = [{
497    Result is the natural logarithm of x, i.e., the value y which satisfies the
498    equation x = ey. Result is undefined if x <= 0.
499
500    The operand x must be a scalar or vector whose component type is 16-bit or
501    32-bit floating-point.
502
503    Result Type and the type of x must be the same type. Results are computed
504    per component.
505
506    <!-- End of AutoGen section -->
507    ```
508    restricted-float-scalar-type ::=  `f16` | `f32`
509    restricted-float-scalar-vector-type ::=
510      restricted-float-scalar-type |
511      `vector<` integer-literal `x` restricted-float-scalar-type `>`
512    log-op ::= ssa-id `=` `spv.GLSL.Log` ssa-use `:`
513               restricted-float-scalar-vector-type
514    ```
515    #### Example:
516
517    ```mlir
518    %2 = spv.GLSL.Log %0 : f32
519    %3 = spv.GLSL.Log %1 : vector<3xf16>
520    ```
521  }];
522}
523
524// -----
525
526def SPV_GLSLFMaxOp : SPV_GLSLBinaryArithmeticOp<"FMax", 40, SPV_Float> {
527  let summary = "Return maximum of two floating-point operands";
528
529  let description = [{
530    Result is y if x < y; otherwise result is x. Which operand is the
531    result is undefined if one of the operands is a NaN.
532
533    The operands must all be a scalar or vector whose component type
534    is floating-point.
535
536    Result Type and the type of all operands must be the same
537    type. Results are computed per component.
538
539    <!-- End of AutoGen section -->
540    ```
541    float-scalar-vector-type ::= float-type |
542                                 `vector<` integer-literal `x` float-type `>`
543    fmax-op ::= ssa-id `=` `spv.GLSL.FMax` ssa-use `:`
544                float-scalar-vector-type
545    ```
546    #### Example:
547
548    ```mlir
549    %2 = spv.GLSL.FMax %0, %1 : f32
550    %3 = spv.GLSL.FMax %0, %1 : vector<3xf16>
551    ```
552  }];
553}
554
555// -----
556
557def SPV_GLSLSMaxOp : SPV_GLSLBinaryArithmeticOp<"SMax", 42, SPV_Integer> {
558  let summary = "Return maximum of two signed integer operands";
559
560  let description = [{
561    Result is y if x < y; otherwise result is x, where x and y are interpreted
562    as signed integers.
563
564    Result Type and the type of x and y must both be integer scalar or integer
565    vector types. Result Type and operand types must have the same number of
566    components with the same component width. Results are computed per
567    component.
568
569    <!-- End of AutoGen section -->
570    ```
571    integer-scalar-vector-type ::= integer-type |
572                                   `vector<` integer-literal `x` integer-type `>`
573    smax-op ::= ssa-id `=` `spv.GLSL.SMax` ssa-use `:`
574                integer-scalar-vector-type
575    ```
576    #### Example:
577
578    ```mlir
579    %2 = spv.GLSL.SMax %0, %1 : i32
580    %3 = spv.GLSL.SMax %0, %1 : vector<3xi16>
581    ```
582  }];
583}
584
585// -----
586
587def SPV_GLSLFMinOp : SPV_GLSLBinaryArithmeticOp<"FMin", 37, SPV_Float> {
588  let summary = "Return minimum of two floating-point operands";
589
590  let description = [{
591    Result is y if y < x; otherwise result is x. Which operand is the result is
592    undefined if one of the operands is a NaN.
593
594    The operands must all be a scalar or vector whose component type is
595    floating-point.
596
597    Result Type and the type of all operands must be the same type. Results are
598    computed per component.
599
600    <!-- End of AutoGen section -->
601    ```
602    float-scalar-vector-type ::= float-type |
603                                 `vector<` integer-literal `x` float-type `>`
604    fmin-op ::= ssa-id `=` `spv.GLSL.FMin` ssa-use `:`
605                float-scalar-vector-type
606    ```
607    #### Example:
608
609    ```mlir
610    %2 = spv.GLSL.FMin %0, %1 : f32
611    %3 = spv.GLSL.FMin %0, %1 : vector<3xf16>
612    ```
613  }];
614}
615
616// -----
617
618def SPV_GLSLSMinOp : SPV_GLSLBinaryArithmeticOp<"SMin", 39, SPV_Integer> {
619  let summary = "Return minimum of two signed integer operands";
620
621  let description = [{
622    Result is y if y < x; otherwise result is x, where x and y are interpreted
623    as signed integers.
624
625    Result Type and the type of x and y must both be integer scalar or integer
626    vector types. Result Type and operand types must have the same number of
627    components with the same component width. Results are computed per
628    component.
629
630    <!-- End of AutoGen section -->
631    ```
632    integer-scalar-vector-type ::= integer-type |
633                                   `vector<` integer-literal `x` integer-type `>`
634    smin-op ::= ssa-id `=` `spv.GLSL.SMin` ssa-use `:`
635                integer-scalar-vector-type
636    ```
637    #### Example:
638
639    ```mlir
640    %2 = spv.GLSL.SMin %0, %1 : i32
641    %3 = spv.GLSL.SMin %0, %1 : vector<3xi16>
642    ```
643  }];
644}
645
646// -----
647
648def SPV_GLSLPowOp : SPV_GLSLBinaryArithmeticOp<"Pow", 26, SPV_Float16or32> {
649  let summary = "Return x raised to the y power of two operands";
650
651  let description = [{
652    Result is x raised to the y power; x^y.
653
654    Result is undefined if x = 0 and y ≤ 0.
655
656    The operand x and y must be a scalar or vector whose component type is
657    16-bit or 32-bit floating-point.
658
659    Result Type and the type of all operands must be the same type. Results are
660    computed per component.
661
662    <!-- End of AutoGen section -->
663    ```
664    restricted-float-scalar-type ::=  `f16` | `f32`
665    restricted-float-scalar-vector-type ::=
666      restricted-float-scalar-type |
667      `vector<` integer-literal `x` restricted-float-scalar-type `>`
668    pow-op ::= ssa-id `=` `spv.GLSL.Pow` ssa-use `:`
669               restricted-float-scalar-vector-type
670    ```
671    #### Example:
672
673    ```mlir
674    %2 = spv.GLSL.Pow %0, %1 : f32
675    %3 = spv.GLSL.Pow %0, %1 : vector<3xf16>
676    ```
677  }];
678}
679
680// -----
681
682def SPV_GLSLFSignOp : SPV_GLSLUnaryArithmeticOp<"FSign", 6, SPV_Float> {
683  let summary = "Returns the sign of the operand";
684
685  let description = [{
686    Result is 1.0 if x > 0, 0.0 if x = 0, or -1.0 if x < 0.
687
688    The operand x must be a scalar or vector whose component type is
689    floating-point.
690
691    Result Type and the type of x must be the same type. Results are computed
692    per component.
693
694    <!-- End of AutoGen section -->
695    ```
696    float-scalar-vector-type ::= float-type |
697                                 `vector<` integer-literal `x` float-type `>`
698    sign-op ::= ssa-id `=` `spv.GLSL.FSign` ssa-use `:`
699                float-scalar-vector-type
700    ```
701    #### Example:
702
703    ```mlir
704    %2 = spv.GLSL.FSign %0 : f32
705    %3 = spv.GLSL.FSign %1 : vector<3xf16>
706    ```
707  }];
708}
709
710// -----
711
712def SPV_GLSLSSignOp : SPV_GLSLUnaryArithmeticOp<"SSign", 7, SPV_Integer> {
713  let summary = "Returns the sign of the operand";
714
715  let description = [{
716    Result is 1 if x > 0, 0 if x = 0, or -1 if x < 0, where x is interpreted as
717    a signed integer.
718
719    Result Type and the type of x must both be integer scalar or integer vector
720    types. Result Type and operand types must have the same number of components
721    with the same component width. Results are computed per component.
722
723    <!-- End of AutoGen section -->
724    ```
725    integer-scalar-vector-type ::= integer-type |
726                                   `vector<` integer-literal `x` integer-type `>`
727    sign-op ::= ssa-id `=` `spv.GLSL.SSign` ssa-use `:`
728                integer-scalar-vector-type
729    ```
730    #### Example:
731
732    ```mlir
733    %2 = spv.GLSL.SSign %0 : i32
734    %3 = spv.GLSL.SSign %1 : vector<3xi16>
735    ```
736  }];
737}
738
739// -----
740
741def SPV_GLSLSqrtOp : SPV_GLSLUnaryArithmeticOp<"Sqrt", 31, SPV_Float> {
742  let summary = "Returns the square root of the operand";
743
744  let description = [{
745    Result is the square root of x. Result is undefined if x < 0.
746
747    The operand x must be a scalar or vector whose component type is
748    floating-point.
749
750    Result Type and the type of x must be the same type. Results are computed
751    per component.
752
753    <!-- End of AutoGen section -->
754    ```
755    float-scalar-vector-type ::= float-type |
756                                 `vector<` integer-literal `x` float-type `>`
757    sqrt-op ::= ssa-id `=` `spv.GLSL.Sqrt` ssa-use `:`
758                float-scalar-vector-type
759    ```
760    #### Example:
761
762    ```mlir
763    %2 = spv.GLSL.Sqrt %0 : f32
764    %3 = spv.GLSL.Sqrt %1 : vector<3xf16>
765    ```
766  }];
767}
768
769// -----
770
771def SPV_GLSLSinhOp : SPV_GLSLUnaryArithmeticOp<"Sinh", 19, SPV_Float16or32> {
772  let summary = "Hyperbolic sine of operand in radians";
773
774  let description = [{
775    Hyperbolic sine of x radians.
776
777    The operand x must be a scalar or vector whose component type is 16-bit or
778    32-bit floating-point.
779
780    Result Type and the type of x must be the same type. Results are computed
781    per component.
782
783    <!-- End of AutoGen section -->
784    ```
785    restricted-float-scalar-type ::=  `f16` | `f32`
786    restricted-float-scalar-vector-type ::=
787      restricted-float-scalar-type |
788      `vector<` integer-literal `x` restricted-float-scalar-type `>`
789    sinh-op ::= ssa-id `=` `spv.GLSL.Sinh` ssa-use `:`
790                restricted-float-scalar-vector-type
791    ```
792    #### Example:
793
794    ```mlir
795    %2 = spv.GLSL.Sinh %0 : f32
796    %3 = spv.GLSL.Sinh %1 : vector<3xf16>
797    ```
798  }];
799}
800
801// -----
802
803def SPV_GLSLCoshOp : SPV_GLSLUnaryArithmeticOp<"Cosh", 20, SPV_Float16or32> {
804  let summary = "Hyperbolic cosine of operand in radians";
805
806  let description = [{
807    Hyperbolic cosine of x radians.
808
809    The operand x must be a scalar or vector whose component type is 16-bit or
810    32-bit floating-point.
811
812    Result Type and the type of x must be the same type. Results are computed
813    per component.
814
815    <!-- End of AutoGen section -->
816    ```
817    restricted-float-scalar-type ::=  `f16` | `f32`
818    restricted-float-scalar-vector-type ::=
819      restricted-float-scalar-type |
820      `vector<` integer-literal `x` restricted-float-scalar-type `>`
821    cosh-op ::= ssa-id `=` `spv.GLSL.Cosh` ssa-use `:`
822                restricted-float-scalar-vector-type
823    ```
824    #### Example:
825
826    ```mlir
827    %2 = spv.GLSL.Cosh %0 : f32
828    %3 = spv.GLSL.Cosh %1 : vector<3xf16>
829    ```
830  }];
831}
832
833// -----
834
835def SPV_GLSLTanhOp : SPV_GLSLUnaryArithmeticOp<"Tanh", 21, SPV_Float16or32> {
836  let summary = "Hyperbolic tangent of operand in radians";
837
838  let description = [{
839    Hyperbolic tangent of x radians.
840
841    The operand x must be a scalar or vector whose component type is 16-bit or
842    32-bit floating-point.
843
844    Result Type and the type of x must be the same type. Results are computed
845    per component.
846
847    <!-- End of AutoGen section -->
848    ```
849    restricted-float-scalar-type ::=  `f16` | `f32`
850    restricted-float-scalar-vector-type ::=
851      restricted-float-scalar-type |
852      `vector<` integer-literal `x` restricted-float-scalar-type `>`
853    tanh-op ::= ssa-id `=` `spv.GLSL.Tanh` ssa-use `:`
854                restricted-float-scalar-vector-type
855    ```
856    #### Example:
857
858    ```mlir
859    %2 = spv.GLSL.Tanh %0 : f32
860    %3 = spv.GLSL.Tanh %1 : vector<3xf16>
861    ```
862  }];
863}
864
865#endif // SPIRV_GLSL_OPS
866