R600/SI: add folding helper

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
llvm-svn: 176100
This commit is contained in:
Christian Konig 2013-02-26 17:52:16 +00:00
parent d303996918
commit d910b7d534
4 changed files with 30 additions and 0 deletions

View File

@ -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:

View File

@ -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);
}
}

View File

@ -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;
}

View File

@ -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