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