[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp SelectionDAG.cpp

Chris Lattner lattner at cs.uiuc.edu
Tue Aug 16 11:17:21 PDT 2005



Changes in directory llvm/lib/CodeGen/SelectionDAG:

LegalizeDAG.cpp updated: 1.160 -> 1.161
SelectionDAG.cpp updated: 1.139 -> 1.140
---
Log message:

Add some methods for dag->dag isel.
Split RemoveNodeFromCSEMaps out of DeleteNodesIfDead to do it.


---
Diffs of the changes:  (+59 -19)

 LegalizeDAG.cpp  |    2 -
 SelectionDAG.cpp |   76 +++++++++++++++++++++++++++++++++++++++++--------------
 2 files changed, 59 insertions(+), 19 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.160 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.161
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.160	Sun Aug 14 13:38:32 2005
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp	Tue Aug 16 13:17:10 2005
@@ -203,7 +203,7 @@
   return DAG.getNode(ISD::ADD, DestVT, Tmp1, FudgeInReg);
 }
 
-/// PromoteLegalUINT_TO_FP - This function is responsible for legalizing a
+/// PromoteLegalINT_TO_FP - This function is responsible for legalizing a
 /// *INT_TO_FP operation of the specified operand when the target requests that
 /// we promote it.  At this point, we know that the result and operand types are
 /// legal for the target, and that there is a legal UINT_TO_FP or SINT_TO_FP


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.139 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.140
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.139	Sat Aug 13 01:14:17 2005
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp	Tue Aug 16 13:17:10 2005
@@ -177,12 +177,40 @@
   delete DummyNode;
 }
 
+
 void SelectionDAG::DeleteNodeIfDead(SDNode *N, void *NodeSet) {
   if (!N->use_empty())
     return;
 
   // Okay, we really are going to delete this node.  First take this out of the
   // appropriate CSE map.
+  RemoveNodeFromCSEMaps(N);
+  
+  // Next, brutally remove the operand list.  This is safe to do, as there are
+  // no cycles in the graph.
+  while (!N->Operands.empty()) {
+    SDNode *O = N->Operands.back().Val;
+    N->Operands.pop_back();
+    O->removeUser(N);
+    
+    // Now that we removed this operand, see if there are no uses of it left.
+    DeleteNodeIfDead(O, NodeSet);
+  }
+  
+  // Remove the node from the nodes set and delete it.
+  std::set<SDNode*> &AllNodeSet = *(std::set<SDNode*>*)NodeSet;
+  AllNodeSet.erase(N);
+  
+  // Now that the node is gone, check to see if any of the operands of this node
+  // are dead now.
+  delete N;  
+}
+
+/// RemoveNodeFromCSEMaps - Take the specified node out of the CSE map that
+/// correspond to it.  This is useful when we're about to delete or repurpose
+/// the node.  We don't want future request for structurally identical nodes
+/// to return N anymore.
+void SelectionDAG::RemoveNodeFromCSEMaps(SDNode *N) {
   switch (N->getOpcode()) {
   case ISD::Constant:
     Constants.erase(std::make_pair(cast<ConstantSDNode>(N)->getValue(),
@@ -253,24 +281,6 @@
     }
     break;
   }
-
-  // Next, brutally remove the operand list.
-  while (!N->Operands.empty()) {
-    SDNode *O = N->Operands.back().Val;
-    N->Operands.pop_back();
-    O->removeUser(N);
-
-    // Now that we removed this operand, see if there are no uses of it left.
-    DeleteNodeIfDead(O, NodeSet);
-  }
-
-  // Remove the node from the nodes set and delete it.
-  std::set<SDNode*> &AllNodeSet = *(std::set<SDNode*>*)NodeSet;
-  AllNodeSet.erase(N);
-
-  // Now that the node is gone, check to see if any of the operands of this node
-  // are dead now.
-  delete N;
 }
 
 
@@ -1679,6 +1689,36 @@
   return SDOperand(N, 0);
 }
 
+
+/// SelectNodeTo - These are used for target selectors to *mutate* the
+/// specified node to have the specified return type, Target opcode, and
+/// operands.  Note that target opcodes are stored as
+/// ISD::BUILTIN_OP_END+TargetOpcode in the node opcode field.
+void SelectionDAG::SelectNodeTo(SDNode *N, MVT::ValueType VT,
+                                unsigned TargetOpc, SDOperand Op1) {
+  RemoveNodeFromCSEMaps(N);
+  N->MorphNodeTo(ISD::BUILTIN_OP_END+TargetOpc);
+  N->setValueTypes(VT);
+  N->setOperands(Op1);
+}
+void SelectionDAG::SelectNodeTo(SDNode *N, MVT::ValueType VT,
+                                unsigned TargetOpc, SDOperand Op1,
+                                SDOperand Op2) {
+  RemoveNodeFromCSEMaps(N);
+  N->MorphNodeTo(ISD::BUILTIN_OP_END+TargetOpc);
+  N->setValueTypes(VT);
+  N->setOperands(Op1, Op2);
+}
+void SelectionDAG::SelectNodeTo(SDNode *N, MVT::ValueType VT,
+                                unsigned TargetOpc, SDOperand Op1,
+                                SDOperand Op2, SDOperand Op3) {
+  RemoveNodeFromCSEMaps(N);
+  N->MorphNodeTo(ISD::BUILTIN_OP_END+TargetOpc);
+  N->setValueTypes(VT);
+  N->setOperands(Op1, Op2, Op3);
+}
+
+
 /// hasNUsesOfValue - Return true if there are exactly NUSES uses of the
 /// indicated value.  This method ignores uses of other values defined by this
 /// operation.






More information about the llvm-commits mailing list