From 2a2de66db2093a5bc1fd620d1b6ae7992a552b24 Mon Sep 17 00:00:00 2001 From: Andrew Lenharth Date: Sun, 23 Oct 2005 03:40:17 +0000 Subject: [PATCH] add TargetExternalSymbol git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23886 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/SelectionDAG.h | 2 ++ include/llvm/CodeGen/SelectionDAGNodes.h | 9 ++++++--- lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 14 +++++++++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h index 44d14a81e5e..8750cdee1a9 100644 --- a/include/llvm/CodeGen/SelectionDAG.h +++ b/include/llvm/CodeGen/SelectionDAG.h @@ -111,6 +111,7 @@ public: SDOperand getTargetConstantPool(Constant *C, MVT::ValueType VT); SDOperand getBasicBlock(MachineBasicBlock *MBB); SDOperand getExternalSymbol(const char *Sym, MVT::ValueType VT); + SDOperand getTargetExternalSymbol(const char *Sym, MVT::ValueType VT); SDOperand getValueType(MVT::ValueType); SDOperand getRegister(unsigned Reg, MVT::ValueType VT); @@ -382,6 +383,7 @@ private: std::map BBNodes; std::vector ValueTypeNodes; std::map ExternalSymbols; + std::map TargetExternalSymbols; std::map > >, SDNode*> OneResultNodes; diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h index 1f3604a5ae8..8f20b395e3d 100644 --- a/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/include/llvm/CodeGen/SelectionDAGNodes.h @@ -74,6 +74,7 @@ namespace ISD { TargetGlobalAddress, TargetFrameIndex, TargetConstantPool, + TargetExternalSymbol, // CopyToReg - This node has three operands: a chain, a register number to // set to this value, and a value. @@ -932,8 +933,9 @@ class ExternalSymbolSDNode : public SDNode { const char *Symbol; protected: friend class SelectionDAG; - ExternalSymbolSDNode(const char *Sym, MVT::ValueType VT) - : SDNode(ISD::ExternalSymbol, VT), Symbol(Sym) { + ExternalSymbolSDNode(bool isTarget, const char *Sym, MVT::ValueType VT) + : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol, VT), + Symbol(Sym) { } public: @@ -941,7 +943,8 @@ public: static bool classof(const ExternalSymbolSDNode *) { return true; } static bool classof(const SDNode *N) { - return N->getOpcode() == ISD::ExternalSymbol; + return N->getOpcode() == ISD::ExternalSymbol || + N->getOpcode() == ISD::TargetExternalSymbol; } }; diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index a8489d29656..7d3cddb6568 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -312,6 +312,9 @@ void SelectionDAG::RemoveNodeFromCSEMaps(SDNode *N) { case ISD::ExternalSymbol: Erased = ExternalSymbols.erase(cast(N)->getSymbol()); break; + case ISD::TargetExternalSymbol: + Erased = TargetExternalSymbols.erase(cast(N)->getSymbol()); + break; case ISD::VALUETYPE: Erased = ValueTypeNodes[cast(N)->getVT()] != 0; ValueTypeNodes[cast(N)->getVT()] = 0; @@ -551,7 +554,15 @@ SDOperand SelectionDAG::getValueType(MVT::ValueType VT) { SDOperand SelectionDAG::getExternalSymbol(const char *Sym, MVT::ValueType VT) { SDNode *&N = ExternalSymbols[Sym]; if (N) return SDOperand(N, 0); - N = new ExternalSymbolSDNode(Sym, VT); + N = new ExternalSymbolSDNode(false, Sym, VT); + AllNodes.push_back(N); + return SDOperand(N, 0); +} + +SDOperand SelectionDAG::getTargetExternalSymbol(const char *Sym, MVT::ValueType VT) { + SDNode *&N = TargetExternalSymbols[Sym]; + if (N) return SDOperand(N, 0); + N = new ExternalSymbolSDNode(true, Sym, VT); AllNodes.push_back(N); return SDOperand(N, 0); } @@ -1586,6 +1597,7 @@ const char *SDNode::getOperationName(const SelectionDAG *G) const { case ISD::BasicBlock: return "BasicBlock"; case ISD::Register: return "Register"; case ISD::ExternalSymbol: return "ExternalSymbol"; + case ISD::TargetExternalSymbol: return "TargetExternalSymbol"; case ISD::ConstantPool: return "ConstantPool"; case ISD::TargetConstantPool: return "TargetConstantPool"; case ISD::CopyToReg: return "CopyToReg"; -- 2.34.1