ac/llvm: remove gep_2 and others temporary functions
Reviewed-by: Mihai Preda <mhpreda@gmail.com> Reviewed-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Qiang Yu <yuq825@gmail.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Acked-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19035>
This commit is contained in:

committed by
Marge Bot

parent
7508cdd2ff
commit
b31affddf4
@@ -1090,15 +1090,6 @@ LLVMValueRef ac_build_gep_ptr(struct ac_llvm_context *ctx, LLVMTypeRef type, LLV
|
||||
return LLVMBuildGEP2(ctx->builder, type, base_ptr, &index, 1, "");
|
||||
}
|
||||
|
||||
LLVMValueRef ac_build_gep0(struct ac_llvm_context *ctx, LLVMValueRef base_ptr, LLVMValueRef index)
|
||||
{
|
||||
LLVMValueRef indices[2] = {
|
||||
ctx->i32_0,
|
||||
index,
|
||||
};
|
||||
return LLVMBuildGEP(ctx->builder, base_ptr, indices, 2, "");
|
||||
}
|
||||
|
||||
LLVMTypeRef ac_build_gep0_type(LLVMTypeRef pointee_type, LLVMValueRef index)
|
||||
{
|
||||
switch (LLVMGetTypeKind(pointee_type)) {
|
||||
@@ -1121,7 +1112,7 @@ LLVMTypeRef ac_build_gep0_type(LLVMTypeRef pointee_type, LLVMValueRef index)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LLVMValueRef ac_build_gep0_2(struct ac_llvm_context *ctx, LLVMTypeRef pointee_type, LLVMValueRef value, LLVMValueRef index)
|
||||
LLVMValueRef ac_build_gep0(struct ac_llvm_context *ctx, LLVMTypeRef pointee_type, LLVMValueRef value, LLVMValueRef index)
|
||||
{
|
||||
LLVMValueRef indices[2] = {
|
||||
ctx->i32_0,
|
||||
@@ -1136,16 +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, LLVMValueRef base_ptr, LLVMValueRef index,
|
||||
void ac_build_indexed_store(struct ac_llvm_context *ctx, LLVMTypeRef type, LLVMValueRef base_ptr, LLVMValueRef index,
|
||||
LLVMValueRef value)
|
||||
{
|
||||
LLVMBuildStore(ctx->builder, value, ac_build_gep0(ctx, base_ptr, index));
|
||||
}
|
||||
|
||||
void ac_build_indexed_store2(struct ac_llvm_context *ctx, LLVMTypeRef type, LLVMValueRef base_ptr, LLVMValueRef index,
|
||||
LLVMValueRef value)
|
||||
{
|
||||
LLVMBuildStore(ctx->builder, value, ac_build_gep0_2(ctx, type, base_ptr, index));
|
||||
LLVMBuildStore(ctx->builder, value, ac_build_gep0(ctx, type, base_ptr, index));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1176,30 +1161,9 @@ void ac_build_indexed_store2(struct ac_llvm_context *ctx, LLVMTypeRef type, LLVM
|
||||
* ptr2 = LLVMBuildInBoundsGEP(ptr1, 32 / elemsize);
|
||||
* sampler = load(ptr2); // becomes "s_load ptr1, 32" thanks to InBounds
|
||||
*/
|
||||
static LLVMValueRef ac_build_load_custom(struct ac_llvm_context *ctx, LLVMValueRef base_ptr,
|
||||
LLVMValueRef index, bool uniform, bool invariant,
|
||||
bool no_unsigned_wraparound)
|
||||
{
|
||||
LLVMValueRef pointer, result;
|
||||
|
||||
if (no_unsigned_wraparound &&
|
||||
LLVMGetPointerAddressSpace(LLVMTypeOf(base_ptr)) == AC_ADDR_SPACE_CONST_32BIT)
|
||||
pointer = LLVMBuildInBoundsGEP(ctx->builder, base_ptr, &index, 1, "");
|
||||
else
|
||||
pointer = LLVMBuildGEP(ctx->builder, base_ptr, &index, 1, "");
|
||||
|
||||
if (uniform)
|
||||
LLVMSetMetadata(pointer, ctx->uniform_md_kind, ctx->empty_md);
|
||||
result = LLVMBuildLoad(ctx->builder, pointer, "");
|
||||
if (invariant)
|
||||
LLVMSetMetadata(result, ctx->invariant_load_md_kind, ctx->empty_md);
|
||||
LLVMSetAlignment(result, 4);
|
||||
return result;
|
||||
}
|
||||
|
||||
static LLVMValueRef ac_build_load_custom2(struct ac_llvm_context *ctx, LLVMTypeRef type,
|
||||
LLVMValueRef base_ptr, LLVMValueRef index,
|
||||
bool uniform, bool invariant, bool no_unsigned_wraparound)
|
||||
static LLVMValueRef ac_build_load_custom(struct ac_llvm_context *ctx, LLVMTypeRef type,
|
||||
LLVMValueRef base_ptr, LLVMValueRef index,
|
||||
bool uniform, bool invariant, bool no_unsigned_wraparound)
|
||||
{
|
||||
LLVMValueRef pointer, result;
|
||||
|
||||
@@ -1220,39 +1184,28 @@ static LLVMValueRef ac_build_load_custom2(struct ac_llvm_context *ctx, LLVMTypeR
|
||||
|
||||
LLVMValueRef ac_build_load(struct ac_llvm_context *ctx, LLVMTypeRef type, LLVMValueRef base_ptr, LLVMValueRef index)
|
||||
{
|
||||
return ac_build_load_custom2(ctx, type, base_ptr, index, false, false, false);
|
||||
return ac_build_load_custom(ctx, type, base_ptr, index, false, false, false);
|
||||
}
|
||||
|
||||
LLVMValueRef ac_build_load_invariant(struct ac_llvm_context *ctx, LLVMTypeRef type, LLVMValueRef base_ptr,
|
||||
LLVMValueRef index)
|
||||
{
|
||||
return ac_build_load_custom2(ctx, type, base_ptr, index, false, true, false);
|
||||
return ac_build_load_custom(ctx, type, base_ptr, 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, LLVMValueRef base_ptr,
|
||||
LLVMValueRef ac_build_load_to_sgpr(struct ac_llvm_context *ctx, LLVMTypeRef type, LLVMValueRef base_ptr,
|
||||
LLVMValueRef index)
|
||||
{
|
||||
return ac_build_load_custom(ctx, base_ptr, index, true, true, true);
|
||||
}
|
||||
|
||||
LLVMValueRef ac_build_load_to_sgpr2(struct ac_llvm_context *ctx, LLVMTypeRef type, LLVMValueRef base_ptr,
|
||||
LLVMValueRef index)
|
||||
{
|
||||
return ac_build_load_custom2(ctx, type, base_ptr, index, true, true, true);
|
||||
return ac_build_load_custom(ctx, type, base_ptr, index, true, true, true);
|
||||
}
|
||||
|
||||
/* See ac_build_load_custom() documentation. */
|
||||
LLVMValueRef ac_build_load_to_sgpr_uint_wraparound(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef ac_build_load_to_sgpr_uint_wraparound(struct ac_llvm_context *ctx, LLVMTypeRef type,
|
||||
LLVMValueRef base_ptr, LLVMValueRef index)
|
||||
{
|
||||
return ac_build_load_custom(ctx, base_ptr, index, true, true, false);
|
||||
}
|
||||
LLVMValueRef ac_build_load_to_sgpr_uint_wraparound2(struct ac_llvm_context *ctx, LLVMTypeRef type,
|
||||
LLVMValueRef base_ptr, LLVMValueRef index)
|
||||
{
|
||||
return ac_build_load_custom2(ctx, type, base_ptr, index, true, true, false);
|
||||
return ac_build_load_custom(ctx, type, base_ptr, index, true, true, false);
|
||||
}
|
||||
|
||||
static unsigned get_load_cache_policy(struct ac_llvm_context *ctx, unsigned cache_policy)
|
||||
@@ -2830,14 +2783,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_2(ctx, ctx->lds.t, ctx->lds.v, dw_addr);
|
||||
LLVMValueRef v = ac_build_gep0(ctx, ctx->lds.t, ctx->lds.v, 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_store2(ctx, ctx->lds.t, ctx->lds.v, dw_addr, value);
|
||||
ac_build_indexed_store(ctx, ctx->lds.t, ctx->lds.v, dw_addr, value);
|
||||
}
|
||||
|
||||
LLVMValueRef ac_find_lsb(struct ac_llvm_context *ctx, LLVMTypeRef dst_type, LLVMValueRef src0)
|
||||
|
Reference in New Issue
Block a user