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