From 82d94f911150e1c9df1d5a44aa52d85637227afa Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sat, 16 Aug 2008 18:44:46 +0200 Subject: %FSET, %FSETQ: Set global function bindings in a way that compiled code can understand. --- MLKLexicalContext-MLKLLVMCompilation.mm | 72 ++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 33 deletions(-) (limited to 'MLKLexicalContext-MLKLLVMCompilation.mm') diff --git a/MLKLexicalContext-MLKLLVMCompilation.mm b/MLKLexicalContext-MLKLLVMCompilation.mm index 8be1f24..2ff7ec0 100644 --- a/MLKLexicalContext-MLKLLVMCompilation.mm +++ b/MLKLexicalContext-MLKLLVMCompilation.mm @@ -22,8 +22,11 @@ #import #include -#include #include +#include +#include +#include +#include using namespace llvm; using namespace std; @@ -45,56 +48,59 @@ using namespace std; return (flag && [flag boolValue]); } --(Value *) functionCellForSymbol:(id)name +-(Value *) functionCellValueForSymbol:(id)name { - return (Value *) [[self deepPropertyForFunction:name - key:@"LLVM.function-cell"] - pointerValue]; + return (new IntToPtrInst (ConstantInt::get(Type::Int64Ty, + (uint64_t)[self functionCellForSymbol:name], + false), + PointerType::get(Type::Int8Ty, 0))); } --(Value *) closureDataPointerForSymbol:(id)name +-(Value *) closureDataPointerValueForSymbol:(id)name { - return (Value *) [[self deepPropertyForFunction:name - key:@"LLVM.closure-data-pointer"] - pointerValue]; + return (new IntToPtrInst (ConstantInt::get(Type::Int64Ty, + (uint64_t)[self closureDataPointerForSymbol:name], + false), + PointerType::get(Type::Int8Ty, 0))); } --(Value *) bindingForSymbol:(id)name +-(Value *) bindingValueForSymbol:(id)name { - return (Value *) [[self deepPropertyForVariable:name - key:@"LLVM.variable-binding"] - pointerValue]; + return (new IntToPtrInst (ConstantInt::get(Type::Int64Ty, + (uint64_t)[self bindingForSymbol:name], + false), + PointerType::get(Type::Int8Ty, 0))); } --(Value *) valueForSymbol:(id)name +-(Value *) valueValueForSymbol:(id)name { return (Value *) [[self deepPropertyForVariable:name key:@"LLVM.variable-value"] pointerValue]; } --(void) setFunctionCell:(Value *)cellPtr forSymbol:(id)name -{ - [self setDeepProperty:[NSValue valueWithPointer:cellPtr] - forFunction:name - key:@"LLVM.function-cell"]; -} +// -(void) setFunctionCellValue:(Value *)cellPtr forSymbol:(id)name +// { +// [self setDeepProperty:[NSValue valueWithPointer:cellPtr] +// forFunction:name +// key:@"LLVM.function-cell"]; +// } --(void) setClosureDataPointer:(Value *)pointer forSymbol:(id)name -{ - [self setDeepProperty:[NSValue valueWithPointer:pointer] - forFunction:name - key:@"LLVM.closure-data"]; -} +// -(void) setClosureDataPointerValue:(Value *)pointer forSymbol:(id)name +// { +// [self setDeepProperty:[NSValue valueWithPointer:pointer] +// forFunction:name +// key:@"LLVM.closure-data"]; +// } --(void) setBinding:(Value *)binding forSymbol:(id)name -{ - [self setDeepProperty:[NSValue valueWithPointer:binding] - forVariable:name - key:@"LLVM.variable-binding"]; -} +// -(void) setBindingValue:(Value *)binding forSymbol:(id)name +// { +// [self setDeepProperty:[NSValue valueWithPointer:binding] +// forVariable:name +// key:@"LLVM.variable-binding"]; +// } --(void) setValue:(Value *)value forSymbol:(id)name +-(void) setValueValue:(Value *)value forSymbol:(id)name { [self setDeepProperty:[NSValue valueWithPointer:value] forVariable:name -- cgit v1.2.3 From 66168b73736dff38b6db98d08d8a1fbe255012a8 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sat, 16 Aug 2008 18:54:51 +0200 Subject: MLKLexicalContext(MLKLLVMCompilation): Fix value types. --- MLKLexicalContext-MLKLLVMCompilation.mm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'MLKLexicalContext-MLKLLVMCompilation.mm') diff --git a/MLKLexicalContext-MLKLLVMCompilation.mm b/MLKLexicalContext-MLKLLVMCompilation.mm index 2ff7ec0..9ca18e4 100644 --- a/MLKLexicalContext-MLKLLVMCompilation.mm +++ b/MLKLexicalContext-MLKLLVMCompilation.mm @@ -50,10 +50,14 @@ using namespace std; -(Value *) functionCellValueForSymbol:(id)name { + std::vector types (1, PointerType::get(Type::Int8Ty, 0)); return (new IntToPtrInst (ConstantInt::get(Type::Int64Ty, (uint64_t)[self functionCellForSymbol:name], false), - PointerType::get(Type::Int8Ty, 0))); + PointerType::get(FunctionType::get(PointerType::get(Type::Int8Ty, 0), + types, + true), + 0))); } -(Value *) closureDataPointerValueForSymbol:(id)name @@ -61,7 +65,7 @@ using namespace std; return (new IntToPtrInst (ConstantInt::get(Type::Int64Ty, (uint64_t)[self closureDataPointerForSymbol:name], false), - PointerType::get(Type::Int8Ty, 0))); + PointerType::get(PointerType::get(Type::Int8Ty, 0), 0))); } -(Value *) bindingValueForSymbol:(id)name -- cgit v1.2.3 From a78119062f100f3da6e1243ce464c2819da64a2b Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sat, 16 Aug 2008 21:56:34 +0200 Subject: MLKLexicalContext(MLKLLVMCompilation): Further fix value types. --- MLKLexicalContext-MLKLLVMCompilation.mm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'MLKLexicalContext-MLKLLVMCompilation.mm') diff --git a/MLKLexicalContext-MLKLLVMCompilation.mm b/MLKLexicalContext-MLKLLVMCompilation.mm index 9ca18e4..744351a 100644 --- a/MLKLexicalContext-MLKLLVMCompilation.mm +++ b/MLKLexicalContext-MLKLLVMCompilation.mm @@ -48,19 +48,21 @@ using namespace std; return (flag && [flag boolValue]); } --(Value *) functionCellValueForSymbol:(id)name +-(Instruction *) functionCellValueForSymbol:(id)name { std::vector types (1, PointerType::get(Type::Int8Ty, 0)); return (new IntToPtrInst (ConstantInt::get(Type::Int64Ty, (uint64_t)[self functionCellForSymbol:name], false), - PointerType::get(FunctionType::get(PointerType::get(Type::Int8Ty, 0), - types, - true), + PointerType::get(PointerType::get(FunctionType::get(PointerType::get(Type::Int8Ty, + 0), + types, + true), + 0), 0))); } --(Value *) closureDataPointerValueForSymbol:(id)name +-(Instruction *) closureDataPointerValueForSymbol:(id)name { return (new IntToPtrInst (ConstantInt::get(Type::Int64Ty, (uint64_t)[self closureDataPointerForSymbol:name], -- cgit v1.2.3