From 43ed64a182dd5efe976a4fecfb1ed8d713d23a3c Mon Sep 17 00:00:00 2001 From: Anton Korobeynikov Date: Sun, 3 May 2009 12:58:58 +0000 Subject: [PATCH] Clearify the usage and add some debug stuff git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70700 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/MSP430/MSP430ISelDAGToDAG.cpp | 50 +++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp b/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp index 922e42e3d08..0ad8752e88f 100644 --- a/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp +++ b/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp @@ -57,6 +57,10 @@ namespace { private: SDNode *Select(SDValue Op); + + #ifndef NDEBUG + unsigned Indent; + #endif }; } // end anonymous namespace @@ -79,5 +83,49 @@ void MSP430DAGToDAGISel::InstructionSelect() { } 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; }