aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/TextAPI/MachO/Target.cpp
diff options
context:
space:
mode:
authorCyndy Ishida <cyndy_ishida@apple.com>2019-10-08 15:07:36 +0000
committerCyndy Ishida <cyndy_ishida@apple.com>2019-10-08 15:07:36 +0000
commit5d566c5a46aeaa1fa0e5c0b823c9d5f84036dc9a (patch)
tree970df30c81781ed512b1c3ff3d9850ff8fb3e372 /llvm/lib/TextAPI/MachO/Target.cpp
parent6b06ead19be79fd6e2d2abdda4c4cbb7c8f3c7c0 (diff)
downloadllvm-5d566c5a46aeaa1fa0e5c0b823c9d5f84036dc9a.zip
llvm-5d566c5a46aeaa1fa0e5c0b823c9d5f84036dc9a.tar.gz
llvm-5d566c5a46aeaa1fa0e5c0b823c9d5f84036dc9a.tar.bz2
[TextAPI] Introduce TBDv4
Summary: This format introduces new features and platforms The motivation for this format is to support more than 1 platform since previous versions only supported additional architectures and 1 platform, for example ios + ios-simulator and macCatalyst. Reviewers: ributzka, steven_wu Reviewed By: ributzka Subscribers: mgorny, hiraditya, mgrang, dexonsmith, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D67529 llvm-svn: 374058
Diffstat (limited to 'llvm/lib/TextAPI/MachO/Target.cpp')
-rw-r--r--llvm/lib/TextAPI/MachO/Target.cpp40
1 files changed, 39 insertions, 1 deletions
diff --git a/llvm/lib/TextAPI/MachO/Target.cpp b/llvm/lib/TextAPI/MachO/Target.cpp
index 3052aa5..52fb339 100644
--- a/llvm/lib/TextAPI/MachO/Target.cpp
+++ b/llvm/lib/TextAPI/MachO/Target.cpp
@@ -17,6 +17,44 @@
namespace llvm {
namespace MachO {
+Expected<Target> Target::create(StringRef TargetValue) {
+ auto Result = TargetValue.split('-');
+ auto ArchitectureStr = Result.first;
+ auto Architecture = getArchitectureFromName(ArchitectureStr);
+ if (Architecture == AK_unknown)
+ return make_error<StringError>("invalid architecture",
+ inconvertibleErrorCode());
+ auto PlatformStr = Result.second;
+ PlatformKind Platform;
+ Platform = StringSwitch<PlatformKind>(PlatformStr)
+ .Case("macos", PlatformKind::macOS)
+ .Case("ios", PlatformKind::iOS)
+ .Case("tvos", PlatformKind::tvOS)
+ .Case("watchos", PlatformKind::watchOS)
+ .Case("bridgeos", PlatformKind::bridgeOS)
+ .Case("maccatalyst", PlatformKind::macCatalyst)
+ .Case("ios-simulator", PlatformKind::iOSSimulator)
+ .Case("tvos-simulator", PlatformKind::tvOSSimulator)
+ .Case("watchos-simulator", PlatformKind::watchOSSimulator)
+ .Default(PlatformKind::unknown);
+
+ if (Platform == PlatformKind::unknown) {
+ if (PlatformStr.startswith("<") && PlatformStr.endswith(">")) {
+ PlatformStr = PlatformStr.drop_front().drop_back();
+ unsigned long long RawValue;
+ if (PlatformStr.getAsInteger(10, RawValue))
+ return make_error<StringError>("invalid platform number",
+ inconvertibleErrorCode());
+
+ Platform = (PlatformKind)RawValue;
+ }
+ return make_error<StringError>("invalid platform",
+ inconvertibleErrorCode());
+ }
+
+ return Target{Architecture, Platform};
+}
+
Target::operator std::string() const {
return (getArchitectureName(Arch) + " (" + getPlatformName(Platform) + ")")
.str();
@@ -42,4 +80,4 @@ ArchitectureSet mapToArchitectureSet(ArrayRef<Target> Targets) {
}
} // end namespace MachO.
-} // end namespace llvm. \ No newline at end of file
+} // end namespace llvm.