[llvm-commits] [llvm] r70700 - /llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp

Anton Korobeynikov asl at math.spbu.ru
Sun May 3 05:58:59 PDT 2009


Author: asl
Date: Sun May  3 07:58:58 2009
New Revision: 70700

URL: http://llvm.org/viewvc/llvm-project?rev=70700&view=rev
Log:
Clearify the usage and add some debug stuff

Modified:
    llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp

Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp?rev=70700&r1=70699&r2=70700&view=diff

==============================================================================
--- llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp Sun May  3 07:58:58 2009
@@ -57,6 +57,10 @@
 
   private:
     SDNode *Select(SDValue Op);
+
+  #ifndef NDEBUG
+    unsigned Indent;
+  #endif
   };
 }  // end anonymous namespace
 
@@ -79,5 +83,49 @@
 }
 
 SDNode *MSP430DAGToDAGISel::Select(SDValue Op) {
-  return SelectCode(Op);
+  SDNode *Node = Op.getNode();
+
+  // Dump information about the Node being selected
+  #ifndef NDEBUG
+  DOUT << std::string(Indent, ' ') << "Selecting: ";
+  DEBUG(Node->dump(CurDAG));
+  DOUT << "\n";
+  Indent += 2;
+  #endif
+
+  // If we have a custom node, we already have selected!
+  if (Node->isMachineOpcode()) {
+    #ifndef NDEBUG
+    DOUT << std::string(Indent-2, ' ') << "== ";
+    DEBUG(Node->dump(CurDAG));
+    DOUT << "\n";
+    Indent -= 2;
+    #endif
+    return NULL;
+  }
+
+  // Instruction Selection not handled by the auto-generated tablegen selection
+  // should be handled here.
+  // Something like this:
+  //   unsigned Opcode = Node->getOpcode();
+  //   switch (Opcode) {
+  //   default: break;
+  //   case ISD::Foo:
+  //    return SelectFoo(Node)
+  //  }
+
+  // Select the default instruction
+  SDNode *ResNode = SelectCode(Op);
+
+  #ifndef NDEBUG
+  DOUT << std::string(Indent-2, ' ') << "=> ";
+  if (ResNode == NULL || ResNode == Op.getNode())
+    DEBUG(Op.getNode()->dump(CurDAG));
+  else
+    DEBUG(ResNode->dump(CurDAG));
+  DOUT << "\n";
+  Indent -= 2;
+  #endif
+
+  return ResNode;
 }





More information about the llvm-commits mailing list