]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
basic CALL translation: to be refined
authorWolfgang Bumiller <wolfgang.linux@bumiller.com>
Tue, 3 Jul 2012 20:47:01 +0000 (22:47 +0200)
committerWolfgang Bumiller <wolfgang.linux@bumiller.com>
Tue, 3 Jul 2012 20:47:01 +0000 (22:47 +0200)
ir.c

diff --git a/ir.c b/ir.c
index 48c4ccf032da0602350408537fc0dab8cd7bc4dc..ff87a80e59c8cd4fe278b4cd6229cd89033bbf35 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -2210,7 +2210,42 @@ tailcall:
              *      generation already. This would even include later
              *      reuse.... probably... :)
              */
-            printf("TODO: call instruction\n");
+            size_t p;
+            ir_value *retvalue;
+
+            for (p = 0; p < instr->params_count; ++p)
+            {
+                ir_value *param = instr->params[p];
+
+                stmt.opcode = INSTR_STORE_F;
+                stmt.o3.u1 = 0;
+
+                stmt.opcode = type_store_instr[param->vtype];
+                stmt.o1.u1 = param->code.globaladdr;
+                stmt.o2.u1 = OFS_PARM0 + 3 * p;
+                if (code_statements_add(stmt) < 0)
+                    return false;
+            }
+            stmt.opcode = INSTR_CALL0 + instr->params_count;
+            if (stmt.opcode > INSTR_CALL8)
+                stmt.opcode = INSTR_CALL8;
+            stmt.o1.u1 = instr->_ops[1]->code.globaladdr;
+            stmt.o2.u1 = 0;
+            stmt.o3.u1 = 0;
+            if (code_statements_add(stmt) < 0)
+                return false;
+
+            retvalue = instr->_ops[0];
+            if (retvalue && retvalue->store != store_return && retvalue->life_count)
+            {
+                /* not to be kept in OFS_RETURN */
+                stmt.opcode = type_store_instr[retvalue->vtype];
+                stmt.o1.u1 = OFS_RETURN;
+                stmt.o2.u1 = retvalue->code.globaladdr;
+                stmt.o3.u1 = 0;
+                if (code_statements_add(stmt) < 0)
+                    return false;
+            }
             return false;
         }