Added a hook to print out names of target specific DAG nodes.
authorEvan Cheng <evan.cheng@apple.com>
Tue, 20 Dec 2005 06:22:03 +0000 (06:22 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Tue, 20 Dec 2005 06:22:03 +0000 (06:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24877 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/TargetLowering.h
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
lib/CodeGen/SelectionDAG/TargetLowering.cpp
lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86ISelLowering.h

index 29572f99945ea88c9bc645370532c80fc506ea0e..44e07e2503fb87733398e7876bbf4f0784d81c8d 100644 (file)
@@ -375,6 +375,10 @@ public:
   /// implement this.  The default implementation of this aborts.
   virtual SDOperand LowerOperation(SDOperand Op, SelectionDAG &DAG);
 
+  // getTargetNodeName() - This method returns the name of a target specific
+  // DAG node.
+  virtual const char *getTargetNodeName(unsigned Opcode) const;
+
   //===--------------------------------------------------------------------===//
   // Scheduler hooks
   //
index ad8cca742a1913363f7162516d22778e34032677..3438863c9033750307ae98d5730446d1f16358fb 100644 (file)
@@ -1835,15 +1835,18 @@ const char *SDNode::getOperationName(const SelectionDAG *G) const {
     if (getOpcode() < ISD::BUILTIN_OP_END)
       return "<<Unknown DAG Node>>";
     else {
-      if (G)
+      if (G) {
         if (const TargetInstrInfo *TII = G->getTarget().getInstrInfo())
           if (getOpcode()-ISD::BUILTIN_OP_END < TII->getNumOpcodes())
             return TII->getName(getOpcode()-ISD::BUILTIN_OP_END);
 
-      std::string Name
-        = "<<Unknown Target Node:"
-        + itostr((int)getOpcode()-ISD::BUILTIN_OP_END) + ">>";
-      return Name.c_str();
+        TargetLowering &TLI = G->getTargetLoweringInfo();
+        const char *Name =
+          TLI.getTargetNodeName(getOpcode());
+        if (Name) return Name;
+      }
+
+      return "<<Unknown Target Node>>";
     }
    
   case ISD::PCMARKER:      return "PCMarker";
index 415084e2f1ad92fe2f1905132520a779feb9f2e4..8e9524ef1e39e23006766dc946f2bb5e5e62b23d 100644 (file)
@@ -122,3 +122,6 @@ void TargetLowering::computeRegisterProperties() {
   TransformToType[MVT::f64] = MVT::f64;
 }
 
+const char *TargetLowering::getTargetNodeName(unsigned Opcode) const {
+  return NULL;
+}
index 776ff6c8a91c9d6ccbb19753d22c0f79561561dd..496f10548cfc6cfd2ac332569da88b792b74d6dc 100644 (file)
@@ -970,3 +970,20 @@ SDOperand X86TargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
   }
   }
 }
+
+const char *X86TargetLowering::getTargetNodeName(unsigned Opcode) const {
+  switch (Opcode) {
+  default: return NULL;
+  case X86ISD::FILD64m:            return "X86ISD::FILD64m";
+  case X86ISD::FP_TO_INT16_IN_MEM: return "X86ISD::FP_TO_INT16_IN_MEM";
+  case X86ISD::FP_TO_INT32_IN_MEM: return "X86ISD::FP_TO_INT32_IN_MEM";
+  case X86ISD::FP_TO_INT64_IN_MEM: return "X86ISD::FP_TO_INT64_IN_MEM";
+  case X86ISD::CALL:               return "X86ISD::CALL";
+  case X86ISD::TAILCALL:           return "X86ISD::TAILCALL";
+  case X86ISD::RDTSC_DAG:          return "X86ISD::RDTSC_DAG";
+  case X86ISD::CMP:                return "X86ISD::CMP";
+  case X86ISD::TEST:               return "X86ISD::TEST";
+  case X86ISD::CMOV:               return "X86ISD::CMOV";
+  case X86ISD::BRCOND:             return "X86ISD::BRCOND";
+  }
+}
index 918b23420db8103f711d7c877a6255087467830c..b1ce8e22b0e367c70b7f4bf278b3fd9edc63140a 100644 (file)
@@ -123,6 +123,10 @@ namespace llvm {
     LowerFrameReturnAddress(bool isFrameAddr, SDOperand Chain, unsigned Depth,
                             SelectionDAG &DAG);
 
+    /// getTargetNodeName - This method returns the name of a target specific
+    /// DAG node.
+    virtual const char *getTargetNodeName(unsigned Opcode) const;
+
     SDOperand getReturnAddressFrameIndex(SelectionDAG &DAG);
 
   private: