]> de.git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
ir_block_create_storep for storing through pointers, the IR does not implicitly creat...
authorWolfgang Bumiller <wolfgang.linux@bumiller.com>
Tue, 1 May 2012 09:58:52 +0000 (11:58 +0200)
committerWolfgang Bumiller <wolfgang.linux@bumiller.com>
Tue, 1 May 2012 09:58:52 +0000 (11:58 +0200)
ir.c
ir.h

diff --git a/ir.c b/ir.c
index f2e0cae171946535fd153c76b5875cc328533313..7e6645979e43ad4372c26b6207b8bd1fbf0f892a 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -623,6 +623,56 @@ bool ir_block_create_store(ir_block *self, ir_value *target, ir_value *what)
             op = INSTR_STORE_ENT;
 #endif
             break;
+        default:
+            /* Unknown type */
+            return false;
+    }
+    return ir_block_create_store_op(self, op, target, what);
+}
+
+bool ir_block_create_storep(ir_block *self, ir_value *target, ir_value *what)
+{
+    int op = 0;
+    int vtype;
+    if (target->vtype == TYPE_VARIANT)
+        vtype = what->vtype;
+    else
+        vtype = target->vtype;
+
+    if (vtype != what->vtype)
+    {
+        /* Cannot implicitly convert when storing through a pointer */
+        return false;
+    }
+
+    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;
+#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;
     }
     return ir_block_create_store_op(self, op, target, what);
 }
diff --git a/ir.h b/ir.h
index 592f69c48e83a9b213b8bf646977ed48229c2ce6..bcc590b52c424b71ac74779a56b425b50b1163dd 100644 (file)
--- a/ir.h
+++ b/ir.h
@@ -150,6 +150,7 @@ ir_value* ir_block_create_binop(ir_block*, const char *label, int op,
                                 ir_value *left, ir_value *right);
 bool GMQCC_WARN ir_block_create_store_op(ir_block*, int op, ir_value *target, ir_value *what);
 bool GMQCC_WARN ir_block_create_store(ir_block*, ir_value *target, ir_value *what);
+bool GMQCC_WARN ir_block_create_storep(ir_block*, ir_value *target, ir_value *what);
 
 ir_value* ir_block_create_add(ir_block*, const char *label, ir_value *l, ir_value *r);
 ir_value* ir_block_create_sub(ir_block*, const char *label, ir_value *l, ir_value *r);