aco: make validate() usable in tests
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com> Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6013>
This commit is contained in:
parent
e75946cfef
commit
bf4b377b9b
|
@ -45,6 +45,15 @@ static radv_compiler_statistic_info statistic_infos[] = {
|
||||||
[aco::statistic_vgpr_presched] = {"Pre-Sched VGPRs", "VGPR usage before scheduling"},
|
[aco::statistic_vgpr_presched] = {"Pre-Sched VGPRs", "VGPR usage before scheduling"},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void validate(aco::Program *program)
|
||||||
|
{
|
||||||
|
if (!(aco::debug_flags & aco::DEBUG_VALIDATE))
|
||||||
|
return;
|
||||||
|
|
||||||
|
bool is_valid = aco::validate(program, stderr);
|
||||||
|
assert(is_valid);
|
||||||
|
}
|
||||||
|
|
||||||
void aco_compile_shader(unsigned shader_count,
|
void aco_compile_shader(unsigned shader_count,
|
||||||
struct nir_shader *const *shaders,
|
struct nir_shader *const *shaders,
|
||||||
struct radv_shader_binary **binary,
|
struct radv_shader_binary **binary,
|
||||||
|
@ -72,7 +81,7 @@ void aco_compile_shader(unsigned shader_count,
|
||||||
/* Phi lowering */
|
/* Phi lowering */
|
||||||
aco::lower_phis(program.get());
|
aco::lower_phis(program.get());
|
||||||
aco::dominator_tree(program.get());
|
aco::dominator_tree(program.get());
|
||||||
aco::validate(program.get(), stderr);
|
validate(program.get());
|
||||||
|
|
||||||
/* Optimization */
|
/* Optimization */
|
||||||
aco::value_numbering(program.get());
|
aco::value_numbering(program.get());
|
||||||
|
@ -81,7 +90,7 @@ void aco_compile_shader(unsigned shader_count,
|
||||||
/* cleanup and exec mask handling */
|
/* cleanup and exec mask handling */
|
||||||
aco::setup_reduce_temp(program.get());
|
aco::setup_reduce_temp(program.get());
|
||||||
aco::insert_exec_mask(program.get());
|
aco::insert_exec_mask(program.get());
|
||||||
aco::validate(program.get(), stderr);
|
validate(program.get());
|
||||||
|
|
||||||
/* spilling and scheduling */
|
/* spilling and scheduling */
|
||||||
aco::live live_vars = aco::live_var_analysis(program.get(), args->options);
|
aco::live live_vars = aco::live_var_analysis(program.get(), args->options);
|
||||||
|
@ -89,7 +98,7 @@ void aco_compile_shader(unsigned shader_count,
|
||||||
if (program->collect_statistics)
|
if (program->collect_statistics)
|
||||||
aco::collect_presched_stats(program.get());
|
aco::collect_presched_stats(program.get());
|
||||||
aco::schedule_program(program.get(), live_vars);
|
aco::schedule_program(program.get(), live_vars);
|
||||||
aco::validate(program.get(), stderr);
|
validate(program.get());
|
||||||
|
|
||||||
std::string llvm_ir;
|
std::string llvm_ir;
|
||||||
if (args->options->record_ir) {
|
if (args->options->record_ir) {
|
||||||
|
@ -119,7 +128,7 @@ void aco_compile_shader(unsigned shader_count,
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
aco::validate(program.get(), stderr);
|
validate(program.get());
|
||||||
|
|
||||||
/* Lower to HW Instructions */
|
/* Lower to HW Instructions */
|
||||||
aco::ssa_elimination(program.get());
|
aco::ssa_elimination(program.get());
|
||||||
|
|
|
@ -1607,7 +1607,7 @@ void insert_NOPs(Program* program);
|
||||||
unsigned emit_program(Program* program, std::vector<uint32_t>& code);
|
unsigned emit_program(Program* program, std::vector<uint32_t>& code);
|
||||||
void print_asm(Program *program, std::vector<uint32_t>& binary,
|
void print_asm(Program *program, std::vector<uint32_t>& binary,
|
||||||
unsigned exec_size, std::ostream& out);
|
unsigned exec_size, std::ostream& out);
|
||||||
void validate(Program* program, FILE *output);
|
bool validate(Program* program, FILE *output);
|
||||||
bool validate_ra(Program* program, const struct radv_nir_compiler_options *options, FILE *output);
|
bool validate_ra(Program* program, const struct radv_nir_compiler_options *options, FILE *output);
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void perfwarn(bool cond, const char *msg, Instruction *instr=NULL);
|
void perfwarn(bool cond, const char *msg, Instruction *instr=NULL);
|
||||||
|
|
|
@ -46,11 +46,8 @@ void perfwarn(bool cond, const char *msg, Instruction *instr)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void validate(Program* program, FILE * output)
|
bool validate(Program* program, FILE *output)
|
||||||
{
|
{
|
||||||
if (!(debug_flags & DEBUG_VALIDATE))
|
|
||||||
return;
|
|
||||||
|
|
||||||
bool is_valid = true;
|
bool is_valid = true;
|
||||||
auto check = [&output, &is_valid](bool check, const char * msg, aco::Instruction * instr) -> void {
|
auto check = [&output, &is_valid](bool check, const char * msg, aco::Instruction * instr) -> void {
|
||||||
if (!check) {
|
if (!check) {
|
||||||
|
@ -439,7 +436,7 @@ void validate(Program* program, FILE * output)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(is_valid);
|
return is_valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* RA validation */
|
/* RA validation */
|
||||||
|
|
Loading…
Reference in New Issue