* config/tc-mcore.c (mcore_pool_count): New function.

(mcore_cons, mcore_float_cons, mcore_stringer, mcore_fill): Use it.
This commit is contained in:
Alan Modra 2002-11-21 11:43:40 +00:00
parent 5ff3743120
commit 5f8075fa81
2 changed files with 66 additions and 99 deletions

View File

@ -1,3 +1,8 @@
2002-11-21 Alan Modra <amodra@bigpond.net.au>
* config/tc-mcore.c (mcore_pool_count): New function.
(mcore_cons, mcore_float_cons, mcore_stringer, mcore_fill): Use it.
2002-11-20 Klee Dienes <kdienes@apple.com>
* config/tc-mcore.c (md_begin): Use a const iterator. Don't

View File

@ -37,6 +37,7 @@
/* Forward declarations for dumb compilers. */
static void mcore_s_literals PARAMS ((int));
static void mcore_pool_count PARAMS ((void (*) (int), int));
static void mcore_cons PARAMS ((int));
static void mcore_float_cons PARAMS ((int));
static void mcore_stringer PARAMS ((int));
@ -228,22 +229,35 @@ mcore_s_literals (ignore)
demand_empty_rest_of_line ();
}
/* Perform FUNC (ARG), and track number of bytes added to frag. */
static void
mcore_pool_count (func, arg)
void (*func) PARAMS ((int));
int arg;
{
const fragS *curr_frag = frag_now;
offsetT added = -frag_now_fix_octets ();
(*func) (arg);
while (curr_frag != frag_now)
{
added += curr_frag->fr_fix;
curr_frag = curr_frag->fr_next;
}
added += frag_now_fix_octets ();
poolspan += added;
}
static void
mcore_cons (nbytes)
int nbytes;
{
if (now_seg == text_section)
{
char * ptr = input_line_pointer;
int commas = 1;
/* Count the number of commas on the line. */
while (! is_end_of_line [(unsigned char) * ptr])
commas += * ptr ++ == ',';
poolspan += nbytes * commas;
}
mcore_pool_count (cons, nbytes);
else
cons (nbytes);
/* In theory we ought to call check_literals (2,0) here in case
@ -258,24 +272,8 @@ mcore_float_cons (float_type)
int float_type;
{
if (now_seg == text_section)
{
char * ptr = input_line_pointer;
int commas = 1;
#ifdef REPEAT_CONS_EXPRESSIONS
#error REPEAT_CONS_EXPRESSIONS not handled
#endif
/* Count the number of commas on the line. */
while (! is_end_of_line [(unsigned char) * ptr])
commas += * ptr ++ == ',';
/* We would like to compute "hex_float (float_type) * commas"
but hex_float is not exported from read.c */
float_type == 'f' ? 4 : (float_type == 'd' ? 8 : 12);
poolspan += float_type * commas;
}
mcore_pool_count (float_cons, float_type);
else
float_cons (float_type);
/* See the comment in mcore_cons () about calling check_literals.
@ -290,22 +288,8 @@ mcore_stringer (append_zero)
int append_zero;
{
if (now_seg == text_section)
{
char * ptr = input_line_pointer;
/* In theory we should compute how many bytes are going to
be occupied by the string(s) and add this to the poolspan.
To keep things simple however, we just add the number of
bytes left on the current line. This will be an over-
estimate, which is OK, and automatically allows for the
appending a zero byte, since the real string(s) is/are
required to be enclosed in double quotes. */
while (! is_end_of_line [(unsigned char) * ptr])
ptr ++;
poolspan += ptr - input_line_pointer;
}
mcore_pool_count (stringer, append_zero);
else
stringer (append_zero);
/* We call check_literals here in case a large number of strings are
@ -321,30 +305,8 @@ mcore_fill (unused)
int unused;
{
if (now_seg == text_section)
{
char * str = input_line_pointer;
int size = 1;
int repeat;
repeat = atoi (str);
/* Look to see if a size has been specified. */
while (*str != '\n' && *str != 0 && *str != ',')
++ str;
if (* str == ',')
{
size = atoi (str + 1);
if (size > 8)
size = 8;
else if (size < 0)
size = 0;
}
poolspan += size * repeat;
}
mcore_pool_count (s_fill, unused);
else
s_fill (unused);
check_literals (2, 0);