[llvm-commits] CVS: llvm/include/llvm/Function.h Module.h SymbolTable.h TypeSymbolTable.h

Reid Spencer reid at x10sys.com
Fri Jan 5 23:25:21 PST 2007



Changes in directory llvm/include/llvm:

Function.h updated: 1.68 -> 1.69
Module.h updated: 1.77 -> 1.78
SymbolTable.h updated: 1.53 -> 1.54
TypeSymbolTable.h updated: 1.4 -> 1.5
---
Log message:

For PR411: http://llvm.org/PR411 :
Take an incremental step towards type plane elimination. This change 
separates types from values in the symbol tables by finally making use
of the TypeSymbolTable class. This yields more natural interfaces for
dealing with types and unclutters the SymbolTable class.


---
Diffs of the changes:  (+14 -58)

 Function.h        |    4 ++--
 Module.h          |   12 +++++++++---
 SymbolTable.h     |   52 +---------------------------------------------------
 TypeSymbolTable.h |    4 ++--
 4 files changed, 14 insertions(+), 58 deletions(-)


Index: llvm/include/llvm/Function.h
diff -u llvm/include/llvm/Function.h:1.68 llvm/include/llvm/Function.h:1.69
--- llvm/include/llvm/Function.h:1.68	Sat Dec 16 23:15:12 2006
+++ llvm/include/llvm/Function.h	Sat Jan  6 01:24:43 2007
@@ -163,8 +163,8 @@
 
   /// getSymbolTable() - Return the symbol table...
   ///
-  inline       SymbolTable &getSymbolTable()       { return *SymTab; }
-  inline const SymbolTable &getSymbolTable() const { return *SymTab; }
+  inline       SymbolTable &getValueSymbolTable()       { return *SymTab; }
+  inline const SymbolTable &getValueSymbolTable() const { return *SymTab; }
 
 
   //===--------------------------------------------------------------------===//


Index: llvm/include/llvm/Module.h
diff -u llvm/include/llvm/Module.h:1.77 llvm/include/llvm/Module.h:1.78
--- llvm/include/llvm/Module.h:1.77	Sat Dec 16 23:15:12 2006
+++ llvm/include/llvm/Module.h	Sat Jan  6 01:24:43 2007
@@ -25,6 +25,7 @@
 class GlobalValueRefMap;   // Used by ConstantVals.cpp
 class FunctionType;
 class SymbolTable;
+class TypeSymbolTable;
 
 template<> struct ilist_traits<Function>
   : public SymbolTableListTraits<Function, Module, Module> {
@@ -91,7 +92,8 @@
   FunctionListType FunctionList; ///< The Functions in the module
   LibraryListType LibraryList;   ///< The Libraries needed by the module
   std::string GlobalScopeAsm;    ///< Inline Asm at global scope.
-  SymbolTable *SymTab;           ///< Symbol Table for the module
+  SymbolTable *ValSymTab;        ///< Symbol table for values
+  TypeSymbolTable *TypeSymTab;   ///< Symbol table for types
   std::string ModuleID;          ///< Human readable identifier for the module
   std::string TargetTriple;      ///< Platform target triple Module compiled on
   std::string DataLayout;        ///< Target data description
@@ -237,9 +239,13 @@
   /// Get the Module's list of functions.
   FunctionListType       &getFunctionList()           { return FunctionList; }
   /// Get the symbol table of global variable and function identifiers
-  const SymbolTable      &getSymbolTable() const      { return *SymTab; }
+  const SymbolTable      &getValueSymbolTable() const { return *ValSymTab; }
   /// Get the Module's symbol table of global variable and function identifiers.
-  SymbolTable            &getSymbolTable()            { return *SymTab; }
+  SymbolTable            &getValueSymbolTable()       { return *ValSymTab; }
+  /// Get the symbol table of types
+  const TypeSymbolTable   &getTypeSymbolTable() const { return *TypeSymTab; }
+  /// Get the Module's symbol table of types
+  TypeSymbolTable         &getTypeSymbolTable()       { return *TypeSymTab; }
 
 /// @}
 /// @name Global Variable Iteration


Index: llvm/include/llvm/SymbolTable.h
diff -u llvm/include/llvm/SymbolTable.h:1.53 llvm/include/llvm/SymbolTable.h:1.54
--- llvm/include/llvm/SymbolTable.h:1.53	Wed May 31 15:40:36 2006
+++ llvm/include/llvm/SymbolTable.h	Sat Jan  6 01:24:43 2007
@@ -47,16 +47,6 @@
 /// @name Types
 /// @{
 public:
-
-  /// @brief A mapping of names to types.
-  typedef std::map<const std::string, const Type*> TypeMap;
-
-  /// @brief An iterator over the TypeMap.
-  typedef TypeMap::iterator type_iterator;
-
-  /// @brief A const_iterator over the TypeMap.
-  typedef TypeMap::const_iterator type_const_iterator;
-
   /// @brief A mapping of names to values.
   typedef std::map<const std::string, Value *> ValueMap;
 
@@ -96,20 +86,10 @@
   /// @brief Lookup a named, typed value.
   Value *lookup(const Type *Ty, const std::string &name) const;
 
-  /// This method finds the type with the given \p name in the
-  /// type  map and returns it.
-  /// @returns null if the name is not found, otherwise the Type
-  /// associated with the \p name.
-  /// @brief Lookup a type by name.
-  Type* lookupType(const std::string& name) const;
-
   /// @returns true iff the type map and the type plane are both not
   /// empty.
   /// @brief Determine if the symbol table is empty
-  inline bool isEmpty() const { return pmap.empty() && tmap.empty(); }
-
-  /// @brief The number of name/type pairs is returned.
-  inline unsigned num_types() const { return unsigned(tmap.size()); }
+  inline bool isEmpty() const { return pmap.empty(); }
 
   /// Given a base name, return a string that is either equal to it or
   /// derived from it that does not already occur in the symbol table
@@ -178,20 +158,6 @@
     return pmap.find(Typ)->second.end();
   }
 
-  /// Get an iterator to the start of the name/Type map.
-  inline type_iterator type_begin() { return tmap.begin(); }
-
-  /// @brief Get a const_iterator to the start of the name/Type map.
-  inline type_const_iterator type_begin() const { return tmap.begin(); }
-
-  /// Get an iterator to the end of the name/Type map. This serves as the
-  /// marker for end of iteration of the types.
-  inline type_iterator type_end() { return tmap.end(); }
-
-  /// Get a const-iterator to the end of the name/Type map. This serves
-  /// as the marker for end of iteration of the types.
-  inline type_const_iterator type_end() const { return tmap.end(); }
-
   /// This method returns a plane_const_iterator for iteration over
   /// the type planes starting at a specific plane, given by \p Ty.
   /// @brief Find a type plane.
@@ -219,16 +185,6 @@
   /// @brief Strip the symbol table.
   bool strip();
 
-  /// Inserts a type into the symbol table with the specified name. There can be
-  /// a many-to-one mapping between names and types. This method allows a type
-  /// with an existing entry in the symbol table to get a new name.
-  /// @brief Insert a type under a new name.
-  void insert(const std::string &Name, const Type *Typ);
-
-  /// Remove a type at the specified position in the symbol table.
-  /// @returns the removed Type.
-  Type* remove(type_iterator TI);
-
 /// @}
 /// @name Mutators used by Value::setName and other LLVM internals.
 /// @{
@@ -286,15 +242,9 @@
   /// @brief The mapping of types to names to values.
   PlaneMap pmap;
 
-  /// This is the type plane. It is separated from the pmap
-  /// because the elements of the map are name/Type pairs not
-  /// name/Value pairs and Type is not a Value.
-  TypeMap tmap;
-
   /// This value is used to retain the last unique value used
   /// by getUniqueName to generate unique names.
   mutable uint32_t LastUnique;
-
 /// @}
 
 };


Index: llvm/include/llvm/TypeSymbolTable.h
diff -u llvm/include/llvm/TypeSymbolTable.h:1.4 llvm/include/llvm/TypeSymbolTable.h:1.5
--- llvm/include/llvm/TypeSymbolTable.h:1.4	Wed May 31 15:40:34 2006
+++ llvm/include/llvm/TypeSymbolTable.h	Sat Jan  6 01:24:43 2007
@@ -111,12 +111,12 @@
   /// Remove a type at the specified position in the symbol table.
   /// @returns the removed Type.
   /// @returns the Type that was erased from the symbol table.
-  Type* erase(iterator TI);
+  Type* remove(iterator TI);
 
   /// Remove a specific Type from the symbol table. This isn't fast, linear
   /// search, O(n), algorithm.
   /// @returns true if the erase was successful (TI was found)
-  bool erase(Type* TI);
+  bool remove(Type* TI);
 
   /// Rename a type. This ain't fast, we have to linearly search for it first.
   /// @returns true if the rename was successful (type was found)






More information about the llvm-commits mailing list