gimple-pretty-print.c (dump_unary_rhs): Adjust dump format for ABS_EXPR for gimple...
authorPrathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
Tue, 14 Feb 2017 09:21:01 +0000 (09:21 +0000)
committerPrathamesh Kulkarni <prathamesh3492@gcc.gnu.org>
Tue, 14 Feb 2017 09:21:01 +0000 (09:21 +0000)
2017-02-14  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>

* 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
gcc/c/ChangeLog
gcc/c/gimple-parser.c
gcc/gimple-pretty-print.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/gimplefe-25.c [new file with mode: 0644]

index 8abe8c592ce1be05902f4d6977f0f3021c4330e5..4a0d7134c2885a44bdc5fc69752af1e6271a394d 100644 (file)
@@ -1,3 +1,8 @@
+2017-02-14  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>
+
+       * gimple-pretty-print.c (dump_unary_rhs): Adjust dump format for
+       ABS_EXPR for gimple dump.
+
 2017-02-14  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/79462
index 3fe285e873c1346175b92ba6fe3ee865fa8c8f34..3e585b0e4ca9c81975c6a877da488c7466c55392 100644 (file)
@@ -1,3 +1,8 @@
+2017-02-14  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>
+
+       * gimpler-parser.c (c_parser_gimple_statement): Handle ABS_EXPR.
+       (c_parser_gimple_unary_expression): Likewise.
+
 2017-02-13  Jakub Jelinek  <jakub@redhat.com>
 
        * c-parser.c (c_parser_oacc_declare): Add missing space in
index 711cb3daf87ab91fdc6ef1816b3fc2a6e4959c5d..d95987796e0ef55a5470a7615d60e364b73a7e1b 100644 (file)
@@ -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);
     }
index 91c839d327dd83e469ca647d55f900300dc0ea24..0033e97e80fac933933279872e692d8041721b21 100644 (file)
@@ -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:
index 105444ed5a1979f4e26b8b8294d36ea3c502cfe6..cc10fd4c8386311ee89406aa92542dd9dc5fa417 100644 (file)
@@ -1,3 +1,7 @@
+2017-02-14  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>
+
+       * gcc.dg/gimplefe-25.c: New test.
+
 2017-02-14  Jakub Jelinek  <jakub@redhat.com>
 
        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 (file)
index 0000000..d8c44a7
--- /dev/null
@@ -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" } } */