aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2018-06-27 08:36:41 +1000
committerDave Airlie <[email protected]>2018-07-04 05:15:23 +1000
commit473be16c745d0d78a0be71828d05aeb5d8a7cb76 (patch)
treef0bc4bf306d48c9f6bfbb10f89563c3a8d29aed1
parent590cc7c8f67902423d812ab219afec93031c6252 (diff)
ac/radv: split the non-common init_once code from the common target code. (v2)
This just splits out the non-shared code and reuses ac_get_llvm_target in radv. v2: rebase on Marek's patch - fixup brace position/whitespace Reviewed-by: Marek Olšák <[email protected]>
-rw-r--r--src/amd/common/ac_llvm_util.c7
-rw-r--r--src/amd/common/ac_llvm_util.h2
-rw-r--r--src/amd/vulkan/radv_shader.c20
-rw-r--r--src/gallium/drivers/radeonsi/si_pipe.c1
4 files changed, 12 insertions, 18 deletions
diff --git a/src/amd/common/ac_llvm_util.c b/src/amd/common/ac_llvm_util.c
index 99cc677edce..25ff4a8c22a 100644
--- a/src/amd/common/ac_llvm_util.c
+++ b/src/amd/common/ac_llvm_util.c
@@ -57,13 +57,16 @@ static void ac_init_llvm_target()
static once_flag ac_init_llvm_target_once_flag = ONCE_FLAG_INIT;
+void ac_init_llvm_once(void)
+{
+ call_once(&ac_init_llvm_target_once_flag, ac_init_llvm_target);
+}
+
LLVMTargetRef ac_get_llvm_target(const char *triple)
{
LLVMTargetRef target = NULL;
char *err_message = NULL;
- call_once(&ac_init_llvm_target_once_flag, ac_init_llvm_target);
-
if (LLVMGetTargetFromTriple(triple, &target, &err_message)) {
fprintf(stderr, "Cannot find target for triple %s ", triple);
if (err_message) {
diff --git a/src/amd/common/ac_llvm_util.h b/src/amd/common/ac_llvm_util.h
index 6e6d15bb56c..4311c5ea8a4 100644
--- a/src/amd/common/ac_llvm_util.h
+++ b/src/amd/common/ac_llvm_util.h
@@ -111,6 +111,8 @@ ac_get_store_intr_attribs(bool writeonly_memory)
unsigned
ac_count_scratch_private_memory(LLVMValueRef function);
+void ac_init_llvm_once(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c
index 9470c4907c2..749e89e4bf7 100644
--- a/src/amd/vulkan/radv_shader.c
+++ b/src/amd/vulkan/radv_shader.c
@@ -521,22 +521,9 @@ static void radv_init_llvm_target()
static once_flag radv_init_llvm_target_once_flag = ONCE_FLAG_INIT;
-static LLVMTargetRef radv_get_llvm_target(const char *triple)
+static void radv_init_llvm_once(void)
{
- LLVMTargetRef target = NULL;
- char *err_message = NULL;
-
call_once(&radv_init_llvm_target_once_flag, radv_init_llvm_target);
-
- if (LLVMGetTargetFromTriple(triple, &target, &err_message)) {
- fprintf(stderr, "Cannot find target for triple %s ", triple);
- if (err_message) {
- fprintf(stderr, "%s\n", err_message);
- }
- LLVMDisposeMessage(err_message);
- return NULL;
- }
- return target;
}
static LLVMTargetMachineRef radv_create_target_machine(enum radeon_family family,
@@ -546,7 +533,7 @@ static LLVMTargetMachineRef radv_create_target_machine(enum radeon_family family
assert(family >= CHIP_TAHITI);
char features[256];
const char *triple = (tm_options & AC_TM_SUPPORTS_SPILL) ? "amdgcn-mesa-mesa3d" : "amdgcn--";
- LLVMTargetRef target = radv_get_llvm_target(triple);
+ LLVMTargetRef target = ac_get_llvm_target(triple);
snprintf(features, sizeof(features),
"+DumpCode,+vgpr-spilling,-fp32-denormals,+fp64-denormals%s%s%s%s",
@@ -604,8 +591,9 @@ shader_variant_create(struct radv_device *device,
tm_options |= AC_TM_SUPPORTS_SPILL;
if (device->instance->perftest_flags & RADV_PERFTEST_SISCHED)
tm_options |= AC_TM_SISCHED;
- tm = radv_create_target_machine(chip_family, tm_options, NULL);
+ radv_init_llvm_once();
+ tm = radv_create_target_machine(chip_family, tm_options, NULL);
if (gs_copy_shader) {
assert(shader_count == 1);
radv_compile_gs_copy_shader(tm, *shaders, &binary,
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
index 5da8a4b9873..0d6d93a7358 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -120,6 +120,7 @@ static void si_init_compiler(struct si_screen *sscreen,
(!sscreen->llvm_has_working_vgpr_indexing ? AC_TM_PROMOTE_ALLOCA_TO_SCRATCH : 0);
const char *triple;
+ ac_init_llvm_once();
compiler->tm = ac_create_target_machine(sscreen->info.family,
tm_options, &triple);
if (!compiler->tm)