LLVM  11.0.0git
Go to the documentation of this file.
1 //===- IRObjectFile.h - LLVM IR object file implementation ------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file declares the IRObjectFile template class.
10 //
11 //===----------------------------------------------------------------------===//
16 #include "llvm/ADT/PointerUnion.h"
17 #include "llvm/Object/IRSymtab.h"
21 namespace llvm {
22 class BitcodeModule;
23 class Mangler;
24 class Module;
25 class GlobalValue;
26 class Triple;
28 namespace object {
29 class ObjectFile;
31 class IRObjectFile : public SymbolicFile {
32  std::vector<std::unique_ptr<Module>> Mods;
33  ModuleSymbolTable SymTab;
35  std::vector<std::unique_ptr<Module>> Mods);
37 public:
38  ~IRObjectFile() override;
39  void moveSymbolNext(DataRefImpl &Symb) const override;
40  Error printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override;
41  Expected<uint32_t> getSymbolFlags(DataRefImpl Symb) const override;
42  basic_symbol_iterator symbol_begin() const override;
43  basic_symbol_iterator symbol_end() const override;
45  StringRef getTargetTriple() const;
47  static bool classof(const Binary *v) {
48  return v->isIR();
49  }
51  using module_iterator =
53  const Module>;
55  module_iterator module_begin() const { return module_iterator(Mods.begin()); }
56  module_iterator module_end() const { return module_iterator(Mods.end()); }
59  return make_range(module_begin(), module_end());
60  }
62  /// Finds and returns bitcode embedded in the given object file, or an
63  /// error code if not found.
66  /// Finds and returns bitcode in the given memory buffer (which may
67  /// be either a bitcode file or a native object file with embedded bitcode),
68  /// or an error code if not found.
74 };
76 /// The contents of a bitcode file and its irsymtab. Any underlying data
77 /// for the irsymtab are owned by Symtab and Strtab.
78 struct IRSymtabFile {
79  std::vector<BitcodeModule> Mods;
82 };
84 /// Reads a bitcode file, creating its irsymtab if necessary.
87 }
89 }
91 #endif
LLVMContext & Context
This class represents lattice values for constants.
Definition: AllocatorList.h:23
DEBUG_TYPE to vector
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:67
Machine Debugify Module
iterator_range< module_iterator > modules() const
Definition: IRObjectFile.h:58
This class is the base class for all object file types.
Definition: ObjectFile.h:225
module_iterator module_end() const
Definition: IRObjectFile.h:56
irsymtab::Reader TheReader
Definition: IRObjectFile.h:81
module_iterator module_begin() const
Definition: IRObjectFile.h:55
pointee_iterator< std::vector< std::unique_ptr< Module > >::const_iterator, const Module > module_iterator
Definition: IRObjectFile.h:53
Tagged union holding either a T or a Error.
Definition: APFloat.h:42
basic_symbol_iterator symbol_begin() const override
The contents of a bitcode file and its irsymtab.
Definition: IRObjectFile.h:78
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
Expected< uint32_t > getSymbolFlags(DataRefImpl Symb) const override
std::vector< BitcodeModule > Mods
Definition: IRObjectFile.h:79
static bool classof(const Binary *v)
Definition: IRObjectFile.h:47
Error printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override
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:286
A range adaptor for a pair of iterators.
void moveSymbolNext(DataRefImpl &Symb) const override
bool isIR() const
Definition: Binary.h:138
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 ...
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
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:57
Expected< IRSymtabFile > readIRSymtab(MemoryBufferRef MBRef)
Reads a bitcode file, creating its irsymtab if necessary.
StringRef getTargetTriple() const
SmallVector< char, 0 > Symtab
Definition: IRObjectFile.h:80
This class can be used to read a Symtab and Strtab produced by irsymtab::build.
Definition: IRSymtab.h:232