[llvm-branch-commits] [llvm-branch] r362043 - Merging r353865, r353866, and r353874:
Tom Stellard via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed May 29 17:31:30 PDT 2019
Author: tstellar
Date: Wed May 29 17:31:30 2019
New Revision: 362043
URL: http://llvm.org/viewvc/llvm-project?rev=362043&view=rev
Log:
Merging r353865, r353866, and r353874:
------------------------------------------------------------------------
r353865 | sfertile | 2019-02-12 09:48:22 -0800 (Tue, 12 Feb 2019) | 1 line
[PowerPC] Fix printing of negative offsets in call instruction dissasembly.
------------------------------------------------------------------------
------------------------------------------------------------------------
r353866 | sfertile | 2019-02-12 09:49:04 -0800 (Tue, 12 Feb 2019) | 4 lines
[PPC64] Update tests to reflect change in printing of call operand. [NFC]
The printing of branch operands for call instructions was changed to properly
handle negative offsets. Updating the tests to reflect that.
------------------------------------------------------------------------
------------------------------------------------------------------------
r353874 | sfertile | 2019-02-12 12:03:04 -0800 (Tue, 12 Feb 2019) | 5 lines
Fix undefined behaviour in PPCInstPrinter::printBranchOperand.
Fix the undefined behaviour introduced by my previous patch r353865 (left
shifting a potentially negative value), which was caught by the bots that run
UBSan.
------------------------------------------------------------------------
Added:
llvm/branches/release_80/test/tools/llvm-objdump/PowerPC/
llvm/branches/release_80/test/tools/llvm-objdump/PowerPC/branch-offset.s
llvm/branches/release_80/test/tools/llvm-objdump/PowerPC/lit.local.cfg
Modified:
llvm/branches/release_80/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp
llvm/branches/release_80/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp
llvm/branches/release_80/lib/Target/PowerPC/PPCInstrInfo.td
Modified: llvm/branches/release_80/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_80/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp?rev=362043&r1=362042&r2=362043&view=diff
==============================================================================
--- llvm/branches/release_80/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp (original)
+++ llvm/branches/release_80/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp Wed May 29 17:31:30 2019
@@ -61,6 +61,14 @@ extern "C" void LLVMInitializePowerPCDis
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
// encoding values!
Modified: llvm/branches/release_80/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_80/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp?rev=362043&r1=362042&r2=362043&view=diff
==============================================================================
--- llvm/branches/release_80/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp (original)
+++ llvm/branches/release_80/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp Wed May 29 17:31:30 2019
@@ -382,8 +382,11 @@ void PPCInstPrinter::printBranchOperand(
// Branches can take an immediate operand. This is used by the branch
// selection pass to print .+8, an eight byte displacement from the PC.
- O << ".+";
- printAbsBranchOperand(MI, OpNo, O);
+ O << ".";
+ int32_t Imm = SignExtend32<32>((unsigned)MI->getOperand(OpNo).getImm() << 2);
+ if (Imm >= 0)
+ O << "+";
+ O << Imm;
}
void PPCInstPrinter::printAbsBranchOperand(const MCInst *MI, unsigned OpNo,
Modified: llvm/branches/release_80/lib/Target/PowerPC/PPCInstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_80/lib/Target/PowerPC/PPCInstrInfo.td?rev=362043&r1=362042&r2=362043&view=diff
==============================================================================
--- llvm/branches/release_80/lib/Target/PowerPC/PPCInstrInfo.td (original)
+++ llvm/branches/release_80/lib/Target/PowerPC/PPCInstrInfo.td Wed May 29 17:31:30 2019
@@ -737,7 +737,9 @@ def abscondbrtarget : Operand<OtherVT> {
def calltarget : Operand<iPTR> {
let PrintMethod = "printBranchOperand";
let EncoderMethod = "getDirectBrEncoding";
+ let DecoderMethod = "DecodePCRel24BranchTarget";
let ParserMatchClass = PPCDirectBrAsmOperand;
+ let OperandType = "OPERAND_PCREL";
}
def abscalltarget : Operand<iPTR> {
let PrintMethod = "printAbsBranchOperand";
Added: llvm/branches/release_80/test/tools/llvm-objdump/PowerPC/branch-offset.s
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_80/test/tools/llvm-objdump/PowerPC/branch-offset.s?rev=362043&view=auto
==============================================================================
--- llvm/branches/release_80/test/tools/llvm-objdump/PowerPC/branch-offset.s (added)
+++ llvm/branches/release_80/test/tools/llvm-objdump/PowerPC/branch-offset.s Wed May 29 17:31:30 2019
@@ -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, at function
+ .type callee_forward, at function
+ .type callee_back, at function
+
+ .p2align 4
+callee_back:
+ li 3, 55
+ blr
+
+ .p2align 4
+caller:
+.Lgep:
+ addis 2, 12, .TOC.-.Lgep at ha
+ addi 2, 2, .TOC.-.Lgep at 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
+
Added: llvm/branches/release_80/test/tools/llvm-objdump/PowerPC/lit.local.cfg
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_80/test/tools/llvm-objdump/PowerPC/lit.local.cfg?rev=362043&view=auto
==============================================================================
--- llvm/branches/release_80/test/tools/llvm-objdump/PowerPC/lit.local.cfg (added)
+++ llvm/branches/release_80/test/tools/llvm-objdump/PowerPC/lit.local.cfg Wed May 29 17:31:30 2019
@@ -0,0 +1,2 @@
+if not 'PowerPC' in config.root.targets:
+ config.unsupported = True
More information about the llvm-branch-commits
mailing list