Skip to content

Commit 09499d6

Browse files
committed
- remove getInstructionSeparator
- test improvements: - multi-insn packets - branch targets - endloops - inline relocations
1 parent d12711d commit 09499d6

File tree

3 files changed

+54
-32
lines changed

3 files changed

+54
-32
lines changed

llvm/test/tools/llvm-objdump/ELF/Hexagon/branch-targets.yaml

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/// Checks that various hexagon scenarios are handled correctly:
2+
/// - branch targets
3+
/// - endloops
4+
/// - inline-relocs
5+
/// - multi-insn bundles
6+
7+
{
8+
r6 = sub(r1, r0)
9+
r7 = and(r4, #0x0)
10+
if (p1) jump:t target1
11+
if (p2) jump:nt target2
12+
}
13+
14+
{
15+
r8 = r7
16+
r9 = add(r8, #0)
17+
r10 = memw(r9)
18+
} :endloop0
19+
20+
{ jump ##sym }
21+
22+
target1:
23+
nop
24+
25+
target2:
26+
nop
27+
28+
// RUN: llvm-mc %s --triple=hexagon -filetype=obj | llvm-objdump -d -r - | FileCheck %s
29+
30+
// CHECK: 00000000 <.text>:
31+
// CHECK-NEXT: 0: 12 51 00 5c 5c005112 { if (p1) jump:t 0x24 <target1>
32+
// CHECK-NEXT: 4: 14 42 00 5c 5c004214 if (p2) jump:nt 0x28 <target2>
33+
// CHECK-NEXT: 8: 06 41 20 f3 f3204106 r6 = sub(r1,r0)
34+
// CHECK-NEXT: c: 07 c0 04 76 7604c007 r7 = and(r4,#0x0) }
35+
// CHECK-NEXT: 10: 08 80 67 70 70678008 { r8 = r7
36+
// CHECK-NEXT: 14: 09 40 08 b0 b0084009 r9 = add(r8,#0x0)
37+
// CHECK-NEXT: 18: 0a c0 89 91 9189c00a r10 = memw(r9+#0x0) } :endloop0
38+
// CHECK-NEXT: 1c: 00 40 00 00 00004000 { immext(#0x0)
39+
// CHECK-NEXT: 0000001c: R_HEX_B32_PCREL_X sym
40+
// CHECK-NEXT: 20: 00 c0 00 58 5800c000 jump 0x1c <.text+0x1c> }
41+
// CHECK-NEXT: 00000020: R_HEX_B22_PCREL_X sym+0x4
42+
// CHECK-EMPTY:
43+
// CHECK-NEXT: 00000024 <target1>:
44+
// CHECK-NEXT: 24: 00 c0 00 7f 7f00c000 { nop }
45+
// CHECK-NEXT:
46+
// CHECK-NEXT: 00000028 <target2>:
47+
// CHECK-NEXT: 28: 00 c0 00 7f 7f00c000 { nop }

llvm/tools/llvm-objdump/llvm-objdump.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -694,8 +694,6 @@ class PrettyPrinter {
694694
OS << "\t<unknown>";
695695
}
696696

697-
virtual std::string getInstructionSeparator() const { return "\n"; }
698-
699697
virtual void emitPostInstructionInfo(formatted_raw_ostream &FOS,
700698
const MCAsmInfo &MAI,
701699
const MCSubtargetInfo &STI,
@@ -715,7 +713,7 @@ class PrettyPrinter {
715713
FOS << MAI.getCommentString() << ' ' << Comment;
716714
}
717715
LVP.printAfterInst(FOS);
718-
FOS << getInstructionSeparator();
716+
FOS << "\n";
719717
} while (!Comments.empty());
720718
FOS.flush();
721719
}
@@ -741,7 +739,7 @@ class HexagonPrettyPrinter : public PrettyPrinter {
741739
}
742740
}
743741

744-
std::string getInstructionSeparator() const override {
742+
std::string getInstructionSeparator() const {
745743
SmallString<40> Separator;
746744
raw_svector_ostream OS(Separator);
747745
if (ShouldClosePacket) {
@@ -760,8 +758,11 @@ class HexagonPrettyPrinter : public PrettyPrinter {
760758
void emitPostInstructionInfo(formatted_raw_ostream &FOS, const MCAsmInfo &MAI,
761759
const MCSubtargetInfo &STI, StringRef Comments,
762760
LiveVariablePrinter &LVP) override {
763-
764-
PrettyPrinter::emitPostInstructionInfo(FOS, MAI, STI, Comments, LVP);
761+
// Hexagon does not write anything to the comment stream, so we can just
762+
// print the separator.
763+
LVP.printAfterInst(FOS);
764+
FOS << getInstructionSeparator();
765+
FOS.flush();
765766
if (ShouldClosePacket)
766767
reset();
767768
}

0 commit comments

Comments
 (0)