diff options
author | Richard Biener <rguenther@suse.de> | 2017-01-12 08:33:09 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2017-01-12 08:33:09 +0000 |
commit | 6bb4ea5cdf9664f2cec861a2a120192b4ac04d1f (patch) | |
tree | 8d757072a4d9f57d69894171f684fe4872d9d218 /gcc | |
parent | ef9d56f8acf5f46e30d46836095fb920759a2084 (diff) | |
download | gcc-6bb4ea5cdf9664f2cec861a2a120192b4ac04d1f.zip gcc-6bb4ea5cdf9664f2cec861a2a120192b4ac04d1f.tar.gz gcc-6bb4ea5cdf9664f2cec861a2a120192b4ac04d1f.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c/gimple-parser.c | 73 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/gimplefe-21.c | 19 | ||||
-rw-r--r-- | gcc/tree-pretty-print.c | 42 |
6 files changed, 145 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 20da953..012c095 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 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> + * tree.c (initialize_tree_contains_struct): Make TS_OPTIMIZATION and TS_TARGET_OPTION directly derive from TS_BASE. * tree-core.h (tree_optimization_option): Derive from tree_base. diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 341407a..65531aa 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -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> PR c++/72813 diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c index 37e792a..ee8a01a 100644 --- a/gcc/c/gimple-parser.c +++ b/gcc/c/gimple-parser.c @@ -727,6 +727,79 @@ c_parser_gimple_postfix_expression (c_parser *parser) if (c_parser_peek_token (parser)->id_kind == C_ID_ID) { 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; if (! lookup_name (id) && c_parser_parse_ssa_name_id (id, &version, &ver_offset)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b10c036..561bd3f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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> * gcc.dg/zero_bits_compound-2.c: Fix test for aarch64. diff --git a/gcc/testsuite/gcc.dg/gimplefe-21.c b/gcc/testsuite/gcc.dg/gimplefe-21.c new file mode 100644 index 0000000..55ea0b8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gimplefe-21.c @@ -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; +} diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c index 36b29d5..87b4044 100644 --- a/gcc/tree-pretty-print.c +++ b/gcc/tree-pretty-print.c @@ -1459,7 +1459,38 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, int flags, 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 infer them and MEM_ATTR caching will share MEM_REFs with differently-typed op0s. */ @@ -1633,7 +1664,8 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, int flags, break; 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 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)) pp_wide_integer (pp, tree_to_shwi (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 { wide_int val = node; |