LLVM  14.0.0git
IRObjectFile.h
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 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_OBJECT_IROBJECTFILE_H
14 #define LLVM_OBJECT_IROBJECTFILE_H
15 
16 #include "llvm/ADT/PointerUnion.h"
17 #include "llvm/Object/IRSymtab.h"
20 
21 namespace llvm {
22 class BitcodeModule;
23 class Module;
24 
25 namespace object {
26 class ObjectFile;
27 
28 class IRObjectFile : public SymbolicFile {
29  std::vector<std::unique_ptr<Module>> Mods;
30  ModuleSymbolTable SymTab;
32  std::vector<std::unique_ptr<Module>> Mods);
33 
34 public:
35  ~IRObjectFile() override;
36  void moveSymbolNext(DataRefImpl &Symb) const override;
37  Error printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override;
38  Expected<uint32_t> getSymbolFlags(DataRefImpl Symb) const override;
39  basic_symbol_iterator symbol_begin() const override;
40  basic_symbol_iterator symbol_end() const override;
41 
42  StringRef getTargetTriple() const;
43 
44  static bool classof(const Binary *v) {
45  return v->isIR();
46  }
47 
48  using module_iterator =
50  const Module>;
51 
52  module_iterator module_begin() const { return module_iterator(Mods.begin()); }
53  module_iterator module_end() const { return module_iterator(Mods.end()); }
54 
56  return make_range(module_begin(), module_end());
57  }
58 
59  /// Finds and returns bitcode embedded in the given object file, or an
60  /// error code if not found.
62 
63  /// Finds and returns bitcode in the given memory buffer (which may
64  /// be either a bitcode file or a native object file with embedded bitcode),
65  /// or an error code if not found.
68 
71 };
72 
73 /// The contents of a bitcode file and its irsymtab. Any underlying data
74 /// for the irsymtab are owned by Symtab and Strtab.
75 struct IRSymtabFile {
76  std::vector<BitcodeModule> Mods;
79 };
80 
81 /// Reads a bitcode file, creating its irsymtab if necessary.
83 
84 }
85 
86 }
87 
88 #endif
llvm::object::IRSymtabFile
The contents of a bitcode file and its irsymtab.
Definition: IRObjectFile.h:75
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
llvm::make_range
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Definition: iterator_range.h:53
llvm::object::readIRSymtab
Expected< IRSymtabFile > readIRSymtab(MemoryBufferRef MBRef)
Reads a bitcode file, creating its irsymtab if necessary.
Definition: IRObjectFile.cpp:136
llvm::SmallVector< char, 0 >
llvm::object::IRObjectFile::moveSymbolNext
void moveSymbolNext(DataRefImpl &Symb) const override
Definition: IRObjectFile.cpp:41
llvm::object::IRSymtabFile::Strtab
SmallVector< char, 0 > Strtab
Definition: IRObjectFile.h:77
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:42
SymbolicFile.h
llvm::MemoryBufferRef
Definition: MemoryBufferRef.h:22
Context
ManagedStatic< detail::RecordContext > Context
Definition: Record.cpp:96
llvm::object::IRObjectFile::getTargetTriple
StringRef getTargetTriple() const
Definition: IRObjectFile.cpp:67
llvm::object::IRObjectFile::module_end
module_iterator module_end() const
Definition: IRObjectFile.h:53
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::OutputFileType::Object
@ Object
llvm::object::IRObjectFile::findBitcodeInObject
static Expected< MemoryBufferRef > findBitcodeInObject(const ObjectFile &Obj)
Finds and returns bitcode embedded in the given object file, or an error code if not found.
Definition: IRObjectFile.cpp:74
llvm::object::IRSymtabFile::Symtab
SmallVector< char, 0 > Symtab
Definition: IRObjectFile.h:77
llvm::object::IRObjectFile::symbol_begin
basic_symbol_iterator symbol_begin() const override
Definition: IRObjectFile.cpp:54
IRSymtab.h
object
bar al al movzbl eax ret Missed when stored in a memory object
Definition: README.txt:1411
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
llvm::object::IRObjectFile::classof
static bool classof(const Binary *v)
Definition: IRObjectFile.h:44
llvm::irsymtab::Reader
This class can be used to read a Symtab and Strtab produced by irsymtab::build.
Definition: IRSymtab.h:236
llvm::object::IRObjectFile::module_iterator
pointee_iterator< std::vector< std::unique_ptr< Module > >::const_iterator, const Module > module_iterator
Definition: IRObjectFile.h:50
llvm::object::IRObjectFile
Definition: IRObjectFile.h:28
llvm::object::content_iterator
Definition: SymbolicFile.h:67
PointerUnion.h
llvm::codeview::CodeViewContainer::ObjectFile
@ ObjectFile
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::object::IRObjectFile::~IRObjectFile
~IRObjectFile() override
Definition: IRObjectFile.cpp:35
llvm::object::IRObjectFile::printSymbolName
Error printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override
Definition: IRObjectFile.cpp:45
ModuleSymbolTable.h
llvm::object::IRObjectFile::module_begin
module_iterator module_begin() const
Definition: IRObjectFile.h:52
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
llvm::object::ObjectFile
This class is the base class for all object file types.
Definition: ObjectFile.h:227
llvm::object::IRSymtabFile::TheReader
irsymtab::Reader TheReader
Definition: IRObjectFile.h:78
llvm::object::Binary
Definition: Binary.h:32
const_iterator
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::object::DataRefImpl
Definition: SymbolicFile.h:33
llvm::object::IRObjectFile::getSymbolFlags
Expected< uint32_t > getSymbolFlags(DataRefImpl Symb) const override
Definition: IRObjectFile.cpp:50
llvm::object::IRObjectFile::modules
iterator_range< module_iterator > modules() const
Definition: IRObjectFile.h:55
llvm::object::IRObjectFile::symbol_end
basic_symbol_iterator symbol_end() const override
Definition: IRObjectFile.cpp:60
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::object::IRSymtabFile::Mods
std::vector< BitcodeModule > Mods
Definition: IRObjectFile.h:76
llvm::ModuleSymbolTable
Definition: ModuleSymbolTable.h:33
llvm::object::IRObjectFile::create
static Expected< std::unique_ptr< IRObjectFile > > create(MemoryBufferRef Object, LLVMContext &Context)
Definition: IRObjectFile.cpp:111
llvm::object::Binary::isIR
bool isIR() const
Definition: Binary.h:140
llvm::iterator_range
A range adaptor for a pair of iterators.
Definition: iterator_range.h:30
llvm::pointee_iterator
An iterator type that allows iterating over the pointees via some other iterator.
Definition: iterator.h:320
llvm::object::SymbolicFile
Definition: SymbolicFile.h:143
llvm::object::IRObjectFile::findBitcodeInMemBuffer
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 ...
Definition: IRObjectFile.cpp:90