summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2016-07-08 15:24:34 -0700
committerEric Anholt <[email protected]>2016-07-12 15:47:25 -0700
commitd3cdbf6fd817ae5e7a8a72bcc3f43cc1b04a709b (patch)
treeab412a1f54b31304e5d0ed1df2d5e4e188916d52 /src
parent6858f059246b2cf6b969b050154dcb7307a03833 (diff)
vc4: Add a "qir_for_each_inst_inorder" macro and use it in many places.
We have the prior list_foreach() all over the code, but I need to move where instructions live as part of adding support for control flow. Start by just converting to a helper iterator macro. (The simpler "qir_for_each_inst()" will be used for the for-each-inst-in-a-block iterator macro later)
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/vc4/vc4_opt_algebraic.c2
-rw-r--r--src/gallium/drivers/vc4/vc4_opt_constant_folding.c2
-rw-r--r--src/gallium/drivers/vc4/vc4_opt_copy_propagation.c2
-rw-r--r--src/gallium/drivers/vc4/vc4_opt_small_immediates.c2
-rw-r--r--src/gallium/drivers/vc4/vc4_opt_vpm.c4
-rw-r--r--src/gallium/drivers/vc4/vc4_program.c2
-rw-r--r--src/gallium/drivers/vc4/vc4_qir.h3
-rw-r--r--src/gallium/drivers/vc4/vc4_qir_lower_uniforms.c4
-rw-r--r--src/gallium/drivers/vc4/vc4_qir_validate.c2
-rw-r--r--src/gallium/drivers/vc4/vc4_qpu_emit.c2
-rw-r--r--src/gallium/drivers/vc4/vc4_register_allocate.c4
-rw-r--r--src/gallium/drivers/vc4/vc4_reorder_uniforms.c2
12 files changed, 17 insertions, 14 deletions
diff --git a/src/gallium/drivers/vc4/vc4_opt_algebraic.c b/src/gallium/drivers/vc4/vc4_opt_algebraic.c
index b8ce377ff6b..01ad05d2759 100644
--- a/src/gallium/drivers/vc4/vc4_opt_algebraic.c
+++ b/src/gallium/drivers/vc4/vc4_opt_algebraic.c
@@ -143,7 +143,7 @@ qir_opt_algebraic(struct vc4_compile *c)
{
bool progress = false;
- list_for_each_entry(struct qinst, inst, &c->instructions, link) {
+ qir_for_each_inst_inorder(inst, c) {
switch (inst->op) {
case QOP_FMIN:
if (is_1f(c, inst->src[1]) &&
diff --git a/src/gallium/drivers/vc4/vc4_opt_constant_folding.c b/src/gallium/drivers/vc4/vc4_opt_constant_folding.c
index 15ec9f07260..7ff91615545 100644
--- a/src/gallium/drivers/vc4/vc4_opt_constant_folding.c
+++ b/src/gallium/drivers/vc4/vc4_opt_constant_folding.c
@@ -99,7 +99,7 @@ qir_opt_constant_folding(struct vc4_compile *c)
{
bool progress = false;
- list_for_each_entry(struct qinst, inst, &c->instructions, link) {
+ qir_for_each_inst_inorder(inst, c) {
if (constant_fold(c, inst))
progress = true;
}
diff --git a/src/gallium/drivers/vc4/vc4_opt_copy_propagation.c b/src/gallium/drivers/vc4/vc4_opt_copy_propagation.c
index 0eee5c34e1d..a180f040b54 100644
--- a/src/gallium/drivers/vc4/vc4_opt_copy_propagation.c
+++ b/src/gallium/drivers/vc4/vc4_opt_copy_propagation.c
@@ -40,7 +40,7 @@ qir_opt_copy_propagation(struct vc4_compile *c)
bool progress = false;
bool debug = false;
- list_for_each_entry(struct qinst, inst, &c->instructions, link) {
+ qir_for_each_inst_inorder(inst, c) {
int nsrc = qir_get_op_nsrc(inst->op);
for (int i = 0; i < nsrc; i++) {
if (inst->src[i].file != QFILE_TEMP)
diff --git a/src/gallium/drivers/vc4/vc4_opt_small_immediates.c b/src/gallium/drivers/vc4/vc4_opt_small_immediates.c
index e61562171aa..4c105f37344 100644
--- a/src/gallium/drivers/vc4/vc4_opt_small_immediates.c
+++ b/src/gallium/drivers/vc4/vc4_opt_small_immediates.c
@@ -38,7 +38,7 @@ qir_opt_small_immediates(struct vc4_compile *c)
{
bool progress = false;
- list_for_each_entry(struct qinst, inst, &c->instructions, link) {
+ qir_for_each_inst_inorder(inst, c) {
/* The small immediate value sits in the raddr B field, so we
* can't have 2 small immediates in one instruction (unless
* they're the same value, but that should be optimized away
diff --git a/src/gallium/drivers/vc4/vc4_opt_vpm.c b/src/gallium/drivers/vc4/vc4_opt_vpm.c
index d31b673bd63..e2249bd048e 100644
--- a/src/gallium/drivers/vc4/vc4_opt_vpm.c
+++ b/src/gallium/drivers/vc4/vc4_opt_vpm.c
@@ -44,7 +44,7 @@ qir_opt_vpm(struct vc4_compile *c)
uint32_t vpm_write_count = 0;
memset(&use_count, 0, sizeof(use_count));
- list_for_each_entry(struct qinst, inst, &c->instructions, link) {
+ qir_for_each_inst_inorder(inst, c) {
switch (inst->dst.file) {
case QFILE_VPM:
vpm_writes[vpm_write_count++] = inst;
@@ -64,7 +64,7 @@ qir_opt_vpm(struct vc4_compile *c)
/* For instructions reading from a temporary that contains a VPM read
* result, try to move the instruction up in place of the VPM read.
*/
- list_for_each_entry(struct qinst, inst, &c->instructions, link) {
+ qir_for_each_inst_inorder(inst, c) {
if (!inst)
continue;
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c
index 20e2850e625..0a231b2f6e8 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -2003,7 +2003,7 @@ vc4_get_compiled_shader(struct vc4_context *vc4, enum qstage stage,
bool input_live[c->num_input_slots];
memset(input_live, 0, sizeof(input_live));
- list_for_each_entry(struct qinst, inst, &c->instructions, link) {
+ qir_for_each_inst_inorder(inst, c) {
for (int i = 0; i < qir_get_op_nsrc(inst->op); i++) {
if (inst->src[i].file == QFILE_VARY)
input_live[inst->src[i].index] = true;
diff --git a/src/gallium/drivers/vc4/vc4_qir.h b/src/gallium/drivers/vc4/vc4_qir.h
index 2f4b71a3dfa..315f403e43b 100644
--- a/src/gallium/drivers/vc4/vc4_qir.h
+++ b/src/gallium/drivers/vc4/vc4_qir.h
@@ -719,4 +719,7 @@ qir_LOAD_IMM(struct vc4_compile *c, uint32_t val)
qir_reg(QFILE_LOAD_IMM, val), c->undef));
}
+#define qir_for_each_inst_inorder(inst, c) \
+ list_for_each_entry(struct qinst, inst, &c->instructions, link)
+
#endif /* VC4_QIR_H */
diff --git a/src/gallium/drivers/vc4/vc4_qir_lower_uniforms.c b/src/gallium/drivers/vc4/vc4_qir_lower_uniforms.c
index 927268d71ef..9f782dfc7df 100644
--- a/src/gallium/drivers/vc4/vc4_qir_lower_uniforms.c
+++ b/src/gallium/drivers/vc4/vc4_qir_lower_uniforms.c
@@ -118,7 +118,7 @@ qir_lower_uniforms(struct vc4_compile *c)
* than one uniform referenced, and add those uniform values to the
* ht.
*/
- list_for_each_entry(struct qinst, inst, &c->instructions, link) {
+ qir_for_each_inst_inorder(inst, c) {
uint32_t nsrc = qir_get_op_nsrc(inst->op);
if (qir_get_instruction_uniform_count(inst) <= 1)
@@ -154,7 +154,7 @@ qir_lower_uniforms(struct vc4_compile *c)
struct qinst *mov = qir_inst(QOP_MOV, temp, unif, c->undef);
list_add(&mov->link, &c->instructions);
c->defs[temp.index] = mov;
- list_for_each_entry(struct qinst, inst, &c->instructions, link) {
+ qir_for_each_inst_inorder(inst, c) {
uint32_t nsrc = qir_get_op_nsrc(inst->op);
uint32_t count = qir_get_instruction_uniform_count(inst);
diff --git a/src/gallium/drivers/vc4/vc4_qir_validate.c b/src/gallium/drivers/vc4/vc4_qir_validate.c
index da6457c75b3..e8d4372f19f 100644
--- a/src/gallium/drivers/vc4/vc4_qir_validate.c
+++ b/src/gallium/drivers/vc4/vc4_qir_validate.c
@@ -53,7 +53,7 @@ void qir_validate(struct vc4_compile *c)
fail_instr(c, def, "SSA def with condition");
}
- list_for_each_entry(struct qinst, inst, &c->instructions, link) {
+ qir_for_each_inst_inorder(inst, c) {
switch (inst->dst.file) {
case QFILE_TEMP:
if (inst->dst.index >= c->num_temps)
diff --git a/src/gallium/drivers/vc4/vc4_qpu_emit.c b/src/gallium/drivers/vc4/vc4_qpu_emit.c
index 794757e6d18..1fd151acac2 100644
--- a/src/gallium/drivers/vc4/vc4_qpu_emit.c
+++ b/src/gallium/drivers/vc4/vc4_qpu_emit.c
@@ -213,7 +213,7 @@ vc4_generate_code(struct vc4_context *vc4, struct vc4_compile *c)
break;
}
- list_for_each_entry(struct qinst, qinst, &c->instructions, link) {
+ qir_for_each_inst_inorder(qinst, c) {
#if 0
fprintf(stderr, "translating qinst to qpu: ");
qir_dump_inst(qinst);
diff --git a/src/gallium/drivers/vc4/vc4_register_allocate.c b/src/gallium/drivers/vc4/vc4_register_allocate.c
index bca36c3e7f4..bb5a396ca2d 100644
--- a/src/gallium/drivers/vc4/vc4_register_allocate.c
+++ b/src/gallium/drivers/vc4/vc4_register_allocate.c
@@ -198,7 +198,7 @@ vc4_register_allocate(struct vc4_context *vc4, struct vc4_compile *c)
/* Compute the live ranges so we can figure out interference.
*/
uint32_t ip = 0;
- list_for_each_entry(struct qinst, inst, &c->instructions, link) {
+ qir_for_each_inst_inorder(inst, c) {
if (inst->dst.file == QFILE_TEMP) {
def[inst->dst.index] = MIN2(ip, def[inst->dst.index]);
use[inst->dst.index] = ip;
@@ -242,7 +242,7 @@ vc4_register_allocate(struct vc4_context *vc4, struct vc4_compile *c)
sizeof(class_bits));
ip = 0;
- list_for_each_entry(struct qinst, inst, &c->instructions, link) {
+ qir_for_each_inst_inorder(inst, c) {
if (qir_writes_r4(inst)) {
/* This instruction writes r4 (and optionally moves
* its result to a temp), so nothing else can be
diff --git a/src/gallium/drivers/vc4/vc4_reorder_uniforms.c b/src/gallium/drivers/vc4/vc4_reorder_uniforms.c
index 85a0c95e851..7d5076f429e 100644
--- a/src/gallium/drivers/vc4/vc4_reorder_uniforms.c
+++ b/src/gallium/drivers/vc4/vc4_reorder_uniforms.c
@@ -43,7 +43,7 @@ qir_reorder_uniforms(struct vc4_compile *c)
uint32_t uniform_index_size = 0;
uint32_t next_uniform = 0;
- list_for_each_entry(struct qinst, inst, &c->instructions, link) {
+ qir_for_each_inst_inorder(inst, c) {
uint32_t new = ~0;
for (int i = 0; i < qir_get_op_nsrc(inst->op); i++) {