gimple-parser.c (c_parser_gimple_statement): Handle __BIT_INSERT.
authorRichard Biener <rguenther@suse.de>
Thu, 16 May 2019 08:01:09 +0000 (08:01 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 16 May 2019 08:01:09 +0000 (08:01 +0000)
2019-05-16  Richard Biener  <rguenther@suse.de>

c/
* gimple-parser.c (c_parser_gimple_statement): Handle __BIT_INSERT.
(c_parser_gimple_unary_expression): Likewise.

* gimple-pretty-print.c (dump_ternary_rhs): Dump BIT_INSERT_EXPR
as __BIT_INSERT with -gimple.

* gcc.dg/gimplefe-40.c: Amend again.

From-SVN: r271278

gcc/ChangeLog
gcc/c/ChangeLog
gcc/c/gimple-parser.c
gcc/gimple-pretty-print.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/gimplefe-40.c

index ddcd7e258cc57d3248b9ffaaba936b4aae18ecf9..b8c658d1c83a6ece1263dd4bcb7a5870a181ff00 100644 (file)
@@ -1,3 +1,8 @@
+2019-05-16  Richard Biener  <rguenther@suse.de>
+
+       * gimple-pretty-print.c (dump_ternary_rhs): Dump BIT_INSERT_EXPR
+       as __BIT_INSERT with -gimple.
+
 2019-05-15  Jakub Jelinek  <jakub@redhat.com>
 
        * omp-low.c (lower_rec_input_clauses): For if (0) or simdlen (1) set
index 8b9465fd7c65c6d5802c2695fec588f6f6221f41..c42d67a3e32ee92447306ec51034a2f2d3424594 100644 (file)
@@ -1,3 +1,8 @@
+2019-05-16  Richard Biener  <rguenther@suse.de>
+
+       * gimple-parser.c (c_parser_gimple_statement): Handle __BIT_INSERT.
+       (c_parser_gimple_unary_expression): Likewise.
+
 2019-05-15  Richard Biener  <rguenther@suse.de>
 
        * gimple-parser.c (c_parser_gimple_postfix_expression): Handle
index 07ec1e407b24d1411ba74c3a6ac406026728c8b2..6a15b99c215a3d152e0f6d30577cf54efbbaf845 100644 (file)
@@ -746,6 +746,7 @@ 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), "__BIT_INSERT") == 0
            || strcmp (IDENTIFIER_POINTER (id), "__MAX") == 0)
          goto build_unary_expr;
        break;
@@ -1108,6 +1109,37 @@ 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), "__BIT_INSERT") == 0)
+           {
+             /* __BIT_INSERT '(' postfix-expression, postfix-expression,
+                                 integer ')'  */
+             location_t loc = c_parser_peek_token (parser)->location;
+             c_parser_consume_token (parser);
+             if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
+               {
+                 c_expr op0 = c_parser_gimple_postfix_expression (parser);
+                 c_parser_skip_until_found (parser, CPP_COMMA,
+                                            "expected %<,%>");
+                 c_expr op1 = c_parser_gimple_postfix_expression (parser);
+                 c_parser_skip_until_found (parser, CPP_COMMA,
+                                            "expected %<,%>");
+                 c_expr op2 = c_parser_gimple_postfix_expression (parser);
+                 if (TREE_CODE (op2.value) != INTEGER_CST
+                     || !int_fits_type_p (op2.value, bitsizetype))
+                   c_parser_error (parser, "expected constant offset");
+                 c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
+                                            "expected %<)%>");
+                 if (op0.value != error_mark_node
+                     && op1.value != error_mark_node
+                     && TREE_CODE (op2.value) == INTEGER_CST)
+                   ret.value = build3_loc (loc, BIT_INSERT_EXPR,
+                                           TREE_TYPE (op0.value),
+                                           op0.value, op1.value,
+                                           fold_convert (bitsizetype,
+                                                         op2.value));
+               }
+             return ret;
+           }
          else
            return c_parser_gimple_postfix_expression (parser);
        }
index 58212c4dcc14334158a6f7d566b6a4bf838ea6c2..c1c08644638d6dd81f351d50a2e31aa9fb153d56 100644 (file)
@@ -567,21 +567,35 @@ dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc,
       break;
 
     case BIT_INSERT_EXPR:
-      pp_string (buffer, "BIT_INSERT_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_string (buffer, " (");
-      if (INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs2 (gs))))
-       pp_decimal_int (buffer,
-                       TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs2 (gs))));
+      if (flags & TDF_GIMPLE)
+       {
+         pp_string (buffer, "__BIT_INSERT (");
+         dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc,
+                            flags | TDF_SLIM, false);
+         pp_string (buffer, ", ");
+         dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc,
+                            flags | TDF_SLIM, false);
+         pp_string (buffer, ", ");
+         dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc,
+                            flags | TDF_SLIM, false);
+         pp_right_paren (buffer);
+       }
       else
-       dump_generic_node (buffer,
-                          TYPE_SIZE (TREE_TYPE (gimple_assign_rhs2 (gs))),
-                          spc, flags, false);
-      pp_string (buffer, " bits)>");
+       {
+         pp_string (buffer, "BIT_INSERT_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_string (buffer, " (");
+         if (INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs2 (gs))))
+           pp_decimal_int (buffer, TYPE_PRECISION
+                                     (TREE_TYPE (gimple_assign_rhs2 (gs))));
+       }
       break;
 
     default:
index 835963b8f033a9d6dc0ffe7a1cab59b6a1d465c9..2ca1d277804d9ce6bbf7c0f91afe4e3f48f4ff62 100644 (file)
@@ -1,3 +1,7 @@
+2019-05-16  Richard Biener  <rguenther@suse.de>
+
+       * gcc.dg/gimplefe-40.c: Amend again.
+
 2019-05-15  Cherry Zhang  <cherryyz@google.com>
 
        * go.test/test/nilptr2.go: Change use function to actually do
index 58a8ac5553e79dd5c83e805cbb7b4a3a61b38fd6..3939066d1b5908729e0dde745bf1e8df06d3bbd9 100644 (file)
@@ -1,12 +1,13 @@
 /* { dg-do compile { target int128 } } */
-/* { dg-options "-fgimple" } */
+/* { dg-options "-fgimple -Wno-psabi -w" } */
 
 typedef float v4sf __attribute__((vector_size(16)));
-float __GIMPLE (ssa)
+v4sf __GIMPLE (ssa)
 load (const void * p)
 {
   __int128 unsigned _3;
   v4sf _4;
+  v4sf _6;
   float _5;
 
   __BB(2):
@@ -17,5 +18,6 @@ load (const void * p)
 #else
   _5 = 1.0f;
 #endif
-  return _5;
+  _6 = __BIT_INSERT (_4, _5, 0);
+  return _6;
 }