From 186dabf2926eb049e9a954dae6fa765687dc353c Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 15 May 2019 12:51:58 +0000 Subject: [PATCH] gimple-parser.c (c_parser_gimple_postfix_expression): Handle __BIT_FIELD_REF. 2019-05-15 Richard Biener 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 | 5 ++++ gcc/c/ChangeLog | 5 ++++ gcc/c/gimple-parser.c | 37 +++++++++++++++++++++++++++ gcc/testsuite/ChangeLog | 4 +++ gcc/testsuite/gcc.dg/gimplefe-40.c | 12 ++++++--- gcc/tree-pretty-print.c | 40 ++++++++++++++++++++++++------ 6 files changed, 93 insertions(+), 10 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fe85101e435..8ef2c8240be 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2019-05-15 Richard Biener + + * tree-pretty-print.c (dump_generic_node): Dump BIT_FIELD_REF + as __BIT_FIELD_REF with type with -gimple. + 2019-05-15 Vladislav Ivanishin * tree-ssa-uninit.c (is_value_included_in): Remove is_unsigned and merge diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 493d5887f26..8b9465fd7c6 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2019-05-15 Richard Biener + + * gimple-parser.c (c_parser_gimple_postfix_expression): Handle + __BIT_FIELD_REF. + 2019-05-14 Richard Biener * gimple-parser.c (c_parser_gimple_statement): Remove diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c index 7c1f1a97711..07ec1e407b2 100644 --- a/gcc/c/gimple-parser.c +++ b/gcc/c/gimple-parser.c @@ -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 ) */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e569939c654..b7d63ed8210 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-05-15 Richard Biener + + * gcc.dg/gimplefe-40.c: Amend. + 2019-05-15 Iain Sandoe * lib/target-supports.exp diff --git a/gcc/testsuite/gcc.dg/gimplefe-40.c b/gcc/testsuite/gcc.dg/gimplefe-40.c index 0ad142f40dc..58a8ac5553e 100644 --- a/gcc/testsuite/gcc.dg/gimplefe-40.c +++ b/gcc/testsuite/gcc.dg/gimplefe-40.c @@ -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 (_3); - return _4; +#if __SIZEOF_FLOAT__ == 4 + _5 = __BIT_FIELD_REF (_4, 32, 64); +#else + _5 = 1.0f; +#endif + return _5; } diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c index 0af9c5debfa..6645a646617 100644 --- a/gcc/tree-pretty-print.c +++ b/gcc/tree-pretty-print.c @@ -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: -- 2.30.2