mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-27 06:02:22 +00:00
ir_function now has a flags field - flags are: IR_FLAG_HAS_{ARRAYS,UNINITIALIZED,GOTO}
This commit is contained in:
parent
2382fdee50
commit
7998a98818
3 changed files with 15 additions and 16 deletions
6
ast.c
6
ast.c
|
@ -1317,6 +1317,8 @@ bool ast_local_codegen(ast_value *self, ir_function *func, bool param)
|
||||||
ast_expression_common *elemtype = &self->expression.next->expression;
|
ast_expression_common *elemtype = &self->expression.next->expression;
|
||||||
int vtype = elemtype->vtype;
|
int vtype = elemtype->vtype;
|
||||||
|
|
||||||
|
func->flags |= IR_FLAG_HAS_ARRAYS;
|
||||||
|
|
||||||
if (param) {
|
if (param) {
|
||||||
compile_error(ast_ctx(self), "array-parameters are not supported");
|
compile_error(ast_ctx(self), "array-parameters are not supported");
|
||||||
return false;
|
return false;
|
||||||
|
@ -2856,14 +2858,14 @@ bool ast_goto_codegen(ast_goto *self, ast_function *func, bool lvalue, ir_value
|
||||||
if (self->irblock_from) {
|
if (self->irblock_from) {
|
||||||
/* we already tried once, this is the callback */
|
/* we already tried once, this is the callback */
|
||||||
self->irblock_from->final = false;
|
self->irblock_from->final = false;
|
||||||
if (!ir_block_create_jump(self->irblock_from, ast_ctx(self), self->target->irblock)) {
|
if (!ir_block_create_goto(self->irblock_from, ast_ctx(self), self->target->irblock)) {
|
||||||
compile_error(ast_ctx(self), "failed to generate goto to `%s`", self->name);
|
compile_error(ast_ctx(self), "failed to generate goto to `%s`", self->name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!ir_block_create_jump(func->curblock, ast_ctx(self), self->target->irblock)) {
|
if (!ir_block_create_goto(func->curblock, ast_ctx(self), self->target->irblock)) {
|
||||||
compile_error(ast_ctx(self), "failed to generate goto to `%s`", self->name);
|
compile_error(ast_ctx(self), "failed to generate goto to `%s`", self->name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
19
ir.c
19
ir.c
|
@ -433,6 +433,8 @@ ir_function* ir_function_new(ir_builder* owner, int outtype)
|
||||||
mem_d(self);
|
mem_d(self);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
self->flags = 0;
|
||||||
|
|
||||||
self->owner = owner;
|
self->owner = owner;
|
||||||
self->context.file = "<@no context>";
|
self->context.file = "<@no context>";
|
||||||
self->context.line = 0;
|
self->context.line = 0;
|
||||||
|
@ -1529,20 +1531,8 @@ bool ir_block_create_jump(ir_block *self, lex_ctx ctx, ir_block *to)
|
||||||
|
|
||||||
bool ir_block_create_goto(ir_block *self, lex_ctx ctx, ir_block *to)
|
bool ir_block_create_goto(ir_block *self, lex_ctx ctx, ir_block *to)
|
||||||
{
|
{
|
||||||
ir_instr *in;
|
self->owner->flags |= IR_FLAG_HAS_GOTO;
|
||||||
if (!ir_check_unreachable(self))
|
return ir_block_create_jump(self, ctx, to);
|
||||||
return false;
|
|
||||||
self->final = true;
|
|
||||||
in = ir_instr_new(ctx, self, INSTR_GOTO);
|
|
||||||
if (!in)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
in->bops[0] = to;
|
|
||||||
vec_push(self->instr, in);
|
|
||||||
|
|
||||||
vec_push(self->exits, to);
|
|
||||||
vec_push(to->entries, self);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ir_instr* ir_block_create_phi(ir_block *self, lex_ctx ctx, const char *label, int ot)
|
ir_instr* ir_block_create_phi(ir_block *self, lex_ctx ctx, const char *label, int ot)
|
||||||
|
@ -2232,6 +2222,7 @@ bool ir_function_calculate_liferanges(ir_function *self)
|
||||||
if (!vec_ir_value_find(block->living, v->memberof, NULL))
|
if (!vec_ir_value_find(block->living, v->memberof, NULL))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
self->flags |= IR_FLAG_HAS_UNINITIALIZED;
|
||||||
if (irwarning(v->context, WARN_USED_UNINITIALIZED,
|
if (irwarning(v->context, WARN_USED_UNINITIALIZED,
|
||||||
"variable `%s` may be used uninitialized in this function", v->name))
|
"variable `%s` may be used uninitialized in this function", v->name))
|
||||||
{
|
{
|
||||||
|
|
6
ir.h
6
ir.h
|
@ -237,6 +237,8 @@ typedef struct ir_function_s
|
||||||
int *params;
|
int *params;
|
||||||
ir_block **blocks;
|
ir_block **blocks;
|
||||||
|
|
||||||
|
uint32_t flags;
|
||||||
|
|
||||||
int builtin;
|
int builtin;
|
||||||
|
|
||||||
ir_value *value;
|
ir_value *value;
|
||||||
|
@ -270,6 +272,10 @@ typedef struct ir_function_s
|
||||||
|
|
||||||
struct ir_builder_s *owner;
|
struct ir_builder_s *owner;
|
||||||
} ir_function;
|
} ir_function;
|
||||||
|
#define IR_FLAG_HAS_ARRAYS (1<<1)
|
||||||
|
#define IR_FLAG_HAS_UNINITIALIZED (1<<2)
|
||||||
|
#define IR_FLAG_HAS_GOTO (1<<3)
|
||||||
|
#define IR_FLAG_MASK_NO_OVERLAP (IR_FLAG_HAS_ARRAYS | IR_FLAG_HAS_UNINITIALIZED)
|
||||||
|
|
||||||
ir_function* ir_function_new(struct ir_builder_s *owner, int returntype);
|
ir_function* ir_function_new(struct ir_builder_s *owner, int returntype);
|
||||||
void ir_function_delete(ir_function*);
|
void ir_function_delete(ir_function*);
|
||||||
|
|
Loading…
Reference in a new issue