Commit 330a968c by Richard Biener Committed by Richard Biener

genmatch.c (c_expr::gen_transform): Emit newlines from line number changes…

genmatch.c (c_expr::gen_transform): Emit newlines from line number changes rather than after every semicolon.

2019-12-06  Richard Biener  <rguenther@suse.de>

	* genmatch.c (c_expr::gen_transform): Emit newlines from line
	number changes rather than after every semicolon.

From-SVN: r279034
parent 2ef27856
2019-12-06 Richard Biener <rguenther@suse.de>
* genmatch.c (c_expr::gen_transform): Emit newlines from line
number changes rather than after every semicolon.
2019-12-06 Richard Biener <rguenther@suse.de>
PR tree-optimization/92819
* match.pd (VEC_PERM_EXPR -> BIT_INSERT_EXPR): Handle inserts
into the last lane. For two-element vectors try inserting
......@@ -2599,10 +2599,22 @@ c_expr::gen_transform (FILE *f, int indent, const char *dest,
fprintf_indent (f, indent, "%s = ", dest);
unsigned stmt_nr = 1;
int prev_line = -1;
for (unsigned i = 0; i < code.length (); ++i)
{
const cpp_token *token = &code[i];
/* We can't recover from all lexing losses but we can roughly restore line
breaks from location info. */
const line_map_ordinary *map;
linemap_resolve_location (line_table, token->src_loc,
LRK_SPELLING_LOCATION, &map);
expanded_location loc = linemap_expand_location (line_table, map,
token->src_loc);
if (prev_line != -1 && loc.line != prev_line)
fputc ('\n', f);
prev_line = loc.line;
/* Replace captures for code-gen. */
if (token->type == CPP_ATSIGN)
{
......@@ -2653,11 +2665,11 @@ c_expr::gen_transform (FILE *f, int indent, const char *dest,
if (token->type == CPP_SEMICOLON)
{
stmt_nr++;
fputc ('\n', f);
if (dest && stmt_nr == nr_stmts)
fprintf_indent (f, indent, "%s = ", dest);
}
}
fputc ('\n', f);
}
/* Generate transform code for a capture. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment