[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp SelectionDAG.cpp SelectionDAGISel.cpp
Nate Begeman
natebegeman at mac.com
Wed Jan 25 10:22:09 PST 2006
Changes in directory llvm/lib/CodeGen/SelectionDAG:
LegalizeDAG.cpp updated: 1.276 -> 1.277
SelectionDAG.cpp updated: 1.243 -> 1.244
SelectionDAGISel.cpp updated: 1.136 -> 1.137
---
Log message:
First part of bug 680: http://llvm.cs.uiuc.edu/PR680 :
Remove TLI.LowerVA* and replace it with SDNodes that are lowered the same
way as everything else.
---
Diffs of the changes: (+192 -67)
LegalizeDAG.cpp | 157 +++++++++++++++++++++++++++++++++++++++++++++++++--
SelectionDAG.cpp | 33 ++++++++--
SelectionDAGISel.cpp | 69 +++++-----------------
3 files changed, 192 insertions(+), 67 deletions(-)
Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.276 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.277
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.276 Mon Jan 23 23:48:21 2006
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Wed Jan 25 12:21:52 2006
@@ -1115,13 +1115,12 @@
switch (TLI.getOperationAction(Node->getOpcode(), VT)) {
default: assert(0 && "This action is not supported yet!");
case TargetLowering::Custom: {
- SDOperand Op = DAG.getLoad(Node->getValueType(0),
- Tmp1, Tmp2, Node->getOperand(2));
+ SDOperand Op = DAG.getLoad(VT, Tmp1, Tmp2, Node->getOperand(2));
SDOperand Tmp = TLI.LowerOperation(Op, DAG);
if (Tmp.Val) {
Result = LegalizeOp(Tmp);
- // Since loads produce two values, make sure to remember that we legalized
- // both of them.
+ // Since loads produce two values, make sure to remember that we
+ // legalized both of them.
AddLegalizedOperand(SDOperand(Node, 0), Result);
AddLegalizedOperand(SDOperand(Node, 1), Result.getValue(1));
return Result.getValue(Op.ResNo);
@@ -1131,8 +1130,7 @@
case TargetLowering::Legal:
if (Tmp1 != Node->getOperand(0) ||
Tmp2 != Node->getOperand(1))
- Result = DAG.getLoad(Node->getValueType(0), Tmp1, Tmp2,
- Node->getOperand(2));
+ Result = DAG.getLoad(VT, Tmp1, Tmp2, Node->getOperand(2));
else
Result = SDOperand(Node, 0);
@@ -2222,6 +2220,140 @@
}
break;
+ case ISD::VAARG: {
+ Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain.
+ Tmp2 = LegalizeOp(Node->getOperand(1)); // Legalize the pointer.
+
+ MVT::ValueType VT = Node->getValueType(0);
+ switch (TLI.getOperationAction(Node->getOpcode(), MVT::Other)) {
+ default: assert(0 && "This action is not supported yet!");
+ case TargetLowering::Custom: {
+ SDOperand Op = DAG.getVAArg(VT, Tmp1, Tmp2, Node->getOperand(2));
+ SDOperand Tmp = TLI.LowerOperation(Op, DAG);
+ if (Tmp.Val) {
+ Result = LegalizeOp(Tmp);
+ break;
+ }
+ // FALLTHROUGH if the target thinks it is legal.
+ }
+ case TargetLowering::Legal:
+ if (Tmp1 != Node->getOperand(0) ||
+ Tmp2 != Node->getOperand(1))
+ Result = DAG.getVAArg(VT, Tmp1, Tmp2, Node->getOperand(2));
+ else
+ Result = SDOperand(Node, 0);
+ break;
+ case TargetLowering::Expand: {
+ SDOperand VAList = DAG.getLoad(TLI.getPointerTy(), Tmp1, Tmp2,
+ Node->getOperand(2));
+ // Increment the pointer, VAList, to the next vaarg
+ Tmp3 = DAG.getNode(ISD::ADD, TLI.getPointerTy(), VAList,
+ DAG.getConstant(MVT::getSizeInBits(VT)/8,
+ TLI.getPointerTy()));
+ // Store the incremented VAList to the legalized pointer
+ Tmp3 = DAG.getNode(ISD::STORE, MVT::Other, VAList.getValue(1), Tmp3, Tmp2,
+ Node->getOperand(2));
+ // Load the actual argument out of the pointer VAList
+ Result = DAG.getLoad(VT, Tmp3, VAList, DAG.getSrcValue(0));
+ Result = LegalizeOp(Result);
+ break;
+ }
+ }
+ // Since VAARG produces two values, make sure to remember that we
+ // legalized both of them.
+ AddLegalizedOperand(SDOperand(Node, 0), Result);
+ AddLegalizedOperand(SDOperand(Node, 1), Result.getValue(1));
+ return Result.getValue(Op.ResNo);
+ }
+
+ case ISD::VACOPY:
+ Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain.
+ Tmp2 = LegalizeOp(Node->getOperand(1)); // Legalize the dest pointer.
+ Tmp3 = LegalizeOp(Node->getOperand(2)); // Legalize the source pointer.
+
+ switch (TLI.getOperationAction(ISD::VACOPY, MVT::Other)) {
+ default: assert(0 && "This action is not supported yet!");
+ case TargetLowering::Custom: {
+ SDOperand Op = DAG.getNode(ISD::VACOPY, MVT::Other, Tmp1, Tmp2, Tmp3,
+ Node->getOperand(3), Node->getOperand(4));
+ SDOperand Tmp = TLI.LowerOperation(Op, DAG);
+ if (Tmp.Val) {
+ Result = LegalizeOp(Tmp);
+ break;
+ }
+ // FALLTHROUGH if the target thinks it is legal.
+ }
+ case TargetLowering::Legal:
+ if (Tmp1 != Node->getOperand(0) ||
+ Tmp2 != Node->getOperand(1) ||
+ Tmp3 != Node->getOperand(2))
+ Result = DAG.getNode(ISD::VACOPY, MVT::Other, Tmp1, Tmp2, Tmp3,
+ Node->getOperand(3), Node->getOperand(4));
+ break;
+ case TargetLowering::Expand:
+ // This defaults to loading a pointer from the input and storing it to the
+ // output, returning the chain.
+ Tmp4 = DAG.getLoad(TLI.getPointerTy(), Tmp1, Tmp3, Node->getOperand(3));
+ Result = DAG.getNode(ISD::STORE, MVT::Other, Tmp4.getValue(1), Tmp4, Tmp2,
+ Node->getOperand(4));
+ Result = LegalizeOp(Result);
+ break;
+ }
+ break;
+
+ case ISD::VAEND:
+ Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain.
+ Tmp2 = LegalizeOp(Node->getOperand(1)); // Legalize the pointer.
+
+ switch (TLI.getOperationAction(ISD::VAEND, MVT::Other)) {
+ default: assert(0 && "This action is not supported yet!");
+ case TargetLowering::Custom: {
+ SDOperand Op = DAG.getNode(ISD::VAEND, MVT::Other, Tmp1, Tmp2,
+ Node->getOperand(2));
+ SDOperand Tmp = TLI.LowerOperation(Op, DAG);
+ if (Tmp.Val) {
+ Result = LegalizeOp(Tmp);
+ break;
+ }
+ // FALLTHROUGH if the target thinks it is legal.
+ }
+ case TargetLowering::Legal:
+ if (Tmp1 != Node->getOperand(0) ||
+ Tmp2 != Node->getOperand(1))
+ Result = DAG.getNode(ISD::VAEND, MVT::Other, Tmp1, Tmp2,
+ Node->getOperand(2));
+ break;
+ case TargetLowering::Expand:
+ Result = Tmp1; // Default to a no-op, return the chain
+ break;
+ }
+ break;
+
+ case ISD::VASTART:
+ Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain.
+ Tmp2 = LegalizeOp(Node->getOperand(1)); // Legalize the pointer.
+
+ switch (TLI.getOperationAction(ISD::VASTART, MVT::Other)) {
+ default: assert(0 && "This action is not supported yet!");
+ case TargetLowering::Custom: {
+ SDOperand Op = DAG.getNode(ISD::VASTART, MVT::Other, Tmp1, Tmp2,
+ Node->getOperand(2));
+ SDOperand Tmp = TLI.LowerOperation(Op, DAG);
+ if (Tmp.Val) {
+ Result = LegalizeOp(Tmp);
+ break;
+ }
+ // FALLTHROUGH if the target thinks it is legal.
+ }
+ case TargetLowering::Legal:
+ if (Tmp1 != Node->getOperand(0) ||
+ Tmp2 != Node->getOperand(1))
+ Result = DAG.getNode(ISD::VASTART, MVT::Other, Tmp1, Tmp2,
+ Node->getOperand(2));
+ break;
+ }
+ break;
+
case ISD::ROTL:
case ISD::ROTR:
Tmp1 = LegalizeOp(Node->getOperand(0)); // LHS
@@ -3823,6 +3955,19 @@
break;
}
+ case ISD::VAARG: {
+ SDOperand Ch = LegalizeOp(Node->getOperand(0)); // Legalize the chain.
+ SDOperand Ptr = LegalizeOp(Node->getOperand(1)); // Legalize the pointer.
+ Lo = DAG.getVAArg(NVT, Ch, Ptr, Node->getOperand(2));
+ Hi = DAG.getVAArg(NVT, Lo.getValue(1), Ptr, Node->getOperand(2));
+
+ // Remember that we legalized the chain.
+ AddLegalizedOperand(Op.getValue(1), Hi.getValue(1));
+ if (!TLI.isLittleEndian())
+ std::swap(Lo, Hi);
+ break;
+ }
+
case ISD::LOAD: {
SDOperand Ch = LegalizeOp(Node->getOperand(0)); // Legalize the chain.
SDOperand Ptr = LegalizeOp(Node->getOperand(1)); // Legalize the pointer.
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.243 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.244
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.243 Mon Jan 23 23:48:21 2006
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Wed Jan 25 12:21:52 2006
@@ -1348,6 +1348,20 @@
return SDOperand(N, 0);
}
+SDOperand SelectionDAG::getVAArg(MVT::ValueType VT,
+ SDOperand Chain, SDOperand Ptr,
+ SDOperand SV) {
+ std::vector<SDOperand> Ops;
+ Ops.reserve(3);
+ Ops.push_back(Chain);
+ Ops.push_back(Ptr);
+ Ops.push_back(SV);
+ std::vector<MVT::ValueType> VTs;
+ VTs.reserve(2);
+ VTs.push_back(VT); VTs.push_back(MVT::Other); // Add token chain.
+ return getNode(ISD::VAARG, VTs, Ops);
+}
+
SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
std::vector<SDOperand> &Ops) {
switch (Ops.size()) {
@@ -2087,14 +2101,17 @@
case ISD::CALLSEQ_END: return "callseq_end";
// Other operators
- case ISD::LOAD: return "load";
- case ISD::STORE: return "store";
- case ISD::VLOAD: return "vload";
- case ISD::EXTLOAD: return "extload";
- case ISD::SEXTLOAD: return "sextload";
- case ISD::ZEXTLOAD: return "zextload";
- case ISD::TRUNCSTORE: return "truncstore";
-
+ case ISD::LOAD: return "load";
+ case ISD::STORE: return "store";
+ case ISD::VLOAD: return "vload";
+ case ISD::EXTLOAD: return "extload";
+ case ISD::SEXTLOAD: return "sextload";
+ case ISD::ZEXTLOAD: return "zextload";
+ case ISD::TRUNCSTORE: return "truncstore";
+ case ISD::VAARG: return "vaarg";
+ case ISD::VACOPY: return "vacopy";
+ case ISD::VAEND: return "vaend";
+ case ISD::VASTART: return "vastart";
case ISD::DYNAMIC_STACKALLOC: return "dynamic_stackalloc";
case ISD::EXTRACT_ELEMENT: return "extract_element";
case ISD::BUILD_PAIR: return "build_pair";
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.136 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.137
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.136 Wed Jan 25 03:12:57 2006
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Wed Jan 25 12:21:52 2006
@@ -1204,71 +1204,34 @@
return DAG.getNode(ISD::RET, MVT::Other, Chain, Op);
}
-SDOperand TargetLowering::LowerVAStart(SDOperand Chain,
- SDOperand VAListP, Value *VAListV,
- SelectionDAG &DAG) {
- // We have no sane default behavior, just emit a useful error message and bail
- // out.
- std::cerr << "Variable arguments handling not implemented on this target!\n";
- abort();
- return SDOperand();
-}
-
-SDOperand TargetLowering::LowerVAEnd(SDOperand Chain, SDOperand LP, Value *LV,
- SelectionDAG &DAG) {
- // Default to a noop.
- return Chain;
-}
-
-SDOperand TargetLowering::LowerVACopy(SDOperand Chain,
- SDOperand SrcP, Value *SrcV,
- SDOperand DestP, Value *DestV,
- SelectionDAG &DAG) {
- // Default to copying the input list.
- SDOperand Val = DAG.getLoad(getPointerTy(), Chain,
- SrcP, DAG.getSrcValue(SrcV));
- SDOperand Result = DAG.getNode(ISD::STORE, MVT::Other, Val.getValue(1),
- Val, DestP, DAG.getSrcValue(DestV));
- return Result;
-}
-
-std::pair<SDOperand,SDOperand>
-TargetLowering::LowerVAArg(SDOperand Chain, SDOperand VAListP, Value *VAListV,
- const Type *ArgTy, SelectionDAG &DAG) {
- // We have no sane default behavior, just emit a useful error message and bail
- // out.
- std::cerr << "Variable arguments handling not implemented on this target!\n";
- abort();
- return std::make_pair(SDOperand(), SDOperand());
-}
-
-
void SelectionDAGLowering::visitVAStart(CallInst &I) {
- DAG.setRoot(TLI.LowerVAStart(getRoot(), getValue(I.getOperand(1)),
- I.getOperand(1), DAG));
+ DAG.setRoot(DAG.getNode(ISD::VASTART, MVT::Other, getRoot(),
+ getValue(I.getOperand(1)),
+ DAG.getSrcValue(I.getOperand(1))));
}
void SelectionDAGLowering::visitVAArg(VAArgInst &I) {
- std::pair<SDOperand,SDOperand> Result =
- TLI.LowerVAArg(getRoot(), getValue(I.getOperand(0)), I.getOperand(0),
- I.getType(), DAG);
- setValue(&I, Result.first);
- DAG.setRoot(Result.second);
+ SDOperand V = DAG.getVAArg(TLI.getValueType(I.getType()), getRoot(),
+ getValue(I.getOperand(0)),
+ DAG.getSrcValue(I.getOperand(0)));
+ setValue(&I, V);
+ DAG.setRoot(V.getValue(1));
}
void SelectionDAGLowering::visitVAEnd(CallInst &I) {
- DAG.setRoot(TLI.LowerVAEnd(getRoot(), getValue(I.getOperand(1)),
- I.getOperand(1), DAG));
+ DAG.setRoot(DAG.getNode(ISD::VAEND, MVT::Other, getRoot(),
+ getValue(I.getOperand(1)),
+ DAG.getSrcValue(I.getOperand(1))));
}
void SelectionDAGLowering::visitVACopy(CallInst &I) {
- SDOperand Result =
- TLI.LowerVACopy(getRoot(), getValue(I.getOperand(2)), I.getOperand(2),
- getValue(I.getOperand(1)), I.getOperand(1), DAG);
- DAG.setRoot(Result);
+ DAG.setRoot(DAG.getNode(ISD::VACOPY, MVT::Other, getRoot(),
+ getValue(I.getOperand(1)),
+ getValue(I.getOperand(2)),
+ DAG.getSrcValue(I.getOperand(1)),
+ DAG.getSrcValue(I.getOperand(2))));
}
-
// It is always conservatively correct for llvm.returnaddress and
// llvm.frameaddress to return 0.
std::pair<SDOperand, SDOperand>
More information about the llvm-commits
mailing list