From patchwork Fri May 22 21:24:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Meissner X-Patchwork-Id: 475806 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A9DF2140E5D for ; Sat, 23 May 2015 07:24:30 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=jj7/J5PY; dkim-atps=neutral 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:subject:message-id:mime-version:content-type; q=dns; s= default; b=XIkRYk5hiDzAYA59JVmEcsbKVayb5r16PvQZX1VMAlgvnXXJEi1Ix xA44WA+L/ID2D2braB0m9rSyNe+yJDXkoj7bqDfE7N/VNJLFzOlhhanUTSKpgm7u 5rLyXpIR+ra76A6+z6m0DvxO1yBkpiVqx72C9TPBwX0mR3hVG2raFg= 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:subject:message-id:mime-version:content-type; s= default; bh=xGQKnZAQ7ljXBL5CfCtqtaKR5rk=; b=jj7/J5PY4mXXkzLItc6g 6aBMiFAew6wTAPc05RQBirs6G1sfGPbDmlOdgJVjTLf4LFfQ4wN/+bDShQoSj887 5K3n3Z+ma4sEGuQIXq4ts2jEdbp1Y/LRBhy5ys7yeC2kxmhBlci+I/3Hn1qIEwPi fr5V6EbtdHC6NZbwVyt/eRI= Received: (qmail 92445 invoked by alias); 22 May 2015 21:24:24 -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 92428 invoked by uid 89); 22 May 2015 21:24:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.7 required=5.0 tests=AWL, BAYES_50, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 X-HELO: e36.co.us.ibm.com Received: from e36.co.us.ibm.com (HELO e36.co.us.ibm.com) (32.97.110.154) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Fri, 22 May 2015 21:24:20 +0000 Received: from /spool/local by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 22 May 2015 15:24:18 -0600 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 22 May 2015 15:24:16 -0600 Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id 06CD11FF001E for ; Fri, 22 May 2015 15:15:26 -0600 (MDT) Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t4MLO3BJ43188446 for ; Fri, 22 May 2015 14:24:03 -0700 Received: from d03av03.boulder.ibm.com (localhost [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t4MLOFtE001068 for ; Fri, 22 May 2015 15:24:15 -0600 Received: from ibm-tiger.the-meissners.org (dhcp-9-32-77-111.usma.ibm.com [9.32.77.111]) by d03av03.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t4MLOF8w001026; Fri, 22 May 2015 15:24:15 -0600 Received: by ibm-tiger.the-meissners.org (Postfix, from userid 500) id 8746045F24; Fri, 22 May 2015 17:24:14 -0400 (EDT) Date: Fri, 22 May 2015 17:24:14 -0400 From: Michael Meissner To: gcc-patches@gcc.gnu.org, dje.gcc@gmail.com Subject: [PATCH], Add IEEE 128-bit floating point to PowerPC, patch #1 Message-ID: <20150522212414.GA25650@ibm-tiger.the-meissners.org> Mail-Followup-To: Michael Meissner , gcc-patches@gcc.gnu.org, dje.gcc@gmail.com MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15052221-0021-0000-0000-00000AC7F8D0 X-IsSubscribed: yes This patch is the first in a series of patches that will eventually add support for IEEE 128-bit floating point support to the PowerPC GCC compiler. At the current time, we do not plan to change the default for long double. I added a new type keyword (__float128) to get access to IEEE 128-bit floating point, and another (__ibm128) to get access to IBM extended double type. Until all of the GCC and LIBGCC patches have been committed, you will not be able to use IEEE 128-bit floating point, and -mfloat128-software will not be turned on by default. This patch adds the new modes (KFmode and IFmode) and the switches (-mfloat128-{none,software}). Due to the fact that TFmode in the PowerPC compiler either represents IEEE 128-bit floating point or the IBM extended double (double-double) format. For most PowerPC users, the default is to use IBM extended double for long double. Because TFmode can be either floating point format, I added new new modes: KFmode -- IEEE 128-bit floating point IFmode -- IBM extended double floating point If the default for TFmode is ibm extended double, the port will eventually use KFmode for IEEE 128-bit floating point. Likewise if the default for TFmode is IEEE 128-bit floating point, the port will use TFmode for IEEE 128-bit floating point, and IFmode for IBM extended double. I have bootstraped these patches on a power7 and compared them to the unpatched compiler. There were no changes when running make check. Are these patches ok to install in the trunk? 2015-05-22 Michael Meissner * config/rs6000/rs6000-modes.def (IFmode): Define IFmode to provide access to the IBM extended double floating point mode if long double is IEEE 128-bit floating point. (KFmode): Define KFmode to provide access to IEEE 128-bit floating point if long double is the IBM extended double type. * config/rs6000/rs6000.opt (-mfloat128-none): New switches to enable adding IEEE 128-bit floating point support. (-mfloat128-software): Likewise. (-mfloat128-sw): Likewise. * config/rs6000/rs6000.c (rs6000_hard_regno_mode_ok): Do not allow 128-bit floating point types to occupy any register if -mlong-double-64. Do not allow use of IFmode/KFmode unless -mfloat128-software is enabled. (rs6000_debug_reg_global): Add IEEE 128-bit floating point debug support. (rs6000_option_override_internal): Add -mfloat128-* support. (rs6000_init_builtins): Setup __ibm128 and __float128 type modes. * config/rs6000/rs6000.h (rs6000_builtin_type_index): Add ibm128 and float128 type nodes. (ieee128_float_type_node): Likewise. (ibm128_float_type_node): Likewise. Index: gcc/config/rs6000/rs6000-modes.def =================================================================== --- gcc/config/rs6000/rs6000-modes.def (revision 223458) +++ gcc/config/rs6000/rs6000-modes.def (working copy) @@ -18,6 +18,13 @@ along with GCC; see the file COPYING3. If not see . */ +/* IBM 128-bit floating point. IFmode and KFmode use the fractional float + support in order to declare 3 128-bit floating point types. */ +FRACTIONAL_FLOAT_MODE (IF, 106, 16, ibm_extended_format); + +/* Explicit IEEE 128-bit floating point. */ +FRACTIONAL_FLOAT_MODE (KF, 113, 16, ieee_quad_format); + /* 128-bit floating point. ABI_V4 uses IEEE quad, AIX/Darwin adjust this in rs6000_option_override_internal. */ FLOAT_MODE (TF, 16, ieee_quad_format); Index: gcc/config/rs6000/rs6000.opt =================================================================== --- gcc/config/rs6000/rs6000.opt (revision 223458) +++ gcc/config/rs6000/rs6000.opt (working copy) @@ -600,3 +600,19 @@ Allow float/double variables in upper re moptimize-swaps Target Undocumented Var(rs6000_optimize_swaps) Init(1) Save Analyze and remove doubleword swaps from VSX computations. + +mfloat128- +Target RejectNegative Joined Enum(float128_type_t) Var(TARGET_FLOAT128) Init(FLOAT128_UNSET) Save +-mfloat128-{software,none} - Specify how IEEE 128-bit floating point is used. + +Enum +Name(float128_type_t) Type(enum float128_type_t) + +EnumValue +Enum(float128_type_t) String(none) Value(FLOAT128_NONE) + +EnumValue +Enum(float128_type_t) String(software) Value(FLOAT128_SW) + +EnumValue +Enum(float128_type_t) String(sw) Value(FLOAT128_SW) Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 223458) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -1817,6 +1817,16 @@ rs6000_hard_regno_mode_ok (int regno, ma && IN_RANGE (last_regno, FIRST_GPR_REGNO, LAST_GPR_REGNO) && ((regno & 1) == 0)); + /* If we don't allow 128-bit binary floating point, disallow the 128-bit + types from going in any registers. Similarly if __float128 is not + supported, don't allow __float128/__ibm128 types. */ + if (!TARGET_LONG_DOUBLE_128 + && (mode == TFmode || mode == KFmode || mode == IFmode)) + return false; + + if (!TARGET_FLOAT128 && (mode == KFmode || mode == IFmode)) + return false; + /* VSX registers that overlap the FPR registers are larger than for non-VSX implementations. Don't allow an item to be split between a FP register and an Altivec register. Allow TImode in all VSX registers if the user @@ -2086,6 +2096,7 @@ rs6000_debug_reg_global (void) const char *trace_str; const char *abi_str; const char *cmodel_str; + const char *float128_str; struct cl_target_option cl_opts; /* Modes we want tieable information on. */ @@ -2099,6 +2110,8 @@ rs6000_debug_reg_global (void) SFmode, DFmode, TFmode, + IFmode, + KFmode, SDmode, DDmode, TDmode, @@ -2445,6 +2458,15 @@ rs6000_debug_reg_global (void) fprintf (stderr, DEBUG_FMT_S, "e500_double", (TARGET_E500_DOUBLE ? "true" : "false")); + switch (TARGET_FLOAT128) + { + case FLOAT128_NONE: float128_str = "none"; break; + case FLOAT128_SW: float128_str = "software"; break; + default: float128_str = "unknown"; break; + } + + fprintf (stderr, DEBUG_FMT_S, "float128", float128_str); + if (TARGET_LINK_STACK) fprintf (stderr, DEBUG_FMT_S, "link_stack", "true"); @@ -3703,6 +3725,13 @@ rs6000_option_override_internal (bool gl && optimize >= 3) rs6000_isa_flags |= OPTION_MASK_P8_FUSION_SIGN; + /* Set the appropriate IEEE 128-bit floating option. Do not enable float128 + support by default until the libgcc support is added. */ + if (TARGET_FLOAT128 == FLOAT128_UNSET) + TARGET_FLOAT128 = FLOAT128_NONE; + else if (TARGET_FLOAT128 == FLOAT128_SW && !TARGET_VSX) + error ("-mfloat128-software requires VSX support"); + if (TARGET_DEBUG_REG || TARGET_DEBUG_TARGET) rs6000_print_isa_options (stderr, 0, "after defaults", rs6000_isa_flags); @@ -14320,6 +14349,8 @@ rs6000_init_builtins (void) tree tdecl; tree ftype; machine_mode mode; + machine_mode ieee128_mode; + machine_mode ibm128_mode; if (TARGET_DEBUG_BUILTIN) fprintf (stderr, "rs6000_init_builtins%s%s%s%s\n", @@ -14387,6 +14418,32 @@ rs6000_init_builtins (void) dfloat128_type_internal_node = dfloat128_type_node; void_type_internal_node = void_type_node; + /* 128-bit floating point support. KFmode is IEEE 128-bit floating point. + IFmode is the IBM extended 128-bit format that is a pair of doubles. + TFmode will be either IEEE 128-bit floating point or the IBM double-double + format that uses a pair of doubles, depending on the switches and + defaults. */ + if (TARGET_IEEEQUAD) + { + ieee128_mode = TFmode; + ibm128_mode = IFmode; + } + else + { + ieee128_mode = KFmode; + ibm128_mode = TFmode; + } + + ieee128_float_type_node = make_node (REAL_TYPE); + TYPE_PRECISION (ieee128_float_type_node) = 128; + layout_type (ieee128_float_type_node); + SET_TYPE_MODE (ieee128_float_type_node, ieee128_mode); + + ibm128_float_type_node = make_node (REAL_TYPE); + TYPE_PRECISION (ibm128_float_type_node) = 128; + layout_type (ibm128_float_type_node); + SET_TYPE_MODE (ibm128_float_type_node, ibm128_mode); + /* Initialize the modes for builtin_function_type, mapping a machine mode to tree type node. */ builtin_mode_to_type[QImode][0] = integer_type_node; @@ -14399,6 +14456,8 @@ rs6000_init_builtins (void) builtin_mode_to_type[TImode][1] = unsigned_intTI_type_node; builtin_mode_to_type[SFmode][0] = float_type_node; builtin_mode_to_type[DFmode][0] = double_type_node; + builtin_mode_to_type[IFmode][0] = ibm128_float_type_node; + builtin_mode_to_type[KFmode][0] = ieee128_float_type_node; builtin_mode_to_type[TFmode][0] = long_double_type_node; builtin_mode_to_type[DDmode][0] = dfloat64_type_node; builtin_mode_to_type[TDmode][0] = dfloat128_type_node; Index: gcc/config/rs6000/rs6000.h =================================================================== --- gcc/config/rs6000/rs6000.h (revision 223458) +++ gcc/config/rs6000/rs6000.h (working copy) @@ -2715,6 +2715,8 @@ enum rs6000_builtin_type_index RS6000_BTI_dfloat64, /* dfloat64_type_node */ RS6000_BTI_dfloat128, /* dfloat128_type_node */ RS6000_BTI_void, /* void_type_node */ + RS6000_BTI_ieee128_float, /* ieee 128-bit floating point */ + RS6000_BTI_ibm128_float, /* IBM 128-bit floating point */ RS6000_BTI_MAX }; @@ -2769,6 +2771,8 @@ enum rs6000_builtin_type_index #define dfloat64_type_internal_node (rs6000_builtin_types[RS6000_BTI_dfloat64]) #define dfloat128_type_internal_node (rs6000_builtin_types[RS6000_BTI_dfloat128]) #define void_type_internal_node (rs6000_builtin_types[RS6000_BTI_void]) +#define ieee128_float_type_node (rs6000_builtin_types[RS6000_BTI_ieee128_float]) +#define ibm128_float_type_node (rs6000_builtin_types[RS6000_BTI_ibm128_float]) extern GTY(()) tree rs6000_builtin_types[RS6000_BTI_MAX]; extern GTY(()) tree rs6000_builtin_decls[RS6000_BUILTIN_COUNT]; Index: gcc/config/rs6000/rs6000-opts.h =================================================================== --- gcc/config/rs6000/rs6000-opts.h (revision 223458) +++ gcc/config/rs6000/rs6000-opts.h (working copy) @@ -79,6 +79,15 @@ enum fpu_type_t FPU_DF_FULL /* Full Double Single Precision FPU */ }; + +/* Float128 support. */ +enum float128_type_t +{ + FLOAT128_UNSET = -1, /* Initial value. */ + FLOAT128_NONE, /* No __float128 support. */ + FLOAT128_SW /* software __float128 support. */ +}; + /* Types of costly dependences. */ enum rs6000_dependence_cost {