From ad071e1cd1a4b880019f1b2e827ee81867815f82 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Thu, 5 Oct 2006 22:57:11 +0000 Subject: [PATCH] Add getStore() helper function to create ISD::STORE nodes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30758 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/SelectionDAG.h | 5 +++++ lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h index f7ebbf25fbc..4ec406107f3 100644 --- a/include/llvm/CodeGen/SelectionDAG.h +++ b/include/llvm/CodeGen/SelectionDAG.h @@ -307,6 +307,11 @@ public: SDOperand Chain, SDOperand Ptr, SDOperand SV, MVT::ValueType EVT); + /// getStore - Helper function to build ISD::STORE nodes. + /// + SDOperand getStore(SDOperand Chain, SDOperand Value, SDOperand Ptr, + SDOperand SV); + // getSrcValue - construct a node to track a Value* through the backend SDOperand getSrcValue(const Value* I, int offset = 0); diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index dc0d00f47e3..e673175172d 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -1490,6 +1490,21 @@ SDOperand SelectionDAG::getExtLoad(ISD::LoadExtType LType, MVT::ValueType VT, return getNode(ISD::LOADX, getVTList(VT, MVT::Other), Ops, 5); } +SDOperand SelectionDAG::getStore(SDOperand Chain, SDOperand Value, + SDOperand Ptr, SDOperand SV) { + SDVTList VTs = getVTList(MVT::Other); + SDOperand Ops[] = { Chain, Value, Ptr, SV }; + SelectionDAGCSEMap::NodeID ID(ISD::STORE, VTs, Ops, 4); + void *IP = 0; + if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP)) + return SDOperand(E, 0); + SDNode *N = new SDNode(ISD::STORE, Chain, Value, Ptr, SV); + N->setValueTypes(VTs); + CSEMap.InsertNode(N, IP); + AllNodes.push_back(N); + return SDOperand(N, 0); +} + SDOperand SelectionDAG::getVAArg(MVT::ValueType VT, SDOperand Chain, SDOperand Ptr, SDOperand SV) { @@ -1523,7 +1538,7 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT, // Also for ConstantFP? #endif if (Ops[0].getValueType() == EVT) // Normal store? - return getNode(ISD::STORE, VT, Ops[0], Ops[1], Ops[2], Ops[3]); + return getStore(Ops[0], Ops[1], Ops[2], Ops[3]); assert(Ops[1].getValueType() > EVT && "Not a truncation?"); assert(MVT::isInteger(Ops[1].getValueType()) == MVT::isInteger(EVT) && "Can't do FP-INT conversion!"); -- 2.34.1