const backend_instruction *start() const;
backend_instruction *end();
const backend_instruction *end() const;
+
+ bblock_t *next();
+ const bblock_t *next() const;
+ bblock_t *prev();
+ const bblock_t *prev() const;
#endif
struct exec_node link;
return (const struct backend_instruction *)exec_list_get_tail_const(&block->instructions);
}
+static inline struct bblock_t *
+bblock_next(struct bblock_t *block)
+{
+ return (struct bblock_t *)block->link.next;
+}
+
+static inline const struct bblock_t *
+bblock_next_const(const struct bblock_t *block)
+{
+ return (const struct bblock_t *)block->link.next;
+}
+
+static inline struct bblock_t *
+bblock_prev(struct bblock_t *block)
+{
+ return (struct bblock_t *)block->link.prev;
+}
+
+static inline const struct bblock_t *
+bblock_prev_const(const struct bblock_t *block)
+{
+ return (const struct bblock_t *)block->link.prev;
+}
+
#ifdef __cplusplus
inline backend_instruction *
bblock_t::start()
{
return bblock_end_const(this);
}
+
+inline bblock_t *
+bblock_t::next()
+{
+ return bblock_next(this);
+}
+
+inline const bblock_t *
+bblock_t::next() const
+{
+ return bblock_next_const(this);
+}
+
+inline bblock_t *
+bblock_t::prev()
+{
+ return bblock_prev(this);
+}
+
+inline const bblock_t *
+bblock_t::prev() const
+{
+ return bblock_prev_const(this);
+}
#endif
struct cfg_t {
continue;
backend_instruction *if_inst = NULL, *else_inst = NULL;
- backend_instruction *prev_inst = ((bblock_t *)endif_block->link.prev)->end();
+ backend_instruction *prev_inst = endif_block->prev()->end();
if (prev_inst->opcode == BRW_OPCODE_ELSE) {
else_inst = prev_inst;
- else_block = (bblock_t *)endif_block->link.prev;
+ else_block = endif_block->prev();
found = true;
if (else_block->start_ip == else_block->end_ip)
- prev_inst = ((bblock_t *)else_block->link.prev)->end();
+ prev_inst = else_block->prev()->end();
}
if (prev_inst->opcode == BRW_OPCODE_IF) {
if_inst = prev_inst;
- if_block = else_block != NULL ? (bblock_t *)else_block->link.prev
- : (bblock_t *)endif_block->link.prev;
+ if_block = else_block != NULL ? else_block->prev()
+ : endif_block->prev();
found = true;
} else {
/* Don't remove the ENDIF if we didn't find a dead IF. */
if (if_inst) {
if (if_block->start_ip == if_block->end_ip) {
- earlier_block = (bblock_t *)if_block->link.prev;
+ earlier_block = if_block->prev();
} else {
earlier_block = if_block;
}
if (endif_inst) {
if (endif_block->start_ip == endif_block->end_ip) {
- later_block = (bblock_t *)endif_block->link.next;
+ later_block = endif_block->next();
} else {
later_block = endif_block;
}
* __next block pointer was pointing to.
*/
if (endif_block != later_block) {
- __next = (bblock_t *)earlier_block->link.next;
+ __next = earlier_block->next();
}
}
jump_inst->opcode != BRW_OPCODE_CONTINUE)
continue;
- fs_inst *if_inst = (fs_inst *)((bblock_t *)block->link.prev)->end();
+ fs_inst *if_inst = (fs_inst *)block->prev()->end();
if (if_inst->opcode != BRW_OPCODE_IF)
continue;
- fs_inst *endif_inst = (fs_inst *)((bblock_t *)block->link.next)->start();
+ fs_inst *endif_inst = (fs_inst *)block->next()->start();
if (endif_inst->opcode != BRW_OPCODE_ENDIF)
continue;
bblock_t *jump_block = block;
- bblock_t *if_block = (bblock_t *)jump_block->link.prev;
- bblock_t *endif_block = (bblock_t *)jump_block->link.next;
+ bblock_t *if_block = jump_block->prev();
+ bblock_t *endif_block = jump_block->next();
/* For Sandybridge with IF with embedded comparison we need to emit an
* instruction to set the flag register.
bblock_t *earlier_block = if_block;
if (if_block->start_ip == if_block->end_ip) {
- earlier_block = (bblock_t *)if_block->link.prev;
+ earlier_block = if_block->prev();
}
if_inst->remove(if_block);
bblock_t *later_block = endif_block;
if (endif_block->start_ip == endif_block->end_ip) {
- later_block = (bblock_t *)endif_block->link.next;
+ later_block = endif_block->next();
}
endif_inst->remove(endif_block);
/* Skip the first block, since we don't want to count the do the calling
* function found.
*/
- for (block = (bblock_t *)block->link.next;
+ for (block = block->next();
depth > 0;
- block = (bblock_t *)block->link.next) {
+ block = block->next()) {
if (block->start()->opcode == BRW_OPCODE_DO)
depth++;
if (block->end()->opcode == BRW_OPCODE_WHILE) {
fs_inst *else_mov[MAX_MOVS] = { NULL };
fs_inst *then_mov[MAX_MOVS] = { NULL };
- bblock_t *then_block = (bblock_t *)block->link.next;
- bblock_t *else_block = (bblock_t *)block->else_block->link.next;
+ bblock_t *then_block = block->next();
+ bblock_t *else_block = block->else_block->next();
int movs = count_movs_from_if(then_mov, else_mov, then_block, else_block);
static void
adjust_later_block_ips(bblock_t *start_block, int ip_adjustment)
{
- for (bblock_t *block_iter = (bblock_t *)start_block->link.next;
+ for (bblock_t *block_iter = start_block->next();
!block_iter->link.is_tail_sentinel();
- block_iter = (bblock_t *)block_iter->link.next) {
+ block_iter = block_iter->next()) {
block_iter->start_ip += ip_adjustment;
block_iter->end_ip += ip_adjustment;
}