diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-02-11 20:51:17 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-02-11 20:51:17 +0000 |
commit | 26cc89ffb1cc57313371b4175ceac56a2f975641 (patch) | |
tree | 76b87b4342a5135d5e26b1fd7940529637216d5c /lib/CodeGen/CGObjCMac.cpp | |
parent | 1bc6913e7af08bb400150ebb31a54cdfd8cde9f9 (diff) |
ir-gen for objc's @selector expression in nonfragile abi mode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64323 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGObjCMac.cpp')
-rw-r--r-- | lib/CodeGen/CGObjCMac.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index e55a6a31fe..f8d456c466 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -680,6 +680,10 @@ private: const NamedDecl *IDName, const ObjCIvarDecl *Ivar); + /// EmitSelector - Return a Value*, of type ObjCTypes.SelectorPtrTy, + /// for the given selector. + llvm::Value *EmitSelector(CGBuilderTy &Builder, Selector Sel); + public: CGObjCNonFragileABIMac(CodeGen::CodeGenModule &cgm); // FIXME. All stubs for now! @@ -705,7 +709,7 @@ public: const ObjCInterfaceDecl *ID); virtual llvm::Value *GetSelector(CGBuilderTy &Builder, Selector Sel) - { return 0; } + { return EmitSelector(Builder, Sel); } virtual void GenerateCategory(const ObjCCategoryImplDecl *CMD); @@ -4578,6 +4582,27 @@ CGObjCNonFragileABIMac::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF, ObjCSuper, ObjCTypes.SuperPtrCTy, true, CallArgs); } + +llvm::Value *CGObjCNonFragileABIMac::EmitSelector(CGBuilderTy &Builder, + Selector Sel) { + llvm::GlobalVariable *&Entry = SelectorReferences[Sel]; + + if (!Entry) { + llvm::Constant *Casted = + llvm::ConstantExpr::getBitCast(GetMethodVarName(Sel), + ObjCTypes.SelectorPtrTy); + Entry = + new llvm::GlobalVariable(ObjCTypes.SelectorPtrTy, false, + llvm::GlobalValue::InternalLinkage, + Casted, "\01L_OBJC_SELECTOR_REFERENCES_", + &CGM.getModule()); + Entry->setSection("__DATA,__objc_selrefs,literal_pointers,no_dead_strip"); + UsedGlobals.push_back(Entry); + } + + return Builder.CreateLoad(Entry, false, "tmp"); +} + /* *** */ CodeGen::CGObjCRuntime * |