Skip to content

[Driver] Hook up Haiku ARM support #67222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/lib/Basic/Targets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion clang/lib/Basic/Targets/ARM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Driver/ToolChains/Arch/ARM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ arm::FloatABI arm::getDefaultFloatABI(const llvm::Triple &Triple) {
}
break;

case llvm::Triple::Haiku:
case llvm::Triple::OpenBSD:
return FloatABI::SoftFP;

Expand Down
2 changes: 2 additions & 0 deletions clang/test/Driver/arm-abi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
5 changes: 5 additions & 0 deletions clang/test/Driver/haiku.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
6 changes: 5 additions & 1 deletion llvm/lib/TargetParser/ARMTargetParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand All @@ -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")
Expand Down Expand Up @@ -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:
Expand Down