Skip to content

Commit

Permalink
Define "contiki" OS specifier.
Browse files Browse the repository at this point in the history
Patch by Michael LeMay

Differential revision: http://reviews.llvm.org/D24897

llvm-svn: 284240
  • Loading branch information
David L Kreitzer committed Oct 14, 2016
1 parent 00fc7a6 commit 3155abf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion llvm/include/llvm/ADT/Triple.h
Expand Up @@ -170,7 +170,8 @@ class Triple {
TvOS, // Apple tvOS
WatchOS, // Apple watchOS
Mesa3D,
LastOSType = Mesa3D
Contiki,
LastOSType = Contiki
};
enum EnvironmentType {
UnknownEnvironment,
Expand Down Expand Up @@ -489,6 +490,10 @@ class Triple {
Env == Triple::GNUX32;
}

bool isOSContiki() const {
return getOS() == Triple::Contiki;
}

/// Checks if the environment could be MSVC.
bool isWindowsMSVCEnvironment() const {
return getOS() == Triple::Win32 &&
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Support/Triple.cpp
Expand Up @@ -193,6 +193,7 @@ StringRef Triple::getOSTypeName(OSType Kind) {
case TvOS: return "tvos";
case WatchOS: return "watchos";
case Mesa3D: return "mesa3d";
case Contiki: return "contiki";
}

llvm_unreachable("Invalid OSType");
Expand Down Expand Up @@ -465,6 +466,7 @@ static Triple::OSType parseOS(StringRef OSName) {
.StartsWith("tvos", Triple::TvOS)
.StartsWith("watchos", Triple::WatchOS)
.StartsWith("mesa3d", Triple::Mesa3D)
.StartsWith("contiki", Triple::Contiki)
.Default(Triple::UnknownOS);
}

Expand Down
6 changes: 6 additions & 0 deletions llvm/unittests/ADT/TripleTest.cpp
Expand Up @@ -87,6 +87,12 @@ TEST(TripleTest, ParsedIDs) {
EXPECT_EQ(Triple::ELFIAMCU, T.getOS());
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());

T = Triple("i386-pc-contiki-unknown");
EXPECT_EQ(Triple::x86, T.getArch());
EXPECT_EQ(Triple::PC, T.getVendor());
EXPECT_EQ(Triple::Contiki, T.getOS());
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());

T = Triple("x86_64-pc-linux-gnu");
EXPECT_EQ(Triple::x86_64, T.getArch());
EXPECT_EQ(Triple::PC, T.getVendor());
Expand Down

0 comments on commit 3155abf

Please sign in to comment.