Tidy gas/expr.c static state

* expr.c (seen, nr_seen): Make file scope.
	(expr_begin): Clear seen, nr_seen, and expr_symbol_lines.
	(expr_end): New function.
	* expr.h (expr_end): Declare.
	* output-file.c (output_file_close): Call expr_end.
	* config/tc-hppa.c (expr_end): Rename to expr_parse_end.
	* config/tc-mips.c: Likewise.
	* config/tc-riscv.c: Likewise.
	* config/tc-sparc.c: Likewise.
This commit is contained in:
Alan Modra
2023-01-14 22:13:54 +10:30
parent 6e4b74e9a9
commit 6eb099ae93
7 changed files with 123 additions and 107 deletions

View File

@ -591,7 +591,7 @@ static struct pa_it the_insn;
/* Points to the end of an expression just parsed by get_expression /* Points to the end of an expression just parsed by get_expression
and friends. FIXME. This shouldn't be handled with a file-global and friends. FIXME. This shouldn't be handled with a file-global
variable. */ variable. */
static char *expr_end; static char *expr_parse_end;
/* Nonzero if a .callinfo appeared within the current procedure. */ /* Nonzero if a .callinfo appeared within the current procedure. */
static int callinfo_found; static int callinfo_found;
@ -1270,7 +1270,7 @@ cons_fix_new_hppa (fragS *frag, int where, int size, expressionS *exp,
hppa_field_selector, size * 8, 0, 0); hppa_field_selector, size * 8, 0, 0);
} }
/* Mark (via expr_end) the end of an expression (I think). FIXME. */ /* Mark (via expr_parse_end) the end of an expression (I think). FIXME. */
static void static void
get_expression (char *str) get_expression (char *str)
@ -1286,11 +1286,11 @@ get_expression (char *str)
|| SEG_NORMAL (seg))) || SEG_NORMAL (seg)))
{ {
as_warn (_("Bad segment in expression.")); as_warn (_("Bad segment in expression."));
expr_end = input_line_pointer; expr_parse_end = input_line_pointer;
input_line_pointer = save_in; input_line_pointer = save_in;
return; return;
} }
expr_end = input_line_pointer; expr_parse_end = input_line_pointer;
input_line_pointer = save_in; input_line_pointer = save_in;
} }
@ -2518,7 +2518,7 @@ evaluate_absolute (struct pa_it *insn)
return hppa_field_adjust (0, value, field_selector); return hppa_field_adjust (0, value, field_selector);
} }
/* Mark (via expr_end) the end of an absolute expression. FIXME. */ /* Mark (via expr_parse_end) the end of an absolute expression. FIXME. */
static int static int
pa_get_absolute_expression (struct pa_it *insn, char **strp) pa_get_absolute_expression (struct pa_it *insn, char **strp)
@ -2529,7 +2529,7 @@ pa_get_absolute_expression (struct pa_it *insn, char **strp)
save_in = input_line_pointer; save_in = input_line_pointer;
input_line_pointer = *strp; input_line_pointer = *strp;
expression (&insn->exp); expression (&insn->exp);
expr_end = input_line_pointer; expr_parse_end = input_line_pointer;
input_line_pointer = save_in; input_line_pointer = save_in;
if (insn->exp.X_op != O_constant) if (insn->exp.X_op != O_constant)
{ {
@ -3346,7 +3346,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s); num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant) if (strict && the_insn.exp.X_op != O_constant)
break; break;
s = expr_end; s = expr_parse_end;
CHECK_FIELD (num, 32, 1, 0); CHECK_FIELD (num, 32, 1, 0);
SAVE_IMMEDIATE(num); SAVE_IMMEDIATE(num);
INSERT_FIELD_AND_CONTINUE (opcode, 32 - num, 0); INSERT_FIELD_AND_CONTINUE (opcode, 32 - num, 0);
@ -3356,7 +3356,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s); num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant) if (strict && the_insn.exp.X_op != O_constant)
break; break;
s = expr_end; s = expr_parse_end;
/* When in strict mode, we want to just reject this /* When in strict mode, we want to just reject this
match instead of giving an out of range error. */ match instead of giving an out of range error. */
CHECK_FIELD (num, 15, -16, strict); CHECK_FIELD (num, 15, -16, strict);
@ -3368,7 +3368,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s); num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant) if (strict && the_insn.exp.X_op != O_constant)
break; break;
s = expr_end; s = expr_parse_end;
/* When in strict mode, we want to just reject this /* When in strict mode, we want to just reject this
match instead of giving an out of range error. */ match instead of giving an out of range error. */
CHECK_FIELD (num, 15, -16, strict); CHECK_FIELD (num, 15, -16, strict);
@ -3380,7 +3380,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s); num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant) if (strict && the_insn.exp.X_op != O_constant)
break; break;
s = expr_end; s = expr_parse_end;
CHECK_FIELD (num, 31, 0, strict); CHECK_FIELD (num, 31, 0, strict);
INSERT_FIELD_AND_CONTINUE (opcode, num, 0); INSERT_FIELD_AND_CONTINUE (opcode, num, 0);
@ -3389,7 +3389,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s); num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant) if (strict && the_insn.exp.X_op != O_constant)
break; break;
s = expr_end; s = expr_parse_end;
CHECK_FIELD (num, 31, 0, strict); CHECK_FIELD (num, 31, 0, strict);
INSERT_FIELD_AND_CONTINUE (opcode, num, 16); INSERT_FIELD_AND_CONTINUE (opcode, num, 16);
@ -3398,7 +3398,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s); num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant) if (strict && the_insn.exp.X_op != O_constant)
break; break;
s = expr_end; s = expr_parse_end;
CHECK_FIELD (num, 1023, 0, strict); CHECK_FIELD (num, 1023, 0, strict);
INSERT_FIELD_AND_CONTINUE (opcode, num, 16); INSERT_FIELD_AND_CONTINUE (opcode, num, 16);
@ -4556,7 +4556,7 @@ pa_ip (char *str)
are 0..6 inclusive. */ are 0..6 inclusive. */
case 'h': case 'h':
get_expression (s); get_expression (s);
s = expr_end; s = expr_parse_end;
if (the_insn.exp.X_op == O_constant) if (the_insn.exp.X_op == O_constant)
{ {
num = evaluate_absolute (&the_insn); num = evaluate_absolute (&the_insn);
@ -4573,7 +4573,7 @@ pa_ip (char *str)
get_expression (s); get_expression (s);
if (the_insn.exp.X_op == O_constant) if (the_insn.exp.X_op == O_constant)
{ {
s = expr_end; s = expr_parse_end;
num = evaluate_absolute (&the_insn); num = evaluate_absolute (&the_insn);
CHECK_FIELD (num, 6, 0, 0); CHECK_FIELD (num, 6, 0, 0);
num = (num + 1) ^ 1; num = (num + 1) ^ 1;
@ -4593,7 +4593,7 @@ pa_ip (char *str)
case 'i': case 'i':
the_insn.field_selector = pa_chk_field_selector (&s); the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s); get_expression (s);
s = expr_end; s = expr_parse_end;
if (the_insn.exp.X_op == O_constant) if (the_insn.exp.X_op == O_constant)
{ {
num = evaluate_absolute (&the_insn); num = evaluate_absolute (&the_insn);
@ -4629,7 +4629,7 @@ pa_ip (char *str)
case 'J': case 'J':
the_insn.field_selector = pa_chk_field_selector (&s); the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s); get_expression (s);
s = expr_end; s = expr_parse_end;
if (the_insn.exp.X_op == O_constant) if (the_insn.exp.X_op == O_constant)
{ {
int mb; int mb;
@ -4653,7 +4653,7 @@ pa_ip (char *str)
case 'K': case 'K':
the_insn.field_selector = pa_chk_field_selector (&s); the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s); get_expression (s);
s = expr_end; s = expr_parse_end;
if (the_insn.exp.X_op == O_constant) if (the_insn.exp.X_op == O_constant)
{ {
int mb; int mb;
@ -4675,7 +4675,7 @@ pa_ip (char *str)
case '<': case '<':
the_insn.field_selector = pa_chk_field_selector (&s); the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s); get_expression (s);
s = expr_end; s = expr_parse_end;
if (the_insn.exp.X_op == O_constant) if (the_insn.exp.X_op == O_constant)
{ {
int mb; int mb;
@ -4695,7 +4695,7 @@ pa_ip (char *str)
case '>': case '>':
the_insn.field_selector = pa_chk_field_selector (&s); the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s); get_expression (s);
s = expr_end; s = expr_parse_end;
if (the_insn.exp.X_op == O_constant) if (the_insn.exp.X_op == O_constant)
{ {
int mb; int mb;
@ -4719,7 +4719,7 @@ pa_ip (char *str)
break; break;
the_insn.field_selector = pa_chk_field_selector (&s); the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s); get_expression (s);
s = expr_end; s = expr_parse_end;
if (the_insn.exp.X_op == O_constant) if (the_insn.exp.X_op == O_constant)
{ {
num = evaluate_absolute (&the_insn); num = evaluate_absolute (&the_insn);
@ -4761,7 +4761,7 @@ pa_ip (char *str)
case 'd': case 'd':
the_insn.field_selector = pa_chk_field_selector (&s); the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s); get_expression (s);
s = expr_end; s = expr_parse_end;
if (the_insn.exp.X_op == O_constant) if (the_insn.exp.X_op == O_constant)
{ {
num = evaluate_absolute (&the_insn); num = evaluate_absolute (&the_insn);
@ -4802,7 +4802,7 @@ pa_ip (char *str)
case 'j': case 'j':
the_insn.field_selector = pa_chk_field_selector (&s); the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s); get_expression (s);
s = expr_end; s = expr_parse_end;
if (the_insn.exp.X_op == O_constant) if (the_insn.exp.X_op == O_constant)
{ {
num = evaluate_absolute (&the_insn); num = evaluate_absolute (&the_insn);
@ -4838,7 +4838,7 @@ pa_ip (char *str)
case 'k': case 'k':
the_insn.field_selector = pa_chk_field_selector (&s); the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s); get_expression (s);
s = expr_end; s = expr_parse_end;
if (the_insn.exp.X_op == O_constant) if (the_insn.exp.X_op == O_constant)
{ {
num = evaluate_absolute (&the_insn); num = evaluate_absolute (&the_insn);
@ -4874,7 +4874,7 @@ pa_ip (char *str)
case 'l': case 'l':
the_insn.field_selector = pa_chk_field_selector (&s); the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s); get_expression (s);
s = expr_end; s = expr_parse_end;
if (the_insn.exp.X_op == O_constant) if (the_insn.exp.X_op == O_constant)
{ {
num = evaluate_absolute (&the_insn); num = evaluate_absolute (&the_insn);
@ -4911,7 +4911,7 @@ pa_ip (char *str)
case 'y': case 'y':
the_insn.field_selector = pa_chk_field_selector (&s); the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s); get_expression (s);
s = expr_end; s = expr_parse_end;
if (the_insn.exp.X_op == O_constant) if (the_insn.exp.X_op == O_constant)
{ {
num = evaluate_absolute (&the_insn); num = evaluate_absolute (&the_insn);
@ -4949,7 +4949,7 @@ pa_ip (char *str)
case '&': case '&':
the_insn.field_selector = pa_chk_field_selector (&s); the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s); get_expression (s);
s = expr_end; s = expr_parse_end;
if (the_insn.exp.X_op == O_constant) if (the_insn.exp.X_op == O_constant)
{ {
num = evaluate_absolute (&the_insn); num = evaluate_absolute (&the_insn);
@ -4987,7 +4987,7 @@ pa_ip (char *str)
case 'w': case 'w':
the_insn.field_selector = pa_chk_field_selector (&s); the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s); get_expression (s);
s = expr_end; s = expr_parse_end;
the_insn.pcrel = 1; the_insn.pcrel = 1;
if (!the_insn.exp.X_add_symbol if (!the_insn.exp.X_add_symbol
|| !strcmp (S_GET_NAME (the_insn.exp.X_add_symbol), || !strcmp (S_GET_NAME (the_insn.exp.X_add_symbol),
@ -5011,7 +5011,7 @@ pa_ip (char *str)
the_insn.format = 12; the_insn.format = 12;
the_insn.arg_reloc = last_call_desc.arg_reloc; the_insn.arg_reloc = last_call_desc.arg_reloc;
memset (&last_call_desc, 0, sizeof (struct call_desc)); memset (&last_call_desc, 0, sizeof (struct call_desc));
s = expr_end; s = expr_parse_end;
continue; continue;
} }
@ -5019,7 +5019,7 @@ pa_ip (char *str)
case 'W': case 'W':
the_insn.field_selector = pa_chk_field_selector (&s); the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s); get_expression (s);
s = expr_end; s = expr_parse_end;
the_insn.pcrel = 1; the_insn.pcrel = 1;
if (!the_insn.exp.X_add_symbol if (!the_insn.exp.X_add_symbol
|| !strcmp (S_GET_NAME (the_insn.exp.X_add_symbol), || !strcmp (S_GET_NAME (the_insn.exp.X_add_symbol),
@ -5050,7 +5050,7 @@ pa_ip (char *str)
case 'X': case 'X':
the_insn.field_selector = pa_chk_field_selector (&s); the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s); get_expression (s);
s = expr_end; s = expr_parse_end;
the_insn.pcrel = 1; the_insn.pcrel = 1;
if (!the_insn.exp.X_add_symbol if (!the_insn.exp.X_add_symbol
|| !strcmp (S_GET_NAME (the_insn.exp.X_add_symbol), || !strcmp (S_GET_NAME (the_insn.exp.X_add_symbol),
@ -5080,7 +5080,7 @@ pa_ip (char *str)
case 'z': case 'z':
the_insn.field_selector = pa_chk_field_selector (&s); the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s); get_expression (s);
s = expr_end; s = expr_parse_end;
the_insn.pcrel = 0; the_insn.pcrel = 0;
if (!the_insn.exp.X_add_symbol if (!the_insn.exp.X_add_symbol
|| !strcmp (S_GET_NAME (the_insn.exp.X_add_symbol), || !strcmp (S_GET_NAME (the_insn.exp.X_add_symbol),
@ -5137,7 +5137,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s); num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant) if (strict && the_insn.exp.X_op != O_constant)
break; break;
s = expr_end; s = expr_parse_end;
CHECK_FIELD (num, 3, 1, strict); CHECK_FIELD (num, 3, 1, strict);
INSERT_FIELD_AND_CONTINUE (opcode, num, 6); INSERT_FIELD_AND_CONTINUE (opcode, num, 6);
@ -5146,7 +5146,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s); num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant) if (strict && the_insn.exp.X_op != O_constant)
break; break;
s = expr_end; s = expr_parse_end;
CHECK_FIELD (num, 15, 0, strict); CHECK_FIELD (num, 15, 0, strict);
INSERT_FIELD_AND_CONTINUE (opcode, num, 6); INSERT_FIELD_AND_CONTINUE (opcode, num, 6);
@ -5155,7 +5155,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s); num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant) if (strict && the_insn.exp.X_op != O_constant)
break; break;
s = expr_end; s = expr_parse_end;
CHECK_FIELD (num, 31, 0, strict); CHECK_FIELD (num, 31, 0, strict);
SAVE_IMMEDIATE(num); SAVE_IMMEDIATE(num);
INSERT_FIELD_AND_CONTINUE (opcode, 31 - num, 5); INSERT_FIELD_AND_CONTINUE (opcode, 31 - num, 5);
@ -5165,7 +5165,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s); num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant) if (strict && the_insn.exp.X_op != O_constant)
break; break;
s = expr_end; s = expr_parse_end;
CHECK_FIELD (num, 63, 0, strict); CHECK_FIELD (num, 63, 0, strict);
SAVE_IMMEDIATE(num); SAVE_IMMEDIATE(num);
num = 63 - num; num = 63 - num;
@ -5178,7 +5178,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s); num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant) if (strict && the_insn.exp.X_op != O_constant)
break; break;
s = expr_end; s = expr_parse_end;
CHECK_FIELD (num, 64, 1, strict); CHECK_FIELD (num, 64, 1, strict);
SAVE_IMMEDIATE(num); SAVE_IMMEDIATE(num);
num--; num--;
@ -5191,7 +5191,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s); num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant) if (strict && the_insn.exp.X_op != O_constant)
break; break;
s = expr_end; s = expr_parse_end;
CHECK_FIELD (num, 64, 1, strict); CHECK_FIELD (num, 64, 1, strict);
SAVE_IMMEDIATE(num); SAVE_IMMEDIATE(num);
num--; num--;
@ -5204,7 +5204,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s); num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant) if (strict && the_insn.exp.X_op != O_constant)
break; break;
s = expr_end; s = expr_parse_end;
CHECK_FIELD (num, 31, 0, strict); CHECK_FIELD (num, 31, 0, strict);
SAVE_IMMEDIATE(num); SAVE_IMMEDIATE(num);
INSERT_FIELD_AND_CONTINUE (opcode, num, 5); INSERT_FIELD_AND_CONTINUE (opcode, num, 5);
@ -5214,7 +5214,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s); num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant) if (strict && the_insn.exp.X_op != O_constant)
break; break;
s = expr_end; s = expr_parse_end;
CHECK_FIELD (num, 63, 0, strict); CHECK_FIELD (num, 63, 0, strict);
SAVE_IMMEDIATE(num); SAVE_IMMEDIATE(num);
opcode |= (num & 0x20) << 6; opcode |= (num & 0x20) << 6;
@ -5226,7 +5226,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s); num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant) if (strict && the_insn.exp.X_op != O_constant)
break; break;
s = expr_end; s = expr_parse_end;
CHECK_FIELD (num, 63, 0, strict); CHECK_FIELD (num, 63, 0, strict);
if (num & 0x20) if (num & 0x20)
opcode &= ~(1 << 13); opcode &= ~(1 << 13);
@ -5237,7 +5237,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s); num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant) if (strict && the_insn.exp.X_op != O_constant)
break; break;
s = expr_end; s = expr_parse_end;
CHECK_FIELD (num, 31, 0, strict); CHECK_FIELD (num, 31, 0, strict);
INSERT_FIELD_AND_CONTINUE (opcode, num, 21); INSERT_FIELD_AND_CONTINUE (opcode, num, 21);
@ -5246,7 +5246,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s); num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant) if (strict && the_insn.exp.X_op != O_constant)
break; break;
s = expr_end; s = expr_parse_end;
CHECK_FIELD (num, 511, 1, strict); CHECK_FIELD (num, 511, 1, strict);
INSERT_FIELD_AND_CONTINUE (opcode, num, 3); INSERT_FIELD_AND_CONTINUE (opcode, num, 3);
@ -5255,7 +5255,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s); num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant) if (strict && the_insn.exp.X_op != O_constant)
break; break;
s = expr_end; s = expr_parse_end;
CHECK_FIELD (num, 8191, 0, strict); CHECK_FIELD (num, 8191, 0, strict);
INSERT_FIELD_AND_CONTINUE (opcode, num, 13); INSERT_FIELD_AND_CONTINUE (opcode, num, 13);
@ -5264,7 +5264,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s); num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant) if (strict && the_insn.exp.X_op != O_constant)
break; break;
s = expr_end; s = expr_parse_end;
CHECK_FIELD (num, 67108863, 0, strict); CHECK_FIELD (num, 67108863, 0, strict);
INSERT_FIELD_AND_CONTINUE (opcode, num, 0); INSERT_FIELD_AND_CONTINUE (opcode, num, 0);
@ -5275,7 +5275,7 @@ pa_ip (char *str)
num = pa_get_number (&the_insn, &s); num = pa_get_number (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant) if (strict && the_insn.exp.X_op != O_constant)
break; break;
s = expr_end; s = expr_parse_end;
CHECK_FIELD (num, 7, 0, strict); CHECK_FIELD (num, 7, 0, strict);
INSERT_FIELD_AND_CONTINUE (opcode, num, 6); INSERT_FIELD_AND_CONTINUE (opcode, num, 6);
@ -5284,7 +5284,7 @@ pa_ip (char *str)
num = pa_get_number (&the_insn, &s); num = pa_get_number (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant) if (strict && the_insn.exp.X_op != O_constant)
break; break;
s = expr_end; s = expr_parse_end;
CHECK_FIELD (num, 1048575, 0, strict); CHECK_FIELD (num, 1048575, 0, strict);
num = (num & 0x1f) | ((num & 0x000fffe0) << 6); num = (num & 0x1f) | ((num & 0x000fffe0) << 6);
INSERT_FIELD_AND_CONTINUE (opcode, num, 0); INSERT_FIELD_AND_CONTINUE (opcode, num, 0);
@ -5294,7 +5294,7 @@ pa_ip (char *str)
num = pa_get_number (&the_insn, &s); num = pa_get_number (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant) if (strict && the_insn.exp.X_op != O_constant)
break; break;
s = expr_end; s = expr_parse_end;
CHECK_FIELD (num, 32767, 0, strict); CHECK_FIELD (num, 32767, 0, strict);
INSERT_FIELD_AND_CONTINUE (opcode, num, 11); INSERT_FIELD_AND_CONTINUE (opcode, num, 11);
@ -5303,7 +5303,7 @@ pa_ip (char *str)
num = pa_get_number (&the_insn, &s); num = pa_get_number (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant) if (strict && the_insn.exp.X_op != O_constant)
break; break;
s = expr_end; s = expr_parse_end;
CHECK_FIELD (num, 1023, 0, strict); CHECK_FIELD (num, 1023, 0, strict);
num = (num & 0x1f) | ((num & 0x000003e0) << 6); num = (num & 0x1f) | ((num & 0x000003e0) << 6);
INSERT_FIELD_AND_CONTINUE (opcode, num, 0); INSERT_FIELD_AND_CONTINUE (opcode, num, 0);
@ -5313,7 +5313,7 @@ pa_ip (char *str)
num = pa_get_number (&the_insn, &s); num = pa_get_number (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant) if (strict && the_insn.exp.X_op != O_constant)
break; break;
s = expr_end; s = expr_parse_end;
CHECK_FIELD (num, 32767, 0, strict); CHECK_FIELD (num, 32767, 0, strict);
num = (num & 0x1f) | ((num & 0x00007fe0) << 6); num = (num & 0x1f) | ((num & 0x00007fe0) << 6);
INSERT_FIELD_AND_CONTINUE (opcode, num, 0); INSERT_FIELD_AND_CONTINUE (opcode, num, 0);
@ -5325,7 +5325,7 @@ pa_ip (char *str)
num = pa_get_number (&the_insn, &s); num = pa_get_number (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant) if (strict && the_insn.exp.X_op != O_constant)
break; break;
s = expr_end; s = expr_parse_end;
CHECK_FIELD (num, 7, 0, strict); CHECK_FIELD (num, 7, 0, strict);
INSERT_FIELD_AND_CONTINUE (opcode, num, 6); INSERT_FIELD_AND_CONTINUE (opcode, num, 6);
@ -5334,7 +5334,7 @@ pa_ip (char *str)
num = pa_get_number (&the_insn, &s); num = pa_get_number (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant) if (strict && the_insn.exp.X_op != O_constant)
break; break;
s = expr_end; s = expr_parse_end;
CHECK_FIELD (num, 4194303, 0, strict); CHECK_FIELD (num, 4194303, 0, strict);
num = (num & 0x1f) | ((num & 0x003fffe0) << 4); num = (num & 0x1f) | ((num & 0x003fffe0) << 4);
INSERT_FIELD_AND_CONTINUE (opcode, num, 0); INSERT_FIELD_AND_CONTINUE (opcode, num, 0);

View File

@ -2038,7 +2038,7 @@ mips_mark_labels (void)
mips_compressed_mark_labels (); mips_compressed_mark_labels ();
} }
static char *expr_end; static char *expr_parse_end;
/* An expression in a macro instruction. This is set by mips_ip and /* An expression in a macro instruction. This is set by mips_ip and
mips16_ip and when populated is always an O_constant. */ mips16_ip and when populated is always an O_constant. */
@ -3303,7 +3303,7 @@ mips_parse_argument_token (char *s, char float_format)
set_insn_error (0, _("vector element must be constant")); set_insn_error (0, _("vector element must be constant"));
return 0; return 0;
} }
s = expr_end; s = expr_parse_end;
token.u.index = element.X_add_number; token.u.index = element.X_add_number;
mips_add_token (&token, OT_INTEGER_INDEX); mips_add_token (&token, OT_INTEGER_INDEX);
} }
@ -3344,7 +3344,7 @@ mips_parse_argument_token (char *s, char float_format)
token.u.integer.relocs[1] = BFD_RELOC_UNUSED; token.u.integer.relocs[1] = BFD_RELOC_UNUSED;
token.u.integer.relocs[2] = BFD_RELOC_UNUSED; token.u.integer.relocs[2] = BFD_RELOC_UNUSED;
my_getSmallExpression (&token.u.integer.value, token.u.integer.relocs, s); my_getSmallExpression (&token.u.integer.value, token.u.integer.relocs, s);
s = expr_end; s = expr_parse_end;
mips_add_token (&token, OT_INTEGER); mips_add_token (&token, OT_INTEGER);
return s; return s;
} }
@ -14655,7 +14655,8 @@ parse_relocation (char **str, bfd_reloc_code_real_type *reloc)
expression in *EP and the relocations in the array starting expression in *EP and the relocations in the array starting
at RELOC. Return the number of relocation operators used. at RELOC. Return the number of relocation operators used.
On exit, EXPR_END points to the first character after the expression. */ On exit, EXPR_PARSE_END points to the first character after the
expression. */
static size_t static size_t
my_getSmallExpression (expressionS *ep, bfd_reloc_code_real_type *reloc, my_getSmallExpression (expressionS *ep, bfd_reloc_code_real_type *reloc,
@ -14689,7 +14690,7 @@ my_getSmallExpression (expressionS *ep, bfd_reloc_code_real_type *reloc,
&& parse_relocation (&str, &reversed_reloc[reloc_index])); && parse_relocation (&str, &reversed_reloc[reloc_index]));
my_getExpression (ep, crux); my_getExpression (ep, crux);
str = expr_end; str = expr_parse_end;
/* Match every open bracket. */ /* Match every open bracket. */
while (crux_depth > 0 && (*str == ')' || *str == ' ' || *str == '\t')) while (crux_depth > 0 && (*str == ')' || *str == ' ' || *str == '\t'))
@ -14699,7 +14700,7 @@ my_getSmallExpression (expressionS *ep, bfd_reloc_code_real_type *reloc,
if (crux_depth > 0) if (crux_depth > 0)
as_bad (_("unclosed '('")); as_bad (_("unclosed '('"));
expr_end = str; expr_parse_end = str;
for (i = 0; i < reloc_index; i++) for (i = 0; i < reloc_index; i++)
reloc[i] = reversed_reloc[reloc_index - 1 - i]; reloc[i] = reversed_reloc[reloc_index - 1 - i];
@ -14715,7 +14716,7 @@ my_getExpression (expressionS *ep, char *str)
save_in = input_line_pointer; save_in = input_line_pointer;
input_line_pointer = str; input_line_pointer = str;
expression (ep); expression (ep);
expr_end = input_line_pointer; expr_parse_end = input_line_pointer;
input_line_pointer = save_in; input_line_pointer = save_in;
} }

View File

@ -445,7 +445,7 @@ static bool explicit_attr = false;
/* Indicate CSR or priv instructions are explicitly used. */ /* Indicate CSR or priv instructions are explicitly used. */
static bool explicit_priv_attr = false; static bool explicit_priv_attr = false;
static char *expr_end; static char *expr_parse_end;
/* Macros for encoding relaxation state for RVC branches and far jumps. */ /* Macros for encoding relaxation state for RVC branches and far jumps. */
#define RELAX_BRANCH_ENCODE(uncond, rvc, length) \ #define RELAX_BRANCH_ENCODE(uncond, rvc, length) \
@ -914,7 +914,7 @@ opcode_name_lookup (char **s)
*s = e; *s = e;
*e = save_c; *e = save_c;
expr_end = e; expr_parse_end = e;
return o; return o;
} }
@ -2212,7 +2212,7 @@ my_getExpression (expressionS *ep, char *str)
save_in = input_line_pointer; save_in = input_line_pointer;
input_line_pointer = str; input_line_pointer = str;
expression (ep); expression (ep);
expr_end = input_line_pointer; expr_parse_end = input_line_pointer;
input_line_pointer = save_in; input_line_pointer = save_in;
} }
@ -2220,7 +2220,8 @@ my_getExpression (expressionS *ep, char *str)
expression in *EP and the relocation, if any, in RELOC. expression in *EP and the relocation, if any, in RELOC.
Return the number of relocation operators used (0 or 1). Return the number of relocation operators used (0 or 1).
On exit, EXPR_END points to the first character after the expression. */ On exit, EXPR_PARSE_END points to the first character after the
expression. */
static size_t static size_t
my_getSmallExpression (expressionS *ep, bfd_reloc_code_real_type *reloc, my_getSmallExpression (expressionS *ep, bfd_reloc_code_real_type *reloc,
@ -2238,7 +2239,7 @@ my_getSmallExpression (expressionS *ep, bfd_reloc_code_real_type *reloc,
{ {
ep->X_op = O_register; ep->X_op = O_register;
ep->X_add_number = regno; ep->X_add_number = regno;
expr_end = str; expr_parse_end = str;
return 0; return 0;
} }
@ -2265,7 +2266,7 @@ my_getSmallExpression (expressionS *ep, bfd_reloc_code_real_type *reloc,
&& parse_relocation (&str, reloc, percent_op)); && parse_relocation (&str, reloc, percent_op));
my_getExpression (ep, crux); my_getExpression (ep, crux);
str = expr_end; str = expr_parse_end;
/* Match every open bracket. */ /* Match every open bracket. */
while (crux_depth > 0 && (*str == ')' || *str == ' ' || *str == '\t')) while (crux_depth > 0 && (*str == ')' || *str == ' ' || *str == '\t'))
@ -2275,7 +2276,7 @@ my_getSmallExpression (expressionS *ep, bfd_reloc_code_real_type *reloc,
if (crux_depth > 0) if (crux_depth > 0)
as_bad ("unclosed '('"); as_bad ("unclosed '('");
expr_end = str; expr_parse_end = str;
return reloc_index; return reloc_index;
} }
@ -2299,7 +2300,8 @@ my_getOpcodeExpression (expressionS *ep, bfd_reloc_code_real_type *reloc,
} }
/* Parse string STR as a vsetvli operand. Store the expression in *EP. /* Parse string STR as a vsetvli operand. Store the expression in *EP.
On exit, EXPR_END points to the first character after the expression. */ On exit, EXPR_PARSE_END points to the first character after the
expression. */
static void static void
my_getVsetvliExpression (expressionS *ep, char *str) my_getVsetvliExpression (expressionS *ep, char *str)
@ -2349,12 +2351,12 @@ my_getVsetvliExpression (expressionS *ep, char *str)
| (vsew_value << OP_SH_VSEW) | (vsew_value << OP_SH_VSEW)
| (vta_value << OP_SH_VTA) | (vta_value << OP_SH_VTA)
| (vma_value << OP_SH_VMA); | (vma_value << OP_SH_VMA);
expr_end = str; expr_parse_end = str;
} }
else else
{ {
my_getExpression (ep, str); my_getExpression (ep, str);
str = expr_end; str = expr_parse_end;
} }
} }
@ -2613,7 +2615,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
break; break;
ip->insn_opcode |= ENCODE_CITYPE_IMM (imm_expr->X_add_number); ip->insn_opcode |= ENCODE_CITYPE_IMM (imm_expr->X_add_number);
rvc_imm_done: rvc_imm_done:
asarg = expr_end; asarg = expr_parse_end;
imm_expr->X_op = O_absent; imm_expr->X_op = O_absent;
continue; continue;
case '5': case '5':
@ -2795,7 +2797,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
} }
INSERT_OPERAND (CFUNCT6, *ip, imm_expr->X_add_number); INSERT_OPERAND (CFUNCT6, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent; imm_expr->X_op = O_absent;
asarg = expr_end; asarg = expr_parse_end;
continue; continue;
case '4': case '4':
@ -2810,7 +2812,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
} }
INSERT_OPERAND (CFUNCT4, *ip, imm_expr->X_add_number); INSERT_OPERAND (CFUNCT4, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent; imm_expr->X_op = O_absent;
asarg = expr_end; asarg = expr_parse_end;
continue; continue;
case '3': case '3':
@ -2825,7 +2827,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
} }
INSERT_OPERAND (CFUNCT3, *ip, imm_expr->X_add_number); INSERT_OPERAND (CFUNCT3, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent; imm_expr->X_op = O_absent;
asarg = expr_end; asarg = expr_parse_end;
continue; continue;
case '2': case '2':
@ -2840,7 +2842,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
} }
INSERT_OPERAND (CFUNCT2, *ip, imm_expr->X_add_number); INSERT_OPERAND (CFUNCT2, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent; imm_expr->X_op = O_absent;
asarg = expr_end; asarg = expr_parse_end;
continue; continue;
default: default:
@ -2932,7 +2934,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
ip->insn_opcode ip->insn_opcode
|= ENCODE_RVV_VB_IMM (imm_expr->X_add_number); |= ENCODE_RVV_VB_IMM (imm_expr->X_add_number);
imm_expr->X_op = O_absent; imm_expr->X_op = O_absent;
asarg = expr_end; asarg = expr_parse_end;
continue; continue;
case 'c': /* vtypei for vsetvli */ case 'c': /* vtypei for vsetvli */
@ -2944,7 +2946,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
ip->insn_opcode ip->insn_opcode
|= ENCODE_RVV_VC_IMM (imm_expr->X_add_number); |= ENCODE_RVV_VC_IMM (imm_expr->X_add_number);
imm_expr->X_op = O_absent; imm_expr->X_op = O_absent;
asarg = expr_end; asarg = expr_parse_end;
continue; continue;
case 'i': /* vector arith signed immediate */ case 'i': /* vector arith signed immediate */
@ -2956,7 +2958,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
"value must be -16...15")); "value must be -16...15"));
INSERT_OPERAND (VIMM, *ip, imm_expr->X_add_number); INSERT_OPERAND (VIMM, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent; imm_expr->X_op = O_absent;
asarg = expr_end; asarg = expr_parse_end;
continue; continue;
case 'j': /* vector arith unsigned immediate */ case 'j': /* vector arith unsigned immediate */
@ -2968,7 +2970,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
"value must be 0...31")); "value must be 0...31"));
INSERT_OPERAND (VIMM, *ip, imm_expr->X_add_number); INSERT_OPERAND (VIMM, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent; imm_expr->X_op = O_absent;
asarg = expr_end; asarg = expr_parse_end;
continue; continue;
case 'k': /* vector arith signed immediate, minus 1 */ case 'k': /* vector arith signed immediate, minus 1 */
@ -2980,7 +2982,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
"value must be -15...16")); "value must be -15...16"));
INSERT_OPERAND (VIMM, *ip, imm_expr->X_add_number - 1); INSERT_OPERAND (VIMM, *ip, imm_expr->X_add_number - 1);
imm_expr->X_op = O_absent; imm_expr->X_op = O_absent;
asarg = expr_end; asarg = expr_parse_end;
continue; continue;
case 'm': /* optional vector mask */ case 'm': /* optional vector mask */
@ -3041,7 +3043,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
imm_expr->X_add_number); imm_expr->X_add_number);
INSERT_OPERAND (SHAMTW, *ip, imm_expr->X_add_number); INSERT_OPERAND (SHAMTW, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent; imm_expr->X_op = O_absent;
asarg = expr_end; asarg = expr_parse_end;
continue; continue;
case '>': /* Shift amount, 0 - (XLEN-1). */ case '>': /* Shift amount, 0 - (XLEN-1). */
@ -3052,7 +3054,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
imm_expr->X_add_number); imm_expr->X_add_number);
INSERT_OPERAND (SHAMT, *ip, imm_expr->X_add_number); INSERT_OPERAND (SHAMT, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent; imm_expr->X_op = O_absent;
asarg = expr_end; asarg = expr_parse_end;
continue; continue;
case 'Z': /* CSRRxI immediate. */ case 'Z': /* CSRRxI immediate. */
@ -3063,7 +3065,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
imm_expr->X_add_number); imm_expr->X_add_number);
INSERT_OPERAND (RS1, *ip, imm_expr->X_add_number); INSERT_OPERAND (RS1, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent; imm_expr->X_op = O_absent;
asarg = expr_end; asarg = expr_parse_end;
continue; continue;
case 'E': /* Control register. */ case 'E': /* Control register. */
@ -3080,7 +3082,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
imm_expr->X_add_number); imm_expr->X_add_number);
INSERT_OPERAND (CSR, *ip, imm_expr->X_add_number); INSERT_OPERAND (CSR, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent; imm_expr->X_op = O_absent;
asarg = expr_end; asarg = expr_parse_end;
} }
continue; continue;
@ -3177,7 +3179,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
&& imm_expr->X_op != O_constant) && imm_expr->X_op != O_constant)
break; break;
normalize_constant_expr (imm_expr); normalize_constant_expr (imm_expr);
asarg = expr_end; asarg = expr_parse_end;
continue; continue;
case 'A': case 'A':
@ -3187,7 +3189,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
if (imm_expr->X_op != O_symbol) if (imm_expr->X_op != O_symbol)
break; break;
*imm_reloc = BFD_RELOC_32; *imm_reloc = BFD_RELOC_32;
asarg = expr_end; asarg = expr_parse_end;
continue; continue;
case 'B': case 'B':
@ -3198,7 +3200,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
break; break;
if (imm_expr->X_op == O_symbol) if (imm_expr->X_op == O_symbol)
*imm_reloc = BFD_RELOC_32; *imm_reloc = BFD_RELOC_32;
asarg = expr_end; asarg = expr_parse_end;
continue; continue;
case 'j': /* Sign-extended immediate. */ case 'j': /* Sign-extended immediate. */
@ -3238,14 +3240,14 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
|| imm_expr->X_add_number < -(signed)RISCV_IMM_REACH/2) || imm_expr->X_add_number < -(signed)RISCV_IMM_REACH/2)
break; break;
} }
asarg = expr_end; asarg = expr_parse_end;
continue; continue;
case 'p': /* PC-relative offset. */ case 'p': /* PC-relative offset. */
branch: branch:
*imm_reloc = BFD_RELOC_12_PCREL; *imm_reloc = BFD_RELOC_12_PCREL;
my_getExpression (imm_expr, asarg); my_getExpression (imm_expr, asarg);
asarg = expr_end; asarg = expr_parse_end;
continue; continue;
case 'u': /* Upper 20 bits. */ case 'u': /* Upper 20 bits. */
@ -3262,7 +3264,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
*imm_reloc = BFD_RELOC_RISCV_HI20; *imm_reloc = BFD_RELOC_RISCV_HI20;
imm_expr->X_add_number <<= RISCV_IMM_BITS; imm_expr->X_add_number <<= RISCV_IMM_BITS;
} }
asarg = expr_end; asarg = expr_parse_end;
continue; continue;
case 'a': /* 20-bit PC-relative offset. */ case 'a': /* 20-bit PC-relative offset. */
@ -3279,13 +3281,13 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
} }
jump: jump:
my_getExpression (imm_expr, asarg); my_getExpression (imm_expr, asarg);
asarg = expr_end; asarg = expr_parse_end;
*imm_reloc = BFD_RELOC_RISCV_JMP; *imm_reloc = BFD_RELOC_RISCV_JMP;
continue; continue;
case 'c': case 'c':
my_getExpression (imm_expr, asarg); my_getExpression (imm_expr, asarg);
asarg = expr_end; asarg = expr_parse_end;
if (strcmp (asarg, "@plt") == 0) if (strcmp (asarg, "@plt") == 0)
asarg += 4; asarg += 4;
*imm_reloc = BFD_RELOC_RISCV_CALL_PLT; *imm_reloc = BFD_RELOC_RISCV_CALL_PLT;
@ -3308,7 +3310,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
} }
INSERT_OPERAND (OP, *ip, imm_expr->X_add_number); INSERT_OPERAND (OP, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent; imm_expr->X_op = O_absent;
asarg = expr_end; asarg = expr_parse_end;
continue; continue;
case '2': case '2':
@ -3323,7 +3325,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
} }
INSERT_OPERAND (OP2, *ip, imm_expr->X_add_number); INSERT_OPERAND (OP2, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent; imm_expr->X_op = O_absent;
asarg = expr_end; asarg = expr_parse_end;
continue; continue;
default: default:
@ -3346,7 +3348,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
} }
INSERT_OPERAND (FUNCT7, *ip, imm_expr->X_add_number); INSERT_OPERAND (FUNCT7, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent; imm_expr->X_op = O_absent;
asarg = expr_end; asarg = expr_parse_end;
continue; continue;
case '3': case '3':
@ -3361,7 +3363,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
} }
INSERT_OPERAND (FUNCT3, *ip, imm_expr->X_add_number); INSERT_OPERAND (FUNCT3, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent; imm_expr->X_op = O_absent;
asarg = expr_end; asarg = expr_parse_end;
continue; continue;
case '2': case '2':
@ -3376,7 +3378,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
} }
INSERT_OPERAND (FUNCT2, *ip, imm_expr->X_add_number); INSERT_OPERAND (FUNCT2, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent; imm_expr->X_op = O_absent;
asarg = expr_end; asarg = expr_parse_end;
continue; continue;
default: default:
@ -3392,7 +3394,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
(unsigned long)imm_expr->X_add_number); (unsigned long)imm_expr->X_add_number);
INSERT_OPERAND(BS, *ip, imm_expr->X_add_number); INSERT_OPERAND(BS, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent; imm_expr->X_op = O_absent;
asarg = expr_end; asarg = expr_parse_end;
continue; continue;
case 'Y': /* rnum immediate */ case 'Y': /* rnum immediate */
@ -3403,7 +3405,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
(unsigned long)imm_expr->X_add_number); (unsigned long)imm_expr->X_add_number);
INSERT_OPERAND(RNUM, *ip, imm_expr->X_add_number); INSERT_OPERAND(RNUM, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent; imm_expr->X_op = O_absent;
asarg = expr_end; asarg = expr_parse_end;
continue; continue;
case 'z': case 'z':
@ -3411,7 +3413,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
|| imm_expr->X_op != O_constant || imm_expr->X_op != O_constant
|| imm_expr->X_add_number != 0) || imm_expr->X_add_number != 0)
break; break;
asarg = expr_end; asarg = expr_parse_end;
imm_expr->X_op = O_absent; imm_expr->X_op = O_absent;
continue; continue;
@ -3429,7 +3431,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
ENCODE_STYPE_IMM ((unsigned) (imm_expr->X_add_number) & ENCODE_STYPE_IMM ((unsigned) (imm_expr->X_add_number) &
~ 0x1fU); ~ 0x1fU);
imm_expr->X_op = O_absent; imm_expr->X_op = O_absent;
asarg = expr_end; asarg = expr_parse_end;
continue; continue;
case 'X': /* Integer immediate. */ case 'X': /* Integer immediate. */
@ -3476,7 +3478,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
} }
INSERT_IMM (n, s, *ip, imm_expr->X_add_number); INSERT_IMM (n, s, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent; imm_expr->X_op = O_absent;
asarg = expr_end; asarg = expr_parse_end;
continue; continue;
default: default:
goto unknown_riscv_ip_operand; goto unknown_riscv_ip_operand;

View File

@ -1201,7 +1201,7 @@ BSR (bfd_vma val, int amount)
} }
/* For communication between sparc_ip and get_expression. */ /* For communication between sparc_ip and get_expression. */
static char *expr_end; static char *expr_parse_end;
/* Values for `special_case'. /* Values for `special_case'.
Instructions that require weird handling because they're longer than Instructions that require weird handling because they're longer than
@ -2741,7 +2741,7 @@ sparc_ip (char *str, const struct sparc_opcode **pinsn)
*s1 = '\0'; *s1 = '\0';
(void) get_expression (s); (void) get_expression (s);
*s1 = ')'; *s1 = ')';
if (expr_end != s1) if (expr_parse_end != s1)
{ {
as_bad (_("Expression inside %%%s could not be parsed"), op_arg); as_bad (_("Expression inside %%%s could not be parsed"), op_arg);
return special_case; return special_case;
@ -2794,7 +2794,7 @@ sparc_ip (char *str, const struct sparc_opcode **pinsn)
(void) get_expression (s); (void) get_expression (s);
if (op_arg) if (op_arg)
*s = ')'; *s = ')';
s = expr_end; s = expr_parse_end;
} }
if (op_arg) if (op_arg)
@ -3373,11 +3373,11 @@ get_expression (char *str)
&& seg != undefined_section) && seg != undefined_section)
{ {
the_insn.error = _("bad segment"); the_insn.error = _("bad segment");
expr_end = input_line_pointer; expr_parse_end = input_line_pointer;
input_line_pointer = save_in; input_line_pointer = save_in;
return 1; return 1;
} }
expr_end = input_line_pointer; expr_parse_end = input_line_pointer;
input_line_pointer = save_in; input_line_pointer = save_in;
return 0; return 0;
} }

View File

@ -130,12 +130,12 @@ expr_symbol_where (symbolS *sym, const char **pfile, unsigned int *pline)
/* Look up a previously used .startof. / .sizeof. symbol, or make a fresh /* Look up a previously used .startof. / .sizeof. symbol, or make a fresh
one. */ one. */
static symbolS **seen[2];
static unsigned int nr_seen[2];
static symbolS * static symbolS *
symbol_lookup_or_make (const char *name, bool start) symbol_lookup_or_make (const char *name, bool start)
{ {
static symbolS **seen[2];
static unsigned int nr_seen[2];
char *buf = concat (start ? ".startof." : ".sizeof.", name, NULL); char *buf = concat (start ? ".startof." : ".sizeof.", name, NULL);
symbolS *symbolP; symbolS *symbolP;
unsigned int i; unsigned int i;
@ -1596,6 +1596,17 @@ expr_begin (void)
e.X_op = O_max; e.X_op = O_max;
gas_assert (e.X_op == O_max); gas_assert (e.X_op == O_max);
} }
memset (seen, 0, sizeof seen);
memset (nr_seen, 0, sizeof nr_seen);
expr_symbol_lines = NULL;
}
void
expr_end (void)
{
for (size_t i = 0; i < ARRAY_SIZE (seen); i++)
free (seen[i]);
} }
/* Return the encoding for the operator at INPUT_LINE_POINTER, and /* Return the encoding for the operator at INPUT_LINE_POINTER, and

View File

@ -175,6 +175,7 @@ typedef char operator_rankT;
extern char get_symbol_name (char **); extern char get_symbol_name (char **);
extern char restore_line_pointer (char); extern char restore_line_pointer (char);
extern void expr_begin (void); extern void expr_begin (void);
extern void expr_end (void);
extern void expr_set_precedence (void); extern void expr_set_precedence (void);
extern void expr_set_rank (operatorT, operator_rankT); extern void expr_set_rank (operatorT, operator_rankT);
extern void add_to_result (expressionS *, offsetT, int); extern void add_to_result (expressionS *, offsetT, int);

View File

@ -111,6 +111,7 @@ output_file_close (void)
md_end (); md_end ();
#endif #endif
macro_end (); macro_end ();
expr_end ();
read_end (); read_end ();
symbol_end (); symbol_end ();
subsegs_end (obs); subsegs_end (obs);