From: Chris Lattner Date: Sun, 10 Jul 2005 00:29:18 +0000 (+0000) Subject: Change TRUNCSTORE to use a VTSDNode operand instead of being an MVTSTDNode X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9fadb4c1c0a6d223aa468f9f72f8c2562dc66839;p=oota-llvm.git Change TRUNCSTORE to use a VTSDNode operand instead of being an MVTSTDNode git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22366 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index c6fc076ee28..c42c0e031a7 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -679,7 +679,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { Tmp3 = PromoteOp(Node->getOperand(1)); Result = DAG.getNode(ISD::TRUNCSTORE, MVT::Other, Tmp1, Tmp3, Tmp2, Node->getOperand(3), - Node->getOperand(1).getValueType()); + DAG.getValueType(Node->getOperand(1).getValueType())); break; case Expand: @@ -718,8 +718,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { if (Tmp1 != Node->getOperand(0) || Tmp2 != Node->getOperand(1) || Tmp3 != Node->getOperand(2)) Result = DAG.getNode(ISD::TRUNCSTORE, MVT::Other, Tmp1, Tmp2, Tmp3, - Node->getOperand(3), - cast(Node)->getExtraValueType()); + Node->getOperand(3), Node->getOperand(4)); break; case Promote: case Expand: @@ -1482,7 +1481,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { SDOperand StackSlot = DAG.getFrameIndex(SSFI, TLI.getPointerTy()); Result = DAG.getNode(ISD::TRUNCSTORE, MVT::Other, DAG.getEntryNode(), Node->getOperand(0), StackSlot, - DAG.getSrcValue(NULL), ExtraVT); + DAG.getSrcValue(NULL), DAG.getValueType(ExtraVT)); Result = DAG.getNode(ISD::EXTLOAD, Node->getValueType(0), Result, StackSlot, DAG.getSrcValue(NULL), ExtraVT); } else { diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 9cf6e0f3a6d..8ae96f8d4da 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -235,7 +235,6 @@ void SelectionDAG::DeleteNodeIfDead(SDNode *N, void *NodeSet) { cast(N)->getCondition(), N->getValueType(0)))); break; - case ISD::TRUNCSTORE: case ISD::EXTLOAD: case ISD::SEXTLOAD: case ISD::ZEXTLOAD: { @@ -1465,6 +1464,20 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT, return getNode(Opcode, VT, Ops); } +SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT, + SDOperand N1, SDOperand N2, SDOperand N3, + SDOperand N4, SDOperand N5) { + std::vector Ops; + Ops.reserve(5); + Ops.push_back(N1); + Ops.push_back(N2); + Ops.push_back(N3); + Ops.push_back(N4); + Ops.push_back(N5); + return getNode(Opcode, VT, Ops); +} + + SDOperand SelectionDAG::getSrcValue(const Value *V, int Offset) { assert((!V || isa(V->getType())) && "SrcValue is not a pointer?"); @@ -1496,6 +1509,27 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT, else // Unconditional branch to false dest. return getNode(ISD::BR, MVT::Other, Ops[0], Ops[3]); break; + + case ISD::TRUNCSTORE: { + assert(Ops.size() == 5 && "TRUNCSTORE takes 5 operands!"); + MVT::ValueType EVT = cast(Ops[4])->getVT(); +#if 0 // FIXME: If the target supports EVT natively, convert to a truncate/store + // If this is a truncating store of a constant, convert to the desired type + // and store it instead. + if (isa(Ops[0])) { + SDOperand Op = getNode(ISD::TRUNCATE, EVT, N1); + if (isa(Op)) + N1 = Op; + } + // Also for ConstantFP? +#endif + if (Ops[0].getValueType() == EVT) // Normal store? + return getNode(ISD::STORE, VT, 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!"); + break; + } } // Memoize nodes. @@ -1596,47 +1630,6 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,SDOperand N1, return SDOperand(N, 0); } -SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,SDOperand N1, - SDOperand N2, SDOperand N3, SDOperand N4, - MVT::ValueType EVT) { - switch (Opcode) { - default: assert(0 && "Bad opcode for this accessor!"); - case ISD::TRUNCSTORE: -#if 0 // FIXME: If the target supports EVT natively, convert to a truncate/store - // If this is a truncating store of a constant, convert to the desired type - // and store it instead. - if (isa(N1)) { - SDOperand Op = getNode(ISD::TRUNCATE, EVT, N1); - if (isa(Op)) - N1 = Op; - } - // Also for ConstantFP? -#endif - if (N1.getValueType() == EVT) // Normal store? - return getNode(ISD::STORE, VT, N1, N2, N3, N4); - assert(N2.getValueType() > EVT && "Not a truncation?"); - assert(MVT::isInteger(N2.getValueType()) == MVT::isInteger(EVT) && - "Can't do FP-INT conversion!"); - break; - } - - EVTStruct NN; - NN.Opcode = Opcode; - NN.VT = VT; - NN.EVT = EVT; - NN.Ops.push_back(N1); - NN.Ops.push_back(N2); - NN.Ops.push_back(N3); - NN.Ops.push_back(N4); - - SDNode *&N = MVTSDNodes[NN]; - if (N) return SDOperand(N, 0); - N = new MVTSDNode(Opcode, VT, N1, N2, N3, N4, EVT); - AllNodes.push_back(N); - return SDOperand(N, 0); -} - - /// hasNUsesOfValue - Return true if there are exactly NUSES uses of the /// indicated value. This method ignores uses of other values defined by this /// operation. diff --git a/lib/Target/Alpha/AlphaISelPattern.cpp b/lib/Target/Alpha/AlphaISelPattern.cpp index 32259631ce1..aeb15a02f50 100644 --- a/lib/Target/Alpha/AlphaISelPattern.cpp +++ b/lib/Target/Alpha/AlphaISelPattern.cpp @@ -419,7 +419,7 @@ SDOperand AlphaTargetLowering::LowerVAStart(SDOperand Chain, SDOperand VAListP, DAG.getConstant(8, MVT::i64)); return DAG.getNode(ISD::TRUNCSTORE, MVT::Other, S1, DAG.getConstant(VarArgsOffset, MVT::i64), SA2, - DAG.getSrcValue(VAListV, 8), MVT::i32); + DAG.getSrcValue(VAListV, 8), DAG.getValueType(MVT::i32)); } std::pair AlphaTargetLowering:: @@ -457,7 +457,8 @@ LowerVAArg(SDOperand Chain, SDOperand VAListP, Value *VAListV, DAG.getConstant(8, MVT::i64)); SDOperand Update = DAG.getNode(ISD::TRUNCSTORE, MVT::Other, Result.getValue(1), NewOffset, - Tmp, DAG.getSrcValue(VAListV, 8), MVT::i32); + Tmp, DAG.getSrcValue(VAListV, 8), + DAG.getValueType(MVT::i32)); Result = DAG.getNode(ISD::TRUNCATE, getValueType(ArgTy), Result); return std::make_pair(Result, Update); @@ -478,7 +479,8 @@ LowerVACopy(SDOperand Chain, SDOperand SrcP, Value *SrcV, SDOperand DestP, SDOperand NPD = DAG.getNode(ISD::ADD, MVT::i64, DestP, DAG.getConstant(8, MVT::i64)); return DAG.getNode(ISD::TRUNCSTORE, MVT::Other, Val.getValue(1), - Val, NPD, DAG.getSrcValue(DestV, 8), MVT::i32); + Val, NPD, DAG.getSrcValue(DestV, 8), + DAG.getValueType(MVT::i32)); } namespace { @@ -2283,7 +2285,7 @@ void AlphaISel::Select(SDOperand N) { case MVT::f32: Opc = Alpha::STS; break; } } else { //ISD::TRUNCSTORE - switch(cast(Node)->getExtraValueType()) { + switch(cast(Node->getOperand(4))->getVT()) { default: assert(0 && "unknown Type in store"); case MVT::i1: //FIXME: DAG does not promote this load case MVT::i8: Opc = Alpha::STB; break; diff --git a/lib/Target/IA64/IA64ISelPattern.cpp b/lib/Target/IA64/IA64ISelPattern.cpp index a93e2ead274..3b3f90a489c 100644 --- a/lib/Target/IA64/IA64ISelPattern.cpp +++ b/lib/Target/IA64/IA64ISelPattern.cpp @@ -2361,7 +2361,7 @@ void ISel::Select(SDOperand N) { case MVT::f64: Opc = IA64::STF8; break; } } else { // truncstore - switch(cast(Node)->getExtraValueType()) { + switch(cast(Node->getOperand(4))->getVT()) { default: assert(0 && "unknown type in truncstore"); case MVT::i1: Opc = IA64::ST1; isBool=true; break; //FIXME: DAG does not promote this load? diff --git a/lib/Target/PowerPC/PPC64ISelPattern.cpp b/lib/Target/PowerPC/PPC64ISelPattern.cpp index 6761ab1115c..1fca3391707 100644 --- a/lib/Target/PowerPC/PPC64ISelPattern.cpp +++ b/lib/Target/PowerPC/PPC64ISelPattern.cpp @@ -1593,7 +1593,7 @@ void ISel::Select(SDOperand N) { case MVT::f32: Opc = PPC::STFS; break; } } else { //ISD::TRUNCSTORE - switch(cast(Node)->getExtraValueType()) { + switch(cast(Node->getOperand(4))->getVT()) { default: assert(0 && "unknown Type in store"); case MVT::i1: //FIXME: DAG does not promote this load case MVT::i8: Opc= PPC::STB; break; diff --git a/lib/Target/PowerPC/PPCISelPattern.cpp b/lib/Target/PowerPC/PPCISelPattern.cpp index b29b11f182b..f5a09a7f60f 100644 --- a/lib/Target/PowerPC/PPCISelPattern.cpp +++ b/lib/Target/PowerPC/PPCISelPattern.cpp @@ -2530,7 +2530,7 @@ void ISel::Select(SDOperand N) { case MVT::f32: Opc = PPC::STFS; break; } } else { //ISD::TRUNCSTORE - switch(cast(Node)->getExtraValueType()) { + switch(cast(Node->getOperand(4))->getVT()) { default: assert(0 && "unknown Type in store"); case MVT::i1: case MVT::i8: Opc = PPC::STB; break; diff --git a/lib/Target/Sparc/SparcV8ISelPattern.cpp b/lib/Target/Sparc/SparcV8ISelPattern.cpp index e19e14c12b3..c2740e339be 100644 --- a/lib/Target/Sparc/SparcV8ISelPattern.cpp +++ b/lib/Target/Sparc/SparcV8ISelPattern.cpp @@ -489,7 +489,7 @@ void ISel::Select(SDOperand N) { Tmp2 = SelectExpr(Address); unsigned VT = opcode == ISD::STORE ? - Value.getValueType() : cast(Node)->getExtraValueType(); + Value.getValueType() : cast(Node->getOperand(4))->getVT(); switch(VT) { default: assert(0 && "unknown Type in store"); case MVT::f64: Opc = V8::STDFrr; break; diff --git a/lib/Target/SparcV8/SparcV8ISelPattern.cpp b/lib/Target/SparcV8/SparcV8ISelPattern.cpp index e19e14c12b3..c2740e339be 100644 --- a/lib/Target/SparcV8/SparcV8ISelPattern.cpp +++ b/lib/Target/SparcV8/SparcV8ISelPattern.cpp @@ -489,7 +489,7 @@ void ISel::Select(SDOperand N) { Tmp2 = SelectExpr(Address); unsigned VT = opcode == ISD::STORE ? - Value.getValueType() : cast(Node)->getExtraValueType(); + Value.getValueType() : cast(Node->getOperand(4))->getVT(); switch(VT) { default: assert(0 && "unknown Type in store"); case MVT::f64: Opc = V8::STDFrr; break; diff --git a/lib/Target/X86/X86ISelPattern.cpp b/lib/Target/X86/X86ISelPattern.cpp index d7a1c4d01d8..af75bdc7796 100644 --- a/lib/Target/X86/X86ISelPattern.cpp +++ b/lib/Target/X86/X86ISelPattern.cpp @@ -4009,7 +4009,7 @@ static SDOperand GetAdjustedArgumentStores(SDOperand Chain, int Offset, StoreVT = Chain.getOperand(1).getValueType(); break; case ISD::TRUNCSTORE: // FLOAT store - StoreVT = cast(Chain)->getExtraValueType(); + StoreVT = cast(Chain.getOperand(4))->getVT(); break; } @@ -4043,7 +4043,7 @@ static SDOperand GetAdjustedArgumentStores(SDOperand Chain, int Offset, FIN); assert(Chain.getOpcode() == ISD::TRUNCSTORE); return DAG.getNode(ISD::TRUNCSTORE, MVT::Other, InChain, Chain.getOperand(1), - FIN, DAG.getSrcValue(NULL), StoreVT); + FIN, DAG.getSrcValue(NULL), DAG.getValueType(StoreVT)); } @@ -4366,10 +4366,9 @@ void ISel::Select(SDOperand N) { SelectExpr(N.getValue(0)); return; - case ISD::TRUNCSTORE: { // truncstore chain, val, ptr :storety - // On X86, we can represent all types except for Bool and Float natively. + case ISD::TRUNCSTORE: { // truncstore chain, val, ptr, SRCVALUE, storety X86AddressMode AM; - MVT::ValueType StoredTy = cast(Node)->getExtraValueType(); + MVT::ValueType StoredTy = cast(N.getOperand(4))->getVT(); assert((StoredTy == MVT::i1 || StoredTy == MVT::f32 || StoredTy == MVT::i16 /*FIXME: THIS IS JUST FOR TESTING!*/) && "Unsupported TRUNCSTORE for this target!");