OLD | NEW |
1 //===- subzero/src/IceGlobalContext.cpp - Global context defs -------------===// | 1 //===- subzero/src/IceGlobalContext.cpp - Global context defs -------------===// |
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 // This file defines aspects of the compilation that persist across | 10 // This file defines aspects of the compilation that persist across |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 Str << "|" << Name << "|Spills+Fills|" | 206 Str << "|" << Name << "|Spills+Fills|" |
207 << Stats[CS_NumSpills] + Stats[CS_NumFills] << "\n"; | 207 << Stats[CS_NumSpills] + Stats[CS_NumFills] << "\n"; |
208 Str << "|" << Name << "|Memory Usage|"; | 208 Str << "|" << Name << "|Memory Usage|"; |
209 if (ssize_t MemUsed = llvm::TimeRecord::getCurrentTime(false).getMemUsed()) | 209 if (ssize_t MemUsed = llvm::TimeRecord::getCurrentTime(false).getMemUsed()) |
210 Str << MemUsed; | 210 Str << MemUsed; |
211 else | 211 else |
212 Str << "(requires '-track-memory')"; | 212 Str << "(requires '-track-memory')"; |
213 Str << "\n"; | 213 Str << "\n"; |
214 } | 214 } |
215 | 215 |
216 GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit, | 216 GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit, Ostream *OsError, |
217 ELFStreamer *ELFStr, const ClFlags &Flags) | 217 ELFStreamer *ELFStr, const ClFlags &Flags) |
218 : ConstPool(new ConstantPool()), ErrorStatus(), StrDump(OsDump), | 218 : ConstPool(new ConstantPool()), ErrorStatus(), StrDump(OsDump), |
219 StrEmit(OsEmit), Flags(Flags), RNG(Flags.getRandomSeed()), ObjectWriter(), | 219 StrEmit(OsEmit), StrError(OsError), Flags(Flags), |
| 220 RNG(Flags.getRandomSeed()), ObjectWriter(), |
220 OptQ(/*Sequential=*/Flags.isSequential(), | 221 OptQ(/*Sequential=*/Flags.isSequential(), |
221 /*MaxSize=*/Flags.getNumTranslationThreads()), | 222 /*MaxSize=*/Flags.getNumTranslationThreads()), |
222 // EmitQ is allowed unlimited size. | 223 // EmitQ is allowed unlimited size. |
223 EmitQ(/*Sequential=*/Flags.isSequential()) { | 224 EmitQ(/*Sequential=*/Flags.isSequential()) { |
| 225 assert(OsDump && "OsDump is not defined for GlobalContext"); |
| 226 assert(OsEmit && "OsEmit is not defined for GlobalContext"); |
| 227 assert(OsError && "OsError is not defined for GlobalContext"); |
224 // Make sure thread_local fields are properly initialized before any | 228 // Make sure thread_local fields are properly initialized before any |
225 // accesses are made. Do this here instead of at the start of | 229 // accesses are made. Do this here instead of at the start of |
226 // main() so that all clients (e.g. unit tests) can benefit for | 230 // main() so that all clients (e.g. unit tests) can benefit for |
227 // free. | 231 // free. |
228 GlobalContext::TlsInit(); | 232 GlobalContext::TlsInit(); |
229 Cfg::TlsInit(); | 233 Cfg::TlsInit(); |
230 // Create a new ThreadContext for the current thread. No need to | 234 // Create a new ThreadContext for the current thread. No need to |
231 // lock AllThreadContexts at this point since no other threads have | 235 // lock AllThreadContexts at this point since no other threads have |
232 // access yet to this GlobalContext object. | 236 // access yet to this GlobalContext object. |
233 ThreadContext *MyTLS = new ThreadContext(); | 237 ThreadContext *MyTLS = new ThreadContext(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 getFlags().getTranslateOnly())) { | 275 getFlags().getTranslateOnly())) { |
272 Func->dump(); | 276 Func->dump(); |
273 Cfg::setCurrentCfg(nullptr); | 277 Cfg::setCurrentCfg(nullptr); |
274 continue; // Func goes out of scope and gets deleted | 278 continue; // Func goes out of scope and gets deleted |
275 } | 279 } |
276 Func->translate(); | 280 Func->translate(); |
277 EmitterWorkItem *Item = nullptr; | 281 EmitterWorkItem *Item = nullptr; |
278 if (Func->hasError()) { | 282 if (Func->hasError()) { |
279 getErrorStatus()->assign(EC_Translation); | 283 getErrorStatus()->assign(EC_Translation); |
280 OstreamLocker L(this); | 284 OstreamLocker L(this); |
281 getStrDump() << "ICE translation error: " << Func->getFunctionName() | 285 getStrError() << "ICE translation error: " << Func->getFunctionName() |
282 << ": " << Func->getError() << "\n"; | 286 << ": " << Func->getError() << "\n"; |
283 Item = new EmitterWorkItem(Func->getSequenceNumber()); | 287 Item = new EmitterWorkItem(Func->getSequenceNumber()); |
284 } else { | 288 } else { |
285 Func->getAssembler<>()->setInternal(Func->getInternal()); | 289 Func->getAssembler<>()->setInternal(Func->getInternal()); |
286 switch (getFlags().getOutFileType()) { | 290 switch (getFlags().getOutFileType()) { |
287 case FT_Elf: | 291 case FT_Elf: |
288 case FT_Iasm: { | 292 case FT_Iasm: { |
289 Func->emitIAS(); | 293 Func->emitIAS(); |
290 // The Cfg has already emitted into the assembly buffer, so | 294 // The Cfg has already emitted into the assembly buffer, so |
291 // stats have been fully collected into this thread's TLS. | 295 // stats have been fully collected into this thread's TLS. |
292 // Dump them before TLS is reset for the next Cfg. | 296 // Dump them before TLS is reset for the next Cfg. |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 Ctx = Func->getContext(); | 829 Ctx = Func->getContext(); |
826 Active = | 830 Active = |
827 Func->getFocusedTiming() || Ctx->getFlags().getSubzeroTimingEnabled(); | 831 Func->getFocusedTiming() || Ctx->getFlags().getSubzeroTimingEnabled(); |
828 if (Active) | 832 if (Active) |
829 Ctx->pushTimer(ID, StackID); | 833 Ctx->pushTimer(ID, StackID); |
830 } | 834 } |
831 | 835 |
832 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS); | 836 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS); |
833 | 837 |
834 } // end of namespace Ice | 838 } // end of namespace Ice |
OLD | NEW |