Mercurial > projects > ldc
comparison gen/toobj.c @ 55:0ccfae271c45 trunk
[svn r59] Added support for C-style variadic functions. Currently only works on x86, x86-64 va_arg is broken in LLVM 2.1. PPC and PPC64 unknown.
Updates to runtime. Rebuild!
author | lindquist |
---|---|
date | Wed, 24 Oct 2007 22:18:06 +0200 |
parents | 28e99b04a132 |
children | a9d29e9f1fed |
comparison
equal
deleted
inserted
replaced
54:28e99b04a132 | 55:0ccfae271c45 |
---|---|
644 if (llvmDModule) { | 644 if (llvmDModule) { |
645 assert(llvmValue != 0); | 645 assert(llvmValue != 0); |
646 return; | 646 return; |
647 } | 647 } |
648 | 648 |
649 Type* t = LLVM_DtoDType(type); | |
650 TypeFunction* f = (TypeFunction*)t; | |
651 | |
652 bool declareOnly = false; | |
653 if (TemplateInstance* tinst = parent->isTemplateInstance()) { | |
654 TemplateDeclaration* tempdecl = tinst->tempdecl; | |
655 if (tempdecl->llvmInternal == LLVMva_start) | |
656 { | |
657 Logger::println("magic va_start found"); | |
658 llvmInternal = LLVMva_start; | |
659 declareOnly = true; | |
660 } | |
661 else if (tempdecl->llvmInternal == LLVMva_arg) | |
662 { | |
663 Logger::println("magic va_arg found"); | |
664 llvmInternal = LLVMva_arg; | |
665 return; | |
666 } | |
667 } | |
668 | |
649 llvm::Function* func = LLVM_DtoDeclareFunction(this); | 669 llvm::Function* func = LLVM_DtoDeclareFunction(this); |
670 | |
671 if (declareOnly) | |
672 return; | |
650 | 673 |
651 if (!gIR->structs.empty() && gIR->topstruct().queueFuncs) { | 674 if (!gIR->structs.empty() && gIR->topstruct().queueFuncs) { |
652 if (!llvmQueued) { | 675 if (!llvmQueued) { |
653 Logger::println("queueing %s", toChars()); | 676 Logger::println("queueing %s", toChars()); |
654 gIR->topstruct().funcs.push_back(this); | 677 gIR->topstruct().funcs.push_back(this); |
655 llvmQueued = true; | 678 llvmQueued = true; |
656 } | 679 } |
657 return; // we wait with the definition as they might invoke a virtual method and the vtable is not yet complete | 680 return; // we wait with the definition as they might invoke a virtual method and the vtable is not yet complete |
658 } | 681 } |
659 | 682 |
660 Type* t = LLVM_DtoDType(type); | |
661 TypeFunction* f = (TypeFunction*)t; | |
662 assert(f->llvmType); | 683 assert(f->llvmType); |
663 const llvm::FunctionType* functype = llvm::cast<llvm::FunctionType>(llvmValue->getType()->getContainedType(0)); | 684 const llvm::FunctionType* functype = llvm::cast<llvm::FunctionType>(llvmValue->getType()->getContainedType(0)); |
664 | 685 |
665 // only members of the current module maybe be defined | 686 // only members of the current module maybe be defined |
666 if (getModule() == gIR->dmodule || parent->isTemplateInstance()) | 687 if (getModule() == gIR->dmodule || parent->isTemplateInstance()) |