[llvm-commits] [llvm] r66336 - in /llvm/trunk: include/llvm/BasicBlock.h include/llvm/Module.h include/llvm/SymbolTableListTraits.h lib/VMCore/BasicBlock.cpp

Gabor Greif ggreif at gmail.com
Sat Mar 7 04:33:25 PST 2009


Author: ggreif
Date: Sat Mar  7 06:33:24 2009
New Revision: 66336

URL: http://llvm.org/viewvc/llvm-project?rev=66336&view=rev
Log:
simplify the way how traits get hold of the symbol table

Modified:
    llvm/trunk/include/llvm/BasicBlock.h
    llvm/trunk/include/llvm/Module.h
    llvm/trunk/include/llvm/SymbolTableListTraits.h
    llvm/trunk/lib/VMCore/BasicBlock.cpp

Modified: llvm/trunk/include/llvm/BasicBlock.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/BasicBlock.h?rev=66336&r1=66335&r2=66336&view=diff

==============================================================================
--- llvm/trunk/include/llvm/BasicBlock.h (original)
+++ llvm/trunk/include/llvm/BasicBlock.h Sat Mar  7 06:33:24 2009
@@ -45,8 +45,6 @@
   Instruction *provideInitialHead() const { return createSentinel(); }
   Instruction *ensureHead(Instruction*) const { return createSentinel(); }
   static void noteHead(Instruction*, Instruction*) {}
-
-  static ValueSymbolTable *getSymTab(BasicBlock *ItemParent);
 private:
   mutable ilist_node<Instruction> Sentinel;
 };
@@ -184,10 +182,15 @@
   ///
   const InstListType &getInstList() const { return InstList; }
         InstListType &getInstList()       { return InstList; }
+
+  /// getSublistAccess() - returns pointer to member of instruction list
   static iplist<Instruction> BasicBlock::*getSublistAccess(Instruction*) {
     return &BasicBlock::InstList;
   }
 
+  /// getValueSymbolTable() - returns pointer to symbol table (if any)
+  ValueSymbolTable *getValueSymbolTable();
+
   /// Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const BasicBlock *) { return true; }
   static inline bool classof(const Value *V) {

Modified: llvm/trunk/include/llvm/Module.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Module.h?rev=66336&r1=66335&r2=66336&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Module.h (original)
+++ llvm/trunk/include/llvm/Module.h Sat Mar  7 06:33:24 2009
@@ -31,21 +31,18 @@
   // createSentinel is used to create a node that marks the end of the list.
   static Function *createSentinel();
   static void destroySentinel(Function *F) { delete F; }
-  static inline ValueSymbolTable *getSymTab(Module *M);
 };
 template<> struct ilist_traits<GlobalVariable>
   : public SymbolTableListTraits<GlobalVariable, Module> {
   // createSentinel is used to create a node that marks the end of the list.
   static GlobalVariable *createSentinel();
   static void destroySentinel(GlobalVariable *GV) { delete GV; }
-  static inline ValueSymbolTable *getSymTab(Module *M);
 };
 template<> struct ilist_traits<GlobalAlias>
   : public SymbolTableListTraits<GlobalAlias, Module> {
   // createSentinel is used to create a node that marks the end of the list.
   static GlobalAlias *createSentinel();
   static void destroySentinel(GlobalAlias *GA) { delete GA; }
-  static inline ValueSymbolTable *getSymTab(Module *M);
 };
 
 /// A Module instance is used to store all the information related to an
@@ -409,22 +406,6 @@
   M.print(O, 0);
   return O;
 }
-  
-
-inline ValueSymbolTable *
-ilist_traits<Function>::getSymTab(Module *M) {
-  return M ? &M->getValueSymbolTable() : 0;
-}
-
-inline ValueSymbolTable *
-ilist_traits<GlobalVariable>::getSymTab(Module *M) {
-  return M ? &M->getValueSymbolTable() : 0;
-}
-
-inline ValueSymbolTable *
-ilist_traits<GlobalAlias>::getSymTab(Module *M) {
-  return M ? &M->getValueSymbolTable() : 0;
-}
 
 } // End llvm namespace
 

Modified: llvm/trunk/include/llvm/SymbolTableListTraits.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/SymbolTableListTraits.h?rev=66336&r1=66335&r2=66336&view=diff

==============================================================================
--- llvm/trunk/include/llvm/SymbolTableListTraits.h (original)
+++ llvm/trunk/include/llvm/SymbolTableListTraits.h Sat Mar  7 06:33:24 2009
@@ -55,8 +55,12 @@
   }
 
   static iplist<ValueSubClass> &getList(ItemParentClass *Par) {
-  return Par->*(Par->getSublistAccess((ValueSubClass*)0));
-}
+    return Par->*(Par->getSublistAccess((ValueSubClass*)0));
+  }
+
+  static ValueSymbolTable *getSymTab(ItemParentClass *Par) {
+    return Par ? toPtr(Par->getValueSymbolTable()) : 0;
+  }
 
   void addNodeToList(ValueSubClass *V);
   void removeNodeFromList(ValueSubClass *V);
@@ -66,6 +70,8 @@
 //private:
   template<typename TPtr>
   void setSymTabObject(TPtr *, TPtr);
+  static ValueSymbolTable *toPtr(ValueSymbolTable *P) { return P; }
+  static ValueSymbolTable *toPtr(ValueSymbolTable &R) { return &R; }
 };
 
 } // End llvm namespace

Modified: llvm/trunk/lib/VMCore/BasicBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/BasicBlock.cpp?rev=66336&r1=66335&r2=66336&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/BasicBlock.cpp (original)
+++ llvm/trunk/lib/VMCore/BasicBlock.cpp Sat Mar  7 06:33:24 2009
@@ -23,11 +23,9 @@
 #include <algorithm>
 using namespace llvm;
 
-inline ValueSymbolTable *
-ilist_traits<Instruction>::getSymTab(BasicBlock *BB) {
-  if (BB)
-    if (Function *F = BB->getParent())
-      return &F->getValueSymbolTable();
+ValueSymbolTable *BasicBlock::getValueSymbolTable() {
+  if (Function *F = getParent())
+    return &F->getValueSymbolTable();
   return 0;
 }
 





More information about the llvm-commits mailing list