Port a shift-by-1 optimization from LegalizeDAG: it
[oota-llvm.git] / lib / CodeGen / SelectionDAG / SelectionDAGPrinter.cpp
index 719b949591ec56f93c5c2ebd2a60da2866a8bcb1..db119a649549c0e42dd947410101b3ebfa451ad9 100644 (file)
@@ -18,7 +18,8 @@
 #include "llvm/CodeGen/ScheduleDAG.h"
 #include "llvm/CodeGen/MachineConstantPool.h"
 #include "llvm/CodeGen/MachineFunction.h"
-#include "llvm/Target/MRegisterInfo.h"
+#include "llvm/CodeGen/MachineModuleInfo.h"
+#include "llvm/Target/TargetRegisterInfo.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Support/GraphWriter.h"
 #include "llvm/ADT/StringExtras.h"
@@ -48,7 +49,7 @@ namespace llvm {
     template<typename EdgeIter>
     static std::string getEdgeAttributes(const void *Node, EdgeIter EI) {
       SDOperand Op = EI.getNode()->getOperand(EI.getOperand());
-      MVT::ValueType VT = Op.getValueType();
+      MVT VT = Op.getValueType();
       if (VT == MVT::Flag)
         return "color=red,style=bold";
       else if (VT == MVT::Other)
@@ -90,7 +91,7 @@ std::string DOTGraphTraits<SelectionDAG*>::getNodeLabel(const SDNode *Node,
     if (Node->getValueType(i) == MVT::Other)
       Op += ":ch";
     else
-      Op = Op + ":" + MVT::getValueTypeString(Node->getValueType(i));
+      Op = Op + ":" + Node->getValueType(i).getMVTString();
     
   if (const ConstantSDNode *CSDN = dyn_cast<ConstantSDNode>(Node)) {
     Op += ": " + utostr(CSDN->getValue());
@@ -132,11 +133,19 @@ std::string DOTGraphTraits<SelectionDAG*>::getNodeLabel(const SDNode *Node,
     //Op += " " + (const void*)BBDN->getBasicBlock();
   } else if (const RegisterSDNode *R = dyn_cast<RegisterSDNode>(Node)) {
     if (G && R->getReg() != 0 &&
-        MRegisterInfo::isPhysicalRegister(R->getReg())) {
-      Op = Op + " " + G->getTarget().getRegisterInfo()->getName(R->getReg());
+        TargetRegisterInfo::isPhysicalRegister(R->getReg())) {
+      Op = Op + " " +
+        G->getTarget().getRegisterInfo()->getName(R->getReg());
     } else {
       Op += " #" + utostr(R->getReg());
     }
+  } else if (const DbgStopPointSDNode *D = dyn_cast<DbgStopPointSDNode>(Node)) {
+    Op += ": " + D->getCompileUnit()->getFileName();
+    Op += ":" + utostr(D->getLine());
+    if (D->getColumn() != 0)
+      Op += ":" + utostr(D->getColumn());
+  } else if (const LabelSDNode *L = dyn_cast<LabelSDNode>(Node)) {
+    Op += ": LabelID=" + utostr(L->getLabelID());
   } else if (const ExternalSymbolSDNode *ES =
              dyn_cast<ExternalSymbolSDNode>(Node)) {
     Op += "'" + std::string(ES->getSymbol()) + "'";
@@ -150,10 +159,10 @@ std::string DOTGraphTraits<SelectionDAG*>::getNodeLabel(const SDNode *Node,
       Op += "<" + M->MO.getValue()->getName() + ":" + itostr(M->MO.getOffset()) + ">";
     else
       Op += "<null:" + itostr(M->MO.getOffset()) + ">";
+  } else if (const ARG_FLAGSSDNode *N = dyn_cast<ARG_FLAGSSDNode>(Node)) {
+    Op = Op + " AF=" + N->getArgFlags().getArgFlagsString();
   } else if (const VTSDNode *N = dyn_cast<VTSDNode>(Node)) {
-    Op = Op + " VT=" + MVT::getValueTypeString(N->getVT());
-  } else if (const StringSDNode *N = dyn_cast<StringSDNode>(Node)) {
-    Op = Op + "\"" + N->getValue() + "\"";
+    Op = Op + " VT=" + N->getVT().getMVTString();
   } else if (const LoadSDNode *LD = dyn_cast<LoadSDNode>(Node)) {
     bool doExt = true;
     switch (LD->getExtensionType()) {
@@ -169,7 +178,7 @@ std::string DOTGraphTraits<SelectionDAG*>::getNodeLabel(const SDNode *Node,
       break;
     }
     if (doExt)
-      Op += MVT::getValueTypeString(LD->getMemoryVT()) + ">";
+      Op += LD->getMemoryVT().getMVTString() + ">";
     if (LD->isVolatile())
       Op += "<V>";
     Op += LD->getIndexedModeName(LD->getAddressingMode());
@@ -177,7 +186,7 @@ std::string DOTGraphTraits<SelectionDAG*>::getNodeLabel(const SDNode *Node,
       Op += " A=" + utostr(LD->getAlignment());
   } else if (const StoreSDNode *ST = dyn_cast<StoreSDNode>(Node)) {
     if (ST->isTruncatingStore())
-      Op += "<trunc " + MVT::getValueTypeString(ST->getMemoryVT()) + ">";
+      Op += "<trunc " + ST->getMemoryVT().getMVTString() + ">";
     if (ST->isVolatile())
       Op += "<V>";
     Op += ST->getIndexedModeName(ST->getAddressingMode());
@@ -280,6 +289,8 @@ namespace llvm {
     /// edge, override this method.
     template<typename EdgeIter>
     static std::string getEdgeAttributes(const void *Node, EdgeIter EI) {
+      if (EI.isSpecialDep())
+        return "color=cyan,style=dashed";
       if (EI.isCtrlDep())
         return "color=blue,style=dashed";
       return "";
@@ -296,8 +307,9 @@ namespace llvm {
     static void addCustomGraphFeatures(ScheduleDAG *G,
                                        GraphWriter<ScheduleDAG*> &GW) {
       GW.emitSimpleNode(0, "plaintext=circle", "GraphRoot");
-      if (G->DAG.getRoot().Val)
-        GW.emitEdge(0, -1, G->SUnitMap[G->DAG.getRoot().Val].front(), -1, "");
+      const SDNode *N = G->DAG.getRoot().Val;
+      if (N && N->getNodeId() != -1)
+        GW.emitEdge(0, -1, &G->SUnits[N->getNodeId()], -1, "");
     }
   };
 }
@@ -311,7 +323,10 @@ std::string DOTGraphTraits<ScheduleDAG*>::getNodeLabel(const SUnit *SU,
                                                       &G->DAG) + "\n";
   }
 
-  Op += DOTGraphTraits<SelectionDAG*>::getNodeLabel(SU->Node, &G->DAG);
+  if (SU->Node)
+    Op += DOTGraphTraits<SelectionDAG*>::getNodeLabel(SU->Node, &G->DAG);
+  else
+    Op += "<CROSS RC COPY>";
 
   return Op;
 }