ac: Silence a compiler warning about results[0].
[mesa.git] / src / amd / common / ac_llvm_util.c
index e20456e2ff8f85e096ac7351f2d65b215cf06501..675926ea679bf64580a38d0e65417713d0a32b82 100644 (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;
@@ -110,22 +112,30 @@ static const char *ac_get_llvm_processor_name(enum radeon_family family)
        case CHIP_POLARIS11:
        case CHIP_POLARIS12:
                return "polaris11";
+       case CHIP_VEGA10:
+       case CHIP_RAVEN:
+               return "gfx900";
        default:
                return "";
        }
 }
 
-LLVMTargetMachineRef ac_create_target_machine(enum radeon_family family, bool supports_spill)
+LLVMTargetMachineRef ac_create_target_machine(enum radeon_family family, enum ac_target_machine_options tm_options)
 {
        assert(family >= CHIP_TAHITI);
-
-       const char *triple = supports_spill ? "amdgcn-mesa-mesa3d" : "amdgcn--";
+       char features[256];
+       const char *triple = (tm_options & AC_TM_SUPPORTS_SPILL) ? "amdgcn-mesa-mesa3d" : "amdgcn--";
        LLVMTargetRef target = ac_get_llvm_target(triple);
+
+       snprintf(features, sizeof(features),
+                "+DumpCode,+vgpr-spilling,-fp32-denormals%s",
+                tm_options & AC_TM_SISCHED ? ",+si-scheduler" : "");
+       
        LLVMTargetMachineRef tm = LLVMCreateTargetMachine(
                                     target,
                                     triple,
                                     ac_get_llvm_processor_name(family),
-                                    "+DumpCode,+vgpr-spilling,-fp32-denormals,-xnack",
+                                    features,
                                     LLVMCodeGenLevelDefault,
                                     LLVMRelocDefault,
                                     LLVMCodeModelDefault);
@@ -217,3 +227,13 @@ ac_dump_module(LLVMModuleRef module)
        fprintf(stderr, "%s", str);
        LLVMDisposeMessage(str);
 }
+
+void
+ac_llvm_add_target_dep_function_attr(LLVMValueRef F,
+                                    const char *name, int value)
+{
+       char str[16];
+
+       snprintf(str, sizeof(str), "%i", value);
+       LLVMAddTargetDependentFunctionAttr(F, name, str);
+}