On 17.10.2017 20:14, Ian Romanick wrote:
From: Ian Romanick <ian.d.roman...@intel.com>

    text           data     bss     dec     hex filename
8255243  268856  294072 8818171  868dfb 32-bit i965_dri.so before
8255291  268856  294072 8818219  868e2b 32-bit i965_dri.so after
7815195  345592  420592 8581379  82f103 64-bit i965_dri.so before
7815339  345592  420592 8581523  82f193 64-bit i965_dri.so after

How does this change lead to such a big reduction, and shouldn't the lexer changes be in a separate patch?

Cheers,
Nicolai


Signed-off-by: Ian Romanick <ian.d.roman...@intel.com>
---
  src/compiler/glsl/ast.h          | 13 +++++++++++--
  src/compiler/glsl/ast_to_hir.cpp |  4 +++-
  src/compiler/glsl/glsl_lexer.ll  | 21 +++++++++++++--------
  src/compiler/glsl/glsl_parser.yy |  2 +-
  4 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h
index 1be86ac..eee2248 100644
--- a/src/compiler/glsl/ast.h
+++ b/src/compiler/glsl/ast.h
@@ -27,6 +27,7 @@
#include "list.h"
  #include "glsl_parser_extras.h"
+#include "compiler/glsl_types.h"
struct _mesa_glsl_parse_state; @@ -853,7 +854,7 @@ class ast_type_specifier : public ast_node {
  public:
     /** Construct a type specifier from a type name */
     ast_type_specifier(const char *name)
-      : type_name(name), structure(NULL), array_specifier(NULL),
+      : type(NULL), type_name(name), structure(NULL), array_specifier(NULL),
        default_precision(ast_precision_none)
     {
        /* empty */
@@ -861,12 +862,19 @@ public:
/** Construct a type specifier from a structure definition */
     ast_type_specifier(ast_struct_specifier *s)
-      : type_name(s->name), structure(s), array_specifier(NULL),
+      : type(NULL), type_name(s->name), structure(s), array_specifier(NULL),
        default_precision(ast_precision_none)
     {
        /* empty */
     }
+ ast_type_specifier(const glsl_type *t)
+      : type(t), type_name(t->name), structure(NULL), array_specifier(NULL),
+        default_precision(ast_precision_none)
+   {
+      /* empty */
+   }
+
     const struct glsl_type *glsl_type(const char **name,
                                     struct _mesa_glsl_parse_state *state)
        const;
@@ -875,6 +883,7 @@ public:
ir_rvalue *hir(exec_list *, struct _mesa_glsl_parse_state *); + const struct glsl_type *type;
     const char *type_name;
     ast_struct_specifier *structure;
diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index d7c8b47..6090ee9 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -2361,7 +2361,9 @@ ast_type_specifier::glsl_type(const char **name,
  {
     const struct glsl_type *type;
- if (structure)
+   if (this->type != NULL)
+      type = this->type;
+   else if (structure)
        type = structure->type;
     else
        type = state->symbols->get_type(this->type_name);
diff --git a/src/compiler/glsl/glsl_lexer.ll b/src/compiler/glsl/glsl_lexer.ll
index 5dad6ee..d2278ba 100644
--- a/src/compiler/glsl/glsl_lexer.ll
+++ b/src/compiler/glsl/glsl_lexer.ll
@@ -132,18 +132,23 @@ static int classify_identifier(struct 
_mesa_glsl_parse_state *, const char *,
  /**
   * Like DEPRECATED_ES_KEYWORD, but for types
   */
-#define DEPRECATED_ES_TYPE(gtype)                                      \
+#define DEPRECATED_ES_TYPE_WITH_ALT(alt_expr, gtype)                   \
     do {                                                                       
\
        if (yyextra->is_version(0, 300)) {                           \
-        _mesa_glsl_error(yylloc, yyextra,                              \
-                         "illegal use of reserved word `%s'", yytext);       \
-        return ERROR_TOK;                                              \
-      } else {                                                         \
-        yylval->type = gtype;                                               \
+         _mesa_glsl_error(yylloc, yyextra,                             \
+                          "illegal use of reserved word `%s'", yytext);      \
+         return ERROR_TOK;                                             \
+      } else if (alt_expr) {                                           \
+         yylval->type = gtype;                                              \
           return BASIC_TYPE_TOK;                                               
\
+      } else {                                                         \
+         return classify_identifier(yyextra, yytext, yyleng, yylval);  \
        }                                                                       
\
     } while (0)
+#define DEPRECATED_ES_TYPE(gtype) \
+   DEPRECATED_ES_TYPE_WITH_ALT(true, gtype)
+
  static int
  literal_integer(char *text, int len, struct _mesa_glsl_parse_state *state,
                YYSTYPE *lval, YYLTYPE *lloc, int base)
@@ -619,9 +624,9 @@ dmat4x4             TYPE_WITH_ALT(110, 100, 400, 0, 
yyextra->ARB_gpu_shader_fp64_enable, gl
  fvec2         KEYWORD(110, 100, 0, 0, FVEC2);
  fvec3         KEYWORD(110, 100, 0, 0, FVEC3);
  fvec4         KEYWORD(110, 100, 0, 0, FVEC4);
-sampler2DRect          DEPRECATED_ES_TYPE(glsl_type::sampler2DRect_type);
+sampler2DRect          
DEPRECATED_ES_TYPE_WITH_ALT(yyextra->ARB_texture_rectangle_enable, 
glsl_type::sampler2DRect_type);
  sampler3DRect         KEYWORD(110, 100, 0, 0, SAMPLER3DRECT);
-sampler2DRectShadow    DEPRECATED_ES_TYPE(glsl_type::sampler2DRectShadow_type);
+sampler2DRectShadow    
DEPRECATED_ES_TYPE_WITH_ALT(yyextra->ARB_texture_rectangle_enable, 
glsl_type::sampler2DRectShadow_type);
  sizeof                KEYWORD(110, 100, 0, 0, SIZEOF);
  cast          KEYWORD(110, 100, 0, 0, CAST);
  namespace     KEYWORD(110, 100, 0, 0, NAMESPACE);
diff --git a/src/compiler/glsl/glsl_parser.yy b/src/compiler/glsl/glsl_parser.yy
index 0a53425..19147c7 100644
--- a/src/compiler/glsl/glsl_parser.yy
+++ b/src/compiler/glsl/glsl_parser.yy
@@ -2189,7 +2189,7 @@ type_specifier_nonarray:
     basic_type_specifier_nonarray
     {
        void *ctx = state->linalloc;
-      $$ = new(ctx) ast_type_specifier($1->name);
+      $$ = new(ctx) ast_type_specifier($1);
        $$->set_location(@1);
     }
     | struct_specifier



--
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to