Index: lib/Target/AMDGPU/SIDefines.h =================================================================== --- lib/Target/AMDGPU/SIDefines.h +++ lib/Target/AMDGPU/SIDefines.h @@ -248,7 +248,6 @@ ID_LDS_ALLOC = 6, ID_IB_STS = 7, ID_SYMBOLIC_LAST_ = 8, - ID_MEM_BASES = 15, ID_SHIFT_ = 0, ID_WIDTH_ = 6, ID_MASK_ = (((1 << ID_WIDTH_) - 1) << ID_SHIFT_) @@ -258,20 +257,14 @@ OFFSET_DEFAULT_ = 0, OFFSET_SHIFT_ = 6, OFFSET_WIDTH_ = 5, - OFFSET_MASK_ = (((1 << OFFSET_WIDTH_) - 1) << OFFSET_SHIFT_), - - OFFSET_SRC_SHARED_BASE = 16, - OFFSET_SRC_PRIVATE_BASE = 0 + OFFSET_MASK_ = (((1 << OFFSET_WIDTH_) - 1) << OFFSET_SHIFT_) }; enum WidthMinusOne { // WidthMinusOne, (5) [15:11] WIDTH_M1_DEFAULT_ = 31, WIDTH_M1_SHIFT_ = 11, WIDTH_M1_WIDTH_ = 5, - WIDTH_M1_MASK_ = (((1 << WIDTH_M1_WIDTH_) - 1) << WIDTH_M1_SHIFT_), - - WIDTH_M1_SRC_SHARED_BASE = 15, - WIDTH_M1_SRC_PRIVATE_BASE = 15 + WIDTH_M1_MASK_ = (((1 << WIDTH_M1_WIDTH_) - 1) << WIDTH_M1_SHIFT_) }; } // namespace Hwreg Index: lib/Target/AMDGPU/SIISelLowering.cpp =================================================================== --- lib/Target/AMDGPU/SIISelLowering.cpp +++ lib/Target/AMDGPU/SIISelLowering.cpp @@ -2348,24 +2348,15 @@ SDValue SITargetLowering::getSegmentAperture(unsigned AS, const SDLoc &DL, SelectionDAG &DAG) const { - // FIXME: Use inline constants (src_{shared, private}_base) instead. if (Subtarget->hasApertureRegs()) { - unsigned Offset = AS == AMDGPUASI.LOCAL_ADDRESS ? - AMDGPU::Hwreg::OFFSET_SRC_SHARED_BASE : - AMDGPU::Hwreg::OFFSET_SRC_PRIVATE_BASE; - unsigned WidthM1 = AS == AMDGPUASI.LOCAL_ADDRESS ? - AMDGPU::Hwreg::WIDTH_M1_SRC_SHARED_BASE : - AMDGPU::Hwreg::WIDTH_M1_SRC_PRIVATE_BASE; - unsigned Encoding = - AMDGPU::Hwreg::ID_MEM_BASES << AMDGPU::Hwreg::ID_SHIFT_ | - Offset << AMDGPU::Hwreg::OFFSET_SHIFT_ | - WidthM1 << AMDGPU::Hwreg::WIDTH_M1_SHIFT_; - - SDValue EncodingImm = DAG.getTargetConstant(Encoding, DL, MVT::i16); - SDValue ApertureReg = SDValue( - DAG.getMachineNode(AMDGPU::S_GETREG_B32, DL, MVT::i32, EncodingImm), 0); - SDValue ShiftAmount = DAG.getTargetConstant(WidthM1 + 1, DL, MVT::i32); - return DAG.getNode(ISD::SHL, DL, MVT::i32, ApertureReg, ShiftAmount); + unsigned ApertureRegNo = AS == AMDGPUASI.LOCAL_ADDRESS ? + AMDGPU::SRC_SHARED_BASE : AMDGPU::SRC_PRIVATE_BASE; + + SDValue ApertureReg = CreateLiveInRegister( + DAG, &AMDGPU::SReg_64RegClass, ApertureRegNo, MVT::i64); + SDValue Aperture = SDValue( + DAG.getMachineNode(AMDGPU::S_MOV_B64, DL, MVT::i64, ApertureReg), 0); + return DAG.getTargetExtractSubreg(AMDGPU::sub1, DL, MVT::i32, Aperture); } MachineFunction &MF = DAG.getMachineFunction(); Index: lib/Target/AMDGPU/SIInstrInfo.cpp =================================================================== --- lib/Target/AMDGPU/SIInstrInfo.cpp +++ lib/Target/AMDGPU/SIInstrInfo.cpp @@ -412,7 +412,7 @@ return; } - if (!AMDGPU::SReg_64_WITH_SUBREGSRegClass.contains(SrcReg)) { + if (!AMDGPU::SReg_64RegClass.contains(SrcReg)) { reportIllegalCopy(this, MBB, MI, DL, DestReg, SrcReg, KillSrc); return; } Index: lib/Target/AMDGPU/SIRegisterInfo.cpp =================================================================== --- lib/Target/AMDGPU/SIRegisterInfo.cpp +++ lib/Target/AMDGPU/SIRegisterInfo.cpp @@ -1036,6 +1036,9 @@ // TODO: It might be helpful to have some target specific flags in // TargetRegisterClass to mark which classes are VGPRs to make this trivial. bool SIRegisterInfo::hasVGPRs(const TargetRegisterClass *RC) const { + if (!RC) + return false; + switch (RC->getSize()) { case 0: return false; case 1: return false; Index: test/CodeGen/AMDGPU/addrspacecast.ll =================================================================== --- test/CodeGen/AMDGPU/addrspacecast.ll +++ test/CodeGen/AMDGPU/addrspacecast.ll @@ -12,11 +12,8 @@ ; CI-DAG: v_mov_b32_e32 [[VAPERTURE:v[0-9]+]], [[APERTURE]] ; GFX9-DAG: s_load_dword [[PTR:s[0-9]+]], s[4:5], 0x0{{$}} -; GFX9-DAG: s_getreg_b32 [[SSRC_SHARED:s[0-9]+]], hwreg(15, 16, 16) -; GFX9-DAG: s_lshl_b32 [[SSRC_SHARED_BASE:s[0-9]+]], [[SSRC_SHARED]], 16 -; GFX9-DAG: v_mov_b32_e32 [[VAPERTURE:v[0-9]+]], [[SSRC_SHARED_BASE]] - -; GFX9-XXX: v_mov_b32_e32 [[VAPERTURE:v[0-9]+]], src_shared_base +; GFX9-DAG: s_mov_b64 s{{\[}}[[LO_SREG:[0-9]+]]:[[HI_SREG:[0-9]+]]{{\]}}, src_shared_base +; GFX9-DAG: v_mov_b32_e32 [[VAPERTURE:v[0-9]+]], s[[HI_SREG]] ; HSA-DAG: v_mov_b32_e32 [[VPTR:v[0-9]+]], [[PTR]] @@ -49,11 +46,8 @@ ; CI-DAG: v_mov_b32_e32 [[VAPERTURE:v[0-9]+]], [[APERTURE]] ; GFX9-DAG: s_load_dword [[PTR:s[0-9]+]], s[4:5], 0x0{{$}} -; GFX9-DAG: s_getreg_b32 [[SSRC_PRIVATE:s[0-9]+]], hwreg(15, 0, 16) -; GFX9-DAG: s_lshl_b32 [[SSRC_PRIVATE_BASE:s[0-9]+]], [[SSRC_PRIVATE]], 16 -; GFX9-DAG: v_mov_b32_e32 [[VAPERTURE:v[0-9]+]], [[SSRC_PRIVATE_BASE]] - -; GFX9-XXX: v_mov_b32_e32 [[VAPERTURE:v[0-9]+]], src_private_base +; GFX9-DAG: s_mov_b64 s{{\[}}[[LO_SREG:[0-9]+]]:[[HI_SREG:[0-9]+]]{{\]}}, src_private_base +; GFX9-DAG: v_mov_b32_e32 [[VAPERTURE:v[0-9]+]], s[[HI_SREG]] ; HSA-DAG: v_mov_b32_e32 [[VPTR:v[0-9]+]], [[PTR]] @@ -161,11 +155,9 @@ ; HSA-LABEL: {{^}}cast_0_group_to_flat_addrspacecast: ; CI: s_load_dword [[APERTURE:s[0-9]+]], s[4:5], 0x10 ; CI-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], [[APERTURE]] -; GFX9-DAG: s_getreg_b32 [[SSRC_SHARED:s[0-9]+]], hwreg(15, 16, 16) -; GFX9-DAG: s_lshl_b32 [[SSRC_SHARED_BASE:s[0-9]+]], [[SSRC_SHARED]], 16 -; GFX9-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], [[SSRC_SHARED_BASE]] -; GFX9-XXX: v_mov_b32_e32 v[[HI:[0-9]+]], src_shared_base +; GFX9-DAG: s_mov_b64 s{{\[}}[[LO_SREG:[0-9]+]]:[[HI_SREG:[0-9]+]]{{\]}}, src_shared_base +; GFX9-DAG: v_mov_b32_e32 [[VAPERTURE:v[0-9]+]], s[[HI_SREG]] ; HSA-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], 0{{$}} ; HSA-DAG: v_mov_b32_e32 v[[K:[0-9]+]], 7{{$}}