LLVM API Documentation

IRObjectFile.h
Go to the documentation of this file.
00001 //===- IRObjectFile.h - LLVM IR object file implementation ------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file declares the IRObjectFile template class.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_OBJECT_IROBJECTFILE_H
00015 #define LLVM_OBJECT_IROBJECTFILE_H
00016 
00017 #include "llvm/Object/SymbolicFile.h"
00018 
00019 namespace llvm {
00020 class Mangler;
00021 class Module;
00022 class GlobalValue;
00023 
00024 namespace object {
00025 class IRObjectFile : public SymbolicFile {
00026   std::unique_ptr<Module> M;
00027   std::unique_ptr<Mangler> Mang;
00028   std::vector<std::pair<std::string, uint32_t>> AsmSymbols;
00029 
00030 public:
00031   IRObjectFile(MemoryBufferRef Object, std::unique_ptr<Module> M);
00032   ~IRObjectFile();
00033   void moveSymbolNext(DataRefImpl &Symb) const override;
00034   std::error_code printSymbolName(raw_ostream &OS,
00035                                   DataRefImpl Symb) const override;
00036   uint32_t getSymbolFlags(DataRefImpl Symb) const override;
00037   const GlobalValue *getSymbolGV(DataRefImpl Symb) const;
00038   basic_symbol_iterator symbol_begin_impl() const override;
00039   basic_symbol_iterator symbol_end_impl() const override;
00040 
00041   const Module &getModule() const {
00042     return const_cast<IRObjectFile*>(this)->getModule();
00043   }
00044   Module &getModule() {
00045     return *M;
00046   }
00047 
00048   static inline bool classof(const Binary *v) {
00049     return v->isIR();
00050   }
00051 
00052   static ErrorOr<std::unique_ptr<IRObjectFile>>
00053   createIRObjectFile(MemoryBufferRef Object, LLVMContext &Context);
00054 };
00055 }
00056 }
00057 
00058 #endif