gimple-parser.c (c_parser_gimple_postfix_expression): Handle __BIT_FIELD_REF.
authorRichard Biener <rguenther@suse.de>
Wed, 15 May 2019 12:51:58 +0000 (12:51 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 15 May 2019 12:51:58 +0000 (12:51 +0000)
2019-05-15  Richard Biener  <rguenther@suse.de>

c/
* gimple-parser.c (c_parser_gimple_postfix_expression): Handle
__BIT_FIELD_REF.

* tree-pretty-print.c (dump_generic_node): Dump BIT_FIELD_REF
as __BIT_FIELD_REF with type with -gimple.

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

From-SVN: r271208

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

index fe85101e4357481fa4c1c9f14e4427c92049b614..8ef2c8240be2c5992903490e9cb50e59d43564c4 100644 (file)
@@ -1,3 +1,8 @@
+2019-05-15  Richard Biener  <rguenther@suse.de>
+
+       * tree-pretty-print.c (dump_generic_node): Dump BIT_FIELD_REF
+       as __BIT_FIELD_REF with type with -gimple.
+
 2019-05-15  Vladislav Ivanishin  <vlad@ispras.ru>
 
        * tree-ssa-uninit.c (is_value_included_in): Remove is_unsigned and merge
index 493d5887f26213e917d107b5f6a59da6bd9d8ca8..8b9465fd7c65c6d5802c2695fec588f6f6221f41 100644 (file)
@@ -1,3 +1,8 @@
+2019-05-15  Richard Biener  <rguenther@suse.de>
+
+       * gimple-parser.c (c_parser_gimple_postfix_expression): Handle
+       __BIT_FIELD_REF.
+
 2019-05-14  Richard Biener  <rguenther@suse.de>
 
        * gimple-parser.c (c_parser_gimple_statement): Remove
index 7c1f1a97711b4a725a650d457badfe00820c57aa..07ec1e407b24d1411ba74c3a6ac406026728c8b2 100644 (file)
@@ -1415,6 +1415,43 @@ c_parser_gimple_postfix_expression (gimple_parser &parser)
                }
              break;
            }
+         else if (strcmp (IDENTIFIER_POINTER (id), "__BIT_FIELD_REF") == 0)
+           {
+             /* __BIT_FIELD_REF '<' type-name [ ',' number ] '>'
+                               '(' postfix-expression, integer, integer ')'  */
+             location_t loc = c_parser_peek_token (parser)->location;
+             c_parser_consume_token (parser);
+             tree type = c_parser_gimple_typespec (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);
+                 if (TREE_CODE (op1.value) != INTEGER_CST
+                     || !int_fits_type_p (op1.value, bitsizetype))
+                   c_parser_error (parser, "expected constant size");
+                 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 (type
+                     && op0.value != error_mark_node
+                     && TREE_CODE (op1.value) == INTEGER_CST
+                     && TREE_CODE (op2.value) == INTEGER_CST)
+                   expr.value = build3_loc (loc, BIT_FIELD_REF, type,
+                                            op0.value,
+                                            fold_convert (bitsizetype,
+                                                          op1.value),
+                                            fold_convert (bitsizetype,
+                                                          op2.value));
+               }
+             break;
+           }
          else if (strcmp (IDENTIFIER_POINTER (id), "_Literal") == 0)
            {
              /* _Literal '(' type-name ')' ( [ '-' ] constant | constructor ) */
index e569939c65458c25bb1606cc09de845d452a4f61..b7d63ed8210cf0eb45ac8d761fe07ad7c395114c 100644 (file)
@@ -1,3 +1,7 @@
+2019-05-15  Richard Biener  <rguenther@suse.de>
+
+       * gcc.dg/gimplefe-40.c: Amend.
+
 2019-05-15  Iain Sandoe  <iain@sandoe.co.uk>
 
        * lib/target-supports.exp 
index 0ad142f40dc0c285c79065732b247978daebc639..58a8ac5553e79dd5c83e805cbb7b4a3a61b38fd6 100644 (file)
@@ -1,15 +1,21 @@
 /* { dg-do compile { target int128 } } */
-/* { dg-options "-fgimple -Wno-psabi -w" } */
+/* { dg-options "-fgimple" } */
 
 typedef float v4sf __attribute__((vector_size(16)));
-v4sf __GIMPLE (ssa)
+float __GIMPLE (ssa)
 load (const void * p)
 {
   __int128 unsigned _3;
   v4sf _4;
+  float _5;
 
   __BB(2):
   _3 = __MEM <__int128 unsigned, 8> ((char *)p_2(D));
   _4 = __VIEW_CONVERT <v4sf>(_3);
-  return _4;
+#if __SIZEOF_FLOAT__ == 4
+  _5 = __BIT_FIELD_REF <float> (_4, 32, 64);
+#else
+  _5 = 1.0f;
+#endif
+  return _5;
 }
index 0af9c5debfaaa94fcd88573beae5f95eab4cb466..6645a6466171e38f453501cfe2004267d32000f8 100644 (file)
@@ -2111,13 +2111,39 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags,
       break;
 
     case BIT_FIELD_REF:
-      pp_string (pp, "BIT_FIELD_REF <");
-      dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
-      pp_string (pp, ", ");
-      dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
-      pp_string (pp, ", ");
-      dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
-      pp_greater (pp);
+      if (flags & TDF_GIMPLE)
+       {
+         pp_string (pp, "__BIT_FIELD_REF <");
+         dump_generic_node (pp, TREE_TYPE (node),
+                            spc, flags | TDF_SLIM, false);
+         if (TYPE_ALIGN (TREE_TYPE (node))
+             != TYPE_ALIGN (TYPE_MAIN_VARIANT (TREE_TYPE (node))))
+           {
+             pp_string (pp, ", ");
+             pp_decimal_int (pp, TYPE_ALIGN (TREE_TYPE (node)));
+           }
+         pp_greater (pp);
+         pp_string (pp, " (");
+         dump_generic_node (pp, TREE_OPERAND (node, 0), spc,
+                            flags | TDF_SLIM, false);
+         pp_string (pp, ", ");
+         dump_generic_node (pp, TREE_OPERAND (node, 1), spc,
+                            flags | TDF_SLIM, false);
+         pp_string (pp, ", ");
+         dump_generic_node (pp, TREE_OPERAND (node, 2), spc,
+                            flags | TDF_SLIM, false);
+         pp_right_paren (pp);
+       }
+      else
+       {
+         pp_string (pp, "BIT_FIELD_REF <");
+         dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
+         pp_string (pp, ", ");
+         dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
+         pp_string (pp, ", ");
+         dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
+         pp_greater (pp);
+       }
       break;
 
     case BIT_INSERT_EXPR: