diff mbox

[match-and-simplify] add new lower function

Message ID CAJXstsA7okOtHOP=YxYrpzWWy5Z-tqqc=pEs+-S=Wqv4kRoSgg@mail.gmail.com
State New
Headers show

Commit Message

Prathamesh Kulkarni Oct. 23, 2014, 9:22 a.m. UTC
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

Comments

Richard Biener Oct. 24, 2014, 9:20 a.m. UTC | #1
On Thu, Oct 23, 2014 at 11:22 AM, Prathamesh Kulkarni
<bilbotheelffriend@gmail.com> wrote:
> 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.

I don't think this is more readable.

Thanks,
Richard.

> * genmatch.c (lower): New overloaded function.
>     (lower): Adjust to call overloaded lower.
>
> Thanks,
> Prathamesh
diff mbox

Patch

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.  */