CGObjCRuntime.h revision c46b43517a18c8f41934a38a3580bd477ab54265
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 160f984268b05edab2cc555a427c441baa9c252658Chris Lattner#ifndef CLANG_CODEGEN_OBCJRUNTIME_H 170f984268b05edab2cc555a427c441baa9c252658Chris Lattner#define CLANG_CODEGEN_OBCJRUNTIME_H 18e91593ef084479340582b2ba177b44be50a717b7Daniel Dunbar#include "clang/Basic/IdentifierTable.h" // Selector 19df9ccc6381314ccca6407abb209155e9273a631dFariborz Jahanian#include "clang/AST/DeclObjC.h" 200f984268b05edab2cc555a427c441baa9c252658Chris Lattner 2145d196b8387dcefc4df26cda114fa34c6528e928Daniel Dunbar#include "CGBuilder.h" 2246f45b9bec4a265ad8400a538e5ec3a5683617f1Daniel Dunbar#include "CGCall.h" 2345d196b8387dcefc4df26cda114fa34c6528e928Daniel Dunbar#include "CGValue.h" 248f2926b73ed635afecd020da787af6a837601a2bDaniel Dunbar 250f984268b05edab2cc555a427c441baa9c252658Chris Lattnernamespace llvm { 260f984268b05edab2cc555a427c441baa9c252658Chris Lattner class Constant; 279777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar class Function; 289777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar class Module; 299777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar class StructLayout; 3084ad77a8f83121713ea69d8002d1fd19565f87abDaniel Dunbar class StructType; 310f984268b05edab2cc555a427c441baa9c252658Chris Lattner class Type; 320f984268b05edab2cc555a427c441baa9c252658Chris Lattner class Value; 330f984268b05edab2cc555a427c441baa9c252658Chris Lattner} 340f984268b05edab2cc555a427c441baa9c252658Chris Lattner 350f984268b05edab2cc555a427c441baa9c252658Chris Lattnernamespace clang { 3646f45b9bec4a265ad8400a538e5ec3a5683617f1Daniel Dunbarnamespace CodeGen { 3746f45b9bec4a265ad8400a538e5ec3a5683617f1Daniel Dunbar class CodeGenFunction; 3846f45b9bec4a265ad8400a538e5ec3a5683617f1Daniel Dunbar} 398f2926b73ed635afecd020da787af6a837601a2bDaniel Dunbar 409777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar class FieldDecl; 4164d5d6c5903157c521af496479d06dc26032d718Anders Carlsson class ObjCAtTryStmt; 4264d5d6c5903157c521af496479d06dc26032d718Anders Carlsson class ObjCAtThrowStmt; 4310cac6f7115b59a466bb8d2d51cdddeb38aadc37Chris Lattner class ObjCAtSynchronizedStmt; 44679a502d462ef819e6175b58e255ca3f3391e7cfFariborz Jahanian class ObjCContainerDecl; 457ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar class ObjCCategoryImplDecl; 467ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar class ObjCImplementationDecl; 47ddb2a3d55a24a1dbdf9152621642d9a4b4fc2f61Daniel Dunbar class ObjCInterfaceDecl; 488f2926b73ed635afecd020da787af6a837601a2bDaniel Dunbar class ObjCMessageExpr; 497ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar class ObjCMethodDecl; 50af2f62ce32e462f256855cd24b06dec4755d2827Daniel Dunbar class ObjCProtocolDecl; 518e67b63530b4f39a48bc12d97376f373a6901279Chris Lattner class Selector; 520bb20361a321593887f067515dd04cf109f4c74aFariborz Jahanian class ObjCIvarDecl; 5333fdb738a6c125f4c788733897021b7c1a062b0cSteve Naroff class ObjCStringLiteral; 5489ecd41e0a6bfb3b0913dbe41c3c666340b308c7Fariborz Jahanian class BlockDeclRefExpr; 55af2f62ce32e462f256855cd24b06dec4755d2827Daniel Dunbar 560f984268b05edab2cc555a427c441baa9c252658Chris Lattnernamespace CodeGen { 57dce1406f1c1f572cfd61c494546572d63461c741Chris Lattner class CodeGenModule; 586b5a61b6dc400027fd793dcadceeb9da944a37eaJohn McCall class CGBlockInfo; 590f984268b05edab2cc555a427c441baa9c252658Chris Lattner 60f5408fe484495ee4efbdd709c8a2c2fdbbbdb328Mike Stump// FIXME: Several methods should be pure virtual but aren't to avoid the 61f5408fe484495ee4efbdd709c8a2c2fdbbbdb328Mike Stump// partially-implemented subclass breaking. 6220ff3108fcd2c3bd734dc79efc22ebaa090abd41Anton Korobeynikov 6320ff3108fcd2c3bd734dc79efc22ebaa090abd41Anton Korobeynikov/// Implements runtime-specific code generation functions. 640f984268b05edab2cc555a427c441baa9c252658Chris Lattnerclass CGObjCRuntime { 65f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbarprotected: 66de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall CodeGen::CodeGenModule &CGM; 67de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall CGObjCRuntime(CodeGen::CodeGenModule &CGM) : CGM(CGM) {} 68de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall 699777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar // Utility functions for unified ivar access. These need to 709777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar // eventually be folded into other places (the structure layout 719777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar // code). 729777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar 7384ad77a8f83121713ea69d8002d1fd19565f87abDaniel Dunbar /// Compute an offset to the given ivar, suitable for passing to 7484ad77a8f83121713ea69d8002d1fd19565f87abDaniel Dunbar /// EmitValueForIvarAtOffset. Note that the correct handling of 7584ad77a8f83121713ea69d8002d1fd19565f87abDaniel Dunbar /// bit-fields is carefully coordinated by these two, use caution! 769f89f2bc111339ee7fa0df3c2f18e39493b460c4Daniel Dunbar /// 779f89f2bc111339ee7fa0df3c2f18e39493b460c4Daniel Dunbar /// The latter overload is suitable for computing the offset of a 789f89f2bc111339ee7fa0df3c2f18e39493b460c4Daniel Dunbar /// sythesized ivar. 799777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar uint64_t ComputeIvarBaseOffset(CodeGen::CodeGenModule &CGM, 809777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar const ObjCInterfaceDecl *OID, 819777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar const ObjCIvarDecl *Ivar); 829f89f2bc111339ee7fa0df3c2f18e39493b460c4Daniel Dunbar uint64_t ComputeIvarBaseOffset(CodeGen::CodeGenModule &CGM, 839f89f2bc111339ee7fa0df3c2f18e39493b460c4Daniel Dunbar const ObjCImplementationDecl *OID, 849f89f2bc111339ee7fa0df3c2f18e39493b460c4Daniel Dunbar const ObjCIvarDecl *Ivar); 859777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar 869777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar LValue EmitValueForIvarAtOffset(CodeGen::CodeGenFunction &CGF, 879777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar const ObjCInterfaceDecl *OID, 889777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar llvm::Value *BaseValue, 899777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar const ObjCIvarDecl *Ivar, 909777687562c338601c2f17906e65e1c1a0aad96fDaniel Dunbar unsigned CVRQualifiers, 911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump llvm::Value *Offset); 929735ca6e01113aec6a825dd5b1cb1b98fb377d31David Chisnall /// Emits a try / catch statement. This function is intended to be called by 939735ca6e01113aec6a825dd5b1cb1b98fb377d31David Chisnall /// subclasses, and provides a generic mechanism for generating these, which 942ee5ba35febf830d366b65dd0dcbf8e291c41342James Dennett /// should be usable by all runtimes. The caller must provide the functions 952ee5ba35febf830d366b65dd0dcbf8e291c41342James Dennett /// to call when entering and exiting a \@catch() block, and the function 962ee5ba35febf830d366b65dd0dcbf8e291c41342James Dennett /// used to rethrow exceptions. If the begin and end catch functions are 972ee5ba35febf830d366b65dd0dcbf8e291c41342James Dennett /// NULL, then the function assumes that the EH personality function provides 982ee5ba35febf830d366b65dd0dcbf8e291c41342James Dennett /// the thrown object directly. 999735ca6e01113aec6a825dd5b1cb1b98fb377d31David Chisnall void EmitTryCatchStmt(CodeGenFunction &CGF, 1009735ca6e01113aec6a825dd5b1cb1b98fb377d31David Chisnall const ObjCAtTryStmt &S, 101789ecdebd04aebdb2d6b801ebe8e04a189ebc023David Chisnall llvm::Constant *beginCatchFn, 102789ecdebd04aebdb2d6b801ebe8e04a189ebc023David Chisnall llvm::Constant *endCatchFn, 103789ecdebd04aebdb2d6b801ebe8e04a189ebc023David Chisnall llvm::Constant *exceptionRethrowFn); 1042ee5ba35febf830d366b65dd0dcbf8e291c41342James Dennett /// Emits an \@synchronize() statement, using the \p syncEnterFn and 1052ee5ba35febf830d366b65dd0dcbf8e291c41342James Dennett /// \p syncExitFn arguments as the functions called to lock and unlock 1062ee5ba35febf830d366b65dd0dcbf8e291c41342James Dennett /// the object. This function can be called by subclasses that use 1072ee5ba35febf830d366b65dd0dcbf8e291c41342James Dennett /// zero-cost exception handling. 1089735ca6e01113aec6a825dd5b1cb1b98fb377d31David Chisnall void EmitAtSynchronizedStmt(CodeGenFunction &CGF, 1099735ca6e01113aec6a825dd5b1cb1b98fb377d31David Chisnall const ObjCAtSynchronizedStmt &S, 1109735ca6e01113aec6a825dd5b1cb1b98fb377d31David Chisnall llvm::Function *syncEnterFn, 1119735ca6e01113aec6a825dd5b1cb1b98fb377d31David Chisnall llvm::Function *syncExitFn); 11258bf6101062867ca4b3028f9e77e4ae642f09b44Daniel Dunbar 1130f984268b05edab2cc555a427c441baa9c252658Chris Lattnerpublic: 1140f984268b05edab2cc555a427c441baa9c252658Chris Lattner virtual ~CGObjCRuntime(); 115af2f62ce32e462f256855cd24b06dec4755d2827Daniel Dunbar 116391d77a26382dddf25da73e29fc1fa5aaaea4c6fChris Lattner /// Generate the function required to register all Objective-C components in 117391d77a26382dddf25da73e29fc1fa5aaaea4c6fChris Lattner /// this compilation unit with the runtime library. 1187ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar virtual llvm::Function *ModuleInitFunction() = 0; 119af2f62ce32e462f256855cd24b06dec4755d2827Daniel Dunbar 1207ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar /// Get a selector for the specified name and type values. The 1217ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar /// return value should have the LLVM type for pointer-to 1227ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar /// ASTContext::getObjCSelType(). 12345d196b8387dcefc4df26cda114fa34c6528e928Daniel Dunbar virtual llvm::Value *GetSelector(CGBuilderTy &Builder, 12403b2960c14aede6ac82bdef32247094ebb72fa69Fariborz Jahanian Selector Sel, bool lval=false) = 0; 125af2f62ce32e462f256855cd24b06dec4755d2827Daniel Dunbar 1261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// Get a typed selector. 127df9ccc6381314ccca6407abb209155e9273a631dFariborz Jahanian virtual llvm::Value *GetSelector(CGBuilderTy &Builder, 128df9ccc6381314ccca6407abb209155e9273a631dFariborz Jahanian const ObjCMethodDecl *Method) = 0; 129df9ccc6381314ccca6407abb209155e9273a631dFariborz Jahanian 1305a180397870944548aaadeaebf58e415885b9489John McCall /// Get the type constant to catch for the given ObjC pointer type. 1315a180397870944548aaadeaebf58e415885b9489John McCall /// This is used externally to implement catching ObjC types in C++. 1325a180397870944548aaadeaebf58e415885b9489John McCall /// Runtimes which don't support this should add the appropriate 1335a180397870944548aaadeaebf58e415885b9489John McCall /// error to Sema. 134cf5abc7ba032bd35158e4d75b0bc92a482fc67e8Fariborz Jahanian virtual llvm::Constant *GetEHType(QualType T) = 0; 1355a180397870944548aaadeaebf58e415885b9489John McCall 1367ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar /// Generate a constant string object. 1370d13f6fdbdd6f06e2449b8834dda53334abd399aDavid Chisnall virtual llvm::Constant *GenerateConstantString(const StringLiteral *) = 0; 138ebcb57a8d298862c65043e88b2429591ab3c58d3Ted Kremenek 13920ff3108fcd2c3bd734dc79efc22ebaa090abd41Anton Korobeynikov /// Generate a category. A category contains a list of methods (and 14020ff3108fcd2c3bd734dc79efc22ebaa090abd41Anton Korobeynikov /// accompanying metadata) and a list of protocols. 1417ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar virtual void GenerateCategory(const ObjCCategoryImplDecl *OCD) = 0; 142af2f62ce32e462f256855cd24b06dec4755d2827Daniel Dunbar 143fc8f0e14ad142ed811e90fbd9a30e419e301c717Chris Lattner /// Generate a class structure for this class. 1447ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar virtual void GenerateClass(const ObjCImplementationDecl *OID) = 0; 1451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 14629254f4dd114fe2dd5c4e7a261ebea941973ad3dDavid Chisnall /// Register an class alias. 14729254f4dd114fe2dd5c4e7a261ebea941973ad3dDavid Chisnall virtual void RegisterAlias(const ObjCCompatibleAliasDecl *OAD) = 0; 14829254f4dd114fe2dd5c4e7a261ebea941973ad3dDavid Chisnall 1491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// Generate an Objective-C message send operation. 150d6c93d703541c992e06eb9a59a2d826a30da65b2Daniel Dunbar /// 151d6c93d703541c992e06eb9a59a2d826a30da65b2Daniel Dunbar /// \param Method - The method being called, this may be null if synthesizing 152d6c93d703541c992e06eb9a59a2d826a30da65b2Daniel Dunbar /// a property setter or getter. 1531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump virtual CodeGen::RValue 1548f2926b73ed635afecd020da787af6a837601a2bDaniel Dunbar GenerateMessageSend(CodeGen::CodeGenFunction &CGF, 155ef072fd2f3347cfd857d6eb787b245b950771430John McCall ReturnValueSlot ReturnSlot, 1567f8ea5c5b3a6a4332a841eefdd86b0726722ea7bDaniel Dunbar QualType ResultType, 1577f8ea5c5b3a6a4332a841eefdd86b0726722ea7bDaniel Dunbar Selector Sel, 158f56f1913e91ad32bed52dd3f6afc26735d336584Daniel Dunbar llvm::Value *Receiver, 159df9ccc6381314ccca6407abb209155e9273a631dFariborz Jahanian const CallArgList &CallArgs, 160c6cd5fd3eae71f8841504a396563343cfaaf503eDavid Chisnall const ObjCInterfaceDecl *Class = 0, 161d6c93d703541c992e06eb9a59a2d826a30da65b2Daniel Dunbar const ObjCMethodDecl *Method = 0) = 0; 162af2f62ce32e462f256855cd24b06dec4755d2827Daniel Dunbar 1637ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar /// Generate an Objective-C message send operation to the super 164f56f1913e91ad32bed52dd3f6afc26735d336584Daniel Dunbar /// class initiated in a method for Class and with the given Self 165f56f1913e91ad32bed52dd3f6afc26735d336584Daniel Dunbar /// object. 166d6c93d703541c992e06eb9a59a2d826a30da65b2Daniel Dunbar /// 167d6c93d703541c992e06eb9a59a2d826a30da65b2Daniel Dunbar /// \param Method - The method being called, this may be null if synthesizing 168d6c93d703541c992e06eb9a59a2d826a30da65b2Daniel Dunbar /// a property setter or getter. 1698f2926b73ed635afecd020da787af6a837601a2bDaniel Dunbar virtual CodeGen::RValue 1708f2926b73ed635afecd020da787af6a837601a2bDaniel Dunbar GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF, 171ef072fd2f3347cfd857d6eb787b245b950771430John McCall ReturnValueSlot ReturnSlot, 1727f8ea5c5b3a6a4332a841eefdd86b0726722ea7bDaniel Dunbar QualType ResultType, 1737f8ea5c5b3a6a4332a841eefdd86b0726722ea7bDaniel Dunbar Selector Sel, 174f56f1913e91ad32bed52dd3f6afc26735d336584Daniel Dunbar const ObjCInterfaceDecl *Class, 1757ce77920a35060f1c8dd72e541e42ce296ccd168Fariborz Jahanian bool isCategoryImpl, 176f56f1913e91ad32bed52dd3f6afc26735d336584Daniel Dunbar llvm::Value *Self, 17719cd87eb5fb3c197e631ce08fd52c446c4d4e8f1Daniel Dunbar bool IsClassMessage, 178d6c93d703541c992e06eb9a59a2d826a30da65b2Daniel Dunbar const CallArgList &CallArgs, 179d6c93d703541c992e06eb9a59a2d826a30da65b2Daniel Dunbar const ObjCMethodDecl *Method = 0) = 0; 18098c5ead87d720d8b68b6f236c3c3579a388fc882Daniel Dunbar 18198c5ead87d720d8b68b6f236c3c3579a388fc882Daniel Dunbar /// Emit the code to return the named protocol as an object, as in a 18217d26a6c1f2cb921d0000c337b4967699dc928fdJames Dennett /// \@protocol expression. 18345d196b8387dcefc4df26cda114fa34c6528e928Daniel Dunbar virtual llvm::Value *GenerateProtocolRef(CGBuilderTy &Builder, 1847ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar const ObjCProtocolDecl *OPD) = 0; 18598c5ead87d720d8b68b6f236c3c3579a388fc882Daniel Dunbar 1861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// Generate the named protocol. Protocols contain method metadata but no 1871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// implementations. 1887ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar virtual void GenerateProtocol(const ObjCProtocolDecl *OPD) = 0; 1897ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar 1907ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar /// Generate a function preamble for a method with the specified 1911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// types. 1927ded7f4983dc4a20561db7a8d02c6b2435030961Daniel Dunbar 193f5408fe484495ee4efbdd709c8a2c2fdbbbdb328Mike Stump // FIXME: Current this just generates the Function definition, but really this 194f5408fe484495ee4efbdd709c8a2c2fdbbbdb328Mike Stump // should also be generating the loads of the parameters, as the runtime 195f5408fe484495ee4efbdd709c8a2c2fdbbbdb328Mike Stump // should have full control over how parameters are passed. 1961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump virtual llvm::Function *GenerateMethod(const ObjCMethodDecl *OMD, 197679a502d462ef819e6175b58e255ca3f3391e7cfFariborz Jahanian const ObjCContainerDecl *CD) = 0; 198af2f62ce32e462f256855cd24b06dec4755d2827Daniel Dunbar 19949f6602707887eea1a558a1dffe0213102f887f2Daniel Dunbar /// Return the runtime function for getting properties. 20074391b48b4791cded373683a3baf67314f358d50Chris Lattner virtual llvm::Constant *GetPropertyGetFunction() = 0; 2011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 20249f6602707887eea1a558a1dffe0213102f887f2Daniel Dunbar /// Return the runtime function for setting properties. 20374391b48b4791cded373683a3baf67314f358d50Chris Lattner virtual llvm::Constant *GetPropertySetFunction() = 0; 20449f6602707887eea1a558a1dffe0213102f887f2Daniel Dunbar 205ebcb57a8d298862c65043e88b2429591ab3c58d3Ted Kremenek /// Return the runtime function for optimized setting properties. 206ebcb57a8d298862c65043e88b2429591ab3c58d3Ted Kremenek virtual llvm::Constant *GetOptimizedPropertySetFunction(bool atomic, 207ebcb57a8d298862c65043e88b2429591ab3c58d3Ted Kremenek bool copy) = 0; 208ebcb57a8d298862c65043e88b2429591ab3c58d3Ted Kremenek 2098fac25d33b13e25f512dd921d4d5a4b565f5d175David Chisnall // API for atomic copying of qualified aggregates in getter. 2108fac25d33b13e25f512dd921d4d5a4b565f5d175David Chisnall virtual llvm::Constant *GetGetStructFunction() = 0; 2118fac25d33b13e25f512dd921d4d5a4b565f5d175David Chisnall // API for atomic copying of qualified aggregates in setter. 2128fac25d33b13e25f512dd921d4d5a4b565f5d175David Chisnall virtual llvm::Constant *GetSetStructFunction() = 0; 213e3173021fa3bfdf7e6759d67838e385a83b2d57eFariborz Jahanian // API for atomic copying of qualified aggregates with non-trivial copy 214e3173021fa3bfdf7e6759d67838e385a83b2d57eFariborz Jahanian // assignment (c++) in setter/getter. 215e3173021fa3bfdf7e6759d67838e385a83b2d57eFariborz Jahanian virtual llvm::Constant *GetCppAtomicObjectFunction() = 0; 2166cc590602f41c3e98e8af0023d54296c8eca7910Fariborz Jahanian 217ddb2a3d55a24a1dbdf9152621642d9a4b4fc2f61Daniel Dunbar /// GetClass - Return a reference to the class for the given 218ddb2a3d55a24a1dbdf9152621642d9a4b4fc2f61Daniel Dunbar /// interface decl. 2191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump virtual llvm::Value *GetClass(CGBuilderTy &Builder, 220ddb2a3d55a24a1dbdf9152621642d9a4b4fc2f61Daniel Dunbar const ObjCInterfaceDecl *OID) = 0; 221f85e193739c953358c865005855253af4f68a497John McCall 222f85e193739c953358c865005855253af4f68a497John McCall 223f85e193739c953358c865005855253af4f68a497John McCall virtual llvm::Value *EmitNSAutoreleasePoolClassRef(CGBuilderTy &Builder) { 224b219cfc4d75f0a03630b7c4509ef791b7e97b2c8David Blaikie llvm_unreachable("autoreleasepool unsupported in this ABI"); 225f85e193739c953358c865005855253af4f68a497John McCall } 226f85e193739c953358c865005855253af4f68a497John McCall 2272abd89c039e835e84519a4cd8a7495899a70153dAnders Carlsson /// EnumerationMutationFunction - Return the function that's called by the 2282abd89c039e835e84519a4cd8a7495899a70153dAnders Carlsson /// compiler when a mutation is detected during foreach iteration. 22974391b48b4791cded373683a3baf67314f358d50Chris Lattner virtual llvm::Constant *EnumerationMutationFunction() = 0; 2301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 231f1549f66a8216a78112286e3978cea2c29d6334cJohn McCall virtual void EmitSynchronizedStmt(CodeGen::CodeGenFunction &CGF, 232f1549f66a8216a78112286e3978cea2c29d6334cJohn McCall const ObjCAtSynchronizedStmt &S) = 0; 233f1549f66a8216a78112286e3978cea2c29d6334cJohn McCall virtual void EmitTryStmt(CodeGen::CodeGenFunction &CGF, 234f1549f66a8216a78112286e3978cea2c29d6334cJohn McCall const ObjCAtTryStmt &S) = 0; 23564d5d6c5903157c521af496479d06dc26032d718Anders Carlsson virtual void EmitThrowStmt(CodeGen::CodeGenFunction &CGF, 23664d5d6c5903157c521af496479d06dc26032d718Anders Carlsson const ObjCAtThrowStmt &S) = 0; 2376bf2ae05c777052e5ec05649710380dea263e7e0Daniel Dunbar virtual llvm::Value *EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF, 2386bf2ae05c777052e5ec05649710380dea263e7e0Daniel Dunbar llvm::Value *AddrWeakObj) = 0; 2393e283e344595e0bd499b13b30a92b7d9c10a2140Fariborz Jahanian virtual void EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF, 2403e283e344595e0bd499b13b30a92b7d9c10a2140Fariborz Jahanian llvm::Value *src, llvm::Value *dest) = 0; 24158626500527695865683d1d65053743de8770b60Fariborz Jahanian virtual void EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF, 242021a7a63984f0f912dc9e9dae2a1b3e1509a40ceFariborz Jahanian llvm::Value *src, llvm::Value *dest, 243021a7a63984f0f912dc9e9dae2a1b3e1509a40ceFariborz Jahanian bool threadlocal=false) = 0; 2447eda8367cf63caee8acf907356b1d199ccaa6e89Fariborz Jahanian virtual void EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF, 2456c7a1f364796ce1acb988714e9e42076d1ce332eFariborz Jahanian llvm::Value *src, llvm::Value *dest, 2466c7a1f364796ce1acb988714e9e42076d1ce332eFariborz Jahanian llvm::Value *ivarOffset) = 0; 24758626500527695865683d1d65053743de8770b60Fariborz Jahanian virtual void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF, 24858626500527695865683d1d65053743de8770b60Fariborz Jahanian llvm::Value *src, llvm::Value *dest) = 0; 2491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 250598d3f61b6ca854e9d3c2f3359e24468502a61aaFariborz Jahanian virtual LValue EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF, 251598d3f61b6ca854e9d3c2f3359e24468502a61aaFariborz Jahanian QualType ObjectTy, 252598d3f61b6ca854e9d3c2f3359e24468502a61aaFariborz Jahanian llvm::Value *BaseValue, 253598d3f61b6ca854e9d3c2f3359e24468502a61aaFariborz Jahanian const ObjCIvarDecl *Ivar, 254598d3f61b6ca854e9d3c2f3359e24468502a61aaFariborz Jahanian unsigned CVRQualifiers) = 0; 255f63aa3fd429cdb9145d78f0b656bc78754efedb9Fariborz Jahanian virtual llvm::Value *EmitIvarOffset(CodeGen::CodeGenFunction &CGF, 2562a03192a02dbf4fdff438d1e658356bde871aba4Daniel Dunbar const ObjCInterfaceDecl *Interface, 257f63aa3fd429cdb9145d78f0b656bc78754efedb9Fariborz Jahanian const ObjCIvarDecl *Ivar) = 0; 258082b02e8403d3ee9d2ded969fbe0e5d472f04cd8Fariborz Jahanian virtual void EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF, 2591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump llvm::Value *DestPtr, 260082b02e8403d3ee9d2ded969fbe0e5d472f04cd8Fariborz Jahanian llvm::Value *SrcPtr, 26155bcace250e1ff366e4482714b344b8cbc8be5f3Fariborz Jahanian llvm::Value *Size) = 0; 2626b5a61b6dc400027fd793dcadceeb9da944a37eaJohn McCall virtual llvm::Constant *BuildGCBlockLayout(CodeGen::CodeGenModule &CGM, 2636b5a61b6dc400027fd793dcadceeb9da944a37eaJohn McCall const CodeGen::CGBlockInfo &blockInfo) = 0; 264c46b43517a18c8f41934a38a3580bd477ab54265Fariborz Jahanian virtual llvm::Constant *BuildRCBlockLayout(CodeGen::CodeGenModule &CGM, 265c46b43517a18c8f41934a38a3580bd477ab54265Fariborz Jahanian const CodeGen::CGBlockInfo &blockInfo) = 0; 2666f40e2244b0590f144c5ceee07981a962fbbc72eFariborz Jahanian virtual llvm::GlobalVariable *GetClassGlobal(const std::string &Name) = 0; 267de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall 268de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall struct MessageSendInfo { 269de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall const CGFunctionInfo &CallInfo; 270de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall llvm::PointerType *MessengerType; 271de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall 272de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall MessageSendInfo(const CGFunctionInfo &callInfo, 273de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall llvm::PointerType *messengerType) 274de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall : CallInfo(callInfo), MessengerType(messengerType) {} 275de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall }; 276de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall 277de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall MessageSendInfo getMessageSendInfo(const ObjCMethodDecl *method, 278de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall QualType resultType, 279de5d3c717684f3821b8db58037bc7140acf134aaJohn McCall CallArgList &callArgs); 2800f984268b05edab2cc555a427c441baa9c252658Chris Lattner}; 2810f984268b05edab2cc555a427c441baa9c252658Chris Lattner 2821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// Creates an instance of an Objective-C runtime class. 283391d77a26382dddf25da73e29fc1fa5aaaea4c6fChris Lattner//TODO: This should include some way of selecting which runtime to target. 284c17a4d3b16a2624a76de5d7508805534545bd3bfDaniel DunbarCGObjCRuntime *CreateGNUObjCRuntime(CodeGenModule &CGM); 285c17a4d3b16a2624a76de5d7508805534545bd3bfDaniel DunbarCGObjCRuntime *CreateMacObjCRuntime(CodeGenModule &CGM); 2860f984268b05edab2cc555a427c441baa9c252658Chris Lattner} 2870f984268b05edab2cc555a427c441baa9c252658Chris Lattner} 2880f984268b05edab2cc555a427c441baa9c252658Chris Lattner#endif 289