aco: emit nir_jump_halt

To halt execution by setting FATAL_HALT.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40723>
This commit is contained in:
Samuel Pitoiset 2026-03-19 15:30:52 +01:00 committed by Marge Bot
parent 371ed09659
commit 6fe7fdb100
5 changed files with 20 additions and 6 deletions

View file

@ -253,6 +253,9 @@ is_atomic_or_control_instr(Program* program, const Instruction* instr, memory_sy
if (is_pops_end_export(program, instr) || is_ordered_ps_done_sendmsg(instr) ||
instr->opcode == aco_opcode::p_pops_gfx9_ordered_section_done)
return cls & ~storage_shared;
if (instr->opcode == aco_opcode::s_sethalt)
return cls & ~storage_shared;
}
return (instr->isBarrier() && instr->barrier().exec_scope > scope_invocation) ? cls : 0;
}

View file

@ -545,7 +545,7 @@ is_reorderable(const Instruction* instr)
instr->opcode != aco_opcode::s_sleep && instr->opcode != aco_opcode::s_trap &&
instr->opcode != aco_opcode::p_call && instr->opcode != aco_opcode::p_logical_start &&
instr->opcode != aco_opcode::p_logical_end &&
instr->opcode != aco_opcode::p_reload_preserved;
instr->opcode != aco_opcode::p_reload_preserved && instr->opcode != aco_opcode::s_sethalt;
}
struct memory_event_set {

View file

@ -251,6 +251,7 @@ isel_context setup_isel_context(Program* program, unsigned shader_count,
/* aco_isel_cfg.cpp */
void emit_loop_break(isel_context* ctx);
void emit_halt(isel_context* ctx);
void begin_loop(isel_context* ctx);
void end_loop(isel_context* ctx);
void begin_uniform_if_then(isel_context* ctx, Temp cond);

View file

@ -158,6 +158,17 @@ end_loop(isel_context* ctx)
ctx->loop_stack.pop_back();
}
void
emit_halt(isel_context* ctx)
{
Builder bld(ctx->program, ctx->block);
bld.barrier(aco_opcode::p_barrier,
memory_sync_info(storage_buffer, semantic_release, scope_device));
bld.sopp(aco_opcode::s_sethalt, 0x1); /* set HALT */
}
void
begin_uniform_if_then(isel_context* ctx, Temp cond)
{

View file

@ -735,12 +735,11 @@ visit_jump(isel_context* ctx, nir_jump_instr* instr)
{
end_empty_exec_skip(ctx);
if (instr->type != nir_jump_break) {
isel_err(&instr->instr, "Unknown NIR jump instr");
abort();
switch (instr->type) {
case nir_jump_break: emit_loop_break(ctx); break;
case nir_jump_halt: emit_halt(ctx); break;
default: isel_err(&instr->instr, "Unknown NIR jump instr"); abort();
}
emit_loop_break(ctx);
}
void