@@ -43,219 +43,170 @@ class TypeInfo;
43
43
44
44
} // namespace irgen
45
45
46
- // / Provides access to the IRGen-based queries that can be performed on
47
- // / declarations to get their various ABI details.
48
- class IRABIDetailsProvider {
46
+ // / Describes the lowered Swift function signature.
47
+ class LoweredFunctionSignature {
49
48
public:
50
- IRABIDetailsProvider (ModuleDecl &mod, const IRGenOptions &opts);
51
- ~IRABIDetailsProvider ();
49
+ class DirectResultType {
50
+ public:
51
+ // / Enumerates all of the members of the underlying record in terms of
52
+ // / their primitive types that needs to be stored in a Clang/LLVM record
53
+ // / when this type is passed or returned directly to/from swiftcc
54
+ // / function.
55
+ // /
56
+ // / Returns true if an error occurred when a particular member can't be
57
+ // / represented with an AST type.
58
+ bool enumerateRecordMembers (
59
+ llvm::function_ref<void (clang::CharUnits, clang::CharUnits, Type)>
60
+ callback) const ;
52
61
53
- using SizeType = uint64_t ;
62
+ private:
63
+ DirectResultType (IRABIDetailsProviderImpl &owner,
64
+ const irgen::TypeInfo &typeDetails);
65
+ IRABIDetailsProviderImpl &owner;
66
+ const irgen::TypeInfo &typeDetails;
67
+ friend class LoweredFunctionSignature ;
68
+ };
54
69
55
- struct SizeAndAlignment {
56
- SizeType size;
57
- SizeType alignment;
70
+ // / Represents a result value returned indirectly out of a function.
71
+ class IndirectResultValue {
72
+ public:
73
+ // / Returns true if this indirect result type uses the `sret` LLVM
74
+ // / attribute.
75
+ inline bool hasSRet () const { return hasSRet_; }
76
+
77
+ private:
78
+ inline IndirectResultValue (bool hasSRet_) : hasSRet_(hasSRet_) {}
79
+ bool hasSRet_;
80
+ friend class LoweredFunctionSignature ;
58
81
};
59
82
60
- // / Information about any ABI additional parameters .
61
- class ABIAdditionalParam {
83
+ // / Represents a parameter passed directly to the function .
84
+ class DirectParameter {
62
85
public:
63
- enum class ABIParameterRole {
64
- // / The Swift error parameter.
65
- None
66
- };
86
+ // / Enumerates all of the members of the underlying record in terms of
87
+ // / their primitive types that needs to be stored in a Clang/LLVM record
88
+ // / when this type is passed or returned directly to/from swiftcc
89
+ // / function.
90
+ // /
91
+ // / Returns true if an error occurred when a particular member can't be
92
+ // / represented with an AST type.
93
+ bool enumerateRecordMembers (
94
+ llvm::function_ref<void (clang::CharUnits, clang::CharUnits, Type)>
95
+ callback) const ;
67
96
68
- inline ABIParameterRole getRole () const { return role ; }
97
+ inline const ParamDecl & getParamDecl () const { return paramDecl ; }
69
98
70
99
private:
71
- inline ABIAdditionalParam (
72
- ABIParameterRole role,
73
- llvm::Optional<GenericRequirement> genericRequirement, CanType canType)
74
- : role(role), genericRequirement(genericRequirement), canType(canType) {
75
- }
100
+ DirectParameter (IRABIDetailsProviderImpl &owner,
101
+ const irgen::TypeInfo &typeDetails,
102
+ const ParamDecl ¶mDecl);
103
+ IRABIDetailsProviderImpl &owner;
104
+ const irgen::TypeInfo &typeDetails;
105
+ const ParamDecl ¶mDecl;
106
+ friend class LoweredFunctionSignature ;
107
+ };
76
108
77
- ABIParameterRole role;
78
- llvm::Optional<GenericRequirement> genericRequirement;
79
- CanType canType;
109
+ // / Represents a parameter passed indirectly to the function.
110
+ class IndirectParameter {
111
+ public:
112
+ inline const ParamDecl &getParamDecl () const { return paramDecl; }
80
113
81
- friend class IRABIDetailsProviderImpl ;
114
+ private:
115
+ IndirectParameter (const ParamDecl ¶mDecl);
116
+ const ParamDecl ¶mDecl;
117
+ friend class LoweredFunctionSignature ;
82
118
};
83
119
84
- // / Describes the lowered Swift function signature.
85
- class LoweredFunctionSignature {
120
+ // / Represents a generic requirement paremeter that must be passed to the
121
+ // / function.
122
+ class GenericRequirementParameter {
86
123
public:
87
- class DirectResultType {
88
- public:
89
- // / Enumerates all of the members of the underlying record in terms of
90
- // / their primitive types that needs to be stored in a Clang/LLVM record
91
- // / when this type is passed or returned directly to/from swiftcc
92
- // / function.
93
- // /
94
- // / Returns true if an error occurred when a particular member can't be
95
- // / represented with an AST type.
96
- bool enumerateRecordMembers (
97
- llvm::function_ref<void (clang::CharUnits, clang::CharUnits, Type)>
98
- callback) const ;
99
-
100
- private:
101
- DirectResultType (IRABIDetailsProviderImpl &owner,
102
- const irgen::TypeInfo &typeDetails);
103
- IRABIDetailsProviderImpl &owner;
104
- const irgen::TypeInfo &typeDetails;
105
- friend class LoweredFunctionSignature ;
106
- };
107
-
108
- // / Represents a result value returned indirectly out of a function.
109
- class IndirectResultValue {
110
- public:
111
- // / Returns true if this indirect result type uses the `sret` LLVM
112
- // / attribute.
113
- inline bool hasSRet () const { return hasSRet_; }
114
-
115
- private:
116
- inline IndirectResultValue (bool hasSRet_) : hasSRet_(hasSRet_) {}
117
- bool hasSRet_;
118
- friend class LoweredFunctionSignature ;
119
- };
120
-
121
- // / Represents a parameter passed directly to the function.
122
- class DirectParameter {
123
- public:
124
- // / Enumerates all of the members of the underlying record in terms of
125
- // / their primitive types that needs to be stored in a Clang/LLVM record
126
- // / when this type is passed or returned directly to/from swiftcc
127
- // / function.
128
- // /
129
- // / Returns true if an error occurred when a particular member can't be
130
- // / represented with an AST type.
131
- bool enumerateRecordMembers (
132
- llvm::function_ref<void (clang::CharUnits, clang::CharUnits, Type)>
133
- callback) const ;
134
-
135
- inline const ParamDecl &getParamDecl () const { return paramDecl; }
136
-
137
- private:
138
- DirectParameter (IRABIDetailsProviderImpl &owner,
139
- const irgen::TypeInfo &typeDetails,
140
- const ParamDecl ¶mDecl);
141
- IRABIDetailsProviderImpl &owner;
142
- const irgen::TypeInfo &typeDetails;
143
- const ParamDecl ¶mDecl;
144
- friend class LoweredFunctionSignature ;
145
- };
146
-
147
- // / Represents a parameter passed indirectly to the function.
148
- class IndirectParameter {
149
- public:
150
- inline const ParamDecl &getParamDecl () const { return paramDecl; }
151
-
152
- private:
153
- IndirectParameter (const ParamDecl ¶mDecl);
154
- const ParamDecl ¶mDecl;
155
- friend class LoweredFunctionSignature ;
156
- };
157
-
158
- // / Represents a generic requirement paremeter that must be passed to the
159
- // / function.
160
- class GenericRequirementParameter {
161
- public:
162
- inline GenericRequirement getRequirement () const { return requirement; }
163
-
164
- private:
165
- GenericRequirementParameter (const GenericRequirement &requirement);
166
- GenericRequirement requirement;
167
- friend class LoweredFunctionSignature ;
168
- };
169
-
170
- // / Represents a parameter which is a Swift type pointer sourced from a
171
- // / valid metadata source, like the type of another argument.
172
- class MetadataSourceParameter {
173
- public:
174
- inline CanType getType () const { return type; }
175
-
176
- private:
177
- MetadataSourceParameter (const CanType &type);
178
- CanType type;
179
- friend class LoweredFunctionSignature ;
180
- };
181
-
182
- // / Represents a context parameter passed to the call.
183
- class ContextParameter {};
184
-
185
- // / Represents an out error parameter passed indirectly to the call.
186
- class ErrorResultValue {};
187
-
188
- // / Returns lowered direct result details, or \c None if direct result is
189
- // / void.
190
- llvm::Optional<DirectResultType> getDirectResultType () const ;
191
-
192
- // / Returns the number of indirect result values in this function signature.
193
- size_t getNumIndirectResultValues () const ;
194
-
195
- // / Traverse the entire parameter list of the function signature.
196
- // /
197
- // / The parameter list can include actual Swift function parameters, result
198
- // / values returned indirectly, and additional values, like generic
199
- // / requirements for polymorphic calls and the error parameter as well.
200
- void visitParameterList (
201
- llvm::function_ref<void (const IndirectResultValue &)>
202
- indirectResultVisitor,
203
- llvm::function_ref<void(const DirectParameter &)> directParamVisitor,
204
- llvm::function_ref<void(const IndirectParameter &)>
205
- indirectParamVisitor,
206
- llvm::function_ref<void(const GenericRequirementParameter &)>
207
- genericRequirementVisitor,
208
- llvm::function_ref<void(const MetadataSourceParameter &)>
209
- metadataSourceVisitor,
210
- llvm::function_ref<void(const ContextParameter &)> contextParamVisitor,
211
- llvm::function_ref<void(const ErrorResultValue &)> errorResultVisitor);
212
-
213
- // / FIXME: make private.
214
- SmallVector<ABIAdditionalParam, 1 > additionalParams;
124
+ inline GenericRequirement getRequirement () const { return requirement; }
215
125
216
126
private:
217
- LoweredFunctionSignature (
218
- const AbstractFunctionDecl *FD, IRABIDetailsProviderImpl &owner,
219
- const irgen::SignatureExpansionABIDetails &abiDetails);
220
- const AbstractFunctionDecl *FD;
221
- IRABIDetailsProviderImpl &owner;
222
- const irgen::SignatureExpansionABIDetails &abiDetails;
223
- SmallVector<CanType, 1 > metadataSourceTypes;
224
- friend class IRABIDetailsProviderImpl ;
127
+ GenericRequirementParameter (const GenericRequirement &requirement);
128
+ GenericRequirement requirement;
129
+ friend class LoweredFunctionSignature ;
130
+ };
131
+
132
+ // / Represents a parameter which is a Swift type pointer sourced from a
133
+ // / valid metadata source, like the type of another argument.
134
+ class MetadataSourceParameter {
135
+ public:
136
+ inline CanType getType () const { return type; }
137
+
138
+ private:
139
+ MetadataSourceParameter (const CanType &type);
140
+ CanType type;
141
+ friend class LoweredFunctionSignature ;
142
+ };
143
+
144
+ // / Represents a context parameter passed to the call.
145
+ class ContextParameter {};
146
+
147
+ // / Represents an out error parameter passed indirectly to the call.
148
+ class ErrorResultValue {};
149
+
150
+ // / Returns lowered direct result details, or \c None if direct result is
151
+ // / void.
152
+ llvm::Optional<DirectResultType> getDirectResultType () const ;
153
+
154
+ // / Returns the number of indirect result values in this function signature.
155
+ size_t getNumIndirectResultValues () const ;
156
+
157
+ // / Traverse the entire parameter list of the function signature.
158
+ // /
159
+ // / The parameter list can include actual Swift function parameters, result
160
+ // / values returned indirectly, and additional values, like generic
161
+ // / requirements for polymorphic calls and the error parameter as well.
162
+ void visitParameterList (
163
+ llvm::function_ref<void (const IndirectResultValue &)>
164
+ indirectResultVisitor,
165
+ llvm::function_ref<void(const DirectParameter &)> directParamVisitor,
166
+ llvm::function_ref<void(const IndirectParameter &)> indirectParamVisitor,
167
+ llvm::function_ref<void(const GenericRequirementParameter &)>
168
+ genericRequirementVisitor,
169
+ llvm::function_ref<void(const MetadataSourceParameter &)>
170
+ metadataSourceVisitor,
171
+ llvm::function_ref<void(const ContextParameter &)> contextParamVisitor,
172
+ llvm::function_ref<void(const ErrorResultValue &)> errorResultVisitor)
173
+ const ;
174
+
175
+ private:
176
+ LoweredFunctionSignature (
177
+ const AbstractFunctionDecl *FD, IRABIDetailsProviderImpl &owner,
178
+ const irgen::SignatureExpansionABIDetails &abiDetails);
179
+ const AbstractFunctionDecl *FD;
180
+ IRABIDetailsProviderImpl &owner;
181
+ const irgen::SignatureExpansionABIDetails &abiDetails;
182
+ SmallVector<CanType, 1 > metadataSourceTypes;
183
+ friend class IRABIDetailsProviderImpl ;
184
+ };
185
+
186
+ // / Provides access to the IRGen-based queries that can be performed on
187
+ // / declarations to get their various ABI details.
188
+ class IRABIDetailsProvider {
189
+ public:
190
+ IRABIDetailsProvider (ModuleDecl &mod, const IRGenOptions &opts);
191
+ ~IRABIDetailsProvider ();
192
+
193
+ using SizeType = uint64_t ;
194
+
195
+ struct SizeAndAlignment {
196
+ SizeType size;
197
+ SizeType alignment;
225
198
};
226
199
227
200
// / Returns the function signature lowered to its C / LLVM - like
228
201
// / representation, or \c None if such representation could not be computed.
229
202
llvm::Optional<LoweredFunctionSignature>
230
203
getFunctionLoweredSignature (AbstractFunctionDecl *fd);
231
204
232
- // / Returns the additional params if they exist after lowering the function.
233
- SmallVector<ABIAdditionalParam, 1 >
234
- getFunctionABIAdditionalParams (AbstractFunctionDecl *fd);
235
-
236
205
// / Returns the size and alignment for the given type, or \c None if the type
237
206
// / is not a fixed layout type.
238
207
llvm::Optional<SizeAndAlignment>
239
208
getTypeSizeAlignment (const NominalTypeDecl *TD);
240
209
241
- // / Returns true if the given type should be passed indirectly into a swiftcc
242
- // / function.
243
- bool shouldPassIndirectly (Type t);
244
-
245
- // / Returns true if the given type should be returned indirectly from a
246
- // / swiftcc function.
247
- bool shouldReturnIndirectly (Type t);
248
-
249
- // / Enumerates all of the members of the underlying record in terms of their
250
- // / primitive types that needs to be stored in a Clang/LLVM record when this
251
- // / type is passed or returned directly to/from swiftcc function.
252
- // /
253
- // / Returns true if an error occurred when a particular member can't be
254
- // / represented with an AST type.
255
- bool enumerateDirectPassingRecordMembers (
256
- Type t, llvm::function_ref<void (clang::CharUnits, clang::CharUnits, Type)>
257
- callback);
258
-
259
210
// / An representation of a single type, or a C struct with multiple members
260
211
// / with specified types. The C struct is expected to be passed via swiftcc
261
212
// / functions.
0 commit comments