LLVM 22.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
21
22namespace llvm {
23class Module;
24
25namespace object {
26class ObjectFile;
27
28class LLVM_ABI IRObjectFile : public SymbolicFile {
29 std::vector<std::unique_ptr<Module>> Mods;
30 ModuleSymbolTable SymTab;
31 IRObjectFile(MemoryBufferRef Object,
32 std::vector<std::unique_ptr<Module>> Mods);
33
34public:
35 ~IRObjectFile() override;
36 void moveSymbolNext(DataRefImpl &Symb) const override;
37 Error printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override;
39 basic_symbol_iterator symbol_begin() const override;
40 basic_symbol_iterator symbol_end() const override;
41 bool is64Bit() const override {
43 }
44 StringRef getTargetTriple() const;
45
46 static bool classof(const Binary *v) {
47 return v->isIR();
48 }
49
52 const Module>;
53
54 module_iterator module_begin() const { return module_iterator(Mods.begin()); }
55 module_iterator module_end() const { return module_iterator(Mods.end()); }
56
60
61 /// Finds and returns bitcode embedded in the given object file, or an
62 /// error code if not found.
63 static Expected<MemoryBufferRef> findBitcodeInObject(const ObjectFile &Obj);
64
65 /// Finds and returns bitcode in the given memory buffer (which may
66 /// be either a bitcode file or a native object file with embedded bitcode),
67 /// or an error code if not found.
69 findBitcodeInMemBuffer(MemoryBufferRef Object);
70
72 LLVMContext &Context);
73};
74
75/// The contents of a bitcode file and its irsymtab. Any underlying data
76/// for the irsymtab are owned by Symtab and Strtab.
82
83/// Reads a bitcode file, creating its irsymtab if necessary.
85}
86
87} // namespace llvm
88
89#endif
#define LLVM_ABI
Definition Compiler.h:213
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
Tagged union holding either a T or a Error.
Definition Error.h:485
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
LLVM_ABI bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition Triple.cpp:1784
This class can be used to read a Symtab and Strtab produced by irsymtab::build.
Definition IRSymtab.h:239
A range adaptor for a pair of iterators.
Expected< uint32_t > getSymbolFlags(DataRefImpl Symb) const override
Error printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override
bool is64Bit() const override
StringRef getTargetTriple() const
pointee_iterator< std::vector< std::unique_ptr< Module > >::const_iterator, const Module > module_iterator
basic_symbol_iterator symbol_begin() const override
module_iterator module_end() const
basic_symbol_iterator symbol_end() const override
void moveSymbolNext(DataRefImpl &Symb) const override
module_iterator module_begin() const
static bool classof(const Binary *v)
iterator_range< module_iterator > modules() const
This class is the base class for all object file types.
Definition ObjectFile.h:231
SymbolicFile(unsigned int Type, MemoryBufferRef Source)
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
LLVM_ABI Expected< IRSymtabFile > readIRSymtab(MemoryBufferRef MBRef)
Reads a bitcode file, creating its irsymtab if necessary.
content_iterator< BasicSymbolRef > basic_symbol_iterator
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
The contents of a bitcode file and its irsymtab.
SmallVector< char, 0 > Strtab
irsymtab::Reader TheReader
std::vector< BitcodeModule > Mods
SmallVector< char, 0 > Symtab
An iterator type that allows iterating over the pointees via some other iterator.
Definition iterator.h:324