From: Chris Lattner Date: Sun, 23 Aug 2009 21:41:43 +0000 (+0000) Subject: Switch SubtargetFeature off of ostreams X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=e0c86afac63a2dbbcff0ad79ed7b93d860451385;p=oota-llvm.git Switch SubtargetFeature off of ostreams git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79864 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Target/SubtargetFeature.h b/include/llvm/Target/SubtargetFeature.h index 5cfdc023d43..58333e2b424 100644 --- a/include/llvm/Target/SubtargetFeature.h +++ b/include/llvm/Target/SubtargetFeature.h @@ -20,12 +20,12 @@ #include #include -#include #include #include "llvm/Support/DataTypes.h" namespace llvm { - + class raw_ostream; + //===----------------------------------------------------------------------===// /// /// SubtargetFeatureKV - Used to provide key value pairs for feature and @@ -102,8 +102,7 @@ public: void *getInfo(const SubtargetInfoKV *Table, size_t TableSize); /// Print feature string. - void print(std::ostream &OS) const; - void print(std::ostream *OS) const { if (OS) print(*OS); } + void print(raw_ostream &OS) const; // Dump feature info. void dump() const; diff --git a/lib/Target/SubtargetFeature.cpp b/lib/Target/SubtargetFeature.cpp index f9370256c60..664a43cbcca 100644 --- a/lib/Target/SubtargetFeature.cpp +++ b/lib/Target/SubtargetFeature.cpp @@ -12,10 +12,9 @@ //===----------------------------------------------------------------------===// #include "llvm/Target/SubtargetFeature.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/ADT/StringExtras.h" -#include "llvm/Support/Streams.h" #include -#include #include #include using namespace llvm; @@ -145,22 +144,22 @@ static void Help(const SubtargetFeatureKV *CPUTable, size_t CPUTableSize, unsigned MaxFeatLen = getLongestEntryLength(FeatTable, FeatTableSize); // Print the CPU table. - cerr << "Available CPUs for this target:\n\n"; + errs() << "Available CPUs for this target:\n\n"; for (size_t i = 0; i != CPUTableSize; i++) - cerr << " " << CPUTable[i].Key + errs() << " " << CPUTable[i].Key << std::string(MaxCPULen - std::strlen(CPUTable[i].Key), ' ') << " - " << CPUTable[i].Desc << ".\n"; - cerr << "\n"; + errs() << "\n"; // Print the Feature table. - cerr << "Available features for this target:\n\n"; + errs() << "Available features for this target:\n\n"; for (size_t i = 0; i != FeatTableSize; i++) - cerr << " " << FeatTable[i].Key + errs() << " " << FeatTable[i].Key << std::string(MaxFeatLen - std::strlen(FeatTable[i].Key), ' ') << " - " << FeatTable[i].Desc << ".\n"; - cerr << "\n"; + errs() << "\n"; - cerr << "Use +feature to enable a feature, or -feature to disable it.\n" + errs() << "Use +feature to enable a feature, or -feature to disable it.\n" << "For example, llc -mcpu=mycpu -mattr=+feature1,-feature2\n"; exit(1); } @@ -283,10 +282,9 @@ uint32_t SubtargetFeatures::getBits(const SubtargetFeatureKV *CPUTable, SetImpliedBits(Bits, &FE, FeatureTable, FeatureTableSize); } } else { - cerr << "'" << Features[0] - << "' is not a recognized processor for this target" - << " (ignoring processor)" - << "\n"; + errs() << "'" << Features[0] + << "' is not a recognized processor for this target" + << " (ignoring processor)\n"; } // Iterate through each feature for (size_t i = 1; i < Features.size(); i++) { @@ -314,10 +312,9 @@ uint32_t SubtargetFeatures::getBits(const SubtargetFeatureKV *CPUTable, ClearImpliedBits(Bits, FeatureEntry, FeatureTable, FeatureTableSize); } } else { - cerr << "'" << Feature - << "' is not a recognized feature for this target" - << " (ignoring feature)" - << "\n"; + errs() << "'" << Feature + << "' is not a recognized feature for this target" + << " (ignoring feature)\n"; } } @@ -340,25 +337,23 @@ void *SubtargetFeatures::getInfo(const SubtargetInfoKV *Table, if (Entry) { return Entry->Value; } else { - cerr << "'" << Features[0] - << "' is not a recognized processor for this target" - << " (ignoring processor)" - << "\n"; + errs() << "'" << Features[0] + << "' is not a recognized processor for this target" + << " (ignoring processor)\n"; return NULL; } } /// print - Print feature string. /// -void SubtargetFeatures::print(std::ostream &OS) const { - for (size_t i = 0; i < Features.size(); i++) { +void SubtargetFeatures::print(raw_ostream &OS) const { + for (size_t i = 0, e = Features.size(); i != e; ++i) OS << Features[i] << " "; - } OS << "\n"; } /// dump - Dump feature info. /// void SubtargetFeatures::dump() const { - print(*cerr.stream()); + print(errs()); }