From patchwork Tue May 12 20:36:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 1288790 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=adacore-com.20150623.gappssmtp.com header.i=@adacore-com.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=Idy41uaM; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49M8j51x3Xz9sSF for ; Wed, 13 May 2020 06:36:23 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 14F91393BC24; Tue, 12 May 2020 20:36:20 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by sourceware.org (Postfix) with ESMTPS id 3E8D0393BC10 for ; Tue, 12 May 2020 20:36:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3E8D0393BC10 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=botcazou@adacore.com Received: by mail-wm1-x336.google.com with SMTP id f134so11527233wmf.1 for ; Tue, 12 May 2020 13:36:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=FndoQal+iDAw/A+NDnttMVFRgVyOujePOu9faClwV5Y=; b=Idy41uaMQkxmoiO0aDZX3RxhaxsgeBejjB3kv07LP2BIs4P7ck1z8mNl1GHzqdtsCx tdrqyAn5vr4xJ8N3hT/hRzuDhS0o973SD+fkhSO7n/LB6DMCfRuHG7MinnEPlEVXrA3C y4BCXRiXYP6cXT2nqvqV0eZMXc0kp3AyFomA/mKhaWdKCb8o/W+v0BXzMvZd9r9zInTs DDRkPih6pfTb3ii+GY+FXAARAtjtcqMFoSD7p/eYy1UNoRqVO5gtcdfNZSO2odsgODll eXWPbnQY9oOX4hUjXTtJC/bQNTz7G4RL+e/vXIVylw4+WcGSxiuBHn1HLJpbB0BRniL4 rEUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=FndoQal+iDAw/A+NDnttMVFRgVyOujePOu9faClwV5Y=; b=QzTPukD+xEestYD3MMBO8goZN4hVSON8C34htLrHb+E3vJw4wjPcdWXiFBTPpiobIN rVnWfjewwS0X8RrAZBY9dNwBUtNmPq33dWCpwGss3QfAnywQbOnC3pANXqZOP/KVgRiZ rjw+7dERIC7Jq0sbcNXaWlUx3O8vc13NtU7tp2VOCUf9V8Vf6xzcp9NeSW5oTBqJ+oRL qZfF0kyeZIm3dG6W6w5ypFXsk3MhrhZDc4MCWfOqf0e0KmCutHzjuq2omsjOEJFJ8u3j zQZjK+b3z+Ecq8HQWgwIAiGbW4Ms4MTNQlAqH9eLicUbFbp9CbOBVLc3wRO0fUEsyDxA xaLA== X-Gm-Message-State: AGi0PubFe4Vk4lVjm9NWvWB3+zgZHg3OOJuX8OfWxlTSPfwNLGMrz+CP g4U7NU0a0hmBIFXWFL9boWizTCKdXJkYGA== X-Google-Smtp-Source: APiQypKlBGJs8w9MQerwc0EexbXdbBtBgytw0OPg/oOSPip1wOq8x0EmHu2XltwFNvQ5f/TlYSqIag== X-Received: by 2002:a1c:de05:: with SMTP id v5mr15501455wmg.1.1589315775872; Tue, 12 May 2020 13:36:15 -0700 (PDT) Received: from polaris.localnet ([2a01:e0a:41b:9230:1a03:73ff:fe45:373a]) by smtp.gmail.com with ESMTPSA id b20sm33710443wme.9.2020.05.12.13.36.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 May 2020 13:36:15 -0700 (PDT) From: Eric Botcazou X-Google-Original-From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Be prepared for more aggregates in gigi Date: Tue, 12 May 2020 22:36:12 +0200 Message-ID: <3796486.fGCPiDdZM2@polaris> MIME-Version: 1.0 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" This makes sure that gigi is prepared to handle more aggregates in the special memset code path. Tested on x86-64/Linux, applied on the mainline. 2020-05-12 Eric Botcazou * sem_aggr.ads (Is_Single_Aggregate): New function. * sem_aggr.adb (Is_Others_Aggregate): Use local variable. (Is_Single_Aggregate): New function to recognize an aggregate with a single association containing a single choice. * fe.h (Is_Others_Aggregate): Delete. (Is_Single_Aggregate): New declaration. * gcc-interface/trans.c (gnat_to_gnu) : Call Is_Single_Aggregate instead of Is_Others_Aggregate. diff --git a/gcc/ada/fe.h b/gcc/ada/fe.h index 6b3f300301c..99613282213 100644 --- a/gcc/ada/fe.h +++ b/gcc/ada/fe.h @@ -253,9 +253,9 @@ extern Boolean No_Exception_Handlers_Set (void); /* sem_aggr: */ -#define Is_Others_Aggregate sem_aggr__is_others_aggregate +#define Is_Single_Aggregate sem_aggr__is_single_aggregate -extern Boolean Is_Others_Aggregate (Node_Id); +extern Boolean Is_Single_Aggregate (Node_Id); /* sem_aux: */ diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index cddeae3081a..b7a4cadb7e6 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -7887,7 +7887,7 @@ gnat_to_gnu (Node_Id gnat_node) const bool use_memset_p = regular_array_type_p && Nkind (gnat_inner) == N_Aggregate - && Is_Others_Aggregate (gnat_inner); + && Is_Single_Aggregate (gnat_inner); /* If we use memset, we need to find the innermost expression. */ if (use_memset_p) @@ -7897,7 +7897,7 @@ gnat_to_gnu (Node_Id gnat_node) gnat_temp = Expression (First (Component_Associations (gnat_temp))); } while (Nkind (gnat_temp) == N_Aggregate - && Is_Others_Aggregate (gnat_temp)); + && Is_Single_Aggregate (gnat_temp)); gnu_rhs = gnat_to_gnu (gnat_temp); } else diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index e41fcdb6cc0..5a26cf9c7fd 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -832,13 +832,26 @@ package body Sem_Aggr is ------------------------- function Is_Others_Aggregate (Aggr : Node_Id) return Boolean is + Assoc : constant List_Id := Component_Associations (Aggr); + begin return No (Expressions (Aggr)) - and then - Nkind (First (Choice_List (First (Component_Associations (Aggr))))) = - N_Others_Choice; + and then Nkind (First (Choice_List (First (Assoc)))) = N_Others_Choice; end Is_Others_Aggregate; + ------------------------- + -- Is_Single_Aggregate -- + ------------------------- + + function Is_Single_Aggregate (Aggr : Node_Id) return Boolean is + Assoc : constant List_Id := Component_Associations (Aggr); + + begin + return No (Expressions (Aggr)) + and then No (Next (First (Assoc))) + and then No (Next (First (Choice_List (First (Assoc))))); + end Is_Single_Aggregate; + ---------------------------- -- Is_Top_Level_Aggregate -- ---------------------------- diff --git a/gcc/ada/sem_aggr.ads b/gcc/ada/sem_aggr.ads index 1d4f3489d78..13519a25742 100644 --- a/gcc/ada/sem_aggr.ads +++ b/gcc/ada/sem_aggr.ads @@ -37,6 +37,9 @@ package Sem_Aggr is function Is_Others_Aggregate (Aggr : Node_Id) return Boolean; -- Returns True is aggregate Aggr consists of a single OTHERS choice + function Is_Single_Aggregate (Aggr : Node_Id) return Boolean; + -- Returns True is aggregate Aggr consists of a single choice + -- WARNING: There is a matching C declaration of this subprogram in fe.h end Sem_Aggr;