gimple-parser.c (c_parser_gimple_statement): Handle __VEC_PERM.
authorRichard Biener <rguenther@suse.de>
Fri, 17 May 2019 12:04:21 +0000 (12:04 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 17 May 2019 12:04:21 +0000 (12:04 +0000)
2019-05-17  Richard Biener  <rguenther@suse.de>

c/
* gimple-parser.c (c_parser_gimple_statement): Handle __VEC_PERM.
(c_parser_gimple_unary_expression): Likewise.
(c_parser_gimple_parentized_ternary_expression): New function.

* gimple-pretty-print.c (dump_ternary_rhs): Handle dumping
VEC_PERM_EXPR as __VEC_PERM with -gimple.

* gcc.dg/gimplefe-41.c: New testcase.

From-SVN: r271320

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

index 4f4711177cf8a03e1eff5b44b14a3ae74bda117b..16b67c49da818f8bc42ec3c066fbbca90e90fd87 100644 (file)
@@ -1,3 +1,8 @@
+2019-05-17  Richard Biener  <rguenther@suse.de>
+
+       * gimple-pretty-print.c (dump_ternary_rhs): Handle dumping
+       VEC_PERM_EXPR as __VEC_PERM with -gimple.
+
 2019-05-17  Andreas Krebbel  <krebbel@linux.ibm.com>
 
        * config/s390/s390-builtins.def (s390_vec_sldw_*): Use the
index c42d67a3e32ee92447306ec51034a2f2d3424594..863fabfffdd032ea06a526fd7db2bf659de71883 100644 (file)
@@ -1,3 +1,9 @@
+2019-05-17  Richard Biener  <rguenther@suse.de>
+
+       * gimple-parser.c (c_parser_gimple_statement): Handle __VEC_PERM.
+       (c_parser_gimple_unary_expression): Likewise.
+       (c_parser_gimple_parentized_ternary_expression): New function.
+
 2019-05-16  Richard Biener  <rguenther@suse.de>
 
        * gimple-parser.c (c_parser_gimple_statement): Handle __BIT_INSERT.
index 6a15b99c215a3d152e0f6d30577cf54efbbaf845..275ad911d0867db570e1d14e179d1c50f73b1f79 100644 (file)
@@ -746,8 +746,9 @@ c_parser_gimple_statement (gimple_parser &parser, gimple_seq *seq)
        if (strcmp (IDENTIFIER_POINTER (id), "__ABS") == 0
            || strcmp (IDENTIFIER_POINTER (id), "__ABSU") == 0
            || strcmp (IDENTIFIER_POINTER (id), "__MIN") == 0
+           || strcmp (IDENTIFIER_POINTER (id), "__MAX") == 0
            || strcmp (IDENTIFIER_POINTER (id), "__BIT_INSERT") == 0
-           || strcmp (IDENTIFIER_POINTER (id), "__MAX") == 0)
+           || strcmp (IDENTIFIER_POINTER (id), "__VEC_PERM") == 0)
          goto build_unary_expr;
        break;
       }
@@ -1012,6 +1013,38 @@ c_parser_gimple_parentized_binary_expression (gimple_parser &parser,
   return ret;
 }
 
+/* Parse a gimple parentized binary expression.  */
+
+static c_expr
+c_parser_gimple_parentized_ternary_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_COMMA, "expected %<)%>"))
+    return ret;
+  c_expr op3 = 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
+      && op3.value != error_mark_node)
+    ret.value = build3_loc (op_loc,
+                           code, TREE_TYPE (op1.value),
+                           op1.value, op2.value, op3.value);
+  return ret;
+}
+
 /* Parse gimple unary expression.
 
    gimple-unary-expression:
@@ -1109,6 +1142,9 @@ c_parser_gimple_unary_expression (gimple_parser &parser)
            return c_parser_gimple_parentized_binary_expression (parser,
                                                                 op_loc,
                                                                 MAX_EXPR);
+         else if (strcmp (IDENTIFIER_POINTER (id), "__VEC_PERM") == 0)
+           return c_parser_gimple_parentized_ternary_expression
+                       (parser, op_loc, VEC_PERM_EXPR);
          else if (strcmp (IDENTIFIER_POINTER (id), "__BIT_INSERT") == 0)
            {
              /* __BIT_INSERT '(' postfix-expression, postfix-expression,
index c1c08644638d6dd81f351d50a2e31aa9fb153d56..10f79ea619e3ebfdcbe9f5159e174cf2bb08b7d8 100644 (file)
@@ -529,13 +529,19 @@ dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc,
       break;
     
     case VEC_PERM_EXPR:
-      pp_string (buffer, "VEC_PERM_EXPR <");
+      if (flags & TDF_GIMPLE)
+       pp_string (buffer, "__VEC_PERM (");
+      else
+       pp_string (buffer, "VEC_PERM_EXPR <");
       dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
       pp_string (buffer, ", ");
       dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
       pp_string (buffer, ", ");
       dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
-      pp_greater (buffer);
+      if (flags & TDF_GIMPLE)
+       pp_right_paren (buffer);
+      else
+       pp_greater (buffer);
       break;
 
     case REALIGN_LOAD_EXPR:
index 053a9492168e7d806e16a5a4db74375ceb98912d..650c25a89e52b41adb3c7dba814bfeefe9fdbb82 100644 (file)
@@ -1,3 +1,7 @@
+2019-05-17  Richard Biener  <rguenther@suse.de>
+
+       * gcc.dg/gimplefe-41.c: New testcase.
+
 2019-05-17  Jun Ma  <JunMa@linux.alibaba.com>
 
        PR tree-optimization/90106
diff --git a/gcc/testsuite/gcc.dg/gimplefe-41.c b/gcc/testsuite/gcc.dg/gimplefe-41.c
new file mode 100644 (file)
index 0000000..cd642d6
--- /dev/null
@@ -0,0 +1,39 @@
+/* { dg-do compile } */
+/* { dg-options "-fgimple -Wno-psabi -w" } */
+
+typedef double __v2df __attribute__ ((__vector_size__ (16)));
+typedef unsigned long __v2di __attribute__ ((__vector_size__ (16)));
+
+__v2df __GIMPLE (ssa)
+_mm_add_sd (__v2df x, __v2df y)
+{
+  __v2df z;
+  double _1;
+  double _2;
+  double _3;
+  __v2df _7;
+
+  __BB(2):
+  _1 = __BIT_FIELD_REF <double> (x_4(D), 64u, 0u);
+  _2 = __BIT_FIELD_REF <double> (y_5(D), 64u, 0u);
+  _3 = _1 + _2;
+  _7 = _Literal (__v2df) {_3, _3};
+  z_6 = __VEC_PERM (x_4(D), _7, _Literal (__v2di) { 2ul, 1ul });
+  return z_6;
+}
+
+__v2df __GIMPLE (ssa)
+_mm_add_sd2 (__v2df x, __v2df y)
+{
+  __v2df z;
+  double _1;
+  double _2;
+  double _3;
+
+  __BB(2):
+  _1 = __BIT_FIELD_REF <double> (x_4(D), 64u, 0u);
+  _2 = __BIT_FIELD_REF <double> (y_5(D), 64u, 0u);
+  _3 = _1 + _2;
+  z_6 = __BIT_INSERT (x_4(D), _3, 0);
+  return z_6;
+}