diff options
| author | Owen Anderson <resistor@mac.com> | 2009-07-21 02:47:59 +0000 |
|---|---|---|
| committer | Owen Anderson <resistor@mac.com> | 2009-07-21 02:47:59 +0000 |
| commit | 2ad52176f9ea4274061435045ae45473b57d5d07 (patch) | |
| tree | 7ee9cf7301120ffa5df2c4ef07ae364f6da3fdc0 /llvm/lib/VMCore | |
| parent | 3b4e2a7621efcb9115d3a8f11f56d60f0c78407d (diff) | |
| download | bcm5719-llvm-2ad52176f9ea4274061435045ae45473b57d5d07.tar.gz bcm5719-llvm-2ad52176f9ea4274061435045ae45473b57d5d07.zip | |
Move a bit more state over to the LLVMContext.
llvm-svn: 76533
Diffstat (limited to 'llvm/lib/VMCore')
| -rw-r--r-- | llvm/lib/VMCore/Constants.cpp | 22 | ||||
| -rw-r--r-- | llvm/lib/VMCore/LLVMContext.cpp | 8 | ||||
| -rw-r--r-- | llvm/lib/VMCore/LLVMContextImpl.h | 21 |
3 files changed, 26 insertions, 25 deletions
diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp index 71e98377738..347cd166115 100644 --- a/llvm/lib/VMCore/Constants.cpp +++ b/llvm/lib/VMCore/Constants.cpp @@ -169,28 +169,6 @@ ConstantInt::ConstantInt(const IntegerType *Ty, const APInt& V) assert(V.getBitWidth() == Ty->getBitWidth() && "Invalid constant for type"); } -ConstantInt *ConstantInt::TheTrueVal = 0; -ConstantInt *ConstantInt::TheFalseVal = 0; - -namespace llvm { - void CleanupTrueFalse(void *) { - ConstantInt::ResetTrueFalse(); - } -} - -static ManagedCleanup<llvm::CleanupTrueFalse> TrueFalseCleanup; - -ConstantInt *ConstantInt::CreateTrueFalseVals(bool WhichOne) { - assert(TheTrueVal == 0 && TheFalseVal == 0); - TheTrueVal = getGlobalContext().getConstantInt(Type::Int1Ty, 1); - TheFalseVal = getGlobalContext().getConstantInt(Type::Int1Ty, 0); - - // Ensure that llvm_shutdown nulls out TheTrueVal/TheFalseVal. - TrueFalseCleanup.Register(); - - return WhichOne ? TheTrueVal : TheFalseVal; -} - //===----------------------------------------------------------------------===// // ConstantFP //===----------------------------------------------------------------------===// diff --git a/llvm/lib/VMCore/LLVMContext.cpp b/llvm/lib/VMCore/LLVMContext.cpp index 4d847a7102f..bb3762bd813 100644 --- a/llvm/lib/VMCore/LLVMContext.cpp +++ b/llvm/lib/VMCore/LLVMContext.cpp @@ -81,11 +81,15 @@ UndefValue* LLVMContext::getUndef(const Type* Ty) { // ConstantInt accessors. ConstantInt* LLVMContext::getConstantIntTrue() { - return ConstantInt::getTrue(); + assert(this && "Context not initialized!"); + assert(pImpl && "Context not initialized!"); + return pImpl->getConstantIntTrue(); } ConstantInt* LLVMContext::getConstantIntFalse() { - return ConstantInt::getFalse(); + assert(this && "Context not initialized!"); + assert(pImpl && "Context not initialized!"); + return pImpl->getConstantIntFalse(); } Constant* LLVMContext::getConstantInt(const Type* Ty, uint64_t V, diff --git a/llvm/lib/VMCore/LLVMContextImpl.h b/llvm/lib/VMCore/LLVMContextImpl.h index 129a759cd99..5571995c7e5 100644 --- a/llvm/lib/VMCore/LLVMContextImpl.h +++ b/llvm/lib/VMCore/LLVMContextImpl.h @@ -15,6 +15,8 @@ #ifndef LLVM_LLVMCONTEXT_IMPL_H #define LLVM_LLVMCONTEXT_IMPL_H +#include "llvm/LLVMContext.h" +#include "llvm/DerivedTypes.h" #include "llvm/System/RWMutex.h" #include "llvm/ADT/APFloat.h" #include "llvm/ADT/APInt.h" @@ -100,10 +102,13 @@ class LLVMContextImpl { FoldingSet<MDNode> MDNodeSet; LLVMContext &Context; + ConstantInt *TheTrueVal; + ConstantInt *TheFalseVal; + LLVMContextImpl(); LLVMContextImpl(const LLVMContextImpl&); public: - LLVMContextImpl(LLVMContext &C) : Context(C) { } + LLVMContextImpl(LLVMContext &C) : Context(C), TheTrueVal(0), TheFalseVal(0) {} /// Return a ConstantInt with the specified value and an implied Type. The /// type is the integer type that corresponds to the bit width of the value. @@ -115,6 +120,20 @@ public: MDNode *getMDNode(Value*const* Vals, unsigned NumVals); + ConstantInt *getConstantIntTrue() { + if (TheTrueVal) + return TheTrueVal; + else + return (TheTrueVal = Context.getConstantInt(IntegerType::get(1), 1)); + } + + ConstantInt *getConstantIntFalse() { + if (TheFalseVal) + return TheFalseVal; + else + return (TheFalseVal = Context.getConstantInt(IntegerType::get(1), 0)); + } + void erase(MDString *M); void erase(MDNode *M); }; |

