summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2014-06-24 12:42:00 -0700
committerMatt Turner <mattst88@gmail.com>2014-07-01 08:55:51 -0700
commitbc2fbbafd216676ccc7c3abd794ecb7dd1fa631f (patch)
treef1765fb6b562078742058b0adc4ce66caf5a4247
parente8e5f0a342505a4d10cbcdee03592c96d286b57c (diff)
downloadexternal_mesa3d-bc2fbbafd216676ccc7c3abd794ecb7dd1fa631f.zip
external_mesa3d-bc2fbbafd216676ccc7c3abd794ecb7dd1fa631f.tar.gz
external_mesa3d-bc2fbbafd216676ccc7c3abd794ecb7dd1fa631f.tar.bz2
i965: Add and use foreach_inst_in_block macros.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
-rw-r--r--src/mesa/drivers/dri/i965/brw_cfg.h10
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp9
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_cse.cpp5
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_dead_code_eliminate.cpp4
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp5
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp4
-rw-r--r--src/mesa/drivers/dri/i965/brw_vec4_live_variables.cpp5
7 files changed, 17 insertions, 25 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_cfg.h b/src/mesa/drivers/dri/i965/brw_cfg.h
index 9466bd2..b55eacb 100644
--- a/src/mesa/drivers/dri/i965/brw_cfg.h
+++ b/src/mesa/drivers/dri/i965/brw_cfg.h
@@ -105,4 +105,14 @@ public:
};
#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 */
diff --git a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
index 3c6e616..184a284 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
@@ -157,9 +157,7 @@ fs_copy_prop_dataflow::setup_initial_values()
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;
@@ -532,10 +530,7 @@ fs_visitor::opt_copy_propagate_local(void *copy_prop_ctx, bblock_t *block,
{
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)
diff --git a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
index 26873b8..e4068fc 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
@@ -173,10 +173,7 @@ fs_visitor::opt_cse_local(bblock_t *block, exec_list *aeb)
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()))
diff --git a/src/mesa/drivers/dri/i965/brw_fs_dead_code_eliminate.cpp b/src/mesa/drivers/dri/i965/brw_fs_dead_code_eliminate.cpp
index 962d8c6..3fefe81 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_dead_code_eliminate.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_dead_code_eliminate.cpp
@@ -51,9 +51,7 @@ fs_visitor::dead_code_eliminate()
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()) {
diff --git a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
index d39724a..0973dc9 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
@@ -144,10 +144,7 @@ fs_live_variables::setup_def_use()
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];
diff --git a/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp b/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp
index 29c8b2e..079eb2e 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp
@@ -34,9 +34,7 @@ opt_saturate_propagation_local(fs_visitor *v, bblock_t *block)
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 ||
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_live_variables.cpp b/src/mesa/drivers/dri/i965/brw_vec4_live_variables.cpp
index 7ffa5fe..5f0b696 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_live_variables.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_live_variables.cpp
@@ -72,10 +72,7 @@ vec4_live_variables::setup_def_use()
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) {