aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-07-09 22:08:04 +0000
committerDan Gohman <gohman@apple.com>2008-07-09 22:08:04 +0000
commit1ea58a52a4296afff10e9db1e54928f38e6d74c6 (patch)
tree9fbfe6816e4c6f07a2eafb4712b9f8845d3c8a46 /lib/CodeGen/SelectionDAG/SelectionDAG.cpp
parent7705ea33e4898c6d7718f0a2dab22d6659498fc4 (diff)
Move MemoryVT out of LSBaseNode into MemSDNode, allowing the
getMemOperand function to be moved into the base class as well and made non-virtual. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53372 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAG.cpp44
1 files changed, 16 insertions, 28 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 39cce98f6b..fc70c19ff6 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -4331,10 +4331,10 @@ GlobalAddressSDNode::GlobalAddressSDNode(bool isTarget, const GlobalValue *GA,
TheGlobal = const_cast<GlobalValue*>(GA);
}
-MemSDNode::MemSDNode(unsigned Opc, SDVTList VTs,
+MemSDNode::MemSDNode(unsigned Opc, SDVTList VTs, MVT memvt,
const Value *srcValue, int SVO,
unsigned alignment, bool vol)
- : SDNode(Opc, VTs), SrcValue(srcValue), SVOffset(SVO),
+ : SDNode(Opc, VTs), MemoryVT(memvt), SrcValue(srcValue), SVOffset(SVO),
Flags(vol | ((Log2_32(alignment) + 1) << 1)) {
assert(isPowerOf2_32(alignment) && "Alignment is not a power of 2!");
@@ -4343,13 +4343,22 @@ MemSDNode::MemSDNode(unsigned Opc, SDVTList VTs,
}
/// getMemOperand - Return a MachineMemOperand object describing the memory
-/// reference performed by this atomic.
-MachineMemOperand AtomicSDNode::getMemOperand() const {
- int Size = (getValueType(0).getSizeInBits() + 7) >> 3;
- int Flags = MachineMemOperand::MOLoad | MachineMemOperand::MOStore;
+/// reference performed by this memory reference.
+MachineMemOperand MemSDNode::getMemOperand() const {
+ int Flags;
+ if (isa<LoadSDNode>(this))
+ Flags = MachineMemOperand::MOLoad;
+ else if (isa<StoreSDNode>(this))
+ Flags = MachineMemOperand::MOStore;
+ else {
+ assert(isa<AtomicSDNode>(this) && "Unknown MemSDNode opcode!");
+ Flags = MachineMemOperand::MOLoad | MachineMemOperand::MOStore;
+ }
+
+ int Size = (getMemoryVT().getSizeInBits() + 7) >> 3;
if (isVolatile()) Flags |= MachineMemOperand::MOVolatile;
- // Check if the atomic references a frame index
+ // Check if the memory reference references a frame index
const FrameIndexSDNode *FI =
dyn_cast<const FrameIndexSDNode>(getBasePtr().Val);
if (!getSrcValue() && FI)
@@ -4360,27 +4369,6 @@ MachineMemOperand AtomicSDNode::getMemOperand() const {
Size, getAlignment());
}
-/// getMemOperand - Return a MachineMemOperand object describing the memory
-/// reference performed by this load or store.
-MachineMemOperand LSBaseSDNode::getMemOperand() const {
- int Size = (getMemoryVT().getSizeInBits() + 7) >> 3;
- int Flags =
- getOpcode() == ISD::LOAD ? MachineMemOperand::MOLoad :
- MachineMemOperand::MOStore;
- if (isVolatile()) Flags |= MachineMemOperand::MOVolatile;
-
- // Check if the load references a frame index, and does not have
- // an SV attached.
- const FrameIndexSDNode *FI =
- dyn_cast<const FrameIndexSDNode>(getBasePtr().Val);
- if (!getSrcValue() && FI)
- return MachineMemOperand(PseudoSourceValue::getFixedStack(), Flags,
- FI->getIndex(), Size, getAlignment());
- else
- return MachineMemOperand(getSrcValue(), Flags,
- getSrcValueOffset(), Size, getAlignment());
-}
-
/// Profile - Gather unique data for the node.
///
void SDNode::Profile(FoldingSetNodeID &ID) {