aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/SymbolTableListTraits.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-06-25 16:12:52 +0000
committerChris Lattner <sabre@nondot.org>2002-06-25 16:12:52 +0000
commit18961504fc2b299578dba817900a0696cf3ccc4d (patch)
treec34853ffc064b841932d0897e25305c81c3a7338 /include/llvm/SymbolTableListTraits.h
parenta2204e1ff25265a1da00ecbb3ebb22c05acf7194 (diff)
downloadexternal_llvm-18961504fc2b299578dba817900a0696cf3ccc4d.tar.gz
external_llvm-18961504fc2b299578dba817900a0696cf3ccc4d.tar.bz2
external_llvm-18961504fc2b299578dba817900a0696cf3ccc4d.zip
*** empty log message ***
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2777 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/SymbolTableListTraits.h')
-rw-r--r--include/llvm/SymbolTableListTraits.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/include/llvm/SymbolTableListTraits.h b/include/llvm/SymbolTableListTraits.h
new file mode 100644
index 0000000000..74aede11a3
--- /dev/null
+++ b/include/llvm/SymbolTableListTraits.h
@@ -0,0 +1,68 @@
+//===-- llvm/SymbolTableListTraits.h - Traits for iplist -------*- C++ -*--===//
+//
+// This file defines a generic class that is used to implement the automatic
+// symbol table manipulation that occurs when you put (for example) a named
+// instruction into a basic block.
+//
+// The way that this is implemented is by using a special traits class with the
+// intrusive list that makes up the list of instructions in a basic block. When
+// a new element is added to the list of instructions, the traits class is
+// notified, allowing the symbol table to be updated.
+//
+// This generic class implements the traits class. It must be generic so that
+// it can work for all uses it, which include lists of instructions, basic
+// blocks, arguments, functions, global variables, etc...
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SYMBOLTABLELISTTRAITS_H
+#define LLVM_SYMBOLTABLELISTTRAITS_H
+
+template<typename NodeTy> class ilist_iterator;
+template<typename NodeTy, typename Traits> class iplist;
+template<typename Ty> struct ilist_traits;
+
+// ValueSubClass - The type of objects that I hold
+// ItemParentType - I call setParent() on all of my "ValueSubclass" items, and
+// this is the value that I pass in.
+// SymTabType - This is the class type, whose symtab I insert my
+// ValueSubClass items into. Most of the time it is
+// ItemParentType, but Instructions have item parents of BB's
+// but symtabtype's of a Function
+//
+template<typename ValueSubClass, typename ItemParentClass, typename SymTabClass,
+ typename SubClass=ilist_traits<ValueSubClass> >
+class SymbolTableListTraits {
+ SymTabClass *SymTabObject;
+ ItemParentClass *ItemParent;
+public:
+ SymbolTableListTraits() : SymTabObject(0), ItemParent(0) {}
+
+ SymTabClass *getParent() { return SymTabObject; }
+ const SymTabClass *getParent() const { return SymTabObject; }
+
+ static ValueSubClass *getPrev(ValueSubClass *V) { return V->getPrev(); }
+ static ValueSubClass *getNext(ValueSubClass *V) { return V->getNext(); }
+ static const ValueSubClass *getPrev(const ValueSubClass *V) {
+ return V->getPrev();
+ }
+ static const ValueSubClass *getNext(const ValueSubClass *V) {
+ return V->getNext();
+ }
+
+ static void setPrev(ValueSubClass *V, ValueSubClass *P) { V->setPrev(P); }
+ static void setNext(ValueSubClass *V, ValueSubClass *N) { V->setNext(N); }
+
+ void addNodeToList(ValueSubClass *V);
+ void removeNodeFromList(ValueSubClass *V);
+ void transferNodesFromList(iplist<ValueSubClass,
+ ilist_traits<ValueSubClass> > &L2,
+ ilist_iterator<ValueSubClass> first,
+ ilist_iterator<ValueSubClass> last);
+
+//private:
+ void setItemParent(ItemParentClass *IP) { ItemParent = IP; }//This is private!
+ void setParent(SymTabClass *Parent); // This is private!
+};
+
+#endif