https://github.com/alexrp updated 
https://github.com/llvm/llvm-project/pull/232943

From f1fb04b577f6b82def512956a8e376c992d52f87 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= <[email protected]>
Date: Fri, 16 Oct 2026 23:09:16 +0200
Subject: [PATCH] [Sparc] Use 64-bit long double for v8 sparc-netbsd

---
 clang/test/CodeGen/Sparc/sparc-long-double-abi.c | 1 +
 clang/test/Preprocessor/init.c                   | 2 +-
 llvm/lib/TargetParser/Triple.cpp                 | 4 ++--
 llvm/unittests/TargetParser/TripleTest.cpp       | 6 +++++-
 4 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/clang/test/CodeGen/Sparc/sparc-long-double-abi.c 
b/clang/test/CodeGen/Sparc/sparc-long-double-abi.c
index 0cc2d666d1642e..d6f226890762fc 100644
--- a/clang/test/CodeGen/Sparc/sparc-long-double-abi.c
+++ b/clang/test/CodeGen/Sparc/sparc-long-double-abi.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple sparc-unknown-none -O1 -emit-llvm -o - %s | 
FileCheck %s
 // RUN: %clang_cc1 -triple sparc-unknown-linux-gnu -O1 -emit-llvm -o - %s | 
FileCheck %s --check-prefix=LINUX
+// RUN: %clang_cc1 -triple sparc-unknown-netbsd -O1 -emit-llvm -o - %s | 
FileCheck %s
 
 void sink(long double);
 void vararg(int, ...);
diff --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
index df8142b4c273fe..0d6463f5411aed 100644
--- a/clang/test/Preprocessor/init.c
+++ b/clang/test/Preprocessor/init.c
@@ -1010,7 +1010,7 @@
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=sparc-none-none < /dev/null | FileCheck -match-full-lines -check-prefix 
SPARC -check-prefix SPARC-DEFAULT -check-prefix SPARC-LDBL64 %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=sparc-rtems-elf < /dev/null | FileCheck -match-full-lines -check-prefix 
SPARC -check-prefix SPARC-DEFAULT -check-prefix SPARC-LDBL64 %s
-// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=sparc-none-netbsd < /dev/null | FileCheck -match-full-lines 
-check-prefix SPARC -check-prefix SPARC-NETOPENBSD -check-prefix SPARC-LDBL128 
%s
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=sparc-none-netbsd < /dev/null | FileCheck -match-full-lines 
-check-prefix SPARC -check-prefix SPARC-NETOPENBSD -check-prefix SPARC-LDBL64 %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=sparc-unknown-linux-gnu < /dev/null | FileCheck -match-full-lines 
-check-prefix SPARC-LDBL128 %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=sparc-sun-solaris < /dev/null | FileCheck -match-full-lines 
-check-prefix SPARC-LDBL128 %s
 // RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=sparc-none-none < /dev/null | FileCheck -match-full-lines -check-prefix 
SPARC -check-prefix SPARC-DEFAULT -check-prefix SPARC-LDBL64 -check-prefix 
SPARC-DEFAULT-CXX %s
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 44a94de914a9a8..ee236cf1ac1c47 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -2566,8 +2566,8 @@ LongDoubleFormat Triple::getDefaultLongDoubleFormat() 
const {
     return LongDoubleFormat::IEEEquad;
   case sparc:
   case sparcel:
-    // GCC uses IEEE double for bare-metal and RTEMS SPARC V8 targets.
-    if (getOS() == UnknownOS || getOS() == RTEMS)
+    // GCC uses IEEE double for bare-metal, NetBSD, and RTEMS SPARC V8 targets.
+    if (getOS() == UnknownOS || getOS() == NetBSD || getOS() == RTEMS)
       return LongDoubleFormat::IEEEdouble;
     return LongDoubleFormat::IEEEquad;
   case ppc:
diff --git a/llvm/unittests/TargetParser/TripleTest.cpp 
b/llvm/unittests/TargetParser/TripleTest.cpp
index 17176837300024..576d974d3653ab 100644
--- a/llvm/unittests/TargetParser/TripleTest.cpp
+++ b/llvm/unittests/TargetParser/TripleTest.cpp
@@ -1787,10 +1787,12 @@ TEST(TripleTest, DefaultLongDoubleFormat) {
       LongDoubleFormat::IEEEdouble,
       Triple("thumbv7-unknown-linux-gnueabi").getDefaultLongDoubleFormat());
 
-  // SPARC V8 uses IEEE double for bare-metal and RTEMS targets. Linux,
+  // SPARC V8 uses IEEE double for bare-metal, NetBSD, and RTEMS targets. 
Linux,
   // Solaris, and other targets use IEEE quad. SPARC V9 always uses IEEE quad.
   EXPECT_EQ(LongDoubleFormat::IEEEdouble,
             Triple("sparc-unknown-unknown").getDefaultLongDoubleFormat());
+  EXPECT_EQ(LongDoubleFormat::IEEEdouble,
+            Triple("sparc-unknown-netbsd").getDefaultLongDoubleFormat());
   EXPECT_EQ(LongDoubleFormat::IEEEdouble,
             Triple("sparc-unknown-rtems").getDefaultLongDoubleFormat());
   EXPECT_EQ(LongDoubleFormat::IEEEquad,
@@ -1801,6 +1803,8 @@ TEST(TripleTest, DefaultLongDoubleFormat) {
             Triple("sparc-unknown-solaris").getDefaultLongDoubleFormat());
   EXPECT_EQ(LongDoubleFormat::IEEEquad,
             Triple("sparcv9-unknown-linux-gnu").getDefaultLongDoubleFormat());
+  EXPECT_EQ(LongDoubleFormat::IEEEquad,
+            Triple("sparcv9-unknown-netbsd").getDefaultLongDoubleFormat());
 
   // Targets that use IEEE quad, independent of the environment.
   EXPECT_EQ(LongDoubleFormat::IEEEquad,

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to