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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 public: | 98 public: |
99 ConstantPool() {} | 99 ConstantPool() {} |
100 TypePool<IceType_f32, float, ConstantFloat> Floats; | 100 TypePool<IceType_f32, float, ConstantFloat> Floats; |
101 TypePool<IceType_f64, double, ConstantDouble> Doubles; | 101 TypePool<IceType_f64, double, ConstantDouble> Doubles; |
102 TypePool<IceType_i1, int8_t, ConstantInteger32> Integers1; | 102 TypePool<IceType_i1, int8_t, ConstantInteger32> Integers1; |
103 TypePool<IceType_i8, int8_t, ConstantInteger32> Integers8; | 103 TypePool<IceType_i8, int8_t, ConstantInteger32> Integers8; |
104 TypePool<IceType_i16, int16_t, ConstantInteger32> Integers16; | 104 TypePool<IceType_i16, int16_t, ConstantInteger32> Integers16; |
105 TypePool<IceType_i32, int32_t, ConstantInteger32> Integers32; | 105 TypePool<IceType_i32, int32_t, ConstantInteger32> Integers32; |
106 TypePool<IceType_i64, int64_t, ConstantInteger64> Integers64; | 106 TypePool<IceType_i64, int64_t, ConstantInteger64> Integers64; |
107 TypePool<IceType_i32, RelocatableTuple, ConstantRelocatable> Relocatables; | 107 TypePool<IceType_i32, RelocatableTuple, ConstantRelocatable> Relocatables; |
| 108 TypePool<IceType_i32, RelocatableTuple, ConstantRelocatable> |
| 109 ExternRelocatables; |
108 UndefPool Undefs; | 110 UndefPool Undefs; |
109 }; | 111 }; |
110 | 112 |
111 void GlobalContext::CodeStats::dump(const IceString &Name, Ostream &Str) { | 113 void GlobalContext::CodeStats::dump(const IceString &Name, Ostream &Str) { |
112 if (!ALLOW_DUMP) | 114 if (!ALLOW_DUMP) |
113 return; | 115 return; |
114 Str << "|" << Name << "|Inst Count |" << InstructionsEmitted << "\n"; | 116 Str << "|" << Name << "|Inst Count |" << InstructionsEmitted << "\n"; |
115 Str << "|" << Name << "|Regs Saved |" << RegistersSaved << "\n"; | 117 Str << "|" << Name << "|Regs Saved |" << RegistersSaved << "\n"; |
116 Str << "|" << Name << "|Frame Bytes |" << FrameBytes << "\n"; | 118 Str << "|" << Name << "|Frame Bytes |" << FrameBytes << "\n"; |
117 Str << "|" << Name << "|Spills |" << Spills << "\n"; | 119 Str << "|" << Name << "|Spills |" << Spills << "\n"; |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 return getConstPool()->Doubles.getOrAdd(this, ConstantDouble); | 417 return getConstPool()->Doubles.getOrAdd(this, ConstantDouble); |
416 } | 418 } |
417 | 419 |
418 Constant *GlobalContext::getConstantSym(RelocOffsetT Offset, | 420 Constant *GlobalContext::getConstantSym(RelocOffsetT Offset, |
419 const IceString &Name, | 421 const IceString &Name, |
420 bool SuppressMangling) { | 422 bool SuppressMangling) { |
421 return getConstPool()->Relocatables.getOrAdd( | 423 return getConstPool()->Relocatables.getOrAdd( |
422 this, RelocatableTuple(Offset, Name, SuppressMangling)); | 424 this, RelocatableTuple(Offset, Name, SuppressMangling)); |
423 } | 425 } |
424 | 426 |
| 427 Constant *GlobalContext::getConstantExternSym(const IceString &Name) { |
| 428 const RelocOffsetT Offset = 0; |
| 429 const bool SuppressMangling = true; |
| 430 return getConstPool()->ExternRelocatables.getOrAdd( |
| 431 this, RelocatableTuple(Offset, Name, SuppressMangling)); |
| 432 } |
| 433 |
425 Constant *GlobalContext::getConstantUndef(Type Ty) { | 434 Constant *GlobalContext::getConstantUndef(Type Ty) { |
426 return getConstPool()->Undefs.getOrAdd(this, Ty); | 435 return getConstPool()->Undefs.getOrAdd(this, Ty); |
427 } | 436 } |
428 | 437 |
429 // All locking is done by the getConstant*() target function. | 438 // All locking is done by the getConstant*() target function. |
430 Constant *GlobalContext::getConstantZero(Type Ty) { | 439 Constant *GlobalContext::getConstantZero(Type Ty) { |
431 switch (Ty) { | 440 switch (Ty) { |
432 case IceType_i1: | 441 case IceType_i1: |
433 return getConstantInt1(0); | 442 return getConstantInt1(0); |
434 case IceType_i8: | 443 case IceType_i8: |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 BaseOS << "Unsupported constant type: " << Ty; | 496 BaseOS << "Unsupported constant type: " << Ty; |
488 llvm_unreachable(BaseOS.str().c_str()); | 497 llvm_unreachable(BaseOS.str().c_str()); |
489 } break; | 498 } break; |
490 case IceType_void: | 499 case IceType_void: |
491 case IceType_NUM: | 500 case IceType_NUM: |
492 break; | 501 break; |
493 } | 502 } |
494 llvm_unreachable("Unknown type"); | 503 llvm_unreachable("Unknown type"); |
495 } | 504 } |
496 | 505 |
| 506 ConstantList GlobalContext::getConstantExternSyms() { |
| 507 return getConstPool()->ExternRelocatables.getConstantPool(); |
| 508 } |
| 509 |
497 TimerStackIdT GlobalContext::newTimerStackID(const IceString &Name) { | 510 TimerStackIdT GlobalContext::newTimerStackID(const IceString &Name) { |
498 if (!ALLOW_DUMP) | 511 if (!ALLOW_DUMP) |
499 return 0; | 512 return 0; |
500 auto Timers = getTimers(); | 513 auto Timers = getTimers(); |
501 TimerStackIdT NewID = Timers->size(); | 514 TimerStackIdT NewID = Timers->size(); |
502 Timers->push_back(TimerStack(Name)); | 515 Timers->push_back(TimerStack(Name)); |
503 return NewID; | 516 return NewID; |
504 } | 517 } |
505 | 518 |
506 TimerIdT GlobalContext::getTimerID(TimerStackIdT StackID, | 519 TimerIdT GlobalContext::getTimerID(TimerStackIdT StackID, |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 void TimerMarker::pushCfg(const Cfg *Func) { | 587 void TimerMarker::pushCfg(const Cfg *Func) { |
575 Ctx = Func->getContext(); | 588 Ctx = Func->getContext(); |
576 Active = Func->getFocusedTiming() || Ctx->getFlags().SubzeroTimingEnabled; | 589 Active = Func->getFocusedTiming() || Ctx->getFlags().SubzeroTimingEnabled; |
577 if (Active) | 590 if (Active) |
578 Ctx->pushTimer(ID, StackID); | 591 Ctx->pushTimer(ID, StackID); |
579 } | 592 } |
580 | 593 |
581 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS); | 594 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS); |
582 | 595 |
583 } // end of namespace Ice | 596 } // end of namespace Ice |
OLD | NEW |