From patchwork Thu Jun 17 16:05:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 56067 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]) by ozlabs.org (Postfix) with SMTP id 1ADF5B7D64 for ; Fri, 18 Jun 2010 02:05:31 +1000 (EST) Received: (qmail 32604 invoked by alias); 17 Jun 2010 16:05:28 -0000 Received: (qmail 31532 invoked by uid 22791); 17 Jun 2010 16:05:22 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, TW_DR, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 17 Jun 2010 16:05:15 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 1CA64CB02A7; Thu, 17 Jun 2010 18:05:21 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2J-m6MlJvWj2; Thu, 17 Jun 2010 18:05:21 +0200 (CEST) Received: from saumur.act-europe.fr (saumur.act-europe.fr [10.10.0.183]) by mel.act-europe.fr (Postfix) with ESMTP id 09EE6CB0298; Thu, 17 Jun 2010 18:05:21 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id 17AFDD9A01; Thu, 17 Jun 2010 18:05:31 +0200 (CEST) Date: Thu, 17 Jun 2010 18:05:31 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Robert Dewar Subject: [Ada] More work on short circuit forms Message-ID: <20100617160531.GA28977@adacore.com> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.9i X-IsSubscribed: yes 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 This patch cleans up the method for choosing whether to use the new N_Expressions_With_Actions node for short circuit forms, by introducing a new flag Opt.Use_Expression_With_Actions. This is still off by default for now. Tested on x86_64-pc-linux-gnu, committed on trunk 2010-06-17 Robert Dewar * debug.adb: Add documentation for debug flags .X and .Y * exp_ch4.adb (Expand_Short_Circuit_Operator): Use Use_Expression_With_Actions. * gnat1drv.adb (Adjust_Global_Switches): Set Use_Expression_With_Actions. * opt.ads (Use_Expression_With_Actions): New switch. Index: debug.adb =================================================================== --- debug.adb (revision 160929) +++ debug.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2010, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -141,8 +141,8 @@ package body Debug is -- d.U -- d.V -- d.W Print out debugging information for Walk_Library_Items - -- d.X Use Expression_With_Actions for short-circuited forms - -- d.Y + -- d.X Use Expression_With_Actions + -- d.Y Do not use Expression_With_Actions -- d.Z -- d1 Error msgs have node numbers where possible @@ -581,10 +581,15 @@ package body Debug is -- d.X By default, the compiler uses an elaborate rewriting framework for -- short-circuited forms where the right hand condition generates - -- actions to be inserted. Use of this switch causes the compiler to - -- use the much simpler Expression_With_Actions node for this purpose. - -- It is a debug flag to aid transitional implementation in gigi and - -- the back end. As soon as that works fine, we will remove this flag. + -- actions to be inserted. With the gcc backend, we now use the new + -- N_Expression_With_Actions node for this expansion, but we still use + -- the old method for other backends and in SCIL mode. This debug flag + -- forces use of the new N_Expression_With_Actions node in these other + -- cases and is intended for transitional use. + + -- d.Y Prevents the use of the N_Expression_With_Actions node even in the + -- case of the gcc back end. Provided as a back up in case the new + -- scheme has problems. -- d1 Error messages have node numbers where possible. Normally error -- messages have only source locations. This option is useful when Index: gnat1drv.adb =================================================================== --- gnat1drv.adb (revision 160923) +++ gnat1drv.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2010, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -332,6 +332,33 @@ procedure Gnat1drv is else Suppress_Options (Overflow_Check) := True; end if; + + -- Set switch indicating if we can use N_Expression_With_Actions + + -- Debug flag -gnatd.X decisively sets usage on + + if Debug_Flag_Dot_XX then + Use_Expression_With_Actions := True; + + -- Debug flag -gnatd.Y decisively sets usage off + + elsif Debug_Flag_Dot_YY then + Use_Expression_With_Actions := False; + + -- If no debug flags, usage off for AAMP, VM, SCIL cases + + elsif AAMP_On_Target + or else VM_Target /= No_VM + or else Generate_SCIL + then + Use_Expression_With_Actions := False; + + -- Otherwise normal gcc back end, for now still turn usage off by + -- default. + + else + Use_Expression_With_Actions := False; + end if; end Adjust_Global_Switches; -------------------- Index: exp_ch4.adb =================================================================== --- exp_ch4.adb (revision 160929) +++ exp_ch4.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2010, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -8829,10 +8829,10 @@ package body Exp_Ch4 is -- of the introduction of the new variable C, which obscures the -- structure of the test. - -- We use this "old approach" by default for now, unless the - -- special debug switch gnatd.X is used. + -- We use this "old approach" if use of N_Expression_With_Actions + -- is False (see description in Opt of when this is or is not set). - if not Debug_Flag_Dot_XX then + if not Use_Expression_With_Actions then Op_Var := Make_Temporary (Loc, 'C', Related_Node => N); Insert_Action (N, Index: opt.ads =================================================================== --- opt.ads (revision 160923) +++ opt.ads (working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2010, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -453,8 +453,8 @@ package Opt is Front_End_Setjmp_Longjmp_Exceptions; -- GNAT -- Set to the appropriate value depending on the default as given in - -- system.ads (ZCX_By_Default, GCC_ZCX_Support). - -- The C convention is there to make this variable accessible to gigi. + -- system.ads (ZCX_By_Default, GCC_ZCX_Support). The C convention is there + -- to make this variable accessible to gigi. Exception_Tracebacks : Boolean := False; -- GNATBIND @@ -1239,6 +1239,13 @@ package Opt is -- Set to True if -h (-gnath for the compiler) switch encountered -- requesting usage information + Use_Expression_With_Actions : Boolean := False; + -- The N_Expression_With_Actions node has been introduced relatively + -- recently, and not all back ends are prepared to handle it yet. So + -- we use this flag to suppress its use during a transitional period. + -- Currently the default is False for all cases except the standard + -- GCC back end. The default can be modified using -gnatd.X/-gnatd.Y. + Use_Pragma_Linker_Constructor : Boolean := False; -- GNATBIND -- True if pragma Linker_Constructor applies to adainit