From 6a93b72ea5824527ab6b23bf6ffee8b1798e6c0a Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Sun, 23 Dec 2012 22:58:46 +0100 Subject: [PATCH] -Ostrip-constant-names --- doc/gmqcc.1 | 5 +++++ ir.c | 8 +++++++- opts.def | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/doc/gmqcc.1 b/doc/gmqcc.1 index 474ec51..8c30d8d 100644 --- a/doc/gmqcc.1 +++ b/doc/gmqcc.1 @@ -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 ce98e6c..bd60b57 100644 --- 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"); diff --git a/opts.def b/opts.def index e8d41cb..2c68898 100644 --- 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 */ -- 2.39.2