Daniel Dunbar | 303e2c2 | 2008-08-11 02:45:11 +0000 | [diff] [blame] | 1 | //===----- CGObjCRuntime.h - Interface to ObjC Runtimes ---------*- C++ -*-===// |
Chris Lattner | b7256cd | 2008-03-01 08:50:34 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This provides an abstract class for Objective-C code generation. Concrete |
| 11 | // subclasses of this implement code generation for specific Objective-C |
| 12 | // runtime libraries. |
| 13 | // |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
Benjamin Kramer | 2f5db8b | 2014-08-13 16:25:19 +0000 | [diff] [blame] | 16 | #ifndef LLVM_CLANG_LIB_CODEGEN_CGOBJCRUNTIME_H |
| 17 | #define LLVM_CLANG_LIB_CODEGEN_CGOBJCRUNTIME_H |
Daniel Dunbar | cb46385 | 2008-11-01 01:53:16 +0000 | [diff] [blame] | 18 | #include "CGBuilder.h" |
Daniel Dunbar | 41cf9de | 2008-09-09 01:06:48 +0000 | [diff] [blame] | 19 | #include "CGCall.h" |
David Chisnall | 93ce018 | 2018-08-10 12:53:13 +0000 | [diff] [blame] | 20 | #include "CGCleanup.h" |
Daniel Dunbar | cb46385 | 2008-11-01 01:53:16 +0000 | [diff] [blame] | 21 | #include "CGValue.h" |
Chandler Carruth | 3a02247 | 2012-12-04 09:13:33 +0000 | [diff] [blame] | 22 | #include "clang/AST/DeclObjC.h" |
| 23 | #include "clang/Basic/IdentifierTable.h" // Selector |
Daniel Dunbar | 97db84c | 2008-08-23 03:46:30 +0000 | [diff] [blame] | 24 | |
Chris Lattner | b7256cd | 2008-03-01 08:50:34 +0000 | [diff] [blame] | 25 | namespace llvm { |
Chris Lattner | b7256cd | 2008-03-01 08:50:34 +0000 | [diff] [blame] | 26 | class Constant; |
Daniel Dunbar | 9fd114d | 2009-04-22 07:32:20 +0000 | [diff] [blame] | 27 | class Function; |
| 28 | class Module; |
| 29 | class StructLayout; |
Daniel Dunbar | 7b4dfc8 | 2009-04-22 09:39:34 +0000 | [diff] [blame] | 30 | class StructType; |
Chris Lattner | b7256cd | 2008-03-01 08:50:34 +0000 | [diff] [blame] | 31 | class Type; |
| 32 | class Value; |
Chris Lattner | b7256cd | 2008-03-01 08:50:34 +0000 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | namespace clang { |
Daniel Dunbar | 41cf9de | 2008-09-09 01:06:48 +0000 | [diff] [blame] | 36 | namespace CodeGen { |
| 37 | class CodeGenFunction; |
| 38 | } |
Daniel Dunbar | 97db84c | 2008-08-23 03:46:30 +0000 | [diff] [blame] | 39 | |
Daniel Dunbar | 9fd114d | 2009-04-22 07:32:20 +0000 | [diff] [blame] | 40 | class FieldDecl; |
Anders Carlsson | 1963b0c | 2008-09-09 10:04:29 +0000 | [diff] [blame] | 41 | class ObjCAtTryStmt; |
| 42 | class ObjCAtThrowStmt; |
Chris Lattner | e132e24 | 2008-11-15 21:26:17 +0000 | [diff] [blame] | 43 | class ObjCAtSynchronizedStmt; |
Fariborz Jahanian | 0196a1c | 2009-01-10 21:06:09 +0000 | [diff] [blame] | 44 | class ObjCContainerDecl; |
Daniel Dunbar | 9299250 | 2008-08-15 22:20:32 +0000 | [diff] [blame] | 45 | class ObjCCategoryImplDecl; |
| 46 | class ObjCImplementationDecl; |
Daniel Dunbar | 7c6d3a7 | 2008-08-16 00:25:02 +0000 | [diff] [blame] | 47 | class ObjCInterfaceDecl; |
Daniel Dunbar | 97db84c | 2008-08-23 03:46:30 +0000 | [diff] [blame] | 48 | class ObjCMessageExpr; |
Daniel Dunbar | 9299250 | 2008-08-15 22:20:32 +0000 | [diff] [blame] | 49 | class ObjCMethodDecl; |
Daniel Dunbar | 89da6ad | 2008-08-13 00:59:25 +0000 | [diff] [blame] | 50 | class ObjCProtocolDecl; |
Chris Lattner | 6d522c0 | 2008-06-26 04:37:12 +0000 | [diff] [blame] | 51 | class Selector; |
Fariborz Jahanian | 9f84b78 | 2009-02-02 20:02:29 +0000 | [diff] [blame] | 52 | class ObjCIvarDecl; |
Steve Naroff | 66afeb5 | 2009-03-31 16:53:37 +0000 | [diff] [blame] | 53 | class ObjCStringLiteral; |
Fariborz Jahanian | c05349e | 2010-08-04 16:57:49 +0000 | [diff] [blame] | 54 | class BlockDeclRefExpr; |
Daniel Dunbar | 89da6ad | 2008-08-13 00:59:25 +0000 | [diff] [blame] | 55 | |
Chris Lattner | b7256cd | 2008-03-01 08:50:34 +0000 | [diff] [blame] | 56 | namespace CodeGen { |
Chris Lattner | 87ab27d | 2008-06-26 04:19:03 +0000 | [diff] [blame] | 57 | class CodeGenModule; |
John McCall | 351762c | 2011-02-07 10:33:21 +0000 | [diff] [blame] | 58 | class CGBlockInfo; |
Chris Lattner | b7256cd | 2008-03-01 08:50:34 +0000 | [diff] [blame] | 59 | |
Mike Stump | 18bb928 | 2009-05-16 07:57:57 +0000 | [diff] [blame] | 60 | // FIXME: Several methods should be pure virtual but aren't to avoid the |
| 61 | // partially-implemented subclass breaking. |
Anton Korobeynikov | 1200aca | 2008-06-01 14:13:53 +0000 | [diff] [blame] | 62 | |
| 63 | /// Implements runtime-specific code generation functions. |
Chris Lattner | b7256cd | 2008-03-01 08:50:34 +0000 | [diff] [blame] | 64 | class CGObjCRuntime { |
Daniel Dunbar | dc406b8 | 2010-04-05 21:36:35 +0000 | [diff] [blame] | 65 | protected: |
John McCall | a729c62 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 66 | CodeGen::CodeGenModule &CGM; |
| 67 | CGObjCRuntime(CodeGen::CodeGenModule &CGM) : CGM(CGM) {} |
| 68 | |
Daniel Dunbar | 9fd114d | 2009-04-22 07:32:20 +0000 | [diff] [blame] | 69 | // Utility functions for unified ivar access. These need to |
| 70 | // eventually be folded into other places (the structure layout |
| 71 | // code). |
| 72 | |
Daniel Dunbar | 7b4dfc8 | 2009-04-22 09:39:34 +0000 | [diff] [blame] | 73 | /// Compute an offset to the given ivar, suitable for passing to |
| 74 | /// EmitValueForIvarAtOffset. Note that the correct handling of |
| 75 | /// bit-fields is carefully coordinated by these two, use caution! |
Daniel Dunbar | 96120237 | 2009-05-03 12:57:56 +0000 | [diff] [blame] | 76 | /// |
| 77 | /// The latter overload is suitable for computing the offset of a |
| 78 | /// sythesized ivar. |
Eli Friedman | 8cbca20 | 2012-11-06 22:15:52 +0000 | [diff] [blame] | 79 | uint64_t ComputeIvarBaseOffset(CodeGen::CodeGenModule &CGM, |
| 80 | const ObjCInterfaceDecl *OID, |
| 81 | const ObjCIvarDecl *Ivar); |
| 82 | uint64_t ComputeIvarBaseOffset(CodeGen::CodeGenModule &CGM, |
| 83 | const ObjCImplementationDecl *OID, |
| 84 | const ObjCIvarDecl *Ivar); |
Daniel Dunbar | 9fd114d | 2009-04-22 07:32:20 +0000 | [diff] [blame] | 85 | |
| 86 | LValue EmitValueForIvarAtOffset(CodeGen::CodeGenFunction &CGF, |
| 87 | const ObjCInterfaceDecl *OID, |
| 88 | llvm::Value *BaseValue, |
| 89 | const ObjCIvarDecl *Ivar, |
| 90 | unsigned CVRQualifiers, |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 91 | llvm::Value *Offset); |
David Chisnall | d3858d6 | 2011-03-25 11:57:33 +0000 | [diff] [blame] | 92 | /// Emits a try / catch statement. This function is intended to be called by |
| 93 | /// subclasses, and provides a generic mechanism for generating these, which |
James Dennett | be30245 | 2012-06-15 22:10:14 +0000 | [diff] [blame] | 94 | /// should be usable by all runtimes. The caller must provide the functions |
| 95 | /// to call when entering and exiting a \@catch() block, and the function |
| 96 | /// used to rethrow exceptions. If the begin and end catch functions are |
| 97 | /// NULL, then the function assumes that the EH personality function provides |
| 98 | /// the thrown object directly. |
David Chisnall | d3858d6 | 2011-03-25 11:57:33 +0000 | [diff] [blame] | 99 | void EmitTryCatchStmt(CodeGenFunction &CGF, |
| 100 | const ObjCAtTryStmt &S, |
David Chisnall | 3fe8956 | 2011-05-23 22:33:28 +0000 | [diff] [blame] | 101 | llvm::Constant *beginCatchFn, |
| 102 | llvm::Constant *endCatchFn, |
| 103 | llvm::Constant *exceptionRethrowFn); |
John McCall | 17f0275 | 2015-10-30 00:56:02 +0000 | [diff] [blame] | 104 | |
| 105 | void EmitInitOfCatchParam(CodeGenFunction &CGF, llvm::Value *exn, |
| 106 | const VarDecl *paramDecl); |
| 107 | |
James Dennett | be30245 | 2012-06-15 22:10:14 +0000 | [diff] [blame] | 108 | /// Emits an \@synchronize() statement, using the \p syncEnterFn and |
| 109 | /// \p syncExitFn arguments as the functions called to lock and unlock |
| 110 | /// the object. This function can be called by subclasses that use |
| 111 | /// zero-cost exception handling. |
David Chisnall | d3858d6 | 2011-03-25 11:57:33 +0000 | [diff] [blame] | 112 | void EmitAtSynchronizedStmt(CodeGenFunction &CGF, |
| 113 | const ObjCAtSynchronizedStmt &S, |
| 114 | llvm::Function *syncEnterFn, |
| 115 | llvm::Function *syncExitFn); |
Daniel Dunbar | 48595de | 2008-08-11 16:50:21 +0000 | [diff] [blame] | 116 | |
Chris Lattner | b7256cd | 2008-03-01 08:50:34 +0000 | [diff] [blame] | 117 | public: |
| 118 | virtual ~CGObjCRuntime(); |
Daniel Dunbar | 9299250 | 2008-08-15 22:20:32 +0000 | [diff] [blame] | 119 | |
| 120 | /// Generate the function required to register all Objective-C components in |
| 121 | /// this compilation unit with the runtime library. |
| 122 | virtual llvm::Function *ModuleInitFunction() = 0; |
| 123 | |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 124 | /// Get a selector for the specified name and type values. |
| 125 | /// The result should have the LLVM type for ASTContext::getObjCSelType(). |
| 126 | virtual llvm::Value *GetSelector(CodeGenFunction &CGF, Selector Sel) = 0; |
| 127 | |
| 128 | /// Get the address of a selector for the specified name and type values. |
| 129 | /// This is a rarely-used language extension, but sadly it exists. |
| 130 | /// |
| 131 | /// The result should have the LLVM type for a pointer to |
Daniel Dunbar | 9299250 | 2008-08-15 22:20:32 +0000 | [diff] [blame] | 132 | /// ASTContext::getObjCSelType(). |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 133 | virtual Address GetAddrOfSelector(CodeGenFunction &CGF, Selector Sel) = 0; |
Daniel Dunbar | 9299250 | 2008-08-15 22:20:32 +0000 | [diff] [blame] | 134 | |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 135 | /// Get a typed selector. |
John McCall | 882987f | 2013-02-28 19:01:20 +0000 | [diff] [blame] | 136 | virtual llvm::Value *GetSelector(CodeGenFunction &CGF, |
Fariborz Jahanian | f3648b8 | 2009-05-05 21:36:57 +0000 | [diff] [blame] | 137 | const ObjCMethodDecl *Method) = 0; |
| 138 | |
John McCall | 2ca705e | 2010-07-24 00:37:23 +0000 | [diff] [blame] | 139 | /// Get the type constant to catch for the given ObjC pointer type. |
| 140 | /// This is used externally to implement catching ObjC types in C++. |
| 141 | /// Runtimes which don't support this should add the appropriate |
| 142 | /// error to Sema. |
Fariborz Jahanian | 831f0fc | 2011-06-23 19:00:08 +0000 | [diff] [blame] | 143 | virtual llvm::Constant *GetEHType(QualType T) = 0; |
John McCall | 2ca705e | 2010-07-24 00:37:23 +0000 | [diff] [blame] | 144 | |
David Chisnall | 93ce018 | 2018-08-10 12:53:13 +0000 | [diff] [blame] | 145 | virtual CatchTypeInfo getCatchAllTypeInfo() { return { nullptr, 0 }; } |
| 146 | |
Daniel Dunbar | 9299250 | 2008-08-15 22:20:32 +0000 | [diff] [blame] | 147 | /// Generate a constant string object. |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 148 | virtual ConstantAddress GenerateConstantString(const StringLiteral *) = 0; |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 149 | |
Daniel Dunbar | 9299250 | 2008-08-15 22:20:32 +0000 | [diff] [blame] | 150 | /// Generate a category. A category contains a list of methods (and |
| 151 | /// accompanying metadata) and a list of protocols. |
| 152 | virtual void GenerateCategory(const ObjCCategoryImplDecl *OCD) = 0; |
| 153 | |
Chris Lattner | 57540c5 | 2011-04-15 05:22:18 +0000 | [diff] [blame] | 154 | /// Generate a class structure for this class. |
Daniel Dunbar | 9299250 | 2008-08-15 22:20:32 +0000 | [diff] [blame] | 155 | virtual void GenerateClass(const ObjCImplementationDecl *OID) = 0; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 156 | |
David Chisnall | 92d436b | 2012-01-31 18:59:20 +0000 | [diff] [blame] | 157 | /// Register an class alias. |
| 158 | virtual void RegisterAlias(const ObjCCompatibleAliasDecl *OAD) = 0; |
| 159 | |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 160 | /// Generate an Objective-C message send operation. |
Daniel Dunbar | aff9fca | 2009-09-17 04:01:22 +0000 | [diff] [blame] | 161 | /// |
| 162 | /// \param Method - The method being called, this may be null if synthesizing |
| 163 | /// a property setter or getter. |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 164 | virtual CodeGen::RValue |
Daniel Dunbar | 97db84c | 2008-08-23 03:46:30 +0000 | [diff] [blame] | 165 | GenerateMessageSend(CodeGen::CodeGenFunction &CGF, |
John McCall | 78a1511 | 2010-05-22 01:48:05 +0000 | [diff] [blame] | 166 | ReturnValueSlot ReturnSlot, |
Daniel Dunbar | 4b8c6db | 2008-08-30 05:35:15 +0000 | [diff] [blame] | 167 | QualType ResultType, |
| 168 | Selector Sel, |
Daniel Dunbar | ca8531a | 2008-08-25 08:19:24 +0000 | [diff] [blame] | 169 | llvm::Value *Receiver, |
Fariborz Jahanian | f3648b8 | 2009-05-05 21:36:57 +0000 | [diff] [blame] | 170 | const CallArgList &CallArgs, |
Craig Topper | 8a13c41 | 2014-05-21 05:09:00 +0000 | [diff] [blame] | 171 | const ObjCInterfaceDecl *Class = nullptr, |
| 172 | const ObjCMethodDecl *Method = nullptr) = 0; |
Daniel Dunbar | 89da6ad | 2008-08-13 00:59:25 +0000 | [diff] [blame] | 173 | |
Daniel Dunbar | 9299250 | 2008-08-15 22:20:32 +0000 | [diff] [blame] | 174 | /// Generate an Objective-C message send operation to the super |
Daniel Dunbar | ca8531a | 2008-08-25 08:19:24 +0000 | [diff] [blame] | 175 | /// class initiated in a method for Class and with the given Self |
| 176 | /// object. |
Daniel Dunbar | aff9fca | 2009-09-17 04:01:22 +0000 | [diff] [blame] | 177 | /// |
| 178 | /// \param Method - The method being called, this may be null if synthesizing |
| 179 | /// a property setter or getter. |
Daniel Dunbar | 97db84c | 2008-08-23 03:46:30 +0000 | [diff] [blame] | 180 | virtual CodeGen::RValue |
| 181 | GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF, |
John McCall | 78a1511 | 2010-05-22 01:48:05 +0000 | [diff] [blame] | 182 | ReturnValueSlot ReturnSlot, |
Daniel Dunbar | 4b8c6db | 2008-08-30 05:35:15 +0000 | [diff] [blame] | 183 | QualType ResultType, |
| 184 | Selector Sel, |
Daniel Dunbar | ca8531a | 2008-08-25 08:19:24 +0000 | [diff] [blame] | 185 | const ObjCInterfaceDecl *Class, |
Fariborz Jahanian | bac73ac | 2009-02-28 20:07:56 +0000 | [diff] [blame] | 186 | bool isCategoryImpl, |
Daniel Dunbar | ca8531a | 2008-08-25 08:19:24 +0000 | [diff] [blame] | 187 | llvm::Value *Self, |
Daniel Dunbar | c722b85 | 2008-08-30 03:02:31 +0000 | [diff] [blame] | 188 | bool IsClassMessage, |
Daniel Dunbar | aff9fca | 2009-09-17 04:01:22 +0000 | [diff] [blame] | 189 | const CallArgList &CallArgs, |
Craig Topper | 8a13c41 | 2014-05-21 05:09:00 +0000 | [diff] [blame] | 190 | const ObjCMethodDecl *Method = nullptr) = 0; |
Daniel Dunbar | 6630e10 | 2008-08-12 05:08:18 +0000 | [diff] [blame] | 191 | |
| 192 | /// Emit the code to return the named protocol as an object, as in a |
James Dennett | 1355bd1 | 2012-06-11 06:19:40 +0000 | [diff] [blame] | 193 | /// \@protocol expression. |
John McCall | 882987f | 2013-02-28 19:01:20 +0000 | [diff] [blame] | 194 | virtual llvm::Value *GenerateProtocolRef(CodeGenFunction &CGF, |
Daniel Dunbar | 9299250 | 2008-08-15 22:20:32 +0000 | [diff] [blame] | 195 | const ObjCProtocolDecl *OPD) = 0; |
Daniel Dunbar | 6630e10 | 2008-08-12 05:08:18 +0000 | [diff] [blame] | 196 | |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 197 | /// Generate the named protocol. Protocols contain method metadata but no |
| 198 | /// implementations. |
Daniel Dunbar | 9299250 | 2008-08-15 22:20:32 +0000 | [diff] [blame] | 199 | virtual void GenerateProtocol(const ObjCProtocolDecl *OPD) = 0; |
Daniel Dunbar | 89da6ad | 2008-08-13 00:59:25 +0000 | [diff] [blame] | 200 | |
Daniel Dunbar | 9299250 | 2008-08-15 22:20:32 +0000 | [diff] [blame] | 201 | /// Generate a function preamble for a method with the specified |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 202 | /// types. |
Daniel Dunbar | 9299250 | 2008-08-15 22:20:32 +0000 | [diff] [blame] | 203 | |
Mike Stump | 18bb928 | 2009-05-16 07:57:57 +0000 | [diff] [blame] | 204 | // FIXME: Current this just generates the Function definition, but really this |
| 205 | // should also be generating the loads of the parameters, as the runtime |
| 206 | // should have full control over how parameters are passed. |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 207 | virtual llvm::Function *GenerateMethod(const ObjCMethodDecl *OMD, |
Fariborz Jahanian | 0196a1c | 2009-01-10 21:06:09 +0000 | [diff] [blame] | 208 | const ObjCContainerDecl *CD) = 0; |
Daniel Dunbar | 89da6ad | 2008-08-13 00:59:25 +0000 | [diff] [blame] | 209 | |
Daniel Dunbar | a91c3e0 | 2008-09-24 03:38:44 +0000 | [diff] [blame] | 210 | /// Return the runtime function for getting properties. |
Chris Lattner | d480892 | 2009-03-22 21:03:39 +0000 | [diff] [blame] | 211 | virtual llvm::Constant *GetPropertyGetFunction() = 0; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 212 | |
Daniel Dunbar | a91c3e0 | 2008-09-24 03:38:44 +0000 | [diff] [blame] | 213 | /// Return the runtime function for setting properties. |
Chris Lattner | d480892 | 2009-03-22 21:03:39 +0000 | [diff] [blame] | 214 | virtual llvm::Constant *GetPropertySetFunction() = 0; |
Daniel Dunbar | a91c3e0 | 2008-09-24 03:38:44 +0000 | [diff] [blame] | 215 | |
Ted Kremenek | e65b086 | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 216 | /// Return the runtime function for optimized setting properties. |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 217 | virtual llvm::Constant *GetOptimizedPropertySetFunction(bool atomic, |
Ted Kremenek | e65b086 | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 218 | bool copy) = 0; |
| 219 | |
David Chisnall | 168b80f | 2010-12-26 22:13:16 +0000 | [diff] [blame] | 220 | // API for atomic copying of qualified aggregates in getter. |
| 221 | virtual llvm::Constant *GetGetStructFunction() = 0; |
| 222 | // API for atomic copying of qualified aggregates in setter. |
| 223 | virtual llvm::Constant *GetSetStructFunction() = 0; |
David Chisnall | 0d75e06 | 2012-12-17 18:54:24 +0000 | [diff] [blame] | 224 | /// API for atomic copying of qualified aggregates with non-trivial copy |
| 225 | /// assignment (c++) in setter. |
| 226 | virtual llvm::Constant *GetCppAtomicObjectSetFunction() = 0; |
| 227 | /// API for atomic copying of qualified aggregates with non-trivial copy |
| 228 | /// assignment (c++) in getter. |
| 229 | virtual llvm::Constant *GetCppAtomicObjectGetFunction() = 0; |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 230 | |
Daniel Dunbar | 7c6d3a7 | 2008-08-16 00:25:02 +0000 | [diff] [blame] | 231 | /// GetClass - Return a reference to the class for the given |
| 232 | /// interface decl. |
John McCall | 882987f | 2013-02-28 19:01:20 +0000 | [diff] [blame] | 233 | virtual llvm::Value *GetClass(CodeGenFunction &CGF, |
Daniel Dunbar | 7c6d3a7 | 2008-08-16 00:25:02 +0000 | [diff] [blame] | 234 | const ObjCInterfaceDecl *OID) = 0; |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 235 | |
| 236 | |
John McCall | 882987f | 2013-02-28 19:01:20 +0000 | [diff] [blame] | 237 | virtual llvm::Value *EmitNSAutoreleasePoolClassRef(CodeGenFunction &CGF) { |
David Blaikie | 83d382b | 2011-09-23 05:06:16 +0000 | [diff] [blame] | 238 | llvm_unreachable("autoreleasepool unsupported in this ABI"); |
John McCall | 31168b0 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 239 | } |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 240 | |
Anders Carlsson | 3f35a26 | 2008-08-31 04:05:03 +0000 | [diff] [blame] | 241 | /// EnumerationMutationFunction - Return the function that's called by the |
| 242 | /// compiler when a mutation is detected during foreach iteration. |
Chris Lattner | d480892 | 2009-03-22 21:03:39 +0000 | [diff] [blame] | 243 | virtual llvm::Constant *EnumerationMutationFunction() = 0; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 244 | |
John McCall | bd30929 | 2010-07-06 01:34:17 +0000 | [diff] [blame] | 245 | virtual void EmitSynchronizedStmt(CodeGen::CodeGenFunction &CGF, |
| 246 | const ObjCAtSynchronizedStmt &S) = 0; |
| 247 | virtual void EmitTryStmt(CodeGen::CodeGenFunction &CGF, |
| 248 | const ObjCAtTryStmt &S) = 0; |
Anders Carlsson | 1963b0c | 2008-09-09 10:04:29 +0000 | [diff] [blame] | 249 | virtual void EmitThrowStmt(CodeGen::CodeGenFunction &CGF, |
Fariborz Jahanian | 1eab052 | 2013-01-10 19:02:56 +0000 | [diff] [blame] | 250 | const ObjCAtThrowStmt &S, |
| 251 | bool ClearInsertionPoint=true) = 0; |
Daniel Dunbar | be9dae8 | 2009-04-21 00:49:20 +0000 | [diff] [blame] | 252 | virtual llvm::Value *EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF, |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 253 | Address AddrWeakObj) = 0; |
Fariborz Jahanian | 83f45b55 | 2008-11-18 22:37:34 +0000 | [diff] [blame] | 254 | virtual void EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF, |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 255 | llvm::Value *src, Address dest) = 0; |
Fariborz Jahanian | d7db964 | 2008-11-19 00:59:10 +0000 | [diff] [blame] | 256 | virtual void EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF, |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 257 | llvm::Value *src, Address dest, |
Fariborz Jahanian | 217af24 | 2010-07-20 20:30:03 +0000 | [diff] [blame] | 258 | bool threadlocal=false) = 0; |
Fariborz Jahanian | e881b53 | 2008-11-20 19:23:36 +0000 | [diff] [blame] | 259 | virtual void EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF, |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 260 | llvm::Value *src, Address dest, |
Fariborz Jahanian | 7a95d72 | 2009-09-24 22:25:38 +0000 | [diff] [blame] | 261 | llvm::Value *ivarOffset) = 0; |
Fariborz Jahanian | d7db964 | 2008-11-19 00:59:10 +0000 | [diff] [blame] | 262 | virtual void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF, |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 263 | llvm::Value *src, Address dest) = 0; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 264 | |
Fariborz Jahanian | 712bfa6 | 2009-02-03 19:03:09 +0000 | [diff] [blame] | 265 | virtual LValue EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF, |
| 266 | QualType ObjectTy, |
| 267 | llvm::Value *BaseValue, |
| 268 | const ObjCIvarDecl *Ivar, |
Fariborz Jahanian | 712bfa6 | 2009-02-03 19:03:09 +0000 | [diff] [blame] | 269 | unsigned CVRQualifiers) = 0; |
Fariborz Jahanian | 21fc74c | 2009-02-10 19:02:04 +0000 | [diff] [blame] | 270 | virtual llvm::Value *EmitIvarOffset(CodeGen::CodeGenFunction &CGF, |
Daniel Dunbar | 722f424 | 2009-04-22 05:08:15 +0000 | [diff] [blame] | 271 | const ObjCInterfaceDecl *Interface, |
Fariborz Jahanian | 21fc74c | 2009-02-10 19:02:04 +0000 | [diff] [blame] | 272 | const ObjCIvarDecl *Ivar) = 0; |
Fariborz Jahanian | 5f21d2f | 2009-07-08 01:18:33 +0000 | [diff] [blame] | 273 | virtual void EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF, |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 274 | Address DestPtr, |
| 275 | Address SrcPtr, |
Fariborz Jahanian | 021510e | 2010-06-15 22:44:06 +0000 | [diff] [blame] | 276 | llvm::Value *Size) = 0; |
John McCall | 351762c | 2011-02-07 10:33:21 +0000 | [diff] [blame] | 277 | virtual llvm::Constant *BuildGCBlockLayout(CodeGen::CodeGenModule &CGM, |
| 278 | const CodeGen::CGBlockInfo &blockInfo) = 0; |
Fariborz Jahanian | 0c58ce9 | 2012-10-27 21:10:38 +0000 | [diff] [blame] | 279 | virtual llvm::Constant *BuildRCBlockLayout(CodeGen::CodeGenModule &CGM, |
| 280 | const CodeGen::CGBlockInfo &blockInfo) = 0; |
Vedant Kumar | 2f5bb115 | 2015-12-21 20:21:15 +0000 | [diff] [blame] | 281 | |
| 282 | /// Returns an i8* which points to the byref layout information. |
Fariborz Jahanian | a9d4464 | 2012-11-14 17:15:51 +0000 | [diff] [blame] | 283 | virtual llvm::Constant *BuildByrefLayout(CodeGen::CodeGenModule &CGM, |
| 284 | QualType T) = 0; |
Vedant Kumar | 2f5bb115 | 2015-12-21 20:21:15 +0000 | [diff] [blame] | 285 | |
John McCall | a729c62 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 286 | struct MessageSendInfo { |
| 287 | const CGFunctionInfo &CallInfo; |
| 288 | llvm::PointerType *MessengerType; |
| 289 | |
| 290 | MessageSendInfo(const CGFunctionInfo &callInfo, |
| 291 | llvm::PointerType *messengerType) |
| 292 | : CallInfo(callInfo), MessengerType(messengerType) {} |
| 293 | }; |
| 294 | |
| 295 | MessageSendInfo getMessageSendInfo(const ObjCMethodDecl *method, |
| 296 | QualType resultType, |
| 297 | CallArgList &callArgs); |
Eli Friedman | 8593748 | 2012-11-06 23:40:48 +0000 | [diff] [blame] | 298 | |
| 299 | // FIXME: This probably shouldn't be here, but the code to compute |
| 300 | // it is here. |
| 301 | unsigned ComputeBitfieldBitOffset(CodeGen::CodeGenModule &CGM, |
| 302 | const ObjCInterfaceDecl *ID, |
| 303 | const ObjCIvarDecl *Ivar); |
Chris Lattner | b7256cd | 2008-03-01 08:50:34 +0000 | [diff] [blame] | 304 | }; |
| 305 | |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 306 | /// Creates an instance of an Objective-C runtime class. |
Chris Lattner | 4bd5596 | 2008-03-30 23:03:07 +0000 | [diff] [blame] | 307 | //TODO: This should include some way of selecting which runtime to target. |
Daniel Dunbar | 303e2c2 | 2008-08-11 02:45:11 +0000 | [diff] [blame] | 308 | CGObjCRuntime *CreateGNUObjCRuntime(CodeGenModule &CGM); |
| 309 | CGObjCRuntime *CreateMacObjCRuntime(CodeGenModule &CGM); |
Alexander Kornienko | ab9db51 | 2015-06-22 23:07:51 +0000 | [diff] [blame] | 310 | } |
| 311 | } |
Chris Lattner | b7256cd | 2008-03-01 08:50:34 +0000 | [diff] [blame] | 312 | #endif |