aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2023-01-14 22:13:54 +1030
committerAlan Modra <amodra@gmail.com>2023-01-16 23:25:32 +1030
commit6eb099ae9324f1210d98a406dee07f22ab26a4eb (patch)
tree3c8202ab6286e37eab4820af9500ec0c80339c92
parent6e4b74e9a962dd730e84ca54e6d5654b03e69b09 (diff)
downloadfsf-binutils-gdb-6eb099ae9324f1210d98a406dee07f22ab26a4eb.zip
fsf-binutils-gdb-6eb099ae9324f1210d98a406dee07f22ab26a4eb.tar.gz
fsf-binutils-gdb-6eb099ae9324f1210d98a406dee07f22ab26a4eb.tar.bz2
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.
-rw-r--r--gas/config/tc-hppa.c102
-rw-r--r--gas/config/tc-mips.c15
-rw-r--r--gas/config/tc-riscv.c86
-rw-r--r--gas/config/tc-sparc.c10
-rw-r--r--gas/expr.c15
-rw-r--r--gas/expr.h1
-rw-r--r--gas/output-file.c1
7 files changed, 123 insertions, 107 deletions
diff --git a/gas/config/tc-hppa.c b/gas/config/tc-hppa.c
index 360fc9c..c91b2b5 100644
--- a/gas/config/tc-hppa.c
+++ b/gas/config/tc-hppa.c
@@ -591,7 +591,7 @@ static struct pa_it the_insn;
/* Points to the end of an expression just parsed by get_expression
and friends. FIXME. This shouldn't be handled with a file-global
variable. */
-static char *expr_end;
+static char *expr_parse_end;
/* Nonzero if a .callinfo appeared within the current procedure. */
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);
}
-/* 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
get_expression (char *str)
@@ -1286,11 +1286,11 @@ get_expression (char *str)
|| SEG_NORMAL (seg)))
{
as_warn (_("Bad segment in expression."));
- expr_end = input_line_pointer;
+ expr_parse_end = input_line_pointer;
input_line_pointer = save_in;
return;
}
- expr_end = input_line_pointer;
+ expr_parse_end = input_line_pointer;
input_line_pointer = save_in;
}
@@ -2518,7 +2518,7 @@ evaluate_absolute (struct pa_it *insn)
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
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;
input_line_pointer = *strp;
expression (&insn->exp);
- expr_end = input_line_pointer;
+ expr_parse_end = input_line_pointer;
input_line_pointer = save_in;
if (insn->exp.X_op != O_constant)
{
@@ -3346,7 +3346,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant)
break;
- s = expr_end;
+ s = expr_parse_end;
CHECK_FIELD (num, 32, 1, 0);
SAVE_IMMEDIATE(num);
INSERT_FIELD_AND_CONTINUE (opcode, 32 - num, 0);
@@ -3356,7 +3356,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant)
break;
- s = expr_end;
+ s = expr_parse_end;
/* When in strict mode, we want to just reject this
match instead of giving an out of range error. */
CHECK_FIELD (num, 15, -16, strict);
@@ -3368,7 +3368,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant)
break;
- s = expr_end;
+ s = expr_parse_end;
/* When in strict mode, we want to just reject this
match instead of giving an out of range error. */
CHECK_FIELD (num, 15, -16, strict);
@@ -3380,7 +3380,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant)
break;
- s = expr_end;
+ s = expr_parse_end;
CHECK_FIELD (num, 31, 0, strict);
INSERT_FIELD_AND_CONTINUE (opcode, num, 0);
@@ -3389,7 +3389,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant)
break;
- s = expr_end;
+ s = expr_parse_end;
CHECK_FIELD (num, 31, 0, strict);
INSERT_FIELD_AND_CONTINUE (opcode, num, 16);
@@ -3398,7 +3398,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant)
break;
- s = expr_end;
+ s = expr_parse_end;
CHECK_FIELD (num, 1023, 0, strict);
INSERT_FIELD_AND_CONTINUE (opcode, num, 16);
@@ -4556,7 +4556,7 @@ pa_ip (char *str)
are 0..6 inclusive. */
case 'h':
get_expression (s);
- s = expr_end;
+ s = expr_parse_end;
if (the_insn.exp.X_op == O_constant)
{
num = evaluate_absolute (&the_insn);
@@ -4573,7 +4573,7 @@ pa_ip (char *str)
get_expression (s);
if (the_insn.exp.X_op == O_constant)
{
- s = expr_end;
+ s = expr_parse_end;
num = evaluate_absolute (&the_insn);
CHECK_FIELD (num, 6, 0, 0);
num = (num + 1) ^ 1;
@@ -4593,7 +4593,7 @@ pa_ip (char *str)
case 'i':
the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s);
- s = expr_end;
+ s = expr_parse_end;
if (the_insn.exp.X_op == O_constant)
{
num = evaluate_absolute (&the_insn);
@@ -4629,7 +4629,7 @@ pa_ip (char *str)
case 'J':
the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s);
- s = expr_end;
+ s = expr_parse_end;
if (the_insn.exp.X_op == O_constant)
{
int mb;
@@ -4653,7 +4653,7 @@ pa_ip (char *str)
case 'K':
the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s);
- s = expr_end;
+ s = expr_parse_end;
if (the_insn.exp.X_op == O_constant)
{
int mb;
@@ -4675,7 +4675,7 @@ pa_ip (char *str)
case '<':
the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s);
- s = expr_end;
+ s = expr_parse_end;
if (the_insn.exp.X_op == O_constant)
{
int mb;
@@ -4695,7 +4695,7 @@ pa_ip (char *str)
case '>':
the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s);
- s = expr_end;
+ s = expr_parse_end;
if (the_insn.exp.X_op == O_constant)
{
int mb;
@@ -4719,7 +4719,7 @@ pa_ip (char *str)
break;
the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s);
- s = expr_end;
+ s = expr_parse_end;
if (the_insn.exp.X_op == O_constant)
{
num = evaluate_absolute (&the_insn);
@@ -4761,7 +4761,7 @@ pa_ip (char *str)
case 'd':
the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s);
- s = expr_end;
+ s = expr_parse_end;
if (the_insn.exp.X_op == O_constant)
{
num = evaluate_absolute (&the_insn);
@@ -4802,7 +4802,7 @@ pa_ip (char *str)
case 'j':
the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s);
- s = expr_end;
+ s = expr_parse_end;
if (the_insn.exp.X_op == O_constant)
{
num = evaluate_absolute (&the_insn);
@@ -4838,7 +4838,7 @@ pa_ip (char *str)
case 'k':
the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s);
- s = expr_end;
+ s = expr_parse_end;
if (the_insn.exp.X_op == O_constant)
{
num = evaluate_absolute (&the_insn);
@@ -4874,7 +4874,7 @@ pa_ip (char *str)
case 'l':
the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s);
- s = expr_end;
+ s = expr_parse_end;
if (the_insn.exp.X_op == O_constant)
{
num = evaluate_absolute (&the_insn);
@@ -4911,7 +4911,7 @@ pa_ip (char *str)
case 'y':
the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s);
- s = expr_end;
+ s = expr_parse_end;
if (the_insn.exp.X_op == O_constant)
{
num = evaluate_absolute (&the_insn);
@@ -4949,7 +4949,7 @@ pa_ip (char *str)
case '&':
the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s);
- s = expr_end;
+ s = expr_parse_end;
if (the_insn.exp.X_op == O_constant)
{
num = evaluate_absolute (&the_insn);
@@ -4987,7 +4987,7 @@ pa_ip (char *str)
case 'w':
the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s);
- s = expr_end;
+ s = expr_parse_end;
the_insn.pcrel = 1;
if (!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.arg_reloc = last_call_desc.arg_reloc;
memset (&last_call_desc, 0, sizeof (struct call_desc));
- s = expr_end;
+ s = expr_parse_end;
continue;
}
@@ -5019,7 +5019,7 @@ pa_ip (char *str)
case 'W':
the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s);
- s = expr_end;
+ s = expr_parse_end;
the_insn.pcrel = 1;
if (!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':
the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s);
- s = expr_end;
+ s = expr_parse_end;
the_insn.pcrel = 1;
if (!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':
the_insn.field_selector = pa_chk_field_selector (&s);
get_expression (s);
- s = expr_end;
+ s = expr_parse_end;
the_insn.pcrel = 0;
if (!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);
if (strict && the_insn.exp.X_op != O_constant)
break;
- s = expr_end;
+ s = expr_parse_end;
CHECK_FIELD (num, 3, 1, strict);
INSERT_FIELD_AND_CONTINUE (opcode, num, 6);
@@ -5146,7 +5146,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant)
break;
- s = expr_end;
+ s = expr_parse_end;
CHECK_FIELD (num, 15, 0, strict);
INSERT_FIELD_AND_CONTINUE (opcode, num, 6);
@@ -5155,7 +5155,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant)
break;
- s = expr_end;
+ s = expr_parse_end;
CHECK_FIELD (num, 31, 0, strict);
SAVE_IMMEDIATE(num);
INSERT_FIELD_AND_CONTINUE (opcode, 31 - num, 5);
@@ -5165,7 +5165,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant)
break;
- s = expr_end;
+ s = expr_parse_end;
CHECK_FIELD (num, 63, 0, strict);
SAVE_IMMEDIATE(num);
num = 63 - num;
@@ -5178,7 +5178,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant)
break;
- s = expr_end;
+ s = expr_parse_end;
CHECK_FIELD (num, 64, 1, strict);
SAVE_IMMEDIATE(num);
num--;
@@ -5191,7 +5191,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant)
break;
- s = expr_end;
+ s = expr_parse_end;
CHECK_FIELD (num, 64, 1, strict);
SAVE_IMMEDIATE(num);
num--;
@@ -5204,7 +5204,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant)
break;
- s = expr_end;
+ s = expr_parse_end;
CHECK_FIELD (num, 31, 0, strict);
SAVE_IMMEDIATE(num);
INSERT_FIELD_AND_CONTINUE (opcode, num, 5);
@@ -5214,7 +5214,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant)
break;
- s = expr_end;
+ s = expr_parse_end;
CHECK_FIELD (num, 63, 0, strict);
SAVE_IMMEDIATE(num);
opcode |= (num & 0x20) << 6;
@@ -5226,7 +5226,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant)
break;
- s = expr_end;
+ s = expr_parse_end;
CHECK_FIELD (num, 63, 0, strict);
if (num & 0x20)
opcode &= ~(1 << 13);
@@ -5237,7 +5237,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant)
break;
- s = expr_end;
+ s = expr_parse_end;
CHECK_FIELD (num, 31, 0, strict);
INSERT_FIELD_AND_CONTINUE (opcode, num, 21);
@@ -5246,7 +5246,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant)
break;
- s = expr_end;
+ s = expr_parse_end;
CHECK_FIELD (num, 511, 1, strict);
INSERT_FIELD_AND_CONTINUE (opcode, num, 3);
@@ -5255,7 +5255,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant)
break;
- s = expr_end;
+ s = expr_parse_end;
CHECK_FIELD (num, 8191, 0, strict);
INSERT_FIELD_AND_CONTINUE (opcode, num, 13);
@@ -5264,7 +5264,7 @@ pa_ip (char *str)
num = pa_get_absolute_expression (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant)
break;
- s = expr_end;
+ s = expr_parse_end;
CHECK_FIELD (num, 67108863, 0, strict);
INSERT_FIELD_AND_CONTINUE (opcode, num, 0);
@@ -5275,7 +5275,7 @@ pa_ip (char *str)
num = pa_get_number (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant)
break;
- s = expr_end;
+ s = expr_parse_end;
CHECK_FIELD (num, 7, 0, strict);
INSERT_FIELD_AND_CONTINUE (opcode, num, 6);
@@ -5284,7 +5284,7 @@ pa_ip (char *str)
num = pa_get_number (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant)
break;
- s = expr_end;
+ s = expr_parse_end;
CHECK_FIELD (num, 1048575, 0, strict);
num = (num & 0x1f) | ((num & 0x000fffe0) << 6);
INSERT_FIELD_AND_CONTINUE (opcode, num, 0);
@@ -5294,7 +5294,7 @@ pa_ip (char *str)
num = pa_get_number (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant)
break;
- s = expr_end;
+ s = expr_parse_end;
CHECK_FIELD (num, 32767, 0, strict);
INSERT_FIELD_AND_CONTINUE (opcode, num, 11);
@@ -5303,7 +5303,7 @@ pa_ip (char *str)
num = pa_get_number (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant)
break;
- s = expr_end;
+ s = expr_parse_end;
CHECK_FIELD (num, 1023, 0, strict);
num = (num & 0x1f) | ((num & 0x000003e0) << 6);
INSERT_FIELD_AND_CONTINUE (opcode, num, 0);
@@ -5313,7 +5313,7 @@ pa_ip (char *str)
num = pa_get_number (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant)
break;
- s = expr_end;
+ s = expr_parse_end;
CHECK_FIELD (num, 32767, 0, strict);
num = (num & 0x1f) | ((num & 0x00007fe0) << 6);
INSERT_FIELD_AND_CONTINUE (opcode, num, 0);
@@ -5325,7 +5325,7 @@ pa_ip (char *str)
num = pa_get_number (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant)
break;
- s = expr_end;
+ s = expr_parse_end;
CHECK_FIELD (num, 7, 0, strict);
INSERT_FIELD_AND_CONTINUE (opcode, num, 6);
@@ -5334,7 +5334,7 @@ pa_ip (char *str)
num = pa_get_number (&the_insn, &s);
if (strict && the_insn.exp.X_op != O_constant)
break;
- s = expr_end;
+ s = expr_parse_end;
CHECK_FIELD (num, 4194303, 0, strict);
num = (num & 0x1f) | ((num & 0x003fffe0) << 4);
INSERT_FIELD_AND_CONTINUE (opcode, num, 0);
diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
index e59021e..e911aaa 100644
--- a/gas/config/tc-mips.c
+++ b/gas/config/tc-mips.c
@@ -2038,7 +2038,7 @@ mips_mark_labels (void)
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
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"));
return 0;
}
- s = expr_end;
+ s = expr_parse_end;
token.u.index = element.X_add_number;
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[2] = BFD_RELOC_UNUSED;
my_getSmallExpression (&token.u.integer.value, token.u.integer.relocs, s);
- s = expr_end;
+ s = expr_parse_end;
mips_add_token (&token, OT_INTEGER);
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
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
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]));
my_getExpression (ep, crux);
- str = expr_end;
+ str = expr_parse_end;
/* Match every open bracket. */
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)
as_bad (_("unclosed '('"));
- expr_end = str;
+ expr_parse_end = str;
for (i = 0; i < reloc_index; i++)
reloc[i] = reversed_reloc[reloc_index - 1 - i];
@@ -14715,7 +14716,7 @@ my_getExpression (expressionS *ep, char *str)
save_in = input_line_pointer;
input_line_pointer = str;
expression (ep);
- expr_end = input_line_pointer;
+ expr_parse_end = input_line_pointer;
input_line_pointer = save_in;
}
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index 6793b64..3ec474c 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -445,7 +445,7 @@ static bool explicit_attr = false;
/* Indicate CSR or priv instructions are explicitly used. */
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. */
#define RELAX_BRANCH_ENCODE(uncond, rvc, length) \
@@ -914,7 +914,7 @@ opcode_name_lookup (char **s)
*s = e;
*e = save_c;
- expr_end = e;
+ expr_parse_end = e;
return o;
}
@@ -2212,7 +2212,7 @@ my_getExpression (expressionS *ep, char *str)
save_in = input_line_pointer;
input_line_pointer = str;
expression (ep);
- expr_end = input_line_pointer;
+ expr_parse_end = input_line_pointer;
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.
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
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_add_number = regno;
- expr_end = str;
+ expr_parse_end = str;
return 0;
}
@@ -2265,7 +2266,7 @@ my_getSmallExpression (expressionS *ep, bfd_reloc_code_real_type *reloc,
&& parse_relocation (&str, reloc, percent_op));
my_getExpression (ep, crux);
- str = expr_end;
+ str = expr_parse_end;
/* Match every open bracket. */
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)
as_bad ("unclosed '('");
- expr_end = str;
+ expr_parse_end = str;
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.
- 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
my_getVsetvliExpression (expressionS *ep, char *str)
@@ -2349,12 +2351,12 @@ my_getVsetvliExpression (expressionS *ep, char *str)
| (vsew_value << OP_SH_VSEW)
| (vta_value << OP_SH_VTA)
| (vma_value << OP_SH_VMA);
- expr_end = str;
+ expr_parse_end = str;
}
else
{
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;
ip->insn_opcode |= ENCODE_CITYPE_IMM (imm_expr->X_add_number);
rvc_imm_done:
- asarg = expr_end;
+ asarg = expr_parse_end;
imm_expr->X_op = O_absent;
continue;
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);
imm_expr->X_op = O_absent;
- asarg = expr_end;
+ asarg = expr_parse_end;
continue;
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);
imm_expr->X_op = O_absent;
- asarg = expr_end;
+ asarg = expr_parse_end;
continue;
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);
imm_expr->X_op = O_absent;
- asarg = expr_end;
+ asarg = expr_parse_end;
continue;
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);
imm_expr->X_op = O_absent;
- asarg = expr_end;
+ asarg = expr_parse_end;
continue;
default:
@@ -2932,7 +2934,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
ip->insn_opcode
|= ENCODE_RVV_VB_IMM (imm_expr->X_add_number);
imm_expr->X_op = O_absent;
- asarg = expr_end;
+ asarg = expr_parse_end;
continue;
case 'c': /* vtypei for vsetvli */
@@ -2944,7 +2946,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
ip->insn_opcode
|= ENCODE_RVV_VC_IMM (imm_expr->X_add_number);
imm_expr->X_op = O_absent;
- asarg = expr_end;
+ asarg = expr_parse_end;
continue;
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"));
INSERT_OPERAND (VIMM, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent;
- asarg = expr_end;
+ asarg = expr_parse_end;
continue;
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"));
INSERT_OPERAND (VIMM, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent;
- asarg = expr_end;
+ asarg = expr_parse_end;
continue;
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"));
INSERT_OPERAND (VIMM, *ip, imm_expr->X_add_number - 1);
imm_expr->X_op = O_absent;
- asarg = expr_end;
+ asarg = expr_parse_end;
continue;
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);
INSERT_OPERAND (SHAMTW, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent;
- asarg = expr_end;
+ asarg = expr_parse_end;
continue;
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);
INSERT_OPERAND (SHAMT, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent;
- asarg = expr_end;
+ asarg = expr_parse_end;
continue;
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);
INSERT_OPERAND (RS1, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent;
- asarg = expr_end;
+ asarg = expr_parse_end;
continue;
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);
INSERT_OPERAND (CSR, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent;
- asarg = expr_end;
+ asarg = expr_parse_end;
}
continue;
@@ -3177,7 +3179,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
&& imm_expr->X_op != O_constant)
break;
normalize_constant_expr (imm_expr);
- asarg = expr_end;
+ asarg = expr_parse_end;
continue;
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)
break;
*imm_reloc = BFD_RELOC_32;
- asarg = expr_end;
+ asarg = expr_parse_end;
continue;
case 'B':
@@ -3198,7 +3200,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
break;
if (imm_expr->X_op == O_symbol)
*imm_reloc = BFD_RELOC_32;
- asarg = expr_end;
+ asarg = expr_parse_end;
continue;
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)
break;
}
- asarg = expr_end;
+ asarg = expr_parse_end;
continue;
case 'p': /* PC-relative offset. */
branch:
*imm_reloc = BFD_RELOC_12_PCREL;
my_getExpression (imm_expr, asarg);
- asarg = expr_end;
+ asarg = expr_parse_end;
continue;
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_expr->X_add_number <<= RISCV_IMM_BITS;
}
- asarg = expr_end;
+ asarg = expr_parse_end;
continue;
case 'a': /* 20-bit PC-relative offset. */
@@ -3279,13 +3281,13 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
}
jump:
my_getExpression (imm_expr, asarg);
- asarg = expr_end;
+ asarg = expr_parse_end;
*imm_reloc = BFD_RELOC_RISCV_JMP;
continue;
case 'c':
my_getExpression (imm_expr, asarg);
- asarg = expr_end;
+ asarg = expr_parse_end;
if (strcmp (asarg, "@plt") == 0)
asarg += 4;
*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);
imm_expr->X_op = O_absent;
- asarg = expr_end;
+ asarg = expr_parse_end;
continue;
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);
imm_expr->X_op = O_absent;
- asarg = expr_end;
+ asarg = expr_parse_end;
continue;
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);
imm_expr->X_op = O_absent;
- asarg = expr_end;
+ asarg = expr_parse_end;
continue;
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);
imm_expr->X_op = O_absent;
- asarg = expr_end;
+ asarg = expr_parse_end;
continue;
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);
imm_expr->X_op = O_absent;
- asarg = expr_end;
+ asarg = expr_parse_end;
continue;
default:
@@ -3392,7 +3394,7 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
(unsigned long)imm_expr->X_add_number);
INSERT_OPERAND(BS, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent;
- asarg = expr_end;
+ asarg = expr_parse_end;
continue;
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);
INSERT_OPERAND(RNUM, *ip, imm_expr->X_add_number);
imm_expr->X_op = O_absent;
- asarg = expr_end;
+ asarg = expr_parse_end;
continue;
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_add_number != 0)
break;
- asarg = expr_end;
+ asarg = expr_parse_end;
imm_expr->X_op = O_absent;
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) &
~ 0x1fU);
imm_expr->X_op = O_absent;
- asarg = expr_end;
+ asarg = expr_parse_end;
continue;
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);
imm_expr->X_op = O_absent;
- asarg = expr_end;
+ asarg = expr_parse_end;
continue;
default:
goto unknown_riscv_ip_operand;
diff --git a/gas/config/tc-sparc.c b/gas/config/tc-sparc.c
index a5acd56..eada5e5 100644
--- a/gas/config/tc-sparc.c
+++ b/gas/config/tc-sparc.c
@@ -1201,7 +1201,7 @@ BSR (bfd_vma val, int amount)
}
/* For communication between sparc_ip and get_expression. */
-static char *expr_end;
+static char *expr_parse_end;
/* Values for `special_case'.
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';
(void) get_expression (s);
*s1 = ')';
- if (expr_end != s1)
+ if (expr_parse_end != s1)
{
as_bad (_("Expression inside %%%s could not be parsed"), op_arg);
return special_case;
@@ -2794,7 +2794,7 @@ sparc_ip (char *str, const struct sparc_opcode **pinsn)
(void) get_expression (s);
if (op_arg)
*s = ')';
- s = expr_end;
+ s = expr_parse_end;
}
if (op_arg)
@@ -3373,11 +3373,11 @@ get_expression (char *str)
&& seg != undefined_section)
{
the_insn.error = _("bad segment");
- expr_end = input_line_pointer;
+ expr_parse_end = input_line_pointer;
input_line_pointer = save_in;
return 1;
}
- expr_end = input_line_pointer;
+ expr_parse_end = input_line_pointer;
input_line_pointer = save_in;
return 0;
}
diff --git a/gas/expr.c b/gas/expr.c
index 28ec58c..ba3d210 100644
--- a/gas/expr.c
+++ b/gas/expr.c
@@ -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
one. */
+static symbolS **seen[2];
+static unsigned int nr_seen[2];
static symbolS *
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);
symbolS *symbolP;
unsigned int i;
@@ -1596,6 +1596,17 @@ expr_begin (void)
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
diff --git a/gas/expr.h b/gas/expr.h
index ae57a3e..8de272f 100644
--- a/gas/expr.h
+++ b/gas/expr.h
@@ -175,6 +175,7 @@ typedef char operator_rankT;
extern char get_symbol_name (char **);
extern char restore_line_pointer (char);
extern void expr_begin (void);
+extern void expr_end (void);
extern void expr_set_precedence (void);
extern void expr_set_rank (operatorT, operator_rankT);
extern void add_to_result (expressionS *, offsetT, int);
diff --git a/gas/output-file.c b/gas/output-file.c
index 0c3a811..4c97e8f 100644
--- a/gas/output-file.c
+++ b/gas/output-file.c
@@ -111,6 +111,7 @@ output_file_close (void)
md_end ();
#endif
macro_end ();
+ expr_end ();
read_end ();
symbol_end ();
subsegs_end (obs);