Use arc-passes.def to register ARC specific passes.

Ok to apply?
Claudiu

gcc/
xxxx-xx-xx  Claudiu Zissulescu  <claz...@synopsys.com>

        * config/arc/arc-protos.h (make_pass_arc_ifcvt): Declare.
        (make_pass_arc_predicate_delay_insns): Likewise.
        * config/arc/arc.c (class pass_arc_ifcvt): Reformat text, add gate
        method.
        (class pass_arc_predicate_delay_insns): Likewise.
        (arc_init): Remove registering of ARC specific passes.
        * config/arc/t-arc (PASSES_EXTRA): Add arc-passes.def.
        * config/arc/arc-passes.def: New file.
---
 gcc/config/arc/arc-passes.def | 29 ++++++++++++++++
 gcc/config/arc/arc-protos.h   |  3 ++
 gcc/config/arc/arc.c          | 64 +++++++++++++++--------------------
 gcc/config/arc/t-arc          |  2 ++
 4 files changed, 61 insertions(+), 37 deletions(-)
 create mode 100644 gcc/config/arc/arc-passes.def

diff --git a/gcc/config/arc/arc-passes.def b/gcc/config/arc/arc-passes.def
new file mode 100644
index 00000000000..ebb69a563df
--- /dev/null
+++ b/gcc/config/arc/arc-passes.def
@@ -0,0 +1,29 @@
+/* Description of target passes for ARC.
+   Copyright (C) 2019 Free Software Foundation, Inc. */
+
+/* This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it under
+   the terms of the GNU General Public License as published by the Free
+   Software Foundation; either version 3, or (at your option) any later
+   version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or
+   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+   for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
+
+/* First target dependent ARC if-conversion pass.  */
+INSERT_PASS_AFTER (pass_delay_slots, 1, pass_arc_ifcvt);
+
+/* Second target dependent ARC if-conversion pass.  */
+INSERT_PASS_BEFORE (pass_shorten_branches, 1, pass_arc_ifcvt);
+
+/* Find annulled delay insns and convert them to use the appropriate
+   predicate.  This allows branch shortening to size up these
+   instructions properly.  */
+INSERT_PASS_AFTER (pass_delay_slots, 1, pass_arc_predicate_delay_insns);
diff --git a/gcc/config/arc/arc-protos.h b/gcc/config/arc/arc-protos.h
index 1220e77206d..da128dcbcb2 100644
--- a/gcc/config/arc/arc-protos.h
+++ b/gcc/config/arc/arc-protos.h
@@ -111,3 +111,6 @@ extern void arc_eh_return_address_location (rtx);
 extern bool arc_is_jli_call_p (rtx);
 extern void arc_file_end (void);
 extern bool arc_is_secure_call_p (rtx);
+
+rtl_opt_pass * make_pass_arc_ifcvt (gcc::context *ctxt);
+rtl_opt_pass * make_pass_arc_predicate_delay_insns (gcc::context *ctxt);
diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
index 918c4e06533..d67775448a3 100644
--- a/gcc/config/arc/arc.c
+++ b/gcc/config/arc/arc.c
@@ -961,14 +961,24 @@ const pass_data pass_data_arc_ifcvt =
 
 class pass_arc_ifcvt : public rtl_opt_pass
 {
-public:
-  pass_arc_ifcvt(gcc::context *ctxt)
-  : rtl_opt_pass(pass_data_arc_ifcvt, ctxt)
-  {}
+ public:
+ pass_arc_ifcvt (gcc::context *ctxt)
+   : rtl_opt_pass (pass_data_arc_ifcvt, ctxt)
+    {}
 
   /* opt_pass methods: */
-  opt_pass * clone () { return new pass_arc_ifcvt (m_ctxt); }
-  virtual unsigned int execute (function *) { return arc_ifcvt (); }
+  opt_pass * clone ()
+    {
+      return new pass_arc_ifcvt (m_ctxt);
+    }
+  virtual unsigned int execute (function *)
+  {
+    return arc_ifcvt ();
+  }
+  virtual bool gate (function *)
+  {
+    return (optimize > 1 && !TARGET_NO_COND_EXEC);
+  }
 };
 
 } // anon namespace
@@ -998,16 +1008,20 @@ const pass_data pass_data_arc_predicate_delay_insns =
 
 class pass_arc_predicate_delay_insns : public rtl_opt_pass
 {
-public:
-  pass_arc_predicate_delay_insns(gcc::context *ctxt)
-  : rtl_opt_pass(pass_data_arc_predicate_delay_insns, ctxt)
-  {}
+ public:
+ pass_arc_predicate_delay_insns(gcc::context *ctxt)
+   : rtl_opt_pass(pass_data_arc_predicate_delay_insns, ctxt)
+    {}
 
   /* opt_pass methods: */
   virtual unsigned int execute (function *)
-    {
-      return arc_predicate_delay_insns ();
-    }
+  {
+    return arc_predicate_delay_insns ();
+  }
+  virtual bool gate (function *)
+  {
+    return flag_delayed_branch;
+  }
 };
 
 } // anon namespace
@@ -1100,30 +1114,6 @@ arc_init (void)
   arc_punct_chars['&'] = 1;
   arc_punct_chars['+'] = 1;
   arc_punct_chars['_'] = 1;
-
-  if (optimize > 1 && !TARGET_NO_COND_EXEC)
-    {
-      /* There are two target-independent ifcvt passes, and arc_reorg may do
-        one or more arc_ifcvt calls.  */
-      opt_pass *pass_arc_ifcvt_4 = make_pass_arc_ifcvt (g);
-      struct register_pass_info arc_ifcvt4_info
-       = { pass_arc_ifcvt_4, "dbr", 1, PASS_POS_INSERT_AFTER };
-      struct register_pass_info arc_ifcvt5_info
-       = { pass_arc_ifcvt_4->clone (), "shorten", 1, PASS_POS_INSERT_BEFORE };
-
-      register_pass (&arc_ifcvt4_info);
-      register_pass (&arc_ifcvt5_info);
-    }
-
-  if (flag_delayed_branch)
-    {
-      opt_pass *pass_arc_predicate_delay_insns
-       = make_pass_arc_predicate_delay_insns (g);
-      struct register_pass_info arc_predicate_delay_info
-       = { pass_arc_predicate_delay_insns, "dbr", 1, PASS_POS_INSERT_AFTER };
-
-      register_pass (&arc_predicate_delay_info);
-    }
 }
 
 /* Parse -mirq-ctrl-saved=RegisterRange, blink, lp_copunt.  The
diff --git a/gcc/config/arc/t-arc b/gcc/config/arc/t-arc
index ca6e06ac3ab..604e639b5bf 100644
--- a/gcc/config/arc/t-arc
+++ b/gcc/config/arc/t-arc
@@ -43,6 +43,8 @@ $(srcdir)/config/arc/arc-tables.opt: 
$(srcdir)/config/arc/genoptions.awk \
                                 $(srcdir)/config/arc/arc-cpus.def
        $(AWK) -f $< -v FORMAT=Makefile $< $(srcdir)/config/arc/arc-cpus.def > 
$@
 
+PASSES_EXTRA += $(srcdir)/config/arc/arc-passes.def
+
 # Local Variables:
 # mode: Makefile
 # End:
-- 
2.23.0

Reply via email to