LLVM
8.0.1
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/ADT/StringRef.h
"
19
#include "
llvm/IR/Value.h
"
20
#include <cstdint>
21
22
namespace
llvm
{
23
24
class
Argument;
25
class
BasicBlock
;
26
class
Function
;
27
class
GlobalAlias;
28
class
GlobalIFunc;
29
class
GlobalVariable;
30
class
Instruction;
31
template
<
unsigned
InternalLen>
class
SmallString;
32
template
<
typename
ValueSubClass>
class
SymbolTableListTraits;
33
34
/// This class provides a symbol table of name/value pairs. It is essentially
35
/// a std::map<std::string,Value*> but has a controlled interface provided by
36
/// LLVM as well as ensuring uniqueness of names.
37
///
38
class
ValueSymbolTable
{
39
friend
class
SymbolTableListTraits
<
Argument
>;
40
friend
class
SymbolTableListTraits
<
BasicBlock
>;
41
friend
class
SymbolTableListTraits
<
Function
>;
42
friend
class
SymbolTableListTraits
<
GlobalAlias
>;
43
friend
class
SymbolTableListTraits
<
GlobalIFunc
>;
44
friend
class
SymbolTableListTraits
<
GlobalVariable
>;
45
friend
class
SymbolTableListTraits
<
Instruction
>;
46
friend
class
Value
;
47
48
/// @name Types
49
/// @{
50
public
:
51
/// A mapping of names to values.
52
using
ValueMap
=
StringMap<Value*>
;
53
54
/// An iterator over a ValueMap.
55
using
iterator
=
ValueMap::iterator
;
56
57
/// A const_iterator over a ValueMap.
58
using
const_iterator
=
ValueMap::const_iterator
;
59
60
/// @}
61
/// @name Constructors
62
/// @{
63
64
ValueSymbolTable
() : vmap(0) {}
65
~ValueSymbolTable
();
66
67
/// @}
68
/// @name Accessors
69
/// @{
70
71
/// This method finds the value with the given \p Name in the
72
/// the symbol table.
73
/// @returns the value associated with the \p Name
74
/// Lookup a named Value.
75
Value
*
lookup
(
StringRef
Name
)
const
{
return
vmap.
lookup
(Name); }
76
77
/// @returns true iff the symbol table is empty
78
/// Determine if the symbol table is empty
79
inline
bool
empty
()
const
{
return
vmap.
empty
(); }
80
81
/// The number of name/type pairs is returned.
82
inline
unsigned
size
()
const
{
return
unsigned
(vmap.
size
()); }
83
84
/// This function can be used from the debugger to display the
85
/// content of the symbol table while debugging.
86
/// Print out symbol table on stderr
87
void
dump
()
const
;
88
89
/// @}
90
/// @name Iteration
91
/// @{
92
93
/// Get an iterator that from the beginning of the symbol table.
94
inline
iterator
begin
() {
return
vmap.
begin
(); }
95
96
/// Get a const_iterator that from the beginning of the symbol table.
97
inline
const_iterator
begin
()
const
{
return
vmap.
begin
(); }
98
99
/// Get an iterator to the end of the symbol table.
100
inline
iterator
end
() {
return
vmap.
end
(); }
101
102
/// Get a const_iterator to the end of the symbol table.
103
inline
const_iterator
end
()
const
{
return
vmap.
end
(); }
104
105
/// @}
106
/// @name Mutators
107
/// @{
108
private
:
109
ValueName
*makeUniqueName(
Value
*V,
SmallString<256>
&UniqueName);
110
111
/// This method adds the provided value \p N to the symbol table. The Value
112
/// must have a name which is used to place the value in the symbol table.
113
/// If the inserted name conflicts, this renames the value.
114
/// Add a named value to the symbol table
115
void
reinsertValue(
Value
*V);
116
117
/// createValueName - This method attempts to create a value name and insert
118
/// it into the symbol table with the specified name. If it conflicts, it
119
/// auto-renames the name and returns that instead.
120
ValueName
*createValueName(
StringRef
Name
,
Value
*V);
121
122
/// This method removes a value from the symbol table. It leaves the
123
/// ValueName attached to the value, but it is no longer inserted in the
124
/// symtab.
125
void
removeValueName(
ValueName
*V);
126
127
/// @}
128
/// @name Internal Data
129
/// @{
130
131
ValueMap
vmap;
///< The map that holds the symbol table.
132
mutable
uint32_t
LastUnique = 0;
///< Counter for tracking unique names
133
134
/// @}
135
};
136
137
}
// end namespace llvm
138
139
#endif // LLVM_IR_VALUESYMBOLTABLE_H
llvm::ValueSymbolTable
This class provides a symbol table of name/value pairs.
Definition:
ValueSymbolTable.h:38
llvm::Argument
This class represents an incoming formal argument to a Function.
Definition:
Argument.h:30
llvm::ValueSymbolTable::begin
iterator begin()
Get an iterator that from the beginning of the symbol table.
Definition:
ValueSymbolTable.h:94
llvm
This class represents lattice values for constants.
Definition:
AllocatorList.h:24
llvm::StringMapEntry
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
Definition:
StringMap.h:126
llvm::ISD::BasicBlock
Various leaf nodes.
Definition:
ISDOpcodes.h:60
llvm::ValueSymbolTable::~ValueSymbolTable
~ValueSymbolTable()
Definition:
ValueSymbolTable.cpp:34
llvm::GlobalAlias
Definition:
GlobalAlias.h:28
StringMapConstIterator< ValueTy >
llvm::GlobalIFunc
Definition:
GlobalIFunc.h:33
llvm::codeview::PublicSymFlags::Function
llvm::Function
Definition:
Function.h:60
Name
amdgpu Simplify well known AMD library false Value Value const Twine & Name
Definition:
AMDGPULibCalls.cpp:221
llvm::StringMapImpl::size
unsigned size() const
Definition:
StringMap.h:112
unsigned
llvm::Instruction
Definition:
Instruction.h:44
llvm::ValueSymbolTable::size
unsigned size() const
The number of name/type pairs is returned.
Definition:
ValueSymbolTable.h:82
llvm::ValueSymbolTable::empty
bool empty() const
Definition:
ValueSymbolTable.h:79
llvm::SmallString< 256 >
llvm::ValueSymbolTable::end
iterator end()
Get an iterator to the end of the symbol table.
Definition:
ValueSymbolTable.h:100
llvm::ValueSymbolTable::end
const_iterator end() const
Get a const_iterator to the end of the symbol table.
Definition:
ValueSymbolTable.h:103
llvm::ValueSymbolTable::ValueSymbolTable
ValueSymbolTable()
Definition:
ValueSymbolTable.h:64
llvm::BasicBlock
LLVM Basic Block Representation.
Definition:
BasicBlock.h:58
StringMap.h
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:347
llvm::ValueSymbolTable::begin
const_iterator begin() const
Get a const_iterator that from the beginning of the symbol table.
Definition:
ValueSymbolTable.h:97
llvm::GlobalVariable
Definition:
GlobalVariable.h:42
llvm::StringMap::iterator
StringMapIterator< ValueTy > iterator
Definition:
StringMap.h:313
uint32_t
StringRef.h
llvm::StringMap
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Definition:
StringMap.h:220
llvm::StringMap::begin
iterator begin()
Definition:
StringMap.h:315
Value.h
llvm::StringMapIterator
Definition:
StringMap.h:35
llvm::SymbolTableListTraits
Definition:
GlobalAlias.h:26
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:119
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:75
llvm::StringMapImpl::empty
bool empty() const
Definition:
StringMap.h:111
llvm::Value
LLVM Value Representation.
Definition:
Value.h:73
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:
StringRef.h:49
llvm::StringMap::const_iterator
StringMapConstIterator< ValueTy > const_iterator
Definition:
StringMap.h:312
llvm::StringMap::end
iterator end()
Definition:
StringMap.h:318
Generated on Sun Dec 20 2020 13:53:30 for LLVM by
1.8.13