diff options
Diffstat (limited to 'include/llvm/CodeGen')
-rw-r--r-- | include/llvm/CodeGen/MachineConstantPool.h | 5 | ||||
-rw-r--r-- | include/llvm/CodeGen/SelectionDAG.h | 6 | ||||
-rw-r--r-- | include/llvm/CodeGen/SelectionDAGCSEMap.h | 129 | ||||
-rw-r--r-- | include/llvm/CodeGen/SelectionDAGNodes.h | 22 |
4 files changed, 13 insertions, 149 deletions
diff --git a/include/llvm/CodeGen/MachineConstantPool.h b/include/llvm/CodeGen/MachineConstantPool.h index 1878b52727..17ddcf1823 100644 --- a/include/llvm/CodeGen/MachineConstantPool.h +++ b/include/llvm/CodeGen/MachineConstantPool.h @@ -15,7 +15,8 @@ #ifndef LLVM_CODEGEN_MACHINECONSTANTPOOL_H #define LLVM_CODEGEN_MACHINECONSTANTPOOL_H -#include "llvm/CodeGen/SelectionDAGCSEMap.h" +#include "llvm/ADT/FoldingSet.h" +#include "llvm/CodeGen/SelectionDAGNodes.h" #include <vector> #include <iosfwd> @@ -43,7 +44,7 @@ public: virtual int getExistingMachineCPValue(MachineConstantPool *CP, unsigned Alignment) = 0; - virtual void AddSelectionDAGCSEId(SelectionDAGCSEMap::NodeID *Id) = 0; + virtual void AddSelectionDAGCSEId(FoldingSetNodeID &ID) = 0; /// print - Implement operator<<... /// diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h index 6e343bd06f..58f869d89d 100644 --- a/include/llvm/CodeGen/SelectionDAG.h +++ b/include/llvm/CodeGen/SelectionDAG.h @@ -15,8 +15,9 @@ #ifndef LLVM_CODEGEN_SELECTIONDAG_H #define LLVM_CODEGEN_SELECTIONDAG_H -#include "llvm/CodeGen/SelectionDAGCSEMap.h" +#include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/ilist" +#include "llvm/CodeGen/SelectionDAGNodes.h" #include <list> #include <vector> @@ -31,6 +32,7 @@ namespace llvm { class MachineDebugInfo; class MachineFunction; class MachineConstantPoolValue; + class SDOperand; /// SelectionDAG class - This is used to represent a portion of an LLVM function /// in a low-level Data Dependence DAG representation suitable for instruction @@ -56,7 +58,7 @@ class SelectionDAG { /// CSEMap - This structure is used to memoize nodes, automatically performing /// CSE with existing nodes with a duplicate is requested. - SelectionDAGCSEMap CSEMap; + FoldingSet<SDNode> CSEMap; public: SelectionDAG(TargetLowering &tli, MachineFunction &mf, MachineDebugInfo *di) diff --git a/include/llvm/CodeGen/SelectionDAGCSEMap.h b/include/llvm/CodeGen/SelectionDAGCSEMap.h deleted file mode 100644 index 067cf1fd16..0000000000 --- a/include/llvm/CodeGen/SelectionDAGCSEMap.h +++ /dev/null @@ -1,129 +0,0 @@ -//===-- llvm/CodeGen/SelectionDAGCSEMap.h - CSE Map for SD ------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by Chris Lattner and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file declares the SelectionDAG class, and transitively defines the -// SDNode class and subclasses. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CODEGEN_SELECTIONDAGCSEMAP_H -#define LLVM_CODEGEN_SELECTIONDAGCSEMAP_H - -#include "llvm/ADT/SmallVector.h" -#include "llvm/CodeGen/SelectionDAGNodes.h" - -namespace llvm { - class SDNode; - class SDOperand; - struct SDVTList; - - /// SelectionDAGCSEMap - This class is used for two purposes: - /// 1. Given information (e.g. opcode and operand info) about a node we want - /// to create, look up the unique instance of the node in the map. If - /// the node already exists, return it, otherwise return the bucket it - /// should be inserted into. - /// 2. Given a node that has already been created, remove it from the CSE - /// map. - /// - /// This class is implemented as a chained hash table, where the "buckets" are - /// actually the SDNodes themselves (the next pointer is in the SDNode). - /// - class SelectionDAGCSEMap { - void **Buckets; - unsigned NumBuckets; // Always a power of 2. - unsigned NumNodes; - public: - class NodeID; - SelectionDAGCSEMap(); - ~SelectionDAGCSEMap(); - - /// RemoveNode - Remove a node from the CSE map, returning true if one was - /// removed or false if the node was not in the CSE map. - bool RemoveNode(SDNode *N); - - /// GetOrInsertSimpleNode - If there is an existing simple SDNode exactly - /// equal to the specified node, return it. Otherwise, insert 'N' and it - /// instead. This only works on *simple* SDNodes, not ConstantSDNode or any - /// other classes derived from SDNode. - SDNode *GetOrInsertNode(SDNode *N); - - /// FindNodeOrInsertPos - Look up the node specified by ID. If it exists, - /// return it. If not, return the insertion token that will make insertion - /// faster. - SDNode *FindNodeOrInsertPos(const NodeID &ID, void *&InsertPos); - - /// InsertNode - Insert the specified node into the CSE Map, knowing that it - /// is not already in the map. InsertPos must be obtained from - /// FindNodeOrInsertPos. - void InsertNode(SDNode *N, void *InsertPos); - - class NodeID { - /// Use a SmallVector to avoid a heap allocation in the common case. - /// - SmallVector<unsigned, 32> Bits; - public: - NodeID() {} - NodeID(SDNode *N); - NodeID(unsigned short ID, SDVTList VTList); - NodeID(unsigned short ID, SDVTList VTList, SDOperand Op); - NodeID(unsigned short ID, SDVTList VTList, - SDOperand Op1, SDOperand Op2); - NodeID(unsigned short ID, SDVTList VTList, - SDOperand Op1, SDOperand Op2, SDOperand Op3); - NodeID(unsigned short ID, SDVTList VTList, - const SDOperand *OpList, unsigned N); - - void SetOpcode(unsigned short ID) { - Bits.push_back(ID); - } - - /// getOpcode - Return the opcode that has been set for this NodeID. - /// - unsigned getOpcode() const { - return Bits[0]; - } - - void SetValueTypes(SDVTList VTList); - void SetOperands() {} - void SetOperands(SDOperand Op) { AddOperand(Op); } - void SetOperands(SDOperand Op1, SDOperand Op2) { - AddOperand(Op1); AddOperand(Op2); - } - void SetOperands(SDOperand Op1, SDOperand Op2, SDOperand Op3) { - AddOperand(Op1); AddOperand(Op2); AddOperand(Op3); - } - void SetOperands(const SDOperand *Ops, unsigned NumOps); - void AddOperand(SDOperand Op); - void AddPointer(const void *Ptr); - void AddInteger(signed I) { - Bits.push_back(I); - } - void AddInteger(unsigned I) { - Bits.push_back(I); - } - void AddInteger(uint64_t I) { - Bits.push_back(unsigned(I)); - Bits.push_back(unsigned(I >> 32)); - } - - unsigned ComputeHash() const; - - bool operator==(const NodeID &RHS) const; - }; - - private: - SDNode *GetNextPtr(void *NextInBucketPtr); - SDNode *GetNextPtr(void *NextInBucketPtr, void **Buckets, unsigned NumBuck); - void **GetBucketPtr(void *NextInBucketPtr); - void **GetBucketFor(const NodeID &ID) const; - void GrowHashTable(); - }; -} // end namespace llvm - -#endif diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h index 18afa69917..5dfb280a4f 100644 --- a/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/include/llvm/CodeGen/SelectionDAGNodes.h @@ -20,6 +20,7 @@ #define LLVM_CODEGEN_SELECTIONDAGNODES_H #include "llvm/Value.h" +#include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/GraphTraits.h" #include "llvm/ADT/iterator" #include "llvm/ADT/SmallVector.h" @@ -742,7 +743,7 @@ template<> struct simplify_type<const SDOperand> { /// SDNode - Represents one node in the SelectionDAG. /// -class SDNode { +class SDNode : public FoldingSetNode { /// NodeType - The operation that this node performs. /// unsigned short NodeType; @@ -766,9 +767,6 @@ class SDNode { SDNode *Prev, *Next; friend struct ilist_traits<SDNode>; - /// NextInBucket - This is used by the SelectionDAGCSEMap. - void *NextInBucket; - /// Uses - These are all of the SDNode's that use a value produced by this /// node. SmallVector<SDNode*,3> Uses; @@ -778,7 +776,6 @@ class SDNode { public: virtual ~SDNode() { assert(NumOperands == 0 && "Operand list not cleared before deletion"); - assert(NextInBucket == 0 && "Still in CSEMap?"); NodeType = ISD::DELETED_NODE; } @@ -863,11 +860,10 @@ public: static bool classof(const SDNode *) { return true; } - - /// NextInBucket accessors, these are private to SelectionDAGCSEMap. - void *getNextInBucket() const { return NextInBucket; } - void SetNextInBucket(void *N) { NextInBucket = N; } - + /// Profile - Gather unique data for the node. + /// + void Profile(FoldingSetNodeID &ID); + protected: friend class SelectionDAG; @@ -880,7 +876,6 @@ protected: ValueList = getValueTypeList(VT); NumValues = 1; Prev = 0; Next = 0; - NextInBucket = 0; } SDNode(unsigned NT, SDOperand Op) : NodeType(NT), NodeId(-1) { @@ -891,7 +886,6 @@ protected: ValueList = 0; NumValues = 0; Prev = 0; Next = 0; - NextInBucket = 0; } SDNode(unsigned NT, SDOperand N1, SDOperand N2) : NodeType(NT), NodeId(-1) { @@ -903,7 +897,6 @@ protected: ValueList = 0; NumValues = 0; Prev = 0; Next = 0; - NextInBucket = 0; } SDNode(unsigned NT, SDOperand N1, SDOperand N2, SDOperand N3) : NodeType(NT), NodeId(-1) { @@ -918,7 +911,6 @@ protected: ValueList = 0; NumValues = 0; Prev = 0; Next = 0; - NextInBucket = 0; } SDNode(unsigned NT, SDOperand N1, SDOperand N2, SDOperand N3, SDOperand N4) : NodeType(NT), NodeId(-1) { @@ -934,7 +926,6 @@ protected: ValueList = 0; NumValues = 0; Prev = 0; Next = 0; - NextInBucket = 0; } SDNode(unsigned Opc, const SDOperand *Ops, unsigned NumOps) : NodeType(Opc), NodeId(-1) { @@ -949,7 +940,6 @@ protected: ValueList = 0; NumValues = 0; Prev = 0; Next = 0; - NextInBucket = 0; } /// MorphNodeTo - This clears the return value and operands list, and sets the |