From 7226158d7e3986e55b58214a749aa4eabb3fb6d5 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Tue, 20 Dec 2005 06:22:03 +0000 Subject: [PATCH] Added a hook to print out names of target specific DAG nodes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24877 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetLowering.h | 4 ++++ lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 13 ++++++++----- lib/CodeGen/SelectionDAG/TargetLowering.cpp | 3 +++ lib/Target/X86/X86ISelLowering.cpp | 17 +++++++++++++++++ lib/Target/X86/X86ISelLowering.h | 4 ++++ 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h index 29572f99945..44e07e2503f 100644 --- a/include/llvm/Target/TargetLowering.h +++ b/include/llvm/Target/TargetLowering.h @@ -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 // diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index ad8cca742a1..3438863c903 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -1835,15 +1835,18 @@ const char *SDNode::getOperationName(const SelectionDAG *G) const { if (getOpcode() < ISD::BUILTIN_OP_END) return "<>"; 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 - = "<>"; - return Name.c_str(); + TargetLowering &TLI = G->getTargetLoweringInfo(); + const char *Name = + TLI.getTargetNodeName(getOpcode()); + if (Name) return Name; + } + + return "<>"; } case ISD::PCMARKER: return "PCMarker"; diff --git a/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/lib/CodeGen/SelectionDAG/TargetLowering.cpp index 415084e2f1a..8e9524ef1e3 100644 --- a/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -122,3 +122,6 @@ void TargetLowering::computeRegisterProperties() { TransformToType[MVT::f64] = MVT::f64; } +const char *TargetLowering::getTargetNodeName(unsigned Opcode) const { + return NULL; +} diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 776ff6c8a91..496f10548cf 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -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"; + } +} diff --git a/lib/Target/X86/X86ISelLowering.h b/lib/Target/X86/X86ISelLowering.h index 918b23420db..b1ce8e22b0e 100644 --- a/lib/Target/X86/X86ISelLowering.h +++ b/lib/Target/X86/X86ISelLowering.h @@ -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: