3 * Copyright © 2010 Intel Corporation
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
37 #include "ir_visitor.h"
38 #include "ir_hierarchical_visitor.h"
41 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
50 ir_type_dereference_array
,
51 ir_type_dereference_record
,
52 ir_type_dereference_variable
,
56 ir_type_function_signature
,
63 ir_type_max
, /**< maximum ir_type enum number, for validation */
67 * Base class of all IR instructions
69 class ir_instruction
: public exec_node
{
71 enum ir_node_type ir_type
;
72 const struct glsl_type
*type
;
74 /** ir_print_visitor helper for debugging. */
75 void print(void) const;
77 virtual void accept(ir_visitor
*) = 0;
78 virtual ir_visitor_status
accept(ir_hierarchical_visitor
*) = 0;
79 virtual ir_instruction
*clone(struct hash_table
*ht
) const = 0;
82 * \name IR instruction downcast functions
84 * These functions either cast the object to a derived class or return
85 * \c NULL if the object's type does not match the specified derived class.
86 * Additional downcast functions will be added as needed.
89 virtual class ir_variable
* as_variable() { return NULL
; }
90 virtual class ir_function
* as_function() { return NULL
; }
91 virtual class ir_dereference
* as_dereference() { return NULL
; }
92 virtual class ir_dereference_array
* as_dereference_array() { return NULL
; }
93 virtual class ir_dereference_variable
*as_dereference_variable() { return NULL
; }
94 virtual class ir_expression
* as_expression() { return NULL
; }
95 virtual class ir_rvalue
* as_rvalue() { return NULL
; }
96 virtual class ir_loop
* as_loop() { return NULL
; }
97 virtual class ir_assignment
* as_assignment() { return NULL
; }
98 virtual class ir_call
* as_call() { return NULL
; }
99 virtual class ir_return
* as_return() { return NULL
; }
100 virtual class ir_if
* as_if() { return NULL
; }
101 virtual class ir_swizzle
* as_swizzle() { return NULL
; }
102 virtual class ir_constant
* as_constant() { return NULL
; }
108 ir_type
= ir_type_unset
;
114 class ir_rvalue
: public ir_instruction
{
116 virtual ir_rvalue
*clone(struct hash_table
*) const = 0;
118 virtual ir_constant
*constant_expression_value() = 0;
120 virtual ir_rvalue
* as_rvalue()
125 virtual bool is_lvalue()
131 * Get the variable that is ultimately referenced by an r-value
133 virtual ir_variable
*variable_referenced()
140 * If an r-value is a reference to a whole variable, get that variable
143 * Pointer to a variable that is completely dereferenced by the r-value. If
144 * the r-value is not a dereference or the dereference does not access the
145 * entire variable (i.e., it's just one array element, struct field), \c NULL
148 virtual ir_variable
*whole_variable_referenced()
158 enum ir_variable_mode
{
164 ir_var_temporary
/**< Temporary variable generated during compilation. */
167 enum ir_variable_interpolation
{
174 class ir_variable
: public ir_instruction
{
176 ir_variable(const struct glsl_type
*, const char *, ir_variable_mode
);
178 virtual ir_variable
*clone(struct hash_table
*ht
) const;
180 virtual ir_variable
*as_variable()
185 virtual void accept(ir_visitor
*v
)
190 virtual ir_visitor_status
accept(ir_hierarchical_visitor
*);
194 * Get the string value for the interpolation qualifier
197 * If none of \c shader_in or \c shader_out is set, an empty string will
198 * be returned. Otherwise the string that would be used in a shader to
199 * specify \c mode will be returned.
201 const char *interpolation_string() const;
204 * Calculate the number of slots required to hold this variable
206 * This is used to determine how many uniform or varying locations a variable
207 * occupies. The count is in units of floating point components.
209 unsigned component_slots() const;
214 * Highest element accessed with a constant expression array index
216 * Not used for non-array variables.
218 unsigned max_array_access
;
220 unsigned read_only
:1;
222 unsigned invariant
:1;
223 /** If the variable is initialized outside of the scope of the shader */
224 unsigned shader_in
:1;
226 * If the variable value is later used outside of the scope of the shader.
228 unsigned shader_out
:1;
231 unsigned interpolation
:2;
234 * Flag that the whole array is assignable
236 * In GLSL 1.20 and later whole arrays are assignable (and comparable for
237 * equality). This flag enables this behavior.
239 unsigned array_lvalue
:1;
242 * Storage location of the base of this variable
244 * The precise meaning of this field depends on the nature of the variable.
246 * - Vertex shader input: one of the values from \c gl_vert_attrib.
247 * - Vertex shader output: one of the values from \c gl_vert_result.
248 * - Fragment shader input: one of the values from \c gl_frag_attrib.
249 * - Fragment shader output: one of the values from \c gl_frag_result.
250 * - Uniforms: Per-stage uniform slot number.
251 * - Other: This field is not currently used.
253 * If the variable is a uniform, shader input, or shader output, and the
254 * slot has not been assigned, the value will be -1.
259 * Emit a warning if this variable is accessed.
261 const char *warn_extension
;
264 * Value assigned in the initializer of a variable declared "const"
266 ir_constant
*constant_value
;
272 * The representation of a function instance; may be the full definition or
273 * simply a prototype.
275 class ir_function_signature
: public ir_instruction
{
276 /* An ir_function_signature will be part of the list of signatures in
280 ir_function_signature(const glsl_type
*return_type
);
282 virtual ir_function_signature
*clone(struct hash_table
*ht
) const;
284 virtual void accept(ir_visitor
*v
)
289 virtual ir_visitor_status
accept(ir_hierarchical_visitor
*);
292 * Get the name of the function for which this is a signature
294 const char *function_name() const;
297 * Get a handle to the function for which this is a signature
299 * There is no setter function, this function returns a \c const pointer,
300 * and \c ir_function_signature::_function is private for a reason. The
301 * only way to make a connection between a function and function signature
302 * is via \c ir_function::add_signature. This helps ensure that certain
303 * invariants (i.e., a function signature is in the list of signatures for
304 * its \c _function) are met.
306 * \sa ir_function::add_signature
308 inline const class ir_function
*function() const
310 return this->_function
;
314 * Check whether the qualifiers match between this signature's parameters
315 * and the supplied parameter list. If not, returns the name of the first
316 * parameter with mismatched qualifiers (for use in error messages).
318 const char *qualifiers_match(exec_list
*params
);
321 * Replace the current parameter list with the given one. This is useful
322 * if the current information came from a prototype, and either has invalid
323 * or missing parameter names.
325 void replace_parameters(exec_list
*new_params
);
328 * Function return type.
330 * \note This discards the optional precision qualifier.
332 const struct glsl_type
*return_type
;
335 * List of ir_variable of function parameters.
337 * This represents the storage. The paramaters passed in a particular
338 * call will be in ir_call::actual_paramaters.
340 struct exec_list parameters
;
342 /** Whether or not this function has a body (which may be empty). */
343 unsigned is_defined
:1;
345 /** Whether or not this function signature is a built-in. */
346 unsigned is_built_in
:1;
348 /** Body of instructions in the function. */
349 struct exec_list body
;
352 /** Function of which this signature is one overload. */
353 class ir_function
*_function
;
355 friend class ir_function
;
360 * Header for tracking multiple overloaded functions with the same name.
361 * Contains a list of ir_function_signatures representing each of the
364 class ir_function
: public ir_instruction
{
366 ir_function(const char *name
);
368 virtual ir_function
*clone(struct hash_table
*ht
) const;
370 virtual ir_function
*as_function()
375 virtual void accept(ir_visitor
*v
)
380 virtual ir_visitor_status
accept(ir_hierarchical_visitor
*);
382 void add_signature(ir_function_signature
*sig
)
384 sig
->_function
= this;
385 this->signatures
.push_tail(sig
);
389 * Get an iterator for the set of function signatures
391 exec_list_iterator
iterator()
393 return signatures
.iterator();
397 * Find a signature that matches a set of actual parameters, taking implicit
398 * conversions into account.
400 ir_function_signature
*matching_signature(const exec_list
*actual_param
);
403 * Find a signature that exactly matches a set of actual parameters without
404 * any implicit type conversions.
406 ir_function_signature
*exact_matching_signature(const exec_list
*actual_ps
);
409 * Name of the function.
415 * List of ir_function_signature for each overloaded function with this name.
417 struct exec_list signatures
;
420 inline const char *ir_function_signature::function_name() const
422 return this->_function
->name
;
428 * IR instruction representing high-level if-statements
430 class ir_if
: public ir_instruction
{
432 ir_if(ir_rvalue
*condition
)
433 : condition(condition
)
435 ir_type
= ir_type_if
;
438 virtual ir_if
*clone(struct hash_table
*ht
) const;
440 virtual ir_if
*as_if()
445 virtual void accept(ir_visitor
*v
)
450 virtual ir_visitor_status
accept(ir_hierarchical_visitor
*);
452 ir_rvalue
*condition
;
453 /** List of ir_instruction for the body of the then branch */
454 exec_list then_instructions
;
455 /** List of ir_instruction for the body of the else branch */
456 exec_list else_instructions
;
461 * IR instruction representing a high-level loop structure.
463 class ir_loop
: public ir_instruction
{
465 ir_loop() : from(NULL
), to(NULL
), increment(NULL
), counter(NULL
)
467 ir_type
= ir_type_loop
;
470 virtual ir_loop
*clone(struct hash_table
*ht
) const;
472 virtual void accept(ir_visitor
*v
)
477 virtual ir_visitor_status
accept(ir_hierarchical_visitor
*);
479 virtual ir_loop
*as_loop()
485 * Get an iterator for the instructions of the loop body
487 exec_list_iterator
iterator()
489 return body_instructions
.iterator();
492 /** List of ir_instruction that make up the body of the loop. */
493 exec_list body_instructions
;
496 * \name Loop counter and controls
501 ir_rvalue
*increment
;
502 ir_variable
*counter
;
507 class ir_assignment
: public ir_instruction
{
509 ir_assignment(ir_rvalue
*lhs
, ir_rvalue
*rhs
, ir_rvalue
*condition
);
511 virtual ir_assignment
*clone(struct hash_table
*ht
) const;
513 virtual ir_constant
*constant_expression_value();
515 virtual void accept(ir_visitor
*v
)
520 virtual ir_visitor_status
accept(ir_hierarchical_visitor
*);
522 virtual ir_assignment
* as_assignment()
528 * Left-hand side of the assignment.
533 * Value being assigned
538 * Optional condition for the assignment.
540 ir_rvalue
*condition
;
543 /* Update ir_expression::num_operands() and operator_strs when
544 * updating this list.
546 enum ir_expression_operation
{
559 ir_unop_f2i
, /**< Float-to-integer conversion. */
560 ir_unop_i2f
, /**< Integer-to-float conversion. */
561 ir_unop_f2b
, /**< Float-to-boolean conversion */
562 ir_unop_b2f
, /**< Boolean-to-float conversion */
563 ir_unop_i2b
, /**< int-to-boolean conversion */
564 ir_unop_b2i
, /**< Boolean-to-int conversion */
565 ir_unop_u2f
, /**< Unsigned-to-float conversion. */
568 * \name Unary floating-point rounding operations.
578 * \name Trigonometric operations.
586 * \name Partial derivatives.
599 * Takes one of two combinations of arguments:
604 * Does not take integer types.
609 * \name Binary comparison operators
621 * \name Bit-wise binary operations.
643 class ir_expression
: public ir_rvalue
{
645 ir_expression(int op
, const struct glsl_type
*type
,
646 ir_rvalue
*, ir_rvalue
*);
648 virtual ir_expression
*as_expression()
653 virtual ir_expression
*clone(struct hash_table
*ht
) const;
655 virtual ir_constant
*constant_expression_value();
657 static unsigned int get_num_operands(ir_expression_operation
);
658 unsigned int get_num_operands() const
660 return get_num_operands(operation
);
664 * Return a string representing this expression's operator.
666 const char *operator_string();
669 * Do a reverse-lookup to translate the given string into an operator.
671 static ir_expression_operation
get_operator(const char *);
673 virtual void accept(ir_visitor
*v
)
678 virtual ir_visitor_status
accept(ir_hierarchical_visitor
*);
680 ir_expression_operation operation
;
681 ir_rvalue
*operands
[2];
686 * IR instruction representing a function call
688 class ir_call
: public ir_rvalue
{
690 ir_call(ir_function_signature
*callee
, exec_list
*actual_parameters
)
693 ir_type
= ir_type_call
;
694 assert(callee
->return_type
!= NULL
);
695 type
= callee
->return_type
;
696 actual_parameters
->move_nodes_to(& this->actual_parameters
);
699 virtual ir_call
*clone(struct hash_table
*ht
) const;
701 virtual ir_constant
*constant_expression_value();
703 virtual ir_call
*as_call()
708 virtual void accept(ir_visitor
*v
)
713 virtual ir_visitor_status
accept(ir_hierarchical_visitor
*);
716 * Get a generic ir_call object when an error occurs
718 * Any allocation will be performed with 'ctx' as talloc owner.
720 static ir_call
*get_error_instruction(void *ctx
);
723 * Get an iterator for the set of acutal parameters
725 exec_list_iterator
iterator()
727 return actual_parameters
.iterator();
731 * Get the name of the function being called.
733 const char *callee_name() const
735 return callee
->function_name();
738 ir_function_signature
*get_callee()
744 * Set the function call target
746 void set_callee(ir_function_signature
*sig
);
749 * Generates an inline version of the function before @ir,
750 * returning the return value of the function.
752 ir_rvalue
*generate_inline(ir_instruction
*ir
);
754 /* List of ir_rvalue of paramaters passed in this call. */
755 exec_list actual_parameters
;
761 this->ir_type
= ir_type_call
;
764 ir_function_signature
*callee
;
769 * \name Jump-like IR instructions.
771 * These include \c break, \c continue, \c return, and \c discard.
774 class ir_jump
: public ir_instruction
{
778 ir_type
= ir_type_unset
;
782 class ir_return
: public ir_jump
{
787 this->ir_type
= ir_type_return
;
790 ir_return(ir_rvalue
*value
)
793 this->ir_type
= ir_type_return
;
796 virtual ir_return
*clone(struct hash_table
*) const;
798 virtual ir_return
*as_return()
803 ir_rvalue
*get_value() const
808 virtual void accept(ir_visitor
*v
)
813 virtual ir_visitor_status
accept(ir_hierarchical_visitor
*);
820 * Jump instructions used inside loops
822 * These include \c break and \c continue. The \c break within a loop is
823 * different from the \c break within a switch-statement.
827 class ir_loop_jump
: public ir_jump
{
834 ir_loop_jump(jump_mode mode
)
836 this->ir_type
= ir_type_loop_jump
;
841 virtual ir_loop_jump
*clone(struct hash_table
*) const;
843 virtual void accept(ir_visitor
*v
)
848 virtual ir_visitor_status
accept(ir_hierarchical_visitor
*);
850 bool is_break() const
852 return mode
== jump_break
;
855 bool is_continue() const
857 return mode
== jump_continue
;
860 /** Mode selector for the jump instruction. */
863 /** Loop containing this break instruction. */
868 * IR instruction representing discard statements.
870 class ir_discard
: public ir_jump
{
874 this->ir_type
= ir_type_discard
;
875 this->condition
= NULL
;
878 ir_discard(ir_rvalue
*cond
)
880 this->condition
= cond
;
883 virtual ir_discard
*clone(struct hash_table
*ht
) const;
885 virtual void accept(ir_visitor
*v
)
890 virtual ir_visitor_status
accept(ir_hierarchical_visitor
*);
892 ir_rvalue
*condition
;
898 * Texture sampling opcodes used in ir_texture
900 enum ir_texture_opcode
{
901 ir_tex
, /* Regular texture look-up */
902 ir_txb
, /* Texture look-up with LOD bias */
903 ir_txl
, /* Texture look-up with explicit LOD */
904 ir_txd
, /* Texture look-up with partial derivatvies */
905 ir_txf
/* Texel fetch with explicit LOD */
910 * IR instruction to sample a texture
912 * The specific form of the IR instruction depends on the \c mode value
913 * selected from \c ir_texture_opcodes. In the printed IR, these will
917 * | Projection divisor
918 * | | Shadow comparitor
921 * (tex (sampler) (coordinate) (0 0 0) (1) ( ))
922 * (txb (sampler) (coordinate) (0 0 0) (1) ( ) (bias))
923 * (txl (sampler) (coordinate) (0 0 0) (1) ( ) (lod))
924 * (txd (sampler) (coordinate) (0 0 0) (1) ( ) (dPdx dPdy))
925 * (txf (sampler) (coordinate) (0 0 0) (lod))
927 class ir_texture
: public ir_rvalue
{
929 ir_texture(enum ir_texture_opcode op
)
930 : op(op
), projector(NULL
), shadow_comparitor(NULL
)
932 this->ir_type
= ir_type_texture
;
935 virtual ir_texture
*clone(struct hash_table
*) const;
937 virtual ir_constant
*constant_expression_value();
939 virtual void accept(ir_visitor
*v
)
944 virtual ir_visitor_status
accept(ir_hierarchical_visitor
*);
947 * Return a string representing the ir_texture_opcode.
949 const char *opcode_string();
951 /** Set the sampler and infer the type. */
952 void set_sampler(ir_dereference
*sampler
);
955 * Do a reverse-lookup to translate a string into an ir_texture_opcode.
957 static ir_texture_opcode
get_opcode(const char *);
959 enum ir_texture_opcode op
;
961 /** Sampler to use for the texture access. */
962 ir_dereference
*sampler
;
964 /** Texture coordinate to sample */
965 ir_rvalue
*coordinate
;
968 * Value used for projective divide.
970 * If there is no projective divide (the common case), this will be
971 * \c NULL. Optimization passes should check for this to point to a constant
972 * of 1.0 and replace that with \c NULL.
974 ir_rvalue
*projector
;
977 * Coordinate used for comparison on shadow look-ups.
979 * If there is no shadow comparison, this will be \c NULL. For the
980 * \c ir_txf opcode, this *must* be \c NULL.
982 ir_rvalue
*shadow_comparitor
;
984 /** Explicit texel offsets. */
985 signed char offsets
[3];
988 ir_rvalue
*lod
; /**< Floating point LOD */
989 ir_rvalue
*bias
; /**< Floating point LOD bias */
991 ir_rvalue
*dPdx
; /**< Partial derivative of coordinate wrt X */
992 ir_rvalue
*dPdy
; /**< Partial derivative of coordinate wrt Y */
998 struct ir_swizzle_mask
{
1005 * Number of components in the swizzle.
1007 unsigned num_components
:3;
1010 * Does the swizzle contain duplicate components?
1012 * L-value swizzles cannot contain duplicate components.
1014 unsigned has_duplicates
:1;
1018 class ir_swizzle
: public ir_rvalue
{
1020 ir_swizzle(ir_rvalue
*, unsigned x
, unsigned y
, unsigned z
, unsigned w
,
1023 ir_swizzle(ir_rvalue
*val
, const unsigned *components
, unsigned count
);
1025 ir_swizzle(ir_rvalue
*val
, ir_swizzle_mask mask
);
1027 virtual ir_swizzle
*clone(struct hash_table
*) const;
1029 virtual ir_constant
*constant_expression_value();
1031 virtual ir_swizzle
*as_swizzle()
1037 * Construct an ir_swizzle from the textual representation. Can fail.
1039 static ir_swizzle
*create(ir_rvalue
*, const char *, unsigned vector_length
);
1041 virtual void accept(ir_visitor
*v
)
1046 virtual ir_visitor_status
accept(ir_hierarchical_visitor
*);
1050 return val
->is_lvalue() && !mask
.has_duplicates
;
1054 * Get the variable that is ultimately referenced by an r-value
1056 virtual ir_variable
*variable_referenced();
1059 ir_swizzle_mask mask
;
1063 * Initialize the mask component of a swizzle
1065 * This is used by the \c ir_swizzle constructors.
1067 void init_mask(const unsigned *components
, unsigned count
);
1071 class ir_dereference
: public ir_rvalue
{
1073 virtual ir_dereference
*clone(struct hash_table
*) const = 0;
1075 virtual ir_dereference
*as_dereference()
1083 * Get the variable that is ultimately referenced by an r-value
1085 virtual ir_variable
*variable_referenced() = 0;
1089 class ir_dereference_variable
: public ir_dereference
{
1091 ir_dereference_variable(ir_variable
*var
);
1093 virtual ir_dereference_variable
*clone(struct hash_table
*) const;
1095 virtual ir_constant
*constant_expression_value();
1097 virtual ir_dereference_variable
*as_dereference_variable()
1103 * Get the variable that is ultimately referenced by an r-value
1105 virtual ir_variable
*variable_referenced()
1110 virtual ir_variable
*whole_variable_referenced()
1112 /* ir_dereference_variable objects always dereference the entire
1113 * variable. However, if this dereference is dereferenced by anything
1114 * else, the complete deferefernce chain is not a whole-variable
1115 * dereference. This method should only be called on the top most
1116 * ir_rvalue in a dereference chain.
1121 virtual void accept(ir_visitor
*v
)
1126 virtual ir_visitor_status
accept(ir_hierarchical_visitor
*);
1129 * Object being dereferenced.
1135 class ir_dereference_array
: public ir_dereference
{
1137 ir_dereference_array(ir_rvalue
*value
, ir_rvalue
*array_index
);
1139 ir_dereference_array(ir_variable
*var
, ir_rvalue
*array_index
);
1141 virtual ir_dereference_array
*clone(struct hash_table
*) const;
1143 virtual ir_constant
*constant_expression_value();
1145 virtual ir_dereference_array
*as_dereference_array()
1151 * Get the variable that is ultimately referenced by an r-value
1153 virtual ir_variable
*variable_referenced()
1155 return this->array
->variable_referenced();
1158 virtual void accept(ir_visitor
*v
)
1163 virtual ir_visitor_status
accept(ir_hierarchical_visitor
*);
1166 ir_rvalue
*array_index
;
1169 void set_array(ir_rvalue
*value
);
1173 class ir_dereference_record
: public ir_dereference
{
1175 ir_dereference_record(ir_rvalue
*value
, const char *field
);
1177 ir_dereference_record(ir_variable
*var
, const char *field
);
1179 virtual ir_dereference_record
*clone(struct hash_table
*) const;
1181 virtual ir_constant
*constant_expression_value();
1184 * Get the variable that is ultimately referenced by an r-value
1186 virtual ir_variable
*variable_referenced()
1188 return this->record
->variable_referenced();
1191 virtual void accept(ir_visitor
*v
)
1196 virtual ir_visitor_status
accept(ir_hierarchical_visitor
*);
1204 * Data stored in an ir_constant
1206 union ir_constant_data
{
1214 class ir_constant
: public ir_rvalue
{
1216 ir_constant(const struct glsl_type
*type
, const ir_constant_data
*data
);
1217 ir_constant(bool b
);
1218 ir_constant(unsigned int u
);
1220 ir_constant(float f
);
1223 * Construct an ir_constant from a list of ir_constant values
1225 ir_constant(const struct glsl_type
*type
, exec_list
*values
);
1228 * Construct an ir_constant from a scalar component of another ir_constant
1230 * The new \c ir_constant inherits the type of the component from the
1234 * In the case of a matrix constant, the new constant is a scalar, \b not
1237 ir_constant(const ir_constant
*c
, unsigned i
);
1239 virtual ir_constant
*clone(struct hash_table
*) const;
1241 virtual ir_constant
*constant_expression_value();
1243 virtual ir_constant
*as_constant()
1248 virtual void accept(ir_visitor
*v
)
1253 virtual ir_visitor_status
accept(ir_hierarchical_visitor
*);
1256 * Get a particular component of a constant as a specific type
1258 * This is useful, for example, to get a value from an integer constant
1259 * as a float or bool. This appears frequently when constructors are
1260 * called with all constant parameters.
1263 bool get_bool_component(unsigned i
) const;
1264 float get_float_component(unsigned i
) const;
1265 int get_int_component(unsigned i
) const;
1266 unsigned get_uint_component(unsigned i
) const;
1269 ir_constant
*get_array_element(unsigned i
) const;
1271 ir_constant
*get_record_field(const char *name
);
1274 * Determine whether a constant has the same value as another constant
1276 bool has_value(const ir_constant
*) const;
1279 * Value of the constant.
1281 * The field used to back the values supplied by the constant is determined
1282 * by the type associated with the \c ir_instruction. Constants may be
1283 * scalars, vectors, or matrices.
1285 union ir_constant_data value
;
1287 /* Array elements */
1288 ir_constant
**array_elements
;
1290 /* Structure fields */
1291 exec_list components
;
1295 * Parameterless constructor only used by the clone method
1301 visit_exec_list(exec_list
*list
, ir_visitor
*visitor
);
1303 void validate_ir_tree(exec_list
*instructions
);
1306 * Make a clone of each IR instruction in a list
1308 * \param in List of IR instructions that are to be cloned
1309 * \param out List to hold the cloned instructions
1312 clone_ir_list(exec_list
*out
, const exec_list
*in
);
1315 _mesa_glsl_initialize_variables(exec_list
*instructions
,
1316 struct _mesa_glsl_parse_state
*state
);
1319 _mesa_glsl_initialize_functions(exec_list
*instructions
,
1320 struct _mesa_glsl_parse_state
*state
);
1323 _mesa_glsl_release_functions(void);
1326 reparent_ir(exec_list
*list
, void *mem_ctx
);
1328 class glsl_symbol_table
;
1331 import_prototypes(const exec_list
*source
, exec_list
*dest
,
1332 class glsl_symbol_table
*symbols
, void *mem_ctx
);