summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp')
-rw-r--r--llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp b/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
index 157b06b7f46..fcaa6f907e5 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
@@ -129,6 +129,10 @@ private:
bool SelectSMRDBufferImm(SDValue Addr, SDValue &Offset) const;
bool SelectSMRDBufferImm32(SDValue Addr, SDValue &Offset) const;
bool SelectSMRDBufferSgpr(SDValue Addr, SDValue &Offset) const;
+ bool selectMOVRELOffsetImpl(SDValue Index, SDValue &Base,
+ SDValue &Offset, bool IsInsert) const;
+ bool selectMOVRELSOffset(SDValue Index, SDValue &Base, SDValue &Offset) const;
+ bool selectMOVRELDOffset(SDValue Index, SDValue &Base, SDValue &Offset) const;
bool SelectVOP3Mods(SDValue In, SDValue &Src, SDValue &SrcMods) const;
bool SelectVOP3NoMods(SDValue In, SDValue &Src, SDValue &SrcMods) const;
bool SelectVOP3Mods0(SDValue In, SDValue &Src, SDValue &SrcMods,
@@ -1189,6 +1193,51 @@ bool AMDGPUDAGToDAGISel::SelectSMRDBufferSgpr(SDValue Addr,
!isa<ConstantSDNode>(Offset);
}
+bool AMDGPUDAGToDAGISel::selectMOVRELOffsetImpl(SDValue Index,
+ SDValue &Base,
+ SDValue &Offset,
+ bool IsInsert) const {
+ SDLoc DL(Index);
+
+ if (CurDAG->isBaseWithConstantOffset(Index)) {
+ SDValue N0 = Index.getOperand(0);
+ SDValue N1 = Index.getOperand(1);
+ ConstantSDNode *C1 = cast<ConstantSDNode>(N1);
+
+ // (add n0, c0)
+ Base = N0;
+ Offset = CurDAG->getTargetConstant(C1->getZExtValue(), DL, MVT::i32);
+ return true;
+ }
+
+ if (IsInsert) {
+ if (ConstantSDNode *CBase = dyn_cast<ConstantSDNode>(Index)) {
+ Base = CurDAG->getRegister(AMDGPU::NoRegister, MVT::i32);
+ Offset = CurDAG->getTargetConstant(CBase->getZExtValue(), DL, MVT::i32);
+ return true;
+ }
+ } else {
+ if (isa<ConstantSDNode>(Index))
+ return false;
+ }
+
+ Base = Index;
+ Offset = CurDAG->getTargetConstant(0, DL, MVT::i32);
+ return true;
+}
+
+bool AMDGPUDAGToDAGISel::selectMOVRELSOffset(SDValue Index,
+ SDValue &Base,
+ SDValue &Offset) const {
+ return selectMOVRELOffsetImpl(Index, Base, Offset, false);
+}
+
+bool AMDGPUDAGToDAGISel::selectMOVRELDOffset(SDValue Index,
+ SDValue &Base,
+ SDValue &Offset) const {
+ return selectMOVRELOffsetImpl(Index, Base, Offset, true);
+}
+
SDNode *AMDGPUDAGToDAGISel::getS_BFE(unsigned Opcode, const SDLoc &DL,
SDValue Val, uint32_t Offset,
uint32_t Width) {
OpenPOWER on IntegriCloud