Skip to content

Commit cac14b5

Browse files
author
Strahinja Petrovic
committed
[Mips] Fix for decoding DINS instruction - disassembler
This patch fixes decoding of size and position for DINSM and DINSU instructions. Differential Revision: https://reviews.llvm.org/D31072 llvm-svn: 298593
1 parent d341290 commit cac14b5

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

llvm/lib/Target/Mips/Disassembler/MipsDisassembler.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2264,7 +2264,14 @@ static DecodeStatus DecodeInsSize(MCInst &Inst,
22642264
const void *Decoder) {
22652265
// First we need to grab the pos(lsb) from MCInst.
22662266
int Pos = Inst.getOperand(2).getImm();
2267-
int Size = (int) Insn - Pos + 1;
2267+
if (Inst.getOpcode() == Mips::DINSU)
2268+
Pos += 32;
2269+
int Size;
2270+
if (Inst.getOpcode() == Mips::DINSM ||
2271+
Inst.getOpcode() == Mips::DINSU)
2272+
Size = (int) Insn - Pos + 33;
2273+
else
2274+
Size = (int) Insn - Pos + 1;
22682275
Inst.addOperand(MCOperand::createImm(SignExtend32<16>(Size)));
22692276
return MCDisassembler::Success;
22702277
}

llvm/test/MC/Mips/mips64extins.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
dextu $2, $4, 34, 6 # CHECK: dextu ${{[0-9]+}}, ${{[0-9]+}}, 34, 6
66
dextm $2, $4, 5, 34 # CHECK: dextm ${{[0-9]+}}, ${{[0-9]+}}, 5, 34
77
dins $4, $5, 8, 10 # CHECK: dins ${{[0-9]+}}, ${{[0-9]+}}, 8, 10
8-
dinsm $4, $5, 10, 1 # CHECK: dinsm ${{[0-9]+}}, ${{[0-9]+}}, 10, 1
8+
dinsm $4, $5, 30, 6 # CHECK: dinsm ${{[0-9]+}}, ${{[0-9]+}}, 30, 6
99
dinsu $4, $5, 40, 13 # CHECK: dinsu ${{[0-9]+}}, ${{[0-9]+}}, 40, 13

0 commit comments

Comments
 (0)