gallivm: LLVM-15 opaque pointers: disable LLVMGetElementType(ptr_type)
authorMihai Preda <mhpreda@gmail.com>
Fri, 19 Aug 2022 08:56:35 +0000 (11:56 +0300)
committerMarge Bot <emma+marge@anholt.net>
Sat, 3 Sep 2022 03:31:34 +0000 (03:31 +0000)
with opaque pointers, we can't query the element type of a pointer type

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18334>

src/gallium/auxiliary/gallivm/lp_bld_ir_common.c
src/gallium/auxiliary/gallivm/lp_bld_struct.c
src/gallium/auxiliary/gallivm/lp_bld_swizzle.c

index d127ea0..042cd5c 100644 (file)
@@ -209,8 +209,9 @@ void lp_exec_mask_store(struct lp_exec_mask *mask,
 
    assert(lp_check_value(bld_store->type, val));
    assert(LLVMGetTypeKind(LLVMTypeOf(dst_ptr)) == LLVMPointerTypeKind);
-   assert(LLVMGetElementType(LLVMTypeOf(dst_ptr)) == LLVMTypeOf(val) ||
-          LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(dst_ptr))) == LLVMArrayTypeKind);
+   assert(LLVM_VERSION_MAJOR >= 15
+          || (LLVMGetElementType(LLVMTypeOf(dst_ptr)) == LLVMTypeOf(val)
+              || LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(dst_ptr))) == LLVMArrayTypeKind));
 
    if (exec_mask) {
       LLVMValueRef res, dst;
index be579c4..9e3e24c 100644 (file)
@@ -120,7 +120,7 @@ lp_build_array_get_ptr(struct gallivm_state *gallivm,
    LLVMValueRef indices[2];
    LLVMValueRef element_ptr;
    assert(LLVMGetTypeKind(LLVMTypeOf(ptr)) == LLVMPointerTypeKind);
-   assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMArrayTypeKind);
+   assert(LLVM_VERSION_MAJOR >= 15 || LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMArrayTypeKind);
    indices[0] = lp_build_const_int32(gallivm, 0);
    indices[1] = index;
    element_ptr = LLVMBuildGEP(gallivm->builder, ptr, indices, ARRAY_SIZE(indices), "");
@@ -140,7 +140,7 @@ lp_build_array_get(struct gallivm_state *gallivm,
    LLVMValueRef element_ptr;
    LLVMValueRef res;
    assert(LLVMGetTypeKind(LLVMTypeOf(ptr)) == LLVMPointerTypeKind);
-   assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMArrayTypeKind);
+   assert(LLVM_VERSION_MAJOR >= 15 || LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMArrayTypeKind);
    element_ptr = lp_build_array_get_ptr(gallivm, ptr, index);
    res = LLVMBuildLoad(gallivm->builder, element_ptr, "");
 #ifdef DEBUG
@@ -158,7 +158,7 @@ lp_build_array_set(struct gallivm_state *gallivm,
 {
    LLVMValueRef element_ptr;
    assert(LLVMGetTypeKind(LLVMTypeOf(ptr)) == LLVMPointerTypeKind);
-   assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMArrayTypeKind);
+   assert(LLVM_VERSION_MAJOR >= 15 || LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMArrayTypeKind);
    element_ptr = lp_build_array_get_ptr(gallivm, ptr, index);
    LLVMBuildStore(gallivm->builder, value, element_ptr);
 }
index b23c4cb..904eaa0 100644 (file)
@@ -63,7 +63,7 @@ lp_build_broadcast(struct gallivm_state *gallivm,
       LLVMTypeRef i32_type = LLVMInt32TypeInContext(gallivm->context);
       LLVMTypeRef i32_vec_type = LLVMVectorType(i32_type, length);
 
-      assert(LLVMGetElementType(vec_type) == LLVMTypeOf(scalar));
+      assert(LLVM_VERSION_MAJOR >= 15 || LLVMGetElementType(vec_type) == LLVMTypeOf(scalar));
 
       res = LLVMBuildInsertElement(builder, undef, scalar, LLVMConstNull(i32_type), "");
       res = LLVMBuildShuffleVector(builder, res, undef, LLVMConstNull(i32_vec_type), "");