glsl2: Use _mesa_glsl_parse_state as the talloc parent, not glsl_shader.
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 25 Jun 2010 20:14:37 +0000 (13:14 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 30 Jun 2010 20:52:24 +0000 (13:52 -0700)
_mesa_glsl_parse_state should be the parent for all temporary allocation
done while compiling a shader.  glsl_shader should only be used as the
parent for the shader's final IR---the _result_ of compilation.

Since many IR instructions may be added or discarded during optimization
passes, IR should not ever be allocated to glsl_shader directly.

Done via sed -i s/talloc_parent(state)/state/g and s/talloc_parent(st)/st/g.

This also removes a ton of talloc_parent calls, which may help performance.

src/glsl/ast_function.cpp
src/glsl/ast_to_hir.cpp
src/glsl/glsl_lexer.lpp
src/glsl/glsl_parser.ypp
src/glsl/hir_field_selection.cpp
src/glsl/ir_reader.cpp

index f3074a362d7b82314f34009615f223ee9fb043ae..b68111538798245e3b4e52ca78c62160d314b67d 100644 (file)
@@ -59,7 +59,7 @@ process_call(exec_list *instructions, ir_function *f,
             YYLTYPE *loc, exec_list *actual_parameters,
             struct _mesa_glsl_parse_state *state)
 {
-   void *ctx = talloc_parent(state);
+   void *ctx = state;
 
    const ir_function_signature *sig =
       f->matching_signature(actual_parameters);
@@ -119,7 +119,7 @@ match_function_by_name(exec_list *instructions, const char *name,
                       YYLTYPE *loc, exec_list *actual_parameters,
                       struct _mesa_glsl_parse_state *state)
 {
-   void *ctx = talloc_parent(state);
+   void *ctx = state;
    ir_function *f = state->symbols->get_function(name);
 
    if (f == NULL) {
@@ -244,7 +244,7 @@ process_array_constructor(exec_list *instructions,
                          YYLTYPE *loc, exec_list *parameters,
                          struct _mesa_glsl_parse_state *state)
 {
-   void *ctx = talloc_parent(state);
+   void *ctx = state;
    /* Array constructors come in two forms: sized and unsized.  Sized array
     * constructors look like 'vec4[2](a, b)', where 'a' and 'b' are vec4
     * variables.  In this case the number of parameters must exactly match the
@@ -318,7 +318,7 @@ constant_record_constructor(const glsl_type *constructor_type,
                            YYLTYPE *loc, exec_list *parameters,
                            struct _mesa_glsl_parse_state *state)
 {
-   void *ctx = talloc_parent(state);
+   void *ctx = state;
    bool all_parameters_are_constant = true;
 
    exec_node *node = parameters->head;
@@ -862,7 +862,7 @@ ir_rvalue *
 ast_function_expression::hir(exec_list *instructions,
                             struct _mesa_glsl_parse_state *state)
 {
-   void *ctx = talloc_parent(state);
+   void *ctx = state;
    /* There are three sorts of function calls.
     *
     * 1. contstructors - The first subexpression is an ast_type_specifier.
index ba292400925cb0c06c6d45cd86bb2b1d5f31225b..53f17de7b95071a0dec1dafcbef23e0371b0e328 100644 (file)
@@ -86,7 +86,7 @@ static bool
 apply_implicit_conversion(const glsl_type *to, ir_rvalue * &from,
                          struct _mesa_glsl_parse_state *state)
 {
-   void *ctx = talloc_parent(state);
+   void *ctx = state;
    if (to->base_type == from->type->base_type)
       return true;
 
@@ -473,7 +473,7 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state,
              ir_rvalue *lhs, ir_rvalue *rhs,
              YYLTYPE lhs_loc)
 {
-   void *ctx = talloc_parent(state);
+   void *ctx = state;
    bool error_emitted = (lhs->type->is_error() || rhs->type->is_error());
 
    if (!error_emitted) {
@@ -550,7 +550,7 @@ static ir_variable *
 generate_temporary(const glsl_type *type, exec_list *instructions,
                   struct _mesa_glsl_parse_state *state)
 {
-   void *ctx = talloc_parent(state);
+   void *ctx = state;
    char *name = (char *) malloc(sizeof(char) * 13);
 
    snprintf(name, 13, "tmp_%08X", state->temp_index);
@@ -600,7 +600,7 @@ ir_rvalue *
 ast_expression::hir(exec_list *instructions,
                    struct _mesa_glsl_parse_state *state)
 {
-   void *ctx = talloc_parent(state);
+   void *ctx = state;
    static const int operations[AST_NUM_OPERATORS] = {
       -1,               /* ast_assign doesn't convert to ir_expression. */
       -1,               /* ast_plus doesn't convert to ir_expression. */
@@ -1544,7 +1544,7 @@ ir_rvalue *
 ast_declarator_list::hir(exec_list *instructions,
                         struct _mesa_glsl_parse_state *state)
 {
-   void *ctx = talloc_parent(state);
+   void *ctx = state;
    const struct glsl_type *decl_type;
    const char *type_name = NULL;
    ir_rvalue *result = NULL;
@@ -1883,7 +1883,7 @@ ir_rvalue *
 ast_parameter_declarator::hir(exec_list *instructions,
                              struct _mesa_glsl_parse_state *state)
 {
-   void *ctx = talloc_parent(state);
+   void *ctx = state;
    const struct glsl_type *type;
    const char *name = NULL;
    YYLTYPE loc = this->get_location();
@@ -1984,7 +1984,7 @@ ir_rvalue *
 ast_function::hir(exec_list *instructions,
                  struct _mesa_glsl_parse_state *state)
 {
-   void *ctx = talloc_parent(state);
+   void *ctx = state;
    ir_function *f = NULL;
    ir_function_signature *sig = NULL;
    exec_list hir_parameters;
@@ -2152,7 +2152,7 @@ ir_rvalue *
 ast_jump_statement::hir(exec_list *instructions,
                        struct _mesa_glsl_parse_state *state)
 {
-   void *ctx = talloc_parent(state);
+   void *ctx = state;
 
    switch (mode) {
    case ast_return: {
@@ -2255,7 +2255,7 @@ ir_rvalue *
 ast_selection_statement::hir(exec_list *instructions,
                             struct _mesa_glsl_parse_state *state)
 {
-   void *ctx = talloc_parent(state);
+   void *ctx = state;
 
    ir_rvalue *const condition = this->condition->hir(instructions, state);
 
@@ -2295,7 +2295,7 @@ void
 ast_iteration_statement::condition_to_hir(ir_loop *stmt,
                                          struct _mesa_glsl_parse_state *state)
 {
-   void *ctx = talloc_parent(state);
+   void *ctx = state;
 
    if (condition != NULL) {
       ir_rvalue *const cond =
@@ -2331,7 +2331,7 @@ ir_rvalue *
 ast_iteration_statement::hir(exec_list *instructions,
                             struct _mesa_glsl_parse_state *state)
 {
-   void *ctx = talloc_parent(state);
+   void *ctx = state;
 
    /* For-loops and while-loops start a new scope, but do-while loops do not.
     */
index fa439f1278785a146f0493c8c08c21edfe569358..f236a156820dc0c197411310e1758858511ec6ad 100644 (file)
@@ -313,7 +313,7 @@ precision   return PRECISION;
 
 [_a-zA-Z][_a-zA-Z0-9]* {
                            struct _mesa_glsl_parse_state *state = yyextra;
-                           void *ctx = talloc_parent(state);   
+                           void *ctx = state;  
                            yylval->identifier = talloc_strdup(ctx, yytext);
                            return IDENTIFIER;
                        }
index 4132495f403fbedfedf4af47848ade8e043f272d..d894a968ec21c870dfcc050824ec35a00184b212 100644 (file)
@@ -255,35 +255,35 @@ variable_identifier:
 primary_expression:
        variable_identifier
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression(ast_identifier, NULL, NULL, NULL);
           $$->set_location(yylloc);
           $$->primary_expression.identifier = $1;
        }
        | INTCONSTANT
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression(ast_int_constant, NULL, NULL, NULL);
           $$->set_location(yylloc);
           $$->primary_expression.int_constant = $1;
        }
        | UINTCONSTANT
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression(ast_uint_constant, NULL, NULL, NULL);
           $$->set_location(yylloc);
           $$->primary_expression.uint_constant = $1;
        }
        | FLOATCONSTANT
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression(ast_float_constant, NULL, NULL, NULL);
           $$->set_location(yylloc);
           $$->primary_expression.float_constant = $1;
        }
        | BOOLCONSTANT
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression(ast_bool_constant, NULL, NULL, NULL);
           $$->set_location(yylloc);
           $$->primary_expression.bool_constant = $1;
@@ -298,7 +298,7 @@ postfix_expression:
        primary_expression
        | postfix_expression '[' integer_expression ']'
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression(ast_array_index, $1, $3, NULL);
           $$->set_location(yylloc);
        }
@@ -314,20 +314,20 @@ postfix_expression:
        }
        | postfix_expression '.' IDENTIFIER
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression(ast_field_selection, $1, NULL, NULL);
           $$->set_location(yylloc);
           $$->primary_expression.identifier = $3;
        }
        | postfix_expression INC_OP
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression(ast_post_inc, $1, NULL, NULL);
           $$->set_location(yylloc);
        }
        | postfix_expression DEC_OP
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression(ast_post_dec, $1, NULL, NULL);
           $$->set_location(yylloc);
        }
@@ -345,7 +345,7 @@ function_call_or_method:
        function_call_generic
        | postfix_expression '.' function_call_generic
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression(ast_field_selection, $1, $3, NULL);
           $$->set_location(yylloc);
        }
@@ -386,20 +386,20 @@ function_call_header:
 function_identifier:
        type_specifier
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_function_expression($1);
           $$->set_location(yylloc);
        }
        | IDENTIFIER
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           ast_expression *callee = new(ctx) ast_expression($1);
           $$ = new(ctx) ast_function_expression(callee);
           $$->set_location(yylloc);
        }
        | FIELD_SELECTION
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           ast_expression *callee = new(ctx) ast_expression($1);
           $$ = new(ctx) ast_function_expression(callee);
           $$->set_location(yylloc);
@@ -411,19 +411,19 @@ unary_expression:
        postfix_expression
        | INC_OP unary_expression
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression(ast_pre_inc, $2, NULL, NULL);
           $$->set_location(yylloc);
        }
        | DEC_OP unary_expression
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression(ast_pre_dec, $2, NULL, NULL);
           $$->set_location(yylloc);
        }
        | unary_operator unary_expression
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression($1, $2, NULL, NULL);
           $$->set_location(yylloc);
        }
@@ -441,19 +441,19 @@ multiplicative_expression:
        unary_expression
        | multiplicative_expression '*' unary_expression
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression_bin(ast_mul, $1, $3);
           $$->set_location(yylloc);
        }
        | multiplicative_expression '/' unary_expression
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression_bin(ast_div, $1, $3);
           $$->set_location(yylloc);
        }
        | multiplicative_expression '%' unary_expression
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression_bin(ast_mod, $1, $3);
           $$->set_location(yylloc);
        }
@@ -463,13 +463,13 @@ additive_expression:
        multiplicative_expression
        | additive_expression '+' multiplicative_expression
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression_bin(ast_add, $1, $3);
           $$->set_location(yylloc);
        }
        | additive_expression '-' multiplicative_expression
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression_bin(ast_sub, $1, $3);
           $$->set_location(yylloc);
        }
@@ -479,13 +479,13 @@ shift_expression:
        additive_expression
        | shift_expression LEFT_OP additive_expression
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression_bin(ast_lshift, $1, $3);
           $$->set_location(yylloc);
        }
        | shift_expression RIGHT_OP additive_expression
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression_bin(ast_rshift, $1, $3);
           $$->set_location(yylloc);
        }
@@ -495,25 +495,25 @@ relational_expression:
        shift_expression
        | relational_expression '<' shift_expression
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression_bin(ast_less, $1, $3);
           $$->set_location(yylloc);
        }
        | relational_expression '>' shift_expression
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression_bin(ast_greater, $1, $3);
           $$->set_location(yylloc);
        }
        | relational_expression LE_OP shift_expression
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression_bin(ast_lequal, $1, $3);
           $$->set_location(yylloc);
        }
        | relational_expression GE_OP shift_expression
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression_bin(ast_gequal, $1, $3);
           $$->set_location(yylloc);
        }
@@ -523,13 +523,13 @@ equality_expression:
        relational_expression
        | equality_expression EQ_OP relational_expression
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression_bin(ast_equal, $1, $3);
           $$->set_location(yylloc);
        }
        | equality_expression NE_OP relational_expression
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression_bin(ast_nequal, $1, $3);
           $$->set_location(yylloc);
        }
@@ -539,7 +539,7 @@ and_expression:
        equality_expression
        | and_expression '&' equality_expression
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression_bin(ast_bit_or, $1, $3);
           $$->set_location(yylloc);
        }
@@ -549,7 +549,7 @@ exclusive_or_expression:
        and_expression
        | exclusive_or_expression '^' and_expression
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression_bin(ast_bit_xor, $1, $3);
           $$->set_location(yylloc);
        }
@@ -559,7 +559,7 @@ inclusive_or_expression:
        exclusive_or_expression
        | inclusive_or_expression '|' exclusive_or_expression
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression_bin(ast_bit_or, $1, $3);
           $$->set_location(yylloc);
        }
@@ -569,7 +569,7 @@ logical_and_expression:
        inclusive_or_expression
        | logical_and_expression AND_OP inclusive_or_expression
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression_bin(ast_logic_and, $1, $3);
           $$->set_location(yylloc);
        }
@@ -579,7 +579,7 @@ logical_xor_expression:
        logical_and_expression
        | logical_xor_expression XOR_OP logical_and_expression
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression_bin(ast_logic_xor, $1, $3);
           $$->set_location(yylloc);
        }
@@ -589,7 +589,7 @@ logical_or_expression:
        logical_xor_expression
        | logical_or_expression OR_OP logical_xor_expression
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression_bin(ast_logic_or, $1, $3);
           $$->set_location(yylloc);
        }
@@ -599,7 +599,7 @@ conditional_expression:
        logical_or_expression
        | logical_or_expression '?' expression ':' assignment_expression
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression(ast_conditional, $1, $3, $5);
           $$->set_location(yylloc);
        }
@@ -609,7 +609,7 @@ assignment_expression:
        conditional_expression
        | unary_expression assignment_operator assignment_expression
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression($2, $1, $3, NULL);
           $$->set_location(yylloc);
        }
@@ -636,7 +636,7 @@ expression:
        }
        | expression ',' assignment_expression
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           if ($1->oper != ast_sequence) {
              $$ = new(ctx) ast_expression(ast_sequence, NULL, NULL, NULL);
              $$->set_location(yylloc);
@@ -700,7 +700,7 @@ function_header_with_parameters:
 function_header:
        fully_specified_type IDENTIFIER '('
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_function();
           $$->set_location(yylloc);
           $$->return_type = $1;
@@ -711,7 +711,7 @@ function_header:
 parameter_declarator:
        type_specifier IDENTIFIER
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_parameter_declarator();
           $$->set_location(yylloc);
           $$->type = new(ctx) ast_fully_specified_type();
@@ -721,7 +721,7 @@ parameter_declarator:
        }
        | type_specifier IDENTIFIER '[' constant_expression ']'
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_parameter_declarator();
           $$->set_location(yylloc);
           $$->type = new(ctx) ast_fully_specified_type();
@@ -748,7 +748,7 @@ parameter_declaration:
        }
        | parameter_type_qualifier parameter_qualifier parameter_type_specifier
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $1.i |= $2.i;
 
           $$ = new(ctx) ast_parameter_declarator();
@@ -759,7 +759,7 @@ parameter_declaration:
        }
        | parameter_qualifier parameter_type_specifier
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_parameter_declarator();
           $$->set_location(yylloc);
           $$->type = new(ctx) ast_fully_specified_type();
@@ -783,7 +783,7 @@ init_declarator_list:
        single_declaration
        | init_declarator_list ',' IDENTIFIER
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, NULL);
           decl->set_location(yylloc);
 
@@ -792,7 +792,7 @@ init_declarator_list:
        }
        | init_declarator_list ',' IDENTIFIER '[' ']'
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, NULL);
           decl->set_location(yylloc);
 
@@ -801,7 +801,7 @@ init_declarator_list:
        }
        | init_declarator_list ',' IDENTIFIER '[' constant_expression ']'
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, NULL);
           decl->set_location(yylloc);
 
@@ -810,7 +810,7 @@ init_declarator_list:
        }
        | init_declarator_list ',' IDENTIFIER '[' ']' '=' initializer
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, $7);
           decl->set_location(yylloc);
 
@@ -819,7 +819,7 @@ init_declarator_list:
        }
        | init_declarator_list ',' IDENTIFIER '[' constant_expression ']' '=' initializer
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, $8);
           decl->set_location(yylloc);
 
@@ -828,7 +828,7 @@ init_declarator_list:
        }
        | init_declarator_list ',' IDENTIFIER '=' initializer
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, $5);
           decl->set_location(yylloc);
 
@@ -841,7 +841,7 @@ init_declarator_list:
 single_declaration:
        fully_specified_type
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           if ($1->specifier->type_specifier != ast_struct) {
              _mesa_glsl_error(& @1, state, "empty declaration list\n");
              YYERROR;
@@ -852,7 +852,7 @@ single_declaration:
        }
        | fully_specified_type IDENTIFIER
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL);
 
           $$ = new(ctx) ast_declarator_list($1);
@@ -861,7 +861,7 @@ single_declaration:
        }
        | fully_specified_type IDENTIFIER '[' ']'
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, NULL);
 
           $$ = new(ctx) ast_declarator_list($1);
@@ -870,7 +870,7 @@ single_declaration:
        }
        | fully_specified_type IDENTIFIER '[' constant_expression ']'
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, NULL);
 
           $$ = new(ctx) ast_declarator_list($1);
@@ -879,7 +879,7 @@ single_declaration:
        }
        | fully_specified_type IDENTIFIER '[' ']' '=' initializer
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, $6);
 
           $$ = new(ctx) ast_declarator_list($1);
@@ -888,7 +888,7 @@ single_declaration:
        }
        | fully_specified_type IDENTIFIER '[' constant_expression ']' '=' initializer
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, $7);
 
           $$ = new(ctx) ast_declarator_list($1);
@@ -897,7 +897,7 @@ single_declaration:
        }
        | fully_specified_type IDENTIFIER '=' initializer
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4);
 
           $$ = new(ctx) ast_declarator_list($1);
@@ -906,7 +906,7 @@ single_declaration:
        }
        | INVARIANT IDENTIFIER // Vertex only.
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL);
 
           $$ = new(ctx) ast_declarator_list(NULL);
@@ -920,14 +920,14 @@ single_declaration:
 fully_specified_type:
        type_specifier
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_fully_specified_type();
           $$->set_location(yylloc);
           $$->specifier = $1;
        }
        | type_qualifier type_specifier
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_fully_specified_type();
           $$->set_location(yylloc);
           $$->qualifier = $1.q;
@@ -998,19 +998,19 @@ type_specifier_no_prec:
 type_specifier_nonarray:
        basic_type_specifier_nonarray
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_type_specifier($1);
           $$->set_location(yylloc);
        }
        | struct_specifier
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_type_specifier($1);
           $$->set_location(yylloc);
        }
        | IDENTIFIER
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_type_specifier($1);
           $$->set_location(yylloc);
        }
@@ -1112,13 +1112,13 @@ precision_qualifier:
 struct_specifier:
        STRUCT IDENTIFIER '{' struct_declaration_list '}'
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_struct_specifier($2, $4);
           $$->set_location(yylloc);
        }
        | STRUCT '{' struct_declaration_list '}'
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_struct_specifier(NULL, $3);
           $$->set_location(yylloc);
        }
@@ -1140,7 +1140,7 @@ struct_declaration_list:
 struct_declaration:
        type_specifier struct_declarator_list ';'
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           ast_fully_specified_type *type = new(ctx) ast_fully_specified_type();
           type->set_location(yylloc);
 
@@ -1168,13 +1168,13 @@ struct_declarator_list:
 struct_declarator:
        IDENTIFIER
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_declaration($1, false, NULL, NULL);
           $$->set_location(yylloc);
        }
        | IDENTIFIER '[' constant_expression ']'
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_declaration($1, true, $3, NULL);
           $$->set_location(yylloc);
        }
@@ -1217,13 +1217,13 @@ simple_statement:
 compound_statement:
        '{' '}'
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_compound_statement(true, NULL);
           $$->set_location(yylloc);
        }
        | '{' statement_list '}'
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_compound_statement(true, $2);
           $$->set_location(yylloc);
        }
@@ -1237,13 +1237,13 @@ statement_no_new_scope:
 compound_statement_no_new_scope:
        '{' '}'
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_compound_statement(false, NULL);
           $$->set_location(yylloc);
        }
        | '{' statement_list '}'
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_compound_statement(false, $2);
           $$->set_location(yylloc);
        }
@@ -1274,13 +1274,13 @@ statement_list:
 expression_statement:
        ';'
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression_statement(NULL);
           $$->set_location(yylloc);
        }
        | expression ';'
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_expression_statement($1);
           $$->set_location(yylloc);
        }
@@ -1289,7 +1289,7 @@ expression_statement:
 selection_statement_matched:
        IF '(' expression ')' statement_matched ELSE statement_matched
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_selection_statement($3, $5, $7);
           $$->set_location(yylloc);
        }
@@ -1298,19 +1298,19 @@ selection_statement_matched:
 selection_statement_unmatched:
        IF '(' expression ')' statement_matched
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_selection_statement($3, $5, NULL);
           $$->set_location(yylloc);
        }
        | IF '(' expression ')' statement_unmatched
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_selection_statement($3, $5, NULL);
           $$->set_location(yylloc);
        }
        | IF '(' expression ')' statement_matched ELSE statement_unmatched
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_selection_statement($3, $5, $7);
           $$->set_location(yylloc);
        }
@@ -1323,7 +1323,7 @@ condition:
        }
        | fully_specified_type IDENTIFIER '=' initializer
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4);
           ast_declarator_list *declarator = new(ctx) ast_declarator_list($1);
           decl->set_location(yylloc);
@@ -1346,21 +1346,21 @@ case_label:
 iteration_statement:
        WHILE '(' condition ')' statement_no_new_scope
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_while,
                                                    NULL, $3, NULL, $5);
           $$->set_location(yylloc);
        }
        | DO statement WHILE '(' expression ')' ';'
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while,
                                                    NULL, $5, NULL, $2);
           $$->set_location(yylloc);
        }
        | FOR '(' for_init_statement for_rest_statement ')' statement_no_new_scope
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_for,
                                                    $3, $4.cond, $4.rest, $6);
           $$->set_location(yylloc);
@@ -1397,31 +1397,31 @@ for_rest_statement:
 jump_statement:
        CONTINUE ';' 
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_continue, NULL);
           $$->set_location(yylloc);
        }
        | BREAK ';'
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_break, NULL);
           $$->set_location(yylloc);
        }
        | RETURN ';'
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, NULL);
           $$->set_location(yylloc);
        }
        | RETURN expression ';'
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, $2);
           $$->set_location(yylloc);
        }
        | DISCARD ';' // Fragment shader only.
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_discard, NULL);
           $$->set_location(yylloc);
        }
@@ -1435,7 +1435,7 @@ external_declaration:
 function_definition:
        function_prototype compound_statement_no_new_scope
        {
-          void *ctx = talloc_parent(state);
+          void *ctx = state;
           $$ = new(ctx) ast_function_definition();
           $$->set_location(yylloc);
           $$->prototype = $1;
index e2efff60d3434027ee85889832dc9d745271653d..5500e09d7e61b77da21c41d2e61944552837baed 100644 (file)
@@ -33,7 +33,7 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr,
                                 exec_list *instructions,
                                 struct _mesa_glsl_parse_state *state)
 {
-   void *ctx = talloc_parent(state);
+   void *ctx = state;
    ir_rvalue *result = NULL;
    ir_rvalue *op;
 
index 03dce0d6849541a9ee9eb2bf0fc9b1404a98af5f..5ba76e29ea003a8ddc5399d5173f29958edd8e4b 100644 (file)
@@ -191,7 +191,7 @@ scan_for_prototypes(_mesa_glsl_parse_state *st, exec_list *instructions,
 static ir_function *
 read_function(_mesa_glsl_parse_state *st, s_list *list, bool skip_body)
 {
-   void *ctx = talloc_parent(st);
+   void *ctx = st;
    if (list->length() < 3) {
       ir_read_error(st, list, "Expected (function <name> (signature ...) ...)");
       return NULL;
@@ -235,7 +235,7 @@ static void
 read_function_sig(_mesa_glsl_parse_state *st, ir_function *f, s_list *list,
                  bool skip_body)
 {
-   void *ctx = talloc_parent(st);
+   void *ctx = st;
    if (list->length() != 4) {
       ir_read_error(st, list, "Expected (signature <type> (parameters ...) "
                              "(<instruction> ...))");
@@ -334,7 +334,7 @@ static ir_instruction *
 read_instruction(_mesa_glsl_parse_state *st, s_expression *expr,
                 ir_loop *loop_ctx)
 {
-   void *ctx = talloc_parent(st);
+   void *ctx = st;
    s_symbol *symbol = SX_AS_SYMBOL(expr);
    if (symbol != NULL) {
       if (strcmp(symbol->value(), "break") == 0 && loop_ctx != NULL)
@@ -376,7 +376,7 @@ read_instruction(_mesa_glsl_parse_state *st, s_expression *expr,
 static ir_variable *
 read_declaration(_mesa_glsl_parse_state *st, s_list *list)
 {
-   void *ctx = talloc_parent(st);
+   void *ctx = st;
    if (list->length() != 4) {
       ir_read_error(st, list, "expected (declare (<qualifiers>) <type> "
                              "<name>)");
@@ -448,7 +448,7 @@ read_declaration(_mesa_glsl_parse_state *st, s_list *list)
 static ir_if *
 read_if(_mesa_glsl_parse_state *st, s_list *list, ir_loop *loop_ctx)
 {
-   void *ctx = talloc_parent(st);
+   void *ctx = st;
    if (list->length() != 4) {
       ir_read_error(st, list, "expected (if <condition> (<then> ...) "
                           "(<else> ...))");
@@ -480,7 +480,7 @@ read_if(_mesa_glsl_parse_state *st, s_list *list, ir_loop *loop_ctx)
 static ir_loop *
 read_loop(_mesa_glsl_parse_state *st, s_list *list)
 {
-   void *ctx = talloc_parent(st);
+   void *ctx = st;
    if (list->length() != 6) {
       ir_read_error(st, list, "expected (loop <counter> <from> <to> "
                              "<increment> <body>)");
@@ -508,7 +508,7 @@ read_loop(_mesa_glsl_parse_state *st, s_list *list)
 static ir_return *
 read_return(_mesa_glsl_parse_state *st, s_list *list)
 {
-   void *ctx = talloc_parent(st);
+   void *ctx = st;
    if (list->length() != 2) {
       ir_read_error(st, list, "expected (return <rvalue>)");
       return NULL;
@@ -564,7 +564,7 @@ read_rvalue(_mesa_glsl_parse_state *st, s_expression *expr)
 static ir_assignment *
 read_assignment(_mesa_glsl_parse_state *st, s_list *list)
 {
-   void *ctx = talloc_parent(st);
+   void *ctx = st;
    if (list->length() != 4) {
       ir_read_error(st, list, "expected (assign <condition> <lhs> <rhs>)");
       return NULL;
@@ -599,7 +599,7 @@ read_assignment(_mesa_glsl_parse_state *st, s_list *list)
 static ir_call *
 read_call(_mesa_glsl_parse_state *st, s_list *list)
 {
-   void *ctx = talloc_parent(st);
+   void *ctx = st;
    if (list->length() != 3) {
       ir_read_error(st, list, "expected (call <name> (<param> ...))");
       return NULL;
@@ -644,7 +644,7 @@ read_call(_mesa_glsl_parse_state *st, s_list *list)
 static ir_expression *
 read_expression(_mesa_glsl_parse_state *st, s_list *list)
 {
-   void *ctx = talloc_parent(st);
+   void *ctx = st;
    const unsigned list_length = list->length();
    if (list_length < 4) {
       ir_read_error(st, list, "expected (expression <type> <operator> "
@@ -749,7 +749,7 @@ read_swizzle(_mesa_glsl_parse_state *st, s_list *list)
 static ir_constant *
 read_constant(_mesa_glsl_parse_state *st, s_list *list)
 {
-   void *ctx = talloc_parent(st);
+   void *ctx = st;
    if (list->length() != 3) {
       ir_read_error(st, list, "expected (constant <type> (<num> ... <num>))");
       return NULL;
@@ -840,7 +840,7 @@ read_dereference(_mesa_glsl_parse_state *st, s_expression *expr)
 static ir_dereference *
 read_var_ref(_mesa_glsl_parse_state *st, s_list *list)
 {
-   void *ctx = talloc_parent(st);
+   void *ctx = st;
    if (list->length() != 2) {
       ir_read_error(st, list, "expected (var_ref <variable name>)");
       return NULL;
@@ -863,7 +863,7 @@ read_var_ref(_mesa_glsl_parse_state *st, s_list *list)
 static ir_dereference *
 read_array_ref(_mesa_glsl_parse_state *st, s_list *list)
 {
-   void *ctx = talloc_parent(st);
+   void *ctx = st;
    if (list->length() != 3) {
       ir_read_error(st, list, "expected (array_ref <rvalue> <index>)");
       return NULL;
@@ -884,7 +884,7 @@ read_array_ref(_mesa_glsl_parse_state *st, s_list *list)
 static ir_dereference *
 read_record_ref(_mesa_glsl_parse_state *st, s_list *list)
 {
-   void *ctx = talloc_parent(st);
+   void *ctx = st;
    if (list->length() != 3) {
       ir_read_error(st, list, "expected (record_ref <rvalue> <field>)");
       return NULL;
@@ -920,7 +920,7 @@ valid_texture_list_length(ir_texture_opcode op, s_list *list)
 static ir_texture *
 read_texture(_mesa_glsl_parse_state *st, s_list *list)
 {
-   void *ctx = talloc_parent(st);
+   void *ctx = st;
    s_symbol *tag = SX_AS_SYMBOL(list->subexpressions.head);
    assert(tag != NULL);