-Ostrip-constant-names
authorWolfgang Bumiller <blub@speed.at>
Sun, 23 Dec 2012 21:58:46 +0000 (22:58 +0100)
committerWolfgang Bumiller <blub@speed.at>
Sun, 23 Dec 2012 21:58:46 +0000 (22:58 +0100)
doc/gmqcc.1
ir.c
opts.def

index 474ec518d683782a4db1a202ca34cb66a3ba7fd5..8c30d8d8da05cc57ffa5b92e702b30a03ef84b58 100644 (file)
@@ -362,6 +362,11 @@ variable which is not 'alive' at that point can be used to keep the
 result. This can reduce the size of the global section.
 This will not have declared variables overlap, even if it was
 possible.
+.TP
+.B -Ostrip-constant-names
+Don't generate defs for immediate values or even declared constants.
+Meaning variables which are implicitly constant or qualified as such
+using the 'const' keyword.
 .SH CONFIG
 The configuration file is similar to regular .ini files. Comments
 start with hashtags or semicolons, sections are written in square
diff --git a/ir.c b/ir.c
index ce98e6c252c49bf340f261862c5e597f0f2c313c..bd60b574d5e672a7777250c7cb29595b0d4f6c43 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -3120,7 +3120,13 @@ static bool ir_builder_gen_global(ir_builder *self, ir_value *global, bool isloc
         def.type   = global->vtype;
         def.offset = vec_size(code_globals);
 
-        if (global->name) {
+        if (OPTS_OPTIMIZATION(OPTIM_STRIP_CONSTANT_NAMES) &&
+            (global->name[0] == '#' || global->cvq == CV_CONST))
+        {
+            pushdef = false;
+        }
+
+        if (pushdef && global->name) {
             if (global->name[0] == '#') {
                 if (!self->str_immediate)
                     self->str_immediate = code_genstring("IMMEDIATE");
index e8d41cb8bac265e55e450fcec30e5e80f68ace2b..2c68898dda5c0e951d6d38cc05b00b830eaa94f0 100644 (file)
--- a/opts.def
+++ b/opts.def
@@ -83,6 +83,7 @@
     GMQCC_DEFINE_FLAG(TAIL_RECURSION, 1)
     GMQCC_DEFINE_FLAG(TAIL_CALLS,     2)
     GMQCC_DEFINE_FLAG(OVERLAP_LOCALS, 3)
+    GMQCC_DEFINE_FLAG(STRIP_CONSTANT_NAMES, 1)
 #endif
 
 /* some cleanup so we don't have to */