diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h index 32049688eb3..02af6d30cc2 100644 --- a/include/llvm/CodeGen/SelectionDAG.h +++ b/include/llvm/CodeGen/SelectionDAG.h @@ -99,6 +99,7 @@ public: SDOperand getGlobalAddress(const GlobalValue *GV, MVT::ValueType VT); SDOperand getTargetGlobalAddress(const GlobalValue *GV, MVT::ValueType VT); SDOperand getFrameIndex(int FI, MVT::ValueType VT); + SDOperand getTargetFrameIndex(int FI, MVT::ValueType VT); SDOperand getConstantPool(unsigned CPIdx, MVT::ValueType VT); SDOperand getBasicBlock(MachineBasicBlock *MBB); SDOperand getExternalSymbol(const char *Sym, MVT::ValueType VT); @@ -307,7 +308,7 @@ private: std::map, SDNode*> Constants; std::map, SDNode*> TargetConstants; std::map, SDNode*> ConstantFPs; - std::map FrameIndices; + std::map FrameIndices, TargetFrameIndices; std::map ConstantPoolIndices; std::map BBNodes; std::vector ValueTypeNodes; diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h index 5681a36f5c4..319403ca3cb 100644 --- a/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/include/llvm/CodeGen/SelectionDAGNodes.h @@ -65,6 +65,7 @@ namespace ISD { // anything else with this node, and this is valid in the target-specific // dag, turning into a GlobalAddress operand. TargetGlobalAddress, + TargetFrameIndex, // CopyToReg - This node has three operands: a chain, a register number to // set to this value, and a value. @@ -812,15 +813,16 @@ class FrameIndexSDNode : public SDNode { int FI; protected: friend class SelectionDAG; - FrameIndexSDNode(int fi, MVT::ValueType VT) - : SDNode(ISD::FrameIndex, VT), FI(fi) {} + FrameIndexSDNode(int fi, MVT::ValueType VT, bool isTarg) + : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, VT), FI(fi) {} public: int getIndex() const { return FI; } static bool classof(const FrameIndexSDNode *) { return true; } static bool classof(const SDNode *N) { - return N->getOpcode() == ISD::FrameIndex; + return N->getOpcode() == ISD::FrameIndex || + N->getOpcode() == ISD::TargetFrameIndex; } }; diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 97c28521c7b..68ef11e8bf9 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -261,6 +261,9 @@ void SelectionDAG::RemoveNodeFromCSEMaps(SDNode *N) { case ISD::FrameIndex: FrameIndices.erase(cast(N)->getIndex()); break; + case ISD::TargetFrameIndex: + TargetFrameIndices.erase(cast(N)->getIndex()); + break; case ISD::ConstantPool: ConstantPoolIndices.erase(cast(N)->getIndex()); break; @@ -433,7 +436,15 @@ SDOperand SelectionDAG::getTargetGlobalAddress(const GlobalValue *GV, SDOperand SelectionDAG::getFrameIndex(int FI, MVT::ValueType VT) { SDNode *&N = FrameIndices[FI]; if (N) return SDOperand(N, 0); - N = new FrameIndexSDNode(FI, VT); + N = new FrameIndexSDNode(FI, VT, false); + AllNodes.push_back(N); + return SDOperand(N, 0); +} + +SDOperand SelectionDAG::getTargetFrameIndex(int FI, MVT::ValueType VT) { + SDNode *&N = TargetFrameIndices[FI]; + if (N) return SDOperand(N, 0); + N = new FrameIndexSDNode(FI, VT, true); AllNodes.push_back(N); return SDOperand(N, 0); } @@ -2071,6 +2082,7 @@ const char *SDNode::getOperationName(const SelectionDAG *G) const { case ISD::GlobalAddress: return "GlobalAddress"; case ISD::TargetGlobalAddress: return "TargetGlobalAddress"; case ISD::FrameIndex: return "FrameIndex"; + case ISD::TargetFrameIndex: return "TargetFrameIndex"; case ISD::BasicBlock: return "BasicBlock"; case ISD::Register: return "Register"; case ISD::ExternalSymbol: return "ExternalSymbol";