diff mbox

[match-and-simplify] reject expanding operator-list to implicit 'for'

Message ID CAAgBjMmHp+voXYijmt--sVt7-VDey84EtkO0Zd13HVimeyz+TQ@mail.gmail.com
State New
Headers show

Commit Message

Prathamesh Kulkarni May 20, 2015, 10:47 a.m. UTC
Hi,
This patch rejects expanding operator-list to implicit 'for'.
OK for trunk after bootstrap+testing ?

Thanks,
Prathamesh
2015-05-20  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>

	* genmatch.c (parser::record_operlist): Remove.
	(parser::oper_lists_set): Likewise.
	(parser::oper_lists): Likewise.
	(parser::parse_operation): Reject operator-list and remove call to parser::record_operlist.
	(parser::parse_c_expr): Remove call to parser::record_operlist.
	(parser::push_simplify): Remove pushing and popping parser::oper_lists in parser::active_fors.
	(parser::parse_simplify): Avoid initializing parser::oper_lists and parser::oper_lists_set.
	(parser::parser): Likewise.

Comments

Prathamesh Kulkarni May 20, 2015, 11:08 a.m. UTC | #1
On 20 May 2015 at 16:17, Prathamesh Kulkarni
<prathamesh.kulkarni@linaro.org> wrote:
> Hi,
> This patch rejects expanding operator-list to implicit 'for'.
On second thoughts, should we reject expansion of operator-list _only_
if it's mixed with 'for' ?
We could define multiple operator-lists in simplify to be the same as
enclosing the simplify in 'for' with number of iterators
equal to number of operator-lists.
So we could allow
(define_operator_list op1 ...)
(define_operator_list op2 ...)

(simplify
  (op1 (op2 ... )))

is equivalent to:
(for  temp1 (op1)
       temp2 (op2)
  (simplify
    (temp1 (temp2 ...))))

I think we have patterns like these in match-builtin.pd in the
match-and-simplify branch
And reject mixing of 'for' and operator-lists.
Admittedly the implicit 'for' behavior is not obvious from the syntax -;(

Thanks,
Prathamesh
> OK for trunk after bootstrap+testing ?
>
> Thanks,
> Prathamesh
diff mbox

Patch

Index: genmatch.c
===================================================================
--- genmatch.c	(revision 223437)
+++ genmatch.c	(working copy)
@@ -2714,7 +2714,6 @@ 
   c_expr *parse_c_expr (cpp_ttype);
   operand *parse_op ();
 
-  void record_operlist (source_location, user_id *);
 
   void parse_pattern ();
   void push_simplify (vec<simplify *>&, operand *, source_location,
@@ -2729,9 +2728,6 @@ 
   cpp_reader *r;
   vec<if_or_with> active_ifs;
   vec<vec<user_id *> > active_fors;
-  hash_set<user_id *> *oper_lists_set;
-  vec<user_id *> oper_lists;
-
   cid_map_t *capture_ids;
 
 public:
@@ -2860,22 +2856,6 @@ 
   return (const char *)token->val.str.text;
 }
 
-
-/* Record an operator-list use for transparent for handling.  */
-
-void
-parser::record_operlist (source_location loc, user_id *p)
-{
-  if (!oper_lists_set->add (p))
-    {
-      if (!oper_lists.is_empty ()
-	  && oper_lists[0]->substitutes.length () != p->substitutes.length ())
-	fatal_at (loc, "User-defined operator list does not have the "
-		  "same number of entries as others used in the pattern");
-      oper_lists.safe_push (p);
-    }
-}
-
 /* Parse the operator ID, special-casing convert?, convert1? and
    convert2?  */
 
@@ -2913,7 +2893,7 @@ 
 
   user_id *p = dyn_cast<user_id *> (op);
   if (p && p->is_oper_list)
-    record_operlist (id_tok->src_loc, p);
+    fatal_at (id_tok, "invalid use of operator-list %s", id); 
   return op;
 }
 
@@ -3051,11 +3031,8 @@ 
       /* If this is possibly a user-defined identifier mark it used.  */
       if (token->type == CPP_NAME)
 	{
-	  id_base *idb = get_operator ((const char *)CPP_HASHNODE
-				      (token->val.node.node)->ident.str);
-	  user_id *p;
-	  if (idb && (p = dyn_cast<user_id *> (idb)) && p->is_oper_list)
-	    record_operlist (token->src_loc, p);
+	  get_operator ((const char *)CPP_HASHNODE
+		       (token->val.node.node)->ident.str);
 	}
 
       /* Record the token.  */
@@ -3140,16 +3117,9 @@ 
 		       operand *match, source_location match_loc,
 		       operand *result, source_location result_loc)
 {
-  /* Build and push a temporary for for operator list uses in expressions.  */
-  if (!oper_lists.is_empty ())
-    active_fors.safe_push (oper_lists);
-
   simplifiers.safe_push
     (new simplify (match, match_loc, result, result_loc,
 		   active_ifs.copy (), active_fors.copy (), capture_ids));
-
-  if (!oper_lists.is_empty ())
-    active_fors.pop ();
 }
 
 /* Parse
@@ -3170,11 +3140,7 @@ 
   /* Reset the capture map.  */
   if (!capture_ids)
     capture_ids = new cid_map_t;
-  /* Reset oper_lists and set.  */
-  hash_set <user_id *> olist;
-  oper_lists_set = &olist;
-  oper_lists = vNULL;
-
+  
   const cpp_token *loc = peek ();
   parsing_match_operand = true;
   struct operand *match = parse_op ();
@@ -3563,8 +3529,6 @@ 
   active_ifs = vNULL;
   active_fors = vNULL;
   simplifiers = vNULL;
-  oper_lists_set = NULL;
-  oper_lists = vNULL;
   capture_ids = NULL;
   user_predicates = vNULL;
   parsing_match_operand = false;