[llvm] r320683 - [CodeGen] Print live-out register lists as liveout(...) in both MIR and debug output
Francis Visoiu Mistrih via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 14 02:03:14 PST 2017
Author: thegameg
Date: Thu Dec 14 02:03:14 2017
New Revision: 320683
URL: http://llvm.org/viewvc/llvm-project?rev=320683&view=rev
Log:
[CodeGen] Print live-out register lists as liveout(...) in both MIR and debug output
Work towards the unification of MIR and debug output by printing
`liveout(...)` instead of `<regliveout>`.
Only debug syntax is affected.
Modified:
llvm/trunk/lib/CodeGen/MIRPrinter.cpp
llvm/trunk/lib/CodeGen/MachineOperand.cpp
llvm/trunk/unittests/CodeGen/MachineOperandTest.cpp
Modified: llvm/trunk/lib/CodeGen/MIRPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRPrinter.cpp?rev=320683&r1=320682&r2=320683&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRPrinter.cpp Thu Dec 14 02:03:14 2017
@@ -797,7 +797,8 @@ void MIPrinter::print(const MachineInstr
case MachineOperand::MO_TargetIndex:
case MachineOperand::MO_JumpTableIndex:
case MachineOperand::MO_ExternalSymbol:
- case MachineOperand::MO_GlobalAddress: {
+ case MachineOperand::MO_GlobalAddress:
+ case MachineOperand::MO_RegisterLiveOut: {
unsigned TiedOperandIdx = 0;
if (ShouldPrintRegisterTies && Op.isReg() && Op.isTied() && !Op.isDef())
TiedOperandIdx = Op.getParent()->findTiedOperandIdx(OpIdx);
@@ -829,21 +830,6 @@ void MIPrinter::print(const MachineInstr
printCustomRegMask(Op.getRegMask(), OS, TRI);
break;
}
- case MachineOperand::MO_RegisterLiveOut: {
- const uint32_t *RegMask = Op.getRegLiveOut();
- OS << "liveout(";
- bool IsCommaNeeded = false;
- for (unsigned Reg = 0, E = TRI->getNumRegs(); Reg < E; ++Reg) {
- if (RegMask[Reg / 32] & (1U << (Reg % 32))) {
- if (IsCommaNeeded)
- OS << ", ";
- OS << printReg(Reg, TRI);
- IsCommaNeeded = true;
- }
- }
- OS << ")";
- break;
- }
case MachineOperand::MO_Metadata:
Op.getMetadata()->printAsOperand(OS, MST);
break;
Modified: llvm/trunk/lib/CodeGen/MachineOperand.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineOperand.cpp?rev=320683&r1=320682&r2=320683&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineOperand.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineOperand.cpp Thu Dec 14 02:03:14 2017
@@ -637,9 +637,25 @@ void MachineOperand::print(raw_ostream &
OS << ">";
break;
}
- case MachineOperand::MO_RegisterLiveOut:
- OS << "<regliveout>";
+ case MachineOperand::MO_RegisterLiveOut: {
+ const uint32_t *RegMask = getRegLiveOut();
+ OS << "liveout(";
+ if (!TRI) {
+ OS << "<unknown>";
+ } else {
+ bool IsCommaNeeded = false;
+ for (unsigned Reg = 0, E = TRI->getNumRegs(); Reg < E; ++Reg) {
+ if (RegMask[Reg / 32] & (1U << (Reg % 32))) {
+ if (IsCommaNeeded)
+ OS << ", ";
+ OS << printReg(Reg, TRI);
+ IsCommaNeeded = true;
+ }
+ }
+ }
+ OS << ")";
break;
+ }
case MachineOperand::MO_Metadata:
OS << '<';
getMetadata()->printAsOperand(OS, MST);
Modified: llvm/trunk/unittests/CodeGen/MachineOperandTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/CodeGen/MachineOperandTest.cpp?rev=320683&r1=320682&r2=320683&view=diff
==============================================================================
--- llvm/trunk/unittests/CodeGen/MachineOperandTest.cpp (original)
+++ llvm/trunk/unittests/CodeGen/MachineOperandTest.cpp Thu Dec 14 02:03:14 2017
@@ -272,4 +272,21 @@ TEST(MachineOperandTest, PrintGlobalAddr
}
}
+TEST(MachineOperandTest, PrintRegisterLiveOut) {
+ // Create a MachineOperand with a register live out list and print it.
+ uint32_t Mask = 0;
+ MachineOperand MO = MachineOperand::CreateRegLiveOut(&Mask);
+
+ // Checking some preconditions on the newly created
+ // MachineOperand.
+ ASSERT_TRUE(MO.isRegLiveOut());
+ ASSERT_TRUE(MO.getRegLiveOut() == &Mask);
+
+ std::string str;
+ // Print a MachineOperand containing a register live out list without a TRI.
+ raw_string_ostream OS(str);
+ MO.print(OS, /*TRI=*/nullptr, /*IntrinsicInfo=*/nullptr);
+ ASSERT_TRUE(OS.str() == "liveout(<unknown>)");
+}
+
} // end namespace
More information about the llvm-commits
mailing list