diff options
author | Alyssa Rosenzweig <[email protected]> | 2020-03-05 17:10:46 -0500 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-03-07 00:37:39 +0000 |
commit | 65c8dcca3b35a482c8378e10bb245a92e2e2bfdf (patch) | |
tree | 7bf9dd375618b408a7783b46fe8fcf4cfcc50c24 /src/panfrost/bifrost | |
parent | 987aea14000ce6524b12d72488dc1275d5e8a991 (diff) |
pan/bi: Handle jumps (breaks, continues)
Loops should behave reasonably now.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4097>
Diffstat (limited to 'src/panfrost/bifrost')
-rw-r--r-- | src/panfrost/bifrost/bifrost_compile.c | 61 |
1 files changed, 60 insertions, 1 deletions
diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index 01f20c44d55..68dcd31b95c 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -37,6 +37,65 @@ #include "bi_print.h" static bi_block *emit_cf_list(bi_context *ctx, struct exec_list *list); +static bi_instruction *bi_emit_branch(bi_context *ctx); +static void bi_block_add_successor(bi_block *block, bi_block *successor); + +static void +emit_jump(bi_context *ctx, nir_jump_instr *instr) +{ + bi_instruction *branch = bi_emit_branch(ctx); + + switch (instr->type) { + case nir_jump_break: + branch->branch.target = ctx->break_block; + break; + case nir_jump_continue: + branch->branch.target = ctx->continue_block; + break; + default: + unreachable("Unhandled jump type"); + } + + bi_block_add_successor(ctx->current_block, branch->branch.target); +} + +static void +emit_instr(bi_context *ctx, struct nir_instr *instr) +{ + switch (instr->type) { +#if 0 + case nir_instr_type_load_const: + emit_load_const(ctx, nir_instr_as_load_const(instr)); + break; + + case nir_instr_type_intrinsic: + emit_intrinsic(ctx, nir_instr_as_intrinsic(instr)); + break; + + case nir_instr_type_alu: + emit_alu(ctx, nir_instr_as_alu(instr)); + break; + + case nir_instr_type_tex: + emit_tex(ctx, nir_instr_as_tex(instr)); + break; +#endif + + case nir_instr_type_jump: + emit_jump(ctx, nir_instr_as_jump(instr)); + break; + + case nir_instr_type_ssa_undef: + /* Spurious */ + break; + + default: + //unreachable("Unhandled instruction type"); + break; + } +} + + static bi_block * create_empty_block(bi_context *ctx) @@ -88,7 +147,7 @@ emit_block(bi_context *ctx, nir_block *block) list_inithead(&ctx->current_block->instructions); nir_foreach_instr(instr, block) { - //emit_instr(ctx, instr); + emit_instr(ctx, instr); ++ctx->instruction_count; } |