diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h index 2c3de32a715..3b25884f241 100644 --- a/src/compiler/glsl/ast.h +++ b/src/compiler/glsl/ast.h @@ -25,7 +25,7 @@ #ifndef AST_H #define AST_H -#include "list.h" +#include "ir_list.h" #include "glsl_parser_extras.h" #include "compiler/glsl_types.h" #include "util/bitset.h" @@ -60,7 +60,7 @@ public: /** * Convert the AST node to the high-level intermediate representation */ - virtual ir_rvalue *hir(exec_list *instructions, + virtual ir_rvalue *hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); virtual bool has_sequence_subexpression() const; @@ -129,7 +129,7 @@ public: unsigned last_column; /**< Last column in the last line. */ } location; - exec_node link; + ir_exec_node link; virtual void set_is_lhs(bool); @@ -238,15 +238,15 @@ public: static const char *operator_string(enum ast_operators op); - virtual ir_rvalue *hir(exec_list *instructions, + virtual ir_rvalue *hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); - virtual void hir_no_rvalue(exec_list *instructions, + virtual void hir_no_rvalue(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); virtual bool has_sequence_subexpression() const; - ir_rvalue *do_hir(exec_list *instructions, + ir_rvalue *do_hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state, bool needs_rvalue); @@ -273,7 +273,7 @@ public: * List of expressions for an \c ast_sequence or parameters for an * \c ast_function_call */ - exec_list expressions; + ir_exec_list expressions; /** * For things that can't be l-values, this describes what it is. @@ -326,10 +326,10 @@ public: return cons; } - virtual ir_rvalue *hir(exec_list *instructions, + virtual ir_rvalue *hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); - virtual void hir_no_rvalue(exec_list *instructions, + virtual void hir_no_rvalue(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); virtual bool has_sequence_subexpression() const; @@ -340,7 +340,7 @@ private: */ bool cons; ir_rvalue * - handle_method(exec_list *instructions, + handle_method(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); }; @@ -348,7 +348,7 @@ class ast_subroutine_list : public ast_node { public: virtual void print(void) const; - exec_list declarations; + ir_exec_list declarations; }; class ast_array_specifier : public ast_node { @@ -375,7 +375,7 @@ public: /* This list contains objects of type ast_node containing the * array dimensions in outermost-to-innermost order. */ - exec_list array_dimensions; + ir_exec_list array_dimensions; }; class ast_layout_expression : public ast_node { @@ -395,7 +395,7 @@ public: layout_const_expressions.append_list(&l_expr->layout_const_expressions); } - exec_list layout_const_expressions; + ir_exec_list layout_const_expressions; }; /** @@ -428,10 +428,10 @@ public: */ const glsl_type *constructor_type; - virtual ir_rvalue *hir(exec_list *instructions, + virtual ir_rvalue *hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); - virtual void hir_no_rvalue(exec_list *instructions, + virtual void hir_no_rvalue(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); }; @@ -441,11 +441,11 @@ public: ast_compound_statement(int new_scope, ast_node *statements); virtual void print(void) const; - virtual ir_rvalue *hir(exec_list *instructions, + virtual ir_rvalue *hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); int new_scope; - exec_list statements; + ir_exec_list statements; }; class ast_declaration : public ast_node { @@ -897,13 +897,13 @@ public: ast_declarator_list *declarator_list); virtual void print(void) const; - virtual ir_rvalue *hir(exec_list *instructions, + virtual ir_rvalue *hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); const char *name; ast_type_qualifier *layout; /* List of ast_declarator_list * */ - exec_list declarations; + ir_exec_list declarations; bool is_declaration; const glsl_type *type; }; @@ -941,7 +941,7 @@ public: virtual void print(void) const; - ir_rvalue *hir(exec_list *, struct _mesa_glsl_parse_state *); + ir_rvalue *hir(ir_exec_list *, struct _mesa_glsl_parse_state *); const struct glsl_type *type; const char *type_name; @@ -977,12 +977,12 @@ public: ast_declarator_list(ast_fully_specified_type *); virtual void print(void) const; - virtual ir_rvalue *hir(exec_list *instructions, + virtual ir_rvalue *hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); ast_fully_specified_type *type; /** List of 'ast_declaration *' */ - exec_list declarations; + ir_exec_list declarations; /** * Flags for redeclarations. In these cases, no type is specified, to @@ -1007,15 +1007,15 @@ public: virtual void print(void) const; - virtual ir_rvalue *hir(exec_list *instructions, + virtual ir_rvalue *hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); ast_fully_specified_type *type; const char *identifier; ast_array_specifier *array_specifier; - static void parameters_to_hir(exec_list *ast_parameters, - bool formal, exec_list *ir_parameters, + static void parameters_to_hir(ir_exec_list *ast_parameters, + bool formal, ir_exec_list *ir_parameters, struct _mesa_glsl_parse_state *state); private: @@ -1037,13 +1037,13 @@ public: virtual void print(void) const; - virtual ir_rvalue *hir(exec_list *instructions, + virtual ir_rvalue *hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); ast_fully_specified_type *return_type; const char *identifier; - exec_list parameters; + ir_exec_list parameters; private: /** @@ -1075,7 +1075,7 @@ public: ast_expression_statement(ast_expression *); virtual void print(void) const; - virtual ir_rvalue *hir(exec_list *instructions, + virtual ir_rvalue *hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); ast_expression *expression; @@ -1087,7 +1087,7 @@ public: ast_case_label(ast_expression *test_value); virtual void print(void) const; - virtual ir_rvalue *hir(exec_list *instructions, + virtual ir_rvalue *hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); /** @@ -1102,13 +1102,13 @@ public: ast_case_label_list(void); virtual void print(void) const; - virtual ir_rvalue *hir(exec_list *instructions, + virtual ir_rvalue *hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); /** * A list of case labels. */ - exec_list labels; + ir_exec_list labels; }; @@ -1117,7 +1117,7 @@ public: ast_case_statement(ast_case_label_list *labels); virtual void print(void) const; - virtual ir_rvalue *hir(exec_list *instructions, + virtual ir_rvalue *hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); ast_case_label_list *labels; @@ -1125,7 +1125,7 @@ public: /** * A list of statements. */ - exec_list stmts; + ir_exec_list stmts; }; @@ -1134,13 +1134,13 @@ public: ast_case_statement_list(void); virtual void print(void) const; - virtual ir_rvalue *hir(exec_list *instructions, + virtual ir_rvalue *hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); /** * A list of cases. */ - exec_list cases; + ir_exec_list cases; }; @@ -1149,7 +1149,7 @@ public: ast_switch_body(ast_case_statement_list *stmts); virtual void print(void) const; - virtual ir_rvalue *hir(exec_list *instructions, + virtual ir_rvalue *hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); ast_case_statement_list *stmts; @@ -1163,7 +1163,7 @@ public: ast_node *else_statement); virtual void print(void) const; - virtual ir_rvalue *hir(exec_list *instructions, + virtual ir_rvalue *hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); ast_expression *condition; @@ -1178,15 +1178,15 @@ public: ast_node *body); virtual void print(void) const; - virtual ir_rvalue *hir(exec_list *instructions, + virtual ir_rvalue *hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); ast_expression *test_expression; ast_node *body; protected: - void test_to_hir(exec_list *, struct _mesa_glsl_parse_state *); - void eval_test_expression(exec_list *instructions, + void test_to_hir(ir_exec_list *, struct _mesa_glsl_parse_state *); + void eval_test_expression(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); ir_rvalue *test_val; }; @@ -1198,7 +1198,7 @@ public: virtual void print(void) const; - virtual ir_rvalue *hir(exec_list *, struct _mesa_glsl_parse_state *); + virtual ir_rvalue *hir(ir_exec_list *, struct _mesa_glsl_parse_state *); enum ast_iteration_modes { ast_for, @@ -1211,7 +1211,7 @@ public: ast_node *condition; ast_expression *rest_expression; - exec_list rest_instructions; + ir_exec_list rest_instructions; ast_node *body; @@ -1221,7 +1221,7 @@ public: * This is factored out of ::hir because some loops have the condition * test at the top (for and while), and others have it at the end (do-while). */ - void condition_to_hir(exec_list *, struct _mesa_glsl_parse_state *); + void condition_to_hir(ir_exec_list *, struct _mesa_glsl_parse_state *); }; @@ -1230,7 +1230,7 @@ public: ast_jump_statement(int mode, ast_expression *return_value); virtual void print(void) const; - virtual ir_rvalue *hir(exec_list *instructions, + virtual ir_rvalue *hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); enum ast_jump_modes { @@ -1249,7 +1249,7 @@ public: ast_demote_statement(void) {} virtual void print(void) const; - virtual ir_rvalue *hir(exec_list *instructions, + virtual ir_rvalue *hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); }; @@ -1262,7 +1262,7 @@ public: virtual void print(void) const; - virtual ir_rvalue *hir(exec_list *instructions, + virtual ir_rvalue *hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); ast_function *prototype; @@ -1278,7 +1278,7 @@ public: { } - virtual ir_rvalue *hir(exec_list *instructions, + virtual ir_rvalue *hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); ast_type_qualifier default_layout; @@ -1294,7 +1294,7 @@ public: const char *instance_name; /** List of ast_declarator_list * */ - exec_list declarations; + ir_exec_list declarations; /** * Declared array size of the block instance @@ -1318,7 +1318,7 @@ public: set_location(locp); } - virtual ir_rvalue *hir(exec_list *instructions, + virtual ir_rvalue *hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); }; @@ -1336,7 +1336,7 @@ public: set_location(locp); } - virtual ir_rvalue *hir(exec_list *instructions, + virtual ir_rvalue *hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); private: @@ -1360,7 +1360,7 @@ public: set_location(locp); } - virtual ir_rvalue *hir(exec_list *instructions, + virtual ir_rvalue *hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); private: @@ -1375,7 +1375,7 @@ public: /* empty */ } - virtual ir_rvalue *hir(exec_list *instructions, + virtual ir_rvalue *hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); private: @@ -1384,11 +1384,11 @@ private: /*@}*/ extern void -_mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state); +_mesa_ast_to_hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); extern ir_rvalue * _mesa_ast_field_selection_to_hir(const ast_expression *expr, - exec_list *instructions, + ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); extern ir_rvalue * diff --git a/src/compiler/glsl/ast_array_index.cpp b/src/compiler/glsl/ast_array_index.cpp index 5d758672b00..8ccc8778dac 100644 --- a/src/compiler/glsl/ast_array_index.cpp +++ b/src/compiler/glsl/ast_array_index.cpp @@ -28,7 +28,7 @@ void ast_array_specifier::print(void) const { - foreach_list_typed (ast_node, array_dimension, link, &this->array_dimensions) { + ir_foreach_list_typed (ast_node, array_dimension, link, &this->array_dimensions) { printf("[ "); if (((ast_expression*)array_dimension)->oper != ast_unsized_array_dim) array_dimension->print(); diff --git a/src/compiler/glsl/ast_function.cpp b/src/compiler/glsl/ast_function.cpp index 34eb894fc36..7764da94773 100644 --- a/src/compiler/glsl/ast_function.cpp +++ b/src/compiler/glsl/ast_function.cpp @@ -35,14 +35,14 @@ static ir_rvalue * convert_component(ir_rvalue *src, const glsl_type *desired_type); static unsigned -process_parameters(exec_list *instructions, exec_list *actual_parameters, - exec_list *parameters, +process_parameters(ir_exec_list *instructions, ir_exec_list *actual_parameters, + ir_exec_list *parameters, struct _mesa_glsl_parse_state *state) { void *mem_ctx = state; unsigned count = 0; - foreach_list_typed(ast_node, ast, link, parameters) { + ir_foreach_list_typed(ast_node, ast, link, parameters) { /* We need to process the parameters first in order to know if we can * raise or not a unitialized warning. Calling set_is_lhs silence the * warning for now. Raising the warning or not will be checked at @@ -87,7 +87,7 @@ process_parameters(exec_list *instructions, exec_list *actual_parameters, */ char * prototype_string(const glsl_type *return_type, const char *name, - exec_list *parameters) + ir_exec_list *parameters) { char *str = NULL; @@ -97,7 +97,7 @@ prototype_string(const glsl_type *return_type, const char *name, ralloc_asprintf_append(&str, "%s(", name); const char *comma = ""; - foreach_in_list(const ir_instruction, param, parameters) { + ir_foreach_in_list(const ir_instruction, param, parameters) { ralloc_asprintf_append(&str, "%s%s", comma, glsl_get_type_name(param->ir_type == ir_type_variable ? ((ir_variable *)param)->type : @@ -226,20 +226,20 @@ is_atomic_image_function(const char *func_name) static bool verify_parameter_modes(_mesa_glsl_parse_state *state, ir_function_signature *sig, - exec_list &actual_ir_parameters, - exec_list &actual_ast_parameters) + ir_exec_list &actual_ir_parameters, + ir_exec_list &actual_ast_parameters) { - exec_node *actual_ir_node = actual_ir_parameters.get_head_raw(); - exec_node *actual_ast_node = actual_ast_parameters.get_head_raw(); + ir_exec_node *actual_ir_node = actual_ir_parameters.get_head_raw(); + ir_exec_node *actual_ast_node = actual_ast_parameters.get_head_raw(); - foreach_in_list(const ir_variable, formal, &sig->parameters) { + ir_foreach_in_list(const ir_variable, formal, &sig->parameters) { /* The lists must be the same length. */ assert(!actual_ir_node->is_tail_sentinel()); assert(!actual_ast_node->is_tail_sentinel()); const ir_rvalue *const actual = (ir_rvalue *) actual_ir_node; const ast_expression *const actual_ast = - exec_node_data(ast_expression, actual_ast_node, link); + ir_exec_node_data(ast_expression, actual_ast_node, link); YYLTYPE loc = actual_ast->get_location(); @@ -396,7 +396,7 @@ verify_parameter_modes(_mesa_glsl_parse_state *state, (ir_rvalue *) actual_ir_parameters.get_head_raw(); const ast_expression *const actual_ast = - exec_node_data(ast_expression, + ir_exec_node_data(ast_expression, actual_ast_parameters.get_head_raw(), link); YYLTYPE loc = actual_ast->get_location(); @@ -409,7 +409,7 @@ verify_parameter_modes(_mesa_glsl_parse_state *state, (ir_rvalue *) actual_ir_parameters.get_head_raw(); const ast_expression *const actual_ast = - exec_node_data(ast_expression, + ir_exec_node_data(ast_expression, actual_ast_parameters.get_head_raw(), link); YYLTYPE loc = actual_ast->get_location(); @@ -424,7 +424,7 @@ verify_parameter_modes(_mesa_glsl_parse_state *state, struct copy_index_deref_data { void *mem_ctx; - exec_list *before_instructions; + ir_exec_list *before_instructions; }; static void @@ -465,7 +465,7 @@ copy_index_derefs_to_temps(ir_instruction *ir, void *data) static void fix_parameter(void *mem_ctx, ir_rvalue *actual, const glsl_type *formal_type, - exec_list *before_instructions, exec_list *after_instructions, + ir_exec_list *before_instructions, ir_exec_list *after_instructions, bool parameter_is_inout) { ir_expression *const expr = actual->as_expression(); @@ -568,21 +568,21 @@ fix_parameter(void *mem_ctx, ir_rvalue *actual, const glsl_type *formal_type, * this returns NULL. */ static ir_rvalue * -generate_call(exec_list *instructions, ir_function_signature *sig, - exec_list *actual_parameters, +generate_call(ir_exec_list *instructions, ir_function_signature *sig, + ir_exec_list *actual_parameters, ir_variable *sub_var, ir_rvalue *array_idx, struct _mesa_glsl_parse_state *state) { void *ctx = state; - exec_list post_call_conversions; + ir_exec_list post_call_conversions; /* Perform implicit conversion of arguments. For out parameters, we need * to place them in a temporary variable and do the conversion after the * call takes place. Since we haven't emitted the call yet, we'll place - * the post-call conversions in a temporary exec_list, and emit them later. + * the post-call conversions in a temporary ir_exec_list, and emit them later. */ - foreach_two_lists(formal_node, &sig->parameters, + ir_foreach_two_lists(formal_node, &sig->parameters, actual_node, actual_parameters) { ir_rvalue *actual = (ir_rvalue *) actual_node; ir_variable *formal = (ir_variable *) formal_node; @@ -699,7 +699,7 @@ generate_call(exec_list *instructions, ir_function_signature *sig, */ static ir_function_signature * match_function_by_name(const char *name, - exec_list *actual_parameters, + ir_exec_list *actual_parameters, struct _mesa_glsl_parse_state *state) { ir_function *f = state->symbols->get_function(name); @@ -747,7 +747,7 @@ match_function_by_name(const char *name, static ir_function_signature * match_subroutine_by_name(const char *name, - exec_list *actual_parameters, + ir_exec_list *actual_parameters, struct _mesa_glsl_parse_state *state, ir_variable **var_r) { @@ -785,10 +785,10 @@ match_subroutine_by_name(const char *name, } static ir_rvalue * -generate_array_index(void *mem_ctx, exec_list *instructions, +generate_array_index(void *mem_ctx, ir_exec_list *instructions, struct _mesa_glsl_parse_state *state, YYLTYPE loc, const ast_expression *array, ast_expression *idx, - const char **function_name, exec_list *actual_parameters) + const char **function_name, ir_exec_list *actual_parameters) { if (array->oper == ast_array_index) { /* This handles arrays of arrays */ @@ -827,7 +827,7 @@ function_exists(_mesa_glsl_parse_state *state, { ir_function *f = symbols->get_function(name); if (f != NULL) { - foreach_in_list(ir_function_signature, sig, &f->signatures) { + ir_foreach_in_list(ir_function_signature, sig, &f->signatures) { if (sig->is_builtin() && !sig->is_builtin_available(state)) continue; return true; @@ -843,7 +843,7 @@ print_function_prototypes(_mesa_glsl_parse_state *state, YYLTYPE *loc, if (f == NULL) return; - foreach_in_list(ir_function_signature, sig, &f->signatures) { + ir_foreach_in_list(ir_function_signature, sig, &f->signatures) { if (sig->is_builtin() && !sig->is_builtin_available(state)) continue; @@ -861,7 +861,7 @@ print_function_prototypes(_mesa_glsl_parse_state *state, YYLTYPE *loc, static void no_matching_function_error(const char *name, YYLTYPE *loc, - exec_list *actual_parameters, + ir_exec_list *actual_parameters, _mesa_glsl_parse_state *state) { struct glsl_symbol_table *symb = _mesa_glsl_get_builtin_function_symbols(); @@ -1255,9 +1255,9 @@ dereference_component(ir_rvalue *src, unsigned component) static ir_rvalue * -process_vec_mat_constructor(exec_list *instructions, +process_vec_mat_constructor(ir_exec_list *instructions, const glsl_type *constructor_type, - YYLTYPE *loc, exec_list *parameters, + YYLTYPE *loc, ir_exec_list *parameters, struct _mesa_glsl_parse_state *state) { void *ctx = state; @@ -1276,7 +1276,7 @@ process_vec_mat_constructor(exec_list *instructions, return ir_rvalue::error_value(ctx); } - exec_list actual_parameters; + ir_exec_list actual_parameters; const unsigned parameter_count = process_parameters(instructions, &actual_parameters, parameters, state); @@ -1294,7 +1294,7 @@ process_vec_mat_constructor(exec_list *instructions, bool all_parameters_are_constant = true; /* Type cast each parameter and, if possible, fold constants. */ - foreach_in_list_safe(ir_rvalue, ir, &actual_parameters) { + ir_foreach_in_list_safe(ir_rvalue, ir, &actual_parameters) { /* Apply implicit conversions (not the scalar constructor rules, see the * spec quote above!) and attempt to convert the parameter to a constant * valued expression. After doing so, track whether or not all the @@ -1330,7 +1330,7 @@ process_vec_mat_constructor(exec_list *instructions, int i = 0; - foreach_in_list(ir_rvalue, rhs, &actual_parameters) { + ir_foreach_in_list(ir_rvalue, rhs, &actual_parameters) { ir_instruction *assignment = NULL; if (glsl_type_is_matrix(var->type)) { @@ -1355,9 +1355,9 @@ process_vec_mat_constructor(exec_list *instructions, static ir_rvalue * -process_array_constructor(exec_list *instructions, +process_array_constructor(ir_exec_list *instructions, const glsl_type *constructor_type, - YYLTYPE *loc, exec_list *parameters, + YYLTYPE *loc, ir_exec_list *parameters, struct _mesa_glsl_parse_state *state) { void *ctx = state; @@ -1381,7 +1381,7 @@ process_array_constructor(exec_list *instructions, * that can be converted to the element type of the array according to * Section 4.1.10 "Implicit Conversions."" */ - exec_list actual_parameters; + ir_exec_list actual_parameters; const unsigned parameter_count = process_parameters(instructions, &actual_parameters, parameters, state); bool is_unsized_array = glsl_type_is_unsized_array(constructor_type); @@ -1410,7 +1410,7 @@ process_array_constructor(exec_list *instructions, const glsl_type *element_type = constructor_type->fields.array; /* Type cast each parameter and, if possible, fold constants. */ - foreach_in_list_safe(ir_rvalue, ir, &actual_parameters) { + ir_foreach_in_list_safe(ir_rvalue, ir, &actual_parameters) { /* Apply implicit conversions (not the scalar constructor rules, see the * spec quote above!) and attempt to convert the parameter to a constant * valued expression. After doing so, track whether or not all the @@ -1466,7 +1466,7 @@ process_array_constructor(exec_list *instructions, instructions->push_tail(var); int i = 0; - foreach_in_list(ir_rvalue, rhs, &actual_parameters) { + ir_foreach_in_list(ir_rvalue, rhs, &actual_parameters) { ir_rvalue *lhs = new(ctx) ir_dereference_array(var, new(ctx) ir_constant(i)); @@ -1484,7 +1484,7 @@ process_array_constructor(exec_list *instructions, * Determine if a list consists of a single scalar r-value */ static bool -single_scalar_parameter(exec_list *parameters) +single_scalar_parameter(ir_exec_list *parameters) { const ir_rvalue *const p = (ir_rvalue *) parameters->get_head_raw(); assert(((ir_rvalue *)p)->as_rvalue() != NULL); @@ -1506,8 +1506,8 @@ single_scalar_parameter(exec_list *parameters) */ static ir_rvalue * emit_inline_vector_constructor(const glsl_type *type, - exec_list *instructions, - exec_list *parameters, + ir_exec_list *instructions, + ir_exec_list *parameters, void *ctx) { assert(!parameters->is_empty()); @@ -1540,7 +1540,7 @@ emit_inline_vector_constructor(const glsl_type *type, memset(&data, 0, sizeof(data)); - foreach_in_list(ir_rvalue, param, parameters) { + ir_foreach_in_list(ir_rvalue, param, parameters) { unsigned rhs_components = glsl_get_components(param->type); /* Do not try to assign more components to the vector than it has! */ @@ -1603,7 +1603,7 @@ emit_inline_vector_constructor(const glsl_type *type, } base_component = 0; - foreach_in_list(ir_rvalue, param, parameters) { + ir_foreach_in_list(ir_rvalue, param, parameters) { unsigned rhs_components = glsl_get_components(param->type); /* Do not try to assign more components to the vector than it has! */ @@ -1700,8 +1700,8 @@ assign_to_matrix_column(ir_variable *var, unsigned column, unsigned row_base, */ static ir_rvalue * emit_inline_matrix_constructor(const glsl_type *type, - exec_list *instructions, - exec_list *parameters, + ir_exec_list *instructions, + ir_exec_list *parameters, void *ctx) { assert(!parameters->is_empty()); @@ -1910,7 +1910,7 @@ emit_inline_matrix_constructor(const glsl_type *type, unsigned col_idx = 0; unsigned row_idx = 0; - foreach_in_list(ir_rvalue, rhs, parameters) { + ir_foreach_in_list(ir_rvalue, rhs, parameters) { unsigned rhs_components = glsl_get_components(rhs->type); unsigned rhs_base = 0; @@ -1968,8 +1968,8 @@ emit_inline_matrix_constructor(const glsl_type *type, static ir_rvalue * emit_inline_record_constructor(const glsl_type *type, - exec_list *instructions, - exec_list *parameters, + ir_exec_list *instructions, + ir_exec_list *parameters, void *mem_ctx) { ir_variable *const var = @@ -1979,7 +1979,7 @@ emit_inline_record_constructor(const glsl_type *type, instructions->push_tail(var); - exec_node *node = parameters->get_head_raw(); + ir_exec_node *node = parameters->get_head_raw(); for (unsigned i = 0; i < type->length; i++) { assert(!node->is_tail_sentinel()); @@ -2001,9 +2001,9 @@ emit_inline_record_constructor(const glsl_type *type, static ir_rvalue * -process_record_constructor(exec_list *instructions, +process_record_constructor(ir_exec_list *instructions, const glsl_type *constructor_type, - YYLTYPE *loc, exec_list *parameters, + YYLTYPE *loc, ir_exec_list *parameters, struct _mesa_glsl_parse_state *state) { void *ctx = state; @@ -2024,7 +2024,7 @@ process_record_constructor(exec_list *instructions, * "Implicit Conversions". In the latter case, an implicit conversion * will be done on the initializer before the assignment is done." */ - exec_list actual_parameters; + ir_exec_list actual_parameters; const unsigned parameter_count = process_parameters(instructions, &actual_parameters, parameters, @@ -2043,7 +2043,7 @@ process_record_constructor(exec_list *instructions, int i = 0; /* Type cast each parameter and, if possible, fold constants. */ - foreach_in_list_safe(ir_rvalue, ir, &actual_parameters) { + ir_foreach_in_list_safe(ir_rvalue, ir, &actual_parameters) { const glsl_struct_field *struct_field = &constructor_type->fields.structure[i]; @@ -2081,7 +2081,7 @@ process_record_constructor(exec_list *instructions, } ir_rvalue * -ast_function_expression::handle_method(exec_list *instructions, +ast_function_expression::handle_method(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { const ast_expression *field = subexpressions[0]; @@ -2167,7 +2167,7 @@ static inline bool is_valid_constructor(const glsl_type *type, } ir_rvalue * -ast_function_expression::hir(exec_list *instructions, +ast_function_expression::hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { void *ctx = state; @@ -2268,9 +2268,9 @@ ast_function_expression::hir(exec_list *instructions, unsigned matrix_parameters = 0; unsigned nonmatrix_parameters = 0; - exec_list actual_parameters; + ir_exec_list actual_parameters; - foreach_list_typed(ast_node, ast, link, &this->expressions) { + ir_foreach_list_typed(ast_node, ast, link, &this->expressions) { ir_rvalue *result = ast->hir(instructions, state); /* From page 50 (page 56 of the PDF) of the GLSL 1.50 spec: @@ -2350,7 +2350,7 @@ ast_function_expression::hir(exec_list *instructions, * matrix up into a series of column vectors. */ if (!glsl_type_is_matrix(constructor_type)) { - foreach_in_list_safe(ir_rvalue, matrix, &actual_parameters) { + ir_foreach_in_list_safe(ir_rvalue, matrix, &actual_parameters) { if (!glsl_type_is_matrix(matrix->type)) continue; @@ -2376,7 +2376,7 @@ ast_function_expression::hir(exec_list *instructions, bool all_parameters_are_constant = true; /* Type cast each parameter and, if possible, fold constants.*/ - foreach_in_list_safe(ir_rvalue, ir, &actual_parameters) { + ir_foreach_in_list_safe(ir_rvalue, ir, &actual_parameters) { const glsl_type *desired_type; /* From section 5.4.1 of the ARB_bindless_texture spec: @@ -2485,7 +2485,7 @@ ast_function_expression::hir(exec_list *instructions, const ast_expression *id = subexpressions[0]; const char *func_name = NULL; YYLTYPE loc = get_location(); - exec_list actual_parameters; + ir_exec_list actual_parameters; ir_variable *sub_var = NULL; ir_rvalue *array_idx = NULL; @@ -2603,7 +2603,7 @@ ast_function_expression::hir(exec_list *instructions, bool ast_function_expression::has_sequence_subexpression() const { - foreach_list_typed(const ast_node, ast, link, &this->expressions) { + ir_foreach_list_typed(const ast_node, ast, link, &this->expressions) { if (ast->has_sequence_subexpression()) return true; } @@ -2612,7 +2612,7 @@ ast_function_expression::has_sequence_subexpression() const } ir_rvalue * -ast_aggregate_initializer::hir(exec_list *instructions, +ast_aggregate_initializer::hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { void *ctx = state; diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp index 5aa2805d80f..9bf8f2fe223 100644 --- a/src/compiler/glsl/ast_to_hir.cpp +++ b/src/compiler/glsl/ast_to_hir.cpp @@ -66,12 +66,12 @@ using namespace ir_builder; static void detect_conflicting_assignments(struct _mesa_glsl_parse_state *state, - exec_list *instructions); + ir_exec_list *instructions); static void verify_subroutine_associated_funcs(struct _mesa_glsl_parse_state *state); static void -remove_per_vertex_blocks(exec_list *instructions, +remove_per_vertex_blocks(ir_exec_list *instructions, _mesa_glsl_parse_state *state, ir_variable_mode mode); /** @@ -127,7 +127,7 @@ private: }; void -_mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) +_mesa_ast_to_hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { _mesa_glsl_initialize_variables(instructions, state); @@ -156,7 +156,7 @@ _mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) */ state->symbols->push_scope(); - foreach_list_typed (ast_node, ast, link, & state->translation_unit) + ir_foreach_list_typed (ast_node, ast, link, & state->translation_unit) ast->hir(instructions, state); verify_subroutine_associated_funcs(state); @@ -173,7 +173,7 @@ _mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) * applications depend on this behavior, and it matches what nearly all * other drivers do. */ - foreach_in_list_safe(ir_instruction, node, instructions) { + ir_foreach_in_list_safe(ir_instruction, node, instructions) { ir_variable *const var = node->as_variable(); if (var == NULL) @@ -937,7 +937,7 @@ mark_whole_array_access(ir_rvalue *access) } static bool -do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, +do_assignment(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state, const char *non_lvalue_description, ir_rvalue *lhs, ir_rvalue *rhs, ir_rvalue **out_rvalue, bool needs_rvalue, @@ -1071,7 +1071,7 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, } static ir_rvalue * -get_lvalue_copy(exec_list *instructions, ir_rvalue *lvalue) +get_lvalue_copy(ir_exec_list *instructions, ir_rvalue *lvalue) { void *ctx = ralloc_parent(lvalue); ir_variable *var; @@ -1088,7 +1088,7 @@ get_lvalue_copy(exec_list *instructions, ir_rvalue *lvalue) ir_rvalue * -ast_node::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) +ast_node::hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { (void) instructions; (void) state; @@ -1108,14 +1108,14 @@ ast_node::set_is_lhs(bool /* new_value */) } void -ast_function_expression::hir_no_rvalue(exec_list *instructions, +ast_function_expression::hir_no_rvalue(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { (void)hir(instructions, state); } void -ast_aggregate_initializer::hir_no_rvalue(exec_list *instructions, +ast_aggregate_initializer::hir_no_rvalue(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { (void)hir(instructions, state); @@ -1220,7 +1220,7 @@ do_comparison(void *mem_ctx, int operation, ir_rvalue *op0, ir_rvalue *op1) * boolean to avoid triggering cascading error messages. */ static ir_rvalue * -get_scalar_boolean_operand(exec_list *instructions, +get_scalar_boolean_operand(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state, ast_expression *parent_expr, int operand, @@ -1340,14 +1340,14 @@ constant_one_for_inc_dec(void *ctx, const glsl_type *type) } ir_rvalue * -ast_expression::hir(exec_list *instructions, +ast_expression::hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { return do_hir(instructions, state, true); } void -ast_expression::hir_no_rvalue(exec_list *instructions, +ast_expression::hir_no_rvalue(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { do_hir(instructions, state, false); @@ -1372,7 +1372,7 @@ ast_expression::set_is_lhs(bool new_value) } ir_rvalue * -ast_expression::do_hir(exec_list *instructions, +ast_expression::do_hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state, bool needs_rvalue) { @@ -1629,7 +1629,7 @@ ast_expression::do_hir(exec_list *instructions, break; case ast_logic_and: { - exec_list rhs_instructions; + ir_exec_list rhs_instructions; op[0] = get_scalar_boolean_operand(instructions, state, this, 0, "LHS", &error_emitted); op[1] = get_scalar_boolean_operand(&rhs_instructions, state, this, 1, @@ -1663,7 +1663,7 @@ ast_expression::do_hir(exec_list *instructions, } case ast_logic_or: { - exec_list rhs_instructions; + ir_exec_list rhs_instructions; op[0] = get_scalar_boolean_operand(instructions, state, this, 0, "LHS", &error_emitted); op[1] = get_scalar_boolean_operand(&rhs_instructions, state, this, 1, @@ -1883,8 +1883,8 @@ ast_expression::do_hir(exec_list *instructions, * the if-statement assigns a value to the anonymous temporary. This * temporary is the r-value of the expression. */ - exec_list then_instructions; - exec_list else_instructions; + ir_exec_list then_instructions; + ir_exec_list else_instructions; op[1] = this->subexpressions[1]->hir(&then_instructions, state); op[2] = this->subexpressions[2]->hir(&else_instructions, state); @@ -2175,10 +2175,10 @@ ast_expression::do_hir(exec_list *instructions, * therefore add instructions to the instruction list), they get dropped * on the floor. */ - exec_node *previous_tail = NULL; + ir_exec_node *previous_tail = NULL; YYLTYPE previous_operand_loc = loc; - foreach_list_typed (ast_node, ast, link, &this->expressions) { + ir_foreach_list_typed (ast_node, ast, link, &this->expressions) { /* If one of the operands of comma operator does not generate any * code, we want to emit a warning. At each pass through the loop * previous_tail will point to the last instruction in the stream @@ -2309,7 +2309,7 @@ ast_expression::has_sequence_subexpression() const } ir_rvalue * -ast_expression_statement::hir(exec_list *instructions, +ast_expression_statement::hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { /* It is possible to have expression statements that don't have an @@ -2331,13 +2331,13 @@ ast_expression_statement::hir(exec_list *instructions, ir_rvalue * -ast_compound_statement::hir(exec_list *instructions, +ast_compound_statement::hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { if (new_scope) state->symbols->push_scope(); - foreach_list_typed (ast_node, ast, link, &this->statements) + ir_foreach_list_typed (ast_node, ast, link, &this->statements) ast->hir(instructions, state); if (new_scope) @@ -2349,18 +2349,18 @@ ast_compound_statement::hir(exec_list *instructions, } /** - * Evaluate the given exec_node (which should be an ast_node representing + * Evaluate the given ir_exec_node (which should be an ast_node representing * a single array dimension) and return its integer value. */ static unsigned -process_array_size(exec_node *node, +process_array_size(ir_exec_node *node, struct _mesa_glsl_parse_state *state) { void *mem_ctx = state; - exec_list dummy_instructions; + ir_exec_list dummy_instructions; - ast_node *array_size = exec_node_data(ast_node, node, link); + ast_node *array_size = ir_exec_node_data(ast_node, node, link); /** * Dimensions other than the outermost dimension can by unsized if they @@ -2436,7 +2436,7 @@ process_array_type(YYLTYPE *loc, const glsl_type *base, } } - for (exec_node *node = array_specifier->array_dimensions.get_tail_raw(); + for (ir_exec_node *node = array_specifier->array_dimensions.get_tail_raw(); !node->is_head_sentinel(); node = node->prev) { unsigned array_size = process_array_size(node, state); array_type = glsl_array_type(array_type, array_size, 0); @@ -4617,7 +4617,7 @@ get_variable_being_redeclared(ir_variable **var_ptr, YYLTYPE loc, static ir_rvalue * process_initializer(ir_variable *var, ast_declaration *decl, ast_fully_specified_type *type, - exec_list *initializer_instructions, + ir_exec_list *initializer_instructions, struct _mesa_glsl_parse_state *state) { void *mem_ctx = state; @@ -5051,7 +5051,7 @@ validate_identifier(const char *identifier, YYLTYPE loc, } ir_rvalue * -ast_declarator_list::hir(exec_list *instructions, +ast_declarator_list::hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { void *ctx = state; @@ -5080,7 +5080,7 @@ ast_declarator_list::hir(exec_list *instructions, "scope"); } - foreach_list_typed (ast_declaration, decl, link, &this->declarations) { + ir_foreach_list_typed (ast_declaration, decl, link, &this->declarations) { assert(decl->array_specifier == NULL); assert(decl->initializer == NULL); @@ -5113,7 +5113,7 @@ ast_declarator_list::hir(exec_list *instructions, if (this->precise) { assert(this->type == NULL); - foreach_list_typed (ast_declaration, decl, link, &this->declarations) { + ir_foreach_list_typed (ast_declaration, decl, link, &this->declarations) { assert(decl->array_specifier == NULL); assert(decl->initializer == NULL); @@ -5359,7 +5359,7 @@ ast_declarator_list::hir(exec_list *instructions, } } - foreach_list_typed (ast_declaration, decl, link, &this->declarations) { + ir_foreach_list_typed (ast_declaration, decl, link, &this->declarations) { const struct glsl_type *var_type; ir_variable *var; const char *identifier = decl->identifier; @@ -5825,7 +5825,7 @@ ast_declarator_list::hir(exec_list *instructions, * redeclarations) the declaration may not actually be added to the * instruction stream. */ - exec_list initializer_instructions; + ir_exec_list initializer_instructions; /* Examine var name here since var may get deleted in the next call */ bool var_is_gl_id = is_gl_identifier(var->name); @@ -5980,7 +5980,7 @@ ast_declarator_list::hir(exec_list *instructions, ir_rvalue * -ast_parameter_declarator::hir(exec_list *instructions, +ast_parameter_declarator::hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { void *ctx = state; @@ -6114,15 +6114,15 @@ ast_parameter_declarator::hir(exec_list *instructions, void -ast_parameter_declarator::parameters_to_hir(exec_list *ast_parameters, +ast_parameter_declarator::parameters_to_hir(ir_exec_list *ast_parameters, bool formal, - exec_list *ir_parameters, + ir_exec_list *ir_parameters, _mesa_glsl_parse_state *state) { ast_parameter_declarator *void_param = NULL; unsigned count = 0; - foreach_list_typed (ast_parameter_declarator, param, link, ast_parameters) { + ir_foreach_list_typed (ast_parameter_declarator, param, link, ast_parameters) { param->formal_parameter = formal; param->hir(ir_parameters, state); @@ -6156,13 +6156,13 @@ emit_function(_mesa_glsl_parse_state *state, ir_function *f) ir_rvalue * -ast_function::hir(exec_list *instructions, +ast_function::hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { void *ctx = state; ir_function *f = NULL; ir_function_signature *sig = NULL; - exec_list hir_parameters; + ir_exec_list hir_parameters; YYLTYPE loc = this->get_location(); const char *const name = identifier; @@ -6453,7 +6453,7 @@ ast_function::hir(exec_list *instructions, f->subroutine_types = ralloc_array(state, const struct glsl_type *, f->num_subroutine_types); idx = 0; - foreach_list_typed(ast_declaration, decl, link, &this->return_type->qualifier.subroutine_list->declarations) { + ir_foreach_list_typed(ast_declaration, decl, link, &this->return_type->qualifier.subroutine_list->declarations) { const struct glsl_type *type; /* the subroutine type must be already declared */ type = state->symbols->get_type(decl->identifier); @@ -6511,7 +6511,7 @@ ast_function::hir(exec_list *instructions, ir_rvalue * -ast_function_definition::hir(exec_list *instructions, +ast_function_definition::hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { prototype->is_definition = true; @@ -6531,7 +6531,7 @@ ast_function_definition::hir(exec_list *instructions, * Add these to the symbol table. */ state->symbols->push_scope(); - foreach_in_list(ir_variable, var, &signature->parameters) { + ir_foreach_in_list(ir_variable, var, &signature->parameters) { assert(var->as_variable() != NULL); /* The only way a parameter would "exist" is if two parameters have @@ -6570,7 +6570,7 @@ ast_function_definition::hir(exec_list *instructions, ir_rvalue * -ast_jump_statement::hir(exec_list *instructions, +ast_jump_statement::hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { void *ctx = state; @@ -6736,7 +6736,7 @@ ast_jump_statement::hir(exec_list *instructions, ir_rvalue * -ast_demote_statement::hir(exec_list *instructions, +ast_demote_statement::hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { void *ctx = state; @@ -6755,7 +6755,7 @@ ast_demote_statement::hir(exec_list *instructions, ir_rvalue * -ast_selection_statement::hir(exec_list *instructions, +ast_selection_statement::hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { void *ctx = state; @@ -6835,7 +6835,7 @@ key_contents(const void *key) } void -ast_switch_statement::eval_test_expression(exec_list *instructions, +ast_switch_statement::eval_test_expression(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { if (test_val == NULL) @@ -6843,7 +6843,7 @@ ast_switch_statement::eval_test_expression(exec_list *instructions, } ir_rvalue * -ast_switch_statement::hir(exec_list *instructions, +ast_switch_statement::hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { void *ctx = state; @@ -6958,7 +6958,7 @@ ast_switch_statement::hir(exec_list *instructions, void -ast_switch_statement::test_to_hir(exec_list *instructions, +ast_switch_statement::test_to_hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { void *ctx = state; @@ -6983,7 +6983,7 @@ ast_switch_statement::test_to_hir(exec_list *instructions, ir_rvalue * -ast_switch_body::hir(exec_list *instructions, +ast_switch_body::hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { if (stmts != NULL) { @@ -6997,12 +6997,12 @@ ast_switch_body::hir(exec_list *instructions, } ir_rvalue * -ast_case_statement_list::hir(exec_list *instructions, +ast_case_statement_list::hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { - exec_list default_case, after_default, tmp; + ir_exec_list default_case, after_default, tmp; - foreach_list_typed (ast_case_statement, case_stmt, link, & this->cases) { + ir_foreach_list_typed (ast_case_statement, case_stmt, link, & this->cases) { case_stmt->hir(&tmp, state); /* Default case. */ @@ -7061,7 +7061,7 @@ ast_case_statement_list::hir(exec_list *instructions, } ir_rvalue * -ast_case_statement::hir(exec_list *instructions, +ast_case_statement::hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { labels->hir(instructions, state); @@ -7071,7 +7071,7 @@ ast_case_statement::hir(exec_list *instructions, new(state) ir_dereference_variable(state->switch_state.is_fallthru_var); ir_if *const test_fallthru = new(state) ir_if(deref_fallthru_guard); - foreach_list_typed (ast_node, stmt, link, & this->stmts) + ir_foreach_list_typed (ast_node, stmt, link, & this->stmts) stmt->hir(& test_fallthru->then_instructions, state); instructions->push_tail(test_fallthru); @@ -7082,10 +7082,10 @@ ast_case_statement::hir(exec_list *instructions, ir_rvalue * -ast_case_label_list::hir(exec_list *instructions, +ast_case_label_list::hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { - foreach_list_typed (ast_case_label, label, link, & this->labels) + ir_foreach_list_typed (ast_case_label, label, link, & this->labels) label->hir(instructions, state); /* Case labels do not have r-values. */ @@ -7093,7 +7093,7 @@ ast_case_label_list::hir(exec_list *instructions, } ir_rvalue * -ast_case_label::hir(exec_list *instructions, +ast_case_label::hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { ir_factory body(instructions, state); @@ -7230,7 +7230,7 @@ ast_case_label::hir(exec_list *instructions, } void -ast_iteration_statement::condition_to_hir(exec_list *instructions, +ast_iteration_statement::condition_to_hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { void *ctx = state; @@ -7265,7 +7265,7 @@ ast_iteration_statement::condition_to_hir(exec_list *instructions, ir_rvalue * -ast_iteration_statement::hir(exec_list *instructions, +ast_iteration_statement::hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { void *ctx = state; @@ -7370,7 +7370,7 @@ is_valid_default_precision_type(const struct glsl_type *const type) ir_rvalue * -ast_type_specifier::hir(exec_list *instructions, +ast_type_specifier::hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { if (this->default_precision == ast_precision_none && this->structure == NULL) @@ -7480,9 +7480,9 @@ ast_type_specifier::hir(exec_list *instructions, * stored in \c *fields_ret. */ static unsigned -ast_process_struct_or_iface_block_members(exec_list *instructions, +ast_process_struct_or_iface_block_members(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state, - exec_list *declarations, + ir_exec_list *declarations, glsl_struct_field **fields_ret, bool is_interface, enum glsl_matrix_layout matrix_layout, @@ -7503,7 +7503,7 @@ ast_process_struct_or_iface_block_members(exec_list *instructions, * This means that we actually need to count the number of elements in the * 'declarations' list in each of the elements. */ - foreach_list_typed (ast_declarator_list, decl_list, link, declarations) { + ir_foreach_list_typed (ast_declarator_list, decl_list, link, declarations) { decl_count += decl_list->declarations.length(); } @@ -7519,7 +7519,7 @@ ast_process_struct_or_iface_block_members(exec_list *instructions, bool first_member_has_explicit_location = false; unsigned i = 0; - foreach_list_typed (ast_declarator_list, decl_list, link, declarations) { + ir_foreach_list_typed (ast_declarator_list, decl_list, link, declarations) { const char *type_name; YYLTYPE loc = decl_list->get_location(); @@ -7711,7 +7711,7 @@ ast_process_struct_or_iface_block_members(exec_list *instructions, validate_matrix_layout_for_type(state, &loc, decl_type, NULL); } - foreach_list_typed (ast_declaration, decl, link, + ir_foreach_list_typed (ast_declaration, decl, link, &decl_list->declarations) { YYLTYPE loc = decl->get_location(); @@ -7970,7 +7970,7 @@ is_anonymous(const glsl_type *t) } ir_rvalue * -ast_struct_specifier::hir(exec_list *instructions, +ast_struct_specifier::hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { YYLTYPE loc = this->get_location(); @@ -8086,7 +8086,7 @@ apply_memory_qualifiers(ir_variable *var, glsl_struct_field field) } ir_rvalue * -ast_interface_block::hir(exec_list *instructions, +ast_interface_block::hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { YYLTYPE loc = this->get_location(); @@ -8214,7 +8214,7 @@ ast_interface_block::hir(exec_list *instructions, matrix_layout = GLSL_MATRIX_LAYOUT_COLUMN_MAJOR; bool redeclaring_per_vertex = strcmp(this->block_name, "gl_PerVertex") == 0; - exec_list declared_variables; + ir_exec_list declared_variables; glsl_struct_field *fields; /* For blocks that accept memory qualifiers (i.e. shader storage), verify @@ -8833,7 +8833,7 @@ ast_interface_block::hir(exec_list *instructions, * thinking there are conflicting definitions of gl_PerVertex in the * shader. */ - foreach_in_list_safe(ir_instruction, node, instructions) { + ir_foreach_in_list_safe(ir_instruction, node, instructions) { ir_variable *const var = node->as_variable(); if (var != NULL && var->get_interface_type() == earlier_per_vertex && @@ -8856,7 +8856,7 @@ ast_interface_block::hir(exec_list *instructions, ir_rvalue * -ast_tcs_output_layout::hir(exec_list *instructions, +ast_tcs_output_layout::hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { YYLTYPE loc = this->get_location(); @@ -8887,7 +8887,7 @@ ast_tcs_output_layout::hir(exec_list *instructions, /* If any shader outputs occurred before this declaration and did not * specify an array size, their size is determined now. */ - foreach_in_list (ir_instruction, node, instructions) { + ir_foreach_in_list (ir_instruction, node, instructions) { ir_variable *var = node->as_variable(); if (var == NULL || var->data.mode != ir_var_shader_out) continue; @@ -8913,7 +8913,7 @@ ast_tcs_output_layout::hir(exec_list *instructions, ir_rvalue * -ast_gs_input_layout::hir(exec_list *instructions, +ast_gs_input_layout::hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { YYLTYPE loc = this->get_location(); @@ -8941,7 +8941,7 @@ ast_gs_input_layout::hir(exec_list *instructions, /* If any shader inputs occurred before this declaration and did not * specify an array size, their size is determined now. */ - foreach_in_list(ir_instruction, node, instructions) { + ir_foreach_in_list(ir_instruction, node, instructions) { ir_variable *var = node->as_variable(); if (var == NULL || var->data.mode != ir_var_shader_in) continue; @@ -8969,7 +8969,7 @@ ast_gs_input_layout::hir(exec_list *instructions, ir_rvalue * -ast_cs_input_layout::hir(exec_list *instructions, +ast_cs_input_layout::hir(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { YYLTYPE loc = this->get_location(); @@ -9078,7 +9078,7 @@ ast_cs_input_layout::hir(exec_list *instructions, static void detect_conflicting_assignments(struct _mesa_glsl_parse_state *state, - exec_list *instructions) + ir_exec_list *instructions) { bool gl_FragColor_assigned = false; bool gl_FragData_assigned = false; @@ -9091,7 +9091,7 @@ detect_conflicting_assignments(struct _mesa_glsl_parse_state *state, YYLTYPE loc; memset(&loc, 0, sizeof(loc)); - foreach_in_list(ir_instruction, node, instructions) { + ir_foreach_in_list(ir_instruction, node, instructions) { ir_variable *var = node->as_variable(); if (!var || !var->data.assigned) @@ -9185,7 +9185,7 @@ verify_subroutine_associated_funcs(struct _mesa_glsl_parse_state *state) unsigned definitions = 0; ir_function *fn = state->subroutines[i]; /* Calculate number of function definitions with the same name */ - foreach_in_list(ir_function_signature, sig, &fn->signatures) { + ir_foreach_in_list(ir_function_signature, sig, &fn->signatures) { if (sig->is_defined) { if (++definitions > 1) { _mesa_glsl_error(&loc, state, @@ -9202,7 +9202,7 @@ verify_subroutine_associated_funcs(struct _mesa_glsl_parse_state *state) } static void -remove_per_vertex_blocks(exec_list *instructions, +remove_per_vertex_blocks(ir_exec_list *instructions, _mesa_glsl_parse_state *state, ir_variable_mode mode) { /* Find the gl_PerVertex interface block of the appropriate (in/out) mode, @@ -9242,7 +9242,7 @@ remove_per_vertex_blocks(exec_list *instructions, /* Remove any ir_variable declarations that refer to the interface block * we're removing. */ - foreach_in_list_safe(ir_instruction, node, instructions) { + ir_foreach_in_list_safe(ir_instruction, node, instructions) { ir_variable *const var = node->as_variable(); if (var != NULL && var->get_interface_type() == per_vertex && var->data.mode == mode && @@ -9254,7 +9254,7 @@ remove_per_vertex_blocks(exec_list *instructions, } ir_rvalue * -ast_warnings_toggle::hir(exec_list *, +ast_warnings_toggle::hir(ir_exec_list *, struct _mesa_glsl_parse_state *state) { state->warnings_enabled = enable; diff --git a/src/compiler/glsl/ast_type.cpp b/src/compiler/glsl/ast_type.cpp index 36acf7f00d0..2bc83041fd3 100644 --- a/src/compiler/glsl/ast_type.cpp +++ b/src/compiler/glsl/ast_type.cpp @@ -976,11 +976,11 @@ ast_layout_expression::process_qualifier_constant(struct _mesa_glsl_parse_state if (!can_be_zero) min_value = 1; - for (exec_node *node = layout_const_expressions.get_head_raw(); + for (ir_exec_node *node = layout_const_expressions.get_head_raw(); !node->is_tail_sentinel(); node = node->next) { - exec_list dummy_instructions; - ast_node *const_expression = exec_node_data(ast_node, node, link); + ir_exec_list dummy_instructions; + ast_node *const_expression = ir_exec_node_data(ast_node, node, link); ir_rvalue *const ir = const_expression->hir(&dummy_instructions, state); @@ -1032,7 +1032,7 @@ process_qualifier_constant(struct _mesa_glsl_parse_state *state, ast_expression *const_expression, unsigned *value) { - exec_list dummy_instructions; + ir_exec_list dummy_instructions; if (const_expression == NULL) { *value = 0; diff --git a/src/compiler/glsl/builtin_functions.cpp b/src/compiler/glsl/builtin_functions.cpp index 3356140b12c..7007c77b85c 100644 --- a/src/compiler/glsl/builtin_functions.cpp +++ b/src/compiler/glsl/builtin_functions.cpp @@ -1155,7 +1155,7 @@ public: void initialize(); void release(); ir_function_signature *find(_mesa_glsl_parse_state *state, - const char *name, exec_list *actual_parameters); + const char *name, ir_exec_list *actual_parameters); /** * A symbol table to hold all the built-in signatures; created by this @@ -1208,7 +1208,7 @@ private: * point to the ir_variable that will hold the function return * value, or be \c NULL if the function has void return type. */ - ir_call *call(ir_function *f, ir_variable *ret, exec_list params); + ir_call *call(ir_function *f, ir_variable *ret, ir_exec_list params); /** Create a new function and add the given signatures. */ void add_function(const char *name, ...); @@ -1634,7 +1634,7 @@ builtin_builder::~builtin_builder() ir_function_signature * builtin_builder::find(_mesa_glsl_parse_state *state, - const char *name, exec_list *actual_parameters) + const char *name, ir_exec_list *actual_parameters) { /* The shader currently being compiled requested a built-in function; * it needs to link against builtin_builder::shader in order to get them. @@ -6035,7 +6035,7 @@ builtin_builder::add_function(const char *name, ...) break; if (false) { - exec_list stuff; + ir_exec_list stuff; stuff.push_tail(sig); validate_ir_tree(&stuff); } @@ -6374,7 +6374,7 @@ builtin_builder::new_sig(const glsl_type *return_type, ir_function_signature *sig = new(mem_ctx) ir_function_signature(return_type, avail); - exec_list plist; + ir_exec_list plist; va_start(ap, num_params); for (int i = 0; i < num_params; i++) { plist.push_tail(va_arg(ap, ir_variable *)); @@ -6511,11 +6511,11 @@ builtin_builder::asin_expr(ir_variable *x, float p0, float p1) * \c ir_call. */ ir_call * -builtin_builder::call(ir_function *f, ir_variable *ret, exec_list params) +builtin_builder::call(ir_function *f, ir_variable *ret, ir_exec_list params) { - exec_list actual_params; + ir_exec_list actual_params; - foreach_in_list_safe(ir_instruction, ir, ¶ms) { + ir_foreach_in_list_safe(ir_instruction, ir, ¶ms) { ir_dereference_variable *d = ir->as_dereference_variable(); if (d != NULL) { d->remove(); @@ -8684,7 +8684,7 @@ builtin_builder::_atomic_counter_op1(const char *intrinsic, body.emit(assign(neg_data, neg(data))); - exec_list parameters; + ir_exec_list parameters; parameters.push_tail(new(mem_ctx) ir_dereference_variable(counter)); parameters.push_tail(new(mem_ctx) ir_dereference_variable(neg_data)); @@ -9584,7 +9584,7 @@ _mesa_glsl_builtin_functions_decref() ir_function_signature * _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state *state, - const char *name, exec_list *actual_parameters) + const char *name, ir_exec_list *actual_parameters) { ir_function_signature *s; simple_mtx_lock(&builtins_lock); @@ -9602,7 +9602,7 @@ _mesa_glsl_has_builtin_function(_mesa_glsl_parse_state *state, const char *name) simple_mtx_lock(&builtins_lock); f = builtins.symbols->get_function(name); if (f != NULL) { - foreach_in_list(ir_function_signature, sig, &f->signatures) { + ir_foreach_in_list(ir_function_signature, sig, &f->signatures) { if (sig->is_builtin_available(state)) { ret = true; break; @@ -9629,7 +9629,7 @@ _mesa_get_main_function_signature(glsl_symbol_table *symbol_table) { ir_function *const f = symbol_table->get_function("main"); if (f != NULL) { - exec_list void_parameters; + ir_exec_list void_parameters; /* Look for the 'void main()' signature and ensure that it's defined. * This keeps the linker from accidentally pick a shader that just diff --git a/src/compiler/glsl/builtin_functions.h b/src/compiler/glsl/builtin_functions.h index 07aaf913db2..2d515f686b3 100644 --- a/src/compiler/glsl/builtin_functions.h +++ b/src/compiler/glsl/builtin_functions.h @@ -42,7 +42,7 @@ _mesa_glsl_builtin_functions_decref(void); extern ir_function_signature * _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state *state, - const char *name, exec_list *actual_parameters); + const char *name, ir_exec_list *actual_parameters); extern bool _mesa_glsl_has_builtin_function(_mesa_glsl_parse_state *state, diff --git a/src/compiler/glsl/builtin_variables.cpp b/src/compiler/glsl/builtin_variables.cpp index 2ee428bdd66..47893770c6a 100644 --- a/src/compiler/glsl/builtin_variables.cpp +++ b/src/compiler/glsl/builtin_variables.cpp @@ -418,7 +418,7 @@ per_vertex_accumulator::construct_interface_instance() const class builtin_variable_generator { public: - builtin_variable_generator(exec_list *instructions, + builtin_variable_generator(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); void generate_constants(); void generate_uniforms(); @@ -511,7 +511,7 @@ private: add_varying(slot, type, GLSL_PRECISION_NONE, name, interp); } - exec_list * const instructions; + ir_exec_list * const instructions; struct _mesa_glsl_parse_state * const state; glsl_symbol_table * const symtab; @@ -541,7 +541,7 @@ private: builtin_variable_generator::builtin_variable_generator( - exec_list *instructions, struct _mesa_glsl_parse_state *state) + ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) : instructions(instructions), state(state), symtab(state->symbols), compatibility(state->compat_shader || state->ARB_compatibility_enable), bool_t(&glsl_type_builtin_bool), int_t(&glsl_type_builtin_int), @@ -1680,7 +1680,7 @@ builtin_variable_generator::generate_varyings() void -_mesa_glsl_initialize_variables(exec_list *instructions, +_mesa_glsl_initialize_variables(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { builtin_variable_generator gen(instructions, state); diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp index 02f237c402a..bf8f2747146 100644 --- a/src/compiler/glsl/glsl_parser_extras.cpp +++ b/src/compiler/glsl/glsl_parser_extras.cpp @@ -1102,10 +1102,10 @@ _mesa_ast_set_aggregate_type(const glsl_type *type, * E.g., if if struct S[2] we want to set each element's type to * struct S. */ - for (exec_node *expr_node = ai->expressions.get_head_raw(); + for (ir_exec_node *expr_node = ai->expressions.get_head_raw(); !expr_node->is_tail_sentinel(); expr_node = expr_node->next) { - ast_expression *expr = exec_node_data(ast_expression, expr_node, + ast_expression *expr = ir_exec_node_data(ast_expression, expr_node, link); if (expr->oper == ast_aggregate) @@ -1114,12 +1114,12 @@ _mesa_ast_set_aggregate_type(const glsl_type *type, /* If the aggregate is a struct, recursively set its fields' types. */ } else if (glsl_type_is_struct(type)) { - exec_node *expr_node = ai->expressions.get_head_raw(); + ir_exec_node *expr_node = ai->expressions.get_head_raw(); /* Iterate through the struct's fields. */ for (unsigned i = 0; !expr_node->is_tail_sentinel() && i < type->length; i++, expr_node = expr_node->next) { - ast_expression *expr = exec_node_data(ast_expression, expr_node, + ast_expression *expr = ir_exec_node_data(ast_expression, expr_node, link); if (expr->oper == ast_aggregate) { @@ -1128,10 +1128,10 @@ _mesa_ast_set_aggregate_type(const glsl_type *type, } /* If the aggregate is a matrix, set its columns' types. */ } else if (glsl_type_is_matrix(type)) { - for (exec_node *expr_node = ai->expressions.get_head_raw(); + for (ir_exec_node *expr_node = ai->expressions.get_head_raw(); !expr_node->is_tail_sentinel(); expr_node = expr_node->next) { - ast_expression *expr = exec_node_data(ast_expression, expr_node, + ast_expression *expr = ir_exec_node_data(ast_expression, expr_node, link); if (expr->oper == ast_aggregate) @@ -1243,7 +1243,7 @@ _mesa_ast_process_interface_block(YYLTYPE *locp, block->default_layout.xfb_buffer = state->out_qualifier->xfb_buffer; } - foreach_list_typed (ast_declarator_list, member, link, &block->declarations) { + ir_foreach_list_typed (ast_declarator_list, member, link, &block->declarations) { ast_type_qualifier& qualifier = member->type->qualifier; if ((qualifier.flags.i & interface_type_mask) == 0) { /* GLSLangSpec.1.50.11, 4.3.7 (Interface Blocks): @@ -1358,7 +1358,7 @@ ast_compound_statement::print(void) const { printf("{\n"); - foreach_list_typed(ast_node, ast, link, &this->statements) { + ir_foreach_list_typed(ast_node, ast, link, &this->statements) { ast->print(); } @@ -1437,7 +1437,7 @@ ast_expression::print(void) const subexpressions[0]->print(); printf("( "); - foreach_list_typed (ast_node, ast, link, &this->expressions) { + ir_foreach_list_typed (ast_node, ast, link, &this->expressions) { if (&ast->link != this->expressions.get_head()) printf(", "); @@ -1484,7 +1484,7 @@ ast_expression::print(void) const case ast_sequence: { printf("( "); - foreach_list_typed (ast_node, ast, link, & this->expressions) { + ir_foreach_list_typed (ast_node, ast, link, & this->expressions) { if (&ast->link != this->expressions.get_head()) printf(", "); @@ -1496,7 +1496,7 @@ ast_expression::print(void) const case ast_aggregate: { printf("{ "); - foreach_list_typed (ast_node, ast, link, & this->expressions) { + ir_foreach_list_typed (ast_node, ast, link, & this->expressions) { if (&ast->link != this->expressions.get_head()) printf(", "); @@ -1550,7 +1550,7 @@ ast_function::print(void) const return_type->print(); printf(" %s (", identifier); - foreach_list_typed(ast_node, ast, link, & this->parameters) { + ir_foreach_list_typed(ast_node, ast, link, & this->parameters) { ast->print(); } @@ -1627,7 +1627,7 @@ ast_declarator_list::print(void) const else printf("precise "); - foreach_list_typed (ast_node, ast, link, & this->declarations) { + ir_foreach_list_typed (ast_node, ast, link, & this->declarations) { if (&ast->link != this->declarations.get_head()) printf(", "); @@ -1769,7 +1769,7 @@ ast_case_label::ast_case_label(ast_expression *test_value) void ast_case_label_list::print(void) const { - foreach_list_typed(ast_node, ast, link, & this->labels) { + ir_foreach_list_typed(ast_node, ast, link, & this->labels) { ast->print(); } printf("\n"); @@ -1784,7 +1784,7 @@ ast_case_label_list::ast_case_label_list(void) void ast_case_statement::print(void) const { labels->print(); - foreach_list_typed(ast_node, ast, link, & this->stmts) { + ir_foreach_list_typed(ast_node, ast, link, & this->stmts) { ast->print(); printf("\n"); } @@ -1799,7 +1799,7 @@ ast_case_statement::ast_case_statement(ast_case_label_list *labels) void ast_case_statement_list::print(void) const { - foreach_list_typed(ast_node, ast, link, & this->cases) { + ir_foreach_list_typed(ast_node, ast, link, & this->cases) { ast->print(); } } @@ -1869,7 +1869,7 @@ void ast_struct_specifier::print(void) const { printf("struct %s { ", name); - foreach_list_typed(ast_node, ast, link, &this->declarations) { + ir_foreach_list_typed(ast_node, ast, link, &this->declarations) { ast->print(); } printf("} "); @@ -1886,7 +1886,7 @@ ast_struct_specifier::ast_struct_specifier(const char *identifier, void ast_subroutine_list::print(void) const { - foreach_list_typed (ast_node, ast, link, & this->declarations) { + ir_foreach_list_typed (ast_node, ast, link, & this->declarations) { if (&ast->link != this->declarations.get_head()) printf(", "); ast->print(); @@ -2358,7 +2358,7 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader, } if (dump_ast) { - foreach_list_typed(ast_node, ast, link, &state->translation_unit) { + ir_foreach_list_typed(ast_node, ast, link, &state->translation_unit) { ast->print(); } printf("\n\n"); @@ -2367,7 +2367,7 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader, ralloc_free(shader->ir); ralloc_free(shader->nir); shader->nir = NULL; - shader->ir = new(shader) exec_list; + shader->ir = new(shader) ir_exec_list; if (!state->error && !state->translation_unit.is_empty()) _mesa_ast_to_hir(shader->ir, state); @@ -2485,7 +2485,7 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader, * integers in floating point registers). */ bool -do_common_optimization(exec_list *ir, bool linked, +do_common_optimization(ir_exec_list *ir, bool linked, const struct gl_shader_compiler_options *options, bool native_integers) { diff --git a/src/compiler/glsl/glsl_parser_extras.h b/src/compiler/glsl/glsl_parser_extras.h index ad09d7ad14e..06f66cc1f79 100644 --- a/src/compiler/glsl/glsl_parser_extras.h +++ b/src/compiler/glsl/glsl_parser_extras.h @@ -385,7 +385,7 @@ struct _mesa_glsl_parse_state { const struct gl_constants *consts; gl_api api; void *scanner; - exec_list translation_unit; + ir_exec_list translation_unit; glsl_symbol_table *symbols; linear_ctx *linalloc; @@ -618,7 +618,7 @@ struct _mesa_glsl_parse_state { * During AST to IR conversion, pointer to the toplevel IR * instruction list being generated. */ - exec_list *toplevel_ir; + ir_exec_list *toplevel_ir; /** Have we found a return statement in this function? */ bool found_return; diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp index 6764c03d71b..3779c602e52 100644 --- a/src/compiler/glsl/glsl_to_nir.cpp +++ b/src/compiler/glsl/glsl_to_nir.cpp @@ -109,7 +109,7 @@ public: private: void add_instr(nir_instr *instr, unsigned num_components, unsigned bit_size); - void truncate_after_instruction(exec_node *ir); + void truncate_after_instruction(ir_exec_node *ir); nir_def *evaluate_rvalue(ir_rvalue *ir); nir_alu_instr *emit(nir_op op, unsigned dest_size, nir_def **srcs); @@ -246,7 +246,7 @@ nir_visitor::evaluate_deref(ir_instruction *ir) } void -nir_visitor::truncate_after_instruction(exec_node *ir) +nir_visitor::truncate_after_instruction(ir_exec_node *ir) { if (!ir) return; @@ -658,7 +658,7 @@ nir_visitor::visit(ir_variable *ir) ir_visitor_status nir_function_visitor::visit_enter(ir_function *ir) { - foreach_in_list(ir_function_signature, sig, &ir->signatures) { + ir_foreach_in_list(ir_function_signature, sig, &ir->signatures) { visitor->create_function(sig); } return visit_continue_with_parent; @@ -689,7 +689,7 @@ nir_visitor::create_function(ir_function_signature *ir) np++; } - foreach_in_list(ir_variable, param, &ir->parameters) { + ir_foreach_in_list(ir_variable, param, &ir->parameters) { func->params[np].num_components = 1; func->params[np].bit_size = 32; @@ -716,7 +716,7 @@ nir_visitor::create_function(ir_function_signature *ir) void nir_visitor::visit(ir_function *ir) { - foreach_in_list(ir_function_signature, sig, &ir->signatures) + ir_foreach_in_list(ir_function_signature, sig, &ir->signatures) sig->accept(this); } @@ -1258,7 +1258,7 @@ nir_visitor::visit(ir_call *ir) assert(param_count == 2 || param_count == 3); /* Deref */ - exec_node *param = ir->actual_parameters.get_head(); + ir_exec_node *param = ir->actual_parameters.get_head(); ir_rvalue *rvalue = (ir_rvalue *) param; ir_dereference *deref = rvalue->as_dereference(); ir_swizzle *swizzle = NULL; @@ -1316,7 +1316,7 @@ nir_visitor::visit(ir_call *ir) case nir_intrinsic_atomic_counter_exchange_deref: case nir_intrinsic_atomic_counter_comp_swap_deref: { /* Set the counter variable dereference. */ - exec_node *param = ir->actual_parameters.get_head(); + ir_exec_node *param = ir->actual_parameters.get_head(); ir_dereference *counter = (ir_dereference *)param; instr->src[0] = nir_src_for_ssa(&evaluate_deref(counter)->def); @@ -1351,7 +1351,7 @@ nir_visitor::visit(ir_call *ir) case nir_intrinsic_image_deref_size: case nir_intrinsic_image_deref_sparse_load: { /* Set the image variable dereference. */ - exec_node *param = ir->actual_parameters.get_head(); + ir_exec_node *param = ir->actual_parameters.get_head(); ir_dereference *image = (ir_dereference *)param; nir_deref_instr *deref = evaluate_deref(image); const glsl_type *type = deref->type; @@ -1539,7 +1539,7 @@ nir_visitor::visit(ir_call *ir) break; } case nir_intrinsic_store_ssbo: { - exec_node *param = ir->actual_parameters.get_head(); + ir_exec_node *param = ir->actual_parameters.get_head(); ir_rvalue *block = ((ir_instruction *)param)->as_rvalue(); param = param->get_next(); @@ -1567,7 +1567,7 @@ nir_visitor::visit(ir_call *ir) break; } case nir_intrinsic_load_shared: { - exec_node *param = ir->actual_parameters.get_head(); + ir_exec_node *param = ir->actual_parameters.get_head(); ir_rvalue *offset = ((ir_instruction *)param)->as_rvalue(); nir_intrinsic_set_base(instr, 0); @@ -1590,7 +1590,7 @@ nir_visitor::visit(ir_call *ir) break; } case nir_intrinsic_store_shared: { - exec_node *param = ir->actual_parameters.get_head(); + ir_exec_node *param = ir->actual_parameters.get_head(); ir_rvalue *offset = ((ir_instruction *)param)->as_rvalue(); param = param->get_next(); @@ -1625,7 +1625,7 @@ nir_visitor::visit(ir_call *ir) glsl_get_bit_size(type)); instr->num_components = instr->def.num_components; - exec_node *param = ir->actual_parameters.get_head(); + ir_exec_node *param = ir->actual_parameters.get_head(); ir_rvalue *value = ((ir_instruction *)param)->as_rvalue(); instr->src[0] = nir_src_for_ssa(evaluate_rvalue(value)); @@ -1684,7 +1684,7 @@ nir_visitor::visit(ir_call *ir) } unsigned index = 0; - foreach_in_list(ir_rvalue, param, &ir->actual_parameters) { + ir_foreach_in_list(ir_rvalue, param, &ir->actual_parameters) { instr->src[index] = nir_src_for_ssa(evaluate_rvalue(param)); if (!nir_intrinsic_src_components(instr, index)) @@ -1729,7 +1729,7 @@ nir_visitor::visit(ir_call *ir) call->params[i++] = nir_src_for_ssa(&ret_deref->def); } - foreach_two_lists(formal_node, &ir->callee->parameters, + ir_foreach_two_lists(formal_node, &ir->callee->parameters, actual_node, &ir->actual_parameters) { ir_rvalue *param_rvalue = (ir_rvalue *) actual_node; ir_variable *sig_param = (ir_variable *) formal_node; @@ -1767,7 +1767,7 @@ nir_visitor::visit(ir_call *ir) * do not overwrite global variables prematurely. */ i = ir->return_deref ? 1 : 0; - foreach_two_lists(formal_node, &ir->callee->parameters, + ir_foreach_two_lists(formal_node, &ir->callee->parameters, actual_node, &ir->actual_parameters) { ir_rvalue *param_rvalue = (ir_rvalue *) actual_node; ir_variable *sig_param = (ir_variable *) formal_node; @@ -2737,7 +2737,7 @@ nir_visitor::visit(ir_dereference_variable *ir) ir->variable_referenced()->data.mode == ir_var_function_in) { unsigned i = (sig->return_type != &glsl_type_builtin_void) ? 1 : 0; - foreach_in_list(ir_variable, param, &sig->parameters) { + ir_foreach_in_list(ir_variable, param, &sig->parameters) { if (param == ir->variable_referenced()) { break; } diff --git a/src/compiler/glsl/hir_field_selection.cpp b/src/compiler/glsl/hir_field_selection.cpp index 5c64153a75b..b9724bd515c 100644 --- a/src/compiler/glsl/hir_field_selection.cpp +++ b/src/compiler/glsl/hir_field_selection.cpp @@ -28,7 +28,7 @@ ir_rvalue * _mesa_ast_field_selection_to_hir(const ast_expression *expr, - exec_list *instructions, + ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { void *ctx = state; diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp index a5a2fa3e039..71c0a214b58 100644 --- a/src/compiler/glsl/ir.cpp +++ b/src/compiler/glsl/ir.cpp @@ -863,7 +863,7 @@ ir_constant::ir_constant(const ir_constant *c, unsigned i) } } -ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list) +ir_constant::ir_constant(const struct glsl_type *type, ir_exec_list *value_list) : ir_rvalue(ir_type_constant) { this->const_elements = NULL; @@ -880,7 +880,7 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list) if (glsl_type_is_array(type) || glsl_type_is_struct(type)) { this->const_elements = ralloc_array(this, ir_constant *, type->length); unsigned i = 0; - foreach_in_list(ir_constant, value, value_list) { + ir_foreach_in_list(ir_constant, value, value_list) { assert(value->as_constant() != NULL); this->const_elements[i++] = value; @@ -2108,10 +2108,10 @@ modes_match(unsigned a, unsigned b) const char * -ir_function_signature::qualifiers_match(exec_list *params) +ir_function_signature::qualifiers_match(ir_exec_list *params) { /* check that the qualifiers match. */ - foreach_two_lists(a_node, &this->parameters, b_node, params) { + ir_foreach_two_lists(a_node, &this->parameters, b_node, params) { ir_variable *a = (ir_variable *) a_node; ir_variable *b = (ir_variable *) b_node; @@ -2136,7 +2136,7 @@ ir_function_signature::qualifiers_match(exec_list *params) void -ir_function_signature::replace_parameters(exec_list *new_params) +ir_function_signature::replace_parameters(ir_exec_list *new_params) { /* Destroy all of the previous parameter information. If the previous * parameter information comes from the function prototype, it may either @@ -2157,7 +2157,7 @@ ir_function::ir_function(const char *name) bool ir_function::has_user_signature() { - foreach_in_list(ir_function_signature, sig, &this->signatures) { + ir_foreach_in_list(ir_function_signature, sig, &this->signatures) { if (!sig->is_builtin()) return true; } @@ -2176,17 +2176,17 @@ ir_rvalue::error_value(void *mem_ctx) void -visit_exec_list(exec_list *list, ir_visitor *visitor) +visit_exec_list(ir_exec_list *list, ir_visitor *visitor) { - foreach_in_list(ir_instruction, node, list) { + ir_foreach_in_list(ir_instruction, node, list) { node->accept(visitor); } } void -visit_exec_list_safe(exec_list *list, ir_visitor *visitor) +visit_exec_list_safe(ir_exec_list *list, ir_visitor *visitor) { - foreach_in_list_safe(ir_instruction, node, list) { + ir_foreach_in_list_safe(ir_instruction, node, list) { node->accept(visitor); } } @@ -2222,9 +2222,9 @@ steal_memory(ir_instruction *ir, void *new_ctx) void -reparent_ir(exec_list *list, void *mem_ctx) +reparent_ir(ir_exec_list *list, void *mem_ctx) { - foreach_in_list(ir_instruction, node, list) { + ir_foreach_in_list(ir_instruction, node, list) { visit_tree(node, steal_memory, mem_ctx); } } diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h index 55f1c313807..e2a6c701715 100644 --- a/src/compiler/glsl/ir.h +++ b/src/compiler/glsl/ir.h @@ -32,7 +32,7 @@ #include "util/format/u_format.h" #include "util/half_float.h" #include "compiler/glsl_types.h" -#include "list.h" +#include "ir_list.h" #include "ir_visitor.h" #include "ir_hierarchical_visitor.h" #include "util/glheader.h" @@ -102,7 +102,7 @@ enum ir_node_type { /** * Base class of all IR instructions */ -class ir_instruction : public exec_node { +class ir_instruction : public ir_exec_node { public: enum ir_node_type ir_type; @@ -1184,7 +1184,7 @@ public: * Returns NULL for non-built-ins. */ ir_constant *constant_expression_value(void *mem_ctx, - exec_list *actual_parameters, + ir_exec_list *actual_parameters, struct hash_table *variable_context); /** @@ -1214,14 +1214,14 @@ public: * and the supplied parameter list. If not, returns the name of the first * parameter with mismatched qualifiers (for use in error messages). */ - const char *qualifiers_match(exec_list *params); + const char *qualifiers_match(ir_exec_list *params); /** * Replace the current parameter list with the given one. This is useful * if the current information came from a prototype, and either has invalid * or missing parameter names. */ - void replace_parameters(exec_list *new_params); + void replace_parameters(ir_exec_list *new_params); /** * Function return type. @@ -1236,7 +1236,7 @@ public: * This represents the storage. The paramaters passed in a particular * call will be in ir_call::actual_paramaters. */ - struct exec_list parameters; + struct ir_exec_list parameters; /** Whether or not this function has a body (which may be empty). */ unsigned is_defined:1; @@ -1267,7 +1267,7 @@ public: bool is_builtin_available(const _mesa_glsl_parse_state *state) const; /** Body of instructions in the function. */ - struct exec_list body; + struct ir_exec_list body; private: /** @@ -1296,7 +1296,7 @@ private: * and the value in *result if result is non-NULL. */ bool constant_expression_evaluate_expression_list(void *mem_ctx, - const struct exec_list &body, + const struct ir_exec_list &body, struct hash_table *variable_context, ir_constant **result); }; @@ -1331,7 +1331,7 @@ public: * conversions into account. Also flags whether the match was exact. */ ir_function_signature *matching_signature(_mesa_glsl_parse_state *state, - const exec_list *actual_param, + const ir_exec_list *actual_param, bool has_implicit_conversions, bool has_implicit_int_to_uint_conversion, bool allow_builtins, @@ -1342,7 +1342,7 @@ public: * conversions into account. */ ir_function_signature *matching_signature(_mesa_glsl_parse_state *state, - const exec_list *actual_param, + const ir_exec_list *actual_param, bool has_implicit_conversions, bool has_implicit_int_to_uint_conversion, bool allow_builtins); @@ -1352,7 +1352,7 @@ public: * any implicit type conversions. */ ir_function_signature *exact_matching_signature(_mesa_glsl_parse_state *state, - const exec_list *actual_ps); + const ir_exec_list *actual_ps); /** * Name of the function. @@ -1365,7 +1365,7 @@ public: /** * List of ir_function_signature for each overloaded function with this name. */ - struct exec_list signatures; + struct ir_exec_list signatures; /** * is this function a subroutine type declaration @@ -1413,9 +1413,9 @@ public: ir_rvalue *condition; /** List of ir_instruction for the body of the then branch */ - exec_list then_instructions; + ir_exec_list then_instructions; /** List of ir_instruction for the body of the else branch */ - exec_list else_instructions; + ir_exec_list else_instructions; }; @@ -1436,7 +1436,7 @@ public: virtual ir_visitor_status accept(ir_hierarchical_visitor *); /** List of ir_instruction that make up the body of the loop. */ - exec_list body_instructions; + ir_exec_list body_instructions; }; @@ -1610,7 +1610,7 @@ class ir_call : public ir_instruction { public: ir_call(ir_function_signature *callee, ir_dereference_variable *return_deref, - exec_list *actual_parameters) + ir_exec_list *actual_parameters) : ir_instruction(ir_type_call), return_deref(return_deref), callee(callee), sub_var(NULL), array_idx(NULL) { assert(callee->return_type != NULL); @@ -1619,7 +1619,7 @@ public: ir_call(ir_function_signature *callee, ir_dereference_variable *return_deref, - exec_list *actual_parameters, + ir_exec_list *actual_parameters, ir_variable *var, ir_rvalue *array_idx) : ir_instruction(ir_type_call), return_deref(return_deref), callee(callee), sub_var(var), array_idx(array_idx) { @@ -1665,7 +1665,7 @@ public: ir_function_signature *callee; /* List of ir_rvalue of paramaters passed in this call. */ - exec_list actual_parameters; + ir_exec_list actual_parameters; /* * ARB_shader_subroutine support - @@ -2200,7 +2200,7 @@ public: /** * Construct an ir_constant from a list of ir_constant values */ - ir_constant(const struct glsl_type *type, exec_list *values); + ir_constant(const struct glsl_type *type, ir_exec_list *values); /** * Construct an ir_constant from a scalar component of another ir_constant @@ -2410,15 +2410,15 @@ public: * Apply a visitor to each IR node in a list */ void -visit_exec_list(exec_list *list, ir_visitor *visitor); +visit_exec_list(ir_exec_list *list, ir_visitor *visitor); void -visit_exec_list_safe(exec_list *list, ir_visitor *visitor); +visit_exec_list_safe(ir_exec_list *list, ir_visitor *visitor); /** * Validate invariants on each IR node in a list */ -void validate_ir_tree(exec_list *instructions); +void validate_ir_tree(ir_exec_list *instructions); /** * Detect whether an unlinked shader contains static recursion @@ -2429,7 +2429,7 @@ void validate_ir_tree(exec_list *instructions); */ void detect_recursion_unlinked(struct _mesa_glsl_parse_state *state, - exec_list *instructions); + ir_exec_list *instructions); /** * Make a clone of each IR instruction in a list @@ -2438,14 +2438,14 @@ detect_recursion_unlinked(struct _mesa_glsl_parse_state *state, * \param out List to hold the cloned instructions */ void -clone_ir_list(void *mem_ctx, exec_list *out, const exec_list *in); +clone_ir_list(void *mem_ctx, ir_exec_list *out, const ir_exec_list *in); extern void -reparent_ir(exec_list *list, void *mem_ctx); +reparent_ir(ir_exec_list *list, void *mem_ctx); extern char * prototype_string(const glsl_type *return_type, const char *name, - exec_list *parameters); + ir_exec_list *parameters); const char * mode_string(const ir_variable *var); @@ -2457,10 +2457,10 @@ extern void _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state); extern void -_mesa_glsl_initialize_variables(struct exec_list *instructions, +_mesa_glsl_initialize_variables(struct ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); -extern void _mesa_print_ir(FILE *f, struct exec_list *instructions, +extern void _mesa_print_ir(FILE *f, struct ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); extern void diff --git a/src/compiler/glsl/ir_basic_block.cpp b/src/compiler/glsl/ir_basic_block.cpp index 15481aa47f6..a206631dfa3 100644 --- a/src/compiler/glsl/ir_basic_block.cpp +++ b/src/compiler/glsl/ir_basic_block.cpp @@ -47,7 +47,7 @@ * don't get returned, nor do the assignments that will be generated * for ir_call parameters. */ -void call_for_basic_blocks(exec_list *instructions, +void call_for_basic_blocks(ir_exec_list *instructions, void (*callback)(ir_instruction *first, ir_instruction *last, void *data), @@ -56,7 +56,7 @@ void call_for_basic_blocks(exec_list *instructions, ir_instruction *leader = NULL; ir_instruction *last = NULL; - foreach_in_list(ir_instruction, ir, instructions) { + ir_foreach_in_list(ir_instruction, ir, instructions) { ir_if *ir_if; ir_loop *ir_loop; ir_function *ir_function; @@ -87,7 +87,7 @@ void call_for_basic_blocks(exec_list *instructions, * and the body of main(). Perhaps those instructions ought * to live inside of main(). */ - foreach_in_list(ir_function_signature, ir_sig, &ir_function->signatures) { + ir_foreach_in_list(ir_function_signature, ir_sig, &ir_function->signatures) { call_for_basic_blocks(&ir_sig->body, callback, data); } } diff --git a/src/compiler/glsl/ir_basic_block.h b/src/compiler/glsl/ir_basic_block.h index 3d32e4e110d..dc97ff5b6ec 100644 --- a/src/compiler/glsl/ir_basic_block.h +++ b/src/compiler/glsl/ir_basic_block.h @@ -24,7 +24,7 @@ #ifndef GLSL_IR_BASIC_BLOCK_H #define GLSL_IR_BASIC_BLOCK_H -void call_for_basic_blocks(exec_list *instructions, +void call_for_basic_blocks(ir_exec_list *instructions, void (*callback)(ir_instruction *first, ir_instruction *last, void *data), diff --git a/src/compiler/glsl/ir_builder.h b/src/compiler/glsl/ir_builder.h index efb274a2e16..47e1a7ff7eb 100644 --- a/src/compiler/glsl/ir_builder.h +++ b/src/compiler/glsl/ir_builder.h @@ -76,7 +76,7 @@ public: class ir_factory { public: - ir_factory(exec_list *instructions = NULL, void *mem_ctx = NULL) + ir_factory(ir_exec_list *instructions = NULL, void *mem_ctx = NULL) : instructions(instructions), mem_ctx(mem_ctx) { @@ -110,7 +110,7 @@ public: return new(mem_ctx) ir_constant(b); } - exec_list *instructions; + ir_exec_list *instructions; void *mem_ctx; }; diff --git a/src/compiler/glsl/ir_clone.cpp b/src/compiler/glsl/ir_clone.cpp index 2aba20d3000..7110bad7838 100644 --- a/src/compiler/glsl/ir_clone.cpp +++ b/src/compiler/glsl/ir_clone.cpp @@ -121,11 +121,11 @@ ir_if::clone(void *mem_ctx, struct hash_table *ht) const { ir_if *new_if = new(mem_ctx) ir_if(this->condition->clone(mem_ctx, ht)); - foreach_in_list(ir_instruction, ir, &this->then_instructions) { + ir_foreach_in_list(ir_instruction, ir, &this->then_instructions) { new_if->then_instructions.push_tail(ir->clone(mem_ctx, ht)); } - foreach_in_list(ir_instruction, ir, &this->else_instructions) { + ir_foreach_in_list(ir_instruction, ir, &this->else_instructions) { new_if->else_instructions.push_tail(ir->clone(mem_ctx, ht)); } @@ -137,7 +137,7 @@ ir_loop::clone(void *mem_ctx, struct hash_table *ht) const { ir_loop *new_loop = new(mem_ctx) ir_loop(); - foreach_in_list(ir_instruction, ir, &this->body_instructions) { + ir_foreach_in_list(ir_instruction, ir, &this->body_instructions) { new_loop->body_instructions.push_tail(ir->clone(mem_ctx, ht)); } @@ -151,9 +151,9 @@ ir_call::clone(void *mem_ctx, struct hash_table *ht) const if (this->return_deref != NULL) new_return_ref = this->return_deref->clone(mem_ctx, ht); - exec_list new_parameters; + ir_exec_list new_parameters; - foreach_in_list(ir_instruction, ir, &this->actual_parameters) { + ir_foreach_in_list(ir_instruction, ir, &this->actual_parameters) { new_parameters.push_tail(ir->clone(mem_ctx, ht)); } @@ -276,7 +276,7 @@ ir_function::clone(void *mem_ctx, struct hash_table *ht) const for (int i = 0; i < copy->num_subroutine_types; i++) copy->subroutine_types[i] = this->subroutine_types[i]; - foreach_in_list(const ir_function_signature, sig, &this->signatures) { + ir_foreach_in_list(const ir_function_signature, sig, &this->signatures) { ir_function_signature *sig_copy = sig->clone(mem_ctx, ht); copy->add_signature(sig_copy); @@ -298,7 +298,7 @@ ir_function_signature::clone(void *mem_ctx, struct hash_table *ht) const /* Clone the instruction list. */ - foreach_in_list(const ir_instruction, inst, &this->body) { + ir_foreach_in_list(const ir_instruction, inst, &this->body) { ir_instruction *const inst_copy = inst->clone(mem_ctx, ht); copy->body.push_tail(inst_copy); } @@ -318,7 +318,7 @@ ir_function_signature::clone_prototype(void *mem_ctx, struct hash_table *ht) con /* Clone the parameter list, but NOT the body. */ - foreach_in_list(const ir_variable, param, &this->parameters) { + ir_foreach_in_list(const ir_variable, param, &this->parameters) { assert(const_cast(param)->as_variable() != NULL); ir_variable *const param_copy = param->clone(mem_ctx, ht); @@ -414,7 +414,7 @@ private: static void -fixup_function_calls(struct hash_table *ht, exec_list *instructions) +fixup_function_calls(struct hash_table *ht, ir_exec_list *instructions) { fixup_ir_call_visitor v(ht); v.run(instructions); @@ -422,11 +422,11 @@ fixup_function_calls(struct hash_table *ht, exec_list *instructions) void -clone_ir_list(void *mem_ctx, exec_list *out, const exec_list *in) +clone_ir_list(void *mem_ctx, ir_exec_list *out, const ir_exec_list *in) { struct hash_table *ht = _mesa_pointer_hash_table_create(NULL); - foreach_in_list(const ir_instruction, original, in) { + ir_foreach_in_list(const ir_instruction, original, in) { ir_instruction *copy = original->clone(mem_ctx, ht); out->push_tail(copy); diff --git a/src/compiler/glsl/ir_constant_expression.cpp b/src/compiler/glsl/ir_constant_expression.cpp index fb6707022a4..04152e3cf4e 100644 --- a/src/compiler/glsl/ir_constant_expression.cpp +++ b/src/compiler/glsl/ir_constant_expression.cpp @@ -1057,13 +1057,13 @@ ir_call::constant_expression_value(void *mem_ctx, struct hash_table *variable_co bool ir_function_signature::constant_expression_evaluate_expression_list(void *mem_ctx, - const struct exec_list &body, + const struct ir_exec_list &body, struct hash_table *variable_context, ir_constant **result) { assert(mem_ctx); - foreach_in_list(ir_instruction, inst, &body) { + ir_foreach_in_list(ir_instruction, inst, &body) { switch(inst->ir_type) { /* (declare () type symbol) */ @@ -1138,7 +1138,7 @@ bool ir_function_signature::constant_expression_evaluate_expression_list(void *m if (!cond || !glsl_type_is_boolean(cond->type)) return false; - exec_list &branch = cond->get_bool_component(0) ? iif->then_instructions : iif->else_instructions; + ir_exec_list &branch = cond->get_bool_component(0) ? iif->then_instructions : iif->else_instructions; *result = NULL; if (!constant_expression_evaluate_expression_list(mem_ctx, branch, @@ -1168,7 +1168,7 @@ bool ir_function_signature::constant_expression_evaluate_expression_list(void *m ir_constant * ir_function_signature::constant_expression_value(void *mem_ctx, - exec_list *actual_parameters, + ir_exec_list *actual_parameters, struct hash_table *variable_context) { assert(mem_ctx); @@ -1209,9 +1209,9 @@ ir_function_signature::constant_expression_value(void *mem_ctx, * have to use the variable objects from the object with the body, * but the parameter instanciation on the current object. */ - const exec_node *parameter_info = origin ? origin->parameters.get_head_raw() : parameters.get_head_raw(); + const ir_exec_node *parameter_info = origin ? origin->parameters.get_head_raw() : parameters.get_head_raw(); - foreach_in_list(ir_rvalue, n, actual_parameters) { + ir_foreach_in_list(ir_rvalue, n, actual_parameters) { ir_constant *constant = n->constant_expression_value(mem_ctx, variable_context); if (constant == NULL) { diff --git a/src/compiler/glsl/ir_expression_flattening.cpp b/src/compiler/glsl/ir_expression_flattening.cpp index bd06be5274f..c3e177791d9 100644 --- a/src/compiler/glsl/ir_expression_flattening.cpp +++ b/src/compiler/glsl/ir_expression_flattening.cpp @@ -52,7 +52,7 @@ public: }; void -do_expression_flattening(exec_list *instructions, +do_expression_flattening(ir_exec_list *instructions, bool (*predicate)(ir_instruction *ir)) { ir_expression_flattening_visitor v(predicate); diff --git a/src/compiler/glsl/ir_expression_flattening.h b/src/compiler/glsl/ir_expression_flattening.h index e75bdfd8420..12666da19cf 100644 --- a/src/compiler/glsl/ir_expression_flattening.h +++ b/src/compiler/glsl/ir_expression_flattening.h @@ -37,7 +37,7 @@ #ifndef GLSL_IR_EXPRESSION_FLATTENING_H #define GLSL_IR_EXPRESSION_FLATTENING_H -void do_expression_flattening(exec_list *instructions, +void do_expression_flattening(ir_exec_list *instructions, bool (*predicate)(ir_instruction *ir)); #endif /* GLSL_IR_EXPRESSION_FLATTENING_H */ diff --git a/src/compiler/glsl/ir_function.cpp b/src/compiler/glsl/ir_function.cpp index 7560761a914..c20a99ce3f5 100644 --- a/src/compiler/glsl/ir_function.cpp +++ b/src/compiler/glsl/ir_function.cpp @@ -55,10 +55,10 @@ get_param_type(const ir_instruction *inst) static parameter_list_match_t parameter_lists_match(bool has_implicit_conversions, bool has_implicit_int_to_uint_conversion, - const exec_list *list_a, const exec_list *list_b) + const ir_exec_list *list_a, const ir_exec_list *list_b) { - const exec_node *node_a = list_a->get_head_raw(); - const exec_node *node_b = list_b->get_head_raw(); + const ir_exec_node *node_a = list_a->get_head_raw(); + const ir_exec_node *node_b = list_b->get_head_raw(); /* This is set to true if there is an inexact match requiring an implicit * conversion. */ @@ -219,7 +219,7 @@ is_better_parameter_match(parameter_match_t a_match, static bool -is_best_inexact_overload(const exec_list *actual_parameters, +is_best_inexact_overload(const ir_exec_list *actual_parameters, ir_function_signature **matches, int num_matches, ir_function_signature *sig) @@ -244,9 +244,9 @@ is_best_inexact_overload(const exec_list *actual_parameters, if (*other == sig) continue; - const exec_node *node_a = sig->parameters.get_head_raw(); - const exec_node *node_b = (*other)->parameters.get_head_raw(); - const exec_node *node_p = actual_parameters->get_head_raw(); + const ir_exec_node *node_a = sig->parameters.get_head_raw(); + const ir_exec_node *node_b = (*other)->parameters.get_head_raw(); + const ir_exec_node *node_p = actual_parameters->get_head_raw(); bool better_for_some_parameter = false; @@ -280,7 +280,7 @@ is_best_inexact_overload(const exec_list *actual_parameters, static ir_function_signature * choose_best_inexact_overload(_mesa_glsl_parse_state *state, - const exec_list *actual_parameters, + const ir_exec_list *actual_parameters, ir_function_signature **matches, int num_matches, bool has_choose_best_inexact_overload) { @@ -303,7 +303,7 @@ choose_best_inexact_overload(_mesa_glsl_parse_state *state, ir_function_signature * ir_function::matching_signature(_mesa_glsl_parse_state *state, - const exec_list *actual_parameters, + const ir_exec_list *actual_parameters, bool has_implicit_conversions, bool has_implicit_int_to_uint_conversion, bool allow_builtins) @@ -316,7 +316,7 @@ ir_function::matching_signature(_mesa_glsl_parse_state *state, ir_function_signature * ir_function::matching_signature(_mesa_glsl_parse_state *state, - const exec_list *actual_parameters, + const ir_exec_list *actual_parameters, bool has_implicit_conversions, bool has_implicit_int_to_uint_conversion, bool allow_builtins, @@ -337,7 +337,7 @@ ir_function::matching_signature(_mesa_glsl_parse_state *state, * multiple ways to apply these conversions to the actual arguments of a * call such that the call can be made to match multiple signatures." */ - foreach_in_list(ir_function_signature, sig, &this->signatures) { + ir_foreach_in_list(ir_function_signature, sig, &this->signatures) { /* Skip over any built-ins that aren't available in this shader. */ if (sig->is_builtin() && (!allow_builtins || !sig->is_builtin_available(state))) @@ -393,10 +393,10 @@ ir_function::matching_signature(_mesa_glsl_parse_state *state, static bool -parameter_lists_match_exact(const exec_list *list_a, const exec_list *list_b) +parameter_lists_match_exact(const ir_exec_list *list_a, const ir_exec_list *list_b) { - const exec_node *node_a = list_a->get_head_raw(); - const exec_node *node_b = list_b->get_head_raw(); + const ir_exec_node *node_a = list_a->get_head_raw(); + const ir_exec_node *node_b = list_b->get_head_raw(); for (/* empty */ ; !node_a->is_tail_sentinel() && !node_b->is_tail_sentinel() @@ -419,9 +419,9 @@ parameter_lists_match_exact(const exec_list *list_a, const exec_list *list_b) ir_function_signature * ir_function::exact_matching_signature(_mesa_glsl_parse_state *state, - const exec_list *actual_parameters) + const ir_exec_list *actual_parameters) { - foreach_in_list(ir_function_signature, sig, &this->signatures) { + ir_foreach_in_list(ir_function_signature, sig, &this->signatures) { /* Skip over any built-ins that aren't available in this shader. */ if (sig->is_builtin() && !sig->is_builtin_available(state)) continue; diff --git a/src/compiler/glsl/ir_function_detect_recursion.cpp b/src/compiler/glsl/ir_function_detect_recursion.cpp index 292412882d0..d8bc86cd3bd 100644 --- a/src/compiler/glsl/ir_function_detect_recursion.cpp +++ b/src/compiler/glsl/ir_function_detect_recursion.cpp @@ -126,7 +126,7 @@ namespace { -struct call_node : public exec_node { +struct call_node : public ir_exec_node { class function *func; }; @@ -143,10 +143,10 @@ public: ir_function_signature *sig; /** List of functions called by this function. */ - exec_list callees; + ir_exec_list callees; /** List of functions that call this function. */ - exec_list callers; + ir_exec_list callers; }; class has_recursion_visitor : public ir_hierarchical_visitor { @@ -229,9 +229,9 @@ public: } /* anonymous namespace */ static void -destroy_links(exec_list *list, function *f) +destroy_links(ir_exec_list *list, function *f) { - foreach_in_list_safe(call_node, node, list) { + ir_foreach_in_list_safe(call_node, node, list) { /* If this is the right function, remove it. Note that the loop cannot * terminate now. There can be multiple links to a function if it is * either called multiple times or calls multiple times. @@ -293,7 +293,7 @@ emit_errors_unlinked(const void *key, void *data, void *closure) void detect_recursion_unlinked(struct _mesa_glsl_parse_state *state, - exec_list *instructions) + ir_exec_list *instructions) { has_recursion_visitor v; diff --git a/src/compiler/glsl/ir_hierarchical_visitor.cpp b/src/compiler/glsl/ir_hierarchical_visitor.cpp index 9c126044eb3..c32c9dd896c 100644 --- a/src/compiler/glsl/ir_hierarchical_visitor.cpp +++ b/src/compiler/glsl/ir_hierarchical_visitor.cpp @@ -371,7 +371,7 @@ ir_hierarchical_visitor::visit_leave(ir_end_primitive *ir) } void -ir_hierarchical_visitor::run(exec_list *instructions) +ir_hierarchical_visitor::run(ir_exec_list *instructions) { visit_list_elements(this, instructions); } diff --git a/src/compiler/glsl/ir_hierarchical_visitor.h b/src/compiler/glsl/ir_hierarchical_visitor.h index dff6a39a6a4..554e2c6b7c2 100644 --- a/src/compiler/glsl/ir_hierarchical_visitor.h +++ b/src/compiler/glsl/ir_hierarchical_visitor.h @@ -147,7 +147,7 @@ public: /** * Utility function to process a linked list of instructions with a visitor */ - void run(struct exec_list *instructions); + void run(struct ir_exec_list *instructions); /** * Utility function to call both the leave and enter callback functions. @@ -209,7 +209,7 @@ void visit_tree(ir_instruction *ir, void (*callback_leave)(class ir_instruction *ir, void *data) = NULL, void *data_leave = NULL); -ir_visitor_status visit_list_elements(ir_hierarchical_visitor *v, exec_list *l, +ir_visitor_status visit_list_elements(ir_hierarchical_visitor *v, ir_exec_list *l, bool statement_list = true); #endif /* __cplusplus */ diff --git a/src/compiler/glsl/ir_hv_accept.cpp b/src/compiler/glsl/ir_hv_accept.cpp index e47adf282de..89a4c3a466e 100644 --- a/src/compiler/glsl/ir_hv_accept.cpp +++ b/src/compiler/glsl/ir_hv_accept.cpp @@ -44,12 +44,12 @@ * processed, some of the added nodes may not be processed. */ ir_visitor_status -visit_list_elements(ir_hierarchical_visitor *v, exec_list *l, +visit_list_elements(ir_hierarchical_visitor *v, ir_exec_list *l, bool statement_list) { ir_instruction *prev_base_ir = v->base_ir; - foreach_in_list_safe(ir_instruction, ir, l) { + ir_foreach_in_list_safe(ir_instruction, ir, l) { if (statement_list) v->base_ir = ir; ir_visitor_status s = ir->accept(v); diff --git a/src/compiler/glsl/ir_list.h b/src/compiler/glsl/ir_list.h new file mode 100644 index 00000000000..d06b4d2126c --- /dev/null +++ b/src/compiler/glsl/ir_list.h @@ -0,0 +1,804 @@ +/* + * Copyright © 2008, 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file list.h + * \brief Doubly-linked list abstract container type. + * + * Each doubly-linked list has a sentinel head and tail node. These nodes + * contain no data. The head sentinel can be identified by its \c prev + * pointer being \c NULL. The tail sentinel can be identified by its + * \c next pointer being \c NULL. + * + * A list is empty if either the head sentinel's \c next pointer points to the + * tail sentinel or the tail sentinel's \c prev poiner points to the head + * sentinel. The head sentinel and tail sentinel nodes are allocated within the + * list structure. + * + * Do note that this means that the list nodes will contain pointers into the + * list structure itself and as a result you may not \c realloc() an \c + * ir_exec_list or any structure in which an \c ir_exec_list is embedded. + */ + +#ifndef IR_LIST_H +#define IR_LIST_H + +#ifndef __cplusplus +#include +#endif +#include + +#include "util/ralloc.h" + +struct ir_exec_node { + struct ir_exec_node *next; + struct ir_exec_node *prev; + +#ifdef __cplusplus + DECLARE_RZALLOC_CXX_OPERATORS(ir_exec_node) + + ir_exec_node() : next(NULL), prev(NULL) + { + /* empty */ + } + + const ir_exec_node *get_next() const; + ir_exec_node *get_next(); + + const ir_exec_node *get_prev() const; + ir_exec_node *get_prev(); + + void remove(); + + /** + * Link a node with itself + * + * This creates a sort of degenerate list that is occasionally useful. + */ + void self_link(); + + /** + * Insert a node in the list after the current node + */ + void insert_after(ir_exec_node *after); + + /** + * Insert another list in the list after the current node + */ + void insert_after(struct ir_exec_list *after); + + /** + * Insert a node in the list before the current node + */ + void insert_before(ir_exec_node *before); + + /** + * Insert another list in the list before the current node + */ + void insert_before(struct ir_exec_list *before); + + /** + * Replace the current node with the given node. + */ + void replace_with(ir_exec_node *replacement); + + /** + * Is this the sentinel at the tail of the list? + */ + bool is_tail_sentinel() const; + + /** + * Is this the sentinel at the head of the list? + */ + bool is_head_sentinel() const; +#endif +}; + +static inline void +ir_exec_node_init(struct ir_exec_node *n) +{ + n->next = NULL; + n->prev = NULL; +} + +static inline const struct ir_exec_node * +ir_exec_node_get_next_const(const struct ir_exec_node *n) +{ + return n->next; +} + +static inline struct ir_exec_node * +ir_exec_node_get_next(struct ir_exec_node *n) +{ + return n->next; +} + +static inline const struct ir_exec_node * +ir_exec_node_get_prev_const(const struct ir_exec_node *n) +{ + return n->prev; +} + +static inline struct ir_exec_node * +ir_exec_node_get_prev(struct ir_exec_node *n) +{ + return n->prev; +} + +static inline void +ir_exec_node_remove(struct ir_exec_node *n) +{ + n->next->prev = n->prev; + n->prev->next = n->next; + n->next = NULL; + n->prev = NULL; +} + +static inline void +ir_exec_node_self_link(struct ir_exec_node *n) +{ + n->next = n; + n->prev = n; +} + +static inline void +ir_exec_node_insert_after(struct ir_exec_node *n, struct ir_exec_node *after) +{ + after->next = n->next; + after->prev = n; + + n->next->prev = after; + n->next = after; +} + +static inline void +ir_exec_node_insert_node_before(struct ir_exec_node *n, struct ir_exec_node *before) +{ + before->next = n; + before->prev = n->prev; + + n->prev->next = before; + n->prev = before; +} + +static inline void +ir_exec_node_replace_with(struct ir_exec_node *n, struct ir_exec_node *replacement) +{ + replacement->prev = n->prev; + replacement->next = n->next; + + n->prev->next = replacement; + n->next->prev = replacement; +} + +static inline bool +ir_exec_node_is_tail_sentinel(const struct ir_exec_node *n) +{ + return n->next == NULL; +} + +static inline bool +ir_exec_node_is_head_sentinel(const struct ir_exec_node *n) +{ + return n->prev == NULL; +} + +#ifdef __cplusplus +inline const ir_exec_node *ir_exec_node::get_next() const +{ + return ir_exec_node_get_next_const(this); +} + +inline ir_exec_node *ir_exec_node::get_next() +{ + return ir_exec_node_get_next(this); +} + +inline const ir_exec_node *ir_exec_node::get_prev() const +{ + return ir_exec_node_get_prev_const(this); +} + +inline ir_exec_node *ir_exec_node::get_prev() +{ + return ir_exec_node_get_prev(this); +} + +inline void ir_exec_node::remove() +{ + ir_exec_node_remove(this); +} + +inline void ir_exec_node::self_link() +{ + ir_exec_node_self_link(this); +} + +inline void ir_exec_node::insert_after(ir_exec_node *after) +{ + ir_exec_node_insert_after(this, after); +} + +inline void ir_exec_node::insert_before(ir_exec_node *before) +{ + ir_exec_node_insert_node_before(this, before); +} + +inline void ir_exec_node::replace_with(ir_exec_node *replacement) +{ + ir_exec_node_replace_with(this, replacement); +} + +inline bool ir_exec_node::is_tail_sentinel() const +{ + return ir_exec_node_is_tail_sentinel(this); +} + +inline bool ir_exec_node::is_head_sentinel() const +{ + return ir_exec_node_is_head_sentinel(this); +} +#endif + +#ifdef __cplusplus +/* This macro will not work correctly if `t' uses virtual inheritance. */ +#define ir_exec_list_offsetof(t, f, p) \ + (((char *) &((t *) p)->f) - ((char *) p)) +#else +#define ir_exec_list_offsetof(t, f, p) offsetof(t, f) +#endif + +/** + * Get a pointer to the structure containing an ir_exec_node + * + * Given a pointer to an \c ir_exec_node embedded in a structure, get a pointer to + * the containing structure. + * + * \param type Base type of the structure containing the node + * \param node Pointer to the \c ir_exec_node + * \param field Name of the field in \c type that is the embedded \c ir_exec_node + */ +#define ir_exec_node_data(type, node, field) \ + ((type *) (((uintptr_t) node) - ir_exec_list_offsetof(type, field, node))) + +#ifdef __cplusplus +struct ir_exec_node; +#endif + +struct ir_exec_list { + struct ir_exec_node head_sentinel; + struct ir_exec_node tail_sentinel; + +#ifdef __cplusplus + DECLARE_RALLOC_CXX_OPERATORS(ir_exec_list) + + ir_exec_list() + { + make_empty(); + } + + void make_empty(); + + bool is_empty() const; + + const ir_exec_node *get_head() const; + ir_exec_node *get_head(); + const ir_exec_node *get_head_raw() const; + ir_exec_node *get_head_raw(); + + const ir_exec_node *get_tail() const; + ir_exec_node *get_tail(); + const ir_exec_node *get_tail_raw() const; + ir_exec_node *get_tail_raw(); + + unsigned length() const; + + void push_head(ir_exec_node *n); + void push_tail(ir_exec_node *n); + void push_degenerate_list_at_head(ir_exec_node *n); + + /** + * Remove the first node from a list and return it + * + * \return + * The first node in the list or \c NULL if the list is empty. + * + * \sa ir_exec_list::get_head + */ + ir_exec_node *pop_head(); + + /** + * Move all of the nodes from this list to the target list + */ + void move_nodes_to(ir_exec_list *target); + + /** + * Append all nodes from the source list to the end of the target list + */ + void append_list(ir_exec_list *source); + + /** + * Prepend all nodes from the source list to the beginning of the target + * list + */ + void prepend_list(ir_exec_list *source); +#endif +}; + +static inline void +ir_exec_list_make_empty(struct ir_exec_list *list) +{ + list->head_sentinel.next = &list->tail_sentinel; + list->head_sentinel.prev = NULL; + list->tail_sentinel.next = NULL; + list->tail_sentinel.prev = &list->head_sentinel; +} + +static inline bool +ir_exec_list_is_empty(const struct ir_exec_list *list) +{ + /* There are three ways to test whether a list is empty or not. + * + * - Check to see if the head sentinel's \c next is the tail sentinel. + * - Check to see if the tail sentinel's \c prev is the head sentinel. + * - Check to see if the head is the sentinel node by test whether its + * \c next pointer is \c NULL. + * + * The first two methods tend to generate better code on modern systems + * because they save a pointer dereference. + */ + return list->head_sentinel.next == &list->tail_sentinel; +} + +static inline bool +ir_exec_list_is_singular(const struct ir_exec_list *list) +{ + return !ir_exec_list_is_empty(list) && + list->head_sentinel.next->next == &list->tail_sentinel; +} + +static inline const struct ir_exec_node * +ir_exec_list_get_head_const(const struct ir_exec_list *list) +{ + return !ir_exec_list_is_empty(list) ? list->head_sentinel.next : NULL; +} + +static inline struct ir_exec_node * +ir_exec_list_get_head(struct ir_exec_list *list) +{ + return !ir_exec_list_is_empty(list) ? list->head_sentinel.next : NULL; +} + +static inline const struct ir_exec_node * +ir_exec_list_get_head_raw_const(const struct ir_exec_list *list) +{ + return list->head_sentinel.next; +} + +static inline struct ir_exec_node * +ir_exec_list_get_head_raw(struct ir_exec_list *list) +{ + return list->head_sentinel.next; +} + +static inline const struct ir_exec_node * +ir_exec_list_get_tail_const(const struct ir_exec_list *list) +{ + return !ir_exec_list_is_empty(list) ? list->tail_sentinel.prev : NULL; +} + +static inline struct ir_exec_node * +ir_exec_list_get_tail(struct ir_exec_list *list) +{ + return !ir_exec_list_is_empty(list) ? list->tail_sentinel.prev : NULL; +} + +static inline const struct ir_exec_node * +ir_exec_list_get_tail_raw_const(const struct ir_exec_list *list) +{ + return list->tail_sentinel.prev; +} + +static inline struct ir_exec_node * +ir_exec_list_get_tail_raw(struct ir_exec_list *list) +{ + return list->tail_sentinel.prev; +} + +static inline unsigned +ir_exec_list_length(const struct ir_exec_list *list) +{ + unsigned size = 0; + struct ir_exec_node *node; + + for (node = list->head_sentinel.next; node->next != NULL; node = node->next) { + size++; + } + + return size; +} + +static inline void +ir_exec_list_push_head(struct ir_exec_list *list, struct ir_exec_node *n) +{ + n->next = list->head_sentinel.next; + n->prev = &list->head_sentinel; + + n->next->prev = n; + list->head_sentinel.next = n; +} + +static inline void +ir_exec_list_push_tail(struct ir_exec_list *list, struct ir_exec_node *n) +{ + n->next = &list->tail_sentinel; + n->prev = list->tail_sentinel.prev; + + n->prev->next = n; + list->tail_sentinel.prev = n; +} + +static inline void +ir_exec_list_push_degenerate_list_at_head(struct ir_exec_list *list, struct ir_exec_node *n) +{ + assert(n->prev->next == n); + + n->prev->next = list->head_sentinel.next; + list->head_sentinel.next->prev = n->prev; + n->prev = &list->head_sentinel; + list->head_sentinel.next = n; +} + +static inline struct ir_exec_node * +ir_exec_list_pop_head(struct ir_exec_list *list) +{ + struct ir_exec_node *const n = ir_exec_list_get_head(list); + if (n != NULL) + ir_exec_node_remove(n); + + return n; +} + +static inline void +ir_exec_list_move_nodes_to(struct ir_exec_list *list, struct ir_exec_list *target) +{ + if (ir_exec_list_is_empty(list)) { + ir_exec_list_make_empty(target); + } else { + target->head_sentinel.next = list->head_sentinel.next; + target->head_sentinel.prev = NULL; + target->tail_sentinel.next = NULL; + target->tail_sentinel.prev = list->tail_sentinel.prev; + + target->head_sentinel.next->prev = &target->head_sentinel; + target->tail_sentinel.prev->next = &target->tail_sentinel; + + ir_exec_list_make_empty(list); + } +} + +static inline void +ir_exec_list_append(struct ir_exec_list *list, struct ir_exec_list *source) +{ + if (ir_exec_list_is_empty(source)) + return; + + /* Link the first node of the source with the last node of the target list. + */ + list->tail_sentinel.prev->next = source->head_sentinel.next; + source->head_sentinel.next->prev = list->tail_sentinel.prev; + + /* Make the tail of the source list be the tail of the target list. + */ + list->tail_sentinel.prev = source->tail_sentinel.prev; + list->tail_sentinel.prev->next = &list->tail_sentinel; + + /* Make the source list empty for good measure. + */ + ir_exec_list_make_empty(source); +} + +static inline void +ir_exec_node_insert_list_after(struct ir_exec_node *n, struct ir_exec_list *after) +{ + if (ir_exec_list_is_empty(after)) + return; + + after->tail_sentinel.prev->next = n->next; + after->head_sentinel.next->prev = n; + + n->next->prev = after->tail_sentinel.prev; + n->next = after->head_sentinel.next; + + ir_exec_list_make_empty(after); +} + +static inline void +ir_exec_list_prepend(struct ir_exec_list *list, struct ir_exec_list *source) +{ + ir_exec_list_append(source, list); + ir_exec_list_move_nodes_to(source, list); +} + +static inline void +ir_exec_node_insert_list_before(struct ir_exec_node *n, struct ir_exec_list *before) +{ + if (ir_exec_list_is_empty(before)) + return; + + before->tail_sentinel.prev->next = n; + before->head_sentinel.next->prev = n->prev; + + n->prev->next = before->head_sentinel.next; + n->prev = before->tail_sentinel.prev; + + ir_exec_list_make_empty(before); +} + +static inline void +ir_exec_list_validate(const struct ir_exec_list *list) +{ + const struct ir_exec_node *node; + + assert(list->head_sentinel.next->prev == &list->head_sentinel); + assert(list->head_sentinel.prev == NULL); + assert(list->tail_sentinel.next == NULL); + assert(list->tail_sentinel.prev->next == &list->tail_sentinel); + + /* We could try to use one of the interators below for this but they all + * either require C++ or assume the ir_exec_node is embedded in a structure + * which is not the case for this function. + */ + for (node = list->head_sentinel.next; node->next != NULL; node = node->next) { + assert(node->next->prev == node); + assert(node->prev->next == node); + } +} + +#ifdef __cplusplus +inline void ir_exec_list::make_empty() +{ + ir_exec_list_make_empty(this); +} + +inline bool ir_exec_list::is_empty() const +{ + return ir_exec_list_is_empty(this); +} + +inline const ir_exec_node *ir_exec_list::get_head() const +{ + return ir_exec_list_get_head_const(this); +} + +inline ir_exec_node *ir_exec_list::get_head() +{ + return ir_exec_list_get_head(this); +} + +inline const ir_exec_node *ir_exec_list::get_head_raw() const +{ + return ir_exec_list_get_head_raw_const(this); +} + +inline ir_exec_node *ir_exec_list::get_head_raw() +{ + return ir_exec_list_get_head_raw(this); +} + +inline const ir_exec_node *ir_exec_list::get_tail() const +{ + return ir_exec_list_get_tail_const(this); +} + +inline ir_exec_node *ir_exec_list::get_tail() +{ + return ir_exec_list_get_tail(this); +} + +inline const ir_exec_node *ir_exec_list::get_tail_raw() const +{ + return ir_exec_list_get_tail_raw_const(this); +} + +inline ir_exec_node *ir_exec_list::get_tail_raw() +{ + return ir_exec_list_get_tail_raw(this); +} + +inline unsigned ir_exec_list::length() const +{ + return ir_exec_list_length(this); +} + +inline void ir_exec_list::push_head(ir_exec_node *n) +{ + ir_exec_list_push_head(this, n); +} + +inline void ir_exec_list::push_tail(ir_exec_node *n) +{ + ir_exec_list_push_tail(this, n); +} + +inline void ir_exec_list::push_degenerate_list_at_head(ir_exec_node *n) +{ + ir_exec_list_push_degenerate_list_at_head(this, n); +} + +inline ir_exec_node *ir_exec_list::pop_head() +{ + return ir_exec_list_pop_head(this); +} + +inline void ir_exec_list::move_nodes_to(ir_exec_list *target) +{ + ir_exec_list_move_nodes_to(this, target); +} + +inline void ir_exec_list::append_list(ir_exec_list *source) +{ + ir_exec_list_append(this, source); +} + +inline void ir_exec_node::insert_after(ir_exec_list *after) +{ + ir_exec_node_insert_list_after(this, after); +} + +inline void ir_exec_list::prepend_list(ir_exec_list *source) +{ + ir_exec_list_prepend(this, source); +} + +inline void ir_exec_node::insert_before(ir_exec_list *before) +{ + ir_exec_node_insert_list_before(this, before); +} +#endif + +#define ir_exec_node_typed_forward(__node, __type) \ + (!ir_exec_node_is_tail_sentinel(__node) ? (__type) (__node) : NULL) + +#define ir_exec_node_typed_backward(__node, __type) \ + (!ir_exec_node_is_head_sentinel(__node) ? (__type) (__node) : NULL) + +#define ir_foreach_in_list(__type, __inst, __list) \ + for (__type *__inst = ir_exec_node_typed_forward((__list)->head_sentinel.next, __type *); \ + (__inst) != NULL; \ + (__inst) = ir_exec_node_typed_forward((__inst)->next, __type *)) + +#define ir_foreach_in_list_reverse(__type, __inst, __list) \ + for (__type *__inst = ir_exec_node_typed_backward((__list)->tail_sentinel.prev, __type *); \ + (__inst) != NULL; \ + (__inst) = ir_exec_node_typed_backward((__inst)->prev, __type *)) + +/** + * This version is safe even if the current node is removed. + */ + +#define ir_foreach_in_list_safe(__type, __node, __list) \ + for (__type *__node = ir_exec_node_typed_forward((__list)->head_sentinel.next, __type *), \ + *__next = (__node) ? ir_exec_node_typed_forward((__list)->head_sentinel.next->next, __type *) : NULL; \ + (__node) != NULL; \ + (__node) = __next, __next = __next ? ir_exec_node_typed_forward(__next->next, __type *) : NULL) + +#define ir_foreach_in_list_reverse_safe(__type, __node, __list) \ + for (__type *__node = ir_exec_node_typed_backward((__list)->tail_sentinel.prev, __type *), \ + *__prev = (__node) ? ir_exec_node_typed_backward((__list)->tail_sentinel.prev->prev, __type *) : NULL; \ + (__node) != NULL; \ + (__node) = __prev, __prev = __prev ? ir_exec_node_typed_backward(__prev->prev, __type *) : NULL) + +#define ir_foreach_in_list_use_after(__type, __inst, __list) \ + __type *__inst; \ + for ((__inst) = ir_exec_node_typed_forward((__list)->head_sentinel.next, __type *); \ + (__inst) != NULL; \ + (__inst) = ir_exec_node_typed_forward((__inst)->next, __type *)) + +/** + * Iterate through two lists at once. Stops at the end of the shorter list. + * + * This is safe against either current node being removed or replaced. + */ +#define ir_foreach_two_lists(__node1, __list1, __node2, __list2) \ + for (struct ir_exec_node * __node1 = (__list1)->head_sentinel.next, \ + * __node2 = (__list2)->head_sentinel.next, \ + * __next1 = __node1->next, \ + * __next2 = __node2->next \ + ; __next1 != NULL && __next2 != NULL \ + ; __node1 = __next1, \ + __node2 = __next2, \ + __next1 = __next1->next, \ + __next2 = __next2->next) + +#define ir_exec_node_data_forward(type, node, field) \ + (!ir_exec_node_is_tail_sentinel(node) ? ir_exec_node_data(type, node, field) : NULL) + +#define ir_exec_node_data_backward(type, node, field) \ + (!ir_exec_node_is_head_sentinel(node) ? ir_exec_node_data(type, node, field) : NULL) + +#define ir_exec_node_data_next(type, node, field) \ + ir_exec_node_data_forward(type, (node)->field.next, field) + +#define ir_exec_node_data_prev(type, node, field) \ + ir_exec_node_data_backward(type, (node)->field.prev, field) + +#define ir_exec_node_data_head(type, list, field) \ + ir_exec_node_data_forward(type, (list)->head_sentinel.next, field) + +#define ir_exec_node_data_tail(type, list, field) \ + ir_exec_node_data_backward(type, (list)->tail_sentinel.prev, field) + +/** + * Iterate over the list from head to tail. Removal is safe for all nodes except the current + * iteration's. + */ +#define ir_foreach_list_typed(type, node, field, list) \ + for (type * node = ir_exec_node_data_head(type, list, field); \ + node != NULL; \ + node = ir_exec_node_data_next(type, node, field)) + +#define ir_foreach_list_typed_from(type, node, field, list, __start) \ + for (type * node = ir_exec_node_data_forward(type, (__start), field); \ + node != NULL; \ + node = ir_exec_node_data_next(type, node, field)) + +/** + * Iterate over the list from tail to head. Removal is safe for all nodes except the current + * iteration's. + */ +#define ir_foreach_list_typed_reverse(type, node, field, list) \ + for (type * node = ir_exec_node_data_tail(type, list, field); \ + node != NULL; \ + node = ir_exec_node_data_prev(type, node, field)) + +#define ir_foreach_list_typed_from_reverse(type, node, field, list, __start) \ + for (type * node = ir_exec_node_data_backward(type, (__start), field); \ + node != NULL; \ + node = ir_exec_node_data_prev(type, node, field)) + +/** + * Iterate over the list from head to tail. Removal is safe for all nodes except the next + * iteration's. If the next iteration's node is removed and not inserted again, this loop exits. + */ +#define ir_foreach_list_typed_safe(type, node, field, list) \ + for (type * node = ir_exec_node_data_head(type, list, field), \ + * __next = node ? \ + ir_exec_node_data_next(type, node, field) : NULL; \ + node != NULL; \ + node = __next, __next = (__next && __next->field.next) ? \ + ir_exec_node_data_next(type, __next, field) : NULL) + +/** + * Iterate over the list from tail to head. Removal is safe for all nodes except the next + * iteration's. If the next iteration's node is removed and not inserted again, this loop exits. + */ +#define ir_foreach_list_typed_reverse_safe(type, node, field, list) \ + for (type * node = ir_exec_node_data_tail(type, list, field), \ + * __prev = node ? \ + ir_exec_node_data_prev(type, node, field) : NULL; \ + node != NULL; \ + node = __prev, __prev = (__prev && __prev->field.prev) ? \ + ir_exec_node_data_prev(type, __prev, field) : NULL) + +#endif /* IR_LIST_H */ diff --git a/src/compiler/glsl/ir_optimization.h b/src/compiler/glsl/ir_optimization.h index be461ca4246..b4be96f0ec2 100644 --- a/src/compiler/glsl/ir_optimization.h +++ b/src/compiler/glsl/ir_optimization.h @@ -34,40 +34,40 @@ struct gl_shader; struct gl_linked_shader; struct gl_shader_program; -bool do_common_optimization(exec_list *ir, bool linked, +bool do_common_optimization(ir_exec_list *ir, bool linked, const struct gl_shader_compiler_options *options, bool native_integers); -bool do_rebalance_tree(exec_list *instructions); -bool do_algebraic(exec_list *instructions, bool native_integers, +bool do_rebalance_tree(ir_exec_list *instructions); +bool do_algebraic(ir_exec_list *instructions, bool native_integers, const struct gl_shader_compiler_options *options); -bool do_dead_code(exec_list *instructions); -bool do_dead_code_local(exec_list *instructions); -bool do_dead_code_unlinked(exec_list *instructions); -bool do_lower_jumps(exec_list *instructions, bool pull_out_jumps = true, bool lower_continue = false); -bool do_if_simplification(exec_list *instructions); -bool opt_flatten_nested_if_blocks(exec_list *instructions); -bool do_mat_op_to_vec(exec_list *instructions); -bool do_minmax_prune(exec_list *instructions); -bool do_tree_grafting(exec_list *instructions); -bool do_vec_index_to_cond_assign(exec_list *instructions); -bool lower_instructions(exec_list *instructions, +bool do_dead_code(ir_exec_list *instructions); +bool do_dead_code_local(ir_exec_list *instructions); +bool do_dead_code_unlinked(ir_exec_list *instructions); +bool do_lower_jumps(ir_exec_list *instructions, bool pull_out_jumps = true, bool lower_continue = false); +bool do_if_simplification(ir_exec_list *instructions); +bool opt_flatten_nested_if_blocks(ir_exec_list *instructions); +bool do_mat_op_to_vec(ir_exec_list *instructions); +bool do_minmax_prune(ir_exec_list *instructions); +bool do_tree_grafting(ir_exec_list *instructions); +bool do_vec_index_to_cond_assign(ir_exec_list *instructions); +bool lower_instructions(ir_exec_list *instructions, bool force_abs_sqrt, bool have_gpu_shader5); -bool lower_packing_builtins(exec_list *instructions, +bool lower_packing_builtins(ir_exec_list *instructions, bool has_shading_language_packing, bool has_gpu_shader5, bool has_half_float_packing); bool lower_vector_derefs(gl_shader *shader); -void optimize_dead_builtin_variables(exec_list *instructions, +void optimize_dead_builtin_variables(ir_exec_list *instructions, enum ir_variable_mode other); -bool lower_builtins(exec_list *instructions); -bool lower_subroutine(exec_list *instructions, struct _mesa_glsl_parse_state *state); -bool propagate_invariance(exec_list *instructions); +bool lower_builtins(ir_exec_list *instructions); +bool lower_subroutine(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state); +bool propagate_invariance(ir_exec_list *instructions); namespace ir_builder { class ir_factory; }; void lower_precision(const struct gl_shader_compiler_options *options, - exec_list *instructions); + ir_exec_list *instructions); #endif /* GLSL_IR_OPTIMIZATION_H */ diff --git a/src/compiler/glsl/ir_print_visitor.cpp b/src/compiler/glsl/ir_print_visitor.cpp index 718265388fd..aeecbf027fc 100644 --- a/src/compiler/glsl/ir_print_visitor.cpp +++ b/src/compiler/glsl/ir_print_visitor.cpp @@ -62,7 +62,7 @@ glsl_print_type(FILE *f, const glsl_type *t) extern "C" { void -_mesa_print_ir(FILE *f, exec_list *instructions, +_mesa_print_ir(FILE *f, ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { if (state) { @@ -83,7 +83,7 @@ _mesa_print_ir(FILE *f, exec_list *instructions, } fprintf(f, "(\n"); - foreach_in_list(ir_instruction, ir, instructions) { + ir_foreach_in_list(ir_instruction, ir, instructions) { ir->fprint(f); if (ir->ir_type != ir_type_function) fprintf(f, "\n"); @@ -253,7 +253,7 @@ void ir_print_visitor::visit(ir_function_signature *ir) fprintf(f, "(parameters\n"); indentation++; - foreach_in_list(ir_variable, inst, &ir->parameters) { + ir_foreach_in_list(ir_variable, inst, &ir->parameters) { indent(); inst->accept(this); fprintf(f, "\n"); @@ -268,7 +268,7 @@ void ir_print_visitor::visit(ir_function_signature *ir) fprintf(f, "(\n"); indentation++; - foreach_in_list(ir_instruction, inst, &ir->body) { + ir_foreach_in_list(ir_instruction, inst, &ir->body) { indent(); inst->accept(this); fprintf(f, "\n"); @@ -285,7 +285,7 @@ void ir_print_visitor::visit(ir_function *ir) { fprintf(f, "(%s function %s\n", ir->is_subroutine ? "subroutine" : "", ir->name); indentation++; - foreach_in_list(ir_function_signature, sig, &ir->signatures) { + ir_foreach_in_list(ir_function_signature, sig, &ir->signatures) { indent(); sig->accept(this); fprintf(f, "\n"); @@ -558,7 +558,7 @@ ir_print_visitor::visit(ir_call *ir) if (ir->return_deref) ir->return_deref->accept(this); fprintf(f, " ("); - foreach_in_list(ir_rvalue, param, &ir->actual_parameters) { + ir_foreach_in_list(ir_rvalue, param, &ir->actual_parameters) { param->accept(this); } fprintf(f, "))\n"); @@ -610,7 +610,7 @@ ir_print_visitor::visit(ir_if *ir) fprintf(f, "(\n"); indentation++; - foreach_in_list(ir_instruction, inst, &ir->then_instructions) { + ir_foreach_in_list(ir_instruction, inst, &ir->then_instructions) { indent(); inst->accept(this); fprintf(f, "\n"); @@ -625,7 +625,7 @@ ir_print_visitor::visit(ir_if *ir) fprintf(f, "(\n"); indentation++; - foreach_in_list(ir_instruction, inst, &ir->else_instructions) { + ir_foreach_in_list(ir_instruction, inst, &ir->else_instructions) { indent(); inst->accept(this); fprintf(f, "\n"); @@ -645,7 +645,7 @@ ir_print_visitor::visit(ir_loop *ir) fprintf(f, "(loop (\n"); indentation++; - foreach_in_list(ir_instruction, inst, &ir->body_instructions) { + ir_foreach_in_list(ir_instruction, inst, &ir->body_instructions) { indent(); inst->accept(this); fprintf(f, "\n"); diff --git a/src/compiler/glsl/ir_rvalue_visitor.cpp b/src/compiler/glsl/ir_rvalue_visitor.cpp index 33390b4bc5b..72a6317789c 100644 --- a/src/compiler/glsl/ir_rvalue_visitor.cpp +++ b/src/compiler/glsl/ir_rvalue_visitor.cpp @@ -124,7 +124,7 @@ ir_rvalue_base_visitor::rvalue_visit(ir_assignment *ir) ir_visitor_status ir_rvalue_base_visitor::rvalue_visit(ir_call *ir) { - foreach_in_list_safe(ir_rvalue, param, &ir->actual_parameters) { + ir_foreach_in_list_safe(ir_rvalue, param, &ir->actual_parameters) { ir_rvalue *new_param = param; handle_rvalue(&new_param); diff --git a/src/compiler/glsl/ir_validate.cpp b/src/compiler/glsl/ir_validate.cpp index 6b18e5ebdf0..7ebd598718a 100644 --- a/src/compiler/glsl/ir_validate.cpp +++ b/src/compiler/glsl/ir_validate.cpp @@ -243,7 +243,7 @@ ir_validate::visit_enter(ir_function *ir) /* Verify that all of the things stored in the list of signatures are, * in fact, function signatures. */ - foreach_in_list(ir_instruction, sig, &ir->signatures) { + ir_foreach_in_list(ir_instruction, sig, &ir->signatures) { if (sig->ir_type != ir_type_function_signature) { printf("Non-signature in signature list of function `%s'\n", ir->name); @@ -1175,8 +1175,8 @@ ir_validate::visit_enter(ir_call *ir) abort(); } - const exec_node *formal_param_node = callee->parameters.get_head_raw(); - const exec_node *actual_param_node = ir->actual_parameters.get_head_raw(); + const ir_exec_node *formal_param_node = callee->parameters.get_head_raw(); + const ir_exec_node *actual_param_node = ir->actual_parameters.get_head_raw(); while (true) { if (formal_param_node->is_tail_sentinel() != actual_param_node->is_tail_sentinel()) { @@ -1244,7 +1244,7 @@ check_node_type(ir_instruction *ir, void *data) } void -validate_ir_tree(exec_list *instructions) +validate_ir_tree(ir_exec_list *instructions) { /* We shouldn't have any reason to validate IR in a release build, * and it's half composed of assert()s anyway which wouldn't do @@ -1258,7 +1258,7 @@ validate_ir_tree(exec_list *instructions) v.run(instructions); - foreach_in_list(ir_instruction, ir, instructions) { + ir_foreach_in_list(ir_instruction, ir, instructions) { visit_tree(ir, check_node_type, NULL); } } diff --git a/src/compiler/glsl/ir_variable_refcount.cpp b/src/compiler/glsl/ir_variable_refcount.cpp index 0f514b8442a..39c4c6428f9 100644 --- a/src/compiler/glsl/ir_variable_refcount.cpp +++ b/src/compiler/glsl/ir_variable_refcount.cpp @@ -48,10 +48,10 @@ free_entry(struct hash_entry *entry) ir_variable_refcount_entry *ivre = (ir_variable_refcount_entry *) entry->data; /* Free assignment list */ - exec_node *n; + ir_exec_node *n; while ((n = ivre->assign_list.pop_head()) != NULL) { struct assignment_entry *assignment_entry = - exec_node_data(struct assignment_entry, n, link); + ir_exec_node_data(struct assignment_entry, n, link); free(assignment_entry); } diff --git a/src/compiler/glsl/ir_variable_refcount.h b/src/compiler/glsl/ir_variable_refcount.h index ae80bf4a718..6aa4ec04a68 100644 --- a/src/compiler/glsl/ir_variable_refcount.h +++ b/src/compiler/glsl/ir_variable_refcount.h @@ -37,7 +37,7 @@ #include "compiler/glsl_types.h" struct assignment_entry { - exec_node link; + ir_exec_node link; ir_assignment *assign; }; @@ -53,7 +53,7 @@ public: * This is intended to be used for dead code optimisation and may * not be a complete list. */ - exec_list assign_list; + ir_exec_list assign_list; /** Number of times the variable is referenced, including assignments. */ unsigned referenced_count; diff --git a/src/compiler/glsl/linker_util.cpp b/src/compiler/glsl/linker_util.cpp index eee71605a07..29af69b743b 100644 --- a/src/compiler/glsl/linker_util.cpp +++ b/src/compiler/glsl/linker_util.cpp @@ -226,12 +226,12 @@ link_util_find_empty_block(struct gl_shader_program *prog, { const unsigned entries = MAX2(1, uniform->array_elements); - foreach_list_typed(struct empty_uniform_block, block, link, + ir_foreach_list_typed(struct empty_uniform_block, block, link, &prog->EmptyUniformLocations) { /* Found a block with enough slots to fit the uniform */ if (block->slots == entries) { unsigned start = block->start; - exec_node_remove(&block->link); + ir_exec_node_remove(&block->link); ralloc_free(block); return start; @@ -260,7 +260,7 @@ link_util_update_empty_uniform_locations(struct gl_shader_program *prog) if (!current_block || current_block->start + current_block->slots != i) { current_block = rzalloc(prog, struct empty_uniform_block); current_block->start = i; - exec_list_push_tail(&prog->EmptyUniformLocations, + ir_exec_list_push_tail(&prog->EmptyUniformLocations, ¤t_block->link); } diff --git a/src/compiler/glsl/linker_util.h b/src/compiler/glsl/linker_util.h index 956ae81504e..716052f0e79 100644 --- a/src/compiler/glsl/linker_util.h +++ b/src/compiler/glsl/linker_util.h @@ -26,7 +26,7 @@ #include "util/bitset.h" #include "util/glheader.h" -#include "compiler/glsl/list.h" +#include "compiler/glsl/ir_list.h" #include "compiler/glsl_types.h" #include "main/mtypes.h" #include "main/shader_types.h" @@ -61,7 +61,7 @@ extern "C" { * continouous block of empty slots in UniformRemapTable. */ struct empty_uniform_block { - struct exec_node link; + struct ir_exec_node link; /* The start location of the block */ unsigned start; /* The number of slots in the block */ diff --git a/src/compiler/glsl/lower_builtins.cpp b/src/compiler/glsl/lower_builtins.cpp index 7b5ac204e65..99a04c29a80 100644 --- a/src/compiler/glsl/lower_builtins.cpp +++ b/src/compiler/glsl/lower_builtins.cpp @@ -42,7 +42,7 @@ public: } bool -lower_builtins(exec_list *instructions) +lower_builtins(ir_exec_list *instructions) { lower_builtins_visitor v; visit_list_elements(&v, instructions); diff --git a/src/compiler/glsl/lower_instructions.cpp b/src/compiler/glsl/lower_instructions.cpp index d5f623c39a9..24961bc40ce 100644 --- a/src/compiler/glsl/lower_instructions.cpp +++ b/src/compiler/glsl/lower_instructions.cpp @@ -84,7 +84,7 @@ private: #define lowering(x) (this->lower & x) bool -lower_instructions(exec_list *instructions, bool force_abs_sqrt, +lower_instructions(ir_exec_list *instructions, bool force_abs_sqrt, bool have_gpu_shader5) { unsigned what_to_lower = diff --git a/src/compiler/glsl/lower_jumps.cpp b/src/compiler/glsl/lower_jumps.cpp index 80bc2c0774e..ba5f6ef21d9 100644 --- a/src/compiler/glsl/lower_jumps.cpp +++ b/src/compiler/glsl/lower_jumps.cpp @@ -185,7 +185,7 @@ struct loop_record { /* also supported for the "function loop" */ if(!this->execute_flag) { - exec_list& list = this->loop ? this->loop->body_instructions : signature->body; + ir_exec_list& list = this->loop ? this->loop->body_instructions : signature->body; this->execute_flag = new(this->signature) ir_variable(&glsl_type_builtin_bool, "execute_flag", ir_var_temporary); list.push_head(new(this->signature) ir_assignment(new(this->signature) ir_dereference_variable(execute_flag), new(this->signature) ir_constant(true))); list.push_head(this->execute_flag); @@ -222,7 +222,7 @@ struct ir_lower_jumps_visitor : public ir_control_flow_visitor { * DEAD_CODE_ELIMINATION: If this->block.min_strength is not * strength_none, the visited node is at the end of its exec_list. * In other words, any unreachable statements that follow the - * visited statement in its exec_list have been removed. + * visited statement in its ir_exec_list have been removed. * * CONTAINED_JUMPS_LOWERED: If the visited statement contains other * statements, then should_lower_jump() is false for all of the @@ -251,7 +251,7 @@ struct ir_lower_jumps_visitor : public ir_control_flow_visitor { { } - void truncate_after_instruction(exec_node *ir) + void truncate_after_instruction(ir_exec_node *ir) { if (!ir) return; @@ -262,7 +262,7 @@ struct ir_lower_jumps_visitor : public ir_control_flow_visitor { } } - void move_outer_block_inside(ir_instruction *ir, exec_list *inner_block) + void move_outer_block_inside(ir_instruction *ir, ir_exec_list *inner_block) { while (!ir->get_next()->is_tail_sentinel()) { ir_instruction *move_ir = (ir_instruction *)ir->get_next(); @@ -360,7 +360,7 @@ struct ir_lower_jumps_visitor : public ir_control_flow_visitor { return lower; } - block_record visit_block(exec_list* list) + block_record visit_block(ir_exec_list* list) { /* Note: since visiting a node may change that node's next * pointer, we can't use visit_exec_list(), because @@ -373,7 +373,7 @@ struct ir_lower_jumps_visitor : public ir_control_flow_visitor { block_record saved_block = this->block; this->block = block_record(); - foreach_in_list(ir_instruction, node, list) { + ir_foreach_in_list(ir_instruction, node, list) { node->accept(this); } block_record ret = this->block; @@ -406,7 +406,7 @@ retry: /* we get here if we put code after the if inside a branch */ * ir->else_instructions end with an unconditional jump. */ for(unsigned i = 0; i < 2; ++i) { - exec_list& list = i ? ir->else_instructions : ir->then_instructions; + ir_exec_list& list = i ? ir->else_instructions : ir->then_instructions; jumps[i] = 0; if(!list.is_empty() && get_jump_strength((ir_instruction*)list.get_tail())) jumps[i] = (ir_jump*)list.get_tail(); @@ -586,8 +586,8 @@ retry: /* we get here if we put code after the if inside a branch */ if(move_into >= 0) { assert(!block_records[move_into].min_strength && !block_records[move_into].may_clear_execute_flag); /* otherwise, we just truncated */ - exec_list* list = move_into ? &ir->else_instructions : &ir->then_instructions; - exec_node* next = ir->get_next(); + ir_exec_list* list = move_into ? &ir->else_instructions : &ir->then_instructions; + ir_exec_node* next = ir->get_next(); if(!next->is_tail_sentinel()) { move_outer_block_inside(ir, list); @@ -598,7 +598,7 @@ retry: /* we get here if we put code after the if inside a branch */ * block_records[move_into] with the result of this * analysis. */ - exec_list list; + ir_exec_list list; list.head_sentinel.next = next; block_records[move_into] = visit_block(&list); @@ -619,7 +619,7 @@ retry: /* we get here if we put code after the if inside a branch */ * any instructions that that are already wrapped in the * appropriate guard. */ - exec_node *node; + ir_exec_node *node; for(node = ir->get_next(); !node->is_tail_sentinel();) { ir_instruction* ir_after = (ir_instruction*)node; @@ -804,7 +804,7 @@ retry: /* we get here if we put code after the if inside a branch */ } /* anonymous namespace */ bool -do_lower_jumps(exec_list *instructions, bool pull_out_jumps, bool lower_continue) +do_lower_jumps(ir_exec_list *instructions, bool pull_out_jumps, bool lower_continue) { ir_lower_jumps_visitor v; v.pull_out_jumps = pull_out_jumps; diff --git a/src/compiler/glsl/lower_mat_op_to_vec.cpp b/src/compiler/glsl/lower_mat_op_to_vec.cpp index 6aac4e7b3cb..e2737fe78bb 100644 --- a/src/compiler/glsl/lower_mat_op_to_vec.cpp +++ b/src/compiler/glsl/lower_mat_op_to_vec.cpp @@ -85,7 +85,7 @@ mat_op_to_vec_predicate(ir_instruction *ir) } bool -do_mat_op_to_vec(exec_list *instructions) +do_mat_op_to_vec(ir_exec_list *instructions) { ir_mat_op_to_vec_visitor v; diff --git a/src/compiler/glsl/lower_packing_builtins.cpp b/src/compiler/glsl/lower_packing_builtins.cpp index fb689e463e5..3126af32d41 100644 --- a/src/compiler/glsl/lower_packing_builtins.cpp +++ b/src/compiler/glsl/lower_packing_builtins.cpp @@ -144,7 +144,7 @@ private: const int op_mask; bool progress; ir_factory factory; - exec_list factory_instructions; + ir_exec_list factory_instructions; /** * Determine the needed lowering operation by filtering \a expr_op @@ -1326,7 +1326,7 @@ private: * \brief Lower the builtin packing functions. */ bool -lower_packing_builtins(exec_list *instructions, +lower_packing_builtins(ir_exec_list *instructions, bool has_shading_language_packing, bool has_gpu_shader5, bool has_half_float_packing) diff --git a/src/compiler/glsl/lower_precision.cpp b/src/compiler/glsl/lower_precision.cpp index e1be1c8162e..15179b29493 100644 --- a/src/compiler/glsl/lower_precision.cpp +++ b/src/compiler/glsl/lower_precision.cpp @@ -522,7 +522,7 @@ handle_call(ir_call *ir, const struct set *lowerable_rvalues, /* If the call is to a builtin, then the function won’t have a return * precision and we should determine it from the precision of the arguments. */ - foreach_in_list(ir_rvalue, param, &ir->actual_parameters) { + ir_foreach_in_list(ir_rvalue, param, &ir->actual_parameters) { if (!check_parameters) break; @@ -605,7 +605,7 @@ find_lowerable_rvalues_visitor::visit_leave(ir_assignment *ir) void find_lowerable_rvalues(const struct gl_shader_compiler_options *options, - exec_list *instructions, + ir_exec_list *instructions, struct set *result) { find_lowerable_rvalues_visitor v(result, options); @@ -909,7 +909,7 @@ find_precision_visitor::map_builtin(ir_function_signature *sig) * lowp. */ if (strcmp(sig->function_name(), "bitCount") != 0) { - foreach_in_list(ir_variable, param, &lowered_sig->parameters) { + ir_foreach_in_list(ir_variable, param, &lowered_sig->parameters) { /* Demote the precision of unqualified function arguments. */ if (param->data.precision == GLSL_PRECISION_NONE) param->data.precision = GLSL_PRECISION_MEDIUM; @@ -1279,7 +1279,7 @@ lower_variables_visitor::visit_enter(ir_call *ir) void *mem_ctx = ralloc_parent(ir); /* We can't pass 16-bit variables as 32-bit inout/out parameters. */ - foreach_two_lists(formal_node, &ir->callee->parameters, + ir_foreach_two_lists(formal_node, &ir->callee->parameters, actual_node, &ir->actual_parameters) { ir_dereference *param_deref = ((ir_rvalue *)actual_node)->as_dereference(); @@ -1349,7 +1349,7 @@ lower_variables_visitor::visit_enter(ir_call *ir) void lower_precision(const struct gl_shader_compiler_options *options, - exec_list *instructions) + ir_exec_list *instructions) { find_precision_visitor v(options); find_lowerable_rvalues(options, instructions, v.lowerable_rvalues); diff --git a/src/compiler/glsl/lower_subroutine.cpp b/src/compiler/glsl/lower_subroutine.cpp index 810ada76ce4..fd0690814ed 100644 --- a/src/compiler/glsl/lower_subroutine.cpp +++ b/src/compiler/glsl/lower_subroutine.cpp @@ -52,7 +52,7 @@ public: } bool -lower_subroutine(exec_list *instructions, struct _mesa_glsl_parse_state *state) +lower_subroutine(ir_exec_list *instructions, struct _mesa_glsl_parse_state *state) { lower_subroutine_visitor v(state); visit_list_elements(&v, instructions); @@ -67,9 +67,9 @@ lower_subroutine_visitor::call_clone(ir_call *call, ir_function_signature *calle if (call->return_deref != NULL) new_return_ref = call->return_deref->clone(mem_ctx, NULL); - exec_list new_parameters; + ir_exec_list new_parameters; - foreach_in_list(ir_instruction, ir, &call->actual_parameters) { + ir_foreach_in_list(ir_instruction, ir, &call->actual_parameters) { new_parameters.push_tail(ir->clone(mem_ctx, NULL)); } diff --git a/src/compiler/glsl/lower_vec_index_to_cond_assign.cpp b/src/compiler/glsl/lower_vec_index_to_cond_assign.cpp index be1334cc493..d47348abdfb 100644 --- a/src/compiler/glsl/lower_vec_index_to_cond_assign.cpp +++ b/src/compiler/glsl/lower_vec_index_to_cond_assign.cpp @@ -142,7 +142,7 @@ ir_vec_index_to_cond_assign_visitor::visit_leave(ir_assignment *ir) ir_visitor_status ir_vec_index_to_cond_assign_visitor::visit_enter(ir_call *ir) { - foreach_in_list_safe(ir_rvalue, param, &ir->actual_parameters) { + ir_foreach_in_list_safe(ir_rvalue, param, &ir->actual_parameters) { ir_rvalue *new_param = convert_vector_extract_to_cond_assign(param); if (new_param != param) { @@ -171,7 +171,7 @@ ir_vec_index_to_cond_assign_visitor::visit_enter(ir_if *ir) } bool -do_vec_index_to_cond_assign(exec_list *instructions) +do_vec_index_to_cond_assign(ir_exec_list *instructions) { ir_vec_index_to_cond_assign_visitor v; diff --git a/src/compiler/glsl/lower_vector_derefs.cpp b/src/compiler/glsl/lower_vector_derefs.cpp index f4b51fe8ede..f7097e595d4 100644 --- a/src/compiler/glsl/lower_vector_derefs.cpp +++ b/src/compiler/glsl/lower_vector_derefs.cpp @@ -47,7 +47,7 @@ public: bool progress; gl_shader_stage shader_stage; - exec_list factory_instructions; + ir_exec_list factory_instructions; ir_factory factory; }; diff --git a/src/compiler/glsl/meson.build b/src/compiler/glsl/meson.build index 34a3db18da4..33bb81bcbe3 100644 --- a/src/compiler/glsl/meson.build +++ b/src/compiler/glsl/meson.build @@ -153,6 +153,7 @@ files_libglsl = files( 'ir_hierarchical_visitor.cpp', 'ir_hierarchical_visitor.h', 'ir_hv_accept.cpp', + 'ir_list.h', 'ir_optimization.h', 'ir_print_visitor.cpp', 'ir_print_visitor.h', diff --git a/src/compiler/glsl/opt_algebraic.cpp b/src/compiler/glsl/opt_algebraic.cpp index 3f13a66bebb..1c9b34d6a3c 100644 --- a/src/compiler/glsl/opt_algebraic.cpp +++ b/src/compiler/glsl/opt_algebraic.cpp @@ -410,7 +410,7 @@ ir_algebraic_visitor::handle_rvalue(ir_rvalue **rvalue) } bool -do_algebraic(exec_list *instructions, bool native_integers, +do_algebraic(ir_exec_list *instructions, bool native_integers, const struct gl_shader_compiler_options *options) { ir_algebraic_visitor v(native_integers, options); diff --git a/src/compiler/glsl/opt_dead_builtin_variables.cpp b/src/compiler/glsl/opt_dead_builtin_variables.cpp index c03c243ac5d..3f9de0062a5 100644 --- a/src/compiler/glsl/opt_dead_builtin_variables.cpp +++ b/src/compiler/glsl/opt_dead_builtin_variables.cpp @@ -33,10 +33,10 @@ * outputs (fragment shader only) that are not used can be removed. */ void -optimize_dead_builtin_variables(exec_list *instructions, +optimize_dead_builtin_variables(ir_exec_list *instructions, enum ir_variable_mode other) { - foreach_in_list_safe(ir_instruction, inst, instructions) { + ir_foreach_in_list_safe(ir_instruction, inst, instructions) { ir_variable *var = inst->as_variable(); if (!var || var->data.used) continue; diff --git a/src/compiler/glsl/opt_dead_code.cpp b/src/compiler/glsl/opt_dead_code.cpp index fa6ec846ee6..bfa802a3460 100644 --- a/src/compiler/glsl/opt_dead_code.cpp +++ b/src/compiler/glsl/opt_dead_code.cpp @@ -43,7 +43,7 @@ static bool debug = false; * for usage on an unlinked instruction stream. */ bool -do_dead_code(exec_list *instructions) +do_dead_code(ir_exec_list *instructions) { ir_variable_refcount_visitor v; bool progress = false; @@ -85,7 +85,7 @@ do_dead_code(exec_list *instructions) while (!entry->assign_list.is_empty()) { struct assignment_entry *assignment_entry = - exec_node_data(struct assignment_entry, + ir_exec_node_data(struct assignment_entry, entry->assign_list.get_head_raw(), link); assignment_entry->assign->remove(); @@ -165,14 +165,14 @@ do_dead_code(exec_list *instructions) * with global scope. */ bool -do_dead_code_unlinked(exec_list *instructions) +do_dead_code_unlinked(ir_exec_list *instructions) { bool progress = false; - foreach_in_list(ir_instruction, ir, instructions) { + ir_foreach_in_list(ir_instruction, ir, instructions) { ir_function *f = ir->as_function(); if (f) { - foreach_in_list(ir_function_signature, sig, &f->signatures) { + ir_foreach_in_list(ir_function_signature, sig, &f->signatures) { if (do_dead_code(&sig->body)) progress = true; } diff --git a/src/compiler/glsl/opt_flatten_nested_if_blocks.cpp b/src/compiler/glsl/opt_flatten_nested_if_blocks.cpp index 66d55ae5c1d..687cb7655f1 100644 --- a/src/compiler/glsl/opt_flatten_nested_if_blocks.cpp +++ b/src/compiler/glsl/opt_flatten_nested_if_blocks.cpp @@ -72,7 +72,7 @@ nested_if_flattener::visit_enter(ir_assignment *ir) } bool -opt_flatten_nested_if_blocks(exec_list *instructions) +opt_flatten_nested_if_blocks(ir_exec_list *instructions) { nested_if_flattener v; diff --git a/src/compiler/glsl/opt_function_inlining.cpp b/src/compiler/glsl/opt_function_inlining.cpp index 1e14aa41729..4ac3a904959 100644 --- a/src/compiler/glsl/opt_function_inlining.cpp +++ b/src/compiler/glsl/opt_function_inlining.cpp @@ -35,7 +35,7 @@ #include "util/hash_table.h" static void -do_variable_replacement(exec_list *instructions, +do_variable_replacement(ir_exec_list *instructions, ir_variable *orig, ir_rvalue *repl); @@ -152,7 +152,7 @@ ir_call::generate_inline(ir_instruction *next_ir) * and set up the mapping of real function body variables to ours. */ i = 0; - foreach_two_lists(formal_node, &this->callee->parameters, + ir_foreach_two_lists(formal_node, &this->callee->parameters, actual_node, &this->actual_parameters) { ir_variable *sig_param = (ir_variable *) formal_node; ir_rvalue *param = (ir_rvalue *) actual_node; @@ -224,10 +224,10 @@ ir_call::generate_inline(ir_instruction *next_ir) ++i; } - exec_list new_instructions; + ir_exec_list new_instructions; /* Generate the inlined body of the function to a new list */ - foreach_in_list(ir_instruction, ir, &callee->body) { + ir_foreach_in_list(ir_instruction, ir, &callee->body) { ir_instruction *new_ir = ir->clone(ctx, ht); new_instructions.push_tail(new_ir); @@ -237,7 +237,7 @@ ir_call::generate_inline(ir_instruction *next_ir) /* If any opaque types were passed in, replace any deref of the * opaque variable with a deref of the argument. */ - foreach_two_lists(formal_node, &this->callee->parameters, + ir_foreach_two_lists(formal_node, &this->callee->parameters, actual_node, &this->actual_parameters) { ir_rvalue *const param = (ir_rvalue *) actual_node; ir_variable *sig_param = (ir_variable *) formal_node; @@ -255,7 +255,7 @@ ir_call::generate_inline(ir_instruction *next_ir) * variables to our own. */ i = 0; - foreach_two_lists(formal_node, &this->callee->parameters, + ir_foreach_two_lists(formal_node, &this->callee->parameters, actual_node, &this->actual_parameters) { ir_rvalue *const param = (ir_rvalue *) actual_node; const ir_variable *const sig_param = (ir_variable *) formal_node; @@ -361,7 +361,7 @@ ir_variable_replacement_visitor::visit_leave(ir_assignment *ir) ir_visitor_status ir_variable_replacement_visitor::visit_leave(ir_call *ir) { - foreach_in_list_safe(ir_rvalue, param, &ir->actual_parameters) { + ir_foreach_in_list_safe(ir_rvalue, param, &ir->actual_parameters) { ir_rvalue *new_param = param; replace_rvalue(&new_param); @@ -373,7 +373,7 @@ ir_variable_replacement_visitor::visit_leave(ir_call *ir) } static void -do_variable_replacement(exec_list *instructions, +do_variable_replacement(ir_exec_list *instructions, ir_variable *orig, ir_rvalue *repl) { diff --git a/src/compiler/glsl/opt_if_simplification.cpp b/src/compiler/glsl/opt_if_simplification.cpp index 136ef877294..1ec0237aa84 100644 --- a/src/compiler/glsl/opt_if_simplification.cpp +++ b/src/compiler/glsl/opt_if_simplification.cpp @@ -59,7 +59,7 @@ ir_if_simplification_visitor::visit_enter(ir_assignment *ir) } bool -do_if_simplification(exec_list *instructions) +do_if_simplification(ir_exec_list *instructions) { ir_if_simplification_visitor v; diff --git a/src/compiler/glsl/opt_minmax.cpp b/src/compiler/glsl/opt_minmax.cpp index 0c4d279c20c..a6825002ef3 100644 --- a/src/compiler/glsl/opt_minmax.cpp +++ b/src/compiler/glsl/opt_minmax.cpp @@ -523,7 +523,7 @@ ir_minmax_visitor::handle_rvalue(ir_rvalue **rvalue) } bool -do_minmax_prune(exec_list *instructions) +do_minmax_prune(ir_exec_list *instructions) { ir_minmax_visitor v; diff --git a/src/compiler/glsl/opt_rebalance_tree.cpp b/src/compiler/glsl/opt_rebalance_tree.cpp index 153aac48364..95900a5e114 100644 --- a/src/compiler/glsl/opt_rebalance_tree.cpp +++ b/src/compiler/glsl/opt_rebalance_tree.cpp @@ -327,7 +327,7 @@ ir_rebalance_visitor::handle_rvalue(ir_rvalue **rvalue) } bool -do_rebalance_tree(exec_list *instructions) +do_rebalance_tree(ir_exec_list *instructions) { ir_rebalance_visitor v; diff --git a/src/compiler/glsl/opt_tree_grafting.cpp b/src/compiler/glsl/opt_tree_grafting.cpp index 6ed8da99d5e..3673ff57bf7 100644 --- a/src/compiler/glsl/opt_tree_grafting.cpp +++ b/src/compiler/glsl/opt_tree_grafting.cpp @@ -203,7 +203,7 @@ ir_tree_grafting_visitor::visit_enter(ir_function_signature *ir) ir_visitor_status ir_tree_grafting_visitor::visit_enter(ir_call *ir) { - foreach_two_lists(formal_node, &ir->callee->parameters, + ir_foreach_two_lists(formal_node, &ir->callee->parameters, actual_node, &ir->actual_parameters) { ir_variable *sig_param = (ir_variable *) formal_node; ir_rvalue *ir = (ir_rvalue *) actual_node; @@ -323,7 +323,7 @@ try_tree_grafting(ir_assignment *start, fprintf(stderr, "\n"); } - for (exec_node *node = start->next; + for (ir_exec_node *node = start->next; node != bb_last->next; node = node->next) { ir_instruction *ir = (ir_instruction *) node; @@ -349,7 +349,7 @@ tree_grafting_basic_block(ir_instruction *bb_first, { struct tree_grafting_info *info = (struct tree_grafting_info *)data; ir_instruction *ir; - exec_node *node, *node_next; + ir_exec_node *node, *node_next; for (node = bb_first, node_next = bb_first->next; node != bb_last->next; @@ -407,7 +407,7 @@ tree_grafting_basic_block(ir_instruction *bb_first, * Does a copy propagation pass on the code present in the instruction stream. */ bool -do_tree_grafting(exec_list *instructions) +do_tree_grafting(ir_exec_list *instructions) { ir_variable_refcount_visitor refs; struct tree_grafting_info info; diff --git a/src/compiler/glsl/propagate_invariance.cpp b/src/compiler/glsl/propagate_invariance.cpp index 2673fa16378..c64615c8d77 100644 --- a/src/compiler/glsl/propagate_invariance.cpp +++ b/src/compiler/glsl/propagate_invariance.cpp @@ -114,7 +114,7 @@ ir_invariance_propagation_visitor::visit(ir_dereference_variable *ir) } bool -propagate_invariance(exec_list *instructions) +propagate_invariance(ir_exec_list *instructions) { ir_invariance_propagation_visitor visitor; bool progress = false; diff --git a/src/compiler/glsl/standalone_scaffolding.cpp b/src/compiler/glsl/standalone_scaffolding.cpp index f1218348d59..b243ed1d329 100644 --- a/src/compiler/glsl/standalone_scaffolding.cpp +++ b/src/compiler/glsl/standalone_scaffolding.cpp @@ -311,7 +311,7 @@ standalone_create_shader_program(void) whole_program->FragDataBindings = new string_to_uint_map; whole_program->FragDataIndexBindings = new string_to_uint_map; - exec_list_make_empty(&whole_program->EmptyUniformLocations); + ir_exec_list_make_empty(&whole_program->EmptyUniformLocations); return whole_program; } diff --git a/src/compiler/glsl/tests/builtin_variable_test.cpp b/src/compiler/glsl/tests/builtin_variable_test.cpp index 1e42840ae45..2e76acff314 100644 --- a/src/compiler/glsl/tests/builtin_variable_test.cpp +++ b/src/compiler/glsl/tests/builtin_variable_test.cpp @@ -51,7 +51,7 @@ public: struct gl_shader *shader; void *mem_ctx; gl_context ctx; - exec_list ir; + ir_exec_list ir; }; void @@ -101,7 +101,7 @@ common_builtin::string_starts_with_prefix(const char *str, const char *prefix) void common_builtin::names_start_with_gl() { - foreach_in_list(ir_instruction, node, &this->ir) { + ir_foreach_in_list(ir_instruction, node, &this->ir) { ir_variable *const var = node->as_variable(); string_starts_with_prefix(var->name, "gl_"); @@ -111,7 +111,7 @@ common_builtin::names_start_with_gl() void common_builtin::uniforms_and_system_values_dont_have_explicit_location() { - foreach_in_list(ir_instruction, node, &this->ir) { + ir_foreach_in_list(ir_instruction, node, &this->ir) { ir_variable *const var = node->as_variable(); if (var->data.mode != ir_var_uniform && var->data.mode != ir_var_system_value) @@ -125,7 +125,7 @@ common_builtin::uniforms_and_system_values_dont_have_explicit_location() void common_builtin::constants_are_constant() { - foreach_in_list(ir_instruction, node, &this->ir) { + ir_foreach_in_list(ir_instruction, node, &this->ir) { ir_variable *const var = node->as_variable(); if (var->data.mode != ir_var_auto) @@ -140,7 +140,7 @@ common_builtin::constants_are_constant() void common_builtin::no_invalid_variable_modes() { - foreach_in_list(ir_instruction, node, &this->ir) { + ir_foreach_in_list(ir_instruction, node, &this->ir) { ir_variable *const var = node->as_variable(); switch (var->data.mode) { @@ -177,7 +177,7 @@ TEST_F(vertex_builtin, names_start_with_gl) TEST_F(vertex_builtin, inputs_have_explicit_location) { - foreach_in_list(ir_instruction, node, &this->ir) { + ir_foreach_in_list(ir_instruction, node, &this->ir) { ir_variable *const var = node->as_variable(); if (var->data.mode != ir_var_shader_in) @@ -192,7 +192,7 @@ TEST_F(vertex_builtin, inputs_have_explicit_location) TEST_F(vertex_builtin, outputs_have_explicit_location) { - foreach_in_list(ir_instruction, node, &this->ir) { + ir_foreach_in_list(ir_instruction, node, &this->ir) { ir_variable *const var = node->as_variable(); if (var->data.mode != ir_var_shader_out) @@ -245,7 +245,7 @@ TEST_F(fragment_builtin, names_start_with_gl) TEST_F(fragment_builtin, inputs_have_explicit_location) { - foreach_in_list(ir_instruction, node, &this->ir) { + ir_foreach_in_list(ir_instruction, node, &this->ir) { ir_variable *const var = node->as_variable(); if (var->data.mode != ir_var_shader_in) @@ -265,7 +265,7 @@ TEST_F(fragment_builtin, inputs_have_explicit_location) TEST_F(fragment_builtin, outputs_have_explicit_location) { - foreach_in_list(ir_instruction, node, &this->ir) { + ir_foreach_in_list(ir_instruction, node, &this->ir) { ir_variable *const var = node->as_variable(); if (var->data.mode != ir_var_shader_out) @@ -316,7 +316,7 @@ TEST_F(geometry_builtin, names_start_with_gl) TEST_F(geometry_builtin, inputs_have_explicit_location) { - foreach_in_list(ir_instruction, node, &this->ir) { + ir_foreach_in_list(ir_instruction, node, &this->ir) { ir_variable *const var = node->as_variable(); if (var->data.mode != ir_var_shader_in) @@ -362,7 +362,7 @@ TEST_F(geometry_builtin, inputs_have_explicit_location) TEST_F(geometry_builtin, outputs_have_explicit_location) { - foreach_in_list(ir_instruction, node, &this->ir) { + ir_foreach_in_list(ir_instruction, node, &this->ir) { ir_variable *const var = node->as_variable(); if (var->data.mode != ir_var_shader_out) diff --git a/src/compiler/glsl/tests/list_iterators.cpp b/src/compiler/glsl/tests/list_iterators.cpp index c21ff2e3314..6d36986db8e 100644 --- a/src/compiler/glsl/tests/list_iterators.cpp +++ b/src/compiler/glsl/tests/list_iterators.cpp @@ -23,9 +23,9 @@ #include -#include "list.h" +#include "ir_list.h" -class test_node_inherite : public exec_node { +class test_node_inherite : public ir_exec_node { public: uint32_t value; @@ -39,7 +39,7 @@ public: void *mem_ctx; - exec_list node_list; + ir_exec_list node_list; }; void @@ -47,19 +47,19 @@ list_iterators_node_inherite::SetUp() { mem_ctx = ralloc_context(NULL); - exec_list_make_empty(&node_list); + ir_exec_list_make_empty(&node_list); for (size_t i = 0; i < GetParam(); i++) { test_node_inherite *node = new(mem_ctx) test_node_inherite(); node->value = i; - exec_list_push_tail(&node_list, node); + ir_exec_list_push_tail(&node_list, node); } } void list_iterators_node_inherite::TearDown() { - exec_list_make_empty(&node_list); + ir_exec_list_make_empty(&node_list); ralloc_free(mem_ctx); mem_ctx = NULL; @@ -74,7 +74,7 @@ INSTANTIATE_TEST_SUITE_P( TEST_P(list_iterators_node_inherite, foreach_in_list) { size_t i = 0; - foreach_in_list(test_node_inherite, n, &node_list) { + ir_foreach_in_list(test_node_inherite, n, &node_list) { EXPECT_EQ(n->value, i); i++; } @@ -83,7 +83,7 @@ TEST_P(list_iterators_node_inherite, foreach_in_list) TEST_P(list_iterators_node_inherite, foreach_in_list_reverse) { size_t i = GetParam() - 1; - foreach_in_list_reverse(test_node_inherite, n, &node_list) { + ir_foreach_in_list_reverse(test_node_inherite, n, &node_list) { EXPECT_EQ(n->value, i); i--; } @@ -92,7 +92,7 @@ TEST_P(list_iterators_node_inherite, foreach_in_list_reverse) TEST_P(list_iterators_node_inherite, foreach_in_list_safe) { size_t i = 0; - foreach_in_list_safe(test_node_inherite, n, &node_list) { + ir_foreach_in_list_safe(test_node_inherite, n, &node_list) { EXPECT_EQ(n->value, i); if (i % 2 == 0) { @@ -102,13 +102,13 @@ TEST_P(list_iterators_node_inherite, foreach_in_list_safe) i++; } - exec_list_validate(&node_list); + ir_exec_list_validate(&node_list); } TEST_P(list_iterators_node_inherite, foreach_in_list_reverse_safe) { size_t i = GetParam() - 1; - foreach_in_list_reverse_safe(test_node_inherite, n, &node_list) { + ir_foreach_in_list_reverse_safe(test_node_inherite, n, &node_list) { EXPECT_EQ(n->value, i); if (i % 2 == 0) { @@ -118,13 +118,13 @@ TEST_P(list_iterators_node_inherite, foreach_in_list_reverse_safe) i--; } - exec_list_validate(&node_list); + ir_exec_list_validate(&node_list); } TEST_P(list_iterators_node_inherite, foreach_in_list_use_after) { size_t i = 0; - foreach_in_list_use_after(test_node_inherite, n, &node_list) { + ir_foreach_in_list_use_after(test_node_inherite, n, &node_list) { EXPECT_EQ(n->value, i); if (i == GetParam() / 2) { @@ -144,7 +144,7 @@ class test_node_embed { public: uint32_t value_header; - exec_node node; + ir_exec_node node; uint32_t value_footer; virtual ~test_node_embed() = default; @@ -157,7 +157,7 @@ public: void *mem_ctx; - exec_list node_list; + ir_exec_list node_list; }; void @@ -165,20 +165,20 @@ list_iterators_node_embed::SetUp() { mem_ctx = ralloc_context(NULL); - exec_list_make_empty(&node_list); + ir_exec_list_make_empty(&node_list); for (size_t i = 0; i < GetParam(); i++) { test_node_embed *node = new(mem_ctx) test_node_embed(); node->value_header = i; node->value_footer = i; - exec_list_push_tail(&node_list, &node->node); + ir_exec_list_push_tail(&node_list, &node->node); } } void list_iterators_node_embed::TearDown() { - exec_list_make_empty(&node_list); + ir_exec_list_make_empty(&node_list); ralloc_free(mem_ctx); mem_ctx = NULL; @@ -193,7 +193,7 @@ INSTANTIATE_TEST_SUITE_P( TEST_P(list_iterators_node_embed, foreach_list_typed) { size_t i = 0; - foreach_list_typed(test_node_embed, n, node, &node_list) { + ir_foreach_list_typed(test_node_embed, n, node, &node_list) { EXPECT_EQ(n->value_header, i); EXPECT_EQ(n->value_footer, i); i++; @@ -206,14 +206,14 @@ TEST_P(list_iterators_node_embed, foreach_list_typed_from) return; } - exec_node *start_node = node_list.get_head(); + ir_exec_node *start_node = node_list.get_head(); size_t i = 0; for (; i < GetParam() / 2; i++) { start_node = start_node->get_next(); } - foreach_list_typed_from(test_node_embed, n, node, &node_list, start_node) { + ir_foreach_list_typed_from(test_node_embed, n, node, &node_list, start_node) { EXPECT_EQ(n->value_header, i); EXPECT_EQ(n->value_footer, i); i++; @@ -223,7 +223,7 @@ TEST_P(list_iterators_node_embed, foreach_list_typed_from) TEST_P(list_iterators_node_embed, foreach_list_typed_reverse) { size_t i = GetParam() - 1; - foreach_list_typed_reverse(test_node_embed, n, node, &node_list) { + ir_foreach_list_typed_reverse(test_node_embed, n, node, &node_list) { EXPECT_EQ(n->value_header, i); EXPECT_EQ(n->value_footer, i); i--; @@ -233,33 +233,33 @@ TEST_P(list_iterators_node_embed, foreach_list_typed_reverse) TEST_P(list_iterators_node_embed, foreach_list_typed_safe) { size_t i = 0; - foreach_list_typed_safe(test_node_embed, n, node, &node_list) { + ir_foreach_list_typed_safe(test_node_embed, n, node, &node_list) { EXPECT_EQ(n->value_header, i); EXPECT_EQ(n->value_footer, i); if (i % 2 == 0) { - exec_node_remove(&n->node); + ir_exec_node_remove(&n->node); } i++; } - exec_list_validate(&node_list); + ir_exec_list_validate(&node_list); } TEST_P(list_iterators_node_embed, foreach_list_typed_reverse_safe) { size_t i = GetParam() - 1; - foreach_list_typed_reverse_safe(test_node_embed, n, node, &node_list) { + ir_foreach_list_typed_reverse_safe(test_node_embed, n, node, &node_list) { EXPECT_EQ(n->value_header, i); EXPECT_EQ(n->value_footer, i); if (i % 2 == 0) { - exec_node_remove(&n->node); + ir_exec_node_remove(&n->node); } i--; } - exec_list_validate(&node_list); + ir_exec_list_validate(&node_list); } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 058df583acd..73709ca0fd7 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -50,7 +50,6 @@ #include "compiler/shader_enums.h" #include "compiler/shader_info.h" #include "main/formats.h" /* MESA_FORMAT_COUNT */ -#include "compiler/glsl/list.h" #include "util/u_idalloc.h" #include "util/simple_mtx.h" #include "util/u_dynarray.h" diff --git a/src/mesa/main/shader_types.h b/src/mesa/main/shader_types.h index 0e27dc7dac0..ba684677ba4 100644 --- a/src/mesa/main/shader_types.h +++ b/src/mesa/main/shader_types.h @@ -39,6 +39,7 @@ #include "util/mesa-blake3.h" #include "compiler/shader_info.h" #include "compiler/glsl/list.h" +#include "compiler/glsl/ir_list.h" #include "pipe/p_state.h" @@ -187,7 +188,7 @@ struct gl_shader GLbitfield BlendSupport; struct nir_shader *nir; - struct exec_list *ir; + struct ir_exec_list *ir; /** * Whether early fragment tests are enabled as defined by @@ -445,7 +446,7 @@ struct gl_shader_program * allocate slots to explicit locations. This list stores the blocks of * continuous empty slots inside UniformRemapTable. */ - struct exec_list EmptyUniformLocations; + struct ir_exec_list EmptyUniformLocations; /** * Total number of explicit uniform location including inactive uniforms. diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c index 0d5a66e992a..a51c4efdd9c 100644 --- a/src/mesa/main/shaderobj.c +++ b/src/mesa/main/shaderobj.c @@ -292,7 +292,7 @@ init_shader_program(struct gl_shader_program *prog) prog->TransformFeedback.BufferMode = GL_INTERLEAVED_ATTRIBS; - exec_list_make_empty(&prog->EmptyUniformLocations); + ir_exec_list_make_empty(&prog->EmptyUniformLocations); } /**