On Mon, Nov 10, 2014 at 2:39 PM, Prathamesh Kulkarni
<bilbotheelffri...@gmail.com> wrote:
> Hi,
>   This patch adds support for operator-lists to be used in expression.
>
> I reuse operator-list as the iterator. This is not really valid since
> user-defined operator-lists cannot be iterator in 'for', but it was
> convenient to reuse operator-list as a 'for' iterator
> and lower_for doesn't care about that.
> eg:
> (define_operator_list  list1 plus minus)
>
> (simplify
>   (list1 @x integer_zerop)
>   (non_lvalue @x))
>
> is wrapped into 'for' as: (lower_operator_list):
> (for list1 (plus minus)
>   (simplify
>     (list1 @x integer_zerop)
>     (non_lvalue @x)))
>
> this is not really valid since we reject list1 to be used as iterator if
> it were written by user.
>
> Is this okay or should I introduce an explicit temporary iterator ?

No, it's ok to re-use it.

I think you should get rid of the extra lowering step and instead
in parse_simplify create the extra for directly when building
a simplify (the multiple simplfy buildings really ask for factoring
it out to a method in the parser class which has access to
active_fors, active_ifs and friends).

Also you use a vector to store operator_lists - this will gobble
up duplicates.  It's probably better to use a pointer_hash <user_id *>
for this.

Thanks for continuing to work on this!

Richard.

> so it gets lowered to something like:
> (for tmp1 (list1)
>   (simplify
>     (tmp1 @x integer_zerop)
>     (non_lvalue @x)))
>
> * genmatch.c
>   (fatal_at): New overloaded function.
>   (simplify::oper_lists): New member.
>   (simplify::simplify): Add default argument.
>   (lower_commutative): Adjust call to simplify::simplify.
>   (lower_opt_convert): Likewise.
>   (lower_operator_list): New function.
>   (lower): Call lower_operator_list.
>   (parser::parsing_for_p): New member function.
>   (parser::oper_lists): New member.
>   (parser::parse_operation): Check for operator-list.
>   (parser::parse_c_expr): Likewise.
>   (parser::parse_simplify): Reset parser::oper_lists.
>     Adjust call to simplify::simplify.
>   (parser::parser): Initialize parser::oper_lists.
>
> * match-builtin.pd:
>   Adjust patten to use SQRTs and POWs.
>
> Thanks,
> Prathamesh

Reply via email to