Add code to handle even-numbered only register operands
[binutils.git] / opcodes / frv-ibld.c
blobbac1837e1be951f57239c85328f58c564ea5f3da
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 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 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));
59 #if CGEN_INT_INSN_P
60 static void put_insn_int_value
61 PARAMS ((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 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));
71 #endif
73 /* Operand insertion. */
75 #if ! CGEN_INT_INSN_P
77 /* Subroutine of insert_normal. */
79 static CGEN_INLINE void
80 insert_1 (cd, value, start, length, word_length, bufp)
81 CGEN_CPU_DESC cd;
82 unsigned long value;
83 int start,length,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 (cd, value, attrs, word_offset, start, length, word_length,
122 total_length, buffer)
123 CGEN_CPU_DESC cd;
124 long value;
125 unsigned int attrs;
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. */
134 if (length == 0)
135 return NULL;
137 #if 0
138 if (CGEN_INT_INSN_P
139 && word_offset != 0)
140 abort ();
141 #endif
143 if (word_length > 32)
144 abort ();
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)
150 if (word_offset == 0
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)
162 || value < minval)
164 /* xgettext:c-format */
165 sprintf (errbuf,
166 _("operand out of range (%ld not between %ld and %lu)"),
167 value, minval, maxval);
168 return errbuf;
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 */
178 sprintf (errbuf,
179 _("operand out of range (%lu not between 0 and %lu)"),
180 value, maxval);
181 return errbuf;
184 else
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)
193 sprintf
194 /* xgettext:c-format */
195 (errbuf, _("operand out of range (%ld not between %ld and %ld)"),
196 value, minval, maxval);
197 return errbuf;
202 #if CGEN_INT_INSN_P
205 int shift;
207 if (CGEN_INSN_LSB0_P)
208 shift = (word_offset + start + 1) - length;
209 else
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 */
224 return NULL;
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. */
234 static const char *
235 insert_insn_normal (cd, insn, fields, buffer, pc)
236 CGEN_CPU_DESC cd;
237 const CGEN_INSN * insn;
238 CGEN_FIELDS * fields;
239 CGEN_INSN_BYTES_PTR buffer;
240 bfd_vma pc;
242 const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
243 unsigned long value;
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. */
252 #if CGEN_INT_INSN_P
254 put_insn_int_value (cd, buffer, cd->base_insn_bitsize,
255 CGEN_FIELDS_BITSIZE (fields), value);
257 #else
259 cgen_put_insn_value (cd, buffer, min ((unsigned) cd->base_insn_bitsize,
260 (unsigned) CGEN_FIELDS_BITSIZE (fields)),
261 value);
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)
272 const char *errmsg;
274 if (CGEN_SYNTAX_CHAR_P (* syn))
275 continue;
277 errmsg = (* cd->insert_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
278 fields, buffer, pc);
279 if (errmsg)
280 return errmsg;
283 return NULL;
286 #if CGEN_INT_INSN_P
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. */
290 static void
291 put_insn_int_value (cd, buf, length, insn_length, value)
292 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 (cd, ex_info, offset, bytes, pc)
324 CGEN_CPU_DESC cd ATTRIBUTE_UNUSED;
325 CGEN_EXTRACT_INFO *ex_info;
326 int offset, 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 (cd, ex_info, start, length, word_length, bufp, pc)
368 CGEN_CPU_DESC cd;
369 CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED;
370 int start,length,word_length;
371 unsigned char *bufp;
372 bfd_vma pc ATTRIBUTE_UNUSED;
374 unsigned long x;
375 int shift;
376 #if 0
377 int big_p = CGEN_CPU_INSN_ENDIAN (cd) == CGEN_ENDIAN_BIG;
378 #endif
379 x = cgen_get_insn_value (cd, bufp, word_length);
381 if (CGEN_INSN_LSB0_P)
382 shift = (start + 1) - length;
383 else
384 shift = (word_length - (start + length));
385 return x >> shift;
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
408 necessary. */
410 static int
411 extract_normal (cd, ex_info, insn_value, attrs, word_offset, start, length,
412 word_length, total_length, pc, valuep)
413 CGEN_CPU_DESC cd;
414 #if ! CGEN_INT_INSN_P
415 CGEN_EXTRACT_INFO *ex_info;
416 #else
417 CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED;
418 #endif
419 CGEN_INSN_INT insn_value;
420 unsigned int attrs;
421 unsigned int word_offset, start, length, word_length, total_length;
422 #if ! CGEN_INT_INSN_P
423 bfd_vma pc;
424 #else
425 bfd_vma pc ATTRIBUTE_UNUSED;
426 #endif
427 long *valuep;
429 long value, mask;
431 /* If LENGTH is zero, this operand doesn't contribute to the value
432 so give it a standard value of zero. */
433 if (length == 0)
435 *valuep = 0;
436 return 1;
439 #if 0
440 if (CGEN_INT_INSN_P
441 && word_offset != 0)
442 abort ();
443 #endif
445 if (word_length > 32)
446 abort ();
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)
452 if (word_offset == 0
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);
463 else
464 value = insn_value >> (total_length - ( word_offset + start + length));
467 #if ! CGEN_INT_INSN_P
469 else
471 unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
473 if (word_length > 32)
474 abort ();
476 if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
477 return 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;
487 value &= mask;
488 /* sign extend? */
489 if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)
490 && (value & (1L << (length - 1))))
491 value |= ~mask;
493 *valuep = value;
495 return 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
505 been called). */
507 static int
508 extract_insn_normal (cd, insn, ex_info, insn_value, fields, pc)
509 CGEN_CPU_DESC cd;
510 const CGEN_INSN *insn;
511 CGEN_EXTRACT_INFO *ex_info;
512 CGEN_INSN_INT insn_value;
513 CGEN_FIELDS *fields;
514 bfd_vma pc;
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)
525 int length;
527 if (CGEN_SYNTAX_CHAR_P (*syn))
528 continue;
530 length = (* cd->extract_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
531 ex_info, insn_value, fields, pc);
532 if (length <= 0)
533 return length;
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. */
559 const char *
560 frv_cgen_insert_operand (cd, opindex, fields, buffer, pc)
561 CGEN_CPU_DESC cd;
562 int opindex;
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);
570 switch (opindex)
572 case FRV_OPERAND_A :
573 errmsg = insert_normal (cd, fields->f_A, 0, 0, 17, 1, 32, total_length, buffer);
574 break;
575 case FRV_OPERAND_ACC40SI :
576 errmsg = insert_normal (cd, fields->f_ACC40Si, 0, 0, 17, 6, 32, total_length, buffer);
577 break;
578 case FRV_OPERAND_ACC40SK :
579 errmsg = insert_normal (cd, fields->f_ACC40Sk, 0, 0, 30, 6, 32, total_length, buffer);
580 break;
581 case FRV_OPERAND_ACC40UI :
582 errmsg = insert_normal (cd, fields->f_ACC40Ui, 0, 0, 17, 6, 32, total_length, buffer);
583 break;
584 case FRV_OPERAND_ACC40UK :
585 errmsg = insert_normal (cd, fields->f_ACC40Uk, 0, 0, 30, 6, 32, total_length, buffer);
586 break;
587 case FRV_OPERAND_ACCGI :
588 errmsg = insert_normal (cd, fields->f_ACCGi, 0, 0, 17, 6, 32, total_length, buffer);
589 break;
590 case FRV_OPERAND_ACCGK :
591 errmsg = insert_normal (cd, fields->f_ACCGk, 0, 0, 30, 6, 32, total_length, buffer);
592 break;
593 case FRV_OPERAND_CCI :
594 errmsg = insert_normal (cd, fields->f_CCi, 0, 0, 11, 3, 32, total_length, buffer);
595 break;
596 case FRV_OPERAND_CPRDOUBLEK :
597 errmsg = insert_normal (cd, fields->f_CPRk, 0, 0, 30, 6, 32, total_length, buffer);
598 break;
599 case FRV_OPERAND_CPRI :
600 errmsg = insert_normal (cd, fields->f_CPRi, 0, 0, 17, 6, 32, total_length, buffer);
601 break;
602 case FRV_OPERAND_CPRJ :
603 errmsg = insert_normal (cd, fields->f_CPRj, 0, 0, 5, 6, 32, total_length, buffer);
604 break;
605 case FRV_OPERAND_CPRK :
606 errmsg = insert_normal (cd, fields->f_CPRk, 0, 0, 30, 6, 32, total_length, buffer);
607 break;
608 case FRV_OPERAND_CRI :
609 errmsg = insert_normal (cd, fields->f_CRi, 0, 0, 14, 3, 32, total_length, buffer);
610 break;
611 case FRV_OPERAND_CRJ :
612 errmsg = insert_normal (cd, fields->f_CRj, 0, 0, 2, 3, 32, total_length, buffer);
613 break;
614 case FRV_OPERAND_CRJ_FLOAT :
615 errmsg = insert_normal (cd, fields->f_CRj_float, 0, 0, 26, 2, 32, total_length, buffer);
616 break;
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);
623 break;
624 case FRV_OPERAND_CRK :
625 errmsg = insert_normal (cd, fields->f_CRk, 0, 0, 27, 3, 32, total_length, buffer);
626 break;
627 case FRV_OPERAND_FCCI_1 :
628 errmsg = insert_normal (cd, fields->f_FCCi_1, 0, 0, 11, 2, 32, total_length, buffer);
629 break;
630 case FRV_OPERAND_FCCI_2 :
631 errmsg = insert_normal (cd, fields->f_FCCi_2, 0, 0, 26, 2, 32, total_length, buffer);
632 break;
633 case FRV_OPERAND_FCCI_3 :
634 errmsg = insert_normal (cd, fields->f_FCCi_3, 0, 0, 1, 2, 32, total_length, buffer);
635 break;
636 case FRV_OPERAND_FCCK :
637 errmsg = insert_normal (cd, fields->f_FCCk, 0, 0, 26, 2, 32, total_length, buffer);
638 break;
639 case FRV_OPERAND_FRDOUBLEI :
640 errmsg = insert_normal (cd, fields->f_FRi, 0, 0, 17, 6, 32, total_length, buffer);
641 break;
642 case FRV_OPERAND_FRDOUBLEJ :
643 errmsg = insert_normal (cd, fields->f_FRj, 0, 0, 5, 6, 32, total_length, buffer);
644 break;
645 case FRV_OPERAND_FRDOUBLEK :
646 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer);
647 break;
648 case FRV_OPERAND_FRI :
649 errmsg = insert_normal (cd, fields->f_FRi, 0, 0, 17, 6, 32, total_length, buffer);
650 break;
651 case FRV_OPERAND_FRINTI :
652 errmsg = insert_normal (cd, fields->f_FRi, 0, 0, 17, 6, 32, total_length, buffer);
653 break;
654 case FRV_OPERAND_FRINTIEVEN :
655 errmsg = insert_normal (cd, fields->f_FRi, 0, 0, 17, 6, 32, total_length, buffer);
656 break;
657 case FRV_OPERAND_FRINTJ :
658 errmsg = insert_normal (cd, fields->f_FRj, 0, 0, 5, 6, 32, total_length, buffer);
659 break;
660 case FRV_OPERAND_FRINTJEVEN :
661 errmsg = insert_normal (cd, fields->f_FRj, 0, 0, 5, 6, 32, total_length, buffer);
662 break;
663 case FRV_OPERAND_FRINTK :
664 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer);
665 break;
666 case FRV_OPERAND_FRINTKEVEN :
667 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer);
668 break;
669 case FRV_OPERAND_FRJ :
670 errmsg = insert_normal (cd, fields->f_FRj, 0, 0, 5, 6, 32, total_length, buffer);
671 break;
672 case FRV_OPERAND_FRK :
673 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer);
674 break;
675 case FRV_OPERAND_FRKHI :
676 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer);
677 break;
678 case FRV_OPERAND_FRKLO :
679 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer);
680 break;
681 case FRV_OPERAND_GRDOUBLEK :
682 errmsg = insert_normal (cd, fields->f_GRk, 0, 0, 30, 6, 32, total_length, buffer);
683 break;
684 case FRV_OPERAND_GRI :
685 errmsg = insert_normal (cd, fields->f_GRi, 0, 0, 17, 6, 32, total_length, buffer);
686 break;
687 case FRV_OPERAND_GRJ :
688 errmsg = insert_normal (cd, fields->f_GRj, 0, 0, 5, 6, 32, total_length, buffer);
689 break;
690 case FRV_OPERAND_GRK :
691 errmsg = insert_normal (cd, fields->f_GRk, 0, 0, 30, 6, 32, total_length, buffer);
692 break;
693 case FRV_OPERAND_GRKHI :
694 errmsg = insert_normal (cd, fields->f_GRk, 0, 0, 30, 6, 32, total_length, buffer);
695 break;
696 case FRV_OPERAND_GRKLO :
697 errmsg = insert_normal (cd, fields->f_GRk, 0, 0, 30, 6, 32, total_length, buffer);
698 break;
699 case FRV_OPERAND_ICCI_1 :
700 errmsg = insert_normal (cd, fields->f_ICCi_1, 0, 0, 11, 2, 32, total_length, buffer);
701 break;
702 case FRV_OPERAND_ICCI_2 :
703 errmsg = insert_normal (cd, fields->f_ICCi_2, 0, 0, 26, 2, 32, total_length, buffer);
704 break;
705 case FRV_OPERAND_ICCI_3 :
706 errmsg = insert_normal (cd, fields->f_ICCi_3, 0, 0, 1, 2, 32, total_length, buffer);
707 break;
708 case FRV_OPERAND_LI :
709 errmsg = insert_normal (cd, fields->f_LI, 0, 0, 25, 1, 32, total_length, buffer);
710 break;
711 case FRV_OPERAND_AE :
712 errmsg = insert_normal (cd, fields->f_ae, 0, 0, 25, 1, 32, total_length, buffer);
713 break;
714 case FRV_OPERAND_CCOND :
715 errmsg = insert_normal (cd, fields->f_ccond, 0, 0, 12, 1, 32, total_length, buffer);
716 break;
717 case FRV_OPERAND_COND :
718 errmsg = insert_normal (cd, fields->f_cond, 0, 0, 8, 1, 32, total_length, buffer);
719 break;
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);
722 break;
723 case FRV_OPERAND_DEBUG :
724 errmsg = insert_normal (cd, fields->f_debug, 0, 0, 25, 1, 32, total_length, buffer);
725 break;
726 case FRV_OPERAND_EIR :
727 errmsg = insert_normal (cd, fields->f_eir, 0, 0, 17, 6, 32, total_length, buffer);
728 break;
729 case FRV_OPERAND_HINT :
730 errmsg = insert_normal (cd, fields->f_hint, 0, 0, 17, 2, 32, total_length, buffer);
731 break;
732 case FRV_OPERAND_HINT_NOT_TAKEN :
733 errmsg = insert_normal (cd, fields->f_hint, 0, 0, 17, 2, 32, total_length, buffer);
734 break;
735 case FRV_OPERAND_HINT_TAKEN :
736 errmsg = insert_normal (cd, fields->f_hint, 0, 0, 17, 2, 32, total_length, buffer);
737 break;
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);
744 break;
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);
752 if (errmsg)
753 break;
754 errmsg = insert_normal (cd, fields->f_labelL18, 0, 0, 17, 18, 32, total_length, buffer);
755 if (errmsg)
756 break;
758 break;
759 case FRV_OPERAND_LOCK :
760 errmsg = insert_normal (cd, fields->f_lock, 0, 0, 25, 1, 32, total_length, buffer);
761 break;
762 case FRV_OPERAND_PACK :
763 errmsg = insert_normal (cd, fields->f_pack, 0, 0, 31, 1, 32, total_length, buffer);
764 break;
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);
767 break;
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);
770 break;
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);
773 break;
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);
776 break;
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);
779 break;
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);
782 break;
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);
785 break;
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);
793 if (errmsg)
794 break;
795 errmsg = insert_normal (cd, fields->f_spr_l, 0, 0, 17, 6, 32, total_length, buffer);
796 if (errmsg)
797 break;
799 break;
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);
807 if (errmsg)
808 break;
809 errmsg = insert_normal (cd, fields->f_u12_l, 0, 0, 5, 6, 32, total_length, buffer);
810 if (errmsg)
811 break;
813 break;
814 case FRV_OPERAND_U16 :
815 errmsg = insert_normal (cd, fields->f_u16, 0, 0, 15, 16, 32, total_length, buffer);
816 break;
817 case FRV_OPERAND_U6 :
818 errmsg = insert_normal (cd, fields->f_u6, 0, 0, 5, 6, 32, total_length, buffer);
819 break;
820 case FRV_OPERAND_UHI16 :
821 errmsg = insert_normal (cd, fields->f_u16, 0, 0, 15, 16, 32, total_length, buffer);
822 break;
823 case FRV_OPERAND_ULO16 :
824 errmsg = insert_normal (cd, fields->f_u16, 0, 0, 15, 16, 32, total_length, buffer);
825 break;
827 default :
828 /* xgettext:c-format */
829 fprintf (stderr, _("Unrecognized field %d while building insn.\n"),
830 opindex);
831 abort ();
834 return errmsg;
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
854 the handlers. */
857 frv_cgen_extract_operand (cd, opindex, ex_info, insn_value, fields, pc)
858 CGEN_CPU_DESC cd;
859 int opindex;
860 CGEN_EXTRACT_INFO *ex_info;
861 CGEN_INSN_INT insn_value;
862 CGEN_FIELDS * fields;
863 bfd_vma pc;
865 /* Assume success (for those operands that are nops). */
866 int length = 1;
867 unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
869 switch (opindex)
871 case FRV_OPERAND_A :
872 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 1, 32, total_length, pc, & fields->f_A);
873 break;
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);
876 break;
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);
879 break;
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);
882 break;
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);
885 break;
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);
888 break;
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);
891 break;
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);
894 break;
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);
897 break;
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);
900 break;
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);
903 break;
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);
906 break;
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);
909 break;
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);
912 break;
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);
915 break;
916 case FRV_OPERAND_CRJ_INT :
918 long value;
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;
923 break;
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);
926 break;
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);
929 break;
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);
932 break;
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);
935 break;
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);
938 break;
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);
941 break;
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);
944 break;
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);
947 break;
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);
950 break;
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);
953 break;
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);
956 break;
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);
959 break;
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);
962 break;
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);
965 break;
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);
968 break;
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);
971 break;
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);
974 break;
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);
977 break;
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);
980 break;
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);
983 break;
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);
986 break;
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);
989 break;
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);
992 break;
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);
995 break;
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);
998 break;
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);
1001 break;
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);
1004 break;
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);
1007 break;
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);
1010 break;
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);
1013 break;
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);
1016 break;
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);
1019 break;
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);
1022 break;
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);
1025 break;
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);
1028 break;
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);
1031 break;
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);
1034 break;
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);
1037 break;
1038 case FRV_OPERAND_LABEL16 :
1040 long value;
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;
1045 break;
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));
1056 break;
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);
1059 break;
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);
1062 break;
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);
1065 break;
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);
1068 break;
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);
1071 break;
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);
1074 break;
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);
1077 break;
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);
1080 break;
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);
1083 break;
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)));
1094 break;
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)));
1105 break;
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);
1108 break;
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);
1111 break;
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);
1114 break;
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);
1117 break;
1119 default :
1120 /* xgettext:c-format */
1121 fprintf (stderr, _("Unrecognized field %d while decoding insn.\n"),
1122 opindex);
1123 abort ();
1126 return length;
1129 cgen_insert_fn * const frv_cgen_insert_handlers[] =
1131 insert_insn_normal,
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
1147 not appropriate. */
1150 frv_cgen_get_int_operand (cd, opindex, fields)
1151 CGEN_CPU_DESC cd ATTRIBUTE_UNUSED;
1152 int opindex;
1153 const CGEN_FIELDS * fields;
1155 int value;
1157 switch (opindex)
1159 case FRV_OPERAND_A :
1160 value = fields->f_A;
1161 break;
1162 case FRV_OPERAND_ACC40SI :
1163 value = fields->f_ACC40Si;
1164 break;
1165 case FRV_OPERAND_ACC40SK :
1166 value = fields->f_ACC40Sk;
1167 break;
1168 case FRV_OPERAND_ACC40UI :
1169 value = fields->f_ACC40Ui;
1170 break;
1171 case FRV_OPERAND_ACC40UK :
1172 value = fields->f_ACC40Uk;
1173 break;
1174 case FRV_OPERAND_ACCGI :
1175 value = fields->f_ACCGi;
1176 break;
1177 case FRV_OPERAND_ACCGK :
1178 value = fields->f_ACCGk;
1179 break;
1180 case FRV_OPERAND_CCI :
1181 value = fields->f_CCi;
1182 break;
1183 case FRV_OPERAND_CPRDOUBLEK :
1184 value = fields->f_CPRk;
1185 break;
1186 case FRV_OPERAND_CPRI :
1187 value = fields->f_CPRi;
1188 break;
1189 case FRV_OPERAND_CPRJ :
1190 value = fields->f_CPRj;
1191 break;
1192 case FRV_OPERAND_CPRK :
1193 value = fields->f_CPRk;
1194 break;
1195 case FRV_OPERAND_CRI :
1196 value = fields->f_CRi;
1197 break;
1198 case FRV_OPERAND_CRJ :
1199 value = fields->f_CRj;
1200 break;
1201 case FRV_OPERAND_CRJ_FLOAT :
1202 value = fields->f_CRj_float;
1203 break;
1204 case FRV_OPERAND_CRJ_INT :
1205 value = fields->f_CRj_int;
1206 break;
1207 case FRV_OPERAND_CRK :
1208 value = fields->f_CRk;
1209 break;
1210 case FRV_OPERAND_FCCI_1 :
1211 value = fields->f_FCCi_1;
1212 break;
1213 case FRV_OPERAND_FCCI_2 :
1214 value = fields->f_FCCi_2;
1215 break;
1216 case FRV_OPERAND_FCCI_3 :
1217 value = fields->f_FCCi_3;
1218 break;
1219 case FRV_OPERAND_FCCK :
1220 value = fields->f_FCCk;
1221 break;
1222 case FRV_OPERAND_FRDOUBLEI :
1223 value = fields->f_FRi;
1224 break;
1225 case FRV_OPERAND_FRDOUBLEJ :
1226 value = fields->f_FRj;
1227 break;
1228 case FRV_OPERAND_FRDOUBLEK :
1229 value = fields->f_FRk;
1230 break;
1231 case FRV_OPERAND_FRI :
1232 value = fields->f_FRi;
1233 break;
1234 case FRV_OPERAND_FRINTI :
1235 value = fields->f_FRi;
1236 break;
1237 case FRV_OPERAND_FRINTIEVEN :
1238 value = fields->f_FRi;
1239 break;
1240 case FRV_OPERAND_FRINTJ :
1241 value = fields->f_FRj;
1242 break;
1243 case FRV_OPERAND_FRINTJEVEN :
1244 value = fields->f_FRj;
1245 break;
1246 case FRV_OPERAND_FRINTK :
1247 value = fields->f_FRk;
1248 break;
1249 case FRV_OPERAND_FRINTKEVEN :
1250 value = fields->f_FRk;
1251 break;
1252 case FRV_OPERAND_FRJ :
1253 value = fields->f_FRj;
1254 break;
1255 case FRV_OPERAND_FRK :
1256 value = fields->f_FRk;
1257 break;
1258 case FRV_OPERAND_FRKHI :
1259 value = fields->f_FRk;
1260 break;
1261 case FRV_OPERAND_FRKLO :
1262 value = fields->f_FRk;
1263 break;
1264 case FRV_OPERAND_GRDOUBLEK :
1265 value = fields->f_GRk;
1266 break;
1267 case FRV_OPERAND_GRI :
1268 value = fields->f_GRi;
1269 break;
1270 case FRV_OPERAND_GRJ :
1271 value = fields->f_GRj;
1272 break;
1273 case FRV_OPERAND_GRK :
1274 value = fields->f_GRk;
1275 break;
1276 case FRV_OPERAND_GRKHI :
1277 value = fields->f_GRk;
1278 break;
1279 case FRV_OPERAND_GRKLO :
1280 value = fields->f_GRk;
1281 break;
1282 case FRV_OPERAND_ICCI_1 :
1283 value = fields->f_ICCi_1;
1284 break;
1285 case FRV_OPERAND_ICCI_2 :
1286 value = fields->f_ICCi_2;
1287 break;
1288 case FRV_OPERAND_ICCI_3 :
1289 value = fields->f_ICCi_3;
1290 break;
1291 case FRV_OPERAND_LI :
1292 value = fields->f_LI;
1293 break;
1294 case FRV_OPERAND_AE :
1295 value = fields->f_ae;
1296 break;
1297 case FRV_OPERAND_CCOND :
1298 value = fields->f_ccond;
1299 break;
1300 case FRV_OPERAND_COND :
1301 value = fields->f_cond;
1302 break;
1303 case FRV_OPERAND_D12 :
1304 value = fields->f_d12;
1305 break;
1306 case FRV_OPERAND_DEBUG :
1307 value = fields->f_debug;
1308 break;
1309 case FRV_OPERAND_EIR :
1310 value = fields->f_eir;
1311 break;
1312 case FRV_OPERAND_HINT :
1313 value = fields->f_hint;
1314 break;
1315 case FRV_OPERAND_HINT_NOT_TAKEN :
1316 value = fields->f_hint;
1317 break;
1318 case FRV_OPERAND_HINT_TAKEN :
1319 value = fields->f_hint;
1320 break;
1321 case FRV_OPERAND_LABEL16 :
1322 value = fields->f_label16;
1323 break;
1324 case FRV_OPERAND_LABEL24 :
1325 value = fields->f_label24;
1326 break;
1327 case FRV_OPERAND_LOCK :
1328 value = fields->f_lock;
1329 break;
1330 case FRV_OPERAND_PACK :
1331 value = fields->f_pack;
1332 break;
1333 case FRV_OPERAND_S10 :
1334 value = fields->f_s10;
1335 break;
1336 case FRV_OPERAND_S12 :
1337 value = fields->f_d12;
1338 break;
1339 case FRV_OPERAND_S16 :
1340 value = fields->f_s16;
1341 break;
1342 case FRV_OPERAND_S5 :
1343 value = fields->f_s5;
1344 break;
1345 case FRV_OPERAND_S6 :
1346 value = fields->f_s6;
1347 break;
1348 case FRV_OPERAND_S6_1 :
1349 value = fields->f_s6_1;
1350 break;
1351 case FRV_OPERAND_SLO16 :
1352 value = fields->f_s16;
1353 break;
1354 case FRV_OPERAND_SPR :
1355 value = fields->f_spr;
1356 break;
1357 case FRV_OPERAND_U12 :
1358 value = fields->f_u12;
1359 break;
1360 case FRV_OPERAND_U16 :
1361 value = fields->f_u16;
1362 break;
1363 case FRV_OPERAND_U6 :
1364 value = fields->f_u6;
1365 break;
1366 case FRV_OPERAND_UHI16 :
1367 value = fields->f_u16;
1368 break;
1369 case FRV_OPERAND_ULO16 :
1370 value = fields->f_u16;
1371 break;
1373 default :
1374 /* xgettext:c-format */
1375 fprintf (stderr, _("Unrecognized field %d while getting int operand.\n"),
1376 opindex);
1377 abort ();
1380 return value;
1383 bfd_vma
1384 frv_cgen_get_vma_operand (cd, opindex, fields)
1385 CGEN_CPU_DESC cd ATTRIBUTE_UNUSED;
1386 int opindex;
1387 const CGEN_FIELDS * fields;
1389 bfd_vma value;
1391 switch (opindex)
1393 case FRV_OPERAND_A :
1394 value = fields->f_A;
1395 break;
1396 case FRV_OPERAND_ACC40SI :
1397 value = fields->f_ACC40Si;
1398 break;
1399 case FRV_OPERAND_ACC40SK :
1400 value = fields->f_ACC40Sk;
1401 break;
1402 case FRV_OPERAND_ACC40UI :
1403 value = fields->f_ACC40Ui;
1404 break;
1405 case FRV_OPERAND_ACC40UK :
1406 value = fields->f_ACC40Uk;
1407 break;
1408 case FRV_OPERAND_ACCGI :
1409 value = fields->f_ACCGi;
1410 break;
1411 case FRV_OPERAND_ACCGK :
1412 value = fields->f_ACCGk;
1413 break;
1414 case FRV_OPERAND_CCI :
1415 value = fields->f_CCi;
1416 break;
1417 case FRV_OPERAND_CPRDOUBLEK :
1418 value = fields->f_CPRk;
1419 break;
1420 case FRV_OPERAND_CPRI :
1421 value = fields->f_CPRi;
1422 break;
1423 case FRV_OPERAND_CPRJ :
1424 value = fields->f_CPRj;
1425 break;
1426 case FRV_OPERAND_CPRK :
1427 value = fields->f_CPRk;
1428 break;
1429 case FRV_OPERAND_CRI :
1430 value = fields->f_CRi;
1431 break;
1432 case FRV_OPERAND_CRJ :
1433 value = fields->f_CRj;
1434 break;
1435 case FRV_OPERAND_CRJ_FLOAT :
1436 value = fields->f_CRj_float;
1437 break;
1438 case FRV_OPERAND_CRJ_INT :
1439 value = fields->f_CRj_int;
1440 break;
1441 case FRV_OPERAND_CRK :
1442 value = fields->f_CRk;
1443 break;
1444 case FRV_OPERAND_FCCI_1 :
1445 value = fields->f_FCCi_1;
1446 break;
1447 case FRV_OPERAND_FCCI_2 :
1448 value = fields->f_FCCi_2;
1449 break;
1450 case FRV_OPERAND_FCCI_3 :
1451 value = fields->f_FCCi_3;
1452 break;
1453 case FRV_OPERAND_FCCK :
1454 value = fields->f_FCCk;
1455 break;
1456 case FRV_OPERAND_FRDOUBLEI :
1457 value = fields->f_FRi;
1458 break;
1459 case FRV_OPERAND_FRDOUBLEJ :
1460 value = fields->f_FRj;
1461 break;
1462 case FRV_OPERAND_FRDOUBLEK :
1463 value = fields->f_FRk;
1464 break;
1465 case FRV_OPERAND_FRI :
1466 value = fields->f_FRi;
1467 break;
1468 case FRV_OPERAND_FRINTI :
1469 value = fields->f_FRi;
1470 break;
1471 case FRV_OPERAND_FRINTIEVEN :
1472 value = fields->f_FRi;
1473 break;
1474 case FRV_OPERAND_FRINTJ :
1475 value = fields->f_FRj;
1476 break;
1477 case FRV_OPERAND_FRINTJEVEN :
1478 value = fields->f_FRj;
1479 break;
1480 case FRV_OPERAND_FRINTK :
1481 value = fields->f_FRk;
1482 break;
1483 case FRV_OPERAND_FRINTKEVEN :
1484 value = fields->f_FRk;
1485 break;
1486 case FRV_OPERAND_FRJ :
1487 value = fields->f_FRj;
1488 break;
1489 case FRV_OPERAND_FRK :
1490 value = fields->f_FRk;
1491 break;
1492 case FRV_OPERAND_FRKHI :
1493 value = fields->f_FRk;
1494 break;
1495 case FRV_OPERAND_FRKLO :
1496 value = fields->f_FRk;
1497 break;
1498 case FRV_OPERAND_GRDOUBLEK :
1499 value = fields->f_GRk;
1500 break;
1501 case FRV_OPERAND_GRI :
1502 value = fields->f_GRi;
1503 break;
1504 case FRV_OPERAND_GRJ :
1505 value = fields->f_GRj;
1506 break;
1507 case FRV_OPERAND_GRK :
1508 value = fields->f_GRk;
1509 break;
1510 case FRV_OPERAND_GRKHI :
1511 value = fields->f_GRk;
1512 break;
1513 case FRV_OPERAND_GRKLO :
1514 value = fields->f_GRk;
1515 break;
1516 case FRV_OPERAND_ICCI_1 :
1517 value = fields->f_ICCi_1;
1518 break;
1519 case FRV_OPERAND_ICCI_2 :
1520 value = fields->f_ICCi_2;
1521 break;
1522 case FRV_OPERAND_ICCI_3 :
1523 value = fields->f_ICCi_3;
1524 break;
1525 case FRV_OPERAND_LI :
1526 value = fields->f_LI;
1527 break;
1528 case FRV_OPERAND_AE :
1529 value = fields->f_ae;
1530 break;
1531 case FRV_OPERAND_CCOND :
1532 value = fields->f_ccond;
1533 break;
1534 case FRV_OPERAND_COND :
1535 value = fields->f_cond;
1536 break;
1537 case FRV_OPERAND_D12 :
1538 value = fields->f_d12;
1539 break;
1540 case FRV_OPERAND_DEBUG :
1541 value = fields->f_debug;
1542 break;
1543 case FRV_OPERAND_EIR :
1544 value = fields->f_eir;
1545 break;
1546 case FRV_OPERAND_HINT :
1547 value = fields->f_hint;
1548 break;
1549 case FRV_OPERAND_HINT_NOT_TAKEN :
1550 value = fields->f_hint;
1551 break;
1552 case FRV_OPERAND_HINT_TAKEN :
1553 value = fields->f_hint;
1554 break;
1555 case FRV_OPERAND_LABEL16 :
1556 value = fields->f_label16;
1557 break;
1558 case FRV_OPERAND_LABEL24 :
1559 value = fields->f_label24;
1560 break;
1561 case FRV_OPERAND_LOCK :
1562 value = fields->f_lock;
1563 break;
1564 case FRV_OPERAND_PACK :
1565 value = fields->f_pack;
1566 break;
1567 case FRV_OPERAND_S10 :
1568 value = fields->f_s10;
1569 break;
1570 case FRV_OPERAND_S12 :
1571 value = fields->f_d12;
1572 break;
1573 case FRV_OPERAND_S16 :
1574 value = fields->f_s16;
1575 break;
1576 case FRV_OPERAND_S5 :
1577 value = fields->f_s5;
1578 break;
1579 case FRV_OPERAND_S6 :
1580 value = fields->f_s6;
1581 break;
1582 case FRV_OPERAND_S6_1 :
1583 value = fields->f_s6_1;
1584 break;
1585 case FRV_OPERAND_SLO16 :
1586 value = fields->f_s16;
1587 break;
1588 case FRV_OPERAND_SPR :
1589 value = fields->f_spr;
1590 break;
1591 case FRV_OPERAND_U12 :
1592 value = fields->f_u12;
1593 break;
1594 case FRV_OPERAND_U16 :
1595 value = fields->f_u16;
1596 break;
1597 case FRV_OPERAND_U6 :
1598 value = fields->f_u6;
1599 break;
1600 case FRV_OPERAND_UHI16 :
1601 value = fields->f_u16;
1602 break;
1603 case FRV_OPERAND_ULO16 :
1604 value = fields->f_u16;
1605 break;
1607 default :
1608 /* xgettext:c-format */
1609 fprintf (stderr, _("Unrecognized field %d while getting vma operand.\n"),
1610 opindex);
1611 abort ();
1614 return value;
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
1625 not appropriate. */
1627 void
1628 frv_cgen_set_int_operand (cd, opindex, fields, value)
1629 CGEN_CPU_DESC cd ATTRIBUTE_UNUSED;
1630 int opindex;
1631 CGEN_FIELDS * fields;
1632 int value;
1634 switch (opindex)
1636 case FRV_OPERAND_A :
1637 fields->f_A = value;
1638 break;
1639 case FRV_OPERAND_ACC40SI :
1640 fields->f_ACC40Si = value;
1641 break;
1642 case FRV_OPERAND_ACC40SK :
1643 fields->f_ACC40Sk = value;
1644 break;
1645 case FRV_OPERAND_ACC40UI :
1646 fields->f_ACC40Ui = value;
1647 break;
1648 case FRV_OPERAND_ACC40UK :
1649 fields->f_ACC40Uk = value;
1650 break;
1651 case FRV_OPERAND_ACCGI :
1652 fields->f_ACCGi = value;
1653 break;
1654 case FRV_OPERAND_ACCGK :
1655 fields->f_ACCGk = value;
1656 break;
1657 case FRV_OPERAND_CCI :
1658 fields->f_CCi = value;
1659 break;
1660 case FRV_OPERAND_CPRDOUBLEK :
1661 fields->f_CPRk = value;
1662 break;
1663 case FRV_OPERAND_CPRI :
1664 fields->f_CPRi = value;
1665 break;
1666 case FRV_OPERAND_CPRJ :
1667 fields->f_CPRj = value;
1668 break;
1669 case FRV_OPERAND_CPRK :
1670 fields->f_CPRk = value;
1671 break;
1672 case FRV_OPERAND_CRI :
1673 fields->f_CRi = value;
1674 break;
1675 case FRV_OPERAND_CRJ :
1676 fields->f_CRj = value;
1677 break;
1678 case FRV_OPERAND_CRJ_FLOAT :
1679 fields->f_CRj_float = value;
1680 break;
1681 case FRV_OPERAND_CRJ_INT :
1682 fields->f_CRj_int = value;
1683 break;
1684 case FRV_OPERAND_CRK :
1685 fields->f_CRk = value;
1686 break;
1687 case FRV_OPERAND_FCCI_1 :
1688 fields->f_FCCi_1 = value;
1689 break;
1690 case FRV_OPERAND_FCCI_2 :
1691 fields->f_FCCi_2 = value;
1692 break;
1693 case FRV_OPERAND_FCCI_3 :
1694 fields->f_FCCi_3 = value;
1695 break;
1696 case FRV_OPERAND_FCCK :
1697 fields->f_FCCk = value;
1698 break;
1699 case FRV_OPERAND_FRDOUBLEI :
1700 fields->f_FRi = value;
1701 break;
1702 case FRV_OPERAND_FRDOUBLEJ :
1703 fields->f_FRj = value;
1704 break;
1705 case FRV_OPERAND_FRDOUBLEK :
1706 fields->f_FRk = value;
1707 break;
1708 case FRV_OPERAND_FRI :
1709 fields->f_FRi = value;
1710 break;
1711 case FRV_OPERAND_FRINTI :
1712 fields->f_FRi = value;
1713 break;
1714 case FRV_OPERAND_FRINTIEVEN :
1715 fields->f_FRi = value;
1716 break;
1717 case FRV_OPERAND_FRINTJ :
1718 fields->f_FRj = value;
1719 break;
1720 case FRV_OPERAND_FRINTJEVEN :
1721 fields->f_FRj = value;
1722 break;
1723 case FRV_OPERAND_FRINTK :
1724 fields->f_FRk = value;
1725 break;
1726 case FRV_OPERAND_FRINTKEVEN :
1727 fields->f_FRk = value;
1728 break;
1729 case FRV_OPERAND_FRJ :
1730 fields->f_FRj = value;
1731 break;
1732 case FRV_OPERAND_FRK :
1733 fields->f_FRk = value;
1734 break;
1735 case FRV_OPERAND_FRKHI :
1736 fields->f_FRk = value;
1737 break;
1738 case FRV_OPERAND_FRKLO :
1739 fields->f_FRk = value;
1740 break;
1741 case FRV_OPERAND_GRDOUBLEK :
1742 fields->f_GRk = value;
1743 break;
1744 case FRV_OPERAND_GRI :
1745 fields->f_GRi = value;
1746 break;
1747 case FRV_OPERAND_GRJ :
1748 fields->f_GRj = value;
1749 break;
1750 case FRV_OPERAND_GRK :
1751 fields->f_GRk = value;
1752 break;
1753 case FRV_OPERAND_GRKHI :
1754 fields->f_GRk = value;
1755 break;
1756 case FRV_OPERAND_GRKLO :
1757 fields->f_GRk = value;
1758 break;
1759 case FRV_OPERAND_ICCI_1 :
1760 fields->f_ICCi_1 = value;
1761 break;
1762 case FRV_OPERAND_ICCI_2 :
1763 fields->f_ICCi_2 = value;
1764 break;
1765 case FRV_OPERAND_ICCI_3 :
1766 fields->f_ICCi_3 = value;
1767 break;
1768 case FRV_OPERAND_LI :
1769 fields->f_LI = value;
1770 break;
1771 case FRV_OPERAND_AE :
1772 fields->f_ae = value;
1773 break;
1774 case FRV_OPERAND_CCOND :
1775 fields->f_ccond = value;
1776 break;
1777 case FRV_OPERAND_COND :
1778 fields->f_cond = value;
1779 break;
1780 case FRV_OPERAND_D12 :
1781 fields->f_d12 = value;
1782 break;
1783 case FRV_OPERAND_DEBUG :
1784 fields->f_debug = value;
1785 break;
1786 case FRV_OPERAND_EIR :
1787 fields->f_eir = value;
1788 break;
1789 case FRV_OPERAND_HINT :
1790 fields->f_hint = value;
1791 break;
1792 case FRV_OPERAND_HINT_NOT_TAKEN :
1793 fields->f_hint = value;
1794 break;
1795 case FRV_OPERAND_HINT_TAKEN :
1796 fields->f_hint = value;
1797 break;
1798 case FRV_OPERAND_LABEL16 :
1799 fields->f_label16 = value;
1800 break;
1801 case FRV_OPERAND_LABEL24 :
1802 fields->f_label24 = value;
1803 break;
1804 case FRV_OPERAND_LOCK :
1805 fields->f_lock = value;
1806 break;
1807 case FRV_OPERAND_PACK :
1808 fields->f_pack = value;
1809 break;
1810 case FRV_OPERAND_S10 :
1811 fields->f_s10 = value;
1812 break;
1813 case FRV_OPERAND_S12 :
1814 fields->f_d12 = value;
1815 break;
1816 case FRV_OPERAND_S16 :
1817 fields->f_s16 = value;
1818 break;
1819 case FRV_OPERAND_S5 :
1820 fields->f_s5 = value;
1821 break;
1822 case FRV_OPERAND_S6 :
1823 fields->f_s6 = value;
1824 break;
1825 case FRV_OPERAND_S6_1 :
1826 fields->f_s6_1 = value;
1827 break;
1828 case FRV_OPERAND_SLO16 :
1829 fields->f_s16 = value;
1830 break;
1831 case FRV_OPERAND_SPR :
1832 fields->f_spr = value;
1833 break;
1834 case FRV_OPERAND_U12 :
1835 fields->f_u12 = value;
1836 break;
1837 case FRV_OPERAND_U16 :
1838 fields->f_u16 = value;
1839 break;
1840 case FRV_OPERAND_U6 :
1841 fields->f_u6 = value;
1842 break;
1843 case FRV_OPERAND_UHI16 :
1844 fields->f_u16 = value;
1845 break;
1846 case FRV_OPERAND_ULO16 :
1847 fields->f_u16 = value;
1848 break;
1850 default :
1851 /* xgettext:c-format */
1852 fprintf (stderr, _("Unrecognized field %d while setting int operand.\n"),
1853 opindex);
1854 abort ();
1858 void
1859 frv_cgen_set_vma_operand (cd, opindex, fields, value)
1860 CGEN_CPU_DESC cd ATTRIBUTE_UNUSED;
1861 int opindex;
1862 CGEN_FIELDS * fields;
1863 bfd_vma value;
1865 switch (opindex)
1867 case FRV_OPERAND_A :
1868 fields->f_A = value;
1869 break;
1870 case FRV_OPERAND_ACC40SI :
1871 fields->f_ACC40Si = value;
1872 break;
1873 case FRV_OPERAND_ACC40SK :
1874 fields->f_ACC40Sk = value;
1875 break;
1876 case FRV_OPERAND_ACC40UI :
1877 fields->f_ACC40Ui = value;
1878 break;
1879 case FRV_OPERAND_ACC40UK :
1880 fields->f_ACC40Uk = value;
1881 break;
1882 case FRV_OPERAND_ACCGI :
1883 fields->f_ACCGi = value;
1884 break;
1885 case FRV_OPERAND_ACCGK :
1886 fields->f_ACCGk = value;
1887 break;
1888 case FRV_OPERAND_CCI :
1889 fields->f_CCi = value;
1890 break;
1891 case FRV_OPERAND_CPRDOUBLEK :
1892 fields->f_CPRk = value;
1893 break;
1894 case FRV_OPERAND_CPRI :
1895 fields->f_CPRi = value;
1896 break;
1897 case FRV_OPERAND_CPRJ :
1898 fields->f_CPRj = value;
1899 break;
1900 case FRV_OPERAND_CPRK :
1901 fields->f_CPRk = value;
1902 break;
1903 case FRV_OPERAND_CRI :
1904 fields->f_CRi = value;
1905 break;
1906 case FRV_OPERAND_CRJ :
1907 fields->f_CRj = value;
1908 break;
1909 case FRV_OPERAND_CRJ_FLOAT :
1910 fields->f_CRj_float = value;
1911 break;
1912 case FRV_OPERAND_CRJ_INT :
1913 fields->f_CRj_int = value;
1914 break;
1915 case FRV_OPERAND_CRK :
1916 fields->f_CRk = value;
1917 break;
1918 case FRV_OPERAND_FCCI_1 :
1919 fields->f_FCCi_1 = value;
1920 break;
1921 case FRV_OPERAND_FCCI_2 :
1922 fields->f_FCCi_2 = value;
1923 break;
1924 case FRV_OPERAND_FCCI_3 :
1925 fields->f_FCCi_3 = value;
1926 break;
1927 case FRV_OPERAND_FCCK :
1928 fields->f_FCCk = value;
1929 break;
1930 case FRV_OPERAND_FRDOUBLEI :
1931 fields->f_FRi = value;
1932 break;
1933 case FRV_OPERAND_FRDOUBLEJ :
1934 fields->f_FRj = value;
1935 break;
1936 case FRV_OPERAND_FRDOUBLEK :
1937 fields->f_FRk = value;
1938 break;
1939 case FRV_OPERAND_FRI :
1940 fields->f_FRi = value;
1941 break;
1942 case FRV_OPERAND_FRINTI :
1943 fields->f_FRi = value;
1944 break;
1945 case FRV_OPERAND_FRINTIEVEN :
1946 fields->f_FRi = value;
1947 break;
1948 case FRV_OPERAND_FRINTJ :
1949 fields->f_FRj = value;
1950 break;
1951 case FRV_OPERAND_FRINTJEVEN :
1952 fields->f_FRj = value;
1953 break;
1954 case FRV_OPERAND_FRINTK :
1955 fields->f_FRk = value;
1956 break;
1957 case FRV_OPERAND_FRINTKEVEN :
1958 fields->f_FRk = value;
1959 break;
1960 case FRV_OPERAND_FRJ :
1961 fields->f_FRj = value;
1962 break;
1963 case FRV_OPERAND_FRK :
1964 fields->f_FRk = value;
1965 break;
1966 case FRV_OPERAND_FRKHI :
1967 fields->f_FRk = value;
1968 break;
1969 case FRV_OPERAND_FRKLO :
1970 fields->f_FRk = value;
1971 break;
1972 case FRV_OPERAND_GRDOUBLEK :
1973 fields->f_GRk = value;
1974 break;
1975 case FRV_OPERAND_GRI :
1976 fields->f_GRi = value;
1977 break;
1978 case FRV_OPERAND_GRJ :
1979 fields->f_GRj = value;
1980 break;
1981 case FRV_OPERAND_GRK :
1982 fields->f_GRk = value;
1983 break;
1984 case FRV_OPERAND_GRKHI :
1985 fields->f_GRk = value;
1986 break;
1987 case FRV_OPERAND_GRKLO :
1988 fields->f_GRk = value;
1989 break;
1990 case FRV_OPERAND_ICCI_1 :
1991 fields->f_ICCi_1 = value;
1992 break;
1993 case FRV_OPERAND_ICCI_2 :
1994 fields->f_ICCi_2 = value;
1995 break;
1996 case FRV_OPERAND_ICCI_3 :
1997 fields->f_ICCi_3 = value;
1998 break;
1999 case FRV_OPERAND_LI :
2000 fields->f_LI = value;
2001 break;
2002 case FRV_OPERAND_AE :
2003 fields->f_ae = value;
2004 break;
2005 case FRV_OPERAND_CCOND :
2006 fields->f_ccond = value;
2007 break;
2008 case FRV_OPERAND_COND :
2009 fields->f_cond = value;
2010 break;
2011 case FRV_OPERAND_D12 :
2012 fields->f_d12 = value;
2013 break;
2014 case FRV_OPERAND_DEBUG :
2015 fields->f_debug = value;
2016 break;
2017 case FRV_OPERAND_EIR :
2018 fields->f_eir = value;
2019 break;
2020 case FRV_OPERAND_HINT :
2021 fields->f_hint = value;
2022 break;
2023 case FRV_OPERAND_HINT_NOT_TAKEN :
2024 fields->f_hint = value;
2025 break;
2026 case FRV_OPERAND_HINT_TAKEN :
2027 fields->f_hint = value;
2028 break;
2029 case FRV_OPERAND_LABEL16 :
2030 fields->f_label16 = value;
2031 break;
2032 case FRV_OPERAND_LABEL24 :
2033 fields->f_label24 = value;
2034 break;
2035 case FRV_OPERAND_LOCK :
2036 fields->f_lock = value;
2037 break;
2038 case FRV_OPERAND_PACK :
2039 fields->f_pack = value;
2040 break;
2041 case FRV_OPERAND_S10 :
2042 fields->f_s10 = value;
2043 break;
2044 case FRV_OPERAND_S12 :
2045 fields->f_d12 = value;
2046 break;
2047 case FRV_OPERAND_S16 :
2048 fields->f_s16 = value;
2049 break;
2050 case FRV_OPERAND_S5 :
2051 fields->f_s5 = value;
2052 break;
2053 case FRV_OPERAND_S6 :
2054 fields->f_s6 = value;
2055 break;
2056 case FRV_OPERAND_S6_1 :
2057 fields->f_s6_1 = value;
2058 break;
2059 case FRV_OPERAND_SLO16 :
2060 fields->f_s16 = value;
2061 break;
2062 case FRV_OPERAND_SPR :
2063 fields->f_spr = value;
2064 break;
2065 case FRV_OPERAND_U12 :
2066 fields->f_u12 = value;
2067 break;
2068 case FRV_OPERAND_U16 :
2069 fields->f_u16 = value;
2070 break;
2071 case FRV_OPERAND_U6 :
2072 fields->f_u6 = value;
2073 break;
2074 case FRV_OPERAND_UHI16 :
2075 fields->f_u16 = value;
2076 break;
2077 case FRV_OPERAND_ULO16 :
2078 fields->f_u16 = value;
2079 break;
2081 default :
2082 /* xgettext:c-format */
2083 fprintf (stderr, _("Unrecognized field %d while setting vma operand.\n"),
2084 opindex);
2085 abort ();
2089 /* Function to call before using the instruction builder tables. */
2091 void
2092 frv_cgen_init_ibld_table (cd)
2093 CGEN_CPU_DESC 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;