static
-LLVMModuleRef ac_translate_nir_to_llvm(LLVMTargetMachineRef tm,
- LLVMPassManagerRef passmgr,
+LLVMModuleRef ac_translate_nir_to_llvm(struct ac_llvm_compiler *ac_llvm,
struct nir_shader *const *shaders,
int shader_count,
struct radv_shader_variant_info *shader_info,
ac_llvm_context_init(&ctx.ac, ctx.context, options->chip_class,
options->family);
- ctx.ac.module = ac_create_module(tm, ctx.context);
+ ctx.ac.module = ac_create_module(ac_llvm->tm, ctx.context);
enum ac_float_mode float_mode =
options->unsafe_math ? AC_FLOAT_MODE_UNSAFE_FP_MATH :
if (options->dump_preoptir)
ac_dump_module(ctx.ac.module);
- ac_llvm_finalize_module(&ctx, passmgr, options);
+ ac_llvm_finalize_module(&ctx, ac_llvm->passmgr, options);
if (shader_count == 1)
ac_nir_eliminate_const_vs_outputs(&ctx);
static unsigned ac_llvm_compile(LLVMModuleRef M,
struct ac_shader_binary *binary,
- LLVMTargetMachineRef tm)
+ struct ac_llvm_compiler *ac_llvm)
{
unsigned retval = 0;
char *err;
&retval);
/* Compile IR*/
- mem_err = LLVMTargetMachineEmitToMemoryBuffer(tm, M, LLVMObjectFile,
+ mem_err = LLVMTargetMachineEmitToMemoryBuffer(ac_llvm->tm, M, LLVMObjectFile,
&err, &out_buffer);
/* Process Errors/Warnings */
return retval;
}
-static void ac_compile_llvm_module(LLVMTargetMachineRef tm,
+static void ac_compile_llvm_module(struct ac_llvm_compiler *ac_llvm,
LLVMModuleRef llvm_module,
struct ac_shader_binary *binary,
struct ac_shader_config *config,
LLVMDisposeMessage(llvm_ir);
}
- int v = ac_llvm_compile(llvm_module, binary, tm);
+ int v = ac_llvm_compile(llvm_module, binary, ac_llvm);
if (v) {
fprintf(stderr, "compile failed\n");
}
}
void
-radv_compile_nir_shader(LLVMTargetMachineRef tm,
- LLVMPassManagerRef passmgr,
+radv_compile_nir_shader(struct ac_llvm_compiler *ac_llvm,
struct ac_shader_binary *binary,
struct ac_shader_config *config,
struct radv_shader_variant_info *shader_info,
LLVMModuleRef llvm_module;
- llvm_module = ac_translate_nir_to_llvm(tm, passmgr, nir, nir_count, shader_info,
+ llvm_module = ac_translate_nir_to_llvm(ac_llvm, nir, nir_count, shader_info,
options);
- ac_compile_llvm_module(tm, llvm_module, binary, config, shader_info,
+ ac_compile_llvm_module(ac_llvm, llvm_module, binary, config, shader_info,
nir[0]->info.stage, options);
for (int i = 0; i < nir_count; ++i)
}
void
-radv_compile_gs_copy_shader(LLVMTargetMachineRef tm,
- LLVMPassManagerRef passmgr,
+radv_compile_gs_copy_shader(struct ac_llvm_compiler *ac_llvm,
struct nir_shader *geom_shader,
struct ac_shader_binary *binary,
struct ac_shader_config *config,
ac_llvm_context_init(&ctx.ac, ctx.context, options->chip_class,
options->family);
- ctx.ac.module = ac_create_module(tm, ctx.context);
+ ctx.ac.module = ac_create_module(ac_llvm->tm, ctx.context);
ctx.is_gs_copy_shader = true;
LLVMBuildRetVoid(ctx.ac.builder);
- ac_llvm_finalize_module(&ctx, passmgr, options);
+ ac_llvm_finalize_module(&ctx, ac_llvm->passmgr, options);
- ac_compile_llvm_module(tm, ctx.ac.module, binary, config, shader_info,
+ ac_compile_llvm_module(ac_llvm, ctx.ac.module, binary, config, shader_info,
MESA_SHADER_VERTEX, options);
}
#include "ac_gpu_info.h"
#include "ac_surface.h"
#include "ac_llvm_build.h"
+#include "ac_llvm_util.h"
#include "radv_descriptor_set.h"
#include "radv_extensions.h"
#include "radv_cs.h"
struct radv_shader_variant_info;
struct radv_nir_compiler_options;
-void radv_compile_gs_copy_shader(LLVMTargetMachineRef tm,
- LLVMPassManagerRef passmgr,
+void radv_compile_gs_copy_shader(struct ac_llvm_compiler *ac_llvm,
struct nir_shader *geom_shader,
struct ac_shader_binary *binary,
struct ac_shader_config *config,
struct radv_shader_variant_info *shader_info,
const struct radv_nir_compiler_options *option);
-void radv_compile_nir_shader(LLVMTargetMachineRef tm,
- LLVMPassManagerRef passmgr,
+void radv_compile_nir_shader(struct ac_llvm_compiler *ac_llvm,
struct ac_shader_binary *binary,
struct ac_shader_config *config,
struct radv_shader_variant_info *shader_info,
enum ac_target_machine_options tm_options = 0;
struct radv_shader_variant *variant;
struct ac_shader_binary binary;
- LLVMTargetMachineRef tm;
- LLVMPassManagerRef passmgr;
+ struct ac_llvm_compiler ac_llvm;
variant = calloc(1, sizeof(struct radv_shader_variant));
if (!variant)
tm_options |= AC_TM_CHECK_IR;
radv_init_llvm_once();
- tm = ac_create_target_machine(chip_family, tm_options, NULL);
- passmgr = ac_create_passmgr(NULL, tm_options & AC_TM_CHECK_IR);
+ ac_init_llvm_compiler(&ac_llvm, false, chip_family, tm_options);
if (gs_copy_shader) {
assert(shader_count == 1);
- radv_compile_gs_copy_shader(tm, passmgr, *shaders, &binary,
+ radv_compile_gs_copy_shader(&ac_llvm, *shaders, &binary,
&variant->config, &variant->info,
options);
} else {
- radv_compile_nir_shader(tm, passmgr, &binary, &variant->config,
+ radv_compile_nir_shader(&ac_llvm, &binary, &variant->config,
&variant->info, shaders, shader_count,
options);
}
- LLVMDisposePassManager(passmgr);
- LLVMDisposeTargetMachine(tm);
+ ac_destroy_llvm_compiler(&ac_llvm);
radv_fill_shader_variant(device, variant, &binary, stage);