radeon/llvm: Use amdgcn triple for SI+ on LLVM >= 3.6
authorTom Stellard <thomas.stellard@amd.com>
Tue, 23 Dec 2014 15:26:23 +0000 (10:26 -0500)
committerTom Stellard <thomas.stellard@amd.com>
Tue, 6 Jan 2015 20:53:21 +0000 (12:53 -0800)
src/gallium/drivers/radeon/r600_pipe_common.c
src/gallium/drivers/radeon/radeon_llvm_emit.c
src/gallium/drivers/radeon/radeon_llvm_emit.h
src/gallium/drivers/radeonsi/si_pipe.c

index d4133d8cbad259514911281c55fe62ad86c277ab..d46b3b38f8685a5638436ca6b1f54fa816f30b66 100644 (file)
@@ -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) {
index 4f288e42b1f24d83a3c543f9eb6f660d36947dbb..b98afb246aeaa12e4a67a74061629a5091d27951 100644 (file)
@@ -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);
index 66217b5ce5f5d5d7471de010280e869d67c93f61..3ccef78e36d464f3ece2ea5b93ec2ff7d871aaba 100644 (file)
@@ -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,
index 4b7156140b787f1966e9c5750941d41e358966d4..02c02ab07d314234112f136f388bfac24cebb021 100644 (file)
@@ -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);