From: Wolfgang Bumiller Date: Sun, 23 Dec 2012 15:31:01 +0000 (+0100) Subject: remember the maximum amount of required function-locals X-Git-Tag: before-library~533 X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=commitdiff_plain;h=88a643784094eec609322e7cb574cf12d5223a0e remember the maximum amount of required function-locals --- diff --git a/ir.c b/ir.c index 38effd7..7ce418d 100644 --- a/ir.c +++ b/ir.c @@ -285,6 +285,8 @@ ir_builder* ir_builder_new(const char *modulename) self->htfields = util_htnew(IR_HT_SIZE); self->htfunctions = util_htnew(IR_HT_SIZE); + self->max_locals = 0; + self->str_immediate = 0; self->name = NULL; if (!ir_builder_set_name(self, modulename)) { @@ -3477,6 +3479,11 @@ bool ir_builder_generate(ir_builder *self, const char *filename) if (!ir_builder_gen_global(self, self->globals[i], false)) { return false; } + if (self->globals[i]->vtype == TYPE_FUNCTION) { + ir_function *func = self->globals[i]->constval.vfunc; + if (func && self->max_locals < func->allocated_locals) + self->max_locals = func->allocated_locals; + } } for (i = 0; i < vec_size(self->fields); ++i) diff --git a/ir.h b/ir.h index 7594695..d07dbf0 100644 --- a/ir.h +++ b/ir.h @@ -312,6 +312,9 @@ typedef struct ir_builder_s ir_value **extparams; + /* the highest func->allocated_locals */ + size_t max_locals; + const char **filenames; qcint *filestrings; /* we cache the #IMMEDIATE string here */