diff mbox

[Ada] More work on short circuit forms

Message ID 20100617160531.GA28977@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet June 17, 2010, 4:05 p.m. UTC
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  <dewar@adacore.com>

	* 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.
diff mbox

Patch

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