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_IR_OBJECT_FILE_H
15#define LLVM_OBJECT_IR_OBJECT_FILE_H
16
17#include "llvm/Object/SymbolicFile.h"
18
19namespace llvm {
20class Mangler;
21class Module;
22class GlobalValue;
23
24namespace object {
25class IRObjectFile : public SymbolicFile {
26  std::unique_ptr<Module> M;
27  std::unique_ptr<Mangler> Mang;
28  std::vector<std::pair<std::string, uint32_t>> AsmSymbols;
29
30public:
31  IRObjectFile(std::unique_ptr<MemoryBuffer> Object, std::unique_ptr<Module> M);
32  ~IRObjectFile();
33  void moveSymbolNext(DataRefImpl &Symb) const override;
34  std::error_code printSymbolName(raw_ostream &OS,
35                                  DataRefImpl Symb) const override;
36  uint32_t getSymbolFlags(DataRefImpl Symb) const override;
37  const GlobalValue *getSymbolGV(DataRefImpl Symb) const;
38  basic_symbol_iterator symbol_begin_impl() const override;
39  basic_symbol_iterator symbol_end_impl() const override;
40
41  const Module &getModule() const {
42    return const_cast<IRObjectFile*>(this)->getModule();
43  }
44  Module &getModule() {
45    return *M;
46  }
47
48  static inline bool classof(const Binary *v) {
49    return v->isIR();
50  }
51
52  static ErrorOr<IRObjectFile *>
53  createIRObjectFile(std::unique_ptr<MemoryBuffer> Object,
54                     LLVMContext &Context);
55};
56}
57}
58
59#endif
60