[LLVMdev] [cfe-dev] [PATCH] triples for baremetal
Jonathan Roelofs
jonathan at codesourcery.com
Thu Jun 19 06:52:18 PDT 2014
[+llvm-commits, +cfe-commits] (forgot to add them too)
-------- Original Message --------
Subject: [cfe-dev] [PATCH] triples for baremetal
Date: Thu, 19 Jun 2014 07:43:44 -0600
From: Jonathan Roelofs <jonathan at codesourcery.com>
To: Eric Christopher <echristo at gmail.com>
CC: Clang Commits <cfe-commits at cs.uiuc.edu>, Phoebe Buckheister
<llvm at quasiparticle.net>, "cfe-dev at cs.uiuc.edu" <cfe-dev at cs.uiuc.edu>,
"llvmdev at cs.uiuc.edu" <llvmdev at cs.uiuc.edu>
Eric,
Attached are patches for llvm and clang that implement this.
I've made 'none' a component that must be added explicitly (i.e. don't turn
arm-eabi into arm--none-eabi, but rather turn it into arm--unknown-eabi) to try
to reduce surprises. It also keeps the normalization logic a bit simpler than it
would otherwise have to be.
SPIR triples were one place where I was uncertain... I'm not sure if they'd
prefer to use 'none' or rather just omit that part of the triple. So on those,
I've left them to use Triple::UnknownOS.
Cheers,
Jon
On 6/17/14, 11:11 AM, Eric Christopher wrote:
> Agreed.
>
> -eric
>
> On Tue, Jun 17, 2014 at 9:54 AM, Jonathan Roelofs
> <jonathan at codesourcery.com> wrote:
>> [+llvmdev, -llvm-dev]
>>
>> (Oopsies, llvmdev doesn't have a hyphen in it like all the others do)
>>
>>
>> On 6/17/14, 10:45 AM, Jonathan Roelofs wrote:
>>>
>>> [+llvm-dev, cfe-dev]
>>>
>>> Was "Re: [PATCH] ARM: allow inline atomics on Cortex M"
>>>
>>> On 6/17/14, 10:42 AM, Jonathan Roelofs wrote:
>>>>
>>>>
>>>>
>>>> On 6/17/14, 9:35 AM, Renato Golin wrote:
>>>>>
>>>>> On 17 June 2014 16:29, Jonathan Roelofs <jonathan at codesourcery.com>
>>>>> wrote:
>>>>>>
>>>>>> Attached is what I now think the patch ought to be.
>>>>>
>>>>>
>>>>> Does unknownOS *always* mean bare-metal?
>>>>
>>>> I'm not sure. It might be a good time to fork this thread, and start
>>>> another
>>>> about triples for bare-metal...
>>>
>>>
>>> Personally, I think we ought to add a 'None' entry to the OSType enum
>>> specifically for baremetal, and then map triples like arm-none-eabi and
>>> arm--eabi to it (but not arm-foobar-eabi, for example).
>>>
>>> Thoughts?
>>>
>>> Jon
>>>
>>>>>
>>>>> --renato
>>>>>
>>>>
>>>
>>
>> --
>> Jon Roelofs
>> jonathan at codesourcery.com
>> CodeSourcery / Mentor Embedded
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
--
Jon Roelofs
jonathan at codesourcery.com
CodeSourcery / Mentor Embedded
--
Jon Roelofs
jonathan at codesourcery.com
CodeSourcery / Mentor Embedded
-------------- next part --------------
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp (revision 211122)
+++ lib/Driver/Tools.cpp (working copy)
@@ -675,7 +675,7 @@
default:
// Assume "soft", but warn the user we are guessing.
FloatABI = "soft";
- if (Triple.getOS() != llvm::Triple::UnknownOS ||
+ if (Triple.getOS() != llvm::Triple::NoneOS ||
!Triple.isOSBinFormatMachO())
D.Diag(diag::warn_drv_assuming_mfloat_abi_is) << "soft";
break;
@@ -756,7 +756,7 @@
// The backend is hardwired to assume AAPCS for M-class processors, ensure
// the frontend matches that.
if (Triple.getEnvironment() == llvm::Triple::EABI ||
- (Triple.getOS() == llvm::Triple::UnknownOS &&
+ (Triple.getOS() == llvm::Triple::NoneOS &&
Triple.getObjectFormat() == llvm::Triple::MachO) ||
StringRef(CPUName).startswith("cortex-m")) {
ABIName = "aapcs";
@@ -5128,7 +5128,7 @@
if (Str == "x86_64h")
T.setArchName(Str);
else if (Str == "armv6m" || Str == "armv7m" || Str == "armv7em") {
- T.setOS(llvm::Triple::UnknownOS);
+ T.setOS(llvm::Triple::NoneOS);
T.setObjectFormat(llvm::Triple::MachO);
}
}
Index: test/Driver/macho-embedded.c
===================================================================
--- test/Driver/macho-embedded.c (revision 211122)
+++ test/Driver/macho-embedded.c (working copy)
@@ -11,5 +11,5 @@
// CHECK-AAPCS: "-target-abi" "aapcs"
// CHECK-APCS: "-target-abi" "apcs-gnu"
-// CHECK-MACHO-EMBEDDED: "-triple" "{{thumbv[67]e?m}}-apple-unknown-macho"
+// CHECK-MACHO-EMBEDDED: "-triple" "{{thumbv[67]e?m}}-apple-none-macho"
// CHECK-MACHO-EMBEDDED: "-mrelocation-model" "pic"
-------------- next part --------------
Index: include/llvm/ADT/Triple.h
===================================================================
--- include/llvm/ADT/Triple.h (revision 211122)
+++ include/llvm/ADT/Triple.h (working copy)
@@ -105,6 +105,7 @@
MacOSX,
MinGW32, // i*86-pc-mingw32, *-w64-mingw32
NetBSD,
+ NoneOS, // Baremetal
OpenBSD,
Solaris,
Win32,
Index: lib/Support/Triple.cpp
===================================================================
--- lib/Support/Triple.cpp (revision 211122)
+++ lib/Support/Triple.cpp (working copy)
@@ -137,6 +137,7 @@
case MacOSX: return "macosx";
case MinGW32: return "mingw32";
case NetBSD: return "netbsd";
+ case NoneOS: return "none";
case OpenBSD: return "openbsd";
case Solaris: return "solaris";
case Win32: return "windows";
@@ -310,6 +311,7 @@
.StartsWith("macosx", Triple::MacOSX)
.StartsWith("mingw32", Triple::MinGW32)
.StartsWith("netbsd", Triple::NetBSD)
+ .StartsWith("none", Triple::NoneOS)
.StartsWith("openbsd", Triple::OpenBSD)
.StartsWith("solaris", Triple::Solaris)
.StartsWith("win32", Triple::Win32)
Index: lib/Target/ARM/ARMSubtarget.cpp
===================================================================
--- lib/Target/ARM/ARMSubtarget.cpp (revision 211122)
+++ lib/Target/ARM/ARMSubtarget.cpp (working copy)
@@ -264,7 +264,7 @@
default:
if ((isTargetIOS() && isMClass()) ||
(TargetTriple.isOSBinFormatMachO() &&
- TargetTriple.getOS() == Triple::UnknownOS))
+ TargetTriple.getOS() == Triple::NoneOS))
TargetABI = ARM_ABI_AAPCS;
else
TargetABI = ARM_ABI_APCS;
Index: unittests/ADT/TripleTest.cpp
===================================================================
--- unittests/ADT/TripleTest.cpp (revision 211122)
+++ unittests/ADT/TripleTest.cpp (working copy)
@@ -123,12 +123,6 @@
EXPECT_EQ(Triple::UnknownOS, T.getOS());
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
- T = Triple("arm-none-none-eabi");
- EXPECT_EQ(Triple::arm, T.getArch());
- EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
- EXPECT_EQ(Triple::UnknownOS, T.getOS());
- EXPECT_EQ(Triple::EABI, T.getEnvironment());
-
T = Triple("huh");
EXPECT_EQ(Triple::UnknownArch, T.getArch());
}
@@ -246,7 +240,7 @@
EXPECT_EQ("i486--linux-gnu", Triple::normalize("i486-linux-gnu")); // i486-pc-linux-gnu
EXPECT_EQ("i386-redhat-linux", Triple::normalize("i386-redhat-linux")); // i386-redhat-linux-gnu
EXPECT_EQ("i686--linux", Triple::normalize("i686-linux")); // i686-pc-linux-gnu
- EXPECT_EQ("arm-none--eabi", Triple::normalize("arm-none-eabi")); // arm-none-eabi
+ EXPECT_EQ("arm--none-eabi", Triple::normalize("arm-none-eabi")); // arm-none-eabi
}
TEST(TripleTest, MutateName) {
@@ -564,4 +558,27 @@
EXPECT_EQ("i686-pc-windows-elf", Triple::normalize("i686-pc-windows-elf-elf"));
}
+
+TEST(TripleTest, Baremetal) {
+ Triple T;
+
+ T = Triple("arm--dunno-eabi");
+ EXPECT_EQ(Triple::arm, T.getArch());
+ EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+ EXPECT_EQ(Triple::UnknownOS, T.getOS());
+ EXPECT_EQ(Triple::EABI, T.getEnvironment());
+
+ EXPECT_EQ("arm---eabi", Triple::normalize("arm---eabi"));
+ EXPECT_EQ("arm---eabi", Triple::normalize("arm--eabi"));
+ EXPECT_EQ("arm---eabi", Triple::normalize("arm-eabi"));
+
+ T = Triple("arm--none-eabi");
+ EXPECT_EQ(Triple::arm, T.getArch());
+ EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+ EXPECT_EQ(Triple::NoneOS, T.getOS());
+ EXPECT_EQ(Triple::EABI, T.getEnvironment());
+
+ EXPECT_EQ("arm-none-none-eabi", Triple::normalize("arm-none-none-eabi"));
+ EXPECT_EQ("arm--none-eabi", Triple::normalize("arm-none-eabi"));
}
+}
-------------- next part --------------
_______________________________________________
cfe-dev mailing list
cfe-dev at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
More information about the llvm-dev
mailing list