From 8ee8b3b28ceb4b453c7b4129d94915c6365d872b Mon Sep 17 00:00:00 2001 From: Strahinja Petrovic Date: Thu, 23 Mar 2017 13:19:04 +0000 Subject: [PATCH] [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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298593 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/Mips/Disassembler/MipsDisassembler.cpp | 9 ++++++++- test/MC/Mips/mips64extins.s | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/Target/Mips/Disassembler/MipsDisassembler.cpp b/lib/Target/Mips/Disassembler/MipsDisassembler.cpp index 4098ea796bf..ecdf6b0de6e 100644 --- a/lib/Target/Mips/Disassembler/MipsDisassembler.cpp +++ b/lib/Target/Mips/Disassembler/MipsDisassembler.cpp @@ -2264,7 +2264,14 @@ static DecodeStatus DecodeInsSize(MCInst &Inst, const void *Decoder) { // First we need to grab the pos(lsb) from MCInst. int Pos = Inst.getOperand(2).getImm(); - int Size = (int) Insn - Pos + 1; + if (Inst.getOpcode() == Mips::DINSU) + Pos += 32; + int Size; + if (Inst.getOpcode() == Mips::DINSM || + Inst.getOpcode() == Mips::DINSU) + Size = (int) Insn - Pos + 33; + else + Size = (int) Insn - Pos + 1; Inst.addOperand(MCOperand::createImm(SignExtend32<16>(Size))); return MCDisassembler::Success; } diff --git a/test/MC/Mips/mips64extins.s b/test/MC/Mips/mips64extins.s index 3f1973bf52d..5bd18ff62d5 100644 --- a/test/MC/Mips/mips64extins.s +++ b/test/MC/Mips/mips64extins.s @@ -5,5 +5,5 @@ dextu $2, $4, 34, 6 # CHECK: dextu ${{[0-9]+}}, ${{[0-9]+}}, 34, 6 dextm $2, $4, 5, 34 # CHECK: dextm ${{[0-9]+}}, ${{[0-9]+}}, 5, 34 dins $4, $5, 8, 10 # CHECK: dins ${{[0-9]+}}, ${{[0-9]+}}, 8, 10 - dinsm $4, $5, 10, 1 # CHECK: dinsm ${{[0-9]+}}, ${{[0-9]+}}, 10, 1 + dinsm $4, $5, 30, 6 # CHECK: dinsm ${{[0-9]+}}, ${{[0-9]+}}, 30, 6 dinsu $4, $5, 40, 13 # CHECK: dinsu ${{[0-9]+}}, ${{[0-9]+}}, 40, 13 -- 2.11.0