Remove redundant code for checking numbers with suffixes. Add

functionality to break out of assembler loops.
This commit is contained in:
Timothy Wall 2000-02-08 19:06:00 +00:00
parent f15632584b
commit 6dc19fc4d6
4 changed files with 53 additions and 28 deletions

View File

@ -1,3 +1,13 @@
2000-02-08 Timothy Wall <twall@redhat.com>
* read.c (s_rept): Call do_repeat, which abstracts the repeat
logic.
(do_repeat): New. Abstract repeat logic so that a "break" can be
implemented.
(end_repeat): New. Provide support for a "break" out of the
repeat loop.
* read.h: Add prototypes for new functions.
2000-02-08 Timothy Wall <twall@redhat.com>
* doc/internals.texi: Document NUMBERS_WITH_SUFFIX macro.

View File

@ -833,25 +833,6 @@ operand (expressionP)
integer_constant (0, expressionP);
break;
}
if (NUMBERS_WITH_SUFFIX)
{
/* Check for a binary constant. */
for (s = input_line_pointer; *s == '0' || *s == '1'; s++)
;
if (toupper (*s) == 'B')
{
integer_constant (0, expressionP);
break;
}
/* Check for an octal constant. */
for (s = input_line_pointer; *s >= '0' && *s <= '7'; s++)
;
if (toupper (*s) == 'Q')
{
integer_constant (0, expressionP);
break;
}
}
}
c = *input_line_pointer;
switch (c)
@ -888,14 +869,14 @@ operand (expressionP)
case 'x':
case 'X':
if (flag_m68k_mri)
if (flag_m68k_mri || NUMBERS_WITH_SUFFIX)
goto default_case;
input_line_pointer++;
integer_constant (16, expressionP);
break;
case 'b':
if (LOCAL_LABELS_FB && ! flag_m68k_mri && ! NUMBERS_WITH_SUFFIX)
if (LOCAL_LABELS_FB && ! (flag_m68k_mri || NUMBERS_WITH_SUFFIX))
{
/* This code used to check for '+' and '-' here, and, in
some conditions, fall through to call
@ -917,7 +898,7 @@ operand (expressionP)
/* Fall through. */
case 'B':
input_line_pointer++;
if (flag_m68k_mri)
if (flag_m68k_mri || NUMBERS_WITH_SUFFIX)
goto default_case;
integer_constant (2, expressionP);
break;
@ -930,7 +911,9 @@ operand (expressionP)
case '5':
case '6':
case '7':
integer_constant (flag_m68k_mri ? 0 : 8, expressionP);
integer_constant ((flag_m68k_mri || NUMBERS_WITH_SUFFIX)
? 0 : 8,
expressionP);
break;
case 'f':
@ -980,7 +963,7 @@ operand (expressionP)
case 'd':
case 'D':
if (flag_m68k_mri)
if (flag_m68k_mri || NUMBERS_WITH_SUFFIX)
{
integer_constant (0, expressionP);
break;

View File

@ -2644,15 +2644,28 @@ s_rept (ignore)
int ignore ATTRIBUTE_UNUSED;
{
int count;
sb one;
sb many;
count = get_absolute_expression ();
do_repeat(count, "REPT", "ENDR");
}
/* This function provides a generic repeat block implementation. It allows
different directives to be used as the start/end keys. */
void
do_repeat (count, start, end)
int count;
const char *start;
const char *end;
{
sb one;
sb many;
sb_new (&one);
if (! buffer_and_nest ("REPT", "ENDR", &one, get_line_sb))
if (! buffer_and_nest (start, end, &one, get_line_sb))
{
as_bad (_("rept without endr"));
as_bad (_("%s without %s"), start, end);
return;
}
@ -2667,6 +2680,23 @@ s_rept (ignore)
buffer_limit = input_scrub_next_buffer (&input_line_pointer);
}
/* Skip to end of current repeat loop; EXTRA indicates how many additional
input buffers to skip. Assumes that conditionals preceding the loop end
are properly nested.
This function makes it easier to implement a premature "break" out of the
loop. The EXTRA arg accounts for other buffers we might have inserted,
such as line substitutions. */
void
end_repeat (extra)
int extra;
{
cond_exit_macro (macro_nest);
while (extra-- >= 0)
buffer_limit = input_scrub_next_buffer (&input_line_pointer);
}
/* Handle the .equ, .equiv and .set directives. If EQUIV is 1, then
this is .equiv, and it is an error if the symbol is already
defined. */

View File

@ -116,6 +116,8 @@ extern void stabs_generate_asm_file PARAMS ((void));
extern void stabs_generate_asm_lineno PARAMS ((void));
extern void stabs_generate_asm_func PARAMS ((const char *, const char *));
extern void stabs_generate_asm_endfunc PARAMS ((const char *, const char *));
extern void do_repeat PARAMS((int,const char *,const char *));
extern void end_repeat PARAMS((int));
extern void generate_lineno_debug PARAMS ((void));