From: Richard Biener Date: Fri, 5 Dec 2025 09:29:07 +0000 (+0100) Subject: Add clique/base parsing and dumping to the GIMPLE FE X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=82305f37dbedaded25014d3f45736e503d564bb2;p=thirdparty%2Fgcc.git Add clique/base parsing and dumping to the GIMPLE FE 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. --- diff --git a/gcc/c/gimple-parser.cc b/gcc/c/gimple-parser.cc index d4c5001623e..52819a6587f 100644 --- a/gcc/c/gimple-parser.cc +++ b/gcc/c/gimple-parser.cc @@ -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 index 00000000000..b209ab6d546 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gimplefe-58.c @@ -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 (q_3(D), 1:0); + __MEM ((int *)p_5(D), 1 :1) = 1; + _1 = __MEM (q_3(D), 1: 0); + _7 = _1 + x_4; + return _7; +} diff --git a/gcc/tree-pretty-print.cc b/gcc/tree-pretty-print.cc index ba04911ae90..12e09320683 100644 --- a/gcc/tree-pretty-print.cc +++ b/gcc/tree-pretty-print.cc @@ -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