Back to index

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

Go to the source code of this file.

Classes

struct  xc16x_insn

Defines

#define INSN_VALUE(buf)   (buf)
#define XC16X_SHORTOPTS   ""
#define MAX_LITTLENUMS   6
#define DEBUG   0

Functions

static void xc16xlmode (int arg ATTRIBUTE_UNUSED)
static void xc16xsmode (int arg ATTRIBUTE_UNUSED)
static void xc16xmode (int arg ATTRIBUTE_UNUSED)
void md_begin (void)
void md_assemble (char *str)
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)
void md_show_usage (FILE *stream)
int md_parse_option (int c ATTRIBUTE_UNUSED, char *arg ATTRIBUTE_UNUSED)
char * md_atof (int type, char *litP, int *sizeP)
valueT md_section_align (segT segment, valueT size)
symbolS * md_undefined_symbol (char *name ATTRIBUTE_UNUSED)
int md_estimate_size_before_relax (fragS *fragP ATTRIBUTE_UNUSED, segT segment_type ATTRIBUTE_UNUSED)
long md_pcrel_from (fixS *fixP)
long md_pcrel_from_section (fixS *fixP, segT sec)
arelenttc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
void md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
void md_convert_frag (bfd *headers ATTRIBUTE_UNUSED, segT seg ATTRIBUTE_UNUSED, fragS *fragP ATTRIBUTE_UNUSED)

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 = XC16X_SHORTOPTS
size_t md_longopts_size = sizeof (md_longopts)
const pseudo_typeS md_pseudo_table []

Class Documentation

struct xc16x_insn

Definition at line 39 of file tc-xc16x.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 DEBUG   0
#define INSN_VALUE (   buf)    (buf)

Definition at line 49 of file tc-xc16x.c.

#define MAX_LITTLENUMS   6

Definition at line 227 of file tc-xc16x.c.

#define XC16X_SHORTOPTS   ""

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


Function Documentation

void md_apply_fix ( fixS *  fixP,
valueT valP,
segT seg  ATTRIBUTE_UNUSED 
)

Definition at line 366 of file tc-xc16x.c.

{
  if(!strstr (seg->name,".debug"))
    {
      if (*valP < 128)
       *valP /= 2;
      if (*valP>268435455)
       {
         *valP = *valP * (-1);
         *valP /= 2;
         *valP = 256 - (*valP);
       }
    }
  
  gas_cgen_md_apply_fix (fixP, valP, seg);
  return;
}

Here is the call graph for this function:

void md_assemble ( char *  str)

Definition at line 123 of file tc-xc16x.c.

{
  xc16x_insn insn;
  char *errmsg;

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

  insn.insn = xc16x_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);
}

Here is the call graph for this function:

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

Definition at line 230 of file tc-xc16x.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 = prec - 1; i >= 0; i--)
     {
       md_number_to_chars (litP, (valueT) words[i],
                        sizeof (LITTLENUM_TYPE));
       litP += sizeof (LITTLENUM_TYPE);
     }

  return NULL;
}

Here is the call graph for this function:

void md_begin ( void  )

Definition at line 107 of file tc-xc16x.c.

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

  /* Set the machine number and endian.  */
  gas_cgen_cpu_desc = xc16x_cgen_cpu_open (CGEN_CPU_OPEN_MACHS, 0,
                                      CGEN_CPU_OPEN_ENDIAN,
                                      CGEN_ENDIAN_LITTLE,
                                      CGEN_CPU_OPEN_END);
  xc16x_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 150 of file tc-xc16x.c.

{
  switch (operand->type)
    {
    case XC16X_OPERAND_REL:
      fixP->fx_where += 1;
      fixP->fx_pcrel = 1;
      return BFD_RELOC_8_PCREL;

    case XC16X_OPERAND_CADDR:
      fixP->fx_where += 2;
      return BFD_RELOC_16;

    case XC16X_OPERAND_UIMM7:
      fixP->fx_where += 1;
      fixP->fx_pcrel = 1;
      return BFD_RELOC_8_PCREL;

    case XC16X_OPERAND_UIMM16:
    case XC16X_OPERAND_MEMORY:
      fixP->fx_where += 2;
      return BFD_RELOC_16;

    case XC16X_OPERAND_UPOF16:
      fixP->fx_where += 2;
      return BFD_RELOC_XC16X_POF;

    case XC16X_OPERAND_UPAG16:
      fixP->fx_where += 2;
      return BFD_RELOC_XC16X_PAG;

    case XC16X_OPERAND_USEG8:
      fixP->fx_where += 1;
      return BFD_RELOC_XC16X_SEG;

    case XC16X_OPERAND_USEG16:
    case  XC16X_OPERAND_USOF16:
      fixP->fx_where += 2;
      return BFD_RELOC_XC16X_SOF;

    default : /* avoid -Wall warning */
      break;
    }

  fixP->fx_where += 2;
  return BFD_RELOC_XC16X_SOF;
}
void md_convert_frag ( bfd *headers  ATTRIBUTE_UNUSED,
segT seg  ATTRIBUTE_UNUSED,
fragS *fragP  ATTRIBUTE_UNUSED 
)

Definition at line 385 of file tc-xc16x.c.

{
  printf (_("call to md_convert_frag \n"));
  abort ();
}

Here is the call graph for this function:

int md_estimate_size_before_relax ( fragS *fragP  ATTRIBUTE_UNUSED,
segT segment_type  ATTRIBUTE_UNUSED 
)

Definition at line 290 of file tc-xc16x.c.

{
  printf (_("call tomd_estimate_size_before_relax \n"));
  abort ();
}

Here is the call graph for this function:

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

Definition at line 203 of file tc-xc16x.c.

Here is the call graph for this function:

int md_parse_option ( int c  ATTRIBUTE_UNUSED,
char *arg  ATTRIBUTE_UNUSED 
)

Definition at line 215 of file tc-xc16x.c.

{
  return 0;
}
long md_pcrel_from ( fixS *  fixP)

Definition at line 299 of file tc-xc16x.c.

{
  long temp_val;
  temp_val=fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address;

  return temp_val;
}
long md_pcrel_from_section ( fixS *  fixP,
segT sec   
)

Definition at line 308 of file tc-xc16x.c.

{
  if (fixP->fx_addsy != (symbolS *) NULL
      && (! S_IS_DEFINED (fixP->fx_addsy)
         || S_GET_SEGMENT (fixP->fx_addsy) != sec
          || S_IS_EXTERNAL (fixP->fx_addsy)
          || S_IS_WEAK (fixP->fx_addsy)))
    {
      return 0;
    }

  return md_pcrel_from (fixP);
}

Here is the call graph for this function:

valueT md_section_align ( segT segment  ,
valueT size   
)

Definition at line 277 of file tc-xc16x.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 209 of file tc-xc16x.c.

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

Here is the call graph for this function:

symbolS* md_undefined_symbol ( char *name  ATTRIBUTE_UNUSED)

Definition at line 284 of file tc-xc16x.c.

{
  return NULL;
}
arelent* tc_gen_reloc ( asection *section  ATTRIBUTE_UNUSED,
fixS *  fixp 
)

Definition at line 323 of file tc-xc16x.c.

{
  arelent *rel;
  bfd_reloc_code_real_type r_type;

  if (fixp->fx_addsy && fixp->fx_subsy)
    {
      if ((S_GET_SEGMENT (fixp->fx_addsy) != S_GET_SEGMENT (fixp->fx_subsy))
         || S_GET_SEGMENT (fixp->fx_addsy) == undefined_section)
       {
         as_bad_where (fixp->fx_file, fixp->fx_line,
                     "Difference of symbols in different sections is not supported");
         return NULL;
       }
    }

  rel = xmalloc (sizeof (arelent));
  rel->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
  *rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
  rel->address = fixp->fx_frag->fr_address + fixp->fx_where;
  rel->addend = fixp->fx_offset;

  r_type = fixp->fx_r_type;

#define DEBUG 0
#if DEBUG
  fprintf (stderr, "%s\n", bfd_get_reloc_code_name (r_type));
  fflush(stderr);
#endif

  rel->howto = bfd_reloc_type_lookup (stdoutput, r_type);
   if (rel->howto == NULL)
    {
      as_bad_where (fixp->fx_file, fixp->fx_line,
                  _("Cannot represent relocation type %s"),
                  bfd_get_reloc_code_name (r_type));
      return NULL;
    }

  return rel;
}

Here is the call graph for this function:

static void xc16xlmode ( int arg  ATTRIBUTE_UNUSED) [static]

Definition at line 75 of file tc-xc16x.c.

{
 if (stdoutput != NULL)
  if (!bfd_set_arch_mach (stdoutput, bfd_arch_xc16x, bfd_mach_xc16xl))
    as_warn (_("could not set architecture and machine"));
}

Here is the call graph for this function:

static void xc16xmode ( int arg  ATTRIBUTE_UNUSED) [static]

Definition at line 90 of file tc-xc16x.c.

{
  if (!bfd_set_arch_mach (stdoutput, bfd_arch_xc16x, bfd_mach_xc16x))
    as_warn (_("could not set architecture and machine"));
}

Here is the call graph for this function:

static void xc16xsmode ( int arg  ATTRIBUTE_UNUSED) [static]

Definition at line 83 of file tc-xc16x.c.

{
  if (!bfd_set_arch_mach (stdoutput, bfd_arch_xc16x, bfd_mach_xc16xs))
    as_warn (_("could not set architecture and machine"));
}

Here is the call graph for this function:


Variable Documentation

const char comment_chars[] = ";"

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

const char EXP_CHARS[] = "eE"

Definition at line 62 of file tc-xc16x.c.

const char FLT_CHARS[] = "dD"

Definition at line 63 of file tc-xc16x.c.

const char line_comment_chars[] = "#"

Definition at line 60 of file tc-xc16x.c.

Definition at line 61 of file tc-xc16x.c.

size_t md_longopts_size = sizeof (md_longopts)

Definition at line 72 of file tc-xc16x.c.

const pseudo_typeS md_pseudo_table[]
Initial value:
{
  { "word",   cons,         2 },
  {"xc16xl",  xc16xlmode,  0},
  {"xc16xs", xc16xsmode, 0},
  {"xc16x",  xc16xmode,  0},
  { NULL,     NULL,         0 }
}

Definition at line 97 of file tc-xc16x.c.

Definition at line 66 of file tc-xc16x.c.