diff options
author | Christian Konig <christian.koenig@amd.com> | 2013-02-26 17:52:16 +0000 |
---|---|---|
committer | Christian Konig <christian.koenig@amd.com> | 2013-02-26 17:52:16 +0000 |
commit | c018ecac2f2f475b6e1023e90d0e48fcf9bd6e1d (patch) | |
tree | 1ce9097ebae4bf9b197ae514a24bd5ddcb83f98b | |
parent | 749428f852b63a98e872ba69b0c576b26b7b7518 (diff) | |
download | external_llvm-c018ecac2f2f475b6e1023e90d0e48fcf9bd6e1d.zip external_llvm-c018ecac2f2f475b6e1023e90d0e48fcf9bd6e1d.tar.gz external_llvm-c018ecac2f2f475b6e1023e90d0e48fcf9bd6e1d.tar.bz2 |
R600/SI: add folding helper
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176100 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/R600/AMDGPUISelLowering.h | 4 | ||||
-rw-r--r-- | lib/Target/R600/AMDILISelDAGToDAG.cpp | 19 | ||||
-rw-r--r-- | lib/Target/R600/SIISelLowering.cpp | 6 | ||||
-rw-r--r-- | lib/Target/R600/SIISelLowering.h | 1 |
4 files changed, 30 insertions, 0 deletions
diff --git a/lib/Target/R600/AMDGPUISelLowering.h b/lib/Target/R600/AMDGPUISelLowering.h index 404f620..9e7d997 100644 --- a/lib/Target/R600/AMDGPUISelLowering.h +++ b/lib/Target/R600/AMDGPUISelLowering.h @@ -65,6 +65,10 @@ public: SDValue LowerMinMax(SDValue Op, SelectionDAG &DAG) const; virtual const char* getTargetNodeName(unsigned Opcode) const; + virtual SDNode *PostISelFolding(MachineSDNode *N, SelectionDAG &DAG) const { + return N; + } + // Functions defined in AMDILISelLowering.cpp public: diff --git a/lib/Target/R600/AMDILISelDAGToDAG.cpp b/lib/Target/R600/AMDILISelDAGToDAG.cpp index 2e726e9..2f70fa9 100644 --- a/lib/Target/R600/AMDILISelDAGToDAG.cpp +++ b/lib/Target/R600/AMDILISelDAGToDAG.cpp @@ -43,6 +43,7 @@ public: SDNode *Select(SDNode *N); virtual const char *getPassName() const; + virtual void PostprocessISelDAG(); private: inline SDValue getSmallIPtrImm(unsigned Imm); @@ -575,3 +576,21 @@ bool AMDGPUDAGToDAGISel::SelectADDRIndirect(SDValue Addr, SDValue &Base, return true; } + +void AMDGPUDAGToDAGISel::PostprocessISelDAG() { + + // Go over all selected nodes and try to fold them a bit more + const AMDGPUTargetLowering& Lowering = ((const AMDGPUTargetLowering&)TLI); + for (SelectionDAG::allnodes_iterator I = CurDAG->allnodes_begin(), + E = CurDAG->allnodes_end(); I != E; ++I) { + + MachineSDNode *Node = dyn_cast<MachineSDNode>(I); + if (!Node) + continue; + + SDNode *ResNode = Lowering.PostISelFolding(Node, *CurDAG); + if (ResNode != Node) + ReplaceUses(Node, ResNode); + } +} + diff --git a/lib/Target/R600/SIISelLowering.cpp b/lib/Target/R600/SIISelLowering.cpp index 212e3f2..13173e8 100644 --- a/lib/Target/R600/SIISelLowering.cpp +++ b/lib/Target/R600/SIISelLowering.cpp @@ -357,3 +357,9 @@ SDValue SITargetLowering::PerformDAGCombine(SDNode *N, } return SDValue(); } + +SDNode *SITargetLowering::PostISelFolding(MachineSDNode *Node, + SelectionDAG &DAG) const { + // TODO: Implement immediate folding + return Node; +} diff --git a/lib/Target/R600/SIISelLowering.h b/lib/Target/R600/SIISelLowering.h index 5d048f8..71f99ac 100644 --- a/lib/Target/R600/SIISelLowering.h +++ b/lib/Target/R600/SIISelLowering.h @@ -41,6 +41,7 @@ public: virtual EVT getSetCCResultType(EVT VT) const; virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const; virtual SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const; + virtual SDNode *PostISelFolding(MachineSDNode *N, SelectionDAG &DAG) const; }; } // End namespace llvm |