};
#endif
+#define foreach_inst_in_block(__type, __inst, __block) \
+ for (__type *__inst = (__type *)__block->start; \
+ __inst != __block->end->next; \
+ __inst = (__type *)__inst->next)
+
+#define foreach_inst_in_block_reverse(__type, __inst, __block) \
+ for (__type *__inst = (__type *)__block->end; \
+ __inst != __block->start->prev; \
+ __inst = (__type *)__inst->prev)
+
#endif /* BRW_CFG_H */
for (int b = 0; b < cfg->num_blocks; b++) {
bblock_t *block = cfg->blocks[b];
- for (fs_inst *inst = (fs_inst *)block->start;
- inst != block->end->next;
- inst = (fs_inst *)inst->next) {
+ foreach_inst_in_block(fs_inst, inst, block) {
if (inst->dst.file != GRF)
continue;
{
bool progress = false;
- for (fs_inst *inst = (fs_inst *)block->start;
- inst != block->end->next;
- inst = (fs_inst *)inst->next) {
-
+ foreach_inst_in_block(fs_inst, inst, block) {
/* Try propagating into this instruction. */
for (int i = 0; i < inst->sources; i++) {
if (inst->src[i].file != GRF)
void *cse_ctx = ralloc_context(NULL);
int ip = block->start_ip;
- for (fs_inst *inst = (fs_inst *)block->start;
- inst != block->end->next;
- inst = (fs_inst *) inst->next) {
-
+ foreach_inst_in_block(fs_inst, inst, block) {
/* Skip some cases. */
if (is_expression(inst) && !inst->is_partial_write() &&
(inst->dst.file != HW_REG || inst->dst.is_null()))
memcpy(live, live_intervals->bd[b].liveout,
sizeof(BITSET_WORD) * BITSET_WORDS(num_vars));
- for (fs_inst *inst = (fs_inst *)block->end;
- inst != block->start->prev;
- inst = (fs_inst *)inst->prev) {
+ foreach_inst_in_block_reverse(fs_inst, inst, block) {
if (inst->dst.file == GRF &&
!inst->has_side_effects() &&
!inst->writes_flag()) {
if (b > 0)
assert(cfg->blocks[b - 1]->end_ip == ip - 1);
- for (fs_inst *inst = (fs_inst *)block->start;
- inst != block->end->next;
- inst = (fs_inst *)inst->next) {
-
+ foreach_inst_in_block(fs_inst, inst, block) {
/* Set use[] for this instruction */
for (unsigned int i = 0; i < inst->sources; i++) {
fs_reg reg = inst->src[i];
bool progress = false;
int ip = block->start_ip - 1;
- for (fs_inst *inst = (fs_inst *)block->start;
- inst != block->end->next;
- inst = (fs_inst *) inst->next) {
+ foreach_inst_in_block(fs_inst, inst, block) {
ip++;
if (inst->opcode != BRW_OPCODE_MOV ||
if (b > 0)
assert(cfg->blocks[b - 1]->end_ip == ip - 1);
- for (vec4_instruction *inst = (vec4_instruction *)block->start;
- inst != block->end->next;
- inst = (vec4_instruction *)inst->next) {
-
+ foreach_inst_in_block(vec4_instruction, inst, block) {
/* Set use[] for this instruction */
for (unsigned int i = 0; i < 3; i++) {
if (inst->src[i].file == GRF) {