Add an index operand to some of the iq2000 co-processor instructions
[deliverable/binutils-gdb.git] / include / opcode / crx.h
CommitLineData
1fe1f39c
NC
1/* crx.h -- Header file for CRX opcode and register tables.
2 Copyright 2004 Free Software Foundation, Inc.
3 Contributed by Tomer Levi, NSC, Israel.
4 Originally written for GAS 2.12 by Tomer Levi, NSC, Israel.
5 Updates, BFDizing, GNUifying and ELF support by Tomer Levi.
6
7 This file is part of GAS, GDB and the GNU binutils.
8
9 GAS, GDB, and GNU binutils is free software; you can redistribute it
10 and/or modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2, or (at your
12 option) any later version.
13
14 GAS, GDB, and GNU binutils are distributed in the hope that they will be
15 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22
23#ifndef _CRX_H_
24#define _CRX_H_
25
26/* CRX core/debug Registers :
27 The enums are used as indices to CRX registers table (crx_regtab).
28 Therefore, order MUST be preserved. */
29
30typedef enum
31 {
32 /* 32-bit general purpose registers. */
33 r0, r1, r2, r3, r4, r5, r6, r7, r8, r9,
34 r10, r11, r12, r13, r14, r15, ra, sp,
35 /* 32-bit user registers. */
36 u0, u1, u2, u3, u4, u5, u6, u7, u8, u9,
37 u10, u11, u12, u13, u14, u15, ura, usp,
38 /* hi and lo registers. */
39 hi, lo,
40 /* hi and lo user registers. */
41 uhi, ulo,
42 /* Processor Status Register. */
43 psr,
44 /* Configuration Register. */
45 cfg,
46 /* Coprocessor Configuration Register. */
47 cpcfg,
48 /* Cashe Configuration Register. */
49 ccfg,
50 /* Interrupt Base Register. */
51 intbase,
52 /* Interrupt Stack Pointer Register. */
53 isp,
54 /* Coprocessor Enable Register. */
55 cen,
56 /* Program Counter Register. */
57 pc,
58 /* Not a register. */
59 nullregister,
60 MAX_REG
61 }
62reg;
63
64/* CRX Coprocessor registers and special registers :
65 The enums are used as indices to CRX coprocessor registers table
66 (crx_copregtab). Therefore, order MUST be preserved. */
67
68typedef enum
69 {
70 /* Coprocessor registers. */
71 c0 = MAX_REG, c1, c2, c3, c4, c5, c6, c7, c8,
72 c9, c10, c11, c12, c13, c14, c15,
73 /* Coprocessor special registers. */
74 cs0, cs1 ,cs2, cs3, cs4, cs5, cs6, cs7, cs8,
75 cs9, cs10, cs11, cs12, cs13, cs14, cs15,
76 /* Not a Coprocessor register. */
77 nullcopregister,
78 MAX_COPREG
79 }
80copreg;
81
82/* CRX Register types. */
83
84typedef enum
85 {
86 CRX_PC_REGTYPE, /* pc type */
87 CRX_R_REGTYPE, /* r<N> */
88 CRX_U_REGTYPE, /* u<N> */
89 CRX_C_REGTYPE, /* c<N> */
90 CRX_CS_REGTYPE, /* cs<N> */
91 CRX_MTPR_REGTYPE, /* mtpr */
92 CRX_CFG_REGTYPE /* *hi|lo, *cfg, psr */
93 }
94reg_type;
95
96/* CRX argument types :
97 The argument types correspond to instructions operands
98
99 Argument types :
100 r - register
101 c - constant
102 d - displacement
103 ic - immediate
104 icr - index register
105 rbase - register base
106 s - star ('*')
107 copr - coprocessor register
108 copsr - coprocessor special register. */
109
110typedef enum
111 {
112 arg_r, arg_c, arg_cr, arg_dc, arg_dcr, arg_sc,
113 arg_ic, arg_icr, arg_rbase, arg_copr, arg_copsr,
114 /* Not an argument. */
115 nullargs
116 }
117argtype;
118
119/* CRX operand types :
120 The operand types correspond to instructions operands
121
122 Operand Types :
123 cst4 - 4-bit encoded constant
124 iN - N-bit immediate field
125 d, dispsN - N-bit immediate signed displacement
126 dispuN - N-bit immediate unsigned displacement
127 absN - N-bit absolute address
128 rbase - 4-bit genaral-purpose register specifier
129 regr - 4-bit genaral-purpose register specifier
130 regr8 - 8-bit register address space
131 copregr - coprocessor register
132 copsregr - coprocessor special register
133 scl2 - 2-bit scaling factor for memory index
134 ridx - register index. */
135
136typedef enum
137 {
138 dummy, cst4, disps9,
645ea12c
TL
139 /* Immediate operands. */
140 i16, i32,
141 /* Unsigned immediate operands. */
142 us3, us4, us5, us16,
143 /* Signed displacement operands. */
1fe1f39c 144 d5, d9, d17, d25, d33,
645ea12c 145 /* Absolute operands. */
1fe1f39c 146 abs16, abs32,
645ea12c 147 /* Register relative operands. */
1fe1f39c
NC
148 rbase, rbase_cst4,
149 rbase_dispu8, rbase_dispu12, rbase_dispu16, rbase_dispu28, rbase_dispu32,
645ea12c 150 /* Index operands. */
1fe1f39c 151 rbase_ridx_scl2_dispu6, rbase_ridx_scl2_dispu22,
645ea12c 152 /* Register and processor register operands. */
1fe1f39c
NC
153 regr, regr8, copregr,copregr8,copsregr,
154 /* Not an operand. */
155 nulloperand,
156 /* Maximum supported operand. */
157 MAX_OPRD
158 }
159operand_type;
160
161/* CRX instruction types. */
162
163#define ARITH_INS 1
164#define LD_STOR_INS 2
165#define BRANCH_INS 3
166#define ARITH_BYTE_INS 4
167#define CMPBR_INS 5
168#define SHIFT_INS 6
169#define BRANCH_NEQ_INS 7
170#define LD_STOR_INS_INC 8
171#define STOR_IMM_INS 9
172#define CSTBIT_INS 10
173#define SYS_INS 11
174#define JMP_INS 12
175#define MUL_INS 13
176#define DIV_INS 14
177#define COP_BRANCH_INS 15
178#define COP_REG_INS 16
48c9f030
NC
179#define COPS_REG_INS 17
180#define DCR_BRANCH_INS 18
181#define MMC_INS 19
182#define MMU_INS 20
1fe1f39c
NC
183
184/* Maximum value supported for instruction types. */
185#define CRX_INS_MAX (1 << 5)
186/* Mask to record an instruction type. */
187#define CRX_INS_MASK (CRX_INS_MAX - 1)
188/* Return instruction type, given instruction's attributes. */
189#define CRX_INS_TYPE(attr) ((attr) & CRX_INS_MASK)
190
191/* Indicates whether this instruction has a register list as parameter. */
192#define REG_LIST CRX_INS_MAX
193/* The operands in binary and assembly are placed in reverse order.
194 load - (REVERSE_MATCH)/store - (! REVERSE_MATCH). */
195#define REVERSE_MATCH (REG_LIST << 1)
196
197/* Kind of displacement map used DISPU[BWD]4. */
198#define DISPUB4 (REVERSE_MATCH << 1)
199#define DISPUW4 (DISPUB4 << 1)
200#define DISPUD4 (DISPUW4 << 1)
201#define CST4MAP (DISPUB4 | DISPUW4 | DISPUD4)
202
203/* Printing formats, where the instruction prefix isn't consecutive. */
204#define FMT_1 (DISPUD4 << 1) /* 0xF0F00000 */
205#define FMT_2 (FMT_1 << 1) /* 0xFFF0FF00 */
206#define FMT_3 (FMT_2 << 1) /* 0xFFF00F00 */
207#define FMT_4 (FMT_3 << 1) /* 0xFFF0F000 */
208#define FMT_5 (FMT_4 << 1) /* 0xFFF0FFF0 */
209#define FMT_CRX (FMT_1 | FMT_2 | FMT_3 | FMT_4 | FMT_5)
210
211#define RELAXABLE (FMT_5 << 1)
212
213/* Maximum operands per instruction. */
214#define MAX_OPERANDS 5
215/* Maximum words per instruction. */
216#define MAX_WORDS 3
217/* Maximum register name length. */
218#define MAX_REGNAME_LEN 10
219/* Maximum instruction length. */
220#define MAX_INST_LEN 256
221
222/* Single operand description. */
223
224typedef struct
225 {
226 /* Operand type. */
227 operand_type op_type;
228 /* Operand location within the opcode. */
229 unsigned int shift;
230 }
231operand_desc;
232
233/* Instruction data structure used in instruction table. */
234
235typedef struct
236 {
237 /* Name. */
238 const char *mnemonic;
239 /* Size (in words). */
240 unsigned int size;
241 /* Constant prefix (matched by the disassembler). */
242 unsigned long match;
243 /* Match size (in bits). */
244 int match_bits;
245 /* Attributes. */
246 unsigned int flags;
247 /* Operands (always last, so unreferenced operands are initialized). */
248 operand_desc operands[MAX_OPERANDS];
249 }
250inst;
251
252/* Data structure for a single instruction's arguments (Operands). */
253
254typedef struct
255 {
256 /* Register or base register. */
257 reg r;
258 /* Index register. */
259 reg i_r;
260 /* Coprocessor register. */
261 copreg cr;
262 /* Constant/immediate/absolute value. */
263 unsigned long int constant;
264 /* Scaled index mode. */
265 unsigned int scale;
266 /* Argument type. */
267 argtype type;
268 /* Size of the argument (in bits) required to represent. */
269 int size;
270 /* Indicates whether a constant is positive or negative. */
271 int signflag;
272 }
273argument;
274
275/* Internal structure to hold the various entities
276 corresponding to the current assembling instruction. */
277
278typedef struct
279 {
280 /* Number of arguments. */
281 int nargs;
282 /* The argument data structure for storing args (operands). */
283 argument arg[MAX_OPERANDS];
284/* The following fields are required only by CRX-assembler. */
285#ifdef TC_CRX
286 /* Expression used for setting the fixups (if any). */
287 expressionS exp;
288 bfd_reloc_code_real_type rtype;
289#endif /* TC_CRX */
290 /* Instruction size (in bytes). */
291 int size;
292 }
293ins;
294
295/* Structure to hold information about predefined operands. */
296
297typedef struct
298 {
299 /* Size (in bits). */
300 unsigned int bit_size;
301 /* Argument type. */
302 argtype arg_type;
303 }
304operand_entry;
305
306/* Structure to hold trap handler information. */
307
308typedef struct
309 {
310 /* Trap name. */
311 char *name;
312 /* Index in dispatch table. */
313 unsigned int entry;
314 }
315trap_entry;
316
317/* Structure to hold information about predefined registers. */
318
319typedef struct
320 {
321 /* Name (string representation). */
322 char *name;
323 /* Value (enum representation). */
324 union
325 {
326 /* Register. */
327 reg reg_val;
328 /* Coprocessor register. */
329 copreg copreg_val;
330 } value;
331 /* Register image. */
332 int image;
333 /* Register type. */
334 reg_type type;
335 }
336reg_entry;
337
338/* Structure to hold a cst4 operand mapping. */
339
340typedef struct
341 {
342 /* The binary value which is written to the object file. */
343 int binary;
344 /* The value which is mapped. */
345 int value;
346 }
347cst4_entry;
348
349/* CRX opcode table. */
350extern const inst crx_instruction[];
351extern const int crx_num_opcodes;
352#define NUMOPCODES crx_num_opcodes
353
354/* CRX operands table. */
355extern const operand_entry crx_optab[];
356
357/* CRX registers table. */
358extern const reg_entry crx_regtab[];
359extern const int crx_num_regs;
360#define NUMREGS crx_num_regs
361
362/* CRX coprocessor registers table. */
363extern const reg_entry crx_copregtab[];
364extern const int crx_num_copregs;
365#define NUMCOPREGS crx_num_copregs
366
367/* CRX trap/interrupt table. */
368extern const trap_entry crx_traps[];
369extern const int crx_num_traps;
370#define NUMTRAPS crx_num_traps
371
372/* cst4 operand mapping. */
373extern const cst4_entry cst4_map[];
374extern const int cst4_maps;
375
376/* Current instruction we're assembling. */
377extern const inst *instruction;
378
379/* A macro for representing the instruction "constant" opcode, that is,
380 the FIXED part of the instruction. The "constant" opcode is represented
381 as a 32-bit unsigned long, where OPC is expanded (by a left SHIFT)
382 over that range. */
383#define BIN(OPC,SHIFT) (OPC << SHIFT)
384
385/* Is the current instruction type is TYPE ? */
386#define IS_INSN_TYPE(TYPE) \
387 (CRX_INS_TYPE(instruction->flags) == TYPE)
388
389/* Is the current instruction mnemonic is MNEMONIC ? */
390#define IS_INSN_MNEMONIC(MNEMONIC) \
391 (strcmp(instruction->mnemonic,MNEMONIC) == 0)
392
393/* Does the current instruction has register list ? */
394#define INST_HAS_REG_LIST \
395 (instruction->flags & REG_LIST)
396
397/* Long long type handling. */
398/* Replace all appearances of 'long long int' with LONGLONG. */
399typedef long long int LONGLONG;
400typedef unsigned long long ULONGLONG;
1fe1f39c
NC
401
402#endif /* _CRX_H_ */
This page took 0.049316 seconds and 4 git commands to generate.