diff options
-rw-r--r-- | src/gallium/drivers/radeon/r600_pipe_common.c | 11 | ||||
-rw-r--r-- | src/gallium/drivers/radeon/radeon_llvm_emit.c | 21 | ||||
-rw-r--r-- | src/gallium/drivers/radeon/radeon_llvm_emit.h | 2 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_pipe.c | 9 |
4 files changed, 27 insertions, 16 deletions
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c index d4133d8cbad..d46b3b38f86 100644 --- a/src/gallium/drivers/radeon/r600_pipe_common.c +++ b/src/gallium/drivers/radeon/r600_pipe_common.c @@ -499,6 +499,12 @@ static int r600_get_compute_param(struct pipe_screen *screen, switch (param) { case PIPE_COMPUTE_CAP_IR_TARGET: { const char *gpu; + const char *triple; + if (rscreen->family <= CHIP_ARUBA || HAVE_LLVM < 0x0306) { + triple = "r600--"; + } else { + triple = "amdgcn--"; + } switch(rscreen->family) { /* Clang < 3.6 is missing Hainan in its list of * GPUs, so we need to use the name of a similar GPU. @@ -513,9 +519,10 @@ static int r600_get_compute_param(struct pipe_screen *screen, break; } if (ret) { - sprintf(ret, "%s-r600--", gpu); + sprintf(ret, "%s-%s", gpu, triple); + } - return (8 + strlen(gpu)) * sizeof(char); + return (strlen(triple) + strlen(gpu)) * sizeof(char); } case PIPE_COMPUTE_CAP_GRID_DIMENSION: if (ret) { diff --git a/src/gallium/drivers/radeon/radeon_llvm_emit.c b/src/gallium/drivers/radeon/radeon_llvm_emit.c index 4f288e42b1f..b98afb246ae 100644 --- a/src/gallium/drivers/radeon/radeon_llvm_emit.c +++ b/src/gallium/drivers/radeon/radeon_llvm_emit.c @@ -98,20 +98,19 @@ static void init_r600_target() } } -LLVMTargetRef radeon_llvm_get_r600_target() +LLVMTargetRef radeon_llvm_get_r600_target(const char *triple) { LLVMTargetRef target = NULL; + char *err_message = NULL; + init_r600_target(); - for (target = LLVMGetFirstTarget(); target; - target = LLVMGetNextTarget(target)) { - if (!strncmp(LLVMGetTargetName(target), "r600", 4)) { - break; + if (LLVMGetTargetFromTriple(triple, &target, &err_message)) { + fprintf(stderr, "Cannot find target for triple %s ", triple); + if (err_message) { + fprintf(stderr, "%s\n", err_message); } - } - - if (!target) { - fprintf(stderr, "Can't find target r600\n"); + LLVMDisposeMessage(err_message); return NULL; } return target; @@ -155,7 +154,8 @@ unsigned radeon_llvm_compile(LLVMModuleRef M, struct radeon_shader_binary *binar LLVMBool mem_err; if (!tm) { - LLVMTargetRef target = radeon_llvm_get_r600_target(); + strncpy(triple, "r600--", TRIPLE_STRING_LEN); + LLVMTargetRef target = radeon_llvm_get_r600_target(triple); if (!target) { return 1; } @@ -165,7 +165,6 @@ unsigned radeon_llvm_compile(LLVMModuleRef M, struct radeon_shader_binary *binar LLVMDumpModule(M); strncpy(fs, "+DumpCode", FS_STRING_LEN); } - strncpy(triple, "r600--", TRIPLE_STRING_LEN); tm = LLVMCreateTargetMachine(target, triple, cpu, fs, LLVMCodeGenLevelDefault, LLVMRelocDefault, LLVMCodeModelDefault); diff --git a/src/gallium/drivers/radeon/radeon_llvm_emit.h b/src/gallium/drivers/radeon/radeon_llvm_emit.h index 66217b5ce5f..3ccef78e36d 100644 --- a/src/gallium/drivers/radeon/radeon_llvm_emit.h +++ b/src/gallium/drivers/radeon/radeon_llvm_emit.h @@ -34,7 +34,7 @@ struct radeon_shader_binary; void radeon_llvm_shader_type(LLVMValueRef F, unsigned type); -LLVMTargetRef radeon_llvm_get_r600_target(void); +LLVMTargetRef radeon_llvm_get_r600_target(const char *triple); unsigned radeon_llvm_compile( LLVMModuleRef M, diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index 4b7156140b7..02c02ab07d3 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -485,6 +485,11 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws) { struct si_screen *sscreen = CALLOC_STRUCT(si_screen); LLVMTargetRef r600_target; +#if HAVE_LLVM >= 0x0306 + const char *triple = "amdgcn--"; +#else + const char *triple = "r600--"; +#endif if (sscreen == NULL) { return NULL; } @@ -514,8 +519,8 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws) #if HAVE_LLVM >= 0x0306 /* Initialize LLVM TargetMachine */ - r600_target = radeon_llvm_get_r600_target(); - sscreen->tm = LLVMCreateTargetMachine(r600_target, "r600--", + r600_target = radeon_llvm_get_r600_target(triple); + sscreen->tm = LLVMCreateTargetMachine(r600_target, triple, r600_get_llvm_processor_name(sscreen->b.family), "+DumpCode", LLVMCodeGenLevelDefault, LLVMRelocDefault, LLVMCodeModelDefault); |