/* tc-openrisc.c -- Assembler for the OpenRISC family.
- Copyright (C) 2001, 2002 Free Software Foundation.
+ Copyright 2001, 2002, 2003, 2005, 2006, 2007, 2009
+ Free Software Foundation.
Contributed by Johan Rydberg, jrydberg@opencores.org
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
- the Free Software Foundation; either version 2, or (at your option)
+ the Free Software Foundation; either version 3, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
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 Foundation, 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ the Free Software Foundation, 51 Franklin Street - Fifth Floor,
+ Boston, MA 02110-1301, USA. */
-#include <stdio.h>
#include "as.h"
#include "subsegs.h"
#include "symcat.h"
unsigned long openrisc_machine = 0; /* default */
int
-md_parse_option (c, arg)
- int c ATTRIBUTE_UNUSED;
- char * arg ATTRIBUTE_UNUSED;
+md_parse_option (int c ATTRIBUTE_UNUSED, char * arg ATTRIBUTE_UNUSED)
{
return 0;
}
void
-md_show_usage (stream)
- FILE * stream ATTRIBUTE_UNUSED;
+md_show_usage (FILE * stream ATTRIBUTE_UNUSED)
{
}
static void
-ignore_pseudo (val)
- int val ATTRIBUTE_UNUSED;
+ignore_pseudo (int val ATTRIBUTE_UNUSED)
{
discard_rest_of_line ();
}
\f
void
-md_begin ()
+md_begin (void)
{
/* Initialize the `cgen' interface. */
}
void
-md_assemble (str)
- char * str;
+md_assemble (char * str)
{
static int last_insn_had_delay_slot = 0;
openrisc_insn insn;
if (!insn.insn)
{
- as_bad (errmsg);
+ as_bad ("%s", errmsg);
return;
}
gas_cgen_finish_insn (insn.insn, insn.buffer,
CGEN_FIELDS_BITSIZE (& insn.fields), 1, NULL);
-#if 0 /* Currently disabled */
- /* Warn about invalid insns in delay slots. */
- if (last_insn_had_delay_slot
- && CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_NOT_IN_DELAY_SLOT))
- as_warn (_("Instruction %s not allowed in a delay slot."),
- CGEN_INSN_NAME (insn.insn));
-#endif
-
last_insn_had_delay_slot
= CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_DELAY_SLOT);
}
We just ignore it. */
void
-md_operand (expressionP)
- expressionS * expressionP;
+md_operand (expressionS * expressionP)
{
if (* input_line_pointer == '#')
{
}
valueT
-md_section_align (segment, size)
- segT segment;
- valueT size;
+md_section_align (segT segment, valueT size)
{
int align = bfd_get_section_alignment (stdoutput, segment);
return ((size + (1 << align) - 1) & (-1 << align));
}
symbolS *
-md_undefined_symbol (name)
- char * name ATTRIBUTE_UNUSED;
+md_undefined_symbol (char * name ATTRIBUTE_UNUSED)
{
return 0;
}
{0x2000000 - 1 - 2, -0x2000000 - 2, 4, 0 }
};
-long
-openrisc_relax_frag (segment, fragP, stretch)
- segT segment;
- fragS * fragP;
- long stretch;
-{
- /* Address of branch insn. */
- long address = fragP->fr_address + fragP->fr_fix - 2;
- long growth = 0;
-
- /* Keep 32 bit insns aligned on 32 bit boundaries. */
- if (fragP->fr_subtype == 2)
- {
- if ((address & 3) != 0)
- {
- fragP->fr_subtype = 3;
- growth = 2;
- }
- }
- else if (fragP->fr_subtype == 3)
- {
- if ((address & 3) == 0)
- {
- fragP->fr_subtype = 2;
- growth = -2;
- }
- }
- else
- {
- growth = relax_frag (segment, fragP, stretch);
-
- /* Long jump on odd halfword boundary? */
- if (fragP->fr_subtype == 2 && (address & 3) != 0)
- {
- fragP->fr_subtype = 3;
- growth += 2;
- }
- }
-
- return growth;
-}
-
-
/* Return an initial guess of the length by which a fragment must grow to
hold a branch to reach its destination.
Also updates fr_type/fr_subtype as necessary.
0 value. */
int
-md_estimate_size_before_relax (fragP, segment)
- fragS * fragP;
- segT segment;
+md_estimate_size_before_relax (fragS * fragP, segT segment)
{
/* The only thing we have to handle here are symbols outside of the
current segment. They may be undefined or in a different segment in
if ((strcmp (CGEN_INSN_MNEMONIC (insn),
CGEN_INSN_MNEMONIC (fragP->fr_cgen.insn))
== 0)
- && CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_RELAX))
+ && CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_RELAXED))
break;
}
if (i == 4)
fragP->fr_subtype is the subtype of what the address relaxed to. */
void
-md_convert_frag (abfd, sec, fragP)
- bfd * abfd ATTRIBUTE_UNUSED;
- segT sec ATTRIBUTE_UNUSED;
- fragS * fragP ATTRIBUTE_UNUSED;
+md_convert_frag (bfd * abfd ATTRIBUTE_UNUSED,
+ segT sec ATTRIBUTE_UNUSED,
+ fragS * fragP ATTRIBUTE_UNUSED)
{
/* FIXME */
}
given a PC relative reloc. */
long
-md_pcrel_from_section (fixP, sec)
- fixS * fixP;
- segT sec;
+md_pcrel_from_section (fixS * fixP, segT sec)
{
if (fixP->fx_addsy != (symbolS *) NULL
&& (! S_IS_DEFINED (fixP->fx_addsy)
|| S_GET_SEGMENT (fixP->fx_addsy) != sec))
- {
- /* The symbol is undefined (or is defined but not in this section).
- Let the linker figure it out. */
- return 0;
- }
+ /* The symbol is undefined (or is defined but not in this section).
+ Let the linker figure it out. */
+ return 0;
return (fixP->fx_frag->fr_address + fixP->fx_where) & ~1;
}
*FIXP may be modified if desired. */
bfd_reloc_code_real_type
-md_cgen_lookup_reloc (insn, operand, fixP)
- const CGEN_INSN * insn ATTRIBUTE_UNUSED;
- const CGEN_OPERAND * operand;
- fixS * fixP;
+md_cgen_lookup_reloc (const CGEN_INSN * insn ATTRIBUTE_UNUSED,
+ const CGEN_OPERAND * operand,
+ fixS * fixP)
{
bfd_reloc_code_real_type type;
return BFD_RELOC_NONE;
}
-
-/* See whether we need to force a relocation into the output file.
- This is used to force out switch and PC relative relocations when
- relaxing. */
-
-int
-openrisc_force_relocation (fix)
- fixS * fix ATTRIBUTE_UNUSED;
-{
- if (fix->fx_r_type == BFD_RELOC_VTABLE_INHERIT
- || fix->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
- return 1;
-
- return 0;
-}
-
-
\f
/* Write a value out to the object file, using the appropriate endianness. */
void
-md_number_to_chars (buf, val, n)
- char * buf;
- valueT val;
- int n;
+md_number_to_chars (char * buf, valueT val, int n)
{
number_to_chars_bigendian (buf, val, n);
}
#define MAX_LITTLENUMS 6
char *
-md_atof (type, litP, sizeP)
- char type;
- char * litP;
- int * sizeP;
+md_atof (int type, char * litP, int * sizeP)
{
- int i;
- int prec;
- LITTLENUM_TYPE words [MAX_LITTLENUMS];
- char * t;
- char * atof_ieee ();
-
- switch (type)
- {
- case 'f':
- case 'F':
- case 's':
- case 'S':
- prec = 2;
- break;
-
- case 'd':
- case 'D':
- case 'r':
- case 'R':
- prec = 4;
- break;
-
- /* FIXME: Some targets allow other format chars for bigger sizes here. */
-
- default:
- * sizeP = 0;
- return _("Bad call to md_atof()");
- }
-
- t = atof_ieee (input_line_pointer, type, words);
- if (t)
- input_line_pointer = t;
- * sizeP = prec * sizeof (LITTLENUM_TYPE);
-
- for (i = 0; i < prec; i++)
- {
- md_number_to_chars (litP, (valueT) words[i],
- sizeof (LITTLENUM_TYPE));
- litP += sizeof (LITTLENUM_TYPE);
- }
-
- return 0;
+ return ieee_md_atof (type, litP, sizeP, TRUE);
}
-boolean
-openrisc_fix_adjustable (fixP)
- fixS * fixP;
+bfd_boolean
+openrisc_fix_adjustable (fixS * fixP)
{
- if (fixP->fx_addsy == NULL)
- return 1;
-
- /* We need the symbol name for the VTABLE entries */
+ /* We need the symbol name for the VTABLE entries. */
if (fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT
|| fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
return 0;
return 1;
}
-
-
-