mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-05 12:31:46 +00:00
R600/SI: Move all rsrc building functions to SIISelLowering
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221383 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
12bd9f11c0
commit
d8586375b8
@ -944,52 +944,6 @@ bool AMDGPUDAGToDAGISel::SelectMUBUFAddr64(SDValue Addr, SDValue &SRsrc,
|
||||
return SelectMUBUFAddr64(Addr, SRsrc, VAddr, Offset);
|
||||
}
|
||||
|
||||
static SDValue buildSMovImm32(SelectionDAG *DAG, SDLoc DL, uint64_t Val) {
|
||||
SDValue K = DAG->getTargetConstant(Val, MVT::i32);
|
||||
return SDValue(DAG->getMachineNode(AMDGPU::S_MOV_B32, DL, MVT::i32, K), 0);
|
||||
}
|
||||
|
||||
static SDValue buildRSRC(SelectionDAG *DAG, SDLoc DL, SDValue Ptr,
|
||||
uint32_t RsrcDword1, uint64_t RsrcDword2And3) {
|
||||
SDValue PtrLo = DAG->getTargetExtractSubreg(AMDGPU::sub0, DL, MVT::i32, Ptr);
|
||||
SDValue PtrHi = DAG->getTargetExtractSubreg(AMDGPU::sub1, DL, MVT::i32, Ptr);
|
||||
if (RsrcDword1) {
|
||||
PtrHi = SDValue(DAG->getMachineNode(AMDGPU::S_OR_B32, DL, MVT::i32, PtrHi,
|
||||
DAG->getConstant(RsrcDword1, MVT::i32)), 0);
|
||||
}
|
||||
|
||||
SDValue DataLo = buildSMovImm32(DAG, DL,
|
||||
RsrcDword2And3 & UINT64_C(0xFFFFFFFF));
|
||||
SDValue DataHi = buildSMovImm32(DAG, DL, RsrcDword2And3 >> 32);
|
||||
|
||||
const SDValue Ops[] = {
|
||||
DAG->getTargetConstant(AMDGPU::SReg_128RegClassID, MVT::i32),
|
||||
PtrLo,
|
||||
DAG->getTargetConstant(AMDGPU::sub0, MVT::i32),
|
||||
PtrHi,
|
||||
DAG->getTargetConstant(AMDGPU::sub1, MVT::i32),
|
||||
DataLo,
|
||||
DAG->getTargetConstant(AMDGPU::sub2, MVT::i32),
|
||||
DataHi,
|
||||
DAG->getTargetConstant(AMDGPU::sub3, MVT::i32)
|
||||
};
|
||||
|
||||
return SDValue(DAG->getMachineNode(AMDGPU::REG_SEQUENCE, DL,
|
||||
MVT::v4i32, Ops), 0);
|
||||
}
|
||||
|
||||
/// \brief Return a resource descriptor with the 'Add TID' bit enabled
|
||||
/// The TID (Thread ID) is multipled by the stride value (bits [61:48]
|
||||
/// of the resource descriptor) to create an offset, which is added to the
|
||||
/// resource ponter.
|
||||
static SDValue buildScratchRSRC(SelectionDAG *DAG, SDLoc DL, SDValue Ptr) {
|
||||
|
||||
uint64_t Rsrc = AMDGPU::RSRC_DATA_FORMAT | AMDGPU::RSRC_TID_ENABLE |
|
||||
0xffffffff; // Size
|
||||
|
||||
return buildRSRC(DAG, DL, Ptr, 0, Rsrc);
|
||||
}
|
||||
|
||||
bool AMDGPUDAGToDAGISel::SelectMUBUFScratch(SDValue Addr, SDValue &Rsrc,
|
||||
SDValue &VAddr, SDValue &SOffset,
|
||||
SDValue &ImmOffset) const {
|
||||
@ -1009,9 +963,10 @@ bool AMDGPUDAGToDAGISel::SelectMUBUFScratch(SDValue Addr, SDValue &Rsrc,
|
||||
Lowering.CreateLiveInRegister(*CurDAG, &AMDGPU::SReg_32RegClass,
|
||||
ScratchOffsetReg, MVT::i32);
|
||||
|
||||
Rsrc = buildScratchRSRC(CurDAG, DL,
|
||||
CurDAG->getCopyFromReg(CurDAG->getEntryNode(), DL,
|
||||
MRI.getLiveInVirtReg(ScratchPtrReg), MVT::i64));
|
||||
SDValue ScratchPtr =
|
||||
CurDAG->getCopyFromReg(CurDAG->getEntryNode(), DL,
|
||||
MRI.getLiveInVirtReg(ScratchPtrReg), MVT::i64);
|
||||
Rsrc = SDValue(Lowering.buildScratchRSRC(*CurDAG, DL, ScratchPtr), 0);
|
||||
SOffset = CurDAG->getCopyFromReg(CurDAG->getEntryNode(), DL,
|
||||
MRI.getLiveInVirtReg(ScratchOffsetReg), MVT::i32);
|
||||
|
||||
@ -1064,7 +1019,11 @@ bool AMDGPUDAGToDAGISel::SelectMUBUFOffset(SDValue Addr, SDValue &SRsrc,
|
||||
uint64_t Rsrc = AMDGPU::RSRC_DATA_FORMAT |
|
||||
APInt::getAllOnesValue(32).getZExtValue(); // Size
|
||||
SDLoc DL(Addr);
|
||||
SRsrc = buildRSRC(CurDAG, DL, Ptr, 0, Rsrc);
|
||||
|
||||
const SITargetLowering& Lowering =
|
||||
*static_cast<const SITargetLowering*>(getTargetLowering());
|
||||
|
||||
SRsrc = SDValue(Lowering.buildRSRC(*CurDAG, DL, Ptr, 0, Rsrc), 0);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -2019,6 +2019,50 @@ MachineSDNode *SITargetLowering::wrapAddr64Rsrc(SelectionDAG &DAG,
|
||||
#endif
|
||||
}
|
||||
|
||||
/// \brief Return a resource descriptor with the 'Add TID' bit enabled
|
||||
/// The TID (Thread ID) is multipled by the stride value (bits [61:48]
|
||||
/// of the resource descriptor) to create an offset, which is added to the
|
||||
/// resource ponter.
|
||||
MachineSDNode *SITargetLowering::buildRSRC(SelectionDAG &DAG,
|
||||
SDLoc DL,
|
||||
SDValue Ptr,
|
||||
uint32_t RsrcDword1,
|
||||
uint64_t RsrcDword2And3) const {
|
||||
SDValue PtrLo = DAG.getTargetExtractSubreg(AMDGPU::sub0, DL, MVT::i32, Ptr);
|
||||
SDValue PtrHi = DAG.getTargetExtractSubreg(AMDGPU::sub1, DL, MVT::i32, Ptr);
|
||||
if (RsrcDword1) {
|
||||
PtrHi = SDValue(DAG.getMachineNode(AMDGPU::S_OR_B32, DL, MVT::i32, PtrHi,
|
||||
DAG.getConstant(RsrcDword1, MVT::i32)), 0);
|
||||
}
|
||||
|
||||
SDValue DataLo = buildSMovImm32(DAG, DL,
|
||||
RsrcDword2And3 & UINT64_C(0xFFFFFFFF));
|
||||
SDValue DataHi = buildSMovImm32(DAG, DL, RsrcDword2And3 >> 32);
|
||||
|
||||
const SDValue Ops[] = {
|
||||
DAG.getTargetConstant(AMDGPU::SReg_128RegClassID, MVT::i32),
|
||||
PtrLo,
|
||||
DAG.getTargetConstant(AMDGPU::sub0, MVT::i32),
|
||||
PtrHi,
|
||||
DAG.getTargetConstant(AMDGPU::sub1, MVT::i32),
|
||||
DataLo,
|
||||
DAG.getTargetConstant(AMDGPU::sub2, MVT::i32),
|
||||
DataHi,
|
||||
DAG.getTargetConstant(AMDGPU::sub3, MVT::i32)
|
||||
};
|
||||
|
||||
return DAG.getMachineNode(AMDGPU::REG_SEQUENCE, DL, MVT::v4i32, Ops);
|
||||
}
|
||||
|
||||
MachineSDNode *SITargetLowering::buildScratchRSRC(SelectionDAG &DAG,
|
||||
SDLoc DL,
|
||||
SDValue Ptr) const {
|
||||
uint64_t Rsrc = AMDGPU::RSRC_DATA_FORMAT | AMDGPU::RSRC_TID_ENABLE |
|
||||
0xffffffff; // Size
|
||||
|
||||
return buildRSRC(DAG, DL, Ptr, 0, Rsrc);
|
||||
}
|
||||
|
||||
MachineSDNode *SITargetLowering::AdjustRegClass(MachineSDNode *N,
|
||||
SelectionDAG &DAG) const {
|
||||
|
||||
|
@ -107,6 +107,14 @@ public:
|
||||
void legalizeTargetIndependentNode(SDNode *Node, SelectionDAG &DAG) const;
|
||||
|
||||
MachineSDNode *wrapAddr64Rsrc(SelectionDAG &DAG, SDLoc DL, SDValue Ptr) const;
|
||||
MachineSDNode *buildRSRC(SelectionDAG &DAG,
|
||||
SDLoc DL,
|
||||
SDValue Ptr,
|
||||
uint32_t RsrcDword1,
|
||||
uint64_t RsrcDword2And3) const;
|
||||
MachineSDNode *buildScratchRSRC(SelectionDAG &DAG,
|
||||
SDLoc DL,
|
||||
SDValue Ptr) const;
|
||||
};
|
||||
|
||||
} // End namespace llvm
|
||||
|
Loading…
x
Reference in New Issue
Block a user