/* tc-d10v.c -- Assembler code for the Mitsubishi D10V
- Copyright (C) 1996, 97, 98, 99, 2000 Free Software Foundation.
+ Copyright 1996, 1997, 1998, 1999, 2000, 2001
+ Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
Boston, MA 02111-1307, USA. */
#include <stdio.h>
-#include <ctype.h>
#include "as.h"
+#include "safe-ctype.h"
#include "subsegs.h"
#include "opcode/d10v.h"
#include "elf/ppc.h"
+//#include "read.h"
const char comment_chars[] = ";";
const char line_comment_chars[] = "#";
#define PACK_RIGHT_LEFT (3) /* "<-" */
static packing_type etype = PACK_UNSPEC; /* Used by d10v_cleanup. */
-/* True if instruction swapping warnings should be inhibited. */
-static unsigned char flag_warn_suppress_instructionswap; /* --nowarnswap */
+/* True if instruction swapping warnings should be inhibited.
+ --nowarnswap. */
+static boolean flag_warn_suppress_instructionswap;
+
+/* True if instruction packing should be performed when --gstabs is specified.
+ --gstabs-packing, --no-gstabs-packing. */
+static boolean flag_allow_gstabs_packing = 1;
/* Local functions. */
static int reg_name_search PARAMS ((char *name));
static int get_operands PARAMS ((expressionS exp[]));
static struct d10v_opcode *find_opcode PARAMS ((struct d10v_opcode *opcode, expressionS ops[]));
static unsigned long build_insn PARAMS ((struct d10v_opcode *opcode, expressionS *opers, unsigned long insn));
-static void write_long PARAMS ((struct d10v_opcode *opcode, unsigned long insn, Fixups *fx));
+static void write_long PARAMS ((unsigned long insn, Fixups *fx));
static void write_1_short PARAMS ((struct d10v_opcode *opcode, unsigned long insn, Fixups *fx));
static int write_2_short PARAMS ((struct d10v_opcode *opcode1, unsigned long insn1,
struct d10v_opcode *opcode2, unsigned long insn2, packing_type exec_type, Fixups *fx));
{
#define OPTION_NOWARNSWAP (OPTION_MD_BASE)
{"nowarnswap", no_argument, NULL, OPTION_NOWARNSWAP},
+#define OPTION_GSTABSPACKING (OPTION_MD_BASE + 1)
+ {"gstabspacking", no_argument, NULL, OPTION_GSTABSPACKING},
+ {"gstabs-packing", no_argument, NULL, OPTION_GSTABSPACKING},
+#define OPTION_NOGSTABSPACKING (OPTION_MD_BASE + 2)
+ {"nogstabspacking", no_argument, NULL, OPTION_NOGSTABSPACKING},
+ {"no-gstabs-packing", no_argument, NULL, OPTION_NOGSTABSPACKING},
{NULL, no_argument, NULL, 0}
};
-size_t md_longopts_size = sizeof(md_longopts);
+
+size_t md_longopts_size = sizeof (md_longopts);
static void d10v_dot_word PARAMS ((int));
int bits;
int flags;
{
- long min, max, bit1;
+ long min, max;
int retval = 0;
/* Don't bother checking 16-bit values. */
{
max = (1 << bits) - 1;
min = 0;
- if ((num > max) || (num < min))
+ if (((long) num > max) || ((long) num < min))
retval = 1;
}
return retval;
FILE *stream;
{
fprintf (stream, _("D10V options:\n\
--O optimize. Will do some operations in parallel.\n"));
+-O Optimize. Will do some operations in parallel.\n\
+--gstabs-packing Pack adjacent short instructions together even\n\
+ when --gstabs is specified. On by default.\n\
+--no-gstabs-packing If --gstabs is specified, do not pack adjacent\n\
+ instructions together.\n"));
}
int
md_parse_option (c, arg)
int c;
- char *arg;
+ char *arg ATTRIBUTE_UNUSED;
{
switch (c)
{
case OPTION_NOWARNSWAP:
flag_warn_suppress_instructionswap = 1;
break;
+ case OPTION_GSTABSPACKING:
+ flag_allow_gstabs_packing = 1;
+ break;
+ case OPTION_NOGSTABSPACKING:
+ flag_allow_gstabs_packing = 0;
+ break;
default:
return 0;
}
symbolS *
md_undefined_symbol (name)
- char *name;
+ char *name ATTRIBUTE_UNUSED;
{
return 0;
}
void
md_convert_frag (abfd, sec, fragP)
- bfd *abfd;
- asection *sec;
- fragS *fragP;
+ bfd *abfd ATTRIBUTE_UNUSED;
+ asection *sec ATTRIBUTE_UNUSED;
+ fragS *fragP ATTRIBUTE_UNUSED;
{
abort ();
}
/* Check for identifier@word+constant. */
if (*input_line_pointer == '-' || *input_line_pointer == '+')
{
- char *orig_line = input_line_pointer;
expressionS new_exp;
expression (&new_exp);
exp[numops].X_add_number = new_exp.X_add_number;
/* Truncate to the proper number of bits. */
if (check_range (value, bits, d10v_operands[op_type].flags))
- as_bad_where (fix->fx_file, fix->fx_line, _("operand out of range: %d"), value);
+ as_bad_where (fix->fx_file, fix->fx_line,
+ _("operand out of range: %d"), value);
value &= 0x7FFFFFFF >> (31 - bits);
insn |= (value << shift);
/* Write out a long form instruction. */
static void
-write_long (opcode, insn, fx)
- struct d10v_opcode *opcode;
+write_long (insn, fx)
unsigned long insn;
Fixups *fx;
{
/* Assemble first instruction and save it. */
prev_insn = do_assemble (str, &prev_opcode);
- if (prev_insn == -1)
+ prev_seg = now_seg;
+ prev_subseg = now_subseg;
+ if (prev_insn == (unsigned long) -1)
as_fatal (_("can't find opcode "));
fixups = fixups->next;
str = str2 + 2;
}
insn = do_assemble (str, &opcode);
- if (insn == -1)
+ if (insn == (unsigned long) -1)
{
if (extype != PACK_UNSPEC)
{
if (extype != PACK_UNSPEC)
as_fatal (_("Unable to mix instructions as specified"));
d10v_cleanup ();
- write_long (opcode, insn, fixups);
+ write_long (insn, fixups);
prev_opcode = NULL;
return;
}
&& !is_end_of_line[*op_end] && *op_end != ' ';
op_end++)
{
- name[nlen] = tolower (op_start[nlen]);
+ name[nlen] = TOLOWER (op_start[nlen]);
nlen++;
}
name[nlen] = 0;
struct d10v_opcode *opcode;
expressionS myops[];
{
- int i, match, done;
+ int i, match;
struct d10v_opcode *next_opcode;
/* Get all the operands and save them as expressions. */
arelent *
tc_gen_reloc (seg, fixp)
- asection *seg;
+ asection *seg ATTRIBUTE_UNUSED;
fixS *fixp;
{
arelent *reloc;
int
md_estimate_size_before_relax (fragp, seg)
- fragS *fragp;
- asection *seg;
+ fragS *fragp ATTRIBUTE_UNUSED;
+ asection *seg ATTRIBUTE_UNUSED;
{
abort ();
return 0;
md_apply_fix3 (fixp, valuep, seg)
fixS *fixp;
valueT *valuep;
- segT seg;
+ segT seg ATTRIBUTE_UNUSED;
{
char *where;
unsigned long insn;
rep = (struct d10v_opcode *) hash_find (d10v_hash, "rep");
repi = (struct d10v_opcode *) hash_find (d10v_hash, "repi");
if ((insn & FM11) == FM11
- && ((repi != NULL && (insn & repi->mask) == repi->opcode)
- || (rep != NULL && (insn & rep->mask) == rep->opcode))
+ && ( (repi != NULL && (insn & repi->mask) == (unsigned) repi->opcode)
+ || (rep != NULL && (insn & rep->mask) == (unsigned) rep->opcode))
&& value < 4)
as_fatal
(_("line %d: rep or repi must include at least 4 instructions"),
return 0;
}
-/* Called after the assembler has finished parsing the input file or
- after a label is defined. Because the D10V assembler sometimes
+/* d10v_cleanup() is called after the assembler has finished parsing
+ the input file, when a label is read from the input file, or when a
+ stab directive is output. Because the D10V assembler sometimes
saves short instructions to see if it can package them with the
next instruction, there may be a short instruction that still needs
to be written.
segT seg;
subsegT subseg;
- if (prev_opcode && etype == PACK_UNSPEC)
+ /* If cleanup was invoked because the assembler encountered, e.g., a
+ user label, we write out the pending instruction, if any. If it
+ was invoked because the assembler is outputting a piece of line
+ debugging information, though, we write out the pending
+ instruction only if the --no-gstabs-packing command line switch
+ has been specified. */
+ if (prev_opcode
+ && etype == PACK_UNSPEC
+ && (! outputting_stabs_line_debug || ! flag_allow_gstabs_packing))
{
seg = now_seg;
subseg = now_subseg;
+
if (prev_seg)
subseg_set (prev_seg, prev_subseg);
+
write_1_short (prev_opcode, prev_insn, fixups->next);
+
subseg_set (seg, subseg);
prev_opcode = NULL;
}
/* Clobbers input_line_pointer, checks end-of-line. */
static void
-d10v_dot_word (nbytes)
- register int nbytes; /* 1=.byte, 2=.word, 4=.long */
+d10v_dot_word (dummy)
+ int dummy ATTRIBUTE_UNUSED;
{
expressionS exp;
- bfd_reloc_code_real_type reloc;
char *p;
- int offset;
if (is_it_end_of_statement ())
{