OLD | NEW |
1 //===- subzero/src/IceCompiler.cpp - Driver for bitcode translation -------===// | 1 //===- subzero/src/IceCompiler.cpp - Driver for bitcode translation -------===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 /// | 9 /// |
10 /// \file | 10 /// \file |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "IceCfg.h" | 21 #include "IceCfg.h" |
22 #include "IceClFlags.h" | 22 #include "IceClFlags.h" |
23 #include "IceClFlagsExtra.h" | 23 #include "IceClFlagsExtra.h" |
24 #include "IceConverter.h" | 24 #include "IceConverter.h" |
25 #include "IceELFObjectWriter.h" | 25 #include "IceELFObjectWriter.h" |
26 #include "PNaClTranslator.h" | 26 #include "PNaClTranslator.h" |
27 | 27 |
28 #pragma clang diagnostic push | 28 #pragma clang diagnostic push |
29 #pragma clang diagnostic ignored "-Wunused-parameter" | 29 #pragma clang diagnostic ignored "-Wunused-parameter" |
30 #include "llvm/ADT/STLExtras.h" | 30 #include "llvm/ADT/STLExtras.h" |
| 31 #include "llvm/Bitcode/NaCl/NaClReaderWriter.h" |
31 #include "llvm/IR/LLVMContext.h" | 32 #include "llvm/IR/LLVMContext.h" |
32 #include "llvm/IR/Module.h" | 33 #include "llvm/IR/Module.h" |
33 #include "llvm/IRReader/IRReader.h" | 34 #include "llvm/IRReader/IRReader.h" |
34 #include "llvm/Support/SourceMgr.h" | 35 #include "llvm/Support/SourceMgr.h" |
35 #include "llvm/Support/StreamingMemoryObject.h" | 36 #include "llvm/Support/StreamingMemoryObject.h" |
36 #pragma clang diagnostic pop | 37 #pragma clang diagnostic pop |
37 | 38 |
38 namespace Ice { | 39 namespace Ice { |
39 | 40 |
40 namespace { | 41 namespace { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 Translator.reset(PTranslator.release()); | 133 Translator.reset(PTranslator.release()); |
133 } else if (BuildDefs::llvmIr()) { | 134 } else if (BuildDefs::llvmIr()) { |
134 if (PNACL_BROWSER_TRANSLATOR) { | 135 if (PNACL_BROWSER_TRANSLATOR) { |
135 Ctx.getStrError() | 136 Ctx.getStrError() |
136 << "non BuildOnRead is not supported w/ PNACL_BROWSER_TRANSLATOR\n"; | 137 << "non BuildOnRead is not supported w/ PNACL_BROWSER_TRANSLATOR\n"; |
137 return Ctx.getErrorStatus()->assign(EC_Args); | 138 return Ctx.getErrorStatus()->assign(EC_Args); |
138 } | 139 } |
139 // Parse the input LLVM IR file into a module. | 140 // Parse the input LLVM IR file into a module. |
140 llvm::SMDiagnostic Err; | 141 llvm::SMDiagnostic Err; |
141 TimerMarker T1(Ice::TimerStack::TT_parse, &Ctx); | 142 TimerMarker T1(Ice::TimerStack::TT_parse, &Ctx); |
142 llvm::raw_ostream *Verbose = | 143 llvm::DiagnosticHandlerFunction DiagnosticHandler = |
143 ExtraFlags.getLLVMVerboseErrors() ? &llvm::errs() : nullptr; | 144 ExtraFlags.getLLVMVerboseErrors() |
| 145 ? redirectNaClDiagnosticToStream(llvm::errs()) |
| 146 : nullptr; |
144 std::unique_ptr<llvm::Module> Mod = | 147 std::unique_ptr<llvm::Module> Mod = |
145 NaClParseIRFile(IRFilename, ExtraFlags.getInputFileFormat(), Err, | 148 NaClParseIRFile(IRFilename, ExtraFlags.getInputFileFormat(), Err, |
146 Verbose, llvm::getGlobalContext()); | 149 llvm::getGlobalContext(), DiagnosticHandler); |
147 if (!Mod) { | 150 if (!Mod) { |
148 Err.print(ExtraFlags.getAppName().c_str(), llvm::errs()); | 151 Err.print(ExtraFlags.getAppName().c_str(), llvm::errs()); |
149 return Ctx.getErrorStatus()->assign(EC_Bitcode); | 152 return Ctx.getErrorStatus()->assign(EC_Bitcode); |
150 } | 153 } |
151 | 154 |
152 std::unique_ptr<Converter> Converter(new class Converter(Mod.get(), &Ctx)); | 155 std::unique_ptr<Converter> Converter(new class Converter(Mod.get(), &Ctx)); |
153 Converter->convertToIce(); | 156 Converter->convertToIce(); |
154 Translator.reset(Converter.release()); | 157 Translator.reset(Converter.release()); |
155 } else { | 158 } else { |
156 Ctx.getStrError() << "Error: Build doesn't allow LLVM IR, " | 159 Ctx.getStrError() << "Error: Build doesn't allow LLVM IR, " |
(...skipping 22 matching lines...) Expand all Loading... |
179 | 182 |
180 if (Ctx.getFlags().getTimeEachFunction()) { | 183 if (Ctx.getFlags().getTimeEachFunction()) { |
181 const bool DumpCumulative = false; | 184 const bool DumpCumulative = false; |
182 Ctx.dumpTimers(GlobalContext::TSK_Funcs, DumpCumulative); | 185 Ctx.dumpTimers(GlobalContext::TSK_Funcs, DumpCumulative); |
183 } | 186 } |
184 constexpr bool FinalStats = true; | 187 constexpr bool FinalStats = true; |
185 Ctx.dumpStats("_FINAL_", FinalStats); | 188 Ctx.dumpStats("_FINAL_", FinalStats); |
186 } | 189 } |
187 | 190 |
188 } // end of namespace Ice | 191 } // end of namespace Ice |
OLD | NEW |