LLVM  8.0.1
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  using module_iterator =
55  const Module>;
56 
57  module_iterator module_begin() const { return module_iterator(Mods.begin()); }
58  module_iterator module_end() const { return module_iterator(Mods.end()); }
59 
61  return make_range(module_begin(), module_end());
62  }
63 
64  /// Finds and returns bitcode embedded in the given object file, or an
65  /// error code if not found.
67 
68  /// Finds and returns bitcode in the given memory buffer (which may
69  /// be either a bitcode file or a native object file with embedded bitcode),
70  /// or an error code if not found.
73 
76 };
77 
78 /// The contents of a bitcode file and its irsymtab. Any underlying data
79 /// for the irsymtab are owned by Symtab and Strtab.
80 struct IRSymtabFile {
81  std::vector<BitcodeModule> Mods;
84 };
85 
86 /// Reads a bitcode file, creating its irsymtab if necessary.
88 
89 }
90 
91 }
92 
93 #endif
LLVMContext & Context
This class represents lattice values for constants.
Definition: AllocatorList.h:24
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:65
iterator_range< module_iterator > modules() const
Definition: IRObjectFile.h:60
This class is the base class for all object file types.
Definition: ObjectFile.h:202
module_iterator module_end() const
Definition: IRObjectFile.h:58
irsymtab::Reader TheReader
Definition: IRObjectFile.h:83
module_iterator module_begin() const
Definition: IRObjectFile.h:57
pointee_iterator< std::vector< std::unique_ptr< Module > >::const_iterator, const Module > module_iterator
Definition: IRObjectFile.h:55
Tagged union holding either a T or a Error.
Definition: CachePruning.h:23
basic_symbol_iterator symbol_begin() const override
The contents of a bitcode file and its irsymtab.
Definition: IRObjectFile.h:80
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:69
std::vector< BitcodeModule > Mods
Definition: IRObjectFile.h:81
static bool classof(const Binary *v)
Definition: IRObjectFile.h:49
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
static Expected< MemoryBufferRef > findBitcodeInObject(const ObjectFile &Obj)
Finds and returns bitcode embedded in the given object file, or an error code if not found...
An iterator type that allows iterating over the pointees via some other iterator. ...
Definition: iterator.h:287
A range adaptor for a pair of iterators.
void moveSymbolNext(DataRefImpl &Symb) const override
bool isIR() const
Definition: Binary.h:127
static Expected< MemoryBufferRef > findBitcodeInMemBuffer(MemoryBufferRef Object)
Finds and returns bitcode in the given memory buffer (which may be either a bitcode file or a native ...
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
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.
StringRef getTargetTriple() const
SmallVector< char, 0 > Symtab
Definition: IRObjectFile.h:82
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:228