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] |
On Tue, Nov 11, 2014 at 9:55 AM, Richard Biener <richard.guenther@gmail.com> wrote: > On Mon, Nov 10, 2014 at 2:39 PM, Prathamesh Kulkarni > <bilbotheelffriend@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! I have picked this up now and did the suggested changes. I've also removed the restriction on the use in for as we have one case where that's useful in match-builtins.pd already. I have for now restricted the operator lists to combine a little more than for regular fors - namely I require the same number of operators. I am testing the following patch on trunk and hope to commit it there tomorrow and then bring it back to the branch via a merge. Bootstrap running on x86_64-unknown-linux-gnu (testing not neccessary on trunk as the generated files are unchanged). Bootstrap / test on the branch running as well. Richard. 2014-12-01 Richard Biener <rguenther@suse.de> Prathamesh Kulkarni <bilbotheelffriend@gmail.com> * genmatch.c: Include hash-set.h. (fatal_at): Add source_location overload. (parser::record_operlist): New method. (parser::push_simplify): Likewise. (parser::oper_lists_set): New member. (parser::oper_lists): Likewise. (parser::parse_operation): Record seen operator list references. (parser::parse_c_expr): Likewise. (parser::parse_simplify): Init oper_lists_set and oper_lists and use push_simplify. (parser::parser): Init oper_lists_set and oper_lists. > 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
Attachment:
mas-oper-list-expr
Description: Binary data
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |