LLVM
4.0.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
llvm.src
include
llvm
IR
ValueSymbolTable.h
Go to the documentation of this file.
1
//===-- llvm/ValueSymbolTable.h - Implement a Value Symtab ------*- C++ -*-===//
2
//
3
// The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// This file implements the name/Value symbol table for LLVM.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_IR_VALUESYMBOLTABLE_H
15
#define LLVM_IR_VALUESYMBOLTABLE_H
16
17
#include "
llvm/ADT/StringMap.h
"
18
#include "
llvm/IR/Value.h
"
19
#include "llvm/Support/DataTypes.h"
20
21
namespace
llvm {
22
template
<
typename
ValueSubClass>
class
SymbolTableListTraits;
23
template
<
unsigned
InternalLen>
class
SmallString;
24
class
BasicBlock
;
25
class
Function
;
26
class
NamedMDNode;
27
class
Module;
28
class
StringRef;
29
30
/// This class provides a symbol table of name/value pairs. It is essentially
31
/// a std::map<std::string,Value*> but has a controlled interface provided by
32
/// LLVM as well as ensuring uniqueness of names.
33
///
34
class
ValueSymbolTable
{
35
friend
class
Value
;
36
friend
class
SymbolTableListTraits
<
Argument
>;
37
friend
class
SymbolTableListTraits
<
BasicBlock
>;
38
friend
class
SymbolTableListTraits
<
Instruction
>;
39
friend
class
SymbolTableListTraits
<
Function
>;
40
friend
class
SymbolTableListTraits
<
GlobalVariable
>;
41
friend
class
SymbolTableListTraits
<
GlobalAlias
>;
42
friend
class
SymbolTableListTraits
<
GlobalIFunc
>;
43
/// @name Types
44
/// @{
45
public
:
46
/// @brief A mapping of names to values.
47
typedef
StringMap<Value*>
ValueMap
;
48
49
/// @brief An iterator over a ValueMap.
50
typedef
ValueMap::iterator
iterator
;
51
52
/// @brief A const_iterator over a ValueMap.
53
typedef
ValueMap::const_iterator
const_iterator
;
54
55
/// @}
56
/// @name Constructors
57
/// @{
58
public
:
59
ValueSymbolTable
() : vmap(0), LastUnique(0) {}
60
~ValueSymbolTable
();
61
62
/// @}
63
/// @name Accessors
64
/// @{
65
public
:
66
/// This method finds the value with the given \p Name in the
67
/// the symbol table.
68
/// @returns the value associated with the \p Name
69
/// @brief Lookup a named Value.
70
Value
*
lookup
(
StringRef
Name
)
const
{
return
vmap.
lookup
(Name); }
71
72
/// @returns true iff the symbol table is empty
73
/// @brief Determine if the symbol table is empty
74
inline
bool
empty
()
const
{
return
vmap.
empty
(); }
75
76
/// @brief The number of name/type pairs is returned.
77
inline
unsigned
size
()
const
{
return
unsigned
(vmap.
size
()); }
78
79
/// This function can be used from the debugger to display the
80
/// content of the symbol table while debugging.
81
/// @brief Print out symbol table on stderr
82
void
dump
()
const
;
83
84
/// @}
85
/// @name Iteration
86
/// @{
87
public
:
88
/// @brief Get an iterator that from the beginning of the symbol table.
89
inline
iterator
begin
() {
return
vmap.
begin
(); }
90
91
/// @brief Get a const_iterator that from the beginning of the symbol table.
92
inline
const_iterator
begin
()
const
{
return
vmap.
begin
(); }
93
94
/// @brief Get an iterator to the end of the symbol table.
95
inline
iterator
end
() {
return
vmap.
end
(); }
96
97
/// @brief Get a const_iterator to the end of the symbol table.
98
inline
const_iterator
end
()
const
{
return
vmap.
end
(); }
99
100
/// @}
101
/// @name Mutators
102
/// @{
103
private
:
104
ValueName
*makeUniqueName(
Value
*V,
SmallString<256>
&UniqueName);
105
106
/// This method adds the provided value \p N to the symbol table. The Value
107
/// must have a name which is used to place the value in the symbol table.
108
/// If the inserted name conflicts, this renames the value.
109
/// @brief Add a named value to the symbol table
110
void
reinsertValue(
Value
*V);
111
112
/// createValueName - This method attempts to create a value name and insert
113
/// it into the symbol table with the specified name. If it conflicts, it
114
/// auto-renames the name and returns that instead.
115
ValueName
*createValueName(
StringRef
Name
,
Value
*V);
116
117
/// This method removes a value from the symbol table. It leaves the
118
/// ValueName attached to the value, but it is no longer inserted in the
119
/// symtab.
120
void
removeValueName(
ValueName
*V);
121
122
/// @}
123
/// @name Internal Data
124
/// @{
125
private
:
126
ValueMap
vmap;
///< The map that holds the symbol table.
127
mutable
uint32_t
LastUnique;
///< Counter for tracking unique names
128
129
/// @}
130
};
131
132
}
// End llvm namespace
133
134
#endif
llvm::ValueSymbolTable
This class provides a symbol table of name/value pairs.
Definition:
ValueSymbolTable.h:34
llvm::Argument
LLVM Argument representation.
Definition:
Argument.h:34
llvm::ValueSymbolTable::begin
iterator begin()
Get an iterator that from the beginning of the symbol table.
Definition:
ValueSymbolTable.h:89
llvm::StringMapEntry
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
Definition:
StringMap.h:36
llvm::ISD::BasicBlock
Various leaf nodes.
Definition:
ISDOpcodes.h:60
llvm::ValueSymbolTable::~ValueSymbolTable
~ValueSymbolTable()
Definition:
ValueSymbolTable.cpp:30
llvm::GlobalAlias
Definition:
GlobalAlias.h:28
llvm::ValueSymbolTable::begin
const_iterator begin() const
Get a const_iterator that from the beginning of the symbol table.
Definition:
ValueSymbolTable.h:92
llvm::GlobalIFunc
Definition:
GlobalIFunc.h:33
llvm::StringMapImpl::empty
bool empty() const
Definition:
StringMap.h:113
llvm::Function
Definition:
Function.h:48
llvm::ValueSymbolTable::iterator
ValueMap::iterator iterator
An iterator over a ValueMap.
Definition:
ValueSymbolTable.h:50
llvm::GraphProgram::Name
Name
Definition:
GraphWriter.h:43
unsigned
llvm::Instruction
Definition:
Instruction.h:39
llvm::ValueSymbolTable::size
unsigned size() const
The number of name/type pairs is returned.
Definition:
ValueSymbolTable.h:77
llvm::SmallString< 256 >
llvm::ValueSymbolTable::end
iterator end()
Get an iterator to the end of the symbol table.
Definition:
ValueSymbolTable.h:95
llvm::ValueSymbolTable::end
const_iterator end() const
Get a const_iterator to the end of the symbol table.
Definition:
ValueSymbolTable.h:98
llvm::ValueSymbolTable::ValueSymbolTable
ValueSymbolTable()
Definition:
ValueSymbolTable.h:59
llvm::BasicBlock
LLVM Basic Block Representation.
Definition:
BasicBlock.h:51
llvm::StringMapImpl::size
unsigned size() const
Definition:
StringMap.h:114
StringMap.h
llvm::StringMapConstIterator
Definition:
StringMap.h:32
llvm::GlobalVariable
Definition:
GlobalVariable.h:41
uint32_t
llvm::ValueMap
See the file comment.
Definition:
ValueMap.h:87
llvm::StringMap::lookup
ValueTy lookup(StringRef Key) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Definition:
StringMap.h:329
llvm::ValueSymbolTable::const_iterator
ValueMap::const_iterator const_iterator
A const_iterator over a ValueMap.
Definition:
ValueSymbolTable.h:53
llvm::StringMap< Value * >
llvm::ValueSymbolTable::dump
void dump() const
This function can be used from the debugger to display the content of the symbol table while debuggin...
Definition:
ValueSymbolTable.cpp:104
llvm::StringMap::begin
iterator begin()
Definition:
StringMap.h:302
Value.h
llvm::StringMapIterator
Definition:
StringMap.h:34
llvm::ValueSymbolTable::empty
bool empty() const
Determine if the symbol table is empty.
Definition:
ValueSymbolTable.h:74
llvm::SymbolTableListTraits
Definition:
Argument.h:24
llvm::ValueSymbolTable::ValueMap
StringMap< Value * > ValueMap
A mapping of names to values.
Definition:
ValueSymbolTable.h:47
llvm::Value
LLVM Value Representation.
Definition:
Value.h:71
llvm::pdb::PDB_SymType::Function
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:
StringRef.h:47
llvm::StringMap::end
iterator end()
Definition:
StringMap.h:305
llvm::ValueSymbolTable::lookup
Value * lookup(StringRef Name) const
This method finds the value with the given Name in the the symbol table.
Definition:
ValueSymbolTable.h:70
Generated on Wed Mar 8 2017 17:30:25 for LLVM by
1.8.6