]> de.git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
remember the maximum amount of required function-locals
authorWolfgang Bumiller <blub@speed.at>
Sun, 23 Dec 2012 15:31:01 +0000 (16:31 +0100)
committerWolfgang Bumiller <blub@speed.at>
Sun, 23 Dec 2012 15:31:01 +0000 (16:31 +0100)
ir.c
ir.h

diff --git a/ir.c b/ir.c
index 38effd70ee6513eddecd2cc4e9554449c113285f..7ce418d9049971da2a84219d94c3a84de9703db9 100644 (file)
--- 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 75946959a900ed0914dd21b2072359c2594f34d4..d07dbf0bb0f17ea5f7e66ea2f74ac3c727b8daf9 100644 (file)
--- 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 */