[cfe-commits] r170096 - in /cfe/trunk: lib/Basic/Targets.cpp lib/Driver/ToolChains.cpp lib/Driver/ToolChains.h lib/Driver/Tools.cpp test/Driver/freebsd.c test/Misc/freebsd-arm-size_t.c

Rafael Espindola rafael.espindola at gmail.com
Wed Dec 12 20:17:14 PST 2012


Author: rafael
Date: Wed Dec 12 22:17:14 2012
New Revision: 170096

URL: http://llvm.org/viewvc/llvm-project?rev=170096&view=rev
Log:
Initial support for FreeBSD on ARM.
Patch by Andrew Turner.

Added:
    cfe/trunk/test/Misc/freebsd-arm-size_t.c
Modified:
    cfe/trunk/lib/Basic/Targets.cpp
    cfe/trunk/lib/Driver/ToolChains.cpp
    cfe/trunk/lib/Driver/ToolChains.h
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/test/Driver/freebsd.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=170096&r1=170095&r2=170096&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Dec 12 22:17:14 2012
@@ -3094,7 +3094,9 @@
     // name.
     if (Name == "apcs-gnu") {
       DoubleAlign = LongLongAlign = LongDoubleAlign = SuitableAlign = 32;
-      SizeType = UnsignedLong;
+      // size_t is unsigned int on FreeBSD.
+      if (getTriple().getOS() != llvm::Triple::FreeBSD)
+        SizeType = UnsignedLong;
 
       // Revert to using SignedInt on apcs-gnu to comply with existing behaviour.
       WCharType = SignedInt;

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=170096&r1=170095&r2=170096&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Wed Dec 12 22:17:14 2012
@@ -1861,6 +1861,19 @@
   return *T;
 }
 
+bool FreeBSD::UseSjLjExceptions() const {
+  // FreeBSD uses SjLj exceptions on ARM oabi.
+  switch (getTriple().getEnvironment()) {
+  case llvm::Triple::GNUEABI:
+  case llvm::Triple::EABI:
+    return false;
+
+  default:
+    return (getTriple().getArch() == llvm::Triple::arm ||
+            getTriple().getArch() == llvm::Triple::thumb);
+  }
+}
+
 /// NetBSD - NetBSD tool chain which can call as(1) and ld(1) directly.
 
 NetBSD::NetBSD(const Driver &D, const llvm::Triple& Triple, const ArgList &Args)

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=170096&r1=170095&r2=170096&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Wed Dec 12 22:17:14 2012
@@ -452,6 +452,7 @@
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
                            const ActionList &Inputs) const;
+  virtual bool UseSjLjExceptions() const;
 };
 
 class LLVM_LIBRARY_VISIBILITY NetBSD : public Generic_ELF {

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=170096&r1=170095&r2=170096&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Dec 12 22:17:14 2012
@@ -662,6 +662,11 @@
       break;
     }
 
+    case llvm::Triple::FreeBSD:
+      // FreeBSD defaults to soft float
+      FloatABI = "soft";
+      break;
+
     default:
       switch(Triple.getEnvironment()) {
       case llvm::Triple::GNUEABIHF:
@@ -4944,6 +4949,17 @@
          LastPICArg->getOption().matches(options::OPT_fpie))) {
       CmdArgs.push_back("-KPIC");
     }
+  } else if (getToolChain().getArch() == llvm::Triple::arm ||
+             getToolChain().getArch() == llvm::Triple::thumb) {
+    CmdArgs.push_back("-mfpu=softvfp");
+    switch(getToolChain().getTriple().getEnvironment()) {
+    case llvm::Triple::GNUEABI:
+    case llvm::Triple::EABI:
+      break;
+
+    default:
+      CmdArgs.push_back("-matpcs");
+    }
   }
 
   Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA,

Modified: cfe/trunk/test/Driver/freebsd.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/freebsd.c?rev=170096&r1=170095&r2=170096&view=diff
==============================================================================
--- cfe/trunk/test/Driver/freebsd.c (original)
+++ cfe/trunk/test/Driver/freebsd.c Wed Dec 12 22:17:14 2012
@@ -96,3 +96,14 @@
 // RUN:   | FileCheck --check-prefix=CHECK-NORMAL %s
 // CHECK-NORMAL: crt1.o
 // CHECK-NORMAL: crtbegin.o
+
+// RUN: %clang %s -### -o %t.o -target arm-unknown-freebsd10.0 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM %s
+// CHECK-ARM: clang{{.*}}" "-cc1"{{.*}}" "-fsjlj-exceptions"
+// CHECK-ARM: as{{.*}}" "-mfpu=softvfp"{{.*}}"-matpcs"
+
+// RUN: %clang %s -### -o %t.o -target arm-gnueabi-freebsd10.0 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM-EABI %s
+// CHECK-ARM-EABI-NOT: clang{{.*}}" "-cc1"{{.*}}" "-fsjlj-exceptions"
+// CHECK-ARM-EABI: as{{.*}}" "-mfpu=softvfp"
+// CHECK-ARM-EABI-NOT: as{{.*}}" "-matpcs"

Added: cfe/trunk/test/Misc/freebsd-arm-size_t.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/freebsd-arm-size_t.c?rev=170096&view=auto
==============================================================================
--- cfe/trunk/test/Misc/freebsd-arm-size_t.c (added)
+++ cfe/trunk/test/Misc/freebsd-arm-size_t.c Wed Dec 12 22:17:14 2012
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple arm-unknown-freebsd10.0 -verify %s
+// expected-no-diagnostics
+
+/* Define a size_t as expected for FreeBSD ARM */
+typedef unsigned int size_t;
+
+/* Declare a builtin function that uses size_t */
+void *malloc(size_t);
+





More information about the cfe-commits mailing list