]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Replacing 2 switches to use type_store_instr instead
authorWolfgang Bumiller <wolfgang.linux@bumiller.com>
Mon, 16 Jul 2012 08:19:04 +0000 (10:19 +0200)
committerWolfgang Bumiller <wolfgang.linux@bumiller.com>
Mon, 16 Jul 2012 08:19:04 +0000 (10:19 +0200)
ir.c

diff --git a/ir.c b/ir.c
index fbf07bc9552756642ea269677413920b0730a1f7..ad9b0d6b4059b31853a16af813616b798926afc7 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -830,46 +830,15 @@ bool ir_block_create_store(ir_block *self, ir_value *target, ir_value *what)
     else
         vtype = target->vtype;
 
-    switch (vtype) {
-        case TYPE_FLOAT:
 #if 0
-            if (what->vtype == TYPE_INTEGER)
-                op = INSTR_CONV_ITOF;
-            else
-#endif
-                op = INSTR_STORE_F;
-            break;
-        case TYPE_VECTOR:
-            op = INSTR_STORE_V;
-            break;
-        case TYPE_ENTITY:
-            op = INSTR_STORE_ENT;
-            break;
-        case TYPE_STRING:
-            op = INSTR_STORE_S;
-            break;
-        case TYPE_FIELD:
-            op = INSTR_STORE_FLD;
-            break;
-#if 0
-        case TYPE_INTEGER:
-            if (what->vtype == TYPE_INTEGER)
-                op = INSTR_CONV_FTOI;
-            else
-                op = INSTR_STORE_I;
-            break;
-#endif
-        case TYPE_POINTER:
-#if 0
-            op = INSTR_STORE_I;
-#else
-            op = INSTR_STORE_ENT;
+    if      (vtype == TYPE_FLOAT   && what->vtype == TYPE_INTEGER)
+        op = INSTR_CONV_ITOF;
+    else if (vtype == TYPE_INTEGER && what->vtype == TYPE_FLOAT)
+        op = INSTR_CONV_FTOI;
+    else
 #endif
-            break;
-        default:
-            /* Unknown type */
-            return false;
-    }
+        op = type_store_instr[vtype];
+
     return ir_block_create_store_op(self, op, target, what);
 }
 
@@ -886,6 +855,8 @@ 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;
@@ -918,6 +889,8 @@ bool ir_block_create_storep(ir_block *self, ir_value *target, ir_value *what)
             /* Unknown type */
             return false;
     }
+#endif
+
     return ir_block_create_store_op(self, op, target, what);
 }