Mercurial > projects > ldc
comparison gen/tollvm.c @ 27:92408a3a2bac trunk
[svn r31] * Fixed returning through hidden pointer was unable to report back the return value
* Fixed removed some litter instructions sometimes produced by constructor calls
author | lindquist |
---|---|
date | Thu, 04 Oct 2007 11:39:53 +0200 |
parents | 25bb577878e8 |
children | 253a5fc4033a |
comparison
equal
deleted
inserted
replaced
26:99737f94abfb | 27:92408a3a2bac |
---|---|
890 | 890 |
891 ////////////////////////////////////////////////////////////////////////////////////////// | 891 ////////////////////////////////////////////////////////////////////////////////////////// |
892 | 892 |
893 llvm::Function* LLVM_DtoDeclareFunction(FuncDeclaration* fdecl) | 893 llvm::Function* LLVM_DtoDeclareFunction(FuncDeclaration* fdecl) |
894 { | 894 { |
895 // mangled name | |
896 char* mangled_name = (fdecl->llvmInternal == LLVMintrinsic) ? fdecl->llvmInternal1 : fdecl->mangle(); | |
897 | |
898 // unit test special handling | |
899 if (fdecl->isUnitTestDeclaration()) | |
900 { | |
901 assert(0 && "no unittests yet"); | |
902 /*const llvm::FunctionType* fnty = llvm::FunctionType::get(llvm::Type::VoidTy, std::vector<const llvm::Type*>(), false); | |
903 // make the function | |
904 llvm::Function* func = gIR->module->getFunction(mangled_name); | |
905 if (func == 0) | |
906 func = new llvm::Function(fnty,llvm::GlobalValue::InternalLinkage,mangled_name,gIR->module); | |
907 func->setCallingConv(llvm::CallingConv::Fast); | |
908 fdecl->llvmValue = func; | |
909 return func; | |
910 */ | |
911 } | |
912 | |
913 // regular function | |
895 TypeFunction* f = (TypeFunction*)fdecl->type; | 914 TypeFunction* f = (TypeFunction*)fdecl->type; |
896 assert(f != 0); | 915 assert(f != 0); |
897 | 916 |
898 if (fdecl->llvmValue != 0) { | 917 if (fdecl->llvmValue != 0) { |
899 if (!llvm::isa<llvm::Function>(fdecl->llvmValue)) | 918 if (!llvm::isa<llvm::Function>(fdecl->llvmValue)) |
912 fatal(); | 931 fatal(); |
913 } | 932 } |
914 | 933 |
915 // construct function | 934 // construct function |
916 const llvm::FunctionType* functype = (f->llvmType == 0) ? LLVM_DtoFunctionType(fdecl) : llvm::cast<llvm::FunctionType>(f->llvmType); | 935 const llvm::FunctionType* functype = (f->llvmType == 0) ? LLVM_DtoFunctionType(fdecl) : llvm::cast<llvm::FunctionType>(f->llvmType); |
917 | |
918 // mangled name | |
919 char* mangled_name = (fdecl->llvmInternal == LLVMintrinsic) ? fdecl->llvmInternal1 : fdecl->mangle(); | |
920 | 936 |
921 // make the function | 937 // make the function |
922 llvm::Function* func = gIR->module->getFunction(mangled_name); | 938 llvm::Function* func = gIR->module->getFunction(mangled_name); |
923 if (func == 0) { | 939 if (func == 0) { |
924 func = new llvm::Function(functype,LLVM_DtoLinkage(fdecl->protection, fdecl->storage_class),mangled_name,gIR->module); | 940 func = new llvm::Function(functype,LLVM_DtoLinkage(fdecl->protection, fdecl->storage_class),mangled_name,gIR->module); |