forked from OSchip/llvm-project
[PowerPC] Fix printing of negative offsets in call instruction dissasembly.
llvm-svn: 353865
This commit is contained in:
parent
acbb7ca26c
commit
c069452027
|
@ -60,6 +60,14 @@ extern "C" void LLVMInitializePowerPCDisassembler() {
|
||||||
createPPCLEDisassembler);
|
createPPCLEDisassembler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DecodeStatus DecodePCRel24BranchTarget(MCInst &Inst, unsigned Imm,
|
||||||
|
uint64_t Addr,
|
||||||
|
const void *Decoder) {
|
||||||
|
int32_t Offset = SignExtend32<24>(Imm);
|
||||||
|
Inst.addOperand(MCOperand::createImm(Offset));
|
||||||
|
return MCDisassembler::Success;
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: These can be generated by TableGen from the existing register
|
// FIXME: These can be generated by TableGen from the existing register
|
||||||
// encoding values!
|
// encoding values!
|
||||||
|
|
||||||
|
|
|
@ -381,8 +381,11 @@ void PPCInstPrinter::printBranchOperand(const MCInst *MI, unsigned OpNo,
|
||||||
|
|
||||||
// Branches can take an immediate operand. This is used by the branch
|
// Branches can take an immediate operand. This is used by the branch
|
||||||
// selection pass to print .+8, an eight byte displacement from the PC.
|
// selection pass to print .+8, an eight byte displacement from the PC.
|
||||||
O << ".+";
|
O << ".";
|
||||||
printAbsBranchOperand(MI, OpNo, O);
|
int32_t Imm = MI->getOperand(OpNo).getImm() << 2;
|
||||||
|
if (Imm >= 0)
|
||||||
|
O << "+";
|
||||||
|
O << Imm;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PPCInstPrinter::printAbsBranchOperand(const MCInst *MI, unsigned OpNo,
|
void PPCInstPrinter::printAbsBranchOperand(const MCInst *MI, unsigned OpNo,
|
||||||
|
|
|
@ -736,7 +736,9 @@ def abscondbrtarget : Operand<OtherVT> {
|
||||||
def calltarget : Operand<iPTR> {
|
def calltarget : Operand<iPTR> {
|
||||||
let PrintMethod = "printBranchOperand";
|
let PrintMethod = "printBranchOperand";
|
||||||
let EncoderMethod = "getDirectBrEncoding";
|
let EncoderMethod = "getDirectBrEncoding";
|
||||||
|
let DecoderMethod = "DecodePCRel24BranchTarget";
|
||||||
let ParserMatchClass = PPCDirectBrAsmOperand;
|
let ParserMatchClass = PPCDirectBrAsmOperand;
|
||||||
|
let OperandType = "OPERAND_PCREL";
|
||||||
}
|
}
|
||||||
def abscalltarget : Operand<iPTR> {
|
def abscalltarget : Operand<iPTR> {
|
||||||
let PrintMethod = "printAbsBranchOperand";
|
let PrintMethod = "printAbsBranchOperand";
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
# RUN: llvm-mc -triple=powerpc64le-unknown-linux -filetype=obj %s -o %t.o
|
||||||
|
# RUN: llvm-objdump -d %t.o | FileCheck %s
|
||||||
|
|
||||||
|
# RUN: llvm-mc -triple=powerpc64-unknown-linux -filetype=obj %s -o %t.o
|
||||||
|
# RUN: llvm-objdump -d %t.o | FileCheck %s
|
||||||
|
|
||||||
|
# RUN: llvm-mc -triple=powerpc-unknown-linux -filetype=obj %s -o %t.o
|
||||||
|
# RUN: llvm-objdump -d %t.o | FileCheck %s
|
||||||
|
|
||||||
|
# CHECK: 0000000000000000 callee_back:
|
||||||
|
# CHECK: 18: {{.*}} bl .-24
|
||||||
|
# CHECK: 20: {{.*}} bl .+16
|
||||||
|
# CHECK: 0000000000000030 callee_forward:
|
||||||
|
|
||||||
|
.text
|
||||||
|
.global caller
|
||||||
|
.type caller,@function
|
||||||
|
.type callee_forward,@function
|
||||||
|
.type callee_back,@function
|
||||||
|
|
||||||
|
.p2align 4
|
||||||
|
callee_back:
|
||||||
|
li 3, 55
|
||||||
|
blr
|
||||||
|
|
||||||
|
.p2align 4
|
||||||
|
caller:
|
||||||
|
.Lgep:
|
||||||
|
addis 2, 12, .TOC.-.Lgep@ha
|
||||||
|
addi 2, 2, .TOC.-.Lgep@l
|
||||||
|
.Llep:
|
||||||
|
.localentry caller, .Llep-.Lgep
|
||||||
|
bl callee_back
|
||||||
|
mr 31, 3
|
||||||
|
bl callee_forward
|
||||||
|
add 3, 3, 31
|
||||||
|
blr
|
||||||
|
|
||||||
|
.p2align 4
|
||||||
|
callee_forward:
|
||||||
|
li 3, 66
|
||||||
|
blr
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
if not 'PowerPC' in config.root.targets:
|
||||||
|
config.unsupported = True
|
Loading…
Reference in New Issue