diff options
author | Marek Olšák <[email protected]> | 2017-12-31 23:35:59 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2018-01-27 02:09:09 +0100 |
commit | b633999a4e765230701c98957364814c7f4f042b (patch) | |
tree | 57395d0aa00823fc58cb4646dd4e630a4b38ad45 /src/amd/common | |
parent | e17eb8800f3c4255f55b33af53336bd29dbcfa77 (diff) |
ac: rename and move si_const_array into common code
Reviewed-by: Samuel Pitoiset <[email protected]>
Diffstat (limited to 'src/amd/common')
-rw-r--r-- | src/amd/common/ac_llvm_build.c | 6 | ||||
-rw-r--r-- | src/amd/common/ac_llvm_build.h | 3 | ||||
-rw-r--r-- | src/amd/common/ac_nir_to_llvm.c | 20 |
3 files changed, 16 insertions, 13 deletions
diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c index fa2f7f5097e..5e08508fedb 100644 --- a/src/amd/common/ac_llvm_build.c +++ b/src/amd/common/ac_llvm_build.c @@ -1876,3 +1876,9 @@ LLVMValueRef ac_find_lsb(struct ac_llvm_context *ctx, ctx->i32_0, ""), LLVMConstInt(ctx->i32, -1, 0), lsb, ""); } + +LLVMTypeRef ac_array_in_const_addr_space(LLVMTypeRef elem_type) +{ + return LLVMPointerType(LLVMArrayType(elem_type, 0), + AC_CONST_ADDR_SPACE); +} diff --git a/src/amd/common/ac_llvm_build.h b/src/amd/common/ac_llvm_build.h index 2ca7a97e76e..78437d603e3 100644 --- a/src/amd/common/ac_llvm_build.h +++ b/src/amd/common/ac_llvm_build.h @@ -328,6 +328,9 @@ void ac_lds_store(struct ac_llvm_context *ctx, LLVMValueRef ac_find_lsb(struct ac_llvm_context *ctx, LLVMTypeRef dst_type, LLVMValueRef src0); + +LLVMTypeRef ac_array_in_const_addr_space(LLVMTypeRef elem_type); + #ifdef __cplusplus } #endif diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index 92188cfb8e3..dbbac905353 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -355,12 +355,6 @@ create_llvm_function(LLVMContextRef ctx, LLVMModuleRef module, return main_function; } -static LLVMTypeRef const_array(LLVMTypeRef elem_type, int num_elements) -{ - return LLVMPointerType(LLVMArrayType(elem_type, num_elements), - AC_CONST_ADDR_SPACE); -} - static int get_elem_bits(struct ac_llvm_context *ctx, LLVMTypeRef type) { if (LLVMGetTypeKind(type) == LLVMVectorTypeKind) @@ -647,7 +641,7 @@ declare_global_input_sgprs(struct nir_to_llvm_context *ctx, struct arg_info *args, LLVMValueRef *desc_sets) { - LLVMTypeRef type = const_array(ctx->ac.i8, 1024 * 1024); + LLVMTypeRef type = ac_array_in_const_addr_space(ctx->ac.i8); unsigned num_sets = ctx->options->layout ? ctx->options->layout->num_sets : 0; unsigned stage_mask = 1 << stage; @@ -664,7 +658,7 @@ declare_global_input_sgprs(struct nir_to_llvm_context *ctx, } } } else { - add_array_arg(args, const_array(type, 32), desc_sets); + add_array_arg(args, ac_array_in_const_addr_space(type), desc_sets); } if (ctx->shader_info->info.loads_push_constants) { @@ -684,7 +678,7 @@ declare_vs_specific_input_sgprs(struct nir_to_llvm_context *ctx, (stage == MESA_SHADER_VERTEX || (has_previous_stage && previous_stage == MESA_SHADER_VERTEX))) { if (ctx->shader_info->info.vs.has_vertex_buffers) { - add_arg(args, ARG_SGPR, const_array(ctx->ac.v4i32, 16), + add_arg(args, ARG_SGPR, ac_array_in_const_addr_space(ctx->ac.v4i32), &ctx->vertex_buffers); } add_arg(args, ARG_SGPR, ctx->ac.i32, &ctx->abi.base_vertex); @@ -799,7 +793,7 @@ static void create_function(struct nir_to_llvm_context *ctx, allocate_user_sgprs(ctx, stage, needs_view_index, &user_sgpr_info); if (user_sgpr_info.need_ring_offsets && !ctx->options->supports_spill) { - add_arg(&args, ARG_SGPR, const_array(ctx->ac.v4i32, 16), + add_arg(&args, ARG_SGPR, ac_array_in_const_addr_space(ctx->ac.v4i32), &ctx->ring_offsets); } @@ -1082,7 +1076,7 @@ static void create_function(struct nir_to_llvm_context *ctx, LLVMPointerType(ctx->ac.i8, AC_CONST_ADDR_SPACE), NULL, 0, AC_FUNC_ATTR_READNONE); ctx->ring_offsets = LLVMBuildBitCast(ctx->builder, ctx->ring_offsets, - const_array(ctx->ac.v4i32, 16), ""); + ac_array_in_const_addr_space(ctx->ac.v4i32), ""); } } @@ -4039,7 +4033,7 @@ static LLVMValueRef load_sample_position(struct nir_to_llvm_context *ctx, LLVMValueRef ptr = ac_build_gep0(&ctx->ac, ctx->ring_offsets, LLVMConstInt(ctx->ac.i32, RING_PS_SAMPLE_POSITIONS, false)); ptr = LLVMBuildBitCast(ctx->builder, ptr, - const_array(ctx->ac.v2f32, 64), ""); + ac_array_in_const_addr_space(ctx->ac.v2f32), ""); sample_id = LLVMBuildAdd(ctx->builder, sample_id, ctx->sample_pos_offset, ""); result = ac_build_load_invariant(&ctx->ac, ptr, sample_id); @@ -4650,7 +4644,7 @@ static LLVMValueRef radv_get_sampler_desc(struct ac_shader_abi *abi, index = LLVMBuildMul(builder, index, LLVMConstInt(ctx->ac.i32, stride / type_size, 0), ""); list = ac_build_gep0(&ctx->ac, list, LLVMConstInt(ctx->ac.i32, offset, 0)); - list = LLVMBuildPointerCast(builder, list, const_array(type, 0), ""); + list = LLVMBuildPointerCast(builder, list, ac_array_in_const_addr_space(type), ""); return ac_build_load_to_sgpr(&ctx->ac, list, index); } |