Mercurial > projects > ldc
comparison gen/toobj.c @ 74:eb379601d445 trunk
[svn r78] Removed the useless pragmas
author | lindquist |
---|---|
date | Wed, 31 Oct 2007 04:05:38 +0100 |
parents | b706170e24a9 |
children | 714057ff2dbb |
comparison
equal
deleted
inserted
replaced
73:b706170e24a9 | 74:eb379601d445 |
---|---|
589 void VarDeclaration::toObjFile() | 589 void VarDeclaration::toObjFile() |
590 { | 590 { |
591 Logger::print("VarDeclaration::toObjFile(): %s | %s\n", toChars(), type->toChars()); | 591 Logger::print("VarDeclaration::toObjFile(): %s | %s\n", toChars(), type->toChars()); |
592 LOG_SCOPE; | 592 LOG_SCOPE; |
593 llvm::Module* M = gIR->module; | 593 llvm::Module* M = gIR->module; |
594 | |
595 // handle bind pragma | |
596 if (llvmInternal == LLVMbind) { | |
597 Logger::println("var is bound: %s", llvmInternal1); | |
598 llvmValue = M->getGlobalVariable(llvmInternal1); | |
599 assert(llvmValue); | |
600 return; | |
601 } | |
602 | 594 |
603 // global variable or magic | 595 // global variable or magic |
604 if (isDataseg() || parent->isModule()) | 596 if (isDataseg() || parent->isModule()) |
605 { | 597 { |
606 if (llvmTouched) return; | 598 if (llvmTouched) return; |
794 // only members of the current module maybe be defined | 786 // only members of the current module maybe be defined |
795 if (getModule() == gIR->dmodule || parent->isTemplateInstance()) | 787 if (getModule() == gIR->dmodule || parent->isTemplateInstance()) |
796 { | 788 { |
797 llvmDModule = gIR->dmodule; | 789 llvmDModule = gIR->dmodule; |
798 | 790 |
799 bool allow_fbody = true; | |
800 // handle static constructor / destructor | 791 // handle static constructor / destructor |
801 if (isStaticCtorDeclaration() || isStaticDtorDeclaration()) { | 792 if (isStaticCtorDeclaration() || isStaticDtorDeclaration()) { |
802 const llvm::ArrayType* sctor_type = llvm::ArrayType::get(llvm::PointerType::get(functype),1); | 793 const llvm::ArrayType* sctor_type = llvm::ArrayType::get(llvm::PointerType::get(functype),1); |
803 //Logger::cout() << "static ctor type: " << *sctor_type << '\n'; | 794 //Logger::cout() << "static ctor type: " << *sctor_type << '\n'; |
804 | 795 |
805 llvm::Constant* sctor_func = llvm::cast<llvm::Constant>(llvmValue); | 796 llvm::Constant* sctor_func = llvm::cast<llvm::Constant>(llvmValue); |
806 //Logger::cout() << "static ctor func: " << *sctor_func << '\n'; | 797 //Logger::cout() << "static ctor func: " << *sctor_func << '\n'; |
807 | 798 |
808 llvm::Constant* sctor_init = 0; | 799 llvm::Constant* sctor_init = llvm::ConstantArray::get(sctor_type,&sctor_func,1); |
809 if (llvmInternal == LLVMnull) | |
810 { | |
811 llvm::Constant* sctor_init_null = llvm::Constant::getNullValue(sctor_func->getType()); | |
812 sctor_init = llvm::ConstantArray::get(sctor_type,&sctor_init_null,1); | |
813 allow_fbody = false; | |
814 } | |
815 else | |
816 { | |
817 sctor_init = llvm::ConstantArray::get(sctor_type,&sctor_func,1); | |
818 } | |
819 | 800 |
820 //Logger::cout() << "static ctor init: " << *sctor_init << '\n'; | 801 //Logger::cout() << "static ctor init: " << *sctor_init << '\n'; |
821 | 802 |
822 // output the llvm.global_ctors array | 803 // output the llvm.global_ctors array |
823 const char* varname = isStaticCtorDeclaration() ? "_d_module_ctor_array" : "_d_module_dtor_array"; | 804 const char* varname = isStaticCtorDeclaration() ? "_d_module_ctor_array" : "_d_module_dtor_array"; |
824 llvm::GlobalVariable* sctor_arr = new llvm::GlobalVariable(sctor_type, false, llvm::GlobalValue::AppendingLinkage, sctor_init, varname, gIR->module); | 805 llvm::GlobalVariable* sctor_arr = new llvm::GlobalVariable(sctor_type, false, llvm::GlobalValue::AppendingLinkage, sctor_init, varname, gIR->module); |
825 } | 806 } |
826 | 807 |
827 // function definition | 808 // function definition |
828 if (allow_fbody && fbody != 0) | 809 if (fbody != 0) |
829 { | 810 { |
830 gIR->functions.push_back(IRFunction(this)); | 811 gIR->functions.push_back(IRFunction(this)); |
831 gIR->func().func = func; | 812 gIR->func().func = func; |
832 | 813 |
833 // first make absolutely sure the type is up to date | 814 // first make absolutely sure the type is up to date |