]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ir.h
Fix a possibly uninitialized variable
[xonotic/gmqcc.git] / ir.h
diff --git a/ir.h b/ir.h
index 3cb045c5d8a42092aa457d5f1b2b9398ec35284f..9379d70d416bff90c130beaa7a3d7454a237d70e 100644 (file)
--- a/ir.h
+++ b/ir.h
@@ -40,6 +40,8 @@ typedef struct ir_value_s {
     lex_ctx   context;
     /* even the IR knows the subtype of a field */
     int       fieldtype;
+    /* and the output type of a function */
+    int       outtype;
 
     MEM_VECTOR_MAKE(struct ir_instr_s*, reads);
     MEM_VECTOR_MAKE(struct ir_instr_s*, writes);
@@ -59,7 +61,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 */
@@ -100,6 +102,13 @@ bool ir_values_overlap(const ir_value*, const ir_value*);
 void ir_value_dump(ir_value*, int (*oprintf)(const char*,...));
 void ir_value_dump_life(ir_value *self, int (*oprintf)(const char*,...));
 
+/* A vector of IR values */
+typedef struct {
+    MEM_VECTOR_MAKE(ir_value*, v);
+} ir_value_vector;
+MEM_VECTOR_PROTO(ir_value_vector, ir_value*, v);
+
+/* PHI data */
 typedef struct ir_phi_entry_s
 {
     ir_value          *value;
@@ -115,6 +124,7 @@ typedef struct ir_instr_s
     struct ir_block_s* (bops[2]);
 
     MEM_VECTOR_MAKE(ir_phi_entry_t, phi);
+    MEM_VECTOR_MAKE(ir_value*, params);
 
     /* For the temp-allocation */
     size_t eid;
@@ -128,6 +138,8 @@ void      ir_instr_delete(ir_instr*);
 MEM_VECTOR_PROTO(ir_value, ir_phi_entry_t, phi);
 bool GMQCC_WARN ir_instr_op(ir_instr*, int op, ir_value *value, bool writing);
 
+MEM_VECTOR_PROTO(ir_value, ir_value*, params);
+
 void ir_instr_dump(ir_instr* in, char *ind, int (*oprintf)(const char*,...));
 
 /* block */
@@ -186,6 +198,9 @@ ir_value* ir_block_create_div(ir_block*, const char *label, ir_value *l, ir_valu
 ir_instr* ir_block_create_phi(ir_block*, const char *label, int vtype);
 ir_value* ir_phi_value(ir_instr*);
 bool GMQCC_WARN ir_phi_add(ir_instr*, ir_block *b, ir_value *v);
+ir_instr* ir_block_create_call(ir_block*, const char *label, ir_value *func, int otype);
+ir_value* ir_call_value(ir_instr*);
+bool GMQCC_WARN ir_call_param(ir_instr*, ir_value*);
 
 bool GMQCC_WARN ir_block_create_return(ir_block*, ir_value *opt_value);
 
@@ -222,6 +237,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;