2000-08-09 11:33:42 +08:00
|
|
|
|
/* tc-i860.c -- Assembler for the Intel i860 architecture.
|
2006-06-07 19:27:58 +08:00
|
|
|
|
Copyright 1989, 1992, 1993, 1994, 1995, 1998, 1999, 2000, 2001, 2002,
|
2009-09-02 15:25:43 +08:00
|
|
|
|
2003, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
|
|
|
|
Brought back from the dead and completely reworked
|
|
|
|
|
by Jason Eckhardt <jle@cygnus.com>.
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
This file is part of GAS, the GNU Assembler.
|
|
|
|
|
|
|
|
|
|
GAS is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-07-03 19:01:12 +08:00
|
|
|
|
the Free Software Foundation; either version 3, or (at your option)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
|
|
GAS is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
|
|
|
with GAS; see the file COPYING. If not, write to the Free Software
|
2005-05-05 17:13:19 +08:00
|
|
|
|
Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
#include "as.h"
|
2001-09-19 13:33:36 +08:00
|
|
|
|
#include "safe-ctype.h"
|
2000-08-09 11:33:42 +08:00
|
|
|
|
#include "subsegs.h"
|
1999-05-03 15:29:11 +08:00
|
|
|
|
#include "opcode/i860.h"
|
2000-08-09 11:33:42 +08:00
|
|
|
|
#include "elf/i860.h"
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* The opcode hash table. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
static struct hash_control *op_hash = NULL;
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* These characters always start a comment. */
|
|
|
|
|
const char comment_chars[] = "#!/";
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* These characters start a comment at the beginning of a line. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
const char line_comment_chars[] = "#/";
|
|
|
|
|
|
2000-06-09 08:00:04 +08:00
|
|
|
|
const char line_separator_chars[] = ";";
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Characters that can be used to separate the mantissa from the exponent
|
|
|
|
|
in floating point numbers. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
const char EXP_CHARS[] = "eE";
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Characters that indicate this number is a floating point constant.
|
|
|
|
|
As in 0f12.456 or 0d1.2345e12. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
const char FLT_CHARS[] = "rRsSfFdDxXpP";
|
|
|
|
|
|
2003-08-02 11:03:52 +08:00
|
|
|
|
/* Register prefix (depends on syntax). */
|
|
|
|
|
static char reg_prefix;
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
2003-05-12 11:35:34 +08:00
|
|
|
|
#define MAX_FIXUPS 2
|
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
struct i860_it
|
2000-08-09 11:33:42 +08:00
|
|
|
|
{
|
|
|
|
|
char *error;
|
|
|
|
|
unsigned long opcode;
|
|
|
|
|
enum expand_type expand;
|
2003-05-12 11:35:34 +08:00
|
|
|
|
struct i860_fi
|
|
|
|
|
{
|
|
|
|
|
expressionS exp;
|
|
|
|
|
bfd_reloc_code_real_type reloc;
|
|
|
|
|
int pcrel;
|
|
|
|
|
valueT fup;
|
|
|
|
|
} fi[MAX_FIXUPS];
|
2000-08-09 11:33:42 +08:00
|
|
|
|
} the_insn;
|
|
|
|
|
|
2003-05-12 11:35:34 +08:00
|
|
|
|
/* The current fixup count. */
|
|
|
|
|
static int fc;
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
static char *expr_end;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Indicates error if a pseudo operation was expanded after a branch. */
|
|
|
|
|
static char last_expand;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* If true, then warn if any pseudo operations were expanded. */
|
|
|
|
|
static int target_warn_expand = 0;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2003-05-24 12:22:23 +08:00
|
|
|
|
/* If true, then XP support is enabled. */
|
|
|
|
|
static int target_xp = 0;
|
|
|
|
|
|
2003-08-02 11:03:52 +08:00
|
|
|
|
/* If true, then Intel syntax is enabled (default to AT&T/SVR4 syntax). */
|
|
|
|
|
static int target_intel_syntax = 0;
|
|
|
|
|
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Prototypes. */
|
2003-07-31 04:24:55 +08:00
|
|
|
|
static void i860_process_insn (char *);
|
|
|
|
|
static void s_dual (int);
|
|
|
|
|
static void s_enddual (int);
|
|
|
|
|
static void s_atmp (int);
|
2003-08-07 12:05:42 +08:00
|
|
|
|
static void s_align_wrapper (int);
|
2003-07-31 04:24:55 +08:00
|
|
|
|
static int i860_get_expression (char *);
|
|
|
|
|
static bfd_reloc_code_real_type obtain_reloc_for_imm16 (fixS *, long *);
|
2000-08-09 11:33:42 +08:00
|
|
|
|
#ifdef DEBUG_I860
|
2003-07-31 04:24:55 +08:00
|
|
|
|
static void print_insn (struct i860_it *);
|
2000-08-09 11:33:42 +08:00
|
|
|
|
#endif
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
const pseudo_typeS md_pseudo_table[] =
|
|
|
|
|
{
|
2003-08-07 12:05:42 +08:00
|
|
|
|
{"align", s_align_wrapper, 0},
|
|
|
|
|
{"dual", s_dual, 0},
|
|
|
|
|
{"enddual", s_enddual, 0},
|
|
|
|
|
{"atmp", s_atmp, 0},
|
|
|
|
|
{NULL, 0, 0},
|
2000-08-09 11:33:42 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Dual-instruction mode handling. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
enum dual
|
|
|
|
|
{
|
|
|
|
|
DUAL_OFF = 0, DUAL_ON, DUAL_DDOT, DUAL_ONDDOT,
|
|
|
|
|
};
|
2000-08-09 11:33:42 +08:00
|
|
|
|
static enum dual dual_mode = DUAL_OFF;
|
|
|
|
|
|
|
|
|
|
/* Handle ".dual" directive. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
static void
|
2003-07-31 04:24:55 +08:00
|
|
|
|
s_dual (int ignore ATTRIBUTE_UNUSED)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2003-08-06 06:58:00 +08:00
|
|
|
|
if (target_intel_syntax)
|
|
|
|
|
dual_mode = DUAL_ON;
|
|
|
|
|
else
|
|
|
|
|
as_bad (_("Directive .dual available only with -mintel-syntax option"));
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Handle ".enddual" directive. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
static void
|
2003-07-31 04:24:55 +08:00
|
|
|
|
s_enddual (int ignore ATTRIBUTE_UNUSED)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2003-08-06 06:58:00 +08:00
|
|
|
|
if (target_intel_syntax)
|
|
|
|
|
dual_mode = DUAL_OFF;
|
|
|
|
|
else
|
|
|
|
|
as_bad (_("Directive .enddual available only with -mintel-syntax option"));
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Temporary register used when expanding assembler pseudo operations. */
|
|
|
|
|
static int atmp = 31;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
static void
|
2003-07-31 04:24:55 +08:00
|
|
|
|
s_atmp (int ignore ATTRIBUTE_UNUSED)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2003-08-06 06:58:00 +08:00
|
|
|
|
int temp;
|
|
|
|
|
|
|
|
|
|
if (! target_intel_syntax)
|
|
|
|
|
{
|
|
|
|
|
as_bad (_("Directive .atmp available only with -mintel-syntax option"));
|
|
|
|
|
demand_empty_rest_of_line ();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (strncmp (input_line_pointer, "sp", 2) == 0)
|
|
|
|
|
{
|
|
|
|
|
input_line_pointer += 2;
|
|
|
|
|
atmp = 2;
|
|
|
|
|
}
|
|
|
|
|
else if (strncmp (input_line_pointer, "fp", 2) == 0)
|
|
|
|
|
{
|
|
|
|
|
input_line_pointer += 2;
|
|
|
|
|
atmp = 3;
|
|
|
|
|
}
|
|
|
|
|
else if (strncmp (input_line_pointer, "r", 1) == 0)
|
|
|
|
|
{
|
|
|
|
|
input_line_pointer += 1;
|
|
|
|
|
temp = get_absolute_expression ();
|
|
|
|
|
if (temp >= 0 && temp <= 31)
|
|
|
|
|
atmp = temp;
|
|
|
|
|
else
|
|
|
|
|
as_bad (_("Unknown temporary pseudo register"));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
as_bad (_("Unknown temporary pseudo register"));
|
|
|
|
|
}
|
|
|
|
|
demand_empty_rest_of_line ();
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-07 12:05:42 +08:00
|
|
|
|
/* Handle ".align" directive depending on syntax mode.
|
|
|
|
|
AT&T/SVR4 syntax uses the standard align directive. However,
|
|
|
|
|
the Intel syntax additionally allows keywords for the alignment
|
|
|
|
|
parameter: ".align type", where type is one of {.short, .long,
|
|
|
|
|
.quad, .single, .double} representing alignments of 2, 4,
|
|
|
|
|
16, 4, and 8, respectively. */
|
|
|
|
|
static void
|
|
|
|
|
s_align_wrapper (int arg)
|
|
|
|
|
{
|
|
|
|
|
char *parm = input_line_pointer;
|
|
|
|
|
|
|
|
|
|
if (target_intel_syntax)
|
|
|
|
|
{
|
|
|
|
|
/* Replace a keyword with the equivalent integer so the
|
|
|
|
|
standard align routine can parse the directive. */
|
|
|
|
|
if (strncmp (parm, ".short", 6) == 0)
|
|
|
|
|
strncpy (parm, " 2", 6);
|
|
|
|
|
else if (strncmp (parm, ".long", 5) == 0)
|
|
|
|
|
strncpy (parm, " 4", 5);
|
|
|
|
|
else if (strncmp (parm, ".quad", 5) == 0)
|
|
|
|
|
strncpy (parm, " 16", 5);
|
|
|
|
|
else if (strncmp (parm, ".single", 7) == 0)
|
|
|
|
|
strncpy (parm, " 4", 7);
|
|
|
|
|
else if (strncmp (parm, ".double", 7) == 0)
|
|
|
|
|
strncpy (parm, " 8", 7);
|
|
|
|
|
|
|
|
|
|
while (*input_line_pointer == ' ')
|
|
|
|
|
++input_line_pointer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
s_align_bytes (arg);
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
/* This function is called once, at assembler startup time. It should
|
2000-08-09 11:33:42 +08:00
|
|
|
|
set up all the tables and data structures that the MD part of the
|
|
|
|
|
assembler will need. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
void
|
2003-07-31 04:24:55 +08:00
|
|
|
|
md_begin (void)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2000-08-09 11:33:42 +08:00
|
|
|
|
const char *retval = NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
int lose = 0;
|
2000-08-09 11:33:42 +08:00
|
|
|
|
unsigned int i = 0;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
op_hash = hash_new ();
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
while (i860_opcodes[i].name != NULL)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
const char *name = i860_opcodes[i].name;
|
2008-08-13 07:39:31 +08:00
|
|
|
|
retval = hash_insert (op_hash, name, (void *) &i860_opcodes[i]);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (retval != NULL)
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, _("internal error: can't hash `%s': %s\n"),
|
|
|
|
|
i860_opcodes[i].name, retval);
|
|
|
|
|
lose = 1;
|
|
|
|
|
}
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
if (i860_opcodes[i].match & i860_opcodes[i].lose)
|
|
|
|
|
{
|
2000-08-09 11:33:42 +08:00
|
|
|
|
fprintf (stderr,
|
|
|
|
|
_("internal error: losing opcode: `%s' \"%s\"\n"),
|
1999-05-03 15:29:11 +08:00
|
|
|
|
i860_opcodes[i].name, i860_opcodes[i].args);
|
|
|
|
|
lose = 1;
|
|
|
|
|
}
|
|
|
|
|
++i;
|
|
|
|
|
}
|
2000-08-09 11:33:42 +08:00
|
|
|
|
while (i860_opcodes[i].name != NULL
|
|
|
|
|
&& strcmp (i860_opcodes[i].name, name) == 0);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (lose)
|
2000-08-09 11:33:42 +08:00
|
|
|
|
as_fatal (_("Defective assembler. No assembly attempted."));
|
2003-08-02 11:03:52 +08:00
|
|
|
|
|
|
|
|
|
/* Set the register prefix for either Intel or AT&T/SVR4 syntax. */
|
|
|
|
|
reg_prefix = target_intel_syntax ? 0 : '%';
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* This is the core of the machine-dependent assembler. STR points to a
|
|
|
|
|
machine dependent instruction. This function emits the frags/bytes
|
|
|
|
|
it assembles to. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
void
|
2003-07-31 04:24:55 +08:00
|
|
|
|
md_assemble (char *str)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2000-08-09 11:33:42 +08:00
|
|
|
|
char *destp;
|
|
|
|
|
int num_opcodes = 1;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
int i;
|
|
|
|
|
struct i860_it pseudo[3];
|
|
|
|
|
|
* gas/app, gas/as.c, gas/as.h, gas/atof-generic.c, gas/cgen.c,
gas/config/atof-ieee.c, gas/config/obj-aout.c,
gas/config/obj-coff.c, gas/config/obj-ecoff.c,
gas/config/obj-elf.c, gas/config/obj-som.c, gas/config/tc-alpha.c,
gas/config/tc-arc.c, gas/config/tc-arm.c, gas/config/tc-cr16.c,
gas/config/tc-cris.c, gas/config/tc-crx.c, gas/config/tc-d30v.c,
gas/config/tc-dlx.c, gas/config/tc-hppa.c, gas/config/tc-i370.c,
gas/config/tc-i386-intel.c, gas/config/tc-i386.c,
gas/config/tc-i860.c, gas/config/tc-i960.c, gas/config/tc-ia64.c,
gas/config/tc-iq2000.c, gas/config/tc-m32c.c,
gas/config/tc-m32r.c, gas/config/tc-m68hc11.c,
gas/config/tc-m68k.c, gas/config/tc-maxq.c, gas/config/tc-mcore.c,
gas/config/tc-mep.c, gas/config/tc-mips.c, gas/config/tc-mmix.c,
gas/config/tc-mn10300.c, gas/config/tc-moxie.c,
gas/config/tc-ns32k.c, gas/config/tc-pj.c, gas/config/tc-ppc.c,
gas/config/tc-s390.c, gas/config/tc-score.c,
gas/config/tc-score7.c, gas/config/tc-sh.c, gas/config/tc-sparc.c,
gas/config/tc-spu.c, gas/config/tc-tic30.c, gas/config/tc-vax.c,
gas/config/tc-xtensa.c, gas/config/xtensa-relax.c,
gas/dw2gencfi.c, gas/dwarf2dbg.c, gas/ehopt.c, gas/expr.c,
gas/frags.c, gas/input-file.c, gas/read.c, gas/sb.c,
gas/subsegs.c, gas/symbols.c, gas/write.c: Change the name of the
gas macro `assert' to `gas_assert'.
2009-06-23 01:56:02 +08:00
|
|
|
|
gas_assert (str);
|
2003-05-12 11:35:34 +08:00
|
|
|
|
fc = 0;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Assemble the instruction. */
|
|
|
|
|
i860_process_insn (str);
|
|
|
|
|
|
|
|
|
|
/* Check for expandable flag to produce pseudo-instructions. This
|
|
|
|
|
is an undesirable feature that should be avoided. */
|
2003-05-24 12:22:23 +08:00
|
|
|
|
if (the_insn.expand != 0 && the_insn.expand != XP_ONLY
|
2003-05-12 11:35:34 +08:00
|
|
|
|
&& ! (the_insn.fi[0].fup & (OP_SEL_HA | OP_SEL_H | OP_SEL_L | OP_SEL_GOT
|
2000-08-09 11:33:42 +08:00
|
|
|
|
| OP_SEL_GOTOFF | OP_SEL_PLT)))
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
|
pseudo[i] = the_insn;
|
|
|
|
|
|
2003-05-12 11:35:34 +08:00
|
|
|
|
fc = 1;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
switch (the_insn.expand)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
case E_DELAY:
|
2000-08-09 11:33:42 +08:00
|
|
|
|
num_opcodes = 1;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case E_MOV:
|
2003-05-12 11:35:34 +08:00
|
|
|
|
if (the_insn.fi[0].exp.X_add_symbol == NULL
|
|
|
|
|
&& the_insn.fi[0].exp.X_op_symbol == NULL
|
|
|
|
|
&& (the_insn.fi[0].exp.X_add_number < (1 << 15)
|
|
|
|
|
&& the_insn.fi[0].exp.X_add_number >= -(1 << 15)))
|
1999-05-03 15:29:11 +08:00
|
|
|
|
break;
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
|
|
|
|
/* Emit "or l%const,r0,ireg_dest". */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
pseudo[0].opcode = (the_insn.opcode & 0x001f0000) | 0xe4000000;
|
2003-05-12 11:35:34 +08:00
|
|
|
|
pseudo[0].fi[0].fup = (OP_IMM_S16 | OP_SEL_L);
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
|
|
|
|
/* Emit "orh h%const,ireg_dest,ireg_dest". */
|
|
|
|
|
pseudo[1].opcode = (the_insn.opcode & 0x03ffffff) | 0xec000000
|
|
|
|
|
| ((the_insn.opcode & 0x001f0000) << 5);
|
2003-05-12 11:35:34 +08:00
|
|
|
|
pseudo[1].fi[0].fup = (OP_IMM_S16 | OP_SEL_H);
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
|
|
|
|
num_opcodes = 2;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case E_ADDR:
|
2003-05-12 11:35:34 +08:00
|
|
|
|
if (the_insn.fi[0].exp.X_add_symbol == NULL
|
|
|
|
|
&& the_insn.fi[0].exp.X_op_symbol == NULL
|
|
|
|
|
&& (the_insn.fi[0].exp.X_add_number < (1 << 15)
|
|
|
|
|
&& the_insn.fi[0].exp.X_add_number >= -(1 << 15)))
|
1999-05-03 15:29:11 +08:00
|
|
|
|
break;
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
2003-08-25 10:48:14 +08:00
|
|
|
|
/* Emit "orh ha%addr_expr,ireg_src2,r31". */
|
|
|
|
|
pseudo[0].opcode = 0xec000000 | (the_insn.opcode & 0x03e00000)
|
|
|
|
|
| (atmp << 16);
|
2003-05-12 11:35:34 +08:00
|
|
|
|
pseudo[0].fi[0].fup = (OP_IMM_S16 | OP_SEL_HA);
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
|
|
|
|
/* Emit "l%addr_expr(r31),ireg_dest". We pick up the fixup
|
|
|
|
|
information from the original instruction. */
|
|
|
|
|
pseudo[1].opcode = (the_insn.opcode & ~0x03e00000) | (atmp << 21);
|
2003-05-12 11:35:34 +08:00
|
|
|
|
pseudo[1].fi[0].fup = the_insn.fi[0].fup | OP_SEL_L;
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
|
|
|
|
num_opcodes = 2;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
break;
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
case E_U32:
|
2003-05-12 11:35:34 +08:00
|
|
|
|
if (the_insn.fi[0].exp.X_add_symbol == NULL
|
|
|
|
|
&& the_insn.fi[0].exp.X_op_symbol == NULL
|
|
|
|
|
&& (the_insn.fi[0].exp.X_add_number < (1 << 16)
|
|
|
|
|
&& the_insn.fi[0].exp.X_add_number >= 0))
|
1999-05-03 15:29:11 +08:00
|
|
|
|
break;
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
|
|
|
|
/* Emit "$(opcode)h h%const,ireg_src2,r31". */
|
|
|
|
|
pseudo[0].opcode = (the_insn.opcode & 0xf3e0ffff) | 0x0c000000
|
|
|
|
|
| (atmp << 16);
|
2003-05-12 11:35:34 +08:00
|
|
|
|
pseudo[0].fi[0].fup = (OP_IMM_S16 | OP_SEL_H);
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
|
|
|
|
/* Emit "$(opcode) l%const,r31,ireg_dest". */
|
|
|
|
|
pseudo[1].opcode = (the_insn.opcode & 0xf01f0000) | 0x04000000
|
|
|
|
|
| (atmp << 21);
|
2003-05-12 11:35:34 +08:00
|
|
|
|
pseudo[1].fi[0].fup = (OP_IMM_S16 | OP_SEL_L);
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
|
|
|
|
num_opcodes = 2;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
break;
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
case E_AND:
|
2003-05-12 11:35:34 +08:00
|
|
|
|
if (the_insn.fi[0].exp.X_add_symbol == NULL
|
|
|
|
|
&& the_insn.fi[0].exp.X_op_symbol == NULL
|
|
|
|
|
&& (the_insn.fi[0].exp.X_add_number < (1 << 16)
|
|
|
|
|
&& the_insn.fi[0].exp.X_add_number >= 0))
|
1999-05-03 15:29:11 +08:00
|
|
|
|
break;
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
|
|
|
|
/* Emit "andnot h%const,ireg_src2,r31". */
|
|
|
|
|
pseudo[0].opcode = (the_insn.opcode & 0x03e0ffff) | 0xd4000000
|
|
|
|
|
| (atmp << 16);
|
2003-05-12 11:35:34 +08:00
|
|
|
|
pseudo[0].fi[0].fup = (OP_IMM_S16 | OP_SEL_H);
|
|
|
|
|
pseudo[0].fi[0].exp.X_add_number =
|
|
|
|
|
-1 - the_insn.fi[0].exp.X_add_number;
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
|
|
|
|
/* Emit "andnot l%const,r31,ireg_dest". */
|
|
|
|
|
pseudo[1].opcode = (the_insn.opcode & 0x001f0000) | 0xd4000000
|
|
|
|
|
| (atmp << 21);
|
2003-05-12 11:35:34 +08:00
|
|
|
|
pseudo[1].fi[0].fup = (OP_IMM_S16 | OP_SEL_L);
|
|
|
|
|
pseudo[1].fi[0].exp.X_add_number =
|
|
|
|
|
-1 - the_insn.fi[0].exp.X_add_number;
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
|
|
|
|
num_opcodes = 2;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case E_S32:
|
2003-05-12 11:35:34 +08:00
|
|
|
|
if (the_insn.fi[0].exp.X_add_symbol == NULL
|
|
|
|
|
&& the_insn.fi[0].exp.X_op_symbol == NULL
|
|
|
|
|
&& (the_insn.fi[0].exp.X_add_number < (1 << 15)
|
|
|
|
|
&& the_insn.fi[0].exp.X_add_number >= -(1 << 15)))
|
1999-05-03 15:29:11 +08:00
|
|
|
|
break;
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
|
|
|
|
/* Emit "orh h%const,r0,r31". */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
pseudo[0].opcode = 0xec000000 | (atmp << 16);
|
2003-05-12 11:35:34 +08:00
|
|
|
|
pseudo[0].fi[0].fup = (OP_IMM_S16 | OP_SEL_H);
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
|
|
|
|
/* Emit "or l%const,r31,r31". */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
pseudo[1].opcode = 0xe4000000 | (atmp << 21) | (atmp << 16);
|
2003-05-12 11:35:34 +08:00
|
|
|
|
pseudo[1].fi[0].fup = (OP_IMM_S16 | OP_SEL_L);
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
|
|
|
|
/* Emit "r31,ireg_src2,ireg_dest". */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
pseudo[2].opcode = (the_insn.opcode & ~0x0400ffff) | (atmp << 11);
|
2003-05-12 11:35:34 +08:00
|
|
|
|
pseudo[2].fi[0].fup = OP_IMM_S16;
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
|
|
|
|
num_opcodes = 3;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
as_fatal (_("failed sanity check."));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
the_insn = pseudo[0];
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
|
|
|
|
/* Warn if an opcode is expanded after a delayed branch. */
|
|
|
|
|
if (num_opcodes > 1 && last_expand == 1)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
as_warn (_("Expanded opcode after delayed branch: `%s'"), str);
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
|
|
|
|
/* Warn if an opcode is expanded in dual mode. */
|
|
|
|
|
if (num_opcodes > 1 && dual_mode != DUAL_OFF)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
as_warn (_("Expanded opcode in dual mode: `%s'"), str);
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
|
|
|
|
/* Notify if any expansions happen. */
|
|
|
|
|
if (target_warn_expand && num_opcodes > 1)
|
|
|
|
|
as_warn (_("An instruction was expanded (%s)"), str);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2009-09-08 18:36:39 +08:00
|
|
|
|
dwarf2_emit_insn (0);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
i = 0;
|
|
|
|
|
do
|
2000-08-09 11:33:42 +08:00
|
|
|
|
{
|
2003-05-12 11:35:34 +08:00
|
|
|
|
int tmp;
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Output the opcode. Note that the i860 always reads instructions
|
|
|
|
|
as little-endian data. */
|
|
|
|
|
destp = frag_more (4);
|
|
|
|
|
number_to_chars_littleendian (destp, the_insn.opcode, 4);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Check for expanded opcode after branch or in dual mode. */
|
2003-05-12 11:35:34 +08:00
|
|
|
|
last_expand = the_insn.fi[0].pcrel;
|
|
|
|
|
|
|
|
|
|
/* Output the symbol-dependent stuff. Only btne and bte will ever
|
|
|
|
|
loop more than once here, since only they (possibly) have more
|
|
|
|
|
than one fixup. */
|
|
|
|
|
for (tmp = 0; tmp < fc; tmp++)
|
|
|
|
|
{
|
|
|
|
|
if (the_insn.fi[tmp].fup != OP_NONE)
|
|
|
|
|
{
|
|
|
|
|
fixS *fix;
|
|
|
|
|
fix = fix_new_exp (frag_now,
|
|
|
|
|
destp - frag_now->fr_literal,
|
|
|
|
|
4,
|
|
|
|
|
&the_insn.fi[tmp].exp,
|
|
|
|
|
the_insn.fi[tmp].pcrel,
|
|
|
|
|
the_insn.fi[tmp].reloc);
|
|
|
|
|
|
|
|
|
|
/* Despite the odd name, this is a scratch field. We use
|
|
|
|
|
it to encode operand type information. */
|
|
|
|
|
fix->fx_addnumber = the_insn.fi[tmp].fup;
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
the_insn = pseudo[++i];
|
|
|
|
|
}
|
2000-08-09 11:33:42 +08:00
|
|
|
|
while (--num_opcodes > 0);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Assemble the instruction pointed to by STR. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
static void
|
2003-07-31 04:24:55 +08:00
|
|
|
|
i860_process_insn (char *str)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
char *s;
|
|
|
|
|
const char *args;
|
|
|
|
|
char c;
|
|
|
|
|
struct i860_opcode *insn;
|
2000-08-09 11:33:42 +08:00
|
|
|
|
char *args_start;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
unsigned long opcode;
|
|
|
|
|
unsigned int mask;
|
|
|
|
|
int match = 0;
|
|
|
|
|
int comma = 0;
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
#if 1 /* For compiler warnings. */
|
|
|
|
|
args = 0;
|
|
|
|
|
insn = 0;
|
|
|
|
|
args_start = 0;
|
|
|
|
|
opcode = 0;
|
|
|
|
|
#endif
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2001-09-19 13:33:36 +08:00
|
|
|
|
for (s = str; ISLOWER (*s) || *s == '.' || *s == '3'
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|| *s == '2' || *s == '1'; ++s)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
;
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
switch (*s)
|
|
|
|
|
{
|
|
|
|
|
case '\0':
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ',':
|
|
|
|
|
comma = 1;
|
|
|
|
|
|
|
|
|
|
/*FALLTHROUGH*/
|
|
|
|
|
|
|
|
|
|
case ' ':
|
|
|
|
|
*s++ = '\0';
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
as_fatal (_("Unknown opcode: `%s'"), str);
|
|
|
|
|
}
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Check for dual mode ("d.") opcode prefix. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (strncmp (str, "d.", 2) == 0)
|
2000-08-09 11:33:42 +08:00
|
|
|
|
{
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (dual_mode == DUAL_ON)
|
|
|
|
|
dual_mode = DUAL_ONDDOT;
|
|
|
|
|
else
|
|
|
|
|
dual_mode = DUAL_DDOT;
|
|
|
|
|
str += 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((insn = (struct i860_opcode *) hash_find (op_hash, str)) == NULL)
|
|
|
|
|
{
|
|
|
|
|
if (dual_mode == DUAL_DDOT || dual_mode == DUAL_ONDDOT)
|
|
|
|
|
str -= 2;
|
|
|
|
|
as_bad (_("Unknown opcode: `%s'"), str);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (comma)
|
2000-08-09 11:33:42 +08:00
|
|
|
|
*--s = ',';
|
|
|
|
|
|
|
|
|
|
args_start = s;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
for (;;)
|
|
|
|
|
{
|
2003-05-12 11:35:34 +08:00
|
|
|
|
int t;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
opcode = insn->match;
|
|
|
|
|
memset (&the_insn, '\0', sizeof (the_insn));
|
2003-05-19 05:24:33 +08:00
|
|
|
|
fc = 0;
|
2003-05-12 11:35:34 +08:00
|
|
|
|
for (t = 0; t < MAX_FIXUPS; t++)
|
|
|
|
|
{
|
|
|
|
|
the_insn.fi[t].reloc = BFD_RELOC_NONE;
|
|
|
|
|
the_insn.fi[t].pcrel = 0;
|
|
|
|
|
the_insn.fi[t].fup = OP_NONE;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Build the opcode, checking as we go that the operands match. */
|
|
|
|
|
for (args = insn->args; ; ++args)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2003-05-12 11:35:34 +08:00
|
|
|
|
if (fc > MAX_FIXUPS)
|
|
|
|
|
abort ();
|
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
switch (*args)
|
|
|
|
|
{
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* End of args. */
|
|
|
|
|
case '\0':
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (*s == '\0')
|
2000-08-09 11:33:42 +08:00
|
|
|
|
match = 1;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
break;
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* These must match exactly. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
case '+':
|
2000-08-09 11:33:42 +08:00
|
|
|
|
case '(':
|
1999-05-03 15:29:11 +08:00
|
|
|
|
case ')':
|
|
|
|
|
case ',':
|
|
|
|
|
case ' ':
|
|
|
|
|
if (*s++ == *args)
|
|
|
|
|
continue;
|
|
|
|
|
break;
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Must be at least one digit. */
|
|
|
|
|
case '#':
|
2001-09-19 13:33:36 +08:00
|
|
|
|
if (ISDIGIT (*s++))
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2001-09-19 13:33:36 +08:00
|
|
|
|
while (ISDIGIT (*s))
|
2000-08-09 11:33:42 +08:00
|
|
|
|
++s;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Next operand must be a register. */
|
|
|
|
|
case '1':
|
1999-05-03 15:29:11 +08:00
|
|
|
|
case '2':
|
|
|
|
|
case 'd':
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Check for register prefix if necessary. */
|
|
|
|
|
if (reg_prefix && *s != reg_prefix)
|
|
|
|
|
goto error;
|
2003-08-02 11:03:52 +08:00
|
|
|
|
else if (reg_prefix)
|
2000-08-09 11:33:42 +08:00
|
|
|
|
s++;
|
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
switch (*s)
|
|
|
|
|
{
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Frame pointer. */
|
|
|
|
|
case 'f':
|
1999-05-03 15:29:11 +08:00
|
|
|
|
s++;
|
|
|
|
|
if (*s++ == 'p')
|
|
|
|
|
{
|
|
|
|
|
mask = 0x3;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
goto error;
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Stack pointer. */
|
|
|
|
|
case 's':
|
1999-05-03 15:29:11 +08:00
|
|
|
|
s++;
|
|
|
|
|
if (*s++ == 'p')
|
|
|
|
|
{
|
|
|
|
|
mask = 0x2;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
goto error;
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Any register r0..r31. */
|
|
|
|
|
case 'r':
|
1999-05-03 15:29:11 +08:00
|
|
|
|
s++;
|
2001-09-19 13:33:36 +08:00
|
|
|
|
if (!ISDIGIT (c = *s++))
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
2001-09-19 13:33:36 +08:00
|
|
|
|
if (ISDIGIT (*s))
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
if ((c = 10 * (c - '0') + (*s++ - '0')) >= 32)
|
2000-08-09 11:33:42 +08:00
|
|
|
|
goto error;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
2000-08-09 11:33:42 +08:00
|
|
|
|
c -= '0';
|
1999-05-03 15:29:11 +08:00
|
|
|
|
mask = c;
|
|
|
|
|
break;
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Not this opcode. */
|
|
|
|
|
default:
|
1999-05-03 15:29:11 +08:00
|
|
|
|
goto error;
|
|
|
|
|
}
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
|
|
|
|
/* Obtained the register, now place it in the opcode. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
switch (*args)
|
|
|
|
|
{
|
|
|
|
|
case '1':
|
|
|
|
|
opcode |= mask << 11;
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
case '2':
|
|
|
|
|
opcode |= mask << 21;
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
case 'd':
|
|
|
|
|
opcode |= mask << 16;
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Next operand is a floating point register. */
|
|
|
|
|
case 'e':
|
1999-05-03 15:29:11 +08:00
|
|
|
|
case 'f':
|
|
|
|
|
case 'g':
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Check for register prefix if necessary. */
|
|
|
|
|
if (reg_prefix && *s != reg_prefix)
|
|
|
|
|
goto error;
|
2003-08-02 11:03:52 +08:00
|
|
|
|
else if (reg_prefix)
|
2000-08-09 11:33:42 +08:00
|
|
|
|
s++;
|
|
|
|
|
|
2001-09-19 13:33:36 +08:00
|
|
|
|
if (*s++ == 'f' && ISDIGIT (*s))
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
mask = *s++;
|
2001-09-19 13:33:36 +08:00
|
|
|
|
if (ISDIGIT (*s))
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
mask = 10 * (mask - '0') + (*s++ - '0');
|
|
|
|
|
if (mask >= 32)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2000-08-09 11:33:42 +08:00
|
|
|
|
mask -= '0';
|
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
switch (*args)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
case 'e':
|
|
|
|
|
opcode |= mask << 11;
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
case 'f':
|
|
|
|
|
opcode |= mask << 21;
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
case 'g':
|
|
|
|
|
opcode |= mask << 16;
|
2000-08-09 11:33:42 +08:00
|
|
|
|
if ((opcode & (1 << 10)) && mask != 0
|
|
|
|
|
&& (mask == ((opcode >> 11) & 0x1f)))
|
|
|
|
|
as_warn (_("Pipelined instruction: fsrc1 = fdest"));
|
1999-05-03 15:29:11 +08:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Next operand must be a control register. */
|
|
|
|
|
case 'c':
|
|
|
|
|
/* Check for register prefix if necessary. */
|
|
|
|
|
if (reg_prefix && *s != reg_prefix)
|
|
|
|
|
goto error;
|
2003-08-02 11:03:52 +08:00
|
|
|
|
else if (reg_prefix)
|
2000-08-09 11:33:42 +08:00
|
|
|
|
s++;
|
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (strncmp (s, "fir", 3) == 0)
|
|
|
|
|
{
|
|
|
|
|
opcode |= 0x0 << 21;
|
|
|
|
|
s += 3;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (strncmp (s, "psr", 3) == 0)
|
|
|
|
|
{
|
|
|
|
|
opcode |= 0x1 << 21;
|
|
|
|
|
s += 3;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (strncmp (s, "dirbase", 7) == 0)
|
|
|
|
|
{
|
|
|
|
|
opcode |= 0x2 << 21;
|
|
|
|
|
s += 7;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (strncmp (s, "db", 2) == 0)
|
|
|
|
|
{
|
|
|
|
|
opcode |= 0x3 << 21;
|
|
|
|
|
s += 2;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (strncmp (s, "fsr", 3) == 0)
|
|
|
|
|
{
|
|
|
|
|
opcode |= 0x4 << 21;
|
|
|
|
|
s += 3;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (strncmp (s, "epsr", 4) == 0)
|
|
|
|
|
{
|
|
|
|
|
opcode |= 0x5 << 21;
|
|
|
|
|
s += 4;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2003-05-24 12:22:23 +08:00
|
|
|
|
/* The remaining control registers are XP only. */
|
|
|
|
|
if (target_xp && strncmp (s, "bear", 4) == 0)
|
|
|
|
|
{
|
|
|
|
|
opcode |= 0x6 << 21;
|
|
|
|
|
s += 4;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (target_xp && strncmp (s, "ccr", 3) == 0)
|
|
|
|
|
{
|
|
|
|
|
opcode |= 0x7 << 21;
|
|
|
|
|
s += 3;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (target_xp && strncmp (s, "p0", 2) == 0)
|
|
|
|
|
{
|
|
|
|
|
opcode |= 0x8 << 21;
|
|
|
|
|
s += 2;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (target_xp && strncmp (s, "p1", 2) == 0)
|
|
|
|
|
{
|
|
|
|
|
opcode |= 0x9 << 21;
|
|
|
|
|
s += 2;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (target_xp && strncmp (s, "p2", 2) == 0)
|
|
|
|
|
{
|
|
|
|
|
opcode |= 0xa << 21;
|
|
|
|
|
s += 2;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (target_xp && strncmp (s, "p3", 2) == 0)
|
|
|
|
|
{
|
|
|
|
|
opcode |= 0xb << 21;
|
|
|
|
|
s += 2;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
break;
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* 5-bit immediate in src1. */
|
|
|
|
|
case '5':
|
|
|
|
|
if (! i860_get_expression (s))
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
s = expr_end;
|
2003-05-12 11:35:34 +08:00
|
|
|
|
the_insn.fi[fc].fup |= OP_IMM_U5;
|
|
|
|
|
fc++;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* 26-bit immediate, relative branch (lbroff). */
|
|
|
|
|
case 'l':
|
2003-05-12 11:35:34 +08:00
|
|
|
|
the_insn.fi[fc].pcrel = 1;
|
|
|
|
|
the_insn.fi[fc].fup |= OP_IMM_BR26;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
goto immediate;
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* 16-bit split immediate, relative branch (sbroff). */
|
|
|
|
|
case 'r':
|
2003-05-12 11:35:34 +08:00
|
|
|
|
the_insn.fi[fc].pcrel = 1;
|
|
|
|
|
the_insn.fi[fc].fup |= OP_IMM_BR16;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
goto immediate;
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* 16-bit split immediate. */
|
|
|
|
|
case 's':
|
2003-05-12 11:35:34 +08:00
|
|
|
|
the_insn.fi[fc].fup |= OP_IMM_SPLIT16;
|
2000-08-09 11:33:42 +08:00
|
|
|
|
goto immediate;
|
|
|
|
|
|
|
|
|
|
/* 16-bit split immediate, byte aligned (st.b). */
|
|
|
|
|
case 'S':
|
2003-05-12 11:35:34 +08:00
|
|
|
|
the_insn.fi[fc].fup |= OP_IMM_SPLIT16;
|
2000-08-09 11:33:42 +08:00
|
|
|
|
goto immediate;
|
|
|
|
|
|
|
|
|
|
/* 16-bit split immediate, half-word aligned (st.s). */
|
|
|
|
|
case 'T':
|
2003-05-12 11:35:34 +08:00
|
|
|
|
the_insn.fi[fc].fup |= (OP_IMM_SPLIT16 | OP_ENCODE1 | OP_ALIGN2);
|
2000-08-09 11:33:42 +08:00
|
|
|
|
goto immediate;
|
|
|
|
|
|
|
|
|
|
/* 16-bit split immediate, word aligned (st.l). */
|
|
|
|
|
case 'U':
|
2003-05-12 11:35:34 +08:00
|
|
|
|
the_insn.fi[fc].fup |= (OP_IMM_SPLIT16 | OP_ENCODE1 | OP_ALIGN4);
|
2000-08-09 11:33:42 +08:00
|
|
|
|
goto immediate;
|
|
|
|
|
|
|
|
|
|
/* 16-bit immediate. */
|
|
|
|
|
case 'i':
|
2003-05-12 11:35:34 +08:00
|
|
|
|
the_insn.fi[fc].fup |= OP_IMM_S16;
|
2000-08-09 11:33:42 +08:00
|
|
|
|
goto immediate;
|
|
|
|
|
|
|
|
|
|
/* 16-bit immediate, byte aligned (ld.b). */
|
|
|
|
|
case 'I':
|
2003-05-12 11:35:34 +08:00
|
|
|
|
the_insn.fi[fc].fup |= OP_IMM_S16;
|
2000-08-09 11:33:42 +08:00
|
|
|
|
goto immediate;
|
|
|
|
|
|
|
|
|
|
/* 16-bit immediate, half-word aligned (ld.s). */
|
|
|
|
|
case 'J':
|
2003-05-12 11:35:34 +08:00
|
|
|
|
the_insn.fi[fc].fup |= (OP_IMM_S16 | OP_ENCODE1 | OP_ALIGN2);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
goto immediate;
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* 16-bit immediate, word aligned (ld.l, {p}fld.l, fst.l). */
|
|
|
|
|
case 'K':
|
|
|
|
|
if (insn->name[0] == 'l')
|
2003-05-12 11:35:34 +08:00
|
|
|
|
the_insn.fi[fc].fup |= (OP_IMM_S16 | OP_ENCODE1 | OP_ALIGN4);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
else
|
2003-05-12 11:35:34 +08:00
|
|
|
|
the_insn.fi[fc].fup |= (OP_IMM_S16 | OP_ENCODE2 | OP_ALIGN4);
|
2000-08-09 11:33:42 +08:00
|
|
|
|
goto immediate;
|
|
|
|
|
|
|
|
|
|
/* 16-bit immediate, double-word aligned ({p}fld.d, fst.d). */
|
|
|
|
|
case 'L':
|
2003-05-12 11:35:34 +08:00
|
|
|
|
the_insn.fi[fc].fup |= (OP_IMM_S16 | OP_ENCODE3 | OP_ALIGN8);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
goto immediate;
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* 16-bit immediate, quad-word aligned (fld.q, fst.q). */
|
|
|
|
|
case 'M':
|
2003-05-12 11:35:34 +08:00
|
|
|
|
the_insn.fi[fc].fup |= (OP_IMM_S16 | OP_ENCODE3 | OP_ALIGN16);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
/*FALLTHROUGH*/
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Handle the immediate for either the Intel syntax or
|
|
|
|
|
SVR4 syntax. The Intel syntax is "ha%immediate"
|
|
|
|
|
whereas SVR4 syntax is "[immediate]@ha". */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
immediate:
|
2003-08-02 11:03:52 +08:00
|
|
|
|
if (target_intel_syntax == 0)
|
2000-08-09 11:33:42 +08:00
|
|
|
|
{
|
2003-08-02 11:03:52 +08:00
|
|
|
|
/* AT&T/SVR4 syntax. */
|
|
|
|
|
if (*s == ' ')
|
|
|
|
|
s++;
|
|
|
|
|
|
|
|
|
|
/* Note that if i860_get_expression() fails, we will still
|
|
|
|
|
have created U entries in the symbol table for the
|
|
|
|
|
'symbols' in the input string. Try not to create U
|
|
|
|
|
symbols for registers, etc. */
|
|
|
|
|
if (! i860_get_expression (s))
|
|
|
|
|
s = expr_end;
|
|
|
|
|
else
|
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
|
|
if (strncmp (s, "@ha", 3) == 0)
|
|
|
|
|
{
|
|
|
|
|
the_insn.fi[fc].fup |= OP_SEL_HA;
|
|
|
|
|
s += 3;
|
|
|
|
|
}
|
|
|
|
|
else if (strncmp (s, "@h", 2) == 0)
|
|
|
|
|
{
|
|
|
|
|
the_insn.fi[fc].fup |= OP_SEL_H;
|
|
|
|
|
s += 2;
|
|
|
|
|
}
|
|
|
|
|
else if (strncmp (s, "@l", 2) == 0)
|
|
|
|
|
{
|
|
|
|
|
the_insn.fi[fc].fup |= OP_SEL_L;
|
|
|
|
|
s += 2;
|
|
|
|
|
}
|
|
|
|
|
else if (strncmp (s, "@gotoff", 7) == 0
|
|
|
|
|
|| strncmp (s, "@GOTOFF", 7) == 0)
|
|
|
|
|
{
|
|
|
|
|
as_bad (_("Assembler does not yet support PIC"));
|
|
|
|
|
the_insn.fi[fc].fup |= OP_SEL_GOTOFF;
|
|
|
|
|
s += 7;
|
|
|
|
|
}
|
|
|
|
|
else if (strncmp (s, "@got", 4) == 0
|
|
|
|
|
|| strncmp (s, "@GOT", 4) == 0)
|
|
|
|
|
{
|
|
|
|
|
as_bad (_("Assembler does not yet support PIC"));
|
|
|
|
|
the_insn.fi[fc].fup |= OP_SEL_GOT;
|
|
|
|
|
s += 4;
|
|
|
|
|
}
|
|
|
|
|
else if (strncmp (s, "@plt", 4) == 0
|
|
|
|
|
|| strncmp (s, "@PLT", 4) == 0)
|
|
|
|
|
{
|
|
|
|
|
as_bad (_("Assembler does not yet support PIC"));
|
|
|
|
|
the_insn.fi[fc].fup |= OP_SEL_PLT;
|
|
|
|
|
s += 4;
|
|
|
|
|
}
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
2003-08-02 11:03:52 +08:00
|
|
|
|
the_insn.expand = insn->expand;
|
|
|
|
|
fc++;
|
2003-05-12 11:35:34 +08:00
|
|
|
|
|
2003-08-02 11:03:52 +08:00
|
|
|
|
continue;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
2003-08-02 11:03:52 +08:00
|
|
|
|
else
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2003-08-02 11:03:52 +08:00
|
|
|
|
/* Intel syntax. */
|
|
|
|
|
if (*s == ' ')
|
|
|
|
|
s++;
|
|
|
|
|
if (strncmp (s, "ha%", 3) == 0)
|
|
|
|
|
{
|
|
|
|
|
the_insn.fi[fc].fup |= OP_SEL_HA;
|
|
|
|
|
s += 3;
|
|
|
|
|
}
|
|
|
|
|
else if (strncmp (s, "h%", 2) == 0)
|
|
|
|
|
{
|
|
|
|
|
the_insn.fi[fc].fup |= OP_SEL_H;
|
|
|
|
|
s += 2;
|
|
|
|
|
}
|
|
|
|
|
else if (strncmp (s, "l%", 2) == 0)
|
|
|
|
|
{
|
|
|
|
|
the_insn.fi[fc].fup |= OP_SEL_L;
|
|
|
|
|
s += 2;
|
|
|
|
|
}
|
|
|
|
|
the_insn.expand = insn->expand;
|
|
|
|
|
|
|
|
|
|
/* Note that if i860_get_expression() fails, we will still
|
|
|
|
|
have created U entries in the symbol table for the
|
|
|
|
|
'symbols' in the input string. Try not to create U
|
|
|
|
|
symbols for registers, etc. */
|
|
|
|
|
if (! i860_get_expression (s))
|
|
|
|
|
s = expr_end;
|
|
|
|
|
else
|
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
|
|
fc++;
|
|
|
|
|
continue;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
as_fatal (_("failed sanity check."));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
error:
|
|
|
|
|
if (match == 0)
|
|
|
|
|
{
|
|
|
|
|
/* Args don't match. */
|
2000-08-09 11:33:42 +08:00
|
|
|
|
if (insn[1].name != NULL
|
|
|
|
|
&& ! strcmp (insn->name, insn[1].name))
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
++insn;
|
2000-08-09 11:33:42 +08:00
|
|
|
|
s = args_start;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2000-08-09 11:33:42 +08:00
|
|
|
|
as_bad (_("Illegal operands for %s"), insn->name);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-06 12:31:58 +08:00
|
|
|
|
/* Set the dual bit on this instruction if necessary. */
|
|
|
|
|
if (dual_mode != DUAL_OFF)
|
|
|
|
|
{
|
|
|
|
|
if ((opcode & 0xfc000000) == 0x48000000 || opcode == 0xb0000000)
|
|
|
|
|
{
|
2003-08-07 03:53:19 +08:00
|
|
|
|
/* The instruction is a flop or a fnop, so set its dual bit
|
|
|
|
|
(but check that it is 8-byte aligned). */
|
|
|
|
|
if (((frag_now->fr_address + frag_now_fix_octets ()) & 7) == 0)
|
|
|
|
|
opcode |= (1 << 9);
|
|
|
|
|
else
|
|
|
|
|
as_bad (_("'d.%s' must be 8-byte aligned"), insn->name);
|
|
|
|
|
|
2003-08-06 12:31:58 +08:00
|
|
|
|
if (dual_mode == DUAL_DDOT)
|
|
|
|
|
dual_mode = DUAL_OFF;
|
|
|
|
|
else if (dual_mode == DUAL_ONDDOT)
|
|
|
|
|
dual_mode = DUAL_ON;
|
|
|
|
|
}
|
|
|
|
|
else if (dual_mode == DUAL_DDOT || dual_mode == DUAL_ONDDOT)
|
|
|
|
|
as_bad (_("Prefix 'd.' invalid for instruction `%s'"), insn->name);
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
the_insn.opcode = opcode;
|
2003-05-24 12:22:23 +08:00
|
|
|
|
|
|
|
|
|
/* Only recognize XP instructions when the user has requested it. */
|
|
|
|
|
if (insn->expand == XP_ONLY && ! target_xp)
|
|
|
|
|
as_bad (_("Unknown opcode: `%s'"), insn->name);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
2003-07-31 04:24:55 +08:00
|
|
|
|
i860_get_expression (char *str)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
char *save_in;
|
|
|
|
|
segT seg;
|
|
|
|
|
|
|
|
|
|
save_in = input_line_pointer;
|
|
|
|
|
input_line_pointer = str;
|
2003-05-12 11:35:34 +08:00
|
|
|
|
seg = expression (&the_insn.fi[fc].exp);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (seg != absolute_section
|
|
|
|
|
&& seg != undefined_section
|
|
|
|
|
&& ! SEG_NORMAL (seg))
|
|
|
|
|
{
|
|
|
|
|
the_insn.error = _("bad segment");
|
|
|
|
|
expr_end = input_line_pointer;
|
|
|
|
|
input_line_pointer = save_in;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
expr_end = input_line_pointer;
|
|
|
|
|
input_line_pointer = save_in;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *
|
2003-07-31 04:24:55 +08:00
|
|
|
|
md_atof (int type, char *litP, int *sizeP)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2007-10-18 00:45:56 +08:00
|
|
|
|
return ieee_md_atof (type, litP, sizeP, TRUE);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Write out in current endian mode. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
void
|
2003-07-31 04:24:55 +08:00
|
|
|
|
md_number_to_chars (char *buf, valueT val, int n)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2000-08-09 11:33:42 +08:00
|
|
|
|
if (target_big_endian)
|
|
|
|
|
number_to_chars_bigendian (buf, val, n);
|
|
|
|
|
else
|
|
|
|
|
number_to_chars_littleendian (buf, val, n);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* This should never be called for i860. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
int
|
2003-07-31 04:24:55 +08:00
|
|
|
|
md_estimate_size_before_relax (register fragS *fragP ATTRIBUTE_UNUSED,
|
|
|
|
|
segT segtype ATTRIBUTE_UNUSED)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2007-10-18 21:03:12 +08:00
|
|
|
|
as_fatal (_("relaxation not supported\n"));
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
#ifdef DEBUG_I860
|
1999-05-03 15:29:11 +08:00
|
|
|
|
static void
|
2003-07-31 04:24:55 +08:00
|
|
|
|
print_insn (struct i860_it *insn)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
if (insn->error)
|
2000-08-09 11:33:42 +08:00
|
|
|
|
fprintf (stderr, "ERROR: %s\n", insn->error);
|
|
|
|
|
|
|
|
|
|
fprintf (stderr, "opcode = 0x%08lx\t", insn->opcode);
|
|
|
|
|
fprintf (stderr, "expand = 0x%x\t", insn->expand);
|
|
|
|
|
fprintf (stderr, "reloc = %s\t\n",
|
|
|
|
|
bfd_get_reloc_code_name (insn->reloc));
|
1999-05-03 15:29:11 +08:00
|
|
|
|
fprintf (stderr, "exp = {\n");
|
|
|
|
|
fprintf (stderr, "\t\tX_add_symbol = %s\n",
|
|
|
|
|
insn->exp.X_add_symbol ?
|
|
|
|
|
(S_GET_NAME (insn->exp.X_add_symbol) ?
|
|
|
|
|
S_GET_NAME (insn->exp.X_add_symbol) : "???") : "0");
|
|
|
|
|
fprintf (stderr, "\t\tX_op_symbol = %s\n",
|
|
|
|
|
insn->exp.X_op_symbol ?
|
|
|
|
|
(S_GET_NAME (insn->exp.X_op_symbol) ?
|
|
|
|
|
S_GET_NAME (insn->exp.X_op_symbol) : "???") : "0");
|
2000-08-09 11:33:42 +08:00
|
|
|
|
fprintf (stderr, "\t\tX_add_number = %lx\n",
|
1999-05-03 15:29:11 +08:00
|
|
|
|
insn->exp.X_add_number);
|
|
|
|
|
fprintf (stderr, "}\n");
|
|
|
|
|
}
|
2000-08-09 11:33:42 +08:00
|
|
|
|
#endif /* DEBUG_I860 */
|
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
#ifdef OBJ_ELF
|
2002-06-08 15:37:16 +08:00
|
|
|
|
const char *md_shortopts = "VQ:";
|
2000-08-09 11:33:42 +08:00
|
|
|
|
#else
|
2002-06-08 15:37:16 +08:00
|
|
|
|
const char *md_shortopts = "";
|
2000-08-09 11:33:42 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define OPTION_EB (OPTION_MD_BASE + 0)
|
|
|
|
|
#define OPTION_EL (OPTION_MD_BASE + 1)
|
|
|
|
|
#define OPTION_WARN_EXPAND (OPTION_MD_BASE + 2)
|
2003-05-24 12:22:23 +08:00
|
|
|
|
#define OPTION_XP (OPTION_MD_BASE + 3)
|
2003-08-02 11:03:52 +08:00
|
|
|
|
#define OPTION_INTEL_SYNTAX (OPTION_MD_BASE + 4)
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
struct option md_longopts[] = {
|
2000-08-09 11:33:42 +08:00
|
|
|
|
{ "EB", no_argument, NULL, OPTION_EB },
|
|
|
|
|
{ "EL", no_argument, NULL, OPTION_EL },
|
|
|
|
|
{ "mwarn-expand", no_argument, NULL, OPTION_WARN_EXPAND },
|
2003-05-24 12:22:23 +08:00
|
|
|
|
{ "mxp", no_argument, NULL, OPTION_XP },
|
2003-08-02 11:03:52 +08:00
|
|
|
|
{ "mintel-syntax",no_argument, NULL, OPTION_INTEL_SYNTAX },
|
2000-08-09 11:33:42 +08:00
|
|
|
|
{ NULL, no_argument, NULL, 0 }
|
1999-05-03 15:29:11 +08:00
|
|
|
|
};
|
2000-08-09 11:33:42 +08:00
|
|
|
|
size_t md_longopts_size = sizeof (md_longopts);
|
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
int
|
2003-07-31 04:24:55 +08:00
|
|
|
|
md_parse_option (int c, char *arg ATTRIBUTE_UNUSED)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2000-08-09 11:33:42 +08:00
|
|
|
|
switch (c)
|
|
|
|
|
{
|
|
|
|
|
case OPTION_EB:
|
|
|
|
|
target_big_endian = 1;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OPTION_EL:
|
|
|
|
|
target_big_endian = 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OPTION_WARN_EXPAND:
|
|
|
|
|
target_warn_expand = 1;
|
|
|
|
|
break;
|
|
|
|
|
|
2003-05-24 12:22:23 +08:00
|
|
|
|
case OPTION_XP:
|
|
|
|
|
target_xp = 1;
|
|
|
|
|
break;
|
|
|
|
|
|
2003-08-02 11:03:52 +08:00
|
|
|
|
case OPTION_INTEL_SYNTAX:
|
|
|
|
|
target_intel_syntax = 1;
|
|
|
|
|
break;
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
#ifdef OBJ_ELF
|
|
|
|
|
/* SVR4 argument compatibility (-V): print version ID. */
|
|
|
|
|
case 'V':
|
|
|
|
|
print_version_id ();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
/* SVR4 argument compatibility (-Qy, -Qn): controls whether
|
|
|
|
|
a .comment section should be emitted or not (ignored). */
|
|
|
|
|
case 'Q':
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2003-07-31 04:24:55 +08:00
|
|
|
|
md_show_usage (FILE *stream)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2000-08-09 11:33:42 +08:00
|
|
|
|
fprintf (stream, _("\
|
|
|
|
|
-EL generate code for little endian mode (default)\n\
|
|
|
|
|
-EB generate code for big endian mode\n\
|
2003-05-24 12:22:23 +08:00
|
|
|
|
-mwarn-expand warn if pseudo operations are expanded\n\
|
2003-08-02 11:03:52 +08:00
|
|
|
|
-mxp enable i860XP support (disabled by default)\n\
|
|
|
|
|
-mintel-syntax enable Intel syntax (default to AT&T/SVR4)\n"));
|
2000-08-09 11:33:42 +08:00
|
|
|
|
#ifdef OBJ_ELF
|
|
|
|
|
/* SVR4 compatibility flags. */
|
|
|
|
|
fprintf (stream, _("\
|
|
|
|
|
-V print assembler version number\n\
|
|
|
|
|
-Qy, -Qn ignored\n"));
|
|
|
|
|
#endif
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* We have no need to default values of symbols. */
|
|
|
|
|
symbolS *
|
2003-07-31 04:24:55 +08:00
|
|
|
|
md_undefined_symbol (char *name ATTRIBUTE_UNUSED)
|
2000-08-09 11:33:42 +08:00
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The i860 denotes auto-increment with '++'. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
void
|
2003-07-31 04:24:55 +08:00
|
|
|
|
md_operand (expressionS *exp)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2000-08-09 11:33:42 +08:00
|
|
|
|
char *s;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2000-08-17 05:34:45 +08:00
|
|
|
|
for (s = input_line_pointer; *s; s++)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2000-08-09 11:33:42 +08:00
|
|
|
|
if (s[0] == '+' && s[1] == '+')
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2000-08-09 11:33:42 +08:00
|
|
|
|
input_line_pointer += 2;
|
|
|
|
|
exp->X_op = O_register;
|
|
|
|
|
break;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
2000-08-09 11:33:42 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Round up a section size to the appropriate boundary. */
|
|
|
|
|
valueT
|
2003-07-31 04:24:55 +08:00
|
|
|
|
md_section_align (segT segment ATTRIBUTE_UNUSED,
|
|
|
|
|
valueT size ATTRIBUTE_UNUSED)
|
2000-08-09 11:33:42 +08:00
|
|
|
|
{
|
|
|
|
|
/* Byte alignment is fine. */
|
|
|
|
|
return size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* On the i860, a PC-relative offset is relative to the address of the
|
2003-11-01 05:33:59 +08:00
|
|
|
|
offset plus its size. */
|
2000-08-09 11:33:42 +08:00
|
|
|
|
long
|
2003-07-31 04:24:55 +08:00
|
|
|
|
md_pcrel_from (fixS *fixP)
|
2000-08-09 11:33:42 +08:00
|
|
|
|
{
|
|
|
|
|
return fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Determine the relocation needed for non PC-relative 16-bit immediates.
|
|
|
|
|
Also adjust the given immediate as necessary. Finally, check that
|
|
|
|
|
all constraints (such as alignment) are satisfied. */
|
|
|
|
|
static bfd_reloc_code_real_type
|
2003-07-31 04:24:55 +08:00
|
|
|
|
obtain_reloc_for_imm16 (fixS *fix, long *val)
|
2000-08-09 11:33:42 +08:00
|
|
|
|
{
|
|
|
|
|
valueT fup = fix->fx_addnumber;
|
2000-09-16 08:56:47 +08:00
|
|
|
|
bfd_reloc_code_real_type reloc;
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
|
|
|
|
if (fix->fx_pcrel)
|
|
|
|
|
abort ();
|
|
|
|
|
|
|
|
|
|
/* Check alignment restrictions. */
|
|
|
|
|
if ((fup & OP_ALIGN2) && (*val & 0x1))
|
|
|
|
|
as_bad_where (fix->fx_file, fix->fx_line,
|
|
|
|
|
_("This immediate requires 0 MOD 2 alignment"));
|
|
|
|
|
else if ((fup & OP_ALIGN4) && (*val & 0x3))
|
|
|
|
|
as_bad_where (fix->fx_file, fix->fx_line,
|
|
|
|
|
_("This immediate requires 0 MOD 4 alignment"));
|
|
|
|
|
else if ((fup & OP_ALIGN8) && (*val & 0x7))
|
|
|
|
|
as_bad_where (fix->fx_file, fix->fx_line,
|
|
|
|
|
_("This immediate requires 0 MOD 8 alignment"));
|
|
|
|
|
else if ((fup & OP_ALIGN16) && (*val & 0xf))
|
|
|
|
|
as_bad_where (fix->fx_file, fix->fx_line,
|
|
|
|
|
_("This immediate requires 0 MOD 16 alignment"));
|
|
|
|
|
|
|
|
|
|
if (fup & OP_SEL_HA)
|
|
|
|
|
{
|
|
|
|
|
*val = (*val >> 16) + (*val & 0x8000 ? 1 : 0);
|
|
|
|
|
reloc = BFD_RELOC_860_HIGHADJ;
|
|
|
|
|
}
|
|
|
|
|
else if (fup & OP_SEL_H)
|
|
|
|
|
{
|
|
|
|
|
*val >>= 16;
|
|
|
|
|
reloc = BFD_RELOC_860_HIGH;
|
|
|
|
|
}
|
|
|
|
|
else if (fup & OP_SEL_L)
|
|
|
|
|
{
|
|
|
|
|
int num_encode;
|
|
|
|
|
if (fup & OP_IMM_SPLIT16)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2000-08-09 11:33:42 +08:00
|
|
|
|
if (fup & OP_ENCODE1)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2000-08-09 11:33:42 +08:00
|
|
|
|
num_encode = 1;
|
|
|
|
|
reloc = BFD_RELOC_860_SPLIT1;
|
|
|
|
|
}
|
|
|
|
|
else if (fup & OP_ENCODE2)
|
|
|
|
|
{
|
|
|
|
|
num_encode = 2;
|
|
|
|
|
reloc = BFD_RELOC_860_SPLIT2;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2000-08-09 11:33:42 +08:00
|
|
|
|
num_encode = 0;
|
|
|
|
|
reloc = BFD_RELOC_860_SPLIT0;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
2000-08-09 11:33:42 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (fup & OP_ENCODE1)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2000-08-09 11:33:42 +08:00
|
|
|
|
num_encode = 1;
|
|
|
|
|
reloc = BFD_RELOC_860_LOW1;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
2000-08-09 11:33:42 +08:00
|
|
|
|
else if (fup & OP_ENCODE2)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2000-08-09 11:33:42 +08:00
|
|
|
|
num_encode = 2;
|
|
|
|
|
reloc = BFD_RELOC_860_LOW2;
|
|
|
|
|
}
|
|
|
|
|
else if (fup & OP_ENCODE3)
|
|
|
|
|
{
|
|
|
|
|
num_encode = 3;
|
|
|
|
|
reloc = BFD_RELOC_860_LOW3;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2000-08-09 11:33:42 +08:00
|
|
|
|
num_encode = 0;
|
|
|
|
|
reloc = BFD_RELOC_860_LOW0;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2000-08-09 11:33:42 +08:00
|
|
|
|
|
|
|
|
|
/* Preserve size encode bits. */
|
|
|
|
|
*val &= ~((1 << num_encode) - 1);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
2000-08-09 11:33:42 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* No selector. What reloc do we generate (???)? */
|
|
|
|
|
reloc = BFD_RELOC_32;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return reloc;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Attempt to simplify or eliminate a fixup. To indicate that a fixup
|
|
|
|
|
has been eliminated, set fix->fx_done. If fix->fx_addsy is non-NULL,
|
|
|
|
|
we will have to generate a reloc entry. */
|
2001-11-16 05:29:00 +08:00
|
|
|
|
|
|
|
|
|
void
|
gas:
* cgen.c, cgen.h, tc.h, write.c, config/obj-coff.c
* config/tc-a29k.c, config/tc-alpha.c, config/tc-alpha.h
* config/tc-arc.c, config/tc-arc.h, config/tc-arm.c
* config/tc-arm.h, config/tc-avr.c, config/tc-avr.h
* config/tc-cris.c, config/tc-crx.c, config/tc-d10v.c
* config/tc-d10v.h, config/tc-d30v.c, config/tc-d30v.h
* config/tc-dlx.c, config/tc-dlx.h, config/tc-fr30.h
* config/tc-frv.c, config/tc-frv.h, config/tc-h8300.c
* config/tc-h8500.c, config/tc-hppa.c, config/tc-hppa.h
* config/tc-i370.c, config/tc-i370.h, config/tc-i386.c
* config/tc-i386.h, config/tc-i860.c, config/tc-i860.h
* config/tc-i960.c, config/tc-i960.h, config/tc-ia64.c
* config/tc-ip2k.c, config/tc-ip2k.h, config/tc-iq2000.c
* config/tc-iq2000.h, config/tc-m32r.c, config/tc-m32r.h
* config/tc-m68hc11.c, config/tc-m68hc11.h, config/tc-m68k.c
* config/tc-m68k.h, config/tc-m88k.c, config/tc-maxq.c
* config/tc-mcore.c, config/tc-mcore.h, config/tc-mips.c
* config/tc-mips.h, config/tc-mmix.c, config/tc-mn10200.c
* config/tc-mn10300.c, config/tc-msp430.c, config/tc-ns32k.c
* config/tc-openrisc.h, config/tc-or32.c, config/tc-or32.h
* config/tc-pdp11.c, config/tc-pj.c, config/tc-pj.h
* config/tc-ppc.c, config/tc-ppc.h, config/tc-s390.c
* config/tc-s390.h, config/tc-sh64.c, config/tc-sh.c
* config/tc-sh.h, config/tc-sparc.c, config/tc-sparc.h
* config/tc-tahoe.c, config/tc-tic30.c, config/tc-tic4x.c
* config/tc-tic54x.c, config/tc-tic80.c, config/tc-v850.c
* config/tc-v850.h, config/tc-vax.c, config/tc-vax.h
* config/tc-w65.c, config/tc-xstormy16.c, config/tc-xstormy16.h
* config/tc-xtensa.c, config/tc-z8k.c:
Replace all instances of the string "_apply_fix3" with
"_apply_fix".
* po/POTFILES.in, po/gas.pot: Regenerate.
bfd:
* coff-i386.c: Change md_apply_fix3 to md_apply_fix in comment.
cgen:
* doc/porting.texi: Change all mention of md_apply_fix3 and
gas_cgen_md_apply_fix3 to md_apply_fix and gas_cgen_md_apply_fix
respectively.
2005-06-08 01:54:22 +08:00
|
|
|
|
md_apply_fix (fixS *fix, valueT *valP, segT seg ATTRIBUTE_UNUSED)
|
2000-08-09 11:33:42 +08:00
|
|
|
|
{
|
|
|
|
|
char *buf;
|
2002-09-05 08:01:18 +08:00
|
|
|
|
long val = *valP;
|
2000-08-09 11:33:42 +08:00
|
|
|
|
unsigned long insn;
|
|
|
|
|
valueT fup;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
buf = fix->fx_frag->fr_literal + fix->fx_where;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Recall that earlier we stored the opcode little-endian. */
|
|
|
|
|
insn = bfd_getl32 (buf);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* We stored a fix-up in this oddly-named scratch field. */
|
|
|
|
|
fup = fix->fx_addnumber;
|
|
|
|
|
|
|
|
|
|
/* Determine the necessary relocations as well as inserting an
|
|
|
|
|
immediate into the instruction. */
|
2003-05-12 11:35:34 +08:00
|
|
|
|
if (fup & OP_IMM_U5)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2000-08-09 11:33:42 +08:00
|
|
|
|
if (val & ~0x1f)
|
|
|
|
|
as_bad_where (fix->fx_file, fix->fx_line,
|
|
|
|
|
_("5-bit immediate too large"));
|
|
|
|
|
if (fix->fx_addsy)
|
|
|
|
|
as_bad_where (fix->fx_file, fix->fx_line,
|
|
|
|
|
_("5-bit field must be absolute"));
|
|
|
|
|
|
|
|
|
|
insn |= (val & 0x1f) << 11;
|
|
|
|
|
bfd_putl32 (insn, buf);
|
|
|
|
|
fix->fx_r_type = BFD_RELOC_NONE;
|
|
|
|
|
fix->fx_done = 1;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
2000-08-09 11:33:42 +08:00
|
|
|
|
else if (fup & OP_IMM_S16)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2000-08-09 11:33:42 +08:00
|
|
|
|
fix->fx_r_type = obtain_reloc_for_imm16 (fix, &val);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Insert the immediate. */
|
2000-08-22 07:26:19 +08:00
|
|
|
|
if (fix->fx_addsy)
|
|
|
|
|
fix->fx_done = 0;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
insn |= val & 0xffff;
|
|
|
|
|
bfd_putl32 (insn, buf);
|
|
|
|
|
fix->fx_r_type = BFD_RELOC_NONE;
|
|
|
|
|
fix->fx_done = 1;
|
|
|
|
|
}
|
2000-08-09 11:33:42 +08:00
|
|
|
|
}
|
|
|
|
|
else if (fup & OP_IMM_U16)
|
2001-11-16 05:29:00 +08:00
|
|
|
|
abort ();
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
else if (fup & OP_IMM_SPLIT16)
|
|
|
|
|
{
|
|
|
|
|
fix->fx_r_type = obtain_reloc_for_imm16 (fix, &val);
|
|
|
|
|
|
|
|
|
|
/* Insert the immediate. */
|
2000-08-22 07:26:19 +08:00
|
|
|
|
if (fix->fx_addsy)
|
|
|
|
|
fix->fx_done = 0;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
insn |= val & 0x7ff;
|
|
|
|
|
insn |= (val & 0xf800) << 5;
|
|
|
|
|
bfd_putl32 (insn, buf);
|
|
|
|
|
fix->fx_r_type = BFD_RELOC_NONE;
|
|
|
|
|
fix->fx_done = 1;
|
|
|
|
|
}
|
2000-09-16 08:56:47 +08:00
|
|
|
|
}
|
2000-08-09 11:33:42 +08:00
|
|
|
|
else if (fup & OP_IMM_BR16)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2000-08-09 11:33:42 +08:00
|
|
|
|
if (val & 0x3)
|
|
|
|
|
as_bad_where (fix->fx_file, fix->fx_line,
|
|
|
|
|
_("A branch offset requires 0 MOD 4 alignment"));
|
|
|
|
|
|
|
|
|
|
val = val >> 2;
|
|
|
|
|
|
|
|
|
|
/* Insert the immediate. */
|
2000-08-22 07:26:19 +08:00
|
|
|
|
if (fix->fx_addsy)
|
|
|
|
|
{
|
|
|
|
|
fix->fx_done = 0;
|
|
|
|
|
fix->fx_r_type = BFD_RELOC_860_PC16;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
insn |= (val & 0x7ff);
|
|
|
|
|
insn |= ((val & 0xf800) << 5);
|
|
|
|
|
bfd_putl32 (insn, buf);
|
|
|
|
|
fix->fx_r_type = BFD_RELOC_NONE;
|
|
|
|
|
fix->fx_done = 1;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
2000-08-09 11:33:42 +08:00
|
|
|
|
else if (fup & OP_IMM_BR26)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2000-08-09 11:33:42 +08:00
|
|
|
|
if (val & 0x3)
|
|
|
|
|
as_bad_where (fix->fx_file, fix->fx_line,
|
|
|
|
|
_("A branch offset requires 0 MOD 4 alignment"));
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
val >>= 2;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Insert the immediate. */
|
2000-08-22 07:26:19 +08:00
|
|
|
|
if (fix->fx_addsy)
|
|
|
|
|
{
|
|
|
|
|
fix->fx_r_type = BFD_RELOC_860_PC26;
|
|
|
|
|
fix->fx_done = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
insn |= (val & 0x3ffffff);
|
|
|
|
|
bfd_putl32 (insn, buf);
|
|
|
|
|
fix->fx_r_type = BFD_RELOC_NONE;
|
|
|
|
|
fix->fx_done = 1;
|
|
|
|
|
}
|
2000-08-09 11:33:42 +08:00
|
|
|
|
}
|
|
|
|
|
else if (fup != OP_NONE)
|
|
|
|
|
{
|
2000-09-16 08:56:47 +08:00
|
|
|
|
as_bad_where (fix->fx_file, fix->fx_line,
|
2002-12-13 06:27:07 +08:00
|
|
|
|
_("Unrecognized fix-up (0x%08lx)"), (unsigned long) fup);
|
2000-08-09 11:33:42 +08:00
|
|
|
|
abort ();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* I believe only fix-ups such as ".long .ep.main-main+0xc8000000"
|
|
|
|
|
reach here (???). */
|
2000-08-22 07:26:19 +08:00
|
|
|
|
if (fix->fx_addsy)
|
|
|
|
|
{
|
|
|
|
|
fix->fx_r_type = BFD_RELOC_32;
|
|
|
|
|
fix->fx_done = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
insn |= (val & 0xffffffff);
|
|
|
|
|
bfd_putl32 (insn, buf);
|
|
|
|
|
fix->fx_r_type = BFD_RELOC_NONE;
|
|
|
|
|
fix->fx_done = 1;
|
|
|
|
|
}
|
2000-08-09 11:33:42 +08:00
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
/* Generate a machine dependent reloc from a fixup. */
|
|
|
|
|
arelent*
|
2003-07-31 04:24:55 +08:00
|
|
|
|
tc_gen_reloc (asection *section ATTRIBUTE_UNUSED,
|
|
|
|
|
fixS *fixp)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2000-08-09 11:33:42 +08:00
|
|
|
|
arelent *reloc;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
reloc = xmalloc (sizeof (*reloc));
|
|
|
|
|
reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
|
|
|
|
|
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
|
|
|
|
|
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
|
|
|
|
|
reloc->addend = fixp->fx_offset;
|
|
|
|
|
reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2000-08-09 11:33:42 +08:00
|
|
|
|
if (! reloc->howto)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2000-08-09 11:33:42 +08:00
|
|
|
|
as_bad_where (fixp->fx_file, fixp->fx_line,
|
|
|
|
|
"Cannot represent %s relocation in object file",
|
|
|
|
|
bfd_get_reloc_code_name (fixp->fx_r_type));
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
2000-08-09 11:33:42 +08:00
|
|
|
|
return reloc;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
2003-08-07 07:59:36 +08:00
|
|
|
|
|
|
|
|
|
/* This is called from HANDLE_ALIGN in write.c. Fill in the contents
|
|
|
|
|
of an rs_align_code fragment. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
i860_handle_align (fragS *fragp)
|
|
|
|
|
{
|
|
|
|
|
/* Instructions are always stored little-endian on the i860. */
|
|
|
|
|
static const unsigned char le_nop[] = { 0x00, 0x00, 0x00, 0xA0 };
|
|
|
|
|
|
|
|
|
|
int bytes;
|
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
|
|
if (fragp->fr_type != rs_align_code)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
bytes = fragp->fr_next->fr_address - fragp->fr_address - fragp->fr_fix;
|
|
|
|
|
p = fragp->fr_literal + fragp->fr_fix;
|
|
|
|
|
|
|
|
|
|
/* Make sure we are on a 4-byte boundary, in case someone has been
|
|
|
|
|
putting data into a text section. */
|
|
|
|
|
if (bytes & 3)
|
|
|
|
|
{
|
|
|
|
|
int fix = bytes & 3;
|
|
|
|
|
memset (p, 0, fix);
|
|
|
|
|
p += fix;
|
|
|
|
|
fragp->fr_fix += fix;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
memcpy (p, le_nop, 4);
|
|
|
|
|
fragp->fr_var = 4;
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-08 03:20:45 +08:00
|
|
|
|
/* This is called after a user-defined label is seen. We check
|
|
|
|
|
if the label has a double colon (valid in Intel syntax mode only),
|
|
|
|
|
in which case it should be externalized. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
i860_check_label (symbolS *labelsym)
|
|
|
|
|
{
|
|
|
|
|
/* At this point, the current line pointer is sitting on the character
|
|
|
|
|
just after the first colon on the label. */
|
|
|
|
|
if (target_intel_syntax && *input_line_pointer == ':')
|
|
|
|
|
{
|
|
|
|
|
S_SET_EXTERNAL (labelsym);
|
|
|
|
|
input_line_pointer++;
|
|
|
|
|
}
|
|
|
|
|
}
|