Revert "gas: have scrubber retain more whitespace"

This reverts commit 6ae8a30d44.

This fixes PR gas/32073.
This commit is contained in:
H.J. Lu
2024-08-12 08:43:21 -07:00
parent 65d41fb015
commit 87582defe7
26 changed files with 405 additions and 620 deletions

View File

@@ -1628,7 +1628,6 @@ m32c_cgen_build_insn_regex (CGEN_INSN *insn)
char rxbuf[CGEN_MAX_RX_ELEMENTS];
char *rx = rxbuf;
const CGEN_SYNTAX_CHAR_TYPE *syn;
char prev_syntax_char = 0;
int reg_err;
syn = CGEN_SYNTAX_STRING (CGEN_OPCODE_SYNTAX (opc));
@@ -1666,15 +1665,6 @@ m32c_cgen_build_insn_regex (CGEN_INSN *insn)
{
char c = CGEN_SYNTAX_CHAR (* syn);
/* See whitespace related comments in parse_insn_normal(). */
if (c != ' ' && prev_syntax_char != ' '
&& (!ISALNUM (c) || !ISALNUM (prev_syntax_char)))
{
*rx++ = ' ';
*rx++ = '*';
}
prev_syntax_char = c;
switch (c)
{
/* Escape any regex metacharacters in the syntax. */
@@ -1708,7 +1698,6 @@ m32c_cgen_build_insn_regex (CGEN_INSN *insn)
/* Replace non-syntax fields with globs. */
*rx++ = '.';
*rx++ = '*';
prev_syntax_char = 0;
}
}
@@ -1766,8 +1755,10 @@ parse_insn_normal (CGEN_CPU_DESC cd,
const char *errmsg;
const char *p;
const CGEN_SYNTAX_CHAR_TYPE * syn;
char prev_syntax_char = 0;
bool past_opcode_p;
#ifdef CGEN_MNEMONIC_OPERANDS
/* FIXME: wip */
int past_opcode_p;
#endif
/* For now we assume the mnemonic is first (there are no leading operands).
We can parse it without needing to set up operand parsing.
@@ -1783,13 +1774,13 @@ parse_insn_normal (CGEN_CPU_DESC cd,
#ifndef CGEN_MNEMONIC_OPERANDS
if (* str && ! ISSPACE (* str))
return _("unrecognized instruction");
past_opcode_p = true;
#else
past_opcode_p = false;
#endif
CGEN_INIT_PARSE (cd);
cgen_init_parse_operand (cd);
#ifdef CGEN_MNEMONIC_OPERANDS
past_opcode_p = 0;
#endif
/* We don't check for (*str != '\0') here because we want to parse
any trailing fake arguments in the syntax string. */
@@ -1803,28 +1794,18 @@ parse_insn_normal (CGEN_CPU_DESC cd,
while (* syn != 0)
{
char c = CGEN_SYNTAX_CHAR_P (*syn) ? CGEN_SYNTAX_CHAR (*syn) : 0;
/* FIXME: Despite this check we may still take inappropriate advantage of
the fact that GAS's input scrubber will remove extraneous whitespace.
We may also be a little too lax with this now, yet being more strict
would require targets to indicate where whitespace is permissible. */
if (past_opcode_p && c != ' ' && ISSPACE (*str)
/* No whitespace between consecutive alphanumeric syntax elements. */
&& (!ISALNUM (c) || !ISALNUM (prev_syntax_char)))
++str;
prev_syntax_char = c;
/* Non operand chars must match exactly. */
if (c != 0)
if (CGEN_SYNTAX_CHAR_P (* syn))
{
/* FIXME: While we allow for non-GAS callers above, we assume the
first char after the mnemonic part is a space. */
if (TOLOWER (*str) == TOLOWER (c))
/* FIXME: We also take inappropriate advantage of the fact that
GAS's input scrubber will remove extraneous blanks. */
if (TOLOWER (*str) == TOLOWER (CGEN_SYNTAX_CHAR (* syn)))
{
#ifdef CGEN_MNEMONIC_OPERANDS
if (c == ' ')
past_opcode_p = true;
if (CGEN_SYNTAX_CHAR(* syn) == ' ')
past_opcode_p = 1;
#endif
++ syn;
++ str;
@@ -1836,7 +1817,7 @@ parse_insn_normal (CGEN_CPU_DESC cd,
/* xgettext:c-format */
sprintf (msg, _("syntax error (expected char `%c', found `%c')"),
c, *str);
CGEN_SYNTAX_CHAR(*syn), *str);
return msg;
}
else
@@ -1846,12 +1827,15 @@ parse_insn_normal (CGEN_CPU_DESC cd,
/* xgettext:c-format */
sprintf (msg, _("syntax error (expected char `%c', found end of instruction)"),
c);
CGEN_SYNTAX_CHAR(*syn));
return msg;
}
continue;
}
#ifdef CGEN_MNEMONIC_OPERANDS
(void) past_opcode_p;
#endif
/* We have an operand of some sort. */
errmsg = cd->parse_operand (cd, CGEN_SYNTAX_FIELD (*syn), &str, fields);
if (errmsg)