/Volumes/compiler/apple/swift/lib/AST/Builtins.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | //===--- Builtins.cpp - Swift Language Builtin ASTs -----------------------===// |
2 | | // |
3 | | // This source file is part of the Swift.org open source project |
4 | | // |
5 | | // Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors |
6 | | // Licensed under Apache License v2.0 with Runtime Library Exception |
7 | | // |
8 | | // See https://swift.org/LICENSE.txt for license information |
9 | | // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
10 | | // |
11 | | //===----------------------------------------------------------------------===// |
12 | | // |
13 | | // This file implements the interface to the Builtin APIs. |
14 | | // |
15 | | //===----------------------------------------------------------------------===// |
16 | | |
17 | | #include "swift/AST/Builtins.h" |
18 | | #include "swift/AST/ASTContext.h" |
19 | | #include "swift/AST/ASTSynthesis.h" |
20 | | #include "swift/AST/FileUnit.h" |
21 | | #include "swift/AST/Module.h" |
22 | | #include "swift/AST/ParameterList.h" |
23 | | #include "swift/AST/TypeCheckRequests.h" |
24 | | #include "swift/AST/Types.h" |
25 | | #include "swift/Strings.h" |
26 | | #include "llvm/ADT/SmallString.h" |
27 | | #include "llvm/ADT/StringSwitch.h" |
28 | | #include "llvm/IR/Attributes.h" |
29 | | #include "llvm/IR/Instructions.h" |
30 | | #include "llvm/IR/Intrinsics.h" |
31 | | #include "llvm/Support/ManagedStatic.h" |
32 | | #include <tuple> |
33 | | |
34 | | using namespace swift; |
35 | | |
36 | | struct BuiltinExtraInfoTy { |
37 | | const char *Attributes; |
38 | | }; |
39 | | |
40 | | static const BuiltinExtraInfoTy BuiltinExtraInfo[] = { |
41 | | {nullptr}, |
42 | | #define BUILTIN(Id, Name, Attrs) {Attrs}, |
43 | | #include "swift/AST/Builtins.def" |
44 | | }; |
45 | | |
46 | 261M | bool BuiltinInfo::isReadNone() const { |
47 | 261M | return strchr(BuiltinExtraInfo[(unsigned)ID].Attributes, 'n') != nullptr; |
48 | 261M | } |
49 | | |
50 | | const llvm::AttributeList & |
51 | 4.09M | IntrinsicInfo::getOrCreateAttributes(ASTContext &Ctx) const { |
52 | 4.09M | using DenseMapInfo = llvm::DenseMapInfo<llvm::AttributeList>; |
53 | 4.09M | if (DenseMapInfo::isEqual(Attrs, DenseMapInfo::getEmptyKey())) { |
54 | 21.3k | Attrs = llvm::Intrinsic::getAttributes(Ctx.getIntrinsicScratchContext(), ID); |
55 | 21.3k | } |
56 | 4.09M | return Attrs; |
57 | 4.09M | } |
58 | | |
59 | 1.12M | Type swift::getBuiltinType(ASTContext &Context, StringRef Name) { |
60 | | // Vectors are VecNxT, where "N" is the number of elements and |
61 | | // T is the element type. |
62 | 1.12M | if (Name.startswith("Vec")) { |
63 | 29.8k | Name = Name.substr(3); |
64 | 29.8k | StringRef::size_type xPos = Name.find('x'); |
65 | 29.8k | if (xPos == StringRef::npos) |
66 | 0 | return Type(); |
67 | | |
68 | 29.8k | unsigned numElements; |
69 | 29.8k | if (Name.substr(0, xPos).getAsInteger(10, numElements) || |
70 | 29.8k | numElements == 0 || numElements > 1024) |
71 | 0 | return Type(); |
72 | | |
73 | 29.8k | Type elementType = getBuiltinType(Context, Name.substr(xPos + 1)); |
74 | 29.8k | if (!elementType) |
75 | 0 | return Type(); |
76 | | |
77 | 29.8k | return BuiltinVectorType::get(Context, elementType, numElements); |
78 | 29.8k | } |
79 | | |
80 | 1.09M | if (Name == "RawPointer") |
81 | 42.2k | return Context.TheRawPointerType; |
82 | 1.05M | if (Name == "RawUnsafeContinuation") |
83 | 522 | return Context.TheRawUnsafeContinuationType; |
84 | 1.05M | if (Name == "Job") |
85 | 1.99k | return Context.TheJobType; |
86 | 1.04M | if (Name == "DefaultActorStorage") |
87 | 0 | return Context.TheDefaultActorStorageType; |
88 | 1.04M | if (Name == "NonDefaultDistributedActorStorage") |
89 | 0 | return Context.TheNonDefaultDistributedActorStorageType; |
90 | 1.04M | if (Name == "Executor") |
91 | 2.46k | return Context.TheExecutorType; |
92 | 1.04M | if (Name == "NativeObject") |
93 | 14.3k | return Context.TheNativeObjectType; |
94 | 1.03M | if (Name == "BridgeObject") |
95 | 14.8k | return Context.TheBridgeObjectType; |
96 | 1.01M | if (Name == "SILToken") |
97 | 1.14k | return Context.TheSILTokenType; |
98 | 1.01M | if (Name == "UnsafeValueBuffer") |
99 | 51 | return Context.TheUnsafeValueBufferType; |
100 | 1.01M | if (Name == "PackIndex") |
101 | 18 | return Context.ThePackIndexType; |
102 | | |
103 | 1.01M | if (Name == "FPIEEE32") |
104 | 17.6k | return Context.TheIEEE32Type; |
105 | 998k | if (Name == "FPIEEE64") |
106 | 19.5k | return Context.TheIEEE64Type; |
107 | | |
108 | 978k | if (Name == "Word") |
109 | 85.8k | return BuiltinIntegerType::getWordType(Context); |
110 | | |
111 | 892k | if (Name == "IntLiteral") |
112 | 69.9k | return Context.TheIntegerLiteralType; |
113 | | |
114 | | // Handle 'int8' and friends. |
115 | 822k | if (Name.substr(0, 3) == "Int") { |
116 | 515k | unsigned BitWidth; |
117 | 515k | if (!Name.substr(3).getAsInteger(10, BitWidth) && |
118 | 515k | BitWidth <= 2048 && BitWidth != 0) // Cap to prevent insane things. |
119 | 515k | return BuiltinIntegerType::get(BitWidth, Context); |
120 | 515k | } |
121 | | |
122 | | // Target specific FP types. |
123 | 307k | if (Name == "FPIEEE16") |
124 | 2.43k | return Context.TheIEEE16Type; |
125 | 304k | if (Name == "FPIEEE80") |
126 | 894 | return Context.TheIEEE80Type; |
127 | 304k | if (Name == "FPIEEE128") |
128 | 12 | return Context.TheIEEE128Type; |
129 | 304k | if (Name == "FPPPC128") |
130 | 0 | return Context.ThePPC128Type; |
131 | | |
132 | | // AnyObject is the empty class-constrained existential. |
133 | 304k | if (Name == "AnyObject") |
134 | 28.3k | return CanType( |
135 | 28.3k | ProtocolCompositionType::theAnyObjectType(Context)); |
136 | | |
137 | 275k | return Type(); |
138 | 304k | } |
139 | | |
140 | | /// getBuiltinBaseName - Decode the type list of a builtin (e.g. mul_Int32) and |
141 | | /// return the base name (e.g. "mul"). |
142 | | StringRef swift::getBuiltinBaseName(ASTContext &C, StringRef Name, |
143 | 570k | SmallVectorImpl<Type> &Types) { |
144 | | // builtin-id ::= operation-id ('_' type-id)* |
145 | 570k | for (StringRef::size_type Underscore = Name.find_last_of('_'); |
146 | 1.13M | Underscore != StringRef::npos; Underscore = Name.find_last_of('_')) { |
147 | | |
148 | | // Check that the type parameter is well-formed and set it up for returning. |
149 | | // This allows operations with underscores in them, like "icmp_eq". |
150 | 808k | Type Ty = getBuiltinType(C, Name.substr(Underscore + 1)); |
151 | 808k | if (Ty.isNull()) break; |
152 | | |
153 | 565k | Types.push_back(Ty); |
154 | | |
155 | 565k | Name = Name.substr(0, Underscore); |
156 | 565k | } |
157 | | |
158 | 570k | std::reverse(Types.begin(), Types.end()); |
159 | 570k | return Name; |
160 | 570k | } |
161 | | |
162 | | namespace { |
163 | | |
164 | | /// AST synthesizers (see ASTSynthesis.h for the general pattern) |
165 | | /// for generics. |
166 | | enum UnrestrictedGenericParam { _unrestricted }; |
167 | | |
168 | | /// A synthesizer which generates a conformance requirement. |
169 | | template <class TypeS, class ProtocolS> |
170 | | struct ConformsToSynthesizer { |
171 | | TypeS Type; |
172 | | ProtocolS Protocol; |
173 | | }; |
174 | | template <class TypeS, class ProtocolS> |
175 | | constexpr ConformsToSynthesizer<TypeS, ProtocolS> |
176 | 75 | _conformsTo(TypeS type, ProtocolS protocol) { |
177 | 75 | return {type, protocol}; |
178 | 75 | } |
179 | | |
180 | | /// A synthesizer which generates a layout constraint requirement. |
181 | | template <class TypeS> |
182 | | struct LayoutConstraintSynthesizer { |
183 | | TypeS Type; |
184 | | LayoutConstraint Constraint; |
185 | | }; |
186 | | template <class TypeS> |
187 | | LayoutConstraintSynthesizer<TypeS> |
188 | 2.94k | _layout(TypeS type, LayoutConstraint constraint) { |
189 | 2.94k | return {type, constraint}; |
190 | 2.94k | } |
191 | 2.94k | static LayoutConstraint _classLayout() { |
192 | 2.94k | return LayoutConstraint::getLayoutConstraint(LayoutConstraintKind::Class); |
193 | 2.94k | } |
194 | | |
195 | | /// A synthesizer which generates a generic parameter list. |
196 | | template <class... ParamS> |
197 | | struct GenericParamListSynthesizer { |
198 | | VariadicSynthesizerStorage<ParamS...> Params; |
199 | | }; |
200 | | template <class... ParamS> |
201 | | constexpr GenericParamListSynthesizer<ParamS...> |
202 | 18.6k | _generics(ParamS... params) { |
203 | 18.6k | return {{params...}}; |
204 | 18.6k | } Builtins.cpp:_ZN12_GLOBAL__N_19_genericsIJNS_24UnrestrictedGenericParamEEEENS_27GenericParamListSynthesizerIJDpT_EEES4_ Line | Count | Source | 202 | 15.6k | _generics(ParamS... params) { | 203 | 15.6k | return {{params...}}; | 204 | 15.6k | } |
Builtins.cpp:_ZN12_GLOBAL__N_19_genericsIJNS_24UnrestrictedGenericParamES1_EEENS_27GenericParamListSynthesizerIJDpT_EEES4_ Line | Count | Source | 202 | 21 | _generics(ParamS... params) { | 203 | 21 | return {{params...}}; | 204 | 21 | } |
Builtins.cpp:_ZN12_GLOBAL__N_19_genericsIJNS_24UnrestrictedGenericParamENS_27LayoutConstraintSynthesizerIN5swift24TypeParamTypeSynthesizerEEEEEENS_27GenericParamListSynthesizerIJDpT_EEES8_ Line | Count | Source | 202 | 2.94k | _generics(ParamS... params) { | 203 | 2.94k | return {{params...}}; | 204 | 2.94k | } |
Builtins.cpp:_ZN12_GLOBAL__N_19_genericsIJNS_24UnrestrictedGenericParamENS_21ConformsToSynthesizerIN5swift24TypeParamTypeSynthesizerENS3_24SingletonTypeSynthesizerEEEEEENS_27GenericParamListSynthesizerIJDpT_EEES9_ Line | Count | Source | 202 | 75 | _generics(ParamS... params) { | 203 | 75 | return {{params...}}; | 204 | 75 | } |
|
205 | | |
206 | | struct CountGenericParameters { |
207 | | unsigned &Count; |
208 | | |
209 | 18.6k | void operator()(UnrestrictedGenericParam _) const { |
210 | 18.6k | Count++; |
211 | 18.6k | } |
212 | | |
213 | | template <class TypeS, class ProtoS> |
214 | 75 | void operator()(const ConformsToSynthesizer<TypeS, ProtoS> &_) const { |
215 | | // not a parameter |
216 | 75 | } |
217 | | |
218 | | template <class TypeS> |
219 | 2.94k | void operator()(const LayoutConstraintSynthesizer<TypeS> &_) const { |
220 | | // not a parameter |
221 | 2.94k | } |
222 | | }; |
223 | | |
224 | | } // end anonymous namespace |
225 | | |
226 | | static const char * const GenericParamNames[] = { |
227 | | "T", |
228 | | "U", |
229 | | "V", |
230 | | "W", |
231 | | "X", |
232 | | "Y", |
233 | | "Z" |
234 | | }; |
235 | | |
236 | | static GenericTypeParamDecl* |
237 | | createGenericParam(ASTContext &ctx, const char *name, unsigned index, |
238 | 24.7k | bool isParameterPack = false) { |
239 | 24.7k | ModuleDecl *M = ctx.TheBuiltinModule; |
240 | 24.7k | Identifier ident = ctx.getIdentifier(name); |
241 | 24.7k | return GenericTypeParamDecl::createImplicit( |
242 | 24.7k | &M->getMainFile(FileUnitKind::Builtin), ident, /*depth*/ 0, index, |
243 | 24.7k | isParameterPack); |
244 | 24.7k | } |
245 | | |
246 | | /// Create a generic parameter list with multiple generic parameters. |
247 | | static GenericParamList *getGenericParams(ASTContext &ctx, |
248 | | unsigned numParameters, |
249 | 23.8k | bool areParameterPacks = false) { |
250 | 23.8k | assert(numParameters <= std::size(GenericParamNames)); |
251 | | |
252 | 0 | SmallVector<GenericTypeParamDecl *, 2> genericParams; |
253 | 48.5k | for (unsigned i = 0; i != numParameters; ++i) |
254 | 24.7k | genericParams.push_back(createGenericParam(ctx, GenericParamNames[i], i, |
255 | 24.7k | areParameterPacks)); |
256 | | |
257 | 23.8k | auto paramList = GenericParamList::create(ctx, SourceLoc(), genericParams, |
258 | 23.8k | SourceLoc()); |
259 | 23.8k | return paramList; |
260 | 23.8k | } |
261 | | |
262 | | template <class... ParamsS> |
263 | | static GenericParamList *synthesizeGenericParamList(SynthesisContext &SC, |
264 | 18.6k | const GenericParamListSynthesizer<ParamsS...> ¶ms) { |
265 | 18.6k | unsigned count = 0; |
266 | 18.6k | params.Params.visit(CountGenericParameters{count}); |
267 | 18.6k | auto paramList = getGenericParams(SC.Context, count); |
268 | 18.6k | SC.GenericParams = paramList; |
269 | 18.6k | return paramList; |
270 | 18.6k | } Builtins.cpp:_ZL26synthesizeGenericParamListIJN12_GLOBAL__N_124UnrestrictedGenericParamEEEPN5swift16GenericParamListERNS2_16SynthesisContextERKNS0_27GenericParamListSynthesizerIJDpT_EEE Line | Count | Source | 264 | 15.6k | const GenericParamListSynthesizer<ParamsS...> ¶ms) { | 265 | 15.6k | unsigned count = 0; | 266 | 15.6k | params.Params.visit(CountGenericParameters{count}); | 267 | 15.6k | auto paramList = getGenericParams(SC.Context, count); | 268 | 15.6k | SC.GenericParams = paramList; | 269 | 15.6k | return paramList; | 270 | 15.6k | } |
Builtins.cpp:_ZL26synthesizeGenericParamListIJN12_GLOBAL__N_124UnrestrictedGenericParamES1_EEPN5swift16GenericParamListERNS2_16SynthesisContextERKNS0_27GenericParamListSynthesizerIJDpT_EEE Line | Count | Source | 264 | 21 | const GenericParamListSynthesizer<ParamsS...> ¶ms) { | 265 | 21 | unsigned count = 0; | 266 | 21 | params.Params.visit(CountGenericParameters{count}); | 267 | 21 | auto paramList = getGenericParams(SC.Context, count); | 268 | 21 | SC.GenericParams = paramList; | 269 | 21 | return paramList; | 270 | 21 | } |
Builtins.cpp:_ZL26synthesizeGenericParamListIJN12_GLOBAL__N_124UnrestrictedGenericParamENS0_27LayoutConstraintSynthesizerIN5swift24TypeParamTypeSynthesizerEEEEEPNS3_16GenericParamListERNS3_16SynthesisContextERKNS0_27GenericParamListSynthesizerIJDpT_EEE Line | Count | Source | 264 | 2.94k | const GenericParamListSynthesizer<ParamsS...> ¶ms) { | 265 | 2.94k | unsigned count = 0; | 266 | 2.94k | params.Params.visit(CountGenericParameters{count}); | 267 | 2.94k | auto paramList = getGenericParams(SC.Context, count); | 268 | 2.94k | SC.GenericParams = paramList; | 269 | 2.94k | return paramList; | 270 | 2.94k | } |
Builtins.cpp:_ZL26synthesizeGenericParamListIJN12_GLOBAL__N_124UnrestrictedGenericParamENS0_21ConformsToSynthesizerIN5swift24TypeParamTypeSynthesizerENS3_24SingletonTypeSynthesizerEEEEEPNS3_16GenericParamListERNS3_16SynthesisContextERKNS0_27GenericParamListSynthesizerIJDpT_EEE Line | Count | Source | 264 | 75 | const GenericParamListSynthesizer<ParamsS...> ¶ms) { | 265 | 75 | unsigned count = 0; | 266 | 75 | params.Params.visit(CountGenericParameters{count}); | 267 | 75 | auto paramList = getGenericParams(SC.Context, count); | 268 | 75 | SC.GenericParams = paramList; | 269 | 75 | return paramList; | 270 | 75 | } |
|
271 | | |
272 | | namespace { |
273 | | struct CollectGenericParams { |
274 | | SynthesisContext &SC; |
275 | | SmallVector<GenericTypeParamType *, 2> GenericParamTypes; |
276 | | SmallVector<Requirement, 2> AddedRequirements; |
277 | | |
278 | 18.6k | CollectGenericParams(SynthesisContext &SC) : SC(SC) { |
279 | 18.6k | for (auto gp : SC.GenericParams->getParams()) { |
280 | 18.6k | GenericParamTypes.push_back( |
281 | 18.6k | gp->getDeclaredInterfaceType()->castTo<GenericTypeParamType>()); |
282 | 18.6k | } |
283 | 18.6k | } |
284 | | |
285 | 18.6k | void operator()(UnrestrictedGenericParam _) {} |
286 | | |
287 | | template <class TypeS, class ProtoS> |
288 | 75 | void operator()(const ConformsToSynthesizer<TypeS, ProtoS> &conf) { |
289 | 75 | auto type = synthesizeType(SC, conf.Type); |
290 | 75 | auto protocolType = synthesizeType(SC, conf.Protocol); |
291 | 75 | AddedRequirements.push_back({RequirementKind::Conformance, |
292 | 75 | type, protocolType}); |
293 | 75 | } |
294 | | |
295 | | template <class TypeS> |
296 | 2.94k | void operator()(const LayoutConstraintSynthesizer<TypeS> &req) { |
297 | 2.94k | auto type = synthesizeType(SC, req.Type); |
298 | 2.94k | AddedRequirements.push_back({RequirementKind::Layout, |
299 | 2.94k | type, req.Constraint}); |
300 | 2.94k | } |
301 | | }; |
302 | | |
303 | | } // end anonymous namespace |
304 | | |
305 | | template <class... ParamsS> |
306 | | static GenericSignature |
307 | | synthesizeGenericSignature(SynthesisContext &SC, |
308 | 18.6k | const GenericParamListSynthesizer<ParamsS...> &list) { |
309 | 18.6k | assert(SC.GenericParams && "synthesizeGenericParamList not called first"); |
310 | 0 | CollectGenericParams collector(SC); |
311 | 18.6k | list.Params.visit(collector); |
312 | | |
313 | 18.6k | return buildGenericSignature(SC.Context, |
314 | 18.6k | GenericSignature(), |
315 | 18.6k | std::move(collector.GenericParamTypes), |
316 | 18.6k | std::move(collector.AddedRequirements)); |
317 | 18.6k | } Builtins.cpp:_ZL26synthesizeGenericSignatureIJN12_GLOBAL__N_124UnrestrictedGenericParamEEEN5swift16GenericSignatureERNS2_16SynthesisContextERKNS0_27GenericParamListSynthesizerIJDpT_EEE Line | Count | Source | 308 | 15.6k | const GenericParamListSynthesizer<ParamsS...> &list) { | 309 | 15.6k | assert(SC.GenericParams && "synthesizeGenericParamList not called first"); | 310 | 0 | CollectGenericParams collector(SC); | 311 | 15.6k | list.Params.visit(collector); | 312 | | | 313 | 15.6k | return buildGenericSignature(SC.Context, | 314 | 15.6k | GenericSignature(), | 315 | 15.6k | std::move(collector.GenericParamTypes), | 316 | 15.6k | std::move(collector.AddedRequirements)); | 317 | 15.6k | } |
Builtins.cpp:_ZL26synthesizeGenericSignatureIJN12_GLOBAL__N_124UnrestrictedGenericParamES1_EEN5swift16GenericSignatureERNS2_16SynthesisContextERKNS0_27GenericParamListSynthesizerIJDpT_EEE Line | Count | Source | 308 | 21 | const GenericParamListSynthesizer<ParamsS...> &list) { | 309 | 21 | assert(SC.GenericParams && "synthesizeGenericParamList not called first"); | 310 | 0 | CollectGenericParams collector(SC); | 311 | 21 | list.Params.visit(collector); | 312 | | | 313 | 21 | return buildGenericSignature(SC.Context, | 314 | 21 | GenericSignature(), | 315 | 21 | std::move(collector.GenericParamTypes), | 316 | 21 | std::move(collector.AddedRequirements)); | 317 | 21 | } |
Builtins.cpp:_ZL26synthesizeGenericSignatureIJN12_GLOBAL__N_124UnrestrictedGenericParamENS0_27LayoutConstraintSynthesizerIN5swift24TypeParamTypeSynthesizerEEEEENS3_16GenericSignatureERNS3_16SynthesisContextERKNS0_27GenericParamListSynthesizerIJDpT_EEE Line | Count | Source | 308 | 2.94k | const GenericParamListSynthesizer<ParamsS...> &list) { | 309 | 2.94k | assert(SC.GenericParams && "synthesizeGenericParamList not called first"); | 310 | 0 | CollectGenericParams collector(SC); | 311 | 2.94k | list.Params.visit(collector); | 312 | | | 313 | 2.94k | return buildGenericSignature(SC.Context, | 314 | 2.94k | GenericSignature(), | 315 | 2.94k | std::move(collector.GenericParamTypes), | 316 | 2.94k | std::move(collector.AddedRequirements)); | 317 | 2.94k | } |
Builtins.cpp:_ZL26synthesizeGenericSignatureIJN12_GLOBAL__N_124UnrestrictedGenericParamENS0_21ConformsToSynthesizerIN5swift24TypeParamTypeSynthesizerENS3_24SingletonTypeSynthesizerEEEEENS3_16GenericSignatureERNS3_16SynthesisContextERKNS0_27GenericParamListSynthesizerIJDpT_EEE Line | Count | Source | 308 | 75 | const GenericParamListSynthesizer<ParamsS...> &list) { | 309 | 75 | assert(SC.GenericParams && "synthesizeGenericParamList not called first"); | 310 | 0 | CollectGenericParams collector(SC); | 311 | 75 | list.Params.visit(collector); | 312 | | | 313 | 75 | return buildGenericSignature(SC.Context, | 314 | 75 | GenericSignature(), | 315 | 75 | std::move(collector.GenericParamTypes), | 316 | 75 | std::move(collector.AddedRequirements)); | 317 | 75 | } |
|
318 | | |
319 | | /// Build a builtin function declaration. |
320 | | /// |
321 | | /// This is a "legacy" interface; you should probably use one of |
322 | | /// the templated overloads below. |
323 | | static FuncDecl * |
324 | 7.78k | getBuiltinFunction(Identifier Id, ArrayRef<Type> argTypes, Type ResType) { |
325 | 7.78k | auto &Context = ResType->getASTContext(); |
326 | | |
327 | 7.78k | ModuleDecl *M = Context.TheBuiltinModule; |
328 | 7.78k | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); |
329 | | |
330 | 7.78k | SmallVector<ParamDecl*, 4> params; |
331 | 14.8k | for (Type argType : argTypes) { |
332 | 14.8k | auto PD = new (Context) ParamDecl(SourceLoc(), SourceLoc(), |
333 | 14.8k | Identifier(), SourceLoc(), Identifier(), DC); |
334 | 14.8k | PD->setSpecifier(ParamSpecifier::Default); |
335 | 14.8k | PD->setInterfaceType(argType); |
336 | 14.8k | PD->setImplicit(); |
337 | 14.8k | params.push_back(PD); |
338 | 14.8k | } |
339 | | |
340 | 7.78k | auto *paramList = ParameterList::create(Context, params); |
341 | | |
342 | 7.78k | DeclName Name(Context, Id, paramList); |
343 | 7.78k | auto *const FD = FuncDecl::createImplicit( |
344 | 7.78k | Context, StaticSpellingKind::None, Name, /*NameLoc=*/SourceLoc(), |
345 | 7.78k | /*Async=*/false, /*Throws=*/false, /*thrownType=*/Type(), |
346 | 7.78k | /*GenericParams=*/nullptr, paramList, ResType, DC); |
347 | 7.78k | FD->setAccess(AccessLevel::Public); |
348 | 7.78k | return FD; |
349 | 7.78k | } |
350 | | |
351 | | template <class ExtInfoS, class ParamsS, class ResultS> |
352 | | static FuncDecl * |
353 | | getBuiltinFunctionImpl(SynthesisContext &SC, Identifier id, |
354 | | GenericParamList *genericParams, |
355 | | GenericSignature signature, |
356 | | const ExtInfoS &extInfoS, |
357 | | const ParamsS ¶msS, |
358 | 28.4k | const ResultS &resultS) { |
359 | 28.4k | auto params = synthesizeParameterList(SC, paramsS); |
360 | 28.4k | auto extInfo = synthesizeExtInfo(SC, extInfoS); |
361 | 28.4k | auto resultType = synthesizeType(SC, resultS); |
362 | | |
363 | 28.4k | DeclName name(SC.Context, id, params); |
364 | 28.4k | auto *FD = FuncDecl::createImplicit( |
365 | 28.4k | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), |
366 | 28.4k | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), |
367 | 28.4k | genericParams, params, resultType, SC.DC); |
368 | 28.4k | FD->setAccess(AccessLevel::Public); |
369 | 28.4k | FD->setGenericSignature(signature); |
370 | 28.4k | return FD; |
371 | 28.4k | } Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJEEENS0_22IntegerTypeSynthesizerEEPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 6 | const ResultS &resultS) { | 359 | 6 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 6 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 6 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 6 | DeclName name(SC.Context, id, params); | 364 | 6 | auto *FD = FuncDecl::createImplicit( | 365 | 6 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 6 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 6 | genericParams, params, resultType, SC.DC); | 368 | 6 | FD->setAccess(AccessLevel::Public); | 369 | 6 | FD->setGenericSignature(signature); | 370 | 6 | return FD; | 371 | 6 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJEEENS0_24SingletonTypeSynthesizerEEPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 45 | const ResultS &resultS) { | 359 | 45 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 45 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 45 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 45 | DeclName name(SC.Context, id, params); | 364 | 45 | auto *FD = FuncDecl::createImplicit( | 365 | 45 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 45 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 45 | genericParams, params, resultType, SC.DC); | 368 | 45 | FD->setAccess(AccessLevel::Public); | 369 | 45 | FD->setGenericSignature(signature); | 370 | 45 | return FD; | 371 | 45 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerENS0_4TypeES4_EEENS0_16TupleSynthesizerIJS4_NS0_22IntegerTypeSynthesizerEEEEEPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 33 | const ResultS &resultS) { | 359 | 33 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 33 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 33 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 33 | DeclName name(SC.Context, id, params); | 364 | 33 | auto *FD = FuncDecl::createImplicit( | 365 | 33 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 33 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 33 | genericParams, params, resultType, SC.DC); | 368 | 33 | FD->setAccess(AccessLevel::Public); | 369 | 33 | FD->setGenericSignature(signature); | 370 | 33 | return FD; | 371 | 33 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerENS0_4TypeEEEES4_EPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 12 | const ResultS &resultS) { | 359 | 12 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 12 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 12 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 12 | DeclName name(SC.Context, id, params); | 364 | 12 | auto *FD = FuncDecl::createImplicit( | 365 | 12 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 12 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 12 | genericParams, params, resultType, SC.DC); | 368 | 12 | FD->setAccess(AccessLevel::Public); | 369 | 12 | FD->setGenericSignature(signature); | 370 | 12 | return FD; | 371 | 12 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerEEEENS0_4TypeEEPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 30 | const ResultS &resultS) { | 359 | 30 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 30 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 30 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 30 | DeclName name(SC.Context, id, params); | 364 | 30 | auto *FD = FuncDecl::createImplicit( | 365 | 30 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 30 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 30 | genericParams, params, resultType, SC.DC); | 368 | 30 | FD->setAccess(AccessLevel::Public); | 369 | 30 | FD->setGenericSignature(signature); | 370 | 30 | return FD; | 371 | 30 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerENS0_4TypeEEEES3_EPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 42 | const ResultS &resultS) { | 359 | 42 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 42 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 42 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 42 | DeclName name(SC.Context, id, params); | 364 | 42 | auto *FD = FuncDecl::createImplicit( | 365 | 42 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 42 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 42 | genericParams, params, resultType, SC.DC); | 368 | 42 | FD->setAccess(AccessLevel::Public); | 369 | 42 | FD->setGenericSignature(signature); | 370 | 42 | return FD; | 371 | 42 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_4TypeES3_EEES3_EPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 2.51k | const ResultS &resultS) { | 359 | 2.51k | auto params = synthesizeParameterList(SC, paramsS); | 360 | 2.51k | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 2.51k | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 2.51k | DeclName name(SC.Context, id, params); | 364 | 2.51k | auto *FD = FuncDecl::createImplicit( | 365 | 2.51k | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 2.51k | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 2.51k | genericParams, params, resultType, SC.DC); | 368 | 2.51k | FD->setAccess(AccessLevel::Public); | 369 | 2.51k | FD->setGenericSignature(signature); | 370 | 2.51k | return FD; | 371 | 2.51k | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerENS0_4TypeENS0_23MetatypeTypeSynthesizerINS0_24TypeParamTypeSynthesizerEEEEEES3_EPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 15 | const ResultS &resultS) { | 359 | 15 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 15 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 15 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 15 | DeclName name(SC.Context, id, params); | 364 | 15 | auto *FD = FuncDecl::createImplicit( | 365 | 15 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 15 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 15 | genericParams, params, resultType, SC.DC); | 368 | 15 | FD->setAccess(AccessLevel::Public); | 369 | 15 | FD->setGenericSignature(signature); | 370 | 15 | return FD; | 371 | 15 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerENS0_4TypeENS0_23MetatypeTypeSynthesizerINS0_24TypeParamTypeSynthesizerEEES7_EEES3_EPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 6 | const ResultS &resultS) { | 359 | 6 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 6 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 6 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 6 | DeclName name(SC.Context, id, params); | 364 | 6 | auto *FD = FuncDecl::createImplicit( | 365 | 6 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 6 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 6 | genericParams, params, resultType, SC.DC); | 368 | 6 | FD->setAccess(AccessLevel::Public); | 369 | 6 | FD->setGenericSignature(signature); | 370 | 6 | return FD; | 371 | 6 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerENS0_23MetatypeTypeSynthesizerINS0_24TypeParamTypeSynthesizerEEEEEES3_EPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 17 | const ResultS &resultS) { | 359 | 17 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 17 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 17 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 17 | DeclName name(SC.Context, id, params); | 364 | 17 | auto *FD = FuncDecl::createImplicit( | 365 | 17 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 17 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 17 | genericParams, params, resultType, SC.DC); | 368 | 17 | FD->setAccess(AccessLevel::Public); | 369 | 17 | FD->setGenericSignature(signature); | 370 | 17 | return FD; | 371 | 17 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerES3_NS0_23MetatypeTypeSynthesizerINS0_24TypeParamTypeSynthesizerEEEEEES3_EPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 24 | const ResultS &resultS) { | 359 | 24 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 24 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 24 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 24 | DeclName name(SC.Context, id, params); | 364 | 24 | auto *FD = FuncDecl::createImplicit( | 365 | 24 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 24 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 24 | genericParams, params, resultType, SC.DC); | 368 | 24 | FD->setAccess(AccessLevel::Public); | 369 | 24 | FD->setGenericSignature(signature); | 370 | 24 | return FD; | 371 | 24 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerEEEES3_EPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 213 | const ResultS &resultS) { | 359 | 213 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 213 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 213 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 213 | DeclName name(SC.Context, id, params); | 364 | 213 | auto *FD = FuncDecl::createImplicit( | 365 | 213 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 213 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 213 | genericParams, params, resultType, SC.DC); | 368 | 213 | FD->setAccess(AccessLevel::Public); | 369 | 213 | FD->setGenericSignature(signature); | 370 | 213 | return FD; | 371 | 213 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_24TypeParamTypeSynthesizerEEEES3_EPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 30 | const ResultS &resultS) { | 359 | 30 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 30 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 30 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 30 | DeclName name(SC.Context, id, params); | 364 | 30 | auto *FD = FuncDecl::createImplicit( | 365 | 30 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 30 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 30 | genericParams, params, resultType, SC.DC); | 368 | 30 | FD->setAccess(AccessLevel::Public); | 369 | 30 | FD->setGenericSignature(signature); | 370 | 30 | return FD; | 371 | 30 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerES3_EEES3_EPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 54 | const ResultS &resultS) { | 359 | 54 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 54 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 54 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 54 | DeclName name(SC.Context, id, params); | 364 | 54 | auto *FD = FuncDecl::createImplicit( | 365 | 54 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 54 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 54 | genericParams, params, resultType, SC.DC); | 368 | 54 | FD->setAccess(AccessLevel::Public); | 369 | 54 | FD->setGenericSignature(signature); | 370 | 54 | return FD; | 371 | 54 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_4TypeES3_NS0_22IntegerTypeSynthesizerEEEENS0_16TupleSynthesizerIJS3_S4_EEEEPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 786 | const ResultS &resultS) { | 359 | 786 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 786 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 786 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 786 | DeclName name(SC.Context, id, params); | 364 | 786 | auto *FD = FuncDecl::createImplicit( | 365 | 786 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 786 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 786 | genericParams, params, resultType, SC.DC); | 368 | 786 | FD->setAccess(AccessLevel::Public); | 369 | 786 | FD->setGenericSignature(signature); | 370 | 786 | return FD; | 371 | 786 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_4TypeES3_EEENS0_21VectorTypeSynthesizerINS0_22IntegerTypeSynthesizerEEEEPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 2.91k | const ResultS &resultS) { | 359 | 2.91k | auto params = synthesizeParameterList(SC, paramsS); | 360 | 2.91k | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 2.91k | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 2.91k | DeclName name(SC.Context, id, params); | 364 | 2.91k | auto *FD = FuncDecl::createImplicit( | 365 | 2.91k | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 2.91k | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 2.91k | genericParams, params, resultType, SC.DC); | 368 | 2.91k | FD->setAccess(AccessLevel::Public); | 369 | 2.91k | FD->setGenericSignature(signature); | 370 | 2.91k | return FD; | 371 | 2.91k | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_4TypeES3_EEENS0_22IntegerTypeSynthesizerEEPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 1.30k | const ResultS &resultS) { | 359 | 1.30k | auto params = synthesizeParameterList(SC, paramsS); | 360 | 1.30k | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 1.30k | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 1.30k | DeclName name(SC.Context, id, params); | 364 | 1.30k | auto *FD = FuncDecl::createImplicit( | 365 | 1.30k | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 1.30k | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 1.30k | genericParams, params, resultType, SC.DC); | 368 | 1.30k | FD->setAccess(AccessLevel::Public); | 369 | 1.30k | FD->setGenericSignature(signature); | 370 | 1.30k | return FD; | 371 | 1.30k | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_4TypeEEEES3_EPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 1.60k | const ResultS &resultS) { | 359 | 1.60k | auto params = synthesizeParameterList(SC, paramsS); | 360 | 1.60k | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 1.60k | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 1.60k | DeclName name(SC.Context, id, params); | 364 | 1.60k | auto *FD = FuncDecl::createImplicit( | 365 | 1.60k | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 1.60k | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 1.60k | genericParams, params, resultType, SC.DC); | 368 | 1.60k | FD->setAccess(AccessLevel::Public); | 369 | 1.60k | FD->setGenericSignature(signature); | 370 | 1.60k | return FD; | 371 | 1.60k | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_24TypeParamTypeSynthesizerEEEENS0_24SingletonTypeSynthesizerEEPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 3.09k | const ResultS &resultS) { | 359 | 3.09k | auto params = synthesizeParameterList(SC, paramsS); | 360 | 3.09k | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 3.09k | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 3.09k | DeclName name(SC.Context, id, params); | 364 | 3.09k | auto *FD = FuncDecl::createImplicit( | 365 | 3.09k | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 3.09k | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 3.09k | genericParams, params, resultType, SC.DC); | 368 | 3.09k | FD->setAccess(AccessLevel::Public); | 369 | 3.09k | FD->setGenericSignature(signature); | 370 | 3.09k | return FD; | 371 | 3.09k | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerEEEENS0_24TypeParamTypeSynthesizerEEPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 51 | const ResultS &resultS) { | 359 | 51 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 51 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 51 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 51 | DeclName name(SC.Context, id, params); | 364 | 51 | auto *FD = FuncDecl::createImplicit( | 365 | 51 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 51 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 51 | genericParams, params, resultType, SC.DC); | 368 | 51 | FD->setAccess(AccessLevel::Public); | 369 | 51 | FD->setGenericSignature(signature); | 370 | 51 | return FD; | 371 | 51 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_23MetatypeTypeSynthesizerINS0_24TypeParamTypeSynthesizerEEENS0_24SingletonTypeSynthesizerEEEES6_EPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 9 | const ResultS &resultS) { | 359 | 9 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 9 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 9 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 9 | DeclName name(SC.Context, id, params); | 364 | 9 | auto *FD = FuncDecl::createImplicit( | 365 | 9 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 9 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 9 | genericParams, params, resultType, SC.DC); | 368 | 9 | FD->setAccess(AccessLevel::Public); | 369 | 9 | FD->setGenericSignature(signature); | 370 | 9 | return FD; | 371 | 9 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_25SpecifiedParamSynthesizerINS0_24TypeParamTypeSynthesizerEEENS0_24SingletonTypeSynthesizerEEEES6_EPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 108 | const ResultS &resultS) { | 359 | 108 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 108 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 108 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 108 | DeclName name(SC.Context, id, params); | 364 | 108 | auto *FD = FuncDecl::createImplicit( | 365 | 108 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 108 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 108 | genericParams, params, resultType, SC.DC); | 368 | 108 | FD->setAccess(AccessLevel::Public); | 369 | 108 | FD->setGenericSignature(signature); | 370 | 108 | return FD; | 371 | 108 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_23MetatypeTypeSynthesizerINS0_24TypeParamTypeSynthesizerEEENS0_24SingletonTypeSynthesizerES6_EEES6_EPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 2.01k | const ResultS &resultS) { | 359 | 2.01k | auto params = synthesizeParameterList(SC, paramsS); | 360 | 2.01k | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 2.01k | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 2.01k | DeclName name(SC.Context, id, params); | 364 | 2.01k | auto *FD = FuncDecl::createImplicit( | 365 | 2.01k | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 2.01k | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 2.01k | genericParams, params, resultType, SC.DC); | 368 | 2.01k | FD->setAccess(AccessLevel::Public); | 369 | 2.01k | FD->setGenericSignature(signature); | 370 | 2.01k | return FD; | 371 | 2.01k | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_23MetatypeTypeSynthesizerINS0_24TypeParamTypeSynthesizerEEENS0_24SingletonTypeSynthesizerES6_S6_EEES6_EPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 6.44k | const ResultS &resultS) { | 359 | 6.44k | auto params = synthesizeParameterList(SC, paramsS); | 360 | 6.44k | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 6.44k | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 6.44k | DeclName name(SC.Context, id, params); | 364 | 6.44k | auto *FD = FuncDecl::createImplicit( | 365 | 6.44k | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 6.44k | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 6.44k | genericParams, params, resultType, SC.DC); | 368 | 6.44k | FD->setAccess(AccessLevel::Public); | 369 | 6.44k | FD->setGenericSignature(signature); | 370 | 6.44k | return FD; | 371 | 6.44k | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_25SpecifiedParamSynthesizerINS0_24TypeParamTypeSynthesizerEEEEEENS0_22IntegerTypeSynthesizerEEPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 75 | const ResultS &resultS) { | 359 | 75 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 75 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 75 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 75 | DeclName name(SC.Context, id, params); | 364 | 75 | auto *FD = FuncDecl::createImplicit( | 365 | 75 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 75 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 75 | genericParams, params, resultType, SC.DC); | 368 | 75 | FD->setAccess(AccessLevel::Public); | 369 | 75 | FD->setGenericSignature(signature); | 370 | 75 | return FD; | 371 | 75 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_25SpecifiedParamSynthesizerINS0_24TypeParamTypeSynthesizerEEEEEENS0_24SingletonTypeSynthesizerEEPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 15 | const ResultS &resultS) { | 359 | 15 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 15 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 15 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 15 | DeclName name(SC.Context, id, params); | 364 | 15 | auto *FD = FuncDecl::createImplicit( | 365 | 15 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 15 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 15 | genericParams, params, resultType, SC.DC); | 368 | 15 | FD->setAccess(AccessLevel::Public); | 369 | 15 | FD->setGenericSignature(signature); | 370 | 15 | return FD; | 371 | 15 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_24TypeParamTypeSynthesizerENS0_23MetatypeTypeSynthesizerIS3_EEEEENS0_24SingletonTypeSynthesizerEEPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 15 | const ResultS &resultS) { | 359 | 15 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 15 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 15 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 15 | DeclName name(SC.Context, id, params); | 364 | 15 | auto *FD = FuncDecl::createImplicit( | 365 | 15 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 15 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 15 | genericParams, params, resultType, SC.DC); | 368 | 15 | FD->setAccess(AccessLevel::Public); | 369 | 15 | FD->setGenericSignature(signature); | 370 | 15 | return FD; | 371 | 15 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_23MetatypeTypeSynthesizerINS0_24TypeParamTypeSynthesizerEEEEEENS0_24SingletonTypeSynthesizerEEPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 6.22k | const ResultS &resultS) { | 359 | 6.22k | auto params = synthesizeParameterList(SC, paramsS); | 360 | 6.22k | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 6.22k | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 6.22k | DeclName name(SC.Context, id, params); | 364 | 6.22k | auto *FD = FuncDecl::createImplicit( | 365 | 6.22k | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 6.22k | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 6.22k | genericParams, params, resultType, SC.DC); | 368 | 6.22k | FD->setAccess(AccessLevel::Public); | 369 | 6.22k | FD->setGenericSignature(signature); | 370 | 6.22k | return FD; | 371 | 6.22k | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_23MetatypeTypeSynthesizerINS0_24TypeParamTypeSynthesizerEEEEEENS0_22IntegerTypeSynthesizerEEPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 331 | const ResultS &resultS) { | 359 | 331 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 331 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 331 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 331 | DeclName name(SC.Context, id, params); | 364 | 331 | auto *FD = FuncDecl::createImplicit( | 365 | 331 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 331 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 331 | genericParams, params, resultType, SC.DC); | 368 | 331 | FD->setAccess(AccessLevel::Public); | 369 | 331 | FD->setGenericSignature(signature); | 370 | 331 | return FD; | 371 | 331 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_34ExistentialMetatypeTypeSynthesizerINS0_24SingletonTypeSynthesizerEEES5_EEENS0_22IntegerTypeSynthesizerEEPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 48 | const ResultS &resultS) { | 359 | 48 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 48 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 48 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 48 | DeclName name(SC.Context, id, params); | 364 | 48 | auto *FD = FuncDecl::createImplicit( | 365 | 48 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 48 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 48 | genericParams, params, resultType, SC.DC); | 368 | 48 | FD->setAccess(AccessLevel::Public); | 369 | 48 | FD->setGenericSignature(signature); | 370 | 48 | return FD; | 371 | 48 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerES3_S3_EEES3_EPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 60 | const ResultS &resultS) { | 359 | 60 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 60 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 60 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 60 | DeclName name(SC.Context, id, params); | 364 | 60 | auto *FD = FuncDecl::createImplicit( | 365 | 60 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 60 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 60 | genericParams, params, resultType, SC.DC); | 368 | 60 | FD->setAccess(AccessLevel::Public); | 369 | 60 | FD->setGenericSignature(signature); | 370 | 60 | return FD; | 371 | 60 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_25SpecifiedParamSynthesizerINS0_24SingletonTypeSynthesizerEEEEEENS0_24TypeParamTypeSynthesizerEEPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 24 | const ResultS &resultS) { | 359 | 24 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 24 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 24 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 24 | DeclName name(SC.Context, id, params); | 364 | 24 | auto *FD = FuncDecl::createImplicit( | 365 | 24 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 24 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 24 | genericParams, params, resultType, SC.DC); | 368 | 24 | FD->setAccess(AccessLevel::Public); | 369 | 24 | FD->setGenericSignature(signature); | 370 | 24 | return FD; | 371 | 24 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_4TypeEEEENS0_24SingletonTypeSynthesizerEEPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 12 | const ResultS &resultS) { | 359 | 12 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 12 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 12 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 12 | DeclName name(SC.Context, id, params); | 364 | 12 | auto *FD = FuncDecl::createImplicit( | 365 | 12 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 12 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 12 | genericParams, params, resultType, SC.DC); | 368 | 12 | FD->setAccess(AccessLevel::Public); | 369 | 12 | FD->setGenericSignature(signature); | 370 | 12 | return FD; | 371 | 12 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_4TypeEEEENS0_22IntegerTypeSynthesizerEEPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 12 | const ResultS &resultS) { | 359 | 12 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 12 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 12 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 12 | DeclName name(SC.Context, id, params); | 364 | 12 | auto *FD = FuncDecl::createImplicit( | 365 | 12 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 12 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 12 | genericParams, params, resultType, SC.DC); | 368 | 12 | FD->setAccess(AccessLevel::Public); | 369 | 12 | FD->setGenericSignature(signature); | 370 | 12 | return FD; | 371 | 12 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_4TypeENS0_24SingletonTypeSynthesizerEEEES4_EPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 12 | const ResultS &resultS) { | 359 | 12 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 12 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 12 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 12 | DeclName name(SC.Context, id, params); | 364 | 12 | auto *FD = FuncDecl::createImplicit( | 365 | 12 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 12 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 12 | genericParams, params, resultType, SC.DC); | 368 | 12 | FD->setAccess(AccessLevel::Public); | 369 | 12 | FD->setGenericSignature(signature); | 370 | 12 | return FD; | 371 | 12 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift16AsyncSynthesizerINS0_33FunctionRepresentationSynthesizerEEENS0_24ParameterListSynthesizerIJEEENS0_19OptionalSynthesizerINS0_24SingletonTypeSynthesizerEEEEPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 6 | const ResultS &resultS) { | 359 | 6 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 6 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 6 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 6 | DeclName name(SC.Context, id, params); | 364 | 6 | auto *FD = FuncDecl::createImplicit( | 365 | 6 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 6 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 6 | genericParams, params, resultType, SC.DC); | 368 | 6 | FD->setAccess(AccessLevel::Public); | 369 | 6 | FD->setGenericSignature(signature); | 370 | 6 | return FD; | 371 | 6 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_23FunctionTypeSynthesizerINS0_16AsyncSynthesizerINS0_19NoescapeSynthesizerIS1_EEEENS0_24TypeParamTypeSynthesizerENS2_IJEEEEEEEES8_EPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 9 | const ResultS &resultS) { | 359 | 9 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 9 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 9 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 9 | DeclName name(SC.Context, id, params); | 364 | 9 | auto *FD = FuncDecl::createImplicit( | 365 | 9 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 9 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 9 | genericParams, params, resultType, SC.DC); | 368 | 9 | FD->setAccess(AccessLevel::Public); | 369 | 9 | FD->setGenericSignature(signature); | 370 | 9 | return FD; | 371 | 9 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_25SpecifiedParamSynthesizerINS0_24SingletonTypeSynthesizerEEEEEES4_EPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 3 | const ResultS &resultS) { | 359 | 3 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 3 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 3 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 3 | DeclName name(SC.Context, id, params); | 364 | 3 | auto *FD = FuncDecl::createImplicit( | 365 | 3 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 3 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 3 | genericParams, params, resultType, SC.DC); | 368 | 3 | FD->setAccess(AccessLevel::Public); | 369 | 3 | FD->setGenericSignature(signature); | 370 | 3 | return FD; | 371 | 3 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerENS0_25SpecifiedParamSynthesizerINS0_24TypeParamTypeSynthesizerEEEEEES3_EPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 144 | const ResultS &resultS) { | 359 | 144 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 144 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 144 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 144 | DeclName name(SC.Context, id, params); | 364 | 144 | auto *FD = FuncDecl::createImplicit( | 365 | 144 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 144 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 144 | genericParams, params, resultType, SC.DC); | 368 | 144 | FD->setAccess(AccessLevel::Public); | 369 | 144 | FD->setGenericSignature(signature); | 370 | 144 | return FD; | 371 | 144 | } |
Builtins.cpp:_ZL22getBuiltinFunctionImplIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerENS0_25SpecifiedParamSynthesizerIS3_EEEEES3_EPNS0_8FuncDeclERNS0_16SynthesisContextENS0_10IdentifierEPNS0_16GenericParamListENS0_16GenericSignatureERKT_RKT0_RKT1_ Line | Count | Source | 358 | 45 | const ResultS &resultS) { | 359 | 45 | auto params = synthesizeParameterList(SC, paramsS); | 360 | 45 | auto extInfo = synthesizeExtInfo(SC, extInfoS); | 361 | 45 | auto resultType = synthesizeType(SC, resultS); | 362 | | | 363 | 45 | DeclName name(SC.Context, id, params); | 364 | 45 | auto *FD = FuncDecl::createImplicit( | 365 | 45 | SC.Context, StaticSpellingKind::None, name, /*NameLoc=*/SourceLoc(), | 366 | 45 | extInfo.isAsync(), extInfo.isThrowing(), /*thrownType=*/Type(), | 367 | 45 | genericParams, params, resultType, SC.DC); | 368 | 45 | FD->setAccess(AccessLevel::Public); | 369 | 45 | FD->setGenericSignature(signature); | 370 | 45 | return FD; | 371 | 45 | } |
|
372 | | |
373 | | /// Synthesize a non-generic builtin function declaration. |
374 | | template <class ExtInfoS, class ParamsS, class ResultS> |
375 | | static FuncDecl * |
376 | | getBuiltinFunction(ASTContext &ctx, Identifier id, |
377 | | const ExtInfoS &extInfoS, const ParamsS ¶msS, |
378 | 9.76k | const ResultS &resultS) { |
379 | 9.76k | ModuleDecl *M = ctx.TheBuiltinModule; |
380 | 9.76k | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); |
381 | | |
382 | 9.76k | SynthesisContext SC(ctx, DC); |
383 | 9.76k | return getBuiltinFunctionImpl(SC, id, nullptr, GenericSignature(), |
384 | 9.76k | extInfoS, paramsS, resultS); |
385 | 9.76k | } Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJEEENS0_22IntegerTypeSynthesizerEEPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_ Line | Count | Source | 378 | 6 | const ResultS &resultS) { | 379 | 6 | ModuleDecl *M = ctx.TheBuiltinModule; | 380 | 6 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 381 | | | 382 | 6 | SynthesisContext SC(ctx, DC); | 383 | 6 | return getBuiltinFunctionImpl(SC, id, nullptr, GenericSignature(), | 384 | 6 | extInfoS, paramsS, resultS); | 385 | 6 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJEEENS0_24SingletonTypeSynthesizerEEPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_ Line | Count | Source | 378 | 45 | const ResultS &resultS) { | 379 | 45 | ModuleDecl *M = ctx.TheBuiltinModule; | 380 | 45 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 381 | | | 382 | 45 | SynthesisContext SC(ctx, DC); | 383 | 45 | return getBuiltinFunctionImpl(SC, id, nullptr, GenericSignature(), | 384 | 45 | extInfoS, paramsS, resultS); | 385 | 45 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerENS0_4TypeES4_EEENS0_16TupleSynthesizerIJS4_NS0_22IntegerTypeSynthesizerEEEEEPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_ Line | Count | Source | 378 | 33 | const ResultS &resultS) { | 379 | 33 | ModuleDecl *M = ctx.TheBuiltinModule; | 380 | 33 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 381 | | | 382 | 33 | SynthesisContext SC(ctx, DC); | 383 | 33 | return getBuiltinFunctionImpl(SC, id, nullptr, GenericSignature(), | 384 | 33 | extInfoS, paramsS, resultS); | 385 | 33 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerENS0_4TypeEEEES4_EPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_ Line | Count | Source | 378 | 12 | const ResultS &resultS) { | 379 | 12 | ModuleDecl *M = ctx.TheBuiltinModule; | 380 | 12 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 381 | | | 382 | 12 | SynthesisContext SC(ctx, DC); | 383 | 12 | return getBuiltinFunctionImpl(SC, id, nullptr, GenericSignature(), | 384 | 12 | extInfoS, paramsS, resultS); | 385 | 12 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerEEEENS0_4TypeEEPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_ Line | Count | Source | 378 | 30 | const ResultS &resultS) { | 379 | 30 | ModuleDecl *M = ctx.TheBuiltinModule; | 380 | 30 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 381 | | | 382 | 30 | SynthesisContext SC(ctx, DC); | 383 | 30 | return getBuiltinFunctionImpl(SC, id, nullptr, GenericSignature(), | 384 | 30 | extInfoS, paramsS, resultS); | 385 | 30 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerENS0_4TypeEEEES3_EPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_ Line | Count | Source | 378 | 42 | const ResultS &resultS) { | 379 | 42 | ModuleDecl *M = ctx.TheBuiltinModule; | 380 | 42 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 381 | | | 382 | 42 | SynthesisContext SC(ctx, DC); | 383 | 42 | return getBuiltinFunctionImpl(SC, id, nullptr, GenericSignature(), | 384 | 42 | extInfoS, paramsS, resultS); | 385 | 42 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_4TypeES3_EEES3_EPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_ Line | Count | Source | 378 | 2.51k | const ResultS &resultS) { | 379 | 2.51k | ModuleDecl *M = ctx.TheBuiltinModule; | 380 | 2.51k | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 381 | | | 382 | 2.51k | SynthesisContext SC(ctx, DC); | 383 | 2.51k | return getBuiltinFunctionImpl(SC, id, nullptr, GenericSignature(), | 384 | 2.51k | extInfoS, paramsS, resultS); | 385 | 2.51k | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerEEEES3_EPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_ Line | Count | Source | 378 | 213 | const ResultS &resultS) { | 379 | 213 | ModuleDecl *M = ctx.TheBuiltinModule; | 380 | 213 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 381 | | | 382 | 213 | SynthesisContext SC(ctx, DC); | 383 | 213 | return getBuiltinFunctionImpl(SC, id, nullptr, GenericSignature(), | 384 | 213 | extInfoS, paramsS, resultS); | 385 | 213 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerES3_EEES3_EPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_ Line | Count | Source | 378 | 54 | const ResultS &resultS) { | 379 | 54 | ModuleDecl *M = ctx.TheBuiltinModule; | 380 | 54 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 381 | | | 382 | 54 | SynthesisContext SC(ctx, DC); | 383 | 54 | return getBuiltinFunctionImpl(SC, id, nullptr, GenericSignature(), | 384 | 54 | extInfoS, paramsS, resultS); | 385 | 54 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_4TypeES3_NS0_22IntegerTypeSynthesizerEEEENS0_16TupleSynthesizerIJS3_S4_EEEEPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_ Line | Count | Source | 378 | 786 | const ResultS &resultS) { | 379 | 786 | ModuleDecl *M = ctx.TheBuiltinModule; | 380 | 786 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 381 | | | 382 | 786 | SynthesisContext SC(ctx, DC); | 383 | 786 | return getBuiltinFunctionImpl(SC, id, nullptr, GenericSignature(), | 384 | 786 | extInfoS, paramsS, resultS); | 385 | 786 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_4TypeES3_EEENS0_21VectorTypeSynthesizerINS0_22IntegerTypeSynthesizerEEEEPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_ Line | Count | Source | 378 | 2.91k | const ResultS &resultS) { | 379 | 2.91k | ModuleDecl *M = ctx.TheBuiltinModule; | 380 | 2.91k | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 381 | | | 382 | 2.91k | SynthesisContext SC(ctx, DC); | 383 | 2.91k | return getBuiltinFunctionImpl(SC, id, nullptr, GenericSignature(), | 384 | 2.91k | extInfoS, paramsS, resultS); | 385 | 2.91k | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_4TypeES3_EEENS0_22IntegerTypeSynthesizerEEPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_ Line | Count | Source | 378 | 1.30k | const ResultS &resultS) { | 379 | 1.30k | ModuleDecl *M = ctx.TheBuiltinModule; | 380 | 1.30k | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 381 | | | 382 | 1.30k | SynthesisContext SC(ctx, DC); | 383 | 1.30k | return getBuiltinFunctionImpl(SC, id, nullptr, GenericSignature(), | 384 | 1.30k | extInfoS, paramsS, resultS); | 385 | 1.30k | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_4TypeEEEES3_EPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_ Line | Count | Source | 378 | 1.60k | const ResultS &resultS) { | 379 | 1.60k | ModuleDecl *M = ctx.TheBuiltinModule; | 380 | 1.60k | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 381 | | | 382 | 1.60k | SynthesisContext SC(ctx, DC); | 383 | 1.60k | return getBuiltinFunctionImpl(SC, id, nullptr, GenericSignature(), | 384 | 1.60k | extInfoS, paramsS, resultS); | 385 | 1.60k | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_34ExistentialMetatypeTypeSynthesizerINS0_24SingletonTypeSynthesizerEEES5_EEENS0_22IntegerTypeSynthesizerEEPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_ Line | Count | Source | 378 | 48 | const ResultS &resultS) { | 379 | 48 | ModuleDecl *M = ctx.TheBuiltinModule; | 380 | 48 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 381 | | | 382 | 48 | SynthesisContext SC(ctx, DC); | 383 | 48 | return getBuiltinFunctionImpl(SC, id, nullptr, GenericSignature(), | 384 | 48 | extInfoS, paramsS, resultS); | 385 | 48 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerES3_S3_EEES3_EPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_ Line | Count | Source | 378 | 60 | const ResultS &resultS) { | 379 | 60 | ModuleDecl *M = ctx.TheBuiltinModule; | 380 | 60 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 381 | | | 382 | 60 | SynthesisContext SC(ctx, DC); | 383 | 60 | return getBuiltinFunctionImpl(SC, id, nullptr, GenericSignature(), | 384 | 60 | extInfoS, paramsS, resultS); | 385 | 60 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_4TypeEEEENS0_24SingletonTypeSynthesizerEEPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_ Line | Count | Source | 378 | 12 | const ResultS &resultS) { | 379 | 12 | ModuleDecl *M = ctx.TheBuiltinModule; | 380 | 12 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 381 | | | 382 | 12 | SynthesisContext SC(ctx, DC); | 383 | 12 | return getBuiltinFunctionImpl(SC, id, nullptr, GenericSignature(), | 384 | 12 | extInfoS, paramsS, resultS); | 385 | 12 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_4TypeEEEENS0_22IntegerTypeSynthesizerEEPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_ Line | Count | Source | 378 | 12 | const ResultS &resultS) { | 379 | 12 | ModuleDecl *M = ctx.TheBuiltinModule; | 380 | 12 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 381 | | | 382 | 12 | SynthesisContext SC(ctx, DC); | 383 | 12 | return getBuiltinFunctionImpl(SC, id, nullptr, GenericSignature(), | 384 | 12 | extInfoS, paramsS, resultS); | 385 | 12 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_4TypeENS0_24SingletonTypeSynthesizerEEEES4_EPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_ Line | Count | Source | 378 | 12 | const ResultS &resultS) { | 379 | 12 | ModuleDecl *M = ctx.TheBuiltinModule; | 380 | 12 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 381 | | | 382 | 12 | SynthesisContext SC(ctx, DC); | 383 | 12 | return getBuiltinFunctionImpl(SC, id, nullptr, GenericSignature(), | 384 | 12 | extInfoS, paramsS, resultS); | 385 | 12 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift16AsyncSynthesizerINS0_33FunctionRepresentationSynthesizerEEENS0_24ParameterListSynthesizerIJEEENS0_19OptionalSynthesizerINS0_24SingletonTypeSynthesizerEEEEPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_ Line | Count | Source | 378 | 6 | const ResultS &resultS) { | 379 | 6 | ModuleDecl *M = ctx.TheBuiltinModule; | 380 | 6 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 381 | | | 382 | 6 | SynthesisContext SC(ctx, DC); | 383 | 6 | return getBuiltinFunctionImpl(SC, id, nullptr, GenericSignature(), | 384 | 6 | extInfoS, paramsS, resultS); | 385 | 6 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_25SpecifiedParamSynthesizerINS0_24SingletonTypeSynthesizerEEEEEES4_EPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_ Line | Count | Source | 378 | 3 | const ResultS &resultS) { | 379 | 3 | ModuleDecl *M = ctx.TheBuiltinModule; | 380 | 3 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 381 | | | 382 | 3 | SynthesisContext SC(ctx, DC); | 383 | 3 | return getBuiltinFunctionImpl(SC, id, nullptr, GenericSignature(), | 384 | 3 | extInfoS, paramsS, resultS); | 385 | 3 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerENS0_25SpecifiedParamSynthesizerIS3_EEEEES3_EPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_ Line | Count | Source | 378 | 45 | const ResultS &resultS) { | 379 | 45 | ModuleDecl *M = ctx.TheBuiltinModule; | 380 | 45 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 381 | | | 382 | 45 | SynthesisContext SC(ctx, DC); | 383 | 45 | return getBuiltinFunctionImpl(SC, id, nullptr, GenericSignature(), | 384 | 45 | extInfoS, paramsS, resultS); | 385 | 45 | } |
|
386 | | |
387 | | /// Synthesize a generic builtin function declaration. |
388 | | template <class ExtInfoS, class GenericsS, class ParamsS, class ResultS> |
389 | | static FuncDecl * |
390 | | getBuiltinFunction(ASTContext &ctx, Identifier id, |
391 | | const ExtInfoS &extInfoS, |
392 | | const GenericsS &genericsS, |
393 | | const ParamsS ¶msS, |
394 | 18.6k | const ResultS &resultS) { |
395 | 18.6k | ModuleDecl *M = ctx.TheBuiltinModule; |
396 | 18.6k | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); |
397 | | |
398 | 18.6k | SynthesisContext SC(ctx, DC); |
399 | 18.6k | auto genericParamList = synthesizeGenericParamList(SC, genericsS); |
400 | 18.6k | auto genericSignature = synthesizeGenericSignature(SC, genericsS); |
401 | | |
402 | 18.6k | return getBuiltinFunctionImpl(SC, id, genericParamList, genericSignature, |
403 | 18.6k | extInfoS, paramsS, resultS); |
404 | 18.6k | } Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerEN12_GLOBAL__N_127GenericParamListSynthesizerIJNS2_24UnrestrictedGenericParamEEEENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerENS0_4TypeENS0_23MetatypeTypeSynthesizerINS0_24TypeParamTypeSynthesizerEEEEEES7_EPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_RKT2_ Line | Count | Source | 394 | 15 | const ResultS &resultS) { | 395 | 15 | ModuleDecl *M = ctx.TheBuiltinModule; | 396 | 15 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 397 | | | 398 | 15 | SynthesisContext SC(ctx, DC); | 399 | 15 | auto genericParamList = synthesizeGenericParamList(SC, genericsS); | 400 | 15 | auto genericSignature = synthesizeGenericSignature(SC, genericsS); | 401 | | | 402 | 15 | return getBuiltinFunctionImpl(SC, id, genericParamList, genericSignature, | 403 | 15 | extInfoS, paramsS, resultS); | 404 | 15 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerEN12_GLOBAL__N_127GenericParamListSynthesizerIJNS2_24UnrestrictedGenericParamES4_EEENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerENS0_4TypeENS0_23MetatypeTypeSynthesizerINS0_24TypeParamTypeSynthesizerEEESB_EEES7_EPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_RKT2_ Line | Count | Source | 394 | 6 | const ResultS &resultS) { | 395 | 6 | ModuleDecl *M = ctx.TheBuiltinModule; | 396 | 6 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 397 | | | 398 | 6 | SynthesisContext SC(ctx, DC); | 399 | 6 | auto genericParamList = synthesizeGenericParamList(SC, genericsS); | 400 | 6 | auto genericSignature = synthesizeGenericSignature(SC, genericsS); | 401 | | | 402 | 6 | return getBuiltinFunctionImpl(SC, id, genericParamList, genericSignature, | 403 | 6 | extInfoS, paramsS, resultS); | 404 | 6 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerEN12_GLOBAL__N_127GenericParamListSynthesizerIJNS2_24UnrestrictedGenericParamEEEENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerENS0_23MetatypeTypeSynthesizerINS0_24TypeParamTypeSynthesizerEEEEEES7_EPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_RKT2_ Line | Count | Source | 394 | 17 | const ResultS &resultS) { | 395 | 17 | ModuleDecl *M = ctx.TheBuiltinModule; | 396 | 17 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 397 | | | 398 | 17 | SynthesisContext SC(ctx, DC); | 399 | 17 | auto genericParamList = synthesizeGenericParamList(SC, genericsS); | 400 | 17 | auto genericSignature = synthesizeGenericSignature(SC, genericsS); | 401 | | | 402 | 17 | return getBuiltinFunctionImpl(SC, id, genericParamList, genericSignature, | 403 | 17 | extInfoS, paramsS, resultS); | 404 | 17 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerEN12_GLOBAL__N_127GenericParamListSynthesizerIJNS2_24UnrestrictedGenericParamEEEENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerES7_NS0_23MetatypeTypeSynthesizerINS0_24TypeParamTypeSynthesizerEEEEEES7_EPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_RKT2_ Line | Count | Source | 394 | 24 | const ResultS &resultS) { | 395 | 24 | ModuleDecl *M = ctx.TheBuiltinModule; | 396 | 24 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 397 | | | 398 | 24 | SynthesisContext SC(ctx, DC); | 399 | 24 | auto genericParamList = synthesizeGenericParamList(SC, genericsS); | 400 | 24 | auto genericSignature = synthesizeGenericSignature(SC, genericsS); | 401 | | | 402 | 24 | return getBuiltinFunctionImpl(SC, id, genericParamList, genericSignature, | 403 | 24 | extInfoS, paramsS, resultS); | 404 | 24 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerEN12_GLOBAL__N_127GenericParamListSynthesizerIJNS2_24UnrestrictedGenericParamEEEENS0_24ParameterListSynthesizerIJNS0_24TypeParamTypeSynthesizerEEEES7_EPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_RKT2_ Line | Count | Source | 394 | 30 | const ResultS &resultS) { | 395 | 30 | ModuleDecl *M = ctx.TheBuiltinModule; | 396 | 30 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 397 | | | 398 | 30 | SynthesisContext SC(ctx, DC); | 399 | 30 | auto genericParamList = synthesizeGenericParamList(SC, genericsS); | 400 | 30 | auto genericSignature = synthesizeGenericSignature(SC, genericsS); | 401 | | | 402 | 30 | return getBuiltinFunctionImpl(SC, id, genericParamList, genericSignature, | 403 | 30 | extInfoS, paramsS, resultS); | 404 | 30 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerEN12_GLOBAL__N_127GenericParamListSynthesizerIJNS2_24UnrestrictedGenericParamEEEENS0_24ParameterListSynthesizerIJNS0_24TypeParamTypeSynthesizerEEEENS0_24SingletonTypeSynthesizerEEPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_RKT2_ Line | Count | Source | 394 | 78 | const ResultS &resultS) { | 395 | 78 | ModuleDecl *M = ctx.TheBuiltinModule; | 396 | 78 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 397 | | | 398 | 78 | SynthesisContext SC(ctx, DC); | 399 | 78 | auto genericParamList = synthesizeGenericParamList(SC, genericsS); | 400 | 78 | auto genericSignature = synthesizeGenericSignature(SC, genericsS); | 401 | | | 402 | 78 | return getBuiltinFunctionImpl(SC, id, genericParamList, genericSignature, | 403 | 78 | extInfoS, paramsS, resultS); | 404 | 78 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerEN12_GLOBAL__N_127GenericParamListSynthesizerIJNS2_24UnrestrictedGenericParamEEEENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerEEEENS0_24TypeParamTypeSynthesizerEEPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_RKT2_ Line | Count | Source | 394 | 51 | const ResultS &resultS) { | 395 | 51 | ModuleDecl *M = ctx.TheBuiltinModule; | 396 | 51 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 397 | | | 398 | 51 | SynthesisContext SC(ctx, DC); | 399 | 51 | auto genericParamList = synthesizeGenericParamList(SC, genericsS); | 400 | 51 | auto genericSignature = synthesizeGenericSignature(SC, genericsS); | 401 | | | 402 | 51 | return getBuiltinFunctionImpl(SC, id, genericParamList, genericSignature, | 403 | 51 | extInfoS, paramsS, resultS); | 404 | 51 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerEN12_GLOBAL__N_127GenericParamListSynthesizerIJNS2_24UnrestrictedGenericParamEEEENS0_24ParameterListSynthesizerIJNS0_23MetatypeTypeSynthesizerINS0_24TypeParamTypeSynthesizerEEENS0_24SingletonTypeSynthesizerEEEESA_EPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_RKT2_ Line | Count | Source | 394 | 9 | const ResultS &resultS) { | 395 | 9 | ModuleDecl *M = ctx.TheBuiltinModule; | 396 | 9 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 397 | | | 398 | 9 | SynthesisContext SC(ctx, DC); | 399 | 9 | auto genericParamList = synthesizeGenericParamList(SC, genericsS); | 400 | 9 | auto genericSignature = synthesizeGenericSignature(SC, genericsS); | 401 | | | 402 | 9 | return getBuiltinFunctionImpl(SC, id, genericParamList, genericSignature, | 403 | 9 | extInfoS, paramsS, resultS); | 404 | 9 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerEN12_GLOBAL__N_127GenericParamListSynthesizerIJNS2_24UnrestrictedGenericParamEEEENS0_24ParameterListSynthesizerIJNS0_25SpecifiedParamSynthesizerINS0_24TypeParamTypeSynthesizerEEENS0_24SingletonTypeSynthesizerEEEESA_EPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_RKT2_ Line | Count | Source | 394 | 108 | const ResultS &resultS) { | 395 | 108 | ModuleDecl *M = ctx.TheBuiltinModule; | 396 | 108 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 397 | | | 398 | 108 | SynthesisContext SC(ctx, DC); | 399 | 108 | auto genericParamList = synthesizeGenericParamList(SC, genericsS); | 400 | 108 | auto genericSignature = synthesizeGenericSignature(SC, genericsS); | 401 | | | 402 | 108 | return getBuiltinFunctionImpl(SC, id, genericParamList, genericSignature, | 403 | 108 | extInfoS, paramsS, resultS); | 404 | 108 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerEN12_GLOBAL__N_127GenericParamListSynthesizerIJNS2_24UnrestrictedGenericParamEEEENS0_24ParameterListSynthesizerIJNS0_23MetatypeTypeSynthesizerINS0_24TypeParamTypeSynthesizerEEENS0_24SingletonTypeSynthesizerESA_EEESA_EPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_RKT2_ Line | Count | Source | 394 | 2.01k | const ResultS &resultS) { | 395 | 2.01k | ModuleDecl *M = ctx.TheBuiltinModule; | 396 | 2.01k | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 397 | | | 398 | 2.01k | SynthesisContext SC(ctx, DC); | 399 | 2.01k | auto genericParamList = synthesizeGenericParamList(SC, genericsS); | 400 | 2.01k | auto genericSignature = synthesizeGenericSignature(SC, genericsS); | 401 | | | 402 | 2.01k | return getBuiltinFunctionImpl(SC, id, genericParamList, genericSignature, | 403 | 2.01k | extInfoS, paramsS, resultS); | 404 | 2.01k | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerEN12_GLOBAL__N_127GenericParamListSynthesizerIJNS2_24UnrestrictedGenericParamEEEENS0_24ParameterListSynthesizerIJNS0_23MetatypeTypeSynthesizerINS0_24TypeParamTypeSynthesizerEEENS0_24SingletonTypeSynthesizerESA_SA_EEESA_EPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_RKT2_ Line | Count | Source | 394 | 6.44k | const ResultS &resultS) { | 395 | 6.44k | ModuleDecl *M = ctx.TheBuiltinModule; | 396 | 6.44k | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 397 | | | 398 | 6.44k | SynthesisContext SC(ctx, DC); | 399 | 6.44k | auto genericParamList = synthesizeGenericParamList(SC, genericsS); | 400 | 6.44k | auto genericSignature = synthesizeGenericSignature(SC, genericsS); | 401 | | | 402 | 6.44k | return getBuiltinFunctionImpl(SC, id, genericParamList, genericSignature, | 403 | 6.44k | extInfoS, paramsS, resultS); | 404 | 6.44k | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerEN12_GLOBAL__N_127GenericParamListSynthesizerIJNS2_24UnrestrictedGenericParamEEEENS0_24ParameterListSynthesizerIJNS0_25SpecifiedParamSynthesizerINS0_24TypeParamTypeSynthesizerEEEEEENS0_22IntegerTypeSynthesizerEEPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_RKT2_ Line | Count | Source | 394 | 75 | const ResultS &resultS) { | 395 | 75 | ModuleDecl *M = ctx.TheBuiltinModule; | 396 | 75 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 397 | | | 398 | 75 | SynthesisContext SC(ctx, DC); | 399 | 75 | auto genericParamList = synthesizeGenericParamList(SC, genericsS); | 400 | 75 | auto genericSignature = synthesizeGenericSignature(SC, genericsS); | 401 | | | 402 | 75 | return getBuiltinFunctionImpl(SC, id, genericParamList, genericSignature, | 403 | 75 | extInfoS, paramsS, resultS); | 404 | 75 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerEN12_GLOBAL__N_127GenericParamListSynthesizerIJNS2_24UnrestrictedGenericParamEEEENS0_24ParameterListSynthesizerIJNS0_25SpecifiedParamSynthesizerINS0_24TypeParamTypeSynthesizerEEEEEENS0_24SingletonTypeSynthesizerEEPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_RKT2_ Line | Count | Source | 394 | 15 | const ResultS &resultS) { | 395 | 15 | ModuleDecl *M = ctx.TheBuiltinModule; | 396 | 15 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 397 | | | 398 | 15 | SynthesisContext SC(ctx, DC); | 399 | 15 | auto genericParamList = synthesizeGenericParamList(SC, genericsS); | 400 | 15 | auto genericSignature = synthesizeGenericSignature(SC, genericsS); | 401 | | | 402 | 15 | return getBuiltinFunctionImpl(SC, id, genericParamList, genericSignature, | 403 | 15 | extInfoS, paramsS, resultS); | 404 | 15 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerEN12_GLOBAL__N_127GenericParamListSynthesizerIJNS2_24UnrestrictedGenericParamES4_EEENS0_24ParameterListSynthesizerIJNS0_24TypeParamTypeSynthesizerENS0_23MetatypeTypeSynthesizerIS7_EEEEENS0_24SingletonTypeSynthesizerEEPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_RKT2_ Line | Count | Source | 394 | 15 | const ResultS &resultS) { | 395 | 15 | ModuleDecl *M = ctx.TheBuiltinModule; | 396 | 15 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 397 | | | 398 | 15 | SynthesisContext SC(ctx, DC); | 399 | 15 | auto genericParamList = synthesizeGenericParamList(SC, genericsS); | 400 | 15 | auto genericSignature = synthesizeGenericSignature(SC, genericsS); | 401 | | | 402 | 15 | return getBuiltinFunctionImpl(SC, id, genericParamList, genericSignature, | 403 | 15 | extInfoS, paramsS, resultS); | 404 | 15 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerEN12_GLOBAL__N_127GenericParamListSynthesizerIJNS2_24UnrestrictedGenericParamEEEENS0_24ParameterListSynthesizerIJNS0_23MetatypeTypeSynthesizerINS0_24TypeParamTypeSynthesizerEEEEEENS0_24SingletonTypeSynthesizerEEPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_RKT2_ Line | Count | Source | 394 | 6.22k | const ResultS &resultS) { | 395 | 6.22k | ModuleDecl *M = ctx.TheBuiltinModule; | 396 | 6.22k | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 397 | | | 398 | 6.22k | SynthesisContext SC(ctx, DC); | 399 | 6.22k | auto genericParamList = synthesizeGenericParamList(SC, genericsS); | 400 | 6.22k | auto genericSignature = synthesizeGenericSignature(SC, genericsS); | 401 | | | 402 | 6.22k | return getBuiltinFunctionImpl(SC, id, genericParamList, genericSignature, | 403 | 6.22k | extInfoS, paramsS, resultS); | 404 | 6.22k | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerEN12_GLOBAL__N_127GenericParamListSynthesizerIJNS2_24UnrestrictedGenericParamEEEENS0_24ParameterListSynthesizerIJNS0_23MetatypeTypeSynthesizerINS0_24TypeParamTypeSynthesizerEEEEEENS0_22IntegerTypeSynthesizerEEPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_RKT2_ Line | Count | Source | 394 | 331 | const ResultS &resultS) { | 395 | 331 | ModuleDecl *M = ctx.TheBuiltinModule; | 396 | 331 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 397 | | | 398 | 331 | SynthesisContext SC(ctx, DC); | 399 | 331 | auto genericParamList = synthesizeGenericParamList(SC, genericsS); | 400 | 331 | auto genericSignature = synthesizeGenericSignature(SC, genericsS); | 401 | | | 402 | 331 | return getBuiltinFunctionImpl(SC, id, genericParamList, genericSignature, | 403 | 331 | extInfoS, paramsS, resultS); | 404 | 331 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerEN12_GLOBAL__N_127GenericParamListSynthesizerIJNS2_24UnrestrictedGenericParamEEEENS0_24ParameterListSynthesizerIJNS0_25SpecifiedParamSynthesizerINS0_24SingletonTypeSynthesizerEEEEEENS0_24TypeParamTypeSynthesizerEEPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_RKT2_ Line | Count | Source | 394 | 24 | const ResultS &resultS) { | 395 | 24 | ModuleDecl *M = ctx.TheBuiltinModule; | 396 | 24 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 397 | | | 398 | 24 | SynthesisContext SC(ctx, DC); | 399 | 24 | auto genericParamList = synthesizeGenericParamList(SC, genericsS); | 400 | 24 | auto genericSignature = synthesizeGenericSignature(SC, genericsS); | 401 | | | 402 | 24 | return getBuiltinFunctionImpl(SC, id, genericParamList, genericSignature, | 403 | 24 | extInfoS, paramsS, resultS); | 404 | 24 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerEN12_GLOBAL__N_127GenericParamListSynthesizerIJNS2_24UnrestrictedGenericParamEEEENS0_24ParameterListSynthesizerIJNS0_23FunctionTypeSynthesizerINS0_16AsyncSynthesizerINS0_19NoescapeSynthesizerIS1_EEEENS0_24TypeParamTypeSynthesizerENS6_IJEEEEEEEESC_EPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_RKT2_ Line | Count | Source | 394 | 9 | const ResultS &resultS) { | 395 | 9 | ModuleDecl *M = ctx.TheBuiltinModule; | 396 | 9 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 397 | | | 398 | 9 | SynthesisContext SC(ctx, DC); | 399 | 9 | auto genericParamList = synthesizeGenericParamList(SC, genericsS); | 400 | 9 | auto genericSignature = synthesizeGenericSignature(SC, genericsS); | 401 | | | 402 | 9 | return getBuiltinFunctionImpl(SC, id, genericParamList, genericSignature, | 403 | 9 | extInfoS, paramsS, resultS); | 404 | 9 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerEN12_GLOBAL__N_127GenericParamListSynthesizerIJNS2_24UnrestrictedGenericParamENS2_27LayoutConstraintSynthesizerINS0_24TypeParamTypeSynthesizerEEEEEENS0_24ParameterListSynthesizerIJS6_EEENS0_24SingletonTypeSynthesizerEEPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_RKT2_ Line | Count | Source | 394 | 2.94k | const ResultS &resultS) { | 395 | 2.94k | ModuleDecl *M = ctx.TheBuiltinModule; | 396 | 2.94k | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 397 | | | 398 | 2.94k | SynthesisContext SC(ctx, DC); | 399 | 2.94k | auto genericParamList = synthesizeGenericParamList(SC, genericsS); | 400 | 2.94k | auto genericSignature = synthesizeGenericSignature(SC, genericsS); | 401 | | | 402 | 2.94k | return getBuiltinFunctionImpl(SC, id, genericParamList, genericSignature, | 403 | 2.94k | extInfoS, paramsS, resultS); | 404 | 2.94k | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerEN12_GLOBAL__N_127GenericParamListSynthesizerIJNS2_24UnrestrictedGenericParamENS2_21ConformsToSynthesizerINS0_24TypeParamTypeSynthesizerENS0_24SingletonTypeSynthesizerEEEEEENS0_24ParameterListSynthesizerIJS6_EEES7_EPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_RKT2_ Line | Count | Source | 394 | 75 | const ResultS &resultS) { | 395 | 75 | ModuleDecl *M = ctx.TheBuiltinModule; | 396 | 75 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 397 | | | 398 | 75 | SynthesisContext SC(ctx, DC); | 399 | 75 | auto genericParamList = synthesizeGenericParamList(SC, genericsS); | 400 | 75 | auto genericSignature = synthesizeGenericSignature(SC, genericsS); | 401 | | | 402 | 75 | return getBuiltinFunctionImpl(SC, id, genericParamList, genericSignature, | 403 | 75 | extInfoS, paramsS, resultS); | 404 | 75 | } |
Builtins.cpp:_ZL18getBuiltinFunctionIN5swift33FunctionRepresentationSynthesizerEN12_GLOBAL__N_127GenericParamListSynthesizerIJNS2_24UnrestrictedGenericParamEEEENS0_24ParameterListSynthesizerIJNS0_24SingletonTypeSynthesizerENS0_25SpecifiedParamSynthesizerINS0_24TypeParamTypeSynthesizerEEEEEES7_EPNS0_8FuncDeclERNS0_10ASTContextENS0_10IdentifierERKT_RKT0_RKT1_RKT2_ Line | Count | Source | 394 | 144 | const ResultS &resultS) { | 395 | 144 | ModuleDecl *M = ctx.TheBuiltinModule; | 396 | 144 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); | 397 | | | 398 | 144 | SynthesisContext SC(ctx, DC); | 399 | 144 | auto genericParamList = synthesizeGenericParamList(SC, genericsS); | 400 | 144 | auto genericSignature = synthesizeGenericSignature(SC, genericsS); | 401 | | | 402 | 144 | return getBuiltinFunctionImpl(SC, id, genericParamList, genericSignature, | 403 | 144 | extInfoS, paramsS, resultS); | 404 | 144 | } |
|
405 | | |
406 | | namespace { |
407 | | |
408 | | enum class BuiltinThrowsKind : uint8_t { |
409 | | None, |
410 | | Throws, |
411 | | Rethrows |
412 | | }; |
413 | | |
414 | | } |
415 | | |
416 | | /// Build a builtin function declaration. |
417 | | static FuncDecl * |
418 | | getBuiltinGenericFunction(Identifier Id, |
419 | | ArrayRef<AnyFunctionType::Param> ArgParamTypes, |
420 | | Type ResType, |
421 | | GenericParamList *GenericParams, |
422 | | GenericSignature Sig, |
423 | 5.21k | bool Async, BuiltinThrowsKind Throws) { |
424 | 5.21k | assert(GenericParams && "Missing generic parameters"); |
425 | 0 | auto &Context = ResType->getASTContext(); |
426 | | |
427 | 5.21k | ModuleDecl *M = Context.TheBuiltinModule; |
428 | 5.21k | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); |
429 | | |
430 | 5.21k | SmallVector<ParamDecl*, 4> params; |
431 | 11.9k | for (unsigned i = 0, e = ArgParamTypes.size(); i < e; ++i) { |
432 | 6.75k | auto paramIfaceType = ArgParamTypes[i].getPlainType(); |
433 | 6.75k | auto specifier = |
434 | 6.75k | ParamDecl::getParameterSpecifierForValueOwnership( |
435 | 6.75k | ArgParamTypes[i].getParameterFlags().getValueOwnership()); |
436 | 6.75k | auto PD = new (Context) ParamDecl(SourceLoc(), SourceLoc(), |
437 | 6.75k | Identifier(), SourceLoc(), |
438 | 6.75k | Identifier(), DC); |
439 | 6.75k | PD->setSpecifier(specifier); |
440 | 6.75k | PD->setInterfaceType(paramIfaceType); |
441 | 6.75k | PD->setImplicit(); |
442 | 6.75k | params.push_back(PD); |
443 | 6.75k | } |
444 | | |
445 | 5.21k | auto *paramList = ParameterList::create(Context, params); |
446 | | |
447 | 5.21k | DeclName Name(Context, Id, paramList); |
448 | 5.21k | auto *const func = FuncDecl::createImplicit( |
449 | 5.21k | Context, StaticSpellingKind::None, Name, |
450 | 5.21k | /*NameLoc=*/SourceLoc(), |
451 | 5.21k | Async, |
452 | 5.21k | Throws != BuiltinThrowsKind::None, /*thrownType=*/Type(), |
453 | 5.21k | GenericParams, paramList, ResType, DC); |
454 | | |
455 | 5.21k | func->setAccess(AccessLevel::Public); |
456 | 5.21k | func->setGenericSignature(Sig); |
457 | 5.21k | if (Throws == BuiltinThrowsKind::Rethrows) |
458 | 0 | func->getAttrs().add(new (Context) RethrowsAttr(/*ThrowsLoc*/ SourceLoc())); |
459 | | |
460 | 5.21k | return func; |
461 | 5.21k | } |
462 | | |
463 | | /// Build a getelementptr operation declaration. |
464 | | static ValueDecl *getGepRawOperation(ASTContext &ctx, |
465 | 27 | Identifier id, Type argType) { |
466 | | // This is always "(i8*, IntTy) -> i8*" |
467 | 27 | return getBuiltinFunction(ctx, id, _thin, |
468 | 27 | _parameters(_rawPointer, argType), |
469 | 27 | _rawPointer); |
470 | 27 | } |
471 | | |
472 | | static ValueDecl *getStringObjectOrOperation(ASTContext &ctx, |
473 | 30 | Identifier id, Type argType) { |
474 | 30 | return getBuiltinFunction(ctx, id, _thin, |
475 | 30 | _parameters(argType, argType), |
476 | 30 | argType); |
477 | 30 | } |
478 | | |
479 | | /// Build a binary operation declaration. |
480 | | static ValueDecl *getBinaryOperation(ASTContext &ctx, |
481 | 2.48k | Identifier id, Type argType) { |
482 | 2.48k | return getBuiltinFunction(ctx, id, _thin, |
483 | 2.48k | _parameters(argType, argType), |
484 | 2.48k | argType); |
485 | 2.48k | } |
486 | | |
487 | | /// Build a declaration for a binary operation with overflow. |
488 | | static ValueDecl *getBinaryOperationWithOverflow(ASTContext &ctx, |
489 | | Identifier id, |
490 | 786 | Type argType) { |
491 | 786 | return getBuiltinFunction(ctx, id, _thin, |
492 | 786 | _parameters(argType, argType, _int(1)), |
493 | 786 | _tuple(argType, _int(1))); |
494 | 786 | } |
495 | | |
496 | | static ValueDecl *getUnaryOperation(ASTContext &ctx, Identifier id, |
497 | 141 | Type argType) { |
498 | 141 | return getBuiltinFunction(ctx, id, _thin, _parameters(argType), argType); |
499 | 141 | } |
500 | | |
501 | | /// Build a binary predicate declaration. |
502 | | static ValueDecl *getBinaryPredicate(ASTContext &ctx, Identifier id, |
503 | 4.22k | Type argType) { |
504 | 4.22k | if (auto vecType = argType->getAs<BuiltinVectorType>()) { |
505 | 2.91k | return getBuiltinFunction(ctx, id, _thin, |
506 | 2.91k | _parameters(argType, argType), |
507 | 2.91k | _vector(vecType->getNumElements(), _int(1))); |
508 | 2.91k | } |
509 | | |
510 | 1.30k | return getBuiltinFunction(ctx, id, _thin, |
511 | 1.30k | _parameters(argType, argType), |
512 | 1.30k | _int(1)); |
513 | 4.22k | } |
514 | | |
515 | | /// Build a cast. There is some custom type checking here. |
516 | | static ValueDecl *getCastOperation(ASTContext &Context, Identifier Id, |
517 | | BuiltinValueKind VK, |
518 | 1.76k | ArrayRef<Type> Types) { |
519 | 1.76k | if (Types.empty() || Types.size() > 2) return nullptr; |
520 | 1.76k | Type Input = Types[0]; |
521 | 1.76k | Type Output = Types.size() == 2 ? Types[1] : Type(); |
522 | | |
523 | | // If both types are vectors, look through the vectors. |
524 | 1.76k | Type CheckInput = Input; |
525 | 1.76k | Type CheckOutput = Output; |
526 | 1.76k | bool UnwrappedVector = false; |
527 | 1.76k | auto InputVec = Input->getAs<BuiltinVectorType>(); |
528 | 1.76k | auto OutputVec = Output.isNull()? nullptr :Output->getAs<BuiltinVectorType>(); |
529 | 1.76k | if (InputVec && OutputVec && |
530 | 1.76k | InputVec->getNumElements() == OutputVec->getNumElements()) { |
531 | 219 | UnwrappedVector = true; |
532 | 219 | CheckInput = InputVec->getElementType(); |
533 | 219 | CheckOutput = OutputVec->getElementType(); |
534 | 219 | } |
535 | | |
536 | | // Custom type checking. We know the one or two types have been subjected to |
537 | | // the "isBuiltinTypeOverloaded" predicate successfully. |
538 | 1.76k | switch (VK) { |
539 | 0 | default: llvm_unreachable("Not a cast operation"); |
540 | |
|
541 | 153 | case BuiltinValueKind::Trunc: |
542 | 153 | if (CheckOutput.isNull() || |
543 | 153 | !CheckInput->is<BuiltinIntegerType>() || |
544 | 153 | !CheckOutput->is<BuiltinIntegerType>() || |
545 | 153 | CheckInput->castTo<BuiltinIntegerType>()->getLeastWidth() <= |
546 | 153 | CheckOutput->castTo<BuiltinIntegerType>()->getGreatestWidth()) |
547 | 90 | return nullptr; |
548 | 63 | break; |
549 | 222 | case BuiltinValueKind::TruncOrBitCast: |
550 | 222 | if (CheckOutput.isNull() || |
551 | 222 | !CheckInput->is<BuiltinIntegerType>() || |
552 | 222 | !CheckOutput->is<BuiltinIntegerType>() || |
553 | 222 | CheckInput->castTo<BuiltinIntegerType>()->getLeastWidth() < |
554 | 222 | CheckOutput->castTo<BuiltinIntegerType>()->getGreatestWidth()) |
555 | 60 | return nullptr; |
556 | 162 | break; |
557 | | |
558 | 189 | case BuiltinValueKind::ZExt: |
559 | 462 | case BuiltinValueKind::SExt: { |
560 | 462 | if (CheckOutput.isNull() || |
561 | 462 | !CheckInput->is<BuiltinIntegerType>() || |
562 | 462 | !CheckOutput->is<BuiltinIntegerType>() || |
563 | 462 | CheckInput->castTo<BuiltinIntegerType>()->getGreatestWidth() >= |
564 | 462 | CheckOutput->castTo<BuiltinIntegerType>()->getLeastWidth()) |
565 | 90 | return nullptr; |
566 | 372 | break; |
567 | 462 | } |
568 | 372 | case BuiltinValueKind::ZExtOrBitCast: |
569 | 324 | case BuiltinValueKind::SExtOrBitCast: { |
570 | 324 | if (CheckOutput.isNull() || |
571 | 324 | !CheckInput->is<BuiltinIntegerType>() || |
572 | 324 | !CheckOutput->is<BuiltinIntegerType>() || |
573 | 324 | CheckInput->castTo<BuiltinIntegerType>()->getGreatestWidth() > |
574 | 324 | CheckOutput->castTo<BuiltinIntegerType>()->getLeastWidth()) |
575 | 60 | return nullptr; |
576 | 264 | break; |
577 | 324 | } |
578 | | |
579 | 264 | case BuiltinValueKind::FPToUI: |
580 | 294 | case BuiltinValueKind::FPToSI: |
581 | 294 | if (CheckOutput.isNull() || !CheckInput->is<BuiltinFloatType>() || |
582 | 294 | !CheckOutput->is<BuiltinIntegerType>()) |
583 | 0 | return nullptr; |
584 | 294 | break; |
585 | | |
586 | 294 | case BuiltinValueKind::UIToFP: |
587 | 60 | case BuiltinValueKind::SIToFP: |
588 | 60 | if (CheckOutput.isNull() || !CheckInput->is<BuiltinIntegerType>() || |
589 | 60 | !CheckOutput->is<BuiltinFloatType>()) |
590 | 0 | return nullptr; |
591 | 60 | break; |
592 | | |
593 | 72 | case BuiltinValueKind::FPTrunc: |
594 | 72 | if (CheckOutput.isNull() || |
595 | 72 | !CheckInput->is<BuiltinFloatType>() || |
596 | 72 | !CheckOutput->is<BuiltinFloatType>() || |
597 | 72 | CheckInput->castTo<BuiltinFloatType>()->getFPKind() <= |
598 | 72 | CheckOutput->castTo<BuiltinFloatType>()->getFPKind()) |
599 | 0 | return nullptr; |
600 | 72 | break; |
601 | 72 | case BuiltinValueKind::FPExt: |
602 | 30 | if (CheckOutput.isNull() || |
603 | 30 | !CheckInput->is<BuiltinFloatType>() || |
604 | 30 | !CheckOutput->is<BuiltinFloatType>() || |
605 | 30 | CheckInput->castTo<BuiltinFloatType>()->getFPKind() >= |
606 | 30 | CheckOutput->castTo<BuiltinFloatType>()->getFPKind()) |
607 | 0 | return nullptr; |
608 | 30 | break; |
609 | | |
610 | 51 | case BuiltinValueKind::PtrToInt: |
611 | | // FIXME: Do we care about vectors of pointers? |
612 | 51 | if (!CheckOutput.isNull() || !CheckInput->is<BuiltinIntegerType>() || |
613 | 51 | UnwrappedVector) |
614 | 0 | return nullptr; |
615 | 51 | Output = Input; |
616 | 51 | Input = Context.TheRawPointerType; |
617 | 51 | break; |
618 | 39 | case BuiltinValueKind::IntToPtr: |
619 | | // FIXME: Do we care about vectors of pointers? |
620 | 39 | if (!CheckOutput.isNull() || !CheckInput->is<BuiltinIntegerType>() || |
621 | 39 | UnwrappedVector) |
622 | 0 | return nullptr; |
623 | 39 | Output = Context.TheRawPointerType; |
624 | 39 | break; |
625 | 54 | case BuiltinValueKind::BitCast: |
626 | 54 | if (CheckOutput.isNull()) return nullptr; |
627 | | |
628 | | // Support float <-> int bitcast where the types are the same widths. |
629 | 54 | if (auto *BIT = CheckInput->getAs<BuiltinIntegerType>()) |
630 | 24 | if (auto *BFT = CheckOutput->getAs<BuiltinFloatType>()) |
631 | 21 | if (BIT->isFixedWidth() && BIT->getFixedWidth() == BFT->getBitWidth()) |
632 | 21 | break; |
633 | 33 | if (auto *BFT = CheckInput->getAs<BuiltinFloatType>()) |
634 | 27 | if (auto *BIT = CheckOutput->getAs<BuiltinIntegerType>()) |
635 | 27 | if (BIT->isFixedWidth() && BIT->getFixedWidth() == BFT->getBitWidth()) |
636 | 27 | break; |
637 | | |
638 | | // Support VecNxInt1 -> IntN bitcast for SIMD comparison results. |
639 | 6 | if (auto *Vec = CheckInput->getAs<BuiltinVectorType>()) |
640 | 3 | if (auto *BIT = CheckOutput->getAs<BuiltinIntegerType>()) |
641 | 3 | if (auto *Element = Vec->getElementType()->getAs<BuiltinIntegerType>()) |
642 | 3 | if (Element->getFixedWidth() == 1 && |
643 | 3 | BIT->isFixedWidth() && |
644 | 3 | BIT->getFixedWidth() == Vec->getNumElements()) |
645 | 3 | break; |
646 | | // And IntN -> VecNxInt1 for SIMDMask random generators. |
647 | 3 | if (auto *Vec = CheckOutput->getAs<BuiltinVectorType>()) |
648 | 3 | if (auto *BIT = CheckInput->getAs<BuiltinIntegerType>()) |
649 | 3 | if (auto *Element = Vec->getElementType()->getAs<BuiltinIntegerType>()) |
650 | 3 | if (Element->getFixedWidth() == 1 && |
651 | 3 | BIT->isFixedWidth() && |
652 | 3 | BIT->getFixedWidth() == Vec->getNumElements()) |
653 | 3 | break; |
654 | | |
655 | | // FIXME: Implement bitcast typechecking. |
656 | 0 | llvm_unreachable("Bitcast not supported yet!"); |
657 | 0 | return nullptr; |
658 | 1.76k | } |
659 | | |
660 | 1.46k | return getBuiltinFunction(Context, Id, _thin, |
661 | 1.46k | _parameters(Input), |
662 | 1.46k | Output); |
663 | 1.76k | } |
664 | | |
665 | | namespace { |
666 | | class BuiltinFunctionBuilder { |
667 | | public: |
668 | | ASTContext &Context; |
669 | | |
670 | | private: |
671 | | GenericParamList *TheGenericParamList; |
672 | | SmallVector<AnyFunctionType::Param, 4> InterfaceParams; |
673 | | Type InterfaceResult; |
674 | | bool Async = false; |
675 | | BuiltinThrowsKind Throws = BuiltinThrowsKind::None; |
676 | | |
677 | | // Accumulate params and requirements here, so that we can call |
678 | | // `buildGenericSignature()` when `build()` is called. |
679 | | SmallVector<GenericTypeParamType *, 2> genericParamTypes; |
680 | | SmallVector<Requirement, 2> addedRequirements; |
681 | | |
682 | | public: |
683 | | BuiltinFunctionBuilder(ASTContext &ctx, unsigned numGenericParams = 1, |
684 | | bool wantsAdditionalAnyObjectRequirement = false, |
685 | | bool areParametersPacks = false) |
686 | 5.21k | : Context(ctx) { |
687 | 5.21k | TheGenericParamList = getGenericParams(ctx, numGenericParams, |
688 | 5.21k | areParametersPacks); |
689 | 5.21k | if (wantsAdditionalAnyObjectRequirement) { |
690 | 27 | Requirement req(RequirementKind::Conformance, |
691 | 27 | TheGenericParamList->getParams()[0]->getInterfaceType(), |
692 | 27 | ctx.getAnyObjectConstraint()); |
693 | 27 | addedRequirements.push_back(req); |
694 | 27 | } |
695 | 6.04k | for (auto gp : TheGenericParamList->getParams()) { |
696 | 6.04k | genericParamTypes.push_back( |
697 | 6.04k | gp->getDeclaredInterfaceType()->castTo<GenericTypeParamType>()); |
698 | 6.04k | } |
699 | 5.21k | } |
700 | | |
701 | | template <class G> |
702 | | void addParameter(const G &generator, |
703 | 6.75k | ParamSpecifier ownership = ParamSpecifier::Default) { |
704 | 6.75k | Type gTyIface = generator.build(*this); |
705 | 6.75k | auto flags = ParameterTypeFlags().withOwnershipSpecifier(ownership); |
706 | 6.75k | InterfaceParams.emplace_back(gTyIface, Identifier(), flags); |
707 | 6.75k | } Builtins.cpp:_ZN12_GLOBAL__N_122BuiltinFunctionBuilder12addParameterINS0_17MetatypeGeneratorINS0_18ParameterGeneratorEEEEEvRKT_N5swift14ParamSpecifierE Line | Count | Source | 703 | 2.02k | ParamSpecifier ownership = ParamSpecifier::Default) { | 704 | 2.02k | Type gTyIface = generator.build(*this); | 705 | 2.02k | auto flags = ParameterTypeFlags().withOwnershipSpecifier(ownership); | 706 | 2.02k | InterfaceParams.emplace_back(gTyIface, Identifier(), flags); | 707 | 2.02k | } |
Builtins.cpp:_ZN12_GLOBAL__N_122BuiltinFunctionBuilder12addParameterINS0_17ConcreteGeneratorEEEvRKT_N5swift14ParamSpecifierE Line | Count | Source | 703 | 3.16k | ParamSpecifier ownership = ParamSpecifier::Default) { | 704 | 3.16k | Type gTyIface = generator.build(*this); | 705 | 3.16k | auto flags = ParameterTypeFlags().withOwnershipSpecifier(ownership); | 706 | 3.16k | InterfaceParams.emplace_back(gTyIface, Identifier(), flags); | 707 | 3.16k | } |
Builtins.cpp:_ZN12_GLOBAL__N_122BuiltinFunctionBuilder12addParameterINS0_15LambdaGeneratorEEEvRKT_N5swift14ParamSpecifierE Line | Count | Source | 703 | 12 | ParamSpecifier ownership = ParamSpecifier::Default) { | 704 | 12 | Type gTyIface = generator.build(*this); | 705 | 12 | auto flags = ParameterTypeFlags().withOwnershipSpecifier(ownership); | 706 | 12 | InterfaceParams.emplace_back(gTyIface, Identifier(), flags); | 707 | 12 | } |
Builtins.cpp:_ZN12_GLOBAL__N_122BuiltinFunctionBuilder12addParameterINS0_18ParameterGeneratorEEEvRKT_N5swift14ParamSpecifierE Line | Count | Source | 703 | 1.54k | ParamSpecifier ownership = ParamSpecifier::Default) { | 704 | 1.54k | Type gTyIface = generator.build(*this); | 705 | 1.54k | auto flags = ParameterTypeFlags().withOwnershipSpecifier(ownership); | 706 | 1.54k | InterfaceParams.emplace_back(gTyIface, Identifier(), flags); | 707 | 1.54k | } |
Builtins.cpp:_ZN12_GLOBAL__N_122BuiltinFunctionBuilder12addParameterINS0_17MetatypeGeneratorINS0_15LambdaGeneratorEEEEEvRKT_N5swift14ParamSpecifierE Line | Count | Source | 703 | 9 | ParamSpecifier ownership = ParamSpecifier::Default) { | 704 | 9 | Type gTyIface = generator.build(*this); | 705 | 9 | auto flags = ParameterTypeFlags().withOwnershipSpecifier(ownership); | 706 | 9 | InterfaceParams.emplace_back(gTyIface, Identifier(), flags); | 707 | 9 | } |
|
708 | | |
709 | | template <class G> |
710 | 5.21k | void setResult(const G &generator) { |
711 | 5.21k | InterfaceResult = generator.build(*this); |
712 | 5.21k | } Builtins.cpp:_ZN12_GLOBAL__N_122BuiltinFunctionBuilder9setResultINS0_18ParameterGeneratorEEEvRKT_ Line | Count | Source | 710 | 1.70k | void setResult(const G &generator) { | 711 | 1.70k | InterfaceResult = generator.build(*this); | 712 | 1.70k | } |
Builtins.cpp:_ZN12_GLOBAL__N_122BuiltinFunctionBuilder9setResultINS0_15LambdaGeneratorEEEvRKT_ Line | Count | Source | 710 | 12 | void setResult(const G &generator) { | 711 | 12 | InterfaceResult = generator.build(*this); | 712 | 12 | } |
Builtins.cpp:_ZN12_GLOBAL__N_122BuiltinFunctionBuilder9setResultINS0_17ConcreteGeneratorEEEvRKT_ Line | Count | Source | 710 | 3.48k | void setResult(const G &generator) { | 711 | 3.48k | InterfaceResult = generator.build(*this); | 712 | 3.48k | } |
Builtins.cpp:_ZN12_GLOBAL__N_122BuiltinFunctionBuilder9setResultINS0_17MetatypeGeneratorINS0_18ParameterGeneratorEEEEEvRKT_ Line | Count | Source | 710 | 6 | void setResult(const G &generator) { | 711 | 6 | InterfaceResult = generator.build(*this); | 712 | 6 | } |
|
713 | | |
714 | | template <class G> |
715 | 31 | void addConformanceRequirement(const G &generator, ProtocolDecl *proto) { |
716 | 31 | Requirement req(RequirementKind::Conformance, |
717 | 31 | generator.build(*this), |
718 | 31 | proto->getDeclaredInterfaceType()); |
719 | 31 | addedRequirements.push_back(req); |
720 | 31 | } |
721 | | |
722 | 78 | void setAsync() { |
723 | 78 | Async = true; |
724 | 78 | } |
725 | | |
726 | 39 | void setThrows() { |
727 | 39 | Throws = BuiltinThrowsKind::Throws; |
728 | 39 | } |
729 | | |
730 | 0 | void setRethrows() { |
731 | 0 | Throws = BuiltinThrowsKind::Rethrows; |
732 | 0 | } |
733 | | |
734 | 5.21k | FuncDecl *build(Identifier name) { |
735 | 5.21k | auto GenericSig = buildGenericSignature( |
736 | 5.21k | Context, GenericSignature(), |
737 | 5.21k | std::move(genericParamTypes), |
738 | 5.21k | std::move(addedRequirements)); |
739 | 5.21k | return getBuiltinGenericFunction(name, InterfaceParams, |
740 | 5.21k | InterfaceResult, |
741 | 5.21k | TheGenericParamList, GenericSig, |
742 | 5.21k | Async, Throws); |
743 | 5.21k | } |
744 | | |
745 | | // Don't use these generator classes directly; call the make{...} |
746 | | // functions which follow this class. |
747 | | |
748 | | struct ConcreteGenerator { |
749 | | Type TheType; |
750 | 6.65k | Type build(BuiltinFunctionBuilder &builder) const { |
751 | 6.65k | return TheType; |
752 | 6.65k | } |
753 | | }; |
754 | | struct ParameterGenerator { |
755 | | unsigned Index; |
756 | 6.62k | Type build(BuiltinFunctionBuilder &builder) const { |
757 | 6.62k | return builder.TheGenericParamList->getParams()[Index] |
758 | 6.62k | ->getDeclaredInterfaceType(); |
759 | 6.62k | } |
760 | | }; |
761 | | struct LambdaGenerator { |
762 | | std::function<Type(BuiltinFunctionBuilder &)> TheFunction; |
763 | 45 | Type build(BuiltinFunctionBuilder &builder) const { |
764 | 45 | return TheFunction(builder); |
765 | 45 | } |
766 | | }; |
767 | | template <class T> |
768 | | struct MetatypeGenerator { |
769 | | T Object; |
770 | | llvm::Optional<MetatypeRepresentation> Repr; |
771 | 2.03k | Type build(BuiltinFunctionBuilder &builder) const { |
772 | 2.03k | return MetatypeType::get(Object.build(builder), Repr); |
773 | 2.03k | } Builtins.cpp:_ZNK12_GLOBAL__N_122BuiltinFunctionBuilder17MetatypeGeneratorINS0_18ParameterGeneratorEE5buildERS0_ Line | Count | Source | 771 | 2.02k | Type build(BuiltinFunctionBuilder &builder) const { | 772 | 2.02k | return MetatypeType::get(Object.build(builder), Repr); | 773 | 2.02k | } |
Builtins.cpp:_ZNK12_GLOBAL__N_122BuiltinFunctionBuilder17MetatypeGeneratorINS0_15LambdaGeneratorEE5buildERS0_ Line | Count | Source | 771 | 9 | Type build(BuiltinFunctionBuilder &builder) const { | 772 | 9 | return MetatypeType::get(Object.build(builder), Repr); | 773 | 9 | } |
|
774 | | }; |
775 | | template <class T> |
776 | | struct PackExpansionGenerator { |
777 | | T Object; |
778 | 9 | Type build(BuiltinFunctionBuilder &builder) const { |
779 | 9 | auto patternTy = Object.build(builder); |
780 | 9 | SmallVector<Type, 2> packs; |
781 | 9 | patternTy->getTypeParameterPacks(packs); |
782 | 9 | return PackExpansionType::get(patternTy, packs[0]); |
783 | 9 | } |
784 | | }; |
785 | | }; |
786 | | } // end anonymous namespace |
787 | | |
788 | | static BuiltinFunctionBuilder::ConcreteGenerator |
789 | 6.65k | makeConcrete(Type type) { |
790 | 6.65k | return { type }; |
791 | 6.65k | } |
792 | | |
793 | | static BuiltinFunctionBuilder::ParameterGenerator |
794 | 6.52k | makeGenericParam(unsigned index = 0) { |
795 | 6.52k | return { index }; |
796 | 6.52k | } |
797 | | |
798 | | template <class... Gs> |
799 | | static BuiltinFunctionBuilder::LambdaGenerator |
800 | 9 | makeTuple(const Gs & ...elementGenerators) { |
801 | 9 | return { |
802 | 9 | [=](BuiltinFunctionBuilder &builder) -> Type { |
803 | 9 | TupleTypeElt elts[] = { |
804 | 9 | elementGenerators.build(builder)... |
805 | 9 | }; |
806 | 9 | return TupleType::get(elts, builder.Context); |
807 | 9 | } |
808 | 9 | }; |
809 | 9 | } |
810 | | |
811 | | template <class... Gs> |
812 | | static BuiltinFunctionBuilder::LambdaGenerator |
813 | | makeBoundGenericType(NominalTypeDecl *decl, |
814 | | const Gs & ...argumentGenerators) { |
815 | | return { |
816 | | [=](BuiltinFunctionBuilder &builder) -> Type { |
817 | | Type args[] = { |
818 | | argumentGenerators.build(builder)... |
819 | | }; |
820 | | return BoundGenericType::get(decl, Type(), args); |
821 | | } |
822 | | }; |
823 | | } |
824 | | |
825 | | template <class T> |
826 | | static BuiltinFunctionBuilder::MetatypeGenerator<T> |
827 | | makeMetatype(const T &object, |
828 | 2.03k | llvm::Optional<MetatypeRepresentation> repr = llvm::None) { |
829 | 2.03k | return { object, repr }; |
830 | 2.03k | } Builtins.cpp:_ZL12makeMetatypeIN12_GLOBAL__N_122BuiltinFunctionBuilder18ParameterGeneratorEENS1_17MetatypeGeneratorIT_EERKS4_NSt3__18optionalIN5swift22MetatypeRepresentationEEE Line | Count | Source | 828 | 2.02k | llvm::Optional<MetatypeRepresentation> repr = llvm::None) { | 829 | 2.02k | return { object, repr }; | 830 | 2.02k | } |
Builtins.cpp:_ZL12makeMetatypeIN12_GLOBAL__N_122BuiltinFunctionBuilder15LambdaGeneratorEENS1_17MetatypeGeneratorIT_EERKS4_NSt3__18optionalIN5swift22MetatypeRepresentationEEE Line | Count | Source | 828 | 9 | llvm::Optional<MetatypeRepresentation> repr = llvm::None) { | 829 | 9 | return { object, repr }; | 830 | 9 | } |
|
831 | | |
832 | | template <class T> |
833 | | static BuiltinFunctionBuilder::PackExpansionGenerator<T> |
834 | 9 | makePackExpansion(const T &object) { |
835 | 9 | return { object }; |
836 | 9 | } |
837 | | |
838 | | /// Create a function with type <T> T -> (). |
839 | 63 | static ValueDecl *getRefCountingOperation(ASTContext &ctx, Identifier id) { |
840 | 63 | return getBuiltinFunction(ctx, id, _thin, |
841 | 63 | _generics(_unrestricted), |
842 | 63 | _parameters(_typeparam(0)), |
843 | 63 | _void); |
844 | 63 | } |
845 | | |
846 | 51 | static ValueDecl *getLoadOperation(ASTContext &ctx, Identifier id) { |
847 | 51 | return getBuiltinFunction(ctx, id, _thin, |
848 | 51 | _generics(_unrestricted), |
849 | 51 | _parameters(_rawPointer), |
850 | 51 | _typeparam(0)); |
851 | 51 | } |
852 | | |
853 | 81 | static ValueDecl *getStoreOperation(ASTContext &ctx, Identifier id) { |
854 | 81 | return getBuiltinFunction(ctx, id, _thin, |
855 | 81 | _generics(_unrestricted), |
856 | 81 | _parameters(_owned(_typeparam(0)), |
857 | 81 | _rawPointer), |
858 | 81 | _void); |
859 | 81 | } |
860 | | |
861 | 9 | static ValueDecl *getDestroyOperation(ASTContext &ctx, Identifier id) { |
862 | 9 | return getBuiltinFunction(ctx, id, _thin, |
863 | 9 | _generics(_unrestricted), |
864 | 9 | _parameters(_metatype(_typeparam(0)), |
865 | 9 | _rawPointer), |
866 | 9 | _void); |
867 | 9 | } |
868 | | |
869 | 2.01k | static ValueDecl *getDestroyArrayOperation(ASTContext &ctx, Identifier id) { |
870 | 2.01k | return getBuiltinFunction(ctx, id, _thin, |
871 | 2.01k | _generics(_unrestricted), |
872 | 2.01k | _parameters(_metatype(_typeparam(0)), |
873 | 2.01k | _rawPointer, |
874 | 2.01k | _word), |
875 | 2.01k | _void); |
876 | 2.01k | } |
877 | | |
878 | 30 | static ValueDecl *getCopyOperation(ASTContext &ctx, Identifier id) { |
879 | 30 | return getBuiltinFunction(ctx, id, _thin, _generics(_unrestricted), |
880 | 30 | _parameters(_typeparam(0)), _typeparam(0)); |
881 | 30 | } |
882 | | |
883 | 18 | static ValueDecl *getAssumeAlignment(ASTContext &ctx, Identifier id) { |
884 | | // This is always "(Builtin.RawPointer, Builtin.Word) -> Builtin.RawPointer" |
885 | 18 | return getBuiltinFunction(ctx, id, _thin, _parameters(_rawPointer, _word), |
886 | 18 | _rawPointer); |
887 | 18 | } |
888 | | |
889 | 6.44k | static ValueDecl *getTransferArrayOperation(ASTContext &ctx, Identifier id) { |
890 | 6.44k | return getBuiltinFunction(ctx, id, _thin, |
891 | 6.44k | _generics(_unrestricted), |
892 | 6.44k | _parameters(_metatype(_typeparam(0)), |
893 | 6.44k | _rawPointer, |
894 | 6.44k | _rawPointer, |
895 | 6.44k | _word), |
896 | 6.44k | _void); |
897 | 6.44k | } |
898 | | |
899 | 75 | static ValueDecl *getIsUniqueOperation(ASTContext &ctx, Identifier id) { |
900 | | // <T> (@inout T) -> Int1 |
901 | 75 | return getBuiltinFunction(ctx, id, _thin, |
902 | 75 | _generics(_unrestricted), |
903 | 75 | _parameters(_inout(_typeparam(0))), |
904 | 75 | _int(1)); |
905 | 75 | } |
906 | | |
907 | 15 | static ValueDecl *getEndCOWMutation(ASTContext &ctx, Identifier id) { |
908 | | // <T> (@inout T) -> () |
909 | 15 | return getBuiltinFunction(ctx, id, _thin, |
910 | 15 | _generics(_unrestricted), |
911 | 15 | _parameters(_inout(_typeparam(0))), |
912 | 15 | _void); |
913 | 15 | } |
914 | | |
915 | 15 | static ValueDecl *getBindMemoryOperation(ASTContext &ctx, Identifier id) { |
916 | 15 | FuncDecl *fd = getBuiltinFunction(ctx, id, _thin, |
917 | 15 | _generics(_unrestricted), |
918 | 15 | _parameters(_rawPointer, |
919 | 15 | _word, |
920 | 15 | _metatype(_typeparam(0))), |
921 | 15 | _word); |
922 | 15 | fd->getAttrs().add(new (ctx) DiscardableResultAttr(/*implicit*/true)); |
923 | 15 | return fd; |
924 | 15 | } |
925 | | |
926 | 15 | static ValueDecl *getRebindMemoryOperation(ASTContext &ctx, Identifier id) { |
927 | 15 | FuncDecl *fd = getBuiltinFunction(ctx, id, _thin, |
928 | 15 | _parameters(_rawPointer, |
929 | 15 | _word), |
930 | 15 | _word); |
931 | 15 | fd->getAttrs().add(new (ctx) DiscardableResultAttr(/*implicit*/true)); |
932 | 15 | return fd; |
933 | 15 | } |
934 | | |
935 | | static ValueDecl *getAllocWithTailElemsOperation(ASTContext &Context, |
936 | | Identifier Id, |
937 | 21 | int NumTailTypes) { |
938 | 21 | if (NumTailTypes < 1 || |
939 | 21 | 1 + NumTailTypes > (int)std::size(GenericParamNames)) |
940 | 0 | return nullptr; |
941 | 21 | BuiltinFunctionBuilder builder(Context, 1 + NumTailTypes); |
942 | 21 | builder.addParameter(makeMetatype(makeGenericParam(0))); |
943 | 54 | for (int Idx = 0; Idx < NumTailTypes; ++Idx) { |
944 | 33 | builder.addParameter(makeConcrete(BuiltinIntegerType::getWordType(Context))); |
945 | 33 | builder.addParameter(makeMetatype(makeGenericParam(Idx + 1))); |
946 | 33 | } |
947 | 21 | builder.setResult(makeGenericParam(0)); |
948 | 21 | return builder.build(Id); |
949 | 21 | } |
950 | | |
951 | | static ValueDecl *getProjectTailElemsOperation(ASTContext &ctx, |
952 | 15 | Identifier id) { |
953 | 15 | return getBuiltinFunction(ctx, id, _thin, |
954 | 15 | _generics(_unrestricted, _unrestricted), |
955 | 15 | _parameters(_typeparam(0), |
956 | 15 | _metatype(_typeparam(1))), |
957 | 15 | _rawPointer); |
958 | 15 | } |
959 | | |
960 | | /// Build a getelementptr operation declaration. |
961 | | static ValueDecl *getGepOperation(ASTContext &ctx, Identifier id, |
962 | 15 | Type argType) { |
963 | 15 | return getBuiltinFunction(ctx, id, _thin, |
964 | 15 | _generics(_unrestricted), |
965 | 15 | _parameters(_rawPointer, |
966 | 15 | argType, |
967 | 15 | _metatype(_typeparam(0))), |
968 | 15 | _rawPointer); |
969 | 15 | } |
970 | | |
971 | | static ValueDecl *getGetTailAddrOperation(ASTContext &ctx, Identifier id, |
972 | 6 | Type argType) { |
973 | 6 | return getBuiltinFunction(ctx, id, _thin, |
974 | 6 | _generics(_unrestricted, _unrestricted), |
975 | 6 | _parameters(_rawPointer, |
976 | 6 | argType, |
977 | 6 | _metatype(_typeparam(0)), |
978 | 6 | _metatype(_typeparam(1))), |
979 | 6 | _rawPointer); |
980 | 6 | } |
981 | | |
982 | | static ValueDecl *getBeginUnpairedAccessOperation(ASTContext &ctx, |
983 | 9 | Identifier id) { |
984 | 9 | return getBuiltinFunction(ctx, id, _thin, |
985 | 9 | _generics(_unrestricted), |
986 | 9 | _parameters(_rawPointer, |
987 | 9 | _rawPointer, |
988 | 9 | _metatype(_typeparam(0))), |
989 | 9 | _void); |
990 | 9 | } |
991 | | |
992 | | static ValueDecl * |
993 | | getPerformInstantaneousReadAccessOperation(ASTContext &ctx, |
994 | 9 | Identifier id) { |
995 | 9 | return getBuiltinFunction(ctx, id, _thin, |
996 | 9 | _generics(_unrestricted), |
997 | 9 | _parameters(_rawPointer, |
998 | 9 | _metatype(_typeparam(0))), |
999 | 9 | _void); |
1000 | 9 | } |
1001 | | |
1002 | | static ValueDecl *getEndUnpairedAccessOperation(ASTContext &ctx, |
1003 | 3 | Identifier id) { |
1004 | 3 | return getBuiltinFunction(ctx, id, _thin, |
1005 | 3 | _parameters(_rawPointer), |
1006 | 3 | _void); |
1007 | 3 | } |
1008 | | |
1009 | | static ValueDecl *getSizeOrAlignOfOperation(ASTContext &ctx, |
1010 | 6.17k | Identifier id) { |
1011 | 6.17k | return getBuiltinFunction(ctx, id, _thin, |
1012 | 6.17k | _generics(_unrestricted), |
1013 | 6.17k | _parameters(_metatype(_typeparam(0))), |
1014 | 6.17k | _word); |
1015 | 6.17k | } |
1016 | | |
1017 | 205 | static ValueDecl *getIsPODOperation(ASTContext &ctx, Identifier id) { |
1018 | 205 | return getBuiltinFunction(ctx, id, _thin, |
1019 | 205 | _generics(_unrestricted), |
1020 | 205 | _parameters(_metatype(_typeparam(0))), |
1021 | 205 | _int(1)); |
1022 | 205 | } |
1023 | | |
1024 | 87 | static ValueDecl *getIsConcrete(ASTContext &ctx, Identifier id) { |
1025 | 87 | return getBuiltinFunction(ctx, id, _thin, |
1026 | 87 | _generics(_unrestricted), |
1027 | 87 | _parameters(_metatype(_typeparam(0))), |
1028 | 87 | _int(1)); |
1029 | 87 | } |
1030 | | |
1031 | 21 | static ValueDecl *getIsBitwiseTakable(ASTContext &ctx, Identifier id) { |
1032 | 21 | return getBuiltinFunction(ctx, id, _thin, |
1033 | 21 | _generics(_unrestricted), |
1034 | 21 | _parameters(_metatype(_typeparam(0))), |
1035 | 21 | _int(1)); |
1036 | 21 | } |
1037 | | |
1038 | 18 | static ValueDecl *getIsOptionalOperation(ASTContext &ctx, Identifier id) { |
1039 | 18 | return getBuiltinFunction(ctx, id, _thin, |
1040 | 18 | _generics(_unrestricted), |
1041 | 18 | _parameters(_metatype(_typeparam(0))), |
1042 | 18 | _int(1)); |
1043 | 18 | } |
1044 | | |
1045 | 48 | static ValueDecl *getIsSameMetatypeOperation(ASTContext &ctx, Identifier id) { |
1046 | 48 | return getBuiltinFunction(ctx, id, _thin, |
1047 | 48 | _parameters(_existentialMetatype(_any), |
1048 | 48 | _existentialMetatype(_any)), |
1049 | 48 | _int(1)); |
1050 | 48 | } |
1051 | | |
1052 | 21 | static ValueDecl *getAllocOperation(ASTContext &ctx, Identifier id) { |
1053 | 21 | return getBuiltinFunction(ctx, id, _thin, |
1054 | 21 | _parameters(_word, _word), |
1055 | 21 | _rawPointer); |
1056 | 21 | } |
1057 | | |
1058 | 15 | static ValueDecl *getDeallocOperation(ASTContext &ctx, Identifier id) { |
1059 | 15 | return getBuiltinFunction(ctx, id, _thin, |
1060 | 15 | _parameters(_rawPointer, _word, _word), |
1061 | 15 | _void); |
1062 | 15 | } |
1063 | | |
1064 | 45 | static ValueDecl *getStackAllocOperation(ASTContext &ctx, Identifier id) { |
1065 | 45 | return getBuiltinFunction(ctx, id, _thin, |
1066 | 45 | _parameters(_word, _word, _word), |
1067 | 45 | _rawPointer); |
1068 | 45 | } |
1069 | | |
1070 | 27 | static ValueDecl *getStackDeallocOperation(ASTContext &ctx, Identifier id) { |
1071 | 27 | return getBuiltinFunction(ctx, id, _thin, |
1072 | 27 | _parameters(_rawPointer), |
1073 | 27 | _void); |
1074 | 27 | } |
1075 | | |
1076 | 9 | static ValueDecl *getFenceOperation(ASTContext &ctx, Identifier id) { |
1077 | 9 | return getBuiltinFunction(ctx, id, _thin, _parameters(), _void); |
1078 | 9 | } |
1079 | | |
1080 | 6 | static ValueDecl *getIfdefOperation(ASTContext &ctx, Identifier id) { |
1081 | 6 | return getBuiltinFunction(ctx, id, _thin, _parameters(), _int(1)); |
1082 | 6 | } |
1083 | | |
1084 | 93 | static ValueDecl *getVoidErrorOperation(ASTContext &ctx, Identifier id) { |
1085 | 93 | return getBuiltinFunction(ctx, id, _thin, _parameters(_error), _void); |
1086 | 93 | } |
1087 | | |
1088 | | static ValueDecl *getUnexpectedErrorOperation(ASTContext &ctx, |
1089 | 12 | Identifier id) { |
1090 | 12 | return getBuiltinFunction(ctx, id, _thin, _parameters(_error), _never); |
1091 | 12 | } |
1092 | | |
1093 | | static ValueDecl *getCmpXChgOperation(ASTContext &ctx, Identifier id, |
1094 | 33 | Type T) { |
1095 | 33 | return getBuiltinFunction(ctx, id, _thin, |
1096 | 33 | _parameters(_rawPointer, T, T), |
1097 | 33 | _tuple(T, _int(1))); |
1098 | 33 | } |
1099 | | |
1100 | | static ValueDecl *getAtomicRMWOperation(ASTContext &ctx, Identifier id, |
1101 | 12 | Type T) { |
1102 | 12 | return getBuiltinFunction(ctx, id, _thin, |
1103 | 12 | _parameters(_rawPointer, T), |
1104 | 12 | T); |
1105 | 12 | } |
1106 | | |
1107 | | static ValueDecl *getAtomicLoadOperation(ASTContext &ctx, Identifier id, |
1108 | 30 | Type T) { |
1109 | 30 | return getBuiltinFunction(ctx, id, _thin, |
1110 | 30 | _parameters(_rawPointer), |
1111 | 30 | T); |
1112 | 30 | } |
1113 | | |
1114 | | static ValueDecl *getAtomicStoreOperation(ASTContext &ctx, Identifier id, |
1115 | 15 | Type T) { |
1116 | 15 | return getBuiltinFunction(ctx, id, _thin, |
1117 | 15 | _parameters(_rawPointer, T), |
1118 | 15 | _void); |
1119 | 15 | } |
1120 | | |
1121 | | static ValueDecl *getNativeObjectCast(ASTContext &Context, Identifier Id, |
1122 | 93 | BuiltinValueKind BV) { |
1123 | | |
1124 | 93 | ParamSpecifier ownership; |
1125 | 93 | Type builtinTy; |
1126 | 93 | switch (BV) { |
1127 | 12 | case BuiltinValueKind::CastToNativeObject: |
1128 | 39 | case BuiltinValueKind::UnsafeCastToNativeObject: |
1129 | 57 | case BuiltinValueKind::CastFromNativeObject: |
1130 | 57 | builtinTy = Context.TheNativeObjectType; |
1131 | 57 | ownership = ParamSpecifier::LegacyOwned; |
1132 | 57 | break; |
1133 | | |
1134 | 18 | case BuiltinValueKind::BridgeToRawPointer: |
1135 | 36 | case BuiltinValueKind::BridgeFromRawPointer: |
1136 | 36 | builtinTy = Context.TheRawPointerType; |
1137 | 36 | ownership = ParamSpecifier::Default; |
1138 | 36 | break; |
1139 | | |
1140 | 0 | default: |
1141 | 0 | llvm_unreachable("unexpected kind"); |
1142 | 93 | } |
1143 | | |
1144 | 93 | BuiltinFunctionBuilder builder(Context); |
1145 | 93 | if (BV == BuiltinValueKind::CastToNativeObject || |
1146 | 93 | BV == BuiltinValueKind::UnsafeCastToNativeObject || |
1147 | 93 | BV == BuiltinValueKind::BridgeToRawPointer) { |
1148 | 57 | builder.addParameter(makeGenericParam(), ownership); |
1149 | 57 | builder.setResult(makeConcrete(builtinTy)); |
1150 | 57 | } else { |
1151 | 36 | builder.addParameter(makeConcrete(builtinTy), ownership); |
1152 | 36 | builder.setResult(makeGenericParam()); |
1153 | 36 | } |
1154 | 93 | return builder.build(Id); |
1155 | 93 | } |
1156 | | |
1157 | | static ValueDecl *getCastToBridgeObjectOperation(ASTContext &ctx, |
1158 | 27 | Identifier id) { |
1159 | 27 | return getBuiltinFunction(ctx, id, _thin, |
1160 | 27 | _generics(_unrestricted), |
1161 | 27 | _parameters(_owned(_typeparam(0)), |
1162 | 27 | _word), |
1163 | 27 | _bridgeObject); |
1164 | 27 | } |
1165 | | |
1166 | | static ValueDecl *getCastFromBridgeObjectOperation(ASTContext &ctx, |
1167 | | Identifier id, |
1168 | 48 | BuiltinValueKind BV) { |
1169 | 48 | switch (BV) { |
1170 | 24 | case BuiltinValueKind::CastReferenceFromBridgeObject: { |
1171 | 24 | return getBuiltinFunction(ctx, id, _thin, |
1172 | 24 | _generics(_unrestricted), |
1173 | 24 | _parameters(_owned(_bridgeObject)), |
1174 | 24 | _typeparam(0)); |
1175 | 0 | } |
1176 | | |
1177 | 24 | case BuiltinValueKind::CastBitPatternFromBridgeObject: { |
1178 | 24 | return getBuiltinFunction(ctx, id, _thin, |
1179 | 24 | _parameters(_bridgeObject), |
1180 | 24 | _word); |
1181 | 0 | } |
1182 | | |
1183 | 0 | default: |
1184 | 0 | llvm_unreachable("not a cast from bridge object op"); |
1185 | 48 | } |
1186 | 48 | } |
1187 | | |
1188 | | /// ClassifyBridgeObject has type: |
1189 | | /// (Builtin.BridgeObject) -> (Builtin.Int1, Builtin.Int1). |
1190 | 9 | static ValueDecl *getClassifyBridgeObject(ASTContext &C, Identifier Id) { |
1191 | 9 | Type int1Ty = BuiltinIntegerType::get(1, C); |
1192 | 9 | Type resultTy = TupleType::get({ |
1193 | 9 | TupleTypeElt(int1Ty, C.getIdentifier("isObjCObject")), |
1194 | 9 | TupleTypeElt(int1Ty, C.getIdentifier("isObjCTaggedPointer")) |
1195 | 9 | }, C); |
1196 | | |
1197 | 9 | return getBuiltinFunction(Id, { C.TheBridgeObjectType }, resultTy); |
1198 | 9 | } |
1199 | | |
1200 | 15 | static ValueDecl *getValueToBridgeObject(ASTContext &ctx, Identifier id) { |
1201 | 15 | return getBuiltinFunction(ctx, id, _thin, |
1202 | 15 | _generics(_unrestricted), |
1203 | 15 | _parameters(_typeparam(0)), |
1204 | 15 | _bridgeObject); |
1205 | 15 | } |
1206 | | |
1207 | 27 | static ValueDecl *getCOWBufferForReading(ASTContext &C, Identifier Id) { |
1208 | | // <T : AnyObject> T -> T |
1209 | | // |
1210 | 27 | BuiltinFunctionBuilder builder(C, 1, true); |
1211 | 27 | auto T = makeGenericParam(); |
1212 | 27 | builder.addParameter(T); |
1213 | 27 | builder.setResult(T); |
1214 | 27 | return builder.build(Id); |
1215 | 27 | } |
1216 | | |
1217 | 0 | static ValueDecl *getTypePtrAuthDiscriminator(ASTContext &C, Identifier Id) { |
1218 | | // <T : AnyObject> (T.Type) -> Int64 |
1219 | 0 | BuiltinFunctionBuilder builder(C); |
1220 | 0 | builder.addParameter(makeMetatype(makeGenericParam())); |
1221 | 0 | Type Int64Ty = BuiltinIntegerType::get(64, C); |
1222 | 0 | builder.setResult(makeConcrete(Int64Ty)); |
1223 | 0 | return builder.build(Id); |
1224 | 0 | } |
1225 | | |
1226 | 21 | static ValueDecl *getOnFastPath(ASTContext &Context, Identifier Id) { |
1227 | 21 | return getBuiltinFunction(Id, {}, TupleType::getEmpty(Context)); |
1228 | 21 | } |
1229 | | |
1230 | | static ValueDecl *getCastReferenceOperation(ASTContext &ctx, |
1231 | 18 | Identifier name) { |
1232 | | // <T, U> T -> U |
1233 | | // SILGen and IRGen check additional constraints during lowering. |
1234 | 18 | BuiltinFunctionBuilder builder(ctx, 2); |
1235 | 18 | builder.addParameter(makeGenericParam(0), ParamSpecifier::LegacyOwned); |
1236 | 18 | builder.setResult(makeGenericParam(1)); |
1237 | 18 | return builder.build(name); |
1238 | 18 | } |
1239 | | |
1240 | | static ValueDecl *getReinterpretCastOperation(ASTContext &ctx, |
1241 | 720 | Identifier name) { |
1242 | | // <T, U> T -> U |
1243 | | // SILGen and IRGen check additional constraints during lowering. |
1244 | 720 | BuiltinFunctionBuilder builder(ctx, 2); |
1245 | 720 | builder.addParameter(makeGenericParam(0), ParamSpecifier::LegacyOwned); |
1246 | 720 | builder.setResult(makeGenericParam(1)); |
1247 | 720 | return builder.build(name); |
1248 | 720 | } |
1249 | | |
1250 | | static ValueDecl *getZeroInitializerOperation(ASTContext &Context, |
1251 | 560 | Identifier Id) { |
1252 | | // <T> () -> T |
1253 | 560 | BuiltinFunctionBuilder builder(Context); |
1254 | 560 | builder.setResult(makeGenericParam()); |
1255 | 560 | return builder.build(Id); |
1256 | 560 | } |
1257 | | |
1258 | | static ValueDecl *getGetObjCTypeEncodingOperation(ASTContext &Context, |
1259 | 18 | Identifier Id) { |
1260 | | // <T> T.Type -> RawPointer |
1261 | 18 | BuiltinFunctionBuilder builder(Context); |
1262 | 18 | builder.addParameter(makeMetatype(makeGenericParam())); |
1263 | 18 | builder.setResult(makeConcrete(Context.TheRawPointerType)); |
1264 | 18 | return builder.build(Id); |
1265 | 18 | } |
1266 | | |
1267 | | static ValueDecl *getAutoDiffApplyDerivativeFunction( |
1268 | | ASTContext &Context, Identifier Id, AutoDiffDerivativeFunctionKind kind, |
1269 | 12 | unsigned arity, bool throws, Type thrownType) { |
1270 | 12 | assert(arity >= 1); |
1271 | | // JVP: |
1272 | | // <...T...(arity), R> (@differentiable(_forward) (...T) throws -> R, ...T) |
1273 | | // rethrows -> (R, (...T.TangentVector) -> R.TangentVector) |
1274 | | // VJP: |
1275 | | // <...T...(arity), R> (@differentiable(reverse) (...T) throws -> R, ...T) |
1276 | | // rethrows -> (R, (R.TangentVector) -> ...T.TangentVector) |
1277 | 0 | unsigned numGenericParams = 1 + arity; |
1278 | 12 | BuiltinFunctionBuilder builder(Context, numGenericParams); |
1279 | | // Get the `Differentiable` protocol. |
1280 | 12 | auto *diffableProto = Context.getProtocol(KnownProtocolKind::Differentiable); |
1281 | | // Create type parameters and add conformance constraints. |
1282 | 12 | auto fnResultGen = makeGenericParam(arity); |
1283 | 12 | builder.addConformanceRequirement(fnResultGen, diffableProto); |
1284 | 12 | SmallVector<decltype(fnResultGen), 2> fnParamGens; |
1285 | 16 | for (auto i : range(arity)) { |
1286 | 16 | auto T = makeGenericParam(i); |
1287 | 16 | builder.addConformanceRequirement(T, diffableProto); |
1288 | 16 | fnParamGens.push_back(T); |
1289 | 16 | } |
1290 | | // Generator for the first argument, i.e. the `@differentiable` function. |
1291 | 12 | BuiltinFunctionBuilder::LambdaGenerator firstArgGen{ |
1292 | | // Generator for the function type at the argument position, i.e. the |
1293 | | // function being differentiated. |
1294 | 24 | [=, &fnParamGens](BuiltinFunctionBuilder &builder) -> Type { |
1295 | 24 | auto extInfo = |
1296 | 24 | FunctionType::ExtInfoBuilder() |
1297 | | // TODO: Use `kind.getMinimalDifferentiabilityKind()`. |
1298 | 24 | .withDifferentiabilityKind(DifferentiabilityKind::Reverse) |
1299 | 24 | .withNoEscape() |
1300 | 24 | .withThrows(throws, thrownType) |
1301 | 24 | .build(); |
1302 | 24 | SmallVector<FunctionType::Param, 2> params; |
1303 | 24 | for (auto ¶mGen : fnParamGens) |
1304 | 32 | params.push_back(FunctionType::Param(paramGen.build(builder))); |
1305 | 24 | return FunctionType::get(params, fnResultGen.build(builder), extInfo); |
1306 | 24 | }}; |
1307 | | // Eagerly build the type of the first arg, then use that to compute the type |
1308 | | // of the result. |
1309 | 12 | auto *diffFnType = |
1310 | 12 | firstArgGen.build(builder)->castTo<AnyFunctionType>(); |
1311 | 12 | diffFnType = diffFnType->getWithoutDifferentiability()->withExtInfo( |
1312 | 12 | diffFnType->getExtInfo().withNoEscape(false)); |
1313 | 12 | auto *paramIndices = IndexSubset::get( |
1314 | 12 | Context, SmallBitVector(diffFnType->getNumParams(), true)); |
1315 | | // Generator for the resultant function type, i.e. the AD derivative function. |
1316 | 12 | BuiltinFunctionBuilder::LambdaGenerator resultGen{ |
1317 | 12 | [=, &Context](BuiltinFunctionBuilder &builder) -> Type { |
1318 | 12 | auto derivativeFnTy = diffFnType->getAutoDiffDerivativeFunctionType( |
1319 | 12 | paramIndices, kind, |
1320 | 12 | LookUpConformanceInModule(Context.TheBuiltinModule)); |
1321 | 12 | return derivativeFnTy->getResult(); |
1322 | 12 | }}; |
1323 | 12 | builder.addParameter(firstArgGen); |
1324 | 12 | for (auto argGen : fnParamGens) |
1325 | 16 | builder.addParameter(argGen); |
1326 | 12 | if (throws) |
1327 | 0 | builder.setRethrows(); |
1328 | 12 | builder.setResult(resultGen); |
1329 | 12 | return builder.build(Id); |
1330 | 12 | } |
1331 | | |
1332 | | static ValueDecl *getAutoDiffApplyTransposeFunction( |
1333 | | ASTContext &Context, Identifier Id, unsigned arity, bool throws, |
1334 | 0 | Type thrownType) { |
1335 | 0 | assert(arity >= 1); |
1336 | | // <...T...(arity), R> |
1337 | | // (@differentiable(_linear) (...T) throws -> R, ...R.TangentVector) |
1338 | | // rethrows -> (...T.TangentVector) |
1339 | 0 | unsigned numGenericParams = 1 + arity; |
1340 | 0 | BuiltinFunctionBuilder builder(Context, numGenericParams); |
1341 | 0 | auto *diffableProto = Context.getProtocol(KnownProtocolKind::Differentiable); |
1342 | 0 | auto *addArithProto = |
1343 | 0 | Context.getProtocol(KnownProtocolKind::AdditiveArithmetic); |
1344 | | // Create type parameters and add conformance constraints. |
1345 | 0 | auto linearFnResultGen = makeGenericParam(arity); |
1346 | 0 | builder.addConformanceRequirement(linearFnResultGen, diffableProto); |
1347 | 0 | builder.addConformanceRequirement(linearFnResultGen, addArithProto); |
1348 | 0 | SmallVector<decltype(linearFnResultGen), 2> linearFnParamGens; |
1349 | 0 | for (auto i : range(arity)) { |
1350 | 0 | auto T = makeGenericParam(i); |
1351 | 0 | builder.addConformanceRequirement(T, diffableProto); |
1352 | 0 | builder.addConformanceRequirement(T, addArithProto); |
1353 | 0 | linearFnParamGens.push_back(T); |
1354 | 0 | } |
1355 | | // Generator for the first argument, i.e. the `@differentiable(_linear)` |
1356 | | // function. |
1357 | 0 | BuiltinFunctionBuilder::LambdaGenerator firstArgGen { |
1358 | | // Generator for the function type at the argument position, i.e. the |
1359 | | // function being differentiated. |
1360 | 0 | [=, &linearFnParamGens](BuiltinFunctionBuilder &builder) -> Type { |
1361 | 0 | FunctionType::ExtInfo ext; |
1362 | 0 | auto extInfo = |
1363 | 0 | FunctionType::ExtInfoBuilder() |
1364 | 0 | .withDifferentiabilityKind(DifferentiabilityKind::Linear) |
1365 | 0 | .withNoEscape() |
1366 | 0 | .withThrows(throws, thrownType) |
1367 | 0 | .build(); |
1368 | 0 | SmallVector<FunctionType::Param, 2> params; |
1369 | 0 | for (auto ¶mGen : linearFnParamGens) |
1370 | 0 | params.push_back(FunctionType::Param(paramGen.build(builder))); |
1371 | | // FIXME: Verify ExtInfo state is correct, not working by accident. |
1372 | 0 | FunctionType::ExtInfo info; |
1373 | 0 | auto innerFunction = |
1374 | 0 | FunctionType::get(params, linearFnResultGen.build(builder), info); |
1375 | 0 | return innerFunction->withExtInfo(extInfo); |
1376 | 0 | } |
1377 | 0 | }; |
1378 | 0 | builder.addParameter(firstArgGen); |
1379 | 0 | builder.addParameter(linearFnResultGen); |
1380 | 0 | if (throws) |
1381 | 0 | builder.setRethrows(); |
1382 | 0 | if (arity == 1) |
1383 | 0 | builder.setResult(linearFnParamGens.front()); |
1384 | 0 | else { |
1385 | 0 | BuiltinFunctionBuilder::LambdaGenerator tupleResultGen { |
1386 | 0 | [&](BuiltinFunctionBuilder &builder) -> Type { |
1387 | 0 | SmallVector<TupleTypeElt, 2> tupleElts; |
1388 | 0 | for (auto linearFnParamGen : linearFnParamGens) |
1389 | 0 | tupleElts.push_back(linearFnParamGen.build(builder)); |
1390 | 0 | return TupleType::get(tupleElts, Context); |
1391 | 0 | } |
1392 | 0 | }; |
1393 | 0 | builder.setResult(tupleResultGen); |
1394 | 0 | } |
1395 | 0 | return builder.build(Id); |
1396 | 0 | } |
1397 | | |
1398 | | static ValueDecl *getGlobalStringTablePointer(ASTContext &Context, |
1399 | 18 | Identifier Id) { |
1400 | | // String -> Builtin.RawPointer |
1401 | 18 | auto stringType = Context.getStringType(); |
1402 | 18 | return getBuiltinFunction(Id, {stringType}, Context.TheRawPointerType); |
1403 | 18 | } |
1404 | | |
1405 | | static ValueDecl *getConvertStrongToUnownedUnsafe(ASTContext &ctx, |
1406 | 0 | Identifier id) { |
1407 | | // We actually want this: |
1408 | | // |
1409 | | // (T, inout unowned (unsafe) T) -> () |
1410 | | // |
1411 | | // But for simplicity, we actually accept T, U and do the checking |
1412 | | // in the emission method that everything works up. This is a |
1413 | | // builtin, so we can crash. |
1414 | 0 | BuiltinFunctionBuilder builder(ctx, 2); |
1415 | 0 | builder.addParameter(makeGenericParam(0)); |
1416 | 0 | builder.addParameter(makeGenericParam(1), ParamSpecifier::InOut); |
1417 | 0 | builder.setResult(makeConcrete(TupleType::getEmpty(ctx))); |
1418 | 0 | return builder.build(id); |
1419 | 0 | } |
1420 | | |
1421 | | static ValueDecl *getConvertUnownedUnsafeToGuaranteed(ASTContext &ctx, |
1422 | 18 | Identifier id) { |
1423 | | // We actually want this: |
1424 | | // |
1425 | | /// <BaseT, T> (BaseT, @inout unowned(unsafe) T) -> T |
1426 | | // |
1427 | | // But for simplicity, we actually accept three generic params T, U and do the |
1428 | | // checking in the emission method that everything works up. This is a |
1429 | | // builtin, so we can crash. |
1430 | 18 | BuiltinFunctionBuilder builder(ctx, 3); |
1431 | 18 | builder.addParameter(makeGenericParam(0)); // Base |
1432 | 18 | builder.addParameter(makeGenericParam(1), ParamSpecifier::InOut); // Unmanaged |
1433 | 18 | builder.setResult(makeGenericParam(2)); // Guaranteed Result |
1434 | 18 | return builder.build(id); |
1435 | 18 | } |
1436 | | |
1437 | 12 | static ValueDecl *getGetCurrentAsyncTask(ASTContext &ctx, Identifier id) { |
1438 | 12 | return getBuiltinFunction(id, { }, ctx.TheNativeObjectType); |
1439 | 12 | } |
1440 | | |
1441 | 6 | static ValueDecl *getGetCurrentExecutor(ASTContext &ctx, Identifier id) { |
1442 | 6 | return getBuiltinFunction(ctx, id, _async(_thin), |
1443 | 6 | _parameters(), |
1444 | 6 | _optional(_executor)); |
1445 | 6 | } |
1446 | | |
1447 | 9 | static ValueDecl *getCancelAsyncTask(ASTContext &ctx, Identifier id) { |
1448 | 9 | return getBuiltinFunction( |
1449 | 9 | id, { ctx.TheNativeObjectType }, ctx.TheEmptyTupleType); |
1450 | 9 | } |
1451 | | |
1452 | 1.91k | Type swift::getAsyncTaskAndContextType(ASTContext &ctx) { |
1453 | 1.91k | TupleTypeElt resultTupleElements[2] = { |
1454 | 1.91k | ctx.TheNativeObjectType, // task, |
1455 | 1.91k | ctx.TheRawPointerType // initial context |
1456 | 1.91k | }; |
1457 | | |
1458 | 1.91k | return TupleType::get(resultTupleElements, ctx); |
1459 | 1.91k | } |
1460 | | |
1461 | 759 | static ValueDecl *getCreateAsyncTask(ASTContext &ctx, Identifier id) { |
1462 | 759 | BuiltinFunctionBuilder builder(ctx); |
1463 | 759 | auto genericParam = makeGenericParam().build(builder); |
1464 | 759 | builder.addParameter(makeConcrete(ctx.getIntType())); // 0 flags |
1465 | 759 | auto extInfo = ASTExtInfoBuilder().withAsync().withThrows().build(); |
1466 | 759 | builder.addParameter( |
1467 | 759 | makeConcrete(FunctionType::get({ }, genericParam, extInfo))); // 1 operation |
1468 | 759 | builder.setResult(makeConcrete(getAsyncTaskAndContextType(ctx))); |
1469 | 759 | return builder.build(id); |
1470 | 759 | } |
1471 | | |
1472 | 147 | static ValueDecl *getCreateAsyncTaskInGroup(ASTContext &ctx, Identifier id) { |
1473 | 147 | BuiltinFunctionBuilder builder(ctx); |
1474 | 147 | auto genericParam = makeGenericParam().build(builder); // <T> |
1475 | 147 | builder.addParameter(makeConcrete(ctx.getIntType())); // 0 flags |
1476 | 147 | builder.addParameter(makeConcrete(ctx.TheRawPointerType)); // 1 group |
1477 | 147 | auto extInfo = ASTExtInfoBuilder().withAsync().withThrows().build(); |
1478 | 147 | builder.addParameter( |
1479 | 147 | makeConcrete(FunctionType::get({ }, genericParam, extInfo))); // 2 operation |
1480 | 147 | builder.setResult(makeConcrete(getAsyncTaskAndContextType(ctx))); |
1481 | | |
1482 | 147 | return builder.build(id); |
1483 | 147 | } |
1484 | | |
1485 | 9 | static ValueDecl *getTaskRunInline(ASTContext &ctx, Identifier id) { |
1486 | 9 | return getBuiltinFunction( |
1487 | 9 | ctx, id, _thin, _generics(_unrestricted), |
1488 | 9 | _parameters( |
1489 | 9 | _function(_async(_noescape(_thick)), _typeparam(0), _parameters())), |
1490 | 9 | _typeparam(0)); |
1491 | 9 | } |
1492 | | |
1493 | 3 | static ValueDecl *getConvertTaskToJob(ASTContext &ctx, Identifier id) { |
1494 | 3 | return getBuiltinFunction(ctx, id, |
1495 | 3 | _thin, |
1496 | 3 | _parameters(_owned(_nativeObject)), |
1497 | 3 | _job); |
1498 | 3 | } |
1499 | | |
1500 | | static ValueDecl *getDefaultActorInitDestroy(ASTContext &ctx, |
1501 | 6 | Identifier id) { |
1502 | 6 | return getBuiltinFunction(ctx, id, _thin, |
1503 | 6 | _parameters(_nativeObject), |
1504 | 6 | _void); |
1505 | 6 | } |
1506 | | |
1507 | | static ValueDecl *getDistributedActorInitializeRemote(ASTContext &ctx, |
1508 | 0 | Identifier id) { |
1509 | 0 | return getBuiltinFunction(ctx, id, _thin, |
1510 | 0 | _generics(_unrestricted), // TODO(distributed): restrict to DistributedActor |
1511 | 0 | _parameters(_metatype(_typeparam(0))), |
1512 | 0 | _rawPointer); |
1513 | 0 | } |
1514 | | |
1515 | | static ValueDecl *getResumeContinuationReturning(ASTContext &ctx, |
1516 | 144 | Identifier id) { |
1517 | 144 | return getBuiltinFunction(ctx, id, _thin, |
1518 | 144 | _generics(_unrestricted), |
1519 | 144 | _parameters(_rawUnsafeContinuation, |
1520 | 144 | _owned(_typeparam(0))), |
1521 | 144 | _void); |
1522 | 144 | } |
1523 | | |
1524 | | static ValueDecl *getResumeContinuationThrowing(ASTContext &ctx, |
1525 | 45 | Identifier id) { |
1526 | 45 | return getBuiltinFunction(ctx, id, _thin, |
1527 | 45 | _parameters(_rawUnsafeContinuation, |
1528 | 45 | _owned(_error)), |
1529 | 45 | _void); |
1530 | 45 | } |
1531 | | |
1532 | 342 | static ValueDecl *getStartAsyncLet(ASTContext &ctx, Identifier id) { |
1533 | 342 | ModuleDecl *M = ctx.TheBuiltinModule; |
1534 | 342 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); |
1535 | 342 | SynthesisContext SC(ctx, DC); |
1536 | | |
1537 | 342 | BuiltinFunctionBuilder builder(ctx); |
1538 | 342 | auto genericParam = makeGenericParam().build(builder); // <T> |
1539 | | |
1540 | | // AsyncLet* |
1541 | 342 | builder.addParameter(makeConcrete(OptionalType::get(ctx.TheRawPointerType))); |
1542 | | |
1543 | | // TaskOptionRecord* |
1544 | 342 | builder.addParameter(makeConcrete(OptionalType::get(ctx.TheRawPointerType))); |
1545 | | |
1546 | | // operation async function pointer: () async throws -> T |
1547 | 342 | auto extInfo = ASTExtInfoBuilder().withAsync().withThrows().withNoEscape().build(); |
1548 | 342 | builder.addParameter( |
1549 | 342 | makeConcrete(FunctionType::get({ }, genericParam, extInfo))); |
1550 | | |
1551 | | // -> Builtin.RawPointer |
1552 | 342 | builder.setResult(makeConcrete(synthesizeType(SC, _rawPointer))); |
1553 | 342 | return builder.build(id); |
1554 | 342 | } |
1555 | | |
1556 | 6 | static ValueDecl *getEndAsyncLet(ASTContext &ctx, Identifier id) { |
1557 | 6 | return getBuiltinFunction(ctx, id, _thin, |
1558 | 6 | _parameters(_rawPointer), |
1559 | 6 | _void); |
1560 | 6 | } |
1561 | | |
1562 | 42 | static ValueDecl *getCreateTaskGroup(ASTContext &ctx, Identifier id) { |
1563 | 42 | return getBuiltinFunction(ctx, id, _thin, |
1564 | 42 | _generics(_unrestricted), |
1565 | 42 | _parameters(_metatype(_typeparam(0))), |
1566 | 42 | _rawPointer); |
1567 | 42 | } |
1568 | | |
1569 | 36 | static ValueDecl *getCreateTaskGroupWithFlags(ASTContext &ctx, Identifier id) { |
1570 | 36 | ModuleDecl *M = ctx.TheBuiltinModule; |
1571 | 36 | DeclContext *DC = &M->getMainFile(FileUnitKind::Builtin); |
1572 | 36 | SynthesisContext SC(ctx, DC); |
1573 | | |
1574 | 36 | BuiltinFunctionBuilder builder(ctx); |
1575 | | |
1576 | | // int |
1577 | 36 | builder.addParameter(makeConcrete(ctx.getIntType())); // 0 flags |
1578 | | |
1579 | | // T.self |
1580 | 36 | builder.addParameter(makeMetatype(makeGenericParam(0))); // 1 ChildTaskResult.Type |
1581 | | |
1582 | | // -> Builtin.RawPointer |
1583 | 36 | builder.setResult(makeConcrete(synthesizeType(SC, _rawPointer))); |
1584 | 36 | return builder.build(id); |
1585 | 36 | } |
1586 | | |
1587 | 42 | static ValueDecl *getDestroyTaskGroup(ASTContext &ctx, Identifier id) { |
1588 | 42 | return getBuiltinFunction(ctx, id, _thin, |
1589 | 42 | _parameters(_rawPointer), |
1590 | 42 | _void); |
1591 | 42 | } |
1592 | | |
1593 | | static ValueDecl *getBuildMainActorExecutorRef(ASTContext &ctx, |
1594 | 36 | Identifier id) { |
1595 | 36 | return getBuiltinFunction(ctx, id, _thin, _parameters(), _executor); |
1596 | 36 | } |
1597 | | |
1598 | | static ValueDecl *getBuildDefaultActorExecutorRef(ASTContext &ctx, |
1599 | 2.94k | Identifier id) { |
1600 | 2.94k | return getBuiltinFunction(ctx, id, _thin, |
1601 | 2.94k | _generics(_unrestricted, |
1602 | 2.94k | _layout(_typeparam(0), _classLayout())), |
1603 | 2.94k | _parameters(_typeparam(0)), |
1604 | 2.94k | _executor); |
1605 | 2.94k | } |
1606 | | |
1607 | | static ValueDecl *getTargetOSVersionAtLeast(ASTContext &Context, |
1608 | 15 | Identifier Id) { |
1609 | 15 | auto int32Type = BuiltinIntegerType::get(32, Context); |
1610 | 15 | return getBuiltinFunction(Id, {int32Type, int32Type, int32Type}, int32Type); |
1611 | 15 | } |
1612 | | |
1613 | | static ValueDecl *getBuildOrdinarySerialExecutorRef(ASTContext &ctx, |
1614 | 39 | Identifier id) { |
1615 | 39 | return getBuiltinFunction(ctx, id, _thin, |
1616 | 39 | _generics(_unrestricted, |
1617 | 39 | _conformsTo(_typeparam(0), _serialExecutor)), |
1618 | 39 | _parameters(_typeparam(0)), |
1619 | 39 | _executor); |
1620 | 39 | } |
1621 | | |
1622 | | static ValueDecl *getBuildComplexEqualitySerialExecutorRef(ASTContext &ctx, |
1623 | 36 | Identifier id) { |
1624 | 36 | return getBuiltinFunction(ctx, id, _thin, |
1625 | 36 | _generics(_unrestricted, |
1626 | 36 | _conformsTo(_typeparam(0), _serialExecutor)), |
1627 | 36 | _parameters(_typeparam(0)), |
1628 | 36 | _executor); |
1629 | 36 | } |
1630 | | |
1631 | | static ValueDecl *getAutoDiffCreateLinearMapContext(ASTContext &ctx, |
1632 | 8 | Identifier id) { |
1633 | 8 | return getBuiltinFunction( |
1634 | 8 | ctx, id, _thin, _generics(_unrestricted), |
1635 | 8 | _parameters(_metatype(_typeparam(0))), _nativeObject); |
1636 | 8 | } |
1637 | | |
1638 | | static ValueDecl *getAutoDiffProjectTopLevelSubcontext(ASTContext &ctx, |
1639 | 8 | Identifier id) { |
1640 | 8 | return getBuiltinFunction( |
1641 | 8 | id, {ctx.TheNativeObjectType}, ctx.TheRawPointerType); |
1642 | 8 | } |
1643 | | |
1644 | | static ValueDecl *getAutoDiffAllocateSubcontext(ASTContext &ctx, |
1645 | 8 | Identifier id) { |
1646 | 8 | return getBuiltinFunction( |
1647 | 8 | ctx, id, _thin, _generics(_unrestricted), |
1648 | 8 | _parameters(_nativeObject, _metatype(_typeparam(0))), _rawPointer); |
1649 | 8 | } |
1650 | | |
1651 | 9 | static ValueDecl *getPoundAssert(ASTContext &Context, Identifier Id) { |
1652 | 9 | auto int1Type = BuiltinIntegerType::get(1, Context); |
1653 | 9 | auto optionalRawPointerType = BoundGenericEnumType::get( |
1654 | 9 | Context.getOptionalDecl(), Type(), {Context.TheRawPointerType}); |
1655 | 9 | return getBuiltinFunction(Id, {int1Type, optionalRawPointerType}, |
1656 | 9 | Context.TheEmptyTupleType); |
1657 | 9 | } |
1658 | | |
1659 | 24 | static ValueDecl *getTSanInoutAccess(ASTContext &Context, Identifier Id) { |
1660 | | // <T> T -> () |
1661 | 24 | BuiltinFunctionBuilder builder(Context); |
1662 | 24 | builder.addParameter(makeGenericParam()); |
1663 | 24 | builder.setResult(makeConcrete(Context.TheEmptyTupleType)); |
1664 | 24 | return builder.build(Id); |
1665 | 24 | } |
1666 | | |
1667 | 126 | static ValueDecl *getAddressOfOperation(ASTContext &Context, Identifier Id) { |
1668 | | // <T> (@inout T) -> RawPointer |
1669 | 126 | BuiltinFunctionBuilder builder(Context); |
1670 | 126 | builder.addParameter(makeGenericParam(), ParamSpecifier::InOut); |
1671 | 126 | builder.setResult(makeConcrete(Context.TheRawPointerType)); |
1672 | 126 | return builder.build(Id); |
1673 | 126 | } |
1674 | | |
1675 | | static ValueDecl *getAddressOfBorrowOperation(ASTContext &Context, |
1676 | 45 | Identifier Id) { |
1677 | | // <T> (T) -> RawPointer |
1678 | 45 | BuiltinFunctionBuilder builder(Context); |
1679 | 45 | builder.addParameter(makeGenericParam()); |
1680 | 45 | builder.setResult(makeConcrete(Context.TheRawPointerType)); |
1681 | 45 | return builder.build(Id); |
1682 | 45 | } |
1683 | | |
1684 | 3 | static ValueDecl *getTypeJoinOperation(ASTContext &Context, Identifier Id) { |
1685 | | // <T,U,V> (T.Type, U.Type) -> V.Type |
1686 | 3 | BuiltinFunctionBuilder builder(Context, 3); |
1687 | 3 | builder.addParameter(makeMetatype(makeGenericParam(0))); |
1688 | 3 | builder.addParameter(makeMetatype(makeGenericParam(1))); |
1689 | 3 | builder.setResult(makeMetatype(makeGenericParam(2))); |
1690 | 3 | return builder.build(Id); |
1691 | 3 | } |
1692 | | |
1693 | | static ValueDecl *getTypeJoinInoutOperation(ASTContext &Context, |
1694 | 0 | Identifier Id) { |
1695 | | // <T,U,V> (inout T, U.Type) -> V.Type |
1696 | 0 | BuiltinFunctionBuilder builder(Context, 3); |
1697 | 0 | builder.addParameter(makeGenericParam(0), ParamSpecifier::InOut); |
1698 | 0 | builder.addParameter(makeMetatype(makeGenericParam(1))); |
1699 | 0 | builder.setResult(makeMetatype(makeGenericParam(2))); |
1700 | 0 | return builder.build(Id); |
1701 | 0 | } |
1702 | | |
1703 | 3 | static ValueDecl *getTypeJoinMetaOperation(ASTContext &Context, Identifier Id) { |
1704 | | // <T,U,V> (T.Type, U.Type) -> V.Type |
1705 | 3 | BuiltinFunctionBuilder builder(Context, 3); |
1706 | 3 | builder.addParameter(makeMetatype(makeGenericParam(0))); |
1707 | 3 | builder.addParameter(makeMetatype(makeGenericParam(1))); |
1708 | 3 | builder.setResult(makeMetatype(makeGenericParam(2))); |
1709 | 3 | return builder.build(Id); |
1710 | 3 | } |
1711 | | |
1712 | | static ValueDecl *getTriggerFallbackDiagnosticOperation(ASTContext &Context, |
1713 | 3 | Identifier Id) { |
1714 | | // () -> Void |
1715 | 3 | return getBuiltinFunction(Id, {}, Context.TheEmptyTupleType); |
1716 | 3 | } |
1717 | | |
1718 | | static ValueDecl *getCanBeObjCClassOperation(ASTContext &Context, |
1719 | 1.90k | Identifier Id) { |
1720 | | // <T> T.Type -> Builtin.Int8 |
1721 | 1.90k | BuiltinFunctionBuilder builder(Context); |
1722 | 1.90k | builder.addParameter(makeMetatype(makeGenericParam())); |
1723 | 1.90k | builder.setResult(makeConcrete(BuiltinIntegerType::get(8, Context))); |
1724 | 1.90k | return builder.build(Id); |
1725 | 1.90k | } |
1726 | | |
1727 | 6 | static ValueDecl *getLegacyCondFailOperation(ASTContext &C, Identifier Id) { |
1728 | | // Int1 -> () |
1729 | 6 | auto CondTy = BuiltinIntegerType::get(1, C); |
1730 | 6 | auto VoidTy = TupleType::getEmpty(C); |
1731 | 6 | return getBuiltinFunction(Id, {CondTy}, VoidTy); |
1732 | 6 | } |
1733 | | |
1734 | 27 | static ValueDecl *getCondFailOperation(ASTContext &C, Identifier Id) { |
1735 | | // Int1 -> () |
1736 | 27 | auto CondTy = BuiltinIntegerType::get(1, C); |
1737 | 27 | auto MsgTy = C.TheRawPointerType; |
1738 | 27 | auto VoidTy = TupleType::getEmpty(C); |
1739 | 27 | return getBuiltinFunction(Id, {CondTy, MsgTy}, VoidTy); |
1740 | 27 | } |
1741 | | |
1742 | 99 | static ValueDecl *getAssertConfOperation(ASTContext &C, Identifier Id) { |
1743 | | // () -> Int32 |
1744 | 99 | auto Int32Ty = BuiltinIntegerType::get(32, C); |
1745 | 99 | return getBuiltinFunction(Id, {}, Int32Ty); |
1746 | 99 | } |
1747 | | |
1748 | 18 | static ValueDecl *getFixLifetimeOperation(ASTContext &C, Identifier Id) { |
1749 | | // <T> T -> () |
1750 | 18 | BuiltinFunctionBuilder builder(C); |
1751 | 18 | builder.addParameter(makeGenericParam()); |
1752 | 18 | builder.setResult(makeConcrete(TupleType::getEmpty(C))); |
1753 | 18 | return builder.build(Id); |
1754 | 18 | } |
1755 | | |
1756 | | static ValueDecl *getExtractElementOperation(ASTContext &Context, Identifier Id, |
1757 | 357 | Type FirstTy, Type SecondTy) { |
1758 | | // (Vector<N, T>, Int32) -> T |
1759 | 357 | auto VecTy = FirstTy->getAs<BuiltinVectorType>(); |
1760 | 357 | if (!VecTy) |
1761 | 0 | return nullptr; |
1762 | | |
1763 | 357 | auto IndexTy = SecondTy->getAs<BuiltinIntegerType>(); |
1764 | 357 | if (!IndexTy || !IndexTy->isFixedWidth() || IndexTy->getFixedWidth() != 32) |
1765 | 0 | return nullptr; |
1766 | | |
1767 | 357 | Type ResultTy = VecTy->getElementType(); |
1768 | 357 | return getBuiltinFunction(Id, { VecTy, IndexTy }, ResultTy); |
1769 | 357 | } |
1770 | | |
1771 | | static ValueDecl *getInsertElementOperation(ASTContext &Context, Identifier Id, |
1772 | | Type FirstTy, Type SecondTy, |
1773 | 357 | Type ThirdTy) { |
1774 | | // (Vector<N, T>, T, Int32) -> Vector<N, T> |
1775 | 357 | auto VecTy = FirstTy->getAs<BuiltinVectorType>(); |
1776 | 357 | if (!VecTy) |
1777 | 0 | return nullptr; |
1778 | 357 | auto ElementTy = VecTy->getElementType(); |
1779 | | |
1780 | 357 | if (!SecondTy->isEqual(ElementTy)) |
1781 | 0 | return nullptr; |
1782 | | |
1783 | 357 | auto IndexTy = ThirdTy->getAs<BuiltinIntegerType>(); |
1784 | 357 | if (!IndexTy || !IndexTy->isFixedWidth() || IndexTy->getFixedWidth() != 32) |
1785 | 0 | return nullptr; |
1786 | | |
1787 | 357 | Type ArgElts[] = { VecTy, ElementTy, IndexTy }; |
1788 | 357 | return getBuiltinFunction(Id, ArgElts, VecTy); |
1789 | 357 | } |
1790 | | |
1791 | | static ValueDecl *getShuffleVectorOperation(ASTContext &Context, Identifier Id, |
1792 | 3 | Type FirstTy, Type SecondTy) { |
1793 | | // (Vector<N, T>, Vector<N, T>, Vector<M, Int32) -> Vector<M, T> |
1794 | 3 | auto VecTy = FirstTy->getAs<BuiltinVectorType>(); |
1795 | 3 | if (!VecTy) |
1796 | 0 | return nullptr; |
1797 | 3 | auto ElementTy = VecTy->getElementType(); |
1798 | | |
1799 | 3 | auto IndexTy = SecondTy->getAs<BuiltinVectorType>(); |
1800 | 3 | if (!IndexTy) |
1801 | 0 | return nullptr; |
1802 | 3 | auto IdxElTy = IndexTy->getElementType()->getAs<BuiltinIntegerType>(); |
1803 | 3 | if (!IdxElTy || !IdxElTy->isFixedWidth() || IdxElTy->getFixedWidth() != 32) |
1804 | 0 | return nullptr; |
1805 | | |
1806 | 3 | Type ArgElts[] = { VecTy, VecTy, IndexTy }; |
1807 | 3 | Type ResultTy = BuiltinVectorType::get(Context, ElementTy, |
1808 | 3 | IndexTy->getNumElements()); |
1809 | 3 | return getBuiltinFunction(Id, ArgElts, ResultTy); |
1810 | 3 | } |
1811 | | |
1812 | 18 | static ValueDecl *getStaticReportOperation(ASTContext &Context, Identifier Id) { |
1813 | 18 | auto BoolTy = BuiltinIntegerType::get(1, Context); |
1814 | 18 | auto MessageTy = Context.TheRawPointerType; |
1815 | | |
1816 | 18 | Type ArgElts[] = { BoolTy, BoolTy, MessageTy }; |
1817 | 18 | Type ResultTy = TupleType::getEmpty(Context); |
1818 | | |
1819 | 18 | return getBuiltinFunction(Id, ArgElts, ResultTy); |
1820 | 18 | } |
1821 | | |
1822 | | static ValueDecl *getCheckedTruncOperation(ASTContext &Context, Identifier Id, |
1823 | | Type InputTy, Type OutputTy, |
1824 | 216 | bool AllowLiteral) { |
1825 | 216 | auto InTy = InputTy->getAs<AnyBuiltinIntegerType>(); |
1826 | 216 | auto OutTy = OutputTy->getAs<BuiltinIntegerType>(); |
1827 | 216 | if (!InTy || !OutTy) |
1828 | 0 | return nullptr; |
1829 | 216 | if (isa<BuiltinIntegerLiteralType>(InTy)) { |
1830 | 186 | if (!AllowLiteral) |
1831 | 0 | return nullptr; |
1832 | 186 | } else if (cast<BuiltinIntegerType>(InTy)->getLeastWidth() |
1833 | 30 | < OutTy->getGreatestWidth()) { |
1834 | 0 | return nullptr; |
1835 | 0 | } |
1836 | | |
1837 | 216 | Type OverflowBitTy = BuiltinIntegerType::get(1, Context); |
1838 | 216 | TupleTypeElt ResultElts[] = { Type(OutTy), OverflowBitTy }; |
1839 | 216 | Type ResultTy = TupleType::get(ResultElts, Context); |
1840 | 216 | return getBuiltinFunction(Id, { InTy }, ResultTy); |
1841 | 216 | } |
1842 | | |
1843 | | static ValueDecl *getIntToFPWithOverflowOperation(ASTContext &Context, |
1844 | | Identifier Id, Type InputTy, |
1845 | 45 | Type OutputTy) { |
1846 | 45 | auto InTy = InputTy->getAs<BuiltinIntegerLiteralType>(); |
1847 | 45 | auto OutTy = OutputTy->getAs<BuiltinFloatType>(); |
1848 | 45 | if (!InTy || !OutTy) |
1849 | 0 | return nullptr; |
1850 | | |
1851 | 45 | return getBuiltinFunction(Id, { InTy }, OutTy); |
1852 | 45 | } |
1853 | | |
1854 | | static ValueDecl *getBitWidthOperation( |
1855 | | ASTContext &ctx, |
1856 | | Identifier id, |
1857 | | Type valueTy |
1858 | 12 | ) { |
1859 | 12 | if (!valueTy->getAs<BuiltinIntegerLiteralType>()) return nullptr; |
1860 | 12 | return getBuiltinFunction(ctx, id, _thin, _parameters(valueTy), _word); |
1861 | 12 | } |
1862 | | |
1863 | | static ValueDecl *getIsNegativeOperation( |
1864 | | ASTContext &ctx, |
1865 | | Identifier id, |
1866 | | Type valueTy |
1867 | 12 | ) { |
1868 | 12 | if (!valueTy->getAs<BuiltinIntegerLiteralType>()) return nullptr; |
1869 | 12 | return getBuiltinFunction(ctx, id, _thin, _parameters(valueTy), _int(1)); |
1870 | 12 | } |
1871 | | |
1872 | | static ValueDecl *getWordAtIndexOperation( |
1873 | | ASTContext &ctx, |
1874 | | Identifier id, |
1875 | | Type valueTy |
1876 | 12 | ) { |
1877 | 12 | if (!valueTy->getAs<BuiltinIntegerLiteralType>()) return nullptr; |
1878 | 12 | return getBuiltinFunction(ctx, id, _thin, _parameters(valueTy, _word), _word); |
1879 | 12 | } |
1880 | | |
1881 | | static ValueDecl *getUnreachableOperation(ASTContext &Context, |
1882 | 54 | Identifier Id) { |
1883 | 54 | auto NeverTy = Context.getNeverType(); |
1884 | 54 | if (!NeverTy) |
1885 | 0 | return nullptr; |
1886 | | |
1887 | | // () -> Never |
1888 | 54 | return getBuiltinFunction(Id, {}, NeverTy); |
1889 | 54 | } |
1890 | | |
1891 | | static ValueDecl *getOnceOperation(ASTContext &Context, |
1892 | | Identifier Id, |
1893 | 5.58k | bool withContext) { |
1894 | | // (RawPointer, @convention(c) (Context) -> ()[, Context]) -> () |
1895 | | |
1896 | 5.58k | auto HandleTy = Context.TheRawPointerType; |
1897 | 5.58k | auto VoidTy = Context.TheEmptyTupleType; |
1898 | 5.58k | SmallVector<AnyFunctionType::Param, 1> CFuncParams; |
1899 | 5.58k | swift::CanType ContextTy = Context.TheRawPointerType; |
1900 | 5.58k | auto ContextArg = FunctionType::Param(ContextTy); |
1901 | 5.58k | CFuncParams.push_back(ContextArg); |
1902 | 5.58k | auto Rep = FunctionTypeRepresentation::CFunctionPointer; |
1903 | 5.58k | auto ClangType = Context.getClangFunctionType(CFuncParams, VoidTy, Rep); |
1904 | 5.58k | auto Thin = |
1905 | 5.58k | FunctionType::ExtInfoBuilder(FunctionTypeRepresentation::CFunctionPointer, |
1906 | 5.58k | /*throws*/ false, Type()) |
1907 | 5.58k | .withClangFunctionType(ClangType) |
1908 | 5.58k | .build(); |
1909 | 5.58k | auto BlockTy = FunctionType::get(CFuncParams, VoidTy, Thin); |
1910 | 5.58k | SmallVector<swift::Type, 3> ArgTypes = {HandleTy, BlockTy}; |
1911 | 5.58k | if (withContext) |
1912 | 3 | ArgTypes.push_back(ContextTy); |
1913 | 5.58k | return getBuiltinFunction(Id, ArgTypes, VoidTy); |
1914 | 5.58k | } |
1915 | | |
1916 | | static ValueDecl *getPolymorphicBinaryOperation(ASTContext &ctx, |
1917 | 228 | Identifier id) { |
1918 | 228 | BuiltinFunctionBuilder builder(ctx); |
1919 | 228 | builder.addParameter(makeGenericParam()); |
1920 | 228 | builder.addParameter(makeGenericParam()); |
1921 | 228 | builder.setResult(makeGenericParam()); |
1922 | 228 | return builder.build(id); |
1923 | 228 | } |
1924 | | |
1925 | | static ValueDecl *getWithUnsafeContinuation(ASTContext &ctx, |
1926 | | Identifier id, |
1927 | 78 | bool throws) { |
1928 | 78 | BuiltinFunctionBuilder builder(ctx); |
1929 | | |
1930 | 78 | auto contTy = ctx.TheRawUnsafeContinuationType; |
1931 | 78 | SmallVector<AnyFunctionType::Param, 1> params; |
1932 | 78 | params.emplace_back(contTy); |
1933 | | |
1934 | 78 | auto voidTy = ctx.TheEmptyTupleType; |
1935 | 78 | auto extInfo = FunctionType::ExtInfoBuilder().withNoEscape().build(); |
1936 | 78 | auto *fnTy = FunctionType::get(params, voidTy, extInfo); |
1937 | | |
1938 | 78 | builder.addParameter(makeConcrete(fnTy)); |
1939 | 78 | builder.setResult(makeGenericParam()); |
1940 | | |
1941 | 78 | builder.setAsync(); |
1942 | 78 | if (throws) |
1943 | 39 | builder.setThrows(); |
1944 | | |
1945 | 78 | return builder.build(id); |
1946 | 78 | } |
1947 | | |
1948 | 3 | static ValueDecl *getHopToActor(ASTContext &ctx, Identifier id) { |
1949 | 3 | BuiltinFunctionBuilder builder(ctx); |
1950 | 3 | auto *actorProto = ctx.getProtocol(KnownProtocolKind::Actor); |
1951 | | // Create type parameters and add conformance constraints. |
1952 | 3 | auto actorParam = makeGenericParam(); |
1953 | 3 | builder.addParameter(actorParam); |
1954 | 3 | builder.addConformanceRequirement(actorParam, actorProto); |
1955 | 3 | builder.setResult(makeConcrete(TupleType::getEmpty(ctx))); |
1956 | 3 | return builder.build(id); |
1957 | 3 | } |
1958 | | |
1959 | 9 | static ValueDecl *getPackLength(ASTContext &ctx, Identifier id) { |
1960 | 9 | BuiltinFunctionBuilder builder(ctx, /* genericParamCount */ 1, |
1961 | 9 | /* anyObject */ false, |
1962 | 9 | /* areParametersPack */ true); |
1963 | | |
1964 | 9 | auto paramTy = makeMetatype(makeTuple(makePackExpansion(makeGenericParam()))); |
1965 | 9 | builder.addParameter(paramTy); |
1966 | 9 | builder.setResult(makeConcrete(BuiltinIntegerType::getWordType(ctx))); |
1967 | | |
1968 | 9 | return builder.build(id); |
1969 | 9 | } |
1970 | | |
1971 | | /// An array of the overloaded builtin kinds. |
1972 | | static const OverloadedBuiltinKind OverloadedBuiltinKinds[] = { |
1973 | | OverloadedBuiltinKind::None, |
1974 | | |
1975 | | // There's deliberately no BUILTIN clause here so that we'll blow up |
1976 | | // if new builtin categories are added there and not here. |
1977 | | #define BUILTIN_CAST_OPERATION(id, attrs, name) \ |
1978 | | OverloadedBuiltinKind::Special, |
1979 | | #define BUILTIN_CAST_OR_BITCAST_OPERATION(id, attrs, name) \ |
1980 | | OverloadedBuiltinKind::Special, |
1981 | | #define BUILTIN_BINARY_OPERATION_OVERLOADED_STATIC(id, name, attrs, overload) \ |
1982 | | OverloadedBuiltinKind::overload, |
1983 | | #define BUILTIN_BINARY_OPERATION_POLYMORPHIC(id, name) \ |
1984 | | OverloadedBuiltinKind::Special, |
1985 | | #define BUILTIN_BINARY_OPERATION_WITH_OVERFLOW(id, name, _, attrs, overload) \ |
1986 | | OverloadedBuiltinKind::overload, |
1987 | | #define BUILTIN_BINARY_PREDICATE(id, name, attrs, overload) \ |
1988 | | OverloadedBuiltinKind::overload, |
1989 | | #define BUILTIN_UNARY_OPERATION(id, name, attrs, overload) \ |
1990 | | OverloadedBuiltinKind::overload, |
1991 | | #define BUILTIN_SIL_OPERATION(id, name, overload) \ |
1992 | | OverloadedBuiltinKind::overload, |
1993 | | #define BUILTIN_MISC_OPERATION(id, name, attrs, overload) \ |
1994 | | OverloadedBuiltinKind::overload, |
1995 | | #define BUILTIN_SANITIZER_OPERATION(id, name, attrs) \ |
1996 | | OverloadedBuiltinKind::None, |
1997 | | #define BUILTIN_TYPE_CHECKER_OPERATION(id, name) OverloadedBuiltinKind::Special, |
1998 | | #define BUILTIN_TYPE_TRAIT_OPERATION(id, name) \ |
1999 | | OverloadedBuiltinKind::Special, |
2000 | | #define BUILTIN_RUNTIME_CALL(id, attrs, name) \ |
2001 | | OverloadedBuiltinKind::Special, |
2002 | | #include "swift/AST/Builtins.def" |
2003 | | }; |
2004 | | |
2005 | | /// Determines if a builtin type falls within the given category. |
2006 | 13.5k | inline bool isBuiltinTypeOverloaded(Type T, OverloadedBuiltinKind OK) { |
2007 | 13.5k | switch (OK) { |
2008 | 0 | case OverloadedBuiltinKind::None: |
2009 | 0 | return false; // always fail. |
2010 | 1.03k | case OverloadedBuiltinKind::Integer: |
2011 | 1.03k | return T->is<BuiltinIntegerType>(); |
2012 | 3.55k | case OverloadedBuiltinKind::IntegerOrVector: |
2013 | 3.55k | return T->is<BuiltinIntegerType>() || |
2014 | 3.55k | (T->is<BuiltinVectorType>() && |
2015 | 2.16k | T->castTo<BuiltinVectorType>()->getElementType() |
2016 | 2.16k | ->is<BuiltinIntegerType>()); |
2017 | 0 | case OverloadedBuiltinKind::IntegerOrRawPointer: |
2018 | 0 | return T->is<BuiltinIntegerType>() || T->is<BuiltinRawPointerType>(); |
2019 | 2.03k | case OverloadedBuiltinKind::IntegerOrRawPointerOrVector: |
2020 | 2.03k | return T->is<BuiltinIntegerType>() || T->is<BuiltinRawPointerType>() || |
2021 | 2.03k | (T->is<BuiltinVectorType>() && |
2022 | 1.29k | T->castTo<BuiltinVectorType>()->getElementType() |
2023 | 1.29k | ->is<BuiltinIntegerType>()); |
2024 | 0 | case OverloadedBuiltinKind::Float: |
2025 | 0 | return T->is<BuiltinFloatType>(); |
2026 | 1.09k | case OverloadedBuiltinKind::FloatOrVector: |
2027 | 1.09k | return T->is<BuiltinFloatType>() || |
2028 | 1.09k | (T->is<BuiltinVectorType>() && |
2029 | 759 | T->castTo<BuiltinVectorType>()->getElementType() |
2030 | 759 | ->is<BuiltinFloatType>()); |
2031 | 5.78k | case OverloadedBuiltinKind::Special: |
2032 | 5.78k | return true; |
2033 | 13.5k | } |
2034 | 0 | llvm_unreachable("bad overloaded builtin kind"); |
2035 | 0 | } |
2036 | | |
2037 | 3 | bool swift::canBuiltinBeOverloadedForType(BuiltinValueKind ID, Type Ty) { |
2038 | 3 | if (ID == BuiltinValueKind::None) |
2039 | 0 | return false; |
2040 | | |
2041 | 3 | return isBuiltinTypeOverloaded(Ty, OverloadedBuiltinKinds[unsigned(ID)]); |
2042 | 3 | } |
2043 | | |
2044 | | /// Table of string intrinsic names indexed by enum value. |
2045 | | static const char *const IntrinsicNameTable[] = { |
2046 | | "not_intrinsic", |
2047 | | #define GET_INTRINSIC_NAME_TABLE |
2048 | | #include "llvm/IR/IntrinsicImpl.inc" |
2049 | | #undef GET_INTRINSIC_NAME_TABLE |
2050 | | }; |
2051 | | |
2052 | | #define GET_INTRINSIC_TARGET_DATA |
2053 | | #include "llvm/IR/IntrinsicImpl.inc" |
2054 | | #undef GET_INTRINSIC_TARGET_DATA |
2055 | | |
2056 | 303k | llvm::Intrinsic::ID swift::getLLVMIntrinsicID(StringRef InName) { |
2057 | 303k | using namespace llvm; |
2058 | | |
2059 | | // Swift intrinsic names start with int_. |
2060 | 303k | if (!InName.startswith("int_")) |
2061 | 280k | return llvm::Intrinsic::not_intrinsic; |
2062 | 22.6k | InName = InName.drop_front(strlen("int_")); |
2063 | | |
2064 | | // Prepend "llvm." and change _ to . in name. |
2065 | 22.6k | SmallString<128> NameS; |
2066 | 22.6k | NameS.append("llvm."); |
2067 | 22.6k | for (char C : InName) |
2068 | 115k | NameS.push_back(C == '_' ? '.' : C); |
2069 | | |
2070 | 22.6k | const char *Name = NameS.c_str(); |
2071 | 22.6k | ArrayRef<const char *> NameTable(&IntrinsicNameTable[1], |
2072 | 22.6k | TargetInfos[1].Offset); |
2073 | 22.6k | int Idx = Intrinsic::lookupLLVMIntrinsicByName(NameTable, Name); |
2074 | 22.6k | return static_cast<Intrinsic::ID>(Idx + 1); |
2075 | 303k | } |
2076 | | |
2077 | | llvm::Intrinsic::ID |
2078 | 6.10M | swift::getLLVMIntrinsicIDForBuiltinWithOverflow(BuiltinValueKind ID) { |
2079 | 6.10M | switch (ID) { |
2080 | 0 | default: break; |
2081 | 3.53M | case BuiltinValueKind::SAddOver: |
2082 | 3.53M | return llvm::Intrinsic::sadd_with_overflow; |
2083 | 340k | case BuiltinValueKind::UAddOver: |
2084 | 340k | return llvm::Intrinsic::uadd_with_overflow; |
2085 | 1.18M | case BuiltinValueKind::SSubOver: |
2086 | 1.18M | return llvm::Intrinsic::ssub_with_overflow; |
2087 | 679k | case BuiltinValueKind::USubOver: |
2088 | 679k | return llvm::Intrinsic::usub_with_overflow; |
2089 | 335k | case BuiltinValueKind::SMulOver: |
2090 | 335k | return llvm::Intrinsic::smul_with_overflow; |
2091 | 37.0k | case BuiltinValueKind::UMulOver: |
2092 | 37.0k | return llvm::Intrinsic::umul_with_overflow; |
2093 | 6.10M | } |
2094 | 0 | llvm_unreachable("Cannot convert the overflow builtin to llvm intrinsic."); |
2095 | 0 | } |
2096 | | |
2097 | | namespace { |
2098 | | |
2099 | | class IntrinsicTypeDecoder { |
2100 | | ArrayRef<llvm::Intrinsic::IITDescriptor> &Table; |
2101 | | ArrayRef<Type> TypeArguments; |
2102 | | ASTContext &Context; |
2103 | | public: |
2104 | | IntrinsicTypeDecoder(ArrayRef<llvm::Intrinsic::IITDescriptor> &table, |
2105 | | ArrayRef<Type> typeArguments, ASTContext &ctx) |
2106 | 2.32k | : Table(table), TypeArguments(typeArguments), Context(ctx) {} |
2107 | | |
2108 | | Type decodeImmediate(); |
2109 | | |
2110 | | /// Return the type argument at the given index. |
2111 | 1.99k | Type getTypeArgument(unsigned index) { |
2112 | 1.99k | if (index >= TypeArguments.size()) |
2113 | 0 | return Type(); |
2114 | 1.99k | return TypeArguments[index]; |
2115 | 1.99k | } |
2116 | | |
2117 | | /// Create a pointer type. |
2118 | 0 | Type makePointer(Type eltType, unsigned addrspace) { |
2119 | | // Reject non-default address space pointers. |
2120 | 0 | if (addrspace) |
2121 | 0 | return Type(); |
2122 | | |
2123 | | // For now, always ignore the element type and use RawPointer. |
2124 | 0 | return Context.TheRawPointerType; |
2125 | 0 | } |
2126 | | |
2127 | | /// Create a vector type. |
2128 | 0 | Type makeVector(Type eltType, unsigned width) { |
2129 | 0 | return BuiltinVectorType::get(Context, eltType, width); |
2130 | 0 | } |
2131 | | |
2132 | | /// Return the first type or, if the second type is a vector type, a vector |
2133 | | /// of the first type of the same length as the second type. |
2134 | 57 | Type maybeMakeVectorized(Type eltType, Type maybeVectorType) { |
2135 | 57 | if (auto vectorType = maybeVectorType->getAs<BuiltinVectorType>()) { |
2136 | 0 | return makeVector(eltType, vectorType->getNumElements()); |
2137 | 0 | } |
2138 | 57 | return eltType; |
2139 | 57 | } |
2140 | | }; |
2141 | | |
2142 | | } // end anonymous namespace |
2143 | | |
2144 | | static Type DecodeIntrinsicType(ArrayRef<llvm::Intrinsic::IITDescriptor> &table, |
2145 | 2.32k | ArrayRef<Type> typeArguments, ASTContext &ctx) { |
2146 | 2.32k | return IntrinsicTypeDecoder(table, typeArguments, ctx).decodeImmediate(); |
2147 | 2.32k | } |
2148 | | |
2149 | 2.49k | Type IntrinsicTypeDecoder::decodeImmediate() { |
2150 | 2.49k | typedef llvm::Intrinsic::IITDescriptor IITDescriptor; |
2151 | 2.49k | IITDescriptor D = Table.front(); |
2152 | 2.49k | Table = Table.slice(1); |
2153 | 2.49k | switch (D.Kind) { |
2154 | 0 | case IITDescriptor::BFloat: |
2155 | 0 | case IITDescriptor::MMX: |
2156 | 0 | case IITDescriptor::AMX: |
2157 | 0 | case IITDescriptor::Metadata: |
2158 | 0 | case IITDescriptor::ExtendArgument: |
2159 | 0 | case IITDescriptor::TruncArgument: |
2160 | 0 | case IITDescriptor::HalfVecArgument: |
2161 | 0 | case IITDescriptor::VarArg: |
2162 | 0 | case IITDescriptor::Token: |
2163 | 0 | case IITDescriptor::VecOfAnyPtrsToElt: |
2164 | 0 | case IITDescriptor::VecOfBitcastsToInt: |
2165 | 0 | case IITDescriptor::Subdivide2Argument: |
2166 | 0 | case IITDescriptor::Subdivide4Argument: |
2167 | 0 | case IITDescriptor::PPCQuad: |
2168 | 0 | case IITDescriptor::AArch64Svcount: |
2169 | | // These types cannot be expressed in swift yet. |
2170 | 0 | return Type(); |
2171 | | |
2172 | | // Fundamental types. |
2173 | 153 | case IITDescriptor::Void: |
2174 | 153 | return TupleType::getEmpty(Context); |
2175 | 0 | case IITDescriptor::Half: |
2176 | 0 | return Context.TheIEEE16Type; |
2177 | 0 | case IITDescriptor::Float: |
2178 | 0 | return Context.TheIEEE32Type; |
2179 | 0 | case IITDescriptor::Double: |
2180 | 0 | return Context.TheIEEE64Type; |
2181 | 0 | case IITDescriptor::Quad: |
2182 | 0 | return Context.TheIEEE128Type; |
2183 | 291 | case IITDescriptor::Integer: |
2184 | 291 | return BuiltinIntegerType::get(D.Integer_Width, Context); |
2185 | | |
2186 | | // A vector of an immediate type. |
2187 | 0 | case IITDescriptor::Vector: { |
2188 | 0 | Type eltType = decodeImmediate(); |
2189 | 0 | if (!eltType) return Type(); |
2190 | 0 | return makeVector(eltType, D.Vector_Width.getKnownMinValue()); |
2191 | 0 | } |
2192 | | |
2193 | | // The element type of a vector type. |
2194 | 3 | case IITDescriptor::VecElementArgument: { |
2195 | 3 | Type argType = getTypeArgument(D.getArgumentNumber()); |
2196 | 3 | if (!argType) return Type(); |
2197 | 3 | auto vecType = argType->getAs<BuiltinVectorType>(); |
2198 | 3 | if (!vecType) return Type(); |
2199 | 3 | return vecType->getElementType(); |
2200 | 3 | } |
2201 | | |
2202 | | // A pointer to an immediate type. |
2203 | 0 | case IITDescriptor::Pointer: { |
2204 | 0 | Type pointeeType = decodeImmediate(); |
2205 | 0 | if (!pointeeType) return Type(); |
2206 | 0 | return makePointer(pointeeType, D.Pointer_AddressSpace); |
2207 | 0 | } |
2208 | | |
2209 | | // A type argument. |
2210 | 1.93k | case IITDescriptor::Argument: |
2211 | 1.93k | return getTypeArgument(D.getArgumentNumber()); |
2212 | | |
2213 | | // A vector of the same width as a type argument. |
2214 | 57 | case IITDescriptor::SameVecWidthArgument: { |
2215 | 57 | Type maybeVectorType = getTypeArgument(D.getArgumentNumber()); |
2216 | 57 | if (!maybeVectorType) return Type(); |
2217 | 57 | Type eltType = decodeImmediate(); |
2218 | 57 | if (!eltType) return Type(); |
2219 | 57 | return maybeMakeVectorized(eltType, maybeVectorType); |
2220 | 57 | } |
2221 | | |
2222 | | |
2223 | | // A struct, which we translate as a tuple. |
2224 | 57 | case IITDescriptor::Struct: { |
2225 | 57 | SmallVector<TupleTypeElt, 5> Elts; |
2226 | 171 | for (unsigned i = 0; i != D.Struct_NumElements; ++i) { |
2227 | 114 | Type T = decodeImmediate(); |
2228 | 114 | if (!T) return Type(); |
2229 | | |
2230 | 114 | Elts.push_back(T); |
2231 | 114 | } |
2232 | 57 | return TupleType::get(Elts, Context); |
2233 | 57 | } |
2234 | 2.49k | } |
2235 | 0 | llvm_unreachable("unhandled"); |
2236 | 0 | } |
2237 | | |
2238 | | /// \returns true on success, false on failure. |
2239 | | static bool |
2240 | | getSwiftFunctionTypeForIntrinsic(llvm::Intrinsic::ID ID, |
2241 | | ArrayRef<Type> TypeArgs, |
2242 | | ASTContext &Context, |
2243 | | SmallVectorImpl<Type> &ArgElts, |
2244 | 909 | Type &ResultTy) { |
2245 | 909 | typedef llvm::Intrinsic::IITDescriptor IITDescriptor; |
2246 | 909 | SmallVector<IITDescriptor, 8> Table; |
2247 | 909 | getIntrinsicInfoTableEntries(ID, Table); |
2248 | | |
2249 | 909 | ArrayRef<IITDescriptor> TableRef = Table; |
2250 | | |
2251 | | // Decode the intrinsic's LLVM IR type, and map it to swift builtin types. |
2252 | 909 | ResultTy = DecodeIntrinsicType(TableRef, TypeArgs, Context); |
2253 | 909 | if (!ResultTy) |
2254 | 0 | return false; |
2255 | | |
2256 | 2.32k | while (!TableRef.empty()) { |
2257 | 1.41k | Type ArgTy = DecodeIntrinsicType(TableRef, TypeArgs, Context); |
2258 | 1.41k | if (!ArgTy) |
2259 | 0 | return false; |
2260 | 1.41k | ArgElts.push_back(ArgTy); |
2261 | 1.41k | } |
2262 | | |
2263 | | // Translate LLVM function attributes to Swift function attributes. |
2264 | 909 | IntrinsicInfo II; |
2265 | 909 | II.ID = ID; |
2266 | 909 | auto attrs = II.getOrCreateAttributes(Context); |
2267 | 909 | if (attrs.hasFnAttr(llvm::Attribute::NoReturn)) { |
2268 | 78 | ResultTy = Context.getNeverType(); |
2269 | 78 | if (!ResultTy) |
2270 | 0 | return false; |
2271 | 78 | } |
2272 | | |
2273 | 909 | return true; |
2274 | 909 | } |
2275 | | |
2276 | 9 | static bool isValidFenceOrdering(StringRef Ordering) { |
2277 | 9 | return Ordering == "acquire" || Ordering == "release" || |
2278 | 9 | Ordering == "acqrel" || Ordering == "seqcst"; |
2279 | 9 | } |
2280 | | |
2281 | 12 | static bool isValidRMWOrdering(StringRef Ordering) { |
2282 | 12 | return Ordering == "unordered" || Ordering == "monotonic" || |
2283 | 12 | Ordering == "acquire" || Ordering == "release" || |
2284 | 12 | Ordering == "acqrel" || Ordering == "seqcst"; |
2285 | 12 | } |
2286 | | |
2287 | 30 | static bool isValidLoadOrdering(StringRef Ordering) { |
2288 | 30 | return Ordering == "unordered" || Ordering == "monotonic" || |
2289 | 30 | Ordering == "acquire" || |
2290 | 30 | Ordering == "seqcst"; |
2291 | 30 | } |
2292 | | |
2293 | 15 | static bool isValidStoreOrdering(StringRef Ordering) { |
2294 | 15 | return Ordering == "unordered" || Ordering == "monotonic" || |
2295 | 15 | Ordering == "release" || |
2296 | 15 | Ordering == "seqcst"; |
2297 | 15 | } |
2298 | | |
2299 | 3.08k | llvm::AtomicOrdering swift::decodeLLVMAtomicOrdering(StringRef O) { |
2300 | 3.08k | using namespace llvm; |
2301 | 3.08k | return StringSwitch<AtomicOrdering>(O) |
2302 | 3.08k | .Case("unordered", AtomicOrdering::Unordered) |
2303 | 3.08k | .Case("monotonic", AtomicOrdering::Monotonic) |
2304 | 3.08k | .Case("acquire", AtomicOrdering::Acquire) |
2305 | 3.08k | .Case("release", AtomicOrdering::Release) |
2306 | 3.08k | .Case("acqrel", AtomicOrdering::AcquireRelease) |
2307 | 3.08k | .Case("seqcst", AtomicOrdering::SequentiallyConsistent) |
2308 | 3.08k | .Default(AtomicOrdering::NotAtomic); |
2309 | 3.08k | } |
2310 | | |
2311 | 66 | static bool isUnknownOrUnordered(llvm::AtomicOrdering ordering) { |
2312 | 66 | using namespace llvm; |
2313 | 66 | switch (ordering) { |
2314 | 0 | case AtomicOrdering::NotAtomic: |
2315 | 0 | case AtomicOrdering::Unordered: |
2316 | 0 | return true; |
2317 | | |
2318 | 9 | case AtomicOrdering::Monotonic: |
2319 | 27 | case AtomicOrdering::Acquire: |
2320 | 27 | case AtomicOrdering::Release: |
2321 | 36 | case AtomicOrdering::AcquireRelease: |
2322 | 66 | case AtomicOrdering::SequentiallyConsistent: |
2323 | 66 | return false; |
2324 | 66 | } |
2325 | | |
2326 | 0 | llvm_unreachable("Unhandled AtomicOrdering in switch."); |
2327 | 0 | } |
2328 | | |
2329 | | static bool isValidCmpXChgOrdering(StringRef SuccessString, |
2330 | 33 | StringRef FailureString) { |
2331 | 33 | using namespace llvm; |
2332 | 33 | AtomicOrdering SuccessOrdering = decodeLLVMAtomicOrdering(SuccessString); |
2333 | 33 | AtomicOrdering FailureOrdering = decodeLLVMAtomicOrdering(FailureString); |
2334 | | |
2335 | | // Unordered and unknown values are not allowed. |
2336 | 33 | if (isUnknownOrUnordered(SuccessOrdering) || |
2337 | 33 | isUnknownOrUnordered(FailureOrdering)) |
2338 | 0 | return false; |
2339 | | // Success must be at least as strong as failure. |
2340 | 33 | if (!isAtLeastOrStrongerThan(SuccessOrdering, FailureOrdering)) |
2341 | 0 | return false; |
2342 | | // Failure may not release because no store occurred. |
2343 | 33 | if (FailureOrdering == AtomicOrdering::Release || |
2344 | 33 | FailureOrdering == AtomicOrdering::AcquireRelease) |
2345 | 0 | return false; |
2346 | | |
2347 | 33 | return true; |
2348 | 33 | } |
2349 | | |
2350 | 41.7k | ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) { |
2351 | | // Builtin.TheTupleType resolves to the singleton instance of BuiltinTupleDecl. |
2352 | 41.7k | if (Id == Context.Id_TheTupleType) |
2353 | 3 | return Context.getBuiltinTupleDecl(); |
2354 | | |
2355 | 41.7k | SmallVector<Type, 4> Types; |
2356 | 41.7k | StringRef OperationName = getBuiltinBaseName(Context, Id.str(), Types); |
2357 | | |
2358 | | // If this is the name of an LLVM intrinsic, cons up a swift function with a |
2359 | | // type that matches the IR types. |
2360 | 41.7k | if (llvm::Intrinsic::ID ID = getLLVMIntrinsicID(OperationName)) { |
2361 | 909 | SmallVector<Type, 8> ArgElts; |
2362 | 909 | Type ResultTy; |
2363 | 909 | if (getSwiftFunctionTypeForIntrinsic(ID, Types, Context, ArgElts, ResultTy)) |
2364 | 909 | return getBuiltinFunction(Id, ArgElts, ResultTy); |
2365 | 909 | } |
2366 | | |
2367 | | // If this starts with fence, we have special suffixes to handle. |
2368 | 40.8k | if (OperationName.startswith("ifdef_")) { |
2369 | 6 | OperationName = OperationName.drop_front(strlen("ifdef_")); |
2370 | 6 | if (!Types.empty()) return nullptr; |
2371 | 6 | if (OperationName.empty()) return nullptr; |
2372 | 6 | return getIfdefOperation(Context, Id); |
2373 | 6 | } |
2374 | | |
2375 | | // If this starts with fence, we have special suffixes to handle. |
2376 | 40.8k | if (OperationName.startswith("fence_")) { |
2377 | 9 | OperationName = OperationName.drop_front(strlen("fence_")); |
2378 | | |
2379 | | // Verify we have a single integer, floating point, or pointer type. |
2380 | 9 | if (!Types.empty()) return nullptr; |
2381 | | |
2382 | | // Get and validate the ordering argument, which is required. |
2383 | 9 | auto Underscore = OperationName.find('_'); |
2384 | 9 | if (!isValidFenceOrdering(OperationName.substr(0, Underscore))) |
2385 | 0 | return nullptr; |
2386 | 9 | OperationName = OperationName.substr(Underscore); |
2387 | | |
2388 | | // Accept singlethread if present. |
2389 | 9 | if (OperationName.startswith("_singlethread")) |
2390 | 3 | OperationName = OperationName.drop_front(strlen("_singlethread")); |
2391 | | // Nothing else is allowed in the name. |
2392 | 9 | if (!OperationName.empty()) |
2393 | 0 | return nullptr; |
2394 | 9 | return getFenceOperation(Context, Id); |
2395 | 9 | } |
2396 | | |
2397 | | // If this starts with cmpxchg, we have special suffixes to handle. |
2398 | 40.8k | if (OperationName.startswith("cmpxchg_")) { |
2399 | 33 | OperationName = OperationName.drop_front(strlen("cmpxchg_")); |
2400 | | |
2401 | | // Verify we have a single integer, floating point, or pointer type. |
2402 | 33 | if (Types.size() != 1) return nullptr; |
2403 | 33 | Type T = Types[0]; |
2404 | 33 | if (!T->is<BuiltinIntegerType>() && !T->is<BuiltinRawPointerType>() && |
2405 | 33 | !T->is<BuiltinFloatType>()) |
2406 | 0 | return nullptr; |
2407 | | |
2408 | | // Get and validate the ordering arguments, which are both required. |
2409 | 33 | SmallVector<StringRef, 4> Parts; |
2410 | 33 | OperationName.split(Parts, "_"); |
2411 | 33 | if (Parts.size() < 2) |
2412 | 0 | return nullptr; |
2413 | 33 | if (!isValidCmpXChgOrdering(Parts[0], Parts[1])) |
2414 | 0 | return nullptr; |
2415 | 33 | auto NextPart = Parts.begin() + 2; |
2416 | | |
2417 | | // Accept weak, volatile, and singlethread if present. |
2418 | 33 | if (NextPart != Parts.end() && *NextPart == "weak") |
2419 | 3 | ++NextPart; |
2420 | 33 | if (NextPart != Parts.end() && *NextPart == "volatile") |
2421 | 12 | ++NextPart; |
2422 | 33 | if (NextPart != Parts.end() && *NextPart == "singlethread") |
2423 | 9 | ++NextPart; |
2424 | | // Nothing else is allowed in the name. |
2425 | 33 | if (NextPart != Parts.end()) |
2426 | 0 | return nullptr; |
2427 | 33 | return getCmpXChgOperation(Context, Id, T); |
2428 | 33 | } |
2429 | | |
2430 | | // If this starts with atomicrmw, we have special suffixes to handle. |
2431 | 40.8k | if (OperationName.startswith("atomicrmw_")) { |
2432 | 12 | OperationName = OperationName.drop_front(strlen("atomicrmw_")); |
2433 | | |
2434 | | // Verify we have a single integer or pointer type. |
2435 | 12 | if (Types.size() != 1) return nullptr; |
2436 | 12 | Type Ty = Types[0]; |
2437 | 12 | if (!Ty->is<BuiltinIntegerType>() && !Ty->is<BuiltinRawPointerType>()) |
2438 | 0 | return nullptr; |
2439 | | |
2440 | | // Get and validate the suboperation name, which is required. |
2441 | 12 | auto Underscore = OperationName.find('_'); |
2442 | 12 | if (Underscore == StringRef::npos) return nullptr; |
2443 | 12 | StringRef SubOp = OperationName.substr(0, Underscore); |
2444 | 12 | if (SubOp != "xchg" && SubOp != "add" && SubOp != "sub" && SubOp != "and" && |
2445 | 12 | SubOp != "nand" && SubOp != "or" && SubOp != "xor" && SubOp != "max" && |
2446 | 12 | SubOp != "min" && SubOp != "umax" && SubOp != "umin") |
2447 | 0 | return nullptr; |
2448 | 12 | OperationName = OperationName.drop_front(Underscore+1); |
2449 | | |
2450 | | // Get and validate the ordering argument, which is required. |
2451 | 12 | Underscore = OperationName.find('_'); |
2452 | 12 | if (!isValidRMWOrdering(OperationName.substr(0, Underscore))) |
2453 | 0 | return nullptr; |
2454 | 12 | OperationName = OperationName.substr(Underscore); |
2455 | | |
2456 | | // Accept volatile and singlethread if present. |
2457 | 12 | if (OperationName.startswith("_volatile")) |
2458 | 9 | OperationName = OperationName.drop_front(strlen("_volatile")); |
2459 | 12 | if (OperationName.startswith("_singlethread")) |
2460 | 6 | OperationName = OperationName.drop_front(strlen("_singlethread")); |
2461 | | // Nothing else is allowed in the name. |
2462 | 12 | if (!OperationName.empty()) |
2463 | 0 | return nullptr; |
2464 | 12 | return getAtomicRMWOperation(Context, Id, Ty); |
2465 | 12 | } |
2466 | | |
2467 | | // If this starts with atomicload or atomicstore, we have special suffixes to |
2468 | | // handle. |
2469 | 40.8k | if (OperationName.startswith("atomicload_")) { |
2470 | 30 | OperationName = OperationName.drop_front(strlen("atomicload_")); |
2471 | | |
2472 | | // Verify we have a single integer, floating point, or pointer type. |
2473 | 30 | if (Types.size() != 1) return nullptr; |
2474 | 30 | Type T = Types[0]; |
2475 | 30 | if (!T->is<BuiltinIntegerType>() && !T->is<BuiltinRawPointerType>() && |
2476 | 30 | !T->is<BuiltinFloatType>()) |
2477 | 0 | return nullptr; |
2478 | | |
2479 | | // Get and validate the ordering argument, which is required. |
2480 | 30 | auto Underscore = OperationName.find('_'); |
2481 | 30 | if (!isValidLoadOrdering(OperationName.substr(0, Underscore))) |
2482 | 0 | return nullptr; |
2483 | 30 | OperationName = OperationName.substr(Underscore); |
2484 | | |
2485 | | // Accept volatile and singlethread if present. |
2486 | 30 | if (OperationName.startswith("_volatile")) |
2487 | 6 | OperationName = OperationName.drop_front(strlen("_volatile")); |
2488 | 30 | if (OperationName.startswith("_singlethread")) |
2489 | 6 | OperationName = OperationName.drop_front(strlen("_singlethread")); |
2490 | | // Nothing else is allowed in the name. |
2491 | 30 | if (!OperationName.empty()) |
2492 | 0 | return nullptr; |
2493 | 30 | return getAtomicLoadOperation(Context, Id, T); |
2494 | 30 | } |
2495 | 40.7k | if (OperationName.startswith("atomicstore_")) { |
2496 | 15 | OperationName = OperationName.drop_front(strlen("atomicstore_")); |
2497 | | |
2498 | | // Verify we have a single integer, floating point, or pointer type. |
2499 | 15 | if (Types.size() != 1) return nullptr; |
2500 | 15 | Type T = Types[0]; |
2501 | 15 | if (!T->is<BuiltinIntegerType>() && !T->is<BuiltinRawPointerType>() && |
2502 | 15 | !T->is<BuiltinFloatType>()) |
2503 | 0 | return nullptr; |
2504 | | |
2505 | | // Get and validate the ordering argument, which is required. |
2506 | 15 | auto Underscore = OperationName.find('_'); |
2507 | 15 | if (!isValidStoreOrdering(OperationName.substr(0, Underscore))) |
2508 | 0 | return nullptr; |
2509 | 15 | OperationName = OperationName.substr(Underscore); |
2510 | | |
2511 | | // Accept volatile and singlethread if present. |
2512 | 15 | if (OperationName.startswith("_volatile")) |
2513 | 6 | OperationName = OperationName.drop_front(strlen("_volatile")); |
2514 | 15 | if (OperationName.startswith("_singlethread")) |
2515 | 6 | OperationName = OperationName.drop_front(strlen("_singlethread")); |
2516 | | // Nothing else is allowed in the name. |
2517 | 15 | if (!OperationName.empty()) |
2518 | 0 | return nullptr; |
2519 | 15 | return getAtomicStoreOperation(Context, Id, T); |
2520 | 15 | } |
2521 | 40.7k | if (OperationName.startswith("allocWithTailElems_")) { |
2522 | 21 | OperationName = OperationName.drop_front(strlen("allocWithTailElems_")); |
2523 | 21 | int NumTailTypes = 0; |
2524 | 21 | if (OperationName.getAsInteger(10, NumTailTypes)) |
2525 | 0 | return nullptr; |
2526 | | |
2527 | 21 | return getAllocWithTailElemsOperation(Context, Id, NumTailTypes); |
2528 | 21 | } |
2529 | 40.7k | if (OperationName.startswith("applyDerivative_")) { |
2530 | 12 | AutoDiffDerivativeFunctionKind kind; |
2531 | 12 | unsigned arity; |
2532 | 12 | bool throws; |
2533 | 12 | if (!autodiff::getBuiltinApplyDerivativeConfig( |
2534 | 12 | OperationName, kind, arity, throws)) |
2535 | 0 | return nullptr; |
2536 | 12 | return getAutoDiffApplyDerivativeFunction(Context, Id, kind, arity, |
2537 | 12 | throws, /*thrownType=*/Type()); |
2538 | 12 | } |
2539 | 40.7k | if (OperationName.startswith("applyTranspose_")) { |
2540 | 0 | unsigned arity; |
2541 | 0 | bool throws; |
2542 | 0 | if (!autodiff::getBuiltinApplyTransposeConfig( |
2543 | 0 | OperationName, arity, throws)) |
2544 | 0 | return nullptr; |
2545 | 0 | return getAutoDiffApplyTransposeFunction(Context, Id, arity, throws, |
2546 | 0 | /*thrownType=*/Type()); |
2547 | 0 | } |
2548 | | |
2549 | 40.7k | auto BV = llvm::StringSwitch<BuiltinValueKind>(OperationName) |
2550 | 9.65M | #define BUILTIN(id, name, Attrs) .Case(name, BuiltinValueKind::id) |
2551 | 40.7k | #include "swift/AST/Builtins.def" |
2552 | 40.7k | .Default(BuiltinValueKind::None); |
2553 | | |
2554 | | // Filter out inappropriate overloads. |
2555 | 40.7k | OverloadedBuiltinKind OBK = OverloadedBuiltinKinds[unsigned(BV)]; |
2556 | | |
2557 | | // Verify that all types match the overload filter. |
2558 | 40.7k | for (Type T : Types) |
2559 | 13.4k | if (!isBuiltinTypeOverloaded(T, OBK)) |
2560 | 0 | return nullptr; |
2561 | | |
2562 | 40.7k | switch (BV) { |
2563 | 0 | case BuiltinValueKind::Fence: |
2564 | 0 | case BuiltinValueKind::Ifdef: |
2565 | 0 | case BuiltinValueKind::CmpXChg: |
2566 | 0 | case BuiltinValueKind::AtomicRMW: |
2567 | 0 | case BuiltinValueKind::AtomicLoad: |
2568 | 0 | case BuiltinValueKind::AtomicStore: |
2569 | 0 | case BuiltinValueKind::AllocWithTailElems: |
2570 | 0 | llvm_unreachable("Handled above"); |
2571 | 78 | case BuiltinValueKind::None: return nullptr; |
2572 | | |
2573 | 27 | case BuiltinValueKind::GepRaw: |
2574 | 27 | if (Types.size() != 1) return nullptr; |
2575 | 27 | return getGepRawOperation(Context, Id, Types[0]); |
2576 | | |
2577 | 30 | case BuiltinValueKind::StringObjectOr: |
2578 | 30 | if (Types.size() != 1) |
2579 | 0 | return nullptr; |
2580 | 30 | return getStringObjectOrOperation(Context, Id, Types[0]); |
2581 | | |
2582 | 15 | case BuiltinValueKind::Gep: |
2583 | 15 | if (Types.size() != 1) return nullptr; |
2584 | 15 | return getGepOperation(Context, Id, Types[0]); |
2585 | | |
2586 | 6 | case BuiltinValueKind::GetTailAddr: |
2587 | 6 | if (Types.size() != 1) return nullptr; |
2588 | 6 | return getGetTailAddrOperation(Context, Id, Types[0]); |
2589 | | |
2590 | 9 | case BuiltinValueKind::PerformInstantaneousReadAccess: |
2591 | 9 | if (!Types.empty()) return nullptr; |
2592 | 9 | return getPerformInstantaneousReadAccessOperation(Context, Id); |
2593 | | |
2594 | 9 | case BuiltinValueKind::BeginUnpairedModifyAccess: |
2595 | 9 | if (!Types.empty()) return nullptr; |
2596 | 9 | return getBeginUnpairedAccessOperation(Context, Id); |
2597 | | |
2598 | 3 | case BuiltinValueKind::EndUnpairedAccess: |
2599 | 3 | if (!Types.empty()) return nullptr; |
2600 | 3 | return getEndUnpairedAccessOperation(Context, Id); |
2601 | | |
2602 | 30 | case BuiltinValueKind::Copy: |
2603 | 30 | if (!Types.empty()) |
2604 | 0 | return nullptr; |
2605 | 30 | return getCopyOperation(Context, Id); |
2606 | | |
2607 | 18 | case BuiltinValueKind::AssumeAlignment: |
2608 | 18 | if (!Types.empty()) |
2609 | 0 | return nullptr; |
2610 | 18 | return getAssumeAlignment(Context, Id); |
2611 | | |
2612 | 0 | #define BUILTIN(id, name, Attrs) |
2613 | 0 | #define BUILTIN_BINARY_OPERATION(id, name, attrs) |
2614 | 0 | #define BUILTIN_BINARY_OPERATION_OVERLOADED_STATIC(id, name, attrs, overload) \ |
2615 | 30.8k | case BuiltinValueKind::id: |
2616 | 30.8k | #include "swift/AST/Builtins.def" |
2617 | 30.8k | if (Types.size() != 1) return nullptr; |
2618 | 2.48k | return getBinaryOperation(Context, Id, Types[0]); |
2619 | | |
2620 | 0 | #define BUILTIN(id, name, attrs) |
2621 | 0 | #define BUILTIN_BINARY_OPERATION(id, name, attrs) |
2622 | 0 | #define BUILTIN_BINARY_OPERATION_POLYMORPHIC(id, name) \ |
2623 | 2.74k | case BuiltinValueKind::id: |
2624 | 2.74k | #include "swift/AST/Builtins.def" |
2625 | 2.74k | if (!Types.empty()) |
2626 | 0 | return nullptr; |
2627 | 228 | return getPolymorphicBinaryOperation(Context, Id); |
2628 | | |
2629 | 0 | #define BUILTIN(id, name, Attrs) |
2630 | 3.45k | #define BUILTIN_BINARY_OPERATION_WITH_OVERFLOW(id, name, _, attrs, overload) case BuiltinValueKind::id: |
2631 | 3.45k | #include "swift/AST/Builtins.def" |
2632 | 3.45k | if (Types.size() != 1) return nullptr; |
2633 | 786 | return getBinaryOperationWithOverflow(Context, Id, Types[0]); |
2634 | | |
2635 | 0 | #define BUILTIN(id, name, Attrs) |
2636 | 76.2k | #define BUILTIN_BINARY_PREDICATE(id, name, attrs, overload) case BuiltinValueKind::id: |
2637 | 76.2k | #include "swift/AST/Builtins.def" |
2638 | 76.2k | if (Types.size() != 1) return nullptr; |
2639 | 4.22k | return getBinaryPredicate(Context, Id, Types[0]); |
2640 | | |
2641 | 0 | #define BUILTIN(id, name, Attrs) |
2642 | 297 | #define BUILTIN_UNARY_OPERATION(id, name, attrs, overload) case BuiltinValueKind::id: |
2643 | 4.22k | #include "swift/AST/Builtins.def" |
2644 | 297 | if (Types.size() != 1) return nullptr; |
2645 | 141 | return getUnaryOperation(Context, Id, Types[0]); |
2646 | | |
2647 | 0 | #define BUILTIN(id, name, Attrs) |
2648 | 10.2k | #define BUILTIN_CAST_OPERATION(id, name, attrs) case BuiltinValueKind::id: |
2649 | 4.89k | #define BUILTIN_CAST_OR_BITCAST_OPERATION(id, name, attrs) case BuiltinValueKind::id: |
2650 | 1.76k | #include "swift/AST/Builtins.def" |
2651 | 1.76k | return getCastOperation(Context, Id, BV, Types); |
2652 | | |
2653 | 24 | case BuiltinValueKind::Retain: |
2654 | 48 | case BuiltinValueKind::Release: |
2655 | 63 | case BuiltinValueKind::Autorelease: |
2656 | 63 | if (!Types.empty()) return nullptr; |
2657 | 63 | return getRefCountingOperation(Context, Id); |
2658 | | |
2659 | 9 | case BuiltinValueKind::Load: |
2660 | 27 | case BuiltinValueKind::LoadRaw: |
2661 | 33 | case BuiltinValueKind::LoadInvariant: |
2662 | 51 | case BuiltinValueKind::Take: |
2663 | 51 | if (!Types.empty()) return nullptr; |
2664 | 51 | return getLoadOperation(Context, Id); |
2665 | | |
2666 | 9 | case BuiltinValueKind::Destroy: |
2667 | 9 | if (!Types.empty()) return nullptr; |
2668 | 9 | return getDestroyOperation(Context, Id); |
2669 | | |
2670 | 12 | case BuiltinValueKind::Assign: |
2671 | 81 | case BuiltinValueKind::Init: |
2672 | 81 | if (!Types.empty()) return nullptr; |
2673 | 81 | return getStoreOperation(Context, Id); |
2674 | | |
2675 | 2.01k | case BuiltinValueKind::DestroyArray: |
2676 | 2.01k | if (!Types.empty()) return nullptr; |
2677 | 2.01k | return getDestroyArrayOperation(Context, Id); |
2678 | | |
2679 | 2.28k | case BuiltinValueKind::CopyArray: |
2680 | 2.30k | case BuiltinValueKind::TakeArrayNoAlias: |
2681 | 4.22k | case BuiltinValueKind::TakeArrayFrontToBack: |
2682 | 6.13k | case BuiltinValueKind::TakeArrayBackToFront: |
2683 | 6.15k | case BuiltinValueKind::AssignCopyArrayNoAlias: |
2684 | 6.27k | case BuiltinValueKind::AssignCopyArrayFrontToBack: |
2685 | 6.39k | case BuiltinValueKind::AssignCopyArrayBackToFront: |
2686 | 6.44k | case BuiltinValueKind::AssignTakeArray: |
2687 | 6.44k | if (!Types.empty()) return nullptr; |
2688 | 6.44k | return getTransferArrayOperation(Context, Id); |
2689 | | |
2690 | 27 | case BuiltinValueKind::IsUnique: |
2691 | 45 | case BuiltinValueKind::IsUnique_native: |
2692 | 60 | case BuiltinValueKind::BeginCOWMutation: |
2693 | 75 | case BuiltinValueKind::BeginCOWMutation_native: |
2694 | 75 | if (!Types.empty()) return nullptr; |
2695 | | // BeginCOWMutation has the same signature as IsUnique. |
2696 | 75 | return getIsUniqueOperation(Context, Id); |
2697 | | |
2698 | 15 | case BuiltinValueKind::EndCOWMutation: |
2699 | 15 | if (!Types.empty()) return nullptr; |
2700 | 15 | return getEndCOWMutation(Context, Id); |
2701 | | |
2702 | 15 | case BuiltinValueKind::BindMemory: |
2703 | 15 | if (!Types.empty()) return nullptr; |
2704 | 15 | return getBindMemoryOperation(Context, Id); |
2705 | | |
2706 | 15 | case BuiltinValueKind::RebindMemory: |
2707 | 15 | if (!Types.empty()) return nullptr; |
2708 | 15 | return getRebindMemoryOperation(Context, Id); |
2709 | | |
2710 | 15 | case BuiltinValueKind::ProjectTailElems: |
2711 | 15 | if (!Types.empty()) return nullptr; |
2712 | 15 | return getProjectTailElemsOperation(Context, Id); |
2713 | | |
2714 | 860 | case BuiltinValueKind::Sizeof: |
2715 | 3.76k | case BuiltinValueKind::Strideof: |
2716 | 6.17k | case BuiltinValueKind::Alignof: |
2717 | 6.17k | return getSizeOrAlignOfOperation(Context, Id); |
2718 | | |
2719 | 205 | case BuiltinValueKind::IsPOD: |
2720 | 205 | return getIsPODOperation(Context, Id); |
2721 | | |
2722 | 87 | case BuiltinValueKind::IsConcrete: |
2723 | 87 | return getIsConcrete(Context, Id); |
2724 | | |
2725 | 21 | case BuiltinValueKind::IsBitwiseTakable: |
2726 | 21 | return getIsBitwiseTakable(Context, Id); |
2727 | | |
2728 | 18 | case BuiltinValueKind::IsOptionalType: |
2729 | 18 | return getIsOptionalOperation(Context, Id); |
2730 | | |
2731 | 48 | case BuiltinValueKind::IsSameMetatype: |
2732 | 48 | return getIsSameMetatypeOperation(Context, Id); |
2733 | | |
2734 | 21 | case BuiltinValueKind::AllocRaw: |
2735 | 21 | return getAllocOperation(Context, Id); |
2736 | | |
2737 | 15 | case BuiltinValueKind::DeallocRaw: |
2738 | 15 | return getDeallocOperation(Context, Id); |
2739 | | |
2740 | 27 | case BuiltinValueKind::StackAlloc: |
2741 | 45 | case BuiltinValueKind::UnprotectedStackAlloc: |
2742 | 45 | return getStackAllocOperation(Context, Id); |
2743 | 27 | case BuiltinValueKind::StackDealloc: |
2744 | 27 | return getStackDeallocOperation(Context, Id); |
2745 | | |
2746 | 12 | case BuiltinValueKind::CastToNativeObject: |
2747 | 39 | case BuiltinValueKind::UnsafeCastToNativeObject: |
2748 | 57 | case BuiltinValueKind::CastFromNativeObject: |
2749 | 75 | case BuiltinValueKind::BridgeToRawPointer: |
2750 | 93 | case BuiltinValueKind::BridgeFromRawPointer: |
2751 | 93 | if (!Types.empty()) return nullptr; |
2752 | 93 | return getNativeObjectCast(Context, Id, BV); |
2753 | | |
2754 | 27 | case BuiltinValueKind::CastToBridgeObject: |
2755 | 27 | if (!Types.empty()) return nullptr; |
2756 | 27 | return getCastToBridgeObjectOperation(Context, Id); |
2757 | 24 | case BuiltinValueKind::CastReferenceFromBridgeObject: |
2758 | 48 | case BuiltinValueKind::CastBitPatternFromBridgeObject: |
2759 | 48 | if (!Types.empty()) return nullptr; |
2760 | 48 | return getCastFromBridgeObjectOperation(Context, Id, BV); |
2761 | | |
2762 | 18 | case BuiltinValueKind::CastReference: |
2763 | 18 | if (!Types.empty()) return nullptr; |
2764 | 18 | return getCastReferenceOperation(Context, Id); |
2765 | | |
2766 | 720 | case BuiltinValueKind::ReinterpretCast: |
2767 | 720 | if (!Types.empty()) return nullptr; |
2768 | 720 | return getReinterpretCastOperation(Context, Id); |
2769 | | |
2770 | 60 | case BuiltinValueKind::AddressOf: |
2771 | 126 | case BuiltinValueKind::UnprotectedAddressOf: |
2772 | 126 | if (!Types.empty()) return nullptr; |
2773 | 126 | return getAddressOfOperation(Context, Id); |
2774 | | |
2775 | 6 | case BuiltinValueKind::LegacyCondFail: |
2776 | 6 | return getLegacyCondFailOperation(Context, Id); |
2777 | | |
2778 | 24 | case BuiltinValueKind::AddressOfBorrow: |
2779 | 24 | case BuiltinValueKind::AddressOfBorrowOpaque: |
2780 | 45 | case BuiltinValueKind::UnprotectedAddressOfBorrow: |
2781 | 45 | case BuiltinValueKind::UnprotectedAddressOfBorrowOpaque: |
2782 | 45 | if (!Types.empty()) return nullptr; |
2783 | 45 | return getAddressOfBorrowOperation(Context, Id); |
2784 | | |
2785 | 27 | case BuiltinValueKind::CondFailMessage: |
2786 | 27 | return getCondFailOperation(Context, Id); |
2787 | | |
2788 | 99 | case BuiltinValueKind::AssertConf: |
2789 | 99 | return getAssertConfOperation(Context, Id); |
2790 | | |
2791 | 18 | case BuiltinValueKind::FixLifetime: |
2792 | 18 | return getFixLifetimeOperation(Context, Id); |
2793 | | |
2794 | 1.90k | case BuiltinValueKind::CanBeObjCClass: |
2795 | 1.90k | return getCanBeObjCClassOperation(Context, Id); |
2796 | | |
2797 | 27 | case BuiltinValueKind::CondUnreachable: |
2798 | 54 | case BuiltinValueKind::Unreachable: |
2799 | 54 | return getUnreachableOperation(Context, Id); |
2800 | | |
2801 | 560 | case BuiltinValueKind::ZeroInitializer: |
2802 | 560 | return getZeroInitializerOperation(Context, Id); |
2803 | | |
2804 | 5.58k | case BuiltinValueKind::Once: |
2805 | 5.58k | case BuiltinValueKind::OnceWithContext: |
2806 | 5.58k | return getOnceOperation(Context, Id, BV == BuiltinValueKind::OnceWithContext); |
2807 | | |
2808 | 81 | case BuiltinValueKind::WillThrow: |
2809 | 93 | case BuiltinValueKind::ErrorInMain: |
2810 | 93 | return getVoidErrorOperation(Context, Id); |
2811 | | |
2812 | 12 | case BuiltinValueKind::UnexpectedError: |
2813 | 12 | return getUnexpectedErrorOperation(Context, Id); |
2814 | | |
2815 | 357 | case BuiltinValueKind::ExtractElement: |
2816 | 357 | if (Types.size() != 2) return nullptr; |
2817 | 357 | return getExtractElementOperation(Context, Id, Types[0], Types[1]); |
2818 | | |
2819 | 357 | case BuiltinValueKind::InsertElement: |
2820 | 357 | if (Types.size() != 3) return nullptr; |
2821 | 357 | return getInsertElementOperation(Context, Id, Types[0], Types[1], Types[2]); |
2822 | | |
2823 | 3 | case BuiltinValueKind::ShuffleVector: |
2824 | 3 | if (Types.size() != 2) return nullptr; |
2825 | 3 | return getShuffleVectorOperation(Context, Id, Types[0], Types[1]); |
2826 | | |
2827 | 18 | case BuiltinValueKind::StaticReport: |
2828 | 18 | if (!Types.empty()) return nullptr; |
2829 | 18 | return getStaticReportOperation(Context, Id); |
2830 | | |
2831 | 132 | case BuiltinValueKind::SToSCheckedTrunc: |
2832 | 207 | case BuiltinValueKind::SToUCheckedTrunc: |
2833 | 207 | if (Types.size() != 2) return nullptr; |
2834 | 207 | return getCheckedTruncOperation(Context, Id, Types[0], Types[1], true); |
2835 | | |
2836 | 3 | case BuiltinValueKind::UToSCheckedTrunc: |
2837 | 9 | case BuiltinValueKind::UToUCheckedTrunc: |
2838 | 9 | if (Types.size() != 2) return nullptr; |
2839 | 9 | return getCheckedTruncOperation(Context, Id, Types[0], Types[1], false); |
2840 | | |
2841 | 9 | case BuiltinValueKind::ClassifyBridgeObject: |
2842 | 9 | if (!Types.empty()) return nullptr; |
2843 | 9 | return getClassifyBridgeObject(Context, Id); |
2844 | 15 | case BuiltinValueKind::ValueToBridgeObject: |
2845 | 15 | if (!Types.empty()) |
2846 | 0 | return nullptr; |
2847 | 15 | return getValueToBridgeObject(Context, Id); |
2848 | | |
2849 | 27 | case BuiltinValueKind::COWBufferForReading: |
2850 | 27 | return getCOWBufferForReading(Context, Id); |
2851 | | |
2852 | 0 | case BuiltinValueKind::ApplyDerivative: |
2853 | 0 | case BuiltinValueKind::ApplyTranspose: |
2854 | 0 | llvm_unreachable("Handled above"); |
2855 | |
|
2856 | 21 | case BuiltinValueKind::OnFastPath: |
2857 | 21 | return getOnFastPath(Context, Id); |
2858 | | |
2859 | 45 | case BuiltinValueKind::IntToFPWithOverflow: |
2860 | 45 | if (Types.size() != 2) return nullptr; |
2861 | 45 | return getIntToFPWithOverflowOperation(Context, Id, Types[0], Types[1]); |
2862 | | |
2863 | 12 | case BuiltinValueKind::BitWidth: |
2864 | 12 | if (Types.size() != 1) return nullptr; |
2865 | 12 | return getBitWidthOperation(Context, Id, Types[0]); |
2866 | | |
2867 | 12 | case BuiltinValueKind::IsNegative: |
2868 | 12 | if (Types.size() != 1) return nullptr; |
2869 | 12 | return getIsNegativeOperation(Context, Id, Types[0]); |
2870 | | |
2871 | 12 | case BuiltinValueKind::WordAtIndex: |
2872 | 12 | if (Types.size() != 1) return nullptr; |
2873 | 12 | return getWordAtIndexOperation(Context, Id, Types[0]); |
2874 | | |
2875 | 18 | case BuiltinValueKind::GetObjCTypeEncoding: |
2876 | 18 | return getGetObjCTypeEncodingOperation(Context, Id); |
2877 | | |
2878 | 18 | case BuiltinValueKind::GlobalStringTablePointer: |
2879 | 18 | return getGlobalStringTablePointer(Context, Id); |
2880 | | |
2881 | 0 | case BuiltinValueKind::ConvertStrongToUnownedUnsafe: |
2882 | 0 | return getConvertStrongToUnownedUnsafe(Context, Id); |
2883 | | |
2884 | 18 | case BuiltinValueKind::ConvertUnownedUnsafeToGuaranteed: |
2885 | 18 | return getConvertUnownedUnsafeToGuaranteed(Context, Id); |
2886 | | |
2887 | 12 | case BuiltinValueKind::GetCurrentAsyncTask: |
2888 | 12 | return getGetCurrentAsyncTask(Context, Id); |
2889 | | |
2890 | 6 | case BuiltinValueKind::GetCurrentExecutor: |
2891 | 6 | return getGetCurrentExecutor(Context, Id); |
2892 | | |
2893 | 9 | case BuiltinValueKind::CancelAsyncTask: |
2894 | 9 | return getCancelAsyncTask(Context, Id); |
2895 | | |
2896 | 759 | case BuiltinValueKind::CreateAsyncTask: |
2897 | 759 | return getCreateAsyncTask(Context, Id); |
2898 | | |
2899 | 147 | case BuiltinValueKind::CreateAsyncTaskInGroup: |
2900 | 147 | return getCreateAsyncTaskInGroup(Context, Id); |
2901 | | |
2902 | 9 | case BuiltinValueKind::TaskRunInline: |
2903 | 9 | return getTaskRunInline(Context, Id); |
2904 | | |
2905 | 15 | case BuiltinValueKind::TargetOSVersionAtLeast: |
2906 | 15 | return getTargetOSVersionAtLeast(Context, Id); |
2907 | | |
2908 | 3 | case BuiltinValueKind::ConvertTaskToJob: |
2909 | 3 | return getConvertTaskToJob(Context, Id); |
2910 | | |
2911 | 36 | case BuiltinValueKind::BuildMainActorExecutorRef: |
2912 | 36 | return getBuildMainActorExecutorRef(Context, Id); |
2913 | | |
2914 | 2.94k | case BuiltinValueKind::BuildDefaultActorExecutorRef: |
2915 | 2.94k | return getBuildDefaultActorExecutorRef(Context, Id); |
2916 | | |
2917 | 39 | case BuiltinValueKind::BuildOrdinarySerialExecutorRef: |
2918 | 39 | return getBuildOrdinarySerialExecutorRef(Context, Id); |
2919 | 36 | case BuiltinValueKind::BuildComplexEqualitySerialExecutorRef: |
2920 | 36 | return getBuildComplexEqualitySerialExecutorRef(Context, Id); |
2921 | | |
2922 | 9 | case BuiltinValueKind::PoundAssert: |
2923 | 9 | return getPoundAssert(Context, Id); |
2924 | | |
2925 | 24 | case BuiltinValueKind::TSanInoutAccess: |
2926 | 24 | return getTSanInoutAccess(Context, Id); |
2927 | | |
2928 | 0 | case BuiltinValueKind::Swift3ImplicitObjCEntrypoint: |
2929 | 0 | return getBuiltinFunction(Id, |
2930 | 0 | {}, |
2931 | 0 | TupleType::getEmpty(Context)); |
2932 | | |
2933 | 0 | case BuiltinValueKind::TypePtrAuthDiscriminator: |
2934 | 0 | return getTypePtrAuthDiscriminator(Context, Id); |
2935 | | |
2936 | 3 | case BuiltinValueKind::TypeJoin: |
2937 | 3 | return getTypeJoinOperation(Context, Id); |
2938 | | |
2939 | 0 | case BuiltinValueKind::TypeJoinInout: |
2940 | 0 | return getTypeJoinInoutOperation(Context, Id); |
2941 | | |
2942 | 3 | case BuiltinValueKind::TypeJoinMeta: |
2943 | 3 | return getTypeJoinMetaOperation(Context, Id); |
2944 | | |
2945 | 3 | case BuiltinValueKind::TriggerFallbackDiagnostic: |
2946 | 3 | return getTriggerFallbackDiagnosticOperation(Context, Id); |
2947 | | |
2948 | 3 | case BuiltinValueKind::InitializeDefaultActor: |
2949 | 3 | case BuiltinValueKind::InitializeNonDefaultDistributedActor: |
2950 | 6 | case BuiltinValueKind::DestroyDefaultActor: |
2951 | 6 | return getDefaultActorInitDestroy(Context, Id); |
2952 | | |
2953 | 0 | case BuiltinValueKind::InitializeDistributedRemoteActor: |
2954 | 0 | return getDistributedActorInitializeRemote(Context, Id); |
2955 | | |
2956 | 336 | case BuiltinValueKind::StartAsyncLet: |
2957 | 342 | case BuiltinValueKind::StartAsyncLetWithLocalBuffer: |
2958 | 342 | return getStartAsyncLet(Context, Id); |
2959 | | |
2960 | 0 | case BuiltinValueKind::EndAsyncLet: |
2961 | 6 | case BuiltinValueKind::EndAsyncLetLifetime: |
2962 | 6 | return getEndAsyncLet(Context, Id); |
2963 | | |
2964 | 42 | case BuiltinValueKind::CreateTaskGroup: |
2965 | 42 | return getCreateTaskGroup(Context, Id); |
2966 | 36 | case BuiltinValueKind::CreateTaskGroupWithFlags: |
2967 | 36 | return getCreateTaskGroupWithFlags(Context, Id); |
2968 | | |
2969 | 42 | case BuiltinValueKind::DestroyTaskGroup: |
2970 | 42 | return getDestroyTaskGroup(Context, Id); |
2971 | | |
2972 | 54 | case BuiltinValueKind::ResumeNonThrowingContinuationReturning: |
2973 | 144 | case BuiltinValueKind::ResumeThrowingContinuationReturning: |
2974 | 144 | return getResumeContinuationReturning(Context, Id); |
2975 | | |
2976 | 45 | case BuiltinValueKind::ResumeThrowingContinuationThrowing: |
2977 | 45 | return getResumeContinuationThrowing(Context, Id); |
2978 | | |
2979 | 39 | case BuiltinValueKind::WithUnsafeContinuation: |
2980 | 39 | return getWithUnsafeContinuation(Context, Id, /*throws=*/false); |
2981 | | |
2982 | 39 | case BuiltinValueKind::WithUnsafeThrowingContinuation: |
2983 | 39 | return getWithUnsafeContinuation(Context, Id, /*throws=*/true); |
2984 | | |
2985 | 3 | case BuiltinValueKind::HopToActor: |
2986 | 3 | return getHopToActor(Context, Id); |
2987 | | |
2988 | 8 | case BuiltinValueKind::AutoDiffCreateLinearMapContextWithType: |
2989 | 8 | return getAutoDiffCreateLinearMapContext(Context, Id); |
2990 | | |
2991 | 8 | case BuiltinValueKind::AutoDiffProjectTopLevelSubcontext: |
2992 | 8 | return getAutoDiffProjectTopLevelSubcontext(Context, Id); |
2993 | | |
2994 | 8 | case BuiltinValueKind::AutoDiffAllocateSubcontextWithType: |
2995 | 8 | return getAutoDiffAllocateSubcontext(Context, Id); |
2996 | | |
2997 | 9 | case BuiltinValueKind::PackLength: |
2998 | 9 | return getPackLength(Context, Id); |
2999 | 40.7k | } |
3000 | | |
3001 | 0 | llvm_unreachable("bad builtin value!"); |
3002 | 0 | } |
3003 | | |
3004 | 10.0k | StringRef swift::getBuiltinName(BuiltinValueKind ID) { |
3005 | 10.0k | switch (ID) { |
3006 | 0 | case BuiltinValueKind::None: |
3007 | 0 | llvm_unreachable("no builtin kind"); |
3008 | 0 | #define BUILTIN(Id, Name, Attrs) \ |
3009 | 10.0k | case BuiltinValueKind::Id: \ |
3010 | 10.0k | return Name; |
3011 | 10.0k | #include "swift/AST/Builtins.def" |
3012 | 10.0k | } |
3013 | 0 | llvm_unreachable("bad BuiltinValueKind"); |
3014 | 0 | } |
3015 | | |
3016 | 35.6M | bool swift::isPolymorphicBuiltin(BuiltinValueKind id) { |
3017 | 35.6M | switch (id) { |
3018 | 0 | case BuiltinValueKind::None: |
3019 | 0 | llvm_unreachable("no builtin kind"); |
3020 | 0 | #define BUILTIN(Id, Name, Attrs) \ |
3021 | 35.6M | case BuiltinValueKind::Id: \ |
3022 | 35.6M | return false; |
3023 | 0 | #define BUILTIN_BINARY_OPERATION_POLYMORPHIC(Id, Name) \ |
3024 | 351 | case BuiltinValueKind::Id: \ |
3025 | 351 | return true; |
3026 | 35.6M | #include "swift/AST/Builtins.def" |
3027 | 35.6M | } |
3028 | 0 | llvm_unreachable("bad BuiltinValueKind"); |
3029 | 0 | } |
3030 | | |
3031 | 6.40M | BuiltinTypeKind BuiltinType::getBuiltinTypeKind() const { |
3032 | | // If we do not have a vector or an integer our job is easy. |
3033 | 6.40M | return BuiltinTypeKind(std::underlying_type<TypeKind>::type(getKind())); |
3034 | 6.40M | } |
3035 | | |
3036 | | StringRef BuiltinType::getTypeName(SmallVectorImpl<char> &result, |
3037 | 6.40M | bool prependBuiltinNamespace) const { |
3038 | | #ifdef MAYBE_GET_NAMESPACED_BUILTIN |
3039 | | #error \ |
3040 | | "We define MAYBE_GET_NAMESPACED_BUILTIN here. Do not define before this?!" |
3041 | | #endif |
3042 | 6.40M | #define MAYBE_GET_NAMESPACED_BUILTIN(NAME) \ |
3043 | 6.40M | ((prependBuiltinNamespace) ? NAME : NAME.getWithoutPrefix()) |
3044 | | |
3045 | 6.40M | llvm::raw_svector_ostream printer(result); |
3046 | 6.40M | switch (getBuiltinTypeKind()) { |
3047 | 405k | case BuiltinTypeKind::BuiltinRawPointer: |
3048 | 405k | printer << MAYBE_GET_NAMESPACED_BUILTIN(BUILTIN_TYPE_NAME_RAWPOINTER); |
3049 | 405k | break; |
3050 | 846 | case BuiltinTypeKind::BuiltinRawUnsafeContinuation: |
3051 | 846 | printer << MAYBE_GET_NAMESPACED_BUILTIN(BUILTIN_TYPE_NAME_RAWUNSAFECONTINUATION); |
3052 | 846 | break; |
3053 | 87 | case BuiltinTypeKind::BuiltinJob: |
3054 | 87 | printer << MAYBE_GET_NAMESPACED_BUILTIN(BUILTIN_TYPE_NAME_JOB); |
3055 | 87 | break; |
3056 | 6.46k | case BuiltinTypeKind::BuiltinExecutor: |
3057 | 6.46k | printer << MAYBE_GET_NAMESPACED_BUILTIN(BUILTIN_TYPE_NAME_EXECUTOR); |
3058 | 6.46k | break; |
3059 | 0 | case BuiltinTypeKind::BuiltinDefaultActorStorage: |
3060 | 0 | printer << MAYBE_GET_NAMESPACED_BUILTIN(BUILTIN_TYPE_NAME_DEFAULTACTORSTORAGE); |
3061 | 0 | break; |
3062 | 0 | case BuiltinTypeKind::BuiltinNonDefaultDistributedActorStorage: |
3063 | 0 | printer << MAYBE_GET_NAMESPACED_BUILTIN(BUILTIN_TYPE_NAME_NONDEFAULTDISTRIBUTEDACTORSTORAGE); |
3064 | 0 | break; |
3065 | 9 | case BuiltinTypeKind::BuiltinPackIndex: |
3066 | 9 | printer << MAYBE_GET_NAMESPACED_BUILTIN(BUILTIN_TYPE_NAME_PACKINDEX); |
3067 | 9 | break; |
3068 | 83.2k | case BuiltinTypeKind::BuiltinNativeObject: |
3069 | 83.2k | printer << MAYBE_GET_NAMESPACED_BUILTIN(BUILTIN_TYPE_NAME_NATIVEOBJECT); |
3070 | 83.2k | break; |
3071 | 104k | case BuiltinTypeKind::BuiltinBridgeObject: |
3072 | 104k | printer << MAYBE_GET_NAMESPACED_BUILTIN(BUILTIN_TYPE_NAME_BRIDGEOBJECT); |
3073 | 104k | break; |
3074 | 240 | case BuiltinTypeKind::BuiltinUnsafeValueBuffer: |
3075 | 240 | printer << MAYBE_GET_NAMESPACED_BUILTIN( |
3076 | 240 | BUILTIN_TYPE_NAME_UNSAFEVALUEBUFFER); |
3077 | 240 | break; |
3078 | 71.5k | case BuiltinTypeKind::BuiltinIntegerLiteral: |
3079 | 71.5k | printer << MAYBE_GET_NAMESPACED_BUILTIN(BUILTIN_TYPE_NAME_INTLITERAL); |
3080 | 71.5k | break; |
3081 | 42.4k | case BuiltinTypeKind::BuiltinVector: { |
3082 | 42.4k | const auto *t = cast<const BuiltinVectorType>(this); |
3083 | 42.4k | llvm::SmallString<32> UnderlyingStrVec; |
3084 | 42.4k | StringRef UnderlyingStr; |
3085 | 42.4k | { |
3086 | | // FIXME: Ugly hack: remove the .Builtin from the element type. |
3087 | 42.4k | { |
3088 | 42.4k | llvm::raw_svector_ostream UnderlyingOS(UnderlyingStrVec); |
3089 | 42.4k | t->getElementType().print(UnderlyingOS); |
3090 | 42.4k | } |
3091 | 42.4k | if (UnderlyingStrVec.startswith(BUILTIN_TYPE_NAME_PREFIX)) |
3092 | 42.4k | UnderlyingStr = UnderlyingStrVec.substr(8); |
3093 | 0 | else |
3094 | 0 | UnderlyingStr = UnderlyingStrVec; |
3095 | 42.4k | } |
3096 | | |
3097 | 42.4k | printer << MAYBE_GET_NAMESPACED_BUILTIN(BUILTIN_TYPE_NAME_VEC) |
3098 | 42.4k | << t->getNumElements() << "x" << UnderlyingStr; |
3099 | 42.4k | break; |
3100 | 0 | } |
3101 | 5.63M | case BuiltinTypeKind::BuiltinInteger: { |
3102 | 5.63M | auto width = cast<const BuiltinIntegerType>(this)->getWidth(); |
3103 | 5.63M | if (width.isFixedWidth()) { |
3104 | 4.00M | printer << MAYBE_GET_NAMESPACED_BUILTIN(BUILTIN_TYPE_NAME_INT) |
3105 | 4.00M | << width.getFixedWidth(); |
3106 | 4.00M | break; |
3107 | 4.00M | } |
3108 | | |
3109 | 1.62M | if (width.isPointerWidth()) { |
3110 | 1.62M | printer << MAYBE_GET_NAMESPACED_BUILTIN(BUILTIN_TYPE_NAME_WORD); |
3111 | 1.62M | break; |
3112 | 1.62M | } |
3113 | | |
3114 | 0 | llvm_unreachable("impossible bit width"); |
3115 | 0 | } |
3116 | 59.0k | case BuiltinTypeKind::BuiltinFloat: { |
3117 | 59.0k | switch (cast<const BuiltinFloatType>(this)->getFPKind()) { |
3118 | 4.87k | case BuiltinFloatType::IEEE16: |
3119 | 4.87k | printer << MAYBE_GET_NAMESPACED_BUILTIN(BUILTIN_TYPE_NAME_FLOAT) << "16"; |
3120 | 4.87k | break; |
3121 | 41.4k | case BuiltinFloatType::IEEE32: |
3122 | 41.4k | printer << MAYBE_GET_NAMESPACED_BUILTIN(BUILTIN_TYPE_NAME_FLOAT) << "32"; |
3123 | 41.4k | break; |
3124 | 12.6k | case BuiltinFloatType::IEEE64: |
3125 | 12.6k | printer << MAYBE_GET_NAMESPACED_BUILTIN(BUILTIN_TYPE_NAME_FLOAT) << "64"; |
3126 | 12.6k | break; |
3127 | 78 | case BuiltinFloatType::IEEE80: |
3128 | 78 | printer << MAYBE_GET_NAMESPACED_BUILTIN(BUILTIN_TYPE_NAME_FLOAT) << "80"; |
3129 | 78 | break; |
3130 | 0 | case BuiltinFloatType::IEEE128: |
3131 | 0 | printer << MAYBE_GET_NAMESPACED_BUILTIN(BUILTIN_TYPE_NAME_FLOAT) << "128"; |
3132 | 0 | break; |
3133 | 0 | case BuiltinFloatType::PPC128: |
3134 | 0 | printer << MAYBE_GET_NAMESPACED_BUILTIN(BUILTIN_TYPE_NAME_FLOAT_PPC) |
3135 | 0 | << "128"; |
3136 | 0 | break; |
3137 | 59.0k | } |
3138 | 59.0k | break; |
3139 | 59.0k | } |
3140 | 6.40M | } |
3141 | 6.40M | #undef MAYBE_GET_NAMESPACED_BUILTIN |
3142 | | |
3143 | 6.40M | return printer.str(); |
3144 | 6.40M | } |