diff options
author | Chris Lattner <sabre@nondot.org> | 2009-04-22 02:32:31 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-04-22 02:32:31 +0000 |
commit | 4176b0c632b166548f5d0437efff10a748cd62c4 (patch) | |
tree | 13efc2fe8fdd63725e65e59a399f1d8fc76012b0 /lib/CodeGen | |
parent | 34b02a11576fd6123a703102fc0405a5bb29f6a9 (diff) |
make message send functions lazy, we're down from 14 non-lazy functions to 9.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69764 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/CGObjCMac.cpp | 129 |
1 files changed, 65 insertions, 64 deletions
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 323b5c9f54..97410cb213 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -134,9 +134,68 @@ public: class ObjCTypesHelper : public ObjCCommonTypesHelper { private: - llvm::Constant *MessageSendFn, *MessageSendStretFn, *MessageSendFpretFn; - llvm::Constant *MessageSendSuperFn, *MessageSendSuperStretFn, - *MessageSendSuperFpretFn; + llvm::Constant *getMessageSendFn() { + // id objc_msgSend (id, SEL, ...) + std::vector<const llvm::Type*> Params; + Params.push_back(ObjectPtrTy); + Params.push_back(SelectorPtrTy); + return + CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy, + Params, true), + "objc_msgSend"); + } + + llvm::Constant *getMessageSendStretFn() { + // id objc_msgSend_stret (id, SEL, ...) + std::vector<const llvm::Type*> Params; + Params.push_back(ObjectPtrTy); + Params.push_back(SelectorPtrTy); + return + CGM.CreateRuntimeFunction(llvm::FunctionType::get(llvm::Type::VoidTy, + Params, true), + "objc_msgSend_stret"); + + } + + llvm::Constant *getMessageSendFpretFn() { + // FIXME: This should be long double on x86_64? + // [double | long double] objc_msgSend_fpret(id self, SEL op, ...) + std::vector<const llvm::Type*> Params; + Params.push_back(ObjectPtrTy); + Params.push_back(SelectorPtrTy); + return + CGM.CreateRuntimeFunction(llvm::FunctionType::get(llvm::Type::DoubleTy, + Params, + true), + "objc_msgSend_fpret"); + + } + + llvm::Constant *getMessageSendSuperFn() { + // id objc_msgSendSuper(struct objc_super *super, SEL op, ...) + std::vector<const llvm::Type*> Params; + Params.push_back(SuperPtrTy); + Params.push_back(SelectorPtrTy); + return CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy, + Params, true), + "objc_msgSendSuper"); + } + llvm::Constant *getMessageSendSuperStretFn() { + // void objc_msgSendSuper_stret(void * stretAddr, struct objc_super *super, + // SEL op, ...) + std::vector<const llvm::Type*> Params; + Params.push_back(Int8PtrTy); + Params.push_back(SuperPtrTy); + Params.push_back(SelectorPtrTy); + return CGM.CreateRuntimeFunction(llvm::FunctionType::get(llvm::Type::VoidTy, + Params, true), + "objc_msgSendSuper_stret"); + } + + llvm::Constant *getMessageSendSuperFpretFn() { + // There is no objc_msgSendSuper_fpret? How can that work? + return getMessageSendSuperFn(); + } public: /// SymtabTy - LLVM type for struct objc_symtab. @@ -249,15 +308,15 @@ public: llvm::Constant *getSendFn(bool IsSuper) { - return IsSuper ? MessageSendSuperFn : MessageSendFn; + return IsSuper ? getMessageSendSuperFn() : getMessageSendFn(); } llvm::Constant *getSendStretFn(bool IsSuper) { - return IsSuper ? MessageSendSuperStretFn : MessageSendStretFn; + return IsSuper ? getMessageSendSuperStretFn() : getMessageSendStretFn(); } llvm::Constant *getSendFpretFn(bool IsSuper) { - return IsSuper ? MessageSendSuperFpretFn : MessageSendFpretFn; + return IsSuper ? getMessageSendSuperFpretFn() : getMessageSendFpretFn(); } }; @@ -3589,64 +3648,6 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) NULL); CGM.getModule().addTypeName("struct._objc_module", ModuleTy); - // Message send functions. - - // id objc_msgSend (id, SEL, ...) - std::vector<const llvm::Type*> Params; - Params.push_back(ObjectPtrTy); - Params.push_back(SelectorPtrTy); - MessageSendFn = - CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy, - Params, - true), - "objc_msgSend"); - - // id objc_msgSend_stret (id, SEL, ...) - Params.clear(); - Params.push_back(ObjectPtrTy); - Params.push_back(SelectorPtrTy); - MessageSendStretFn = - CGM.CreateRuntimeFunction(llvm::FunctionType::get(llvm::Type::VoidTy, - Params, - true), - "objc_msgSend_stret"); - - // - Params.clear(); - Params.push_back(ObjectPtrTy); - Params.push_back(SelectorPtrTy); - // FIXME: This should be long double on x86_64? - // [double | long double] objc_msgSend_fpret(id self, SEL op, ...) - MessageSendFpretFn = - CGM.CreateRuntimeFunction(llvm::FunctionType::get(llvm::Type::DoubleTy, - Params, - true), - "objc_msgSend_fpret"); - - // id objc_msgSendSuper(struct objc_super *super, SEL op, ...) - Params.clear(); - Params.push_back(SuperPtrTy); - Params.push_back(SelectorPtrTy); - MessageSendSuperFn = - CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy, - Params, - true), - "objc_msgSendSuper"); - - // void objc_msgSendSuper_stret(void * stretAddr, struct objc_super *super, - // SEL op, ...) - Params.clear(); - Params.push_back(Int8PtrTy); - Params.push_back(SuperPtrTy); - Params.push_back(SelectorPtrTy); - MessageSendSuperStretFn = - CGM.CreateRuntimeFunction(llvm::FunctionType::get(llvm::Type::VoidTy, - Params, - true), - "objc_msgSendSuper_stret"); - - // There is no objc_msgSendSuper_fpret? How can that work? - MessageSendSuperFpretFn = MessageSendSuperFn; // FIXME: This is the size of the setjmp buffer and should be // target specific. 18 is what's used on 32-bit X86. |