diff options
author | Dan Gohman <gohman@apple.com> | 2008-07-09 22:08:04 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-07-09 22:08:04 +0000 |
commit | 1ea58a52a4296afff10e9db1e54928f38e6d74c6 (patch) | |
tree | 9fbfe6816e4c6f07a2eafb4712b9f8845d3c8a46 | |
parent | 7705ea33e4898c6d7718f0a2dab22d6659498fc4 (diff) | |
download | external_llvm-1ea58a52a4296afff10e9db1e54928f38e6d74c6.zip external_llvm-1ea58a52a4296afff10e9db1e54928f38e6d74c6.tar.gz external_llvm-1ea58a52a4296afff10e9db1e54928f38e6d74c6.tar.bz2 |
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
-rw-r--r-- | include/llvm/CodeGen/SelectionDAGNodes.h | 39 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 44 |
2 files changed, 32 insertions, 51 deletions
diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h index c5fc5fe..16b406c 100644 --- a/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/include/llvm/CodeGen/SelectionDAGNodes.h @@ -1437,6 +1437,9 @@ class MemSDNode : public SDNode { virtual void ANCHOR(); // Out-of-line virtual method to give class a home. private: + // MemoryVT - VT of in-memory value. + MVT MemoryVT; + //! SrcValue - Memory location for alias analysis. const Value *SrcValue; @@ -1448,7 +1451,7 @@ private: unsigned Flags; public: - MemSDNode(unsigned Opc, SDVTList VTs, + MemSDNode(unsigned Opc, SDVTList VTs, MVT MemoryVT, const Value *srcValue, int SVOff, unsigned alignment, bool isvolatile); @@ -1460,9 +1463,17 @@ public: const Value *getSrcValue() const { return SrcValue; } int getSrcValueOffset() const { return SVOffset; } + /// getMemoryVT - Return the type of the in-memory value. + MVT getMemoryVT() const { return MemoryVT; } + /// getMemOperand - Return a MachineMemOperand object describing the memory /// reference performed by operation. - virtual MachineMemOperand getMemOperand() const = 0; + MachineMemOperand getMemOperand() const; + + const SDOperand &getChain() const { return getOperand(0); } + const SDOperand &getBasePtr() const { + return getOperand(getOpcode() == ISD::STORE ? 2 : 1); + } // Methods to support isa and dyn_cast static bool classof(const MemSDNode *) { return true; } @@ -1501,7 +1512,7 @@ class AtomicSDNode : public MemSDNode { AtomicSDNode(unsigned Opc, SDVTList VTL, SDOperand Chain, SDOperand Ptr, SDOperand Cmp, SDOperand Swp, const Value* SrcVal, unsigned Align=0) - : MemSDNode(Opc, VTL, SrcVal, /*SVOffset=*/0, + : MemSDNode(Opc, VTL, Cmp.getValueType(), SrcVal, /*SVOffset=*/0, Align, /*isVolatile=*/true) { Ops[0] = Chain; Ops[1] = Ptr; @@ -1511,7 +1522,7 @@ class AtomicSDNode : public MemSDNode { } AtomicSDNode(unsigned Opc, SDVTList VTL, SDOperand Chain, SDOperand Ptr, SDOperand Val, const Value* SrcVal, unsigned Align=0) - : MemSDNode(Opc, VTL, SrcVal, /*SVOffset=*/0, + : MemSDNode(Opc, VTL, Val.getValueType(), SrcVal, /*SVOffset=*/0, Align, /*isVolatile=*/true) { Ops[0] = Chain; Ops[1] = Ptr; @@ -1519,16 +1530,11 @@ class AtomicSDNode : public MemSDNode { InitOperands(Ops, 3); } - const SDOperand &getChain() const { return getOperand(0); } const SDOperand &getBasePtr() const { return getOperand(1); } const SDOperand &getVal() const { return getOperand(2); } bool isCompareAndSwap() const { return getOpcode() == ISD::ATOMIC_CMP_SWAP; } - /// getMemOperand - Return a MachineMemOperand object describing the memory - /// reference performed by this atomic load/store. - virtual MachineMemOperand getMemOperand() const; - // Methods to support isa and dyn_cast static bool classof(const AtomicSDNode *) { return true; } static bool classof(const SDNode *N) { @@ -2052,9 +2058,6 @@ private: // AddrMode - unindexed, pre-indexed, post-indexed. ISD::MemIndexedMode AddrMode; - // MemoryVT - VT of in-memory value. - MVT MemoryVT; - protected: //! Operand array for load and store /*! @@ -2067,7 +2070,7 @@ public: LSBaseSDNode(ISD::NodeType NodeTy, SDOperand *Operands, unsigned numOperands, SDVTList VTs, ISD::MemIndexedMode AM, MVT VT, const Value *SV, int SVO, unsigned Align, bool Vol) - : MemSDNode(NodeTy, VTs, SV, SVO, Align, Vol), AddrMode(AM), MemoryVT(VT) { + : MemSDNode(NodeTy, VTs, VT, SV, SVO, Align, Vol), AddrMode(AM) { for (unsigned i = 0; i != numOperands; ++i) Ops[i] = Operands[i]; InitOperands(Ops, numOperands); @@ -2076,16 +2079,10 @@ public: "Only indexed loads and stores have a non-undef offset operand"); } - const SDOperand &getChain() const { return getOperand(0); } - const SDOperand &getBasePtr() const { - return getOperand(getOpcode() == ISD::LOAD ? 1 : 2); - } const SDOperand &getOffset() const { return getOperand(getOpcode() == ISD::LOAD ? 2 : 3); } - MVT getMemoryVT() const { return MemoryVT; } - ISD::MemIndexedMode getAddressingMode() const { return AddrMode; } /// isIndexed - Return true if this is a pre/post inc/dec load/store. @@ -2094,10 +2091,6 @@ public: /// isUnindexed - Return true if this is NOT a pre/post inc/dec load/store. bool isUnindexed() const { return AddrMode == ISD::UNINDEXED; } - /// getMemOperand - Return a MachineMemOperand object describing the memory - /// reference performed by this load or store. - virtual MachineMemOperand getMemOperand() const; - static bool classof(const LSBaseSDNode *) { return true; } static bool classof(const SDNode *N) { return N->getOpcode() == ISD::LOAD || diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 39cce98..fc70c19 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) { |