Skip to content

Commit

Permalink
[Triple] Add triple for Fuchsia
Browse files Browse the repository at this point in the history
Fuchsia is a new operating system.

Differential Revision: https://reviews.llvm.org/D25116

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283419 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
petrhosek committed Oct 6, 2016
1 parent 8926801 commit fc05fb6
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/llvm/ADT/Triple.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class Triple {
Darwin,
DragonFly,
FreeBSD,
Fuchsia,
IOS,
KFreeBSD,
Linux,
Expand Down Expand Up @@ -462,6 +463,10 @@ class Triple {
return getOS() == Triple::FreeBSD;
}

bool isOSFuchsia() const {
return getOS() == Triple::Fuchsia;
}

bool isOSDragonFly() const { return getOS() == Triple::DragonFly; }

bool isOSSolaris() const {
Expand Down
2 changes: 2 additions & 0 deletions lib/Support/Triple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ StringRef Triple::getOSTypeName(OSType Kind) {
case Darwin: return "darwin";
case DragonFly: return "dragonfly";
case FreeBSD: return "freebsd";
case Fuchsia: return "fuchsia";
case IOS: return "ios";
case KFreeBSD: return "kfreebsd";
case Linux: return "linux";
Expand Down Expand Up @@ -438,6 +439,7 @@ static Triple::OSType parseOS(StringRef OSName) {
.StartsWith("darwin", Triple::Darwin)
.StartsWith("dragonfly", Triple::DragonFly)
.StartsWith("freebsd", Triple::FreeBSD)
.StartsWith("fuchsia", Triple::Fuchsia)
.StartsWith("ios", Triple::IOS)
.StartsWith("kfreebsd", Triple::KFreeBSD)
.StartsWith("linux", Triple::Linux)
Expand Down
2 changes: 2 additions & 0 deletions lib/Target/X86/X86TargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
return make_unique<X86FreeBSDTargetObjectFile>();
if (TT.isOSLinux() || TT.isOSNaCl())
return make_unique<X86LinuxNaClTargetObjectFile>();
if (TT.isOSFuchsia())
return make_unique<X86FuchsiaTargetObjectFile>();
if (TT.isOSBinFormatELF())
return make_unique<X86ELFTargetObjectFile>();
if (TT.isKnownWindowsMSVCEnvironment() || TT.isWindowsCoreCLREnvironment())
Expand Down
7 changes: 7 additions & 0 deletions lib/Target/X86/X86TargetObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ X86FreeBSDTargetObjectFile::Initialize(MCContext &Ctx,
InitializeELF(TM.Options.UseInitArray);
}

void
X86FuchsiaTargetObjectFile::Initialize(MCContext &Ctx,
const TargetMachine &TM) {
TargetLoweringObjectFileELF::Initialize(Ctx, TM);
InitializeELF(TM.Options.UseInitArray);
}

void
X86LinuxNaClTargetObjectFile::Initialize(MCContext &Ctx,
const TargetMachine &TM) {
Expand Down
5 changes: 5 additions & 0 deletions lib/Target/X86/X86TargetObjectFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ namespace llvm {
void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
};

/// \brief This implementation is used for Fuchsia on x86-64.
class X86FuchsiaTargetObjectFile : public X86ELFTargetObjectFile {
void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
};

/// X86LinuxNaClTargetObjectFile - This implementation is used for linux and
/// Native Client on x86 and x86-64.
class X86LinuxNaClTargetObjectFile : public X86ELFTargetObjectFile {
Expand Down
6 changes: 6 additions & 0 deletions unittests/ADT/TripleTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@ TEST(TripleTest, ParsedIDs) {
EXPECT_EQ(Triple::CloudABI, T.getOS());
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());

T = Triple("x86_64-unknown-fuchsia");
EXPECT_EQ(Triple::x86_64, T.getArch());
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
EXPECT_EQ(Triple::Fuchsia, T.getOS());
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());

T = Triple("wasm32-unknown-unknown");
EXPECT_EQ(Triple::wasm32, T.getArch());
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
Expand Down

0 comments on commit fc05fb6

Please sign in to comment.