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:
Rhys Perry 2020-01-30 11:49:20 +00:00 committed by Marge Bot
parent e75946cfef
commit bf4b377b9b
3 changed files with 16 additions and 10 deletions

View File

@ -45,6 +45,15 @@ static radv_compiler_statistic_info statistic_infos[] = {
[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,
struct nir_shader *const *shaders,
struct radv_shader_binary **binary,
@ -72,7 +81,7 @@ void aco_compile_shader(unsigned shader_count,
/* Phi lowering */
aco::lower_phis(program.get());
aco::dominator_tree(program.get());
aco::validate(program.get(), stderr);
validate(program.get());
/* Optimization */
aco::value_numbering(program.get());
@ -81,7 +90,7 @@ void aco_compile_shader(unsigned shader_count,
/* cleanup and exec mask handling */
aco::setup_reduce_temp(program.get());
aco::insert_exec_mask(program.get());
aco::validate(program.get(), stderr);
validate(program.get());
/* spilling and scheduling */
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)
aco::collect_presched_stats(program.get());
aco::schedule_program(program.get(), live_vars);
aco::validate(program.get(), stderr);
validate(program.get());
std::string llvm_ir;
if (args->options->record_ir) {
@ -119,7 +128,7 @@ void aco_compile_shader(unsigned shader_count,
abort();
}
aco::validate(program.get(), stderr);
validate(program.get());
/* Lower to HW Instructions */
aco::ssa_elimination(program.get());

View File

@ -1607,7 +1607,7 @@ void insert_NOPs(Program* program);
unsigned emit_program(Program* program, std::vector<uint32_t>& code);
void print_asm(Program *program, std::vector<uint32_t>& binary,
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);
#ifndef NDEBUG
void perfwarn(bool cond, const char *msg, Instruction *instr=NULL);

View File

@ -46,11 +46,8 @@ void perfwarn(bool cond, const char *msg, Instruction *instr)
}
#endif
void validate(Program* program, FILE * output)
bool validate(Program* program, FILE *output)
{
if (!(debug_flags & DEBUG_VALIDATE))
return;
bool is_valid = true;
auto check = [&output, &is_valid](bool check, const char * msg, aco::Instruction * instr) -> void {
if (!check) {
@ -439,7 +436,7 @@ void validate(Program* program, FILE * output)
}
}
assert(is_valid);
return is_valid;
}
/* RA validation */