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