]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
ir_function.allocated_locals now contains the number of locals a function requires...
authorWolfgang (Blub) Bumiller <blub@speed.at>
Mon, 25 Jun 2012 15:43:10 +0000 (17:43 +0200)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Mon, 25 Jun 2012 15:43:10 +0000 (17:43 +0200)
ir.c
ir.h

diff --git a/ir.c b/ir.c
index f8804d75de6482e1a42a9c71b460318b38b7f3d4..ccf9da548e734da3cc46f2db1b90bd2d616284ed 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -1581,11 +1581,11 @@ bool ir_function_allocate_locals(ir_function *self)
             if (v->vtype == TYPE_VECTOR || v->vtype == TYPE_VARIANT)
                 alloc.sizes[a] = 3;
 
-            self->values[i]->code.slot = a;
+            self->values[i]->code.local = a;
             break;
         }
         if (a >= alloc.locals_count) {
-            self->values[i]->code.slot = alloc.locals_count;
+            self->values[i]->code.local = alloc.locals_count;
             if (!function_allocator_alloc(&alloc, v))
                 goto error;
         }
@@ -1602,9 +1602,11 @@ bool ir_function_allocate_locals(ir_function *self)
             goto error;
     }
 
+    self->allocated_locals = pos + alloc.sizes[alloc.sizes_count-1];
+
     /* Take over the actual slot positions */
     for (i = 0; i < self->values_count; ++i)
-        self->values[i]->code.slot = alloc.positions[self->values[i]->code.slot];
+        self->values[i]->code.local = alloc.positions[self->values[i]->code.local];
 
     goto cleanup;
 
diff --git a/ir.h b/ir.h
index 3cb045c5d8a42092aa457d5f1b2b9398ec35284f..a611dba13cba29e8f655f8e26ad9da27ecd7f272 100644 (file)
--- a/ir.h
+++ b/ir.h
@@ -59,7 +59,7 @@ typedef struct ir_value_s {
         int32_t globaladdr;
         int32_t name;
         /* filled by the local-allocator */
-        int32_t slot;
+        int32_t local;
     } code;
 
     /* For the temp allocator */
@@ -222,6 +222,8 @@ typedef struct ir_function_s
     /* locally defined variables */
     MEM_VECTOR_MAKE(ir_value*, locals);
 
+    size_t allocated_locals;
+
     ir_block*     first;
     ir_block*     last;