ac: use 1D GEPs for descriptors and constants
authorMarek Olšák <marek.olsak@amd.com>
Fri, 10 May 2019 00:58:21 +0000 (20:58 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 14 May 2019 19:15:11 +0000 (15:15 -0400)
just a cleanup

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Tested-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/common/ac_llvm_build.c
src/amd/common/ac_nir_to_llvm.c
src/amd/vulkan/radv_nir_to_llvm.c

index f1ed68d5df36266f17ad516499834123e35cd68a..58dcd2e863d2381e74696fd276aaa1cb97a02bd5 100644 (file)
@@ -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 *
index 151e0d0f961a0ca9ff21f64702a9ac06f14550b8..682645e9b1f7e928c95df7fc01ea951a0afbec97 100644 (file)
@@ -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;
index 5a34a85d7b4fc9342d95a85ad6a33b060b492e2f..e8be058d3f75d9ee5307d40e4a4221a8022bdce2 100644 (file)
@@ -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), "");