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 | |
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 45 of file SymbolTable.h.
typedef std::map<const std::string, const Type*> llvm::SymbolTable::TypeMap |
typedef TypeMap::const_iterator llvm::SymbolTable::type_const_iterator |
typedef std::map<const std::string, Value *> llvm::SymbolTable::ValueMap |
typedef ValueMap::iterator llvm::SymbolTable::value_iterator |
typedef ValueMap::const_iterator llvm::SymbolTable::value_const_iterator |
typedef std::map<const Type *, ValueMap> llvm::SymbolTable::PlaneMap |
typedef PlaneMap::iterator llvm::SymbolTable::plane_iterator |
typedef PlaneMap::const_iterator llvm::SymbolTable::plane_const_iterator |
llvm::SymbolTable::SymbolTable | ( | ) | [inline] |
Definition at line 83 of file SymbolTable.h.
SymbolTable::~SymbolTable | ( | ) |
llvm::SymbolTable::SymbolTable | ( | ) | [inline] |
Definition at line 83 of file SymbolTable.h.
SymbolTable::~SymbolTable | ( | ) |
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().
bool llvm::SymbolTable::isEmpty | ( | ) | const [inline] |
Determine if the symbol table is empty.
Definition at line 109 of file SymbolTable.h.
unsigned llvm::SymbolTable::num_types | ( | ) | const [inline] |
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 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::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 134 of file SymbolTable.h.
Referenced by llvm::SlotCalculator::getPlane(), and llvm::Function::renameLocalSymbols().
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 139 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 143 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 147 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 152 of file SymbolTable.h.
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 160 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 168 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 176 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 182 of file SymbolTable.h.
Referenced by llvm::CloneModule(), fillTypeNameTable(), llvm::SlotCalculator::getPlane(), llvm::Module::getTypeName(), and LinkTypes().
type_const_iterator llvm::SymbolTable::type_begin | ( | ) | const [inline] |
Get a const_iterator to the start of the name/Type map.
Definition at line 185 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 189 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 193 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 198 of file SymbolTable.h.
Referenced by llvm::Function::renameLocalSymbols().
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 206 of file SymbolTable.h.
bool SymbolTable::strip | ( | ) |
Strip the symbol table.
This method will strip the symbol table of its names leaving the type and values.
Definition at line 263 of file SymbolTable.cpp.
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().
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().
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 241 of file SymbolTable.h.
References llvm::Value::getName(), llvm::Value::getType(), llvm::Value::hasName(), and Val.
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.
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().