From b45ac7bee691a45ccf1c3dc8cdc9c80ea076f1ee Mon Sep 17 00:00:00 2001
From: Matthias Andreas Benkard <code@mail.matthias.benkard.de>
Date: Thu, 8 Sep 2011 23:38:35 +0200
Subject: Update to LLVM 2.9.

---
 MLKLLVMCompiler.mm                      | 112 +++++++++++++++-----------------
 MLKLexicalContext-MLKLLVMCompilation.mm |  21 +++---
 Toilet Lisp.xcodeproj/project.pbxproj   |   4 ++
 llvm_context.h                          |  27 ++++++++
 4 files changed, 94 insertions(+), 70 deletions(-)
 create mode 100644 llvm_context.h

diff --git a/MLKLLVMCompiler.mm b/MLKLLVMCompiler.mm
index bb235bf..72b455b 100644
--- a/MLKLLVMCompiler.mm
+++ b/MLKLLVMCompiler.mm
@@ -18,9 +18,11 @@
 
 #import "MLKCompiledClosure.h"
 #import "MLKDynamicContext.h"
+#import "MLKLexicalContext-MLKLLVMCompilation.h"
 #import "MLKLLVMCompiler.h"
 #import "MLKPackage.h"
 #import "globals.h"
+#import "llvm_context.h"
 #import "util.h"
 
 #import <Foundation/NSArray.h>
@@ -42,7 +44,6 @@
 #include <llvm/Instructions.h>
 //#include <llvm/Interpreter.h>
 #include <llvm/Module.h>
-#include <llvm/ModuleProvider.h>
 #include <llvm/PassManager.h>
 #include <llvm/Support/IRBuilder.h>
 #include <llvm/Target/TargetData.h>
@@ -69,23 +70,17 @@ using namespace std;
 
 static ExecutionEngine *execution_engine;
 static llvm::Module *module;
-#if defined(LLVM_MAJOR_VERSION) && (LLVM_MAJOR_VERSION <= 2) && (LLVM_MINOR_VERSION <= 3)
-static IRBuilder builder;
-#else
-static IRBuilder<true, ConstantFolder> builder;
-#endif
+static IRBuilder<true, ConstantFolder> builder(llvm_context);
 static FunctionPassManager *fpm;
-static PointerType *VoidPointerTy, *PointerPointerTy;
-static ModuleProvider *module_provider;
 
 
 static Constant
 *createGlobalStringPtr (const char *string)
 {
   Constant *(indices[2]);
-  indices[0] = indices[1] = ConstantInt::get (Type::Int32Ty, 0);
+  indices[0] = indices[1] = ConstantInt::get (Int32Ty, 0);
 
-  Constant *str = ConstantArray::get (string);
+  Constant *str = ConstantArray::get (llvm_context, string);
   Constant *str2 = new GlobalVariable (str->getType(),
                                        true, 
                                        GlobalValue::InternalLinkage,
@@ -114,16 +109,12 @@ static Constant
 
 +(void) initialize
 {
-  module = new llvm::Module ("MLKLLVMModule");
-  module_provider = new ExistingModuleProvider (module);
-
-  //execution_engine = ExecutionEngine::create (module_provider, true);
-  execution_engine = ExecutionEngine::create (module_provider, false);
+  module = new llvm::Module ("MLKLLVMModule", llvm_context);
 
-  VoidPointerTy = PointerType::get(Type::Int8Ty, 0);
-  PointerPointerTy = PointerType::get(VoidPointerTy, 0);
+  //execution_engine = ExecutionEngine::create (module, true);
+  execution_engine = ExecutionEngine::create (module, false);
 
-  fpm = new FunctionPassManager (module_provider);
+  fpm = new FunctionPassManager (module);
   fpm->add (new TargetData (*execution_engine->getTargetData()));
   //fpm->add (new TargetData (module));
   fpm->add (createScalarReplAggregatesPass());
@@ -151,7 +142,7 @@ static Constant
 
   Value *v = NULL;
   BasicBlock *block;
-  vector<const Type*> noargs (0, Type::VoidTy);
+  vector<const Type*> noargs (0, VoidTy);
   FunctionType *function_type = FunctionType::get (VoidPointerTy,
                                                    noargs,
                                                    false);
@@ -166,7 +157,7 @@ static Constant
                            forCompiler:self];
   [self markVariablesForHeapAllocationInForm:form];
 
-  block = BasicBlock::Create ("entry", function);
+  block = BasicBlock::Create (llvm_context, "entry", function);
   builder.SetInsertPoint (block);
 
   v = [self processForm:form];
@@ -193,7 +184,7 @@ static Constant
   // FIXME: Free machine code when appropriate.  (I.e. now?  But this crashes after a LOAD.)
   //execution_engine->freeMachineCodeForFunction (function);
 #else
-  Interpreter *i = Interpreter::create (module_provider);
+  Interpreter *i = Interpreter::create (module);
   lambdaForm = i->runFunction (function)->PointerVal;
 #endif
 
@@ -292,7 +283,7 @@ static Constant
                onObject:object
                withArgumentVector:argv
                name:@""
-               returnType:(Type::VoidTy)];
+               returnType:(VoidTy)];
 }
 
 +(Value *) insertMethodCall:(NSString *)messageName
@@ -390,7 +381,7 @@ static Constant
 {
   Constant *function =
     module->getOrInsertFunction ("puts",
-                                 Type::Int32Ty,
+                                 Int32Ty,
                                  VoidPointerTy,
                                  NULL);
 
@@ -401,7 +392,7 @@ static Constant
 {
   Constant *function =
     module->getOrInsertFunction ("printf",
-                                 Type::Int32Ty,
+                                 Int32Ty,
                                  VoidPointerTy,
                                  VoidPointerTy,
                                  NULL);
@@ -472,8 +463,8 @@ static Constant
 
   Function *function = builder.GetInsertBlock()->getParent();
 
-  BasicBlock *loopBlock = BasicBlock::Create ("loop", function);
-  BasicBlock *joinBlock = BasicBlock::Create ("after_loop");
+  BasicBlock *loopBlock = BasicBlock::Create (llvm_context, "loop", function);
+  BasicBlock *joinBlock = BasicBlock::Create (llvm_context, "after_loop");
 
   builder.CreateBr (loopBlock);
   builder.SetInsertPoint (loopBlock);
@@ -510,7 +501,7 @@ static Constant
                                  onObject:mlkdynamiccontext];
 
       LRETAIN (_form);  // FIXME: release
-      Value *symbolV = builder.CreateIntToPtr (ConstantInt::get(Type::Int64Ty,
+      Value *symbolV = builder.CreateIntToPtr (ConstantInt::get(Int64Ty,
                                                                 (uint64_t)_form,
                                                                 false),
                                                VoidPointerTy);
@@ -579,8 +570,8 @@ static Constant
       ptrdiff_t code_offset = offsetof (MLKCompiledClosure, m_code);
       ptrdiff_t data_offset = offsetof (MLKCompiledClosure, m_data);
 #endif
-      Constant *code_offset_value = ConstantInt::get (Type::Int32Ty, code_offset, false);
-      Constant *data_offset_value = ConstantInt::get (Type::Int32Ty, data_offset, false);
+      Constant *code_offset_value = ConstantInt::get (Int32Ty, code_offset, false);
+      Constant *data_offset_value = ConstantInt::get (Int32Ty, data_offset, false);
       Value *codeptr = builder.CreateGEP (closure, code_offset_value);
       Value *dataptr = builder.CreateGEP (closure, data_offset_value);
       codeptr = builder.CreateBitCast (codeptr, PointerPointerTy, "closure_code_ptr");
@@ -616,7 +607,7 @@ static Constant
   //GlobalVariable *endmarker = module->getGlobalVariable ("MLKEndOfArgumentsMarker", false);
   //endmarker->setConstant (true);
   //GlobalVariable *endmarker = new GlobalVariable (VoidPointerTy, true, GlobalValue::ExternalWeakLinkage);
-  Value *endmarker = builder.CreateIntToPtr (ConstantInt::get(Type::Int64Ty,
+  Value *endmarker = builder.CreateIntToPtr (ConstantInt::get(Int64Ty,
                                                               (uint64_t)MLKEndOfArgumentsMarker,
                                                               false),
                                              VoidPointerTy);
@@ -637,7 +628,8 @@ static Constant
   // XXX
   if ([_context functionIsInline:_head])
     {
-      InlineFunction (call);
+      // FIXME: What to do here?
+      //InlineFunction (call);
     }
 
   //[_compiler insertTrace:[NSString stringWithFormat:@"%@ done.", MLKPrintToString(_head)]];
@@ -674,19 +666,19 @@ build_simple_function_definition (MLKBodyForm *processed_form,
   functionMultiValue->setName ("function_multiple_value_return_pointer");
 
   BasicBlock *outerBlock = builder.GetInsertBlock ();
-  BasicBlock *initBlock = BasicBlock::Create ("init_function", function);
-  BasicBlock *loopBlock = BasicBlock::Create ("load_args");
-  BasicBlock *loopInitBlock = BasicBlock::Create ("load_args_prelude");
-  BasicBlock *joinBlock = BasicBlock::Create ("function_body");
-  BasicBlock *lambdaListNewBlock = BasicBlock::Create ("lambda_list_new");
-  BasicBlock *lambdaListUpdateBlock = BasicBlock::Create ("lambda_list_update");
+  BasicBlock *initBlock = BasicBlock::Create (llvm_context, "init_function", function);
+  BasicBlock *loopBlock = BasicBlock::Create (llvm_context, "load_args");
+  BasicBlock *loopInitBlock = BasicBlock::Create (llvm_context, "load_args_prelude");
+  BasicBlock *joinBlock = BasicBlock::Create (llvm_context, "function_body");
+  BasicBlock *lambdaListNewBlock = BasicBlock::Create (llvm_context, "lambda_list_new");
+  BasicBlock *lambdaListUpdateBlock = BasicBlock::Create (llvm_context, "lambda_list_update");
 
   // ***** HANDLE CLOSURE VARIABLES *****
   builder.SetInsertPoint (outerBlock);
 
   NSArray *freeVariables = [[processed_form freeVariables] allObjects];
   closure_data = builder.CreateAlloca (VoidPointerTy,
-                                       ConstantInt::get(Type::Int32Ty,
+                                       ConstantInt::get(Int32Ty,
                                                         (uint32_t)[freeVariables count],
                                                         false));
   closure_data_size = 0;
@@ -697,7 +689,7 @@ build_simple_function_definition (MLKBodyForm *processed_form,
       MLKSymbol *symbol = [freeVariables objectAtIndex:i];
       if (![_context variableIsGlobal:symbol])
         {
-          Constant *position = ConstantInt::get(Type::Int32Ty, closure_data_size, false);
+          Constant *position = ConstantInt::get(Int32Ty, closure_data_size, false);
 
           // Fill in the closure data array.
           builder.SetInsertPoint (outerBlock);
@@ -721,16 +713,16 @@ build_simple_function_definition (MLKBodyForm *processed_form,
 
   // ***** HANDLE ARGUMENTS *****
   builder.SetInsertPoint (initBlock);
-  Value *endmarker = builder.CreateIntToPtr (ConstantInt::get(Type::Int64Ty,
+  Value *endmarker = builder.CreateIntToPtr (ConstantInt::get(Int64Ty,
                                                               (uint64_t)MLKEndOfArgumentsMarker,
                                                               false),
-                                             PointerType::get(Type::Int8Ty, 0));
+                                             PointerType::get(Int8Ty, 0));
 
   Value *ap = builder.CreateAlloca (VoidPointerTy, NULL, "ap");
   Value *ap2 = builder.CreateBitCast (ap, VoidPointerTy);
 
   builder.CreateCall (module->getOrInsertFunction ("llvm.va_start",
-                                                   Type::VoidTy,
+                                                   VoidTy,
                                                    VoidPointerTy,
                                                    NULL),
                       ap2);
@@ -787,7 +779,7 @@ build_simple_function_definition (MLKBodyForm *processed_form,
   function->getBasicBlockList().push_back (joinBlock);
 
   builder.CreateCall (module->getOrInsertFunction ("llvm.va_end",
-                                                   Type::VoidTy,
+                                                   VoidTy,
                                                    VoidPointerTy,
                                                    NULL),
                       ap2);
@@ -858,7 +850,7 @@ build_simple_function_definition (MLKBodyForm *processed_form,
   vector<Value *> argv;
   argv.push_back (function);
   argv.push_back (builder.CreateBitCast (closure_data, VoidPointerTy));
-  argv.push_back (builder.CreateIntToPtr (ConstantInt::get(Type::Int32Ty,
+  argv.push_back (builder.CreateIntToPtr (ConstantInt::get(Int32Ty,
                                                            closure_data_size,
                                                            false),
                                           VoidPointerTy));
@@ -945,7 +937,7 @@ build_simple_function_definition (MLKBodyForm *processed_form,
       vector<Value *> argv;
       argv.push_back (function);
       argv.push_back (builder.CreateBitCast (closure_data, VoidPointerTy));
-      argv.push_back (builder.CreateIntToPtr (ConstantInt::get(Type::Int32Ty,
+      argv.push_back (builder.CreateIntToPtr (ConstantInt::get(Int32Ty,
                                                                closure_data_size,
                                                                false),
                                               VoidPointerTy));
@@ -996,7 +988,7 @@ build_simple_function_definition (MLKBodyForm *processed_form,
     [[NSGarbageCollector defaultCollector] disableCollectorForPointer:_quotedData];
 #endif
 
-  return builder.CreateIntToPtr (ConstantInt::get(Type::Int64Ty,
+  return builder.CreateIntToPtr (ConstantInt::get(Int64Ty,
                                                   (uint64_t)_quotedData,
                                                   false),
                                  VoidPointerTy);
@@ -1017,7 +1009,7 @@ build_simple_function_definition (MLKBodyForm *processed_form,
     [[NSGarbageCollector defaultCollector] disableCollectorForPointer:_form];
 #endif
 
-  return builder.CreateIntToPtr (ConstantInt::get(Type::Int64Ty,
+  return builder.CreateIntToPtr (ConstantInt::get(Int64Ty,
                                                   (uint64_t)_form,
                                                   false),
                                  VoidPointerTy);
@@ -1029,9 +1021,9 @@ build_simple_function_definition (MLKBodyForm *processed_form,
 -(Value *) reallyProcessForLLVMWithMultiValue:(Value *)multiValue
 {
   Function *function = builder.GetInsertBlock()->getParent();
-  BasicBlock *thenBlock = BasicBlock::Create ("if_then", function);
-  BasicBlock *elseBlock = BasicBlock::Create ("if_else");
-  BasicBlock *joinBlock = BasicBlock::Create ("if_join");
+  BasicBlock *thenBlock = BasicBlock::Create (llvm_context, "if_then", function);
+  BasicBlock *elseBlock = BasicBlock::Create (llvm_context, "if_else");
+  BasicBlock *joinBlock = BasicBlock::Create (llvm_context, "if_join");
 
   Value *test = builder.CreateICmpNE ([_conditionForm processForLLVMWithMultiValue:NULL],
                                       ConstantPointerNull::get (VoidPointerTy));
@@ -1082,7 +1074,7 @@ build_simple_function_definition (MLKBodyForm *processed_form,
             [[NSGarbageCollector defaultCollector] disableCollectorForPointer:variable];
 #endif
 
-          Value *symbolV = builder.CreateIntToPtr (ConstantInt::get(Type::Int64Ty,
+          Value *symbolV = builder.CreateIntToPtr (ConstantInt::get(Int64Ty,
                                                                     (uint64_t)variable,
                                                                     false),
                                                    VoidPointerTy);
@@ -1096,9 +1088,9 @@ build_simple_function_definition (MLKBodyForm *processed_form,
           // Test whether the binding is non-null.  If so, set its value, else create a new one.
 
           Function *function = builder.GetInsertBlock()->getParent();
-          BasicBlock *setBlock = BasicBlock::Create ("setq_set_existing_dynamic_binding", function);
-          BasicBlock *makeNewBlock = BasicBlock::Create ("setq_make_new_dynamic_binding");
-          BasicBlock *joinBlock = BasicBlock::Create ("setq_join");
+          BasicBlock *setBlock = BasicBlock::Create (llvm_context, "setq_set_existing_dynamic_binding", function);
+          BasicBlock *makeNewBlock = BasicBlock::Create (llvm_context, "setq_make_new_dynamic_binding");
+          BasicBlock *joinBlock = BasicBlock::Create (llvm_context, "setq_join");
 
           Value *test = builder.CreateICmpNE (binding, ConstantPointerNull::get (VoidPointerTy));
           //Value *value = builder.CreateAlloca (VoidPointerTy, NULL, "if_result");
@@ -1164,7 +1156,7 @@ build_simple_function_definition (MLKBodyForm *processed_form,
     forSymbol:[[MLKPackage findPackage:@"COMMON-LISP"]
                 intern:@"*PACKAGE*"]];
 
-  return builder.CreateIntToPtr (ConstantInt::get(Type::Int64Ty,
+  return builder.CreateIntToPtr (ConstantInt::get(Int64Ty,
                                                   (uint64_t)package,
                                                   false),
                                  VoidPointerTy);
@@ -1188,7 +1180,7 @@ build_simple_function_definition (MLKBodyForm *processed_form,
         [[NSGarbageCollector defaultCollector] disableCollectorForPointer:_functionName];
 #endif
       
-      Value *symbolV = builder.CreateIntToPtr (ConstantInt::get(Type::Int64Ty,
+      Value *symbolV = builder.CreateIntToPtr (ConstantInt::get(Int64Ty,
                                                                 (uint64_t)_functionName,
                                                                 false),
                                                VoidPointerTy);
@@ -1222,7 +1214,7 @@ build_simple_function_definition (MLKBodyForm *processed_form,
 @implementation MLKMultipleValueListForm (MLKLLVMCompilation)
 -(Value *) reallyProcessForLLVMWithMultiValue:(Value *)multiValue
 {
-  Value *endmarker = builder.CreateIntToPtr (ConstantInt::get(Type::Int64Ty,
+  Value *endmarker = builder.CreateIntToPtr (ConstantInt::get(Int64Ty,
                                                               (uint64_t)MLKEndOfArgumentsMarker,
                                                               false),
                                              VoidPointerTy);
@@ -1233,9 +1225,9 @@ build_simple_function_definition (MLKBodyForm *processed_form,
   Value *return_value = builder.CreateAlloca (VoidPointerTy, NULL);
 
   Function *function = builder.GetInsertBlock()->getParent();
-  BasicBlock *singleValueBlock = BasicBlock::Create ("single_value_block", function);
-  BasicBlock *multipleValueBlock = BasicBlock::Create ("multiple_value_block");
-  BasicBlock *joinBlock = BasicBlock::Create ("join_block");
+  BasicBlock *singleValueBlock = BasicBlock::Create (llvm_context, "single_value_block", function);
+  BasicBlock *multipleValueBlock = BasicBlock::Create (llvm_context, "multiple_value_block");
+  BasicBlock *joinBlock = BasicBlock::Create (llvm_context, "join_block");
 
   Value *multi_tmp_content = builder.CreateLoad (multi_tmp);
   Value *isSingleValue = builder.CreateICmpEQ (multi_tmp_content, endmarker);
diff --git a/MLKLexicalContext-MLKLLVMCompilation.mm b/MLKLexicalContext-MLKLLVMCompilation.mm
index 936ada5..8f46a70 100644
--- a/MLKLexicalContext-MLKLLVMCompilation.mm
+++ b/MLKLexicalContext-MLKLLVMCompilation.mm
@@ -26,11 +26,12 @@
 #include <llvm/Constants.h>
 #include <llvm/DerivedTypes.h>
 #include <llvm/Instructions.h>
+#include <llvm/LLVMContext.h> 
 #include <llvm/Value.h>
+#include "llvm_context.h"
 using namespace llvm;
 using namespace std;
 
-
 id MLKDummyUseLLVMLexicalContext = nil;
 
 @implementation MLKLexicalContext (MLKLLVMCompilation)
@@ -57,11 +58,11 @@ id MLKDummyUseLLVMLexicalContext = nil;
 
 -(Instruction *) functionCellValueForSymbol:(id)name
 {
-  std::vector<const Type *> types (2, PointerType::get(PointerType::get(Type::Int8Ty, 0), 0));
-  return (new IntToPtrInst (ConstantInt::get(Type::Int64Ty,
+  std::vector<const Type *> types (2, PointerType::get(PointerType::get(Int8Ty, 0), 0));
+  return (new IntToPtrInst (ConstantInt::get(Int64Ty,
                                              (uint64_t)[self functionCellForSymbol:name],
                                              false),
-                            PointerType::get(PointerType::get(FunctionType::get(PointerType::get(Type::Int8Ty,
+                            PointerType::get(PointerType::get(FunctionType::get(PointerType::get(Int8Ty,
                                                                                                  0),
                                                                                 types,
                                                                                 true),
@@ -71,27 +72,27 @@ id MLKDummyUseLLVMLexicalContext = nil;
 
 -(Instruction *) closureDataPointerValueForSymbol:(id)name
 {
-  return (new IntToPtrInst (ConstantInt::get(Type::Int64Ty,
+  return (new IntToPtrInst (ConstantInt::get(Int64Ty,
                                              (uint64_t)[self closureDataPointerForSymbol:name],
                                              false),
-                            PointerType::get(PointerType::get(PointerType::get(Type::Int8Ty, 0), 0), 0)));
+                            PointerType::get(PointerType::get(PointerType::get(Int8Ty, 0), 0), 0)));
 }
 
 -(Instruction *) closureDataLengthValueForSymbol:(id)name
 {
   // The length cell isn't really a void** but an intptr_t*.
-  return (new IntToPtrInst (ConstantInt::get(Type::Int64Ty,
+  return (new IntToPtrInst (ConstantInt::get(Int64Ty,
                                              (uint64_t)[self closureDataLengthForSymbol:name],
                                              false),
-                            PointerType::get(PointerType::get(Type::Int8Ty, 0), 0)));
+                            PointerType::get(PointerType::get(Int8Ty, 0), 0)));
 }
 
 -(Instruction *) globalBindingValueForSymbol:(id)name
 {
-  return (new IntToPtrInst (ConstantInt::get(Type::Int64Ty,
+  return (new IntToPtrInst (ConstantInt::get(Int64Ty,
                                              (uint64_t)[self bindingForSymbol:name],
                                              false),
-                            PointerType::get(Type::Int8Ty, 0)));
+                            PointerType::get(Int8Ty, 0)));
 }
 
 -(Value *) bindingValueForSymbol:(id)name
diff --git a/Toilet Lisp.xcodeproj/project.pbxproj b/Toilet Lisp.xcodeproj/project.pbxproj
index 1c9ca0b..996080b 100644
--- a/Toilet Lisp.xcodeproj/project.pbxproj	
+++ b/Toilet Lisp.xcodeproj/project.pbxproj	
@@ -66,6 +66,7 @@
 		A787138E0E4EFF8A00A7191F /* ffi.lisp in CopyFiles */ = {isa = PBXBuildFile; fileRef = A787138B0E4EFF8A00A7191F /* ffi.lisp */; };
 		A787138F0E4EFF8A00A7191F /* package.lisp in CopyFiles */ = {isa = PBXBuildFile; fileRef = A787138C0E4EFF8A00A7191F /* package.lisp */; };
 		A78713900E4EFF8A00A7191F /* string.lisp in CopyFiles */ = {isa = PBXBuildFile; fileRef = A787138D0E4EFF8A00A7191F /* string.lisp */; };
+		A7900BC71419687C00FB74B8 /* llvm_context.h in Headers */ = {isa = PBXBuildFile; fileRef = A7900BC61419687C00FB74B8 /* llvm_context.h */; };
 		A7A833860E476CF3005D64E0 /* functions.m in Sources */ = {isa = PBXBuildFile; fileRef = A7A833800E476CF3005D64E0 /* functions.m */; };
 		A7A833870E476CF3005D64E0 /* MLKBackquoteReader.m in Sources */ = {isa = PBXBuildFile; fileRef = A7A833810E476CF3005D64E0 /* MLKBackquoteReader.m */; };
 		A7A833880E476CF3005D64E0 /* MLKCommaReader.m in Sources */ = {isa = PBXBuildFile; fileRef = A7A833820E476CF3005D64E0 /* MLKCommaReader.m */; };
@@ -313,6 +314,7 @@
 		A787138B0E4EFF8A00A7191F /* ffi.lisp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ffi.lisp; sourceTree = "<group>"; };
 		A787138C0E4EFF8A00A7191F /* package.lisp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = package.lisp; sourceTree = "<group>"; };
 		A787138D0E4EFF8A00A7191F /* string.lisp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = string.lisp; sourceTree = "<group>"; };
+		A7900BC61419687C00FB74B8 /* llvm_context.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = llvm_context.h; sourceTree = "<group>"; };
 		A7A833800E476CF3005D64E0 /* functions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = functions.m; sourceTree = "<group>"; };
 		A7A833810E476CF3005D64E0 /* MLKBackquoteReader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MLKBackquoteReader.m; sourceTree = "<group>"; };
 		A7A833820E476CF3005D64E0 /* MLKCommaReader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MLKCommaReader.m; sourceTree = "<group>"; };
@@ -607,6 +609,7 @@
 		A7E5C48C0E2169CE00A01D81 /* Headers */ = {
 			isa = PBXGroup;
 			children = (
+				A7900BC61419687C00FB74B8 /* llvm_context.h */,
 				A7A8628C0E6E775F00021916 /* MLKNoSuchSymbolError.h */,
 				A7A8628E0E6E776000021916 /* MLKStreamError.h */,
 				A7A862900E6E776000021916 /* MLKUnboundVariableError.h */,
@@ -743,6 +746,7 @@
 			files = (
 				A745C44E0E618B2C00C43A04 /* MLKLLVMCompiler.h in Headers */,
 				A745C44F0E618B2C00C43A04 /* MLKLexicalContext-MLKLLVMCompilation.h in Headers */,
+				A7900BC71419687C00FB74B8 /* llvm_context.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/llvm_context.h b/llvm_context.h
new file mode 100644
index 0000000..5fce54b
--- /dev/null
+++ b/llvm_context.h
@@ -0,0 +1,27 @@
+//
+//  llvm_context.h
+//  Toilet Lisp
+//
+//  Created by Matthias Benkard on 08.09.11.
+//  Copyright 2011 __MyCompanyName__. All rights reserved.
+//
+
+#ifndef Toilet_Lisp_llvm_context_h
+#define Toilet_Lisp_llvm_context_h
+
+#include <llvm/DerivedTypes.h>
+#include <llvm/LLVMContext.h> 
+#include <llvm/Support/TypeBuilder.h>
+
+LLVMContext llvm_context;
+//const Type* IntPtrTy = IntegerType::getInt32Ty(C);
+const Type* Int8Ty = IntegerType::getInt8Ty(llvm_context);
+const Type* Int16Ty = IntegerType::getInt16Ty(llvm_context);
+const Type* Int32Ty = IntegerType::getInt32Ty(llvm_context);
+const Type* Int64Ty = IntegerType::getInt64Ty(llvm_context);
+//const Type* VoidTy = TypeBuilder<void, false>::get(llvm_context);
+const Type* VoidTy = Type::getVoidTy(llvm_context);
+const PointerType* VoidPointerTy = PointerType::get(Int8Ty, 0);
+const PointerType* PointerPointerTy = PointerType::get(VoidPointerTy, 0);
+
+#endif
-- 
cgit v1.2.3