]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add clique/base parsing and dumping to the GIMPLE FE
authorRichard Biener <rguenther@suse.de>
Fri, 5 Dec 2025 09:29:07 +0000 (10:29 +0100)
committerRichard Biener <rguenther@suse.de>
Fri, 5 Dec 2025 10:47:10 +0000 (11:47 +0100)
The following adds clique/base on __MEM to the GIMPLE parser and
to -gimple dumping.

gcc/c/
* gimple-parser.cc (c_parser_gimple_postfix_expression):
Parse optional clique : base specifier on __MEM.

gcc/
* tree-pretty-print.cc (dump_mem_ref): Dump clique : base
specifier for MEM_REF and TARGET_MEM_REF when dumping
GIMPLE format.

gcc/testsuite/
* gcc.dg/gimplefe-58.c: New testcase.

gcc/c/gimple-parser.cc
gcc/testsuite/gcc.dg/gimplefe-58.c [new file with mode: 0644]
gcc/tree-pretty-print.cc

index d4c5001623e82ffe83ee4e1ecd1e1edad443e8f1..52819a6587f78b64af6a7574e7f4398defab95b3 100644 (file)
@@ -1529,7 +1529,8 @@ c_parser_gimple_postfix_expression (gimple_parser &parser)
            {
              /* __MEM '<' type-name [ ',' number ] '>'
                       '(' [ '(' type-name ')' ] unary-expression
-                          [ '+' number ] ')'  */
+                          [ '+' number ]
+                          [ ',' number ':' number ] ')'  */
              location_t loc = c_parser_peek_token (parser)->location;
              c_parser_consume_token (parser);
              tree type = c_parser_gimple_typespec (parser);
@@ -1539,6 +1540,8 @@ c_parser_gimple_postfix_expression (gimple_parser &parser)
              step.value = NULL_TREE;
              index.value = NULL_TREE;
              index2.value = NULL_TREE;
+             unsigned short clique = 0;
+             unsigned short base = 0;
              if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
                {
                  tree alias_type = NULL_TREE;
@@ -1620,6 +1623,27 @@ c_parser_gimple_postfix_expression (gimple_parser &parser)
                                  "expected constant step for %<__MEM%> "
                                  "operand");
                    }
+                 if (c_parser_next_token_is (parser, CPP_COMMA))
+                   {
+                     struct c_expr cl, ba;
+                     c_parser_consume_token (parser);
+                     cl = c_parser_gimple_postfix_expression (parser);
+                     if (c_parser_require (parser,
+                                           CPP_COLON, "expected %<:%>"))
+                       {
+                         ba = c_parser_gimple_postfix_expression (parser);
+                         if (!tree_fits_uhwi_p (cl.value)
+                             || !tree_fits_uhwi_p (ba.value)
+                             || compare_tree_int (cl.value,
+                                                  (clique = tree_to_uhwi
+                                                               (cl.value)))
+                             || compare_tree_int (ba.value,
+                                                  (base = tree_to_uhwi
+                                                                (ba.value))))
+                           error_at (cl.get_start (),
+                                     "invalid clique/base pair");
+                       }
+                   }
                  c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
                                             "expected %<)%>");
                }
@@ -1635,6 +1659,12 @@ c_parser_gimple_postfix_expression (gimple_parser &parser)
              else
                expr.value = build2_loc (loc, MEM_REF,
                                         type, ptr.value, alias_off.value);
+             if (clique != 0)
+               {
+                 cfun->last_clique = MAX (cfun->last_clique, clique);
+                 MR_DEPENDENCE_CLIQUE (expr.value) = clique;
+                 MR_DEPENDENCE_BASE (expr.value) = base;
+               }
              break;
            }
          else if (strcmp (IDENTIFIER_POINTER (id), "__VIEW_CONVERT") == 0)
diff --git a/gcc/testsuite/gcc.dg/gimplefe-58.c b/gcc/testsuite/gcc.dg/gimplefe-58.c
new file mode 100644 (file)
index 0000000..b209ab6
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-fgimple" } */
+
+int __GIMPLE (ssa)
+foo (int * restrict p, int * q)
+{
+  int x;
+  int _1;
+  int _7;
+
+  __BB(2):
+  x_4 = __MEM <int> (q_3(D), 1:0);
+  __MEM <int> ((int *)p_5(D), 1 :1) = 1;
+  _1 = __MEM <int> (q_3(D), 1: 0);
+  _7 = _1 + x_4;
+  return _7;
+}
index ba04911ae905c7bdf7702ece3184f4e152cd1a45..12e093206833b88e8d271b104fc6f63d8468a0a7 100644 (file)
@@ -2004,6 +2004,13 @@ dump_mem_ref (pretty_printer *pp, tree node, int spc, dump_flags_t flags)
                                 spc, flags | TDF_SLIM, false);
            }
        }
+      if (MR_DEPENDENCE_CLIQUE (node) != 0)
+       {
+         pp_string (pp, ", ");
+         pp_decimal_int (pp, MR_DEPENDENCE_CLIQUE (node));
+         pp_colon (pp);
+         pp_decimal_int (pp, MR_DEPENDENCE_BASE (node));
+       }
       pp_right_paren (pp);
     }
   else if (TREE_CODE (node) == MEM_REF