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