LLVM API Documentation
#include <SymbolTable.h>
Inheritance diagram for llvm::SymbolTable:
Public Types | |
Types | |
typedef std::map< const std::string, const Type * > | TypeMap |
A mapping of names to types. | |
typedef TypeMap::iterator | type_iterator |
An iterator over the TypeMap. | |
typedef TypeMap::const_iterator | type_const_iterator |
A const_iterator over the TypeMap. | |
typedef std::map< const std::string, Value * > | ValueMap |
A mapping of names to values. | |
typedef ValueMap::iterator | value_iterator |
An iterator over a ValueMap. | |
typedef ValueMap::const_iterator | value_const_iterator |
A const_iterator over a ValueMap. | |
typedef std::map< const Type *, ValueMap > | PlaneMap |
A mapping of types to names to values (type planes). | |
typedef PlaneMap::iterator | plane_iterator |
An iterator over the type planes. | |
typedef PlaneMap::const_iterator | plane_const_iterator |
A const_iterator over the type planes. | |
Public Member Functions | |
Constructors | |
SymbolTable () | |
~SymbolTable () | |
Accessors | |
Value * | lookup (const Type *Ty, const std::string &name) const |
Lookup a named, typed value. | |
Type * | lookupType (const std::string &name) const |
Lookup a type by name. | |
bool | isEmpty () const |
Determine if the symbol table is empty. | |
unsigned | num_types () const |
The number of name/type pairs is returned. | |
std::string | getUniqueName (const Type *Ty, const std::string &BaseName) const |
Get a name unique to this symbol table. | |
void | dump () const |
Print out symbol table on stderr. | |
Iteration | |
plane_iterator | plane_begin () |
plane_const_iterator | plane_begin () const |
plane_iterator | plane_end () |
plane_const_iterator | plane_end () const |
value_iterator | value_begin (const Type *Typ) |
value_const_iterator | value_begin (const Type *Typ) const |
value_iterator | value_end (const Type *Typ) |
value_const_iterator | value_end (const Type *Typ) const |
type_iterator | type_begin () |
Get an iterator to the start of the name/Type map. | |
type_const_iterator | type_begin () const |
Get a const_iterator to the start of the name/Type map. | |
type_iterator | type_end () |
type_const_iterator | type_end () const |
plane_const_iterator | find (const Type *Typ) const |
Find a type plane. | |
plane_iterator | find (const Type *Typ) |
Find a type plane. | |
Mutators | |
bool | strip () |
Strip the symbol table. | |
void | insert (const std::string &Name, const Type *Typ) |
Insert a type under a new name. | |
Type * | remove (type_iterator TI) |
Mutators used by Value::setName and other LLVM internals. | |
void | insert (Value *Val) |
Add a named value to the symbol table. | |
void | remove (Value *Val) |
Remove a named value from the symbol table. | |
void | changeName (Value *V, const std::string &Name) |
The SymbolTable provides several utility functions for answering common questions about its contents as well as an iterator interface for directly iterating over the contents. To reduce confusion, the terms "type", "value", and "plane" are used consistently. For example, There is a TypeMap typedef that is the mapping of names to Types. Similarly there is a ValueMap typedef that is the mapping of names to Values. Finally, there is a PlaneMap typedef that is the mapping of types to planes of ValueMap. This is the basic structure of the symbol table. When you call type_begin() you're asking for an iterator at the start of the TypeMap. When you call plane_begin(), you're asking for an iterator at the start of the PlaneMap. Finally, when you call value_begin(), you're asking for an iterator at the start of a ValueMap for a specific type plane.
Definition at line 44 of file SymbolTable.h.
typedef PlaneMap::const_iterator llvm::SymbolTable::plane_const_iterator |
typedef std::map<const Type *, ValueMap> llvm::SymbolTable::PlaneMap |
typedef TypeMap::const_iterator llvm::SymbolTable::type_const_iterator |
typedef std::map<const std::string, const Type*> llvm::SymbolTable::TypeMap |
typedef ValueMap::const_iterator llvm::SymbolTable::value_const_iterator |
typedef std::map<const std::string, Value *> llvm::SymbolTable::ValueMap |
llvm::SymbolTable::SymbolTable | ( | ) | [inline] |
Definition at line 82 of file SymbolTable.h.
SymbolTable::~SymbolTable | ( | ) |
void SymbolTable::changeName | ( | Value * | V, | |
const std::string & | Name | |||
) |
changeName - Given a value with a non-empty name, remove its existing entry from the symbol table and insert a new one for Name. This is equivalent to doing "remove(V), V->Name = Name, insert(V)", but is faster, and will not temporarily remove the symbol table plane if V is the last value in the symtab with that name (which could invalidate iterators to that plane).
Definition at line 99 of file SymbolTable.cpp.
References getUniqueName(), PI, and V.
Referenced by llvm::Value::setName().
void SymbolTable::dump | ( | ) | const [virtual] |
Print out symbol table on stderr.
This function can be used from the debugger to display the content of the symbol table while debugging.
Implements llvm::AbstractTypeUser.
Definition at line 439 of file SymbolTable.cpp.
References DumpPlane(), and DumpTypes().
plane_iterator llvm::SymbolTable::find | ( | const Type * | Typ | ) | [inline] |
Find a type plane.
This method returns a plane_iterator for iteration over the type planes starting at a specific plane, given by Ty
.
Definition at line 205 of file SymbolTable.h.
plane_const_iterator llvm::SymbolTable::find | ( | const Type * | Typ | ) | const [inline] |
Find a type plane.
This method returns a plane_const_iterator for iteration over the type planes starting at a specific plane, given by Ty
.
Definition at line 197 of file SymbolTable.h.
Referenced by llvm::Function::renameLocalSymbols().
std::string SymbolTable::getUniqueName | ( | const Type * | Ty, | |
const std::string & | BaseName | |||
) | const |
Get a name unique to this symbol table.
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 for the specified type.
Definition at line 57 of file SymbolTable.cpp.
References PI, Ty, and llvm::utostr().
Referenced by changeName(), and insert().
void llvm::SymbolTable::insert | ( | Value * | Val | ) | [inline] |
Add a named value to the symbol table.
This method adds the provided value N
to the symbol table. The Value must have both a name and a type which are extracted and used to place the value in the correct type plane under the value's name.
Definition at line 240 of file SymbolTable.h.
References llvm::Value::getName(), llvm::Value::getType(), llvm::Value::hasName(), and Val.
void SymbolTable::insert | ( | const std::string & | Name, | |
const Type * | Typ | |||
) |
Insert a type under a new name.
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.
Definition at line 236 of file SymbolTable.cpp.
References dump(), llvm::Type::getDescription(), getUniqueName(), llvm::Type::isAbstract(), lookupType(), and T.
Referenced by llvm::Module::addTypeName(), llvm::BytecodeReader::ParseSymbolTable(), ResolveTypes(), and llvm::Value::setName().
bool llvm::SymbolTable::isEmpty | ( | ) | const [inline] |
Determine if the symbol table is empty.
Definition at line 108 of file SymbolTable.h.
Lookup a named, typed value.
This method finds the value with the given name
in the type plane Ty
and returns it. This method will not find any Types, only Values. Use lookupType to find Types by name.
name
in type plane Ty
. Definition at line 75 of file SymbolTable.cpp.
Referenced by ForceRenaming(), llvm::Module::getFunction(), llvm::Module::getOrInsertFunction(), lookupInSymbolTable(), and setValueName().
Type * SymbolTable::lookupType | ( | const std::string & | name | ) | const |
Lookup a type by name.
This method finds the type with the given name
in the type map and returns it.
name
. Definition at line 87 of file SymbolTable.cpp.
Referenced by llvm::Module::addTypeName(), llvm::Module::getTypeByName(), insert(), and LinkTypes().
unsigned llvm::SymbolTable::num_types | ( | ) | const [inline] |
plane_const_iterator llvm::SymbolTable::plane_begin | ( | ) | const [inline] |
Get a const_iterator that starts at the beginning of the type planes. The iterator will iterate over the Type/ValueMap pairs in the type planes.
Definition at line 138 of file SymbolTable.h.
plane_iterator llvm::SymbolTable::plane_begin | ( | ) | [inline] |
Get an iterator that starts at the beginning of the type planes. The iterator will iterate over the Type/ValueMap pairs in the type planes.
Definition at line 133 of file SymbolTable.h.
Referenced by llvm::SlotCalculator::getPlane(), and llvm::Function::renameLocalSymbols().
plane_const_iterator llvm::SymbolTable::plane_end | ( | ) | const [inline] |
Get a const_iterator at the end of the type planes. This serves as the marker for end of iteration over the type planes.
Definition at line 146 of file SymbolTable.h.
plane_iterator llvm::SymbolTable::plane_end | ( | ) | [inline] |
Get an iterator at the end of the type planes. This serves as the marker for end of iteration over the type planes.
Definition at line 142 of file SymbolTable.h.
Referenced by llvm::SlotCalculator::getPlane(), and llvm::Function::renameLocalSymbols().
void SymbolTable::remove | ( | Value * | Val | ) |
Remove a named value from the symbol table.
This method removes a named value from the symbol table. The type and name of the Value are extracted from N
and used to lookup the Value in the correct type plane. If the Value is not in the symbol table, this method silently ignores the request.
Definition at line 127 of file SymbolTable.cpp.
References DEBUG_ABSTYPE, dump(), llvm::Type::getDescription(), llvm::Value::getName(), llvm::Value::getType(), llvm::Value::hasName(), llvm::Type::isAbstract(), and PI.
Type * SymbolTable::remove | ( | type_iterator | TI | ) |
Remove a type at the specified position in the symbol table.
Definition at line 163 of file SymbolTable.cpp.
References DEBUG_ABSTYPE, and dump().
Referenced by llvm::Value::setName(), and strip().
bool SymbolTable::strip | ( | ) |
type_const_iterator llvm::SymbolTable::type_begin | ( | ) | const [inline] |
Get a const_iterator to the start of the name/Type map.
Definition at line 184 of file SymbolTable.h.
type_iterator llvm::SymbolTable::type_begin | ( | ) | [inline] |
Get an iterator to the start of the name/Type map.
Definition at line 181 of file SymbolTable.h.
Referenced by llvm::CloneModule(), fillTypeNameTable(), llvm::SlotCalculator::getPlane(), llvm::Module::getTypeName(), and LinkTypes().
type_const_iterator llvm::SymbolTable::type_end | ( | ) | const [inline] |
Get a const-iterator to the end of the name/Type map. This serves as the marker for end of iteration of the types.
Definition at line 192 of file SymbolTable.h.
type_iterator llvm::SymbolTable::type_end | ( | ) | [inline] |
Get an iterator to the end of the name/Type map. This serves as the marker for end of iteration of the types.
Definition at line 188 of file SymbolTable.h.
Referenced by llvm::CloneModule(), fillTypeNameTable(), llvm::SlotCalculator::getPlane(), llvm::Module::getTypeName(), and LinkTypes().
value_const_iterator llvm::SymbolTable::value_begin | ( | const Type * | Typ | ) | const [inline] |
Get a const_iterator that starts at the beginning of a type plane. The iterator will iterate over the name/value pairs in the type plane.
Definition at line 159 of file SymbolTable.h.
value_iterator llvm::SymbolTable::value_begin | ( | const Type * | Typ | ) | [inline] |
Get an iterator that starts at the beginning of a type plane. The iterator will iterate over the name/value pairs in the type plane.
Definition at line 151 of file SymbolTable.h.
value_const_iterator llvm::SymbolTable::value_end | ( | const Type * | Typ | ) | const [inline] |
Get a const_iterator to the end of a type plane. This serves as the marker for end of iteration of the type plane.
Definition at line 175 of file SymbolTable.h.
value_iterator llvm::SymbolTable::value_end | ( | const Type * | Typ | ) | [inline] |
Get an iterator to the end of a type plane. This serves as the marker for end of iteration of the type plane.
Definition at line 167 of file SymbolTable.h.