[llvm-commits] [llvm] r77011 - in /llvm/trunk: examples/BrainF/ examples/Fibonacci/ examples/HowToUseJIT/ examples/ModuleMaker/ examples/ParallelJIT/ include/llvm/ include/llvm/Support/ lib/Analysis/ lib/AsmParser/ lib/Bitcode/Reader/ lib/CodeGen/ lib/CodeGen/SelectionDAG/ lib/ExecutionEngine/JIT/ lib/Target/ARM/ lib/Target/Alpha/ lib/Target/CBackend/ lib/Target/X86/ lib/Target/XCore/ lib/Transforms/IPO/ lib/Transforms/Instrumentation/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ tools/bugpoint/ unittests/E...

Owen Anderson resistor at mac.com
Fri Jul 24 16:12:03 PDT 2009


Author: resistor
Date: Fri Jul 24 18:12:02 2009
New Revision: 77011

URL: http://llvm.org/viewvc/llvm-project?rev=77011&view=rev
Log:
Revert the ConstantInt constructors back to their 2.5 forms where possible, thanks to contexts-on-types.  More to come.

Modified:
    llvm/trunk/examples/BrainF/BrainF.cpp
    llvm/trunk/examples/BrainF/BrainFDriver.cpp
    llvm/trunk/examples/Fibonacci/fibonacci.cpp
    llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp
    llvm/trunk/examples/ModuleMaker/ModuleMaker.cpp
    llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp
    llvm/trunk/include/llvm/Constants.h
    llvm/trunk/include/llvm/LLVMContext.h
    llvm/trunk/include/llvm/Support/IRBuilder.h
    llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
    llvm/trunk/lib/Analysis/ConstantFolding.cpp
    llvm/trunk/lib/Analysis/DebugInfo.cpp
    llvm/trunk/lib/Analysis/ScalarEvolution.cpp
    llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp
    llvm/trunk/lib/AsmParser/LLParser.cpp
    llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
    llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
    llvm/trunk/lib/CodeGen/ShadowStackGC.cpp
    llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp
    llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp
    llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp
    llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp
    llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp
    llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp
    llvm/trunk/lib/Target/CBackend/CBackend.cpp
    llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
    llvm/trunk/lib/Target/XCore/XCoreISelDAGToDAG.cpp
    llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
    llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
    llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp
    llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp
    llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp
    llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp
    llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
    llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
    llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
    llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp
    llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
    llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp
    llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp
    llvm/trunk/lib/Transforms/Scalar/PredicateSimplifier.cpp
    llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp
    llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
    llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp
    llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp
    llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
    llvm/trunk/lib/Transforms/Utils/LowerAllocations.cpp
    llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp
    llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
    llvm/trunk/lib/VMCore/AutoUpgrade.cpp
    llvm/trunk/lib/VMCore/ConstantFold.cpp
    llvm/trunk/lib/VMCore/Constants.cpp
    llvm/trunk/lib/VMCore/Core.cpp
    llvm/trunk/lib/VMCore/Instructions.cpp
    llvm/trunk/lib/VMCore/LLVMContext.cpp
    llvm/trunk/lib/VMCore/LLVMContextImpl.cpp
    llvm/trunk/lib/VMCore/LLVMContextImpl.h
    llvm/trunk/tools/bugpoint/ExtractFunction.cpp
    llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp
    llvm/trunk/unittests/Support/ValueHandleTest.cpp
    llvm/trunk/unittests/VMCore/ConstantsTest.cpp
    llvm/trunk/unittests/VMCore/MetadataTest.cpp
    llvm/trunk/win32/unistd.h

Modified: llvm/trunk/examples/BrainF/BrainF.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/BrainF/BrainF.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/examples/BrainF/BrainF.cpp (original)
+++ llvm/trunk/examples/BrainF/BrainF.cpp Fri Jul 24 18:12:02 2009
@@ -77,16 +77,16 @@
   builder = new IRBuilder<>(BasicBlock::Create(label, brainf_func));
 
   //%arr = malloc i8, i32 %d
-  ConstantInt *val_mem = C.getConstantInt(APInt(32, memtotal));
+  ConstantInt *val_mem = ConstantInt::get(C, APInt(32, memtotal));
   ptr_arr = builder->CreateMalloc(IntegerType::Int8Ty, val_mem, "arr");
 
   //call void @llvm.memset.i32(i8 *%arr, i8 0, i32 %d, i32 1)
   {
     Value *memset_params[] = {
       ptr_arr,
-      C.getConstantInt(APInt(8, 0)),
+      ConstantInt::get(C, APInt(8, 0)),
       val_mem,
-      C.getConstantInt(APInt(32, 1))
+      ConstantInt::get(C, APInt(32, 1))
     };
 
     CallInst *memset_call = builder->
@@ -97,12 +97,12 @@
   //%arrmax = getelementptr i8 *%arr, i32 %d
   if (comflag & flag_arraybounds) {
     ptr_arrmax = builder->
-      CreateGEP(ptr_arr, C.getConstantInt(APInt(32, memtotal)), "arrmax");
+      CreateGEP(ptr_arr, ConstantInt::get(C, APInt(32, memtotal)), "arrmax");
   }
 
   //%head.%d = getelementptr i8 *%arr, i32 %d
   curhead = builder->CreateGEP(ptr_arr,
-                               C.getConstantInt(APInt(32, memtotal/2)),
+                               ConstantInt::get(C, APInt(32, memtotal/2)),
                                headreg);
 
 
@@ -229,7 +229,7 @@
         {
           //%head.%d = getelementptr i8 *%head.%d, i32 %d
           curhead = builder->
-            CreateGEP(curhead, C.getConstantInt(APInt(32, curvalue)),
+            CreateGEP(curhead, ConstantInt::get(C, APInt(32, curvalue)),
                       headreg);
 
           //Error block for array out of bounds
@@ -264,7 +264,7 @@
 
           //%tape.%d = add i8 %tape.%d, %d
           Value *tape_1 = builder->
-            CreateAdd(tape_0, C.getConstantInt(APInt(8, curvalue)), tapereg);
+            CreateAdd(tape_0, ConstantInt::get(C, APInt(8, curvalue)), tapereg);
 
           //store i8 %tape.%d, i8 *%head.%d\n"
           builder->CreateStore(tape_1, curhead);
@@ -429,7 +429,7 @@
 
       //%test.%d = icmp eq i8 %tape.%d, 0
       ICmpInst *test_0 = new ICmpInst(*testbb, ICmpInst::ICMP_EQ, tape_0,
-                                      C.getConstantInt(APInt(8, 0)), testreg);
+                                    ConstantInt::get(C, APInt(8, 0)), testreg);
 
       //br i1 %test.%d, label %main.%d, label %main.%d
       BasicBlock *bb_0 = BasicBlock::Create(label, brainf_func);

Modified: llvm/trunk/examples/BrainF/BrainFDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/BrainF/BrainFDriver.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/examples/BrainF/BrainFDriver.cpp (original)
+++ llvm/trunk/examples/BrainF/BrainFDriver.cpp Fri Jul 24 18:12:02 2009
@@ -80,7 +80,7 @@
   }
 
   //ret i32 0
-  ReturnInst::Create(getGlobalContext().getConstantInt(APInt(32, 0)), bb);
+  ReturnInst::Create(ConstantInt::get(getGlobalContext(), APInt(32, 0)), bb);
 }
 
 int main(int argc, char **argv) {

Modified: llvm/trunk/examples/Fibonacci/fibonacci.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Fibonacci/fibonacci.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/examples/Fibonacci/fibonacci.cpp (original)
+++ llvm/trunk/examples/Fibonacci/fibonacci.cpp Fri Jul 24 18:12:02 2009
@@ -47,8 +47,8 @@
   BasicBlock *BB = BasicBlock::Create("EntryBlock", FibF);
 
   // Get pointers to the constants.
-  Value *One = Context.getConstantInt(Type::Int32Ty, 1);
-  Value *Two = Context.getConstantInt(Type::Int32Ty, 2);
+  Value *One = ConstantInt::get(Type::Int32Ty, 1);
+  Value *Two = ConstantInt::get(Type::Int32Ty, 2);
 
   // Get pointer to the integer argument of the add1 function...
   Argument *ArgX = FibF->arg_begin();   // Get the arg.

Modified: llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp (original)
+++ llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp Fri Jul 24 18:12:02 2009
@@ -69,7 +69,7 @@
   BasicBlock *BB = BasicBlock::Create("EntryBlock", Add1F);
 
   // Get pointers to the constant `1'.
-  Value *One = Context.getConstantInt(Type::Int32Ty, 1);
+  Value *One = ConstantInt::get(Type::Int32Ty, 1);
 
   // Get pointers to the integer argument of the add1 function...
   assert(Add1F->arg_begin() != Add1F->arg_end()); // Make sure there's an arg
@@ -94,7 +94,7 @@
   BB = BasicBlock::Create("EntryBlock", FooF);
 
   // Get pointers to the constant `10'.
-  Value *Ten = Context.getConstantInt(Type::Int32Ty, 10);
+  Value *Ten = ConstantInt::get(Type::Int32Ty, 10);
 
   // Pass Ten to the call call:
   CallInst *Add1CallRes = CallInst::Create(Add1F, Ten, "add1", BB);

Modified: llvm/trunk/examples/ModuleMaker/ModuleMaker.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/ModuleMaker/ModuleMaker.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/examples/ModuleMaker/ModuleMaker.cpp (original)
+++ llvm/trunk/examples/ModuleMaker/ModuleMaker.cpp Fri Jul 24 18:12:02 2009
@@ -42,8 +42,8 @@
   BasicBlock *BB = BasicBlock::Create("EntryBlock", F);
 
   // Get pointers to the constant integers...
-  Value *Two = Context.getConstantInt(Type::Int32Ty, 2);
-  Value *Three = Context.getConstantInt(Type::Int32Ty, 3);
+  Value *Two = ConstantInt::get(Type::Int32Ty, 2);
+  Value *Three = ConstantInt::get(Type::Int32Ty, 3);
 
   // Create the add instruction... does not insert...
   Instruction *Add = BinaryOperator::Create(Instruction::Add, Two, Three,

Modified: llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp (original)
+++ llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp Fri Jul 24 18:12:02 2009
@@ -44,7 +44,7 @@
   BasicBlock *BB = BasicBlock::Create("EntryBlock", Add1F);
 
   // Get pointers to the constant `1'.
-  Value *One = M->getContext().getConstantInt(Type::Int32Ty, 1);
+  Value *One = ConstantInt::get(Type::Int32Ty, 1);
 
   // Get pointers to the integer argument of the add1 function...
   assert(Add1F->arg_begin() != Add1F->arg_end()); // Make sure there's an arg
@@ -72,8 +72,8 @@
   BasicBlock *BB = BasicBlock::Create("EntryBlock", FibF);
 
   // Get pointers to the constants.
-  Value *One = M->getContext().getConstantInt(Type::Int32Ty, 1);
-  Value *Two = M->getContext().getConstantInt(Type::Int32Ty, 2);
+  Value *One = ConstantInt::get(Type::Int32Ty, 1);
+  Value *Two = ConstantInt::get(Type::Int32Ty, 2);
 
   // Get pointer to the integer argument of the add1 function...
   Argument *ArgX = FibF->arg_begin();   // Get the arg.

Modified: llvm/trunk/include/llvm/Constants.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constants.h?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Constants.h (original)
+++ llvm/trunk/include/llvm/Constants.h Fri Jul 24 18:12:02 2009
@@ -57,6 +57,35 @@
     return User::operator new(s, 0);
   }
 public:
+  /// If Ty is a vector type, return a Constant with a splat of the given
+  /// value. Otherwise return a ConstantInt for the given value.
+  static Constant* get(const Type* Ty, uint64_t V, bool isSigned = false);
+                              
+  /// Return a ConstantInt with the specified integer value for the specified
+  /// type. If the type is wider than 64 bits, the value will be zero-extended
+  /// to fit the type, unless isSigned is true, in which case the value will
+  /// be interpreted as a 64-bit signed integer and sign-extended to fit
+  /// the type.
+  /// @brief Get a ConstantInt for a specific value.
+  static ConstantInt* get(const IntegerType* Ty, uint64_t V,
+                          bool isSigned = false);
+
+  /// Return a ConstantInt with the specified value for the specified type. The
+  /// value V will be canonicalized to a an unsigned APInt. Accessing it with
+  /// either getSExtValue() or getZExtValue() will yield a correctly sized and
+  /// signed value for the type Ty.
+  /// @brief Get a ConstantInt for a specific signed value.
+  static ConstantInt* getSigned(const IntegerType* Ty, int64_t V);
+  static Constant *getSigned(const Type *Ty, int64_t V);
+  
+  /// 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.
+  static ConstantInt* get(LLVMContext &Context, const APInt& V);
+  
+  /// If Ty is a vector type, return a Constant with a splat of the given
+  /// value. Otherwise return a ConstantInt for the given value.
+  static Constant* get(const Type* Ty, const APInt& V);
+  
   /// Return the constant as an APInt value reference. This allows clients to
   /// obtain a copy of the value, with all its precision in tact.
   /// @brief Return the constant's value.

Modified: llvm/trunk/include/llvm/LLVMContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LLVMContext.h?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/include/llvm/LLVMContext.h (original)
+++ llvm/trunk/include/llvm/LLVMContext.h Fri Jul 24 18:12:02 2009
@@ -53,6 +53,8 @@
 /// to have one context per thread.
 class LLVMContext {
   LLVMContextImpl* pImpl;
+  
+  friend class ConstantInt;
 public:
   LLVMContext();
   ~LLVMContext();
@@ -72,36 +74,6 @@
   ConstantInt* getTrue();
   ConstantInt* getFalse();
   
-  /// If Ty is a vector type, return a Constant with a splat of the given
-  /// value. Otherwise return a ConstantInt for the given value.
-  Constant* getConstantInt(const Type* Ty, uint64_t V,
-                              bool isSigned = false);
-                              
-  /// Return a ConstantInt with the specified integer value for the specified
-  /// type. If the type is wider than 64 bits, the value will be zero-extended
-  /// to fit the type, unless isSigned is true, in which case the value will
-  /// be interpreted as a 64-bit signed integer and sign-extended to fit
-  /// the type.
-  /// @brief Get a ConstantInt for a specific value.
-  ConstantInt* getConstantInt(const IntegerType* Ty, uint64_t V,
-                              bool isSigned = false);
-
-  /// Return a ConstantInt with the specified value for the specified type. The
-  /// value V will be canonicalized to a an unsigned APInt. Accessing it with
-  /// either getSExtValue() or getZExtValue() will yield a correctly sized and
-  /// signed value for the type Ty.
-  /// @brief Get a ConstantInt for a specific signed value.
-  ConstantInt* getConstantIntSigned(const IntegerType* Ty, int64_t V);
-  Constant *getConstantIntSigned(const Type *Ty, int64_t V);
-  
-  /// 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.
-  ConstantInt* getConstantInt(const APInt& V);
-  
-  /// If Ty is a vector type, return a Constant with a splat of the given
-  /// value. Otherwise return a ConstantInt for the given value.
-  Constant* getConstantInt(const Type* Ty, const APInt& V);
-  
   // ConstantPointerNull accessors
   ConstantPointerNull* getConstantPointerNull(const PointerType* T);
   

Modified: llvm/trunk/include/llvm/Support/IRBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/IRBuilder.h (original)
+++ llvm/trunk/include/llvm/Support/IRBuilder.h Fri Jul 24 18:12:02 2009
@@ -370,7 +370,7 @@
     return Insert(GetElementPtrInst::Create(Ptr, Idx), Name);
   }
   Value *CreateConstGEP1_32(Value *Ptr, unsigned Idx0, const char *Name = "") {
-    Value *Idx = Context.getConstantInt(Type::Int32Ty, Idx0);
+    Value *Idx = ConstantInt::get(Type::Int32Ty, Idx0);
 
     if (Constant *PC = dyn_cast<Constant>(Ptr))
       return Folder.CreateGetElementPtr(PC, &Idx, 1);
@@ -380,8 +380,8 @@
   Value *CreateConstGEP2_32(Value *Ptr, unsigned Idx0, unsigned Idx1, 
                     const char *Name = "") {
     Value *Idxs[] = {
-      Context.getConstantInt(Type::Int32Ty, Idx0),
-      Context.getConstantInt(Type::Int32Ty, Idx1)
+      ConstantInt::get(Type::Int32Ty, Idx0),
+      ConstantInt::get(Type::Int32Ty, Idx1)
     };
 
     if (Constant *PC = dyn_cast<Constant>(Ptr))
@@ -390,7 +390,7 @@
     return Insert(GetElementPtrInst::Create(Ptr, Idxs, Idxs+2), Name);    
   }
   Value *CreateConstGEP1_64(Value *Ptr, uint64_t Idx0, const char *Name = "") {
-    Value *Idx = Context.getConstantInt(Type::Int64Ty, Idx0);
+    Value *Idx = ConstantInt::get(Type::Int64Ty, Idx0);
 
     if (Constant *PC = dyn_cast<Constant>(Ptr))
       return Folder.CreateGetElementPtr(PC, &Idx, 1);
@@ -400,8 +400,8 @@
   Value *CreateConstGEP2_64(Value *Ptr, uint64_t Idx0, uint64_t Idx1, 
                     const char *Name = "") {
     Value *Idxs[] = {
-      Context.getConstantInt(Type::Int64Ty, Idx0),
-      Context.getConstantInt(Type::Int64Ty, Idx1)
+      ConstantInt::get(Type::Int64Ty, Idx0),
+      ConstantInt::get(Type::Int64Ty, Idx1)
     };
 
     if (Constant *PC = dyn_cast<Constant>(Ptr))
@@ -428,7 +428,7 @@
   }
   Value *CreateGlobalStringPtr(const char *Str = "", const char *Name = "") {
     Value *gv = CreateGlobalString(Str, Name);
-    Value *zero = Context.getConstantInt(Type::Int32Ty, 0);
+    Value *zero = ConstantInt::get(Type::Int32Ty, 0);
     Value *Args[] = { zero, zero };
     return CreateGEP(gv, Args, Args+2, Name);
   }

Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Fri Jul 24 18:12:02 2009
@@ -780,10 +780,10 @@
           //
           if (const ArrayType *AT = dyn_cast<ArrayType>(BasePtr1Ty))
             GEP1Ops[i] =
-                  Context.getConstantInt(Type::Int64Ty,AT->getNumElements()-1);
+                  ConstantInt::get(Type::Int64Ty,AT->getNumElements()-1);
           else if (const VectorType *VT = dyn_cast<VectorType>(BasePtr1Ty))
             GEP1Ops[i] = 
-                  Context.getConstantInt(Type::Int64Ty,VT->getNumElements()-1);
+                  ConstantInt::get(Type::Int64Ty,VT->getNumElements()-1);
         }
       }
 

Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original)
+++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Fri Jul 24 18:12:02 2009
@@ -113,7 +113,7 @@
       if (IsConstantOffsetFromGlobal(Op1, GV2, Offs2, *TD) &&
           GV1 == GV2) {
         // (&GV+C1) - (&GV+C2) -> C1-C2, pointer arithmetic cannot overflow.
-        return Context.getConstantInt(Op0->getType(), Offs1-Offs2);
+        return ConstantInt::get(Op0->getType(), Offs1-Offs2);
       }
   }
     
@@ -151,7 +151,7 @@
   
   uint64_t Offset = TD->getIndexedOffset(Ptr->getType(),
                                          (Value**)Ops+1, NumOps-1);
-  Constant *C = Context.getConstantInt(TD->getIntPtrType(), Offset+BasePtr);
+  Constant *C = ConstantInt::get(TD->getIntPtrType(), Offset+BasePtr);
   return Context.getConstantExprIntToPtr(C, ResultTy);
 }
 
@@ -232,7 +232,7 @@
             
             // Shift it to the right place, depending on endianness.
             Src = Context.getConstantExprShl(Src, 
-                             Context.getConstantInt(Src->getType(), ShiftAmt));
+                             ConstantInt::get(Src->getType(), ShiftAmt));
             ShiftAmt += isLittleEndian ? SrcBitSize : -SrcBitSize;
             
             // Mix it in.
@@ -255,7 +255,7 @@
             // Shift the piece of the value into the right place, depending on
             // endianness.
             Constant *Elt = Context.getConstantExprLShr(Src, 
-                            Context.getConstantInt(Src->getType(), ShiftAmt));
+                            ConstantInt::get(Src->getType(), ShiftAmt));
             ShiftAmt += isLittleEndian ? DstBitSize : -DstBitSize;
 
             // Truncate and remember this piece.
@@ -376,7 +376,7 @@
         unsigned InWidth = Input->getType()->getScalarSizeInBits();
         if (TD->getPointerSizeInBits() < InWidth) {
           Constant *Mask = 
-            Context.getConstantInt(APInt::getLowBitsSet(InWidth,
+            ConstantInt::get(Context, APInt::getLowBitsSet(InWidth,
                                                   TD->getPointerSizeInBits()));
           Input = Context.getConstantExprAnd(Input, Mask);
         }
@@ -420,7 +420,7 @@
                                             AT->getNumElements()))) {
                         Constant *Index[] = {
                           Context.getNullValue(CE->getType()),
-                          Context.getConstantInt(ElemIdx)
+                          ConstantInt::get(Context, ElemIdx)
                         };
                         return
                         Context.getConstantExprGetElementPtr(GV, &Index[0], 2);
@@ -801,13 +801,13 @@
       }
     } else if (ConstantInt *Op = dyn_cast<ConstantInt>(Operands[0])) {
       if (Len > 11 && !memcmp(Str, "llvm.bswap", 10))
-        return Context.getConstantInt(Op->getValue().byteSwap());
+        return ConstantInt::get(Context, Op->getValue().byteSwap());
       else if (Len > 11 && !memcmp(Str, "llvm.ctpop", 10))
-        return Context.getConstantInt(Ty, Op->getValue().countPopulation());
+        return ConstantInt::get(Ty, Op->getValue().countPopulation());
       else if (Len > 10 && !memcmp(Str, "llvm.cttz", 9))
-        return Context.getConstantInt(Ty, Op->getValue().countTrailingZeros());
+        return ConstantInt::get(Ty, Op->getValue().countTrailingZeros());
       else if (Len > 10 && !memcmp(Str, "llvm.ctlz", 9))
-        return Context.getConstantInt(Ty, Op->getValue().countLeadingZeros());
+        return ConstantInt::get(Ty, Op->getValue().countLeadingZeros());
     }
   } else if (NumOperands == 2) {
     if (ConstantFP *Op1 = dyn_cast<ConstantFP>(Operands[0])) {

Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/DebugInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/DebugInfo.cpp Fri Jul 24 18:12:02 2009
@@ -482,7 +482,7 @@
 Constant *DIFactory::GetTagConstant(unsigned TAG) {
   assert((TAG & LLVMDebugVersionMask) == 0 &&
          "Tag too large for debug encoding!");
-  return VMContext.getConstantInt(Type::Int32Ty, TAG | LLVMDebugVersion);
+  return ConstantInt::get(Type::Int32Ty, TAG | LLVMDebugVersion);
 }
 
 Constant *DIFactory::GetStringConstant(const std::string &String) {
@@ -541,8 +541,8 @@
 DISubrange DIFactory::GetOrCreateSubrange(int64_t Lo, int64_t Hi) {
   Constant *Elts[] = {
     GetTagConstant(dwarf::DW_TAG_subrange_type),
-    VMContext.getConstantInt(Type::Int64Ty, Lo),
-    VMContext.getConstantInt(Type::Int64Ty, Hi)
+    ConstantInt::get(Type::Int64Ty, Lo),
+    ConstantInt::get(Type::Int64Ty, Hi)
   };
   
   Constant *Init = VMContext.getConstantStruct(Elts, 
@@ -577,14 +577,14 @@
   Constant *Elts[] = {
     GetTagConstant(dwarf::DW_TAG_compile_unit),
     VMContext.getNullValue(EmptyStructPtr),
-    VMContext.getConstantInt(Type::Int32Ty, LangID),
+    ConstantInt::get(Type::Int32Ty, LangID),
     GetStringConstant(Filename),
     GetStringConstant(Directory),
     GetStringConstant(Producer),
-    VMContext.getConstantInt(Type::Int1Ty, isMain),
-    VMContext.getConstantInt(Type::Int1Ty, isOptimized),
+    ConstantInt::get(Type::Int1Ty, isMain),
+    ConstantInt::get(Type::Int1Ty, isOptimized),
     GetStringConstant(Flags),
-    VMContext.getConstantInt(Type::Int32Ty, RunTimeVer)
+    ConstantInt::get(Type::Int32Ty, RunTimeVer)
   };
   
   Constant *Init = VMContext.getConstantStruct(Elts,
@@ -603,7 +603,7 @@
   Constant *Elts[] = {
     GetTagConstant(dwarf::DW_TAG_enumerator),
     GetStringConstant(Name),
-    VMContext.getConstantInt(Type::Int64Ty, Val)
+    ConstantInt::get(Type::Int64Ty, Val)
   };
   
   Constant *Init = VMContext.getConstantStruct(Elts,
@@ -632,12 +632,12 @@
     getCastToEmpty(Context),
     GetStringConstant(Name),
     getCastToEmpty(CompileUnit),
-    VMContext.getConstantInt(Type::Int32Ty, LineNumber),
-    VMContext.getConstantInt(Type::Int64Ty, SizeInBits),
-    VMContext.getConstantInt(Type::Int64Ty, AlignInBits),
-    VMContext.getConstantInt(Type::Int64Ty, OffsetInBits),
-    VMContext.getConstantInt(Type::Int32Ty, Flags),
-    VMContext.getConstantInt(Type::Int32Ty, Encoding)
+    ConstantInt::get(Type::Int32Ty, LineNumber),
+    ConstantInt::get(Type::Int64Ty, SizeInBits),
+    ConstantInt::get(Type::Int64Ty, AlignInBits),
+    ConstantInt::get(Type::Int64Ty, OffsetInBits),
+    ConstantInt::get(Type::Int32Ty, Flags),
+    ConstantInt::get(Type::Int32Ty, Encoding)
   };
   
   Constant *Init = VMContext.getConstantStruct(Elts,
@@ -668,11 +668,11 @@
     getCastToEmpty(Context),
     GetStringConstant(Name),
     getCastToEmpty(CompileUnit),
-    VMContext.getConstantInt(Type::Int32Ty, LineNumber),
-    VMContext.getConstantInt(Type::Int64Ty, SizeInBits),
-    VMContext.getConstantInt(Type::Int64Ty, AlignInBits),
-    VMContext.getConstantInt(Type::Int64Ty, OffsetInBits),
-    VMContext.getConstantInt(Type::Int32Ty, Flags),
+    ConstantInt::get(Type::Int32Ty, LineNumber),
+    ConstantInt::get(Type::Int64Ty, SizeInBits),
+    ConstantInt::get(Type::Int64Ty, AlignInBits),
+    ConstantInt::get(Type::Int64Ty, OffsetInBits),
+    ConstantInt::get(Type::Int32Ty, Flags),
     getCastToEmpty(DerivedFrom)
   };
   
@@ -706,14 +706,14 @@
     getCastToEmpty(Context),
     GetStringConstant(Name),
     getCastToEmpty(CompileUnit),
-    VMContext.getConstantInt(Type::Int32Ty, LineNumber),
-    VMContext.getConstantInt(Type::Int64Ty, SizeInBits),
-    VMContext.getConstantInt(Type::Int64Ty, AlignInBits),
-    VMContext.getConstantInt(Type::Int64Ty, OffsetInBits),
-    VMContext.getConstantInt(Type::Int32Ty, Flags),
+    ConstantInt::get(Type::Int32Ty, LineNumber),
+    ConstantInt::get(Type::Int64Ty, SizeInBits),
+    ConstantInt::get(Type::Int64Ty, AlignInBits),
+    ConstantInt::get(Type::Int64Ty, OffsetInBits),
+    ConstantInt::get(Type::Int32Ty, Flags),
     getCastToEmpty(DerivedFrom),
     getCastToEmpty(Elements),
-    VMContext.getConstantInt(Type::Int32Ty, RuntimeLang)
+    ConstantInt::get(Type::Int32Ty, RuntimeLang)
   };
   
   Constant *Init = VMContext.getConstantStruct(Elts,
@@ -748,10 +748,10 @@
     GetStringConstant(DisplayName),
     GetStringConstant(LinkageName),
     getCastToEmpty(CompileUnit),
-    VMContext.getConstantInt(Type::Int32Ty, LineNo),
+    ConstantInt::get(Type::Int32Ty, LineNo),
     getCastToEmpty(Type),
-    VMContext.getConstantInt(Type::Int1Ty, isLocalToUnit),
-    VMContext.getConstantInt(Type::Int1Ty, isDefinition)
+    ConstantInt::get(Type::Int1Ty, isLocalToUnit),
+    ConstantInt::get(Type::Int1Ty, isDefinition)
   };
   
   Constant *Init = VMContext.getConstantStruct(Elts,
@@ -781,10 +781,10 @@
     GetStringConstant(DisplayName),
     GetStringConstant(LinkageName),
     getCastToEmpty(CompileUnit),
-    VMContext.getConstantInt(Type::Int32Ty, LineNo),
+    ConstantInt::get(Type::Int32Ty, LineNo),
     getCastToEmpty(Type),
-    VMContext.getConstantInt(Type::Int1Ty, isLocalToUnit),
-    VMContext.getConstantInt(Type::Int1Ty, isDefinition),
+    ConstantInt::get(Type::Int1Ty, isLocalToUnit),
+    ConstantInt::get(Type::Int1Ty, isDefinition),
     VMContext.getConstantExprBitCast(Val, EmptyStructPtr)
   };
   
@@ -810,7 +810,7 @@
     getCastToEmpty(Context),
     GetStringConstant(Name),
     getCastToEmpty(CompileUnit),
-    VMContext.getConstantInt(Type::Int32Ty, LineNo),
+    ConstantInt::get(Type::Int32Ty, LineNo),
     getCastToEmpty(Type)
   };
   
@@ -862,8 +862,8 @@
   
   // Invoke llvm.dbg.stoppoint
   Value *Args[] = {
-    VMContext.getConstantInt(llvm::Type::Int32Ty, LineNo),
-    VMContext.getConstantInt(llvm::Type::Int32Ty, ColNo),
+    ConstantInt::get(llvm::Type::Int32Ty, LineNo),
+    ConstantInt::get(llvm::Type::Int32Ty, ColNo),
     getCastToEmpty(CU)
   };
   CallInst::Create(StopPointFn, Args, Args+3, "", BB);

Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Fri Jul 24 18:12:02 2009
@@ -192,13 +192,13 @@
 }
 
 const SCEV *ScalarEvolution::getConstant(const APInt& Val) {
-  return getConstant(getContext().getConstantInt(Val));
+  return getConstant(ConstantInt::get(getContext(), Val));
 }
 
 const SCEV *
 ScalarEvolution::getConstant(const Type *Ty, uint64_t V, bool isSigned) {
   return getConstant(
-    getContext().getConstantInt(cast<IntegerType>(Ty), V, isSigned));
+    ConstantInt::get(cast<IntegerType>(Ty), V, isSigned));
 }
 
 const Type *SCEVConstant::getType() const { return V->getType(); }
@@ -1518,7 +1518,8 @@
     ++Idx;
     while (const SCEVConstant *RHSC = dyn_cast<SCEVConstant>(Ops[Idx])) {
       // We found two constants, fold them together!
-      ConstantInt *Fold = getContext().getConstantInt(LHSC->getValue()->getValue() *
+      ConstantInt *Fold = ConstantInt::get(getContext(),
+                                           LHSC->getValue()->getValue() *
                                            RHSC->getValue()->getValue());
       Ops[0] = getConstant(Fold);
       Ops.erase(Ops.begin()+1);  // Erase the folded element
@@ -1869,7 +1870,7 @@
     assert(Idx < Ops.size());
     while (const SCEVConstant *RHSC = dyn_cast<SCEVConstant>(Ops[Idx])) {
       // We found two constants, fold them together!
-      ConstantInt *Fold = getContext().getConstantInt(
+      ConstantInt *Fold = ConstantInt::get(getContext(),
                               APIntOps::smax(LHSC->getValue()->getValue(),
                                              RHSC->getValue()->getValue()));
       Ops[0] = getConstant(Fold);
@@ -1966,7 +1967,7 @@
     assert(Idx < Ops.size());
     while (const SCEVConstant *RHSC = dyn_cast<SCEVConstant>(Ops[Idx])) {
       // We found two constants, fold them together!
-      ConstantInt *Fold = getContext().getConstantInt(
+      ConstantInt *Fold = ConstantInt::get(getContext(),
                               APIntOps::umax(LHSC->getValue()->getValue(),
                                              RHSC->getValue()->getValue()));
       Ops[0] = getConstant(Fold);
@@ -2133,7 +2134,7 @@
 /// specified signed integer value and return a SCEV for the constant.
 const SCEV *ScalarEvolution::getIntegerSCEV(int Val, const Type *Ty) {
   const IntegerType *ITy = cast<IntegerType>(getEffectiveSCEVType(Ty));
-  return getConstant(getContext().getConstantInt(ITy, Val));
+  return getConstant(ConstantInt::get(ITy, Val));
 }
 
 /// getNegativeSCEV - Return a SCEV corresponding to -V = -1*V
@@ -2896,7 +2897,7 @@
     // Turn shift left of a constant amount into a multiply.
     if (ConstantInt *SA = dyn_cast<ConstantInt>(U->getOperand(1))) {
       uint32_t BitWidth = cast<IntegerType>(V->getType())->getBitWidth();
-      Constant *X = getContext().getConstantInt(
+      Constant *X = ConstantInt::get(getContext(),
         APInt(BitWidth, 1).shl(SA->getLimitedValue(BitWidth)));
       return getMulExpr(getSCEV(U->getOperand(0)), getSCEV(X));
     }
@@ -2906,7 +2907,7 @@
     // Turn logical shift right of a constant into a unsigned divide.
     if (ConstantInt *SA = dyn_cast<ConstantInt>(U->getOperand(1))) {
       uint32_t BitWidth = cast<IntegerType>(V->getType())->getBitWidth();
-      Constant *X = getContext().getConstantInt(
+      Constant *X = ConstantInt::get(getContext(),
         APInt(BitWidth, 1).shl(SA->getLimitedValue(BitWidth)));
       return getUDivExpr(getSCEV(U->getOperand(0)), getSCEV(X));
     }
@@ -3558,7 +3559,7 @@
 
   unsigned MaxSteps = MaxBruteForceIterations;
   for (unsigned IterationNum = 0; IterationNum != MaxSteps; ++IterationNum) {
-    ConstantInt *ItCst = getContext().getConstantInt(
+    ConstantInt *ItCst = ConstantInt::get(
                            cast<IntegerType>(IdxExpr->getType()), IterationNum);
     ConstantInt *Val = EvaluateConstantChrecAtConstant(IdxExpr, ItCst, *this);
 
@@ -4072,9 +4073,9 @@
     LLVMContext &Context = SE.getContext();
 
     ConstantInt *Solution1 =
-      Context.getConstantInt((NegB + SqrtVal).sdiv(TwoA));
+      ConstantInt::get(Context, (NegB + SqrtVal).sdiv(TwoA));
     ConstantInt *Solution2 =
-      Context.getConstantInt((NegB - SqrtVal).sdiv(TwoA));
+      ConstantInt::get(Context, (NegB - SqrtVal).sdiv(TwoA));
 
     return std::make_pair(SE.getConstant(Solution1),
                           SE.getConstant(Solution2));
@@ -4836,7 +4837,7 @@
 
     // The exit value should be (End+A)/A.
     APInt ExitVal = (End + A).udiv(A);
-    ConstantInt *ExitValue = SE.getContext().getConstantInt(ExitVal);
+    ConstantInt *ExitValue = ConstantInt::get(SE.getContext(), ExitVal);
 
     // Evaluate at the exit value.  If we really did fall out of the valid
     // range, then we computed our trip count, otherwise wrap around or other
@@ -4848,7 +4849,7 @@
     // Ensure that the previous value is in the range.  This is a sanity check.
     assert(Range.contains(
            EvaluateConstantChrecAtConstant(this,
-           SE.getContext().getConstantInt(ExitVal - One), SE)->getValue()) &&
+           ConstantInt::get(SE.getContext(), ExitVal - One), SE)->getValue()) &&
            "Linear scev computation is off in a bad way!");
     return SE.getConstant(ExitValue);
   } else if (isQuadratic()) {
@@ -4883,7 +4884,7 @@
         if (Range.contains(R1Val->getValue())) {
           // The next iteration must be out of the range...
           ConstantInt *NextVal =
-                 SE.getContext().getConstantInt(R1->getValue()->getValue()+1);
+                ConstantInt::get(SE.getContext(), R1->getValue()->getValue()+1);
 
           R1Val = EvaluateConstantChrecAtConstant(this, NextVal, SE);
           if (!Range.contains(R1Val->getValue()))
@@ -4894,7 +4895,7 @@
         // If R1 was not in the range, then it is a good return value.  Make
         // sure that R1-1 WAS in the range though, just in case.
         ConstantInt *NextVal =
-                 SE.getContext().getConstantInt(R1->getValue()->getValue()-1);
+               ConstantInt::get(SE.getContext(), R1->getValue()->getValue()-1);
         R1Val = EvaluateConstantChrecAtConstant(this, NextVal, SE);
         if (Range.contains(R1Val->getValue()))
           return R1;

Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Fri Jul 24 18:12:02 2009
@@ -167,7 +167,7 @@
   // For a Constant, check for a multiple of the given factor.
   if (const SCEVConstant *C = dyn_cast<SCEVConstant>(S)) {
     ConstantInt *CI =
-      SE.getContext().getConstantInt(C->getValue()->getValue().sdiv(Factor));
+      ConstantInt::get(SE.getContext(), C->getValue()->getValue().sdiv(Factor));
     // If the quotient is zero and the remainder is non-zero, reject
     // the value at this scale. It will be considered for subsequent
     // smaller scales.
@@ -298,8 +298,7 @@
             uint64_t FullOffset = C->getValue()->getZExtValue();
             if (FullOffset < SL.getSizeInBytes()) {
               unsigned ElIdx = SL.getElementContainingOffset(FullOffset);
-              GepIndices.push_back(
-                            getContext().getConstantInt(Type::Int32Ty, ElIdx));
+              GepIndices.push_back(ConstantInt::get(Type::Int32Ty, ElIdx));
               ElTy = STy->getTypeAtIndex(ElIdx);
               Ops[0] =
                 SE.getConstant(Ty, FullOffset - SL.getElementOffset(ElIdx));
@@ -412,7 +411,7 @@
     const APInt &RHS = SC->getValue()->getValue();
     if (RHS.isPowerOf2())
       return InsertBinop(Instruction::LShr, LHS,
-                         getContext().getConstantInt(Ty, RHS.logBase2()));
+                         ConstantInt::get(Ty, RHS.logBase2()));
   }
 
   Value *RHS = expandCodeFor(S->getRHS(), Ty);
@@ -532,7 +531,7 @@
 
     // Insert a unit add instruction right before the terminator corresponding
     // to the back-edge.
-    Constant *One = getContext().getConstantInt(Ty, 1);
+    Constant *One = ConstantInt::get(Ty, 1);
     Instruction *Add = BinaryOperator::CreateAdd(PN, One, "indvar.next",
                                                  (*HPI)->getTerminator());
     InsertedValues.insert(Add);

Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Fri Jul 24 18:12:02 2009
@@ -2138,7 +2138,7 @@
     if (!isa<IntegerType>(Ty))
       return Error(ID.Loc, "integer constant must have integer type");
     ID.APSIntVal.extOrTrunc(Ty->getPrimitiveSizeInBits());
-    V = Context.getConstantInt(ID.APSIntVal);
+    V = ConstantInt::get(Context, ID.APSIntVal);
     return false;
   case ValID::t_APFloat:
     if (!Ty->isFloatingPoint() ||

Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Fri Jul 24 18:12:02 2009
@@ -877,7 +877,7 @@
     case bitc::CST_CODE_INTEGER:   // INTEGER: [intval]
       if (!isa<IntegerType>(CurTy) || Record.empty())
         return Error("Invalid CST_INTEGER record");
-      V = Context.getConstantInt(CurTy, DecodeSignRotatedValue(Record[0]));
+      V = ConstantInt::get(CurTy, DecodeSignRotatedValue(Record[0]));
       break;
     case bitc::CST_CODE_WIDE_INTEGER: {// WIDE_INTEGER: [n x intval]
       if (!isa<IntegerType>(CurTy) || Record.empty())
@@ -888,8 +888,9 @@
       Words.resize(NumWords);
       for (unsigned i = 0; i != NumWords; ++i)
         Words[i] = DecodeSignRotatedValue(Record[i]);
-      V = Context.getConstantInt(APInt(cast<IntegerType>(CurTy)->getBitWidth(),
-                                 NumWords, &Words[0]));
+      V = ConstantInt::get(Context, 
+                           APInt(cast<IntegerType>(CurTy)->getBitWidth(),
+                           NumWords, &Words[0]));
       break;
     }
     case bitc::CST_CODE_FLOAT: {    // FLOAT: [fpval]
@@ -951,7 +952,7 @@
       unsigned Size = Record.size();
       std::vector<Constant*> Elts;
       for (unsigned i = 0; i != Size; ++i)
-        Elts.push_back(Context.getConstantInt(EltTy, Record[i]));
+        Elts.push_back(ConstantInt::get(EltTy, Record[i]));
       V = Context.getConstantArray(ATy, Elts);
       break;
     }
@@ -965,7 +966,7 @@
       unsigned Size = Record.size();
       std::vector<Constant*> Elts;
       for (unsigned i = 0; i != Size; ++i)
-        Elts.push_back(Context.getConstantInt(EltTy, Record[i]));
+        Elts.push_back(ConstantInt::get(EltTy, Record[i]));
       Elts.push_back(Context.getNullValue(EltTy));
       V = Context.getConstantArray(ATy, Elts);
       break;

Modified: llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp (original)
+++ llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp Fri Jul 24 18:12:02 2009
@@ -159,27 +159,27 @@
   switch(BitSize) {
   default: llvm_unreachable("Unhandled type size of value to byteswap!");
   case 16: {
-    Value *Tmp1 = Builder.CreateShl(V, Context.getConstantInt(V->getType(), 8),
+    Value *Tmp1 = Builder.CreateShl(V, ConstantInt::get(V->getType(), 8),
                                     "bswap.2");
-    Value *Tmp2 = Builder.CreateLShr(V, Context.getConstantInt(V->getType(), 8),
+    Value *Tmp2 = Builder.CreateLShr(V, ConstantInt::get(V->getType(), 8),
                                      "bswap.1");
     V = Builder.CreateOr(Tmp1, Tmp2, "bswap.i16");
     break;
   }
   case 32: {
-    Value *Tmp4 = Builder.CreateShl(V, Context.getConstantInt(V->getType(), 24),
+    Value *Tmp4 = Builder.CreateShl(V, ConstantInt::get(V->getType(), 24),
                                     "bswap.4");
-    Value *Tmp3 = Builder.CreateShl(V, Context.getConstantInt(V->getType(), 8),
+    Value *Tmp3 = Builder.CreateShl(V, ConstantInt::get(V->getType(), 8),
                                     "bswap.3");
-    Value *Tmp2 = Builder.CreateLShr(V, Context.getConstantInt(V->getType(), 8),
+    Value *Tmp2 = Builder.CreateLShr(V, ConstantInt::get(V->getType(), 8),
                                      "bswap.2");
-    Value *Tmp1 = Builder.CreateLShr(V,Context.getConstantInt(V->getType(), 24),
+    Value *Tmp1 = Builder.CreateLShr(V,ConstantInt::get(V->getType(), 24),
                                      "bswap.1");
     Tmp3 = Builder.CreateAnd(Tmp3,
-                             Context.getConstantInt(Type::Int32Ty, 0xFF0000),
+                             ConstantInt::get(Type::Int32Ty, 0xFF0000),
                              "bswap.and3");
     Tmp2 = Builder.CreateAnd(Tmp2,
-                             Context.getConstantInt(Type::Int32Ty, 0xFF00),
+                             ConstantInt::get(Type::Int32Ty, 0xFF00),
                              "bswap.and2");
     Tmp4 = Builder.CreateOr(Tmp4, Tmp3, "bswap.or1");
     Tmp2 = Builder.CreateOr(Tmp2, Tmp1, "bswap.or2");
@@ -187,44 +187,44 @@
     break;
   }
   case 64: {
-    Value *Tmp8 = Builder.CreateShl(V, Context.getConstantInt(V->getType(), 56),
+    Value *Tmp8 = Builder.CreateShl(V, ConstantInt::get(V->getType(), 56),
                                     "bswap.8");
-    Value *Tmp7 = Builder.CreateShl(V, Context.getConstantInt(V->getType(), 40),
+    Value *Tmp7 = Builder.CreateShl(V, ConstantInt::get(V->getType(), 40),
                                     "bswap.7");
-    Value *Tmp6 = Builder.CreateShl(V, Context.getConstantInt(V->getType(), 24),
+    Value *Tmp6 = Builder.CreateShl(V, ConstantInt::get(V->getType(), 24),
                                     "bswap.6");
-    Value *Tmp5 = Builder.CreateShl(V, Context.getConstantInt(V->getType(), 8),
+    Value *Tmp5 = Builder.CreateShl(V, ConstantInt::get(V->getType(), 8),
                                     "bswap.5");
-    Value* Tmp4 = Builder.CreateLShr(V, Context.getConstantInt(V->getType(), 8),
+    Value* Tmp4 = Builder.CreateLShr(V, ConstantInt::get(V->getType(), 8),
                                      "bswap.4");
     Value* Tmp3 = Builder.CreateLShr(V, 
-                                     Context.getConstantInt(V->getType(), 24),
+                                     ConstantInt::get(V->getType(), 24),
                                      "bswap.3");
     Value* Tmp2 = Builder.CreateLShr(V, 
-                                     Context.getConstantInt(V->getType(), 40),
+                                     ConstantInt::get(V->getType(), 40),
                                      "bswap.2");
     Value* Tmp1 = Builder.CreateLShr(V, 
-                                     Context.getConstantInt(V->getType(), 56),
+                                     ConstantInt::get(V->getType(), 56),
                                      "bswap.1");
     Tmp7 = Builder.CreateAnd(Tmp7,
-                             Context.getConstantInt(Type::Int64Ty,
+                             ConstantInt::get(Type::Int64Ty,
                                               0xFF000000000000ULL),
                              "bswap.and7");
     Tmp6 = Builder.CreateAnd(Tmp6,
-                             Context.getConstantInt(Type::Int64Ty,
+                             ConstantInt::get(Type::Int64Ty,
                                               0xFF0000000000ULL),
                              "bswap.and6");
     Tmp5 = Builder.CreateAnd(Tmp5,
-                        Context.getConstantInt(Type::Int64Ty, 0xFF00000000ULL),
+                        ConstantInt::get(Type::Int64Ty, 0xFF00000000ULL),
                              "bswap.and5");
     Tmp4 = Builder.CreateAnd(Tmp4,
-                        Context.getConstantInt(Type::Int64Ty, 0xFF000000ULL),
+                        ConstantInt::get(Type::Int64Ty, 0xFF000000ULL),
                              "bswap.and4");
     Tmp3 = Builder.CreateAnd(Tmp3,
-                             Context.getConstantInt(Type::Int64Ty, 0xFF0000ULL),
+                             ConstantInt::get(Type::Int64Ty, 0xFF0000ULL),
                              "bswap.and3");
     Tmp2 = Builder.CreateAnd(Tmp2,
-                             Context.getConstantInt(Type::Int64Ty, 0xFF00ULL),
+                             ConstantInt::get(Type::Int64Ty, 0xFF00ULL),
                              "bswap.and2");
     Tmp8 = Builder.CreateOr(Tmp8, Tmp7, "bswap.or1");
     Tmp6 = Builder.CreateOr(Tmp6, Tmp5, "bswap.or2");
@@ -254,23 +254,23 @@
 
   unsigned BitSize = V->getType()->getPrimitiveSizeInBits();
   unsigned WordSize = (BitSize + 63) / 64;
-  Value *Count = Context.getConstantInt(V->getType(), 0);
+  Value *Count = ConstantInt::get(V->getType(), 0);
 
   for (unsigned n = 0; n < WordSize; ++n) {
     Value *PartValue = V;
     for (unsigned i = 1, ct = 0; i < (BitSize>64 ? 64 : BitSize); 
          i <<= 1, ++ct) {
-      Value *MaskCst = Context.getConstantInt(V->getType(), MaskValues[ct]);
+      Value *MaskCst = ConstantInt::get(V->getType(), MaskValues[ct]);
       Value *LHS = Builder.CreateAnd(PartValue, MaskCst, "cppop.and1");
       Value *VShift = Builder.CreateLShr(PartValue,
-                                        Context.getConstantInt(V->getType(), i),
+                                        ConstantInt::get(V->getType(), i),
                                          "ctpop.sh");
       Value *RHS = Builder.CreateAnd(VShift, MaskCst, "cppop.and2");
       PartValue = Builder.CreateAdd(LHS, RHS, "ctpop.step");
     }
     Count = Builder.CreateAdd(PartValue, Count, "ctpop.part");
     if (BitSize > 64) {
-      V = Builder.CreateLShr(V, Context.getConstantInt(V->getType(), 64),
+      V = Builder.CreateLShr(V, ConstantInt::get(V->getType(), 64),
                              "ctpop.part.sh");
       BitSize -= 64;
     }
@@ -287,7 +287,7 @@
 
   unsigned BitSize = V->getType()->getPrimitiveSizeInBits();
   for (unsigned i = 1; i < BitSize; i <<= 1) {
-    Value *ShVal = Context.getConstantInt(V->getType(), i);
+    Value *ShVal = ConstantInt::get(V->getType(), i);
     ShVal = Builder.CreateLShr(V, ShVal, "ctlz.sh");
     V = Builder.CreateOr(V, ShVal, "ctlz.step");
   }
@@ -378,7 +378,7 @@
     Value *Src = CI->getOperand(1);
     Value *NotSrc = Builder.CreateNot(Src);
     NotSrc->setName(Src->getName() + ".not");
-    Value *SrcM1 = Context.getConstantInt(Src->getType(), 1);
+    Value *SrcM1 = ConstantInt::get(Src->getType(), 1);
     SrcM1 = Builder.CreateSub(Src, SrcM1);
     Src = LowerCTPOP(Context, Builder.CreateAnd(NotSrc, SrcM1), CI);
     CI->replaceAllUsesWith(Src);
@@ -414,7 +414,7 @@
   case Intrinsic::readcyclecounter: {
     cerr << "WARNING: this target does not support the llvm.readcyclecoun"
          << "ter intrinsic.  It is being lowered to a constant 0\n";
-    CI->replaceAllUsesWith(Context.getConstantInt(Type::Int64Ty, 0));
+    CI->replaceAllUsesWith(ConstantInt::get(Type::Int64Ty, 0));
     break;
   }
 
@@ -434,7 +434,7 @@
   case Intrinsic::eh_typeid_for_i32:
   case Intrinsic::eh_typeid_for_i64:
     // Return something different to eh_selector.
-    CI->replaceAllUsesWith(Context.getConstantInt(CI->getType(), 1));
+    CI->replaceAllUsesWith(ConstantInt::get(CI->getType(), 1));
     break;
 
   case Intrinsic::var_annotation:
@@ -506,7 +506,7 @@
   case Intrinsic::flt_rounds:
      // Lower to "round to the nearest"
      if (CI->getType() != Type::VoidTy)
-       CI->replaceAllUsesWith(Context.getConstantInt(CI->getType(), 1));
+       CI->replaceAllUsesWith(ConstantInt::get(CI->getType(), 1));
      break;
   }
 

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Fri Jul 24 18:12:02 2009
@@ -109,7 +109,7 @@
         APInt IntVal(IntBitWidth, 2, x);
 
         unsigned IntegerReg =
-          getRegForValue(V->getContext().getConstantInt(IntVal));
+          getRegForValue(ConstantInt::get(V->getContext(), IntVal));
         if (IntegerReg != 0)
           Reg = FastEmit_r(IntVT.getSimpleVT(), VT, ISD::SINT_TO_FP, IntegerReg);
       }

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Fri Jul 24 18:12:02 2009
@@ -2038,7 +2038,7 @@
   case MVT::i64: FF = 0x5F800000ULL; break;  // 2^64 (as a float)
   }
   if (TLI.isLittleEndian()) FF <<= 32;
-  Constant *FudgeFactor = DAG.getContext()->getConstantInt(Type::Int64Ty, FF);
+  Constant *FudgeFactor = ConstantInt::get(Type::Int64Ty, FF);
 
   SDValue CPIdx = DAG.getConstantPool(FudgeFactor, TLI.getPointerTy());
   unsigned Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlignment();

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp Fri Jul 24 18:12:02 2009
@@ -2306,7 +2306,7 @@
 
     // Build a 64 bit pair (0, FF) in the constant pool, with FF in the lo bits.
     SDValue FudgePtr = DAG.getConstantPool(
-                                  DAG.getContext()->getConstantInt(FF.zext(64)),
+                               ConstantInt::get(*DAG.getContext(), FF.zext(64)),
                                            TLI.getPointerTy());
 
     // Get a pointer to FF if the sign bit was set, or to 0 otherwise.

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Fri Jul 24 18:12:02 2009
@@ -874,7 +874,7 @@
 }
 
 SDValue SelectionDAG::getConstant(const APInt &Val, MVT VT, bool isT) {
-  return getConstant(*Context->getConstantInt(Val), VT, isT);
+  return getConstant(*ConstantInt::get(*Context, Val), VT, isT);
 }
 
 SDValue SelectionDAG::getConstant(const ConstantInt &Val, MVT VT, bool isT) {

Modified: llvm/trunk/lib/CodeGen/ShadowStackGC.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ShadowStackGC.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/ShadowStackGC.cpp (original)
+++ llvm/trunk/lib/CodeGen/ShadowStackGC.cpp Fri Jul 24 18:12:02 2009
@@ -203,8 +203,8 @@
   }
 
   Constant *BaseElts[] = {
-    Context.getConstantInt(Type::Int32Ty, Roots.size(), false),
-    Context.getConstantInt(Type::Int32Ty, NumMeta, false),
+    ConstantInt::get(Type::Int32Ty, Roots.size(), false),
+    ConstantInt::get(Type::Int32Ty, NumMeta, false),
   };
 
   Constant *DescriptorElts[] = {
@@ -236,8 +236,8 @@
                                     GlobalVariable::InternalLinkage,
                                     FrameMap, "__gc_" + F.getName());
 
-  Constant *GEPIndices[2] = { Context.getConstantInt(Type::Int32Ty, 0),
-                              Context.getConstantInt(Type::Int32Ty, 0) };
+  Constant *GEPIndices[2] = { ConstantInt::get(Type::Int32Ty, 0),
+                              ConstantInt::get(Type::Int32Ty, 0) };
   return Context.getConstantExprGetElementPtr(GV, GEPIndices, 2);
 }
 
@@ -342,9 +342,9 @@
 GetElementPtrInst *
 ShadowStackGC::CreateGEP(LLVMContext &Context, IRBuilder<> &B, Value *BasePtr,
                          int Idx, int Idx2, const char *Name) {
-  Value *Indices[] = { Context.getConstantInt(Type::Int32Ty, 0),
-                       Context.getConstantInt(Type::Int32Ty, Idx),
-                       Context.getConstantInt(Type::Int32Ty, Idx2) };
+  Value *Indices[] = { ConstantInt::get(Type::Int32Ty, 0),
+                       ConstantInt::get(Type::Int32Ty, Idx),
+                       ConstantInt::get(Type::Int32Ty, Idx2) };
   Value* Val = B.CreateGEP(BasePtr, Indices, Indices + 3, Name);
 
   assert(isa<GetElementPtrInst>(Val) && "Unexpected folded constant");
@@ -355,8 +355,8 @@
 GetElementPtrInst *
 ShadowStackGC::CreateGEP(LLVMContext &Context, IRBuilder<> &B, Value *BasePtr,
                          int Idx, const char *Name) {
-  Value *Indices[] = { Context.getConstantInt(Type::Int32Ty, 0),
-                       Context.getConstantInt(Type::Int32Ty, Idx) };
+  Value *Indices[] = { ConstantInt::get(Type::Int32Ty, 0),
+                       ConstantInt::get(Type::Int32Ty, Idx) };
   Value *Val = B.CreateGEP(BasePtr, Indices, Indices + 2, Name);
 
   assert(isa<GetElementPtrInst>(Val) && "Unexpected folded constant");

Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Fri Jul 24 18:12:02 2009
@@ -487,7 +487,7 @@
     switch (ArgTy->getTypeID()) {
     default: llvm_unreachable("Unknown argument type for function call!");
     case Type::IntegerTyID:
-        C = Context.getConstantInt(AV.IntVal);
+        C = ConstantInt::get(F->getContext(), AV.IntVal);
         break;
     case Type::FloatTyID:
         C = Context.getConstantFP(APFloat(AV.FloatVal));
@@ -503,9 +503,9 @@
     case Type::PointerTyID:
       void *ArgPtr = GVTOP(AV);
       if (sizeof(void*) == 4)
-        C = Context.getConstantInt(Type::Int32Ty, (int)(intptr_t)ArgPtr);
+        C = ConstantInt::get(Type::Int32Ty, (int)(intptr_t)ArgPtr);
       else
-        C = Context.getConstantInt(Type::Int64Ty, (intptr_t)ArgPtr);
+        C = ConstantInt::get(Type::Int64Ty, (intptr_t)ArgPtr);
       // Cast the integer to pointer
       C = Context.getConstantExprIntToPtr(C, ArgTy);
       break;

Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Fri Jul 24 18:12:02 2009
@@ -903,8 +903,7 @@
                   unsigned PredReg) const {
   MachineFunction &MF = *MBB.getParent();
   MachineConstantPool *ConstantPool = MF.getConstantPool();
-  Constant *C =
-             MF.getFunction()->getContext().getConstantInt(Type::Int32Ty, Val);
+  Constant *C = ConstantInt::get(Type::Int32Ty, Val);
   unsigned Idx = ConstantPool->getConstantPoolIndex(C, 4);
 
   BuildMI(MBB, MBBI, dl, TII.get(ARM::LDRcp))

Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Fri Jul 24 18:12:02 2009
@@ -877,8 +877,7 @@
                !ARM_AM::isSOImmTwoPartVal(Val));     // two instrs.
     if (UseCP) {
       SDValue CPIdx =
-        CurDAG->getTargetConstantPool(
-                       CurDAG->getContext()->getConstantInt(Type::Int32Ty, Val),
+        CurDAG->getTargetConstantPool(ConstantInt::get(Type::Int32Ty, Val),
                                       TLI.getPointerTy());
 
       SDNode *ResNode;

Modified: llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp Fri Jul 24 18:12:02 2009
@@ -58,8 +58,7 @@
                                            unsigned PredReg) const {
   MachineFunction &MF = *MBB.getParent();
   MachineConstantPool *ConstantPool = MF.getConstantPool();
-  Constant *C =
-             MF.getFunction()->getContext().getConstantInt(Type::Int32Ty, Val);
+  Constant *C = ConstantInt::get(Type::Int32Ty, Val);
   unsigned Idx = ConstantPool->getConstantPoolIndex(C, 4);
 
   BuildMI(MBB, MBBI, dl, TII.get(ARM::tLDRcp))

Modified: llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp Fri Jul 24 18:12:02 2009
@@ -52,8 +52,7 @@
                                            unsigned PredReg) const {
   MachineFunction &MF = *MBB.getParent();
   MachineConstantPool *ConstantPool = MF.getConstantPool();
-  Constant *C = 
-             MF.getFunction()->getContext().getConstantInt(Type::Int32Ty, Val);
+  Constant *C = ConstantInt::get(Type::Int32Ty, Val);
   unsigned Idx = ConstantPool->getConstantPoolIndex(C, 4);
 
   BuildMI(MBB, MBBI, dl, TII.get(ARM::t2LDRpci))

Modified: llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp Fri Jul 24 18:12:02 2009
@@ -305,7 +305,7 @@
       // val32 >= IMM_LOW  + IMM_LOW  * IMM_MULT) //always true
       break; //(zext (LDAH (LDA)))
     //Else use the constant pool
-    ConstantInt *C = CurDAG->getContext()->getConstantInt(Type::Int64Ty, uval);
+    ConstantInt *C = ConstantInt::get(Type::Int64Ty, uval);
     SDValue CPI = CurDAG->getTargetConstantPool(C, MVT::i64);
     SDNode *Tmp = CurDAG->getTargetNode(Alpha::LDAHr, dl, MVT::i64, CPI,
                                         SDValue(getGlobalBaseReg(), 0));

Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original)
+++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Fri Jul 24 18:12:02 2009
@@ -3500,7 +3500,7 @@
     if (!ITy->isPowerOf2ByteWidth())
       // We have a bit width that doesn't match an even power-of-2 byte
       // size. Consequently we must & the value with the type's bit mask
-      BitMask = I.getContext().getConstantInt(ITy, ITy->getBitMask());
+      BitMask = ConstantInt::get(ITy, ITy->getBitMask());
   if (BitMask)
     Out << "((";
   writeOperand(Operand);

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri Jul 24 18:12:02 2009
@@ -4889,10 +4889,10 @@
 
   // Build some magic constants.
   std::vector<Constant*> CV0;
-  CV0.push_back(Context->getConstantInt(APInt(32, 0x45300000)));
-  CV0.push_back(Context->getConstantInt(APInt(32, 0x43300000)));
-  CV0.push_back(Context->getConstantInt(APInt(32, 0)));
-  CV0.push_back(Context->getConstantInt(APInt(32, 0)));
+  CV0.push_back(ConstantInt::get(*Context, APInt(32, 0x45300000)));
+  CV0.push_back(ConstantInt::get(*Context, APInt(32, 0x43300000)));
+  CV0.push_back(ConstantInt::get(*Context, APInt(32, 0)));
+  CV0.push_back(ConstantInt::get(*Context, APInt(32, 0)));
   Constant *C0 = Context->getConstantVector(CV0);
   SDValue CPIdx0 = DAG.getConstantPool(C0, getPointerTy(), 16);
 

Modified: llvm/trunk/lib/Target/XCore/XCoreISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreISelDAGToDAG.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Target/XCore/XCoreISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/XCore/XCoreISelDAGToDAG.cpp Fri Jul 24 18:12:02 2009
@@ -174,8 +174,7 @@
         else if (! Predicate_immU16(N)) {
           unsigned Val = cast<ConstantSDNode>(N)->getZExtValue();
           SDValue CPIdx =
-            CurDAG->getTargetConstantPool(
-                       CurDAG->getContext()->getConstantInt(Type::Int32Ty, Val),
+            CurDAG->getTargetConstantPool(ConstantInt::get(Type::Int32Ty, Val),
                                           TLI.getPointerTy());
           return CurDAG->getTargetNode(XCore::LDWCP_lru6, dl, MVT::i32, 
                                        MVT::Other, CPIdx, 

Modified: llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp Fri Jul 24 18:12:02 2009
@@ -638,9 +638,9 @@
         // Emit a GEP and load for each element of the struct.
         const Type *AgTy = cast<PointerType>(I->getType())->getElementType();
         const StructType *STy = cast<StructType>(AgTy);
-        Value *Idxs[2] = { Context.getConstantInt(Type::Int32Ty, 0), 0 };
+        Value *Idxs[2] = { ConstantInt::get(Type::Int32Ty, 0), 0 };
         for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
-          Idxs[1] = Context.getConstantInt(Type::Int32Ty, i);
+          Idxs[1] = ConstantInt::get(Type::Int32Ty, i);
           Value *Idx = GetElementPtrInst::Create(*AI, Idxs, Idxs+2,
                                                  (*AI)->getName()+"."+utostr(i),
                                                  Call);
@@ -665,7 +665,7 @@
               // Use i32 to index structs, and i64 for others (pointers/arrays).
               // This satisfies GEP constraints.
               const Type *IdxTy = (isa<StructType>(ElTy) ? Type::Int32Ty : Type::Int64Ty);
-              Ops.push_back(Context.getConstantInt(IdxTy, *II));
+              Ops.push_back(ConstantInt::get(IdxTy, *II));
               // Keep track of the type we're currently indexing
               ElTy = cast<CompositeType>(ElTy)->getTypeAtIndex(*II);
             }
@@ -758,10 +758,10 @@
       const Type *AgTy = cast<PointerType>(I->getType())->getElementType();
       Value *TheAlloca = new AllocaInst(AgTy, 0, "", InsertPt);
       const StructType *STy = cast<StructType>(AgTy);
-      Value *Idxs[2] = { Context.getConstantInt(Type::Int32Ty, 0), 0 };
+      Value *Idxs[2] = { ConstantInt::get(Type::Int32Ty, 0), 0 };
 
       for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
-        Idxs[1] = Context.getConstantInt(Type::Int32Ty, i);
+        Idxs[1] = ConstantInt::get(Type::Int32Ty, i);
         Value *Idx = 
           GetElementPtrInst::Create(TheAlloca, Idxs, Idxs+2,
                                     TheAlloca->getName()+"."+utostr(i), 

Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Fri Jul 24 18:12:02 2009
@@ -488,7 +488,7 @@
     const StructLayout &Layout = *TD.getStructLayout(STy);
     for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
       Constant *In = getAggregateConstantElement(Init,
-                                    Context.getConstantInt(Type::Int32Ty, i),
+                                    ConstantInt::get(Type::Int32Ty, i),
                                     Context);
       assert(In && "Couldn't get element of initializer?");
       GlobalVariable *NGV = new GlobalVariable(Context,
@@ -523,7 +523,7 @@
     unsigned EltAlign = TD.getABITypeAlignment(STy->getElementType());
     for (unsigned i = 0, e = NumElements; i != e; ++i) {
       Constant *In = getAggregateConstantElement(Init,
-                                    Context.getConstantInt(Type::Int32Ty, i),
+                                    ConstantInt::get(Type::Int32Ty, i),
                                     Context);
       assert(In && "Couldn't get element of initializer?");
 
@@ -1508,7 +1508,7 @@
       if (const ArrayType *AT = dyn_cast<ArrayType>(MI->getAllocatedType())) {
         MallocInst *NewMI = 
           new MallocInst(AllocSTy, 
-                  Context.getConstantInt(Type::Int32Ty, AT->getNumElements()),
+                  ConstantInt::get(Type::Int32Ty, AT->getNumElements()),
                          "", MI);
         NewMI->takeName(MI);
         Value *Cast = new BitCastInst(NewMI, MI->getType(), "tmp", MI);
@@ -1605,7 +1605,7 @@
       // Only do this if we weren't storing a loaded value.
       Value *StoreVal;
       if (StoringOther || SI->getOperand(0) == InitVal)
-        StoreVal = Context.getConstantInt(Type::Int1Ty, StoringOther);
+        StoreVal = ConstantInt::get(Type::Int1Ty, StoringOther);
       else {
         // Otherwise, we are storing a previously loaded copy.  To do this,
         // change the copy from copying the original value to just copying the
@@ -1947,7 +1947,7 @@
                                           LLVMContext &Context) {
   // If we made a change, reassemble the initializer list.
   std::vector<Constant*> CSVals;
-  CSVals.push_back(Context.getConstantInt(Type::Int32Ty, 65535));
+  CSVals.push_back(ConstantInt::get(Type::Int32Ty, 65535));
   CSVals.push_back(0);
   
   // Create the new init list.
@@ -1959,7 +1959,7 @@
       const Type *FTy = Context.getFunctionType(Type::VoidTy, false);
       const PointerType *PFTy = Context.getPointerTypeUnqual(FTy);
       CSVals[1] = Context.getNullValue(PFTy);
-      CSVals[0] = Context.getConstantInt(Type::Int32Ty, 2147483647);
+      CSVals[0] = ConstantInt::get(Type::Int32Ty, 2147483647);
     }
     CAList.push_back(Context.getConstantStruct(CSVals));
   }

Modified: llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/LowerSetJmp.cpp Fri Jul 24 18:12:02 2009
@@ -383,8 +383,7 @@
     new BitCastInst(Inst->getOperand(1), SBPTy, "SBJmpBuf", Inst);
   std::vector<Value*> Args = 
     make_vector<Value*>(GetSetJmpMap(Func), BufPtr,
-                        Inst->getContext().getConstantInt(Type::Int32Ty,
-                                         SetJmpIDMap[Func]++), 0);
+                        ConstantInt::get(Type::Int32Ty,SetJmpIDMap[Func]++), 0);
   CallInst::Create(AddSJToMap, Args.begin(), Args.end(), "", Inst);
 
   // We are guaranteed that there are no values live across basic blocks
@@ -434,9 +433,8 @@
 
   // Add the case for this setjmp's number...
   SwitchValuePair SVP = GetSJSwitch(Func, GetRethrowBB(Func));
-  SVP.first->addCase(Inst->getContext().getConstantInt(Type::Int32Ty,
-                                             SetJmpIDMap[Func] - 1),
-                                             SetJmpContBlock);
+  SVP.first->addCase(ConstantInt::get(Type::Int32Ty, SetJmpIDMap[Func] - 1),
+                     SetJmpContBlock);
 
   // Value coming from the handling of the exception.
   PHI->addIncoming(SVP.second, SVP.second->getParent());

Modified: llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp Fri Jul 24 18:12:02 2009
@@ -55,7 +55,7 @@
     // pass null.
     Args[2] = Context.getConstantPointerNull(UIntPtr);
   }
-  Args[3] = Context.getConstantInt(Type::Int32Ty, NumElements);
+  Args[3] = ConstantInt::get(Type::Int32Ty, NumElements);
 
   Instruction *InitCall = CallInst::Create(InitFn, Args.begin(), Args.end(),
                                            "newargc", InsertPos);
@@ -111,7 +111,7 @@
   // Create the getelementptr constant expression
   std::vector<Constant*> Indices(2);
   Indices[0] = Context.getNullValue(Type::Int32Ty);
-  Indices[1] = Context.getConstantInt(Type::Int32Ty, CounterNum);
+  Indices[1] = ConstantInt::get(Type::Int32Ty, CounterNum);
   Constant *ElementPtr = 
     Context.getConstantExprGetElementPtr(CounterArray, &Indices[0],
                                           Indices.size());
@@ -119,7 +119,7 @@
   // Load, increment and store the value back.
   Value *OldVal = new LoadInst(ElementPtr, "OldFuncCounter", InsertPos);
   Value *NewVal = BinaryOperator::Create(Instruction::Add, OldVal,
-                                      Context.getConstantInt(Type::Int32Ty, 1),
+                                      ConstantInt::get(Type::Int32Ty, 1),
                                          "NewFuncCounter", InsertPos);
   new StoreInst(NewVal, ElementPtr, InsertPos);
 }

Modified: llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp Fri Jul 24 18:12:02 2009
@@ -197,7 +197,7 @@
   
 GlobalRandomCounter::GlobalRandomCounter(Module& M, const IntegerType* t,
                                          uint64_t resetval) : T(t) {
-  ConstantInt* Init = M.getContext().getConstantInt(T, resetval); 
+  ConstantInt* Init = ConstantInt::get(T, resetval); 
   ResetValue = Init;
   Counter = new GlobalVariable(M, T, false, GlobalValue::InternalLinkage,
                                Init, "RandomSteeringCounter");
@@ -209,16 +209,15 @@
 
 void GlobalRandomCounter::ProcessChoicePoint(BasicBlock* bb) {
   BranchInst* t = cast<BranchInst>(bb->getTerminator());
-  LLVMContext &Context = bb->getContext();
   
   //decrement counter
   LoadInst* l = new LoadInst(Counter, "counter", t);
   
   ICmpInst* s = new ICmpInst(t, ICmpInst::ICMP_EQ, l,
-                             Context.getConstantInt(T, 0), 
+                             ConstantInt::get(T, 0), 
                              "countercc");
 
-  Value* nv = BinaryOperator::CreateSub(l, Context.getConstantInt(T, 1),
+  Value* nv = BinaryOperator::CreateSub(l, ConstantInt::get(T, 1),
                                         "counternew", t);
   new StoreInst(nv, Counter, t);
   t->setCondition(s);
@@ -236,7 +235,7 @@
 GlobalRandomCounterOpt::GlobalRandomCounterOpt(Module& M, const IntegerType* t,
                                                uint64_t resetval) 
   : AI(0), T(t) {
-  ConstantInt* Init = M.getContext().getConstantInt(T, resetval);
+  ConstantInt* Init = ConstantInt::get(T, resetval);
   ResetValue  = Init;
   Counter = new GlobalVariable(M, T, false, GlobalValue::InternalLinkage,
                                Init, "RandomSteeringCounter");
@@ -283,16 +282,15 @@
 
 void GlobalRandomCounterOpt::ProcessChoicePoint(BasicBlock* bb) {
   BranchInst* t = cast<BranchInst>(bb->getTerminator());
-  LLVMContext &Context = bb->getContext();
   
   //decrement counter
   LoadInst* l = new LoadInst(AI, "counter", t);
   
   ICmpInst* s = new ICmpInst(t, ICmpInst::ICMP_EQ, l,
-                             Context.getConstantInt(T, 0), 
+                             ConstantInt::get(T, 0), 
                              "countercc");
 
-  Value* nv = BinaryOperator::CreateSub(l, Context.getConstantInt(T, 1),
+  Value* nv = BinaryOperator::CreateSub(l, ConstantInt::get(T, 1),
                                         "counternew", t);
   new StoreInst(nv, AI, t);
   t->setCondition(s);
@@ -318,15 +316,14 @@
 
 void CycleCounter::ProcessChoicePoint(BasicBlock* bb) {
   BranchInst* t = cast<BranchInst>(bb->getTerminator());
-  LLVMContext &Context = bb->getContext();
   
   CallInst* c = CallInst::Create(F, "rdcc", t);
   BinaryOperator* b = 
-    BinaryOperator::CreateAnd(c, Context.getConstantInt(Type::Int64Ty, rm),
+    BinaryOperator::CreateAnd(c, ConstantInt::get(Type::Int64Ty, rm),
                               "mrdcc", t);
   
   ICmpInst *s = new ICmpInst(t, ICmpInst::ICMP_EQ, b,
-                             Context.getConstantInt(Type::Int64Ty, 0), 
+                             ConstantInt::get(Type::Int64Ty, 0), 
                              "mrdccc");
 
   t->setCondition(s);
@@ -353,7 +350,7 @@
   // Create the getelementptr constant expression
   std::vector<Constant*> Indices(2);
   Indices[0] = BB->getContext().getNullValue(Type::Int32Ty);
-  Indices[1] = BB->getContext().getConstantInt(Type::Int32Ty, CounterNum);
+  Indices[1] = ConstantInt::get(Type::Int32Ty, CounterNum);
   Constant *ElementPtr = 
     BB->getContext().getConstantExprGetElementPtr(CounterArray,
                                                         &Indices[0], 2);
@@ -362,7 +359,7 @@
   Value *OldVal = new LoadInst(ElementPtr, "OldCounter", InsertPos);
   profcode.insert(OldVal);
   Value *NewVal = BinaryOperator::CreateAdd(OldVal,
-                              BB->getContext().getConstantInt(Type::Int32Ty, 1),
+                              ConstantInt::get(Type::Int32Ty, 1),
                                             "NewCounter", InsertPos);
   profcode.insert(NewVal);
   profcode.insert(new StoreInst(NewVal, ElementPtr, InsertPos));
@@ -483,7 +480,7 @@
   //b:
   BranchInst::Create(cast<BasicBlock>(Translate(dst)), bbC);
   BranchInst::Create(dst, cast<BasicBlock>(Translate(dst)), 
-                     F.getContext().getConstantInt(Type::Int1Ty, true), bbCp);
+                     ConstantInt::get(Type::Int1Ty, true), bbCp);
   //c:
   {
     TerminatorInst* iB = src->getTerminator();
@@ -540,8 +537,7 @@
     ReplaceInstWithInst(T, BranchInst::Create(T->getSuccessor(0),
                                               cast<BasicBlock>(
                                                 Translate(T->getSuccessor(0))),
-                                    F.getContext().getConstantInt(Type::Int1Ty,
-                                                               true)));
+                                    ConstantInt::get(Type::Int1Ty, true)));
     
     //do whatever is needed now that the function is duplicated
     c->PrepFunction(&F);

Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Fri Jul 24 18:12:02 2009
@@ -617,7 +617,7 @@
         V = new SExtInst(V, IntPtrTy, "sunkaddr", InsertPt);
       }
       if (AddrMode.Scale != 1)
-        V = BinaryOperator::CreateMul(V, Context.getConstantInt(IntPtrTy,
+        V = BinaryOperator::CreateMul(V, ConstantInt::get(IntPtrTy,
                                                                 AddrMode.Scale),
                                       "sunkaddr", InsertPt);
       Result = V;
@@ -649,7 +649,7 @@
 
     // Add in the Base Offset if present.
     if (AddrMode.BaseOffs) {
-      Value *V = Context.getConstantInt(IntPtrTy, AddrMode.BaseOffs);
+      Value *V = ConstantInt::get(IntPtrTy, AddrMode.BaseOffs);
       if (Result)
         Result = BinaryOperator::CreateAdd(Result, V, "sunkaddr", InsertPt);
       else

Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Fri Jul 24 18:12:02 2009
@@ -718,18 +718,18 @@
   // Insert new integer induction variable.
   PHINode *NewPHI = PHINode::Create(Type::Int32Ty,
                                     PH->getName()+".int", PH);
-  NewPHI->addIncoming(Context.getConstantInt(Type::Int32Ty, newInitValue),
+  NewPHI->addIncoming(ConstantInt::get(Type::Int32Ty, newInitValue),
                       PH->getIncomingBlock(IncomingEdge));
 
   Value *NewAdd = BinaryOperator::CreateAdd(NewPHI,
-                                          Context.getConstantInt(Type::Int32Ty,
+                                          ConstantInt::get(Type::Int32Ty,
                                                              newIncrValue),
                                             Incr->getName()+".int", Incr);
   NewPHI->addIncoming(NewAdd, PH->getIncomingBlock(BackEdge));
 
   // The back edge is edge 1 of newPHI, whatever it may have been in the
   // original PHI.
-  ConstantInt *NewEV = Context.getConstantInt(Type::Int32Ty, intEV);
+  ConstantInt *NewEV = ConstantInt::get(Type::Int32Ty, intEV);
   Value *LHS = (EVIndex == 1 ? NewPHI->getIncomingValue(1) : NewEV);
   Value *RHS = (EVIndex == 1 ? NewEV : NewPHI->getIncomingValue(1));
   ICmpInst *NewEC = new ICmpInst(EC->getParent()->getTerminator(),

Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Fri Jul 24 18:12:02 2009
@@ -599,7 +599,7 @@
 
   // Constants can be considered to be not'ed values...
   if (ConstantInt *C = dyn_cast<ConstantInt>(V))
-    return Context->getConstantInt(~C->getValue());
+    return ConstantInt::get(*Context, ~C->getValue());
   return 0;
 }
 
@@ -620,7 +620,7 @@
           // The multiplier is really 1 << CST.
           uint32_t BitWidth = cast<IntegerType>(V->getType())->getBitWidth();
           uint32_t CSTVal = CST->getLimitedValue(BitWidth);
-          CST = Context->getConstantInt(APInt(BitWidth, 1).shl(CSTVal));
+          CST = ConstantInt::get(*Context, APInt(BitWidth, 1).shl(CSTVal));
           return I->getOperand(0);
         }
     }
@@ -640,12 +640,12 @@
 /// AddOne - Add one to a ConstantInt
 static Constant *AddOne(Constant *C, LLVMContext *Context) {
   return Context->getConstantExprAdd(C, 
-    Context->getConstantInt(C->getType(), 1));
+    ConstantInt::get(C->getType(), 1));
 }
 /// SubOne - Subtract one from a ConstantInt
 static Constant *SubOne(ConstantInt *C, LLVMContext *Context) {
   return Context->getConstantExprSub(C, 
-    Context->getConstantInt(C->getType(), 1));
+    ConstantInt::get(C->getType(), 1));
 }
 /// MultiplyOverflows - True if the multiply can not be expressed in an int
 /// this size.
@@ -692,7 +692,7 @@
 
   // This instruction is producing bits that are not demanded. Shrink the RHS.
   Demanded &= OpC->getValue();
-  I->setOperand(OpNo, Context->getConstantInt(Demanded));
+  I->setOperand(OpNo, ConstantInt::get(*Context, Demanded));
   return true;
 }
 
@@ -1023,7 +1023,8 @@
     if ((DemandedMask & (RHSKnownZero|RHSKnownOne)) == DemandedMask) { 
       // all known
       if ((RHSKnownOne & LHSKnownOne) == RHSKnownOne) {
-        Constant *AndC = Context->getConstantInt(~RHSKnownOne & DemandedMask);
+        Constant *AndC = ConstantInt::get(*Context, 
+                                          ~RHSKnownOne & DemandedMask);
         Instruction *And = 
           BinaryOperator::CreateAnd(I->getOperand(0), AndC, "tmp");
         return InsertNewInstBefore(And, *I);
@@ -1395,10 +1396,10 @@
           Instruction *NewVal;
           if (InputBit > ResultBit)
             NewVal = BinaryOperator::CreateLShr(I->getOperand(1),
-                    Context->getConstantInt(I->getType(), InputBit-ResultBit));
+                    ConstantInt::get(I->getType(), InputBit-ResultBit));
           else
             NewVal = BinaryOperator::CreateShl(I->getOperand(1),
-                    Context->getConstantInt(I->getType(), ResultBit-InputBit));
+                    ConstantInt::get(I->getType(), ResultBit-InputBit));
           NewVal->takeName(I);
           return InsertNewInstBefore(NewVal, *I);
         }
@@ -1415,7 +1416,7 @@
   // If the client is only demanding bits that we know, return the known
   // constant.
   if ((DemandedMask & (RHSKnownZero|RHSKnownOne)) == DemandedMask) {
-    Constant *C = Context->getConstantInt(RHSKnownOne);
+    Constant *C = ConstantInt::get(*Context, RHSKnownOne);
     if (isa<PointerType>(V->getType()))
       C = Context->getConstantExprIntToPtr(C, V->getType());
     return C;
@@ -1602,7 +1603,7 @@
         if (UndefElts[i])
           Elts.push_back(Context->getUndef(Type::Int32Ty));
         else
-          Elts.push_back(Context->getConstantInt(Type::Int32Ty,
+          Elts.push_back(ConstantInt::get(Type::Int32Ty,
                                           Shuffle->getMaskValue(i)));
       }
       I->setOperand(2, Context->getConstantVector(Elts));
@@ -1733,9 +1734,9 @@
           Value *RHS = II->getOperand(2);
           // Extract the element as scalars.
           LHS = InsertNewInstBefore(new ExtractElementInst(LHS, 
-            Context->getConstantInt(Type::Int32Ty, 0U, false), "tmp"), *II);
+            ConstantInt::get(Type::Int32Ty, 0U, false), "tmp"), *II);
           RHS = InsertNewInstBefore(new ExtractElementInst(RHS,
-            Context->getConstantInt(Type::Int32Ty, 0U, false), "tmp"), *II);
+            ConstantInt::get(Type::Int32Ty, 0U, false), "tmp"), *II);
           
           switch (II->getIntrinsicID()) {
           default: llvm_unreachable("Case stmts out of sync!");
@@ -1754,7 +1755,7 @@
           Instruction *New =
             InsertElementInst::Create(
               Context->getUndef(II->getType()), TmpV,
-              Context->getConstantInt(Type::Int32Ty, 0U, false), II->getName());
+              ConstantInt::get(Type::Int32Ty, 0U, false), II->getName());
           InsertNewInstBefore(New, *II);
           AddSoonDeadInstToWorklist(*II, 0);
           return New;
@@ -1860,7 +1861,7 @@
   bool shouldApply(Value *LHS) const { return LHS == RHS; }
   Instruction *apply(BinaryOperator &Add) const {
     return BinaryOperator::CreateShl(Add.getOperand(0),
-                                     Context->getConstantInt(Add.getType(), 1));
+                                     ConstantInt::get(Add.getType(), 1));
   }
 };
 
@@ -2543,7 +2544,7 @@
       ConstantInt *C2 = 0;
       if (dyn_castFoldableMul(Op1I, C2, Context) == Op0) {
         Constant *CP1 = 
-          Context->getConstantExprSub(Context->getConstantInt(I.getType(), 1),
+          Context->getConstantExprSub(ConstantInt::get(I.getType(), 1),
                                              C2);
         return BinaryOperator::CreateMul(Op0, CP1);
       }
@@ -2654,7 +2655,7 @@
       const APInt& Val = cast<ConstantInt>(CI)->getValue();
       if (Val.isPowerOf2()) {          // Replace X*(2^C) with X << C
         return BinaryOperator::CreateShl(Op0,
-                 Context->getConstantInt(Op0->getType(), Val.logBase2()));
+                 ConstantInt::get(Op0->getType(), Val.logBase2()));
       }
     } else if (isa<VectorType>(Op1->getType())) {
       if (Op1->isNullValue())
@@ -2761,7 +2762,7 @@
           isSignBitCheck(SCI->getPredicate(), cast<ConstantInt>(SCIOp1), TIS) &&
           TIS) {
         // Shift the X value right to turn it into "all signbits".
-        Constant *Amt = Context->getConstantInt(SCIOp0->getType(),
+        Constant *Amt = ConstantInt::get(SCIOp0->getType(),
                                           SCOpTy->getPrimitiveSizeInBits()-1);
         Value *V =
           InsertNewInstBefore(
@@ -2932,12 +2933,12 @@
   // (sdiv X, X) --> 1     (udiv X, X) --> 1
   if (Op0 == Op1) {
     if (const VectorType *Ty = dyn_cast<VectorType>(I.getType())) {
-      Constant *CI = Context->getConstantInt(Ty->getElementType(), 1);
+      Constant *CI = ConstantInt::get(Ty->getElementType(), 1);
       std::vector<Constant*> Elts(Ty->getNumElements(), CI);
       return ReplaceInstUsesWith(I, Context->getConstantVector(Elts));
     }
 
-    Constant *CI = Context->getConstantInt(I.getType(), 1);
+    Constant *CI = ConstantInt::get(I.getType(), 1);
     return ReplaceInstUsesWith(I, CI);
   }
   
@@ -3008,7 +3009,7 @@
     // if so, convert to a right shift.
     if (C->getValue().isPowerOf2())  // 0 not included in isPowerOf2
       return BinaryOperator::CreateLShr(Op0, 
-            Context->getConstantInt(Op0->getType(), C->getValue().logBase2()));
+            ConstantInt::get(Op0->getType(), C->getValue().logBase2()));
 
     // X udiv C, where C >= signbit
     if (C->getValue().isNegative()) {
@@ -3016,7 +3017,7 @@
                                                     ICmpInst::ICMP_ULT, Op0, C),
                                       I);
       return SelectInst::Create(IC, Context->getNullValue(I.getType()),
-                                Context->getConstantInt(I.getType(), 1));
+                                ConstantInt::get(I.getType(), 1));
     }
   }
 
@@ -3029,7 +3030,7 @@
         Value *N = RHSI->getOperand(1);
         const Type *NTy = N->getType();
         if (uint32_t C2 = C1.logBase2()) {
-          Constant *C2V = Context->getConstantInt(NTy, C2);
+          Constant *C2V = ConstantInt::get(NTy, C2);
           N = InsertNewInstBefore(BinaryOperator::CreateAdd(N, C2V, "tmp"), I);
         }
         return BinaryOperator::CreateLShr(Op0, N);
@@ -3047,13 +3048,13 @@
           // Compute the shift amounts
           uint32_t TSA = TVA.logBase2(), FSA = FVA.logBase2();
           // Construct the "on true" case of the select
-          Constant *TC = Context->getConstantInt(Op0->getType(), TSA);
+          Constant *TC = ConstantInt::get(Op0->getType(), TSA);
           Instruction *TSI = BinaryOperator::CreateLShr(
                                                  Op0, TC, SI->getName()+".t");
           TSI = InsertNewInstBefore(TSI, I);
   
           // Construct the "on false" case of the select
-          Constant *FC = Context->getConstantInt(Op0->getType(), FSA); 
+          Constant *FC = ConstantInt::get(Op0->getType(), FSA); 
           Instruction *FSI = BinaryOperator::CreateLShr(
                                                  Op0, FC, SI->getName()+".f");
           FSI = InsertNewInstBefore(FSI, I);
@@ -3577,7 +3578,7 @@
     uint32_t BitWidth = AndRHS->getType()->getBitWidth();
     uint32_t OpRHSVal = OpRHS->getLimitedValue(BitWidth);
     APInt ShlMask(APInt::getHighBitsSet(BitWidth, BitWidth-OpRHSVal));
-    ConstantInt *CI = Context->getConstantInt(AndRHS->getValue() & ShlMask);
+    ConstantInt *CI = ConstantInt::get(*Context, AndRHS->getValue() & ShlMask);
 
     if (CI->getValue() == ShlMask) { 
     // Masking out bits that the shift already masks
@@ -3597,7 +3598,7 @@
     uint32_t BitWidth = AndRHS->getType()->getBitWidth();
     uint32_t OpRHSVal = OpRHS->getLimitedValue(BitWidth);
     APInt ShrMask(APInt::getLowBitsSet(BitWidth, BitWidth - OpRHSVal));
-    ConstantInt *CI = Context->getConstantInt(AndRHS->getValue() & ShrMask);
+    ConstantInt *CI = ConstantInt::get(*Context, AndRHS->getValue() & ShrMask);
 
     if (CI->getValue() == ShrMask) {   
     // Masking out bits that the shift already masks.
@@ -3616,7 +3617,7 @@
       uint32_t BitWidth = AndRHS->getType()->getBitWidth();
       uint32_t OpRHSVal = OpRHS->getLimitedValue(BitWidth);
       APInt ShrMask(APInt::getLowBitsSet(BitWidth, BitWidth - OpRHSVal));
-      Constant *C = Context->getConstantInt(AndRHS->getValue() & ShrMask);
+      Constant *C = ConstantInt::get(*Context, AndRHS->getValue() & ShrMask);
       if (C == AndRHS) {          // Masking out bits shifted in.
         // (Val ashr C1) & C2 -> (Val lshr C1) & C2
         // Make the argument unsigned.
@@ -3856,7 +3857,7 @@
                                                      Val->getName()+".off");
         InsertNewInstBefore(Add, I);
         return new ICmpInst(*Context, ICmpInst::ICMP_UGT, Add,
-                            Context->getConstantInt(Add->getType(), 1));
+                            ConstantInt::get(Add->getType(), 1));
       }
       break;                        // (X != 13 & X != 15) -> no change
     }
@@ -4770,7 +4771,7 @@
       InsertNewInstBefore(Or, I);
       Or->takeName(Op0);
       return BinaryOperator::CreateAnd(Or, 
-               Context->getConstantInt(RHS->getValue() | C1->getValue()));
+               ConstantInt::get(*Context, RHS->getValue() | C1->getValue()));
     }
 
     // (X ^ C1) | C2 --> (X | C2) ^ (C1&~C2)
@@ -4780,7 +4781,7 @@
       InsertNewInstBefore(Or, I);
       Or->takeName(Op0);
       return BinaryOperator::CreateXor(Or,
-                 Context->getConstantInt(C1->getValue() & ~RHS->getValue()));
+                 ConstantInt::get(*Context, C1->getValue() & ~RHS->getValue()));
     }
 
     // Try to fold constant and into select arguments.
@@ -5107,7 +5108,7 @@
         if (Constant *Op0I0C = dyn_cast<Constant>(Op0I->getOperand(0))) {
           Constant *NegOp0I0C = Context->getConstantExprNeg(Op0I0C);
           Constant *ConstantRHS = Context->getConstantExprSub(NegOp0I0C,
-                                      Context->getConstantInt(I.getType(), 1));
+                                      ConstantInt::get(I.getType(), 1));
           return BinaryOperator::CreateAdd(Op0I->getOperand(1), ConstantRHS);
         }
           
@@ -5118,12 +5119,12 @@
             Constant *NegOp0CI = Context->getConstantExprNeg(Op0CI);
             return BinaryOperator::CreateSub(
                            Context->getConstantExprSub(NegOp0CI,
-                                      Context->getConstantInt(I.getType(), 1)),
+                                      ConstantInt::get(I.getType(), 1)),
                                       Op0I->getOperand(0));
           } else if (RHS->getValue().isSignBit()) {
             // (X + C) ^ signbit -> (X + C + signbit)
-            Constant *C =
-                   Context->getConstantInt(RHS->getValue() + Op0CI->getValue());
+            Constant *C = ConstantInt::get(*Context,
+                                           RHS->getValue() + Op0CI->getValue());
             return BinaryOperator::CreateAdd(Op0I->getOperand(0), C);
 
           }
@@ -5327,7 +5328,7 @@
 
   if (const VectorType *VTy = dyn_cast<VectorType>(In1->getType())) {
     for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
-      Constant *Idx = Context->getConstantInt(Type::Int32Ty, i);
+      Constant *Idx = ConstantInt::get(Type::Int32Ty, i);
       if (HasAddOverflow(ExtractElement(Result, Idx, Context),
                          ExtractElement(In1, Idx, Context),
                          ExtractElement(In2, Idx, Context),
@@ -5363,7 +5364,7 @@
 
   if (const VectorType *VTy = dyn_cast<VectorType>(In1->getType())) {
     for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
-      Constant *Idx = Context->getConstantInt(Type::Int32Ty, i);
+      Constant *Idx = ConstantInt::get(Type::Int32Ty, i);
       if (HasSubOverflow(ExtractElement(Result, Idx, Context),
                          ExtractElement(In1, Idx, Context),
                          ExtractElement(In2, Idx, Context),
@@ -5405,16 +5406,17 @@
         
         if (ConstantInt *RC = dyn_cast<ConstantInt>(Result))
           Result = 
-             Context->getConstantInt(RC->getValue() + APInt(IntPtrWidth, Size));
+             ConstantInt::get(*Context, 
+                              RC->getValue() + APInt(IntPtrWidth, Size));
         else
           Result = IC.InsertNewInstBefore(
                    BinaryOperator::CreateAdd(Result,
-                                        Context->getConstantInt(IntPtrTy, Size),
+                                        ConstantInt::get(IntPtrTy, Size),
                                              GEP->getName()+".offs"), I);
         continue;
       }
       
-      Constant *Scale = Context->getConstantInt(IntPtrTy, Size);
+      Constant *Scale = ConstantInt::get(IntPtrTy, Size);
       Constant *OC =
               Context->getConstantExprIntegerCast(OpC, IntPtrTy, true /*SExt*/);
       Scale = Context->getConstantExprMul(OC, Scale);
@@ -5438,7 +5440,7 @@
                                                       Op->getName()+".c"), I);
     }
     if (Size != 1) {
-      Constant *Scale = Context->getConstantInt(IntPtrTy, Size);
+      Constant *Scale = ConstantInt::get(IntPtrTy, Size);
       if (Constant *OpC = dyn_cast<Constant>(Op))
         Op = Context->getConstantExprMul(OpC, Scale);
       else    // We'll let instcombine(mul) convert this to a shl if possible.
@@ -5559,7 +5561,7 @@
     VariableIdx = CastInst::CreateIntegerCast(VariableIdx, IntPtrTy,
                                               true /*SExt*/, 
                                               VariableIdx->getNameStart(), &I);
-  Constant *OffsetVal = IC.getContext()->getConstantInt(IntPtrTy, NewOffs);
+  Constant *OffsetVal = ConstantInt::get(IntPtrTy, NewOffs);
   return BinaryOperator::CreateAdd(VariableIdx, OffsetVal, "offset", &I);
 }
 
@@ -5653,7 +5655,7 @@
 
       if (NumDifferences == 0)   // SAME GEP?
         return ReplaceInstUsesWith(I, // No comparison is needed here.
-                                   Context->getConstantInt(Type::Int1Ty,
+                                   ConstantInt::get(Type::Int1Ty,
                                              ICmpInst::isTrueWhenEqual(Cond)));
 
       else if (NumDifferences == 1) {
@@ -5985,7 +5987,7 @@
 
   // icmp X, X
   if (Op0 == Op1)
-    return ReplaceInstUsesWith(I, Context->getConstantInt(Type::Int1Ty, 
+    return ReplaceInstUsesWith(I, ConstantInt::get(Type::Int1Ty, 
                                                    I.isTrueWhenEqual()));
 
   if (isa<UndefValue>(Op1))                  // X icmp undef -> undef
@@ -5997,7 +5999,7 @@
        isa<ConstantPointerNull>(Op0)) &&
       (isa<GlobalValue>(Op1) || isa<AllocaInst>(Op1) ||
        isa<ConstantPointerNull>(Op1)))
-    return ReplaceInstUsesWith(I, Context->getConstantInt(Type::Int1Ty, 
+    return ReplaceInstUsesWith(I, ConstantInt::get(Type::Int1Ty, 
                                                    !I.isTrueWhenEqual()));
 
   // icmp's with boolean values can always be turned into bitwise operations
@@ -6141,10 +6143,10 @@
     // that code below can assume that Min != Max.
     if (!isa<Constant>(Op0) && Op0Min == Op0Max)
       return new ICmpInst(*Context, I.getPredicate(),
-                          Context->getConstantInt(Op0Min), Op1);
+                          ConstantInt::get(*Context, Op0Min), Op1);
     if (!isa<Constant>(Op1) && Op1Min == Op1Max)
       return new ICmpInst(*Context, I.getPredicate(), Op0, 
-                          Context->getConstantInt(Op1Min));
+                          ConstantInt::get(*Context, Op1Min));
 
     // Based on the range information we know about the LHS, see if we can
     // simplify this comparison.  For example, (x&4) < 8  is always true.
@@ -6344,7 +6346,7 @@
         // can assume it is successful and remove the malloc.
         if (LHSI->hasOneUse() && isa<ConstantPointerNull>(RHSC)) {
           AddToWorkList(LHSI);
-          return ReplaceInstUsesWith(I, Context->getConstantInt(Type::Int1Ty,
+          return ReplaceInstUsesWith(I, ConstantInt::get(Type::Int1Ty,
                                                          !I.isTrueWhenEqual()));
         }
         break;
@@ -6442,7 +6444,7 @@
             // Mask = -1 >> count-trailing-zeros(Cst).
             if (!CI->isZero() && !CI->isOne()) {
               const APInt &AP = CI->getValue();
-              ConstantInt *Mask = Context->getConstantInt(
+              ConstantInt *Mask = ConstantInt::get(*Context, 
                                       APInt::getLowBitsSet(AP.getBitWidth(),
                                                            AP.getBitWidth() -
                                                       AP.countTrailingZeros()));
@@ -6489,7 +6491,7 @@
         if (match(B, m_ConstantInt(C1), *Context) &&
             match(D, m_ConstantInt(C2), *Context) && Op1->hasOneUse()) {
           Constant *NC = 
-                       Context->getConstantInt(C1->getValue() ^ C2->getValue());
+                   ConstantInt::get(*Context, C1->getValue() ^ C2->getValue());
           Instruction *Xor = BinaryOperator::CreateXor(C, NC, "tmp");
           return new ICmpInst(*Context, I.getPredicate(), A,
                               InsertNewInstBefore(Xor, I));
@@ -6727,7 +6729,7 @@
         NewRHS.zext(SrcBits);
         NewRHS |= KnownOne;
         return new ICmpInst(*Context, ICI.getPredicate(), LHSI->getOperand(0),
-                            Context->getConstantInt(NewRHS));
+                            ConstantInt::get(*Context, NewRHS));
       }
     }
     break;
@@ -6770,7 +6772,7 @@
                                          ? ICI.getUnsignedPredicate()
                                          : ICI.getSignedPredicate();
           return new ICmpInst(*Context, Pred, LHSI->getOperand(0),
-                              Context->getConstantInt(RHSV ^ SignBit));
+                              ConstantInt::get(*Context, RHSV ^ SignBit));
         }
 
         // (icmp u/s (xor A ~SignBit), C) -> (icmp s/u (xor C ~SignBit), A)
@@ -6781,7 +6783,7 @@
                                          : ICI.getSignedPredicate();
           Pred = ICI.getSwappedPredicate(Pred);
           return new ICmpInst(*Context, Pred, LHSI->getOperand(0),
-                              Context->getConstantInt(RHSV ^ NotSignBit));
+                              ConstantInt::get(*Context, RHSV ^ NotSignBit));
         }
       }
     }
@@ -6810,10 +6812,10 @@
           NewCI.zext(BitWidth);
           Instruction *NewAnd = 
             BinaryOperator::CreateAnd(Cast->getOperand(0),
-                               Context->getConstantInt(NewCST),LHSI->getName());
+                           ConstantInt::get(*Context, NewCST), LHSI->getName());
           InsertNewInstBefore(NewAnd, ICI);
           return new ICmpInst(*Context, ICI.getPredicate(), NewAnd,
-                              Context->getConstantInt(NewCI));
+                              ConstantInt::get(*Context, NewCI));
         }
       }
       
@@ -6930,7 +6932,7 @@
                                                                  ShAmt);
       if (Comp != RHS) {// Comparing against a bit that we know is zero.
         bool IsICMP_NE = ICI.getPredicate() == ICmpInst::ICMP_NE;
-        Constant *Cst = Context->getConstantInt(Type::Int1Ty, IsICMP_NE);
+        Constant *Cst = ConstantInt::get(Type::Int1Ty, IsICMP_NE);
         return ReplaceInstUsesWith(ICI, Cst);
       }
       
@@ -6938,7 +6940,7 @@
         // Otherwise strength reduce the shift into an and.
         uint32_t ShAmtVal = (uint32_t)ShAmt->getLimitedValue(TypeBits);
         Constant *Mask =
-          Context->getConstantInt(APInt::getLowBitsSet(TypeBits, 
+          ConstantInt::get(*Context, APInt::getLowBitsSet(TypeBits, 
                                                        TypeBits-ShAmtVal));
         
         Instruction *AndI =
@@ -6946,7 +6948,7 @@
                                     Mask, LHSI->getName()+".mask");
         Value *And = InsertNewInstBefore(AndI, ICI);
         return new ICmpInst(*Context, ICI.getPredicate(), And,
-                            Context->getConstantInt(RHSV.lshr(ShAmtVal)));
+                            ConstantInt::get(*Context, RHSV.lshr(ShAmtVal)));
       }
     }
     
@@ -6955,7 +6957,7 @@
     if (LHSI->hasOneUse() &&
         isSignBitCheck(ICI.getPredicate(), RHS, TrueIfSigned)) {
       // (X << 31) <s 0  --> (X&1) != 0
-      Constant *Mask = Context->getConstantInt(APInt(TypeBits, 1) <<
+      Constant *Mask = ConstantInt::get(*Context, APInt(TypeBits, 1) <<
                                            (TypeBits-ShAmt->getZExtValue()-1));
       Instruction *AndI =
         BinaryOperator::CreateAnd(LHSI->getOperand(0),
@@ -6994,7 +6996,7 @@
     
     if (Comp != RHSV) { // Comparing against a bit that we know is zero.
       bool IsICMP_NE = ICI.getPredicate() == ICmpInst::ICMP_NE;
-      Constant *Cst = Context->getConstantInt(Type::Int1Ty, IsICMP_NE);
+      Constant *Cst = ConstantInt::get(Type::Int1Ty, IsICMP_NE);
       return ReplaceInstUsesWith(ICI, Cst);
     }
     
@@ -7011,7 +7013,7 @@
     if (LHSI->hasOneUse()) {
       // Otherwise strength reduce the shift into an and.
       APInt Val(APInt::getHighBitsSet(TypeBits, TypeBits - ShAmtVal));
-      Constant *Mask = Context->getConstantInt(Val);
+      Constant *Mask = ConstantInt::get(*Context, Val);
       
       Instruction *AndI =
         BinaryOperator::CreateAnd(LHSI->getOperand(0),
@@ -7051,18 +7053,18 @@
       if (ICI.isSignedPredicate()) {
         if (CR.getLower().isSignBit()) {
           return new ICmpInst(*Context, ICmpInst::ICMP_SLT, LHSI->getOperand(0),
-                              Context->getConstantInt(CR.getUpper()));
+                              ConstantInt::get(*Context, CR.getUpper()));
         } else if (CR.getUpper().isSignBit()) {
           return new ICmpInst(*Context, ICmpInst::ICMP_SGE, LHSI->getOperand(0),
-                              Context->getConstantInt(CR.getLower()));
+                              ConstantInt::get(*Context, CR.getLower()));
         }
       } else {
         if (CR.getLower().isMinValue()) {
           return new ICmpInst(*Context, ICmpInst::ICMP_ULT, LHSI->getOperand(0),
-                              Context->getConstantInt(CR.getUpper()));
+                              ConstantInt::get(*Context, CR.getUpper()));
         } else if (CR.getUpper().isMinValue()) {
           return new ICmpInst(*Context, ICmpInst::ICMP_UGE, LHSI->getOperand(0),
-                              Context->getConstantInt(CR.getLower()));
+                              ConstantInt::get(*Context, CR.getLower()));
         }
       }
     }
@@ -7136,7 +7138,7 @@
           Constant *NotCI = Context->getConstantExprNot(RHS);
           if (!Context->getConstantExprAnd(BOC, NotCI)->isNullValue())
             return ReplaceInstUsesWith(ICI,
-                                       Context->getConstantInt(Type::Int1Ty, 
+                                       ConstantInt::get(Type::Int1Ty, 
                                        isICMP_NE));
         }
         break;
@@ -7147,7 +7149,7 @@
           // comparison can never succeed!
           if ((RHSV & ~BOC->getValue()) != 0)
             return ReplaceInstUsesWith(ICI,
-                                       Context->getConstantInt(Type::Int1Ty,
+                                       ConstantInt::get(Type::Int1Ty,
                                        isICMP_NE));
           
           // If we have ((X & C) == C), turn it into ((X & C) != 0).
@@ -7181,7 +7183,7 @@
       if (II->getIntrinsicID() == Intrinsic::bswap) {
         AddToWorkList(II);
         ICI.setOperand(0, II->getOperand(1));
-        ICI.setOperand(1, Context->getConstantInt(RHSV.byteSwap()));
+        ICI.setOperand(1, ConstantInt::get(*Context, RHSV.byteSwap()));
         return &ICI;
       }
     }
@@ -7411,7 +7413,7 @@
     if (I.getOpcode() != Instruction::AShr)
       return ReplaceInstUsesWith(I, Context->getNullValue(Op0->getType()));
     else {
-      I.setOperand(1, Context->getConstantInt(I.getType(), TypeBits-1));
+      I.setOperand(1, ConstantInt::get(I.getType(), TypeBits-1));
       return &I;
     }
   }
@@ -7467,7 +7469,7 @@
       }
 
       Instruction *And =
-        BinaryOperator::CreateAnd(NSh, Context->getConstantInt(MaskV), 
+        BinaryOperator::CreateAnd(NSh, ConstantInt::get(*Context, MaskV), 
                                   TI->getName());
       InsertNewInstBefore(And, I); // shift1 & 0x00FF
 
@@ -7501,7 +7503,7 @@
                                      Op0BO->getOperand(1)->getName());
             InsertNewInstBefore(X, I);  // (X + (Y << C))
             uint32_t Op1Val = Op1->getLimitedValue(TypeBits);
-            return BinaryOperator::CreateAnd(X, Context->getConstantInt(
+            return BinaryOperator::CreateAnd(X, ConstantInt::get(*Context,
                        APInt::getHighBitsSet(TypeBits, TypeBits-Op1Val)));
           }
           
@@ -7541,7 +7543,7 @@
                                      Op0BO->getOperand(0)->getName());
             InsertNewInstBefore(X, I);  // (X + (Y << C))
             uint32_t Op1Val = Op1->getLimitedValue(TypeBits);
-            return BinaryOperator::CreateAnd(X, Context->getConstantInt(
+            return BinaryOperator::CreateAnd(X, ConstantInt::get(*Context,
                        APInt::getHighBitsSet(TypeBits, TypeBits-Op1Val)));
           }
           
@@ -7642,14 +7644,14 @@
       }
       
       return BinaryOperator::Create(I.getOpcode(), X,
-                                    Context->getConstantInt(Ty, AmtSum));
+                                    ConstantInt::get(Ty, AmtSum));
     } else if (ShiftOp->getOpcode() == Instruction::LShr &&
                I.getOpcode() == Instruction::AShr) {
       if (AmtSum >= TypeBits)
         return ReplaceInstUsesWith(I, Context->getNullValue(I.getType()));
       
       // ((X >>u C1) >>s C2) -> (X >>u (C1+C2))  since C1 != 0.
-      return BinaryOperator::CreateLShr(X, Context->getConstantInt(Ty, AmtSum));
+      return BinaryOperator::CreateLShr(X, ConstantInt::get(Ty, AmtSum));
     } else if (ShiftOp->getOpcode() == Instruction::AShr &&
                I.getOpcode() == Instruction::LShr) {
       // ((X >>s C1) >>u C2) -> ((X >>s (C1+C2)) & mask) since C1 != 0.
@@ -7657,11 +7659,11 @@
         AmtSum = TypeBits-1;
       
       Instruction *Shift =
-        BinaryOperator::CreateAShr(X, Context->getConstantInt(Ty, AmtSum));
+        BinaryOperator::CreateAShr(X, ConstantInt::get(Ty, AmtSum));
       InsertNewInstBefore(Shift, I);
 
       APInt Mask(APInt::getLowBitsSet(TypeBits, TypeBits - ShiftAmt2));
-      return BinaryOperator::CreateAnd(Shift, Context->getConstantInt(Mask));
+      return BinaryOperator::CreateAnd(Shift, ConstantInt::get(*Context, Mask));
     }
     
     // Okay, if we get here, one shift must be left, and the other shift must be
@@ -7670,12 +7672,12 @@
       // If we have ((X >>? C) << C), turn this into X & (-1 << C).
       if (I.getOpcode() == Instruction::Shl) {
         APInt Mask(APInt::getHighBitsSet(TypeBits, TypeBits - ShiftAmt1));
-        return BinaryOperator::CreateAnd(X, Context->getConstantInt(Mask));
+        return BinaryOperator::CreateAnd(X, ConstantInt::get(*Context, Mask));
       }
       // If we have ((X << C) >>u C), turn this into X & (-1 >>u C).
       if (I.getOpcode() == Instruction::LShr) {
         APInt Mask(APInt::getLowBitsSet(TypeBits, TypeBits - ShiftAmt1));
-        return BinaryOperator::CreateAnd(X, Context->getConstantInt(Mask));
+        return BinaryOperator::CreateAnd(X, ConstantInt::get(*Context, Mask));
       }
       // We can simplify ((X << C) >>s C) into a trunc + sext.
       // NOTE: we could do this for any C, but that would make 'unusual' integer
@@ -7707,22 +7709,24 @@
         assert(ShiftOp->getOpcode() == Instruction::LShr ||
                ShiftOp->getOpcode() == Instruction::AShr);
         Instruction *Shift =
-          BinaryOperator::CreateShl(X, Context->getConstantInt(Ty, ShiftDiff));
+          BinaryOperator::CreateShl(X, ConstantInt::get(Ty, ShiftDiff));
         InsertNewInstBefore(Shift, I);
         
         APInt Mask(APInt::getHighBitsSet(TypeBits, TypeBits - ShiftAmt2));
-        return BinaryOperator::CreateAnd(Shift, Context->getConstantInt(Mask));
+        return BinaryOperator::CreateAnd(Shift,
+                                         ConstantInt::get(*Context, Mask));
       }
       
       // (X << C1) >>u C2  --> X >>u (C2-C1) & (-1 >> C2)
       if (I.getOpcode() == Instruction::LShr) {
         assert(ShiftOp->getOpcode() == Instruction::Shl);
         Instruction *Shift =
-          BinaryOperator::CreateLShr(X, Context->getConstantInt(Ty, ShiftDiff));
+          BinaryOperator::CreateLShr(X, ConstantInt::get(Ty, ShiftDiff));
         InsertNewInstBefore(Shift, I);
         
         APInt Mask(APInt::getLowBitsSet(TypeBits, TypeBits - ShiftAmt2));
-        return BinaryOperator::CreateAnd(Shift, Context->getConstantInt(Mask));
+        return BinaryOperator::CreateAnd(Shift,
+                                         ConstantInt::get(*Context, Mask));
       }
       
       // We can't handle (X << C1) >>s C2, it shifts arbitrary bits in.
@@ -7736,22 +7740,24 @@
                ShiftOp->getOpcode() == Instruction::AShr);
         Instruction *Shift =
           BinaryOperator::Create(ShiftOp->getOpcode(), X,
-                                 Context->getConstantInt(Ty, ShiftDiff));
+                                 ConstantInt::get(Ty, ShiftDiff));
         InsertNewInstBefore(Shift, I);
         
         APInt Mask(APInt::getHighBitsSet(TypeBits, TypeBits - ShiftAmt2));
-        return BinaryOperator::CreateAnd(Shift, Context->getConstantInt(Mask));
+        return BinaryOperator::CreateAnd(Shift,
+                                         ConstantInt::get(*Context, Mask));
       }
       
       // (X << C1) >>u C2  --> X << (C1-C2) & (-1 >> C2)
       if (I.getOpcode() == Instruction::LShr) {
         assert(ShiftOp->getOpcode() == Instruction::Shl);
         Instruction *Shift =
-          BinaryOperator::CreateShl(X, Context->getConstantInt(Ty, ShiftDiff));
+          BinaryOperator::CreateShl(X, ConstantInt::get(Ty, ShiftDiff));
         InsertNewInstBefore(Shift, I);
         
         APInt Mask(APInt::getLowBitsSet(TypeBits, TypeBits - ShiftAmt2));
-        return BinaryOperator::CreateAnd(Shift, Context->getConstantInt(Mask));
+        return BinaryOperator::CreateAnd(Shift,
+                                         ConstantInt::get(*Context, Mask));
       }
       
       // We can't handle (X << C1) >>a C2, it shifts arbitrary bits in.
@@ -7771,7 +7777,7 @@
   if (ConstantInt *CI = dyn_cast<ConstantInt>(Val)) {
     Offset = CI->getZExtValue();
     Scale  = 0;
-    return Context->getConstantInt(Type::Int32Ty, 0);
+    return ConstantInt::get(Type::Int32Ty, 0);
   } else if (BinaryOperator *I = dyn_cast<BinaryOperator>(Val)) {
     if (ConstantInt *RHS = dyn_cast<ConstantInt>(I->getOperand(1))) {
       if (I->getOpcode() == Instruction::Shl) {
@@ -7868,7 +7874,7 @@
     Amt = NumElements;
   } else {
     // If the allocation size is constant, form a constant mul expression
-    Amt = Context->getConstantInt(Type::Int32Ty, Scale);
+    Amt = ConstantInt::get(Type::Int32Ty, Scale);
     if (isa<ConstantInt>(NumElements))
       Amt = Context->getConstantExprMul(cast<ConstantInt>(NumElements),
                                  cast<ConstantInt>(Amt));
@@ -7880,7 +7886,7 @@
   }
   
   if (int Offset = (AllocElTySize*ArrayOffset)/CastElTySize) {
-    Value *Off = Context->getConstantInt(Type::Int32Ty, Offset, true);
+    Value *Off = ConstantInt::get(Type::Int32Ty, Offset, true);
     Instruction *Tmp = BinaryOperator::CreateAdd(Amt, Off, "tmp");
     Amt = InsertNewInstBefore(Tmp, AI);
   }
@@ -8181,7 +8187,7 @@
     assert((uint64_t)Offset < (uint64_t)TySize && "Out of range offset");
   }
   
-  NewIndices.push_back(Context->getConstantInt(IntPtrTy, FirstIdx));
+  NewIndices.push_back(ConstantInt::get(IntPtrTy, FirstIdx));
     
   // Index into the types.  If we fail, set OrigBase to null.
   while (Offset) {
@@ -8195,14 +8201,14 @@
              "Offset must stay within the indexed type");
       
       unsigned Elt = SL->getElementContainingOffset(Offset);
-      NewIndices.push_back(Context->getConstantInt(Type::Int32Ty, Elt));
+      NewIndices.push_back(ConstantInt::get(Type::Int32Ty, Elt));
       
       Offset -= SL->getElementOffset(Elt);
       Ty = STy->getElementType(Elt);
     } else if (const ArrayType *AT = dyn_cast<ArrayType>(Ty)) {
       uint64_t EltSize = TD->getTypeAllocSize(AT->getElementType());
       assert(EltSize && "Cannot index into a zero-sized array");
-      NewIndices.push_back(Context->getConstantInt(IntPtrTy,Offset/EltSize));
+      NewIndices.push_back(ConstantInt::get(IntPtrTy,Offset/EltSize));
       Offset %= EltSize;
       Ty = AT->getElementType();
     } else {
@@ -8399,8 +8405,8 @@
           return ReplaceInstUsesWith(CI, Res);
 
         // We need to emit an AND to clear the high bits.
-        Constant *C = Context->getConstantInt(APInt::getLowBitsSet(DestBitSize,
-                                                            SrcBitSize));
+        Constant *C = ConstantInt::get(*Context, 
+                                 APInt::getLowBitsSet(DestBitSize, SrcBitSize));
         return BinaryOperator::CreateAnd(Res, C);
       }
       case Instruction::SExt: {
@@ -8447,7 +8453,7 @@
         (!Op0->hasOneUse() || !isa<CmpInst>(Op0))) {
       Value *New = InsertCastBefore(Instruction::ZExt, Op0, DestTy, CI);
       return BinaryOperator::CreateXor(New,
-                                      Context->getConstantInt(CI.getType(), 1));
+                                      ConstantInt::get(CI.getType(), 1));
     }
     break;
 
@@ -8477,7 +8483,7 @@
 
   // Canonicalize trunc x to i1 -> (icmp ne (and x, 1), 0)
   if (DestBitWidth == 1) {
-    Constant *One = Context->getConstantInt(Src->getType(), 1);
+    Constant *One = ConstantInt::get(Src->getType(), 1);
     Src = InsertNewInstBefore(BinaryOperator::CreateAnd(Src, One, "tmp"), CI);
     Value *Zero = Context->getNullValue(Src->getType());
     return new ICmpInst(*Context, ICmpInst::ICMP_NE, Src, Zero);
@@ -8524,7 +8530,7 @@
       if (!DoXform) return ICI;
 
       Value *In = ICI->getOperand(0);
-      Value *Sh = Context->getConstantInt(In->getType(),
+      Value *Sh = ConstantInt::get(In->getType(),
                                    In->getType()->getScalarSizeInBits()-1);
       In = InsertNewInstBefore(BinaryOperator::CreateLShr(In, Sh,
                                                         In->getName()+".lobit"),
@@ -8534,7 +8540,7 @@
                                          false/*ZExt*/, "tmp", &CI);
 
       if (ICI->getPredicate() == ICmpInst::ICMP_SGT) {
-        Constant *One = Context->getConstantInt(In->getType(), 1);
+        Constant *One = ConstantInt::get(In->getType(), 1);
         In = InsertNewInstBefore(BinaryOperator::CreateXor(In, One,
                                                          In->getName()+".not"),
                                  CI);
@@ -8570,7 +8576,7 @@
         if (Op1CV != 0 && (Op1CV != KnownZeroMask)) {
           // (X&4) == 2 --> false
           // (X&4) != 2 --> true
-          Constant *Res = Context->getConstantInt(Type::Int1Ty, isNE);
+          Constant *Res = ConstantInt::get(Type::Int1Ty, isNE);
           Res = Context->getConstantExprZExt(Res, CI.getType());
           return ReplaceInstUsesWith(CI, Res);
         }
@@ -8581,12 +8587,12 @@
           // Perform a logical shr by shiftamt.
           // Insert the shift to put the result in the low bit.
           In = InsertNewInstBefore(BinaryOperator::CreateLShr(In,
-                              Context->getConstantInt(In->getType(), ShiftAmt),
+                              ConstantInt::get(In->getType(), ShiftAmt),
                                                    In->getName()+".lobit"), CI);
         }
           
         if ((Op1CV != 0) == isNE) { // Toggle the low bit.
-          Constant *One = Context->getConstantInt(In->getType(), 1);
+          Constant *One = ConstantInt::get(In->getType(), 1);
           In = BinaryOperator::CreateXor(In, One, "tmp");
           InsertNewInstBefore(cast<Instruction>(In), CI);
         }
@@ -8625,21 +8631,21 @@
     // SrcSize  > DstSize: trunc(a) & mask
     if (SrcSize < DstSize) {
       APInt AndValue(APInt::getLowBitsSet(SrcSize, MidSize));
-      Constant *AndConst = Context->getConstantInt(A->getType(), AndValue);
+      Constant *AndConst = ConstantInt::get(A->getType(), AndValue);
       Instruction *And =
         BinaryOperator::CreateAnd(A, AndConst, CSrc->getName()+".mask");
       InsertNewInstBefore(And, CI);
       return new ZExtInst(And, CI.getType());
     } else if (SrcSize == DstSize) {
       APInt AndValue(APInt::getLowBitsSet(SrcSize, MidSize));
-      return BinaryOperator::CreateAnd(A, Context->getConstantInt(A->getType(),
+      return BinaryOperator::CreateAnd(A, ConstantInt::get(A->getType(),
                                                            AndValue));
     } else if (SrcSize > DstSize) {
       Instruction *Trunc = new TruncInst(A, CI.getType(), "tmp");
       InsertNewInstBefore(Trunc, CI);
       APInt AndValue(APInt::getLowBitsSet(DstSize, MidSize));
       return BinaryOperator::CreateAnd(Trunc, 
-                                       Context->getConstantInt(Trunc->getType(),
+                                       ConstantInt::get(Trunc->getType(),
                                                                AndValue));
     }
   }
@@ -8754,7 +8760,7 @@
       unsigned MidSize = Src->getType()->getScalarSizeInBits();
       unsigned SrcDstSize = CI.getType()->getScalarSizeInBits();
       unsigned ShAmt = CA->getZExtValue()+SrcDstSize-MidSize;
-      Constant *ShAmtV = Context->getConstantInt(CI.getType(), ShAmt);
+      Constant *ShAmtV = ConstantInt::get(CI.getType(), ShAmt);
       I = InsertNewInstBefore(BinaryOperator::CreateShl(I, ShAmtV,
                                                         CI.getName()), CI);
       return BinaryOperator::CreateAShr(I, ShAmtV);
@@ -9089,7 +9095,7 @@
   case Instruction::And:
     return Context->getAllOnesValue(I->getType());
   case Instruction::Mul:
-    return Context->getConstantInt(I->getType(), 1);
+    return ConstantInt::get(I->getType(), 1);
   }
 }
 
@@ -9322,7 +9328,7 @@
         if ((Pred == ICmpInst::ICMP_SLT && Op1CV == 0) ||
             (Pred == ICmpInst::ICMP_SGT && Op1CV.isAllOnesValue())) {
           Value *In = ICI->getOperand(0);
-          Value *Sh = Context->getConstantInt(In->getType(),
+          Value *Sh = ConstantInt::get(In->getType(),
                                        In->getType()->getScalarSizeInBits()-1);
           In = InsertNewInstBefore(BinaryOperator::CreateAShr(In, Sh,
                                                           In->getName()+".lobit"),
@@ -9674,7 +9680,7 @@
   unsigned CopyAlign = MI->getAlignment();
 
   if (CopyAlign < MinAlign) {
-    MI->setAlignment(Context->getConstantInt(MI->getAlignmentType(), 
+    MI->setAlignment(ConstantInt::get(MI->getAlignmentType(), 
                                              MinAlign, false));
     return MI;
   }
@@ -9749,7 +9755,7 @@
 Instruction *InstCombiner::SimplifyMemSet(MemSetInst *MI) {
   unsigned Alignment = GetOrEnforceKnownAlignment(MI->getDest());
   if (MI->getAlignment() < Alignment) {
-    MI->setAlignment(Context->getConstantInt(MI->getAlignmentType(),
+    MI->setAlignment(ConstantInt::get(MI->getAlignmentType(),
                                              Alignment, false));
     return MI;
   }
@@ -9777,7 +9783,7 @@
     
     // Extract the fill value and store.
     uint64_t Fill = FillC->getZExtValue()*0x0101010101010101ULL;
-    InsertNewInstBefore(new StoreInst(Context->getConstantInt(ITy, Fill),
+    InsertNewInstBefore(new StoreInst(ConstantInt::get(ITy, Fill),
                                       Dest, false, Alignment), *MI);
     
     // Set the size of the copy to 0, it will be deleted on the next iteration.
@@ -9950,14 +9956,14 @@
           if (ExtractedElts[Idx] == 0) {
             Instruction *Elt = 
               new ExtractElementInst(Idx < 16 ? Op0 : Op1, 
-                  Context->getConstantInt(Type::Int32Ty, Idx&15, false), "tmp");
+                  ConstantInt::get(Type::Int32Ty, Idx&15, false), "tmp");
             InsertNewInstBefore(Elt, CI);
             ExtractedElts[Idx] = Elt;
           }
         
           // Insert this value into the result vector.
           Result = InsertElementInst::Create(Result, ExtractedElts[Idx],
-                               Context->getConstantInt(Type::Int32Ty, i, false), 
+                               ConstantInt::get(Type::Int32Ty, i, false), 
                                "tmp");
           InsertNewInstBefore(cast<Instruction>(Result), CI);
         }
@@ -11230,16 +11236,16 @@
         if (ArrayEltSize == 1) {
           NewIdx = GEP.getOperand(1);
           Scale = 
-               Context->getConstantInt(cast<IntegerType>(NewIdx->getType()), 1);
+               ConstantInt::get(cast<IntegerType>(NewIdx->getType()), 1);
         } else if (ConstantInt *CI = dyn_cast<ConstantInt>(GEP.getOperand(1))) {
-          NewIdx = Context->getConstantInt(CI->getType(), 1);
+          NewIdx = ConstantInt::get(CI->getType(), 1);
           Scale = CI;
         } else if (Instruction *Inst =dyn_cast<Instruction>(GEP.getOperand(1))){
           if (Inst->getOpcode() == Instruction::Shl &&
               isa<ConstantInt>(Inst->getOperand(1))) {
             ConstantInt *ShAmt = cast<ConstantInt>(Inst->getOperand(1));
             uint32_t ShAmtVal = ShAmt->getLimitedValue(64);
-            Scale = Context->getConstantInt(cast<IntegerType>(Inst->getType()),
+            Scale = ConstantInt::get(cast<IntegerType>(Inst->getType()),
                                      1ULL << ShAmtVal);
             NewIdx = Inst->getOperand(0);
           } else if (Inst->getOpcode() == Instruction::Mul &&
@@ -11255,7 +11261,7 @@
         // operation after making sure Scale doesn't have the sign bit set.
         if (ArrayEltSize && Scale && Scale->getSExtValue() >= 0LL &&
             Scale->getZExtValue() % ArrayEltSize == 0) {
-          Scale = Context->getConstantInt(Scale->getType(),
+          Scale = ConstantInt::get(Scale->getType(),
                                    Scale->getZExtValue() / ArrayEltSize);
           if (Scale->getZExtValue() != 1) {
             Constant *C =
@@ -11466,7 +11472,7 @@
             SingleChar = 0;
             StrVal = (StrVal << 8) | SingleChar;
           }
-          Value *NL = Context->getConstantInt(StrVal);
+          Value *NL = ConstantInt::get(*Context, StrVal);
           return IC.ReplaceInstUsesWith(LI, NL);
         }
       }
@@ -12462,7 +12468,7 @@
           return ReplaceInstUsesWith(EI, Context->getUndef(EI.getType()));
         }
         return new ExtractElementInst(Src,
-                         Context->getConstantInt(Type::Int32Ty, SrcIdx, false));
+                         ConstantInt::get(Type::Int32Ty, SrcIdx, false));
       }
     }
     // FIXME: Canonicalize extractelement(bitcast) -> bitcast(extractelement)
@@ -12485,11 +12491,11 @@
     return true;
   } else if (V == LHS) {
     for (unsigned i = 0; i != NumElts; ++i)
-      Mask.push_back(Context->getConstantInt(Type::Int32Ty, i));
+      Mask.push_back(ConstantInt::get(Type::Int32Ty, i));
     return true;
   } else if (V == RHS) {
     for (unsigned i = 0; i != NumElts; ++i)
-      Mask.push_back(Context->getConstantInt(Type::Int32Ty, i+NumElts));
+      Mask.push_back(ConstantInt::get(Type::Int32Ty, i+NumElts));
     return true;
   } else if (InsertElementInst *IEI = dyn_cast<InsertElementInst>(V)) {
     // If this is an insert of an extract from some other vector, include it.
@@ -12523,11 +12529,11 @@
             // If so, update the mask to reflect the inserted value.
             if (EI->getOperand(0) == LHS) {
               Mask[InsertedIdx % NumElts] = 
-                 Context->getConstantInt(Type::Int32Ty, ExtractedIdx);
+                 ConstantInt::get(Type::Int32Ty, ExtractedIdx);
             } else {
               assert(EI->getOperand(0) == RHS);
               Mask[InsertedIdx % NumElts] = 
-                Context->getConstantInt(Type::Int32Ty, ExtractedIdx+NumElts);
+                ConstantInt::get(Type::Int32Ty, ExtractedIdx+NumElts);
               
             }
             return true;
@@ -12555,7 +12561,7 @@
     Mask.assign(NumElts, Context->getUndef(Type::Int32Ty));
     return V;
   } else if (isa<ConstantAggregateZero>(V)) {
-    Mask.assign(NumElts, Context->getConstantInt(Type::Int32Ty, 0));
+    Mask.assign(NumElts, ConstantInt::get(Type::Int32Ty, 0));
     return V;
   } else if (InsertElementInst *IEI = dyn_cast<InsertElementInst>(V)) {
     // If this is an insert of an extract from some other vector, include it.
@@ -12576,7 +12582,7 @@
           RHS = EI->getOperand(0);
           Value *V = CollectShuffleElements(VecOp, Mask, RHS, Context);
           Mask[InsertedIdx % NumElts] = 
-            Context->getConstantInt(Type::Int32Ty, NumElts+ExtractedIdx);
+            ConstantInt::get(Type::Int32Ty, NumElts+ExtractedIdx);
           return V;
         }
         
@@ -12586,7 +12592,7 @@
           // Everything but the extracted element is replaced with the RHS.
           for (unsigned i = 0; i != NumElts; ++i) {
             if (i != InsertedIdx)
-              Mask[i] = Context->getConstantInt(Type::Int32Ty, NumElts+i);
+              Mask[i] = ConstantInt::get(Type::Int32Ty, NumElts+i);
           }
           return V;
         }
@@ -12604,7 +12610,7 @@
   
   // Otherwise, can't do anything fancy.  Return an identity vector.
   for (unsigned i = 0; i != NumElts; ++i)
-    Mask.push_back(Context->getConstantInt(Type::Int32Ty, i));
+    Mask.push_back(ConstantInt::get(Type::Int32Ty, i));
   return V;
 }
 
@@ -12651,11 +12657,11 @@
           Mask.assign(NumVectorElts, Context->getUndef(Type::Int32Ty));
         else {
           assert(isa<ConstantAggregateZero>(VecOp) && "Unknown thing");
-          Mask.assign(NumVectorElts, Context->getConstantInt(Type::Int32Ty,
+          Mask.assign(NumVectorElts, ConstantInt::get(Type::Int32Ty,
                                                        NumVectorElts));
         } 
         Mask[InsertedIdx] = 
-                           Context->getConstantInt(Type::Int32Ty, ExtractedIdx);
+                           ConstantInt::get(Type::Int32Ty, ExtractedIdx);
         return new ShuffleVectorInst(EI->getOperand(0), VecOp,
                                      Context->getConstantVector(Mask));
       }
@@ -12728,7 +12734,7 @@
           Elts.push_back(Context->getUndef(Type::Int32Ty));
         } else {
           Mask[i] = Mask[i] % e;  // Force to LHS.
-          Elts.push_back(Context->getConstantInt(Type::Int32Ty, Mask[i]));
+          Elts.push_back(ConstantInt::get(Type::Int32Ty, Mask[i]));
         }
       }
     }
@@ -12786,7 +12792,7 @@
           if (NewMask[i] >= LHSInNElts*2) {
             Elts.push_back(Context->getUndef(Type::Int32Ty));
           } else {
-            Elts.push_back(Context->getConstantInt(Type::Int32Ty, NewMask[i]));
+            Elts.push_back(ConstantInt::get(Type::Int32Ty, NewMask[i]));
           }
         }
         return new ShuffleVectorInst(LHSSVI->getOperand(0),

Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Fri Jul 24 18:12:02 2009
@@ -434,8 +434,7 @@
          << "' folding condition to '" << BranchDir << "': "
          << *BB->getTerminator();
     ++NumFolds;
-    DestBI->setCondition(BB->getContext().getConstantInt(Type::Int1Ty, 
-                                                         BranchDir));
+    DestBI->setCondition(ConstantInt::get(Type::Int1Ty, BranchDir));
     ConstantFoldTerminator(BB);
     return true;
   }
@@ -757,7 +756,7 @@
   // We can only do the simplification for phi nodes of 'false' with AND or
   // 'true' with OR.  See if we have any entries in the phi for this.
   unsigned PredNo = ~0U;
-  ConstantInt *PredCst = V->getContext().getConstantInt(Type::Int1Ty, !isAnd);
+  ConstantInt *PredCst = ConstantInt::get(Type::Int1Ty, !isAnd);
   for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {
     if (PN->getIncomingValue(i) == PredCst) {
       PredNo = i;

Modified: llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Fri Jul 24 18:12:02 2009
@@ -295,14 +295,14 @@
 // Return V+1
 static Value *getPlusOne(Value *V, bool Sign, Instruction *InsertPt, 
                          LLVMContext &Context) {
-  Constant *One = Context.getConstantInt(V->getType(), 1, Sign);
+  Constant *One = ConstantInt::get(V->getType(), 1, Sign);
   return BinaryOperator::CreateAdd(V, One, "lsp", InsertPt);
 }
 
 // Return V-1
 static Value *getMinusOne(Value *V, bool Sign, Instruction *InsertPt,
                           LLVMContext &Context) {
-  Constant *One = Context.getConstantInt(V->getType(), 1, Sign);
+  Constant *One = ConstantInt::get(V->getType(), 1, Sign);
   return BinaryOperator::CreateSub(V, One, "lsp", InsertPt);
 }
 

Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Fri Jul 24 18:12:02 2009
@@ -1991,9 +1991,9 @@
 
       NewStride = &IU->StrideOrder[i];
       if (!isa<PointerType>(NewCmpTy))
-        NewCmpRHS = Context.getConstantInt(NewCmpTy, NewCmpVal);
+        NewCmpRHS = ConstantInt::get(NewCmpTy, NewCmpVal);
       else {
-        Constant *CI = Context.getConstantInt(NewCmpIntTy, NewCmpVal);
+        Constant *CI = ConstantInt::get(NewCmpIntTy, NewCmpVal);
         NewCmpRHS = Context.getConstantExprIntToPtr(CI, NewCmpTy);
       }
       NewOffset = TyBits == NewTyBits
@@ -2432,8 +2432,6 @@
   if (!ExitingBlock)
     return; // More than one block exiting!
 
-  LLVMContext &Context = ExitingBlock->getContext();
-
   // Okay, we've computed the exiting block.  See what condition causes us to
   // exit.
   //
@@ -2506,7 +2504,7 @@
   Value *startVal = phi->getIncomingValue(inBlock);
   Value *endVal = Cond->getOperand(1);
   // FIXME check for case where both are constant
-  Constant* Zero = Context.getConstantInt(Cond->getOperand(1)->getType(), 0);
+  Constant* Zero = ConstantInt::get(Cond->getOperand(1)->getType(), 0);
   BinaryOperator *NewStartVal = 
     BinaryOperator::Create(Instruction::Sub, endVal, startVal,
                            "tmp", PreInsertPt);

Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Fri Jul 24 18:12:02 2009
@@ -911,7 +911,7 @@
     if (IsEqual)
       Replacement = Val;
     else
-      Replacement = Context.getConstantInt(Type::Int1Ty, 
+      Replacement = ConstantInt::get(Type::Int1Ty, 
                                      !cast<ConstantInt>(Val)->getZExtValue());
     
     for (unsigned i = 0, e = Users.size(); i != e; ++i)

Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Fri Jul 24 18:12:02 2009
@@ -69,7 +69,7 @@
         if (Val != Val2)
           return 0;
       }
-      return Context.getConstantInt(Val);
+      return ConstantInt::get(Context, Val);
     }
   }
   
@@ -448,9 +448,9 @@
     Value *Ops[] = {
       StartPtr, ByteVal,   // Start, value
       // size
-      SI->getContext().getConstantInt(Type::Int64Ty, Range.End-Range.Start),
+      ConstantInt::get(Type::Int64Ty, Range.End-Range.Start),
       // align
-      SI->getContext().getConstantInt(Type::Int32Ty, Range.Alignment)
+      ConstantInt::get(Type::Int32Ty, Range.Alignment)
     };
     Value *C = CallInst::Create(MemSetF, Ops, Ops+4, "", InsertPt);
     DEBUG(cerr << "Replace stores:\n";

Modified: llvm/trunk/lib/Transforms/Scalar/PredicateSimplifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/PredicateSimplifier.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/PredicateSimplifier.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/PredicateSimplifier.cpp Fri Jul 24 18:12:02 2009
@@ -1169,7 +1169,8 @@
         Value *V = VN.value(n); // XXX: redesign worklist.
         const Type *Ty = V->getType();
         if (Ty->isInteger()) {
-          addToWorklist(V, Context->getConstantInt(*I), ICmpInst::ICMP_EQ, VRP);
+          addToWorklist(V, ConstantInt::get(*Context, *I),
+                        ICmpInst::ICMP_EQ, VRP);
           return;
         } else if (const PointerType *PTy = dyn_cast<PointerType>(Ty)) {
           assert(*I == 0 && "Pointer is null but not zero?");
@@ -1783,7 +1784,7 @@
             if (ConstantInt *CI = dyn_cast<ConstantInt>(Canonical)) {
               if (ConstantInt *Arg = dyn_cast<ConstantInt>(LHS)) {
                 add(RHS,
-                    Context->getConstantInt(CI->getValue() ^ Arg->getValue()),
+                  ConstantInt::get(*Context, CI->getValue() ^ Arg->getValue()),
                     ICmpInst::ICMP_EQ, NewContext);
               }
             }
@@ -1895,7 +1896,7 @@
         assert(!Ty->isFPOrFPVector() && "Float in work queue!");
 
         Constant *Zero = Context->getNullValue(Ty);
-        Constant *One = Context->getConstantInt(Ty, 1);
+        Constant *One = ConstantInt::get(Ty, 1);
         ConstantInt *AllOnes = cast<ConstantInt>(Context->getAllOnesValue(Ty));
 
         switch (Opcode) {
@@ -2535,23 +2536,23 @@
 
   void PredicateSimplifier::Forwards::visitSExtInst(SExtInst &SI) {
     VRPSolver VRP(VN, IG, UB, VR, PS->DTDFS, PS->modified, &SI);
-    LLVMContext *Context = &SI.getContext();
+    LLVMContext &Context = SI.getContext();
     uint32_t SrcBitWidth = cast<IntegerType>(SI.getSrcTy())->getBitWidth();
     uint32_t DstBitWidth = cast<IntegerType>(SI.getDestTy())->getBitWidth();
     APInt Min(APInt::getHighBitsSet(DstBitWidth, DstBitWidth-SrcBitWidth+1));
     APInt Max(APInt::getLowBitsSet(DstBitWidth, SrcBitWidth-1));
-    VRP.add(Context->getConstantInt(Min), &SI, ICmpInst::ICMP_SLE);
-    VRP.add(Context->getConstantInt(Max), &SI, ICmpInst::ICMP_SGE);
+    VRP.add(ConstantInt::get(Context, Min), &SI, ICmpInst::ICMP_SLE);
+    VRP.add(ConstantInt::get(Context, Max), &SI, ICmpInst::ICMP_SGE);
     VRP.solve();
   }
 
   void PredicateSimplifier::Forwards::visitZExtInst(ZExtInst &ZI) {
     VRPSolver VRP(VN, IG, UB, VR, PS->DTDFS, PS->modified, &ZI);
-    LLVMContext *Context = &ZI.getContext();
+    LLVMContext &Context = ZI.getContext();
     uint32_t SrcBitWidth = cast<IntegerType>(ZI.getSrcTy())->getBitWidth();
     uint32_t DstBitWidth = cast<IntegerType>(ZI.getDestTy())->getBitWidth();
     APInt Max(APInt::getLowBitsSet(DstBitWidth, SrcBitWidth));
-    VRP.add(Context->getConstantInt(Max), &ZI, ICmpInst::ICMP_UGE);
+    VRP.add(ConstantInt::get(Context, Max), &ZI, ICmpInst::ICMP_UGE);
     VRP.solve();
   }
 
@@ -2640,7 +2641,7 @@
 
     Pred = IC.getPredicate();
 
-    LLVMContext *Context = &IC.getContext();
+    LLVMContext &Context = IC.getContext();
 
     if (ConstantInt *Op1 = dyn_cast<ConstantInt>(IC.getOperand(1))) {
       ConstantInt *NextVal = 0;
@@ -2649,12 +2650,12 @@
         case ICmpInst::ICMP_SLT:
         case ICmpInst::ICMP_ULT:
           if (Op1->getValue() != 0)
-            NextVal = Context->getConstantInt(Op1->getValue()-1);
+            NextVal = ConstantInt::get(Context, Op1->getValue()-1);
          break;
         case ICmpInst::ICMP_SGT:
         case ICmpInst::ICMP_UGT:
           if (!Op1->getValue().isAllOnesValue())
-            NextVal = Context->getConstantInt(Op1->getValue()+1);
+            NextVal = ConstantInt::get(Context, Op1->getValue()+1);
          break;
       }
 

Modified: llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Fri Jul 24 18:12:02 2009
@@ -466,7 +466,7 @@
       (Shl->hasOneUse() && 
        (isReassociableOp(Shl->use_back(), Instruction::Mul) ||
         isReassociableOp(Shl->use_back(), Instruction::Add)))) {
-    Constant *MulCst = Context.getConstantInt(Shl->getType(), 1);
+    Constant *MulCst = ConstantInt::get(Shl->getType(), 1);
     MulCst =
         Context.getConstantExprShl(MulCst, cast<Constant>(Shl->getOperand(1)));
     

Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Fri Jul 24 18:12:02 2009
@@ -776,7 +776,7 @@
     unsigned OtherEltAlign = MemAlignment;
     
     if (OtherPtr) {
-      Value *Idx[2] = { Zero, Context.getConstantInt(Type::Int32Ty, i) };
+      Value *Idx[2] = { Zero, ConstantInt::get(Type::Int32Ty, i) };
       OtherElt = GetElementPtrInst::Create(OtherPtr, Idx, Idx + 2,
                                            OtherPtr->getNameStr()+"."+utostr(i),
                                            MI);
@@ -839,7 +839,7 @@
           }
           
           // Convert the integer value to the appropriate type.
-          StoreVal = Context.getConstantInt(TotalVal);
+          StoreVal = ConstantInt::get(Context, TotalVal);
           if (isa<PointerType>(ValTy))
             StoreVal = Context.getConstantExprIntToPtr(StoreVal, ValTy);
           else if (ValTy->isFloatingPoint())
@@ -876,15 +876,15 @@
       Value *Ops[] = {
         SROADest ? EltPtr : OtherElt,  // Dest ptr
         SROADest ? OtherElt : EltPtr,  // Src ptr
-        Context.getConstantInt(MI->getOperand(3)->getType(), EltSize), // Size
-        Context.getConstantInt(Type::Int32Ty, OtherEltAlign)  // Align
+        ConstantInt::get(MI->getOperand(3)->getType(), EltSize), // Size
+        ConstantInt::get(Type::Int32Ty, OtherEltAlign)  // Align
       };
       CallInst::Create(TheFn, Ops, Ops + 4, "", MI);
     } else {
       assert(isa<MemSetInst>(MI));
       Value *Ops[] = {
         EltPtr, MI->getOperand(2),  // Dest, Value,
-        Context.getConstantInt(MI->getOperand(3)->getType(), EltSize), // Size
+        ConstantInt::get(MI->getOperand(3)->getType(), EltSize), // Size
         Zero  // Align
       };
       CallInst::Create(TheFn, Ops, Ops + 4, "", MI);
@@ -934,7 +934,7 @@
       
       Value *EltVal = SrcVal;
       if (Shift) {
-        Value *ShiftVal = Context.getConstantInt(EltVal->getType(), Shift);
+        Value *ShiftVal = ConstantInt::get(EltVal->getType(), Shift);
         EltVal = BinaryOperator::CreateLShr(EltVal, ShiftVal,
                                             "sroa.store.elt", SI);
       }
@@ -982,7 +982,7 @@
       
       Value *EltVal = SrcVal;
       if (Shift) {
-        Value *ShiftVal = Context.getConstantInt(EltVal->getType(), Shift);
+        Value *ShiftVal = ConstantInt::get(EltVal->getType(), Shift);
         EltVal = BinaryOperator::CreateLShr(EltVal, ShiftVal,
                                             "sroa.store.elt", SI);
       }
@@ -1089,7 +1089,7 @@
       Shift = AllocaSizeBits-Shift-FieldIntTy->getBitWidth();
     
     if (Shift) {
-      Value *ShiftVal = Context.getConstantInt(SrcField->getType(), Shift);
+      Value *ShiftVal = ConstantInt::get(SrcField->getType(), Shift);
       SrcField = BinaryOperator::CreateShl(SrcField, ShiftVal, "", LI);
     }
 
@@ -1212,7 +1212,7 @@
                                              Indices.begin(),
                                              Indices.end(),
                                              GEPI->getName()+".0", GEPI);
-  Indices[1] = Context.getConstantInt(Type::Int32Ty, 1);
+  Indices[1] = ConstantInt::get(Type::Int32Ty, 1);
   Value *OneIdx = GetElementPtrInst::Create(GEPI->getOperand(0),
                                             Indices.begin(),
                                             Indices.end(),
@@ -1469,7 +1469,7 @@
         
         Value *Old = Builder.CreateLoad(NewAI, (NewAI->getName()+".in").c_str());
         Value *New = ConvertScalar_InsertValue(
-                                      User->getContext().getConstantInt(APVal),
+                                    ConstantInt::get(User->getContext(), APVal),
                                                Old, Offset, Builder);
         Builder.CreateStore(New, NewAI);
       }
@@ -1558,7 +1558,7 @@
     }
     // Return the element extracted out of it.
     Value *V = Builder.CreateExtractElement(FromVal,
-                                    Context.getConstantInt(Type::Int32Ty,Elt),
+                                    ConstantInt::get(Type::Int32Ty,Elt),
                                             "tmp");
     if (V->getType() != ToType)
       V = Builder.CreateBitCast(V, ToType, "tmp");
@@ -1611,11 +1611,11 @@
   // only some bits are used.
   if (ShAmt > 0 && (unsigned)ShAmt < NTy->getBitWidth())
     FromVal = Builder.CreateLShr(FromVal,
-                                 Context.getConstantInt(FromVal->getType(),
+                                 ConstantInt::get(FromVal->getType(),
                                                            ShAmt), "tmp");
   else if (ShAmt < 0 && (unsigned)-ShAmt < NTy->getBitWidth())
     FromVal = Builder.CreateShl(FromVal, 
-                                Context.getConstantInt(FromVal->getType(),
+                                ConstantInt::get(FromVal->getType(),
                                                           -ShAmt), "tmp");
 
   // Finally, unconditionally truncate the integer to the right width.
@@ -1677,7 +1677,7 @@
       SV = Builder.CreateBitCast(SV, VTy->getElementType(), "tmp");
     
     SV = Builder.CreateInsertElement(Old, SV, 
-                                   Context.getConstantInt(Type::Int32Ty, Elt),
+                                   ConstantInt::get(Type::Int32Ty, Elt),
                                      "tmp");
     return SV;
   }
@@ -1745,11 +1745,11 @@
   // only some bits in the structure are set.
   APInt Mask(APInt::getLowBitsSet(DestWidth, SrcWidth));
   if (ShAmt > 0 && (unsigned)ShAmt < DestWidth) {
-    SV = Builder.CreateShl(SV, Context.getConstantInt(SV->getType(),
+    SV = Builder.CreateShl(SV, ConstantInt::get(SV->getType(),
                            ShAmt), "tmp");
     Mask <<= ShAmt;
   } else if (ShAmt < 0 && (unsigned)-ShAmt < DestWidth) {
-    SV = Builder.CreateLShr(SV, Context.getConstantInt(SV->getType(),
+    SV = Builder.CreateLShr(SV, ConstantInt::get(SV->getType(),
                             -ShAmt), "tmp");
     Mask = Mask.lshr(-ShAmt);
   }
@@ -1758,7 +1758,7 @@
   // in the new bits.
   if (SrcWidth != DestWidth) {
     assert(DestWidth > SrcWidth);
-    Old = Builder.CreateAnd(Old, Context.getConstantInt(~Mask), "mask");
+    Old = Builder.CreateAnd(Old, ConstantInt::get(Context, ~Mask), "mask");
     SV = Builder.CreateOr(Old, SV, "ins");
   }
   return SV;

Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Fri Jul 24 18:12:02 2009
@@ -157,7 +157,7 @@
   Tys[0] = Len->getType();
   Value *MemCpy = Intrinsic::getDeclaration(M, IID, Tys, 1);
   return B.CreateCall4(MemCpy, CastToCStr(Dst, B), CastToCStr(Src, B), Len,
-                       Context->getConstantInt(Type::Int32Ty, Align));
+                       ConstantInt::get(Type::Int32Ty, Align));
 }
 
 /// EmitMemChr - Emit a call to the memchr function.  This assumes that Ptr is
@@ -213,7 +213,7 @@
  const Type *Tys[1];
  Tys[0] = Len->getType();
  Value *MemSet = Intrinsic::getDeclaration(M, IID, Tys, 1);
- Value *Align = Context->getConstantInt(Type::Int32Ty, 1);
+ Value *Align = ConstantInt::get(Type::Int32Ty, 1);
  return B.CreateCall4(MemSet, CastToCStr(Dst, B), Val, Len, Align);
 }
 
@@ -346,7 +346,7 @@
                                TD->getIntPtrType(), TD->getIntPtrType(),
                                File->getType(), NULL);
   CallInst *CI = B.CreateCall4(F, CastToCStr(Ptr, B), Size,
-                        Context->getConstantInt(TD->getIntPtrType(), 1), File);
+                        ConstantInt::get(TD->getIntPtrType(), 1), File);
 
   if (const Function *Fn = dyn_cast<Function>(F->stripPointerCasts()))
     CI->setCallingConv(Fn->getCallingConv());
@@ -580,7 +580,7 @@
     // We have enough information to now generate the memcpy call to do the
     // concatenation for us.  Make a memcpy to copy the nul byte with align = 1.
     EmitMemCpy(CpyDst, Src,
-               Context->getConstantInt(TD->getIntPtrType(), Len+1), 1, B);
+               ConstantInt::get(TD->getIntPtrType(), Len+1), 1, B);
   }
 };
 
@@ -652,7 +652,7 @@
         return 0;
       
       return EmitMemChr(SrcStr, CI->getOperand(2), // include nul.
-                        Context->getConstantInt(TD->getIntPtrType(), Len), B);
+                        ConstantInt::get(TD->getIntPtrType(), Len), B);
     }
 
     // Otherwise, the character is a constant, see if the first argument is
@@ -677,7 +677,7 @@
     }
     
     // strchr(s+n,c)  -> gep(s+n+i,c)
-    Value *Idx = Context->getConstantInt(Type::Int64Ty, i);
+    Value *Idx = ConstantInt::get(Type::Int64Ty, i);
     return B.CreateGEP(SrcStr, Idx, "strchr");
   }
 };
@@ -696,7 +696,7 @@
     
     Value *Str1P = CI->getOperand(1), *Str2P = CI->getOperand(2);
     if (Str1P == Str2P)      // strcmp(x,x)  -> 0
-      return Context->getConstantInt(CI->getType(), 0);
+      return ConstantInt::get(CI->getType(), 0);
     
     std::string Str1, Str2;
     bool HasStr1 = GetConstantStringInfo(Str1P, Str1);
@@ -710,7 +710,7 @@
     
     // strcmp(x, y)  -> cnst  (if both x and y are constant strings)
     if (HasStr1 && HasStr2)
-      return Context->getConstantInt(CI->getType(), 
+      return ConstantInt::get(CI->getType(), 
                                      strcmp(Str1.c_str(),Str2.c_str()));
 
     // strcmp(P, "x") -> memcmp(P, "x", 2)
@@ -718,7 +718,7 @@
     uint64_t Len2 = GetStringLength(Str2P);
     if (Len1 && Len2) {
       return EmitMemCmp(Str1P, Str2P,
-                        Context->getConstantInt(TD->getIntPtrType(),
+                        ConstantInt::get(TD->getIntPtrType(),
                         std::min(Len1, Len2)), B);
     }
 
@@ -741,7 +741,7 @@
     
     Value *Str1P = CI->getOperand(1), *Str2P = CI->getOperand(2);
     if (Str1P == Str2P)      // strncmp(x,x,n)  -> 0
-      return Context->getConstantInt(CI->getType(), 0);
+      return ConstantInt::get(CI->getType(), 0);
     
     // Get the length argument if it is constant.
     uint64_t Length;
@@ -751,7 +751,7 @@
       return 0;
     
     if (Length == 0) // strncmp(x,y,0)   -> 0
-      return Context->getConstantInt(CI->getType(), 0);
+      return ConstantInt::get(CI->getType(), 0);
     
     std::string Str1, Str2;
     bool HasStr1 = GetConstantStringInfo(Str1P, Str1);
@@ -765,7 +765,7 @@
     
     // strncmp(x, y)  -> cnst  (if both x and y are constant strings)
     if (HasStr1 && HasStr2)
-      return Context->getConstantInt(CI->getType(),
+      return ConstantInt::get(CI->getType(),
                               strncmp(Str1.c_str(), Str2.c_str(), Length));
     return 0;
   }
@@ -795,7 +795,7 @@
     // We have enough information to now generate the memcpy call to do the
     // concatenation for us.  Make a memcpy to copy the nul byte with align = 1.
     EmitMemCpy(Dst, Src,
-               Context->getConstantInt(TD->getIntPtrType(), Len), 1, B);
+               ConstantInt::get(TD->getIntPtrType(), Len), 1, B);
     return Dst;
   }
 };
@@ -823,7 +823,7 @@
 
     if (SrcLen == 0) {
       // strncpy(x, "", y) -> memset(x, '\0', y, 1)
-      EmitMemSet(Dst, Context->getConstantInt(Type::Int8Ty, '\0'), LenOp, B);
+      EmitMemSet(Dst, ConstantInt::get(Type::Int8Ty, '\0'), LenOp, B);
       return Dst;
     }
 
@@ -840,7 +840,7 @@
 
     // strncpy(x, s, c) -> memcpy(x, s, c, 1) [s and c are constant]
     EmitMemCpy(Dst, Src,
-               Context->getConstantInt(TD->getIntPtrType(), Len), 1, B);
+               ConstantInt::get(TD->getIntPtrType(), Len), 1, B);
 
     return Dst;
   }
@@ -861,7 +861,7 @@
 
     // Constant folding: strlen("xyz") -> 3
     if (uint64_t Len = GetStringLength(Src))
-      return Context->getConstantInt(CI->getType(), Len-1);
+      return ConstantInt::get(CI->getType(), Len-1);
 
     // Handle strlen(p) != 0.
     if (!IsOnlyUsedInZeroEqualityComparison(CI)) return 0;
@@ -980,7 +980,7 @@
     Value *Dst = CastToCStr(CI->getOperand(1), B);
     Value *Src = CastToCStr(CI->getOperand(2), B);
     Value *Size = CI->getOperand(3);
-    Value *Align = Context->getConstantInt(Type::Int32Ty, 1);
+    Value *Align = ConstantInt::get(Type::Int32Ty, 1);
     B.CreateCall4(MemMove, Dst, Src, Size, Align);
     return CI->getOperand(1);
   }
@@ -1154,7 +1154,7 @@
     if (ConstantInt *CI = dyn_cast<ConstantInt>(Op)) {
       if (CI->getValue() == 0)  // ffs(0) -> 0.
         return Context->getNullValue(CI->getType());
-      return Context->getConstantInt(Type::Int32Ty, // ffs(c) -> cttz(c)+1
+      return ConstantInt::get(Type::Int32Ty, // ffs(c) -> cttz(c)+1
                               CI->getValue().countTrailingZeros()+1);
     }
     
@@ -1163,11 +1163,11 @@
     Value *F = Intrinsic::getDeclaration(Callee->getParent(),
                                          Intrinsic::cttz, &ArgType, 1);
     Value *V = B.CreateCall(F, Op, "cttz");
-    V = B.CreateAdd(V, Context->getConstantInt(V->getType(), 1), "tmp");
+    V = B.CreateAdd(V, ConstantInt::get(V->getType(), 1), "tmp");
     V = B.CreateIntCast(V, Type::Int32Ty, false, "tmp");
     
     Value *Cond = B.CreateICmpNE(Op, Context->getNullValue(ArgType), "tmp");
-    return B.CreateSelect(Cond, V, Context->getConstantInt(Type::Int32Ty, 0));
+    return B.CreateSelect(Cond, V, ConstantInt::get(Type::Int32Ty, 0));
   }
 };
 
@@ -1184,9 +1184,9 @@
     
     // isdigit(c) -> (c-'0') <u 10
     Value *Op = CI->getOperand(1);
-    Op = B.CreateSub(Op, Context->getConstantInt(Type::Int32Ty, '0'), 
+    Op = B.CreateSub(Op, ConstantInt::get(Type::Int32Ty, '0'), 
                      "isdigittmp");
-    Op = B.CreateICmpULT(Op, Context->getConstantInt(Type::Int32Ty, 10), 
+    Op = B.CreateICmpULT(Op, ConstantInt::get(Type::Int32Ty, 10), 
                          "isdigit");
     return B.CreateZExt(Op, CI->getType());
   }
@@ -1205,7 +1205,7 @@
     
     // isascii(c) -> c <u 128
     Value *Op = CI->getOperand(1);
-    Op = B.CreateICmpULT(Op, Context->getConstantInt(Type::Int32Ty, 128),
+    Op = B.CreateICmpULT(Op, ConstantInt::get(Type::Int32Ty, 128),
                          "isascii");
     return B.CreateZExt(Op, CI->getType());
   }
@@ -1246,7 +1246,7 @@
     
     // isascii(c) -> c & 0x7f
     return B.CreateAnd(CI->getOperand(1),
-                       Context->getConstantInt(CI->getType(),0x7F));
+                       ConstantInt::get(CI->getType(),0x7F));
   }
 };
 
@@ -1274,13 +1274,13 @@
     // Empty format string -> noop.
     if (FormatStr.empty())  // Tolerate printf's declared void.
       return CI->use_empty() ? (Value*)CI : 
-                               Context->getConstantInt(CI->getType(), 0);
+                               ConstantInt::get(CI->getType(), 0);
     
     // printf("x") -> putchar('x'), even for '%'.
     if (FormatStr.size() == 1) {
-      EmitPutChar(Context->getConstantInt(Type::Int32Ty, FormatStr[0]), B);
+      EmitPutChar(ConstantInt::get(Type::Int32Ty, FormatStr[0]), B);
       return CI->use_empty() ? (Value*)CI : 
-                               Context->getConstantInt(CI->getType(), 1);
+                               ConstantInt::get(CI->getType(), 1);
     }
     
     // printf("foo\n") --> puts("foo")
@@ -1294,7 +1294,7 @@
                              GlobalVariable::InternalLinkage, C, "str");
       EmitPutS(C, B);
       return CI->use_empty() ? (Value*)CI : 
-                    Context->getConstantInt(CI->getType(), FormatStr.size()+1);
+                    ConstantInt::get(CI->getType(), FormatStr.size()+1);
     }
     
     // Optimize specific format strings.
@@ -1303,7 +1303,7 @@
         isa<IntegerType>(CI->getOperand(2)->getType())) {
       EmitPutChar(CI->getOperand(2), B);
       return CI->use_empty() ? (Value*)CI : 
-                               Context->getConstantInt(CI->getType(), 1);
+                               ConstantInt::get(CI->getType(), 1);
     }
     
     // printf("%s\n", str) --> puts(str)
@@ -1344,8 +1344,8 @@
       
       // sprintf(str, fmt) -> llvm.memcpy(str, fmt, strlen(fmt)+1, 1)
       EmitMemCpy(CI->getOperand(1), CI->getOperand(2), // Copy the nul byte.
-          Context->getConstantInt(TD->getIntPtrType(), FormatStr.size()+1),1,B);
-      return Context->getConstantInt(CI->getType(), FormatStr.size());
+          ConstantInt::get(TD->getIntPtrType(), FormatStr.size()+1),1,B);
+      return ConstantInt::get(CI->getType(), FormatStr.size());
     }
     
     // The remaining optimizations require the format string to be "%s" or "%c"
@@ -1360,10 +1360,10 @@
       Value *V = B.CreateTrunc(CI->getOperand(3), Type::Int8Ty, "char");
       Value *Ptr = CastToCStr(CI->getOperand(1), B);
       B.CreateStore(V, Ptr);
-      Ptr = B.CreateGEP(Ptr, Context->getConstantInt(Type::Int32Ty, 1), "nul");
+      Ptr = B.CreateGEP(Ptr, ConstantInt::get(Type::Int32Ty, 1), "nul");
       B.CreateStore(Context->getNullValue(Type::Int8Ty), Ptr);
       
-      return Context->getConstantInt(CI->getType(), 1);
+      return ConstantInt::get(CI->getType(), 1);
     }
     
     if (FormatStr[1] == 's') {
@@ -1372,7 +1372,7 @@
 
       Value *Len = EmitStrLen(CI->getOperand(3), B);
       Value *IncLen = B.CreateAdd(Len,
-                                  Context->getConstantInt(Len->getType(), 1),
+                                  ConstantInt::get(Len->getType(), 1),
                                   "leninc");
       EmitMemCpy(CI->getOperand(1), CI->getOperand(3), IncLen, 1, B);
       
@@ -1405,13 +1405,13 @@
     
     // If this is writing zero records, remove the call (it's a noop).
     if (Bytes == 0)
-      return Context->getConstantInt(CI->getType(), 0);
+      return ConstantInt::get(CI->getType(), 0);
     
     // If this is writing one byte, turn it into fputc.
     if (Bytes == 1) {  // fwrite(S,1,1,F) -> fputc(S[0],F)
       Value *Char = B.CreateLoad(CastToCStr(CI->getOperand(1), B), "char");
       EmitFPutC(Char, CI->getOperand(4), B);
-      return Context->getConstantInt(CI->getType(), 1);
+      return ConstantInt::get(CI->getType(), 1);
     }
 
     return 0;
@@ -1434,7 +1434,7 @@
     uint64_t Len = GetStringLength(CI->getOperand(1));
     if (!Len) return 0;
     EmitFWrite(CI->getOperand(1),
-               Context->getConstantInt(TD->getIntPtrType(), Len-1),
+               ConstantInt::get(TD->getIntPtrType(), Len-1),
                CI->getOperand(2), B);
     return CI;  // Known to have no uses (see above).
   }
@@ -1463,10 +1463,10 @@
         if (FormatStr[i] == '%')  // Could handle %% -> % if we cared.
           return 0; // We found a format specifier.
       
-      EmitFWrite(CI->getOperand(2), Context->getConstantInt(TD->getIntPtrType(),
+      EmitFWrite(CI->getOperand(2), ConstantInt::get(TD->getIntPtrType(),
                                                      FormatStr.size()),
                  CI->getOperand(1), B);
-      return Context->getConstantInt(CI->getType(), FormatStr.size());
+      return ConstantInt::get(CI->getType(), FormatStr.size());
     }
     
     // The remaining optimizations require the format string to be "%s" or "%c"
@@ -1479,7 +1479,7 @@
       // fprintf(F, "%c", chr) --> *(i8*)dst = chr
       if (!isa<IntegerType>(CI->getOperand(3)->getType())) return 0;
       EmitFPutC(CI->getOperand(3), CI->getOperand(1), B);
-      return Context->getConstantInt(CI->getType(), 1);
+      return ConstantInt::get(CI->getType(), 1);
     }
     
     if (FormatStr[1] == 's') {

Modified: llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp Fri Jul 24 18:12:02 2009
@@ -306,7 +306,7 @@
     if (AggregateArgs) {
       Value *Idx[2];
       Idx[0] = Context.getNullValue(Type::Int32Ty);
-      Idx[1] = Context.getConstantInt(Type::Int32Ty, i);
+      Idx[1] = ConstantInt::get(Type::Int32Ty, i);
       TerminatorInst *TI = newFunction->begin()->getTerminator();
       GetElementPtrInst *GEP = 
         GetElementPtrInst::Create(AI, Idx, Idx+2, 
@@ -396,7 +396,7 @@
     for (unsigned i = 0, e = inputs.size(); i != e; ++i) {
       Value *Idx[2];
       Idx[0] = Context.getNullValue(Type::Int32Ty);
-      Idx[1] = Context.getConstantInt(Type::Int32Ty, i);
+      Idx[1] = ConstantInt::get(Type::Int32Ty, i);
       GetElementPtrInst *GEP =
         GetElementPtrInst::Create(Struct, Idx, Idx + 2,
                                   "gep_" + StructValues[i]->getName());
@@ -422,7 +422,7 @@
     if (AggregateArgs) {
       Value *Idx[2];
       Idx[0] = Context.getNullValue(Type::Int32Ty);
-      Idx[1] = Context.getConstantInt(Type::Int32Ty, FirstOut + i);
+      Idx[1] = ConstantInt::get(Type::Int32Ty, FirstOut + i);
       GetElementPtrInst *GEP
         = GetElementPtrInst::Create(Struct, Idx, Idx + 2,
                                     "gep_reload_" + outputs[i]->getName());
@@ -474,17 +474,17 @@
           case 0:
           case 1: break;  // No value needed.
           case 2:         // Conditional branch, return a bool
-            brVal = Context.getConstantInt(Type::Int1Ty, !SuccNum);
+            brVal = ConstantInt::get(Type::Int1Ty, !SuccNum);
             break;
           default:
-            brVal = Context.getConstantInt(Type::Int16Ty, SuccNum);
+            brVal = ConstantInt::get(Type::Int16Ty, SuccNum);
             break;
           }
 
           ReturnInst *NTRet = ReturnInst::Create(brVal, NewTarget);
 
           // Update the switch instruction.
-          TheSwitch->addCase(Context.getConstantInt(Type::Int16Ty, SuccNum),
+          TheSwitch->addCase(ConstantInt::get(Type::Int16Ty, SuccNum),
                              OldTarget);
 
           // Restore values just before we exit
@@ -523,7 +523,7 @@
               if (AggregateArgs) {
                 Value *Idx[2];
                 Idx[0] = Context.getNullValue(Type::Int32Ty);
-                Idx[1] = Context.getConstantInt(Type::Int32Ty,FirstOut+out);
+                Idx[1] = ConstantInt::get(Type::Int32Ty,FirstOut+out);
                 GetElementPtrInst *GEP =
                   GetElementPtrInst::Create(OAI, Idx, Idx + 2,
                                             "gep_" + outputs[out]->getName(),

Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Fri Jul 24 18:12:02 2009
@@ -324,14 +324,14 @@
         if (TD == 0)
           Size = Context.getConstantExprSizeOf(AggTy);
         else
-          Size = Context.getConstantInt(Type::Int64Ty,
+          Size = ConstantInt::get(Type::Int64Ty,
                                          TD->getTypeStoreSize(AggTy));
 
         // Always generate a memcpy of alignment 1 here because we don't know
         // the alignment of the src pointer.  Other optimizations can infer
         // better alignment.
         Value *CallArgs[] = {
-          DestCast, SrcCast, Size, Context.getConstantInt(Type::Int32Ty, 1)
+          DestCast, SrcCast, Size, ConstantInt::get(Type::Int32Ty, 1)
         };
         CallInst *TheMemCpy =
           CallInst::Create(MemCpyFn, CallArgs, CallArgs+4, "", TheCall);

Modified: llvm/trunk/lib/Transforms/Utils/LowerAllocations.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LowerAllocations.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LowerAllocations.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LowerAllocations.cpp Fri Jul 24 18:12:02 2009
@@ -118,7 +118,7 @@
       // malloc(type) becomes i8 *malloc(size)
       Value *MallocArg;
       if (LowerMallocArgToInteger)
-        MallocArg = Context.getConstantInt(Type::Int64Ty,
+        MallocArg = ConstantInt::get(Type::Int64Ty,
                                      TD.getTypeAllocSize(AllocTy));
       else
         MallocArg = Context.getConstantExprSizeOf(AllocTy);

Modified: llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp Fri Jul 24 18:12:02 2009
@@ -272,7 +272,7 @@
                                          AllocaInst *InvokeNum,
                                          SwitchInst *CatchSwitch) {
   LLVMContext &Context = II->getContext();
-  ConstantInt *InvokeNoC = Context.getConstantInt(Type::Int32Ty, InvokeNo);
+  ConstantInt *InvokeNoC = ConstantInt::get(Type::Int32Ty, InvokeNo);
 
   // If the unwind edge has phi nodes, split the edge.
   if (isa<PHINode>(II->getUnwindDest()->begin())) {
@@ -483,7 +483,7 @@
 
     std::vector<Value*> Idx;
     Idx.push_back(Context.getNullValue(Type::Int32Ty));
-    Idx.push_back(Context.getConstantInt(Type::Int32Ty, 1));
+    Idx.push_back(ConstantInt::get(Type::Int32Ty, 1));
     OldJmpBufPtr = GetElementPtrInst::Create(JmpBuf, Idx.begin(), Idx.end(),
                                              "OldBuf",
                                               EntryBB->getTerminator());
@@ -504,7 +504,7 @@
     // executing.  For normal calls it contains zero.
     AllocaInst *InvokeNum = new AllocaInst(Type::Int32Ty, 0,
                                            "invokenum",EntryBB->begin());
-    new StoreInst(Context.getConstantInt(Type::Int32Ty, 0), InvokeNum, true,
+    new StoreInst(ConstantInt::get(Type::Int32Ty, 0), InvokeNum, true,
                   EntryBB->getTerminator());
 
     // Insert a load in the Catch block, and a switch on its value.  By default,
@@ -523,7 +523,7 @@
     BasicBlock *ContBlock = EntryBB->splitBasicBlock(EntryBB->getTerminator(),
                                                      "setjmp.cont");
 
-    Idx[1] = Context.getConstantInt(Type::Int32Ty, 0);
+    Idx[1] = ConstantInt::get(Type::Int32Ty, 0);
     Value *JmpBufPtr = GetElementPtrInst::Create(JmpBuf, Idx.begin(), Idx.end(),
                                                  "TheJmpBuf",
                                                  EntryBB->getTerminator());
@@ -577,12 +577,12 @@
   // Get a pointer to the jmpbuf and longjmp.
   std::vector<Value*> Idx;
   Idx.push_back(Context.getNullValue(Type::Int32Ty));
-  Idx.push_back(Context.getConstantInt(Type::Int32Ty, 0));
+  Idx.push_back(ConstantInt::get(Type::Int32Ty, 0));
   Idx[0] = GetElementPtrInst::Create(BufPtr, Idx.begin(), Idx.end(), "JmpBuf",
                                      UnwindBlock);
   Idx[0] = new BitCastInst(Idx[0], PointerType::getUnqual(Type::Int8Ty),
                            "tmp", UnwindBlock);
-  Idx[1] = Context.getConstantInt(Type::Int32Ty, 1);
+  Idx[1] = ConstantInt::get(Type::Int32Ty, 1);
   CallInst::Create(LongJmpFn, Idx.begin(), Idx.end(), "", UnwindBlock);
   new UnreachableInst(UnwindBlock);
 

Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Fri Jul 24 18:12:02 2009
@@ -1611,7 +1611,7 @@
     if (BB->getSinglePredecessor()) {
       // Turn this into a branch on constant.
       bool CondIsTrue = PBI->getSuccessor(0) == BB;
-      BI->setCondition(Context.getConstantInt(Type::Int1Ty, CondIsTrue));
+      BI->setCondition(ConstantInt::get(Type::Int1Ty, CondIsTrue));
       return true;  // Nuke the branch on constant.
     }
     
@@ -1631,7 +1631,7 @@
             PBI->getCondition() == BI->getCondition() &&
             PBI->getSuccessor(0) != PBI->getSuccessor(1)) {
           bool CondIsTrue = PBI->getSuccessor(0) == BB;
-          NewPN->addIncoming(Context.getConstantInt(Type::Int1Ty, 
+          NewPN->addIncoming(ConstantInt::get(Type::Int1Ty, 
                                               CondIsTrue), *PI);
         } else {
           NewPN->addIncoming(BI->getCondition(), *PI);

Modified: llvm/trunk/lib/VMCore/AutoUpgrade.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AutoUpgrade.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/AutoUpgrade.cpp (original)
+++ llvm/trunk/lib/VMCore/AutoUpgrade.cpp Fri Jul 24 18:12:02 2009
@@ -271,20 +271,20 @@
                                   Context.getPointerTypeUnqual(Type::DoubleTy),
                                       "upgraded.", CI);
         Value *Load = new LoadInst(Addr, "upgraded.", false, 8, CI);
-        Value *Idx = Context.getConstantInt(Type::Int32Ty, 0);
+        Value *Idx = ConstantInt::get(Type::Int32Ty, 0);
         Op1 = InsertElementInst::Create(Op1, Load, Idx, "upgraded.", CI);
 
         if (isLoadH) {
-          Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 0));
-          Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 2));
+          Idxs.push_back(ConstantInt::get(Type::Int32Ty, 0));
+          Idxs.push_back(ConstantInt::get(Type::Int32Ty, 2));
         } else {
-          Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 2));
-          Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 1));
+          Idxs.push_back(ConstantInt::get(Type::Int32Ty, 2));
+          Idxs.push_back(ConstantInt::get(Type::Int32Ty, 1));
         }
         Value *Mask = Context.getConstantVector(Idxs);
         SI = new ShuffleVectorInst(Op0, Op1, Mask, "upgraded.", CI);
       } else if (isMovL) {
-        Constant *Zero = Context.getConstantInt(Type::Int32Ty, 0);
+        Constant *Zero = ConstantInt::get(Type::Int32Ty, 0);
         Idxs.push_back(Zero);
         Idxs.push_back(Zero);
         Idxs.push_back(Zero);
@@ -292,32 +292,32 @@
         Value *ZeroV = Context.getConstantVector(Idxs);
 
         Idxs.clear(); 
-        Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 4));
-        Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 5));
-        Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 2));
-        Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 3));
+        Idxs.push_back(ConstantInt::get(Type::Int32Ty, 4));
+        Idxs.push_back(ConstantInt::get(Type::Int32Ty, 5));
+        Idxs.push_back(ConstantInt::get(Type::Int32Ty, 2));
+        Idxs.push_back(ConstantInt::get(Type::Int32Ty, 3));
         Value *Mask = Context.getConstantVector(Idxs);
         SI = new ShuffleVectorInst(ZeroV, Op0, Mask, "upgraded.", CI);
       } else if (isMovSD ||
                  isUnpckhPD || isUnpcklPD || isPunpckhQPD || isPunpcklQPD) {
         Value *Op1 = CI->getOperand(2);
         if (isMovSD) {
-          Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 2));
-          Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 1));
+          Idxs.push_back(ConstantInt::get(Type::Int32Ty, 2));
+          Idxs.push_back(ConstantInt::get(Type::Int32Ty, 1));
         } else if (isUnpckhPD || isPunpckhQPD) {
-          Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 1));
-          Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 3));
+          Idxs.push_back(ConstantInt::get(Type::Int32Ty, 1));
+          Idxs.push_back(ConstantInt::get(Type::Int32Ty, 3));
         } else {
-          Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 0));
-          Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 2));
+          Idxs.push_back(ConstantInt::get(Type::Int32Ty, 0));
+          Idxs.push_back(ConstantInt::get(Type::Int32Ty, 2));
         }
         Value *Mask = Context.getConstantVector(Idxs);
         SI = new ShuffleVectorInst(Op0, Op1, Mask, "upgraded.", CI);
       } else if (isShufPD) {
         Value *Op1 = CI->getOperand(2);
         unsigned MaskVal = cast<ConstantInt>(CI->getOperand(3))->getZExtValue();
-        Idxs.push_back(Context.getConstantInt(Type::Int32Ty, MaskVal & 1));
-        Idxs.push_back(Context.getConstantInt(Type::Int32Ty,
+        Idxs.push_back(ConstantInt::get(Type::Int32Ty, MaskVal & 1));
+        Idxs.push_back(ConstantInt::get(Type::Int32Ty,
                                                ((MaskVal >> 1) & 1)+2));
         Value *Mask = Context.getConstantVector(Idxs);
         SI = new ShuffleVectorInst(Op0, Op1, Mask, "upgraded.", CI);

Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/ConstantFold.cpp (original)
+++ llvm/trunk/lib/VMCore/ConstantFold.cpp Fri Jul 24 18:12:02 2009
@@ -171,7 +171,7 @@
   // Handle ConstantFP input.
   if (const ConstantFP *FP = dyn_cast<ConstantFP>(V))
     // FP -> Integral.
-    return Context.getConstantInt(FP->getValueAPF().bitcastToAPInt());
+    return ConstantInt::get(Context, FP->getValueAPF().bitcastToAPInt());
 
   return 0;
 }
@@ -258,7 +258,7 @@
       (void) V.convertToInteger(x, DestBitWidth, opc==Instruction::FPToSI,
                                 APFloat::rmTowardZero, &ignored);
       APInt Val(DestBitWidth, 2, x);
-      return Context.getConstantInt(Val);
+      return ConstantInt::get(Context, Val);
     }
     return 0; // Can't fold.
   case Instruction::IntToPtr:   //always treated as unsigned
@@ -267,7 +267,7 @@
     return 0;                   // Other pointer types cannot be casted
   case Instruction::PtrToInt:   // always treated as unsigned
     if (V->isNullValue())       // is it a null pointer value?
-      return Context.getConstantInt(DestTy, 0);
+      return ConstantInt::get(DestTy, 0);
     return 0;                   // Other pointer types cannot be casted
   case Instruction::UIToFP:
   case Instruction::SIToFP:
@@ -287,7 +287,7 @@
       uint32_t BitWidth = cast<IntegerType>(DestTy)->getBitWidth();
       APInt Result(CI->getValue());
       Result.zext(BitWidth);
-      return Context.getConstantInt(Result);
+      return ConstantInt::get(Context, Result);
     }
     return 0;
   case Instruction::SExt:
@@ -295,7 +295,7 @@
       uint32_t BitWidth = cast<IntegerType>(DestTy)->getBitWidth();
       APInt Result(CI->getValue());
       Result.sext(BitWidth);
-      return Context.getConstantInt(Result);
+      return ConstantInt::get(Context, Result);
     }
     return 0;
   case Instruction::Trunc:
@@ -303,7 +303,7 @@
       uint32_t BitWidth = cast<IntegerType>(DestTy)->getBitWidth();
       APInt Result(CI->getValue());
       Result.trunc(BitWidth);
-      return Context.getConstantInt(Result);
+      return ConstantInt::get(Context, Result);
     }
     return 0;
   case Instruction::BitCast:
@@ -721,51 +721,51 @@
       default:
         break;
       case Instruction::Add:     
-        return Context.getConstantInt(C1V + C2V);
+        return ConstantInt::get(Context, C1V + C2V);
       case Instruction::Sub:     
-        return Context.getConstantInt(C1V - C2V);
+        return ConstantInt::get(Context, C1V - C2V);
       case Instruction::Mul:     
-        return Context.getConstantInt(C1V * C2V);
+        return ConstantInt::get(Context, C1V * C2V);
       case Instruction::UDiv:
         assert(!CI2->isNullValue() && "Div by zero handled above");
-        return Context.getConstantInt(C1V.udiv(C2V));
+        return ConstantInt::get(Context, C1V.udiv(C2V));
       case Instruction::SDiv:
         assert(!CI2->isNullValue() && "Div by zero handled above");
         if (C2V.isAllOnesValue() && C1V.isMinSignedValue())
           return Context.getUndef(CI1->getType());   // MIN_INT / -1 -> undef
-        return Context.getConstantInt(C1V.sdiv(C2V));
+        return ConstantInt::get(Context, C1V.sdiv(C2V));
       case Instruction::URem:
         assert(!CI2->isNullValue() && "Div by zero handled above");
-        return Context.getConstantInt(C1V.urem(C2V));
+        return ConstantInt::get(Context, C1V.urem(C2V));
       case Instruction::SRem:
         assert(!CI2->isNullValue() && "Div by zero handled above");
         if (C2V.isAllOnesValue() && C1V.isMinSignedValue())
           return Context.getUndef(CI1->getType());   // MIN_INT % -1 -> undef
-        return Context.getConstantInt(C1V.srem(C2V));
+        return ConstantInt::get(Context, C1V.srem(C2V));
       case Instruction::And:
-        return Context.getConstantInt(C1V & C2V);
+        return ConstantInt::get(Context, C1V & C2V);
       case Instruction::Or:
-        return Context.getConstantInt(C1V | C2V);
+        return ConstantInt::get(Context, C1V | C2V);
       case Instruction::Xor:
-        return Context.getConstantInt(C1V ^ C2V);
+        return ConstantInt::get(Context, C1V ^ C2V);
       case Instruction::Shl: {
         uint32_t shiftAmt = C2V.getZExtValue();
         if (shiftAmt < C1V.getBitWidth())
-          return Context.getConstantInt(C1V.shl(shiftAmt));
+          return ConstantInt::get(Context, C1V.shl(shiftAmt));
         else
           return Context.getUndef(C1->getType()); // too big shift is undef
       }
       case Instruction::LShr: {
         uint32_t shiftAmt = C2V.getZExtValue();
         if (shiftAmt < C1V.getBitWidth())
-          return Context.getConstantInt(C1V.lshr(shiftAmt));
+          return ConstantInt::get(Context, C1V.lshr(shiftAmt));
         else
           return Context.getUndef(C1->getType()); // too big shift is undef
       }
       case Instruction::AShr: {
         uint32_t shiftAmt = C2V.getZExtValue();
         if (shiftAmt < C1V.getBitWidth())
-          return Context.getConstantInt(C1V.ashr(shiftAmt));
+          return ConstantInt::get(Context, C1V.ashr(shiftAmt));
         else
           return Context.getUndef(C1->getType()); // too big shift is undef
       }
@@ -1420,25 +1420,25 @@
     switch (pred) {
     default: llvm_unreachable("Invalid ICmp Predicate"); return 0;
     case ICmpInst::ICMP_EQ:
-      return Context.getConstantInt(Type::Int1Ty, V1 == V2);
+      return ConstantInt::get(Type::Int1Ty, V1 == V2);
     case ICmpInst::ICMP_NE: 
-      return Context.getConstantInt(Type::Int1Ty, V1 != V2);
+      return ConstantInt::get(Type::Int1Ty, V1 != V2);
     case ICmpInst::ICMP_SLT:
-      return Context.getConstantInt(Type::Int1Ty, V1.slt(V2));
+      return ConstantInt::get(Type::Int1Ty, V1.slt(V2));
     case ICmpInst::ICMP_SGT:
-      return Context.getConstantInt(Type::Int1Ty, V1.sgt(V2));
+      return ConstantInt::get(Type::Int1Ty, V1.sgt(V2));
     case ICmpInst::ICMP_SLE:
-      return Context.getConstantInt(Type::Int1Ty, V1.sle(V2));
+      return ConstantInt::get(Type::Int1Ty, V1.sle(V2));
     case ICmpInst::ICMP_SGE:
-      return Context.getConstantInt(Type::Int1Ty, V1.sge(V2));
+      return ConstantInt::get(Type::Int1Ty, V1.sge(V2));
     case ICmpInst::ICMP_ULT:
-      return Context.getConstantInt(Type::Int1Ty, V1.ult(V2));
+      return ConstantInt::get(Type::Int1Ty, V1.ult(V2));
     case ICmpInst::ICMP_UGT:
-      return Context.getConstantInt(Type::Int1Ty, V1.ugt(V2));
+      return ConstantInt::get(Type::Int1Ty, V1.ugt(V2));
     case ICmpInst::ICMP_ULE:
-      return Context.getConstantInt(Type::Int1Ty, V1.ule(V2));
+      return ConstantInt::get(Type::Int1Ty, V1.ule(V2));
     case ICmpInst::ICMP_UGE:
-      return Context.getConstantInt(Type::Int1Ty, V1.uge(V2));
+      return ConstantInt::get(Type::Int1Ty, V1.uge(V2));
     }
   } else if (isa<ConstantFP>(C1) && isa<ConstantFP>(C2)) {
     APFloat C1V = cast<ConstantFP>(C1)->getValueAPF();
@@ -1449,38 +1449,38 @@
     case FCmpInst::FCMP_FALSE: return Context.getFalse();
     case FCmpInst::FCMP_TRUE:  return Context.getTrue();
     case FCmpInst::FCMP_UNO:
-      return Context.getConstantInt(Type::Int1Ty, R==APFloat::cmpUnordered);
+      return ConstantInt::get(Type::Int1Ty, R==APFloat::cmpUnordered);
     case FCmpInst::FCMP_ORD:
-      return Context.getConstantInt(Type::Int1Ty, R!=APFloat::cmpUnordered);
+      return ConstantInt::get(Type::Int1Ty, R!=APFloat::cmpUnordered);
     case FCmpInst::FCMP_UEQ:
-      return Context.getConstantInt(Type::Int1Ty, R==APFloat::cmpUnordered ||
+      return ConstantInt::get(Type::Int1Ty, R==APFloat::cmpUnordered ||
                                             R==APFloat::cmpEqual);
     case FCmpInst::FCMP_OEQ:   
-      return Context.getConstantInt(Type::Int1Ty, R==APFloat::cmpEqual);
+      return ConstantInt::get(Type::Int1Ty, R==APFloat::cmpEqual);
     case FCmpInst::FCMP_UNE:
-      return Context.getConstantInt(Type::Int1Ty, R!=APFloat::cmpEqual);
+      return ConstantInt::get(Type::Int1Ty, R!=APFloat::cmpEqual);
     case FCmpInst::FCMP_ONE:   
-      return Context.getConstantInt(Type::Int1Ty, R==APFloat::cmpLessThan ||
+      return ConstantInt::get(Type::Int1Ty, R==APFloat::cmpLessThan ||
                                             R==APFloat::cmpGreaterThan);
     case FCmpInst::FCMP_ULT: 
-      return Context.getConstantInt(Type::Int1Ty, R==APFloat::cmpUnordered ||
+      return ConstantInt::get(Type::Int1Ty, R==APFloat::cmpUnordered ||
                                             R==APFloat::cmpLessThan);
     case FCmpInst::FCMP_OLT:   
-      return Context.getConstantInt(Type::Int1Ty, R==APFloat::cmpLessThan);
+      return ConstantInt::get(Type::Int1Ty, R==APFloat::cmpLessThan);
     case FCmpInst::FCMP_UGT:
-      return Context.getConstantInt(Type::Int1Ty, R==APFloat::cmpUnordered ||
+      return ConstantInt::get(Type::Int1Ty, R==APFloat::cmpUnordered ||
                                             R==APFloat::cmpGreaterThan);
     case FCmpInst::FCMP_OGT:
-      return Context.getConstantInt(Type::Int1Ty, R==APFloat::cmpGreaterThan);
+      return ConstantInt::get(Type::Int1Ty, R==APFloat::cmpGreaterThan);
     case FCmpInst::FCMP_ULE:
-      return Context.getConstantInt(Type::Int1Ty, R!=APFloat::cmpGreaterThan);
+      return ConstantInt::get(Type::Int1Ty, R!=APFloat::cmpGreaterThan);
     case FCmpInst::FCMP_OLE: 
-      return Context.getConstantInt(Type::Int1Ty, R==APFloat::cmpLessThan ||
+      return ConstantInt::get(Type::Int1Ty, R==APFloat::cmpLessThan ||
                                             R==APFloat::cmpEqual);
     case FCmpInst::FCMP_UGE:
-      return Context.getConstantInt(Type::Int1Ty, R!=APFloat::cmpLessThan);
+      return ConstantInt::get(Type::Int1Ty, R!=APFloat::cmpLessThan);
     case FCmpInst::FCMP_OGE: 
-      return Context.getConstantInt(Type::Int1Ty, R==APFloat::cmpGreaterThan ||
+      return ConstantInt::get(Type::Int1Ty, R==APFloat::cmpGreaterThan ||
                                             R==APFloat::cmpEqual);
     }
   } else if (isa<VectorType>(C1->getType())) {
@@ -1555,7 +1555,7 @@
     
     // If we evaluated the result, return it now.
     if (Result != -1)
-      return Context.getConstantInt(Type::Int1Ty, Result);
+      return ConstantInt::get(Type::Int1Ty, Result);
 
   } else {
     // Evaluate the relation between the two constants, per the predicate.
@@ -1632,7 +1632,7 @@
     
     // If we evaluated the result, return it now.
     if (Result != -1)
-      return Context.getConstantInt(Type::Int1Ty, Result);
+      return ConstantInt::get(Type::Int1Ty, Result);
     
     if (!isa<ConstantExpr>(C1) && isa<ConstantExpr>(C2)) {
       // If C2 is a constant expr and C1 isn't, flip them around and fold the

Modified: llvm/trunk/lib/VMCore/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Constants.cpp (original)
+++ llvm/trunk/lib/VMCore/Constants.cpp Fri Jul 24 18:12:02 2009
@@ -11,6 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "LLVMContextImpl.h"
 #include "llvm/Constants.h"
 #include "ConstantFold.h"
 #include "llvm/DerivedTypes.h"
@@ -171,6 +172,72 @@
   assert(V.getBitWidth() == Ty->getBitWidth() && "Invalid constant for type");
 }
 
+// Get a ConstantInt from an APInt. Note that the value stored in the DenseMap 
+// as the key, is a DenseMapAPIntKeyInfo::KeyTy which has provided the
+// operator== and operator!= to ensure that the DenseMap doesn't attempt to
+// compare APInt's of different widths, which would violate an APInt class
+// invariant which generates an assertion.
+ConstantInt *ConstantInt::get(LLVMContext &Context, const APInt& V) {
+  // Get the corresponding integer type for the bit width of the value.
+  const IntegerType *ITy = Context.getIntegerType(V.getBitWidth());
+  // get an existing value or the insertion position
+  DenseMapAPIntKeyInfo::KeyTy Key(V, ITy);
+  
+  Context.pImpl->ConstantsLock.reader_acquire();
+  ConstantInt *&Slot = Context.pImpl->IntConstants[Key]; 
+  Context.pImpl->ConstantsLock.reader_release();
+    
+  if (!Slot) {
+    sys::SmartScopedWriter<true> Writer(Context.pImpl->ConstantsLock);
+    ConstantInt *&NewSlot = Context.pImpl->IntConstants[Key]; 
+    if (!Slot) {
+      NewSlot = new ConstantInt(ITy, V);
+    }
+    
+    return NewSlot;
+  } else {
+    return Slot;
+  }
+}
+
+Constant* ConstantInt::get(const Type* Ty, uint64_t V, bool isSigned) {
+  Constant *C = get(cast<IntegerType>(Ty->getScalarType()),
+                               V, isSigned);
+
+  // For vectors, broadcast the value.
+  if (const VectorType *VTy = dyn_cast<VectorType>(Ty))
+    return Ty->getContext().getConstantVector(
+      std::vector<Constant *>(VTy->getNumElements(), C));
+
+  return C;
+}
+
+ConstantInt* ConstantInt::get(const IntegerType* Ty, uint64_t V, 
+                              bool isSigned) {
+  return get(Ty->getContext(), APInt(Ty->getBitWidth(), V, isSigned));
+}
+
+ConstantInt* ConstantInt::getSigned(const IntegerType* Ty, int64_t V) {
+  return get(Ty, V, true);
+}
+
+Constant *ConstantInt::getSigned(const Type *Ty, int64_t V) {
+  return get(Ty, V, true);
+}
+
+Constant* ConstantInt::get(const Type* Ty, const APInt& V) {
+  ConstantInt *C = get(Ty->getContext(), V);
+  assert(C->getType() == Ty->getScalarType() &&
+         "ConstantInt type doesn't match the type implied by its value!");
+
+  // For vectors, broadcast the value.
+  if (const VectorType *VTy = dyn_cast<VectorType>(Ty))
+    return Ty->getContext().getConstantVector(
+      std::vector<Constant *>(VTy->getNumElements(), C));
+
+  return C;
+}
+
 //===----------------------------------------------------------------------===//
 //                                ConstantFP
 //===----------------------------------------------------------------------===//
@@ -758,275 +825,6 @@
 //===----------------------------------------------------------------------===//
 //                      Factory Function Implementation
 
-
-// The number of operands for each ConstantCreator::create method is
-// determined by the ConstantTraits template.
-// ConstantCreator - A class that is used to create constants by
-// ValueMap*.  This class should be partially specialized if there is
-// something strange that needs to be done to interface to the ctor for the
-// constant.
-//
-namespace llvm {
-  template<class ValType>
-  struct ConstantTraits;
-
-  template<typename T, typename Alloc>
-  struct VISIBILITY_HIDDEN ConstantTraits< std::vector<T, Alloc> > {
-    static unsigned uses(const std::vector<T, Alloc>& v) {
-      return v.size();
-    }
-  };
-
-  template<class ConstantClass, class TypeClass, class ValType>
-  struct VISIBILITY_HIDDEN ConstantCreator {
-    static ConstantClass *create(const TypeClass *Ty, const ValType &V) {
-      return new(ConstantTraits<ValType>::uses(V)) ConstantClass(Ty, V);
-    }
-  };
-
-  template<class ConstantClass, class TypeClass>
-  struct VISIBILITY_HIDDEN ConvertConstantType {
-    static void convert(ConstantClass *OldC, const TypeClass *NewTy) {
-      llvm_unreachable("This type cannot be converted!");
-    }
-  };
-
-  template<class ValType, class TypeClass, class ConstantClass,
-           bool HasLargeKey = false  /*true for arrays and structs*/ >
-  class VISIBILITY_HIDDEN ValueMap : public AbstractTypeUser {
-  public:
-    typedef std::pair<const Type*, ValType> MapKey;
-    typedef std::map<MapKey, Constant *> MapTy;
-    typedef std::map<Constant*, typename MapTy::iterator> InverseMapTy;
-    typedef std::map<const Type*, typename MapTy::iterator> AbstractTypeMapTy;
-  private:
-    /// Map - This is the main map from the element descriptor to the Constants.
-    /// This is the primary way we avoid creating two of the same shape
-    /// constant.
-    MapTy Map;
-    
-    /// InverseMap - If "HasLargeKey" is true, this contains an inverse mapping
-    /// from the constants to their element in Map.  This is important for
-    /// removal of constants from the array, which would otherwise have to scan
-    /// through the map with very large keys.
-    InverseMapTy InverseMap;
-
-    /// AbstractTypeMap - Map for abstract type constants.
-    ///
-    AbstractTypeMapTy AbstractTypeMap;
-    
-    /// ValueMapLock - Mutex for this map.
-    sys::SmartMutex<true> ValueMapLock;
-
-  public:
-    // NOTE: This function is not locked.  It is the caller's responsibility
-    // to enforce proper synchronization.
-    typename MapTy::iterator map_end() { return Map.end(); }
-    
-    /// InsertOrGetItem - Return an iterator for the specified element.
-    /// If the element exists in the map, the returned iterator points to the
-    /// entry and Exists=true.  If not, the iterator points to the newly
-    /// inserted entry and returns Exists=false.  Newly inserted entries have
-    /// I->second == 0, and should be filled in.
-    /// NOTE: This function is not locked.  It is the caller's responsibility
-    // to enforce proper synchronization.
-    typename MapTy::iterator InsertOrGetItem(std::pair<MapKey, Constant *>
-                                   &InsertVal,
-                                   bool &Exists) {
-      std::pair<typename MapTy::iterator, bool> IP = Map.insert(InsertVal);
-      Exists = !IP.second;
-      return IP.first;
-    }
-    
-private:
-    typename MapTy::iterator FindExistingElement(ConstantClass *CP) {
-      if (HasLargeKey) {
-        typename InverseMapTy::iterator IMI = InverseMap.find(CP);
-        assert(IMI != InverseMap.end() && IMI->second != Map.end() &&
-               IMI->second->second == CP &&
-               "InverseMap corrupt!");
-        return IMI->second;
-      }
-      
-      typename MapTy::iterator I =
-        Map.find(MapKey(static_cast<const TypeClass*>(CP->getRawType()),
-                        getValType(CP)));
-      if (I == Map.end() || I->second != CP) {
-        // FIXME: This should not use a linear scan.  If this gets to be a
-        // performance problem, someone should look at this.
-        for (I = Map.begin(); I != Map.end() && I->second != CP; ++I)
-          /* empty */;
-      }
-      return I;
-    }
-    
-    ConstantClass* Create(const TypeClass *Ty, const ValType &V,
-                          typename MapTy::iterator I) {
-      ConstantClass* Result =
-        ConstantCreator<ConstantClass,TypeClass,ValType>::create(Ty, V);
-
-      assert(Result->getType() == Ty && "Type specified is not correct!");
-      I = Map.insert(I, std::make_pair(MapKey(Ty, V), Result));
-
-      if (HasLargeKey)  // Remember the reverse mapping if needed.
-        InverseMap.insert(std::make_pair(Result, I));
-
-      // If the type of the constant is abstract, make sure that an entry
-      // exists for it in the AbstractTypeMap.
-      if (Ty->isAbstract()) {
-        typename AbstractTypeMapTy::iterator TI = 
-                                                 AbstractTypeMap.find(Ty);
-
-        if (TI == AbstractTypeMap.end()) {
-          // Add ourselves to the ATU list of the type.
-          cast<DerivedType>(Ty)->addAbstractTypeUser(this);
-
-          AbstractTypeMap.insert(TI, std::make_pair(Ty, I));
-        }
-      }
-      
-      return Result;
-    }
-public:
-    
-    /// getOrCreate - Return the specified constant from the map, creating it if
-    /// necessary.
-    ConstantClass *getOrCreate(const TypeClass *Ty, const ValType &V) {
-      sys::SmartScopedLock<true> Lock(ValueMapLock);
-      MapKey Lookup(Ty, V);
-      ConstantClass* Result = 0;
-      
-      typename MapTy::iterator I = Map.find(Lookup);
-      // Is it in the map?  
-      if (I != Map.end())
-        Result = static_cast<ConstantClass *>(I->second);
-        
-      if (!Result) {
-        // If no preexisting value, create one now...
-        Result = Create(Ty, V, I);
-      }
-        
-      return Result;
-    }
-
-    void remove(ConstantClass *CP) {
-      sys::SmartScopedLock<true> Lock(ValueMapLock);
-      typename MapTy::iterator I = FindExistingElement(CP);
-      assert(I != Map.end() && "Constant not found in constant table!");
-      assert(I->second == CP && "Didn't find correct element?");
-
-      if (HasLargeKey)  // Remember the reverse mapping if needed.
-        InverseMap.erase(CP);
-      
-      // Now that we found the entry, make sure this isn't the entry that
-      // the AbstractTypeMap points to.
-      const TypeClass *Ty = static_cast<const TypeClass *>(I->first.first);
-      if (Ty->isAbstract()) {
-        assert(AbstractTypeMap.count(Ty) &&
-               "Abstract type not in AbstractTypeMap?");
-        typename MapTy::iterator &ATMEntryIt = AbstractTypeMap[Ty];
-        if (ATMEntryIt == I) {
-          // Yes, we are removing the representative entry for this type.
-          // See if there are any other entries of the same type.
-          typename MapTy::iterator TmpIt = ATMEntryIt;
-
-          // First check the entry before this one...
-          if (TmpIt != Map.begin()) {
-            --TmpIt;
-            if (TmpIt->first.first != Ty) // Not the same type, move back...
-              ++TmpIt;
-          }
-
-          // If we didn't find the same type, try to move forward...
-          if (TmpIt == ATMEntryIt) {
-            ++TmpIt;
-            if (TmpIt == Map.end() || TmpIt->first.first != Ty)
-              --TmpIt;   // No entry afterwards with the same type
-          }
-
-          // If there is another entry in the map of the same abstract type,
-          // update the AbstractTypeMap entry now.
-          if (TmpIt != ATMEntryIt) {
-            ATMEntryIt = TmpIt;
-          } else {
-            // Otherwise, we are removing the last instance of this type
-            // from the table.  Remove from the ATM, and from user list.
-            cast<DerivedType>(Ty)->removeAbstractTypeUser(this);
-            AbstractTypeMap.erase(Ty);
-          }
-        }
-      }
-
-      Map.erase(I);
-    }
-
-    
-    /// MoveConstantToNewSlot - If we are about to change C to be the element
-    /// specified by I, update our internal data structures to reflect this
-    /// fact.
-    /// NOTE: This function is not locked. It is the responsibility of the
-    /// caller to enforce proper synchronization if using this method.
-    void MoveConstantToNewSlot(ConstantClass *C, typename MapTy::iterator I) {
-      // First, remove the old location of the specified constant in the map.
-      typename MapTy::iterator OldI = FindExistingElement(C);
-      assert(OldI != Map.end() && "Constant not found in constant table!");
-      assert(OldI->second == C && "Didn't find correct element?");
-      
-      // If this constant is the representative element for its abstract type,
-      // update the AbstractTypeMap so that the representative element is I.
-      if (C->getType()->isAbstract()) {
-        typename AbstractTypeMapTy::iterator ATI =
-            AbstractTypeMap.find(C->getType());
-        assert(ATI != AbstractTypeMap.end() &&
-               "Abstract type not in AbstractTypeMap?");
-        if (ATI->second == OldI)
-          ATI->second = I;
-      }
-      
-      // Remove the old entry from the map.
-      Map.erase(OldI);
-      
-      // Update the inverse map so that we know that this constant is now
-      // located at descriptor I.
-      if (HasLargeKey) {
-        assert(I->second == C && "Bad inversemap entry!");
-        InverseMap[C] = I;
-      }
-    }
-    
-    void refineAbstractType(const DerivedType *OldTy, const Type *NewTy) {
-      sys::SmartScopedLock<true> Lock(ValueMapLock);
-      typename AbstractTypeMapTy::iterator I =
-        AbstractTypeMap.find(cast<Type>(OldTy));
-
-      assert(I != AbstractTypeMap.end() &&
-             "Abstract type not in AbstractTypeMap?");
-
-      // Convert a constant at a time until the last one is gone.  The last one
-      // leaving will remove() itself, causing the AbstractTypeMapEntry to be
-      // eliminated eventually.
-      do {
-        ConvertConstantType<ConstantClass,
-                            TypeClass>::convert(
-                                static_cast<ConstantClass *>(I->second->second),
-                                                cast<TypeClass>(NewTy));
-
-        I = AbstractTypeMap.find(cast<Type>(OldTy));
-      } while (I != AbstractTypeMap.end());
-    }
-
-    // If the type became concrete without being refined to any other existing
-    // type, we just remove ourselves from the ATU list.
-    void typeBecameConcrete(const DerivedType *AbsTy) {
-      AbsTy->removeAbstractTypeUser(this);
-    }
-
-    void dump() const {
-      DOUT << "Constant.cpp: ValueMap\n";
-    }
-  };
-}
-
 /// destroyConstant - Remove the constant from the constant table...
 ///
 void ConstantAggregateZero::destroyConstant() {

Modified: llvm/trunk/lib/VMCore/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Core.cpp (original)
+++ llvm/trunk/lib/VMCore/Core.cpp Fri Jul 24 18:12:02 2009
@@ -365,8 +365,7 @@
 
 LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
                           int SignExtend) {
-  return wrap(getGlobalContext().getConstantInt(unwrap<IntegerType>(IntTy), N,
-                                                 SignExtend != 0));
+  return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), N, SignExtend != 0));
 }
 
 static const fltSemantics &SemanticsForType(Type *Ty) {

Modified: llvm/trunk/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Fri Jul 24 18:12:02 2009
@@ -704,7 +704,7 @@
 
 static Value *getAISize(LLVMContext &Context, Value *Amt) {
   if (!Amt)
-    Amt = Context.getConstantInt(Type::Int32Ty, 1);
+    Amt = ConstantInt::get(Type::Int32Ty, 1);
   else {
     assert(!isa<BasicBlock>(Amt) &&
            "Passed basic block into allocation size parameter! Use other ctor");

Modified: llvm/trunk/lib/VMCore/LLVMContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContext.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/LLVMContext.cpp (original)
+++ llvm/trunk/lib/VMCore/LLVMContext.cpp Fri Jul 24 18:12:02 2009
@@ -39,7 +39,7 @@
 Constant* LLVMContext::getNullValue(const Type* Ty) {
   switch (Ty->getTypeID()) {
   case Type::IntegerTyID:
-    return getConstantInt(Ty, 0);
+    return ConstantInt::get(Ty, 0);
   case Type::FloatTyID:
     return getConstantFP(APFloat(APInt(32, 0)));
   case Type::DoubleTyID:
@@ -65,7 +65,7 @@
 
 Constant* LLVMContext::getAllOnesValue(const Type* Ty) {
   if (const IntegerType* ITy = dyn_cast<IntegerType>(Ty))
-    return getConstantInt(APInt::getAllOnesValue(ITy->getBitWidth()));
+    return ConstantInt::get(*this, APInt::getAllOnesValue(ITy->getBitWidth()));
   
   std::vector<Constant*> Elts;
   const VectorType* VTy = cast<VectorType>(Ty);
@@ -92,51 +92,6 @@
   return pImpl->getFalse();
 }
 
-Constant* LLVMContext::getConstantInt(const Type* Ty, uint64_t V,
-                                         bool isSigned) {
-  Constant *C = getConstantInt(cast<IntegerType>(Ty->getScalarType()),
-                               V, isSigned);
-
-  // For vectors, broadcast the value.
-  if (const VectorType *VTy = dyn_cast<VectorType>(Ty))
-    return
-      getConstantVector(std::vector<Constant *>(VTy->getNumElements(), C));
-
-  return C;
-}
-
-
-ConstantInt* LLVMContext::getConstantInt(const IntegerType* Ty, uint64_t V,
-                                         bool isSigned) {
-  return getConstantInt(APInt(Ty->getBitWidth(), V, isSigned));
-}
-
-ConstantInt* LLVMContext::getConstantIntSigned(const IntegerType* Ty,
-                                               int64_t V) {
-  return getConstantInt(Ty, V, true);
-}
-
-Constant *LLVMContext::getConstantIntSigned(const Type *Ty, int64_t V) {
-  return getConstantInt(Ty, V, true);
-}
-
-ConstantInt* LLVMContext::getConstantInt(const APInt& V) {
-  return pImpl->getConstantInt(V);
-}
-
-Constant* LLVMContext::getConstantInt(const Type* Ty, const APInt& V) {
-  ConstantInt *C = getConstantInt(V);
-  assert(C->getType() == Ty->getScalarType() &&
-         "ConstantInt type doesn't match the type implied by its value!");
-
-  // For vectors, broadcast the value.
-  if (const VectorType *VTy = dyn_cast<VectorType>(Ty))
-    return
-      getConstantVector(std::vector<Constant *>(VTy->getNumElements(), C));
-
-  return C;
-}
-
 // ConstantPointerNull accessors.
 ConstantPointerNull* LLVMContext::getConstantPointerNull(const PointerType* T) {
   return ConstantPointerNull::get(T);
@@ -194,11 +149,11 @@
                                         bool AddNull) {
   std::vector<Constant*> ElementVals;
   for (unsigned i = 0; i < Str.length(); ++i)
-    ElementVals.push_back(getConstantInt(Type::Int8Ty, Str[i]));
+    ElementVals.push_back(ConstantInt::get(Type::Int8Ty, Str[i]));
 
   // Add a null terminator to the string...
   if (AddNull) {
-    ElementVals.push_back(getConstantInt(Type::Int8Ty, 0));
+    ElementVals.push_back(ConstantInt::get(Type::Int8Ty, 0));
   }
 
   ArrayType *ATy = getArrayType(Type::Int8Ty, ElementVals.size());
@@ -302,8 +257,8 @@
   // alignof is implemented as: (i64) gep ({i8,Ty}*)null, 0, 1
   const Type *AligningTy = getStructType(Type::Int8Ty, Ty, NULL);
   Constant *NullPtr = getNullValue(AligningTy->getPointerTo());
-  Constant *Zero = getConstantInt(Type::Int32Ty, 0);
-  Constant *One = getConstantInt(Type::Int32Ty, 1);
+  Constant *Zero = ConstantInt::get(Type::Int32Ty, 0);
+  Constant *One = ConstantInt::get(Type::Int32Ty, 1);
   Constant *Indices[2] = { Zero, One };
   Constant *GEP = getConstantExprGetElementPtr(NullPtr, Indices, 2);
   return getConstantExprCast(Instruction::PtrToInt, GEP, Type::Int32Ty);
@@ -463,7 +418,7 @@
 
 Constant* LLVMContext::getConstantExprSizeOf(const Type* Ty) {
   // sizeof is implemented as: (i64) gep (Ty*)null, 1
-  Constant *GEPIdx = getConstantInt(Type::Int32Ty, 1);
+  Constant *GEPIdx = ConstantInt::get(Type::Int32Ty, 1);
   Constant *GEP = getConstantExprGetElementPtr(
                             getNullValue(getPointerTypeUnqual(Ty)), &GEPIdx, 1);
   return getConstantExprCast(Instruction::PtrToInt, GEP, Type::Int64Ty);

Modified: llvm/trunk/lib/VMCore/LLVMContextImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContextImpl.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/LLVMContextImpl.cpp (original)
+++ llvm/trunk/lib/VMCore/LLVMContextImpl.cpp Fri Jul 24 18:12:02 2009
@@ -45,368 +45,10 @@
   return Elements;
 }
 
-namespace llvm {
-template<typename T, typename Alloc>
-struct VISIBILITY_HIDDEN ConstantTraits< std::vector<T, Alloc> > {
-  static unsigned uses(const std::vector<T, Alloc>& v) {
-    return v.size();
-  }
-};
-
-template<class ConstantClass, class TypeClass, class ValType>
-struct VISIBILITY_HIDDEN ConstantCreator {
-  static ConstantClass *create(const TypeClass *Ty, const ValType &V) {
-    return new(ConstantTraits<ValType>::uses(V)) ConstantClass(Ty, V);
-  }
-};
-
-template<class ConstantClass, class TypeClass>
-struct VISIBILITY_HIDDEN ConvertConstantType {
-  static void convert(ConstantClass *OldC, const TypeClass *NewTy) {
-    llvm_unreachable("This type cannot be converted!");
-  }
-};
-
-// ConstantAggregateZero does not take extra "value" argument...
-template<class ValType>
-struct ConstantCreator<ConstantAggregateZero, Type, ValType> {
-  static ConstantAggregateZero *create(const Type *Ty, const ValType &V){
-    return new ConstantAggregateZero(Ty);
-  }
-};
-
-template<>
-struct ConvertConstantType<ConstantAggregateZero, Type> {
-  static void convert(ConstantAggregateZero *OldC, const Type *NewTy) {
-    // Make everyone now use a constant of the new type...
-    Constant *New = NewTy->getContext().getConstantAggregateZero(NewTy);
-    assert(New != OldC && "Didn't replace constant??");
-    OldC->uncheckedReplaceAllUsesWith(New);
-    OldC->destroyConstant();     // This constant is now dead, destroy it.
-  }
-};
-
-template<>
-struct ConvertConstantType<ConstantArray, ArrayType> {
-  static void convert(ConstantArray *OldC, const ArrayType *NewTy) {
-    // Make everyone now use a constant of the new type...
-    std::vector<Constant*> C;
-    for (unsigned i = 0, e = OldC->getNumOperands(); i != e; ++i)
-      C.push_back(cast<Constant>(OldC->getOperand(i)));
-    Constant *New = NewTy->getContext().getConstantArray(NewTy, C);
-    assert(New != OldC && "Didn't replace constant??");
-    OldC->uncheckedReplaceAllUsesWith(New);
-    OldC->destroyConstant();    // This constant is now dead, destroy it.
-  }
-};
-
-template<>
-struct ConvertConstantType<ConstantStruct, StructType> {
-  static void convert(ConstantStruct *OldC, const StructType *NewTy) {
-    // Make everyone now use a constant of the new type...
-    std::vector<Constant*> C;
-    for (unsigned i = 0, e = OldC->getNumOperands(); i != e; ++i)
-      C.push_back(cast<Constant>(OldC->getOperand(i)));
-    Constant *New = NewTy->getContext().getConstantStruct(NewTy, C);
-    assert(New != OldC && "Didn't replace constant??");
-
-    OldC->uncheckedReplaceAllUsesWith(New);
-    OldC->destroyConstant();    // This constant is now dead, destroy it.
-  }
-};
-
-template<>
-struct ConvertConstantType<ConstantVector, VectorType> {
-  static void convert(ConstantVector *OldC, const VectorType *NewTy) {
-    // Make everyone now use a constant of the new type...
-    std::vector<Constant*> C;
-    for (unsigned i = 0, e = OldC->getNumOperands(); i != e; ++i)
-      C.push_back(cast<Constant>(OldC->getOperand(i)));
-    Constant *New = OldC->getContext().getConstantVector(NewTy, C);
-    assert(New != OldC && "Didn't replace constant??");
-    OldC->uncheckedReplaceAllUsesWith(New);
-    OldC->destroyConstant();    // This constant is now dead, destroy it.
-  }
-};
-}
-  
-template<class ValType, class TypeClass, class ConstantClass,
-         bool HasLargeKey  /*true for arrays and structs*/ >
-class VISIBILITY_HIDDEN ValueMap : public AbstractTypeUser {
-public:
-  typedef std::pair<const Type*, ValType> MapKey;
-  typedef std::map<MapKey, Constant *> MapTy;
-  typedef std::map<Constant*, typename MapTy::iterator> InverseMapTy;
-  typedef std::map<const Type*, typename MapTy::iterator> AbstractTypeMapTy;
-private:
-  /// Map - This is the main map from the element descriptor to the Constants.
-  /// This is the primary way we avoid creating two of the same shape
-  /// constant.
-  MapTy Map;
-    
-  /// InverseMap - If "HasLargeKey" is true, this contains an inverse mapping
-  /// from the constants to their element in Map.  This is important for
-  /// removal of constants from the array, which would otherwise have to scan
-  /// through the map with very large keys.
-  InverseMapTy InverseMap;
-
-  /// AbstractTypeMap - Map for abstract type constants.
-  ///
-  AbstractTypeMapTy AbstractTypeMap;
-    
-  /// ValueMapLock - Mutex for this map.
-  sys::SmartMutex<true> ValueMapLock;
-
-public:
-  // NOTE: This function is not locked.  It is the caller's responsibility
-  // to enforce proper synchronization.
-  typename MapTy::iterator map_end() { return Map.end(); }
-    
-  /// InsertOrGetItem - Return an iterator for the specified element.
-  /// If the element exists in the map, the returned iterator points to the
-  /// entry and Exists=true.  If not, the iterator points to the newly
-  /// inserted entry and returns Exists=false.  Newly inserted entries have
-  /// I->second == 0, and should be filled in.
-  /// NOTE: This function is not locked.  It is the caller's responsibility
-  // to enforce proper synchronization.
-  typename MapTy::iterator InsertOrGetItem(std::pair<MapKey, Constant *>
-                                 &InsertVal,
-                                 bool &Exists) {
-    std::pair<typename MapTy::iterator, bool> IP = Map.insert(InsertVal);
-    Exists = !IP.second;
-    return IP.first;
-  }
-    
-private:
-  typename MapTy::iterator FindExistingElement(ConstantClass *CP) {
-    if (HasLargeKey) {
-      typename InverseMapTy::iterator IMI = InverseMap.find(CP);
-      assert(IMI != InverseMap.end() && IMI->second != Map.end() &&
-             IMI->second->second == CP &&
-             "InverseMap corrupt!");
-      return IMI->second;
-    }
-      
-    typename MapTy::iterator I =
-      Map.find(MapKey(static_cast<const TypeClass*>(CP->getRawType()),
-                      getValType(CP)));
-    if (I == Map.end() || I->second != CP) {
-      // FIXME: This should not use a linear scan.  If this gets to be a
-      // performance problem, someone should look at this.
-      for (I = Map.begin(); I != Map.end() && I->second != CP; ++I)
-        /* empty */;
-    }
-    return I;
-  }
-    
-  ConstantClass* Create(const TypeClass *Ty, const ValType &V,
-                        typename MapTy::iterator I) {
-    ConstantClass* Result =
-      ConstantCreator<ConstantClass,TypeClass,ValType>::create(Ty, V);
-
-    assert(Result->getType() == Ty && "Type specified is not correct!");
-    I = Map.insert(I, std::make_pair(MapKey(Ty, V), Result));
-
-    if (HasLargeKey)  // Remember the reverse mapping if needed.
-      InverseMap.insert(std::make_pair(Result, I));
-
-    // If the type of the constant is abstract, make sure that an entry
-    // exists for it in the AbstractTypeMap.
-    if (Ty->isAbstract()) {
-      typename AbstractTypeMapTy::iterator TI = 
-                                               AbstractTypeMap.find(Ty);
-
-      if (TI == AbstractTypeMap.end()) {
-        // Add ourselves to the ATU list of the type.
-        cast<DerivedType>(Ty)->addAbstractTypeUser(this);
-
-        AbstractTypeMap.insert(TI, std::make_pair(Ty, I));
-      }
-    }
-      
-    return Result;
-  }
-public:
-    
-  /// getOrCreate - Return the specified constant from the map, creating it if
-  /// necessary.
-  ConstantClass *getOrCreate(const TypeClass *Ty, const ValType &V) {
-    sys::SmartScopedLock<true> Lock(ValueMapLock);
-    MapKey Lookup(Ty, V);
-    ConstantClass* Result = 0;
-    
-    typename MapTy::iterator I = Map.find(Lookup);
-    // Is it in the map?  
-    if (I != Map.end())
-      Result = static_cast<ConstantClass *>(I->second);
-        
-    if (!Result) {
-      // If no preexisting value, create one now...
-      Result = Create(Ty, V, I);
-    }
-        
-    return Result;
-  }
-
-  void remove(ConstantClass *CP) {
-    sys::SmartScopedLock<true> Lock(ValueMapLock);
-    typename MapTy::iterator I = FindExistingElement(CP);
-    assert(I != Map.end() && "Constant not found in constant table!");
-    assert(I->second == CP && "Didn't find correct element?");
-
-    if (HasLargeKey)  // Remember the reverse mapping if needed.
-      InverseMap.erase(CP);
-      
-    // Now that we found the entry, make sure this isn't the entry that
-    // the AbstractTypeMap points to.
-    const TypeClass *Ty = static_cast<const TypeClass *>(I->first.first);
-    if (Ty->isAbstract()) {
-      assert(AbstractTypeMap.count(Ty) &&
-             "Abstract type not in AbstractTypeMap?");
-      typename MapTy::iterator &ATMEntryIt = AbstractTypeMap[Ty];
-      if (ATMEntryIt == I) {
-        // Yes, we are removing the representative entry for this type.
-        // See if there are any other entries of the same type.
-        typename MapTy::iterator TmpIt = ATMEntryIt;
-
-        // First check the entry before this one...
-        if (TmpIt != Map.begin()) {
-          --TmpIt;
-          if (TmpIt->first.first != Ty) // Not the same type, move back...
-            ++TmpIt;
-        }
-
-        // If we didn't find the same type, try to move forward...
-        if (TmpIt == ATMEntryIt) {
-          ++TmpIt;
-          if (TmpIt == Map.end() || TmpIt->first.first != Ty)
-            --TmpIt;   // No entry afterwards with the same type
-        }
-
-        // If there is another entry in the map of the same abstract type,
-        // update the AbstractTypeMap entry now.
-        if (TmpIt != ATMEntryIt) {
-          ATMEntryIt = TmpIt;
-        } else {
-          // Otherwise, we are removing the last instance of this type
-          // from the table.  Remove from the ATM, and from user list.
-          cast<DerivedType>(Ty)->removeAbstractTypeUser(this);
-          AbstractTypeMap.erase(Ty);
-        }
-      }
-    }
-
-    Map.erase(I);
-  }
-
-    
-  /// MoveConstantToNewSlot - If we are about to change C to be the element
-  /// specified by I, update our internal data structures to reflect this
-  /// fact.
-  /// NOTE: This function is not locked. It is the responsibility of the
-  /// caller to enforce proper synchronization if using this method.
-  void MoveConstantToNewSlot(ConstantClass *C, typename MapTy::iterator I) {
-    // First, remove the old location of the specified constant in the map.
-    typename MapTy::iterator OldI = FindExistingElement(C);
-    assert(OldI != Map.end() && "Constant not found in constant table!");
-    assert(OldI->second == C && "Didn't find correct element?");
-      
-    // If this constant is the representative element for its abstract type,
-    // update the AbstractTypeMap so that the representative element is I.
-    if (C->getType()->isAbstract()) {
-      typename AbstractTypeMapTy::iterator ATI =
-          AbstractTypeMap.find(C->getType());
-      assert(ATI != AbstractTypeMap.end() &&
-             "Abstract type not in AbstractTypeMap?");
-      if (ATI->second == OldI)
-        ATI->second = I;
-    }
-      
-    // Remove the old entry from the map.
-    Map.erase(OldI);
-    
-    // Update the inverse map so that we know that this constant is now
-    // located at descriptor I.
-    if (HasLargeKey) {
-      assert(I->second == C && "Bad inversemap entry!");
-      InverseMap[C] = I;
-    }
-  }
-    
-  void refineAbstractType(const DerivedType *OldTy, const Type *NewTy) {
-    sys::SmartScopedLock<true> Lock(ValueMapLock);
-    typename AbstractTypeMapTy::iterator I =
-      AbstractTypeMap.find(cast<Type>(OldTy));
-
-    assert(I != AbstractTypeMap.end() &&
-           "Abstract type not in AbstractTypeMap?");
-
-    // Convert a constant at a time until the last one is gone.  The last one
-    // leaving will remove() itself, causing the AbstractTypeMapEntry to be
-    // eliminated eventually.
-    do {
-      ConvertConstantType<ConstantClass,
-                          TypeClass>::convert(
-                              static_cast<ConstantClass *>(I->second->second),
-                                              cast<TypeClass>(NewTy));
-
-      I = AbstractTypeMap.find(cast<Type>(OldTy));
-    } while (I != AbstractTypeMap.end());
-  }
-
-  // If the type became concrete without being refined to any other existing
-  // type, we just remove ourselves from the ATU list.
-  void typeBecameConcrete(const DerivedType *AbsTy) {
-    AbsTy->removeAbstractTypeUser(this);
-  }
-
-  void dump() const {
-    DOUT << "Constant.cpp: ValueMap\n";
-  }
-};
 
 LLVMContextImpl::LLVMContextImpl(LLVMContext &C) :
-    Context(C), TheTrueVal(0), TheFalseVal(0) {
-  AggZeroConstants = new ValueMap<char, Type, ConstantAggregateZero>();
-  ArrayConstants = new ArrayConstantsTy();
-  StructConstants = new StructConstantsTy();
-  VectorConstants = new VectorConstantsTy();
-}
-
-LLVMContextImpl::~LLVMContextImpl() {
-  delete AggZeroConstants;
-  delete ArrayConstants;
-  delete StructConstants;
-  delete VectorConstants;
-}
-
-// Get a ConstantInt from an APInt. Note that the value stored in the DenseMap 
-// as the key, is a DenseMapAPIntKeyInfo::KeyTy which has provided the
-// operator== and operator!= to ensure that the DenseMap doesn't attempt to
-// compare APInt's of different widths, which would violate an APInt class
-// invariant which generates an assertion.
-ConstantInt *LLVMContextImpl::getConstantInt(const APInt& V) {
-  // Get the corresponding integer type for the bit width of the value.
-  const IntegerType *ITy = Context.getIntegerType(V.getBitWidth());
-  // get an existing value or the insertion position
-  DenseMapAPIntKeyInfo::KeyTy Key(V, ITy);
-  
-  ConstantsLock.reader_acquire();
-  ConstantInt *&Slot = IntConstants[Key]; 
-  ConstantsLock.reader_release();
-    
-  if (!Slot) {
-    sys::SmartScopedWriter<true> Writer(ConstantsLock);
-    ConstantInt *&NewSlot = IntConstants[Key]; 
-    if (!Slot) {
-      NewSlot = new ConstantInt(ITy, V);
-    }
-    
-    return NewSlot;
-  } else {
-    return Slot;
-  }
-}
+    Context(C), TheTrueVal(0), TheFalseVal(0) { }
+
 
 ConstantFP *LLVMContextImpl::getConstantFP(const APFloat &V) {
   DenseMapAPFloatKeyInfo::KeyTy Key(V);
@@ -483,7 +125,7 @@
          "Cannot create an aggregate zero of non-aggregate type!");
 
   // Implicitly locked.
-  return AggZeroConstants->getOrCreate(Ty, 0);
+  return AggZeroConstants.getOrCreate(Ty, 0);
 }
 
 Constant *LLVMContextImpl::getConstantArray(const ArrayType *Ty,
@@ -493,12 +135,12 @@
     Constant *C = V[0];
     if (!C->isNullValue()) {
       // Implicitly locked.
-      return ArrayConstants->getOrCreate(Ty, V);
+      return ArrayConstants.getOrCreate(Ty, V);
     }
     for (unsigned i = 1, e = V.size(); i != e; ++i)
       if (V[i] != C) {
         // Implicitly locked.
-        return ArrayConstants->getOrCreate(Ty, V);
+        return ArrayConstants.getOrCreate(Ty, V);
       }
   }
   
@@ -511,7 +153,7 @@
   for (unsigned i = 0, e = V.size(); i != e; ++i)
     if (!V[i]->isNullValue())
       // Implicitly locked.
-      return StructConstants->getOrCreate(Ty, V);
+      return StructConstants.getOrCreate(Ty, V);
 
   return Context.getConstantAggregateZero(Ty);
 }
@@ -539,7 +181,7 @@
     return Context.getUndef(Ty);
     
   // Implicitly locked.
-  return VectorConstants->getOrCreate(Ty, V);
+  return VectorConstants.getOrCreate(Ty, V);
 }
 
 // *** erase methods ***
@@ -556,19 +198,19 @@
 }
 
 void LLVMContextImpl::erase(ConstantAggregateZero *Z) {
-  AggZeroConstants->remove(Z);
+  AggZeroConstants.remove(Z);
 }
 
 void LLVMContextImpl::erase(ConstantArray *C) {
-  ArrayConstants->remove(C);
+  ArrayConstants.remove(C);
 }
 
 void LLVMContextImpl::erase(ConstantStruct *S) {
-  StructConstants->remove(S);
+  StructConstants.remove(S);
 }
 
 void LLVMContextImpl::erase(ConstantVector *V) {
-  VectorConstants->remove(V);
+  VectorConstants.remove(V);
 }
 
 // *** RAUW helpers ***
@@ -621,7 +263,7 @@
     sys::SmartScopedWriter<true> Writer(ConstantsLock);
     bool Exists;
     ArrayConstantsTy::MapTy::iterator I =
-      ArrayConstants->InsertOrGetItem(Lookup, Exists);
+      ArrayConstants.InsertOrGetItem(Lookup, Exists);
     
     if (Exists) {
       Replacement = I->second;
@@ -630,7 +272,7 @@
       // creating a new constant array, inserting it, replaceallusesof'ing the
       // old with the new, then deleting the old... just update the current one
       // in place!
-      ArrayConstants->MoveConstantToNewSlot(CA, I);
+      ArrayConstants.MoveConstantToNewSlot(CA, I);
       
       // Update to the new value.  Optimize for the case when we have a single
       // operand that we're changing, but handle bulk updates efficiently.
@@ -693,7 +335,7 @@
     sys::SmartScopedWriter<true> Writer(ConstantsLock);
     bool Exists;
     StructConstantsTy::MapTy::iterator I =
-      StructConstants->InsertOrGetItem(Lookup, Exists);
+      StructConstants.InsertOrGetItem(Lookup, Exists);
     
     if (Exists) {
       Replacement = I->second;
@@ -702,7 +344,7 @@
       // creating a new constant struct, inserting it, replaceallusesof'ing the
       // old with the new, then deleting the old... just update the current one
       // in place!
-      StructConstants->MoveConstantToNewSlot(CS, I);
+      StructConstants.MoveConstantToNewSlot(CS, I);
       
       // Update to the new value.
       CS->setOperand(OperandToUpdate, ToC);

Modified: llvm/trunk/lib/VMCore/LLVMContextImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContextImpl.h?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/LLVMContextImpl.h (original)
+++ llvm/trunk/lib/VMCore/LLVMContextImpl.h Fri Jul 24 18:12:02 2009
@@ -16,6 +16,7 @@
 #define LLVM_LLVMCONTEXT_IMPL_H
 
 #include "llvm/LLVMContext.h"
+#include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -29,14 +30,336 @@
 #include <map>
 #include <vector>
 
-template<class ValType, class TypeClass, class ConstantClass,
-         bool HasLargeKey = false  /*true for arrays and structs*/ >
-class ValueMap;
-
 namespace llvm {
 template<class ValType>
 struct ConstantTraits;
 
+// The number of operands for each ConstantCreator::create method is
+// determined by the ConstantTraits template.
+// ConstantCreator - A class that is used to create constants by
+// ValueMap*.  This class should be partially specialized if there is
+// something strange that needs to be done to interface to the ctor for the
+// constant.
+//
+template<typename T, typename Alloc>
+struct VISIBILITY_HIDDEN ConstantTraits< std::vector<T, Alloc> > {
+  static unsigned uses(const std::vector<T, Alloc>& v) {
+    return v.size();
+  }
+};
+
+template<class ConstantClass, class TypeClass, class ValType>
+struct VISIBILITY_HIDDEN ConstantCreator {
+  static ConstantClass *create(const TypeClass *Ty, const ValType &V) {
+    return new(ConstantTraits<ValType>::uses(V)) ConstantClass(Ty, V);
+  }
+};
+
+template<class ConstantClass, class TypeClass>
+struct VISIBILITY_HIDDEN ConvertConstantType {
+  static void convert(ConstantClass *OldC, const TypeClass *NewTy) {
+    llvm_unreachable("This type cannot be converted!");
+  }
+};
+
+// ConstantAggregateZero does not take extra "value" argument...
+template<class ValType>
+struct ConstantCreator<ConstantAggregateZero, Type, ValType> {
+  static ConstantAggregateZero *create(const Type *Ty, const ValType &V){
+    return new ConstantAggregateZero(Ty);
+  }
+};
+
+template<>
+struct ConvertConstantType<ConstantAggregateZero, Type> {
+  static void convert(ConstantAggregateZero *OldC, const Type *NewTy) {
+    // Make everyone now use a constant of the new type...
+    Constant *New = NewTy->getContext().getConstantAggregateZero(NewTy);
+    assert(New != OldC && "Didn't replace constant??");
+    OldC->uncheckedReplaceAllUsesWith(New);
+    OldC->destroyConstant();     // This constant is now dead, destroy it.
+  }
+};
+
+template<>
+struct ConvertConstantType<ConstantArray, ArrayType> {
+  static void convert(ConstantArray *OldC, const ArrayType *NewTy) {
+    // Make everyone now use a constant of the new type...
+    std::vector<Constant*> C;
+    for (unsigned i = 0, e = OldC->getNumOperands(); i != e; ++i)
+      C.push_back(cast<Constant>(OldC->getOperand(i)));
+    Constant *New = NewTy->getContext().getConstantArray(NewTy, C);
+    assert(New != OldC && "Didn't replace constant??");
+    OldC->uncheckedReplaceAllUsesWith(New);
+    OldC->destroyConstant();    // This constant is now dead, destroy it.
+  }
+};
+
+template<>
+struct ConvertConstantType<ConstantStruct, StructType> {
+  static void convert(ConstantStruct *OldC, const StructType *NewTy) {
+    // Make everyone now use a constant of the new type...
+    std::vector<Constant*> C;
+    for (unsigned i = 0, e = OldC->getNumOperands(); i != e; ++i)
+      C.push_back(cast<Constant>(OldC->getOperand(i)));
+    Constant *New = NewTy->getContext().getConstantStruct(NewTy, C);
+    assert(New != OldC && "Didn't replace constant??");
+
+    OldC->uncheckedReplaceAllUsesWith(New);
+    OldC->destroyConstant();    // This constant is now dead, destroy it.
+  }
+};
+
+template<>
+struct ConvertConstantType<ConstantVector, VectorType> {
+  static void convert(ConstantVector *OldC, const VectorType *NewTy) {
+    // Make everyone now use a constant of the new type...
+    std::vector<Constant*> C;
+    for (unsigned i = 0, e = OldC->getNumOperands(); i != e; ++i)
+      C.push_back(cast<Constant>(OldC->getOperand(i)));
+    Constant *New = OldC->getContext().getConstantVector(NewTy, C);
+    assert(New != OldC && "Didn't replace constant??");
+    OldC->uncheckedReplaceAllUsesWith(New);
+    OldC->destroyConstant();    // This constant is now dead, destroy it.
+  }
+};
+
+template<class ValType, class TypeClass, class ConstantClass,
+         bool HasLargeKey = false /*true for arrays and structs*/ >
+class ValueMap : public AbstractTypeUser {
+public:
+  typedef std::pair<const Type*, ValType> MapKey;
+  typedef std::map<MapKey, Constant *> MapTy;
+  typedef std::map<Constant*, typename MapTy::iterator> InverseMapTy;
+  typedef std::map<const Type*, typename MapTy::iterator> AbstractTypeMapTy;
+private:
+  /// Map - This is the main map from the element descriptor to the Constants.
+  /// This is the primary way we avoid creating two of the same shape
+  /// constant.
+  MapTy Map;
+    
+  /// InverseMap - If "HasLargeKey" is true, this contains an inverse mapping
+  /// from the constants to their element in Map.  This is important for
+  /// removal of constants from the array, which would otherwise have to scan
+  /// through the map with very large keys.
+  InverseMapTy InverseMap;
+
+  /// AbstractTypeMap - Map for abstract type constants.
+  ///
+  AbstractTypeMapTy AbstractTypeMap;
+    
+  /// ValueMapLock - Mutex for this map.
+  sys::SmartMutex<true> ValueMapLock;
+
+public:
+  // NOTE: This function is not locked.  It is the caller's responsibility
+  // to enforce proper synchronization.
+  typename MapTy::iterator map_end() { return Map.end(); }
+    
+  /// InsertOrGetItem - Return an iterator for the specified element.
+  /// If the element exists in the map, the returned iterator points to the
+  /// entry and Exists=true.  If not, the iterator points to the newly
+  /// inserted entry and returns Exists=false.  Newly inserted entries have
+  /// I->second == 0, and should be filled in.
+  /// NOTE: This function is not locked.  It is the caller's responsibility
+  // to enforce proper synchronization.
+  typename MapTy::iterator InsertOrGetItem(std::pair<MapKey, Constant *>
+                                 &InsertVal,
+                                 bool &Exists) {
+    std::pair<typename MapTy::iterator, bool> IP = Map.insert(InsertVal);
+    Exists = !IP.second;
+    return IP.first;
+  }
+    
+private:
+  typename MapTy::iterator FindExistingElement(ConstantClass *CP) {
+    if (HasLargeKey) {
+      typename InverseMapTy::iterator IMI = InverseMap.find(CP);
+      assert(IMI != InverseMap.end() && IMI->second != Map.end() &&
+             IMI->second->second == CP &&
+             "InverseMap corrupt!");
+      return IMI->second;
+    }
+      
+    typename MapTy::iterator I =
+      Map.find(MapKey(static_cast<const TypeClass*>(CP->getRawType()),
+                      getValType(CP)));
+    if (I == Map.end() || I->second != CP) {
+      // FIXME: This should not use a linear scan.  If this gets to be a
+      // performance problem, someone should look at this.
+      for (I = Map.begin(); I != Map.end() && I->second != CP; ++I)
+        /* empty */;
+    }
+    return I;
+  }
+    
+  ConstantClass* Create(const TypeClass *Ty, const ValType &V,
+                        typename MapTy::iterator I) {
+    ConstantClass* Result =
+      ConstantCreator<ConstantClass,TypeClass,ValType>::create(Ty, V);
+
+    assert(Result->getType() == Ty && "Type specified is not correct!");
+    I = Map.insert(I, std::make_pair(MapKey(Ty, V), Result));
+
+    if (HasLargeKey)  // Remember the reverse mapping if needed.
+      InverseMap.insert(std::make_pair(Result, I));
+
+    // If the type of the constant is abstract, make sure that an entry
+    // exists for it in the AbstractTypeMap.
+    if (Ty->isAbstract()) {
+      typename AbstractTypeMapTy::iterator TI = 
+                                               AbstractTypeMap.find(Ty);
+
+      if (TI == AbstractTypeMap.end()) {
+        // Add ourselves to the ATU list of the type.
+        cast<DerivedType>(Ty)->addAbstractTypeUser(this);
+
+        AbstractTypeMap.insert(TI, std::make_pair(Ty, I));
+      }
+    }
+      
+    return Result;
+  }
+public:
+    
+  /// getOrCreate - Return the specified constant from the map, creating it if
+  /// necessary.
+  ConstantClass *getOrCreate(const TypeClass *Ty, const ValType &V) {
+    sys::SmartScopedLock<true> Lock(ValueMapLock);
+    MapKey Lookup(Ty, V);
+    ConstantClass* Result = 0;
+    
+    typename MapTy::iterator I = Map.find(Lookup);
+    // Is it in the map?  
+    if (I != Map.end())
+      Result = static_cast<ConstantClass *>(I->second);
+        
+    if (!Result) {
+      // If no preexisting value, create one now...
+      Result = Create(Ty, V, I);
+    }
+        
+    return Result;
+  }
+
+  void remove(ConstantClass *CP) {
+    sys::SmartScopedLock<true> Lock(ValueMapLock);
+    typename MapTy::iterator I = FindExistingElement(CP);
+    assert(I != Map.end() && "Constant not found in constant table!");
+    assert(I->second == CP && "Didn't find correct element?");
+
+    if (HasLargeKey)  // Remember the reverse mapping if needed.
+      InverseMap.erase(CP);
+      
+    // Now that we found the entry, make sure this isn't the entry that
+    // the AbstractTypeMap points to.
+    const TypeClass *Ty = static_cast<const TypeClass *>(I->first.first);
+    if (Ty->isAbstract()) {
+      assert(AbstractTypeMap.count(Ty) &&
+             "Abstract type not in AbstractTypeMap?");
+      typename MapTy::iterator &ATMEntryIt = AbstractTypeMap[Ty];
+      if (ATMEntryIt == I) {
+        // Yes, we are removing the representative entry for this type.
+        // See if there are any other entries of the same type.
+        typename MapTy::iterator TmpIt = ATMEntryIt;
+
+        // First check the entry before this one...
+        if (TmpIt != Map.begin()) {
+          --TmpIt;
+          if (TmpIt->first.first != Ty) // Not the same type, move back...
+            ++TmpIt;
+        }
+
+        // If we didn't find the same type, try to move forward...
+        if (TmpIt == ATMEntryIt) {
+          ++TmpIt;
+          if (TmpIt == Map.end() || TmpIt->first.first != Ty)
+            --TmpIt;   // No entry afterwards with the same type
+        }
+
+        // If there is another entry in the map of the same abstract type,
+        // update the AbstractTypeMap entry now.
+        if (TmpIt != ATMEntryIt) {
+          ATMEntryIt = TmpIt;
+        } else {
+          // Otherwise, we are removing the last instance of this type
+          // from the table.  Remove from the ATM, and from user list.
+          cast<DerivedType>(Ty)->removeAbstractTypeUser(this);
+          AbstractTypeMap.erase(Ty);
+        }
+      }
+    }
+
+    Map.erase(I);
+  }
+
+    
+  /// MoveConstantToNewSlot - If we are about to change C to be the element
+  /// specified by I, update our internal data structures to reflect this
+  /// fact.
+  /// NOTE: This function is not locked. It is the responsibility of the
+  /// caller to enforce proper synchronization if using this method.
+  void MoveConstantToNewSlot(ConstantClass *C, typename MapTy::iterator I) {
+    // First, remove the old location of the specified constant in the map.
+    typename MapTy::iterator OldI = FindExistingElement(C);
+    assert(OldI != Map.end() && "Constant not found in constant table!");
+    assert(OldI->second == C && "Didn't find correct element?");
+      
+    // If this constant is the representative element for its abstract type,
+    // update the AbstractTypeMap so that the representative element is I.
+    if (C->getType()->isAbstract()) {
+      typename AbstractTypeMapTy::iterator ATI =
+          AbstractTypeMap.find(C->getType());
+      assert(ATI != AbstractTypeMap.end() &&
+             "Abstract type not in AbstractTypeMap?");
+      if (ATI->second == OldI)
+        ATI->second = I;
+    }
+      
+    // Remove the old entry from the map.
+    Map.erase(OldI);
+    
+    // Update the inverse map so that we know that this constant is now
+    // located at descriptor I.
+    if (HasLargeKey) {
+      assert(I->second == C && "Bad inversemap entry!");
+      InverseMap[C] = I;
+    }
+  }
+    
+  void refineAbstractType(const DerivedType *OldTy, const Type *NewTy) {
+    sys::SmartScopedLock<true> Lock(ValueMapLock);
+    typename AbstractTypeMapTy::iterator I =
+      AbstractTypeMap.find(cast<Type>(OldTy));
+
+    assert(I != AbstractTypeMap.end() &&
+           "Abstract type not in AbstractTypeMap?");
+
+    // Convert a constant at a time until the last one is gone.  The last one
+    // leaving will remove() itself, causing the AbstractTypeMapEntry to be
+    // eliminated eventually.
+    do {
+      ConvertConstantType<ConstantClass,
+                          TypeClass>::convert(
+                              static_cast<ConstantClass *>(I->second->second),
+                                              cast<TypeClass>(NewTy));
+
+      I = AbstractTypeMap.find(cast<Type>(OldTy));
+    } while (I != AbstractTypeMap.end());
+  }
+
+  // If the type became concrete without being refined to any other existing
+  // type, we just remove ourselves from the ATU list.
+  void typeBecameConcrete(const DerivedType *AbsTy) {
+    AbsTy->removeAbstractTypeUser(this);
+  }
+
+  void dump() const {
+    DOUT << "Constant.cpp: ValueMap\n";
+  }
+};
+
+
 class ConstantInt;
 class ConstantFP;
 class MDString;
@@ -112,19 +435,19 @@
   
   FoldingSet<MDNode> MDNodeSet;
   
-  ValueMap<char, Type, ConstantAggregateZero> *AggZeroConstants;
+  ValueMap<char, Type, ConstantAggregateZero> AggZeroConstants;
   
   typedef ValueMap<std::vector<Constant*>, ArrayType, 
     ConstantArray, true /*largekey*/> ArrayConstantsTy;
-  ArrayConstantsTy *ArrayConstants;
+  ArrayConstantsTy ArrayConstants;
   
   typedef ValueMap<std::vector<Constant*>, StructType,
                    ConstantStruct, true /*largekey*/> StructConstantsTy;
-  StructConstantsTy *StructConstants;
+  StructConstantsTy StructConstants;
   
   typedef ValueMap<std::vector<Constant*>, VectorType,
                    ConstantVector> VectorConstantsTy;
-  VectorConstantsTy *VectorConstants;
+  VectorConstantsTy VectorConstants;
   
   LLVMContext &Context;
   ConstantInt *TheTrueVal;
@@ -132,13 +455,10 @@
   
   LLVMContextImpl();
   LLVMContextImpl(const LLVMContextImpl&);
+  
+  friend class ConstantInt;
 public:
   LLVMContextImpl(LLVMContext &C);
-  ~LLVMContextImpl();
-  
-  /// 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.
-  ConstantInt *getConstantInt(const APInt &V);
   
   ConstantFP *getConstantFP(const APFloat &V);
   
@@ -161,14 +481,14 @@
     if (TheTrueVal)
       return TheTrueVal;
     else
-      return (TheTrueVal = Context.getConstantInt(IntegerType::get(1), 1));
+      return (TheTrueVal = ConstantInt::get(IntegerType::get(1), 1));
   }
   
   ConstantInt *getFalse() {
     if (TheFalseVal)
       return TheFalseVal;
     else
-      return (TheFalseVal = Context.getConstantInt(IntegerType::get(1), 0));
+      return (TheFalseVal = ConstantInt::get(IntegerType::get(1), 0));
   }
   
   void erase(MDString *M);

Modified: llvm/trunk/tools/bugpoint/ExtractFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ExtractFunction.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/tools/bugpoint/ExtractFunction.cpp (original)
+++ llvm/trunk/tools/bugpoint/ExtractFunction.cpp Fri Jul 24 18:12:02 2009
@@ -185,7 +185,7 @@
   std::vector<Constant*> ArrayElts;
   for (unsigned i = 0, e = TorList.size(); i != e; ++i) {
     std::vector<Constant*> Elts;
-    Elts.push_back(Context.getConstantInt(Type::Int32Ty, TorList[i].second));
+    Elts.push_back(ConstantInt::get(Type::Int32Ty, TorList[i].second));
     Elts.push_back(TorList[i].first);
     ArrayElts.push_back(Context.getConstantStruct(Elts));
   }

Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp (original)
+++ llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Fri Jul 24 18:12:02 2009
@@ -39,8 +39,7 @@
   IRBuilder<> builder(Entry);
   Value *Load = builder.CreateLoad(G);
   const Type *GTy = G->getType()->getElementType();
-  Value *Add = builder.CreateAdd(Load,
-    getGlobalContext().getConstantInt(GTy, 1LL));
+  Value *Add = builder.CreateAdd(Load, ConstantInt::get(GTy, 1LL));
   builder.CreateStore(Add, G);
   builder.CreateRet(Add);
   return F;

Modified: llvm/trunk/unittests/Support/ValueHandleTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/ValueHandleTest.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/unittests/Support/ValueHandleTest.cpp (original)
+++ llvm/trunk/unittests/Support/ValueHandleTest.cpp Fri Jul 24 18:12:02 2009
@@ -26,7 +26,7 @@
   std::auto_ptr<BitCastInst> BitcastV;
 
   ValueHandle() :
-    ConstantV(getGlobalContext().getConstantInt(Type::Int32Ty, 0)),
+    ConstantV(ConstantInt::get(Type::Int32Ty, 0)),
     BitcastV(new BitCastInst(ConstantV, Type::Int32Ty)) {
   }
 };

Modified: llvm/trunk/unittests/VMCore/ConstantsTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/VMCore/ConstantsTest.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/unittests/VMCore/ConstantsTest.cpp (original)
+++ llvm/trunk/unittests/VMCore/ConstantsTest.cpp Fri Jul 24 18:12:02 2009
@@ -17,11 +17,10 @@
 
 TEST(ConstantsTest, Integer_i1) {
   const IntegerType* Int1 = IntegerType::get(1);
-  Constant* One = getGlobalContext().getConstantInt(Int1, 1, true);
-  Constant* Zero = getGlobalContext().getConstantInt(Int1, 0);
-  Constant* NegOne =
-    getGlobalContext().getConstantInt(Int1, static_cast<uint64_t>(-1), true);
-  EXPECT_EQ(NegOne, getGlobalContext().getConstantIntSigned(Int1, -1));
+  Constant* One = ConstantInt::get(Int1, 1, true);
+  Constant* Zero = ConstantInt::get(Int1, 0);
+  Constant* NegOne = ConstantInt::get(Int1, static_cast<uint64_t>(-1), true);
+  EXPECT_EQ(NegOne, ConstantInt::getSigned(Int1, -1));
   Constant* Undef = getGlobalContext().getUndef(Int1);
 
   // Input:  @b = constant i1 add(i1 1 , i1 1)
@@ -99,16 +98,15 @@
 
 TEST(ConstantsTest, IntSigns) {
   const IntegerType* Int8Ty = Type::Int8Ty;
-  LLVMContext &Context = getGlobalContext();
-  EXPECT_EQ(100, Context.getConstantInt(Int8Ty, 100, false)->getSExtValue());
-  EXPECT_EQ(100, Context.getConstantInt(Int8Ty, 100, true)->getSExtValue());
-  EXPECT_EQ(100, Context.getConstantIntSigned(Int8Ty, 100)->getSExtValue());
-  EXPECT_EQ(-50, Context.getConstantInt(Int8Ty, 206)->getSExtValue());
-  EXPECT_EQ(-50, Context.getConstantIntSigned(Int8Ty, -50)->getSExtValue());
-  EXPECT_EQ(206U, Context.getConstantIntSigned(Int8Ty, -50)->getZExtValue());
+  EXPECT_EQ(100, ConstantInt::get(Int8Ty, 100, false)->getSExtValue());
+  EXPECT_EQ(100, ConstantInt::get(Int8Ty, 100, true)->getSExtValue());
+  EXPECT_EQ(100, ConstantInt::getSigned(Int8Ty, 100)->getSExtValue());
+  EXPECT_EQ(-50, ConstantInt::get(Int8Ty, 206)->getSExtValue());
+  EXPECT_EQ(-50, ConstantInt::getSigned(Int8Ty, -50)->getSExtValue());
+  EXPECT_EQ(206U, ConstantInt::getSigned(Int8Ty, -50)->getZExtValue());
 
   // Overflow is handled by truncation.
-  EXPECT_EQ(0x3b, Context.getConstantInt(Int8Ty, 0x13b)->getSExtValue());
+  EXPECT_EQ(0x3b, ConstantInt::get(Int8Ty, 0x13b)->getSExtValue());
 }
 
 }  // end anonymous namespace

Modified: llvm/trunk/unittests/VMCore/MetadataTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/VMCore/MetadataTest.cpp?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/unittests/VMCore/MetadataTest.cpp (original)
+++ llvm/trunk/unittests/VMCore/MetadataTest.cpp Fri Jul 24 18:12:02 2009
@@ -69,7 +69,7 @@
 
   MDString *s1 = getGlobalContext().getMDString(&x[0], 3);
   MDString *s2 = getGlobalContext().getMDString(&y[0], 3);
-  ConstantInt *CI = getGlobalContext().getConstantInt(APInt(8, 0));
+  ConstantInt *CI = ConstantInt::get(getGlobalContext(), APInt(8, 0));
 
   std::vector<Value *> V;
   V.push_back(s1);
@@ -102,7 +102,7 @@
 }
 
 TEST(MDNodeTest, Delete) {
-  Constant *C = getGlobalContext().getConstantInt(Type::Int32Ty, 1);
+  Constant *C = ConstantInt::get(Type::Int32Ty, 1);
   Instruction *I = new BitCastInst(C, Type::Int32Ty);
 
   Value *const V = I;

Modified: llvm/trunk/win32/unistd.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/win32/unistd.h?rev=77011&r1=77010&r2=77011&view=diff

==============================================================================
--- llvm/trunk/win32/unistd.h (original)
+++ llvm/trunk/win32/unistd.h Fri Jul 24 18:12:02 2009
@@ -1 +1 @@
-// This file has to be here because it's #included from the auto generated FileLexer.cpp
\ No newline at end of file
+// This file has to be here because it's #included from the auto generated FileLexer.cpp





More information about the llvm-commits mailing list