summaryrefslogtreecommitdiffstats
path: root/src/amd
diff options
context:
space:
mode:
Diffstat (limited to 'src/amd')
-rw-r--r--src/amd/common/ac_llvm_helper.cpp10
-rw-r--r--src/amd/common/ac_llvm_util.h1
-rw-r--r--src/amd/vulkan/radv_nir_to_llvm.c12
3 files changed, 13 insertions, 10 deletions
diff --git a/src/amd/common/ac_llvm_helper.cpp b/src/amd/common/ac_llvm_helper.cpp
index 1a2aee3bc9a..495bd98da9c 100644
--- a/src/amd/common/ac_llvm_helper.cpp
+++ b/src/amd/common/ac_llvm_helper.cpp
@@ -61,6 +61,16 @@ bool ac_llvm_is_function(LLVMValueRef v)
return LLVMGetValueKind(v) == LLVMFunctionValueKind;
}
+LLVMModuleRef ac_create_module(LLVMTargetMachineRef tm, LLVMContextRef ctx)
+{
+ llvm::TargetMachine *TM = reinterpret_cast<llvm::TargetMachine*>(tm);
+ LLVMModuleRef module = LLVMModuleCreateWithNameInContext("mesa-shader", ctx);
+
+ llvm::unwrap(module)->setTargetTriple(TM->getTargetTriple().getTriple());
+ llvm::unwrap(module)->setDataLayout(TM->createDataLayout());
+ return module;
+}
+
LLVMBuilderRef ac_create_builder(LLVMContextRef ctx,
enum ac_float_mode float_mode)
{
diff --git a/src/amd/common/ac_llvm_util.h b/src/amd/common/ac_llvm_util.h
index 0aa803c5bc1..6e6d15bb56c 100644
--- a/src/amd/common/ac_llvm_util.h
+++ b/src/amd/common/ac_llvm_util.h
@@ -83,6 +83,7 @@ void ac_dump_module(LLVMModuleRef module);
LLVMValueRef ac_llvm_get_called_value(LLVMValueRef call);
bool ac_llvm_is_function(LLVMValueRef v);
+LLVMModuleRef ac_create_module(LLVMTargetMachineRef tm, LLVMContextRef ctx);
LLVMBuilderRef ac_create_builder(LLVMContextRef ctx,
enum ac_float_mode float_mode);
diff --git a/src/amd/vulkan/radv_nir_to_llvm.c b/src/amd/vulkan/radv_nir_to_llvm.c
index cd8d86603bc..ce6d5e1547d 100644
--- a/src/amd/vulkan/radv_nir_to_llvm.c
+++ b/src/amd/vulkan/radv_nir_to_llvm.c
@@ -3165,14 +3165,7 @@ LLVMModuleRef ac_translate_nir_to_llvm(LLVMTargetMachineRef tm,
ac_llvm_context_init(&ctx.ac, ctx.context, options->chip_class,
options->family);
- ctx.ac.module = LLVMModuleCreateWithNameInContext("shader", ctx.context);
- LLVMSetTarget(ctx.ac.module, options->supports_spill ? "amdgcn-mesa-mesa3d" : "amdgcn--");
-
- LLVMTargetDataRef data_layout = LLVMCreateTargetDataLayout(tm);
- char *data_layout_str = LLVMCopyStringRepOfTargetData(data_layout);
- LLVMSetDataLayout(ctx.ac.module, data_layout_str);
- LLVMDisposeTargetData(data_layout);
- LLVMDisposeMessage(data_layout_str);
+ ctx.ac.module = ac_create_module(tm, ctx.context);
enum ac_float_mode float_mode =
options->unsafe_math ? AC_FLOAT_MODE_UNSAFE_FP_MATH :
@@ -3613,10 +3606,9 @@ radv_compile_gs_copy_shader(LLVMTargetMachineRef tm,
ac_llvm_context_init(&ctx.ac, ctx.context, options->chip_class,
options->family);
- ctx.ac.module = LLVMModuleCreateWithNameInContext("shader", ctx.context);
+ ctx.ac.module = ac_create_module(tm, ctx.context);
ctx.is_gs_copy_shader = true;
- LLVMSetTarget(ctx.ac.module, "amdgcn--");
enum ac_float_mode float_mode =
options->unsafe_math ? AC_FLOAT_MODE_UNSAFE_FP_MATH :