[llvm-commits] [llvm] r55608 - in /llvm/trunk/lib/CodeGen/SelectionDAG: LegalizeTypes.cpp LegalizeTypes.h

Gabor Greif ggreif at gmail.com
Mon Sep 1 08:10:22 PDT 2008


Author: ggreif
Date: Mon Sep  1 10:10:19 2008
New Revision: 55608

URL: http://llvm.org/viewvc/llvm-project?rev=55608&view=rev
Log:
Provide two overloads of AnalyzeNewNode.

The first can update the SDNode in an SDValue
while the second is called with SDNode* and
returns a possibly updated SDNode*.

This patch has no intended functional impact,
but helps eliminating ugly temporary SDValues.

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp?rev=55608&r1=55607&r2=55608&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp Mon Sep  1 10:10:19 2008
@@ -221,11 +221,11 @@
 /// AnalyzeNewNode - The specified node is the root of a subtree of potentially
 /// new nodes.  Correct any processed operands (this may change the node) and
 /// calculate the NodeId.
-void DAGTypeLegalizer::AnalyzeNewNode(SDValue &Val) {
-  SDNode * const N(Val.getNode());
+/// Returns the potentially changed node.
+SDNode *DAGTypeLegalizer::AnalyzeNewNode(SDNode *N) {
   // If this was an existing node that is already done, we're done.
   if (N->getNodeId() != NewNode)
-    return;
+    return N;
 
   // Remove any stale map entries.
   ExpungeNode(N);
@@ -268,16 +268,26 @@
 
   // Some operands changed - update the node.
   if (!NewOps.empty())
-    Val.setNode(DAG.UpdateNodeOperands(SDValue(N, 0),
-				       &NewOps[0],
-				       NewOps.size()).getNode());
-
-  SDNode * const Nu(Val.getNode());
-  Nu->setNodeId(Nu->getNumOperands()-NumProcessed);
-  if (Nu->getNodeId() == ReadyToProcess)
-    Worklist.push_back(Nu);
+    N = DAG.UpdateNodeOperands(SDValue(N, 0),
+                               &NewOps[0],
+                               NewOps.size()).getNode();
+
+  N->setNodeId(N->getNumOperands()-NumProcessed);
+  if (N->getNodeId() == ReadyToProcess)
+    Worklist.push_back(N);
+  return N;
+}
+
+/// AnalyzeNewNode - call AnalyzeNewNode(SDNode *N)
+/// and update the node in SDValue if necessary.
+void DAGTypeLegalizer::AnalyzeNewNode(SDValue &Val) {
+  SDNode *N(Val.getNode());
+  SDNode *M(AnalyzeNewNode(N));
+  if (N != M)
+    Val.setNode(M);
 }
 
+
 namespace {
   /// NodeUpdateListener - This class is a DAGUpdateListener that listens for
   /// updates to nodes and recomputes their ready state.
@@ -338,9 +348,7 @@
   // If expansion produced new nodes, make sure they are properly marked.
   ExpungeNode(From);
 
-  SDValue ToNode(To, 0);
-  AnalyzeNewNode(ToNode); // Expunges To.
-  To = ToNode.getNode();
+  To = AnalyzeNewNode(To); // Expunges To.
 
   assert(From->getNumValues() == To->getNumValues() &&
          "Node results don't match");

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h?rev=55608&r1=55607&r2=55608&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h Mon Sep  1 10:10:19 2008
@@ -157,9 +157,7 @@
   /// for the specified node, adding it to the worklist if ready.
   SDNode *ReanalyzeNode(SDNode *N) {
     N->setNodeId(NewNode);
-    SDValue V(N, 0);
-    AnalyzeNewNode(V); // FIXME: ignore the change?
-    return V.getNode();
+    return AnalyzeNewNode(N);
   }
 
   void NoteDeletion(SDNode *Old, SDNode *New) {
@@ -171,6 +169,7 @@
 
 private:
   void AnalyzeNewNode(SDValue &Val);
+  SDNode *AnalyzeNewNode(SDNode *N);
 
   void ReplaceValueWith(SDValue From, SDValue To);
   void ReplaceNodeWith(SDNode *From, SDNode *To);





More information about the llvm-commits mailing list