]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - opcodes/mt-ibld.c
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / opcodes / mt-ibld.c
CommitLineData
4162bb66 1/* DO NOT EDIT! -*- buffer-read-only: t -*- vi:set ro: */
d031aafb 2/* Instruction building/extraction support for mt. -*- C -*-
ac188222 3
47b0e7ad
NC
4 THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator.
5 - the resultant file is machine generated, cgen-ibld.in isn't
ac188222 6
250d07de 7 Copyright (C) 1996-2021 Free Software Foundation, Inc.
ac188222 8
9b201bb5 9 This file is part of libopcodes.
ac188222 10
9b201bb5 11 This library is free software; you can redistribute it and/or modify
47b0e7ad 12 it under the terms of the GNU General Public License as published by
9b201bb5 13 the Free Software Foundation; either version 3, or (at your option)
47b0e7ad 14 any later version.
ac188222 15
9b201bb5
NC
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.
ac188222 20
47b0e7ad
NC
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. */
ac188222
DB
24
25/* ??? Eventually more and more of this stuff can go to cpu-independent files.
26 Keep that in mind. */
27
28#include "sysdep.h"
29#include <stdio.h>
30#include "ansidecl.h"
31#include "dis-asm.h"
32#include "bfd.h"
33#include "symcat.h"
d031aafb
NS
34#include "mt-desc.h"
35#include "mt-opc.h"
fe8afbc4 36#include "cgen/basic-modes.h"
ac188222
DB
37#include "opintl.h"
38#include "safe-ctype.h"
39
47b0e7ad 40#undef min
ac188222 41#define min(a,b) ((a) < (b) ? (a) : (b))
47b0e7ad 42#undef max
ac188222
DB
43#define max(a,b) ((a) > (b) ? (a) : (b))
44
45/* Used by the ifield rtx function. */
46#define FLD(f) (fields->f)
47
48static 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);
51static const char * insert_insn_normal
52 (CGEN_CPU_DESC, const CGEN_INSN *,
53 CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma);
54static 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 *);
58static int extract_insn_normal
59 (CGEN_CPU_DESC, const CGEN_INSN *, CGEN_EXTRACT_INFO *,
60 CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma);
61#if CGEN_INT_INSN_P
62static void put_insn_int_value
63 (CGEN_CPU_DESC, CGEN_INSN_BYTES_PTR, int, int, CGEN_INSN_INT);
64#endif
65#if ! CGEN_INT_INSN_P
66static CGEN_INLINE void insert_1
67 (CGEN_CPU_DESC, unsigned long, int, int, int, unsigned char *);
68static CGEN_INLINE int fill_cache
69 (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, int, int, bfd_vma);
70static CGEN_INLINE long extract_1
71 (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, int, int, int, unsigned char *, bfd_vma);
72#endif
73\f
74/* Operand insertion. */
75
76#if ! CGEN_INT_INSN_P
77
78/* Subroutine of insert_normal. */
79
80static CGEN_INLINE void
81insert_1 (CGEN_CPU_DESC cd,
82 unsigned long value,
83 int start,
84 int length,
85 int word_length,
86 unsigned char *bufp)
87{
a1e60a1b 88 unsigned long x, mask;
ac188222
DB
89 int shift;
90
e9bffec9 91 x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
ac188222
DB
92
93 /* Written this way to avoid undefined behaviour. */
a1e60a1b 94 mask = (1UL << (length - 1) << 1) - 1;
ac188222
DB
95 if (CGEN_INSN_LSB0_P)
96 shift = (start + 1) - length;
97 else
98 shift = (word_length - (start + length));
99 x = (x & ~(mask << shift)) | ((value & mask) << shift);
100
e9bffec9 101 cgen_put_insn_value (cd, bufp, word_length, (bfd_vma) x, cd->endian);
ac188222
DB
102}
103
104#endif /* ! CGEN_INT_INSN_P */
105
106/* Default insertion routine.
107
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.
114
115 The result is an error message or NULL if success. */
116
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
120 necessary. */
121
122static const char *
123insert_normal (CGEN_CPU_DESC cd,
124 long value,
125 unsigned int attrs,
126 unsigned int word_offset,
127 unsigned int start,
128 unsigned int length,
129 unsigned int word_length,
130 unsigned int total_length,
131 CGEN_INSN_BYTES_PTR buffer)
132{
133 static char errbuf[100];
a1e60a1b 134 unsigned long mask;
ac188222
DB
135
136 /* If LENGTH is zero, this operand doesn't contribute to the value. */
137 if (length == 0)
138 return NULL;
139
a1e60a1b
AM
140 /* Written this way to avoid undefined behaviour. */
141 mask = (1UL << (length - 1) << 1) - 1;
142
b7cd1872 143 if (word_length > 8 * sizeof (CGEN_INSN_INT))
ac188222
DB
144 abort ();
145
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)
149 {
150 if (word_offset == 0
151 && word_length > total_length)
152 word_length = total_length;
153 }
154
155 /* Ensure VALUE will fit. */
156 if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGN_OPT))
157 {
ae3e98b4 158 long minval = - (1UL << (length - 1));
ac188222 159 unsigned long maxval = mask;
43e65147 160
ac188222
DB
161 if ((value > 0 && (unsigned long) value > maxval)
162 || value < minval)
163 {
164 /* xgettext:c-format */
165 sprintf (errbuf,
166 _("operand out of range (%ld not between %ld and %lu)"),
167 value, minval, maxval);
168 return errbuf;
169 }
170 }
171 else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED))
172 {
173 unsigned long maxval = mask;
1620f33d
AM
174 unsigned long val = (unsigned long) value;
175
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))
181 val &= 0xFFFFFFFF;
182
183 if (val > maxval)
ac188222
DB
184 {
185 /* xgettext:c-format */
186 sprintf (errbuf,
1620f33d
AM
187 _("operand out of range (0x%lx not between 0 and 0x%lx)"),
188 val, maxval);
ac188222
DB
189 return errbuf;
190 }
191 }
192 else
193 {
194 if (! cgen_signed_overflow_ok_p (cd))
195 {
ae3e98b4
AM
196 long minval = - (1UL << (length - 1));
197 long maxval = (1UL << (length - 1)) - 1;
43e65147 198
ac188222
DB
199 if (value < minval || value > maxval)
200 {
201 sprintf
202 /* xgettext:c-format */
203 (errbuf, _("operand out of range (%ld not between %ld and %ld)"),
204 value, minval, maxval);
205 return errbuf;
206 }
207 }
208 }
209
210#if CGEN_INT_INSN_P
211
212 {
a143b004 213 int shift_within_word, shift_to_word, shift;
ac188222 214
a143b004
AB
215 /* How to shift the value to BIT0 of the word. */
216 shift_to_word = total_length - (word_offset + word_length);
217
218 /* How to shift the value to the field within the word. */
ac188222 219 if (CGEN_INSN_LSB0_P)
a143b004 220 shift_within_word = start + 1 - length;
ac188222 221 else
a143b004
AB
222 shift_within_word = word_length - start - length;
223
224 /* The total SHIFT, then mask in the value. */
225 shift = shift_to_word + shift_within_word;
ac188222
DB
226 *buffer = (*buffer & ~(mask << shift)) | ((value & mask) << shift);
227 }
228
229#else /* ! CGEN_INT_INSN_P */
230
231 {
232 unsigned char *bufp = (unsigned char *) buffer + word_offset / 8;
233
234 insert_1 (cd, value, start, length, word_length, bufp);
235 }
236
237#endif /* ! CGEN_INT_INSN_P */
238
239 return NULL;
240}
241
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. */
248
249static const char *
250insert_insn_normal (CGEN_CPU_DESC cd,
251 const CGEN_INSN * insn,
252 CGEN_FIELDS * fields,
253 CGEN_INSN_BYTES_PTR buffer,
254 bfd_vma pc)
255{
256 const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
257 unsigned long value;
258 const CGEN_SYNTAX_CHAR_TYPE * syn;
259
260 CGEN_INIT_INSERT (cd);
261 value = CGEN_INSN_BASE_VALUE (insn);
262
263 /* If we're recording insns as numbers (rather than a string of bytes),
264 target byte order handling is deferred until later. */
265
266#if CGEN_INT_INSN_P
267
268 put_insn_int_value (cd, buffer, cd->base_insn_bitsize,
269 CGEN_FIELDS_BITSIZE (fields), value);
270
271#else
272
273 cgen_put_insn_value (cd, buffer, min ((unsigned) cd->base_insn_bitsize,
e9bffec9
JM
274 (unsigned) CGEN_FIELDS_BITSIZE (fields)),
275 value, cd->insn_endian);
ac188222
DB
276
277#endif /* ! CGEN_INT_INSN_P */
278
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. */
283
284 for (syn = CGEN_SYNTAX_STRING (syntax); * syn; ++ syn)
285 {
286 const char *errmsg;
287
288 if (CGEN_SYNTAX_CHAR_P (* syn))
289 continue;
290
291 errmsg = (* cd->insert_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
292 fields, buffer, pc);
293 if (errmsg)
294 return errmsg;
295 }
296
297 return NULL;
298}
299
300#if CGEN_INT_INSN_P
301/* Cover function to store an insn value into an integral insn. Must go here
47b0e7ad 302 because it needs <prefix>-desc.h for CGEN_INT_INSN_P. */
ac188222
DB
303
304static void
305put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
306 CGEN_INSN_BYTES_PTR buf,
307 int length,
308 int insn_length,
309 CGEN_INSN_INT value)
310{
311 /* For architectures with insns smaller than the base-insn-bitsize,
312 length may be too big. */
313 if (length > insn_length)
314 *buf = value;
315 else
316 {
317 int shift = insn_length - length;
318 /* Written this way to avoid undefined behaviour. */
a1e60a1b 319 CGEN_INSN_INT mask = length == 0 ? 0 : (1UL << (length - 1) << 1) - 1;
47b0e7ad 320
ac188222
DB
321 *buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
322 }
323}
324#endif
325\f
326/* Operand extraction. */
327
328#if ! CGEN_INT_INSN_P
329
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. */
335
336static CGEN_INLINE int
337fill_cache (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
338 CGEN_EXTRACT_INFO *ex_info,
339 int offset,
340 int bytes,
341 bfd_vma pc)
342{
343 /* It's doubtful that the middle part has already been fetched so
344 we don't optimize that case. kiss. */
345 unsigned int mask;
346 disassemble_info *info = (disassemble_info *) ex_info->dis_info;
347
348 /* First do a quick check. */
349 mask = (1 << bytes) - 1;
350 if (((ex_info->valid >> offset) & mask) == mask)
351 return 1;
352
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))
356 break;
357
358 if (bytes)
359 {
360 int status;
361
362 pc += offset;
363 status = (*info->read_memory_func)
364 (pc, ex_info->insn_bytes + offset, bytes, info);
365
366 if (status != 0)
367 {
368 (*info->memory_error_func) (status, pc, info);
369 return 0;
370 }
371
372 ex_info->valid |= ((1 << bytes) - 1) << offset;
373 }
374
375 return 1;
376}
377
378/* Subroutine of extract_normal. */
379
380static CGEN_INLINE long
381extract_1 (CGEN_CPU_DESC cd,
382 CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED,
383 int start,
384 int length,
385 int word_length,
386 unsigned char *bufp,
387 bfd_vma pc ATTRIBUTE_UNUSED)
388{
389 unsigned long x;
390 int shift;
47b0e7ad 391
e9bffec9 392 x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
ac188222
DB
393
394 if (CGEN_INSN_LSB0_P)
395 shift = (start + 1) - length;
396 else
397 shift = (word_length - (start + length));
398 return x >> shift;
399}
400
401#endif /* ! CGEN_INT_INSN_P */
402
403/* Default extraction routine.
404
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.
415
416 Returns 1 for success, 0 for failure. */
417
418/* ??? The return code isn't properly used. wip. */
419
420/* ??? This doesn't handle bfd_vma's. Create another function when
421 necessary. */
422
423static int
424extract_normal (CGEN_CPU_DESC cd,
425#if ! CGEN_INT_INSN_P
426 CGEN_EXTRACT_INFO *ex_info,
427#else
428 CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED,
429#endif
430 CGEN_INSN_INT insn_value,
431 unsigned int attrs,
432 unsigned int word_offset,
433 unsigned int start,
434 unsigned int length,
435 unsigned int word_length,
436 unsigned int total_length,
437#if ! CGEN_INT_INSN_P
438 bfd_vma pc,
439#else
440 bfd_vma pc ATTRIBUTE_UNUSED,
441#endif
442 long *valuep)
443{
444 long value, mask;
445
446 /* If LENGTH is zero, this operand doesn't contribute to the value
447 so give it a standard value of zero. */
448 if (length == 0)
449 {
450 *valuep = 0;
451 return 1;
452 }
453
b7cd1872 454 if (word_length > 8 * sizeof (CGEN_INSN_INT))
ac188222
DB
455 abort ();
456
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)
460 {
1620f33d
AM
461 if (word_offset + word_length > total_length)
462 word_length = total_length - word_offset;
ac188222
DB
463 }
464
465 /* Does the value reside in INSN_VALUE, and at the right alignment? */
466
467 if (CGEN_INT_INSN_P || (word_offset == 0 && word_length == total_length))
468 {
469 if (CGEN_INSN_LSB0_P)
470 value = insn_value >> ((word_offset + start + 1) - length);
471 else
472 value = insn_value >> (total_length - ( word_offset + start + length));
473 }
474
475#if ! CGEN_INT_INSN_P
476
477 else
478 {
479 unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
480
b7cd1872 481 if (word_length > 8 * sizeof (CGEN_INSN_INT))
ac188222
DB
482 abort ();
483
484 if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
2f5dd314
AM
485 {
486 *valuep = 0;
487 return 0;
488 }
ac188222
DB
489
490 value = extract_1 (cd, ex_info, start, length, word_length, bufp, pc);
491 }
492
493#endif /* ! CGEN_INT_INSN_P */
494
495 /* Written this way to avoid undefined behaviour. */
a1e60a1b 496 mask = (1UL << (length - 1) << 1) - 1;
ac188222
DB
497
498 value &= mask;
499 /* sign extend? */
500 if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)
ae3e98b4 501 && (value & (1UL << (length - 1))))
ac188222
DB
502 value |= ~mask;
503
504 *valuep = value;
505
506 return 1;
507}
508
509/* Default insn extractor.
510
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
516 been called). */
517
518static int
519extract_insn_normal (CGEN_CPU_DESC cd,
520 const CGEN_INSN *insn,
521 CGEN_EXTRACT_INFO *ex_info,
522 CGEN_INSN_INT insn_value,
523 CGEN_FIELDS *fields,
524 bfd_vma pc)
525{
526 const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
527 const CGEN_SYNTAX_CHAR_TYPE *syn;
528
529 CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn);
530
531 CGEN_INIT_EXTRACT (cd);
532
533 for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn)
534 {
535 int length;
536
537 if (CGEN_SYNTAX_CHAR_P (*syn))
538 continue;
539
540 length = (* cd->extract_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
541 ex_info, insn_value, fields, pc);
542 if (length <= 0)
543 return length;
544 }
545
546 /* We recognized and successfully extracted this insn. */
547 return CGEN_INSN_BITSIZE (insn);
548}
549\f
47b0e7ad 550/* Machine generated code added here. */
ac188222 551
d031aafb 552const char * mt_cgen_insert_operand
47b0e7ad 553 (CGEN_CPU_DESC, int, CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma);
ac188222
DB
554
555/* Main entry point for operand insertion.
556
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.
563
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. */
568
569const char *
d031aafb 570mt_cgen_insert_operand (CGEN_CPU_DESC cd,
47b0e7ad
NC
571 int opindex,
572 CGEN_FIELDS * fields,
573 CGEN_INSN_BYTES_PTR buffer,
574 bfd_vma pc ATTRIBUTE_UNUSED)
ac188222
DB
575{
576 const char * errmsg = NULL;
577 unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
578
579 switch (opindex)
580 {
d031aafb 581 case MT_OPERAND_A23 :
ac188222
DB
582 errmsg = insert_normal (cd, fields->f_a23, 0, 0, 23, 1, 32, total_length, buffer);
583 break;
d031aafb 584 case MT_OPERAND_BALL :
ac188222
DB
585 errmsg = insert_normal (cd, fields->f_ball, 0, 0, 19, 1, 32, total_length, buffer);
586 break;
d031aafb 587 case MT_OPERAND_BALL2 :
ac188222
DB
588 errmsg = insert_normal (cd, fields->f_ball2, 0, 0, 15, 1, 32, total_length, buffer);
589 break;
d031aafb 590 case MT_OPERAND_BANKADDR :
ac188222
DB
591 errmsg = insert_normal (cd, fields->f_bankaddr, 0, 0, 25, 13, 32, total_length, buffer);
592 break;
d031aafb 593 case MT_OPERAND_BRC :
ac188222
DB
594 errmsg = insert_normal (cd, fields->f_brc, 0, 0, 18, 3, 32, total_length, buffer);
595 break;
d031aafb 596 case MT_OPERAND_BRC2 :
ac188222
DB
597 errmsg = insert_normal (cd, fields->f_brc2, 0, 0, 14, 3, 32, total_length, buffer);
598 break;
d031aafb 599 case MT_OPERAND_CB1INCR :
6f84a2a6
NS
600 errmsg = insert_normal (cd, fields->f_cb1incr, 0|(1<<CGEN_IFLD_SIGNED), 0, 19, 6, 32, total_length, buffer);
601 break;
d031aafb 602 case MT_OPERAND_CB1SEL :
6f84a2a6
NS
603 errmsg = insert_normal (cd, fields->f_cb1sel, 0, 0, 25, 3, 32, total_length, buffer);
604 break;
d031aafb 605 case MT_OPERAND_CB2INCR :
6f84a2a6
NS
606 errmsg = insert_normal (cd, fields->f_cb2incr, 0|(1<<CGEN_IFLD_SIGNED), 0, 13, 6, 32, total_length, buffer);
607 break;
d031aafb 608 case MT_OPERAND_CB2SEL :
6f84a2a6
NS
609 errmsg = insert_normal (cd, fields->f_cb2sel, 0, 0, 22, 3, 32, total_length, buffer);
610 break;
d031aafb 611 case MT_OPERAND_CBRB :
ac188222
DB
612 errmsg = insert_normal (cd, fields->f_cbrb, 0, 0, 10, 1, 32, total_length, buffer);
613 break;
d031aafb 614 case MT_OPERAND_CBS :
ac188222
DB
615 errmsg = insert_normal (cd, fields->f_cbs, 0, 0, 19, 2, 32, total_length, buffer);
616 break;
d031aafb 617 case MT_OPERAND_CBX :
ac188222
DB
618 errmsg = insert_normal (cd, fields->f_cbx, 0, 0, 14, 3, 32, total_length, buffer);
619 break;
d031aafb 620 case MT_OPERAND_CCB :
ac188222
DB
621 errmsg = insert_normal (cd, fields->f_ccb, 0, 0, 11, 1, 32, total_length, buffer);
622 break;
d031aafb 623 case MT_OPERAND_CDB :
ac188222
DB
624 errmsg = insert_normal (cd, fields->f_cdb, 0, 0, 10, 1, 32, total_length, buffer);
625 break;
d031aafb 626 case MT_OPERAND_CELL :
ac188222
DB
627 errmsg = insert_normal (cd, fields->f_cell, 0, 0, 9, 3, 32, total_length, buffer);
628 break;
d031aafb 629 case MT_OPERAND_COLNUM :
ac188222
DB
630 errmsg = insert_normal (cd, fields->f_colnum, 0, 0, 18, 3, 32, total_length, buffer);
631 break;
d031aafb 632 case MT_OPERAND_CONTNUM :
ac188222
DB
633 errmsg = insert_normal (cd, fields->f_contnum, 0, 0, 8, 9, 32, total_length, buffer);
634 break;
d031aafb 635 case MT_OPERAND_CR :
ac188222
DB
636 errmsg = insert_normal (cd, fields->f_cr, 0, 0, 22, 3, 32, total_length, buffer);
637 break;
d031aafb 638 case MT_OPERAND_CTXDISP :
ac188222
DB
639 errmsg = insert_normal (cd, fields->f_ctxdisp, 0, 0, 5, 6, 32, total_length, buffer);
640 break;
d031aafb 641 case MT_OPERAND_DUP :
ac188222
DB
642 errmsg = insert_normal (cd, fields->f_dup, 0, 0, 6, 1, 32, total_length, buffer);
643 break;
d031aafb 644 case MT_OPERAND_FBDISP :
ac188222
DB
645 errmsg = insert_normal (cd, fields->f_fbdisp, 0, 0, 15, 6, 32, total_length, buffer);
646 break;
d031aafb 647 case MT_OPERAND_FBINCR :
ac188222
DB
648 errmsg = insert_normal (cd, fields->f_fbincr, 0, 0, 23, 4, 32, total_length, buffer);
649 break;
d031aafb 650 case MT_OPERAND_FRDR :
ac188222
DB
651 errmsg = insert_normal (cd, fields->f_dr, 0|(1<<CGEN_IFLD_ABS_ADDR), 0, 19, 4, 32, total_length, buffer);
652 break;
d031aafb 653 case MT_OPERAND_FRDRRR :
ac188222
DB
654 errmsg = insert_normal (cd, fields->f_drrr, 0|(1<<CGEN_IFLD_ABS_ADDR), 0, 15, 4, 32, total_length, buffer);
655 break;
d031aafb 656 case MT_OPERAND_FRSR1 :
ac188222
DB
657 errmsg = insert_normal (cd, fields->f_sr1, 0|(1<<CGEN_IFLD_ABS_ADDR), 0, 23, 4, 32, total_length, buffer);
658 break;
d031aafb 659 case MT_OPERAND_FRSR2 :
ac188222
DB
660 errmsg = insert_normal (cd, fields->f_sr2, 0|(1<<CGEN_IFLD_ABS_ADDR), 0, 19, 4, 32, total_length, buffer);
661 break;
d031aafb 662 case MT_OPERAND_ID :
ac188222
DB
663 errmsg = insert_normal (cd, fields->f_id, 0, 0, 14, 1, 32, total_length, buffer);
664 break;
d031aafb 665 case MT_OPERAND_IMM16 :
ac188222
DB
666 {
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);
670 }
671 break;
d031aafb 672 case MT_OPERAND_IMM16L :
6f84a2a6
NS
673 errmsg = insert_normal (cd, fields->f_imm16l, 0, 0, 23, 16, 32, total_length, buffer);
674 break;
d031aafb 675 case MT_OPERAND_IMM16O :
ac188222
DB
676 {
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);
680 }
681 break;
d031aafb 682 case MT_OPERAND_IMM16Z :
ac188222
DB
683 errmsg = insert_normal (cd, fields->f_imm16u, 0, 0, 15, 16, 32, total_length, buffer);
684 break;
d031aafb 685 case MT_OPERAND_INCAMT :
ac188222
DB
686 errmsg = insert_normal (cd, fields->f_incamt, 0, 0, 19, 8, 32, total_length, buffer);
687 break;
d031aafb 688 case MT_OPERAND_INCR :
ac188222
DB
689 errmsg = insert_normal (cd, fields->f_incr, 0, 0, 17, 6, 32, total_length, buffer);
690 break;
d031aafb 691 case MT_OPERAND_LENGTH :
ac188222
DB
692 errmsg = insert_normal (cd, fields->f_length, 0, 0, 15, 3, 32, total_length, buffer);
693 break;
d031aafb 694 case MT_OPERAND_LOOPSIZE :
6f84a2a6
NS
695 {
696 long value = fields->f_loopo;
fe8afbc4 697 value = ((USI) (value) >> (2));
6f84a2a6
NS
698 errmsg = insert_normal (cd, value, 0, 0, 7, 8, 32, total_length, buffer);
699 }
700 break;
d031aafb 701 case MT_OPERAND_MASK :
ac188222
DB
702 errmsg = insert_normal (cd, fields->f_mask, 0, 0, 25, 16, 32, total_length, buffer);
703 break;
d031aafb 704 case MT_OPERAND_MASK1 :
ac188222
DB
705 errmsg = insert_normal (cd, fields->f_mask1, 0, 0, 22, 3, 32, total_length, buffer);
706 break;
d031aafb 707 case MT_OPERAND_MODE :
ac188222
DB
708 errmsg = insert_normal (cd, fields->f_mode, 0, 0, 25, 2, 32, total_length, buffer);
709 break;
d031aafb 710 case MT_OPERAND_PERM :
ac188222
DB
711 errmsg = insert_normal (cd, fields->f_perm, 0, 0, 25, 2, 32, total_length, buffer);
712 break;
d031aafb 713 case MT_OPERAND_RBBC :
ac188222
DB
714 errmsg = insert_normal (cd, fields->f_rbbc, 0, 0, 25, 2, 32, total_length, buffer);
715 break;
d031aafb 716 case MT_OPERAND_RC :
ac188222
DB
717 errmsg = insert_normal (cd, fields->f_rc, 0, 0, 15, 1, 32, total_length, buffer);
718 break;
d031aafb 719 case MT_OPERAND_RC1 :
ac188222
DB
720 errmsg = insert_normal (cd, fields->f_rc1, 0, 0, 11, 1, 32, total_length, buffer);
721 break;
d031aafb 722 case MT_OPERAND_RC2 :
ac188222
DB
723 errmsg = insert_normal (cd, fields->f_rc2, 0, 0, 6, 1, 32, total_length, buffer);
724 break;
d031aafb 725 case MT_OPERAND_RC3 :
6f84a2a6
NS
726 errmsg = insert_normal (cd, fields->f_rc3, 0, 0, 7, 1, 32, total_length, buffer);
727 break;
d031aafb 728 case MT_OPERAND_RCNUM :
ac188222
DB
729 errmsg = insert_normal (cd, fields->f_rcnum, 0, 0, 14, 3, 32, total_length, buffer);
730 break;
d031aafb 731 case MT_OPERAND_RDA :
ac188222
DB
732 errmsg = insert_normal (cd, fields->f_rda, 0, 0, 25, 1, 32, total_length, buffer);
733 break;
d031aafb 734 case MT_OPERAND_ROWNUM :
ac188222
DB
735 errmsg = insert_normal (cd, fields->f_rownum, 0, 0, 14, 3, 32, total_length, buffer);
736 break;
d031aafb 737 case MT_OPERAND_ROWNUM1 :
ac188222
DB
738 errmsg = insert_normal (cd, fields->f_rownum1, 0, 0, 12, 3, 32, total_length, buffer);
739 break;
d031aafb 740 case MT_OPERAND_ROWNUM2 :
ac188222
DB
741 errmsg = insert_normal (cd, fields->f_rownum2, 0, 0, 9, 3, 32, total_length, buffer);
742 break;
d031aafb 743 case MT_OPERAND_SIZE :
ac188222
DB
744 errmsg = insert_normal (cd, fields->f_size, 0, 0, 13, 14, 32, total_length, buffer);
745 break;
d031aafb 746 case MT_OPERAND_TYPE :
ac188222
DB
747 errmsg = insert_normal (cd, fields->f_type, 0, 0, 21, 2, 32, total_length, buffer);
748 break;
d031aafb 749 case MT_OPERAND_WR :
ac188222
DB
750 errmsg = insert_normal (cd, fields->f_wr, 0, 0, 24, 1, 32, total_length, buffer);
751 break;
d031aafb 752 case MT_OPERAND_XMODE :
ac188222
DB
753 errmsg = insert_normal (cd, fields->f_xmode, 0, 0, 23, 1, 32, total_length, buffer);
754 break;
755
756 default :
757 /* xgettext:c-format */
a6743a54
AM
758 opcodes_error_handler
759 (_("internal error: unrecognized field %d while building insn"),
760 opindex);
ac188222
DB
761 abort ();
762 }
763
764 return errmsg;
765}
766
d031aafb 767int mt_cgen_extract_operand
47b0e7ad 768 (CGEN_CPU_DESC, int, CGEN_EXTRACT_INFO *, CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma);
ac188222
DB
769
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.
773
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.
780
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
783 the handlers. */
784
785int
d031aafb 786mt_cgen_extract_operand (CGEN_CPU_DESC cd,
47b0e7ad
NC
787 int opindex,
788 CGEN_EXTRACT_INFO *ex_info,
789 CGEN_INSN_INT insn_value,
790 CGEN_FIELDS * fields,
791 bfd_vma pc)
ac188222
DB
792{
793 /* Assume success (for those operands that are nops). */
794 int length = 1;
795 unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
796
797 switch (opindex)
798 {
d031aafb 799 case MT_OPERAND_A23 :
ac188222
DB
800 length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 1, 32, total_length, pc, & fields->f_a23);
801 break;
d031aafb 802 case MT_OPERAND_BALL :
ac188222
DB
803 length = extract_normal (cd, ex_info, insn_value, 0, 0, 19, 1, 32, total_length, pc, & fields->f_ball);
804 break;
d031aafb 805 case MT_OPERAND_BALL2 :
ac188222
DB
806 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 1, 32, total_length, pc, & fields->f_ball2);
807 break;
d031aafb 808 case MT_OPERAND_BANKADDR :
ac188222
DB
809 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 13, 32, total_length, pc, & fields->f_bankaddr);
810 break;
d031aafb 811 case MT_OPERAND_BRC :
ac188222
DB
812 length = extract_normal (cd, ex_info, insn_value, 0, 0, 18, 3, 32, total_length, pc, & fields->f_brc);
813 break;
d031aafb 814 case MT_OPERAND_BRC2 :
ac188222
DB
815 length = extract_normal (cd, ex_info, insn_value, 0, 0, 14, 3, 32, total_length, pc, & fields->f_brc2);
816 break;
d031aafb 817 case MT_OPERAND_CB1INCR :
6f84a2a6
NS
818 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 19, 6, 32, total_length, pc, & fields->f_cb1incr);
819 break;
d031aafb 820 case MT_OPERAND_CB1SEL :
6f84a2a6
NS
821 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 3, 32, total_length, pc, & fields->f_cb1sel);
822 break;
d031aafb 823 case MT_OPERAND_CB2INCR :
6f84a2a6
NS
824 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 13, 6, 32, total_length, pc, & fields->f_cb2incr);
825 break;
d031aafb 826 case MT_OPERAND_CB2SEL :
6f84a2a6
NS
827 length = extract_normal (cd, ex_info, insn_value, 0, 0, 22, 3, 32, total_length, pc, & fields->f_cb2sel);
828 break;
d031aafb 829 case MT_OPERAND_CBRB :
ac188222
DB
830 length = extract_normal (cd, ex_info, insn_value, 0, 0, 10, 1, 32, total_length, pc, & fields->f_cbrb);
831 break;
d031aafb 832 case MT_OPERAND_CBS :
ac188222
DB
833 length = extract_normal (cd, ex_info, insn_value, 0, 0, 19, 2, 32, total_length, pc, & fields->f_cbs);
834 break;
d031aafb 835 case MT_OPERAND_CBX :
ac188222
DB
836 length = extract_normal (cd, ex_info, insn_value, 0, 0, 14, 3, 32, total_length, pc, & fields->f_cbx);
837 break;
d031aafb 838 case MT_OPERAND_CCB :
ac188222
DB
839 length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 1, 32, total_length, pc, & fields->f_ccb);
840 break;
d031aafb 841 case MT_OPERAND_CDB :
ac188222
DB
842 length = extract_normal (cd, ex_info, insn_value, 0, 0, 10, 1, 32, total_length, pc, & fields->f_cdb);
843 break;
d031aafb 844 case MT_OPERAND_CELL :
ac188222
DB
845 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_cell);
846 break;
d031aafb 847 case MT_OPERAND_COLNUM :
ac188222
DB
848 length = extract_normal (cd, ex_info, insn_value, 0, 0, 18, 3, 32, total_length, pc, & fields->f_colnum);
849 break;
d031aafb 850 case MT_OPERAND_CONTNUM :
ac188222
DB
851 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 9, 32, total_length, pc, & fields->f_contnum);
852 break;
d031aafb 853 case MT_OPERAND_CR :
ac188222
DB
854 length = extract_normal (cd, ex_info, insn_value, 0, 0, 22, 3, 32, total_length, pc, & fields->f_cr);
855 break;
d031aafb 856 case MT_OPERAND_CTXDISP :
ac188222
DB
857 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_ctxdisp);
858 break;
d031aafb 859 case MT_OPERAND_DUP :
ac188222
DB
860 length = extract_normal (cd, ex_info, insn_value, 0, 0, 6, 1, 32, total_length, pc, & fields->f_dup);
861 break;
d031aafb 862 case MT_OPERAND_FBDISP :
ac188222
DB
863 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 6, 32, total_length, pc, & fields->f_fbdisp);
864 break;
d031aafb 865 case MT_OPERAND_FBINCR :
ac188222
DB
866 length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 4, 32, total_length, pc, & fields->f_fbincr);
867 break;
d031aafb 868 case MT_OPERAND_FRDR :
ac188222
DB
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);
870 break;
d031aafb 871 case MT_OPERAND_FRDRRR :
ac188222
DB
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);
873 break;
d031aafb 874 case MT_OPERAND_FRSR1 :
ac188222
DB
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);
876 break;
d031aafb 877 case MT_OPERAND_FRSR2 :
ac188222
DB
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);
879 break;
d031aafb 880 case MT_OPERAND_ID :
ac188222
DB
881 length = extract_normal (cd, ex_info, insn_value, 0, 0, 14, 1, 32, total_length, pc, & fields->f_id);
882 break;
d031aafb 883 case MT_OPERAND_IMM16 :
ac188222
DB
884 {
885 long value;
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;
889 }
890 break;
d031aafb 891 case MT_OPERAND_IMM16L :
6f84a2a6
NS
892 length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 16, 32, total_length, pc, & fields->f_imm16l);
893 break;
d031aafb 894 case MT_OPERAND_IMM16O :
ac188222
DB
895 {
896 long value;
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;
900 }
901 break;
d031aafb 902 case MT_OPERAND_IMM16Z :
ac188222
DB
903 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_imm16u);
904 break;
d031aafb 905 case MT_OPERAND_INCAMT :
ac188222
DB
906 length = extract_normal (cd, ex_info, insn_value, 0, 0, 19, 8, 32, total_length, pc, & fields->f_incamt);
907 break;
d031aafb 908 case MT_OPERAND_INCR :
ac188222
DB
909 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_incr);
910 break;
d031aafb 911 case MT_OPERAND_LENGTH :
ac188222
DB
912 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_length);
913 break;
d031aafb 914 case MT_OPERAND_LOOPSIZE :
6f84a2a6
NS
915 {
916 long value;
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;
920 }
921 break;
d031aafb 922 case MT_OPERAND_MASK :
ac188222
DB
923 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 16, 32, total_length, pc, & fields->f_mask);
924 break;
d031aafb 925 case MT_OPERAND_MASK1 :
ac188222
DB
926 length = extract_normal (cd, ex_info, insn_value, 0, 0, 22, 3, 32, total_length, pc, & fields->f_mask1);
927 break;
d031aafb 928 case MT_OPERAND_MODE :
ac188222
DB
929 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 2, 32, total_length, pc, & fields->f_mode);
930 break;
d031aafb 931 case MT_OPERAND_PERM :
ac188222
DB
932 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 2, 32, total_length, pc, & fields->f_perm);
933 break;
d031aafb 934 case MT_OPERAND_RBBC :
ac188222
DB
935 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 2, 32, total_length, pc, & fields->f_rbbc);
936 break;
d031aafb 937 case MT_OPERAND_RC :
ac188222
DB
938 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 1, 32, total_length, pc, & fields->f_rc);
939 break;
d031aafb 940 case MT_OPERAND_RC1 :
ac188222
DB
941 length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 1, 32, total_length, pc, & fields->f_rc1);
942 break;
d031aafb 943 case MT_OPERAND_RC2 :
ac188222
DB
944 length = extract_normal (cd, ex_info, insn_value, 0, 0, 6, 1, 32, total_length, pc, & fields->f_rc2);
945 break;
d031aafb 946 case MT_OPERAND_RC3 :
6f84a2a6
NS
947 length = extract_normal (cd, ex_info, insn_value, 0, 0, 7, 1, 32, total_length, pc, & fields->f_rc3);
948 break;
d031aafb 949 case MT_OPERAND_RCNUM :
ac188222
DB
950 length = extract_normal (cd, ex_info, insn_value, 0, 0, 14, 3, 32, total_length, pc, & fields->f_rcnum);
951 break;
d031aafb 952 case MT_OPERAND_RDA :
ac188222
DB
953 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_rda);
954 break;
d031aafb 955 case MT_OPERAND_ROWNUM :
ac188222
DB
956 length = extract_normal (cd, ex_info, insn_value, 0, 0, 14, 3, 32, total_length, pc, & fields->f_rownum);
957 break;
d031aafb 958 case MT_OPERAND_ROWNUM1 :
ac188222
DB
959 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_rownum1);
960 break;
d031aafb 961 case MT_OPERAND_ROWNUM2 :
ac188222
DB
962 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_rownum2);
963 break;
d031aafb 964 case MT_OPERAND_SIZE :
ac188222
DB
965 length = extract_normal (cd, ex_info, insn_value, 0, 0, 13, 14, 32, total_length, pc, & fields->f_size);
966 break;
d031aafb 967 case MT_OPERAND_TYPE :
ac188222
DB
968 length = extract_normal (cd, ex_info, insn_value, 0, 0, 21, 2, 32, total_length, pc, & fields->f_type);
969 break;
d031aafb 970 case MT_OPERAND_WR :
ac188222
DB
971 length = extract_normal (cd, ex_info, insn_value, 0, 0, 24, 1, 32, total_length, pc, & fields->f_wr);
972 break;
d031aafb 973 case MT_OPERAND_XMODE :
ac188222
DB
974 length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 1, 32, total_length, pc, & fields->f_xmode);
975 break;
976
977 default :
978 /* xgettext:c-format */
a6743a54
AM
979 opcodes_error_handler
980 (_("internal error: unrecognized field %d while decoding insn"),
981 opindex);
ac188222
DB
982 abort ();
983 }
984
985 return length;
986}
987
43e65147 988cgen_insert_fn * const mt_cgen_insert_handlers[] =
ac188222
DB
989{
990 insert_insn_normal,
991};
992
43e65147 993cgen_extract_fn * const mt_cgen_extract_handlers[] =
ac188222
DB
994{
995 extract_insn_normal,
996};
997
d031aafb
NS
998int mt_cgen_get_int_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *);
999bfd_vma mt_cgen_get_vma_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *);
ac188222
DB
1000
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
1004 not appropriate. */
1005
1006int
d031aafb 1007mt_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
47b0e7ad
NC
1008 int opindex,
1009 const CGEN_FIELDS * fields)
ac188222
DB
1010{
1011 int value;
1012
1013 switch (opindex)
1014 {
d031aafb 1015 case MT_OPERAND_A23 :
ac188222
DB
1016 value = fields->f_a23;
1017 break;
d031aafb 1018 case MT_OPERAND_BALL :
ac188222
DB
1019 value = fields->f_ball;
1020 break;
d031aafb 1021 case MT_OPERAND_BALL2 :
ac188222
DB
1022 value = fields->f_ball2;
1023 break;
d031aafb 1024 case MT_OPERAND_BANKADDR :
ac188222
DB
1025 value = fields->f_bankaddr;
1026 break;
d031aafb 1027 case MT_OPERAND_BRC :
ac188222
DB
1028 value = fields->f_brc;
1029 break;
d031aafb 1030 case MT_OPERAND_BRC2 :
ac188222
DB
1031 value = fields->f_brc2;
1032 break;
d031aafb 1033 case MT_OPERAND_CB1INCR :
6f84a2a6
NS
1034 value = fields->f_cb1incr;
1035 break;
d031aafb 1036 case MT_OPERAND_CB1SEL :
6f84a2a6
NS
1037 value = fields->f_cb1sel;
1038 break;
d031aafb 1039 case MT_OPERAND_CB2INCR :
6f84a2a6
NS
1040 value = fields->f_cb2incr;
1041 break;
d031aafb 1042 case MT_OPERAND_CB2SEL :
6f84a2a6
NS
1043 value = fields->f_cb2sel;
1044 break;
d031aafb 1045 case MT_OPERAND_CBRB :
ac188222
DB
1046 value = fields->f_cbrb;
1047 break;
d031aafb 1048 case MT_OPERAND_CBS :
ac188222
DB
1049 value = fields->f_cbs;
1050 break;
d031aafb 1051 case MT_OPERAND_CBX :
ac188222
DB
1052 value = fields->f_cbx;
1053 break;
d031aafb 1054 case MT_OPERAND_CCB :
ac188222
DB
1055 value = fields->f_ccb;
1056 break;
d031aafb 1057 case MT_OPERAND_CDB :
ac188222
DB
1058 value = fields->f_cdb;
1059 break;
d031aafb 1060 case MT_OPERAND_CELL :
ac188222
DB
1061 value = fields->f_cell;
1062 break;
d031aafb 1063 case MT_OPERAND_COLNUM :
ac188222
DB
1064 value = fields->f_colnum;
1065 break;
d031aafb 1066 case MT_OPERAND_CONTNUM :
ac188222
DB
1067 value = fields->f_contnum;
1068 break;
d031aafb 1069 case MT_OPERAND_CR :
ac188222
DB
1070 value = fields->f_cr;
1071 break;
d031aafb 1072 case MT_OPERAND_CTXDISP :
ac188222
DB
1073 value = fields->f_ctxdisp;
1074 break;
d031aafb 1075 case MT_OPERAND_DUP :
ac188222
DB
1076 value = fields->f_dup;
1077 break;
d031aafb 1078 case MT_OPERAND_FBDISP :
ac188222
DB
1079 value = fields->f_fbdisp;
1080 break;
d031aafb 1081 case MT_OPERAND_FBINCR :
ac188222
DB
1082 value = fields->f_fbincr;
1083 break;
d031aafb 1084 case MT_OPERAND_FRDR :
ac188222
DB
1085 value = fields->f_dr;
1086 break;
d031aafb 1087 case MT_OPERAND_FRDRRR :
ac188222
DB
1088 value = fields->f_drrr;
1089 break;
d031aafb 1090 case MT_OPERAND_FRSR1 :
ac188222
DB
1091 value = fields->f_sr1;
1092 break;
d031aafb 1093 case MT_OPERAND_FRSR2 :
ac188222
DB
1094 value = fields->f_sr2;
1095 break;
d031aafb 1096 case MT_OPERAND_ID :
ac188222
DB
1097 value = fields->f_id;
1098 break;
d031aafb 1099 case MT_OPERAND_IMM16 :
ac188222
DB
1100 value = fields->f_imm16s;
1101 break;
d031aafb 1102 case MT_OPERAND_IMM16L :
6f84a2a6
NS
1103 value = fields->f_imm16l;
1104 break;
d031aafb 1105 case MT_OPERAND_IMM16O :
ac188222
DB
1106 value = fields->f_imm16s;
1107 break;
d031aafb 1108 case MT_OPERAND_IMM16Z :
ac188222
DB
1109 value = fields->f_imm16u;
1110 break;
d031aafb 1111 case MT_OPERAND_INCAMT :
ac188222
DB
1112 value = fields->f_incamt;
1113 break;
d031aafb 1114 case MT_OPERAND_INCR :
ac188222
DB
1115 value = fields->f_incr;
1116 break;
d031aafb 1117 case MT_OPERAND_LENGTH :
ac188222
DB
1118 value = fields->f_length;
1119 break;
d031aafb 1120 case MT_OPERAND_LOOPSIZE :
6f84a2a6
NS
1121 value = fields->f_loopo;
1122 break;
d031aafb 1123 case MT_OPERAND_MASK :
ac188222
DB
1124 value = fields->f_mask;
1125 break;
d031aafb 1126 case MT_OPERAND_MASK1 :
ac188222
DB
1127 value = fields->f_mask1;
1128 break;
d031aafb 1129 case MT_OPERAND_MODE :
ac188222
DB
1130 value = fields->f_mode;
1131 break;
d031aafb 1132 case MT_OPERAND_PERM :
ac188222
DB
1133 value = fields->f_perm;
1134 break;
d031aafb 1135 case MT_OPERAND_RBBC :
ac188222
DB
1136 value = fields->f_rbbc;
1137 break;
d031aafb 1138 case MT_OPERAND_RC :
ac188222
DB
1139 value = fields->f_rc;
1140 break;
d031aafb 1141 case MT_OPERAND_RC1 :
ac188222
DB
1142 value = fields->f_rc1;
1143 break;
d031aafb 1144 case MT_OPERAND_RC2 :
ac188222
DB
1145 value = fields->f_rc2;
1146 break;
d031aafb 1147 case MT_OPERAND_RC3 :
6f84a2a6
NS
1148 value = fields->f_rc3;
1149 break;
d031aafb 1150 case MT_OPERAND_RCNUM :
ac188222
DB
1151 value = fields->f_rcnum;
1152 break;
d031aafb 1153 case MT_OPERAND_RDA :
ac188222
DB
1154 value = fields->f_rda;
1155 break;
d031aafb 1156 case MT_OPERAND_ROWNUM :
ac188222
DB
1157 value = fields->f_rownum;
1158 break;
d031aafb 1159 case MT_OPERAND_ROWNUM1 :
ac188222
DB
1160 value = fields->f_rownum1;
1161 break;
d031aafb 1162 case MT_OPERAND_ROWNUM2 :
ac188222
DB
1163 value = fields->f_rownum2;
1164 break;
d031aafb 1165 case MT_OPERAND_SIZE :
ac188222
DB
1166 value = fields->f_size;
1167 break;
d031aafb 1168 case MT_OPERAND_TYPE :
ac188222
DB
1169 value = fields->f_type;
1170 break;
d031aafb 1171 case MT_OPERAND_WR :
ac188222
DB
1172 value = fields->f_wr;
1173 break;
d031aafb 1174 case MT_OPERAND_XMODE :
ac188222
DB
1175 value = fields->f_xmode;
1176 break;
1177
1178 default :
1179 /* xgettext:c-format */
a6743a54
AM
1180 opcodes_error_handler
1181 (_("internal error: unrecognized field %d while getting int operand"),
1182 opindex);
ac188222
DB
1183 abort ();
1184 }
1185
1186 return value;
1187}
1188
1189bfd_vma
d031aafb 1190mt_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
47b0e7ad
NC
1191 int opindex,
1192 const CGEN_FIELDS * fields)
ac188222
DB
1193{
1194 bfd_vma value;
1195
1196 switch (opindex)
1197 {
d031aafb 1198 case MT_OPERAND_A23 :
ac188222
DB
1199 value = fields->f_a23;
1200 break;
d031aafb 1201 case MT_OPERAND_BALL :
ac188222
DB
1202 value = fields->f_ball;
1203 break;
d031aafb 1204 case MT_OPERAND_BALL2 :
ac188222
DB
1205 value = fields->f_ball2;
1206 break;
d031aafb 1207 case MT_OPERAND_BANKADDR :
ac188222
DB
1208 value = fields->f_bankaddr;
1209 break;
d031aafb 1210 case MT_OPERAND_BRC :
ac188222
DB
1211 value = fields->f_brc;
1212 break;
d031aafb 1213 case MT_OPERAND_BRC2 :
ac188222
DB
1214 value = fields->f_brc2;
1215 break;
d031aafb 1216 case MT_OPERAND_CB1INCR :
6f84a2a6
NS
1217 value = fields->f_cb1incr;
1218 break;
d031aafb 1219 case MT_OPERAND_CB1SEL :
6f84a2a6
NS
1220 value = fields->f_cb1sel;
1221 break;
d031aafb 1222 case MT_OPERAND_CB2INCR :
6f84a2a6
NS
1223 value = fields->f_cb2incr;
1224 break;
d031aafb 1225 case MT_OPERAND_CB2SEL :
6f84a2a6
NS
1226 value = fields->f_cb2sel;
1227 break;
d031aafb 1228 case MT_OPERAND_CBRB :
ac188222
DB
1229 value = fields->f_cbrb;
1230 break;
d031aafb 1231 case MT_OPERAND_CBS :
ac188222
DB
1232 value = fields->f_cbs;
1233 break;
d031aafb 1234 case MT_OPERAND_CBX :
ac188222
DB
1235 value = fields->f_cbx;
1236 break;
d031aafb 1237 case MT_OPERAND_CCB :
ac188222
DB
1238 value = fields->f_ccb;
1239 break;
d031aafb 1240 case MT_OPERAND_CDB :
ac188222
DB
1241 value = fields->f_cdb;
1242 break;
d031aafb 1243 case MT_OPERAND_CELL :
ac188222
DB
1244 value = fields->f_cell;
1245 break;
d031aafb 1246 case MT_OPERAND_COLNUM :
ac188222
DB
1247 value = fields->f_colnum;
1248 break;
d031aafb 1249 case MT_OPERAND_CONTNUM :
ac188222
DB
1250 value = fields->f_contnum;
1251 break;
d031aafb 1252 case MT_OPERAND_CR :
ac188222
DB
1253 value = fields->f_cr;
1254 break;
d031aafb 1255 case MT_OPERAND_CTXDISP :
ac188222
DB
1256 value = fields->f_ctxdisp;
1257 break;
d031aafb 1258 case MT_OPERAND_DUP :
ac188222
DB
1259 value = fields->f_dup;
1260 break;
d031aafb 1261 case MT_OPERAND_FBDISP :
ac188222
DB
1262 value = fields->f_fbdisp;
1263 break;
d031aafb 1264 case MT_OPERAND_FBINCR :
ac188222
DB
1265 value = fields->f_fbincr;
1266 break;
d031aafb 1267 case MT_OPERAND_FRDR :
ac188222
DB
1268 value = fields->f_dr;
1269 break;
d031aafb 1270 case MT_OPERAND_FRDRRR :
ac188222
DB
1271 value = fields->f_drrr;
1272 break;
d031aafb 1273 case MT_OPERAND_FRSR1 :
ac188222
DB
1274 value = fields->f_sr1;
1275 break;
d031aafb 1276 case MT_OPERAND_FRSR2 :
ac188222
DB
1277 value = fields->f_sr2;
1278 break;
d031aafb 1279 case MT_OPERAND_ID :
ac188222
DB
1280 value = fields->f_id;
1281 break;
d031aafb 1282 case MT_OPERAND_IMM16 :
ac188222
DB
1283 value = fields->f_imm16s;
1284 break;
d031aafb 1285 case MT_OPERAND_IMM16L :
6f84a2a6
NS
1286 value = fields->f_imm16l;
1287 break;
d031aafb 1288 case MT_OPERAND_IMM16O :
ac188222
DB
1289 value = fields->f_imm16s;
1290 break;
d031aafb 1291 case MT_OPERAND_IMM16Z :
ac188222
DB
1292 value = fields->f_imm16u;
1293 break;
d031aafb 1294 case MT_OPERAND_INCAMT :
ac188222
DB
1295 value = fields->f_incamt;
1296 break;
d031aafb 1297 case MT_OPERAND_INCR :
ac188222
DB
1298 value = fields->f_incr;
1299 break;
d031aafb 1300 case MT_OPERAND_LENGTH :
ac188222
DB
1301 value = fields->f_length;
1302 break;
d031aafb 1303 case MT_OPERAND_LOOPSIZE :
6f84a2a6
NS
1304 value = fields->f_loopo;
1305 break;
d031aafb 1306 case MT_OPERAND_MASK :
ac188222
DB
1307 value = fields->f_mask;
1308 break;
d031aafb 1309 case MT_OPERAND_MASK1 :
ac188222
DB
1310 value = fields->f_mask1;
1311 break;
d031aafb 1312 case MT_OPERAND_MODE :
ac188222
DB
1313 value = fields->f_mode;
1314 break;
d031aafb 1315 case MT_OPERAND_PERM :
ac188222
DB
1316 value = fields->f_perm;
1317 break;
d031aafb 1318 case MT_OPERAND_RBBC :
ac188222
DB
1319 value = fields->f_rbbc;
1320 break;
d031aafb 1321 case MT_OPERAND_RC :
ac188222
DB
1322 value = fields->f_rc;
1323 break;
d031aafb 1324 case MT_OPERAND_RC1 :
ac188222
DB
1325 value = fields->f_rc1;
1326 break;
d031aafb 1327 case MT_OPERAND_RC2 :
ac188222
DB
1328 value = fields->f_rc2;
1329 break;
d031aafb 1330 case MT_OPERAND_RC3 :
6f84a2a6
NS
1331 value = fields->f_rc3;
1332 break;
d031aafb 1333 case MT_OPERAND_RCNUM :
ac188222
DB
1334 value = fields->f_rcnum;
1335 break;
d031aafb 1336 case MT_OPERAND_RDA :
ac188222
DB
1337 value = fields->f_rda;
1338 break;
d031aafb 1339 case MT_OPERAND_ROWNUM :
ac188222
DB
1340 value = fields->f_rownum;
1341 break;
d031aafb 1342 case MT_OPERAND_ROWNUM1 :
ac188222
DB
1343 value = fields->f_rownum1;
1344 break;
d031aafb 1345 case MT_OPERAND_ROWNUM2 :
ac188222
DB
1346 value = fields->f_rownum2;
1347 break;
d031aafb 1348 case MT_OPERAND_SIZE :
ac188222
DB
1349 value = fields->f_size;
1350 break;
d031aafb 1351 case MT_OPERAND_TYPE :
ac188222
DB
1352 value = fields->f_type;
1353 break;
d031aafb 1354 case MT_OPERAND_WR :
ac188222
DB
1355 value = fields->f_wr;
1356 break;
d031aafb 1357 case MT_OPERAND_XMODE :
ac188222
DB
1358 value = fields->f_xmode;
1359 break;
1360
1361 default :
1362 /* xgettext:c-format */
a6743a54
AM
1363 opcodes_error_handler
1364 (_("internal error: unrecognized field %d while getting vma operand"),
1365 opindex);
ac188222
DB
1366 abort ();
1367 }
1368
1369 return value;
1370}
1371
d031aafb
NS
1372void mt_cgen_set_int_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, int);
1373void mt_cgen_set_vma_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, bfd_vma);
ac188222
DB
1374
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
1378 not appropriate. */
1379
1380void
d031aafb 1381mt_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
47b0e7ad
NC
1382 int opindex,
1383 CGEN_FIELDS * fields,
1384 int value)
ac188222
DB
1385{
1386 switch (opindex)
1387 {
d031aafb 1388 case MT_OPERAND_A23 :
ac188222
DB
1389 fields->f_a23 = value;
1390 break;
d031aafb 1391 case MT_OPERAND_BALL :
ac188222
DB
1392 fields->f_ball = value;
1393 break;
d031aafb 1394 case MT_OPERAND_BALL2 :
ac188222
DB
1395 fields->f_ball2 = value;
1396 break;
d031aafb 1397 case MT_OPERAND_BANKADDR :
ac188222
DB
1398 fields->f_bankaddr = value;
1399 break;
d031aafb 1400 case MT_OPERAND_BRC :
ac188222
DB
1401 fields->f_brc = value;
1402 break;
d031aafb 1403 case MT_OPERAND_BRC2 :
ac188222
DB
1404 fields->f_brc2 = value;
1405 break;
d031aafb 1406 case MT_OPERAND_CB1INCR :
6f84a2a6
NS
1407 fields->f_cb1incr = value;
1408 break;
d031aafb 1409 case MT_OPERAND_CB1SEL :
6f84a2a6
NS
1410 fields->f_cb1sel = value;
1411 break;
d031aafb 1412 case MT_OPERAND_CB2INCR :
6f84a2a6
NS
1413 fields->f_cb2incr = value;
1414 break;
d031aafb 1415 case MT_OPERAND_CB2SEL :
6f84a2a6
NS
1416 fields->f_cb2sel = value;
1417 break;
d031aafb 1418 case MT_OPERAND_CBRB :
ac188222
DB
1419 fields->f_cbrb = value;
1420 break;
d031aafb 1421 case MT_OPERAND_CBS :
ac188222
DB
1422 fields->f_cbs = value;
1423 break;
d031aafb 1424 case MT_OPERAND_CBX :
ac188222
DB
1425 fields->f_cbx = value;
1426 break;
d031aafb 1427 case MT_OPERAND_CCB :
ac188222
DB
1428 fields->f_ccb = value;
1429 break;
d031aafb 1430 case MT_OPERAND_CDB :
ac188222
DB
1431 fields->f_cdb = value;
1432 break;
d031aafb 1433 case MT_OPERAND_CELL :
ac188222
DB
1434 fields->f_cell = value;
1435 break;
d031aafb 1436 case MT_OPERAND_COLNUM :
ac188222
DB
1437 fields->f_colnum = value;
1438 break;
d031aafb 1439 case MT_OPERAND_CONTNUM :
ac188222
DB
1440 fields->f_contnum = value;
1441 break;
d031aafb 1442 case MT_OPERAND_CR :
ac188222
DB
1443 fields->f_cr = value;
1444 break;
d031aafb 1445 case MT_OPERAND_CTXDISP :
ac188222
DB
1446 fields->f_ctxdisp = value;
1447 break;
d031aafb 1448 case MT_OPERAND_DUP :
ac188222
DB
1449 fields->f_dup = value;
1450 break;
d031aafb 1451 case MT_OPERAND_FBDISP :
ac188222
DB
1452 fields->f_fbdisp = value;
1453 break;
d031aafb 1454 case MT_OPERAND_FBINCR :
ac188222
DB
1455 fields->f_fbincr = value;
1456 break;
d031aafb 1457 case MT_OPERAND_FRDR :
ac188222
DB
1458 fields->f_dr = value;
1459 break;
d031aafb 1460 case MT_OPERAND_FRDRRR :
ac188222
DB
1461 fields->f_drrr = value;
1462 break;
d031aafb 1463 case MT_OPERAND_FRSR1 :
ac188222
DB
1464 fields->f_sr1 = value;
1465 break;
d031aafb 1466 case MT_OPERAND_FRSR2 :
ac188222
DB
1467 fields->f_sr2 = value;
1468 break;
d031aafb 1469 case MT_OPERAND_ID :
ac188222
DB
1470 fields->f_id = value;
1471 break;
d031aafb 1472 case MT_OPERAND_IMM16 :
ac188222
DB
1473 fields->f_imm16s = value;
1474 break;
d031aafb 1475 case MT_OPERAND_IMM16L :
6f84a2a6
NS
1476 fields->f_imm16l = value;
1477 break;
d031aafb 1478 case MT_OPERAND_IMM16O :
ac188222
DB
1479 fields->f_imm16s = value;
1480 break;
d031aafb 1481 case MT_OPERAND_IMM16Z :
ac188222
DB
1482 fields->f_imm16u = value;
1483 break;
d031aafb 1484 case MT_OPERAND_INCAMT :
ac188222
DB
1485 fields->f_incamt = value;
1486 break;
d031aafb 1487 case MT_OPERAND_INCR :
ac188222
DB
1488 fields->f_incr = value;
1489 break;
d031aafb 1490 case MT_OPERAND_LENGTH :
ac188222
DB
1491 fields->f_length = value;
1492 break;
d031aafb 1493 case MT_OPERAND_LOOPSIZE :
6f84a2a6
NS
1494 fields->f_loopo = value;
1495 break;
d031aafb 1496 case MT_OPERAND_MASK :
ac188222
DB
1497 fields->f_mask = value;
1498 break;
d031aafb 1499 case MT_OPERAND_MASK1 :
ac188222
DB
1500 fields->f_mask1 = value;
1501 break;
d031aafb 1502 case MT_OPERAND_MODE :
ac188222
DB
1503 fields->f_mode = value;
1504 break;
d031aafb 1505 case MT_OPERAND_PERM :
ac188222
DB
1506 fields->f_perm = value;
1507 break;
d031aafb 1508 case MT_OPERAND_RBBC :
ac188222
DB
1509 fields->f_rbbc = value;
1510 break;
d031aafb 1511 case MT_OPERAND_RC :
ac188222
DB
1512 fields->f_rc = value;
1513 break;
d031aafb 1514 case MT_OPERAND_RC1 :
ac188222
DB
1515 fields->f_rc1 = value;
1516 break;
d031aafb 1517 case MT_OPERAND_RC2 :
ac188222
DB
1518 fields->f_rc2 = value;
1519 break;
d031aafb 1520 case MT_OPERAND_RC3 :
6f84a2a6
NS
1521 fields->f_rc3 = value;
1522 break;
d031aafb 1523 case MT_OPERAND_RCNUM :
ac188222
DB
1524 fields->f_rcnum = value;
1525 break;
d031aafb 1526 case MT_OPERAND_RDA :
ac188222
DB
1527 fields->f_rda = value;
1528 break;
d031aafb 1529 case MT_OPERAND_ROWNUM :
ac188222
DB
1530 fields->f_rownum = value;
1531 break;
d031aafb 1532 case MT_OPERAND_ROWNUM1 :
ac188222
DB
1533 fields->f_rownum1 = value;
1534 break;
d031aafb 1535 case MT_OPERAND_ROWNUM2 :
ac188222
DB
1536 fields->f_rownum2 = value;
1537 break;
d031aafb 1538 case MT_OPERAND_SIZE :
ac188222
DB
1539 fields->f_size = value;
1540 break;
d031aafb 1541 case MT_OPERAND_TYPE :
ac188222
DB
1542 fields->f_type = value;
1543 break;
d031aafb 1544 case MT_OPERAND_WR :
ac188222
DB
1545 fields->f_wr = value;
1546 break;
d031aafb 1547 case MT_OPERAND_XMODE :
ac188222
DB
1548 fields->f_xmode = value;
1549 break;
1550
1551 default :
1552 /* xgettext:c-format */
a6743a54
AM
1553 opcodes_error_handler
1554 (_("internal error: unrecognized field %d while setting int operand"),
1555 opindex);
ac188222
DB
1556 abort ();
1557 }
1558}
1559
1560void
d031aafb 1561mt_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
47b0e7ad
NC
1562 int opindex,
1563 CGEN_FIELDS * fields,
1564 bfd_vma value)
ac188222
DB
1565{
1566 switch (opindex)
1567 {
d031aafb 1568 case MT_OPERAND_A23 :
ac188222
DB
1569 fields->f_a23 = value;
1570 break;
d031aafb 1571 case MT_OPERAND_BALL :
ac188222
DB
1572 fields->f_ball = value;
1573 break;
d031aafb 1574 case MT_OPERAND_BALL2 :
ac188222
DB
1575 fields->f_ball2 = value;
1576 break;
d031aafb 1577 case MT_OPERAND_BANKADDR :
ac188222
DB
1578 fields->f_bankaddr = value;
1579 break;
d031aafb 1580 case MT_OPERAND_BRC :
ac188222
DB
1581 fields->f_brc = value;
1582 break;
d031aafb 1583 case MT_OPERAND_BRC2 :
ac188222
DB
1584 fields->f_brc2 = value;
1585 break;
d031aafb 1586 case MT_OPERAND_CB1INCR :
6f84a2a6
NS
1587 fields->f_cb1incr = value;
1588 break;
d031aafb 1589 case MT_OPERAND_CB1SEL :
6f84a2a6
NS
1590 fields->f_cb1sel = value;
1591 break;
d031aafb 1592 case MT_OPERAND_CB2INCR :
6f84a2a6
NS
1593 fields->f_cb2incr = value;
1594 break;
d031aafb 1595 case MT_OPERAND_CB2SEL :
6f84a2a6
NS
1596 fields->f_cb2sel = value;
1597 break;
d031aafb 1598 case MT_OPERAND_CBRB :
ac188222
DB
1599 fields->f_cbrb = value;
1600 break;
d031aafb 1601 case MT_OPERAND_CBS :
ac188222
DB
1602 fields->f_cbs = value;
1603 break;
d031aafb 1604 case MT_OPERAND_CBX :
ac188222
DB
1605 fields->f_cbx = value;
1606 break;
d031aafb 1607 case MT_OPERAND_CCB :
ac188222
DB
1608 fields->f_ccb = value;
1609 break;
d031aafb 1610 case MT_OPERAND_CDB :
ac188222
DB
1611 fields->f_cdb = value;
1612 break;
d031aafb 1613 case MT_OPERAND_CELL :
ac188222
DB
1614 fields->f_cell = value;
1615 break;
d031aafb 1616 case MT_OPERAND_COLNUM :
ac188222
DB
1617 fields->f_colnum = value;
1618 break;
d031aafb 1619 case MT_OPERAND_CONTNUM :
ac188222
DB
1620 fields->f_contnum = value;
1621 break;
d031aafb 1622 case MT_OPERAND_CR :
ac188222
DB
1623 fields->f_cr = value;
1624 break;
d031aafb 1625 case MT_OPERAND_CTXDISP :
ac188222
DB
1626 fields->f_ctxdisp = value;
1627 break;
d031aafb 1628 case MT_OPERAND_DUP :
ac188222
DB
1629 fields->f_dup = value;
1630 break;
d031aafb 1631 case MT_OPERAND_FBDISP :
ac188222
DB
1632 fields->f_fbdisp = value;
1633 break;
d031aafb 1634 case MT_OPERAND_FBINCR :
ac188222
DB
1635 fields->f_fbincr = value;
1636 break;
d031aafb 1637 case MT_OPERAND_FRDR :
ac188222
DB
1638 fields->f_dr = value;
1639 break;
d031aafb 1640 case MT_OPERAND_FRDRRR :
ac188222
DB
1641 fields->f_drrr = value;
1642 break;
d031aafb 1643 case MT_OPERAND_FRSR1 :
ac188222
DB
1644 fields->f_sr1 = value;
1645 break;
d031aafb 1646 case MT_OPERAND_FRSR2 :
ac188222
DB
1647 fields->f_sr2 = value;
1648 break;
d031aafb 1649 case MT_OPERAND_ID :
ac188222
DB
1650 fields->f_id = value;
1651 break;
d031aafb 1652 case MT_OPERAND_IMM16 :
ac188222
DB
1653 fields->f_imm16s = value;
1654 break;
d031aafb 1655 case MT_OPERAND_IMM16L :
6f84a2a6
NS
1656 fields->f_imm16l = value;
1657 break;
d031aafb 1658 case MT_OPERAND_IMM16O :
ac188222
DB
1659 fields->f_imm16s = value;
1660 break;
d031aafb 1661 case MT_OPERAND_IMM16Z :
ac188222
DB
1662 fields->f_imm16u = value;
1663 break;
d031aafb 1664 case MT_OPERAND_INCAMT :
ac188222
DB
1665 fields->f_incamt = value;
1666 break;
d031aafb 1667 case MT_OPERAND_INCR :
ac188222
DB
1668 fields->f_incr = value;
1669 break;
d031aafb 1670 case MT_OPERAND_LENGTH :
ac188222
DB
1671 fields->f_length = value;
1672 break;
d031aafb 1673 case MT_OPERAND_LOOPSIZE :
6f84a2a6
NS
1674 fields->f_loopo = value;
1675 break;
d031aafb 1676 case MT_OPERAND_MASK :
ac188222
DB
1677 fields->f_mask = value;
1678 break;
d031aafb 1679 case MT_OPERAND_MASK1 :
ac188222
DB
1680 fields->f_mask1 = value;
1681 break;
d031aafb 1682 case MT_OPERAND_MODE :
ac188222
DB
1683 fields->f_mode = value;
1684 break;
d031aafb 1685 case MT_OPERAND_PERM :
ac188222
DB
1686 fields->f_perm = value;
1687 break;
d031aafb 1688 case MT_OPERAND_RBBC :
ac188222
DB
1689 fields->f_rbbc = value;
1690 break;
d031aafb 1691 case MT_OPERAND_RC :
ac188222
DB
1692 fields->f_rc = value;
1693 break;
d031aafb 1694 case MT_OPERAND_RC1 :
ac188222
DB
1695 fields->f_rc1 = value;
1696 break;
d031aafb 1697 case MT_OPERAND_RC2 :
ac188222
DB
1698 fields->f_rc2 = value;
1699 break;
d031aafb 1700 case MT_OPERAND_RC3 :
6f84a2a6
NS
1701 fields->f_rc3 = value;
1702 break;
d031aafb 1703 case MT_OPERAND_RCNUM :
ac188222
DB
1704 fields->f_rcnum = value;
1705 break;
d031aafb 1706 case MT_OPERAND_RDA :
ac188222
DB
1707 fields->f_rda = value;
1708 break;
d031aafb 1709 case MT_OPERAND_ROWNUM :
ac188222
DB
1710 fields->f_rownum = value;
1711 break;
d031aafb 1712 case MT_OPERAND_ROWNUM1 :
ac188222
DB
1713 fields->f_rownum1 = value;
1714 break;
d031aafb 1715 case MT_OPERAND_ROWNUM2 :
ac188222
DB
1716 fields->f_rownum2 = value;
1717 break;
d031aafb 1718 case MT_OPERAND_SIZE :
ac188222
DB
1719 fields->f_size = value;
1720 break;
d031aafb 1721 case MT_OPERAND_TYPE :
ac188222
DB
1722 fields->f_type = value;
1723 break;
d031aafb 1724 case MT_OPERAND_WR :
ac188222
DB
1725 fields->f_wr = value;
1726 break;
d031aafb 1727 case MT_OPERAND_XMODE :
ac188222
DB
1728 fields->f_xmode = value;
1729 break;
1730
1731 default :
1732 /* xgettext:c-format */
a6743a54
AM
1733 opcodes_error_handler
1734 (_("internal error: unrecognized field %d while setting vma operand"),
1735 opindex);
ac188222
DB
1736 abort ();
1737 }
1738}
1739
1740/* Function to call before using the instruction builder tables. */
1741
1742void
d031aafb 1743mt_cgen_init_ibld_table (CGEN_CPU_DESC cd)
ac188222 1744{
d031aafb
NS
1745 cd->insert_handlers = & mt_cgen_insert_handlers[0];
1746 cd->extract_handlers = & mt_cgen_extract_handlers[0];
ac188222 1747
d031aafb
NS
1748 cd->insert_operand = mt_cgen_insert_operand;
1749 cd->extract_operand = mt_cgen_extract_operand;
ac188222 1750
d031aafb
NS
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;
ac188222 1755}