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