diff options
Diffstat (limited to 'llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp')
-rw-r--r-- | llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp | 22 |
1 files changed, 2 insertions, 20 deletions
diff --git a/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp b/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp index 9a635bb..ca12326 100644 --- a/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp +++ b/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp @@ -169,29 +169,12 @@ X86GenericDisassembler::X86GenericDisassembler( llvm_unreachable("Invalid CPU mode"); } -namespace { -struct Region { - ArrayRef<uint8_t> Bytes; - uint64_t Base; - Region(ArrayRef<uint8_t> Bytes, uint64_t Base) : Bytes(Bytes), Base(Base) {} -}; -} // end anonymous namespace - /// A callback function that wraps the readByte method from Region. /// /// @param Arg - The generic callback parameter. In this case, this should /// be a pointer to a Region. /// @param Byte - A pointer to the byte to be read. /// @param Address - The address to be read. -static int regionReader(const void *Arg, uint8_t *Byte, uint64_t Address) { - auto *R = static_cast<const Region *>(Arg); - ArrayRef<uint8_t> Bytes = R->Bytes; - unsigned Index = Address - R->Base; - if (Bytes.size() <= Index) - return -1; - *Byte = Bytes[Index]; - return 0; -} /// logger - a callback function that wraps the operator<< method from /// raw_ostream. @@ -222,10 +205,9 @@ MCDisassembler::DecodeStatus X86GenericDisassembler::getInstruction( if (&VStream == &nulls()) LoggerFn = nullptr; // Disable logging completely if it's going to nulls(). - Region R(Bytes, Address); + std::pair<ArrayRef<uint8_t>, uint64_t> R(Bytes, Address); - int Ret = decodeInstruction(&InternalInstr, regionReader, (const void *)&R, - LoggerFn, (void *)&VStream, + int Ret = decodeInstruction(&InternalInstr, &R, LoggerFn, (void *)&VStream, (const void *)MII.get(), Address, fMode); if (Ret) { |