Back to index

cell-binutils  2.17cvs20070401
Classes | Defines | Enumerations | Functions
sh-opc.h File Reference
#include "bfd.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  sh_opcode_info

Defines

#define MASK(LO, HI)
#define arch_sh1_base   (1 << 0)
#define arch_sh2_base   (1 << 1)
#define arch_sh2a_sh3_base   (1 << 2)
#define arch_sh3_base   (1 << 3)
#define arch_sh2a_sh4_base   (1 << 4)
#define arch_sh4_base   (1 << 5)
#define arch_sh4a_base   (1 << 6)
#define arch_sh2a_base   (1 << 7)
#define arch_sh_base_mask   MASK (0, 7)
#define arch_op32   (1 << 25) /* This is a 32-bit opcode. */
#define arch_opann_mask   MASK (25, 25)
#define arch_sh_no_mmu   (1 << 26)
#define arch_sh_has_mmu   (1 << 27)
#define arch_sh_mmu_mask   MASK (26, 27)
#define arch_sh_no_co   (1 << 28) /* Neither FPU nor DSP co-processor. */
#define arch_sh_sp_fpu   (1 << 29) /* Single precision FPU. */
#define arch_sh_dp_fpu   (1 << 30) /* Double precision FPU. */
#define arch_sh_has_dsp   (1 << 31)
#define arch_sh_co_mask   MASK (28, 31)
#define arch_sh1   (arch_sh1_base |arch_sh_no_mmu |arch_sh_no_co)
#define arch_sh2   (arch_sh2_base |arch_sh_no_mmu |arch_sh_no_co)
#define arch_sh2a   (arch_sh2a_base |arch_sh_no_mmu |arch_sh_dp_fpu)
#define arch_sh2a_nofpu   (arch_sh2a_base |arch_sh_no_mmu |arch_sh_no_co)
#define arch_sh2e   (arch_sh2_base |arch_sh_no_mmu |arch_sh_sp_fpu)
#define arch_sh_dsp   (arch_sh2_base |arch_sh_no_mmu |arch_sh_has_dsp)
#define arch_sh3_nommu   (arch_sh3_base |arch_sh_no_mmu |arch_sh_no_co)
#define arch_sh3   (arch_sh3_base |arch_sh_has_mmu|arch_sh_no_co)
#define arch_sh3e   (arch_sh3_base |arch_sh_has_mmu|arch_sh_sp_fpu)
#define arch_sh3_dsp   (arch_sh3_base |arch_sh_has_mmu|arch_sh_has_dsp)
#define arch_sh4   (arch_sh4_base |arch_sh_has_mmu|arch_sh_dp_fpu)
#define arch_sh4a   (arch_sh4a_base |arch_sh_has_mmu|arch_sh_dp_fpu)
#define arch_sh4al_dsp   (arch_sh4a_base |arch_sh_has_mmu|arch_sh_has_dsp)
#define arch_sh4_nofpu   (arch_sh4_base |arch_sh_has_mmu|arch_sh_no_co)
#define arch_sh4a_nofpu   (arch_sh4a_base |arch_sh_has_mmu|arch_sh_no_co)
#define arch_sh4_nommu_nofpu   (arch_sh4_base |arch_sh_no_mmu |arch_sh_no_co)
#define arch_sh2a_nofpu_or_sh4_nommu_nofpu   (arch_sh2a_sh4_base|arch_sh_no_mmu |arch_sh_no_co)
#define arch_sh2a_nofpu_or_sh3_nommu   (arch_sh2a_sh3_base|arch_sh_no_mmu |arch_sh_no_co)
#define arch_sh2a_or_sh3e   (arch_sh2a_sh4_base|arch_sh_no_mmu |arch_sh_sp_fpu)
#define arch_sh2a_or_sh4   (arch_sh2a_sh4_base|arch_sh_no_mmu |arch_sh_dp_fpu)
#define SH_MERGE_ARCH_SET(SET1, SET2)   ((SET1) & (SET2))
#define SH_VALID_BASE_ARCH_SET(SET)   (((SET) & arch_sh_base_mask) != 0)
#define SH_VALID_MMU_ARCH_SET(SET)   (((SET) & arch_sh_mmu_mask) != 0)
#define SH_VALID_CO_ARCH_SET(SET)   (((SET) & arch_sh_co_mask) != 0)
#define SH_VALID_ARCH_SET(SET)
#define SH_MERGE_ARCH_SET_VALID(SET1, SET2)   SH_VALID_ARCH_SET (SH_MERGE_ARCH_SET (SET1, SET2))
#define SH_ARCH_SET_HAS_FPU(SET)   (((SET) & (arch_sh_sp_fpu | arch_sh_dp_fpu)) != 0)
#define SH_ARCH_SET_HAS_DSP(SET)   (((SET) & arch_sh_has_dsp) != 0)
#define SH_ARCH_UNKNOWN_ARCH   0xffffffff
#define arch_sh_up
#define arch_sh2_up
#define arch_sh2a_nofpu_or_sh3_nommu_up
#define arch_sh2a_nofpu_or_sh4_nommu_nofpu_up
#define arch_sh2a_nofpu_up
#define arch_sh3_nommu_up
#define arch_sh3_up
#define arch_sh4_nommu_nofpu_up
#define arch_sh4_nofpu_up
#define arch_sh4a_nofpu_up
#define arch_sh2e_up
#define arch_sh2a_or_sh3e_up
#define arch_sh2a_or_sh4_up
#define arch_sh2a_up   (arch_sh2a)
#define arch_sh3e_up
#define arch_sh4_up
#define arch_sh4a_up   (arch_sh4a)
#define arch_sh_dsp_up
#define arch_sh3_dsp_up
#define arch_sh4al_dsp_up   (arch_sh4al_dsp)

Enumerations

enum  sh_nibble_type {
  HEX_0, HEX_1, HEX_2, HEX_3,
  HEX_4, HEX_5, HEX_6, HEX_7,
  HEX_8, HEX_9, HEX_A, HEX_B,
  HEX_C, HEX_D, HEX_E, HEX_F,
  HEX_XX00, HEX_00YY, REG_N, REG_N_D,
  REG_N_B01, REG_M, SDT_REG_N, REG_NM,
  REG_B, BRANCH_12, BRANCH_8, IMM0_4,
  IMM0_4BY2, IMM0_4BY4, IMM1_4, IMM1_4BY2,
  IMM1_4BY4, PCRELIMM_8BY2, PCRELIMM_8BY4, IMM0_8,
  IMM0_8BY2, IMM0_8BY4, IMM1_8, IMM1_8BY2,
  IMM1_8BY4, PPI, NOPX, NOPY,
  MOVX, MOVY, MOVX_NOPY, MOVY_NOPX,
  PSH, PMUL, PPI3, PPI3NC,
  PDC, PPIC, REPEAT, IMM0_3c,
  IMM0_3s, IMM0_3Uc, IMM0_3Us, IMM0_20_4,
  IMM0_20, IMM0_20BY8, DISP0_12, DISP0_12BY2,
  DISP0_12BY4, DISP0_12BY8, DISP1_12, DISP1_12BY2,
  DISP1_12BY4, DISP1_12BY8
}
enum  sh_arg_type {
  A_END, A_BDISP12, A_BDISP8, A_DEC_M,
  A_DEC_N, A_DISP_GBR, A_PC, A_DISP_PC,
  A_DISP_PC_ABS, A_DISP_REG_M, A_DISP_REG_N, A_GBR,
  A_IMM, A_INC_M, A_INC_N, A_IND_M,
  A_IND_N, A_IND_R0_REG_M, A_IND_R0_REG_N, A_MACH,
  A_MACL, A_PR, A_R0, A_R0_GBR,
  A_REG_M, A_REG_N, A_REG_B, A_SR,
  A_VBR, A_TBR, A_DISP_TBR, A_DISP2_TBR,
  A_DEC_R15, A_INC_R15, A_MOD, A_RE,
  A_RS, A_DSR, DSP_REG_M, DSP_REG_N,
  DSP_REG_X, DSP_REG_Y, DSP_REG_E, DSP_REG_F,
  DSP_REG_G, DSP_REG_A_M, DSP_REG_AX, DSP_REG_XY,
  DSP_REG_AY, DSP_REG_YX, AX_INC_N, AY_INC_N,
  AXY_INC_N, AYX_INC_N, AX_IND_N, AY_IND_N,
  AXY_IND_N, AYX_IND_N, AX_PMOD_N, AXY_PMOD_N,
  AY_PMOD_N, AYX_PMOD_N, AS_DEC_N, AS_INC_N,
  AS_IND_N, AS_PMOD_N, A_A0, A_X0,
  A_X1, A_Y0, A_Y1, A_SSR,
  A_SPC, A_SGR, A_DBR, F_REG_N,
  F_REG_M, D_REG_N, D_REG_M, X_REG_N,
  X_REG_M, DX_REG_N, DX_REG_M, V_REG_N,
  V_REG_M, XMTRX_M4, F_FR0, FPUL_N,
  FPUL_M, FPSCR_N, FPSCR_M
}
enum  sh_dsp_reg_nums {
  A_A1_NUM = 5, A_A0_NUM = 7, A_X0_NUM, A_X1_NUM,
  A_Y0_NUM, A_Y1_NUM, A_M0_NUM, A_A1G_NUM,
  A_M1_NUM, A_A0G_NUM
}

Functions

unsigned int sh_get_arch_from_bfd_mach (unsigned long mach)
unsigned int sh_get_arch_up_from_bfd_mach (unsigned long mach)
unsigned long sh_get_bfd_mach_from_arch_set (unsigned int arch_set)
bfd_boolean sh_merge_bfd_arch (bfd *ibfd, bfd *obfd)

Class Documentation

struct sh_opcode_info

Definition at line 370 of file sh-opc.h.

Class Members
unsigned int arch
sh_arg_type arg
char * name
sh_nibble_type nibbles

Define Documentation

#define arch_op32   (1 << 25) /* This is a 32-bit opcode. */

Definition at line 221 of file sh-opc.h.

#define arch_opann_mask   MASK (25, 25)

Definition at line 222 of file sh-opc.h.

Definition at line 235 of file sh-opc.h.

#define arch_sh1_base   (1 << 0)

Definition at line 207 of file sh-opc.h.

Definition at line 236 of file sh-opc.h.

#define arch_sh2_base   (1 << 1)

Definition at line 208 of file sh-opc.h.

#define arch_sh2_up
Value:

Definition at line 317 of file sh-opc.h.

Definition at line 237 of file sh-opc.h.

#define arch_sh2a_base   (1 << 7)

Definition at line 214 of file sh-opc.h.

Definition at line 238 of file sh-opc.h.

Definition at line 252 of file sh-opc.h.

Definition at line 251 of file sh-opc.h.

Value:

Definition at line 329 of file sh-opc.h.

Definition at line 253 of file sh-opc.h.

Value:

Definition at line 350 of file sh-opc.h.

Definition at line 254 of file sh-opc.h.

Value:

Definition at line 353 of file sh-opc.h.

#define arch_sh2a_sh3_base   (1 << 2)

Definition at line 209 of file sh-opc.h.

#define arch_sh2a_sh4_base   (1 << 4)

Definition at line 211 of file sh-opc.h.

#define arch_sh2a_up   (arch_sh2a)

Definition at line 356 of file sh-opc.h.

Definition at line 239 of file sh-opc.h.

#define arch_sh2e_up
Value:

Definition at line 348 of file sh-opc.h.

Definition at line 242 of file sh-opc.h.

#define arch_sh3_base   (1 << 3)

Definition at line 210 of file sh-opc.h.

Definition at line 244 of file sh-opc.h.

#define arch_sh3_dsp_up
Value:

Definition at line 366 of file sh-opc.h.

Definition at line 241 of file sh-opc.h.

Value:

Definition at line 331 of file sh-opc.h.

#define arch_sh3_up
Value:

Definition at line 334 of file sh-opc.h.

Definition at line 243 of file sh-opc.h.

#define arch_sh3e_up
Value:

Definition at line 357 of file sh-opc.h.

Definition at line 245 of file sh-opc.h.

#define arch_sh4_base   (1 << 5)

Definition at line 212 of file sh-opc.h.

Definition at line 248 of file sh-opc.h.

Value:

Definition at line 340 of file sh-opc.h.

Definition at line 250 of file sh-opc.h.

Value:

Definition at line 338 of file sh-opc.h.

#define arch_sh4_up
Value:

Definition at line 359 of file sh-opc.h.

Definition at line 246 of file sh-opc.h.

#define arch_sh4a_base   (1 << 6)

Definition at line 213 of file sh-opc.h.

Definition at line 249 of file sh-opc.h.

Value:

Definition at line 343 of file sh-opc.h.

#define arch_sh4a_up   (arch_sh4a)

Definition at line 361 of file sh-opc.h.

Definition at line 247 of file sh-opc.h.

Definition at line 368 of file sh-opc.h.

#define arch_sh_base_mask   MASK (0, 7)

Definition at line 215 of file sh-opc.h.

#define arch_sh_co_mask   MASK (28, 31)

Definition at line 232 of file sh-opc.h.

#define arch_sh_dp_fpu   (1 << 30) /* Double precision FPU. */

Definition at line 230 of file sh-opc.h.

Definition at line 240 of file sh-opc.h.

#define arch_sh_dsp_up
Value:

Definition at line 364 of file sh-opc.h.

#define arch_sh_has_dsp   (1 << 31)

Definition at line 231 of file sh-opc.h.

#define arch_sh_has_mmu   (1 << 27)

Definition at line 225 of file sh-opc.h.

#define arch_sh_mmu_mask   MASK (26, 27)

Definition at line 226 of file sh-opc.h.

#define arch_sh_no_co   (1 << 28) /* Neither FPU nor DSP co-processor. */

Definition at line 228 of file sh-opc.h.

#define arch_sh_no_mmu   (1 << 26)

Definition at line 224 of file sh-opc.h.

#define arch_sh_sp_fpu   (1 << 29) /* Single precision FPU. */

Definition at line 229 of file sh-opc.h.

#define arch_sh_up
Value:

Definition at line 315 of file sh-opc.h.

#define MASK (   LO,
  HI 
)
Value:
(  LO < 1   ? ((1 << (HI + 1)) - 1) \
                    : HI > 30  ? (-1 << LO) \
                    : LO == HI ? (1 << LO) \
                    :            (((1 << (HI + 1)) - 1) & (-1 << LO)))

Definition at line 202 of file sh-opc.h.

#define SH_ARCH_SET_HAS_DSP (   SET)    (((SET) & arch_sh_has_dsp) != 0)

Definition at line 269 of file sh-opc.h.

#define SH_ARCH_SET_HAS_FPU (   SET)    (((SET) & (arch_sh_sp_fpu | arch_sh_dp_fpu)) != 0)

Definition at line 267 of file sh-opc.h.

#define SH_ARCH_UNKNOWN_ARCH   0xffffffff

Definition at line 276 of file sh-opc.h.

#define SH_MERGE_ARCH_SET (   SET1,
  SET2 
)    ((SET1) & (SET2))

Definition at line 256 of file sh-opc.h.

#define SH_MERGE_ARCH_SET_VALID (   SET1,
  SET2 
)    SH_VALID_ARCH_SET (SH_MERGE_ARCH_SET (SET1, SET2))

Definition at line 264 of file sh-opc.h.

#define SH_VALID_ARCH_SET (   SET)
Value:

Definition at line 260 of file sh-opc.h.

#define SH_VALID_BASE_ARCH_SET (   SET)    (((SET) & arch_sh_base_mask) != 0)

Definition at line 257 of file sh-opc.h.

#define SH_VALID_CO_ARCH_SET (   SET)    (((SET) & arch_sh_co_mask) != 0)

Definition at line 259 of file sh-opc.h.

#define SH_VALID_MMU_ARCH_SET (   SET)    (((SET) & arch_sh_mmu_mask) != 0)

Definition at line 258 of file sh-opc.h.


Enumeration Type Documentation

Enumerator:
A_END 
A_BDISP12 
A_BDISP8 
A_DEC_M 
A_DEC_N 
A_DISP_GBR 
A_PC 
A_DISP_PC 
A_DISP_PC_ABS 
A_DISP_REG_M 
A_DISP_REG_N 
A_GBR 
A_IMM 
A_INC_M 
A_INC_N 
A_IND_M 
A_IND_N 
A_IND_R0_REG_M 
A_IND_R0_REG_N 
A_MACH 
A_MACL 
A_PR 
A_R0 
A_R0_GBR 
A_REG_M 
A_REG_N 
A_REG_B 
A_SR 
A_VBR 
A_TBR 
A_DISP_TBR 
A_DISP2_TBR 
A_DEC_R15 
A_INC_R15 
A_MOD 
A_RE 
A_RS 
A_DSR 
DSP_REG_M 
DSP_REG_N 
DSP_REG_X 
DSP_REG_Y 
DSP_REG_E 
DSP_REG_F 
DSP_REG_G 
DSP_REG_A_M 
DSP_REG_AX 
DSP_REG_XY 
DSP_REG_AY 
DSP_REG_YX 
AX_INC_N 
AY_INC_N 
AXY_INC_N 
AYX_INC_N 
AX_IND_N 
AY_IND_N 
AXY_IND_N 
AYX_IND_N 
AX_PMOD_N 
AXY_PMOD_N 
AY_PMOD_N 
AYX_PMOD_N 
AS_DEC_N 
AS_INC_N 
AS_IND_N 
AS_PMOD_N 
A_A0 
A_X0 
A_X1 
A_Y0 
A_Y1 
A_SSR 
A_SPC 
A_SGR 
A_DBR 
F_REG_N 
F_REG_M 
D_REG_N 
D_REG_M 
X_REG_N 
X_REG_M 
DX_REG_N 
DX_REG_M 
V_REG_N 
V_REG_M 
XMTRX_M4 
F_FR0 
FPUL_N 
FPUL_M 
FPSCR_N 
FPSCR_M 

Definition at line 96 of file sh-opc.h.

Enumerator:
A_A1_NUM 
A_A0_NUM 
A_X0_NUM 
A_X1_NUM 
A_Y0_NUM 
A_Y1_NUM 
A_M0_NUM 
A_A1G_NUM 
A_M1_NUM 
A_A0G_NUM 

Definition at line 192 of file sh-opc.h.

Enumerator:
HEX_0 
HEX_1 
HEX_2 
HEX_3 
HEX_4 
HEX_5 
HEX_6 
HEX_7 
HEX_8 
HEX_9 
HEX_A 
HEX_B 
HEX_C 
HEX_D 
HEX_E 
HEX_F 
HEX_XX00 
HEX_00YY 
REG_N 
REG_N_D 
REG_N_B01 
REG_M 
SDT_REG_N 
REG_NM 
REG_B 
BRANCH_12 
BRANCH_8 
IMM0_4 
IMM0_4BY2 
IMM0_4BY4 
IMM1_4 
IMM1_4BY2 
IMM1_4BY4 
PCRELIMM_8BY2 
PCRELIMM_8BY4 
IMM0_8 
IMM0_8BY2 
IMM0_8BY4 
IMM1_8 
IMM1_8BY2 
IMM1_8BY4 
PPI 
NOPX 
NOPY 
MOVX 
MOVY 
MOVX_NOPY 
MOVY_NOPX 
PSH 
PMUL 
PPI3 
PPI3NC 
PDC 
PPIC 
REPEAT 
IMM0_3c 
IMM0_3s 
IMM0_3Uc 
IMM0_3Us 
IMM0_20_4 
IMM0_20 
IMM0_20BY8 
DISP0_12 
DISP0_12BY2 
DISP0_12BY4 
DISP0_12BY8 
DISP1_12 
DISP1_12BY2 
DISP1_12BY4 
DISP1_12BY8 

Definition at line 21 of file sh-opc.h.


Function Documentation

Definition at line 388 of file cpu-sh.c.

{
  int i = 0;

  while (bfd_to_arch_table[i].bfd_mach != 0)
    if (bfd_to_arch_table[i].bfd_mach == mach)
      return bfd_to_arch_table[i].arch;
    else
      i++;

  /* Machine not found.   */
  BFD_FAIL();

  return SH_ARCH_UNKNOWN_ARCH;
}

Here is the caller graph for this function:

Definition at line 410 of file cpu-sh.c.

{
  int i = 0;

  while (bfd_to_arch_table[i].bfd_mach != 0)
    if (bfd_to_arch_table[i].bfd_mach == mach)
      return bfd_to_arch_table[i].arch_up;
    else
      i++;

  /* Machine not found.  */
  BFD_FAIL();

  return SH_ARCH_UNKNOWN_ARCH;
}

Here is the caller graph for this function:

Definition at line 433 of file cpu-sh.c.

{
  unsigned long result = 0;
  unsigned int best = ~arch_set;
  unsigned int co_mask = ~0;
  int i = 0;

  /* If arch_set permits variants with no coprocessor then do not allow
     the other irrelevant co-processor bits to influence the choice:
       e.g. if dsp is disallowed by arch_set, then the algorithm would
       prefer fpu variants over nofpu variants because they also disallow
       dsp - even though the nofpu would be the most correct choice.
     This assumes that EVERY fpu/dsp variant has a no-coprocessor
     counter-part, or their non-fpu/dsp instructions do not have the
     no co-processor bit set.  */
  if (arch_set & arch_sh_no_co)
    co_mask = ~(arch_sh_sp_fpu | arch_sh_dp_fpu | arch_sh_has_dsp);

  while (bfd_to_arch_table[i].bfd_mach != 0)
    {
      unsigned int try = bfd_to_arch_table[i].arch_up & co_mask;

      /* Conceptually: Find the architecture with the least number
        of extra features or, if they have the same number, then
        the greatest number of required features.  Disregard
         architectures where the required features alone do
        not describe a valid architecture.  */
      if (((try & ~arch_set) < (best & ~arch_set)
          || ((try & ~arch_set) == (best & ~arch_set)
              && (~try & arch_set) < (~best & arch_set)))
         && SH_MERGE_ARCH_SET_VALID (try, arch_set))
       {
         result = bfd_to_arch_table[i].bfd_mach;
         best = try;
       }

      i++;
    }

  /* This might happen if a new variant is added to sh-opc.h
     but no corresponding entry is added to the table above.  */
  BFD_ASSERT (result != 0);

  return result;
}

Here is the caller graph for this function:

bfd_boolean sh_merge_bfd_arch ( bfd ibfd,
bfd obfd 
)

Definition at line 488 of file cpu-sh.c.

{
  unsigned int old_arch, new_arch, merged_arch;

  if (! _bfd_generic_verify_endian_match (ibfd, obfd))
    return FALSE;

  old_arch = sh_get_arch_up_from_bfd_mach (bfd_get_mach (obfd));
  new_arch = sh_get_arch_up_from_bfd_mach (bfd_get_mach (ibfd));

  merged_arch = SH_MERGE_ARCH_SET (old_arch, new_arch);

  if (!SH_VALID_CO_ARCH_SET (merged_arch))
    {
      (*_bfd_error_handler)
       ("%B: uses %s instructions while previous modules use %s instructions",
        ibfd,
        SH_ARCH_SET_HAS_DSP (new_arch) ? "dsp" : "floating point",
        SH_ARCH_SET_HAS_DSP (new_arch) ? "floating point" : "dsp");
      bfd_set_error (bfd_error_bad_value);
      return FALSE;
    }
  else if (!SH_VALID_ARCH_SET (merged_arch))
    {
      (*_bfd_error_handler)
       ("internal error: merge of architecture '%s' with architecture '%s' produced unknown architecture\n",
        bfd_printable_name (obfd),
        bfd_printable_name (ibfd));
      bfd_set_error (bfd_error_bad_value);
      return FALSE;
    }

  bfd_default_set_arch_mach (obfd, bfd_arch_sh,
                          sh_get_bfd_mach_from_arch_set (merged_arch));
  
  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function: