]> de.git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
type_storep_instr: in theory we could use type_store_instr + INSTR_STOREP_F - INSTR_S...
authorWolfgang Bumiller <wolfgang.linux@bumiller.com>
Mon, 16 Jul 2012 08:24:35 +0000 (10:24 +0200)
committerWolfgang Bumiller <wolfgang.linux@bumiller.com>
Mon, 16 Jul 2012 08:24:35 +0000 (10:24 +0200)
gmqcc.h
ir.c

diff --git a/gmqcc.h b/gmqcc.h
index 6a56675683904297cf8bf9538fe5f37f9b46d777..0ba02deaa9d6740095ffccfdd71422cb5d25c2c5 100644 (file)
--- a/gmqcc.h
+++ b/gmqcc.h
@@ -372,6 +372,12 @@ enum {
 
 extern size_t type_sizeof[TYPE_COUNT];
 extern uint16_t type_store_instr[TYPE_COUNT];
+/* could use type_store_instr + INSTR_STOREP_F - INSTR_STORE_F
+ * but this breaks when TYPE_INTEGER is added, since with the enhanced
+ * instruction set, the old ones are left untouched, thus the _I instructions
+ * are at a seperate place.
+ */
+extern uint16_t type_storep_instr[TYPE_COUNT];
 
 /*
  * Each paramater incerements by 3 since vector types hold
diff --git a/ir.c b/ir.c
index ad9b0d6b4059b31853a16af813616b798926afc7..f2c0f14dac64b3d50f9c3d4ec199753d18e5673f 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -59,6 +59,21 @@ uint16_t type_store_instr[TYPE_COUNT] = {
     INSTR_STORE_V, /* variant, should never be accessed */
 };
 
+uint16_t type_store_instr[TYPE_COUNT] = {
+    INSTR_STOREP_F, /* should use I when having integer support */
+    INSTR_STOREP_S,
+    INSTR_STOREP_F,
+    INSTR_STOREP_V,
+    INSTR_STOREP_ENT,
+    INSTR_STOREP_FLD,
+    INSTR_STOREP_FNC,
+    INSTR_STOREP_ENT, /* should use I */
+#if 0
+    INSTR_STOREP_ENT, /* integer type */
+#endif
+    INSTR_STOREP_V, /* variant, should never be accessed */
+};
+
 MEM_VEC_FUNCTIONS(ir_value_vector, ir_value*, v)
 
 /***********************************************************************
@@ -835,7 +850,6 @@ bool ir_block_create_store(ir_block *self, ir_value *target, ir_value *what)
         op = INSTR_CONV_ITOF;
     else if (vtype == TYPE_INTEGER && what->vtype == TYPE_FLOAT)
         op = INSTR_CONV_FTOI;
-    else
 #endif
         op = type_store_instr[vtype];
 
@@ -855,41 +869,7 @@ bool ir_block_create_storep(ir_block *self, ir_value *target, ir_value *what)
      */
     vtype = what->vtype;
 
-    op = type_store_instr[vtype] + (INSTR_STOREP_F - INSTR_STORE_F);
-#if 0
-    switch (vtype) {
-        case TYPE_FLOAT:
-            op = INSTR_STOREP_F;
-            break;
-        case TYPE_VECTOR:
-            op = INSTR_STOREP_V;
-            break;
-        case TYPE_ENTITY:
-            op = INSTR_STOREP_ENT;
-            break;
-        case TYPE_STRING:
-            op = INSTR_STOREP_S;
-            break;
-        case TYPE_FIELD:
-            op = INSTR_STOREP_FLD;
-            break;
-#if 0
-        case TYPE_INTEGER:
-            op = INSTR_STOREP_I;
-            break;
-#endif
-        case TYPE_POINTER:
-#if 0
-            op = INSTR_STOREP_I;
-#else
-            op = INSTR_STOREP_ENT;
-#endif
-            break;
-        default:
-            /* Unknown type */
-            return false;
-    }
-#endif
+    op = type_storep_instr[vtype];
 
     return ir_block_create_store_op(self, op, target, what);
 }