radeonsi: merge si_llvm_get_amdgpu_target into ac_get_llvm_target

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
This commit is contained in:
Marek Olšák 2017-07-04 22:38:37 +02:00
parent c351037d6c
commit 4560f2b90a
5 changed files with 12 additions and 53 deletions

View File

@ -40,21 +40,23 @@ static void ac_init_llvm_target()
LLVMInitializeAMDGPUTargetMC();
LLVMInitializeAMDGPUAsmPrinter();
/*
* Workaround for bug in llvm 4.0 that causes image intrinsics
/* For inline assembly. */
LLVMInitializeAMDGPUAsmParser();
/* Workaround for bug in llvm 4.0 that causes image intrinsics
* to disappear.
* https://reviews.llvm.org/D26348
*/
#if HAVE_LLVM >= 0x0400
const char *argv[2] = {"mesa", "-simplifycfg-sink-common=false"};
LLVMParseCommandLineOptions(2, argv, NULL);
#endif
if (HAVE_LLVM >= 0x0400) {
/* "mesa" is the prefix for error messages */
const char *argv[2] = { "mesa", "-simplifycfg-sink-common=false" };
LLVMParseCommandLineOptions(2, argv, NULL);
}
}
static once_flag ac_init_llvm_target_once_flag = ONCE_FLAG_INIT;
static LLVMTargetRef ac_get_llvm_target(const char *triple)
LLVMTargetRef ac_get_llvm_target(const char *triple)
{
LLVMTargetRef target = NULL;
char *err_message = NULL;

View File

@ -60,6 +60,7 @@ enum ac_target_machine_options {
};
LLVMTargetMachineRef ac_create_target_machine(enum radeon_family family, enum ac_target_machine_options tm_options);
LLVMTargetRef ac_get_llvm_target(const char *triple);
void ac_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes);
bool ac_is_sgpr_param(LLVMValueRef param);
void ac_add_function_attr(LLVMContextRef ctx, LLVMValueRef function,

View File

@ -145,7 +145,7 @@ si_create_llvm_target_machine(struct si_screen *sscreen)
sscreen->b.chip_class >= GFX9 ? ",+xnack" : ",-xnack",
sscreen->b.debug_flags & DBG_SI_SCHED ? ",+si-scheduler" : "");
return LLVMCreateTargetMachine(si_llvm_get_amdgpu_target(triple), triple,
return LLVMCreateTargetMachine(ac_get_llvm_target(triple), triple,
r600_get_llvm_processor_name(sscreen->b.family),
features,
LLVMCodeGenLevelDefault,

View File

@ -246,8 +246,6 @@ si_shader_context(struct lp_build_tgsi_context *bld_base)
void si_llvm_add_attribute(LLVMValueRef F, const char *name, int value);
LLVMTargetRef si_llvm_get_amdgpu_target(const char *triple);
unsigned si_llvm_compile(LLVMModuleRef M, struct ac_shader_binary *binary,
LLVMTargetMachineRef tm,
struct pipe_debug_callback *debug);

View File

@ -40,7 +40,6 @@
#include <stdio.h>
#include <llvm-c/Transforms/IPO.h>
#include <llvm-c/Transforms/Scalar.h>
#include <llvm-c/Support.h>
/* Data for if/else/endif and bgnloop/endloop control flow structures.
*/
@ -66,47 +65,6 @@ void si_llvm_add_attribute(LLVMValueRef F, const char *name, int value)
LLVMAddTargetDependentFunctionAttr(F, name, str);
}
static void init_amdgpu_target()
{
LLVMInitializeAMDGPUTargetInfo();
LLVMInitializeAMDGPUTarget();
LLVMInitializeAMDGPUTargetMC();
LLVMInitializeAMDGPUAsmPrinter();
/* For inline assembly. */
LLVMInitializeAMDGPUAsmParser();
if (HAVE_LLVM >= 0x0400) {
/*
* Workaround for bug in llvm 4.0 that causes image intrinsics
* to disappear.
* https://reviews.llvm.org/D26348
*/
const char *argv[2] = {"mesa", "-simplifycfg-sink-common=false"};
LLVMParseCommandLineOptions(2, argv, NULL);
}
}
static once_flag init_amdgpu_target_once_flag = ONCE_FLAG_INIT;
LLVMTargetRef si_llvm_get_amdgpu_target(const char *triple)
{
LLVMTargetRef target = NULL;
char *err_message = NULL;
call_once(&init_amdgpu_target_once_flag, init_amdgpu_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;
}
struct si_llvm_diagnostics {
struct pipe_debug_callback *debug;
unsigned retval;