From 1be33173de27a37c1efdb814fd26e421f667579a Mon Sep 17 00:00:00 2001 From: Prathamesh Kulkarni Date: Tue, 14 Feb 2017 09:21:01 +0000 Subject: [PATCH] gimple-pretty-print.c (dump_unary_rhs): Adjust dump format for ABS_EXPR for gimple dump. 2017-02-14 Prathamesh Kulkarni * gimple-pretty-print.c (dump_unary_rhs): Adjust dump format for ABS_EXPR for gimple dump. c/ * gimpler-parser.c (c_parser_gimple_statement): Handle ABS_EXPR. (c_parser_gimple_unary_expression): Likewise. testsuite/ * gcc.dg/gimplefe-25.c: New test. From-SVN: r245422 --- gcc/ChangeLog | 5 +++++ gcc/c/ChangeLog | 5 +++++ gcc/c/gimple-parser.c | 22 +++++++++++++++++++++- gcc/gimple-pretty-print.c | 14 +++++++++++--- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.dg/gimplefe-25.c | 11 +++++++++++ 6 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/gimplefe-25.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8abe8c592ce..4a0d7134c28 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-02-14 Prathamesh Kulkarni + + * gimple-pretty-print.c (dump_unary_rhs): Adjust dump format for + ABS_EXPR for gimple dump. + 2017-02-14 Jakub Jelinek PR target/79462 diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 3fe285e873c..3e585b0e4ca 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2017-02-14 Prathamesh Kulkarni + + * gimpler-parser.c (c_parser_gimple_statement): Handle ABS_EXPR. + (c_parser_gimple_unary_expression): Likewise. + 2017-02-13 Jakub Jelinek * c-parser.c (c_parser_oacc_declare): Add missing space in diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c index 711cb3daf87..d95987796e0 100644 --- a/gcc/c/gimple-parser.c +++ b/gcc/c/gimple-parser.c @@ -325,6 +325,13 @@ c_parser_gimple_statement (c_parser *parser, gimple_seq *seq) /* Unary expression. */ switch (c_parser_peek_token (parser)->type) { + case CPP_NAME: + { + tree id = c_parser_peek_token (parser)->value; + if (strcmp (IDENTIFIER_POINTER (id), "__ABS") == 0) + goto build_unary_expr; + break; + } case CPP_KEYWORD: if (c_parser_peek_token (parser)->keyword != RID_REALPART && c_parser_peek_token (parser)->keyword != RID_IMAGPART) @@ -336,6 +343,7 @@ c_parser_gimple_statement (c_parser *parser, gimple_seq *seq) case CPP_COMPL: case CPP_NOT: case CPP_MULT: /* pointer deref */ + build_unary_expr: rhs = c_parser_gimple_unary_expression (parser); if (rhs.value != error_mark_node) { @@ -536,7 +544,7 @@ c_parser_gimple_binary_expression (c_parser *parser) unary-operator gimple-postfix-expression unary-operator: one of - & * + - ~ + & * + - ~ abs_expr */ static c_expr @@ -600,6 +608,18 @@ c_parser_gimple_unary_expression (c_parser *parser) default: return c_parser_gimple_postfix_expression (parser); } + case CPP_NAME: + { + tree id = c_parser_peek_token (parser)->value; + if (strcmp (IDENTIFIER_POINTER (id), "__ABS") == 0) + { + c_parser_consume_token (parser); + op = c_parser_gimple_postfix_expression (parser); + return parser_build_unary_op (op_loc, ABS_EXPR, op); + } + else + return c_parser_gimple_postfix_expression (parser); + } default: return c_parser_gimple_postfix_expression (parser); } diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c index 91c839d327d..0033e97e80f 100644 --- a/gcc/gimple-pretty-print.c +++ b/gcc/gimple-pretty-print.c @@ -323,9 +323,17 @@ dump_unary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags) break; case ABS_EXPR: - pp_string (buffer, "ABS_EXPR <"); - dump_generic_node (buffer, rhs, spc, flags, false); - pp_greater (buffer); + if (flags & TDF_GIMPLE) + { + pp_string (buffer, "__ABS "); + dump_generic_node (buffer, rhs, spc, flags, false); + } + else + { + pp_string (buffer, "ABS_EXPR <"); + dump_generic_node (buffer, rhs, spc, flags, false); + pp_greater (buffer); + } break; default: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 105444ed5a1..cc10fd4c838 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-02-14 Prathamesh Kulkarni + + * gcc.dg/gimplefe-25.c: New test. + 2017-02-14 Jakub Jelinek PR tree-optimization/79408 diff --git a/gcc/testsuite/gcc.dg/gimplefe-25.c b/gcc/testsuite/gcc.dg/gimplefe-25.c new file mode 100644 index 00000000000..d8c44a74013 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gimplefe-25.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fgimple -fdump-tree-ssa-gimple" } */ + +int __GIMPLE() f(int a) +{ + int t0; + t0_1 = __ABS a; + return t0_1; +} + +/* { dg-final { scan-tree-dump "__ABS a" "ssa" } } */ -- 2.30.2