mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-12 18:33:22 +00:00
Change *EXTLOAD to use an VTSDNode operand instead of being an MVTSDNode.
This is the last MVTSDNode. This allows us to eliminate a bunch of special case code for handling MVTSDNodes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22367 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9fadb4c1c0
commit
5f056bf4b8
@ -178,21 +178,14 @@ public:
|
|||||||
SDOperand getNode(unsigned Opcode, std::vector<MVT::ValueType> &ResultTys,
|
SDOperand getNode(unsigned Opcode, std::vector<MVT::ValueType> &ResultTys,
|
||||||
std::vector<SDOperand> &Ops);
|
std::vector<SDOperand> &Ops);
|
||||||
|
|
||||||
// getNode - These versions take an extra value type for extending and
|
|
||||||
// truncating loads, stores, rounds, extends etc.
|
|
||||||
SDOperand getNode(unsigned Opcode, MVT::ValueType VT, SDOperand N1,
|
|
||||||
SDOperand N2, MVT::ValueType EVT);
|
|
||||||
SDOperand getNode(unsigned Opcode, MVT::ValueType VT,
|
|
||||||
SDOperand N, MVT::ValueType EVT);
|
|
||||||
SDOperand getNode(unsigned Opcode, MVT::ValueType VT, SDOperand N1,
|
|
||||||
SDOperand N2, SDOperand N3, MVT::ValueType EVT);
|
|
||||||
|
|
||||||
|
|
||||||
/// getLoad - Loads are not normal binary operators: their result type is not
|
/// getLoad - Loads are not normal binary operators: their result type is not
|
||||||
/// determined by their operands, and they produce a value AND a token chain.
|
/// determined by their operands, and they produce a value AND a token chain.
|
||||||
///
|
///
|
||||||
SDOperand getLoad(MVT::ValueType VT, SDOperand Chain, SDOperand Ptr,
|
SDOperand getLoad(MVT::ValueType VT, SDOperand Chain, SDOperand Ptr,
|
||||||
SDOperand SV);
|
SDOperand SV);
|
||||||
|
SDOperand getExtLoad(unsigned Opcode, MVT::ValueType VT, SDOperand Chain,
|
||||||
|
SDOperand Ptr, SDOperand SV, MVT::ValueType EVT);
|
||||||
|
|
||||||
// getSrcValue - construct a node to track a Value* through the backend
|
// getSrcValue - construct a node to track a Value* through the backend
|
||||||
SDOperand getSrcValue(const Value* I, int offset = 0);
|
SDOperand getSrcValue(const Value* I, int offset = 0);
|
||||||
@ -227,6 +220,7 @@ private:
|
|||||||
std::map<unsigned, SDNode*> ConstantPoolIndices;
|
std::map<unsigned, SDNode*> ConstantPoolIndices;
|
||||||
std::map<MachineBasicBlock *, SDNode*> BBNodes;
|
std::map<MachineBasicBlock *, SDNode*> BBNodes;
|
||||||
std::vector<SDNode*> ValueTypeNodes;
|
std::vector<SDNode*> ValueTypeNodes;
|
||||||
|
std::map<std::string, SDNode*> ExternalSymbols;
|
||||||
std::map<std::pair<unsigned,
|
std::map<std::pair<unsigned,
|
||||||
std::pair<MVT::ValueType, std::vector<SDOperand> > >,
|
std::pair<MVT::ValueType, std::vector<SDOperand> > >,
|
||||||
SDNode*> OneResultNodes;
|
SDNode*> OneResultNodes;
|
||||||
@ -234,23 +228,6 @@ private:
|
|||||||
std::pair<std::vector<MVT::ValueType>,
|
std::pair<std::vector<MVT::ValueType>,
|
||||||
std::vector<SDOperand> > >,
|
std::vector<SDOperand> > >,
|
||||||
SDNode*> ArbitraryNodes;
|
SDNode*> ArbitraryNodes;
|
||||||
|
|
||||||
std::map<std::string, SDNode*> ExternalSymbols;
|
|
||||||
struct EVTStruct {
|
|
||||||
unsigned Opcode;
|
|
||||||
MVT::ValueType VT, EVT;
|
|
||||||
std::vector<SDOperand> Ops;
|
|
||||||
bool operator<(const EVTStruct &RHS) const {
|
|
||||||
if (Opcode < RHS.Opcode) return true;
|
|
||||||
if (Opcode > RHS.Opcode) return false;
|
|
||||||
if (VT < RHS.VT) return true;
|
|
||||||
if (VT > RHS.VT) return false;
|
|
||||||
if (EVT < RHS.EVT) return true;
|
|
||||||
if (EVT > RHS.EVT) return false;
|
|
||||||
return Ops < RHS.Ops;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
std::map<EVTStruct, SDNode*> MVTSDNodes;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <> struct GraphTraits<SelectionDAG*> : public GraphTraits<SDNode*> {
|
template <> struct GraphTraits<SelectionDAG*> : public GraphTraits<SDNode*> {
|
||||||
|
@ -180,11 +180,11 @@ namespace ISD {
|
|||||||
// SRCVALUE node that provides alias analysis information.
|
// SRCVALUE node that provides alias analysis information.
|
||||||
LOAD, STORE,
|
LOAD, STORE,
|
||||||
|
|
||||||
// EXTLOAD, SEXTLOAD, ZEXTLOAD - These three operators are instances of the
|
// EXTLOAD, SEXTLOAD, ZEXTLOAD - These three operators all load a value from
|
||||||
// MVTSDNode. All of these load a value from memory and extend them to a
|
// memory and extend them to a larger value (e.g. load a byte into a word
|
||||||
// larger value (e.g. load a byte into a word register). All three of these
|
// register). All three of these have four operands, a token chain, a
|
||||||
// have two operands, a chain and a pointer to load from. The extra value
|
// pointer to load from, a SRCVALUE for alias analysis, and a VALUETYPE node
|
||||||
// type is the source type being loaded.
|
// indicating the type to load.
|
||||||
//
|
//
|
||||||
// SEXTLOAD loads the integer operand and sign extends it to a larger
|
// SEXTLOAD loads the integer operand and sign extends it to a larger
|
||||||
// integer result type.
|
// integer result type.
|
||||||
@ -863,34 +863,6 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// MVTSDNode - This class is used for operators that require an extra
|
|
||||||
/// value-type to be kept with the node.
|
|
||||||
class MVTSDNode : public SDNode {
|
|
||||||
MVT::ValueType ExtraValueType;
|
|
||||||
protected:
|
|
||||||
friend class SelectionDAG;
|
|
||||||
MVTSDNode(unsigned Opc, MVT::ValueType VT1, SDOperand Op0, MVT::ValueType EVT)
|
|
||||||
: SDNode(Opc, Op0), ExtraValueType(EVT) {
|
|
||||||
setValueTypes(VT1);
|
|
||||||
}
|
|
||||||
MVTSDNode(unsigned Opc, MVT::ValueType VT1, MVT::ValueType VT2,
|
|
||||||
SDOperand Op0, SDOperand Op1, SDOperand Op2, MVT::ValueType EVT)
|
|
||||||
: SDNode(Opc, Op0, Op1, Op2), ExtraValueType(EVT) {
|
|
||||||
setValueTypes(VT1, VT2);
|
|
||||||
}
|
|
||||||
public:
|
|
||||||
|
|
||||||
MVT::ValueType getExtraValueType() const { return ExtraValueType; }
|
|
||||||
|
|
||||||
static bool classof(const MVTSDNode *) { return true; }
|
|
||||||
static bool classof(const SDNode *N) {
|
|
||||||
return
|
|
||||||
N->getOpcode() == ISD::EXTLOAD ||
|
|
||||||
N->getOpcode() == ISD::SEXTLOAD ||
|
|
||||||
N->getOpcode() == ISD::ZEXTLOAD;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class SDNodeIterator : public forward_iterator<SDNode, ptrdiff_t> {
|
class SDNodeIterator : public forward_iterator<SDNode, ptrdiff_t> {
|
||||||
SDNode *Node;
|
SDNode *Node;
|
||||||
unsigned Operand;
|
unsigned Operand;
|
||||||
|
@ -317,8 +317,8 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
|
|||||||
SDOperand CPIdx = DAG.getConstantPool(CP->getConstantPoolIndex(LLVMC),
|
SDOperand CPIdx = DAG.getConstantPool(CP->getConstantPoolIndex(LLVMC),
|
||||||
TLI.getPointerTy());
|
TLI.getPointerTy());
|
||||||
if (Extend) {
|
if (Extend) {
|
||||||
Result = DAG.getNode(ISD::EXTLOAD, MVT::f64, DAG.getEntryNode(), CPIdx,
|
Result = DAG.getExtLoad(ISD::EXTLOAD, MVT::f64, DAG.getEntryNode(),
|
||||||
DAG.getSrcValue(NULL), MVT::f32);
|
CPIdx, DAG.getSrcValue(NULL), MVT::f32);
|
||||||
} else {
|
} else {
|
||||||
Result = DAG.getLoad(VT, DAG.getEntryNode(), CPIdx,
|
Result = DAG.getLoad(VT, DAG.getEntryNode(), CPIdx,
|
||||||
DAG.getSrcValue(NULL));
|
DAG.getSrcValue(NULL));
|
||||||
@ -495,13 +495,13 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
|
|||||||
Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain.
|
Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain.
|
||||||
Tmp2 = LegalizeOp(Node->getOperand(1)); // Legalize the pointer.
|
Tmp2 = LegalizeOp(Node->getOperand(1)); // Legalize the pointer.
|
||||||
|
|
||||||
MVT::ValueType SrcVT = cast<MVTSDNode>(Node)->getExtraValueType();
|
MVT::ValueType SrcVT = cast<VTSDNode>(Node->getOperand(3))->getVT();
|
||||||
switch (TLI.getOperationAction(Node->getOpcode(), SrcVT)) {
|
switch (TLI.getOperationAction(Node->getOpcode(), SrcVT)) {
|
||||||
default: assert(0 && "This action is not supported yet!");
|
default: assert(0 && "This action is not supported yet!");
|
||||||
case TargetLowering::Promote:
|
case TargetLowering::Promote:
|
||||||
assert(SrcVT == MVT::i1 && "Can only promote EXTLOAD from i1 -> i8!");
|
assert(SrcVT == MVT::i1 && "Can only promote EXTLOAD from i1 -> i8!");
|
||||||
Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0),
|
Result = DAG.getExtLoad(Node->getOpcode(), Node->getValueType(0),
|
||||||
Tmp1, Tmp2, Node->getOperand(2), MVT::i8);
|
Tmp1, Tmp2, Node->getOperand(2), MVT::i8);
|
||||||
// Since loads produce two values, make sure to remember that we legalized
|
// Since loads produce two values, make sure to remember that we legalized
|
||||||
// both of them.
|
// both of them.
|
||||||
AddLegalizedOperand(SDOperand(Node, 0), Result);
|
AddLegalizedOperand(SDOperand(Node, 0), Result);
|
||||||
@ -511,8 +511,8 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
|
|||||||
case TargetLowering::Legal:
|
case TargetLowering::Legal:
|
||||||
if (Tmp1 != Node->getOperand(0) ||
|
if (Tmp1 != Node->getOperand(0) ||
|
||||||
Tmp2 != Node->getOperand(1))
|
Tmp2 != Node->getOperand(1))
|
||||||
Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0),
|
Result = DAG.getExtLoad(Node->getOpcode(), Node->getValueType(0),
|
||||||
Tmp1, Tmp2, Node->getOperand(2), SrcVT);
|
Tmp1, Tmp2, Node->getOperand(2), SrcVT);
|
||||||
else
|
else
|
||||||
Result = SDOperand(Node, 0);
|
Result = SDOperand(Node, 0);
|
||||||
|
|
||||||
@ -534,8 +534,8 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
|
|||||||
"EXTLOAD should always be supported!");
|
"EXTLOAD should always be supported!");
|
||||||
// Turn the unsupported load into an EXTLOAD followed by an explicit
|
// Turn the unsupported load into an EXTLOAD followed by an explicit
|
||||||
// zero/sign extend inreg.
|
// zero/sign extend inreg.
|
||||||
Result = DAG.getNode(ISD::EXTLOAD, Node->getValueType(0),
|
Result = DAG.getExtLoad(ISD::EXTLOAD, Node->getValueType(0),
|
||||||
Tmp1, Tmp2, Node->getOperand(2), SrcVT);
|
Tmp1, Tmp2, Node->getOperand(2), SrcVT);
|
||||||
SDOperand ValRes;
|
SDOperand ValRes;
|
||||||
if (Node->getOpcode() == ISD::SEXTLOAD)
|
if (Node->getOpcode() == ISD::SEXTLOAD)
|
||||||
ValRes = DAG.getNode(ISD::SIGN_EXTEND_INREG, Result.getValueType(),
|
ValRes = DAG.getNode(ISD::SIGN_EXTEND_INREG, Result.getValueType(),
|
||||||
@ -1362,8 +1362,9 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
|
|||||||
else {
|
else {
|
||||||
assert(Node->getValueType(0) == MVT::f64 && "Unexpected conversion");
|
assert(Node->getValueType(0) == MVT::f64 && "Unexpected conversion");
|
||||||
FudgeInReg =
|
FudgeInReg =
|
||||||
LegalizeOp(DAG.getNode(ISD::EXTLOAD, MVT::f64, DAG.getEntryNode(),
|
LegalizeOp(DAG.getExtLoad(ISD::EXTLOAD, MVT::f64,
|
||||||
CPIdx, DAG.getSrcValue(NULL), MVT::f32));
|
DAG.getEntryNode(), CPIdx,
|
||||||
|
DAG.getSrcValue(NULL), MVT::f32));
|
||||||
}
|
}
|
||||||
Result = DAG.getNode(ISD::ADD, Node->getValueType(0), Tmp1, FudgeInReg);
|
Result = DAG.getNode(ISD::ADD, Node->getValueType(0), Tmp1, FudgeInReg);
|
||||||
break;
|
break;
|
||||||
@ -1451,7 +1452,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
|
|||||||
case TargetLowering::Legal:
|
case TargetLowering::Legal:
|
||||||
if (Tmp1 != Node->getOperand(0))
|
if (Tmp1 != Node->getOperand(0))
|
||||||
Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0), Tmp1,
|
Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0), Tmp1,
|
||||||
ExtraVT);
|
DAG.getValueType(ExtraVT));
|
||||||
break;
|
break;
|
||||||
case TargetLowering::Expand:
|
case TargetLowering::Expand:
|
||||||
// If this is an integer extend and shifts are supported, do that.
|
// If this is an integer extend and shifts are supported, do that.
|
||||||
@ -1482,8 +1483,9 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
|
|||||||
Result = DAG.getNode(ISD::TRUNCSTORE, MVT::Other, DAG.getEntryNode(),
|
Result = DAG.getNode(ISD::TRUNCSTORE, MVT::Other, DAG.getEntryNode(),
|
||||||
Node->getOperand(0), StackSlot,
|
Node->getOperand(0), StackSlot,
|
||||||
DAG.getSrcValue(NULL), DAG.getValueType(ExtraVT));
|
DAG.getSrcValue(NULL), DAG.getValueType(ExtraVT));
|
||||||
Result = DAG.getNode(ISD::EXTLOAD, Node->getValueType(0),
|
Result = DAG.getExtLoad(ISD::EXTLOAD, Node->getValueType(0),
|
||||||
Result, StackSlot, DAG.getSrcValue(NULL), ExtraVT);
|
Result, StackSlot, DAG.getSrcValue(NULL),
|
||||||
|
ExtraVT);
|
||||||
} else {
|
} else {
|
||||||
assert(0 && "Unknown op");
|
assert(0 && "Unknown op");
|
||||||
}
|
}
|
||||||
@ -1768,11 +1770,11 @@ SDOperand SelectionDAGLegalize::PromoteOp(SDOperand Op) {
|
|||||||
Tmp2 = LegalizeOp(Node->getOperand(1)); // Legalize the pointer.
|
Tmp2 = LegalizeOp(Node->getOperand(1)); // Legalize the pointer.
|
||||||
// FIXME: When the DAG combiner exists, change this to use EXTLOAD!
|
// FIXME: When the DAG combiner exists, change this to use EXTLOAD!
|
||||||
if (MVT::isInteger(NVT))
|
if (MVT::isInteger(NVT))
|
||||||
Result = DAG.getNode(ISD::ZEXTLOAD, NVT, Tmp1, Tmp2, Node->getOperand(2),
|
Result = DAG.getExtLoad(ISD::ZEXTLOAD, NVT, Tmp1, Tmp2,
|
||||||
VT);
|
Node->getOperand(2), VT);
|
||||||
else
|
else
|
||||||
Result = DAG.getNode(ISD::EXTLOAD, NVT, Tmp1, Tmp2, Node->getOperand(2),
|
Result = DAG.getExtLoad(ISD::EXTLOAD, NVT, Tmp1, Tmp2,
|
||||||
VT);
|
Node->getOperand(2), VT);
|
||||||
|
|
||||||
// Remember that we legalized the chain.
|
// Remember that we legalized the chain.
|
||||||
AddLegalizedOperand(Op.getValue(1), Result.getValue(1));
|
AddLegalizedOperand(Op.getValue(1), Result.getValue(1));
|
||||||
@ -2277,8 +2279,8 @@ ExpandIntToFP(bool isSigned, MVT::ValueType DestTy, SDOperand Source) {
|
|||||||
DAG.getSrcValue(NULL));
|
DAG.getSrcValue(NULL));
|
||||||
else {
|
else {
|
||||||
assert(DestTy == MVT::f64 && "Unexpected conversion");
|
assert(DestTy == MVT::f64 && "Unexpected conversion");
|
||||||
FudgeInReg = DAG.getNode(ISD::EXTLOAD, MVT::f64, DAG.getEntryNode(),
|
FudgeInReg = DAG.getExtLoad(ISD::EXTLOAD, MVT::f64, DAG.getEntryNode(),
|
||||||
CPIdx, DAG.getSrcValue(NULL), MVT::f32);
|
CPIdx, DAG.getSrcValue(NULL), MVT::f32);
|
||||||
}
|
}
|
||||||
return DAG.getNode(ISD::ADD, DestTy, SignedConv, FudgeInReg);
|
return DAG.getNode(ISD::ADD, DestTy, SignedConv, FudgeInReg);
|
||||||
}
|
}
|
||||||
|
@ -235,18 +235,6 @@ void SelectionDAG::DeleteNodeIfDead(SDNode *N, void *NodeSet) {
|
|||||||
cast<SetCCSDNode>(N)->getCondition(),
|
cast<SetCCSDNode>(N)->getCondition(),
|
||||||
N->getValueType(0))));
|
N->getValueType(0))));
|
||||||
break;
|
break;
|
||||||
case ISD::EXTLOAD:
|
|
||||||
case ISD::SEXTLOAD:
|
|
||||||
case ISD::ZEXTLOAD: {
|
|
||||||
EVTStruct NN;
|
|
||||||
NN.Opcode = N->getOpcode();
|
|
||||||
NN.VT = N->getValueType(0);
|
|
||||||
NN.EVT = cast<MVTSDNode>(N)->getExtraValueType();
|
|
||||||
for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i)
|
|
||||||
NN.Ops.push_back(N->getOperand(i));
|
|
||||||
MVTSDNodes.erase(NN);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
if (N->getNumOperands() == 1)
|
if (N->getNumOperands() == 1)
|
||||||
UnaryOps.erase(std::make_pair(N->getOpcode(),
|
UnaryOps.erase(std::make_pair(N->getOpcode(),
|
||||||
@ -795,7 +783,7 @@ static bool MaskedValueIsZero(const SDOperand &Op, uint64_t Mask,
|
|||||||
TLI.getSetCCResultContents() == TargetLowering::ZeroOrOneSetCCResult;
|
TLI.getSetCCResultContents() == TargetLowering::ZeroOrOneSetCCResult;
|
||||||
|
|
||||||
case ISD::ZEXTLOAD:
|
case ISD::ZEXTLOAD:
|
||||||
SrcBits = MVT::getSizeInBits(cast<MVTSDNode>(Op)->getExtraValueType());
|
SrcBits = MVT::getSizeInBits(cast<VTSDNode>(Op.getOperand(3))->getVT());
|
||||||
return (Mask & ((1ULL << SrcBits)-1)) == 0; // Returning only the zext bits.
|
return (Mask & ((1ULL << SrcBits)-1)) == 0; // Returning only the zext bits.
|
||||||
case ISD::ZERO_EXTEND:
|
case ISD::ZERO_EXTEND:
|
||||||
SrcBits = MVT::getSizeInBits(Op.getOperand(0).getValueType());
|
SrcBits = MVT::getSizeInBits(Op.getOperand(0).getValueType());
|
||||||
@ -1248,7 +1236,7 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
|
|||||||
|
|
||||||
// If we are sign extending a sextload, return just the load.
|
// If we are sign extending a sextload, return just the load.
|
||||||
if (N1.getOpcode() == ISD::SEXTLOAD)
|
if (N1.getOpcode() == ISD::SEXTLOAD)
|
||||||
if (cast<MVTSDNode>(N1)->getExtraValueType() <= EVT)
|
if (cast<VTSDNode>(N1.getOperand(3))->getVT() <= EVT)
|
||||||
return N1;
|
return N1;
|
||||||
|
|
||||||
// If we are extending the result of a setcc, and we already know the
|
// If we are extending the result of a setcc, and we already know the
|
||||||
@ -1335,6 +1323,22 @@ SDOperand SelectionDAG::getLoad(MVT::ValueType VT,
|
|||||||
return SDOperand(N, 0);
|
return SDOperand(N, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SDOperand SelectionDAG::getExtLoad(unsigned Opcode, MVT::ValueType VT,
|
||||||
|
SDOperand Chain, SDOperand Ptr, SDOperand SV,
|
||||||
|
MVT::ValueType EVT) {
|
||||||
|
std::vector<SDOperand> Ops;
|
||||||
|
Ops.reserve(4);
|
||||||
|
Ops.push_back(Chain);
|
||||||
|
Ops.push_back(Ptr);
|
||||||
|
Ops.push_back(SV);
|
||||||
|
Ops.push_back(getValueType(EVT));
|
||||||
|
std::vector<MVT::ValueType> VTs;
|
||||||
|
VTs.reserve(2);
|
||||||
|
VTs.push_back(VT); VTs.push_back(MVT::Other); // Add token chain.
|
||||||
|
return getNode(Opcode, VTs, Ops);
|
||||||
|
}
|
||||||
|
|
||||||
SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
|
SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
|
||||||
SDOperand N1, SDOperand N2, SDOperand N3) {
|
SDOperand N1, SDOperand N2, SDOperand N3) {
|
||||||
// Perform various simplifications.
|
// Perform various simplifications.
|
||||||
@ -1547,11 +1551,29 @@ SDOperand SelectionDAG::getNode(unsigned Opcode,
|
|||||||
if (ResultTys.size() == 1)
|
if (ResultTys.size() == 1)
|
||||||
return getNode(Opcode, ResultTys[0], Ops);
|
return getNode(Opcode, ResultTys[0], Ops);
|
||||||
|
|
||||||
|
switch (Opcode) {
|
||||||
|
case ISD::EXTLOAD:
|
||||||
|
case ISD::SEXTLOAD:
|
||||||
|
case ISD::ZEXTLOAD: {
|
||||||
|
MVT::ValueType EVT = cast<VTSDNode>(Ops[3])->getVT();
|
||||||
|
assert(Ops.size() == 4 && ResultTys.size() == 2 && "Bad *EXTLOAD!");
|
||||||
|
// If they are asking for an extending load from/to the same thing, return a
|
||||||
|
// normal load.
|
||||||
|
if (ResultTys[0] == EVT)
|
||||||
|
return getLoad(ResultTys[0], Ops[0], Ops[1], Ops[2]);
|
||||||
|
assert(EVT < ResultTys[0] &&
|
||||||
|
"Should only be an extending load, not truncating!");
|
||||||
|
assert((Opcode == ISD::EXTLOAD || MVT::isInteger(ResultTys[0])) &&
|
||||||
|
"Cannot sign/zero extend a FP load!");
|
||||||
|
assert(MVT::isInteger(ResultTys[0]) == MVT::isInteger(EVT) &&
|
||||||
|
"Cannot convert from FP to Int or Int -> FP!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: figure out how to safely handle things like
|
// FIXME: figure out how to safely handle things like
|
||||||
// int foo(int x) { return 1 << (x & 255); }
|
// int foo(int x) { return 1 << (x & 255); }
|
||||||
// int bar() { return foo(256); }
|
// int bar() { return foo(256); }
|
||||||
#if 0
|
#if 0
|
||||||
switch (Opcode) {
|
|
||||||
case ISD::SRA_PARTS:
|
case ISD::SRA_PARTS:
|
||||||
case ISD::SRL_PARTS:
|
case ISD::SRL_PARTS:
|
||||||
case ISD::SHL_PARTS:
|
case ISD::SHL_PARTS:
|
||||||
@ -1567,8 +1589,8 @@ SDOperand SelectionDAG::getNode(unsigned Opcode,
|
|||||||
return getNode(Opcode, VT, N1, N2, N3.getOperand(0));
|
return getNode(Opcode, VT, N1, N2, N3.getOperand(0));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// Memoize the node.
|
// Memoize the node.
|
||||||
SDNode *&N = ArbitraryNodes[std::make_pair(Opcode, std::make_pair(ResultTys,
|
SDNode *&N = ArbitraryNodes[std::make_pair(Opcode, std::make_pair(ResultTys,
|
||||||
@ -1580,56 +1602,6 @@ SDOperand SelectionDAG::getNode(unsigned Opcode,
|
|||||||
return SDOperand(N, 0);
|
return SDOperand(N, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,SDOperand N1,
|
|
||||||
MVT::ValueType EVT) {
|
|
||||||
EVTStruct NN;
|
|
||||||
NN.Opcode = Opcode;
|
|
||||||
NN.VT = VT;
|
|
||||||
NN.EVT = EVT;
|
|
||||||
NN.Ops.push_back(N1);
|
|
||||||
|
|
||||||
SDNode *&N = MVTSDNodes[NN];
|
|
||||||
if (N) return SDOperand(N, 0);
|
|
||||||
N = new MVTSDNode(Opcode, VT, N1, EVT);
|
|
||||||
AllNodes.push_back(N);
|
|
||||||
return SDOperand(N, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,SDOperand N1,
|
|
||||||
SDOperand N2, SDOperand N3, MVT::ValueType EVT) {
|
|
||||||
switch (Opcode) {
|
|
||||||
default: assert(0 && "Bad opcode for this accessor!");
|
|
||||||
case ISD::EXTLOAD:
|
|
||||||
case ISD::SEXTLOAD:
|
|
||||||
case ISD::ZEXTLOAD:
|
|
||||||
// If they are asking for an extending load from/to the same thing, return a
|
|
||||||
// normal load.
|
|
||||||
if (VT == EVT)
|
|
||||||
return getLoad(VT, N1, N2, N3);
|
|
||||||
assert(EVT < VT && "Should only be an extending load, not truncating!");
|
|
||||||
assert((Opcode == ISD::EXTLOAD || MVT::isInteger(VT)) &&
|
|
||||||
"Cannot sign/zero extend a FP load!");
|
|
||||||
assert(MVT::isInteger(VT) == MVT::isInteger(EVT) &&
|
|
||||||
"Cannot convert from FP to Int or Int -> FP!");
|
|
||||||
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);
|
|
||||||
|
|
||||||
SDNode *&N = MVTSDNodes[NN];
|
|
||||||
if (N) return SDOperand(N, 0);
|
|
||||||
N = new MVTSDNode(Opcode, VT, MVT::Other, N1, N2, N3, EVT);
|
|
||||||
AllNodes.push_back(N);
|
|
||||||
return SDOperand(N, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// hasNUsesOfValue - Return true if there are exactly NUSES uses of the
|
/// hasNUsesOfValue - Return true if there are exactly NUSES uses of the
|
||||||
/// indicated value. This method ignores uses of other values defined by this
|
/// indicated value. This method ignores uses of other values defined by this
|
||||||
/// operation.
|
/// operation.
|
||||||
@ -1836,8 +1808,6 @@ void SDNode::dump() const {
|
|||||||
} else if (const ExternalSymbolSDNode *ES =
|
} else if (const ExternalSymbolSDNode *ES =
|
||||||
dyn_cast<ExternalSymbolSDNode>(this)) {
|
dyn_cast<ExternalSymbolSDNode>(this)) {
|
||||||
std::cerr << "'" << ES->getSymbol() << "'";
|
std::cerr << "'" << ES->getSymbol() << "'";
|
||||||
} else if (const MVTSDNode *M = dyn_cast<MVTSDNode>(this)) {
|
|
||||||
std::cerr << " - Ty = " << MVT::getValueTypeString(M->getExtraValueType());
|
|
||||||
} else if (const SrcValueSDNode *M = dyn_cast<SrcValueSDNode>(this)) {
|
} else if (const SrcValueSDNode *M = dyn_cast<SrcValueSDNode>(this)) {
|
||||||
if (M->getValue())
|
if (M->getValue())
|
||||||
std::cerr << "<" << M->getValue() << ":" << M->getOffset() << ">";
|
std::cerr << "<" << M->getValue() << ":" << M->getOffset() << ">";
|
||||||
|
@ -88,8 +88,6 @@ std::string DOTGraphTraits<SelectionDAG*>::getNodeLabel(const SDNode *Node,
|
|||||||
} else if (const ExternalSymbolSDNode *ES =
|
} else if (const ExternalSymbolSDNode *ES =
|
||||||
dyn_cast<ExternalSymbolSDNode>(Node)) {
|
dyn_cast<ExternalSymbolSDNode>(Node)) {
|
||||||
Op += "'" + std::string(ES->getSymbol()) + "'";
|
Op += "'" + std::string(ES->getSymbol()) + "'";
|
||||||
} else if (const MVTSDNode *M = dyn_cast<MVTSDNode>(Node)) {
|
|
||||||
Op = Op + " ty=" + MVT::getValueTypeString(M->getExtraValueType());
|
|
||||||
} else if (const SrcValueSDNode *M = dyn_cast<SrcValueSDNode>(Node)) {
|
} else if (const SrcValueSDNode *M = dyn_cast<SrcValueSDNode>(Node)) {
|
||||||
if (M->getValue())
|
if (M->getValue())
|
||||||
Op += "<" + M->getValue()->getName() + ":" + itostr(M->getOffset()) + ">";
|
Op += "<" + M->getValue()->getName() + ":" + itostr(M->getOffset()) + ">";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user