[Patch] Support for Nuxi CloudABI

Ed Schouten ed at nuxi.nl
Sun Mar 8 04:32:03 PDT 2015


2015-03-07 17:46 GMT+01:00 Eric Christopher <echristo at gmail.com>:
> That's fine. Just reply with the patch with testcase for the record. :)

Sure!

Before Eric pointed me to the unit tests for Triple, I was under the
impression that we only tested triples by having accidental testing
coverage for them through the IR dumps we have in test/. My idea was
therefore to at least add some coverage for CloudABI by adjusting one
of the existing tests to use the CloudABI triple:

Index: test/CodeGen/X86/dwarf-eh-prepare.ll
===================================================================
--- test/CodeGen/X86/dwarf-eh-prepare.ll        (revision 231492)
+++ test/CodeGen/X86/dwarf-eh-prepare.ll        (working copy)
@@ -1,4 +1,4 @@
-; RUN: opt -mtriple=x86_64-linux-gnu -dwarfehprepare < %s -S | FileCheck %s
+; RUN: opt -mtriple=x86_64-unknown-cloudabi -dwarfehprepare < %s -S |
FileCheck %s

 ; Check basic functionality of IR-to-IR DWARF EH preparation. This should
 ; eliminate resumes. This pass requires a TargetMachine, so we put it under X86

Further testing (after I sent the patch to Eric) revealed that this
change makes little sense. LLVM doesn't really care if the triple you
provide is valid at all. I used a couple of random OS names but none
of them caused the test to fail.

My proposal is to stick to the original patch I sent out two days ago,
including the change to unittests/ADT/TripleTest.cpp. Attached is a
combined patch.

-- 
Ed Schouten <ed at nuxi.nl>
-------------- next part --------------
Index: include/llvm/ADT/Triple.h
===================================================================
--- include/llvm/ADT/Triple.h	(revision 231492)
+++ include/llvm/ADT/Triple.h	(working copy)
@@ -120,6 +120,7 @@
   enum OSType {
     UnknownOS,
 
+    CloudABI,
     Darwin,
     DragonFly,
     FreeBSD,
Index: include/llvm/MC/MCELFObjectWriter.h
===================================================================
--- include/llvm/MC/MCELFObjectWriter.h	(revision 231492)
+++ include/llvm/MC/MCELFObjectWriter.h	(working copy)
@@ -41,6 +41,8 @@
 public:
   static uint8_t getOSABI(Triple::OSType OSType) {
     switch (OSType) {
+      case Triple::CloudABI:
+        return ELF::ELFOSABI_CLOUDABI;
       case Triple::PS4:
       case Triple::FreeBSD:
         return ELF::ELFOSABI_FREEBSD;
Index: include/llvm/Support/ELF.h
===================================================================
--- include/llvm/Support/ELF.h	(revision 231492)
+++ include/llvm/Support/ELF.h	(working copy)
@@ -344,6 +344,7 @@
   ELFOSABI_NSK = 14,          // Hewlett-Packard Non-Stop Kernel
   ELFOSABI_AROS = 15,         // AROS
   ELFOSABI_FENIXOS = 16,      // FenixOS
+  ELFOSABI_CLOUDABI = 17,     // Nuxi CloudABI
   ELFOSABI_C6000_ELFABI = 64, // Bare-metal TMS320C6000
   ELFOSABI_C6000_LINUX = 65,  // Linux TMS320C6000
   ELFOSABI_ARM = 97,          // ARM
Index: lib/Object/ELFYAML.cpp
===================================================================
--- lib/Object/ELFYAML.cpp	(revision 231492)
+++ lib/Object/ELFYAML.cpp	(working copy)
@@ -235,6 +235,7 @@
   ECase(ELFOSABI_NSK)
   ECase(ELFOSABI_AROS)
   ECase(ELFOSABI_FENIXOS)
+  ECase(ELFOSABI_CLOUDABI)
   ECase(ELFOSABI_C6000_ELFABI)
   ECase(ELFOSABI_C6000_LINUX)
   ECase(ELFOSABI_ARM)
Index: lib/Support/Triple.cpp
===================================================================
--- lib/Support/Triple.cpp	(revision 231492)
+++ lib/Support/Triple.cpp	(working copy)
@@ -141,6 +141,7 @@
   switch (Kind) {
   case UnknownOS: return "unknown";
 
+  case CloudABI: return "cloudabi";
   case Darwin: return "darwin";
   case DragonFly: return "dragonfly";
   case FreeBSD: return "freebsd";
@@ -345,6 +346,7 @@
 
 static Triple::OSType parseOS(StringRef OSName) {
   return StringSwitch<Triple::OSType>(OSName)
+    .StartsWith("cloudabi", Triple::CloudABI)
     .StartsWith("darwin", Triple::Darwin)
     .StartsWith("dragonfly", Triple::DragonFly)
     .StartsWith("freebsd", Triple::FreeBSD)
Index: tools/llvm-readobj/ELFDumper.cpp
===================================================================
--- tools/llvm-readobj/ELFDumper.cpp	(revision 231492)
+++ tools/llvm-readobj/ELFDumper.cpp	(working copy)
@@ -207,6 +207,7 @@
   { "NSK",          ELF::ELFOSABI_NSK          },
   { "AROS",         ELF::ELFOSABI_AROS         },
   { "FenixOS",      ELF::ELFOSABI_FENIXOS      },
+  { "CloudABI",     ELF::ELFOSABI_CLOUDABI     },
   { "C6000_ELFABI", ELF::ELFOSABI_C6000_ELFABI },
   { "C6000_LINUX" , ELF::ELFOSABI_C6000_LINUX  },
   { "ARM",          ELF::ELFOSABI_ARM          },
Index: unittests/ADT/TripleTest.cpp
===================================================================
--- unittests/ADT/TripleTest.cpp	(revision 231492)
+++ unittests/ADT/TripleTest.cpp	(working copy)
@@ -159,6 +159,12 @@
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
   EXPECT_EQ(Triple::UnknownOS, T.getOS());
 
+  T = Triple("x86_64-unknown-cloudabi");
+  EXPECT_EQ(Triple::x86_64, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::CloudABI, T.getOS());
+  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
+
   T = Triple("huh");
   EXPECT_EQ(Triple::UnknownArch, T.getArch());
 }


More information about the llvm-commits mailing list