Skip to content

Commit

Permalink
[Driver] Enable __float128 support on X86 on FreeBSD / NetBSD (#72788)
Browse files Browse the repository at this point in the history
  • Loading branch information
brad0 authored Nov 19, 2023
1 parent aafd211 commit 23c47eb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
16 changes: 15 additions & 1 deletion clang/lib/Basic/Targets/OSTargets.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ class LLVM_LIBRARY_VISIBILITY FreeBSDTargetInfo : public OSTargetInfo<Target> {
Builder.defineMacro("__FreeBSD_cc_version", Twine(CCVersion));
Builder.defineMacro("__KPRINTF_ATTRIBUTE__");
DefineStd(Builder, "unix", Opts);
if (this->HasFloat128)
Builder.defineMacro("__FLOAT128__");

// On FreeBSD, wchar_t contains the number of the code point as
// used by the character set of the locale. These character sets are
Expand All @@ -204,9 +206,11 @@ class LLVM_LIBRARY_VISIBILITY FreeBSDTargetInfo : public OSTargetInfo<Target> {
FreeBSDTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
: OSTargetInfo<Target>(Triple, Opts) {
switch (Triple.getArch()) {
default:
case llvm::Triple::x86:
case llvm::Triple::x86_64:
this->HasFloat128 = true;
[[fallthrough]];
default:
this->MCountName = ".mcount";
break;
case llvm::Triple::mips:
Expand Down Expand Up @@ -372,12 +376,22 @@ class LLVM_LIBRARY_VISIBILITY NetBSDTargetInfo : public OSTargetInfo<Target> {
Builder.defineMacro("__unix__");
if (Opts.POSIXThreads)
Builder.defineMacro("_REENTRANT");
if (this->HasFloat128)
Builder.defineMacro("__FLOAT128__");
}

public:
NetBSDTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
: OSTargetInfo<Target>(Triple, Opts) {
this->MCountName = "__mcount";
switch (Triple.getArch()) {
default:
break;
case llvm::Triple::x86:
case llvm::Triple::x86_64:
this->HasFloat128 = true;
break;
}
}
};

Expand Down
12 changes: 10 additions & 2 deletions clang/test/CodeGenCXX/float128-declarations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@
// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-X86
// RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-linux-gnu -std=c++11 \
// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-X86
// RUN: %clang_cc1 -emit-llvm -triple i686-pc-openbsd -std=c++11 \
// RUN: %clang_cc1 -emit-llvm -triple i386-unknown-freebsd -std=c++11 \
// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-X86
// RUN: %clang_cc1 -emit-llvm -triple amd64-pc-openbsd -std=c++11 \
// RUN: %clang_cc1 -emit-llvm -triple amd64-unknown-freebsd -std=c++11 \
// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-X86
// RUN: %clang_cc1 -emit-llvm -triple i386-unknown-netbsd -std=c++11 \
// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-X86
// RUN: %clang_cc1 -emit-llvm -triple amd64-unknown-netbsd -std=c++11 \
// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-X86
// RUN: %clang_cc1 -emit-llvm -triple i386-unknown-openbsd -std=c++11 \
// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-X86
// RUN: %clang_cc1 -emit-llvm -triple amd64-unknown-openbsd -std=c++11 \
// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-X86
// RUN: %clang_cc1 -emit-llvm -triple i386-pc-solaris2.11 -std=c++11 \
// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-X86
Expand Down

0 comments on commit 23c47eb

Please sign in to comment.