From: Marek Olšák <marek.ol...@amd.com> Compile times of simple shaders are reduced by ~20%. Compile times of prologs and epilogs are reduced by up to 40%. --- src/gallium/drivers/radeonsi/si_pipe.c | 2 ++ .../drivers/radeonsi/si_shader_tgsi_setup.c | 33 ++----------------- 2 files changed, 4 insertions(+), 31 deletions(-)
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index 740533fd7a0..ac4f77a8964 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -109,24 +109,26 @@ static void si_init_compiler(struct si_screen *sscreen, { enum ac_target_machine_options tm_options = (sscreen->debug_flags & DBG(SI_SCHED) ? AC_TM_SISCHED : 0) | (sscreen->info.chip_class >= GFX9 ? AC_TM_FORCE_ENABLE_XNACK : 0) | (sscreen->info.chip_class < GFX9 ? AC_TM_FORCE_DISABLE_XNACK : 0) | (!sscreen->llvm_has_working_vgpr_indexing ? AC_TM_PROMOTE_ALLOCA_TO_SCRATCH : 0) | (sscreen->debug_flags & DBG(CHECK_IR) ? AC_TM_CHECK_IR : 0); ac_init_llvm_once(); ac_init_llvm_compiler(compiler, true, sscreen->info.family, tm_options); + compiler->passes = ac_create_llvm_passes(compiler->tm); } static void si_destroy_compiler(struct ac_llvm_compiler *compiler) { + ac_destroy_llvm_passes(compiler->passes); ac_destroy_llvm_compiler(compiler); } /* * pipe_context */ static void si_destroy_context(struct pipe_context *context) { struct si_context *sctx = (struct si_context *)context; int i; diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c index 566d3a8eb6e..6c1e18ff812 100644 --- a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c +++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c @@ -78,63 +78,34 @@ static void si_diagnostic_handler(LLVMDiagnosticInfoRef di, void *context) /** * Compile an LLVM module to machine code. * * @returns 0 for success, 1 for failure */ unsigned si_llvm_compile(LLVMModuleRef M, struct ac_shader_binary *binary, struct ac_llvm_compiler *compiler, struct pipe_debug_callback *debug) { struct si_llvm_diagnostics diag; - char *err; LLVMContextRef llvm_ctx; - LLVMMemoryBufferRef out_buffer; - unsigned buffer_size; - const char *buffer_data; - LLVMBool mem_err; diag.debug = debug; diag.retval = 0; /* Setup Diagnostic Handler*/ llvm_ctx = LLVMGetModuleContext(M); LLVMContextSetDiagnosticHandler(llvm_ctx, si_diagnostic_handler, &diag); - /* Compile IR*/ - mem_err = LLVMTargetMachineEmitToMemoryBuffer(compiler->tm, M, - LLVMObjectFile, &err, - &out_buffer); - - /* Process Errors/Warnings */ - if (mem_err) { - fprintf(stderr, "%s: %s", __FUNCTION__, err); - pipe_debug_message(debug, SHADER_INFO, - "LLVM emit error: %s", err); - FREE(err); + /* Compile IR. */ + if (!ac_compile_module_to_binary(compiler->passes, M, binary)) diag.retval = 1; - goto out; - } - - /* Extract Shader Code*/ - buffer_size = LLVMGetBufferSize(out_buffer); - buffer_data = LLVMGetBufferStart(out_buffer); - - if (!ac_elf_read(buffer_data, buffer_size, binary)) { - fprintf(stderr, "radeonsi: cannot read an ELF shader binary\n"); - diag.retval = 1; - } - - /* Clean up */ - LLVMDisposeMemoryBuffer(out_buffer); -out: if (diag.retval != 0) pipe_debug_message(debug, SHADER_INFO, "LLVM compile failed"); return diag.retval; } LLVMTypeRef tgsi2llvmtype(struct lp_build_tgsi_context *bld_base, enum tgsi_opcode_type type) { struct si_shader_context *ctx = si_shader_context(bld_base); -- 2.17.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev