[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp SelectionDAG.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sat Jan 28 23:58:27 PST 2006
Changes in directory llvm/lib/CodeGen/SelectionDAG:
LegalizeDAG.cpp updated: 1.292 -> 1.293
SelectionDAG.cpp updated: 1.249 -> 1.250
---
Log message:
Remove some special case hacks for CALLSEQ_*, using UpdateNodeOperands
instead.
---
Diffs of the changes: (+27 -60)
LegalizeDAG.cpp | 37 +++++++++++++++++++++----------------
SelectionDAG.cpp | 50 ++++++--------------------------------------------
2 files changed, 27 insertions(+), 60 deletions(-)
Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.292 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.293
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.292 Sun Jan 29 00:34:16 2006
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Sun Jan 29 01:58:15 2006
@@ -589,22 +589,24 @@
case ISD::CALLSEQ_START:
case ISD::CALLSEQ_END:
Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain.
- // Do not try to legalize the target-specific arguments (#1+)
- Tmp2 = Node->getOperand(0);
- if (Tmp1 != Tmp2)
- Node->setAdjCallChain(Tmp1);
-
- // If this has a flag input, do legalize it.
- if (Node->getOperand(Node->getNumOperands()-1).getValueType() == MVT::Flag){
- Tmp1 = LegalizeOp(Node->getOperand(Node->getNumOperands()-1));
- if (Tmp1 != Node->getOperand(Node->getNumOperands()-1))
- Node->setAdjCallFlag(Tmp1);
+ // Do not try to legalize the target-specific arguments (#1+), except for
+ // an optional flag input.
+ if (Node->getOperand(Node->getNumOperands()-1).getValueType() != MVT::Flag){
+ if (Tmp1 != Node->getOperand(0)) {
+ std::vector<SDOperand> Ops(Node->op_begin(), Node->op_end());
+ Ops[0] = Tmp1;
+ Result = DAG.UpdateNodeOperands(Result, Ops);
+ }
+ } else {
+ Tmp2 = LegalizeOp(Node->getOperand(Node->getNumOperands()-1));
+ if (Tmp1 != Node->getOperand(0) ||
+ Tmp2 != Node->getOperand(Node->getNumOperands()-1)) {
+ std::vector<SDOperand> Ops(Node->op_begin(), Node->op_end());
+ Ops[0] = Tmp1;
+ Ops.back() = Tmp2;
+ Result = DAG.UpdateNodeOperands(Result, Ops);
+ }
}
-
- // Note that we do not create new CALLSEQ_DOWN/UP nodes here. These
- // nodes are treated specially and are mutated in place. This makes the dag
- // legalization process more efficient and also makes libcall insertion
- // easier.
break;
case ISD::DYNAMIC_STACKALLOC: {
Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain.
@@ -2964,7 +2966,10 @@
SDOperand InToken = DAG.getNode(ISD::TokenFactor, MVT::Other, CallResult,
OutChain->getOperand(0));
// Change the node to refer to the new token.
- OutChain->setAdjCallChain(InToken);
+ std::vector<SDOperand> Ops(OutChain->op_begin(), OutChain->op_end());
+ Ops[0] = InToken;
+ SDOperand Res = DAG.UpdateNodeOperands(SDOperand(OutChain, 0), Ops);
+ assert(Res.Val == OutChain && "Didn't update in place!");
}
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.249 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.250
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.249 Sun Jan 29 00:26:56 2006
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Sun Jan 29 01:58:15 2006
@@ -380,9 +380,7 @@
// flag result (which cannot be CSE'd) or is one of the special cases that are
// not subject to CSE.
if (!Erased && N->getValueType(N->getNumValues()-1) != MVT::Flag &&
- N->getOpcode() != ISD::CALLSEQ_START &&
- N->getOpcode() != ISD::CALLSEQ_END && !N->isTargetOpcode()) {
-
+ !N->isTargetOpcode()) {
N->dump();
assert(0 && "Node is not in map!");
}
@@ -396,9 +394,7 @@
///
SDNode *SelectionDAG::AddNonLeafNodeToCSEMaps(SDNode *N) {
assert(N->getNumOperands() && "This is a leaf node!");
- if (N->getOpcode() == ISD::CALLSEQ_START ||
- N->getOpcode() == ISD::CALLSEQ_END ||
- N->getOpcode() == ISD::HANDLENODE || N->getValueType(0) == MVT::Flag)
+ if (N->getOpcode() == ISD::HANDLENODE || N->getValueType(0) == MVT::Flag)
return 0; // Never add these nodes.
// Check that remaining values produced are not flags.
@@ -451,9 +447,7 @@
/// return null, otherwise return a pointer to the slot it would take. If a
/// node already exists with these operands, the slot will be non-null.
SDNode **SelectionDAG::FindModifiedNodeSlot(SDNode *N, SDOperand Op) {
- if (N->getOpcode() == ISD::CALLSEQ_START ||
- N->getOpcode() == ISD::CALLSEQ_END ||
- N->getOpcode() == ISD::HANDLENODE || N->getValueType(0) == MVT::Flag)
+ if (N->getOpcode() == ISD::HANDLENODE || N->getValueType(0) == MVT::Flag)
return 0; // Never add these nodes.
// Check that remaining values produced are not flags.
@@ -481,9 +475,7 @@
/// node already exists with these operands, the slot will be non-null.
SDNode **SelectionDAG::FindModifiedNodeSlot(SDNode *N,
SDOperand Op1, SDOperand Op2) {
- if (N->getOpcode() == ISD::CALLSEQ_START ||
- N->getOpcode() == ISD::CALLSEQ_END ||
- N->getOpcode() == ISD::HANDLENODE || N->getValueType(0) == MVT::Flag)
+ if (N->getOpcode() == ISD::HANDLENODE || N->getValueType(0) == MVT::Flag)
return 0; // Never add these nodes.
// Check that remaining values produced are not flags.
@@ -512,9 +504,7 @@
/// node already exists with these operands, the slot will be non-null.
SDNode **SelectionDAG::FindModifiedNodeSlot(SDNode *N,
const std::vector<SDOperand> &Ops) {
- if (N->getOpcode() == ISD::CALLSEQ_START ||
- N->getOpcode() == ISD::CALLSEQ_END ||
- N->getOpcode() == ISD::HANDLENODE || N->getValueType(0) == MVT::Flag)
+ if (N->getOpcode() == ISD::HANDLENODE || N->getValueType(0) == MVT::Flag)
return 0; // Never add these nodes.
// Check that remaining values produced are not flags.
@@ -1296,8 +1286,7 @@
// Memoize this node if possible.
SDNode *N;
- if (Opcode != ISD::CALLSEQ_START && Opcode != ISD::CALLSEQ_END &&
- VT != MVT::Flag) {
+ if (VT != MVT::Flag) {
SDNode *&BON = BinaryOps[std::make_pair(Opcode, std::make_pair(N1, N2))];
if (BON) return SDOperand(BON, 0);
@@ -1387,33 +1376,6 @@
return getNode(Opcode, VT, Ops);
}
-// setAdjCallChain - This method changes the token chain of an
-// CALLSEQ_START/END node to be the specified operand.
-void SDNode::setAdjCallChain(SDOperand N) {
- assert(N.getValueType() == MVT::Other);
- assert((getOpcode() == ISD::CALLSEQ_START ||
- getOpcode() == ISD::CALLSEQ_END) && "Cannot adjust this node!");
-
- OperandList[0].Val->removeUser(this);
- OperandList[0] = N;
- OperandList[0].Val->Uses.push_back(this);
-}
-
-// setAdjCallFlag - This method changes the flag input of an
-// CALLSEQ_START/END node to be the specified operand.
-void SDNode::setAdjCallFlag(SDOperand N) {
- assert(N.getValueType() == MVT::Flag);
- assert((getOpcode() == ISD::CALLSEQ_START ||
- getOpcode() == ISD::CALLSEQ_END) && "Cannot adjust this node!");
-
- SDOperand &FlagOp = OperandList[getNumOperands()-1];
- assert(FlagOp.getValueType() == MVT::Flag);
- FlagOp.Val->removeUser(this);
- FlagOp = N;
- FlagOp.Val->Uses.push_back(this);
-}
-
-
SDOperand SelectionDAG::getLoad(MVT::ValueType VT,
SDOperand Chain, SDOperand Ptr,
SDOperand SV) {
More information about the llvm-commits
mailing list