basic CALL translation: to be refined

This commit is contained in:
Wolfgang Bumiller 2012-07-03 22:47:01 +02:00
parent e8cc27df5b
commit e965ffb9df

37
ir.c
View file

@ -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;
}