Back to index

cell-binutils  2.17cvs20070401
Classes | Defines | Functions | Variables
tc-fr30.c File Reference
#include "as.h"
#include "safe-ctype.h"
#include "subsegs.h"
#include "symcat.h"
#include "opcodes/fr30-desc.h"
#include "opcodes/fr30-opc.h"
#include "cgen.h"

Go to the source code of this file.

Classes

struct  fr30_insn

Defines

#define INSN_VALUE(buf)   (buf)
#define FR30_SHORTOPTS   ""
#define MAX_LITTLENUMS   6

Functions

int md_parse_option (int c ATTRIBUTE_UNUSED, char *arg ATTRIBUTE_UNUSED)
void md_show_usage (FILE *stream)
void md_begin (void)
void md_assemble (char *str)
void md_operand (expressionS *expressionP)
valueT md_section_align (segT segment, valueT size)
symbolS * md_undefined_symbol (char *name ATTRIBUTE_UNUSED)
int md_estimate_size_before_relax (fragS *fragP, segT segment)
void md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT sec ATTRIBUTE_UNUSED, fragS *fragP ATTRIBUTE_UNUSED)
long md_pcrel_from_section (fixS *fixP, segT sec)
bfd_reloc_code_real_type md_cgen_lookup_reloc (const CGEN_INSN *insn ATTRIBUTE_UNUSED, const CGEN_OPERAND *operand, fixS *fixP)
void md_number_to_chars (char *buf, valueT val, int n)
char * md_atof (int type, char *litP, int *sizeP)
static char restore_colon (int advance_i_l_p_by)
char fr30_is_colon_insn (char *start)
bfd_boolean fr30_fix_adjustable (fixS *fixP)

Variables

const char comment_chars [] = ";"
const char line_comment_chars [] = "#"
const char line_separator_chars [] = "|"
const char EXP_CHARS [] = "eE"
const char FLT_CHARS [] = "dD"
const char * md_shortopts = FR30_SHORTOPTS
size_t md_longopts_size = sizeof (md_longopts)
const pseudo_typeS md_pseudo_table []
const relax_typeS md_relax_table []

Class Documentation

struct fr30_insn

Definition at line 32 of file tc-fr30.c.

Class Members
char * addr
unsigned char buffer
CGEN_FIELDS fields
fixS * fixups
fragS * frag
int indices
const CGEN_INSN * insn
int num_fixups
const CGEN_INSN * orig_insn

Define Documentation

#define FR30_SHORTOPTS   ""

Definition at line 58 of file tc-fr30.c.

#define INSN_VALUE (   buf)    (buf)

Definition at line 42 of file tc-fr30.c.

#define MAX_LITTLENUMS   6

Definition at line 327 of file tc-fr30.c.


Function Documentation

bfd_boolean fr30_fix_adjustable ( fixS *  fixP)

Definition at line 460 of file tc-fr30.c.

{
  /* 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;
}
char fr30_is_colon_insn ( char *  start)

Definition at line 399 of file tc-fr30.c.

{
  char * i_l_p = input_line_pointer;

  /* Check to see if the symbol parsed so far is 'ldi'.  */
  if (   (start[0] != 'l' && start[0] != 'L')
      || (start[1] != 'd' && start[1] != 'D')
      || (start[2] != 'i' && start[2] != 'I')
      || start[3] != 0)
    {
      /* Nope - check to see a 'd' follows the colon.  */
      if (   (i_l_p[1] == 'd' || i_l_p[1] == 'D')
         && (i_l_p[2] == ' ' || i_l_p[2] == '\t' || i_l_p[2] == '\n'))
       {
         /* Yup - it might be delay slot instruction.  */
         int           i;
         static char * delay_insns [] =
         {
           "call", "jmp", "ret", "bra", "bno",
           "beq",  "bne", "bc",  "bnc", "bn",
           "bp",   "bv",  "bnv", "blt", "bge",
           "ble",  "bgt", "bls", "bhi"
         };

         for (i = sizeof (delay_insns) / sizeof (delay_insns[0]); i--;)
           {
             char * insn = delay_insns[i];
             int    len  = strlen (insn);

             if (start [len] != 0)
              continue;

             while (len --)
              if (TOLOWER (start [len]) != insn [len])
                break;

             if (len == -1)
              return restore_colon (1);
           }
       }

      /* Nope - it is a normal label.  */
      return 0;
    }

  /* Check to see if the text following the colon is '8'.  */
  if (i_l_p[1] == '8' && (i_l_p[2] == ' ' || i_l_p[2] == '\t'))
    return restore_colon (2);

  /* Check to see if the text following the colon is '20'.  */
  else if (i_l_p[1] == '2' && i_l_p[2] =='0' && (i_l_p[3] == ' ' || i_l_p[3] == '\t'))
    return restore_colon (3);

  /* Check to see if the text following the colon is '32'.  */
  else if (i_l_p[1] == '3' && i_l_p[2] =='2' && (i_l_p[3] == ' ' || i_l_p[3] == '\t'))
    return restore_colon (3);

  return 0;
}

Here is the call graph for this function:

void md_assemble ( char *  str)

Definition at line 110 of file tc-fr30.c.

{
  static int last_insn_had_delay_slot = 0;
  fr30_insn insn;
  char *errmsg;

  /* Initialize GAS's cgen interface for a new instruction.  */
  gas_cgen_init_parse ();

  insn.insn = fr30_cgen_assemble_insn
    (gas_cgen_cpu_desc, str, & insn.fields, insn.buffer, & errmsg);

  if (!insn.insn)
    {
      as_bad (errmsg);
      return;
    }

  /* Doesn't really matter what we pass for RELAX_P here.  */
  gas_cgen_finish_insn (insn.insn, insn.buffer,
                     CGEN_FIELDS_BITSIZE (& insn.fields), 1, NULL);

  /* 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));

  last_insn_had_delay_slot
    = CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_DELAY_SLOT);
}

Here is the call graph for this function:

char* md_atof ( int type  ,
char *  litP,
int sizeP 
)

Definition at line 330 of file tc-fr30.c.

{
  int              i;
  int              prec;
  LITTLENUM_TYPE   words [MAX_LITTLENUMS];
  char *           t;

  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;
}

Here is the call graph for this function:

void md_begin ( void  )

Definition at line 94 of file tc-fr30.c.

{
  /* Initialize the `cgen' interface.  */

  /* Set the machine number and endian.  */
  gas_cgen_cpu_desc = fr30_cgen_cpu_open (CGEN_CPU_OPEN_MACHS, 0,
                                     CGEN_CPU_OPEN_ENDIAN,
                                     CGEN_ENDIAN_BIG,
                                     CGEN_CPU_OPEN_END);
  fr30_cgen_init_asm (gas_cgen_cpu_desc);

  /* This is a callback from cgen to gas to parse operands.  */
  cgen_set_parse_operand_fn (gas_cgen_cpu_desc, gas_cgen_parse_operand);
}

Here is the call graph for this function:

bfd_reloc_code_real_type md_cgen_lookup_reloc ( const CGEN_INSN *insn  ATTRIBUTE_UNUSED,
const CGEN_OPERAND operand,
fixS *  fixP 
)

Definition at line 291 of file tc-fr30.c.

{
  switch (operand->type)
    {
    case FR30_OPERAND_LABEL9:  fixP->fx_pcrel = 1; return BFD_RELOC_FR30_9_PCREL;
    case FR30_OPERAND_LABEL12: fixP->fx_pcrel = 1; return BFD_RELOC_FR30_12_PCREL;
    case FR30_OPERAND_DISP10:  return BFD_RELOC_FR30_10_IN_8;
    case FR30_OPERAND_DISP9:   return BFD_RELOC_FR30_9_IN_8;
    case FR30_OPERAND_DISP8:   return BFD_RELOC_FR30_8_IN_8;
    case FR30_OPERAND_UDISP6:  return BFD_RELOC_FR30_6_IN_4;
    case FR30_OPERAND_I8:      return BFD_RELOC_8;
    case FR30_OPERAND_I32:     return BFD_RELOC_FR30_48;
    case FR30_OPERAND_I20:     return BFD_RELOC_FR30_20;
    default : /* Avoid -Wall warning.  */
      break;
    }

  return BFD_RELOC_NONE;
}
void md_convert_frag ( bfd *abfd  ATTRIBUTE_UNUSED,
segT sec  ATTRIBUTE_UNUSED,
fragS *fragP  ATTRIBUTE_UNUSED 
)

Definition at line 262 of file tc-fr30.c.

{
}
int md_estimate_size_before_relax ( fragS *  fragP,
segT segment   
)

Definition at line 211 of file tc-fr30.c.

{
  /* 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
     which case linker scripts may place them anywhere.
     However, we can't finish the fragment here and emit the reloc as insn
     alignment requirements may move the insn about.  */

  if (S_GET_SEGMENT (fragP->fr_symbol) != segment)
    {
      /* The symbol is undefined in this segment.
        Change the relaxation subtype to the max allowable and leave
        all further handling to md_convert_frag.  */
      fragP->fr_subtype = 2;

      {
       const CGEN_INSN * insn;
       int               i;

       /* Update the recorded insn.
          Fortunately we don't have to look very far.
          FIXME: Change this to record in the instruction the next higher
          relaxable insn to use.  */
       for (i = 0, insn = fragP->fr_cgen.insn; i < 4; i++, insn++)
         {
           if ((strcmp (CGEN_INSN_MNEMONIC (insn),
                      CGEN_INSN_MNEMONIC (fragP->fr_cgen.insn))
               == 0)
              && CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_RELAXED))
             break;
         }
       if (i == 4)
         abort ();

       fragP->fr_cgen.insn = insn;
       return 2;
      }
    }

  /* Return the size of the variable part of the frag.  */
  return md_relax_table[fragP->fr_subtype].rlx_length;
}

Here is the call graph for this function:

void md_number_to_chars ( char *  buf,
valueT  val,
int  n 
)

Definition at line 316 of file tc-fr30.c.

Here is the call graph for this function:

void md_operand ( expressionS expressionP)

Definition at line 146 of file tc-fr30.c.

{
  if (* input_line_pointer == '#')
    {
      input_line_pointer ++;
      expression (expressionP);
    }
}
int md_parse_option ( int c  ATTRIBUTE_UNUSED,
char *arg  ATTRIBUTE_UNUSED 
)

Definition at line 68 of file tc-fr30.c.

{
  switch (c)
    {
    default:
      return 0;
    }
  return 1;
}
long md_pcrel_from_section ( fixS *  fixP,
segT sec   
)

Definition at line 274 of file tc-fr30.c.

{
  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;

  return (fixP->fx_frag->fr_address + fixP->fx_where) & ~1;
}

Here is the call graph for this function:

valueT md_section_align ( segT segment  ,
valueT size   
)

Definition at line 156 of file tc-fr30.c.

{
  int align = bfd_get_section_alignment (stdoutput, segment);

  return ((size + (1 << align) - 1) & (-1 << align));
}

Here is the call graph for this function:

void md_show_usage ( FILE *  stream)

Definition at line 80 of file tc-fr30.c.

{
  fprintf (stream, _(" FR30 specific command line options:\n"));
}

Here is the call graph for this function:

symbolS* md_undefined_symbol ( char *name  ATTRIBUTE_UNUSED)

Definition at line 164 of file tc-fr30.c.

{
  return NULL;
}
static char restore_colon ( int  advance_i_l_p_by) [static]

Definition at line 377 of file tc-fr30.c.

{
  char c;

  /* Restore the colon, and advance input_line_pointer to
     the end of the new symbol.  */
  * input_line_pointer = ':';
  input_line_pointer += advance_i_l_p_by;
  c = * input_line_pointer;
  * input_line_pointer = 0;

  return c;
}

Here is the caller graph for this function:


Variable Documentation

const char comment_chars[] = ";"

Definition at line 52 of file tc-fr30.c.

const char EXP_CHARS[] = "eE"

Definition at line 55 of file tc-fr30.c.

const char FLT_CHARS[] = "dD"

Definition at line 56 of file tc-fr30.c.

const char line_comment_chars[] = "#"

Definition at line 53 of file tc-fr30.c.

Definition at line 54 of file tc-fr30.c.

size_t md_longopts_size = sizeof (md_longopts)

Definition at line 65 of file tc-fr30.c.

const pseudo_typeS md_pseudo_table[]
Initial value:
{
  { "word",   cons,         4 },
  { NULL,     NULL,         0 }
}

Definition at line 86 of file tc-fr30.c.

const relax_typeS md_relax_table[]
Initial value:
{


  
  {1, 1, 0, 0},

  
  
  {511 - 2 - 2, -512 - 2 + 2, 0, 2 },
  
  {0x2000000 - 1 - 2, -0x2000000 - 2, 2, 0 },
  
  {0x2000000 - 1 - 2, -0x2000000 - 2, 4, 0 }
}

Definition at line 173 of file tc-fr30.c.

Definition at line 59 of file tc-fr30.c.