From patchwork Thu Jul 13 08:42:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107597 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1926546qge; Thu, 13 Jul 2017 01:42:44 -0700 (PDT) X-Received: by 10.98.163.88 with SMTP id s85mr59945581pfe.217.1499935364256; Thu, 13 Jul 2017 01:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935364; cv=none; d=google.com; s=arc-20160816; b=g/QiHQd+3C3mmqKH5IFa+S4DoE3AO8uckXgGJJ5EmDJaDHmP2RP5AAz/Jf84gUC3XV zPx9jmEC825CIAwTGt3K9xwO3j3ThE74T2pLYo/8HXb/9lSoa93NC62MsICGkGxX1YUG 8LDrRR33lXPzWbaau5p0pYJndd9WNitNNlsojzds84+a5t57nweYVjnJbMFrJDNnbsiD +P3mnXeIYxWx4lnGMmPO0BvsO0mvwvm6eM1DlcuNM0P5L/bvtHCyaqVxjdIYJ1Exoz43 X/8m7Dvx4oiaUF07ezuSWyQkJzZN/U1XZWtOd3Tu7OK5UHzBLsXDTW05PejZQrU7e86h GwDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:mail-followup-to:to:from:delivered-to:sender:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=/mxNGxKRxj3mIWRX0CX59mVVkoKopdn1vMSCsORfizE=; b=IkA4Xu89UKuBZzd91BnPTmm+qrjIRXIfPlGSOzg346LJvby9NSmFV6cJMr/yzq43zF uMQinb96XmstgjIaqjKmq3mZCFvaTSl9/M9mIz0Dj/Iu2XmqqQX+l90749eMrINuu3I8 3LYqIUJPMxtNNtFnLNBkx5rseNESzjs8NnpYAIffwWS4TyR0PVwFGLrdz5WUvIjo3ona SbsHcjbxembnkuxiz+R1l60MKgQnFS6DWNvDeE0Hwbmz8+1uGnEUf9fcgXZRCLU3RpW9 CTTSI73cDKH3x+axA6DaSx0Rm8fiZUoNuVjpMqRxrI+qQJB8PQskvxtU+K41S5SMvwWl 7v4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=pY75F5wd; spf=pass (google.com: domain of gcc-patches-return-458001-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458001-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id x187si3891454pgx.147.2017.07.13.01.42.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:42:44 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458001-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=pY75F5wd; spf=pass (google.com: domain of gcc-patches-return-458001-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458001-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=default; b=JcunSsNjJVquM/qsfYLht/1urmSBi lycuw71+KhU+gSgAWlRUYWTsZaauZk9h/TeG3py96T52DHXqhzaGBlChG+wzj21i 2cMR1odIyIi1tYjzMkyyBbeXDlZNbs9qAVb9+HWPXHUPbCLTCI+buGCF+IBxbWtt TwkU4B2SiAf9wU= 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:references:date:in-reply-to:message-id:mime-version :content-type; s=default; bh=xwn3423t1wB7woPmc4rDXxdh4oA=; b=pY7 5F5wd3yYKxUUL5tzNyKWn6U7yvO1DFzH/lRPjFzLAwnXNhuoyzQ8MbjGOW6ZDwgF QF4hAxzqfPu0OA1EloYy3ERi+MkCyxegwHc4s35nAKKSty/5fOD9Hm2VeHWoFo97 Rlbinh0Dn50VlhgGjYFuwRRCj1SVQVsx10aduLMc= Received: (qmail 112258 invoked by alias); 13 Jul 2017 08:42:26 -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 111170 invoked by uid 89); 13 Jul 2017 08:42:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f44.google.com Received: from mail-wm0-f44.google.com (HELO mail-wm0-f44.google.com) (74.125.82.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:42:24 +0000 Received: by mail-wm0-f44.google.com with SMTP id i127so18003598wma.0 for ; Thu, 13 Jul 2017 01:42:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:mail-followup-to:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=/mxNGxKRxj3mIWRX0CX59mVVkoKopdn1vMSCsORfizE=; b=OwACebKFxnzW7T7f8xtGBRIty3DqEDB//Oop+X49guRq12h8BKuZX54ltpfSseefDx I+BJpuoX+h3mn5ehu5RnaTk5Nm9ixrEnoTmfIrbkpKgMoUwlyQLNgaMeODz0+pIpA2us SZ7eRBsywuMi1w1cFZRvA4FtR/PexA72FQfxzdONCPPPc6EdWJekAdieNtnTJ4ljz4VA kKn1GlA6DWoJPgKp0IkB7iGWCF7NtEfsUwqf775sOlMJm8TOFJxzsg65K9+e+RkJw/fx JbMxjJx6ECFtgDv4Tyoj8IUSqP019qwoKlI46BhLyOeZGBL0AxjPSQrHIaOLaFRFZLc3 2t3g== X-Gm-Message-State: AIVw110/3gM5LV+Hvod+3crNM+0b8CZuefFD6NmHG7/rs/7nPIY+rhp2 i3sZy2HZZ7S6BAHroIPeRA== X-Received: by 10.28.68.132 with SMTP id r126mr1077111wma.118.1499935342604; Thu, 13 Jul 2017 01:42:22 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id q70sm4570198wrb.3.2017.07.13.01.42.21 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:42:21 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [11/77] Add a float_mode_for_size helper function References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:42:20 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87tw2glocz.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This provides a type-safe way to ask for a float mode and get it as a scalar_float_mode. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * coretypes.h (opt_scalar_float_mode): New typedef. * machmode.h (float_mode_for_size): New function. * emit-rtl.c (double_mode): Delete. (init_emit_once): Use float_mode_for_size. * stor-layout.c (layout_type): Likewise. * gdbhooks.py (build_pretty_printer): Handle opt_scalar_float_mode. Index: gcc/coretypes.h =================================================================== --- gcc/coretypes.h 2017-07-13 09:18:23.795186280 +0100 +++ gcc/coretypes.h 2017-07-13 09:18:25.915974717 +0100 @@ -57,6 +57,7 @@ typedef struct rtx_def *rtx; typedef const struct rtx_def *const_rtx; class scalar_float_mode; template class opt_mode; +typedef opt_mode opt_scalar_float_mode; /* Subclasses of rtx_def, using indentation to show the class hierarchy, along with the relevant invariant. Index: gcc/machmode.h =================================================================== --- gcc/machmode.h 2017-07-13 09:18:23.798185961 +0100 +++ gcc/machmode.h 2017-07-13 09:18:25.916974620 +0100 @@ -521,7 +521,16 @@ #define GET_MODE_COMPLEX_MODE(MODE) ((ma extern machine_mode mode_for_size (unsigned int, enum mode_class, int); -/* Similar, but find the smallest mode for a given width. */ +/* Return the machine mode to use for a MODE_FLOAT of SIZE bits, if one + exists. */ + +inline opt_scalar_float_mode +float_mode_for_size (unsigned int size) +{ + return dyn_cast (mode_for_size (size, MODE_FLOAT, 0)); +} + +/* Similar to mode_for_size, but find the smallest mode for a given width. */ extern machine_mode smallest_mode_for_size (unsigned int, enum mode_class); Index: gcc/emit-rtl.c =================================================================== --- gcc/emit-rtl.c 2017-07-13 09:18:21.530429366 +0100 +++ gcc/emit-rtl.c 2017-07-13 09:18:25.916974620 +0100 @@ -71,7 +71,6 @@ #define initial_regno_reg_rtx (this_targ machine_mode byte_mode; /* Mode whose width is BITS_PER_UNIT. */ machine_mode word_mode; /* Mode whose width is BITS_PER_WORD. */ -machine_mode double_mode; /* Mode whose width is DOUBLE_TYPE_SIZE. */ machine_mode ptr_mode; /* Mode whose width is POINTER_SIZE. */ /* Datastructures maintained for currently processed function in RTL form. */ @@ -5895,7 +5894,7 @@ init_emit_once (void) { int i; machine_mode mode; - machine_mode double_mode; + scalar_float_mode double_mode; /* Initialize the CONST_INT, CONST_WIDE_INT, CONST_DOUBLE, CONST_FIXED, and memory attribute hash tables. */ @@ -5939,7 +5938,7 @@ init_emit_once (void) else const_true_rtx = gen_rtx_CONST_INT (VOIDmode, STORE_FLAG_VALUE); - double_mode = mode_for_size (DOUBLE_TYPE_SIZE, MODE_FLOAT, 0); + double_mode = *float_mode_for_size (DOUBLE_TYPE_SIZE); real_from_integer (&dconst0, double_mode, 0, SIGNED); real_from_integer (&dconst1, double_mode, 1, SIGNED); Index: gcc/stor-layout.c =================================================================== --- gcc/stor-layout.c 2017-07-13 09:18:22.938277517 +0100 +++ gcc/stor-layout.c 2017-07-13 09:18:25.916974620 +0100 @@ -2142,14 +2142,16 @@ layout_type (tree type) break; case REAL_TYPE: - /* 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; + { + /* 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, *float_mode_for_size (TYPE_PRECISION (type))); + scalar_float_mode mode = as_a (TYPE_MODE (type)); + TYPE_SIZE (type) = bitsize_int (GET_MODE_BITSIZE (mode)); + TYPE_SIZE_UNIT (type) = size_int (GET_MODE_SIZE (mode)); + break; + } case FIXED_POINT_TYPE: /* TYPE_MODE (type) has been set already. */ Index: gcc/gdbhooks.py =================================================================== --- gcc/gdbhooks.py 2017-07-13 09:18:23.798185961 +0100 +++ gcc/gdbhooks.py 2017-07-13 09:18:25.916974620 +0100 @@ -542,6 +542,8 @@ def build_pretty_printer(): pp.add_printer_for_regex(r'opt_mode<(\S+)>', 'opt_mode', OptMachineModePrinter) + pp.add_printer_for_types(['opt_scalar_float_mode'], + 'opt_mode', OptMachineModePrinter) pp.add_printer_for_types(['scalar_float_mode'], 'scalar_float_mode', MachineModePrinter)