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 |
11 // multiple functions. | 11 // multiple functions. |
12 // | 12 // |
13 //===----------------------------------------------------------------------===// | 13 //===----------------------------------------------------------------------===// |
14 | 14 |
15 #include "llvm/ADT/STLExtras.h" | |
16 | |
15 #include <ctype.h> // isdigit(), isupper() | 17 #include <ctype.h> // isdigit(), isupper() |
16 #include <locale> // locale | 18 #include <locale> // locale |
17 | 19 |
18 #include "IceCfg.h" | 20 #include "IceCfg.h" |
19 #include "IceClFlags.h" | 21 #include "IceClFlags.h" |
20 #include "IceDefs.h" | 22 #include "IceDefs.h" |
21 #include "IceGlobalContext.h" | 23 #include "IceGlobalContext.h" |
24 #include "IceGlobalInits.h" | |
22 #include "IceOperand.h" | 25 #include "IceOperand.h" |
23 #include "IceTargetLowering.h" | 26 #include "IceTargetLowering.h" |
24 #include "IceTimerTree.h" | 27 #include "IceTimerTree.h" |
25 #include "IceTypes.h" | 28 #include "IceTypes.h" |
26 | 29 |
27 namespace Ice { | 30 namespace Ice { |
28 | 31 |
29 // TypePool maps constants of type KeyType (e.g. float) to pointers to | 32 // TypePool maps constants of type KeyType (e.g. float) to pointers to |
30 // type ValueType (e.g. ConstantFloat). KeyType values are compared | 33 // type ValueType (e.g. ConstantFloat). KeyType values are compared |
31 // using memcmp() because of potential NaN values in KeyType values. | 34 // using memcmp() because of potential NaN values in KeyType values. |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
282 OrigSuffix.data()); | 285 OrigSuffix.data()); |
283 incrementSubstitutions(NewName); | 286 incrementSubstitutions(NewName); |
284 return NewName.data(); | 287 return NewName.data(); |
285 } | 288 } |
286 | 289 |
287 // Transform bar ==> Prefixbar | 290 // Transform bar ==> Prefixbar |
288 // ^^^^^^ | 291 // ^^^^^^ |
289 return getTestPrefix() + Name; | 292 return getTestPrefix() + Name; |
290 } | 293 } |
291 | 294 |
292 GlobalContext::~GlobalContext() {} | 295 GlobalContext::~GlobalContext() { |
296 llvm::DeleteContainerPointers(GlobalAddresses); | |
297 } | |
293 | 298 |
294 Constant *GlobalContext::getConstantInt64(Type Ty, uint64_t ConstantInt64) { | 299 Constant *GlobalContext::getConstantInt64(Type Ty, uint64_t ConstantInt64) { |
295 assert(Ty == IceType_i64); | 300 assert(Ty == IceType_i64); |
296 return ConstPool->Integers64.getOrAdd(this, Ty, ConstantInt64); | 301 return ConstPool->Integers64.getOrAdd(this, Ty, ConstantInt64); |
297 } | 302 } |
298 | 303 |
299 Constant *GlobalContext::getConstantInt32(Type Ty, uint32_t ConstantInt32) { | 304 Constant *GlobalContext::getConstantInt32(Type Ty, uint32_t ConstantInt32) { |
300 if (Ty == IceType_i1) | 305 if (Ty == IceType_i1) |
301 ConstantInt32 &= UINT32_C(1); | 306 ConstantInt32 &= UINT32_C(1); |
302 return ConstPool->Integers32.getOrAdd(this, Ty, ConstantInt32); | 307 return ConstPool->Integers32.getOrAdd(this, Ty, ConstantInt32); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 BaseOS << "Unsupported constant type: " << Ty; | 383 BaseOS << "Unsupported constant type: " << Ty; |
379 llvm_unreachable(BaseOS.str().c_str()); | 384 llvm_unreachable(BaseOS.str().c_str()); |
380 } break; | 385 } break; |
381 case IceType_void: | 386 case IceType_void: |
382 case IceType_NUM: | 387 case IceType_NUM: |
383 break; | 388 break; |
384 } | 389 } |
385 llvm_unreachable("Unknown type"); | 390 llvm_unreachable("Unknown type"); |
386 } | 391 } |
387 | 392 |
393 Function *GlobalContext::newFunction(const FuncSigType *Signature, | |
394 unsigned CallingConv, unsigned Linkage, | |
395 bool IsProto) { | |
396 Function *Func = new Function( | |
397 *Signature, static_cast<llvm::CallingConv::ID>(CallingConv), | |
398 static_cast<llvm::GlobalValue::LinkageTypes>(Linkage), IsProto); | |
399 GlobalAddresses.push_back(Func); | |
400 return Func; | |
401 } | |
402 | |
403 GlobalVariable *GlobalContext::newGlobalVariable() { | |
404 GlobalVariable *Vbl = new GlobalVariable(); | |
jvoung (off chromium)
2014/10/10 01:47:28
Most abbreviations of "Variable" are "Var" in the
Karl
2014/10/10 20:17:30
Done.
| |
405 GlobalAddresses.push_back(Vbl); | |
406 return Vbl; | |
407 } | |
408 | |
388 TimerIdT GlobalContext::getTimerID(TimerStackIdT StackID, | 409 TimerIdT GlobalContext::getTimerID(TimerStackIdT StackID, |
389 const IceString &Name) { | 410 const IceString &Name) { |
390 assert(StackID < Timers.size()); | 411 assert(StackID < Timers.size()); |
391 return Timers[StackID].getTimerID(Name); | 412 return Timers[StackID].getTimerID(Name); |
392 } | 413 } |
393 | 414 |
394 TimerStackIdT GlobalContext::newTimerStackID(const IceString &Name) { | 415 TimerStackIdT GlobalContext::newTimerStackID(const IceString &Name) { |
395 TimerStackIdT NewID = Timers.size(); | 416 TimerStackIdT NewID = Timers.size(); |
396 Timers.push_back(TimerStack(Name)); | 417 Timers.push_back(TimerStack(Name)); |
397 return NewID; | 418 return NewID; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
435 } | 456 } |
436 | 457 |
437 TimerMarker::TimerMarker(TimerIdT ID, const Cfg *Func) | 458 TimerMarker::TimerMarker(TimerIdT ID, const Cfg *Func) |
438 : ID(ID), Ctx(Func->getContext()), | 459 : ID(ID), Ctx(Func->getContext()), |
439 Active(Func->getFocusedTiming() || Ctx->getFlags().SubzeroTimingEnabled) { | 460 Active(Func->getFocusedTiming() || Ctx->getFlags().SubzeroTimingEnabled) { |
440 if (Active) | 461 if (Active) |
441 Ctx->pushTimer(ID); | 462 Ctx->pushTimer(ID); |
442 } | 463 } |
443 | 464 |
444 } // end of namespace Ice | 465 } // end of namespace Ice |
OLD | NEW |