2000-08-05 Kazu Hirata <kazu@hxi.com>

* config/tc-cris.c: Fix formatting.
	* config/tc-i386.c: Likewise.
	* config/tc-sparc.c (sparc_ip): Simplify the code.
This commit is contained in:
Kazu Hirata
2000-08-04 18:43:45 +00:00
parent afbb8d7a46
commit 47926f603c
4 changed files with 725 additions and 736 deletions

View File

@ -1,3 +1,9 @@
2000-08-05 Kazu Hirata <kazu@hxi.com>
* config/tc-cris.c: Fix formatting.
* config/tc-i386.c: Likewise.
* config/tc-sparc.c (sparc_ip): Simplify the code.
2000-08-04 Kazu Hirata <kazu@hxi.com>
* config/tc-cris.c: Rearrange code for readability.

View File

@ -133,11 +133,11 @@ const char cris_comment_chars[] = ";";
/* This array holds the chars that only start a comment at the beginning of
a line. If the line seems to have the form '# 123 filename'
.line and .file directives will appear in the pre-processed output */
.line and .file directives will appear in the pre-processed output. */
/* Note that input_file.c hand-checks for '#' at the beginning of the
first line of the input file. This is because the compiler outputs
#NO_APP at the beginning of its output. */
/* Also note that slash-star will always start a comment */
/* Also note that slash-star will always start a comment. */
const char line_comment_chars[] = "#";
const char line_separator_chars[] = "@";
@ -145,7 +145,6 @@ const char line_separator_chars[] = "@";
const char EXP_CHARS[] = "";
const char FLT_CHARS[] = "";
/* For CRIS, we encode the relax_substateTs (in e.g. fr_substate) as:
2 1 0
---/ /--+-----------------+-----------------+-----------------+
@ -175,15 +174,14 @@ const char FLT_CHARS[] = "";
#define STATE_UNDF (3)
#define STATE_MAX_LENGTH (3)
/* These displacements are relative to the adress following the opcode
word of the instruction. The first letter is Byte, Word. The 2nd
letter is Forward, Backward. */
#define BRANCH_BF ( 254)
#define BRANCH_BB (-256)
#define BRANCH_WF (2+ 32767)
#define BRANCH_WB (2+-32768)
#define BRANCH_WF (2 + 32767)
#define BRANCH_WB (2 + -32768)
#define BDAP_BF ( 127)
#define BDAP_BB (-128)
@ -238,7 +236,6 @@ const relax_typeS md_cris_relax_table[] =
#undef BDAP_WF
#undef BDAP_WB
/* Target-specific multicharacter options, not const-declared at usage
in 2.9.1 and CVS of 2000-02-16. */
struct option md_longopts[] =
@ -250,7 +247,6 @@ struct option md_longopts[] =
size_t md_longopts_size = sizeof (md_longopts);
const char *md_shortopts = "hHN";
/* At first glance, this may seems wrong and should be 4 (ba + nop); but
since a short_jump must skip a *number* of long jumps, it must also be
a long jump. Here, we hope to make it a "ba [16bit_offs]" and a "nop"
@ -264,8 +260,8 @@ const char *md_shortopts = "hHN";
const int md_short_jump_size = 6;
const int md_long_jump_size = 6;
/* Report output format. */
const char *
cris_target_format ()
{
@ -327,7 +323,7 @@ md_estimate_size_before_relax (fragP, segment_type)
fragP->fr_fix += 2 + 2 + 2 + 4;
writep = fragP->fr_literal + old_fr_fix;
gen_cond_branch_32 (fragP->fr_opcode, writep, fragP,
fragP->fr_symbol, (symbolS *)NULL,
fragP->fr_symbol, (symbolS *) NULL,
fragP->fr_offset);
frag_wane (fragP);
}
@ -418,7 +414,6 @@ md_estimate_size_before_relax (fragP, segment_type)
return fragP->fr_var + (fragP->fr_fix - old_fr_fix);
}
/* Perform post-processing of machine-dependent frags after relaxation.
Called after relaxation is finished.
In: Address of frag.
@ -496,7 +491,7 @@ md_convert_frag (abfd, sec, fragP)
case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_DWORD):
gen_cond_branch_32 (fragP->fr_opcode, var_partp, fragP,
fragP->fr_symbol, (symbolS *)NULL,
fragP->fr_symbol, (symbolS *) NULL,
fragP->fr_offset);
/* Ten bytes added: a branch, nop and a jump. */
var_part_size = 2 + 2 + 4 + 2;
@ -513,7 +508,7 @@ md_convert_frag (abfd, sec, fragP)
opcodep[0] = BDAP_PC_LOW + (1 << 4);
opcodep[1] &= 0xF0;
opcodep[1] |= BDAP_INCR_HIGH;
md_number_to_chars (var_partp, (long)(target_address), 2);
md_number_to_chars (var_partp, (long) (target_address), 2);
var_part_size = 2;
break;
@ -536,7 +531,6 @@ md_convert_frag (abfd, sec, fragP)
}
fragP->fr_fix += var_part_size;
}
/* Generate a short jump around a secondary jump table.
@ -562,15 +556,15 @@ cris_create_short_jump (storep, from_addr, to_addr, fragP, to_symbol)
if (-254 <= distance && distance <= 256)
{
/* Create a "short" short jump: "BA distance - 2". */
storep[0] = branch_disp (distance-2);
storep[0] = branch_disp (distance - 2);
storep[1] = BA_QUICK_HIGH;
/* A nop for the delay slot. */
md_number_to_chars (storep+2, NOP_OPCODE, 2);
md_number_to_chars (storep + 2, NOP_OPCODE, 2);
/* The extra word should be filled with something sane too. Make it
a nop to keep disassembly sane. */
md_number_to_chars (storep+4, NOP_OPCODE, 2);
md_number_to_chars (storep + 4, NOP_OPCODE, 2);
}
else
{
@ -581,11 +575,10 @@ cris_create_short_jump (storep, from_addr, to_addr, fragP, to_symbol)
md_number_to_chars (storep + 2, (long) (distance - 4), 2);
/* A nop for the delay slot. */
md_number_to_chars (storep+4, NOP_OPCODE, 2);
md_number_to_chars (storep + 4, NOP_OPCODE, 2);
}
}
/* Generate a long jump in a secondary jump table.
storep Where to store the jump instruction.
@ -624,8 +617,8 @@ md_create_long_jump (storep, from_addr, to_addr, fragP, to_symbol)
}
}
/* Port-specific assembler initialization. */
void
md_begin ()
{
@ -652,13 +645,14 @@ md_begin ()
cris_opcodes[i].args);
++i;
} while (cris_opcodes[i].name != NULL
}
while (cris_opcodes[i].name != NULL
&& strcmp (cris_opcodes[i].name, name) == 0);
}
}
/* Assemble a source line. */
void
md_assemble (str)
char *str;
@ -735,7 +729,7 @@ md_assemble (str)
opcodep = frag_more (2);
/* Output the instruction opcode. */
md_number_to_chars (opcodep, (long)(output_instruction.opcode), 2);
md_number_to_chars (opcodep, (long) (output_instruction.opcode), 2);
/* Output the symbol-dependent instruction stuff. */
if (output_instruction.insn_type == CRIS_INSN_BRANCH)
@ -773,7 +767,7 @@ md_assemble (str)
branch. */
gen_cond_branch_32 (opcodep, frag_more (10), frag_now,
output_instruction.expr.X_add_symbol,
(symbolS *)NULL,
(symbolS *) NULL,
output_instruction.expr.X_add_number);
}
}
@ -823,8 +817,8 @@ md_assemble (str)
}
}
/* Low level text-to-bits assembly. */
static void
cris_process_instruction (insn_text, out_insnp, prefixp)
char *insn_text;
@ -851,9 +845,7 @@ cris_process_instruction (insn_text, out_insnp, prefixp)
/* Find the end of the opcode mnemonic. We assume (true in 2.9.1)
that the caller has translated the opcode to lower-case, up to the
first non-letter. */
for (operands = insn_text;
islower (*operands);
++operands)
for (operands = insn_text; islower (*operands); ++operands)
;
/* Terminate the opcode after letters, but save the character there if
@ -864,13 +856,13 @@ cris_process_instruction (insn_text, out_insnp, prefixp)
break;
case '.':
/* Put back the modified character later */
/* Put back the modified character later. */
modified_char = *operands;
/* FALLTHROUGH. */
/* Fall through. */
case ' ':
/* Consume the character after the mnemonic and replace */
/* it with '\0'. */
/* Consume the character after the mnemonic
and replace it with '\0'. */
*operands++ = '\0';
break;
@ -897,11 +889,8 @@ cris_process_instruction (insn_text, out_insnp, prefixp)
*--operands = modified_char;
}
/* Try to match an opcode table slot. */
for (s = operands;
;
)
for (s = operands;;)
{
int imm_expr_found;
@ -921,9 +910,7 @@ cris_process_instruction (insn_text, out_insnp, prefixp)
/* Build the opcode, checking as we go to make sure that the
operands match. */
for (args = instruction->args;
;
++args)
for (args = instruction->args;; ++args)
{
switch (*args)
{
@ -1011,8 +998,7 @@ cris_process_instruction (insn_text, out_insnp, prefixp)
if (! get_flags (&s, &flags))
break;
out_insnp->opcode
|= ((flags & 0xf0) << 8) | (flags & 0xf);
out_insnp->opcode |= ((flags & 0xf0) << 8) | (flags & 0xf);
continue;
}
@ -1203,8 +1189,7 @@ cris_process_instruction (insn_text, out_insnp, prefixp)
break;
else
{
out_insnp->opcode |=
(regno << 12) | (size_bits << 4);
out_insnp->opcode |= (regno << 12) | (size_bits << 4);
continue;
}
@ -1312,7 +1297,7 @@ cris_process_instruction (insn_text, out_insnp, prefixp)
|| out_insnp->expr.X_add_number > 255))
as_bad (_("Immediate value not in 8 bit range: %ld"),
out_insnp->expr.X_add_number);
/* FALLTHROUGH. */
/* Fall through. */
case 2:
/* FIXME: We need an indicator in the instruction
table to pass on, to indicate if we need to check
@ -1343,7 +1328,7 @@ cris_process_instruction (insn_text, out_insnp, prefixp)
|| out_insnp->expr.X_add_number > 255))
as_bad (_("Immediate value not in 8 bit range: %ld"),
out_insnp->expr.X_add_number);
/* FALLTHROUGH. */
/* Fall through. */
case 1:
if (out_insnp->expr.X_op == O_constant
&& (out_insnp->expr.X_add_number < -32768
@ -1367,7 +1352,6 @@ cris_process_instruction (insn_text, out_insnp, prefixp)
}
}
/* Get a B, W, or D size modifier from the string pointed out by *cPP,
which must point to a '.' in front of the modifier. On successful
return, *cPP is advanced to the character following the size
@ -1390,7 +1374,7 @@ get_bwd_size_modifier (cPP, size_bitsp)
return 0;
else
{
/* Consume the '.' */
/* Consume the '.'. */
(*cPP)++;
switch (**cPP)
@ -1420,7 +1404,6 @@ get_bwd_size_modifier (cPP, size_bitsp)
}
}
/* Get a B or W size modifier from the string pointed out by *cPP,
which must point to a '.' in front of the modifier. On successful
return, *cPP is advanced to the character following the size
@ -1443,7 +1426,7 @@ get_bw_size_modifier (cPP, size_bitsp)
return 0;
else
{
/* Consume the '.' */
/* Consume the '.'. */
(*cPP)++;
switch (**cPP)
@ -1468,7 +1451,6 @@ get_bw_size_modifier (cPP, size_bitsp)
}
}
/* Get a general register from the string pointed out by *cPP. The
variable *cPP is advanced to the character following the general
register name on a successful return, and has its initial position
@ -1509,7 +1491,7 @@ get_gen_reg (cPP, regnop)
case 'R':
case 'r':
/* Hopefully r[0-9] or r1[0-5]. Consume 'R' or 'r' */
/* Hopefully r[0-9] or r1[0-5]. Consume 'R' or 'r'. */
(*cPP)++;
if (isdigit (**cPP))
@ -1526,7 +1508,7 @@ get_gen_reg (cPP, regnop)
else
{
/* One more digit. Consume and add. */
*regnop = *regnop*10 + (**cPP - '0');
*regnop = *regnop * 10 + (**cPP - '0');
/* We need to check for a valid register number; Rn,
0 <= n <= MAX_REG. */
@ -1563,7 +1545,6 @@ get_gen_reg (cPP, regnop)
return 0;
}
/* Get a special register from the string pointed out by *cPP. The
variable *cPP is advanced to the character following the special
register name if one is found, and retains its original position
@ -1588,11 +1569,8 @@ get_spec_reg (cPP, sregpp)
const struct cris_spec_reg *sregp;
/* Loop over all special registers. */
for (sregp = cris_spec_regs;
sregp->name != NULL;
sregp++)
for (sregp = cris_spec_regs; sregp->name != NULL; sregp++)
{
/* Start over from beginning of the supposed name. */
s1 = *cPP;
s2 = sregp->name;
@ -1620,7 +1598,6 @@ get_spec_reg (cPP, sregpp)
return 0;
}
/* Get an unprefixed or side-effect-prefix operand from the string pointed
out by *cPP. The pointer *cPP is advanced to the character following
the indirect operand if we have success, else it contains an undefined
@ -1850,7 +1827,6 @@ get_autoinc_prefix_or_indir_op (cPP, prefixp, is_autoincp, src_regnop,
return 0;
}
/* This function gets an indirect operand in a three-address operand
combination from the string pointed out by *cPP. The pointer *cPP is
advanced to the character following the indirect operand on success, or
@ -2041,8 +2017,7 @@ get_3op_or_dip_prefix_op (cPP, prefixp)
/* Expression found, the so called absolute mode for a
double-indirect prefix on PC. */
prefixp->kind = PREFIX_DIP;
prefixp->opcode
= DIP_OPCODE | (AUTOINCR_BIT << 8) | REG_PC;
prefixp->opcode = DIP_OPCODE | (AUTOINCR_BIT << 8) | REG_PC;
prefixp->reloc = BFD_RELOC_32;
}
else
@ -2060,7 +2035,6 @@ get_3op_or_dip_prefix_op (cPP, prefixp)
return 1;
}
/* Get an expression from the string pointed out by *cPP.
The pointer *cPP is advanced to the character following the expression
on a success, or retains its original value otherwise.
@ -2099,7 +2073,6 @@ cris_get_expression (cPP, exprP)
return 1;
}
/* Get a sequence of flag characters from *spp. The pointer *cPP is
advanced to the character following the expression. The flag
characters are consecutive, no commas or spaces.
@ -2179,7 +2152,6 @@ get_flags (cPP, flagsp)
}
}
/* Generate code and fixes for a BDAP prefix.
base_regno Int containing the base register number.
@ -2239,7 +2211,6 @@ gen_bdap (base_regno, exprP)
exprP->X_add_symbol, exprP->X_add_number, opcodep);
}
/* Encode a branch displacement in the range -256..254 into the form used
by CRIS conditional branch instructions.
@ -2259,7 +2230,6 @@ branch_disp (offset)
return disp;
}
/* Generate code and fixes for a 32-bit conditional branch instruction
created by "extending" an existing 8-bit branch instruction.
@ -2301,7 +2271,7 @@ gen_cond_branch_32 (opcodep, writep, fragP, add_symP, sub_symP, add_num)
it's not the optimal extended construct, but we should get this
rarely enough that it shouldn't matter. */
writep[8] = branch_disp (-2-6);
writep[8] = branch_disp (-2 - 6);
writep[9] = opcodep[1];
/* Then, we change the branch to an unconditional branch over the
@ -2338,12 +2308,11 @@ gen_cond_branch_32 (opcodep, writep, fragP, add_symP, sub_symP, add_num)
}
}
/* This *could* be:
Turn a string in input_line_pointer into a floating point constant of
type type, and store the appropriate bytes in *litp. The number of
LITTLENUMS emitted is stored in *sizep.
Turn a string in input_line_pointer into a floating point constant
of type TYPE, and store the appropriate bytes in *LITP. The number
of LITTLENUMS emitted is stored in *SIZEP.
type A character from FLTCHARS that describes what kind of
floating-point number is wanted.
@ -2370,7 +2339,6 @@ md_atof (type, litp, sizep)
return _("Bad call to md_atof () - floating point formats are not supported");
}
/* Turn a number as a fixS * into a series of bytes that represents the
number on the target machine. The purpose of this procedure is the
same as that of md_number_to_chars but this procedure is supposed to
@ -2503,10 +2471,10 @@ cris_number_to_imm (bufp, val, n, fixP)
}
}
/* Processes machine-dependent command line options. Called once for
each option on the command line that the machine-independent part of
GAS does not understand. */
int
md_parse_option (arg, argp)
int arg;
@ -2517,7 +2485,8 @@ md_parse_option (arg, argp)
case 'H':
case 'h':
md_show_usage (stdout);
exit (0); /* Don't continue */
/* Don't continue. */
exit (0);
case 'N':
warn_for_branch_expansion = 1;
@ -2558,7 +2527,6 @@ md_section_align (segment, size)
return size;
}
/* Generate a machine-dependent relocation. */
arelent *
tc_gen_reloc (section, fixP)
@ -2640,8 +2608,8 @@ tc_gen_reloc (section, fixP)
return relP;
}
/* Machine-dependent usage-output. */
void
md_show_usage (stream)
FILE *stream;
@ -2664,7 +2632,6 @@ md_show_usage (stream)
fprintf (stream, _("Description : Assembler for the CRIS processor.\n"));
}
/* Apply a fixS (fixup of an instruction or data that we didn't have
enough info to complete immediately) to the data in a frag. */
@ -2707,7 +2674,6 @@ md_apply_fix (fixP, valP)
return 1;
}
/* All relocations are relative to the location just after the fixup;
the address of the fixup plus its size. */
@ -2727,7 +2693,6 @@ md_pcrel_from (fixP)
return fixP->fx_size + addr;
}
/* We have no need to give defaults for symbol-values. */
symbolS *
md_undefined_symbol (name)
@ -2736,7 +2701,6 @@ md_undefined_symbol (name)
return 0;
}
/* Definition of TC_FORCE_RELOCATION.
FIXME: Unsure of this. Can we omit it? Just copied from tc-i386.c
when doing multi-object format with ELF, since it's the only other

File diff suppressed because it is too large Load Diff

View File

@ -1420,10 +1420,12 @@ sparc_ip (str, pinsn)
goto error;
}
kmask |= mask;
while (*s == ' ') { ++s; continue; }
while (*s == ' ')
++s;
if (*s == '|' || *s == '+')
++s;
while (*s == ' ') { ++s; continue; }
while (*s == ' ')
++s;
}
}
else