mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-23 20:33:05 +00:00
VINSTR_NRCALL, translated like any other call for now; to be used to mark a call which never returns, ie the error builtin
This commit is contained in:
parent
2a2c208884
commit
384446316a
4 changed files with 17 additions and 10 deletions
8
ast.c
8
ast.c
|
@ -1640,7 +1640,7 @@ bool ast_store_codegen(ast_store *self, ast_function *func, bool lvalue, ir_valu
|
|||
if (!(*cgen)((ast_expression*)(self->source), func, false, &right))
|
||||
return false;
|
||||
|
||||
call = ir_block_create_call(func->curblock, ast_ctx(self), ast_function_label(func, "store"), funval);
|
||||
call = ir_block_create_call(func->curblock, ast_ctx(self), ast_function_label(func, "store"), funval, false);
|
||||
if (!call)
|
||||
return false;
|
||||
ir_call_param(call, iridx);
|
||||
|
@ -1878,7 +1878,7 @@ bool ast_binstore_codegen(ast_binstore *self, ast_function *func, bool lvalue, i
|
|||
if (!(*cgen)((ast_expression*)(arr->setter), func, true, &funval))
|
||||
return false;
|
||||
|
||||
call = ir_block_create_call(func->curblock, ast_ctx(self), ast_function_label(func, "store"), funval);
|
||||
call = ir_block_create_call(func->curblock, ast_ctx(self), ast_function_label(func, "store"), funval, false);
|
||||
if (!call)
|
||||
return false;
|
||||
ir_call_param(call, iridx);
|
||||
|
@ -2110,7 +2110,7 @@ bool ast_array_index_codegen(ast_array_index *self, ast_function *func, bool lva
|
|||
if (!(*cgen)((ast_expression*)(arr->getter), func, true, &funval))
|
||||
return false;
|
||||
|
||||
call = ir_block_create_call(func->curblock, ast_ctx(self), ast_function_label(func, "fetch"), funval);
|
||||
call = ir_block_create_call(func->curblock, ast_ctx(self), ast_function_label(func, "fetch"), funval, false);
|
||||
if (!call)
|
||||
return false;
|
||||
ir_call_param(call, iridx);
|
||||
|
@ -2905,7 +2905,7 @@ bool ast_call_codegen(ast_call *self, ast_function *func, bool lvalue, ir_value
|
|||
vec_push(params, param);
|
||||
}
|
||||
|
||||
callinstr = ir_block_create_call(func->curblock, ast_ctx(self), ast_function_label(func, "call"), funval);
|
||||
callinstr = ir_block_create_call(func->curblock, ast_ctx(self), ast_function_label(func, "call"), funval, false);
|
||||
if (!callinstr)
|
||||
goto error;
|
||||
|
||||
|
|
7
gmqcc.h
7
gmqcc.h
|
@ -546,7 +546,12 @@ enum {
|
|||
*/
|
||||
VINSTR_PHI,
|
||||
VINSTR_JUMP,
|
||||
VINSTR_COND
|
||||
VINSTR_COND,
|
||||
/* A never returning CALL.
|
||||
* Creating this causes IR blocks to be marked as 'final'.
|
||||
* No-Return-Call
|
||||
*/
|
||||
VINSTR_NRCALL
|
||||
};
|
||||
|
||||
extern prog_section_statement *code_statements;
|
||||
|
|
10
ir.c
10
ir.c
|
@ -1566,11 +1566,11 @@ void ir_phi_add(ir_instr* self, ir_block *b, ir_value *v)
|
|||
}
|
||||
|
||||
/* call related code */
|
||||
ir_instr* ir_block_create_call(ir_block *self, lex_ctx ctx, const char *label, ir_value *func)
|
||||
ir_instr* ir_block_create_call(ir_block *self, lex_ctx ctx, const char *label, ir_value *func, bool noreturn)
|
||||
{
|
||||
ir_value *out;
|
||||
ir_instr *in;
|
||||
in = ir_instr_new(ctx, self, INSTR_CALL0);
|
||||
in = ir_instr_new(ctx, self, (noreturn ? VINSTR_NRCALL : INSTR_CALL0));
|
||||
if (!in)
|
||||
return NULL;
|
||||
out = ir_value_out(self->owner, label, (func->outtype == TYPE_VOID) ? store_return : store_value, func->outtype);
|
||||
|
@ -2793,7 +2793,9 @@ tailcall:
|
|||
goto tailcall;
|
||||
}
|
||||
|
||||
if (instr->opcode >= INSTR_CALL0 && instr->opcode <= INSTR_CALL8) {
|
||||
if ( (instr->opcode >= INSTR_CALL0 && instr->opcode <= INSTR_CALL8)
|
||||
|| instr->opcode == VINSTR_NRCALL)
|
||||
{
|
||||
/* Trivial call translation:
|
||||
* copy all params to OFS_PARM*
|
||||
* if the output's storetype is not store_return,
|
||||
|
@ -3663,7 +3665,7 @@ void ir_instr_dump(ir_instr *in, char *ind,
|
|||
if (in->_ops[1] || in->_ops[2])
|
||||
oprintf(" <- ");
|
||||
}
|
||||
if (in->opcode == INSTR_CALL0) {
|
||||
if (in->opcode == INSTR_CALL0 || in->opcode == VINSTR_NRCALL) {
|
||||
oprintf("CALL%i\t", vec_size(in->params));
|
||||
} else
|
||||
oprintf("%s\t", qc_opname(in->opcode));
|
||||
|
|
2
ir.h
2
ir.h
|
@ -209,7 +209,7 @@ ir_value* ir_block_create_div(ir_block*, lex_ctx, const char *label, ir_value *l
|
|||
ir_instr* ir_block_create_phi(ir_block*, lex_ctx, const char *label, int vtype);
|
||||
ir_value* ir_phi_value(ir_instr*);
|
||||
void ir_phi_add(ir_instr*, ir_block *b, ir_value *v);
|
||||
ir_instr* ir_block_create_call(ir_block*, lex_ctx, const char *label, ir_value *func);
|
||||
ir_instr* ir_block_create_call(ir_block*, lex_ctx, const char *label, ir_value *func, bool noreturn);
|
||||
ir_value* ir_call_value(ir_instr*);
|
||||
void ir_call_param(ir_instr*, ir_value*);
|
||||
|
||||
|
|
Loading…
Reference in a new issue