forked from OSchip/llvm-project
Change TRUNCSTORE to use a VTSDNode operand instead of being an MVTSTDNode
llvm-svn: 22366
This commit is contained in:
parent
9bfa5495dd
commit
36db1ed06f
|
@ -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<MVTSDNode>(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 {
|
||||
|
|
|
@ -235,7 +235,6 @@ void SelectionDAG::DeleteNodeIfDead(SDNode *N, void *NodeSet) {
|
|||
cast<SetCCSDNode>(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<SDOperand> 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<PointerType>(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<VTSDNode>(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<Constant>(Ops[0])) {
|
||||
SDOperand Op = getNode(ISD::TRUNCATE, EVT, N1);
|
||||
if (isa<Constant>(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<Constant>(N1)) {
|
||||
SDOperand Op = getNode(ISD::TRUNCATE, EVT, N1);
|
||||
if (isa<Constant>(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.
|
||||
|
|
|
@ -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<SDOperand,SDOperand> 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<MVTSDNode>(Node)->getExtraValueType()) {
|
||||
switch(cast<VTSDNode>(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;
|
||||
|
|
|
@ -2361,7 +2361,7 @@ void ISel::Select(SDOperand N) {
|
|||
case MVT::f64: Opc = IA64::STF8; break;
|
||||
}
|
||||
} else { // truncstore
|
||||
switch(cast<MVTSDNode>(Node)->getExtraValueType()) {
|
||||
switch(cast<VTSDNode>(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?
|
||||
|
|
|
@ -2530,7 +2530,7 @@ void ISel::Select(SDOperand N) {
|
|||
case MVT::f32: Opc = PPC::STFS; break;
|
||||
}
|
||||
} else { //ISD::TRUNCSTORE
|
||||
switch(cast<MVTSDNode>(Node)->getExtraValueType()) {
|
||||
switch(cast<VTSDNode>(Node->getOperand(4))->getVT()) {
|
||||
default: assert(0 && "unknown Type in store");
|
||||
case MVT::i1:
|
||||
case MVT::i8: Opc = PPC::STB; break;
|
||||
|
|
|
@ -1593,7 +1593,7 @@ void ISel::Select(SDOperand N) {
|
|||
case MVT::f32: Opc = PPC::STFS; break;
|
||||
}
|
||||
} else { //ISD::TRUNCSTORE
|
||||
switch(cast<MVTSDNode>(Node)->getExtraValueType()) {
|
||||
switch(cast<VTSDNode>(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;
|
||||
|
|
|
@ -489,7 +489,7 @@ void ISel::Select(SDOperand N) {
|
|||
Tmp2 = SelectExpr(Address);
|
||||
|
||||
unsigned VT = opcode == ISD::STORE ?
|
||||
Value.getValueType() : cast<MVTSDNode>(Node)->getExtraValueType();
|
||||
Value.getValueType() : cast<VTSDNode>(Node->getOperand(4))->getVT();
|
||||
switch(VT) {
|
||||
default: assert(0 && "unknown Type in store");
|
||||
case MVT::f64: Opc = V8::STDFrr; break;
|
||||
|
|
|
@ -4009,7 +4009,7 @@ static SDOperand GetAdjustedArgumentStores(SDOperand Chain, int Offset,
|
|||
StoreVT = Chain.getOperand(1).getValueType();
|
||||
break;
|
||||
case ISD::TRUNCSTORE: // FLOAT store
|
||||
StoreVT = cast<MVTSDNode>(Chain)->getExtraValueType();
|
||||
StoreVT = cast<VTSDNode>(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<MVTSDNode>(Node)->getExtraValueType();
|
||||
MVT::ValueType StoredTy = cast<VTSDNode>(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!");
|
||||
|
|
Loading…
Reference in New Issue