Switch SubtargetFeature off of ostreams

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79864 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2009-08-23 21:41:43 +00:00
parent b683ea4712
commit e0c86afac6
2 changed files with 23 additions and 29 deletions

View File

@ -20,11 +20,11 @@
#include <string>
#include <vector>
#include <iosfwd>
#include <cstring>
#include "llvm/Support/DataTypes.h"
namespace llvm {
class raw_ostream;
//===----------------------------------------------------------------------===//
///
@ -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;

View File

@ -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 <algorithm>
#include <ostream>
#include <cassert>
#include <cctype>
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]
errs() << "'" << Features[0]
<< "' is not a recognized processor for this target"
<< " (ignoring processor)"
<< "\n";
<< " (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
errs() << "'" << Feature
<< "' is not a recognized feature for this target"
<< " (ignoring feature)"
<< "\n";
<< " (ignoring feature)\n";
}
}
@ -340,25 +337,23 @@ void *SubtargetFeatures::getInfo(const SubtargetInfoKV *Table,
if (Entry) {
return Entry->Value;
} else {
cerr << "'" << Features[0]
errs() << "'" << Features[0]
<< "' is not a recognized processor for this target"
<< " (ignoring processor)"
<< "\n";
<< " (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());
}