Statistics
| Branch: | Revision:

root / target-cris / opcode-cris.h @ 94cff60a

History | View | Annotate | Download (10.1 kB)

1 450d4ff5 ths
/* cris.h -- Header file for CRIS opcode and register tables.
2 450d4ff5 ths
   Copyright (C) 2000, 2001, 2004 Free Software Foundation, Inc.
3 450d4ff5 ths
   Contributed by Axis Communications AB, Lund, Sweden.
4 450d4ff5 ths
   Originally written for GAS 1.38.1 by Mikael Asker.
5 450d4ff5 ths
   Updated, BFDized and GNUified by Hans-Peter Nilsson.
6 450d4ff5 ths

7 450d4ff5 ths
This file is part of GAS, GDB and the GNU binutils.
8 450d4ff5 ths

9 450d4ff5 ths
GAS, GDB, and GNU binutils is free software; you can redistribute it
10 450d4ff5 ths
and/or modify it under the terms of the GNU General Public License as
11 450d4ff5 ths
published by the Free Software Foundation; either version 2, or (at your
12 450d4ff5 ths
option) any later version.
13 450d4ff5 ths

14 450d4ff5 ths
GAS, GDB, and GNU binutils are distributed in the hope that they will be
15 450d4ff5 ths
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
16 450d4ff5 ths
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 450d4ff5 ths
GNU General Public License for more details.
18 450d4ff5 ths

19 450d4ff5 ths
You should have received a copy of the GNU General Public License
20 450d4ff5 ths
along with this program; if not, write to the Free Software
21 450d4ff5 ths
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
22 450d4ff5 ths
23 450d4ff5 ths
#ifndef __CRIS_H_INCLUDED_
24 450d4ff5 ths
#define __CRIS_H_INCLUDED_
25 450d4ff5 ths
26 450d4ff5 ths
#if !defined(__STDC__) && !defined(const)
27 450d4ff5 ths
#define const
28 450d4ff5 ths
#endif
29 450d4ff5 ths
30 450d4ff5 ths
31 450d4ff5 ths
/* Registers.  */
32 450d4ff5 ths
#define MAX_REG (15)
33 450d4ff5 ths
#define REG_SP (14)
34 450d4ff5 ths
#define REG_PC (15)
35 450d4ff5 ths
36 450d4ff5 ths
/* CPU version control of disassembly and assembly of instructions.
37 450d4ff5 ths
   May affect how the instruction is assembled, at least the size of
38 450d4ff5 ths
   immediate operands.  */
39 450d4ff5 ths
enum cris_insn_version_usage
40 450d4ff5 ths
{
41 450d4ff5 ths
  /* Any version.  */
42 450d4ff5 ths
  cris_ver_version_all=0,
43 450d4ff5 ths
44 450d4ff5 ths
  /* Indeterminate (intended for disassembly only, or obsolete).  */
45 450d4ff5 ths
  cris_ver_warning,
46 450d4ff5 ths
47 450d4ff5 ths
  /* Only for v0..3 (Etrax 1..4).  */
48 450d4ff5 ths
  cris_ver_v0_3,
49 450d4ff5 ths
50 450d4ff5 ths
  /* Only for v3 or higher (ETRAX 4 and beyond).  */
51 450d4ff5 ths
  cris_ver_v3p,
52 450d4ff5 ths
53 450d4ff5 ths
  /* Only for v8 (Etrax 100).  */
54 450d4ff5 ths
  cris_ver_v8,
55 450d4ff5 ths
56 450d4ff5 ths
  /* Only for v8 or higher (ETRAX 100, ETRAX 100 LX).  */
57 450d4ff5 ths
  cris_ver_v8p,
58 450d4ff5 ths
59 450d4ff5 ths
  /* Only for v0..10.  FIXME: Not sure what to do with this.  */
60 450d4ff5 ths
  cris_ver_sim_v0_10,
61 450d4ff5 ths
62 450d4ff5 ths
  /* Only for v0..10.  */
63 450d4ff5 ths
  cris_ver_v0_10,
64 450d4ff5 ths
65 450d4ff5 ths
  /* Only for v3..10.  (ETRAX 4, ETRAX 100 and ETRAX 100 LX).  */
66 450d4ff5 ths
  cris_ver_v3_10,
67 450d4ff5 ths
68 450d4ff5 ths
  /* Only for v8..10 (ETRAX 100 and ETRAX 100 LX).  */
69 450d4ff5 ths
  cris_ver_v8_10,
70 450d4ff5 ths
71 450d4ff5 ths
  /* Only for v10 (ETRAX 100 LX) and same series.  */
72 450d4ff5 ths
  cris_ver_v10,
73 450d4ff5 ths
74 450d4ff5 ths
  /* Only for v10 (ETRAX 100 LX) and same series.  */
75 450d4ff5 ths
  cris_ver_v10p,
76 450d4ff5 ths
77 450d4ff5 ths
  /* Only for v32 or higher (codename GUINNESS).
78 450d4ff5 ths
     Of course some or all these of may change to cris_ver_v32p if/when
79 450d4ff5 ths
     there's a new revision. */
80 450d4ff5 ths
  cris_ver_v32p
81 450d4ff5 ths
};
82 450d4ff5 ths
83 450d4ff5 ths
84 450d4ff5 ths
/* Special registers.  */
85 450d4ff5 ths
struct cris_spec_reg
86 450d4ff5 ths
{
87 450d4ff5 ths
  const char *const name;
88 450d4ff5 ths
  unsigned int number;
89 450d4ff5 ths
90 450d4ff5 ths
  /* The size of the register.  */
91 450d4ff5 ths
  unsigned int reg_size;
92 450d4ff5 ths
93 450d4ff5 ths
  /* What CPU version the special register of that name is implemented
94 450d4ff5 ths
     in.  If cris_ver_warning, emit an unimplemented-warning.  */
95 450d4ff5 ths
  enum cris_insn_version_usage applicable_version;
96 450d4ff5 ths
97 450d4ff5 ths
  /* There might be a specific warning for using a special register
98 450d4ff5 ths
     here.  */
99 450d4ff5 ths
  const char *const warning;
100 450d4ff5 ths
};
101 450d4ff5 ths
extern const struct cris_spec_reg cris_spec_regs[];
102 450d4ff5 ths
103 450d4ff5 ths
104 450d4ff5 ths
/* Support registers (kind of special too, but not named as such).  */
105 450d4ff5 ths
struct cris_support_reg
106 450d4ff5 ths
{
107 450d4ff5 ths
  const char *const name;
108 450d4ff5 ths
  unsigned int number;
109 450d4ff5 ths
};
110 450d4ff5 ths
extern const struct cris_support_reg cris_support_regs[];
111 450d4ff5 ths
112 450d4ff5 ths
struct cris_cond15
113 450d4ff5 ths
{
114 450d4ff5 ths
  /* The name of the condition.  */
115 450d4ff5 ths
  const char *const name;
116 450d4ff5 ths
117 450d4ff5 ths
  /* What CPU version this condition name applies to.  */
118 450d4ff5 ths
  enum cris_insn_version_usage applicable_version;
119 450d4ff5 ths
};
120 450d4ff5 ths
extern const struct cris_cond15 cris_conds15[];
121 450d4ff5 ths
122 450d4ff5 ths
/* Opcode-dependent constants.  */
123 450d4ff5 ths
#define AUTOINCR_BIT (0x04)
124 450d4ff5 ths
125 450d4ff5 ths
/* Prefixes.  */
126 450d4ff5 ths
#define BDAP_QUICK_OPCODE (0x0100)
127 450d4ff5 ths
#define BDAP_QUICK_Z_BITS (0x0e00)
128 450d4ff5 ths
129 450d4ff5 ths
#define BIAP_OPCODE          (0x0540)
130 450d4ff5 ths
#define BIAP_Z_BITS          (0x0a80)
131 450d4ff5 ths
132 450d4ff5 ths
#define DIP_OPCODE          (0x0970)
133 450d4ff5 ths
#define DIP_Z_BITS          (0xf280)
134 450d4ff5 ths
135 450d4ff5 ths
#define BDAP_INDIR_LOW          (0x40)
136 450d4ff5 ths
#define BDAP_INDIR_LOW_Z  (0x80)
137 450d4ff5 ths
#define BDAP_INDIR_HIGH          (0x09)
138 450d4ff5 ths
#define BDAP_INDIR_HIGH_Z (0x02)
139 450d4ff5 ths
140 450d4ff5 ths
#define BDAP_INDIR_OPCODE (BDAP_INDIR_HIGH * 0x0100 + BDAP_INDIR_LOW)
141 450d4ff5 ths
#define BDAP_INDIR_Z_BITS (BDAP_INDIR_HIGH_Z * 0x100 + BDAP_INDIR_LOW_Z)
142 450d4ff5 ths
#define BDAP_PC_LOW          (BDAP_INDIR_LOW + REG_PC)
143 450d4ff5 ths
#define BDAP_INCR_HIGH          (BDAP_INDIR_HIGH + AUTOINCR_BIT)
144 450d4ff5 ths
145 450d4ff5 ths
/* No prefix must have this code for its "match" bits in the
146 450d4ff5 ths
   opcode-table.  "BCC .+2" will do nicely.  */
147 450d4ff5 ths
#define NO_CRIS_PREFIX 0
148 450d4ff5 ths
149 450d4ff5 ths
/* Definitions for condition codes.  */
150 450d4ff5 ths
#define CC_CC  0x0
151 450d4ff5 ths
#define CC_HS  0x0
152 450d4ff5 ths
#define CC_CS  0x1
153 450d4ff5 ths
#define CC_LO  0x1
154 450d4ff5 ths
#define CC_NE  0x2
155 450d4ff5 ths
#define CC_EQ  0x3
156 450d4ff5 ths
#define CC_VC  0x4
157 450d4ff5 ths
#define CC_VS  0x5
158 450d4ff5 ths
#define CC_PL  0x6
159 450d4ff5 ths
#define CC_MI  0x7
160 450d4ff5 ths
#define CC_LS  0x8
161 450d4ff5 ths
#define CC_HI  0x9
162 450d4ff5 ths
#define CC_GE  0xA
163 450d4ff5 ths
#define CC_LT  0xB
164 450d4ff5 ths
#define CC_GT  0xC
165 450d4ff5 ths
#define CC_LE  0xD
166 450d4ff5 ths
#define CC_A   0xE
167 450d4ff5 ths
#define CC_EXT 0xF
168 450d4ff5 ths
169 450d4ff5 ths
/* A table of strings "cc", "cs"... indexed with condition code
170 450d4ff5 ths
   values as above.  */
171 450d4ff5 ths
extern const char *const cris_cc_strings[];
172 450d4ff5 ths
173 450d4ff5 ths
/* Bcc quick.  */
174 450d4ff5 ths
#define BRANCH_QUICK_LOW  (0)
175 450d4ff5 ths
#define BRANCH_QUICK_HIGH (0)
176 450d4ff5 ths
#define BRANCH_QUICK_OPCODE (BRANCH_QUICK_HIGH * 0x0100 + BRANCH_QUICK_LOW)
177 450d4ff5 ths
#define BRANCH_QUICK_Z_BITS (0x0F00)
178 450d4ff5 ths
179 450d4ff5 ths
/* BA quick.  */
180 450d4ff5 ths
#define BA_QUICK_HIGH (BRANCH_QUICK_HIGH + CC_A * 0x10)
181 450d4ff5 ths
#define BA_QUICK_OPCODE (BA_QUICK_HIGH * 0x100 + BRANCH_QUICK_LOW)
182 450d4ff5 ths
183 450d4ff5 ths
/* Bcc [PC+].  */
184 450d4ff5 ths
#define BRANCH_PC_LOW         (0xFF)
185 450d4ff5 ths
#define BRANCH_INCR_HIGH (0x0D)
186 450d4ff5 ths
#define BA_PC_INCR_OPCODE \
187 450d4ff5 ths
 ((BRANCH_INCR_HIGH + CC_A * 0x10) * 0x0100 + BRANCH_PC_LOW)
188 450d4ff5 ths
189 450d4ff5 ths
/* Jump.  */
190 450d4ff5 ths
/* Note that old versions generated special register 8 (in high bits)
191 450d4ff5 ths
   and not-that-old versions recognized it as a jump-instruction.
192 450d4ff5 ths
   That opcode now belongs to JUMPU.  */
193 450d4ff5 ths
#define JUMP_INDIR_OPCODE (0x0930)
194 450d4ff5 ths
#define JUMP_INDIR_Z_BITS (0xf2c0)
195 450d4ff5 ths
#define JUMP_PC_INCR_OPCODE \
196 450d4ff5 ths
 (JUMP_INDIR_OPCODE + AUTOINCR_BIT * 0x0100 + REG_PC)
197 450d4ff5 ths
198 450d4ff5 ths
#define MOVE_M_TO_PREG_OPCODE 0x0a30
199 450d4ff5 ths
#define MOVE_M_TO_PREG_ZBITS 0x01c0
200 450d4ff5 ths
201 450d4ff5 ths
/* BDAP.D N,PC.  */
202 450d4ff5 ths
#define MOVE_PC_INCR_OPCODE_PREFIX \
203 450d4ff5 ths
 (((BDAP_INCR_HIGH | (REG_PC << 4)) << 8) | BDAP_PC_LOW | (2 << 4))
204 450d4ff5 ths
#define MOVE_PC_INCR_OPCODE_SUFFIX \
205 450d4ff5 ths
 (MOVE_M_TO_PREG_OPCODE | REG_PC | (AUTOINCR_BIT << 8))
206 450d4ff5 ths
207 450d4ff5 ths
#define JUMP_PC_INCR_OPCODE_V32 (0x0DBF)
208 450d4ff5 ths
209 450d4ff5 ths
/* BA DWORD (V32).  */
210 450d4ff5 ths
#define BA_DWORD_OPCODE (0x0EBF)
211 450d4ff5 ths
212 450d4ff5 ths
/* Nop.  */
213 450d4ff5 ths
#define NOP_OPCODE (0x050F)
214 450d4ff5 ths
#define NOP_Z_BITS (0xFFFF ^ NOP_OPCODE)
215 450d4ff5 ths
216 450d4ff5 ths
#define NOP_OPCODE_V32 (0x05B0)
217 450d4ff5 ths
#define NOP_Z_BITS_V32 (0xFFFF ^ NOP_OPCODE_V32)
218 450d4ff5 ths
219 450d4ff5 ths
/* For the compatibility mode, let's use "MOVE R0,P0".  Doesn't affect
220 450d4ff5 ths
   registers or flags.  Unfortunately shuts off interrupts for one cycle
221 450d4ff5 ths
   for < v32, but there doesn't seem to be any alternative without that
222 450d4ff5 ths
   effect.  */
223 450d4ff5 ths
#define NOP_OPCODE_COMMON (0x630)
224 450d4ff5 ths
#define NOP_OPCODE_ZBITS_COMMON (0xffff & ~NOP_OPCODE_COMMON)
225 450d4ff5 ths
226 450d4ff5 ths
/* LAPC.D  */
227 450d4ff5 ths
#define LAPC_DWORD_OPCODE (0x0D7F)
228 450d4ff5 ths
#define LAPC_DWORD_Z_BITS (0x0fff & ~LAPC_DWORD_OPCODE)
229 450d4ff5 ths
230 450d4ff5 ths
/* Structure of an opcode table entry.  */
231 450d4ff5 ths
enum cris_imm_oprnd_size_type
232 450d4ff5 ths
{
233 450d4ff5 ths
  /* No size is applicable.  */
234 450d4ff5 ths
  SIZE_NONE,
235 450d4ff5 ths
236 450d4ff5 ths
  /* Always 32 bits.  */
237 450d4ff5 ths
  SIZE_FIX_32,
238 450d4ff5 ths
239 450d4ff5 ths
  /* Indicated by size of special register.  */
240 450d4ff5 ths
  SIZE_SPEC_REG,
241 450d4ff5 ths
242 450d4ff5 ths
  /* Indicated by size field, signed.  */
243 450d4ff5 ths
  SIZE_FIELD_SIGNED,
244 450d4ff5 ths
245 450d4ff5 ths
  /* Indicated by size field, unsigned.  */
246 450d4ff5 ths
  SIZE_FIELD_UNSIGNED,
247 450d4ff5 ths
248 450d4ff5 ths
  /* Indicated by size field, no sign implied.  */
249 450d4ff5 ths
  SIZE_FIELD
250 450d4ff5 ths
};
251 450d4ff5 ths
252 450d4ff5 ths
/* For GDB.  FIXME: Is this the best way to handle opcode
253 450d4ff5 ths
   interpretation?  */
254 450d4ff5 ths
enum cris_op_type
255 450d4ff5 ths
{
256 450d4ff5 ths
  cris_not_implemented_op = 0,
257 450d4ff5 ths
  cris_abs_op,
258 450d4ff5 ths
  cris_addi_op,
259 450d4ff5 ths
  cris_asr_op,
260 450d4ff5 ths
  cris_asrq_op,
261 450d4ff5 ths
  cris_ax_ei_setf_op,
262 450d4ff5 ths
  cris_bdap_prefix,
263 450d4ff5 ths
  cris_biap_prefix,
264 450d4ff5 ths
  cris_break_op,
265 450d4ff5 ths
  cris_btst_nop_op,
266 450d4ff5 ths
  cris_clearf_di_op,
267 450d4ff5 ths
  cris_dip_prefix,
268 450d4ff5 ths
  cris_dstep_logshift_mstep_neg_not_op,
269 450d4ff5 ths
  cris_eight_bit_offset_branch_op,
270 450d4ff5 ths
  cris_move_mem_to_reg_movem_op,
271 450d4ff5 ths
  cris_move_reg_to_mem_movem_op,
272 450d4ff5 ths
  cris_move_to_preg_op,
273 450d4ff5 ths
  cris_muls_op,
274 450d4ff5 ths
  cris_mulu_op,
275 450d4ff5 ths
  cris_none_reg_mode_add_sub_cmp_and_or_move_op,
276 450d4ff5 ths
  cris_none_reg_mode_clear_test_op,
277 450d4ff5 ths
  cris_none_reg_mode_jump_op,
278 450d4ff5 ths
  cris_none_reg_mode_move_from_preg_op,
279 450d4ff5 ths
  cris_quick_mode_add_sub_op,
280 450d4ff5 ths
  cris_quick_mode_and_cmp_move_or_op,
281 450d4ff5 ths
  cris_quick_mode_bdap_prefix,
282 450d4ff5 ths
  cris_reg_mode_add_sub_cmp_and_or_move_op,
283 450d4ff5 ths
  cris_reg_mode_clear_op,
284 450d4ff5 ths
  cris_reg_mode_jump_op,
285 450d4ff5 ths
  cris_reg_mode_move_from_preg_op,
286 450d4ff5 ths
  cris_reg_mode_test_op,
287 450d4ff5 ths
  cris_scc_op,
288 450d4ff5 ths
  cris_sixteen_bit_offset_branch_op,
289 450d4ff5 ths
  cris_three_operand_add_sub_cmp_and_or_op,
290 450d4ff5 ths
  cris_three_operand_bound_op,
291 450d4ff5 ths
  cris_two_operand_bound_op,
292 450d4ff5 ths
  cris_xor_op
293 450d4ff5 ths
};
294 450d4ff5 ths
295 450d4ff5 ths
struct cris_opcode
296 450d4ff5 ths
{
297 450d4ff5 ths
  /* The name of the insn.  */
298 450d4ff5 ths
  const char *name;
299 450d4ff5 ths
300 450d4ff5 ths
  /* Bits that must be 1 for a match.  */
301 450d4ff5 ths
  unsigned int match;
302 450d4ff5 ths
303 450d4ff5 ths
  /* Bits that must be 0 for a match.  */
304 450d4ff5 ths
  unsigned int lose;
305 450d4ff5 ths
306 450d4ff5 ths
  /* See the table in "opcodes/cris-opc.c".  */
307 450d4ff5 ths
  const char *args;
308 450d4ff5 ths
309 450d4ff5 ths
  /* Nonzero if this is a delayed branch instruction.  */
310 450d4ff5 ths
  char delayed;
311 450d4ff5 ths
312 450d4ff5 ths
  /* Size of immediate operands.  */
313 450d4ff5 ths
  enum cris_imm_oprnd_size_type imm_oprnd_size;
314 450d4ff5 ths
315 450d4ff5 ths
  /* Indicates which version this insn was first implemented in.  */
316 450d4ff5 ths
  enum cris_insn_version_usage applicable_version;
317 450d4ff5 ths
318 450d4ff5 ths
  /* What kind of operation this is.  */
319 450d4ff5 ths
  enum cris_op_type op;
320 450d4ff5 ths
};
321 450d4ff5 ths
extern const struct cris_opcode cris_opcodes[];
322 450d4ff5 ths
323 450d4ff5 ths
324 450d4ff5 ths
/* These macros are for the target-specific flags in disassemble_info
325 450d4ff5 ths
   used at disassembly.  */
326 450d4ff5 ths
327 450d4ff5 ths
/* This insn accesses memory.  This flag is more trustworthy than
328 450d4ff5 ths
   checking insn_type for "dis_dref" which does not work for
329 450d4ff5 ths
   e.g. "JSR [foo]".  */
330 450d4ff5 ths
#define CRIS_DIS_FLAG_MEMREF (1 << 0)
331 450d4ff5 ths
332 450d4ff5 ths
/* The "target" field holds a register number.  */
333 450d4ff5 ths
#define CRIS_DIS_FLAG_MEM_TARGET_IS_REG (1 << 1)
334 450d4ff5 ths
335 450d4ff5 ths
/* The "target2" field holds a register number; add it to "target".  */
336 450d4ff5 ths
#define CRIS_DIS_FLAG_MEM_TARGET2_IS_REG (1 << 2)
337 450d4ff5 ths
338 450d4ff5 ths
/* Yet another add-on: the register in "target2" must be multiplied
339 450d4ff5 ths
   by 2 before adding to "target".  */
340 450d4ff5 ths
#define CRIS_DIS_FLAG_MEM_TARGET2_MULT2 (1 << 3)
341 450d4ff5 ths
342 450d4ff5 ths
/* Yet another add-on: the register in "target2" must be multiplied
343 450d4ff5 ths
   by 4 (mutually exclusive with .._MULT2).  */
344 450d4ff5 ths
#define CRIS_DIS_FLAG_MEM_TARGET2_MULT4 (1 << 4)
345 450d4ff5 ths
346 450d4ff5 ths
/* The register in "target2" is an indirect memory reference (of the
347 450d4ff5 ths
   register there), add to "target".  Assumed size is dword (mutually
348 450d4ff5 ths
   exclusive with .._MULT[24]).  */
349 450d4ff5 ths
#define CRIS_DIS_FLAG_MEM_TARGET2_MEM (1 << 5)
350 450d4ff5 ths
351 450d4ff5 ths
/* Add-on to CRIS_DIS_FLAG_MEM_TARGET2_MEM; the memory access is "byte";
352 450d4ff5 ths
   sign-extended before adding to "target".  */
353 450d4ff5 ths
#define CRIS_DIS_FLAG_MEM_TARGET2_MEM_BYTE (1 << 6)
354 450d4ff5 ths
355 450d4ff5 ths
/* Add-on to CRIS_DIS_FLAG_MEM_TARGET2_MEM; the memory access is "word";
356 450d4ff5 ths
   sign-extended before adding to "target".  */
357 450d4ff5 ths
#define CRIS_DIS_FLAG_MEM_TARGET2_MEM_WORD (1 << 7)
358 450d4ff5 ths
359 450d4ff5 ths
#endif /* __CRIS_H_INCLUDED_ */
360 450d4ff5 ths
361 450d4ff5 ths
/*
362 450d4ff5 ths
 * Local variables:
363 450d4ff5 ths
 * eval: (c-set-style "gnu")
364 450d4ff5 ths
 * indent-tabs-mode: t
365 450d4ff5 ths
 * End:
366 450d4ff5 ths
 */