tree-pretty-print.c (dump_generic_node): Provide -gimple variant for MEM_REF.
2017-01-12 Richard Biener <rguenther@suse.de> * tree-pretty-print.c (dump_generic_node): Provide -gimple variant for MEM_REF. Sanitize INTEGER_CST for -gimple. c/ * gimple-parser.c (c_parser_gimple_postfix_expression): Parse __MEM. * gcc.dg/gimplefe-21.c: New testcase. From-SVN: r244350
This commit is contained in:
parent
ef9d56f8ac
commit
6bb4ea5cdf
@ -1,3 +1,8 @@
|
|||||||
|
2017-01-12 Richard Biener <rguenther@suse.de>
|
||||||
|
|
||||||
|
* tree-pretty-print.c (dump_generic_node): Provide -gimple
|
||||||
|
variant for MEM_REF. Sanitize INTEGER_CST for -gimple.
|
||||||
|
|
||||||
2017-01-12 Richard Biener <rguenther@suse.de>
|
2017-01-12 Richard Biener <rguenther@suse.de>
|
||||||
|
|
||||||
* tree.c (initialize_tree_contains_struct): Make TS_OPTIMIZATION
|
* tree.c (initialize_tree_contains_struct): Make TS_OPTIMIZATION
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2017-01-12 Richard Biener <rguenther@suse.de>
|
||||||
|
|
||||||
|
* gimple-parser.c (c_parser_gimple_postfix_expression): Parse
|
||||||
|
__MEM.
|
||||||
|
|
||||||
2017-01-11 Jakub Jelinek <jakub@redhat.com>
|
2017-01-11 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
PR c++/72813
|
PR c++/72813
|
||||||
|
@ -727,6 +727,79 @@ c_parser_gimple_postfix_expression (c_parser *parser)
|
|||||||
if (c_parser_peek_token (parser)->id_kind == C_ID_ID)
|
if (c_parser_peek_token (parser)->id_kind == C_ID_ID)
|
||||||
{
|
{
|
||||||
tree id = c_parser_peek_token (parser)->value;
|
tree id = c_parser_peek_token (parser)->value;
|
||||||
|
if (strcmp (IDENTIFIER_POINTER (id), "__MEM") == 0)
|
||||||
|
{
|
||||||
|
/* __MEM '<' type-name [ ',' number ] '>'
|
||||||
|
'(' [ '(' type-name ')' ] unary-expression
|
||||||
|
[ '+' number ] ')' */
|
||||||
|
location_t loc = c_parser_peek_token (parser)->location;
|
||||||
|
c_parser_consume_token (parser);
|
||||||
|
struct c_type_name *type_name = NULL;
|
||||||
|
tree alignment = NULL_TREE;
|
||||||
|
if (c_parser_require (parser, CPP_LESS, "expected %<<%>"))
|
||||||
|
{
|
||||||
|
type_name = c_parser_type_name (parser);
|
||||||
|
/* Optional alignment. */
|
||||||
|
if (c_parser_next_token_is (parser, CPP_COMMA))
|
||||||
|
{
|
||||||
|
c_parser_consume_token (parser);
|
||||||
|
alignment
|
||||||
|
= c_parser_gimple_postfix_expression (parser).value;
|
||||||
|
}
|
||||||
|
c_parser_skip_until_found (parser,
|
||||||
|
CPP_GREATER, "expected %<>%>");
|
||||||
|
}
|
||||||
|
struct c_expr ptr;
|
||||||
|
ptr.value = error_mark_node;
|
||||||
|
tree alias_off = NULL_TREE;
|
||||||
|
if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
|
||||||
|
{
|
||||||
|
tree alias_type = NULL_TREE;
|
||||||
|
/* Optional alias-type cast. */
|
||||||
|
if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
|
||||||
|
{
|
||||||
|
c_parser_consume_token (parser);
|
||||||
|
struct c_type_name *alias_type_name
|
||||||
|
= c_parser_type_name (parser);
|
||||||
|
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
|
||||||
|
"expected %<)%>");
|
||||||
|
if (alias_type_name)
|
||||||
|
{
|
||||||
|
tree tem;
|
||||||
|
alias_type = groktypename (alias_type_name,
|
||||||
|
&tem, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ptr = c_parser_gimple_unary_expression (parser);
|
||||||
|
if (! alias_type)
|
||||||
|
alias_type = TREE_TYPE (ptr.value);
|
||||||
|
/* Optional constant offset. */
|
||||||
|
if (c_parser_next_token_is (parser, CPP_PLUS))
|
||||||
|
{
|
||||||
|
c_parser_consume_token (parser);
|
||||||
|
alias_off
|
||||||
|
= c_parser_gimple_postfix_expression (parser).value;
|
||||||
|
alias_off = fold_convert (alias_type, alias_off);
|
||||||
|
}
|
||||||
|
if (! alias_off)
|
||||||
|
alias_off = build_int_cst (alias_type, 0);
|
||||||
|
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
|
||||||
|
"expected %<)%>");
|
||||||
|
}
|
||||||
|
if (! type_name || c_parser_error (parser))
|
||||||
|
{
|
||||||
|
c_parser_set_error (parser, false);
|
||||||
|
return expr;
|
||||||
|
}
|
||||||
|
tree tem = NULL_TREE;
|
||||||
|
tree type = groktypename (type_name, &tem, NULL);
|
||||||
|
if (alignment)
|
||||||
|
type = build_aligned_type (type, tree_to_uhwi (alignment));
|
||||||
|
expr.value = build2_loc (loc, MEM_REF,
|
||||||
|
type, ptr.value, alias_off);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* SSA name. */
|
||||||
unsigned version, ver_offset;
|
unsigned version, ver_offset;
|
||||||
if (! lookup_name (id)
|
if (! lookup_name (id)
|
||||||
&& c_parser_parse_ssa_name_id (id, &version, &ver_offset))
|
&& c_parser_parse_ssa_name_id (id, &version, &ver_offset))
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
2017-01-12 Richard Biener <rguenther@suse.de>
|
||||||
|
|
||||||
|
* gcc.dg/gimplefe-21.c: New testcase.
|
||||||
|
|
||||||
2017-01-12 Michael Collison <michael.collison@arm.com>
|
2017-01-12 Michael Collison <michael.collison@arm.com>
|
||||||
|
|
||||||
* gcc.dg/zero_bits_compound-2.c: Fix test for aarch64.
|
* gcc.dg/zero_bits_compound-2.c: Fix test for aarch64.
|
||||||
|
19
gcc/testsuite/gcc.dg/gimplefe-21.c
Normal file
19
gcc/testsuite/gcc.dg/gimplefe-21.c
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/* { dg-do compile } */
|
||||||
|
/* { dg-options "-fgimple" } */
|
||||||
|
|
||||||
|
float __GIMPLE ()
|
||||||
|
foo (int * p)
|
||||||
|
{
|
||||||
|
float f;
|
||||||
|
float D1800;
|
||||||
|
unsigned int D1799;
|
||||||
|
|
||||||
|
D1799 = __MEM <unsigned int, 8> ((char *)p + 1);
|
||||||
|
__MEM <unsigned int, 16> ((char *)&f + 0xfffffffffffffffe) = D1799;
|
||||||
|
__MEM <int> (p) = 1;
|
||||||
|
__MEM <int, 2> (p) = 1;
|
||||||
|
__MEM <int> (p + 2) = 1;
|
||||||
|
__MEM <int> ((char *)p) = 1;
|
||||||
|
D1800 = f;
|
||||||
|
return D1800;
|
||||||
|
}
|
@ -1459,7 +1459,38 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, int flags,
|
|||||||
|
|
||||||
case MEM_REF:
|
case MEM_REF:
|
||||||
{
|
{
|
||||||
if (integer_zerop (TREE_OPERAND (node, 1))
|
if (flags & TDF_GIMPLE)
|
||||||
|
{
|
||||||
|
pp_string (pp, "__MEM <");
|
||||||
|
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, " (");
|
||||||
|
if (TREE_TYPE (TREE_OPERAND (node, 0))
|
||||||
|
!= TREE_TYPE (TREE_OPERAND (node, 1)))
|
||||||
|
{
|
||||||
|
pp_left_paren (pp);
|
||||||
|
dump_generic_node (pp, TREE_TYPE (TREE_OPERAND (node, 1)),
|
||||||
|
spc, flags | TDF_SLIM, false);
|
||||||
|
pp_right_paren (pp);
|
||||||
|
}
|
||||||
|
dump_generic_node (pp, TREE_OPERAND (node, 0),
|
||||||
|
spc, flags | TDF_SLIM, false);
|
||||||
|
if (! integer_zerop (TREE_OPERAND (node, 1)))
|
||||||
|
{
|
||||||
|
pp_string (pp, " + ");
|
||||||
|
dump_generic_node (pp, TREE_OPERAND (node, 1),
|
||||||
|
spc, flags | TDF_SLIM, false);
|
||||||
|
}
|
||||||
|
pp_right_paren (pp);
|
||||||
|
}
|
||||||
|
else if (integer_zerop (TREE_OPERAND (node, 1))
|
||||||
/* Dump the types of INTEGER_CSTs explicitly, for we can't
|
/* Dump the types of INTEGER_CSTs explicitly, for we can't
|
||||||
infer them and MEM_ATTR caching will share MEM_REFs
|
infer them and MEM_ATTR caching will share MEM_REFs
|
||||||
with differently-typed op0s. */
|
with differently-typed op0s. */
|
||||||
@ -1633,7 +1664,8 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, int flags,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case INTEGER_CST:
|
case INTEGER_CST:
|
||||||
if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE)
|
if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE
|
||||||
|
&& ! (flags & TDF_GIMPLE))
|
||||||
{
|
{
|
||||||
/* In the case of a pointer, one may want to divide by the
|
/* In the case of a pointer, one may want to divide by the
|
||||||
size of the pointed-to type. Unfortunately, this not
|
size of the pointed-to type. Unfortunately, this not
|
||||||
@ -1661,7 +1693,11 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, int flags,
|
|||||||
else if (tree_fits_shwi_p (node))
|
else if (tree_fits_shwi_p (node))
|
||||||
pp_wide_integer (pp, tree_to_shwi (node));
|
pp_wide_integer (pp, tree_to_shwi (node));
|
||||||
else if (tree_fits_uhwi_p (node))
|
else if (tree_fits_uhwi_p (node))
|
||||||
|
{
|
||||||
pp_unsigned_wide_integer (pp, tree_to_uhwi (node));
|
pp_unsigned_wide_integer (pp, tree_to_uhwi (node));
|
||||||
|
if (flags & TDF_GIMPLE)
|
||||||
|
pp_character (pp, 'U');
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wide_int val = node;
|
wide_int val = node;
|
||||||
|
Loading…
Reference in New Issue
Block a user