Resolve a terrible hack in tblgen: instead of hardcoding
[oota-llvm.git] / include / llvm / Analysis / CFGPrinter.h
index 47b1a5c31c9d6a83ec0b5bfc6de40c84e4139645..ac8f59602daba603eaa77e5ea48aea80c1e5b09d 100644 (file)
@@ -1,4 +1,4 @@
-//===-- CFGPrinter.h - CFG printer external interface ------------*- C++ -*-===//
+//===-- CFGPrinter.h - CFG printer external interface -----------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -31,19 +31,22 @@ struct DOTGraphTraits<const Function*> : public DefaultDOTGraphTraits {
     return "CFG for '" + F->getNameStr() + "' function";
   }
 
-  static std::string getNodeLabel(const BasicBlock *Node,
-                                  const Function *Graph,
-                                  bool ShortNames) {
-    if (ShortNames && !Node->getName().empty())
+  static std::string getSimpleNodeLabel(const BasicBlock *Node,
+                                  const Function *Graph) {
+    if (!Node->getName().empty())
       return Node->getNameStr(); 
 
     std::string Str;
     raw_string_ostream OS(Str);
 
-    if (ShortNames) {
-      WriteAsOperand(OS, Node, false);
-      return OS.str();
-    }
+    WriteAsOperand(OS, Node, false);
+    return OS.str();
+  }
+
+  static std::string getCompleteNodeLabel(const BasicBlock *Node, 
+                                          const Function *Graph) {
+    std::string Str;
+    raw_string_ostream OS(Str);
 
     if (Node->getName().empty()) {
       WriteAsOperand(OS, Node, false);
@@ -68,6 +71,14 @@ struct DOTGraphTraits<const Function*> : public DefaultDOTGraphTraits {
     return OutStr;
   }
 
+  std::string getNodeLabel(const BasicBlock *Node,
+                           const Function *Graph) {
+    if (isSimple())
+      return getSimpleNodeLabel(Node, Graph);
+    else
+      return getCompleteNodeLabel(Node, Graph);
+  }
+
   static std::string getEdgeSourceLabel(const BasicBlock *Node,
                                         succ_const_iterator I) {
     // Label source of conditional branches with "T" or "F"