summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp3
-rw-r--r--llvm/lib/MC/MCDisassembler/Disassembler.cpp5
-rw-r--r--llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp7
-rw-r--r--llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.h2
-rw-r--r--llvm/lib/Target/ARM/Disassembler/ARMDisassembler.cpp19
-rw-r--r--llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp8
-rw-r--r--llvm/lib/Target/Mips/Disassembler/MipsDisassembler.cpp26
-rw-r--r--llvm/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp8
-rw-r--r--llvm/lib/Target/Sparc/Disassembler/SparcDisassembler.cpp18
-rw-r--r--llvm/lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp12
-rw-r--r--llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp28
-rw-r--r--llvm/lib/Target/X86/Disassembler/X86Disassembler.h2
-rw-r--r--llvm/lib/Target/XCore/Disassembler/XCoreDisassembler.cpp21
13 files changed, 72 insertions, 87 deletions
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
index dad02dca531..5b3bd1dee46 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
@@ -668,7 +668,8 @@ private:
bool decodeInst(StringRef Symbol, MCInst &Inst, uint64_t &Size) const {
MCDisassembler *Dis = Checker.Disassembler;
StringRef SectionMem = Checker.getSubsectionStartingAt(Symbol);
- StringRefMemoryObject SectionBytes(SectionMem, 0);
+ ArrayRef<uint8_t> SectionBytes((uint8_t *)SectionMem.begin(),
+ SectionMem.size());
MCDisassembler::DecodeStatus S =
Dis->getInstruction(Inst, Size, SectionBytes, 0, nulls(), nulls());
diff --git a/llvm/lib/MC/MCDisassembler/Disassembler.cpp b/llvm/lib/MC/MCDisassembler/Disassembler.cpp
index 22095313f1c..bb2d707b404 100644
--- a/llvm/lib/MC/MCDisassembler/Disassembler.cpp
+++ b/llvm/lib/MC/MCDisassembler/Disassembler.cpp
@@ -245,8 +245,7 @@ size_t LLVMDisasmInstruction(LLVMDisasmContextRef DCR, uint8_t *Bytes,
size_t OutStringSize){
LLVMDisasmContext *DC = (LLVMDisasmContext *)DCR;
// Wrap the pointer to the Bytes, BytesSize and PC in a MemoryObject.
- StringRef Data((const char*) Bytes, BytesSize);
- StringRefMemoryObject MemoryObject(Data, PC);
+ ArrayRef<uint8_t> Data(Bytes, BytesSize);
uint64_t Size;
MCInst Inst;
@@ -255,7 +254,7 @@ size_t LLVMDisasmInstruction(LLVMDisasmContextRef DCR, uint8_t *Bytes,
MCDisassembler::DecodeStatus S;
SmallVector<char, 64> InsnStr;
raw_svector_ostream Annotations(InsnStr);
- S = DisAsm->getInstruction(Inst, Size, MemoryObject, PC,
+ S = DisAsm->getInstruction(Inst, Size, Data, 0,
/*REMOVE*/ nulls(), Annotations);
switch (S) {
case MCDisassembler::Fail:
diff --git a/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp b/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp
index ebdca907d64..878e29c0974 100644
--- a/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp
+++ b/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp
@@ -19,7 +19,6 @@
#include "llvm/MC/MCInst.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/MemoryObject.h"
#include "llvm/Support/TargetRegistry.h"
using namespace llvm;
@@ -200,17 +199,15 @@ static MCDisassembler *createAArch64Disassembler(const Target &T,
}
DecodeStatus AArch64Disassembler::getInstruction(MCInst &MI, uint64_t &Size,
- const MemoryObject &Region,
+ ArrayRef<uint8_t> Bytes,
uint64_t Address,
raw_ostream &OS,
raw_ostream &CS) const {
CommentStream = &CS;
- uint8_t Bytes[4];
-
Size = 0;
// We want to read exactly 4 bytes of data.
- if (Region.readBytes(Address, 4, Bytes) == -1)
+ if (Bytes.size() < 4)
return Fail;
Size = 4;
diff --git a/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.h b/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.h
index 84942caac24..7fb57adfeeb 100644
--- a/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.h
+++ b/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.h
@@ -29,7 +29,7 @@ public:
~AArch64Disassembler() {}
MCDisassembler::DecodeStatus
- getInstruction(MCInst &Instr, uint64_t &Size, const MemoryObject &Segion,
+ getInstruction(MCInst &Instr, uint64_t &Size, ArrayRef<uint8_t> Bytes,
uint64_t Address, raw_ostream &VStream,
raw_ostream &CStream) const override;
};
diff --git a/llvm/lib/Target/ARM/Disassembler/ARMDisassembler.cpp b/llvm/lib/Target/ARM/Disassembler/ARMDisassembler.cpp
index fc399eab568..ef6541890bf 100644
--- a/llvm/lib/Target/ARM/Disassembler/ARMDisassembler.cpp
+++ b/llvm/lib/Target/ARM/Disassembler/ARMDisassembler.cpp
@@ -20,7 +20,6 @@
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/LEB128.h"
-#include "llvm/Support/MemoryObject.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/raw_ostream.h"
#include <vector>
@@ -95,7 +94,7 @@ public:
~ARMDisassembler() {}
DecodeStatus getInstruction(MCInst &Instr, uint64_t &Size,
- const MemoryObject &Region, uint64_t Address,
+ ArrayRef<uint8_t> Bytes, uint64_t Address,
raw_ostream &VStream,
raw_ostream &CStream) const override;
};
@@ -110,7 +109,7 @@ public:
~ThumbDisassembler() {}
DecodeStatus getInstruction(MCInst &Instr, uint64_t &Size,
- const MemoryObject &Region, uint64_t Address,
+ ArrayRef<uint8_t> Bytes, uint64_t Address,
raw_ostream &VStream,
raw_ostream &CStream) const override;
@@ -407,19 +406,17 @@ static MCDisassembler *createThumbDisassembler(const Target &T,
}
DecodeStatus ARMDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
- const MemoryObject &Region,
+ ArrayRef<uint8_t> Bytes,
uint64_t Address, raw_ostream &OS,
raw_ostream &CS) const {
CommentStream = &CS;
- uint8_t Bytes[4];
-
assert(!(STI.getFeatureBits() & ARM::ModeThumb) &&
"Asked to disassemble an ARM instruction but Subtarget is in Thumb "
"mode!");
// We want to read exactly 4 bytes of data.
- if (Region.readBytes(Address, 4, Bytes) == -1) {
+ if (Bytes.size() < 4) {
Size = 0;
return MCDisassembler::Fail;
}
@@ -673,19 +670,17 @@ void ThumbDisassembler::UpdateThumbVFPPredicate(MCInst &MI) const {
}
DecodeStatus ThumbDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
- const MemoryObject &Region,
+ ArrayRef<uint8_t> Bytes,
uint64_t Address,
raw_ostream &OS,
raw_ostream &CS) const {
CommentStream = &CS;
- uint8_t Bytes[4];
-
assert((STI.getFeatureBits() & ARM::ModeThumb) &&
"Asked to disassemble in Thumb mode but Subtarget is in ARM mode!");
// We want to read exactly 2 bytes of data.
- if (Region.readBytes(Address, 2, Bytes) == -1) {
+ if (Bytes.size() < 2) {
Size = 0;
return MCDisassembler::Fail;
}
@@ -737,7 +732,7 @@ DecodeStatus ThumbDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
}
// We want to read exactly 4 bytes of data.
- if (Region.readBytes(Address, 4, Bytes) == -1) {
+ if (Bytes.size() < 4) {
Size = 0;
return MCDisassembler::Fail;
}
diff --git a/llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp b/llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp
index 4899c505725..c213abb026e 100644
--- a/llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp
+++ b/llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp
@@ -20,7 +20,6 @@
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/LEB128.h"
-#include "llvm/Support/MemoryObject.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/Endian.h"
@@ -43,7 +42,7 @@ public:
: MCDisassembler(STI, Ctx) {}
DecodeStatus getInstruction(MCInst &Instr, uint64_t &Size,
- MemoryObject const &Region, uint64_t Address,
+ ArrayRef<uint8_t> Bytes, uint64_t Address,
raw_ostream &VStream,
raw_ostream &CStream) const override;
};
@@ -63,13 +62,12 @@ extern "C" void LLVMInitializeHexagonDisassembler() {
}
DecodeStatus HexagonDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
- MemoryObject const &Region,
+ ArrayRef<uint8_t> Bytes,
uint64_t Address,
raw_ostream &os,
raw_ostream &cs) const {
- std::array<uint8_t, 4> Bytes;
Size = 4;
- if (Region.readBytes(Address, Bytes.size(), Bytes.data()) == -1)
+ if (Bytes.size() < 4)
return MCDisassembler::Fail;
uint32_t insn =
diff --git a/llvm/lib/Target/Mips/Disassembler/MipsDisassembler.cpp b/llvm/lib/Target/Mips/Disassembler/MipsDisassembler.cpp
index d733b1b85d6..5d594f1f426 100644
--- a/llvm/lib/Target/Mips/Disassembler/MipsDisassembler.cpp
+++ b/llvm/lib/Target/Mips/Disassembler/MipsDisassembler.cpp
@@ -20,7 +20,6 @@
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/Support/MathExtras.h"
-#include "llvm/Support/MemoryObject.h"
#include "llvm/Support/TargetRegistry.h"
using namespace llvm;
@@ -73,7 +72,7 @@ public:
}
DecodeStatus getInstruction(MCInst &Instr, uint64_t &Size,
- const MemoryObject &Region, uint64_t Address,
+ ArrayRef<uint8_t> Bytes, uint64_t Address,
raw_ostream &VStream,
raw_ostream &CStream) const override;
};
@@ -86,7 +85,7 @@ public:
MipsDisassemblerBase(STI, Ctx, bigEndian) {}
DecodeStatus getInstruction(MCInst &Instr, uint64_t &Size,
- const MemoryObject &Region, uint64_t Address,
+ ArrayRef<uint8_t> Bytes, uint64_t Address,
raw_ostream &VStream,
raw_ostream &CStream) const override;
};
@@ -697,16 +696,13 @@ static DecodeStatus DecodeBlezGroupBranch(MCInst &MI, InsnType insn,
return MCDisassembler::Success;
}
-/// Read four bytes from the MemoryObject and return 32 bit word sorted
+/// Read four bytes from the ArrayRef and return 32 bit word sorted
/// according to the given endianess
-static DecodeStatus readInstruction32(const MemoryObject &Region,
- uint64_t Address, uint64_t &Size,
- uint32_t &Insn, bool IsBigEndian,
- bool IsMicroMips) {
- uint8_t Bytes[4];
-
+static DecodeStatus readInstruction32(ArrayRef<uint8_t> Bytes, uint64_t Address,
+ uint64_t &Size, uint32_t &Insn,
+ bool IsBigEndian, bool IsMicroMips) {
// We want to read exactly 4 Bytes of data.
- if (Region.readBytes(Address, 4, Bytes) == -1) {
+ if (Bytes.size() < 4) {
Size = 0;
return MCDisassembler::Fail;
}
@@ -733,14 +729,14 @@ static DecodeStatus readInstruction32(const MemoryObject &Region,
}
DecodeStatus MipsDisassembler::getInstruction(MCInst &Instr, uint64_t &Size,
- const MemoryObject &Region,
+ ArrayRef<uint8_t> Bytes,
uint64_t Address,
raw_ostream &VStream,
raw_ostream &CStream) const {
uint32_t Insn;
DecodeStatus Result =
- readInstruction32(Region, Address, Size, Insn, IsBigEndian, IsMicroMips);
+ readInstruction32(Bytes, Address, Size, Insn, IsBigEndian, IsMicroMips);
if (Result == MCDisassembler::Fail)
return MCDisassembler::Fail;
@@ -799,14 +795,14 @@ DecodeStatus MipsDisassembler::getInstruction(MCInst &Instr, uint64_t &Size,
}
DecodeStatus Mips64Disassembler::getInstruction(MCInst &Instr, uint64_t &Size,
- const MemoryObject &Region,
+ ArrayRef<uint8_t> Bytes,
uint64_t Address,
raw_ostream &VStream,
raw_ostream &CStream) const {
uint32_t Insn;
DecodeStatus Result =
- readInstruction32(Region, Address, Size, Insn, IsBigEndian, false);
+ readInstruction32(Bytes, Address, Size, Insn, IsBigEndian, false);
if (Result == MCDisassembler::Fail)
return MCDisassembler::Fail;
diff --git a/llvm/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp b/llvm/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp
index 101d1caa7e2..5251b60f348 100644
--- a/llvm/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp
+++ b/llvm/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp
@@ -12,7 +12,6 @@
#include "llvm/MC/MCFixedLenDisassembler.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCSubtargetInfo.h"
-#include "llvm/Support/MemoryObject.h"
#include "llvm/Support/TargetRegistry.h"
using namespace llvm;
@@ -29,7 +28,7 @@ public:
virtual ~PPCDisassembler() {}
DecodeStatus getInstruction(MCInst &Instr, uint64_t &Size,
- const MemoryObject &Region, uint64_t Address,
+ ArrayRef<uint8_t> Bytes, uint64_t Address,
raw_ostream &VStream,
raw_ostream &CStream) const override;
};
@@ -322,13 +321,12 @@ static DecodeStatus decodeCRBitMOperand(MCInst &Inst, uint64_t Imm,
#include "PPCGenDisassemblerTables.inc"
DecodeStatus PPCDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
- const MemoryObject &Region,
+ ArrayRef<uint8_t> Bytes,
uint64_t Address, raw_ostream &OS,
raw_ostream &CS) const {
// Get the four bytes of the instruction.
- uint8_t Bytes[4];
Size = 4;
- if (Region.readBytes(Address, Size, Bytes) == -1) {
+ if (Bytes.size() < 4) {
Size = 0;
return MCDisassembler::Fail;
}
diff --git a/llvm/lib/Target/Sparc/Disassembler/SparcDisassembler.cpp b/llvm/lib/Target/Sparc/Disassembler/SparcDisassembler.cpp
index 0e81302abfb..8bc4ca98161 100644
--- a/llvm/lib/Target/Sparc/Disassembler/SparcDisassembler.cpp
+++ b/llvm/lib/Target/Sparc/Disassembler/SparcDisassembler.cpp
@@ -16,7 +16,6 @@
#include "SparcSubtarget.h"
#include "llvm/MC/MCDisassembler.h"
#include "llvm/MC/MCFixedLenDisassembler.h"
-#include "llvm/Support/MemoryObject.h"
#include "llvm/Support/TargetRegistry.h"
using namespace llvm;
@@ -35,7 +34,7 @@ public:
virtual ~SparcDisassembler() {}
DecodeStatus getInstruction(MCInst &Instr, uint64_t &Size,
- const MemoryObject &Region, uint64_t Address,
+ ArrayRef<uint8_t> Bytes, uint64_t Address,
raw_ostream &VStream,
raw_ostream &CStream) const override;
};
@@ -207,14 +206,11 @@ static DecodeStatus DecodeSWAP(MCInst &Inst, unsigned insn, uint64_t Address,
#include "SparcGenDisassemblerTables.inc"
-/// Read four bytes from the MemoryObject and return 32 bit word.
-static DecodeStatus readInstruction32(const MemoryObject &Region,
- uint64_t Address, uint64_t &Size,
- uint32_t &Insn) {
- uint8_t Bytes[4];
-
+/// Read four bytes from the ArrayRef and return 32 bit word.
+static DecodeStatus readInstruction32(ArrayRef<uint8_t> Bytes, uint64_t Address,
+ uint64_t &Size, uint32_t &Insn) {
// We want to read exactly 4 Bytes of data.
- if (Region.readBytes(Address, 4, Bytes) == -1) {
+ if (Bytes.size() < 4) {
Size = 0;
return MCDisassembler::Fail;
}
@@ -227,13 +223,13 @@ static DecodeStatus readInstruction32(const MemoryObject &Region,
}
DecodeStatus SparcDisassembler::getInstruction(MCInst &Instr, uint64_t &Size,
- const MemoryObject &Region,
+ ArrayRef<uint8_t> Bytes,
uint64_t Address,
raw_ostream &VStream,
raw_ostream &CStream) const {
uint32_t Insn;
- DecodeStatus Result = readInstruction32(Region, Address, Size, Insn);
+ DecodeStatus Result = readInstruction32(Bytes, Address, Size, Insn);
if (Result == MCDisassembler::Fail)
return MCDisassembler::Fail;
diff --git a/llvm/lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp b/llvm/lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp
index 2b0ae3ca7de..23173bfbd91 100644
--- a/llvm/lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp
+++ b/llvm/lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp
@@ -12,7 +12,6 @@
#include "llvm/MC/MCFixedLenDisassembler.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCSubtargetInfo.h"
-#include "llvm/Support/MemoryObject.h"
#include "llvm/Support/TargetRegistry.h"
using namespace llvm;
@@ -28,8 +27,8 @@ public:
: MCDisassembler(STI, Ctx) {}
virtual ~SystemZDisassembler() {}
- DecodeStatus getInstruction(MCInst &Instr, uint64_t &Size,
- const MemoryObject &Region, uint64_t Address,
+ DecodeStatus getInstruction(MCInst &instr, uint64_t &Size,
+ ArrayRef<uint8_t> Bytes, uint64_t Address,
raw_ostream &VStream,
raw_ostream &CStream) const override;
};
@@ -287,14 +286,13 @@ static DecodeStatus decodeBDLAddr64Disp12Len8Operand(MCInst &Inst,
#include "SystemZGenDisassemblerTables.inc"
DecodeStatus SystemZDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
- const MemoryObject &Region,
+ ArrayRef<uint8_t> Bytes,
uint64_t Address,
raw_ostream &OS,
raw_ostream &CS) const {
// Get the first two bytes of the instruction.
- uint8_t Bytes[6];
Size = 0;
- if (Region.readBytes(Address, 2, Bytes) == -1)
+ if (Bytes.size() < 2)
return MCDisassembler::Fail;
// The top 2 bits of the first byte specify the size.
@@ -311,7 +309,7 @@ DecodeStatus SystemZDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
}
// Read any remaining bytes.
- if (Size > 2 && Region.readBytes(Address + 2, Size - 2, Bytes + 2) == -1)
+ if (Bytes.size() < Size)
return MCDisassembler::Fail;
// Construct the instruction.
diff --git a/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp b/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp
index 5ceba2fac05..5e8c2d609f6 100644
--- a/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp
+++ b/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp
@@ -23,7 +23,6 @@
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/Support/Debug.h"
-#include "llvm/Support/MemoryObject.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/raw_ostream.h"
@@ -97,15 +96,26 @@ X86GenericDisassembler::X86GenericDisassembler(
}
}
-/// A callback function that wraps the readByte method from MemoryObject.
+struct Region {
+ ArrayRef<uint8_t> Bytes;
+ uint64_t Base;
+ Region(ArrayRef<uint8_t> Bytes, uint64_t Base) : Bytes(Bytes), Base(Base) {}
+};
+
+/// 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 MemoryObject.
+/// 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) {
- const MemoryObject *Region = static_cast<const MemoryObject *>(Arg);
- return Region->readByte(Address, Byte);
+ 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
@@ -127,7 +137,7 @@ static void logger(void* arg, const char* log) {
//
MCDisassembler::DecodeStatus X86GenericDisassembler::getInstruction(
- MCInst &Instr, uint64_t &Size, const MemoryObject &Region, uint64_t Address,
+ MCInst &Instr, uint64_t &Size, ArrayRef<uint8_t> Bytes, uint64_t Address,
raw_ostream &VStream, raw_ostream &CStream) const {
CommentStream = &CStream;
@@ -137,8 +147,10 @@ MCDisassembler::DecodeStatus X86GenericDisassembler::getInstruction(
if (&VStream == &nulls())
LoggerFn = nullptr; // Disable logging completely if it's going to nulls().
- int Ret = decodeInstruction(&InternalInstr, regionReader,
- (const void *)&Region, LoggerFn, (void *)&VStream,
+ Region R(Bytes, Address);
+
+ int Ret = decodeInstruction(&InternalInstr, regionReader, (const void *)&R,
+ LoggerFn, (void *)&VStream,
(const void *)MII.get(), Address, fMode);
if (Ret) {
diff --git a/llvm/lib/Target/X86/Disassembler/X86Disassembler.h b/llvm/lib/Target/X86/Disassembler/X86Disassembler.h
index 9f0346c5550..d7f426b2641 100644
--- a/llvm/lib/Target/X86/Disassembler/X86Disassembler.h
+++ b/llvm/lib/Target/X86/Disassembler/X86Disassembler.h
@@ -97,7 +97,7 @@ public:
std::unique_ptr<const MCInstrInfo> MII);
public:
DecodeStatus getInstruction(MCInst &instr, uint64_t &size,
- const MemoryObject &region, uint64_t address,
+ ArrayRef<uint8_t> Bytes, uint64_t Address,
raw_ostream &vStream,
raw_ostream &cStream) const override;
diff --git a/llvm/lib/Target/XCore/Disassembler/XCoreDisassembler.cpp b/llvm/lib/Target/XCore/Disassembler/XCoreDisassembler.cpp
index 7ac0a55b68a..640e6b09d64 100644
--- a/llvm/lib/Target/XCore/Disassembler/XCoreDisassembler.cpp
+++ b/llvm/lib/Target/XCore/Disassembler/XCoreDisassembler.cpp
@@ -19,7 +19,6 @@
#include "llvm/MC/MCFixedLenDisassembler.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCSubtargetInfo.h"
-#include "llvm/Support/MemoryObject.h"
#include "llvm/Support/TargetRegistry.h"
using namespace llvm;
@@ -37,18 +36,16 @@ public:
MCDisassembler(STI, Ctx) {}
DecodeStatus getInstruction(MCInst &Instr, uint64_t &Size,
- const MemoryObject &Region, uint64_t Address,
+ ArrayRef<uint8_t> Bytes, uint64_t Address,
raw_ostream &VStream,
raw_ostream &CStream) const override;
};
}
-static bool readInstruction16(const MemoryObject &Region, uint64_t Address,
+static bool readInstruction16(ArrayRef<uint8_t> Bytes, uint64_t Address,
uint64_t &Size, uint16_t &Insn) {
- uint8_t Bytes[4];
-
// We want to read exactly 2 Bytes of data.
- if (Region.readBytes(Address, 2, Bytes) == -1) {
+ if (Bytes.size() < 2) {
Size = 0;
return false;
}
@@ -57,12 +54,10 @@ static bool readInstruction16(const MemoryObject &Region, uint64_t Address,
return true;
}
-static bool readInstruction32(const MemoryObject &Region, uint64_t Address,
+static bool readInstruction32(ArrayRef<uint8_t> Bytes, uint64_t Address,
uint64_t &Size, uint32_t &Insn) {
- uint8_t Bytes[4];
-
// We want to read exactly 4 Bytes of data.
- if (Region.readBytes(Address, 4, Bytes) == -1) {
+ if (Bytes.size() < 4) {
Size = 0;
return false;
}
@@ -741,11 +736,11 @@ DecodeL4RSrcDstSrcDstInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
}
MCDisassembler::DecodeStatus XCoreDisassembler::getInstruction(
- MCInst &instr, uint64_t &Size, const MemoryObject &Region, uint64_t Address,
+ MCInst &instr, uint64_t &Size, ArrayRef<uint8_t> Bytes, uint64_t Address,
raw_ostream &vStream, raw_ostream &cStream) const {
uint16_t insn16;
- if (!readInstruction16(Region, Address, Size, insn16)) {
+ if (!readInstruction16(Bytes, Address, Size, insn16)) {
return Fail;
}
@@ -759,7 +754,7 @@ MCDisassembler::DecodeStatus XCoreDisassembler::getInstruction(
uint32_t insn32;
- if (!readInstruction32(Region, Address, Size, insn32)) {
+ if (!readInstruction32(Bytes, Address, Size, insn32)) {
return Fail;
}
OpenPOWER on IntegriCloud