1bf215546Sopenharmony_ci/* -*- c++ -*- */ 2bf215546Sopenharmony_ci/* 3bf215546Sopenharmony_ci * Copyright © 2009 Intel Corporation 4bf215546Sopenharmony_ci * 5bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 6bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 7bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 8bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 10bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 11bf215546Sopenharmony_ci * 12bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 13bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 14bf215546Sopenharmony_ci * Software. 15bf215546Sopenharmony_ci * 16bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22bf215546Sopenharmony_ci * DEALINGS IN THE SOFTWARE. 23bf215546Sopenharmony_ci */ 24bf215546Sopenharmony_ci 25bf215546Sopenharmony_ci#ifndef AST_H 26bf215546Sopenharmony_ci#define AST_H 27bf215546Sopenharmony_ci 28bf215546Sopenharmony_ci#include "list.h" 29bf215546Sopenharmony_ci#include "glsl_parser_extras.h" 30bf215546Sopenharmony_ci#include "compiler/glsl_types.h" 31bf215546Sopenharmony_ci#include "util/bitset.h" 32bf215546Sopenharmony_ci 33bf215546Sopenharmony_cistruct _mesa_glsl_parse_state; 34bf215546Sopenharmony_ci 35bf215546Sopenharmony_cistruct YYLTYPE; 36bf215546Sopenharmony_ci 37bf215546Sopenharmony_ci/** 38bf215546Sopenharmony_ci * \defgroup AST Abstract syntax tree node definitions 39bf215546Sopenharmony_ci * 40bf215546Sopenharmony_ci * An abstract syntax tree is generated by the parser. This is a fairly 41bf215546Sopenharmony_ci * direct representation of the gramma derivation for the source program. 42bf215546Sopenharmony_ci * No symantic checking is done during the generation of the AST. Only 43bf215546Sopenharmony_ci * syntactic checking is done. Symantic checking is performed by a later 44bf215546Sopenharmony_ci * stage that converts the AST to a more generic intermediate representation. 45bf215546Sopenharmony_ci * 46bf215546Sopenharmony_ci *@{ 47bf215546Sopenharmony_ci */ 48bf215546Sopenharmony_ci/** 49bf215546Sopenharmony_ci * Base class of all abstract syntax tree nodes 50bf215546Sopenharmony_ci */ 51bf215546Sopenharmony_ciclass ast_node { 52bf215546Sopenharmony_cipublic: 53bf215546Sopenharmony_ci DECLARE_LINEAR_ZALLOC_CXX_OPERATORS(ast_node); 54bf215546Sopenharmony_ci 55bf215546Sopenharmony_ci /** 56bf215546Sopenharmony_ci * Print an AST node in something approximating the original GLSL code 57bf215546Sopenharmony_ci */ 58bf215546Sopenharmony_ci virtual void print(void) const; 59bf215546Sopenharmony_ci 60bf215546Sopenharmony_ci /** 61bf215546Sopenharmony_ci * Convert the AST node to the high-level intermediate representation 62bf215546Sopenharmony_ci */ 63bf215546Sopenharmony_ci virtual ir_rvalue *hir(exec_list *instructions, 64bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 65bf215546Sopenharmony_ci 66bf215546Sopenharmony_ci virtual bool has_sequence_subexpression() const; 67bf215546Sopenharmony_ci 68bf215546Sopenharmony_ci /** 69bf215546Sopenharmony_ci * Retrieve the source location of an AST node 70bf215546Sopenharmony_ci * 71bf215546Sopenharmony_ci * This function is primarily used to get the source position of an AST node 72bf215546Sopenharmony_ci * into a form that can be passed to \c _mesa_glsl_error. 73bf215546Sopenharmony_ci * 74bf215546Sopenharmony_ci * \sa _mesa_glsl_error, ast_node::set_location 75bf215546Sopenharmony_ci */ 76bf215546Sopenharmony_ci struct YYLTYPE get_location(void) const 77bf215546Sopenharmony_ci { 78bf215546Sopenharmony_ci struct YYLTYPE locp; 79bf215546Sopenharmony_ci 80bf215546Sopenharmony_ci locp.path = this->location.path; 81bf215546Sopenharmony_ci locp.source = this->location.source; 82bf215546Sopenharmony_ci locp.first_line = this->location.first_line; 83bf215546Sopenharmony_ci locp.first_column = this->location.first_column; 84bf215546Sopenharmony_ci locp.last_line = this->location.last_line; 85bf215546Sopenharmony_ci locp.last_column = this->location.last_column; 86bf215546Sopenharmony_ci 87bf215546Sopenharmony_ci return locp; 88bf215546Sopenharmony_ci } 89bf215546Sopenharmony_ci 90bf215546Sopenharmony_ci /** 91bf215546Sopenharmony_ci * Set the source location of an AST node from a parser location 92bf215546Sopenharmony_ci * 93bf215546Sopenharmony_ci * \sa ast_node::get_location 94bf215546Sopenharmony_ci */ 95bf215546Sopenharmony_ci void set_location(const struct YYLTYPE &locp) 96bf215546Sopenharmony_ci { 97bf215546Sopenharmony_ci this->location.path = locp.path; 98bf215546Sopenharmony_ci this->location.source = locp.source; 99bf215546Sopenharmony_ci this->location.first_line = locp.first_line; 100bf215546Sopenharmony_ci this->location.first_column = locp.first_column; 101bf215546Sopenharmony_ci this->location.last_line = locp.last_line; 102bf215546Sopenharmony_ci this->location.last_column = locp.last_column; 103bf215546Sopenharmony_ci } 104bf215546Sopenharmony_ci 105bf215546Sopenharmony_ci /** 106bf215546Sopenharmony_ci * Set the source location range of an AST node using two location nodes 107bf215546Sopenharmony_ci * 108bf215546Sopenharmony_ci * \sa ast_node::set_location 109bf215546Sopenharmony_ci */ 110bf215546Sopenharmony_ci void set_location_range(const struct YYLTYPE &begin, const struct YYLTYPE &end) 111bf215546Sopenharmony_ci { 112bf215546Sopenharmony_ci this->location.path = begin.path; 113bf215546Sopenharmony_ci this->location.source = begin.source; 114bf215546Sopenharmony_ci this->location.first_line = begin.first_line; 115bf215546Sopenharmony_ci this->location.last_line = end.last_line; 116bf215546Sopenharmony_ci this->location.first_column = begin.first_column; 117bf215546Sopenharmony_ci this->location.last_column = end.last_column; 118bf215546Sopenharmony_ci } 119bf215546Sopenharmony_ci 120bf215546Sopenharmony_ci /** 121bf215546Sopenharmony_ci * Source location of the AST node. 122bf215546Sopenharmony_ci */ 123bf215546Sopenharmony_ci struct { 124bf215546Sopenharmony_ci char *path; /**< GLSL shader include path. */ 125bf215546Sopenharmony_ci unsigned source; /**< GLSL source number. */ 126bf215546Sopenharmony_ci unsigned first_line; /**< First line number within the source string. */ 127bf215546Sopenharmony_ci unsigned first_column; /**< First column in the first line. */ 128bf215546Sopenharmony_ci unsigned last_line; /**< Last line number within the source string. */ 129bf215546Sopenharmony_ci unsigned last_column; /**< Last column in the last line. */ 130bf215546Sopenharmony_ci } location; 131bf215546Sopenharmony_ci 132bf215546Sopenharmony_ci exec_node link; 133bf215546Sopenharmony_ci 134bf215546Sopenharmony_ci virtual void set_is_lhs(bool); 135bf215546Sopenharmony_ci 136bf215546Sopenharmony_ciprotected: 137bf215546Sopenharmony_ci /** 138bf215546Sopenharmony_ci * The only constructor is protected so that only derived class objects can 139bf215546Sopenharmony_ci * be created. 140bf215546Sopenharmony_ci */ 141bf215546Sopenharmony_ci ast_node(void); 142bf215546Sopenharmony_ci}; 143bf215546Sopenharmony_ci 144bf215546Sopenharmony_ci 145bf215546Sopenharmony_ci/** 146bf215546Sopenharmony_ci * Operators for AST expression nodes. 147bf215546Sopenharmony_ci */ 148bf215546Sopenharmony_cienum ast_operators { 149bf215546Sopenharmony_ci ast_assign, 150bf215546Sopenharmony_ci ast_plus, /**< Unary + operator. */ 151bf215546Sopenharmony_ci ast_neg, 152bf215546Sopenharmony_ci ast_add, 153bf215546Sopenharmony_ci ast_sub, 154bf215546Sopenharmony_ci ast_mul, 155bf215546Sopenharmony_ci ast_div, 156bf215546Sopenharmony_ci ast_mod, 157bf215546Sopenharmony_ci ast_lshift, 158bf215546Sopenharmony_ci ast_rshift, 159bf215546Sopenharmony_ci ast_less, 160bf215546Sopenharmony_ci ast_greater, 161bf215546Sopenharmony_ci ast_lequal, 162bf215546Sopenharmony_ci ast_gequal, 163bf215546Sopenharmony_ci ast_equal, 164bf215546Sopenharmony_ci ast_nequal, 165bf215546Sopenharmony_ci ast_bit_and, 166bf215546Sopenharmony_ci ast_bit_xor, 167bf215546Sopenharmony_ci ast_bit_or, 168bf215546Sopenharmony_ci ast_bit_not, 169bf215546Sopenharmony_ci ast_logic_and, 170bf215546Sopenharmony_ci ast_logic_xor, 171bf215546Sopenharmony_ci ast_logic_or, 172bf215546Sopenharmony_ci ast_logic_not, 173bf215546Sopenharmony_ci 174bf215546Sopenharmony_ci ast_mul_assign, 175bf215546Sopenharmony_ci ast_div_assign, 176bf215546Sopenharmony_ci ast_mod_assign, 177bf215546Sopenharmony_ci ast_add_assign, 178bf215546Sopenharmony_ci ast_sub_assign, 179bf215546Sopenharmony_ci ast_ls_assign, 180bf215546Sopenharmony_ci ast_rs_assign, 181bf215546Sopenharmony_ci ast_and_assign, 182bf215546Sopenharmony_ci ast_xor_assign, 183bf215546Sopenharmony_ci ast_or_assign, 184bf215546Sopenharmony_ci 185bf215546Sopenharmony_ci ast_conditional, 186bf215546Sopenharmony_ci 187bf215546Sopenharmony_ci ast_pre_inc, 188bf215546Sopenharmony_ci ast_pre_dec, 189bf215546Sopenharmony_ci ast_post_inc, 190bf215546Sopenharmony_ci ast_post_dec, 191bf215546Sopenharmony_ci ast_field_selection, 192bf215546Sopenharmony_ci ast_array_index, 193bf215546Sopenharmony_ci ast_unsized_array_dim, 194bf215546Sopenharmony_ci 195bf215546Sopenharmony_ci ast_function_call, 196bf215546Sopenharmony_ci 197bf215546Sopenharmony_ci ast_identifier, 198bf215546Sopenharmony_ci ast_int_constant, 199bf215546Sopenharmony_ci ast_uint_constant, 200bf215546Sopenharmony_ci ast_float_constant, 201bf215546Sopenharmony_ci ast_bool_constant, 202bf215546Sopenharmony_ci ast_double_constant, 203bf215546Sopenharmony_ci ast_int64_constant, 204bf215546Sopenharmony_ci ast_uint64_constant, 205bf215546Sopenharmony_ci 206bf215546Sopenharmony_ci ast_sequence, 207bf215546Sopenharmony_ci ast_aggregate 208bf215546Sopenharmony_ci 209bf215546Sopenharmony_ci /** 210bf215546Sopenharmony_ci * Number of possible operators for an ast_expression 211bf215546Sopenharmony_ci * 212bf215546Sopenharmony_ci * This is done as a define instead of as an additional value in the enum so 213bf215546Sopenharmony_ci * that the compiler won't generate spurious messages like "warning: 214bf215546Sopenharmony_ci * enumeration value ‘ast_num_operators’ not handled in switch" 215bf215546Sopenharmony_ci */ 216bf215546Sopenharmony_ci #define AST_NUM_OPERATORS (ast_aggregate + 1) 217bf215546Sopenharmony_ci}; 218bf215546Sopenharmony_ci 219bf215546Sopenharmony_ci/** 220bf215546Sopenharmony_ci * Representation of any sort of expression. 221bf215546Sopenharmony_ci */ 222bf215546Sopenharmony_ciclass ast_expression : public ast_node { 223bf215546Sopenharmony_cipublic: 224bf215546Sopenharmony_ci ast_expression(int oper, ast_expression *, 225bf215546Sopenharmony_ci ast_expression *, ast_expression *); 226bf215546Sopenharmony_ci 227bf215546Sopenharmony_ci ast_expression(const char *identifier) : 228bf215546Sopenharmony_ci oper(ast_identifier) 229bf215546Sopenharmony_ci { 230bf215546Sopenharmony_ci subexpressions[0] = NULL; 231bf215546Sopenharmony_ci subexpressions[1] = NULL; 232bf215546Sopenharmony_ci subexpressions[2] = NULL; 233bf215546Sopenharmony_ci primary_expression.identifier = identifier; 234bf215546Sopenharmony_ci this->non_lvalue_description = NULL; 235bf215546Sopenharmony_ci this->is_lhs = false; 236bf215546Sopenharmony_ci } 237bf215546Sopenharmony_ci 238bf215546Sopenharmony_ci static const char *operator_string(enum ast_operators op); 239bf215546Sopenharmony_ci 240bf215546Sopenharmony_ci virtual ir_rvalue *hir(exec_list *instructions, 241bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 242bf215546Sopenharmony_ci 243bf215546Sopenharmony_ci virtual void hir_no_rvalue(exec_list *instructions, 244bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 245bf215546Sopenharmony_ci 246bf215546Sopenharmony_ci virtual bool has_sequence_subexpression() const; 247bf215546Sopenharmony_ci 248bf215546Sopenharmony_ci ir_rvalue *do_hir(exec_list *instructions, 249bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state, 250bf215546Sopenharmony_ci bool needs_rvalue); 251bf215546Sopenharmony_ci 252bf215546Sopenharmony_ci virtual void print(void) const; 253bf215546Sopenharmony_ci 254bf215546Sopenharmony_ci enum ast_operators oper; 255bf215546Sopenharmony_ci 256bf215546Sopenharmony_ci ast_expression *subexpressions[3]; 257bf215546Sopenharmony_ci 258bf215546Sopenharmony_ci union { 259bf215546Sopenharmony_ci const char *identifier; 260bf215546Sopenharmony_ci int int_constant; 261bf215546Sopenharmony_ci float float_constant; 262bf215546Sopenharmony_ci unsigned uint_constant; 263bf215546Sopenharmony_ci int bool_constant; 264bf215546Sopenharmony_ci double double_constant; 265bf215546Sopenharmony_ci uint64_t uint64_constant; 266bf215546Sopenharmony_ci int64_t int64_constant; 267bf215546Sopenharmony_ci } primary_expression; 268bf215546Sopenharmony_ci 269bf215546Sopenharmony_ci 270bf215546Sopenharmony_ci /** 271bf215546Sopenharmony_ci * List of expressions for an \c ast_sequence or parameters for an 272bf215546Sopenharmony_ci * \c ast_function_call 273bf215546Sopenharmony_ci */ 274bf215546Sopenharmony_ci exec_list expressions; 275bf215546Sopenharmony_ci 276bf215546Sopenharmony_ci /** 277bf215546Sopenharmony_ci * For things that can't be l-values, this describes what it is. 278bf215546Sopenharmony_ci * 279bf215546Sopenharmony_ci * This text is used by the code that generates IR for assignments to 280bf215546Sopenharmony_ci * detect and emit useful messages for assignments to some things that 281bf215546Sopenharmony_ci * can't be l-values. For example, pre- or post-incerement expressions. 282bf215546Sopenharmony_ci * 283bf215546Sopenharmony_ci * \note 284bf215546Sopenharmony_ci * This pointer may be \c NULL. 285bf215546Sopenharmony_ci */ 286bf215546Sopenharmony_ci const char *non_lvalue_description; 287bf215546Sopenharmony_ci 288bf215546Sopenharmony_ci void set_is_lhs(bool new_value); 289bf215546Sopenharmony_ci 290bf215546Sopenharmony_ciprivate: 291bf215546Sopenharmony_ci bool is_lhs; 292bf215546Sopenharmony_ci}; 293bf215546Sopenharmony_ci 294bf215546Sopenharmony_ciclass ast_expression_bin : public ast_expression { 295bf215546Sopenharmony_cipublic: 296bf215546Sopenharmony_ci ast_expression_bin(int oper, ast_expression *, ast_expression *); 297bf215546Sopenharmony_ci 298bf215546Sopenharmony_ci virtual void print(void) const; 299bf215546Sopenharmony_ci}; 300bf215546Sopenharmony_ci 301bf215546Sopenharmony_ci/** 302bf215546Sopenharmony_ci * Subclass of expressions for function calls 303bf215546Sopenharmony_ci */ 304bf215546Sopenharmony_ciclass ast_function_expression : public ast_expression { 305bf215546Sopenharmony_cipublic: 306bf215546Sopenharmony_ci ast_function_expression(ast_expression *callee) 307bf215546Sopenharmony_ci : ast_expression(ast_function_call, callee, 308bf215546Sopenharmony_ci NULL, NULL), 309bf215546Sopenharmony_ci cons(false) 310bf215546Sopenharmony_ci { 311bf215546Sopenharmony_ci /* empty */ 312bf215546Sopenharmony_ci } 313bf215546Sopenharmony_ci 314bf215546Sopenharmony_ci ast_function_expression(class ast_type_specifier *type) 315bf215546Sopenharmony_ci : ast_expression(ast_function_call, (ast_expression *) type, 316bf215546Sopenharmony_ci NULL, NULL), 317bf215546Sopenharmony_ci cons(true) 318bf215546Sopenharmony_ci { 319bf215546Sopenharmony_ci /* empty */ 320bf215546Sopenharmony_ci } 321bf215546Sopenharmony_ci 322bf215546Sopenharmony_ci bool is_constructor() const 323bf215546Sopenharmony_ci { 324bf215546Sopenharmony_ci return cons; 325bf215546Sopenharmony_ci } 326bf215546Sopenharmony_ci 327bf215546Sopenharmony_ci virtual ir_rvalue *hir(exec_list *instructions, 328bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 329bf215546Sopenharmony_ci 330bf215546Sopenharmony_ci virtual void hir_no_rvalue(exec_list *instructions, 331bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 332bf215546Sopenharmony_ci 333bf215546Sopenharmony_ci virtual bool has_sequence_subexpression() const; 334bf215546Sopenharmony_ci 335bf215546Sopenharmony_ciprivate: 336bf215546Sopenharmony_ci /** 337bf215546Sopenharmony_ci * Is this function call actually a constructor? 338bf215546Sopenharmony_ci */ 339bf215546Sopenharmony_ci bool cons; 340bf215546Sopenharmony_ci ir_rvalue * 341bf215546Sopenharmony_ci handle_method(exec_list *instructions, 342bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 343bf215546Sopenharmony_ci}; 344bf215546Sopenharmony_ci 345bf215546Sopenharmony_ciclass ast_subroutine_list : public ast_node 346bf215546Sopenharmony_ci{ 347bf215546Sopenharmony_cipublic: 348bf215546Sopenharmony_ci virtual void print(void) const; 349bf215546Sopenharmony_ci exec_list declarations; 350bf215546Sopenharmony_ci}; 351bf215546Sopenharmony_ci 352bf215546Sopenharmony_ciclass ast_array_specifier : public ast_node { 353bf215546Sopenharmony_cipublic: 354bf215546Sopenharmony_ci ast_array_specifier(const struct YYLTYPE &locp, ast_expression *dim) 355bf215546Sopenharmony_ci { 356bf215546Sopenharmony_ci set_location(locp); 357bf215546Sopenharmony_ci array_dimensions.push_tail(&dim->link); 358bf215546Sopenharmony_ci } 359bf215546Sopenharmony_ci 360bf215546Sopenharmony_ci void add_dimension(ast_expression *dim) 361bf215546Sopenharmony_ci { 362bf215546Sopenharmony_ci array_dimensions.push_tail(&dim->link); 363bf215546Sopenharmony_ci } 364bf215546Sopenharmony_ci 365bf215546Sopenharmony_ci bool is_single_dimension() const 366bf215546Sopenharmony_ci { 367bf215546Sopenharmony_ci return this->array_dimensions.get_tail_raw()->prev != NULL && 368bf215546Sopenharmony_ci this->array_dimensions.get_tail_raw()->prev->is_head_sentinel(); 369bf215546Sopenharmony_ci } 370bf215546Sopenharmony_ci 371bf215546Sopenharmony_ci virtual void print(void) const; 372bf215546Sopenharmony_ci 373bf215546Sopenharmony_ci /* This list contains objects of type ast_node containing the 374bf215546Sopenharmony_ci * array dimensions in outermost-to-innermost order. 375bf215546Sopenharmony_ci */ 376bf215546Sopenharmony_ci exec_list array_dimensions; 377bf215546Sopenharmony_ci}; 378bf215546Sopenharmony_ci 379bf215546Sopenharmony_ciclass ast_layout_expression : public ast_node { 380bf215546Sopenharmony_cipublic: 381bf215546Sopenharmony_ci ast_layout_expression(const struct YYLTYPE &locp, ast_expression *expr) 382bf215546Sopenharmony_ci { 383bf215546Sopenharmony_ci set_location(locp); 384bf215546Sopenharmony_ci layout_const_expressions.push_tail(&expr->link); 385bf215546Sopenharmony_ci } 386bf215546Sopenharmony_ci 387bf215546Sopenharmony_ci bool process_qualifier_constant(struct _mesa_glsl_parse_state *state, 388bf215546Sopenharmony_ci const char *qual_indentifier, 389bf215546Sopenharmony_ci unsigned *value, bool can_be_zero); 390bf215546Sopenharmony_ci 391bf215546Sopenharmony_ci void merge_qualifier(ast_layout_expression *l_expr) 392bf215546Sopenharmony_ci { 393bf215546Sopenharmony_ci layout_const_expressions.append_list(&l_expr->layout_const_expressions); 394bf215546Sopenharmony_ci } 395bf215546Sopenharmony_ci 396bf215546Sopenharmony_ci exec_list layout_const_expressions; 397bf215546Sopenharmony_ci}; 398bf215546Sopenharmony_ci 399bf215546Sopenharmony_ci/** 400bf215546Sopenharmony_ci * C-style aggregate initialization class 401bf215546Sopenharmony_ci * 402bf215546Sopenharmony_ci * Represents C-style initializers of vectors, matrices, arrays, and 403bf215546Sopenharmony_ci * structures. E.g., vec3 pos = {1.0, 0.0, -1.0} is equivalent to 404bf215546Sopenharmony_ci * vec3 pos = vec3(1.0, 0.0, -1.0). 405bf215546Sopenharmony_ci * 406bf215546Sopenharmony_ci * Specified in GLSL 4.20 and GL_ARB_shading_language_420pack. 407bf215546Sopenharmony_ci * 408bf215546Sopenharmony_ci * \sa _mesa_ast_set_aggregate_type 409bf215546Sopenharmony_ci */ 410bf215546Sopenharmony_ciclass ast_aggregate_initializer : public ast_expression { 411bf215546Sopenharmony_cipublic: 412bf215546Sopenharmony_ci ast_aggregate_initializer() 413bf215546Sopenharmony_ci : ast_expression(ast_aggregate, NULL, NULL, NULL), 414bf215546Sopenharmony_ci constructor_type(NULL) 415bf215546Sopenharmony_ci { 416bf215546Sopenharmony_ci /* empty */ 417bf215546Sopenharmony_ci } 418bf215546Sopenharmony_ci 419bf215546Sopenharmony_ci /** 420bf215546Sopenharmony_ci * glsl_type of the aggregate, which is inferred from the LHS of whatever 421bf215546Sopenharmony_ci * the aggregate is being used to initialize. This can't be inferred at 422bf215546Sopenharmony_ci * parse time (since the parser deals with ast_type_specifiers, not 423bf215546Sopenharmony_ci * glsl_types), so the parser leaves it NULL. However, the ast-to-hir 424bf215546Sopenharmony_ci * conversion code makes sure to fill it in with the appropriate type 425bf215546Sopenharmony_ci * before hir() is called. 426bf215546Sopenharmony_ci */ 427bf215546Sopenharmony_ci const glsl_type *constructor_type; 428bf215546Sopenharmony_ci 429bf215546Sopenharmony_ci virtual ir_rvalue *hir(exec_list *instructions, 430bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 431bf215546Sopenharmony_ci 432bf215546Sopenharmony_ci virtual void hir_no_rvalue(exec_list *instructions, 433bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 434bf215546Sopenharmony_ci}; 435bf215546Sopenharmony_ci 436bf215546Sopenharmony_ci 437bf215546Sopenharmony_ciclass ast_compound_statement : public ast_node { 438bf215546Sopenharmony_cipublic: 439bf215546Sopenharmony_ci ast_compound_statement(int new_scope, ast_node *statements); 440bf215546Sopenharmony_ci virtual void print(void) const; 441bf215546Sopenharmony_ci 442bf215546Sopenharmony_ci virtual ir_rvalue *hir(exec_list *instructions, 443bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 444bf215546Sopenharmony_ci 445bf215546Sopenharmony_ci int new_scope; 446bf215546Sopenharmony_ci exec_list statements; 447bf215546Sopenharmony_ci}; 448bf215546Sopenharmony_ci 449bf215546Sopenharmony_ciclass ast_declaration : public ast_node { 450bf215546Sopenharmony_cipublic: 451bf215546Sopenharmony_ci ast_declaration(const char *identifier, 452bf215546Sopenharmony_ci ast_array_specifier *array_specifier, 453bf215546Sopenharmony_ci ast_expression *initializer); 454bf215546Sopenharmony_ci virtual void print(void) const; 455bf215546Sopenharmony_ci 456bf215546Sopenharmony_ci const char *identifier; 457bf215546Sopenharmony_ci 458bf215546Sopenharmony_ci ast_array_specifier *array_specifier; 459bf215546Sopenharmony_ci 460bf215546Sopenharmony_ci ast_expression *initializer; 461bf215546Sopenharmony_ci}; 462bf215546Sopenharmony_ci 463bf215546Sopenharmony_ci 464bf215546Sopenharmony_cienum { 465bf215546Sopenharmony_ci ast_precision_none = 0, /**< Absence of precision qualifier. */ 466bf215546Sopenharmony_ci ast_precision_high, 467bf215546Sopenharmony_ci ast_precision_medium, 468bf215546Sopenharmony_ci ast_precision_low 469bf215546Sopenharmony_ci}; 470bf215546Sopenharmony_ci 471bf215546Sopenharmony_cienum { 472bf215546Sopenharmony_ci ast_depth_none = 0, /**< Absence of depth qualifier. */ 473bf215546Sopenharmony_ci ast_depth_any, 474bf215546Sopenharmony_ci ast_depth_greater, 475bf215546Sopenharmony_ci ast_depth_less, 476bf215546Sopenharmony_ci ast_depth_unchanged 477bf215546Sopenharmony_ci}; 478bf215546Sopenharmony_ci 479bf215546Sopenharmony_cistruct ast_type_qualifier { 480bf215546Sopenharmony_ci DECLARE_RALLOC_CXX_OPERATORS(ast_type_qualifier); 481bf215546Sopenharmony_ci /* Note: this bitset needs to have at least as many bits as the 'q' 482bf215546Sopenharmony_ci * struct has flags, below. Previously, the size was 128 instead of 96. 483bf215546Sopenharmony_ci * But an apparent bug in GCC 5.4.0 causes bad SSE code generation 484bf215546Sopenharmony_ci * elsewhere, leading to a crash. 96 bits works around the issue. 485bf215546Sopenharmony_ci * See https://bugs.freedesktop.org/show_bug.cgi?id=105497 486bf215546Sopenharmony_ci */ 487bf215546Sopenharmony_ci DECLARE_BITSET_T(bitset_t, 96); 488bf215546Sopenharmony_ci 489bf215546Sopenharmony_ci union flags { 490bf215546Sopenharmony_ci struct { 491bf215546Sopenharmony_ci unsigned invariant:1; 492bf215546Sopenharmony_ci unsigned precise:1; 493bf215546Sopenharmony_ci unsigned constant:1; 494bf215546Sopenharmony_ci unsigned attribute:1; 495bf215546Sopenharmony_ci unsigned varying:1; 496bf215546Sopenharmony_ci unsigned in:1; 497bf215546Sopenharmony_ci unsigned out:1; 498bf215546Sopenharmony_ci unsigned centroid:1; 499bf215546Sopenharmony_ci unsigned sample:1; 500bf215546Sopenharmony_ci unsigned patch:1; 501bf215546Sopenharmony_ci unsigned uniform:1; 502bf215546Sopenharmony_ci unsigned buffer:1; 503bf215546Sopenharmony_ci unsigned shared_storage:1; 504bf215546Sopenharmony_ci unsigned smooth:1; 505bf215546Sopenharmony_ci unsigned flat:1; 506bf215546Sopenharmony_ci unsigned noperspective:1; 507bf215546Sopenharmony_ci 508bf215546Sopenharmony_ci /** \name Layout qualifiers for GL_ARB_fragment_coord_conventions */ 509bf215546Sopenharmony_ci /*@{*/ 510bf215546Sopenharmony_ci unsigned origin_upper_left:1; 511bf215546Sopenharmony_ci unsigned pixel_center_integer:1; 512bf215546Sopenharmony_ci /*@}*/ 513bf215546Sopenharmony_ci 514bf215546Sopenharmony_ci /** 515bf215546Sopenharmony_ci * Flag set if GL_ARB_enhanced_layouts "align" layout qualifier is 516bf215546Sopenharmony_ci * used. 517bf215546Sopenharmony_ci */ 518bf215546Sopenharmony_ci unsigned explicit_align:1; 519bf215546Sopenharmony_ci 520bf215546Sopenharmony_ci /** 521bf215546Sopenharmony_ci * Flag set if GL_ARB_explicit_attrib_location "location" layout 522bf215546Sopenharmony_ci * qualifier is used. 523bf215546Sopenharmony_ci */ 524bf215546Sopenharmony_ci unsigned explicit_location:1; 525bf215546Sopenharmony_ci /** 526bf215546Sopenharmony_ci * Flag set if GL_ARB_explicit_attrib_location "index" layout 527bf215546Sopenharmony_ci * qualifier is used. 528bf215546Sopenharmony_ci */ 529bf215546Sopenharmony_ci unsigned explicit_index:1; 530bf215546Sopenharmony_ci 531bf215546Sopenharmony_ci /** 532bf215546Sopenharmony_ci * Flag set if GL_ARB_enhanced_layouts "component" layout 533bf215546Sopenharmony_ci * qualifier is used. 534bf215546Sopenharmony_ci */ 535bf215546Sopenharmony_ci unsigned explicit_component:1; 536bf215546Sopenharmony_ci 537bf215546Sopenharmony_ci /** 538bf215546Sopenharmony_ci * Flag set if GL_ARB_shading_language_420pack "binding" layout 539bf215546Sopenharmony_ci * qualifier is used. 540bf215546Sopenharmony_ci */ 541bf215546Sopenharmony_ci unsigned explicit_binding:1; 542bf215546Sopenharmony_ci 543bf215546Sopenharmony_ci /** 544bf215546Sopenharmony_ci * Flag set if GL_ARB_shader_atomic counter "offset" layout 545bf215546Sopenharmony_ci * qualifier is used. 546bf215546Sopenharmony_ci */ 547bf215546Sopenharmony_ci unsigned explicit_offset:1; 548bf215546Sopenharmony_ci 549bf215546Sopenharmony_ci /** \name Layout qualifiers for GL_AMD_conservative_depth */ 550bf215546Sopenharmony_ci /** \{ */ 551bf215546Sopenharmony_ci unsigned depth_type:1; 552bf215546Sopenharmony_ci /** \} */ 553bf215546Sopenharmony_ci 554bf215546Sopenharmony_ci /** \name Layout qualifiers for GL_ARB_uniform_buffer_object */ 555bf215546Sopenharmony_ci /** \{ */ 556bf215546Sopenharmony_ci unsigned std140:1; 557bf215546Sopenharmony_ci unsigned std430:1; 558bf215546Sopenharmony_ci unsigned shared:1; 559bf215546Sopenharmony_ci unsigned packed:1; 560bf215546Sopenharmony_ci unsigned column_major:1; 561bf215546Sopenharmony_ci unsigned row_major:1; 562bf215546Sopenharmony_ci /** \} */ 563bf215546Sopenharmony_ci 564bf215546Sopenharmony_ci /** \name Layout qualifiers for GLSL 1.50 geometry shaders */ 565bf215546Sopenharmony_ci /** \{ */ 566bf215546Sopenharmony_ci unsigned prim_type:1; 567bf215546Sopenharmony_ci unsigned max_vertices:1; 568bf215546Sopenharmony_ci /** \} */ 569bf215546Sopenharmony_ci 570bf215546Sopenharmony_ci /** 571bf215546Sopenharmony_ci * local_size_{x,y,z} flags for compute shaders. Bit 0 represents 572bf215546Sopenharmony_ci * local_size_x, and so on. 573bf215546Sopenharmony_ci */ 574bf215546Sopenharmony_ci unsigned local_size:3; 575bf215546Sopenharmony_ci 576bf215546Sopenharmony_ci /** \name Layout qualifiers for ARB_compute_variable_group_size. */ 577bf215546Sopenharmony_ci /** \{ */ 578bf215546Sopenharmony_ci unsigned local_size_variable:1; 579bf215546Sopenharmony_ci /** \} */ 580bf215546Sopenharmony_ci 581bf215546Sopenharmony_ci /** \name Layout and memory qualifiers for ARB_shader_image_load_store. */ 582bf215546Sopenharmony_ci /** \{ */ 583bf215546Sopenharmony_ci unsigned early_fragment_tests:1; 584bf215546Sopenharmony_ci unsigned explicit_image_format:1; 585bf215546Sopenharmony_ci unsigned coherent:1; 586bf215546Sopenharmony_ci unsigned _volatile:1; 587bf215546Sopenharmony_ci unsigned restrict_flag:1; 588bf215546Sopenharmony_ci unsigned read_only:1; /**< "readonly" qualifier. */ 589bf215546Sopenharmony_ci unsigned write_only:1; /**< "writeonly" qualifier. */ 590bf215546Sopenharmony_ci /** \} */ 591bf215546Sopenharmony_ci 592bf215546Sopenharmony_ci /** \name Layout qualifiers for GL_ARB_gpu_shader5 */ 593bf215546Sopenharmony_ci /** \{ */ 594bf215546Sopenharmony_ci unsigned invocations:1; 595bf215546Sopenharmony_ci unsigned stream:1; /**< Has stream value assigned */ 596bf215546Sopenharmony_ci unsigned explicit_stream:1; /**< stream value assigned explicitly by shader code */ 597bf215546Sopenharmony_ci /** \} */ 598bf215546Sopenharmony_ci 599bf215546Sopenharmony_ci /** \name Layout qualifiers for GL_ARB_enhanced_layouts */ 600bf215546Sopenharmony_ci /** \{ */ 601bf215546Sopenharmony_ci unsigned explicit_xfb_offset:1; /**< xfb_offset value assigned explicitly by shader code */ 602bf215546Sopenharmony_ci unsigned xfb_buffer:1; /**< Has xfb_buffer value assigned */ 603bf215546Sopenharmony_ci unsigned explicit_xfb_buffer:1; /**< xfb_buffer value assigned explicitly by shader code */ 604bf215546Sopenharmony_ci unsigned xfb_stride:1; /**< Is xfb_stride value yet to be merged with global values */ 605bf215546Sopenharmony_ci unsigned explicit_xfb_stride:1; /**< xfb_stride value assigned explicitly by shader code */ 606bf215546Sopenharmony_ci /** \} */ 607bf215546Sopenharmony_ci 608bf215546Sopenharmony_ci /** \name Layout qualifiers for GL_ARB_tessellation_shader */ 609bf215546Sopenharmony_ci /** \{ */ 610bf215546Sopenharmony_ci /* tess eval input layout */ 611bf215546Sopenharmony_ci /* gs prim_type reused for primitive mode */ 612bf215546Sopenharmony_ci unsigned vertex_spacing:1; 613bf215546Sopenharmony_ci unsigned ordering:1; 614bf215546Sopenharmony_ci unsigned point_mode:1; 615bf215546Sopenharmony_ci /* tess control output layout */ 616bf215546Sopenharmony_ci unsigned vertices:1; 617bf215546Sopenharmony_ci /** \} */ 618bf215546Sopenharmony_ci 619bf215546Sopenharmony_ci /** \name Qualifiers for GL_ARB_shader_subroutine */ 620bf215546Sopenharmony_ci /** \{ */ 621bf215546Sopenharmony_ci unsigned subroutine:1; /**< Is this marked 'subroutine' */ 622bf215546Sopenharmony_ci /** \} */ 623bf215546Sopenharmony_ci 624bf215546Sopenharmony_ci /** \name Qualifiers for GL_KHR_blend_equation_advanced */ 625bf215546Sopenharmony_ci /** \{ */ 626bf215546Sopenharmony_ci unsigned blend_support:1; /**< Are there any blend_support_ qualifiers */ 627bf215546Sopenharmony_ci /** \} */ 628bf215546Sopenharmony_ci 629bf215546Sopenharmony_ci /** 630bf215546Sopenharmony_ci * Flag set if GL_ARB_post_depth_coverage layout qualifier is used. 631bf215546Sopenharmony_ci */ 632bf215546Sopenharmony_ci unsigned post_depth_coverage:1; 633bf215546Sopenharmony_ci 634bf215546Sopenharmony_ci /** 635bf215546Sopenharmony_ci * Flags for the layout qualifers added by ARB_fragment_shader_interlock 636bf215546Sopenharmony_ci */ 637bf215546Sopenharmony_ci 638bf215546Sopenharmony_ci unsigned pixel_interlock_ordered:1; 639bf215546Sopenharmony_ci unsigned pixel_interlock_unordered:1; 640bf215546Sopenharmony_ci unsigned sample_interlock_ordered:1; 641bf215546Sopenharmony_ci unsigned sample_interlock_unordered:1; 642bf215546Sopenharmony_ci 643bf215546Sopenharmony_ci /** 644bf215546Sopenharmony_ci * Flag set if GL_INTEL_conservartive_rasterization layout qualifier 645bf215546Sopenharmony_ci * is used. 646bf215546Sopenharmony_ci */ 647bf215546Sopenharmony_ci unsigned inner_coverage:1; 648bf215546Sopenharmony_ci 649bf215546Sopenharmony_ci /** \name Layout qualifiers for GL_ARB_bindless_texture */ 650bf215546Sopenharmony_ci /** \{ */ 651bf215546Sopenharmony_ci unsigned bindless_sampler:1; 652bf215546Sopenharmony_ci unsigned bindless_image:1; 653bf215546Sopenharmony_ci unsigned bound_sampler:1; 654bf215546Sopenharmony_ci unsigned bound_image:1; 655bf215546Sopenharmony_ci /** \} */ 656bf215546Sopenharmony_ci 657bf215546Sopenharmony_ci /** \name Layout qualifiers for GL_EXT_shader_framebuffer_fetch_non_coherent */ 658bf215546Sopenharmony_ci /** \{ */ 659bf215546Sopenharmony_ci unsigned non_coherent:1; 660bf215546Sopenharmony_ci /** \} */ 661bf215546Sopenharmony_ci 662bf215546Sopenharmony_ci /** \name Layout qualifiers for NV_compute_shader_derivatives */ 663bf215546Sopenharmony_ci /** \{ */ 664bf215546Sopenharmony_ci unsigned derivative_group:1; 665bf215546Sopenharmony_ci /** \} */ 666bf215546Sopenharmony_ci 667bf215546Sopenharmony_ci /** 668bf215546Sopenharmony_ci * Flag set if GL_NV_viewport_array2 viewport_relative layout 669bf215546Sopenharmony_ci * qualifier is used. 670bf215546Sopenharmony_ci */ 671bf215546Sopenharmony_ci unsigned viewport_relative:1; 672bf215546Sopenharmony_ci } 673bf215546Sopenharmony_ci /** \brief Set of flags, accessed by name. */ 674bf215546Sopenharmony_ci q; 675bf215546Sopenharmony_ci 676bf215546Sopenharmony_ci /** \brief Set of flags, accessed as a bitmask. */ 677bf215546Sopenharmony_ci bitset_t i; 678bf215546Sopenharmony_ci } flags; 679bf215546Sopenharmony_ci 680bf215546Sopenharmony_ci /** Precision of the type (highp/medium/lowp). */ 681bf215546Sopenharmony_ci unsigned precision:2; 682bf215546Sopenharmony_ci 683bf215546Sopenharmony_ci /** Type of layout qualifiers for GL_AMD_conservative_depth. */ 684bf215546Sopenharmony_ci unsigned depth_type:3; 685bf215546Sopenharmony_ci 686bf215546Sopenharmony_ci /** 687bf215546Sopenharmony_ci * Alignment specified via GL_ARB_enhanced_layouts "align" layout qualifier 688bf215546Sopenharmony_ci */ 689bf215546Sopenharmony_ci ast_expression *align; 690bf215546Sopenharmony_ci 691bf215546Sopenharmony_ci /** Geometry shader invocations for GL_ARB_gpu_shader5. */ 692bf215546Sopenharmony_ci ast_layout_expression *invocations; 693bf215546Sopenharmony_ci 694bf215546Sopenharmony_ci /** 695bf215546Sopenharmony_ci * Location specified via GL_ARB_explicit_attrib_location layout 696bf215546Sopenharmony_ci * 697bf215546Sopenharmony_ci * \note 698bf215546Sopenharmony_ci * This field is only valid if \c explicit_location is set. 699bf215546Sopenharmony_ci */ 700bf215546Sopenharmony_ci ast_expression *location; 701bf215546Sopenharmony_ci /** 702bf215546Sopenharmony_ci * Index specified via GL_ARB_explicit_attrib_location layout 703bf215546Sopenharmony_ci * 704bf215546Sopenharmony_ci * \note 705bf215546Sopenharmony_ci * This field is only valid if \c explicit_index is set. 706bf215546Sopenharmony_ci */ 707bf215546Sopenharmony_ci ast_expression *index; 708bf215546Sopenharmony_ci 709bf215546Sopenharmony_ci /** 710bf215546Sopenharmony_ci * Component specified via GL_ARB_enhaced_layouts 711bf215546Sopenharmony_ci * 712bf215546Sopenharmony_ci * \note 713bf215546Sopenharmony_ci * This field is only valid if \c explicit_component is set. 714bf215546Sopenharmony_ci */ 715bf215546Sopenharmony_ci ast_expression *component; 716bf215546Sopenharmony_ci 717bf215546Sopenharmony_ci /** Maximum output vertices in GLSL 1.50 geometry shaders. */ 718bf215546Sopenharmony_ci ast_layout_expression *max_vertices; 719bf215546Sopenharmony_ci 720bf215546Sopenharmony_ci /** Stream in GLSL 1.50 geometry shaders. */ 721bf215546Sopenharmony_ci ast_expression *stream; 722bf215546Sopenharmony_ci 723bf215546Sopenharmony_ci /** xfb_buffer specified via the GL_ARB_enhanced_layouts keyword. */ 724bf215546Sopenharmony_ci ast_expression *xfb_buffer; 725bf215546Sopenharmony_ci 726bf215546Sopenharmony_ci /** xfb_stride specified via the GL_ARB_enhanced_layouts keyword. */ 727bf215546Sopenharmony_ci ast_expression *xfb_stride; 728bf215546Sopenharmony_ci 729bf215546Sopenharmony_ci /** global xfb_stride values for each buffer */ 730bf215546Sopenharmony_ci ast_layout_expression *out_xfb_stride[MAX_FEEDBACK_BUFFERS]; 731bf215546Sopenharmony_ci 732bf215546Sopenharmony_ci /** 733bf215546Sopenharmony_ci * Input or output primitive type in GLSL 1.50 geometry shaders 734bf215546Sopenharmony_ci * and tessellation shaders. 735bf215546Sopenharmony_ci */ 736bf215546Sopenharmony_ci GLenum prim_type; 737bf215546Sopenharmony_ci 738bf215546Sopenharmony_ci /** 739bf215546Sopenharmony_ci * Binding specified via GL_ARB_shading_language_420pack's "binding" keyword. 740bf215546Sopenharmony_ci * 741bf215546Sopenharmony_ci * \note 742bf215546Sopenharmony_ci * This field is only valid if \c explicit_binding is set. 743bf215546Sopenharmony_ci */ 744bf215546Sopenharmony_ci ast_expression *binding; 745bf215546Sopenharmony_ci 746bf215546Sopenharmony_ci /** 747bf215546Sopenharmony_ci * Offset specified via GL_ARB_shader_atomic_counter's or 748bf215546Sopenharmony_ci * GL_ARB_enhanced_layouts "offset" keyword, or by GL_ARB_enhanced_layouts 749bf215546Sopenharmony_ci * "xfb_offset" keyword. 750bf215546Sopenharmony_ci * 751bf215546Sopenharmony_ci * \note 752bf215546Sopenharmony_ci * This field is only valid if \c explicit_offset is set. 753bf215546Sopenharmony_ci */ 754bf215546Sopenharmony_ci ast_expression *offset; 755bf215546Sopenharmony_ci 756bf215546Sopenharmony_ci /** 757bf215546Sopenharmony_ci * Local size specified via GL_ARB_compute_shader's "local_size_{x,y,z}" 758bf215546Sopenharmony_ci * layout qualifier. Element i of this array is only valid if 759bf215546Sopenharmony_ci * flags.q.local_size & (1 << i) is set. 760bf215546Sopenharmony_ci */ 761bf215546Sopenharmony_ci ast_layout_expression *local_size[3]; 762bf215546Sopenharmony_ci 763bf215546Sopenharmony_ci /** Tessellation evaluation shader: vertex spacing (equal, fractional even/odd) */ 764bf215546Sopenharmony_ci enum gl_tess_spacing vertex_spacing; 765bf215546Sopenharmony_ci 766bf215546Sopenharmony_ci /** Tessellation evaluation shader: vertex ordering (CW or CCW) */ 767bf215546Sopenharmony_ci GLenum ordering; 768bf215546Sopenharmony_ci 769bf215546Sopenharmony_ci /** Tessellation evaluation shader: point mode */ 770bf215546Sopenharmony_ci bool point_mode; 771bf215546Sopenharmony_ci 772bf215546Sopenharmony_ci /** Tessellation control shader: number of output vertices */ 773bf215546Sopenharmony_ci ast_layout_expression *vertices; 774bf215546Sopenharmony_ci 775bf215546Sopenharmony_ci /** 776bf215546Sopenharmony_ci * Image format specified with an ARB_shader_image_load_store 777bf215546Sopenharmony_ci * layout qualifier. 778bf215546Sopenharmony_ci * 779bf215546Sopenharmony_ci * \note 780bf215546Sopenharmony_ci * This field is only valid if \c explicit_image_format is set. 781bf215546Sopenharmony_ci */ 782bf215546Sopenharmony_ci enum pipe_format image_format; 783bf215546Sopenharmony_ci 784bf215546Sopenharmony_ci /** 785bf215546Sopenharmony_ci * Arrangement of invocations used to calculate derivatives in a compute 786bf215546Sopenharmony_ci * shader. From NV_compute_shader_derivatives. 787bf215546Sopenharmony_ci */ 788bf215546Sopenharmony_ci enum gl_derivative_group derivative_group; 789bf215546Sopenharmony_ci 790bf215546Sopenharmony_ci /** 791bf215546Sopenharmony_ci * Base type of the data read from or written to this image. Only 792bf215546Sopenharmony_ci * the following enumerants are allowed: GLSL_TYPE_UINT, 793bf215546Sopenharmony_ci * GLSL_TYPE_INT, GLSL_TYPE_FLOAT. 794bf215546Sopenharmony_ci * 795bf215546Sopenharmony_ci * \note 796bf215546Sopenharmony_ci * This field is only valid if \c explicit_image_format is set. 797bf215546Sopenharmony_ci */ 798bf215546Sopenharmony_ci glsl_base_type image_base_type; 799bf215546Sopenharmony_ci 800bf215546Sopenharmony_ci /** 801bf215546Sopenharmony_ci * Return true if and only if an interpolation qualifier is present. 802bf215546Sopenharmony_ci */ 803bf215546Sopenharmony_ci bool has_interpolation() const; 804bf215546Sopenharmony_ci 805bf215546Sopenharmony_ci /** 806bf215546Sopenharmony_ci * Return whether a layout qualifier is present. 807bf215546Sopenharmony_ci */ 808bf215546Sopenharmony_ci bool has_layout() const; 809bf215546Sopenharmony_ci 810bf215546Sopenharmony_ci /** 811bf215546Sopenharmony_ci * Return whether a storage qualifier is present. 812bf215546Sopenharmony_ci */ 813bf215546Sopenharmony_ci bool has_storage() const; 814bf215546Sopenharmony_ci 815bf215546Sopenharmony_ci /** 816bf215546Sopenharmony_ci * Return whether an auxiliary storage qualifier is present. 817bf215546Sopenharmony_ci */ 818bf215546Sopenharmony_ci bool has_auxiliary_storage() const; 819bf215546Sopenharmony_ci 820bf215546Sopenharmony_ci /** 821bf215546Sopenharmony_ci * Return true if and only if a memory qualifier is present. 822bf215546Sopenharmony_ci */ 823bf215546Sopenharmony_ci bool has_memory() const; 824bf215546Sopenharmony_ci 825bf215546Sopenharmony_ci /** 826bf215546Sopenharmony_ci * Return true if the qualifier is a subroutine declaration. 827bf215546Sopenharmony_ci */ 828bf215546Sopenharmony_ci bool is_subroutine_decl() const; 829bf215546Sopenharmony_ci 830bf215546Sopenharmony_ci bool merge_qualifier(YYLTYPE *loc, 831bf215546Sopenharmony_ci _mesa_glsl_parse_state *state, 832bf215546Sopenharmony_ci const ast_type_qualifier &q, 833bf215546Sopenharmony_ci bool is_single_layout_merge, 834bf215546Sopenharmony_ci bool is_multiple_layouts_merge = false); 835bf215546Sopenharmony_ci 836bf215546Sopenharmony_ci /** 837bf215546Sopenharmony_ci * Validate current qualifier against the global out one. 838bf215546Sopenharmony_ci */ 839bf215546Sopenharmony_ci bool validate_out_qualifier(YYLTYPE *loc, 840bf215546Sopenharmony_ci _mesa_glsl_parse_state *state); 841bf215546Sopenharmony_ci 842bf215546Sopenharmony_ci /** 843bf215546Sopenharmony_ci * Merge current qualifier into the global out one. 844bf215546Sopenharmony_ci */ 845bf215546Sopenharmony_ci bool merge_into_out_qualifier(YYLTYPE *loc, 846bf215546Sopenharmony_ci _mesa_glsl_parse_state *state, 847bf215546Sopenharmony_ci ast_node* &node); 848bf215546Sopenharmony_ci 849bf215546Sopenharmony_ci /** 850bf215546Sopenharmony_ci * Validate current qualifier against the global in one. 851bf215546Sopenharmony_ci */ 852bf215546Sopenharmony_ci bool validate_in_qualifier(YYLTYPE *loc, 853bf215546Sopenharmony_ci _mesa_glsl_parse_state *state); 854bf215546Sopenharmony_ci 855bf215546Sopenharmony_ci /** 856bf215546Sopenharmony_ci * Merge current qualifier into the global in one. 857bf215546Sopenharmony_ci */ 858bf215546Sopenharmony_ci bool merge_into_in_qualifier(YYLTYPE *loc, 859bf215546Sopenharmony_ci _mesa_glsl_parse_state *state, 860bf215546Sopenharmony_ci ast_node* &node); 861bf215546Sopenharmony_ci 862bf215546Sopenharmony_ci /** 863bf215546Sopenharmony_ci * Push pending layout qualifiers to the global values. 864bf215546Sopenharmony_ci */ 865bf215546Sopenharmony_ci bool push_to_global(YYLTYPE *loc, 866bf215546Sopenharmony_ci _mesa_glsl_parse_state *state); 867bf215546Sopenharmony_ci 868bf215546Sopenharmony_ci bool validate_flags(YYLTYPE *loc, 869bf215546Sopenharmony_ci _mesa_glsl_parse_state *state, 870bf215546Sopenharmony_ci const ast_type_qualifier &allowed_flags, 871bf215546Sopenharmony_ci const char *message, const char *name); 872bf215546Sopenharmony_ci 873bf215546Sopenharmony_ci ast_subroutine_list *subroutine_list; 874bf215546Sopenharmony_ci}; 875bf215546Sopenharmony_ci 876bf215546Sopenharmony_ciclass ast_declarator_list; 877bf215546Sopenharmony_ci 878bf215546Sopenharmony_ciclass ast_struct_specifier : public ast_node { 879bf215546Sopenharmony_cipublic: 880bf215546Sopenharmony_ci ast_struct_specifier(const char *identifier, 881bf215546Sopenharmony_ci ast_declarator_list *declarator_list); 882bf215546Sopenharmony_ci virtual void print(void) const; 883bf215546Sopenharmony_ci 884bf215546Sopenharmony_ci virtual ir_rvalue *hir(exec_list *instructions, 885bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 886bf215546Sopenharmony_ci 887bf215546Sopenharmony_ci const char *name; 888bf215546Sopenharmony_ci ast_type_qualifier *layout; 889bf215546Sopenharmony_ci /* List of ast_declarator_list * */ 890bf215546Sopenharmony_ci exec_list declarations; 891bf215546Sopenharmony_ci bool is_declaration; 892bf215546Sopenharmony_ci const glsl_type *type; 893bf215546Sopenharmony_ci}; 894bf215546Sopenharmony_ci 895bf215546Sopenharmony_ci 896bf215546Sopenharmony_ci 897bf215546Sopenharmony_ciclass ast_type_specifier : public ast_node { 898bf215546Sopenharmony_cipublic: 899bf215546Sopenharmony_ci /** Construct a type specifier from a type name */ 900bf215546Sopenharmony_ci ast_type_specifier(const char *name) 901bf215546Sopenharmony_ci : type(NULL), type_name(name), structure(NULL), array_specifier(NULL), 902bf215546Sopenharmony_ci default_precision(ast_precision_none) 903bf215546Sopenharmony_ci { 904bf215546Sopenharmony_ci /* empty */ 905bf215546Sopenharmony_ci } 906bf215546Sopenharmony_ci 907bf215546Sopenharmony_ci /** Construct a type specifier from a structure definition */ 908bf215546Sopenharmony_ci ast_type_specifier(ast_struct_specifier *s) 909bf215546Sopenharmony_ci : type(NULL), type_name(s->name), structure(s), array_specifier(NULL), 910bf215546Sopenharmony_ci default_precision(ast_precision_none) 911bf215546Sopenharmony_ci { 912bf215546Sopenharmony_ci /* empty */ 913bf215546Sopenharmony_ci } 914bf215546Sopenharmony_ci 915bf215546Sopenharmony_ci ast_type_specifier(const glsl_type *t) 916bf215546Sopenharmony_ci : type(t), type_name(t->name), structure(NULL), array_specifier(NULL), 917bf215546Sopenharmony_ci default_precision(ast_precision_none) 918bf215546Sopenharmony_ci { 919bf215546Sopenharmony_ci /* empty */ 920bf215546Sopenharmony_ci } 921bf215546Sopenharmony_ci 922bf215546Sopenharmony_ci const struct glsl_type *glsl_type(const char **name, 923bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state) 924bf215546Sopenharmony_ci const; 925bf215546Sopenharmony_ci 926bf215546Sopenharmony_ci virtual void print(void) const; 927bf215546Sopenharmony_ci 928bf215546Sopenharmony_ci ir_rvalue *hir(exec_list *, struct _mesa_glsl_parse_state *); 929bf215546Sopenharmony_ci 930bf215546Sopenharmony_ci const struct glsl_type *type; 931bf215546Sopenharmony_ci const char *type_name; 932bf215546Sopenharmony_ci ast_struct_specifier *structure; 933bf215546Sopenharmony_ci 934bf215546Sopenharmony_ci ast_array_specifier *array_specifier; 935bf215546Sopenharmony_ci 936bf215546Sopenharmony_ci /** For precision statements, this is the given precision; otherwise none. */ 937bf215546Sopenharmony_ci unsigned default_precision:2; 938bf215546Sopenharmony_ci}; 939bf215546Sopenharmony_ci 940bf215546Sopenharmony_ci 941bf215546Sopenharmony_ciclass ast_fully_specified_type : public ast_node { 942bf215546Sopenharmony_cipublic: 943bf215546Sopenharmony_ci virtual void print(void) const; 944bf215546Sopenharmony_ci bool has_qualifiers(_mesa_glsl_parse_state *state) const; 945bf215546Sopenharmony_ci 946bf215546Sopenharmony_ci ast_fully_specified_type() : qualifier(), specifier(NULL) 947bf215546Sopenharmony_ci { 948bf215546Sopenharmony_ci } 949bf215546Sopenharmony_ci 950bf215546Sopenharmony_ci const struct glsl_type *glsl_type(const char **name, 951bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state) 952bf215546Sopenharmony_ci const; 953bf215546Sopenharmony_ci 954bf215546Sopenharmony_ci ast_type_qualifier qualifier; 955bf215546Sopenharmony_ci ast_type_specifier *specifier; 956bf215546Sopenharmony_ci}; 957bf215546Sopenharmony_ci 958bf215546Sopenharmony_ci 959bf215546Sopenharmony_ciclass ast_declarator_list : public ast_node { 960bf215546Sopenharmony_cipublic: 961bf215546Sopenharmony_ci ast_declarator_list(ast_fully_specified_type *); 962bf215546Sopenharmony_ci virtual void print(void) const; 963bf215546Sopenharmony_ci 964bf215546Sopenharmony_ci virtual ir_rvalue *hir(exec_list *instructions, 965bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 966bf215546Sopenharmony_ci 967bf215546Sopenharmony_ci ast_fully_specified_type *type; 968bf215546Sopenharmony_ci /** List of 'ast_declaration *' */ 969bf215546Sopenharmony_ci exec_list declarations; 970bf215546Sopenharmony_ci 971bf215546Sopenharmony_ci /** 972bf215546Sopenharmony_ci * Flags for redeclarations. In these cases, no type is specified, to 973bf215546Sopenharmony_ci * `type` is allowed to be NULL. In all other cases, this would be an error. 974bf215546Sopenharmony_ci */ 975bf215546Sopenharmony_ci int invariant; /** < `invariant` redeclaration */ 976bf215546Sopenharmony_ci int precise; /** < `precise` redeclaration */ 977bf215546Sopenharmony_ci}; 978bf215546Sopenharmony_ci 979bf215546Sopenharmony_ci 980bf215546Sopenharmony_ciclass ast_parameter_declarator : public ast_node { 981bf215546Sopenharmony_cipublic: 982bf215546Sopenharmony_ci ast_parameter_declarator() : 983bf215546Sopenharmony_ci type(NULL), 984bf215546Sopenharmony_ci identifier(NULL), 985bf215546Sopenharmony_ci array_specifier(NULL), 986bf215546Sopenharmony_ci formal_parameter(false), 987bf215546Sopenharmony_ci is_void(false) 988bf215546Sopenharmony_ci { 989bf215546Sopenharmony_ci /* empty */ 990bf215546Sopenharmony_ci } 991bf215546Sopenharmony_ci 992bf215546Sopenharmony_ci virtual void print(void) const; 993bf215546Sopenharmony_ci 994bf215546Sopenharmony_ci virtual ir_rvalue *hir(exec_list *instructions, 995bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 996bf215546Sopenharmony_ci 997bf215546Sopenharmony_ci ast_fully_specified_type *type; 998bf215546Sopenharmony_ci const char *identifier; 999bf215546Sopenharmony_ci ast_array_specifier *array_specifier; 1000bf215546Sopenharmony_ci 1001bf215546Sopenharmony_ci static void parameters_to_hir(exec_list *ast_parameters, 1002bf215546Sopenharmony_ci bool formal, exec_list *ir_parameters, 1003bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 1004bf215546Sopenharmony_ci 1005bf215546Sopenharmony_ciprivate: 1006bf215546Sopenharmony_ci /** Is this parameter declaration part of a formal parameter list? */ 1007bf215546Sopenharmony_ci bool formal_parameter; 1008bf215546Sopenharmony_ci 1009bf215546Sopenharmony_ci /** 1010bf215546Sopenharmony_ci * Is this parameter 'void' type? 1011bf215546Sopenharmony_ci * 1012bf215546Sopenharmony_ci * This field is set by \c ::hir. 1013bf215546Sopenharmony_ci */ 1014bf215546Sopenharmony_ci bool is_void; 1015bf215546Sopenharmony_ci}; 1016bf215546Sopenharmony_ci 1017bf215546Sopenharmony_ci 1018bf215546Sopenharmony_ciclass ast_function : public ast_node { 1019bf215546Sopenharmony_cipublic: 1020bf215546Sopenharmony_ci ast_function(void); 1021bf215546Sopenharmony_ci 1022bf215546Sopenharmony_ci virtual void print(void) const; 1023bf215546Sopenharmony_ci 1024bf215546Sopenharmony_ci virtual ir_rvalue *hir(exec_list *instructions, 1025bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 1026bf215546Sopenharmony_ci 1027bf215546Sopenharmony_ci ast_fully_specified_type *return_type; 1028bf215546Sopenharmony_ci const char *identifier; 1029bf215546Sopenharmony_ci 1030bf215546Sopenharmony_ci exec_list parameters; 1031bf215546Sopenharmony_ci 1032bf215546Sopenharmony_ciprivate: 1033bf215546Sopenharmony_ci /** 1034bf215546Sopenharmony_ci * Is this prototype part of the function definition? 1035bf215546Sopenharmony_ci * 1036bf215546Sopenharmony_ci * Used by ast_function_definition::hir to process the parameters, etc. 1037bf215546Sopenharmony_ci * of the function. 1038bf215546Sopenharmony_ci * 1039bf215546Sopenharmony_ci * \sa ::hir 1040bf215546Sopenharmony_ci */ 1041bf215546Sopenharmony_ci bool is_definition; 1042bf215546Sopenharmony_ci 1043bf215546Sopenharmony_ci /** 1044bf215546Sopenharmony_ci * Function signature corresponding to this function prototype instance 1045bf215546Sopenharmony_ci * 1046bf215546Sopenharmony_ci * Used by ast_function_definition::hir to process the parameters, etc. 1047bf215546Sopenharmony_ci * of the function. 1048bf215546Sopenharmony_ci * 1049bf215546Sopenharmony_ci * \sa ::hir 1050bf215546Sopenharmony_ci */ 1051bf215546Sopenharmony_ci class ir_function_signature *signature; 1052bf215546Sopenharmony_ci 1053bf215546Sopenharmony_ci friend class ast_function_definition; 1054bf215546Sopenharmony_ci}; 1055bf215546Sopenharmony_ci 1056bf215546Sopenharmony_ci 1057bf215546Sopenharmony_ciclass ast_expression_statement : public ast_node { 1058bf215546Sopenharmony_cipublic: 1059bf215546Sopenharmony_ci ast_expression_statement(ast_expression *); 1060bf215546Sopenharmony_ci virtual void print(void) const; 1061bf215546Sopenharmony_ci 1062bf215546Sopenharmony_ci virtual ir_rvalue *hir(exec_list *instructions, 1063bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 1064bf215546Sopenharmony_ci 1065bf215546Sopenharmony_ci ast_expression *expression; 1066bf215546Sopenharmony_ci}; 1067bf215546Sopenharmony_ci 1068bf215546Sopenharmony_ci 1069bf215546Sopenharmony_ciclass ast_case_label : public ast_node { 1070bf215546Sopenharmony_cipublic: 1071bf215546Sopenharmony_ci ast_case_label(ast_expression *test_value); 1072bf215546Sopenharmony_ci virtual void print(void) const; 1073bf215546Sopenharmony_ci 1074bf215546Sopenharmony_ci virtual ir_rvalue *hir(exec_list *instructions, 1075bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 1076bf215546Sopenharmony_ci 1077bf215546Sopenharmony_ci /** 1078bf215546Sopenharmony_ci * An test value of NULL means 'default'. 1079bf215546Sopenharmony_ci */ 1080bf215546Sopenharmony_ci ast_expression *test_value; 1081bf215546Sopenharmony_ci}; 1082bf215546Sopenharmony_ci 1083bf215546Sopenharmony_ci 1084bf215546Sopenharmony_ciclass ast_case_label_list : public ast_node { 1085bf215546Sopenharmony_cipublic: 1086bf215546Sopenharmony_ci ast_case_label_list(void); 1087bf215546Sopenharmony_ci virtual void print(void) const; 1088bf215546Sopenharmony_ci 1089bf215546Sopenharmony_ci virtual ir_rvalue *hir(exec_list *instructions, 1090bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 1091bf215546Sopenharmony_ci 1092bf215546Sopenharmony_ci /** 1093bf215546Sopenharmony_ci * A list of case labels. 1094bf215546Sopenharmony_ci */ 1095bf215546Sopenharmony_ci exec_list labels; 1096bf215546Sopenharmony_ci}; 1097bf215546Sopenharmony_ci 1098bf215546Sopenharmony_ci 1099bf215546Sopenharmony_ciclass ast_case_statement : public ast_node { 1100bf215546Sopenharmony_cipublic: 1101bf215546Sopenharmony_ci ast_case_statement(ast_case_label_list *labels); 1102bf215546Sopenharmony_ci virtual void print(void) const; 1103bf215546Sopenharmony_ci 1104bf215546Sopenharmony_ci virtual ir_rvalue *hir(exec_list *instructions, 1105bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 1106bf215546Sopenharmony_ci 1107bf215546Sopenharmony_ci ast_case_label_list *labels; 1108bf215546Sopenharmony_ci 1109bf215546Sopenharmony_ci /** 1110bf215546Sopenharmony_ci * A list of statements. 1111bf215546Sopenharmony_ci */ 1112bf215546Sopenharmony_ci exec_list stmts; 1113bf215546Sopenharmony_ci}; 1114bf215546Sopenharmony_ci 1115bf215546Sopenharmony_ci 1116bf215546Sopenharmony_ciclass ast_case_statement_list : public ast_node { 1117bf215546Sopenharmony_cipublic: 1118bf215546Sopenharmony_ci ast_case_statement_list(void); 1119bf215546Sopenharmony_ci virtual void print(void) const; 1120bf215546Sopenharmony_ci 1121bf215546Sopenharmony_ci virtual ir_rvalue *hir(exec_list *instructions, 1122bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 1123bf215546Sopenharmony_ci 1124bf215546Sopenharmony_ci /** 1125bf215546Sopenharmony_ci * A list of cases. 1126bf215546Sopenharmony_ci */ 1127bf215546Sopenharmony_ci exec_list cases; 1128bf215546Sopenharmony_ci}; 1129bf215546Sopenharmony_ci 1130bf215546Sopenharmony_ci 1131bf215546Sopenharmony_ciclass ast_switch_body : public ast_node { 1132bf215546Sopenharmony_cipublic: 1133bf215546Sopenharmony_ci ast_switch_body(ast_case_statement_list *stmts); 1134bf215546Sopenharmony_ci virtual void print(void) const; 1135bf215546Sopenharmony_ci 1136bf215546Sopenharmony_ci virtual ir_rvalue *hir(exec_list *instructions, 1137bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 1138bf215546Sopenharmony_ci 1139bf215546Sopenharmony_ci ast_case_statement_list *stmts; 1140bf215546Sopenharmony_ci}; 1141bf215546Sopenharmony_ci 1142bf215546Sopenharmony_ci 1143bf215546Sopenharmony_ciclass ast_selection_statement : public ast_node { 1144bf215546Sopenharmony_cipublic: 1145bf215546Sopenharmony_ci ast_selection_statement(ast_expression *condition, 1146bf215546Sopenharmony_ci ast_node *then_statement, 1147bf215546Sopenharmony_ci ast_node *else_statement); 1148bf215546Sopenharmony_ci virtual void print(void) const; 1149bf215546Sopenharmony_ci 1150bf215546Sopenharmony_ci virtual ir_rvalue *hir(exec_list *instructions, 1151bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 1152bf215546Sopenharmony_ci 1153bf215546Sopenharmony_ci ast_expression *condition; 1154bf215546Sopenharmony_ci ast_node *then_statement; 1155bf215546Sopenharmony_ci ast_node *else_statement; 1156bf215546Sopenharmony_ci}; 1157bf215546Sopenharmony_ci 1158bf215546Sopenharmony_ci 1159bf215546Sopenharmony_ciclass ast_switch_statement : public ast_node { 1160bf215546Sopenharmony_cipublic: 1161bf215546Sopenharmony_ci ast_switch_statement(ast_expression *test_expression, 1162bf215546Sopenharmony_ci ast_node *body); 1163bf215546Sopenharmony_ci virtual void print(void) const; 1164bf215546Sopenharmony_ci 1165bf215546Sopenharmony_ci virtual ir_rvalue *hir(exec_list *instructions, 1166bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 1167bf215546Sopenharmony_ci 1168bf215546Sopenharmony_ci ast_expression *test_expression; 1169bf215546Sopenharmony_ci ast_node *body; 1170bf215546Sopenharmony_ci 1171bf215546Sopenharmony_ciprotected: 1172bf215546Sopenharmony_ci void test_to_hir(exec_list *, struct _mesa_glsl_parse_state *); 1173bf215546Sopenharmony_ci void eval_test_expression(exec_list *instructions, 1174bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 1175bf215546Sopenharmony_ci ir_rvalue *test_val; 1176bf215546Sopenharmony_ci}; 1177bf215546Sopenharmony_ci 1178bf215546Sopenharmony_ciclass ast_iteration_statement : public ast_node { 1179bf215546Sopenharmony_cipublic: 1180bf215546Sopenharmony_ci ast_iteration_statement(int mode, ast_node *init, ast_node *condition, 1181bf215546Sopenharmony_ci ast_expression *rest_expression, ast_node *body); 1182bf215546Sopenharmony_ci 1183bf215546Sopenharmony_ci virtual void print(void) const; 1184bf215546Sopenharmony_ci 1185bf215546Sopenharmony_ci virtual ir_rvalue *hir(exec_list *, struct _mesa_glsl_parse_state *); 1186bf215546Sopenharmony_ci 1187bf215546Sopenharmony_ci enum ast_iteration_modes { 1188bf215546Sopenharmony_ci ast_for, 1189bf215546Sopenharmony_ci ast_while, 1190bf215546Sopenharmony_ci ast_do_while 1191bf215546Sopenharmony_ci } mode; 1192bf215546Sopenharmony_ci 1193bf215546Sopenharmony_ci 1194bf215546Sopenharmony_ci ast_node *init_statement; 1195bf215546Sopenharmony_ci ast_node *condition; 1196bf215546Sopenharmony_ci ast_expression *rest_expression; 1197bf215546Sopenharmony_ci 1198bf215546Sopenharmony_ci exec_list rest_instructions; 1199bf215546Sopenharmony_ci 1200bf215546Sopenharmony_ci ast_node *body; 1201bf215546Sopenharmony_ci 1202bf215546Sopenharmony_ci /** 1203bf215546Sopenharmony_ci * Generate IR from the condition of a loop 1204bf215546Sopenharmony_ci * 1205bf215546Sopenharmony_ci * This is factored out of ::hir because some loops have the condition 1206bf215546Sopenharmony_ci * test at the top (for and while), and others have it at the end (do-while). 1207bf215546Sopenharmony_ci */ 1208bf215546Sopenharmony_ci void condition_to_hir(exec_list *, struct _mesa_glsl_parse_state *); 1209bf215546Sopenharmony_ci}; 1210bf215546Sopenharmony_ci 1211bf215546Sopenharmony_ci 1212bf215546Sopenharmony_ciclass ast_jump_statement : public ast_node { 1213bf215546Sopenharmony_cipublic: 1214bf215546Sopenharmony_ci ast_jump_statement(int mode, ast_expression *return_value); 1215bf215546Sopenharmony_ci virtual void print(void) const; 1216bf215546Sopenharmony_ci 1217bf215546Sopenharmony_ci virtual ir_rvalue *hir(exec_list *instructions, 1218bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 1219bf215546Sopenharmony_ci 1220bf215546Sopenharmony_ci enum ast_jump_modes { 1221bf215546Sopenharmony_ci ast_continue, 1222bf215546Sopenharmony_ci ast_break, 1223bf215546Sopenharmony_ci ast_return, 1224bf215546Sopenharmony_ci ast_discard 1225bf215546Sopenharmony_ci } mode; 1226bf215546Sopenharmony_ci 1227bf215546Sopenharmony_ci ast_expression *opt_return_value; 1228bf215546Sopenharmony_ci}; 1229bf215546Sopenharmony_ci 1230bf215546Sopenharmony_ci 1231bf215546Sopenharmony_ciclass ast_demote_statement : public ast_node { 1232bf215546Sopenharmony_cipublic: 1233bf215546Sopenharmony_ci ast_demote_statement(void) {} 1234bf215546Sopenharmony_ci virtual void print(void) const; 1235bf215546Sopenharmony_ci 1236bf215546Sopenharmony_ci virtual ir_rvalue *hir(exec_list *instructions, 1237bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 1238bf215546Sopenharmony_ci}; 1239bf215546Sopenharmony_ci 1240bf215546Sopenharmony_ci 1241bf215546Sopenharmony_ciclass ast_function_definition : public ast_node { 1242bf215546Sopenharmony_cipublic: 1243bf215546Sopenharmony_ci ast_function_definition() : prototype(NULL), body(NULL) 1244bf215546Sopenharmony_ci { 1245bf215546Sopenharmony_ci } 1246bf215546Sopenharmony_ci 1247bf215546Sopenharmony_ci virtual void print(void) const; 1248bf215546Sopenharmony_ci 1249bf215546Sopenharmony_ci virtual ir_rvalue *hir(exec_list *instructions, 1250bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 1251bf215546Sopenharmony_ci 1252bf215546Sopenharmony_ci ast_function *prototype; 1253bf215546Sopenharmony_ci ast_compound_statement *body; 1254bf215546Sopenharmony_ci}; 1255bf215546Sopenharmony_ci 1256bf215546Sopenharmony_ciclass ast_interface_block : public ast_node { 1257bf215546Sopenharmony_cipublic: 1258bf215546Sopenharmony_ci ast_interface_block(const char *instance_name, 1259bf215546Sopenharmony_ci ast_array_specifier *array_specifier) 1260bf215546Sopenharmony_ci : block_name(NULL), instance_name(instance_name), 1261bf215546Sopenharmony_ci array_specifier(array_specifier) 1262bf215546Sopenharmony_ci { 1263bf215546Sopenharmony_ci } 1264bf215546Sopenharmony_ci 1265bf215546Sopenharmony_ci virtual ir_rvalue *hir(exec_list *instructions, 1266bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 1267bf215546Sopenharmony_ci 1268bf215546Sopenharmony_ci ast_type_qualifier default_layout; 1269bf215546Sopenharmony_ci ast_type_qualifier layout; 1270bf215546Sopenharmony_ci const char *block_name; 1271bf215546Sopenharmony_ci 1272bf215546Sopenharmony_ci /** 1273bf215546Sopenharmony_ci * Declared name of the block instance, if specified. 1274bf215546Sopenharmony_ci * 1275bf215546Sopenharmony_ci * If the block does not have an instance name, this field will be 1276bf215546Sopenharmony_ci * \c NULL. 1277bf215546Sopenharmony_ci */ 1278bf215546Sopenharmony_ci const char *instance_name; 1279bf215546Sopenharmony_ci 1280bf215546Sopenharmony_ci /** List of ast_declarator_list * */ 1281bf215546Sopenharmony_ci exec_list declarations; 1282bf215546Sopenharmony_ci 1283bf215546Sopenharmony_ci /** 1284bf215546Sopenharmony_ci * Declared array size of the block instance 1285bf215546Sopenharmony_ci * 1286bf215546Sopenharmony_ci * If the block is not declared as an array or if the block instance array 1287bf215546Sopenharmony_ci * is unsized, this field will be \c NULL. 1288bf215546Sopenharmony_ci */ 1289bf215546Sopenharmony_ci ast_array_specifier *array_specifier; 1290bf215546Sopenharmony_ci}; 1291bf215546Sopenharmony_ci 1292bf215546Sopenharmony_ci 1293bf215546Sopenharmony_ci/** 1294bf215546Sopenharmony_ci * AST node representing a declaration of the output layout for tessellation 1295bf215546Sopenharmony_ci * control shaders. 1296bf215546Sopenharmony_ci */ 1297bf215546Sopenharmony_ciclass ast_tcs_output_layout : public ast_node 1298bf215546Sopenharmony_ci{ 1299bf215546Sopenharmony_cipublic: 1300bf215546Sopenharmony_ci ast_tcs_output_layout(const struct YYLTYPE &locp) 1301bf215546Sopenharmony_ci { 1302bf215546Sopenharmony_ci set_location(locp); 1303bf215546Sopenharmony_ci } 1304bf215546Sopenharmony_ci 1305bf215546Sopenharmony_ci virtual ir_rvalue *hir(exec_list *instructions, 1306bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 1307bf215546Sopenharmony_ci}; 1308bf215546Sopenharmony_ci 1309bf215546Sopenharmony_ci 1310bf215546Sopenharmony_ci/** 1311bf215546Sopenharmony_ci * AST node representing a declaration of the input layout for geometry 1312bf215546Sopenharmony_ci * shaders. 1313bf215546Sopenharmony_ci */ 1314bf215546Sopenharmony_ciclass ast_gs_input_layout : public ast_node 1315bf215546Sopenharmony_ci{ 1316bf215546Sopenharmony_cipublic: 1317bf215546Sopenharmony_ci ast_gs_input_layout(const struct YYLTYPE &locp, GLenum prim_type) 1318bf215546Sopenharmony_ci : prim_type(prim_type) 1319bf215546Sopenharmony_ci { 1320bf215546Sopenharmony_ci set_location(locp); 1321bf215546Sopenharmony_ci } 1322bf215546Sopenharmony_ci 1323bf215546Sopenharmony_ci virtual ir_rvalue *hir(exec_list *instructions, 1324bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 1325bf215546Sopenharmony_ci 1326bf215546Sopenharmony_ciprivate: 1327bf215546Sopenharmony_ci const GLenum prim_type; 1328bf215546Sopenharmony_ci}; 1329bf215546Sopenharmony_ci 1330bf215546Sopenharmony_ci 1331bf215546Sopenharmony_ci/** 1332bf215546Sopenharmony_ci * AST node representing a decalaration of the input layout for compute 1333bf215546Sopenharmony_ci * shaders. 1334bf215546Sopenharmony_ci */ 1335bf215546Sopenharmony_ciclass ast_cs_input_layout : public ast_node 1336bf215546Sopenharmony_ci{ 1337bf215546Sopenharmony_cipublic: 1338bf215546Sopenharmony_ci ast_cs_input_layout(const struct YYLTYPE &locp, 1339bf215546Sopenharmony_ci ast_layout_expression *const *local_size) 1340bf215546Sopenharmony_ci { 1341bf215546Sopenharmony_ci for (int i = 0; i < 3; i++) { 1342bf215546Sopenharmony_ci this->local_size[i] = local_size[i]; 1343bf215546Sopenharmony_ci } 1344bf215546Sopenharmony_ci set_location(locp); 1345bf215546Sopenharmony_ci } 1346bf215546Sopenharmony_ci 1347bf215546Sopenharmony_ci virtual ir_rvalue *hir(exec_list *instructions, 1348bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 1349bf215546Sopenharmony_ci 1350bf215546Sopenharmony_ciprivate: 1351bf215546Sopenharmony_ci ast_layout_expression *local_size[3]; 1352bf215546Sopenharmony_ci}; 1353bf215546Sopenharmony_ci 1354bf215546Sopenharmony_ciclass ast_warnings_toggle : public ast_node { 1355bf215546Sopenharmony_cipublic: 1356bf215546Sopenharmony_ci ast_warnings_toggle(bool _enable) 1357bf215546Sopenharmony_ci : enable(_enable) 1358bf215546Sopenharmony_ci { 1359bf215546Sopenharmony_ci /* empty */ 1360bf215546Sopenharmony_ci } 1361bf215546Sopenharmony_ci 1362bf215546Sopenharmony_ci virtual ir_rvalue *hir(exec_list *instructions, 1363bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 1364bf215546Sopenharmony_ci 1365bf215546Sopenharmony_ciprivate: 1366bf215546Sopenharmony_ci bool enable; 1367bf215546Sopenharmony_ci}; 1368bf215546Sopenharmony_ci/*@}*/ 1369bf215546Sopenharmony_ci 1370bf215546Sopenharmony_ciextern void 1371bf215546Sopenharmony_ci_mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state); 1372bf215546Sopenharmony_ci 1373bf215546Sopenharmony_ciextern ir_rvalue * 1374bf215546Sopenharmony_ci_mesa_ast_field_selection_to_hir(const ast_expression *expr, 1375bf215546Sopenharmony_ci exec_list *instructions, 1376bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state); 1377bf215546Sopenharmony_ci 1378bf215546Sopenharmony_ciextern ir_rvalue * 1379bf215546Sopenharmony_ci_mesa_ast_array_index_to_hir(void *mem_ctx, 1380bf215546Sopenharmony_ci struct _mesa_glsl_parse_state *state, 1381bf215546Sopenharmony_ci ir_rvalue *array, ir_rvalue *idx, 1382bf215546Sopenharmony_ci YYLTYPE &loc, YYLTYPE &idx_loc); 1383bf215546Sopenharmony_ci 1384bf215546Sopenharmony_ciextern void 1385bf215546Sopenharmony_ci_mesa_ast_set_aggregate_type(const glsl_type *type, 1386bf215546Sopenharmony_ci ast_expression *expr); 1387bf215546Sopenharmony_ci 1388bf215546Sopenharmony_civoid 1389bf215546Sopenharmony_ciemit_function(_mesa_glsl_parse_state *state, ir_function *f); 1390bf215546Sopenharmony_ci 1391bf215546Sopenharmony_ciextern void 1392bf215546Sopenharmony_cicheck_builtin_array_max_size(const char *name, unsigned size, 1393bf215546Sopenharmony_ci YYLTYPE loc, struct _mesa_glsl_parse_state *state); 1394bf215546Sopenharmony_ci 1395bf215546Sopenharmony_ciextern void _mesa_ast_process_interface_block(YYLTYPE *locp, 1396bf215546Sopenharmony_ci _mesa_glsl_parse_state *state, 1397bf215546Sopenharmony_ci ast_interface_block *const block, 1398bf215546Sopenharmony_ci const struct ast_type_qualifier &q); 1399bf215546Sopenharmony_ci 1400bf215546Sopenharmony_ciextern bool 1401bf215546Sopenharmony_ciprocess_qualifier_constant(struct _mesa_glsl_parse_state *state, 1402bf215546Sopenharmony_ci YYLTYPE *loc, 1403bf215546Sopenharmony_ci const char *qual_indentifier, 1404bf215546Sopenharmony_ci ast_expression *const_expression, 1405bf215546Sopenharmony_ci unsigned *value); 1406bf215546Sopenharmony_ci#endif /* AST_H */ 1407