LLVM  10.0.0svn
Platform.cpp
Go to the documentation of this file.
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.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "llvm/ADT/ArrayRef.h"
14 #include "llvm/ADT/Triple.h"
16 
17 namespace llvm {
18 namespace MachO {
19 
20 PlatformKind mapToPlatformKind(PlatformKind Platform, bool WantSim) {
21  switch (Platform) {
22  default:
23  return Platform;
24  case PlatformKind::iOS:
26  case PlatformKind::tvOS:
30  }
31  llvm_unreachable("Unknown llvm.MachO.PlatformKind enum");
32 }
33 
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())
43  if (Target.getEnvironment() == Triple::MacABI)
45  return PlatformKind::iOS;
46  case Triple::TvOS:
49  case Triple::WatchOS:
52  // TODO: add bridgeOS once in llvm::Triple
53  }
54  llvm_unreachable("Unknown Target Triple");
55 }
56 
58  PlatformSet Result;
59  for (const auto &Target : Targets)
61  return Result;
62 }
63 
65  switch (Platform) {
67  return "unknown";
69  return "macOS";
70  case PlatformKind::iOS:
71  return "iOS";
72  case PlatformKind::tvOS:
73  return "tvOS";
75  return "watchOS";
77  return "bridgeOS";
79  return "macCatalyst";
81  return "iOS Simulator";
83  return "tvOS Simulator";
85  return "watchOS Simulator";
86  }
87  llvm_unreachable("Unknown llvm.MachO.PlatformKind enum");
88 }
89 
90 } // end namespace MachO.
91 } // end namespace llvm.
PlatformKind
Defines the list of MachO platforms.
Definition: Platform.h:22
This class represents lattice values for constants.
Definition: AllocatorList.h:23
OSType getOS() const
getOS - Get the parsed operating system type of this triple.
Definition: Triple.h:305
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:32
StringRef getPlatformName(PlatformKind Platform)
Definition: Platform.cpp:64
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition: SmallSet.h:134
PlatformKind mapToPlatformKind(PlatformKind Platform, bool WantSim)
Definition: Platform.cpp:20
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn&#39;t already there.
Definition: SmallSet.h:180
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
EnvironmentType getEnvironment() const
getEnvironment - Get the parsed environment type of this triple.
Definition: Triple.h:314
PlatformSet mapToPlatformSet(ArrayRef< Triple > Targets)
Definition: Platform.cpp:57
bool isSimulatorEnvironment() const
Definition: Triple.h:485
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48