xref: /openbsd-src/gnu/usr.bin/binutils/include/opcode/d10v.h (revision cf2f2c5620d6d9a4fd01930983c4b9a1f76d7aa3)
1fddef416Sniklas /* d10v.h -- Header file for D10V opcode table
2*cf2f2c56Smiod    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2003
3*cf2f2c56Smiod    Free Software Foundation, Inc.
4fddef416Sniklas    Written by Martin Hunt (hunt@cygnus.com), Cygnus Support
5fddef416Sniklas 
6fddef416Sniklas This file is part of GDB, GAS, and the GNU binutils.
7fddef416Sniklas 
8fddef416Sniklas GDB, GAS, and the GNU binutils are free software; you can redistribute
9fddef416Sniklas them and/or modify them under the terms of the GNU General Public
10fddef416Sniklas License as published by the Free Software Foundation; either version
11fddef416Sniklas 1, or (at your option) any later version.
12fddef416Sniklas 
13fddef416Sniklas GDB, GAS, and the GNU binutils are distributed in the hope that they
14fddef416Sniklas will be useful, but WITHOUT ANY WARRANTY; without even the implied
15fddef416Sniklas warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
16fddef416Sniklas the GNU General Public License for more details.
17fddef416Sniklas 
18fddef416Sniklas You should have received a copy of the GNU General Public License
19fddef416Sniklas along with this file; see the file COPYING.  If not, write to the Free
20fddef416Sniklas Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
21fddef416Sniklas 
22fddef416Sniklas #ifndef D10V_H
23fddef416Sniklas #define D10V_H
24fddef416Sniklas 
25fddef416Sniklas /* Format Specifier */
26fddef416Sniklas #define FM00	0
27fddef416Sniklas #define FM01	0x40000000
28fddef416Sniklas #define FM10	0x80000000
29fddef416Sniklas #define FM11	0xC0000000
30fddef416Sniklas 
31fddef416Sniklas #define NOP 0x5e00
32fddef416Sniklas #define OPCODE_DIVS	0x14002800
33fddef416Sniklas 
34fddef416Sniklas /* The opcode table is an array of struct d10v_opcode.  */
35fddef416Sniklas 
36fddef416Sniklas struct d10v_opcode
37fddef416Sniklas {
38fddef416Sniklas   /* The opcode name.  */
39fddef416Sniklas   const char *name;
40fddef416Sniklas 
41fddef416Sniklas   /* the opcode format */
42fddef416Sniklas   int format;
43fddef416Sniklas 
44fddef416Sniklas   /* These numbers were picked so we can do if( i & SHORT_OPCODE) */
45fddef416Sniklas #define SHORT_OPCODE 1
46fddef416Sniklas #define LONG_OPCODE  8
47fddef416Sniklas #define SHORT_2	     1		/* short with 2 operands */
48fddef416Sniklas #define SHORT_B	     3		/* short with 8-bit branch */
49fddef416Sniklas #define LONG_B	     8		/* long with 16-bit branch */
50fddef416Sniklas #define LONG_L       10		/* long with 3 operands */
51fddef416Sniklas #define LONG_R       12		/* reserved */
52fddef416Sniklas 
53fddef416Sniklas   /* just a placeholder for variable-length instructions */
54fddef416Sniklas   /* for example, "bra" will be a fake for "bra.s" and bra.l" */
55fddef416Sniklas   /* which will immediately follow in the opcode table.  */
56fddef416Sniklas #define OPCODE_FAKE  32
57fddef416Sniklas 
58fddef416Sniklas   /* the number of cycles */
59fddef416Sniklas   int cycles;
60fddef416Sniklas 
61fddef416Sniklas   /* the execution unit(s) used */
62fddef416Sniklas   int unit;
63fddef416Sniklas #define EITHER	0
64fddef416Sniklas #define IU	1
65fddef416Sniklas #define MU	2
66fddef416Sniklas #define BOTH	3
67fddef416Sniklas 
68fddef416Sniklas   /* execution type; parallel or sequential */
69fddef416Sniklas   /* this field is used to decide if two instructions */
70fddef416Sniklas   /* can be executed in parallel */
71fddef416Sniklas   int exec_type;
72fddef416Sniklas #define PARONLY 1	/* parallel only */
73fddef416Sniklas #define SEQ	2	/* must be sequential */
74fddef416Sniklas #define PAR	4	/* may be parallel */
75fddef416Sniklas #define BRANCH_LINK 8	/* subroutine call.  must be aligned */
76fddef416Sniklas #define RMEM     16	/* reads memory */
77fddef416Sniklas #define WMEM     32	/* writes memory */
78fddef416Sniklas #define RF0      64	/* reads f0 */
79fddef416Sniklas #define WF0     128	/* modifies f0 */
80fddef416Sniklas #define WCAR    256	/* write Carry */
81fddef416Sniklas #define BRANCH  512	/* branch, no link */
825f210c2aSfgsch #define ALONE  1024	/* short but pack with a NOP if on asm line alone */
83fddef416Sniklas 
84fddef416Sniklas   /* the opcode */
85fddef416Sniklas   long opcode;
86fddef416Sniklas 
87fddef416Sniklas   /* mask.  if( (i & mask) == opcode ) then match */
88fddef416Sniklas   long mask;
89fddef416Sniklas 
90fddef416Sniklas   /* An array of operand codes.  Each code is an index into the
91fddef416Sniklas      operand table.  They appear in the order which the operands must
92fddef416Sniklas      appear in assembly code, and are terminated by a zero.  */
93fddef416Sniklas   unsigned char operands[6];
94fddef416Sniklas };
95fddef416Sniklas 
96fddef416Sniklas /* The table itself is sorted by major opcode number, and is otherwise
97fddef416Sniklas    in the order in which the disassembler should consider
98fddef416Sniklas    instructions.  */
99fddef416Sniklas extern const struct d10v_opcode d10v_opcodes[];
100fddef416Sniklas extern const int d10v_num_opcodes;
101fddef416Sniklas 
102fddef416Sniklas /* The operands table is an array of struct d10v_operand.  */
103fddef416Sniklas struct d10v_operand
104fddef416Sniklas {
105fddef416Sniklas   /* The number of bits in the operand.  */
106fddef416Sniklas   int bits;
107fddef416Sniklas 
108fddef416Sniklas   /* How far the operand is left shifted in the instruction.  */
109fddef416Sniklas   int shift;
110fddef416Sniklas 
111fddef416Sniklas   /* One bit syntax flags.  */
112fddef416Sniklas   int flags;
113fddef416Sniklas };
114fddef416Sniklas 
115fddef416Sniklas /* Elements in the table are retrieved by indexing with values from
116fddef416Sniklas    the operands field of the d10v_opcodes table.  */
117fddef416Sniklas 
118fddef416Sniklas extern const struct d10v_operand d10v_operands[];
119fddef416Sniklas 
120fddef416Sniklas /* Values defined for the flags field of a struct d10v_operand.  */
121fddef416Sniklas 
122fddef416Sniklas /* the operand must be an even number */
123fddef416Sniklas #define OPERAND_EVEN	(1)
124fddef416Sniklas 
125fddef416Sniklas /* the operand must be an odd number */
126fddef416Sniklas #define OPERAND_ODD	(2)
127fddef416Sniklas 
128fddef416Sniklas /* this is the destination register; it will be modified */
129fddef416Sniklas /* this is used by the optimizer */
130fddef416Sniklas #define OPERAND_DEST	(4)
131fddef416Sniklas 
132fddef416Sniklas /* number or symbol */
133fddef416Sniklas #define OPERAND_NUM	(8)
134fddef416Sniklas 
135fddef416Sniklas /* address or label */
136fddef416Sniklas #define OPERAND_ADDR	(0x10)
137fddef416Sniklas 
138fddef416Sniklas /* register */
139fddef416Sniklas #define OPERAND_REG	(0x20)
140fddef416Sniklas 
141fddef416Sniklas /* postincrement +  */
142fddef416Sniklas #define OPERAND_PLUS	(0x40)
143fddef416Sniklas 
144fddef416Sniklas /* postdecrement -  */
145fddef416Sniklas #define OPERAND_MINUS	(0x80)
146fddef416Sniklas 
147fddef416Sniklas /* @  */
148fddef416Sniklas #define OPERAND_ATSIGN	(0x100)
149fddef416Sniklas 
150fddef416Sniklas /* @(  */
151fddef416Sniklas #define OPERAND_ATPAR	(0x200)
152fddef416Sniklas 
153f7cc78ecSespie /* accumulator 0 */
154f7cc78ecSespie #define OPERAND_ACC0	(0x400)
155fddef416Sniklas 
156f7cc78ecSespie /* accumulator 1 */
157f7cc78ecSespie #define OPERAND_ACC1	(0x800)
158f7cc78ecSespie 
159f7cc78ecSespie /* f0 / f1 flag register */
160f7cc78ecSespie #define OPERAND_FFLAG	(0x1000)
161f7cc78ecSespie 
162f7cc78ecSespie /* c flag register */
163f7cc78ecSespie #define OPERAND_CFLAG	(0x2000)
164fddef416Sniklas 
165fddef416Sniklas /* control register  */
166f7cc78ecSespie #define OPERAND_CONTROL	(0x4000)
167fddef416Sniklas 
168fddef416Sniklas /* predecrement mode '@-sp'  */
169f7cc78ecSespie #define OPERAND_ATMINUS	(0x8000)
170fddef416Sniklas 
171fddef416Sniklas /* signed number */
172f7cc78ecSespie #define OPERAND_SIGNED	(0x10000)
173fddef416Sniklas 
174fddef416Sniklas /* special accumulator shifts need a 4-bit number */
175fddef416Sniklas /* 1 <= x <= 16 */
176f7cc78ecSespie #define OPERAND_SHIFT	(0x20000)
177f7cc78ecSespie 
178f7cc78ecSespie /* general purpose register */
179f7cc78ecSespie #define OPERAND_GPR	(0x40000)
180f7cc78ecSespie 
181f7cc78ecSespie /* special imm3 values with range restricted to -2 <= imm3 <= 3 */
182f7cc78ecSespie /* needed for rac/rachi */
183f7cc78ecSespie #define RESTRICTED_NUM3	(0x80000)
184fddef416Sniklas 
185d2201f2fSdrahn /* Pre-decrement is only supported for SP.  */
186d2201f2fSdrahn #define OPERAND_SP      (0x100000)
187d2201f2fSdrahn 
188d2201f2fSdrahn /* Post-decrement is not supported for SP.  Like OPERAND_EVEN, and
189d2201f2fSdrahn    unlike OPERAND_SP, this flag doesn't prevent the instruction from
190d2201f2fSdrahn    matching, it only fails validation later on.  */
191d2201f2fSdrahn #define OPERAND_NOSP    (0x200000)
192d2201f2fSdrahn 
193fddef416Sniklas /* Structure to hold information about predefined registers.  */
194fddef416Sniklas struct pd_reg
195fddef416Sniklas {
196fddef416Sniklas   char *name;		/* name to recognize */
197fddef416Sniklas   char *pname;		/* name to print for this register */
198fddef416Sniklas   int value;
199fddef416Sniklas };
200fddef416Sniklas 
201fddef416Sniklas extern const struct pd_reg d10v_predefined_registers[];
202*cf2f2c56Smiod int d10v_reg_name_cnt (void);
203fddef416Sniklas 
204fddef416Sniklas /* an expressionS only has one register type, so we fake it */
205fddef416Sniklas /* by setting high bits to indicate type */
206fddef416Sniklas #define REGISTER_MASK	0xFF
207fddef416Sniklas 
208fddef416Sniklas #endif /* D10V_H */
209