1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[mips] Fix calculation of a branch instruction offset to escape left shift of negative value

llvm-svn: 313815
This commit is contained in:
Simon Atanasyan 2017-09-20 21:01:30 +00:00
parent 8b8ba5f251
commit 837de6973e
2 changed files with 10 additions and 5 deletions

View File

@ -2278,7 +2278,7 @@ static DecodeStatus DecodeBranchTarget7MM(MCInst &Inst,
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 DecodeBranchTarget10MM(MCInst &Inst,
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 DecodeBranchTarget26MM(MCInst &Inst,
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;

View File

@ -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