public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrea Corallo <andrea.corallo@arm.com>
To: <gcc-patches@gcc.gnu.org>
Cc: <kyrylo.tkachov@arm.com>, <richard.sandiford@arm.com>,
	<Richard.Earnshaw@arm.com>
Subject: [PATCH 1/3] recog: Improve parser for pattern new compact syntax
Date: Fri, 22 Sep 2023 10:07:01 +0200	[thread overview]
Message-ID: <20230922080703.93612-1-andrea.corallo@arm.com> (raw)

From: Richard Sandiford <richard.sandiford@arm.com>

Hi all,

this is to add support to the new compact pattern syntax for the case
where the constraints do appear unsorted like:

(define_insn "*<optab>si3_insn_uxtw"
  [(set (match_operand:DI 0 "register_operand")
        (zero_extend:DI (SHIFT_no_rotate:SI
         (match_operand:SI 1 "register_operand")
         (match_operand:QI 2 "aarch64_reg_or_shift_imm_si"))))]
  ""
  {@ [cons: =0, 2,   1]
     [      r,  Uss, r] <shift>\\t%w0, %w1, %2
     [      r,  r,   r] <shift>\\t%w0, %w1, %w2
  }
  [(set_attr "type" "bfx,shift_reg")]
)

Best Regards

  Andrea

gcc/Changelog

2023-09-20  Richard Sandiford  <richard.sandiford@arm.com>

	* gensupport.cc (convert_syntax): Updated to support unordered
	constraints in compact syntax.
---
 gcc/gensupport.cc | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/gcc/gensupport.cc b/gcc/gensupport.cc
index f7164b3214d..7e125e3d8db 100644
--- a/gcc/gensupport.cc
+++ b/gcc/gensupport.cc
@@ -896,19 +896,6 @@ convert_syntax (rtx x, file_location loc)
 
   parse_section_layout (loc, &templ, "cons:", tconvec, true);
 
-  /* Check for any duplicate cons entries and sort based on i.  */
-  for (auto e : tconvec)
-    {
-      unsigned idx = e.idx;
-      if (idx >= convec.size ())
-	convec.resize (idx + 1);
-
-      if (convec[idx].idx >= 0)
-	fatal_at (loc, "duplicate cons number found: %d", idx);
-      convec[idx] = e;
-    }
-  tconvec.clear ();
-
   if (*templ != ']')
     {
       if (*templ == ';')
@@ -951,13 +938,13 @@ convert_syntax (rtx x, file_location loc)
 	  new_templ += '\n';
 	  new_templ.append (buffer);
 	  /* Parse the constraint list, then the attribute list.  */
-	  if (convec.size () > 0)
-	    parse_section (&templ, convec.size (), alt_no, convec, loc,
+	  if (tconvec.size () > 0)
+	    parse_section (&templ, tconvec.size (), alt_no, tconvec, loc,
 			   "constraint");
 
 	  if (attrvec.size () > 0)
 	    {
-	      if (convec.size () > 0 && !expect_char (&templ, ';'))
+	      if (tconvec.size () > 0 && !expect_char (&templ, ';'))
 		fatal_at (loc, "expected `;' to separate constraints "
 			       "and attributes in alternative %d", alt_no);
 
@@ -1027,6 +1014,19 @@ convert_syntax (rtx x, file_location loc)
       ++alt_no;
     }
 
+  /* Check for any duplicate cons entries and sort based on i.  */
+  for (auto e : tconvec)
+    {
+      unsigned idx = e.idx;
+      if (idx >= convec.size ())
+	convec.resize (idx + 1);
+
+      if (convec[idx].idx >= 0)
+	fatal_at (loc, "duplicate cons number found: %d", idx);
+      convec[idx] = e;
+    }
+  tconvec.clear ();
+
   /* Write the constraints and attributes into their proper places.  */
   if (convec.size () > 0)
     add_constraints (x, loc, convec);
-- 
2.25.1


             reply	other threads:[~2023-09-22  8:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-22  8:07 Andrea Corallo [this message]
2023-09-22  8:07 ` [PATCH 2/3] recog: Support space in "[ cons" Andrea Corallo
2023-09-27 10:53   ` Richard Sandiford
2023-09-22  8:07 ` [PATCH 3/3] aarch64: Convert aarch64 multi choice patterns to new syntax Andrea Corallo
2023-09-27 11:02   ` Richard Sandiford
2023-10-03  9:23     ` Andrea Corallo
2023-09-27 10:53 ` [PATCH 1/3] recog: Improve parser for pattern new compact syntax Richard Sandiford

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230922080703.93612-1-andrea.corallo@arm.com \
    --to=andrea.corallo@arm.com \
    --cc=Richard.Earnshaw@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=kyrylo.tkachov@arm.com \
    --cc=richard.sandiford@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).