Skip to content

Conversation

brad0
Copy link
Contributor

@brad0 brad0 commented Nov 19, 2023

No description provided.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Nov 19, 2023
@llvmbot
Copy link
Member

llvmbot commented Nov 19, 2023

@llvm/pr-subscribers-clang

Author: Brad Smith (brad0)

Changes

…/ NetBSD


Full diff: https://github.com/llvm/llvm-project/pull/72788.diff

2 Files Affected:

  • (modified) clang/lib/Basic/Targets/OSTargets.h (+18-2)
  • (modified) clang/test/CodeGenCXX/float128-declarations.cpp (+12-2)
diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h
index 23799d8a4ae17bc..7cb4110921b9e62 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -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
@@ -204,17 +206,21 @@ 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::ppc64le:
+      this->HasFloat128 = true;
+      [[fallthrough]];
     case llvm::Triple::mips:
     case llvm::Triple::mipsel:
     case llvm::Triple::ppc:
     case llvm::Triple::ppcle:
     case llvm::Triple::ppc64:
-    case llvm::Triple::ppc64le:
       this->MCountName = "_mcount";
       break;
     case llvm::Triple::arm:
@@ -372,12 +378,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;
+    }
   }
 };
 
diff --git a/clang/test/CodeGenCXX/float128-declarations.cpp b/clang/test/CodeGenCXX/float128-declarations.cpp
index ddfe9dce109c81e..fd6c98fc4ba3d0b 100644
--- a/clang/test/CodeGenCXX/float128-declarations.cpp
+++ b/clang/test/CodeGenCXX/float128-declarations.cpp
@@ -2,13 +2,23 @@
 // RUN:   -target-feature +float128 -std=c++11 %s -o - | FileCheck %s
 // RUN: %clang_cc1 -emit-llvm -triple powerpc64le-unknown-unknown \
 // RUN:   -target-feature +float128 -std=c++11 %s -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -triple powerpc64le-unknown-freebsd \
+// RUN:   -target-feature +float128 -std=c++11 %s -o - | FileCheck %s
 // RUN: %clang_cc1 -emit-llvm -triple i386-unknown-linux-gnu -std=c++11 \
 // 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-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-pc-openbsd -std=c++11 \
+// 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

@brad0 brad0 force-pushed the clang_driver_freebsd_netbsd_float128 branch from 96f280a to 851adf1 Compare November 19, 2023 07:08
@brad0 brad0 changed the title [Driver] Enable __float128 support on X86 and PowerPC64le on FreeBSD … [Driver] Enable __float128 support on X86 and PPC64le on FreeBSD / NetBSD Nov 19, 2023
@brad0 brad0 requested review from nikic, emaste and MaskRay and removed request for nikic November 19, 2023 07:11
@MaskRay
Copy link
Member

MaskRay commented Nov 19, 2023

Linux ppc64le does not support __float128. Should *BSD support it?

@brad0
Copy link
Contributor Author

brad0 commented Nov 19, 2023

Linux ppc64le does not support __float128. Should *BSD support it?

There was another patch floating around to add support for the driver. I'll remove it for now.

@brad0 brad0 force-pushed the clang_driver_freebsd_netbsd_float128 branch from 851adf1 to bde98ba Compare November 19, 2023 07:35
@brad0 brad0 changed the title [Driver] Enable __float128 support on X86 and PPC64le on FreeBSD / NetBSD [Driver] Enable __float128 support on X86 on FreeBSD / NetBSD Nov 19, 2023
@brad0 brad0 merged commit 23c47eb into llvm:main Nov 19, 2023
@brad0 brad0 deleted the clang_driver_freebsd_netbsd_float128 branch November 19, 2023 08:00
sr-tream pushed a commit to sr-tream/llvm-project that referenced this pull request Nov 20, 2023
zahiraam pushed a commit to zahiraam/llvm-project that referenced this pull request Nov 20, 2023
tru pushed a commit that referenced this pull request Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category platform:freebsd platform:netbsd
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants