LLVM  4.0.0
ModuleSymbolTable.h
Go to the documentation of this file.
1 //===- ModuleSymbolTable.h - symbol table for in-memory IR ----------------===//
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 class represents a symbol table built from in-memory IR. It provides
11 // access to GlobalValues and should only be used if such access is required
12 // (e.g. in the LTO implementation).
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_OBJECT_MODULESYMBOLTABLE_H
17 #define LLVM_OBJECT_MODULESYMBOLTABLE_H
18 
19 #include "llvm/ADT/PointerUnion.h"
20 #include "llvm/ADT/Triple.h"
21 #include "llvm/IR/Mangler.h"
23 #include <string>
24 #include <utility>
25 
26 namespace llvm {
27 
28 class GlobalValue;
29 
31 public:
32  typedef std::pair<std::string, uint32_t> AsmSymbol;
34 
35 private:
36  Module *FirstMod = nullptr;
37 
39  std::vector<Symbol> SymTab;
40  Mangler Mang;
41 
42 public:
43  ArrayRef<Symbol> symbols() const { return SymTab; }
44  void addModule(Module *M);
45 
46  void printSymbolName(raw_ostream &OS, Symbol S) const;
48 
49  /// Parse inline ASM and collect the symbols that are defined or referenced in
50  /// the current module.
51  ///
52  /// For each found symbol, call \p AsmSymbol with the name of the symbol found
53  /// and the associated flags.
54  static void CollectAsmSymbols(
55  const Triple &TheTriple, StringRef InlineAsm,
57 };
58 
59 }
60 
61 #endif
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:52
std::pair< std::string, uint32_t > AsmSymbol
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:83
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
PointerUnion< GlobalValue *, AsmSymbol * > Symbol
uint32_t getSymbolFlags(Symbol S) const
ArrayRef< Symbol > symbols() const
void printSymbolName(raw_ostream &OS, Symbol S) const
static void CollectAsmSymbols(const Triple &TheTriple, StringRef InlineAsm, function_ref< void(StringRef, object::BasicSymbolRef::Flags)> AsmSymbol)
Parse inline ASM and collect the symbols that are defined or referenced in the current module...
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
A discriminated union of two pointer types, with the discriminator in the low bit of the pointer...
Definition: PointerUnion.h:87