X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FTypeSymbolTable.h;h=55b8b7a3d9aff26f80d5e77aea5f4055b68fb60f;hb=7293ac12811c8a43023830380e70c0fda941f8ec;hp=a31525bdc7cd92135e641096ac5db6143d9d90fb;hpb=0cf4bc79959e6dd1f0a31a7c7cf91da0f32c0b8d;p=oota-llvm.git diff --git a/include/llvm/TypeSymbolTable.h b/include/llvm/TypeSymbolTable.h index a31525bdc7c..55b8b7a3d9a 100644 --- a/include/llvm/TypeSymbolTable.h +++ b/include/llvm/TypeSymbolTable.h @@ -2,8 +2,8 @@ // // The LLVM Compiler Infrastructure // -// This file was developed by Reid Spencer. It is distributed under the -// University of Illinois Open Source License. See LICENSE.TXT for details. +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // @@ -15,6 +15,8 @@ #define LLVM_TYPE_SYMBOL_TABLE_H #include "llvm/Type.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/System/DataTypes.h" #include namespace llvm { @@ -43,7 +45,7 @@ public: /// @{ public: - TypeSymbolTable() {} + TypeSymbolTable():LastUnique(0) {} ~TypeSymbolTable(); /// @} @@ -55,14 +57,28 @@ public: /// incrementing an integer and appending it to the name, if necessary /// @returns the unique name /// @brief Get a unique name for a type - std::string getUniqueName(const std::string &BaseName) const; + std::string getUniqueName(StringRef BaseName) 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* lookup(const std::string& name) const; + Type *lookup(StringRef name) const; + + /// Lookup the type associated with name. + /// @returns end() if the name is not found, or an iterator at the entry for + /// Type. + iterator find(StringRef Name) { + return tmap.find(Name); + } + + /// Lookup the type associated with name. + /// @returns end() if the name is not found, or an iterator at the entry for + /// Type. + const_iterator find(StringRef Name) const { + return tmap.find(Name); + } /// @returns true iff the symbol table is empty. /// @brief Determine if the symbol table is empty @@ -87,7 +103,7 @@ public: /// @brief Get a const_iterator to the start of the symbol table inline const_iterator begin() const { return tmap.begin(); } - /// Get an iterator to the end of the symbol talbe. + /// Get an iterator to the end of the symbol table. inline iterator end() { return tmap.end(); } /// Get a const_iterator to the end of the symbol table. @@ -98,29 +114,16 @@ public: /// @{ public: - /// This method will strip the symbol table of its names - /// @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); + void insert(StringRef Name, const Type *Typ); /// 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); - - /// 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); - - /// 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) - bool rename(Type* T, const std::string& new_name); + Type* remove(iterator TI); /// @} /// @name AbstractTypeUser Methods @@ -138,7 +141,7 @@ private: /// @{ private: TypeMap tmap; ///< This is the mapping of names to types. - mutable unsigned long LastUnique; ///< Counter for tracking unique names + mutable uint32_t LastUnique; ///< Counter for tracking unique names /// @} @@ -147,4 +150,3 @@ private: } // End llvm namespace #endif -