- struct list_head depth_list; /* depth sorted unscheduled instrs */
- struct ir3_instruction *scheduled; /* last scheduled instr XXX remove*/
- struct ir3_instruction *addr; /* current a0.x user, if any */
- struct ir3_instruction *pred; /* current p0.x user, if any */
- int live_values; /* estimate of current live values */
- bool error;
-};
-
-static bool is_scheduled(struct ir3_instruction *instr)
-{
- return !!(instr->flags & IR3_INSTR_MARK);
-}
-
-static bool is_sfu_or_mem(struct ir3_instruction *instr)
-{
- return is_sfu(instr) || is_mem(instr);
-}
-
-static void
-unuse_each_src(struct ir3_sched_ctx *ctx, struct ir3_instruction *instr)
-{
- struct ir3_instruction *src;
-
- foreach_ssa_src_n(src, n, instr) {
- if (__is_false_dep(instr, n))
- continue;
- if (instr->block != src->block)
- continue;
- if ((src->opc == OPC_META_FI) || (src->opc == OPC_META_FO)) {
- unuse_each_src(ctx, src);
- } else {
- debug_assert(src->use_count > 0);
-
- if (--src->use_count == 0) {
- ctx->live_values -= dest_regs(src);
- debug_assert(ctx->live_values >= 0);
- }
- }
- }
-}
-
-static void clear_cache(struct ir3_sched_ctx *ctx, struct ir3_instruction *instr);
-static void use_instr(struct ir3_instruction *instr);
-
-/* transfers a use-count to new instruction, for cases where we
- * "spill" address or predicate. Note this might cause the
- * previous instruction that loaded a0.x/p0.x to become live
- * again, when we previously thought it was dead.
- */
-static void
-transfer_use(struct ir3_sched_ctx *ctx, struct ir3_instruction *orig_instr,
- struct ir3_instruction *new_instr)
-{
- struct ir3_instruction *src;
-
- debug_assert(is_scheduled(orig_instr));
-
- foreach_ssa_src_n(src, n, new_instr) {
- if (__is_false_dep(new_instr, n))
- continue;
- ctx->live_values += dest_regs(src);
- use_instr(src);
- }
-
- clear_cache(ctx, orig_instr);
-}
-
-static void
-use_each_src(struct ir3_instruction *instr)
-{
- struct ir3_instruction *src;
-
- foreach_ssa_src_n(src, n, instr) {
- if (__is_false_dep(instr, n))
- continue;
- use_instr(src);
- }
-}
-
-static void
-use_instr(struct ir3_instruction *instr)
-{
- if ((instr->opc == OPC_META_FI) || (instr->opc == OPC_META_FO)) {
- use_each_src(instr);
- } else {
- instr->use_count++;
- }
-}