2019-09-05 10:20:39 +08:00
|
|
|
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=hawaii -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,CI %s
|
|
|
|
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GFX9 %s
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}is_local_vgpr:
|
2022-01-14 19:03:21 +08:00
|
|
|
; GCN-DAG: {{flat|global}}_load_dwordx2 v{{\[[0-9]+}}:[[PTR_HI:[0-9]+]]]
|
2019-09-05 10:20:39 +08:00
|
|
|
; CI-DAG: s_load_dword [[APERTURE:s[0-9]+]], s[4:5], 0x10
|
|
|
|
; GFX9-DAG: s_getreg_b32 [[APERTURE:s[0-9]+]], hwreg(HW_REG_SH_MEM_BASES, 16, 16)
|
|
|
|
; GFX9: s_lshl_b32 [[APERTURE]], [[APERTURE]], 16
|
|
|
|
|
|
|
|
; GCN: v_cmp_eq_u32_e32 vcc, [[APERTURE]], v[[PTR_HI]]
|
|
|
|
; GCN: v_cndmask_b32_e64 v{{[0-9]+}}, 0, 1, vcc
|
|
|
|
define amdgpu_kernel void @is_local_vgpr(i8* addrspace(1)* %ptr.ptr) {
|
|
|
|
%id = call i32 @llvm.amdgcn.workitem.id.x()
|
|
|
|
%gep = getelementptr inbounds i8*, i8* addrspace(1)* %ptr.ptr, i32 %id
|
|
|
|
%ptr = load volatile i8*, i8* addrspace(1)* %gep
|
|
|
|
%val = call i1 @llvm.amdgcn.is.shared(i8* %ptr)
|
|
|
|
%ext = zext i1 %val to i32
|
|
|
|
store i32 %ext, i32 addrspace(1)* undef
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FIXME: setcc (zero_extend (setcc)), 1) not folded out, resulting in
|
|
|
|
; select and vcc branch.
|
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}is_local_sgpr:
|
|
|
|
; CI-DAG: s_load_dword [[APERTURE:s[0-9]+]], s[4:5], 0x10{{$}}
|
|
|
|
; GFX9-DAG: s_getreg_b32 [[APERTURE:s[0-9]+]], hwreg(HW_REG_SH_MEM_BASES, 16, 16)
|
|
|
|
; GFX9-DAG: s_lshl_b32 [[APERTURE]], [[APERTURE]], 16
|
|
|
|
|
|
|
|
; CI-DAG: s_load_dword [[PTR_HI:s[0-9]+]], s[6:7], 0x1{{$}}
|
AMDGPU: Set up User SGPRs for queue_ptr only when necessary
Summary:
In general, we need queue_ptr for aperture bases and trap handling,
and user SGPRs have to be set up to hold queue_ptr. In current implementation,
user SGPRs are set up unnecessarily for some cases. If the target has aperture
registers, queue_ptr is not needed to reference aperture bases. For trap
handling, if target suppots getDoorbellID, queue_ptr is also not necessary.
Futher, code object version 5 introduces new kernel ABI which passes queue_ptr
as an implicit kernel argument, so user SGPRs are no longer necessary for
queue_ptr. Based on the trap handling document:
https://llvm.org/docs/AMDGPUUsage.html#amdgpu-trap-handler-for-amdhsa-os-v4-onwards-table,
llvm.debugtrap does not need queue_ptr, we remove queue_ptr suport for llvm.debugtrap
in the backend.
Reviewers: sameerds, arsenm
Fixes: SWDEV-307189
Differential Revision: https://reviews.llvm.org/D119762
2022-03-10 02:14:05 +08:00
|
|
|
; GFX9-DAG: s_load_dword [[PTR_HI:s[0-9]+]], s[4:5], 0x4{{$}}
|
2019-09-05 10:20:39 +08:00
|
|
|
|
2021-07-16 00:43:56 +08:00
|
|
|
; GCN: s_cmp_eq_u32 [[PTR_HI]], [[APERTURE]]
|
2019-09-05 10:20:39 +08:00
|
|
|
; GCN: s_cbranch_vccnz
|
|
|
|
define amdgpu_kernel void @is_local_sgpr(i8* %ptr) {
|
|
|
|
%val = call i1 @llvm.amdgcn.is.shared(i8* %ptr)
|
|
|
|
br i1 %val, label %bb0, label %bb1
|
|
|
|
|
|
|
|
bb0:
|
|
|
|
store volatile i32 0, i32 addrspace(1)* undef
|
|
|
|
br label %bb1
|
|
|
|
|
|
|
|
bb1:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
declare i32 @llvm.amdgcn.workitem.id.x() #0
|
|
|
|
declare i1 @llvm.amdgcn.is.shared(i8* nocapture) #0
|
|
|
|
|
|
|
|
attributes #0 = { nounwind readnone speculatable }
|