On 10/20/2017 02:24 AM, Richard Biener wrote:
On Fri, Oct 20, 2017 at 4:09 AM, Sandra Loosemore
<san...@codesourcery.com> wrote:
This patch adds a function to indicate whether the split1 pass has run
yet.  This is used in part 3 of the patch set to decide whether 32-bit
symbolic constant expressions are permitted, e.g. in
TARGET_LEGITIMATE_ADDRESS_P and the movsi expander.

Since there's currently no usable hook for querying the pass manager
where it is relative to another pass, I implemented this using a
target-specific pass that runs directly after split1 and does nothing
but set a flag.

"Nice" hack ;)  The only currently existing way would be to add a property
to the IL state like

const pass_data pass_data_split_all_insns =
{
   RTL_PASS, /* type */
   "split1", /* name */
   OPTGROUP_NONE, /* optinfo_flags */
   TV_NONE, /* tv_id */
   0, /* properties_required */
   PROP_rtl_split_insns, /* properties_provided */
   0, /* properties_destroyed */

and test that via cfun->curr_properties & PROP_rtl_split_insns

Having run split might be a important enough change to warrant this.
Likewise reload_completed and reload_in_progress could be transitioned
to IL properties.

Richard.

Well, here's a new version of this patch that implements what you suggested above. It's certainly simpler than the original version, or the WIP patch I posted before to add a general hook based on enumerating the passes. Is this OK?

-Sandra

2017-10-21  Sandra Loosemore  <san...@codesourcery.com>

	gcc/
	* tree-hass.h (PROP_rtl_split_insns): Define.
	* recog.c (pass_data_split_all_insns): Provide PROP_rtl_split_insns.
	* config/nios2/nios2.c: Adjust includes.
	(nios2_symbolic_constant_allowed): New.
diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h
index 9f76d82..21bde1c 100644
--- a/gcc/tree-pass.h
+++ b/gcc/tree-pass.h
@@ -223,6 +223,7 @@ protected:
 						   current choices have
 						   been optimized.  */
 #define PROP_gimple_lomp_dev	(1 << 16)	/* done omp_device_lower */
+#define PROP_rtl_split_insns	(1 << 17)	/* split1 completed.  */
 
 #define PROP_trees \
   (PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh | PROP_gimple_lomp)
diff --git a/gcc/recog.c b/gcc/recog.c
index b8e9b1b..6bf8164 100644
--- a/gcc/recog.c
+++ b/gcc/recog.c
@@ -3862,7 +3862,7 @@ const pass_data pass_data_split_all_insns =
   OPTGROUP_NONE, /* optinfo_flags */
   TV_NONE, /* tv_id */
   0, /* properties_required */
-  0, /* properties_provided */
+  PROP_rtl_split_insns, /* properties_provided */
   0, /* properties_destroyed */
   0, /* todo_flags_start */
   0, /* todo_flags_finish */
diff --git a/gcc/config/nios2/nios2.c b/gcc/config/nios2/nios2.c
index 3e55673..f5963d4 100644
--- a/gcc/config/nios2/nios2.c
+++ b/gcc/config/nios2/nios2.c
@@ -48,6 +48,7 @@
 #include "langhooks.h"
 #include "stor-layout.h"
 #include "builtins.h"
+#include "tree-pass.h"
 
 /* This file should be included last.  */
 #include "target-def.h"
@@ -1976,6 +1977,19 @@ nios2_validate_compare (machine_mode mode, rtx *cmp, rtx *op1, rtx *op2)
 
 /* Addressing modes and constants.  */
 
+/* Symbolic constants are split into high/lo_sum pairs during the 
+   split1 pass.  After that, they are not considered legitimate addresses.
+   This function returns true if in a pre-split context where these
+   constants are allowed.  */
+static bool
+nios2_symbolic_constant_allowed (void)
+{
+  /* The reload_completed check is for the benefit of
+     nios2_asm_output_mi_thunk and perhaps other places that try to
+     emulate a post-reload pass.  */
+  return !(cfun->curr_properties & PROP_rtl_split_insns) && !reload_completed;
+}
+
 /* Return true if X is constant expression with a reference to an
    "ordinary" symbol; not GOT-relative, not GP-relative, not TLS.  */
 static bool

Reply via email to