diff options
author | Martin Liska <mliska@suse.cz> | 2019-05-09 15:03:45 +0200 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2019-05-09 13:03:45 +0000 |
commit | fd4485aa04b5db3f0fc367ce7aefc8431112e1a1 (patch) | |
tree | a5b080e2a38e8e3f6ee9397c56ddd2b383f6dab8 /gcc/c | |
parent | d276406ac1e7fc7f9c380325c994cf477b3d6fb8 (diff) | |
download | gcc-fd4485aa04b5db3f0fc367ce7aefc8431112e1a1.zip gcc-fd4485aa04b5db3f0fc367ce7aefc8431112e1a1.tar.gz gcc-fd4485aa04b5db3f0fc367ce7aefc8431112e1a1.tar.bz2 |
Support {MIN,MAX}_EXPR in GIMPLE FE.
2019-05-09 Martin Liska <mliska@suse.cz>
* gimple-pretty-print.c (dump_binary_rhs): Dump MIN_EXPR
and MAX_EXPR in GIMPLE FE format.
2019-05-09 Martin Liska <mliska@suse.cz>
* gimple-parser.c (c_parser_gimple_statement): Support __MIN and
__MAX.
(c_parser_gimple_unary_expression): Parse also binary expression
__MIN and __MAX.
(c_parser_gimple_parentized_binary_expression): New function.
2019-05-09 Martin Liska <mliska@suse.cz>
* gcc.dg/gimplefe-39.c: New test.
From-SVN: r271035
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/c/gimple-parser.c | 38 |
2 files changed, 45 insertions, 1 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 67f0e08..cb8bfcb 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,5 +1,13 @@ 2019-05-09 Martin Liska <mliska@suse.cz> + * gimple-parser.c (c_parser_gimple_statement): Support __MIN and + __MAX. + (c_parser_gimple_unary_expression): Parse also binary expression + __MIN and __MAX. + (c_parser_gimple_parentized_binary_expression): New function. + +2019-05-09 Martin Liska <mliska@suse.cz> + * gimple-parser.c (struct gimple_parser): Add probability. for gimple_parser_edge. (gimple_parser::push_edge): Add new argument probability. diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c index ede5a92..99f7647 100644 --- a/gcc/c/gimple-parser.c +++ b/gcc/c/gimple-parser.c @@ -750,7 +750,9 @@ c_parser_gimple_statement (gimple_parser &parser, gimple_seq *seq) { tree id = c_parser_peek_token (parser)->value; if (strcmp (IDENTIFIER_POINTER (id), "__ABS") == 0 - || strcmp (IDENTIFIER_POINTER (id), "__ABSU") == 0) + || strcmp (IDENTIFIER_POINTER (id), "__ABSU") == 0 + || strcmp (IDENTIFIER_POINTER (id), "__MIN") == 0 + || strcmp (IDENTIFIER_POINTER (id), "__MAX") == 0) goto build_unary_expr; break; } @@ -989,6 +991,32 @@ c_parser_gimple_binary_expression (gimple_parser &parser) return ret; } +/* Parse a gimple parentized binary expression. */ + +static c_expr +c_parser_gimple_parentized_binary_expression (gimple_parser &parser, + location_t op_loc, + tree_code code) +{ + struct c_expr ret; + ret.set_error (); + + c_parser_consume_token (parser); + if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) + return ret; + c_expr op1 = c_parser_gimple_postfix_expression (parser); + if (!c_parser_require (parser, CPP_COMMA, "expected %<,%>")) + return ret; + c_expr op2 = c_parser_gimple_postfix_expression (parser); + if (!c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>")) + return ret; + + if (op1.value != error_mark_node && op2.value != error_mark_node) + ret.value = build2_loc (op_loc, + code, TREE_TYPE (op1.value), op1.value, op2.value); + return ret; +} + /* Parse gimple unary expression. gimple-unary-expression: @@ -1078,6 +1106,14 @@ c_parser_gimple_unary_expression (gimple_parser &parser) op = c_parser_gimple_postfix_expression (parser); return parser_build_unary_op (op_loc, ABSU_EXPR, op); } + else if (strcmp (IDENTIFIER_POINTER (id), "__MIN") == 0) + return c_parser_gimple_parentized_binary_expression (parser, + op_loc, + MIN_EXPR); + else if (strcmp (IDENTIFIER_POINTER (id), "__MAX") == 0) + return c_parser_gimple_parentized_binary_expression (parser, + op_loc, + MAX_EXPR); else return c_parser_gimple_postfix_expression (parser); } |