[vmkit-commits] [vmkit] r75784 - in /vmkit/trunk: lib/JnJVM/Compiler/ lib/Mvm/Compiler/ lib/N3/Mono/ lib/N3/VMCore/ tools/vmjc/

Nicolas Geoffray nicolas.geoffray at lip6.fr
Wed Jul 15 06:31:36 PDT 2009


Author: geoffray
Date: Wed Jul 15 08:31:22 2009
New Revision: 75784

URL: http://llvm.org/viewvc/llvm-project?rev=75784&view=rev
Log:
Move to new LLVM API.


Modified:
    vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.inc
    vmkit/trunk/lib/JnJVM/Compiler/ExceptionsDwarf.inc
    vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp
    vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp
    vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp
    vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp
    vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp
    vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp
    vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp
    vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp
    vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
    vmkit/trunk/lib/N3/Mono/MonoString.cpp
    vmkit/trunk/lib/N3/VMCore/CLIJit.cpp
    vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp
    vmkit/trunk/lib/N3/VMCore/Opcodes.cpp
    vmkit/trunk/lib/N3/VMCore/VMCache.cpp
    vmkit/trunk/lib/N3/VMCore/VMClass.cpp
    vmkit/trunk/tools/vmjc/vmjc.cpp

Modified: vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.inc?rev=75784&r1=75783&r2=75784&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.inc (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.inc Wed Jul 15 08:31:22 2009
@@ -431,7 +431,7 @@
                                     currentBlock);
 
     uint32 depth = cur->catchClass->virtualVT->depth;
-    Value* depthCl = ConstantInt::get(Type::Int32Ty, depth);
+    Value* depthCl = llvmContext->getConstantInt(Type::Int32Ty, depth);
     Value* cmp = 0;
 
     if (depth >= JavaVirtualTable::getDisplayLength()) {

Modified: vmkit/trunk/lib/JnJVM/Compiler/ExceptionsDwarf.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/ExceptionsDwarf.inc?rev=75784&r1=75783&r2=75784&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/ExceptionsDwarf.inc (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/ExceptionsDwarf.inc Wed Jul 15 08:31:22 2009
@@ -426,7 +426,7 @@
     Value* objCl = CallInst::Create(module->GetClassFunction, obj, "",
                                     currentBlock);
 
-    Value* depthCl = ConstantInt::get(Type::Int32Ty, cur->catchClass->depth);
+    Value* depthCl = llvmContext->getConstantInt(Type::Int32Ty, cur->catchClass->depth);
     Value* depthClObj = CallInst::Create(module->GetDepthFunction, objCl, "",
                                          currentBlock);
     
@@ -529,7 +529,7 @@
                                      cur->javaHandler);
       OldIsolateID = new LoadInst(IsolateIDPtr, "", cur->javaHandler);
 
-      Value* MyID = ConstantInt::get(module->pointerSizeType,
+      Value* MyID = llvmContext->getConstantInt(module->pointerSizeType,
                                      loader->getIsolate()->IsolateID);
 
       new StoreInst(MyID, IsolateIDPtr, cur->javaHandler);

Modified: vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp?rev=75784&r1=75783&r2=75784&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp Wed Jul 15 08:31:22 2009
@@ -42,6 +42,10 @@
     const TargetData* targetData = JnjvmModule::TheTargetData;
     const StructLayout* sl = 0;
     const StructType* structType = 0;
+    JavaLLVMCompiler* Mod = 
+      (JavaLLVMCompiler*)classDef->classLoader->getCompiler();
+    Module* LMod = Mod->getLLVMModule();
+    LLVMContext& Context = LMod->getContext();
     
     if (classDef->super) {
       LLVMClassInfo* CLI = JavaLLVMCompiler::getClassInfo(classDef->super);
@@ -76,10 +80,8 @@
     
     uint64 size = JnjvmModule::getTypeSize(structType);
     classDef->virtualSize = (uint32)size;
-    virtualSizeConstant = ConstantInt::get(Type::Int32Ty, size);
+    virtualSizeConstant = Context.getConstantInt(Type::Int32Ty, size);
    
-    JavaLLVMCompiler* Mod = 
-      (JavaLLVMCompiler*)classDef->classLoader->getCompiler();
     Mod->makeVT(classDef);
   }
 
@@ -119,10 +121,15 @@
 
 Value* LLVMClassInfo::getVirtualSize() {
   if (!virtualSizeConstant) {
+    JavaLLVMCompiler* Mod = 
+      (JavaLLVMCompiler*)classDef->classLoader->getCompiler();
+    Module* LMod = Mod->getLLVMModule();
+    LLVMContext& Context = LMod->getContext();
+
     getVirtualType();
     assert(classDef->virtualSize && "Zero size for a class?");
     virtualSizeConstant = 
-      ConstantInt::get(Type::Int32Ty, classDef->virtualSize);
+      Context.getConstantInt(Type::Int32Ty, classDef->virtualSize);
   }
   return virtualSizeConstant;
 }
@@ -187,9 +194,12 @@
 Constant* LLVMMethodInfo::getOffset() {
   if (!offsetConstant) {
     JnjvmClassLoader* JCL = methodDef->classDef->classLoader;
-    JavaCompiler* Mod = JCL->getCompiler();
+    JavaLLVMCompiler* Mod = (JavaLLVMCompiler*)JCL->getCompiler();
+    Module* LMod = Mod->getLLVMModule();
+    LLVMContext& Context = LMod->getContext();
+    
     Mod->resolveVirtualClass(methodDef->classDef);
-    offsetConstant = ConstantInt::get(Type::Int32Ty, methodDef->offset);
+    offsetConstant = Context.getConstantInt(Type::Int32Ty, methodDef->offset);
   }
   return offsetConstant;
 }
@@ -197,14 +207,17 @@
 Constant* LLVMFieldInfo::getOffset() {
   if (!offsetConstant) {
     JnjvmClassLoader* JCL = fieldDef->classDef->classLoader;
-    JavaCompiler* Mod = JCL->getCompiler();
+    JavaLLVMCompiler* Mod = (JavaLLVMCompiler*)JCL->getCompiler();
+    Module* LMod = Mod->getLLVMModule();
+    LLVMContext& Context = LMod->getContext();
+    
     if (isStatic(fieldDef->access)) {
       Mod->resolveStaticClass(fieldDef->classDef); 
     } else {
       Mod->resolveVirtualClass(fieldDef->classDef); 
     }
     
-    offsetConstant = ConstantInt::get(Type::Int32Ty, fieldDef->num);
+    offsetConstant = Context.getConstantInt(Type::Int32Ty, fieldDef->num);
   }
   return offsetConstant;
 }

Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp?rev=75784&r1=75783&r2=75784&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp Wed Jul 15 08:31:22 2009
@@ -130,13 +130,14 @@
 }
 
 Constant* JavaAOTCompiler::getMethodInClass(JavaMethod* meth) {
+  LLVMContext& Context = getLLVMModule()->getContext();
   Class* cl = meth->classDef;
   Constant* MOffset = 0;
   Constant* Array = 0;
   method_iterator SI = virtualMethods.find(cl);
   for (uint32 i = 0; i < cl->nbVirtualMethods + cl->nbStaticMethods; ++i) {
     if (&cl->virtualMethods[i] == meth) {
-      MOffset = ConstantInt::get(Type::Int32Ty, i);
+      MOffset = Context.getConstantInt(Type::Int32Ty, i);
       break;
     }
   }
@@ -282,7 +283,8 @@
       varGV->setInitializer(CreateConstantFromJavaObject(obj));
       return C;
     } else {
-      Constant* CI = ConstantInt::get(Type::Int64Ty, uint64_t(obj));
+      LLVMContext& Context = getLLVMModule()->getContext();
+      Constant* CI = Context.getConstantInt(Type::Int64Ty, uint64_t(obj));
       CI = ConstantExpr::getIntToPtr(CI, JnjvmModule::JavaObjectType);
       finalObjects.insert(std::make_pair(obj, CI));
       return CI;
@@ -297,6 +299,7 @@
   const Type* Ty = LCI->getStaticType();
   const StructType* STy = dyn_cast<StructType>(Ty->getContainedType(0));
   Module& Mod = *getLLVMModule();
+  LLVMContext& Context = Mod.getContext();
   
   std::vector<Constant*> Elts;
   
@@ -314,27 +317,27 @@
         if (type->isPrimitive()) {
           const PrimitiveTypedef* prim = (PrimitiveTypedef*)type;
           if (prim->isBool() || prim->isByte()) {
-            ConstantInt* CI = ConstantInt::get(Type::Int8Ty,
+            ConstantInt* CI = Context.getConstantInt(Type::Int8Ty,
                                                field.getInt8Field(obj));
             Elts.push_back(CI);
           } else if (prim->isShort() || prim->isChar()) {
-            ConstantInt* CI = ConstantInt::get(Type::Int16Ty,
+            ConstantInt* CI = Context.getConstantInt(Type::Int16Ty,
                                                field.getInt16Field(obj));
             Elts.push_back(CI);
           } else if (prim->isInt()) {
-            ConstantInt* CI = ConstantInt::get(Type::Int32Ty,
+            ConstantInt* CI = Context.getConstantInt(Type::Int32Ty,
                                                field.getInt32Field(obj));
             Elts.push_back(CI);
           } else if (prim->isLong()) {
-            ConstantInt* CI = ConstantInt::get(Type::Int64Ty,
+            ConstantInt* CI = Context.getConstantInt(Type::Int64Ty,
                                                field.getLongField(obj));
             Elts.push_back(CI);
           } else if (prim->isFloat()) {
-            Constant* CF = ConstantFP::get(Type::FloatTy,
+            Constant* CF = Context.getConstantFP(Type::FloatTy,
                                            field.getFloatField(obj));
             Elts.push_back(CF);
           } else if (prim->isDouble()) {
-            Constant* CF = ConstantFP::get(Type::DoubleTy,
+            Constant* CF = Context.getConstantFP(Type::DoubleTy,
                                            field.getDoubleField(obj));
             Elts.push_back(CF);
           } else {
@@ -358,13 +361,13 @@
       uint16 idx = reader.readU2();
       if (type->isPrimitive()) {
         if (Ty == Type::Int64Ty) {
-          Elts.push_back(ConstantInt::get(Ty, (uint64)ctpInfo->LongAt(idx)));
+          Elts.push_back(Context.getConstantInt(Ty, (uint64)ctpInfo->LongAt(idx)));
         } else if (Ty == Type::DoubleTy) {
-          Elts.push_back(ConstantFP::get(Ty, ctpInfo->DoubleAt(idx)));
+          Elts.push_back(Context.getConstantFP(Ty, ctpInfo->DoubleAt(idx)));
         } else if (Ty == Type::FloatTy) {
-          Elts.push_back(ConstantFP::get(Ty, ctpInfo->FloatAt(idx)));
+          Elts.push_back(Context.getConstantFP(Ty, ctpInfo->FloatAt(idx)));
         } else {
-          Elts.push_back(ConstantInt::get(Ty, (uint64)ctpInfo->IntegerAt(idx)));
+          Elts.push_back(Context.getConstantInt(Ty, (uint64)ctpInfo->IntegerAt(idx)));
         }
       } else if (type->isReference()){
         const UTF8* utf8 = ctpInfo->UTF8At(ctpInfo->ctpDef[idx]);
@@ -485,12 +488,13 @@
     dyn_cast<StructType>(JnjvmModule::JavaObjectType->getContainedType(0));
   
   std::vector<Constant*> Elmts;
+  LLVMContext& Context = getLLVMModule()->getContext();
 
   // VT
   Elmts.push_back(getVirtualTable(cl->virtualVT));
   
   // lock
-  Constant* L = ConstantInt::get(Type::Int64Ty, 0);
+  Constant* L = Context.getConstantInt(Type::Int64Ty, 0);
   Elmts.push_back(ConstantExpr::getIntToPtr(L, JnjvmModule::ptrType));
 
   return ConstantStruct::get(STy, Elmts);
@@ -529,6 +533,7 @@
 Constant* JavaAOTCompiler::CreateConstantFromJavaObject(JavaObject* obj) {
   CommonClass* cl = obj->getClass();
   Module& Mod = *getLLVMModule();
+  LLVMContext& Context = getLLVMModule()->getContext();
 
   if (cl->isArray()) {
     Classpath* upcalls = cl->classLoader->bootstrapLoader->upcalls;
@@ -587,27 +592,27 @@
         if (type->isPrimitive()) {
           const PrimitiveTypedef* prim = (PrimitiveTypedef*)type;
           if (prim->isBool() || prim->isByte()) {
-            ConstantInt* CI = ConstantInt::get(Type::Int8Ty,
+            ConstantInt* CI = Context.getConstantInt(Type::Int8Ty,
                                                field.getInt8Field(obj));
             TempElts.push_back(CI);
           } else if (prim->isShort() || prim->isChar()) {
-            ConstantInt* CI = ConstantInt::get(Type::Int16Ty,
+            ConstantInt* CI = Context.getConstantInt(Type::Int16Ty,
                                                field.getInt16Field(obj));
             TempElts.push_back(CI);
           } else if (prim->isInt()) {
-            ConstantInt* CI = ConstantInt::get(Type::Int32Ty,
+            ConstantInt* CI = Context.getConstantInt(Type::Int32Ty,
                                                field.getInt32Field(obj));
             TempElts.push_back(CI);
           } else if (prim->isLong()) {
-            ConstantInt* CI = ConstantInt::get(Type::Int64Ty,
+            ConstantInt* CI = Context.getConstantInt(Type::Int64Ty,
                                                field.getLongField(obj));
             TempElts.push_back(CI);
           } else if (prim->isFloat()) {
-            Constant* CF = ConstantFP::get(Type::FloatTy,
+            Constant* CF = Context.getConstantFP(Type::FloatTy,
                                            field.getFloatField(obj));
             TempElts.push_back(CF);
           } else if (prim->isDouble()) {
-            Constant* CF = ConstantFP::get(Type::DoubleTy,
+            Constant* CF = Context.getConstantFP(Type::DoubleTy,
                                            field.getDoubleField(obj));
             TempElts.push_back(CF);
           } else {
@@ -636,6 +641,7 @@
   LLVMClassInfo* LCI = getClassInfo(cl);
   const StructType* STy = 
     dyn_cast<StructType>(LCI->getVirtualType()->getContainedType(0));
+  LLVMContext& Context = getLLVMModule()->getContext();
 
   std::vector<Constant*> Elmts;
 
@@ -653,9 +659,9 @@
 	Array = ConstantExpr::getBitCast(varGV, JnjvmModule::JavaObjectType);
 
   Elmts.push_back(Array);
-  Elmts.push_back(ConstantInt::get(Type::Int32Ty, str->count));
-  Elmts.push_back(ConstantInt::get(Type::Int32Ty, str->cachedHashCode));
-  Elmts.push_back(ConstantInt::get(Type::Int32Ty, str->offset));
+  Elmts.push_back(Context.getConstantInt(Type::Int32Ty, str->count));
+  Elmts.push_back(Context.getConstantInt(Type::Int32Ty, str->cachedHashCode));
+  Elmts.push_back(Context.getConstantInt(Type::Int32Ty, str->offset));
  
   return ConstantStruct::get(STy, Elmts);
 }
@@ -664,12 +670,12 @@
 Constant* JavaAOTCompiler::CreateConstantFromCacheNode(CacheNode* CN) {
   const StructType* STy = 
     dyn_cast<StructType>(JnjvmModule::CacheNodeType->getContainedType(0));
-  Module& Mod = *getLLVMModule();
+  LLVMContext& Context = getLLVMModule()->getContext();
 
   std::vector<Constant*> Elmts;
-  Elmts.push_back(Mod.getContext().getNullValue(STy->getContainedType(0)));
-  Elmts.push_back(Mod.getContext().getNullValue(STy->getContainedType(1)));
-  Elmts.push_back(Mod.getContext().getNullValue(STy->getContainedType(2)));
+  Elmts.push_back(Context.getNullValue(STy->getContainedType(0)));
+  Elmts.push_back(Context.getNullValue(STy->getContainedType(1)));
+  Elmts.push_back(Context.getNullValue(STy->getContainedType(2)));
   Elmts.push_back(getEnveloppe(CN->enveloppe));
   
   return ConstantStruct::get(STy, Elmts);
@@ -703,6 +709,7 @@
 Constant* JavaAOTCompiler::CreateConstantFromAttribut(Attribut& attribut) {
   const StructType* STy = 
     dyn_cast<StructType>(JnjvmModule::AttributType->getContainedType(0));
+  LLVMContext& Context = getLLVMModule()->getContext();
 
 
   std::vector<Constant*> Elmts;
@@ -711,10 +718,10 @@
   Elmts.push_back(getUTF8(attribut.name));
 
   // start
-  Elmts.push_back(ConstantInt::get(Type::Int32Ty, attribut.start));
+  Elmts.push_back(Context.getConstantInt(Type::Int32Ty, attribut.start));
 
   // nbb
-  Elmts.push_back(ConstantInt::get(Type::Int32Ty, attribut.nbb));
+  Elmts.push_back(Context.getConstantInt(Type::Int32Ty, attribut.nbb));
   
   return ConstantStruct::get(STy, Elmts);
 }
@@ -723,6 +730,7 @@
   const StructType* STy = 
     dyn_cast<StructType>(JnjvmModule::JavaCommonClassType->getContainedType(0));
   Module& Mod = *getLLVMModule();
+  LLVMContext& Context = getLLVMModule()->getContext();
   
   const llvm::Type* TempTy = 0;
 
@@ -737,7 +745,7 @@
   CommonClassElts.push_back(ConstantArray::get(ATy, TCM, 1));
   
   // access
-  CommonClassElts.push_back(ConstantInt::get(Type::Int16Ty, cl->access));
+  CommonClassElts.push_back(Context.getConstantInt(Type::Int16Ty, cl->access));
  
   // interfaces
   if (cl->nbInterfaces) {
@@ -747,7 +755,7 @@
 
     ATy = ArrayType::get(JnjvmModule::JavaClassType, cl->nbInterfaces);
     Constant* interfaces = ConstantArray::get(ATy, TempElmts);
-    interfaces = new GlobalVariable(*getLLVMModule(), ATy, true,
+    interfaces = new GlobalVariable(Mod, ATy, true,
                                     GlobalValue::InternalLinkage,
                                     interfaces, "");
     interfaces = ConstantExpr::getCast(Instruction::BitCast, interfaces,
@@ -756,11 +764,11 @@
     CommonClassElts.push_back(interfaces);
   } else {
     const Type* Ty = PointerType::getUnqual(JnjvmModule::JavaClassType);
-    CommonClassElts.push_back(Mod.getContext().getNullValue(Ty));
+    CommonClassElts.push_back(Context.getNullValue(Ty));
   }
 
   // nbInterfaces
-  CommonClassElts.push_back(ConstantInt::get(Type::Int16Ty, cl->nbInterfaces));
+  CommonClassElts.push_back(Context.getConstantInt(Type::Int16Ty, cl->nbInterfaces));
 
   // name
   CommonClassElts.push_back(getUTF8(cl->name));
@@ -793,6 +801,7 @@
   const StructType* STy = 
     dyn_cast<StructType>(JnjvmModule::JavaFieldType->getContainedType(0));
   Module& Mod = *getLLVMModule();
+  LLVMContext& Context = Mod.getContext();
   
   std::vector<Constant*> FieldElts;
   std::vector<Constant*> TempElts;
@@ -801,7 +810,7 @@
   FieldElts.push_back(Mod.getContext().getNullValue(JnjvmModule::ptrType));
   
   // access
-  FieldElts.push_back(ConstantInt::get(Type::Int16Ty, field.access));
+  FieldElts.push_back(Context.getConstantInt(Type::Int16Ty, field.access));
 
   // name
   FieldElts.push_back(getUTF8(field.name));
@@ -831,16 +840,16 @@
   }
   
   // nbAttributs
-  FieldElts.push_back(ConstantInt::get(Type::Int16Ty, field.nbAttributs));
+  FieldElts.push_back(Context.getConstantInt(Type::Int16Ty, field.nbAttributs));
 
   // classDef
   FieldElts.push_back(getNativeClass(field.classDef));
 
   // ptrOffset
-  FieldElts.push_back(ConstantInt::get(Type::Int32Ty, field.ptrOffset));
+  FieldElts.push_back(Context.getConstantInt(Type::Int32Ty, field.ptrOffset));
 
   // num
-  FieldElts.push_back(ConstantInt::get(Type::Int16Ty, field.num));
+  FieldElts.push_back(Context.getConstantInt(Type::Int16Ty, field.num));
 
   //JInfo
   FieldElts.push_back(Mod.getContext().getNullValue(JnjvmModule::ptrType));
@@ -852,15 +861,16 @@
   const StructType* STy = 
     dyn_cast<StructType>(JnjvmModule::JavaMethodType->getContainedType(0));
   Module& Mod = *getLLVMModule();
+  LLVMContext& Context = Mod.getContext();
   
   std::vector<Constant*> MethodElts;
   std::vector<Constant*> TempElts;
   
   // signature
-  MethodElts.push_back(Mod.getContext().getNullValue(JnjvmModule::ptrType));
+  MethodElts.push_back(Context.getNullValue(JnjvmModule::ptrType));
   
   // access
-  MethodElts.push_back(ConstantInt::get(Type::Int16Ty, method.access));
+  MethodElts.push_back(Context.getConstantInt(Type::Int16Ty, method.access));
  
   // attributs
   if (method.nbAttributs) {
@@ -872,7 +882,7 @@
 
     Constant* attributs = ConstantArray::get(ATy, TempElts);
     TempElts.clear();
-    attributs = new GlobalVariable(*getLLVMModule(), ATy, true,
+    attributs = new GlobalVariable(Mod, ATy, true,
                                    GlobalValue::InternalLinkage,
                                    attributs, "");
     attributs = ConstantExpr::getCast(Instruction::BitCast, attributs,
@@ -880,19 +890,19 @@
 
     MethodElts.push_back(attributs);
   } else {
-    MethodElts.push_back(Mod.getContext().getNullValue(JnjvmModule::AttributType));
+    MethodElts.push_back(Context.getNullValue(JnjvmModule::AttributType));
   }
   
   // nbAttributs
-  MethodElts.push_back(ConstantInt::get(Type::Int16Ty, method.nbAttributs));
+  MethodElts.push_back(Context.getConstantInt(Type::Int16Ty, method.nbAttributs));
   
   // enveloppes
   // already allocated by the JIT, don't reallocate them.
-  MethodElts.push_back(Mod.getContext().getNullValue(JnjvmModule::EnveloppeType));
+  MethodElts.push_back(Context.getNullValue(JnjvmModule::EnveloppeType));
   
   // nbEnveloppes
   // 0 because we're not allocating here.
-  MethodElts.push_back(ConstantInt::get(Type::Int16Ty, 0));
+  MethodElts.push_back(Context.getConstantInt(Type::Int16Ty, 0));
   
   // classDef
   MethodElts.push_back(getNativeClass(method.classDef));
@@ -904,11 +914,11 @@
   MethodElts.push_back(getUTF8(method.type));
   
   // canBeInlined
-  MethodElts.push_back(ConstantInt::get(Type::Int8Ty, method.canBeInlined));
+  MethodElts.push_back(Context.getConstantInt(Type::Int8Ty, method.canBeInlined));
 
   // code
   if (isAbstract(method.access)) {
-    MethodElts.push_back(Mod.getContext().getNullValue(JnjvmModule::ptrType));
+    MethodElts.push_back(Context.getNullValue(JnjvmModule::ptrType));
   } else {
     LLVMMethodInfo* LMI = getMethodInfo(&method);
     Function* func = LMI->getMethod();
@@ -917,10 +927,10 @@
   }
 
   // offset
-  MethodElts.push_back(ConstantInt::get(Type::Int32Ty, method.offset));
+  MethodElts.push_back(Context.getConstantInt(Type::Int32Ty, method.offset));
 
   //JInfo
-  MethodElts.push_back(Mod.getContext().getNullValue(JnjvmModule::ptrType));
+  MethodElts.push_back(Context.getNullValue(JnjvmModule::ptrType));
   
   return ConstantStruct::get(STy, MethodElts); 
 }
@@ -929,6 +939,7 @@
   const llvm::Type* JCPTy = 
     JnjvmModule::JavaClassPrimitiveType->getContainedType(0);
   const StructType* STy = dyn_cast<StructType>(JCPTy);
+  LLVMContext& Context = getLLVMModule()->getContext();
   
   std::vector<Constant*> ClassElts;
   
@@ -936,7 +947,7 @@
   ClassElts.push_back(CreateConstantFromCommonClass(cl));
 
   // primSize
-  ClassElts.push_back(ConstantInt::get(Type::Int32Ty, cl->logSize));
+  ClassElts.push_back(Context.getConstantInt(Type::Int32Ty, cl->logSize));
 
   return ConstantStruct::get(STy, ClassElts);
 }
@@ -966,6 +977,7 @@
   const StructType* STy = 
     dyn_cast<StructType>(JnjvmModule::JavaClassType->getContainedType(0));
   Module& Mod = *getLLVMModule();
+  LLVMContext& Context = getLLVMModule()->getContext();
   
   std::vector<Constant*> ClassElts;
   std::vector<Constant*> TempElts;
@@ -974,7 +986,7 @@
   ClassElts.push_back(CreateConstantFromCommonClass(cl));
 
   // virtualSize
-  ClassElts.push_back(ConstantInt::get(Type::Int32Ty, cl->virtualSize));
+  ClassElts.push_back(Context.getConstantInt(Type::Int32Ty, cl->virtualSize));
 
   // IsolateInfo
   const ArrayType* ATy = dyn_cast<ArrayType>(STy->getContainedType(2));
@@ -984,15 +996,15 @@
   assert(TCMTy && "Malformed type");
 
   uint32 status = cl->needsInitialisationCheck() ? vmjc : ready;
-  TempElts.push_back(ConstantInt::get(Type::Int8Ty, status));
-  TempElts.push_back(ConstantInt::get(Type::Int1Ty, status == ready ? 1 : 0));
+  TempElts.push_back(Context.getConstantInt(Type::Int8Ty, status));
+  TempElts.push_back(Context.getConstantInt(Type::Int1Ty, status == ready ? 1 : 0));
   TempElts.push_back(getStaticInstance(cl));
   Constant* CStr[1] = { ConstantStruct::get(TCMTy, TempElts) };
   TempElts.clear();
   ClassElts.push_back(ConstantArray::get(ATy, CStr, 1));
 
   // thinlock
-  ClassElts.push_back(Mod.getContext().getNullValue(JnjvmModule::ptrType));
+  ClassElts.push_back(Context.getNullValue(JnjvmModule::ptrType));
 
   if (cl->nbVirtualFields + cl->nbStaticFields) {
     ATy = ArrayType::get(JnjvmModule::JavaFieldType->getContainedType(0),
@@ -1022,30 +1034,30 @@
   
     fields = ConstantArray::get(ATy, TempElts);
     TempElts.clear();
-    fields = new GlobalVariable(*getLLVMModule(), ATy, false,
+    fields = new GlobalVariable(Mod, ATy, false,
                                 GlobalValue::InternalLinkage,
                                 fields, "");
     fields = ConstantExpr::getCast(Instruction::BitCast, fields,
                                    JnjvmModule::JavaFieldType);
   } else {
-    fields = Mod.getContext().getNullValue(JnjvmModule::JavaFieldType);
+    fields = Context.getNullValue(JnjvmModule::JavaFieldType);
   }
 
   // virtualFields
   ClassElts.push_back(fields);
 
   ConstantInt* nbVirtualFields = 
-    ConstantInt::get(Type::Int16Ty, cl->nbVirtualFields);
+    Context.getConstantInt(Type::Int16Ty, cl->nbVirtualFields);
   // nbVirtualFields
   ClassElts.push_back(nbVirtualFields);
   
   // staticFields
   // Output null, getLLVMModule() will be set in  the initializer. Otherwise, the
   // assembly emitter of LLVM will try to align the data.
-  ClassElts.push_back(Mod.getContext().getNullValue(JnjvmModule::JavaFieldType));
+  ClassElts.push_back(Context.getNullValue(JnjvmModule::JavaFieldType));
 
   // nbStaticFields
-  ClassElts.push_back(ConstantInt::get(Type::Int16Ty, cl->nbStaticFields));
+  ClassElts.push_back(Context.getConstantInt(Type::Int16Ty, cl->nbStaticFields));
   
   // virtualMethods
   if (cl->nbVirtualMethods + cl->nbStaticMethods) {
@@ -1069,21 +1081,21 @@
   if (cl->nbVirtualMethods + cl->nbStaticMethods) {
     methods = ConstantArray::get(ATy, TempElts);
     TempElts.clear();
-    GlobalVariable* GV = new GlobalVariable(*getLLVMModule(), ATy, false,
+    GlobalVariable* GV = new GlobalVariable(Mod, ATy, false,
                                             GlobalValue::InternalLinkage,
                                             methods, "");
     virtualMethods.insert(std::make_pair(cl, GV));
     methods = ConstantExpr::getCast(Instruction::BitCast, GV,
                                     JnjvmModule::JavaMethodType);
   } else {
-    methods = Mod.getContext().getNullValue(JnjvmModule::JavaMethodType);
+    methods = Context.getNullValue(JnjvmModule::JavaMethodType);
   }
 
   // virtualMethods
   ClassElts.push_back(methods);
 
   ConstantInt* nbVirtualMethods = 
-    ConstantInt::get(Type::Int16Ty, cl->nbVirtualMethods);
+    Context.getConstantInt(Type::Int16Ty, cl->nbVirtualMethods);
   // nbVirtualMethods
   ClassElts.push_back(nbVirtualMethods);
   
@@ -1092,7 +1104,7 @@
   ClassElts.push_back(Mod.getContext().getNullValue(JnjvmModule::JavaMethodType));
 
   // nbStaticMethods
-  ClassElts.push_back(ConstantInt::get(Type::Int16Ty, cl->nbStaticMethods));
+  ClassElts.push_back(Context.getConstantInt(Type::Int16Ty, cl->nbStaticMethods));
 
   // ownerClass
   ClassElts.push_back(Mod.getContext().getNullValue(JnjvmModule::ptrType));
@@ -1125,7 +1137,7 @@
   }
   
   // nbAttributs
-  ClassElts.push_back(ConstantInt::get(Type::Int16Ty, cl->nbAttributs));
+  ClassElts.push_back(Context.getConstantInt(Type::Int16Ty, cl->nbAttributs));
   
   // innerClasses
   if (cl->nbInnerClasses) {
@@ -1149,7 +1161,7 @@
   }
 
   // nbInnerClasses
-  ClassElts.push_back(ConstantInt::get(Type::Int16Ty, cl->nbInnerClasses));
+  ClassElts.push_back(Context.getConstantInt(Type::Int16Ty, cl->nbInnerClasses));
 
   // outerClass
   if (cl->outerClass) {
@@ -1159,19 +1171,19 @@
   }
 
   // innerAccess
-  ClassElts.push_back(ConstantInt::get(Type::Int16Ty, cl->innerAccess));
+  ClassElts.push_back(Context.getConstantInt(Type::Int16Ty, cl->innerAccess));
   
   // innerOuterResolved
-  ClassElts.push_back(ConstantInt::get(Type::Int8Ty, cl->innerOuterResolved));
+  ClassElts.push_back(Context.getConstantInt(Type::Int8Ty, cl->innerOuterResolved));
   
   // isAnonymous
-  ClassElts.push_back(ConstantInt::get(Type::Int8Ty, cl->isAnonymous));
+  ClassElts.push_back(Context.getConstantInt(Type::Int8Ty, cl->isAnonymous));
   
   // virtualTableSize
-  ClassElts.push_back(ConstantInt::get(Type::Int32Ty, cl->virtualTableSize));
+  ClassElts.push_back(Context.getConstantInt(Type::Int32Ty, cl->virtualTableSize));
   
   // staticSize
-  ClassElts.push_back(ConstantInt::get(Type::Int32Ty, cl->staticSize));
+  ClassElts.push_back(Context.getConstantInt(Type::Int32Ty, cl->staticSize));
 
   // JInfo
   ClassElts.push_back(Mod.getContext().getNullValue(JnjvmModule::ptrType));
@@ -1182,10 +1194,12 @@
 template<typename T>
 Constant* JavaAOTCompiler::CreateConstantFromArray(const T* val, const Type* Ty) {
   Module& Mod = *getLLVMModule();
+  LLVMContext& Context = Mod.getContext();
   std::vector<const Type*> Elemts;
   const ArrayType* ATy = ArrayType::get(Ty, val->size);
   Elemts.push_back(JnjvmModule::JavaObjectType->getContainedType(0));
   Elemts.push_back(JnjvmModule::pointerSizeType);
+  
 
   Elemts.push_back(ATy);
 
@@ -1193,14 +1207,14 @@
   
   std::vector<Constant*> Cts;
   Cts.push_back(CreateConstantForBaseObject(val->getClass()));
-  Cts.push_back(ConstantInt::get(JnjvmModule::pointerSizeType, val->size));
+  Cts.push_back(Context.getConstantInt(JnjvmModule::pointerSizeType, val->size));
   
   std::vector<Constant*> Vals;
   for (sint32 i = 0; i < val->size; ++i) {
     if (Ty->isInteger()) {
-      Vals.push_back(ConstantInt::get(Ty, (uint64)val->elements[i]));
+      Vals.push_back(Context.getConstantInt(Ty, (uint64)val->elements[i]));
     } else if (Ty->isFloatingPoint()) {
-      Vals.push_back(ConstantFP::get(Ty, (double)(size_t)val->elements[i]));
+      Vals.push_back(Context.getConstantFP(Ty, (double)(size_t)val->elements[i]));
     } else {
       if (val->elements[i]) {
         Vals.push_back(getFinalObject((JavaObject*)(size_t)val->elements[i]));
@@ -1216,6 +1230,8 @@
 }
 
 Constant* JavaAOTCompiler::CreateConstantFromUTF8(const UTF8* val) {
+  Module& Mod = *getLLVMModule();
+  LLVMContext& Context = Mod.getContext();
   std::vector<const Type*> Elemts;
   const ArrayType* ATy = ArrayType::get(Type::Int16Ty, val->size);
   Elemts.push_back(JnjvmModule::pointerSizeType);
@@ -1225,11 +1241,11 @@
   const StructType* STy = StructType::get(Elemts);
   
   std::vector<Constant*> Cts;
-  Cts.push_back(ConstantInt::get(JnjvmModule::pointerSizeType, val->size));
+  Cts.push_back(Context.getConstantInt(JnjvmModule::pointerSizeType, val->size));
   
   std::vector<Constant*> Vals;
   for (sint32 i = 0; i < val->size; ++i) {
-    Vals.push_back(ConstantInt::get(Type::Int16Ty, val->elements[i]));
+    Vals.push_back(Context.getConstantInt(Type::Int16Ty, val->elements[i]));
   }
 
   Cts.push_back(ConstantArray::get(ATy, Vals));
@@ -1260,6 +1276,7 @@
 
 Constant* JavaAOTCompiler::CreateConstantFromVT(JavaVirtualTable* VT) {
   Module& Mod = *getLLVMModule();
+  LLVMContext& Context = Mod.getContext();
   CommonClass* classDef = VT->cl;
   uint32 size = classDef->isClass() ? classDef->asClass()->virtualTableSize :
                                       JavaVirtualTable::getBaseSize();
@@ -1309,11 +1326,11 @@
 
   // depth
   Elemts.push_back(ConstantExpr::getIntToPtr(
-        ConstantInt::get(Type::Int64Ty, VT->depth), PTy));
+        Context.getConstantInt(Type::Int64Ty, VT->depth), PTy));
   
   // offset
   Elemts.push_back(ConstantExpr::getIntToPtr(
-        ConstantInt::get(Type::Int64Ty, VT->offset), PTy));
+        Context.getConstantInt(Type::Int64Ty, VT->offset), PTy));
   
   // cache
   Elemts.push_back(N);
@@ -1331,7 +1348,7 @@
   
   // nbSecondaryTypes
   Elemts.push_back(ConstantExpr::getIntToPtr(
-        ConstantInt::get(Type::Int64Ty, VT->nbSecondaryTypes), PTy));
+        Context.getConstantInt(Type::Int64Ty, VT->nbSecondaryTypes), PTy));
   
   // secondaryTypes
   const ArrayType* DTy = ArrayType::get(JnjvmModule::VTType,
@@ -1461,7 +1478,7 @@
   
     
     Constant* cons = 
-      ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
+      ConstantExpr::getIntToPtr(Context.getConstantInt(Type::Int64Ty,
                                                  uint64_t(isolate)),
                                 ptrType);
 
@@ -1886,6 +1903,8 @@
 }
 
 void JavaAOTCompiler::generateMain(const char* name, bool jit) {
+  Module& Mod = *getLLVMModule();
+  LLVMContext& Context = Mod.getContext();
 
   // Type Definitions
   std::vector<const Type*> FuncArgs;
@@ -1903,7 +1922,7 @@
     GlobalValue::InternalLinkage, 0, "mainClass");
 
 
-  Constant* NameArray = ConstantArray::get(name, true);
+  Constant* NameArray = Context.getConstantArray(name, true);
   GvarArrayStr->setInitializer(NameArray);
   Value* Indices[2] = { JavaIntrinsics.constantZero,
                         JavaIntrinsics.constantZero };

Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp?rev=75784&r1=75783&r2=75784&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp Wed Jul 15 08:31:22 2009
@@ -158,7 +158,7 @@
     Constant* Offset = LMI->getOffset();
     indexes2[1] = Offset;
 #ifdef ISOLATE_SHARING
-    indexesCtp = ConstantInt::get(Type::Int32Ty,
+    indexesCtp = llvmContext->getConstantInt(Type::Int32Ty,
                                   Offset->getZExtValue() * -1);
 #endif
   } else {
@@ -371,7 +371,7 @@
   // this problem because it passes first arguments in registers.
   // Therefore, it was overwriting the frame pointer when entering the
   // native method.
-  Value* Temp = new AllocaInst(module->ptrType, "", currentBlock);
+  Value* Temp = new AllocaInst(*llvmContext, module->ptrType, "", currentBlock);
   new StoreInst(FrameAddr, Temp, currentBlock);
   Value* result = llvm::CallInst::Create(nativeFunc, nativeArgs.begin(),
                                          nativeArgs.end(), "", currentBlock);
@@ -445,8 +445,8 @@
 
   // It's a thin lock. Look if we're the owner of this lock.
   currentBlock = ThinLockBB;
-  Value* idMask = ConstantInt::get(module->pointerSizeType, 0x7FFFFF00);
-  Value* cptMask = ConstantInt::get(module->pointerSizeType, 0xFF);
+  Value* idMask = llvmContext->getConstantInt(module->pointerSizeType, 0x7FFFFF00);
+  Value* cptMask = llvmContext->getConstantInt(module->pointerSizeType, 0xFF);
   Value* IdInLock = BinaryOperator::CreateAnd(atomic, idMask, "", currentBlock);
   Value* owner = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, threadId,
                               IdInLock, "");
@@ -637,21 +637,21 @@
     Instruction* firstInstruction = firstBB->begin();
 
     for (int i = 0; i < maxLocals; i++) {
-      intLocals.push_back(new AllocaInst(Type::Int32Ty, "", firstInstruction));
-      doubleLocals.push_back(new AllocaInst(Type::DoubleTy, "",
+      intLocals.push_back(new AllocaInst(*llvmContext, Type::Int32Ty, "", firstInstruction));
+      doubleLocals.push_back(new AllocaInst(*llvmContext, Type::DoubleTy, "",
                                             firstInstruction));
-      longLocals.push_back(new AllocaInst(Type::Int64Ty, "", firstInstruction));
-      floatLocals.push_back(new AllocaInst(Type::FloatTy, "", firstInstruction));
-      objectLocals.push_back(new AllocaInst(module->JavaObjectType, "",
+      longLocals.push_back(new AllocaInst(*llvmContext, Type::Int64Ty, "", firstInstruction));
+      floatLocals.push_back(new AllocaInst(*llvmContext, Type::FloatTy, "", firstInstruction));
+      objectLocals.push_back(new AllocaInst(*llvmContext, module->JavaObjectType, "",
                                           firstInstruction));
     }
   } else {
     for (int i = 0; i < maxLocals; i++) {
-      intLocals.push_back(new AllocaInst(Type::Int32Ty, "", firstBB));
-      doubleLocals.push_back(new AllocaInst(Type::DoubleTy, "", firstBB));
-      longLocals.push_back(new AllocaInst(Type::Int64Ty, "", firstBB));
-      floatLocals.push_back(new AllocaInst(Type::FloatTy, "", firstBB));
-      objectLocals.push_back(new AllocaInst(module->JavaObjectType, "",
+      intLocals.push_back(new AllocaInst(*llvmContext, Type::Int32Ty, "", firstBB));
+      doubleLocals.push_back(new AllocaInst(*llvmContext, Type::DoubleTy, "", firstBB));
+      longLocals.push_back(new AllocaInst(*llvmContext, Type::Int64Ty, "", firstBB));
+      floatLocals.push_back(new AllocaInst(*llvmContext, Type::FloatTy, "", firstBB));
+      objectLocals.push_back(new AllocaInst(*llvmContext, module->JavaObjectType, "",
                                             firstBB));
     }
   }
@@ -775,11 +775,11 @@
   
 
   for (int i = 0; i < maxLocals; i++) {
-    intLocals.push_back(new AllocaInst(Type::Int32Ty, "", currentBlock));
-    doubleLocals.push_back(new AllocaInst(Type::DoubleTy, "", currentBlock));
-    longLocals.push_back(new AllocaInst(Type::Int64Ty, "", currentBlock));
-    floatLocals.push_back(new AllocaInst(Type::FloatTy, "", currentBlock));
-    objectLocals.push_back(new AllocaInst(module->JavaObjectType, "",
+    intLocals.push_back(new AllocaInst(*llvmContext, Type::Int32Ty, "", currentBlock));
+    doubleLocals.push_back(new AllocaInst(*llvmContext, Type::DoubleTy, "", currentBlock));
+    longLocals.push_back(new AllocaInst(*llvmContext, Type::Int64Ty, "", currentBlock));
+    floatLocals.push_back(new AllocaInst(*llvmContext, Type::FloatTy, "", currentBlock));
+    objectLocals.push_back(new AllocaInst(*llvmContext, module->JavaObjectType, "",
                                           currentBlock));
   }
 
@@ -831,7 +831,7 @@
 
 #if defined(ISOLATE_SHARING)
   ctpCache = i;
-  Value* addrCtpCache = new AllocaInst(module->ConstantPoolType, "",
+  Value* addrCtpCache = new AllocaInst(*llvmContext, module->ConstantPoolType, "",
                                        currentBlock);
   /// make it volatile to be sure it's on the stack
   new StoreInst(ctpCache, addrCtpCache, true, currentBlock);
@@ -857,7 +857,7 @@
                                    currentBlock);
     OldIsolateID = new LoadInst(IsolateIDPtr, "", currentBlock);
 
-    Value* MyID = ConstantInt::get(module->pointerSizeType,
+    Value* MyID = llvmContext->getConstantInt(module->pointerSizeType,
                                    loader->getIsolate()->IsolateID);
     Cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, OldIsolateID, MyID,
                        "");
@@ -1065,16 +1065,16 @@
 #endif
         
   } else if (type == JavaConstantPool::ConstantLong) {
-    push(ConstantInt::get(Type::Int64Ty, ctpInfo->LongAt(index)),
+    push(llvmContext->getConstantInt(Type::Int64Ty, ctpInfo->LongAt(index)),
          false);
   } else if (type == JavaConstantPool::ConstantDouble) {
-    push(ConstantFP::get(Type::DoubleTy, ctpInfo->DoubleAt(index)),
+    push(llvmContext->getConstantFP(Type::DoubleTy, ctpInfo->DoubleAt(index)),
          false);
   } else if (type == JavaConstantPool::ConstantInteger) {
-    push(ConstantInt::get(Type::Int32Ty, ctpInfo->IntegerAt(index)),
+    push(llvmContext->getConstantInt(Type::Int32Ty, ctpInfo->IntegerAt(index)),
          false);
   } else if (type == JavaConstantPool::ConstantFloat) {
-    push(ConstantFP::get(Type::FloatTy, ctpInfo->FloatAt(index)),
+    push(llvmContext->getConstantFP(Type::FloatTy, ctpInfo->FloatAt(index)),
          false);
   } else if (type == JavaConstantPool::ConstantClass) {
     UserCommonClass* cl = 0;
@@ -1404,7 +1404,7 @@
   BranchInst::Create(falseCl, trueCl, test, currentBlock);
   std::vector<Value*> Args;
   Args.push_back(ctpCache);
-  Args.push_back(ConstantInt::get(Type::Int32Ty, index));
+  Args.push_back(llvmContext->getConstantInt(Type::Int32Ty, index));
   Args.push_back(GV);
   res = CallInst::Create(module->SpecialCtpLookupFunction, Args.begin(),
                          Args.end(), "", falseCl);
@@ -1532,7 +1532,7 @@
   Args.push_back(resolver);
   Args.push_back(CTP);
   Args.push_back(Cl);
-  Args.push_back(ConstantInt::get(Type::Int32Ty, index));
+  Args.push_back(llvmContext->getConstantInt(Type::Int32Ty, index));
   if (additionalArg) Args.push_back(additionalArg);
 
   Value* res = 0;
@@ -1774,28 +1774,28 @@
         const PrimitiveTypedef* prim = (PrimitiveTypedef*)sign;
         if (prim->isInt()) {
           sint32 val = field->getInt32Field(Obj);
-          push(ConstantInt::get(Type::Int32Ty, val), false);
+          push(llvmContext->getConstantInt(Type::Int32Ty, val), false);
         } else if (prim->isByte()) {
           sint8 val = (sint8)field->getInt8Field(Obj);
-          push(ConstantInt::get(Type::Int8Ty, val), false);
+          push(llvmContext->getConstantInt(Type::Int8Ty, val), false);
         } else if (prim->isBool()) {
           uint8 val = (uint8)field->getInt8Field(Obj);
-          push(ConstantInt::get(Type::Int8Ty, val), true);
+          push(llvmContext->getConstantInt(Type::Int8Ty, val), true);
         } else if (prim->isShort()) {
           sint16 val = (sint16)field->getInt16Field(Obj);
-          push(ConstantInt::get(Type::Int16Ty, val), false);
+          push(llvmContext->getConstantInt(Type::Int16Ty, val), false);
         } else if (prim->isChar()) {
           uint16 val = (uint16)field->getInt16Field(Obj);
-          push(ConstantInt::get(Type::Int16Ty, val), true);
+          push(llvmContext->getConstantInt(Type::Int16Ty, val), true);
         } else if (prim->isLong()) {
           sint64 val = (sint64)field->getLongField(Obj);
-          push(ConstantInt::get(Type::Int64Ty, val), false);
+          push(llvmContext->getConstantInt(Type::Int64Ty, val), false);
         } else if (prim->isFloat()) {
           float val = (float)field->getFloatField(Obj);
-          push(ConstantFP::get(Type::FloatTy, val), false);
+          push(llvmContext->getConstantFP(Type::FloatTy, val), false);
         } else if (prim->isDouble()) {
           double val = (double)field->getDoubleField(Obj);
-          push(ConstantFP::get(Type::DoubleTy, val), false);
+          push(llvmContext->getConstantFP(Type::DoubleTy, val), false);
         } else {
           abort();
         }

Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp?rev=75784&r1=75783&r2=75784&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp Wed Jul 15 08:31:22 2009
@@ -29,41 +29,47 @@
 using namespace llvm;
 
 Constant* JavaJITCompiler::getNativeClass(CommonClass* classDef) {
+  LLVMContext& Context = getLLVMModule()->getContext();
   const llvm::Type* Ty = classDef->isClass() ? JnjvmModule::JavaClassType :
                                                JnjvmModule::JavaCommonClassType;
   
-  ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64_t(classDef));
+  ConstantInt* CI = Context.getConstantInt(Type::Int64Ty, uint64_t(classDef));
   return ConstantExpr::getIntToPtr(CI, Ty);
 }
 
 Constant* JavaJITCompiler::getConstantPool(JavaConstantPool* ctp) {
   void* ptr = ctp->ctpRes;
   assert(ptr && "No constant pool found");
-  ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64_t(ptr));
+  LLVMContext& Context = getLLVMModule()->getContext();
+  ConstantInt* CI = Context.getConstantInt(Type::Int64Ty, uint64_t(ptr));
   return ConstantExpr::getIntToPtr(CI, JnjvmModule::ConstantPoolType);
 }
 
 Constant* JavaJITCompiler::getMethodInClass(JavaMethod* meth) {
-  ConstantInt* CI = ConstantInt::get(Type::Int64Ty, (int64_t)meth);
+  LLVMContext& Context = getLLVMModule()->getContext();
+  ConstantInt* CI = Context.getConstantInt(Type::Int64Ty, (int64_t)meth);
   return ConstantExpr::getIntToPtr(CI, JnjvmModule::JavaMethodType);
 }
 
 Constant* JavaJITCompiler::getString(JavaString* str) {
   assert(str && "No string given");
-  ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64(str));
+  LLVMContext& Context = getLLVMModule()->getContext();
+  ConstantInt* CI = Context.getConstantInt(Type::Int64Ty, uint64(str));
   return ConstantExpr::getIntToPtr(CI, JnjvmModule::JavaObjectType);
 }
 
 Constant* JavaJITCompiler::getEnveloppe(Enveloppe* enveloppe) {
   assert(enveloppe && "No enveloppe given");
-  ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64(enveloppe));
+  LLVMContext& Context = getLLVMModule()->getContext();
+  ConstantInt* CI = Context.getConstantInt(Type::Int64Ty, uint64(enveloppe));
   return ConstantExpr::getIntToPtr(CI, JnjvmModule::EnveloppeType);
 }
 
 Constant* JavaJITCompiler::getJavaClass(CommonClass* cl) {
   JavaObject* obj = cl->getClassDelegatee(JavaThread::get()->getJVM());
   assert(obj && "Delegatee not created");
-  Constant* CI = ConstantInt::get(Type::Int64Ty, uint64(obj));
+  LLVMContext& Context = getLLVMModule()->getContext();
+  Constant* CI = Context.getConstantInt(Type::Int64Ty, uint64(obj));
   return ConstantExpr::getIntToPtr(CI, JnjvmModule::JavaObjectType);
 }
 
@@ -77,11 +83,13 @@
 }
 
 Constant* JavaJITCompiler::getFinalObject(JavaObject* obj) {
-  Constant* CI = ConstantInt::get(Type::Int64Ty, uint64(obj));
+  LLVMContext& Context = getLLVMModule()->getContext();
+  Constant* CI = Context.getConstantInt(Type::Int64Ty, uint64(obj));
   return ConstantExpr::getIntToPtr(CI, JnjvmModule::JavaObjectType);
 }
 
 Constant* JavaJITCompiler::getStaticInstance(Class* classDef) {
+  LLVMContext& Context = getLLVMModule()->getContext();
 #ifdef ISOLATE
   assert(0 && "Should not be here");
   abort();
@@ -96,27 +104,29 @@
     }
     classDef->release();
   }
-  Constant* CI = ConstantInt::get(Type::Int64Ty, (uint64_t(obj)));
+  Constant* CI = Context.getConstantInt(Type::Int64Ty, (uint64_t(obj)));
   return ConstantExpr::getIntToPtr(CI, JnjvmModule::ptrType);
 }
 
 Constant* JavaJITCompiler::getVirtualTable(JavaVirtualTable* VT) {
+  LLVMContext& Context = getLLVMModule()->getContext();
   if (VT->cl->isClass()) {
     LLVMClassInfo* LCI = getClassInfo(VT->cl->asClass());
     LCI->getVirtualType();
   }
   
-  ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64_t(VT));
+  ConstantInt* CI = Context.getConstantInt(Type::Int64Ty, uint64_t(VT));
   return ConstantExpr::getIntToPtr(CI, JnjvmModule::VTType);
 }
 
 Constant* JavaJITCompiler::getNativeFunction(JavaMethod* meth, void* ptr) {
+  LLVMContext& Context = getLLVMModule()->getContext();
   LLVMSignatureInfo* LSI = getSignatureInfo(meth->getSignature());
   const llvm::Type* valPtrType = LSI->getNativePtrType();
   
   assert(ptr && "No native function given");
 
-  Constant* CI = ConstantInt::get(Type::Int64Ty, uint64_t(ptr));
+  Constant* CI = Context.getConstantInt(Type::Int64Ty, uint64_t(ptr));
   return ConstantExpr::getIntToPtr(CI, valPtrType);
 }
 
@@ -134,7 +144,8 @@
 
 #ifdef SERVICE
 Value* JavaJITCompiler::getIsolate(Jnjvm* isolate, Value* Where) {
-  ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64_t(isolate));
+  LLVMContext& Context = getLLVMModule()->getContext();
+  ConstantInt* CI = Context.getConstantInt(Type::Int64Ty, uint64_t(isolate));
   return ConstantExpr::getIntToPtr(CI, JnjvmModule::ptrType);
 }
 #endif

Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp?rev=75784&r1=75783&r2=75784&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp Wed Jul 15 08:31:22 2009
@@ -161,8 +161,8 @@
 #if JNJVM_EXECUTE > 1
     {
       Value* args[3] = {
-        ConstantInt::get(Type::Int32Ty, (int64_t)bytecodes[i]),
-        ConstantInt::get(Type::Int32Ty, (int64_t)i),
+        llvmContext->getConstantInt(Type::Int32Ty, (int64_t)bytecodes[i]),
+        llvmContext->getConstantInt(Type::Int32Ty, (int64_t)i),
         TheCompiler->getMethodInClass(compilingMethod)
       };
     
@@ -241,13 +241,13 @@
         break;
 
       case BIPUSH : 
-        push(ConstantExpr::getSExt(ConstantInt::get(Type::Int8Ty,
+        push(ConstantExpr::getSExt(llvmContext->getConstantInt(Type::Int8Ty,
                                                     bytecodes[++i]),
                                    Type::Int32Ty), false);
         break;
 
       case SIPUSH :
-        push(ConstantExpr::getSExt(ConstantInt::get(Type::Int16Ty,
+        push(ConstantExpr::getSExt(llvmContext->getConstantInt(Type::Int16Ty,
                                                     readS2(bytecodes, i)),
                                    Type::Int32Ty), false);
         break;
@@ -1098,7 +1098,7 @@
       case IUSHR : {
         Value* val2 = popAsInt();
         Value* val1 = popAsInt();
-        Value* mask = ConstantInt::get(Type::Int32Ty, 0x1F);
+        Value* mask = llvmContext->getConstantInt(Type::Int32Ty, 0x1F);
         val2 = BinaryOperator::CreateAnd(val2, mask, "", currentBlock);
         push(BinaryOperator::CreateLShr(val1, val2, "", currentBlock),
              false);
@@ -1107,7 +1107,7 @@
 
       case LUSHR : {
         Value* val2 = new ZExtInst(pop(), Type::Int64Ty, "", currentBlock);
-        Value* mask = ConstantInt::get(Type::Int64Ty, 0x3F);
+        Value* mask = llvmContext->getConstantInt(Type::Int64Ty, 0x3F);
         val2 = BinaryOperator::CreateAnd(val2, mask, "", currentBlock);
         pop(); // remove the 0 on the stack
         Value* val1 = pop();
@@ -1179,7 +1179,7 @@
         sint16 val = WREAD_S1(bytecodes, false, i, wide);
         llvm::Value* add = BinaryOperator::CreateAdd(
             new LoadInst(intLocals[idx], "", currentBlock), 
-            ConstantInt::get(Type::Int32Ty, val), "",
+            llvmContext->getConstantInt(Type::Int32Ty, val), "",
             currentBlock);
         new StoreInst(add, intLocals[idx], false, currentBlock);
         break;
@@ -1715,7 +1715,7 @@
       case JSR : {
         uint32 tmp = i;
         Value* expr = ConstantExpr::getIntToPtr(
-                                    ConstantInt::get(Type::Int64Ty,
+                                    llvmContext->getConstantInt(Type::Int64Ty,
                                                      uint64_t (jsrIndex++)),
                                     module->JavaObjectType);
         push(expr, false);
@@ -1734,7 +1734,7 @@
         uint32 index = 0;
         for (std::vector<BasicBlock*>::iterator i = jsrs.begin(), 
             e = jsrs.end(); i!= e; ++i, ++index) {
-          inst->addCase(ConstantInt::get(Type::Int32Ty, index), *i);
+          inst->addCase(llvmContext->getConstantInt(Type::Int32Ty, index), *i);
         }
 
         break;
@@ -1755,7 +1755,7 @@
         const llvm::Type* type = index->getType();
         for (sint32 cur = low; cur < high; ++cur) {
           Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ,
-                                    ConstantInt::get(type, cur), index, "");
+                                    llvmContext->getConstantInt(type, cur), index, "");
           BasicBlock* falseBlock = createBasicBlock("continue tableswitch");
           branch(cmp, opcodeInfos[tmp + readU4(bytecodes, i)].newBlock,
                  falseBlock, currentBlock);
@@ -1785,7 +1785,7 @@
           key = new SExtInst(key, Type::Int32Ty, "", currentBlock);
         }
         for (uint32 cur = 0; cur < nbs; ++cur) {
-          Value* val = ConstantInt::get(Type::Int32Ty, readU4(bytecodes, i));
+          Value* val = llvmContext->getConstantInt(Type::Int32Ty, readU4(bytecodes, i));
           Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val, key,
                                     "");
           BasicBlock* falseBlock = createBasicBlock("continue lookupswitch");
@@ -1904,7 +1904,7 @@
           valCl = TheCompiler->getNativeClass(dcl);
 #else
           Value* args[2] = { isolateLocal,
-                             ConstantInt::get(Type::Int32Ty, id - 4) };
+                             llvmContext->getConstantInt(Type::Int32Ty, id - 4) };
           valCl = CallInst::Create(module->GetJnjvmArrayClassFunction,
                                    args, args + 2, "", currentBlock);
 #endif
@@ -2055,7 +2055,7 @@
         } else {
           BasicBlock* ifFalse = createBasicBlock("false type compare");
           BranchInst::Create(endBlock, ifFalse, cmp, currentBlock);
-          node->addIncoming(ConstantInt::getFalse(), currentBlock);
+          node->addIncoming(llvmContext->getConstantIntFalse(), currentBlock);
           currentBlock = ifFalse;
         }
 
@@ -2083,7 +2083,7 @@
                                                 objVT, "", currentBlock);
             
             uint32 depth = cl->virtualVT->depth;
-            ConstantInt* CI = ConstantInt::get(Type::Int32Ty, depth);
+            ConstantInt* CI = llvmContext->getConstantInt(Type::Int32Ty, depth);
             Value* displayArgs[2] = { inDisplay, CI };
             Value* VTInDisplay = 
               CallInst::Create(module->GetVTInDisplayFunction,
@@ -2138,7 +2138,7 @@
         Value* valCl = getResolvedCommonClass(index, true, 0);
         Value** args = (Value**)alloca(sizeof(Value*) * (dim + 2));
         args[0] = valCl;
-        args[1] = ConstantInt::get(Type::Int32Ty, dim);
+        args[1] = llvmContext->getConstantInt(Type::Int32Ty, dim);
 
         for (int cur = dim + 1; cur >= 2; --cur)
           args[cur] = pop();

Modified: vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp?rev=75784&r1=75783&r2=75784&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp Wed Jul 15 08:31:22 2009
@@ -113,6 +113,7 @@
 
 void JnjvmModule::initialise() {
   Module* module = globalModule;
+  LLVMContext& Context = module->getContext();
   jnjvm::llvm_runtime::makeLLVMModuleContents(module);
 
   VTType = PointerType::getUnqual(module->getTypeByName("VT"));
@@ -178,10 +179,10 @@
 
   JavaObjectNullConstant =
     module->getContext().getNullValue(JnjvmModule::JavaObjectType);
-  MaxArraySizeConstant = ConstantInt::get(Type::Int32Ty,
+  MaxArraySizeConstant = Context.getConstantInt(Type::Int32Ty,
                                           JavaArray::MaxArraySize);
   JavaArraySizeConstant = 
-    ConstantInt::get(Type::Int32Ty, sizeof(JavaObject) + sizeof(ssize_t));
+    Context.getConstantInt(Type::Int32Ty, sizeof(JavaObject) + sizeof(ssize_t));
   
   
   JavaArrayElementsOffsetConstant = mvm::MvmModule::constantTwo;
@@ -191,19 +192,19 @@
   OffsetClassInVTConstant = mvm::MvmModule::constantThree;
   OffsetDepthInVTConstant = mvm::MvmModule::constantFour;
   OffsetDisplayInVTConstant = mvm::MvmModule::constantSeven;
-  OffsetBaseClassVTInVTConstant = ConstantInt::get(Type::Int32Ty, 17);
+  OffsetBaseClassVTInVTConstant = Context.getConstantInt(Type::Int32Ty, 17);
   
   OffsetObjectSizeInClassConstant = mvm::MvmModule::constantOne;
-  OffsetVTInClassConstant = ConstantInt::get(Type::Int32Ty, 7);
+  OffsetVTInClassConstant = Context.getConstantInt(Type::Int32Ty, 7);
   OffsetTaskClassMirrorInClassConstant = mvm::MvmModule::constantTwo;
   OffsetStaticInstanceInTaskClassMirrorConstant = mvm::MvmModule::constantTwo;
   OffsetStatusInTaskClassMirrorConstant = mvm::MvmModule::constantZero;
   OffsetInitializedInTaskClassMirrorConstant = mvm::MvmModule::constantOne;
   
-  OffsetJavaExceptionInThreadConstant = ConstantInt::get(Type::Int32Ty, 9);
-  OffsetCXXExceptionInThreadConstant = ConstantInt::get(Type::Int32Ty, 10);
+  OffsetJavaExceptionInThreadConstant = Context.getConstantInt(Type::Int32Ty, 9);
+  OffsetCXXExceptionInThreadConstant = Context.getConstantInt(Type::Int32Ty, 10);
   
-  ClassReadyConstant = ConstantInt::get(Type::Int8Ty, ready);
+  ClassReadyConstant = Context.getConstantInt(Type::Int8Ty, ready);
  
   LLVMAssessorInfo::initialise();
 }

Modified: vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp?rev=75784&r1=75783&r2=75784&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp Wed Jul 15 08:31:22 2009
@@ -119,6 +119,7 @@
   JavaLLVMCompiler* TheCompiler = 
     (JavaLLVMCompiler*)meth->classDef->classLoader->getCompiler();
   JnjvmModule* module = TheCompiler->getIntrinsics();
+  LLVMContext* Context = F.getContext();
   bool Changed = false;
   for (Function::iterator BI = F.begin(), BE = F.end(); BI != BE; BI++) { 
     BasicBlock *Cur = BI; 
@@ -408,7 +409,7 @@
           ConstantInt* Cons = dyn_cast<ConstantInt>(Index);
           assert(CI && "Wrong use of GetConstantPoolAt");
           uint64 val = Cons->getZExtValue();
-          Value* indexes = ConstantInt::get(Type::Int32Ty, val + 1);
+          Value* indexes = Context->getConstantInt(Type::Int32Ty, val + 1);
 #else
           Value* indexes = Index;
 #endif
@@ -535,7 +536,7 @@
           BasicBlock* FailedBlock = BasicBlock::Create("", &F);
           PHINode* node = PHINode::Create(Type::Int1Ty, "", CurEndBlock);
 
-          ConstantInt* CC = ConstantInt::get(Type::Int32Ty,
+          ConstantInt* CC = Context->getConstantInt(Type::Int32Ty,
               JavaVirtualTable::getOffsetIndex());
           Value* indices[2] = { module->constantZero, CC };
           Value* Offset = GetElementPtrInst::Create(VT2, indices, indices + 2,
@@ -593,7 +594,7 @@
           //    if (VT1.cache == VT2 || VT1 == VT2) goto end with true;
           //    else goto headerLoop;
           ConstantInt* cacheIndex = 
-            ConstantInt::get(Type::Int32Ty, JavaVirtualTable::getCacheIndex());
+            Context->getConstantInt(Type::Int32Ty, JavaVirtualTable::getCacheIndex());
           Value* indices[2] = { module->constantZero, cacheIndex };
           Instruction* CachePtr = 
             GetElementPtrInst::Create(VT1, indices, indices + 2, "", CI);
@@ -611,7 +612,7 @@
           //    size = VT1->nbSecondaryTypes;
           //    i = 0;
           //    goto test;
-          ConstantInt* sizeIndex = ConstantInt::get(Type::Int32Ty, 
+          ConstantInt* sizeIndex = Context->getConstantInt(Type::Int32Ty, 
               JavaVirtualTable::getNumSecondaryTypesIndex());
           indices[1] = sizeIndex;
           Instruction* Size = GetElementPtrInst::Create(VT1, indices,
@@ -620,7 +621,7 @@
           Size = new LoadInst(Size, "", false, Preheader);
           Size = new PtrToIntInst(Size, Type::Int32Ty, "", Preheader);
     
-          ConstantInt* secondaryTypesIndex = ConstantInt::get(Type::Int32Ty, 
+          ConstantInt* secondaryTypesIndex = Context->getConstantInt(Type::Int32Ty, 
               JavaVirtualTable::getSecondaryTypesIndex());
           indices[1] = secondaryTypesIndex;
           Instruction* secondaryTypes = 

Modified: vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp?rev=75784&r1=75783&r2=75784&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp (original)
+++ vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp Wed Jul 15 08:31:22 2009
@@ -168,6 +168,7 @@
 bool EscapeAnalysis::processMalloc(Instruction* I, Value* Size, Value* VT,
                                    Loop* CurLoop) {
   Instruction* Alloc = I;
+  LLVMContext* Context = I->getParent()->getContext();
   
   ConstantInt* CI = dyn_cast<ConstantInt>(Size);
   bool hasFinalizer = true;
@@ -219,7 +220,7 @@
         BB->getInstList().insert(BB->getTerminator(), Alloc);
       }
 
-      AllocaInst* AI = new AllocaInst(Type::Int8Ty, Size, "", Alloc);
+      AllocaInst* AI = new AllocaInst(*Context, Type::Int8Ty, Size, "", Alloc);
       BitCastInst* BI = new BitCastInst(AI, Alloc->getType(), "", Alloc);
       DOUT << "escape" << Alloc->getParent()->getParent()->getName() << "\n";
       Alloc->replaceAllUsesWith(BI);

Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=75784&r1=75783&r2=75784&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original)
+++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Wed Jul 15 08:31:22 2009
@@ -87,55 +87,55 @@
     Type::Int32Ty : Type::Int64Ty;
   
   // Constant declaration
-  constantLongMinusOne = ConstantInt::get(Type::Int64Ty, (uint64_t)-1);
-  constantLongZero = ConstantInt::get(Type::Int64Ty, 0);
-  constantLongOne = ConstantInt::get(Type::Int64Ty, 1);
-  constantZero = ConstantInt::get(Type::Int32Ty, 0);
-  constantInt8Zero = ConstantInt::get(Type::Int8Ty, 0);
-  constantOne = ConstantInt::get(Type::Int32Ty, 1);
-  constantTwo = ConstantInt::get(Type::Int32Ty, 2);
-  constantThree = ConstantInt::get(Type::Int32Ty, 3);
-  constantFour = ConstantInt::get(Type::Int32Ty, 4);
-  constantFive = ConstantInt::get(Type::Int32Ty, 5);
-  constantSix = ConstantInt::get(Type::Int32Ty, 6);
-  constantSeven = ConstantInt::get(Type::Int32Ty, 7);
-  constantEight = ConstantInt::get(Type::Int32Ty, 8);
-  constantMinusOne = ConstantInt::get(Type::Int32Ty, (uint64_t)-1);
-  constantMinInt = ConstantInt::get(Type::Int32Ty, MinInt);
-  constantMaxInt = ConstantInt::get(Type::Int32Ty, MaxInt);
-  constantMinLong = ConstantInt::get(Type::Int64Ty, MinLong);
-  constantMaxLong = ConstantInt::get(Type::Int64Ty, MaxLong);
-  constantFloatZero = ConstantFP::get(Type::FloatTy, 0.0f);
-  constantFloatOne = ConstantFP::get(Type::FloatTy, 1.0f);
-  constantFloatTwo = ConstantFP::get(Type::FloatTy, 2.0f);
-  constantDoubleZero = ConstantFP::get(Type::DoubleTy, 0.0);
-  constantDoubleOne = ConstantFP::get(Type::DoubleTy, 1.0);
-  constantMaxIntFloat = ConstantFP::get(Type::FloatTy, MaxIntFloat);
-  constantMinIntFloat = ConstantFP::get(Type::FloatTy, MinIntFloat);
-  constantMinLongFloat = ConstantFP::get(Type::FloatTy, MinLongFloat);
-  constantMinLongDouble = ConstantFP::get(Type::DoubleTy, MinLongDouble);
-  constantMaxLongFloat = ConstantFP::get(Type::FloatTy, MaxLongFloat);
-  constantMaxIntDouble = ConstantFP::get(Type::DoubleTy, MaxIntDouble);
-  constantMinIntDouble = ConstantFP::get(Type::DoubleTy, MinIntDouble);
-  constantMaxLongDouble = ConstantFP::get(Type::DoubleTy, MaxLongDouble);
-  constantMaxLongDouble = ConstantFP::get(Type::DoubleTy, MaxLongDouble);
-  constantFloatInfinity = ConstantFP::get(Type::FloatTy, MaxFloat);
-  constantFloatMinusInfinity = ConstantFP::get(Type::FloatTy, MinFloat);
-  constantDoubleInfinity = ConstantFP::get(Type::DoubleTy, MaxDouble);
-  constantDoubleMinusInfinity = ConstantFP::get(Type::DoubleTy, MinDouble);
-  constantDoubleMinusZero = ConstantFP::get(Type::DoubleTy, -0.0);
-  constantFloatMinusZero = ConstantFP::get(Type::FloatTy, -0.0f);
-  constantThreadIDMask = ConstantInt::get(pointerSizeType, mvm::Thread::IDMask);
+  constantLongMinusOne = globalContext->getConstantInt(Type::Int64Ty, (uint64_t)-1);
+  constantLongZero = globalContext->getConstantInt(Type::Int64Ty, 0);
+  constantLongOne = globalContext->getConstantInt(Type::Int64Ty, 1);
+  constantZero = globalContext->getConstantInt(Type::Int32Ty, 0);
+  constantInt8Zero = globalContext->getConstantInt(Type::Int8Ty, 0);
+  constantOne = globalContext->getConstantInt(Type::Int32Ty, 1);
+  constantTwo = globalContext->getConstantInt(Type::Int32Ty, 2);
+  constantThree = globalContext->getConstantInt(Type::Int32Ty, 3);
+  constantFour = globalContext->getConstantInt(Type::Int32Ty, 4);
+  constantFive = globalContext->getConstantInt(Type::Int32Ty, 5);
+  constantSix = globalContext->getConstantInt(Type::Int32Ty, 6);
+  constantSeven = globalContext->getConstantInt(Type::Int32Ty, 7);
+  constantEight = globalContext->getConstantInt(Type::Int32Ty, 8);
+  constantMinusOne = globalContext->getConstantInt(Type::Int32Ty, (uint64_t)-1);
+  constantMinInt = globalContext->getConstantInt(Type::Int32Ty, MinInt);
+  constantMaxInt = globalContext->getConstantInt(Type::Int32Ty, MaxInt);
+  constantMinLong = globalContext->getConstantInt(Type::Int64Ty, MinLong);
+  constantMaxLong = globalContext->getConstantInt(Type::Int64Ty, MaxLong);
+  constantFloatZero = globalContext->getConstantFP(Type::FloatTy, 0.0f);
+  constantFloatOne = globalContext->getConstantFP(Type::FloatTy, 1.0f);
+  constantFloatTwo = globalContext->getConstantFP(Type::FloatTy, 2.0f);
+  constantDoubleZero = globalContext->getConstantFP(Type::DoubleTy, 0.0);
+  constantDoubleOne = globalContext->getConstantFP(Type::DoubleTy, 1.0);
+  constantMaxIntFloat = globalContext->getConstantFP(Type::FloatTy, MaxIntFloat);
+  constantMinIntFloat = globalContext->getConstantFP(Type::FloatTy, MinIntFloat);
+  constantMinLongFloat = globalContext->getConstantFP(Type::FloatTy, MinLongFloat);
+  constantMinLongDouble = globalContext->getConstantFP(Type::DoubleTy, MinLongDouble);
+  constantMaxLongFloat = globalContext->getConstantFP(Type::FloatTy, MaxLongFloat);
+  constantMaxIntDouble = globalContext->getConstantFP(Type::DoubleTy, MaxIntDouble);
+  constantMinIntDouble = globalContext->getConstantFP(Type::DoubleTy, MinIntDouble);
+  constantMaxLongDouble = globalContext->getConstantFP(Type::DoubleTy, MaxLongDouble);
+  constantMaxLongDouble = globalContext->getConstantFP(Type::DoubleTy, MaxLongDouble);
+  constantFloatInfinity = globalContext->getConstantFP(Type::FloatTy, MaxFloat);
+  constantFloatMinusInfinity = globalContext->getConstantFP(Type::FloatTy, MinFloat);
+  constantDoubleInfinity = globalContext->getConstantFP(Type::DoubleTy, MaxDouble);
+  constantDoubleMinusInfinity = globalContext->getConstantFP(Type::DoubleTy, MinDouble);
+  constantDoubleMinusZero = globalContext->getConstantFP(Type::DoubleTy, -0.0);
+  constantFloatMinusZero = globalContext->getConstantFP(Type::FloatTy, -0.0f);
+  constantThreadIDMask = globalContext->getConstantInt(pointerSizeType, mvm::Thread::IDMask);
   constantStackOverflowMask = 
-    ConstantInt::get(pointerSizeType, mvm::Thread::StackOverflowMask);
-  constantFatMask = ConstantInt::get(pointerSizeType, 
+    globalContext->getConstantInt(pointerSizeType, mvm::Thread::StackOverflowMask);
+  constantFatMask = globalContext->getConstantInt(pointerSizeType, 
       pointerSizeType == Type::Int32Ty ? 0x80000000 : 0x8000000000000000LL);
-  constantPtrOne = ConstantInt::get(pointerSizeType, 1);
-  constantPtrZero = ConstantInt::get(pointerSizeType, 0);
+  constantPtrOne = globalContext->getConstantInt(pointerSizeType, 1);
+  constantPtrZero = globalContext->getConstantInt(pointerSizeType, 0);
 
   constantPtrNull = globalContext->getNullValue(ptrType); 
   constantPtrLogSize = 
-    ConstantInt::get(Type::Int32Ty, sizeof(void*) == 8 ? 3 : 2);
+    globalContext->getConstantInt(Type::Int32Ty, sizeof(void*) == 8 ? 3 : 2);
   arrayPtrType = PointerType::getUnqual(ArrayType::get(Type::Int8Ty, 0));
 }
 

Modified: vmkit/trunk/lib/N3/Mono/MonoString.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/Mono/MonoString.cpp?rev=75784&r1=75783&r2=75784&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/Mono/MonoString.cpp (original)
+++ vmkit/trunk/lib/N3/Mono/MonoString.cpp Wed Jul 15 08:31:22 2009
@@ -9,6 +9,7 @@
 
 #include "llvm/DerivedTypes.h"
 #include "llvm/GlobalVariable.h"
+#include "llvm/LLVMContext.h"
 
 #include "mvm/JIT.h"
 
@@ -50,10 +51,12 @@
     VirtualMachine* vm = VMThread::get()->vm;
     if (!str->_llvmVar) {
       const Type* pty = mvm::MvmModule::ptrType;
+      Module* Mod = vm->getLLVMModule();
+      LLVMContext& Context = Mod->getContext();
       Constant* cons = 
-        ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (this)),
+        ConstantExpr::getIntToPtr(Context.getConstantInt(Type::Int64Ty, uint64_t (this)),
                                   pty);
-      str->_llvmVar = new GlobalVariable(*(vm->getLLVMModule()), pty, true,
+      str->_llvmVar = new GlobalVariable(*Mod, pty, true,
                                     GlobalValue::ExternalLinkage,
                                     cons, "");
     }

Modified: vmkit/trunk/lib/N3/VMCore/CLIJit.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJit.cpp?rev=75784&r1=75783&r2=75784&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLIJit.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/CLIJit.cpp Wed Jul 15 08:31:22 2009
@@ -102,7 +102,8 @@
 #ifdef MULTIPLE_GC
   Value* GC = ++(block->getParent()->arg_begin());
 #endif
-  
+ 
+  Function* llvmFunction = block->getParent();
   Constant* zero = mvm::MvmModule::constantZero;
   for (std::vector<VMField*>::iterator i = fields.begin(), 
             e = fields.end(); i!= e; ++i) {
@@ -112,7 +113,7 @@
       args.push_back(zero);
       if (boxed) {
         ConstantInt* CI = dyn_cast<ConstantInt>(field->offset);
-        args.push_back(ConstantInt::get(CI->getValue() + 1));
+        args.push_back(llvmFunction->getContext()->getConstantInt(CI->getValue() + 1));
       } else {
         args.push_back(field->offset);
       }
@@ -124,7 +125,7 @@
       args.push_back(zero);
       if (boxed) {
         ConstantInt* CI = dyn_cast<ConstantInt>(field->offset);
-        args.push_back(ConstantInt::get(CI->getValue() + 1));
+        args.push_back(llvmFunction->getContext()->getConstantInt(CI->getValue() + 1));
       } else {
         args.push_back(field->offset);
       }
@@ -624,13 +625,13 @@
     return;
 
   } else if (type->super == MSCorlib::pValue || type->super == MSCorlib::pEnum) {
-    obj = new AllocaInst(type->naturalType, "", currentBlock);
+    obj = new AllocaInst(*(llvmFunction->getContext()), type->naturalType, "", currentBlock);
     uint64 size = module->getTypeSize(type->naturalType);
         
     std::vector<Value*> params;
     params.push_back(new BitCastInst(obj, module->ptrType, "", currentBlock));
     params.push_back(module->constantInt8Zero);
-    params.push_back(ConstantInt::get(Type::Int32Ty, size));
+    params.push_back(llvmFunction->getContext()->getConstantInt(Type::Int32Ty, size));
     params.push_back(module->constantZero);
     CallInst::Create(module->llvm_memset_i32, params.begin(), params.end(),
                      "", currentBlock);
@@ -737,7 +738,7 @@
     std::vector<Value*> params;
     params.push_back(new BitCastInst(ptr, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
     params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
-    params.push_back(ConstantInt::get(Type::Int32Ty, size));
+    params.push_back(llvmFunction->getContext()->getConstantInt(Type::Int32Ty, size));
     params.push_back(module->constantZero);
     CallInst::Create(module->llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock);
 
@@ -949,7 +950,7 @@
   void* natPtr = NativeUtil::nativeLookup(compilingClass, compilingMethod);
   
   Value* valPtr = 
-    ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, (uint64)natPtr),
+    ConstantExpr::getIntToPtr(llvmFunction->getContext()->getConstantInt(Type::Int64Ty, (uint64)natPtr),
                               PointerType::getUnqual(funcType));
   
   Value* result = CallInst::Create(valPtr, nativeArgs.begin(),
@@ -977,7 +978,7 @@
   }
   
    if (nbe) {
-    supplLocal = new AllocaInst(VMObject::llvmType, "exceptionVar",
+    supplLocal = new AllocaInst(*(llvmFunction->getContext()), VMObject::llvmType, "exceptionVar",
                                 currentBlock);
   }
   
@@ -1209,7 +1210,7 @@
     
     const Type* cur = i->getType();
 
-    AllocaInst* alloc = new AllocaInst(cur, "", currentBlock);
+    AllocaInst* alloc = new AllocaInst(*(llvmFunction->getContext()), cur, "", currentBlock);
     new StoreInst(i, alloc, false, currentBlock);
     arguments.push_back(alloc);
   } 
@@ -1222,7 +1223,7 @@
             e = temp.end(); i!= e; ++i) {
       VMCommonClass* cl = *i;
       cl->resolveType(false, false, genMethod);
-      AllocaInst* alloc = new AllocaInst(cl->naturalType, "", currentBlock);
+      AllocaInst* alloc = new AllocaInst(*(llvmFunction->getContext()), cl->naturalType, "", currentBlock);
       if (cl->naturalType->isSingleValueType()) {
         new StoreInst(llvmFunction->getContext()->getNullValue(cl->naturalType), alloc, false,
                       currentBlock);
@@ -1233,7 +1234,7 @@
         params.push_back(new BitCastInst(alloc, module->ptrType, "",
                                          currentBlock));
         params.push_back(module->constantInt8Zero);
-        params.push_back(ConstantInt::get(Type::Int32Ty, size));
+        params.push_back(llvmFunction->getContext()->getConstantInt(Type::Int32Ty, size));
         params.push_back(module->constantZero);
         CallInst::Create(module->llvm_memset_i32, params.begin(),
                          params.end(), "", currentBlock);
@@ -1281,7 +1282,7 @@
                                        currentBlock));
       params.push_back(new BitCastInst(endNode, module->ptrType, "",
                                        currentBlock));
-      params.push_back(ConstantInt::get(Type::Int32Ty, size));
+      params.push_back(llvmFunction->getContext()->getConstantInt(Type::Int32Ty, size));
       params.push_back(module->constantFour);
       CallInst::Create(module->llvm_memcpy_i32, params.begin(), params.end(),
                        "", currentBlock);
@@ -1386,7 +1387,7 @@
     
     const Type* cur = (*i)->getType();
 
-    AllocaInst* alloc = new AllocaInst(cur, "", currentBlock);
+    AllocaInst* alloc = new AllocaInst(*(llvmFunction->getContext()), cur, "", currentBlock);
     new StoreInst(*i, alloc, false, currentBlock);
     arguments.push_back(alloc);
   } 
@@ -1399,7 +1400,7 @@
             e = temp.end(); i!= e; ++i) {
       VMCommonClass* cl = *i;
       cl->resolveType(false, false, genMethod);
-      AllocaInst* alloc = new AllocaInst(cl->naturalType, "", currentBlock);
+      AllocaInst* alloc = new AllocaInst(*(llvmFunction->getContext()), cl->naturalType, "", currentBlock);
       if (cl->naturalType->isSingleValueType()) {
         new StoreInst(llvmFunction->getContext()->getNullValue(cl->naturalType), alloc, false,
                       currentBlock);
@@ -1410,7 +1411,7 @@
         params.push_back(new BitCastInst(alloc, module->ptrType, "",
                                          currentBlock));
         params.push_back(module->constantInt8Zero);
-        params.push_back(ConstantInt::get(Type::Int32Ty, size));
+        params.push_back(llvmFunction->getContext()->getConstantInt(Type::Int32Ty, size));
         params.push_back(module->constantZero);
         CallInst::Create(module->llvm_memset_i32, params.begin(),
                          params.end(), "", currentBlock);
@@ -1622,7 +1623,7 @@
       funcType = funcType->getContainedType(0);
     }
     const Type* lastType = funcType->getContainedType(funcType->getNumContainedTypes() - 1);
-    ret = new AllocaInst(lastType->getContainedType(0), "", InsertAtEnd);
+    ret = new AllocaInst(*(llvmFunction->getContext()), lastType->getContainedType(0), "", InsertAtEnd);
     args.push_back(ret);
   }
   Value* val = 0;
@@ -1654,7 +1655,7 @@
       funcType = funcType->getContainedType(0);
     }
     const Type* lastType = funcType->getContainedType(funcType->getNumContainedTypes() - 1);
-    ret = new AllocaInst(lastType->getContainedType(0), "", InsertAtEnd);
+    ret = new AllocaInst(*(llvmFunction->getContext()), lastType->getContainedType(0), "", InsertAtEnd);
     args.push_back(ret);
   }
   
@@ -1691,7 +1692,7 @@
       funcType = funcType->getContainedType(0);
     }
     const Type* lastType = funcType->getContainedType(funcType->getNumContainedTypes() - 1);
-    ret = new AllocaInst(lastType->getContainedType(0), "", InsertAtEnd);
+    ret = new AllocaInst(*(llvmFunction->getContext()), lastType->getContainedType(0), "", InsertAtEnd);
     args.push_back(ret);
   }
 
@@ -1720,7 +1721,7 @@
       funcType = funcType->getContainedType(0);
     }
     const Type* lastType = funcType->getContainedType(funcType->getNumContainedTypes() - 1);
-    ret = new AllocaInst(lastType->getContainedType(0), "", InsertAtEnd);
+    ret = new AllocaInst(*(llvmFunction->getContext()), lastType->getContainedType(0), "", InsertAtEnd);
     args.push_back(ret);
   }
 

Modified: vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp?rev=75784&r1=75783&r2=75784&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp Wed Jul 15 08:31:22 2009
@@ -364,12 +364,14 @@
   if (!_llvmVar) {
     aquire();
     if (!_llvmVar) {
+      Module* Mod = vm->getLLVMModule();
+      LLVMContext& Context = Mod->getContext();
       const Type* pty = mvm::MvmModule::ptrType;
       Constant* cons = 
-        ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (this)),
+        ConstantExpr::getIntToPtr(Context.getConstantInt(Type::Int64Ty, uint64_t (this)),
                                     pty);
 
-      _llvmVar = new GlobalVariable(*(vm->getLLVMModule()), pty, true,
+      _llvmVar = new GlobalVariable(*Mod, pty, true,
                                     GlobalValue::ExternalLinkage,
                                     cons, "");
     
@@ -384,11 +386,13 @@
     classDef->aquire();
     if (!_llvmVar) {
       const Type* pty = mvm::MvmModule::ptrType;
+      Module* Mod = classDef->vm->getLLVMModule();
+      LLVMContext& Context = Mod->getContext();
       Constant* cons = 
-        ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (this)),
+        ConstantExpr::getIntToPtr(Context.getConstantInt(Type::Int64Ty, uint64_t (this)),
                                   pty);
 
-      _llvmVar = new GlobalVariable(*(classDef->vm->getLLVMModule()), pty, true,
+      _llvmVar = new GlobalVariable(*Mod, pty, true,
                                     GlobalValue::ExternalLinkage,
                                     cons, "");
     }
@@ -401,12 +405,14 @@
   if (!_llvmVar) {
     classDef->aquire();
     if (!_llvmVar) {
+      Module* Mod = classDef->vm->getLLVMModule();
+      LLVMContext& Context = Mod->getContext();
       const Type* pty = mvm::MvmModule::ptrType;
       Constant* cons = 
-        ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (this)),
+        ConstantExpr::getIntToPtr(Context.getConstantInt(Type::Int64Ty, uint64_t (this)),
                                   pty);
 
-      _llvmVar = new GlobalVariable(*(classDef->vm->getLLVMModule()), pty, true,
+      _llvmVar = new GlobalVariable(*Mod, pty, true,
                                     GlobalValue::ExternalLinkage,
                                     cons, "");
     

Modified: vmkit/trunk/lib/N3/VMCore/Opcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/Opcodes.cpp?rev=75784&r1=75783&r2=75784&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/Opcodes.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/Opcodes.cpp Wed Jul 15 08:31:22 2009
@@ -164,6 +164,7 @@
 static void store(Value* val, Value* local, bool vol, 
                   BasicBlock* currentBlock, mvm::MvmModule* module) {
   const Type* contained = local->getType()->getContainedType(0);
+  Function* llvmFunction = currentBlock->getParent();
   if (contained->isSingleValueType()) {
     if (val->getType() != contained) {
       convertValue(val, contained, currentBlock);
@@ -175,7 +176,7 @@
     std::vector<Value*> params;
     params.push_back(new BitCastInst(local, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
     params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
-    params.push_back(ConstantInt::get(Type::Int32Ty, size));
+    params.push_back(llvmFunction->getContext()->getConstantInt(Type::Int32Ty, size));
     params.push_back(module->constantZero);
     CallInst::Create(module->llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock);
   } else {
@@ -185,15 +186,16 @@
 
 static Value* load(Value* val, const char* name, BasicBlock* currentBlock, mvm::MvmModule* module) {
   const Type* contained = val->getType()->getContainedType(0);
+  Function* llvmFunction = currentBlock->getParent();
   if (contained->isSingleValueType()) {
     return new LoadInst(val, name, currentBlock);
   } else {
     uint64 size = module->getTypeSize(contained);
-    Value* ret = new AllocaInst(contained, "", currentBlock); 
+    Value* ret = new AllocaInst(*(llvmFunction->getContext()), contained, "", currentBlock); 
     std::vector<Value*> params;
     params.push_back(new BitCastInst(ret, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
     params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
-    params.push_back(ConstantInt::get(Type::Int32Ty, size));
+    params.push_back(llvmFunction->getContext()->getConstantInt(Type::Int32Ty, size));
     params.push_back(module->constantZero);
     CallInst::Create(module->llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock);
     return ret;
@@ -228,13 +230,13 @@
 #if N3_EXECUTE > 1
     if (bytecodes[i] == 0xFE) {
       std::vector<llvm::Value*> args;
-      args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)OpcodeNamesFE[bytecodes[i + 1]]));
-      args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)compilingMethod));
+      args.push_back(llvmFunction->getContext()->getConstantInt(Type::Int32Ty, (int64_t)OpcodeNamesFE[bytecodes[i + 1]]));
+      args.push_back(llvmFunction->getContext()->getConstantInt(Type::Int32Ty, (int64_t)compilingMethod));
       CallInst::Create(printExecutionLLVM, args.begin(), args.end(), "", currentBlock);
     } else {
       std::vector<llvm::Value*> args;
-      args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)OpcodeNames[bytecodes[i]]));
-      args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)compilingMethod));
+      args.push_back(llvmFunction->getContext()->getConstantInt(Type::Int32Ty, (int64_t)OpcodeNames[bytecodes[i]]));
+      args.push_back(llvmFunction->getContext()->getConstantInt(Type::Int32Ty, (int64_t)compilingMethod));
       CallInst::Create(printExecutionLLVM, args.begin(), args.end(), "", currentBlock);
     }
 #endif
@@ -703,7 +705,7 @@
         uint32 index = 0; 
         for (std::vector<BasicBlock*>::iterator i = leaves.begin(), 
              e = leaves.end(); i!= e; ++i, ++index) {
-          inst->addCase(ConstantInt::get(Type::Int32Ty, index), *i); 
+          inst->addCase(llvmFunction->getContext()->getConstantInt(Type::Int32Ty, index), *i); 
         }
 
         //currentBlock = bb2;
@@ -747,22 +749,22 @@
       }
 
       case LDC_I4 : {
-        push(ConstantInt::get(Type::Int32Ty, readS4(bytecodes, i)));
+        push(llvmFunction->getContext()->getConstantInt(Type::Int32Ty, readS4(bytecodes, i)));
         break;
       }
       
       case LDC_I8 : {
-        push(ConstantInt::get(Type::Int64Ty, readS8(bytecodes, i)));
+        push(llvmFunction->getContext()->getConstantInt(Type::Int64Ty, readS8(bytecodes, i)));
         break;
       }
       
       case LDC_R4 : {
-        push(ConstantFP::get(Type::FloatTy, readFloat(bytecodes, i)));
+        push(llvmFunction->getContext()->getConstantFP(Type::FloatTy, readFloat(bytecodes, i)));
         break;
       }
       
       case LDC_R8 : {
-        push(ConstantFP::get(Type::DoubleTy, readDouble(bytecodes, i)));
+        push(llvmFunction->getContext()->getConstantFP(Type::DoubleTy, readDouble(bytecodes, i)));
         break;
       }
       
@@ -817,7 +819,7 @@
       }
       
       case LDC_I4_S : {
-        push(ConstantInt::get(Type::Int32Ty, readS1(bytecodes, i)));
+        push(llvmFunction->getContext()->getConstantInt(Type::Int32Ty, readS1(bytecodes, i)));
         break;
       }
  
@@ -952,7 +954,7 @@
           }
           if (res) {
             Value* expr = ConstantExpr::getIntToPtr(
-                                    ConstantInt::get(Type::Int64Ty,
+                                    llvmFunction->getContext()->getConstantInt(Type::Int64Ty,
                                                      uint64_t (leaveIndex++)),
                                     VMObject::llvmType);
 
@@ -984,7 +986,7 @@
           }
           if (res) {
             Value* expr = ConstantExpr::getIntToPtr(
-                                    ConstantInt::get(Type::Int64Ty,
+                                    llvmFunction->getContext()->getConstantInt(Type::Int64Ty,
                                                      uint64_t (leaveIndex++)),
                                     VMObject::llvmType);
 
@@ -1028,7 +1030,7 @@
       case NOP : break;
 
       case NOT : {
-        push(BinaryOperator::CreateNot(pop(), "", currentBlock));
+        push(BinaryOperator::CreateNot(*(llvmFunction->getContext()), pop(), "", currentBlock));
         break;
       }
 
@@ -1260,7 +1262,7 @@
           sint32 index = next + offset;
           assert(index > 0);
           BasicBlock* BB = opcodeInfos[index].newBlock;
-          SI->addCase(ConstantInt::get(Type::Int32Ty, t), BB);
+          SI->addCase(llvmFunction->getContext()->getConstantInt(Type::Int32Ty, t), BB);
         }
         break;
       }
@@ -1300,7 +1302,7 @@
 
         if (val->getType()->getTypeID() != Type::PointerTyID) {
           convertValue(val, type->naturalType, currentBlock); 
-          Value* tmp = new AllocaInst(type->naturalType, "", currentBlock);
+          Value* tmp = new AllocaInst(*(llvmFunction->getContext()), type->naturalType, "", currentBlock);
           new StoreInst(val, tmp, false, currentBlock);
           val = tmp;
         }
@@ -1311,7 +1313,7 @@
         std::vector<Value*> params;
         params.push_back(new BitCastInst(ptr, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
         params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
-        params.push_back(ConstantInt::get(Type::Int32Ty, size));
+        params.push_back(llvmFunction->getContext()->getConstantInt(Type::Int32Ty, size));
         params.push_back(module->constantZero);
         CallInst::Create(module->llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock);
         
@@ -1578,7 +1580,7 @@
         uint32 value = readU4(bytecodes, i);
         uint32 index = value & 0xfffffff;
         const UTF8* utf8 = compilingClass->assembly->readUserString(index);
-        Value* val = ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, (int64_t)utf8),
+        Value* val = ConstantExpr::getIntToPtr(llvmFunction->getContext()->getConstantInt(Type::Int64Ty, (int64_t)utf8),
                                                module->ptrType);
         Value* res = CallInst::Create(newStringLLVM, val, "", currentBlock);
         /*CLIString * str = 
@@ -1792,7 +1794,7 @@
                                                  true, genClass, genMethod);
         assert(type);
 
-        Value* val = new AllocaInst(type->naturalType, "", currentBlock);
+        Value* val = new AllocaInst(*(llvmFunction->getContext()), type->naturalType, "", currentBlock);
         Value* obj = pop();
 
         if (obj->getType() != type->virtualType) {
@@ -1810,7 +1812,7 @@
         std::vector<Value*> params;
         params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
         params.push_back(new BitCastInst(ptr, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
-        params.push_back(ConstantInt::get(Type::Int32Ty, size));
+        params.push_back(llvmFunction->getContext()->getConstantInt(Type::Int32Ty, size));
         params.push_back(module->constantZero);
         CallInst::Create(module->llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock);
         
@@ -1922,7 +1924,7 @@
           }
           
           case LOCALLOC : {
-            push(new AllocaInst(Type::Int8Ty, pop(), "", currentBlock));
+            push(new AllocaInst(*(llvmFunction->getContext()), Type::Int8Ty, pop(), "", currentBlock));
             break;
           }
           
@@ -1961,7 +1963,7 @@
               params.push_back(new BitCastInst(pop(), module->ptrType, "",
                                                currentBlock));
               params.push_back(module->constantInt8Zero);
-              params.push_back(ConstantInt::get(Type::Int32Ty, size));
+              params.push_back(llvmFunction->getContext()->getConstantInt(Type::Int32Ty, size));
               params.push_back(module->constantZero);
               CallInst::Create(module->llvm_memset_i32, params.begin(),
                                params.end(), "", currentBlock);

Modified: vmkit/trunk/lib/N3/VMCore/VMCache.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMCache.cpp?rev=75784&r1=75783&r2=75784&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMCache.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VMCache.cpp Wed Jul 15 08:31:22 2009
@@ -92,7 +92,7 @@
   Value* five = module->constantFive;
   
   Value* llvmEnv = 
-    ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (enveloppe)),
+    ConstantExpr::getIntToPtr(llvmFunction->getContext()->getConstantInt(Type::Int64Ty, uint64_t (enveloppe)),
                   Enveloppe::llvmType);
   
   std::vector<Value*> args1;

Modified: vmkit/trunk/lib/N3/VMCore/VMClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMClass.cpp?rev=75784&r1=75783&r2=75784&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMClass.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VMClass.cpp Wed Jul 15 08:31:22 2009
@@ -279,7 +279,7 @@
   for (std::vector<VMField*>::iterator i = cl->staticFields.begin(),
             e = cl->staticFields.end(); i!= e; ++i) {
     // preincrement because 0 is VMObject
-    (*i)->offset = llvm::ConstantInt::get(llvm::Type::Int32Ty, ++offset);
+    (*i)->offset = vm->getLLVMModule()->getContext().getConstantInt(llvm::Type::Int32Ty, ++offset);
   }
   for (std::vector<VMField*>::iterator i = cl->staticFields.begin(),
             e = cl->staticFields.end(); i!= e; ++i) {
@@ -329,7 +329,7 @@
         uint32 offset = -1;
         for (std::vector<VMField*>::iterator i = virtualFields.begin(), 
           e = virtualFields.end(); i!= e; ++i) {
-          (*i)->offset = llvm::ConstantInt::get(llvm::Type::Int32Ty, ++offset);
+          (*i)->offset = vm->getLLVMModule()->getContext().getConstantInt(llvm::Type::Int32Ty, ++offset);
           const llvm::Type* type = (*i)->signature->naturalType;
           Elts.push_back(type);
         }
@@ -343,7 +343,7 @@
       uint32 offset = 0;
       for (std::vector<VMField*>::iterator i = virtualFields.begin(), 
            e = virtualFields.end(); i!= e; ++i) {
-        (*i)->offset = llvm::ConstantInt::get(llvm::Type::Int32Ty, ++offset);
+        (*i)->offset = vm->getLLVMModule()->getContext().getConstantInt(llvm::Type::Int32Ty, ++offset);
         const llvm::Type* type = (*i)->signature->naturalType;
         Elts.push_back(type);
       }

Modified: vmkit/trunk/tools/vmjc/vmjc.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmjc/vmjc.cpp?rev=75784&r1=75783&r2=75784&view=diff

==============================================================================
--- vmkit/trunk/tools/vmjc/vmjc.cpp (original)
+++ vmkit/trunk/tools/vmjc/vmjc.cpp Wed Jul 15 08:31:22 2009
@@ -29,6 +29,7 @@
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/PassNameParser.h"
 #include "llvm/Support/PluginLoader.h"
+#include "llvm/Support/RegistryParser.h"
 #include "llvm/Support/Streams.h"
 #include "llvm/Support/SystemUtils.h"
 #include "llvm/Support/raw_ostream.h"
@@ -37,6 +38,7 @@
 #include "llvm/Target/TargetMachineRegistry.h"
 #include "llvm/Target/TargetMachine.h"
 
+
 #include "MvmGC.h"
 #include "mvm/JIT.h"
 #include "mvm/Object.h"
@@ -119,6 +121,9 @@
 WithClinit("with-clinit", cl::desc("Set a property"), cl::ZeroOrMore,
            cl::CommaSeparated);
 
+static cl::opt<const TargetMachineRegistry::entry*, false,
+               RegistryParser<TargetMachine> >
+MArch("march", cl::desc("Architecture to generate code for:"));
 
 
 inline void addPass(FunctionPassManager *PM, Pass *P) {
@@ -187,26 +192,36 @@
         TheModule->setTargetTriple(TargetTriple);
       else
         TheModule->setTargetTriple(mvm::MvmModule::getHostTriple());
-    
-      // Create the TargetMachine we will be generating code with.
-      std::string Err; 
-      const TargetMachineRegistry::entry *TME = 
-        TargetMachineRegistry::getClosestStaticTargetForModule(*TheModule, Err);
-      if (!TME) {
-        cerr << "Did not get a target machine!\n";
-        exit(1);
+   
+
+      // Allocate target machine.  First, check whether the user has
+      // explicitly specified an architecture to compile for.
+      const Target *TheTarget;
+      if (MArch) {
+        TheTarget = &MArch->TheTarget;
+      } else {
+        std::string Err;
+        TheTarget = 
+          TargetRegistry::getClosestStaticTargetForModule(*TheModule, Err);
+        if (TheTarget == 0) {
+          std::cerr << argv[0] << ": error auto-selecting target for module '"
+                    << Err << "'.  Please use the -march option to explicitly "
+                    << "pick a target.\n";
+          return 1;
+        }
       }
 
-      std::string FeatureStr;
-      TargetMachine* TheTarget = TME->CtorFn(*TheModule, FeatureStr);
+      std::string FeaturesStr;
+      TargetMachine *Target =
+        TheTarget->createTargetMachine(*TheModule, FeaturesStr);
 
       // Install information about target datalayout stuff into the module for
       // optimizer use.
-      TheModule->setDataLayout(TheTarget->getTargetData()->
+      TheModule->setDataLayout(Target->getTargetData()->
                                getStringRepresentation());
 
 
-      mvm::MvmModule::initialise(CodeGenOpt::Default, TheModule, TheTarget);
+      mvm::MvmModule::initialise(CodeGenOpt::Default, TheModule, Target);
     } else {
       mvm::MvmModule::initialise();
     }





More information about the vmkit-commits mailing list