diff options
Diffstat (limited to 'include/llvm/CodeGen')
-rw-r--r-- | include/llvm/CodeGen/MachineBasicBlock.h | 32 | ||||
-rw-r--r-- | include/llvm/CodeGen/MachineFunction.h | 29 | ||||
-rw-r--r-- | include/llvm/CodeGen/MachineInstr.h | 22 | ||||
-rw-r--r-- | include/llvm/CodeGen/SelectionDAG.h | 58 | ||||
-rw-r--r-- | include/llvm/CodeGen/SelectionDAGISel.h | 2 | ||||
-rw-r--r-- | include/llvm/CodeGen/SelectionDAGNodes.h | 32 |
6 files changed, 97 insertions, 78 deletions
diff --git a/include/llvm/CodeGen/MachineBasicBlock.h b/include/llvm/CodeGen/MachineBasicBlock.h index f0f9d54..8ee75c9 100644 --- a/include/llvm/CodeGen/MachineBasicBlock.h +++ b/include/llvm/CodeGen/MachineBasicBlock.h @@ -19,30 +19,34 @@ #include "llvm/Support/Streams.h" namespace llvm { - class MachineFunction; + +class BasicBlock; +class MachineFunction; template <> -struct alist_traits<MachineInstr, MachineInstr> { -protected: +class ilist_traits<MachineInstr> : public ilist_default_traits<MachineInstr> { + mutable MachineInstr Sentinel; + // this is only set by the MachineBasicBlock owning the LiveList friend class MachineBasicBlock; MachineBasicBlock* Parent; - typedef alist_iterator<MachineInstr> iterator; - public: - alist_traits<MachineInstr, MachineInstr>() : Parent(0) { } + MachineInstr *createSentinel() const { return &Sentinel; } + void destroySentinel(MachineInstr *) const {} void addNodeToList(MachineInstr* N); void removeNodeFromList(MachineInstr* N); - void transferNodesFromList(alist_traits &, iterator, iterator); + void transferNodesFromList(ilist_traits &SrcTraits, + ilist_iterator<MachineInstr> first, + ilist_iterator<MachineInstr> last); void deleteNode(MachineInstr *N); +private: + void createNode(const MachineInstr &); }; -class BasicBlock; - -class MachineBasicBlock { - typedef alist<MachineInstr> Instructions; +class MachineBasicBlock : public ilist_node<MachineBasicBlock> { + typedef ilist<MachineInstr> Instructions; Instructions Insts; const BasicBlock *BB; int Number; @@ -65,6 +69,10 @@ class MachineBasicBlock { /// exception handler. bool IsLandingPad; + // Intrusive list support + friend class ilist_sentinel_traits<MachineBasicBlock>; + MachineBasicBlock() {} + explicit MachineBasicBlock(MachineFunction &mf, const BasicBlock *bb); ~MachineBasicBlock(); @@ -287,7 +295,7 @@ public: void setNumber(int N) { Number = N; } private: // Methods used to maintain doubly linked list of blocks... - friend struct alist_traits<MachineBasicBlock>; + friend struct ilist_traits<MachineBasicBlock>; // Machine-CFG mutators diff --git a/include/llvm/CodeGen/MachineFunction.h b/include/llvm/CodeGen/MachineFunction.h index 98f3a94..7b24600 100644 --- a/include/llvm/CodeGen/MachineFunction.h +++ b/include/llvm/CodeGen/MachineFunction.h @@ -18,7 +18,7 @@ #ifndef LLVM_CODEGEN_MACHINEFUNCTION_H #define LLVM_CODEGEN_MACHINEFUNCTION_H -#include "llvm/ADT/alist.h" +#include "llvm/ADT/ilist.h" #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/Support/Annotation.h" #include "llvm/Support/Allocator.h" @@ -34,15 +34,18 @@ class MachineConstantPool; class MachineJumpTableInfo; template <> -class alist_traits<MachineBasicBlock, MachineBasicBlock> { - typedef alist_iterator<MachineBasicBlock> iterator; +class ilist_traits<MachineBasicBlock> + : public ilist_default_traits<MachineBasicBlock> { + mutable MachineBasicBlock Sentinel; public: + MachineBasicBlock *createSentinel() const { return &Sentinel; } + void destroySentinel(MachineBasicBlock *) const {} + void addNodeToList(MachineBasicBlock* MBB); void removeNodeFromList(MachineBasicBlock* MBB); - void transferNodesFromList(alist_traits<MachineBasicBlock> &, - iterator, - iterator) {} void deleteNode(MachineBasicBlock *MBB); +private: + void createNode(const MachineBasicBlock &); }; /// MachineFunctionInfo - This class can be derived from and used by targets to @@ -87,11 +90,8 @@ class MachineFunction : private Annotation { // Allocation management for basic blocks in function. Recycler<MachineBasicBlock> BasicBlockRecycler; - // Allocation management for memoperands in function. - Recycler<MachineMemOperand> MemOperandRecycler; - // List of machine basic blocks in function - typedef alist<MachineBasicBlock> BasicBlockListType; + typedef ilist<MachineBasicBlock> BasicBlockListType; BasicBlockListType BasicBlocks; public: @@ -302,15 +302,6 @@ public: /// DeleteMachineBasicBlock - Delete the given MachineBasicBlock. /// void DeleteMachineBasicBlock(MachineBasicBlock *MBB); - - /// CreateMachineMemOperand - Allocate a new MachineMemOperand. Use this - /// instead of `new MachineMemOperand'. - /// - MachineMemOperand *CreateMachineMemOperand(const MachineMemOperand &MMO); - - /// DeleteMachineMemOperand - Delete the given MachineMemOperand. - /// - void DeleteMachineMemOperand(MachineMemOperand *MMO); }; //===--------------------------------------------------------------------===// diff --git a/include/llvm/CodeGen/MachineInstr.h b/include/llvm/CodeGen/MachineInstr.h index 31f4974..bcbcf31 100644 --- a/include/llvm/CodeGen/MachineInstr.h +++ b/include/llvm/CodeGen/MachineInstr.h @@ -16,9 +16,12 @@ #ifndef LLVM_CODEGEN_MACHINEINSTR_H #define LLVM_CODEGEN_MACHINEINSTR_H -#include "llvm/ADT/alist.h" +#include "llvm/ADT/ilist.h" +#include "llvm/ADT/ilist_node.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/CodeGen/MachineOperand.h" #include "llvm/CodeGen/MachineMemOperand.h" +#include <list> #include <vector> namespace llvm { @@ -31,13 +34,13 @@ class MachineFunction; //===----------------------------------------------------------------------===// /// MachineInstr - Representation of each machine instruction. /// -class MachineInstr { +class MachineInstr : public ilist_node<MachineInstr> { const TargetInstrDesc *TID; // Instruction descriptor. unsigned short NumImplicitOps; // Number of implicit operands (which // are determined at construction time). std::vector<MachineOperand> Operands; // the operands - alist<MachineMemOperand> MemOperands; // information on memory references + std::list<MachineMemOperand> MemOperands; // information on memory references MachineBasicBlock *Parent; // Pointer to the owning basic block. // OperandComplete - Return true if it's illegal to add a new operand @@ -47,8 +50,9 @@ class MachineInstr { void operator=(const MachineInstr&); // DO NOT IMPLEMENT // Intrusive list support - friend struct alist_traits<MachineInstr>; - friend struct alist_traits<MachineBasicBlock>; + friend struct ilist_traits<MachineInstr>; + friend struct ilist_traits<MachineBasicBlock>; + friend struct ilist_sentinel_traits<MachineInstr>; void setParent(MachineBasicBlock *P) { Parent = P; } /// MachineInstr ctor - This constructor creates a copy of the given @@ -105,13 +109,13 @@ public: unsigned getNumExplicitOperands() const; /// Access to memory operands of the instruction - alist<MachineMemOperand>::iterator memoperands_begin() + std::list<MachineMemOperand>::iterator memoperands_begin() { return MemOperands.begin(); } - alist<MachineMemOperand>::iterator memoperands_end() + std::list<MachineMemOperand>::iterator memoperands_end() { return MemOperands.end(); } - alist<MachineMemOperand>::const_iterator memoperands_begin() const + std::list<MachineMemOperand>::const_iterator memoperands_begin() const { return MemOperands.begin(); } - alist<MachineMemOperand>::const_iterator memoperands_end() const + std::list<MachineMemOperand>::const_iterator memoperands_end() const { return MemOperands.end(); } bool memoperands_empty() const { return MemOperands.empty(); } diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h index 692d902..49dbd43 100644 --- a/include/llvm/CodeGen/SelectionDAG.h +++ b/include/llvm/CodeGen/SelectionDAG.h @@ -15,6 +15,7 @@ #ifndef LLVM_CODEGEN_SELECTIONDAG_H #define LLVM_CODEGEN_SELECTIONDAG_H +#include "llvm/ADT/ilist.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/StringMap.h" #include "llvm/CodeGen/SelectionDAGNodes.h" @@ -26,13 +27,38 @@ #include <string> namespace llvm { - class AliasAnalysis; - class TargetLowering; - class TargetMachine; - class MachineModuleInfo; - class MachineFunction; - class MachineConstantPoolValue; - class FunctionLoweringInfo; + +class AliasAnalysis; +class TargetLowering; +class TargetMachine; +class MachineModuleInfo; +class MachineFunction; +class MachineConstantPoolValue; +class FunctionLoweringInfo; + +/// NodeAllocatorType - The AllocatorType for allocating SDNodes. We use +/// pool allocation with recycling. +/// +typedef RecyclingAllocator<BumpPtrAllocator, SDNode, sizeof(LargestSDNode), + AlignOf<MostAlignedSDNode>::Alignment> + NodeAllocatorType; + +template<> class ilist_traits<SDNode> : public ilist_default_traits<SDNode> { + mutable SDNode Sentinel; +public: + ilist_traits() : Sentinel(ISD::DELETED_NODE, SDVTList()) {} + + SDNode *createSentinel() const { + return &Sentinel; + } + static void destroySentinel(SDNode *) {} + + static void deleteNode(SDNode *) { + assert(0 && "ilist_traits<SDNode> shouldn't see a deleteNode call!"); + } +private: + static void createNode(const SDNode &); +}; /// SelectionDAG class - This is used to represent a portion of an LLVM function /// in a low-level Data Dependence DAG representation suitable for instruction @@ -55,7 +81,12 @@ class SelectionDAG { SDValue Root, EntryNode; /// AllNodes - A linked list of nodes in the current DAG. - alist<SDNode, LargestSDNode> &AllNodes; + ilist<SDNode> AllNodes; + + /// NodeAllocator - Pool allocation for nodes. The allocator isn't + /// allocated inside this class because we want to reuse a single + /// recycler across multiple SelectionDAG runs. + NodeAllocatorType &NodeAllocator; /// CSEMap - This structure is used to memoize nodes, automatically performing /// CSE with existing nodes with a duplicate is requested. @@ -71,8 +102,8 @@ class SelectionDAG { public: SelectionDAG(TargetLowering &tli, MachineFunction &mf, FunctionLoweringInfo &fli, MachineModuleInfo *mmi, - alist<SDNode, LargestSDNode> &NodePool) - : TLI(tli), MF(mf), FLI(fli), MMI(mmi), AllNodes(NodePool) { + NodeAllocatorType &nodeallocator) + : TLI(tli), MF(mf), FLI(fli), MMI(mmi), NodeAllocator(nodeallocator) { EntryNode = Root = getNode(ISD::EntryToken, MVT::Other); } ~SelectionDAG(); @@ -108,13 +139,13 @@ public: /// void setGraphColor(const SDNode *N, const char *Color); - typedef alist<SDNode, LargestSDNode>::const_iterator allnodes_const_iterator; + typedef ilist<SDNode>::const_iterator allnodes_const_iterator; allnodes_const_iterator allnodes_begin() const { return AllNodes.begin(); } allnodes_const_iterator allnodes_end() const { return AllNodes.end(); } - typedef alist<SDNode, LargestSDNode>::iterator allnodes_iterator; + typedef ilist<SDNode>::iterator allnodes_iterator; allnodes_iterator allnodes_begin() { return AllNodes.begin(); } allnodes_iterator allnodes_end() { return AllNodes.end(); } - alist<SDNode, LargestSDNode>::size_type allnodes_size() const { + ilist<SDNode>::size_type allnodes_size() const { return AllNodes.size(); } @@ -682,7 +713,6 @@ public: SDValue getShuffleScalarElt(const SDNode *N, unsigned Idx); private: - inline alist_traits<SDNode, LargestSDNode>::AllocatorType &getAllocator(); void RemoveNodeFromCSEMaps(SDNode *N); SDNode *AddNonLeafNodeToCSEMaps(SDNode *N); SDNode *FindModifiedNodeSlot(SDNode *N, SDValue Op, void *&InsertPos); diff --git a/include/llvm/CodeGen/SelectionDAGISel.h b/include/llvm/CodeGen/SelectionDAGISel.h index c384fa5..668e64e 100644 --- a/include/llvm/CodeGen/SelectionDAGISel.h +++ b/include/llvm/CodeGen/SelectionDAGISel.h @@ -182,7 +182,7 @@ private: FunctionLoweringInfo &FuncInfo); void SelectBasicBlock(BasicBlock *BB, MachineFunction &MF, FunctionLoweringInfo &FuncInfo, - alist<SDNode, LargestSDNode> &AllNodes); + NodeAllocatorType &NodeAllocator); void BuildSelectionDAG(SelectionDAG &DAG, BasicBlock *LLVMBB, std::vector<std::pair<MachineInstr*, unsigned> > &PHINodesToUpdate, diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h index d690732..dbb1294 100644 --- a/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/include/llvm/CodeGen/SelectionDAGNodes.h @@ -25,7 +25,8 @@ #include "llvm/ADT/iterator.h" #include "llvm/ADT/APFloat.h" #include "llvm/ADT/APInt.h" -#include "llvm/ADT/alist.h" +#include "llvm/ADT/ilist_node.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/CodeGen/ValueTypes.h" #include "llvm/CodeGen/MachineMemOperand.h" #include "llvm/Support/Allocator.h" @@ -43,6 +44,7 @@ class SDNode; class CompileUnitDesc; template <typename T> struct DenseMapInfo; template <typename T> struct simplify_type; +template <typename T> class ilist_traits; /// SDVTList - This represents a list of ValueType's that has been intern'd by /// a SelectionDAG. Instances of this simple value class are returned by @@ -1028,7 +1030,7 @@ public: /// SDNode - Represents one node in the SelectionDAG. /// -class SDNode : public FoldingSetNode { +class SDNode : public FoldingSetNode, public ilist_node<SDNode> { private: /// NodeType - The operation that this node performs. /// @@ -1268,6 +1270,7 @@ public: protected: friend class SelectionDAG; + friend class ilist_traits<SDNode>; /// getValueTypeList - Return a pointer to the specified value type. /// @@ -2236,27 +2239,10 @@ template <> struct GraphTraits<SDNode*> { /// typedef LoadSDNode LargestSDNode; -// alist_traits specialization for pool-allocating SDNodes. -template <> -class alist_traits<SDNode, LargestSDNode> { - typedef alist_iterator<SDNode, LargestSDNode> iterator; - -public: - // Pool-allocate and recycle SDNodes. - typedef RecyclingAllocator<BumpPtrAllocator, SDNode, LargestSDNode> - AllocatorType; - - // Allocate the allocator immediately inside the traits class. - AllocatorType Allocator; - - void addNodeToList(SDNode*) {} - void removeNodeFromList(SDNode*) {} - void transferNodesFromList(alist_traits &, iterator, iterator) {} - void deleteNode(SDNode *N) { - N->~SDNode(); - Allocator.Deallocate(N); - } -}; +/// MostAlignedSDNode - The SDNode class with the greatest alignment +/// requirement. +/// +typedef ConstantSDNode MostAlignedSDNode; namespace ISD { /// isNormalLoad - Returns true if the specified node is a non-extending |