llvm.org GIT mirror llvm / 7184781
Have asm printers use formatted_raw_ostream directly to avoid a dynamic_cast<>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75670 91177308-0d34-0410-b5e6-96231b3b80d8 David Greene 11 years ago
67 changed file(s) with 280 addition(s) and 209 deletion(s). Raw diff Collapse all Expand all
3939 class Section;
4040 class TargetAsmInfo;
4141 class Type;
42 class raw_ostream;
42 class formatted_raw_ostream;
4343
4444 /// AsmPrinter - This class is intended to be used as a driving class for all
4545 /// asm writers.
6868 public:
6969 /// Output stream on which we're printing assembly code.
7070 ///
71 raw_ostream &O;
71 formatted_raw_ostream &O;
7272
7373 /// Target machine description.
7474 ///
117117 mutable DebugLocTuple PrevDLT;
118118
119119 protected:
120 explicit AsmPrinter(raw_ostream &o, TargetMachine &TM,
120 explicit AsmPrinter(formatted_raw_ostream &o, TargetMachine &TM,
121121 const TargetAsmInfo *T, bool V);
122122
123123 public:
2222 /// asm-specific constructs.
2323 ///
2424 class formatted_raw_ostream : public raw_ostream {
25 public:
26 /// DELETE_STREAM - Tell the destructor to delete the held stream.
27 ///
28 const static bool DELETE_STREAM = true;
29 /// PRESERVE_STREAM - Tell the destructor to not delete the held
30 /// stream.
31 ///
32 const static bool PRESERVE_STREAM = false;
33
2534 private:
2635 /// TheStream - The real stream we output to.
2736 ///
2837 raw_ostream &TheStream;
38 /// DeleteStream - Do we need to delete TheStream in the
39 /// destructor?
40 ///
41 bool DeleteStream;
2942
3043 /// Column - The current output column of the stream. The column
3144 /// scheme is zero-based.
6073 /// stream will use stdout instead.
6174 /// \param Binary - The file should be opened in binary mode on
6275 /// platforms that support this distinction.
63 formatted_raw_ostream(raw_ostream &Stream)
64 : raw_ostream(), TheStream(Stream), Column(0) {}
76 formatted_raw_ostream(raw_ostream &Stream, bool Delete = false)
77 : raw_ostream(), TheStream(Stream), DeleteStream(Delete), Column(0) {}
78
79 ~formatted_raw_ostream() {
80 if (DeleteStream)
81 delete &TheStream;
82 }
6583
6684 /// PadToColumn - Align the output to some column number.
6785 ///
7189 ///
7290 void PadToColumn(unsigned NewCol, unsigned MinPad = 0);
7391 };
74 }
92
93 /// fouts() - This returns a reference to a formatted_raw_ostream for
94 /// standard output. Use it like: fouts() << "foo" << "bar";
95 formatted_raw_ostream &fouts();
96
97 /// ferrs() - This returns a reference to a formatted_raw_ostream for
98 /// standard error. Use it like: ferrs() << "foo" << "bar";
99 formatted_raw_ostream &ferrs();
100
101 } // end llvm namespace
102
75103
76104 #endif
3636 class Pass;
3737 class TargetMachOWriterInfo;
3838 class TargetELFWriterInfo;
39 class raw_ostream;
39 class formatted_raw_ostream;
4040
4141 // Relocation model types.
4242 namespace Reloc {
231231 /// is not supported.
232232 ///
233233 virtual FileModel::Model addPassesToEmitFile(PassManagerBase &,
234 raw_ostream &,
234 formatted_raw_ostream &,
235235 CodeGenFileType,
236236 CodeGenOpt::Level) {
237237 return FileModel::None;
295295 /// require having the entire module at once. This is not recommended, do not
296296 /// use this.
297297 virtual bool WantsWholeFile() const { return false; }
298 virtual bool addPassesToEmitWholeFile(PassManager &, raw_ostream &,
298 virtual bool addPassesToEmitWholeFile(PassManager &, formatted_raw_ostream &,
299299 CodeGenFileType,
300300 CodeGenOpt::Level) {
301301 return true;
328328 /// target-specific passes in standard locations.
329329 ///
330330 virtual FileModel::Model addPassesToEmitFile(PassManagerBase &PM,
331 raw_ostream &Out,
331 formatted_raw_ostream &Out,
332332 CodeGenFileType FileType,
333333 CodeGenOpt::Level);
334334
412412 /// the asmprinter, if asm emission is supported. If this is not supported,
413413 /// 'true' should be returned.
414414 virtual bool addAssemblyEmitter(PassManagerBase &, CodeGenOpt::Level,
415 bool /* VerboseAsmDefault */, raw_ostream &) {
415 bool /* VerboseAsmDefault */,
416 formatted_raw_ostream &) {
416417 return true;
417418 }
418419
2525 #include "llvm/Support/ErrorHandling.h"
2626 #include "llvm/Support/FormattedStream.h"
2727 #include "llvm/Support/Mangler.h"
28 #include "llvm/Support/raw_ostream.h"
28 #include "llvm/Support/FormattedStream.h"
2929 #include "llvm/Target/TargetAsmInfo.h"
3030 #include "llvm/Target/TargetData.h"
3131 #include "llvm/Target/TargetLowering.h"
4242 cl::init(cl::BOU_UNSET));
4343
4444 char AsmPrinter::ID = 0;
45 AsmPrinter::AsmPrinter(raw_ostream &o, TargetMachine &tm,
45 AsmPrinter::AsmPrinter(formatted_raw_ostream &o, TargetMachine &tm,
4646 const TargetAsmInfo *T, bool VDef)
4747 : MachineFunctionPass(&ID), FunctionNumber(0), O(o),
4848 TM(tm), TAI(T), TRI(tm.getRegisterInfo()),
735735
736736 /// printStringChar - Print a char, escaped if necessary.
737737 ///
738 static void printStringChar(raw_ostream &O, unsigned char C) {
738 static void printStringChar(formatted_raw_ostream &O, unsigned char C) {
739739 if (C == '"') {
740740 O << "\\\"";
741741 } else if (C == '\\') {
977977 /// printAsCString - Print the specified array as a C compatible string, only if
978978 /// the predicate isString is true.
979979 ///
980 static void printAsCString(raw_ostream &O, const ConstantArray *CVA,
980 static void printAsCString(formatted_raw_ostream &O, const ConstantArray *CVA,
981981 unsigned LastElt) {
982982 assert(CVA->isString() && "Array is not string compatible!");
983983
2121 #include "llvm/Target/TargetAsmInfo.h"
2222 #include "llvm/Transforms/Scalar.h"
2323 #include "llvm/Support/CommandLine.h"
24 #include "llvm/Support/raw_ostream.h"
24 #include "llvm/Support/FormattedStream.h"
2525 using namespace llvm;
2626
2727 namespace llvm {
5555
5656 FileModel::Model
5757 LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
58 raw_ostream &Out,
58 formatted_raw_ostream &Out,
5959 CodeGenFileType FileType,
6060 CodeGenOpt::Level OptLevel) {
6161 // Add common CodeGen passes.
5454 }
5555 }
5656
57 /// fouts() - This returns a reference to a formatted_raw_ostream for
58 /// standard output. Use it like: fouts() << "foo" << "bar";
59 formatted_raw_ostream &llvm::fouts() {
60 static formatted_raw_ostream S(outs());
61 return S;
62 }
63
64 /// ferrs() - This returns a reference to a formatted_raw_ostream for
65 /// standard error. Use it like: ferrs() << "foo" << "bar";
66 formatted_raw_ostream &llvm::ferrs() {
67 static formatted_raw_ostream S(errs());
68 return S;
69 }
165165 case 0: break;
166166 default:
167167 // Normally the string to emit is shorter than the buffer.
168 if (Size <= unsigned(OutBufEnd-OutBufStart)) {
168 if (Size <= unsigned(OutBufEnd-OutBufCur)) {
169169 memcpy(OutBufCur, Ptr, Size);
170170 break;
171171 }
2525 class MachineCodeEmitter;
2626 class JITCodeEmitter;
2727 class ObjectCodeEmitter;
28 class raw_ostream;
28 class formatted_raw_ostream;
2929
3030 // Enums corresponding to ARM condition codes
3131 namespace ARMCC {
9292 }
9393
9494 FunctionPass *createARMISelDag(ARMBaseTargetMachine &TM);
95 FunctionPass *createARMCodePrinterPass(raw_ostream &O,
95 FunctionPass *createARMCodePrinterPass(formatted_raw_ostream &O,
9696 ARMBaseTargetMachine &TM,
9797 bool Verbose);
9898 FunctionPass *createARMCodeEmitterPass(ARMBaseTargetMachine &TM,
1717 #include "llvm/PassManager.h"
1818 #include "llvm/CodeGen/Passes.h"
1919 #include "llvm/Support/CommandLine.h"
20 #include "llvm/Support/raw_ostream.h"
20 #include "llvm/Support/FormattedStream.h"
2121 #include "llvm/Target/TargetMachineRegistry.h"
2222 #include "llvm/Target/TargetOptions.h"
2323 using namespace llvm;
182182 bool ARMBaseTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
183183 CodeGenOpt::Level OptLevel,
184184 bool Verbose,
185 raw_ostream &Out) {
185 formatted_raw_ostream &Out) {
186186 // Output assembly language.
187187 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
188188 if (AsmPrinterCtor)
205205 if (DumpAsm) {
206206 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
207207 if (AsmPrinterCtor)
208 PM.add(AsmPrinterCtor(errs(), *this, true));
208 PM.add(AsmPrinterCtor(ferrs(), *this, true));
209209 }
210210
211211 return false;
224224 if (DumpAsm) {
225225 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
226226 if (AsmPrinterCtor)
227 PM.add(AsmPrinterCtor(errs(), *this, true));
227 PM.add(AsmPrinterCtor(ferrs(), *this, true));
228228 }
229229
230230 return false;
243243 if (DumpAsm) {
244244 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
245245 if (AsmPrinterCtor)
246 PM.add(AsmPrinterCtor(errs(), *this, true));
246 PM.add(AsmPrinterCtor(ferrs(), *this, true));
247247 }
248248
249249 return false;
258258 if (DumpAsm) {
259259 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
260260 if (AsmPrinterCtor)
261 PM.add(AsmPrinterCtor(errs(), *this, true));
261 PM.add(AsmPrinterCtor(ferrs(), *this, true));
262262 }
263263
264264 return false;
273273 if (DumpAsm) {
274274 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
275275 if (AsmPrinterCtor)
276 PM.add(AsmPrinterCtor(errs(), *this, true));
276 PM.add(AsmPrinterCtor(ferrs(), *this, true));
277277 }
278278
279279 return false;
288288 if (DumpAsm) {
289289 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
290290 if (AsmPrinterCtor)
291 PM.add(AsmPrinterCtor(errs(), *this, true));
292 }
293
294 return false;
295 }
296
291 PM.add(AsmPrinterCtor(ferrs(), *this, true));
292 }
293
294 return false;
295 }
296
4040 protected:
4141 // To avoid having target depend on the asmprinter stuff libraries, asmprinter
4242 // set this functions to ctor pointer at startup time if they are linked in.
43 typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
43 typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
4444 ARMBaseTargetMachine &tm,
4545 bool verbose);
4646 static AsmPrinterCtorFn AsmPrinterCtor;
7070 virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
7171 virtual bool addAssemblyEmitter(PassManagerBase &PM,
7272 CodeGenOpt::Level OptLevel,
73 bool Verbose, raw_ostream &Out);
73 bool Verbose, formatted_raw_ostream &Out);
7474 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
7575 bool DumpAsm, MachineCodeEmitter &MCE);
7676 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
3737 #include "llvm/Support/ErrorHandling.h"
3838 #include "llvm/Support/Mangler.h"
3939 #include "llvm/Support/MathExtras.h"
40 #include "llvm/Support/raw_ostream.h"
40 #include "llvm/Support/FormattedStream.h"
4141 #include
4242 using namespace llvm;
4343
8181 /// True if asm printer is printing a series of CONSTPOOL_ENTRY.
8282 bool InCPMode;
8383 public:
84 explicit ARMAsmPrinter(raw_ostream &O, TargetMachine &TM,
84 explicit ARMAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
8585 const TargetAsmInfo *T, bool V)
8686 : AsmPrinter(O, TM, T, V), DW(0), AFI(NULL), MCP(NULL),
8787 InCPMode(false) {
370370 }
371371 }
372372
373 static void printSOImm(raw_ostream &O, int64_t V, bool VerboseAsm,
373 static void printSOImm(formatted_raw_ostream &O, int64_t V, bool VerboseAsm,
374374 const TargetAsmInfo *TAI) {
375375 // Break it up into two parts that make up a shifter immediate.
376376 V = ARM_AM::getSOImmVal(V);
10121012
10131013 /// PrintUnmangledNameSafely - Print out the printable characters in the name.
10141014 /// Don't print things like \\n or \\0.
1015 static void PrintUnmangledNameSafely(const Value *V, raw_ostream &OS) {
1015 static void PrintUnmangledNameSafely(const Value *V, formatted_raw_ostream &OS) {
10161016 for (const char *Name = V->getNameStart(), *E = Name+V->getNameLen();
10171017 Name != E; ++Name)
10181018 if (isprint(*Name))
12521252 /// using the given target machine description. This should work
12531253 /// regardless of whether the function is in SSA form.
12541254 ///
1255 FunctionPass *llvm::createARMCodePrinterPass(raw_ostream &o,
1255 FunctionPass *llvm::createARMCodePrinterPass(formatted_raw_ostream &o,
12561256 ARMBaseTargetMachine &tm,
12571257 bool verbose) {
12581258 return new ARMAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
2222 class FunctionPass;
2323 class MachineCodeEmitter;
2424 class ObjectCodeEmitter;
25 class raw_ostream;
25 class formatted_raw_ostream;
2626
2727 FunctionPass *createAlphaISelDag(AlphaTargetMachine &TM);
28 FunctionPass *createAlphaCodePrinterPass(raw_ostream &OS,
28 FunctionPass *createAlphaCodePrinterPass(formatted_raw_ostream &OS,
2929 TargetMachine &TM,
3030 bool Verbose);
3131 FunctionPass *createAlphaPatternInstructionSelector(TargetMachine &TM);
1616 #include "llvm/Module.h"
1717 #include "llvm/PassManager.h"
1818 #include "llvm/Target/TargetMachineRegistry.h"
19 #include "llvm/Support/raw_ostream.h"
19 #include "llvm/Support/FormattedStream.h"
2020
2121 using namespace llvm;
2222
8888 bool AlphaTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
8989 CodeGenOpt::Level OptLevel,
9090 bool Verbose,
91 raw_ostream &Out) {
91 formatted_raw_ostream &Out) {
9292 PM.add(createAlphaLLRPPass(*this));
9393 // Output assembly language.
9494 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
103103 if (DumpAsm) {
104104 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
105105 if (AsmPrinterCtor)
106 PM.add(AsmPrinterCtor(errs(), *this, true));
106 PM.add(AsmPrinterCtor(ferrs(), *this, true));
107107 }
108108 return false;
109109 }
114114 if (DumpAsm) {
115115 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
116116 if (AsmPrinterCtor)
117 PM.add(AsmPrinterCtor(errs(), *this, true));
117 PM.add(AsmPrinterCtor(ferrs(), *this, true));
118118 }
119119 return false;
120120 }
125125 if (DumpAsm) {
126126 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
127127 if (AsmPrinterCtor)
128 PM.add(AsmPrinterCtor(errs(), *this, true));
128 PM.add(AsmPrinterCtor(ferrs(), *this, true));
129129 }
130130 return false;
131131 }
3838
3939 // To avoid having target depend on the asmprinter stuff libraries, asmprinter
4040 // set this functions to ctor pointer at startup time if they are linked in.
41 typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
41 typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
4242 TargetMachine &tm,
4343 bool verbose);
4444 static AsmPrinterCtorFn AsmPrinterCtor;
6868 virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
6969 virtual bool addAssemblyEmitter(PassManagerBase &PM,
7070 CodeGenOpt::Level OptLevel,
71 bool Verbose, raw_ostream &Out);
71 bool Verbose, formatted_raw_ostream &Out);
7272 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
7373 bool DumpAsm, MachineCodeEmitter &MCE);
7474 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
2626 #include "llvm/Support/Compiler.h"
2727 #include "llvm/Support/ErrorHandling.h"
2828 #include "llvm/Support/Mangler.h"
29 #include "llvm/Support/raw_ostream.h"
29 #include "llvm/Support/FormattedStream.h"
3030 #include "llvm/ADT/Statistic.h"
3131 using namespace llvm;
3232
3737 /// Unique incrementer for label values for referencing Global values.
3838 ///
3939
40 explicit AlphaAsmPrinter(raw_ostream &o, TargetMachine &tm,
40 explicit AlphaAsmPrinter(formatted_raw_ostream &o, TargetMachine &tm,
4141 const TargetAsmInfo *T, bool V)
4242 : AsmPrinter(o, tm, T, V) {}
4343
6767 /// using the given target machine description. This should work
6868 /// regardless of whether the function is in SSA form.
6969 ///
70 FunctionPass *llvm::createAlphaCodePrinterPass(raw_ostream &o,
70 FunctionPass *llvm::createAlphaCodePrinterPass(formatted_raw_ostream &o,
7171 TargetMachine &tm,
7272 bool verbose) {
7373 return new AlphaAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
3535 #include "llvm/Support/CallSite.h"
3636 #include "llvm/Support/CFG.h"
3737 #include "llvm/Support/ErrorHandling.h"
38 #include "llvm/Support/FormattedStream.h"
3839 #include "llvm/Support/GetElementPtrTypeIterator.h"
3940 #include "llvm/Support/InstVisitor.h"
4041 #include "llvm/Support/Mangler.h"
4142 #include "llvm/Support/MathExtras.h"
42 #include "llvm/Support/raw_ostream.h"
4343 #include "llvm/ADT/StringExtras.h"
4444 #include "llvm/ADT/STLExtras.h"
4545 #include "llvm/Support/MathExtras.h"
8888 /// CWriter - This class is the main chunk of code that converts an LLVM
8989 /// module to a C translation unit.
9090 class CWriter : public FunctionPass, public InstVisitor {
91 raw_ostream &Out;
91 formatted_raw_ostream &Out;
9292 IntrinsicLowering *IL;
9393 Mangler *Mang;
9494 LoopInfo *LI;
106106
107107 public:
108108 static char ID;
109 explicit CWriter(raw_ostream &o)
109 explicit CWriter(formatted_raw_ostream &o)
110110 : FunctionPass(&ID), Out(o), IL(0), Mang(0), LI(0),
111111 TheModule(0), TAsm(0), TD(0), OpaqueCounter(0), NextAnonValueNumber(0) {
112112 FPCounter = 0;
151151 return false;
152152 }
153153
154 raw_ostream &printType(raw_ostream &Out, const Type *Ty,
155 bool isSigned = false,
156 const std::string &VariableName = "",
157 bool IgnoreName = false,
158 const AttrListPtr &PAL = AttrListPtr());
154 raw_ostream &printType(formatted_raw_ostream &Out,
155 const Type *Ty,
156 bool isSigned = false,
157 const std::string &VariableName = "",
158 bool IgnoreName = false,
159 const AttrListPtr &PAL = AttrListPtr());
159160 std::ostream &printType(std::ostream &Out, const Type *Ty,
160161 bool isSigned = false,
161162 const std::string &VariableName = "",
162163 bool IgnoreName = false,
163164 const AttrListPtr &PAL = AttrListPtr());
164 raw_ostream &printSimpleType(raw_ostream &Out, const Type *Ty,
165 bool isSigned,
166 const std::string &NameSoFar = "");
165 raw_ostream &printSimpleType(formatted_raw_ostream &Out,
166 const Type *Ty,
167 bool isSigned,
168 const std::string &NameSoFar = "");
167169 std::ostream &printSimpleType(std::ostream &Out, const Type *Ty,
168170 bool isSigned,
169171 const std::string &NameSoFar = "");
170172
171 void printStructReturnPointerFunctionType(raw_ostream &Out,
173 void printStructReturnPointerFunctionType(formatted_raw_ostream &Out,
172174 const AttrListPtr &PAL,
173175 const PointerType *Ty);
174176
434436 /// printStructReturnPointerFunctionType - This is like printType for a struct
435437 /// return type, except, instead of printing the type as void (*)(Struct*, ...)
436438 /// print it as "Struct (*)(...)", for struct return functions.
437 void CWriter::printStructReturnPointerFunctionType(raw_ostream &Out,
439 void CWriter::printStructReturnPointerFunctionType(formatted_raw_ostream &Out,
438440 const AttrListPtr &PAL,
439441 const PointerType *TheTy) {
440442 const FunctionType *FTy = cast(TheTy->getElementType());
470472 }
471473
472474 raw_ostream &
473 CWriter::printSimpleType(raw_ostream &Out, const Type *Ty, bool isSigned,
475 CWriter::printSimpleType(formatted_raw_ostream &Out, const Type *Ty,
476 bool isSigned,
474477 const std::string &NameSoFar) {
475478 assert((Ty->isPrimitiveType() || Ty->isInteger() || isa(Ty)) &&
476479 "Invalid type for printSimpleType");
566569 // Pass the Type* and the variable name and this prints out the variable
567570 // declaration.
568571 //
569 raw_ostream &CWriter::printType(raw_ostream &Out, const Type *Ty,
570 bool isSigned, const std::string &NameSoFar,
571 bool IgnoreName, const AttrListPtr &PAL) {
572 raw_ostream &CWriter::printType(formatted_raw_ostream &Out,
573 const Type *Ty,
574 bool isSigned, const std::string &NameSoFar,
575 bool IgnoreName, const AttrListPtr &PAL) {
572576 if (Ty->isPrimitiveType() || Ty->isInteger() || isa(Ty)) {
573577 printSimpleType(Out, Ty, isSigned, NameSoFar);
574578 return Out;
16391643 // generateCompilerSpecificCode - This is where we add conditional compilation
16401644 // directives to cater to specific compilers as need be.
16411645 //
1642 static void generateCompilerSpecificCode(raw_ostream& Out,
1646 static void generateCompilerSpecificCode(formatted_raw_ostream& Out,
16431647 const TargetData *TD) {
16441648 // Alloca is hard to get, and we don't want to include stdlib.h here.
16451649 Out << "/* get a declaration for alloca */\n"
36253629 //===----------------------------------------------------------------------===//
36263630
36273631 bool CTargetMachine::addPassesToEmitWholeFile(PassManager &PM,
3628 raw_ostream &o,
3632 formatted_raw_ostream &o,
36293633 CodeGenFileType FileType,
36303634 CodeGenOpt::Level OptLevel) {
36313635 if (FileType != TargetMachine::AssemblyFile) return true;
2525 : DataLayout(&M) {}
2626
2727 virtual bool WantsWholeFile() const { return true; }
28 virtual bool addPassesToEmitWholeFile(PassManager &PM, raw_ostream &Out,
28 virtual bool addPassesToEmitWholeFile(PassManager &PM,
29 formatted_raw_ostream &Out,
2930 CodeGenFileType FileType,
3031 CodeGenOpt::Level OptLevel);
3132
3131 #include "llvm/Support/Debug.h"
3232 #include "llvm/Support/ErrorHandling.h"
3333 #include "llvm/Support/Compiler.h"
34 #include "llvm/Support/raw_ostream.h"
34 #include "llvm/Support/FormattedStream.h"
3535 #include "llvm/Target/TargetAsmInfo.h"
3636 #include "llvm/Target/TargetRegisterInfo.h"
3737 #include "llvm/Target/TargetInstrInfo.h"
4949 class VISIBILITY_HIDDEN SPUAsmPrinter : public AsmPrinter {
5050 std::set FnStubs, GVStubs;
5151 public:
52 explicit SPUAsmPrinter(raw_ostream &O, TargetMachine &TM,
52 explicit SPUAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
5353 const TargetAsmInfo *T, bool V) :
5454 AsmPrinter(O, TM, T, V) {}
5555
288288 class VISIBILITY_HIDDEN LinuxAsmPrinter : public SPUAsmPrinter {
289289 DwarfWriter *DW;
290290 public:
291 explicit LinuxAsmPrinter(raw_ostream &O, SPUTargetMachine &TM,
291 explicit LinuxAsmPrinter(formatted_raw_ostream &O, SPUTargetMachine &TM,
292292 const TargetAsmInfo *T, bool V)
293293 : SPUAsmPrinter(O, TM, T, V), DW(0) {}
294294
491491
492492 /// PrintUnmangledNameSafely - Print out the printable characters in the name.
493493 /// Don't print things like \\n or \\0.
494 static void PrintUnmangledNameSafely(const Value *V, raw_ostream &OS) {
494 static void PrintUnmangledNameSafely(const Value *V, formatted_raw_ostream &OS) {
495495 for (const char *Name = V->getNameStart(), *E = Name+V->getNameLen();
496496 Name != E; ++Name)
497497 if (isprint(*Name))
597597 /// assembly code for a MachineFunction to the given output stream, in a format
598598 /// that the Linux SPU assembler can deal with.
599599 ///
600 FunctionPass *llvm::createSPUAsmPrinterPass(raw_ostream &o,
600 FunctionPass *llvm::createSPUAsmPrinterPass(formatted_raw_ostream &o,
601601 SPUTargetMachine &tm,
602602 bool verbose) {
603603 return new LinuxAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
2020 namespace llvm {
2121 class SPUTargetMachine;
2222 class FunctionPass;
23 class raw_ostream;
23 class formatted_raw_ostream;
2424
2525 FunctionPass *createSPUISelDag(SPUTargetMachine &TM);
26 FunctionPass *createSPUAsmPrinterPass(raw_ostream &o,
26 FunctionPass *createSPUAsmPrinterPass(formatted_raw_ostream &o,
2727 SPUTargetMachine &tm,
2828 bool verbose);
2929
8989 bool SPUTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
9090 CodeGenOpt::Level OptLevel,
9191 bool Verbose,
92 raw_ostream &Out) {
92 formatted_raw_ostream &Out) {
9393 // Output assembly language.
9494 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
9595 if (AsmPrinterCtor)
4040
4141 // To avoid having target depend on the asmprinter stuff libraries, asmprinter
4242 // set this functions to ctor pointer at startup time if they are linked in.
43 typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
43 typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
4444 SPUTargetMachine &tm,
4545 bool verbose);
4646 static AsmPrinterCtorFn AsmPrinterCtor;
9393 CodeGenOpt::Level OptLevel);
9494 virtual bool addAssemblyEmitter(PassManagerBase &PM,
9595 CodeGenOpt::Level OptLevel,
96 bool Verbose, raw_ostream &Out);
96 bool Verbose, formatted_raw_ostream &Out);
9797
9898 static void registerAsmPrinter(AsmPrinterCtorFn F) {
9999 AsmPrinterCtor = F;
2828 #include "llvm/ADT/SmallPtrSet.h"
2929 #include "llvm/Support/CommandLine.h"
3030 #include "llvm/Support/ErrorHandling.h"
31 #include "llvm/Support/FormattedStream.h"
3132 #include "llvm/Support/Streams.h"
32 #include "llvm/Support/raw_ostream.h"
3333 #include "llvm/Config/config.h"
3434 #include
3535 #include
9797 /// CppWriter - This class is the main chunk of code that converts an LLVM
9898 /// module to a C++ translation unit.
9999 class CppWriter : public ModulePass {
100 raw_ostream &Out;
100 formatted_raw_ostream &Out;
101101 const Module *TheModule;
102102 uint64_t uniqueNum;
103103 TypeMap TypeNames;
112112
113113 public:
114114 static char ID;
115 explicit CppWriter(raw_ostream &o) :
115 explicit CppWriter(formatted_raw_ostream &o) :
116116 ModulePass(&ID), Out(o), uniqueNum(0), is_inline(false) {}
117117
118118 virtual const char *getPassName() const { return "C++ backend"; }
165165 };
166166
167167 static unsigned indent_level = 0;
168 inline raw_ostream& nl(raw_ostream& Out, int delta = 0) {
168 inline formatted_raw_ostream& nl(formatted_raw_ostream& Out, int delta = 0) {
169169 Out << "\n";
170170 if (delta >= 0 || indent_level >= unsigned(-delta))
171171 indent_level += delta;
18061806 Out << "#include \n";
18071807 Out << "#include \n";
18081808 Out << "#include \n";
1809 Out << "#include \n";
18091810 Out << "#include \n";
1810 Out << "#include \n";
18111811 Out << "#include \n";
18121812 Out << "#include \n";
18131813 Out << "#include \n";
20122012 //===----------------------------------------------------------------------===//
20132013
20142014 bool CPPTargetMachine::addPassesToEmitWholeFile(PassManager &PM,
2015 raw_ostream &o,
2015 formatted_raw_ostream &o,
20162016 CodeGenFileType FileType,
20172017 CodeGenOpt::Level OptLevel) {
20182018 if (FileType != TargetMachine::AssemblyFile) return true;
1818
1919 namespace llvm {
2020
21 class raw_ostream;
21 class formatted_raw_ostream;
2222
2323 struct CPPTargetMachine : public TargetMachine {
2424 const TargetData DataLayout; // Calculates type size & alignment
2727 : DataLayout(&M) {}
2828
2929 virtual bool WantsWholeFile() const { return true; }
30 virtual bool addPassesToEmitWholeFile(PassManager &PM, raw_ostream &Out,
30 virtual bool addPassesToEmitWholeFile(PassManager &PM,
31 formatted_raw_ostream &Out,
3132 CodeGenFileType FileType,
3233 CodeGenOpt::Level OptLevel);
3334
2626 #include "llvm/CodeGen/MachineFunctionPass.h"
2727 #include "llvm/Target/TargetAsmInfo.h"
2828 #include "llvm/Support/ErrorHandling.h"
29 #include "llvm/Support/FormattedStream.h"
2930 #include "llvm/Support/Mangler.h"
30 #include "llvm/Support/raw_ostream.h"
3131 #include "llvm/ADT/Statistic.h"
3232 using namespace llvm;
3333
3737 class IA64AsmPrinter : public AsmPrinter {
3838 std::set ExternalFunctionNames, ExternalObjectNames;
3939 public:
40 explicit IA64AsmPrinter(raw_ostream &O, TargetMachine &TM,
40 explicit IA64AsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
4141 const TargetAsmInfo *T, bool V)
4242 : AsmPrinter(O, TM, T, V) {}
4343
367367 /// assembly code for a MachineFunction to the given output stream, using
368368 /// the given target machine description.
369369 ///
370 FunctionPass *llvm::createIA64CodePrinterPass(raw_ostream &o,
370 FunctionPass *llvm::createIA64CodePrinterPass(formatted_raw_ostream &o,
371371 IA64TargetMachine &tm,
372372 bool verbose) {
373373 return new IA64AsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
1919
2020 class IA64TargetMachine;
2121 class FunctionPass;
22 class raw_ostream;
22 class formatted_raw_ostream;
2323
2424 /// createIA64DAGToDAGInstructionSelector - This pass converts an LLVM
2525 /// function into IA64 machine code in a sane, DAG->DAG transform.
3636 /// using the given target machine description. This should work
3737 /// regardless of whether the function is in SSA form.
3838 ///
39 FunctionPass *createIA64CodePrinterPass(raw_ostream &o,
39 FunctionPass *createIA64CodePrinterPass(formatted_raw_ostream &o,
4040 IA64TargetMachine &tm,
4141 bool verbose);
4242
8686 bool IA64TargetMachine::addAssemblyEmitter(PassManagerBase &PM,
8787 CodeGenOpt::Level OptLevel,
8888 bool Verbose,
89 raw_ostream &Out) {
89 formatted_raw_ostream &Out) {
9090 // Output assembly language.
9191 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
9292 if (AsmPrinterCtor)
3535
3636 // To avoid having target depend on the asmprinter stuff libraries, asmprinter
3737 // set this functions to ctor pointer at startup time if they are linked in.
38 typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
38 typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
3939 IA64TargetMachine &tm,
4040 bool verbose);
4141 static AsmPrinterCtorFn AsmPrinterCtor;
6161 virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
6262 virtual bool addAssemblyEmitter(PassManagerBase &PM,
6363 CodeGenOpt::Level OptLevel,
64 bool Verbose, raw_ostream &Out);
64 bool Verbose, formatted_raw_ostream &Out);
6565
6666 static void registerAsmPrinter(AsmPrinterCtorFn F) {
6767 AsmPrinterCtor = F;
3434 : DataLayout(&M) {}
3535
3636 virtual bool WantsWholeFile() const { return true; }
37 virtual bool addPassesToEmitWholeFile(PassManager &PM, raw_ostream &Out,
37 virtual bool addPassesToEmitWholeFile(PassManager &PM,
38 formatted_raw_ostream &Out,
3839 CodeGenFileType FileType,
3940 CodeGenOpt::Level OptLevel);
4041
17011702 // External Interface declaration
17021703 //===----------------------------------------------------------------------===//
17031704
1704 bool MSILTarget::addPassesToEmitWholeFile(PassManager &PM, raw_ostream &o,
1705 bool MSILTarget::addPassesToEmitWholeFile(PassManager &PM,
1706 formatted_raw_ostream &o,
17051707 CodeGenFileType FileType,
17061708 CodeGenOpt::Level OptLevel)
17071709 {
2020 #include "llvm/PassManager.h"
2121 #include "llvm/Analysis/FindUsedTypes.h"
2222 #include "llvm/Analysis/LoopInfo.h"
23 #include "llvm/Support/FormattedStream.h"
2324 #include "llvm/Support/GetElementPtrTypeIterator.h"
24 #include "llvm/Support/raw_ostream.h"
2525 #include "llvm/Target/TargetData.h"
2626 #include "llvm/Target/TargetMachine.h"
2727 #include "llvm/Target/TargetMachineRegistry.h"
7474 }
7575
7676 public:
77 raw_ostream &Out;
77 formatted_raw_ostream &Out;
7878 Module* ModulePtr;
7979 const TargetData* TD;
8080 Mangler* Mang;
8484 StaticInitList;
8585 const std::set* UsedTypes;
8686 static char ID;
87 <<<<<<< .mine
88 MSILWriter(formatted_raw_ostream &o) : FunctionPass(&ID), Out(o) {
89 =======
8790 DenseMap AnonValueNumbers;
8891 unsigned NextAnonValueNumber;
8992
9093 MSILWriter(raw_ostream &o)
9194 : FunctionPass(&ID), Out(o), NextAnonValueNumber(0) {
95 >>>>>>> .r75668
9296 UniqID = 0;
9397 }
9498
1919 namespace llvm {
2020 class MSP430TargetMachine;
2121 class FunctionPass;
22 class raw_ostream;
22 class formatted_raw_ostream;
2323
2424 FunctionPass *createMSP430ISelDag(MSP430TargetMachine &TM,
2525 CodeGenOpt::Level OptLevel);
26 FunctionPass *createMSP430CodePrinterPass(raw_ostream &o,
26 FunctionPass *createMSP430CodePrinterPass(formatted_raw_ostream &o,
2727 MSP430TargetMachine &tm,
2828 bool verbose);
2929 } // end namespace llvm;
2828 #include "llvm/Target/TargetData.h"
2929 #include "llvm/ADT/Statistic.h"
3030 #include "llvm/Support/Compiler.h"
31 #include "llvm/Support/FormattedStream.h"
3132 #include "llvm/Support/Mangler.h"
32 #include "llvm/Support/raw_ostream.h"
3333 #include "llvm/Support/ErrorHandling.h"
3434
3535 using namespace llvm;
3939 namespace {
4040 class VISIBILITY_HIDDEN MSP430AsmPrinter : public AsmPrinter {
4141 public:
42 MSP430AsmPrinter(raw_ostream &O, MSP430TargetMachine &TM,
42 MSP430AsmPrinter(formatted_raw_ostream &O, MSP430TargetMachine &TM,
4343 const TargetAsmInfo *TAI, bool V)
4444 : AsmPrinter(O, TM, TAI, V) {}
4545
7474 /// using the given target machine description. This should work
7575 /// regardless of whether the function is in SSA form.
7676 ///
77 FunctionPass *llvm::createMSP430CodePrinterPass(raw_ostream &o,
77 FunctionPass *llvm::createMSP430CodePrinterPass(formatted_raw_ostream &o,
7878 MSP430TargetMachine &tm,
7979 bool verbose) {
8080 return new MSP430AsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
5959 bool MSP430TargetMachine::addAssemblyEmitter(PassManagerBase &PM,
6060 CodeGenOpt::Level OptLevel,
6161 bool Verbose,
62 raw_ostream &Out) {
62 formatted_raw_ostream &Out) {
6363 // Output assembly language.
6464 PM.add(createMSP430CodePrinterPass(Out, *this, Verbose));
6565 return false;
5858 virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
5959 virtual bool addAssemblyEmitter(PassManagerBase &PM,
6060 CodeGenOpt::Level OptLevel, bool Verbose,
61 raw_ostream &Out);
61 formatted_raw_ostream &Out);
6262 static unsigned getModuleMatchQuality(const Module &M);
6363 }; // MSP430TargetMachine.
6464
3838 #include "llvm/ADT/StringExtras.h"
3939 #include "llvm/Support/Debug.h"
4040 #include "llvm/Support/CommandLine.h"
41 #include "llvm/Support/FormattedStream.h"
4142 #include "llvm/Support/MathExtras.h"
42 #include "llvm/Support/raw_ostream.h"
4343 #include
4444
4545 using namespace llvm;
5050 class VISIBILITY_HIDDEN MipsAsmPrinter : public AsmPrinter {
5151 const MipsSubtarget *Subtarget;
5252 public:
53 explicit MipsAsmPrinter(raw_ostream &O, MipsTargetMachine &TM,
53 explicit MipsAsmPrinter(formatted_raw_ostream &O, MipsTargetMachine &TM,
5454 const TargetAsmInfo *T, bool V)
5555 : AsmPrinter(O, TM, T, V) {
5656 Subtarget = &TM.getSubtarget();
9090 /// assembly code for a MachineFunction to the given output stream,
9191 /// using the given target machine description. This should work
9292 /// regardless of whether the function is in SSA form.
93 FunctionPass *llvm::createMipsCodePrinterPass(raw_ostream &o,
93 FunctionPass *llvm::createMipsCodePrinterPass(formatted_raw_ostream &o,
9494 MipsTargetMachine &tm,
9595 bool verbose) {
9696 return new MipsAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
2020 class MipsTargetMachine;
2121 class FunctionPass;
2222 class MachineCodeEmitter;
23 class raw_ostream;
23 class formatted_raw_ostream;
2424
2525 FunctionPass *createMipsISelDag(MipsTargetMachine &TM);
2626 FunctionPass *createMipsDelaySlotFillerPass(MipsTargetMachine &TM);
27 FunctionPass *createMipsCodePrinterPass(raw_ostream &OS,
27 FunctionPass *createMipsCodePrinterPass(formatted_raw_ostream &OS,
2828 MipsTargetMachine &TM,
2929 bool Verbose);
3030 } // end namespace llvm;
130130 // true if AssemblyEmitter is supported
131131 bool MipsTargetMachine::
132132 addAssemblyEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
133 bool Verbose, raw_ostream &Out) {
133 bool Verbose, formatted_raw_ostream &Out) {
134134 // Output assembly language.
135135 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
136136 PM.add(AsmPrinterCtor(Out, *this, Verbose));
2121 #include "llvm/Target/TargetFrameInfo.h"
2222
2323 namespace llvm {
24 class raw_ostream;
24 class formatted_raw_ostream;
2525
2626 class MipsTargetMachine : public LLVMTargetMachine {
2727 MipsSubtarget Subtarget;
3636 // To avoid having target depend on the asmprinter stuff libraries,
3737 // asmprinter set this functions to ctor pointer at startup time if they are
3838 // linked in.
39 typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
39 typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
4040 MipsTargetMachine &tm,
4141 bool verbose);
4242 static AsmPrinterCtorFn AsmPrinterCtor;
7474 CodeGenOpt::Level OptLevel);
7575 virtual bool addAssemblyEmitter(PassManagerBase &PM,
7676 CodeGenOpt::Level OptLevel,
77 bool Verbose, raw_ostream &Out);
77 bool Verbose, formatted_raw_ostream &Out);
7878 };
7979
8080 /// MipselTargetMachine - Mipsel target machine.
2626 class PIC16TargetMachine;
2727 class FunctionPass;
2828 class MachineCodeEmitter;
29 class raw_ostream;
29 class formatted_raw_ostream;
3030
3131 namespace PIC16CC {
3232 enum CondCodes {
342342
343343
344344 FunctionPass *createPIC16ISelDag(PIC16TargetMachine &TM);
345 FunctionPass *createPIC16CodePrinterPass(raw_ostream &OS,
345 FunctionPass *createPIC16CodePrinterPass(formatted_raw_ostream &OS,
346346 PIC16TargetMachine &TM,
347347 bool Verbose);
348348 // Banksel optimzer pass.
1717 #include "llvm/Function.h"
1818 #include "llvm/Module.h"
1919 #include "llvm/CodeGen/DwarfWriter.h"
20 #include "llvm/Support/FormattedStream.h"
2021 #include "llvm/CodeGen/MachineFrameInfo.h"
21 #include "llvm/Support/raw_ostream.h"
2222 #include "llvm/Support/Mangler.h"
2323 #include "llvm/Support/ErrorHandling.h"
2424 #include "llvm/CodeGen/DwarfWriter.h"
111111 /// using the given target machine description. This should work
112112 /// regardless of whether the function is in SSA form.
113113 ///
114 FunctionPass *llvm::createPIC16CodePrinterPass(raw_ostream &o,
114 FunctionPass *llvm::createPIC16CodePrinterPass(formatted_raw_ostream &o,
115115 PIC16TargetMachine &tm,
116116 bool verbose) {
117117 return new PIC16AsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
2828
2929 namespace llvm {
3030 struct VISIBILITY_HIDDEN PIC16AsmPrinter : public AsmPrinter {
31 explicit PIC16AsmPrinter(raw_ostream &O, PIC16TargetMachine &TM,
31 explicit PIC16AsmPrinter(formatted_raw_ostream &O, PIC16TargetMachine &TM,
3232 const TargetAsmInfo *T, bool V)
3333 : AsmPrinter(O, TM, T, V), DbgInfo(O, T) {
3434 PTLI = TM.getTargetLowering();
1515 #include "llvm/GlobalVariable.h"
1616 #include "llvm/CodeGen/MachineFunction.h"
1717 #include "llvm/Support/DebugLoc.h"
18 #include "llvm/Support/raw_ostream.h"
18 #include "llvm/Support/FormattedStream.h"
1919
2020 using namespace llvm;
2121
8989 };
9090 }
9191
92 class raw_ostream;
92 class formatted_raw_ostream;
9393
9494 class PIC16DbgInfo {
95 raw_ostream &O;
95 formatted_raw_ostream &O;
9696 const TargetAsmInfo *TAI;
9797 std::string CurFile;
9898 unsigned CurLine;
102102 bool EmitDebugDirectives;
103103
104104 public:
105 PIC16DbgInfo(raw_ostream &o, const TargetAsmInfo *T) : O(o), TAI(T) {
105 PIC16DbgInfo(formatted_raw_ostream &o, const TargetAsmInfo *T)
106 : O(o), TAI(T) {
106107 CurFile = "";
107108 CurLine = 0;
108109 EmitDebugDirectives = false;
6666
6767 bool PIC16TargetMachine::addAssemblyEmitter(PassManagerBase &PM,
6868 CodeGenOpt::Level OptLevel,
69 bool Verbose, raw_ostream &Out) {
69 bool Verbose,
70 formatted_raw_ostream &Out) {
7071 // Output assembly language.
7172 PM.add(createPIC16CodePrinterPass(Out, *this, Verbose));
7273 return false;
6060 CodeGenOpt::Level OptLevel);
6161 virtual bool addAssemblyEmitter(PassManagerBase &PM,
6262 CodeGenOpt::Level OptLevel,
63 bool Verbose, raw_ostream &Out);
63 bool Verbose, formatted_raw_ostream &Out);
6464 virtual bool addPostRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
6565 }; // PIC16TargetMachine.
6666
3737 #include "llvm/Support/Debug.h"
3838 #include "llvm/Support/ErrorHandling.h"
3939 #include "llvm/Support/Compiler.h"
40 #include "llvm/Support/raw_ostream.h"
40 #include "llvm/Support/FormattedStream.h"
4141 #include "llvm/Target/TargetAsmInfo.h"
4242 #include "llvm/Target/TargetRegisterInfo.h"
4343 #include "llvm/Target/TargetInstrInfo.h"
5555 StringSet<> FnStubs, GVStubs, HiddenGVStubs;
5656 const PPCSubtarget &Subtarget;
5757 public:
58 explicit PPCAsmPrinter(raw_ostream &O, TargetMachine &TM,
58 explicit PPCAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
5959 const TargetAsmInfo *T, bool V)
6060 : AsmPrinter(O, TM, T, V),
6161 Subtarget(TM.getSubtarget()) {}
293293 /// PPCLinuxAsmPrinter - PowerPC assembly printer, customized for Linux
294294 class VISIBILITY_HIDDEN PPCLinuxAsmPrinter : public PPCAsmPrinter {
295295 public:
296 explicit PPCLinuxAsmPrinter(raw_ostream &O, PPCTargetMachine &TM,
296 explicit PPCLinuxAsmPrinter(formatted_raw_ostream &O, PPCTargetMachine &TM,
297297 const TargetAsmInfo *T, bool V)
298298 : PPCAsmPrinter(O, TM, T, V){}
299299
317317 /// PPCDarwinAsmPrinter - PowerPC assembly printer, customized for Darwin/Mac
318318 /// OS X
319319 class VISIBILITY_HIDDEN PPCDarwinAsmPrinter : public PPCAsmPrinter {
320 raw_ostream &OS;
320 formatted_raw_ostream &OS;
321321 public:
322 explicit PPCDarwinAsmPrinter(raw_ostream &O, PPCTargetMachine &TM,
322 explicit PPCDarwinAsmPrinter(formatted_raw_ostream &O, PPCTargetMachine &TM,
323323 const TargetAsmInfo *T, bool V)
324324 : PPCAsmPrinter(O, TM, T, V), OS(O) {}
325325
628628
629629 /// PrintUnmangledNameSafely - Print out the printable characters in the name.
630630 /// Don't print things like \\n or \\0.
631 static void PrintUnmangledNameSafely(const Value *V, raw_ostream &OS) {
631 static void PrintUnmangledNameSafely(const Value *V, formatted_raw_ostream &OS) {
632632 for (const char *Name = V->getNameStart(), *E = Name+V->getNameLen();
633633 Name != E; ++Name)
634634 if (isprint(*Name))
11071107 /// for a MachineFunction to the given output stream, in a format that the
11081108 /// Darwin assembler can deal with.
11091109 ///
1110 FunctionPass *llvm::createPPCAsmPrinterPass(raw_ostream &o,
1110 FunctionPass *llvm::createPPCAsmPrinterPass(formatted_raw_ostream &o,
11111111 PPCTargetMachine &tm,
11121112 bool verbose) {
11131113 const PPCSubtarget *Subtarget = &tm.getSubtarget();
2424 class FunctionPass;
2525 class MachineCodeEmitter;
2626 class ObjectCodeEmitter;
27 class raw_ostream;
27 class formatted_raw_ostream;
2828
2929 FunctionPass *createPPCBranchSelectionPass();
3030 FunctionPass *createPPCISelDag(PPCTargetMachine &TM);
31 FunctionPass *createPPCAsmPrinterPass(raw_ostream &OS, PPCTargetMachine &TM,
31 FunctionPass *createPPCAsmPrinterPass(formatted_raw_ostream &OS,
32 PPCTargetMachine &TM,
3233 bool Verbose);
3334 FunctionPass *createPPCCodeEmitterPass(PPCTargetMachine &TM,
3435 MachineCodeEmitter &MCE);
1717 #include "llvm/PassManager.h"
1818 #include "llvm/Target/TargetMachineRegistry.h"
1919 #include "llvm/Target/TargetOptions.h"
20 #include "llvm/Support/raw_ostream.h"
20 #include "llvm/Support/FormattedStream.h"
2121 using namespace llvm;
2222
2323 /// PowerPCTargetMachineModule - Note that this is used on hosts that
148148 bool PPCTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
149149 CodeGenOpt::Level OptLevel,
150150 bool Verbose,
151 raw_ostream &Out) {
151 formatted_raw_ostream &Out) {
152152 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
153153 if (AsmPrinterCtor)
154154 PM.add(AsmPrinterCtor(Out, *this, Verbose));
182182 if (DumpAsm) {
183183 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
184184 if (AsmPrinterCtor)
185 PM.add(AsmPrinterCtor(errs(), *this, true));
185 PM.add(AsmPrinterCtor(ferrs(), *this, true));
186186 }
187187
188188 return false;
214214 if (DumpAsm) {
215215 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
216216 if (AsmPrinterCtor)
217 PM.add(AsmPrinterCtor(errs(), *this, true));
217 PM.add(AsmPrinterCtor(ferrs(), *this, true));
218218 }
219219
220220 return false;
246246 if (DumpAsm) {
247247 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
248248 if (AsmPrinterCtor)
249 PM.add(AsmPrinterCtor(errs(), *this, true));
249 PM.add(AsmPrinterCtor(ferrs(), *this, true));
250250 }
251251
252252 return false;
261261 if (DumpAsm) {
262262 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
263263 if (AsmPrinterCtor)
264 PM.add(AsmPrinterCtor(errs(), *this, true));
264 PM.add(AsmPrinterCtor(ferrs(), *this, true));
265265 }
266266
267267 return false;
276276 if (DumpAsm) {
277277 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
278278 if (AsmPrinterCtor)
279 PM.add(AsmPrinterCtor(errs(), *this, true));
279 PM.add(AsmPrinterCtor(ferrs(), *this, true));
280280 }
281281
282282 return false;
291291 if (DumpAsm) {
292292 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
293293 if (AsmPrinterCtor)
294 PM.add(AsmPrinterCtor(errs(), *this, true));
295 }
296
297 return false;
298 }
299
300
294 PM.add(AsmPrinterCtor(ferrs(), *this, true));
295 }
296
297 return false;
298 }
299
300
4343
4444 // To avoid having target depend on the asmprinter stuff libraries, asmprinter
4545 // set this functions to ctor pointer at startup time if they are linked in.
46 typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
46 typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
4747 PPCTargetMachine &tm,
4848 bool verbose);
4949 static AsmPrinterCtorFn AsmPrinterCtor;
7979 virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
8080 virtual bool addAssemblyEmitter(PassManagerBase &PM,
8181 CodeGenOpt::Level OptLevel,
82 bool Verbose, raw_ostream &Out);
82 bool Verbose, formatted_raw_ostream &Out);
8383 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
8484 bool DumpAsm, MachineCodeEmitter &MCE);
8585 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
2626 #include "llvm/CodeGen/MachineInstr.h"
2727 #include "llvm/Target/TargetAsmInfo.h"
2828 #include "llvm/Support/ErrorHandling.h"
29 #include "llvm/Support/FormattedStream.h"
2930 #include "llvm/Support/Mangler.h"
30 #include "llvm/Support/raw_ostream.h"
3131 #include "llvm/ADT/Statistic.h"
3232 #include "llvm/ADT/StringExtras.h"
3333 #include "llvm/Support/CommandLine.h"
4949 ValueMapTy NumberForBB;
5050 unsigned BBNumber;
5151 public:
52 explicit SparcAsmPrinter(raw_ostream &O, TargetMachine &TM,
52 explicit SparcAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
5353 const TargetAsmInfo *T, bool V)
5454 : AsmPrinter(O, TM, T, V), BBNumber(0) {}
5555
8181 /// using the given target machine description. This should work
8282 /// regardless of whether the function is in SSA form.
8383 ///
84 FunctionPass *llvm::createSparcCodePrinterPass(raw_ostream &o,
84 FunctionPass *llvm::createSparcCodePrinterPass(formatted_raw_ostream &o,
8585 TargetMachine &tm,
8686 bool verbose) {
8787 return new SparcAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
2121 namespace llvm {
2222 class FunctionPass;
2323 class SparcTargetMachine;
24 class raw_ostream;
24 class formatted_raw_ostream;
2525
2626 FunctionPass *createSparcISelDag(SparcTargetMachine &TM);
27 FunctionPass *createSparcCodePrinterPass(raw_ostream &OS, TargetMachine &TM,
27 FunctionPass *createSparcCodePrinterPass(formatted_raw_ostream &OS,
28 TargetMachine &TM,
2829 bool Verbose);
2930 FunctionPass *createSparcDelaySlotFillerPass(TargetMachine &TM);
3031 FunctionPass *createSparcFPMoverPass(TargetMachine &TM);
8585 bool SparcTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
8686 CodeGenOpt::Level OptLevel,
8787 bool Verbose,
88 raw_ostream &Out) {
88 formatted_raw_ostream &Out) {
8989 // Output assembly language.
9090 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
9191 if (AsmPrinterCtor)
3636
3737 // To avoid having target depend on the asmprinter stuff libraries, asmprinter
3838 // set this functions to ctor pointer at startup time if they are linked in.
39 typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
39 typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
4040 TargetMachine &tm,
4141 bool verbose);
4242 static AsmPrinterCtorFn AsmPrinterCtor;
6161 virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
6262 virtual bool addAssemblyEmitter(PassManagerBase &PM,
6363 CodeGenOpt::Level OptLevel,
64 bool Verbose, raw_ostream &Out);
64 bool Verbose, formatted_raw_ostream &Out);
6565
6666 static void registerAsmPrinter(AsmPrinterCtorFn F) {
6767 AsmPrinterCtor = F;
3333 #include "llvm/CodeGen/MachineJumpTableInfo.h"
3434 #include "llvm/Support/CommandLine.h"
3535 #include "llvm/Support/ErrorHandling.h"
36 #include "llvm/Support/FormattedStream.h"
3637 #include "llvm/Support/Mangler.h"
37 #include "llvm/Support/raw_ostream.h"
3838 #include "llvm/Target/TargetAsmInfo.h"
3939 #include "llvm/Target/TargetOptions.h"
4040 using namespace llvm;
5959
6060 /// PrintUnmangledNameSafely - Print out the printable characters in the name.
6161 /// Don't print things like \\n or \\0.
62 static void PrintUnmangledNameSafely(const Value *V, raw_ostream &OS) {
62 static void PrintUnmangledNameSafely(const Value *V,
63 formatted_raw_ostream &OS) {
6364 for (const char *Name = V->getNameStart(), *E = Name+V->getNameLen();
6465 Name != E; ++Name)
6566 if (isprint(*Name))
3636 MCContext *Context;
3737 MCStreamer *Streamer;
3838 public:
39 explicit X86ATTAsmPrinter(raw_ostream &O, X86TargetMachine &TM,
39 explicit X86ATTAsmPrinter(formatted_raw_ostream &O, X86TargetMachine &TM,
4040 const TargetAsmInfo *T, bool V)
4141 : AsmPrinter(O, TM, T, V) {
4242 Subtarget = &TM.getSubtarget();
1616 #include "X86ATTAsmPrinter.h"
1717 #include "llvm/Target/TargetAsmInfo.h"
1818 #include "llvm/Support/ErrorHandling.h"
19 #include "llvm/Support/raw_ostream.h"
19 #include "llvm/Support/FormattedStream.h"
2020 using namespace llvm;
2121
2222 // Include the auto-generated portion of the assembly writer.
2222 /// for a MachineFunction to the given output stream, using the given target
2323 /// machine description.
2424 ///
25 FunctionPass *llvm::createX86CodePrinterPass(raw_ostream &o,
25 FunctionPass *llvm::createX86CodePrinterPass(formatted_raw_ostream &o,
2626 X86TargetMachine &tm,
2727 bool verbose) {
2828 const X86Subtarget *Subtarget = &tm.getSubtarget();
1919 #include "llvm/CodeGen/AsmPrinter.h"
2020 #include "llvm/ADT/StringSet.h"
2121 #include "llvm/Support/Compiler.h"
22 #include "llvm/Support/raw_ostream.h"
22 #include "llvm/Support/FormattedStream.h"
2323
2424 namespace llvm {
2525
2626 struct VISIBILITY_HIDDEN X86IntelAsmPrinter : public AsmPrinter {
27 explicit X86IntelAsmPrinter(raw_ostream &O, X86TargetMachine &TM,
27 explicit X86IntelAsmPrinter(formatted_raw_ostream &O, X86TargetMachine &TM,
2828 const TargetAsmInfo *T, bool V)
2929 : AsmPrinter(O, TM, T, V) {}
3030
2222 class FunctionPass;
2323 class MachineCodeEmitter;
2424 class JITCodeEmitter;
25 class raw_ostream;
25 class formatted_raw_ostream;
2626
2727 /// createX86ISelDag - This pass converts a legalized DAG into a
2828 /// X86-specific DAG, ready for instruction scheduling.
4545 /// assembly code for a MachineFunction to the given output stream,
4646 /// using the given target machine description.
4747 ///
48 FunctionPass *createX86CodePrinterPass(raw_ostream &o, X86TargetMachine &tm,
48 FunctionPass *createX86CodePrinterPass(formatted_raw_ostream &o,
49 X86TargetMachine &tm,
4950 bool Verbose);
5051
5152 /// createX86CodeEmitterPass - Return a pass that emits the collected X86 code
1717 #include "llvm/PassManager.h"
1818 #include "llvm/CodeGen/MachineFunction.h"
1919 #include "llvm/CodeGen/Passes.h"
20 #include "llvm/Support/raw_ostream.h"
20 #include "llvm/Support/FormattedStream.h"
2121 #include "llvm/Target/TargetOptions.h"
2222 #include "llvm/Target/TargetMachineRegistry.h"
2323 using namespace llvm;
236236 bool X86TargetMachine::addAssemblyEmitter(PassManagerBase &PM,
237237 CodeGenOpt::Level OptLevel,
238238 bool Verbose,
239 raw_ostream &Out) {
239 formatted_raw_ostream &Out) {
240240 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
241241 if (AsmPrinterCtor)
242242 PM.add(AsmPrinterCtor(Out, *this, Verbose));
269269 if (DumpAsm) {
270270 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
271271 if (AsmPrinterCtor)
272 PM.add(AsmPrinterCtor(errs(), *this, true));
272 PM.add(AsmPrinterCtor(ferrs(), *this, true));
273273 }
274274
275275 return false;
301301 if (DumpAsm) {
302302 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
303303 if (AsmPrinterCtor)
304 PM.add(AsmPrinterCtor(errs(), *this, true));
304 PM.add(AsmPrinterCtor(ferrs(), *this, true));
305305 }
306306
307307 return false;
315315 if (DumpAsm) {
316316 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
317317 if (AsmPrinterCtor)
318 PM.add(AsmPrinterCtor(errs(), *this, true));
318 PM.add(AsmPrinterCtor(ferrs(), *this, true));
319319 }
320320
321321 return false;
329329 if (DumpAsm) {
330330 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
331331 if (AsmPrinterCtor)
332 PM.add(AsmPrinterCtor(errs(), *this, true));
332 PM.add(AsmPrinterCtor(ferrs(), *this, true));
333333 }
334334
335335 return false;
343343 if (DumpAsm) {
344344 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
345345 if (AsmPrinterCtor)
346 PM.add(AsmPrinterCtor(errs(), *this, true));
346 PM.add(AsmPrinterCtor(ferrs(), *this, true));
347347 }
348348
349349 return false;
357357 if (DumpAsm) {
358358 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
359359 if (AsmPrinterCtor)
360 PM.add(AsmPrinterCtor(errs(), *this, true));
361 }
362
363 return false;
364 }
360 PM.add(AsmPrinterCtor(ferrs(), *this, true));
361 }
362
363 return false;
364 }
2525
2626 namespace llvm {
2727
28 class raw_ostream;
28 class formatted_raw_ostream;
2929
3030 class X86TargetMachine : public LLVMTargetMachine {
3131 X86Subtarget Subtarget;
4242
4343 // To avoid having target depend on the asmprinter stuff libraries, asmprinter
4444 // set this functions to ctor pointer at startup time if they are linked in.
45 typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
45 typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
4646 X86TargetMachine &tm,
4747 bool verbose);
4848 static AsmPrinterCtorFn AsmPrinterCtor;
7878 virtual bool addPostRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
7979 virtual bool addAssemblyEmitter(PassManagerBase &PM,
8080 CodeGenOpt::Level OptLevel,
81 bool Verbose, raw_ostream &Out);
81 bool Verbose, formatted_raw_ostream &Out);
8282 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
8383 bool DumpAsm, MachineCodeEmitter &MCE);
8484 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
2020 class FunctionPass;
2121 class TargetMachine;
2222 class XCoreTargetMachine;
23 class raw_ostream;
23 class formatted_raw_ostream;
2424
2525 FunctionPass *createXCoreISelDag(XCoreTargetMachine &TM);
26 FunctionPass *createXCoreCodePrinterPass(raw_ostream &OS,
26 FunctionPass *createXCoreCodePrinterPass(formatted_raw_ostream &OS,
2727 XCoreTargetMachine &TM,
2828 bool Verbose);
2929 } // end namespace llvm;
3232 #include "llvm/ADT/StringExtras.h"
3333 #include "llvm/Support/CommandLine.h"
3434 #include "llvm/Support/ErrorHandling.h"
35 #include "llvm/Support/FormattedStream.h"
3536 #include "llvm/Support/MathExtras.h"
36 #include "llvm/Support/raw_ostream.h"
3737 #include
3838 #include
3939 using namespace llvm;
5757 DwarfWriter *DW;
5858 const XCoreSubtarget &Subtarget;
5959 public:
60 explicit XCoreAsmPrinter(raw_ostream &O, XCoreTargetMachine &TM,
60 explicit XCoreAsmPrinter(formatted_raw_ostream &O, XCoreTargetMachine &TM,
6161 const TargetAsmInfo *T, bool V)
6262 : AsmPrinter(O, TM, T, V), DW(0),
6363 Subtarget(*TM.getSubtargetImpl()) {}
103103 /// using the given target machine description. This should work
104104 /// regardless of whether the function is in SSA form.
105105 ///
106 FunctionPass *llvm::createXCoreCodePrinterPass(raw_ostream &o,
106 FunctionPass *llvm::createXCoreCodePrinterPass(formatted_raw_ostream &o,
107107 XCoreTargetMachine &tm,
108108 bool verbose) {
109109 return new XCoreAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
111111
112112 // PrintEscapedString - Print each character of the specified string, escaping
113113 // it if it is not printable or if it is an escape char.
114 static void PrintEscapedString(const std::string &Str, raw_ostream &Out) {
114 static void PrintEscapedString(const std::string &Str,
115 formatted_raw_ostream &Out) {
115116 for (unsigned i = 0, e = Str.size(); i != e; ++i) {
116117 unsigned char C = Str[i];
117118 if (isprint(C) && C != '"' && C != '\\') {
6666 bool XCoreTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
6767 CodeGenOpt::Level OptLevel,
6868 bool Verbose,
69 raw_ostream &Out) {
69 formatted_raw_ostream &Out) {
7070 // Output assembly language.
7171 PM.add(createXCoreCodePrinterPass(Out, *this, Verbose));
7272 return false;
5454 virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
5555 virtual bool addAssemblyEmitter(PassManagerBase &PM,
5656 CodeGenOpt::Level OptLevel,
57 bool Verbose, raw_ostream &Out);
57 bool Verbose, formatted_raw_ostream &Out);
5858 };
5959
6060 } // end namespace llvm
2929 #include "llvm/Pass.h"
3030 #include "llvm/Support/CommandLine.h"
3131 #include "llvm/Support/FileUtilities.h"
32 #include "llvm/Support/FormattedStream.h"
3233 #include "llvm/Support/ManagedStatic.h"
3334 #include "llvm/Support/MemoryBuffer.h"
3435 #include "llvm/Support/PluginLoader.h"
3536 #include "llvm/Support/PrettyStackTrace.h"
3637 #include "llvm/Support/RegistryParser.h"
37 #include "llvm/Support/raw_ostream.h"
3838 #include "llvm/Analysis/Verifier.h"
3939 #include "llvm/System/Signals.h"
4040 #include "llvm/Config/config.h"
127127 return outputFilename;
128128 }
129129
130 static raw_ostream *GetOutputStream(const char *ProgName) {
130 static formatted_raw_ostream *GetOutputStream(const char *ProgName) {
131131 if (OutputFilename != "") {
132132 if (OutputFilename == "-")
133 return &outs();
133 return &fouts();
134134
135135 // Specified an output filename?
136136 if (!Force && std::ifstream(OutputFilename.c_str())) {
145145 sys::RemoveFileOnSignal(sys::Path(OutputFilename));
146146
147147 std::string error;
148 raw_ostream *Out = new raw_fd_ostream(OutputFilename.c_str(), true, error);
148 raw_fd_ostream *FDOut = new raw_fd_ostream(OutputFilename.c_str(),
149 true, error);
150 formatted_raw_ostream *Out =
151 new formatted_raw_ostream(*FDOut, formatted_raw_ostream::DELETE_STREAM);
149152 if (!error.empty()) {
150153 std::cerr << error << '\n';
151154 delete Out;
157160
158161 if (InputFilename == "-") {
159162 OutputFilename = "-";
160 return &outs();
163 return &fouts();
161164 }
162165
163166 OutputFilename = GetFileNameRoot(InputFilename);
198201 sys::RemoveFileOnSignal(sys::Path(OutputFilename));
199202
200203 std::string error;
201 raw_ostream *Out = new raw_fd_ostream(OutputFilename.c_str(), Binary, error);
204 raw_fd_ostream *FDOut = new raw_fd_ostream(OutputFilename.c_str(),
205 Binary, error);
206 formatted_raw_ostream *Out =
207 new formatted_raw_ostream(*FDOut, formatted_raw_ostream::DELETE_STREAM);
202208 if (!error.empty()) {
203209 std::cerr << error << '\n';
204210 delete Out;
267273 TargetMachine &Target = *target.get();
268274
269275 // Figure out where we are going to send the output...
270 raw_ostream *Out = GetOutputStream(argv[0]);
276 formatted_raw_ostream *Out = GetOutputStream(argv[0]);
271277 if (Out == 0) return 1;
272278
273279 CodeGenOpt::Level OLvl = CodeGenOpt::Default;
294300 if (Target.addPassesToEmitWholeFile(PM, *Out, FileType, OLvl)) {
295301 std::cerr << argv[0] << ": target does not support generation of this"
296302 << " file type!\n";
297 if (Out != &outs()) delete Out;
303 if (Out != &fouts()) delete Out;
298304 // And the Out file is empty and useless, so remove it now.
299305 sys::Path(OutputFilename).eraseFromDisk();
300306 return 1;
324330 case FileModel::Error:
325331 std::cerr << argv[0] << ": target does not support generation of this"
326332 << " file type!\n";
327 if (Out != &outs()) delete Out;
333 if (Out != &fouts()) delete Out;
328334 // And the Out file is empty and useless, so remove it now.
329335 sys::Path(OutputFilename).eraseFromDisk();
330336 return 1;
341347 if (Target.addPassesToEmitFileFinish(Passes, OCE, OLvl)) {
342348 std::cerr << argv[0] << ": target does not support generation of this"
343349 << " file type!\n";
344 if (Out != &outs()) delete Out;
350 if (Out != &fouts()) delete Out;
345351 // And the Out file is empty and useless, so remove it now.
346352 sys::Path(OutputFilename).eraseFromDisk();
347353 return 1;
363369 Passes.doFinalization();
364370 }
365371
372 Out->flush();
373
366374 // Delete the ostream if it's not a stdout stream
367 if (Out != &outs()) delete Out;
375 if (Out != &fouts()) delete Out;
368376
369377 return 0;
370378 }
2929 #include "llvm/Bitcode/ReaderWriter.h"
3030 #include "llvm/CodeGen/FileWriters.h"
3131 #include "llvm/Support/CommandLine.h"
32 #include "llvm/Support/FormattedStream.h"
3233 #include "llvm/Support/Mangler.h"
3334 #include "llvm/Support/MemoryBuffer.h"
3435 #include "llvm/Support/StandardPasses.h"
3536 #include "llvm/Support/SystemUtils.h"
36 #include "llvm/Support/raw_ostream.h"
3737 #include "llvm/System/Signals.h"
3838 #include "llvm/Target/SubtargetFeature.h"
3939 #include "llvm/Target/TargetOptions.h"
184184 // generate assembly code
185185 bool genResult = false;
186186 {
187 raw_fd_ostream asmFile(uniqueAsmPath.c_str(), false, errMsg);
187 raw_fd_ostream asmFD(raw_fd_ostream(uniqueAsmPath.c_str(),
188 false, errMsg));
189 formatted_raw_ostream asmFile(asmFD);
188190 if (!errMsg.empty())
189191 return NULL;
190192 genResult = this->generateAssemblyCode(asmFile, errMsg);
389391 }
390392
391393 /// Optimize merged modules using various IPO passes
392 bool LTOCodeGenerator::generateAssemblyCode(raw_ostream& out,
394 bool LTOCodeGenerator::generateAssemblyCode(formatted_raw_ostream& out,
393395 std::string& errMsg)
394396 {
395397 if ( this->determineTarget(errMsg) )
4444 const void* compile(size_t* length, std::string& errMsg);
4545 void setCodeGenDebugOptions(const char *opts);
4646 private:
47 bool generateAssemblyCode(llvm::raw_ostream& out,
47 bool generateAssemblyCode(llvm::formatted_raw_ostream& out,
4848 std::string& errMsg);
4949 bool assemble(const std::string& asmPath,
5050 const std::string& objPath, std::string& errMsg);