Mesa (main): amd/llvm: Transition to LLVM "opaque pointers"
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sat Apr 9 17:19:56 UTC 2022
Module: Mesa
Branch: main
Commit: 279eea5bda2444fdce21744b972dad5016f0f366
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=279eea5bda2444fdce21744b972dad5016f0f366
Author: Mihai Preda <mhpreda at gmail.com>
Date: Mon Apr 4 10:07:49 2022 +0300
amd/llvm: Transition to LLVM "opaque pointers"
For context, see LLVM opaque pointers:
https://llvm.org/docs/OpaquePointers.html
https://llvm.org/devmtg/2015-10/slides/Blaikie-OpaquePointerTypes.pdf
This fixes the deprecation warnings in src/amd/llvm only.
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15572>
---
src/amd/llvm/ac_llvm_build.c | 65 +++++++++++++++++++-------------------
src/amd/llvm/ac_llvm_build.h | 2 +-
src/amd/llvm/ac_nir_to_llvm.c | 72 +++++++++++++++++++++++--------------------
src/amd/llvm/ac_nir_to_llvm.h | 2 +-
4 files changed, 71 insertions(+), 70 deletions(-)
diff --git a/src/amd/llvm/ac_llvm_build.c b/src/amd/llvm/ac_llvm_build.c
index 4fcd8f4da7a..33836b6d18e 100644
--- a/src/amd/llvm/ac_llvm_build.c
+++ b/src/amd/llvm/ac_llvm_build.c
@@ -294,21 +294,20 @@ LLVMValueRef ac_build_intrinsic(struct ac_llvm_context *ctx, const char *name,
LLVMTypeRef return_type, LLVMValueRef *params, unsigned param_count,
unsigned attrib_mask)
{
- LLVMValueRef function, call;
+ LLVMValueRef call;
bool set_callsite_attrs = !(attrib_mask & AC_FUNC_ATTR_LEGACY);
- function = LLVMGetNamedFunction(ctx->module, name);
- if (!function) {
- LLVMTypeRef param_types[32], function_type;
- unsigned i;
+ LLVMTypeRef param_types[32];
+ assert(param_count <= 32);
+ for (unsigned i = 0; i < param_count; ++i) {
+ assert(params[i]);
+ param_types[i] = LLVMTypeOf(params[i]);
+ }
- assert(param_count <= 32);
+ LLVMTypeRef function_type = LLVMFunctionType(return_type, param_types, param_count, 0);
+ LLVMValueRef function = LLVMGetNamedFunction(ctx->module, name);
- for (i = 0; i < param_count; ++i) {
- assert(params[i]);
- param_types[i] = LLVMTypeOf(params[i]);
- }
- function_type = LLVMFunctionType(return_type, param_types, param_count, 0);
+ if (!function) {
function = LLVMAddFunction(ctx->module, name, function_type);
LLVMSetFunctionCallConv(function, LLVMCCallConv);
@@ -318,7 +317,7 @@ LLVMValueRef ac_build_intrinsic(struct ac_llvm_context *ctx, const char *name,
ac_add_func_attributes(ctx->context, function, attrib_mask);
}
- call = LLVMBuildCall(ctx->builder, function, params, param_count, "");
+ call = LLVMBuildCall2(ctx->builder, function_type, function, params, param_count, "");
if (set_callsite_attrs)
ac_add_func_attributes(ctx->context, call, attrib_mask);
return call;
@@ -420,27 +419,27 @@ void ac_build_optimization_barrier(struct ac_llvm_context *ctx, LLVMValueRef *pg
if (!pgpr) {
LLVMTypeRef ftype = LLVMFunctionType(ctx->voidt, NULL, 0, false);
LLVMValueRef inlineasm = LLVMConstInlineAsm(ftype, code, "", true, false);
- LLVMBuildCall(builder, inlineasm, NULL, 0, "");
+ LLVMBuildCall2(builder, ftype, inlineasm, NULL, 0, "");
} else if (LLVMTypeOf(*pgpr) == ctx->i32) {
/* Simple version for i32 that allows the caller to set LLVM metadata on the call
* instruction. */
LLVMTypeRef ftype = LLVMFunctionType(ctx->i32, &ctx->i32, 1, false);
LLVMValueRef inlineasm = LLVMConstInlineAsm(ftype, code, constraint, true, false);
- *pgpr = LLVMBuildCall(builder, inlineasm, pgpr, 1, "");
+ *pgpr = LLVMBuildCall2(builder, ftype, inlineasm, pgpr, 1, "");
} else if (LLVMTypeOf(*pgpr) == ctx->i16) {
/* Simple version for i16 that allows the caller to set LLVM metadata on the call
* instruction. */
LLVMTypeRef ftype = LLVMFunctionType(ctx->i16, &ctx->i16, 1, false);
LLVMValueRef inlineasm = LLVMConstInlineAsm(ftype, code, constraint, true, false);
- *pgpr = LLVMBuildCall(builder, inlineasm, pgpr, 1, "");
+ *pgpr = LLVMBuildCall2(builder, ftype, inlineasm, pgpr, 1, "");
} else if (LLVMGetTypeKind(LLVMTypeOf(*pgpr)) == LLVMPointerTypeKind) {
LLVMTypeRef type = LLVMTypeOf(*pgpr);
LLVMTypeRef ftype = LLVMFunctionType(type, &type, 1, false);
LLVMValueRef inlineasm = LLVMConstInlineAsm(ftype, code, constraint, true, false);
- *pgpr = LLVMBuildCall(builder, inlineasm, pgpr, 1, "");
+ *pgpr = LLVMBuildCall2(builder, ftype, inlineasm, pgpr, 1, "");
} else {
LLVMTypeRef ftype = LLVMFunctionType(ctx->i32, &ctx->i32, 1, false);
LLVMValueRef inlineasm = LLVMConstInlineAsm(ftype, code, constraint, true, false);
@@ -461,7 +460,7 @@ void ac_build_optimization_barrier(struct ac_llvm_context *ctx, LLVMValueRef *pg
vgpr = LLVMBuildBitCast(builder, vgpr, LLVMVectorType(ctx->i32, vgpr_size / 4), "");
vgpr0 = LLVMBuildExtractElement(builder, vgpr, ctx->i32_0, "");
- vgpr0 = LLVMBuildCall(builder, inlineasm, &vgpr0, 1, "");
+ vgpr0 = LLVMBuildCall2(builder, ftype, inlineasm, &vgpr0, 1, "");
vgpr = LLVMBuildInsertElement(builder, vgpr, vgpr0, ctx->i32_0, "");
vgpr = LLVMBuildBitCast(builder, vgpr, vgpr_type, "");
@@ -574,7 +573,7 @@ LLVMValueRef ac_build_varying_gather_values(struct ac_llvm_context *ctx, LLVMVal
}
LLVMValueRef ac_build_gather_values_extended(struct ac_llvm_context *ctx, LLVMValueRef *values,
- unsigned value_count, unsigned value_stride, bool load,
+ unsigned value_count, unsigned value_stride,
bool always_vector)
{
LLVMBuilderRef builder = ctx->builder;
@@ -582,16 +581,12 @@ LLVMValueRef ac_build_gather_values_extended(struct ac_llvm_context *ctx, LLVMVa
unsigned i;
if (value_count == 1 && !always_vector) {
- if (load)
- return LLVMBuildLoad(builder, values[0], "");
return values[0];
} else if (!value_count)
unreachable("value_count is 0");
for (i = 0; i < value_count; i++) {
LLVMValueRef value = values[i * value_stride];
- if (load)
- value = LLVMBuildLoad(builder, value, "");
if (!i)
vec = LLVMGetUndef(LLVMVectorType(LLVMTypeOf(value), value_count));
@@ -604,7 +599,7 @@ LLVMValueRef ac_build_gather_values_extended(struct ac_llvm_context *ctx, LLVMVa
LLVMValueRef ac_build_gather_values(struct ac_llvm_context *ctx, LLVMValueRef *values,
unsigned value_count)
{
- return ac_build_gather_values_extended(ctx, values, value_count, 1, false, false);
+ return ac_build_gather_values_extended(ctx, values, value_count, 1, false);
}
LLVMValueRef ac_build_concat(struct ac_llvm_context *ctx, LLVMValueRef a, LLVMValueRef b)
@@ -1031,8 +1026,8 @@ LLVMValueRef ac_build_gep0(struct ac_llvm_context *ctx, LLVMValueRef base_ptr, L
LLVMValueRef ac_build_pointer_add(struct ac_llvm_context *ctx, LLVMValueRef ptr, LLVMValueRef index)
{
- return LLVMBuildPointerCast(ctx->builder, LLVMBuildGEP(ctx->builder, ptr, &index, 1, ""),
- LLVMTypeOf(ptr), "");
+ LLVMValueRef offset_ptr = LLVMBuildGEP(ctx->builder, ptr, &index, 1, "");
+ return LLVMBuildPointerCast(ctx->builder, offset_ptr, LLVMTypeOf(ptr), "");
}
void ac_build_indexed_store(struct ac_llvm_context *ctx, LLVMValueRef base_ptr, LLVMValueRef index,
@@ -1315,7 +1310,7 @@ LLVMValueRef ac_build_buffer_load_format(struct ac_llvm_context *ctx, LLVMValueR
LLVMValueRef args[] = {ac_build_gather_values(ctx, addr_comp, 2),
LLVMBuildBitCast(ctx->builder, rsrc, ctx->v4i32, "")};
- LLVMValueRef res = LLVMBuildCall(ctx->builder, inlineasm, args, 2, "");
+ LLVMValueRef res = LLVMBuildCall2(ctx->builder, calltype, inlineasm, args, 2, "");
return ac_build_concat(ctx, ac_trim_vector(ctx, res, num_channels),
ac_llvm_extract_elem(ctx, res, 4));
@@ -2359,7 +2354,7 @@ LLVMValueRef ac_build_cvt_pknorm_i16_f16(struct ac_llvm_context *ctx,
LLVMValueRef code = LLVMConstInlineAsm(calltype,
"v_cvt_pknorm_i16_f16 $0, $1, $2", "=v,v,v",
false, false);
- return LLVMBuildCall(ctx->builder, code, args, 2, "");
+ return LLVMBuildCall2(ctx->builder, calltype, code, args, 2, "");
}
LLVMValueRef ac_build_cvt_pknorm_u16_f16(struct ac_llvm_context *ctx,
@@ -2370,7 +2365,7 @@ LLVMValueRef ac_build_cvt_pknorm_u16_f16(struct ac_llvm_context *ctx,
LLVMValueRef code = LLVMConstInlineAsm(calltype,
"v_cvt_pknorm_u16_f16 $0, $1, $2", "=v,v,v",
false, false);
- return LLVMBuildCall(ctx->builder, code, args, 2, "");
+ return LLVMBuildCall2(ctx->builder, calltype, code, args, 2, "");
}
/* The 8-bit and 10-bit clamping is for HW workarounds. */
@@ -2998,7 +2993,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 LLVMBuildLoad(ctx->builder, ac_build_gep0(ctx, ctx->lds, dw_addr), "");
+ return LLVMBuildLoad2(ctx->builder, ctx->i32, ac_build_gep0(ctx, ctx->lds, dw_addr), "");
}
void ac_lds_store(struct ac_llvm_context *ctx, LLVMValueRef dw_addr, LLVMValueRef value)
@@ -3194,7 +3189,7 @@ static void ac_branch_exited(struct ac_llvm_context *ctx)
*
* This is an optional optimization that only kills whole inactive quads.
*/
- LLVMValueRef cond = LLVMBuildLoad(ctx->builder, ctx->postponed_kill, "");
+ LLVMValueRef cond = LLVMBuildLoad2(ctx->builder, ctx->i1, ctx->postponed_kill, "");
ac_build_kill_if_false(ctx, ac_build_wqm_vote(ctx, cond));
ctx->conditional_demote_seen = false;
}
@@ -4195,7 +4190,8 @@ void ac_build_wg_wavescan_top(struct ac_llvm_context *ctx, struct ac_wg_scan *ws
tmp = LLVMBuildICmp(builder, LLVMIntEQ, tid, last_lane, "");
ac_build_ifcc(ctx, tmp, 1000);
- LLVMBuildStore(builder, ws->src, LLVMBuildGEP(builder, ws->scratch, &ws->waveidx, 1, ""));
+ LLVMBuildStore(builder, ws->src,
+ LLVMBuildGEP2(builder, LLVMTypeOf(ws->src), ws->scratch, &ws->waveidx, 1, ""));
ac_build_endif(ctx, 1000);
}
@@ -4235,7 +4231,8 @@ void ac_build_wg_wavescan_bottom(struct ac_llvm_context *ctx, struct ac_wg_scan
tmp = LLVMBuildICmp(builder, LLVMIntULT, tid, ws->waveidx, "");
ac_build_ifcc(ctx, tmp, 1001);
{
- tmp = LLVMBuildLoad(builder, LLVMBuildGEP(builder, ws->scratch, &tid, 1, ""), "");
+ tmp = LLVMBuildLoad2(builder, LLVMTypeOf(ws->src),
+ LLVMBuildGEP2(builder, LLVMTypeOf(ws->src), ws->scratch, &tid, 1, ""), "");
ac_build_optimization_barrier(ctx, &tmp, false);
@@ -4472,7 +4469,7 @@ LLVMValueRef ac_build_is_helper_invocation(struct ac_llvm_context *ctx)
LLVMValueRef exact =
ac_build_intrinsic(ctx, "llvm.amdgcn.ps.live", ctx->i1, NULL, 0, AC_FUNC_ATTR_READNONE);
- LLVMValueRef postponed = LLVMBuildLoad(ctx->builder, ctx->postponed_kill, "");
+ LLVMValueRef postponed = LLVMBuildLoad2(ctx->builder, ctx->i1, ctx->postponed_kill, "");
return LLVMBuildNot(ctx->builder, LLVMBuildAnd(ctx->builder, exact, postponed, ""), "");
}
@@ -4745,7 +4742,7 @@ void ac_build_s_endpgm(struct ac_llvm_context *ctx)
{
LLVMTypeRef calltype = LLVMFunctionType(ctx->voidt, NULL, 0, false);
LLVMValueRef code = LLVMConstInlineAsm(calltype, "s_endpgm", "", true, false);
- LLVMBuildCall(ctx->builder, code, NULL, 0, "");
+ LLVMBuildCall2(ctx->builder, calltype, code, NULL, 0, "");
}
/**
diff --git a/src/amd/llvm/ac_llvm_build.h b/src/amd/llvm/ac_llvm_build.h
index 03d03737a3c..488a5400fe4 100644
--- a/src/amd/llvm/ac_llvm_build.h
+++ b/src/amd/llvm/ac_llvm_build.h
@@ -192,7 +192,7 @@ LLVMValueRef ac_build_varying_gather_values(struct ac_llvm_context *ctx, LLVMVal
unsigned value_count, unsigned component);
LLVMValueRef ac_build_gather_values_extended(struct ac_llvm_context *ctx, LLVMValueRef *values,
- unsigned value_count, unsigned value_stride, bool load,
+ unsigned value_count, unsigned value_stride,
bool always_vector);
LLVMValueRef ac_build_gather_values(struct ac_llvm_context *ctx, LLVMValueRef *values,
unsigned value_count);
diff --git a/src/amd/llvm/ac_nir_to_llvm.c b/src/amd/llvm/ac_nir_to_llvm.c
index 429ef1e3e8b..1789073b172 100644
--- a/src/amd/llvm/ac_nir_to_llvm.c
+++ b/src/amd/llvm/ac_nir_to_llvm.c
@@ -87,7 +87,7 @@ static LLVMValueRef get_src(struct ac_nir_context *nir, nir_src src)
return nir->ssa_defs[src.ssa->index];
}
-static LLVMValueRef get_memory_ptr(struct ac_nir_context *ctx, nir_src src, unsigned bit_size, unsigned c_off)
+static LLVMValueRef get_memory_ptr_t(struct ac_nir_context *ctx, nir_src src, LLVMTypeRef elem_type, unsigned c_off)
{
LLVMValueRef ptr = get_src(ctx, src);
LLVMValueRef lds_i8 = ctx->ac.lds;
@@ -95,12 +95,15 @@ static LLVMValueRef get_memory_ptr(struct ac_nir_context *ctx, nir_src src, unsi
lds_i8 = LLVMBuildBitCast(ctx->ac.builder, ctx->ac.lds, LLVMPointerType(ctx->ac.i8, AC_ADDR_SPACE_LDS), "");
ptr = LLVMBuildAdd(ctx->ac.builder, ptr, LLVMConstInt(ctx->ac.i32, c_off, 0), "");
- ptr = LLVMBuildGEP(ctx->ac.builder, lds_i8, &ptr, 1, "");
+ ptr = LLVMBuildGEP2(ctx->ac.builder, ctx->ac.i8, lds_i8, &ptr, 1, "");
int addr_space = LLVMGetPointerAddressSpace(LLVMTypeOf(ptr));
- LLVMTypeRef type = LLVMIntTypeInContext(ctx->ac.context, bit_size);
+ return LLVMBuildBitCast(ctx->ac.builder, ptr, LLVMPointerType(elem_type, addr_space), "");
+}
- return LLVMBuildBitCast(ctx->ac.builder, ptr, LLVMPointerType(type, addr_space), "");
+static LLVMValueRef get_memory_ptr(struct ac_nir_context *ctx, nir_src src, unsigned bit_size, unsigned c_off)
+{
+ return get_memory_ptr_t(ctx, src, LLVMIntTypeInContext(ctx->ac.context, bit_size), c_off);
}
static LLVMBasicBlockRef get_block(struct ac_nir_context *nir, const struct nir_block *b)
@@ -1675,14 +1678,13 @@ static LLVMValueRef visit_load_push_constant(struct ac_nir_context *ctx, nir_int
}
}
- ptr =
- LLVMBuildGEP(ctx->ac.builder, ac_get_arg(&ctx->ac, ctx->args->push_constants), &addr, 1, "");
+ ptr = LLVMBuildGEP(ctx->ac.builder, ac_get_arg(&ctx->ac, ctx->args->push_constants), &addr, 1, "");
if (instr->dest.ssa.bit_size == 8) {
unsigned load_dwords = instr->dest.ssa.num_components > 1 ? 2 : 1;
LLVMTypeRef vec_type = LLVMVectorType(ctx->ac.i8, 4 * load_dwords);
ptr = ac_cast_ptr(&ctx->ac, ptr, vec_type);
- LLVMValueRef res = LLVMBuildLoad(ctx->ac.builder, ptr, "");
+ LLVMValueRef res = LLVMBuildLoad2(ctx->ac.builder, vec_type, ptr, "");
LLVMValueRef params[3];
if (load_dwords > 1) {
@@ -1710,7 +1712,7 @@ static LLVMValueRef visit_load_push_constant(struct ac_nir_context *ctx, nir_int
unsigned load_dwords = instr->dest.ssa.num_components / 2 + 1;
LLVMTypeRef vec_type = LLVMVectorType(ctx->ac.i16, 2 * load_dwords);
ptr = ac_cast_ptr(&ctx->ac, ptr, vec_type);
- LLVMValueRef res = LLVMBuildLoad(ctx->ac.builder, ptr, "");
+ LLVMValueRef res = LLVMBuildLoad2(ctx->ac.builder, vec_type, ptr, "");
res = LLVMBuildBitCast(ctx->ac.builder, res, vec_type, "");
LLVMValueRef cond = LLVMBuildLShr(ctx->ac.builder, addr, ctx->ac.i32_1, "");
cond = LLVMBuildTrunc(ctx->ac.builder, cond, ctx->ac.i1, "");
@@ -1728,9 +1730,10 @@ static LLVMValueRef visit_load_push_constant(struct ac_nir_context *ctx, nir_int
return LLVMBuildBitCast(ctx->ac.builder, res, get_def_type(ctx, &instr->dest.ssa), "");
}
- ptr = ac_cast_ptr(&ctx->ac, ptr, get_def_type(ctx, &instr->dest.ssa));
+ LLVMTypeRef ptr_type = get_def_type(ctx, &instr->dest.ssa);
+ ptr = ac_cast_ptr(&ctx->ac, ptr, ptr_type);
- return LLVMBuildLoad(ctx->ac.builder, ptr, "");
+ return LLVMBuildLoad2(ctx->ac.builder, ptr_type, ptr, "");
}
static LLVMValueRef visit_get_ssbo_size(struct ac_nir_context *ctx,
@@ -1797,7 +1800,7 @@ static LLVMValueRef enter_waterfall_ssbo(struct ac_nir_context *ctx, struct wate
static void visit_store_ssbo(struct ac_nir_context *ctx, nir_intrinsic_instr *instr)
{
if (ctx->ac.postponed_kill) {
- LLVMValueRef cond = LLVMBuildLoad(ctx->ac.builder, ctx->ac.postponed_kill, "");
+ LLVMValueRef cond = LLVMBuildLoad2(ctx->ac.builder, ctx->ac.i1, ctx->ac.postponed_kill, "");
ac_build_ifcc(&ctx->ac, cond, 7000);
}
@@ -1954,7 +1957,7 @@ static LLVMValueRef emit_ssbo_comp_swap_64(struct ac_nir_context *ctx, LLVMValue
static LLVMValueRef visit_atomic_ssbo(struct ac_nir_context *ctx, nir_intrinsic_instr *instr)
{
if (ctx->ac.postponed_kill) {
- LLVMValueRef cond = LLVMBuildLoad(ctx->ac.builder, ctx->ac.postponed_kill, "");
+ LLVMValueRef cond = LLVMBuildLoad2(ctx->ac.builder, ctx->ac.i1, ctx->ac.postponed_kill, "");
ac_build_ifcc(&ctx->ac, cond, 7001);
}
@@ -2128,7 +2131,7 @@ static LLVMValueRef visit_load_global(struct ac_nir_context *ctx,
addr = LLVMBuildIntToPtr(ctx->ac.builder, addr, ptr_type, "");
- val = LLVMBuildLoad(ctx->ac.builder, addr, "");
+ val = LLVMBuildLoad2(ctx->ac.builder, result_type, addr, "");
if (nir_intrinsic_access(instr) & (ACCESS_COHERENT | ACCESS_VOLATILE)) {
LLVMSetOrdering(val, LLVMAtomicOrderingMonotonic);
@@ -2142,7 +2145,7 @@ static void visit_store_global(struct ac_nir_context *ctx,
nir_intrinsic_instr *instr)
{
if (ctx->ac.postponed_kill) {
- LLVMValueRef cond = LLVMBuildLoad(ctx->ac.builder, ctx->ac.postponed_kill, "");
+ LLVMValueRef cond = LLVMBuildLoad2(ctx->ac.builder, ctx->ac.i1, ctx->ac.postponed_kill, "");
ac_build_ifcc(&ctx->ac, cond, 7002);
}
@@ -2170,7 +2173,7 @@ static LLVMValueRef visit_global_atomic(struct ac_nir_context *ctx,
nir_intrinsic_instr *instr)
{
if (ctx->ac.postponed_kill) {
- LLVMValueRef cond = LLVMBuildLoad(ctx->ac.builder, ctx->ac.postponed_kill, "");
+ LLVMValueRef cond = LLVMBuildLoad2(ctx->ac.builder, ctx->ac.i1, ctx->ac.postponed_kill, "");
ac_build_ifcc(&ctx->ac, cond, 7002);
}
@@ -2305,7 +2308,7 @@ static unsigned type_scalar_size_bytes(const struct glsl_type *type)
static void visit_store_output(struct ac_nir_context *ctx, nir_intrinsic_instr *instr)
{
if (ctx->ac.postponed_kill) {
- LLVMValueRef cond = LLVMBuildLoad(ctx->ac.builder, ctx->ac.postponed_kill, "");
+ LLVMValueRef cond = LLVMBuildLoad2(ctx->ac.builder, ctx->ac.i1, ctx->ac.postponed_kill, "");
ac_build_ifcc(&ctx->ac, cond, 7002);
}
@@ -2363,8 +2366,7 @@ static void visit_store_output(struct ac_nir_context *ctx, nir_intrinsic_instr *
* using read-modify-write.
*/
index = LLVMConstInt(ctx->ac.i32, nir_intrinsic_io_semantics(instr).high_16bits, 0);
- output = LLVMBuildLoad(ctx->ac.builder, output_addr, "");
- output = LLVMBuildBitCast(ctx->ac.builder, output, ctx->ac.v2f16, "");
+ output = LLVMBuildLoad2(ctx->ac.builder, ctx->ac.v2f16, output_addr, "");
output = LLVMBuildInsertElement(ctx->ac.builder, output, value, index, "");
value = LLVMBuildBitCast(ctx->ac.builder, output, ctx->ac.f32, "");
}
@@ -2621,7 +2623,7 @@ static void visit_image_store(struct ac_nir_context *ctx, const nir_intrinsic_in
bool bindless)
{
if (ctx->ac.postponed_kill) {
- LLVMValueRef cond = LLVMBuildLoad(ctx->ac.builder, ctx->ac.postponed_kill, "");
+ LLVMValueRef cond = LLVMBuildLoad2(ctx->ac.builder, ctx->ac.i1, ctx->ac.postponed_kill, "");
ac_build_ifcc(&ctx->ac, cond, 7003);
}
@@ -2695,7 +2697,7 @@ static LLVMValueRef visit_image_atomic(struct ac_nir_context *ctx, const nir_int
bool bindless)
{
if (ctx->ac.postponed_kill) {
- LLVMValueRef cond = LLVMBuildLoad(ctx->ac.builder, ctx->ac.postponed_kill, "");
+ LLVMValueRef cond = LLVMBuildLoad2(ctx->ac.builder, ctx->ac.i1, ctx->ac.postponed_kill, "");
ac_build_ifcc(&ctx->ac, cond, 7004);
}
@@ -2984,7 +2986,7 @@ static void emit_demote(struct ac_nir_context *ctx, const nir_intrinsic_instr *i
return;
}
- LLVMValueRef mask = LLVMBuildLoad(ctx->ac.builder, ctx->ac.postponed_kill, "");
+ LLVMValueRef mask = LLVMBuildLoad2(ctx->ac.builder, ctx->ac.i1, ctx->ac.postponed_kill, "");
mask = LLVMBuildAnd(ctx->ac.builder, mask, cond, "");
LLVMBuildStore(ctx->ac.builder, mask, ctx->ac.postponed_kill);
@@ -3082,12 +3084,13 @@ static LLVMValueRef visit_load_shared(struct ac_nir_context *ctx, const nir_intr
LLVMValueRef values[4], derived_ptr, index, ret;
unsigned const_off = nir_intrinsic_base(instr);
- LLVMValueRef ptr = get_memory_ptr(ctx, instr->src[0], instr->dest.ssa.bit_size, const_off);
+ LLVMTypeRef elem_type = LLVMIntTypeInContext(ctx->ac.context, instr->dest.ssa.bit_size);
+ LLVMValueRef ptr = get_memory_ptr_t(ctx, instr->src[0], elem_type, const_off);
for (int chan = 0; chan < instr->num_components; chan++) {
index = LLVMConstInt(ctx->ac.i32, chan, 0);
- derived_ptr = LLVMBuildGEP(ctx->ac.builder, ptr, &index, 1, "");
- values[chan] = LLVMBuildLoad(ctx->ac.builder, derived_ptr, "");
+ derived_ptr = LLVMBuildGEP2(ctx->ac.builder, elem_type, ptr, &index, 1, "");
+ values[chan] = LLVMBuildLoad2(ctx->ac.builder, elem_type, derived_ptr, "");
}
ret = ac_build_gather_values(&ctx->ac, values, instr->num_components);
@@ -3101,7 +3104,8 @@ static void visit_store_shared(struct ac_nir_context *ctx, const nir_intrinsic_i
LLVMBuilderRef builder = ctx->ac.builder;
unsigned const_off = nir_intrinsic_base(instr);
- LLVMValueRef ptr = get_memory_ptr(ctx, instr->src[1], instr->src[0].ssa->bit_size, const_off);
+ LLVMTypeRef elem_type = LLVMIntTypeInContext(ctx->ac.context, instr->src[0].ssa->bit_size);
+ LLVMValueRef ptr = get_memory_ptr_t(ctx, instr->src[1], elem_type, const_off);
LLVMValueRef src = get_src(ctx, instr->src[0]);
int writemask = nir_intrinsic_write_mask(instr);
@@ -3111,7 +3115,7 @@ static void visit_store_shared(struct ac_nir_context *ctx, const nir_intrinsic_i
}
data = ac_llvm_extract_elem(&ctx->ac, src, chan);
index = LLVMConstInt(ctx->ac.i32, chan, 0);
- derived_ptr = LLVMBuildGEP(builder, ptr, &index, 1, "");
+ derived_ptr = LLVMBuildGEP2(builder, elem_type, ptr, &index, 1, "");
LLVMBuildStore(builder, data, derived_ptr);
}
}
@@ -3120,7 +3124,7 @@ static LLVMValueRef visit_var_atomic(struct ac_nir_context *ctx, const nir_intri
LLVMValueRef ptr, int src_idx)
{
if (ctx->ac.postponed_kill) {
- LLVMValueRef cond = LLVMBuildLoad(ctx->ac.builder, ctx->ac.postponed_kill, "");
+ LLVMValueRef cond = LLVMBuildLoad2(ctx->ac.builder, ctx->ac.i1, ctx->ac.postponed_kill, "");
ac_build_ifcc(&ctx->ac, cond, 7005);
}
@@ -4095,7 +4099,7 @@ static void visit_intrinsic(struct ac_nir_context *ctx, nir_intrinsic_instr *ins
: LLVMVectorType(comp_type, instr->dest.ssa.num_components);
unsigned addr_space = LLVMGetPointerAddressSpace(LLVMTypeOf(ptr));
ptr = LLVMBuildBitCast(ctx->ac.builder, ptr, LLVMPointerType(vec_type, addr_space), "");
- result = LLVMBuildLoad(ctx->ac.builder, ptr, "");
+ result = LLVMBuildLoad2(ctx->ac.builder, vec_type, ptr, "");
break;
}
case nir_intrinsic_store_scratch: {
@@ -4111,7 +4115,7 @@ static void visit_intrinsic(struct ac_nir_context *ctx, nir_intrinsic_instr *ins
u_bit_scan_consecutive_range(&wrmask, &start, &count);
LLVMValueRef offset = LLVMConstInt(ctx->ac.i32, start, false);
- LLVMValueRef offset_ptr = LLVMBuildGEP(ctx->ac.builder, ptr, &offset, 1, "");
+ LLVMValueRef offset_ptr = LLVMBuildGEP2(ctx->ac.builder, comp_type, ptr, &offset, 1, "");
LLVMTypeRef vec_type = count == 1 ? comp_type : LLVMVectorType(comp_type, count);
offset_ptr = LLVMBuildBitCast(ctx->ac.builder, offset_ptr,
LLVMPointerType(vec_type, addr_space), "");
@@ -4141,7 +4145,7 @@ static void visit_intrinsic(struct ac_nir_context *ctx, nir_intrinsic_instr *ins
: LLVMVectorType(comp_type, instr->dest.ssa.num_components);
unsigned addr_space = LLVMGetPointerAddressSpace(LLVMTypeOf(ptr));
ptr = LLVMBuildBitCast(ctx->ac.builder, ptr, LLVMPointerType(vec_type, addr_space), "");
- result = LLVMBuildLoad(ctx->ac.builder, ptr, "");
+ result = LLVMBuildLoad2(ctx->ac.builder, vec_type, ptr, "");
break;
}
case nir_intrinsic_set_vertex_and_primitive_count:
@@ -4302,11 +4306,11 @@ static void visit_intrinsic(struct ac_nir_context *ctx, nir_intrinsic_instr *ins
LLVMTypeRef byte_ptr_type = LLVMPointerType(ctx->ac.i8, AC_ADDR_SPACE_CONST);
LLVMValueRef addr = LLVMBuildIntToPtr(ctx->ac.builder, base, byte_ptr_type, "");
- addr = LLVMBuildGEP(ctx->ac.builder, addr, &offset, 1, "");
+ addr = LLVMBuildGEP2(ctx->ac.builder, ctx->ac.i8, addr, &offset, 1, "");
addr = LLVMBuildBitCast(ctx->ac.builder, addr, ptr_type, "");
LLVMSetMetadata(addr, ctx->ac.uniform_md_kind, ctx->ac.empty_md);
- result = LLVMBuildLoad(ctx->ac.builder, addr, "");
+ result = LLVMBuildLoad2(ctx->ac.builder, result_type, addr, "");
LLVMSetMetadata(result, ctx->ac.invariant_load_md_kind, ctx->ac.empty_md);
break;
}
@@ -5014,7 +5018,7 @@ static void visit_ssa_undef(struct ac_nir_context *ctx, const nir_ssa_undef_inst
} else {
LLVMValueRef zero = LLVMConstInt(type, 0, false);
if (num_components > 1) {
- zero = ac_build_gather_values_extended(&ctx->ac, &zero, 4, 0, false, false);
+ zero = ac_build_gather_values_extended(&ctx->ac, &zero, 4, 0, false);
}
ctx->ssa_defs[instr->def.index] = zero;
}
@@ -5436,7 +5440,7 @@ void ac_nir_translate(struct ac_llvm_context *ac, struct ac_shader_abi *abi,
phi_post_pass(&ctx);
if (ctx.ac.postponed_kill)
- ac_build_kill_if_false(&ctx.ac, LLVMBuildLoad(ctx.ac.builder, ctx.ac.postponed_kill, ""));
+ ac_build_kill_if_false(&ctx.ac, LLVMBuildLoad2(ctx.ac.builder, ctx.ac.i1, ctx.ac.postponed_kill, ""));
if (!gl_shader_stage_is_compute(nir->info.stage))
ctx.abi->emit_outputs(ctx.abi);
diff --git a/src/amd/llvm/ac_nir_to_llvm.h b/src/amd/llvm/ac_nir_to_llvm.h
index 3d495c77c14..f4ed35a0153 100644
--- a/src/amd/llvm/ac_nir_to_llvm.h
+++ b/src/amd/llvm/ac_nir_to_llvm.h
@@ -26,7 +26,7 @@
#include "amd_family.h"
#include "compiler/shader_enums.h"
-#include "llvm-c/Core.h"
+#include <llvm-c/Core.h>
#include "llvm-c/TargetMachine.h"
#include <stdbool.h>
More information about the mesa-commit
mailing list