/* tc-xgate.c -- Assembler code for Freescale XGATE
- Copyright (C) 2010-2014 Free Software Foundation, Inc.
+ Copyright (C) 2010-2019 Free Software Foundation, Inc.
Contributed by Sean Keys <skeys@ipdatasys.com>
This file is part of GAS, the GNU Assembler.
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 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);
{ NULL, no_argument, NULL, 0 }
};
-size_t md_longopts_size = sizeof(md_longopts);
+size_t md_longopts_size = sizeof (md_longopts);
-char *
+const char *
md_atof (int type, char *litP, int *sizeP)
{
return ieee_md_atof (type, litP, sizeP, TRUE);
}
int
-md_parse_option (int c, char *arg)
+md_parse_option (int c, const char *arg)
{
switch (c)
{
else if (strcasecmp (arg, "v3") == 0)
current_architecture = XGATE_V3;
else
- as_bad (_(" architecture variant invalid"));
+ as_bad (_("architecture variant invalid"));
break;
case OPTION_PRINT_INSN_SYNTAX:
struct xgate_opcode *xgate_opcode_ptr = NULL;
struct xgate_opcode *xgate_op_table = NULL;
struct xgate_opcode_handle *op_handles = 0;
- char *prev_op_name = 0;
+ const char *prev_op_name = 0;
int handle_enum = 0;
int number_of_op_handles = 0;
int i, j = 0;
/* Create a local copy of our opcode table
including an extra line for NULL termination. */
- xgate_op_table = (struct xgate_opcode *)
- xmalloc ((xgate_num_opcodes) * sizeof (struct xgate_opcode));
+ xgate_op_table = XNEWVEC (struct xgate_opcode, xgate_num_opcodes);
memset (xgate_op_table, 0,
- sizeof(struct xgate_opcode) * (xgate_num_opcodes));
+ sizeof (struct xgate_opcode) * (xgate_num_opcodes));
for (xgate_opcode_ptr = (struct xgate_opcode*) xgate_opcodes, i = 0;
i < xgate_num_opcodes; i++)
xgate_op_table[i] = xgate_opcode_ptr[i];
- qsort (xgate_op_table, xgate_num_opcodes, sizeof(struct xgate_opcode),
+ qsort (xgate_op_table, xgate_num_opcodes, sizeof (struct xgate_opcode),
(int (*)(const void *, const void *)) cmp_opcode);
/* Calculate number of handles since this will be
prev_op_name = xgate_opcode_ptr->name;
}
- op_handles = (struct xgate_opcode_handle *)
- xmalloc (sizeof(struct xgate_opcode_handle) * (number_of_op_handles));
+ op_handles = XNEWVEC (struct xgate_opcode_handle, number_of_op_handles);
/* Insert unique opcode names into hash table, aliasing duplicates. */
xgate_hash = hash_new ();
-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\
+ --mxgate specify the processor variant [default %s]\n\
--print-insn-syntax print the syntax of instruction in case of error\n\
--print-opcodes print the list of instructions with syntax\n\
--generate-example generate an example of each instruction"),
symbolS *
md_undefined_symbol (char *name ATTRIBUTE_UNUSED)
{
- return 0;
+ return NULL;
}
/* GAS will call this function for each section at the end of the assembly,
valueT
md_section_align (asection * seg, valueT addr)
{
- int align = bfd_get_section_alignment (stdoutput, seg);
- return ((addr + (1 << align) - 1) & (-1 << align));
+ int align = bfd_section_alignment (seg);
+ return ((addr + (1 << align) - 1) & -(1 << align));
}
void
fixup_required = 0;
oper_check = 0; /* set error flags */
- input_line = extract_word (input_line, op_name, sizeof(op_name));
+ input_line = extract_word (input_line, op_name, sizeof (op_name));
/* Check to make sure we are not reading a bogus line. */
if (!op_name[0])
if (!opcode)
{
- as_bad (_("matching operands to opcode "));
+ as_bad (_("matching operands to opcode"));
xgate_print_syntax (opcode_handle->opc0[0]->name);
}
else if (opcode->size == 2)
}
else
{
- operandCount = xgate_get_operands(input_line, new_operands);
+ operandCount = xgate_get_operands (input_line, new_operands);
macro_opcode = xgate_find_match (opcode_handle,
opcode_handle->number_of_modes, new_operands,
- operandCount);
+ operandCount);
xgate_scan_operands (macro_opcode, new_operands);
}
}
{
arelent * reloc;
- reloc = (arelent *) xmalloc (sizeof(arelent));
- reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof(asymbol *));
+ reloc = XNEW (arelent);
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
xgate_parse_exp (char *s, expressionS * op)
{
input_line_pointer = s;
- expression(op);
+
+ expression (op);
if (op->X_op == O_absent)
as_bad (_("missing operand"));
return input_line_pointer;
switch (operandCount)
{
case 0:
- if (!strcmp(opcode_handle->opc0[i]->constraints, XGATE_OP_INH))
+ if (!strcmp (opcode_handle->opc0[i]->constraints, XGATE_OP_INH))
return opcode_handle->opc0[i];
break;
case 1:
if (oprs[0].reg >= REG_R0 && oprs[0].reg <= REG_R7)
- if (!strcmp(opcode_handle->opc0[i]->constraints, XGATE_OP_MON))
- return opcode_handle->opc0[i];
- if (!strcmp(opcode_handle->opc0[i]->constraints, XGATE_OP_DYA_MON))
- return opcode_handle->opc0[i];
+ {
+ if (!strcmp (opcode_handle->opc0[i]->constraints, XGATE_OP_MON))
+ return opcode_handle->opc0[i];
+ if (!strcmp (opcode_handle->opc0[i]->constraints, XGATE_OP_DYA_MON))
+ return opcode_handle->opc0[i];
+ }
if (oprs[0].reg == REG_NONE)
- if (!strcmp(opcode_handle->opc0[i]->constraints, XGATE_OP_IMM3))
+ if (!strcmp (opcode_handle->opc0[i]->constraints, XGATE_OP_IMM3))
return opcode_handle->opc0[i];
break;
case 2:
if (oprs[0].reg >= REG_R0 && oprs[0].reg <= REG_R7)
{
if (oprs[1].reg >= REG_R0 && oprs[1].reg <= REG_R7)
- if (!strcmp(opcode_handle->opc0[i]->constraints, XGATE_OP_DYA))
- return opcode_handle->opc0[i];
+ {
+ if (!strcmp (opcode_handle->opc0[i]->constraints, XGATE_OP_DYA))
+ return opcode_handle->opc0[i];
+ }
if (oprs[1].reg == REG_CCR)
- if (!strcmp(opcode_handle->opc0[i]->constraints,
+ if (!strcmp (opcode_handle->opc0[i]->constraints,
XGATE_OP_MON_R_C))
return opcode_handle->opc0[i];
if (oprs[1].reg == REG_PC)
- if (!strcmp(opcode_handle->opc0[i]->constraints,
+ if (!strcmp (opcode_handle->opc0[i]->constraints,
XGATE_OP_MON_R_P))
return opcode_handle->opc0[i];
if (oprs[1].reg == REG_NONE)
- if (!strcmp(opcode_handle->opc0[i]->constraints, XGATE_OP_IMM16)
- || !strcmp(opcode_handle->opc0[i]->constraints, XGATE_OP_IMM8)
- || !strcmp(opcode_handle->opc0[i]->constraints, XGATE_OP_IMM4)
- || !strcmp(opcode_handle->opc0[i]->constraints,
+ if (!strcmp (opcode_handle->opc0[i]->constraints, XGATE_OP_IMM16)
+ || !strcmp (opcode_handle->opc0[i]->constraints, XGATE_OP_IMM8)
+ || !strcmp (opcode_handle->opc0[i]->constraints, XGATE_OP_IMM4)
+ || !strcmp (opcode_handle->opc0[i]->constraints,
XGATE_OP_IMM16mADD)
- || !strcmp(opcode_handle->opc0[i]->constraints,
+ || !strcmp (opcode_handle->opc0[i]->constraints,
XGATE_OP_IMM16mAND)
- || !strcmp(opcode_handle->opc0[i]->constraints,
+ || !strcmp (opcode_handle->opc0[i]->constraints,
XGATE_OP_IMM16mCPC)
- || !strcmp(opcode_handle->opc0[i]->constraints,
+ || !strcmp (opcode_handle->opc0[i]->constraints,
XGATE_OP_IMM16mSUB)
- || !strcmp(opcode_handle->opc0[i]->constraints,
+ || !strcmp (opcode_handle->opc0[i]->constraints,
XGATE_OP_IMM16mLDW))
return opcode_handle->opc0[i];
}
if (oprs[0].reg == REG_CCR)
- if (!strcmp(opcode_handle->opc0[i]->constraints, XGATE_OP_MON_C_R))
+ if (!strcmp (opcode_handle->opc0[i]->constraints, XGATE_OP_MON_C_R))
return opcode_handle->opc0[i];
break;
case 3:
{
if (oprs[2].reg >= REG_R0 && oprs[2].reg <= REG_R7)
{
- if (!strcmp(opcode_handle->opc0[i]->constraints,
+ if (!strcmp (opcode_handle->opc0[i]->constraints,
XGATE_OP_IDR)
- || !strcmp(opcode_handle->opc0[i]->constraints,
+ || !strcmp (opcode_handle->opc0[i]->constraints,
XGATE_OP_TRI))
return opcode_handle->opc0[i];
}
if (oprs[2].reg == REG_NONE)
- if (!strcmp(opcode_handle->opc0[i]->constraints,
+ if (!strcmp (opcode_handle->opc0[i]->constraints,
XGATE_OP_IDO5))
return opcode_handle->opc0[i];
}
}
break;
default:
- as_bad(_("unknown operand count"));
+ as_bad (_("unknown operand count"));
break;
}
}
bfdsym = symbol_get_bfdsym (sym);
elfsym = elf_symbol_from (bfd_asymbol_bfd (bfdsym), bfdsym);
- gas_assert(elfsym);
+ gas_assert (elfsym);
/* Mark the symbol as being *from XGATE */
elfsym->internal_elf_sym.st_target_internal = 1;
/* reg_name_search() finds the register number given its name.
Returns the register number or REG_NONE on failure. */
+
static register_id
reg_name_search (char *name)
{
/* Parse operand modifiers such as inc/dec/hi/low. */
static op_modifiers
-xgate_determine_modifiers(char **line)
+xgate_determine_modifiers (char **line)
{
char *local_line = line[0];
++op;
bin = xgate_apply_operand (operand, &oper_mask, bin, operand_bit_length);
- if(first_operand_equals_second)
+ if (first_operand_equals_second)
bin = xgate_apply_operand (operand, &oper_mask, bin,
operand_bit_length);
/* Parse second operand. */
if (operand.reg == REG_NONE)
as_bad (_(": expected register name r0-r7 ") );
op_mask = operand.reg;
- if(operand.mod == MOD_POSTINC)
+ if (operand.mod == MOD_POSTINC)
pp_fix = INCREMENT;
- if(operand.mod == MOD_PREDEC)
+ if (operand.mod == MOD_PREDEC)
pp_fix = DECREMENT;
op_mask <<= 2;
op_mask |= pp_fix;