From: Marek Olšák Date: Fri, 10 May 2019 00:58:21 +0000 (-0400) Subject: ac: use 1D GEPs for descriptors and constants X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6b0b8f132aa8f13be36835c23232374bf9fd82ab;p=mesa.git ac: use 1D GEPs for descriptors and constants just a cleanup Reviewed-by: Bas Nieuwenhuizen Tested-by: Bas Nieuwenhuizen --- diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c index f1ed68d5df3..58dcd2e863d 100644 --- a/src/amd/common/ac_llvm_build.c +++ b/src/amd/common/ac_llvm_build.c @@ -1016,7 +1016,7 @@ LLVMValueRef ac_build_pointer_add(struct ac_llvm_context *ctx, LLVMValueRef ptr, LLVMValueRef index) { return LLVMBuildPointerCast(ctx->builder, - ac_build_gep0(ctx, ptr, index), + LLVMBuildGEP(ctx->builder, ptr, &index, 1, ""), LLVMTypeOf(ptr), ""); } @@ -1063,13 +1063,12 @@ ac_build_load_custom(struct ac_llvm_context *ctx, LLVMValueRef base_ptr, bool no_unsigned_wraparound) { LLVMValueRef pointer, result; - LLVMValueRef indices[2] = {ctx->i32_0, index}; if (no_unsigned_wraparound && LLVMGetPointerAddressSpace(LLVMTypeOf(base_ptr)) == AC_ADDR_SPACE_CONST_32BIT) - pointer = LLVMBuildInBoundsGEP(ctx->builder, base_ptr, indices, 2, ""); + pointer = LLVMBuildInBoundsGEP(ctx->builder, base_ptr, &index, 1, ""); else - pointer = LLVMBuildGEP(ctx->builder, base_ptr, indices, 2, ""); + pointer = LLVMBuildGEP(ctx->builder, base_ptr, &index, 1, ""); if (uniform) LLVMSetMetadata(pointer, ctx->uniform_md_kind, ctx->empty_md); @@ -3314,7 +3313,7 @@ void ac_declare_lds_as_pointer(struct ac_llvm_context *ctx) LLVMValueRef ac_lds_load(struct ac_llvm_context *ctx, LLVMValueRef dw_addr) { - return ac_build_load(ctx, ctx->lds, dw_addr); + return LLVMBuildLoad(ctx->builder, ac_build_gep0(ctx, ctx->lds, dw_addr), ""); } void ac_lds_store(struct ac_llvm_context *ctx, @@ -3395,14 +3394,12 @@ LLVMValueRef ac_find_lsb(struct ac_llvm_context *ctx, LLVMTypeRef ac_array_in_const_addr_space(LLVMTypeRef elem_type) { - return LLVMPointerType(LLVMArrayType(elem_type, 0), - AC_ADDR_SPACE_CONST); + return LLVMPointerType(elem_type, AC_ADDR_SPACE_CONST); } LLVMTypeRef ac_array_in_const32_addr_space(LLVMTypeRef elem_type) { - return LLVMPointerType(LLVMArrayType(elem_type, 0), - AC_ADDR_SPACE_CONST_32BIT); + return LLVMPointerType(elem_type, AC_ADDR_SPACE_CONST_32BIT); } static struct ac_llvm_flow * diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index 151e0d0f961..682645e9b1f 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -1439,7 +1439,7 @@ static LLVMValueRef visit_load_push_constant(struct ac_nir_context *ctx, } } - ptr = ac_build_gep0(&ctx->ac, ctx->abi->push_constants, addr); + ptr = LLVMBuildGEP(ctx->ac.builder, ctx->abi->push_constants, &addr, 1, ""); if (instr->dest.ssa.bit_size == 8) { unsigned load_dwords = instr->dest.ssa.num_components > 1 ? 2 : 1; diff --git a/src/amd/vulkan/radv_nir_to_llvm.c b/src/amd/vulkan/radv_nir_to_llvm.c index 5a34a85d7b4..e8be058d3f7 100644 --- a/src/amd/vulkan/radv_nir_to_llvm.c +++ b/src/amd/vulkan/radv_nir_to_llvm.c @@ -1311,7 +1311,7 @@ radv_load_resource(struct ac_shader_abi *abi, LLVMValueRef index, offset = ac_build_imad(&ctx->ac, index, stride, offset); } - desc_ptr = ac_build_gep0(&ctx->ac, desc_ptr, offset); + desc_ptr = LLVMBuildGEP(ctx->ac.builder, desc_ptr, &offset, 1, ""); desc_ptr = ac_cast_ptr(&ctx->ac, desc_ptr, ctx->ac.v4i32); LLVMSetMetadata(desc_ptr, ctx->ac.uniform_md_kind, ctx->ac.empty_md); @@ -1755,7 +1755,8 @@ static LLVMValueRef load_sample_position(struct ac_shader_abi *abi, struct radv_shader_context *ctx = radv_shader_context_from_abi(abi); LLVMValueRef result; - LLVMValueRef ptr = ac_build_gep0(&ctx->ac, ctx->ring_offsets, LLVMConstInt(ctx->ac.i32, RING_PS_SAMPLE_POSITIONS, false)); + LLVMValueRef index = LLVMConstInt(ctx->ac.i32, RING_PS_SAMPLE_POSITIONS, false); + LLVMValueRef ptr = LLVMBuildGEP(ctx->ac.builder, ctx->ring_offsets, &index, 1, ""); ptr = LLVMBuildBitCast(ctx->ac.builder, ptr, ac_array_in_const_addr_space(ctx->ac.v2f32), ""); @@ -2025,7 +2026,8 @@ static LLVMValueRef radv_get_sampler_desc(struct ac_shader_abi *abi, adjusted_index = LLVMBuildMul(builder, adjusted_index, LLVMConstInt(ctx->ac.i32, stride / type_size, 0), ""); - list = ac_build_gep0(&ctx->ac, list, LLVMConstInt(ctx->ac.i32, offset, 0)); + LLVMValueRef val_offset = LLVMConstInt(ctx->ac.i32, offset, 0); + list = LLVMBuildGEP(builder, list, &val_offset, 1, ""); list = LLVMBuildPointerCast(builder, list, ac_array_in_const32_addr_space(type), "");