LLVM  15.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/Object/IRSymtab.h"
19 
20 namespace llvm {
21 class BitcodeModule;
22 class Module;
23 
24 namespace object {
25 class ObjectFile;
26 
27 class IRObjectFile : public SymbolicFile {
28  std::vector<std::unique_ptr<Module>> Mods;
29  ModuleSymbolTable SymTab;
31  std::vector<std::unique_ptr<Module>> Mods);
32 
33 public:
34  ~IRObjectFile() override;
35  void moveSymbolNext(DataRefImpl &Symb) const override;
36  Error printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override;
37  Expected<uint32_t> getSymbolFlags(DataRefImpl Symb) const override;
38  basic_symbol_iterator symbol_begin() const override;
39  basic_symbol_iterator symbol_end() const override;
40 
41  StringRef getTargetTriple() const;
42 
43  static bool classof(const Binary *v) {
44  return v->isIR();
45  }
46 
47  using module_iterator =
49  const Module>;
50 
51  module_iterator module_begin() const { return module_iterator(Mods.begin()); }
52  module_iterator module_end() const { return module_iterator(Mods.end()); }
53 
55  return make_range(module_begin(), module_end());
56  }
57 
58  /// Finds and returns bitcode embedded in the given object file, or an
59  /// error code if not found.
61 
62  /// 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 
70 };
71 
72 /// The contents of a bitcode file and its irsymtab. Any underlying data
73 /// for the irsymtab are owned by Symtab and Strtab.
74 struct IRSymtabFile {
75  std::vector<BitcodeModule> Mods;
78 };
79 
80 /// Reads a bitcode file, creating its irsymtab if necessary.
82 
83 }
84 
85 }
86 
87 #endif
const_iterator
llvm::object::IRSymtabFile
The contents of a bitcode file and its irsymtab.
Definition: IRObjectFile.h:74
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
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:76
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:41
SymbolicFile.h
llvm::MemoryBufferRef
Definition: MemoryBufferRef.h:22
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::object::IRObjectFile::getTargetTriple
StringRef getTargetTriple() const
Definition: IRObjectFile.cpp:67
llvm::object::IRObjectFile::module_end
module_iterator module_end() const
Definition: IRObjectFile.h:52
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:54
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:76
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:68
llvm::object::IRObjectFile::classof
static bool classof(const Binary *v)
Definition: IRObjectFile.h:43
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:49
llvm::object::IRObjectFile
Definition: IRObjectFile.h:27
llvm::object::content_iterator
Definition: SymbolicFile.h:69
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
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:51
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::object::ObjectFile
This class is the base class for all object file types.
Definition: ObjectFile.h:228
llvm::object::IRSymtabFile::TheReader
irsymtab::Reader TheReader
Definition: IRObjectFile.h:77
llvm::object::Binary
Definition: Binary.h:32
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::object::DataRefImpl
Definition: SymbolicFile.h:35
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:54
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:155
llvm::object::IRSymtabFile::Mods
std::vector< BitcodeModule > Mods
Definition: IRObjectFile.h:75
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:144
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:145
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