amd: replace major llvm version checks with LLVM_VERSION_MAJOR
authorEric Engestrom <eric.engestrom@intel.com>
Tue, 27 Aug 2019 23:06:03 +0000 (00:06 +0100)
committerEric Engestrom <eric.engestrom@intel.com>
Fri, 6 Sep 2019 21:26:29 +0000 (22:26 +0100)
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
src/amd/common/ac_llvm_build.c
src/amd/common/ac_llvm_util.h
src/amd/common/ac_nir_to_llvm.c
src/amd/vulkan/radv_device.c
src/amd/vulkan/radv_extensions.py
src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c
src/gallium/drivers/radeonsi/si_get.c
src/gallium/drivers/radeonsi/si_pipe.c
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c

index f4d91567fa1a48b63febb93d90573e8538e0a2f1..94ec569ad9fcf23bc7ce3e71a425eb115cb7ca04 100644 (file)
@@ -26,6 +26,7 @@
 #include "ac_llvm_build.h"
 
 #include <llvm-c/Core.h>
+#include <llvm/Config/llvm-config.h>
 
 #include "c11/threads.h"
 
@@ -443,7 +444,7 @@ ac_build_optimization_barrier(struct ac_llvm_context *ctx,
 LLVMValueRef
 ac_build_shader_clock(struct ac_llvm_context *ctx)
 {
-       const char *intr = HAVE_LLVM >= 0x0900 && ctx->chip_class >= GFX8 ?
+       const char *intr = LLVM_VERSION_MAJOR >= 9 && ctx->chip_class >= GFX8 ?
                                "llvm.amdgcn.s.memrealtime" : "llvm.readcyclecounter";
        LLVMValueRef tmp = ac_build_intrinsic(ctx, intr, ctx->i64, NULL, 0, 0);
        return LLVMBuildBitCast(ctx->builder, tmp, ctx->v2i32, "");
@@ -455,7 +456,7 @@ ac_build_ballot(struct ac_llvm_context *ctx,
 {
        const char *name;
 
-       if (HAVE_LLVM >= 0x900) {
+       if (LLVM_VERSION_MAJOR >= 9) {
                if (ctx->wave_size == 64)
                        name = "llvm.amdgcn.icmp.i64.i32";
                else
@@ -485,7 +486,7 @@ ac_build_ballot(struct ac_llvm_context *ctx,
 LLVMValueRef ac_get_i1_sgpr_mask(struct ac_llvm_context *ctx,
                                 LLVMValueRef value)
 {
-       const char *name = HAVE_LLVM >= 0x900 ? "llvm.amdgcn.icmp.i64.i1" : "llvm.amdgcn.icmp.i1";
+       const char *name = LLVM_VERSION_MAJOR >= 9 ? "llvm.amdgcn.icmp.i64.i1" : "llvm.amdgcn.icmp.i1";
        LLVMValueRef args[3] = {
                value,
                ctx->i1false,
@@ -1511,7 +1512,7 @@ ac_build_tbuffer_load_short(struct ac_llvm_context *ctx,
 {
        LLVMValueRef res;
 
-       if (HAVE_LLVM >= 0x900) {
+       if (LLVM_VERSION_MAJOR >= 9) {
                voffset = LLVMBuildAdd(ctx->builder, voffset, immoffset, "");
 
                /* LLVM 9+ supports i8/i16 with struct/raw intrinsics. */
@@ -1543,7 +1544,7 @@ ac_build_tbuffer_load_byte(struct ac_llvm_context *ctx,
 {
        LLVMValueRef res;
 
-       if (HAVE_LLVM >= 0x900) {
+       if (LLVM_VERSION_MAJOR >= 9) {
                voffset = LLVMBuildAdd(ctx->builder, voffset, immoffset, "");
 
                /* LLVM 9+ supports i8/i16 with struct/raw intrinsics. */
@@ -1685,7 +1686,7 @@ ac_build_opencoded_load_format(struct ac_llvm_context *ctx,
                load_log_size += -log_recombine;
        }
 
-       assert(load_log_size >= 2 || HAVE_LLVM >= 0x0900);
+       assert(load_log_size >= 2 || LLVM_VERSION_MAJOR >= 9);
 
        LLVMValueRef loads[32]; /* up to 32 bytes */
        for (unsigned i = 0; i < load_num_channels; ++i) {
@@ -1955,7 +1956,7 @@ ac_build_tbuffer_store_short(struct ac_llvm_context *ctx,
 {
        vdata = LLVMBuildBitCast(ctx->builder, vdata, ctx->i16, "");
 
-       if (HAVE_LLVM >= 0x900) {
+       if (LLVM_VERSION_MAJOR >= 9) {
                /* LLVM 9+ supports i8/i16 with struct/raw intrinsics. */
                ac_build_buffer_store_common(ctx, rsrc, vdata, NULL,
                                             voffset, soffset, 1,
@@ -1982,7 +1983,7 @@ ac_build_tbuffer_store_byte(struct ac_llvm_context *ctx,
 {
        vdata = LLVMBuildBitCast(ctx->builder, vdata, ctx->i8, "");
 
-       if (HAVE_LLVM >= 0x900) {
+       if (LLVM_VERSION_MAJOR >= 9) {
                /* LLVM 9+ supports i8/i16 with struct/raw intrinsics. */
                ac_build_buffer_store_common(ctx, rsrc, vdata, NULL,
                                             voffset, soffset, 1,
index 8209b6dcabcecb8081089f6bc3c1b3b0b29977d6..60c9a17e447d77b1340aa4808c6f16c69c203bf1 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <stdbool.h>
 #include <llvm-c/TargetMachine.h>
+#include <llvm/Config/llvm-config.h>
 
 #include "amd_family.h"
 
@@ -152,7 +153,7 @@ ac_has_vec3_support(enum chip_class chip, bool use_format)
                return false;
        }
 
-       return HAVE_LLVM >= 0x900;
+       return LLVM_VERSION_MAJOR >= 9;
 }
 
 #ifdef __cplusplus
index 13578770d4a81f7228da2461a54e617aebaec02f..5ed21b1650b86f6008ad8b7045fafc38f8882a9b 100644 (file)
@@ -21,6 +21,8 @@
  * IN THE SOFTWARE.
  */
 
+#include <llvm/Config/llvm-config.h>
+
 #include "ac_nir_to_llvm.h"
 #include "ac_llvm_build.h"
 #include "ac_llvm_util.h"
@@ -1806,7 +1808,7 @@ static LLVMValueRef visit_atomic_ssbo(struct ac_nir_context *ctx,
        params[arg_count++] = ac_llvm_extract_elem(&ctx->ac, get_src(ctx, instr->src[2]), 0);
        params[arg_count++] = descriptor;
 
-       if (HAVE_LLVM >= 0x900) {
+       if (LLVM_VERSION_MAJOR >= 9) {
                /* XXX: The new raw/struct atomic intrinsics are buggy with
                 * LLVM 8, see r358579.
                 */
@@ -2546,7 +2548,7 @@ static LLVMValueRef get_image_buffer_descriptor(struct ac_nir_context *ctx,
                                                bool write, bool atomic)
 {
        LLVMValueRef rsrc = get_image_descriptor(ctx, instr, AC_DESC_BUFFER, write);
-       if (ctx->ac.chip_class == GFX9 && HAVE_LLVM < 0x900 && atomic) {
+       if (ctx->ac.chip_class == GFX9 && LLVM_VERSION_MAJOR < 9 && atomic) {
                LLVMValueRef elem_count = LLVMBuildExtractElement(ctx->ac.builder, rsrc, LLVMConstInt(ctx->ac.i32, 2, 0), "");
                LLVMValueRef stride = LLVMBuildExtractElement(ctx->ac.builder, rsrc, LLVMConstInt(ctx->ac.i32, 1, 0), "");
                stride = LLVMBuildLShr(ctx->ac.builder, stride, LLVMConstInt(ctx->ac.i32, 16, 0), "");
@@ -2791,7 +2793,7 @@ static LLVMValueRef visit_image_atomic(struct ac_nir_context *ctx,
                params[param_count++] = LLVMBuildExtractElement(ctx->ac.builder, get_src(ctx, instr->src[1]),
                                                                ctx->ac.i32_0, ""); /* vindex */
                params[param_count++] = ctx->ac.i32_0; /* voffset */
-               if (HAVE_LLVM >= 0x900) {
+               if (LLVM_VERSION_MAJOR >= 9) {
                        /* XXX: The new raw/struct atomic intrinsics are buggy
                         * with LLVM 8, see r358579.
                         */
@@ -3052,7 +3054,7 @@ static LLVMValueRef visit_var_atomic(struct ac_nir_context *ctx,
        LLVMValueRef result;
        LLVMValueRef src = get_src(ctx, instr->src[src_idx]);
 
-       const char *sync_scope = HAVE_LLVM >= 0x0900 ? "workgroup-one-as" : "workgroup";
+       const char *sync_scope = LLVM_VERSION_MAJOR >= 9 ? "workgroup-one-as" : "workgroup";
 
        if (instr->intrinsic == nir_intrinsic_shared_atomic_comp_swap ||
            instr->intrinsic == nir_intrinsic_deref_atomic_comp_swap) {
@@ -4723,7 +4725,7 @@ setup_constant_data(struct ac_nir_context *ctx,
         * the code sections. See https://reviews.llvm.org/D65813.
         */
        unsigned address_space =
-               HAVE_LLVM < 0x1000 ? AC_ADDR_SPACE_GLOBAL : AC_ADDR_SPACE_CONST;
+               LLVM_VERSION_MAJOR < 10 ? AC_ADDR_SPACE_GLOBAL : AC_ADDR_SPACE_CONST;
 
        LLVMValueRef global =
                LLVMAddGlobalInAddressSpace(ctx->ac.module, type,
index 265a7bd791298d43cd55d40394f1ca2ab331c630..b9d6ccc4c032a4653ff6c0d36104cffbcdcba4da 100644 (file)
@@ -29,6 +29,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <llvm/Config/llvm-config.h>
 #include "radv_debug.h"
 #include "radv_private.h"
 #include "radv_shader.h"
@@ -531,7 +532,7 @@ radv_handle_per_app_options(struct radv_instance *instance,
                 * load/store memory operations.
                 * See https://reviews.llvm.org/D61313
                 */
-               if (HAVE_LLVM < 0x900)
+               if (LLVM_VERSION_MAJOR < 9)
                        instance->debug_flags |= RADV_DEBUG_NO_LOAD_STORE_OPT;
        } else if (!strcmp(name, "Wolfenstein: Youngblood")) {
                if (!(instance->debug_flags & RADV_DEBUG_NO_SHADER_BALLOT)) {
@@ -857,7 +858,7 @@ void radv_GetPhysicalDeviceFeatures2(
                        features->storageBuffer16BitAccess = enabled;
                        features->uniformAndStorageBuffer16BitAccess = enabled;
                        features->storagePushConstant16 = enabled;
-                       features->storageInputOutput16 = enabled && HAVE_LLVM >= 0x900;
+                       features->storageInputOutput16 = enabled && LLVM_VERSION_MAJOR >= 9;
                        break;
                }
                case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES: {
@@ -963,8 +964,8 @@ void radv_GetPhysicalDeviceFeatures2(
                case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES_KHR: {
                        VkPhysicalDeviceShaderAtomicInt64FeaturesKHR *features =
                                (VkPhysicalDeviceShaderAtomicInt64FeaturesKHR *)ext;
-                       features->shaderBufferInt64Atomics = HAVE_LLVM >= 0x0900;
-                       features->shaderSharedInt64Atomics = HAVE_LLVM >= 0x0900;
+                       features->shaderBufferInt64Atomics = LLVM_VERSION_MAJOR >= 9;
+                       features->shaderSharedInt64Atomics = LLVM_VERSION_MAJOR >= 9;
                        break;
                }
                case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES_EXT: {
index 34d63ed90c334848523e7363f32ab85f6b83835a..4bb4c4dfc23feb4087f240796f9f0d0775eef966 100644 (file)
@@ -85,7 +85,7 @@ EXTENSIONS = [
     Extension('VK_KHR_relaxed_block_layout',              1, True),
     Extension('VK_KHR_sampler_mirror_clamp_to_edge',      1, True),
     Extension('VK_KHR_sampler_ycbcr_conversion',          1, True),
-    Extension('VK_KHR_shader_atomic_int64',               1, 'HAVE_LLVM >= 0x0900'),
+    Extension('VK_KHR_shader_atomic_int64',               1, 'LLVM_VERSION_MAJOR >= 9'),
     Extension('VK_KHR_shader_draw_parameters',            1, True),
     Extension('VK_KHR_shader_float16_int8',               1, True),
     Extension('VK_KHR_storage_buffer_storage_class',      1, True),
index 7e861736f23de77a7284d09629fc20e8f0a16c4c..c85bbe4cee88bfe3d0f80243186a481ae72f2e18 100644 (file)
@@ -33,6 +33,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <llvm/Config/llvm-config.h>
 #include <amdgpu_drm.h>
 #include <assert.h>
 #include "radv_amdgpu_cs.h"
@@ -46,7 +47,7 @@ do_winsys_init(struct radv_amdgpu_winsys *ws, int fd)
                return false;
 
        /* LLVM 9.0 is required for GFX10. */
-       if (ws->info.chip_class == GFX10 && HAVE_LLVM < 0x0900) {
+       if (ws->info.chip_class == GFX10 && LLVM_VERSION_MAJOR < 9) {
                fprintf(stderr, "radv: Navi family support requires LLVM 9 or higher\n");
                return false;
        }
index 09dfcebbbb745a920ef62f4d81a07d400a7856fe..118301fbf4b98b682e9afca53a911220210d4455 100644 (file)
@@ -33,6 +33,7 @@
 #include "util/u_video.h"
 #include "compiler/nir/nir.h"
 
+#include <llvm/Config/llvm-config.h>
 #include <sys/utsname.h>
 
 static const char *si_get_vendor(struct pipe_screen *pscreen)
@@ -207,7 +208,7 @@ static int si_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
        case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY:
        case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY:
        case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY:
-               return HAVE_LLVM < 0x0900 && !sscreen->info.has_unaligned_shader_loads;
+               return LLVM_VERSION_MAJOR < 9 && !sscreen->info.has_unaligned_shader_loads;
 
        case PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE:
                return sscreen->info.has_sparse_vm_mappings ?
@@ -345,7 +346,7 @@ static int si_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
        case PIPE_CAP_PCI_FUNCTION:
                return sscreen->info.pci_func;
        case PIPE_CAP_TGSI_ATOMINC_WRAP:
-               return HAVE_LLVM >= 0x1000;
+               return LLVM_VERSION_MAJOR >= 10;
 
        default:
                return u_pipe_screen_get_param_defaults(pscreen, param);
index e477b7ba002d1e4457d85b80470a1df60761bb3c..4edd3e4a4eb207e6a14c6bacaefbe8d4db93d99c 100644 (file)
@@ -45,6 +45,8 @@
 #include "gallium/winsys/amdgpu/drm/amdgpu_public.h"
 #include <xf86drm.h>
 
+#include <llvm/Config/llvm-config.h>
+
 static const struct debug_named_value debug_options[] = {
        /* Shader logging options: */
        { "vs", DBG(VS), "Print vertex shaders" },
@@ -924,7 +926,7 @@ radeonsi_screen_create_impl(struct radeon_winsys *ws,
        sscreen->ws = ws;
        ws->query_info(ws, &sscreen->info);
 
-       if (sscreen->info.chip_class == GFX10 && HAVE_LLVM < 0x0900) {
+       if (sscreen->info.chip_class == GFX10 && LLVM_VERSION_MAJOR < 9) {
                fprintf(stderr, "radeonsi: Navi family support requires LLVM 9 or higher\n");
                FREE(sscreen);
                return NULL;
index 7636d44bee43584938a0654aff8994493addd026..86b87566b42de54ab98c17edc21083601f6e9f5f 100644 (file)
@@ -22,6 +22,8 @@
  * USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
+#include <llvm/Config/llvm-config.h>
+
 #include "util/u_memory.h"
 #include "util/u_string.h"
 #include "tgsi/tgsi_build.h"
@@ -5028,7 +5030,7 @@ static void create_function(struct si_shader_context *ctx)
        shader->info.num_input_vgprs -= num_prolog_vgprs;
 
        if (shader->key.as_ls || ctx->type == PIPE_SHADER_TESS_CTRL) {
-               if (USE_LDS_SYMBOLS && HAVE_LLVM >= 0x0900) {
+               if (USE_LDS_SYMBOLS && LLVM_VERSION_MAJOR >= 9) {
                        /* The LSHS size is not known until draw time, so we append it
                         * at the end of whatever LDS use there may be in the rest of
                         * the shader (currently none, unless LLVM decides to do its
@@ -5085,7 +5087,7 @@ static void preload_ring_buffers(struct si_shader_context *ctx)
                        ctx->esgs_ring =
                                ac_build_load_to_sgpr(&ctx->ac, buf_ptr, offset);
                } else {
-                       if (USE_LDS_SYMBOLS && HAVE_LLVM >= 0x0900) {
+                       if (USE_LDS_SYMBOLS && LLVM_VERSION_MAJOR >= 9) {
                                /* Declare the ESGS ring as an explicit LDS symbol. */
                                declare_esgs_ring(ctx);
                        } else {
index 76156817685c0fa29d0f83ee252fc7a37bbbd38b..f1d9d64a2406c92db872ff4beb634de37d4a0950 100644 (file)
@@ -22,6 +22,8 @@
  * USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
+#include <llvm/Config/llvm-config.h>
+
 #include "si_shader_internal.h"
 #include "si_pipe.h"
 #include "sid.h"
@@ -742,7 +744,7 @@ static void atomic_emit_memory(struct si_shader_context *ctx,
        LLVMBuilderRef builder = ctx->ac.builder;
        const struct tgsi_full_instruction * inst = emit_data->inst;
        LLVMValueRef ptr, result, arg;
-       const char *sync_scope = HAVE_LLVM >= 0x0900 ? "workgroup-one-as" : "workgroup";
+       const char *sync_scope = LLVM_VERSION_MAJOR >= 9 ? "workgroup-one-as" : "workgroup";
 
        ptr = get_memory_ptr(ctx, inst, ctx->i32, 1);