From: Wolfgang Bumiller Date: Tue, 3 Jul 2012 20:47:01 +0000 (+0200) Subject: basic CALL translation: to be refined X-Git-Tag: 0.1-rc1~459 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=e965ffb9dfac38923c811d2a1bd9ba02b0d3fa76;p=xonotic%2Fgmqcc.git basic CALL translation: to be refined --- diff --git a/ir.c b/ir.c index 48c4ccf..ff87a80 100644 --- 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; }