mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 02:33:06 +01:00
[llvm][TextAPI] add mapping from OS string to Platform
* add utility for matching target triple OS value strings to PlatformKind This was reviewed offline by ributzka, steven_wu
This commit is contained in:
parent
ab08d36d20
commit
98255d6170
@ -39,6 +39,7 @@ PlatformKind mapToPlatformKind(PlatformKind Platform, bool WantSim);
|
|||||||
PlatformKind mapToPlatformKind(const Triple &Target);
|
PlatformKind mapToPlatformKind(const Triple &Target);
|
||||||
PlatformSet mapToPlatformSet(ArrayRef<Triple> Targets);
|
PlatformSet mapToPlatformSet(ArrayRef<Triple> Targets);
|
||||||
StringRef getPlatformName(PlatformKind Platform);
|
StringRef getPlatformName(PlatformKind Platform);
|
||||||
|
PlatformKind getPlatformFromName(StringRef Name);
|
||||||
|
|
||||||
} // end namespace MachO.
|
} // end namespace MachO.
|
||||||
} // end namespace llvm.
|
} // end namespace llvm.
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "llvm/TextAPI/Platform.h"
|
#include "llvm/TextAPI/Platform.h"
|
||||||
#include "llvm/ADT/ArrayRef.h"
|
#include "llvm/ADT/ArrayRef.h"
|
||||||
|
#include "llvm/ADT/StringSwitch.h"
|
||||||
#include "llvm/ADT/Triple.h"
|
#include "llvm/ADT/Triple.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
@ -89,5 +90,20 @@ StringRef getPlatformName(PlatformKind Platform) {
|
|||||||
llvm_unreachable("Unknown llvm.MachO.PlatformKind enum");
|
llvm_unreachable("Unknown llvm.MachO.PlatformKind enum");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlatformKind getPlatformFromName(StringRef Name) {
|
||||||
|
return StringSwitch<PlatformKind>(Name)
|
||||||
|
.Case("macos", PlatformKind::macOS)
|
||||||
|
.Case("ios", PlatformKind::iOS)
|
||||||
|
.Case("tvos", PlatformKind::tvOS)
|
||||||
|
.Case("watchos", PlatformKind::watchOS)
|
||||||
|
.Case("bridgeos", PlatformKind::macOS)
|
||||||
|
.Case("ios-macabi", PlatformKind::macCatalyst)
|
||||||
|
.Case("ios-simulator", PlatformKind::iOSSimulator)
|
||||||
|
.Case("tvos-simulator", PlatformKind::tvOSSimulator)
|
||||||
|
.Case("watchos-simulator", PlatformKind::watchOSSimulator)
|
||||||
|
.Case("driverkit", PlatformKind::driverKit)
|
||||||
|
.Default(PlatformKind::unknown);
|
||||||
|
}
|
||||||
|
|
||||||
} // end namespace MachO.
|
} // end namespace MachO.
|
||||||
} // end namespace llvm.
|
} // end namespace llvm.
|
||||||
|
@ -82,8 +82,8 @@ TEST(TBDv4, ReadFile) {
|
|||||||
TBDFile File = std::move(Result.get());
|
TBDFile File = std::move(Result.get());
|
||||||
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
|
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
|
||||||
PlatformSet Platforms;
|
PlatformSet Platforms;
|
||||||
Platforms.insert(PlatformKind::macOS);
|
Platforms.insert(getPlatformFromName("macos"));
|
||||||
Platforms.insert(PlatformKind::iOS);
|
Platforms.insert(getPlatformFromName("ios"));
|
||||||
auto Archs = AK_i386 | AK_x86_64;
|
auto Archs = AK_i386 | AK_x86_64;
|
||||||
TargetList Targets = {
|
TargetList Targets = {
|
||||||
Target(AK_i386, PlatformKind::macOS),
|
Target(AK_i386, PlatformKind::macOS),
|
||||||
|
Loading…
Reference in New Issue
Block a user