comparison gen/runtime.cpp @ 98:6789050b5ad1 trunk

[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references. Now uses the DMD _adEq(void[], void[], TypeInfo) runtime function for array equality comparison.
author lindquist
date Wed, 14 Nov 2007 23:39:10 +0100
parents fd32135dca3e
children 1700239cab2e
comparison
equal deleted inserted replaced
97:c4e161556a21 98:6789050b5ad1
59 59
60 ////////////////////////////////////////////////////////////////////////////////////////////////// 60 //////////////////////////////////////////////////////////////////////////////////////////////////
61 61
62 llvm::Function* LLVM_D_GetRuntimeFunction(llvm::Module* target, const char* name) 62 llvm::Function* LLVM_D_GetRuntimeFunction(llvm::Module* target, const char* name)
63 { 63 {
64 // TODO maybe check the target module first, to allow overriding the runtime on a pre module basis?
65 // could be done and seems like it could be neat too :)
66
67 if (global.params.noruntime) { 64 if (global.params.noruntime) {
68 error("No implicit runtime calls allowed with -noruntime option enabled"); 65 error("No implicit runtime calls allowed with -noruntime option enabled");
69 fatal(); 66 fatal();
70 } 67 }
71 68
72 if (!M) { 69 if (!M) {
73 assert(!runtime_failed); 70 assert(!runtime_failed);
74 LLVM_D_InitRuntime(); 71 LLVM_D_InitRuntime();
75 } 72 }
76 73
77 llvm::Function* fn = M->getFunction(name); 74 llvm::Function* fn = target->getFunction(name);
75 if (fn)
76 return fn;
77
78 fn = M->getFunction(name);
78 if (!fn) { 79 if (!fn) {
79 error("Runtime function '%s' was not found", name); 80 printf("Runtime function '%s' was not found\n", name);
80 fatal(); 81 assert(0);
81 //return NULL; 82 //return NULL;
82 } 83 }
83 84
84 const llvm::FunctionType* fnty = fn->getFunctionType(); 85 const llvm::FunctionType* fnty = fn->getFunctionType();
85 return llvm::cast<llvm::Function>(target->getOrInsertFunction(name, fnty)); 86 return llvm::cast<llvm::Function>(target->getOrInsertFunction(name, fnty));