mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-31 03:50:36 +00:00
Ignore generating a return instruction in accumulated functions, eventually we'll have a way to merge these into one function but for now the RETURN is a waste.
This commit is contained in:
parent
dd33f4e498
commit
97217b55d1
3 changed files with 9 additions and 0 deletions
2
ast.c
2
ast.c
|
@ -1879,6 +1879,8 @@ bool ast_function_codegen(ast_function *self, ir_builder *ir)
|
|||
for (i = 0; i < vec_size(ec->params); i++)
|
||||
vec_push(call->params, (ast_expression*)ec->params[i]);
|
||||
vec_push(vec_last(self->blocks)->exprs, (ast_expression*)call);
|
||||
|
||||
self->ir_func->flags |= IR_FLAG_ACCUMULATE;
|
||||
}
|
||||
|
||||
for (i = 0; i < vec_size(self->blocks); ++i) {
|
||||
|
|
6
ir.c
6
ir.c
|
@ -1583,7 +1583,13 @@ bool ir_block_create_return(ir_block *self, lex_ctx_t ctx, ir_value *v)
|
|||
ir_instr *in;
|
||||
if (!ir_check_unreachable(self))
|
||||
return false;
|
||||
|
||||
self->final = true;
|
||||
|
||||
/* can eliminate the return instructions for accumulation */
|
||||
if (self->owner->flags & IR_FLAG_ACCUMULATE)
|
||||
return true;
|
||||
|
||||
self->is_return = true;
|
||||
in = ir_instr_new(ctx, self, INSTR_RETURN);
|
||||
if (!in)
|
||||
|
|
1
ir.h
1
ir.h
|
@ -232,6 +232,7 @@ typedef struct ir_function_s
|
|||
#define IR_FLAG_HAS_GOTO (1<<3)
|
||||
#define IR_FLAG_INCLUDE_DEF (1<<4)
|
||||
#define IR_FLAG_ERASEABLE (1<<5)
|
||||
#define IR_FLAG_ACCUMULATE (1<<6)
|
||||
#define IR_FLAG_MASK_NO_OVERLAP (IR_FLAG_HAS_ARRAYS | IR_FLAG_HAS_UNINITIALIZED)
|
||||
#define IR_FLAG_MASK_NO_LOCAL_TEMPS (IR_FLAG_HAS_ARRAYS | IR_FLAG_HAS_UNINITIALIZED)
|
||||
|
||||
|
|
Loading…
Reference in a new issue