LLVM: include/llvm/Object/IRSymtab.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#ifndef LLVM_OBJECT_IRSYMTAB_H
24#define LLVM_OBJECT_IRSYMTAB_H
25
36#include
37#include
38#include
39
40namespace llvm {
41
44
46
48
49
50
51
52
54
55
63
64
67
69 return {reinterpret_cast<const T *>(Symtab.data() + Offset), Size};
70 }
71};
72
73
74
81
82
89
90
91
93
95
96
97
99
100
102
119};
120
121
122
125
126
127
129
130
132};
133
134
136
137
138
141
142
143
144
145
147
152
154
155
157
158
160};
161
162}
163
164
165
169
170
171
173
178
179
183
184
186
187
188
190
191
192
194
196
200
207
211
216
221
226
227
228
233
235};
236
237
238
241
247
249
251 return R.get(Symtab);
252 }
253
255 return *reinterpret_cast<const storage::Header *>(Symtab.data());
256 }
257
258public:
260
263 Modules = range(header().Modules);
264 Comdats = range(header().Comdats);
265 Symbols = range(header().Symbols);
266 Uncommons = range(header().Uncommons);
267 DependentLibraries = range(header().DependentLibraries);
268 }
269
271
272
273
274
276
278
279
280
281
283
285
286
288
289
290 std::vector<std::pair<StringRef, llvm::Comdat::SelectionKind>>
292 std::vector<std::pair<StringRef, llvm::Comdat::SelectionKind>> ComdatTable;
293 ComdatTable.reserve(Comdats.size());
294 for (auto C : Comdats)
297 return ComdatTable;
298 }
299
300
302
303
305 std::vector Specifiers;
306 Specifiers.reserve(DependentLibraries.size());
307 for (auto S : DependentLibraries) {
308 Specifiers.push_back(str(S));
309 }
310 return Specifiers;
311 }
312};
313
314
315
320
321 void read() {
322 if (SymI == SymE)
323 return;
324
325 Name = R->str(SymI->Name);
326 IRName = R->str(SymI->IRName);
328 Flags = SymI->Flags;
329
335 } else
336
338 }
339
340public:
343 : SymI(SymI), SymE(SymE), UncI(UncI), R(R) {
344 read();
345 }
346
348 ++SymI;
350 ++UncI;
351 read();
352 }
353
355};
356
358 return {SymbolRef(Symbols.begin(), Symbols.end(), Uncommons.begin(), this),
359 SymbolRef(Symbols.end(), Symbols.end(), nullptr, this)};
360}
361
364 const storage::Symbol *MBegin = Symbols.begin() + M.Begin,
365 *MEnd = Symbols.begin() + M.End;
366 return {SymbolRef(MBegin, MEnd, Uncommons.begin() + M.UncBegin, this),
367 SymbolRef(MEnd, MEnd, nullptr, this)};
368}
369
370
371
376
377
379
380}
381}
382
383#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the BumpPtrAllocator interface.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
VisibilityTypes
An enumeration for the kinds of visibility of global values.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Utility for building string tables with deduplicated suffixes.
Ephemeral symbols produced by Reader::symbols() and Reader::module_symbols().
Definition IRSymtab.h:316
SymbolRef(const storage::Symbol *SymI, const storage::Symbol *SymE, const storage::Uncommon *UncI, const Reader *R)
Definition IRSymtab.h:341
bool operator==(const SymbolRef &Other) const
Definition IRSymtab.h:354
void moveNext()
Definition IRSymtab.h:347
This class can be used to read a Symtab and Strtab produced by irsymtab::build.
Definition IRSymtab.h:239
Reader(StringRef Symtab, StringRef Strtab)
Definition IRSymtab.h:262
symbol_range module_symbols(unsigned I) const
Returns a slice of the symbol table for the I'th module in the file.
Definition IRSymtab.h:362
symbol_range symbols() const
Returns the symbol table for the entire bitcode file.
Definition IRSymtab.h:357
StringRef getTargetTriple() const
Definition IRSymtab.h:284
std::vector< std::pair< StringRef, llvm::Comdat::SelectionKind > > getComdatTable() const
Returns a table with all the comdats used by this file.
Definition IRSymtab.h:291
StringRef getCOFFLinkerOpts() const
COFF-specific: returns linker options specified in the input file.
Definition IRSymtab.h:301
StringRef getSourceFileName() const
Returns the source file path specified at compile time.
Definition IRSymtab.h:287
std::vector< StringRef > getDependentLibraries() const
Returns dependent library specifiers.
Definition IRSymtab.h:304
size_t getNumModules() const
Definition IRSymtab.h:277
iterator_range< object::content_iterator< SymbolRef > > symbol_range
Definition IRSymtab.h:270
A range adaptor for a pair of iterators.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
This file contains the declaration of the Comdat class, which represents a single COMDAT in LLVM.
@ C
The default llvm calling convention, compatible with C.
support::ulittle32_t Word
Definition IRSymtab.h:53
LLVM_ABI Expected< FileContents > readBitcode(const BitcodeFileContents &BFC)
Reads the contents of a bitcode file, creating its irsymtab if necessary.
LLVM_ABI Error build(ArrayRef< Module * > Mods, SmallVector< char, 0 > &Symtab, StringTableBuilder &StrtabBuilder, BumpPtrAllocator &Alloc)
Fills in Symtab and StrtabBuilder with a valid symbol and string table for Mods.
detail::packed_endian_specific_integral< uint32_t, llvm::endianness::little, unaligned > ulittle32_t
This is an optimization pass for GlobalISel generic memory operations.
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
The contents of the irsymtab in a bitcode file.
Definition IRSymtab.h:372
SmallVector< char, 0 > Strtab
Definition IRSymtab.h:373
SmallVector< char, 0 > Symtab
Definition IRSymtab.h:373
Reader TheReader
Definition IRSymtab.h:374
This represents a symbol that has been read from a storage::Symbol and possibly a storage::Uncommon.
Definition IRSymtab.h:172
StringRef getName() const
Returns the mangled symbol name.
Definition IRSymtab.h:185
StringRef SectionName
Definition IRSymtab.h:182
bool canBeOmittedFromSymbolTable() const
Definition IRSymtab.h:208
StringRef Name
Definition IRSymtab.h:174
uint32_t CommonSize
Definition IRSymtab.h:180
uint32_t Flags
Definition IRSymtab.h:177
bool isGlobal() const
Definition IRSymtab.h:212
bool isUsed() const
Definition IRSymtab.h:205
StringRef getSectionName() const
Definition IRSymtab.h:234
bool isTLS() const
Definition IRSymtab.h:206
bool isUnnamedAddr() const
Definition IRSymtab.h:214
bool isWeak() const
Definition IRSymtab.h:202
StringRef COFFWeakExternFallbackName
Definition IRSymtab.h:181
bool isIndirect() const
Definition IRSymtab.h:204
bool isCommon() const
Definition IRSymtab.h:203
uint32_t getCommonAlignment() const
Definition IRSymtab.h:222
StringRef IRName
Definition IRSymtab.h:175
int ComdatIndex
Definition IRSymtab.h:176
bool isFormatSpecific() const
Definition IRSymtab.h:213
bool isExecutable() const
Definition IRSymtab.h:215
uint64_t getCommonSize() const
Definition IRSymtab.h:217
storage::Symbol S
Definition IRSymtab.h:195
int getComdatIndex() const
Returns the index into the comdat table (see Reader::getComdatTable()), or -1 if not a comdat member.
Definition IRSymtab.h:193
GlobalValue::VisibilityTypes getVisibility() const
Definition IRSymtab.h:197
bool isUndefined() const
Definition IRSymtab.h:201
uint32_t CommonAlign
Definition IRSymtab.h:180
StringRef getIRName() const
Returns the unmangled symbol name, or the empty string if this is not an IR symbol.
Definition IRSymtab.h:189
StringRef getCOFFWeakExternalFallback() const
COFF-specific: for weak externals, returns the name of the symbol that is used as a fallback if the w...
Definition IRSymtab.h:229
This is equivalent to an IR comdat.
Definition IRSymtab.h:83
Str Name
Definition IRSymtab.h:84
Word SelectionKind
Definition IRSymtab.h:87
Describes the range of a particular module's symbols within the symbol table.
Definition IRSymtab.h:75
Word Begin
Definition IRSymtab.h:76
Word UncBegin
The index of the first Uncommon for this Module.
Definition IRSymtab.h:79
Word End
Definition IRSymtab.h:76
A reference to a range of objects in the symbol table.
Definition IRSymtab.h:65
Word Offset
Definition IRSymtab.h:66
Word Size
Definition IRSymtab.h:66
ArrayRef< T > get(StringRef Symtab) const
Definition IRSymtab.h:68
A reference to a string in the string table.
Definition IRSymtab.h:56
StringRef get(StringRef Strtab) const
Definition IRSymtab.h:59
Word Offset
Definition IRSymtab.h:57
Word Size
Definition IRSymtab.h:57
Contains the information needed by linkers for symbol resolution, as well as by the LTO implementatio...
Definition IRSymtab.h:92
Str Name
The mangled symbol name.
Definition IRSymtab.h:94
Str IRName
The unmangled symbol name, or the empty string if this is not an IR symbol.
Definition IRSymtab.h:98
Word ComdatIndex
The index into Header::Comdats, or -1 if not a comdat member.
Definition IRSymtab.h:101
Word Flags
Definition IRSymtab.h:103
FlagBits
Definition IRSymtab.h:104
@ FB_may_omit
Definition IRSymtab.h:113
@ FB_common
Definition IRSymtab.h:109
@ FB_undefined
Definition IRSymtab.h:107
@ FB_unnamed_addr
Definition IRSymtab.h:116
@ FB_has_uncommon
Definition IRSymtab.h:106
@ FB_used
Definition IRSymtab.h:111
@ FB_tls
Definition IRSymtab.h:112
@ FB_weak
Definition IRSymtab.h:108
@ FB_indirect
Definition IRSymtab.h:110
@ FB_global
Definition IRSymtab.h:114
@ FB_format_specific
Definition IRSymtab.h:115
@ FB_executable
Definition IRSymtab.h:117
@ FB_visibility
Definition IRSymtab.h:105
This data structure contains rarely used symbol fields and is optionally referenced by a Symbol.
Definition IRSymtab.h:123
Str SectionName
Specified section name, if any.
Definition IRSymtab.h:131
Str COFFWeakExternFallbackName
COFF-specific: the name of the symbol that a weak external resolves to if not defined.
Definition IRSymtab.h:128
Word CommonAlign
Definition IRSymtab.h:124
Word CommonSize
Definition IRSymtab.h:124