Home | History | Annotate | Line # | Download | only in opcode
v850.h revision 1.1.1.5
      1      1.1     skrll /* v850.h -- Header file for NEC V850 opcode table
      2  1.1.1.5  christos    Copyright (C) 1996-2018 Free Software Foundation, Inc.
      3      1.1     skrll    Written by J.T. Conklin, Cygnus Support
      4      1.1     skrll 
      5  1.1.1.2  christos    This file is part of GDB, GAS, and the GNU binutils.
      6      1.1     skrll 
      7  1.1.1.2  christos    GDB, GAS, and the GNU binutils are free software; you can redistribute
      8  1.1.1.2  christos    them and/or modify them under the terms of the GNU General Public
      9  1.1.1.2  christos    License as published by the Free Software Foundation; either version 3,
     10  1.1.1.2  christos    or (at your option) any later version.
     11  1.1.1.2  christos 
     12  1.1.1.2  christos    GDB, GAS, and the GNU binutils are distributed in the hope that they
     13  1.1.1.2  christos    will be useful, but WITHOUT ANY WARRANTY; without even the implied
     14  1.1.1.2  christos    warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
     15  1.1.1.2  christos    the GNU General Public License for more details.
     16  1.1.1.2  christos 
     17  1.1.1.2  christos    You should have received a copy of the GNU General Public License
     18  1.1.1.2  christos    along with this file; see the file COPYING3.  If not, write to the Free
     19  1.1.1.2  christos    Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
     20  1.1.1.2  christos    MA 02110-1301, USA.  */
     21      1.1     skrll 
     22      1.1     skrll #ifndef V850_H
     23      1.1     skrll #define V850_H
     24      1.1     skrll 
     25  1.1.1.4  christos #ifdef __cplusplus
     26  1.1.1.4  christos extern "C" {
     27  1.1.1.4  christos #endif
     28  1.1.1.4  christos 
     29      1.1     skrll /* The opcode table is an array of struct v850_opcode.  */
     30      1.1     skrll 
     31      1.1     skrll struct v850_opcode
     32      1.1     skrll {
     33      1.1     skrll   /* The opcode name.  */
     34      1.1     skrll   const char *name;
     35      1.1     skrll 
     36      1.1     skrll   /* The opcode itself.  Those bits which will be filled in with
     37      1.1     skrll      operands are zeroes.  */
     38      1.1     skrll   unsigned long opcode;
     39      1.1     skrll 
     40      1.1     skrll   /* The opcode mask.  This is used by the disassembler.  This is a
     41      1.1     skrll      mask containing ones indicating those bits which must match the
     42      1.1     skrll      opcode field, and zeroes indicating those bits which need not
     43      1.1     skrll      match (and are presumably filled in by operands).  */
     44      1.1     skrll   unsigned long mask;
     45      1.1     skrll 
     46      1.1     skrll   /* An array of operand codes.  Each code is an index into the
     47      1.1     skrll      operand table.  They appear in the order which the operands must
     48      1.1     skrll      appear in assembly code, and are terminated by a zero.  */
     49      1.1     skrll   unsigned char operands[8];
     50      1.1     skrll 
     51      1.1     skrll   /* Which (if any) operand is a memory operand.  */
     52      1.1     skrll   unsigned int memop;
     53      1.1     skrll 
     54      1.1     skrll   /* Target processor(s).  A bit field of processors which support
     55      1.1     skrll      this instruction.  Note a bit field is used as some instructions
     56      1.1     skrll      are available on multiple, different processor types, whereas
     57      1.1     skrll      other instructions are only available on one specific type.  */
     58      1.1     skrll   unsigned int processors;
     59      1.1     skrll };
     60      1.1     skrll 
     61  1.1.1.3  christos /* Values for architecture number.  */
     62  1.1.1.3  christos #define arch_V850      0
     63  1.1.1.3  christos #define arch_V850E     (arch_V850 + 1)
     64  1.1.1.3  christos #define arch_V850E1    (arch_V850E + 1)
     65  1.1.1.3  christos #define arch_V850E2    (arch_V850E1 + 1)
     66  1.1.1.3  christos #define arch_V850E2V3  (arch_V850E2 + 1)
     67  1.1.1.3  christos #define arch_V850E3V5  (arch_V850E2V3 + 1)
     68  1.1.1.3  christos #define arch_separator (arch_V850E3V5 + 1)
     69  1.1.1.3  christos 
     70  1.1.1.3  christos #define opt_EXTENSION  (arch_separator)
     71  1.1.1.3  christos #define opt_ALIAS      (opt_EXTENSION + 1)
     72  1.1.1.3  christos 
     73      1.1     skrll /* Values for the processors field in the v850_opcode structure.  */
     74  1.1.1.3  christos #define PROCESSOR_V850       (1 << (arch_V850))     /* Just the V850.  */
     75  1.1.1.3  christos #define PROCESSOR_V850E      (1 << (arch_V850E))    /* Just the V850E.  */
     76  1.1.1.3  christos #define PROCESSOR_V850E1     (1 << (arch_V850E1))   /* Just the V850E1.  */
     77  1.1.1.3  christos #define PROCESSOR_V850E2     (1 << (arch_V850E2))   /* Just the V850E2.  */
     78  1.1.1.3  christos #define PROCESSOR_V850E2V3   (1 << (arch_V850E2V3)) /* Just the V850E2V3.  */
     79  1.1.1.3  christos #define PROCESSOR_V850E3V5   (1 << (arch_V850E3V5)) /* Just the V850E3V5.  */
     80  1.1.1.3  christos 
     81  1.1.1.3  christos /* UPPERS */
     82  1.1.1.3  christos #define PROCESSOR_V850E3V5_UP (PROCESSOR_V850E3V5)
     83  1.1.1.3  christos #define PROCESSOR_V850E2V3_UP (PROCESSOR_V850E2V3 | PROCESSOR_V850E3V5_UP)
     84  1.1.1.3  christos #define PROCESSOR_V850E2_UP   (PROCESSOR_V850E2   | PROCESSOR_V850E2V3_UP)
     85  1.1.1.3  christos #define PROCESSOR_V850E_UP    (PROCESSOR_V850E    | PROCESSOR_V850E1 | PROCESSOR_V850E2_UP)
     86  1.1.1.3  christos #define PROCESSOR_ALL         (PROCESSOR_V850     | PROCESSOR_V850E_UP)
     87  1.1.1.3  christos 
     88  1.1.1.3  christos #define PROCESSOR_MASK        (PROCESSOR_ALL)
     89  1.1.1.3  christos #define PROCESSOR_NOT_V850    (PROCESSOR_ALL & (~ PROCESSOR_V850))         /* Any processor except the V850.  */
     90  1.1.1.3  christos 
     91  1.1.1.3  christos #define PROCESSOR_UNKNOWN    ~(PROCESSOR_MASK)
     92  1.1.1.3  christos 
     93  1.1.1.3  christos /* OPTIONS */
     94  1.1.1.3  christos #define PROCESSOR_OPTION_EXTENSION (1 << (opt_EXTENSION))                  /* Enable extension opcodes.  */
     95  1.1.1.3  christos #define PROCESSOR_OPTION_ALIAS     (1 << (opt_ALIAS))                      /* Enable alias opcodes.  */
     96  1.1.1.3  christos 
     97  1.1.1.2  christos #define SET_PROCESSOR_MASK(mask,set)	((mask) = ((mask) & ~PROCESSOR_MASK) | (set))
     98      1.1     skrll 
     99      1.1     skrll /* The table itself is sorted by major opcode number, and is otherwise
    100      1.1     skrll    in the order in which the disassembler should consider
    101      1.1     skrll    instructions.  */
    102      1.1     skrll extern const struct v850_opcode v850_opcodes[];
    103      1.1     skrll extern const int v850_num_opcodes;
    104      1.1     skrll 
    105      1.1     skrll 
    106      1.1     skrll /* The operands table is an array of struct v850_operand.  */
    108      1.1     skrll 
    109      1.1     skrll struct v850_operand
    110      1.1     skrll {
    111  1.1.1.2  christos   /* The number of bits in the operand.  */
    112  1.1.1.2  christos   /* If this value is -1 then the operand's bits are in a discontinous
    113      1.1     skrll      distribution in the instruction. */
    114      1.1     skrll   int bits;
    115      1.1     skrll 
    116      1.1     skrll   /* (bits >= 0):  How far the operand is left shifted in the instruction.  */
    117      1.1     skrll   /* (bits == -1): Bit mask of the bits in the operand.  */
    118      1.1     skrll   int shift;
    119      1.1     skrll 
    120      1.1     skrll   /* Insertion function.  This is used by the assembler.  To insert an
    121      1.1     skrll      operand value into an instruction, check this field.
    122      1.1     skrll 
    123      1.1     skrll      If it is NULL, execute
    124      1.1     skrll          i |= (op & ((1 << o->bits) - 1)) << o->shift;
    125      1.1     skrll      (i is the instruction which we are filling in, o is a pointer to
    126      1.1     skrll      this structure, and op is the opcode value; this assumes twos
    127      1.1     skrll      complement arithmetic).
    128      1.1     skrll 
    129      1.1     skrll      If this field is not NULL, then simply call it with the
    130      1.1     skrll      instruction and the operand value.  It will return the new value
    131      1.1     skrll      of the instruction.  If the ERRMSG argument is not NULL, then if
    132      1.1     skrll      the operand value is illegal, *ERRMSG will be set to a warning
    133      1.1     skrll      string (the operand will be inserted in any case).  If the
    134      1.1     skrll      operand value is legal, *ERRMSG will be unchanged (most operands
    135      1.1     skrll      can accept any value).  */
    136      1.1     skrll   unsigned long (* insert)
    137      1.1     skrll     (unsigned long instruction, long op, const char ** errmsg);
    138      1.1     skrll 
    139      1.1     skrll   /* Extraction function.  This is used by the disassembler.  To
    140      1.1     skrll      extract this operand type from an instruction, check this field.
    141      1.1     skrll 
    142      1.1     skrll      If it is NULL, compute
    143      1.1     skrll          op = o->bits == -1 ? ((i) & o->shift) : ((i) >> o->shift) & ((1 << o->bits) - 1);
    144      1.1     skrll 	 if (o->flags & V850_OPERAND_SIGNED)
    145      1.1     skrll 	     op = (op << (32 - o->bits)) >> (32 - o->bits);
    146      1.1     skrll      (i is the instruction, o is a pointer to this structure, and op
    147      1.1     skrll      is the result; this assumes twos complement arithmetic).
    148      1.1     skrll 
    149      1.1     skrll      If this field is not NULL, then simply call it with the
    150      1.1     skrll      instruction value.  It will return the value of the operand.  If
    151      1.1     skrll      the INVALID argument is not NULL, *INVALID will be set to
    152      1.1     skrll      non-zero if this operand type can not actually be extracted from
    153      1.1     skrll      this operand (i.e., the instruction does not match).  If the
    154      1.1     skrll      operand is valid, *INVALID will not be changed.  */
    155      1.1     skrll   unsigned long (* extract) (unsigned long instruction, int * invalid);
    156      1.1     skrll 
    157      1.1     skrll   /* One bit syntax flags.  */
    158  1.1.1.2  christos   int flags;
    159  1.1.1.2  christos 
    160      1.1     skrll   int default_reloc;
    161      1.1     skrll };
    162      1.1     skrll 
    163      1.1     skrll /* Elements in the table are retrieved by indexing with values from
    164      1.1     skrll    the operands field of the v850_opcodes table.  */
    165      1.1     skrll 
    166      1.1     skrll extern const struct v850_operand v850_operands[];
    167      1.1     skrll 
    168      1.1     skrll /* Values defined for the flags field of a struct v850_operand.  */
    169  1.1.1.2  christos 
    170      1.1     skrll /* This operand names a general purpose register.  */
    171      1.1     skrll #define V850_OPERAND_REG	0x01
    172  1.1.1.2  christos 
    173  1.1.1.2  christos /* This operand is the ep register.  */
    174      1.1     skrll #define V850_OPERAND_EP		0x02
    175  1.1.1.2  christos 
    176  1.1.1.2  christos /* This operand names a system register.  */
    177      1.1     skrll #define V850_OPERAND_SRG	0x04
    178  1.1.1.2  christos 
    179  1.1.1.2  christos /* Prologue eilogue type instruction, V850E specific.  */
    180      1.1     skrll #define V850E_OPERAND_REG_LIST	0x08
    181  1.1.1.2  christos 
    182  1.1.1.2  christos /* This operand names a condition code used in the setf instruction.  */
    183      1.1     skrll #define V850_OPERAND_CC		0x10
    184  1.1.1.2  christos 
    185      1.1     skrll #define V850_OPERAND_FLOAT_CC	0x20
    186  1.1.1.2  christos 
    187  1.1.1.2  christos /* This operand names a vector purpose register.  */
    188      1.1     skrll #define V850_OPERAND_VREG	0x40
    189  1.1.1.2  christos 
    190  1.1.1.2  christos /* 16 bit immediate follows instruction, V850E specific.  */
    191      1.1     skrll #define V850E_IMMEDIATE16	0x80
    192  1.1.1.2  christos 
    193  1.1.1.2  christos /* hi16 bit immediate follows instruction, V850E specific.  */
    194      1.1     skrll #define V850E_IMMEDIATE16HI	0x100
    195  1.1.1.2  christos 
    196  1.1.1.2  christos /* 23 bit immediate follows instruction, V850E specific.  */
    197      1.1     skrll #define V850E_IMMEDIATE23	0x200
    198      1.1     skrll 
    199      1.1     skrll /* 32 bit immediate follows instruction, V850E specific.  */
    200      1.1     skrll #define V850E_IMMEDIATE32	0x400
    201  1.1.1.2  christos 
    202  1.1.1.2  christos /* This is a relaxable operand.   Only used for D9->D22 branch relaxing
    203  1.1.1.2  christos    right now.  We may need others in the future (or maybe handle them like
    204  1.1.1.2  christos    promoted operands on the mn10300?).  */
    205  1.1.1.2  christos #define V850_OPERAND_RELAX	0x800
    206  1.1.1.2  christos 
    207  1.1.1.2  christos /* This operand takes signed values.  */
    208  1.1.1.2  christos #define V850_OPERAND_SIGNED	0x1000
    209  1.1.1.2  christos 
    210  1.1.1.2  christos /* This operand is a displacement.  */
    211  1.1.1.2  christos #define V850_OPERAND_DISP	0x2000
    212  1.1.1.2  christos 
    213  1.1.1.2  christos /* This operand is a PC displacement.  */
    214  1.1.1.2  christos #define V850_PCREL		0x4000
    215  1.1.1.2  christos 
    216  1.1.1.2  christos /* The register specified must be even number.  */
    217  1.1.1.2  christos #define V850_REG_EVEN		0x8000
    218  1.1.1.2  christos 
    219  1.1.1.2  christos /* The register specified must not be r0.  */
    220  1.1.1.2  christos #define V850_NOT_R0	        0x20000
    221  1.1.1.2  christos 
    222  1.1.1.2  christos /* The register specified must not be 0.  */
    223  1.1.1.2  christos #define V850_NOT_IMM0	        0x40000
    224  1.1.1.2  christos 
    225  1.1.1.2  christos /* The condition code must not be SA CONDITION.  */
    226  1.1.1.2  christos #define V850_NOT_SA		0x80000
    227  1.1.1.2  christos 
    228  1.1.1.2  christos /* The operand has '!' prefix.  */
    229  1.1.1.2  christos #define V850_OPERAND_BANG	0x100000
    230  1.1.1.2  christos 
    231  1.1.1.2  christos /* The operand has '%' prefix.  */
    232  1.1.1.2  christos #define V850_OPERAND_PERCENT	0x200000
    233  1.1.1.5  christos 
    234  1.1.1.3  christos /* This operand is a cache operation.  */
    235  1.1.1.3  christos #define V850_OPERAND_CACHEOP	0x400000
    236  1.1.1.5  christos 
    237  1.1.1.3  christos /* This operand is a prefetch operation.  */
    238  1.1.1.3  christos #define V850_OPERAND_PREFOP	0x800000
    239  1.1.1.3  christos 
    240  1.1.1.3  christos /* A PC-relative displacement where a positive value indicates a backwards displacement.  */
    241  1.1.1.3  christos #define V850_INVERSE_PCREL	0x1000000
    242  1.1.1.3  christos 
    243  1.1.1.2  christos extern int v850_msg_is_out_of_range (const char *);
    244  1.1.1.4  christos 
    245  1.1.1.4  christos #ifdef __cplusplus
    246  1.1.1.4  christos }
    247  1.1.1.4  christos #endif
    248      1.1     skrll 
    249                    #endif /* V850_H */
    250