3 * Copyright © 2009 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.
30 #include "glsl_parser_extras.h"
32 struct _mesa_glsl_parse_state
;
37 * \defgroup AST Abstract syntax tree node definitions
39 * An abstract syntax tree is generated by the parser. This is a fairly
40 * direct representation of the gramma derivation for the source program.
41 * No symantic checking is done during the generation of the AST. Only
42 * syntactic checking is done. Symantic checking is performed by a later
43 * stage that converts the AST to a more generic intermediate representation.
48 * Base class of all abstract syntax tree nodes
52 DECLARE_RALLOC_CXX_OPERATORS(ast_node
);
55 * Print an AST node in something approximating the original GLSL code
57 virtual void print(void) const;
60 * Convert the AST node to the high-level intermediate representation
62 virtual ir_rvalue
*hir(exec_list
*instructions
,
63 struct _mesa_glsl_parse_state
*state
);
65 virtual bool has_sequence_subexpression() const;
68 * Retrieve the source location of an AST node
70 * This function is primarily used to get the source position of an AST node
71 * into a form that can be passed to \c _mesa_glsl_error.
73 * \sa _mesa_glsl_error, ast_node::set_location
75 struct YYLTYPE
get_location(void) const
79 locp
.source
= this->location
.source
;
80 locp
.first_line
= this->location
.first_line
;
81 locp
.first_column
= this->location
.first_column
;
82 locp
.last_line
= this->location
.last_line
;
83 locp
.last_column
= this->location
.last_column
;
89 * Set the source location of an AST node from a parser location
91 * \sa ast_node::get_location
93 void set_location(const struct YYLTYPE
&locp
)
95 this->location
.source
= locp
.source
;
96 this->location
.first_line
= locp
.first_line
;
97 this->location
.first_column
= locp
.first_column
;
98 this->location
.last_line
= locp
.last_line
;
99 this->location
.last_column
= locp
.last_column
;
103 * Set the source location range of an AST node using two location nodes
105 * \sa ast_node::set_location
107 void set_location_range(const struct YYLTYPE
&begin
, const struct YYLTYPE
&end
)
109 this->location
.source
= begin
.source
;
110 this->location
.first_line
= begin
.first_line
;
111 this->location
.last_line
= end
.last_line
;
112 this->location
.first_column
= begin
.first_column
;
113 this->location
.last_column
= end
.last_column
;
117 * Source location of the AST node.
120 unsigned source
; /**< GLSL source number. */
121 unsigned first_line
; /**< First line number within the source string. */
122 unsigned first_column
; /**< First column in the first line. */
123 unsigned last_line
; /**< Last line number within the source string. */
124 unsigned last_column
; /**< Last column in the last line. */
131 * The only constructor is protected so that only derived class objects can
139 * Operators for AST expression nodes.
143 ast_plus
, /**< Unary + operator. */
186 ast_unsized_array_dim
,
202 * Representation of any sort of expression.
204 class ast_expression
: public ast_node
{
206 ast_expression(int oper
, ast_expression
*,
207 ast_expression
*, ast_expression
*);
209 ast_expression(const char *identifier
) :
212 subexpressions
[0] = NULL
;
213 subexpressions
[1] = NULL
;
214 subexpressions
[2] = NULL
;
215 primary_expression
.identifier
= identifier
;
216 this->non_lvalue_description
= NULL
;
217 this->is_lhs
= false;
220 static const char *operator_string(enum ast_operators op
);
222 virtual ir_rvalue
*hir(exec_list
*instructions
,
223 struct _mesa_glsl_parse_state
*state
);
225 virtual void hir_no_rvalue(exec_list
*instructions
,
226 struct _mesa_glsl_parse_state
*state
);
228 virtual bool has_sequence_subexpression() const;
230 ir_rvalue
*do_hir(exec_list
*instructions
,
231 struct _mesa_glsl_parse_state
*state
,
234 virtual void print(void) const;
236 enum ast_operators oper
;
238 ast_expression
*subexpressions
[3];
241 const char *identifier
;
243 float float_constant
;
244 unsigned uint_constant
;
246 double double_constant
;
247 } primary_expression
;
251 * List of expressions for an \c ast_sequence or parameters for an
252 * \c ast_function_call
254 exec_list expressions
;
257 * For things that can't be l-values, this describes what it is.
259 * This text is used by the code that generates IR for assignments to
260 * detect and emit useful messages for assignments to some things that
261 * can't be l-values. For example, pre- or post-incerement expressions.
264 * This pointer may be \c NULL.
266 const char *non_lvalue_description
;
268 void set_is_lhs(bool new_value
);
274 class ast_expression_bin
: public ast_expression
{
276 ast_expression_bin(int oper
, ast_expression
*, ast_expression
*);
278 virtual void print(void) const;
282 * Subclass of expressions for function calls
284 class ast_function_expression
: public ast_expression
{
286 ast_function_expression(ast_expression
*callee
)
287 : ast_expression(ast_function_call
, callee
,
294 ast_function_expression(class ast_type_specifier
*type
)
295 : ast_expression(ast_function_call
, (ast_expression
*) type
,
302 bool is_constructor() const
307 virtual ir_rvalue
*hir(exec_list
*instructions
,
308 struct _mesa_glsl_parse_state
*state
);
310 virtual void hir_no_rvalue(exec_list
*instructions
,
311 struct _mesa_glsl_parse_state
*state
);
313 virtual bool has_sequence_subexpression() const;
317 * Is this function call actually a constructor?
321 handle_method(exec_list
*instructions
,
322 struct _mesa_glsl_parse_state
*state
);
325 class ast_subroutine_list
: public ast_node
328 virtual void print(void) const;
329 exec_list declarations
;
332 class ast_array_specifier
: public ast_node
{
334 ast_array_specifier(const struct YYLTYPE
&locp
, ast_expression
*dim
)
337 array_dimensions
.push_tail(&dim
->link
);
340 void add_dimension(ast_expression
*dim
)
342 array_dimensions
.push_tail(&dim
->link
);
345 bool is_single_dimension() const
347 return this->array_dimensions
.tail_pred
->prev
!= NULL
&&
348 this->array_dimensions
.tail_pred
->prev
->is_head_sentinel();
351 virtual void print(void) const;
353 /* This list contains objects of type ast_node containing the
354 * array dimensions in outermost-to-innermost order.
356 exec_list array_dimensions
;
359 class ast_layout_expression
: public ast_node
{
361 ast_layout_expression(const struct YYLTYPE
&locp
, ast_expression
*expr
)
364 layout_const_expressions
.push_tail(&expr
->link
);
367 bool process_qualifier_constant(struct _mesa_glsl_parse_state
*state
,
368 const char *qual_indentifier
,
369 unsigned *value
, bool can_be_zero
);
371 void merge_qualifier(ast_layout_expression
*l_expr
)
373 layout_const_expressions
.append_list(&l_expr
->layout_const_expressions
);
376 exec_list layout_const_expressions
;
380 * C-style aggregate initialization class
382 * Represents C-style initializers of vectors, matrices, arrays, and
383 * structures. E.g., vec3 pos = {1.0, 0.0, -1.0} is equivalent to
384 * vec3 pos = vec3(1.0, 0.0, -1.0).
386 * Specified in GLSL 4.20 and GL_ARB_shading_language_420pack.
388 * \sa _mesa_ast_set_aggregate_type
390 class ast_aggregate_initializer
: public ast_expression
{
392 ast_aggregate_initializer()
393 : ast_expression(ast_aggregate
, NULL
, NULL
, NULL
),
394 constructor_type(NULL
)
400 * glsl_type of the aggregate, which is inferred from the LHS of whatever
401 * the aggregate is being used to initialize. This can't be inferred at
402 * parse time (since the parser deals with ast_type_specifiers, not
403 * glsl_types), so the parser leaves it NULL. However, the ast-to-hir
404 * conversion code makes sure to fill it in with the appropriate type
405 * before hir() is called.
407 const glsl_type
*constructor_type
;
409 virtual ir_rvalue
*hir(exec_list
*instructions
,
410 struct _mesa_glsl_parse_state
*state
);
412 virtual void hir_no_rvalue(exec_list
*instructions
,
413 struct _mesa_glsl_parse_state
*state
);
417 * Number of possible operators for an ast_expression
419 * This is done as a define instead of as an additional value in the enum so
420 * that the compiler won't generate spurious messages like "warning:
421 * enumeration value ‘ast_num_operators’ not handled in switch"
423 #define AST_NUM_OPERATORS (ast_sequence + 1)
426 class ast_compound_statement
: public ast_node
{
428 ast_compound_statement(int new_scope
, ast_node
*statements
);
429 virtual void print(void) const;
431 virtual ir_rvalue
*hir(exec_list
*instructions
,
432 struct _mesa_glsl_parse_state
*state
);
435 exec_list statements
;
438 class ast_declaration
: public ast_node
{
440 ast_declaration(const char *identifier
,
441 ast_array_specifier
*array_specifier
,
442 ast_expression
*initializer
);
443 virtual void print(void) const;
445 const char *identifier
;
447 ast_array_specifier
*array_specifier
;
449 ast_expression
*initializer
;
454 ast_precision_none
= 0, /**< Absence of precision qualifier. */
456 ast_precision_medium
,
460 struct ast_type_qualifier
{
461 DECLARE_RALLOC_CXX_OPERATORS(ast_type_qualifier
);
465 unsigned invariant
:1;
468 unsigned attribute
:1;
477 unsigned shared_storage
:1;
480 unsigned noperspective
:1;
482 /** \name Layout qualifiers for GL_ARB_fragment_coord_conventions */
484 unsigned origin_upper_left
:1;
485 unsigned pixel_center_integer
:1;
489 * Flag set if GL_ARB_enhanced_layouts "align" layout qualifier is
492 unsigned explicit_align
:1;
495 * Flag set if GL_ARB_explicit_attrib_location "location" layout
498 unsigned explicit_location
:1;
500 * Flag set if GL_ARB_explicit_attrib_location "index" layout
503 unsigned explicit_index
:1;
506 * Flag set if GL_ARB_shading_language_420pack "binding" layout
509 unsigned explicit_binding
:1;
512 * Flag set if GL_ARB_shader_atomic counter "offset" layout
515 unsigned explicit_offset
:1;
517 /** \name Layout qualifiers for GL_AMD_conservative_depth */
519 unsigned depth_any
:1;
520 unsigned depth_greater
:1;
521 unsigned depth_less
:1;
522 unsigned depth_unchanged
:1;
525 /** \name Layout qualifiers for GL_ARB_uniform_buffer_object */
531 unsigned column_major
:1;
532 unsigned row_major
:1;
535 /** \name Layout qualifiers for GLSL 1.50 geometry shaders */
537 unsigned prim_type
:1;
538 unsigned max_vertices
:1;
542 * local_size_{x,y,z} flags for compute shaders. Bit 0 represents
543 * local_size_x, and so on.
545 unsigned local_size
:3;
547 /** \name Layout and memory qualifiers for ARB_shader_image_load_store. */
549 unsigned early_fragment_tests
:1;
550 unsigned explicit_image_format
:1;
552 unsigned _volatile
:1;
553 unsigned restrict_flag
:1;
554 unsigned read_only
:1; /**< "readonly" qualifier. */
555 unsigned write_only
:1; /**< "writeonly" qualifier. */
558 /** \name Layout qualifiers for GL_ARB_gpu_shader5 */
560 unsigned invocations
:1;
561 unsigned stream
:1; /**< Has stream value assigned */
562 unsigned explicit_stream
:1; /**< stream value assigned explicitly by shader code */
565 /** \name Layout qualifiers for GL_ARB_tessellation_shader */
567 /* tess eval input layout */
568 /* gs prim_type reused for primitive mode */
569 unsigned vertex_spacing
:1;
571 unsigned point_mode
:1;
572 /* tess control output layout */
576 /** \name Qualifiers for GL_ARB_shader_subroutine */
578 unsigned subroutine
:1; /**< Is this marked 'subroutine' */
579 unsigned subroutine_def
:1; /**< Is this marked 'subroutine' with a list of types */
582 /** \brief Set of flags, accessed by name. */
585 /** \brief Set of flags, accessed as a bitmask. */
589 /** Precision of the type (highp/medium/lowp). */
590 unsigned precision
:2;
593 * Alignment specified via GL_ARB_enhanced_layouts "align" layout qualifier
595 ast_expression
*align
;
597 /** Geometry shader invocations for GL_ARB_gpu_shader5. */
598 ast_layout_expression
*invocations
;
601 * Location specified via GL_ARB_explicit_attrib_location layout
604 * This field is only valid if \c explicit_location is set.
606 ast_expression
*location
;
608 * Index specified via GL_ARB_explicit_attrib_location layout
611 * This field is only valid if \c explicit_index is set.
613 ast_expression
*index
;
615 /** Maximum output vertices in GLSL 1.50 geometry shaders. */
616 ast_layout_expression
*max_vertices
;
618 /** Stream in GLSL 1.50 geometry shaders. */
619 ast_expression
*stream
;
622 * Input or output primitive type in GLSL 1.50 geometry shaders
623 * and tessellation shaders.
628 * Binding specified via GL_ARB_shading_language_420pack's "binding" keyword.
631 * This field is only valid if \c explicit_binding is set.
633 ast_expression
*binding
;
636 * Offset specified via GL_ARB_shader_atomic_counter's "offset"
640 * This field is only valid if \c explicit_offset is set.
642 ast_expression
*offset
;
645 * Local size specified via GL_ARB_compute_shader's "local_size_{x,y,z}"
646 * layout qualifier. Element i of this array is only valid if
647 * flags.q.local_size & (1 << i) is set.
649 ast_layout_expression
*local_size
[3];
651 /** Tessellation evaluation shader: vertex spacing (equal, fractional even/odd) */
652 GLenum vertex_spacing
;
654 /** Tessellation evaluation shader: vertex ordering (CW or CCW) */
657 /** Tessellation evaluation shader: point mode */
660 /** Tessellation control shader: number of output vertices */
661 ast_layout_expression
*vertices
;
664 * Image format specified with an ARB_shader_image_load_store
668 * This field is only valid if \c explicit_image_format is set.
673 * Base type of the data read from or written to this image. Only
674 * the following enumerants are allowed: GLSL_TYPE_UINT,
675 * GLSL_TYPE_INT, GLSL_TYPE_FLOAT.
678 * This field is only valid if \c explicit_image_format is set.
680 glsl_base_type image_base_type
;
682 /** Flag to know if this represents a default value for a qualifier */
683 bool is_default_qualifier
;
686 * Return true if and only if an interpolation qualifier is present.
688 bool has_interpolation() const;
691 * Return whether a layout qualifier is present.
693 bool has_layout() const;
696 * Return whether a storage qualifier is present.
698 bool has_storage() const;
701 * Return whether an auxiliary storage qualifier is present.
703 bool has_auxiliary_storage() const;
705 bool merge_qualifier(YYLTYPE
*loc
,
706 _mesa_glsl_parse_state
*state
,
707 const ast_type_qualifier
&q
,
708 bool is_single_layout_merge
);
710 bool merge_out_qualifier(YYLTYPE
*loc
,
711 _mesa_glsl_parse_state
*state
,
712 const ast_type_qualifier
&q
,
713 ast_node
* &node
, bool create_node
);
715 bool merge_in_qualifier(YYLTYPE
*loc
,
716 _mesa_glsl_parse_state
*state
,
717 const ast_type_qualifier
&q
,
718 ast_node
* &node
, bool create_node
);
720 ast_subroutine_list
*subroutine_list
;
723 class ast_declarator_list
;
725 class ast_struct_specifier
: public ast_node
{
727 ast_struct_specifier(const char *identifier
,
728 ast_declarator_list
*declarator_list
);
729 virtual void print(void) const;
731 virtual ir_rvalue
*hir(exec_list
*instructions
,
732 struct _mesa_glsl_parse_state
*state
);
735 ast_type_qualifier
*layout
;
736 /* List of ast_declarator_list * */
737 exec_list declarations
;
743 class ast_type_specifier
: public ast_node
{
745 /** Construct a type specifier from a type name */
746 ast_type_specifier(const char *name
)
747 : type_name(name
), structure(NULL
), array_specifier(NULL
),
748 default_precision(ast_precision_none
)
753 /** Construct a type specifier from a structure definition */
754 ast_type_specifier(ast_struct_specifier
*s
)
755 : type_name(s
->name
), structure(s
), array_specifier(NULL
),
756 default_precision(ast_precision_none
)
761 const struct glsl_type
*glsl_type(const char **name
,
762 struct _mesa_glsl_parse_state
*state
)
765 virtual void print(void) const;
767 ir_rvalue
*hir(exec_list
*, struct _mesa_glsl_parse_state
*);
769 const char *type_name
;
770 ast_struct_specifier
*structure
;
772 ast_array_specifier
*array_specifier
;
774 /** For precision statements, this is the given precision; otherwise none. */
775 unsigned default_precision
:2;
779 class ast_fully_specified_type
: public ast_node
{
781 virtual void print(void) const;
782 bool has_qualifiers(_mesa_glsl_parse_state
*state
) const;
784 ast_fully_specified_type() : qualifier(), specifier(NULL
)
788 const struct glsl_type
*glsl_type(const char **name
,
789 struct _mesa_glsl_parse_state
*state
)
792 ast_type_qualifier qualifier
;
793 ast_type_specifier
*specifier
;
797 class ast_declarator_list
: public ast_node
{
799 ast_declarator_list(ast_fully_specified_type
*);
800 virtual void print(void) const;
802 virtual ir_rvalue
*hir(exec_list
*instructions
,
803 struct _mesa_glsl_parse_state
*state
);
805 ast_fully_specified_type
*type
;
806 /** List of 'ast_declaration *' */
807 exec_list declarations
;
810 * Flags for redeclarations. In these cases, no type is specified, to
811 * `type` is allowed to be NULL. In all other cases, this would be an error.
813 int invariant
; /** < `invariant` redeclaration */
814 int precise
; /** < `precise` redeclaration */
818 class ast_parameter_declarator
: public ast_node
{
820 ast_parameter_declarator() :
823 array_specifier(NULL
),
824 formal_parameter(false),
830 virtual void print(void) const;
832 virtual ir_rvalue
*hir(exec_list
*instructions
,
833 struct _mesa_glsl_parse_state
*state
);
835 ast_fully_specified_type
*type
;
836 const char *identifier
;
837 ast_array_specifier
*array_specifier
;
839 static void parameters_to_hir(exec_list
*ast_parameters
,
840 bool formal
, exec_list
*ir_parameters
,
841 struct _mesa_glsl_parse_state
*state
);
844 /** Is this parameter declaration part of a formal parameter list? */
845 bool formal_parameter
;
848 * Is this parameter 'void' type?
850 * This field is set by \c ::hir.
856 class ast_function
: public ast_node
{
860 virtual void print(void) const;
862 virtual ir_rvalue
*hir(exec_list
*instructions
,
863 struct _mesa_glsl_parse_state
*state
);
865 ast_fully_specified_type
*return_type
;
866 const char *identifier
;
868 exec_list parameters
;
872 * Is this prototype part of the function definition?
874 * Used by ast_function_definition::hir to process the parameters, etc.
882 * Function signature corresponding to this function prototype instance
884 * Used by ast_function_definition::hir to process the parameters, etc.
889 class ir_function_signature
*signature
;
891 friend class ast_function_definition
;
895 class ast_expression_statement
: public ast_node
{
897 ast_expression_statement(ast_expression
*);
898 virtual void print(void) const;
900 virtual ir_rvalue
*hir(exec_list
*instructions
,
901 struct _mesa_glsl_parse_state
*state
);
903 ast_expression
*expression
;
907 class ast_case_label
: public ast_node
{
909 ast_case_label(ast_expression
*test_value
);
910 virtual void print(void) const;
912 virtual ir_rvalue
*hir(exec_list
*instructions
,
913 struct _mesa_glsl_parse_state
*state
);
916 * An test value of NULL means 'default'.
918 ast_expression
*test_value
;
922 class ast_case_label_list
: public ast_node
{
924 ast_case_label_list(void);
925 virtual void print(void) const;
927 virtual ir_rvalue
*hir(exec_list
*instructions
,
928 struct _mesa_glsl_parse_state
*state
);
931 * A list of case labels.
937 class ast_case_statement
: public ast_node
{
939 ast_case_statement(ast_case_label_list
*labels
);
940 virtual void print(void) const;
942 virtual ir_rvalue
*hir(exec_list
*instructions
,
943 struct _mesa_glsl_parse_state
*state
);
945 ast_case_label_list
*labels
;
948 * A list of statements.
954 class ast_case_statement_list
: public ast_node
{
956 ast_case_statement_list(void);
957 virtual void print(void) const;
959 virtual ir_rvalue
*hir(exec_list
*instructions
,
960 struct _mesa_glsl_parse_state
*state
);
969 class ast_switch_body
: public ast_node
{
971 ast_switch_body(ast_case_statement_list
*stmts
);
972 virtual void print(void) const;
974 virtual ir_rvalue
*hir(exec_list
*instructions
,
975 struct _mesa_glsl_parse_state
*state
);
977 ast_case_statement_list
*stmts
;
981 class ast_selection_statement
: public ast_node
{
983 ast_selection_statement(ast_expression
*condition
,
984 ast_node
*then_statement
,
985 ast_node
*else_statement
);
986 virtual void print(void) const;
988 virtual ir_rvalue
*hir(exec_list
*instructions
,
989 struct _mesa_glsl_parse_state
*state
);
991 ast_expression
*condition
;
992 ast_node
*then_statement
;
993 ast_node
*else_statement
;
997 class ast_switch_statement
: public ast_node
{
999 ast_switch_statement(ast_expression
*test_expression
,
1001 virtual void print(void) const;
1003 virtual ir_rvalue
*hir(exec_list
*instructions
,
1004 struct _mesa_glsl_parse_state
*state
);
1006 ast_expression
*test_expression
;
1010 void test_to_hir(exec_list
*, struct _mesa_glsl_parse_state
*);
1013 class ast_iteration_statement
: public ast_node
{
1015 ast_iteration_statement(int mode
, ast_node
*init
, ast_node
*condition
,
1016 ast_expression
*rest_expression
, ast_node
*body
);
1018 virtual void print(void) const;
1020 virtual ir_rvalue
*hir(exec_list
*, struct _mesa_glsl_parse_state
*);
1022 enum ast_iteration_modes
{
1029 ast_node
*init_statement
;
1030 ast_node
*condition
;
1031 ast_expression
*rest_expression
;
1036 * Generate IR from the condition of a loop
1038 * This is factored out of ::hir because some loops have the condition
1039 * test at the top (for and while), and others have it at the end (do-while).
1041 void condition_to_hir(exec_list
*, struct _mesa_glsl_parse_state
*);
1045 class ast_jump_statement
: public ast_node
{
1047 ast_jump_statement(int mode
, ast_expression
*return_value
);
1048 virtual void print(void) const;
1050 virtual ir_rvalue
*hir(exec_list
*instructions
,
1051 struct _mesa_glsl_parse_state
*state
);
1053 enum ast_jump_modes
{
1060 ast_expression
*opt_return_value
;
1064 class ast_function_definition
: public ast_node
{
1066 ast_function_definition() : prototype(NULL
), body(NULL
)
1070 virtual void print(void) const;
1072 virtual ir_rvalue
*hir(exec_list
*instructions
,
1073 struct _mesa_glsl_parse_state
*state
);
1075 ast_function
*prototype
;
1076 ast_compound_statement
*body
;
1079 class ast_interface_block
: public ast_node
{
1081 ast_interface_block(const char *instance_name
,
1082 ast_array_specifier
*array_specifier
)
1083 : block_name(NULL
), instance_name(instance_name
),
1084 array_specifier(array_specifier
)
1088 virtual ir_rvalue
*hir(exec_list
*instructions
,
1089 struct _mesa_glsl_parse_state
*state
);
1091 ast_type_qualifier layout
;
1092 const char *block_name
;
1095 * Declared name of the block instance, if specified.
1097 * If the block does not have an instance name, this field will be
1100 const char *instance_name
;
1102 /** List of ast_declarator_list * */
1103 exec_list declarations
;
1106 * Declared array size of the block instance
1108 * If the block is not declared as an array or if the block instance array
1109 * is unsized, this field will be \c NULL.
1111 ast_array_specifier
*array_specifier
;
1116 * AST node representing a declaration of the output layout for tessellation
1119 class ast_tcs_output_layout
: public ast_node
1122 ast_tcs_output_layout(const struct YYLTYPE
&locp
)
1127 virtual ir_rvalue
*hir(exec_list
*instructions
,
1128 struct _mesa_glsl_parse_state
*state
);
1133 * AST node representing a declaration of the input layout for geometry
1136 class ast_gs_input_layout
: public ast_node
1139 ast_gs_input_layout(const struct YYLTYPE
&locp
, GLenum prim_type
)
1140 : prim_type(prim_type
)
1145 virtual ir_rvalue
*hir(exec_list
*instructions
,
1146 struct _mesa_glsl_parse_state
*state
);
1149 const GLenum prim_type
;
1154 * AST node representing a decalaration of the input layout for compute
1157 class ast_cs_input_layout
: public ast_node
1160 ast_cs_input_layout(const struct YYLTYPE
&locp
,
1161 ast_layout_expression
*const *local_size
)
1163 for (int i
= 0; i
< 3; i
++) {
1164 this->local_size
[i
] = local_size
[i
];
1169 virtual ir_rvalue
*hir(exec_list
*instructions
,
1170 struct _mesa_glsl_parse_state
*state
);
1173 ast_layout_expression
*local_size
[3];
1179 _mesa_ast_to_hir(exec_list
*instructions
, struct _mesa_glsl_parse_state
*state
);
1182 _mesa_ast_field_selection_to_hir(const ast_expression
*expr
,
1183 exec_list
*instructions
,
1184 struct _mesa_glsl_parse_state
*state
);
1187 _mesa_ast_array_index_to_hir(void *mem_ctx
,
1188 struct _mesa_glsl_parse_state
*state
,
1189 ir_rvalue
*array
, ir_rvalue
*idx
,
1190 YYLTYPE
&loc
, YYLTYPE
&idx_loc
);
1193 _mesa_ast_set_aggregate_type(const glsl_type
*type
,
1194 ast_expression
*expr
);
1197 emit_function(_mesa_glsl_parse_state
*state
, ir_function
*f
);
1200 check_builtin_array_max_size(const char *name
, unsigned size
,
1201 YYLTYPE loc
, struct _mesa_glsl_parse_state
*state
);
1203 extern void _mesa_ast_process_interface_block(YYLTYPE
*locp
,
1204 _mesa_glsl_parse_state
*state
,
1205 ast_interface_block
*const block
,
1206 const struct ast_type_qualifier
&q
);