block_list.make_empty();
blocks = NULL;
num_blocks = 0;
- ip = 0;
- cur = NULL;
+
+ bblock_t *cur = NULL;
+ int ip = 0;
bblock_t *entry = new_block();
bblock_t *cur_if = NULL, *cur_else = NULL, *cur_endif = NULL;
exec_list if_stack, else_stack, do_stack, while_stack;
bblock_t *next;
- set_next_block(entry);
+ set_next_block(&cur, entry, ip);
entry->start = (backend_instruction *) instructions->get_head();
next->start = (backend_instruction *)inst->next;
cur_if->add_successor(mem_ctx, next);
- set_next_block(next);
+ set_next_block(&cur, next, ip);
break;
case BRW_OPCODE_ELSE:
next->start = (backend_instruction *)inst->next;
cur_if->add_successor(mem_ctx, next);
- set_next_block(next);
+ set_next_block(&cur, next, ip);
break;
case BRW_OPCODE_ENDIF: {
cur->end = (backend_instruction *)inst->prev;
cur->add_successor(mem_ctx, cur_endif);
- ip--;
- set_next_block(cur_endif);
- ip++;
+ set_next_block(&cur, cur_endif, ip - 1);
}
backend_instruction *else_inst = NULL;
cur->add_successor(mem_ctx, next);
cur_do = next;
- set_next_block(next);
+ set_next_block(&cur, next, ip);
break;
case BRW_OPCODE_CONTINUE:
if (inst->predicate)
cur->add_successor(mem_ctx, next);
- set_next_block(next);
+ set_next_block(&cur, next, ip);
break;
case BRW_OPCODE_BREAK:
if (inst->predicate)
cur->add_successor(mem_ctx, next);
- set_next_block(next);
+ set_next_block(&cur, next, ip);
break;
case BRW_OPCODE_WHILE:
cur_while->start = (backend_instruction *)inst->next;
cur->add_successor(mem_ctx, cur_do);
- set_next_block(cur_while);
+ set_next_block(&cur, cur_while, ip);
/* Pop the stack so we're in the previous loop */
cur_do = pop_stack(&do_stack);
}
void
-cfg_t::set_next_block(bblock_t *block)
+cfg_t::set_next_block(bblock_t **cur, bblock_t *block, int ip)
{
- if (cur) {
- assert(cur->end->next == block->start);
- cur->end_ip = ip - 1;
+ if (*cur) {
+ assert((*cur)->end->next == block->start);
+ (*cur)->end_ip = ip - 1;
}
block->start_ip = ip;
block->block_num = num_blocks++;
block_list.push_tail(new(mem_ctx) bblock_link(block));
- cur = block;
+ *cur = block;
}
void