diff --git a/src/amd/llvm/ac_llvm_build.c b/src/amd/llvm/ac_llvm_build.c index a5b145397b1..3cc556e7104 100644 --- a/src/amd/llvm/ac_llvm_build.c +++ b/src/amd/llvm/ac_llvm_build.c @@ -1112,14 +1112,14 @@ LLVMTypeRef ac_build_gep0_type(LLVMTypeRef pointee_type, LLVMValueRef index) return NULL; } -LLVMValueRef ac_build_gep0(struct ac_llvm_context *ctx, LLVMTypeRef pointee_type, LLVMValueRef value, LLVMValueRef index) +LLVMValueRef ac_build_gep0(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr, LLVMValueRef index) { LLVMValueRef indices[2] = { ctx->i32_0, index, }; - return LLVMBuildGEP2(ctx->builder, pointee_type, value, indices, 2, ""); + return LLVMBuildGEP2(ctx->builder, ptr.t, ptr.v, indices, 2, ""); } LLVMValueRef ac_build_pointer_add(struct ac_llvm_context *ctx, LLVMTypeRef type, LLVMValueRef ptr, LLVMValueRef index) @@ -1127,10 +1127,10 @@ LLVMValueRef ac_build_pointer_add(struct ac_llvm_context *ctx, LLVMTypeRef type, return LLVMBuildGEP2(ctx->builder, type, ptr, &index, 1, ""); } -void ac_build_indexed_store(struct ac_llvm_context *ctx, LLVMTypeRef type, LLVMValueRef base_ptr, LLVMValueRef index, +void ac_build_indexed_store(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr, LLVMValueRef index, LLVMValueRef value) { - LLVMBuildStore(ctx->builder, value, ac_build_gep0(ctx, type, base_ptr, index)); + LLVMBuildStore(ctx->builder, value, ac_build_gep0(ctx, ptr, index)); } /** @@ -1182,30 +1182,29 @@ static LLVMValueRef ac_build_load_custom(struct ac_llvm_context *ctx, LLVMTypeRe return result; } -LLVMValueRef ac_build_load(struct ac_llvm_context *ctx, LLVMTypeRef type, LLVMValueRef base_ptr, LLVMValueRef index) +LLVMValueRef ac_build_load(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr, LLVMValueRef index) { - return ac_build_load_custom(ctx, type, base_ptr, index, false, false, false); + return ac_build_load_custom(ctx, ptr.t, ptr.v, index, false, false, false); } -LLVMValueRef ac_build_load_invariant(struct ac_llvm_context *ctx, LLVMTypeRef type, LLVMValueRef base_ptr, +LLVMValueRef ac_build_load_invariant(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr, LLVMValueRef index) { - return ac_build_load_custom(ctx, type, base_ptr, index, false, true, false); + return ac_build_load_custom(ctx, ptr.t, ptr.v, index, false, true, false); } /* This assumes that there is no unsigned integer wraparound during the address * computation, excluding all GEPs within base_ptr. */ -LLVMValueRef ac_build_load_to_sgpr(struct ac_llvm_context *ctx, LLVMTypeRef type, LLVMValueRef base_ptr, +LLVMValueRef ac_build_load_to_sgpr(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr, LLVMValueRef index) { - return ac_build_load_custom(ctx, type, base_ptr, index, true, true, true); + return ac_build_load_custom(ctx, ptr.t, ptr.v, index, true, true, true); } /* See ac_build_load_custom() documentation. */ -LLVMValueRef ac_build_load_to_sgpr_uint_wraparound(struct ac_llvm_context *ctx, LLVMTypeRef type, - LLVMValueRef base_ptr, LLVMValueRef index) +LLVMValueRef ac_build_load_to_sgpr_uint_wraparound(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr, LLVMValueRef index) { - return ac_build_load_custom(ctx, type, base_ptr, index, true, true, false); + return ac_build_load_custom(ctx, ptr.t, ptr.v, index, true, true, false); } static unsigned get_load_cache_policy(struct ac_llvm_context *ctx, unsigned cache_policy) @@ -2783,14 +2782,14 @@ void ac_declare_lds_as_pointer(struct ac_llvm_context *ctx) LLVMValueRef ac_lds_load(struct ac_llvm_context *ctx, LLVMValueRef dw_addr) { - LLVMValueRef v = ac_build_gep0(ctx, ctx->lds.t, ctx->lds.v, dw_addr); + LLVMValueRef v = ac_build_gep0(ctx, ctx->lds, dw_addr); return LLVMBuildLoad2(ctx->builder, ctx->i32, v, ""); } void ac_lds_store(struct ac_llvm_context *ctx, LLVMValueRef dw_addr, LLVMValueRef value) { value = ac_to_integer(ctx, value); - ac_build_indexed_store(ctx, ctx->lds.t, ctx->lds.v, dw_addr, value); + ac_build_indexed_store(ctx, ctx->lds, dw_addr, value); } LLVMValueRef ac_find_lsb(struct ac_llvm_context *ctx, LLVMTypeRef dst_type, LLVMValueRef src0) diff --git a/src/amd/llvm/ac_llvm_build.h b/src/amd/llvm/ac_llvm_build.h index 6055a7d494a..d3f2ea99a2c 100644 --- a/src/amd/llvm/ac_llvm_build.h +++ b/src/amd/llvm/ac_llvm_build.h @@ -258,19 +258,19 @@ LLVMValueRef ac_build_pointer_add(struct ac_llvm_context *ctx, LLVMTypeRef type, LLVMValueRef index); LLVMTypeRef ac_build_gep0_type(LLVMTypeRef pointee_type, LLVMValueRef index); -LLVMValueRef ac_build_gep0(struct ac_llvm_context *ctx, LLVMTypeRef type, LLVMValueRef value, LLVMValueRef index); +LLVMValueRef ac_build_gep0(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr, LLVMValueRef index); -void ac_build_indexed_store(struct ac_llvm_context *ctx, LLVMTypeRef type, LLVMValueRef base_ptr, LLVMValueRef index, +void ac_build_indexed_store(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr, LLVMValueRef index, LLVMValueRef value); -LLVMValueRef ac_build_load(struct ac_llvm_context *ctx, LLVMTypeRef type, LLVMValueRef base_ptr, LLVMValueRef index); -LLVMValueRef ac_build_load_invariant(struct ac_llvm_context *ctx, LLVMTypeRef type, LLVMValueRef base_ptr, +LLVMValueRef ac_build_load(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr, LLVMValueRef index); +LLVMValueRef ac_build_load_invariant(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr, LLVMValueRef index); -LLVMValueRef ac_build_load_to_sgpr(struct ac_llvm_context *ctx, LLVMTypeRef type, LLVMValueRef base_ptr, +LLVMValueRef ac_build_load_to_sgpr(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr, LLVMValueRef index); -LLVMValueRef ac_build_load_to_sgpr_uint_wraparound(struct ac_llvm_context *ctx, LLVMTypeRef type, - LLVMValueRef base_ptr, LLVMValueRef index); +LLVMValueRef ac_build_load_to_sgpr_uint_wraparound(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr, + LLVMValueRef index); void ac_build_buffer_store_dword(struct ac_llvm_context *ctx, LLVMValueRef rsrc, LLVMValueRef vdata, LLVMValueRef vindex, LLVMValueRef voffset, LLVMValueRef soffset, diff --git a/src/amd/llvm/ac_nir_to_llvm.c b/src/amd/llvm/ac_nir_to_llvm.c index 19d6a34537a..d8efa4190a2 100644 --- a/src/amd/llvm/ac_nir_to_llvm.c +++ b/src/amd/llvm/ac_nir_to_llvm.c @@ -1667,8 +1667,8 @@ static LLVMValueRef visit_load_push_constant(struct ac_nir_context *ctx, nir_int } } - LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, ctx->args, ctx->args->push_constants); - ptr = LLVMBuildGEP2(ctx->ac.builder, type, ac_get_arg(&ctx->ac, ctx->args->push_constants), &addr, 1, ""); + struct ac_llvm_pointer pc = ac_get_ptr_arg(&ctx->ac, ctx->args, ctx->args->push_constants); + ptr = LLVMBuildGEP2(ctx->ac.builder, pc.t, pc.v, &addr, 1, ""); if (instr->dest.ssa.bit_size == 8) { unsigned load_dwords = instr->dest.ssa.num_components > 1 ? 2 : 1; @@ -3717,8 +3717,8 @@ static bool visit_intrinsic(struct ac_nir_context *ctx, nir_intrinsic_instr *ins if (ctx->abi->load_grid_size_from_user_sgpr) { result = ac_get_arg(&ctx->ac, ctx->args->num_work_groups); } else { - LLVMValueRef ptr = ac_get_arg(&ctx->ac, ctx->args->num_work_groups); - result = ac_build_load_invariant(&ctx->ac, ctx->ac.v3i32, ptr, ctx->ac.i32_0); + result = ac_build_load_invariant(&ctx->ac, + ac_get_ptr_arg(&ctx->ac, ctx->args, ctx->args->num_work_groups), ctx->ac.i32_0); } if (nir_dest_bit_size(instr->dest) == 64) result = LLVMBuildZExt(ctx->ac.builder, result, LLVMVectorType(ctx->ac.i64, 3), ""); @@ -4115,7 +4115,7 @@ static bool visit_intrinsic(struct ac_nir_context *ctx, nir_intrinsic_instr *ins break; case nir_intrinsic_load_scratch: { LLVMValueRef offset = get_src(ctx, instr->src[0]); - LLVMValueRef ptr = ac_build_gep0(&ctx->ac, ctx->scratch.t, ctx->scratch.v, offset); + LLVMValueRef ptr = ac_build_gep0(&ctx->ac, ctx->scratch, offset); LLVMTypeRef comp_type = LLVMIntTypeInContext(ctx->ac.context, instr->dest.ssa.bit_size); LLVMTypeRef vec_type = instr->dest.ssa.num_components == 1 ? comp_type @@ -4125,7 +4125,7 @@ static bool visit_intrinsic(struct ac_nir_context *ctx, nir_intrinsic_instr *ins } case nir_intrinsic_store_scratch: { LLVMValueRef offset = get_src(ctx, instr->src[1]); - LLVMValueRef ptr = ac_build_gep0(&ctx->ac, ctx->scratch.t, ctx->scratch.v, offset); + LLVMValueRef ptr = ac_build_gep0(&ctx->ac, ctx->scratch, offset); LLVMTypeRef comp_type = LLVMIntTypeInContext(ctx->ac.context, instr->src[0].ssa->bit_size); LLVMValueRef src = get_src(ctx, instr->src[0]); unsigned wrmask = nir_intrinsic_write_mask(instr); @@ -4154,7 +4154,7 @@ static bool visit_intrinsic(struct ac_nir_context *ctx, nir_intrinsic_instr *ins LLVMValueRef cond = LLVMBuildICmp(ctx->ac.builder, LLVMIntULT, offset, size, ""); offset = LLVMBuildSelect(ctx->ac.builder, cond, offset, size, ""); - LLVMValueRef ptr = ac_build_gep0(&ctx->ac, ctx->constant_data.t, ctx->constant_data.v, offset); + LLVMValueRef ptr = ac_build_gep0(&ctx->ac, ctx->constant_data, offset); LLVMTypeRef comp_type = LLVMIntTypeInContext(ctx->ac.context, instr->dest.ssa.bit_size); LLVMTypeRef vec_type = instr->dest.ssa.num_components == 1 ? comp_type diff --git a/src/amd/vulkan/radv_nir_to_llvm.c b/src/amd/vulkan/radv_nir_to_llvm.c index 95d0cebd903..47ae7128529 100644 --- a/src/amd/vulkan/radv_nir_to_llvm.c +++ b/src/amd/vulkan/radv_nir_to_llvm.c @@ -108,13 +108,12 @@ load_descriptor_sets(struct radv_shader_context *ctx) uint32_t mask = ctx->shader_info->desc_set_used_mask; if (user_sgprs_locs->shader_data[AC_UD_INDIRECT_DESCRIPTOR_SETS].sgpr_idx != -1) { - LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args->ac, ctx->args->descriptor_sets[0]); - LLVMValueRef desc_sets = ac_get_arg(&ctx->ac, ctx->args->descriptor_sets[0]); + struct ac_llvm_pointer desc_sets = ac_get_ptr_arg(&ctx->ac, &ctx->args->ac, ctx->args->descriptor_sets[0]); while (mask) { int i = u_bit_scan(&mask); ctx->descriptor_sets[i] = - ac_build_load_to_sgpr(&ctx->ac, type, desc_sets, LLVMConstInt(ctx->ac.i32, i, false)); + ac_build_load_to_sgpr(&ctx->ac, desc_sets, LLVMConstInt(ctx->ac.i32, i, false)); LLVMSetAlignment(ctx->descriptor_sets[i], 4); } } else { @@ -350,8 +349,7 @@ static void load_vs_input(struct radv_shader_context *ctx, unsigned driver_location, LLVMTypeRef dest_type, LLVMValueRef out[4]) { - LLVMTypeRef t_list_type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args->ac, ctx->args->ac.vertex_buffers); - LLVMValueRef t_list_ptr = ac_get_arg(&ctx->ac, ctx->args->ac.vertex_buffers); + struct ac_llvm_pointer t_list_ptr = ac_get_ptr_arg(&ctx->ac, &ctx->args->ac, ctx->args->ac.vertex_buffers); LLVMValueRef t_offset; LLVMValueRef t_list; LLVMValueRef input; @@ -402,7 +400,7 @@ load_vs_input(struct radv_shader_context *ctx, unsigned driver_location, LLVMTyp desc_index = util_bitcount(ctx->shader_info->vs.vb_desc_usage_mask & u_bit_consecutive(0, desc_index)); t_offset = LLVMConstInt(ctx->ac.i32, desc_index, false); - t_list = ac_build_load_to_sgpr(&ctx->ac, t_list_type, t_list_ptr, t_offset); + t_list = ac_build_load_to_sgpr(&ctx->ac, t_list_ptr, t_offset); /* Always split typed vertex buffer loads on GFX6 and GFX10+ to avoid any alignment issues that * triggers memory violations and eventually a GPU hang. This can happen if the stride (static or @@ -800,8 +798,7 @@ radv_emit_streamout(struct radv_shader_context *ctx, unsigned stream) */ LLVMValueRef so_write_offset[4] = {0}; LLVMValueRef so_buffers[4] = {0}; - LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args->ac, ctx->args->streamout_buffers); - LLVMValueRef buf_ptr = ac_get_arg(&ctx->ac, ctx->args->streamout_buffers); + struct ac_llvm_pointer buf_ptr = ac_get_ptr_arg(&ctx->ac, &ctx->args->ac, ctx->args->streamout_buffers); for (i = 0; i < 4; i++) { uint16_t stride = ctx->shader_info->so.strides[i]; @@ -811,7 +808,7 @@ radv_emit_streamout(struct radv_shader_context *ctx, unsigned stream) LLVMValueRef offset = LLVMConstInt(ctx->ac.i32, i, false); - so_buffers[i] = ac_build_load_to_sgpr(&ctx->ac, type, buf_ptr, offset); + so_buffers[i] = ac_build_load_to_sgpr(&ctx->ac, buf_ptr, offset); LLVMValueRef so_offset = ac_get_arg(&ctx->ac, ctx->args->ac.streamout_offset[i]); @@ -1178,6 +1175,8 @@ radv_llvm_visit_export_vertex(struct ac_shader_abi *abi) static void ac_setup_rings(struct radv_shader_context *ctx) { + struct ac_llvm_pointer ring_offsets = { .t = ctx->ac.i8, .v = ctx->ring_offsets }; + if (ctx->options->gfx_level <= GFX8 && (ctx->stage == MESA_SHADER_GEOMETRY || (ctx->stage == MESA_SHADER_VERTEX && ctx->shader_info->vs.as_es) || @@ -1185,12 +1184,11 @@ ac_setup_rings(struct radv_shader_context *ctx) unsigned ring = ctx->stage == MESA_SHADER_GEOMETRY ? RING_ESGS_GS : RING_ESGS_VS; LLVMValueRef offset = LLVMConstInt(ctx->ac.i32, ring, false); - ctx->esgs_ring = ac_build_load_to_sgpr(&ctx->ac, ctx->ac.i8, ctx->ring_offsets, offset); + ctx->esgs_ring = ac_build_load_to_sgpr(&ctx->ac, ring_offsets, offset); } if (ctx->args->is_gs_copy_shader) { - ctx->gsvs_ring[0] = ac_build_load_to_sgpr(&ctx->ac, ctx->ac.i8, ctx->ring_offsets, - LLVMConstInt(ctx->ac.i32, RING_GSVS_VS, false)); + ctx->gsvs_ring[0] = ac_build_load_to_sgpr(&ctx->ac, ring_offsets, LLVMConstInt(ctx->ac.i32, RING_GSVS_VS, false)); } if (ctx->stage == MESA_SHADER_GEOMETRY) { @@ -1207,7 +1205,7 @@ ac_setup_rings(struct radv_shader_context *ctx) unsigned num_records = ctx->ac.wave_size; LLVMValueRef base_ring; - base_ring = ac_build_load_to_sgpr(&ctx->ac, ctx->ac.i8, ctx->ring_offsets, + base_ring = ac_build_load_to_sgpr(&ctx->ac, ring_offsets, LLVMConstInt(ctx->ac.i32, RING_GSVS_GS, false)); for (unsigned stream = 0; stream < 4; stream++) { @@ -1248,9 +1246,9 @@ ac_setup_rings(struct radv_shader_context *ctx) if (ctx->stage == MESA_SHADER_TESS_CTRL || ctx->stage == MESA_SHADER_TESS_EVAL) { ctx->hs_ring_tess_offchip = ac_build_load_to_sgpr( - &ctx->ac, ctx->ac.i8, ctx->ring_offsets, LLVMConstInt(ctx->ac.i32, RING_HS_TESS_OFFCHIP, false)); + &ctx->ac, ring_offsets, LLVMConstInt(ctx->ac.i32, RING_HS_TESS_OFFCHIP, false)); ctx->hs_ring_tess_factor = ac_build_load_to_sgpr( - &ctx->ac, ctx->ac.i8, ctx->ring_offsets, LLVMConstInt(ctx->ac.i32, RING_HS_TESS_FACTOR, false)); + &ctx->ac, ring_offsets, LLVMConstInt(ctx->ac.i32, RING_HS_TESS_FACTOR, false)); } } diff --git a/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c b/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c index 27b907cdd55..004d9ede626 100644 --- a/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c +++ b/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c @@ -65,18 +65,13 @@ static LLVMValueRef ngg_get_ordered_id(struct si_shader_context *ctx) static LLVMValueRef ngg_get_query_buf(struct si_shader_context *ctx) { - LLVMValueRef buf_ptr = ac_get_arg(&ctx->ac, ctx->internal_bindings); - LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->internal_bindings); - return ac_build_load_to_sgpr(&ctx->ac, type, buf_ptr, + return ac_build_load_to_sgpr(&ctx->ac, ac_get_ptr_arg(&ctx->ac, &ctx->args, ctx->internal_bindings), LLVMConstInt(ctx->ac.i32, SI_GS_QUERY_BUF, false)); } static LLVMValueRef ngg_get_emulated_counters_buf(struct si_shader_context *ctx) { - LLVMValueRef buf_ptr = ac_get_arg(&ctx->ac, ctx->internal_bindings); - LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->internal_bindings); - - return ac_build_load_to_sgpr(&ctx->ac, type, buf_ptr, + return ac_build_load_to_sgpr(&ctx->ac, ac_get_ptr_arg(&ctx->ac, &ctx->args, ctx->internal_bindings), LLVMConstInt(ctx->ac.i32, SI_GS_QUERY_EMULATED_COUNTERS_BUF, false)); } @@ -253,7 +248,7 @@ static void build_streamout_vertex(struct si_shader_context *ctx, LLVMValueRef * for (unsigned comp = 0; comp < 4; comp++) { LLVMValueRef idx = LLVMConstInt(ctx->ac.i32, 4 * reg + comp, false); - LLVMValueRef v = ac_build_gep0(&ctx->ac, vertexptr.t, vertexptr.v, idx); + LLVMValueRef v = ac_build_gep0(&ctx->ac, vertexptr, idx); out.values[comp] = LLVMBuildLoad2(builder, ac_build_gep0_type(vertexptr.t, idx), v, ""); out.vertex_streams = info->output_streams[reg]; } @@ -287,8 +282,7 @@ static void build_streamout(struct si_shader_context *ctx, struct ngg_streamout struct si_shader_info *info = &ctx->shader->selector->info; struct pipe_stream_output_info *so = &ctx->so; LLVMBuilderRef builder = ctx->ac.builder; - LLVMValueRef buf_ptr = ac_get_arg(&ctx->ac, ctx->internal_bindings); - LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->internal_bindings); + struct ac_llvm_pointer arg = ac_get_ptr_arg(&ctx->ac, &ctx->args, ctx->internal_bindings); LLVMValueRef tid = gfx10_get_thread_id_in_tg(ctx); LLVMValueRef tmp, tmp2; LLVMValueRef i32_2 = LLVMConstInt(ctx->ac.i32, 2, false); @@ -328,7 +322,7 @@ static void build_streamout(struct si_shader_context *ctx, struct ngg_streamout LLVMConstInt(ctx->ac.i32, buffer, false)); so_buffer[buffer] = ac_build_load_to_sgpr( - &ctx->ac, type, buf_ptr, LLVMConstInt(ctx->ac.i32, SI_VS_STREAMOUT_BUF0 + buffer, false)); + &ctx->ac, arg, LLVMConstInt(ctx->ac.i32, SI_VS_STREAMOUT_BUF0 + buffer, false)); } tmp = LLVMBuildICmp(builder, LLVMIntEQ, get_wave_id_in_tg(ctx), ctx->ac.i32_0, ""); @@ -345,7 +339,7 @@ static void build_streamout(struct si_shader_context *ctx, struct ngg_streamout ac_build_ifcc(&ctx->ac, tmp, 5210); { if (isgs) { - LLVMValueRef vt = ac_build_gep0(&ctx->ac, ctx->gs_ngg_scratch.t, ctx->gs_ngg_scratch.v, tid); + LLVMValueRef vt = ac_build_gep0(&ctx->ac, ctx->gs_ngg_scratch, tid); tmp = LLVMBuildLoad2(builder, ac_build_gep0_type(ctx->gs_ngg_scratch.t, tid), vt, ""); } else { tmp = ac_build_writelane(&ctx->ac, ctx->ac.i32_0, ngg_get_prim_cnt(ctx), ctx->ac.i32_0); @@ -452,7 +446,7 @@ static void build_streamout(struct si_shader_context *ctx, struct ngg_streamout LLVMBuildStore(builder, tmp, offsets_vgpr); tmp2 = LLVMBuildAdd(builder, ac_get_thread_id(&ctx->ac), scratch_offset_basev, ""); - tmp2 = ac_build_gep0(&ctx->ac, ctx->gs_ngg_scratch.t, ctx->gs_ngg_scratch.v, tmp2); + tmp2 = ac_build_gep0(&ctx->ac, ctx->gs_ngg_scratch, tmp2); LLVMBuildStore(builder, tmp, tmp2); } ac_build_endif(&ctx->ac, 5210); @@ -546,7 +540,7 @@ static void build_streamout(struct si_shader_context *ctx, struct ngg_streamout ac_build_ifcc(&ctx->ac, tmp, 5225); { tmp = LLVMBuildAdd(builder, ac_get_thread_id(&ctx->ac), scratch_emit_basev, ""); - tmp = ac_build_gep0(&ctx->ac, ctx->gs_ngg_scratch.t, ctx->gs_ngg_scratch.v, tmp); + tmp = ac_build_gep0(&ctx->ac, ctx->gs_ngg_scratch, tmp); LLVMBuildStore(builder, emit_vgpr, tmp); } ac_build_endif(&ctx->ac, 5225); @@ -567,7 +561,7 @@ static void build_streamout(struct si_shader_context *ctx, struct ngg_streamout primemit_scan[stream].op = nir_op_iadd; primemit_scan[stream].src = nggso->prim_enable[stream]; primemit_scan[stream].scratch = ac_build_gep0( - &ctx->ac, ctx->gs_ngg_scratch.t, ctx->gs_ngg_scratch.v, + &ctx->ac, ctx->gs_ngg_scratch, LLVMConstInt(ctx->ac.i32, 12 + 8 * stream, false)); primemit_scan[stream].waveidx = get_wave_id_in_tg(ctx); primemit_scan[stream].numwaves = get_tgsize(ctx); @@ -592,7 +586,7 @@ static void build_streamout(struct si_shader_context *ctx, struct ngg_streamout LLVMValueRef scratch_vgpr; LLVMValueRef idx = ac_get_thread_id(&ctx->ac); - LLVMValueRef v = ac_build_gep0(&ctx->ac, ctx->gs_ngg_scratch.t, ctx->gs_ngg_scratch.v, idx); + LLVMValueRef v = ac_build_gep0(&ctx->ac, ctx->gs_ngg_scratch, idx); scratch_vgpr = LLVMBuildLoad2(builder, ac_build_gep0_type(ctx->gs_ngg_scratch.t, idx), v, ""); for (unsigned buffer = 0; buffer < 4; ++buffer) { @@ -779,7 +773,7 @@ static void load_vertex_counts(struct si_shader_context *ctx, struct ac_llvm_poi */ ac_build_ifcc(&ctx->ac, LLVMBuildICmp(builder, LLVMIntULT, tid, LLVMConstInt(ctx->ac.i32, num_i8vec4, 0), ""), 17771); - LLVMValueRef v = ac_build_gep0(&ctx->ac, lds.t, lds.v, tid); + LLVMValueRef v = ac_build_gep0(&ctx->ac, lds, tid); LLVMBuildStore(builder, LLVMBuildLoad2(builder, ac_build_gep0_type(lds.t, tid), v, ""), i8vec4_lane); ac_build_endif(&ctx->ac, 17771); @@ -953,10 +947,9 @@ static void cull_primitive(struct si_shader_context *ctx, /* Load the viewport state for small prim culling. */ bool prim_is_lines = shader->key.ge.opt.ngg_culling & SI_NGG_CULL_LINES; - LLVMValueRef ptr = ac_get_arg(&ctx->ac, ctx->small_prim_cull_info); - LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->small_prim_cull_info); + struct ac_llvm_pointer small_prim_cull_info_arg = ac_get_ptr_arg(&ctx->ac, &ctx->args, ctx->small_prim_cull_info); /* Lines will always use the non-AA viewport transformation. */ - LLVMValueRef vp = ac_build_load_to_sgpr(&ctx->ac, type, ptr, + LLVMValueRef vp = ac_build_load_to_sgpr(&ctx->ac, small_prim_cull_info_arg, prim_is_lines ? ctx->ac.i32_1 : ctx->ac.i32_0); vp = LLVMBuildBitCast(builder, vp, ctx->ac.v4f32, ""); vp_scale[0] = ac_llvm_extract_elem(&ctx->ac, vp, 0); @@ -970,7 +963,8 @@ static void cull_primitive(struct si_shader_context *ctx, options.cull_w = true; if (prim_is_lines) { - LLVMValueRef terms = ac_build_load_to_sgpr(&ctx->ac, ctx->ac.v2f32, ptr, LLVMConstInt(ctx->ac.i32, 4, 0)); + small_prim_cull_info_arg.t = ctx->ac.v2f32; + LLVMValueRef terms = ac_build_load_to_sgpr(&ctx->ac, small_prim_cull_info_arg, LLVMConstInt(ctx->ac.i32, 4, 0)); terms = LLVMBuildBitCast(builder, terms, ctx->ac.v2f32, ""); clip_half_line_width[0] = ac_llvm_extract_elem(&ctx->ac, terms, 0); clip_half_line_width[1] = ac_llvm_extract_elem(&ctx->ac, terms, 1); @@ -1062,14 +1056,14 @@ void gfx10_ngg_culling_build_end(struct si_shader_context *ctx) /* Store Position.W into LDS. */ LLVMBuildStore( builder, ac_to_integer(&ctx->ac, position[3]), - ac_build_gep0(&ctx->ac, es_vtxptr.t, es_vtxptr.v, LLVMConstInt(ctx->ac.i32, lds_pos_cull_w, 0))); + ac_build_gep0(&ctx->ac, es_vtxptr, LLVMConstInt(ctx->ac.i32, lds_pos_cull_w, 0))); /* Store Position.XY / W into LDS. */ for (unsigned chan = 0; chan < 2; chan++) { LLVMValueRef val = ac_build_fdiv(&ctx->ac, position[chan], position[3]); LLVMBuildStore( builder, ac_to_integer(&ctx->ac, val), - ac_build_gep0(&ctx->ac, es_vtxptr.t, es_vtxptr.v, LLVMConstInt(ctx->ac.i32, lds_pos_cull_x_div_w + chan, 0))); + ac_build_gep0(&ctx->ac, es_vtxptr, LLVMConstInt(ctx->ac.i32, lds_pos_cull_x_div_w + chan, 0))); } break; @@ -1111,7 +1105,7 @@ void gfx10_ngg_culling_build_end(struct si_shader_context *ctx) /* Initialize the packed data. */ LLVMBuildStore( builder, packed_data, - ac_build_gep0(&ctx->ac, es_vtxptr.t, es_vtxptr.v, LLVMConstInt(ctx->ac.i32, lds_packed_data, 0))); + ac_build_gep0(&ctx->ac, es_vtxptr, LLVMConstInt(ctx->ac.i32, lds_packed_data, 0))); ac_build_endif(&ctx->ac, ctx->merged_wrap_if_label); ac_build_waitcnt(&ctx->ac, AC_WAIT_LGKM); @@ -1208,7 +1202,7 @@ void gfx10_ngg_culling_build_end(struct si_shader_context *ctx) continue; LLVMValueRef idx = LLVMConstInt(ctx->ac.i32, index, 0); - LLVMValueRef v = ac_build_gep0(&ctx->ac, gs_vtxptr[vtx].t, gs_vtxptr[vtx].v, idx); + LLVMValueRef v = ac_build_gep0(&ctx->ac, gs_vtxptr[vtx], idx); pos[vtx][chan] = LLVMBuildLoad2(builder, ac_build_gep0_type(gs_vtxptr[vtx].t, idx), v, ""); pos[vtx][chan] = ac_to_float(&ctx->ac, pos[vtx][chan]); } @@ -1305,7 +1299,7 @@ void gfx10_ngg_culling_build_end(struct si_shader_context *ctx) LLVMBuildStore( builder, ac_to_integer(&ctx->ac, LLVMBuildLoad2(builder, ctx->ac.f32, addrs[4 * pos_index + chan], "")), - ac_build_gep0(&ctx->ac, new_vtx.t, new_vtx.v, LLVMConstInt(ctx->ac.i32, lds_pos_x + chan, 0))); + ac_build_gep0(&ctx->ac, new_vtx, LLVMConstInt(ctx->ac.i32, lds_pos_x + chan, 0))); } /* Store VertexID and InstanceID into LDS. ES threads will have to load them @@ -1315,24 +1309,24 @@ void gfx10_ngg_culling_build_end(struct si_shader_context *ctx) if (ctx->stage == MESA_SHADER_VERTEX) { LLVMBuildStore( builder, ctx->abi.vertex_id, - ac_build_gep0(&ctx->ac, new_vtx.t, new_vtx.v, LLVMConstInt(ctx->ac.i32, lds_vertex_id, 0))); + ac_build_gep0(&ctx->ac, new_vtx, LLVMConstInt(ctx->ac.i32, lds_vertex_id, 0))); if (uses_instance_id) { LLVMBuildStore( builder, ctx->abi.instance_id, - ac_build_gep0(&ctx->ac, new_vtx.t, new_vtx.v, LLVMConstInt(ctx->ac.i32, lds_instance_id, 0))); + ac_build_gep0(&ctx->ac, new_vtx, LLVMConstInt(ctx->ac.i32, lds_instance_id, 0))); } } else { assert(ctx->stage == MESA_SHADER_TESS_EVAL); LLVMBuildStore(builder, ac_to_integer(&ctx->ac, ac_get_arg(&ctx->ac, ctx->args.tes_u)), - ac_build_gep0(&ctx->ac, new_vtx.t, new_vtx.v, LLVMConstInt(ctx->ac.i32, lds_tes_u, 0))); + ac_build_gep0(&ctx->ac, new_vtx, LLVMConstInt(ctx->ac.i32, lds_tes_u, 0))); LLVMBuildStore(builder, ac_to_integer(&ctx->ac, ac_get_arg(&ctx->ac, ctx->args.tes_v)), - ac_build_gep0(&ctx->ac, new_vtx.t, new_vtx.v, LLVMConstInt(ctx->ac.i32, lds_tes_v, 0))); + ac_build_gep0(&ctx->ac, new_vtx, LLVMConstInt(ctx->ac.i32, lds_tes_v, 0))); LLVMBuildStore(builder, LLVMBuildTrunc(builder, ac_get_arg(&ctx->ac, ctx->args.tes_rel_patch_id), ctx->ac.i8, ""), si_build_gep_i8(ctx, new_vtx.value, lds_byte2_tes_rel_patch_id)); if (uses_tes_prim_id) { LLVMBuildStore( builder, ac_get_arg(&ctx->ac, ctx->args.tes_patch_id), - ac_build_gep0(&ctx->ac, new_vtx.t, new_vtx.v, LLVMConstInt(ctx->ac.i32, lds_tes_patch_id, 0))); + ac_build_gep0(&ctx->ac, new_vtx, LLVMConstInt(ctx->ac.i32, lds_tes_patch_id, 0))); } } } @@ -1411,13 +1405,13 @@ void gfx10_ngg_culling_build_end(struct si_shader_context *ctx) /* Prepare LDS addresses of the new ES input VGPRs. */ LLVMValueRef input_vgpr_addresses[4] = { - ac_build_gep0(&ctx->ac, es_vtxptr.t, es_vtxptr.v, LLVMConstInt(ctx->ac.i32, lds_vertex_id, 0)), - ac_build_gep0(&ctx->ac, es_vtxptr.t, es_vtxptr.v, LLVMConstInt(ctx->ac.i32, lds_instance_id, 0)), + ac_build_gep0(&ctx->ac, es_vtxptr, LLVMConstInt(ctx->ac.i32, lds_vertex_id, 0)), + ac_build_gep0(&ctx->ac, es_vtxptr, LLVMConstInt(ctx->ac.i32, lds_instance_id, 0)), }; if (ctx->stage == MESA_SHADER_TESS_EVAL) { input_vgpr_addresses[2] = si_build_gep_i8(ctx, es_vtxptr.v, lds_byte2_tes_rel_patch_id); if (uses_tes_prim_id) { - input_vgpr_addresses[3] = ac_build_gep0(&ctx->ac, es_vtxptr.t, es_vtxptr.v, + input_vgpr_addresses[3] = ac_build_gep0(&ctx->ac, es_vtxptr, LLVMConstInt(ctx->ac.i32, lds_tes_patch_id, 0)); } } @@ -1545,7 +1539,7 @@ void gfx10_ngg_build_end(struct si_shader_context *ctx) */ if (ctx->so.num_outputs) { LLVMValueRef idx = LLVMConstInt(ctx->ac.i32, 4 * i + j, false); - tmp = ac_build_gep0(&ctx->ac, vertex_ptr.t, vertex_ptr.v, idx); + tmp = ac_build_gep0(&ctx->ac, vertex_ptr, idx); tmp2 = LLVMBuildLoad2(builder, ac_build_gep0_type(vertex_ptr.t, idx), addrs[4 * i + j], ""); LLVMTypeRef type = ac_to_integer_type(&ctx->ac, ctx->ac.f32); tmp2 = LLVMBuildBitCast(ctx->ac.builder, tmp2, type, ""); @@ -1561,7 +1555,7 @@ void gfx10_ngg_build_end(struct si_shader_context *ctx) edgeflag = ac_build_umin(&ctx->ac, edgeflag, ctx->ac.i32_1); tmp = LLVMConstInt(ctx->ac.i32, ngg_nogs_vertex_size(ctx->shader) - 1, 0); - tmp = ac_build_gep0(&ctx->ac, vertex_ptr.t, vertex_ptr.v, tmp); + tmp = ac_build_gep0(&ctx->ac, vertex_ptr, tmp); LLVMBuildStore(builder, edgeflag, tmp); } } @@ -1624,7 +1618,7 @@ void gfx10_ngg_build_end(struct si_shader_context *ctx) struct ac_llvm_pointer vt = ngg_nogs_vertex_ptr(ctx, vtxindex[i]); tmp2 = LLVMConstInt(ctx->ac.i32, ngg_nogs_vertex_size(ctx->shader) - 1, 0); tmp = LLVMBuildLoad2(builder, ac_build_gep0_type(vt.t, tmp2), - ac_build_gep0(&ctx->ac, vt.t, vt.v, tmp2), ""); + ac_build_gep0(&ctx->ac, vt, tmp2), ""); tmp = LLVMBuildTrunc(builder, tmp, ctx->ac.i1, ""); user_edgeflags[i] = ac_build_alloca_init(&ctx->ac, tmp, ""); @@ -1655,7 +1649,7 @@ void gfx10_ngg_build_end(struct si_shader_context *ctx) struct ac_llvm_pointer vertex_ptr = ngg_nogs_vertex_ptr(ctx, provoking_vtx_index); LLVMBuildStore(builder, ac_get_arg(&ctx->ac, ctx->args.gs_prim_id), - ac_build_gep0(&ctx->ac, vertex_ptr.t, vertex_ptr.v, ctx->ac.i32_0)); + ac_build_gep0(&ctx->ac, vertex_ptr, ctx->ac.i32_0)); ac_build_endif(&ctx->ac, 5400); } @@ -1719,7 +1713,7 @@ void gfx10_ngg_build_end(struct si_shader_context *ctx) for (unsigned j = 0; j < 4; j++) { tmp = LLVMConstInt(ctx->ac.i32, lds_pos_x + j, 0); - LLVMValueRef v = ac_build_gep0(&ctx->ac, vertex_ptr.t, vertex_ptr.v, tmp); + LLVMValueRef v = ac_build_gep0(&ctx->ac, vertex_ptr, tmp); tmp = LLVMBuildLoad2(builder, ac_build_gep0_type(vertex_ptr.t, tmp), v, ""); outputs[i].values[j] = LLVMBuildBitCast(ctx->ac.builder, tmp, ac_to_float_type(&ctx->ac, ctx->ac.f32), ""); @@ -1742,7 +1736,7 @@ void gfx10_ngg_build_end(struct si_shader_context *ctx) struct ac_llvm_pointer vt = ngg_nogs_vertex_ptr(ctx, gfx10_get_thread_id_in_tg(ctx)); outputs[i].values[0] = LLVMBuildLoad2( - builder, ac_build_gep0_type(vt.t, ctx->ac.i32_0), ac_build_gep0(&ctx->ac, vt.t, vt.v, ctx->ac.i32_0), ""); + builder, ac_build_gep0_type(vt.t, ctx->ac.i32_0), ac_build_gep0(&ctx->ac, vt, ctx->ac.i32_0), ""); } else { assert(ctx->stage == MESA_SHADER_TESS_EVAL); outputs[i].values[0] = si_get_primitive_id(ctx, 0); @@ -1821,7 +1815,7 @@ static struct ac_llvm_pointer ngg_gs_vertex_ptr(struct si_shader_context *ctx, L } return (struct ac_llvm_pointer) { - .value = ac_build_gep0(&ctx->ac, storage.t, storage.v, vertexidx), + .value = ac_build_gep0(&ctx->ac, storage, vertexidx), .pointee_type = ac_build_gep0_type(storage.t, vertexidx) }; } @@ -1948,7 +1942,7 @@ void gfx10_ngg_gs_emit_begin(struct si_shader_context *ctx) tmp = LLVMBuildICmp(builder, LLVMIntULT, tid, LLVMConstInt(ctx->ac.i32, 4, false), ""); ac_build_ifcc(&ctx->ac, tmp, 5090); { - LLVMValueRef ptr = ac_build_gep0(&ctx->ac, scratchptr.t, scratchptr.v, tid); + LLVMValueRef ptr = ac_build_gep0(&ctx->ac, scratchptr, tid); LLVMBuildStore(builder, ctx->ac.i32_0, ptr); } ac_build_endif(&ctx->ac, 5090); @@ -2033,7 +2027,7 @@ void gfx10_ngg_gs_build_end(struct si_shader_context *ctx) { LLVMBuildAtomicRMW( builder, LLVMAtomicRMWBinOpAdd, - ac_build_gep0(&ctx->ac, ctx->gs_ngg_scratch.t, ctx->gs_ngg_scratch.v, LLVMConstInt(ctx->ac.i32, stream, false)), + ac_build_gep0(&ctx->ac, ctx->gs_ngg_scratch, LLVMConstInt(ctx->ac.i32, stream, false)), numprims, LLVMAtomicOrderingMonotonic, false); } ac_build_endif(&ctx->ac, 5105); @@ -2069,7 +2063,7 @@ void gfx10_ngg_gs_build_end(struct si_shader_context *ctx) ""); struct ac_llvm_pointer vt = ngg_gs_vertex_ptr(ctx, tmp); nggso.vertices[i].t = ac_build_gep0_type(vt.t, ctx->ac.i32_0); - nggso.vertices[i].v = ac_build_gep0(&ctx->ac, vt.t, vt.v, ctx->ac.i32_0); + nggso.vertices[i].v = ac_build_gep0(&ctx->ac, vt, ctx->ac.i32_0); } build_streamout(ctx, &nggso); @@ -2096,9 +2090,7 @@ void gfx10_ngg_gs_build_end(struct si_shader_context *ctx) offset = LLVMBuildAdd(builder, offset, tmp, ""); } - tmp = LLVMBuildLoad2(builder, ctx->ac.i32, - ac_build_gep0(&ctx->ac, ctx->gs_ngg_scratch.t, ctx->gs_ngg_scratch.v, - tid), ""); + tmp = LLVMBuildLoad2(builder, ctx->ac.i32, ac_build_gep0(&ctx->ac, ctx->gs_ngg_scratch, tid), ""); LLVMValueRef args[] = { tmp, ngg_get_query_buf(ctx), offset, LLVMConstInt(ctx->ac.i32, 16, false), /* soffset */ @@ -2136,7 +2128,7 @@ void gfx10_ngg_gs_build_end(struct si_shader_context *ctx) tmp = LLVMBuildSub(builder, tid, LLVMConstInt(ctx->ac.i32, verts_per_prim - i - 1, false), ""); struct ac_llvm_pointer vt = ngg_gs_vertex_ptr(ctx, tmp); vtxptr[i].t = ac_build_gep0_type(vt.t, ctx->ac.i32_0); - vtxptr[i].v = ac_build_gep0(&ctx->ac, vt.t, vt.v, ctx->ac.i32_0); + vtxptr[i].v = ac_build_gep0(&ctx->ac, vt, ctx->ac.i32_0); } for (unsigned i = 0; i < info->num_outputs; i++) { @@ -2157,7 +2149,7 @@ void gfx10_ngg_gs_build_end(struct si_shader_context *ctx) continue; LLVMValueRef idx = LLVMConstInt(ctx->ac.i32, 4 * i + comp, false); - tmp = ac_build_gep0(&ctx->ac, vtxptr[vert].t, vtxptr[vert].v, idx); + tmp = ac_build_gep0(&ctx->ac, vtxptr[vert], idx); pos[vert][comp] = LLVMBuildLoad2(builder, ac_build_gep0_type(vtxptr[vert].t, idx), tmp, ""); @@ -2229,7 +2221,7 @@ void gfx10_ngg_gs_build_end(struct si_shader_context *ctx) vertlive_scan.enable_reduce = true; vertlive_scan.enable_exclusive = true; vertlive_scan.src = vertlive; - vertlive_scan.scratch = ac_build_gep0(&ctx->ac, ctx->gs_ngg_scratch.t, ctx->gs_ngg_scratch.v, ctx->ac.i32_0); + vertlive_scan.scratch = ac_build_gep0(&ctx->ac, ctx->gs_ngg_scratch, ctx->ac.i32_0); vertlive_scan.waveidx = get_wave_id_in_tg(ctx); vertlive_scan.numwaves = get_tgsize(ctx); vertlive_scan.maxwaves = DIV_ROUND_UP(256, ctx->ac.wave_size); diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm.c b/src/gallium/drivers/radeonsi/si_shader_llvm.c index e0d6cfaa713..c4213ff27ab 100644 --- a/src/gallium/drivers/radeonsi/si_shader_llvm.c +++ b/src/gallium/drivers/radeonsi/si_shader_llvm.c @@ -765,9 +765,7 @@ static LLVMValueRef si_llvm_load_intrinsic(struct ac_shader_abi *abi, nir_intrin case nir_intrinsic_load_tess_level_outer_default: case nir_intrinsic_load_tess_level_inner_default: { LLVMValueRef slot = LLVMConstInt(ctx->ac.i32, SI_HS_CONST_DEFAULT_TESS_LEVELS, 0); - LLVMValueRef buf = ac_get_arg(&ctx->ac, ctx->internal_bindings); - LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->internal_bindings); - buf = ac_build_load_to_sgpr(&ctx->ac, type, buf, slot); + LLVMValueRef buf = ac_build_load_to_sgpr(&ctx->ac, ac_get_ptr_arg(&ctx->ac, &ctx->args, ctx->internal_bindings), slot); int offset = op == nir_intrinsic_load_tess_level_inner_default ? 4 : 0; LLVMValueRef val[4]; @@ -816,15 +814,15 @@ static LLVMValueRef si_llvm_load_intrinsic(struct ac_shader_abi *abi, nir_intrin case nir_intrinsic_load_clip_half_line_width_amd: { LLVMValueRef ptr = ac_get_arg(&ctx->ac, ctx->small_prim_cull_info); - return ac_build_load_to_sgpr(&ctx->ac, ctx->ac.v2f32, ptr, LLVMConstInt(ctx->ac.i32, 4, 0)); + return ac_build_load_to_sgpr(&ctx->ac, + (struct ac_llvm_pointer) { .t = ctx->ac.v2f32, .v = ptr }, LLVMConstInt(ctx->ac.i32, 4, 0)); } case nir_intrinsic_load_viewport_xy_scale_and_offset: { bool prim_is_lines = ctx->shader->key.ge.opt.ngg_culling & SI_NGG_CULL_LINES; - LLVMValueRef ptr = ac_get_arg(&ctx->ac, ctx->small_prim_cull_info); - LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->small_prim_cull_info); + struct ac_llvm_pointer ptr = ac_get_ptr_arg(&ctx->ac, &ctx->args, ctx->small_prim_cull_info); LLVMValueRef terms = - ac_build_load_to_sgpr(&ctx->ac, type, ptr, prim_is_lines ? ctx->ac.i32_1 : ctx->ac.i32_0); + ac_build_load_to_sgpr(&ctx->ac, ptr, prim_is_lines ? ctx->ac.i32_1 : ctx->ac.i32_0); return LLVMBuildBitCast(ctx->ac.builder, terms, ctx->ac.v4f32, ""); } @@ -878,10 +876,9 @@ static LLVMValueRef si_llvm_load_intrinsic(struct ac_shader_abi *abi, nir_intrin static LLVMValueRef si_llvm_load_user_clip_plane(struct ac_shader_abi *abi, unsigned ucp_id) { struct si_shader_context *ctx = si_shader_context_from_abi(abi); - LLVMValueRef ptr = ac_get_arg(&ctx->ac, ctx->internal_bindings); - LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->internal_bindings); + struct ac_llvm_pointer ptr = ac_get_ptr_arg(&ctx->ac, &ctx->args, ctx->internal_bindings); LLVMValueRef constbuf_index = LLVMConstInt(ctx->ac.i32, SI_VS_CONST_CLIP_PLANES, 0); - LLVMValueRef const_resource = ac_build_load_to_sgpr(&ctx->ac, type, ptr, constbuf_index); + LLVMValueRef const_resource = ac_build_load_to_sgpr(&ctx->ac, ptr, constbuf_index); LLVMValueRef addr = LLVMConstInt(ctx->ac.i32, ucp_id * 16, 0); return ac_build_buffer_load(&ctx->ac, const_resource, 4, NULL, addr, NULL, ctx->ac.f32, 0, true, true); @@ -890,11 +887,10 @@ static LLVMValueRef si_llvm_load_user_clip_plane(struct ac_shader_abi *abi, unsi static LLVMValueRef si_llvm_load_streamout_buffer(struct ac_shader_abi *abi, unsigned buffer) { struct si_shader_context *ctx = si_shader_context_from_abi(abi); - LLVMValueRef buf_ptr = ac_get_arg(&ctx->ac, ctx->internal_bindings); - LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->internal_bindings); + struct ac_llvm_pointer buf_ptr = ac_get_ptr_arg(&ctx->ac, &ctx->args, ctx->internal_bindings); return ac_build_load_to_sgpr( - &ctx->ac, type, buf_ptr, LLVMConstInt(ctx->ac.i32, SI_VS_STREAMOUT_BUF0 + buffer, false)); + &ctx->ac, buf_ptr, LLVMConstInt(ctx->ac.i32, SI_VS_STREAMOUT_BUF0 + buffer, false)); } bool si_llvm_translate_nir(struct si_shader_context *ctx, struct si_shader *shader, @@ -930,11 +926,10 @@ bool si_llvm_translate_nir(struct si_shader_context *ctx, struct si_shader *shad /* preload instance_divisor_constbuf to be used for input load after culling */ if (ctx->shader->key.ge.opt.ngg_culling && ctx->shader->key.ge.part.vs.prolog.instance_divisor_is_fetched) { - LLVMValueRef buf = ac_get_arg(&ctx->ac, ctx->internal_bindings); - LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->internal_bindings); + struct ac_llvm_pointer buf = ac_get_ptr_arg(&ctx->ac, &ctx->args, ctx->internal_bindings); ctx->instance_divisor_constbuf = ac_build_load_to_sgpr( - &ctx->ac, type, buf, LLVMConstInt(ctx->ac.i32, SI_VS_CONST_INSTANCE_DIVISORS, 0)); + &ctx->ac, buf, LLVMConstInt(ctx->ac.i32, SI_VS_CONST_INSTANCE_DIVISORS, 0)); } break; diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm_gs.c b/src/gallium/drivers/radeonsi/si_shader_llvm_gs.c index 60c028761ae..0daea376085 100644 --- a/src/gallium/drivers/radeonsi/si_shader_llvm_gs.c +++ b/src/gallium/drivers/radeonsi/si_shader_llvm_gs.c @@ -98,10 +98,7 @@ static LLVMValueRef si_get_gs_wave_id(struct si_shader_context *ctx) static LLVMValueRef ngg_get_emulated_counters_buf(struct si_shader_context *ctx) { - LLVMValueRef buf_ptr = ac_get_arg(&ctx->ac, ctx->internal_bindings); - LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->internal_bindings); - - return ac_build_load_to_sgpr(&ctx->ac, type, buf_ptr, + return ac_build_load_to_sgpr(&ctx->ac, ac_get_ptr_arg(&ctx->ac, &ctx->args, ctx->internal_bindings), LLVMConstInt(ctx->ac.i32, SI_GS_QUERY_EMULATED_COUNTERS_BUF, false)); } @@ -263,10 +260,9 @@ void si_preload_esgs_ring(struct si_shader_context *ctx) if (ctx->screen->info.gfx_level <= GFX8) { LLVMValueRef offset = LLVMConstInt(ctx->ac.i32, SI_RING_ESGS, 0); - LLVMValueRef buf_ptr = ac_get_arg(&ctx->ac, ctx->internal_bindings); - LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->internal_bindings); - ctx->esgs_ring = ac_build_load_to_sgpr(&ctx->ac, type, buf_ptr, offset); + ctx->esgs_ring = ac_build_load_to_sgpr(&ctx->ac, + ac_get_ptr_arg(&ctx->ac, &ctx->args, ctx->internal_bindings), offset); if (ctx->stage != MESA_SHADER_GEOMETRY) { LLVMValueRef desc1 = LLVMBuildExtractElement(builder, ctx->esgs_ring, ctx->ac.i32_1, ""); @@ -307,9 +303,8 @@ void si_preload_gs_rings(struct si_shader_context *ctx) const struct si_shader_selector *sel = ctx->shader->selector; LLVMBuilderRef builder = ctx->ac.builder; LLVMValueRef offset = LLVMConstInt(ctx->ac.i32, SI_RING_GSVS, 0); - LLVMValueRef buf_ptr = ac_get_arg(&ctx->ac, ctx->internal_bindings); - LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->internal_bindings); - LLVMValueRef base_ring = ac_build_load_to_sgpr(&ctx->ac, type, buf_ptr, offset); + LLVMValueRef base_ring = ac_build_load_to_sgpr(&ctx->ac, + ac_get_ptr_arg(&ctx->ac, &ctx->args, ctx->internal_bindings), offset); /* The conceptual layout of the GSVS ring is * v0c0 .. vLv0 v0c1 .. vLc1 .. @@ -435,10 +430,9 @@ struct si_shader *si_generate_gs_copy_shader(struct si_screen *sscreen, /* Build the main function. */ si_llvm_create_main_func(&ctx, false); - LLVMValueRef buf_ptr = ac_get_arg(&ctx.ac, ctx.internal_bindings); - LLVMTypeRef type = ac_get_arg_pointee_type(&ctx.ac, &ctx.args, ctx.internal_bindings); ctx.gsvs_ring[0] = - ac_build_load_to_sgpr(&ctx.ac, type, buf_ptr, LLVMConstInt(ctx.ac.i32, SI_RING_GSVS, 0)); + ac_build_load_to_sgpr(&ctx.ac, + ac_get_ptr_arg(&ctx.ac, &ctx.args, ctx.internal_bindings), LLVMConstInt(ctx.ac.i32, SI_RING_GSVS, 0)); LLVMValueRef voffset = LLVMBuildMul(ctx.ac.builder, ctx.abi.vertex_id, LLVMConstInt(ctx.ac.i32, 4, 0), ""); diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm_ps.c b/src/gallium/drivers/radeonsi/si_shader_llvm_ps.c index c7660a3caa0..218a3c2a300 100644 --- a/src/gallium/drivers/radeonsi/si_shader_llvm_ps.c +++ b/src/gallium/drivers/radeonsi/si_shader_llvm_ps.c @@ -34,10 +34,9 @@ LLVMValueRef si_get_sample_id(struct si_shader_context *ctx) static LLVMValueRef load_sample_position(struct ac_shader_abi *abi, LLVMValueRef sample_id) { struct si_shader_context *ctx = si_shader_context_from_abi(abi); - LLVMValueRef desc = ac_get_arg(&ctx->ac, ctx->internal_bindings); LLVMValueRef buf_index = LLVMConstInt(ctx->ac.i32, SI_PS_CONST_SAMPLE_POSITIONS, 0); - LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->internal_bindings); - LLVMValueRef resource = ac_build_load_to_sgpr(&ctx->ac, type, desc, buf_index); + LLVMValueRef resource = ac_build_load_to_sgpr( + &ctx->ac, ac_get_ptr_arg(&ctx->ac, &ctx->args, ctx->internal_bindings), buf_index); /* offset = sample_id * 8 (8 = 2 floats containing samplepos.xy) */ LLVMValueRef offset0 = @@ -69,8 +68,9 @@ static LLVMValueRef si_nir_emit_fbfetch(struct ac_shader_abi *abi) ptr = ac_get_arg(&ctx->ac, ctx->internal_bindings); ptr = LLVMBuildPointerCast(ctx->ac.builder, ptr, ac_array_in_const32_addr_space(ctx->ac.v8i32), ""); - image = - ac_build_load_to_sgpr(&ctx->ac, ctx->ac.v8i32, ptr, LLVMConstInt(ctx->ac.i32, SI_PS_IMAGE_COLORBUF0 / 2, 0)); + struct ac_llvm_pointer desc = { .v = ptr, .t = ctx->ac.v8i32 }; + + image = ac_build_load_to_sgpr(&ctx->ac, desc, LLVMConstInt(ctx->ac.i32, SI_PS_IMAGE_COLORBUF0 / 2, 0)); unsigned chan = 0; @@ -90,8 +90,7 @@ static LLVMValueRef si_nir_emit_fbfetch(struct ac_shader_abi *abi) ctx->shader->key.ps.mono.fbfetch_msaa && !(ctx->screen->debug_flags & DBG(NO_FMASK))) { - fmask = ac_build_load_to_sgpr(&ctx->ac, ctx->ac.v8i32, ptr, - LLVMConstInt(ctx->ac.i32, SI_PS_IMAGE_COLORBUF0_FMASK / 2, 0)); + fmask = ac_build_load_to_sgpr(&ctx->ac, desc, LLVMConstInt(ctx->ac.i32, SI_PS_IMAGE_COLORBUF0_FMASK / 2, 0)); ac_apply_fmask_to_sample(&ctx->ac, fmask, args.coords, ctx->shader->key.ps.mono.fbfetch_layered); @@ -550,7 +549,7 @@ static void si_llvm_emit_polygon_stipple(struct si_shader_context *ctx, /* Load the buffer descriptor. */ slot = LLVMConstInt(ctx->ac.i32, SI_PS_CONST_POLY_STIPPLE, 0); - desc = ac_build_load_to_sgpr(&ctx->ac, ctx->ac.v4i32, param_internal_bindings, slot); + desc = ac_build_load_to_sgpr(&ctx->ac, (struct ac_llvm_pointer) { .t = ctx->ac.v4i32, .v = param_internal_bindings }, slot); /* The stipple pattern is 32x32, each row has 32 bits. */ offset = LLVMBuildMul(builder, address[1], LLVMConstInt(ctx->ac.i32, 4, 0), ""); diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm_resources.c b/src/gallium/drivers/radeonsi/si_shader_llvm_resources.c index 23ce4f0e5c0..7900ba9da86 100644 --- a/src/gallium/drivers/radeonsi/si_shader_llvm_resources.c +++ b/src/gallium/drivers/radeonsi/si_shader_llvm_resources.c @@ -94,8 +94,6 @@ static LLVMValueRef load_ubo(struct ac_shader_abi *abi, LLVMValueRef index) struct si_shader_context *ctx = si_shader_context_from_abi(abi); struct si_shader_selector *sel = ctx->shader->selector; - LLVMValueRef ptr = ac_get_arg(&ctx->ac, ctx->const_and_shader_buffers); - if (sel->info.base.num_ubos == 1 && sel->info.base.num_ssbos == 0) { return load_const_buffer_desc_fast_path(ctx); } @@ -105,8 +103,7 @@ static LLVMValueRef load_ubo(struct ac_shader_abi *abi, LLVMValueRef index) LLVMBuildAdd(ctx->ac.builder, index, LLVMConstInt(ctx->ac.i32, SI_NUM_SHADER_BUFFERS, 0), ""); return ac_build_load_to_sgpr(&ctx->ac, - ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->const_and_shader_buffers), - ptr, + ac_get_ptr_arg(&ctx->ac, &ctx->args, ctx->const_and_shader_buffers), index); } @@ -119,14 +116,13 @@ static LLVMValueRef load_ssbo(struct ac_shader_abi *abi, LLVMValueRef index, boo LLVMConstIntGetZExtValue(index) < ctx->shader->selector->cs_num_shaderbufs_in_user_sgprs) return ac_get_arg(&ctx->ac, ctx->cs_shaderbuf[LLVMConstIntGetZExtValue(index)]); - LLVMValueRef rsrc_ptr = ac_get_arg(&ctx->ac, ctx->const_and_shader_buffers); index = si_llvm_bound_index(ctx, index, ctx->num_shader_buffers); index = LLVMBuildSub(ctx->ac.builder, LLVMConstInt(ctx->ac.i32, SI_NUM_SHADER_BUFFERS - 1, 0), index, ""); return ac_build_load_to_sgpr(&ctx->ac, - ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->const_and_shader_buffers), - rsrc_ptr, index); + ac_get_ptr_arg(&ctx->ac, &ctx->args, ctx->const_and_shader_buffers), + index); } /** @@ -181,25 +177,23 @@ static LLVMValueRef fixup_image_desc(struct si_shader_context *ctx, LLVMValueRef /* AC_DESC_FMASK is handled exactly like AC_DESC_IMAGE. The caller should * adjust "index" to point to FMASK. */ -static LLVMValueRef si_load_image_desc(struct si_shader_context *ctx, LLVMTypeRef type, LLVMValueRef list, +static LLVMValueRef si_load_image_desc(struct si_shader_context *ctx, struct ac_llvm_pointer list, LLVMValueRef index, enum ac_descriptor_type desc_type, bool uses_store, bool bindless) { - LLVMBuilderRef builder = ctx->ac.builder; LLVMValueRef rsrc; if (desc_type == AC_DESC_BUFFER) { index = ac_build_imad(&ctx->ac, index, LLVMConstInt(ctx->ac.i32, 2, 0), ctx->ac.i32_1); - list = LLVMBuildPointerCast(builder, list, ac_array_in_const32_addr_space(ctx->ac.v4i32), ""); - type = ctx->ac.v4i32; + list.pointee_type = ctx->ac.v4i32; } else { assert(desc_type == AC_DESC_IMAGE || desc_type == AC_DESC_FMASK); } if (bindless) - rsrc = ac_build_load_to_sgpr_uint_wraparound(&ctx->ac, type, list, index); + rsrc = ac_build_load_to_sgpr_uint_wraparound(&ctx->ac, list, index); else - rsrc = ac_build_load_to_sgpr(&ctx->ac, type, list, index); + rsrc = ac_build_load_to_sgpr(&ctx->ac, list, index); if (desc_type == AC_DESC_IMAGE) rsrc = fixup_image_desc(ctx, rsrc, uses_store); @@ -210,8 +204,7 @@ static LLVMValueRef si_load_image_desc(struct si_shader_context *ctx, LLVMTypeRe /** * Load an image view, fmask view. or sampler state descriptor. */ -static LLVMValueRef si_load_sampler_desc(struct si_shader_context *ctx, LLVMTypeRef list_type, - LLVMValueRef list, +static LLVMValueRef si_load_sampler_desc(struct si_shader_context *ctx, struct ac_llvm_pointer list, LLVMValueRef index, enum ac_descriptor_type type) { LLVMBuilderRef builder = ctx->ac.builder; @@ -224,8 +217,7 @@ static LLVMValueRef si_load_sampler_desc(struct si_shader_context *ctx, LLVMType case AC_DESC_BUFFER: /* The buffer is in [4:7]. */ index = ac_build_imad(&ctx->ac, index, LLVMConstInt(ctx->ac.i32, 4, 0), ctx->ac.i32_1); - list = LLVMBuildPointerCast(builder, list, ac_array_in_const32_addr_space(ctx->ac.v4i32), ""); - list_type = ctx->ac.v4i32; + list.pointee_type = ctx->ac.v4i32; break; case AC_DESC_FMASK: /* The FMASK is at [8:15]. */ @@ -236,8 +228,7 @@ static LLVMValueRef si_load_sampler_desc(struct si_shader_context *ctx, LLVMType /* The sampler state is at [12:15]. */ index = ac_build_imad(&ctx->ac, index, LLVMConstInt(ctx->ac.i32, 4, 0), LLVMConstInt(ctx->ac.i32, 3, 0)); - list = LLVMBuildPointerCast(builder, list, ac_array_in_const32_addr_space(ctx->ac.v4i32), ""); - list_type = ctx->ac.v4i32; + list.pointee_type = ctx->ac.v4i32; break; case AC_DESC_PLANE_0: case AC_DESC_PLANE_1: @@ -248,7 +239,7 @@ static LLVMValueRef si_load_sampler_desc(struct si_shader_context *ctx, LLVMType unreachable("Plane descriptor requested in radeonsi."); } - return ac_build_load_to_sgpr(&ctx->ac, list_type, list, index); + return ac_build_load_to_sgpr(&ctx->ac, list, index); } static LLVMValueRef si_nir_load_sampler_desc(struct ac_shader_abi *abi, unsigned descriptor_set, @@ -265,8 +256,7 @@ static LLVMValueRef si_nir_load_sampler_desc(struct ac_shader_abi *abi, unsigned assert(desc_type <= AC_DESC_BUFFER); if (bindless) { - LLVMValueRef list = ac_get_arg(&ctx->ac, ctx->bindless_samplers_and_images); - LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->bindless_samplers_and_images); + struct ac_llvm_pointer list = ac_get_ptr_arg(&ctx->ac, &ctx->args, ctx->bindless_samplers_and_images); /* dynamic_index is the bindless handle */ if (image) { @@ -278,7 +268,7 @@ static LLVMValueRef si_nir_load_sampler_desc(struct ac_shader_abi *abi, unsigned dynamic_index = LLVMBuildAdd(ctx->ac.builder, dynamic_index, ctx->ac.i32_1, ""); } - return si_load_image_desc(ctx, type, list, dynamic_index, desc_type, write, true); + return si_load_image_desc(ctx, list, dynamic_index, desc_type, write, true); } /* Since bindless handle arithmetic can contain an unsigned integer @@ -288,8 +278,8 @@ static LLVMValueRef si_nir_load_sampler_desc(struct ac_shader_abi *abi, unsigned */ dynamic_index = LLVMBuildMul(ctx->ac.builder, dynamic_index, LLVMConstInt(ctx->ac.i64, 2, 0), ""); - list = ac_build_pointer_add(&ctx->ac, ctx->ac.v8i32, list, dynamic_index); - return si_load_sampler_desc(ctx, type, list, ctx->ac.i32_0, desc_type); + list.v = ac_build_pointer_add(&ctx->ac, ctx->ac.v8i32, list.v, dynamic_index); + return si_load_sampler_desc(ctx, list, ctx->ac.i32_0, desc_type); } unsigned num_slots = image ? ctx->num_images : ctx->num_samplers; @@ -298,8 +288,7 @@ static LLVMValueRef si_nir_load_sampler_desc(struct ac_shader_abi *abi, unsigned if (const_index >= num_slots) const_index = base_index; - LLVMValueRef list = ac_get_arg(&ctx->ac, ctx->samplers_and_images); - LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->samplers_and_images); + struct ac_llvm_pointer list = ac_get_ptr_arg(&ctx->ac, &ctx->args, ctx->samplers_and_images); LLVMValueRef index = LLVMConstInt(ctx->ac.i32, const_index, false); if (dynamic_index) { @@ -336,12 +325,12 @@ static LLVMValueRef si_nir_load_sampler_desc(struct ac_shader_abi *abi, unsigned } index = LLVMBuildSub(ctx->ac.builder, LLVMConstInt(ctx->ac.i32, SI_NUM_IMAGE_SLOTS - 1, 0), index, ""); - return si_load_image_desc(ctx, type, list, index, desc_type, write, false); + return si_load_image_desc(ctx, list, index, desc_type, write, false); } index = LLVMBuildAdd(ctx->ac.builder, index, LLVMConstInt(ctx->ac.i32, SI_NUM_IMAGE_SLOTS / 2, 0), ""); - return si_load_sampler_desc(ctx, type, list, index, desc_type); + return si_load_sampler_desc(ctx, list, index, desc_type); } void si_llvm_init_resource_callbacks(struct si_shader_context *ctx) diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm_vs.c b/src/gallium/drivers/radeonsi/si_shader_llvm_vs.c index d11ad9ffef6..950daf49feb 100644 --- a/src/gallium/drivers/radeonsi/si_shader_llvm_vs.c +++ b/src/gallium/drivers/radeonsi/si_shader_llvm_vs.c @@ -168,9 +168,9 @@ static void load_input_vs(struct si_shader_context *ctx, unsigned input_index, L vb_desc = ac_get_arg(&ctx->ac, ctx->vb_descriptors[input_index]); } else { unsigned index = input_index - num_vbos_in_user_sgprs; - LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->args.vertex_buffers); - vb_desc = ac_build_load_to_sgpr(&ctx->ac, type, ac_get_arg(&ctx->ac, ctx->args.vertex_buffers), - LLVMConstInt(ctx->ac.i32, index, 0)); + vb_desc = ac_build_load_to_sgpr( + &ctx->ac, ac_get_ptr_arg(&ctx->ac, &ctx->args, ctx->args.vertex_buffers), + LLVMConstInt(ctx->ac.i32, index, 0)); } if (ctx->abi.vertex_id_replaced) { @@ -409,8 +409,7 @@ void si_llvm_emit_streamout(struct si_shader_context *ctx, struct si_shader_outp * enabled buffer. */ LLVMValueRef so_write_offset[4] = {}; LLVMValueRef so_buffers[4]; - LLVMValueRef buf_ptr = ac_get_arg(&ctx->ac, ctx->internal_bindings); - LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->internal_bindings); + struct ac_llvm_pointer arg = ac_get_ptr_arg(&ctx->ac, &ctx->args, ctx->internal_bindings); for (i = 0; i < 4; i++) { if (!so->stride[i]) @@ -418,7 +417,7 @@ void si_llvm_emit_streamout(struct si_shader_context *ctx, struct si_shader_outp LLVMValueRef offset = LLVMConstInt(ctx->ac.i32, SI_VS_STREAMOUT_BUF0 + i, 0); - so_buffers[i] = ac_build_load_to_sgpr(&ctx->ac, type, buf_ptr, offset); + so_buffers[i] = ac_build_load_to_sgpr(&ctx->ac, arg, offset); LLVMValueRef so_offset = ac_get_arg(&ctx->ac, ctx->args.streamout_offset[i]); so_offset = LLVMBuildMul(builder, so_offset, LLVMConstInt(ctx->ac.i32, 4, 0), ""); @@ -451,10 +450,9 @@ void si_llvm_clipvertex_to_clipdist(struct si_shader_context *ctx, unsigned chan; unsigned const_chan; LLVMValueRef base_elt; - LLVMValueRef ptr = ac_get_arg(&ctx->ac, ctx->internal_bindings); - LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->internal_bindings); LLVMValueRef constbuf_index = LLVMConstInt(ctx->ac.i32, SI_VS_CONST_CLIP_PLANES, 0); - LLVMValueRef const_resource = ac_build_load_to_sgpr(&ctx->ac, type, ptr, constbuf_index); + LLVMValueRef const_resource = ac_build_load_to_sgpr( + &ctx->ac, ac_get_ptr_arg(&ctx->ac, &ctx->args, ctx->internal_bindings), constbuf_index); unsigned clipdist_mask = ctx->shader->selector->info.clipdist_mask & ~ctx->shader->key.ge.opt.kill_clip_distances; @@ -815,11 +813,9 @@ void si_llvm_build_vs_exports(struct si_shader_context *ctx, LLVMValueRef num_ex /* Get the attribute ring address and descriptor. */ LLVMValueRef attr_address; if (ctx->stage == MESA_SHADER_VERTEX && shader->selector->info.base.vs.blit_sgprs_amd) { - LLVMValueRef ptr = - LLVMBuildPointerCast(ctx->ac.builder, - ac_get_arg(&ctx->ac, ctx->internal_bindings), - LLVMPointerType(ctx->ac.i32, AC_ADDR_SPACE_CONST_32BIT), ""); - attr_address = ac_build_load_to_sgpr(&ctx->ac, ctx->ac.i32, ptr, + struct ac_llvm_pointer ring_ptr = ac_get_ptr_arg(&ctx->ac, &ctx->args, ctx->internal_bindings); + ring_ptr.pointee_type = ctx->ac.i32; + attr_address = ac_build_load_to_sgpr(&ctx->ac, ring_ptr, LLVMConstInt(ctx->ac.i32, SI_GS_ATTRIBUTE_RING * 4, 0)); } else { attr_address = ac_get_arg(&ctx->ac, ctx->gs_attr_address); @@ -1039,7 +1035,8 @@ void si_llvm_build_vs_prolog(struct si_shader_context *ctx, union si_shader_part if (key->vs_prolog.states.instance_divisor_is_fetched) { LLVMValueRef list = si_prolog_get_internal_bindings(ctx); LLVMValueRef buf_index = LLVMConstInt(ctx->ac.i32, SI_VS_CONST_INSTANCE_DIVISORS, 0); - instance_divisor_constbuf = ac_build_load_to_sgpr(&ctx->ac, ctx->ac.v4i32, list, buf_index); + instance_divisor_constbuf = ac_build_load_to_sgpr(&ctx->ac, + (struct ac_llvm_pointer) { .v = list, .t = ctx->ac.v4i32 }, buf_index); } for (i = 0; i < key->vs_prolog.num_inputs; i++) {