mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-27 14:24:40 +00:00
Start implementing truncating stores and extending loads.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19559 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -247,7 +247,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
|
|||||||
case ISD::ImplicitDef:
|
case ISD::ImplicitDef:
|
||||||
Tmp1 = LegalizeOp(Node->getOperand(0));
|
Tmp1 = LegalizeOp(Node->getOperand(0));
|
||||||
if (Tmp1 != Node->getOperand(0))
|
if (Tmp1 != Node->getOperand(0))
|
||||||
Result = DAG.getImplicitDef(cast<RegSDNode>(Node)->getReg());
|
Result = DAG.getImplicitDef(Tmp1, cast<RegSDNode>(Node)->getReg());
|
||||||
break;
|
break;
|
||||||
case ISD::Constant:
|
case ISD::Constant:
|
||||||
// We know we don't need to expand constants here, constants only have one
|
// We know we don't need to expand constants here, constants only have one
|
||||||
@ -525,18 +525,16 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
|
|||||||
Result = DAG.getNode(ISD::STORE, MVT::Other, Result, Hi, Tmp2);
|
Result = DAG.getNode(ISD::STORE, MVT::Other, Result, Hi, Tmp2);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ISD::SELECT: {
|
case ISD::SELECT:
|
||||||
// FIXME: BOOLS MAY REQUIRE PROMOTION!
|
// FIXME: BOOLS MAY REQUIRE PROMOTION!
|
||||||
Tmp1 = LegalizeOp(Node->getOperand(0)); // Cond
|
Tmp1 = LegalizeOp(Node->getOperand(0)); // Cond
|
||||||
Tmp2 = LegalizeOp(Node->getOperand(1)); // TrueVal
|
Tmp2 = LegalizeOp(Node->getOperand(1)); // TrueVal
|
||||||
SDOperand Tmp3 = LegalizeOp(Node->getOperand(2)); // FalseVal
|
Tmp3 = LegalizeOp(Node->getOperand(2)); // FalseVal
|
||||||
|
|
||||||
if (Tmp1 != Node->getOperand(0) ||
|
if (Tmp1 != Node->getOperand(0) || Tmp2 != Node->getOperand(1) ||
|
||||||
Tmp2 != Node->getOperand(1) ||
|
|
||||||
Tmp3 != Node->getOperand(2))
|
Tmp3 != Node->getOperand(2))
|
||||||
Result = DAG.getNode(ISD::SELECT, Node->getValueType(0), Tmp1, Tmp2,Tmp3);
|
Result = DAG.getNode(ISD::SELECT, Node->getValueType(0), Tmp1, Tmp2,Tmp3);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case ISD::SETCC:
|
case ISD::SETCC:
|
||||||
switch (getTypeAction(Node->getOperand(0).getValueType())) {
|
switch (getTypeAction(Node->getOperand(0).getValueType())) {
|
||||||
case Legal:
|
case Legal:
|
||||||
|
@ -833,6 +833,68 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,SDOperand N1,
|
||||||
|
SDOperand N2, 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 loat from/to the same thing, return a
|
||||||
|
// normal load.
|
||||||
|
if (VT == EVT)
|
||||||
|
return getNode(ISD::LOAD, VT, N1, N2);
|
||||||
|
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);
|
||||||
|
|
||||||
|
SDNode *&N = MVTSDNodes[NN];
|
||||||
|
if (N) return SDOperand(N, 0);
|
||||||
|
N = new MVTSDNode(Opcode, VT, N1, N2, 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::TRUNCSTORE:
|
||||||
|
if (N1.getValueType() == EVT) // Normal store?
|
||||||
|
return getNode(ISD::STORE, VT, N1, N2, N3);
|
||||||
|
assert(N1.getValueType() > EVT && "Not a truncation?");
|
||||||
|
assert(MVT::isInteger(N1.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);
|
||||||
|
|
||||||
|
SDNode *&N = MVTSDNodes[NN];
|
||||||
|
if (N) return SDOperand(N, 0);
|
||||||
|
N = new MVTSDNode(Opcode, VT, 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.
|
||||||
@ -923,6 +985,11 @@ const char *SDNode::getOperationName() const {
|
|||||||
// Other operators
|
// Other operators
|
||||||
case ISD::LOAD: return "load";
|
case ISD::LOAD: return "load";
|
||||||
case ISD::STORE: return "store";
|
case ISD::STORE: return "store";
|
||||||
|
case ISD::EXTLOAD: return "extload";
|
||||||
|
case ISD::SEXTLOAD: return "sextload";
|
||||||
|
case ISD::ZEXTLOAD: return "zextload";
|
||||||
|
case ISD::TRUNCSTORE: return "truncstore";
|
||||||
|
|
||||||
case ISD::DYNAMIC_STACKALLOC: return "dynamic_stackalloc";
|
case ISD::DYNAMIC_STACKALLOC: return "dynamic_stackalloc";
|
||||||
case ISD::EXTRACT_ELEMENT: return "extract_element";
|
case ISD::EXTRACT_ELEMENT: return "extract_element";
|
||||||
case ISD::BUILD_PAIR: return "build_pair";
|
case ISD::BUILD_PAIR: return "build_pair";
|
||||||
|
Reference in New Issue
Block a user