glsl: Pull enum ir_expression_operation out to its own file
[mesa.git] / src / compiler / glsl / ir_expression_operation.h
1 /*
2 * Copyright (C) 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24 /* Update ir_expression::get_num_operands() and operator_strs when
25 * updating this list.
26 */
27 enum ir_expression_operation {
28 ir_unop_bit_not,
29 ir_unop_logic_not,
30 ir_unop_neg,
31 ir_unop_abs,
32 ir_unop_sign,
33 ir_unop_rcp,
34 ir_unop_rsq,
35 ir_unop_sqrt,
36 ir_unop_exp, /**< Log base e on gentype */
37 ir_unop_log, /**< Natural log on gentype */
38 ir_unop_exp2,
39 ir_unop_log2,
40 ir_unop_f2i, /**< Float-to-integer conversion. */
41 ir_unop_f2u, /**< Float-to-unsigned conversion. */
42 ir_unop_i2f, /**< Integer-to-float conversion. */
43 ir_unop_f2b, /**< Float-to-boolean conversion */
44 ir_unop_b2f, /**< Boolean-to-float conversion */
45 ir_unop_i2b, /**< int-to-boolean conversion */
46 ir_unop_b2i, /**< Boolean-to-int conversion */
47 ir_unop_u2f, /**< Unsigned-to-float conversion. */
48 ir_unop_i2u, /**< Integer-to-unsigned conversion. */
49 ir_unop_u2i, /**< Unsigned-to-integer conversion. */
50 ir_unop_d2f, /**< Double-to-float conversion. */
51 ir_unop_f2d, /**< Float-to-double conversion. */
52 ir_unop_d2i, /**< Double-to-integer conversion. */
53 ir_unop_i2d, /**< Integer-to-double conversion. */
54 ir_unop_d2u, /**< Double-to-unsigned conversion. */
55 ir_unop_u2d, /**< Unsigned-to-double conversion. */
56 ir_unop_d2b, /**< Double-to-boolean conversion. */
57 ir_unop_bitcast_i2f, /**< Bit-identical int-to-float "conversion" */
58 ir_unop_bitcast_f2i, /**< Bit-identical float-to-int "conversion" */
59 ir_unop_bitcast_u2f, /**< Bit-identical uint-to-float "conversion" */
60 ir_unop_bitcast_f2u, /**< Bit-identical float-to-uint "conversion" */
61
62 /**
63 * \name Unary floating-point rounding operations.
64 */
65 /*@{*/
66 ir_unop_trunc,
67 ir_unop_ceil,
68 ir_unop_floor,
69 ir_unop_fract,
70 ir_unop_round_even,
71 /*@}*/
72
73 /**
74 * \name Trigonometric operations.
75 */
76 /*@{*/
77 ir_unop_sin,
78 ir_unop_cos,
79 /*@}*/
80
81 /**
82 * \name Partial derivatives.
83 */
84 /*@{*/
85 ir_unop_dFdx,
86 ir_unop_dFdx_coarse,
87 ir_unop_dFdx_fine,
88 ir_unop_dFdy,
89 ir_unop_dFdy_coarse,
90 ir_unop_dFdy_fine,
91 /*@}*/
92
93 /**
94 * \name Floating point pack and unpack operations.
95 */
96 /*@{*/
97 ir_unop_pack_snorm_2x16,
98 ir_unop_pack_snorm_4x8,
99 ir_unop_pack_unorm_2x16,
100 ir_unop_pack_unorm_4x8,
101 ir_unop_pack_half_2x16,
102 ir_unop_unpack_snorm_2x16,
103 ir_unop_unpack_snorm_4x8,
104 ir_unop_unpack_unorm_2x16,
105 ir_unop_unpack_unorm_4x8,
106 ir_unop_unpack_half_2x16,
107 /*@}*/
108
109 /**
110 * \name Bit operations, part of ARB_gpu_shader5.
111 */
112 /*@{*/
113 ir_unop_bitfield_reverse,
114 ir_unop_bit_count,
115 ir_unop_find_msb,
116 ir_unop_find_lsb,
117 /*@}*/
118
119 ir_unop_saturate,
120
121 /**
122 * \name Double packing, part of ARB_gpu_shader_fp64.
123 */
124 /*@{*/
125 ir_unop_pack_double_2x32,
126 ir_unop_unpack_double_2x32,
127 /*@}*/
128
129 ir_unop_frexp_sig,
130 ir_unop_frexp_exp,
131
132 ir_unop_noise,
133
134 ir_unop_subroutine_to_int,
135 /**
136 * Interpolate fs input at centroid
137 *
138 * operand0 is the fs input.
139 */
140 ir_unop_interpolate_at_centroid,
141
142 /**
143 * Ask the driver for the total size of a buffer block.
144 *
145 * operand0 is the ir_constant buffer block index in the linked shader.
146 */
147 ir_unop_get_buffer_size,
148
149 /**
150 * Calculate length of an unsized array inside a buffer block.
151 * This opcode is going to be replaced in a lowering pass inside
152 * the linker.
153 *
154 * operand0 is the unsized array's ir_value for the calculation
155 * of its length.
156 */
157 ir_unop_ssbo_unsized_array_length,
158
159 /**
160 * Vote among threads on the value of the boolean argument.
161 */
162 ir_unop_vote_any,
163 ir_unop_vote_all,
164 ir_unop_vote_eq,
165
166 /**
167 * A sentinel marking the last of the unary operations.
168 */
169 ir_last_unop = ir_unop_vote_eq,
170
171 ir_binop_add,
172 ir_binop_sub,
173 ir_binop_mul, /**< Floating-point or low 32-bit integer multiply. */
174 ir_binop_imul_high, /**< Calculates the high 32-bits of a 64-bit multiply. */
175 ir_binop_div,
176
177 /**
178 * Returns the carry resulting from the addition of the two arguments.
179 */
180 /*@{*/
181 ir_binop_carry,
182 /*@}*/
183
184 /**
185 * Returns the borrow resulting from the subtraction of the second argument
186 * from the first argument.
187 */
188 /*@{*/
189 ir_binop_borrow,
190 /*@}*/
191
192 /**
193 * Takes one of two combinations of arguments:
194 *
195 * - mod(vecN, vecN)
196 * - mod(vecN, float)
197 *
198 * Does not take integer types.
199 */
200 ir_binop_mod,
201
202 /**
203 * \name Binary comparison operators which return a boolean vector.
204 * The type of both operands must be equal.
205 */
206 /*@{*/
207 ir_binop_less,
208 ir_binop_greater,
209 ir_binop_lequal,
210 ir_binop_gequal,
211 ir_binop_equal,
212 ir_binop_nequal,
213 /**
214 * Returns single boolean for whether all components of operands[0]
215 * equal the components of operands[1].
216 */
217 ir_binop_all_equal,
218 /**
219 * Returns single boolean for whether any component of operands[0]
220 * is not equal to the corresponding component of operands[1].
221 */
222 ir_binop_any_nequal,
223 /*@}*/
224
225 /**
226 * \name Bit-wise binary operations.
227 */
228 /*@{*/
229 ir_binop_lshift,
230 ir_binop_rshift,
231 ir_binop_bit_and,
232 ir_binop_bit_xor,
233 ir_binop_bit_or,
234 /*@}*/
235
236 ir_binop_logic_and,
237 ir_binop_logic_xor,
238 ir_binop_logic_or,
239
240 ir_binop_dot,
241 ir_binop_min,
242 ir_binop_max,
243
244 ir_binop_pow,
245
246 /**
247 * Load a value the size of a given GLSL type from a uniform block.
248 *
249 * operand0 is the ir_constant uniform block index in the linked shader.
250 * operand1 is a byte offset within the uniform block.
251 */
252 ir_binop_ubo_load,
253
254 /**
255 * \name Multiplies a number by two to a power, part of ARB_gpu_shader5.
256 */
257 /*@{*/
258 ir_binop_ldexp,
259 /*@}*/
260
261 /**
262 * Extract a scalar from a vector
263 *
264 * operand0 is the vector
265 * operand1 is the index of the field to read from operand0
266 */
267 ir_binop_vector_extract,
268
269 /**
270 * Interpolate fs input at offset
271 *
272 * operand0 is the fs input
273 * operand1 is the offset from the pixel center
274 */
275 ir_binop_interpolate_at_offset,
276
277 /**
278 * Interpolate fs input at sample position
279 *
280 * operand0 is the fs input
281 * operand1 is the sample ID
282 */
283 ir_binop_interpolate_at_sample,
284
285 /**
286 * A sentinel marking the last of the binary operations.
287 */
288 ir_last_binop = ir_binop_interpolate_at_sample,
289
290 /**
291 * \name Fused floating-point multiply-add, part of ARB_gpu_shader5.
292 */
293 /*@{*/
294 ir_triop_fma,
295 /*@}*/
296
297 ir_triop_lrp,
298
299 /**
300 * \name Conditional Select
301 *
302 * A vector conditional select instruction (like ?:, but operating per-
303 * component on vectors).
304 *
305 * \see lower_instructions_visitor::ldexp_to_arith
306 */
307 /*@{*/
308 ir_triop_csel,
309 /*@}*/
310
311 ir_triop_bitfield_extract,
312
313 /**
314 * Generate a value with one field of a vector changed
315 *
316 * operand0 is the vector
317 * operand1 is the value to write into the vector result
318 * operand2 is the index in operand0 to be modified
319 */
320 ir_triop_vector_insert,
321
322 /**
323 * A sentinel marking the last of the ternary operations.
324 */
325 ir_last_triop = ir_triop_vector_insert,
326
327 ir_quadop_bitfield_insert,
328
329 ir_quadop_vector,
330
331 /**
332 * A sentinel marking the last of the ternary operations.
333 */
334 ir_last_quadop = ir_quadop_vector,
335
336 /**
337 * A sentinel marking the last of all operations.
338 */
339 ir_last_opcode = ir_quadop_vector
340 };