Skip to content
Snippets Groups Projects
Commit 897561b7 authored by Samuel Pitoiset's avatar Samuel Pitoiset Committed by Marge Bot
Browse files

aco: add aco_postprocess_shader() helper


Signed-off-by: default avatarSamuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: default avatarTimur Kristóf <timur.kristof@gmail.com>
Part-of: <mesa/mesa!17485>
parent d9ffff09
No related branches found
No related tags found
No related merge requests found
......@@ -112,33 +112,13 @@ get_disasm_string(aco::Program* program, std::vector<uint32_t>& 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<aco::Program>& program)
{
aco::init();
ac_shader_config config = {0};
std::unique_ptr<aco::Program> 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<uint32_t> 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<aco::Program> 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<uint32_t> code;
unsigned exec_size = aco::emit_program(program.get(), code);
bool get_disasm = options->dump_shader || options->record_ir;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment