#pragma once // // This file is distributed under the MIT License. See LICENSE.md for details. // #include #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCDisassembler/MCDisassembler.h" #include "llvm/MC/MCInstPrinter.h" #include "llvm/MC/MCInstrInfo.h" #include "llvm/MC/MCObjectFileInfo.h" #include "llvm/MC/MCRegisterInfo.h" #include "llvm/MC/MCSubtargetInfo.h" #include "revng/Support/MetaAddress.h" #include "revng/Yield/Instruction.h" class LLVMDisassemblerInterface { private: std::unique_ptr SubtargetInformation; std::unique_ptr RegisterInformation; std::unique_ptr AssemblyInformation; std::unique_ptr ObjectFileInformation; std::unique_ptr Context; std::unique_ptr InstructionInformation; std::unique_ptr Disassembler; std::unique_ptr Printer; public: explicit LLVMDisassemblerInterface(MetaAddressType::Values AddressType); struct Disassembled { yield::Instruction Instruction; bool HasDelaySlot; uint64_t Size; }; Disassembled instruction(const MetaAddress &Where, llvm::ArrayRef RawBytes); public: inline llvm::StringRef getCommentString() const { return AssemblyInformation->getCommentString(); } inline llvm::StringRef getLabelSuffix() const { return AssemblyInformation->getLabelSuffix(); } private: std::pair, uint64_t> disassemble(const MetaAddress &Address, llvm::ArrayRef RawBytes, const llvm::MCDisassembler &Disassembler); yield::Instruction parse(const llvm::MCInst &Instruction, const MetaAddress &Address, size_t InstructionSize, llvm::MCInstPrinter &Printer, const llvm::MCSubtargetInfo &SI); };