1 /* CPU family header for m32rbf.
3 THIS FILE IS MACHINE GENERATED WITH CGEN.
5 Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
7 This file is part of the GNU simulators.
9 This program 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 2, or (at your option)
14 This program is distributed in the hope that it will be useful,
15 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.
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 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 /* Maximum number of instructions that are fetched at a time.
29 This is for LIW type instructions sets (e.g. m32r). */
30 #define MAX_LIW_INSNS 2
32 /* Maximum number of instructions that can be executed in parallel. */
33 #define MAX_PARALLEL_INSNS 1
35 /* CPU state information. */
37 /* Hardware elements. */
41 #define GET_H_PC() CPU (h_pc)
42 #define SET_H_PC(x) (CPU (h_pc) = (x))
43 /* general registers */
45 #define GET_H_GR(a1) CPU (h_gr)[a1]
46 #define SET_H_GR(a1, x) (CPU (h_gr)[a1] = (x))
47 /* control registers */
49 #define GET_H_CR(index) m32rbf_h_cr_get_handler (current_cpu, index)
50 #define SET_H_CR(index, x) \
52 m32rbf_h_cr_set_handler (current_cpu, (index), (x));\
56 #define GET_H_ACCUM() m32rbf_h_accum_get_handler (current_cpu)
57 #define SET_H_ACCUM(x) \
59 m32rbf_h_accum_set_handler (current_cpu, (x));\
63 #define GET_H_COND() CPU (h_cond)
64 #define SET_H_COND(x) (CPU (h_cond) = (x))
67 #define GET_H_PSW() m32rbf_h_psw_get_handler (current_cpu)
68 #define SET_H_PSW(x) \
70 m32rbf_h_psw_set_handler (current_cpu, (x));\
74 #define GET_H_BPSW() CPU (h_bpsw)
75 #define SET_H_BPSW(x) (CPU (h_bpsw) = (x))
78 #define GET_H_BBPSW() CPU (h_bbpsw)
79 #define SET_H_BBPSW(x) (CPU (h_bbpsw) = (x))
82 #define GET_H_LOCK() CPU (h_lock)
83 #define SET_H_LOCK(x) (CPU (h_lock) = (x))
85 #define CPU_CGEN_HW(cpu) (& (cpu)->cpu_data.hardware)
88 /* Cover fns for register access. */
89 USI m32rbf_h_pc_get (SIM_CPU *);
90 void m32rbf_h_pc_set (SIM_CPU *, USI);
91 SI m32rbf_h_gr_get (SIM_CPU *, UINT);
92 void m32rbf_h_gr_set (SIM_CPU *, UINT, SI);
93 USI m32rbf_h_cr_get (SIM_CPU *, UINT);
94 void m32rbf_h_cr_set (SIM_CPU *, UINT, USI);
95 DI m32rbf_h_accum_get (SIM_CPU *);
96 void m32rbf_h_accum_set (SIM_CPU *, DI);
97 BI m32rbf_h_cond_get (SIM_CPU *);
98 void m32rbf_h_cond_set (SIM_CPU *, BI);
99 UQI m32rbf_h_psw_get (SIM_CPU *);
100 void m32rbf_h_psw_set (SIM_CPU *, UQI);
101 UQI m32rbf_h_bpsw_get (SIM_CPU *);
102 void m32rbf_h_bpsw_set (SIM_CPU *, UQI);
103 UQI m32rbf_h_bbpsw_get (SIM_CPU *);
104 void m32rbf_h_bbpsw_set (SIM_CPU *, UQI);
105 BI m32rbf_h_lock_get (SIM_CPU *);
106 void m32rbf_h_lock_set (SIM_CPU *, BI);
108 /* These must be hand-written. */
109 extern CPUREG_FETCH_FN m32rbf_fetch_register;
110 extern CPUREG_STORE_FN m32rbf_store_register;
120 /* Instruction argument buffer. */
123 struct { /* no operands */
134 unsigned char out_h_gr_SI_14;
138 unsigned char out_h_gr_SI_14;
144 unsigned char out_dr;
150 unsigned char out_dr;
156 unsigned char out_h_gr_SI_14;
170 unsigned char out_dr;
177 unsigned char out_dr;
184 unsigned char in_src1;
185 unsigned char in_src2;
186 unsigned char out_src2;
194 unsigned char in_src1;
195 unsigned char in_src2;
203 unsigned char out_dr;
204 unsigned char out_sr;
212 unsigned char in_src1;
213 unsigned char in_src2;
222 unsigned char out_dr;
231 unsigned char out_dr;
240 unsigned char out_dr;
243 /* Writeback handler. */
245 /* Pointer to argbuf entry for insn whose results need writing back. */
246 const struct argbuf *abuf;
248 /* x-before handler */
250 /*const SCACHE *insns[MAX_PARALLEL_INSNS];*/
253 /* x-after handler */
257 /* This entry is used to terminate each pbb. */
259 /* Number of insns in pbb. */
261 /* Next pbb to execute. */
263 SCACHE *branch_target;
268 /* The ARGBUF struct. */
270 /* These are the baseclass definitions. */
275 /* ??? Temporary hack for skip insns. */
278 /* cpu specific data follows */
281 union sem_fields fields;
286 ??? SCACHE used to contain more than just argbuf. We could delete the
287 type entirely and always just use ARGBUF, but for future concerns and as
288 a level of abstraction it is left in. */
291 struct argbuf argbuf;
294 /* Macros to simplify extraction, reading and semantic code.
295 These define and assign the local vars that contain the insn's fields. */
297 #define EXTRACT_IFMT_EMPTY_VARS \
299 #define EXTRACT_IFMT_EMPTY_CODE \
302 #define EXTRACT_IFMT_ADD_VARS \
308 #define EXTRACT_IFMT_ADD_CODE \
310 f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \
311 f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \
312 f_op2 = EXTRACT_MSB0_UINT (insn, 16, 8, 4); \
313 f_r2 = EXTRACT_MSB0_UINT (insn, 16, 12, 4); \
315 #define EXTRACT_IFMT_ADD3_VARS \
322 #define EXTRACT_IFMT_ADD3_CODE \
324 f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \
325 f_r1 = EXTRACT_MSB0_UINT (insn, 32, 4, 4); \
326 f_op2 = EXTRACT_MSB0_UINT (insn, 32, 8, 4); \
327 f_r2 = EXTRACT_MSB0_UINT (insn, 32, 12, 4); \
328 f_simm16 = EXTRACT_MSB0_INT (insn, 32, 16, 16); \
330 #define EXTRACT_IFMT_AND3_VARS \
337 #define EXTRACT_IFMT_AND3_CODE \
339 f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \
340 f_r1 = EXTRACT_MSB0_UINT (insn, 32, 4, 4); \
341 f_op2 = EXTRACT_MSB0_UINT (insn, 32, 8, 4); \
342 f_r2 = EXTRACT_MSB0_UINT (insn, 32, 12, 4); \
343 f_uimm16 = EXTRACT_MSB0_UINT (insn, 32, 16, 16); \
345 #define EXTRACT_IFMT_OR3_VARS \
352 #define EXTRACT_IFMT_OR3_CODE \
354 f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \
355 f_r1 = EXTRACT_MSB0_UINT (insn, 32, 4, 4); \
356 f_op2 = EXTRACT_MSB0_UINT (insn, 32, 8, 4); \
357 f_r2 = EXTRACT_MSB0_UINT (insn, 32, 12, 4); \
358 f_uimm16 = EXTRACT_MSB0_UINT (insn, 32, 16, 16); \
360 #define EXTRACT_IFMT_ADDI_VARS \
365 #define EXTRACT_IFMT_ADDI_CODE \
367 f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \
368 f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \
369 f_simm8 = EXTRACT_MSB0_INT (insn, 16, 8, 8); \
371 #define EXTRACT_IFMT_ADDV3_VARS \
378 #define EXTRACT_IFMT_ADDV3_CODE \
380 f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \
381 f_r1 = EXTRACT_MSB0_UINT (insn, 32, 4, 4); \
382 f_op2 = EXTRACT_MSB0_UINT (insn, 32, 8, 4); \
383 f_r2 = EXTRACT_MSB0_UINT (insn, 32, 12, 4); \
384 f_simm16 = EXTRACT_MSB0_INT (insn, 32, 16, 16); \
386 #define EXTRACT_IFMT_BC8_VARS \
391 #define EXTRACT_IFMT_BC8_CODE \
393 f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \
394 f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \
395 f_disp8 = ((((EXTRACT_MSB0_INT (insn, 16, 8, 8)) << (2))) + (((pc) & (-4)))); \
397 #define EXTRACT_IFMT_BC24_VARS \
402 #define EXTRACT_IFMT_BC24_CODE \
404 f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \
405 f_r1 = EXTRACT_MSB0_UINT (insn, 32, 4, 4); \
406 f_disp24 = ((((EXTRACT_MSB0_INT (insn, 32, 8, 24)) << (2))) + (pc)); \
408 #define EXTRACT_IFMT_BEQ_VARS \
415 #define EXTRACT_IFMT_BEQ_CODE \
417 f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \
418 f_r1 = EXTRACT_MSB0_UINT (insn, 32, 4, 4); \
419 f_op2 = EXTRACT_MSB0_UINT (insn, 32, 8, 4); \
420 f_r2 = EXTRACT_MSB0_UINT (insn, 32, 12, 4); \
421 f_disp16 = ((((EXTRACT_MSB0_INT (insn, 32, 16, 16)) << (2))) + (pc)); \
423 #define EXTRACT_IFMT_BEQZ_VARS \
430 #define EXTRACT_IFMT_BEQZ_CODE \
432 f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \
433 f_r1 = EXTRACT_MSB0_UINT (insn, 32, 4, 4); \
434 f_op2 = EXTRACT_MSB0_UINT (insn, 32, 8, 4); \
435 f_r2 = EXTRACT_MSB0_UINT (insn, 32, 12, 4); \
436 f_disp16 = ((((EXTRACT_MSB0_INT (insn, 32, 16, 16)) << (2))) + (pc)); \
438 #define EXTRACT_IFMT_CMP_VARS \
444 #define EXTRACT_IFMT_CMP_CODE \
446 f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \
447 f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \
448 f_op2 = EXTRACT_MSB0_UINT (insn, 16, 8, 4); \
449 f_r2 = EXTRACT_MSB0_UINT (insn, 16, 12, 4); \
451 #define EXTRACT_IFMT_CMPI_VARS \
458 #define EXTRACT_IFMT_CMPI_CODE \
460 f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \
461 f_r1 = EXTRACT_MSB0_UINT (insn, 32, 4, 4); \
462 f_op2 = EXTRACT_MSB0_UINT (insn, 32, 8, 4); \
463 f_r2 = EXTRACT_MSB0_UINT (insn, 32, 12, 4); \
464 f_simm16 = EXTRACT_MSB0_INT (insn, 32, 16, 16); \
466 #define EXTRACT_IFMT_DIV_VARS \
473 #define EXTRACT_IFMT_DIV_CODE \
475 f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \
476 f_r1 = EXTRACT_MSB0_UINT (insn, 32, 4, 4); \
477 f_op2 = EXTRACT_MSB0_UINT (insn, 32, 8, 4); \
478 f_r2 = EXTRACT_MSB0_UINT (insn, 32, 12, 4); \
479 f_simm16 = EXTRACT_MSB0_INT (insn, 32, 16, 16); \
481 #define EXTRACT_IFMT_JL_VARS \
487 #define EXTRACT_IFMT_JL_CODE \
489 f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \
490 f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \
491 f_op2 = EXTRACT_MSB0_UINT (insn, 16, 8, 4); \
492 f_r2 = EXTRACT_MSB0_UINT (insn, 16, 12, 4); \
494 #define EXTRACT_IFMT_LD24_VARS \
499 #define EXTRACT_IFMT_LD24_CODE \
501 f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \
502 f_r1 = EXTRACT_MSB0_UINT (insn, 32, 4, 4); \
503 f_uimm24 = EXTRACT_MSB0_UINT (insn, 32, 8, 24); \
505 #define EXTRACT_IFMT_LDI16_VARS \
512 #define EXTRACT_IFMT_LDI16_CODE \
514 f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \
515 f_r1 = EXTRACT_MSB0_UINT (insn, 32, 4, 4); \
516 f_op2 = EXTRACT_MSB0_UINT (insn, 32, 8, 4); \
517 f_r2 = EXTRACT_MSB0_UINT (insn, 32, 12, 4); \
518 f_simm16 = EXTRACT_MSB0_INT (insn, 32, 16, 16); \
520 #define EXTRACT_IFMT_MVFACHI_VARS \
526 #define EXTRACT_IFMT_MVFACHI_CODE \
528 f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \
529 f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \
530 f_op2 = EXTRACT_MSB0_UINT (insn, 16, 8, 4); \
531 f_r2 = EXTRACT_MSB0_UINT (insn, 16, 12, 4); \
533 #define EXTRACT_IFMT_MVFC_VARS \
539 #define EXTRACT_IFMT_MVFC_CODE \
541 f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \
542 f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \
543 f_op2 = EXTRACT_MSB0_UINT (insn, 16, 8, 4); \
544 f_r2 = EXTRACT_MSB0_UINT (insn, 16, 12, 4); \
546 #define EXTRACT_IFMT_MVTACHI_VARS \
552 #define EXTRACT_IFMT_MVTACHI_CODE \
554 f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \
555 f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \
556 f_op2 = EXTRACT_MSB0_UINT (insn, 16, 8, 4); \
557 f_r2 = EXTRACT_MSB0_UINT (insn, 16, 12, 4); \
559 #define EXTRACT_IFMT_MVTC_VARS \
565 #define EXTRACT_IFMT_MVTC_CODE \
567 f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \
568 f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \
569 f_op2 = EXTRACT_MSB0_UINT (insn, 16, 8, 4); \
570 f_r2 = EXTRACT_MSB0_UINT (insn, 16, 12, 4); \
572 #define EXTRACT_IFMT_NOP_VARS \
578 #define EXTRACT_IFMT_NOP_CODE \
580 f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \
581 f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \
582 f_op2 = EXTRACT_MSB0_UINT (insn, 16, 8, 4); \
583 f_r2 = EXTRACT_MSB0_UINT (insn, 16, 12, 4); \
585 #define EXTRACT_IFMT_SETH_VARS \
592 #define EXTRACT_IFMT_SETH_CODE \
594 f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \
595 f_r1 = EXTRACT_MSB0_UINT (insn, 32, 4, 4); \
596 f_op2 = EXTRACT_MSB0_UINT (insn, 32, 8, 4); \
597 f_r2 = EXTRACT_MSB0_UINT (insn, 32, 12, 4); \
598 f_hi16 = EXTRACT_MSB0_UINT (insn, 32, 16, 16); \
600 #define EXTRACT_IFMT_SLLI_VARS \
606 #define EXTRACT_IFMT_SLLI_CODE \
608 f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \
609 f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \
610 f_shift_op2 = EXTRACT_MSB0_UINT (insn, 16, 8, 3); \
611 f_uimm5 = EXTRACT_MSB0_UINT (insn, 16, 11, 5); \
613 #define EXTRACT_IFMT_ST_D_VARS \
620 #define EXTRACT_IFMT_ST_D_CODE \
622 f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \
623 f_r1 = EXTRACT_MSB0_UINT (insn, 32, 4, 4); \
624 f_op2 = EXTRACT_MSB0_UINT (insn, 32, 8, 4); \
625 f_r2 = EXTRACT_MSB0_UINT (insn, 32, 12, 4); \
626 f_simm16 = EXTRACT_MSB0_INT (insn, 32, 16, 16); \
628 #define EXTRACT_IFMT_TRAP_VARS \
634 #define EXTRACT_IFMT_TRAP_CODE \
636 f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \
637 f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \
638 f_op2 = EXTRACT_MSB0_UINT (insn, 16, 8, 4); \
639 f_uimm4 = EXTRACT_MSB0_UINT (insn, 16, 12, 4); \
641 #define EXTRACT_IFMT_CLRPSW_VARS \
646 #define EXTRACT_IFMT_CLRPSW_CODE \
648 f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \
649 f_r1 = EXTRACT_MSB0_UINT (insn, 16, 4, 4); \
650 f_uimm8 = EXTRACT_MSB0_UINT (insn, 16, 8, 8); \
652 #define EXTRACT_IFMT_BSET_VARS \
660 #define EXTRACT_IFMT_BSET_CODE \
662 f_op1 = EXTRACT_MSB0_UINT (insn, 32, 0, 4); \
663 f_bit4 = EXTRACT_MSB0_UINT (insn, 32, 4, 1); \
664 f_uimm3 = EXTRACT_MSB0_UINT (insn, 32, 5, 3); \
665 f_op2 = EXTRACT_MSB0_UINT (insn, 32, 8, 4); \
666 f_r2 = EXTRACT_MSB0_UINT (insn, 32, 12, 4); \
667 f_simm16 = EXTRACT_MSB0_INT (insn, 32, 16, 16); \
669 #define EXTRACT_IFMT_BTST_VARS \
676 #define EXTRACT_IFMT_BTST_CODE \
678 f_op1 = EXTRACT_MSB0_UINT (insn, 16, 0, 4); \
679 f_bit4 = EXTRACT_MSB0_UINT (insn, 16, 4, 1); \
680 f_uimm3 = EXTRACT_MSB0_UINT (insn, 16, 5, 3); \
681 f_op2 = EXTRACT_MSB0_UINT (insn, 16, 8, 4); \
682 f_r2 = EXTRACT_MSB0_UINT (insn, 16, 12, 4); \
684 /* Collection of various things for the trace handler to use. */
686 typedef struct trace_record {
691 #endif /* CPU_M32RBF_H */