LLVM  3.7.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 
18 
19 namespace llvm {
20 class Mangler;
21 class Module;
22 class GlobalValue;
23 
24 namespace object {
25 class ObjectFile;
26 
27 class IRObjectFile : public SymbolicFile {
28  std::unique_ptr<Module> M;
29  std::unique_ptr<Mangler> Mang;
30  std::vector<std::pair<std::string, uint32_t>> AsmSymbols;
31 
32 public:
33  IRObjectFile(MemoryBufferRef Object, std::unique_ptr<Module> M);
34  ~IRObjectFile() override;
35  void moveSymbolNext(DataRefImpl &Symb) const override;
36  std::error_code printSymbolName(raw_ostream &OS,
37  DataRefImpl Symb) const override;
38  uint32_t getSymbolFlags(DataRefImpl Symb) const override;
40  const GlobalValue *getSymbolGV(DataRefImpl Symb) const {
41  return const_cast<IRObjectFile *>(this)->getSymbolGV(Symb);
42  }
44  basic_symbol_iterator symbol_end_impl() const override;
45 
46  const Module &getModule() const {
47  return const_cast<IRObjectFile*>(this)->getModule();
48  }
50  return *M;
51  }
52  std::unique_ptr<Module> takeModule();
53 
54  static inline bool classof(const Binary *v) {
55  return v->isIR();
56  }
57 
58  /// \brief Finds and returns bitcode embedded in the given object file, or an
59  /// error code if not found.
61 
62  /// \brief Finds and returns bitcode in the given memory buffer (which may
63  /// be either a bitcode file or a native object file with embedded bitcode),
64  /// or an error code if not found.
67 
69  LLVMContext &Context);
70 };
71 }
72 }
73 
74 #endif
basic_symbol_iterator symbol_begin_impl() const override
basic_symbol_iterator symbol_end_impl() const override
Represents either an error or a value T.
Definition: ErrorOr.h:82
IRObjectFile(MemoryBufferRef Object, std::unique_ptr< Module > M)
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:114
const GlobalValue * getSymbolGV(DataRefImpl Symb) const
Definition: IRObjectFile.h:40
This class is the base class for all object file types.
Definition: ObjectFile.h:176
GlobalValue * getSymbolGV(DataRefImpl Symb)
static ErrorOr< std::unique_ptr< IRObjectFile > > create(MemoryBufferRef Object, LLVMContext &Context)
std::unique_ptr< Module > takeModule()
bool isIR() const
Definition: Binary.h:116
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
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:41
static bool classof(const Binary *v)
Definition: IRObjectFile.h:54
void moveSymbolNext(DataRefImpl &Symb) const override
const Module & getModule() const
Definition: IRObjectFile.h:46
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:38
uint32_t getSymbolFlags(DataRefImpl Symb) const override