This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[match-and-simplify] add new lower function


Instead of iterating each time for calling lowering function
(lower_opt_convert, etc.),
add new lower function and pass lower_opt_convert, lower_for etc. to
it as callback.

* genmatch.c (lower): New overloaded function.
    (lower): Adjust to call overloaded lower.

Thanks,
Prathamesh
Index: gcc/genmatch.c
===================================================================
--- gcc/genmatch.c	(revision 216577)
+++ gcc/genmatch.c	(working copy)
@@ -880,24 +880,25 @@
 /* Lower the AST for everything in SIMPLIFIERS.  */
 
 static void
+lower (vec<simplify *>& in, vec<simplify *>& out, void (*lower_fn)(simplify *, vec<simplify *>&))
+{
+  for (unsigned i = 0; i < in.length (); ++i)
+    lower_fn (in[i], out);
+}
+
+static void
 lower (vec<simplify *>& simplifiers)
 {
   auto_vec<simplify *> out_simplifiers0;
-  for (unsigned i = 0; i < simplifiers.length (); ++i)
-    lower_opt_convert (simplifiers[i], out_simplifiers0);
-
   auto_vec<simplify *> out_simplifiers1;
-  for (unsigned i = 0; i < out_simplifiers0.length (); ++i)
-    lower_commutative (out_simplifiers0[i], out_simplifiers1);
-
+  
+  lower (simplifiers, out_simplifiers0, lower_opt_convert);
+  lower (out_simplifiers0, out_simplifiers1, lower_commutative);
+  
   simplifiers.truncate (0);
-  for (unsigned i = 0; i < out_simplifiers1.length (); ++i)
-    lower_for (out_simplifiers1[i], simplifiers);
+  lower (out_simplifiers1, simplifiers, lower_for); 
 }
 
-
-
-
 /* The decision tree built for generating GIMPLE and GENERIC pattern
    matching code.  It represents the 'match' expression of all
    simplifies and has those as its leafs.  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]