Lines Matching refs:ctx
108 schedule(struct ir3_postsched_ctx *ctx, struct ir3_instruction *instr)
110 assert(ctx->block == instr->block);
127 ctx->ip = MAX2(ctx->ip, n->earliest_ip) + delay_cycles;
133 child->earliest_ip = MAX2(child->earliest_ip, ctx->ip + delay);
138 dag_prune_head(ctx->dag, &n->dag);
144 ctx->ss_delay = soft_ss_delay(instr);
146 ctx->ss_delay = 0;
147 } else if (ctx->ss_delay > 0) {
148 ctx->ss_delay--;
152 ctx->sy_delay = soft_sy_delay(instr, ctx->block->shader);
154 ctx->sy_delay = 0;
155 } else if (ctx->sy_delay > 0) {
156 ctx->sy_delay--;
161 dump_state(struct ir3_postsched_ctx *ctx)
166 foreach_sched_node (n, &ctx->dag->heads) {
179 node_delay(struct ir3_postsched_ctx *ctx, struct ir3_postsched_node *n)
181 return MAX2(n->earliest_ip, ctx->ip) - ctx->ip;
185 node_delay_soft(struct ir3_postsched_ctx *ctx, struct ir3_postsched_node *n)
187 unsigned delay = node_delay(ctx, n);
193 delay = MAX2(delay, ctx->ss_delay);
195 delay = MAX2(delay, ctx->sy_delay);
202 choose_instr(struct ir3_postsched_ctx *ctx)
206 dump_state(ctx);
208 foreach_sched_node (n, &ctx->dag->heads) {
225 foreach_sched_node (n, &ctx->dag->heads) {
239 foreach_sched_node (n, &ctx->dag->heads) {
240 unsigned d = node_delay(ctx, n);
258 foreach_sched_node (n, &ctx->dag->heads) {
259 unsigned d = node_delay_soft(ctx, n);
283 foreach_sched_node (n, &ctx->dag->heads) {
284 unsigned d = node_delay_soft(ctx, n);
313 foreach_sched_node (n, &ctx->dag->heads) {
314 unsigned d = node_delay(ctx, n);
330 foreach_sched_node (n, &ctx->dag->heads) {
344 struct ir3_postsched_ctx *ctx;
498 calculate_forward_deps(struct ir3_postsched_ctx *ctx)
501 .ctx = ctx,
503 .merged = ctx->v->mergedregs,
506 foreach_instr (instr, &ctx->unscheduled_list) {
512 calculate_reverse_deps(struct ir3_postsched_ctx *ctx)
515 .ctx = ctx,
517 .merged = ctx->v->mergedregs,
520 foreach_instr_rev (instr, &ctx->unscheduled_list) {
526 sched_node_init(struct ir3_postsched_ctx *ctx, struct ir3_instruction *instr)
529 rzalloc(ctx->mem_ctx, struct ir3_postsched_node);
531 dag_init_node(ctx->dag, &n->dag);
553 sched_dag_init(struct ir3_postsched_ctx *ctx)
555 ctx->mem_ctx = ralloc_context(NULL);
557 ctx->dag = dag_create(ctx->mem_ctx);
559 foreach_instr (instr, &ctx->unscheduled_list)
560 sched_node_init(ctx, instr);
562 calculate_forward_deps(ctx);
563 calculate_reverse_deps(ctx);
571 util_dynarray_init(&kills, ctx->mem_ctx);
578 util_dynarray_init(&inputs, ctx->mem_ctx);
586 foreach_instr (instr, &ctx->unscheduled_list) {
625 dag_traverse_bottom_up(ctx->dag, sched_dag_max_delay_cb, NULL);
629 sched_dag_destroy(struct ir3_postsched_ctx *ctx)
631 ralloc_free(ctx->mem_ctx);
632 ctx->mem_ctx = NULL;
633 ctx->dag = NULL;
637 sched_block(struct ir3_postsched_ctx *ctx, struct ir3_block *block)
639 ctx->block = block;
640 ctx->sy_delay = 0;
641 ctx->ss_delay = 0;
647 list_replace(&block->instr_list, &ctx->unscheduled_list);
653 foreach_instr_safe (instr, &ctx->unscheduled_list) {
665 sched_dag_init(ctx);
676 foreach_instr_safe (instr, &ctx->unscheduled_list)
678 schedule(ctx, instr);
680 foreach_instr_safe (instr, &ctx->unscheduled_list)
682 schedule(ctx, instr);
684 while (!list_is_empty(&ctx->unscheduled_list)) {
685 struct ir3_instruction *instr = choose_instr(ctx);
687 unsigned delay = node_delay(ctx, instr->data);
692 schedule(ctx, instr);
695 sched_dag_destroy(ctx);
747 struct ir3_postsched_ctx ctx = {
755 sched_block(&ctx, block);