From e2a7436dd10df70ba14d18ab7cf8ad538f80e653 Mon Sep 17 00:00:00 2001 From: Jan Zielinski Date: Sat, 25 Apr 2020 19:27:07 +0200 Subject: [PATCH] gallium/gallivm: fix compilation issues with llvm 11 Top of the trunk LLVM removes old vector type and introduces two new ones - one for fixed-width and one for scalable vectors. This commit fixes compilation issues by switching from LLVMVectorTypeKind to LLVMFixedVectorTypeKind for new LLVM. Reviewed-by: Jose Fonseca Reviewed-by: Roland Scheidegger Part-of: --- src/gallium/auxiliary/gallivm/lp_bld_conv.c | 8 ++++---- .../auxiliary/gallivm/lp_bld_format_float.c | 6 +++--- src/gallium/auxiliary/gallivm/lp_bld_intr.c | 2 +- src/gallium/auxiliary/gallivm/lp_bld_pack.c | 2 +- src/gallium/auxiliary/gallivm/lp_bld_printf.c | 2 +- .../auxiliary/gallivm/lp_bld_swizzle.c | 2 +- src/gallium/auxiliary/gallivm/lp_bld_type.c | 20 +++++++++++-------- src/gallium/auxiliary/gallivm/lp_bld_type.h | 3 +++ 8 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_conv.c b/src/gallium/auxiliary/gallivm/lp_bld_conv.c index 579801ca93a..1321545808a 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_conv.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_conv.c @@ -34,7 +34,7 @@ * The other side of this is that we need to be able convert between several * types accurately and efficiently. * - * Conversion between types of different bit width is quite complex since a + * Conversion between types of different bit width is quite complex since a * * To remember there are a few invariants in type conversions: * @@ -93,7 +93,7 @@ lp_build_half_to_float(struct gallivm_state *gallivm, { LLVMBuilderRef builder = gallivm->builder; LLVMTypeRef src_type = LLVMTypeOf(src); - unsigned src_length = LLVMGetTypeKind(src_type) == LLVMVectorTypeKind ? + unsigned src_length = LLVMGetTypeKind(src_type) == LLVMFixedVectorTypeKind ? LLVMGetVectorSize(src_type) : 1; struct lp_type f32_type = lp_type_float_vec(32, 32 * src_length); @@ -138,7 +138,7 @@ lp_build_float_to_half(struct gallivm_state *gallivm, { LLVMBuilderRef builder = gallivm->builder; LLVMTypeRef f32_vec_type = LLVMTypeOf(src); - unsigned length = LLVMGetTypeKind(f32_vec_type) == LLVMVectorTypeKind + unsigned length = LLVMGetTypeKind(f32_vec_type) == LLVMFixedVectorTypeKind ? LLVMGetVectorSize(f32_vec_type) : 1; struct lp_type i32_type = lp_type_int_vec(32, 32 * length); struct lp_type i16_type = lp_type_int_vec(16, 16 * length); @@ -673,7 +673,7 @@ lp_build_conv(struct gallivm_state *gallivm, dst[0] = lp_build_extract_range(gallivm, dst[0], 0, dst_type.length); } - return; + return; } /* Special case 2x8x32 --> 1x16x8, 1x8x32 ->1x8x8 diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_float.c b/src/gallium/auxiliary/gallivm/lp_bld_format_float.c index 1924650ca40..1d6647da556 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_format_float.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_format_float.c @@ -240,7 +240,7 @@ lp_build_float_to_r11g11b10(struct gallivm_state *gallivm, LLVMValueRef dst, rcomp, bcomp, gcomp; struct lp_build_context i32_bld; LLVMTypeRef src_type = LLVMTypeOf(*src); - unsigned src_length = LLVMGetTypeKind(src_type) == LLVMVectorTypeKind ? + unsigned src_length = LLVMGetTypeKind(src_type) == LLVMFixedVectorTypeKind ? LLVMGetVectorSize(src_type) : 1; struct lp_type i32_type = lp_type_int_vec(32, 32 * src_length); @@ -406,7 +406,7 @@ lp_build_r11g11b10_to_float(struct gallivm_state *gallivm, LLVMValueRef *dst) { LLVMTypeRef src_type = LLVMTypeOf(src); - unsigned src_length = LLVMGetTypeKind(src_type) == LLVMVectorTypeKind ? + unsigned src_length = LLVMGetTypeKind(src_type) == LLVMFixedVectorTypeKind ? LLVMGetVectorSize(src_type) : 1; struct lp_type f32_type = lp_type_float_vec(32, 32 * src_length); @@ -464,7 +464,7 @@ lp_build_rgb9e5_to_float(struct gallivm_state *gallivm, LLVMBuilderRef builder = gallivm->builder; LLVMTypeRef src_type = LLVMTypeOf(src); LLVMValueRef shift, scale, bias, exp; - unsigned src_length = LLVMGetTypeKind(src_type) == LLVMVectorTypeKind ? + unsigned src_length = LLVMGetTypeKind(src_type) == LLVMFixedVectorTypeKind ? LLVMGetVectorSize(src_type) : 1; struct lp_type i32_type = lp_type_int_vec(32, 32 * src_length); struct lp_type u32_type = lp_type_uint_vec(32, 32 * src_length); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_intr.c b/src/gallium/auxiliary/gallivm/lp_bld_intr.c index 5e9cc70ef3d..4a3aaa1d511 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_intr.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_intr.c @@ -67,7 +67,7 @@ lp_format_intrinsic(char *name, char c; LLVMTypeKind kind = LLVMGetTypeKind(type); - if (kind == LLVMVectorTypeKind) { + if (kind == LLVMFixedVectorTypeKind) { length = LLVMGetVectorSize(type); type = LLVMGetElementType(type); kind = LLVMGetTypeKind(type); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_pack.c b/src/gallium/auxiliary/gallivm/lp_bld_pack.c index e1f652a9342..61e9651fd69 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_pack.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_pack.c @@ -1035,7 +1035,7 @@ lp_build_pad_vector(struct gallivm_state *gallivm, type = LLVMTypeOf(src); - if (LLVMGetTypeKind(type) != LLVMVectorTypeKind) { + if (LLVMGetTypeKind(type) != LLVMFixedVectorTypeKind) { /* Can't use ShuffleVector on non-vector type */ undef = LLVMGetUndef(LLVMVectorType(type, dst_length)); return LLVMBuildInsertElement(gallivm->builder, undef, src, lp_build_const_int32(gallivm, 0), ""); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_printf.c b/src/gallium/auxiliary/gallivm/lp_bld_printf.c index a4233a24e33..6884407a83a 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_printf.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_printf.c @@ -92,7 +92,7 @@ lp_build_print_value(struct gallivm_state *gallivm, type_ref = LLVMTypeOf(value); type_kind = LLVMGetTypeKind(type_ref); - if (type_kind == LLVMVectorTypeKind) { + if (type_kind == LLVMFixedVectorTypeKind) { length = LLVMGetVectorSize(type_ref); type_ref = LLVMGetElementType(type_ref); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c b/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c index b648e681994..922ef0b7c9e 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c @@ -50,7 +50,7 @@ lp_build_broadcast(struct gallivm_state *gallivm, { LLVMValueRef res; - if (LLVMGetTypeKind(vec_type) != LLVMVectorTypeKind) { + if (LLVMGetTypeKind(vec_type) != LLVMFixedVectorTypeKind) { /* scalar */ assert(vec_type == LLVMTypeOf(scalar)); res = scalar; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_type.c b/src/gallium/auxiliary/gallivm/lp_bld_type.c index 5a801999080..0b108702998 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_type.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_type.c @@ -76,7 +76,7 @@ lp_build_vec_type(struct gallivm_state *gallivm,struct lp_type type) * type and check for identity. */ boolean -lp_check_elem_type(struct lp_type type, LLVMTypeRef elem_type) +lp_check_elem_type(struct lp_type type, LLVMTypeRef elem_type) { LLVMTypeKind elem_kind; @@ -113,12 +113,12 @@ lp_check_elem_type(struct lp_type type, LLVMTypeRef elem_type) return FALSE; } - return TRUE; + return TRUE; } boolean -lp_check_vec_type(struct lp_type type, LLVMTypeRef vec_type) +lp_check_vec_type(struct lp_type type, LLVMTypeRef vec_type) { LLVMTypeRef elem_type; @@ -129,7 +129,7 @@ lp_check_vec_type(struct lp_type type, LLVMTypeRef vec_type) if (type.length == 1) return lp_check_elem_type(type, vec_type); - if(LLVMGetTypeKind(vec_type) != LLVMVectorTypeKind) + if(LLVMGetTypeKind(vec_type) != LLVMFixedVectorTypeKind) return FALSE; if(LLVMGetVectorSize(vec_type) != type.length) @@ -142,7 +142,7 @@ lp_check_vec_type(struct lp_type type, LLVMTypeRef vec_type) boolean -lp_check_value(struct lp_type type, LLVMValueRef val) +lp_check_value(struct lp_type type, LLVMValueRef val) { LLVMTypeRef vec_type; @@ -259,7 +259,7 @@ lp_sizeof_llvm_type(LLVMTypeRef t) return 8 * sizeof(float); case LLVMDoubleTypeKind: return 8 * sizeof(double); - case LLVMVectorTypeKind: + case LLVMFixedVectorTypeKind: { LLVMTypeRef elem = LLVMGetElementType(t); unsigned len = LLVMGetVectorSize(t); @@ -311,8 +311,12 @@ lp_typekind_name(LLVMTypeKind t) return "LLVMArrayTypeKind"; case LLVMPointerTypeKind: return "LLVMPointerTypeKind"; - case LLVMVectorTypeKind: + case LLVMFixedVectorTypeKind: + #if LLVM_VERSION_MAJOR >= 11 + return "LLVMFixedVectorTypeKind"; + #else return "LLVMVectorTypeKind"; + #endif case LLVMMetadataTypeKind: return "LLVMMetadataTypeKind"; default: @@ -329,7 +333,7 @@ lp_dump_llvmtype(LLVMTypeRef t) { LLVMTypeKind k = LLVMGetTypeKind(t); - if (k == LLVMVectorTypeKind) { + if (k == LLVMFixedVectorTypeKind) { LLVMTypeRef te = LLVMGetElementType(t); LLVMTypeKind ke = LLVMGetTypeKind(te); unsigned len = LLVMGetVectorSize(t); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_type.h b/src/gallium/auxiliary/gallivm/lp_bld_type.h index 9c7dc252166..f51ce427071 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_type.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_type.h @@ -36,6 +36,9 @@ #ifndef LP_BLD_TYPE_H #define LP_BLD_TYPE_H +#if LLVM_VERSION_MAJOR < 11 +#define LLVMFixedVectorTypeKind LLVMVectorTypeKind +#endif #include "util/format/u_format.h" #include "pipe/p_compiler.h" -- 2.30.2