From patchwork Mon Sep 4 11:42:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 111552 Delivered-To: patch@linaro.org Received: by 10.37.128.210 with SMTP id c18csp4119619ybm; Mon, 4 Sep 2017 04:42:52 -0700 (PDT) X-Received: by 10.84.235.67 with SMTP id g3mr295851plt.299.1504525372734; Mon, 04 Sep 2017 04:42:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504525372; cv=none; d=google.com; s=arc-20160816; b=msq0/dimMrgvYp1K09+A7drw4B1dWNzAXyiYazBupR1jb0SWh4qGf0nVQEYUufz56w Iq+rt+Exmvtk6ldqFYAhCu9Xaq2iXaOoDoRvrdvkZU5+URpabmNzIGEKZAzZ4DIIY9RS 4WHJsNWWcDf99ZcGNGI+VRx1pgNUaWmb9b0A04NimQUyTqtY5RLNUlx6tgnAhWVolire nqTznyJMV7zDDPVWADl8WzDenAcWQFOXG7xFhrcOvigXPvywGhXuQWkyESQe17drVzZS h3M4o/RWz60EETRNDHBLyv/zW4N9+BeJvcTnZnGfPfDR8De6GX/iiIsnzgf0a3ySJWAI qbog== 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=Si19PDkXLQ1bfCwr+nWHdzPTeFDs8KjFRybi2JPc+7U=; b=r/LV/O98Yu+g3KCoh1SIXFCnBUroG9XakB8ZALHe3da6OvDY9mVaB3OHCZsG2VrE6Q yZDRJmpCfaQHwPC6ZRkygz4OT4Oqe+BTG0+TelpmkHfuvFPtVOubhNKI1ArE8iFP7vMV 9YFvlsU3Nrr6JQC+aVsSjmY0FhVhjCAxHxqLh+vIvaI/yEaKGqp7EEJlUpEFhNGwHWpH hY+1Nxy4eQviOVjrwxDttyDoWu1ELwMiqB1MaQp4yW4Q/Tb1S+on3HaH9Yc3OGFzv1cQ fwDeH3xaSymAhrhSXMeMBAwpgS9i8kjwVhaQn7MEL1u7vgCx4v7gahM8Q/LsiZlZqDU4 5/Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=p68z/nPV; spf=pass (google.com: domain of gcc-patches-return-461411-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-461411-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 e5si4751272pfc.562.2017.09.04.04.42.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Sep 2017 04:42:52 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-461411-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.s=default header.b=p68z/nPV; spf=pass (google.com: domain of gcc-patches-return-461411-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-461411-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=K7fp88LeySC5YkE2qtXdA9+NH0rEk FUbi+C5XAdq2EFMgOfyMpPPtXitkguLTTtjrUcNMrN7pVcVYeM01FzszW+xtJPFB nG2iGeqqT5uROxRvylNO8un63wv5M8Z3xQe2hp11F5KJEs+NDfIN1GHrDodHRDvt TkZMe4YB5tamkU= 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=v2O79Gx3MLHDQQQSK4/L3rJduLE=; b=p68 z/nPVruNUH9a3rknK7/jyOPvZWLDHud0KhoHgY9rOLf/k9/4SyeVTAk0eUP6467C xb1BIlyYa0EUaz5D2+ofGCu9F7qTRzJYpp96WKp98WRkgzSFoDIq2ltdqxEkmOlg Kj4AF0/9sqETf/DN7+1ymEXj72jvOTJm5xcoGvHg= Received: (qmail 29208 invoked by alias); 4 Sep 2017 11:42:41 -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 28502 invoked by uid 89); 4 Sep 2017 11:42:40 -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-wr0-f176.google.com Received: from mail-wr0-f176.google.com (HELO mail-wr0-f176.google.com) (209.85.128.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 04 Sep 2017 11:42:35 +0000 Received: by mail-wr0-f176.google.com with SMTP id a43so862411wrc.0 for ; Mon, 04 Sep 2017 04:42:34 -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=Si19PDkXLQ1bfCwr+nWHdzPTeFDs8KjFRybi2JPc+7U=; b=rfMXXATIhgCT3DOMhIRilT/Tyd4tSKK6leoI0dKKGT4B0hlCqGJUrXn9jBYVU8K+Om 3GU2qGaElU/pUhaKlcMEbztKza1WslXLZU9soNdczlkwAtAh41ijFzdTaa9p/jiDpkZ4 OvpadwkGvPPibeU63DIwU5EtoN4ggP6TCOUt2YaaMEnviFRgU6oI0TsIWbyDnzgsXOqE Q2WcJk93vK5Alps9ADrup2/q1+c7BnpuO7satnupXA1Qf9vt6WiL0K7ckEUfZyratykP UT+2OMEAlUX+RJKqBU85/1mtgmsQ8VHeo0twTyWQ0JZc6b64bQCU4SdElS7PVgwDFtC7 Iccg== X-Gm-Message-State: AHPjjUibbxFl6hQ4kFUDhlaW3LkEK1I2BDJgTVS7FAs/JDaRuUC0f80o s1ILcK+xQFO6MDgHaFUnPQ== X-Google-Smtp-Source: ADKCNb77XYb5vgFtIswj0iSRuHjp8cuwCxeEf5OPPwSzv1cwlNq89zRhNUhYVIaPD9xlJtN9wUiK/g== X-Received: by 10.223.188.68 with SMTP id a4mr141713wrh.300.1504525352852; Mon, 04 Sep 2017 04:42:32 -0700 (PDT) Received: from localhost (94.197.120.41.threembb.co.uk. [94.197.120.41]) by smtp.gmail.com with ESMTPSA id l126sm420995wmd.1.2017.09.04.04.42.31 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 04 Sep 2017 04:42:32 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [8/9] Make mode_for_size_tree return an opt_mode References: <87tw0iiu51.fsf@linaro.org> Date: Mon, 04 Sep 2017 12:42:30 +0100 In-Reply-To: <87tw0iiu51.fsf@linaro.org> (Richard Sandiford's message of "Mon, 04 Sep 2017 12:24:26 +0100") Message-ID: <87tw0iheqh.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 ...for consistency with mode_for_size 2017-09-04 Richard Sandiford gcc/ * stor-layout.h (mode_for_size_tree): Return an opt_mode. * stor-layout.c (mode_for_size_tree): Likewise. (mode_for_array): Update accordingly. (layout_decl): Likewise. (compute_record_mode): Likewise. Only set the mode once. gcc/ada/ * gcc-interface/utils.c (make_packable_type): Update call to mode_for_size_tree. Index: gcc/stor-layout.h =================================================================== --- gcc/stor-layout.h 2017-08-21 12:14:47.158835574 +0100 +++ gcc/stor-layout.h 2017-09-04 12:19:01.144339518 +0100 @@ -99,7 +99,7 @@ extern tree make_unsigned_type (int); If LIMIT is nonzero, then don't use modes bigger than MAX_FIXED_MODE_SIZE. The value is BLKmode if no other mode is found. This is like mode_for_size, but is passed a tree. */ -extern machine_mode mode_for_size_tree (const_tree, enum mode_class, int); +extern opt_machine_mode mode_for_size_tree (const_tree, enum mode_class, int); extern tree bitwise_type_for_mode (machine_mode); Index: gcc/stor-layout.c =================================================================== --- gcc/stor-layout.c 2017-09-04 12:18:55.824344959 +0100 +++ gcc/stor-layout.c 2017-09-04 12:19:01.144339518 +0100 @@ -321,19 +321,19 @@ mode_for_size (unsigned int size, enum m /* Similar, except passed a tree node. */ -machine_mode +opt_machine_mode mode_for_size_tree (const_tree size, enum mode_class mclass, int limit) { unsigned HOST_WIDE_INT uhwi; unsigned int ui; if (!tree_fits_uhwi_p (size)) - return BLKmode; + return opt_machine_mode (); uhwi = tree_to_uhwi (size); ui = uhwi; if (uhwi != ui) - return BLKmode; - return mode_for_size (ui, mclass, limit).else_blk (); + return opt_machine_mode (); + return mode_for_size (ui, mclass, limit); } /* Return the narrowest mode of class MCLASS that contains at least @@ -563,7 +563,7 @@ mode_for_array (tree elem_type, tree siz int_size / int_elem_size)) limit_p = false; } - return mode_for_size_tree (size, MODE_INT, limit_p); + return mode_for_size_tree (size, MODE_INT, limit_p).else_blk (); } /* Subroutine of layout_decl: Force alignment required for the data type. @@ -683,17 +683,18 @@ layout_decl (tree decl, unsigned int kno && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST && GET_MODE_CLASS (TYPE_MODE (type)) == MODE_INT) { - machine_mode xmode - = mode_for_size_tree (DECL_SIZE (decl), MODE_INT, 1); - unsigned int xalign = GET_MODE_ALIGNMENT (xmode); - - if (xmode != BLKmode - && !(xalign > BITS_PER_UNIT && DECL_PACKED (decl)) - && (known_align == 0 || known_align >= xalign)) + machine_mode xmode; + if (mode_for_size_tree (DECL_SIZE (decl), + MODE_INT, 1).exists (&xmode)) { - SET_DECL_ALIGN (decl, MAX (xalign, DECL_ALIGN (decl))); - SET_DECL_MODE (decl, xmode); - DECL_BIT_FIELD (decl) = 0; + unsigned int xalign = GET_MODE_ALIGNMENT (xmode); + if (!(xalign > BITS_PER_UNIT && DECL_PACKED (decl)) + && (known_align == 0 || known_align >= xalign)) + { + SET_DECL_ALIGN (decl, MAX (xalign, DECL_ALIGN (decl))); + SET_DECL_MODE (decl, xmode); + DECL_BIT_FIELD (decl) = 0; + } } } @@ -1756,22 +1757,24 @@ compute_record_mode (tree type) if (TREE_CODE (type) == RECORD_TYPE && mode != VOIDmode && tree_fits_uhwi_p (TYPE_SIZE (type)) && GET_MODE_BITSIZE (mode) == tree_to_uhwi (TYPE_SIZE (type))) - SET_TYPE_MODE (type, mode); + ; else - SET_TYPE_MODE (type, mode_for_size_tree (TYPE_SIZE (type), MODE_INT, 1)); + mode = mode_for_size_tree (TYPE_SIZE (type), MODE_INT, 1).else_blk (); /* If structure's known alignment is less than what the scalar mode would need, and it matters, then stick with BLKmode. */ - if (TYPE_MODE (type) != BLKmode + if (mode != BLKmode && STRICT_ALIGNMENT && ! (TYPE_ALIGN (type) >= BIGGEST_ALIGNMENT - || TYPE_ALIGN (type) >= GET_MODE_ALIGNMENT (TYPE_MODE (type)))) + || TYPE_ALIGN (type) >= GET_MODE_ALIGNMENT (mode))) { /* If this is the only reason this type is BLKmode, then don't force containing types to be BLKmode. */ TYPE_NO_FORCE_BLK (type) = 1; - SET_TYPE_MODE (type, BLKmode); + mode = BLKmode; } + + SET_TYPE_MODE (type, mode); } /* Compute TYPE_SIZE and TYPE_ALIGN for TYPE, once it has been laid Index: gcc/ada/gcc-interface/utils.c =================================================================== --- gcc/ada/gcc-interface/utils.c 2017-08-30 12:10:52.658405667 +0100 +++ gcc/ada/gcc-interface/utils.c 2017-09-04 12:19:01.143335745 +0100 @@ -1076,7 +1076,8 @@ make_packable_type (tree type, bool in_r in case the record itself contains a BLKmode field. */ if (in_record && TYPE_MODE (new_type) == BLKmode) SET_TYPE_MODE (new_type, - mode_for_size_tree (TYPE_SIZE (new_type), MODE_INT, 1)); + mode_for_size_tree (TYPE_SIZE (new_type), + MODE_INT, 1).else_blk ()); /* If neither mode nor size nor alignment shrunk, return the old type. */ if (TYPE_MODE (new_type) == BLKmode && new_size >= size && max_align == 0)