Print out an informative comment for KILL instructions.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Wed, 4 Nov 2009 19:24:37 +0000 (19:24 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Wed, 4 Nov 2009 19:24:37 +0000 (19:24 +0000)
The KILL pseudo-instruction may survive to the asm printer pass, just like the IMPLICIT_DEF. Print the KILL as a comment instead of just leaving a blank line in the output.

With -asm-verbose=0, a blank line is printed, like IMPLICIT?DEF.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86041 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/AsmPrinter.h
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp
lib/Target/X86/AsmPrinter/X86MCInstLower.cpp

index a0bd330052ba6225a07e687473bd4a69bfef3f53..d051f843f5328f838a82a61b01cd5e71ca14cf31 100644 (file)
@@ -374,8 +374,10 @@ namespace llvm {
     /// printImplicitDef - This method prints the specified machine instruction
     /// that is an implicit def.
     virtual void printImplicitDef(const MachineInstr *MI) const;
-    
-    
+
+    /// printKill - This method prints the specified kill machine instruction.
+    virtual void printKill(const MachineInstr *MI) const;
+
     /// printPICJumpTableSetLabel - This method prints a set label for the
     /// specified MachineBasicBlock for a jumptable entry.
     virtual void printPICJumpTableSetLabel(unsigned uid,
index 58f3aa50665c655c0149f039e839afbca583d51d..bb6bd957f063bddb15cb12620c71e20caa1be2ed 100644 (file)
@@ -1590,6 +1590,17 @@ void AsmPrinter::printImplicitDef(const MachineInstr *MI) const {
     << TRI->getName(MI->getOperand(0).getReg());
 }
 
+void AsmPrinter::printKill(const MachineInstr *MI) const {
+  if (!VerboseAsm) return;
+  O.PadToColumn(MAI->getCommentColumn());
+  O << MAI->getCommentString() << " kill:";
+  for (unsigned n = 0, e = MI->getNumOperands(); n != e; ++n) {
+    const MachineOperand &op = MI->getOperand(n);
+    assert(op.isReg() && "KILL instruction must have only register operands");
+    O << ' ' << TRI->getName(op.getReg()) << (op.isDef() ? "<def>" : "<kill>");
+  }
+}
+
 /// printLabel - This method prints a local label used by debug and
 /// exception handling tables.
 void AsmPrinter::printLabel(const MachineInstr *MI) const {
index 19db411408a8f529e2617e5e1a68e4fac83f06cb..6cb3e9e4d1579d7e9206de6f8f147c0b6453cdde 100644 (file)
@@ -1346,6 +1346,7 @@ void ARMAsmPrinter::printInstructionThroughMCStreamer(const MachineInstr *MI) {
     printLabel(MI);
     return;
   case TargetInstrInfo::KILL:
+    printKill(MI);
     return;
   case TargetInstrInfo::INLINEASM:
     O << '\t';
index 237c313aa103e7b0f7a1313b5f9c7b96fdd68bf0..11ac931b67a11b4d544279326e787c580f03a5db 100644 (file)
@@ -306,6 +306,7 @@ void MSP430AsmPrinter::printInstructionThroughMCStreamer(const MachineInstr *MI)
     printLabel(MI);
     return;
   case TargetInstrInfo::KILL:
+    printKill(MI);
     return;
   case TargetInstrInfo::INLINEASM:
     O << '\t';
index 24787a8c84049a8f15eda2f6729e33dde455928c..821cca42ed15b9985fbcfcb82a01e8b4b2ab6428 100644 (file)
@@ -412,6 +412,7 @@ void X86AsmPrinter::printInstructionThroughMCStreamer(const MachineInstr *MI) {
     printImplicitDef(MI);
     return;
   case TargetInstrInfo::KILL:
+    printKill(MI);
     return;
   case X86::MOVPC32r: {
     MCInst TmpInst;