From patchwork Wed Nov 23 14:45:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 698348 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 3tP4ss0nxWz9tkH for ; Thu, 24 Nov 2016 01:46:40 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="XeqYWgE7"; 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:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=XpTF/38UCF+ZeHsT90GqkQfeeo+J2EuFFZWFSjhRzEki7SwFqRcGR Qk45dnmJ3bDA80F4l71r+fkY9fpQnKEYITrszc4153PaMg1OubRNUG++/x3Ax26U DEPareOmD7AJOB8IGadTr6HrkrXU1E/2Q9Z4O+HwD1pX/jcDFi3Tfo= 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:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=lJjN5l7aWWED5TFBJ54q3EuTZqM=; b=XeqYWgE7Lq9RCJR4GBaX MGort/P26G2Jqnzg3c5pqAoQtWC/hrnvA98OjRhkX/4AvQbK7kyJm/0MomfMa8RW tFjLKNhwsxDj8D4jElRfYYfoJwC17HeldFGU/uT91Mj9l/BfgGvosea2tStjkCFv 1NLVSvQv1k25zX992YCXP3g= Received: (qmail 17410 invoked by alias); 23 Nov 2016 14:46:12 -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 17294 invoked by uid 89); 23 Nov 2016 14:46:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=richard.sandiford@arm.com, SVE, sve, richardsandifordarmcom X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 23 Nov 2016 14:46:01 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BE84513D5; Wed, 23 Nov 2016 06:45:59 -0800 (PST) Received: from localhost (e105548-lin.manchester.arm.com [10.45.32.67]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 693C33F220 for ; Wed, 23 Nov 2016 06:45:59 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: Set mode of decimal floats before calling layout_type Date: Wed, 23 Nov 2016 14:45:57 +0000 Message-ID: <87lgwap84a.fsf@e105548-lin.cambridge.arm.com> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Previously decimal floating-point types were created and laid out as binary floating-point types, then the caller changed the mode to a decimal mode later. The problem with that approach is that not all targets support an equivalent binary floating-point mode. When they didn't, we would give the type BLKmode and lay it out as a zero-sized type. This probably had no effect in practice. If a target doesn't support a binary mode then it's unlikely to support the decimal equivalent either. However, with the stricter mode checking added by later patches, we would assert if a scalar floating- point type didn't have a scalar floating-point mode. Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64-linux-gnu. OK to install? Thanks, Richard [ This patch is part of the SVE series posted here: https://gcc.gnu.org/ml/gcc/2016-11/msg00030.html ] gcc/ 2016-11-16 Richard Sandiford Alan Hayward David Sherwood * stor-layout.c (layout_type): Allow the caller to set the mode of a float type. Only choose one here if the mode is still VOIDmode. * tree.c (build_common_tree_nodes): Set the type mode of decimal floats before calling layout_type. * config/rs6000/rs6000.c (rs6000_init_builtins): Likewise. diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index fa62e2e..a789ea1 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -16793,8 +16793,8 @@ rs6000_init_builtins (void) { 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, IFmode); + layout_type (ibm128_float_type_node); lang_hooks.types.register_builtin_type (ibm128_float_type_node, "__ibm128"); @@ -16813,8 +16813,8 @@ rs6000_init_builtins (void) { ieee128_float_type_node = make_node (REAL_TYPE); TYPE_PRECISION (ibm128_float_type_node) = 128; - layout_type (ieee128_float_type_node); SET_TYPE_MODE (ieee128_float_type_node, KFmode); + layout_type (ieee128_float_type_node); /* If we are not exporting the __float128/_Float128 keywords, we need a keyword to get the types created. Use __ieee128 as the dummy diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 9f8efcb..5a4bcf1 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -2135,8 +2135,11 @@ layout_type (tree type) break; case REAL_TYPE: - SET_TYPE_MODE (type, - mode_for_size (TYPE_PRECISION (type), MODE_FLOAT, 0)); + /* Allow the caller to choose the type mode, which is how decimal + floats are distinguished from binary ones. */ + if (TYPE_MODE (type) == VOIDmode) + SET_TYPE_MODE (type, + mode_for_size (TYPE_PRECISION (type), MODE_FLOAT, 0)); TYPE_SIZE (type) = bitsize_int (GET_MODE_BITSIZE (TYPE_MODE (type))); TYPE_SIZE_UNIT (type) = size_int (GET_MODE_SIZE (TYPE_MODE (type))); break; diff --git a/gcc/tree.c b/gcc/tree.c index a4c5b1b..f60f331 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -10385,20 +10385,20 @@ build_common_tree_nodes (bool signed_char) /* Decimal float types. */ dfloat32_type_node = make_node (REAL_TYPE); TYPE_PRECISION (dfloat32_type_node) = DECIMAL32_TYPE_SIZE; - layout_type (dfloat32_type_node); SET_TYPE_MODE (dfloat32_type_node, SDmode); + layout_type (dfloat32_type_node); dfloat32_ptr_type_node = build_pointer_type (dfloat32_type_node); dfloat64_type_node = make_node (REAL_TYPE); TYPE_PRECISION (dfloat64_type_node) = DECIMAL64_TYPE_SIZE; - layout_type (dfloat64_type_node); SET_TYPE_MODE (dfloat64_type_node, DDmode); + layout_type (dfloat64_type_node); dfloat64_ptr_type_node = build_pointer_type (dfloat64_type_node); dfloat128_type_node = make_node (REAL_TYPE); TYPE_PRECISION (dfloat128_type_node) = DECIMAL128_TYPE_SIZE; - layout_type (dfloat128_type_node); SET_TYPE_MODE (dfloat128_type_node, TDmode); + layout_type (dfloat128_type_node); dfloat128_ptr_type_node = build_pointer_type (dfloat128_type_node); complex_integer_type_node = build_complex_type (integer_type_node, true);