From 897561b7b98ebbabe0ee68761ccb9302ddc8991f Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Fri, 24 Jun 2022 16:17:07 +0200 Subject: [PATCH] aco: add aco_postprocess_shader() helper MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Samuel Pitoiset Reviewed-by: Timur Kristóf Part-of: --- src/amd/compiler/aco_interface.cpp | 69 +++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/src/amd/compiler/aco_interface.cpp b/src/amd/compiler/aco_interface.cpp index 73e32b2..a33ba1d 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(); - - 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; + std::string llvm_ir; - /* 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,12 +207,42 @@ 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 */ - std::vector code; - unsigned exec_size = aco::emit_program(program.get(), code); + 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) - aco::collect_postasm_stats(program.get(), code); + 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); bool get_disasm = options->dump_shader || options->record_ir; -- 2.7.4