ast_expression_common *elemtype = &self->expression.next->expression;
int vtype = elemtype->vtype;
+ func->flags |= IR_FLAG_HAS_ARRAYS;
+
if (param) {
compile_error(ast_ctx(self), "array-parameters are not supported");
return false;
if (self->irblock_from) {
/* we already tried once, this is the callback */
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);
return false;
}
}
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);
return false;
}
mem_d(self);
return NULL;
}
+ self->flags = 0;
+
self->owner = owner;
self->context.file = "<@no context>";
self->context.line = 0;
bool ir_block_create_goto(ir_block *self, lex_ctx ctx, ir_block *to)
{
- ir_instr *in;
- if (!ir_check_unreachable(self))
- 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;
+ self->owner->flags |= IR_FLAG_HAS_GOTO;
+ return ir_block_create_jump(self, ctx, to);
}
ir_instr* ir_block_create_phi(ir_block *self, lex_ctx ctx, const char *label, int ot)
if (!vec_ir_value_find(block->living, v->memberof, NULL))
continue;
}
+ self->flags |= IR_FLAG_HAS_UNINITIALIZED;
if (irwarning(v->context, WARN_USED_UNINITIALIZED,
"variable `%s` may be used uninitialized in this function", v->name))
{
int *params;
ir_block **blocks;
+ uint32_t flags;
+
int builtin;
ir_value *value;
struct ir_builder_s *owner;
} 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);
void ir_function_delete(ir_function*);