v3d: Move "does this instruction have flags" from sched to generic helpers.
authorEric Anholt <eric@anholt.net>
Sat, 29 Dec 2018 19:00:25 +0000 (11:00 -0800)
committerEric Anholt <eric@anholt.net>
Sun, 30 Dec 2018 16:03:51 +0000 (08:03 -0800)
I wanted to reuse it for DCE of flags updates.

src/broadcom/compiler/qpu_schedule.c
src/broadcom/compiler/v3d_compiler.h
src/broadcom/compiler/vir.c
src/broadcom/compiler/vir_opt_dead_code.c
src/broadcom/qpu/qpu_instr.c
src/broadcom/qpu/qpu_instr.h

index 95494a1412a6044c6684606f01df4292e0d3f01b..be794a88c14b20f919ee52b22ac3a5b387fd8ac2 100644 (file)
@@ -246,30 +246,6 @@ process_waddr_deps(struct schedule_state *state, struct schedule_node *n,
         }
 }
 
-static void
-process_cond_deps(struct schedule_state *state, struct schedule_node *n,
-                  enum v3d_qpu_cond cond)
-{
-        if (cond != V3D_QPU_COND_NONE)
-                add_read_dep(state, state->last_sf, n);
-}
-
-static void
-process_pf_deps(struct schedule_state *state, struct schedule_node *n,
-                enum v3d_qpu_pf pf)
-{
-        if (pf != V3D_QPU_PF_NONE)
-                add_write_dep(state, &state->last_sf, n);
-}
-
-static void
-process_uf_deps(struct schedule_state *state, struct schedule_node *n,
-                enum v3d_qpu_uf uf)
-{
-        if (uf != V3D_QPU_UF_NONE)
-                add_write_dep(state, &state->last_sf, n);
-}
-
 /**
  * Common code for dependencies that need to be tracked both forward and
  * backward.
@@ -350,15 +326,6 @@ calculate_deps(struct schedule_state *state, struct schedule_node *n)
                 add_write_dep(state, &state->last_tlb, n);
                 break;
 
-        case V3D_QPU_A_FLAPUSH:
-        case V3D_QPU_A_FLBPUSH:
-        case V3D_QPU_A_VFLA:
-        case V3D_QPU_A_VFLNA:
-        case V3D_QPU_A_VFLB:
-        case V3D_QPU_A_VFLNB:
-                add_read_dep(state, state->last_sf, n);
-                break;
-
         default:
                 break;
         }
@@ -441,12 +408,10 @@ calculate_deps(struct schedule_state *state, struct schedule_node *n)
         if (qinst->uniform != ~0)
                 add_write_dep(state, &state->last_unif, n);
 
-        process_cond_deps(state, n, inst->flags.ac);
-        process_cond_deps(state, n, inst->flags.mc);
-        process_pf_deps(state, n, inst->flags.apf);
-        process_pf_deps(state, n, inst->flags.mpf);
-        process_uf_deps(state, n, inst->flags.auf);
-        process_uf_deps(state, n, inst->flags.muf);
+        if (v3d_qpu_reads_flags(inst))
+                add_read_dep(state, state->last_sf, n);
+        if (v3d_qpu_writes_flags(inst))
+                add_write_dep(state, &state->last_sf, n);
 }
 
 static void
index 2d9167a27a09a66b58f728b12532eab403c955b8..c7f2f148ac02e85bd7bcb34508ff4446aadd472b 100644 (file)
@@ -769,7 +769,6 @@ bool vir_is_tex(struct qinst *inst);
 bool vir_is_add(struct qinst *inst);
 bool vir_is_mul(struct qinst *inst);
 bool vir_is_float_input(struct qinst *inst);
-bool vir_depends_on_flags(struct qinst *inst);
 bool vir_writes_r3(const struct v3d_device_info *devinfo, struct qinst *inst);
 bool vir_writes_r4(const struct v3d_device_info *devinfo, struct qinst *inst);
 struct qreg vir_follow_movs(struct v3d_compile *c, struct qreg reg);
index 8880a2820457230e45ef5e15fb8ce34dfda9dfca..f49140bcb909cc32f0d074c0a7b2f83713783090 100644 (file)
@@ -203,17 +203,6 @@ vir_is_tex(struct qinst *inst)
         return false;
 }
 
-bool
-vir_depends_on_flags(struct qinst *inst)
-{
-        if (inst->qpu.type == V3D_QPU_INSTR_TYPE_BRANCH) {
-                return (inst->qpu.branch.cond != V3D_QPU_BRANCH_COND_ALWAYS);
-        } else {
-                return (inst->qpu.flags.ac != V3D_QPU_COND_NONE &&
-                        inst->qpu.flags.mc != V3D_QPU_COND_NONE);
-        }
-}
-
 bool
 vir_writes_r3(const struct v3d_device_info *devinfo, struct qinst *inst)
 {
index 4aedbb6540f340232fdc3d4ce25382b3eba321f1..9c93846e9b86461cf391d8b5aff988e30873ed5b 100644 (file)
@@ -47,10 +47,7 @@ dce(struct v3d_compile *c, struct qinst *inst)
                 vir_dump_inst(c, inst);
                 fprintf(stderr, "\n");
         }
-        assert(inst->qpu.flags.apf == V3D_QPU_PF_NONE);
-        assert(inst->qpu.flags.mpf == V3D_QPU_PF_NONE);
-        assert(inst->qpu.flags.auf == V3D_QPU_UF_NONE);
-        assert(inst->qpu.flags.muf == V3D_QPU_UF_NONE);
+        assert(!v3d_qpu_writes_flags(&inst->qpu));
         vir_remove_instruction(c, inst);
 }
 
index 08f29a40937b6661dd2149443caf9dbd518ec64f..338a1887f031e7c45b951a412d53d2cb50e0fad0 100644 (file)
@@ -809,3 +809,44 @@ v3d_qpu_sig_writes_address(const struct v3d_device_info *devinfo,
                 sig->ldtlb ||
                 sig->ldtlbu);
 }
+
+bool
+v3d_qpu_reads_flags(const struct v3d_qpu_instr *inst)
+{
+        if (inst->type == V3D_QPU_INSTR_TYPE_BRANCH) {
+                return inst->branch.cond != V3D_QPU_BRANCH_COND_ALWAYS;
+        } else if (inst->type == V3D_QPU_INSTR_TYPE_ALU) {
+                if (inst->flags.ac != V3D_QPU_COND_NONE ||
+                    inst->flags.mc != V3D_QPU_COND_NONE ||
+                    inst->flags.auf != V3D_QPU_UF_NONE ||
+                    inst->flags.muf != V3D_QPU_UF_NONE)
+                        return true;
+
+                switch (inst->alu.add.op) {
+                case V3D_QPU_A_VFLA:
+                case V3D_QPU_A_VFLNA:
+                case V3D_QPU_A_VFLB:
+                case V3D_QPU_A_VFLNB:
+                case V3D_QPU_A_FLAPUSH:
+                case V3D_QPU_A_FLBPUSH:
+                        return true;
+                default:
+                        break;
+                }
+        }
+
+        return false;
+}
+
+bool
+v3d_qpu_writes_flags(const struct v3d_qpu_instr *inst)
+{
+        if (inst->flags.apf != V3D_QPU_PF_NONE ||
+            inst->flags.mpf != V3D_QPU_PF_NONE ||
+            inst->flags.auf != V3D_QPU_UF_NONE ||
+            inst->flags.muf != V3D_QPU_UF_NONE) {
+                return true;
+        }
+
+        return false;
+}
index 49d66ee888f391fe5efcab478c5aa6a061f349b8..0da61fbb5d51769e20f463bb629f24e104e0dc56 100644 (file)
@@ -458,6 +458,8 @@ bool v3d_qpu_uses_mux(const struct v3d_qpu_instr *inst, enum v3d_qpu_mux mux);
 bool v3d_qpu_uses_vpm(const struct v3d_qpu_instr *inst) ATTRIBUTE_CONST;
 bool v3d_qpu_reads_vpm(const struct v3d_qpu_instr *inst) ATTRIBUTE_CONST;
 bool v3d_qpu_writes_vpm(const struct v3d_qpu_instr *inst) ATTRIBUTE_CONST;
+bool v3d_qpu_reads_flags(const struct v3d_qpu_instr *inst) ATTRIBUTE_CONST;
+bool v3d_qpu_writes_flags(const struct v3d_qpu_instr *inst) ATTRIBUTE_CONST;
 bool v3d_qpu_sig_writes_address(const struct v3d_device_info *devinfo,
                                 const struct v3d_qpu_sig *sig) ATTRIBUTE_CONST;