[MIPS GlobalISel] Select MSA vector generic and builtin add
[llvm-complete.git] / lib / TextAPI / MachO / Platform.cpp
blob588ec9a4d83be8d5ee69ad470d277df22a23ebaa
1 //===- llvm/TextAPI/MachO/Platform.cpp - Platform ---------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Implementations of Platform Helper functions.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/ADT/ArrayRef.h"
14 #include "llvm/ADT/Triple.h"
15 #include "llvm/TextAPI/MachO/Platform.h"
17 namespace llvm {
18 namespace MachO {
20 PlatformKind mapToPlatformKind(PlatformKind Platform, bool WantSim) {
21 switch (Platform) {
22 default:
23 return Platform;
24 case PlatformKind::iOS:
25 return WantSim ? PlatformKind::iOSSimulator : PlatformKind::iOS;
26 case PlatformKind::tvOS:
27 return WantSim ? PlatformKind::tvOSSimulator : PlatformKind::tvOS;
28 case PlatformKind::watchOS:
29 return WantSim ? PlatformKind::watchOSSimulator : PlatformKind::watchOS;
31 llvm_unreachable("Unknown llvm.MachO.PlatformKind enum");
34 PlatformKind mapToPlatformKind(const Triple &Target) {
35 switch (Target.getOS()) {
36 default:
37 return PlatformKind::unknown;
38 case Triple::MacOSX:
39 return PlatformKind::macOS;
40 case Triple::IOS:
41 if (Target.isSimulatorEnvironment())
42 return PlatformKind::iOSSimulator;
43 if (Target.getEnvironment() == Triple::MacABI)
44 return PlatformKind::macCatalyst;
45 return PlatformKind::iOS;
46 case Triple::TvOS:
47 return Target.isSimulatorEnvironment() ? PlatformKind::tvOSSimulator
48 : PlatformKind::tvOS;
49 case Triple::WatchOS:
50 return Target.isSimulatorEnvironment() ? PlatformKind::watchOSSimulator
51 : PlatformKind::watchOS;
52 // TODO: add bridgeOS once in llvm::Triple
54 llvm_unreachable("Unknown Target Triple");
57 PlatformSet mapToPlatformSet(ArrayRef<Triple> Targets) {
58 PlatformSet Result;
59 for (const auto &Target : Targets)
60 Result.insert(mapToPlatformKind(Target));
61 return Result;
64 StringRef getPlatformName(PlatformKind Platform) {
65 switch (Platform) {
66 case PlatformKind::unknown:
67 return "unknown";
68 case PlatformKind::macOS:
69 return "macOS";
70 case PlatformKind::iOS:
71 return "iOS";
72 case PlatformKind::tvOS:
73 return "tvOS";
74 case PlatformKind::watchOS:
75 return "watchOS";
76 case PlatformKind::bridgeOS:
77 return "bridgeOS";
78 case PlatformKind::macCatalyst:
79 return "macCatalyst";
80 case PlatformKind::iOSSimulator:
81 return "iOS Simulator";
82 case PlatformKind::tvOSSimulator:
83 return "tvOS Simulator";
84 case PlatformKind::watchOSSimulator:
85 return "watchOS Simulator";
87 llvm_unreachable("Unknown llvm.MachO.PlatformKind enum");
90 } // end namespace MachO.
91 } // end namespace llvm.