summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2017-09-21 12:14:04 -0500
committerIan Romanick <[email protected]>2017-10-30 09:27:09 -0700
commit4171900cf15f2c81a1f119e1fb92772f6c355199 (patch)
tree638082b4b32b23ac41774eeeacd167f6d64b8112 /src/compiler/glsl
parent792acfc44aabc09a19a1d2ef77369159ddb41e66 (diff)
glsl/parser: Allocate identifier inside classify_identifier
Passing YYSTYPE into classify_identifier enables a later patch. text data bss dec hex filename 8310339 269336 294072 8873747 876713 32-bit i965_dri.so before 8275163 269336 294072 8838571 86ddab 32-bit i965_dri.so after 7845579 346552 420592 8612723 836b73 64-bit i965_dri.so before 7836963 346552 420592 8604107 8349cb 64-bit i965_dri.so after Yes, the 64-bit binary shrinks by 8k. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/compiler/glsl')
-rw-r--r--src/compiler/glsl/glsl_lexer.ll44
1 files changed, 15 insertions, 29 deletions
diff --git a/src/compiler/glsl/glsl_lexer.ll b/src/compiler/glsl/glsl_lexer.ll
index 56519bf92dc..bdd8df16f91 100644
--- a/src/compiler/glsl/glsl_lexer.ll
+++ b/src/compiler/glsl/glsl_lexer.ll
@@ -28,7 +28,8 @@
#include "glsl_parser_extras.h"
#include "glsl_parser.h"
-static int classify_identifier(struct _mesa_glsl_parse_state *, const char *);
+static int classify_identifier(struct _mesa_glsl_parse_state *, const char *,
+ unsigned name_len, YYSTYPE *output);
#ifdef _MSC_VER
#define YY_NO_UNISTD_H
@@ -81,14 +82,7 @@ static int classify_identifier(struct _mesa_glsl_parse_state *, const char *);
"illegal use of reserved word `%s'", yytext); \
return ERROR_TOK; \
} else { \
- /* We're not doing linear_strdup here, to avoid an implicit \
- * call on strlen() for the length of the string, as this is \
- * already found by flex and stored in yyleng */ \
- void *mem_ctx = yyextra->linalloc; \
- char *id = (char *) linear_alloc_child(mem_ctx, yyleng + 1); \
- memcpy(id, yytext, yyleng + 1); \
- yylval->identifier = id; \
- return classify_identifier(yyextra, yytext); \
+ return classify_identifier(yyextra, yytext, yyleng, yylval); \
} \
} while (0)
@@ -460,15 +454,7 @@ layout {
|| yyextra->ARB_tessellation_shader_enable) {
return LAYOUT_TOK;
} else {
- /* We're not doing linear_strdup here, to avoid an implicit call
- * on strlen() for the length of the string, as this is already
- * found by flex and stored in yyleng
- */
- void *mem_ctx = yyextra->linalloc;
- char *id = (char *) linear_alloc_child(mem_ctx, yyleng + 1);
- memcpy(id, yytext, yyleng + 1);
- yylval->identifier = id;
- return classify_identifier(yyextra, yytext);
+ return classify_identifier(yyextra, yytext, yyleng, yylval);
}
}
@@ -637,21 +623,12 @@ u64vec4 KEYWORD_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable, U64V
[_a-zA-Z][_a-zA-Z0-9]* {
struct _mesa_glsl_parse_state *state = yyextra;
- void *ctx = state->linalloc;
if (state->es_shader && yyleng > 1024) {
_mesa_glsl_error(yylloc, state,
"Identifier `%s' exceeds 1024 characters",
yytext);
- } else {
- /* We're not doing linear_strdup here, to avoid an implicit call
- * on strlen() for the length of the string, as this is already
- * found by flex and stored in yyleng
- */
- char *id = (char *) linear_alloc_child(ctx, yyleng + 1);
- memcpy(id, yytext, yyleng + 1);
- yylval->identifier = id;
}
- return classify_identifier(state, yytext);
+ return classify_identifier(state, yytext, yyleng, yylval);
}
\. { struct _mesa_glsl_parse_state *state = yyextra;
@@ -663,8 +640,17 @@ u64vec4 KEYWORD_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable, U64V
%%
int
-classify_identifier(struct _mesa_glsl_parse_state *state, const char *name)
+classify_identifier(struct _mesa_glsl_parse_state *state, const char *name,
+ unsigned name_len, YYSTYPE *output)
{
+ /* We're not doing linear_strdup here, to avoid an implicit call on
+ * strlen() for the length of the string, as this is already found by flex
+ * and stored in yyleng
+ */
+ char *id = (char *) linear_alloc_child(state->linalloc, name_len + 1);
+ memcpy(id, name, name_len + 1);
+ output->identifier = id;
+
if (state->is_field) {
state->is_field = false;
return FIELD_SELECTION;