From patchwork Tue Aug 20 02:35:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 268349 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 5D27D2C0132 for ; Tue, 20 Aug 2013 12:36:11 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=oSRh7OHjwsrFbuc+f jsqfWFXDMQd0sLcgZoGXTBUHcZ73gH6bxlJnTSLP81tkW7h2DzfbVXNHJmFpBgAv 9xH+NKH51xmehiWTxqJyJtRv4cOwRPR8oikfg+S24U3+3d1NcWGES2CkYzlwn0Ht xOKGTjBwZ/oVH3oinstIFlKoRE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=nIT50umc5e1pg38WXV90khU iJIs=; b=hXg1Bt+jeSxQZUy+mXadq5CYUdDA5zkLOSWYADmPKjeokF1A4+8htvl uQYNnac3G3ZcCQVdvUOnc7ga4JQQz9xVD9K51VKFuYH6OTvE2kNyy4TY9qhRo7D9 +lHvAxbBi0a3fJ2CYhmx0FlWZTHs1TabQ23skHyd+VZFIDQZ7pHs= Received: (qmail 21110 invoked by alias); 20 Aug 2013 02:36:04 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 21094 invoked by uid 89); 20 Aug 2013 02:36:03 -0000 X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, SPF_PASS autolearn=ham version=3.3.2 Received: from mail-ie0-f169.google.com (HELO mail-ie0-f169.google.com) (209.85.223.169) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 20 Aug 2013 02:36:02 +0000 Received: by mail-ie0-f169.google.com with SMTP id 10so951357ied.28 for ; Mon, 19 Aug 2013 19:36:01 -0700 (PDT) X-Received: by 10.43.66.11 with SMTP id xo11mr1041116icb.21.1376966161007; Mon, 19 Aug 2013 19:36:01 -0700 (PDT) Received: from bubble.grove.modra.org ([101.166.26.37]) by mx.google.com with ESMTPSA id cl4sm13510481igc.1.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 19 Aug 2013 19:36:00 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 35910EA00C7; Tue, 20 Aug 2013 12:05:55 +0930 (CST) Date: Tue, 20 Aug 2013 12:05:55 +0930 From: Alan Modra To: gcc-patches@gcc.gnu.org Cc: Tom Tromey Subject: [libiberty] IBM long double little-endian Message-ID: <20130820023555.GB3430@bubble.grove.modra.org> Mail-Followup-To: gcc-patches@gcc.gnu.org, Tom Tromey References: <20130819003948.GM4024@bubble.grove.modra.org> <87d2p9llsl.fsf@fleche.redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87d2p9llsl.fsf@fleche.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) On Mon, Aug 19, 2013 at 09:53:14AM -0600, Tom Tromey wrote: > >>>>> "Alan" == Alan Modra writes: > > Alan> This teaches gdb about little-endian IBM long double. Like big-endian > Alan> IBM long double, the little-endian version is an array of two doubles. > > Alan> The patch also deletes some unused code I found in doublest.c. OK to > Alan> apply? > > The gdb bits look fine to me, but the libiberty bits will have to be > sent to the GCC patch list for approval. Repost to gcc. As far as I know, the libiberty files I'm touching below are only used by gdb. OK to apply? include/ * floatformat.h (floatformat_ibm_long_double): Delete. (floatformat_ibm_long_double_big): Declare. (floatformat_ibm_long_double_little): Declare. libiberty/ * floatformat.c (floatformat_ibm_long_double): Rename to.. (floatformat_ibm_long_double_big): ..this. (floatformat_ibm_long_double_little): New. gdb/ * doublest.c (convert_floatformat_to_doublest): Use fmt->split_half for IBM long double nan and inf. (floatformat_is_negative, floatformat_classify, floatformat_mantissa): Similarly. (floatformat_ieee_single, floatformat_ieee_double, floatformat_ieee_quad, floatformat_arm_ext, floatformat_ia64_spill): Delete unused vars. (_initialize_doublest): Delete unused function. * gdbtypes.c (floatformats_ibm_long_double): Use new big- and little-endian variants of floatformat_ibm_long_double. Index: include/floatformat.h =================================================================== RCS file: /cvs/src/src/include/floatformat.h,v retrieving revision 1.16 diff -u -p -r1.16 floatformat.h --- include/floatformat.h 3 Jan 2011 21:05:50 -0000 1.16 +++ include/floatformat.h 16 Aug 2013 06:46:24 -0000 @@ -128,7 +128,8 @@ extern const struct floatformat floatfor extern const struct floatformat floatformat_ia64_quad_big; extern const struct floatformat floatformat_ia64_quad_little; /* IBM long double (double+double). */ -extern const struct floatformat floatformat_ibm_long_double; +extern const struct floatformat floatformat_ibm_long_double_big; +extern const struct floatformat floatformat_ibm_long_double_little; /* Convert from FMT to a double. FROM is the address of the extended float. Index: libiberty/floatformat.c =================================================================== RCS file: /cvs/src/src/libiberty/floatformat.c,v retrieving revision 1.28 diff -u -p -r1.28 floatformat.c --- libiberty/floatformat.c 17 Aug 2012 21:59:31 -0000 1.28 +++ libiberty/floatformat.c 16 Aug 2013 06:46:25 -0000 @@ -371,14 +371,23 @@ floatformat_ibm_long_double_is_valid (co } } -const struct floatformat floatformat_ibm_long_double = +const struct floatformat floatformat_ibm_long_double_big = { floatformat_big, 128, 0, 1, 11, 1023, 2047, 12, 52, floatformat_intbit_no, - "floatformat_ibm_long_double", + "floatformat_ibm_long_double_big", floatformat_ibm_long_double_is_valid, &floatformat_ieee_double_big }; + +const struct floatformat floatformat_ibm_long_double_little = +{ + floatformat_little, 128, 0, 1, 11, 1023, 2047, 12, 52, + floatformat_intbit_no, + "floatformat_ibm_long_double_little", + floatformat_ibm_long_double_is_valid, + &floatformat_ieee_double_little +}; #ifndef min Index: gdb/doublest.c =================================================================== RCS file: /cvs/src/src/gdb/doublest.c,v retrieving revision 1.54 diff -u -p -r1.54 doublest.c --- gdb/doublest.c 21 Jun 2013 16:24:14 -0000 1.54 +++ gdb/doublest.c 16 Aug 2013 06:46:22 -0000 @@ -190,7 +190,8 @@ convert_floatformat_to_doublest (const s { double dto; - floatformat_to_double (fmt, from, &dto); + floatformat_to_double (fmt->split_half ? fmt->split_half : fmt, + from, &dto); *to = (DOUBLEST) dto; return; } @@ -514,6 +515,11 @@ floatformat_is_negative (const struct fl gdb_assert (fmt->totalsize <= FLOATFORMAT_LARGEST_BYTES * FLOATFORMAT_CHAR_BIT); + /* An IBM long double (a two element array of double) always takes the + sign of the first double. */ + if (fmt->split_half) + fmt = fmt->split_half; + order = floatformat_normalize_byteorder (fmt, uval, newfrom); if (order != fmt->byteorder) @@ -540,6 +546,13 @@ floatformat_classify (const struct float gdb_assert (fmt->totalsize <= FLOATFORMAT_LARGEST_BYTES * FLOATFORMAT_CHAR_BIT); + /* An IBM long double (a two element array of double) can be classified + by looking at the first double. inf and nan are specified as + ignoring the second double. zero and subnormal will always have + the second double 0.0 if the long double is correctly rounded. */ + if (fmt->split_half) + fmt = fmt->split_half; + order = floatformat_normalize_byteorder (fmt, uval, newfrom); if (order != fmt->byteorder) @@ -622,6 +635,16 @@ floatformat_mantissa (const struct float gdb_assert (fmt->totalsize <= FLOATFORMAT_LARGEST_BYTES * FLOATFORMAT_CHAR_BIT); + /* For IBM long double (a two element array of double), return the + mantissa of the first double. The problem with returning the + actual mantissa from both doubles is that there can be an + arbitrary number of implied 0's or 1's between the mantissas + of the first and second double. In any case, this function + is only used for dumping out nans, and a nan is specified to + ignore the value in the second double. */ + if (fmt->split_half) + fmt = fmt->split_half; + order = floatformat_normalize_byteorder (fmt, uval, newfrom); if (order != fmt->byteorder) @@ -879,27 +902,3 @@ convert_typed_floating (const void *from floatformat_from_doublest (to_fmt, &d, to); } } - -const struct floatformat *floatformat_ieee_single[BFD_ENDIAN_UNKNOWN]; -const struct floatformat *floatformat_ieee_double[BFD_ENDIAN_UNKNOWN]; -const struct floatformat *floatformat_ieee_quad[BFD_ENDIAN_UNKNOWN]; -const struct floatformat *floatformat_arm_ext[BFD_ENDIAN_UNKNOWN]; -const struct floatformat *floatformat_ia64_spill[BFD_ENDIAN_UNKNOWN]; - -extern void _initialize_doublest (void); - -extern void -_initialize_doublest (void) -{ - floatformat_ieee_single[BFD_ENDIAN_LITTLE] = &floatformat_ieee_single_little; - floatformat_ieee_single[BFD_ENDIAN_BIG] = &floatformat_ieee_single_big; - floatformat_ieee_double[BFD_ENDIAN_LITTLE] = &floatformat_ieee_double_little; - floatformat_ieee_double[BFD_ENDIAN_BIG] = &floatformat_ieee_double_big; - floatformat_arm_ext[BFD_ENDIAN_LITTLE] - = &floatformat_arm_ext_littlebyte_bigword; - floatformat_arm_ext[BFD_ENDIAN_BIG] = &floatformat_arm_ext_big; - floatformat_ia64_spill[BFD_ENDIAN_LITTLE] = &floatformat_ia64_spill_little; - floatformat_ia64_spill[BFD_ENDIAN_BIG] = &floatformat_ia64_spill_big; - floatformat_ieee_quad[BFD_ENDIAN_LITTLE] = &floatformat_ia64_quad_little; - floatformat_ieee_quad[BFD_ENDIAN_BIG] = &floatformat_ia64_quad_big; -} Index: gdb/gdbtypes.c =================================================================== RCS file: /cvs/src/src/gdb/gdbtypes.c,v retrieving revision 1.251 diff -u -p -r1.251 gdbtypes.c --- gdb/gdbtypes.c 15 Apr 2013 17:30:36 -0000 1.251 +++ gdb/gdbtypes.c 16 Aug 2013 06:46:22 -0000 @@ -108,8 +108,8 @@ const struct floatformat *floatformats_v &floatformat_vax_d }; const struct floatformat *floatformats_ibm_long_double[BFD_ENDIAN_UNKNOWN] = { - &floatformat_ibm_long_double, - &floatformat_ibm_long_double + &floatformat_ibm_long_double_big, + &floatformat_ibm_long_double_little }; /* Should opaque types be resolved? */