mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-18 22:31:36 +00:00
basic CALL translation: to be refined
This commit is contained in:
parent
e8cc27df5b
commit
e965ffb9df
1 changed files with 36 additions and 1 deletions
37
ir.c
37
ir.c
|
@ -2210,7 +2210,42 @@ tailcall:
|
||||||
* generation already. This would even include later
|
* generation already. This would even include later
|
||||||
* reuse.... probably... :)
|
* 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue