Create a new #include "Support/..." directory structure to move things
from "llvm/Support/..." that are not llvm dependant.

Move files and fix #includes


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1400 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp b/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp
index 0ba218d..528e5ab 100644
--- a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp
+++ b/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp
@@ -13,15 +13,11 @@
 //************************* User Include Files *****************************/
 
 #include "llvm/CodeGen/InstrScheduling.h"
-#include "SchedPriorities.h"
 #include "llvm/Analysis/LiveVar/BBLiveVar.h"
 #include "llvm/CodeGen/MachineInstr.h"
-#include "llvm/Support/CommandLine.h"
 #include "llvm/Instruction.h"
-
-
-//************************ System Include Files *****************************/
-
+#include "Support/CommandLine.h"
+#include "SchedPriorities.h"
 #include <hash_set>
 #include <algorithm>
 #include <iterator>
diff --git a/lib/Target/SparcV9/InstrSched/SchedGraph.cpp b/lib/Target/SparcV9/InstrSched/SchedGraph.cpp
index 9d3651a..9e9af5b 100644
--- a/lib/Target/SparcV9/InstrSched/SchedGraph.cpp
+++ b/lib/Target/SparcV9/InstrSched/SchedGraph.cpp
@@ -21,8 +21,8 @@
 #include "llvm/CodeGen/InstrSelection.h"
 #include "llvm/Target/MachineInstrInfo.h"
 #include "llvm/Target/MachineRegInfo.h"
-#include "llvm/Support/StringExtras.h"
 #include "llvm/iOther.h"
+#include "Support/StringExtras.h"
 #include <algorithm>
 #include <hash_map>
 #include <vector>
@@ -132,7 +132,7 @@
 }
 
 void SchedGraphEdge::dump(int indent=0) const {
-  printIndent(indent); cout << *this; 
+  cout << string(indent*2, ' ') << *this; 
 }
 
 
@@ -168,7 +168,7 @@
 }
 
 void SchedGraphNode::dump(int indent=0) const {
-  printIndent(indent); cout << *this; 
+  cout << string(indent*2, ' ') << *this; 
 }
 
 
@@ -1023,32 +1023,24 @@
 ostream&
 operator<<(ostream& os, const SchedGraphNode& node)
 {
-  printIndent(4, os);
-  os << "Node " << node.nodeId << " : "
-     << "latency = " << node.latency << endl;
-  
-  printIndent(6, os);
+  os << string(8, ' ')
+     << "Node " << node.nodeId << " : "
+     << "latency = " << node.latency << endl << string(12, ' ');
   
   if (node.getMachineInstr() == NULL)
     os << "(Dummy node)" << endl;
   else
     {
-      os << *node.getMachineInstr() << endl;
-  
-      printIndent(6, os);
+      os << *node.getMachineInstr() << endl << string(12, ' ');
       os << node.inEdges.size() << " Incoming Edges:" << endl;
       for (unsigned i=0, N=node.inEdges.size(); i < N; i++)
-	{
-	  printIndent(8, os);
-	  os << * node.inEdges[i];
-	}
+	  os << string(16, ' ') << *node.inEdges[i];
   
-      printIndent(6, os);
-      os << node.outEdges.size() << " Outgoing Edges:" << endl;
+      os << string(12, ' ') << node.outEdges.size()
+         << " Outgoing Edges:" << endl;
       for (unsigned i=0, N=node.outEdges.size(); i < N; i++)
 	{
-	  printIndent(8, os);
-	  os << * node.outEdges[i];
+	  os << string(16, ' ') << * node.outEdges[i];
 	}
     }
   
diff --git a/lib/Target/SparcV9/InstrSched/SchedGraph.h b/lib/Target/SparcV9/InstrSched/SchedGraph.h
index 44d59a1..a4567a5 100644
--- a/lib/Target/SparcV9/InstrSched/SchedGraph.h
+++ b/lib/Target/SparcV9/InstrSched/SchedGraph.h
@@ -19,11 +19,11 @@
 #ifndef LLVM_CODEGEN_SCHEDGRAPH_H
 #define LLVM_CODEGEN_SCHEDGRAPH_H
 
-#include "llvm/Support/NonCopyable.h"
-#include "llvm/Support/HashExtras.h"
-#include "llvm/Support/GraphTraits.h"
 #include "llvm/Target/MachineInstrInfo.h"
 #include "llvm/CodeGen/MachineInstr.h"
+#include "Support/NonCopyable.h"
+#include "Support/HashExtras.h"
+#include "Support/GraphTraits.h"
 #include <hash_map>
 
 class Value;
diff --git a/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp b/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp
index 31d9f6c..acbe552 100644
--- a/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp
+++ b/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp
@@ -19,7 +19,7 @@
 //**************************************************************************/
 
 #include "SchedPriorities.h"
-#include "llvm/Support/PostOrderIterator.h"
+#include "Support/PostOrderIterator.h"
 
 
 SchedPriorities::SchedPriorities(const Method* method,
diff --git a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp
index f928683..c6d5367 100644
--- a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp
+++ b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp
@@ -30,7 +30,7 @@
 #include "llvm/ConstPoolVals.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/CodeGen/MachineInstr.h"
-#include "llvm/Support/STLExtras.h"
+#include "Support/STLExtras.h"
 
 //------------------------------------------------------------------------ 
 // class InstrTreeNode
diff --git a/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp b/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp
index f27ad71..ce26a1d 100644
--- a/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp
+++ b/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp
@@ -17,12 +17,12 @@
 #include "llvm/CodeGen/InstrSelection.h"
 #include "llvm/CodeGen/InstrSelectionSupport.h"
 #include "llvm/CodeGen/MachineInstr.h"
-#include "llvm/Support/CommandLine.h"
 #include "llvm/Instruction.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/Method.h"
 #include "llvm/iOther.h"
 #include "llvm/Target/MachineRegInfo.h"
+#include "Support/CommandLine.h"
 #include <string.h>
 
 
diff --git a/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp b/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp
index 32201be..e981a86 100644
--- a/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp
+++ b/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp
@@ -11,7 +11,7 @@
 
 #include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h"
 #include "llvm/CodeGen/MachineInstr.h"
-#include "llvm/Support/PostOrderIterator.h"
+#include "Support/PostOrderIterator.h"
 
 
 /************************** Constructor/Destructor ***************************/
diff --git a/lib/Target/SparcV9/RegAlloc/RegAllocCommon.h b/lib/Target/SparcV9/RegAlloc/RegAllocCommon.h
index 5fa51c0..02b3331 100644
--- a/lib/Target/SparcV9/RegAlloc/RegAllocCommon.h
+++ b/lib/Target/SparcV9/RegAlloc/RegAllocCommon.h
@@ -1,5 +1,5 @@
 
-#include "llvm/Support/CommandLine.h"
+#include "Support/CommandLine.h"
 
 #ifndef REG_ALLOC_COMMON_H
 #define  REG_ALLOC_COMMON_H
diff --git a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp
index 618fb6d..3edeb96 100644
--- a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp
+++ b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp
@@ -19,8 +19,8 @@
 #include "llvm/BasicBlock.h"
 #include "llvm/Method.h"
 #include "llvm/Module.h"
-#include "llvm/Support/HashExtras.h"
-#include "llvm/Support/StringExtras.h"
+#include "Support/StringExtras.h"
+#include "Support/HashExtras.h"
 #include <locale.h>
 
 namespace {
@@ -161,6 +161,69 @@
   }
 };
 
+
+// Can we treat the specified array as a string?  Only if it is an array of
+// ubytes or non-negative sbytes.
+//
+static bool isStringCompatible(ConstPoolArray *CPA) {
+  const Type *ETy = cast<ArrayType>(CPA->getType())->getElementType();
+  if (ETy == Type::UByteTy) return true;
+  if (ETy != Type::SByteTy) return false;
+
+  for (unsigned i = 0; i < CPA->getNumOperands(); ++i)
+    if (cast<ConstPoolSInt>(CPA->getOperand(i))->getValue() < 0)
+      return false;
+
+  return true;
+}
+
+// toOctal - Convert the low order bits of X into an octal letter
+static inline char toOctal(int X) {
+  return (X&7)+'0';
+}
+
+// getAsCString - Return the specified array as a C compatible string, only if
+// the predicate isStringCompatible is true.
+//
+static string getAsCString(ConstPoolArray *CPA) {
+  if (isStringCompatible(CPA)) {
+    string Result;
+    const Type *ETy = cast<ArrayType>(CPA->getType())->getElementType();
+    Result = "\"";
+    for (unsigned i = 0; i < CPA->getNumOperands(); ++i) {
+      unsigned char C = (ETy == Type::SByteTy) ?
+        (unsigned char)cast<ConstPoolSInt>(CPA->getOperand(i))->getValue() :
+        (unsigned char)cast<ConstPoolUInt>(CPA->getOperand(i))->getValue();
+
+      if (isprint(C)) {
+        Result += C;
+      } else {
+        switch(C) {
+        case '\a': Result += "\\a"; break;
+        case '\b': Result += "\\b"; break;
+        case '\f': Result += "\\f"; break;
+        case '\n': Result += "\\n"; break;
+        case '\r': Result += "\\r"; break;
+        case '\t': Result += "\\t"; break;
+        case '\v': Result += "\\v"; break;
+        default:
+          Result += '\\';
+          Result += toOctal(C >> 6);
+          Result += toOctal(C >> 3);
+          Result += toOctal(C >> 0);
+          break;
+        }
+      }
+    }
+    Result += "\"";
+
+    return Result;
+  } else {
+    return CPA->getStrValue();
+  }
+}
+
+
 inline bool
 SparcAsmPrinter::OpIsBranchTargetLabel(const MachineInstr *MI,
                                        unsigned int opNum) {
diff --git a/lib/Target/SparcV9/SparcV9InstrSelection.cpp b/lib/Target/SparcV9/SparcV9InstrSelection.cpp
index c1b8aa3..631d609 100644
--- a/lib/Target/SparcV9/SparcV9InstrSelection.cpp
+++ b/lib/Target/SparcV9/SparcV9InstrSelection.cpp
@@ -16,7 +16,6 @@
 #include "llvm/CodeGen/MachineInstr.h"
 #include "llvm/CodeGen/InstrForest.h"
 #include "llvm/CodeGen/InstrSelection.h"
-#include "llvm/Support/MathExtras.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/iTerminators.h"
 #include "llvm/iMemory.h"
@@ -24,10 +23,9 @@
 #include "llvm/BasicBlock.h"
 #include "llvm/Method.h"
 #include "llvm/ConstPoolVals.h"
+#include "Support/MathExtras.h"
 #include <math.h>
 
-//******************** Internal Data Declarations ************************/
-
 
 //************************* Forward Declarations ***************************/