annotate clang/lib/CodeGen/CGObjCRuntime.h @ 221:79ff65ed7e25

LLVM12 Original
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 15 Jun 2021 19:15:29 +0900
parents 0572611fdcc8
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 //===----- CGObjCRuntime.h - Interface to ObjC Runtimes ---------*- C++ -*-===//
anatofuz
parents:
diff changeset
2 //
anatofuz
parents:
diff changeset
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
anatofuz
parents:
diff changeset
4 // See https://llvm.org/LICENSE.txt for license information.
anatofuz
parents:
diff changeset
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
anatofuz
parents:
diff changeset
6 //
anatofuz
parents:
diff changeset
7 //===----------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
8 //
anatofuz
parents:
diff changeset
9 // This provides an abstract class for Objective-C code generation. Concrete
anatofuz
parents:
diff changeset
10 // subclasses of this implement code generation for specific Objective-C
anatofuz
parents:
diff changeset
11 // runtime libraries.
anatofuz
parents:
diff changeset
12 //
anatofuz
parents:
diff changeset
13 //===----------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
14
anatofuz
parents:
diff changeset
15 #ifndef LLVM_CLANG_LIB_CODEGEN_CGOBJCRUNTIME_H
anatofuz
parents:
diff changeset
16 #define LLVM_CLANG_LIB_CODEGEN_CGOBJCRUNTIME_H
anatofuz
parents:
diff changeset
17 #include "CGBuilder.h"
anatofuz
parents:
diff changeset
18 #include "CGCall.h"
anatofuz
parents:
diff changeset
19 #include "CGCleanup.h"
anatofuz
parents:
diff changeset
20 #include "CGValue.h"
anatofuz
parents:
diff changeset
21 #include "clang/AST/DeclObjC.h"
anatofuz
parents:
diff changeset
22 #include "clang/Basic/IdentifierTable.h" // Selector
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
23 #include "llvm/ADT/UniqueVector.h"
150
anatofuz
parents:
diff changeset
24
anatofuz
parents:
diff changeset
25 namespace llvm {
anatofuz
parents:
diff changeset
26 class Constant;
anatofuz
parents:
diff changeset
27 class Function;
anatofuz
parents:
diff changeset
28 class Module;
anatofuz
parents:
diff changeset
29 class StructLayout;
anatofuz
parents:
diff changeset
30 class StructType;
anatofuz
parents:
diff changeset
31 class Type;
anatofuz
parents:
diff changeset
32 class Value;
anatofuz
parents:
diff changeset
33 }
anatofuz
parents:
diff changeset
34
anatofuz
parents:
diff changeset
35 namespace clang {
anatofuz
parents:
diff changeset
36 namespace CodeGen {
anatofuz
parents:
diff changeset
37 class CodeGenFunction;
anatofuz
parents:
diff changeset
38 }
anatofuz
parents:
diff changeset
39
anatofuz
parents:
diff changeset
40 class FieldDecl;
anatofuz
parents:
diff changeset
41 class ObjCAtTryStmt;
anatofuz
parents:
diff changeset
42 class ObjCAtThrowStmt;
anatofuz
parents:
diff changeset
43 class ObjCAtSynchronizedStmt;
anatofuz
parents:
diff changeset
44 class ObjCContainerDecl;
anatofuz
parents:
diff changeset
45 class ObjCCategoryImplDecl;
anatofuz
parents:
diff changeset
46 class ObjCImplementationDecl;
anatofuz
parents:
diff changeset
47 class ObjCInterfaceDecl;
anatofuz
parents:
diff changeset
48 class ObjCMessageExpr;
anatofuz
parents:
diff changeset
49 class ObjCMethodDecl;
anatofuz
parents:
diff changeset
50 class ObjCProtocolDecl;
anatofuz
parents:
diff changeset
51 class Selector;
anatofuz
parents:
diff changeset
52 class ObjCIvarDecl;
anatofuz
parents:
diff changeset
53 class ObjCStringLiteral;
anatofuz
parents:
diff changeset
54 class BlockDeclRefExpr;
anatofuz
parents:
diff changeset
55
anatofuz
parents:
diff changeset
56 namespace CodeGen {
anatofuz
parents:
diff changeset
57 class CodeGenModule;
anatofuz
parents:
diff changeset
58 class CGBlockInfo;
anatofuz
parents:
diff changeset
59
anatofuz
parents:
diff changeset
60 // FIXME: Several methods should be pure virtual but aren't to avoid the
anatofuz
parents:
diff changeset
61 // partially-implemented subclass breaking.
anatofuz
parents:
diff changeset
62
anatofuz
parents:
diff changeset
63 /// Implements runtime-specific code generation functions.
anatofuz
parents:
diff changeset
64 class CGObjCRuntime {
anatofuz
parents:
diff changeset
65 protected:
anatofuz
parents:
diff changeset
66 CodeGen::CodeGenModule &CGM;
anatofuz
parents:
diff changeset
67 CGObjCRuntime(CodeGen::CodeGenModule &CGM) : CGM(CGM) {}
anatofuz
parents:
diff changeset
68
anatofuz
parents:
diff changeset
69 // Utility functions for unified ivar access. These need to
anatofuz
parents:
diff changeset
70 // eventually be folded into other places (the structure layout
anatofuz
parents:
diff changeset
71 // code).
anatofuz
parents:
diff changeset
72
anatofuz
parents:
diff changeset
73 /// Compute an offset to the given ivar, suitable for passing to
anatofuz
parents:
diff changeset
74 /// EmitValueForIvarAtOffset. Note that the correct handling of
anatofuz
parents:
diff changeset
75 /// bit-fields is carefully coordinated by these two, use caution!
anatofuz
parents:
diff changeset
76 ///
anatofuz
parents:
diff changeset
77 /// The latter overload is suitable for computing the offset of a
anatofuz
parents:
diff changeset
78 /// sythesized ivar.
anatofuz
parents:
diff changeset
79 uint64_t ComputeIvarBaseOffset(CodeGen::CodeGenModule &CGM,
anatofuz
parents:
diff changeset
80 const ObjCInterfaceDecl *OID,
anatofuz
parents:
diff changeset
81 const ObjCIvarDecl *Ivar);
anatofuz
parents:
diff changeset
82 uint64_t ComputeIvarBaseOffset(CodeGen::CodeGenModule &CGM,
anatofuz
parents:
diff changeset
83 const ObjCImplementationDecl *OID,
anatofuz
parents:
diff changeset
84 const ObjCIvarDecl *Ivar);
anatofuz
parents:
diff changeset
85
anatofuz
parents:
diff changeset
86 LValue EmitValueForIvarAtOffset(CodeGen::CodeGenFunction &CGF,
anatofuz
parents:
diff changeset
87 const ObjCInterfaceDecl *OID,
anatofuz
parents:
diff changeset
88 llvm::Value *BaseValue,
anatofuz
parents:
diff changeset
89 const ObjCIvarDecl *Ivar,
anatofuz
parents:
diff changeset
90 unsigned CVRQualifiers,
anatofuz
parents:
diff changeset
91 llvm::Value *Offset);
anatofuz
parents:
diff changeset
92 /// Emits a try / catch statement. This function is intended to be called by
anatofuz
parents:
diff changeset
93 /// subclasses, and provides a generic mechanism for generating these, which
anatofuz
parents:
diff changeset
94 /// should be usable by all runtimes. The caller must provide the functions
anatofuz
parents:
diff changeset
95 /// to call when entering and exiting a \@catch() block, and the function
anatofuz
parents:
diff changeset
96 /// used to rethrow exceptions. If the begin and end catch functions are
anatofuz
parents:
diff changeset
97 /// NULL, then the function assumes that the EH personality function provides
anatofuz
parents:
diff changeset
98 /// the thrown object directly.
anatofuz
parents:
diff changeset
99 void EmitTryCatchStmt(CodeGenFunction &CGF, const ObjCAtTryStmt &S,
anatofuz
parents:
diff changeset
100 llvm::FunctionCallee beginCatchFn,
anatofuz
parents:
diff changeset
101 llvm::FunctionCallee endCatchFn,
anatofuz
parents:
diff changeset
102 llvm::FunctionCallee exceptionRethrowFn);
anatofuz
parents:
diff changeset
103
anatofuz
parents:
diff changeset
104 void EmitInitOfCatchParam(CodeGenFunction &CGF, llvm::Value *exn,
anatofuz
parents:
diff changeset
105 const VarDecl *paramDecl);
anatofuz
parents:
diff changeset
106
anatofuz
parents:
diff changeset
107 /// Emits an \@synchronize() statement, using the \p syncEnterFn and
anatofuz
parents:
diff changeset
108 /// \p syncExitFn arguments as the functions called to lock and unlock
anatofuz
parents:
diff changeset
109 /// the object. This function can be called by subclasses that use
anatofuz
parents:
diff changeset
110 /// zero-cost exception handling.
anatofuz
parents:
diff changeset
111 void EmitAtSynchronizedStmt(CodeGenFunction &CGF,
anatofuz
parents:
diff changeset
112 const ObjCAtSynchronizedStmt &S,
anatofuz
parents:
diff changeset
113 llvm::FunctionCallee syncEnterFn,
anatofuz
parents:
diff changeset
114 llvm::FunctionCallee syncExitFn);
anatofuz
parents:
diff changeset
115
anatofuz
parents:
diff changeset
116 public:
anatofuz
parents:
diff changeset
117 virtual ~CGObjCRuntime();
anatofuz
parents:
diff changeset
118
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
119 std::string getSymbolNameForMethod(const ObjCMethodDecl *method,
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
120 bool includeCategoryName = true);
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
121
150
anatofuz
parents:
diff changeset
122 /// Generate the function required to register all Objective-C components in
anatofuz
parents:
diff changeset
123 /// this compilation unit with the runtime library.
anatofuz
parents:
diff changeset
124 virtual llvm::Function *ModuleInitFunction() = 0;
anatofuz
parents:
diff changeset
125
anatofuz
parents:
diff changeset
126 /// Get a selector for the specified name and type values.
anatofuz
parents:
diff changeset
127 /// The result should have the LLVM type for ASTContext::getObjCSelType().
anatofuz
parents:
diff changeset
128 virtual llvm::Value *GetSelector(CodeGenFunction &CGF, Selector Sel) = 0;
anatofuz
parents:
diff changeset
129
anatofuz
parents:
diff changeset
130 /// Get the address of a selector for the specified name and type values.
anatofuz
parents:
diff changeset
131 /// This is a rarely-used language extension, but sadly it exists.
anatofuz
parents:
diff changeset
132 ///
anatofuz
parents:
diff changeset
133 /// The result should have the LLVM type for a pointer to
anatofuz
parents:
diff changeset
134 /// ASTContext::getObjCSelType().
anatofuz
parents:
diff changeset
135 virtual Address GetAddrOfSelector(CodeGenFunction &CGF, Selector Sel) = 0;
anatofuz
parents:
diff changeset
136
anatofuz
parents:
diff changeset
137 /// Get a typed selector.
anatofuz
parents:
diff changeset
138 virtual llvm::Value *GetSelector(CodeGenFunction &CGF,
anatofuz
parents:
diff changeset
139 const ObjCMethodDecl *Method) = 0;
anatofuz
parents:
diff changeset
140
anatofuz
parents:
diff changeset
141 /// Get the type constant to catch for the given ObjC pointer type.
anatofuz
parents:
diff changeset
142 /// This is used externally to implement catching ObjC types in C++.
anatofuz
parents:
diff changeset
143 /// Runtimes which don't support this should add the appropriate
anatofuz
parents:
diff changeset
144 /// error to Sema.
anatofuz
parents:
diff changeset
145 virtual llvm::Constant *GetEHType(QualType T) = 0;
anatofuz
parents:
diff changeset
146
anatofuz
parents:
diff changeset
147 virtual CatchTypeInfo getCatchAllTypeInfo() { return { nullptr, 0 }; }
anatofuz
parents:
diff changeset
148
anatofuz
parents:
diff changeset
149 /// Generate a constant string object.
anatofuz
parents:
diff changeset
150 virtual ConstantAddress GenerateConstantString(const StringLiteral *) = 0;
anatofuz
parents:
diff changeset
151
anatofuz
parents:
diff changeset
152 /// Generate a category. A category contains a list of methods (and
anatofuz
parents:
diff changeset
153 /// accompanying metadata) and a list of protocols.
anatofuz
parents:
diff changeset
154 virtual void GenerateCategory(const ObjCCategoryImplDecl *OCD) = 0;
anatofuz
parents:
diff changeset
155
anatofuz
parents:
diff changeset
156 /// Generate a class structure for this class.
anatofuz
parents:
diff changeset
157 virtual void GenerateClass(const ObjCImplementationDecl *OID) = 0;
anatofuz
parents:
diff changeset
158
anatofuz
parents:
diff changeset
159 /// Register an class alias.
anatofuz
parents:
diff changeset
160 virtual void RegisterAlias(const ObjCCompatibleAliasDecl *OAD) = 0;
anatofuz
parents:
diff changeset
161
anatofuz
parents:
diff changeset
162 /// Generate an Objective-C message send operation.
anatofuz
parents:
diff changeset
163 ///
anatofuz
parents:
diff changeset
164 /// \param Method - The method being called, this may be null if synthesizing
anatofuz
parents:
diff changeset
165 /// a property setter or getter.
anatofuz
parents:
diff changeset
166 virtual CodeGen::RValue
anatofuz
parents:
diff changeset
167 GenerateMessageSend(CodeGen::CodeGenFunction &CGF,
anatofuz
parents:
diff changeset
168 ReturnValueSlot ReturnSlot,
anatofuz
parents:
diff changeset
169 QualType ResultType,
anatofuz
parents:
diff changeset
170 Selector Sel,
anatofuz
parents:
diff changeset
171 llvm::Value *Receiver,
anatofuz
parents:
diff changeset
172 const CallArgList &CallArgs,
anatofuz
parents:
diff changeset
173 const ObjCInterfaceDecl *Class = nullptr,
anatofuz
parents:
diff changeset
174 const ObjCMethodDecl *Method = nullptr) = 0;
anatofuz
parents:
diff changeset
175
anatofuz
parents:
diff changeset
176 /// Generate an Objective-C message send operation.
anatofuz
parents:
diff changeset
177 ///
anatofuz
parents:
diff changeset
178 /// This variant allows for the call to be substituted with an optimized
anatofuz
parents:
diff changeset
179 /// variant.
anatofuz
parents:
diff changeset
180 CodeGen::RValue
anatofuz
parents:
diff changeset
181 GeneratePossiblySpecializedMessageSend(CodeGenFunction &CGF,
anatofuz
parents:
diff changeset
182 ReturnValueSlot Return,
anatofuz
parents:
diff changeset
183 QualType ResultType,
anatofuz
parents:
diff changeset
184 Selector Sel,
anatofuz
parents:
diff changeset
185 llvm::Value *Receiver,
anatofuz
parents:
diff changeset
186 const CallArgList& Args,
anatofuz
parents:
diff changeset
187 const ObjCInterfaceDecl *OID,
anatofuz
parents:
diff changeset
188 const ObjCMethodDecl *Method,
anatofuz
parents:
diff changeset
189 bool isClassMessage);
anatofuz
parents:
diff changeset
190
anatofuz
parents:
diff changeset
191 /// Generate an Objective-C message send operation to the super
anatofuz
parents:
diff changeset
192 /// class initiated in a method for Class and with the given Self
anatofuz
parents:
diff changeset
193 /// object.
anatofuz
parents:
diff changeset
194 ///
anatofuz
parents:
diff changeset
195 /// \param Method - The method being called, this may be null if synthesizing
anatofuz
parents:
diff changeset
196 /// a property setter or getter.
anatofuz
parents:
diff changeset
197 virtual CodeGen::RValue
anatofuz
parents:
diff changeset
198 GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF,
anatofuz
parents:
diff changeset
199 ReturnValueSlot ReturnSlot,
anatofuz
parents:
diff changeset
200 QualType ResultType,
anatofuz
parents:
diff changeset
201 Selector Sel,
anatofuz
parents:
diff changeset
202 const ObjCInterfaceDecl *Class,
anatofuz
parents:
diff changeset
203 bool isCategoryImpl,
anatofuz
parents:
diff changeset
204 llvm::Value *Self,
anatofuz
parents:
diff changeset
205 bool IsClassMessage,
anatofuz
parents:
diff changeset
206 const CallArgList &CallArgs,
anatofuz
parents:
diff changeset
207 const ObjCMethodDecl *Method = nullptr) = 0;
anatofuz
parents:
diff changeset
208
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
209 /// Walk the list of protocol references from a class, category or
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
210 /// protocol to traverse the DAG formed from it's inheritance hierarchy. Find
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
211 /// the list of protocols that ends each walk at either a runtime
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
212 /// protocol or a non-runtime protocol with no parents. For the common case of
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
213 /// just a list of standard runtime protocols this just returns the same list
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
214 /// that was passed in.
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
215 std::vector<const ObjCProtocolDecl *>
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
216 GetRuntimeProtocolList(ObjCProtocolDecl::protocol_iterator begin,
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
217 ObjCProtocolDecl::protocol_iterator end);
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
218
150
anatofuz
parents:
diff changeset
219 /// Emit the code to return the named protocol as an object, as in a
anatofuz
parents:
diff changeset
220 /// \@protocol expression.
anatofuz
parents:
diff changeset
221 virtual llvm::Value *GenerateProtocolRef(CodeGenFunction &CGF,
anatofuz
parents:
diff changeset
222 const ObjCProtocolDecl *OPD) = 0;
anatofuz
parents:
diff changeset
223
anatofuz
parents:
diff changeset
224 /// Generate the named protocol. Protocols contain method metadata but no
anatofuz
parents:
diff changeset
225 /// implementations.
anatofuz
parents:
diff changeset
226 virtual void GenerateProtocol(const ObjCProtocolDecl *OPD) = 0;
anatofuz
parents:
diff changeset
227
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
228 /// GetOrEmitProtocol - Get the protocol object for the given
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
229 /// declaration, emitting it if necessary. The return value has type
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
230 /// ProtocolPtrTy.
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
231 virtual llvm::Constant *GetOrEmitProtocol(const ObjCProtocolDecl *PD) = 0;
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
232
150
anatofuz
parents:
diff changeset
233 /// Generate a function preamble for a method with the specified
anatofuz
parents:
diff changeset
234 /// types.
anatofuz
parents:
diff changeset
235
anatofuz
parents:
diff changeset
236 // FIXME: Current this just generates the Function definition, but really this
anatofuz
parents:
diff changeset
237 // should also be generating the loads of the parameters, as the runtime
anatofuz
parents:
diff changeset
238 // should have full control over how parameters are passed.
anatofuz
parents:
diff changeset
239 virtual llvm::Function *GenerateMethod(const ObjCMethodDecl *OMD,
anatofuz
parents:
diff changeset
240 const ObjCContainerDecl *CD) = 0;
anatofuz
parents:
diff changeset
241
anatofuz
parents:
diff changeset
242 /// Generates prologue for direct Objective-C Methods.
anatofuz
parents:
diff changeset
243 virtual void GenerateDirectMethodPrologue(CodeGenFunction &CGF,
anatofuz
parents:
diff changeset
244 llvm::Function *Fn,
anatofuz
parents:
diff changeset
245 const ObjCMethodDecl *OMD,
anatofuz
parents:
diff changeset
246 const ObjCContainerDecl *CD) = 0;
anatofuz
parents:
diff changeset
247
anatofuz
parents:
diff changeset
248 /// Return the runtime function for getting properties.
anatofuz
parents:
diff changeset
249 virtual llvm::FunctionCallee GetPropertyGetFunction() = 0;
anatofuz
parents:
diff changeset
250
anatofuz
parents:
diff changeset
251 /// Return the runtime function for setting properties.
anatofuz
parents:
diff changeset
252 virtual llvm::FunctionCallee GetPropertySetFunction() = 0;
anatofuz
parents:
diff changeset
253
anatofuz
parents:
diff changeset
254 /// Return the runtime function for optimized setting properties.
anatofuz
parents:
diff changeset
255 virtual llvm::FunctionCallee GetOptimizedPropertySetFunction(bool atomic,
anatofuz
parents:
diff changeset
256 bool copy) = 0;
anatofuz
parents:
diff changeset
257
anatofuz
parents:
diff changeset
258 // API for atomic copying of qualified aggregates in getter.
anatofuz
parents:
diff changeset
259 virtual llvm::FunctionCallee GetGetStructFunction() = 0;
anatofuz
parents:
diff changeset
260 // API for atomic copying of qualified aggregates in setter.
anatofuz
parents:
diff changeset
261 virtual llvm::FunctionCallee GetSetStructFunction() = 0;
anatofuz
parents:
diff changeset
262 /// API for atomic copying of qualified aggregates with non-trivial copy
anatofuz
parents:
diff changeset
263 /// assignment (c++) in setter.
anatofuz
parents:
diff changeset
264 virtual llvm::FunctionCallee GetCppAtomicObjectSetFunction() = 0;
anatofuz
parents:
diff changeset
265 /// API for atomic copying of qualified aggregates with non-trivial copy
anatofuz
parents:
diff changeset
266 /// assignment (c++) in getter.
anatofuz
parents:
diff changeset
267 virtual llvm::FunctionCallee GetCppAtomicObjectGetFunction() = 0;
anatofuz
parents:
diff changeset
268
anatofuz
parents:
diff changeset
269 /// GetClass - Return a reference to the class for the given
anatofuz
parents:
diff changeset
270 /// interface decl.
anatofuz
parents:
diff changeset
271 virtual llvm::Value *GetClass(CodeGenFunction &CGF,
anatofuz
parents:
diff changeset
272 const ObjCInterfaceDecl *OID) = 0;
anatofuz
parents:
diff changeset
273
anatofuz
parents:
diff changeset
274
anatofuz
parents:
diff changeset
275 virtual llvm::Value *EmitNSAutoreleasePoolClassRef(CodeGenFunction &CGF) {
anatofuz
parents:
diff changeset
276 llvm_unreachable("autoreleasepool unsupported in this ABI");
anatofuz
parents:
diff changeset
277 }
anatofuz
parents:
diff changeset
278
anatofuz
parents:
diff changeset
279 /// EnumerationMutationFunction - Return the function that's called by the
anatofuz
parents:
diff changeset
280 /// compiler when a mutation is detected during foreach iteration.
anatofuz
parents:
diff changeset
281 virtual llvm::FunctionCallee EnumerationMutationFunction() = 0;
anatofuz
parents:
diff changeset
282
anatofuz
parents:
diff changeset
283 virtual void EmitSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
anatofuz
parents:
diff changeset
284 const ObjCAtSynchronizedStmt &S) = 0;
anatofuz
parents:
diff changeset
285 virtual void EmitTryStmt(CodeGen::CodeGenFunction &CGF,
anatofuz
parents:
diff changeset
286 const ObjCAtTryStmt &S) = 0;
anatofuz
parents:
diff changeset
287 virtual void EmitThrowStmt(CodeGen::CodeGenFunction &CGF,
anatofuz
parents:
diff changeset
288 const ObjCAtThrowStmt &S,
anatofuz
parents:
diff changeset
289 bool ClearInsertionPoint=true) = 0;
anatofuz
parents:
diff changeset
290 virtual llvm::Value *EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF,
anatofuz
parents:
diff changeset
291 Address AddrWeakObj) = 0;
anatofuz
parents:
diff changeset
292 virtual void EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF,
anatofuz
parents:
diff changeset
293 llvm::Value *src, Address dest) = 0;
anatofuz
parents:
diff changeset
294 virtual void EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF,
anatofuz
parents:
diff changeset
295 llvm::Value *src, Address dest,
anatofuz
parents:
diff changeset
296 bool threadlocal=false) = 0;
anatofuz
parents:
diff changeset
297 virtual void EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF,
anatofuz
parents:
diff changeset
298 llvm::Value *src, Address dest,
anatofuz
parents:
diff changeset
299 llvm::Value *ivarOffset) = 0;
anatofuz
parents:
diff changeset
300 virtual void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
anatofuz
parents:
diff changeset
301 llvm::Value *src, Address dest) = 0;
anatofuz
parents:
diff changeset
302
anatofuz
parents:
diff changeset
303 virtual LValue EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
anatofuz
parents:
diff changeset
304 QualType ObjectTy,
anatofuz
parents:
diff changeset
305 llvm::Value *BaseValue,
anatofuz
parents:
diff changeset
306 const ObjCIvarDecl *Ivar,
anatofuz
parents:
diff changeset
307 unsigned CVRQualifiers) = 0;
anatofuz
parents:
diff changeset
308 virtual llvm::Value *EmitIvarOffset(CodeGen::CodeGenFunction &CGF,
anatofuz
parents:
diff changeset
309 const ObjCInterfaceDecl *Interface,
anatofuz
parents:
diff changeset
310 const ObjCIvarDecl *Ivar) = 0;
anatofuz
parents:
diff changeset
311 virtual void EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF,
anatofuz
parents:
diff changeset
312 Address DestPtr,
anatofuz
parents:
diff changeset
313 Address SrcPtr,
anatofuz
parents:
diff changeset
314 llvm::Value *Size) = 0;
anatofuz
parents:
diff changeset
315 virtual llvm::Constant *BuildGCBlockLayout(CodeGen::CodeGenModule &CGM,
anatofuz
parents:
diff changeset
316 const CodeGen::CGBlockInfo &blockInfo) = 0;
anatofuz
parents:
diff changeset
317 virtual llvm::Constant *BuildRCBlockLayout(CodeGen::CodeGenModule &CGM,
anatofuz
parents:
diff changeset
318 const CodeGen::CGBlockInfo &blockInfo) = 0;
anatofuz
parents:
diff changeset
319 virtual std::string getRCBlockLayoutStr(CodeGen::CodeGenModule &CGM,
anatofuz
parents:
diff changeset
320 const CGBlockInfo &blockInfo) {
anatofuz
parents:
diff changeset
321 return {};
anatofuz
parents:
diff changeset
322 }
anatofuz
parents:
diff changeset
323
anatofuz
parents:
diff changeset
324 /// Returns an i8* which points to the byref layout information.
anatofuz
parents:
diff changeset
325 virtual llvm::Constant *BuildByrefLayout(CodeGen::CodeGenModule &CGM,
anatofuz
parents:
diff changeset
326 QualType T) = 0;
anatofuz
parents:
diff changeset
327
anatofuz
parents:
diff changeset
328 struct MessageSendInfo {
anatofuz
parents:
diff changeset
329 const CGFunctionInfo &CallInfo;
anatofuz
parents:
diff changeset
330 llvm::PointerType *MessengerType;
anatofuz
parents:
diff changeset
331
anatofuz
parents:
diff changeset
332 MessageSendInfo(const CGFunctionInfo &callInfo,
anatofuz
parents:
diff changeset
333 llvm::PointerType *messengerType)
anatofuz
parents:
diff changeset
334 : CallInfo(callInfo), MessengerType(messengerType) {}
anatofuz
parents:
diff changeset
335 };
anatofuz
parents:
diff changeset
336
anatofuz
parents:
diff changeset
337 MessageSendInfo getMessageSendInfo(const ObjCMethodDecl *method,
anatofuz
parents:
diff changeset
338 QualType resultType,
anatofuz
parents:
diff changeset
339 CallArgList &callArgs);
anatofuz
parents:
diff changeset
340
anatofuz
parents:
diff changeset
341 // FIXME: This probably shouldn't be here, but the code to compute
anatofuz
parents:
diff changeset
342 // it is here.
anatofuz
parents:
diff changeset
343 unsigned ComputeBitfieldBitOffset(CodeGen::CodeGenModule &CGM,
anatofuz
parents:
diff changeset
344 const ObjCInterfaceDecl *ID,
anatofuz
parents:
diff changeset
345 const ObjCIvarDecl *Ivar);
anatofuz
parents:
diff changeset
346 };
anatofuz
parents:
diff changeset
347
anatofuz
parents:
diff changeset
348 /// Creates an instance of an Objective-C runtime class.
anatofuz
parents:
diff changeset
349 //TODO: This should include some way of selecting which runtime to target.
anatofuz
parents:
diff changeset
350 CGObjCRuntime *CreateGNUObjCRuntime(CodeGenModule &CGM);
anatofuz
parents:
diff changeset
351 CGObjCRuntime *CreateMacObjCRuntime(CodeGenModule &CGM);
anatofuz
parents:
diff changeset
352 }
anatofuz
parents:
diff changeset
353 }
anatofuz
parents:
diff changeset
354 #endif