ac: define all address spaces properly

This commit is contained in:
Marek Olšák
2018-09-07 18:44:54 -04:00
parent 8f77156c26
commit a668c8d6ba
5 changed files with 16 additions and 14 deletions

View File

@@ -184,7 +184,7 @@ ac_get_type_size(LLVMTypeRef type)
case LLVMDoubleTypeKind:
return 8;
case LLVMPointerTypeKind:
if (LLVMGetPointerAddressSpace(type) == AC_CONST_32BIT_ADDR_SPACE)
if (LLVMGetPointerAddressSpace(type) == AC_ADDR_SPACE_CONST_32BIT)
return 4;
return 8;
case LLVMVectorTypeKind:
@@ -891,7 +891,7 @@ ac_build_load_custom(struct ac_llvm_context *ctx, LLVMValueRef base_ptr,
LLVMValueRef indices[2] = {ctx->i32_0, index};
if (no_unsigned_wraparound &&
LLVMGetPointerAddressSpace(LLVMTypeOf(base_ptr)) == AC_CONST_32BIT_ADDR_SPACE)
LLVMGetPointerAddressSpace(LLVMTypeOf(base_ptr)) == AC_ADDR_SPACE_CONST_32BIT)
pointer = LLVMBuildInBoundsGEP(ctx->builder, base_ptr, indices, 2, "");
else
pointer = LLVMBuildGEP(ctx->builder, base_ptr, indices, 2, "");
@@ -2482,7 +2482,7 @@ void ac_declare_lds_as_pointer(struct ac_llvm_context *ctx)
{
unsigned lds_size = ctx->chip_class >= CIK ? 65536 : 32768;
ctx->lds = LLVMBuildIntToPtr(ctx->builder, ctx->i32_0,
LLVMPointerType(LLVMArrayType(ctx->i32, lds_size / 4), AC_LOCAL_ADDR_SPACE),
LLVMPointerType(LLVMArrayType(ctx->i32, lds_size / 4), AC_ADDR_SPACE_LDS),
"lds");
}
@@ -2564,7 +2564,7 @@ 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_CONST_ADDR_SPACE);
AC_ADDR_SPACE_CONST);
}
LLVMTypeRef ac_array_in_const32_addr_space(LLVMTypeRef elem_type)
@@ -2573,7 +2573,7 @@ LLVMTypeRef ac_array_in_const32_addr_space(LLVMTypeRef elem_type)
return ac_array_in_const_addr_space(elem_type);
return LLVMPointerType(LLVMArrayType(elem_type, 0),
AC_CONST_32BIT_ADDR_SPACE);
AC_ADDR_SPACE_CONST_32BIT);
}
static struct ac_llvm_flow *

View File

@@ -37,10 +37,12 @@ extern "C" {
#define HAVE_32BIT_POINTERS (HAVE_LLVM >= 0x0700)
enum {
/* CONST is the only address space that selects SMEM loads */
AC_CONST_ADDR_SPACE = HAVE_LLVM >= 0x700 ? 4 : 2,
AC_LOCAL_ADDR_SPACE = 3,
AC_CONST_32BIT_ADDR_SPACE = 6, /* same as CONST, but the pointer type has 32 bits */
AC_ADDR_SPACE_FLAT = HAVE_LLVM >= 0x0700 ? 0 : 4, /* Slower than global. */
AC_ADDR_SPACE_GLOBAL = 1,
AC_ADDR_SPACE_GDS = HAVE_LLVM >= 0x0700 ? 2 : 5,
AC_ADDR_SPACE_LDS = 3,
AC_ADDR_SPACE_CONST = HAVE_LLVM >= 0x0700 ? 4 : 2, /* Global allowing SMEM. */
AC_ADDR_SPACE_CONST_32BIT = 6, /* same as CONST, but the pointer type has 32 bits */
};
/* Combine these with & instead of |. */

View File

@@ -3928,7 +3928,7 @@ setup_shared(struct ac_nir_context *ctx,
LLVMAddGlobalInAddressSpace(
ctx->ac.module, glsl_to_llvm_type(&ctx->ac, variable->type),
variable->name ? variable->name : "",
AC_LOCAL_ADDR_SPACE);
AC_ADDR_SPACE_LDS);
_mesa_hash_table_insert(ctx->vars, variable, shared);
}
}

View File

@@ -1136,7 +1136,7 @@ static void create_function(struct radv_shader_context *ctx,
&user_sgpr_idx);
if (ctx->options->supports_spill) {
ctx->ring_offsets = ac_build_intrinsic(&ctx->ac, "llvm.amdgcn.implicit.buffer.ptr",
LLVMPointerType(ctx->ac.i8, AC_CONST_ADDR_SPACE),
LLVMPointerType(ctx->ac.i8, AC_ADDR_SPACE_CONST),
NULL, 0, AC_FUNC_ATTR_READNONE);
ctx->ring_offsets = LLVMBuildBitCast(ctx->ac.builder, ctx->ring_offsets,
ac_array_in_const_addr_space(ctx->ac.v4i32), "");

View File

@@ -2287,7 +2287,7 @@ void si_declare_compute_memory(struct si_shader_context *ctx)
struct si_shader_selector *sel = ctx->shader->selector;
unsigned lds_size = sel->info.properties[TGSI_PROPERTY_CS_LOCAL_SIZE];
LLVMTypeRef i8p = LLVMPointerType(ctx->i8, AC_LOCAL_ADDR_SPACE);
LLVMTypeRef i8p = LLVMPointerType(ctx->i8, AC_ADDR_SPACE_LDS);
LLVMValueRef var;
assert(!ctx->ac.lds);
@@ -2295,7 +2295,7 @@ void si_declare_compute_memory(struct si_shader_context *ctx)
var = LLVMAddGlobalInAddressSpace(ctx->ac.module,
LLVMArrayType(ctx->i8, lds_size),
"compute_lds",
AC_LOCAL_ADDR_SPACE);
AC_ADDR_SPACE_LDS);
LLVMSetAlignment(var, 4);
ctx->ac.lds = LLVMBuildBitCast(ctx->ac.builder, var, i8p, "");
@@ -6669,7 +6669,7 @@ static void si_build_wrapper_function(struct si_shader_context *ctx,
if (LLVMTypeOf(arg) != param_type) {
if (LLVMGetTypeKind(param_type) == LLVMPointerTypeKind) {
if (LLVMGetPointerAddressSpace(param_type) ==
AC_CONST_32BIT_ADDR_SPACE) {
AC_ADDR_SPACE_CONST_32BIT) {
arg = LLVMBuildBitCast(builder, arg, ctx->i32, "");
arg = LLVMBuildIntToPtr(builder, arg, param_type, "");
} else {