[clang] [Sparc][clang] Use 64-bit long double on bare-metal targets (PR #222304)

Folkert de Vries via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 13 08:21:14 PDT 2026


================
@@ -167,11 +167,19 @@ class LLVM_LIBRARY_VISIBILITY SparcV8TargetInfo : public SparcTargetInfo {
       break;
     }
 
-    // The SPARCv8 System V ABI has long double 128-bits in size, but 64-bit
-    // aligned.
-    LongDoubleWidth = 128;
-    LongDoubleAlign = 64;
-    LongDoubleFormat = &llvm::APFloat::IEEEquad();
+    // Bare-metal and RTEMS targets default to 64-bit long double, matching
+    // GCC. Other targets use 128-bit per the SPARCv8 System V ABI, with
+    // 64-bit alignment.
+    if (getTriple().getOS() == llvm::Triple::UnknownOS ||
+        getTriple().getOS() == llvm::Triple::RTEMS) {
+      LongDoubleWidth = 64;
+      LongDoubleAlign = 64;
+      LongDoubleFormat = &llvm::APFloat::IEEEdouble();
+    } else {
+      LongDoubleWidth = 128;
+      LongDoubleAlign = 64;
+      LongDoubleFormat = &llvm::APFloat::IEEEquad();
+    }
----------------
folkertdev wrote:

I think this should be configured here instead

https://github.com/llvm/llvm-project/blob/f6b3f9399e98ef8b79388176e94c910d67669e1f/llvm/lib/TargetParser/Triple.cpp#L2541-L2597

https://github.com/llvm/llvm-project/pull/222304


More information about the cfe-commits mailing list