From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14314 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Samuel Holland Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH] powerpc64: add IEEE binary128 long double support Date: Sun, 30 Jun 2019 14:38:24 -0500 Message-ID: <20190630193825.65174-1-samuel@sholland.org> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="129587"; mail-complaints-to="usenet@blaine.gmane.org" Cc: Samuel Holland To: musl@lists.openwall.com Original-X-From: musl-return-14330-gllmg-musl=m.gmane.org@lists.openwall.com Sun Jun 30 21:38:47 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1hhfew-000Xau-Qz for gllmg-musl@m.gmane.org; Sun, 30 Jun 2019 21:38:47 +0200 Original-Received: (qmail 22249 invoked by uid 550); 30 Jun 2019 19:38:43 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 22209 invoked from network); 30 Jun 2019 19:38:42 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm3; bh=Q7fmqCCvoufHjqMZZHAexVK3Np 0SLhjEvqEIH1wbpBU=; b=GJ8FamT2rOe3+RcfIgFIRX5hSKF/v5bRCJG7eGG+l/ gjnsFNvtBSZrsmeF0cdIKCdW023eI8/V5m5WBdlChZiFg5oT17bSSp1T4rBJJ2+Y oFbloONVZzy7eHPHLRLYC45bWUk8qavT1sKlr5g2Sa88Ty7UT/mjdGCu7u+mY2sC E913NLPHKjK3r0YY4KMor+3Jm/SWKxwqHigq6T51gGRksGF6XXwnWZPbVLWJJa3s r0Y5Nih3ouQzpm5LmoeRkhfSMNPb8PHEuubyRObyB8MJpT8LD9htnzdsqydn/lqW NC8PKa3jaIu1cdgVJuqQjrAVs6uGfupfH99Wp4VI3TIQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=Q7fmqCCvoufHjqMZZ HAexVK3Np0SLhjEvqEIH1wbpBU=; b=KVAjnHAX8yNm5n1Jc0DKVbWUqpfrqbOdZ zUHVRbfZCuZupTjWkMFl3jH1fRDrSlfhxrgWcl2+/2fodPNbtNxEqtdpKUPqJNT1 UgXrIimNZ+h1urScQEmKs5HOjmjMCMiKmuiEXtikzTCYIFc6EmVo7km7vXG876ij YddmyFqeM9iXUaQ0aIeCHJ0gq8bGd96oVsBVuU/5jbcSN8KpYlm/wtsujOG4c7j2 QZvzI9oNdEFyIbcRF7lXdAVJxZ9Ed0ulk9l1eaGb4VJ5QP91NY5TIpcm8+2Bi454 qKMDDpoLOxigXuBS80mGQzgzh/LERiSZ+PvHydrsmgPdD9STxtMZA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrvdeggddufeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgggfestdekredtre dttdenucfhrhhomhepufgrmhhuvghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhho lhhlrghnugdrohhrgheqnecukfhppeejtddrudefhedrudegkedrudehudenucfrrghrrg hmpehmrghilhhfrhhomhepshgrmhhuvghlsehshhholhhlrghnugdrohhrghenucevlhhu shhtvghrufhiiigvpedt X-ME-Proxy: X-Mailer: git-send-email 2.21.0 Xref: news.gmane.org gmane.linux.lib.musl.general:14314 Archived-At: This is added under a new "ieee128" sub-architecture. The 128-bit scalar floating-point ABI uses the Altivec registers for parameter passing, but no special instructions; thus, the ABI can be used with any CPU that supports Altivec. However, hardware instructions to operate on a 128-bit scalar are only available starting with POWER9. Any older CPU will use software fp. With "-mlong-double-128 -mabi=ieeelongdouble", gcc defines both __LONG_DOUBLE_128__ and __LONG_DOUBLE_IEEE128__. clang, when patched with "LongDoubleFormat = &llvm::APFloat::IEEEquad();", defines __LONG_DOUBLE_128__ but not __LONG_DOUBLE_IEEE128__, so we use __LDBL_MANT_DIG__ to distinguish IEEE binary128 from IBM double-double. --- So far the suggested ABI names have been "ld128", "ieee128", "ieeequad", and "f128". "ieee128" is the shortest while still being unambiguous about which 128-bit FP format is being used. Ideally we could use __LONG_DOUBLE_IEEE128__ as the preprocessor condition, but it's not provided by clang. Since we have to check __LDBL_MANT_DIG__ anyway, is checking __LONG_DOUBLE_128__ redundant? --- INSTALL | 4 ++-- arch/powerpc64/bits/float.h | 21 +++++++++++++++++++++ arch/powerpc64/reloc.h | 8 +++++++- configure | 1 + 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/INSTALL b/INSTALL index a2a142bf..ce08bb17 100644 --- a/INSTALL +++ b/INSTALL @@ -76,8 +76,8 @@ and ABI combinations: * PowerPC64 * Both little and big endian variants are supported - * Compiler toolchain must provide 64-bit long double, not IBM - double-double or IEEE quad + * Compiler toolchain must provide 64-bit or 128-bit IEEE long + double, not IBM double-double * Compiler toolchain must use the new (ELFv2) ABI regardless of whether it is for little or big endian diff --git a/arch/powerpc64/bits/float.h b/arch/powerpc64/bits/float.h index c4a655e7..7d282f90 100644 --- a/arch/powerpc64/bits/float.h +++ b/arch/powerpc64/bits/float.h @@ -1,5 +1,24 @@ #define FLT_EVAL_METHOD 0 +#if __LONG_DOUBLE_128__ && __LDBL_MANT_DIG__ == 113 + +#define LDBL_TRUE_MIN 6.47517511943802511092443895822764655e-4966L +#define LDBL_MIN 3.36210314311209350626267781732175260e-4932L +#define LDBL_MAX 1.18973149535723176508575932662800702e+4932L +#define LDBL_EPSILON 1.92592994438723585305597794258492732e-34L + +#define LDBL_MANT_DIG 113 +#define LDBL_MIN_EXP (-16381) +#define LDBL_MAX_EXP 16384 + +#define LDBL_DIG 33 +#define LDBL_MIN_10_EXP (-4931) +#define LDBL_MAX_10_EXP 4932 + +#define DECIMAL_DIG 36 + +#else + #define LDBL_TRUE_MIN 4.94065645841246544177e-324L #define LDBL_MIN 2.22507385850720138309e-308L #define LDBL_MAX 1.79769313486231570815e+308L @@ -14,3 +33,5 @@ #define LDBL_MAX_10_EXP 308 #define DECIMAL_DIG 17 + +#endif diff --git a/arch/powerpc64/reloc.h b/arch/powerpc64/reloc.h index faf70acd..52daecb2 100644 --- a/arch/powerpc64/reloc.h +++ b/arch/powerpc64/reloc.h @@ -6,7 +6,13 @@ #define ENDIAN_SUFFIX "" #endif -#define LDSO_ARCH "powerpc64" ENDIAN_SUFFIX +#if __LONG_DOUBLE_128__ && __LDBL_MANT_DIG__ == 113 +#define FP_SUFFIX "-ieee128" +#else +#define FP_SUFFIX "" +#endif + +#define LDSO_ARCH "powerpc64" ENDIAN_SUFFIX FP_SUFFIX #define TPOFF_K (-0x7000) diff --git a/configure b/configure index 60e0b1fc..6d196570 100755 --- a/configure +++ b/configure @@ -652,6 +652,7 @@ test "$ARCH" = "microblaze" && trycppif __MICROBLAZEEL__ "$t" \ if test "$ARCH" = "powerpc64" ; then trycppif "_CALL_ELF == 2" "$t" || fail "$0: error: unsupported powerpc64 ABI" trycppif __LITTLE_ENDIAN__ "$t" && SUBARCH=${SUBARCH}le +trycppif "__LONG_DOUBLE_128__ && __LDBL_MANT_DIG__ == 113" "$t" && SUBARCH=${SUBARCH}-ieee128 trycppif _SOFT_FLOAT "$t" && fail "$0: error: soft-float not supported on powerpc64" fi -- 2.21.0