2019-09-17 13:22:17 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2018 Google
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
|
* Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
|
* IN THE SOFTWARE.
|
2021-06-09 17:54:53 +02:00
|
|
|
*
|
2019-09-17 13:22:17 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "aco_interface.h"
|
2021-06-09 10:14:54 +02:00
|
|
|
|
2019-09-17 13:22:17 +02:00
|
|
|
#include "aco_ir.h"
|
2021-06-09 15:40:03 +02:00
|
|
|
|
|
|
|
|
#include "util/memstream.h"
|
|
|
|
|
|
2020-11-26 22:06:22 -08:00
|
|
|
#include <array>
|
2019-09-17 13:22:17 +02:00
|
|
|
#include <iostream>
|
2021-06-09 15:40:03 +02:00
|
|
|
#include <vector>
|
2019-09-17 13:22:17 +02:00
|
|
|
|
2022-07-01 11:19:19 +02:00
|
|
|
static const std::array<aco_compiler_statistic_info, aco_num_statistics> statistic_infos = []()
|
2020-11-26 22:06:22 -08:00
|
|
|
{
|
2022-07-01 11:19:19 +02:00
|
|
|
std::array<aco_compiler_statistic_info, aco_num_statistics> ret{};
|
|
|
|
|
ret[aco_statistic_hash] =
|
2021-06-09 10:14:54 +02:00
|
|
|
aco_compiler_statistic_info{"Hash", "CRC32 hash of code and constant data"};
|
2022-07-01 11:19:19 +02:00
|
|
|
ret[aco_statistic_instructions] =
|
2021-06-09 10:14:54 +02:00
|
|
|
aco_compiler_statistic_info{"Instructions", "Instruction count"};
|
2022-07-01 11:19:19 +02:00
|
|
|
ret[aco_statistic_copies] =
|
2021-06-09 10:14:54 +02:00
|
|
|
aco_compiler_statistic_info{"Copies", "Copy instructions created for pseudo-instructions"};
|
2022-07-01 11:19:19 +02:00
|
|
|
ret[aco_statistic_branches] = aco_compiler_statistic_info{"Branches", "Branch instructions"};
|
|
|
|
|
ret[aco_statistic_latency] =
|
2021-06-09 10:14:54 +02:00
|
|
|
aco_compiler_statistic_info{"Latency", "Issue cycles plus stall cycles"};
|
2022-07-01 11:19:19 +02:00
|
|
|
ret[aco_statistic_inv_throughput] = aco_compiler_statistic_info{
|
2021-06-09 10:14:54 +02:00
|
|
|
"Inverse Throughput", "Estimated busy cycles to execute one wave"};
|
2022-07-01 11:19:19 +02:00
|
|
|
ret[aco_statistic_vmem_clauses] = aco_compiler_statistic_info{
|
2021-06-09 10:14:54 +02:00
|
|
|
"VMEM Clause", "Number of VMEM clauses (includes 1-sized clauses)"};
|
2022-07-01 11:19:19 +02:00
|
|
|
ret[aco_statistic_smem_clauses] = aco_compiler_statistic_info{
|
2021-06-09 10:14:54 +02:00
|
|
|
"SMEM Clause", "Number of SMEM clauses (includes 1-sized clauses)"};
|
2022-07-01 11:19:19 +02:00
|
|
|
ret[aco_statistic_sgpr_presched] =
|
2021-06-09 10:14:54 +02:00
|
|
|
aco_compiler_statistic_info{"Pre-Sched SGPRs", "SGPR usage before scheduling"};
|
2022-07-01 11:19:19 +02:00
|
|
|
ret[aco_statistic_vgpr_presched] =
|
2021-06-09 10:14:54 +02:00
|
|
|
aco_compiler_statistic_info{"Pre-Sched VGPRs", "VGPR usage before scheduling"};
|
2020-11-26 22:06:22 -08:00
|
|
|
return ret;
|
|
|
|
|
}();
|
2019-12-04 15:19:56 +00:00
|
|
|
|
2021-06-09 10:14:54 +02:00
|
|
|
const aco_compiler_statistic_info* aco_statistic_infos = statistic_infos.data();
|
2021-03-04 16:41:05 +00:00
|
|
|
|
2022-01-18 14:53:38 +00:00
|
|
|
uint64_t
|
|
|
|
|
aco_get_codegen_flags()
|
|
|
|
|
{
|
|
|
|
|
aco::init();
|
|
|
|
|
/* Exclude flags which don't affect code generation. */
|
|
|
|
|
uint64_t exclude = aco::DEBUG_VALIDATE_IR | aco::DEBUG_VALIDATE_RA | aco::DEBUG_PERFWARN |
|
|
|
|
|
aco::DEBUG_PERF_INFO | aco::DEBUG_LIVE_INFO;
|
|
|
|
|
return aco::debug_flags & ~exclude;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-09 10:14:54 +02:00
|
|
|
static void
|
|
|
|
|
validate(aco::Program* program)
|
2020-01-30 11:49:20 +00:00
|
|
|
{
|
2020-08-18 08:14:06 +02:00
|
|
|
if (!(aco::debug_flags & aco::DEBUG_VALIDATE_IR))
|
2020-01-30 11:49:20 +00:00
|
|
|
return;
|
|
|
|
|
|
2020-08-22 20:41:45 +02:00
|
|
|
ASSERTED bool is_valid = aco::validate_ir(program);
|
2020-01-30 11:49:20 +00:00
|
|
|
assert(is_valid);
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-15 10:03:21 +02:00
|
|
|
static std::string
|
|
|
|
|
get_disasm_string(aco::Program* program, std::vector<uint32_t>& code,
|
|
|
|
|
unsigned exec_size)
|
|
|
|
|
{
|
|
|
|
|
std::string disasm;
|
|
|
|
|
|
|
|
|
|
if (check_print_asm_support(program)) {
|
|
|
|
|
char* data = NULL;
|
|
|
|
|
size_t disasm_size = 0;
|
|
|
|
|
struct u_memstream mem;
|
|
|
|
|
if (u_memstream_open(&mem, &data, &disasm_size)) {
|
|
|
|
|
FILE* const memf = u_memstream_get(&mem);
|
|
|
|
|
aco::print_asm(program, code, exec_size / 4u, memf);
|
|
|
|
|
fputc(0, memf);
|
|
|
|
|
u_memstream_close(&mem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
disasm = std::string(data, data + disasm_size);
|
|
|
|
|
free(data);
|
|
|
|
|
} else {
|
|
|
|
|
disasm = "Shader disassembly is not supported in the current configuration"
|
|
|
|
|
#ifndef LLVM_AVAILABLE
|
|
|
|
|
" (LLVM not available)"
|
|
|
|
|
#endif
|
|
|
|
|
".\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return disasm;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-24 16:17:07 +02:00
|
|
|
static std::string
|
|
|
|
|
aco_postprocess_shader(const struct aco_compiler_options* options,
|
2022-09-22 15:21:07 +08:00
|
|
|
const struct aco_shader_info *info,
|
2022-06-24 16:17:07 +02:00
|
|
|
std::unique_ptr<aco::Program>& program)
|
2019-09-17 13:22:17 +02:00
|
|
|
{
|
2022-06-24 16:17:07 +02:00
|
|
|
std::string llvm_ir;
|
2020-08-14 13:59:16 +02:00
|
|
|
|
2021-10-08 16:14:15 +02:00
|
|
|
if (options->dump_preoptir)
|
2019-09-17 13:22:17 +02:00
|
|
|
aco_print_program(program.get(), stderr);
|
|
|
|
|
|
2020-08-21 11:33:22 +02:00
|
|
|
aco::live live_vars;
|
2022-09-22 15:21:07 +08:00
|
|
|
if (!info->is_trap_handler_shader) {
|
2020-08-21 11:33:22 +02:00
|
|
|
/* Phi lowering */
|
|
|
|
|
aco::lower_phis(program.get());
|
|
|
|
|
aco::dominator_tree(program.get());
|
|
|
|
|
validate(program.get());
|
|
|
|
|
|
|
|
|
|
/* Optimization */
|
2021-10-08 16:14:15 +02:00
|
|
|
if (!options->key.optimisations_disabled) {
|
2020-08-28 08:41:20 +02:00
|
|
|
if (!(aco::debug_flags & aco::DEBUG_NO_VN))
|
|
|
|
|
aco::value_numbering(program.get());
|
|
|
|
|
if (!(aco::debug_flags & aco::DEBUG_NO_OPT))
|
|
|
|
|
aco::optimize(program.get());
|
|
|
|
|
}
|
2020-08-21 11:33:22 +02:00
|
|
|
|
|
|
|
|
/* cleanup and exec mask handling */
|
|
|
|
|
aco::setup_reduce_temp(program.get());
|
|
|
|
|
aco::insert_exec_mask(program.get());
|
|
|
|
|
validate(program.get());
|
|
|
|
|
|
|
|
|
|
/* spilling and scheduling */
|
2020-10-08 10:12:58 +02:00
|
|
|
live_vars = aco::live_var_analysis(program.get());
|
|
|
|
|
aco::spill(program.get(), live_vars);
|
2020-08-21 11:33:22 +02:00
|
|
|
}
|
2019-09-17 13:22:17 +02:00
|
|
|
|
2021-10-08 16:14:15 +02:00
|
|
|
if (options->record_ir) {
|
2021-06-09 10:14:54 +02:00
|
|
|
char* data = NULL;
|
2019-09-24 15:23:46 +01:00
|
|
|
size_t size = 0;
|
2020-08-04 10:58:11 -07:00
|
|
|
u_memstream mem;
|
|
|
|
|
if (u_memstream_open(&mem, &data, &size)) {
|
2021-06-09 10:14:54 +02:00
|
|
|
FILE* const memf = u_memstream_get(&mem);
|
2020-08-04 10:58:11 -07:00
|
|
|
aco_print_program(program.get(), memf);
|
|
|
|
|
fputc(0, memf);
|
|
|
|
|
u_memstream_close(&mem);
|
2019-09-24 15:23:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
llvm_ir = std::string(data, data + size);
|
|
|
|
|
free(data);
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 16:10:46 +00:00
|
|
|
if (program->collect_statistics)
|
|
|
|
|
aco::collect_presched_stats(program.get());
|
|
|
|
|
|
2021-10-08 16:14:15 +02:00
|
|
|
if ((aco::debug_flags & aco::DEBUG_LIVE_INFO) && options->dump_shader)
|
2021-03-15 14:17:14 +00:00
|
|
|
aco_print_program(program.get(), stderr, live_vars, aco::print_live_vars | aco::print_kill);
|
|
|
|
|
|
2022-09-22 15:21:07 +08:00
|
|
|
if (!info->is_trap_handler_shader) {
|
2021-10-08 16:14:15 +02:00
|
|
|
if (!options->key.optimisations_disabled && !(aco::debug_flags & aco::DEBUG_NO_SCHED))
|
2020-08-26 14:24:45 +02:00
|
|
|
aco::schedule_program(program.get(), live_vars);
|
2020-08-21 11:33:22 +02:00
|
|
|
validate(program.get());
|
2019-09-17 13:22:17 +02:00
|
|
|
|
2020-08-21 11:33:22 +02:00
|
|
|
/* Register Allocation */
|
|
|
|
|
aco::register_allocation(program.get(), live_vars.live_out);
|
|
|
|
|
|
2020-10-08 10:12:58 +02:00
|
|
|
if (aco::validate_ra(program.get())) {
|
2020-08-21 11:33:22 +02:00
|
|
|
aco_print_program(program.get(), stderr);
|
|
|
|
|
abort();
|
2021-10-08 16:14:15 +02:00
|
|
|
} else if (options->dump_shader) {
|
2021-04-20 17:35:41 +01:00
|
|
|
aco_print_program(program.get(), stderr);
|
2020-08-21 11:33:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
validate(program.get());
|
2019-09-17 13:22:17 +02:00
|
|
|
|
2020-11-24 11:39:28 +01:00
|
|
|
/* Optimization */
|
2021-10-08 16:14:15 +02:00
|
|
|
if (!options->key.optimisations_disabled && !(aco::debug_flags & aco::DEBUG_NO_OPT)) {
|
2020-11-24 11:39:28 +01:00
|
|
|
aco::optimize_postRA(program.get());
|
|
|
|
|
validate(program.get());
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-21 11:33:22 +02:00
|
|
|
aco::ssa_elimination(program.get());
|
|
|
|
|
}
|
2020-06-16 10:03:00 +01:00
|
|
|
|
2019-09-17 13:22:17 +02:00
|
|
|
/* Lower to HW Instructions */
|
|
|
|
|
aco::lower_to_hw_instr(program.get());
|
|
|
|
|
|
|
|
|
|
/* Insert Waitcnt */
|
|
|
|
|
aco::insert_wait_states(program.get());
|
|
|
|
|
aco::insert_NOPs(program.get());
|
|
|
|
|
|
2022-05-12 02:50:17 -04:00
|
|
|
if (program->gfx_level >= GFX10)
|
2020-07-13 13:42:24 +01:00
|
|
|
aco::form_hard_clauses(program.get());
|
|
|
|
|
|
2021-02-03 13:40:54 +00:00
|
|
|
if (program->collect_statistics || (aco::debug_flags & aco::DEBUG_PERF_INFO))
|
2019-12-04 15:19:56 +00:00
|
|
|
aco::collect_preasm_stats(program.get());
|
|
|
|
|
|
2022-06-24 16:17:07 +02:00
|
|
|
return llvm_ir;
|
|
|
|
|
}
|
2019-09-17 13:22:17 +02:00
|
|
|
|
2022-06-24 16:17:07 +02:00
|
|
|
void
|
|
|
|
|
aco_compile_shader(const struct aco_compiler_options* options,
|
|
|
|
|
const struct aco_shader_info* info,
|
|
|
|
|
unsigned shader_count, struct nir_shader* const* shaders,
|
2023-03-03 11:47:02 -08:00
|
|
|
const struct ac_shader_args *args,
|
2022-06-24 16:17:07 +02:00
|
|
|
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;
|
2019-12-04 15:19:56 +00:00
|
|
|
if (program->collect_statistics)
|
2022-06-24 16:17:07 +02:00
|
|
|
memset(program->statistics, 0, sizeof(program->statistics));
|
|
|
|
|
|
|
|
|
|
program->debug.func = options->debug.func;
|
|
|
|
|
program->debug.private_data = options->debug.private_data;
|
|
|
|
|
|
|
|
|
|
/* Instruction Selection */
|
2022-09-22 15:21:07 +08:00
|
|
|
if (info->is_trap_handler_shader)
|
2022-06-24 16:17:07 +02:00
|
|
|
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);
|
|
|
|
|
|
2022-09-22 15:21:07 +08:00
|
|
|
std::string llvm_ir = aco_postprocess_shader(options, info, program);
|
2022-06-24 16:17:07 +02:00
|
|
|
|
|
|
|
|
/* assembly */
|
|
|
|
|
std::vector<uint32_t> code;
|
|
|
|
|
unsigned exec_size = aco::emit_program(program.get(), code);
|
2019-12-04 15:19:56 +00:00
|
|
|
|
2022-08-09 11:42:10 +01:00
|
|
|
if (program->collect_statistics)
|
|
|
|
|
aco::collect_postasm_stats(program.get(), code);
|
|
|
|
|
|
2021-10-08 16:14:15 +02:00
|
|
|
bool get_disasm = options->dump_shader || options->record_ir;
|
2019-09-17 13:22:17 +02:00
|
|
|
|
|
|
|
|
std::string disasm;
|
2022-05-11 14:10:55 +10:00
|
|
|
if (get_disasm)
|
2021-10-15 10:03:21 +02:00
|
|
|
disasm = get_disasm_string(program.get(), code, exec_size);
|
2019-09-17 13:22:17 +02:00
|
|
|
|
2019-12-04 15:19:56 +00:00
|
|
|
size_t stats_size = 0;
|
|
|
|
|
if (program->collect_statistics)
|
2022-07-01 11:19:19 +02:00
|
|
|
stats_size = aco_num_statistics * sizeof(uint32_t);
|
2019-09-17 13:22:17 +02:00
|
|
|
|
2023-03-17 00:49:44 +01:00
|
|
|
(*build_binary)(binary, &config, llvm_ir.c_str(), llvm_ir.size(), disasm.c_str(), disasm.size(),
|
|
|
|
|
program->statistics, stats_size, exec_size, code.data(), code.size());
|
2023-02-21 14:21:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
aco_compile_rt_prolog(const struct aco_compiler_options* options,
|
|
|
|
|
const struct aco_shader_info* info, const struct ac_shader_args* in_args,
|
|
|
|
|
const struct ac_shader_args* out_args, aco_callback* build_prolog,
|
|
|
|
|
void** binary)
|
|
|
|
|
{
|
|
|
|
|
aco::init();
|
|
|
|
|
|
|
|
|
|
/* create program */
|
|
|
|
|
ac_shader_config config = {0};
|
|
|
|
|
std::unique_ptr<aco::Program> program{new aco::Program};
|
|
|
|
|
program->collect_statistics = false;
|
|
|
|
|
program->debug.func = NULL;
|
|
|
|
|
program->debug.private_data = NULL;
|
|
|
|
|
|
|
|
|
|
aco::select_rt_prolog(program.get(), &config, options, info, in_args, out_args);
|
|
|
|
|
aco::insert_wait_states(program.get());
|
|
|
|
|
aco::insert_NOPs(program.get());
|
|
|
|
|
if (program->gfx_level >= GFX10)
|
|
|
|
|
aco::form_hard_clauses(program.get());
|
|
|
|
|
|
|
|
|
|
if (options->dump_shader)
|
|
|
|
|
aco_print_program(program.get(), stderr);
|
|
|
|
|
|
|
|
|
|
/* assembly */
|
|
|
|
|
std::vector<uint32_t> code;
|
|
|
|
|
code.reserve(align(program->blocks[0].instructions.size() * 2, 16));
|
|
|
|
|
unsigned exec_size = aco::emit_program(program.get(), code);
|
|
|
|
|
|
|
|
|
|
bool get_disasm = options->dump_shader || options->record_ir;
|
|
|
|
|
|
|
|
|
|
std::string disasm;
|
|
|
|
|
if (get_disasm)
|
|
|
|
|
disasm = get_disasm_string(program.get(), code, exec_size);
|
|
|
|
|
|
2023-03-17 00:49:44 +01:00
|
|
|
(*build_prolog)(binary, &config, NULL, 0, disasm.c_str(), disasm.size(), program->statistics, 0,
|
|
|
|
|
exec_size, code.data(), code.size());
|
2019-09-17 13:22:17 +02:00
|
|
|
}
|
2021-04-16 11:55:59 +01:00
|
|
|
|
|
|
|
|
void
|
2022-05-16 14:54:05 +10:00
|
|
|
aco_compile_vs_prolog(const struct aco_compiler_options* options,
|
2023-03-03 11:25:21 -08:00
|
|
|
const struct aco_shader_info* info, const struct aco_vs_prolog_info* pinfo,
|
2023-03-03 11:47:02 -08:00
|
|
|
const struct ac_shader_args* args, aco_shader_part_callback* build_prolog,
|
2023-03-03 11:25:21 -08:00
|
|
|
void** binary)
|
2021-04-16 11:55:59 +01:00
|
|
|
{
|
2021-05-17 17:53:30 +01:00
|
|
|
aco::init();
|
|
|
|
|
|
|
|
|
|
/* create program */
|
|
|
|
|
ac_shader_config config = {0};
|
|
|
|
|
std::unique_ptr<aco::Program> program{new aco::Program};
|
|
|
|
|
program->collect_statistics = false;
|
|
|
|
|
program->debug.func = NULL;
|
|
|
|
|
program->debug.private_data = NULL;
|
|
|
|
|
|
|
|
|
|
/* create IR */
|
2023-03-10 14:26:00 +01:00
|
|
|
aco::select_vs_prolog(program.get(), pinfo, &config, options, info, args);
|
2021-05-17 17:53:30 +01:00
|
|
|
aco::insert_NOPs(program.get());
|
|
|
|
|
|
2021-10-08 16:14:15 +02:00
|
|
|
if (options->dump_shader)
|
2021-05-17 17:53:30 +01:00
|
|
|
aco_print_program(program.get(), stderr);
|
|
|
|
|
|
|
|
|
|
/* assembly */
|
|
|
|
|
std::vector<uint32_t> code;
|
|
|
|
|
code.reserve(align(program->blocks[0].instructions.size() * 2, 16));
|
|
|
|
|
unsigned exec_size = aco::emit_program(program.get(), code);
|
|
|
|
|
|
2021-10-15 10:03:21 +02:00
|
|
|
bool get_disasm = options->dump_shader || options->record_ir;
|
|
|
|
|
|
|
|
|
|
std::string disasm;
|
2022-05-11 14:56:36 +10:00
|
|
|
if (get_disasm)
|
2021-10-15 10:03:21 +02:00
|
|
|
disasm = get_disasm_string(program.get(), code, exec_size);
|
2021-05-17 17:53:30 +01:00
|
|
|
|
2022-05-11 14:56:36 +10:00
|
|
|
(*build_prolog)(binary,
|
|
|
|
|
config.num_sgprs,
|
|
|
|
|
config.num_vgprs,
|
|
|
|
|
code.data(),
|
|
|
|
|
code.size(),
|
|
|
|
|
disasm.data(),
|
|
|
|
|
disasm.size());
|
2021-04-16 11:55:59 +01:00
|
|
|
}
|
2022-07-14 18:53:46 +02:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
aco_compile_ps_epilog(const struct aco_compiler_options* options,
|
2023-03-03 11:25:21 -08:00
|
|
|
const struct aco_shader_info* info, const struct aco_ps_epilog_info* pinfo,
|
2023-03-03 11:47:02 -08:00
|
|
|
const struct ac_shader_args* args, aco_shader_part_callback* build_epilog,
|
2022-07-14 18:53:46 +02:00
|
|
|
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)
|
|
|
|
|
memset(program->statistics, 0, sizeof(program->statistics));
|
|
|
|
|
|
|
|
|
|
program->debug.func = options->debug.func;
|
|
|
|
|
program->debug.private_data = options->debug.private_data;
|
|
|
|
|
|
|
|
|
|
/* Instruction selection */
|
2023-03-03 11:25:21 -08:00
|
|
|
aco::select_ps_epilog(program.get(), pinfo, &config, options, info, args);
|
2022-07-14 18:53:46 +02:00
|
|
|
|
2022-09-22 15:21:07 +08:00
|
|
|
aco_postprocess_shader(options, info, program);
|
2022-07-14 18:53:46 +02:00
|
|
|
|
|
|
|
|
/* assembly */
|
|
|
|
|
std::vector<uint32_t> code;
|
|
|
|
|
unsigned exec_size = aco::emit_program(program.get(), code);
|
|
|
|
|
|
|
|
|
|
bool get_disasm = options->dump_shader || options->record_ir;
|
|
|
|
|
|
|
|
|
|
std::string disasm;
|
|
|
|
|
if (get_disasm)
|
|
|
|
|
disasm = get_disasm_string(program.get(), code, exec_size);
|
|
|
|
|
|
|
|
|
|
(*build_epilog)(binary,
|
|
|
|
|
config.num_sgprs,
|
|
|
|
|
config.num_vgprs,
|
|
|
|
|
code.data(),
|
|
|
|
|
code.size(),
|
|
|
|
|
disasm.data(),
|
|
|
|
|
disasm.size());
|
|
|
|
|
}
|