summaryrefslogtreecommitdiff
path: root/0153-Backport-SME-recog-Improve-parser-for-pattern-new-co.patch
blob: 1302ea137742a332450a39fc80b8471b184fe77d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
From 35b64175c6fd622212d0bf936e7e98c635e1c618 Mon Sep 17 00:00:00 2001
From: Richard Sandiford <richard.sandiford@arm.com>
Date: Wed, 13 Sep 2023 14:50:30 +0100
Subject: [PATCH 054/157] [Backport][SME] recog: Improve parser for pattern new
 compact syntax

Reference: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=dd1091fe455c1ede5993b4cdf10d0f7c461b86d7

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 23c61dcdd..97c614850 100644
--- a/gcc/gensupport.cc
+++ b/gcc/gensupport.cc
@@ -895,19 +895,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 == ';')
@@ -950,13 +937,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);
 
@@ -1026,6 +1013,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.33.0