*/
struct ir3_postsched_ctx {
- struct ir3_context *ctx;
+ struct ir3 *ir;
+
+ struct ir3_shader_variant *v;
void *mem_ctx;
struct ir3_block *block; /* the current block */
struct list_head unscheduled_list; /* unscheduled instructions */
- bool error;
-
int sfu_delay;
int tex_delay;
};
}
struct ir3_postsched_deps_state {
- struct ir3_context *ctx;
+ struct ir3_postsched_ctx *ctx;
enum { F, R } direction;
calculate_deps(struct ir3_postsched_deps_state *state,
struct ir3_postsched_node *node)
{
- struct ir3_register *reg;
int b;
/* Add dependencies on instructions that previously (or next,
/* And then after we update the state for what this instruction
* wrote:
*/
- reg = node->instr->regs[0];
+ struct ir3_register *reg = node->instr->regs[0];
if (reg->flags & IR3_REG_RELATIV) {
/* mark the entire array as written: */
struct ir3_array *arr = ir3_lookup_array(state->ctx->ir, reg->array.id);
calculate_forward_deps(struct ir3_postsched_ctx *ctx)
{
struct ir3_postsched_deps_state state = {
- .ctx = ctx->ctx,
+ .ctx = ctx,
.direction = F,
- .merged = ctx->ctx->compiler->gpu_id >= 600,
+ .merged = ctx->ir->compiler->gpu_id >= 600,
};
foreach_instr (instr, &ctx->unscheduled_list) {
calculate_reverse_deps(struct ir3_postsched_ctx *ctx)
{
struct ir3_postsched_deps_state state = {
- .ctx = ctx->ctx,
+ .ctx = ctx,
.direction = R,
- .merged = ctx->ctx->compiler->gpu_id >= 600,
+ .merged = ctx->ir->compiler->gpu_id >= 600,
};
foreach_instr_rev (instr, &ctx->unscheduled_list) {
*/
foreach_instr (instr, &ctx->unscheduled_list) {
struct ir3_postsched_node *n = instr->data;
- struct ir3_instruction *src;
foreach_ssa_src_n (src, i, instr) {
if (src->block != instr->block)
sched_block(struct ir3_postsched_ctx *ctx, struct ir3_block *block)
{
ctx->block = block;
+ ctx->tex_delay = 0;
+ ctx->sfu_delay = 0;
/* move all instructions to the unscheduled list, and
* empty the block's instruction list (to which we will
schedule(ctx, instr);
while (!list_is_empty(&ctx->unscheduled_list)) {
- struct ir3_instruction *instr;
-
- instr = choose_instr(ctx);
-
- /* this shouldn't happen: */
- if (!instr) {
- ctx->error = true;
- break;
- }
+ struct ir3_instruction *instr = choose_instr(ctx);
unsigned delay = ir3_delay_calc(ctx->block, instr, false, false);
d("delay=%u", delay);
{
foreach_block (block, &ir->block_list) {
foreach_instr_safe (instr, &block->instr_list) {
- struct ir3_register *reg;
foreach_src (reg, instr) {
if (!reg->instr)
}
}
-int
-ir3_postsched(struct ir3_context *cctx)
+bool
+ir3_postsched(struct ir3 *ir, struct ir3_shader_variant *v)
{
struct ir3_postsched_ctx ctx = {
- .ctx = cctx,
+ .ir = ir,
+ .v = v,
};
- ir3_remove_nops(cctx->ir);
- cleanup_self_movs(cctx->ir);
+ ir3_remove_nops(ir);
+ cleanup_self_movs(ir);
- foreach_block (block, &cctx->ir->block_list) {
+ foreach_block (block, &ir->block_list) {
sched_block(&ctx, block);
}
- if (ctx.error)
- return -1;
-
- return 0;
+ return true;
}