diff --git a/src/amd/compiler/aco_interface.cpp b/src/amd/compiler/aco_interface.cpp index 73e32b24f7a..a33ba1d90ed 100644 --- a/src/amd/compiler/aco_interface.cpp +++ b/src/amd/compiler/aco_interface.cpp @@ -112,33 +112,13 @@ get_disasm_string(aco::Program* program, std::vector& code, return disasm; } -void -aco_compile_shader(const struct aco_compiler_options* options, - const struct aco_shader_info* info, - unsigned shader_count, struct nir_shader* const* shaders, - const struct radv_shader_args *args, - aco_callback *build_binary, - void **binary) +static std::string +aco_postprocess_shader(const struct aco_compiler_options* options, + const struct radv_shader_args *args, + std::unique_ptr& program) { - aco::init(); + std::string llvm_ir; - ac_shader_config config = {0}; - std::unique_ptr program{new aco::Program}; - - program->collect_statistics = options->record_stats; - if (program->collect_statistics) - memset(program->statistics, 0, sizeof(program->statistics)); - - program->debug.func = options->debug.func; - program->debug.private_data = options->debug.private_data; - - /* Instruction Selection */ - if (args->is_gs_copy_shader) - aco::select_gs_copy_shader(program.get(), shaders[0], &config, options, info, args); - else if (args->is_trap_handler_shader) - aco::select_trap_handler_shader(program.get(), shaders[0], &config, options, info, args); - else - aco::select_program(program.get(), shader_count, shaders, &config, options, info, args); if (options->dump_preoptir) aco_print_program(program.get(), stderr); @@ -167,7 +147,6 @@ aco_compile_shader(const struct aco_compiler_options* options, aco::spill(program.get(), live_vars); } - std::string llvm_ir; if (options->record_ir) { char* data = NULL; size_t size = 0; @@ -228,13 +207,43 @@ aco_compile_shader(const struct aco_compiler_options* options, if (program->collect_statistics || (aco::debug_flags & aco::DEBUG_PERF_INFO)) aco::collect_preasm_stats(program.get()); - /* Assembly */ + return llvm_ir; +} + +void +aco_compile_shader(const struct aco_compiler_options* options, + const struct aco_shader_info* info, + unsigned shader_count, struct nir_shader* const* shaders, + const struct radv_shader_args *args, + aco_callback *build_binary, + void **binary) +{ + aco::init(); + + ac_shader_config config = {0}; + std::unique_ptr program{new aco::Program}; + + program->collect_statistics = options->record_stats; + if (program->collect_statistics) + memset(program->statistics, 0, sizeof(program->statistics)); + + program->debug.func = options->debug.func; + program->debug.private_data = options->debug.private_data; + + /* Instruction Selection */ + if (args->is_gs_copy_shader) + aco::select_gs_copy_shader(program.get(), shaders[0], &config, options, info, args); + else if (args->is_trap_handler_shader) + aco::select_trap_handler_shader(program.get(), shaders[0], &config, options, info, args); + else + aco::select_program(program.get(), shader_count, shaders, &config, options, info, args); + + std::string llvm_ir = aco_postprocess_shader(options, args, program); + + /* assembly */ std::vector code; unsigned exec_size = aco::emit_program(program.get(), code); - if (program->collect_statistics) - aco::collect_postasm_stats(program.get(), code); - bool get_disasm = options->dump_shader || options->record_ir; std::string disasm;