diff options
author | Sanjay Patel <spatel@rotateright.com> | 2017-06-12 14:41:48 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2017-06-12 14:41:48 +0000 |
commit | d4765a38b4e82ecee39144c83ccb45b11944474a (patch) | |
tree | 83be1cf6975af5ad6dcfd6dcec59422b01a45b41 /llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | |
parent | 6db379a2c8bbc40f39a63c6c34216fe23c80127a (diff) | |
download | bcm5719-llvm-d4765a38b4e82ecee39144c83ccb45b11944474a.tar.gz bcm5719-llvm-d4765a38b4e82ecee39144c83ccb45b11944474a.zip |
[DAG] add helper to bind memop chains; NFCI
This step is just intended to reduce code duplication rather than change any functionality.
A follow-up would be to replace PPCTargetLowering::spliceIntoChain() usage with this new helper.
Differential Revision: https://reviews.llvm.org/D33649
llvm-svn: 305192
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index dff8bd2ad37..7abdc76cb00 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -7244,6 +7244,24 @@ void SelectionDAG::TransferDbgValues(SDValue From, SDValue To) { AddDbgValue(I, ToNode, false); } +void SelectionDAG::makeEquivalentMemoryOrdering(LoadSDNode *OldLoad, + SDValue NewMemOp) { + assert(isa<MemSDNode>(NewMemOp.getNode()) && "Expected a memop node"); + if (!OldLoad->hasAnyUseOfValue(1)) + return; + + // The new memory operation must have the same position as the old load in + // terms of memory dependency. Create a TokenFactor for the old load and new + // memory operation and update uses of the old load's output chain to use that + // TokenFactor. + SDValue OldChain = SDValue(OldLoad, 1); + SDValue NewChain = SDValue(NewMemOp.getNode(), 1); + SDValue TokenFactor = + getNode(ISD::TokenFactor, SDLoc(OldLoad), MVT::Other, OldChain, NewChain); + ReplaceAllUsesOfValueWith(OldChain, TokenFactor); + UpdateNodeOperands(TokenFactor.getNode(), OldChain, NewChain); +} + //===----------------------------------------------------------------------===// // SDNode Class //===----------------------------------------------------------------------===// |