Replace std::iostreams with raw_ostream in TableGen.
authorDaniel Dunbar <daniel@zuster.org>
Fri, 3 Jul 2009 00:10:29 +0000 (00:10 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Fri, 3 Jul 2009 00:10:29 +0000 (00:10 +0000)
 - Sorry, I can't help myself.

 - No intended functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74742 91177308-0d34-0410-b5e6-96231b3b80d8

36 files changed:
utils/TableGen/AsmWriterEmitter.cpp
utils/TableGen/AsmWriterEmitter.h
utils/TableGen/CallingConvEmitter.cpp
utils/TableGen/CallingConvEmitter.h
utils/TableGen/ClangDiagnosticsEmitter.cpp
utils/TableGen/ClangDiagnosticsEmitter.h
utils/TableGen/CodeEmitterGen.cpp
utils/TableGen/CodeEmitterGen.h
utils/TableGen/CodeGenDAGPatterns.cpp
utils/TableGen/CodeGenDAGPatterns.h
utils/TableGen/CodeGenTarget.cpp
utils/TableGen/CodeGenTarget.h
utils/TableGen/DAGISelEmitter.cpp
utils/TableGen/DAGISelEmitter.h
utils/TableGen/FastISelEmitter.cpp
utils/TableGen/FastISelEmitter.h
utils/TableGen/InstrEnumEmitter.cpp
utils/TableGen/InstrEnumEmitter.h
utils/TableGen/InstrInfoEmitter.cpp
utils/TableGen/InstrInfoEmitter.h
utils/TableGen/IntrinsicEmitter.cpp
utils/TableGen/IntrinsicEmitter.h
utils/TableGen/LLVMCConfigurationEmitter.cpp
utils/TableGen/LLVMCConfigurationEmitter.h
utils/TableGen/Record.cpp
utils/TableGen/Record.h
utils/TableGen/RegisterInfoEmitter.cpp
utils/TableGen/RegisterInfoEmitter.h
utils/TableGen/SubtargetEmitter.cpp
utils/TableGen/SubtargetEmitter.h
utils/TableGen/TGLexer.cpp
utils/TableGen/TGParser.cpp
utils/TableGen/TGValueTypes.cpp
utils/TableGen/TableGen.cpp
utils/TableGen/TableGenBackend.cpp
utils/TableGen/TableGenBackend.h

index 183c6912bae9a10f37e4aa226572ca003e8f70fd..f34feef0c28d64df01f2abf77c1625570f29e0c3 100644 (file)
@@ -19,6 +19,7 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/MathExtras.h"
 #include <algorithm>
+#include <iostream>
 using namespace llvm;
 
 static bool isIdentChar(char C) {
@@ -282,7 +283,7 @@ unsigned AsmWriterInst::MatchesAllButOneOp(const AsmWriterInst &Other)const{
 }
 
 static void PrintCases(std::vector<std::pair<std::string,
-                       AsmWriterOperand> > &OpsToPrint, std::ostream &O) {
+                       AsmWriterOperand> > &OpsToPrint, raw_ostream &O) {
   O << "    case " << OpsToPrint.back().first << ": ";
   AsmWriterOperand TheOp = OpsToPrint.back().second;
   OpsToPrint.pop_back();
@@ -304,7 +305,7 @@ static void PrintCases(std::vector<std::pair<std::string,
 /// EmitInstructions - Emit the last instruction in the vector and any other
 /// instructions that are suitably similar to it.
 static void EmitInstructions(std::vector<AsmWriterInst> &Insts,
-                             std::ostream &O) {
+                             raw_ostream &O) {
   AsmWriterInst FirstInst = Insts.back();
   Insts.pop_back();
 
@@ -475,7 +476,7 @@ FindUniqueOperandCommands(std::vector<std::string> &UniqueOperandCommands,
 
 
 
-void AsmWriterEmitter::run(std::ostream &O) {
+void AsmWriterEmitter::run(raw_ostream &O) {
   EmitSourceFileHeader("Assembly Writer Source Fragment", O);
 
   CodeGenTarget Target;
index 302722d6df06fbd0ec763374a16a2b6dcfc6d6b9..75e69964ef89eeb10533f28cf6b745968d5e869b 100644 (file)
@@ -32,7 +32,7 @@ namespace llvm {
     AsmWriterEmitter(RecordKeeper &R) : Records(R) {}
 
     // run - Output the asmwriter, returning true on failure.
-    void run(std::ostream &o);
+    void run(raw_ostream &o);
 
 private:
     AsmWriterInst *getAsmWriterInstByID(unsigned ID) const {
index c1f87014335f733534b792aa09195bfeca307b12..a14be0b76fd68e7063e3e488b0a6f1eba52f42c9 100644 (file)
@@ -17,7 +17,7 @@
 #include "CodeGenTarget.h"
 using namespace llvm;
 
-void CallingConvEmitter::run(std::ostream &O) {
+void CallingConvEmitter::run(raw_ostream &O) {
   EmitSourceFileHeader("Calling Convention Implementation Fragment", O);
 
   std::vector<Record*> CCs = Records.getAllDerivedDefinitions("CallingConv");
@@ -39,7 +39,7 @@ void CallingConvEmitter::run(std::ostream &O) {
 }
 
 
-void CallingConvEmitter::EmitCallingConv(Record *CC, std::ostream &O) {
+void CallingConvEmitter::EmitCallingConv(Record *CC, raw_ostream &O) {
   ListInit *CCActions = CC->getValueAsListInit("Actions");
   Counter = 0;
 
@@ -60,7 +60,7 @@ void CallingConvEmitter::EmitCallingConv(Record *CC, std::ostream &O) {
 }
 
 void CallingConvEmitter::EmitAction(Record *Action,
-                                    unsigned Indent, std::ostream &O) {
+                                    unsigned Indent, raw_ostream &O) {
   std::string IndentStr = std::string(Indent, ' ');
   
   if (Action->isSubClassOf("CCPredicateAction")) {
index ffd6a48c7ad65bde8914da3232d2a4c8289955b0..7fc2507e8889da50503a6b72e5a54eaf86f39162 100644 (file)
@@ -27,11 +27,11 @@ namespace llvm {
     explicit CallingConvEmitter(RecordKeeper &R) : Records(R) {}
 
     // run - Output the asmwriter, returning true on failure.
-    void run(std::ostream &o);
+    void run(raw_ostream &o);
     
   private:
-    void EmitCallingConv(Record *CC, std::ostream &O);
-    void EmitAction(Record *Action, unsigned Indent, std::ostream &O);
+    void EmitCallingConv(Record *CC, raw_ostream &O);
+    void EmitAction(Record *Action, unsigned Indent, raw_ostream &O);
     unsigned Counter;
   };
 }
index a4a56983ca9fbbe8c957df07fdf3faff2b6649ac..c127afd77050ede5cd10275cdbcc3fe00a6f76a2 100644 (file)
@@ -15,7 +15,6 @@
 #include "Record.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Compiler.h"
-#include "llvm/Support/Streams.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/VectorExtras.h"
@@ -27,7 +26,7 @@ using namespace llvm;
 // Warning Tables (.inc file) generation.
 //===----------------------------------------------------------------------===//
 
-void ClangDiagsDefsEmitter::run(std::ostream &OS) {
+void ClangDiagsDefsEmitter::run(raw_ostream &OS) {
   // Write the #if guard
   if (!Component.empty()) {
     std::string ComponentName = UppercaseString(Component);
@@ -85,7 +84,7 @@ struct GroupInfo {
   unsigned IDNo;
 };
 
-void ClangDiagGroupsEmitter::run(std::ostream &OS) {
+void ClangDiagGroupsEmitter::run(raw_ostream &OS) {
   // Invert the 1-[0/1] mapping of diags to group into a one to many mapping of
   // groups to diags in the group.
   std::map<std::string, GroupInfo> DiagsInGroup;
index 58ea524d96477d854471a2f31b94fa16ea19e72e..edd062a73835b709c69060a8768be414cb585197 100644 (file)
@@ -29,7 +29,7 @@ public:
     : Records(R), Component(component) {}
 
   // run - Output the .def file contents
-  void run(std::ostream &OS);
+  void run(raw_ostream &OS);
 };
 
 class ClangDiagGroupsEmitter : public TableGenBackend {
@@ -37,7 +37,7 @@ class ClangDiagGroupsEmitter : public TableGenBackend {
 public:
   explicit ClangDiagGroupsEmitter(RecordKeeper &R) : Records(R) {}
     
-  void run(std::ostream &OS);
+  void run(raw_ostream &OS);
 };
 
   
index 7b0a335b26be1f9f5d84849690e37fb6c1fc88b4..646602557b1fd9f850b9b0fc5df7b1811b4a8cba 100644 (file)
@@ -75,7 +75,7 @@ int CodeEmitterGen::getVariableBit(const std::string &VarName,
 } 
 
 
-void CodeEmitterGen::run(std::ostream &o) {
+void CodeEmitterGen::run(raw_ostream &o) {
   CodeGenTarget Target;
   std::vector<Record*> Insts = Records.getAllDerivedDefinitions("Instruction");
   
index cb272bd56d25e009166adc2e59be1dfa3292b7ba..f0b3229c0411a4b8da8791a7202d426e63f04922 100644 (file)
@@ -30,10 +30,10 @@ public:
   CodeEmitterGen(RecordKeeper &R) : Records(R) {}
 
   // run - Output the code emitter
-  void run(std::ostream &o);
+  void run(raw_ostream &o);
 private:
-  void emitMachineOpEmitter(std::ostream &o, const std::string &Namespace);
-  void emitGetValueBit(std::ostream &o, const std::string &Namespace);
+  void emitMachineOpEmitter(raw_ostream &o, const std::string &Namespace);
+  void emitGetValueBit(raw_ostream &o, const std::string &Namespace);
   void reverseBits(std::vector<Record*> &Insts);
   int getVariableBit(const std::string &VarName, BitsInit *BI, int bit);
 };
index 6a7d305f783b4fac6577d38795a574b9bbc89ec4..2289ae789bdf2c3c949a320f760609ad9d5c0ae4 100644 (file)
@@ -16,9 +16,9 @@
 #include "Record.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Debug.h"
-#include "llvm/Support/Streams.h"
 #include <set>
 #include <algorithm>
+#include <iostream>
 using namespace llvm;
 
 //===----------------------------------------------------------------------===//
@@ -199,7 +199,7 @@ SDTypeConstraint::SDTypeConstraint(Record *R) {
     x.SDTCisEltOfVec_Info.OtherOperandNum =
       R->getValueAsInt("OtherOpNum");
   } else {
-    cerr << "Unrecognized SDTypeConstraint '" << R->getName() << "'!\n";
+    errs() << "Unrecognized SDTypeConstraint '" << R->getName() << "'!\n";
     exit(1);
   }
 }
@@ -213,9 +213,9 @@ TreePatternNode *SDTypeConstraint::getOperandNum(unsigned OpNo,
          "We only work with nodes with zero or one result so far!");
   
   if (OpNo >= (NumResults + N->getNumChildren())) {
-    cerr << "Invalid operand number " << OpNo << " ";
+    errs() << "Invalid operand number " << OpNo << " ";
     N->dump();
-    cerr << '\n';
+    errs() << '\n';
     exit(1);
   }
 
@@ -413,8 +413,8 @@ SDNodeInfo::SDNodeInfo(Record *R) : Def(R) {
     } else if (PropList[i]->getName() == "SDNPMemOperand") {
       Properties |= 1 << SDNPMemOperand;
     } else {
-      cerr << "Unknown SD Node property '" << PropList[i]->getName()
-           << "' on node '" << R->getName() << "'!\n";
+      errs() << "Unknown SD Node property '" << PropList[i]->getName()
+             << "' on node '" << R->getName() << "'!\n";
       exit(1);
     }
   }
@@ -516,7 +516,7 @@ bool TreePatternNode::UpdateNodeType(const std::vector<unsigned char> &ExtVTs,
 
   if (isLeaf()) {
     dump();
-    cerr << " ";
+    errs() << " ";
     TP.error("Type inference contradiction found in node!");
   } else {
     TP.error("Type inference contradiction found in node " + 
@@ -526,7 +526,7 @@ bool TreePatternNode::UpdateNodeType(const std::vector<unsigned char> &ExtVTs,
 }
 
 
-void TreePatternNode::print(std::ostream &OS) const {
+void TreePatternNode::print(raw_ostream &OS) const {
   if (isLeaf()) {
     OS << *getLeafValue();
   } else {
@@ -573,7 +573,7 @@ void TreePatternNode::print(std::ostream &OS) const {
 
 }
 void TreePatternNode::dump() const {
-  print(*cerr.stream());
+  print(errs());
 }
 
 /// isIsomorphicTo - Return true if this node is recursively
@@ -1194,9 +1194,9 @@ TreePatternNode *TreePattern::ParseTreePattern(DagInit *Dag) {
         error("Constant int argument should not have a name!");
       Children.push_back(Node);
     } else {
-      cerr << '"';
+      errs() << '"';
       Arg->dump();
-      cerr << "\": ";
+      errs() << "\": ";
       error("Unknown leaf value for tree pattern!");
     }
   }
@@ -1246,7 +1246,7 @@ bool TreePattern::InferAllTypes() {
   return !HasUnresolvedTypes;
 }
 
-void TreePattern::print(std::ostream &OS) const {
+void TreePattern::print(raw_ostream &OS) const {
   OS << getRecord()->getName();
   if (!Args.empty()) {
     OS << "(" << Args[0];
@@ -1268,7 +1268,7 @@ void TreePattern::print(std::ostream &OS) const {
     OS << "]\n";
 }
 
-void TreePattern::dump() const { print(*cerr.stream()); }
+void TreePattern::dump() const { print(errs()); }
 
 //===----------------------------------------------------------------------===//
 // CodeGenDAGPatterns implementation
@@ -1306,7 +1306,7 @@ CodeGenDAGPatterns::~CodeGenDAGPatterns() {
 Record *CodeGenDAGPatterns::getSDNodeNamed(const std::string &Name) const {
   Record *N = Records.getDef(Name);
   if (!N || !N->isSubClassOf("SDNode")) {
-    cerr << "Error getting SDNode '" << Name << "'!\n";
+    errs() << "Error getting SDNode '" << Name << "'!\n";
     exit(1);
   }
   return N;
@@ -2012,15 +2012,15 @@ void CodeGenDAGPatterns::ParsePatterns() {
         Values.push_back(Tree->getArg(j));
         TypedInit *TArg = dynamic_cast<TypedInit*>(Tree->getArg(j));
         if (TArg == 0) {
-          cerr << "In dag: " << Tree->getAsString();
-          cerr << " --  Untyped argument in pattern\n";
+          errs() << "In dag: " << Tree->getAsString();
+          errs() << " --  Untyped argument in pattern\n";
           assert(0 && "Untyped argument in pattern");
         }
         if (ListTy != 0) {
           ListTy = resolveTypes(ListTy, TArg->getType());
           if (ListTy == 0) {
-            cerr << "In dag: " << Tree->getAsString();
-            cerr << " --  Incompatible types in pattern arguments\n";
+            errs() << "In dag: " << Tree->getAsString();
+            errs() << " --  Incompatible types in pattern arguments\n";
             assert(0 && "Incompatible types in pattern arguments");
           }
         }
@@ -2138,11 +2138,11 @@ static void CombineChildVariants(TreePatternNode *Orig,
   do {
 #ifndef NDEBUG
     if (DebugFlag && !Idxs.empty()) {
-      cerr << Orig->getOperator()->getName() << ": Idxs = [ ";
+      errs() << Orig->getOperator()->getName() << ": Idxs = [ ";
         for (unsigned i = 0; i < Idxs.size(); ++i) {
-          cerr << Idxs[i] << " ";
+          errs() << Idxs[i] << " ";
       }
-      cerr << "]\n";
+      errs() << "]\n";
     }
 #endif
     // Create the variant and add it to the output list.
index 9ce14dcc7b360501b7d25e29d2dcf22b0b984f3a..d3980068124a129f5c9904245c0f10f2f988841e 100644 (file)
@@ -236,7 +236,7 @@ public:
   /// marked isCommutative.
   bool isCommutativeIntrinsic(const CodeGenDAGPatterns &CDP) const;
   
-  void print(std::ostream &OS) const;
+  void print(raw_ostream &OS) const;
   void dump() const;
   
 public:   // Higher level manipulation routines.
@@ -370,7 +370,7 @@ public:
   /// pattern.
   void error(const std::string &Msg) const;
   
-  void print(std::ostream &OS) const;
+  void print(raw_ostream &OS) const;
   void dump() const;
   
 private:
index e280a49bd3b899313419a2cb8ed8806387f6a00f..c17cd0eef2daaba4e0f04a0e6b7dd7556472c529 100644 (file)
@@ -19,7 +19,6 @@
 #include "Record.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/CommandLine.h"
-#include "llvm/Support/Streams.h"
 #include <algorithm>
 using namespace llvm;
 
@@ -423,8 +422,8 @@ ComplexPattern::ComplexPattern(Record *R) {
     } else if (PropList[i]->getName() == "SDNPMemOperand") {
       Properties |= 1 << SDNPMemOperand;
     } else {
-      cerr << "Unsupported SD Node property '" << PropList[i]->getName()
-           << "' on ComplexPattern '" << R->getName() << "'!\n";
+      errs() << "Unsupported SD Node property '" << PropList[i]->getName()
+             << "' on ComplexPattern '" << R->getName() << "'!\n";
       exit(1);
     }
   
@@ -435,8 +434,8 @@ ComplexPattern::ComplexPattern(Record *R) {
     if (PropList[i]->getName() == "CPAttrParentAsRoot") {
       Attributes |= 1 << CPAttrParentAsRoot;
     } else {
-      cerr << "Unsupported pattern attribute '" << PropList[i]->getName()
-           << "' on ComplexPattern '" << R->getName() << "'!\n";
+      errs() << "Unsupported pattern attribute '" << PropList[i]->getName()
+             << "' on ComplexPattern '" << R->getName() << "'!\n";
       exit(1);
     }
 }
index c7cc77ccd41aa093c5472863992f91d51e23c665..0ec9955814603dc8dd632cc3fdb564ab632fa94d 100644 (file)
 #ifndef CODEGEN_TARGET_H
 #define CODEGEN_TARGET_H
 
+#include "llvm/Support/raw_ostream.h"
 #include "CodeGenRegisters.h"
 #include "CodeGenInstruction.h"
 #include <algorithm>
-#include <iosfwd>
 #include <map>
 
 namespace llvm {
index 0e2e61596f69cd1597b61649826d285fe0322c26..bb26a1db3fc2dcec57bb2649a66329cf557e9b71 100644 (file)
@@ -18,9 +18,9 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/Debug.h"
-#include "llvm/Support/Streams.h"
 #include <algorithm>
 #include <deque>
+#include <iostream>
 using namespace llvm;
 
 namespace {
@@ -269,7 +269,7 @@ bool DisablePatternForFastISel(TreePatternNode *N, CodeGenDAGPatterns &CGP) {
 //===----------------------------------------------------------------------===//
 // Node Transformation emitter implementation.
 //
-void DAGISelEmitter::EmitNodeTransforms(std::ostream &OS) {
+void DAGISelEmitter::EmitNodeTransforms(raw_ostream &OS) {
   // Walk the pattern fragments, adding them to a map, which sorts them by
   // name.
   typedef std::map<std::string, CodeGenDAGPatterns::NodeXForm> NXsByNameTy;
@@ -303,7 +303,7 @@ void DAGISelEmitter::EmitNodeTransforms(std::ostream &OS) {
 // Predicate emitter implementation.
 //
 
-void DAGISelEmitter::EmitPredicateFunctions(std::ostream &OS) {
+void DAGISelEmitter::EmitPredicateFunctions(raw_ostream &OS) {
   OS << "\n// Predicate functions.\n";
 
   // Walk the pattern fragments, adding them to a map, which sorts them by
@@ -751,7 +751,7 @@ public:
         } else {
 #ifndef NDEBUG
           Child->dump();
-          cerr << " ";
+          errs() << " ";
 #endif
           assert(0 && "Unknown leaf type!");
         }
@@ -795,7 +795,7 @@ public:
       std::string Val = VariableMap[VarName];
       bool ModifiedVal = false;
       if (Val.empty()) {
-        cerr << "Variable '" << VarName << " referenced but not defined "
+        errs() << "Variable '" << VarName << " referenced but not defined "
              << "and not caught earlier!\n";
         abort();
       }
@@ -813,7 +813,7 @@ public:
         std::string TmpVar =  "Tmp" + utostr(ResNo);
         switch (N->getTypeNum(0)) {
         default:
-          cerr << "Cannot handle " << getEnumName(N->getTypeNum(0))
+          errs() << "Cannot handle " << getEnumName(N->getTypeNum(0))
                << " type as an immediate constant. Aborting\n";
           abort();
         case MVT::i1:  CastType = "bool"; break;
@@ -1351,7 +1351,7 @@ public:
     }
 
     N->dump();
-    cerr << "\n";
+    errs() << "\n";
     throw std::string("Unknown node in result pattern!");
   }
 
@@ -1537,7 +1537,7 @@ static bool EraseCodeLine(std::vector<std::pair<const PatternToMatch*,
 void DAGISelEmitter::EmitPatterns(std::vector<std::pair<const PatternToMatch*, 
                               std::vector<std::pair<unsigned, std::string> > > >
                                   &Patterns, unsigned Indent,
-                                  std::ostream &OS) {
+                                  raw_ostream &OS) {
   typedef std::pair<unsigned, std::string> CodeLine;
   typedef std::vector<CodeLine> CodeList;
   typedef std::vector<std::pair<const PatternToMatch*, CodeList> > PatternList;
@@ -1652,7 +1652,7 @@ static std::string getLegalCName(std::string OpName) {
   return OpName;
 }
 
-void DAGISelEmitter::EmitInstructionSelector(std::ostream &OS) {
+void DAGISelEmitter::EmitInstructionSelector(raw_ostream &OS) {
   const CodeGenTarget &Target = CGP.getTargetInfo();
   
   // Get the namespace to insert instructions into.
@@ -1684,10 +1684,10 @@ void DAGISelEmitter::EmitInstructionSelector(std::ostream &OS) {
                     &Pattern);
         }
       } else {
-        cerr << "Unrecognized opcode '";
+        errs() << "Unrecognized opcode '";
         Node->dump();
-        cerr << "' on tree pattern '";
-        cerr << Pattern.getDstPattern()->getOperator()->getName() << "'!\n";
+        errs() << "' on tree pattern '";
+        errs() << Pattern.getDstPattern()->getOperator()->getName() << "'!\n";
         exit(1);
       }
     }
@@ -1884,9 +1884,9 @@ void DAGISelEmitter::EmitInstructionSelector(std::ostream &OS) {
         // If this pattern definitely matches, and if it isn't the last one, the
         // patterns after it CANNOT ever match.  Error out.
         if (mightNotMatch == false && i != CodeForPatterns.size()-1) {
-          cerr << "Pattern '";
-          CodeForPatterns[i].first->getSrcPattern()->print(*cerr.stream());
-          cerr << "' is impossible to select!\n";
+          errs() << "Pattern '";
+          CodeForPatterns[i].first->getSrcPattern()->print(errs());
+          errs() << "' is impossible to select!\n";
           exit(1);
         }
       }
@@ -2100,7 +2100,7 @@ void DAGISelEmitter::EmitInstructionSelector(std::ostream &OS) {
      << "}\n\n";
 }
 
-void DAGISelEmitter::run(std::ostream &OS) {
+void DAGISelEmitter::run(raw_ostream &OS) {
   EmitSourceFileHeader("DAG Instruction Selector for the " +
                        CGP.getTargetInfo().getName() + " target", OS);
   
index 1b9f8bad88cd5b38f44010520ddd1f33cc2cb40a..d5b889b0551019d33ff7205da012cbc2c6f0efd7 100644 (file)
@@ -30,12 +30,12 @@ public:
   explicit DAGISelEmitter(RecordKeeper &R) : Records(R), CGP(R) {}
 
   // run - Output the isel, returning true on failure.
-  void run(std::ostream &OS);
+  void run(raw_ostream &OS);
   
   
 private:
-  void EmitNodeTransforms(std::ostream &OS);
-  void EmitPredicateFunctions(std::ostream &OS);
+  void EmitNodeTransforms(raw_ostream &OS);
+  void EmitPredicateFunctions(raw_ostream &OS);
   
   void GenerateCodeForPattern(const PatternToMatch &Pattern,
                   std::vector<std::pair<unsigned, std::string> > &GeneratedCode,
@@ -46,9 +46,9 @@ private:
                               unsigned &NumInputRootOps);
   void EmitPatterns(std::vector<std::pair<const PatternToMatch*, 
                   std::vector<std::pair<unsigned, std::string> > > > &Patterns, 
-                    unsigned Indent, std::ostream &OS);
+                    unsigned Indent, raw_ostream &OS);
   
-  void EmitInstructionSelector(std::ostream &OS);
+  void EmitInstructionSelector(raw_ostream &OS);
 };
 
 } // End llvm namespace
index 8c60b088627e3a371cb99992a30afee00566f8dd..0a43f02d5afc31840029cc481d9b134a974b03b9 100644 (file)
@@ -20,7 +20,6 @@
 #include "FastISelEmitter.h"
 #include "Record.h"
 #include "llvm/Support/Debug.h"
-#include "llvm/Support/Streams.h"
 #include "llvm/ADT/VectorExtras.h"
 using namespace llvm;
 
@@ -119,7 +118,7 @@ struct OperandsSignature {
     return true;
   }
 
-  void PrintParameters(std::ostream &OS) const {
+  void PrintParameters(raw_ostream &OS) const {
     for (unsigned i = 0, e = Operands.size(); i != e; ++i) {
       if (Operands[i] == "r") {
         OS << "unsigned Op" << i;
@@ -136,7 +135,7 @@ struct OperandsSignature {
     }
   }
 
-  void PrintArguments(std::ostream &OS,
+  void PrintArguments(raw_ostream &OS,
                       const std::vector<std::string>& PR) const {
     assert(PR.size() == Operands.size());
     bool PrintedArg = false;
@@ -163,7 +162,7 @@ struct OperandsSignature {
     }
   }
 
-  void PrintArguments(std::ostream &OS) const {
+  void PrintArguments(raw_ostream &OS) const {
     for (unsigned i = 0, e = Operands.size(); i != e; ++i) {
       if (Operands[i] == "r") {
         OS << "Op" << i;
@@ -181,7 +180,7 @@ struct OperandsSignature {
   }
 
 
-  void PrintManglingSuffix(std::ostream &OS,
+  void PrintManglingSuffix(raw_ostream &OS,
                            const std::vector<std::string>& PR) const {
     for (unsigned i = 0, e = Operands.size(); i != e; ++i) {
       if (PR[i] != "")
@@ -195,7 +194,7 @@ struct OperandsSignature {
     }
   }
 
-  void PrintManglingSuffix(std::ostream &OS) const {
+  void PrintManglingSuffix(raw_ostream &OS) const {
     for (unsigned i = 0, e = Operands.size(); i != e; ++i) {
       OS << Operands[i];
     }
@@ -217,8 +216,8 @@ public:
   explicit FastISelMap(std::string InstNS);
 
   void CollectPatterns(CodeGenDAGPatterns &CGP);
-  void PrintClass(std::ostream &OS);
-  void PrintFunctionDefinitions(std::ostream &OS);
+  void PrintClass(raw_ostream &OS);
+  void PrintFunctionDefinitions(raw_ostream &OS);
 };
 
 }
@@ -368,7 +367,7 @@ void FastISelMap::CollectPatterns(CodeGenDAGPatterns &CGP) {
   }
 }
 
-void FastISelMap::PrintFunctionDefinitions(std::ostream &OS) {
+void FastISelMap::PrintFunctionDefinitions(raw_ostream &OS) {
   // Now emit code for all the patterns that we collected.
   for (OperandsOpcodeTypeRetPredMap::const_iterator OI = SimplePatterns.begin(),
        OE = SimplePatterns.end(); OI != OE; ++OI) {
@@ -614,7 +613,7 @@ void FastISelMap::PrintFunctionDefinitions(std::ostream &OS) {
   }
 }
 
-void FastISelEmitter::run(std::ostream &OS) {
+void FastISelEmitter::run(raw_ostream &OS) {
   const CodeGenTarget &Target = CGP.getTargetInfo();
 
   // Determine the target's namespace name.
index 4743ca9bfa01ea842376bfd2d1be1d666454ad3a..ce4e77e6f8f240ef001967beb7e63f1ce8178fc0 100644 (file)
@@ -31,7 +31,7 @@ public:
   explicit FastISelEmitter(RecordKeeper &R);
 
   // run - Output the isel, returning true on failure.
-  void run(std::ostream &OS);
+  void run(raw_ostream &OS);
 };
 
 } // End llvm namespace
index 4b4791b61458004e829d30e926c7a07e3b48997f..f382d34f3486866d7fdfde2606578cc6f381d357 100644 (file)
@@ -19,7 +19,7 @@
 using namespace llvm;
 
 // runEnums - Print out enum values for all of the instructions.
-void InstrEnumEmitter::run(std::ostream &OS) {
+void InstrEnumEmitter::run(raw_ostream &OS) {
   EmitSourceFileHeader("Target Instruction Enum Values", OS);
   OS << "namespace llvm {\n\n";
 
index b39fef2d433c9e4db86809fc6e13b5206033924d..89f8b659d702ff712c2c36e9ac66b15bf258f3d9 100644 (file)
@@ -25,7 +25,7 @@ public:
   InstrEnumEmitter(RecordKeeper &R) : Records(R) {}
 
   // run - Output the instruction set description, returning true on failure.
-  void run(std::ostream &OS);
+  void run(raw_ostream &OS);
 };
 
 } // End llvm namespace
index 61dbe64af8f39b904973fece9e5213be0361a2ac..4502da176f4fca7f9eafc316bcba334e32a19d79 100644 (file)
 #include "CodeGenTarget.h"
 #include "Record.h"
 #include <algorithm>
-#include <iostream>
 using namespace llvm;
 
 static void PrintDefList(const std::vector<Record*> &Uses,
-                         unsigned Num, std::ostream &OS) {
+                         unsigned Num, raw_ostream &OS) {
   OS << "static const unsigned ImplicitList" << Num << "[] = { ";
   for (unsigned i = 0, e = Uses.size(); i != e; ++i)
     OS << getQualifiedName(Uses[i]) << ", ";
@@ -28,7 +27,7 @@ static void PrintDefList(const std::vector<Record*> &Uses,
 }
 
 static void PrintBarriers(std::vector<Record*> &Barriers,
-                          unsigned Num, std::ostream &OS) {
+                          unsigned Num, raw_ostream &OS) {
   OS << "static const TargetRegisterClass* Barriers" << Num << "[] = { ";
   for (unsigned i = 0, e = Barriers.size(); i != e; ++i)
     OS << "&" << getQualifiedName(Barriers[i]) << "RegClass, ";
@@ -123,7 +122,7 @@ InstrInfoEmitter::GetOperandInfo(const CodeGenInstruction &Inst) {
   return Result;
 }
 
-void InstrInfoEmitter::EmitOperandInfo(std::ostream &OS, 
+void InstrInfoEmitter::EmitOperandInfo(raw_ostream &OS, 
                                        OperandInfoMapTy &OperandInfoIDs) {
   // ID #0 is for no operand info.
   unsigned OperandListNum = 0;
@@ -177,7 +176,7 @@ void InstrInfoEmitter::DetectRegisterClassBarriers(std::vector<Record*> &Defs,
 //===----------------------------------------------------------------------===//
 
 // run - Emit the main instruction description records for the target...
-void InstrInfoEmitter::run(std::ostream &OS) {
+void InstrInfoEmitter::run(raw_ostream &OS) {
   GatherItinClasses();
 
   EmitSourceFileHeader("Target Instruction Descriptors", OS);
@@ -243,7 +242,7 @@ void InstrInfoEmitter::emitRecord(const CodeGenInstruction &Inst, unsigned Num,
                          std::map<std::vector<Record*>, unsigned> &EmittedLists,
                                   std::map<Record*, unsigned> &BarriersMap,
                                   const OperandInfoMapTy &OpInfo,
-                                  std::ostream &OS) {
+                                  raw_ostream &OS) {
   int MinOperands = 0;
   if (!Inst.OperandList.empty())
     // Each logical operand can be multiple MI operands.
@@ -323,7 +322,7 @@ void InstrInfoEmitter::emitRecord(const CodeGenInstruction &Inst, unsigned Num,
 
 
 void InstrInfoEmitter::emitShiftedValue(Record *R, StringInit *Val,
-                                        IntInit *ShiftInt, std::ostream &OS) {
+                                        IntInit *ShiftInt, raw_ostream &OS) {
   if (Val == 0 || ShiftInt == 0)
     throw std::string("Illegal value or shift amount in TargetInfo*!");
   RecordVal *RV = R->getValue(Val->getValue());
@@ -375,7 +374,7 @@ void InstrInfoEmitter::emitShiftedValue(Record *R, StringInit *Val,
     return;
   }
 
-  std::cerr << "Unhandled initializer: " << *Val << "\n";
+  errs() << "Unhandled initializer: " << *Val << "\n";
   throw "In record '" + R->getName() + "' for TSFlag emission.";
 }
 
index 870ea0c58780963223570e35898f984e418c3cfa..657939e46388508edf81c59af42161b4f0bddc8d 100644 (file)
@@ -36,7 +36,7 @@ public:
   InstrInfoEmitter(RecordKeeper &R) : Records(R), CDP(R) { }
 
   // run - Output the instruction set description, returning true on failure.
-  void run(std::ostream &OS);
+  void run(raw_ostream &OS);
 
 private:
   typedef std::map<std::vector<std::string>, unsigned> OperandInfoMapTy;
@@ -46,16 +46,16 @@ private:
                   std::map<std::vector<Record*>, unsigned> &EL,
                   std::map<Record*, unsigned> &BM,
                   const OperandInfoMapTy &OpInfo,
-                  std::ostream &OS);
+                  raw_ostream &OS);
   void emitShiftedValue(Record *R, StringInit *Val, IntInit *Shift,
-                        std::ostream &OS);
+                        raw_ostream &OS);
 
   // Itinerary information.
   void GatherItinClasses();
   unsigned getItinClassNumber(const Record *InstRec);
   
   // Operand information.
-  void EmitOperandInfo(std::ostream &OS, OperandInfoMapTy &OperandInfoIDs);
+  void EmitOperandInfo(raw_ostream &OS, OperandInfoMapTy &OperandInfoIDs);
   std::vector<std::string> GetOperandInfo(const CodeGenInstruction &Inst);
 
   void DetectRegisterClassBarriers(std::vector<Record*> &Defs,
index 8c34e68ac6dfb69dd1dbcaa37e90b7aa32f29b82..36768316bc0e894c1bff5869b467ce7ab22622f3 100644 (file)
@@ -22,7 +22,7 @@ using namespace llvm;
 // IntrinsicEmitter Implementation
 //===----------------------------------------------------------------------===//
 
-void IntrinsicEmitter::run(std::ostream &OS) {
+void IntrinsicEmitter::run(raw_ostream &OS) {
   EmitSourceFileHeader("Intrinsic Function Source Fragment", OS);
   
   std::vector<CodeGenIntrinsic> Ints = LoadIntrinsics(Records, TargetOnly);
@@ -62,7 +62,7 @@ void IntrinsicEmitter::run(std::ostream &OS) {
 }
 
 void IntrinsicEmitter::EmitEnumInfo(const std::vector<CodeGenIntrinsic> &Ints,
-                                    std::ostream &OS) {
+                                    raw_ostream &OS) {
   OS << "// Enum values for Intrinsics.h\n";
   OS << "#ifdef GET_INTRINSIC_ENUM_VALUES\n";
   for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
@@ -76,7 +76,7 @@ void IntrinsicEmitter::EmitEnumInfo(const std::vector<CodeGenIntrinsic> &Ints,
 
 void IntrinsicEmitter::
 EmitFnNameRecognizer(const std::vector<CodeGenIntrinsic> &Ints, 
-                     std::ostream &OS) {
+                     raw_ostream &OS) {
   // Build a function name -> intrinsic name mapping.
   std::map<std::string, unsigned> IntMapping;
   for (unsigned i = 0, e = Ints.size(); i != e; ++i)
@@ -114,7 +114,7 @@ EmitFnNameRecognizer(const std::vector<CodeGenIntrinsic> &Ints,
 
 void IntrinsicEmitter::
 EmitIntrinsicToNameTable(const std::vector<CodeGenIntrinsic> &Ints, 
-                         std::ostream &OS) {
+                         raw_ostream &OS) {
   OS << "// Intrinsic ID to name table\n";
   OS << "#ifdef GET_INTRINSIC_NAME_TABLE\n";
   OS << "  // Note that entry #0 is the invalid intrinsic!\n";
@@ -125,7 +125,7 @@ EmitIntrinsicToNameTable(const std::vector<CodeGenIntrinsic> &Ints,
 
 void IntrinsicEmitter::
 EmitIntrinsicToOverloadTable(const std::vector<CodeGenIntrinsic> &Ints, 
-                         std::ostream &OS) {
+                         raw_ostream &OS) {
   OS << "// Intrinsic ID to overload table\n";
   OS << "#ifdef GET_INTRINSIC_OVERLOAD_TABLE\n";
   OS << "  // Note that entry #0 is the invalid intrinsic!\n";
@@ -140,7 +140,7 @@ EmitIntrinsicToOverloadTable(const std::vector<CodeGenIntrinsic> &Ints,
   OS << "#endif\n\n";
 }
 
-static void EmitTypeForValueType(std::ostream &OS, MVT::SimpleValueType VT) {
+static void EmitTypeForValueType(raw_ostream &OS, MVT::SimpleValueType VT) {
   if (MVT(VT).isInteger()) {
     unsigned BitWidth = MVT(VT).getSizeInBits();
     OS << "IntegerType::get(" << BitWidth << ")";
@@ -164,10 +164,10 @@ static void EmitTypeForValueType(std::ostream &OS, MVT::SimpleValueType VT) {
   }
 }
 
-static void EmitTypeGenerate(std::ostream &OS, const Record *ArgType,
+static void EmitTypeGenerate(raw_ostream &OS, const Record *ArgType,
                              unsigned &ArgNo);
 
-static void EmitTypeGenerate(std::ostream &OS,
+static void EmitTypeGenerate(raw_ostream &OS,
                              const std::vector<Record*> &ArgTypes,
                              unsigned &ArgNo) {
   if (ArgTypes.size() == 1) {
@@ -186,7 +186,7 @@ static void EmitTypeGenerate(std::ostream &OS,
   OS << " NULL)";
 }
 
-static void EmitTypeGenerate(std::ostream &OS, const Record *ArgType,
+static void EmitTypeGenerate(raw_ostream &OS, const Record *ArgType,
                              unsigned &ArgNo) {
   MVT::SimpleValueType VT = getValueType(ArgType->getValueAsDef("VT"));
 
@@ -275,7 +275,7 @@ namespace {
 }
 
 void IntrinsicEmitter::EmitVerifier(const std::vector<CodeGenIntrinsic> &Ints, 
-                                    std::ostream &OS) {
+                                    raw_ostream &OS) {
   OS << "// Verifier::visitIntrinsicFunctionCall code.\n";
   OS << "#ifdef GET_INTRINSIC_VERIFIER\n";
   OS << "  switch (ID) {\n";
@@ -358,7 +358,7 @@ void IntrinsicEmitter::EmitVerifier(const std::vector<CodeGenIntrinsic> &Ints,
 }
 
 void IntrinsicEmitter::EmitGenerator(const std::vector<CodeGenIntrinsic> &Ints, 
-                                     std::ostream &OS) {
+                                     raw_ostream &OS) {
   OS << "// Code for generating Intrinsic function declarations.\n";
   OS << "#ifdef GET_INTRINSIC_GENERATOR\n";
   OS << "  switch (id) {\n";
@@ -415,7 +415,7 @@ void IntrinsicEmitter::EmitGenerator(const std::vector<CodeGenIntrinsic> &Ints,
 
 /// EmitAttributes - This emits the Intrinsic::getAttributes method.
 void IntrinsicEmitter::
-EmitAttributes(const std::vector<CodeGenIntrinsic> &Ints, std::ostream &OS) {
+EmitAttributes(const std::vector<CodeGenIntrinsic> &Ints, raw_ostream &OS) {
   OS << "// Add parameter attributes that are not common to all intrinsics.\n";
   OS << "#ifdef GET_INTRINSIC_ATTRIBUTES\n";
   if (TargetOnly)
@@ -504,7 +504,7 @@ EmitAttributes(const std::vector<CodeGenIntrinsic> &Ints, std::ostream &OS) {
 
 /// EmitModRefBehavior - Determine intrinsic alias analysis mod/ref behavior.
 void IntrinsicEmitter::
-EmitModRefBehavior(const std::vector<CodeGenIntrinsic> &Ints, std::ostream &OS){
+EmitModRefBehavior(const std::vector<CodeGenIntrinsic> &Ints, raw_ostream &OS){
   OS << "// Determine intrinsic alias analysis mod/ref behavior.\n";
   OS << "#ifdef GET_INTRINSIC_MODREF_BEHAVIOR\n";
   OS << "switch (id) {\n";
@@ -534,7 +534,7 @@ EmitModRefBehavior(const std::vector<CodeGenIntrinsic> &Ints, std::ostream &OS){
 }
 
 void IntrinsicEmitter::
-EmitGCCBuiltinList(const std::vector<CodeGenIntrinsic> &Ints, std::ostream &OS){
+EmitGCCBuiltinList(const std::vector<CodeGenIntrinsic> &Ints, raw_ostream &OS){
   OS << "// Get the GCC builtin that corresponds to an LLVM intrinsic.\n";
   OS << "#ifdef GET_GCC_BUILTIN_NAME\n";
   OS << "  switch (F->getIntrinsicID()) {\n";
@@ -559,7 +559,7 @@ EmitGCCBuiltinList(const std::vector<CodeGenIntrinsic> &Ints, std::ostream &OS){
 typedef std::map<std::string, std::string>::const_iterator StrMapIterator;
 static void EmitBuiltinComparisons(StrMapIterator Start, StrMapIterator End,
                                    unsigned CharStart, unsigned Indent,
-                                   std::string TargetPrefix, std::ostream &OS) {
+                                   std::string TargetPrefix, raw_ostream &OS) {
   if (Start == End) return; // empty range.
   
   // Determine what, if anything, is the same about all these strings.
@@ -633,7 +633,7 @@ static void EmitBuiltinComparisons(StrMapIterator Start, StrMapIterator End,
 /// same target, and we already checked it.
 static void EmitTargetBuiltins(const std::map<std::string, std::string> &BIM,
                                const std::string &TargetPrefix,
-                               std::ostream &OS) {
+                               raw_ostream &OS) {
   // Rearrange the builtins by length.
   std::vector<std::map<std::string, std::string> > BuiltinsByLen;
   BuiltinsByLen.reserve(100);
@@ -660,7 +660,7 @@ static void EmitTargetBuiltins(const std::map<std::string, std::string> &BIM,
         
 void IntrinsicEmitter::
 EmitIntrinsicToGCCBuiltinMap(const std::vector<CodeGenIntrinsic> &Ints, 
-                             std::ostream &OS) {
+                             raw_ostream &OS) {
   typedef std::map<std::string, std::map<std::string, std::string> > BIMTy;
   BIMTy BuiltinMap;
   for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
index 1619d02242929635a92b9101fa92b60b84ea996c..c3c92bcc569415ea7bfd9a5a6b22c28ac6d259c2 100644 (file)
@@ -27,29 +27,29 @@ namespace llvm {
     IntrinsicEmitter(RecordKeeper &R, bool T = false) 
       : Records(R), TargetOnly(T) {}
 
-    void run(std::ostream &OS);
+    void run(raw_ostream &OS);
     
     void EmitEnumInfo(const std::vector<CodeGenIntrinsic> &Ints, 
-                      std::ostream &OS);
+                      raw_ostream &OS);
 
     void EmitFnNameRecognizer(const std::vector<CodeGenIntrinsic> &Ints, 
-                              std::ostream &OS);
+                              raw_ostream &OS);
     void EmitIntrinsicToNameTable(const std::vector<CodeGenIntrinsic> &Ints, 
-                                  std::ostream &OS);
+                                  raw_ostream &OS);
     void EmitIntrinsicToOverloadTable(const std::vector<CodeGenIntrinsic> &Ints, 
-                                      std::ostream &OS);
+                                      raw_ostream &OS);
     void EmitVerifier(const std::vector<CodeGenIntrinsic> &Ints, 
-                      std::ostream &OS);
+                      raw_ostream &OS);
     void EmitGenerator(const std::vector<CodeGenIntrinsic> &Ints, 
-                       std::ostream &OS);
+                       raw_ostream &OS);
     void EmitAttributes(const std::vector<CodeGenIntrinsic> &Ints,
-                        std::ostream &OS);
+                        raw_ostream &OS);
     void EmitModRefBehavior(const std::vector<CodeGenIntrinsic> &Ints,
-                            std::ostream &OS);
+                            raw_ostream &OS);
     void EmitGCCBuiltinList(const std::vector<CodeGenIntrinsic> &Ints, 
-                            std::ostream &OS);
+                            raw_ostream &OS);
     void EmitIntrinsicToGCCBuiltinMap(const std::vector<CodeGenIntrinsic> &Ints, 
-                                      std::ostream &OS);
+                                      raw_ostream &OS);
   };
 
 } // End llvm namespace
index 9fcfd0576505c4e0226affd974d569359cf781b7..fc182ce5af8e7dbd748e9200467f62d933556777 100644 (file)
@@ -19,8 +19,6 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringSet.h"
-#include "llvm/Support/Streams.h"
-
 #include <algorithm>
 #include <cassert>
 #include <functional>
@@ -241,7 +239,7 @@ void OptionDescription::Merge (const OptionDescription& other)
   if (Help == other.Help || Help == DefaultHelpString)
     Help = other.Help;
   else if (other.Help != DefaultHelpString) {
-    llvm::cerr << "Warning: several different help strings"
+    llvm::errs() << "Warning: several different help strings"
       " defined for option " + Name + "\n";
   }
 
@@ -489,7 +487,7 @@ private:
       throw std::string("Only one of (required), (zero_or_one) or "
                         "(one_or_more) properties is allowed!");
     if (!OptionType::IsList(optDesc_.Type))
-      llvm::cerr << "Warning: specifying the 'one_or_more' property "
+      llvm::errs() << "Warning: specifying the 'one_or_more' property "
         "on a non-list option will have no effect.\n";
     optDesc_.setOneOrMore();
   }
@@ -500,7 +498,7 @@ private:
       throw std::string("Only one of (required), (zero_or_one) or "
                         "(one_or_more) properties is allowed!");
     if (!OptionType::IsList(optDesc_.Type))
-      llvm::cerr << "Warning: specifying the 'zero_or_one' property"
+      llvm::errs() << "Warning: specifying the 'zero_or_one' property"
         "on a non-list option will have no effect.\n";
     optDesc_.setZeroOrOne();
   }
@@ -947,7 +945,7 @@ void CheckForSuperfluousOptions (const RecordVector& Edges,
     const OptionDescription& Val = B->second;
     if (!nonSuperfluousOptions.count(Val.Name)
         && Val.Type != OptionType::Alias)
-      llvm::cerr << "Warning: option '-" << Val.Name << "' has no effect! "
+      llvm::errs() << "Warning: option '-" << Val.Name << "' has no effect! "
         "Probable cause: this option is specified only in the OptionList.\n";
   }
 }
@@ -957,7 +955,7 @@ void CheckForSuperfluousOptions (const RecordVector& Edges,
 bool EmitCaseTest1Arg(const std::string& TestName,
                       const DagInit& d,
                       const OptionDescriptions& OptDescs,
-                      std::ostream& O) {
+                      raw_ostream& O) {
   checkNumberOfArguments(&d, 1);
   const std::string& OptName = InitPtrToString(d.getArg(0));
 
@@ -1003,7 +1001,7 @@ bool EmitCaseTest2Args(const std::string& TestName,
                        const DagInit& d,
                        const char* IndentLevel,
                        const OptionDescriptions& OptDescs,
-                       std::ostream& O) {
+                       raw_ostream& O) {
   checkNumberOfArguments(&d, 2);
   const std::string& OptName = InitPtrToString(d.getArg(0));
   const std::string& OptArg = InitPtrToString(d.getArg(1));
@@ -1032,14 +1030,14 @@ bool EmitCaseTest2Args(const std::string& TestName,
 // EmitLogicalOperationTest and EmitCaseTest are mutually recursive.
 void EmitCaseTest(const DagInit& d, const char* IndentLevel,
                   const OptionDescriptions& OptDescs,
-                  std::ostream& O);
+                  raw_ostream& O);
 
 /// EmitLogicalOperationTest - Helper function used by
 /// EmitCaseConstructHandler.
 void EmitLogicalOperationTest(const DagInit& d, const char* LogicOp,
                               const char* IndentLevel,
                               const OptionDescriptions& OptDescs,
-                              std::ostream& O) {
+                              raw_ostream& O) {
   O << '(';
   for (unsigned j = 0, NumArgs = d.getNumArgs(); j < NumArgs; ++j) {
     const DagInit& InnerTest = InitPtrToDag(d.getArg(j));
@@ -1054,7 +1052,7 @@ void EmitLogicalOperationTest(const DagInit& d, const char* LogicOp,
 /// EmitCaseTest - Helper function used by EmitCaseConstructHandler.
 void EmitCaseTest(const DagInit& d, const char* IndentLevel,
                   const OptionDescriptions& OptDescs,
-                  std::ostream& O) {
+                  raw_ostream& O) {
   const std::string& TestName = d.getOperator()->getAsString();
 
   if (TestName == "and")
@@ -1072,12 +1070,12 @@ void EmitCaseTest(const DagInit& d, const char* IndentLevel,
 // Emit code that handles the 'case' construct.
 // Takes a function object that should emit code for every case clause.
 // Callback's type is
-// void F(Init* Statement, const char* IndentLevel, std::ostream& O).
+// void F(Init* Statement, const char* IndentLevel, raw_ostream& O).
 template <typename F>
 void EmitCaseConstructHandler(const Init* Dag, const char* IndentLevel,
                               F Callback, bool EmitElseIf,
                               const OptionDescriptions& OptDescs,
-                              std::ostream& O) {
+                              raw_ostream& O) {
   const DagInit* d = &InitPtrToDag(Dag);
   if (d->getOperator()->getAsString() != "case")
     throw std::string("EmitCaseConstructHandler should be invoked"
@@ -1210,7 +1208,7 @@ void TokenizeCmdline(const std::string& CmdLine, StrVector& Out) {
 /// SubstituteSpecialCommands - Perform string substitution for $CALL
 /// and $ENV. Helper function used by EmitCmdLineVecFill().
 StrVector::const_iterator SubstituteSpecialCommands
-(StrVector::const_iterator Pos, StrVector::const_iterator End, std::ostream& O)
+(StrVector::const_iterator Pos, StrVector::const_iterator End, raw_ostream& O)
 {
 
   const std::string& cmd = *Pos;
@@ -1275,7 +1273,7 @@ StrVector::const_iterator SubstituteSpecialCommands
 /// vector. Helper function used by EmitGenerateActionMethod().
 void EmitCmdLineVecFill(const Init* CmdLine, const std::string& ToolName,
                         bool IsJoin, const char* IndentLevel,
-                        std::ostream& O) {
+                        raw_ostream& O) {
   StrVector StrVec;
   TokenizeCmdline(InitPtrToString(CmdLine), StrVec);
 
@@ -1344,7 +1342,7 @@ class EmitCmdLineVecFillCallback {
     : IsJoin(J), ToolName(TN) {}
 
   void operator()(const Init* Statement, const char* IndentLevel,
-                  std::ostream& O) const
+                  raw_ostream& O) const
   {
     EmitCmdLineVecFill(Statement, ToolName, IsJoin,
                        IndentLevel, O);
@@ -1357,7 +1355,7 @@ class EmitCmdLineVecFillCallback {
 void EmitForwardOptionPropertyHandlingCode (const OptionDescription& D,
                                             const char* Indent,
                                             const std::string& NewName,
-                                            std::ostream& O) {
+                                            raw_ostream& O) {
   const std::string& Name = NewName.empty()
     ? ("-" + D.Name)
     : NewName;
@@ -1416,7 +1414,7 @@ class EmitActionHandler {
   const OptionDescriptions& OptDescs;
 
   void processActionDag(const Init* Statement, const char* IndentLevel,
-                        std::ostream& O) const
+                        raw_ostream& O) const
   {
     const DagInit& Dag = InitPtrToDag(Statement);
     const std::string& ActionName = Dag.getOperator()->getAsString();
@@ -1491,7 +1489,7 @@ class EmitActionHandler {
     : OptDescs(OD) {}
 
   void operator()(const Init* Statement, const char* IndentLevel,
-                  std::ostream& O) const
+                  raw_ostream& O) const
   {
     if (typeid(*Statement) == typeid(ListInit)) {
       const ListInit& DagList = *static_cast<const ListInit*>(Statement);
@@ -1509,7 +1507,7 @@ class EmitActionHandler {
 // Tool::GenerateAction() method.
 void EmitGenerateActionMethod (const ToolDescription& D,
                                const OptionDescriptions& OptDescs,
-                               bool IsJoin, std::ostream& O) {
+                               bool IsJoin, raw_ostream& O) {
   if (IsJoin)
     O << Indent1 << "Action GenerateAction(const PathVector& inFiles,\n";
   else
@@ -1561,7 +1559,7 @@ void EmitGenerateActionMethod (const ToolDescription& D,
 /// a given Tool class.
 void EmitGenerateActionMethods (const ToolDescription& ToolDesc,
                                 const OptionDescriptions& OptDescs,
-                                std::ostream& O) {
+                                raw_ostream& O) {
   if (!ToolDesc.isJoin())
     O << Indent1 << "Action GenerateAction(const PathVector& inFiles,\n"
       << Indent2 << "bool HasChildren,\n"
@@ -1580,7 +1578,7 @@ void EmitGenerateActionMethods (const ToolDescription& ToolDesc,
 
 /// EmitInOutLanguageMethods - Emit the [Input,Output]Language()
 /// methods for a given Tool class.
-void EmitInOutLanguageMethods (const ToolDescription& D, std::ostream& O) {
+void EmitInOutLanguageMethods (const ToolDescription& D, raw_ostream& O) {
   O << Indent1 << "const char** InputLanguages() const {\n"
     << Indent2 << "return InputLanguages_;\n"
     << Indent1 << "}\n\n";
@@ -1594,7 +1592,7 @@ void EmitInOutLanguageMethods (const ToolDescription& D, std::ostream& O) {
 }
 
 /// EmitNameMethod - Emit the Name() method for a given Tool class.
-void EmitNameMethod (const ToolDescription& D, std::ostream& O) {
+void EmitNameMethod (const ToolDescription& D, raw_ostream& O) {
   O << Indent1 << "const char* Name() const {\n"
     << Indent2 << "return \"" << D.Name << "\";\n"
     << Indent1 << "}\n\n";
@@ -1602,7 +1600,7 @@ void EmitNameMethod (const ToolDescription& D, std::ostream& O) {
 
 /// EmitIsJoinMethod - Emit the IsJoin() method for a given Tool
 /// class.
-void EmitIsJoinMethod (const ToolDescription& D, std::ostream& O) {
+void EmitIsJoinMethod (const ToolDescription& D, raw_ostream& O) {
   O << Indent1 << "bool IsJoin() const {\n";
   if (D.isJoin())
     O << Indent2 << "return true;\n";
@@ -1613,7 +1611,7 @@ void EmitIsJoinMethod (const ToolDescription& D, std::ostream& O) {
 
 /// EmitStaticMemberDefinitions - Emit static member definitions for a
 /// given Tool class.
-void EmitStaticMemberDefinitions(const ToolDescription& D, std::ostream& O) {
+void EmitStaticMemberDefinitions(const ToolDescription& D, raw_ostream& O) {
   if (D.InLanguage.empty())
     throw "Tool " + D.Name + " has no 'in_language' property!";
 
@@ -1627,7 +1625,7 @@ void EmitStaticMemberDefinitions(const ToolDescription& D, std::ostream& O) {
 /// EmitToolClassDefinition - Emit a Tool class definition.
 void EmitToolClassDefinition (const ToolDescription& D,
                               const OptionDescriptions& OptDescs,
-                              std::ostream& O) {
+                              raw_ostream& O) {
   if (D.Name == "root")
     return;
 
@@ -1658,7 +1656,7 @@ void EmitToolClassDefinition (const ToolDescription& D,
 /// and emit registration code.
 void EmitOptionDefinitions (const OptionDescriptions& descs,
                             bool HasSink, bool HasExterns,
-                            std::ostream& O)
+                            raw_ostream& O)
 {
   std::vector<OptionDescription> Aliases;
 
@@ -1742,7 +1740,7 @@ void EmitOptionDefinitions (const OptionDescriptions& descs,
 }
 
 /// EmitPopulateLanguageMap - Emit the PopulateLanguageMap() function.
-void EmitPopulateLanguageMap (const RecordKeeper& Records, std::ostream& O)
+void EmitPopulateLanguageMap (const RecordKeeper& Records, raw_ostream& O)
 {
   // Generate code
   O << "void PopulateLanguageMapLocal(LanguageMap& langMap) {\n";
@@ -1776,7 +1774,7 @@ void EmitPopulateLanguageMap (const RecordKeeper& Records, std::ostream& O)
 /// IncDecWeight - Helper function passed to EmitCaseConstructHandler()
 /// by EmitEdgeClass().
 void IncDecWeight (const Init* i, const char* IndentLevel,
-                   std::ostream& O) {
+                   raw_ostream& O) {
   const DagInit& d = InitPtrToDag(i);
   const std::string& OpName = d.getOperator()->getAsString();
 
@@ -1808,7 +1806,7 @@ void IncDecWeight (const Init* i, const char* IndentLevel,
 /// EmitEdgeClass - Emit a single Edge# class.
 void EmitEdgeClass (unsigned N, const std::string& Target,
                     DagInit* Case, const OptionDescriptions& OptDescs,
-                    std::ostream& O) {
+                    raw_ostream& O) {
 
   // Class constructor.
   O << "class Edge" << N << ": public Edge {\n"
@@ -1830,7 +1828,7 @@ void EmitEdgeClass (unsigned N, const std::string& Target,
 /// EmitEdgeClasses - Emit Edge* classes that represent graph edges.
 void EmitEdgeClasses (const RecordVector& EdgeVector,
                       const OptionDescriptions& OptDescs,
-                      std::ostream& O) {
+                      raw_ostream& O) {
   int i = 0;
   for (RecordVector::const_iterator B = EdgeVector.begin(),
          E = EdgeVector.end(); B != E; ++B) {
@@ -1848,7 +1846,7 @@ void EmitEdgeClasses (const RecordVector& EdgeVector,
 /// function.
 void EmitPopulateCompilationGraph (const RecordVector& EdgeVector,
                                    const ToolDescriptions& ToolDescs,
-                                   std::ostream& O)
+                                   raw_ostream& O)
 {
   O << "void PopulateCompilationGraphLocal(CompilationGraph& G) {\n";
 
@@ -1947,7 +1945,7 @@ void FillInHookNames(const ToolDescriptions& ToolDescs,
 /// EmitHookDeclarations - Parse CmdLine fields of all the tool
 /// property records and emit hook function declaration for each
 /// instance of $CALL(HookName).
-void EmitHookDeclarations(const ToolDescriptions& ToolDescs, std::ostream& O) {
+void EmitHookDeclarations(const ToolDescriptions& ToolDescs, raw_ostream& O) {
   llvm::StringMap<unsigned> HookNames;
 
   FillInHookNames(ToolDescs, HookNames);
@@ -1969,7 +1967,7 @@ void EmitHookDeclarations(const ToolDescriptions& ToolDescs, std::ostream& O) {
 }
 
 /// EmitRegisterPlugin - Emit code to register this plugin.
-void EmitRegisterPlugin(int Priority, std::ostream& O) {
+void EmitRegisterPlugin(int Priority, raw_ostream& O) {
   O << "struct Plugin : public llvmc::BasePlugin {\n\n"
     << Indent1 << "int Priority() const { return " << Priority << "; }\n\n"
     << Indent1 << "void PopulateLanguageMap(LanguageMap& langMap) const\n"
@@ -1984,7 +1982,7 @@ void EmitRegisterPlugin(int Priority, std::ostream& O) {
 
 /// EmitIncludes - Emit necessary #include directives and some
 /// additional declarations.
-void EmitIncludes(std::ostream& O) {
+void EmitIncludes(raw_ostream& O) {
   O << "#include \"llvm/CompilerDriver/CompilationGraph.h\"\n"
     << "#include \"llvm/CompilerDriver/ForceLinkageMacros.h\"\n"
     << "#include \"llvm/CompilerDriver/Plugin.h\"\n"
@@ -2079,7 +2077,7 @@ void CheckPluginData(PluginData& Data) {
 
 }
 
-void EmitPluginCode(const PluginData& Data, std::ostream& O) {
+void EmitPluginCode(const PluginData& Data, raw_ostream& O) {
   // Emit file header.
   EmitIncludes(O);
 
@@ -2124,7 +2122,7 @@ void EmitPluginCode(const PluginData& Data, std::ostream& O) {
 }
 
 /// run - The back-end entry point.
-void LLVMCConfigurationEmitter::run (std::ostream &O) {
+void LLVMCConfigurationEmitter::run (raw_ostream &O) {
   try {
   PluginData Data;
 
index 98c4bc0695606f71058e7c044ec6040b01d3f462..347f6f1cc5555045581acbea366c71f1687a270e 100644 (file)
@@ -26,7 +26,7 @@ namespace llvm {
     explicit LLVMCConfigurationEmitter(RecordKeeper &R) : Records(R) {}
 
     // run - Output the asmwriter, returning true on failure.
-    void run(std::ostream &o);
+    void run(raw_ostream &o);
   };
 }
 
index a7538731fd1da52069c6591b1355e0793b08e69b..8f31624644f62ca69fcda60be469e8a7300200fa 100644 (file)
@@ -13,9 +13,8 @@
 
 #include "Record.h"
 #include "llvm/Support/DataTypes.h"
-#include "llvm/Support/Streams.h"
+#include "llvm/Support/Format.h"
 #include "llvm/ADT/StringExtras.h"
-#include <ios>
 
 using namespace llvm;
 
@@ -23,7 +22,7 @@ using namespace llvm;
 //    Type implementations
 //===----------------------------------------------------------------------===//
 
-void RecTy::dump() const { print(*cerr.stream()); }
+void RecTy::dump() const { print(errs()); }
 
 Init *BitRecTy::convertValue(BitsInit *BI) {
   if (BI->getNumBits() != 1) return 0; // Only accept if just one bit!
@@ -330,7 +329,7 @@ RecTy *llvm::resolveTypes(RecTy *T1, RecTy *T2) {
 //    Initializer implementations
 //===----------------------------------------------------------------------===//
 
-void Init::dump() const { return print(*cerr.stream()); }
+void Init::dump() const { return print(errs()); }
 
 Init *BitsInit::convertInitializerBitRange(const std::vector<unsigned> &Bits) {
   BitsInit *BI = new BitsInit(Bits.size());
@@ -360,7 +359,7 @@ std::string BitsInit::getAsString() const {
   return Result + " }";
 }
 
-bool BitsInit::printInHex(std::ostream &OS) const {
+bool BitsInit::printInHex(raw_ostream &OS) const {
   // First, attempt to convert the value into an integer value...
   int64_t Result = 0;
   for (unsigned i = 0, e = getNumBits(); i != e; ++i)
@@ -370,11 +369,11 @@ bool BitsInit::printInHex(std::ostream &OS) const {
       return true;
     }
 
-  OS << "0x" << std::hex << Result << std::dec;
+  OS << format("0x%x", Result);
   return false;
 }
 
-bool BitsInit::printAsVariable(std::ostream &OS) const {
+bool BitsInit::printAsVariable(raw_ostream &OS) const {
   // Get the variable that we may be set equal to...
   assert(getNumBits() != 0);
   VarBitInit *FirstBit = dynamic_cast<VarBitInit*>(getBit(0));
@@ -397,7 +396,7 @@ bool BitsInit::printAsVariable(std::ostream &OS) const {
   return false;
 }
 
-bool BitsInit::printAsUnset(std::ostream &OS) const {
+bool BitsInit::printAsUnset(raw_ostream &OS) const {
   for (unsigned i = 0, e = getNumBits(); i != e; ++i)
     if (!dynamic_cast<UnsetInit*>(getBit(i)))
       return true;
@@ -592,7 +591,7 @@ Init *UnOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) {
         if (Record *D = Records.getDef(Name))
           return new DefInit(D);
 
-        cerr << "Variable not defined: '" + Name + "'\n";
+        errs() << "Variable not defined: '" + Name + "'\n";
         assert(0 && "Variable not found");
         return 0;
       }
@@ -771,7 +770,7 @@ Init *BinOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) {
       if (Record *D = Records.getDef(Name))
         return new DefInit(D);
 
-      cerr << "Variable not defined in !nameconcat: '" + Name + "'\n";
+      errs() << "Variable not defined in !nameconcat: '" + Name + "'\n";
       assert(0 && "Variable not found in !nameconcat");
       return 0;
     }
@@ -886,14 +885,14 @@ static Init *ForeachHelper(Init *LHS, Init *MHS, Init *RHS, RecTy *Type,
   OpInit *RHSo = dynamic_cast<OpInit*>(RHS);
 
   if (!RHSo) {
-    cerr << "!foreach requires an operator\n";
+    errs() << "!foreach requires an operator\n";
     assert(0 && "No operator for !foreach");
   }
 
   TypedInit *LHSt = dynamic_cast<TypedInit*>(LHS);
 
   if (!LHSt) {
-    cerr << "!foreach requires typed variable\n";
+    errs() << "!foreach requires typed variable\n";
     assert(0 && "No typed variable for !foreach");
   }
 
@@ -1308,9 +1307,9 @@ RecordVal::RecordVal(const std::string &N, RecTy *T, unsigned P)
   assert(Value && "Cannot create unset value for current type!");
 }
 
-void RecordVal::dump() const { cerr << *this; }
+void RecordVal::dump() const { errs() << *this; }
 
-void RecordVal::print(std::ostream &OS, bool PrintSem) const {
+void RecordVal::print(raw_ostream &OS, bool PrintSem) const {
   if (getPrefix()) OS << "field ";
   OS << *getType() << " " << getName();
 
@@ -1343,9 +1342,9 @@ void Record::resolveReferencesTo(const RecordVal *RV) {
 }
 
 
-void Record::dump() const { cerr << *this; }
+void Record::dump() const { errs() << *this; }
 
-std::ostream &llvm::operator<<(std::ostream &OS, const Record &R) {
+raw_ostream &llvm::operator<<(raw_ostream &OS, const Record &R) {
   OS << R.getName();
 
   const std::vector<std::string> &TArgs = R.getTemplateArgs();
@@ -1556,10 +1555,10 @@ std::string Record::getValueAsCode(const std::string &FieldName) const {
 
 
 void MultiClass::dump() const {
-  cerr << "Record:\n";
+  errs() << "Record:\n";
   Rec.dump();
   
-  cerr << "Defs:\n";
+  errs() << "Defs:\n";
   for (RecordVector::const_iterator r = DefPrototypes.begin(),
          rend = DefPrototypes.end();
        r != rend;
@@ -1569,9 +1568,9 @@ void MultiClass::dump() const {
 }
 
 
-void RecordKeeper::dump() const { cerr << *this; }
+void RecordKeeper::dump() const { errs() << *this; }
 
-std::ostream &llvm::operator<<(std::ostream &OS, const RecordKeeper &RK) {
+raw_ostream &llvm::operator<<(raw_ostream &OS, const RecordKeeper &RK) {
   OS << "------------- Classes -----------------\n";
   const std::map<std::string, Record*> &Classes = RK.getClasses();
   for (std::map<std::string, Record*>::const_iterator I = Classes.begin(),
index 2254dd84e08984a8ec267a9557ecc5883d02681c..11db910328a460aa63edfe5cddbe9cfac685b90d 100644 (file)
 
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/DataTypes.h"
+#include "llvm/Support/raw_ostream.h"
 #include <map>
-#include <ostream>
 
 namespace llvm {
+class raw_ostream;
   
 // RecTy subclasses.
 class BitRecTy;
@@ -65,7 +66,7 @@ struct RecTy {
   virtual ~RecTy() {}
 
   virtual std::string getAsString() const = 0;
-  void print(std::ostream &OS) const { OS << getAsString(); }
+  void print(raw_ostream &OS) const { OS << getAsString(); }
   void dump() const;
 
   /// typeIsConvertibleTo - Return true if all values of 'this' type can be
@@ -113,7 +114,7 @@ public:   // These methods should only be called by subclasses of RecTy.
   virtual bool baseClassOf(const RecordRecTy *RHS) const { return false; }
 };
 
-inline std::ostream &operator<<(std::ostream &OS, const RecTy &Ty) {
+inline raw_ostream &operator<<(raw_ostream &OS, const RecTy &Ty) {
   Ty.print(OS);
   return OS;
 }
@@ -459,13 +460,13 @@ struct Init {
   virtual bool isComplete() const { return true; }
 
   /// print - Print out this value.
-  void print(std::ostream &OS) const { OS << getAsString(); }
+  void print(raw_ostream &OS) const { OS << getAsString(); }
 
   /// getAsString - Convert this value to a string form.
   virtual std::string getAsString() const = 0;
 
   /// dump - Debugging method that may be called through a debugger, just
-  /// invokes print on cerr.
+  /// invokes print on stderr.
   void dump() const;
 
   /// convertInitializerTo - This virtual function is a simple call-back
@@ -516,7 +517,7 @@ struct Init {
   }
 };
 
-inline std::ostream &operator<<(std::ostream &OS, const Init &I) {
+inline raw_ostream &operator<<(raw_ostream &OS, const Init &I) {
   I.print(OS); return OS;
 }
 
@@ -613,9 +614,9 @@ public:
 
   // printXX - Print this bitstream with the specified format, returning true if
   // it is not possible.
-  bool printInHex(std::ostream &OS) const;
-  bool printAsVariable(std::ostream &OS) const;
-  bool printAsUnset(std::ostream &OS) const;
+  bool printInHex(raw_ostream &OS) const;
+  bool printAsVariable(raw_ostream &OS) const;
+  bool printAsUnset(raw_ostream &OS) const;
 };
 
 
@@ -1210,10 +1211,10 @@ public:
   }
 
   void dump() const;
-  void print(std::ostream &OS, bool PrintSem = true) const;
+  void print(raw_ostream &OS, bool PrintSem = true) const;
 };
 
-inline std::ostream &operator<<(std::ostream &OS, const RecordVal &RV) {
+inline raw_ostream &operator<<(raw_ostream &OS, const RecordVal &RV) {
   RV.print(OS << "  ");
   return OS;
 }
@@ -1378,7 +1379,7 @@ public:
   std::string getValueAsCode(const std::string &FieldName) const;
 };
 
-std::ostream &operator<<(std::ostream &OS, const Record &R);
+raw_ostream &operator<<(raw_ostream &OS, const Record &R);
 
 struct MultiClass {
   Record Rec;  // Placeholder for template args and Name.
@@ -1477,7 +1478,7 @@ public:
 };
   
   
-std::ostream &operator<<(std::ostream &OS, const RecordKeeper &RK);
+raw_ostream &operator<<(raw_ostream &OS, const RecordKeeper &RK);
 
 extern RecordKeeper Records;
 
index dcf965cc1d7909c6b82f39cc2b1327aea53b4e8f..3297e936a2b6b8d0adfacd34925f618daf1edbf7 100644 (file)
 #include "Record.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/STLExtras.h"
-#include "llvm/Support/Streams.h"
-#include <set>
 #include <algorithm>
+#include <set>
 using namespace llvm;
 
 // runEnums - Print out enum values for all of the registers.
-void RegisterInfoEmitter::runEnums(std::ostream &OS) {
+void RegisterInfoEmitter::runEnums(raw_ostream &OS) {
   CodeGenTarget Target;
   const std::vector<CodeGenRegister> &Registers = Target.getRegisters();
 
@@ -47,7 +46,7 @@ void RegisterInfoEmitter::runEnums(std::ostream &OS) {
   OS << "} // End llvm namespace \n";
 }
 
-void RegisterInfoEmitter::runHeader(std::ostream &OS) {
+void RegisterInfoEmitter::runHeader(raw_ostream &OS) {
   EmitSourceFileHeader("Register Information Header Fragment", OS);
   CodeGenTarget Target;
   const std::string &TargetName = Target.getName();
@@ -118,9 +117,9 @@ static void addSuperReg(Record *R, Record *S,
                   std::map<Record*, std::set<Record*>, LessRecord> &SuperRegs,
                   std::map<Record*, std::set<Record*>, LessRecord> &Aliases) {
   if (R == S) {
-    cerr << "Error: recursive sub-register relationship between"
-         << " register " << getQualifiedName(R)
-         << " and its sub-registers?\n";
+    errs() << "Error: recursive sub-register relationship between"
+           << " register " << getQualifiedName(R)
+           << " and its sub-registers?\n";
     abort();
   }
   if (!SuperRegs[R].insert(S).second)
@@ -139,9 +138,9 @@ static void addSubSuperReg(Record *R, Record *S,
                    std::map<Record*, std::set<Record*>, LessRecord> &SuperRegs,
                    std::map<Record*, std::set<Record*>, LessRecord> &Aliases) {
   if (R == S) {
-    cerr << "Error: recursive sub-register relationship between"
-         << " register " << getQualifiedName(R)
-         << " and its sub-registers?\n";
+    errs() << "Error: recursive sub-register relationship between"
+           << " register " << getQualifiedName(R)
+           << " and its sub-registers?\n";
     abort();
   }
 
@@ -172,7 +171,7 @@ public:
 
 // RegisterInfoEmitter::run - Main register file description emitter.
 //
-void RegisterInfoEmitter::run(std::ostream &OS) {
+void RegisterInfoEmitter::run(raw_ostream &OS) {
   CodeGenTarget Target;
   EmitSourceFileHeader("Register Information Source Fragment", OS);
 
@@ -450,15 +449,15 @@ void RegisterInfoEmitter::run(std::ostream &OS) {
     for (unsigned j = 0, e = LI.size(); j != e; ++j) {
       Record *Reg = LI[j];
       if (RegisterAliases[R].count(Reg))
-        cerr << "Warning: register alias between " << getQualifiedName(R)
-             << " and " << getQualifiedName(Reg)
-             << " specified multiple times!\n";
+        errs() << "Warning: register alias between " << getQualifiedName(R)
+               << " and " << getQualifiedName(Reg)
+               << " specified multiple times!\n";
       RegisterAliases[R].insert(Reg);
 
       if (RegisterAliases[Reg].count(R))
-        cerr << "Warning: register alias between " << getQualifiedName(R)
-             << " and " << getQualifiedName(Reg)
-             << " specified multiple times!\n";
+        errs() << "Warning: register alias between " << getQualifiedName(R)
+               << " and " << getQualifiedName(Reg)
+               << " specified multiple times!\n";
       RegisterAliases[Reg].insert(R);
     }
   }
@@ -471,9 +470,9 @@ void RegisterInfoEmitter::run(std::ostream &OS) {
     for (unsigned j = 0, e = LI.size(); j != e; ++j) {
       Record *SubReg = LI[j];
       if (RegisterSubRegs[R].count(SubReg))
-        cerr << "Warning: register " << getQualifiedName(SubReg)
-             << " specified as a sub-register of " << getQualifiedName(R)
-             << " multiple times!\n";
+        errs() << "Warning: register " << getQualifiedName(SubReg)
+               << " specified as a sub-register of " << getQualifiedName(R)
+               << " multiple times!\n";
       addSubSuperReg(R, SubReg, RegisterSubRegs, RegisterSuperRegs,
                      RegisterAliases);
     }
@@ -808,8 +807,8 @@ void RegisterInfoEmitter::run(std::ostream &OS) {
     std::vector<Record*> To   = SubRegs[i]->getValueAsListOfDefs("To");
     
     if (From.size() != To.size()) {
-      cerr << "Error: register list and sub-register list not of equal length"
-           << " in SubRegSet\n";
+      errs() << "Error: register list and sub-register list not of equal length"
+             << " in SubRegSet\n";
       exit(1);
     }
     
@@ -858,8 +857,8 @@ void RegisterInfoEmitter::run(std::ostream &OS) {
     std::vector<int64_t> RegNums = Reg->getValueAsListOfInts("DwarfNumbers");
     maxLength = std::max((size_t)maxLength, RegNums.size());
     if (DwarfRegNums.count(Reg))
-      cerr << "Warning: DWARF numbers for register " << getQualifiedName(Reg)
-           << "specified multiple times\n";
+      errs() << "Warning: DWARF numbers for register " << getQualifiedName(Reg)
+             << "specified multiple times\n";
     DwarfRegNums[Reg] = RegNums;
   }
 
index b5493a9f4574f563911d3f285920d689710e7bc7..1456b4f1ec70deffbf44820312e26c5159eee2bc 100644 (file)
@@ -26,13 +26,13 @@ public:
   RegisterInfoEmitter(RecordKeeper &R) : Records(R) {}
 
   // run - Output the register file description, returning true on failure.
-  void run(std::ostream &o);
+  void run(raw_ostream &o);
 
   // runHeader - Emit a header fragment for the register info emitter.
-  void runHeader(std::ostream &o);
+  void runHeader(raw_ostream &o);
 
   // runEnums - Print out enum values for all of the registers.
-  void runEnums(std::ostream &o);
+  void runEnums(raw_ostream &o);
 };
 
 } // End llvm namespace
index a28e8bc3a4634697941bd03e1045c636f613883c..919ac664efa0e1df07756a8b48cb9ab21d8531c5 100644 (file)
@@ -22,7 +22,7 @@ using namespace llvm;
 //
 // Enumeration - Emit the specified class as an enumeration.
 //
-void SubtargetEmitter::Enumeration(std::ostream &OS,
+void SubtargetEmitter::Enumeration(raw_ostream &OS,
                                    const char *ClassName,
                                    bool isBits) {
   // Get all records of class and sort
@@ -57,7 +57,7 @@ void SubtargetEmitter::Enumeration(std::ostream &OS,
 // FeatureKeyValues - Emit data of all the subtarget features.  Used by the
 // command line.
 //
-void SubtargetEmitter::FeatureKeyValues(std::ostream &OS) {
+void SubtargetEmitter::FeatureKeyValues(raw_ostream &OS) {
   // Gather and sort all the features
   std::vector<Record*> FeatureList =
                            Records.getAllDerivedDefinitions("SubtargetFeature");
@@ -117,7 +117,7 @@ void SubtargetEmitter::FeatureKeyValues(std::ostream &OS) {
 // CPUKeyValues - Emit data of all the subtarget processors.  Used by command
 // line.
 //
-void SubtargetEmitter::CPUKeyValues(std::ostream &OS) {
+void SubtargetEmitter::CPUKeyValues(raw_ostream &OS) {
   // Gather and sort processor information
   std::vector<Record*> ProcessorList =
                           Records.getAllDerivedDefinitions("Processor");
@@ -172,7 +172,7 @@ void SubtargetEmitter::CPUKeyValues(std::ostream &OS) {
 // CollectAllItinClasses - Gathers and enumerates all the itinerary classes.
 // Returns itinerary class count.
 //
-unsigned SubtargetEmitter::CollectAllItinClasses(std::ostream &OS,
+unsigned SubtargetEmitter::CollectAllItinClasses(raw_ostream &OS,
                               std::map<std::string, unsigned> &ItinClassesMap) {
   // Gather and sort all itinerary classes
   std::vector<Record*> ItinClassList =
@@ -239,7 +239,7 @@ void SubtargetEmitter::FormItineraryString(Record *ItinData,
 // EmitStageData - Generate unique itinerary stages.  Record itineraries for 
 // processors.
 //
-void SubtargetEmitter::EmitStageData(std::ostream &OS,
+void SubtargetEmitter::EmitStageData(raw_ostream &OS,
        unsigned NItinClasses,
        std::map<std::string, unsigned> &ItinClassesMap, 
        std::vector<std::vector<InstrItinerary> > &ProcList) {
@@ -326,7 +326,7 @@ void SubtargetEmitter::EmitStageData(std::ostream &OS,
 //
 // EmitProcessorData - Generate data for processor itineraries.
 //
-void SubtargetEmitter::EmitProcessorData(std::ostream &OS,
+void SubtargetEmitter::EmitProcessorData(raw_ostream &OS,
       std::vector<std::vector<InstrItinerary> > &ProcList) {
   // Get an iterator for processor itinerary stages
   std::vector<std::vector<InstrItinerary> >::iterator
@@ -375,7 +375,7 @@ void SubtargetEmitter::EmitProcessorData(std::ostream &OS,
 //
 // EmitProcessorLookup - generate cpu name to itinerary lookup table.
 //
-void SubtargetEmitter::EmitProcessorLookup(std::ostream &OS) {
+void SubtargetEmitter::EmitProcessorLookup(raw_ostream &OS) {
   // Gather and sort processor information
   std::vector<Record*> ProcessorList =
                           Records.getAllDerivedDefinitions("Processor");
@@ -421,7 +421,7 @@ void SubtargetEmitter::EmitProcessorLookup(std::ostream &OS) {
 //
 // EmitData - Emits all stages and itineries, folding common patterns.
 //
-void SubtargetEmitter::EmitData(std::ostream &OS) {
+void SubtargetEmitter::EmitData(raw_ostream &OS) {
   std::map<std::string, unsigned> ItinClassesMap;
   std::vector<std::vector<InstrItinerary> > ProcList;
   
@@ -444,7 +444,7 @@ void SubtargetEmitter::EmitData(std::ostream &OS) {
 // ParseFeaturesFunction - Produces a subtarget specific function for parsing
 // the subtarget features string.
 //
-void SubtargetEmitter::ParseFeaturesFunction(std::ostream &OS) {
+void SubtargetEmitter::ParseFeaturesFunction(raw_ostream &OS) {
   std::vector<Record*> Features =
                        Records.getAllDerivedDefinitions("SubtargetFeature");
   std::sort(Features.begin(), Features.end(), LessRecord());
@@ -489,7 +489,7 @@ void SubtargetEmitter::ParseFeaturesFunction(std::ostream &OS) {
 //
 // SubtargetEmitter::run - Main subtarget enumeration emitter.
 //
-void SubtargetEmitter::run(std::ostream &OS) {
+void SubtargetEmitter::run(raw_ostream &OS) {
   Target = CodeGenTarget().getName();
 
   EmitSourceFileHeader("Subtarget Enumeration Source Fragment", OS);
index 4fcd8f8b0b24be5a539b0a48820a4bb5cf2902fb..f44278cc15fe74a18e5a7ae75a3a2c401fd17f5f 100644 (file)
@@ -29,27 +29,27 @@ class SubtargetEmitter : public TableGenBackend {
   std::string Target;
   bool HasItineraries;
   
-  void Enumeration(std::ostream &OS, const char *ClassName, bool isBits);
-  void FeatureKeyValues(std::ostream &OS);
-  void CPUKeyValues(std::ostream &OS);
-  unsigned CollectAllItinClasses(std::ostream &OS,
+  void Enumeration(raw_ostream &OS, const char *ClassName, bool isBits);
+  void FeatureKeyValues(raw_ostream &OS);
+  void CPUKeyValues(raw_ostream &OS);
+  unsigned CollectAllItinClasses(raw_ostream &OS,
                                std::map<std::string, unsigned> &ItinClassesMap);
   void FormItineraryString(Record *ItinData, std::string &ItinString,
                            unsigned &NStages);
-  void EmitStageData(std::ostream &OS, unsigned NItinClasses,
+  void EmitStageData(raw_ostream &OS, unsigned NItinClasses,
                      std::map<std::string, unsigned> &ItinClassesMap,
                      std::vector<std::vector<InstrItinerary> > &ProcList);
-  void EmitProcessorData(std::ostream &OS,
+  void EmitProcessorData(raw_ostream &OS,
                        std::vector<std::vector<InstrItinerary> > &ProcList);
-  void EmitProcessorLookup(std::ostream &OS);
-  void EmitData(std::ostream &OS);
-  void ParseFeaturesFunction(std::ostream &OS);
+  void EmitProcessorLookup(raw_ostream &OS);
+  void EmitData(raw_ostream &OS);
+  void ParseFeaturesFunction(raw_ostream &OS);
   
 public:
   SubtargetEmitter(RecordKeeper &R) : Records(R), HasItineraries(false) {}
 
   // run - Output the subtarget enumerations, returning true on failure.
-  void run(std::ostream &o);
+  void run(raw_ostream &o);
 
 };
 
index 04bbf3815205a7c3a9993d96559acc7d31a7cf68..4498e305b02879a550799ab4d4243bed8a07146f 100644 (file)
@@ -13,7 +13,6 @@
 
 #include "TGLexer.h"
 #include "llvm/Support/SourceMgr.h"
-#include "llvm/Support/Streams.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Config/config.h"
 #include <cctype>
index 1109defb75ebface19080d4f98a3a7bfe2d858f0..ba480e6e926b5d2192e48998c40d94b1d052fb05 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#include <algorithm>
-#include <sstream>
-
 #include "TGParser.h"
 #include "Record.h"
 #include "llvm/ADT/StringExtras.h"
-#include "llvm/Support/Streams.h"
+#include <algorithm>
+#include <sstream>
 using namespace llvm;
 
 //===----------------------------------------------------------------------===//
@@ -45,11 +43,11 @@ struct SubMultiClassReference {
 };
 
 void SubMultiClassReference::dump() const {
-  cerr << "Multiclass:\n";
+  errs() << "Multiclass:\n";
  
   MC->dump();
  
-  cerr << "Template args:\n";
+  errs() << "Template args:\n";
   for (std::vector<Init *>::const_iterator i = TemplateArgs.begin(),
          iend = TemplateArgs.end();
        i != iend;
index 8979e13f72baf95a78471fe8ca6e774e43f763a0..e4edca6cdc072ad11395536401917dbfc0d2f22c 100644 (file)
@@ -15,7 +15,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/CodeGen/ValueTypes.h"
-#include "llvm/Support/Streams.h"
 #include <map>
 #include <vector>
 using namespace llvm;
index fb80302c1e8d1ee72bc95eade455cd3cbd38d766..601581497a5590078415da3f7e34d3caf541c808 100644 (file)
 #include "Record.h"
 #include "TGParser.h"
 #include "llvm/Support/CommandLine.h"
-#include "llvm/Support/Streams.h"
 #include "llvm/System/Signals.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/raw_ostream.h"
 #include "CallingConvEmitter.h"
 #include "CodeEmitterGen.h"
 #include "RegisterInfoEmitter.h"
@@ -37,8 +37,6 @@
 #include "ClangDiagnosticsEmitter.h"
 #include <algorithm>
 #include <cstdio>
-#include <fstream>
-#include <ios>
 using namespace llvm;
 
 enum ActionType {
@@ -140,7 +138,8 @@ static bool ParseFile(const std::string &Filename,
   std::string ErrorStr;
   MemoryBuffer *F = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), &ErrorStr);
   if (F == 0) {
-    cerr << "Could not open input file '" + Filename + "': " << ErrorStr <<"\n";
+    errs() << "Could not open input file '" + Filename + "': " 
+           << ErrorStr <<"\n";
     return true;
   }
   
@@ -166,12 +165,14 @@ int main(int argc, char **argv) {
   if (ParseFile(InputFilename, IncludeDirs, SrcMgr))
     return 1;
 
-  std::ostream *Out = cout.stream();
+  raw_ostream *Out = &outs();
   if (OutputFilename != "-") {
-    Out = new std::ofstream(OutputFilename.c_str());
+    std::string Error;
+    Out = new raw_fd_ostream(OutputFilename.c_str(), false, Error);
 
-    if (!Out->good()) {
-      cerr << argv[0] << ": error opening " << OutputFilename << "!\n";
+    if (!Error.empty()) {
+      errs() << argv[0] << ": error opening " << OutputFilename 
+             << ":" << Error << "\n";
       return 1;
     }
 
@@ -246,23 +247,23 @@ int main(int argc, char **argv) {
       return 1;
     }
     
-    if (Out != cout.stream()) 
+    if (Out != &outs())
       delete Out;                               // Close the file
     return 0;
     
   } catch (const TGError &Error) {
-    cerr << argv[0] << ": error:\n";
+    errs() << argv[0] << ": error:\n";
     PrintError(Error.getLoc(), Error.getMessage());
     
   } catch (const std::string &Error) {
-    cerr << argv[0] << ": " << Error << "\n";
+    errs() << argv[0] << ": " << Error << "\n";
   } catch (const char *Error) {
-    cerr << argv[0] << ": " << Error << "\n";
+    errs() << argv[0] << ": " << Error << "\n";
   } catch (...) {
-    cerr << argv[0] << ": Unknown unexpected exception occurred.\n";
+    errs() << argv[0] << ": Unknown unexpected exception occurred.\n";
   }
   
-  if (Out != cout.stream()) {
+  if (Out != &outs()) {
     delete Out;                             // Close the file
     std::remove(OutputFilename.c_str());    // Remove the file, it's broken
   }
index 87a1b3da11969720a5a4923a95d660cdb8066242..b3e33b5f9c24d2186aab2928e0f47fa14cac380a 100644 (file)
@@ -16,7 +16,7 @@
 using namespace llvm;
 
 void TableGenBackend::EmitSourceFileHeader(const std::string &Desc,
-                                           std::ostream &OS) const {
+                                           raw_ostream &OS) const {
   OS << "//===- TableGen'erated file -------------------------------------*-"
        " C++ -*-===//\n//\n// " << Desc << "\n//\n// Automatically generate"
        "d file, do not edit!\n//\n//===------------------------------------"
index 109bc9f9ae8d00e7f41db669388584c14274634c..9c2b948b0dfc426b61cf488ee65e3d2332f67e6f 100644 (file)
@@ -15,8 +15,8 @@
 #ifndef TABLEGENBACKEND_H
 #define TABLEGENBACKEND_H
 
+#include "llvm/Support/raw_ostream.h"
 #include <string>
-#include <iosfwd>
 
 namespace llvm {
 
@@ -28,13 +28,13 @@ struct TableGenBackend {
 
   // run - All TableGen backends should implement the run method, which should
   // be the main entry point.
-  virtual void run(std::ostream &OS) = 0;
+  virtual void run(raw_ostream &OS) = 0;
 
 
 public:   // Useful helper routines...
   /// EmitSourceFileHeader - Output a LLVM style file header to the specified
   /// ostream.
-  void EmitSourceFileHeader(const std::string &Desc, std::ostream &OS) const;
+  void EmitSourceFileHeader(const std::string &Desc, raw_ostream &OS) const;
 
 };