mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-17 03:24:34 +00:00
[Mips][Disassembler] When disassembler meets cache/pref instructions for r6 it crashes as the access to operands array is out of range. This patch adds dedicated decoder method for R6 CACHE_HINT_DESC class that properly handles decoding of these instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227430 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -266,6 +266,11 @@ static DecodeStatus DecodeCacheOp(MCInst &Inst,
|
|||||||
uint64_t Address,
|
uint64_t Address,
|
||||||
const void *Decoder);
|
const void *Decoder);
|
||||||
|
|
||||||
|
static DecodeStatus DecodeCacheOpR6(MCInst &Inst,
|
||||||
|
unsigned Insn,
|
||||||
|
uint64_t Address,
|
||||||
|
const void *Decoder);
|
||||||
|
|
||||||
static DecodeStatus DecodeCacheOpMM(MCInst &Inst,
|
static DecodeStatus DecodeCacheOpMM(MCInst &Inst,
|
||||||
unsigned Insn,
|
unsigned Insn,
|
||||||
uint64_t Address,
|
uint64_t Address,
|
||||||
@@ -1137,6 +1142,23 @@ static DecodeStatus DecodeCacheOpMM(MCInst &Inst,
|
|||||||
return MCDisassembler::Success;
|
return MCDisassembler::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DecodeStatus DecodeCacheOpR6(MCInst &Inst,
|
||||||
|
unsigned Insn,
|
||||||
|
uint64_t Address,
|
||||||
|
const void *Decoder) {
|
||||||
|
int Offset = fieldFromInstruction(Insn, 7, 9);
|
||||||
|
unsigned Hint = fieldFromInstruction(Insn, 16, 5);
|
||||||
|
unsigned Base = fieldFromInstruction(Insn, 21, 5);
|
||||||
|
|
||||||
|
Base = getReg(Decoder, Mips::GPR32RegClassID, Base);
|
||||||
|
|
||||||
|
Inst.addOperand(MCOperand::CreateReg(Base));
|
||||||
|
Inst.addOperand(MCOperand::CreateImm(Offset));
|
||||||
|
Inst.addOperand(MCOperand::CreateImm(Hint));
|
||||||
|
|
||||||
|
return MCDisassembler::Success;
|
||||||
|
}
|
||||||
|
|
||||||
static DecodeStatus DecodeSyncI(MCInst &Inst,
|
static DecodeStatus DecodeSyncI(MCInst &Inst,
|
||||||
unsigned Insn,
|
unsigned Insn,
|
||||||
uint64_t Address,
|
uint64_t Address,
|
||||||
|
@@ -549,6 +549,7 @@ class CACHE_HINT_DESC<string instr_asm, Operand MemOpnd,
|
|||||||
dag InOperandList = (ins MemOpnd:$addr, uimm5:$hint);
|
dag InOperandList = (ins MemOpnd:$addr, uimm5:$hint);
|
||||||
string AsmString = !strconcat(instr_asm, "\t$hint, $addr");
|
string AsmString = !strconcat(instr_asm, "\t$hint, $addr");
|
||||||
list<dag> Pattern = [];
|
list<dag> Pattern = [];
|
||||||
|
string DecoderMethod = "DecodeCacheOpR6";
|
||||||
}
|
}
|
||||||
|
|
||||||
class CACHE_DESC : CACHE_HINT_DESC<"cache", mem_simm9, GPR32Opnd>;
|
class CACHE_DESC : CACHE_HINT_DESC<"cache", mem_simm9, GPR32Opnd>;
|
||||||
|
@@ -144,3 +144,5 @@
|
|||||||
0x30 0x81 0x79 0x49 # CHECK: swc2 $25, 304($16)
|
0x30 0x81 0x79 0x49 # CHECK: swc2 $25, 304($16)
|
||||||
0x00 0x01 0x05 0xf8 # CHECK: jialc $5, 256
|
0x00 0x01 0x05 0xf8 # CHECK: jialc $5, 256
|
||||||
0x00 0x01 0x05 0xd8 # CHECK: jic $5, 256
|
0x00 0x01 0x05 0xd8 # CHECK: jic $5, 256
|
||||||
|
0x25 0x04 0xa1 0x7c # CHECK: cache 1, 8($5)
|
||||||
|
0x35 0x04 0xa1 0x7c # CHECK: pref 1, 8($5
|
||||||
|
@@ -144,4 +144,5 @@
|
|||||||
0x49 0x79 0x81 0x30 # CHECK: swc2 $25, 304($16)
|
0x49 0x79 0x81 0x30 # CHECK: swc2 $25, 304($16)
|
||||||
0xf8 0x05 0x01 0x00 # CHECK: jialc $5, 256
|
0xf8 0x05 0x01 0x00 # CHECK: jialc $5, 256
|
||||||
0xd8 0x05 0x01 0x00 # CHECK: jic $5, 256
|
0xd8 0x05 0x01 0x00 # CHECK: jic $5, 256
|
||||||
|
0x7c 0xa1 0x04 0x25 # CHECK: cache 1, 8($5)
|
||||||
|
0x7c 0xa1 0x04 0x35 # CHECK: pref 1, 8($5)
|
||||||
|
@@ -13,5 +13,3 @@
|
|||||||
0x60 0xc0 0x00 0x40 # CHECK: bnec $6, $zero, 256
|
0x60 0xc0 0x00 0x40 # CHECK: bnec $6, $zero, 256
|
||||||
0x60 0xa0 0x00 0x40 # CHECK: bnec $5, $zero, 256
|
0x60 0xa0 0x00 0x40 # CHECK: bnec $5, $zero, 256
|
||||||
0x60 0xa6 0x00 0x40 # CHECK: bnec $5, $6, 256
|
0x60 0xa6 0x00 0x40 # CHECK: bnec $5, $6, 256
|
||||||
0x7c 0xa1 0x04 0x25 # CHECK: cache 1, 8($5)
|
|
||||||
0x7c 0xa1 0x04 0x35 # CHECK: pref 1, 8($5)
|
|
||||||
|
@@ -162,4 +162,5 @@
|
|||||||
0x30 0x81 0x79 0x49 # CHECK: swc2 $25, 304($16)
|
0x30 0x81 0x79 0x49 # CHECK: swc2 $25, 304($16)
|
||||||
0x00 0x01 0x05 0xf8 # CHECK: jialc $5, 256
|
0x00 0x01 0x05 0xf8 # CHECK: jialc $5, 256
|
||||||
0x00 0x01 0x05 0xd8 # CHECK: jic $5, 256
|
0x00 0x01 0x05 0xd8 # CHECK: jic $5, 256
|
||||||
|
0x25 0x04 0xa1 0x7c # CHECK: cache 1, 8($5)
|
||||||
|
0x35 0x04 0xa1 0x7c # CHECK: pref 1, 8($5)
|
||||||
|
@@ -162,4 +162,5 @@
|
|||||||
0x49 0x79 0x81 0x30 # CHECK: swc2 $25, 304($16)
|
0x49 0x79 0x81 0x30 # CHECK: swc2 $25, 304($16)
|
||||||
0xf8 0x05 0x01 0x00 # CHECK: jialc $5, 256
|
0xf8 0x05 0x01 0x00 # CHECK: jialc $5, 256
|
||||||
0xd8 0x05 0x01 0x00 # CHECK: jic $5, 256
|
0xd8 0x05 0x01 0x00 # CHECK: jic $5, 256
|
||||||
|
0x7c 0xa1 0x04 0x25 # CHECK: cache 1, 8($5)
|
||||||
|
0x7c 0xa1 0x04 0x35 # CHECK: pref 1, 8($5)
|
||||||
|
@@ -13,8 +13,6 @@
|
|||||||
0x60 0xc0 0x00 0x40 # CHECK: bnec $6, $zero, 256
|
0x60 0xc0 0x00 0x40 # CHECK: bnec $6, $zero, 256
|
||||||
0x60 0xa0 0x00 0x40 # CHECK: bnec $5, $zero, 256
|
0x60 0xa0 0x00 0x40 # CHECK: bnec $5, $zero, 256
|
||||||
0x60 0xa6 0x00 0x40 # CHECK: bnec $5, $6, 256
|
0x60 0xa6 0x00 0x40 # CHECK: bnec $5, $6, 256
|
||||||
0x7c 0xa1 0x04 0x25 # CHECK: cache 1, 8($5)
|
|
||||||
0x7c 0xa1 0x04 0x35 # CHECK: pref 1, 8($5)
|
|
||||||
0x64 0x58 0x46 0x9f # CHECK: daddiu $24, $2, 18079
|
0x64 0x58 0x46 0x9f # CHECK: daddiu $24, $2, 18079
|
||||||
0x66 0x73 0x69 0x3f # CHECK: daddiu $19, $19, 26943
|
0x66 0x73 0x69 0x3f # CHECK: daddiu $19, $19, 26943
|
||||||
0x65 0x6f 0xec 0x5f # CHECK: daddiu $15, $11, -5025
|
0x65 0x6f 0xec 0x5f # CHECK: daddiu $15, $11, -5025
|
||||||
|
Reference in New Issue
Block a user