1 /* DO NOT EDIT! -*- buffer-read-only: t -*- vi:set ro: */
2 /* Instruction building/extraction support for mt. -*- C -*-
4 THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator.
5 - the resultant file is machine generated, cgen-ibld.in isn't
7 Copyright (C) 1996-2023 Free Software Foundation, Inc.
9 This file is part of libopcodes.
11 This library is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3, or (at your option)
16 It is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
19 License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
25 /* ??? Eventually more and more of this stuff can go to cpu-independent files.
36 #include "cgen/basic-modes.h"
38 #include "safe-ctype.h"
41 #define min(a,b) ((a) < (b) ? (a) : (b))
43 #define max(a,b) ((a) > (b) ? (a) : (b))
45 /* Used by the ifield rtx function. */
46 #define FLD(f) (fields->f)
48 static const char * insert_normal
49 (CGEN_CPU_DESC
, long, unsigned int, unsigned int, unsigned int,
50 unsigned int, unsigned int, unsigned int, CGEN_INSN_BYTES_PTR
);
51 static const char * insert_insn_normal
52 (CGEN_CPU_DESC
, const CGEN_INSN
*,
53 CGEN_FIELDS
*, CGEN_INSN_BYTES_PTR
, bfd_vma
);
54 static int extract_normal
55 (CGEN_CPU_DESC
, CGEN_EXTRACT_INFO
*, CGEN_INSN_INT
,
56 unsigned int, unsigned int, unsigned int, unsigned int,
57 unsigned int, unsigned int, bfd_vma
, long *);
58 static int extract_insn_normal
59 (CGEN_CPU_DESC
, const CGEN_INSN
*, CGEN_EXTRACT_INFO
*,
60 CGEN_INSN_INT
, CGEN_FIELDS
*, bfd_vma
);
62 static void put_insn_int_value
63 (CGEN_CPU_DESC
, CGEN_INSN_BYTES_PTR
, int, int, CGEN_INSN_INT
);
66 static CGEN_INLINE
void insert_1
67 (CGEN_CPU_DESC
, unsigned long, int, int, int, unsigned char *);
68 static CGEN_INLINE
int fill_cache
69 (CGEN_CPU_DESC
, CGEN_EXTRACT_INFO
*, int, int, bfd_vma
);
70 static CGEN_INLINE
long extract_1
71 (CGEN_CPU_DESC
, CGEN_EXTRACT_INFO
*, int, int, int, unsigned char *, bfd_vma
);
74 /* Operand insertion. */
78 /* Subroutine of insert_normal. */
80 static CGEN_INLINE
void
81 insert_1 (CGEN_CPU_DESC cd
,
88 unsigned long x
, mask
;
91 x
= cgen_get_insn_value (cd
, bufp
, word_length
, cd
->endian
);
93 /* Written this way to avoid undefined behaviour. */
94 mask
= (1UL << (length
- 1) << 1) - 1;
96 shift
= (start
+ 1) - length
;
98 shift
= (word_length
- (start
+ length
));
99 x
= (x
& ~(mask
<< shift
)) | ((value
& mask
) << shift
);
101 cgen_put_insn_value (cd
, bufp
, word_length
, (bfd_vma
) x
, cd
->endian
);
104 #endif /* ! CGEN_INT_INSN_P */
106 /* Default insertion routine.
108 ATTRS is a mask of the boolean attributes.
109 WORD_OFFSET is the offset in bits from the start of the insn of the value.
110 WORD_LENGTH is the length of the word in bits in which the value resides.
111 START is the starting bit number in the word, architecture origin.
112 LENGTH is the length of VALUE in bits.
113 TOTAL_LENGTH is the total length of the insn in bits.
115 The result is an error message or NULL if success. */
117 /* ??? This duplicates functionality with bfd's howto table and
118 bfd_install_relocation. */
119 /* ??? This doesn't handle bfd_vma's. Create another function when
123 insert_normal (CGEN_CPU_DESC cd
,
126 unsigned int word_offset
,
129 unsigned int word_length
,
130 unsigned int total_length
,
131 CGEN_INSN_BYTES_PTR buffer
)
133 static char errbuf
[100];
136 /* If LENGTH is zero, this operand doesn't contribute to the value. */
140 /* Written this way to avoid undefined behaviour. */
141 mask
= (1UL << (length
- 1) << 1) - 1;
143 if (word_length
> 8 * sizeof (CGEN_INSN_INT
))
146 /* For architectures with insns smaller than the base-insn-bitsize,
147 word_length may be too big. */
148 if (cd
->min_insn_bitsize
< cd
->base_insn_bitsize
)
151 && word_length
> total_length
)
152 word_length
= total_length
;
155 /* Ensure VALUE will fit. */
156 if (CGEN_BOOL_ATTR (attrs
, CGEN_IFLD_SIGN_OPT
))
158 long minval
= - (1UL << (length
- 1));
159 unsigned long maxval
= mask
;
161 if ((value
> 0 && (unsigned long) value
> maxval
)
164 /* xgettext:c-format */
166 _("operand out of range (%ld not between %ld and %lu)"),
167 value
, minval
, maxval
);
171 else if (! CGEN_BOOL_ATTR (attrs
, CGEN_IFLD_SIGNED
))
173 unsigned long maxval
= mask
;
174 unsigned long val
= (unsigned long) value
;
176 /* For hosts with a word size > 32 check to see if value has been sign
177 extended beyond 32 bits. If so then ignore these higher sign bits
178 as the user is attempting to store a 32-bit signed value into an
179 unsigned 32-bit field which is allowed. */
180 if (sizeof (unsigned long) > 4 && ((value
>> 32) == -1))
185 /* xgettext:c-format */
187 _("operand out of range (0x%lx not between 0 and 0x%lx)"),
194 if (! cgen_signed_overflow_ok_p (cd
))
196 long minval
= - (1UL << (length
- 1));
197 long maxval
= (1UL << (length
- 1)) - 1;
199 if (value
< minval
|| value
> maxval
)
202 /* xgettext:c-format */
203 (errbuf
, _("operand out of range (%ld not between %ld and %ld)"),
204 value
, minval
, maxval
);
213 int shift_within_word
, shift_to_word
, shift
;
215 /* How to shift the value to BIT0 of the word. */
216 shift_to_word
= total_length
- (word_offset
+ word_length
);
218 /* How to shift the value to the field within the word. */
219 if (CGEN_INSN_LSB0_P
)
220 shift_within_word
= start
+ 1 - length
;
222 shift_within_word
= word_length
- start
- length
;
224 /* The total SHIFT, then mask in the value. */
225 shift
= shift_to_word
+ shift_within_word
;
226 *buffer
= (*buffer
& ~(mask
<< shift
)) | ((value
& mask
) << shift
);
229 #else /* ! CGEN_INT_INSN_P */
232 unsigned char *bufp
= (unsigned char *) buffer
+ word_offset
/ 8;
234 insert_1 (cd
, value
, start
, length
, word_length
, bufp
);
237 #endif /* ! CGEN_INT_INSN_P */
242 /* Default insn builder (insert handler).
243 The instruction is recorded in CGEN_INT_INSN_P byte order (meaning
244 that if CGEN_INSN_BYTES_PTR is an int * and thus, the value is
245 recorded in host byte order, otherwise BUFFER is an array of bytes
246 and the value is recorded in target byte order).
247 The result is an error message or NULL if success. */
250 insert_insn_normal (CGEN_CPU_DESC cd
,
251 const CGEN_INSN
* insn
,
252 CGEN_FIELDS
* fields
,
253 CGEN_INSN_BYTES_PTR buffer
,
256 const CGEN_SYNTAX
*syntax
= CGEN_INSN_SYNTAX (insn
);
258 const CGEN_SYNTAX_CHAR_TYPE
* syn
;
260 CGEN_INIT_INSERT (cd
);
261 value
= CGEN_INSN_BASE_VALUE (insn
);
263 /* If we're recording insns as numbers (rather than a string of bytes),
264 target byte order handling is deferred until later. */
268 put_insn_int_value (cd
, buffer
, cd
->base_insn_bitsize
,
269 CGEN_FIELDS_BITSIZE (fields
), value
);
273 cgen_put_insn_value (cd
, buffer
, min ((unsigned) cd
->base_insn_bitsize
,
274 (unsigned) CGEN_FIELDS_BITSIZE (fields
)),
275 value
, cd
->insn_endian
);
277 #endif /* ! CGEN_INT_INSN_P */
279 /* ??? It would be better to scan the format's fields.
280 Still need to be able to insert a value based on the operand though;
281 e.g. storing a branch displacement that got resolved later.
282 Needs more thought first. */
284 for (syn
= CGEN_SYNTAX_STRING (syntax
); * syn
; ++ syn
)
288 if (CGEN_SYNTAX_CHAR_P (* syn
))
291 errmsg
= (* cd
->insert_operand
) (cd
, CGEN_SYNTAX_FIELD (*syn
),
301 /* Cover function to store an insn value into an integral insn. Must go here
302 because it needs <prefix>-desc.h for CGEN_INT_INSN_P. */
305 put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
306 CGEN_INSN_BYTES_PTR buf
,
311 /* For architectures with insns smaller than the base-insn-bitsize,
312 length may be too big. */
313 if (length
> insn_length
)
317 int shift
= insn_length
- length
;
318 /* Written this way to avoid undefined behaviour. */
319 CGEN_INSN_INT mask
= length
== 0 ? 0 : (1UL << (length
- 1) << 1) - 1;
321 *buf
= (*buf
& ~(mask
<< shift
)) | ((value
& mask
) << shift
);
326 /* Operand extraction. */
328 #if ! CGEN_INT_INSN_P
330 /* Subroutine of extract_normal.
331 Ensure sufficient bytes are cached in EX_INFO.
332 OFFSET is the offset in bytes from the start of the insn of the value.
333 BYTES is the length of the needed value.
334 Returns 1 for success, 0 for failure. */
336 static CGEN_INLINE
int
337 fill_cache (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
338 CGEN_EXTRACT_INFO
*ex_info
,
343 /* It's doubtful that the middle part has already been fetched so
344 we don't optimize that case. kiss. */
346 disassemble_info
*info
= (disassemble_info
*) ex_info
->dis_info
;
348 /* First do a quick check. */
349 mask
= (1 << bytes
) - 1;
350 if (((ex_info
->valid
>> offset
) & mask
) == mask
)
353 /* Search for the first byte we need to read. */
354 for (mask
= 1 << offset
; bytes
> 0; --bytes
, ++offset
, mask
<<= 1)
355 if (! (mask
& ex_info
->valid
))
363 status
= (*info
->read_memory_func
)
364 (pc
, ex_info
->insn_bytes
+ offset
, bytes
, info
);
368 (*info
->memory_error_func
) (status
, pc
, info
);
372 ex_info
->valid
|= ((1 << bytes
) - 1) << offset
;
378 /* Subroutine of extract_normal. */
380 static CGEN_INLINE
long
381 extract_1 (CGEN_CPU_DESC cd
,
382 CGEN_EXTRACT_INFO
*ex_info ATTRIBUTE_UNUSED
,
387 bfd_vma pc ATTRIBUTE_UNUSED
)
392 x
= cgen_get_insn_value (cd
, bufp
, word_length
, cd
->endian
);
394 if (CGEN_INSN_LSB0_P
)
395 shift
= (start
+ 1) - length
;
397 shift
= (word_length
- (start
+ length
));
401 #endif /* ! CGEN_INT_INSN_P */
403 /* Default extraction routine.
405 INSN_VALUE is the first base_insn_bitsize bits of the insn in host order,
406 or sometimes less for cases like the m32r where the base insn size is 32
407 but some insns are 16 bits.
408 ATTRS is a mask of the boolean attributes. We only need `SIGNED',
409 but for generality we take a bitmask of all of them.
410 WORD_OFFSET is the offset in bits from the start of the insn of the value.
411 WORD_LENGTH is the length of the word in bits in which the value resides.
412 START is the starting bit number in the word, architecture origin.
413 LENGTH is the length of VALUE in bits.
414 TOTAL_LENGTH is the total length of the insn in bits.
416 Returns 1 for success, 0 for failure. */
418 /* ??? The return code isn't properly used. wip. */
420 /* ??? This doesn't handle bfd_vma's. Create another function when
424 extract_normal (CGEN_CPU_DESC cd
,
425 #if ! CGEN_INT_INSN_P
426 CGEN_EXTRACT_INFO
*ex_info
,
428 CGEN_EXTRACT_INFO
*ex_info ATTRIBUTE_UNUSED
,
430 CGEN_INSN_INT insn_value
,
432 unsigned int word_offset
,
435 unsigned int word_length
,
436 unsigned int total_length
,
437 #if ! CGEN_INT_INSN_P
440 bfd_vma pc ATTRIBUTE_UNUSED
,
446 /* If LENGTH is zero, this operand doesn't contribute to the value
447 so give it a standard value of zero. */
454 if (word_length
> 8 * sizeof (CGEN_INSN_INT
))
457 /* For architectures with insns smaller than the insn-base-bitsize,
458 word_length may be too big. */
459 if (cd
->min_insn_bitsize
< cd
->base_insn_bitsize
)
461 if (word_offset
+ word_length
> total_length
)
462 word_length
= total_length
- word_offset
;
465 /* Does the value reside in INSN_VALUE, and at the right alignment? */
467 if (CGEN_INT_INSN_P
|| (word_offset
== 0 && word_length
== total_length
))
469 if (CGEN_INSN_LSB0_P
)
470 value
= insn_value
>> ((word_offset
+ start
+ 1) - length
);
472 value
= insn_value
>> (total_length
- ( word_offset
+ start
+ length
));
475 #if ! CGEN_INT_INSN_P
479 unsigned char *bufp
= ex_info
->insn_bytes
+ word_offset
/ 8;
481 if (word_length
> 8 * sizeof (CGEN_INSN_INT
))
484 if (fill_cache (cd
, ex_info
, word_offset
/ 8, word_length
/ 8, pc
) == 0)
490 value
= extract_1 (cd
, ex_info
, start
, length
, word_length
, bufp
, pc
);
493 #endif /* ! CGEN_INT_INSN_P */
495 /* Written this way to avoid undefined behaviour. */
496 mask
= (1UL << (length
- 1) << 1) - 1;
500 if (CGEN_BOOL_ATTR (attrs
, CGEN_IFLD_SIGNED
)
501 && (value
& (1UL << (length
- 1))))
509 /* Default insn extractor.
511 INSN_VALUE is the first base_insn_bitsize bits, translated to host order.
512 The extracted fields are stored in FIELDS.
513 EX_INFO is used to handle reading variable length insns.
514 Return the length of the insn in bits, or 0 if no match,
515 or -1 if an error occurs fetching data (memory_error_func will have
519 extract_insn_normal (CGEN_CPU_DESC cd
,
520 const CGEN_INSN
*insn
,
521 CGEN_EXTRACT_INFO
*ex_info
,
522 CGEN_INSN_INT insn_value
,
526 const CGEN_SYNTAX
*syntax
= CGEN_INSN_SYNTAX (insn
);
527 const CGEN_SYNTAX_CHAR_TYPE
*syn
;
529 CGEN_FIELDS_BITSIZE (fields
) = CGEN_INSN_BITSIZE (insn
);
531 CGEN_INIT_EXTRACT (cd
);
533 for (syn
= CGEN_SYNTAX_STRING (syntax
); *syn
; ++syn
)
537 if (CGEN_SYNTAX_CHAR_P (*syn
))
540 length
= (* cd
->extract_operand
) (cd
, CGEN_SYNTAX_FIELD (*syn
),
541 ex_info
, insn_value
, fields
, pc
);
546 /* We recognized and successfully extracted this insn. */
547 return CGEN_INSN_BITSIZE (insn
);
550 /* Machine generated code added here. */
552 const char * mt_cgen_insert_operand
553 (CGEN_CPU_DESC
, int, CGEN_FIELDS
*, CGEN_INSN_BYTES_PTR
, bfd_vma
);
555 /* Main entry point for operand insertion.
557 This function is basically just a big switch statement. Earlier versions
558 used tables to look up the function to use, but
559 - if the table contains both assembler and disassembler functions then
560 the disassembler contains much of the assembler and vice-versa,
561 - there's a lot of inlining possibilities as things grow,
562 - using a switch statement avoids the function call overhead.
564 This function could be moved into `parse_insn_normal', but keeping it
565 separate makes clear the interface between `parse_insn_normal' and each of
566 the handlers. It's also needed by GAS to insert operands that couldn't be
567 resolved during parsing. */
570 mt_cgen_insert_operand (CGEN_CPU_DESC cd
,
572 CGEN_FIELDS
* fields
,
573 CGEN_INSN_BYTES_PTR buffer
,
574 bfd_vma pc ATTRIBUTE_UNUSED
)
576 const char * errmsg
= NULL
;
577 unsigned int total_length
= CGEN_FIELDS_BITSIZE (fields
);
581 case MT_OPERAND_A23
:
582 errmsg
= insert_normal (cd
, fields
->f_a23
, 0, 0, 23, 1, 32, total_length
, buffer
);
584 case MT_OPERAND_BALL
:
585 errmsg
= insert_normal (cd
, fields
->f_ball
, 0, 0, 19, 1, 32, total_length
, buffer
);
587 case MT_OPERAND_BALL2
:
588 errmsg
= insert_normal (cd
, fields
->f_ball2
, 0, 0, 15, 1, 32, total_length
, buffer
);
590 case MT_OPERAND_BANKADDR
:
591 errmsg
= insert_normal (cd
, fields
->f_bankaddr
, 0, 0, 25, 13, 32, total_length
, buffer
);
593 case MT_OPERAND_BRC
:
594 errmsg
= insert_normal (cd
, fields
->f_brc
, 0, 0, 18, 3, 32, total_length
, buffer
);
596 case MT_OPERAND_BRC2
:
597 errmsg
= insert_normal (cd
, fields
->f_brc2
, 0, 0, 14, 3, 32, total_length
, buffer
);
599 case MT_OPERAND_CB1INCR
:
600 errmsg
= insert_normal (cd
, fields
->f_cb1incr
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 19, 6, 32, total_length
, buffer
);
602 case MT_OPERAND_CB1SEL
:
603 errmsg
= insert_normal (cd
, fields
->f_cb1sel
, 0, 0, 25, 3, 32, total_length
, buffer
);
605 case MT_OPERAND_CB2INCR
:
606 errmsg
= insert_normal (cd
, fields
->f_cb2incr
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 13, 6, 32, total_length
, buffer
);
608 case MT_OPERAND_CB2SEL
:
609 errmsg
= insert_normal (cd
, fields
->f_cb2sel
, 0, 0, 22, 3, 32, total_length
, buffer
);
611 case MT_OPERAND_CBRB
:
612 errmsg
= insert_normal (cd
, fields
->f_cbrb
, 0, 0, 10, 1, 32, total_length
, buffer
);
614 case MT_OPERAND_CBS
:
615 errmsg
= insert_normal (cd
, fields
->f_cbs
, 0, 0, 19, 2, 32, total_length
, buffer
);
617 case MT_OPERAND_CBX
:
618 errmsg
= insert_normal (cd
, fields
->f_cbx
, 0, 0, 14, 3, 32, total_length
, buffer
);
620 case MT_OPERAND_CCB
:
621 errmsg
= insert_normal (cd
, fields
->f_ccb
, 0, 0, 11, 1, 32, total_length
, buffer
);
623 case MT_OPERAND_CDB
:
624 errmsg
= insert_normal (cd
, fields
->f_cdb
, 0, 0, 10, 1, 32, total_length
, buffer
);
626 case MT_OPERAND_CELL
:
627 errmsg
= insert_normal (cd
, fields
->f_cell
, 0, 0, 9, 3, 32, total_length
, buffer
);
629 case MT_OPERAND_COLNUM
:
630 errmsg
= insert_normal (cd
, fields
->f_colnum
, 0, 0, 18, 3, 32, total_length
, buffer
);
632 case MT_OPERAND_CONTNUM
:
633 errmsg
= insert_normal (cd
, fields
->f_contnum
, 0, 0, 8, 9, 32, total_length
, buffer
);
636 errmsg
= insert_normal (cd
, fields
->f_cr
, 0, 0, 22, 3, 32, total_length
, buffer
);
638 case MT_OPERAND_CTXDISP
:
639 errmsg
= insert_normal (cd
, fields
->f_ctxdisp
, 0, 0, 5, 6, 32, total_length
, buffer
);
641 case MT_OPERAND_DUP
:
642 errmsg
= insert_normal (cd
, fields
->f_dup
, 0, 0, 6, 1, 32, total_length
, buffer
);
644 case MT_OPERAND_FBDISP
:
645 errmsg
= insert_normal (cd
, fields
->f_fbdisp
, 0, 0, 15, 6, 32, total_length
, buffer
);
647 case MT_OPERAND_FBINCR
:
648 errmsg
= insert_normal (cd
, fields
->f_fbincr
, 0, 0, 23, 4, 32, total_length
, buffer
);
650 case MT_OPERAND_FRDR
:
651 errmsg
= insert_normal (cd
, fields
->f_dr
, 0|(1<<CGEN_IFLD_ABS_ADDR
), 0, 19, 4, 32, total_length
, buffer
);
653 case MT_OPERAND_FRDRRR
:
654 errmsg
= insert_normal (cd
, fields
->f_drrr
, 0|(1<<CGEN_IFLD_ABS_ADDR
), 0, 15, 4, 32, total_length
, buffer
);
656 case MT_OPERAND_FRSR1
:
657 errmsg
= insert_normal (cd
, fields
->f_sr1
, 0|(1<<CGEN_IFLD_ABS_ADDR
), 0, 23, 4, 32, total_length
, buffer
);
659 case MT_OPERAND_FRSR2
:
660 errmsg
= insert_normal (cd
, fields
->f_sr2
, 0|(1<<CGEN_IFLD_ABS_ADDR
), 0, 19, 4, 32, total_length
, buffer
);
663 errmsg
= insert_normal (cd
, fields
->f_id
, 0, 0, 14, 1, 32, total_length
, buffer
);
665 case MT_OPERAND_IMM16
:
667 long value
= fields
->f_imm16s
;
668 value
= ((value
) + (0));
669 errmsg
= insert_normal (cd
, value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 15, 16, 32, total_length
, buffer
);
672 case MT_OPERAND_IMM16L
:
673 errmsg
= insert_normal (cd
, fields
->f_imm16l
, 0, 0, 23, 16, 32, total_length
, buffer
);
675 case MT_OPERAND_IMM16O
:
677 long value
= fields
->f_imm16s
;
678 value
= ((value
) + (0));
679 errmsg
= insert_normal (cd
, value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 15, 16, 32, total_length
, buffer
);
682 case MT_OPERAND_IMM16Z
:
683 errmsg
= insert_normal (cd
, fields
->f_imm16u
, 0, 0, 15, 16, 32, total_length
, buffer
);
685 case MT_OPERAND_INCAMT
:
686 errmsg
= insert_normal (cd
, fields
->f_incamt
, 0, 0, 19, 8, 32, total_length
, buffer
);
688 case MT_OPERAND_INCR
:
689 errmsg
= insert_normal (cd
, fields
->f_incr
, 0, 0, 17, 6, 32, total_length
, buffer
);
691 case MT_OPERAND_LENGTH
:
692 errmsg
= insert_normal (cd
, fields
->f_length
, 0, 0, 15, 3, 32, total_length
, buffer
);
694 case MT_OPERAND_LOOPSIZE
:
696 long value
= fields
->f_loopo
;
697 value
= ((USI
) (value
) >> (2));
698 errmsg
= insert_normal (cd
, value
, 0, 0, 7, 8, 32, total_length
, buffer
);
701 case MT_OPERAND_MASK
:
702 errmsg
= insert_normal (cd
, fields
->f_mask
, 0, 0, 25, 16, 32, total_length
, buffer
);
704 case MT_OPERAND_MASK1
:
705 errmsg
= insert_normal (cd
, fields
->f_mask1
, 0, 0, 22, 3, 32, total_length
, buffer
);
707 case MT_OPERAND_MODE
:
708 errmsg
= insert_normal (cd
, fields
->f_mode
, 0, 0, 25, 2, 32, total_length
, buffer
);
710 case MT_OPERAND_PERM
:
711 errmsg
= insert_normal (cd
, fields
->f_perm
, 0, 0, 25, 2, 32, total_length
, buffer
);
713 case MT_OPERAND_RBBC
:
714 errmsg
= insert_normal (cd
, fields
->f_rbbc
, 0, 0, 25, 2, 32, total_length
, buffer
);
717 errmsg
= insert_normal (cd
, fields
->f_rc
, 0, 0, 15, 1, 32, total_length
, buffer
);
719 case MT_OPERAND_RC1
:
720 errmsg
= insert_normal (cd
, fields
->f_rc1
, 0, 0, 11, 1, 32, total_length
, buffer
);
722 case MT_OPERAND_RC2
:
723 errmsg
= insert_normal (cd
, fields
->f_rc2
, 0, 0, 6, 1, 32, total_length
, buffer
);
725 case MT_OPERAND_RC3
:
726 errmsg
= insert_normal (cd
, fields
->f_rc3
, 0, 0, 7, 1, 32, total_length
, buffer
);
728 case MT_OPERAND_RCNUM
:
729 errmsg
= insert_normal (cd
, fields
->f_rcnum
, 0, 0, 14, 3, 32, total_length
, buffer
);
731 case MT_OPERAND_RDA
:
732 errmsg
= insert_normal (cd
, fields
->f_rda
, 0, 0, 25, 1, 32, total_length
, buffer
);
734 case MT_OPERAND_ROWNUM
:
735 errmsg
= insert_normal (cd
, fields
->f_rownum
, 0, 0, 14, 3, 32, total_length
, buffer
);
737 case MT_OPERAND_ROWNUM1
:
738 errmsg
= insert_normal (cd
, fields
->f_rownum1
, 0, 0, 12, 3, 32, total_length
, buffer
);
740 case MT_OPERAND_ROWNUM2
:
741 errmsg
= insert_normal (cd
, fields
->f_rownum2
, 0, 0, 9, 3, 32, total_length
, buffer
);
743 case MT_OPERAND_SIZE
:
744 errmsg
= insert_normal (cd
, fields
->f_size
, 0, 0, 13, 14, 32, total_length
, buffer
);
746 case MT_OPERAND_TYPE
:
747 errmsg
= insert_normal (cd
, fields
->f_type
, 0, 0, 21, 2, 32, total_length
, buffer
);
750 errmsg
= insert_normal (cd
, fields
->f_wr
, 0, 0, 24, 1, 32, total_length
, buffer
);
752 case MT_OPERAND_XMODE
:
753 errmsg
= insert_normal (cd
, fields
->f_xmode
, 0, 0, 23, 1, 32, total_length
, buffer
);
757 /* xgettext:c-format */
758 opcodes_error_handler
759 (_("internal error: unrecognized field %d while building insn"),
767 int mt_cgen_extract_operand
768 (CGEN_CPU_DESC
, int, CGEN_EXTRACT_INFO
*, CGEN_INSN_INT
, CGEN_FIELDS
*, bfd_vma
);
770 /* Main entry point for operand extraction.
771 The result is <= 0 for error, >0 for success.
772 ??? Actual values aren't well defined right now.
774 This function is basically just a big switch statement. Earlier versions
775 used tables to look up the function to use, but
776 - if the table contains both assembler and disassembler functions then
777 the disassembler contains much of the assembler and vice-versa,
778 - there's a lot of inlining possibilities as things grow,
779 - using a switch statement avoids the function call overhead.
781 This function could be moved into `print_insn_normal', but keeping it
782 separate makes clear the interface between `print_insn_normal' and each of
786 mt_cgen_extract_operand (CGEN_CPU_DESC cd
,
788 CGEN_EXTRACT_INFO
*ex_info
,
789 CGEN_INSN_INT insn_value
,
790 CGEN_FIELDS
* fields
,
793 /* Assume success (for those operands that are nops). */
795 unsigned int total_length
= CGEN_FIELDS_BITSIZE (fields
);
799 case MT_OPERAND_A23
:
800 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 23, 1, 32, total_length
, pc
, & fields
->f_a23
);
802 case MT_OPERAND_BALL
:
803 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 19, 1, 32, total_length
, pc
, & fields
->f_ball
);
805 case MT_OPERAND_BALL2
:
806 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 1, 32, total_length
, pc
, & fields
->f_ball2
);
808 case MT_OPERAND_BANKADDR
:
809 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 25, 13, 32, total_length
, pc
, & fields
->f_bankaddr
);
811 case MT_OPERAND_BRC
:
812 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 18, 3, 32, total_length
, pc
, & fields
->f_brc
);
814 case MT_OPERAND_BRC2
:
815 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 14, 3, 32, total_length
, pc
, & fields
->f_brc2
);
817 case MT_OPERAND_CB1INCR
:
818 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 19, 6, 32, total_length
, pc
, & fields
->f_cb1incr
);
820 case MT_OPERAND_CB1SEL
:
821 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 25, 3, 32, total_length
, pc
, & fields
->f_cb1sel
);
823 case MT_OPERAND_CB2INCR
:
824 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 13, 6, 32, total_length
, pc
, & fields
->f_cb2incr
);
826 case MT_OPERAND_CB2SEL
:
827 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 22, 3, 32, total_length
, pc
, & fields
->f_cb2sel
);
829 case MT_OPERAND_CBRB
:
830 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 10, 1, 32, total_length
, pc
, & fields
->f_cbrb
);
832 case MT_OPERAND_CBS
:
833 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 19, 2, 32, total_length
, pc
, & fields
->f_cbs
);
835 case MT_OPERAND_CBX
:
836 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 14, 3, 32, total_length
, pc
, & fields
->f_cbx
);
838 case MT_OPERAND_CCB
:
839 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 11, 1, 32, total_length
, pc
, & fields
->f_ccb
);
841 case MT_OPERAND_CDB
:
842 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 10, 1, 32, total_length
, pc
, & fields
->f_cdb
);
844 case MT_OPERAND_CELL
:
845 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 9, 3, 32, total_length
, pc
, & fields
->f_cell
);
847 case MT_OPERAND_COLNUM
:
848 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 18, 3, 32, total_length
, pc
, & fields
->f_colnum
);
850 case MT_OPERAND_CONTNUM
:
851 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 8, 9, 32, total_length
, pc
, & fields
->f_contnum
);
854 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 22, 3, 32, total_length
, pc
, & fields
->f_cr
);
856 case MT_OPERAND_CTXDISP
:
857 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 5, 6, 32, total_length
, pc
, & fields
->f_ctxdisp
);
859 case MT_OPERAND_DUP
:
860 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 6, 1, 32, total_length
, pc
, & fields
->f_dup
);
862 case MT_OPERAND_FBDISP
:
863 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 6, 32, total_length
, pc
, & fields
->f_fbdisp
);
865 case MT_OPERAND_FBINCR
:
866 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 23, 4, 32, total_length
, pc
, & fields
->f_fbincr
);
868 case MT_OPERAND_FRDR
:
869 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_ABS_ADDR
), 0, 19, 4, 32, total_length
, pc
, & fields
->f_dr
);
871 case MT_OPERAND_FRDRRR
:
872 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_ABS_ADDR
), 0, 15, 4, 32, total_length
, pc
, & fields
->f_drrr
);
874 case MT_OPERAND_FRSR1
:
875 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_ABS_ADDR
), 0, 23, 4, 32, total_length
, pc
, & fields
->f_sr1
);
877 case MT_OPERAND_FRSR2
:
878 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_ABS_ADDR
), 0, 19, 4, 32, total_length
, pc
, & fields
->f_sr2
);
881 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 14, 1, 32, total_length
, pc
, & fields
->f_id
);
883 case MT_OPERAND_IMM16
:
886 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 15, 16, 32, total_length
, pc
, & value
);
887 value
= ((value
) + (0));
888 fields
->f_imm16s
= value
;
891 case MT_OPERAND_IMM16L
:
892 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 23, 16, 32, total_length
, pc
, & fields
->f_imm16l
);
894 case MT_OPERAND_IMM16O
:
897 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 15, 16, 32, total_length
, pc
, & value
);
898 value
= ((value
) + (0));
899 fields
->f_imm16s
= value
;
902 case MT_OPERAND_IMM16Z
:
903 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 16, 32, total_length
, pc
, & fields
->f_imm16u
);
905 case MT_OPERAND_INCAMT
:
906 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 19, 8, 32, total_length
, pc
, & fields
->f_incamt
);
908 case MT_OPERAND_INCR
:
909 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 17, 6, 32, total_length
, pc
, & fields
->f_incr
);
911 case MT_OPERAND_LENGTH
:
912 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 3, 32, total_length
, pc
, & fields
->f_length
);
914 case MT_OPERAND_LOOPSIZE
:
917 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 7, 8, 32, total_length
, pc
, & value
);
918 value
= ((((value
) << (2))) + (8));
919 fields
->f_loopo
= value
;
922 case MT_OPERAND_MASK
:
923 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 25, 16, 32, total_length
, pc
, & fields
->f_mask
);
925 case MT_OPERAND_MASK1
:
926 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 22, 3, 32, total_length
, pc
, & fields
->f_mask1
);
928 case MT_OPERAND_MODE
:
929 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 25, 2, 32, total_length
, pc
, & fields
->f_mode
);
931 case MT_OPERAND_PERM
:
932 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 25, 2, 32, total_length
, pc
, & fields
->f_perm
);
934 case MT_OPERAND_RBBC
:
935 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 25, 2, 32, total_length
, pc
, & fields
->f_rbbc
);
938 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 1, 32, total_length
, pc
, & fields
->f_rc
);
940 case MT_OPERAND_RC1
:
941 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 11, 1, 32, total_length
, pc
, & fields
->f_rc1
);
943 case MT_OPERAND_RC2
:
944 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 6, 1, 32, total_length
, pc
, & fields
->f_rc2
);
946 case MT_OPERAND_RC3
:
947 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 7, 1, 32, total_length
, pc
, & fields
->f_rc3
);
949 case MT_OPERAND_RCNUM
:
950 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 14, 3, 32, total_length
, pc
, & fields
->f_rcnum
);
952 case MT_OPERAND_RDA
:
953 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 25, 1, 32, total_length
, pc
, & fields
->f_rda
);
955 case MT_OPERAND_ROWNUM
:
956 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 14, 3, 32, total_length
, pc
, & fields
->f_rownum
);
958 case MT_OPERAND_ROWNUM1
:
959 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 12, 3, 32, total_length
, pc
, & fields
->f_rownum1
);
961 case MT_OPERAND_ROWNUM2
:
962 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 9, 3, 32, total_length
, pc
, & fields
->f_rownum2
);
964 case MT_OPERAND_SIZE
:
965 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 13, 14, 32, total_length
, pc
, & fields
->f_size
);
967 case MT_OPERAND_TYPE
:
968 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 21, 2, 32, total_length
, pc
, & fields
->f_type
);
971 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 24, 1, 32, total_length
, pc
, & fields
->f_wr
);
973 case MT_OPERAND_XMODE
:
974 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 23, 1, 32, total_length
, pc
, & fields
->f_xmode
);
978 /* xgettext:c-format */
979 opcodes_error_handler
980 (_("internal error: unrecognized field %d while decoding insn"),
988 cgen_insert_fn
* const mt_cgen_insert_handlers
[] =
993 cgen_extract_fn
* const mt_cgen_extract_handlers
[] =
998 int mt_cgen_get_int_operand (CGEN_CPU_DESC
, int, const CGEN_FIELDS
*);
999 bfd_vma
mt_cgen_get_vma_operand (CGEN_CPU_DESC
, int, const CGEN_FIELDS
*);
1001 /* Getting values from cgen_fields is handled by a collection of functions.
1002 They are distinguished by the type of the VALUE argument they return.
1003 TODO: floating point, inlining support, remove cases where result type
1007 mt_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
1009 const CGEN_FIELDS
* fields
)
1015 case MT_OPERAND_A23
:
1016 value
= fields
->f_a23
;
1018 case MT_OPERAND_BALL
:
1019 value
= fields
->f_ball
;
1021 case MT_OPERAND_BALL2
:
1022 value
= fields
->f_ball2
;
1024 case MT_OPERAND_BANKADDR
:
1025 value
= fields
->f_bankaddr
;
1027 case MT_OPERAND_BRC
:
1028 value
= fields
->f_brc
;
1030 case MT_OPERAND_BRC2
:
1031 value
= fields
->f_brc2
;
1033 case MT_OPERAND_CB1INCR
:
1034 value
= fields
->f_cb1incr
;
1036 case MT_OPERAND_CB1SEL
:
1037 value
= fields
->f_cb1sel
;
1039 case MT_OPERAND_CB2INCR
:
1040 value
= fields
->f_cb2incr
;
1042 case MT_OPERAND_CB2SEL
:
1043 value
= fields
->f_cb2sel
;
1045 case MT_OPERAND_CBRB
:
1046 value
= fields
->f_cbrb
;
1048 case MT_OPERAND_CBS
:
1049 value
= fields
->f_cbs
;
1051 case MT_OPERAND_CBX
:
1052 value
= fields
->f_cbx
;
1054 case MT_OPERAND_CCB
:
1055 value
= fields
->f_ccb
;
1057 case MT_OPERAND_CDB
:
1058 value
= fields
->f_cdb
;
1060 case MT_OPERAND_CELL
:
1061 value
= fields
->f_cell
;
1063 case MT_OPERAND_COLNUM
:
1064 value
= fields
->f_colnum
;
1066 case MT_OPERAND_CONTNUM
:
1067 value
= fields
->f_contnum
;
1069 case MT_OPERAND_CR
:
1070 value
= fields
->f_cr
;
1072 case MT_OPERAND_CTXDISP
:
1073 value
= fields
->f_ctxdisp
;
1075 case MT_OPERAND_DUP
:
1076 value
= fields
->f_dup
;
1078 case MT_OPERAND_FBDISP
:
1079 value
= fields
->f_fbdisp
;
1081 case MT_OPERAND_FBINCR
:
1082 value
= fields
->f_fbincr
;
1084 case MT_OPERAND_FRDR
:
1085 value
= fields
->f_dr
;
1087 case MT_OPERAND_FRDRRR
:
1088 value
= fields
->f_drrr
;
1090 case MT_OPERAND_FRSR1
:
1091 value
= fields
->f_sr1
;
1093 case MT_OPERAND_FRSR2
:
1094 value
= fields
->f_sr2
;
1096 case MT_OPERAND_ID
:
1097 value
= fields
->f_id
;
1099 case MT_OPERAND_IMM16
:
1100 value
= fields
->f_imm16s
;
1102 case MT_OPERAND_IMM16L
:
1103 value
= fields
->f_imm16l
;
1105 case MT_OPERAND_IMM16O
:
1106 value
= fields
->f_imm16s
;
1108 case MT_OPERAND_IMM16Z
:
1109 value
= fields
->f_imm16u
;
1111 case MT_OPERAND_INCAMT
:
1112 value
= fields
->f_incamt
;
1114 case MT_OPERAND_INCR
:
1115 value
= fields
->f_incr
;
1117 case MT_OPERAND_LENGTH
:
1118 value
= fields
->f_length
;
1120 case MT_OPERAND_LOOPSIZE
:
1121 value
= fields
->f_loopo
;
1123 case MT_OPERAND_MASK
:
1124 value
= fields
->f_mask
;
1126 case MT_OPERAND_MASK1
:
1127 value
= fields
->f_mask1
;
1129 case MT_OPERAND_MODE
:
1130 value
= fields
->f_mode
;
1132 case MT_OPERAND_PERM
:
1133 value
= fields
->f_perm
;
1135 case MT_OPERAND_RBBC
:
1136 value
= fields
->f_rbbc
;
1138 case MT_OPERAND_RC
:
1139 value
= fields
->f_rc
;
1141 case MT_OPERAND_RC1
:
1142 value
= fields
->f_rc1
;
1144 case MT_OPERAND_RC2
:
1145 value
= fields
->f_rc2
;
1147 case MT_OPERAND_RC3
:
1148 value
= fields
->f_rc3
;
1150 case MT_OPERAND_RCNUM
:
1151 value
= fields
->f_rcnum
;
1153 case MT_OPERAND_RDA
:
1154 value
= fields
->f_rda
;
1156 case MT_OPERAND_ROWNUM
:
1157 value
= fields
->f_rownum
;
1159 case MT_OPERAND_ROWNUM1
:
1160 value
= fields
->f_rownum1
;
1162 case MT_OPERAND_ROWNUM2
:
1163 value
= fields
->f_rownum2
;
1165 case MT_OPERAND_SIZE
:
1166 value
= fields
->f_size
;
1168 case MT_OPERAND_TYPE
:
1169 value
= fields
->f_type
;
1171 case MT_OPERAND_WR
:
1172 value
= fields
->f_wr
;
1174 case MT_OPERAND_XMODE
:
1175 value
= fields
->f_xmode
;
1179 /* xgettext:c-format */
1180 opcodes_error_handler
1181 (_("internal error: unrecognized field %d while getting int operand"),
1190 mt_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
1192 const CGEN_FIELDS
* fields
)
1198 case MT_OPERAND_A23
:
1199 value
= fields
->f_a23
;
1201 case MT_OPERAND_BALL
:
1202 value
= fields
->f_ball
;
1204 case MT_OPERAND_BALL2
:
1205 value
= fields
->f_ball2
;
1207 case MT_OPERAND_BANKADDR
:
1208 value
= fields
->f_bankaddr
;
1210 case MT_OPERAND_BRC
:
1211 value
= fields
->f_brc
;
1213 case MT_OPERAND_BRC2
:
1214 value
= fields
->f_brc2
;
1216 case MT_OPERAND_CB1INCR
:
1217 value
= fields
->f_cb1incr
;
1219 case MT_OPERAND_CB1SEL
:
1220 value
= fields
->f_cb1sel
;
1222 case MT_OPERAND_CB2INCR
:
1223 value
= fields
->f_cb2incr
;
1225 case MT_OPERAND_CB2SEL
:
1226 value
= fields
->f_cb2sel
;
1228 case MT_OPERAND_CBRB
:
1229 value
= fields
->f_cbrb
;
1231 case MT_OPERAND_CBS
:
1232 value
= fields
->f_cbs
;
1234 case MT_OPERAND_CBX
:
1235 value
= fields
->f_cbx
;
1237 case MT_OPERAND_CCB
:
1238 value
= fields
->f_ccb
;
1240 case MT_OPERAND_CDB
:
1241 value
= fields
->f_cdb
;
1243 case MT_OPERAND_CELL
:
1244 value
= fields
->f_cell
;
1246 case MT_OPERAND_COLNUM
:
1247 value
= fields
->f_colnum
;
1249 case MT_OPERAND_CONTNUM
:
1250 value
= fields
->f_contnum
;
1252 case MT_OPERAND_CR
:
1253 value
= fields
->f_cr
;
1255 case MT_OPERAND_CTXDISP
:
1256 value
= fields
->f_ctxdisp
;
1258 case MT_OPERAND_DUP
:
1259 value
= fields
->f_dup
;
1261 case MT_OPERAND_FBDISP
:
1262 value
= fields
->f_fbdisp
;
1264 case MT_OPERAND_FBINCR
:
1265 value
= fields
->f_fbincr
;
1267 case MT_OPERAND_FRDR
:
1268 value
= fields
->f_dr
;
1270 case MT_OPERAND_FRDRRR
:
1271 value
= fields
->f_drrr
;
1273 case MT_OPERAND_FRSR1
:
1274 value
= fields
->f_sr1
;
1276 case MT_OPERAND_FRSR2
:
1277 value
= fields
->f_sr2
;
1279 case MT_OPERAND_ID
:
1280 value
= fields
->f_id
;
1282 case MT_OPERAND_IMM16
:
1283 value
= fields
->f_imm16s
;
1285 case MT_OPERAND_IMM16L
:
1286 value
= fields
->f_imm16l
;
1288 case MT_OPERAND_IMM16O
:
1289 value
= fields
->f_imm16s
;
1291 case MT_OPERAND_IMM16Z
:
1292 value
= fields
->f_imm16u
;
1294 case MT_OPERAND_INCAMT
:
1295 value
= fields
->f_incamt
;
1297 case MT_OPERAND_INCR
:
1298 value
= fields
->f_incr
;
1300 case MT_OPERAND_LENGTH
:
1301 value
= fields
->f_length
;
1303 case MT_OPERAND_LOOPSIZE
:
1304 value
= fields
->f_loopo
;
1306 case MT_OPERAND_MASK
:
1307 value
= fields
->f_mask
;
1309 case MT_OPERAND_MASK1
:
1310 value
= fields
->f_mask1
;
1312 case MT_OPERAND_MODE
:
1313 value
= fields
->f_mode
;
1315 case MT_OPERAND_PERM
:
1316 value
= fields
->f_perm
;
1318 case MT_OPERAND_RBBC
:
1319 value
= fields
->f_rbbc
;
1321 case MT_OPERAND_RC
:
1322 value
= fields
->f_rc
;
1324 case MT_OPERAND_RC1
:
1325 value
= fields
->f_rc1
;
1327 case MT_OPERAND_RC2
:
1328 value
= fields
->f_rc2
;
1330 case MT_OPERAND_RC3
:
1331 value
= fields
->f_rc3
;
1333 case MT_OPERAND_RCNUM
:
1334 value
= fields
->f_rcnum
;
1336 case MT_OPERAND_RDA
:
1337 value
= fields
->f_rda
;
1339 case MT_OPERAND_ROWNUM
:
1340 value
= fields
->f_rownum
;
1342 case MT_OPERAND_ROWNUM1
:
1343 value
= fields
->f_rownum1
;
1345 case MT_OPERAND_ROWNUM2
:
1346 value
= fields
->f_rownum2
;
1348 case MT_OPERAND_SIZE
:
1349 value
= fields
->f_size
;
1351 case MT_OPERAND_TYPE
:
1352 value
= fields
->f_type
;
1354 case MT_OPERAND_WR
:
1355 value
= fields
->f_wr
;
1357 case MT_OPERAND_XMODE
:
1358 value
= fields
->f_xmode
;
1362 /* xgettext:c-format */
1363 opcodes_error_handler
1364 (_("internal error: unrecognized field %d while getting vma operand"),
1372 void mt_cgen_set_int_operand (CGEN_CPU_DESC
, int, CGEN_FIELDS
*, int);
1373 void mt_cgen_set_vma_operand (CGEN_CPU_DESC
, int, CGEN_FIELDS
*, bfd_vma
);
1375 /* Stuffing values in cgen_fields is handled by a collection of functions.
1376 They are distinguished by the type of the VALUE argument they accept.
1377 TODO: floating point, inlining support, remove cases where argument type
1381 mt_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
1383 CGEN_FIELDS
* fields
,
1388 case MT_OPERAND_A23
:
1389 fields
->f_a23
= value
;
1391 case MT_OPERAND_BALL
:
1392 fields
->f_ball
= value
;
1394 case MT_OPERAND_BALL2
:
1395 fields
->f_ball2
= value
;
1397 case MT_OPERAND_BANKADDR
:
1398 fields
->f_bankaddr
= value
;
1400 case MT_OPERAND_BRC
:
1401 fields
->f_brc
= value
;
1403 case MT_OPERAND_BRC2
:
1404 fields
->f_brc2
= value
;
1406 case MT_OPERAND_CB1INCR
:
1407 fields
->f_cb1incr
= value
;
1409 case MT_OPERAND_CB1SEL
:
1410 fields
->f_cb1sel
= value
;
1412 case MT_OPERAND_CB2INCR
:
1413 fields
->f_cb2incr
= value
;
1415 case MT_OPERAND_CB2SEL
:
1416 fields
->f_cb2sel
= value
;
1418 case MT_OPERAND_CBRB
:
1419 fields
->f_cbrb
= value
;
1421 case MT_OPERAND_CBS
:
1422 fields
->f_cbs
= value
;
1424 case MT_OPERAND_CBX
:
1425 fields
->f_cbx
= value
;
1427 case MT_OPERAND_CCB
:
1428 fields
->f_ccb
= value
;
1430 case MT_OPERAND_CDB
:
1431 fields
->f_cdb
= value
;
1433 case MT_OPERAND_CELL
:
1434 fields
->f_cell
= value
;
1436 case MT_OPERAND_COLNUM
:
1437 fields
->f_colnum
= value
;
1439 case MT_OPERAND_CONTNUM
:
1440 fields
->f_contnum
= value
;
1442 case MT_OPERAND_CR
:
1443 fields
->f_cr
= value
;
1445 case MT_OPERAND_CTXDISP
:
1446 fields
->f_ctxdisp
= value
;
1448 case MT_OPERAND_DUP
:
1449 fields
->f_dup
= value
;
1451 case MT_OPERAND_FBDISP
:
1452 fields
->f_fbdisp
= value
;
1454 case MT_OPERAND_FBINCR
:
1455 fields
->f_fbincr
= value
;
1457 case MT_OPERAND_FRDR
:
1458 fields
->f_dr
= value
;
1460 case MT_OPERAND_FRDRRR
:
1461 fields
->f_drrr
= value
;
1463 case MT_OPERAND_FRSR1
:
1464 fields
->f_sr1
= value
;
1466 case MT_OPERAND_FRSR2
:
1467 fields
->f_sr2
= value
;
1469 case MT_OPERAND_ID
:
1470 fields
->f_id
= value
;
1472 case MT_OPERAND_IMM16
:
1473 fields
->f_imm16s
= value
;
1475 case MT_OPERAND_IMM16L
:
1476 fields
->f_imm16l
= value
;
1478 case MT_OPERAND_IMM16O
:
1479 fields
->f_imm16s
= value
;
1481 case MT_OPERAND_IMM16Z
:
1482 fields
->f_imm16u
= value
;
1484 case MT_OPERAND_INCAMT
:
1485 fields
->f_incamt
= value
;
1487 case MT_OPERAND_INCR
:
1488 fields
->f_incr
= value
;
1490 case MT_OPERAND_LENGTH
:
1491 fields
->f_length
= value
;
1493 case MT_OPERAND_LOOPSIZE
:
1494 fields
->f_loopo
= value
;
1496 case MT_OPERAND_MASK
:
1497 fields
->f_mask
= value
;
1499 case MT_OPERAND_MASK1
:
1500 fields
->f_mask1
= value
;
1502 case MT_OPERAND_MODE
:
1503 fields
->f_mode
= value
;
1505 case MT_OPERAND_PERM
:
1506 fields
->f_perm
= value
;
1508 case MT_OPERAND_RBBC
:
1509 fields
->f_rbbc
= value
;
1511 case MT_OPERAND_RC
:
1512 fields
->f_rc
= value
;
1514 case MT_OPERAND_RC1
:
1515 fields
->f_rc1
= value
;
1517 case MT_OPERAND_RC2
:
1518 fields
->f_rc2
= value
;
1520 case MT_OPERAND_RC3
:
1521 fields
->f_rc3
= value
;
1523 case MT_OPERAND_RCNUM
:
1524 fields
->f_rcnum
= value
;
1526 case MT_OPERAND_RDA
:
1527 fields
->f_rda
= value
;
1529 case MT_OPERAND_ROWNUM
:
1530 fields
->f_rownum
= value
;
1532 case MT_OPERAND_ROWNUM1
:
1533 fields
->f_rownum1
= value
;
1535 case MT_OPERAND_ROWNUM2
:
1536 fields
->f_rownum2
= value
;
1538 case MT_OPERAND_SIZE
:
1539 fields
->f_size
= value
;
1541 case MT_OPERAND_TYPE
:
1542 fields
->f_type
= value
;
1544 case MT_OPERAND_WR
:
1545 fields
->f_wr
= value
;
1547 case MT_OPERAND_XMODE
:
1548 fields
->f_xmode
= value
;
1552 /* xgettext:c-format */
1553 opcodes_error_handler
1554 (_("internal error: unrecognized field %d while setting int operand"),
1561 mt_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
1563 CGEN_FIELDS
* fields
,
1568 case MT_OPERAND_A23
:
1569 fields
->f_a23
= value
;
1571 case MT_OPERAND_BALL
:
1572 fields
->f_ball
= value
;
1574 case MT_OPERAND_BALL2
:
1575 fields
->f_ball2
= value
;
1577 case MT_OPERAND_BANKADDR
:
1578 fields
->f_bankaddr
= value
;
1580 case MT_OPERAND_BRC
:
1581 fields
->f_brc
= value
;
1583 case MT_OPERAND_BRC2
:
1584 fields
->f_brc2
= value
;
1586 case MT_OPERAND_CB1INCR
:
1587 fields
->f_cb1incr
= value
;
1589 case MT_OPERAND_CB1SEL
:
1590 fields
->f_cb1sel
= value
;
1592 case MT_OPERAND_CB2INCR
:
1593 fields
->f_cb2incr
= value
;
1595 case MT_OPERAND_CB2SEL
:
1596 fields
->f_cb2sel
= value
;
1598 case MT_OPERAND_CBRB
:
1599 fields
->f_cbrb
= value
;
1601 case MT_OPERAND_CBS
:
1602 fields
->f_cbs
= value
;
1604 case MT_OPERAND_CBX
:
1605 fields
->f_cbx
= value
;
1607 case MT_OPERAND_CCB
:
1608 fields
->f_ccb
= value
;
1610 case MT_OPERAND_CDB
:
1611 fields
->f_cdb
= value
;
1613 case MT_OPERAND_CELL
:
1614 fields
->f_cell
= value
;
1616 case MT_OPERAND_COLNUM
:
1617 fields
->f_colnum
= value
;
1619 case MT_OPERAND_CONTNUM
:
1620 fields
->f_contnum
= value
;
1622 case MT_OPERAND_CR
:
1623 fields
->f_cr
= value
;
1625 case MT_OPERAND_CTXDISP
:
1626 fields
->f_ctxdisp
= value
;
1628 case MT_OPERAND_DUP
:
1629 fields
->f_dup
= value
;
1631 case MT_OPERAND_FBDISP
:
1632 fields
->f_fbdisp
= value
;
1634 case MT_OPERAND_FBINCR
:
1635 fields
->f_fbincr
= value
;
1637 case MT_OPERAND_FRDR
:
1638 fields
->f_dr
= value
;
1640 case MT_OPERAND_FRDRRR
:
1641 fields
->f_drrr
= value
;
1643 case MT_OPERAND_FRSR1
:
1644 fields
->f_sr1
= value
;
1646 case MT_OPERAND_FRSR2
:
1647 fields
->f_sr2
= value
;
1649 case MT_OPERAND_ID
:
1650 fields
->f_id
= value
;
1652 case MT_OPERAND_IMM16
:
1653 fields
->f_imm16s
= value
;
1655 case MT_OPERAND_IMM16L
:
1656 fields
->f_imm16l
= value
;
1658 case MT_OPERAND_IMM16O
:
1659 fields
->f_imm16s
= value
;
1661 case MT_OPERAND_IMM16Z
:
1662 fields
->f_imm16u
= value
;
1664 case MT_OPERAND_INCAMT
:
1665 fields
->f_incamt
= value
;
1667 case MT_OPERAND_INCR
:
1668 fields
->f_incr
= value
;
1670 case MT_OPERAND_LENGTH
:
1671 fields
->f_length
= value
;
1673 case MT_OPERAND_LOOPSIZE
:
1674 fields
->f_loopo
= value
;
1676 case MT_OPERAND_MASK
:
1677 fields
->f_mask
= value
;
1679 case MT_OPERAND_MASK1
:
1680 fields
->f_mask1
= value
;
1682 case MT_OPERAND_MODE
:
1683 fields
->f_mode
= value
;
1685 case MT_OPERAND_PERM
:
1686 fields
->f_perm
= value
;
1688 case MT_OPERAND_RBBC
:
1689 fields
->f_rbbc
= value
;
1691 case MT_OPERAND_RC
:
1692 fields
->f_rc
= value
;
1694 case MT_OPERAND_RC1
:
1695 fields
->f_rc1
= value
;
1697 case MT_OPERAND_RC2
:
1698 fields
->f_rc2
= value
;
1700 case MT_OPERAND_RC3
:
1701 fields
->f_rc3
= value
;
1703 case MT_OPERAND_RCNUM
:
1704 fields
->f_rcnum
= value
;
1706 case MT_OPERAND_RDA
:
1707 fields
->f_rda
= value
;
1709 case MT_OPERAND_ROWNUM
:
1710 fields
->f_rownum
= value
;
1712 case MT_OPERAND_ROWNUM1
:
1713 fields
->f_rownum1
= value
;
1715 case MT_OPERAND_ROWNUM2
:
1716 fields
->f_rownum2
= value
;
1718 case MT_OPERAND_SIZE
:
1719 fields
->f_size
= value
;
1721 case MT_OPERAND_TYPE
:
1722 fields
->f_type
= value
;
1724 case MT_OPERAND_WR
:
1725 fields
->f_wr
= value
;
1727 case MT_OPERAND_XMODE
:
1728 fields
->f_xmode
= value
;
1732 /* xgettext:c-format */
1733 opcodes_error_handler
1734 (_("internal error: unrecognized field %d while setting vma operand"),
1740 /* Function to call before using the instruction builder tables. */
1743 mt_cgen_init_ibld_table (CGEN_CPU_DESC cd
)
1745 cd
->insert_handlers
= & mt_cgen_insert_handlers
[0];
1746 cd
->extract_handlers
= & mt_cgen_extract_handlers
[0];
1748 cd
->insert_operand
= mt_cgen_insert_operand
;
1749 cd
->extract_operand
= mt_cgen_extract_operand
;
1751 cd
->get_int_operand
= mt_cgen_get_int_operand
;
1752 cd
->set_int_operand
= mt_cgen_set_int_operand
;
1753 cd
->get_vma_operand
= mt_cgen_get_vma_operand
;
1754 cd
->set_vma_operand
= mt_cgen_set_vma_operand
;