Explicitly clear the MI operand list when getInstruction() is called. Call MI.clear() within MCD::OPC_Decode case and inside of translateInstruction() for the X86 target. Remove now unnecessary MI.clear() from ARMDisassembler.
Summary: Explicitly clear the MI operand list when getInstruction() is called. Reviewers: hfinkel, t.p.northover, hvarga, kparzysz, jyknight, qcolombet, uweigand Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D11665 llvm-svn: 244557
This commit is contained in:
parent
65061a293b
commit
f97999dc46
|
@ -459,21 +459,18 @@ DecodeStatus ARMDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
|
||||||
|
|
||||||
// VFP and NEON instructions, similarly, are shared between ARM
|
// VFP and NEON instructions, similarly, are shared between ARM
|
||||||
// and Thumb modes.
|
// and Thumb modes.
|
||||||
MI.clear();
|
|
||||||
Result = decodeInstruction(DecoderTableVFP32, MI, Insn, Address, this, STI);
|
Result = decodeInstruction(DecoderTableVFP32, MI, Insn, Address, this, STI);
|
||||||
if (Result != MCDisassembler::Fail) {
|
if (Result != MCDisassembler::Fail) {
|
||||||
Size = 4;
|
Size = 4;
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
MI.clear();
|
|
||||||
Result = decodeInstruction(DecoderTableVFPV832, MI, Insn, Address, this, STI);
|
Result = decodeInstruction(DecoderTableVFPV832, MI, Insn, Address, this, STI);
|
||||||
if (Result != MCDisassembler::Fail) {
|
if (Result != MCDisassembler::Fail) {
|
||||||
Size = 4;
|
Size = 4;
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
MI.clear();
|
|
||||||
Result =
|
Result =
|
||||||
decodeInstruction(DecoderTableNEONData32, MI, Insn, Address, this, STI);
|
decodeInstruction(DecoderTableNEONData32, MI, Insn, Address, this, STI);
|
||||||
if (Result != MCDisassembler::Fail) {
|
if (Result != MCDisassembler::Fail) {
|
||||||
|
@ -485,7 +482,6 @@ DecodeStatus ARMDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
MI.clear();
|
|
||||||
Result = decodeInstruction(DecoderTableNEONLoadStore32, MI, Insn, Address,
|
Result = decodeInstruction(DecoderTableNEONLoadStore32, MI, Insn, Address,
|
||||||
this, STI);
|
this, STI);
|
||||||
if (Result != MCDisassembler::Fail) {
|
if (Result != MCDisassembler::Fail) {
|
||||||
|
@ -497,7 +493,6 @@ DecodeStatus ARMDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
MI.clear();
|
|
||||||
Result =
|
Result =
|
||||||
decodeInstruction(DecoderTableNEONDup32, MI, Insn, Address, this, STI);
|
decodeInstruction(DecoderTableNEONDup32, MI, Insn, Address, this, STI);
|
||||||
if (Result != MCDisassembler::Fail) {
|
if (Result != MCDisassembler::Fail) {
|
||||||
|
@ -509,7 +504,6 @@ DecodeStatus ARMDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
MI.clear();
|
|
||||||
Result =
|
Result =
|
||||||
decodeInstruction(DecoderTablev8NEON32, MI, Insn, Address, this, STI);
|
decodeInstruction(DecoderTablev8NEON32, MI, Insn, Address, this, STI);
|
||||||
if (Result != MCDisassembler::Fail) {
|
if (Result != MCDisassembler::Fail) {
|
||||||
|
@ -517,7 +511,6 @@ DecodeStatus ARMDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
MI.clear();
|
|
||||||
Result =
|
Result =
|
||||||
decodeInstruction(DecoderTablev8Crypto32, MI, Insn, Address, this, STI);
|
decodeInstruction(DecoderTablev8Crypto32, MI, Insn, Address, this, STI);
|
||||||
if (Result != MCDisassembler::Fail) {
|
if (Result != MCDisassembler::Fail) {
|
||||||
|
@ -525,7 +518,6 @@ DecodeStatus ARMDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
MI.clear();
|
|
||||||
Size = 0;
|
Size = 0;
|
||||||
return MCDisassembler::Fail;
|
return MCDisassembler::Fail;
|
||||||
}
|
}
|
||||||
|
@ -718,7 +710,6 @@ DecodeStatus ThumbDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
MI.clear();
|
|
||||||
Result = decodeInstruction(DecoderTableThumbSBit16, MI, Insn16, Address, this,
|
Result = decodeInstruction(DecoderTableThumbSBit16, MI, Insn16, Address, this,
|
||||||
STI);
|
STI);
|
||||||
if (Result) {
|
if (Result) {
|
||||||
|
@ -729,7 +720,6 @@ DecodeStatus ThumbDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
MI.clear();
|
|
||||||
Result =
|
Result =
|
||||||
decodeInstruction(DecoderTableThumb216, MI, Insn16, Address, this, STI);
|
decodeInstruction(DecoderTableThumb216, MI, Insn16, Address, this, STI);
|
||||||
if (Result != MCDisassembler::Fail) {
|
if (Result != MCDisassembler::Fail) {
|
||||||
|
@ -763,7 +753,6 @@ DecodeStatus ThumbDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
|
||||||
|
|
||||||
uint32_t Insn32 =
|
uint32_t Insn32 =
|
||||||
(Bytes[3] << 8) | (Bytes[2] << 0) | (Bytes[1] << 24) | (Bytes[0] << 16);
|
(Bytes[3] << 8) | (Bytes[2] << 0) | (Bytes[1] << 24) | (Bytes[0] << 16);
|
||||||
MI.clear();
|
|
||||||
Result =
|
Result =
|
||||||
decodeInstruction(DecoderTableThumb32, MI, Insn32, Address, this, STI);
|
decodeInstruction(DecoderTableThumb32, MI, Insn32, Address, this, STI);
|
||||||
if (Result != MCDisassembler::Fail) {
|
if (Result != MCDisassembler::Fail) {
|
||||||
|
@ -774,7 +763,6 @@ DecodeStatus ThumbDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
MI.clear();
|
|
||||||
Result =
|
Result =
|
||||||
decodeInstruction(DecoderTableThumb232, MI, Insn32, Address, this, STI);
|
decodeInstruction(DecoderTableThumb232, MI, Insn32, Address, this, STI);
|
||||||
if (Result != MCDisassembler::Fail) {
|
if (Result != MCDisassembler::Fail) {
|
||||||
|
@ -784,7 +772,6 @@ DecodeStatus ThumbDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fieldFromInstruction(Insn32, 28, 4) == 0xE) {
|
if (fieldFromInstruction(Insn32, 28, 4) == 0xE) {
|
||||||
MI.clear();
|
|
||||||
Result =
|
Result =
|
||||||
decodeInstruction(DecoderTableVFP32, MI, Insn32, Address, this, STI);
|
decodeInstruction(DecoderTableVFP32, MI, Insn32, Address, this, STI);
|
||||||
if (Result != MCDisassembler::Fail) {
|
if (Result != MCDisassembler::Fail) {
|
||||||
|
@ -794,7 +781,6 @@ DecodeStatus ThumbDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MI.clear();
|
|
||||||
Result =
|
Result =
|
||||||
decodeInstruction(DecoderTableVFPV832, MI, Insn32, Address, this, STI);
|
decodeInstruction(DecoderTableVFPV832, MI, Insn32, Address, this, STI);
|
||||||
if (Result != MCDisassembler::Fail) {
|
if (Result != MCDisassembler::Fail) {
|
||||||
|
@ -803,7 +789,6 @@ DecodeStatus ThumbDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fieldFromInstruction(Insn32, 28, 4) == 0xE) {
|
if (fieldFromInstruction(Insn32, 28, 4) == 0xE) {
|
||||||
MI.clear();
|
|
||||||
Result = decodeInstruction(DecoderTableNEONDup32, MI, Insn32, Address, this,
|
Result = decodeInstruction(DecoderTableNEONDup32, MI, Insn32, Address, this,
|
||||||
STI);
|
STI);
|
||||||
if (Result != MCDisassembler::Fail) {
|
if (Result != MCDisassembler::Fail) {
|
||||||
|
@ -814,7 +799,6 @@ DecodeStatus ThumbDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fieldFromInstruction(Insn32, 24, 8) == 0xF9) {
|
if (fieldFromInstruction(Insn32, 24, 8) == 0xF9) {
|
||||||
MI.clear();
|
|
||||||
uint32_t NEONLdStInsn = Insn32;
|
uint32_t NEONLdStInsn = Insn32;
|
||||||
NEONLdStInsn &= 0xF0FFFFFF;
|
NEONLdStInsn &= 0xF0FFFFFF;
|
||||||
NEONLdStInsn |= 0x04000000;
|
NEONLdStInsn |= 0x04000000;
|
||||||
|
@ -828,7 +812,6 @@ DecodeStatus ThumbDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fieldFromInstruction(Insn32, 24, 4) == 0xF) {
|
if (fieldFromInstruction(Insn32, 24, 4) == 0xF) {
|
||||||
MI.clear();
|
|
||||||
uint32_t NEONDataInsn = Insn32;
|
uint32_t NEONDataInsn = Insn32;
|
||||||
NEONDataInsn &= 0xF0FFFFFF; // Clear bits 27-24
|
NEONDataInsn &= 0xF0FFFFFF; // Clear bits 27-24
|
||||||
NEONDataInsn |= (NEONDataInsn & 0x10000000) >> 4; // Move bit 28 to bit 24
|
NEONDataInsn |= (NEONDataInsn & 0x10000000) >> 4; // Move bit 28 to bit 24
|
||||||
|
@ -841,7 +824,6 @@ DecodeStatus ThumbDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
MI.clear();
|
|
||||||
uint32_t NEONCryptoInsn = Insn32;
|
uint32_t NEONCryptoInsn = Insn32;
|
||||||
NEONCryptoInsn &= 0xF0FFFFFF; // Clear bits 27-24
|
NEONCryptoInsn &= 0xF0FFFFFF; // Clear bits 27-24
|
||||||
NEONCryptoInsn |= (NEONCryptoInsn & 0x10000000) >> 4; // Move bit 28 to bit 24
|
NEONCryptoInsn |= (NEONCryptoInsn & 0x10000000) >> 4; // Move bit 28 to bit 24
|
||||||
|
@ -853,7 +835,6 @@ DecodeStatus ThumbDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
MI.clear();
|
|
||||||
uint32_t NEONv8Insn = Insn32;
|
uint32_t NEONv8Insn = Insn32;
|
||||||
NEONv8Insn &= 0xF3FFFFFF; // Clear bits 27-26
|
NEONv8Insn &= 0xF3FFFFFF; // Clear bits 27-26
|
||||||
Result = decodeInstruction(DecoderTablev8NEON32, MI, NEONv8Insn, Address,
|
Result = decodeInstruction(DecoderTablev8NEON32, MI, NEONv8Insn, Address,
|
||||||
|
@ -864,7 +845,6 @@ DecodeStatus ThumbDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MI.clear();
|
|
||||||
Size = 0;
|
Size = 0;
|
||||||
return MCDisassembler::Fail;
|
return MCDisassembler::Fail;
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,6 +235,7 @@ DecodeStatus HexagonDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
|
||||||
Size = 0;
|
Size = 0;
|
||||||
|
|
||||||
*CurrentBundle = &MI;
|
*CurrentBundle = &MI;
|
||||||
|
MI.clear();
|
||||||
MI.setOpcode(Hexagon::BUNDLE);
|
MI.setOpcode(Hexagon::BUNDLE);
|
||||||
MI.addOperand(MCOperand::createImm(0));
|
MI.addOperand(MCOperand::createImm(0));
|
||||||
while (Result == Success && Complete == false) {
|
while (Result == Success && Complete == false) {
|
||||||
|
|
|
@ -401,8 +401,6 @@ DecodeStatus PPCDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
|
||||||
decodeInstruction(DecoderTableQPX32, MI, Inst, Address, this, STI);
|
decodeInstruction(DecoderTableQPX32, MI, Inst, Address, this, STI);
|
||||||
if (result != MCDisassembler::Fail)
|
if (result != MCDisassembler::Fail)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
MI.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return decodeInstruction(DecoderTable32, MI, Inst, Address, this, STI);
|
return decodeInstruction(DecoderTable32, MI, Inst, Address, this, STI);
|
||||||
|
|
|
@ -962,6 +962,7 @@ static bool translateInstruction(MCInst &mcInst,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mcInst.clear();
|
||||||
mcInst.setOpcode(insn.instructionID);
|
mcInst.setOpcode(insn.instructionID);
|
||||||
// If when reading the prefix bytes we determined the overlapping 0xf2 or 0xf3
|
// If when reading the prefix bytes we determined the overlapping 0xf2 or 0xf3
|
||||||
// prefix bytes should be disassembled as xrelease and xacquire then set the
|
// prefix bytes should be disassembled as xrelease and xacquire then set the
|
||||||
|
|
|
@ -2170,6 +2170,7 @@ static void emitDecodeInstruction(formatted_raw_ostream &OS) {
|
||||||
<< " unsigned DecodeIdx = decodeULEB128(Ptr, &Len);\n"
|
<< " unsigned DecodeIdx = decodeULEB128(Ptr, &Len);\n"
|
||||||
<< " Ptr += Len;\n"
|
<< " Ptr += Len;\n"
|
||||||
<< "\n"
|
<< "\n"
|
||||||
|
<< " MI.clear();\n"
|
||||||
<< " MI.setOpcode(Opc);\n"
|
<< " MI.setOpcode(Opc);\n"
|
||||||
<< " bool DecodeComplete;\n"
|
<< " bool DecodeComplete;\n"
|
||||||
<< " S = decodeToMCInst(S, DecodeIdx, insn, MI, Address, DisAsm, DecodeComplete);\n"
|
<< " S = decodeToMCInst(S, DecodeIdx, insn, MI, Address, DisAsm, DecodeComplete);\n"
|
||||||
|
|
Loading…
Reference in New Issue