From b549394992553330f191b589b32a30a1f6fb792f Mon Sep 17 00:00:00 2001 From: Mihai Preda Date: Thu, 30 Jun 2022 09:14:02 +0300 Subject: [PATCH] gallivm: fix a few llvm non-opaque pointers MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit As LLVM 15 transitions to opaque pointers, we need to update the deprecated methods dealing with non-opaque pointers. Reviewed-by: Brian Paul Acked-by: Marek Olšák Part-of: --- src/gallium/auxiliary/gallivm/lp_bld_coro.c | 2 +- src/gallium/auxiliary/gallivm/lp_bld_format.c | 10 ++++++---- src/gallium/auxiliary/gallivm/lp_bld_format.h | 2 ++ src/gallium/auxiliary/gallivm/lp_bld_format_aos_array.c | 3 ++- src/gallium/auxiliary/gallivm/lp_bld_format_s3tc.c | 12 +++++++----- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_coro.c b/src/gallium/auxiliary/gallivm/lp_bld_coro.c index a423f60..0214dcf 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_coro.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_coro.c @@ -206,7 +206,7 @@ LLVMValueRef lp_build_coro_alloc_mem_array(struct gallivm_state *gallivm, LLVMValueRef coro_num_hdls) { LLVMTypeRef mem_ptr_type = LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0); - LLVMValueRef alloced_ptr = LLVMBuildLoad(gallivm->builder, coro_hdl_ptr, ""); + LLVMValueRef alloced_ptr = LLVMBuildLoad2(gallivm->builder, mem_ptr_type, coro_hdl_ptr, ""); LLVMValueRef not_alloced = LLVMBuildICmp(gallivm->builder, LLVMIntEQ, alloced_ptr, LLVMConstNull(mem_ptr_type), ""); LLVMValueRef coro_size = lp_build_coro_size(gallivm); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format.c b/src/gallium/auxiliary/gallivm/lp_bld_format.c index a82fd8f..d26485e 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_format.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_format.c @@ -28,7 +28,10 @@ #include "lp_bld_format.h" - +LLVMTypeRef lp_build_format_cache_member_data_type(struct gallivm_state *gallivm) +{ + return LLVMArrayType(LLVMInt32TypeInContext(gallivm->context), LP_BUILD_FORMAT_CACHE_SIZE * 16); +} LLVMTypeRef lp_build_format_cache_type(struct gallivm_state *gallivm) @@ -36,9 +39,8 @@ lp_build_format_cache_type(struct gallivm_state *gallivm) LLVMTypeRef elem_types[LP_BUILD_FORMAT_CACHE_MEMBER_COUNT]; LLVMTypeRef s; - elem_types[LP_BUILD_FORMAT_CACHE_MEMBER_DATA] = - LLVMArrayType(LLVMInt32TypeInContext(gallivm->context), - LP_BUILD_FORMAT_CACHE_SIZE * 16); + elem_types[LP_BUILD_FORMAT_CACHE_MEMBER_DATA] = lp_build_format_cache_member_data_type(gallivm); + elem_types[LP_BUILD_FORMAT_CACHE_MEMBER_TAGS] = LLVMArrayType(LLVMInt64TypeInContext(gallivm->context), LP_BUILD_FORMAT_CACHE_SIZE); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format.h b/src/gallium/auxiliary/gallivm/lp_bld_format.h index 425b2f5..0ed1dca 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_format.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_format.h @@ -82,6 +82,8 @@ enum { LLVMTypeRef lp_build_format_cache_type(struct gallivm_state *gallivm); +LLVMTypeRef +lp_build_format_cache_member_data_type(struct gallivm_state *gallivm); /* * AoS diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_aos_array.c b/src/gallium/auxiliary/gallivm/lp_bld_format_aos_array.c index bc0bd4f..55b5bec 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_format_aos_array.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_format_aos_array.c @@ -78,7 +78,8 @@ lp_build_fetch_rgba_aos_array(struct gallivm_state *gallivm, * (If all callers can guarantee element type alignment, we should * relax alignment restrictions elsewhere.) */ - ptr = LLVMBuildGEP(builder, base_ptr, &offset, 1, ""); + LLVMTypeRef byte_type = LLVMInt8TypeInContext(gallivm->context); + ptr = LLVMBuildGEP2(builder, byte_type, base_ptr, &offset, 1, ""); ptr = LLVMBuildPointerCast(builder, ptr, LLVMPointerType(src_vec_type, 0), ""); res = LLVMBuildLoad2(builder, src_vec_type, ptr, ""); LLVMSetAlignment(res, src_type.width / 8); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_s3tc.c b/src/gallium/auxiliary/gallivm/lp_bld_format_s3tc.c index 8f972b8..5d91c77 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_format_s3tc.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_format_s3tc.c @@ -1134,14 +1134,15 @@ s3tc_store_cached_block(struct gallivm_state *gallivm, indices[0] = lp_build_const_int32(gallivm, 0); indices[1] = lp_build_const_int32(gallivm, LP_BUILD_FORMAT_CACHE_MEMBER_TAGS); indices[2] = hash_index; - ptr = LLVMBuildGEP(builder, cache, indices, ARRAY_SIZE(indices), ""); + LLVMTypeRef cache_type = lp_build_format_cache_type(gallivm); + ptr = LLVMBuildGEP2(builder, cache_type, cache, indices, ARRAY_SIZE(indices), ""); LLVMBuildStore(builder, tag_value, ptr); indices[1] = lp_build_const_int32(gallivm, LP_BUILD_FORMAT_CACHE_MEMBER_DATA); hash_index = LLVMBuildMul(builder, hash_index, lp_build_const_int32(gallivm, 16), ""); for (count = 0; count < 4; count++) { indices[2] = hash_index; - ptr = LLVMBuildGEP(builder, cache, indices, ARRAY_SIZE(indices), ""); + ptr = LLVMBuildGEP2(builder, cache_type, cache, indices, ARRAY_SIZE(indices), ""); ptr = LLVMBuildBitCast(builder, ptr, type_ptr4x32, ""); LLVMBuildStore(builder, col[count], ptr); hash_index = LLVMBuildAdd(builder, hash_index, lp_build_const_int32(gallivm, 4), ""); @@ -1150,7 +1151,7 @@ s3tc_store_cached_block(struct gallivm_state *gallivm, static LLVMValueRef s3tc_lookup_cached_pixel(struct gallivm_state *gallivm, - LLVMValueRef ptr, + LLVMValueRef cache, LLVMValueRef index) { LLVMBuilderRef builder = gallivm->builder; @@ -1159,8 +1160,9 @@ s3tc_lookup_cached_pixel(struct gallivm_state *gallivm, indices[0] = lp_build_const_int32(gallivm, 0); indices[1] = lp_build_const_int32(gallivm, LP_BUILD_FORMAT_CACHE_MEMBER_DATA); indices[2] = index; - member_ptr = LLVMBuildGEP(builder, ptr, indices, ARRAY_SIZE(indices), ""); - return LLVMBuildLoad(builder, member_ptr, "cache_data"); + member_ptr = LLVMBuildGEP2(builder, lp_build_format_cache_type(gallivm), cache, indices, ARRAY_SIZE(indices), ""); + + return LLVMBuildLoad2(builder, lp_build_format_cache_member_data_type(gallivm), member_ptr, "cache_data"); } static LLVMValueRef -- 2.7.4