https://github.com/brad0 updated https://github.com/llvm/llvm-project/pull/67222
>From b9ad72d918c663f7b5ee782979ce5704b23aa370 Mon Sep 17 00:00:00 2001 From: Brad Smith <b...@comstyle.com> Date: Sat, 23 Sep 2023 03:22:18 -0400 Subject: [PATCH] [Driver] Hook up Haiku ARM support --- clang/lib/Basic/Targets.cpp | 2 ++ clang/lib/Basic/Targets/ARM.cpp | 3 ++- clang/lib/Driver/ToolChains/Arch/ARM.cpp | 1 + clang/test/Driver/arm-abi.c | 2 ++ clang/test/Driver/haiku.c | 5 +++++ llvm/lib/TargetParser/ARMTargetParser.cpp | 6 +++++- 6 files changed, 17 insertions(+), 2 deletions(-) diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index 35d1d0d2c45c530..9e3543c6d5ff81c 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -219,6 +219,8 @@ std::unique_ptr<TargetInfo> AllocateTarget(const llvm::Triple &Triple, return std::make_unique<OpenBSDTargetInfo<ARMleTargetInfo>>(Triple, Opts); case llvm::Triple::RTEMS: return std::make_unique<RTEMSTargetInfo<ARMleTargetInfo>>(Triple, Opts); + case llvm::Triple::Haiku: + return std::make_unique<HaikuTargetInfo<ARMleTargetInfo>>(Triple, Opts); case llvm::Triple::NaCl: return std::make_unique<NaClTargetInfo<ARMleTargetInfo>>(Triple, Opts); case llvm::Triple::Win32: diff --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp index 06e99e67c875584..1e809283748b66c 100644 --- a/clang/lib/Basic/Targets/ARM.cpp +++ b/clang/lib/Basic/Targets/ARM.cpp @@ -257,6 +257,7 @@ ARMTargetInfo::ARMTargetInfo(const llvm::Triple &Triple, bool IsFreeBSD = Triple.isOSFreeBSD(); bool IsOpenBSD = Triple.isOSOpenBSD(); bool IsNetBSD = Triple.isOSNetBSD(); + bool IsHaiku = Triple.isOSHaiku(); // FIXME: the isOSBinFormatMachO is a workaround for identifying a Darwin-like // environment where size_t is `unsigned long` rather than `unsigned int` @@ -323,7 +324,7 @@ ARMTargetInfo::ARMTargetInfo(const llvm::Triple &Triple, default: if (IsNetBSD) setABI("apcs-gnu"); - else if (IsFreeBSD || IsOpenBSD) + else if (IsFreeBSD || IsOpenBSD || IsHaiku) setABI("aapcs-linux"); else setABI("aapcs"); diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp index bb66db5feae8c3b..8e1cff0b443eeeb 100644 --- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp +++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp @@ -404,6 +404,7 @@ arm::FloatABI arm::getDefaultFloatABI(const llvm::Triple &Triple) { } break; + case llvm::Triple::Haiku: case llvm::Triple::OpenBSD: return FloatABI::SoftFP; diff --git a/clang/test/Driver/arm-abi.c b/clang/test/Driver/arm-abi.c index 7bf5977992f65a2..139456cf98e1478 100644 --- a/clang/test/Driver/arm-abi.c +++ b/clang/test/Driver/arm-abi.c @@ -33,6 +33,8 @@ // RUN: | FileCheck -check-prefix=CHECK-AAPCS-LINUX %s // RUN: %clang -target arm--openbsd- %s -### -o %t.o 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-AAPCS-LINUX %s +// RUN: %clang -target arm--haiku- %s -### -o %t.o 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-AAPCS-LINUX %s // Otherwise, ABI is selected based on environment // RUN: %clang -target arm---android %s -### -o %t.o 2>&1 \ diff --git a/clang/test/Driver/haiku.c b/clang/test/Driver/haiku.c index 021ab522be06e5c..3888c6732923228 100644 --- a/clang/test/Driver/haiku.c +++ b/clang/test/Driver/haiku.c @@ -65,3 +65,8 @@ // CHECK-X86_64-SHARED-SAME: "-isysroot" "[[SYSROOT:[^"]+]]" // CHECK-X86_64-SHARED: "{{.*}}ld{{(.exe)?}}" // CHECK-X86_64-SHARED-NOT: "[[SYSROOT]]/boot/system/develop/lib/start_dyn.o" + +// Check default ARM CPU, ARMv6 +// RUN: %clang -### %s 2>&1 --target=arm-unknown-haiku \ +// RUN: | FileCheck --check-prefix=CHECK-ARM-CPU %s +// CHECK-ARM-CPU: "-target-cpu" "arm1176jzf-s" diff --git a/llvm/lib/TargetParser/ARMTargetParser.cpp b/llvm/lib/TargetParser/ARMTargetParser.cpp index c84928eeb07b140..20225232b3cccb7 100644 --- a/llvm/lib/TargetParser/ARMTargetParser.cpp +++ b/llvm/lib/TargetParser/ARMTargetParser.cpp @@ -526,7 +526,8 @@ StringRef ARM::computeDefaultTargetABI(const Triple &TT, StringRef CPU) { default: if (TT.isOSNetBSD()) return "apcs-gnu"; - if (TT.isOSFreeBSD() || TT.isOSOpenBSD() || TT.isOHOSFamily()) + if (TT.isOSFreeBSD() || TT.isOSOpenBSD() || TT.isOSHaiku() || + TT.isOHOSFamily()) return "aapcs-linux"; return "aapcs"; } @@ -542,6 +543,7 @@ StringRef ARM::getARMCPUForArch(const llvm::Triple &Triple, StringRef MArch) { case llvm::Triple::FreeBSD: case llvm::Triple::NetBSD: case llvm::Triple::OpenBSD: + case llvm::Triple::Haiku: if (!MArch.empty() && MArch == "v6") return "arm1176jzf-s"; if (!MArch.empty() && MArch == "v7") @@ -574,6 +576,8 @@ StringRef ARM::getARMCPUForArch(const llvm::Triple &Triple, StringRef MArch) { // If no specific architecture version is requested, return the minimum CPU // required by the OS and environment. switch (Triple.getOS()) { + case llvm::Triple::Haiku: + return "arm1176jzf-s"; case llvm::Triple::NetBSD: switch (Triple.getEnvironment()) { case llvm::Triple::EABI: _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits