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;
};
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,
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,
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);
#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.
*/
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;