From 29285882676388aacff123e8bdf025904abf8ea9 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 24 Jun 2010 15:32:15 -0700 Subject: glsl2: Move the compiler to the subdirectory it will live in in Mesa. --- src/glsl/hir_field_selection.cpp | 81 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 src/glsl/hir_field_selection.cpp (limited to 'src/glsl/hir_field_selection.cpp') diff --git a/src/glsl/hir_field_selection.cpp b/src/glsl/hir_field_selection.cpp new file mode 100644 index 0000000000..e2efff60d3 --- /dev/null +++ b/src/glsl/hir_field_selection.cpp @@ -0,0 +1,81 @@ +/* + * Copyright © 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. + */ + +#include "ir.h" +#include "main/imports.h" +#include "symbol_table.h" +#include "glsl_parser_extras.h" +#include "ast.h" +#include "glsl_types.h" + +struct ir_rvalue * +_mesa_ast_field_selection_to_hir(const ast_expression *expr, + exec_list *instructions, + struct _mesa_glsl_parse_state *state) +{ + void *ctx = talloc_parent(state); + ir_rvalue *result = NULL; + ir_rvalue *op; + + op = expr->subexpressions[0]->hir(instructions, state); + + /* There are two kinds of field selection. There is the selection of a + * specific field from a structure, and there is the selection of a + * swizzle / mask from a vector. Which is which is determined entirely + * by the base type of the thing to which the field selection operator is + * being applied. + */ + YYLTYPE loc = expr->get_location(); + if (op->type->is_error()) { + /* silently propagate the error */ + } else if (op->type->is_vector()) { + ir_swizzle *swiz = ir_swizzle::create(op, + expr->primary_expression.identifier, + op->type->vector_elements); + if (swiz != NULL) { + result = swiz; + } else { + /* FINISHME: Logging of error messages should be moved into + * FINISHME: ir_swizzle::create. This allows the generation of more + * FINISHME: specific error messages. + */ + _mesa_glsl_error(& loc, state, "Invalid swizzle / mask `%s'", + expr->primary_expression.identifier); + } + } else if (op->type->base_type == GLSL_TYPE_STRUCT) { + result = new(ctx) ir_dereference_record(op, + expr->primary_expression.identifier); + + if (result->type->is_error()) { + _mesa_glsl_error(& loc, state, "Cannot access field `%s' of " + "structure", + expr->primary_expression.identifier); + } + } else { + _mesa_glsl_error(& loc, state, "Cannot access field `%s' of " + "non-structure / non-vector.", + expr->primary_expression.identifier); + } + + return result ? result : ir_call::get_error_instruction(ctx); +} -- cgit v1.2.3 From 953ff1283d3d52e6a6b4850c2b0b574111625010 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 25 Jun 2010 13:14:37 -0700 Subject: glsl2: Use _mesa_glsl_parse_state as the talloc parent, not glsl_shader. _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 | 10 +-- src/glsl/ast_to_hir.cpp | 22 ++--- src/glsl/glsl_lexer.lpp | 2 +- src/glsl/glsl_parser.ypp | 174 +++++++++++++++++++-------------------- src/glsl/hir_field_selection.cpp | 2 +- src/glsl/ir_reader.cpp | 30 +++---- 6 files changed, 120 insertions(+), 120 deletions(-) (limited to 'src/glsl/hir_field_selection.cpp') diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index f3074a362d..b681115387 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -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. diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index ba29240092..53f17de7b9 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -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. */ diff --git a/src/glsl/glsl_lexer.lpp b/src/glsl/glsl_lexer.lpp index fa439f1278..f236a15682 100644 --- a/src/glsl/glsl_lexer.lpp +++ b/src/glsl/glsl_lexer.lpp @@ -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; } diff --git a/src/glsl/glsl_parser.ypp b/src/glsl/glsl_parser.ypp index 4132495f40..d894a968ec 100644 --- a/src/glsl/glsl_parser.ypp +++ b/src/glsl/glsl_parser.ypp @@ -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; diff --git a/src/glsl/hir_field_selection.cpp b/src/glsl/hir_field_selection.cpp index e2efff60d3..5500e09d7e 100644 --- a/src/glsl/hir_field_selection.cpp +++ b/src/glsl/hir_field_selection.cpp @@ -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; diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index 03dce0d684..5ba76e29ea 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -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 (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 (parameters ...) " "( ...))"); @@ -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 () " ")"); @@ -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 ( ...) " "( ...))"); @@ -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 " " )"); @@ -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 )"); 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 )"); 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 ( ...))"); 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 " @@ -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 ( ... ))"); 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 )"); 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 )"); 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 )"); 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); -- cgit v1.2.3 From 094cf8c199930d958d9e1139467eb8579d082df6 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Sat, 17 Jul 2010 22:50:26 -0700 Subject: glsl2: Add support for the .length() method on arrays. Fixes piglit test glsl-array-length, and provides proper error messages for negative piglit tests array-length-110.frag, array-length-unsized.frag, and array-length-args.frag. --- src/glsl/hir_field_selection.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/glsl/hir_field_selection.cpp') diff --git a/src/glsl/hir_field_selection.cpp b/src/glsl/hir_field_selection.cpp index 5500e09d7e..db1e06932f 100644 --- a/src/glsl/hir_field_selection.cpp +++ b/src/glsl/hir_field_selection.cpp @@ -71,6 +71,28 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr, "structure", expr->primary_expression.identifier); } + } else if (expr->subexpressions[1] != NULL) { + /* Handle "method calls" in GLSL 1.20 - namely, array.length() */ + if (state->language_version < 120) + _mesa_glsl_error(&loc, state, "Methods not supported in GLSL 1.10."); + + ast_expression *call = expr->subexpressions[1]; + assert(call->oper == ast_function_call); + + const char *method; + method = call->subexpressions[0]->primary_expression.identifier; + + if (op->type->is_array() && strcmp(method, "length") == 0) { + if (!call->expressions.is_empty()) + _mesa_glsl_error(&loc, state, "length method takes no arguments."); + + if (op->type->array_size() == 0) + _mesa_glsl_error(&loc, state, "length called on unsized array."); + + result = new(ctx) ir_constant(op->type->array_size()); + } else { + _mesa_glsl_error(&loc, state, "Unknown method: `%s'.", method); + } } else { _mesa_glsl_error(& loc, state, "Cannot access field `%s' of " "non-structure / non-vector.", -- cgit v1.2.3 From 31747155ea3a24190277b125bd188ac8689af719 Mon Sep 17 00:00:00 2001 From: Aras Pranckevicius Date: Thu, 29 Jul 2010 12:40:49 +0300 Subject: glsl2: Give the path within src/mesa/ for headers instead of relying on -I. --- src/glsl/ast_type.cpp | 2 +- src/glsl/glcpp/glcpp.h | 2 +- src/glsl/glsl_types.cpp | 2 +- src/glsl/hir_field_selection.cpp | 2 +- src/glsl/ir_clone.cpp | 2 +- src/glsl/ir_function_inlining.cpp | 2 +- src/glsl/ir_validate.cpp | 2 +- src/glsl/link_functions.cpp | 2 +- src/glsl/linker.cpp | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/glsl/hir_field_selection.cpp') diff --git a/src/glsl/ast_type.cpp b/src/glsl/ast_type.cpp index e2510a10c6..9a957044e7 100644 --- a/src/glsl/ast_type.cpp +++ b/src/glsl/ast_type.cpp @@ -24,7 +24,7 @@ #include #include "ast.h" extern "C" { -#include "symbol_table.h" +#include "program/symbol_table.h" } void diff --git a/src/glsl/glcpp/glcpp.h b/src/glsl/glcpp/glcpp.h index 869de2efbc..0ccd957eda 100644 --- a/src/glsl/glcpp/glcpp.h +++ b/src/glsl/glcpp/glcpp.h @@ -28,7 +28,7 @@ #include -#include "hash_table.h" +#include "program/hash_table.h" #define yyscan_t void* diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index 8192b86dfc..ce47b8167f 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -28,7 +28,7 @@ #include "glsl_types.h" #include "builtin_types.h" extern "C" { -#include "hash_table.h" +#include "program/hash_table.h" } hash_table *glsl_type::array_types = NULL; diff --git a/src/glsl/hir_field_selection.cpp b/src/glsl/hir_field_selection.cpp index db1e06932f..6dd910d581 100644 --- a/src/glsl/hir_field_selection.cpp +++ b/src/glsl/hir_field_selection.cpp @@ -23,7 +23,7 @@ #include "ir.h" #include "main/imports.h" -#include "symbol_table.h" +#include "program/symbol_table.h" #include "glsl_parser_extras.h" #include "ast.h" #include "glsl_types.h" diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index 6be3e59a95..5ea3a79afc 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -25,7 +25,7 @@ #include "ir.h" #include "glsl_types.h" extern "C" { -#include "hash_table.h" +#include "program/hash_table.h" } /** diff --git a/src/glsl/ir_function_inlining.cpp b/src/glsl/ir_function_inlining.cpp index 77c264f288..9599306243 100644 --- a/src/glsl/ir_function_inlining.cpp +++ b/src/glsl/ir_function_inlining.cpp @@ -33,7 +33,7 @@ #include "ir_function_inlining.h" #include "ir_expression_flattening.h" #include "glsl_types.h" -#include "hash_table.h" +#include "program/hash_table.h" class ir_function_inlining_visitor : public ir_hierarchical_visitor { public: diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 1fa6e19ce9..85417a1dbc 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -36,7 +36,7 @@ #include #include "ir.h" #include "ir_hierarchical_visitor.h" -#include "hash_table.h" +#include "program/hash_table.h" #include "glsl_types.h" class ir_validate : public ir_hierarchical_visitor { diff --git a/src/glsl/link_functions.cpp b/src/glsl/link_functions.cpp index 327be73afe..fdf886f662 100644 --- a/src/glsl/link_functions.cpp +++ b/src/glsl/link_functions.cpp @@ -34,7 +34,7 @@ extern "C" { #include "glsl_parser_extras.h" #include "ir.h" #include "program.h" -#include "hash_table.h" +#include "program/hash_table.h" #include "linker.h" static ir_function_signature * diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 9d53197fdd..a5faff2be7 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -78,7 +78,7 @@ extern "C" { #include "glsl_symbol_table.h" #include "ir.h" #include "program.h" -#include "hash_table.h" +#include "program/hash_table.h" #include "linker.h" #include "ir_optimization.h" -- cgit v1.2.3 From 768b55a5268572ff9fd03e57e92775882eb0a821 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 13 Aug 2010 16:46:43 -0700 Subject: glsl2: Remove unnecessary use of 'struct' before type names In C++ you don't have to say 'struct' or 'class' if the declaration of the type has been seen. Some compilers will complain if you use 'struct' when 'class' should have been used and vice versa. Fixes bugzilla #29539. --- src/glsl/ast.h | 5 ++--- src/glsl/ast_to_hir.cpp | 10 +++++----- src/glsl/glsl_parser.cpp | 36 ++++++++++++++++++------------------ src/glsl/glsl_parser.h | 26 +++++++++++++------------- src/glsl/glsl_parser.ypp | 36 ++++++++++++++++++------------------ src/glsl/hir_field_selection.cpp | 2 +- 6 files changed, 57 insertions(+), 58 deletions(-) (limited to 'src/glsl/hir_field_selection.cpp') diff --git a/src/glsl/ast.h b/src/glsl/ast.h index 7ce879bb79..44c31b6e62 100644 --- a/src/glsl/ast.h +++ b/src/glsl/ast.h @@ -29,7 +29,6 @@ #include "list.h" #include "glsl_parser_extras.h" -struct ir_instruction; struct _mesa_glsl_parse_state; struct YYLTYPE; @@ -657,8 +656,8 @@ public: extern void _mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state); -extern struct ir_rvalue * -_mesa_ast_field_selection_to_hir(const struct ast_expression *expr, +extern ir_rvalue * +_mesa_ast_field_selection_to_hir(const ast_expression *expr, exec_list *instructions, struct _mesa_glsl_parse_state *state); diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 9d4448f89a..6e5d01ee26 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -986,7 +986,7 @@ ast_expression::hir(exec_list *instructions, assert(operations[this->oper] == ir_binop_mod); - struct ir_rvalue *temp_rhs; + ir_rvalue *temp_rhs; temp_rhs = new(ctx) ir_expression(operations[this->oper], type, op[0], op[1]); @@ -1107,7 +1107,7 @@ ast_expression::hir(exec_list *instructions, type = arithmetic_result_type(op[0], op[1], false, state, & loc); - struct ir_rvalue *temp_rhs; + ir_rvalue *temp_rhs; temp_rhs = new(ctx) ir_expression(operations[this->oper], type, op[0], op[1]); @@ -1131,7 +1131,7 @@ ast_expression::hir(exec_list *instructions, type = arithmetic_result_type(op[0], op[1], false, state, & loc); - struct ir_rvalue *temp_rhs; + ir_rvalue *temp_rhs; temp_rhs = new(ctx) ir_expression(operations[this->oper], type, op[0], op[1]); @@ -1453,7 +1453,7 @@ ast_type_specifier::glsl_type(const char **name, static void apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, - struct ir_variable *var, + ir_variable *var, struct _mesa_glsl_parse_state *state, YYLTYPE *loc) { @@ -1620,7 +1620,7 @@ ast_declarator_list::hir(exec_list *instructions, foreach_list_typed (ast_declaration, decl, link, &this->declarations) { const struct glsl_type *var_type; - struct ir_variable *var; + ir_variable *var; /* FINISHME: Emit a warning if a variable declaration shadows a * FINISHME: declaration at a higher scope. diff --git a/src/glsl/glsl_parser.cpp b/src/glsl/glsl_parser.cpp index 8756fcb721..7df9e96d16 100644 --- a/src/glsl/glsl_parser.cpp +++ b/src/glsl/glsl_parser.cpp @@ -347,21 +347,21 @@ typedef union YYSTYPE unsigned i; } type_qualifier; - struct ast_node *node; - struct ast_type_specifier *type_specifier; - struct ast_fully_specified_type *fully_specified_type; - struct ast_function *function; - struct ast_parameter_declarator *parameter_declarator; - struct ast_function_definition *function_definition; - struct ast_compound_statement *compound_statement; - struct ast_expression *expression; - struct ast_declarator_list *declarator_list; - struct ast_struct_specifier *struct_specifier; - struct ast_declaration *declaration; + ast_node *node; + ast_type_specifier *type_specifier; + ast_fully_specified_type *fully_specified_type; + ast_function *function; + ast_parameter_declarator *parameter_declarator; + ast_function_definition *function_definition; + ast_compound_statement *compound_statement; + ast_expression *expression; + ast_declarator_list *declarator_list; + ast_struct_specifier *struct_specifier; + ast_declaration *declaration; struct { - struct ast_node *cond; - struct ast_expression *rest; + ast_node *cond; + ast_expression *rest; } for_rest_statement; @@ -4609,7 +4609,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 1193 "glsl_parser.ypp" { - (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].declarator_list); + (yyval.node) = (ast_node *) (yyvsp[(1) - (1)].declarator_list); (yyvsp[(1) - (1)].declarator_list)->link.self_link(); ;} break; @@ -4619,7 +4619,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 1198 "glsl_parser.ypp" { - (yyval.node) = (struct ast_node *) (yyvsp[(1) - (2)].node); + (yyval.node) = (ast_node *) (yyvsp[(1) - (2)].node); (yyval.node)->link.insert_before(& (yyvsp[(2) - (2)].declarator_list)->link); ;} break; @@ -4687,7 +4687,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 1263 "glsl_parser.ypp" - { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} + { (yyval.node) = (ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} break; case 234: @@ -4730,7 +4730,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 1297 "glsl_parser.ypp" - { (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} + { (yyval.node) = (ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} break; case 242: @@ -4855,7 +4855,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 1385 "glsl_parser.ypp" { - (yyval.node) = (struct ast_node *) (yyvsp[(1) - (1)].expression); + (yyval.node) = (ast_node *) (yyvsp[(1) - (1)].expression); ;} break; diff --git a/src/glsl/glsl_parser.h b/src/glsl/glsl_parser.h index 4124c7f1d2..48a0a5fb3a 100644 --- a/src/glsl/glsl_parser.h +++ b/src/glsl/glsl_parser.h @@ -245,21 +245,21 @@ typedef union YYSTYPE unsigned i; } type_qualifier; - struct ast_node *node; - struct ast_type_specifier *type_specifier; - struct ast_fully_specified_type *fully_specified_type; - struct ast_function *function; - struct ast_parameter_declarator *parameter_declarator; - struct ast_function_definition *function_definition; - struct ast_compound_statement *compound_statement; - struct ast_expression *expression; - struct ast_declarator_list *declarator_list; - struct ast_struct_specifier *struct_specifier; - struct ast_declaration *declaration; + ast_node *node; + ast_type_specifier *type_specifier; + ast_fully_specified_type *fully_specified_type; + ast_function *function; + ast_parameter_declarator *parameter_declarator; + ast_function_definition *function_definition; + ast_compound_statement *compound_statement; + ast_expression *expression; + ast_declarator_list *declarator_list; + ast_struct_specifier *struct_specifier; + ast_declaration *declaration; struct { - struct ast_node *cond; - struct ast_expression *rest; + ast_node *cond; + ast_expression *rest; } for_rest_statement; diff --git a/src/glsl/glsl_parser.ypp b/src/glsl/glsl_parser.ypp index 1ee6da1d23..e0b1d28504 100644 --- a/src/glsl/glsl_parser.ypp +++ b/src/glsl/glsl_parser.ypp @@ -59,21 +59,21 @@ unsigned i; } type_qualifier; - struct ast_node *node; - struct ast_type_specifier *type_specifier; - struct ast_fully_specified_type *fully_specified_type; - struct ast_function *function; - struct ast_parameter_declarator *parameter_declarator; - struct ast_function_definition *function_definition; - struct ast_compound_statement *compound_statement; - struct ast_expression *expression; - struct ast_declarator_list *declarator_list; - struct ast_struct_specifier *struct_specifier; - struct ast_declaration *declaration; + ast_node *node; + ast_type_specifier *type_specifier; + ast_fully_specified_type *fully_specified_type; + ast_function *function; + ast_parameter_declarator *parameter_declarator; + ast_function_definition *function_definition; + ast_compound_statement *compound_statement; + ast_expression *expression; + ast_declarator_list *declarator_list; + ast_struct_specifier *struct_specifier; + ast_declaration *declaration; struct { - struct ast_node *cond; - struct ast_expression *rest; + ast_node *cond; + ast_expression *rest; } for_rest_statement; } @@ -1191,12 +1191,12 @@ struct_specifier: struct_declaration_list: struct_declaration { - $$ = (struct ast_node *) $1; + $$ = (ast_node *) $1; $1->link.self_link(); } | struct_declaration_list struct_declaration { - $$ = (struct ast_node *) $1; + $$ = (ast_node *) $1; $$->link.insert_before(& $2->link); } ; @@ -1260,7 +1260,7 @@ statement: ; statement_matched: - compound_statement { $$ = (struct ast_node *) $1; } + compound_statement { $$ = (ast_node *) $1; } | simple_statement ; @@ -1294,7 +1294,7 @@ compound_statement: ; statement_no_new_scope: - compound_statement_no_new_scope { $$ = (struct ast_node *) $1; } + compound_statement_no_new_scope { $$ = (ast_node *) $1; } | simple_statement ; @@ -1383,7 +1383,7 @@ selection_statement_unmatched: condition: expression { - $$ = (struct ast_node *) $1; + $$ = (ast_node *) $1; } | fully_specified_type IDENTIFIER '=' initializer { diff --git a/src/glsl/hir_field_selection.cpp b/src/glsl/hir_field_selection.cpp index 6dd910d581..23045ff182 100644 --- a/src/glsl/hir_field_selection.cpp +++ b/src/glsl/hir_field_selection.cpp @@ -28,7 +28,7 @@ #include "ast.h" #include "glsl_types.h" -struct ir_rvalue * +ir_rvalue * _mesa_ast_field_selection_to_hir(const ast_expression *expr, exec_list *instructions, struct _mesa_glsl_parse_state *state) -- cgit v1.2.3 From bfd7c9ac228c7ed8aec04c3b3aa33f40ee00b035 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 23 Aug 2010 17:51:42 +0800 Subject: glsl: Include main/core.h. Make glsl include only main/core.h from core mesa. --- src/glsl/ast_function.cpp | 2 +- src/glsl/ast_to_hir.cpp | 3 +-- src/glsl/builtin_function.cpp | 2 +- src/glsl/builtin_variables.h | 2 +- src/glsl/builtins/tools/generate_builtins.py | 2 +- src/glsl/glcpp/glcpp-parse.c | 2 +- src/glsl/glcpp/glcpp-parse.y | 2 +- src/glsl/glsl_parser_extras.cpp | 2 +- src/glsl/glsl_types.cpp | 3 +-- src/glsl/hir_field_selection.cpp | 1 - src/glsl/ir.cpp | 3 +-- src/glsl/ir_constant_expression.cpp | 2 +- src/glsl/ir_explog_to_explog2.cpp | 2 +- src/glsl/ir_set_program_inouts.cpp | 2 +- src/glsl/ir_variable.cpp | 1 - src/glsl/link_functions.cpp | 2 +- src/glsl/linker.cpp | 5 +---- src/glsl/program.h | 8 +------- 18 files changed, 16 insertions(+), 30 deletions(-) (limited to 'src/glsl/hir_field_selection.cpp') diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index f85b308c1b..34b0f70d41 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -25,7 +25,7 @@ #include "ast.h" #include "glsl_types.h" #include "ir.h" -#include "main/macros.h" +#include "main/core.h" /* for MIN2 */ static ir_rvalue * convert_component(ir_rvalue *src, const glsl_type *desired_type); diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 57e331742e..64b142fa35 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -49,8 +49,7 @@ * parser (and lexer) sources. */ -#include "main/imports.h" -#include "main/extensions.h" +#include "main/core.h" /* for struct gl_extensions */ #include "glsl_symbol_table.h" #include "glsl_parser_extras.h" #include "ast.h" diff --git a/src/glsl/builtin_function.cpp b/src/glsl/builtin_function.cpp index 5471ba6020..a277ed6e8d 100644 --- a/src/glsl/builtin_function.cpp +++ b/src/glsl/builtin_function.cpp @@ -23,7 +23,7 @@ */ #include -#include "main/compiler.h" +#include "main/core.h" /* for struct gl_shader */ #include "glsl_parser_extras.h" #include "ir_reader.h" #include "program.h" diff --git a/src/glsl/builtin_variables.h b/src/glsl/builtin_variables.h index 2ec7d621bb..a7dbe480e9 100644 --- a/src/glsl/builtin_variables.h +++ b/src/glsl/builtin_variables.h @@ -21,7 +21,7 @@ * DEALINGS IN THE SOFTWARE. */ -#include "main/mtypes.h" +#include "main/core.h" /* for slot numbers */ struct builtin_variable { enum ir_variable_mode mode; diff --git a/src/glsl/builtins/tools/generate_builtins.py b/src/glsl/builtins/tools/generate_builtins.py index 2a763d784b..c72b5b3bc1 100755 --- a/src/glsl/builtins/tools/generate_builtins.py +++ b/src/glsl/builtins/tools/generate_builtins.py @@ -116,7 +116,7 @@ if __name__ == "__main__": */ #include -#include "main/compiler.h" +#include "main/core.h" /* for struct gl_shader */ #include "glsl_parser_extras.h" #include "ir_reader.h" #include "program.h" diff --git a/src/glsl/glcpp/glcpp-parse.c b/src/glsl/glcpp/glcpp-parse.c index 2c04d7d71b..91eb0bf972 100644 --- a/src/glsl/glcpp/glcpp-parse.c +++ b/src/glsl/glcpp/glcpp-parse.c @@ -100,7 +100,7 @@ #include #include "glcpp.h" -#include "main/mtypes.h" +#include "main/core.h" /* for struct gl_extensions */ #define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str) #define glcpp_printf(stream, fmt, args, ...) \ diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index 3275496d99..3c28edf688 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -29,7 +29,7 @@ #include #include "glcpp.h" -#include "main/mtypes.h" +#include "main/core.h" /* for struct gl_extensions */ #define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str) #define glcpp_printf(stream, fmt, args, ...) \ diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index b864218d50..bc56e4fcaf 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -27,7 +27,7 @@ extern "C" { #include -#include "main/mtypes.h" +#include "main/core.h" /* for struct __GLcontextRec */ } #include "ast.h" diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index c488f5c271..1da2fd76de 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -23,13 +23,12 @@ #include #include -#include "main/compiler.h" +#include "main/core.h" /* for Elements */ #include "glsl_symbol_table.h" #include "glsl_parser_extras.h" #include "glsl_types.h" #include "builtin_types.h" extern "C" { -#include "main/imports.h" #include "program/hash_table.h" } diff --git a/src/glsl/hir_field_selection.cpp b/src/glsl/hir_field_selection.cpp index 23045ff182..3c33127b5f 100644 --- a/src/glsl/hir_field_selection.cpp +++ b/src/glsl/hir_field_selection.cpp @@ -22,7 +22,6 @@ */ #include "ir.h" -#include "main/imports.h" #include "program/symbol_table.h" #include "glsl_parser_extras.h" #include "ast.h" diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 4622a1f939..e5ed10d3e4 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -21,8 +21,7 @@ * DEALINGS IN THE SOFTWARE. */ #include -#include "main/imports.h" -#include "main/macros.h" +#include "main/core.h" /* for MAX2 */ #include "ir.h" #include "ir_visitor.h" #include "glsl_types.h" diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 942f198360..f1c175c97a 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -34,7 +34,7 @@ */ #include -#include "main/macros.h" +#include "main/core.h" /* for MAX2, MIN2, CLAMP */ #include "ir.h" #include "ir_visitor.h" #include "glsl_types.h" diff --git a/src/glsl/ir_explog_to_explog2.cpp b/src/glsl/ir_explog_to_explog2.cpp index 9bf8271081..78694a2029 100644 --- a/src/glsl/ir_explog_to_explog2.cpp +++ b/src/glsl/ir_explog_to_explog2.cpp @@ -29,7 +29,7 @@ * and log2 operations. */ -#include "main/imports.h" +#include "main/core.h" /* for log2f on MSVC */ #include "ir.h" #include "glsl_types.h" diff --git a/src/glsl/ir_set_program_inouts.cpp b/src/glsl/ir_set_program_inouts.cpp index 534f602128..b3f1cc0d8b 100644 --- a/src/glsl/ir_set_program_inouts.cpp +++ b/src/glsl/ir_set_program_inouts.cpp @@ -35,7 +35,7 @@ */ extern "C" { -#include "main/mtypes.h" +#include "main/core.h" /* for struct gl_program */ #include "program/hash_table.h" } #include "ir.h" diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp index 917c06743b..e638c9602f 100644 --- a/src/glsl/ir_variable.cpp +++ b/src/glsl/ir_variable.cpp @@ -21,7 +21,6 @@ * DEALINGS IN THE SOFTWARE. */ -#include "main/compiler.h" #include "ir.h" #include "glsl_parser_extras.h" #include "glsl_symbol_table.h" diff --git a/src/glsl/link_functions.cpp b/src/glsl/link_functions.cpp index dfda05fcbe..6374573e61 100644 --- a/src/glsl/link_functions.cpp +++ b/src/glsl/link_functions.cpp @@ -29,7 +29,7 @@ extern "C" { #include } -#include "main/mtypes.h" +#include "main/core.h" #include "glsl_symbol_table.h" #include "glsl_parser_extras.h" #include "ir.h" diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 38d19c4c71..c5c8c9cdd6 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -72,10 +72,7 @@ extern "C" { #include } -#include "main/compiler.h" -#include "main/mtypes.h" -#include "main/macros.h" -#include "main/shaderobj.h" +#include "main/core.h" #include "glsl_symbol_table.h" #include "ir.h" #include "program.h" diff --git a/src/glsl/program.h b/src/glsl/program.h index ea2c4ab0dd..893169b6cc 100644 --- a/src/glsl/program.h +++ b/src/glsl/program.h @@ -21,13 +21,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include -#include "main/mtypes.h" - -extern "C" { -#include "program/prog_parameter.h" -#include "program/prog_uniform.h" -} +#include "main/core.h" extern void link_shaders(GLcontext *ctx, struct gl_shader_program *prog); -- cgit v1.2.3