daily update
[binutils.git] / opcodes / openrisc-opc.c
blobe6b75a378654fa452464752490ec64a747e8863b
1 /* Instruction opcode table for openrisc.
3 THIS FILE IS MACHINE GENERATED WITH CGEN.
5 Copyright 1996-2010 Free Software Foundation, Inc.
7 This file is part of the GNU Binutils and/or GDB, the GNU debugger.
9 This file is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3, or (at your option)
12 any later version.
14 It is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
17 License for more details.
19 You should have received a copy of the GNU General Public License along
20 with this program; if not, write to the Free Software Foundation, Inc.,
21 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
25 #include "sysdep.h"
26 #include "ansidecl.h"
27 #include "bfd.h"
28 #include "symcat.h"
29 #include "openrisc-desc.h"
30 #include "openrisc-opc.h"
31 #include "libiberty.h"
33 /* -- opc.c */
34 /* -- */
35 /* The hash functions are recorded here to help keep assembler code out of
36 the disassembler and vice versa. */
38 static int asm_hash_insn_p (const CGEN_INSN *);
39 static unsigned int asm_hash_insn (const char *);
40 static int dis_hash_insn_p (const CGEN_INSN *);
41 static unsigned int dis_hash_insn (const char *, CGEN_INSN_INT);
43 /* Instruction formats. */
45 #define F(f) & openrisc_cgen_ifld_table[OPENRISC_##f]
46 static const CGEN_IFMT ifmt_empty ATTRIBUTE_UNUSED = {
47 0, 0, 0x0, { { 0 } }
50 static const CGEN_IFMT ifmt_l_j ATTRIBUTE_UNUSED = {
51 32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_ABS26) }, { 0 } }
54 static const CGEN_IFMT ifmt_l_jr ATTRIBUTE_UNUSED = {
55 32, 32, 0xffe00000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_OP3) }, { F (F_OP4) }, { F (F_R2) }, { F (F_UIMM16) }, { 0 } }
58 static const CGEN_IFMT ifmt_l_bal ATTRIBUTE_UNUSED = {
59 32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_DISP26) }, { 0 } }
62 static const CGEN_IFMT ifmt_l_movhi ATTRIBUTE_UNUSED = {
63 32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_SIMM16) }, { 0 } }
66 static const CGEN_IFMT ifmt_l_mfsr ATTRIBUTE_UNUSED = {
67 32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_UIMM16) }, { 0 } }
70 static const CGEN_IFMT ifmt_l_mtsr ATTRIBUTE_UNUSED = {
71 32, 32, 0xfc0007ff, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_R3) }, { F (F_I16_1) }, { 0 } }
74 static const CGEN_IFMT ifmt_l_lw ATTRIBUTE_UNUSED = {
75 32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_SIMM16) }, { 0 } }
78 static const CGEN_IFMT ifmt_l_sw ATTRIBUTE_UNUSED = {
79 32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R3) }, { F (F_I16NC) }, { 0 } }
82 static const CGEN_IFMT ifmt_l_sll ATTRIBUTE_UNUSED = {
83 32, 32, 0xfc0007ff, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_R3) }, { F (F_F_10_3) }, { F (F_OP6) }, { F (F_F_4_1) }, { F (F_OP7) }, { 0 } }
86 static const CGEN_IFMT ifmt_l_slli ATTRIBUTE_UNUSED = {
87 32, 32, 0xfc00ffe0, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_F_15_8) }, { F (F_OP6) }, { F (F_UIMM5) }, { 0 } }
90 static const CGEN_IFMT ifmt_l_add ATTRIBUTE_UNUSED = {
91 32, 32, 0xfc0007ff, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_R3) }, { F (F_F_10_7) }, { F (F_OP7) }, { 0 } }
94 static const CGEN_IFMT ifmt_l_addi ATTRIBUTE_UNUSED = {
95 32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_LO16) }, { 0 } }
98 static const CGEN_IFMT ifmt_l_sfgts ATTRIBUTE_UNUSED = {
99 32, 32, 0xffe007ff, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_OP5) }, { F (F_R2) }, { F (F_R3) }, { F (F_F_10_11) }, { 0 } }
102 static const CGEN_IFMT ifmt_l_sfgtsi ATTRIBUTE_UNUSED = {
103 32, 32, 0xffe00000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_OP5) }, { F (F_R2) }, { F (F_SIMM16) }, { 0 } }
106 static const CGEN_IFMT ifmt_l_sfgtui ATTRIBUTE_UNUSED = {
107 32, 32, 0xffe00000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_OP5) }, { F (F_R2) }, { F (F_UIMM16) }, { 0 } }
110 #undef F
112 #define A(a) (1 << CGEN_INSN_##a)
113 #define OPERAND(op) OPENRISC_OPERAND_##op
114 #define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */
115 #define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
117 /* The instruction table. */
119 static const CGEN_OPCODE openrisc_cgen_insn_opcode_table[MAX_INSNS] =
121 /* Special null first entry.
122 A `num' value of zero is thus invalid.
123 Also, the special `invalid' insn resides here. */
124 { { 0, 0, 0, 0 }, {{0}}, 0, {0}},
125 /* l.j ${abs-26} */
127 { 0, 0, 0, 0 },
128 { { MNEM, ' ', OP (ABS_26), 0 } },
129 & ifmt_l_j, { 0x0 }
131 /* l.jal ${abs-26} */
133 { 0, 0, 0, 0 },
134 { { MNEM, ' ', OP (ABS_26), 0 } },
135 & ifmt_l_j, { 0x4000000 }
137 /* l.jr $rA */
139 { 0, 0, 0, 0 },
140 { { MNEM, ' ', OP (RA), 0 } },
141 & ifmt_l_jr, { 0x14000000 }
143 /* l.jalr $rA */
145 { 0, 0, 0, 0 },
146 { { MNEM, ' ', OP (RA), 0 } },
147 & ifmt_l_jr, { 0x14200000 }
149 /* l.bal ${disp-26} */
151 { 0, 0, 0, 0 },
152 { { MNEM, ' ', OP (DISP_26), 0 } },
153 & ifmt_l_bal, { 0x8000000 }
155 /* l.bnf ${disp-26} */
157 { 0, 0, 0, 0 },
158 { { MNEM, ' ', OP (DISP_26), 0 } },
159 & ifmt_l_bal, { 0xc000000 }
161 /* l.bf ${disp-26} */
163 { 0, 0, 0, 0 },
164 { { MNEM, ' ', OP (DISP_26), 0 } },
165 & ifmt_l_bal, { 0x10000000 }
167 /* l.brk ${uimm-16} */
169 { 0, 0, 0, 0 },
170 { { MNEM, ' ', OP (UIMM_16), 0 } },
171 & ifmt_l_jr, { 0x17000000 }
173 /* l.rfe $rA */
175 { 0, 0, 0, 0 },
176 { { MNEM, ' ', OP (RA), 0 } },
177 & ifmt_l_jr, { 0x14400000 }
179 /* l.sys ${uimm-16} */
181 { 0, 0, 0, 0 },
182 { { MNEM, ' ', OP (UIMM_16), 0 } },
183 & ifmt_l_jr, { 0x16000000 }
185 /* l.nop */
187 { 0, 0, 0, 0 },
188 { { MNEM, 0 } },
189 & ifmt_l_jr, { 0x15000000 }
191 /* l.movhi $rD,$hi16 */
193 { 0, 0, 0, 0 },
194 { { MNEM, ' ', OP (RD), ',', OP (HI16), 0 } },
195 & ifmt_l_movhi, { 0x18000000 }
197 /* l.mfsr $rD,$rA */
199 { 0, 0, 0, 0 },
200 { { MNEM, ' ', OP (RD), ',', OP (RA), 0 } },
201 & ifmt_l_mfsr, { 0x1c000000 }
203 /* l.mtsr $rA,$rB */
205 { 0, 0, 0, 0 },
206 { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
207 & ifmt_l_mtsr, { 0x40000000 }
209 /* l.lw $rD,${simm-16}($rA) */
211 { 0, 0, 0, 0 },
212 { { MNEM, ' ', OP (RD), ',', OP (SIMM_16), '(', OP (RA), ')', 0 } },
213 & ifmt_l_lw, { 0x80000000 }
215 /* l.lbz $rD,${simm-16}($rA) */
217 { 0, 0, 0, 0 },
218 { { MNEM, ' ', OP (RD), ',', OP (SIMM_16), '(', OP (RA), ')', 0 } },
219 & ifmt_l_lw, { 0x84000000 }
221 /* l.lbs $rD,${simm-16}($rA) */
223 { 0, 0, 0, 0 },
224 { { MNEM, ' ', OP (RD), ',', OP (SIMM_16), '(', OP (RA), ')', 0 } },
225 & ifmt_l_lw, { 0x88000000 }
227 /* l.lhz $rD,${simm-16}($rA) */
229 { 0, 0, 0, 0 },
230 { { MNEM, ' ', OP (RD), ',', OP (SIMM_16), '(', OP (RA), ')', 0 } },
231 & ifmt_l_lw, { 0x8c000000 }
233 /* l.lhs $rD,${simm-16}($rA) */
235 { 0, 0, 0, 0 },
236 { { MNEM, ' ', OP (RD), ',', OP (SIMM_16), '(', OP (RA), ')', 0 } },
237 & ifmt_l_lw, { 0x90000000 }
239 /* l.sw ${ui16nc}($rA),$rB */
241 { 0, 0, 0, 0 },
242 { { MNEM, ' ', OP (UI16NC), '(', OP (RA), ')', ',', OP (RB), 0 } },
243 & ifmt_l_sw, { 0xd4000000 }
245 /* l.sb ${ui16nc}($rA),$rB */
247 { 0, 0, 0, 0 },
248 { { MNEM, ' ', OP (UI16NC), '(', OP (RA), ')', ',', OP (RB), 0 } },
249 & ifmt_l_sw, { 0xd8000000 }
251 /* l.sh ${ui16nc}($rA),$rB */
253 { 0, 0, 0, 0 },
254 { { MNEM, ' ', OP (UI16NC), '(', OP (RA), ')', ',', OP (RB), 0 } },
255 & ifmt_l_sw, { 0xdc000000 }
257 /* l.sll $rD,$rA,$rB */
259 { 0, 0, 0, 0 },
260 { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
261 & ifmt_l_sll, { 0xe0000008 }
263 /* l.slli $rD,$rA,${uimm-5} */
265 { 0, 0, 0, 0 },
266 { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (UIMM_5), 0 } },
267 & ifmt_l_slli, { 0xb4000000 }
269 /* l.srl $rD,$rA,$rB */
271 { 0, 0, 0, 0 },
272 { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
273 & ifmt_l_sll, { 0xe0000028 }
275 /* l.srli $rD,$rA,${uimm-5} */
277 { 0, 0, 0, 0 },
278 { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (UIMM_5), 0 } },
279 & ifmt_l_slli, { 0xb4000020 }
281 /* l.sra $rD,$rA,$rB */
283 { 0, 0, 0, 0 },
284 { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
285 & ifmt_l_sll, { 0xe0000048 }
287 /* l.srai $rD,$rA,${uimm-5} */
289 { 0, 0, 0, 0 },
290 { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (UIMM_5), 0 } },
291 & ifmt_l_slli, { 0xb4000040 }
293 /* l.ror $rD,$rA,$rB */
295 { 0, 0, 0, 0 },
296 { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
297 & ifmt_l_sll, { 0xe0000088 }
299 /* l.rori $rD,$rA,${uimm-5} */
301 { 0, 0, 0, 0 },
302 { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (UIMM_5), 0 } },
303 & ifmt_l_slli, { 0xb4000080 }
305 /* l.add $rD,$rA,$rB */
307 { 0, 0, 0, 0 },
308 { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
309 & ifmt_l_add, { 0xe0000000 }
311 /* l.addi $rD,$rA,$lo16 */
313 { 0, 0, 0, 0 },
314 { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } },
315 & ifmt_l_addi, { 0x94000000 }
317 /* l.sub $rD,$rA,$rB */
319 { 0, 0, 0, 0 },
320 { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
321 & ifmt_l_add, { 0xe0000002 }
323 /* l.subi $rD,$rA,$lo16 */
325 { 0, 0, 0, 0 },
326 { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } },
327 & ifmt_l_addi, { 0x9c000000 }
329 /* l.and $rD,$rA,$rB */
331 { 0, 0, 0, 0 },
332 { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
333 & ifmt_l_add, { 0xe0000003 }
335 /* l.andi $rD,$rA,$lo16 */
337 { 0, 0, 0, 0 },
338 { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } },
339 & ifmt_l_addi, { 0xa0000000 }
341 /* l.or $rD,$rA,$rB */
343 { 0, 0, 0, 0 },
344 { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
345 & ifmt_l_add, { 0xe0000004 }
347 /* l.ori $rD,$rA,$lo16 */
349 { 0, 0, 0, 0 },
350 { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } },
351 & ifmt_l_addi, { 0xa4000000 }
353 /* l.xor $rD,$rA,$rB */
355 { 0, 0, 0, 0 },
356 { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
357 & ifmt_l_add, { 0xe0000005 }
359 /* l.xori $rD,$rA,$lo16 */
361 { 0, 0, 0, 0 },
362 { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } },
363 & ifmt_l_addi, { 0xa8000000 }
365 /* l.mul $rD,$rA,$rB */
367 { 0, 0, 0, 0 },
368 { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
369 & ifmt_l_add, { 0xe0000006 }
371 /* l.muli $rD,$rA,$lo16 */
373 { 0, 0, 0, 0 },
374 { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } },
375 & ifmt_l_addi, { 0xac000000 }
377 /* l.div $rD,$rA,$rB */
379 { 0, 0, 0, 0 },
380 { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
381 & ifmt_l_add, { 0xe0000009 }
383 /* l.divu $rD,$rA,$rB */
385 { 0, 0, 0, 0 },
386 { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
387 & ifmt_l_add, { 0xe000000a }
389 /* l.sfgts $rA,$rB */
391 { 0, 0, 0, 0 },
392 { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
393 & ifmt_l_sfgts, { 0xe4c00000 }
395 /* l.sfgtu $rA,$rB */
397 { 0, 0, 0, 0 },
398 { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
399 & ifmt_l_sfgts, { 0xe4400000 }
401 /* l.sfges $rA,$rB */
403 { 0, 0, 0, 0 },
404 { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
405 & ifmt_l_sfgts, { 0xe4e00000 }
407 /* l.sfgeu $rA,$rB */
409 { 0, 0, 0, 0 },
410 { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
411 & ifmt_l_sfgts, { 0xe4600000 }
413 /* l.sflts $rA,$rB */
415 { 0, 0, 0, 0 },
416 { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
417 & ifmt_l_sfgts, { 0xe5000000 }
419 /* l.sfltu $rA,$rB */
421 { 0, 0, 0, 0 },
422 { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
423 & ifmt_l_sfgts, { 0xe4800000 }
425 /* l.sfles $rA,$rB */
427 { 0, 0, 0, 0 },
428 { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
429 & ifmt_l_sfgts, { 0xe5200000 }
431 /* l.sfleu $rA,$rB */
433 { 0, 0, 0, 0 },
434 { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
435 & ifmt_l_sfgts, { 0xe4a00000 }
437 /* l.sfgtsi $rA,${simm-16} */
439 { 0, 0, 0, 0 },
440 { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } },
441 & ifmt_l_sfgtsi, { 0xb8c00000 }
443 /* l.sfgtui $rA,${uimm-16} */
445 { 0, 0, 0, 0 },
446 { { MNEM, ' ', OP (RA), ',', OP (UIMM_16), 0 } },
447 & ifmt_l_sfgtui, { 0xb8400000 }
449 /* l.sfgesi $rA,${simm-16} */
451 { 0, 0, 0, 0 },
452 { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } },
453 & ifmt_l_sfgtsi, { 0xb8e00000 }
455 /* l.sfgeui $rA,${uimm-16} */
457 { 0, 0, 0, 0 },
458 { { MNEM, ' ', OP (RA), ',', OP (UIMM_16), 0 } },
459 & ifmt_l_sfgtui, { 0xb8600000 }
461 /* l.sfltsi $rA,${simm-16} */
463 { 0, 0, 0, 0 },
464 { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } },
465 & ifmt_l_sfgtsi, { 0xb9000000 }
467 /* l.sfltui $rA,${uimm-16} */
469 { 0, 0, 0, 0 },
470 { { MNEM, ' ', OP (RA), ',', OP (UIMM_16), 0 } },
471 & ifmt_l_sfgtui, { 0xb8800000 }
473 /* l.sflesi $rA,${simm-16} */
475 { 0, 0, 0, 0 },
476 { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } },
477 & ifmt_l_sfgtsi, { 0xb9200000 }
479 /* l.sfleui $rA,${uimm-16} */
481 { 0, 0, 0, 0 },
482 { { MNEM, ' ', OP (RA), ',', OP (UIMM_16), 0 } },
483 & ifmt_l_sfgtui, { 0xb8a00000 }
485 /* l.sfeq $rA,$rB */
487 { 0, 0, 0, 0 },
488 { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
489 & ifmt_l_sfgts, { 0xe4000000 }
491 /* l.sfeqi $rA,${simm-16} */
493 { 0, 0, 0, 0 },
494 { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } },
495 & ifmt_l_sfgtsi, { 0xb8000000 }
497 /* l.sfne $rA,$rB */
499 { 0, 0, 0, 0 },
500 { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
501 & ifmt_l_sfgts, { 0xe4200000 }
503 /* l.sfnei $rA,${simm-16} */
505 { 0, 0, 0, 0 },
506 { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } },
507 & ifmt_l_sfgtsi, { 0xb8200000 }
511 #undef A
512 #undef OPERAND
513 #undef MNEM
514 #undef OP
516 /* Formats for ALIAS macro-insns. */
518 #define F(f) & openrisc_cgen_ifld_table[OPENRISC_##f]
519 static const CGEN_IFMT ifmt_l_ret ATTRIBUTE_UNUSED = {
520 32, 32, 0xffffffff, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_OP3) }, { F (F_OP4) }, { F (F_R2) }, { F (F_UIMM16) }, { 0 } }
523 #undef F
525 /* Each non-simple macro entry points to an array of expansion possibilities. */
527 #define A(a) (1 << CGEN_INSN_##a)
528 #define OPERAND(op) OPENRISC_OPERAND_##op
529 #define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */
530 #define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
532 /* The macro instruction table. */
534 static const CGEN_IBASE openrisc_cgen_macro_insn_table[] =
536 /* l.ret */
538 -1, "l-ret", "l.ret", 32,
539 { 0|A(ALIAS), { { { (1<<MACH_BASE), 0 } } } }
543 /* The macro instruction opcode table. */
545 static const CGEN_OPCODE openrisc_cgen_macro_insn_opcode_table[] =
547 /* l.ret */
549 { 0, 0, 0, 0 },
550 { { MNEM, 0 } },
551 & ifmt_l_ret, { 0x140b0000 }
555 #undef A
556 #undef OPERAND
557 #undef MNEM
558 #undef OP
560 #ifndef CGEN_ASM_HASH_P
561 #define CGEN_ASM_HASH_P(insn) 1
562 #endif
564 #ifndef CGEN_DIS_HASH_P
565 #define CGEN_DIS_HASH_P(insn) 1
566 #endif
568 /* Return non-zero if INSN is to be added to the hash table.
569 Targets are free to override CGEN_{ASM,DIS}_HASH_P in the .opc file. */
571 static int
572 asm_hash_insn_p (insn)
573 const CGEN_INSN *insn ATTRIBUTE_UNUSED;
575 return CGEN_ASM_HASH_P (insn);
578 static int
579 dis_hash_insn_p (insn)
580 const CGEN_INSN *insn;
582 /* If building the hash table and the NO-DIS attribute is present,
583 ignore. */
584 if (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_NO_DIS))
585 return 0;
586 return CGEN_DIS_HASH_P (insn);
589 #ifndef CGEN_ASM_HASH
590 #define CGEN_ASM_HASH_SIZE 127
591 #ifdef CGEN_MNEMONIC_OPERANDS
592 #define CGEN_ASM_HASH(mnem) (*(unsigned char *) (mnem) % CGEN_ASM_HASH_SIZE)
593 #else
594 #define CGEN_ASM_HASH(mnem) (*(unsigned char *) (mnem) % CGEN_ASM_HASH_SIZE) /*FIXME*/
595 #endif
596 #endif
598 /* It doesn't make much sense to provide a default here,
599 but while this is under development we do.
600 BUFFER is a pointer to the bytes of the insn, target order.
601 VALUE is the first base_insn_bitsize bits as an int in host order. */
603 #ifndef CGEN_DIS_HASH
604 #define CGEN_DIS_HASH_SIZE 256
605 #define CGEN_DIS_HASH(buf, value) (*(unsigned char *) (buf))
606 #endif
608 /* The result is the hash value of the insn.
609 Targets are free to override CGEN_{ASM,DIS}_HASH in the .opc file. */
611 static unsigned int
612 asm_hash_insn (mnem)
613 const char * mnem;
615 return CGEN_ASM_HASH (mnem);
618 /* BUF is a pointer to the bytes of the insn, target order.
619 VALUE is the first base_insn_bitsize bits as an int in host order. */
621 static unsigned int
622 dis_hash_insn (buf, value)
623 const char * buf ATTRIBUTE_UNUSED;
624 CGEN_INSN_INT value ATTRIBUTE_UNUSED;
626 return CGEN_DIS_HASH (buf, value);
629 /* Set the recorded length of the insn in the CGEN_FIELDS struct. */
631 static void
632 set_fields_bitsize (CGEN_FIELDS *fields, int size)
634 CGEN_FIELDS_BITSIZE (fields) = size;
637 /* Function to call before using the operand instance table.
638 This plugs the opcode entries and macro instructions into the cpu table. */
640 void
641 openrisc_cgen_init_opcode_table (CGEN_CPU_DESC cd)
643 int i;
644 int num_macros = (sizeof (openrisc_cgen_macro_insn_table) /
645 sizeof (openrisc_cgen_macro_insn_table[0]));
646 const CGEN_IBASE *ib = & openrisc_cgen_macro_insn_table[0];
647 const CGEN_OPCODE *oc = & openrisc_cgen_macro_insn_opcode_table[0];
648 CGEN_INSN *insns = xmalloc (num_macros * sizeof (CGEN_INSN));
650 /* This test has been added to avoid a warning generated
651 if memset is called with a third argument of value zero. */
652 if (num_macros >= 1)
653 memset (insns, 0, num_macros * sizeof (CGEN_INSN));
654 for (i = 0; i < num_macros; ++i)
656 insns[i].base = &ib[i];
657 insns[i].opcode = &oc[i];
658 openrisc_cgen_build_insn_regex (& insns[i]);
660 cd->macro_insn_table.init_entries = insns;
661 cd->macro_insn_table.entry_size = sizeof (CGEN_IBASE);
662 cd->macro_insn_table.num_init_entries = num_macros;
664 oc = & openrisc_cgen_insn_opcode_table[0];
665 insns = (CGEN_INSN *) cd->insn_table.init_entries;
666 for (i = 0; i < MAX_INSNS; ++i)
668 insns[i].opcode = &oc[i];
669 openrisc_cgen_build_insn_regex (& insns[i]);
672 cd->sizeof_fields = sizeof (CGEN_FIELDS);
673 cd->set_fields_bitsize = set_fields_bitsize;
675 cd->asm_hash_p = asm_hash_insn_p;
676 cd->asm_hash = asm_hash_insn;
677 cd->asm_hash_size = CGEN_ASM_HASH_SIZE;
679 cd->dis_hash_p = dis_hash_insn_p;
680 cd->dis_hash = dis_hash_insn;
681 cd->dis_hash_size = CGEN_DIS_HASH_SIZE;