Initial support for FreeBSD on ARM.

Patch by Andrew Turner.

llvm-svn: 170096
This commit is contained in:
Rafael Espindola 2012-12-13 04:17:14 +00:00
parent bc8016d062
commit 0f207edaa5
6 changed files with 53 additions and 1 deletions

View File

@ -3094,7 +3094,9 @@ public:
// 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;

View File

@ -1861,6 +1861,19 @@ Tool &FreeBSD::SelectTool(const Compilation &C, const JobAction &JA,
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)

View File

@ -452,6 +452,7 @@ public:
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 {

View File

@ -662,6 +662,11 @@ static StringRef getARMFloatABI(const Driver &D,
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 @@ void freebsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
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,

View File

@ -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"

View File

@ -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);