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 Free Software Foundation, Inc.
8 This file is part of the GNU Binutils and GDB, the GNU debugger.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software Foundation, Inc.,
22 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
24 /* ??? Eventually more and more of this stuff can go to cpu-independent files.
36 #include "safe-ctype.h"
39 #define min(a,b) ((a) < (b) ? (a) : (b))
41 #define max(a,b) ((a) > (b) ? (a) : (b))
43 /* Used by the ifield rtx function. */
44 #define FLD(f) (fields->f)
46 static const char * insert_normal
47 PARAMS ((CGEN_CPU_DESC, long, unsigned int, unsigned int, unsigned int,
48 unsigned int, unsigned int, unsigned int, CGEN_INSN_BYTES_PTR));
49 static const char * insert_insn_normal
50 PARAMS ((CGEN_CPU_DESC, const CGEN_INSN *,
51 CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma));
52 static int extract_normal
53 PARAMS ((CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, CGEN_INSN_INT,
54 unsigned int, unsigned int, unsigned int, unsigned int,
55 unsigned int, unsigned int, bfd_vma, long *));
56 static int extract_insn_normal
57 PARAMS ((CGEN_CPU_DESC, const CGEN_INSN *, CGEN_EXTRACT_INFO *,
58 CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma));
60 static void put_insn_int_value
61 PARAMS ((CGEN_CPU_DESC, CGEN_INSN_BYTES_PTR, int, int, CGEN_INSN_INT));
64 static CGEN_INLINE void insert_1
65 PARAMS ((CGEN_CPU_DESC, unsigned long, int, int, int, unsigned char *));
66 static CGEN_INLINE int fill_cache
67 PARAMS ((CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, int, int, bfd_vma));
68 static CGEN_INLINE long extract_1
69 PARAMS ((CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, int, int, int,
70 unsigned char *, bfd_vma));
73 /* Operand insertion. */
77 /* Subroutine of insert_normal. */
79 static CGEN_INLINE void
80 insert_1 (cd, value, start, length, word_length, bufp)
83 int start,length,word_length;
89 x = cgen_get_insn_value (cd, bufp, word_length);
91 /* Written this way to avoid undefined behaviour. */
92 mask = (((1L << (length - 1)) - 1) << 1) | 1;
94 shift = (start + 1) - length;
96 shift = (word_length - (start + length));
97 x = (x & ~(mask << shift)) | ((value & mask) << shift);
99 cgen_put_insn_value (cd, bufp, word_length, (bfd_vma) x);
102 #endif /* ! CGEN_INT_INSN_P */
104 /* Default insertion routine.
106 ATTRS is a mask of the boolean attributes.
107 WORD_OFFSET is the offset in bits from the start of the insn of the value.
108 WORD_LENGTH is the length of the word in bits in which the value resides.
109 START is the starting bit number in the word, architecture origin.
110 LENGTH is the length of VALUE in bits.
111 TOTAL_LENGTH is the total length of the insn in bits.
113 The result is an error message or NULL if success. */
115 /* ??? This duplicates functionality with bfd's howto table and
116 bfd_install_relocation. */
117 /* ??? This doesn't handle bfd_vma's. Create another function when
121 insert_normal (cd, value, attrs, word_offset, start, length, word_length,
122 total_length, buffer)
126 unsigned int word_offset, start, length, word_length, total_length;
127 CGEN_INSN_BYTES_PTR buffer;
129 static char errbuf[100];
130 /* Written this way to avoid undefined behaviour. */
131 unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
133 /* If LENGTH is zero, this operand doesn't contribute to the value. */
143 if (word_length > 32)
146 /* For architectures with insns smaller than the base-insn-bitsize,
147 word_length may be too big. */
148 if (cd->min_insn_bitsize < cd->base_insn_bitsize)
151 && word_length > total_length)
152 word_length = total_length;
155 /* Ensure VALUE will fit. */
156 if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGN_OPT))
158 long minval = - (1L << (length - 1));
159 unsigned long maxval = mask;
161 if ((value > 0 && (unsigned long) value > maxval)
164 /* xgettext:c-format */
166 _("operand out of range (%ld not between %ld and %lu)"),
167 value, minval, maxval);
171 else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED))
173 unsigned long maxval = mask;
175 if ((unsigned long) value > maxval)
177 /* xgettext:c-format */
179 _("operand out of range (%lu not between 0 and %lu)"),
186 if (! cgen_signed_overflow_ok_p (cd))
188 long minval = - (1L << (length - 1));
189 long maxval = (1L << (length - 1)) - 1;
191 if (value < minval || value > maxval)
194 /* xgettext:c-format */
195 (errbuf, _("operand out of range (%ld not between %ld and %ld)"),
196 value, minval, maxval);
207 if (CGEN_INSN_LSB0_P)
208 shift = (word_offset + start + 1) - length;
210 shift = total_length - (word_offset + start + length);
211 *buffer = (*buffer & ~(mask << shift)) | ((value & mask) << shift);
214 #else /* ! CGEN_INT_INSN_P */
217 unsigned char *bufp = (unsigned char *) buffer + word_offset / 8;
219 insert_1 (cd, value, start, length, word_length, bufp);
222 #endif /* ! CGEN_INT_INSN_P */
227 /* Default insn builder (insert handler).
228 The instruction is recorded in CGEN_INT_INSN_P byte order (meaning
229 that if CGEN_INSN_BYTES_PTR is an int * and thus, the value is
230 recorded in host byte order, otherwise BUFFER is an array of bytes
231 and the value is recorded in target byte order).
232 The result is an error message or NULL if success. */
235 insert_insn_normal (cd, insn, fields, buffer, pc)
237 const CGEN_INSN * insn;
238 CGEN_FIELDS * fields;
239 CGEN_INSN_BYTES_PTR buffer;
242 const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
244 const CGEN_SYNTAX_CHAR_TYPE * syn;
246 CGEN_INIT_INSERT (cd);
247 value = CGEN_INSN_BASE_VALUE (insn);
249 /* If we're recording insns as numbers (rather than a string of bytes),
250 target byte order handling is deferred until later. */
254 put_insn_int_value (cd, buffer, cd->base_insn_bitsize,
255 CGEN_FIELDS_BITSIZE (fields), value);
259 cgen_put_insn_value (cd, buffer, min ((unsigned) cd->base_insn_bitsize,
260 (unsigned) CGEN_FIELDS_BITSIZE (fields)),
263 #endif /* ! CGEN_INT_INSN_P */
265 /* ??? It would be better to scan the format's fields.
266 Still need to be able to insert a value based on the operand though;
267 e.g. storing a branch displacement that got resolved later.
268 Needs more thought first. */
270 for (syn = CGEN_SYNTAX_STRING (syntax); * syn; ++ syn)
274 if (CGEN_SYNTAX_CHAR_P (* syn))
277 errmsg = (* cd->insert_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
287 /* Cover function to store an insn value into an integral insn. Must go here
288 because it needs <prefix>-desc.h for CGEN_INT_INSN_P. */
291 put_insn_int_value (cd, buf, length, insn_length, value)
292 CGEN_CPU_DESC cd ATTRIBUTE_UNUSED;
293 CGEN_INSN_BYTES_PTR buf;
298 /* For architectures with insns smaller than the base-insn-bitsize,
299 length may be too big. */
300 if (length > insn_length)
304 int shift = insn_length - length;
305 /* Written this way to avoid undefined behaviour. */
306 CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1;
307 *buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
312 /* Operand extraction. */
314 #if ! CGEN_INT_INSN_P
316 /* Subroutine of extract_normal.
317 Ensure sufficient bytes are cached in EX_INFO.
318 OFFSET is the offset in bytes from the start of the insn of the value.
319 BYTES is the length of the needed value.
320 Returns 1 for success, 0 for failure. */
322 static CGEN_INLINE int
323 fill_cache (cd, ex_info, offset, bytes, pc)
324 CGEN_CPU_DESC cd ATTRIBUTE_UNUSED;
325 CGEN_EXTRACT_INFO *ex_info;
329 /* It's doubtful that the middle part has already been fetched so
330 we don't optimize that case. kiss. */
332 disassemble_info *info = (disassemble_info *) ex_info->dis_info;
334 /* First do a quick check. */
335 mask = (1 << bytes) - 1;
336 if (((ex_info->valid >> offset) & mask) == mask)
339 /* Search for the first byte we need to read. */
340 for (mask = 1 << offset; bytes > 0; --bytes, ++offset, mask <<= 1)
341 if (! (mask & ex_info->valid))
349 status = (*info->read_memory_func)
350 (pc, ex_info->insn_bytes + offset, bytes, info);
354 (*info->memory_error_func) (status, pc, info);
358 ex_info->valid |= ((1 << bytes) - 1) << offset;
364 /* Subroutine of extract_normal. */
366 static CGEN_INLINE long
367 extract_1 (cd, ex_info, start, length, word_length, bufp, pc)
369 CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED;
370 int start,length,word_length;
372 bfd_vma pc ATTRIBUTE_UNUSED;
377 int big_p = CGEN_CPU_INSN_ENDIAN (cd) == CGEN_ENDIAN_BIG;
379 x = cgen_get_insn_value (cd, bufp, word_length);
381 if (CGEN_INSN_LSB0_P)
382 shift = (start + 1) - length;
384 shift = (word_length - (start + length));
388 #endif /* ! CGEN_INT_INSN_P */
390 /* Default extraction routine.
392 INSN_VALUE is the first base_insn_bitsize bits of the insn in host order,
393 or sometimes less for cases like the m32r where the base insn size is 32
394 but some insns are 16 bits.
395 ATTRS is a mask of the boolean attributes. We only need `SIGNED',
396 but for generality we take a bitmask of all of them.
397 WORD_OFFSET is the offset in bits from the start of the insn of the value.
398 WORD_LENGTH is the length of the word in bits in which the value resides.
399 START is the starting bit number in the word, architecture origin.
400 LENGTH is the length of VALUE in bits.
401 TOTAL_LENGTH is the total length of the insn in bits.
403 Returns 1 for success, 0 for failure. */
405 /* ??? The return code isn't properly used. wip. */
407 /* ??? This doesn't handle bfd_vma's. Create another function when
411 extract_normal (cd, ex_info, insn_value, attrs, word_offset, start, length,
412 word_length, total_length, pc, valuep)
414 #if ! CGEN_INT_INSN_P
415 CGEN_EXTRACT_INFO *ex_info;
417 CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED;
419 CGEN_INSN_INT insn_value;
421 unsigned int word_offset, start, length, word_length, total_length;
422 #if ! CGEN_INT_INSN_P
425 bfd_vma pc ATTRIBUTE_UNUSED;
431 /* If LENGTH is zero, this operand doesn't contribute to the value
432 so give it a standard value of zero. */
445 if (word_length > 32)
448 /* For architectures with insns smaller than the insn-base-bitsize,
449 word_length may be too big. */
450 if (cd->min_insn_bitsize < cd->base_insn_bitsize)
453 && word_length > total_length)
454 word_length = total_length;
457 /* Does the value reside in INSN_VALUE, and at the right alignment? */
459 if (CGEN_INT_INSN_P || (word_offset == 0 && word_length == total_length))
461 if (CGEN_INSN_LSB0_P)
462 value = insn_value >> ((word_offset + start + 1) - length);
464 value = insn_value >> (total_length - ( word_offset + start + length));
467 #if ! CGEN_INT_INSN_P
471 unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
473 if (word_length > 32)
476 if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
479 value = extract_1 (cd, ex_info, start, length, word_length, bufp, pc);
482 #endif /* ! CGEN_INT_INSN_P */
484 /* Written this way to avoid undefined behaviour. */
485 mask = (((1L << (length - 1)) - 1) << 1) | 1;
489 if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)
490 && (value & (1L << (length - 1))))
498 /* Default insn extractor.
500 INSN_VALUE is the first base_insn_bitsize bits, translated to host order.
501 The extracted fields are stored in FIELDS.
502 EX_INFO is used to handle reading variable length insns.
503 Return the length of the insn in bits, or 0 if no match,
504 or -1 if an error occurs fetching data (memory_error_func will have
508 extract_insn_normal (cd, insn, ex_info, insn_value, fields, pc)
510 const CGEN_INSN *insn;
511 CGEN_EXTRACT_INFO *ex_info;
512 CGEN_INSN_INT insn_value;
516 const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
517 const CGEN_SYNTAX_CHAR_TYPE *syn;
519 CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn);
521 CGEN_INIT_EXTRACT (cd);
523 for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn)
527 if (CGEN_SYNTAX_CHAR_P (*syn))
530 length = (* cd->extract_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
531 ex_info, insn_value, fields, pc);
536 /* We recognized and successfully extracted this insn. */
537 return CGEN_INSN_BITSIZE (insn);
540 /* machine generated code added here */
542 const char * frv_cgen_insert_operand
543 PARAMS ((CGEN_CPU_DESC, int, CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma));
545 /* Main entry point for operand insertion.
547 This function is basically just a big switch statement. Earlier versions
548 used tables to look up the function to use, but
549 - if the table contains both assembler and disassembler functions then
550 the disassembler contains much of the assembler and vice-versa,
551 - there's a lot of inlining possibilities as things grow,
552 - using a switch statement avoids the function call overhead.
554 This function could be moved into `parse_insn_normal', but keeping it
555 separate makes clear the interface between `parse_insn_normal' and each of
556 the handlers. It's also needed by GAS to insert operands that couldn't be
557 resolved during parsing. */
560 frv_cgen_insert_operand (cd, opindex, fields, buffer, pc)
563 CGEN_FIELDS * fields;
564 CGEN_INSN_BYTES_PTR buffer;
565 bfd_vma pc ATTRIBUTE_UNUSED;
567 const char * errmsg = NULL;
568 unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
573 errmsg = insert_normal (cd, fields->f_A, 0, 0, 17, 1, 32, total_length, buffer);
575 case FRV_OPERAND_ACC40SI :
576 errmsg = insert_normal (cd, fields->f_ACC40Si, 0, 0, 17, 6, 32, total_length, buffer);
578 case FRV_OPERAND_ACC40SK :
579 errmsg = insert_normal (cd, fields->f_ACC40Sk, 0, 0, 30, 6, 32, total_length, buffer);
581 case FRV_OPERAND_ACC40UI :
582 errmsg = insert_normal (cd, fields->f_ACC40Ui, 0, 0, 17, 6, 32, total_length, buffer);
584 case FRV_OPERAND_ACC40UK :
585 errmsg = insert_normal (cd, fields->f_ACC40Uk, 0, 0, 30, 6, 32, total_length, buffer);
587 case FRV_OPERAND_ACCGI :
588 errmsg = insert_normal (cd, fields->f_ACCGi, 0, 0, 17, 6, 32, total_length, buffer);
590 case FRV_OPERAND_ACCGK :
591 errmsg = insert_normal (cd, fields->f_ACCGk, 0, 0, 30, 6, 32, total_length, buffer);
593 case FRV_OPERAND_CCI :
594 errmsg = insert_normal (cd, fields->f_CCi, 0, 0, 11, 3, 32, total_length, buffer);
596 case FRV_OPERAND_CPRDOUBLEK :
597 errmsg = insert_normal (cd, fields->f_CPRk, 0, 0, 30, 6, 32, total_length, buffer);
599 case FRV_OPERAND_CPRI :
600 errmsg = insert_normal (cd, fields->f_CPRi, 0, 0, 17, 6, 32, total_length, buffer);
602 case FRV_OPERAND_CPRJ :
603 errmsg = insert_normal (cd, fields->f_CPRj, 0, 0, 5, 6, 32, total_length, buffer);
605 case FRV_OPERAND_CPRK :
606 errmsg = insert_normal (cd, fields->f_CPRk, 0, 0, 30, 6, 32, total_length, buffer);
608 case FRV_OPERAND_CRI :
609 errmsg = insert_normal (cd, fields->f_CRi, 0, 0, 14, 3, 32, total_length, buffer);
611 case FRV_OPERAND_CRJ :
612 errmsg = insert_normal (cd, fields->f_CRj, 0, 0, 2, 3, 32, total_length, buffer);
614 case FRV_OPERAND_CRJ_FLOAT :
615 errmsg = insert_normal (cd, fields->f_CRj_float, 0, 0, 26, 2, 32, total_length, buffer);
617 case FRV_OPERAND_CRJ_INT :
619 long value = fields->f_CRj_int;
620 value = ((value) - (4));
621 errmsg = insert_normal (cd, value, 0, 0, 26, 2, 32, total_length, buffer);
624 case FRV_OPERAND_CRK :
625 errmsg = insert_normal (cd, fields->f_CRk, 0, 0, 27, 3, 32, total_length, buffer);
627 case FRV_OPERAND_FCCI_1 :
628 errmsg = insert_normal (cd, fields->f_FCCi_1, 0, 0, 11, 2, 32, total_length, buffer);
630 case FRV_OPERAND_FCCI_2 :
631 errmsg = insert_normal (cd, fields->f_FCCi_2, 0, 0, 26, 2, 32, total_length, buffer);
633 case FRV_OPERAND_FCCI_3 :
634 errmsg = insert_normal (cd, fields->f_FCCi_3, 0, 0, 1, 2, 32, total_length, buffer);
636 case FRV_OPERAND_FCCK :
637 errmsg = insert_normal (cd, fields->f_FCCk, 0, 0, 26, 2, 32, total_length, buffer);
639 case FRV_OPERAND_FRDOUBLEI :
640 errmsg = insert_normal (cd, fields->f_FRi, 0, 0, 17, 6, 32, total_length, buffer);
642 case FRV_OPERAND_FRDOUBLEJ :
643 errmsg = insert_normal (cd, fields->f_FRj, 0, 0, 5, 6, 32, total_length, buffer);
645 case FRV_OPERAND_FRDOUBLEK :
646 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer);
648 case FRV_OPERAND_FRI :
649 errmsg = insert_normal (cd, fields->f_FRi, 0, 0, 17, 6, 32, total_length, buffer);
651 case FRV_OPERAND_FRINTI :
652 errmsg = insert_normal (cd, fields->f_FRi, 0, 0, 17, 6, 32, total_length, buffer);
654 case FRV_OPERAND_FRINTIEVEN :
655 errmsg = insert_normal (cd, fields->f_FRi, 0, 0, 17, 6, 32, total_length, buffer);
657 case FRV_OPERAND_FRINTJ :
658 errmsg = insert_normal (cd, fields->f_FRj, 0, 0, 5, 6, 32, total_length, buffer);
660 case FRV_OPERAND_FRINTJEVEN :
661 errmsg = insert_normal (cd, fields->f_FRj, 0, 0, 5, 6, 32, total_length, buffer);
663 case FRV_OPERAND_FRINTK :
664 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer);
666 case FRV_OPERAND_FRINTKEVEN :
667 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer);
669 case FRV_OPERAND_FRJ :
670 errmsg = insert_normal (cd, fields->f_FRj, 0, 0, 5, 6, 32, total_length, buffer);
672 case FRV_OPERAND_FRK :
673 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer);
675 case FRV_OPERAND_FRKHI :
676 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer);
678 case FRV_OPERAND_FRKLO :
679 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer);
681 case FRV_OPERAND_GRDOUBLEK :
682 errmsg = insert_normal (cd, fields->f_GRk, 0, 0, 30, 6, 32, total_length, buffer);
684 case FRV_OPERAND_GRI :
685 errmsg = insert_normal (cd, fields->f_GRi, 0, 0, 17, 6, 32, total_length, buffer);
687 case FRV_OPERAND_GRJ :
688 errmsg = insert_normal (cd, fields->f_GRj, 0, 0, 5, 6, 32, total_length, buffer);
690 case FRV_OPERAND_GRK :
691 errmsg = insert_normal (cd, fields->f_GRk, 0, 0, 30, 6, 32, total_length, buffer);
693 case FRV_OPERAND_GRKHI :
694 errmsg = insert_normal (cd, fields->f_GRk, 0, 0, 30, 6, 32, total_length, buffer);
696 case FRV_OPERAND_GRKLO :
697 errmsg = insert_normal (cd, fields->f_GRk, 0, 0, 30, 6, 32, total_length, buffer);
699 case FRV_OPERAND_ICCI_1 :
700 errmsg = insert_normal (cd, fields->f_ICCi_1, 0, 0, 11, 2, 32, total_length, buffer);
702 case FRV_OPERAND_ICCI_2 :
703 errmsg = insert_normal (cd, fields->f_ICCi_2, 0, 0, 26, 2, 32, total_length, buffer);
705 case FRV_OPERAND_ICCI_3 :
706 errmsg = insert_normal (cd, fields->f_ICCi_3, 0, 0, 1, 2, 32, total_length, buffer);
708 case FRV_OPERAND_LI :
709 errmsg = insert_normal (cd, fields->f_LI, 0, 0, 25, 1, 32, total_length, buffer);
711 case FRV_OPERAND_AE :
712 errmsg = insert_normal (cd, fields->f_ae, 0, 0, 25, 1, 32, total_length, buffer);
714 case FRV_OPERAND_CCOND :
715 errmsg = insert_normal (cd, fields->f_ccond, 0, 0, 12, 1, 32, total_length, buffer);
717 case FRV_OPERAND_COND :
718 errmsg = insert_normal (cd, fields->f_cond, 0, 0, 8, 1, 32, total_length, buffer);
720 case FRV_OPERAND_D12 :
721 errmsg = insert_normal (cd, fields->f_d12, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 12, 32, total_length, buffer);
723 case FRV_OPERAND_DEBUG :
724 errmsg = insert_normal (cd, fields->f_debug, 0, 0, 25, 1, 32, total_length, buffer);
726 case FRV_OPERAND_EIR :
727 errmsg = insert_normal (cd, fields->f_eir, 0, 0, 17, 6, 32, total_length, buffer);
729 case FRV_OPERAND_HINT :
730 errmsg = insert_normal (cd, fields->f_hint, 0, 0, 17, 2, 32, total_length, buffer);
732 case FRV_OPERAND_HINT_NOT_TAKEN :
733 errmsg = insert_normal (cd, fields->f_hint, 0, 0, 17, 2, 32, total_length, buffer);
735 case FRV_OPERAND_HINT_TAKEN :
736 errmsg = insert_normal (cd, fields->f_hint, 0, 0, 17, 2, 32, total_length, buffer);
738 case FRV_OPERAND_LABEL16 :
740 long value = fields->f_label16;
741 value = ((int) (((value) - (pc))) >> (2));
742 errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 15, 16, 32, total_length, buffer);
745 case FRV_OPERAND_LABEL24 :
748 FLD (f_labelH6) = ((int) (((FLD (f_label24)) - (pc))) >> (20));
749 FLD (f_labelL18) = ((((unsigned int) (((FLD (f_label24)) - (pc))) >> (2))) & (262143));
751 errmsg = insert_normal (cd, fields->f_labelH6, 0|(1<<CGEN_IFLD_SIGNED), 0, 30, 6, 32, total_length, buffer);
754 errmsg = insert_normal (cd, fields->f_labelL18, 0, 0, 17, 18, 32, total_length, buffer);
759 case FRV_OPERAND_LOCK :
760 errmsg = insert_normal (cd, fields->f_lock, 0, 0, 25, 1, 32, total_length, buffer);
762 case FRV_OPERAND_PACK :
763 errmsg = insert_normal (cd, fields->f_pack, 0, 0, 31, 1, 32, total_length, buffer);
765 case FRV_OPERAND_S10 :
766 errmsg = insert_normal (cd, fields->f_s10, 0|(1<<CGEN_IFLD_SIGNED), 0, 9, 10, 32, total_length, buffer);
768 case FRV_OPERAND_S12 :
769 errmsg = insert_normal (cd, fields->f_d12, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 12, 32, total_length, buffer);
771 case FRV_OPERAND_S16 :
772 errmsg = insert_normal (cd, fields->f_s16, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, buffer);
774 case FRV_OPERAND_S5 :
775 errmsg = insert_normal (cd, fields->f_s5, 0|(1<<CGEN_IFLD_SIGNED), 0, 4, 5, 32, total_length, buffer);
777 case FRV_OPERAND_S6 :
778 errmsg = insert_normal (cd, fields->f_s6, 0|(1<<CGEN_IFLD_SIGNED), 0, 5, 6, 32, total_length, buffer);
780 case FRV_OPERAND_S6_1 :
781 errmsg = insert_normal (cd, fields->f_s6_1, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 6, 32, total_length, buffer);
783 case FRV_OPERAND_SLO16 :
784 errmsg = insert_normal (cd, fields->f_s16, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, buffer);
786 case FRV_OPERAND_SPR :
789 FLD (f_spr_h) = ((unsigned int) (FLD (f_spr)) >> (6));
790 FLD (f_spr_l) = ((FLD (f_spr)) & (63));
792 errmsg = insert_normal (cd, fields->f_spr_h, 0, 0, 30, 6, 32, total_length, buffer);
795 errmsg = insert_normal (cd, fields->f_spr_l, 0, 0, 17, 6, 32, total_length, buffer);
800 case FRV_OPERAND_U12 :
803 FLD (f_u12_h) = ((int) (FLD (f_u12)) >> (6));
804 FLD (f_u12_l) = ((FLD (f_u12)) & (63));
806 errmsg = insert_normal (cd, fields->f_u12_h, 0|(1<<CGEN_IFLD_SIGNED), 0, 17, 6, 32, total_length, buffer);
809 errmsg = insert_normal (cd, fields->f_u12_l, 0, 0, 5, 6, 32, total_length, buffer);
814 case FRV_OPERAND_U16 :
815 errmsg = insert_normal (cd, fields->f_u16, 0, 0, 15, 16, 32, total_length, buffer);
817 case FRV_OPERAND_U6 :
818 errmsg = insert_normal (cd, fields->f_u6, 0, 0, 5, 6, 32, total_length, buffer);
820 case FRV_OPERAND_UHI16 :
821 errmsg = insert_normal (cd, fields->f_u16, 0, 0, 15, 16, 32, total_length, buffer);
823 case FRV_OPERAND_ULO16 :
824 errmsg = insert_normal (cd, fields->f_u16, 0, 0, 15, 16, 32, total_length, buffer);
828 /* xgettext:c-format */
829 fprintf (stderr, _("Unrecognized field %d while building insn.\n"),
837 int frv_cgen_extract_operand
838 PARAMS ((CGEN_CPU_DESC, int, CGEN_EXTRACT_INFO *, CGEN_INSN_INT,
839 CGEN_FIELDS *, bfd_vma));
841 /* Main entry point for operand extraction.
842 The result is <= 0 for error, >0 for success.
843 ??? Actual values aren't well defined right now.
845 This function is basically just a big switch statement. Earlier versions
846 used tables to look up the function to use, but
847 - if the table contains both assembler and disassembler functions then
848 the disassembler contains much of the assembler and vice-versa,
849 - there's a lot of inlining possibilities as things grow,
850 - using a switch statement avoids the function call overhead.
852 This function could be moved into `print_insn_normal', but keeping it
853 separate makes clear the interface between `print_insn_normal' and each of
857 frv_cgen_extract_operand (cd, opindex, ex_info, insn_value, fields, pc)
860 CGEN_EXTRACT_INFO *ex_info;
861 CGEN_INSN_INT insn_value;
862 CGEN_FIELDS * fields;
865 /* Assume success (for those operands that are nops). */
867 unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
872 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 1, 32, total_length, pc, & fields->f_A);
874 case FRV_OPERAND_ACC40SI :
875 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_ACC40Si);
877 case FRV_OPERAND_ACC40SK :
878 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_ACC40Sk);
880 case FRV_OPERAND_ACC40UI :
881 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_ACC40Ui);
883 case FRV_OPERAND_ACC40UK :
884 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_ACC40Uk);
886 case FRV_OPERAND_ACCGI :
887 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_ACCGi);
889 case FRV_OPERAND_ACCGK :
890 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_ACCGk);
892 case FRV_OPERAND_CCI :
893 length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 3, 32, total_length, pc, & fields->f_CCi);
895 case FRV_OPERAND_CPRDOUBLEK :
896 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_CPRk);
898 case FRV_OPERAND_CPRI :
899 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_CPRi);
901 case FRV_OPERAND_CPRJ :
902 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_CPRj);
904 case FRV_OPERAND_CPRK :
905 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_CPRk);
907 case FRV_OPERAND_CRI :
908 length = extract_normal (cd, ex_info, insn_value, 0, 0, 14, 3, 32, total_length, pc, & fields->f_CRi);
910 case FRV_OPERAND_CRJ :
911 length = extract_normal (cd, ex_info, insn_value, 0, 0, 2, 3, 32, total_length, pc, & fields->f_CRj);
913 case FRV_OPERAND_CRJ_FLOAT :
914 length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & fields->f_CRj_float);
916 case FRV_OPERAND_CRJ_INT :
919 length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & value);
920 value = ((value) + (4));
921 fields->f_CRj_int = value;
924 case FRV_OPERAND_CRK :
925 length = extract_normal (cd, ex_info, insn_value, 0, 0, 27, 3, 32, total_length, pc, & fields->f_CRk);
927 case FRV_OPERAND_FCCI_1 :
928 length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 2, 32, total_length, pc, & fields->f_FCCi_1);
930 case FRV_OPERAND_FCCI_2 :
931 length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & fields->f_FCCi_2);
933 case FRV_OPERAND_FCCI_3 :
934 length = extract_normal (cd, ex_info, insn_value, 0, 0, 1, 2, 32, total_length, pc, & fields->f_FCCi_3);
936 case FRV_OPERAND_FCCK :
937 length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & fields->f_FCCk);
939 case FRV_OPERAND_FRDOUBLEI :
940 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_FRi);
942 case FRV_OPERAND_FRDOUBLEJ :
943 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_FRj);
945 case FRV_OPERAND_FRDOUBLEK :
946 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk);
948 case FRV_OPERAND_FRI :
949 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_FRi);
951 case FRV_OPERAND_FRINTI :
952 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_FRi);
954 case FRV_OPERAND_FRINTIEVEN :
955 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_FRi);
957 case FRV_OPERAND_FRINTJ :
958 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_FRj);
960 case FRV_OPERAND_FRINTJEVEN :
961 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_FRj);
963 case FRV_OPERAND_FRINTK :
964 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk);
966 case FRV_OPERAND_FRINTKEVEN :
967 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk);
969 case FRV_OPERAND_FRJ :
970 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_FRj);
972 case FRV_OPERAND_FRK :
973 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk);
975 case FRV_OPERAND_FRKHI :
976 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk);
978 case FRV_OPERAND_FRKLO :
979 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk);
981 case FRV_OPERAND_GRDOUBLEK :
982 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_GRk);
984 case FRV_OPERAND_GRI :
985 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_GRi);
987 case FRV_OPERAND_GRJ :
988 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_GRj);
990 case FRV_OPERAND_GRK :
991 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_GRk);
993 case FRV_OPERAND_GRKHI :
994 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_GRk);
996 case FRV_OPERAND_GRKLO :
997 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_GRk);
999 case FRV_OPERAND_ICCI_1 :
1000 length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 2, 32, total_length, pc, & fields->f_ICCi_1);
1002 case FRV_OPERAND_ICCI_2 :
1003 length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & fields->f_ICCi_2);
1005 case FRV_OPERAND_ICCI_3 :
1006 length = extract_normal (cd, ex_info, insn_value, 0, 0, 1, 2, 32, total_length, pc, & fields->f_ICCi_3);
1008 case FRV_OPERAND_LI :
1009 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_LI);
1011 case FRV_OPERAND_AE :
1012 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_ae);
1014 case FRV_OPERAND_CCOND :
1015 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 1, 32, total_length, pc, & fields->f_ccond);
1017 case FRV_OPERAND_COND :
1018 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 1, 32, total_length, pc, & fields->f_cond);
1020 case FRV_OPERAND_D12 :
1021 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 12, 32, total_length, pc, & fields->f_d12);
1023 case FRV_OPERAND_DEBUG :
1024 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_debug);
1026 case FRV_OPERAND_EIR :
1027 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_eir);
1029 case FRV_OPERAND_HINT :
1030 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 2, 32, total_length, pc, & fields->f_hint);
1032 case FRV_OPERAND_HINT_NOT_TAKEN :
1033 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 2, 32, total_length, pc, & fields->f_hint);
1035 case FRV_OPERAND_HINT_TAKEN :
1036 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 2, 32, total_length, pc, & fields->f_hint);
1038 case FRV_OPERAND_LABEL16 :
1041 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);
1042 value = ((((value) << (2))) + (pc));
1043 fields->f_label16 = value;
1046 case FRV_OPERAND_LABEL24 :
1048 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 30, 6, 32, total_length, pc, & fields->f_labelH6);
1049 if (length <= 0) break;
1050 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 18, 32, total_length, pc, & fields->f_labelL18);
1051 if (length <= 0) break;
1053 FLD (f_label24) = ((((((((FLD (f_labelH6)) << (18))) | (FLD (f_labelL18)))) << (2))) + (pc));
1057 case FRV_OPERAND_LOCK :
1058 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_lock);
1060 case FRV_OPERAND_PACK :
1061 length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 1, 32, total_length, pc, & fields->f_pack);
1063 case FRV_OPERAND_S10 :
1064 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 9, 10, 32, total_length, pc, & fields->f_s10);
1066 case FRV_OPERAND_S12 :
1067 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 12, 32, total_length, pc, & fields->f_d12);
1069 case FRV_OPERAND_S16 :
1070 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, pc, & fields->f_s16);
1072 case FRV_OPERAND_S5 :
1073 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 4, 5, 32, total_length, pc, & fields->f_s5);
1075 case FRV_OPERAND_S6 :
1076 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 5, 6, 32, total_length, pc, & fields->f_s6);
1078 case FRV_OPERAND_S6_1 :
1079 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 6, 32, total_length, pc, & fields->f_s6_1);
1081 case FRV_OPERAND_SLO16 :
1082 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, pc, & fields->f_s16);
1084 case FRV_OPERAND_SPR :
1086 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_spr_h);
1087 if (length <= 0) break;
1088 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_spr_l);
1089 if (length <= 0) break;
1091 FLD (f_spr) = ((((FLD (f_spr_h)) << (6))) | (FLD (f_spr_l)));
1095 case FRV_OPERAND_U12 :
1097 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 17, 6, 32, total_length, pc, & fields->f_u12_h);
1098 if (length <= 0) break;
1099 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_u12_l);
1100 if (length <= 0) break;
1102 FLD (f_u12) = ((((FLD (f_u12_h)) << (6))) | (FLD (f_u12_l)));
1106 case FRV_OPERAND_U16 :
1107 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_u16);
1109 case FRV_OPERAND_U6 :
1110 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_u6);
1112 case FRV_OPERAND_UHI16 :
1113 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_u16);
1115 case FRV_OPERAND_ULO16 :
1116 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_u16);
1120 /* xgettext:c-format */
1121 fprintf (stderr, _("Unrecognized field %d while decoding insn.\n"),
1129 cgen_insert_fn * const frv_cgen_insert_handlers[] =
1134 cgen_extract_fn * const frv_cgen_extract_handlers[] =
1136 extract_insn_normal,
1139 int frv_cgen_get_int_operand
1140 PARAMS ((CGEN_CPU_DESC, int, const CGEN_FIELDS *));
1141 bfd_vma frv_cgen_get_vma_operand
1142 PARAMS ((CGEN_CPU_DESC, int, const CGEN_FIELDS *));
1144 /* Getting values from cgen_fields is handled by a collection of functions.
1145 They are distinguished by the type of the VALUE argument they return.
1146 TODO: floating point, inlining support, remove cases where result type
1150 frv_cgen_get_int_operand (cd, opindex, fields)
1151 CGEN_CPU_DESC cd ATTRIBUTE_UNUSED;
1153 const CGEN_FIELDS * fields;
1159 case FRV_OPERAND_A :
1160 value = fields->f_A;
1162 case FRV_OPERAND_ACC40SI :
1163 value = fields->f_ACC40Si;
1165 case FRV_OPERAND_ACC40SK :
1166 value = fields->f_ACC40Sk;
1168 case FRV_OPERAND_ACC40UI :
1169 value = fields->f_ACC40Ui;
1171 case FRV_OPERAND_ACC40UK :
1172 value = fields->f_ACC40Uk;
1174 case FRV_OPERAND_ACCGI :
1175 value = fields->f_ACCGi;
1177 case FRV_OPERAND_ACCGK :
1178 value = fields->f_ACCGk;
1180 case FRV_OPERAND_CCI :
1181 value = fields->f_CCi;
1183 case FRV_OPERAND_CPRDOUBLEK :
1184 value = fields->f_CPRk;
1186 case FRV_OPERAND_CPRI :
1187 value = fields->f_CPRi;
1189 case FRV_OPERAND_CPRJ :
1190 value = fields->f_CPRj;
1192 case FRV_OPERAND_CPRK :
1193 value = fields->f_CPRk;
1195 case FRV_OPERAND_CRI :
1196 value = fields->f_CRi;
1198 case FRV_OPERAND_CRJ :
1199 value = fields->f_CRj;
1201 case FRV_OPERAND_CRJ_FLOAT :
1202 value = fields->f_CRj_float;
1204 case FRV_OPERAND_CRJ_INT :
1205 value = fields->f_CRj_int;
1207 case FRV_OPERAND_CRK :
1208 value = fields->f_CRk;
1210 case FRV_OPERAND_FCCI_1 :
1211 value = fields->f_FCCi_1;
1213 case FRV_OPERAND_FCCI_2 :
1214 value = fields->f_FCCi_2;
1216 case FRV_OPERAND_FCCI_3 :
1217 value = fields->f_FCCi_3;
1219 case FRV_OPERAND_FCCK :
1220 value = fields->f_FCCk;
1222 case FRV_OPERAND_FRDOUBLEI :
1223 value = fields->f_FRi;
1225 case FRV_OPERAND_FRDOUBLEJ :
1226 value = fields->f_FRj;
1228 case FRV_OPERAND_FRDOUBLEK :
1229 value = fields->f_FRk;
1231 case FRV_OPERAND_FRI :
1232 value = fields->f_FRi;
1234 case FRV_OPERAND_FRINTI :
1235 value = fields->f_FRi;
1237 case FRV_OPERAND_FRINTIEVEN :
1238 value = fields->f_FRi;
1240 case FRV_OPERAND_FRINTJ :
1241 value = fields->f_FRj;
1243 case FRV_OPERAND_FRINTJEVEN :
1244 value = fields->f_FRj;
1246 case FRV_OPERAND_FRINTK :
1247 value = fields->f_FRk;
1249 case FRV_OPERAND_FRINTKEVEN :
1250 value = fields->f_FRk;
1252 case FRV_OPERAND_FRJ :
1253 value = fields->f_FRj;
1255 case FRV_OPERAND_FRK :
1256 value = fields->f_FRk;
1258 case FRV_OPERAND_FRKHI :
1259 value = fields->f_FRk;
1261 case FRV_OPERAND_FRKLO :
1262 value = fields->f_FRk;
1264 case FRV_OPERAND_GRDOUBLEK :
1265 value = fields->f_GRk;
1267 case FRV_OPERAND_GRI :
1268 value = fields->f_GRi;
1270 case FRV_OPERAND_GRJ :
1271 value = fields->f_GRj;
1273 case FRV_OPERAND_GRK :
1274 value = fields->f_GRk;
1276 case FRV_OPERAND_GRKHI :
1277 value = fields->f_GRk;
1279 case FRV_OPERAND_GRKLO :
1280 value = fields->f_GRk;
1282 case FRV_OPERAND_ICCI_1 :
1283 value = fields->f_ICCi_1;
1285 case FRV_OPERAND_ICCI_2 :
1286 value = fields->f_ICCi_2;
1288 case FRV_OPERAND_ICCI_3 :
1289 value = fields->f_ICCi_3;
1291 case FRV_OPERAND_LI :
1292 value = fields->f_LI;
1294 case FRV_OPERAND_AE :
1295 value = fields->f_ae;
1297 case FRV_OPERAND_CCOND :
1298 value = fields->f_ccond;
1300 case FRV_OPERAND_COND :
1301 value = fields->f_cond;
1303 case FRV_OPERAND_D12 :
1304 value = fields->f_d12;
1306 case FRV_OPERAND_DEBUG :
1307 value = fields->f_debug;
1309 case FRV_OPERAND_EIR :
1310 value = fields->f_eir;
1312 case FRV_OPERAND_HINT :
1313 value = fields->f_hint;
1315 case FRV_OPERAND_HINT_NOT_TAKEN :
1316 value = fields->f_hint;
1318 case FRV_OPERAND_HINT_TAKEN :
1319 value = fields->f_hint;
1321 case FRV_OPERAND_LABEL16 :
1322 value = fields->f_label16;
1324 case FRV_OPERAND_LABEL24 :
1325 value = fields->f_label24;
1327 case FRV_OPERAND_LOCK :
1328 value = fields->f_lock;
1330 case FRV_OPERAND_PACK :
1331 value = fields->f_pack;
1333 case FRV_OPERAND_S10 :
1334 value = fields->f_s10;
1336 case FRV_OPERAND_S12 :
1337 value = fields->f_d12;
1339 case FRV_OPERAND_S16 :
1340 value = fields->f_s16;
1342 case FRV_OPERAND_S5 :
1343 value = fields->f_s5;
1345 case FRV_OPERAND_S6 :
1346 value = fields->f_s6;
1348 case FRV_OPERAND_S6_1 :
1349 value = fields->f_s6_1;
1351 case FRV_OPERAND_SLO16 :
1352 value = fields->f_s16;
1354 case FRV_OPERAND_SPR :
1355 value = fields->f_spr;
1357 case FRV_OPERAND_U12 :
1358 value = fields->f_u12;
1360 case FRV_OPERAND_U16 :
1361 value = fields->f_u16;
1363 case FRV_OPERAND_U6 :
1364 value = fields->f_u6;
1366 case FRV_OPERAND_UHI16 :
1367 value = fields->f_u16;
1369 case FRV_OPERAND_ULO16 :
1370 value = fields->f_u16;
1374 /* xgettext:c-format */
1375 fprintf (stderr, _("Unrecognized field %d while getting int operand.\n"),
1384 frv_cgen_get_vma_operand (cd, opindex, fields)
1385 CGEN_CPU_DESC cd ATTRIBUTE_UNUSED;
1387 const CGEN_FIELDS * fields;
1393 case FRV_OPERAND_A :
1394 value = fields->f_A;
1396 case FRV_OPERAND_ACC40SI :
1397 value = fields->f_ACC40Si;
1399 case FRV_OPERAND_ACC40SK :
1400 value = fields->f_ACC40Sk;
1402 case FRV_OPERAND_ACC40UI :
1403 value = fields->f_ACC40Ui;
1405 case FRV_OPERAND_ACC40UK :
1406 value = fields->f_ACC40Uk;
1408 case FRV_OPERAND_ACCGI :
1409 value = fields->f_ACCGi;
1411 case FRV_OPERAND_ACCGK :
1412 value = fields->f_ACCGk;
1414 case FRV_OPERAND_CCI :
1415 value = fields->f_CCi;
1417 case FRV_OPERAND_CPRDOUBLEK :
1418 value = fields->f_CPRk;
1420 case FRV_OPERAND_CPRI :
1421 value = fields->f_CPRi;
1423 case FRV_OPERAND_CPRJ :
1424 value = fields->f_CPRj;
1426 case FRV_OPERAND_CPRK :
1427 value = fields->f_CPRk;
1429 case FRV_OPERAND_CRI :
1430 value = fields->f_CRi;
1432 case FRV_OPERAND_CRJ :
1433 value = fields->f_CRj;
1435 case FRV_OPERAND_CRJ_FLOAT :
1436 value = fields->f_CRj_float;
1438 case FRV_OPERAND_CRJ_INT :
1439 value = fields->f_CRj_int;
1441 case FRV_OPERAND_CRK :
1442 value = fields->f_CRk;
1444 case FRV_OPERAND_FCCI_1 :
1445 value = fields->f_FCCi_1;
1447 case FRV_OPERAND_FCCI_2 :
1448 value = fields->f_FCCi_2;
1450 case FRV_OPERAND_FCCI_3 :
1451 value = fields->f_FCCi_3;
1453 case FRV_OPERAND_FCCK :
1454 value = fields->f_FCCk;
1456 case FRV_OPERAND_FRDOUBLEI :
1457 value = fields->f_FRi;
1459 case FRV_OPERAND_FRDOUBLEJ :
1460 value = fields->f_FRj;
1462 case FRV_OPERAND_FRDOUBLEK :
1463 value = fields->f_FRk;
1465 case FRV_OPERAND_FRI :
1466 value = fields->f_FRi;
1468 case FRV_OPERAND_FRINTI :
1469 value = fields->f_FRi;
1471 case FRV_OPERAND_FRINTIEVEN :
1472 value = fields->f_FRi;
1474 case FRV_OPERAND_FRINTJ :
1475 value = fields->f_FRj;
1477 case FRV_OPERAND_FRINTJEVEN :
1478 value = fields->f_FRj;
1480 case FRV_OPERAND_FRINTK :
1481 value = fields->f_FRk;
1483 case FRV_OPERAND_FRINTKEVEN :
1484 value = fields->f_FRk;
1486 case FRV_OPERAND_FRJ :
1487 value = fields->f_FRj;
1489 case FRV_OPERAND_FRK :
1490 value = fields->f_FRk;
1492 case FRV_OPERAND_FRKHI :
1493 value = fields->f_FRk;
1495 case FRV_OPERAND_FRKLO :
1496 value = fields->f_FRk;
1498 case FRV_OPERAND_GRDOUBLEK :
1499 value = fields->f_GRk;
1501 case FRV_OPERAND_GRI :
1502 value = fields->f_GRi;
1504 case FRV_OPERAND_GRJ :
1505 value = fields->f_GRj;
1507 case FRV_OPERAND_GRK :
1508 value = fields->f_GRk;
1510 case FRV_OPERAND_GRKHI :
1511 value = fields->f_GRk;
1513 case FRV_OPERAND_GRKLO :
1514 value = fields->f_GRk;
1516 case FRV_OPERAND_ICCI_1 :
1517 value = fields->f_ICCi_1;
1519 case FRV_OPERAND_ICCI_2 :
1520 value = fields->f_ICCi_2;
1522 case FRV_OPERAND_ICCI_3 :
1523 value = fields->f_ICCi_3;
1525 case FRV_OPERAND_LI :
1526 value = fields->f_LI;
1528 case FRV_OPERAND_AE :
1529 value = fields->f_ae;
1531 case FRV_OPERAND_CCOND :
1532 value = fields->f_ccond;
1534 case FRV_OPERAND_COND :
1535 value = fields->f_cond;
1537 case FRV_OPERAND_D12 :
1538 value = fields->f_d12;
1540 case FRV_OPERAND_DEBUG :
1541 value = fields->f_debug;
1543 case FRV_OPERAND_EIR :
1544 value = fields->f_eir;
1546 case FRV_OPERAND_HINT :
1547 value = fields->f_hint;
1549 case FRV_OPERAND_HINT_NOT_TAKEN :
1550 value = fields->f_hint;
1552 case FRV_OPERAND_HINT_TAKEN :
1553 value = fields->f_hint;
1555 case FRV_OPERAND_LABEL16 :
1556 value = fields->f_label16;
1558 case FRV_OPERAND_LABEL24 :
1559 value = fields->f_label24;
1561 case FRV_OPERAND_LOCK :
1562 value = fields->f_lock;
1564 case FRV_OPERAND_PACK :
1565 value = fields->f_pack;
1567 case FRV_OPERAND_S10 :
1568 value = fields->f_s10;
1570 case FRV_OPERAND_S12 :
1571 value = fields->f_d12;
1573 case FRV_OPERAND_S16 :
1574 value = fields->f_s16;
1576 case FRV_OPERAND_S5 :
1577 value = fields->f_s5;
1579 case FRV_OPERAND_S6 :
1580 value = fields->f_s6;
1582 case FRV_OPERAND_S6_1 :
1583 value = fields->f_s6_1;
1585 case FRV_OPERAND_SLO16 :
1586 value = fields->f_s16;
1588 case FRV_OPERAND_SPR :
1589 value = fields->f_spr;
1591 case FRV_OPERAND_U12 :
1592 value = fields->f_u12;
1594 case FRV_OPERAND_U16 :
1595 value = fields->f_u16;
1597 case FRV_OPERAND_U6 :
1598 value = fields->f_u6;
1600 case FRV_OPERAND_UHI16 :
1601 value = fields->f_u16;
1603 case FRV_OPERAND_ULO16 :
1604 value = fields->f_u16;
1608 /* xgettext:c-format */
1609 fprintf (stderr, _("Unrecognized field %d while getting vma operand.\n"),
1617 void frv_cgen_set_int_operand
1618 PARAMS ((CGEN_CPU_DESC, int, CGEN_FIELDS *, int));
1619 void frv_cgen_set_vma_operand
1620 PARAMS ((CGEN_CPU_DESC, int, CGEN_FIELDS *, bfd_vma));
1622 /* Stuffing values in cgen_fields is handled by a collection of functions.
1623 They are distinguished by the type of the VALUE argument they accept.
1624 TODO: floating point, inlining support, remove cases where argument type
1628 frv_cgen_set_int_operand (cd, opindex, fields, value)
1629 CGEN_CPU_DESC cd ATTRIBUTE_UNUSED;
1631 CGEN_FIELDS * fields;
1636 case FRV_OPERAND_A :
1637 fields->f_A = value;
1639 case FRV_OPERAND_ACC40SI :
1640 fields->f_ACC40Si = value;
1642 case FRV_OPERAND_ACC40SK :
1643 fields->f_ACC40Sk = value;
1645 case FRV_OPERAND_ACC40UI :
1646 fields->f_ACC40Ui = value;
1648 case FRV_OPERAND_ACC40UK :
1649 fields->f_ACC40Uk = value;
1651 case FRV_OPERAND_ACCGI :
1652 fields->f_ACCGi = value;
1654 case FRV_OPERAND_ACCGK :
1655 fields->f_ACCGk = value;
1657 case FRV_OPERAND_CCI :
1658 fields->f_CCi = value;
1660 case FRV_OPERAND_CPRDOUBLEK :
1661 fields->f_CPRk = value;
1663 case FRV_OPERAND_CPRI :
1664 fields->f_CPRi = value;
1666 case FRV_OPERAND_CPRJ :
1667 fields->f_CPRj = value;
1669 case FRV_OPERAND_CPRK :
1670 fields->f_CPRk = value;
1672 case FRV_OPERAND_CRI :
1673 fields->f_CRi = value;
1675 case FRV_OPERAND_CRJ :
1676 fields->f_CRj = value;
1678 case FRV_OPERAND_CRJ_FLOAT :
1679 fields->f_CRj_float = value;
1681 case FRV_OPERAND_CRJ_INT :
1682 fields->f_CRj_int = value;
1684 case FRV_OPERAND_CRK :
1685 fields->f_CRk = value;
1687 case FRV_OPERAND_FCCI_1 :
1688 fields->f_FCCi_1 = value;
1690 case FRV_OPERAND_FCCI_2 :
1691 fields->f_FCCi_2 = value;
1693 case FRV_OPERAND_FCCI_3 :
1694 fields->f_FCCi_3 = value;
1696 case FRV_OPERAND_FCCK :
1697 fields->f_FCCk = value;
1699 case FRV_OPERAND_FRDOUBLEI :
1700 fields->f_FRi = value;
1702 case FRV_OPERAND_FRDOUBLEJ :
1703 fields->f_FRj = value;
1705 case FRV_OPERAND_FRDOUBLEK :
1706 fields->f_FRk = value;
1708 case FRV_OPERAND_FRI :
1709 fields->f_FRi = value;
1711 case FRV_OPERAND_FRINTI :
1712 fields->f_FRi = value;
1714 case FRV_OPERAND_FRINTIEVEN :
1715 fields->f_FRi = value;
1717 case FRV_OPERAND_FRINTJ :
1718 fields->f_FRj = value;
1720 case FRV_OPERAND_FRINTJEVEN :
1721 fields->f_FRj = value;
1723 case FRV_OPERAND_FRINTK :
1724 fields->f_FRk = value;
1726 case FRV_OPERAND_FRINTKEVEN :
1727 fields->f_FRk = value;
1729 case FRV_OPERAND_FRJ :
1730 fields->f_FRj = value;
1732 case FRV_OPERAND_FRK :
1733 fields->f_FRk = value;
1735 case FRV_OPERAND_FRKHI :
1736 fields->f_FRk = value;
1738 case FRV_OPERAND_FRKLO :
1739 fields->f_FRk = value;
1741 case FRV_OPERAND_GRDOUBLEK :
1742 fields->f_GRk = value;
1744 case FRV_OPERAND_GRI :
1745 fields->f_GRi = value;
1747 case FRV_OPERAND_GRJ :
1748 fields->f_GRj = value;
1750 case FRV_OPERAND_GRK :
1751 fields->f_GRk = value;
1753 case FRV_OPERAND_GRKHI :
1754 fields->f_GRk = value;
1756 case FRV_OPERAND_GRKLO :
1757 fields->f_GRk = value;
1759 case FRV_OPERAND_ICCI_1 :
1760 fields->f_ICCi_1 = value;
1762 case FRV_OPERAND_ICCI_2 :
1763 fields->f_ICCi_2 = value;
1765 case FRV_OPERAND_ICCI_3 :
1766 fields->f_ICCi_3 = value;
1768 case FRV_OPERAND_LI :
1769 fields->f_LI = value;
1771 case FRV_OPERAND_AE :
1772 fields->f_ae = value;
1774 case FRV_OPERAND_CCOND :
1775 fields->f_ccond = value;
1777 case FRV_OPERAND_COND :
1778 fields->f_cond = value;
1780 case FRV_OPERAND_D12 :
1781 fields->f_d12 = value;
1783 case FRV_OPERAND_DEBUG :
1784 fields->f_debug = value;
1786 case FRV_OPERAND_EIR :
1787 fields->f_eir = value;
1789 case FRV_OPERAND_HINT :
1790 fields->f_hint = value;
1792 case FRV_OPERAND_HINT_NOT_TAKEN :
1793 fields->f_hint = value;
1795 case FRV_OPERAND_HINT_TAKEN :
1796 fields->f_hint = value;
1798 case FRV_OPERAND_LABEL16 :
1799 fields->f_label16 = value;
1801 case FRV_OPERAND_LABEL24 :
1802 fields->f_label24 = value;
1804 case FRV_OPERAND_LOCK :
1805 fields->f_lock = value;
1807 case FRV_OPERAND_PACK :
1808 fields->f_pack = value;
1810 case FRV_OPERAND_S10 :
1811 fields->f_s10 = value;
1813 case FRV_OPERAND_S12 :
1814 fields->f_d12 = value;
1816 case FRV_OPERAND_S16 :
1817 fields->f_s16 = value;
1819 case FRV_OPERAND_S5 :
1820 fields->f_s5 = value;
1822 case FRV_OPERAND_S6 :
1823 fields->f_s6 = value;
1825 case FRV_OPERAND_S6_1 :
1826 fields->f_s6_1 = value;
1828 case FRV_OPERAND_SLO16 :
1829 fields->f_s16 = value;
1831 case FRV_OPERAND_SPR :
1832 fields->f_spr = value;
1834 case FRV_OPERAND_U12 :
1835 fields->f_u12 = value;
1837 case FRV_OPERAND_U16 :
1838 fields->f_u16 = value;
1840 case FRV_OPERAND_U6 :
1841 fields->f_u6 = value;
1843 case FRV_OPERAND_UHI16 :
1844 fields->f_u16 = value;
1846 case FRV_OPERAND_ULO16 :
1847 fields->f_u16 = value;
1851 /* xgettext:c-format */
1852 fprintf (stderr, _("Unrecognized field %d while setting int operand.\n"),
1859 frv_cgen_set_vma_operand (cd, opindex, fields, value)
1860 CGEN_CPU_DESC cd ATTRIBUTE_UNUSED;
1862 CGEN_FIELDS * fields;
1867 case FRV_OPERAND_A :
1868 fields->f_A = value;
1870 case FRV_OPERAND_ACC40SI :
1871 fields->f_ACC40Si = value;
1873 case FRV_OPERAND_ACC40SK :
1874 fields->f_ACC40Sk = value;
1876 case FRV_OPERAND_ACC40UI :
1877 fields->f_ACC40Ui = value;
1879 case FRV_OPERAND_ACC40UK :
1880 fields->f_ACC40Uk = value;
1882 case FRV_OPERAND_ACCGI :
1883 fields->f_ACCGi = value;
1885 case FRV_OPERAND_ACCGK :
1886 fields->f_ACCGk = value;
1888 case FRV_OPERAND_CCI :
1889 fields->f_CCi = value;
1891 case FRV_OPERAND_CPRDOUBLEK :
1892 fields->f_CPRk = value;
1894 case FRV_OPERAND_CPRI :
1895 fields->f_CPRi = value;
1897 case FRV_OPERAND_CPRJ :
1898 fields->f_CPRj = value;
1900 case FRV_OPERAND_CPRK :
1901 fields->f_CPRk = value;
1903 case FRV_OPERAND_CRI :
1904 fields->f_CRi = value;
1906 case FRV_OPERAND_CRJ :
1907 fields->f_CRj = value;
1909 case FRV_OPERAND_CRJ_FLOAT :
1910 fields->f_CRj_float = value;
1912 case FRV_OPERAND_CRJ_INT :
1913 fields->f_CRj_int = value;
1915 case FRV_OPERAND_CRK :
1916 fields->f_CRk = value;
1918 case FRV_OPERAND_FCCI_1 :
1919 fields->f_FCCi_1 = value;
1921 case FRV_OPERAND_FCCI_2 :
1922 fields->f_FCCi_2 = value;
1924 case FRV_OPERAND_FCCI_3 :
1925 fields->f_FCCi_3 = value;
1927 case FRV_OPERAND_FCCK :
1928 fields->f_FCCk = value;
1930 case FRV_OPERAND_FRDOUBLEI :
1931 fields->f_FRi = value;
1933 case FRV_OPERAND_FRDOUBLEJ :
1934 fields->f_FRj = value;
1936 case FRV_OPERAND_FRDOUBLEK :
1937 fields->f_FRk = value;
1939 case FRV_OPERAND_FRI :
1940 fields->f_FRi = value;
1942 case FRV_OPERAND_FRINTI :
1943 fields->f_FRi = value;
1945 case FRV_OPERAND_FRINTIEVEN :
1946 fields->f_FRi = value;
1948 case FRV_OPERAND_FRINTJ :
1949 fields->f_FRj = value;
1951 case FRV_OPERAND_FRINTJEVEN :
1952 fields->f_FRj = value;
1954 case FRV_OPERAND_FRINTK :
1955 fields->f_FRk = value;
1957 case FRV_OPERAND_FRINTKEVEN :
1958 fields->f_FRk = value;
1960 case FRV_OPERAND_FRJ :
1961 fields->f_FRj = value;
1963 case FRV_OPERAND_FRK :
1964 fields->f_FRk = value;
1966 case FRV_OPERAND_FRKHI :
1967 fields->f_FRk = value;
1969 case FRV_OPERAND_FRKLO :
1970 fields->f_FRk = value;
1972 case FRV_OPERAND_GRDOUBLEK :
1973 fields->f_GRk = value;
1975 case FRV_OPERAND_GRI :
1976 fields->f_GRi = value;
1978 case FRV_OPERAND_GRJ :
1979 fields->f_GRj = value;
1981 case FRV_OPERAND_GRK :
1982 fields->f_GRk = value;
1984 case FRV_OPERAND_GRKHI :
1985 fields->f_GRk = value;
1987 case FRV_OPERAND_GRKLO :
1988 fields->f_GRk = value;
1990 case FRV_OPERAND_ICCI_1 :
1991 fields->f_ICCi_1 = value;
1993 case FRV_OPERAND_ICCI_2 :
1994 fields->f_ICCi_2 = value;
1996 case FRV_OPERAND_ICCI_3 :
1997 fields->f_ICCi_3 = value;
1999 case FRV_OPERAND_LI :
2000 fields->f_LI = value;
2002 case FRV_OPERAND_AE :
2003 fields->f_ae = value;
2005 case FRV_OPERAND_CCOND :
2006 fields->f_ccond = value;
2008 case FRV_OPERAND_COND :
2009 fields->f_cond = value;
2011 case FRV_OPERAND_D12 :
2012 fields->f_d12 = value;
2014 case FRV_OPERAND_DEBUG :
2015 fields->f_debug = value;
2017 case FRV_OPERAND_EIR :
2018 fields->f_eir = value;
2020 case FRV_OPERAND_HINT :
2021 fields->f_hint = value;
2023 case FRV_OPERAND_HINT_NOT_TAKEN :
2024 fields->f_hint = value;
2026 case FRV_OPERAND_HINT_TAKEN :
2027 fields->f_hint = value;
2029 case FRV_OPERAND_LABEL16 :
2030 fields->f_label16 = value;
2032 case FRV_OPERAND_LABEL24 :
2033 fields->f_label24 = value;
2035 case FRV_OPERAND_LOCK :
2036 fields->f_lock = value;
2038 case FRV_OPERAND_PACK :
2039 fields->f_pack = value;
2041 case FRV_OPERAND_S10 :
2042 fields->f_s10 = value;
2044 case FRV_OPERAND_S12 :
2045 fields->f_d12 = value;
2047 case FRV_OPERAND_S16 :
2048 fields->f_s16 = value;
2050 case FRV_OPERAND_S5 :
2051 fields->f_s5 = value;
2053 case FRV_OPERAND_S6 :
2054 fields->f_s6 = value;
2056 case FRV_OPERAND_S6_1 :
2057 fields->f_s6_1 = value;
2059 case FRV_OPERAND_SLO16 :
2060 fields->f_s16 = value;
2062 case FRV_OPERAND_SPR :
2063 fields->f_spr = value;
2065 case FRV_OPERAND_U12 :
2066 fields->f_u12 = value;
2068 case FRV_OPERAND_U16 :
2069 fields->f_u16 = value;
2071 case FRV_OPERAND_U6 :
2072 fields->f_u6 = value;
2074 case FRV_OPERAND_UHI16 :
2075 fields->f_u16 = value;
2077 case FRV_OPERAND_ULO16 :
2078 fields->f_u16 = value;
2082 /* xgettext:c-format */
2083 fprintf (stderr, _("Unrecognized field %d while setting vma operand.\n"),
2089 /* Function to call before using the instruction builder tables. */
2092 frv_cgen_init_ibld_table (cd)
2095 cd->insert_handlers = & frv_cgen_insert_handlers[0];
2096 cd->extract_handlers = & frv_cgen_extract_handlers[0];
2098 cd->insert_operand = frv_cgen_insert_operand;
2099 cd->extract_operand = frv_cgen_extract_operand;
2101 cd->get_int_operand = frv_cgen_get_int_operand;
2102 cd->set_int_operand = frv_cgen_set_int_operand;
2103 cd->get_vma_operand = frv_cgen_get_vma_operand;
2104 cd->set_vma_operand = frv_cgen_set_vma_operand;