[PATCH 7/7] x86: use is_whitespace()
Jan Beulich
jbeulich@suse.com
Fri Aug 9 12:55:56 GMT 2024
Wherever blanks are permissible in input, tabs ought to be permissible,
too. This is particularly relevant when -f is passed to gas (alongside
appropriate input).
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -583,7 +583,6 @@ static char operand_chars[256];
/* Lexical macros. */
#define is_operand_char(x) (operand_chars[(unsigned char) x])
#define is_register_char(x) (register_chars[(unsigned char) x])
-#define is_space_char(x) ((x) == ' ')
/* All non-digit non-letter characters that may occur in an operand and
which aren't already in extra_symbol_chars[]. */
@@ -1968,7 +1967,7 @@ check_Scc_OszcOperations (const char *l)
{
const char *suffix_string = l;
- while (is_space_char (*suffix_string))
+ while (is_whitespace (*suffix_string))
suffix_string++;
/* If {oszc flags} is absent, just return. */
@@ -1979,7 +1978,7 @@ check_Scc_OszcOperations (const char *l)
suffix_string++;
/* Parse 'dfv='. */
- while (is_space_char (*suffix_string))
+ while (is_whitespace (*suffix_string))
suffix_string++;
if (strncasecmp (suffix_string, "dfv", 3) == 0)
@@ -1990,7 +1989,7 @@ check_Scc_OszcOperations (const char *l)
return -1;
}
- while (is_space_char (*suffix_string))
+ while (is_whitespace (*suffix_string))
suffix_string++;
if (*suffix_string == '=')
@@ -2004,7 +2003,7 @@ check_Scc_OszcOperations (const char *l)
/* Parse 'of, sf, zf, cf}'. */
while (*suffix_string)
{
- while (is_space_char (*suffix_string))
+ while (is_whitespace (*suffix_string))
suffix_string++;
/* Return for '{dfv=}'. */
@@ -2039,7 +2038,7 @@ check_Scc_OszcOperations (const char *l)
suffix_string += 2;
- while (is_space_char (*suffix_string))
+ while (is_whitespace (*suffix_string))
suffix_string++;
if (*suffix_string == '}')
@@ -6864,7 +6863,7 @@ parse_insn (const char *line, char *mnem
{
++mnem_p;
++l;
- if (is_space_char (*l))
+ if (is_whitespace (*l))
++l;
}
else if (mode == parse_pseudo_prefix)
@@ -6883,7 +6882,7 @@ parse_insn (const char *line, char *mnem
l++;
}
split = l;
- if (is_space_char (*l))
+ if (is_whitespace (*l))
++l;
/* Pseudo-prefixes end with a closing figure brace. */
if (*mnemonic == '{' && *l == '}')
@@ -6893,7 +6892,7 @@ parse_insn (const char *line, char *mnem
goto too_long;
*mnem_p = '\0';
- if (is_space_char (*l))
+ if (is_whitespace (*l))
++l;
}
else if (l == split
@@ -7042,7 +7041,7 @@ parse_insn (const char *line, char *mnem
}
/* Skip past PREFIX_SEPARATOR and reset token_start. */
l += (!intel_syntax && *l == PREFIX_SEPARATOR);
- if (is_space_char (*l))
+ if (is_whitespace (*l))
++l;
token_start = l;
}
@@ -7189,10 +7188,10 @@ parse_insn (const char *line, char *mnem
may work in the future and it doesn't hurt to accept them
now. */
token_start = l++;
- if (is_space_char (*l))
+ if (is_whitespace (*l))
++l;
if (TOLOWER (*l) == 'p' && ISALPHA (l[1])
- && (l[2] == END_OF_INSN || is_space_char (l[2])))
+ && (l[2] == END_OF_INSN || is_whitespace (l[2])))
{
if (TOLOWER (l[1]) == 't')
{
@@ -7260,7 +7259,7 @@ parse_operands (char *l, const char *mne
bool in_quotes = false;
/* Skip optional white space before operand. */
- if (is_space_char (*l))
+ if (is_whitespace (*l))
++l;
if (!is_operand_char (*l) && *l != END_OF_INSN && *l != '"')
{
@@ -7294,7 +7293,7 @@ parse_operands (char *l, const char *mne
++l;
else if (*l == '"')
in_quotes = !in_quotes;
- else if (!in_quotes && !is_operand_char (*l) && !is_space_char (*l))
+ else if (!in_quotes && !is_operand_char (*l) && !is_whitespace (*l))
{
as_bad (_("invalid character %s in operand %d"),
output_invalid (*l),
@@ -12470,7 +12469,7 @@ lex_got (enum bfd_reloc_code_real *rel,
be necessary, but be safe. */
tmpbuf = XNEWVEC (char, first + second + 2);
memcpy (tmpbuf, input_line_pointer, first);
- if (second != 0 && *past_reloc != ' ')
+ if (second != 0 && !is_whitespace (*past_reloc))
/* Replace the relocation token with ' ', so that
errors like foo@GOTOFF1 will be detected. */
tmpbuf[first++] = ' ';
@@ -12613,7 +12612,7 @@ s_insn (int dummy ATTRIBUTE_UNUSED)
i.tm.extension_opcode = None;
if (startswith (line, "VEX")
- && (line[3] == '.' || is_space_char (line[3])))
+ && (line[3] == '.' || is_whitespace (line[3])))
{
vex = true;
line += 3;
@@ -12624,7 +12623,7 @@ s_insn (int dummy ATTRIBUTE_UNUSED)
unsigned long n = strtoul (line + 3, &e, 16);
if (e == line + 5 && n >= 0x08 && n <= 0x1f
- && (*e == '.' || is_space_char (*e)))
+ && (*e == '.' || is_whitespace (*e)))
{
xop = true;
/* Arrange for build_vex_prefix() to emit 0x8f. */
@@ -12634,7 +12633,7 @@ s_insn (int dummy ATTRIBUTE_UNUSED)
}
}
else if (startswith (line, "EVEX")
- && (line[4] == '.' || is_space_char (line[4])))
+ && (line[4] == '.' || is_whitespace (line[4])))
{
evex = true;
line += 4;
@@ -12798,14 +12797,14 @@ s_insn (int dummy ATTRIBUTE_UNUSED)
case '0':
if (TOUPPER (line[2]) != 'F')
break;
- if (line[3] == '.' || is_space_char (line[3]))
+ if (line[3] == '.' || is_whitespace (line[3]))
{
i.insn_opcode_space = SPACE_0F;
line += 3;
}
else if (line[3] == '3'
&& (line[4] == '8' || TOUPPER (line[4]) == 'A')
- && (line[5] == '.' || is_space_char (line[5])))
+ && (line[5] == '.' || is_whitespace (line[5])))
{
i.insn_opcode_space = line[4] == '8' ? SPACE_0F38 : SPACE_0F3A;
line += 5;
@@ -12819,7 +12818,7 @@ s_insn (int dummy ATTRIBUTE_UNUSED)
unsigned long n = strtoul (line + 2, &e, 10);
if (n <= (evex ? 15 : 31)
- && (*e == '.' || is_space_char (*e)))
+ && (*e == '.' || is_whitespace (*e)))
{
i.insn_opcode_space = n;
line = e;
@@ -12855,10 +12854,10 @@ s_insn (int dummy ATTRIBUTE_UNUSED)
line += 3;
}
- if (line > end && *line && !is_space_char (*line))
+ if (line > end && *line && !is_whitespace (*line))
{
/* Improve diagnostic a little. */
- if (*line == '.' && line[1] && !is_space_char (line[1]))
+ if (*line == '.' && line[1] && !is_whitespace (line[1]))
++line;
goto done;
}
@@ -12875,7 +12874,7 @@ s_insn (int dummy ATTRIBUTE_UNUSED)
break;
if (*ptr == '+' && ptr[1] == 'r'
- && (ptr[2] == ',' || (is_space_char (ptr[2]) && ptr[3] == ',')))
+ && (ptr[2] == ',' || (is_whitespace (ptr[2]) && ptr[3] == ',')))
{
*ptr = ' ';
ptr[1] = ' ';
@@ -12886,7 +12885,7 @@ s_insn (int dummy ATTRIBUTE_UNUSED)
if (*ptr == '/' && ISDIGIT (ptr[1])
&& (n = strtoul (ptr + 1, &e, 8)) < 8
&& e == ptr + 2
- && (ptr[2] == ',' || (is_space_char (ptr[2]) && ptr[3] == ',')))
+ && (ptr[2] == ',' || (is_whitespace (ptr[2]) && ptr[3] == ',')))
{
*ptr = ' ';
ptr[1] = ' ';
@@ -13491,7 +13490,7 @@ check_VecOperations (char *op_string)
if (*op_string == '{')
{
op_string++;
- if (is_space_char (*op_string))
+ if (is_whitespace (*op_string))
op_string++;
/* Check broadcasts. */
@@ -13663,7 +13662,7 @@ check_VecOperations (char *op_string)
else
goto unknown_vec_op;
- if (is_space_char (*op_string))
+ if (is_whitespace (*op_string))
op_string++;
if (*op_string != '}')
{
@@ -13672,7 +13671,7 @@ check_VecOperations (char *op_string)
}
op_string++;
- if (is_space_char (*op_string))
+ if (is_whitespace (*op_string))
++op_string;
continue;
@@ -13713,7 +13712,7 @@ i386_immediate (char *imm_start)
exp = &im_expressions[i.imm_operands++];
i.op[this_operand].imms = exp;
- if (is_space_char (*imm_start))
+ if (is_whitespace (*imm_start))
++imm_start;
save_input_line_pointer = input_line_pointer;
@@ -14334,14 +14333,14 @@ RC_SAE_immediate (const char *imm_start)
return 0;
pstr++;
- if (is_space_char (*pstr))
+ if (is_whitespace (*pstr))
pstr++;
pstr = RC_SAE_specifier (pstr);
if (pstr == NULL)
return 0;
- if (is_space_char (*pstr))
+ if (is_whitespace (*pstr))
pstr++;
if (*pstr++ != '}')
@@ -14379,7 +14378,7 @@ i386_att_operand (char *operand_string)
char *end_op;
char *op_string = operand_string;
- if (is_space_char (*op_string))
+ if (is_whitespace (*op_string))
++op_string;
/* We check for an absolute prefix (differentiating,
@@ -14388,7 +14387,7 @@ i386_att_operand (char *operand_string)
&& current_templates.start->opcode_modifier.jump)
{
++op_string;
- if (is_space_char (*op_string))
+ if (is_whitespace (*op_string))
++op_string;
i.jumpabsolute = true;
}
@@ -14404,7 +14403,7 @@ i386_att_operand (char *operand_string)
/* Check for a segment override by searching for ':' after a
segment register. */
op_string = end_op;
- if (is_space_char (*op_string))
+ if (is_whitespace (*op_string))
++op_string;
if (*op_string == ':' && r->reg_type.bitfield.class == SReg)
{
@@ -14412,7 +14411,7 @@ i386_att_operand (char *operand_string)
/* Skip the ':' and whitespace. */
++op_string;
- if (is_space_char (*op_string))
+ if (is_whitespace (*op_string))
++op_string;
/* Handle case of %es:*foo. */
@@ -14420,7 +14419,7 @@ i386_att_operand (char *operand_string)
&& current_templates.start->opcode_modifier.jump)
{
++op_string;
- if (is_space_char (*op_string))
+ if (is_whitespace (*op_string))
++op_string;
i.jumpabsolute = true;
}
@@ -14531,7 +14530,7 @@ i386_att_operand (char *operand_string)
/* Handle vector operations. */
--base_string;
- if (is_space_char (*base_string))
+ if (is_whitespace (*base_string))
--base_string;
if (*base_string == '}')
@@ -14548,7 +14547,7 @@ i386_att_operand (char *operand_string)
vop_start = base_string;
--base_string;
- if (is_space_char (*base_string))
+ if (is_whitespace (*base_string))
--base_string;
if (*base_string != '}')
@@ -14600,7 +14599,7 @@ i386_att_operand (char *operand_string)
/* Skip past '(' and whitespace. */
gas_assert (*base_string == '(');
++base_string;
- if (is_space_char (*base_string))
+ if (is_whitespace (*base_string))
++base_string;
if (*base_string == ','
@@ -14616,7 +14615,7 @@ i386_att_operand (char *operand_string)
if (i.base_reg == &bad_reg)
return 0;
base_string = end_op;
- if (is_space_char (*base_string))
+ if (is_whitespace (*base_string))
++base_string;
}
@@ -14624,7 +14623,7 @@ i386_att_operand (char *operand_string)
if (*base_string == ',')
{
++base_string;
- if (is_space_char (*base_string))
+ if (is_whitespace (*base_string))
++base_string;
if ((i.index_reg = parse_register (base_string, &end_op))
@@ -14633,12 +14632,12 @@ i386_att_operand (char *operand_string)
if (i.index_reg == &bad_reg)
return 0;
base_string = end_op;
- if (is_space_char (*base_string))
+ if (is_whitespace (*base_string))
++base_string;
if (*base_string == ',')
{
++base_string;
- if (is_space_char (*base_string))
+ if (is_whitespace (*base_string))
++base_string;
}
else if (*base_string != ')')
@@ -14667,7 +14666,7 @@ i386_att_operand (char *operand_string)
return 0;
base_string = end_scale;
- if (is_space_char (*base_string))
+ if (is_whitespace (*base_string))
++base_string;
if (*base_string != ')')
{
@@ -15919,7 +15918,7 @@ parse_real_register (const char *reg_str
if (*s == REGISTER_PREFIX)
++s;
- if (is_space_char (*s))
+ if (is_whitespace (*s))
++s;
p = reg_name_given;
@@ -15946,18 +15945,18 @@ parse_real_register (const char *reg_str
&& !allow_pseudo_reg)
return (const reg_entry *) NULL;
- if (is_space_char (*s))
+ if (is_whitespace (*s))
++s;
if (*s == '(')
{
++s;
- if (is_space_char (*s))
+ if (is_whitespace (*s))
++s;
if (*s >= '0' && *s <= '7')
{
int fpr = *s - '0';
++s;
- if (is_space_char (*s))
+ if (is_whitespace (*s))
++s;
if (*s == ')')
{
--- a/gas/config/tc-i386-intel.c
+++ b/gas/config/tc-i386-intel.c
@@ -186,7 +186,7 @@ operatorT i386_operator (const char *nam
if (strcasecmp (i386_types[j].name, name) == 0)
break;
- if (i386_types[j].name && *pc == ' ')
+ if (i386_types[j].name && is_whitespace (*pc))
{
const char *start = ++input_line_pointer;
char *pname;
More information about the Binutils
mailing list