[llvm] r313815 - [mips] Fix calculation of a branch instruction offset to escape left shift of negative value
Simon Atanasyan via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 20 14:01:30 PDT 2017
Author: atanasyan
Date: Wed Sep 20 14:01:30 2017
New Revision: 313815
URL: http://llvm.org/viewvc/llvm-project?rev=313815&view=rev
Log:
[mips] Fix calculation of a branch instruction offset to escape left shift of negative value
Modified:
llvm/trunk/lib/Target/Mips/Disassembler/MipsDisassembler.cpp
llvm/trunk/test/MC/Mips/micromips-neg-offset.s
Modified: llvm/trunk/lib/Target/Mips/Disassembler/MipsDisassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/Disassembler/MipsDisassembler.cpp?rev=313815&r1=313814&r2=313815&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/Disassembler/MipsDisassembler.cpp (original)
+++ llvm/trunk/lib/Target/Mips/Disassembler/MipsDisassembler.cpp Wed Sep 20 14:01:30 2017
@@ -2278,7 +2278,7 @@ static DecodeStatus DecodeBranchTarget7M
unsigned Offset,
uint64_t Address,
const void *Decoder) {
- int32_t BranchOffset = SignExtend32<7>(Offset) << 1;
+ int32_t BranchOffset = SignExtend32<8>(Offset << 1);
Inst.addOperand(MCOperand::createImm(BranchOffset));
return MCDisassembler::Success;
}
@@ -2287,7 +2287,7 @@ static DecodeStatus DecodeBranchTarget10
unsigned Offset,
uint64_t Address,
const void *Decoder) {
- int32_t BranchOffset = SignExtend32<10>(Offset) << 1;
+ int32_t BranchOffset = SignExtend32<11>(Offset << 1);
Inst.addOperand(MCOperand::createImm(BranchOffset));
return MCDisassembler::Success;
}
@@ -2305,7 +2305,7 @@ static DecodeStatus DecodeBranchTarget26
unsigned Offset,
uint64_t Address,
const void *Decoder) {
- int32_t BranchOffset = SignExtend32<26>(Offset) << 1;
+ int32_t BranchOffset = SignExtend32<27>(Offset << 1);
Inst.addOperand(MCOperand::createImm(BranchOffset));
return MCDisassembler::Success;
Modified: llvm/trunk/test/MC/Mips/micromips-neg-offset.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/micromips-neg-offset.s?rev=313815&r1=313814&r2=313815&view=diff
==============================================================================
--- llvm/trunk/test/MC/Mips/micromips-neg-offset.s (original)
+++ llvm/trunk/test/MC/Mips/micromips-neg-offset.s Wed Sep 20 14:01:30 2017
@@ -1,8 +1,13 @@
# Check decoding beqz instruction with a negative offset
-# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux -mattr=micromips %s -o - \
+# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
+# RUN: -mattr=micromips -mcpu=mips32r6 %s -o - \
# RUN: | llvm-objdump -d -mattr=micromips - | FileCheck %s
-# CHECK: 0: 8f 7e beqz16 $6, -4
+# CHECK: 0: 8f 7e beqzc16 $6, -4
+# CHECK: 6: cf fe bc16 -4
+# CHECK: c: b7 ff ff fe balc -4
beqz16 $6, -4
+b16 -4
+balc -4
More information about the llvm-commits
mailing list