mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
[CodeGen] Print jump-table index operands as %jump-table.0 in both MIR and debug output
Work towards the unification of MIR and debug output by printing `%jump-table.0` instead of `<jt#0>`. Only debug syntax is affected. llvm-svn: 320566
This commit is contained in:
parent
92477f9fd2
commit
019e3098ec
@ -238,6 +238,8 @@ in the block's definition:
|
||||
The block's name should be identical to the name of the IR block that this
|
||||
machine block is based on.
|
||||
|
||||
.. _block-references:
|
||||
|
||||
Block References
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
@ -630,6 +632,39 @@ and the offset 8:
|
||||
|
||||
%sgpr2 = S_ADD_U32 _, target-index(amdgpu-constdata-start) + 8, implicit-def _, implicit-def _
|
||||
|
||||
Jump-table Index Operands
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
A jump-table index operand with the index 0 is printed as following:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
tBR_JTr killed %r0, %jump-table.0
|
||||
|
||||
A machine jump-table entry contains a list of ``MachineBasicBlocks``. When serializing all the function's jump-table entries, the following format is used:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
jumpTable:
|
||||
kind: <kind>
|
||||
entries:
|
||||
- id: <index>
|
||||
blocks: [ <bbreference>, <bbreference>, ... ]
|
||||
|
||||
where ``<kind>`` is describing how the jump table is represented and emitted (plain address, relocations, PIC, etc.), and each ``<index>`` is a 32-bit unsigned integer and ``blocks`` contains a list of :ref:`machine basic block references <block-references>`.
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
jumpTable:
|
||||
kind: inline
|
||||
entries:
|
||||
- id: 0
|
||||
blocks: [ '%bb.3', '%bb.9', '%bb.4.d3' ]
|
||||
- id: 1
|
||||
blocks: [ '%bb.7', '%bb.7', '%bb.4.d3', '%bb.5' ]
|
||||
|
||||
.. TODO: Describe the parsers default behaviour when optional YAML attributes
|
||||
are missing.
|
||||
.. TODO: Describe the syntax for the bundled instructions.
|
||||
@ -640,8 +675,6 @@ and the offset 8:
|
||||
.. TODO: Describe the frame information YAML mapping.
|
||||
.. TODO: Describe the syntax of the stack object machine operands and their
|
||||
YAML definitions.
|
||||
.. TODO: Describe the syntax of the jump table machine operands and their
|
||||
YAML definitions.
|
||||
.. TODO: Describe the syntax of the block address machine operands.
|
||||
.. TODO: Describe the syntax of the CFI index machine operands.
|
||||
.. TODO: Describe the syntax of the metadata machine operands, and the
|
||||
|
@ -20,6 +20,7 @@
|
||||
#ifndef LLVM_CODEGEN_MACHINEJUMPTABLEINFO_H
|
||||
#define LLVM_CODEGEN_MACHINEJUMPTABLEINFO_H
|
||||
|
||||
#include "llvm/Support/Printable.h"
|
||||
#include <cassert>
|
||||
#include <vector>
|
||||
|
||||
@ -125,6 +126,15 @@ public:
|
||||
void dump() const;
|
||||
};
|
||||
|
||||
|
||||
/// Prints a jump table entry reference.
|
||||
///
|
||||
/// The format is:
|
||||
/// %jump-table.5 - a jump table entry with index == 5.
|
||||
///
|
||||
/// Usage: OS << printJumpTableEntryReference(Idx) << '\n';
|
||||
Printable printJumpTableEntryReference(unsigned Idx);
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
||||
|
@ -852,7 +852,8 @@ void MIPrinter::print(const MachineInstr &MI, unsigned OpIdx,
|
||||
case MachineOperand::MO_CImmediate:
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
case MachineOperand::MO_ConstantPoolIndex:
|
||||
case MachineOperand::MO_TargetIndex: {
|
||||
case MachineOperand::MO_TargetIndex:
|
||||
case MachineOperand::MO_JumpTableIndex: {
|
||||
unsigned TiedOperandIdx = 0;
|
||||
if (ShouldPrintRegisterTies && Op.isReg() && Op.isTied() && !Op.isDef())
|
||||
TiedOperandIdx = Op.getParent()->findTiedOperandIdx(OpIdx);
|
||||
@ -867,9 +868,6 @@ void MIPrinter::print(const MachineInstr &MI, unsigned OpIdx,
|
||||
case MachineOperand::MO_FrameIndex:
|
||||
printStackObjectReference(Op.getIndex());
|
||||
break;
|
||||
case MachineOperand::MO_JumpTableIndex:
|
||||
OS << "%jump-table." << Op.getIndex();
|
||||
break;
|
||||
case MachineOperand::MO_ExternalSymbol: {
|
||||
StringRef Name = Op.getSymbolName();
|
||||
OS << '$';
|
||||
|
@ -906,7 +906,7 @@ void MachineJumpTableInfo::print(raw_ostream &OS) const {
|
||||
OS << "Jump Tables:\n";
|
||||
|
||||
for (unsigned i = 0, e = JumpTables.size(); i != e; ++i) {
|
||||
OS << " jt#" << i << ": ";
|
||||
OS << printJumpTableEntryReference(i) << ": ";
|
||||
for (unsigned j = 0, f = JumpTables[i].MBBs.size(); j != f; ++j)
|
||||
OS << ' ' << printMBBReference(*JumpTables[i].MBBs[j]);
|
||||
}
|
||||
@ -918,6 +918,10 @@ void MachineJumpTableInfo::print(raw_ostream &OS) const {
|
||||
LLVM_DUMP_METHOD void MachineJumpTableInfo::dump() const { print(dbgs()); }
|
||||
#endif
|
||||
|
||||
Printable llvm::printJumpTableEntryReference(unsigned Idx) {
|
||||
return Printable([Idx](raw_ostream &OS) { OS << "%jump-table." << Idx; });
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// MachineConstantPool implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "llvm/CodeGen/MachineOperand.h"
|
||||
#include "llvm/Analysis/Loads.h"
|
||||
#include "llvm/CodeGen/MIRPrinter.h"
|
||||
#include "llvm/CodeGen/MachineJumpTableInfo.h"
|
||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||
#include "llvm/CodeGen/TargetInstrInfo.h"
|
||||
#include "llvm/CodeGen/TargetRegisterInfo.h"
|
||||
@ -523,7 +524,7 @@ void MachineOperand::print(raw_ostream &OS, ModuleSlotTracker &MST,
|
||||
break;
|
||||
}
|
||||
case MachineOperand::MO_JumpTableIndex:
|
||||
OS << "<jt#" << getIndex() << '>';
|
||||
OS << printJumpTableEntryReference(getIndex());
|
||||
break;
|
||||
case MachineOperand::MO_GlobalAddress:
|
||||
OS << "<ga:";
|
||||
|
@ -28,19 +28,19 @@ entry:
|
||||
]
|
||||
; CHECK-LABEL: function jt1:
|
||||
; CHECK-NEXT: Jump Tables:
|
||||
; CHECK0-NEXT: jt#0:
|
||||
; CHECK0-NOT: jt#1:
|
||||
; CHECK4-NEXT: jt#0:
|
||||
; CHECK4-SAME: jt#1:
|
||||
; CHECK4-SAME: jt#2:
|
||||
; CHECK4-SAME: jt#3:
|
||||
; CHECK4-NOT: jt#4:
|
||||
; CHECK8-NEXT: jt#0:
|
||||
; CHECK8-SAME: jt#1:
|
||||
; CHECK8-NOT: jt#2:
|
||||
; CHECKM1-NEXT: jt#0:
|
||||
; CHECKM1-SAME: jt#1
|
||||
; CHECKM1-NOT: jt#2:
|
||||
; CHECK0-NEXT: %jump-table.0:
|
||||
; CHECK0-NOT: %jump-table.1:
|
||||
; CHECK4-NEXT: %jump-table.0:
|
||||
; CHECK4-SAME: %jump-table.1:
|
||||
; CHECK4-SAME: %jump-table.2:
|
||||
; CHECK4-SAME: %jump-table.3:
|
||||
; CHECK4-NOT: %jump-table.4:
|
||||
; CHECK8-NEXT: %jump-table.0:
|
||||
; CHECK8-SAME: %jump-table.1:
|
||||
; CHECK8-NOT: %jump-table.2:
|
||||
; CHECKM1-NEXT: %jump-table.0:
|
||||
; CHECKM1-SAME: %jump-table.1
|
||||
; CHECKM1-NOT: %jump-table.2:
|
||||
; CHEC-NEXT: Function Live Ins:
|
||||
|
||||
bb1: tail call void @ext(i32 0) br label %return
|
||||
@ -77,10 +77,10 @@ entry:
|
||||
]
|
||||
; CHECK-LABEL: function jt2:
|
||||
; CHECK-NEXT: Jump Tables:
|
||||
; CHECK0-NEXT: jt#0: %bb.1 %bb.2 %bb.3 %bb.4 %bb.7 %bb.7 %bb.7 %bb.7 %bb.7 %bb.7 %bb.7 %bb.7 %bb.7 %bb.5 %bb.6{{$}}
|
||||
; CHECK4-NEXT: jt#0: %bb.1 %bb.2 %bb.3 %bb.4{{$}}
|
||||
; CHECK8-NEXT: jt#0: %bb.1 %bb.2 %bb.3 %bb.4{{$}}
|
||||
; CHECKM1-NEXT: jt#0: %bb.1 %bb.2 %bb.3 %bb.4{{$}}
|
||||
; CHECK0-NEXT: %jump-table.0: %bb.1 %bb.2 %bb.3 %bb.4 %bb.7 %bb.7 %bb.7 %bb.7 %bb.7 %bb.7 %bb.7 %bb.7 %bb.7 %bb.5 %bb.6{{$}}
|
||||
; CHECK4-NEXT: %jump-table.0: %bb.1 %bb.2 %bb.3 %bb.4{{$}}
|
||||
; CHECK8-NEXT: %jump-table.0: %bb.1 %bb.2 %bb.3 %bb.4{{$}}
|
||||
; CHECKM1-NEXT: %jump-table.0: %bb.1 %bb.2 %bb.3 %bb.4{{$}}
|
||||
; CHEC-NEXT: Function Live Ins:
|
||||
|
||||
bb1: tail call void @ext(i32 1) br label %return
|
||||
|
@ -12,8 +12,8 @@ entry:
|
||||
]
|
||||
; CHECK-LABEL: function jt2:
|
||||
; CHECK0-NEXT: Jump Tables:
|
||||
; CHECK0-NEXT: jt#0:
|
||||
; CHECK0-NOT: jt#1:
|
||||
; CHECK0-NEXT: %jump-table.0:
|
||||
; CHECK0-NOT: %jump-table.1:
|
||||
; CHECK4-NOT: Jump Tables:
|
||||
; CHECK8-NOT: Jump Tables:
|
||||
|
||||
@ -33,11 +33,11 @@ entry:
|
||||
]
|
||||
; CHECK-LABEL: function jt4:
|
||||
; CHECK0-NEXT: Jump Tables:
|
||||
; CHECK0-NEXT: jt#0:
|
||||
; CHECK0-NOT: jt#1:
|
||||
; CHECK0-NEXT: %jump-table.0:
|
||||
; CHECK0-NOT: %jump-table.1:
|
||||
; CHECK4-NEXT: Jump Tables:
|
||||
; CHECK4-NEXT: jt#0:
|
||||
; CHECK4-NOT: jt#1:
|
||||
; CHECK4-NEXT: %jump-table.0:
|
||||
; CHECK4-NOT: %jump-table.1:
|
||||
; CHECK8-NOT: Jump Tables:
|
||||
|
||||
bb1: tail call void @ext(i32 0) br label %return
|
||||
@ -62,8 +62,8 @@ entry:
|
||||
]
|
||||
; CHECK-LABEL: function jt8:
|
||||
; CHECK-NEXT: Jump Tables:
|
||||
; CHECK-NEXT: jt#0:
|
||||
; CHECK-NOT: jt#1:
|
||||
; CHECK-NEXT: %jump-table.0:
|
||||
; CHECK-NOT: %jump-table.1:
|
||||
|
||||
bb1: tail call void @ext(i32 0) br label %return
|
||||
bb2: tail call void @ext(i32 2) br label %return
|
||||
|
@ -181,4 +181,20 @@ TEST(MachineOperandTest, PrintTargetIndexName) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(MachineOperandTest, PrintJumpTableIndex) {
|
||||
// Create a MachineOperand with a jump-table index and print it.
|
||||
MachineOperand MO = MachineOperand::CreateJTI(3);
|
||||
|
||||
// Checking some preconditions on the newly created
|
||||
// MachineOperand.
|
||||
ASSERT_TRUE(MO.isJTI());
|
||||
ASSERT_TRUE(MO.getIndex() == 3);
|
||||
|
||||
// Print a MachineOperand containing a jump-table index.
|
||||
std::string str;
|
||||
raw_string_ostream OS(str);
|
||||
MO.print(OS, /*TRI=*/nullptr, /*IntrinsicInfo=*/nullptr);
|
||||
ASSERT_TRUE(OS.str() == "%jump-table.3");
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
|
Loading…
x
Reference in New Issue
Block a user