#include "llvm/Support/Debug.h"
#include "llvm/Support/MathExtras.h"
#include <algorithm>
+#include <iostream>
using namespace llvm;
static bool isIdentChar(char C) {
}
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();
/// 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();
-void AsmWriterEmitter::run(std::ostream &O) {
+void AsmWriterEmitter::run(raw_ostream &O) {
EmitSourceFileHeader("Assembly Writer Source Fragment", O);
CodeGenTarget Target;
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 {
#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");
}
-void CallingConvEmitter::EmitCallingConv(Record *CC, std::ostream &O) {
+void CallingConvEmitter::EmitCallingConv(Record *CC, raw_ostream &O) {
ListInit *CCActions = CC->getValueAsListInit("Actions");
Counter = 0;
}
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")) {
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;
};
}
#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"
// 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);
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;
: Records(R), Component(component) {}
// run - Output the .def file contents
- void run(std::ostream &OS);
+ void run(raw_ostream &OS);
};
class ClangDiagGroupsEmitter : public TableGenBackend {
public:
explicit ClangDiagGroupsEmitter(RecordKeeper &R) : Records(R) {}
- void run(std::ostream &OS);
+ void run(raw_ostream &OS);
};
}
-void CodeEmitterGen::run(std::ostream &o) {
+void CodeEmitterGen::run(raw_ostream &o) {
CodeGenTarget Target;
std::vector<Record*> Insts = Records.getAllDerivedDefinitions("Instruction");
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);
};
#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;
//===----------------------------------------------------------------------===//
x.SDTCisEltOfVec_Info.OtherOperandNum =
R->getValueAsInt("OtherOpNum");
} else {
- cerr << "Unrecognized SDTypeConstraint '" << R->getName() << "'!\n";
+ errs() << "Unrecognized SDTypeConstraint '" << R->getName() << "'!\n";
exit(1);
}
}
"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);
}
} 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);
}
}
if (isLeaf()) {
dump();
- cerr << " ";
+ errs() << " ";
TP.error("Type inference contradiction found in node!");
} else {
TP.error("Type inference contradiction found in node " +
}
-void TreePatternNode::print(std::ostream &OS) const {
+void TreePatternNode::print(raw_ostream &OS) const {
if (isLeaf()) {
OS << *getLeafValue();
} else {
}
void TreePatternNode::dump() const {
- print(*cerr.stream());
+ print(errs());
}
/// isIsomorphicTo - Return true if this node is recursively
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!");
}
}
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];
OS << "]\n";
}
-void TreePattern::dump() const { print(*cerr.stream()); }
+void TreePattern::dump() const { print(errs()); }
//===----------------------------------------------------------------------===//
// CodeGenDAGPatterns implementation
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;
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");
}
}
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.
/// 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.
/// pattern.
void error(const std::string &Msg) const;
- void print(std::ostream &OS) const;
+ void print(raw_ostream &OS) const;
void dump() const;
private:
#include "Record.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/Streams.h"
#include <algorithm>
using namespace llvm;
} 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);
}
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);
}
}
#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 {
#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 {
//===----------------------------------------------------------------------===//
// 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;
// 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
} else {
#ifndef NDEBUG
Child->dump();
- cerr << " ";
+ errs() << " ";
#endif
assert(0 && "Unknown leaf type!");
}
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();
}
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;
}
N->dump();
- cerr << "\n";
+ errs() << "\n";
throw std::string("Unknown node in result pattern!");
}
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;
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.
&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);
}
}
// 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);
}
}
<< "}\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);
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,
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
#include "FastISelEmitter.h"
#include "Record.h"
#include "llvm/Support/Debug.h"
-#include "llvm/Support/Streams.h"
#include "llvm/ADT/VectorExtras.h"
using namespace llvm;
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;
}
}
- 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;
}
}
- 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;
}
- 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] != "")
}
}
- 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];
}
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);
};
}
}
}
-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) {
}
}
-void FastISelEmitter::run(std::ostream &OS) {
+void FastISelEmitter::run(raw_ostream &OS) {
const CodeGenTarget &Target = CGP.getTargetInfo();
// Determine the target's namespace name.
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
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";
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
#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]) << ", ";
}
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, ";
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;
//===----------------------------------------------------------------------===//
// 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);
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.
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());
return;
}
- std::cerr << "Unhandled initializer: " << *Val << "\n";
+ errs() << "Unhandled initializer: " << *Val << "\n";
throw "In record '" + R->getName() + "' for TSFlag emission.";
}
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;
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,
// 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);
}
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) {
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)
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";
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";
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 << ")";
}
}
-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) {
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"));
}
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";
}
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";
/// 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)
/// 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";
}
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";
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.
/// 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);
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) {
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
#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>
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";
}
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();
}
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();
}
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";
}
}
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));
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));
// 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));
/// 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")
// 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"
/// 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;
/// 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);
: 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);
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;
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();
: 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);
// 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
/// 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"
/// 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";
}
/// 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";
/// 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";
/// 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!";
/// 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;
/// and emit registration code.
void EmitOptionDefinitions (const OptionDescriptions& descs,
bool HasSink, bool HasExterns,
- std::ostream& O)
+ raw_ostream& O)
{
std::vector<OptionDescription> Aliases;
}
/// 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";
/// 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();
/// 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"
/// 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) {
/// function.
void EmitPopulateCompilationGraph (const RecordVector& EdgeVector,
const ToolDescriptions& ToolDescs,
- std::ostream& O)
+ raw_ostream& O)
{
O << "void PopulateCompilationGraphLocal(CompilationGraph& G) {\n";
/// 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);
}
/// 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"
/// 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"
}
-void EmitPluginCode(const PluginData& Data, std::ostream& O) {
+void EmitPluginCode(const PluginData& Data, raw_ostream& O) {
// Emit file header.
EmitIncludes(O);
}
/// run - The back-end entry point.
-void LLVMCConfigurationEmitter::run (std::ostream &O) {
+void LLVMCConfigurationEmitter::run (raw_ostream &O) {
try {
PluginData Data;
explicit LLVMCConfigurationEmitter(RecordKeeper &R) : Records(R) {}
// run - Output the asmwriter, returning true on failure.
- void run(std::ostream &o);
+ void run(raw_ostream &o);
};
}
#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;
// 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!
// 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());
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)
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));
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;
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;
}
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;
}
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");
}
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();
}
-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();
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;
}
-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(),
#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;
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
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;
}
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
}
};
-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;
}
// 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;
};
}
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;
}
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.
};
-std::ostream &operator<<(std::ostream &OS, const RecordKeeper &RK);
+raw_ostream &operator<<(raw_ostream &OS, const RecordKeeper &RK);
extern RecordKeeper Records;
#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();
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();
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)
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();
}
// 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);
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);
}
}
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);
}
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);
}
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;
}
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
//
// 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
// 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");
// 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");
// 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 =
// 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) {
//
// 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
//
// 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");
//
// 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;
// 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());
//
// 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);
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);
};
#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>
//
//===----------------------------------------------------------------------===//
-#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;
//===----------------------------------------------------------------------===//
};
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;
//===----------------------------------------------------------------------===//
#include "llvm/CodeGen/ValueTypes.h"
-#include "llvm/Support/Streams.h"
#include <map>
#include <vector>
using namespace llvm;
#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"
#include "ClangDiagnosticsEmitter.h"
#include <algorithm>
#include <cstdio>
-#include <fstream>
-#include <ios>
using namespace llvm;
enum ActionType {
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;
}
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;
}
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
}
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//===------------------------------------"
#ifndef TABLEGENBACKEND_H
#define TABLEGENBACKEND_H
+#include "llvm/Support/raw_ostream.h"
#include <string>
-#include <iosfwd>
namespace llvm {
// 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;
};