mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-03 09:58:05 +02:00
amd/common: Implement ptr->int casts in ac_to_integer.
For the implicit casts inherent in nir. This should probably have been done for shared memory for VK_KHR_variable_pointers. Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
This commit is contained in:
parent
e00d9a9a72
commit
58c8dadd32
1 changed files with 13 additions and 0 deletions
|
|
@ -219,6 +219,16 @@ ac_to_integer_type(struct ac_llvm_context *ctx, LLVMTypeRef t)
|
|||
return LLVMVectorType(to_integer_type_scalar(ctx, elem_type),
|
||||
LLVMGetVectorSize(t));
|
||||
}
|
||||
if (LLVMGetTypeKind(t) == LLVMPointerTypeKind) {
|
||||
switch (LLVMGetPointerAddressSpace(t)) {
|
||||
case AC_ADDR_SPACE_GLOBAL:
|
||||
return ctx->i64;
|
||||
case AC_ADDR_SPACE_LDS:
|
||||
return ctx->i32;
|
||||
default:
|
||||
unreachable("unhandled address space");
|
||||
}
|
||||
}
|
||||
return to_integer_type_scalar(ctx, t);
|
||||
}
|
||||
|
||||
|
|
@ -226,6 +236,9 @@ LLVMValueRef
|
|||
ac_to_integer(struct ac_llvm_context *ctx, LLVMValueRef v)
|
||||
{
|
||||
LLVMTypeRef type = LLVMTypeOf(v);
|
||||
if (LLVMGetTypeKind(type) == LLVMPointerTypeKind) {
|
||||
return LLVMBuildPtrToInt(ctx->builder, v, ac_to_integer_type(ctx, type), "");
|
||||
}
|
||||
return LLVMBuildBitCast(ctx->builder, v, ac_to_integer_type(ctx, type), "");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue