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

Nicolas Geoffray nicolas.geoffray at lip6.fr
Sat Aug 15 08:54:15 PDT 2009


Author: geoffray
Date: Sat Aug 15 10:54:14 2009
New Revision: 79108

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


Modified:
    vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.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/JavaJIT.h
    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/JnJVM/VMCore/JavaTypes.h
    vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp
    vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
    vmkit/trunk/lib/Mvm/Compiler/LoopSafePoints.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/LowerArrayLength.cpp
    vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp
    vmkit/trunk/lib/N3/VMCore/Opcodes.cpp
    vmkit/trunk/lib/N3/VMCore/VMCache.cpp
    vmkit/trunk/lib/N3/VMCore/VMClass.cpp

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.inc (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.inc Sat Aug 15 10:54:14 2009
@@ -432,7 +432,7 @@
                                     currentBlock);
 
     uint32 depth = cur->catchClass->virtualVT->depth;
-    Value* depthCl = ConstantInt::get(Type::Int32Ty, depth);
+    Value* depthCl = ConstantInt::get(Type::getInt32Ty(*llvmContext), depth);
     Value* cmp = 0;
 
     if (depth >= JavaVirtualTable::getDisplayLength()) {
@@ -546,7 +546,7 @@
   if (PI == PE) {
     unifiedUnreachable->eraseFromParent();
   } else {
-    new UnreachableInst(unifiedUnreachable);
+    new UnreachableInst(*llvmContext, unifiedUnreachable);
   }
   
   for (Function::iterator BI = llvmFunction->begin(), BE = llvmFunction->end();

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp Sat Aug 15 10:54:14 2009
@@ -10,8 +10,9 @@
 #include "llvm/BasicBlock.h"
 #include "llvm/CallingConv.h"
 #include "llvm/Constants.h"
-#include "llvm/ExecutionEngine/ExecutionEngine.h"
 #include "llvm/Instructions.h"
+#include "llvm/Module.h"
+#include "llvm/ExecutionEngine/ExecutionEngine.h"
 #include "llvm/Support/MutexGuard.h"
 #include "llvm/Target/TargetData.h"
 
@@ -79,7 +80,7 @@
     
     uint64 size = JnjvmModule::getTypeSize(structType);
     classDef->virtualSize = (uint32)size;
-    virtualSizeConstant = ConstantInt::get(Type::Int32Ty, size);
+    virtualSizeConstant = ConstantInt::get(Type::getInt32Ty(context), size);
    
     Mod->makeVT(classDef);
   }
@@ -125,9 +126,7 @@
 Value* LLVMClassInfo::getVirtualSize() {
   if (!virtualSizeConstant) {
     getVirtualType();
-    assert(classDef->virtualSize && "Zero size for a class?");
-    virtualSizeConstant = 
-      ConstantInt::get(Type::Int32Ty, classDef->virtualSize);
+    assert(virtualSizeConstant && "No size for a class?");
   }
   return virtualSizeConstant;
 }
@@ -193,9 +192,11 @@
   if (!offsetConstant) {
     JnjvmClassLoader* JCL = methodDef->classDef->classLoader;
     JavaLLVMCompiler* Mod = (JavaLLVMCompiler*)JCL->getCompiler();
+    LLVMContext& context = Mod->getLLVMModule()->getContext();
     
     Mod->resolveVirtualClass(methodDef->classDef);
-    offsetConstant = ConstantInt::get(Type::Int32Ty, methodDef->offset);
+    offsetConstant = ConstantInt::get(Type::getInt32Ty(context),
+                                      methodDef->offset);
   }
   return offsetConstant;
 }
@@ -204,6 +205,7 @@
   if (!offsetConstant) {
     JnjvmClassLoader* JCL = fieldDef->classDef->classLoader;
     JavaLLVMCompiler* Mod = (JavaLLVMCompiler*)JCL->getCompiler();
+    LLVMContext& context = Mod->getLLVMModule()->getContext();
     
     if (isStatic(fieldDef->access)) {
       Mod->resolveStaticClass(fieldDef->classDef); 
@@ -211,7 +213,7 @@
       Mod->resolveVirtualClass(fieldDef->classDef); 
     }
     
-    offsetConstant = ConstantInt::get(Type::Int32Ty, fieldDef->num);
+    offsetConstant = ConstantInt::get(Type::getInt32Ty(context), fieldDef->num);
   }
   return offsetConstant;
 }
@@ -315,6 +317,7 @@
 
   JavaLLVMCompiler* Mod = 
     (JavaLLVMCompiler*)signature->initialLoader->getCompiler();
+  LLVMContext& context = Mod->getLLVMModule()->getContext();
   Function* res = 0;
   if (Mod->isStaticCompiling()) {
     const char* type = virt ? "virtual_buf" : "static_buf";
@@ -331,7 +334,7 @@
                            Mod->getLLVMModule());
   }
 
-  BasicBlock* currentBlock = BasicBlock::Create("enter", res);
+  BasicBlock* currentBlock = BasicBlock::Create(context, "enter", res);
   Function::arg_iterator i = res->arg_begin();
   Value *obj, *ptr, *func;
 #if defined(ISOLATE_SHARING)
@@ -364,10 +367,10 @@
 
   Value* val = CallInst::Create(func, Args.begin(), Args.end(), "",
                                 currentBlock);
-  if (res->getFunctionType()->getReturnType() != Type::VoidTy)
-    ReturnInst::Create(val, currentBlock);
+  if (!signature->getReturnType()->isVoid())
+    ReturnInst::Create(context, val, currentBlock);
   else
-    ReturnInst::Create(currentBlock);
+    ReturnInst::Create(context, currentBlock);
   
   return res;
 }
@@ -390,8 +393,9 @@
                                           getStaticBufType(),
                                    GlobalValue::InternalLinkage, name,
                                    Mod->getLLVMModule());
+  LLVMContext& context = Mod->getLLVMModule()->getContext();
   
-  BasicBlock* currentBlock = BasicBlock::Create("enter", res);
+  BasicBlock* currentBlock = BasicBlock::Create(context, "enter", res);
   Function::arg_iterator i = res->arg_begin();
   Value *obj, *ap, *func;
 #if defined(ISOLATE_SHARING)
@@ -419,10 +423,10 @@
 
   Value* val = CallInst::Create(func, Args.begin(), Args.end(), "",
                                 currentBlock);
-  if (res->getFunctionType()->getReturnType() != Type::VoidTy)
-    ReturnInst::Create(val, currentBlock);
+  if (!signature->getReturnType()->isVoid())
+    ReturnInst::Create(context, val, currentBlock);
   else
-    ReturnInst::Create(currentBlock);
+    ReturnInst::Create(context, currentBlock);
   
   return res;
 }
@@ -551,40 +555,48 @@
 }
 
 void LLVMAssessorInfo::initialise() {
-  AssessorInfo[I_VOID].llvmType = Type::VoidTy;
+  AssessorInfo[I_VOID].llvmType = Type::getVoidTy(getGlobalContext());
   AssessorInfo[I_VOID].llvmTypePtr = 0;
   AssessorInfo[I_VOID].logSizeInBytesConstant = 0;
   
-  AssessorInfo[I_BOOL].llvmType = Type::Int8Ty;
-  AssessorInfo[I_BOOL].llvmTypePtr = PointerType::getUnqual(Type::Int8Ty);
+  AssessorInfo[I_BOOL].llvmType = Type::getInt8Ty(getGlobalContext());
+  AssessorInfo[I_BOOL].llvmTypePtr =
+    PointerType::getUnqual(Type::getInt8Ty(getGlobalContext()));
   AssessorInfo[I_BOOL].logSizeInBytesConstant = 0;
   
-  AssessorInfo[I_BYTE].llvmType = Type::Int8Ty;
-  AssessorInfo[I_BYTE].llvmTypePtr = PointerType::getUnqual(Type::Int8Ty);
+  AssessorInfo[I_BYTE].llvmType = Type::getInt8Ty(getGlobalContext());
+  AssessorInfo[I_BYTE].llvmTypePtr =
+    PointerType::getUnqual(Type::getInt8Ty(getGlobalContext()));
   AssessorInfo[I_BYTE].logSizeInBytesConstant = 0;
   
-  AssessorInfo[I_SHORT].llvmType = Type::Int16Ty;
-  AssessorInfo[I_SHORT].llvmTypePtr = PointerType::getUnqual(Type::Int16Ty);
+  AssessorInfo[I_SHORT].llvmType = Type::getInt16Ty(getGlobalContext());
+  AssessorInfo[I_SHORT].llvmTypePtr =
+    PointerType::getUnqual(Type::getInt16Ty(getGlobalContext()));
   AssessorInfo[I_SHORT].logSizeInBytesConstant = 1;
   
-  AssessorInfo[I_CHAR].llvmType = Type::Int16Ty;
-  AssessorInfo[I_CHAR].llvmTypePtr = PointerType::getUnqual(Type::Int16Ty);
+  AssessorInfo[I_CHAR].llvmType = Type::getInt16Ty(getGlobalContext());
+  AssessorInfo[I_CHAR].llvmTypePtr =
+    PointerType::getUnqual(Type::getInt16Ty(getGlobalContext()));
   AssessorInfo[I_CHAR].logSizeInBytesConstant = 1;
   
-  AssessorInfo[I_INT].llvmType = Type::Int32Ty;
-  AssessorInfo[I_INT].llvmTypePtr = PointerType::getUnqual(Type::Int32Ty);
+  AssessorInfo[I_INT].llvmType = Type::getInt32Ty(getGlobalContext());
+  AssessorInfo[I_INT].llvmTypePtr =
+    PointerType::getUnqual(Type::getInt32Ty(getGlobalContext()));
   AssessorInfo[I_INT].logSizeInBytesConstant = 2;
   
-  AssessorInfo[I_FLOAT].llvmType = Type::FloatTy;
-  AssessorInfo[I_FLOAT].llvmTypePtr = PointerType::getUnqual(Type::FloatTy);
+  AssessorInfo[I_FLOAT].llvmType = Type::getFloatTy(getGlobalContext());
+  AssessorInfo[I_FLOAT].llvmTypePtr =
+    PointerType::getUnqual(Type::getFloatTy(getGlobalContext()));
   AssessorInfo[I_FLOAT].logSizeInBytesConstant = 2;
   
-  AssessorInfo[I_LONG].llvmType = Type::Int64Ty;
-  AssessorInfo[I_LONG].llvmTypePtr = PointerType::getUnqual(Type::Int64Ty);
+  AssessorInfo[I_LONG].llvmType = Type::getInt64Ty(getGlobalContext());
+  AssessorInfo[I_LONG].llvmTypePtr =
+    PointerType::getUnqual(Type::getInt64Ty(getGlobalContext()));
   AssessorInfo[I_LONG].logSizeInBytesConstant = 3;
   
-  AssessorInfo[I_DOUBLE].llvmType = Type::DoubleTy;
-  AssessorInfo[I_DOUBLE].llvmTypePtr = PointerType::getUnqual(Type::DoubleTy);
+  AssessorInfo[I_DOUBLE].llvmType = Type::getDoubleTy(getGlobalContext());
+  AssessorInfo[I_DOUBLE].llvmTypePtr =
+    PointerType::getUnqual(Type::getDoubleTy(getGlobalContext()));
   AssessorInfo[I_DOUBLE].logSizeInBytesConstant = 3;
   
   AssessorInfo[I_TAB].llvmType = JnjvmModule::JavaObjectType;

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp Sat Aug 15 10:54:14 2009
@@ -137,7 +137,7 @@
   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 = ConstantInt::get(Type::getInt32Ty(getGlobalContext()), i);
       break;
     }
   }
@@ -265,21 +265,21 @@
         CommonClass* subClass = cl->asArrayClass()->baseClass();
         if (subClass->isPrimitive()) {
           if (subClass == upcalls->OfBool) {
-            Ty = Type::Int8Ty;
+            Ty = Type::getInt8Ty(getGlobalContext());
           } else if (subClass == upcalls->OfByte) {
-            Ty = Type::Int8Ty;
+            Ty = Type::getInt8Ty(getGlobalContext());
           } else if (subClass == upcalls->OfShort) {
-            Ty = Type::Int16Ty;
+            Ty = Type::getInt16Ty(getGlobalContext());
           } else if (subClass == upcalls->OfChar) {
-            Ty = Type::Int16Ty;
+            Ty = Type::getInt16Ty(getGlobalContext());
           } else if (subClass == upcalls->OfInt) {
-            Ty = Type::Int32Ty;
+            Ty = Type::getInt32Ty(getGlobalContext());
           } else if (subClass == upcalls->OfFloat) {
-            Ty = Type::FloatTy;
+            Ty = Type::getFloatTy(getGlobalContext());
           } else if (subClass == upcalls->OfLong) {
-            Ty = Type::Int64Ty;
+            Ty = Type::getInt64Ty(getGlobalContext());
           } else if (subClass == upcalls->OfDouble) {
-            Ty = Type::DoubleTy;
+            Ty = Type::getDoubleTy(getGlobalContext());
           } else {
             abort();
           }
@@ -312,7 +312,8 @@
       varGV->setInitializer(CreateConstantFromJavaObject(obj));
       return C;
     } else {
-      Constant* CI = ConstantInt::get(Type::Int64Ty, uint64_t(obj));
+      Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
+                                      uint64_t(obj));
       CI = ConstantExpr::getIntToPtr(CI, JnjvmModule::JavaObjectType);
       finalObjects.insert(std::make_pair(obj, CI));
       return CI;
@@ -343,28 +344,34 @@
         if (type->isPrimitive()) {
           const PrimitiveTypedef* prim = (PrimitiveTypedef*)type;
           if (prim->isBool() || prim->isByte()) {
-            ConstantInt* CI = ConstantInt::get(Type::Int8Ty,
-                                               field.getInt8Field(obj));
+            ConstantInt* CI = ConstantInt::get(
+                Type::getInt8Ty(getGlobalContext()),
+                field.getInt8Field(obj));
             Elts.push_back(CI);
           } else if (prim->isShort() || prim->isChar()) {
-            ConstantInt* CI = ConstantInt::get(Type::Int16Ty,
-                                               field.getInt16Field(obj));
+            ConstantInt* CI = ConstantInt::get(
+                Type::getInt16Ty(getGlobalContext()),
+                field.getInt16Field(obj));
             Elts.push_back(CI);
           } else if (prim->isInt()) {
-            ConstantInt* CI = ConstantInt::get(Type::Int32Ty,
-                                               field.getInt32Field(obj));
+            ConstantInt* CI = ConstantInt::get(
+                Type::getInt32Ty(getGlobalContext()),
+                field.getInt32Field(obj));
             Elts.push_back(CI);
           } else if (prim->isLong()) {
-            ConstantInt* CI = ConstantInt::get(Type::Int64Ty,
-                                               field.getLongField(obj));
+            ConstantInt* CI = ConstantInt::get(
+                Type::getInt64Ty(getGlobalContext()),
+                field.getLongField(obj));
             Elts.push_back(CI);
           } else if (prim->isFloat()) {
-            Constant* CF = ConstantFP::get(Type::FloatTy,
-                                           field.getFloatField(obj));
+            Constant* CF = ConstantFP::get(
+                Type::getFloatTy(getGlobalContext()),
+                field.getFloatField(obj));
             Elts.push_back(CF);
           } else if (prim->isDouble()) {
-            Constant* CF = ConstantFP::get(Type::DoubleTy,
-                                           field.getDoubleField(obj));
+            Constant* CF = ConstantFP::get(
+                Type::getDoubleTy(getGlobalContext()),
+                field.getDoubleField(obj));
             Elts.push_back(CF);
           } else {
             abort();
@@ -386,11 +393,11 @@
       JavaConstantPool * ctpInfo = cl->ctpInfo;
       uint16 idx = reader.readU2();
       if (type->isPrimitive()) {
-        if (Ty == Type::Int64Ty) {
+        if (Ty == Type::getInt64Ty(getGlobalContext())) {
           Elts.push_back(ConstantInt::get(Ty, (uint64)ctpInfo->LongAt(idx)));
-        } else if (Ty == Type::DoubleTy) {
+        } else if (Ty == Type::getDoubleTy(getGlobalContext())) {
           Elts.push_back(ConstantFP::get(Ty, ctpInfo->DoubleAt(idx)));
-        } else if (Ty == Type::FloatTy) {
+        } else if (Ty == Type::getFloatTy(getGlobalContext())) {
           Elts.push_back(ConstantFP::get(Ty, ctpInfo->FloatAt(idx)));
         } else {
           Elts.push_back(ConstantInt::get(Ty, (uint64)ctpInfo->IntegerAt(idx)));
@@ -519,7 +526,7 @@
   Elmts.push_back(getVirtualTable(cl->virtualVT));
   
   // lock
-  Constant* L = ConstantInt::get(Type::Int64Ty, 0);
+  Constant* L = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), 0);
   Elmts.push_back(ConstantExpr::getIntToPtr(L, JnjvmModule::ptrType));
 
   return ConstantStruct::get(STy, Elmts);
@@ -563,28 +570,28 @@
     if (subClass->isPrimitive()) {
       if (subClass == upcalls->OfBool) {
         return CreateConstantFromArray<ArrayUInt8>((ArrayUInt8*)obj,
-                                                   Type::Int8Ty);
+                                        Type::getInt8Ty(getGlobalContext()));
       } else if (subClass == upcalls->OfByte) {
         return CreateConstantFromArray<ArraySInt8>((ArraySInt8*)obj,
-                                                   Type::Int8Ty);
+                                        Type::getInt8Ty(getGlobalContext()));
       } else if (subClass == upcalls->OfShort) {
         return CreateConstantFromArray<ArraySInt16>((ArraySInt16*)obj,
-                                                    Type::Int16Ty);
+                                        Type::getInt16Ty(getGlobalContext()));
       } else if (subClass == upcalls->OfChar) {
         return CreateConstantFromArray<ArrayUInt16>((ArrayUInt16*)obj,
-                                                    Type::Int16Ty);
+                                        Type::getInt16Ty(getGlobalContext()));
       } else if (subClass == upcalls->OfInt) {
         return CreateConstantFromArray<ArraySInt32>((ArraySInt32*)obj,
-                                                    Type::Int32Ty);
+                                        Type::getInt32Ty(getGlobalContext()));
       } else if (subClass == upcalls->OfFloat) {
         return CreateConstantFromArray<ArrayFloat>((ArrayFloat*)obj,
-                                                   Type::FloatTy);
+                                        Type::getFloatTy(getGlobalContext()));
       } else if (subClass == upcalls->OfLong) {
         return CreateConstantFromArray<ArrayLong>((ArrayLong*)obj,
-                                                  Type::Int64Ty);
+                                        Type::getInt64Ty(getGlobalContext()));
       } else if (subClass == upcalls->OfDouble) {
         return CreateConstantFromArray<ArrayDouble>((ArrayDouble*)obj,
-                                                    Type::DoubleTy);
+                                        Type::getDoubleTy(getGlobalContext()));
       } else {
         abort();
       }
@@ -614,27 +621,27 @@
         if (type->isPrimitive()) {
           const PrimitiveTypedef* prim = (PrimitiveTypedef*)type;
           if (prim->isBool() || prim->isByte()) {
-            ConstantInt* CI = ConstantInt::get(Type::Int8Ty,
+            ConstantInt* CI = ConstantInt::get(Type::getInt8Ty(getGlobalContext()),
                                                field.getInt8Field(obj));
             TempElts.push_back(CI);
           } else if (prim->isShort() || prim->isChar()) {
-            ConstantInt* CI = ConstantInt::get(Type::Int16Ty,
+            ConstantInt* CI = ConstantInt::get(Type::getInt16Ty(getGlobalContext()),
                                                field.getInt16Field(obj));
             TempElts.push_back(CI);
           } else if (prim->isInt()) {
-            ConstantInt* CI = ConstantInt::get(Type::Int32Ty,
+            ConstantInt* CI = ConstantInt::get(Type::getInt32Ty(getGlobalContext()),
                                                field.getInt32Field(obj));
             TempElts.push_back(CI);
           } else if (prim->isLong()) {
-            ConstantInt* CI = ConstantInt::get(Type::Int64Ty,
+            ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
                                                field.getLongField(obj));
             TempElts.push_back(CI);
           } else if (prim->isFloat()) {
-            Constant* CF = ConstantFP::get(Type::FloatTy,
+            Constant* CF = ConstantFP::get(Type::getFloatTy(getGlobalContext()),
                                            field.getFloatField(obj));
             TempElts.push_back(CF);
           } else if (prim->isDouble()) {
-            Constant* CF = ConstantFP::get(Type::DoubleTy,
+            Constant* CF = ConstantFP::get(Type::getDoubleTy(getGlobalContext()),
                                            field.getDoubleField(obj));
             TempElts.push_back(CF);
           } else {
@@ -669,7 +676,7 @@
   Elmts.push_back(CreateConstantForBaseObject(cl));
 
   Constant* Array =
-    CreateConstantFromArray<ArrayUInt16>(str->value, Type::Int16Ty);
+    CreateConstantFromArray<ArrayUInt16>(str->value, Type::getInt16Ty(getGlobalContext()));
   
 
   Module& Mod = *getLLVMModule();
@@ -680,9 +687,12 @@
 	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(ConstantInt::get(Type::getInt32Ty(getGlobalContext()),
+                                   str->count));
+  Elmts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()),
+                                   str->cachedHashCode));
+  Elmts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()),
+                                   str->offset));
  
   return ConstantStruct::get(STy, Elmts);
 }
@@ -717,7 +727,7 @@
   Elmts.push_back(getUTF8(val->methodName));
   Elmts.push_back(getUTF8(val->methodSign));
 
-  Elmts.push_back(Constant::getNullValue(Type::Int32Ty));
+  Elmts.push_back(Constant::getNullValue(Type::getInt32Ty(getGlobalContext())));
   Elmts.push_back(getNativeClass(val->classDef));
   Elmts.push_back(firstCache);
 
@@ -736,10 +746,10 @@
   Elmts.push_back(getUTF8(attribut.name));
 
   // start
-  Elmts.push_back(ConstantInt::get(Type::Int32Ty, attribut.start));
+  Elmts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), attribut.start));
 
   // nbb
-  Elmts.push_back(ConstantInt::get(Type::Int32Ty, attribut.nbb));
+  Elmts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), attribut.nbb));
   
   return ConstantStruct::get(STy, Elmts);
 }
@@ -762,7 +772,7 @@
   CommonClassElts.push_back(ConstantArray::get(ATy, TCM, 1));
   
   // access
-  CommonClassElts.push_back(ConstantInt::get(Type::Int16Ty, cl->access));
+  CommonClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->access));
  
   // interfaces
   if (cl->nbInterfaces) {
@@ -785,7 +795,7 @@
   }
 
   // nbInterfaces
-  CommonClassElts.push_back(ConstantInt::get(Type::Int16Ty, cl->nbInterfaces));
+  CommonClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->nbInterfaces));
 
   // name
   CommonClassElts.push_back(getUTF8(cl->name));
@@ -825,7 +835,7 @@
   FieldElts.push_back(Constant::getNullValue(JnjvmModule::ptrType));
   
   // access
-  FieldElts.push_back(ConstantInt::get(Type::Int16Ty, field.access));
+  FieldElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), field.access));
 
   // name
   FieldElts.push_back(getUTF8(field.name));
@@ -855,16 +865,16 @@
   }
   
   // nbAttributs
-  FieldElts.push_back(ConstantInt::get(Type::Int16Ty, field.nbAttributs));
+  FieldElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), field.nbAttributs));
 
   // classDef
   FieldElts.push_back(getNativeClass(field.classDef));
 
   // ptrOffset
-  FieldElts.push_back(ConstantInt::get(Type::Int32Ty, field.ptrOffset));
+  FieldElts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), field.ptrOffset));
 
   // num
-  FieldElts.push_back(ConstantInt::get(Type::Int16Ty, field.num));
+  FieldElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), field.num));
 
   //JInfo
   FieldElts.push_back(Constant::getNullValue(JnjvmModule::ptrType));
@@ -884,7 +894,7 @@
   MethodElts.push_back(Constant::getNullValue(JnjvmModule::ptrType));
   
   // access
-  MethodElts.push_back(ConstantInt::get(Type::Int16Ty, method.access));
+  MethodElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), method.access));
  
   // attributs
   if (method.nbAttributs) {
@@ -908,7 +918,7 @@
   }
   
   // nbAttributs
-  MethodElts.push_back(ConstantInt::get(Type::Int16Ty, method.nbAttributs));
+  MethodElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), method.nbAttributs));
   
   // enveloppes
   // already allocated by the JIT, don't reallocate them.
@@ -916,7 +926,7 @@
   
   // nbEnveloppes
   // 0 because we're not allocating here.
-  MethodElts.push_back(ConstantInt::get(Type::Int16Ty, 0));
+  MethodElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), 0));
   
   // classDef
   MethodElts.push_back(getNativeClass(method.classDef));
@@ -928,7 +938,7 @@
   MethodElts.push_back(getUTF8(method.type));
   
   // canBeInlined
-  MethodElts.push_back(ConstantInt::get(Type::Int8Ty, method.canBeInlined));
+  MethodElts.push_back(ConstantInt::get(Type::getInt8Ty(getGlobalContext()), method.canBeInlined));
 
   // code
   if (isAbstract(method.access)) {
@@ -941,7 +951,7 @@
   }
 
   // offset
-  MethodElts.push_back(ConstantInt::get(Type::Int32Ty, method.offset));
+  MethodElts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), method.offset));
 
   //JInfo
   MethodElts.push_back(Constant::getNullValue(JnjvmModule::ptrType));
@@ -960,7 +970,7 @@
   ClassElts.push_back(CreateConstantFromCommonClass(cl));
 
   // primSize
-  ClassElts.push_back(ConstantInt::get(Type::Int32Ty, cl->logSize));
+  ClassElts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), cl->logSize));
 
   return ConstantStruct::get(STy, ClassElts);
 }
@@ -998,7 +1008,8 @@
   ClassElts.push_back(CreateConstantFromCommonClass(cl));
 
   // virtualSize
-  ClassElts.push_back(ConstantInt::get(Type::Int32Ty, cl->virtualSize));
+  ClassElts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()),
+                                       cl->virtualSize));
 
   // IsolateInfo
   const ArrayType* ATy = dyn_cast<ArrayType>(STy->getContainedType(2));
@@ -1008,8 +1019,10 @@
   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(ConstantInt::get(Type::getInt8Ty(getGlobalContext()),
+                                      status));
+  TempElts.push_back(ConstantInt::get(Type::getInt1Ty(getGlobalContext()),
+                                      status == ready ? 1 : 0));
   TempElts.push_back(getStaticInstance(cl));
   Constant* CStr[1] = { ConstantStruct::get(TCMTy, TempElts) };
   TempElts.clear();
@@ -1059,7 +1072,7 @@
   ClassElts.push_back(fields);
 
   ConstantInt* nbVirtualFields = 
-    ConstantInt::get(Type::Int16Ty, cl->nbVirtualFields);
+    ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->nbVirtualFields);
   // nbVirtualFields
   ClassElts.push_back(nbVirtualFields);
   
@@ -1069,7 +1082,7 @@
   ClassElts.push_back(Constant::getNullValue(JnjvmModule::JavaFieldType));
 
   // nbStaticFields
-  ClassElts.push_back(ConstantInt::get(Type::Int16Ty, cl->nbStaticFields));
+  ClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->nbStaticFields));
   
   // virtualMethods
   if (cl->nbVirtualMethods + cl->nbStaticMethods) {
@@ -1107,7 +1120,7 @@
   ClassElts.push_back(methods);
 
   ConstantInt* nbVirtualMethods = 
-    ConstantInt::get(Type::Int16Ty, cl->nbVirtualMethods);
+    ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->nbVirtualMethods);
   // nbVirtualMethods
   ClassElts.push_back(nbVirtualMethods);
   
@@ -1116,7 +1129,7 @@
   ClassElts.push_back(Constant::getNullValue(JnjvmModule::JavaMethodType));
 
   // nbStaticMethods
-  ClassElts.push_back(ConstantInt::get(Type::Int16Ty, cl->nbStaticMethods));
+  ClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->nbStaticMethods));
 
   // ownerClass
   ClassElts.push_back(Constant::getNullValue(JnjvmModule::ptrType));
@@ -1149,7 +1162,7 @@
   }
   
   // nbAttributs
-  ClassElts.push_back(ConstantInt::get(Type::Int16Ty, cl->nbAttributs));
+  ClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->nbAttributs));
   
   // innerClasses
   if (cl->nbInnerClasses) {
@@ -1173,7 +1186,7 @@
   }
 
   // nbInnerClasses
-  ClassElts.push_back(ConstantInt::get(Type::Int16Ty, cl->nbInnerClasses));
+  ClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->nbInnerClasses));
 
   // outerClass
   if (cl->outerClass) {
@@ -1183,19 +1196,19 @@
   }
 
   // innerAccess
-  ClassElts.push_back(ConstantInt::get(Type::Int16Ty, cl->innerAccess));
+  ClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->innerAccess));
   
   // innerOuterResolved
-  ClassElts.push_back(ConstantInt::get(Type::Int8Ty, cl->innerOuterResolved));
+  ClassElts.push_back(ConstantInt::get(Type::getInt8Ty(getGlobalContext()), cl->innerOuterResolved));
   
   // isAnonymous
-  ClassElts.push_back(ConstantInt::get(Type::Int8Ty, cl->isAnonymous));
+  ClassElts.push_back(ConstantInt::get(Type::getInt8Ty(getGlobalContext()), cl->isAnonymous));
   
   // virtualTableSize
-  ClassElts.push_back(ConstantInt::get(Type::Int32Ty, cl->virtualTableSize));
+  ClassElts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), cl->virtualTableSize));
   
   // staticSize
-  ClassElts.push_back(ConstantInt::get(Type::Int32Ty, cl->staticSize));
+  ClassElts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), cl->staticSize));
 
   // JInfo
   ClassElts.push_back(Constant::getNullValue(JnjvmModule::ptrType));
@@ -1241,7 +1254,7 @@
 
 Constant* JavaAOTCompiler::CreateConstantFromUTF8(const UTF8* val) {
   std::vector<const Type*> Elemts;
-  const ArrayType* ATy = ArrayType::get(Type::Int16Ty, val->size);
+  const ArrayType* ATy = ArrayType::get(Type::getInt16Ty(getGlobalContext()), val->size);
   Elemts.push_back(JnjvmModule::pointerSizeType);
 
   Elemts.push_back(ATy);
@@ -1254,7 +1267,7 @@
   
   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(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), val->elements[i]));
   }
 
   Cts.push_back(ConstantArray::get(ATy, Vals));
@@ -1333,11 +1346,11 @@
 
   // depth
   Elemts.push_back(ConstantExpr::getIntToPtr(
-        ConstantInt::get(Type::Int64Ty, VT->depth), PTy));
+        ConstantInt::get(Type::getInt64Ty(getGlobalContext()), VT->depth), PTy));
   
   // offset
   Elemts.push_back(ConstantExpr::getIntToPtr(
-        ConstantInt::get(Type::Int64Ty, VT->offset), PTy));
+        ConstantInt::get(Type::getInt64Ty(getGlobalContext()), VT->offset), PTy));
   
   // cache
   Elemts.push_back(N);
@@ -1355,7 +1368,7 @@
   
   // nbSecondaryTypes
   Elemts.push_back(ConstantExpr::getIntToPtr(
-        ConstantInt::get(Type::Int64Ty, VT->nbSecondaryTypes), PTy));
+        ConstantInt::get(Type::getInt64Ty(getGlobalContext()), VT->nbSecondaryTypes), PTy));
   
   // secondaryTypes
   const ArrayType* DTy = ArrayType::get(JnjvmModule::VTType,
@@ -1422,13 +1435,13 @@
 
   std::vector<const llvm::Type*> llvmArgs;
   llvmArgs.push_back(JnjvmModule::ptrType); // class loader.
-  const FunctionType* FTy = FunctionType::get(Type::VoidTy, llvmArgs, false);
+  const FunctionType* FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false);
 
   StaticInitializer = Function::Create(FTy, GlobalValue::InternalLinkage,
                                        "Init", getLLVMModule());
   
   llvmArgs.clear();
-  FTy = FunctionType::get(Type::VoidTy, llvmArgs, false);
+  FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false);
   Callback = Function::Create(FTy, GlobalValue::ExternalLinkage,
                               "staticCallback", getLLVMModule());
 
@@ -1441,7 +1454,7 @@
                                   "vmjcNativeLoader", getLLVMModule());
   
   llvmArgs.clear();
-  FTy = FunctionType::get(Type::VoidTy, llvmArgs, false);
+  FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false);
   ObjectPrinter = Function::Create(FTy, GlobalValue::ExternalLinkage,
                                    "printJavaObject", getLLVMModule());
 
@@ -1490,7 +1503,7 @@
   
     
     Constant* cons = 
-      ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
+      ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
                                                  uint64_t(isolate)),
                                 ptrType);
 
@@ -1517,10 +1530,12 @@
   std::vector<const llvm::Type*> llvmArgs;
   llvmArgs.push_back(JnjvmModule::ptrType); // class loader
   llvmArgs.push_back(JnjvmModule::JavaCommonClassType); // cl
-  const FunctionType* FTy = FunctionType::get(Type::VoidTy, llvmArgs, false);
+  const FunctionType* FTy =
+    FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false);
 
   Function* AddClass = Function::Create(FTy, GlobalValue::ExternalLinkage,
-                                        "vmjcAddPreCompiledClass", getLLVMModule());
+                                        "vmjcAddPreCompiledClass",
+                                        getLLVMModule());
  
   llvmArgs.clear();
   // class loader
@@ -1529,12 +1544,13 @@
   llvmArgs.push_back(PointerType::getUnqual(JnjvmModule::JavaClassArrayType));
   // name
   llvmArgs.push_back(JnjvmModule::UTF8Type);
-  FTy = FunctionType::get(Type::VoidTy, llvmArgs, false);
+  FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false);
   
   Function* GetClassArray = Function::Create(FTy, GlobalValue::ExternalLinkage,
                                              "vmjcGetClassArray", getLLVMModule());
   
-  BasicBlock* currentBlock = BasicBlock::Create("enter", StaticInitializer);
+  BasicBlock* currentBlock = BasicBlock::Create(getGlobalContext(), "enter",
+                                                StaticInitializer);
   Function::arg_iterator loader = StaticInitializer->arg_begin();
   
   Value* Args[3];
@@ -1543,7 +1559,7 @@
     llvmArgs.clear();
     llvmArgs.push_back(JnjvmModule::ptrType); // class loader
     llvmArgs.push_back(strings.begin()->second->getType()); // val
-    FTy = FunctionType::get(Type::VoidTy, llvmArgs, false);
+    FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false);
   
     Function* AddString = Function::Create(FTy, GlobalValue::ExternalLinkage,
                                            "vmjcAddString", getLLVMModule());
@@ -1564,7 +1580,7 @@
     llvmArgs.clear();
     llvmArgs.push_back(JnjvmModule::ptrType); // class loader
     llvmArgs.push_back(utf8s.begin()->second->getType()); // val
-    FTy = FunctionType::get(Type::VoidTy, llvmArgs, false);
+    FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false);
   
     Function* AddUTF8 = Function::Create(FTy, GlobalValue::ExternalLinkage,
                                          "vmjcAddUTF8", getLLVMModule());
@@ -1598,7 +1614,7 @@
   }
   
 
-  ReturnInst::Create(currentBlock);
+  ReturnInst::Create(getGlobalContext(), currentBlock);
 }
 
 void JavaAOTCompiler::setNoInline(Class* cl) {
@@ -1941,21 +1957,24 @@
 
   // Type Definitions
   std::vector<const Type*> FuncArgs;
-  FuncArgs.push_back(Type::Int32Ty);
+  FuncArgs.push_back(Type::getInt32Ty(getGlobalContext()));
   FuncArgs.push_back(PointerType::getUnqual(JavaIntrinsics.ptrType));
   
-  FunctionType* FuncTy = FunctionType::get(Type::Int32Ty, FuncArgs, false);
+  FunctionType* FuncTy = FunctionType::get(Type::getInt32Ty(getGlobalContext()),
+                                           FuncArgs, false);
 
   Function* MainFunc = Function::Create(FuncTy, GlobalValue::ExternalLinkage,
                                         "main", TheModule);
-  BasicBlock* currentBlock = BasicBlock::Create("enter", MainFunc);
+  BasicBlock* currentBlock = BasicBlock::Create(getGlobalContext(), "enter",
+                                                MainFunc);
  
   GlobalVariable* GvarArrayStr = new GlobalVariable(
-    *TheModule, ArrayType::get(Type::Int8Ty, strlen(name) + 1), true,
-    GlobalValue::InternalLinkage, 0, "mainClass");
+    *TheModule, ArrayType::get(Type::getInt8Ty(getGlobalContext()),
+                               strlen(name) + 1),
+    true, GlobalValue::InternalLinkage, 0, "mainClass");
 
 
-  Constant* NameArray = ConstantArray::get(name, true);
+  Constant* NameArray = ConstantArray::get(getGlobalContext(), name, true);
   GvarArrayStr->setInitializer(NameArray);
   Value* Indices[2] = { JavaIntrinsics.constantZero,
                         JavaIntrinsics.constantZero };
@@ -1968,7 +1987,7 @@
 
   FuncArgs.push_back(Args[2]->getType());
 
-  FuncTy = FunctionType::get(Type::Int32Ty, FuncArgs, false);
+  FuncTy = FunctionType::get(Type::getInt32Ty(getGlobalContext()), FuncArgs, false);
 
   Function* CalledFunc = 
     Function::Create(FuncTy, GlobalValue::ExternalLinkage,
@@ -1976,6 +1995,6 @@
                      TheModule);
 
   Value* res = CallInst::Create(CalledFunc, Args, Args + 3, "", currentBlock);
-  ReturnInst::Create(res, currentBlock);
+  ReturnInst::Create(getGlobalContext(), res, currentBlock);
 
 }

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp Sat Aug 15 10:54:14 2009
@@ -137,7 +137,7 @@
       res = invoke(func, args, "", currentBlock);
     }
     BranchInst::Create(endBlock, currentBlock);
-    if (retType != Type::VoidTy) {
+    if (retType != Type::getVoidTy(getGlobalContext())) {
       node = PHINode::Create(virtualType->getReturnType(), "", endBlock);
       node->addIncoming(res, currentBlock);
     }
@@ -158,13 +158,13 @@
     Constant* Offset = LMI->getOffset();
     indexes2[1] = Offset;
 #ifdef ISOLATE_SHARING
-    indexesCtp = ConstantInt::get(Type::Int32Ty,
+    indexesCtp = ConstantInt::get(Type::getInt32Ty(getGlobalContext()),
                                   Offset->getZExtValue() * -1);
 #endif
   } else {
     
     Value* val = getConstantPoolAt(index, module->VirtualLookupFunction,
-                                   Type::Int32Ty, args[0], true);
+                                   Type::getInt32Ty(getGlobalContext()), args[0], true);
     indexes2[1] = val;
 #ifdef ISOLATE_SHARING
     Value* mul = BinaryOperator::CreateMul(val, module->constantMinusOne,
@@ -197,9 +197,9 @@
     currentBlock = endBlock;
   }
 
-  if (retType != Type::VoidTy) {
+  if (retType != Type::getVoidTy(getGlobalContext())) {
     push(val, retTypedef->isUnsigned());
-    if (retType == Type::DoubleTy || retType == Type::Int64Ty) {
+    if (retType == Type::getDoubleTy(getGlobalContext()) || retType == Type::getInt64Ty(getGlobalContext())) {
       push(module->constantZero, false);
     }
   }
@@ -254,10 +254,10 @@
   if (!natPtr && !TheCompiler->isStaticCompiling()) {
     currentBlock = createBasicBlock("start");
     CallInst::Create(module->ThrowExceptionFromJITFunction, "", currentBlock);
-    if (returnType != Type::VoidTy)
-      ReturnInst::Create(Constant::getNullValue(returnType), currentBlock);
+    if (returnType != Type::getVoidTy(getGlobalContext()))
+      ReturnInst::Create(*llvmContext, Constant::getNullValue(returnType), currentBlock);
     else
-      ReturnInst::Create(currentBlock);
+      ReturnInst::Create(*llvmContext, currentBlock);
   
     PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "end native compile %s.%s\n",
                 UTF8Buffer(compilingClass->name).cString(),
@@ -279,17 +279,17 @@
   BasicBlock* executeBlock = createBasicBlock("execute");
   endBlock = createBasicBlock("end block");
   
-  Constant* sizeB = ConstantInt::get(Type::Int32Ty, sizeof(jmp_buf));
+  Constant* sizeB = ConstantInt::get(Type::getInt32Ty(getGlobalContext()), sizeof(jmp_buf));
   Value* oldJB = new AllocaInst(module->ptrType, "", currentBlock);
-  Value* newJB = new AllocaInst(Type::Int8Ty, sizeB, "", currentBlock);
+  Value* newJB = new AllocaInst(Type::getInt8Ty(getGlobalContext()), sizeB, "", currentBlock);
       
   // Allocate currentLocalIndexNumber pointer
-  Value* temp = new AllocaInst(Type::Int32Ty, "",
+  Value* temp = new AllocaInst(Type::getInt32Ty(getGlobalContext()), "",
                                currentBlock);
   new StoreInst(module->constantZero, temp, false, currentBlock);
   
   // Allocate oldCurrentLocalIndexNumber pointer
-  Value* oldCLIN = new AllocaInst(PointerType::getUnqual(Type::Int32Ty), "",
+  Value* oldCLIN = new AllocaInst(PointerType::getUnqual(Type::getInt32Ty(getGlobalContext())), "",
                                   currentBlock);
 
   Value* test = CallInst::Create(module->setjmpLLVM, newJB, "",
@@ -299,7 +299,7 @@
                       module->constantZero, "");
   BranchInst::Create(executeBlock, endBlock, test, currentBlock);
   
-  if (returnType != Type::VoidTy) {
+  if (returnType != Type::getVoidTy(getGlobalContext())) {
     endNode = PHINode::Create(returnType, "", endBlock);
     endNode->addIncoming(Constant::getNullValue(returnType),
                          currentBlock);
@@ -441,7 +441,7 @@
     
     endNode->addIncoming(result, currentBlock);
 
-  } else if (returnType != Type::VoidTy) {
+  } else if (returnType != Type::getVoidTy(getGlobalContext())) {
     endNode->addIncoming(result, currentBlock);
   }
   
@@ -456,10 +456,10 @@
 
   CallInst::Create(module->EndJNIFunction, Args2, Args2 + 2, "", currentBlock);
   
-  if (returnType != Type::VoidTy)
-    ReturnInst::Create(endNode, currentBlock);
+  if (returnType != Type::getVoidTy(getGlobalContext()))
+    ReturnInst::Create(*llvmContext, endNode, currentBlock);
   else
-    ReturnInst::Create(currentBlock);
+    ReturnInst::Create(*llvmContext, currentBlock);
   
   PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "end native compile %s.%s\n",
               UTF8Buffer(compilingClass->name).cString(),
@@ -735,30 +735,30 @@
     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(Type::getInt32Ty(getGlobalContext()), "", firstInstruction));
+      doubleLocals.push_back(new AllocaInst(Type::getDoubleTy(getGlobalContext()), "",
                                             firstInstruction));
-      longLocals.push_back(new AllocaInst(Type::Int64Ty, "", firstInstruction));
-      floatLocals.push_back(new AllocaInst(Type::FloatTy, "", firstInstruction));
+      longLocals.push_back(new AllocaInst(Type::getInt64Ty(getGlobalContext()), "", firstInstruction));
+      floatLocals.push_back(new AllocaInst(Type::getFloatTy(getGlobalContext()), "", firstInstruction));
       objectLocals.push_back(new AllocaInst(module->JavaObjectType, "",
                                           firstInstruction));
     }
     for (int i = 0; i < maxStack; i++) {
       objectStack.push_back(new AllocaInst(module->JavaObjectType, "",
                                            firstInstruction));
-      intStack.push_back(new AllocaInst(Type::Int32Ty, "", firstInstruction));
-      doubleStack.push_back(new AllocaInst(Type::DoubleTy, "",
+      intStack.push_back(new AllocaInst(Type::getInt32Ty(getGlobalContext()), "", firstInstruction));
+      doubleStack.push_back(new AllocaInst(Type::getDoubleTy(getGlobalContext()), "",
                                            firstInstruction));
-      longStack.push_back(new AllocaInst(Type::Int64Ty, "", firstInstruction));
-      floatStack.push_back(new AllocaInst(Type::FloatTy, "", firstInstruction));
+      longStack.push_back(new AllocaInst(Type::getInt64Ty(getGlobalContext()), "", firstInstruction));
+      floatStack.push_back(new AllocaInst(Type::getFloatTy(getGlobalContext()), "", 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));
+      intLocals.push_back(new AllocaInst(Type::getInt32Ty(getGlobalContext()), "", firstBB));
+      doubleLocals.push_back(new AllocaInst(Type::getDoubleTy(getGlobalContext()), "", firstBB));
+      longLocals.push_back(new AllocaInst(Type::getInt64Ty(getGlobalContext()), "", firstBB));
+      floatLocals.push_back(new AllocaInst(Type::getFloatTy(getGlobalContext()), "", firstBB));
       objectLocals.push_back(new AllocaInst(module->JavaObjectType, "",
                                             firstBB));
     }
@@ -766,10 +766,10 @@
     for (int i = 0; i < maxStack; i++) {
       objectStack.push_back(new AllocaInst(module->JavaObjectType, "",
                                            firstBB));
-      intStack.push_back(new AllocaInst(Type::Int32Ty, "", firstBB));
-      doubleStack.push_back(new AllocaInst(Type::DoubleTy, "", firstBB));
-      longStack.push_back(new AllocaInst(Type::Int64Ty, "", firstBB));
-      floatStack.push_back(new AllocaInst(Type::FloatTy, "", firstBB));
+      intStack.push_back(new AllocaInst(Type::getInt32Ty(getGlobalContext()), "", firstBB));
+      doubleStack.push_back(new AllocaInst(Type::getDoubleTy(getGlobalContext()), "", firstBB));
+      longStack.push_back(new AllocaInst(Type::getInt64Ty(getGlobalContext()), "", firstBB));
+      floatStack.push_back(new AllocaInst(Type::getFloatTy(getGlobalContext()), "", firstBB));
     }
   }
       
@@ -799,21 +799,21 @@
     const Typedef* cur = arguments[type];
     const Type* curType = (*i)->getType();
 
-    if (curType == Type::Int64Ty){
+    if (curType == Type::getInt64Ty(getGlobalContext())){
       new StoreInst(*i, longLocals[index], false, currentBlock);
       ++index;
     } else if (cur->isUnsigned()) {
-      new StoreInst(new ZExtInst(*i, Type::Int32Ty, "", currentBlock),
+      new StoreInst(new ZExtInst(*i, Type::getInt32Ty(getGlobalContext()), "", currentBlock),
                     intLocals[index], false, currentBlock);
-    } else if (curType == Type::Int8Ty || curType == Type::Int16Ty) {
-      new StoreInst(new SExtInst(*i, Type::Int32Ty, "", currentBlock),
+    } else if (curType == Type::getInt8Ty(getGlobalContext()) || curType == Type::getInt16Ty(getGlobalContext())) {
+      new StoreInst(new SExtInst(*i, Type::getInt32Ty(getGlobalContext()), "", currentBlock),
                     intLocals[index], false, currentBlock);
-    } else if (curType == Type::Int32Ty) {
+    } else if (curType == Type::getInt32Ty(getGlobalContext())) {
       new StoreInst(*i, intLocals[index], false, currentBlock);
-    } else if (curType == Type::DoubleTy) {
+    } else if (curType == Type::getDoubleTy(getGlobalContext())) {
       new StoreInst(*i, doubleLocals[index], false, currentBlock);
       ++index;
-    } else if (curType == Type::FloatTy) {
+    } else if (curType == Type::getFloatTy(getGlobalContext())) {
       new StoreInst(*i, floatLocals[index], false, currentBlock);
     } else {
       new StoreInst(*i, objectLocals[index], false, currentBlock);
@@ -825,7 +825,7 @@
   exploreOpcodes(&compilingClass->bytes->elements[start], codeLen);
   nbEnveloppes = 0;
 
-  if (returnType != Type::VoidTy) {
+  if (returnType != Type::getVoidTy(getGlobalContext())) {
     endNode = PHINode::Create(returnType, "", endBlock);
   }
 
@@ -907,10 +907,10 @@
   
 
   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));
+    intLocals.push_back(new AllocaInst(Type::getInt32Ty(getGlobalContext()), "", currentBlock));
+    doubleLocals.push_back(new AllocaInst(Type::getDoubleTy(getGlobalContext()), "", currentBlock));
+    longLocals.push_back(new AllocaInst(Type::getInt64Ty(getGlobalContext()), "", currentBlock));
+    floatLocals.push_back(new AllocaInst(Type::getFloatTy(getGlobalContext()), "", currentBlock));
     objectLocals.push_back(new AllocaInst(module->JavaObjectType, "",
                                           currentBlock));
   }
@@ -918,10 +918,10 @@
   for (int i = 0; i < maxStack; i++) {
     objectStack.push_back(new AllocaInst(module->JavaObjectType, "",
                                          currentBlock));
-    intStack.push_back(new AllocaInst(Type::Int32Ty, "", currentBlock));
-    doubleStack.push_back(new AllocaInst(Type::DoubleTy, "", currentBlock));
-    longStack.push_back(new AllocaInst(Type::Int64Ty, "", currentBlock));
-    floatStack.push_back(new AllocaInst(Type::FloatTy, "", currentBlock));
+    intStack.push_back(new AllocaInst(Type::getInt32Ty(getGlobalContext()), "", currentBlock));
+    doubleStack.push_back(new AllocaInst(Type::getDoubleTy(getGlobalContext()), "", currentBlock));
+    longStack.push_back(new AllocaInst(Type::getInt64Ty(getGlobalContext()), "", currentBlock));
+    floatStack.push_back(new AllocaInst(Type::getFloatTy(getGlobalContext()), "", currentBlock));
   }
   
   uint32 index = 0;
@@ -948,21 +948,21 @@
     const Typedef* cur = arguments[type];
     const llvm::Type* curType = i->getType();
 
-    if (curType == Type::Int64Ty){
+    if (curType == Type::getInt64Ty(getGlobalContext())){
       new StoreInst(i, longLocals[index], false, currentBlock);
       ++index;
     } else if (cur->isUnsigned()) {
-      new StoreInst(new ZExtInst(i, Type::Int32Ty, "", currentBlock),
+      new StoreInst(new ZExtInst(i, Type::getInt32Ty(getGlobalContext()), "", currentBlock),
                     intLocals[index], false, currentBlock);
-    } else if (curType == Type::Int8Ty || curType == Type::Int16Ty) {
-      new StoreInst(new SExtInst(i, Type::Int32Ty, "", currentBlock),
+    } else if (curType == Type::getInt8Ty(getGlobalContext()) || curType == Type::getInt16Ty(getGlobalContext())) {
+      new StoreInst(new SExtInst(i, Type::getInt32Ty(getGlobalContext()), "", currentBlock),
                     intLocals[index], false, currentBlock);
-    } else if (curType == Type::Int32Ty) {
+    } else if (curType == Type::getInt32Ty(getGlobalContext())) {
       new StoreInst(i, intLocals[index], false, currentBlock);
-    } else if (curType == Type::DoubleTy) {
+    } else if (curType == Type::getDoubleTy(getGlobalContext())) {
       new StoreInst(i, doubleLocals[index], false, currentBlock);
       ++index;
-    } else if (curType == Type::FloatTy) {
+    } else if (curType == Type::getFloatTy(getGlobalContext())) {
       new StoreInst(i, floatLocals[index], false, currentBlock);
     } else {
       new StoreInst(i, objectLocals[index], false, currentBlock);
@@ -1038,7 +1038,7 @@
  
   endBlock = createBasicBlock("end");
 
-  if (returnType != Type::VoidTy) {
+  if (returnType != Type::getVoidTy(getGlobalContext())) {
     endNode = llvm::PHINode::Create(returnType, "", endBlock);
   }
   
@@ -1097,7 +1097,7 @@
   // not return.
   pred_iterator PI = pred_begin(endBlock);
   pred_iterator PE = pred_end(endBlock);
-  if (PI == PE && returnType != Type::VoidTy) {
+  if (PI == PE && returnType != Type::getVoidTy(getGlobalContext())) {
     Instruction* I = currentBlock->getTerminator();
     
     if (isa<UnreachableInst>(I)) {
@@ -1151,10 +1151,10 @@
   if (PI == PE) {
     currentBlock->eraseFromParent();
   } else {
-    if (returnType != Type::VoidTy)
-      ReturnInst::Create(endNode, currentBlock);
+    if (returnType != Type::getVoidTy(getGlobalContext()))
+      ReturnInst::Create(*llvmContext, endNode, currentBlock);
     else
-      ReturnInst::Create(currentBlock);
+      ReturnInst::Create(*llvmContext, currentBlock);
   }
 
   currentBlock = endExceptionBlock;
@@ -1232,16 +1232,16 @@
     }
 #endif   
   } else if (type == JavaConstantPool::ConstantLong) {
-    push(ConstantInt::get(Type::Int64Ty, ctpInfo->LongAt(index)),
+    push(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), ctpInfo->LongAt(index)),
          false);
   } else if (type == JavaConstantPool::ConstantDouble) {
-    push(ConstantFP::get(Type::DoubleTy, ctpInfo->DoubleAt(index)),
+    push(ConstantFP::get(Type::getDoubleTy(getGlobalContext()), ctpInfo->DoubleAt(index)),
          false);
   } else if (type == JavaConstantPool::ConstantInteger) {
-    push(ConstantInt::get(Type::Int32Ty, ctpInfo->IntegerAt(index)),
+    push(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), ctpInfo->IntegerAt(index)),
          false);
   } else if (type == JavaConstantPool::ConstantFloat) {
-    push(ConstantFP::get(Type::FloatTy, ctpInfo->FloatAt(index)),
+    push(ConstantFP::get(Type::getFloatTy(getGlobalContext()), ctpInfo->FloatAt(index)),
          false);
   } else if (type == JavaConstantPool::ConstantClass) {
     UserCommonClass* cl = 0;
@@ -1280,8 +1280,8 @@
                                     const Type* arrayType, bool verif) {
   JITVerifyNull(obj);
   
-  if (index->getType() != Type::Int32Ty) {
-    index = new SExtInst(index, Type::Int32Ty, "", currentBlock);
+  if (index->getType() != Type::getInt32Ty(getGlobalContext())) {
+    index = new SExtInst(index, Type::getInt32Ty(getGlobalContext()), "", currentBlock);
   }
   
   if (TheCompiler->hasExceptionsEnabled()) {
@@ -1329,7 +1329,7 @@
 #endif
   for (sint32 i = start; i >= 0; --i) {
     it--;
-    if (it->get() == Type::Int64Ty || it->get() == Type::DoubleTy) {
+    if (it->get() == Type::getInt64Ty(getGlobalContext()) || it->get() == Type::getDoubleTy(getGlobalContext())) {
       pop();
     }
     bool unsign = topIsUnsigned();
@@ -1355,23 +1355,23 @@
          e = stack.end(); i!= e; ++i) {
       switch (*i) {
         case Int : {
-          PHINode* node = PHINode::Create(Type::Int32Ty, "", dest);
-          node->addIncoming(Constant::getNullValue(Type::Int32Ty), insert);
+          PHINode* node = PHINode::Create(Type::getInt32Ty(getGlobalContext()), "", dest);
+          node->addIncoming(Constant::getNullValue(Type::getInt32Ty(getGlobalContext())), insert);
           break;
         }
         case Float : {
-          PHINode* node = PHINode::Create(Type::FloatTy, "", dest);
-          node->addIncoming(Constant::getNullValue(Type::FloatTy), insert);
+          PHINode* node = PHINode::Create(Type::getFloatTy(getGlobalContext()), "", dest);
+          node->addIncoming(Constant::getNullValue(Type::getFloatTy(getGlobalContext())), insert);
           break;
         }
         case Double : {
-          PHINode* node = PHINode::Create(Type::DoubleTy, "", dest);
-          node->addIncoming(Constant::getNullValue(Type::DoubleTy), insert);
+          PHINode* node = PHINode::Create(Type::getDoubleTy(getGlobalContext()), "", dest);
+          node->addIncoming(Constant::getNullValue(Type::getDoubleTy(getGlobalContext())), insert);
           break;
         }
         case Long : {
-          PHINode* node = PHINode::Create(Type::Int64Ty, "", dest);
-          node->addIncoming(Constant::getNullValue(Type::Int64Ty), insert);
+          PHINode* node = PHINode::Create(Type::getInt64Ty(getGlobalContext()), "", dest);
+          node->addIncoming(Constant::getNullValue(Type::getInt64Ty(getGlobalContext())), insert);
           break;
         }
         case Object : {
@@ -1401,7 +1401,7 @@
   JnjvmBootstrapLoader* loader = compilingClass->classLoader->bootstrapLoader;
   if (name->equals(loader->abs)) {
     const Type* Ty = args[0]->getType();
-    if (Ty == Type::Int32Ty) {
+    if (Ty == Type::getInt32Ty(getGlobalContext())) {
       Constant* const_int32_9 = module->constantZero;
       Constant* const_int32_10 = module->constantMinusOne;
       BinaryOperator* int32_tmpneg = 
@@ -1412,7 +1412,7 @@
                      "abscond");
       return llvm::SelectInst::Create(int1_abscond, args[0], int32_tmpneg,
                                       "abs", currentBlock);
-    } else if (Ty == Type::Int64Ty) {
+    } else if (Ty == Type::getInt64Ty(getGlobalContext())) {
       Constant* const_int64_9 = module->constantLongZero;
       Constant* const_int64_10 = module->constantLongMinusOne;
       
@@ -1425,10 +1425,10 @@
       
       return llvm::SelectInst::Create(int1_abscond, args[0], int64_tmpneg,
                                       "abs", currentBlock);
-    } else if (Ty == Type::FloatTy) {
+    } else if (Ty == Type::getFloatTy(getGlobalContext())) {
       return llvm::CallInst::Create(module->func_llvm_fabs_f32, args[0],
                                     "tmp1", currentBlock);
-    } else if (Ty == Type::DoubleTy) {
+    } else if (Ty == Type::getDoubleTy(getGlobalContext())) {
       return llvm::CallInst::Create(module->func_llvm_fabs_f64, args[0],
                                     "tmp1", currentBlock);
     }
@@ -1568,7 +1568,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(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), index));
   Args.push_back(GV);
   res = CallInst::Create(module->SpecialCtpLookupFunction, Args.begin(),
                          Args.end(), "", falseCl);
@@ -1598,9 +1598,9 @@
   }
   
   const llvm::Type* retType = virtualType->getReturnType();
-  if (retType != Type::VoidTy) {
+  if (retType != Type::getVoidTy(getGlobalContext())) {
     push(val, signature->getReturnType()->isUnsigned());
-    if (retType == Type::DoubleTy || retType == Type::Int64Ty) {
+    if (retType == Type::getDoubleTy(getGlobalContext()) || retType == Type::getInt64Ty(getGlobalContext())) {
       push(module->constantZero, false);
     }
   }
@@ -1667,9 +1667,9 @@
   }
 
   const llvm::Type* retType = staticType->getReturnType();
-  if (retType != Type::VoidTy) {
+  if (retType != Type::getVoidTy(getGlobalContext())) {
     push(val, signature->getReturnType()->isUnsigned());
-    if (retType == Type::DoubleTy || retType == Type::Int64Ty) {
+    if (retType == Type::getDoubleTy(getGlobalContext()) || retType == Type::getInt64Ty(getGlobalContext())) {
       push(module->constantZero, false);
     }
   }
@@ -1696,7 +1696,7 @@
   Args.push_back(resolver);
   Args.push_back(CTP);
   Args.push_back(Cl);
-  Args.push_back(ConstantInt::get(Type::Int32Ty, index));
+  Args.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), index));
   if (additionalArg) Args.push_back(additionalArg);
 
   Value* res = 0;
@@ -1710,8 +1710,8 @@
   
   const Type* realType = 
     module->GetConstantPoolAtFunction->getReturnType();
-  if (returnType == Type::Int32Ty) {
-    return new PtrToIntInst(res, Type::Int32Ty, "", currentBlock);
+  if (returnType == Type::getInt32Ty(getGlobalContext())) {
+    return new PtrToIntInst(res, Type::getInt32Ty(getGlobalContext()), "", currentBlock);
   } else if (returnType != realType) {
     return new BitCastInst(res, returnType, "", currentBlock);
   } 
@@ -1859,7 +1859,7 @@
   if (stat)
     returnType = module->ptrType;
   else
-    returnType = Type::Int32Ty;
+    returnType = Type::getInt32Ty(getGlobalContext());
 
   Value* ptr = getConstantPoolAt(index, func, returnType, 0, true);
   if (!stat) {
@@ -1906,7 +1906,7 @@
   LLVMAssessorInfo& LAI = TheCompiler->getTypedefInfo(sign);
   const Type* type = LAI.llvmType;
   
-  if (type == Type::Int64Ty || type == Type::DoubleTy) {
+  if (type == Type::getInt64Ty(getGlobalContext()) || type == Type::getDoubleTy(getGlobalContext())) {
     val = pop();
   }
   
@@ -1938,28 +1938,28 @@
         const PrimitiveTypedef* prim = (PrimitiveTypedef*)sign;
         if (prim->isInt()) {
           sint32 val = field->getInt32Field(Obj);
-          push(ConstantInt::get(Type::Int32Ty, val), false);
+          push(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), val), false);
         } else if (prim->isByte()) {
           sint8 val = (sint8)field->getInt8Field(Obj);
-          push(ConstantInt::get(Type::Int8Ty, val), false);
+          push(ConstantInt::get(Type::getInt8Ty(getGlobalContext()), val), false);
         } else if (prim->isBool()) {
           uint8 val = (uint8)field->getInt8Field(Obj);
-          push(ConstantInt::get(Type::Int8Ty, val), true);
+          push(ConstantInt::get(Type::getInt8Ty(getGlobalContext()), val), true);
         } else if (prim->isShort()) {
           sint16 val = (sint16)field->getInt16Field(Obj);
-          push(ConstantInt::get(Type::Int16Ty, val), false);
+          push(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), val), false);
         } else if (prim->isChar()) {
           uint16 val = (uint16)field->getInt16Field(Obj);
-          push(ConstantInt::get(Type::Int16Ty, val), true);
+          push(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), val), true);
         } else if (prim->isLong()) {
           sint64 val = (sint64)field->getLongField(Obj);
-          push(ConstantInt::get(Type::Int64Ty, val), false);
+          push(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), val), false);
         } else if (prim->isFloat()) {
           float val = (float)field->getFloatField(Obj);
-          push(ConstantFP::get(Type::FloatTy, val), false);
+          push(ConstantFP::get(Type::getFloatTy(getGlobalContext()), val), false);
         } else if (prim->isDouble()) {
           double val = (double)field->getDoubleField(Obj);
-          push(ConstantFP::get(Type::DoubleTy, val), false);
+          push(ConstantFP::get(Type::getDoubleTy(getGlobalContext()), val), false);
         } else {
           abort();
         }
@@ -1980,7 +1980,7 @@
 #endif
 
   if (!final) push(new LoadInst(ptr, "", currentBlock), sign->isUnsigned());
-  if (type == Type::Int64Ty || type == Type::DoubleTy) {
+  if (type == Type::getInt64Ty(getGlobalContext()) || type == Type::getDoubleTy(getGlobalContext())) {
     push(module->constantZero, false);
   }
 }
@@ -1992,7 +1992,7 @@
   LLVMAssessorInfo& LAI = TheCompiler->getTypedefInfo(sign);
   const Type* type = LAI.llvmType;
   
-  if (type == Type::Int64Ty || type == Type::DoubleTy) {
+  if (type == Type::getInt64Ty(getGlobalContext()) || type == Type::getDoubleTy(getGlobalContext())) {
     val = pop();
   }
   
@@ -2052,7 +2052,7 @@
   }
  
   if (!final) push(new LoadInst(ptr, "", currentBlock), sign->isUnsigned());
-  if (type == Type::Int64Ty || type == Type::DoubleTy) {
+  if (type == Type::getInt64Ty(getGlobalContext()) || type == Type::getDoubleTy(getGlobalContext())) {
     push(module->constantZero, false);
   }
 }
@@ -2077,7 +2077,7 @@
   const llvm::Type* retType = virtualType->getReturnType();
   BasicBlock* endBlock = createBasicBlock("end virtual invoke");
   PHINode * node = 0;
-  if (retType != Type::VoidTy) {
+  if (retType != Type::getVoidTy(getGlobalContext())) {
     node = PHINode::Create(retType, "", endBlock);
   }
   
@@ -2162,7 +2162,8 @@
   currentBlock = endBlock;
   if (node) {
     push(node, signature->getReturnType()->isUnsigned());
-    if (retType == Type::DoubleTy || retType == Type::Int64Ty) {
+    if (retType == Type::getDoubleTy(getGlobalContext()) ||
+        retType == Type::getInt64Ty(getGlobalContext())) {
       push(module->constantZero, false);
     }
   }

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.h (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.h Sat Aug 15 10:54:14 2009
@@ -212,28 +212,30 @@
   void push(llvm::Value* val, bool unsign) {
     const llvm::Type* type = val->getType();
     if (unsign) {
-      val = new llvm::ZExtInst(val, llvm::Type::Int32Ty, "", currentBlock);
+      val = new llvm::ZExtInst(val, llvm::Type::getInt32Ty(*llvmContext), "", currentBlock);
       new llvm::StoreInst(val, intStack[currentStackIndex++], false,
                           currentBlock);
       stack.push_back(Int);
-    } else if (type == llvm::Type::Int8Ty || type == llvm::Type::Int16Ty) {
-      val = new llvm::SExtInst(val, llvm::Type::Int32Ty, "", currentBlock);
+    } else if (type == llvm::Type::getInt8Ty(*llvmContext) ||
+               type == llvm::Type::getInt16Ty(*llvmContext)) {
+      val = new llvm::SExtInst(val, llvm::Type::getInt32Ty(*llvmContext), "",
+                               currentBlock);
       new llvm::StoreInst(val, intStack[currentStackIndex++], false,
                           currentBlock);
       stack.push_back(Int);
-    } else if (type == llvm::Type::Int32Ty) {
+    } else if (type == llvm::Type::getInt32Ty(*llvmContext)) {
       new llvm::StoreInst(val, intStack[currentStackIndex++], false,
                           currentBlock);
       stack.push_back(Int);
-    } else if (type == llvm::Type::Int64Ty) {
+    } else if (type == llvm::Type::getInt64Ty(*llvmContext)) {
       new llvm::StoreInst(val, longStack[currentStackIndex++], false,
                           currentBlock);
       stack.push_back(Long);
-    } else if (type == llvm::Type::FloatTy) {
+    } else if (type == llvm::Type::getFloatTy(*llvmContext)) {
       new llvm::StoreInst(val, floatStack[currentStackIndex++], false,
                           currentBlock);
       stack.push_back(Float);
-    } else if (type == llvm::Type::DoubleTy) {
+    } else if (type == llvm::Type::getDoubleTy(*llvmContext)) {
       new llvm::StoreInst(val, doubleStack[currentStackIndex++], false,
                           currentBlock);
       stack.push_back(Double);
@@ -335,7 +337,7 @@
 
   /// createBasicBlock - Create a new basic block.
   llvm::BasicBlock* createBasicBlock(const char* name = "") {
-    return llvm::BasicBlock::Create(name, llvmFunction);  
+    return llvm::BasicBlock::Create(*llvmContext, name, llvmFunction);
   }
  
   /// branch - Branch based on a boolean value. Update PHI nodes accordingly.

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp Sat Aug 15 10:54:14 2009
@@ -32,45 +32,52 @@
   const llvm::Type* Ty = classDef->isClass() ? JnjvmModule::JavaClassType :
                                                JnjvmModule::JavaCommonClassType;
   
-  ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64_t(classDef));
+  ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
+                                     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));
+  ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
+                                     uint64_t(ptr));
   return ConstantExpr::getIntToPtr(CI, JnjvmModule::ConstantPoolType);
 }
 
 Constant* JavaJITCompiler::getMethodInClass(JavaMethod* meth) {
-  ConstantInt* CI = ConstantInt::get(Type::Int64Ty, (int64_t)meth);
+  ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
+                                     (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));
+  ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
+                                     uint64(str));
   return ConstantExpr::getIntToPtr(CI, JnjvmModule::JavaObjectType);
 }
 
 Constant* JavaJITCompiler::getStringPtr(JavaString** str) {
   assert(str && "No string given");
   const llvm::Type* Ty = PointerType::getUnqual(JnjvmModule::JavaObjectType);
-  ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64(str));
+  ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
+                                     uint64(str));
   return ConstantExpr::getIntToPtr(CI, Ty);
 }
 
 Constant* JavaJITCompiler::getEnveloppe(Enveloppe* enveloppe) {
   assert(enveloppe && "No enveloppe given");
-  ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64(enveloppe));
+  ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
+                                     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));
+  Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
+                                  uint64(obj));
   return ConstantExpr::getIntToPtr(CI, JnjvmModule::JavaObjectType);
 }
 
@@ -78,7 +85,8 @@
   Jnjvm* vm = JavaThread::get()->getJVM();
   JavaObject* const* obj = cl->getClassDelegateePtr(vm);
   assert(obj && "Delegatee not created");
-  Constant* CI = ConstantInt::get(Type::Int64Ty, uint64(obj));
+  Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
+                                  uint64(obj));
   const Type* Ty = PointerType::getUnqual(JnjvmModule::JavaObjectType);
   return ConstantExpr::getIntToPtr(CI, Ty);
 }
@@ -93,7 +101,8 @@
 }
 
 Constant* JavaJITCompiler::getFinalObject(JavaObject* obj) {
-  Constant* CI = ConstantInt::get(Type::Int64Ty, uint64(obj));
+  Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
+                                  uint64(obj));
   return ConstantExpr::getIntToPtr(CI, JnjvmModule::JavaObjectType);
 }
 
@@ -112,7 +121,8 @@
     }
     classDef->release();
   }
-  Constant* CI = ConstantInt::get(Type::Int64Ty, (uint64_t(obj)));
+  Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
+                                  (uint64_t(obj)));
   return ConstantExpr::getIntToPtr(CI, JnjvmModule::ptrType);
 }
 
@@ -122,7 +132,8 @@
     LCI->getVirtualType();
   }
   
-  ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64_t(VT));
+  ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
+                                     uint64_t(VT));
   return ConstantExpr::getIntToPtr(CI, JnjvmModule::VTType);
 }
 
@@ -132,7 +143,8 @@
   
   assert(ptr && "No native function given");
 
-  Constant* CI = ConstantInt::get(Type::Int64Ty, uint64_t(ptr));
+  Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
+                                  uint64_t(ptr));
   return ConstantExpr::getIntToPtr(CI, valPtrType);
 }
 
@@ -150,7 +162,8 @@
 
 #ifdef SERVICE
 Value* JavaJITCompiler::getIsolate(Jnjvm* isolate, Value* Where) {
-  ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64_t(isolate));
+  ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
+                                     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=79108&r1=79107&r2=79108&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp Sat Aug 15 10:54:14 2009
@@ -152,13 +152,13 @@
         } else {
           ++currentStackIndex;
           const Type* Ty = i->getType();
-          if (Ty == Type::Int32Ty) {
+          if (Ty == Type::getInt32Ty(*llvmContext)) {
             stack.push_back(Int);
-          } else if (Ty == Type::Int64Ty) {
+          } else if (Ty == Type::getInt64Ty(*llvmContext)) {
             stack.push_back(Long);
-          } else if (Ty == Type::FloatTy) {
+          } else if (Ty == Type::getFloatTy(*llvmContext)) {
             stack.push_back(Float);
-          } else if (Ty == Type::DoubleTy) {
+          } else if (Ty == Type::getDoubleTy(*llvmContext)) {
             stack.push_back(Double);
           } else if (Ty == module->JavaObjectType) {
             stack.push_back(Object);
@@ -182,8 +182,8 @@
 #if JNJVM_EXECUTE > 1
     {
       Value* args[3] = {
-        ConstantInt::get(Type::Int32Ty, (int64_t)bytecodes[i]),
-        ConstantInt::get(Type::Int32Ty, (int64_t)i),
+        ConstantInt::get(Type::getInt32Ty(*llvmContext), (int64_t)bytecodes[i]),
+        ConstantInt::get(Type::getInt32Ty(*llvmContext), (int64_t)i),
         TheCompiler->getMethodInClass(compilingMethod)
       };
     
@@ -262,15 +262,15 @@
         break;
 
       case BIPUSH : 
-        push(ConstantExpr::getSExt(ConstantInt::get(Type::Int8Ty,
+        push(ConstantExpr::getSExt(ConstantInt::get(Type::getInt8Ty(*llvmContext),
                                                     bytecodes[++i]),
-                                   Type::Int32Ty), false);
+                                   Type::getInt32Ty(*llvmContext)), false);
         break;
 
       case SIPUSH :
-        push(ConstantExpr::getSExt(ConstantInt::get(Type::Int16Ty,
+        push(ConstantExpr::getSExt(ConstantInt::get(Type::getInt16Ty(*llvmContext),
                                                     readS2(bytecodes, i)),
-                                   Type::Int32Ty), false);
+                                   Type::getInt32Ty(*llvmContext)), false);
         break;
 
       case LDC :
@@ -470,7 +470,7 @@
         Value* ptr = verifyAndComputePtr(obj, index,
                                          module->JavaArraySInt8Type);
         Value* val = new LoadInst(ptr, "", currentBlock);
-        push(new SExtInst(val, Type::Int32Ty, "", currentBlock),
+        push(new SExtInst(val, Type::getInt32Ty(*llvmContext), "", currentBlock),
              false);
         break;
       }
@@ -481,7 +481,7 @@
         Value* ptr = verifyAndComputePtr(obj, index,
                                          module->JavaArrayUInt16Type);
         Value* val = new LoadInst(ptr, "", currentBlock);
-        push(new ZExtInst(val, Type::Int32Ty, "", currentBlock),
+        push(new ZExtInst(val, Type::getInt32Ty(*llvmContext), "", currentBlock),
              false);
         break;
       }
@@ -492,7 +492,7 @@
         Value* ptr = verifyAndComputePtr(obj, index,
                                          module->JavaArraySInt16Type);
         Value* val = new LoadInst(ptr, "", currentBlock);
-        push(new SExtInst(val, Type::Int32Ty, "", currentBlock),
+        push(new SExtInst(val, Type::getInt32Ty(*llvmContext), "", currentBlock),
              false);
         break;
       }
@@ -528,32 +528,32 @@
       
       case ISTORE_0 : {
         Value* val = pop();
-        if (val->getType() != Type::Int32Ty) // int8 and int16
-          val = new ZExtInst(val, Type::Int32Ty, "", currentBlock);
+        if (val->getType() != Type::getInt32Ty(*llvmContext)) // int8 and int16
+          val = new ZExtInst(val, Type::getInt32Ty(*llvmContext), "", currentBlock);
         new StoreInst(val, intLocals[0], false, currentBlock);
         break;
       }
       
       case ISTORE_1 : {
         Value* val = pop();
-        if (val->getType() != Type::Int32Ty) // int8 and int16
-          val = new ZExtInst(val, Type::Int32Ty, "", currentBlock);
+        if (val->getType() != Type::getInt32Ty(*llvmContext)) // int8 and int16
+          val = new ZExtInst(val, Type::getInt32Ty(*llvmContext), "", currentBlock);
         new StoreInst(val, intLocals[1], false, currentBlock);
         break;
       }
 
       case ISTORE_2 : {
         Value* val = pop();
-        if (val->getType() != Type::Int32Ty) // int8 and int16
-          val = new ZExtInst(val, Type::Int32Ty, "", currentBlock);
+        if (val->getType() != Type::getInt32Ty(*llvmContext)) // int8 and int16
+          val = new ZExtInst(val, Type::getInt32Ty(*llvmContext), "", currentBlock);
         new StoreInst(val, intLocals[2], false, currentBlock);
         break;
       }
 
       case ISTORE_3 : {
         Value* val = pop();
-        if (val->getType() != Type::Int32Ty) // int8 and int16
-          val = new ZExtInst(val, Type::Int32Ty, "", currentBlock);
+        if (val->getType() != Type::getInt32Ty(*llvmContext)) // int8 and int16
+          val = new ZExtInst(val, Type::getInt32Ty(*llvmContext), "", currentBlock);
         new StoreInst(val, intLocals[3], false, currentBlock);
         break;
       }
@@ -718,8 +718,8 @@
 
       case BASTORE : {
         Value* val = pop();
-        if (val->getType() != Type::Int8Ty) {
-          val = new TruncInst(val, Type::Int8Ty, "", currentBlock);
+        if (val->getType() != Type::getInt8Ty(*llvmContext)) {
+          val = new TruncInst(val, Type::getInt8Ty(*llvmContext), "", currentBlock);
         }
         Value* index = pop();
         Value* obj = pop();
@@ -732,10 +732,10 @@
       case CASTORE : {
         Value* val = pop();
         const Type* type = val->getType();
-        if (type == Type::Int32Ty) {
-          val = new TruncInst(val, Type::Int16Ty, "", currentBlock);
-        } else if (type == Type::Int8Ty) {
-          val = new ZExtInst(val, Type::Int16Ty, "", currentBlock);
+        if (type == Type::getInt32Ty(*llvmContext)) {
+          val = new TruncInst(val, Type::getInt16Ty(*llvmContext), "", currentBlock);
+        } else if (type == Type::getInt8Ty(*llvmContext)) {
+          val = new ZExtInst(val, Type::getInt16Ty(*llvmContext), "", currentBlock);
         }
         Value* index = pop();
         Value* obj = pop();
@@ -748,10 +748,10 @@
       case SASTORE : {
         Value* val = pop();
         const Type* type = val->getType();
-        if (type == Type::Int32Ty) {
-          val = new TruncInst(val, Type::Int16Ty, "", currentBlock);
-        } else if (type == Type::Int8Ty) {
-          val = new SExtInst(val, Type::Int16Ty, "", currentBlock);
+        if (type == Type::getInt32Ty(*llvmContext)) {
+          val = new TruncInst(val, Type::getInt16Ty(*llvmContext), "", currentBlock);
+        } else if (type == Type::getInt8Ty(*llvmContext)) {
+          val = new SExtInst(val, Type::getInt16Ty(*llvmContext), "", currentBlock);
         }
         Value* index = pop();
         Value* obj = pop();
@@ -1096,7 +1096,7 @@
       }
 
       case LSHL : {
-        Value* val2 = new ZExtInst(pop(), Type::Int64Ty, "", currentBlock);
+        Value* val2 = new ZExtInst(pop(), Type::getInt64Ty(*llvmContext), "", currentBlock);
         pop(); // remove the 0 on the stack
         Value* val1 = pop();
         push(BinaryOperator::CreateShl(val1, val2, "", currentBlock),
@@ -1114,7 +1114,7 @@
       }
 
       case LSHR : {
-        Value* val2 = new ZExtInst(pop(), Type::Int64Ty, "", currentBlock);
+        Value* val2 = new ZExtInst(pop(), Type::getInt64Ty(*llvmContext), "", currentBlock);
         pop(); // remove the 0 on the stack
         Value* val1 = pop();
         push(BinaryOperator::CreateAShr(val1, val2, "", currentBlock),
@@ -1126,7 +1126,7 @@
       case IUSHR : {
         Value* val2 = popAsInt();
         Value* val1 = popAsInt();
-        Value* mask = ConstantInt::get(Type::Int32Ty, 0x1F);
+        Value* mask = ConstantInt::get(Type::getInt32Ty(*llvmContext), 0x1F);
         val2 = BinaryOperator::CreateAnd(val2, mask, "", currentBlock);
         push(BinaryOperator::CreateLShr(val1, val2, "", currentBlock),
              false);
@@ -1134,8 +1134,8 @@
       }
 
       case LUSHR : {
-        Value* val2 = new ZExtInst(pop(), Type::Int64Ty, "", currentBlock);
-        Value* mask = ConstantInt::get(Type::Int64Ty, 0x3F);
+        Value* val2 = new ZExtInst(pop(), Type::getInt64Ty(*llvmContext), "", currentBlock);
+        Value* mask = ConstantInt::get(Type::getInt64Ty(*llvmContext), 0x3F);
         val2 = BinaryOperator::CreateAnd(val2, mask, "", currentBlock);
         pop(); // remove the 0 on the stack
         Value* val1 = pop();
@@ -1207,44 +1207,44 @@
         sint16 val = WREAD_S1(bytecodes, false, i, wide);
         llvm::Value* add = BinaryOperator::CreateAdd(
             new LoadInst(intLocals[idx], "", currentBlock), 
-            ConstantInt::get(Type::Int32Ty, val), "",
+            ConstantInt::get(Type::getInt32Ty(*llvmContext), val), "",
             currentBlock);
         new StoreInst(add, intLocals[idx], false, currentBlock);
         break;
       }
 
       case I2L :
-        push(new SExtInst(pop(), llvm::Type::Int64Ty, "", currentBlock),
+        push(new SExtInst(pop(), llvm::Type::getInt64Ty(*llvmContext), "", currentBlock),
              false);
         push(module->constantZero, false);
         break;
 
       case I2F :
-        push(new SIToFPInst(pop(), llvm::Type::FloatTy, "", currentBlock),
+        push(new SIToFPInst(pop(), llvm::Type::getFloatTy(*llvmContext), "", currentBlock),
              false);
         break;
         
       case I2D :
-        push(new SIToFPInst(pop(), llvm::Type::DoubleTy, "", currentBlock),
+        push(new SIToFPInst(pop(), llvm::Type::getDoubleTy(*llvmContext), "", currentBlock),
              false);
         push(module->constantZero, false);
         break;
       
       case L2I :
         pop();
-        push(new TruncInst(pop(), llvm::Type::Int32Ty, "", currentBlock),
+        push(new TruncInst(pop(), llvm::Type::getInt32Ty(*llvmContext), "", currentBlock),
              false);
         break;
       
       case L2F :
         pop();
-        push(new SIToFPInst(pop(), llvm::Type::FloatTy, "", currentBlock),
+        push(new SIToFPInst(pop(), llvm::Type::getFloatTy(*llvmContext), "", currentBlock),
              false);
         break;
       
       case L2D :
         pop();
-        push(new SIToFPInst(pop(), llvm::Type::DoubleTy, "", currentBlock),
+        push(new SIToFPInst(pop(), llvm::Type::getDoubleTy(*llvmContext), "", currentBlock),
              false);
         push(module->constantZero, false);
         break;
@@ -1255,7 +1255,7 @@
                                          val, val, "");
         
         BasicBlock* res = createBasicBlock("F2I");
-        PHINode* node = PHINode::Create(llvm::Type::Int32Ty, "", res);
+        PHINode* node = PHINode::Create(llvm::Type::getInt32Ty(*llvmContext), "", res);
         node->addIncoming(module->constantZero, currentBlock);
         BasicBlock* cont = createBasicBlock("F2I");
 
@@ -1283,7 +1283,7 @@
         node->addIncoming(module->constantMinInt, currentBlock);
         
         currentBlock = cont;
-        llvm::Value* newVal = new FPToSIInst(val, Type::Int32Ty, "",
+        llvm::Value* newVal = new FPToSIInst(val, Type::getInt32Ty(*llvmContext), "",
                                              currentBlock);
         BranchInst::Create(res, currentBlock);
 
@@ -1301,7 +1301,7 @@
                                          val, val, "");
         
         BasicBlock* res = createBasicBlock("F2L");
-        PHINode* node = PHINode::Create(llvm::Type::Int64Ty, "", res);
+        PHINode* node = PHINode::Create(llvm::Type::getInt64Ty(*llvmContext), "", res);
         node->addIncoming(module->constantLongZero, currentBlock);
         BasicBlock* cont = createBasicBlock("F2L");
 
@@ -1328,7 +1328,7 @@
         node->addIncoming(module->constantMinLong, currentBlock);
         
         currentBlock = cont;
-        llvm::Value* newVal = new FPToSIInst(val, Type::Int64Ty, "",
+        llvm::Value* newVal = new FPToSIInst(val, Type::getInt64Ty(*llvmContext), "",
                                              currentBlock);
         BranchInst::Create(res, currentBlock);
 
@@ -1342,7 +1342,7 @@
       }
 
       case F2D :
-        push(new FPExtInst(pop(), llvm::Type::DoubleTy, "", currentBlock),
+        push(new FPExtInst(pop(), llvm::Type::getDoubleTy(*llvmContext), "", currentBlock),
              false);
         push(module->constantZero, false);
         break;
@@ -1354,7 +1354,7 @@
                                          val, val, "");
         
         BasicBlock* res = createBasicBlock("D2I");
-        PHINode* node = PHINode::Create(llvm::Type::Int32Ty, "", res);
+        PHINode* node = PHINode::Create(llvm::Type::getInt32Ty(*llvmContext), "", res);
         node->addIncoming(module->constantZero, currentBlock);
         BasicBlock* cont = createBasicBlock("D2I");
 
@@ -1381,7 +1381,7 @@
         node->addIncoming(module->constantMinInt, currentBlock);
         
         currentBlock = cont;
-        llvm::Value* newVal = new FPToSIInst(val, Type::Int32Ty, "",
+        llvm::Value* newVal = new FPToSIInst(val, Type::getInt32Ty(*llvmContext), "",
                                              currentBlock);
         BranchInst::Create(res, currentBlock);
 
@@ -1401,7 +1401,7 @@
                                          val, val, "");
         
         BasicBlock* res = createBasicBlock("D2L");
-        PHINode* node = PHINode::Create(llvm::Type::Int64Ty, "", res);
+        PHINode* node = PHINode::Create(llvm::Type::getInt64Ty(*llvmContext), "", res);
         node->addIncoming(module->constantLongZero, currentBlock);
         BasicBlock* cont = createBasicBlock("D2L");
 
@@ -1429,7 +1429,7 @@
         node->addIncoming(module->constantMinLong, currentBlock);
         
         currentBlock = cont;
-        llvm::Value* newVal = new FPToSIInst(val, Type::Int64Ty, "",
+        llvm::Value* newVal = new FPToSIInst(val, Type::getInt64Ty(*llvmContext), "",
                                              currentBlock);
         BranchInst::Create(res, currentBlock);
 
@@ -1444,36 +1444,36 @@
 
       case D2F :
         pop(); // remove the 0 on the stack
-        push(new FPTruncInst(pop(), llvm::Type::FloatTy, "", currentBlock),
+        push(new FPTruncInst(pop(), llvm::Type::getFloatTy(*llvmContext), "", currentBlock),
              false);
         break;
 
       case I2B : {
         Value* val = pop();
-        if (val->getType() == Type::Int32Ty) {
-          val = new TruncInst(val, llvm::Type::Int8Ty, "", currentBlock);
+        if (val->getType() == Type::getInt32Ty(*llvmContext)) {
+          val = new TruncInst(val, llvm::Type::getInt8Ty(*llvmContext), "", currentBlock);
         }
-        push(new SExtInst(val, llvm::Type::Int32Ty, "", currentBlock),
+        push(new SExtInst(val, llvm::Type::getInt32Ty(*llvmContext), "", currentBlock),
              false);
         break;
       }
 
       case I2C : {
         Value* val = pop();
-        if (val->getType() == Type::Int32Ty) {
-          val = new TruncInst(val, llvm::Type::Int16Ty, "", currentBlock);
+        if (val->getType() == Type::getInt32Ty(*llvmContext)) {
+          val = new TruncInst(val, llvm::Type::getInt16Ty(*llvmContext), "", currentBlock);
         }
-        push(new ZExtInst(val, llvm::Type::Int32Ty, "", currentBlock),
+        push(new ZExtInst(val, llvm::Type::getInt32Ty(*llvmContext), "", currentBlock),
              false);
         break;
       }
 
       case I2S : {
         Value* val = pop();
-        if (val->getType() == Type::Int32Ty) {
-          val = new TruncInst(val, llvm::Type::Int16Ty, "", currentBlock);
+        if (val->getType() == Type::getInt32Ty(*llvmContext)) {
+          val = new TruncInst(val, llvm::Type::getInt16Ty(*llvmContext), "", currentBlock);
         }
-        push(new SExtInst(val, llvm::Type::Int32Ty, "", currentBlock),
+        push(new SExtInst(val, llvm::Type::getInt32Ty(*llvmContext), "", currentBlock),
              false);
         break;
       }
@@ -1489,7 +1489,7 @@
         
         BasicBlock* cont = createBasicBlock("LCMP");
         BasicBlock* res = createBasicBlock("LCMP");
-        PHINode* node = PHINode::Create(llvm::Type::Int32Ty, "", res);
+        PHINode* node = PHINode::Create(llvm::Type::getInt32Ty(*llvmContext), "", res);
         node->addIncoming(module->constantZero, currentBlock);
         
         BranchInst::Create(res, cont, test, currentBlock);
@@ -1512,14 +1512,14 @@
       case FCMPL : {
         llvm::Value* val2 = pop();
         llvm::Value* val1 = pop();
-        compareFP(val1, val2, Type::FloatTy, false);
+        compareFP(val1, val2, Type::getFloatTy(*llvmContext), false);
         break;
       }
 
       case FCMPG : {
         llvm::Value* val2 = pop();
         llvm::Value* val1 = pop();
-        compareFP(val1, val2, Type::FloatTy, true);
+        compareFP(val1, val2, Type::getFloatTy(*llvmContext), true);
         break;
       }
 
@@ -1529,7 +1529,7 @@
         pop();
         llvm::Value* val1 = pop();
         
-        compareFP(val1, val2, Type::DoubleTy, false);
+        compareFP(val1, val2, Type::getDoubleTy(*llvmContext), false);
         break;
       }
 
@@ -1539,7 +1539,7 @@
         pop();
         llvm::Value* val1 = pop();
         
-        compareFP(val1, val2, Type::DoubleTy, false);
+        compareFP(val1, val2, Type::getDoubleTy(*llvmContext), false);
         break;
       }
 
@@ -1743,7 +1743,7 @@
       case JSR : {
         uint32 tmp = i;
         Value* expr = ConstantExpr::getIntToPtr(
-                                    ConstantInt::get(Type::Int64Ty,
+                                    ConstantInt::get(Type::getInt64Ty(*llvmContext),
                                                      uint64_t (jsrIndex++)),
                                     module->JavaObjectType);
         push(expr, false);
@@ -1755,14 +1755,14 @@
       case RET : {
         uint8 local = readU1(bytecodes, i);
         Value* _val = new LoadInst(objectLocals[local], "", currentBlock);
-        Value* val = new PtrToIntInst(_val, Type::Int32Ty, "", currentBlock);
+        Value* val = new PtrToIntInst(_val, Type::getInt32Ty(*llvmContext), "", currentBlock);
         SwitchInst* inst = SwitchInst::Create(val, jsrs[0], jsrs.size(),
                                           currentBlock);
         
         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(ConstantInt::get(Type::getInt32Ty(*llvmContext), index), *i);
         }
 
         break;
@@ -1808,12 +1808,12 @@
         Value* key = pop();
         const Type* type = key->getType();
         if (unsign) {
-          key = new ZExtInst(key, Type::Int32Ty, "", currentBlock);
-        } else if (type == Type::Int8Ty || type == Type::Int16Ty) {
-          key = new SExtInst(key, Type::Int32Ty, "", currentBlock);
+          key = new ZExtInst(key, Type::getInt32Ty(*llvmContext), "", currentBlock);
+        } else if (type == Type::getInt8Ty(*llvmContext) || type == Type::getInt16Ty(*llvmContext)) {
+          key = new SExtInst(key, Type::getInt32Ty(*llvmContext), "", currentBlock);
         }
         for (uint32 cur = 0; cur < nbs; ++cur) {
-          Value* val = ConstantInt::get(Type::Int32Ty, readU4(bytecodes, i));
+          Value* val = ConstantInt::get(Type::getInt32Ty(*llvmContext), readU4(bytecodes, i));
           Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val, key,
                                     "");
           BasicBlock* falseBlock = createBasicBlock("continue lookupswitch");
@@ -1938,13 +1938,13 @@
           valCl = TheCompiler->getNativeClass(dcl);
 #else
           Value* args[2] = { isolateLocal,
-                             ConstantInt::get(Type::Int32Ty, id - 4) };
+                             ConstantInt::get(Type::getInt32Ty(*llvmContext), id - 4) };
           valCl = CallInst::Create(module->GetJnjvmArrayClassFunction,
                                    args, args + 2, "", currentBlock);
 #endif
 
           LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[charId];
-          sizeElement = ConstantInt::get(Type::Int32Ty,
+          sizeElement = ConstantInt::get(Type::getInt32Ty(*llvmContext),
                                                     LAI.logSizeInBytesConstant);
           if (TheCompiler->isStaticCompiling() &&
               valCl->getType() != module->JavaClassArrayType) {
@@ -2074,7 +2074,7 @@
         Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, obj,
                                   module->JavaObjectNullConstant, "");
         BasicBlock* endBlock = createBasicBlock("end type compare");
-        PHINode* node = PHINode::Create(Type::Int1Ty, "", endBlock);
+        PHINode* node = PHINode::Create(Type::getInt1Ty(*llvmContext), "", endBlock);
         
         if (checkcast) {
           exceptionCheckcast = createBasicBlock("false checkcast");
@@ -2118,7 +2118,7 @@
                                                 objVT, "", currentBlock);
             
             uint32 depth = cl->virtualVT->depth;
-            ConstantInt* CI = ConstantInt::get(Type::Int32Ty, depth);
+            ConstantInt* CI = ConstantInt::get(Type::getInt32Ty(*llvmContext), depth);
             Value* displayArgs[2] = { inDisplay, CI };
             Value* VTInDisplay = 
               CallInst::Create(module->GetVTInDisplayFunction,
@@ -2144,7 +2144,7 @@
           currentBlock = endCheckcast;
         } else {
           pop();
-          push(new ZExtInst(node, Type::Int32Ty, "", currentBlock),
+          push(new ZExtInst(node, Type::getInt32Ty(*llvmContext), "", currentBlock),
                false);
         }
 
@@ -2173,7 +2173,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] = ConstantInt::get(Type::getInt32Ty(*llvmContext), 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=79108&r1=79107&r2=79108&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp Sat Aug 15 10:54:14 2009
@@ -175,10 +175,10 @@
   
   JavaObjectNullConstant =
     Constant::getNullValue(JnjvmModule::JavaObjectType);
-  MaxArraySizeConstant = ConstantInt::get(Type::Int32Ty,
+  MaxArraySizeConstant = ConstantInt::get(Type::getInt32Ty(getGlobalContext()),
                                           JavaArray::MaxArraySize);
-  JavaArraySizeConstant = 
-    ConstantInt::get(Type::Int32Ty, sizeof(JavaObject) + sizeof(ssize_t));
+  JavaArraySizeConstant = ConstantInt::get(Type::getInt32Ty(getGlobalContext()),
+                                          sizeof(JavaObject) + sizeof(ssize_t));
   
   
   JavaArrayElementsOffsetConstant = constantTwo;
@@ -188,22 +188,30 @@
   OffsetClassInVTConstant = constantThree;
   OffsetDepthInVTConstant = constantFour;
   OffsetDisplayInVTConstant = constantSeven;
-  OffsetBaseClassVTInVTConstant = ConstantInt::get(Type::Int32Ty, 17);
+  OffsetBaseClassVTInVTConstant =
+    ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 17);
   
   OffsetObjectSizeInClassConstant = constantOne;
-  OffsetVTInClassConstant = ConstantInt::get(Type::Int32Ty, 7);
+  OffsetVTInClassConstant =
+    ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 7);
   OffsetTaskClassMirrorInClassConstant = constantTwo;
   OffsetStaticInstanceInTaskClassMirrorConstant = constantTwo;
   OffsetStatusInTaskClassMirrorConstant = constantZero;
   OffsetInitializedInTaskClassMirrorConstant = constantOne;
   
-  OffsetIsolateInThreadConstant = ConstantInt::get(Type::Int32Ty, 3);
-  OffsetDoYieldInThreadConstant = ConstantInt::get(Type::Int32Ty, 6);
-  OffsetJNIInThreadConstant = ConstantInt::get(Type::Int32Ty, 12);
-  OffsetJavaExceptionInThreadConstant = ConstantInt::get(Type::Int32Ty, 13);
-  OffsetCXXExceptionInThreadConstant = ConstantInt::get(Type::Int32Ty, 14);
+  OffsetIsolateInThreadConstant =
+    ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 3);
+  OffsetDoYieldInThreadConstant =
+    ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 6);
+  OffsetJNIInThreadConstant =
+    ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 12);
+  OffsetJavaExceptionInThreadConstant =
+    ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 13);
+  OffsetCXXExceptionInThreadConstant =
+    ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 14);
   
-  ClassReadyConstant = ConstantInt::get(Type::Int8Ty, ready);
+  ClassReadyConstant =
+    ConstantInt::get(Type::getInt8Ty(getGlobalContext()), ready);
   
   module->addTypeName("JavaObject", JavaObjectType->getContainedType(0));
   module->addTypeName("JavaArray", JavaArrayType->getContainedType(0));

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp Sat Aug 15 10:54:14 2009
@@ -169,7 +169,7 @@
           Value* ptr = GetElementPtrInst::Create(array, args, args + 2,
                                                  "", CI);
           Value* load = new LoadInst(ptr, "", CI);
-          load = new PtrToIntInst(load, Type::Int32Ty, "", CI);
+          load = new PtrToIntInst(load, Type::getInt32Ty(*Context), "", CI);
           CI->replaceAllUsesWith(load);
           CI->eraseFromParent();
         } else if (V == module->GetVTFunction) {
@@ -265,7 +265,7 @@
           Value* DepthPtr = GetElementPtrInst::Create(val, indexes,
                                                       indexes + 2, "", CI);
           Value* Depth = new LoadInst(DepthPtr, "", CI);
-          Depth = new PtrToIntInst(Depth, Type::Int32Ty, "", CI);
+          Depth = new PtrToIntInst(Depth, Type::getInt32Ty(*Context), "", CI);
           CI->replaceAllUsesWith(Depth);
           CI->eraseFromParent();
         } else if (V == module->GetDisplayFunction) {
@@ -307,8 +307,8 @@
           Value* cmp = new ICmpInst(CI, ICmpInst::ICMP_EQ, Del, 
                                     module->JavaObjectNullConstant, "");
           
-          BasicBlock* NoDelegatee = BasicBlock::Create("No delegatee", &F);
-          BasicBlock* DelegateeOK = BasicBlock::Create("Delegatee OK", &F);
+          BasicBlock* NoDelegatee = BasicBlock::Create(*Context, "No delegatee", &F);
+          BasicBlock* DelegateeOK = BasicBlock::Create(*Context, "Delegatee OK", &F);
           BranchInst::Create(NoDelegatee, DelegateeOK, cmp, CI);
           PHINode* phi = PHINode::Create(module->JavaObjectType, "", DelegateeOK);
           phi->addIncoming(Del, CI->getParent());
@@ -346,8 +346,8 @@
           
           Value* test = new LoadInst(StatusPtr, "", CI);
           
-          BasicBlock* trueCl = BasicBlock::Create("Initialized", &F);
-          BasicBlock* falseCl = BasicBlock::Create("Uninitialized", &F);
+          BasicBlock* trueCl = BasicBlock::Create(*Context, "Initialized", &F);
+          BasicBlock* falseCl = BasicBlock::Create(*Context, "Uninitialized", &F);
           PHINode* node = llvm::PHINode::Create(JnjvmModule::JavaClassType, "", trueCl);
           node->addIncoming(Cl, CI->getParent());
           BranchInst::Create(trueCl, falseCl, test, CI);
@@ -416,7 +416,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 = ConstantInt::get(Type::getInt32Ty(*Context), val + 1);
 #else
           Value* indexes = Index;
 #endif
@@ -425,8 +425,8 @@
           Value* test = new ICmpInst(CI, ICmpInst::ICMP_EQ, arg1,
                                      module->constantPtrNull, "");
  
-          BasicBlock* trueCl = BasicBlock::Create("Ctp OK", &F);
-          BasicBlock* falseCl = BasicBlock::Create("Ctp Not OK", &F);
+          BasicBlock* trueCl = BasicBlock::Create(*Context, "Ctp OK", &F);
+          BasicBlock* falseCl = BasicBlock::Create(*Context, "Ctp Not OK", &F);
           PHINode* node = llvm::PHINode::Create(returnType, "", trueCl);
           node->addIncoming(arg1, CI->getParent());
           BranchInst::Create(falseCl, trueCl, test, CI);
@@ -495,8 +495,8 @@
             Value* cmp = new ICmpInst(CI, ICmpInst::ICMP_EQ, LoadedGV, init,
                                       "");
 
-            BasicBlock* OKBlock = BasicBlock::Create("", &F);
-            BasicBlock* NotOKBlock = BasicBlock::Create("", &F);
+            BasicBlock* OKBlock = BasicBlock::Create(*Context, "", &F);
+            BasicBlock* NotOKBlock = BasicBlock::Create(*Context, "", &F);
             PHINode* node = PHINode::Create(module->JavaClassArrayType, "",
                                             OKBlock);
             node->addIncoming(LoadedGV, CI->getParent());
@@ -538,17 +538,17 @@
           BasicBlock* EndBlock = II->getParent()->splitBasicBlock(II);
           I->getParent()->getTerminator()->eraseFromParent();
           
-          BasicBlock* CurEndBlock = BasicBlock::Create("", &F);
-          BasicBlock* FailedBlock = BasicBlock::Create("", &F);
-          PHINode* node = PHINode::Create(Type::Int1Ty, "", CurEndBlock);
+          BasicBlock* CurEndBlock = BasicBlock::Create(*Context, "", &F);
+          BasicBlock* FailedBlock = BasicBlock::Create(*Context, "", &F);
+          PHINode* node = PHINode::Create(Type::getInt1Ty(*Context), "", CurEndBlock);
 
-          ConstantInt* CC = ConstantInt::get(Type::Int32Ty,
+          ConstantInt* CC = ConstantInt::get(Type::getInt32Ty(*Context),
               JavaVirtualTable::getOffsetIndex());
           Value* indices[2] = { module->constantZero, CC };
           Value* Offset = GetElementPtrInst::Create(VT2, indices, indices + 2,
                                                     "", CI);
           Offset = new LoadInst(Offset, "", false, CI);
-          Offset = new PtrToIntInst(Offset, Type::Int32Ty, "", CI);
+          Offset = new PtrToIntInst(Offset, Type::getInt32Ty(*Context), "", CI);
           indices[1] = Offset;
           Value* CurVT = GetElementPtrInst::Create(VT1, indices, indices + 2,
                                                    "", CI);
@@ -586,21 +586,21 @@
           I->getParent()->getTerminator()->eraseFromParent();
 
 
-          BasicBlock* Preheader = BasicBlock::Create("preheader", &F);
-          BasicBlock* BB4 = BasicBlock::Create("BB4", &F);
-          BasicBlock* BB5 = BasicBlock::Create("BB5", &F);
-          BasicBlock* BB6 = BasicBlock::Create("BB6", &F);
-          BasicBlock* BB7 = BasicBlock::Create("BB7", &F);
-          BasicBlock* BB9 = BasicBlock::Create("BB9", &F);
+          BasicBlock* Preheader = BasicBlock::Create(*Context, "preheader", &F);
+          BasicBlock* BB4 = BasicBlock::Create(*Context, "BB4", &F);
+          BasicBlock* BB5 = BasicBlock::Create(*Context, "BB5", &F);
+          BasicBlock* BB6 = BasicBlock::Create(*Context, "BB6", &F);
+          BasicBlock* BB7 = BasicBlock::Create(*Context, "BB7", &F);
+          BasicBlock* BB9 = BasicBlock::Create(*Context, "BB9", &F);
           const Type* Ty = PointerType::getUnqual(module->VTType);
           
-          PHINode* resFwd = PHINode::Create(Type::Int32Ty, "", BB7);
+          PHINode* resFwd = PHINode::Create(Type::getInt32Ty(*Context), "", BB7);
    
           // This corresponds to:
           //    if (VT1.cache == VT2 || VT1 == VT2) goto end with true;
           //    else goto headerLoop;
           ConstantInt* cacheIndex = 
-            ConstantInt::get(Type::Int32Ty, JavaVirtualTable::getCacheIndex());
+            ConstantInt::get(Type::getInt32Ty(*Context), JavaVirtualTable::getCacheIndex());
           Value* indices[2] = { module->constantZero, cacheIndex };
           Instruction* CachePtr = 
             GetElementPtrInst::Create(VT1, indices, indices + 2, "", CI);
@@ -618,16 +618,16 @@
           //    size = VT1->nbSecondaryTypes;
           //    i = 0;
           //    goto test;
-          ConstantInt* sizeIndex = ConstantInt::get(Type::Int32Ty, 
+          ConstantInt* sizeIndex = ConstantInt::get(Type::getInt32Ty(*Context), 
               JavaVirtualTable::getNumSecondaryTypesIndex());
           indices[1] = sizeIndex;
           Instruction* Size = GetElementPtrInst::Create(VT1, indices,
                                                         indices + 2, "",
                                                         Preheader);
           Size = new LoadInst(Size, "", false, Preheader);
-          Size = new PtrToIntInst(Size, Type::Int32Ty, "", Preheader);
+          Size = new PtrToIntInst(Size, Type::getInt32Ty(*Context), "", Preheader);
     
-          ConstantInt* secondaryTypesIndex = ConstantInt::get(Type::Int32Ty, 
+          ConstantInt* secondaryTypesIndex = ConstantInt::get(Type::getInt32Ty(*Context), 
               JavaVirtualTable::getSecondaryTypesIndex());
           indices[1] = secondaryTypesIndex;
           Instruction* secondaryTypes = 
@@ -674,7 +674,7 @@
           BranchInst::Create(BB9, BB5);
 
           // Final block, that gets the result.
-          PHINode* node = PHINode::Create(Type::Int1Ty, "", BB9);
+          PHINode* node = PHINode::Create(Type::getInt1Ty(*Context), "", BB9);
           node->reserveOperandSpace(3);
           node->addIncoming(ConstantInt::getTrue(*Context), CI->getParent());
           node->addIncoming(ConstantInt::getFalse(*Context), BB7);

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h?rev=79108&r1=79107&r2=79108&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h Sat Aug 15 10:54:14 2009
@@ -91,6 +91,42 @@
   virtual bool isUnsigned() const {
     return false;
   }
+  
+  virtual bool isVoid() const {
+    return false;
+  }
+
+  virtual bool isLong() const {
+    return false;
+  }
+
+  virtual bool isInt() const {
+    return false;
+  }
+
+  virtual bool isChar() const {
+    return false;
+  }
+
+  virtual bool isShort() const {
+    return false;
+  }
+
+  virtual bool isByte() const {
+    return false;
+  }
+
+  virtual bool isBool() const {
+    return false;
+  }
+
+  virtual bool isFloat() const {
+    return false;
+  }
+
+  virtual bool isDouble() const {
+    return false;
+  }
 
   /// getName - Get the name of the type, i.e. java.lang.String or
   /// I.
@@ -142,39 +178,39 @@
     charId = i;
   }
   
-  bool isVoid() const {
+  virtual bool isVoid() const {
     return charId == I_VOID;
   }
 
-  bool isLong() const {
+  virtual bool isLong() const {
     return charId == I_LONG;
   }
 
-  bool isInt() const {
+  virtual bool isInt() const {
     return charId == I_INT;
   }
 
-  bool isChar() const {
+  virtual bool isChar() const {
     return charId == I_CHAR;
   }
 
-  bool isShort() const {
+  virtual bool isShort() const {
     return charId == I_SHORT;
   }
 
-  bool isByte() const {
+  virtual bool isByte() const {
     return charId == I_BYTE;
   }
 
-  bool isBool() const {
+  virtual bool isBool() const {
     return charId == I_BOOL;
   }
 
-  bool isFloat() const {
+  virtual bool isFloat() const {
     return charId == I_FLOAT;
   }
 
-  bool isDouble() const {
+  virtual bool isDouble() const {
     return charId == I_DOUBLE;
   }
   

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

==============================================================================
--- vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp (original)
+++ vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp Sat Aug 15 10:54:14 2009
@@ -168,7 +168,8 @@
 bool EscapeAnalysis::processMalloc(Instruction* I, Value* Size, Value* VT,
                                    Loop* CurLoop) {
   Instruction* Alloc = I;
-  
+  LLVMContext& Context = Alloc->getParent()->getContext();
+
   ConstantInt* CI = dyn_cast<ConstantInt>(Size);
   bool hasFinalizer = true;
   
@@ -219,7 +220,8 @@
         BB->getInstList().insert(BB->getTerminator(), Alloc);
       }
 
-      AllocaInst* AI = new AllocaInst(Type::Int8Ty, Size, "", Alloc);
+      AllocaInst* AI = new AllocaInst(Type::getInt8Ty(Context), Size, "",
+                                      Alloc);
       BitCastInst* BI = new BitCastInst(AI, Alloc->getType(), "", Alloc);
       DOUT << "escape" << Alloc->getParent()->getParent()->getNameStr() << "\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=79108&r1=79107&r2=79108&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original)
+++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Sat Aug 15 10:54:14 2009
@@ -54,9 +54,9 @@
   llvm::NoFramePointerElim = true;
   llvm::DisablePrettyStackTrace = true;
 #if DWARF_EXCEPTIONS
-  llvm::ExceptionHandling = true;
+  llvm::DwarfExceptionHandling = true;
 #else
-  llvm::ExceptionHandling = false;
+  llvm::DwarfExceptionHandling = false;
 #endif
   if (!M) {
     globalModule = new Module("bootstrap module", getGlobalContext());
@@ -83,12 +83,13 @@
 
   mvm::llvm_runtime::makeLLVMModuleContents(globalModule);
   
+  LLVMContext& Context = globalModule->getContext();
   // Type declaration
-  ptrType = PointerType::getUnqual(Type::Int8Ty);
-  ptr32Type = PointerType::getUnqual(Type::Int32Ty);
+  ptrType = PointerType::getUnqual(Type::getInt8Ty(Context));
+  ptr32Type = PointerType::getUnqual(Type::getInt32Ty(Context));
   ptrPtrType = PointerType::getUnqual(ptrType);
   pointerSizeType = globalModule->getPointerSize() == Module::Pointer32 ?
-    Type::Int32Ty : Type::Int64Ty;
+    Type::getInt32Ty(Context) : Type::getInt64Ty(Context);
   
 }
 
@@ -97,59 +98,59 @@
 
   module->setDataLayout(globalModule->getDataLayout());
   module->setTargetTriple(globalModule->getTargetTriple());
-    
+  LLVMContext& Context = module->getContext(); 
   
   // 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);
+  constantLongMinusOne = ConstantInt::get(Type::getInt64Ty(Context), (uint64_t)-1);
+  constantLongZero = ConstantInt::get(Type::getInt64Ty(Context), 0);
+  constantLongOne = ConstantInt::get(Type::getInt64Ty(Context), 1);
+  constantZero = ConstantInt::get(Type::getInt32Ty(Context), 0);
+  constantInt8Zero = ConstantInt::get(Type::getInt8Ty(Context), 0);
+  constantOne = ConstantInt::get(Type::getInt32Ty(Context), 1);
+  constantTwo = ConstantInt::get(Type::getInt32Ty(Context), 2);
+  constantThree = ConstantInt::get(Type::getInt32Ty(Context), 3);
+  constantFour = ConstantInt::get(Type::getInt32Ty(Context), 4);
+  constantFive = ConstantInt::get(Type::getInt32Ty(Context), 5);
+  constantSix = ConstantInt::get(Type::getInt32Ty(Context), 6);
+  constantSeven = ConstantInt::get(Type::getInt32Ty(Context), 7);
+  constantEight = ConstantInt::get(Type::getInt32Ty(Context), 8);
+  constantMinusOne = ConstantInt::get(Type::getInt32Ty(Context), (uint64_t)-1);
+  constantMinInt = ConstantInt::get(Type::getInt32Ty(Context), MinInt);
+  constantMaxInt = ConstantInt::get(Type::getInt32Ty(Context), MaxInt);
+  constantMinLong = ConstantInt::get(Type::getInt64Ty(Context), MinLong);
+  constantMaxLong = ConstantInt::get(Type::getInt64Ty(Context), MaxLong);
+  constantFloatZero = ConstantFP::get(Type::getFloatTy(Context), 0.0f);
+  constantFloatOne = ConstantFP::get(Type::getFloatTy(Context), 1.0f);
+  constantFloatTwo = ConstantFP::get(Type::getFloatTy(Context), 2.0f);
+  constantDoubleZero = ConstantFP::get(Type::getDoubleTy(Context), 0.0);
+  constantDoubleOne = ConstantFP::get(Type::getDoubleTy(Context), 1.0);
+  constantMaxIntFloat = ConstantFP::get(Type::getFloatTy(Context), MaxIntFloat);
+  constantMinIntFloat = ConstantFP::get(Type::getFloatTy(Context), MinIntFloat);
+  constantMinLongFloat = ConstantFP::get(Type::getFloatTy(Context), MinLongFloat);
+  constantMinLongDouble = ConstantFP::get(Type::getDoubleTy(Context), MinLongDouble);
+  constantMaxLongFloat = ConstantFP::get(Type::getFloatTy(Context), MaxLongFloat);
+  constantMaxIntDouble = ConstantFP::get(Type::getDoubleTy(Context), MaxIntDouble);
+  constantMinIntDouble = ConstantFP::get(Type::getDoubleTy(Context), MinIntDouble);
+  constantMaxLongDouble = ConstantFP::get(Type::getDoubleTy(Context), MaxLongDouble);
+  constantMaxLongDouble = ConstantFP::get(Type::getDoubleTy(Context), MaxLongDouble);
+  constantFloatInfinity = ConstantFP::get(Type::getFloatTy(Context), MaxFloat);
+  constantFloatMinusInfinity = ConstantFP::get(Type::getFloatTy(Context), MinFloat);
+  constantDoubleInfinity = ConstantFP::get(Type::getDoubleTy(Context), MaxDouble);
+  constantDoubleMinusInfinity = ConstantFP::get(Type::getDoubleTy(Context), MinDouble);
+  constantDoubleMinusZero = ConstantFP::get(Type::getDoubleTy(Context), -0.0);
+  constantFloatMinusZero = ConstantFP::get(Type::getFloatTy(Context), -0.0f);
   constantThreadIDMask = ConstantInt::get(pointerSizeType, mvm::Thread::IDMask);
   constantStackOverflowMask = 
     ConstantInt::get(pointerSizeType, mvm::Thread::StackOverflowMask);
   constantFatMask = ConstantInt::get(pointerSizeType, 
-      pointerSizeType == Type::Int32Ty ? 0x80000000 : 0x8000000000000000LL);
+      pointerSizeType == Type::getInt32Ty(Context) ? 0x80000000 : 0x8000000000000000LL);
   constantPtrOne = ConstantInt::get(pointerSizeType, 1);
   constantPtrZero = ConstantInt::get(pointerSizeType, 0);
 
   constantPtrNull = Constant::getNullValue(ptrType); 
   constantPtrLogSize = 
-    ConstantInt::get(Type::Int32Ty, sizeof(void*) == 8 ? 3 : 2);
-  arrayPtrType = PointerType::getUnqual(ArrayType::get(Type::Int8Ty, 0));
+    ConstantInt::get(Type::getInt32Ty(Context), sizeof(void*) == 8 ? 3 : 2);
+  arrayPtrType = PointerType::getUnqual(ArrayType::get(Type::getInt8Ty(Context), 0));
 
 
   copyDefinitions(module, globalModule); 
@@ -211,7 +212,7 @@
   llvm_atomic_lcs_i32 = module->getFunction("llvm.atomic.cmp.swap.i32.p0i32");
   llvm_atomic_lcs_i64 = module->getFunction("llvm.atomic.cmp.swap.i64.p0i64");
 
-  llvm_atomic_lcs_ptr = pointerSizeType == Type::Int32Ty ? llvm_atomic_lcs_i32 :
+  llvm_atomic_lcs_ptr = pointerSizeType == Type::getInt32Ty(Context) ? llvm_atomic_lcs_i32 :
                                                            llvm_atomic_lcs_i64;
 
   unconditionalSafePoint = module->getFunction("unconditionalSafePoint");

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

==============================================================================
--- vmkit/trunk/lib/Mvm/Compiler/LoopSafePoints.cpp (original)
+++ vmkit/trunk/lib/Mvm/Compiler/LoopSafePoints.cpp Sat Aug 15 10:54:14 2009
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 
+#include "llvm/Module.h"
 #include "llvm/Analysis/LoopPass.h"
 #include "llvm/Support/CallSite.h"
 #include "llvm/Support/Compiler.h"
@@ -44,7 +45,8 @@
   I->eraseFromParent();
   
   Value* Ld = new LoadInst(YieldPtr, "", NBB);
-  BasicBlock* yield = BasicBlock::Create("", BB->getParent());
+  BasicBlock* yield = BasicBlock::Create(SafeFunction->getContext(), "",
+                                         BB->getParent());
   BranchInst::Create(yield, SU, Ld, NBB);
 
   CallInst::Create(SafeFunction, "", yield);

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

==============================================================================
--- vmkit/trunk/lib/N3/Mono/MonoString.cpp (original)
+++ vmkit/trunk/lib/N3/Mono/MonoString.cpp Sat Aug 15 10:54:14 2009
@@ -53,7 +53,7 @@
       const Type* pty = mvm::MvmModule::ptrType;
       Module* Mod = vm->getLLVMModule();
       Constant* cons = 
-        ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (this)),
+        ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t (this)),
                                   pty);
       str->_llvmVar = new GlobalVariable(*Mod, pty, true,
                                     GlobalValue::ExternalLinkage,

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

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLIJit.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/CLIJit.cpp Sat Aug 15 10:54:14 2009
@@ -112,7 +112,7 @@
       args.push_back(zero);
       if (boxed) {
         ConstantInt* CI = dyn_cast<ConstantInt>(field->offset);
-        args.push_back(ConstantInt::get(Type::Int32Ty, CI->getValue() + 1));
+        args.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), CI->getValue() + 1));
       } else {
         args.push_back(field->offset);
       }
@@ -124,7 +124,7 @@
       args.push_back(zero);
       if (boxed) {
         ConstantInt* CI = dyn_cast<ConstantInt>(field->offset);
-        args.push_back(ConstantInt::get(Type::Int32Ty, CI->getValue() + 1));
+        args.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), CI->getValue() + 1));
       } else {
         args.push_back(field->offset);
       }
@@ -167,9 +167,9 @@
   // Function Definitions
   
   {
-    BasicBlock* label_entry = BasicBlock::Create("entry",func,0);
-    BasicBlock* label_bb = BasicBlock::Create("bb",func,0);
-    BasicBlock* label_return = BasicBlock::Create("return",func,0);
+    BasicBlock* label_entry = BasicBlock::Create(getGlobalContext(), "entry",func,0);
+    BasicBlock* label_bb = BasicBlock::Create(getGlobalContext(), "bb",func,0);
+    BasicBlock* label_return = BasicBlock::Create(getGlobalContext(), "return",func,0);
     
     Value* ptr_v = new BitCastInst(arg, cl->naturalType, "", label_entry);
     
@@ -191,8 +191,8 @@
     BranchInst::Create(label_bb, label_return, int1_tmp1221, label_entry);
     
     // Block bb (label_bb)
-    Argument* fwdref_12 = new Argument(IntegerType::get(32));
-    PHINode* int32_i_015_0 = PHINode::Create(Type::Int32Ty, "i.015.0", 
+    Argument* fwdref_12 = new Argument(IntegerType::get(getGlobalContext(), 32));
+    PHINode* int32_i_015_0 = PHINode::Create(Type::getInt32Ty(getGlobalContext()), "i.015.0", 
                                              label_bb);
     int32_i_015_0->reserveOperandSpace(2);
     int32_i_015_0->addIncoming(fwdref_12, label_bb);
@@ -230,7 +230,7 @@
     BranchInst::Create(label_bb, label_return, int1_tmp12, label_bb);
     
     // Block return (label_return)
-    ReturnInst::Create(label_return);
+    ReturnInst::Create(getGlobalContext(), label_return);
     
     // Resolve Forward References
     fwdref_12->replaceAllUsesWith(int32_tmp6); delete fwdref_12;
@@ -261,7 +261,7 @@
 #ifdef MULTIPLE_GC 
   Argument* GC = ++(func->arg_begin());
 #endif
-  BasicBlock* block = BasicBlock::Create("", func);
+  BasicBlock* block = BasicBlock::Create(getGlobalContext(), "", func);
   llvm::Value* realArg = new BitCastInst(arg, type, "", block);
  
 #ifdef MULTIPLE_GC
@@ -283,7 +283,7 @@
 #endif
   
   traceClass(cl, block, realArg, fields, (cl->super == MSCorlib::pValue && !stat));
-  ReturnInst::Create(block);
+  ReturnInst::Create(getGlobalContext(), block);
 
   void* tracer = mvm::MvmModule::executionEngine->getPointerToGlobal(func);
   ((void**)res)[VT_TRACER_OFFSET] = tracer;
@@ -298,7 +298,7 @@
 }
 
 BasicBlock* CLIJit::createBasicBlock(const char* name) {
-  return BasicBlock::Create(name, llvmFunction);
+  return BasicBlock::Create(getGlobalContext(), name, llvmFunction);
 }
 
 void CLIJit::setCurrentBlock(BasicBlock* newBlock) {
@@ -386,9 +386,9 @@
     } else {
       val = new SExtInst(val, type, "", currentBlock);
     }
-  } else if (type == Type::FloatTy) {
+  } else if (type == Type::getFloatTy(getGlobalContext())) {
     val = new FPTruncInst(val, type, "", currentBlock);
-  } else if (type == Type::DoubleTy) {
+  } else if (type == Type::getDoubleTy(getGlobalContext())) {
     val = new FPExtInst(val, type, "", currentBlock);
   } else {
     val = new BitCastInst(val, type, "", currentBlock);
@@ -542,7 +542,7 @@
       BasicBlock* endBlock = createBasicBlock("end test infinity");
       BasicBlock* minusInfinity = createBasicBlock("- infinity");
       BasicBlock* noInfinity = createBasicBlock("no infinity");
-      PHINode* node = PHINode::Create(Type::Int32Ty, "", endBlock);
+      PHINode* node = PHINode::Create(Type::getInt32Ty(getGlobalContext()), "", endBlock);
       node->addIncoming(module->constantOne, currentBlock);
       node->addIncoming(module->constantMinusOne, minusInfinity);
       node->addIncoming(module->constantZero, noInfinity);
@@ -567,7 +567,7 @@
       BasicBlock* endBlock = createBasicBlock("end test infinity");
       BasicBlock* minusInfinity = createBasicBlock("- infinity");
       BasicBlock* noInfinity = createBasicBlock("no infinity");
-      PHINode* node = PHINode::Create(Type::Int32Ty, "", endBlock);
+      PHINode* node = PHINode::Create(Type::getInt32Ty(getGlobalContext()), "", endBlock);
       node->addIncoming(module->constantOne, currentBlock);
       node->addIncoming(module->constantMinusOne, minusInfinity);
       node->addIncoming(module->constantZero, noInfinity);
@@ -630,7 +630,7 @@
     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(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), size));
     params.push_back(module->constantZero);
     CallInst::Create(module->llvm_memset_i32, params.begin(), params.end(),
                      "", currentBlock);
@@ -735,9 +735,9 @@
     uint64 size = module->getTypeSize(field->signature->naturalType);
         
     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(new BitCastInst(ptr, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock));
+    params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock));
+    params.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), size));
     params.push_back(module->constantZero);
     CallInst::Create(module->llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock);
 
@@ -796,7 +796,7 @@
   } else {
     CallInst::Create(CLIJit::nullPointerExceptionLLVM, args.begin(),
                  args.end(), "", exit);
-    new UnreachableInst(exit);
+    new UnreachableInst(getGlobalContext(), exit);
   }
 
 
@@ -808,8 +808,8 @@
                                          bool verif) {
   JITVerifyNull(obj);
   
-  if (index->getType() != Type::Int32Ty) {
-    index = changeType(index, Type::Int32Ty);
+  if (index->getType() != Type::getInt32Ty(getGlobalContext())) {
+    index = changeType(index, Type::getInt32Ty(getGlobalContext()));
   }
   
   if (true) {
@@ -834,7 +834,7 @@
     } else {
       CallInst::Create(CLIJit::indexOutOfBoundsExceptionLLVM, args.begin(),
                    args.end(), "", ifFalse);
-      new UnreachableInst(ifFalse);
+      new UnreachableInst(getGlobalContext(), ifFalse);
     }
   
     currentBlock = ifTrue;
@@ -899,7 +899,7 @@
 
   new StoreInst(target, targetPtr, false, entry); 
   new StoreInst(handle, handlePtr, false, entry);
-  ReturnInst::Create(entry);
+  ReturnInst::Create(getGlobalContext(), entry);
   
   return func;
 }
@@ -949,17 +949,17 @@
   void* natPtr = NativeUtil::nativeLookup(compilingClass, compilingMethod);
   
   Value* valPtr = 
-    ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, (uint64)natPtr),
+    ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), (uint64)natPtr),
                               PointerType::getUnqual(funcType));
   
   Value* result = CallInst::Create(valPtr, nativeArgs.begin(),
                                    nativeArgs.end(), "", currentBlock);
   
   
-  if (result->getType() != Type::VoidTy)
-    ReturnInst::Create(result, currentBlock);
+  if (result->getType() != Type::getVoidTy(getGlobalContext()))
+    ReturnInst::Create(getGlobalContext(), result, currentBlock);
   else
-    ReturnInst::Create(currentBlock);
+    ReturnInst::Create(getGlobalContext(), currentBlock);
   
   
   return llvmFunction;
@@ -1128,18 +1128,18 @@
        e = args.end(); i!= e; ++i) {
     llvm::Value* arg = *i;
     const llvm::Type* type = arg->getType();
-    if (type == Type::Int8Ty || type == Type::Int16Ty || type == Type::Int1Ty) {
-      CallInst::Create(module->printIntLLVM, new ZExtInst(arg, Type::Int32Ty, "", insertAt), "", insertAt);
-    } else if (type == Type::Int32Ty) {
+    if (type == Type::getInt8Ty(getGlobalContext()) || type == Type::getInt16Ty(getGlobalContext()) || type == Type::getInt1Ty(getGlobalContext())) {
+      CallInst::Create(module->printIntLLVM, new ZExtInst(arg, Type::getInt32Ty(getGlobalContext()), "", insertAt), "", insertAt);
+    } else if (type == Type::getInt32Ty(getGlobalContext())) {
       CallInst::Create(module->printIntLLVM, arg, "", insertAt);
-    } else if (type == Type::Int64Ty) {
+    } else if (type == Type::getInt64Ty(getGlobalContext())) {
       CallInst::Create(module->printLongLLVM, arg, "", insertAt);
-    } else if (type == Type::FloatTy) {
+    } else if (type == Type::getFloatTy(getGlobalContext())) {
       CallInst::Create(module->printFloatLLVM, arg, "", insertAt);
-    } else if (type == Type::DoubleTy) {
+    } else if (type == Type::getDoubleTy(getGlobalContext())) {
       CallInst::Create(module->printDoubleLLVM, arg, "", insertAt);
     } else {
-      CallInst::Create(module->printIntLLVM, new PtrToIntInst(arg, Type::Int32Ty, "", insertAt), "", insertAt);
+      CallInst::Create(module->printIntLLVM, new PtrToIntInst(arg, Type::getInt32Ty(getGlobalContext()), "", insertAt), "", insertAt);
     }
   }
 
@@ -1233,7 +1233,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(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), size));
         params.push_back(module->constantZero);
         CallInst::Create(module->llvm_memset_i32, params.begin(),
                          params.end(), "", currentBlock);
@@ -1248,7 +1248,7 @@
   endBlock = createBasicBlock("end");
 
   const Type* endType = funcType->getReturnType(); 
-  if (endType != Type::VoidTy) {
+  if (endType != Type::getVoidTy(getGlobalContext())) {
     endNode = PHINode::Create(endType, "", endBlock);
   } else if (compilingMethod->structReturn) {
     const Type* lastType = 
@@ -1264,13 +1264,13 @@
   if (PI == PE) {
     endBlock->eraseFromParent();
   } else {
-    if (endType != Type::VoidTy) {
+    if (endType != Type::getVoidTy(getGlobalContext())) {
 #if N3_EXECUTE > 1
       std::vector<Value*> args;
       args.push_back(endNode);
       printArgs(args, endBlock);
 #endif
-      ReturnInst::Create(endNode, endBlock);
+      ReturnInst::Create(getGlobalContext(), endNode, endBlock);
     } else if (compilingMethod->structReturn) {
       const Type* lastType = 
         funcType->getContainedType(funcType->getNumContainedTypes() - 1);
@@ -1281,13 +1281,13 @@
                                        currentBlock));
       params.push_back(new BitCastInst(endNode, module->ptrType, "",
                                        currentBlock));
-      params.push_back(ConstantInt::get(Type::Int32Ty, size));
+      params.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), size));
       params.push_back(module->constantFour);
       CallInst::Create(module->llvm_memcpy_i32, params.begin(), params.end(),
                        "", currentBlock);
-      ReturnInst::Create(currentBlock);
+      ReturnInst::Create(getGlobalContext(), currentBlock);
     } else {
-      ReturnInst::Create(endBlock);
+      ReturnInst::Create(getGlobalContext(), endBlock);
     }
   }
   
@@ -1299,7 +1299,7 @@
     CallInst* ptr_eh_ptr = CallInst::Create(getCppExceptionLLVM, "eh_ptr", 
                                         endExceptionBlock);
     CallInst::Create(module->unwindResume, ptr_eh_ptr, "", endExceptionBlock);
-    new UnreachableInst(endExceptionBlock);
+    new UnreachableInst(getGlobalContext(), endExceptionBlock);
   }
   
   PI = pred_begin(unifiedUnreachable);
@@ -1307,7 +1307,7 @@
   if (PI == PE) {
     unifiedUnreachable->eraseFromParent();
   } else {
-    new UnreachableInst(unifiedUnreachable);
+    new UnreachableInst(getGlobalContext(), unifiedUnreachable);
   }
   
   module->runPasses(llvmFunction, VMThread::get()->perFunctionPasses);
@@ -1410,7 +1410,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(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), size));
         params.push_back(module->constantZero);
         CallInst::Create(module->llvm_memset_i32, params.begin(),
                          params.end(), "", currentBlock);
@@ -1425,7 +1425,7 @@
   endBlock = createBasicBlock("end");
 
   const Type* endType = funcType->getReturnType(); 
-  if (endType != Type::VoidTy) {
+  if (endType != Type::getVoidTy(getGlobalContext())) {
     endNode = PHINode::Create(endType, "", endBlock);
   } else if (compilingMethod->structReturn) {
     const Type* lastType = 

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

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp Sat Aug 15 10:54:14 2009
@@ -42,7 +42,7 @@
   if (stat) obj = classDef->staticInstance;
   void* ptr = (void*)((uint64)obj + ptrOffset);
   
-  if (signature->naturalType == Type::FloatTy) {
+  if (signature->naturalType == Type::getFloatTy(getGlobalContext())) {
     ((float*)ptr)[0] = val;
   } else {
     VMThread::get()->vm->unknownError("wrong type in field assignment");
@@ -60,7 +60,7 @@
   if (stat) obj = classDef->staticInstance;
   void* ptr = (void*)((uint64)obj + ptrOffset);
   
-  if (signature->naturalType == Type::DoubleTy) {
+  if (signature->naturalType == Type::getDoubleTy(getGlobalContext())) {
     ((double*)ptr)[0] = val;
   } else {
     VMThread::get()->vm->unknownError("wrong type in field assignment");
@@ -78,7 +78,7 @@
   if (stat) obj = classDef->staticInstance;
   void* ptr = (void*)((uint64)obj + ptrOffset);
   
-  if (signature->naturalType == Type::Int64Ty) {
+  if (signature->naturalType == Type::getInt64Ty(getGlobalContext())) {
     ((uint64*)ptr)[0] = val;
   } else {
     VMThread::get()->vm->unknownError("wrong type in field assignment");
@@ -96,7 +96,7 @@
   if (stat) obj = classDef->staticInstance;
   void* ptr = (void*)((uint64)obj + ptrOffset);
   
-  if (signature->naturalType == Type::Int32Ty) {
+  if (signature->naturalType == Type::getInt32Ty(getGlobalContext())) {
     ((uint32*)ptr)[0] = val;
   } else {
     VMThread::get()->vm->unknownError("wrong type in field assignment");
@@ -131,7 +131,7 @@
   if (stat) obj = classDef->staticInstance;
   void* ptr = (void*)((uint64)obj + ptrOffset);
   
-  if (signature->naturalType == Type::Int1Ty) {
+  if (signature->naturalType == Type::getInt1Ty(getGlobalContext())) {
     ((bool*)ptr)[0] = val;
   } else {
     VMThread::get()->vm->unknownError("wrong type in field assignment");
@@ -160,27 +160,27 @@
   
   void* ptr = (void*)((uint64)obj + ptrOffset);
   const Type* type = signature->naturalType;
-  if (type == Type::Int8Ty) {
+  if (type == Type::getInt8Ty(getGlobalContext())) {
     GenericValue gv;
     gv.IntVal = APInt(8, ((uint8*)ptr)[0]);
     return gv;
-  } else if (type == Type::Int16Ty) {
+  } else if (type == Type::getInt16Ty(getGlobalContext())) {
     GenericValue gv;
     gv.IntVal = APInt(16, ((uint16*)ptr)[0]);
     return gv;
-  } else if (type == Type::Int32Ty) {
+  } else if (type == Type::getInt32Ty(getGlobalContext())) {
     GenericValue gv;
     gv.IntVal = APInt(32, ((uint32*)ptr)[0]);
     return gv;
-  } else if (type == Type::Int64Ty) {
+  } else if (type == Type::getInt64Ty(getGlobalContext())) {
     GenericValue gv;
     gv.IntVal = APInt(64, ((uint64*)ptr)[0]);
     return gv;
-  } else if (type == Type::DoubleTy) { 
+  } else if (type == Type::getDoubleTy(getGlobalContext())) { 
     GenericValue gv;
     gv.DoubleVal = ((double*)ptr)[0];
     return gv;
-  } else if (type == Type::FloatTy) {
+  } else if (type == Type::getFloatTy(getGlobalContext())) {
     GenericValue gv;
     gv.FloatVal = ((float*)ptr)[0];
     return gv;
@@ -201,27 +201,27 @@
   for (Function::arg_iterator i = func->arg_begin(), e = func->arg_end();
        i != e; ++i) {
     const Type* type = i->getType();
-    if (type == Type::Int8Ty) {
+    if (type == Type::getInt8Ty(getGlobalContext())) {
       GenericValue gv;
       gv.IntVal = APInt(8, va_arg(ap, int));
       args.push_back(gv);
-    } else if (type == Type::Int16Ty) {
+    } else if (type == Type::getInt16Ty(getGlobalContext())) {
       GenericValue gv;
       gv.IntVal = APInt(16, va_arg(ap, int));
       args.push_back(gv);
-    } else if (type == Type::Int32Ty) {
+    } else if (type == Type::getInt32Ty(getGlobalContext())) {
       GenericValue gv;
       gv.IntVal = APInt(32, va_arg(ap, int));
       args.push_back(gv);
-    } else if (type == Type::Int64Ty) {
+    } else if (type == Type::getInt64Ty(getGlobalContext())) {
       GenericValue gv1;
       gv1.IntVal = APInt(64, va_arg(ap, uint64));
       args.push_back(gv1);
-    } else if (type == Type::DoubleTy) { 
+    } else if (type == Type::getDoubleTy(getGlobalContext())) { 
       GenericValue gv1;
       gv1.DoubleVal = va_arg(ap, double);
       args.push_back(gv1);
-    } else if (type == Type::FloatTy) {
+    } else if (type == Type::getFloatTy(getGlobalContext())) {
       GenericValue gv;
       gv.FloatVal = (float)(va_arg(ap, double));
       args.push_back(gv);
@@ -248,27 +248,27 @@
   for (Function::arg_iterator i = ++(func->arg_begin()), e = func->arg_end();
        i != e; ++i) {
     const Type* type = i->getType();
-    if (type == Type::Int8Ty) {
+    if (type == Type::getInt8Ty(getGlobalContext())) {
       GenericValue gv;
       gv.IntVal = APInt(8, va_arg(ap, int));
       args.push_back(gv);
-    } else if (type == Type::Int16Ty) {
+    } else if (type == Type::getInt16Ty(getGlobalContext())) {
       GenericValue gv;
       gv.IntVal = APInt(16, va_arg(ap, int));
       args.push_back(gv);
-    } else if (type == Type::Int32Ty) {
+    } else if (type == Type::getInt32Ty(getGlobalContext())) {
       GenericValue gv;
       gv.IntVal = APInt(32, va_arg(ap, int));
       args.push_back(gv);
-    } else if (type == Type::Int64Ty) {
+    } else if (type == Type::getInt64Ty(getGlobalContext())) {
       GenericValue gv1;
       gv1.IntVal = APInt(64, va_arg(ap, uint64));
       args.push_back(gv1);
-    } else if (type == Type::DoubleTy) { 
+    } else if (type == Type::getDoubleTy(getGlobalContext())) { 
       GenericValue gv1;
       gv1.DoubleVal = va_arg(ap, double);
       args.push_back(gv1);
-    } else if (type == Type::FloatTy) {
+    } else if (type == Type::getFloatTy(getGlobalContext())) {
       GenericValue gv;
       gv.FloatVal = (float)(va_arg(ap, double));
       args.push_back(gv);
@@ -367,7 +367,7 @@
       Module* Mod = vm->getLLVMModule();
       const Type* pty = mvm::MvmModule::ptrType;
       Constant* cons = 
-        ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (this)),
+        ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t (this)),
                                     pty);
 
       _llvmVar = new GlobalVariable(*Mod, pty, true,
@@ -387,7 +387,7 @@
       const Type* pty = mvm::MvmModule::ptrType;
       Module* Mod = classDef->vm->getLLVMModule();
       Constant* cons = 
-        ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (this)),
+        ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t (this)),
                                   pty);
 
       _llvmVar = new GlobalVariable(*Mod, pty, true,
@@ -406,7 +406,7 @@
       Module* Mod = classDef->vm->getLLVMModule();
       const Type* pty = mvm::MvmModule::ptrType;
       Constant* cons = 
-        ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (this)),
+        ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t (this)),
                                   pty);
 
       _llvmVar = new GlobalVariable(*Mod, pty, true,

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

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/LowerArrayLength.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/LowerArrayLength.cpp Sat Aug 15 10:54:14 2009
@@ -46,7 +46,7 @@
           Changed = true;
           Value* val = CI->getOperand(1); // get the array
           std::vector<Value*> args; //size=  2
-          args.push_back(ConstantInt::get(Type::Int32Ty, 0));
+          args.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 0));
           args.push_back(n3::VMArray::sizeOffset());
           Value* ptr = GetElementPtrInst::Create(val, args.begin(), args.end(),
                                                  "", CI);

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

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp Sat Aug 15 10:54:14 2009
@@ -267,22 +267,22 @@
 
   INIT(MSCorlib::pObject,   "System", "Object", VMObject::llvmType, false);
   INIT(MSCorlib::pValue,    "System", "ValueType", 0, false);
-  INIT(MSCorlib::pVoid,     "System", "Void", llvm::Type::VoidTy, true);
-  INIT(MSCorlib::pBoolean,  "System", "Boolean", llvm::Type::Int1Ty, true);
-  INIT(MSCorlib::pUInt8,    "System", "Byte", llvm::Type::Int8Ty, true);
-  INIT(MSCorlib::pSInt8,    "System", "SByte", llvm::Type::Int8Ty, true);
-  INIT(MSCorlib::pChar,     "System", "Char", llvm::Type::Int16Ty, true);
-  INIT(MSCorlib::pSInt16,   "System", "Int16", llvm::Type::Int16Ty, true);
-  INIT(MSCorlib::pUInt16,   "System", "UInt16", llvm::Type::Int16Ty, true);
-  INIT(MSCorlib::pSInt32,   "System", "Int32", llvm::Type::Int32Ty, true);
-  INIT(MSCorlib::pUInt32,   "System", "UInt32", llvm::Type::Int32Ty, true);
-  INIT(MSCorlib::pSInt64,   "System", "Int64", llvm::Type::Int64Ty, true);
-  INIT(MSCorlib::pUInt64,   "System", "UInt64", llvm::Type::Int64Ty, true);
-  INIT(MSCorlib::pIntPtr,   "System", "IntPtr", llvm::PointerType::getUnqual(llvm::Type::Int8Ty), true);
-  INIT(MSCorlib::pUIntPtr,  "System", "UIntPtr", llvm::PointerType::getUnqual(llvm::Type::Int8Ty), true);
-  INIT(MSCorlib::pDouble,   "System", "Double", llvm::Type::DoubleTy, true);
-  INIT(MSCorlib::pFloat,    "System", "Single", llvm::Type::FloatTy, true);
-  INIT(MSCorlib::pEnum,     "System", "Enum", llvm::Type::Int32Ty, true);
+  INIT(MSCorlib::pVoid,     "System", "Void", llvm::Type::getVoidTy(getGlobalContext()), true);
+  INIT(MSCorlib::pBoolean,  "System", "Boolean", llvm::Type::getInt1Ty(getGlobalContext()), true);
+  INIT(MSCorlib::pUInt8,    "System", "Byte", llvm::Type::getInt8Ty(getGlobalContext()), true);
+  INIT(MSCorlib::pSInt8,    "System", "SByte", llvm::Type::getInt8Ty(getGlobalContext()), true);
+  INIT(MSCorlib::pChar,     "System", "Char", llvm::Type::getInt16Ty(getGlobalContext()), true);
+  INIT(MSCorlib::pSInt16,   "System", "Int16", llvm::Type::getInt16Ty(getGlobalContext()), true);
+  INIT(MSCorlib::pUInt16,   "System", "UInt16", llvm::Type::getInt16Ty(getGlobalContext()), true);
+  INIT(MSCorlib::pSInt32,   "System", "Int32", llvm::Type::getInt32Ty(getGlobalContext()), true);
+  INIT(MSCorlib::pUInt32,   "System", "UInt32", llvm::Type::getInt32Ty(getGlobalContext()), true);
+  INIT(MSCorlib::pSInt64,   "System", "Int64", llvm::Type::getInt64Ty(getGlobalContext()), true);
+  INIT(MSCorlib::pUInt64,   "System", "UInt64", llvm::Type::getInt64Ty(getGlobalContext()), true);
+  INIT(MSCorlib::pIntPtr,   "System", "IntPtr", llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(getGlobalContext())), true);
+  INIT(MSCorlib::pUIntPtr,  "System", "UIntPtr", llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(getGlobalContext())), true);
+  INIT(MSCorlib::pDouble,   "System", "Double", llvm::Type::getDoubleTy(getGlobalContext()), true);
+  INIT(MSCorlib::pFloat,    "System", "Single", llvm::Type::getFloatTy(getGlobalContext()), true);
+  INIT(MSCorlib::pEnum,     "System", "Enum", llvm::Type::getInt32Ty(getGlobalContext()), true);
   INIT(MSCorlib::pArray,    "System", "Array", 0, true);
   INIT(MSCorlib::pException,"System", "Exception", 0, false);
   INIT(MSCorlib::pDelegate, "System", "Delegate", 0, false);

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

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/Opcodes.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/Opcodes.cpp Sat Aug 15 10:54:14 2009
@@ -130,10 +130,10 @@
     } else if (isa<PointerType>(t1) && isa<PointerType>(t2)) {
       val1 = new BitCastInst(val1, VMObject::llvmType, "", currentBlock);
       val2 = new BitCastInst(val2, VMObject::llvmType, "", currentBlock);
-    } else if (t1->isInteger() && t2 == PointerType::getUnqual(Type::Int8Ty)) {
+    } else if (t1->isInteger() && t2 == PointerType::getUnqual(Type::getInt8Ty(getGlobalContext()))) {
       // CLI says that this is fine for some operation
       val2 = new PtrToIntInst(val2, t1, "", currentBlock);
-    } else if (t2->isInteger() && t1 == PointerType::getUnqual(Type::Int8Ty)) {
+    } else if (t2->isInteger() && t1 == PointerType::getUnqual(Type::getInt8Ty(getGlobalContext()))) {
       // CLI says that this is fine for some operation
       val1 = new PtrToIntInst(val1, t2, "", currentBlock);
     }
@@ -173,9 +173,9 @@
     uint64 size = module->getTypeSize(contained);
         
     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(new BitCastInst(local, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock));
+    params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock));
+    params.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), size));
     params.push_back(module->constantZero);
     CallInst::Create(module->llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock);
   } else {
@@ -191,9 +191,9 @@
     uint64 size = module->getTypeSize(contained);
     Value* ret = new AllocaInst(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(new BitCastInst(ret, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock));
+    params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock));
+    params.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), size));
     params.push_back(module->constantZero);
     CallInst::Create(module->llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock);
     return ret;
@@ -228,13 +228,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(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), (int64_t)OpcodeNamesFE[bytecodes[i + 1]]));
+      args.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), (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(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), (int64_t)OpcodeNames[bytecodes[i]]));
+      args.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), (int64_t)compilingMethod));
       CallInst::Create(printExecutionLLVM, args.begin(), args.end(), "", currentBlock);
     }
 #endif
@@ -382,10 +382,10 @@
         Value* val = pop();
         const Type* type = val->getType();
         if (type->isFloatingPoint()) {
-          push(new FPToSIInst(val, Type::Int8Ty, "", currentBlock));
-        } else if (type == Type::Int16Ty || type == Type::Int32Ty || 
-                   type == Type::Int64Ty) {
-          push(new TruncInst(val, Type::Int8Ty, "", currentBlock));
+          push(new FPToSIInst(val, Type::getInt8Ty(getGlobalContext()), "", currentBlock));
+        } else if (type == Type::getInt16Ty(getGlobalContext()) || type == Type::getInt32Ty(getGlobalContext()) || 
+                   type == Type::getInt64Ty(getGlobalContext())) {
+          push(new TruncInst(val, Type::getInt8Ty(getGlobalContext()), "", currentBlock));
         } else {
           VMThread::get()->vm->unknownError("implement me");
         }
@@ -396,11 +396,11 @@
         Value* val = pop();
         const Type* type = val->getType();
         if (type->isFloatingPoint()) {
-          push(new FPToSIInst(val, Type::Int16Ty, "", currentBlock));
-        } else if (type == Type::Int32Ty || type == Type::Int64Ty) {
-          push(new TruncInst(val, Type::Int16Ty, "", currentBlock));
-        } else if (type == Type::Int8Ty) {
-          push(new SExtInst(val, Type::Int16Ty, "", currentBlock));
+          push(new FPToSIInst(val, Type::getInt16Ty(getGlobalContext()), "", currentBlock));
+        } else if (type == Type::getInt32Ty(getGlobalContext()) || type == Type::getInt64Ty(getGlobalContext())) {
+          push(new TruncInst(val, Type::getInt16Ty(getGlobalContext()), "", currentBlock));
+        } else if (type == Type::getInt8Ty(getGlobalContext())) {
+          push(new SExtInst(val, Type::getInt16Ty(getGlobalContext()), "", currentBlock));
         } else {
           VMThread::get()->vm->unknownError("implement me");
         }
@@ -411,12 +411,12 @@
         Value* val = pop();
         const Type* type = val->getType();
         if (type->isFloatingPoint()) {
-          push(new FPToSIInst(val, Type::Int32Ty, "", currentBlock));
-        } else if (type == Type::Int64Ty) {
-          push(new TruncInst(val, Type::Int32Ty, "", currentBlock));
-        } else if (type == Type::Int8Ty || type == Type::Int16Ty) {
-          push(new SExtInst(val, Type::Int32Ty, "", currentBlock));
-        } else if (type == Type::Int32Ty) {
+          push(new FPToSIInst(val, Type::getInt32Ty(getGlobalContext()), "", currentBlock));
+        } else if (type == Type::getInt64Ty(getGlobalContext())) {
+          push(new TruncInst(val, Type::getInt32Ty(getGlobalContext()), "", currentBlock));
+        } else if (type == Type::getInt8Ty(getGlobalContext()) || type == Type::getInt16Ty(getGlobalContext())) {
+          push(new SExtInst(val, Type::getInt32Ty(getGlobalContext()), "", currentBlock));
+        } else if (type == Type::getInt32Ty(getGlobalContext())) {
           push(val);
         } else {
           VMThread::get()->vm->unknownError("implement me");
@@ -428,10 +428,10 @@
         Value* val = pop();
         const Type* type = val->getType();
         if (type->isFloatingPoint()) {
-          push(new FPToSIInst(val, Type::Int64Ty, "", currentBlock));
-        } else if (type == Type::Int8Ty || type == Type::Int16Ty || 
-                   type == Type::Int32Ty) {
-          push(new SExtInst(val, Type::Int64Ty, "", currentBlock));
+          push(new FPToSIInst(val, Type::getInt64Ty(getGlobalContext()), "", currentBlock));
+        } else if (type == Type::getInt8Ty(getGlobalContext()) || type == Type::getInt16Ty(getGlobalContext()) || 
+                   type == Type::getInt32Ty(getGlobalContext())) {
+          push(new SExtInst(val, Type::getInt64Ty(getGlobalContext()), "", currentBlock));
         } else {
           VMThread::get()->vm->unknownError("implement me");
         }
@@ -441,10 +441,10 @@
       case CONV_R4 : {
         Value* val = pop();
         const Type* type = val->getType();
-        if (type == Type::DoubleTy) {
-          push(new FPTruncInst(val, Type::FloatTy, "", currentBlock));
+        if (type == Type::getDoubleTy(getGlobalContext())) {
+          push(new FPTruncInst(val, Type::getFloatTy(getGlobalContext()), "", currentBlock));
         } else if (type->isInteger()) {
-          push(new SIToFPInst(val, Type::FloatTy, "", currentBlock));
+          push(new SIToFPInst(val, Type::getFloatTy(getGlobalContext()), "", currentBlock));
         } else {
           VMThread::get()->vm->unknownError("implement me");
         }
@@ -454,11 +454,11 @@
       case CONV_R8 : {
         Value* val = pop();
         const Type* type = val->getType();
-        if (type == Type::FloatTy) {
-          push(new FPExtInst(val, Type::DoubleTy, "", currentBlock));
+        if (type == Type::getFloatTy(getGlobalContext())) {
+          push(new FPExtInst(val, Type::getDoubleTy(getGlobalContext()), "", currentBlock));
         } else if (type->isInteger()) {
-          push(new SIToFPInst(val, Type::DoubleTy, "", currentBlock));
-        } else if (type == Type::DoubleTy) {
+          push(new SIToFPInst(val, Type::getDoubleTy(getGlobalContext()), "", currentBlock));
+        } else if (type == Type::getDoubleTy(getGlobalContext())) {
           push(val);
         } else {
           VMThread::get()->vm->unknownError("implement me");
@@ -470,10 +470,10 @@
         Value* val = pop();
         const Type* type = val->getType();
         if (type->isFloatingPoint()) {
-          push(new FPToUIInst(val, Type::Int8Ty, "", currentBlock));
-        } else if (type == Type::Int16Ty || type == Type::Int32Ty || 
-                   type == Type::Int64Ty) {
-          push(new TruncInst(val, Type::Int8Ty, "", currentBlock));
+          push(new FPToUIInst(val, Type::getInt8Ty(getGlobalContext()), "", currentBlock));
+        } else if (type == Type::getInt16Ty(getGlobalContext()) || type == Type::getInt32Ty(getGlobalContext()) || 
+                   type == Type::getInt64Ty(getGlobalContext())) {
+          push(new TruncInst(val, Type::getInt8Ty(getGlobalContext()), "", currentBlock));
         } else {
           VMThread::get()->vm->unknownError("implement me");
         }
@@ -484,11 +484,11 @@
         Value* val = pop();
         const Type* type = val->getType();
         if (type->isFloatingPoint()) {
-          push(new FPToUIInst(val, Type::Int16Ty, "", currentBlock));
-        } else if (type == Type::Int32Ty || type == Type::Int64Ty) {
-          push(new TruncInst(val, Type::Int8Ty, "", currentBlock));
-        } else if (type == Type::Int8Ty) {
-          push(new ZExtInst(val, Type::Int16Ty, "", currentBlock));
+          push(new FPToUIInst(val, Type::getInt16Ty(getGlobalContext()), "", currentBlock));
+        } else if (type == Type::getInt32Ty(getGlobalContext()) || type == Type::getInt64Ty(getGlobalContext())) {
+          push(new TruncInst(val, Type::getInt8Ty(getGlobalContext()), "", currentBlock));
+        } else if (type == Type::getInt8Ty(getGlobalContext())) {
+          push(new ZExtInst(val, Type::getInt16Ty(getGlobalContext()), "", currentBlock));
         } else {
           VMThread::get()->vm->unknownError("implement me");
         }
@@ -499,11 +499,11 @@
         Value* val = pop();
         const Type* type = val->getType();
         if (type->isFloatingPoint()) {
-          push(new FPToUIInst(val, Type::Int32Ty, "", currentBlock));
-        } else if (type == Type::Int64Ty) {
-          push(new TruncInst(val, Type::Int8Ty, "", currentBlock));
-        } else if (type == Type::Int8Ty || type == Type::Int16Ty) {
-          push(new ZExtInst(val, Type::Int16Ty, "", currentBlock));
+          push(new FPToUIInst(val, Type::getInt32Ty(getGlobalContext()), "", currentBlock));
+        } else if (type == Type::getInt64Ty(getGlobalContext())) {
+          push(new TruncInst(val, Type::getInt8Ty(getGlobalContext()), "", currentBlock));
+        } else if (type == Type::getInt8Ty(getGlobalContext()) || type == Type::getInt16Ty(getGlobalContext())) {
+          push(new ZExtInst(val, Type::getInt16Ty(getGlobalContext()), "", currentBlock));
         } else {
           VMThread::get()->vm->unknownError("implement me");
         }
@@ -514,10 +514,10 @@
         Value* val = pop();
         const Type* type = val->getType();
         if (type->isFloatingPoint()) {
-          push(new FPToUIInst(val, Type::Int64Ty, "", currentBlock));
-        } else if (type == Type::Int8Ty || type == Type::Int16Ty || 
-                   type == Type::Int32Ty) {
-          push(new ZExtInst(val, Type::Int64Ty, "", currentBlock));
+          push(new FPToUIInst(val, Type::getInt64Ty(getGlobalContext()), "", currentBlock));
+        } else if (type == Type::getInt8Ty(getGlobalContext()) || type == Type::getInt16Ty(getGlobalContext()) || 
+                   type == Type::getInt32Ty(getGlobalContext())) {
+          push(new ZExtInst(val, Type::getInt64Ty(getGlobalContext()), "", currentBlock));
         } else {
           VMThread::get()->vm->unknownError("implement me");
         }
@@ -529,12 +529,12 @@
         Value* res = 0;
         
         if (val->getType()->isInteger()) {
-          if (val->getType() != Type::Int64Ty) {
-            val = new ZExtInst(val, Type::Int64Ty, "", currentBlock);
+          if (val->getType() != Type::getInt64Ty(getGlobalContext())) {
+            val = new ZExtInst(val, Type::getInt64Ty(getGlobalContext()), "", currentBlock);
           }
-          res = new IntToPtrInst(val, PointerType::getUnqual(Type::Int8Ty), "", currentBlock);
+          res = new IntToPtrInst(val, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock);
         } else if (!val->getType()->isFloatingPoint()) {
-          res = new BitCastInst(val, PointerType::getUnqual(Type::Int8Ty), "", currentBlock);
+          res = new BitCastInst(val, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock);
         } else {
           VMThread::get()->vm->unknownError("implement me");
         }
@@ -551,11 +551,11 @@
       case CONV_R_UN : {
         Value* val = pop();
         const Type* type = val->getType();
-        if (type == Type::FloatTy) {
-          push(new FPExtInst(val, Type::DoubleTy, "", currentBlock));
+        if (type == Type::getFloatTy(getGlobalContext())) {
+          push(new FPExtInst(val, Type::getDoubleTy(getGlobalContext()), "", currentBlock));
         } else if (type->isInteger()) {
-          push(new UIToFPInst(val, Type::DoubleTy, "", currentBlock));
-        } else if (type == Type::DoubleTy) {
+          push(new UIToFPInst(val, Type::getDoubleTy(getGlobalContext()), "", currentBlock));
+        } else if (type == Type::getDoubleTy(getGlobalContext())) {
           push(val);
         } else {
           VMThread::get()->vm->unknownError("implement me");
@@ -627,12 +627,12 @@
         Value* val = pop();
         const Type* type = val->getType();
         if (type->isFloatingPoint()) {
-          push(new FPToUIInst(val, Type::Int32Ty, "", currentBlock));
-        } else if (type == Type::Int64Ty) {
-          push(new TruncInst(val, Type::Int8Ty, "", currentBlock));
-        } else if (type == Type::Int8Ty || type == Type::Int16Ty) {
-          push(new ZExtInst(val, Type::Int16Ty, "", currentBlock));
-        } else if (type == Type::Int32Ty) {
+          push(new FPToUIInst(val, Type::getInt32Ty(getGlobalContext()), "", currentBlock));
+        } else if (type == Type::getInt64Ty(getGlobalContext())) {
+          push(new TruncInst(val, Type::getInt8Ty(getGlobalContext()), "", currentBlock));
+        } else if (type == Type::getInt8Ty(getGlobalContext()) || type == Type::getInt16Ty(getGlobalContext())) {
+          push(new ZExtInst(val, Type::getInt16Ty(getGlobalContext()), "", currentBlock));
+        } else if (type == Type::getInt32Ty(getGlobalContext())) {
           push(val);
         } else {
           VMThread::get()->vm->unknownError("implement me");
@@ -696,14 +696,14 @@
 
       case ENDFINALLY : {
         Value* val = new LoadInst(supplLocal, "", currentBlock);
-        val = new PtrToIntInst(val, Type::Int32Ty, "", currentBlock);
+        val = new PtrToIntInst(val, Type::getInt32Ty(getGlobalContext()), "", currentBlock);
         SwitchInst* inst = SwitchInst::Create(val, leaves[0], 
                                           leaves.size(), currentBlock);
      
         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(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), index), *i); 
         }
 
         //currentBlock = bb2;
@@ -747,22 +747,22 @@
       }
 
       case LDC_I4 : {
-        push(ConstantInt::get(Type::Int32Ty, readS4(bytecodes, i)));
+        push(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), readS4(bytecodes, i)));
         break;
       }
       
       case LDC_I8 : {
-        push(ConstantInt::get(Type::Int64Ty, readS8(bytecodes, i)));
+        push(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), readS8(bytecodes, i)));
         break;
       }
       
       case LDC_R4 : {
-        push(ConstantFP::get(Type::FloatTy, readFloat(bytecodes, i)));
+        push(ConstantFP::get(Type::getFloatTy(getGlobalContext()), readFloat(bytecodes, i)));
         break;
       }
       
       case LDC_R8 : {
-        push(ConstantFP::get(Type::DoubleTy, readDouble(bytecodes, i)));
+        push(ConstantFP::get(Type::getDoubleTy(getGlobalContext()), readDouble(bytecodes, i)));
         break;
       }
       
@@ -817,14 +817,14 @@
       }
       
       case LDC_I4_S : {
-        push(ConstantInt::get(Type::Int32Ty, readS1(bytecodes, i)));
+        push(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), readS1(bytecodes, i)));
         break;
       }
  
       case LDIND_U1 :
       case LDIND_I1 : {
         Value* _val = pop();
-        Value* val = new BitCastInst(_val, PointerType::getUnqual(Type::Int8Ty), "", currentBlock);
+        Value* val = new BitCastInst(_val, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock);
         push(new LoadInst(val, "", isVolatile, currentBlock));
         isVolatile = false;
         break;
@@ -833,7 +833,7 @@
       case LDIND_U2 :
       case LDIND_I2 : {
         Value* _val = pop();
-        Value* val = new BitCastInst(_val, PointerType::getUnqual(Type::Int16Ty), "", currentBlock);
+        Value* val = new BitCastInst(_val, PointerType::getUnqual(Type::getInt16Ty(getGlobalContext())), "", currentBlock);
         push(new LoadInst(val, "", isVolatile, currentBlock));
         isVolatile = false;
         break;
@@ -843,9 +843,9 @@
       case LDIND_I4 : {
         Value* val = pop();
         if (val->getType()->isInteger()) {
-          val = new IntToPtrInst(val, PointerType::getUnqual(Type::Int32Ty), "", currentBlock);
+          val = new IntToPtrInst(val, PointerType::getUnqual(Type::getInt32Ty(getGlobalContext())), "", currentBlock);
         } else {
-          val = new BitCastInst(val, PointerType::getUnqual(Type::Int32Ty), "", currentBlock);
+          val = new BitCastInst(val, PointerType::getUnqual(Type::getInt32Ty(getGlobalContext())), "", currentBlock);
         }
         push(new LoadInst(val, "", isVolatile, currentBlock));
         isVolatile = false;
@@ -854,7 +854,7 @@
       
       case LDIND_I8 : {
         Value* _val = pop();
-        Value* val = new BitCastInst(_val, PointerType::getUnqual(Type::Int64Ty), "", currentBlock);
+        Value* val = new BitCastInst(_val, PointerType::getUnqual(Type::getInt64Ty(getGlobalContext())), "", currentBlock);
         push(new LoadInst(val, "", isVolatile, currentBlock));
         isVolatile = false;
         break;
@@ -862,7 +862,7 @@
 
       case LDIND_R4 : {
         Value* _val = pop();
-        Value* val = new BitCastInst(_val, PointerType::getUnqual(Type::FloatTy), "", currentBlock);
+        Value* val = new BitCastInst(_val, PointerType::getUnqual(Type::getFloatTy(getGlobalContext())), "", currentBlock);
         push(new LoadInst(val, "", isVolatile, currentBlock));
         isVolatile = false;
         break;
@@ -870,7 +870,7 @@
       
       case LDIND_R8 : {
         Value* _val = pop();
-        Value* val = new BitCastInst(_val, PointerType::getUnqual(Type::DoubleTy), "", currentBlock);
+        Value* val = new BitCastInst(_val, PointerType::getUnqual(Type::getDoubleTy(getGlobalContext())), "", currentBlock);
         push(new LoadInst(val, "", isVolatile, currentBlock));
         isVolatile = false;
         break;
@@ -879,7 +879,7 @@
       case LDIND_I : {
         Value* _val = pop();
         Value* val = new BitCastInst(_val, PointerType::getUnqual(
-                                        PointerType::getUnqual(Type::Int8Ty)), "", currentBlock);
+                                        PointerType::getUnqual(Type::getInt8Ty(getGlobalContext()))), "", currentBlock);
         push(new LoadInst(val, "", isVolatile, currentBlock));
         isVolatile = false;
         break;
@@ -952,7 +952,7 @@
           }
           if (res) {
             Value* expr = ConstantExpr::getIntToPtr(
-                                    ConstantInt::get(Type::Int64Ty,
+                                    ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
                                                      uint64_t (leaveIndex++)),
                                     VMObject::llvmType);
 
@@ -984,7 +984,7 @@
           }
           if (res) {
             Value* expr = ConstantExpr::getIntToPtr(
-                                    ConstantInt::get(Type::Int64Ty,
+                                    ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
                                                      uint64_t (leaveIndex++)),
                                     VMObject::llvmType);
 
@@ -1028,7 +1028,7 @@
       case NOP : break;
 
       case NOT : {
-        push(BinaryOperator::CreateNot(llvmFunction->getContext(), pop(), "", currentBlock));
+        push(BinaryOperator::CreateNot(pop(), "", currentBlock));
         break;
       }
 
@@ -1067,7 +1067,7 @@
       }
 
       case RET : {
-        if (compilingMethod->getSignature(genMethod)->getReturnType() != Type::VoidTy) {
+        if (compilingMethod->getSignature(genMethod)->getReturnType() != Type::getVoidTy(getGlobalContext())) {
           Value* val = pop();
           if (val->getType() == PointerType::getUnqual(endNode->getType())) {
             // In case it's a struct
@@ -1118,9 +1118,9 @@
       case STIND_I1 : {
         Value* val = pop();
         Value* _addr = pop();
-        Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::Int8Ty), "",
+        Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "",
                                       currentBlock);
-        convertValue(val, Type::Int8Ty, currentBlock);
+        convertValue(val, Type::getInt8Ty(getGlobalContext()), currentBlock);
         new StoreInst(val, addr, isVolatile, currentBlock);
         isVolatile = false;
         break;
@@ -1129,7 +1129,7 @@
       case STIND_I2 : {
         Value* val = pop();
         Value* _addr = pop();
-        Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::Int16Ty), 
+        Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::getInt16Ty(getGlobalContext())), 
                                       "", currentBlock);
         new StoreInst(val, addr, isVolatile, currentBlock);
         isVolatile = false;
@@ -1139,7 +1139,7 @@
       case STIND_I4 : {
         Value* val = pop();
         Value* _addr = pop();
-        Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::Int32Ty), 
+        Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::getInt32Ty(getGlobalContext())), 
                                       "", currentBlock);
         new StoreInst(val, addr, isVolatile, currentBlock);
         isVolatile = false;
@@ -1149,7 +1149,7 @@
       case STIND_I8 : {
         Value* val = pop();
         Value* _addr = pop();
-        Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::Int64Ty), 
+        Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::getInt64Ty(getGlobalContext())), 
                                       "", currentBlock);
         new StoreInst(val, addr, isVolatile, currentBlock);
         isVolatile = false;
@@ -1159,7 +1159,7 @@
       case STIND_R4 : {
         Value* val = pop();
         Value* _addr = pop();
-        Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::FloatTy), 
+        Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::getFloatTy(getGlobalContext())), 
                                       "", currentBlock);
         new StoreInst(val, addr, isVolatile, currentBlock);
         isVolatile = false;
@@ -1169,7 +1169,7 @@
       case STIND_R8 : {
         Value* val = pop();
         Value* _addr = pop();
-        Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::DoubleTy), 
+        Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::getDoubleTy(getGlobalContext())), 
                                       "", currentBlock);
         new StoreInst(val, addr, isVolatile, currentBlock);
         isVolatile = false;
@@ -1179,7 +1179,7 @@
       case STIND_I : {
         Value* val = pop();
         Value* _addr = pop();
-        Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::Int32Ty), 
+        Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::getInt32Ty(getGlobalContext())), 
                                       "", currentBlock);
         new StoreInst(val, addr, isVolatile, currentBlock);
         isVolatile = false;
@@ -1260,7 +1260,7 @@
           sint32 index = next + offset;
           assert(index > 0);
           BasicBlock* BB = opcodeInfos[index].newBlock;
-          SI->addCase(ConstantInt::get(Type::Int32Ty, t), BB);
+          SI->addCase(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), t), BB);
         }
         break;
       }
@@ -1309,9 +1309,9 @@
         uint64 size = module->getTypeSize(type->naturalType);
         
         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(new BitCastInst(ptr, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock));
+        params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock));
+        params.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), size));
         params.push_back(module->constantZero);
         CallInst::Create(module->llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock);
         
@@ -1360,7 +1360,7 @@
           InvokeInst::Create(classCastExceptionLLVM, unifiedUnreachable, currentExceptionBlock, exArgs.begin(), exArgs.end(), "", ex);
         } else {
           CallInst::Create(classCastExceptionLLVM, exArgs.begin(), exArgs.end(), "", ex);
-          new UnreachableInst(ex);
+          new UnreachableInst(getGlobalContext(), ex);
         }
 
         currentBlock = ifTrue;
@@ -1578,7 +1578,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(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), (int64_t)utf8),
                                                module->ptrType);
         Value* res = CallInst::Create(newStringLLVM, val, "", currentBlock);
         /*CLIString * str = 
@@ -1680,7 +1680,7 @@
         Value* index = pop();
         Value* obj = pop();
         Value* ptr = verifyAndComputePtr(obj, index, ArraySInt8::llvmType);
-        convertValue(val, Type::Int8Ty, currentBlock);
+        convertValue(val, Type::getInt8Ty(getGlobalContext()), currentBlock);
         new StoreInst(val, ptr, false, currentBlock);
         break;
       }
@@ -1690,7 +1690,7 @@
         Value* index = pop();
         Value* obj = pop();
         Value* ptr = verifyAndComputePtr(obj, index, ArraySInt16::llvmType);
-        convertValue(val, Type::Int16Ty, currentBlock);
+        convertValue(val, Type::getInt16Ty(getGlobalContext()), currentBlock);
         new StoreInst(val, ptr, false, currentBlock);
         break;
       }
@@ -1700,7 +1700,7 @@
         Value* index = pop();
         Value* obj = pop();
         Value* ptr = verifyAndComputePtr(obj, index, ArraySInt32::llvmType);
-        convertValue(val, Type::Int32Ty, currentBlock);
+        convertValue(val, Type::getInt32Ty(getGlobalContext()), currentBlock);
         new StoreInst(val, ptr, false, currentBlock);
         break;
       }
@@ -1710,7 +1710,7 @@
         Value* index = pop();
         Value* obj = pop();
         Value* ptr = verifyAndComputePtr(obj, index, ArrayLong::llvmType);
-        convertValue(val, Type::Int64Ty, currentBlock);
+        convertValue(val, Type::getInt64Ty(getGlobalContext()), currentBlock);
         new StoreInst(val, ptr, false, currentBlock);
         break;
       }
@@ -1720,7 +1720,7 @@
         Value* index = pop();
         Value* obj = pop();
         Value* ptr = verifyAndComputePtr(obj, index, ArrayFloat::llvmType);
-        convertValue(val, Type::FloatTy, currentBlock);
+        convertValue(val, Type::getFloatTy(getGlobalContext()), currentBlock);
         new StoreInst(val, ptr, false, currentBlock);
         break;
       }
@@ -1730,7 +1730,7 @@
         Value* index = pop();
         Value* obj = pop();
         Value* ptr = verifyAndComputePtr(obj, index, ArrayDouble::llvmType);
-        convertValue(val, Type::DoubleTy, currentBlock);
+        convertValue(val, Type::getDoubleTy(getGlobalContext()), currentBlock);
         new StoreInst(val, ptr, false, currentBlock);
         break;
       }
@@ -1779,7 +1779,7 @@
           InvokeInst::Create(throwExceptionLLVM, unifiedUnreachable, currentExceptionBlock, args.begin(), args.end(), "", currentBlock);
         } else {
           CallInst::Create(throwExceptionLLVM, args.begin(), args.end(), "", currentBlock);
-          new UnreachableInst(currentBlock);
+          new UnreachableInst(getGlobalContext(), currentBlock);
         }
         break;
       }
@@ -1808,9 +1808,9 @@
         uint64 size = module->getTypeSize(type->naturalType);
         
         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(new BitCastInst(val, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock));
+        params.push_back(new BitCastInst(ptr, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock));
+        params.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), size));
         params.push_back(module->constantZero);
         CallInst::Create(module->llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock);
         
@@ -1922,7 +1922,7 @@
           }
           
           case LOCALLOC : {
-            push(new AllocaInst(Type::Int8Ty, pop(), "", currentBlock));
+            push(new AllocaInst(Type::getInt8Ty(getGlobalContext()), pop(), "", currentBlock));
             break;
           }
           
@@ -1961,7 +1961,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(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), size));
               params.push_back(module->constantZero);
               CallInst::Create(module->llvm_memset_i32, params.begin(),
                                params.end(), "", currentBlock);
@@ -1991,7 +1991,7 @@
               InvokeInst::Create(throwExceptionLLVM, unifiedUnreachable, currentExceptionBlock, args.begin(), args.end(), "", currentBlock);
             } else {
               CallInst::Create(throwExceptionLLVM, args.begin(), args.end(), "", currentBlock);
-              new UnreachableInst(currentBlock);
+              new UnreachableInst(getGlobalContext(), currentBlock);
             }
             break;
           }

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

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMCache.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VMCache.cpp Sat Aug 15 10:54:14 2009
@@ -92,7 +92,7 @@
   Value* five = module->constantFive;
   
   Value* llvmEnv = 
-    ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (enveloppe)),
+    ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t (enveloppe)),
                   Enveloppe::llvmType);
   
   std::vector<Value*> args1;
@@ -152,7 +152,7 @@
   Value* ret = invoke(meth, args, "", currentBlock, origMeth->structReturn);
 
 
-  if (ret->getType() != Type::VoidTy) {
+  if (ret->getType() != Type::getVoidTy(getGlobalContext())) {
     push(ret);
   }
 }

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

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMClass.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VMClass.cpp Sat Aug 15 10:54:14 2009
@@ -11,6 +11,7 @@
 #include <vector>
 
 #include "llvm/DerivedTypes.h"
+#include "llvm/Module.h"
 
 #include "debug.h"
 #include "types.h"
@@ -168,7 +169,7 @@
   this->isArray = isArray;
   this->isPointer = false;
   this->isPrimitive = false;
-  this->naturalType = llvm::OpaqueType::get();
+  this->naturalType = llvm::OpaqueType::get(llvm::getGlobalContext());
 }
 
 const UTF8* VMClassArray::constructArrayName(const UTF8* name, uint32 dims) {
@@ -279,7 +280,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 = llvm::ConstantInt::get(llvm::Type::getInt32Ty(llvm::getGlobalContext()), ++offset);
   }
   for (std::vector<VMField*>::iterator i = cl->staticFields.begin(),
             e = cl->staticFields.end(); i!= e; ++i) {
@@ -315,7 +316,7 @@
   const llvm::Type* ResultTy = 0;
   if (hasExplicitLayout(flags)) {
     explicitLayoutSize = assembly->getExplicitLayout(token);
-    ResultTy = llvm::IntegerType::get(explicitLayoutSize);
+    ResultTy = llvm::IntegerType::get(llvm::getGlobalContext(), explicitLayoutSize);
   } else if (super != 0) {
     if (super == MSCorlib::pValue) {
       uint32 size = virtualFields.size();
@@ -323,27 +324,27 @@
         virtualFields[0]->offset = VMThread::get()->vm->module->constantZero;
         ResultTy = virtualFields[0]->signature->naturalType;
       } else if (size == 0) {
-        ResultTy = llvm::Type::VoidTy;
+        ResultTy = llvm::Type::getVoidTy(llvm::getGlobalContext());
       } else {
         std::vector<const llvm::Type*> Elts;
         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 = llvm::ConstantInt::get(llvm::Type::getInt32Ty(llvm::getGlobalContext()), ++offset);
           const llvm::Type* type = (*i)->signature->naturalType;
           Elts.push_back(type);
         }
         ResultTy = llvm::StructType::get(vm->LLVMModule->getContext(), Elts);
       }
     } else if (super == MSCorlib::pEnum) {
-      ResultTy = llvm::Type::Int32Ty; // TODO find max
+      ResultTy = llvm::Type::getInt32Ty(llvm::getGlobalContext()); // TODO find max
     } else {
       std::vector<const llvm::Type*> Elts;
       Elts.push_back(super->naturalType->getContainedType(0));
       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 = llvm::ConstantInt::get(llvm::Type::getInt32Ty(llvm::getGlobalContext()), ++offset);
         const llvm::Type* type = (*i)->signature->naturalType;
         Elts.push_back(type);
       }
@@ -384,7 +385,7 @@
 void VMClassArray::makeType() {
   std::vector<const llvm::Type*> arrayFields;
   arrayFields.push_back(VMObject::llvmType->getContainedType(0));
-  arrayFields.push_back(llvm::Type::Int32Ty);
+  arrayFields.push_back(llvm::Type::getInt32Ty(llvm::getGlobalContext()));
   arrayFields.push_back(llvm::ArrayType::get(baseClass->naturalType, 0));
   const llvm::Type* type = llvm::PointerType::getUnqual(llvm::StructType::get(vm->LLVMModule->getContext(), arrayFields, false));
   ((llvm::OpaqueType*)naturalType)->refineAbstractTypeTo(type);
@@ -393,7 +394,7 @@
 }
 
 void VMClassPointer::makeType() {
-  const llvm::Type* type = (baseClass->naturalType == llvm::Type::VoidTy) ? llvm::Type::Int8Ty : baseClass->naturalType;
+  const llvm::Type* type = (baseClass->naturalType == llvm::Type::getVoidTy(llvm::getGlobalContext())) ? llvm::Type::getInt8Ty(llvm::getGlobalContext()) : baseClass->naturalType;
   const llvm::Type* pType = llvm::PointerType::getUnqual(type);
   ((llvm::OpaqueType*)naturalType)->refineAbstractTypeTo(pType);
   naturalType = pType;
@@ -691,9 +692,9 @@
       }
     }
 
-    if (!(ret->isSingleValueType()) && ret != llvm::Type::VoidTy) {
+    if (!(ret->isSingleValueType()) && ret != llvm::Type::getVoidTy(llvm::getGlobalContext())) {
       args.push_back(llvm::PointerType::getUnqual(ret));
-      ret = llvm::Type::VoidTy;
+      ret = llvm::Type::getVoidTy(llvm::getGlobalContext());
       structRet = true;
     } else {
       structRet = false;





More information about the vmkit-commits mailing list