26
26
#include " llvm/TextAPI/MachO/Architecture.h"
27
27
#include " llvm/TextAPI/MachO/ArchitectureSet.h"
28
28
#include " llvm/TextAPI/MachO/PackedVersion.h"
29
+ #include " llvm/TextAPI/MachO/Platform.h"
29
30
#include " llvm/TextAPI/MachO/Symbol.h"
31
+ #include " llvm/TextAPI/MachO/Target.h"
30
32
31
33
namespace llvm {
32
34
namespace MachO {
33
35
34
- // / Defines the list of MachO platforms.
35
- enum class PlatformKind : unsigned {
36
- unknown,
37
- macOS = MachO::PLATFORM_MACOS,
38
- iOS = MachO::PLATFORM_IOS,
39
- tvOS = MachO::PLATFORM_TVOS,
40
- watchOS = MachO::PLATFORM_WATCHOS,
41
- bridgeOS = MachO::PLATFORM_BRIDGEOS,
42
- };
43
-
44
36
// / Defines a list of Objective-C constraints.
45
37
enum class ObjCConstraintType : unsigned {
46
38
// / No constraint.
@@ -89,29 +81,42 @@ class InterfaceFileRef {
89
81
90
82
InterfaceFileRef (StringRef InstallName) : InstallName(InstallName) {}
91
83
92
- InterfaceFileRef (StringRef InstallName, ArchitectureSet Archs )
93
- : InstallName(InstallName), Architectures(Archs ) {}
84
+ InterfaceFileRef (StringRef InstallName, const TargetList Targets )
85
+ : InstallName(InstallName), Targets(std::move(Targets) ) {}
94
86
95
87
StringRef getInstallName () const { return InstallName; };
96
- void addArchitectures (ArchitectureSet Archs) { Architectures |= Archs; }
97
- ArchitectureSet getArchitectures () const { return Architectures; }
98
- bool hasArchitecture (Architecture Arch) const {
99
- return Architectures.has (Arch);
88
+
89
+ void addTarget (const Target &Target);
90
+ template <typename RangeT> void addTargets (RangeT &&Targets) {
91
+ for (const auto &Target : Targets)
92
+ addTarget (Target (Target));
100
93
}
101
94
95
+ using const_target_iterator = TargetList::const_iterator;
96
+ using const_target_range = llvm::iterator_range<const_target_iterator>;
97
+ const_target_range targets () const { return {Targets}; }
98
+
99
+ ArchitectureSet getArchitectures () const {
100
+ return mapToArchitectureSet (Targets);
101
+ }
102
+
103
+ PlatformSet getPlatforms () const { return mapToPlatformSet (Targets); }
104
+
102
105
bool operator ==(const InterfaceFileRef &O) const {
103
- return std::tie (InstallName, Architectures) ==
104
- std::tie (O.InstallName , O.Architectures );
106
+ return std::tie (InstallName, Targets) == std::tie (O.InstallName , O.Targets );
107
+ }
108
+
109
+ bool operator !=(const InterfaceFileRef &O) const {
110
+ return std::tie (InstallName, Targets) != std::tie (O.InstallName , O.Targets );
105
111
}
106
112
107
113
bool operator <(const InterfaceFileRef &O) const {
108
- return std::tie (InstallName, Architectures) <
109
- std::tie (O.InstallName , O.Architectures );
114
+ return std::tie (InstallName, Targets) < std::tie (O.InstallName , O.Targets );
110
115
}
111
116
112
117
private:
113
118
std::string InstallName;
114
- ArchitectureSet Architectures ;
119
+ TargetList Targets ;
115
120
};
116
121
117
122
} // end namespace MachO.
@@ -170,27 +175,43 @@ class InterfaceFile {
170
175
// / \return The file type.
171
176
FileType getFileType () const { return FileKind; }
172
177
173
- // / Set the platform.
174
- void setPlatform (PlatformKind Platform_) { Platform = Platform_; }
178
+ // / Get the architectures.
179
+ // /
180
+ // / \return The applicable architectures.
181
+ ArchitectureSet getArchitectures () const {
182
+ return mapToArchitectureSet (Targets);
183
+ }
175
184
176
- // / Get the platform.
177
- PlatformKind getPlatform () const { return Platform; }
185
+ // / Get the platforms.
186
+ // /
187
+ // / \return The applicable platforms.
188
+ PlatformSet getPlatforms () const { return mapToPlatformSet (Targets); }
178
189
179
- // / Specify the set of supported architectures by this file .
180
- void setArchitectures (ArchitectureSet Architectures_) {
181
- Architectures = Architectures_;
182
- }
190
+ // / Set and add target .
191
+ // /
192
+ // / \param Target the target to add into.
193
+ void addTarget ( const Target &Target);
183
194
184
- // / Add the set of supported architectures by this file.
185
- void addArchitectures (ArchitectureSet Architectures_) {
186
- Architectures |= Architectures_;
195
+ // / Set and add targets.
196
+ // /
197
+ // / Add the subset of llvm::triples that is supported by Tapi
198
+ // /
199
+ // / \param Targets the collection of targets.
200
+ template <typename RangeT> void addTargets (RangeT &&Targets) {
201
+ for (const auto &Target_ : Targets)
202
+ addTarget (Target (Target_));
187
203
}
188
204
189
- // / Add supported architecture by this file..
190
- void addArch (Architecture Arch) { Architectures.set (Arch); }
205
+ using const_target_iterator = TargetList::const_iterator;
206
+ using const_target_range = llvm::iterator_range<const_target_iterator>;
207
+ const_target_range targets () const { return {Targets}; }
191
208
192
- // / Get the set of supported architectures.
193
- ArchitectureSet getArchitectures () const { return Architectures; }
209
+ using const_filtered_target_iterator =
210
+ llvm::filter_iterator<const_target_iterator,
211
+ std::function<bool (const Target &)>>;
212
+ using const_filtered_target_range =
213
+ llvm::iterator_range<const_filtered_target_iterator>;
214
+ const_filtered_target_range targets (ArchitectureSet Archs) const ;
194
215
195
216
// / Set the install name of the library.
196
217
void setInstallName (StringRef InstallName_) { InstallName = InstallName_; }
@@ -244,11 +265,18 @@ class InterfaceFile {
244
265
// / Check if this file was generated during InstallAPI.
245
266
bool isInstallAPI () const { return IsInstallAPI; }
246
267
247
- // / Set the parent umbrella framework.
248
- void setParentUmbrella (StringRef Parent) { ParentUmbrella = Parent; }
268
+ // / Set the parent umbrella frameworks.
269
+ // / \param Target_ The target applicable to Parent
270
+ // / \param Parent The name of Parent
271
+ void addParentUmbrella (const Target &Target_, StringRef Parent);
272
+ const std::vector<std::pair<Target, std::string>> &umbrellas () const {
273
+ return ParentUmbrellas;
274
+ }
249
275
250
276
// / Get the parent umbrella framework.
251
- StringRef getParentUmbrella () const { return ParentUmbrella; }
277
+ const std::vector<std::pair<Target, std::string>> getParentUmbrellas () const {
278
+ return ParentUmbrellas;
279
+ }
252
280
253
281
// / Add an allowable client.
254
282
// /
@@ -258,8 +286,8 @@ class InterfaceFile {
258
286
// / linker refuses to link this library.
259
287
// /
260
288
// / \param Name The name of the client that is allowed to link this library.
261
- // / \param Architectures The set of architecture for which this applies.
262
- void addAllowableClient (StringRef Name, ArchitectureSet Architectures );
289
+ // / \param Target The target triple for which this applies.
290
+ void addAllowableClient (StringRef InstallName, const Target &Target );
263
291
264
292
// / Get the list of allowable clients.
265
293
// /
@@ -271,9 +299,8 @@ class InterfaceFile {
271
299
// / Add a re-exported library.
272
300
// /
273
301
// / \param InstallName The name of the library to re-export.
274
- // / \param Architectures The set of architecture for which this applies.
275
- void addReexportedLibrary (StringRef InstallName,
276
- ArchitectureSet Architectures);
302
+ // / \param Target The target triple for which this applies.
303
+ void addReexportedLibrary (StringRef InstallName, const Target &Target);
277
304
278
305
// / Get the list of re-exported libraries.
279
306
// /
@@ -282,27 +309,27 @@ class InterfaceFile {
282
309
return ReexportedLibraries;
283
310
}
284
311
285
- // / Add an architecture /UUID pair.
312
+ // / Add an Target /UUID pair.
286
313
// /
287
- // / \param Arch The architecture for which this applies.
314
+ // / \param Target The target triple for which this applies.
288
315
// / \param UUID The UUID of the library for the specified architecture.
289
- void addUUID (Architecture Arch , StringRef UUID);
316
+ void addUUID (const Target &Target , StringRef UUID);
290
317
291
- // / Add an architecture /UUID pair.
318
+ // / Add an Target /UUID pair.
292
319
// /
293
- // / \param Arch The architecture for which this applies.
320
+ // / \param Target The target triple for which this applies.
294
321
// / \param UUID The UUID of the library for the specified architecture.
295
- void addUUID (Architecture Arch , uint8_t UUID[16 ]);
322
+ void addUUID (const Target &Target , uint8_t UUID[16 ]);
296
323
297
- // / Get the list of architecture /UUID pairs.
324
+ // / Get the list of Target /UUID pairs.
298
325
// /
299
- // / \return Returns a list of architecture /UUID pairs.
300
- const std::vector<std::pair<Architecture , std::string>> &uuids () const {
326
+ // / \return Returns a list of Target /UUID pairs.
327
+ const std::vector<std::pair<Target , std::string>> &uuids () const {
301
328
return UUIDs;
302
329
}
303
330
304
331
// / Add a symbol to the symbols list or extend an existing one.
305
- void addSymbol (SymbolKind Kind, StringRef Name, ArchitectureSet Architectures ,
332
+ void addSymbol (SymbolKind Kind, StringRef Name, const TargetList &Targets ,
306
333
SymbolFlags Flags = SymbolFlags::None);
307
334
308
335
using SymbolMapType = DenseMap<SymbolsMapKey, Symbol *>;
@@ -411,10 +438,9 @@ class InterfaceFile {
411
438
return StringRef (reinterpret_cast <const char *>(Ptr ), String.size ());
412
439
}
413
440
441
+ TargetList Targets;
414
442
std::string Path;
415
443
FileType FileKind;
416
- PlatformKind Platform;
417
- ArchitectureSet Architectures;
418
444
std::string InstallName;
419
445
PackedVersion CurrentVersion;
420
446
PackedVersion CompatibilityVersion;
@@ -423,10 +449,10 @@ class InterfaceFile {
423
449
bool IsAppExtensionSafe{false };
424
450
bool IsInstallAPI{false };
425
451
ObjCConstraintType ObjcConstraint = ObjCConstraintType::None;
426
- std::string ParentUmbrella ;
452
+ std::vector<std::pair<Target, std:: string>> ParentUmbrellas ;
427
453
std::vector<InterfaceFileRef> AllowableClients;
428
454
std::vector<InterfaceFileRef> ReexportedLibraries;
429
- std::vector<std::pair<Architecture , std::string>> UUIDs;
455
+ std::vector<std::pair<Target , std::string>> UUIDs;
430
456
SymbolMapType Symbols;
431
457
};
432
458
0 commit comments