(op >= INSTR_LOAD_F && op <= INSTR_LOAD_FNC) ||
(op == INSTR_ADDRESS) ||
(op >= INSTR_NOT_F && op <= INSTR_NOT_FNC) ||
- (op >= INSTR_AND && op <= INSTR_BITOR) );
+ (op >= INSTR_AND && op <= INSTR_BITOR) ||
+ (op >= INSTR_CALL0 && op <= INSTR_CALL8) );
}
bool ir_function_pass_peephole(ir_function *self)
return true;
}
-bool ir_function_pass_tailcall(ir_function *self)
+bool ir_function_pass_tailrecursion(ir_function *self)
{
size_t b, p;
}
if (OPTS_OPTIMIZATION(OPTIM_TAIL_RECURSION)) {
- if (!ir_function_pass_tailcall(self)) {
- irerror(self->context, "tailcall optimization pass broke something in `%s`", self->name);
+ if (!ir_function_pass_tailrecursion(self)) {
+ irerror(self->context, "tail-recursion optimization pass broke something in `%s`", self->name);
return false;
}
}
{
if (str && !*str) {
/* actually dup empty strings */
- char *out = mem_a(1);
+ char *out = (char*)mem_a(1);
*out = 0;
return out;
}
ir_value *out;
ir_instr *in;
if (!ir_check_unreachable(self))
- return false;
+ return NULL;
in = ir_instr_new(ctx, self, VINSTR_PHI);
if (!in)
return NULL;
ir_value *out;
ir_instr *in;
if (!ir_check_unreachable(self))
- return false;
+ return NULL;
in = ir_instr_new(ctx, self, (noreturn ? VINSTR_NRCALL : INSTR_CALL0));
if (!in)
return NULL;
for (i = 0; i < vec_size(self->locals); ++i)
{
+#if 0
if (!OPTS_OPTIMIZATION(OPTIM_LOCALTEMPS))
+#endif
self->locals[i]->unique_life = true;
if (!function_allocator_alloc(&alloc, self->locals[i]))
goto error;
code_push_statement(&stmt, instr->context.line);
retvalue = instr->_ops[0];
- if (retvalue && retvalue->store != store_return && vec_size(retvalue->life))
+ if (retvalue && retvalue->store != store_return && (vec_size(retvalue->life) || retvalue->store == store_global))
{
/* not to be kept in OFS_RETURN */
- if (retvalue->vtype == TYPE_FIELD)
- stmt.opcode = field_store_instr[retvalue->vtype];
+ if (retvalue->vtype == TYPE_FIELD && OPTS_FLAG(ADJUST_VECTOR_FIELDS))
+ stmt.opcode = field_store_instr[retvalue->fieldtype];
else
stmt.opcode = type_store_instr[retvalue->vtype];
stmt.o1.u1 = OFS_RETURN;
ir_function *irfun;
size_t i;
-#ifndef NEW_ALLOC_STRAT
- size_t local_var_end;
-#endif
if (!global->hasvalue || (!global->constval.vfunc))
{
fun.firstlocal = vec_size(code_globals);
-#ifndef NEW_ALLOC_STRAT
- local_var_end = fun.firstlocal;
- for (i = 0; i < vec_size(irfun->locals); ++i) {
- if (!ir_builder_gen_global(ir, irfun->locals[i], true)) {
- irerror(irfun->locals[i]->context, "Failed to generate local %s", irfun->locals[i]->name);
- return false;
- }
- }
- if (vec_size(irfun->locals)) {
- ir_value *last = vec_last(irfun->locals);
- local_var_end = last->code.globaladdr;
- local_var_end += ir_value_sizeof(last);
- }
- for (i = 0; i < vec_size(irfun->values); ++i)
- {
- /* generate code.globaladdr for ssa values */
- ir_value *v = irfun->values[i];
-#if 1
- ir_value_code_setaddr(v, fun.firstlocal + v->code.local);
-#else
- ir_value_code_setaddr(v, local_var_end + v->code.local);
-#endif
- }
-#if 1
- for (i = vec_size(code_globals); i < fun.firstlocal + irfun->allocated_locals; ++i)
- vec_push(code_globals, 0);
-#else
- for (i = 0; i < irfun->allocated_locals; ++i) {
- /* fill the locals with zeros */
- vec_push(code_globals, 0);
- }
-#endif
-
- fun.locals = vec_size(code_globals) - fun.firstlocal;
-#else
fun.locals = irfun->allocated_locals;
for (i = 0; i < vec_size(irfun->locals); ++i) {
if (!ir_builder_gen_global(ir, irfun->locals[i], true)) {
}
ir_value_code_setaddr(irfun->locals[i], fun.firstlocal + irfun->locals[i]->code.local);
}
- for (i = vec_size(code_globals) - fun.firstlocal; i < fun.locals; ++i) {
- vec_push(code_globals, 0);
- }
for (i = 0; i < vec_size(irfun->values); ++i)
{
/* generate code.globaladdr for ssa values */
ir_value *v = irfun->values[i];
ir_value_code_setaddr(v, fun.firstlocal + v->code.local);
}
-#endif
+ for (i = vec_size(code_globals); i < fun.firstlocal + irfun->allocated_locals; ++i)
+ vec_push(code_globals, 0);
if (irfun->builtin)
fun.entry = irfun->builtin+1;
char *component;
size_t len, i;
- if (!name || OPTS_FLAG(SINGLE_VECTOR_DEFS))
+ if (!name || name[0] == '#' || OPTS_FLAG(SINGLE_VECTOR_DEFS))
return;
def.type = TYPE_FLOAT;