daily update
[binutils.git] / opcodes / frv-ibld.c
blob9fe25316009e05cc77e86a45f14107af5da9bbb1
1 /* Instruction building/extraction support for frv. -*- C -*-
3 THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator.
4 - the resultant file is machine generated, cgen-ibld.in isn't
6 Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005
7 Free Software Foundation, Inc.
9 This file is part of the GNU Binutils and GDB, the GNU debugger.
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.
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.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
25 /* ??? Eventually more and more of this stuff can go to cpu-independent files.
26 Keep that in mind. */
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"
34 #include "frv-desc.h"
35 #include "frv-opc.h"
36 #include "opintl.h"
37 #include "safe-ctype.h"
39 #undef min
40 #define min(a,b) ((a) < (b) ? (a) : (b))
41 #undef max
42 #define max(a,b) ((a) > (b) ? (a) : (b))
44 /* Used by the ifield rtx function. */
45 #define FLD(f) (fields->f)
47 static 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);
50 static const char * insert_insn_normal
51 (CGEN_CPU_DESC, const CGEN_INSN *,
52 CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma);
53 static 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 *);
57 static 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
61 static 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
65 static CGEN_INLINE void insert_1
66 (CGEN_CPU_DESC, unsigned long, int, int, int, unsigned char *);
67 static CGEN_INLINE int fill_cache
68 (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, int, int, bfd_vma);
69 static CGEN_INLINE long extract_1
70 (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, int, int, int, unsigned char *, bfd_vma);
71 #endif
73 /* Operand insertion. */
75 #if ! CGEN_INT_INSN_P
77 /* Subroutine of insert_normal. */
79 static CGEN_INLINE void
80 insert_1 (CGEN_CPU_DESC cd,
81 unsigned long value,
82 int start,
83 int length,
84 int word_length,
85 unsigned char *bufp)
87 unsigned long x,mask;
88 int shift;
90 x = cgen_get_insn_value (cd, bufp, word_length);
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);
100 cgen_put_insn_value (cd, bufp, word_length, (bfd_vma) x);
103 #endif /* ! CGEN_INT_INSN_P */
105 /* Default insertion routine.
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.
114 The result is an error message or NULL if success. */
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. */
121 static const char *
122 insert_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)
132 static char errbuf[100];
133 /* Written this way to avoid undefined behaviour. */
134 unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
136 /* If LENGTH is zero, this operand doesn't contribute to the value. */
137 if (length == 0)
138 return NULL;
140 if (word_length > 32)
141 abort ();
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)
147 if (word_offset == 0
148 && word_length > total_length)
149 word_length = total_length;
152 /* Ensure VALUE will fit. */
153 if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGN_OPT))
155 long minval = - (1L << (length - 1));
156 unsigned long maxval = mask;
158 if ((value > 0 && (unsigned long) value > maxval)
159 || value < minval)
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;
168 else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED))
170 unsigned long maxval = mask;
172 if ((unsigned long) value > maxval)
174 /* xgettext:c-format */
175 sprintf (errbuf,
176 _("operand out of range (%lu not between 0 and %lu)"),
177 value, maxval);
178 return errbuf;
181 else
183 if (! cgen_signed_overflow_ok_p (cd))
185 long minval = - (1L << (length - 1));
186 long maxval = (1L << (length - 1)) - 1;
188 if (value < minval || value > maxval)
190 sprintf
191 /* xgettext:c-format */
192 (errbuf, _("operand out of range (%ld not between %ld and %ld)"),
193 value, minval, maxval);
194 return errbuf;
199 #if CGEN_INT_INSN_P
202 int shift;
204 if (CGEN_INSN_LSB0_P)
205 shift = (word_offset + start + 1) - length;
206 else
207 shift = total_length - (word_offset + start + length);
208 *buffer = (*buffer & ~(mask << shift)) | ((value & mask) << shift);
211 #else /* ! CGEN_INT_INSN_P */
214 unsigned char *bufp = (unsigned char *) buffer + word_offset / 8;
216 insert_1 (cd, value, start, length, word_length, bufp);
219 #endif /* ! CGEN_INT_INSN_P */
221 return NULL;
224 /* Default insn builder (insert handler).
225 The instruction is recorded in CGEN_INT_INSN_P byte order (meaning
226 that if CGEN_INSN_BYTES_PTR is an int * and thus, the value is
227 recorded in host byte order, otherwise BUFFER is an array of bytes
228 and the value is recorded in target byte order).
229 The result is an error message or NULL if success. */
231 static const char *
232 insert_insn_normal (CGEN_CPU_DESC cd,
233 const CGEN_INSN * insn,
234 CGEN_FIELDS * fields,
235 CGEN_INSN_BYTES_PTR buffer,
236 bfd_vma pc)
238 const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
239 unsigned long value;
240 const CGEN_SYNTAX_CHAR_TYPE * syn;
242 CGEN_INIT_INSERT (cd);
243 value = CGEN_INSN_BASE_VALUE (insn);
245 /* If we're recording insns as numbers (rather than a string of bytes),
246 target byte order handling is deferred until later. */
248 #if CGEN_INT_INSN_P
250 put_insn_int_value (cd, buffer, cd->base_insn_bitsize,
251 CGEN_FIELDS_BITSIZE (fields), value);
253 #else
255 cgen_put_insn_value (cd, buffer, min ((unsigned) cd->base_insn_bitsize,
256 (unsigned) CGEN_FIELDS_BITSIZE (fields)),
257 value);
259 #endif /* ! CGEN_INT_INSN_P */
261 /* ??? It would be better to scan the format's fields.
262 Still need to be able to insert a value based on the operand though;
263 e.g. storing a branch displacement that got resolved later.
264 Needs more thought first. */
266 for (syn = CGEN_SYNTAX_STRING (syntax); * syn; ++ syn)
268 const char *errmsg;
270 if (CGEN_SYNTAX_CHAR_P (* syn))
271 continue;
273 errmsg = (* cd->insert_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
274 fields, buffer, pc);
275 if (errmsg)
276 return errmsg;
279 return NULL;
282 #if CGEN_INT_INSN_P
283 /* Cover function to store an insn value into an integral insn. Must go here
284 because it needs <prefix>-desc.h for CGEN_INT_INSN_P. */
286 static void
287 put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
288 CGEN_INSN_BYTES_PTR buf,
289 int length,
290 int insn_length,
291 CGEN_INSN_INT value)
293 /* For architectures with insns smaller than the base-insn-bitsize,
294 length may be too big. */
295 if (length > insn_length)
296 *buf = value;
297 else
299 int shift = insn_length - length;
300 /* Written this way to avoid undefined behaviour. */
301 CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1;
303 *buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
306 #endif
308 /* Operand extraction. */
310 #if ! CGEN_INT_INSN_P
312 /* Subroutine of extract_normal.
313 Ensure sufficient bytes are cached in EX_INFO.
314 OFFSET is the offset in bytes from the start of the insn of the value.
315 BYTES is the length of the needed value.
316 Returns 1 for success, 0 for failure. */
318 static CGEN_INLINE int
319 fill_cache (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
320 CGEN_EXTRACT_INFO *ex_info,
321 int offset,
322 int bytes,
323 bfd_vma pc)
325 /* It's doubtful that the middle part has already been fetched so
326 we don't optimize that case. kiss. */
327 unsigned int mask;
328 disassemble_info *info = (disassemble_info *) ex_info->dis_info;
330 /* First do a quick check. */
331 mask = (1 << bytes) - 1;
332 if (((ex_info->valid >> offset) & mask) == mask)
333 return 1;
335 /* Search for the first byte we need to read. */
336 for (mask = 1 << offset; bytes > 0; --bytes, ++offset, mask <<= 1)
337 if (! (mask & ex_info->valid))
338 break;
340 if (bytes)
342 int status;
344 pc += offset;
345 status = (*info->read_memory_func)
346 (pc, ex_info->insn_bytes + offset, bytes, info);
348 if (status != 0)
350 (*info->memory_error_func) (status, pc, info);
351 return 0;
354 ex_info->valid |= ((1 << bytes) - 1) << offset;
357 return 1;
360 /* Subroutine of extract_normal. */
362 static CGEN_INLINE long
363 extract_1 (CGEN_CPU_DESC cd,
364 CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED,
365 int start,
366 int length,
367 int word_length,
368 unsigned char *bufp,
369 bfd_vma pc ATTRIBUTE_UNUSED)
371 unsigned long x;
372 int shift;
374 x = cgen_get_insn_value (cd, bufp, word_length);
376 if (CGEN_INSN_LSB0_P)
377 shift = (start + 1) - length;
378 else
379 shift = (word_length - (start + length));
380 return x >> shift;
383 #endif /* ! CGEN_INT_INSN_P */
385 /* Default extraction routine.
387 INSN_VALUE is the first base_insn_bitsize bits of the insn in host order,
388 or sometimes less for cases like the m32r where the base insn size is 32
389 but some insns are 16 bits.
390 ATTRS is a mask of the boolean attributes. We only need `SIGNED',
391 but for generality we take a bitmask of all of them.
392 WORD_OFFSET is the offset in bits from the start of the insn of the value.
393 WORD_LENGTH is the length of the word in bits in which the value resides.
394 START is the starting bit number in the word, architecture origin.
395 LENGTH is the length of VALUE in bits.
396 TOTAL_LENGTH is the total length of the insn in bits.
398 Returns 1 for success, 0 for failure. */
400 /* ??? The return code isn't properly used. wip. */
402 /* ??? This doesn't handle bfd_vma's. Create another function when
403 necessary. */
405 static int
406 extract_normal (CGEN_CPU_DESC cd,
407 #if ! CGEN_INT_INSN_P
408 CGEN_EXTRACT_INFO *ex_info,
409 #else
410 CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED,
411 #endif
412 CGEN_INSN_INT insn_value,
413 unsigned int attrs,
414 unsigned int word_offset,
415 unsigned int start,
416 unsigned int length,
417 unsigned int word_length,
418 unsigned int total_length,
419 #if ! CGEN_INT_INSN_P
420 bfd_vma pc,
421 #else
422 bfd_vma pc ATTRIBUTE_UNUSED,
423 #endif
424 long *valuep)
426 long value, mask;
428 /* If LENGTH is zero, this operand doesn't contribute to the value
429 so give it a standard value of zero. */
430 if (length == 0)
432 *valuep = 0;
433 return 1;
436 if (word_length > 32)
437 abort ();
439 /* For architectures with insns smaller than the insn-base-bitsize,
440 word_length may be too big. */
441 if (cd->min_insn_bitsize < cd->base_insn_bitsize)
443 if (word_offset == 0
444 && word_length > total_length)
445 word_length = total_length;
448 /* Does the value reside in INSN_VALUE, and at the right alignment? */
450 if (CGEN_INT_INSN_P || (word_offset == 0 && word_length == total_length))
452 if (CGEN_INSN_LSB0_P)
453 value = insn_value >> ((word_offset + start + 1) - length);
454 else
455 value = insn_value >> (total_length - ( word_offset + start + length));
458 #if ! CGEN_INT_INSN_P
460 else
462 unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
464 if (word_length > 32)
465 abort ();
467 if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
468 return 0;
470 value = extract_1 (cd, ex_info, start, length, word_length, bufp, pc);
473 #endif /* ! CGEN_INT_INSN_P */
475 /* Written this way to avoid undefined behaviour. */
476 mask = (((1L << (length - 1)) - 1) << 1) | 1;
478 value &= mask;
479 /* sign extend? */
480 if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)
481 && (value & (1L << (length - 1))))
482 value |= ~mask;
484 *valuep = value;
486 return 1;
489 /* Default insn extractor.
491 INSN_VALUE is the first base_insn_bitsize bits, translated to host order.
492 The extracted fields are stored in FIELDS.
493 EX_INFO is used to handle reading variable length insns.
494 Return the length of the insn in bits, or 0 if no match,
495 or -1 if an error occurs fetching data (memory_error_func will have
496 been called). */
498 static int
499 extract_insn_normal (CGEN_CPU_DESC cd,
500 const CGEN_INSN *insn,
501 CGEN_EXTRACT_INFO *ex_info,
502 CGEN_INSN_INT insn_value,
503 CGEN_FIELDS *fields,
504 bfd_vma pc)
506 const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
507 const CGEN_SYNTAX_CHAR_TYPE *syn;
509 CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn);
511 CGEN_INIT_EXTRACT (cd);
513 for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn)
515 int length;
517 if (CGEN_SYNTAX_CHAR_P (*syn))
518 continue;
520 length = (* cd->extract_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
521 ex_info, insn_value, fields, pc);
522 if (length <= 0)
523 return length;
526 /* We recognized and successfully extracted this insn. */
527 return CGEN_INSN_BITSIZE (insn);
530 /* Machine generated code added here. */
532 const char * frv_cgen_insert_operand
533 (CGEN_CPU_DESC, int, CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma);
535 /* Main entry point for operand insertion.
537 This function is basically just a big switch statement. Earlier versions
538 used tables to look up the function to use, but
539 - if the table contains both assembler and disassembler functions then
540 the disassembler contains much of the assembler and vice-versa,
541 - there's a lot of inlining possibilities as things grow,
542 - using a switch statement avoids the function call overhead.
544 This function could be moved into `parse_insn_normal', but keeping it
545 separate makes clear the interface between `parse_insn_normal' and each of
546 the handlers. It's also needed by GAS to insert operands that couldn't be
547 resolved during parsing. */
549 const char *
550 frv_cgen_insert_operand (CGEN_CPU_DESC cd,
551 int opindex,
552 CGEN_FIELDS * fields,
553 CGEN_INSN_BYTES_PTR buffer,
554 bfd_vma pc ATTRIBUTE_UNUSED)
556 const char * errmsg = NULL;
557 unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
559 switch (opindex)
561 case FRV_OPERAND_A0 :
562 errmsg = insert_normal (cd, fields->f_A, 0, 0, 17, 1, 32, total_length, buffer);
563 break;
564 case FRV_OPERAND_A1 :
565 errmsg = insert_normal (cd, fields->f_A, 0, 0, 17, 1, 32, total_length, buffer);
566 break;
567 case FRV_OPERAND_ACC40SI :
568 errmsg = insert_normal (cd, fields->f_ACC40Si, 0, 0, 17, 6, 32, total_length, buffer);
569 break;
570 case FRV_OPERAND_ACC40SK :
571 errmsg = insert_normal (cd, fields->f_ACC40Sk, 0, 0, 30, 6, 32, total_length, buffer);
572 break;
573 case FRV_OPERAND_ACC40UI :
574 errmsg = insert_normal (cd, fields->f_ACC40Ui, 0, 0, 17, 6, 32, total_length, buffer);
575 break;
576 case FRV_OPERAND_ACC40UK :
577 errmsg = insert_normal (cd, fields->f_ACC40Uk, 0, 0, 30, 6, 32, total_length, buffer);
578 break;
579 case FRV_OPERAND_ACCGI :
580 errmsg = insert_normal (cd, fields->f_ACCGi, 0, 0, 17, 6, 32, total_length, buffer);
581 break;
582 case FRV_OPERAND_ACCGK :
583 errmsg = insert_normal (cd, fields->f_ACCGk, 0, 0, 30, 6, 32, total_length, buffer);
584 break;
585 case FRV_OPERAND_CCI :
586 errmsg = insert_normal (cd, fields->f_CCi, 0, 0, 11, 3, 32, total_length, buffer);
587 break;
588 case FRV_OPERAND_CPRDOUBLEK :
589 errmsg = insert_normal (cd, fields->f_CPRk, 0, 0, 30, 6, 32, total_length, buffer);
590 break;
591 case FRV_OPERAND_CPRI :
592 errmsg = insert_normal (cd, fields->f_CPRi, 0, 0, 17, 6, 32, total_length, buffer);
593 break;
594 case FRV_OPERAND_CPRJ :
595 errmsg = insert_normal (cd, fields->f_CPRj, 0, 0, 5, 6, 32, total_length, buffer);
596 break;
597 case FRV_OPERAND_CPRK :
598 errmsg = insert_normal (cd, fields->f_CPRk, 0, 0, 30, 6, 32, total_length, buffer);
599 break;
600 case FRV_OPERAND_CRI :
601 errmsg = insert_normal (cd, fields->f_CRi, 0, 0, 14, 3, 32, total_length, buffer);
602 break;
603 case FRV_OPERAND_CRJ :
604 errmsg = insert_normal (cd, fields->f_CRj, 0, 0, 2, 3, 32, total_length, buffer);
605 break;
606 case FRV_OPERAND_CRJ_FLOAT :
607 errmsg = insert_normal (cd, fields->f_CRj_float, 0, 0, 26, 2, 32, total_length, buffer);
608 break;
609 case FRV_OPERAND_CRJ_INT :
611 long value = fields->f_CRj_int;
612 value = ((value) - (4));
613 errmsg = insert_normal (cd, value, 0, 0, 26, 2, 32, total_length, buffer);
615 break;
616 case FRV_OPERAND_CRK :
617 errmsg = insert_normal (cd, fields->f_CRk, 0, 0, 27, 3, 32, total_length, buffer);
618 break;
619 case FRV_OPERAND_FCCI_1 :
620 errmsg = insert_normal (cd, fields->f_FCCi_1, 0, 0, 11, 2, 32, total_length, buffer);
621 break;
622 case FRV_OPERAND_FCCI_2 :
623 errmsg = insert_normal (cd, fields->f_FCCi_2, 0, 0, 26, 2, 32, total_length, buffer);
624 break;
625 case FRV_OPERAND_FCCI_3 :
626 errmsg = insert_normal (cd, fields->f_FCCi_3, 0, 0, 1, 2, 32, total_length, buffer);
627 break;
628 case FRV_OPERAND_FCCK :
629 errmsg = insert_normal (cd, fields->f_FCCk, 0, 0, 26, 2, 32, total_length, buffer);
630 break;
631 case FRV_OPERAND_FRDOUBLEI :
632 errmsg = insert_normal (cd, fields->f_FRi, 0, 0, 17, 6, 32, total_length, buffer);
633 break;
634 case FRV_OPERAND_FRDOUBLEJ :
635 errmsg = insert_normal (cd, fields->f_FRj, 0, 0, 5, 6, 32, total_length, buffer);
636 break;
637 case FRV_OPERAND_FRDOUBLEK :
638 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer);
639 break;
640 case FRV_OPERAND_FRI :
641 errmsg = insert_normal (cd, fields->f_FRi, 0, 0, 17, 6, 32, total_length, buffer);
642 break;
643 case FRV_OPERAND_FRINTI :
644 errmsg = insert_normal (cd, fields->f_FRi, 0, 0, 17, 6, 32, total_length, buffer);
645 break;
646 case FRV_OPERAND_FRINTIEVEN :
647 errmsg = insert_normal (cd, fields->f_FRi, 0, 0, 17, 6, 32, total_length, buffer);
648 break;
649 case FRV_OPERAND_FRINTJ :
650 errmsg = insert_normal (cd, fields->f_FRj, 0, 0, 5, 6, 32, total_length, buffer);
651 break;
652 case FRV_OPERAND_FRINTJEVEN :
653 errmsg = insert_normal (cd, fields->f_FRj, 0, 0, 5, 6, 32, total_length, buffer);
654 break;
655 case FRV_OPERAND_FRINTK :
656 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer);
657 break;
658 case FRV_OPERAND_FRINTKEVEN :
659 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer);
660 break;
661 case FRV_OPERAND_FRJ :
662 errmsg = insert_normal (cd, fields->f_FRj, 0, 0, 5, 6, 32, total_length, buffer);
663 break;
664 case FRV_OPERAND_FRK :
665 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer);
666 break;
667 case FRV_OPERAND_FRKHI :
668 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer);
669 break;
670 case FRV_OPERAND_FRKLO :
671 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer);
672 break;
673 case FRV_OPERAND_GRDOUBLEK :
674 errmsg = insert_normal (cd, fields->f_GRk, 0, 0, 30, 6, 32, total_length, buffer);
675 break;
676 case FRV_OPERAND_GRI :
677 errmsg = insert_normal (cd, fields->f_GRi, 0, 0, 17, 6, 32, total_length, buffer);
678 break;
679 case FRV_OPERAND_GRJ :
680 errmsg = insert_normal (cd, fields->f_GRj, 0, 0, 5, 6, 32, total_length, buffer);
681 break;
682 case FRV_OPERAND_GRK :
683 errmsg = insert_normal (cd, fields->f_GRk, 0, 0, 30, 6, 32, total_length, buffer);
684 break;
685 case FRV_OPERAND_GRKHI :
686 errmsg = insert_normal (cd, fields->f_GRk, 0, 0, 30, 6, 32, total_length, buffer);
687 break;
688 case FRV_OPERAND_GRKLO :
689 errmsg = insert_normal (cd, fields->f_GRk, 0, 0, 30, 6, 32, total_length, buffer);
690 break;
691 case FRV_OPERAND_ICCI_1 :
692 errmsg = insert_normal (cd, fields->f_ICCi_1, 0, 0, 11, 2, 32, total_length, buffer);
693 break;
694 case FRV_OPERAND_ICCI_2 :
695 errmsg = insert_normal (cd, fields->f_ICCi_2, 0, 0, 26, 2, 32, total_length, buffer);
696 break;
697 case FRV_OPERAND_ICCI_3 :
698 errmsg = insert_normal (cd, fields->f_ICCi_3, 0, 0, 1, 2, 32, total_length, buffer);
699 break;
700 case FRV_OPERAND_LI :
701 errmsg = insert_normal (cd, fields->f_LI, 0, 0, 25, 1, 32, total_length, buffer);
702 break;
703 case FRV_OPERAND_LRAD :
704 errmsg = insert_normal (cd, fields->f_LRAD, 0, 0, 4, 1, 32, total_length, buffer);
705 break;
706 case FRV_OPERAND_LRAE :
707 errmsg = insert_normal (cd, fields->f_LRAE, 0, 0, 5, 1, 32, total_length, buffer);
708 break;
709 case FRV_OPERAND_LRAS :
710 errmsg = insert_normal (cd, fields->f_LRAS, 0, 0, 3, 1, 32, total_length, buffer);
711 break;
712 case FRV_OPERAND_TLBPRL :
713 errmsg = insert_normal (cd, fields->f_TLBPRL, 0, 0, 25, 1, 32, total_length, buffer);
714 break;
715 case FRV_OPERAND_TLBPROPX :
716 errmsg = insert_normal (cd, fields->f_TLBPRopx, 0, 0, 28, 3, 32, total_length, buffer);
717 break;
718 case FRV_OPERAND_AE :
719 errmsg = insert_normal (cd, fields->f_ae, 0, 0, 25, 1, 32, total_length, buffer);
720 break;
721 case FRV_OPERAND_CALLANN :
722 errmsg = insert_normal (cd, fields->f_reloc_ann, 0, 0, 0, 0, 32, total_length, buffer);
723 break;
724 case FRV_OPERAND_CCOND :
725 errmsg = insert_normal (cd, fields->f_ccond, 0, 0, 12, 1, 32, total_length, buffer);
726 break;
727 case FRV_OPERAND_COND :
728 errmsg = insert_normal (cd, fields->f_cond, 0, 0, 8, 1, 32, total_length, buffer);
729 break;
730 case FRV_OPERAND_D12 :
731 errmsg = insert_normal (cd, fields->f_d12, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 12, 32, total_length, buffer);
732 break;
733 case FRV_OPERAND_DEBUG :
734 errmsg = insert_normal (cd, fields->f_debug, 0, 0, 25, 1, 32, total_length, buffer);
735 break;
736 case FRV_OPERAND_EIR :
737 errmsg = insert_normal (cd, fields->f_eir, 0, 0, 17, 6, 32, total_length, buffer);
738 break;
739 case FRV_OPERAND_HINT :
740 errmsg = insert_normal (cd, fields->f_hint, 0, 0, 17, 2, 32, total_length, buffer);
741 break;
742 case FRV_OPERAND_HINT_NOT_TAKEN :
743 errmsg = insert_normal (cd, fields->f_hint, 0, 0, 17, 2, 32, total_length, buffer);
744 break;
745 case FRV_OPERAND_HINT_TAKEN :
746 errmsg = insert_normal (cd, fields->f_hint, 0, 0, 17, 2, 32, total_length, buffer);
747 break;
748 case FRV_OPERAND_LABEL16 :
750 long value = fields->f_label16;
751 value = ((int) (((value) - (pc))) >> (2));
752 errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 15, 16, 32, total_length, buffer);
754 break;
755 case FRV_OPERAND_LABEL24 :
758 FLD (f_labelH6) = ((int) (((FLD (f_label24)) - (pc))) >> (20));
759 FLD (f_labelL18) = ((((unsigned int) (((FLD (f_label24)) - (pc))) >> (2))) & (262143));
761 errmsg = insert_normal (cd, fields->f_labelH6, 0|(1<<CGEN_IFLD_SIGNED), 0, 30, 6, 32, total_length, buffer);
762 if (errmsg)
763 break;
764 errmsg = insert_normal (cd, fields->f_labelL18, 0, 0, 17, 18, 32, total_length, buffer);
765 if (errmsg)
766 break;
768 break;
769 case FRV_OPERAND_LDANN :
770 errmsg = insert_normal (cd, fields->f_reloc_ann, 0, 0, 0, 0, 32, total_length, buffer);
771 break;
772 case FRV_OPERAND_LDDANN :
773 errmsg = insert_normal (cd, fields->f_reloc_ann, 0, 0, 0, 0, 32, total_length, buffer);
774 break;
775 case FRV_OPERAND_LOCK :
776 errmsg = insert_normal (cd, fields->f_lock, 0, 0, 25, 1, 32, total_length, buffer);
777 break;
778 case FRV_OPERAND_PACK :
779 errmsg = insert_normal (cd, fields->f_pack, 0, 0, 31, 1, 32, total_length, buffer);
780 break;
781 case FRV_OPERAND_S10 :
782 errmsg = insert_normal (cd, fields->f_s10, 0|(1<<CGEN_IFLD_SIGNED), 0, 9, 10, 32, total_length, buffer);
783 break;
784 case FRV_OPERAND_S12 :
785 errmsg = insert_normal (cd, fields->f_d12, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 12, 32, total_length, buffer);
786 break;
787 case FRV_OPERAND_S16 :
788 errmsg = insert_normal (cd, fields->f_s16, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, buffer);
789 break;
790 case FRV_OPERAND_S5 :
791 errmsg = insert_normal (cd, fields->f_s5, 0|(1<<CGEN_IFLD_SIGNED), 0, 4, 5, 32, total_length, buffer);
792 break;
793 case FRV_OPERAND_S6 :
794 errmsg = insert_normal (cd, fields->f_s6, 0|(1<<CGEN_IFLD_SIGNED), 0, 5, 6, 32, total_length, buffer);
795 break;
796 case FRV_OPERAND_S6_1 :
797 errmsg = insert_normal (cd, fields->f_s6_1, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 6, 32, total_length, buffer);
798 break;
799 case FRV_OPERAND_SLO16 :
800 errmsg = insert_normal (cd, fields->f_s16, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, buffer);
801 break;
802 case FRV_OPERAND_SPR :
805 FLD (f_spr_h) = ((unsigned int) (FLD (f_spr)) >> (6));
806 FLD (f_spr_l) = ((FLD (f_spr)) & (63));
808 errmsg = insert_normal (cd, fields->f_spr_h, 0, 0, 30, 6, 32, total_length, buffer);
809 if (errmsg)
810 break;
811 errmsg = insert_normal (cd, fields->f_spr_l, 0, 0, 17, 6, 32, total_length, buffer);
812 if (errmsg)
813 break;
815 break;
816 case FRV_OPERAND_U12 :
819 FLD (f_u12_h) = ((int) (FLD (f_u12)) >> (6));
820 FLD (f_u12_l) = ((FLD (f_u12)) & (63));
822 errmsg = insert_normal (cd, fields->f_u12_h, 0|(1<<CGEN_IFLD_SIGNED), 0, 17, 6, 32, total_length, buffer);
823 if (errmsg)
824 break;
825 errmsg = insert_normal (cd, fields->f_u12_l, 0, 0, 5, 6, 32, total_length, buffer);
826 if (errmsg)
827 break;
829 break;
830 case FRV_OPERAND_U16 :
831 errmsg = insert_normal (cd, fields->f_u16, 0, 0, 15, 16, 32, total_length, buffer);
832 break;
833 case FRV_OPERAND_U6 :
834 errmsg = insert_normal (cd, fields->f_u6, 0, 0, 5, 6, 32, total_length, buffer);
835 break;
836 case FRV_OPERAND_UHI16 :
837 errmsg = insert_normal (cd, fields->f_u16, 0, 0, 15, 16, 32, total_length, buffer);
838 break;
839 case FRV_OPERAND_ULO16 :
840 errmsg = insert_normal (cd, fields->f_u16, 0, 0, 15, 16, 32, total_length, buffer);
841 break;
843 default :
844 /* xgettext:c-format */
845 fprintf (stderr, _("Unrecognized field %d while building insn.\n"),
846 opindex);
847 abort ();
850 return errmsg;
853 int frv_cgen_extract_operand
854 (CGEN_CPU_DESC, int, CGEN_EXTRACT_INFO *, CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma);
856 /* Main entry point for operand extraction.
857 The result is <= 0 for error, >0 for success.
858 ??? Actual values aren't well defined right now.
860 This function is basically just a big switch statement. Earlier versions
861 used tables to look up the function to use, but
862 - if the table contains both assembler and disassembler functions then
863 the disassembler contains much of the assembler and vice-versa,
864 - there's a lot of inlining possibilities as things grow,
865 - using a switch statement avoids the function call overhead.
867 This function could be moved into `print_insn_normal', but keeping it
868 separate makes clear the interface between `print_insn_normal' and each of
869 the handlers. */
872 frv_cgen_extract_operand (CGEN_CPU_DESC cd,
873 int opindex,
874 CGEN_EXTRACT_INFO *ex_info,
875 CGEN_INSN_INT insn_value,
876 CGEN_FIELDS * fields,
877 bfd_vma pc)
879 /* Assume success (for those operands that are nops). */
880 int length = 1;
881 unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
883 switch (opindex)
885 case FRV_OPERAND_A0 :
886 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 1, 32, total_length, pc, & fields->f_A);
887 break;
888 case FRV_OPERAND_A1 :
889 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 1, 32, total_length, pc, & fields->f_A);
890 break;
891 case FRV_OPERAND_ACC40SI :
892 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_ACC40Si);
893 break;
894 case FRV_OPERAND_ACC40SK :
895 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_ACC40Sk);
896 break;
897 case FRV_OPERAND_ACC40UI :
898 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_ACC40Ui);
899 break;
900 case FRV_OPERAND_ACC40UK :
901 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_ACC40Uk);
902 break;
903 case FRV_OPERAND_ACCGI :
904 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_ACCGi);
905 break;
906 case FRV_OPERAND_ACCGK :
907 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_ACCGk);
908 break;
909 case FRV_OPERAND_CCI :
910 length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 3, 32, total_length, pc, & fields->f_CCi);
911 break;
912 case FRV_OPERAND_CPRDOUBLEK :
913 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_CPRk);
914 break;
915 case FRV_OPERAND_CPRI :
916 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_CPRi);
917 break;
918 case FRV_OPERAND_CPRJ :
919 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_CPRj);
920 break;
921 case FRV_OPERAND_CPRK :
922 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_CPRk);
923 break;
924 case FRV_OPERAND_CRI :
925 length = extract_normal (cd, ex_info, insn_value, 0, 0, 14, 3, 32, total_length, pc, & fields->f_CRi);
926 break;
927 case FRV_OPERAND_CRJ :
928 length = extract_normal (cd, ex_info, insn_value, 0, 0, 2, 3, 32, total_length, pc, & fields->f_CRj);
929 break;
930 case FRV_OPERAND_CRJ_FLOAT :
931 length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & fields->f_CRj_float);
932 break;
933 case FRV_OPERAND_CRJ_INT :
935 long value;
936 length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & value);
937 value = ((value) + (4));
938 fields->f_CRj_int = value;
940 break;
941 case FRV_OPERAND_CRK :
942 length = extract_normal (cd, ex_info, insn_value, 0, 0, 27, 3, 32, total_length, pc, & fields->f_CRk);
943 break;
944 case FRV_OPERAND_FCCI_1 :
945 length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 2, 32, total_length, pc, & fields->f_FCCi_1);
946 break;
947 case FRV_OPERAND_FCCI_2 :
948 length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & fields->f_FCCi_2);
949 break;
950 case FRV_OPERAND_FCCI_3 :
951 length = extract_normal (cd, ex_info, insn_value, 0, 0, 1, 2, 32, total_length, pc, & fields->f_FCCi_3);
952 break;
953 case FRV_OPERAND_FCCK :
954 length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & fields->f_FCCk);
955 break;
956 case FRV_OPERAND_FRDOUBLEI :
957 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_FRi);
958 break;
959 case FRV_OPERAND_FRDOUBLEJ :
960 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_FRj);
961 break;
962 case FRV_OPERAND_FRDOUBLEK :
963 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk);
964 break;
965 case FRV_OPERAND_FRI :
966 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_FRi);
967 break;
968 case FRV_OPERAND_FRINTI :
969 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_FRi);
970 break;
971 case FRV_OPERAND_FRINTIEVEN :
972 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_FRi);
973 break;
974 case FRV_OPERAND_FRINTJ :
975 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_FRj);
976 break;
977 case FRV_OPERAND_FRINTJEVEN :
978 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_FRj);
979 break;
980 case FRV_OPERAND_FRINTK :
981 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk);
982 break;
983 case FRV_OPERAND_FRINTKEVEN :
984 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk);
985 break;
986 case FRV_OPERAND_FRJ :
987 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_FRj);
988 break;
989 case FRV_OPERAND_FRK :
990 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk);
991 break;
992 case FRV_OPERAND_FRKHI :
993 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk);
994 break;
995 case FRV_OPERAND_FRKLO :
996 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk);
997 break;
998 case FRV_OPERAND_GRDOUBLEK :
999 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_GRk);
1000 break;
1001 case FRV_OPERAND_GRI :
1002 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_GRi);
1003 break;
1004 case FRV_OPERAND_GRJ :
1005 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_GRj);
1006 break;
1007 case FRV_OPERAND_GRK :
1008 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_GRk);
1009 break;
1010 case FRV_OPERAND_GRKHI :
1011 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_GRk);
1012 break;
1013 case FRV_OPERAND_GRKLO :
1014 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_GRk);
1015 break;
1016 case FRV_OPERAND_ICCI_1 :
1017 length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 2, 32, total_length, pc, & fields->f_ICCi_1);
1018 break;
1019 case FRV_OPERAND_ICCI_2 :
1020 length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & fields->f_ICCi_2);
1021 break;
1022 case FRV_OPERAND_ICCI_3 :
1023 length = extract_normal (cd, ex_info, insn_value, 0, 0, 1, 2, 32, total_length, pc, & fields->f_ICCi_3);
1024 break;
1025 case FRV_OPERAND_LI :
1026 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_LI);
1027 break;
1028 case FRV_OPERAND_LRAD :
1029 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 1, 32, total_length, pc, & fields->f_LRAD);
1030 break;
1031 case FRV_OPERAND_LRAE :
1032 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 1, 32, total_length, pc, & fields->f_LRAE);
1033 break;
1034 case FRV_OPERAND_LRAS :
1035 length = extract_normal (cd, ex_info, insn_value, 0, 0, 3, 1, 32, total_length, pc, & fields->f_LRAS);
1036 break;
1037 case FRV_OPERAND_TLBPRL :
1038 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_TLBPRL);
1039 break;
1040 case FRV_OPERAND_TLBPROPX :
1041 length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 3, 32, total_length, pc, & fields->f_TLBPRopx);
1042 break;
1043 case FRV_OPERAND_AE :
1044 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_ae);
1045 break;
1046 case FRV_OPERAND_CALLANN :
1047 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 0, 32, total_length, pc, & fields->f_reloc_ann);
1048 break;
1049 case FRV_OPERAND_CCOND :
1050 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 1, 32, total_length, pc, & fields->f_ccond);
1051 break;
1052 case FRV_OPERAND_COND :
1053 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 1, 32, total_length, pc, & fields->f_cond);
1054 break;
1055 case FRV_OPERAND_D12 :
1056 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 12, 32, total_length, pc, & fields->f_d12);
1057 break;
1058 case FRV_OPERAND_DEBUG :
1059 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_debug);
1060 break;
1061 case FRV_OPERAND_EIR :
1062 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_eir);
1063 break;
1064 case FRV_OPERAND_HINT :
1065 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 2, 32, total_length, pc, & fields->f_hint);
1066 break;
1067 case FRV_OPERAND_HINT_NOT_TAKEN :
1068 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 2, 32, total_length, pc, & fields->f_hint);
1069 break;
1070 case FRV_OPERAND_HINT_TAKEN :
1071 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 2, 32, total_length, pc, & fields->f_hint);
1072 break;
1073 case FRV_OPERAND_LABEL16 :
1075 long value;
1076 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 15, 16, 32, total_length, pc, & value);
1077 value = ((((value) << (2))) + (pc));
1078 fields->f_label16 = value;
1080 break;
1081 case FRV_OPERAND_LABEL24 :
1083 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 30, 6, 32, total_length, pc, & fields->f_labelH6);
1084 if (length <= 0) break;
1085 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 18, 32, total_length, pc, & fields->f_labelL18);
1086 if (length <= 0) break;
1088 FLD (f_label24) = ((((((((FLD (f_labelH6)) << (18))) | (FLD (f_labelL18)))) << (2))) + (pc));
1091 break;
1092 case FRV_OPERAND_LDANN :
1093 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 0, 32, total_length, pc, & fields->f_reloc_ann);
1094 break;
1095 case FRV_OPERAND_LDDANN :
1096 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 0, 32, total_length, pc, & fields->f_reloc_ann);
1097 break;
1098 case FRV_OPERAND_LOCK :
1099 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_lock);
1100 break;
1101 case FRV_OPERAND_PACK :
1102 length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 1, 32, total_length, pc, & fields->f_pack);
1103 break;
1104 case FRV_OPERAND_S10 :
1105 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 9, 10, 32, total_length, pc, & fields->f_s10);
1106 break;
1107 case FRV_OPERAND_S12 :
1108 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 12, 32, total_length, pc, & fields->f_d12);
1109 break;
1110 case FRV_OPERAND_S16 :
1111 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, pc, & fields->f_s16);
1112 break;
1113 case FRV_OPERAND_S5 :
1114 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 4, 5, 32, total_length, pc, & fields->f_s5);
1115 break;
1116 case FRV_OPERAND_S6 :
1117 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 5, 6, 32, total_length, pc, & fields->f_s6);
1118 break;
1119 case FRV_OPERAND_S6_1 :
1120 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 6, 32, total_length, pc, & fields->f_s6_1);
1121 break;
1122 case FRV_OPERAND_SLO16 :
1123 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, pc, & fields->f_s16);
1124 break;
1125 case FRV_OPERAND_SPR :
1127 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_spr_h);
1128 if (length <= 0) break;
1129 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_spr_l);
1130 if (length <= 0) break;
1132 FLD (f_spr) = ((((FLD (f_spr_h)) << (6))) | (FLD (f_spr_l)));
1135 break;
1136 case FRV_OPERAND_U12 :
1138 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 17, 6, 32, total_length, pc, & fields->f_u12_h);
1139 if (length <= 0) break;
1140 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_u12_l);
1141 if (length <= 0) break;
1143 FLD (f_u12) = ((((FLD (f_u12_h)) << (6))) | (FLD (f_u12_l)));
1146 break;
1147 case FRV_OPERAND_U16 :
1148 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_u16);
1149 break;
1150 case FRV_OPERAND_U6 :
1151 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_u6);
1152 break;
1153 case FRV_OPERAND_UHI16 :
1154 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_u16);
1155 break;
1156 case FRV_OPERAND_ULO16 :
1157 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_u16);
1158 break;
1160 default :
1161 /* xgettext:c-format */
1162 fprintf (stderr, _("Unrecognized field %d while decoding insn.\n"),
1163 opindex);
1164 abort ();
1167 return length;
1170 cgen_insert_fn * const frv_cgen_insert_handlers[] =
1172 insert_insn_normal,
1175 cgen_extract_fn * const frv_cgen_extract_handlers[] =
1177 extract_insn_normal,
1180 int frv_cgen_get_int_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *);
1181 bfd_vma frv_cgen_get_vma_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *);
1183 /* Getting values from cgen_fields is handled by a collection of functions.
1184 They are distinguished by the type of the VALUE argument they return.
1185 TODO: floating point, inlining support, remove cases where result type
1186 not appropriate. */
1189 frv_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1190 int opindex,
1191 const CGEN_FIELDS * fields)
1193 int value;
1195 switch (opindex)
1197 case FRV_OPERAND_A0 :
1198 value = fields->f_A;
1199 break;
1200 case FRV_OPERAND_A1 :
1201 value = fields->f_A;
1202 break;
1203 case FRV_OPERAND_ACC40SI :
1204 value = fields->f_ACC40Si;
1205 break;
1206 case FRV_OPERAND_ACC40SK :
1207 value = fields->f_ACC40Sk;
1208 break;
1209 case FRV_OPERAND_ACC40UI :
1210 value = fields->f_ACC40Ui;
1211 break;
1212 case FRV_OPERAND_ACC40UK :
1213 value = fields->f_ACC40Uk;
1214 break;
1215 case FRV_OPERAND_ACCGI :
1216 value = fields->f_ACCGi;
1217 break;
1218 case FRV_OPERAND_ACCGK :
1219 value = fields->f_ACCGk;
1220 break;
1221 case FRV_OPERAND_CCI :
1222 value = fields->f_CCi;
1223 break;
1224 case FRV_OPERAND_CPRDOUBLEK :
1225 value = fields->f_CPRk;
1226 break;
1227 case FRV_OPERAND_CPRI :
1228 value = fields->f_CPRi;
1229 break;
1230 case FRV_OPERAND_CPRJ :
1231 value = fields->f_CPRj;
1232 break;
1233 case FRV_OPERAND_CPRK :
1234 value = fields->f_CPRk;
1235 break;
1236 case FRV_OPERAND_CRI :
1237 value = fields->f_CRi;
1238 break;
1239 case FRV_OPERAND_CRJ :
1240 value = fields->f_CRj;
1241 break;
1242 case FRV_OPERAND_CRJ_FLOAT :
1243 value = fields->f_CRj_float;
1244 break;
1245 case FRV_OPERAND_CRJ_INT :
1246 value = fields->f_CRj_int;
1247 break;
1248 case FRV_OPERAND_CRK :
1249 value = fields->f_CRk;
1250 break;
1251 case FRV_OPERAND_FCCI_1 :
1252 value = fields->f_FCCi_1;
1253 break;
1254 case FRV_OPERAND_FCCI_2 :
1255 value = fields->f_FCCi_2;
1256 break;
1257 case FRV_OPERAND_FCCI_3 :
1258 value = fields->f_FCCi_3;
1259 break;
1260 case FRV_OPERAND_FCCK :
1261 value = fields->f_FCCk;
1262 break;
1263 case FRV_OPERAND_FRDOUBLEI :
1264 value = fields->f_FRi;
1265 break;
1266 case FRV_OPERAND_FRDOUBLEJ :
1267 value = fields->f_FRj;
1268 break;
1269 case FRV_OPERAND_FRDOUBLEK :
1270 value = fields->f_FRk;
1271 break;
1272 case FRV_OPERAND_FRI :
1273 value = fields->f_FRi;
1274 break;
1275 case FRV_OPERAND_FRINTI :
1276 value = fields->f_FRi;
1277 break;
1278 case FRV_OPERAND_FRINTIEVEN :
1279 value = fields->f_FRi;
1280 break;
1281 case FRV_OPERAND_FRINTJ :
1282 value = fields->f_FRj;
1283 break;
1284 case FRV_OPERAND_FRINTJEVEN :
1285 value = fields->f_FRj;
1286 break;
1287 case FRV_OPERAND_FRINTK :
1288 value = fields->f_FRk;
1289 break;
1290 case FRV_OPERAND_FRINTKEVEN :
1291 value = fields->f_FRk;
1292 break;
1293 case FRV_OPERAND_FRJ :
1294 value = fields->f_FRj;
1295 break;
1296 case FRV_OPERAND_FRK :
1297 value = fields->f_FRk;
1298 break;
1299 case FRV_OPERAND_FRKHI :
1300 value = fields->f_FRk;
1301 break;
1302 case FRV_OPERAND_FRKLO :
1303 value = fields->f_FRk;
1304 break;
1305 case FRV_OPERAND_GRDOUBLEK :
1306 value = fields->f_GRk;
1307 break;
1308 case FRV_OPERAND_GRI :
1309 value = fields->f_GRi;
1310 break;
1311 case FRV_OPERAND_GRJ :
1312 value = fields->f_GRj;
1313 break;
1314 case FRV_OPERAND_GRK :
1315 value = fields->f_GRk;
1316 break;
1317 case FRV_OPERAND_GRKHI :
1318 value = fields->f_GRk;
1319 break;
1320 case FRV_OPERAND_GRKLO :
1321 value = fields->f_GRk;
1322 break;
1323 case FRV_OPERAND_ICCI_1 :
1324 value = fields->f_ICCi_1;
1325 break;
1326 case FRV_OPERAND_ICCI_2 :
1327 value = fields->f_ICCi_2;
1328 break;
1329 case FRV_OPERAND_ICCI_3 :
1330 value = fields->f_ICCi_3;
1331 break;
1332 case FRV_OPERAND_LI :
1333 value = fields->f_LI;
1334 break;
1335 case FRV_OPERAND_LRAD :
1336 value = fields->f_LRAD;
1337 break;
1338 case FRV_OPERAND_LRAE :
1339 value = fields->f_LRAE;
1340 break;
1341 case FRV_OPERAND_LRAS :
1342 value = fields->f_LRAS;
1343 break;
1344 case FRV_OPERAND_TLBPRL :
1345 value = fields->f_TLBPRL;
1346 break;
1347 case FRV_OPERAND_TLBPROPX :
1348 value = fields->f_TLBPRopx;
1349 break;
1350 case FRV_OPERAND_AE :
1351 value = fields->f_ae;
1352 break;
1353 case FRV_OPERAND_CALLANN :
1354 value = fields->f_reloc_ann;
1355 break;
1356 case FRV_OPERAND_CCOND :
1357 value = fields->f_ccond;
1358 break;
1359 case FRV_OPERAND_COND :
1360 value = fields->f_cond;
1361 break;
1362 case FRV_OPERAND_D12 :
1363 value = fields->f_d12;
1364 break;
1365 case FRV_OPERAND_DEBUG :
1366 value = fields->f_debug;
1367 break;
1368 case FRV_OPERAND_EIR :
1369 value = fields->f_eir;
1370 break;
1371 case FRV_OPERAND_HINT :
1372 value = fields->f_hint;
1373 break;
1374 case FRV_OPERAND_HINT_NOT_TAKEN :
1375 value = fields->f_hint;
1376 break;
1377 case FRV_OPERAND_HINT_TAKEN :
1378 value = fields->f_hint;
1379 break;
1380 case FRV_OPERAND_LABEL16 :
1381 value = fields->f_label16;
1382 break;
1383 case FRV_OPERAND_LABEL24 :
1384 value = fields->f_label24;
1385 break;
1386 case FRV_OPERAND_LDANN :
1387 value = fields->f_reloc_ann;
1388 break;
1389 case FRV_OPERAND_LDDANN :
1390 value = fields->f_reloc_ann;
1391 break;
1392 case FRV_OPERAND_LOCK :
1393 value = fields->f_lock;
1394 break;
1395 case FRV_OPERAND_PACK :
1396 value = fields->f_pack;
1397 break;
1398 case FRV_OPERAND_S10 :
1399 value = fields->f_s10;
1400 break;
1401 case FRV_OPERAND_S12 :
1402 value = fields->f_d12;
1403 break;
1404 case FRV_OPERAND_S16 :
1405 value = fields->f_s16;
1406 break;
1407 case FRV_OPERAND_S5 :
1408 value = fields->f_s5;
1409 break;
1410 case FRV_OPERAND_S6 :
1411 value = fields->f_s6;
1412 break;
1413 case FRV_OPERAND_S6_1 :
1414 value = fields->f_s6_1;
1415 break;
1416 case FRV_OPERAND_SLO16 :
1417 value = fields->f_s16;
1418 break;
1419 case FRV_OPERAND_SPR :
1420 value = fields->f_spr;
1421 break;
1422 case FRV_OPERAND_U12 :
1423 value = fields->f_u12;
1424 break;
1425 case FRV_OPERAND_U16 :
1426 value = fields->f_u16;
1427 break;
1428 case FRV_OPERAND_U6 :
1429 value = fields->f_u6;
1430 break;
1431 case FRV_OPERAND_UHI16 :
1432 value = fields->f_u16;
1433 break;
1434 case FRV_OPERAND_ULO16 :
1435 value = fields->f_u16;
1436 break;
1438 default :
1439 /* xgettext:c-format */
1440 fprintf (stderr, _("Unrecognized field %d while getting int operand.\n"),
1441 opindex);
1442 abort ();
1445 return value;
1448 bfd_vma
1449 frv_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1450 int opindex,
1451 const CGEN_FIELDS * fields)
1453 bfd_vma value;
1455 switch (opindex)
1457 case FRV_OPERAND_A0 :
1458 value = fields->f_A;
1459 break;
1460 case FRV_OPERAND_A1 :
1461 value = fields->f_A;
1462 break;
1463 case FRV_OPERAND_ACC40SI :
1464 value = fields->f_ACC40Si;
1465 break;
1466 case FRV_OPERAND_ACC40SK :
1467 value = fields->f_ACC40Sk;
1468 break;
1469 case FRV_OPERAND_ACC40UI :
1470 value = fields->f_ACC40Ui;
1471 break;
1472 case FRV_OPERAND_ACC40UK :
1473 value = fields->f_ACC40Uk;
1474 break;
1475 case FRV_OPERAND_ACCGI :
1476 value = fields->f_ACCGi;
1477 break;
1478 case FRV_OPERAND_ACCGK :
1479 value = fields->f_ACCGk;
1480 break;
1481 case FRV_OPERAND_CCI :
1482 value = fields->f_CCi;
1483 break;
1484 case FRV_OPERAND_CPRDOUBLEK :
1485 value = fields->f_CPRk;
1486 break;
1487 case FRV_OPERAND_CPRI :
1488 value = fields->f_CPRi;
1489 break;
1490 case FRV_OPERAND_CPRJ :
1491 value = fields->f_CPRj;
1492 break;
1493 case FRV_OPERAND_CPRK :
1494 value = fields->f_CPRk;
1495 break;
1496 case FRV_OPERAND_CRI :
1497 value = fields->f_CRi;
1498 break;
1499 case FRV_OPERAND_CRJ :
1500 value = fields->f_CRj;
1501 break;
1502 case FRV_OPERAND_CRJ_FLOAT :
1503 value = fields->f_CRj_float;
1504 break;
1505 case FRV_OPERAND_CRJ_INT :
1506 value = fields->f_CRj_int;
1507 break;
1508 case FRV_OPERAND_CRK :
1509 value = fields->f_CRk;
1510 break;
1511 case FRV_OPERAND_FCCI_1 :
1512 value = fields->f_FCCi_1;
1513 break;
1514 case FRV_OPERAND_FCCI_2 :
1515 value = fields->f_FCCi_2;
1516 break;
1517 case FRV_OPERAND_FCCI_3 :
1518 value = fields->f_FCCi_3;
1519 break;
1520 case FRV_OPERAND_FCCK :
1521 value = fields->f_FCCk;
1522 break;
1523 case FRV_OPERAND_FRDOUBLEI :
1524 value = fields->f_FRi;
1525 break;
1526 case FRV_OPERAND_FRDOUBLEJ :
1527 value = fields->f_FRj;
1528 break;
1529 case FRV_OPERAND_FRDOUBLEK :
1530 value = fields->f_FRk;
1531 break;
1532 case FRV_OPERAND_FRI :
1533 value = fields->f_FRi;
1534 break;
1535 case FRV_OPERAND_FRINTI :
1536 value = fields->f_FRi;
1537 break;
1538 case FRV_OPERAND_FRINTIEVEN :
1539 value = fields->f_FRi;
1540 break;
1541 case FRV_OPERAND_FRINTJ :
1542 value = fields->f_FRj;
1543 break;
1544 case FRV_OPERAND_FRINTJEVEN :
1545 value = fields->f_FRj;
1546 break;
1547 case FRV_OPERAND_FRINTK :
1548 value = fields->f_FRk;
1549 break;
1550 case FRV_OPERAND_FRINTKEVEN :
1551 value = fields->f_FRk;
1552 break;
1553 case FRV_OPERAND_FRJ :
1554 value = fields->f_FRj;
1555 break;
1556 case FRV_OPERAND_FRK :
1557 value = fields->f_FRk;
1558 break;
1559 case FRV_OPERAND_FRKHI :
1560 value = fields->f_FRk;
1561 break;
1562 case FRV_OPERAND_FRKLO :
1563 value = fields->f_FRk;
1564 break;
1565 case FRV_OPERAND_GRDOUBLEK :
1566 value = fields->f_GRk;
1567 break;
1568 case FRV_OPERAND_GRI :
1569 value = fields->f_GRi;
1570 break;
1571 case FRV_OPERAND_GRJ :
1572 value = fields->f_GRj;
1573 break;
1574 case FRV_OPERAND_GRK :
1575 value = fields->f_GRk;
1576 break;
1577 case FRV_OPERAND_GRKHI :
1578 value = fields->f_GRk;
1579 break;
1580 case FRV_OPERAND_GRKLO :
1581 value = fields->f_GRk;
1582 break;
1583 case FRV_OPERAND_ICCI_1 :
1584 value = fields->f_ICCi_1;
1585 break;
1586 case FRV_OPERAND_ICCI_2 :
1587 value = fields->f_ICCi_2;
1588 break;
1589 case FRV_OPERAND_ICCI_3 :
1590 value = fields->f_ICCi_3;
1591 break;
1592 case FRV_OPERAND_LI :
1593 value = fields->f_LI;
1594 break;
1595 case FRV_OPERAND_LRAD :
1596 value = fields->f_LRAD;
1597 break;
1598 case FRV_OPERAND_LRAE :
1599 value = fields->f_LRAE;
1600 break;
1601 case FRV_OPERAND_LRAS :
1602 value = fields->f_LRAS;
1603 break;
1604 case FRV_OPERAND_TLBPRL :
1605 value = fields->f_TLBPRL;
1606 break;
1607 case FRV_OPERAND_TLBPROPX :
1608 value = fields->f_TLBPRopx;
1609 break;
1610 case FRV_OPERAND_AE :
1611 value = fields->f_ae;
1612 break;
1613 case FRV_OPERAND_CALLANN :
1614 value = fields->f_reloc_ann;
1615 break;
1616 case FRV_OPERAND_CCOND :
1617 value = fields->f_ccond;
1618 break;
1619 case FRV_OPERAND_COND :
1620 value = fields->f_cond;
1621 break;
1622 case FRV_OPERAND_D12 :
1623 value = fields->f_d12;
1624 break;
1625 case FRV_OPERAND_DEBUG :
1626 value = fields->f_debug;
1627 break;
1628 case FRV_OPERAND_EIR :
1629 value = fields->f_eir;
1630 break;
1631 case FRV_OPERAND_HINT :
1632 value = fields->f_hint;
1633 break;
1634 case FRV_OPERAND_HINT_NOT_TAKEN :
1635 value = fields->f_hint;
1636 break;
1637 case FRV_OPERAND_HINT_TAKEN :
1638 value = fields->f_hint;
1639 break;
1640 case FRV_OPERAND_LABEL16 :
1641 value = fields->f_label16;
1642 break;
1643 case FRV_OPERAND_LABEL24 :
1644 value = fields->f_label24;
1645 break;
1646 case FRV_OPERAND_LDANN :
1647 value = fields->f_reloc_ann;
1648 break;
1649 case FRV_OPERAND_LDDANN :
1650 value = fields->f_reloc_ann;
1651 break;
1652 case FRV_OPERAND_LOCK :
1653 value = fields->f_lock;
1654 break;
1655 case FRV_OPERAND_PACK :
1656 value = fields->f_pack;
1657 break;
1658 case FRV_OPERAND_S10 :
1659 value = fields->f_s10;
1660 break;
1661 case FRV_OPERAND_S12 :
1662 value = fields->f_d12;
1663 break;
1664 case FRV_OPERAND_S16 :
1665 value = fields->f_s16;
1666 break;
1667 case FRV_OPERAND_S5 :
1668 value = fields->f_s5;
1669 break;
1670 case FRV_OPERAND_S6 :
1671 value = fields->f_s6;
1672 break;
1673 case FRV_OPERAND_S6_1 :
1674 value = fields->f_s6_1;
1675 break;
1676 case FRV_OPERAND_SLO16 :
1677 value = fields->f_s16;
1678 break;
1679 case FRV_OPERAND_SPR :
1680 value = fields->f_spr;
1681 break;
1682 case FRV_OPERAND_U12 :
1683 value = fields->f_u12;
1684 break;
1685 case FRV_OPERAND_U16 :
1686 value = fields->f_u16;
1687 break;
1688 case FRV_OPERAND_U6 :
1689 value = fields->f_u6;
1690 break;
1691 case FRV_OPERAND_UHI16 :
1692 value = fields->f_u16;
1693 break;
1694 case FRV_OPERAND_ULO16 :
1695 value = fields->f_u16;
1696 break;
1698 default :
1699 /* xgettext:c-format */
1700 fprintf (stderr, _("Unrecognized field %d while getting vma operand.\n"),
1701 opindex);
1702 abort ();
1705 return value;
1708 void frv_cgen_set_int_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, int);
1709 void frv_cgen_set_vma_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, bfd_vma);
1711 /* Stuffing values in cgen_fields is handled by a collection of functions.
1712 They are distinguished by the type of the VALUE argument they accept.
1713 TODO: floating point, inlining support, remove cases where argument type
1714 not appropriate. */
1716 void
1717 frv_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1718 int opindex,
1719 CGEN_FIELDS * fields,
1720 int value)
1722 switch (opindex)
1724 case FRV_OPERAND_A0 :
1725 fields->f_A = value;
1726 break;
1727 case FRV_OPERAND_A1 :
1728 fields->f_A = value;
1729 break;
1730 case FRV_OPERAND_ACC40SI :
1731 fields->f_ACC40Si = value;
1732 break;
1733 case FRV_OPERAND_ACC40SK :
1734 fields->f_ACC40Sk = value;
1735 break;
1736 case FRV_OPERAND_ACC40UI :
1737 fields->f_ACC40Ui = value;
1738 break;
1739 case FRV_OPERAND_ACC40UK :
1740 fields->f_ACC40Uk = value;
1741 break;
1742 case FRV_OPERAND_ACCGI :
1743 fields->f_ACCGi = value;
1744 break;
1745 case FRV_OPERAND_ACCGK :
1746 fields->f_ACCGk = value;
1747 break;
1748 case FRV_OPERAND_CCI :
1749 fields->f_CCi = value;
1750 break;
1751 case FRV_OPERAND_CPRDOUBLEK :
1752 fields->f_CPRk = value;
1753 break;
1754 case FRV_OPERAND_CPRI :
1755 fields->f_CPRi = value;
1756 break;
1757 case FRV_OPERAND_CPRJ :
1758 fields->f_CPRj = value;
1759 break;
1760 case FRV_OPERAND_CPRK :
1761 fields->f_CPRk = value;
1762 break;
1763 case FRV_OPERAND_CRI :
1764 fields->f_CRi = value;
1765 break;
1766 case FRV_OPERAND_CRJ :
1767 fields->f_CRj = value;
1768 break;
1769 case FRV_OPERAND_CRJ_FLOAT :
1770 fields->f_CRj_float = value;
1771 break;
1772 case FRV_OPERAND_CRJ_INT :
1773 fields->f_CRj_int = value;
1774 break;
1775 case FRV_OPERAND_CRK :
1776 fields->f_CRk = value;
1777 break;
1778 case FRV_OPERAND_FCCI_1 :
1779 fields->f_FCCi_1 = value;
1780 break;
1781 case FRV_OPERAND_FCCI_2 :
1782 fields->f_FCCi_2 = value;
1783 break;
1784 case FRV_OPERAND_FCCI_3 :
1785 fields->f_FCCi_3 = value;
1786 break;
1787 case FRV_OPERAND_FCCK :
1788 fields->f_FCCk = value;
1789 break;
1790 case FRV_OPERAND_FRDOUBLEI :
1791 fields->f_FRi = value;
1792 break;
1793 case FRV_OPERAND_FRDOUBLEJ :
1794 fields->f_FRj = value;
1795 break;
1796 case FRV_OPERAND_FRDOUBLEK :
1797 fields->f_FRk = value;
1798 break;
1799 case FRV_OPERAND_FRI :
1800 fields->f_FRi = value;
1801 break;
1802 case FRV_OPERAND_FRINTI :
1803 fields->f_FRi = value;
1804 break;
1805 case FRV_OPERAND_FRINTIEVEN :
1806 fields->f_FRi = value;
1807 break;
1808 case FRV_OPERAND_FRINTJ :
1809 fields->f_FRj = value;
1810 break;
1811 case FRV_OPERAND_FRINTJEVEN :
1812 fields->f_FRj = value;
1813 break;
1814 case FRV_OPERAND_FRINTK :
1815 fields->f_FRk = value;
1816 break;
1817 case FRV_OPERAND_FRINTKEVEN :
1818 fields->f_FRk = value;
1819 break;
1820 case FRV_OPERAND_FRJ :
1821 fields->f_FRj = value;
1822 break;
1823 case FRV_OPERAND_FRK :
1824 fields->f_FRk = value;
1825 break;
1826 case FRV_OPERAND_FRKHI :
1827 fields->f_FRk = value;
1828 break;
1829 case FRV_OPERAND_FRKLO :
1830 fields->f_FRk = value;
1831 break;
1832 case FRV_OPERAND_GRDOUBLEK :
1833 fields->f_GRk = value;
1834 break;
1835 case FRV_OPERAND_GRI :
1836 fields->f_GRi = value;
1837 break;
1838 case FRV_OPERAND_GRJ :
1839 fields->f_GRj = value;
1840 break;
1841 case FRV_OPERAND_GRK :
1842 fields->f_GRk = value;
1843 break;
1844 case FRV_OPERAND_GRKHI :
1845 fields->f_GRk = value;
1846 break;
1847 case FRV_OPERAND_GRKLO :
1848 fields->f_GRk = value;
1849 break;
1850 case FRV_OPERAND_ICCI_1 :
1851 fields->f_ICCi_1 = value;
1852 break;
1853 case FRV_OPERAND_ICCI_2 :
1854 fields->f_ICCi_2 = value;
1855 break;
1856 case FRV_OPERAND_ICCI_3 :
1857 fields->f_ICCi_3 = value;
1858 break;
1859 case FRV_OPERAND_LI :
1860 fields->f_LI = value;
1861 break;
1862 case FRV_OPERAND_LRAD :
1863 fields->f_LRAD = value;
1864 break;
1865 case FRV_OPERAND_LRAE :
1866 fields->f_LRAE = value;
1867 break;
1868 case FRV_OPERAND_LRAS :
1869 fields->f_LRAS = value;
1870 break;
1871 case FRV_OPERAND_TLBPRL :
1872 fields->f_TLBPRL = value;
1873 break;
1874 case FRV_OPERAND_TLBPROPX :
1875 fields->f_TLBPRopx = value;
1876 break;
1877 case FRV_OPERAND_AE :
1878 fields->f_ae = value;
1879 break;
1880 case FRV_OPERAND_CALLANN :
1881 fields->f_reloc_ann = value;
1882 break;
1883 case FRV_OPERAND_CCOND :
1884 fields->f_ccond = value;
1885 break;
1886 case FRV_OPERAND_COND :
1887 fields->f_cond = value;
1888 break;
1889 case FRV_OPERAND_D12 :
1890 fields->f_d12 = value;
1891 break;
1892 case FRV_OPERAND_DEBUG :
1893 fields->f_debug = value;
1894 break;
1895 case FRV_OPERAND_EIR :
1896 fields->f_eir = value;
1897 break;
1898 case FRV_OPERAND_HINT :
1899 fields->f_hint = value;
1900 break;
1901 case FRV_OPERAND_HINT_NOT_TAKEN :
1902 fields->f_hint = value;
1903 break;
1904 case FRV_OPERAND_HINT_TAKEN :
1905 fields->f_hint = value;
1906 break;
1907 case FRV_OPERAND_LABEL16 :
1908 fields->f_label16 = value;
1909 break;
1910 case FRV_OPERAND_LABEL24 :
1911 fields->f_label24 = value;
1912 break;
1913 case FRV_OPERAND_LDANN :
1914 fields->f_reloc_ann = value;
1915 break;
1916 case FRV_OPERAND_LDDANN :
1917 fields->f_reloc_ann = value;
1918 break;
1919 case FRV_OPERAND_LOCK :
1920 fields->f_lock = value;
1921 break;
1922 case FRV_OPERAND_PACK :
1923 fields->f_pack = value;
1924 break;
1925 case FRV_OPERAND_S10 :
1926 fields->f_s10 = value;
1927 break;
1928 case FRV_OPERAND_S12 :
1929 fields->f_d12 = value;
1930 break;
1931 case FRV_OPERAND_S16 :
1932 fields->f_s16 = value;
1933 break;
1934 case FRV_OPERAND_S5 :
1935 fields->f_s5 = value;
1936 break;
1937 case FRV_OPERAND_S6 :
1938 fields->f_s6 = value;
1939 break;
1940 case FRV_OPERAND_S6_1 :
1941 fields->f_s6_1 = value;
1942 break;
1943 case FRV_OPERAND_SLO16 :
1944 fields->f_s16 = value;
1945 break;
1946 case FRV_OPERAND_SPR :
1947 fields->f_spr = value;
1948 break;
1949 case FRV_OPERAND_U12 :
1950 fields->f_u12 = value;
1951 break;
1952 case FRV_OPERAND_U16 :
1953 fields->f_u16 = value;
1954 break;
1955 case FRV_OPERAND_U6 :
1956 fields->f_u6 = value;
1957 break;
1958 case FRV_OPERAND_UHI16 :
1959 fields->f_u16 = value;
1960 break;
1961 case FRV_OPERAND_ULO16 :
1962 fields->f_u16 = value;
1963 break;
1965 default :
1966 /* xgettext:c-format */
1967 fprintf (stderr, _("Unrecognized field %d while setting int operand.\n"),
1968 opindex);
1969 abort ();
1973 void
1974 frv_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1975 int opindex,
1976 CGEN_FIELDS * fields,
1977 bfd_vma value)
1979 switch (opindex)
1981 case FRV_OPERAND_A0 :
1982 fields->f_A = value;
1983 break;
1984 case FRV_OPERAND_A1 :
1985 fields->f_A = value;
1986 break;
1987 case FRV_OPERAND_ACC40SI :
1988 fields->f_ACC40Si = value;
1989 break;
1990 case FRV_OPERAND_ACC40SK :
1991 fields->f_ACC40Sk = value;
1992 break;
1993 case FRV_OPERAND_ACC40UI :
1994 fields->f_ACC40Ui = value;
1995 break;
1996 case FRV_OPERAND_ACC40UK :
1997 fields->f_ACC40Uk = value;
1998 break;
1999 case FRV_OPERAND_ACCGI :
2000 fields->f_ACCGi = value;
2001 break;
2002 case FRV_OPERAND_ACCGK :
2003 fields->f_ACCGk = value;
2004 break;
2005 case FRV_OPERAND_CCI :
2006 fields->f_CCi = value;
2007 break;
2008 case FRV_OPERAND_CPRDOUBLEK :
2009 fields->f_CPRk = value;
2010 break;
2011 case FRV_OPERAND_CPRI :
2012 fields->f_CPRi = value;
2013 break;
2014 case FRV_OPERAND_CPRJ :
2015 fields->f_CPRj = value;
2016 break;
2017 case FRV_OPERAND_CPRK :
2018 fields->f_CPRk = value;
2019 break;
2020 case FRV_OPERAND_CRI :
2021 fields->f_CRi = value;
2022 break;
2023 case FRV_OPERAND_CRJ :
2024 fields->f_CRj = value;
2025 break;
2026 case FRV_OPERAND_CRJ_FLOAT :
2027 fields->f_CRj_float = value;
2028 break;
2029 case FRV_OPERAND_CRJ_INT :
2030 fields->f_CRj_int = value;
2031 break;
2032 case FRV_OPERAND_CRK :
2033 fields->f_CRk = value;
2034 break;
2035 case FRV_OPERAND_FCCI_1 :
2036 fields->f_FCCi_1 = value;
2037 break;
2038 case FRV_OPERAND_FCCI_2 :
2039 fields->f_FCCi_2 = value;
2040 break;
2041 case FRV_OPERAND_FCCI_3 :
2042 fields->f_FCCi_3 = value;
2043 break;
2044 case FRV_OPERAND_FCCK :
2045 fields->f_FCCk = value;
2046 break;
2047 case FRV_OPERAND_FRDOUBLEI :
2048 fields->f_FRi = value;
2049 break;
2050 case FRV_OPERAND_FRDOUBLEJ :
2051 fields->f_FRj = value;
2052 break;
2053 case FRV_OPERAND_FRDOUBLEK :
2054 fields->f_FRk = value;
2055 break;
2056 case FRV_OPERAND_FRI :
2057 fields->f_FRi = value;
2058 break;
2059 case FRV_OPERAND_FRINTI :
2060 fields->f_FRi = value;
2061 break;
2062 case FRV_OPERAND_FRINTIEVEN :
2063 fields->f_FRi = value;
2064 break;
2065 case FRV_OPERAND_FRINTJ :
2066 fields->f_FRj = value;
2067 break;
2068 case FRV_OPERAND_FRINTJEVEN :
2069 fields->f_FRj = value;
2070 break;
2071 case FRV_OPERAND_FRINTK :
2072 fields->f_FRk = value;
2073 break;
2074 case FRV_OPERAND_FRINTKEVEN :
2075 fields->f_FRk = value;
2076 break;
2077 case FRV_OPERAND_FRJ :
2078 fields->f_FRj = value;
2079 break;
2080 case FRV_OPERAND_FRK :
2081 fields->f_FRk = value;
2082 break;
2083 case FRV_OPERAND_FRKHI :
2084 fields->f_FRk = value;
2085 break;
2086 case FRV_OPERAND_FRKLO :
2087 fields->f_FRk = value;
2088 break;
2089 case FRV_OPERAND_GRDOUBLEK :
2090 fields->f_GRk = value;
2091 break;
2092 case FRV_OPERAND_GRI :
2093 fields->f_GRi = value;
2094 break;
2095 case FRV_OPERAND_GRJ :
2096 fields->f_GRj = value;
2097 break;
2098 case FRV_OPERAND_GRK :
2099 fields->f_GRk = value;
2100 break;
2101 case FRV_OPERAND_GRKHI :
2102 fields->f_GRk = value;
2103 break;
2104 case FRV_OPERAND_GRKLO :
2105 fields->f_GRk = value;
2106 break;
2107 case FRV_OPERAND_ICCI_1 :
2108 fields->f_ICCi_1 = value;
2109 break;
2110 case FRV_OPERAND_ICCI_2 :
2111 fields->f_ICCi_2 = value;
2112 break;
2113 case FRV_OPERAND_ICCI_3 :
2114 fields->f_ICCi_3 = value;
2115 break;
2116 case FRV_OPERAND_LI :
2117 fields->f_LI = value;
2118 break;
2119 case FRV_OPERAND_LRAD :
2120 fields->f_LRAD = value;
2121 break;
2122 case FRV_OPERAND_LRAE :
2123 fields->f_LRAE = value;
2124 break;
2125 case FRV_OPERAND_LRAS :
2126 fields->f_LRAS = value;
2127 break;
2128 case FRV_OPERAND_TLBPRL :
2129 fields->f_TLBPRL = value;
2130 break;
2131 case FRV_OPERAND_TLBPROPX :
2132 fields->f_TLBPRopx = value;
2133 break;
2134 case FRV_OPERAND_AE :
2135 fields->f_ae = value;
2136 break;
2137 case FRV_OPERAND_CALLANN :
2138 fields->f_reloc_ann = value;
2139 break;
2140 case FRV_OPERAND_CCOND :
2141 fields->f_ccond = value;
2142 break;
2143 case FRV_OPERAND_COND :
2144 fields->f_cond = value;
2145 break;
2146 case FRV_OPERAND_D12 :
2147 fields->f_d12 = value;
2148 break;
2149 case FRV_OPERAND_DEBUG :
2150 fields->f_debug = value;
2151 break;
2152 case FRV_OPERAND_EIR :
2153 fields->f_eir = value;
2154 break;
2155 case FRV_OPERAND_HINT :
2156 fields->f_hint = value;
2157 break;
2158 case FRV_OPERAND_HINT_NOT_TAKEN :
2159 fields->f_hint = value;
2160 break;
2161 case FRV_OPERAND_HINT_TAKEN :
2162 fields->f_hint = value;
2163 break;
2164 case FRV_OPERAND_LABEL16 :
2165 fields->f_label16 = value;
2166 break;
2167 case FRV_OPERAND_LABEL24 :
2168 fields->f_label24 = value;
2169 break;
2170 case FRV_OPERAND_LDANN :
2171 fields->f_reloc_ann = value;
2172 break;
2173 case FRV_OPERAND_LDDANN :
2174 fields->f_reloc_ann = value;
2175 break;
2176 case FRV_OPERAND_LOCK :
2177 fields->f_lock = value;
2178 break;
2179 case FRV_OPERAND_PACK :
2180 fields->f_pack = value;
2181 break;
2182 case FRV_OPERAND_S10 :
2183 fields->f_s10 = value;
2184 break;
2185 case FRV_OPERAND_S12 :
2186 fields->f_d12 = value;
2187 break;
2188 case FRV_OPERAND_S16 :
2189 fields->f_s16 = value;
2190 break;
2191 case FRV_OPERAND_S5 :
2192 fields->f_s5 = value;
2193 break;
2194 case FRV_OPERAND_S6 :
2195 fields->f_s6 = value;
2196 break;
2197 case FRV_OPERAND_S6_1 :
2198 fields->f_s6_1 = value;
2199 break;
2200 case FRV_OPERAND_SLO16 :
2201 fields->f_s16 = value;
2202 break;
2203 case FRV_OPERAND_SPR :
2204 fields->f_spr = value;
2205 break;
2206 case FRV_OPERAND_U12 :
2207 fields->f_u12 = value;
2208 break;
2209 case FRV_OPERAND_U16 :
2210 fields->f_u16 = value;
2211 break;
2212 case FRV_OPERAND_U6 :
2213 fields->f_u6 = value;
2214 break;
2215 case FRV_OPERAND_UHI16 :
2216 fields->f_u16 = value;
2217 break;
2218 case FRV_OPERAND_ULO16 :
2219 fields->f_u16 = value;
2220 break;
2222 default :
2223 /* xgettext:c-format */
2224 fprintf (stderr, _("Unrecognized field %d while setting vma operand.\n"),
2225 opindex);
2226 abort ();
2230 /* Function to call before using the instruction builder tables. */
2232 void
2233 frv_cgen_init_ibld_table (CGEN_CPU_DESC cd)
2235 cd->insert_handlers = & frv_cgen_insert_handlers[0];
2236 cd->extract_handlers = & frv_cgen_extract_handlers[0];
2238 cd->insert_operand = frv_cgen_insert_operand;
2239 cd->extract_operand = frv_cgen_extract_operand;
2241 cd->get_int_operand = frv_cgen_get_int_operand;
2242 cd->set_int_operand = frv_cgen_set_int_operand;
2243 cd->get_vma_operand = frv_cgen_get_vma_operand;
2244 cd->set_vma_operand = frv_cgen_set_vma_operand;