LLVM  5.0.0
IRObjectFile.h
Go to the documentation of this file.
1 //===- IRObjectFile.h - LLVM IR object file implementation ------*- 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 declares the IRObjectFile template class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_OBJECT_IROBJECTFILE_H
15 #define LLVM_OBJECT_IROBJECTFILE_H
16 
17 #include "llvm/ADT/PointerUnion.h"
18 #include "llvm/Object/IRSymtab.h"
21 
22 namespace llvm {
23 class BitcodeModule;
24 class Mangler;
25 class Module;
26 class GlobalValue;
27 class Triple;
28 
29 namespace object {
30 class ObjectFile;
31 
32 class IRObjectFile : public SymbolicFile {
33  std::vector<std::unique_ptr<Module>> Mods;
34  ModuleSymbolTable SymTab;
36  std::vector<std::unique_ptr<Module>> Mods);
37 
38 public:
39  ~IRObjectFile() override;
40  void moveSymbolNext(DataRefImpl &Symb) const override;
41  std::error_code printSymbolName(raw_ostream &OS,
42  DataRefImpl Symb) const override;
43  uint32_t getSymbolFlags(DataRefImpl Symb) const override;
44  basic_symbol_iterator symbol_begin() const override;
45  basic_symbol_iterator symbol_end() const override;
46 
47  StringRef getTargetTriple() const;
48 
49  static bool classof(const Binary *v) {
50  return v->isIR();
51  }
52 
53  /// \brief Finds and returns bitcode embedded in the given object file, or an
54  /// error code if not found.
56 
57  /// \brief Finds and returns bitcode in the given memory buffer (which may
58  /// be either a bitcode file or a native object file with embedded bitcode),
59  /// or an error code if not found.
62 
65 };
66 
67 /// The contents of a bitcode file and its irsymtab. Any underlying data
68 /// for the irsymtab are owned by Symtab and Strtab.
69 struct IRSymtabFile {
70  std::vector<BitcodeModule> Mods;
73 };
74 
75 /// Reads a bitcode file, creating its irsymtab if necessary.
77 
78 }
79 
80 }
81 
82 #endif
Represents either an error or a value T.
Definition: ErrorOr.h:69
LLVMContext & Context
This class is the base class for all object file types.
Definition: ObjectFile.h:189
irsymtab::Reader TheReader
Definition: IRObjectFile.h:72
Tagged union holding either a T or a Error.
Definition: CachePruning.h:23
basic_symbol_iterator symbol_begin() const override
bool isIR() const
Definition: Binary.h:126
The contents of a bitcode file and its irsymtab.
Definition: IRObjectFile.h:69
static ErrorOr< MemoryBufferRef > findBitcodeInMemBuffer(MemoryBufferRef Object)
Finds and returns bitcode in the given memory buffer (which may be either a bitcode file or a native ...
std::error_code printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override
static Expected< std::unique_ptr< IRObjectFile > > create(MemoryBufferRef Object, LLVMContext &Context)
basic_symbol_iterator symbol_end() const override
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
std::vector< BitcodeModule > Mods
Definition: IRObjectFile.h:70
StringRef getTargetTriple() const
static bool classof(const Binary *v)
Definition: IRObjectFile.h:49
SmallVector< char, 0 > Strtab
Definition: IRObjectFile.h:71
void moveSymbolNext(DataRefImpl &Symb) const override
static ErrorOr< MemoryBufferRef > findBitcodeInObject(const ObjectFile &Obj)
Finds and returns bitcode embedded in the given object file, or an error code if not found...
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:49
Expected< IRSymtabFile > readIRSymtab(MemoryBufferRef MBRef)
Reads a bitcode file, creating its irsymtab if necessary.
SmallVector< char, 0 > Symtab
Definition: IRObjectFile.h:71
uint32_t getSymbolFlags(DataRefImpl Symb) const override
This class can be used to read a Symtab and Strtab produced by irsymtab::build.
Definition: IRSymtab.h:222