* config/tc-xgate.c: Make some functions static. Formatting

style and whitespace fixes.  Wrap overly long lines.  Format
	help message.
This commit is contained in:
Alan Modra
2012-11-06 10:03:32 +00:00
parent b374d0f8d9
commit 234fa27ce0
2 changed files with 336 additions and 372 deletions

View File

@ -1,3 +1,9 @@
2012-11-06 Alan Modra <amodra@gmail.com>
* config/tc-xgate.c: Make some functions static. Formatting
style and whitespace fixes. Wrap overly long lines. Format
help message.
2012-11-06 Alan Modra <amodra@gmail.com>
* config/tc-tic4x.c: Remove alignment TODO comments.

View File

@ -60,7 +60,8 @@ struct xgate_opcode_handle
struct xgate_opcode *opc0[MAX_OPCODES];
};
/* XGATE's registers all are 16-bit general purpose. They are numbered according to the specifications. */
/* XGATE's registers all are 16-bit general purpose.
They are numbered according to the specifications. */
typedef enum register_id
{
REG_NONE = -1,
@ -95,43 +96,21 @@ typedef struct s_operand
} s_operand;
/* LOCAL FUNCTIONS */
static char *
xgate_parse_exp (char *, expressionS *);
static inline char *
skip_whitespace (char *);
static void
get_default_target (void);
static char *
extract_word (char *, char *, int);
static char *
xgate_new_instruction (int size);
unsigned short
xgate_apply_operand (unsigned short, unsigned short *, unsigned short,
unsigned char);
static struct xgate_opcode *
xgate_find_match (struct xgate_opcode_handle *, int, unsigned int);
static int
cmp_opcode (struct xgate_opcode *, struct xgate_opcode *);
void
xgate_print_syntax (char *);
void
xgate_print_table (void);
unsigned int
xgate_get_operands (char *, s_operand []);
static register_id
reg_name_search (char *);
op_modifiers
xgate_determine_modifiers(char **);
/* Forward declarations. */
static inline char *skip_whitespace (char *);
static void get_default_target (void);
static char *extract_word (char *, char *, int);
static struct xgate_opcode *xgate_find_match (struct xgate_opcode_handle *,
int, unsigned int);
static int cmp_opcode (struct xgate_opcode *, struct xgate_opcode *);
static void xgate_print_table (void);
static unsigned int xgate_get_operands (char *, s_operand []);
static register_id reg_name_search (char *);
static op_modifiers xgate_determine_modifiers(char **);
static void xgate_scan_operands (struct xgate_opcode *opcode, s_operand []);
static unsigned int xgate_parse_operand (struct xgate_opcode *, int *, int,
char **, s_operand);
void
xgate_scan_operands (struct xgate_opcode *opcode, s_operand []);
static unsigned int
xgate_parse_operand (struct xgate_opcode *, int *, int where, char **,
s_operand);
/* LOCAL DATA */
static struct hash_control *xgate_hash;
/* Previous opcode. */
@ -384,13 +363,12 @@ md_show_usage (FILE * stream)
{
get_default_target ();
fprintf (
stream,
fprintf (stream,
_("\
Freescale XGATE co-processor options:\n \
-mshort use 16-bit int ABI (default)\n \
-mlong use 32-bit int ABI\n \
-mshort-double use 32-bit double ABI\n \
Freescale XGATE co-processor options:\n\
-mshort use 16-bit int ABI (default)\n\
-mlong use 32-bit int ABI\n\
-mshort-double use 32-bit double ABI\n\
-mlong-double use 64-bit double ABI (default)\n\
--mxgate specify the processor variant[default %s]\n\
--print-insn-syntax print the syntax of instruction in case of error\n\
@ -412,7 +390,7 @@ xgate_mach (void)
return 0;
}
void
static void
xgate_print_syntax (char *name)
{
int i;
@ -453,7 +431,7 @@ xgate_print_syntax (char *name)
}
}
void
static void
xgate_print_table (void)
{
int i;
@ -554,7 +532,8 @@ md_assemble (char *input_line)
input_line = skip_whitespace (input_line);
char *macro_inline = input_line;
/* Loop though the macro's opcode list and apply operands to each real opcode. */
/* Loop though the macro's opcode list and apply operands to
each real opcode. */
for (i = 0; *p && i < (opcode->size / 2); i++)
{
/* Loop though macro operand list. */
@ -564,15 +543,17 @@ md_assemble (char *input_line)
if (!(opcode_handle = (struct xgate_opcode_handle *)
hash_find (xgate_hash, op_name)))
{
as_bad (
_(": processing macro, real opcode handle not found in hash"));
as_bad (_(": processing macro, real opcode handle"
" not found in hash"));
break;
}
else
{
sh_format = xgate_get_operands(input_line, new_operands);
macro_opcode = xgate_find_match (opcode_handle,
opcode_handle->number_of_modes, sh_format);
macro_opcode
= xgate_find_match (opcode_handle,
opcode_handle->number_of_modes,
sh_format);
xgate_scan_operands (macro_opcode, new_operands);
}
@ -592,8 +573,7 @@ md_estimate_size_before_relax (fragS *fragp, asection *seg)
/* If symbol is undefined or located in a different section,
select the largest supported relocation. */
relax_substateT subtype;
relax_substateT rlx_state[] =
{ 0, 2 };
relax_substateT rlx_state[] = { 0, 2 };
for (subtype = 0; subtype < ARRAY_SIZE (rlx_state); subtype += 2)
{
@ -639,13 +619,9 @@ tc_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
if (fixp->fx_r_type == 0)
{
reloc->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_16);
}
else
{
reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
}
if (reloc->howto == (reloc_howto_type *) NULL)
{
@ -676,11 +652,10 @@ md_apply_fix (fixS * fixP, valueT * valP, segT seg ATTRIBUTE_UNUSED)
int opcode = 0;
ldiv_t result;
/* If the fixup is done mark it done so no further symbol resolution will take place. */
/* If the fixup is done mark it done so no further symbol resolution
will take place. */
if (fixP->fx_addsy == (symbolS *) NULL)
{
fixP->fx_done = 1;
}
/* We don't actually support subtracting a symbol. */
if (fixP->fx_subsy != (symbolS *) NULL)
@ -695,26 +670,34 @@ md_apply_fix (fixS * fixP, valueT * valP, segT seg ATTRIBUTE_UNUSED)
case R_XGATE_PCREL_9:
if (value < -512 || value > 511)
as_bad_where (fixP->fx_file, fixP->fx_line,
_("Value %ld too large for 9-bit PC-relative branch."), value);
_("Value %ld too large for 9-bit PC-relative branch."),
value);
result = ldiv (value, 2); /* from bytes to words */
value = result.quot;
if (result.rem)
as_bad_where (fixP->fx_file, fixP->fx_line, _
("Value %ld not aligned by 2 for 9-bit PC-relative branch."), value);
mask = 0x1FF; /* Clip into 8-bit field FIXME I'm sure there is a more proper place for this */
("Value %ld not aligned by 2 for 9-bit"
" PC-relative branch."), value);
/* Clip into 8-bit field.
FIXME I'm sure there is a more proper place for this. */
mask = 0x1FF;
value &= mask;
number_to_chars_bigendian (where, (opcode | value), 2);
break;
case R_XGATE_PCREL_10:
if (value < -1024 || value > 1023)
as_bad_where (fixP->fx_file, fixP->fx_line,
_("Value %ld too large for 10-bit PC-relative branch."), value);
_("Value %ld too large for 10-bit PC-relative branch."),
value);
result = ldiv (value, 2); /* from bytes to words */
value = result.quot;
if (result.rem)
as_bad_where (fixP->fx_file, fixP->fx_line, _
("Value %ld not aligned by 2 for 10-bit PC-relative branch."), value);
mask = 0x3FF; /* Clip into 9-bit field FIXME I'm sure there is a more proper place for this */
("Value %ld not aligned by 2 for 10-bit"
" PC-relative branch."), value);
/* Clip into 9-bit field.
FIXME I'm sure there is a more proper place for this. */
mask = 0x3FF;
value &= mask;
number_to_chars_bigendian (where, (opcode | value), 2);
break;
@ -864,7 +847,7 @@ xgate_new_instruction (int size)
return f;
}
unsigned short
static unsigned short
xgate_apply_operand (unsigned short new_mask,
unsigned short *availiable_mask_bits,
unsigned short mask,
@ -873,13 +856,15 @@ xgate_apply_operand (unsigned short new_mask,
unsigned short n_shifts;
unsigned int n_drop_bits;
/* Shift until you find an available operand bit "1" and record the number of shifts. */
/* Shift until you find an available operand bit "1" and record
the number of shifts. */
for (n_shifts = 0;
!(*availiable_mask_bits & SIXTEENTH_BIT) && n_shifts < 16;
n_shifts++)
*availiable_mask_bits <<= 1;
/* Shift for the number of bits your operand requires while bits are available. */
/* Shift for the number of bits your operand requires while bits
are available. */
for (n_drop_bits = n_bits;
n_drop_bits && (*availiable_mask_bits & SIXTEENTH_BIT);
--n_drop_bits)
@ -953,7 +938,7 @@ xgate_frob_symbol (symbolS *sym)
return 0;
}
unsigned int
static unsigned int
xgate_get_operands (char *line, s_operand oprs[])
{
int num_operands;
@ -1062,7 +1047,7 @@ reg_name_search (char *name)
/* Parse operand modifiers such as inc/dec/hi/low. */
op_modifiers
static op_modifiers
xgate_determine_modifiers(char **line)
{
char *local_line = line[0];
@ -1089,7 +1074,7 @@ xgate_determine_modifiers(char **line)
/* Parse instruction operands. */
void
static void
xgate_scan_operands (struct xgate_opcode *opcode, s_operand oprs[])
{
char *frag = xgate_new_instruction (opcode->size);
@ -1127,12 +1112,14 @@ xgate_scan_operands (struct xgate_opcode *opcode, s_operand oprs[])
first_operand_equals_second = 1;
++op;
}
operand = xgate_parse_operand (opcode, &operand_bit_length, where, &op, oprs[0]);
operand = xgate_parse_operand (opcode, &operand_bit_length, where,
&op, oprs[0]);
++op;
bin = xgate_apply_operand (operand, &oper_mask, bin, operand_bit_length);
if(first_operand_equals_second)
bin = xgate_apply_operand (operand, &oper_mask, bin, operand_bit_length);
bin = xgate_apply_operand (operand, &oper_mask, bin,
operand_bit_length);
/* Parse second operand. */
if (*op)
{
@ -1158,8 +1145,8 @@ xgate_scan_operands (struct xgate_opcode *opcode, s_operand oprs[])
{
if (*op == ',')
++op;
operand = xgate_parse_operand (opcode, &operand_bit_length, where, &op,
oprs[2]);
operand = xgate_parse_operand (opcode, &operand_bit_length, where,
&op, oprs[2]);
bin = xgate_apply_operand (operand, &oper_mask, bin,
operand_bit_length);
}
@ -1231,31 +1218,22 @@ xgate_parse_operand (struct xgate_opcode *opcode,
(*op_con)++;
op_constraint++;
if (ISDIGIT (*op_constraint))
{
*bit_width = (int) *op_constraint - '0';
}
else if (*op_constraint == 'a')
{
*bit_width = 0x0A;
}
else if (*op_constraint == 'f')
{
*bit_width = 0x0F;
}
/* http://tigcc.ticalc.org/doc/gnuasm.html#SEC31 */
if (operand.exp.X_op == O_constant)
{
op_mask = operand.exp.X_add_number;
if (((opcode->name[strlen (opcode->name) - 1] == 'l') && autoHiLo)
|| operand.mod == MOD_LOAD_LOW)
{
op_mask &= 0x00FF;
}
else if (((opcode->name[strlen (opcode->name) - 1]) == 'h'
&& autoHiLo) || operand.mod == MOD_LOAD_HIGH)
{
op_mask >>= 8;
}
/* Make sure it fits. */
for (i = *bit_width; i; i--)
@ -1275,43 +1253,28 @@ xgate_parse_operand (struct xgate_opcode *opcode,
{
if (((opcode->name[strlen (opcode->name) - 1] == 'l')
&& autoHiLo) || operand.mod == MOD_LOAD_LOW)
{
fix_new_exp (frag_now, where, 2, &operand.exp, FALSE,
BFD_RELOC_XGATE_24);
}
else if (((opcode->name[strlen (opcode->name) - 1]) == 'h'
&& autoHiLo) || operand.mod == MOD_LOAD_HIGH )
{
fix_new_exp (frag_now, where, 2, &operand.exp, FALSE,
BFD_RELOC_XGATE_IMM8_HI);
}
else
{
as_bad (_("you must use a hi/lo directive or 16-bit macro "
"to load a 16-bit value."));
break;
}
}
else if (*op_constraint == '5')
{
fix_new_exp (frag_now, where, 2, &operand.exp, FALSE,
BFD_RELOC_XGATE_IMM5);
}
else if (*op_constraint == '4')
{
fix_new_exp (frag_now, where, 2, &operand.exp, FALSE,
BFD_RELOC_XGATE_IMM4);
}
else if (*op_constraint == '3')
{
fix_new_exp (frag_now, where, 2, &operand.exp, FALSE,
BFD_RELOC_XGATE_IMM3);
}
else
{
as_bad (_(":unknown relocation constraint size"));
}
}
break;
case 'c': /* CCR register expected. */
@ -1333,20 +1296,15 @@ xgate_parse_operand (struct xgate_opcode *opcode,
if (operand.exp.X_op != O_register)
{
if (*op_constraint == '9')
{
fix_new_exp (frag_now, where, 2, &operand.exp, TRUE,
R_XGATE_PCREL_9);
}
else if (*op_constraint == 'a')
{
fix_new_exp (frag_now, where, 2, &operand.exp, TRUE,
R_XGATE_PCREL_10);
}
}
else
{
as_fatal (_("Operand `%x' not recognized in fixup8."), operand.exp.X_op);
}
as_fatal (_("Operand `%x' not recognized in fixup8."),
operand.exp.X_op);
break;
case '?':
break;