2 * Copyright © 2010 Intel Corporation
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:
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
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.
42 * Base class of all IR instructions
44 class ir_instruction
: public simple_node
{
47 const struct glsl_type
*type
;
50 ir_instruction(int mode
);
54 * Dummy constructor to catch bad constructors in derived classes.
56 * Every derived must use the constructor that sets the instructions
57 * mode. Having the \c void constructor private prevents derived classes
58 * from accidentally doing the wrong thing.
64 enum ir_variable_mode
{
72 enum ir_varaible_interpolation
{
78 class ir_variable
: public ir_instruction
{
80 ir_variable(const struct glsl_type
*, const char *);
89 unsigned interpolation
:2;
93 class ir_label
: public ir_instruction
{
95 ir_label(const char *label
);
102 class ir_function_signature
: public ir_instruction
{
104 ir_function_signature(void);
107 * Function return type.
109 * \note This discards the optional precision qualifier.
111 const struct glsl_type
*return_type
;
114 * List of function parameters stored as ir_variable objects.
116 struct simple_node parameters
;
119 * Pointer to the label that begins the function definition.
121 ir_label
*definition
;
126 * Header for tracking functions in the symbol table
128 class ir_function
: public ir_instruction
{
133 * Name of the function.
137 struct simple_node signatures
;
142 class ir_dereference
;
144 class ir_assignment
: public ir_instruction
{
146 ir_assignment(ir_instruction
*lhs
, ir_instruction
*rhs
,
147 ir_expression
*condition
);
150 * Left-hand side of the assignment.
155 * Value being assigned
157 * This should be either \c ir_op_expression or \c ir_op_deference.
162 * Optional condition for the assignment.
164 ir_expression
*condition
;
168 enum ir_expression_operation
{
177 ir_unop_f2i
, /**< Float-to-integer conversion. */
178 ir_unop_i2f
, /**< Integer-to-float conversion. */
181 * \name Unary floating-point rounding operations.
196 * \name Binary comparison operators
208 * \name Bit-wise binary operations.
230 class ir_expression
: public ir_instruction
{
232 ir_expression(int op
, const struct glsl_type
*type
,
233 ir_instruction
*, ir_instruction
*);
235 ir_expression_operation operation
;
236 ir_instruction
*operands
[2];
240 struct ir_swizzle_mask
{
247 * Number of components in the swizzle.
249 unsigned num_components
:2;
252 * Does the swizzle contain duplicate components?
254 * L-value swizzles cannot contain duplicate components.
256 unsigned has_duplicates
:1;
259 class ir_dereference
: public ir_instruction
{
261 ir_dereference(struct ir_instruction
*);
264 ir_reference_variable
,
270 * Object being dereferenced.
272 * Must be either an \c ir_variable or an \c ir_deference.
277 ir_expression
*array_index
;
279 struct ir_swizzle_mask swizzle
;
284 class ir_constant
: public ir_instruction
{
286 ir_constant(const struct glsl_type
*type
, const void *data
);
289 * Value of the constant.
291 * The field used to back the values supplied by the constant is determined
292 * by the type associated with the \c ir_instruction. Constants may be
293 * scalars, vectors, or matrices.