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-2019 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
,
91 x
= cgen_get_insn_value (cd
, bufp
, word_length
);
93 /* Written this way to avoid undefined behaviour. */
94 mask
= (((1L << (length
- 1)) - 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
);
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];
134 /* Written this way to avoid undefined behaviour. */
135 unsigned long mask
= (((1L << (length
- 1)) - 1) << 1) | 1;
137 /* If LENGTH is zero, this operand doesn't contribute to the value. */
141 if (word_length
> 8 * sizeof (CGEN_INSN_INT
))
144 /* For architectures with insns smaller than the base-insn-bitsize,
145 word_length may be too big. */
146 if (cd
->min_insn_bitsize
< cd
->base_insn_bitsize
)
149 && word_length
> total_length
)
150 word_length
= total_length
;
153 /* Ensure VALUE will fit. */
154 if (CGEN_BOOL_ATTR (attrs
, CGEN_IFLD_SIGN_OPT
))
156 long minval
= - (1L << (length
- 1));
157 unsigned long maxval
= mask
;
159 if ((value
> 0 && (unsigned long) value
> maxval
)
162 /* xgettext:c-format */
164 _("operand out of range (%ld not between %ld and %lu)"),
165 value
, minval
, maxval
);
169 else if (! CGEN_BOOL_ATTR (attrs
, CGEN_IFLD_SIGNED
))
171 unsigned long maxval
= mask
;
172 unsigned long val
= (unsigned long) value
;
174 /* For hosts with a word size > 32 check to see if value has been sign
175 extended beyond 32 bits. If so then ignore these higher sign bits
176 as the user is attempting to store a 32-bit signed value into an
177 unsigned 32-bit field which is allowed. */
178 if (sizeof (unsigned long) > 4 && ((value
>> 32) == -1))
183 /* xgettext:c-format */
185 _("operand out of range (0x%lx not between 0 and 0x%lx)"),
192 if (! cgen_signed_overflow_ok_p (cd
))
194 long minval
= - (1L << (length
- 1));
195 long maxval
= (1L << (length
- 1)) - 1;
197 if (value
< minval
|| value
> maxval
)
200 /* xgettext:c-format */
201 (errbuf
, _("operand out of range (%ld not between %ld and %ld)"),
202 value
, minval
, maxval
);
211 int shift_within_word
, shift_to_word
, shift
;
213 /* How to shift the value to BIT0 of the word. */
214 shift_to_word
= total_length
- (word_offset
+ word_length
);
216 /* How to shift the value to the field within the word. */
217 if (CGEN_INSN_LSB0_P
)
218 shift_within_word
= start
+ 1 - length
;
220 shift_within_word
= word_length
- start
- length
;
222 /* The total SHIFT, then mask in the value. */
223 shift
= shift_to_word
+ shift_within_word
;
224 *buffer
= (*buffer
& ~(mask
<< shift
)) | ((value
& mask
) << shift
);
227 #else /* ! CGEN_INT_INSN_P */
230 unsigned char *bufp
= (unsigned char *) buffer
+ word_offset
/ 8;
232 insert_1 (cd
, value
, start
, length
, word_length
, bufp
);
235 #endif /* ! CGEN_INT_INSN_P */
240 /* Default insn builder (insert handler).
241 The instruction is recorded in CGEN_INT_INSN_P byte order (meaning
242 that if CGEN_INSN_BYTES_PTR is an int * and thus, the value is
243 recorded in host byte order, otherwise BUFFER is an array of bytes
244 and the value is recorded in target byte order).
245 The result is an error message or NULL if success. */
248 insert_insn_normal (CGEN_CPU_DESC cd
,
249 const CGEN_INSN
* insn
,
250 CGEN_FIELDS
* fields
,
251 CGEN_INSN_BYTES_PTR buffer
,
254 const CGEN_SYNTAX
*syntax
= CGEN_INSN_SYNTAX (insn
);
256 const CGEN_SYNTAX_CHAR_TYPE
* syn
;
258 CGEN_INIT_INSERT (cd
);
259 value
= CGEN_INSN_BASE_VALUE (insn
);
261 /* If we're recording insns as numbers (rather than a string of bytes),
262 target byte order handling is deferred until later. */
266 put_insn_int_value (cd
, buffer
, cd
->base_insn_bitsize
,
267 CGEN_FIELDS_BITSIZE (fields
), value
);
271 cgen_put_insn_value (cd
, buffer
, min ((unsigned) cd
->base_insn_bitsize
,
272 (unsigned) CGEN_FIELDS_BITSIZE (fields
)),
275 #endif /* ! CGEN_INT_INSN_P */
277 /* ??? It would be better to scan the format's fields.
278 Still need to be able to insert a value based on the operand though;
279 e.g. storing a branch displacement that got resolved later.
280 Needs more thought first. */
282 for (syn
= CGEN_SYNTAX_STRING (syntax
); * syn
; ++ syn
)
286 if (CGEN_SYNTAX_CHAR_P (* syn
))
289 errmsg
= (* cd
->insert_operand
) (cd
, CGEN_SYNTAX_FIELD (*syn
),
299 /* Cover function to store an insn value into an integral insn. Must go here
300 because it needs <prefix>-desc.h for CGEN_INT_INSN_P. */
303 put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
304 CGEN_INSN_BYTES_PTR buf
,
309 /* For architectures with insns smaller than the base-insn-bitsize,
310 length may be too big. */
311 if (length
> insn_length
)
315 int shift
= insn_length
- length
;
316 /* Written this way to avoid undefined behaviour. */
317 CGEN_INSN_INT mask
= (((1L << (length
- 1)) - 1) << 1) | 1;
319 *buf
= (*buf
& ~(mask
<< shift
)) | ((value
& mask
) << shift
);
324 /* Operand extraction. */
326 #if ! CGEN_INT_INSN_P
328 /* Subroutine of extract_normal.
329 Ensure sufficient bytes are cached in EX_INFO.
330 OFFSET is the offset in bytes from the start of the insn of the value.
331 BYTES is the length of the needed value.
332 Returns 1 for success, 0 for failure. */
334 static CGEN_INLINE
int
335 fill_cache (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
336 CGEN_EXTRACT_INFO
*ex_info
,
341 /* It's doubtful that the middle part has already been fetched so
342 we don't optimize that case. kiss. */
344 disassemble_info
*info
= (disassemble_info
*) ex_info
->dis_info
;
346 /* First do a quick check. */
347 mask
= (1 << bytes
) - 1;
348 if (((ex_info
->valid
>> offset
) & mask
) == mask
)
351 /* Search for the first byte we need to read. */
352 for (mask
= 1 << offset
; bytes
> 0; --bytes
, ++offset
, mask
<<= 1)
353 if (! (mask
& ex_info
->valid
))
361 status
= (*info
->read_memory_func
)
362 (pc
, ex_info
->insn_bytes
+ offset
, bytes
, info
);
366 (*info
->memory_error_func
) (status
, pc
, info
);
370 ex_info
->valid
|= ((1 << bytes
) - 1) << offset
;
376 /* Subroutine of extract_normal. */
378 static CGEN_INLINE
long
379 extract_1 (CGEN_CPU_DESC cd
,
380 CGEN_EXTRACT_INFO
*ex_info ATTRIBUTE_UNUSED
,
385 bfd_vma pc ATTRIBUTE_UNUSED
)
390 x
= cgen_get_insn_value (cd
, bufp
, word_length
);
392 if (CGEN_INSN_LSB0_P
)
393 shift
= (start
+ 1) - length
;
395 shift
= (word_length
- (start
+ length
));
399 #endif /* ! CGEN_INT_INSN_P */
401 /* Default extraction routine.
403 INSN_VALUE is the first base_insn_bitsize bits of the insn in host order,
404 or sometimes less for cases like the m32r where the base insn size is 32
405 but some insns are 16 bits.
406 ATTRS is a mask of the boolean attributes. We only need `SIGNED',
407 but for generality we take a bitmask of all of them.
408 WORD_OFFSET is the offset in bits from the start of the insn of the value.
409 WORD_LENGTH is the length of the word in bits in which the value resides.
410 START is the starting bit number in the word, architecture origin.
411 LENGTH is the length of VALUE in bits.
412 TOTAL_LENGTH is the total length of the insn in bits.
414 Returns 1 for success, 0 for failure. */
416 /* ??? The return code isn't properly used. wip. */
418 /* ??? This doesn't handle bfd_vma's. Create another function when
422 extract_normal (CGEN_CPU_DESC cd
,
423 #if ! CGEN_INT_INSN_P
424 CGEN_EXTRACT_INFO
*ex_info
,
426 CGEN_EXTRACT_INFO
*ex_info ATTRIBUTE_UNUSED
,
428 CGEN_INSN_INT insn_value
,
430 unsigned int word_offset
,
433 unsigned int word_length
,
434 unsigned int total_length
,
435 #if ! CGEN_INT_INSN_P
438 bfd_vma pc ATTRIBUTE_UNUSED
,
444 /* If LENGTH is zero, this operand doesn't contribute to the value
445 so give it a standard value of zero. */
452 if (word_length
> 8 * sizeof (CGEN_INSN_INT
))
455 /* For architectures with insns smaller than the insn-base-bitsize,
456 word_length may be too big. */
457 if (cd
->min_insn_bitsize
< cd
->base_insn_bitsize
)
459 if (word_offset
+ word_length
> total_length
)
460 word_length
= total_length
- word_offset
;
463 /* Does the value reside in INSN_VALUE, and at the right alignment? */
465 if (CGEN_INT_INSN_P
|| (word_offset
== 0 && word_length
== total_length
))
467 if (CGEN_INSN_LSB0_P
)
468 value
= insn_value
>> ((word_offset
+ start
+ 1) - length
);
470 value
= insn_value
>> (total_length
- ( word_offset
+ start
+ length
));
473 #if ! CGEN_INT_INSN_P
477 unsigned char *bufp
= ex_info
->insn_bytes
+ word_offset
/ 8;
479 if (word_length
> 8 * sizeof (CGEN_INSN_INT
))
482 if (fill_cache (cd
, ex_info
, word_offset
/ 8, word_length
/ 8, pc
) == 0)
485 value
= extract_1 (cd
, ex_info
, start
, length
, word_length
, bufp
, pc
);
488 #endif /* ! CGEN_INT_INSN_P */
490 /* Written this way to avoid undefined behaviour. */
491 mask
= (((1L << (length
- 1)) - 1) << 1) | 1;
495 if (CGEN_BOOL_ATTR (attrs
, CGEN_IFLD_SIGNED
)
496 && (value
& (1L << (length
- 1))))
504 /* Default insn extractor.
506 INSN_VALUE is the first base_insn_bitsize bits, translated to host order.
507 The extracted fields are stored in FIELDS.
508 EX_INFO is used to handle reading variable length insns.
509 Return the length of the insn in bits, or 0 if no match,
510 or -1 if an error occurs fetching data (memory_error_func will have
514 extract_insn_normal (CGEN_CPU_DESC cd
,
515 const CGEN_INSN
*insn
,
516 CGEN_EXTRACT_INFO
*ex_info
,
517 CGEN_INSN_INT insn_value
,
521 const CGEN_SYNTAX
*syntax
= CGEN_INSN_SYNTAX (insn
);
522 const CGEN_SYNTAX_CHAR_TYPE
*syn
;
524 CGEN_FIELDS_BITSIZE (fields
) = CGEN_INSN_BITSIZE (insn
);
526 CGEN_INIT_EXTRACT (cd
);
528 for (syn
= CGEN_SYNTAX_STRING (syntax
); *syn
; ++syn
)
532 if (CGEN_SYNTAX_CHAR_P (*syn
))
535 length
= (* cd
->extract_operand
) (cd
, CGEN_SYNTAX_FIELD (*syn
),
536 ex_info
, insn_value
, fields
, pc
);
541 /* We recognized and successfully extracted this insn. */
542 return CGEN_INSN_BITSIZE (insn
);
545 /* Machine generated code added here. */
547 const char * mt_cgen_insert_operand
548 (CGEN_CPU_DESC
, int, CGEN_FIELDS
*, CGEN_INSN_BYTES_PTR
, bfd_vma
);
550 /* Main entry point for operand insertion.
552 This function is basically just a big switch statement. Earlier versions
553 used tables to look up the function to use, but
554 - if the table contains both assembler and disassembler functions then
555 the disassembler contains much of the assembler and vice-versa,
556 - there's a lot of inlining possibilities as things grow,
557 - using a switch statement avoids the function call overhead.
559 This function could be moved into `parse_insn_normal', but keeping it
560 separate makes clear the interface between `parse_insn_normal' and each of
561 the handlers. It's also needed by GAS to insert operands that couldn't be
562 resolved during parsing. */
565 mt_cgen_insert_operand (CGEN_CPU_DESC cd
,
567 CGEN_FIELDS
* fields
,
568 CGEN_INSN_BYTES_PTR buffer
,
569 bfd_vma pc ATTRIBUTE_UNUSED
)
571 const char * errmsg
= NULL
;
572 unsigned int total_length
= CGEN_FIELDS_BITSIZE (fields
);
576 case MT_OPERAND_A23
:
577 errmsg
= insert_normal (cd
, fields
->f_a23
, 0, 0, 23, 1, 32, total_length
, buffer
);
579 case MT_OPERAND_BALL
:
580 errmsg
= insert_normal (cd
, fields
->f_ball
, 0, 0, 19, 1, 32, total_length
, buffer
);
582 case MT_OPERAND_BALL2
:
583 errmsg
= insert_normal (cd
, fields
->f_ball2
, 0, 0, 15, 1, 32, total_length
, buffer
);
585 case MT_OPERAND_BANKADDR
:
586 errmsg
= insert_normal (cd
, fields
->f_bankaddr
, 0, 0, 25, 13, 32, total_length
, buffer
);
588 case MT_OPERAND_BRC
:
589 errmsg
= insert_normal (cd
, fields
->f_brc
, 0, 0, 18, 3, 32, total_length
, buffer
);
591 case MT_OPERAND_BRC2
:
592 errmsg
= insert_normal (cd
, fields
->f_brc2
, 0, 0, 14, 3, 32, total_length
, buffer
);
594 case MT_OPERAND_CB1INCR
:
595 errmsg
= insert_normal (cd
, fields
->f_cb1incr
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 19, 6, 32, total_length
, buffer
);
597 case MT_OPERAND_CB1SEL
:
598 errmsg
= insert_normal (cd
, fields
->f_cb1sel
, 0, 0, 25, 3, 32, total_length
, buffer
);
600 case MT_OPERAND_CB2INCR
:
601 errmsg
= insert_normal (cd
, fields
->f_cb2incr
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 13, 6, 32, total_length
, buffer
);
603 case MT_OPERAND_CB2SEL
:
604 errmsg
= insert_normal (cd
, fields
->f_cb2sel
, 0, 0, 22, 3, 32, total_length
, buffer
);
606 case MT_OPERAND_CBRB
:
607 errmsg
= insert_normal (cd
, fields
->f_cbrb
, 0, 0, 10, 1, 32, total_length
, buffer
);
609 case MT_OPERAND_CBS
:
610 errmsg
= insert_normal (cd
, fields
->f_cbs
, 0, 0, 19, 2, 32, total_length
, buffer
);
612 case MT_OPERAND_CBX
:
613 errmsg
= insert_normal (cd
, fields
->f_cbx
, 0, 0, 14, 3, 32, total_length
, buffer
);
615 case MT_OPERAND_CCB
:
616 errmsg
= insert_normal (cd
, fields
->f_ccb
, 0, 0, 11, 1, 32, total_length
, buffer
);
618 case MT_OPERAND_CDB
:
619 errmsg
= insert_normal (cd
, fields
->f_cdb
, 0, 0, 10, 1, 32, total_length
, buffer
);
621 case MT_OPERAND_CELL
:
622 errmsg
= insert_normal (cd
, fields
->f_cell
, 0, 0, 9, 3, 32, total_length
, buffer
);
624 case MT_OPERAND_COLNUM
:
625 errmsg
= insert_normal (cd
, fields
->f_colnum
, 0, 0, 18, 3, 32, total_length
, buffer
);
627 case MT_OPERAND_CONTNUM
:
628 errmsg
= insert_normal (cd
, fields
->f_contnum
, 0, 0, 8, 9, 32, total_length
, buffer
);
631 errmsg
= insert_normal (cd
, fields
->f_cr
, 0, 0, 22, 3, 32, total_length
, buffer
);
633 case MT_OPERAND_CTXDISP
:
634 errmsg
= insert_normal (cd
, fields
->f_ctxdisp
, 0, 0, 5, 6, 32, total_length
, buffer
);
636 case MT_OPERAND_DUP
:
637 errmsg
= insert_normal (cd
, fields
->f_dup
, 0, 0, 6, 1, 32, total_length
, buffer
);
639 case MT_OPERAND_FBDISP
:
640 errmsg
= insert_normal (cd
, fields
->f_fbdisp
, 0, 0, 15, 6, 32, total_length
, buffer
);
642 case MT_OPERAND_FBINCR
:
643 errmsg
= insert_normal (cd
, fields
->f_fbincr
, 0, 0, 23, 4, 32, total_length
, buffer
);
645 case MT_OPERAND_FRDR
:
646 errmsg
= insert_normal (cd
, fields
->f_dr
, 0|(1<<CGEN_IFLD_ABS_ADDR
), 0, 19, 4, 32, total_length
, buffer
);
648 case MT_OPERAND_FRDRRR
:
649 errmsg
= insert_normal (cd
, fields
->f_drrr
, 0|(1<<CGEN_IFLD_ABS_ADDR
), 0, 15, 4, 32, total_length
, buffer
);
651 case MT_OPERAND_FRSR1
:
652 errmsg
= insert_normal (cd
, fields
->f_sr1
, 0|(1<<CGEN_IFLD_ABS_ADDR
), 0, 23, 4, 32, total_length
, buffer
);
654 case MT_OPERAND_FRSR2
:
655 errmsg
= insert_normal (cd
, fields
->f_sr2
, 0|(1<<CGEN_IFLD_ABS_ADDR
), 0, 19, 4, 32, total_length
, buffer
);
658 errmsg
= insert_normal (cd
, fields
->f_id
, 0, 0, 14, 1, 32, total_length
, buffer
);
660 case MT_OPERAND_IMM16
:
662 long value
= fields
->f_imm16s
;
663 value
= ((value
) + (0));
664 errmsg
= insert_normal (cd
, value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 15, 16, 32, total_length
, buffer
);
667 case MT_OPERAND_IMM16L
:
668 errmsg
= insert_normal (cd
, fields
->f_imm16l
, 0, 0, 23, 16, 32, total_length
, buffer
);
670 case MT_OPERAND_IMM16O
:
672 long value
= fields
->f_imm16s
;
673 value
= ((value
) + (0));
674 errmsg
= insert_normal (cd
, value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 15, 16, 32, total_length
, buffer
);
677 case MT_OPERAND_IMM16Z
:
678 errmsg
= insert_normal (cd
, fields
->f_imm16u
, 0, 0, 15, 16, 32, total_length
, buffer
);
680 case MT_OPERAND_INCAMT
:
681 errmsg
= insert_normal (cd
, fields
->f_incamt
, 0, 0, 19, 8, 32, total_length
, buffer
);
683 case MT_OPERAND_INCR
:
684 errmsg
= insert_normal (cd
, fields
->f_incr
, 0, 0, 17, 6, 32, total_length
, buffer
);
686 case MT_OPERAND_LENGTH
:
687 errmsg
= insert_normal (cd
, fields
->f_length
, 0, 0, 15, 3, 32, total_length
, buffer
);
689 case MT_OPERAND_LOOPSIZE
:
691 long value
= fields
->f_loopo
;
692 value
= ((USI
) (value
) >> (2));
693 errmsg
= insert_normal (cd
, value
, 0, 0, 7, 8, 32, total_length
, buffer
);
696 case MT_OPERAND_MASK
:
697 errmsg
= insert_normal (cd
, fields
->f_mask
, 0, 0, 25, 16, 32, total_length
, buffer
);
699 case MT_OPERAND_MASK1
:
700 errmsg
= insert_normal (cd
, fields
->f_mask1
, 0, 0, 22, 3, 32, total_length
, buffer
);
702 case MT_OPERAND_MODE
:
703 errmsg
= insert_normal (cd
, fields
->f_mode
, 0, 0, 25, 2, 32, total_length
, buffer
);
705 case MT_OPERAND_PERM
:
706 errmsg
= insert_normal (cd
, fields
->f_perm
, 0, 0, 25, 2, 32, total_length
, buffer
);
708 case MT_OPERAND_RBBC
:
709 errmsg
= insert_normal (cd
, fields
->f_rbbc
, 0, 0, 25, 2, 32, total_length
, buffer
);
712 errmsg
= insert_normal (cd
, fields
->f_rc
, 0, 0, 15, 1, 32, total_length
, buffer
);
714 case MT_OPERAND_RC1
:
715 errmsg
= insert_normal (cd
, fields
->f_rc1
, 0, 0, 11, 1, 32, total_length
, buffer
);
717 case MT_OPERAND_RC2
:
718 errmsg
= insert_normal (cd
, fields
->f_rc2
, 0, 0, 6, 1, 32, total_length
, buffer
);
720 case MT_OPERAND_RC3
:
721 errmsg
= insert_normal (cd
, fields
->f_rc3
, 0, 0, 7, 1, 32, total_length
, buffer
);
723 case MT_OPERAND_RCNUM
:
724 errmsg
= insert_normal (cd
, fields
->f_rcnum
, 0, 0, 14, 3, 32, total_length
, buffer
);
726 case MT_OPERAND_RDA
:
727 errmsg
= insert_normal (cd
, fields
->f_rda
, 0, 0, 25, 1, 32, total_length
, buffer
);
729 case MT_OPERAND_ROWNUM
:
730 errmsg
= insert_normal (cd
, fields
->f_rownum
, 0, 0, 14, 3, 32, total_length
, buffer
);
732 case MT_OPERAND_ROWNUM1
:
733 errmsg
= insert_normal (cd
, fields
->f_rownum1
, 0, 0, 12, 3, 32, total_length
, buffer
);
735 case MT_OPERAND_ROWNUM2
:
736 errmsg
= insert_normal (cd
, fields
->f_rownum2
, 0, 0, 9, 3, 32, total_length
, buffer
);
738 case MT_OPERAND_SIZE
:
739 errmsg
= insert_normal (cd
, fields
->f_size
, 0, 0, 13, 14, 32, total_length
, buffer
);
741 case MT_OPERAND_TYPE
:
742 errmsg
= insert_normal (cd
, fields
->f_type
, 0, 0, 21, 2, 32, total_length
, buffer
);
745 errmsg
= insert_normal (cd
, fields
->f_wr
, 0, 0, 24, 1, 32, total_length
, buffer
);
747 case MT_OPERAND_XMODE
:
748 errmsg
= insert_normal (cd
, fields
->f_xmode
, 0, 0, 23, 1, 32, total_length
, buffer
);
752 /* xgettext:c-format */
753 opcodes_error_handler
754 (_("internal error: unrecognized field %d while building insn"),
762 int mt_cgen_extract_operand
763 (CGEN_CPU_DESC
, int, CGEN_EXTRACT_INFO
*, CGEN_INSN_INT
, CGEN_FIELDS
*, bfd_vma
);
765 /* Main entry point for operand extraction.
766 The result is <= 0 for error, >0 for success.
767 ??? Actual values aren't well defined right now.
769 This function is basically just a big switch statement. Earlier versions
770 used tables to look up the function to use, but
771 - if the table contains both assembler and disassembler functions then
772 the disassembler contains much of the assembler and vice-versa,
773 - there's a lot of inlining possibilities as things grow,
774 - using a switch statement avoids the function call overhead.
776 This function could be moved into `print_insn_normal', but keeping it
777 separate makes clear the interface between `print_insn_normal' and each of
781 mt_cgen_extract_operand (CGEN_CPU_DESC cd
,
783 CGEN_EXTRACT_INFO
*ex_info
,
784 CGEN_INSN_INT insn_value
,
785 CGEN_FIELDS
* fields
,
788 /* Assume success (for those operands that are nops). */
790 unsigned int total_length
= CGEN_FIELDS_BITSIZE (fields
);
794 case MT_OPERAND_A23
:
795 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 23, 1, 32, total_length
, pc
, & fields
->f_a23
);
797 case MT_OPERAND_BALL
:
798 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 19, 1, 32, total_length
, pc
, & fields
->f_ball
);
800 case MT_OPERAND_BALL2
:
801 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 1, 32, total_length
, pc
, & fields
->f_ball2
);
803 case MT_OPERAND_BANKADDR
:
804 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 25, 13, 32, total_length
, pc
, & fields
->f_bankaddr
);
806 case MT_OPERAND_BRC
:
807 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 18, 3, 32, total_length
, pc
, & fields
->f_brc
);
809 case MT_OPERAND_BRC2
:
810 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 14, 3, 32, total_length
, pc
, & fields
->f_brc2
);
812 case MT_OPERAND_CB1INCR
:
813 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 19, 6, 32, total_length
, pc
, & fields
->f_cb1incr
);
815 case MT_OPERAND_CB1SEL
:
816 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 25, 3, 32, total_length
, pc
, & fields
->f_cb1sel
);
818 case MT_OPERAND_CB2INCR
:
819 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 13, 6, 32, total_length
, pc
, & fields
->f_cb2incr
);
821 case MT_OPERAND_CB2SEL
:
822 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 22, 3, 32, total_length
, pc
, & fields
->f_cb2sel
);
824 case MT_OPERAND_CBRB
:
825 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 10, 1, 32, total_length
, pc
, & fields
->f_cbrb
);
827 case MT_OPERAND_CBS
:
828 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 19, 2, 32, total_length
, pc
, & fields
->f_cbs
);
830 case MT_OPERAND_CBX
:
831 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 14, 3, 32, total_length
, pc
, & fields
->f_cbx
);
833 case MT_OPERAND_CCB
:
834 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 11, 1, 32, total_length
, pc
, & fields
->f_ccb
);
836 case MT_OPERAND_CDB
:
837 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 10, 1, 32, total_length
, pc
, & fields
->f_cdb
);
839 case MT_OPERAND_CELL
:
840 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 9, 3, 32, total_length
, pc
, & fields
->f_cell
);
842 case MT_OPERAND_COLNUM
:
843 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 18, 3, 32, total_length
, pc
, & fields
->f_colnum
);
845 case MT_OPERAND_CONTNUM
:
846 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 8, 9, 32, total_length
, pc
, & fields
->f_contnum
);
849 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 22, 3, 32, total_length
, pc
, & fields
->f_cr
);
851 case MT_OPERAND_CTXDISP
:
852 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 5, 6, 32, total_length
, pc
, & fields
->f_ctxdisp
);
854 case MT_OPERAND_DUP
:
855 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 6, 1, 32, total_length
, pc
, & fields
->f_dup
);
857 case MT_OPERAND_FBDISP
:
858 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 6, 32, total_length
, pc
, & fields
->f_fbdisp
);
860 case MT_OPERAND_FBINCR
:
861 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 23, 4, 32, total_length
, pc
, & fields
->f_fbincr
);
863 case MT_OPERAND_FRDR
:
864 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_ABS_ADDR
), 0, 19, 4, 32, total_length
, pc
, & fields
->f_dr
);
866 case MT_OPERAND_FRDRRR
:
867 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_ABS_ADDR
), 0, 15, 4, 32, total_length
, pc
, & fields
->f_drrr
);
869 case MT_OPERAND_FRSR1
:
870 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_ABS_ADDR
), 0, 23, 4, 32, total_length
, pc
, & fields
->f_sr1
);
872 case MT_OPERAND_FRSR2
:
873 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_ABS_ADDR
), 0, 19, 4, 32, total_length
, pc
, & fields
->f_sr2
);
876 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 14, 1, 32, total_length
, pc
, & fields
->f_id
);
878 case MT_OPERAND_IMM16
:
881 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 15, 16, 32, total_length
, pc
, & value
);
882 value
= ((value
) + (0));
883 fields
->f_imm16s
= value
;
886 case MT_OPERAND_IMM16L
:
887 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 23, 16, 32, total_length
, pc
, & fields
->f_imm16l
);
889 case MT_OPERAND_IMM16O
:
892 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 15, 16, 32, total_length
, pc
, & value
);
893 value
= ((value
) + (0));
894 fields
->f_imm16s
= value
;
897 case MT_OPERAND_IMM16Z
:
898 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 16, 32, total_length
, pc
, & fields
->f_imm16u
);
900 case MT_OPERAND_INCAMT
:
901 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 19, 8, 32, total_length
, pc
, & fields
->f_incamt
);
903 case MT_OPERAND_INCR
:
904 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 17, 6, 32, total_length
, pc
, & fields
->f_incr
);
906 case MT_OPERAND_LENGTH
:
907 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 3, 32, total_length
, pc
, & fields
->f_length
);
909 case MT_OPERAND_LOOPSIZE
:
912 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 7, 8, 32, total_length
, pc
, & value
);
913 value
= ((((value
) << (2))) + (8));
914 fields
->f_loopo
= value
;
917 case MT_OPERAND_MASK
:
918 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 25, 16, 32, total_length
, pc
, & fields
->f_mask
);
920 case MT_OPERAND_MASK1
:
921 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 22, 3, 32, total_length
, pc
, & fields
->f_mask1
);
923 case MT_OPERAND_MODE
:
924 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 25, 2, 32, total_length
, pc
, & fields
->f_mode
);
926 case MT_OPERAND_PERM
:
927 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 25, 2, 32, total_length
, pc
, & fields
->f_perm
);
929 case MT_OPERAND_RBBC
:
930 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 25, 2, 32, total_length
, pc
, & fields
->f_rbbc
);
933 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 1, 32, total_length
, pc
, & fields
->f_rc
);
935 case MT_OPERAND_RC1
:
936 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 11, 1, 32, total_length
, pc
, & fields
->f_rc1
);
938 case MT_OPERAND_RC2
:
939 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 6, 1, 32, total_length
, pc
, & fields
->f_rc2
);
941 case MT_OPERAND_RC3
:
942 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 7, 1, 32, total_length
, pc
, & fields
->f_rc3
);
944 case MT_OPERAND_RCNUM
:
945 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 14, 3, 32, total_length
, pc
, & fields
->f_rcnum
);
947 case MT_OPERAND_RDA
:
948 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 25, 1, 32, total_length
, pc
, & fields
->f_rda
);
950 case MT_OPERAND_ROWNUM
:
951 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 14, 3, 32, total_length
, pc
, & fields
->f_rownum
);
953 case MT_OPERAND_ROWNUM1
:
954 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 12, 3, 32, total_length
, pc
, & fields
->f_rownum1
);
956 case MT_OPERAND_ROWNUM2
:
957 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 9, 3, 32, total_length
, pc
, & fields
->f_rownum2
);
959 case MT_OPERAND_SIZE
:
960 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 13, 14, 32, total_length
, pc
, & fields
->f_size
);
962 case MT_OPERAND_TYPE
:
963 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 21, 2, 32, total_length
, pc
, & fields
->f_type
);
966 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 24, 1, 32, total_length
, pc
, & fields
->f_wr
);
968 case MT_OPERAND_XMODE
:
969 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 23, 1, 32, total_length
, pc
, & fields
->f_xmode
);
973 /* xgettext:c-format */
974 opcodes_error_handler
975 (_("internal error: unrecognized field %d while decoding insn"),
983 cgen_insert_fn
* const mt_cgen_insert_handlers
[] =
988 cgen_extract_fn
* const mt_cgen_extract_handlers
[] =
993 int mt_cgen_get_int_operand (CGEN_CPU_DESC
, int, const CGEN_FIELDS
*);
994 bfd_vma
mt_cgen_get_vma_operand (CGEN_CPU_DESC
, int, const CGEN_FIELDS
*);
996 /* Getting values from cgen_fields is handled by a collection of functions.
997 They are distinguished by the type of the VALUE argument they return.
998 TODO: floating point, inlining support, remove cases where result type
1002 mt_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
1004 const CGEN_FIELDS
* fields
)
1010 case MT_OPERAND_A23
:
1011 value
= fields
->f_a23
;
1013 case MT_OPERAND_BALL
:
1014 value
= fields
->f_ball
;
1016 case MT_OPERAND_BALL2
:
1017 value
= fields
->f_ball2
;
1019 case MT_OPERAND_BANKADDR
:
1020 value
= fields
->f_bankaddr
;
1022 case MT_OPERAND_BRC
:
1023 value
= fields
->f_brc
;
1025 case MT_OPERAND_BRC2
:
1026 value
= fields
->f_brc2
;
1028 case MT_OPERAND_CB1INCR
:
1029 value
= fields
->f_cb1incr
;
1031 case MT_OPERAND_CB1SEL
:
1032 value
= fields
->f_cb1sel
;
1034 case MT_OPERAND_CB2INCR
:
1035 value
= fields
->f_cb2incr
;
1037 case MT_OPERAND_CB2SEL
:
1038 value
= fields
->f_cb2sel
;
1040 case MT_OPERAND_CBRB
:
1041 value
= fields
->f_cbrb
;
1043 case MT_OPERAND_CBS
:
1044 value
= fields
->f_cbs
;
1046 case MT_OPERAND_CBX
:
1047 value
= fields
->f_cbx
;
1049 case MT_OPERAND_CCB
:
1050 value
= fields
->f_ccb
;
1052 case MT_OPERAND_CDB
:
1053 value
= fields
->f_cdb
;
1055 case MT_OPERAND_CELL
:
1056 value
= fields
->f_cell
;
1058 case MT_OPERAND_COLNUM
:
1059 value
= fields
->f_colnum
;
1061 case MT_OPERAND_CONTNUM
:
1062 value
= fields
->f_contnum
;
1064 case MT_OPERAND_CR
:
1065 value
= fields
->f_cr
;
1067 case MT_OPERAND_CTXDISP
:
1068 value
= fields
->f_ctxdisp
;
1070 case MT_OPERAND_DUP
:
1071 value
= fields
->f_dup
;
1073 case MT_OPERAND_FBDISP
:
1074 value
= fields
->f_fbdisp
;
1076 case MT_OPERAND_FBINCR
:
1077 value
= fields
->f_fbincr
;
1079 case MT_OPERAND_FRDR
:
1080 value
= fields
->f_dr
;
1082 case MT_OPERAND_FRDRRR
:
1083 value
= fields
->f_drrr
;
1085 case MT_OPERAND_FRSR1
:
1086 value
= fields
->f_sr1
;
1088 case MT_OPERAND_FRSR2
:
1089 value
= fields
->f_sr2
;
1091 case MT_OPERAND_ID
:
1092 value
= fields
->f_id
;
1094 case MT_OPERAND_IMM16
:
1095 value
= fields
->f_imm16s
;
1097 case MT_OPERAND_IMM16L
:
1098 value
= fields
->f_imm16l
;
1100 case MT_OPERAND_IMM16O
:
1101 value
= fields
->f_imm16s
;
1103 case MT_OPERAND_IMM16Z
:
1104 value
= fields
->f_imm16u
;
1106 case MT_OPERAND_INCAMT
:
1107 value
= fields
->f_incamt
;
1109 case MT_OPERAND_INCR
:
1110 value
= fields
->f_incr
;
1112 case MT_OPERAND_LENGTH
:
1113 value
= fields
->f_length
;
1115 case MT_OPERAND_LOOPSIZE
:
1116 value
= fields
->f_loopo
;
1118 case MT_OPERAND_MASK
:
1119 value
= fields
->f_mask
;
1121 case MT_OPERAND_MASK1
:
1122 value
= fields
->f_mask1
;
1124 case MT_OPERAND_MODE
:
1125 value
= fields
->f_mode
;
1127 case MT_OPERAND_PERM
:
1128 value
= fields
->f_perm
;
1130 case MT_OPERAND_RBBC
:
1131 value
= fields
->f_rbbc
;
1133 case MT_OPERAND_RC
:
1134 value
= fields
->f_rc
;
1136 case MT_OPERAND_RC1
:
1137 value
= fields
->f_rc1
;
1139 case MT_OPERAND_RC2
:
1140 value
= fields
->f_rc2
;
1142 case MT_OPERAND_RC3
:
1143 value
= fields
->f_rc3
;
1145 case MT_OPERAND_RCNUM
:
1146 value
= fields
->f_rcnum
;
1148 case MT_OPERAND_RDA
:
1149 value
= fields
->f_rda
;
1151 case MT_OPERAND_ROWNUM
:
1152 value
= fields
->f_rownum
;
1154 case MT_OPERAND_ROWNUM1
:
1155 value
= fields
->f_rownum1
;
1157 case MT_OPERAND_ROWNUM2
:
1158 value
= fields
->f_rownum2
;
1160 case MT_OPERAND_SIZE
:
1161 value
= fields
->f_size
;
1163 case MT_OPERAND_TYPE
:
1164 value
= fields
->f_type
;
1166 case MT_OPERAND_WR
:
1167 value
= fields
->f_wr
;
1169 case MT_OPERAND_XMODE
:
1170 value
= fields
->f_xmode
;
1174 /* xgettext:c-format */
1175 opcodes_error_handler
1176 (_("internal error: unrecognized field %d while getting int operand"),
1185 mt_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
1187 const CGEN_FIELDS
* fields
)
1193 case MT_OPERAND_A23
:
1194 value
= fields
->f_a23
;
1196 case MT_OPERAND_BALL
:
1197 value
= fields
->f_ball
;
1199 case MT_OPERAND_BALL2
:
1200 value
= fields
->f_ball2
;
1202 case MT_OPERAND_BANKADDR
:
1203 value
= fields
->f_bankaddr
;
1205 case MT_OPERAND_BRC
:
1206 value
= fields
->f_brc
;
1208 case MT_OPERAND_BRC2
:
1209 value
= fields
->f_brc2
;
1211 case MT_OPERAND_CB1INCR
:
1212 value
= fields
->f_cb1incr
;
1214 case MT_OPERAND_CB1SEL
:
1215 value
= fields
->f_cb1sel
;
1217 case MT_OPERAND_CB2INCR
:
1218 value
= fields
->f_cb2incr
;
1220 case MT_OPERAND_CB2SEL
:
1221 value
= fields
->f_cb2sel
;
1223 case MT_OPERAND_CBRB
:
1224 value
= fields
->f_cbrb
;
1226 case MT_OPERAND_CBS
:
1227 value
= fields
->f_cbs
;
1229 case MT_OPERAND_CBX
:
1230 value
= fields
->f_cbx
;
1232 case MT_OPERAND_CCB
:
1233 value
= fields
->f_ccb
;
1235 case MT_OPERAND_CDB
:
1236 value
= fields
->f_cdb
;
1238 case MT_OPERAND_CELL
:
1239 value
= fields
->f_cell
;
1241 case MT_OPERAND_COLNUM
:
1242 value
= fields
->f_colnum
;
1244 case MT_OPERAND_CONTNUM
:
1245 value
= fields
->f_contnum
;
1247 case MT_OPERAND_CR
:
1248 value
= fields
->f_cr
;
1250 case MT_OPERAND_CTXDISP
:
1251 value
= fields
->f_ctxdisp
;
1253 case MT_OPERAND_DUP
:
1254 value
= fields
->f_dup
;
1256 case MT_OPERAND_FBDISP
:
1257 value
= fields
->f_fbdisp
;
1259 case MT_OPERAND_FBINCR
:
1260 value
= fields
->f_fbincr
;
1262 case MT_OPERAND_FRDR
:
1263 value
= fields
->f_dr
;
1265 case MT_OPERAND_FRDRRR
:
1266 value
= fields
->f_drrr
;
1268 case MT_OPERAND_FRSR1
:
1269 value
= fields
->f_sr1
;
1271 case MT_OPERAND_FRSR2
:
1272 value
= fields
->f_sr2
;
1274 case MT_OPERAND_ID
:
1275 value
= fields
->f_id
;
1277 case MT_OPERAND_IMM16
:
1278 value
= fields
->f_imm16s
;
1280 case MT_OPERAND_IMM16L
:
1281 value
= fields
->f_imm16l
;
1283 case MT_OPERAND_IMM16O
:
1284 value
= fields
->f_imm16s
;
1286 case MT_OPERAND_IMM16Z
:
1287 value
= fields
->f_imm16u
;
1289 case MT_OPERAND_INCAMT
:
1290 value
= fields
->f_incamt
;
1292 case MT_OPERAND_INCR
:
1293 value
= fields
->f_incr
;
1295 case MT_OPERAND_LENGTH
:
1296 value
= fields
->f_length
;
1298 case MT_OPERAND_LOOPSIZE
:
1299 value
= fields
->f_loopo
;
1301 case MT_OPERAND_MASK
:
1302 value
= fields
->f_mask
;
1304 case MT_OPERAND_MASK1
:
1305 value
= fields
->f_mask1
;
1307 case MT_OPERAND_MODE
:
1308 value
= fields
->f_mode
;
1310 case MT_OPERAND_PERM
:
1311 value
= fields
->f_perm
;
1313 case MT_OPERAND_RBBC
:
1314 value
= fields
->f_rbbc
;
1316 case MT_OPERAND_RC
:
1317 value
= fields
->f_rc
;
1319 case MT_OPERAND_RC1
:
1320 value
= fields
->f_rc1
;
1322 case MT_OPERAND_RC2
:
1323 value
= fields
->f_rc2
;
1325 case MT_OPERAND_RC3
:
1326 value
= fields
->f_rc3
;
1328 case MT_OPERAND_RCNUM
:
1329 value
= fields
->f_rcnum
;
1331 case MT_OPERAND_RDA
:
1332 value
= fields
->f_rda
;
1334 case MT_OPERAND_ROWNUM
:
1335 value
= fields
->f_rownum
;
1337 case MT_OPERAND_ROWNUM1
:
1338 value
= fields
->f_rownum1
;
1340 case MT_OPERAND_ROWNUM2
:
1341 value
= fields
->f_rownum2
;
1343 case MT_OPERAND_SIZE
:
1344 value
= fields
->f_size
;
1346 case MT_OPERAND_TYPE
:
1347 value
= fields
->f_type
;
1349 case MT_OPERAND_WR
:
1350 value
= fields
->f_wr
;
1352 case MT_OPERAND_XMODE
:
1353 value
= fields
->f_xmode
;
1357 /* xgettext:c-format */
1358 opcodes_error_handler
1359 (_("internal error: unrecognized field %d while getting vma operand"),
1367 void mt_cgen_set_int_operand (CGEN_CPU_DESC
, int, CGEN_FIELDS
*, int);
1368 void mt_cgen_set_vma_operand (CGEN_CPU_DESC
, int, CGEN_FIELDS
*, bfd_vma
);
1370 /* Stuffing values in cgen_fields is handled by a collection of functions.
1371 They are distinguished by the type of the VALUE argument they accept.
1372 TODO: floating point, inlining support, remove cases where argument type
1376 mt_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
1378 CGEN_FIELDS
* fields
,
1383 case MT_OPERAND_A23
:
1384 fields
->f_a23
= value
;
1386 case MT_OPERAND_BALL
:
1387 fields
->f_ball
= value
;
1389 case MT_OPERAND_BALL2
:
1390 fields
->f_ball2
= value
;
1392 case MT_OPERAND_BANKADDR
:
1393 fields
->f_bankaddr
= value
;
1395 case MT_OPERAND_BRC
:
1396 fields
->f_brc
= value
;
1398 case MT_OPERAND_BRC2
:
1399 fields
->f_brc2
= value
;
1401 case MT_OPERAND_CB1INCR
:
1402 fields
->f_cb1incr
= value
;
1404 case MT_OPERAND_CB1SEL
:
1405 fields
->f_cb1sel
= value
;
1407 case MT_OPERAND_CB2INCR
:
1408 fields
->f_cb2incr
= value
;
1410 case MT_OPERAND_CB2SEL
:
1411 fields
->f_cb2sel
= value
;
1413 case MT_OPERAND_CBRB
:
1414 fields
->f_cbrb
= value
;
1416 case MT_OPERAND_CBS
:
1417 fields
->f_cbs
= value
;
1419 case MT_OPERAND_CBX
:
1420 fields
->f_cbx
= value
;
1422 case MT_OPERAND_CCB
:
1423 fields
->f_ccb
= value
;
1425 case MT_OPERAND_CDB
:
1426 fields
->f_cdb
= value
;
1428 case MT_OPERAND_CELL
:
1429 fields
->f_cell
= value
;
1431 case MT_OPERAND_COLNUM
:
1432 fields
->f_colnum
= value
;
1434 case MT_OPERAND_CONTNUM
:
1435 fields
->f_contnum
= value
;
1437 case MT_OPERAND_CR
:
1438 fields
->f_cr
= value
;
1440 case MT_OPERAND_CTXDISP
:
1441 fields
->f_ctxdisp
= value
;
1443 case MT_OPERAND_DUP
:
1444 fields
->f_dup
= value
;
1446 case MT_OPERAND_FBDISP
:
1447 fields
->f_fbdisp
= value
;
1449 case MT_OPERAND_FBINCR
:
1450 fields
->f_fbincr
= value
;
1452 case MT_OPERAND_FRDR
:
1453 fields
->f_dr
= value
;
1455 case MT_OPERAND_FRDRRR
:
1456 fields
->f_drrr
= value
;
1458 case MT_OPERAND_FRSR1
:
1459 fields
->f_sr1
= value
;
1461 case MT_OPERAND_FRSR2
:
1462 fields
->f_sr2
= value
;
1464 case MT_OPERAND_ID
:
1465 fields
->f_id
= value
;
1467 case MT_OPERAND_IMM16
:
1468 fields
->f_imm16s
= value
;
1470 case MT_OPERAND_IMM16L
:
1471 fields
->f_imm16l
= value
;
1473 case MT_OPERAND_IMM16O
:
1474 fields
->f_imm16s
= value
;
1476 case MT_OPERAND_IMM16Z
:
1477 fields
->f_imm16u
= value
;
1479 case MT_OPERAND_INCAMT
:
1480 fields
->f_incamt
= value
;
1482 case MT_OPERAND_INCR
:
1483 fields
->f_incr
= value
;
1485 case MT_OPERAND_LENGTH
:
1486 fields
->f_length
= value
;
1488 case MT_OPERAND_LOOPSIZE
:
1489 fields
->f_loopo
= value
;
1491 case MT_OPERAND_MASK
:
1492 fields
->f_mask
= value
;
1494 case MT_OPERAND_MASK1
:
1495 fields
->f_mask1
= value
;
1497 case MT_OPERAND_MODE
:
1498 fields
->f_mode
= value
;
1500 case MT_OPERAND_PERM
:
1501 fields
->f_perm
= value
;
1503 case MT_OPERAND_RBBC
:
1504 fields
->f_rbbc
= value
;
1506 case MT_OPERAND_RC
:
1507 fields
->f_rc
= value
;
1509 case MT_OPERAND_RC1
:
1510 fields
->f_rc1
= value
;
1512 case MT_OPERAND_RC2
:
1513 fields
->f_rc2
= value
;
1515 case MT_OPERAND_RC3
:
1516 fields
->f_rc3
= value
;
1518 case MT_OPERAND_RCNUM
:
1519 fields
->f_rcnum
= value
;
1521 case MT_OPERAND_RDA
:
1522 fields
->f_rda
= value
;
1524 case MT_OPERAND_ROWNUM
:
1525 fields
->f_rownum
= value
;
1527 case MT_OPERAND_ROWNUM1
:
1528 fields
->f_rownum1
= value
;
1530 case MT_OPERAND_ROWNUM2
:
1531 fields
->f_rownum2
= value
;
1533 case MT_OPERAND_SIZE
:
1534 fields
->f_size
= value
;
1536 case MT_OPERAND_TYPE
:
1537 fields
->f_type
= value
;
1539 case MT_OPERAND_WR
:
1540 fields
->f_wr
= value
;
1542 case MT_OPERAND_XMODE
:
1543 fields
->f_xmode
= value
;
1547 /* xgettext:c-format */
1548 opcodes_error_handler
1549 (_("internal error: unrecognized field %d while setting int operand"),
1556 mt_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
1558 CGEN_FIELDS
* fields
,
1563 case MT_OPERAND_A23
:
1564 fields
->f_a23
= value
;
1566 case MT_OPERAND_BALL
:
1567 fields
->f_ball
= value
;
1569 case MT_OPERAND_BALL2
:
1570 fields
->f_ball2
= value
;
1572 case MT_OPERAND_BANKADDR
:
1573 fields
->f_bankaddr
= value
;
1575 case MT_OPERAND_BRC
:
1576 fields
->f_brc
= value
;
1578 case MT_OPERAND_BRC2
:
1579 fields
->f_brc2
= value
;
1581 case MT_OPERAND_CB1INCR
:
1582 fields
->f_cb1incr
= value
;
1584 case MT_OPERAND_CB1SEL
:
1585 fields
->f_cb1sel
= value
;
1587 case MT_OPERAND_CB2INCR
:
1588 fields
->f_cb2incr
= value
;
1590 case MT_OPERAND_CB2SEL
:
1591 fields
->f_cb2sel
= value
;
1593 case MT_OPERAND_CBRB
:
1594 fields
->f_cbrb
= value
;
1596 case MT_OPERAND_CBS
:
1597 fields
->f_cbs
= value
;
1599 case MT_OPERAND_CBX
:
1600 fields
->f_cbx
= value
;
1602 case MT_OPERAND_CCB
:
1603 fields
->f_ccb
= value
;
1605 case MT_OPERAND_CDB
:
1606 fields
->f_cdb
= value
;
1608 case MT_OPERAND_CELL
:
1609 fields
->f_cell
= value
;
1611 case MT_OPERAND_COLNUM
:
1612 fields
->f_colnum
= value
;
1614 case MT_OPERAND_CONTNUM
:
1615 fields
->f_contnum
= value
;
1617 case MT_OPERAND_CR
:
1618 fields
->f_cr
= value
;
1620 case MT_OPERAND_CTXDISP
:
1621 fields
->f_ctxdisp
= value
;
1623 case MT_OPERAND_DUP
:
1624 fields
->f_dup
= value
;
1626 case MT_OPERAND_FBDISP
:
1627 fields
->f_fbdisp
= value
;
1629 case MT_OPERAND_FBINCR
:
1630 fields
->f_fbincr
= value
;
1632 case MT_OPERAND_FRDR
:
1633 fields
->f_dr
= value
;
1635 case MT_OPERAND_FRDRRR
:
1636 fields
->f_drrr
= value
;
1638 case MT_OPERAND_FRSR1
:
1639 fields
->f_sr1
= value
;
1641 case MT_OPERAND_FRSR2
:
1642 fields
->f_sr2
= value
;
1644 case MT_OPERAND_ID
:
1645 fields
->f_id
= value
;
1647 case MT_OPERAND_IMM16
:
1648 fields
->f_imm16s
= value
;
1650 case MT_OPERAND_IMM16L
:
1651 fields
->f_imm16l
= value
;
1653 case MT_OPERAND_IMM16O
:
1654 fields
->f_imm16s
= value
;
1656 case MT_OPERAND_IMM16Z
:
1657 fields
->f_imm16u
= value
;
1659 case MT_OPERAND_INCAMT
:
1660 fields
->f_incamt
= value
;
1662 case MT_OPERAND_INCR
:
1663 fields
->f_incr
= value
;
1665 case MT_OPERAND_LENGTH
:
1666 fields
->f_length
= value
;
1668 case MT_OPERAND_LOOPSIZE
:
1669 fields
->f_loopo
= value
;
1671 case MT_OPERAND_MASK
:
1672 fields
->f_mask
= value
;
1674 case MT_OPERAND_MASK1
:
1675 fields
->f_mask1
= value
;
1677 case MT_OPERAND_MODE
:
1678 fields
->f_mode
= value
;
1680 case MT_OPERAND_PERM
:
1681 fields
->f_perm
= value
;
1683 case MT_OPERAND_RBBC
:
1684 fields
->f_rbbc
= value
;
1686 case MT_OPERAND_RC
:
1687 fields
->f_rc
= value
;
1689 case MT_OPERAND_RC1
:
1690 fields
->f_rc1
= value
;
1692 case MT_OPERAND_RC2
:
1693 fields
->f_rc2
= value
;
1695 case MT_OPERAND_RC3
:
1696 fields
->f_rc3
= value
;
1698 case MT_OPERAND_RCNUM
:
1699 fields
->f_rcnum
= value
;
1701 case MT_OPERAND_RDA
:
1702 fields
->f_rda
= value
;
1704 case MT_OPERAND_ROWNUM
:
1705 fields
->f_rownum
= value
;
1707 case MT_OPERAND_ROWNUM1
:
1708 fields
->f_rownum1
= value
;
1710 case MT_OPERAND_ROWNUM2
:
1711 fields
->f_rownum2
= value
;
1713 case MT_OPERAND_SIZE
:
1714 fields
->f_size
= value
;
1716 case MT_OPERAND_TYPE
:
1717 fields
->f_type
= value
;
1719 case MT_OPERAND_WR
:
1720 fields
->f_wr
= value
;
1722 case MT_OPERAND_XMODE
:
1723 fields
->f_xmode
= value
;
1727 /* xgettext:c-format */
1728 opcodes_error_handler
1729 (_("internal error: unrecognized field %d while setting vma operand"),
1735 /* Function to call before using the instruction builder tables. */
1738 mt_cgen_init_ibld_table (CGEN_CPU_DESC cd
)
1740 cd
->insert_handlers
= & mt_cgen_insert_handlers
[0];
1741 cd
->extract_handlers
= & mt_cgen_extract_handlers
[0];
1743 cd
->insert_operand
= mt_cgen_insert_operand
;
1744 cd
->extract_operand
= mt_cgen_extract_operand
;
1746 cd
->get_int_operand
= mt_cgen_get_int_operand
;
1747 cd
->set_int_operand
= mt_cgen_set_int_operand
;
1748 cd
->get_vma_operand
= mt_cgen_get_vma_operand
;
1749 cd
->set_vma_operand
= mt_cgen_set_vma_operand
;