1 /* Instruction building/extraction support for mt. -*- C -*-
3 THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator.
4 - the resultant file is machine generated, cgen-ibld.in isn't
6 Copyright (C) 1996-2016 Free Software Foundation, Inc.
8 This file is part of libopcodes.
10 This library is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3, or (at your option)
15 It is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
18 License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software Foundation, Inc.,
22 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
24 /* ??? Eventually more and more of this stuff can go to cpu-independent files.
35 #include "cgen/basic-modes.h"
37 #include "safe-ctype.h"
40 #define min(a,b) ((a) < (b) ? (a) : (b))
42 #define max(a,b) ((a) > (b) ? (a) : (b))
44 /* Used by the ifield rtx function. */
45 #define FLD(f) (fields->f)
47 static const char * insert_normal
48 (CGEN_CPU_DESC
, long, unsigned int, unsigned int, unsigned int,
49 unsigned int, unsigned int, unsigned int, CGEN_INSN_BYTES_PTR
);
50 static const char * insert_insn_normal
51 (CGEN_CPU_DESC
, const CGEN_INSN
*,
52 CGEN_FIELDS
*, CGEN_INSN_BYTES_PTR
, bfd_vma
);
53 static int extract_normal
54 (CGEN_CPU_DESC
, CGEN_EXTRACT_INFO
*, CGEN_INSN_INT
,
55 unsigned int, unsigned int, unsigned int, unsigned int,
56 unsigned int, unsigned int, bfd_vma
, long *);
57 static int extract_insn_normal
58 (CGEN_CPU_DESC
, const CGEN_INSN
*, CGEN_EXTRACT_INFO
*,
59 CGEN_INSN_INT
, CGEN_FIELDS
*, bfd_vma
);
61 static void put_insn_int_value
62 (CGEN_CPU_DESC
, CGEN_INSN_BYTES_PTR
, int, int, CGEN_INSN_INT
);
65 static CGEN_INLINE
void insert_1
66 (CGEN_CPU_DESC
, unsigned long, int, int, int, unsigned char *);
67 static CGEN_INLINE
int fill_cache
68 (CGEN_CPU_DESC
, CGEN_EXTRACT_INFO
*, int, int, bfd_vma
);
69 static CGEN_INLINE
long extract_1
70 (CGEN_CPU_DESC
, CGEN_EXTRACT_INFO
*, int, int, int, unsigned char *, bfd_vma
);
73 /* Operand insertion. */
77 /* Subroutine of insert_normal. */
79 static CGEN_INLINE
void
80 insert_1 (CGEN_CPU_DESC cd
,
90 x
= cgen_get_insn_value (cd
, bufp
, word_length
);
92 /* Written this way to avoid undefined behaviour. */
93 mask
= (((1L << (length
- 1)) - 1) << 1) | 1;
95 shift
= (start
+ 1) - length
;
97 shift
= (word_length
- (start
+ length
));
98 x
= (x
& ~(mask
<< shift
)) | ((value
& mask
) << shift
);
100 cgen_put_insn_value (cd
, bufp
, word_length
, (bfd_vma
) x
);
103 #endif /* ! CGEN_INT_INSN_P */
105 /* Default insertion routine.
107 ATTRS is a mask of the boolean attributes.
108 WORD_OFFSET is the offset in bits from the start of the insn of the value.
109 WORD_LENGTH is the length of the word in bits in which the value resides.
110 START is the starting bit number in the word, architecture origin.
111 LENGTH is the length of VALUE in bits.
112 TOTAL_LENGTH is the total length of the insn in bits.
114 The result is an error message or NULL if success. */
116 /* ??? This duplicates functionality with bfd's howto table and
117 bfd_install_relocation. */
118 /* ??? This doesn't handle bfd_vma's. Create another function when
122 insert_normal (CGEN_CPU_DESC cd
,
125 unsigned int word_offset
,
128 unsigned int word_length
,
129 unsigned int total_length
,
130 CGEN_INSN_BYTES_PTR buffer
)
132 static char errbuf
[100];
133 /* Written this way to avoid undefined behaviour. */
134 unsigned long mask
= (((1L << (length
- 1)) - 1) << 1) | 1;
136 /* If LENGTH is zero, this operand doesn't contribute to the value. */
140 if (word_length
> 8 * sizeof (CGEN_INSN_INT
))
143 /* For architectures with insns smaller than the base-insn-bitsize,
144 word_length may be too big. */
145 if (cd
->min_insn_bitsize
< cd
->base_insn_bitsize
)
148 && word_length
> total_length
)
149 word_length
= total_length
;
152 /* Ensure VALUE will fit. */
153 if (CGEN_BOOL_ATTR (attrs
, CGEN_IFLD_SIGN_OPT
))
155 long minval
= - (1L << (length
- 1));
156 unsigned long maxval
= mask
;
158 if ((value
> 0 && (unsigned long) value
> maxval
)
161 /* xgettext:c-format */
163 _("operand out of range (%ld not between %ld and %lu)"),
164 value
, minval
, maxval
);
168 else if (! CGEN_BOOL_ATTR (attrs
, CGEN_IFLD_SIGNED
))
170 unsigned long maxval
= mask
;
171 unsigned long val
= (unsigned long) value
;
173 /* For hosts with a word size > 32 check to see if value has been sign
174 extended beyond 32 bits. If so then ignore these higher sign bits
175 as the user is attempting to store a 32-bit signed value into an
176 unsigned 32-bit field which is allowed. */
177 if (sizeof (unsigned long) > 4 && ((value
>> 32) == -1))
182 /* xgettext:c-format */
184 _("operand out of range (0x%lx not between 0 and 0x%lx)"),
191 if (! cgen_signed_overflow_ok_p (cd
))
193 long minval
= - (1L << (length
- 1));
194 long maxval
= (1L << (length
- 1)) - 1;
196 if (value
< minval
|| value
> maxval
)
199 /* xgettext:c-format */
200 (errbuf
, _("operand out of range (%ld not between %ld and %ld)"),
201 value
, minval
, maxval
);
212 if (CGEN_INSN_LSB0_P
)
213 shift
= (word_offset
+ start
+ 1) - length
;
215 shift
= total_length
- (word_offset
+ start
+ length
);
216 *buffer
= (*buffer
& ~(mask
<< shift
)) | ((value
& mask
) << shift
);
219 #else /* ! CGEN_INT_INSN_P */
222 unsigned char *bufp
= (unsigned char *) buffer
+ word_offset
/ 8;
224 insert_1 (cd
, value
, start
, length
, word_length
, bufp
);
227 #endif /* ! CGEN_INT_INSN_P */
232 /* Default insn builder (insert handler).
233 The instruction is recorded in CGEN_INT_INSN_P byte order (meaning
234 that if CGEN_INSN_BYTES_PTR is an int * and thus, the value is
235 recorded in host byte order, otherwise BUFFER is an array of bytes
236 and the value is recorded in target byte order).
237 The result is an error message or NULL if success. */
240 insert_insn_normal (CGEN_CPU_DESC cd
,
241 const CGEN_INSN
* insn
,
242 CGEN_FIELDS
* fields
,
243 CGEN_INSN_BYTES_PTR buffer
,
246 const CGEN_SYNTAX
*syntax
= CGEN_INSN_SYNTAX (insn
);
248 const CGEN_SYNTAX_CHAR_TYPE
* syn
;
250 CGEN_INIT_INSERT (cd
);
251 value
= CGEN_INSN_BASE_VALUE (insn
);
253 /* If we're recording insns as numbers (rather than a string of bytes),
254 target byte order handling is deferred until later. */
258 put_insn_int_value (cd
, buffer
, cd
->base_insn_bitsize
,
259 CGEN_FIELDS_BITSIZE (fields
), value
);
263 cgen_put_insn_value (cd
, buffer
, min ((unsigned) cd
->base_insn_bitsize
,
264 (unsigned) CGEN_FIELDS_BITSIZE (fields
)),
267 #endif /* ! CGEN_INT_INSN_P */
269 /* ??? It would be better to scan the format's fields.
270 Still need to be able to insert a value based on the operand though;
271 e.g. storing a branch displacement that got resolved later.
272 Needs more thought first. */
274 for (syn
= CGEN_SYNTAX_STRING (syntax
); * syn
; ++ syn
)
278 if (CGEN_SYNTAX_CHAR_P (* syn
))
281 errmsg
= (* cd
->insert_operand
) (cd
, CGEN_SYNTAX_FIELD (*syn
),
291 /* Cover function to store an insn value into an integral insn. Must go here
292 because it needs <prefix>-desc.h for CGEN_INT_INSN_P. */
295 put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
296 CGEN_INSN_BYTES_PTR buf
,
301 /* For architectures with insns smaller than the base-insn-bitsize,
302 length may be too big. */
303 if (length
> insn_length
)
307 int shift
= insn_length
- length
;
308 /* Written this way to avoid undefined behaviour. */
309 CGEN_INSN_INT mask
= (((1L << (length
- 1)) - 1) << 1) | 1;
311 *buf
= (*buf
& ~(mask
<< shift
)) | ((value
& mask
) << shift
);
316 /* Operand extraction. */
318 #if ! CGEN_INT_INSN_P
320 /* Subroutine of extract_normal.
321 Ensure sufficient bytes are cached in EX_INFO.
322 OFFSET is the offset in bytes from the start of the insn of the value.
323 BYTES is the length of the needed value.
324 Returns 1 for success, 0 for failure. */
326 static CGEN_INLINE
int
327 fill_cache (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
328 CGEN_EXTRACT_INFO
*ex_info
,
333 /* It's doubtful that the middle part has already been fetched so
334 we don't optimize that case. kiss. */
336 disassemble_info
*info
= (disassemble_info
*) ex_info
->dis_info
;
338 /* First do a quick check. */
339 mask
= (1 << bytes
) - 1;
340 if (((ex_info
->valid
>> offset
) & mask
) == mask
)
343 /* Search for the first byte we need to read. */
344 for (mask
= 1 << offset
; bytes
> 0; --bytes
, ++offset
, mask
<<= 1)
345 if (! (mask
& ex_info
->valid
))
353 status
= (*info
->read_memory_func
)
354 (pc
, ex_info
->insn_bytes
+ offset
, bytes
, info
);
358 (*info
->memory_error_func
) (status
, pc
, info
);
362 ex_info
->valid
|= ((1 << bytes
) - 1) << offset
;
368 /* Subroutine of extract_normal. */
370 static CGEN_INLINE
long
371 extract_1 (CGEN_CPU_DESC cd
,
372 CGEN_EXTRACT_INFO
*ex_info ATTRIBUTE_UNUSED
,
377 bfd_vma pc ATTRIBUTE_UNUSED
)
382 x
= cgen_get_insn_value (cd
, bufp
, word_length
);
384 if (CGEN_INSN_LSB0_P
)
385 shift
= (start
+ 1) - length
;
387 shift
= (word_length
- (start
+ length
));
391 #endif /* ! CGEN_INT_INSN_P */
393 /* Default extraction routine.
395 INSN_VALUE is the first base_insn_bitsize bits of the insn in host order,
396 or sometimes less for cases like the m32r where the base insn size is 32
397 but some insns are 16 bits.
398 ATTRS is a mask of the boolean attributes. We only need `SIGNED',
399 but for generality we take a bitmask of all of them.
400 WORD_OFFSET is the offset in bits from the start of the insn of the value.
401 WORD_LENGTH is the length of the word in bits in which the value resides.
402 START is the starting bit number in the word, architecture origin.
403 LENGTH is the length of VALUE in bits.
404 TOTAL_LENGTH is the total length of the insn in bits.
406 Returns 1 for success, 0 for failure. */
408 /* ??? The return code isn't properly used. wip. */
410 /* ??? This doesn't handle bfd_vma's. Create another function when
414 extract_normal (CGEN_CPU_DESC cd
,
415 #if ! CGEN_INT_INSN_P
416 CGEN_EXTRACT_INFO
*ex_info
,
418 CGEN_EXTRACT_INFO
*ex_info ATTRIBUTE_UNUSED
,
420 CGEN_INSN_INT insn_value
,
422 unsigned int word_offset
,
425 unsigned int word_length
,
426 unsigned int total_length
,
427 #if ! CGEN_INT_INSN_P
430 bfd_vma pc ATTRIBUTE_UNUSED
,
436 /* If LENGTH is zero, this operand doesn't contribute to the value
437 so give it a standard value of zero. */
444 if (word_length
> 8 * sizeof (CGEN_INSN_INT
))
447 /* For architectures with insns smaller than the insn-base-bitsize,
448 word_length may be too big. */
449 if (cd
->min_insn_bitsize
< cd
->base_insn_bitsize
)
451 if (word_offset
+ word_length
> total_length
)
452 word_length
= total_length
- word_offset
;
455 /* Does the value reside in INSN_VALUE, and at the right alignment? */
457 if (CGEN_INT_INSN_P
|| (word_offset
== 0 && word_length
== total_length
))
459 if (CGEN_INSN_LSB0_P
)
460 value
= insn_value
>> ((word_offset
+ start
+ 1) - length
);
462 value
= insn_value
>> (total_length
- ( word_offset
+ start
+ length
));
465 #if ! CGEN_INT_INSN_P
469 unsigned char *bufp
= ex_info
->insn_bytes
+ word_offset
/ 8;
471 if (word_length
> 8 * sizeof (CGEN_INSN_INT
))
474 if (fill_cache (cd
, ex_info
, word_offset
/ 8, word_length
/ 8, pc
) == 0)
477 value
= extract_1 (cd
, ex_info
, start
, length
, word_length
, bufp
, pc
);
480 #endif /* ! CGEN_INT_INSN_P */
482 /* Written this way to avoid undefined behaviour. */
483 mask
= (((1L << (length
- 1)) - 1) << 1) | 1;
487 if (CGEN_BOOL_ATTR (attrs
, CGEN_IFLD_SIGNED
)
488 && (value
& (1L << (length
- 1))))
496 /* Default insn extractor.
498 INSN_VALUE is the first base_insn_bitsize bits, translated to host order.
499 The extracted fields are stored in FIELDS.
500 EX_INFO is used to handle reading variable length insns.
501 Return the length of the insn in bits, or 0 if no match,
502 or -1 if an error occurs fetching data (memory_error_func will have
506 extract_insn_normal (CGEN_CPU_DESC cd
,
507 const CGEN_INSN
*insn
,
508 CGEN_EXTRACT_INFO
*ex_info
,
509 CGEN_INSN_INT insn_value
,
513 const CGEN_SYNTAX
*syntax
= CGEN_INSN_SYNTAX (insn
);
514 const CGEN_SYNTAX_CHAR_TYPE
*syn
;
516 CGEN_FIELDS_BITSIZE (fields
) = CGEN_INSN_BITSIZE (insn
);
518 CGEN_INIT_EXTRACT (cd
);
520 for (syn
= CGEN_SYNTAX_STRING (syntax
); *syn
; ++syn
)
524 if (CGEN_SYNTAX_CHAR_P (*syn
))
527 length
= (* cd
->extract_operand
) (cd
, CGEN_SYNTAX_FIELD (*syn
),
528 ex_info
, insn_value
, fields
, pc
);
533 /* We recognized and successfully extracted this insn. */
534 return CGEN_INSN_BITSIZE (insn
);
537 /* Machine generated code added here. */
539 const char * mt_cgen_insert_operand
540 (CGEN_CPU_DESC
, int, CGEN_FIELDS
*, CGEN_INSN_BYTES_PTR
, bfd_vma
);
542 /* Main entry point for operand insertion.
544 This function is basically just a big switch statement. Earlier versions
545 used tables to look up the function to use, but
546 - if the table contains both assembler and disassembler functions then
547 the disassembler contains much of the assembler and vice-versa,
548 - there's a lot of inlining possibilities as things grow,
549 - using a switch statement avoids the function call overhead.
551 This function could be moved into `parse_insn_normal', but keeping it
552 separate makes clear the interface between `parse_insn_normal' and each of
553 the handlers. It's also needed by GAS to insert operands that couldn't be
554 resolved during parsing. */
557 mt_cgen_insert_operand (CGEN_CPU_DESC cd
,
559 CGEN_FIELDS
* fields
,
560 CGEN_INSN_BYTES_PTR buffer
,
561 bfd_vma pc ATTRIBUTE_UNUSED
)
563 const char * errmsg
= NULL
;
564 unsigned int total_length
= CGEN_FIELDS_BITSIZE (fields
);
568 case MT_OPERAND_A23
:
569 errmsg
= insert_normal (cd
, fields
->f_a23
, 0, 0, 23, 1, 32, total_length
, buffer
);
571 case MT_OPERAND_BALL
:
572 errmsg
= insert_normal (cd
, fields
->f_ball
, 0, 0, 19, 1, 32, total_length
, buffer
);
574 case MT_OPERAND_BALL2
:
575 errmsg
= insert_normal (cd
, fields
->f_ball2
, 0, 0, 15, 1, 32, total_length
, buffer
);
577 case MT_OPERAND_BANKADDR
:
578 errmsg
= insert_normal (cd
, fields
->f_bankaddr
, 0, 0, 25, 13, 32, total_length
, buffer
);
580 case MT_OPERAND_BRC
:
581 errmsg
= insert_normal (cd
, fields
->f_brc
, 0, 0, 18, 3, 32, total_length
, buffer
);
583 case MT_OPERAND_BRC2
:
584 errmsg
= insert_normal (cd
, fields
->f_brc2
, 0, 0, 14, 3, 32, total_length
, buffer
);
586 case MT_OPERAND_CB1INCR
:
587 errmsg
= insert_normal (cd
, fields
->f_cb1incr
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 19, 6, 32, total_length
, buffer
);
589 case MT_OPERAND_CB1SEL
:
590 errmsg
= insert_normal (cd
, fields
->f_cb1sel
, 0, 0, 25, 3, 32, total_length
, buffer
);
592 case MT_OPERAND_CB2INCR
:
593 errmsg
= insert_normal (cd
, fields
->f_cb2incr
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 13, 6, 32, total_length
, buffer
);
595 case MT_OPERAND_CB2SEL
:
596 errmsg
= insert_normal (cd
, fields
->f_cb2sel
, 0, 0, 22, 3, 32, total_length
, buffer
);
598 case MT_OPERAND_CBRB
:
599 errmsg
= insert_normal (cd
, fields
->f_cbrb
, 0, 0, 10, 1, 32, total_length
, buffer
);
601 case MT_OPERAND_CBS
:
602 errmsg
= insert_normal (cd
, fields
->f_cbs
, 0, 0, 19, 2, 32, total_length
, buffer
);
604 case MT_OPERAND_CBX
:
605 errmsg
= insert_normal (cd
, fields
->f_cbx
, 0, 0, 14, 3, 32, total_length
, buffer
);
607 case MT_OPERAND_CCB
:
608 errmsg
= insert_normal (cd
, fields
->f_ccb
, 0, 0, 11, 1, 32, total_length
, buffer
);
610 case MT_OPERAND_CDB
:
611 errmsg
= insert_normal (cd
, fields
->f_cdb
, 0, 0, 10, 1, 32, total_length
, buffer
);
613 case MT_OPERAND_CELL
:
614 errmsg
= insert_normal (cd
, fields
->f_cell
, 0, 0, 9, 3, 32, total_length
, buffer
);
616 case MT_OPERAND_COLNUM
:
617 errmsg
= insert_normal (cd
, fields
->f_colnum
, 0, 0, 18, 3, 32, total_length
, buffer
);
619 case MT_OPERAND_CONTNUM
:
620 errmsg
= insert_normal (cd
, fields
->f_contnum
, 0, 0, 8, 9, 32, total_length
, buffer
);
623 errmsg
= insert_normal (cd
, fields
->f_cr
, 0, 0, 22, 3, 32, total_length
, buffer
);
625 case MT_OPERAND_CTXDISP
:
626 errmsg
= insert_normal (cd
, fields
->f_ctxdisp
, 0, 0, 5, 6, 32, total_length
, buffer
);
628 case MT_OPERAND_DUP
:
629 errmsg
= insert_normal (cd
, fields
->f_dup
, 0, 0, 6, 1, 32, total_length
, buffer
);
631 case MT_OPERAND_FBDISP
:
632 errmsg
= insert_normal (cd
, fields
->f_fbdisp
, 0, 0, 15, 6, 32, total_length
, buffer
);
634 case MT_OPERAND_FBINCR
:
635 errmsg
= insert_normal (cd
, fields
->f_fbincr
, 0, 0, 23, 4, 32, total_length
, buffer
);
637 case MT_OPERAND_FRDR
:
638 errmsg
= insert_normal (cd
, fields
->f_dr
, 0|(1<<CGEN_IFLD_ABS_ADDR
), 0, 19, 4, 32, total_length
, buffer
);
640 case MT_OPERAND_FRDRRR
:
641 errmsg
= insert_normal (cd
, fields
->f_drrr
, 0|(1<<CGEN_IFLD_ABS_ADDR
), 0, 15, 4, 32, total_length
, buffer
);
643 case MT_OPERAND_FRSR1
:
644 errmsg
= insert_normal (cd
, fields
->f_sr1
, 0|(1<<CGEN_IFLD_ABS_ADDR
), 0, 23, 4, 32, total_length
, buffer
);
646 case MT_OPERAND_FRSR2
:
647 errmsg
= insert_normal (cd
, fields
->f_sr2
, 0|(1<<CGEN_IFLD_ABS_ADDR
), 0, 19, 4, 32, total_length
, buffer
);
650 errmsg
= insert_normal (cd
, fields
->f_id
, 0, 0, 14, 1, 32, total_length
, buffer
);
652 case MT_OPERAND_IMM16
:
654 long value
= fields
->f_imm16s
;
655 value
= ((value
) + (0));
656 errmsg
= insert_normal (cd
, value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 15, 16, 32, total_length
, buffer
);
659 case MT_OPERAND_IMM16L
:
660 errmsg
= insert_normal (cd
, fields
->f_imm16l
, 0, 0, 23, 16, 32, total_length
, buffer
);
662 case MT_OPERAND_IMM16O
:
664 long value
= fields
->f_imm16s
;
665 value
= ((value
) + (0));
666 errmsg
= insert_normal (cd
, value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 15, 16, 32, total_length
, buffer
);
669 case MT_OPERAND_IMM16Z
:
670 errmsg
= insert_normal (cd
, fields
->f_imm16u
, 0, 0, 15, 16, 32, total_length
, buffer
);
672 case MT_OPERAND_INCAMT
:
673 errmsg
= insert_normal (cd
, fields
->f_incamt
, 0, 0, 19, 8, 32, total_length
, buffer
);
675 case MT_OPERAND_INCR
:
676 errmsg
= insert_normal (cd
, fields
->f_incr
, 0, 0, 17, 6, 32, total_length
, buffer
);
678 case MT_OPERAND_LENGTH
:
679 errmsg
= insert_normal (cd
, fields
->f_length
, 0, 0, 15, 3, 32, total_length
, buffer
);
681 case MT_OPERAND_LOOPSIZE
:
683 long value
= fields
->f_loopo
;
684 value
= ((USI
) (value
) >> (2));
685 errmsg
= insert_normal (cd
, value
, 0, 0, 7, 8, 32, total_length
, buffer
);
688 case MT_OPERAND_MASK
:
689 errmsg
= insert_normal (cd
, fields
->f_mask
, 0, 0, 25, 16, 32, total_length
, buffer
);
691 case MT_OPERAND_MASK1
:
692 errmsg
= insert_normal (cd
, fields
->f_mask1
, 0, 0, 22, 3, 32, total_length
, buffer
);
694 case MT_OPERAND_MODE
:
695 errmsg
= insert_normal (cd
, fields
->f_mode
, 0, 0, 25, 2, 32, total_length
, buffer
);
697 case MT_OPERAND_PERM
:
698 errmsg
= insert_normal (cd
, fields
->f_perm
, 0, 0, 25, 2, 32, total_length
, buffer
);
700 case MT_OPERAND_RBBC
:
701 errmsg
= insert_normal (cd
, fields
->f_rbbc
, 0, 0, 25, 2, 32, total_length
, buffer
);
704 errmsg
= insert_normal (cd
, fields
->f_rc
, 0, 0, 15, 1, 32, total_length
, buffer
);
706 case MT_OPERAND_RC1
:
707 errmsg
= insert_normal (cd
, fields
->f_rc1
, 0, 0, 11, 1, 32, total_length
, buffer
);
709 case MT_OPERAND_RC2
:
710 errmsg
= insert_normal (cd
, fields
->f_rc2
, 0, 0, 6, 1, 32, total_length
, buffer
);
712 case MT_OPERAND_RC3
:
713 errmsg
= insert_normal (cd
, fields
->f_rc3
, 0, 0, 7, 1, 32, total_length
, buffer
);
715 case MT_OPERAND_RCNUM
:
716 errmsg
= insert_normal (cd
, fields
->f_rcnum
, 0, 0, 14, 3, 32, total_length
, buffer
);
718 case MT_OPERAND_RDA
:
719 errmsg
= insert_normal (cd
, fields
->f_rda
, 0, 0, 25, 1, 32, total_length
, buffer
);
721 case MT_OPERAND_ROWNUM
:
722 errmsg
= insert_normal (cd
, fields
->f_rownum
, 0, 0, 14, 3, 32, total_length
, buffer
);
724 case MT_OPERAND_ROWNUM1
:
725 errmsg
= insert_normal (cd
, fields
->f_rownum1
, 0, 0, 12, 3, 32, total_length
, buffer
);
727 case MT_OPERAND_ROWNUM2
:
728 errmsg
= insert_normal (cd
, fields
->f_rownum2
, 0, 0, 9, 3, 32, total_length
, buffer
);
730 case MT_OPERAND_SIZE
:
731 errmsg
= insert_normal (cd
, fields
->f_size
, 0, 0, 13, 14, 32, total_length
, buffer
);
733 case MT_OPERAND_TYPE
:
734 errmsg
= insert_normal (cd
, fields
->f_type
, 0, 0, 21, 2, 32, total_length
, buffer
);
737 errmsg
= insert_normal (cd
, fields
->f_wr
, 0, 0, 24, 1, 32, total_length
, buffer
);
739 case MT_OPERAND_XMODE
:
740 errmsg
= insert_normal (cd
, fields
->f_xmode
, 0, 0, 23, 1, 32, total_length
, buffer
);
744 /* xgettext:c-format */
745 fprintf (stderr
, _("Unrecognized field %d while building insn.\n"),
753 int mt_cgen_extract_operand
754 (CGEN_CPU_DESC
, int, CGEN_EXTRACT_INFO
*, CGEN_INSN_INT
, CGEN_FIELDS
*, bfd_vma
);
756 /* Main entry point for operand extraction.
757 The result is <= 0 for error, >0 for success.
758 ??? Actual values aren't well defined right now.
760 This function is basically just a big switch statement. Earlier versions
761 used tables to look up the function to use, but
762 - if the table contains both assembler and disassembler functions then
763 the disassembler contains much of the assembler and vice-versa,
764 - there's a lot of inlining possibilities as things grow,
765 - using a switch statement avoids the function call overhead.
767 This function could be moved into `print_insn_normal', but keeping it
768 separate makes clear the interface between `print_insn_normal' and each of
772 mt_cgen_extract_operand (CGEN_CPU_DESC cd
,
774 CGEN_EXTRACT_INFO
*ex_info
,
775 CGEN_INSN_INT insn_value
,
776 CGEN_FIELDS
* fields
,
779 /* Assume success (for those operands that are nops). */
781 unsigned int total_length
= CGEN_FIELDS_BITSIZE (fields
);
785 case MT_OPERAND_A23
:
786 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 23, 1, 32, total_length
, pc
, & fields
->f_a23
);
788 case MT_OPERAND_BALL
:
789 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 19, 1, 32, total_length
, pc
, & fields
->f_ball
);
791 case MT_OPERAND_BALL2
:
792 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 1, 32, total_length
, pc
, & fields
->f_ball2
);
794 case MT_OPERAND_BANKADDR
:
795 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 25, 13, 32, total_length
, pc
, & fields
->f_bankaddr
);
797 case MT_OPERAND_BRC
:
798 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 18, 3, 32, total_length
, pc
, & fields
->f_brc
);
800 case MT_OPERAND_BRC2
:
801 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 14, 3, 32, total_length
, pc
, & fields
->f_brc2
);
803 case MT_OPERAND_CB1INCR
:
804 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 19, 6, 32, total_length
, pc
, & fields
->f_cb1incr
);
806 case MT_OPERAND_CB1SEL
:
807 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 25, 3, 32, total_length
, pc
, & fields
->f_cb1sel
);
809 case MT_OPERAND_CB2INCR
:
810 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 13, 6, 32, total_length
, pc
, & fields
->f_cb2incr
);
812 case MT_OPERAND_CB2SEL
:
813 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 22, 3, 32, total_length
, pc
, & fields
->f_cb2sel
);
815 case MT_OPERAND_CBRB
:
816 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 10, 1, 32, total_length
, pc
, & fields
->f_cbrb
);
818 case MT_OPERAND_CBS
:
819 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 19, 2, 32, total_length
, pc
, & fields
->f_cbs
);
821 case MT_OPERAND_CBX
:
822 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 14, 3, 32, total_length
, pc
, & fields
->f_cbx
);
824 case MT_OPERAND_CCB
:
825 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 11, 1, 32, total_length
, pc
, & fields
->f_ccb
);
827 case MT_OPERAND_CDB
:
828 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 10, 1, 32, total_length
, pc
, & fields
->f_cdb
);
830 case MT_OPERAND_CELL
:
831 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 9, 3, 32, total_length
, pc
, & fields
->f_cell
);
833 case MT_OPERAND_COLNUM
:
834 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 18, 3, 32, total_length
, pc
, & fields
->f_colnum
);
836 case MT_OPERAND_CONTNUM
:
837 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 8, 9, 32, total_length
, pc
, & fields
->f_contnum
);
840 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 22, 3, 32, total_length
, pc
, & fields
->f_cr
);
842 case MT_OPERAND_CTXDISP
:
843 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 5, 6, 32, total_length
, pc
, & fields
->f_ctxdisp
);
845 case MT_OPERAND_DUP
:
846 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 6, 1, 32, total_length
, pc
, & fields
->f_dup
);
848 case MT_OPERAND_FBDISP
:
849 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 6, 32, total_length
, pc
, & fields
->f_fbdisp
);
851 case MT_OPERAND_FBINCR
:
852 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 23, 4, 32, total_length
, pc
, & fields
->f_fbincr
);
854 case MT_OPERAND_FRDR
:
855 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_ABS_ADDR
), 0, 19, 4, 32, total_length
, pc
, & fields
->f_dr
);
857 case MT_OPERAND_FRDRRR
:
858 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_ABS_ADDR
), 0, 15, 4, 32, total_length
, pc
, & fields
->f_drrr
);
860 case MT_OPERAND_FRSR1
:
861 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_ABS_ADDR
), 0, 23, 4, 32, total_length
, pc
, & fields
->f_sr1
);
863 case MT_OPERAND_FRSR2
:
864 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_ABS_ADDR
), 0, 19, 4, 32, total_length
, pc
, & fields
->f_sr2
);
867 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 14, 1, 32, total_length
, pc
, & fields
->f_id
);
869 case MT_OPERAND_IMM16
:
872 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 15, 16, 32, total_length
, pc
, & value
);
873 value
= ((value
) + (0));
874 fields
->f_imm16s
= value
;
877 case MT_OPERAND_IMM16L
:
878 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 23, 16, 32, total_length
, pc
, & fields
->f_imm16l
);
880 case MT_OPERAND_IMM16O
:
883 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 15, 16, 32, total_length
, pc
, & value
);
884 value
= ((value
) + (0));
885 fields
->f_imm16s
= value
;
888 case MT_OPERAND_IMM16Z
:
889 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 16, 32, total_length
, pc
, & fields
->f_imm16u
);
891 case MT_OPERAND_INCAMT
:
892 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 19, 8, 32, total_length
, pc
, & fields
->f_incamt
);
894 case MT_OPERAND_INCR
:
895 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 17, 6, 32, total_length
, pc
, & fields
->f_incr
);
897 case MT_OPERAND_LENGTH
:
898 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 3, 32, total_length
, pc
, & fields
->f_length
);
900 case MT_OPERAND_LOOPSIZE
:
903 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 7, 8, 32, total_length
, pc
, & value
);
904 value
= ((((value
) << (2))) + (8));
905 fields
->f_loopo
= value
;
908 case MT_OPERAND_MASK
:
909 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 25, 16, 32, total_length
, pc
, & fields
->f_mask
);
911 case MT_OPERAND_MASK1
:
912 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 22, 3, 32, total_length
, pc
, & fields
->f_mask1
);
914 case MT_OPERAND_MODE
:
915 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 25, 2, 32, total_length
, pc
, & fields
->f_mode
);
917 case MT_OPERAND_PERM
:
918 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 25, 2, 32, total_length
, pc
, & fields
->f_perm
);
920 case MT_OPERAND_RBBC
:
921 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 25, 2, 32, total_length
, pc
, & fields
->f_rbbc
);
924 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 1, 32, total_length
, pc
, & fields
->f_rc
);
926 case MT_OPERAND_RC1
:
927 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 11, 1, 32, total_length
, pc
, & fields
->f_rc1
);
929 case MT_OPERAND_RC2
:
930 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 6, 1, 32, total_length
, pc
, & fields
->f_rc2
);
932 case MT_OPERAND_RC3
:
933 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 7, 1, 32, total_length
, pc
, & fields
->f_rc3
);
935 case MT_OPERAND_RCNUM
:
936 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 14, 3, 32, total_length
, pc
, & fields
->f_rcnum
);
938 case MT_OPERAND_RDA
:
939 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 25, 1, 32, total_length
, pc
, & fields
->f_rda
);
941 case MT_OPERAND_ROWNUM
:
942 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 14, 3, 32, total_length
, pc
, & fields
->f_rownum
);
944 case MT_OPERAND_ROWNUM1
:
945 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 12, 3, 32, total_length
, pc
, & fields
->f_rownum1
);
947 case MT_OPERAND_ROWNUM2
:
948 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 9, 3, 32, total_length
, pc
, & fields
->f_rownum2
);
950 case MT_OPERAND_SIZE
:
951 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 13, 14, 32, total_length
, pc
, & fields
->f_size
);
953 case MT_OPERAND_TYPE
:
954 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 21, 2, 32, total_length
, pc
, & fields
->f_type
);
957 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 24, 1, 32, total_length
, pc
, & fields
->f_wr
);
959 case MT_OPERAND_XMODE
:
960 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 23, 1, 32, total_length
, pc
, & fields
->f_xmode
);
964 /* xgettext:c-format */
965 fprintf (stderr
, _("Unrecognized field %d while decoding insn.\n"),
973 cgen_insert_fn
* const mt_cgen_insert_handlers
[] =
978 cgen_extract_fn
* const mt_cgen_extract_handlers
[] =
983 int mt_cgen_get_int_operand (CGEN_CPU_DESC
, int, const CGEN_FIELDS
*);
984 bfd_vma
mt_cgen_get_vma_operand (CGEN_CPU_DESC
, int, const CGEN_FIELDS
*);
986 /* Getting values from cgen_fields is handled by a collection of functions.
987 They are distinguished by the type of the VALUE argument they return.
988 TODO: floating point, inlining support, remove cases where result type
992 mt_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
994 const CGEN_FIELDS
* fields
)
1000 case MT_OPERAND_A23
:
1001 value
= fields
->f_a23
;
1003 case MT_OPERAND_BALL
:
1004 value
= fields
->f_ball
;
1006 case MT_OPERAND_BALL2
:
1007 value
= fields
->f_ball2
;
1009 case MT_OPERAND_BANKADDR
:
1010 value
= fields
->f_bankaddr
;
1012 case MT_OPERAND_BRC
:
1013 value
= fields
->f_brc
;
1015 case MT_OPERAND_BRC2
:
1016 value
= fields
->f_brc2
;
1018 case MT_OPERAND_CB1INCR
:
1019 value
= fields
->f_cb1incr
;
1021 case MT_OPERAND_CB1SEL
:
1022 value
= fields
->f_cb1sel
;
1024 case MT_OPERAND_CB2INCR
:
1025 value
= fields
->f_cb2incr
;
1027 case MT_OPERAND_CB2SEL
:
1028 value
= fields
->f_cb2sel
;
1030 case MT_OPERAND_CBRB
:
1031 value
= fields
->f_cbrb
;
1033 case MT_OPERAND_CBS
:
1034 value
= fields
->f_cbs
;
1036 case MT_OPERAND_CBX
:
1037 value
= fields
->f_cbx
;
1039 case MT_OPERAND_CCB
:
1040 value
= fields
->f_ccb
;
1042 case MT_OPERAND_CDB
:
1043 value
= fields
->f_cdb
;
1045 case MT_OPERAND_CELL
:
1046 value
= fields
->f_cell
;
1048 case MT_OPERAND_COLNUM
:
1049 value
= fields
->f_colnum
;
1051 case MT_OPERAND_CONTNUM
:
1052 value
= fields
->f_contnum
;
1054 case MT_OPERAND_CR
:
1055 value
= fields
->f_cr
;
1057 case MT_OPERAND_CTXDISP
:
1058 value
= fields
->f_ctxdisp
;
1060 case MT_OPERAND_DUP
:
1061 value
= fields
->f_dup
;
1063 case MT_OPERAND_FBDISP
:
1064 value
= fields
->f_fbdisp
;
1066 case MT_OPERAND_FBINCR
:
1067 value
= fields
->f_fbincr
;
1069 case MT_OPERAND_FRDR
:
1070 value
= fields
->f_dr
;
1072 case MT_OPERAND_FRDRRR
:
1073 value
= fields
->f_drrr
;
1075 case MT_OPERAND_FRSR1
:
1076 value
= fields
->f_sr1
;
1078 case MT_OPERAND_FRSR2
:
1079 value
= fields
->f_sr2
;
1081 case MT_OPERAND_ID
:
1082 value
= fields
->f_id
;
1084 case MT_OPERAND_IMM16
:
1085 value
= fields
->f_imm16s
;
1087 case MT_OPERAND_IMM16L
:
1088 value
= fields
->f_imm16l
;
1090 case MT_OPERAND_IMM16O
:
1091 value
= fields
->f_imm16s
;
1093 case MT_OPERAND_IMM16Z
:
1094 value
= fields
->f_imm16u
;
1096 case MT_OPERAND_INCAMT
:
1097 value
= fields
->f_incamt
;
1099 case MT_OPERAND_INCR
:
1100 value
= fields
->f_incr
;
1102 case MT_OPERAND_LENGTH
:
1103 value
= fields
->f_length
;
1105 case MT_OPERAND_LOOPSIZE
:
1106 value
= fields
->f_loopo
;
1108 case MT_OPERAND_MASK
:
1109 value
= fields
->f_mask
;
1111 case MT_OPERAND_MASK1
:
1112 value
= fields
->f_mask1
;
1114 case MT_OPERAND_MODE
:
1115 value
= fields
->f_mode
;
1117 case MT_OPERAND_PERM
:
1118 value
= fields
->f_perm
;
1120 case MT_OPERAND_RBBC
:
1121 value
= fields
->f_rbbc
;
1123 case MT_OPERAND_RC
:
1124 value
= fields
->f_rc
;
1126 case MT_OPERAND_RC1
:
1127 value
= fields
->f_rc1
;
1129 case MT_OPERAND_RC2
:
1130 value
= fields
->f_rc2
;
1132 case MT_OPERAND_RC3
:
1133 value
= fields
->f_rc3
;
1135 case MT_OPERAND_RCNUM
:
1136 value
= fields
->f_rcnum
;
1138 case MT_OPERAND_RDA
:
1139 value
= fields
->f_rda
;
1141 case MT_OPERAND_ROWNUM
:
1142 value
= fields
->f_rownum
;
1144 case MT_OPERAND_ROWNUM1
:
1145 value
= fields
->f_rownum1
;
1147 case MT_OPERAND_ROWNUM2
:
1148 value
= fields
->f_rownum2
;
1150 case MT_OPERAND_SIZE
:
1151 value
= fields
->f_size
;
1153 case MT_OPERAND_TYPE
:
1154 value
= fields
->f_type
;
1156 case MT_OPERAND_WR
:
1157 value
= fields
->f_wr
;
1159 case MT_OPERAND_XMODE
:
1160 value
= fields
->f_xmode
;
1164 /* xgettext:c-format */
1165 fprintf (stderr
, _("Unrecognized field %d while getting int operand.\n"),
1174 mt_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
1176 const CGEN_FIELDS
* fields
)
1182 case MT_OPERAND_A23
:
1183 value
= fields
->f_a23
;
1185 case MT_OPERAND_BALL
:
1186 value
= fields
->f_ball
;
1188 case MT_OPERAND_BALL2
:
1189 value
= fields
->f_ball2
;
1191 case MT_OPERAND_BANKADDR
:
1192 value
= fields
->f_bankaddr
;
1194 case MT_OPERAND_BRC
:
1195 value
= fields
->f_brc
;
1197 case MT_OPERAND_BRC2
:
1198 value
= fields
->f_brc2
;
1200 case MT_OPERAND_CB1INCR
:
1201 value
= fields
->f_cb1incr
;
1203 case MT_OPERAND_CB1SEL
:
1204 value
= fields
->f_cb1sel
;
1206 case MT_OPERAND_CB2INCR
:
1207 value
= fields
->f_cb2incr
;
1209 case MT_OPERAND_CB2SEL
:
1210 value
= fields
->f_cb2sel
;
1212 case MT_OPERAND_CBRB
:
1213 value
= fields
->f_cbrb
;
1215 case MT_OPERAND_CBS
:
1216 value
= fields
->f_cbs
;
1218 case MT_OPERAND_CBX
:
1219 value
= fields
->f_cbx
;
1221 case MT_OPERAND_CCB
:
1222 value
= fields
->f_ccb
;
1224 case MT_OPERAND_CDB
:
1225 value
= fields
->f_cdb
;
1227 case MT_OPERAND_CELL
:
1228 value
= fields
->f_cell
;
1230 case MT_OPERAND_COLNUM
:
1231 value
= fields
->f_colnum
;
1233 case MT_OPERAND_CONTNUM
:
1234 value
= fields
->f_contnum
;
1236 case MT_OPERAND_CR
:
1237 value
= fields
->f_cr
;
1239 case MT_OPERAND_CTXDISP
:
1240 value
= fields
->f_ctxdisp
;
1242 case MT_OPERAND_DUP
:
1243 value
= fields
->f_dup
;
1245 case MT_OPERAND_FBDISP
:
1246 value
= fields
->f_fbdisp
;
1248 case MT_OPERAND_FBINCR
:
1249 value
= fields
->f_fbincr
;
1251 case MT_OPERAND_FRDR
:
1252 value
= fields
->f_dr
;
1254 case MT_OPERAND_FRDRRR
:
1255 value
= fields
->f_drrr
;
1257 case MT_OPERAND_FRSR1
:
1258 value
= fields
->f_sr1
;
1260 case MT_OPERAND_FRSR2
:
1261 value
= fields
->f_sr2
;
1263 case MT_OPERAND_ID
:
1264 value
= fields
->f_id
;
1266 case MT_OPERAND_IMM16
:
1267 value
= fields
->f_imm16s
;
1269 case MT_OPERAND_IMM16L
:
1270 value
= fields
->f_imm16l
;
1272 case MT_OPERAND_IMM16O
:
1273 value
= fields
->f_imm16s
;
1275 case MT_OPERAND_IMM16Z
:
1276 value
= fields
->f_imm16u
;
1278 case MT_OPERAND_INCAMT
:
1279 value
= fields
->f_incamt
;
1281 case MT_OPERAND_INCR
:
1282 value
= fields
->f_incr
;
1284 case MT_OPERAND_LENGTH
:
1285 value
= fields
->f_length
;
1287 case MT_OPERAND_LOOPSIZE
:
1288 value
= fields
->f_loopo
;
1290 case MT_OPERAND_MASK
:
1291 value
= fields
->f_mask
;
1293 case MT_OPERAND_MASK1
:
1294 value
= fields
->f_mask1
;
1296 case MT_OPERAND_MODE
:
1297 value
= fields
->f_mode
;
1299 case MT_OPERAND_PERM
:
1300 value
= fields
->f_perm
;
1302 case MT_OPERAND_RBBC
:
1303 value
= fields
->f_rbbc
;
1305 case MT_OPERAND_RC
:
1306 value
= fields
->f_rc
;
1308 case MT_OPERAND_RC1
:
1309 value
= fields
->f_rc1
;
1311 case MT_OPERAND_RC2
:
1312 value
= fields
->f_rc2
;
1314 case MT_OPERAND_RC3
:
1315 value
= fields
->f_rc3
;
1317 case MT_OPERAND_RCNUM
:
1318 value
= fields
->f_rcnum
;
1320 case MT_OPERAND_RDA
:
1321 value
= fields
->f_rda
;
1323 case MT_OPERAND_ROWNUM
:
1324 value
= fields
->f_rownum
;
1326 case MT_OPERAND_ROWNUM1
:
1327 value
= fields
->f_rownum1
;
1329 case MT_OPERAND_ROWNUM2
:
1330 value
= fields
->f_rownum2
;
1332 case MT_OPERAND_SIZE
:
1333 value
= fields
->f_size
;
1335 case MT_OPERAND_TYPE
:
1336 value
= fields
->f_type
;
1338 case MT_OPERAND_WR
:
1339 value
= fields
->f_wr
;
1341 case MT_OPERAND_XMODE
:
1342 value
= fields
->f_xmode
;
1346 /* xgettext:c-format */
1347 fprintf (stderr
, _("Unrecognized field %d while getting vma operand.\n"),
1355 void mt_cgen_set_int_operand (CGEN_CPU_DESC
, int, CGEN_FIELDS
*, int);
1356 void mt_cgen_set_vma_operand (CGEN_CPU_DESC
, int, CGEN_FIELDS
*, bfd_vma
);
1358 /* Stuffing values in cgen_fields is handled by a collection of functions.
1359 They are distinguished by the type of the VALUE argument they accept.
1360 TODO: floating point, inlining support, remove cases where argument type
1364 mt_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
1366 CGEN_FIELDS
* fields
,
1371 case MT_OPERAND_A23
:
1372 fields
->f_a23
= value
;
1374 case MT_OPERAND_BALL
:
1375 fields
->f_ball
= value
;
1377 case MT_OPERAND_BALL2
:
1378 fields
->f_ball2
= value
;
1380 case MT_OPERAND_BANKADDR
:
1381 fields
->f_bankaddr
= value
;
1383 case MT_OPERAND_BRC
:
1384 fields
->f_brc
= value
;
1386 case MT_OPERAND_BRC2
:
1387 fields
->f_brc2
= value
;
1389 case MT_OPERAND_CB1INCR
:
1390 fields
->f_cb1incr
= value
;
1392 case MT_OPERAND_CB1SEL
:
1393 fields
->f_cb1sel
= value
;
1395 case MT_OPERAND_CB2INCR
:
1396 fields
->f_cb2incr
= value
;
1398 case MT_OPERAND_CB2SEL
:
1399 fields
->f_cb2sel
= value
;
1401 case MT_OPERAND_CBRB
:
1402 fields
->f_cbrb
= value
;
1404 case MT_OPERAND_CBS
:
1405 fields
->f_cbs
= value
;
1407 case MT_OPERAND_CBX
:
1408 fields
->f_cbx
= value
;
1410 case MT_OPERAND_CCB
:
1411 fields
->f_ccb
= value
;
1413 case MT_OPERAND_CDB
:
1414 fields
->f_cdb
= value
;
1416 case MT_OPERAND_CELL
:
1417 fields
->f_cell
= value
;
1419 case MT_OPERAND_COLNUM
:
1420 fields
->f_colnum
= value
;
1422 case MT_OPERAND_CONTNUM
:
1423 fields
->f_contnum
= value
;
1425 case MT_OPERAND_CR
:
1426 fields
->f_cr
= value
;
1428 case MT_OPERAND_CTXDISP
:
1429 fields
->f_ctxdisp
= value
;
1431 case MT_OPERAND_DUP
:
1432 fields
->f_dup
= value
;
1434 case MT_OPERAND_FBDISP
:
1435 fields
->f_fbdisp
= value
;
1437 case MT_OPERAND_FBINCR
:
1438 fields
->f_fbincr
= value
;
1440 case MT_OPERAND_FRDR
:
1441 fields
->f_dr
= value
;
1443 case MT_OPERAND_FRDRRR
:
1444 fields
->f_drrr
= value
;
1446 case MT_OPERAND_FRSR1
:
1447 fields
->f_sr1
= value
;
1449 case MT_OPERAND_FRSR2
:
1450 fields
->f_sr2
= value
;
1452 case MT_OPERAND_ID
:
1453 fields
->f_id
= value
;
1455 case MT_OPERAND_IMM16
:
1456 fields
->f_imm16s
= value
;
1458 case MT_OPERAND_IMM16L
:
1459 fields
->f_imm16l
= value
;
1461 case MT_OPERAND_IMM16O
:
1462 fields
->f_imm16s
= value
;
1464 case MT_OPERAND_IMM16Z
:
1465 fields
->f_imm16u
= value
;
1467 case MT_OPERAND_INCAMT
:
1468 fields
->f_incamt
= value
;
1470 case MT_OPERAND_INCR
:
1471 fields
->f_incr
= value
;
1473 case MT_OPERAND_LENGTH
:
1474 fields
->f_length
= value
;
1476 case MT_OPERAND_LOOPSIZE
:
1477 fields
->f_loopo
= value
;
1479 case MT_OPERAND_MASK
:
1480 fields
->f_mask
= value
;
1482 case MT_OPERAND_MASK1
:
1483 fields
->f_mask1
= value
;
1485 case MT_OPERAND_MODE
:
1486 fields
->f_mode
= value
;
1488 case MT_OPERAND_PERM
:
1489 fields
->f_perm
= value
;
1491 case MT_OPERAND_RBBC
:
1492 fields
->f_rbbc
= value
;
1494 case MT_OPERAND_RC
:
1495 fields
->f_rc
= value
;
1497 case MT_OPERAND_RC1
:
1498 fields
->f_rc1
= value
;
1500 case MT_OPERAND_RC2
:
1501 fields
->f_rc2
= value
;
1503 case MT_OPERAND_RC3
:
1504 fields
->f_rc3
= value
;
1506 case MT_OPERAND_RCNUM
:
1507 fields
->f_rcnum
= value
;
1509 case MT_OPERAND_RDA
:
1510 fields
->f_rda
= value
;
1512 case MT_OPERAND_ROWNUM
:
1513 fields
->f_rownum
= value
;
1515 case MT_OPERAND_ROWNUM1
:
1516 fields
->f_rownum1
= value
;
1518 case MT_OPERAND_ROWNUM2
:
1519 fields
->f_rownum2
= value
;
1521 case MT_OPERAND_SIZE
:
1522 fields
->f_size
= value
;
1524 case MT_OPERAND_TYPE
:
1525 fields
->f_type
= value
;
1527 case MT_OPERAND_WR
:
1528 fields
->f_wr
= value
;
1530 case MT_OPERAND_XMODE
:
1531 fields
->f_xmode
= value
;
1535 /* xgettext:c-format */
1536 fprintf (stderr
, _("Unrecognized field %d while setting int operand.\n"),
1543 mt_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
1545 CGEN_FIELDS
* fields
,
1550 case MT_OPERAND_A23
:
1551 fields
->f_a23
= value
;
1553 case MT_OPERAND_BALL
:
1554 fields
->f_ball
= value
;
1556 case MT_OPERAND_BALL2
:
1557 fields
->f_ball2
= value
;
1559 case MT_OPERAND_BANKADDR
:
1560 fields
->f_bankaddr
= value
;
1562 case MT_OPERAND_BRC
:
1563 fields
->f_brc
= value
;
1565 case MT_OPERAND_BRC2
:
1566 fields
->f_brc2
= value
;
1568 case MT_OPERAND_CB1INCR
:
1569 fields
->f_cb1incr
= value
;
1571 case MT_OPERAND_CB1SEL
:
1572 fields
->f_cb1sel
= value
;
1574 case MT_OPERAND_CB2INCR
:
1575 fields
->f_cb2incr
= value
;
1577 case MT_OPERAND_CB2SEL
:
1578 fields
->f_cb2sel
= value
;
1580 case MT_OPERAND_CBRB
:
1581 fields
->f_cbrb
= value
;
1583 case MT_OPERAND_CBS
:
1584 fields
->f_cbs
= value
;
1586 case MT_OPERAND_CBX
:
1587 fields
->f_cbx
= value
;
1589 case MT_OPERAND_CCB
:
1590 fields
->f_ccb
= value
;
1592 case MT_OPERAND_CDB
:
1593 fields
->f_cdb
= value
;
1595 case MT_OPERAND_CELL
:
1596 fields
->f_cell
= value
;
1598 case MT_OPERAND_COLNUM
:
1599 fields
->f_colnum
= value
;
1601 case MT_OPERAND_CONTNUM
:
1602 fields
->f_contnum
= value
;
1604 case MT_OPERAND_CR
:
1605 fields
->f_cr
= value
;
1607 case MT_OPERAND_CTXDISP
:
1608 fields
->f_ctxdisp
= value
;
1610 case MT_OPERAND_DUP
:
1611 fields
->f_dup
= value
;
1613 case MT_OPERAND_FBDISP
:
1614 fields
->f_fbdisp
= value
;
1616 case MT_OPERAND_FBINCR
:
1617 fields
->f_fbincr
= value
;
1619 case MT_OPERAND_FRDR
:
1620 fields
->f_dr
= value
;
1622 case MT_OPERAND_FRDRRR
:
1623 fields
->f_drrr
= value
;
1625 case MT_OPERAND_FRSR1
:
1626 fields
->f_sr1
= value
;
1628 case MT_OPERAND_FRSR2
:
1629 fields
->f_sr2
= value
;
1631 case MT_OPERAND_ID
:
1632 fields
->f_id
= value
;
1634 case MT_OPERAND_IMM16
:
1635 fields
->f_imm16s
= value
;
1637 case MT_OPERAND_IMM16L
:
1638 fields
->f_imm16l
= value
;
1640 case MT_OPERAND_IMM16O
:
1641 fields
->f_imm16s
= value
;
1643 case MT_OPERAND_IMM16Z
:
1644 fields
->f_imm16u
= value
;
1646 case MT_OPERAND_INCAMT
:
1647 fields
->f_incamt
= value
;
1649 case MT_OPERAND_INCR
:
1650 fields
->f_incr
= value
;
1652 case MT_OPERAND_LENGTH
:
1653 fields
->f_length
= value
;
1655 case MT_OPERAND_LOOPSIZE
:
1656 fields
->f_loopo
= value
;
1658 case MT_OPERAND_MASK
:
1659 fields
->f_mask
= value
;
1661 case MT_OPERAND_MASK1
:
1662 fields
->f_mask1
= value
;
1664 case MT_OPERAND_MODE
:
1665 fields
->f_mode
= value
;
1667 case MT_OPERAND_PERM
:
1668 fields
->f_perm
= value
;
1670 case MT_OPERAND_RBBC
:
1671 fields
->f_rbbc
= value
;
1673 case MT_OPERAND_RC
:
1674 fields
->f_rc
= value
;
1676 case MT_OPERAND_RC1
:
1677 fields
->f_rc1
= value
;
1679 case MT_OPERAND_RC2
:
1680 fields
->f_rc2
= value
;
1682 case MT_OPERAND_RC3
:
1683 fields
->f_rc3
= value
;
1685 case MT_OPERAND_RCNUM
:
1686 fields
->f_rcnum
= value
;
1688 case MT_OPERAND_RDA
:
1689 fields
->f_rda
= value
;
1691 case MT_OPERAND_ROWNUM
:
1692 fields
->f_rownum
= value
;
1694 case MT_OPERAND_ROWNUM1
:
1695 fields
->f_rownum1
= value
;
1697 case MT_OPERAND_ROWNUM2
:
1698 fields
->f_rownum2
= value
;
1700 case MT_OPERAND_SIZE
:
1701 fields
->f_size
= value
;
1703 case MT_OPERAND_TYPE
:
1704 fields
->f_type
= value
;
1706 case MT_OPERAND_WR
:
1707 fields
->f_wr
= value
;
1709 case MT_OPERAND_XMODE
:
1710 fields
->f_xmode
= value
;
1714 /* xgettext:c-format */
1715 fprintf (stderr
, _("Unrecognized field %d while setting vma operand.\n"),
1721 /* Function to call before using the instruction builder tables. */
1724 mt_cgen_init_ibld_table (CGEN_CPU_DESC cd
)
1726 cd
->insert_handlers
= & mt_cgen_insert_handlers
[0];
1727 cd
->extract_handlers
= & mt_cgen_extract_handlers
[0];
1729 cd
->insert_operand
= mt_cgen_insert_operand
;
1730 cd
->extract_operand
= mt_cgen_extract_operand
;
1732 cd
->get_int_operand
= mt_cgen_get_int_operand
;
1733 cd
->set_int_operand
= mt_cgen_set_int_operand
;
1734 cd
->get_vma_operand
= mt_cgen_get_vma_operand
;
1735 cd
->set_vma_operand
= mt_cgen_set_vma_operand
;