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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 ELFStreamer *ELFStr, const ClFlags &Flags) | 218 ELFStreamer *ELFStr, const ClFlags &Flags) |
219 : ConstPool(new ConstantPool()), ErrorStatus(), StrDump(OsDump), | 219 : ConstPool(new ConstantPool()), ErrorStatus(), StrDump(OsDump), |
220 StrEmit(OsEmit), StrError(OsError), Flags(Flags), | 220 StrEmit(OsEmit), StrError(OsError), Flags(Flags), |
221 RNG(Flags.getRandomSeed()), ObjectWriter(), | 221 RNG(Flags.getRandomSeed()), ObjectWriter(), |
222 OptQ(/*Sequential=*/Flags.isSequential(), | 222 OptQ(/*Sequential=*/Flags.isSequential(), |
223 /*MaxSize=*/Flags.getNumTranslationThreads()), | 223 /*MaxSize=*/Flags.getNumTranslationThreads()), |
224 // EmitQ is allowed unlimited size. | 224 // EmitQ is allowed unlimited size. |
225 EmitQ(/*Sequential=*/Flags.isSequential()), | 225 EmitQ(/*Sequential=*/Flags.isSequential()), |
226 DataLowering(TargetDataLowering::createLowering(this)), | 226 DataLowering(TargetDataLowering::createLowering(this)), |
227 HasSeenCode(false), | 227 HasSeenCode(false), |
228 ProfileBlockInfoVarDecl(VariableDeclaration::create()) { | 228 ProfileBlockInfoVarDecl(VariableDeclaration::create()), |
229 RandomizationCookie(0) { | |
229 assert(OsDump && "OsDump is not defined for GlobalContext"); | 230 assert(OsDump && "OsDump is not defined for GlobalContext"); |
230 assert(OsEmit && "OsEmit is not defined for GlobalContext"); | 231 assert(OsEmit && "OsEmit is not defined for GlobalContext"); |
231 assert(OsError && "OsError is not defined for GlobalContext"); | 232 assert(OsError && "OsError is not defined for GlobalContext"); |
232 // Make sure thread_local fields are properly initialized before any | 233 // Make sure thread_local fields are properly initialized before any |
233 // accesses are made. Do this here instead of at the start of | 234 // accesses are made. Do this here instead of at the start of |
234 // main() so that all clients (e.g. unit tests) can benefit for | 235 // main() so that all clients (e.g. unit tests) can benefit for |
235 // free. | 236 // free. |
236 GlobalContext::TlsInit(); | 237 GlobalContext::TlsInit(); |
237 Cfg::TlsInit(); | 238 Cfg::TlsInit(); |
238 // Create a new ThreadContext for the current thread. No need to | 239 // Create a new ThreadContext for the current thread. No need to |
(...skipping 19 matching lines...) Expand all Loading... | |
258 break; | 259 break; |
259 } | 260 } |
260 ProfileBlockInfoVarDecl->setAlignment(typeWidthInBytes(IceType_i64)); | 261 ProfileBlockInfoVarDecl->setAlignment(typeWidthInBytes(IceType_i64)); |
261 ProfileBlockInfoVarDecl->setIsConstant(true); | 262 ProfileBlockInfoVarDecl->setIsConstant(true); |
262 | 263 |
263 // Note: if you change this symbol, make sure to update | 264 // Note: if you change this symbol, make sure to update |
264 // runtime/szrt_profiler.c as well. | 265 // runtime/szrt_profiler.c as well. |
265 ProfileBlockInfoVarDecl->setName("__Sz_block_profile_info"); | 266 ProfileBlockInfoVarDecl->setName("__Sz_block_profile_info"); |
266 ProfileBlockInfoVarDecl->setSuppressMangling(); | 267 ProfileBlockInfoVarDecl->setSuppressMangling(); |
267 ProfileBlockInfoVarDecl->setLinkage(llvm::GlobalValue::ExternalLinkage); | 268 ProfileBlockInfoVarDecl->setLinkage(llvm::GlobalValue::ExternalLinkage); |
269 | |
270 // Initialize the randomization cookie for diversification. | |
Jim Stichnoth
2015/06/20 17:42:16
Maybe say "constant blinding" instead of "diversif
qining
2015/06/20 23:32:36
Done.
| |
271 RandomizationCookie = | |
272 (uint32_t)RNG.next((uint64_t)std::numeric_limits<uint32_t>::max + 1); | |
268 } | 273 } |
269 | 274 |
270 void GlobalContext::translateFunctions() { | 275 void GlobalContext::translateFunctions() { |
271 while (std::unique_ptr<Cfg> Func = optQueueBlockingPop()) { | 276 while (std::unique_ptr<Cfg> Func = optQueueBlockingPop()) { |
272 // Install Func in TLS for Cfg-specific container allocators. | 277 // Install Func in TLS for Cfg-specific container allocators. |
273 Cfg::setCurrentCfg(Func.get()); | 278 Cfg::setCurrentCfg(Func.get()); |
274 // Reset per-function stats being accumulated in TLS. | 279 // Reset per-function stats being accumulated in TLS. |
275 resetStats(); | 280 resetStats(); |
276 // Set verbose level to none if the current function does NOT | 281 // Set verbose level to none if the current function does NOT |
277 // match the -verbose-focus command-line option. | 282 // match the -verbose-focus command-line option. |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
746 case IceType_NUM: | 751 case IceType_NUM: |
747 break; | 752 break; |
748 } | 753 } |
749 llvm_unreachable("Unknown type"); | 754 llvm_unreachable("Unknown type"); |
750 } | 755 } |
751 | 756 |
752 ConstantList GlobalContext::getConstantPool(Type Ty) { | 757 ConstantList GlobalContext::getConstantPool(Type Ty) { |
753 switch (Ty) { | 758 switch (Ty) { |
754 case IceType_i1: | 759 case IceType_i1: |
755 case IceType_i8: | 760 case IceType_i8: |
761 return getConstPool()->Integers8.getConstantPool(); | |
756 case IceType_i16: | 762 case IceType_i16: |
763 return getConstPool()->Integers16.getConstantPool(); | |
757 case IceType_i32: | 764 case IceType_i32: |
758 return getConstPool()->Integers32.getConstantPool(); | 765 return getConstPool()->Integers32.getConstantPool(); |
759 case IceType_i64: | 766 case IceType_i64: |
760 return getConstPool()->Integers64.getConstantPool(); | 767 return getConstPool()->Integers64.getConstantPool(); |
761 case IceType_f32: | 768 case IceType_f32: |
762 return getConstPool()->Floats.getConstantPool(); | 769 return getConstPool()->Floats.getConstantPool(); |
763 case IceType_f64: | 770 case IceType_f64: |
764 return getConstPool()->Doubles.getConstantPool(); | 771 return getConstPool()->Doubles.getConstantPool(); |
765 case IceType_v4i1: | 772 case IceType_v4i1: |
766 case IceType_v8i1: | 773 case IceType_v8i1: |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
892 Ctx = Func->getContext(); | 899 Ctx = Func->getContext(); |
893 Active = | 900 Active = |
894 Func->getFocusedTiming() || Ctx->getFlags().getSubzeroTimingEnabled(); | 901 Func->getFocusedTiming() || Ctx->getFlags().getSubzeroTimingEnabled(); |
895 if (Active) | 902 if (Active) |
896 Ctx->pushTimer(ID, StackID); | 903 Ctx->pushTimer(ID, StackID); |
897 } | 904 } |
898 | 905 |
899 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS); | 906 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS); |
900 | 907 |
901 } // end of namespace Ice | 908 } // end of namespace Ice |
OLD | NEW |