1c17a4d3b16a2624a76de5d7508805534545bd3bfDaniel Dunbar//===----- CGObjCRuntime.h - Interface to ObjC Runtimes ---------*- C++ -*-===// 20f984268b05edab2cc555a427c441baa9c252658Chris Lattner// 30f984268b05edab2cc555a427c441baa9c252658Chris Lattner// The LLVM Compiler Infrastructure 40f984268b05edab2cc555a427c441baa9c252658Chris Lattner// 50f984268b05edab2cc555a427c441baa9c252658Chris Lattner// This file is distributed under the University of Illinois Open Source 60f984268b05edab2cc555a427c441baa9c252658Chris Lattner// License. See LICENSE.TXT for details. 70f984268b05edab2cc555a427c441baa9c252658Chris Lattner// 80f984268b05edab2cc555a427c441baa9c252658Chris Lattner//===----------------------------------------------------------------------===// 90f984268b05edab2cc555a427c441baa9c252658Chris Lattner// 100f984268b05edab2cc555a427c441baa9c252658Chris Lattner// This provides an abstract class for Objective-C code generation. Concrete 110f984268b05edab2cc555a427c441baa9c252658Chris Lattner// subclasses of this implement code generation for specific Objective-C 120f984268b05edab2cc555a427c441baa9c252658Chris Lattner// runtime libraries. 130f984268b05edab2cc555a427c441baa9c252658Chris Lattner// 140f984268b05edab2cc555a427c441baa9c252658Chris Lattner//===----------------------------------------------------------------------===// 150f984268b05edab2cc555a427c441baa9c252658Chris Lattner 16176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines#ifndef LLVM_CLANG_LIB_CODEGEN_CGOBJCRUNTIME_H 17176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines#define LLVM_CLANG_LIB_CODEGEN_CGOBJCRUNTIME_H 1845d196b8387dcefc4df26cda114fa34c6528e928Daniel Dunbar#include "CGBuilder.h" 1946f45b9bec4a265ad8400a538e5ec3a5683617f1Daniel Dunbar#include "CGCall.h" 2045d196b8387dcefc4df26cda114fa34c6528e928Daniel Dunbar#include "CGValue.h" 2155fc873017f10f6f566b182b70f6fc22aefa3464Chandler Carruth#include "clang/AST/DeclObjC.h" 2255fc873017f10f6f566b182b70f6fc22aefa3464Chandler Carruth#include "clang/Basic/IdentifierTable.h" // Selector 238f2926b73ed635afecd020da787af6a837601a2bDaniel Dunbar 240f984268b05edab2cc555a427c441baa9c252658Chris Lattnernamespace llvm { 250f984268b05edab2cc555a427c441baa9c252658Chris Lattner class Constant; 269777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar class Function; 279777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar class Module; 289777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar class StructLayout; 2984ad77a8f83121713ea69d8002d1fd19565f87abDaniel Dunbar class StructType; 300f984268b05edab2cc555a427c441baa9c252658Chris Lattner class Type; 310f984268b05edab2cc555a427c441baa9c252658Chris Lattner class Value; 320f984268b05edab2cc555a427c441baa9c252658Chris Lattner} 330f984268b05edab2cc555a427c441baa9c252658Chris Lattner 340f984268b05edab2cc555a427c441baa9c252658Chris Lattnernamespace clang { 3546f45b9bec4a265ad8400a538e5ec3a5683617f1Daniel Dunbarnamespace CodeGen { 3646f45b9bec4a265ad8400a538e5ec3a5683617f1Daniel Dunbar class CodeGenFunction; 3746f45b9bec4a265ad8400a538e5ec3a5683617f1Daniel Dunbar} 388f2926b73ed635afecd020da787af6a837601a2bDaniel Dunbar 399777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar class FieldDecl; 4064d5d6c5903157c521af496479d06dc26032d718Anders Carlsson class ObjCAtTryStmt; 4164d5d6c5903157c521af496479d06dc26032d718Anders Carlsson class ObjCAtThrowStmt; 4210cac6f7115b59a466bb8d2d51cdddeb38aadc37Chris Lattner class ObjCAtSynchronizedStmt; 43679a502d462ef819e6175b58e255ca3f3391e7cfFariborz Jahanian class ObjCContainerDecl; 447ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar class ObjCCategoryImplDecl; 457ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar class ObjCImplementationDecl; 46ddb2a3d55a24a1dbdf9152621642d9a4b4fc2f61Daniel Dunbar class ObjCInterfaceDecl; 478f2926b73ed635afecd020da787af6a837601a2bDaniel Dunbar class ObjCMessageExpr; 487ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar class ObjCMethodDecl; 49af2f62ce32e462f256855cd24b06dec4755d2827Daniel Dunbar class ObjCProtocolDecl; 508e67b63530b4f39a48bc12d97376f373a6901279Chris Lattner class Selector; 510bb20361a321593887f067515dd04cf109f4c74aFariborz Jahanian class ObjCIvarDecl; 5233fdb738a6c125f4c788733897021b7c1a062b0cSteve Naroff class ObjCStringLiteral; 5389ecd41e0a6bfb3b0913dbe41c3c666340b308c7Fariborz Jahanian class BlockDeclRefExpr; 54af2f62ce32e462f256855cd24b06dec4755d2827Daniel Dunbar 550f984268b05edab2cc555a427c441baa9c252658Chris Lattnernamespace CodeGen { 56dce1406f1c1f572cfd61c494546572d63461c741Chris Lattner class CodeGenModule; 576b5a61b6dc400027fd793dcadceeb9da944a37eaJohn McCall class CGBlockInfo; 580f984268b05edab2cc555a427c441baa9c252658Chris Lattner 59f5408fe484495ee4efbdd709c8a2c2fdbbbdb328Mike Stump// FIXME: Several methods should be pure virtual but aren't to avoid the 60f5408fe484495ee4efbdd709c8a2c2fdbbbdb328Mike Stump// partially-implemented subclass breaking. 6120ff3108fcd2c3bd734dc79efc22ebaa090abd41Anton Korobeynikov 6220ff3108fcd2c3bd734dc79efc22ebaa090abd41Anton Korobeynikov/// Implements runtime-specific code generation functions. 630f984268b05edab2cc555a427c441baa9c252658Chris Lattnerclass CGObjCRuntime { 64f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbarprotected: 65de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall CodeGen::CodeGenModule &CGM; 66de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall CGObjCRuntime(CodeGen::CodeGenModule &CGM) : CGM(CGM) {} 67de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall 689777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar // Utility functions for unified ivar access. These need to 699777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar // eventually be folded into other places (the structure layout 709777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar // code). 719777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar 7284ad77a8f83121713ea69d8002d1fd19565f87abDaniel Dunbar /// Compute an offset to the given ivar, suitable for passing to 7384ad77a8f83121713ea69d8002d1fd19565f87abDaniel Dunbar /// EmitValueForIvarAtOffset. Note that the correct handling of 7484ad77a8f83121713ea69d8002d1fd19565f87abDaniel Dunbar /// bit-fields is carefully coordinated by these two, use caution! 759f89f2bc111339ee7fa0df3c2f18e39493b460c4Daniel Dunbar /// 769f89f2bc111339ee7fa0df3c2f18e39493b460c4Daniel Dunbar /// The latter overload is suitable for computing the offset of a 779f89f2bc111339ee7fa0df3c2f18e39493b460c4Daniel Dunbar /// sythesized ivar. 78e5b4666d9b86ea30b90b599691e75d380f84ddd6Eli Friedman uint64_t ComputeIvarBaseOffset(CodeGen::CodeGenModule &CGM, 79e5b4666d9b86ea30b90b599691e75d380f84ddd6Eli Friedman const ObjCInterfaceDecl *OID, 80e5b4666d9b86ea30b90b599691e75d380f84ddd6Eli Friedman const ObjCIvarDecl *Ivar); 81e5b4666d9b86ea30b90b599691e75d380f84ddd6Eli Friedman uint64_t ComputeIvarBaseOffset(CodeGen::CodeGenModule &CGM, 82e5b4666d9b86ea30b90b599691e75d380f84ddd6Eli Friedman const ObjCImplementationDecl *OID, 83e5b4666d9b86ea30b90b599691e75d380f84ddd6Eli Friedman const ObjCIvarDecl *Ivar); 849777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar 859777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar LValue EmitValueForIvarAtOffset(CodeGen::CodeGenFunction &CGF, 869777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar const ObjCInterfaceDecl *OID, 879777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar llvm::Value *BaseValue, 889777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar const ObjCIvarDecl *Ivar, 899777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar unsigned CVRQualifiers, 901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump llvm::Value *Offset); 919735ca6e01113aec6a825dd5b1cb1b98fb377d31David Chisnall /// Emits a try / catch statement. This function is intended to be called by 929735ca6e01113aec6a825dd5b1cb1b98fb377d31David Chisnall /// subclasses, and provides a generic mechanism for generating these, which 932ee5ba35febf830d366b65dd0dcbf8e291c41342James Dennett /// should be usable by all runtimes. The caller must provide the functions 942ee5ba35febf830d366b65dd0dcbf8e291c41342James Dennett /// to call when entering and exiting a \@catch() block, and the function 952ee5ba35febf830d366b65dd0dcbf8e291c41342James Dennett /// used to rethrow exceptions. If the begin and end catch functions are 962ee5ba35febf830d366b65dd0dcbf8e291c41342James Dennett /// NULL, then the function assumes that the EH personality function provides 972ee5ba35febf830d366b65dd0dcbf8e291c41342James Dennett /// the thrown object directly. 989735ca6e01113aec6a825dd5b1cb1b98fb377d31David Chisnall void EmitTryCatchStmt(CodeGenFunction &CGF, 999735ca6e01113aec6a825dd5b1cb1b98fb377d31David Chisnall const ObjCAtTryStmt &S, 100789ecdebd04aebdb2d6b801ebe8e04a189ebc023David Chisnall llvm::Constant *beginCatchFn, 101789ecdebd04aebdb2d6b801ebe8e04a189ebc023David Chisnall llvm::Constant *endCatchFn, 102789ecdebd04aebdb2d6b801ebe8e04a189ebc023David Chisnall llvm::Constant *exceptionRethrowFn); 103a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar 104a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar void EmitInitOfCatchParam(CodeGenFunction &CGF, llvm::Value *exn, 105a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar const VarDecl *paramDecl); 106a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar 1072ee5ba35febf830d366b65dd0dcbf8e291c41342James Dennett /// Emits an \@synchronize() statement, using the \p syncEnterFn and 1082ee5ba35febf830d366b65dd0dcbf8e291c41342James Dennett /// \p syncExitFn arguments as the functions called to lock and unlock 1092ee5ba35febf830d366b65dd0dcbf8e291c41342James Dennett /// the object. This function can be called by subclasses that use 1102ee5ba35febf830d366b65dd0dcbf8e291c41342James Dennett /// zero-cost exception handling. 1119735ca6e01113aec6a825dd5b1cb1b98fb377d31David Chisnall void EmitAtSynchronizedStmt(CodeGenFunction &CGF, 1129735ca6e01113aec6a825dd5b1cb1b98fb377d31David Chisnall const ObjCAtSynchronizedStmt &S, 1139735ca6e01113aec6a825dd5b1cb1b98fb377d31David Chisnall llvm::Function *syncEnterFn, 1149735ca6e01113aec6a825dd5b1cb1b98fb377d31David Chisnall llvm::Function *syncExitFn); 11558bf6101062867ca4b3028f9e77e4ae642f09b44Daniel Dunbar 1160f984268b05edab2cc555a427c441baa9c252658Chris Lattnerpublic: 1170f984268b05edab2cc555a427c441baa9c252658Chris Lattner virtual ~CGObjCRuntime(); 118af2f62ce32e462f256855cd24b06dec4755d2827Daniel Dunbar 119391d77a26382dddf25da73e29fc1fa5aaaea4c6fChris Lattner /// Generate the function required to register all Objective-C components in 120391d77a26382dddf25da73e29fc1fa5aaaea4c6fChris Lattner /// this compilation unit with the runtime library. 1217ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar virtual llvm::Function *ModuleInitFunction() = 0; 122af2f62ce32e462f256855cd24b06dec4755d2827Daniel Dunbar 123a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar /// Get a selector for the specified name and type values. 124a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar /// The result should have the LLVM type for ASTContext::getObjCSelType(). 125a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar virtual llvm::Value *GetSelector(CodeGenFunction &CGF, Selector Sel) = 0; 126a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar 127a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar /// Get the address of a selector for the specified name and type values. 128a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar /// This is a rarely-used language extension, but sadly it exists. 129a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar /// 130a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar /// The result should have the LLVM type for a pointer to 1317ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar /// ASTContext::getObjCSelType(). 132a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar virtual Address GetAddrOfSelector(CodeGenFunction &CGF, Selector Sel) = 0; 133af2f62ce32e462f256855cd24b06dec4755d2827Daniel Dunbar 1341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// Get a typed selector. 135bd7370a78604e9a20d698bfe328c1e43f12a0613John McCall virtual llvm::Value *GetSelector(CodeGenFunction &CGF, 136df9ccc6381314ccca6407abb209155e9273a631dFariborz Jahanian const ObjCMethodDecl *Method) = 0; 137df9ccc6381314ccca6407abb209155e9273a631dFariborz Jahanian 1385a180397870944548aaadeaebf58e415885b9489John McCall /// Get the type constant to catch for the given ObjC pointer type. 1395a180397870944548aaadeaebf58e415885b9489John McCall /// This is used externally to implement catching ObjC types in C++. 1405a180397870944548aaadeaebf58e415885b9489John McCall /// Runtimes which don't support this should add the appropriate 1415a180397870944548aaadeaebf58e415885b9489John McCall /// error to Sema. 142cf5abc7ba032bd35158e4d75b0bc92a482fc67e8Fariborz Jahanian virtual llvm::Constant *GetEHType(QualType T) = 0; 1435a180397870944548aaadeaebf58e415885b9489John McCall 1447ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar /// Generate a constant string object. 145a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar virtual ConstantAddress GenerateConstantString(const StringLiteral *) = 0; 146ebcb57a8d298862c65043e88b2429591ab3c58d3Ted Kremenek 14720ff3108fcd2c3bd734dc79efc22ebaa090abd41Anton Korobeynikov /// Generate a category. A category contains a list of methods (and 14820ff3108fcd2c3bd734dc79efc22ebaa090abd41Anton Korobeynikov /// accompanying metadata) and a list of protocols. 1497ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar virtual void GenerateCategory(const ObjCCategoryImplDecl *OCD) = 0; 150af2f62ce32e462f256855cd24b06dec4755d2827Daniel Dunbar 151fc8f0e14ad142ed811e90fbd9a30e419e301c717Chris Lattner /// Generate a class structure for this class. 1527ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar virtual void GenerateClass(const ObjCImplementationDecl *OID) = 0; 1531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 15429254f4dd114fe2dd5c4e7a261ebea941973ad3dDavid Chisnall /// Register an class alias. 15529254f4dd114fe2dd5c4e7a261ebea941973ad3dDavid Chisnall virtual void RegisterAlias(const ObjCCompatibleAliasDecl *OAD) = 0; 15629254f4dd114fe2dd5c4e7a261ebea941973ad3dDavid Chisnall 1571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// Generate an Objective-C message send operation. 158d6c93d703541c992e06eb9a59a2d826a30da65b2Daniel Dunbar /// 159d6c93d703541c992e06eb9a59a2d826a30da65b2Daniel Dunbar /// \param Method - The method being called, this may be null if synthesizing 160d6c93d703541c992e06eb9a59a2d826a30da65b2Daniel Dunbar /// a property setter or getter. 1611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump virtual CodeGen::RValue 1628f2926b73ed635afecd020da787af6a837601a2bDaniel Dunbar GenerateMessageSend(CodeGen::CodeGenFunction &CGF, 163ef072fd2f3347cfd857d6eb787b245b950771430John McCall ReturnValueSlot ReturnSlot, 1647f8ea5c5b3a6a4332a841eefdd86b0726722ea7bDaniel Dunbar QualType ResultType, 1657f8ea5c5b3a6a4332a841eefdd86b0726722ea7bDaniel Dunbar Selector Sel, 166f56f1913e91ad32bed52dd3f6afc26735d336584Daniel Dunbar llvm::Value *Receiver, 167df9ccc6381314ccca6407abb209155e9273a631dFariborz Jahanian const CallArgList &CallArgs, 1686bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines const ObjCInterfaceDecl *Class = nullptr, 1696bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines const ObjCMethodDecl *Method = nullptr) = 0; 170af2f62ce32e462f256855cd24b06dec4755d2827Daniel Dunbar 1717ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar /// Generate an Objective-C message send operation to the super 172f56f1913e91ad32bed52dd3f6afc26735d336584Daniel Dunbar /// class initiated in a method for Class and with the given Self 173f56f1913e91ad32bed52dd3f6afc26735d336584Daniel Dunbar /// object. 174d6c93d703541c992e06eb9a59a2d826a30da65b2Daniel Dunbar /// 175d6c93d703541c992e06eb9a59a2d826a30da65b2Daniel Dunbar /// \param Method - The method being called, this may be null if synthesizing 176d6c93d703541c992e06eb9a59a2d826a30da65b2Daniel Dunbar /// a property setter or getter. 1778f2926b73ed635afecd020da787af6a837601a2bDaniel Dunbar virtual CodeGen::RValue 1788f2926b73ed635afecd020da787af6a837601a2bDaniel Dunbar GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF, 179ef072fd2f3347cfd857d6eb787b245b950771430John McCall ReturnValueSlot ReturnSlot, 1807f8ea5c5b3a6a4332a841eefdd86b0726722ea7bDaniel Dunbar QualType ResultType, 1817f8ea5c5b3a6a4332a841eefdd86b0726722ea7bDaniel Dunbar Selector Sel, 182f56f1913e91ad32bed52dd3f6afc26735d336584Daniel Dunbar const ObjCInterfaceDecl *Class, 1837ce77920a35060f1c8dd72e541e42ce296ccd168Fariborz Jahanian bool isCategoryImpl, 184f56f1913e91ad32bed52dd3f6afc26735d336584Daniel Dunbar llvm::Value *Self, 18519cd87eb5fb3c197e631ce08fd52c446c4d4e8f1Daniel Dunbar bool IsClassMessage, 186d6c93d703541c992e06eb9a59a2d826a30da65b2Daniel Dunbar const CallArgList &CallArgs, 1876bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines const ObjCMethodDecl *Method = nullptr) = 0; 18898c5ead87d720d8b68b6f236c3c3579a388fc882Daniel Dunbar 18998c5ead87d720d8b68b6f236c3c3579a388fc882Daniel Dunbar /// Emit the code to return the named protocol as an object, as in a 19017d26a6c1f2cb921d0000c337b4967699dc928fdJames Dennett /// \@protocol expression. 191bd7370a78604e9a20d698bfe328c1e43f12a0613John McCall virtual llvm::Value *GenerateProtocolRef(CodeGenFunction &CGF, 1927ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar const ObjCProtocolDecl *OPD) = 0; 19398c5ead87d720d8b68b6f236c3c3579a388fc882Daniel Dunbar 1941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// Generate the named protocol. Protocols contain method metadata but no 1951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// implementations. 1967ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar virtual void GenerateProtocol(const ObjCProtocolDecl *OPD) = 0; 1977ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar 1987ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar /// Generate a function preamble for a method with the specified 1991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// types. 2007ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar 201f5408fe484495ee4efbdd709c8a2c2fdbbbdb328Mike Stump // FIXME: Current this just generates the Function definition, but really this 202f5408fe484495ee4efbdd709c8a2c2fdbbbdb328Mike Stump // should also be generating the loads of the parameters, as the runtime 203f5408fe484495ee4efbdd709c8a2c2fdbbbdb328Mike Stump // should have full control over how parameters are passed. 2041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump virtual llvm::Function *GenerateMethod(const ObjCMethodDecl *OMD, 205679a502d462ef819e6175b58e255ca3f3391e7cfFariborz Jahanian const ObjCContainerDecl *CD) = 0; 206af2f62ce32e462f256855cd24b06dec4755d2827Daniel Dunbar 20749f6602707887eea1a558a1dffe0213102f887f2Daniel Dunbar /// Return the runtime function for getting properties. 20874391b48b4791cded373683a3baf67314f358d50Chris Lattner virtual llvm::Constant *GetPropertyGetFunction() = 0; 2091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 21049f6602707887eea1a558a1dffe0213102f887f2Daniel Dunbar /// Return the runtime function for setting properties. 21174391b48b4791cded373683a3baf67314f358d50Chris Lattner virtual llvm::Constant *GetPropertySetFunction() = 0; 21249f6602707887eea1a558a1dffe0213102f887f2Daniel Dunbar 213ebcb57a8d298862c65043e88b2429591ab3c58d3Ted Kremenek /// Return the runtime function for optimized setting properties. 214ebcb57a8d298862c65043e88b2429591ab3c58d3Ted Kremenek virtual llvm::Constant *GetOptimizedPropertySetFunction(bool atomic, 215ebcb57a8d298862c65043e88b2429591ab3c58d3Ted Kremenek bool copy) = 0; 216ebcb57a8d298862c65043e88b2429591ab3c58d3Ted Kremenek 2178fac25d33b13e25f512dd921d4d5a4b565f5d175David Chisnall // API for atomic copying of qualified aggregates in getter. 2188fac25d33b13e25f512dd921d4d5a4b565f5d175David Chisnall virtual llvm::Constant *GetGetStructFunction() = 0; 2198fac25d33b13e25f512dd921d4d5a4b565f5d175David Chisnall // API for atomic copying of qualified aggregates in setter. 2208fac25d33b13e25f512dd921d4d5a4b565f5d175David Chisnall virtual llvm::Constant *GetSetStructFunction() = 0; 221d397cfef01d49a41554309d67ea26340c39e1e94David Chisnall /// API for atomic copying of qualified aggregates with non-trivial copy 222d397cfef01d49a41554309d67ea26340c39e1e94David Chisnall /// assignment (c++) in setter. 223d397cfef01d49a41554309d67ea26340c39e1e94David Chisnall virtual llvm::Constant *GetCppAtomicObjectSetFunction() = 0; 224d397cfef01d49a41554309d67ea26340c39e1e94David Chisnall /// API for atomic copying of qualified aggregates with non-trivial copy 225d397cfef01d49a41554309d67ea26340c39e1e94David Chisnall /// assignment (c++) in getter. 226d397cfef01d49a41554309d67ea26340c39e1e94David Chisnall virtual llvm::Constant *GetCppAtomicObjectGetFunction() = 0; 2276cc590602f41c3e98e8af0023d54296c8eca7910Fariborz Jahanian 228ddb2a3d55a24a1dbdf9152621642d9a4b4fc2f61Daniel Dunbar /// GetClass - Return a reference to the class for the given 229ddb2a3d55a24a1dbdf9152621642d9a4b4fc2f61Daniel Dunbar /// interface decl. 230bd7370a78604e9a20d698bfe328c1e43f12a0613John McCall virtual llvm::Value *GetClass(CodeGenFunction &CGF, 231ddb2a3d55a24a1dbdf9152621642d9a4b4fc2f61Daniel Dunbar const ObjCInterfaceDecl *OID) = 0; 232f85e193739c953358c865005855253af4f68a497John McCall 233f85e193739c953358c865005855253af4f68a497John McCall 234bd7370a78604e9a20d698bfe328c1e43f12a0613John McCall virtual llvm::Value *EmitNSAutoreleasePoolClassRef(CodeGenFunction &CGF) { 235b219cfc4d75f0a03630b7c4509ef791b7e97b2c8David Blaikie llvm_unreachable("autoreleasepool unsupported in this ABI"); 236f85e193739c953358c865005855253af4f68a497John McCall } 237f85e193739c953358c865005855253af4f68a497John McCall 2382abd89c039e835e84519a4cd8a7495899a70153dAnders Carlsson /// EnumerationMutationFunction - Return the function that's called by the 2392abd89c039e835e84519a4cd8a7495899a70153dAnders Carlsson /// compiler when a mutation is detected during foreach iteration. 24074391b48b4791cded373683a3baf67314f358d50Chris Lattner virtual llvm::Constant *EnumerationMutationFunction() = 0; 2411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 242f1549f66a8216a78112286e3978cea2c29d6334cJohn McCall virtual void EmitSynchronizedStmt(CodeGen::CodeGenFunction &CGF, 243f1549f66a8216a78112286e3978cea2c29d6334cJohn McCall const ObjCAtSynchronizedStmt &S) = 0; 244f1549f66a8216a78112286e3978cea2c29d6334cJohn McCall virtual void EmitTryStmt(CodeGen::CodeGenFunction &CGF, 245f1549f66a8216a78112286e3978cea2c29d6334cJohn McCall const ObjCAtTryStmt &S) = 0; 24664d5d6c5903157c521af496479d06dc26032d718Anders Carlsson virtual void EmitThrowStmt(CodeGen::CodeGenFunction &CGF, 2476a3c70ec59804347c99e96aa13934f63f4fed573Fariborz Jahanian const ObjCAtThrowStmt &S, 2486a3c70ec59804347c99e96aa13934f63f4fed573Fariborz Jahanian bool ClearInsertionPoint=true) = 0; 2496bf2ae05c777052e5ec05649710380dea263e7e0Daniel Dunbar virtual llvm::Value *EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF, 250a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar Address AddrWeakObj) = 0; 2513e283e344595e0bd499b13b30a92b7d9c10a2140Fariborz Jahanian virtual void EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF, 252a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar llvm::Value *src, Address dest) = 0; 25358626500527695865683d1d65053743de8770b60Fariborz Jahanian virtual void EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF, 254a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar llvm::Value *src, Address dest, 255021a7a63984f0f912dc9e9dae2a1b3e1509a40ceFariborz Jahanian bool threadlocal=false) = 0; 2567eda8367cf63caee8acf907356b1d199ccaa6e89Fariborz Jahanian virtual void EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF, 257a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar llvm::Value *src, Address dest, 2586c7a1f364796ce1acb988714e9e42076d1ce332eFariborz Jahanian llvm::Value *ivarOffset) = 0; 25958626500527695865683d1d65053743de8770b60Fariborz Jahanian virtual void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF, 260a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar llvm::Value *src, Address dest) = 0; 2611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 262598d3f61b6ca854e9d3c2f3359e24468502a61aaFariborz Jahanian virtual LValue EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF, 263598d3f61b6ca854e9d3c2f3359e24468502a61aaFariborz Jahanian QualType ObjectTy, 264598d3f61b6ca854e9d3c2f3359e24468502a61aaFariborz Jahanian llvm::Value *BaseValue, 265598d3f61b6ca854e9d3c2f3359e24468502a61aaFariborz Jahanian const ObjCIvarDecl *Ivar, 266598d3f61b6ca854e9d3c2f3359e24468502a61aaFariborz Jahanian unsigned CVRQualifiers) = 0; 267f63aa3fd429cdb9145d78f0b656bc78754efedb9Fariborz Jahanian virtual llvm::Value *EmitIvarOffset(CodeGen::CodeGenFunction &CGF, 2682a03192a02dbf4fdff438d1e658356bde871aba4Daniel Dunbar const ObjCInterfaceDecl *Interface, 269f63aa3fd429cdb9145d78f0b656bc78754efedb9Fariborz Jahanian const ObjCIvarDecl *Ivar) = 0; 270082b02e8403d3ee9d2ded969fbe0e5d472f04cd8Fariborz Jahanian virtual void EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF, 271a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar Address DestPtr, 272a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar Address SrcPtr, 27355bcace250e1ff366e4482714b344b8cbc8be5f3Fariborz Jahanian llvm::Value *Size) = 0; 2746b5a61b6dc400027fd793dcadceeb9da944a37eaJohn McCall virtual llvm::Constant *BuildGCBlockLayout(CodeGen::CodeGenModule &CGM, 2756b5a61b6dc400027fd793dcadceeb9da944a37eaJohn McCall const CodeGen::CGBlockInfo &blockInfo) = 0; 276c46b43517a18c8f41934a38a3580bd477ab54265Fariborz Jahanian virtual llvm::Constant *BuildRCBlockLayout(CodeGen::CodeGenModule &CGM, 277c46b43517a18c8f41934a38a3580bd477ab54265Fariborz Jahanian const CodeGen::CGBlockInfo &blockInfo) = 0; 278a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar 279a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar /// Returns an i8* which points to the byref layout information. 2803ca23d7dc6cb61e6f363a58d9256d548199d120cFariborz Jahanian virtual llvm::Constant *BuildByrefLayout(CodeGen::CodeGenModule &CGM, 2813ca23d7dc6cb61e6f363a58d9256d548199d120cFariborz Jahanian QualType T) = 0; 282a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar 283651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines virtual llvm::GlobalVariable *GetClassGlobal(const std::string &Name, 284651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool Weak = false) = 0; 285de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall 286de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall struct MessageSendInfo { 287de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall const CGFunctionInfo &CallInfo; 288de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall llvm::PointerType *MessengerType; 289de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall 290de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall MessageSendInfo(const CGFunctionInfo &callInfo, 291de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall llvm::PointerType *messengerType) 292de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall : CallInfo(callInfo), MessengerType(messengerType) {} 293de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall }; 294de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall 295de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall MessageSendInfo getMessageSendInfo(const ObjCMethodDecl *method, 296de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall QualType resultType, 297de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall CallArgList &callArgs); 2987745786044f159cf9ddf4a8a0f7be8fe2bebfa80Eli Friedman 2997745786044f159cf9ddf4a8a0f7be8fe2bebfa80Eli Friedman // FIXME: This probably shouldn't be here, but the code to compute 3007745786044f159cf9ddf4a8a0f7be8fe2bebfa80Eli Friedman // it is here. 3017745786044f159cf9ddf4a8a0f7be8fe2bebfa80Eli Friedman unsigned ComputeBitfieldBitOffset(CodeGen::CodeGenModule &CGM, 3027745786044f159cf9ddf4a8a0f7be8fe2bebfa80Eli Friedman const ObjCInterfaceDecl *ID, 3037745786044f159cf9ddf4a8a0f7be8fe2bebfa80Eli Friedman const ObjCIvarDecl *Ivar); 3040f984268b05edab2cc555a427c441baa9c252658Chris Lattner}; 3050f984268b05edab2cc555a427c441baa9c252658Chris Lattner 3061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// Creates an instance of an Objective-C runtime class. 307391d77a26382dddf25da73e29fc1fa5aaaea4c6fChris Lattner//TODO: This should include some way of selecting which runtime to target. 308c17a4d3b16a2624a76de5d7508805534545bd3bfDaniel DunbarCGObjCRuntime *CreateGNUObjCRuntime(CodeGenModule &CGM); 309c17a4d3b16a2624a76de5d7508805534545bd3bfDaniel DunbarCGObjCRuntime *CreateMacObjCRuntime(CodeGenModule &CGM); 3100f984268b05edab2cc555a427c441baa9c252658Chris Lattner} 3110f984268b05edab2cc555a427c441baa9c252658Chris Lattner} 3120f984268b05edab2cc555a427c441baa9c252658Chris Lattner#endif 313