int i;
for (i = 0; i < pc->num_refs; i += 64)
FREE(pc->refs[i]);
+ FREE(pc->refs);
}
static const char *
for (i = 0; i < pc->num_blocks; ++i)
FREE(pc->bb_list[i]);
-
+ if (pc->root)
+ FREE(pc->root);
if (ret) { /* on success, these will be referenced by nv50_program */
if (pc->emit)
FREE(pc->emit);
ctx->pc = pc;
ctx->insns = CALLOC(NV_PC_MAX_INSTRUCTIONS, sizeof(struct nv_instruction *));
+ if (!ctx->insns) {
+ FREE(ctx);
+ return -1;
+ }
pc->pass_seq++;
ret = pass_generate_phi_movs(ctx, root);
NV50_DBGMSG("REGISTER ALLOCATION - leaving\n");
out:
+ FREE(ctx->insns);
FREE(ctx);
return ret;
}
#define BLD_MAX_PREDS 4
#define BLD_MAX_IMMDS 128
-#define BLD_MAX_COND_NESTING 4
+#define BLD_MAX_COND_NESTING 8
#define BLD_MAX_LOOP_NESTING 4
#define BLD_MAX_CALL_NESTING 2
{
unsigned i;
- for (i = stk->size - 1; i >= 0; --i)
- if (stk->body[i] == val)
+ for (i = stk->size; i > 0; --i)
+ if (stk->body[i - 1] == val)
break;
- if (i < 0)
+ if (!i)
return FALSE;
- if (i != stk->size - 1)
- stk->body[i] = stk->body[stk->size - 1];
+ if (i != stk->size)
+ stk->body[i - 1] = stk->body[stk->size - 1];
--stk->size; /* XXX: old size in REALLOC */
return TRUE;
{
struct nv_basic_block *b = new_basic_block(bld->pc);
+ assert(bld->cond_lvl < BLD_MAX_COND_NESTING);
+
nvbb_attach_block(bld->pc->current_block, b, CFG_EDGE_FORWARD);
bld->join_bb[bld->cond_lvl] = bld->pc->current_block;
struct nv_basic_block *bl = new_basic_block(bld->pc);
struct nv_basic_block *bb = new_basic_block(bld->pc);
+ assert(bld->loop_lvl < BLD_MAX_LOOP_NESTING);
+
bld->loop_bb[bld->loop_lvl] = bl;
bld->brkt_bb[bld->loop_lvl] = bb;