gas:
[binutils.git] / opcodes / frv-ibld.c
blob61db1bf86e9e773aa4657a8410ff79f9a2d107bc
1 /* Instruction building/extraction support for frv. -*- C -*-
3 THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator.
4 - the resultant file is machine generated, cgen-ibld.in isn't
6 Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005, 2006, 2007,
7 2008, 2010 Free Software Foundation, Inc.
9 This file is part of libopcodes.
11 This library is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3, or (at your option)
14 any later version.
16 It is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
19 License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
25 /* ??? Eventually more and more of this stuff can go to cpu-independent files.
26 Keep that in mind. */
28 #include "sysdep.h"
29 #include <stdio.h>
30 #include "ansidecl.h"
31 #include "dis-asm.h"
32 #include "bfd.h"
33 #include "symcat.h"
34 #include "frv-desc.h"
35 #include "frv-opc.h"
36 #include "cgen/basic-modes.h"
37 #include "opintl.h"
38 #include "safe-ctype.h"
40 #undef min
41 #define min(a,b) ((a) < (b) ? (a) : (b))
42 #undef max
43 #define max(a,b) ((a) > (b) ? (a) : (b))
45 /* Used by the ifield rtx function. */
46 #define FLD(f) (fields->f)
48 static const char * insert_normal
49 (CGEN_CPU_DESC, long, unsigned int, unsigned int, unsigned int,
50 unsigned int, unsigned int, unsigned int, CGEN_INSN_BYTES_PTR);
51 static const char * insert_insn_normal
52 (CGEN_CPU_DESC, const CGEN_INSN *,
53 CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma);
54 static int extract_normal
55 (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, CGEN_INSN_INT,
56 unsigned int, unsigned int, unsigned int, unsigned int,
57 unsigned int, unsigned int, bfd_vma, long *);
58 static int extract_insn_normal
59 (CGEN_CPU_DESC, const CGEN_INSN *, CGEN_EXTRACT_INFO *,
60 CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma);
61 #if CGEN_INT_INSN_P
62 static void put_insn_int_value
63 (CGEN_CPU_DESC, CGEN_INSN_BYTES_PTR, int, int, CGEN_INSN_INT);
64 #endif
65 #if ! CGEN_INT_INSN_P
66 static CGEN_INLINE void insert_1
67 (CGEN_CPU_DESC, unsigned long, int, int, int, unsigned char *);
68 static CGEN_INLINE int fill_cache
69 (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, int, int, bfd_vma);
70 static CGEN_INLINE long extract_1
71 (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, int, int, int, unsigned char *, bfd_vma);
72 #endif
74 /* Operand insertion. */
76 #if ! CGEN_INT_INSN_P
78 /* Subroutine of insert_normal. */
80 static CGEN_INLINE void
81 insert_1 (CGEN_CPU_DESC cd,
82 unsigned long value,
83 int start,
84 int length,
85 int word_length,
86 unsigned char *bufp)
88 unsigned long x,mask;
89 int shift;
91 x = cgen_get_insn_value (cd, bufp, word_length);
93 /* Written this way to avoid undefined behaviour. */
94 mask = (((1L << (length - 1)) - 1) << 1) | 1;
95 if (CGEN_INSN_LSB0_P)
96 shift = (start + 1) - length;
97 else
98 shift = (word_length - (start + length));
99 x = (x & ~(mask << shift)) | ((value & mask) << shift);
101 cgen_put_insn_value (cd, bufp, word_length, (bfd_vma) x);
104 #endif /* ! CGEN_INT_INSN_P */
106 /* Default insertion routine.
108 ATTRS is a mask of the boolean attributes.
109 WORD_OFFSET is the offset in bits from the start of the insn of the value.
110 WORD_LENGTH is the length of the word in bits in which the value resides.
111 START is the starting bit number in the word, architecture origin.
112 LENGTH is the length of VALUE in bits.
113 TOTAL_LENGTH is the total length of the insn in bits.
115 The result is an error message or NULL if success. */
117 /* ??? This duplicates functionality with bfd's howto table and
118 bfd_install_relocation. */
119 /* ??? This doesn't handle bfd_vma's. Create another function when
120 necessary. */
122 static const char *
123 insert_normal (CGEN_CPU_DESC cd,
124 long value,
125 unsigned int attrs,
126 unsigned int word_offset,
127 unsigned int start,
128 unsigned int length,
129 unsigned int word_length,
130 unsigned int total_length,
131 CGEN_INSN_BYTES_PTR buffer)
133 static char errbuf[100];
134 /* Written this way to avoid undefined behaviour. */
135 unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
137 /* If LENGTH is zero, this operand doesn't contribute to the value. */
138 if (length == 0)
139 return NULL;
141 if (word_length > 8 * sizeof (CGEN_INSN_INT))
142 abort ();
144 /* For architectures with insns smaller than the base-insn-bitsize,
145 word_length may be too big. */
146 if (cd->min_insn_bitsize < cd->base_insn_bitsize)
148 if (word_offset == 0
149 && word_length > total_length)
150 word_length = total_length;
153 /* Ensure VALUE will fit. */
154 if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGN_OPT))
156 long minval = - (1L << (length - 1));
157 unsigned long maxval = mask;
159 if ((value > 0 && (unsigned long) value > maxval)
160 || value < minval)
162 /* xgettext:c-format */
163 sprintf (errbuf,
164 _("operand out of range (%ld not between %ld and %lu)"),
165 value, minval, maxval);
166 return errbuf;
169 else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED))
171 unsigned long maxval = mask;
172 unsigned long val = (unsigned long) value;
174 /* For hosts with a word size > 32 check to see if value has been sign
175 extended beyond 32 bits. If so then ignore these higher sign bits
176 as the user is attempting to store a 32-bit signed value into an
177 unsigned 32-bit field which is allowed. */
178 if (sizeof (unsigned long) > 4 && ((value >> 32) == -1))
179 val &= 0xFFFFFFFF;
181 if (val > maxval)
183 /* xgettext:c-format */
184 sprintf (errbuf,
185 _("operand out of range (0x%lx not between 0 and 0x%lx)"),
186 val, maxval);
187 return errbuf;
190 else
192 if (! cgen_signed_overflow_ok_p (cd))
194 long minval = - (1L << (length - 1));
195 long maxval = (1L << (length - 1)) - 1;
197 if (value < minval || value > maxval)
199 sprintf
200 /* xgettext:c-format */
201 (errbuf, _("operand out of range (%ld not between %ld and %ld)"),
202 value, minval, maxval);
203 return errbuf;
208 #if CGEN_INT_INSN_P
211 int shift;
213 if (CGEN_INSN_LSB0_P)
214 shift = (word_offset + start + 1) - length;
215 else
216 shift = total_length - (word_offset + start + length);
217 *buffer = (*buffer & ~(mask << shift)) | ((value & mask) << shift);
220 #else /* ! CGEN_INT_INSN_P */
223 unsigned char *bufp = (unsigned char *) buffer + word_offset / 8;
225 insert_1 (cd, value, start, length, word_length, bufp);
228 #endif /* ! CGEN_INT_INSN_P */
230 return NULL;
233 /* Default insn builder (insert handler).
234 The instruction is recorded in CGEN_INT_INSN_P byte order (meaning
235 that if CGEN_INSN_BYTES_PTR is an int * and thus, the value is
236 recorded in host byte order, otherwise BUFFER is an array of bytes
237 and the value is recorded in target byte order).
238 The result is an error message or NULL if success. */
240 static const char *
241 insert_insn_normal (CGEN_CPU_DESC cd,
242 const CGEN_INSN * insn,
243 CGEN_FIELDS * fields,
244 CGEN_INSN_BYTES_PTR buffer,
245 bfd_vma pc)
247 const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
248 unsigned long value;
249 const CGEN_SYNTAX_CHAR_TYPE * syn;
251 CGEN_INIT_INSERT (cd);
252 value = CGEN_INSN_BASE_VALUE (insn);
254 /* If we're recording insns as numbers (rather than a string of bytes),
255 target byte order handling is deferred until later. */
257 #if CGEN_INT_INSN_P
259 put_insn_int_value (cd, buffer, cd->base_insn_bitsize,
260 CGEN_FIELDS_BITSIZE (fields), value);
262 #else
264 cgen_put_insn_value (cd, buffer, min ((unsigned) cd->base_insn_bitsize,
265 (unsigned) CGEN_FIELDS_BITSIZE (fields)),
266 value);
268 #endif /* ! CGEN_INT_INSN_P */
270 /* ??? It would be better to scan the format's fields.
271 Still need to be able to insert a value based on the operand though;
272 e.g. storing a branch displacement that got resolved later.
273 Needs more thought first. */
275 for (syn = CGEN_SYNTAX_STRING (syntax); * syn; ++ syn)
277 const char *errmsg;
279 if (CGEN_SYNTAX_CHAR_P (* syn))
280 continue;
282 errmsg = (* cd->insert_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
283 fields, buffer, pc);
284 if (errmsg)
285 return errmsg;
288 return NULL;
291 #if CGEN_INT_INSN_P
292 /* Cover function to store an insn value into an integral insn. Must go here
293 because it needs <prefix>-desc.h for CGEN_INT_INSN_P. */
295 static void
296 put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
297 CGEN_INSN_BYTES_PTR buf,
298 int length,
299 int insn_length,
300 CGEN_INSN_INT value)
302 /* For architectures with insns smaller than the base-insn-bitsize,
303 length may be too big. */
304 if (length > insn_length)
305 *buf = value;
306 else
308 int shift = insn_length - length;
309 /* Written this way to avoid undefined behaviour. */
310 CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1;
312 *buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
315 #endif
317 /* Operand extraction. */
319 #if ! CGEN_INT_INSN_P
321 /* Subroutine of extract_normal.
322 Ensure sufficient bytes are cached in EX_INFO.
323 OFFSET is the offset in bytes from the start of the insn of the value.
324 BYTES is the length of the needed value.
325 Returns 1 for success, 0 for failure. */
327 static CGEN_INLINE int
328 fill_cache (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
329 CGEN_EXTRACT_INFO *ex_info,
330 int offset,
331 int bytes,
332 bfd_vma pc)
334 /* It's doubtful that the middle part has already been fetched so
335 we don't optimize that case. kiss. */
336 unsigned int mask;
337 disassemble_info *info = (disassemble_info *) ex_info->dis_info;
339 /* First do a quick check. */
340 mask = (1 << bytes) - 1;
341 if (((ex_info->valid >> offset) & mask) == mask)
342 return 1;
344 /* Search for the first byte we need to read. */
345 for (mask = 1 << offset; bytes > 0; --bytes, ++offset, mask <<= 1)
346 if (! (mask & ex_info->valid))
347 break;
349 if (bytes)
351 int status;
353 pc += offset;
354 status = (*info->read_memory_func)
355 (pc, ex_info->insn_bytes + offset, bytes, info);
357 if (status != 0)
359 (*info->memory_error_func) (status, pc, info);
360 return 0;
363 ex_info->valid |= ((1 << bytes) - 1) << offset;
366 return 1;
369 /* Subroutine of extract_normal. */
371 static CGEN_INLINE long
372 extract_1 (CGEN_CPU_DESC cd,
373 CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED,
374 int start,
375 int length,
376 int word_length,
377 unsigned char *bufp,
378 bfd_vma pc ATTRIBUTE_UNUSED)
380 unsigned long x;
381 int shift;
383 x = cgen_get_insn_value (cd, bufp, word_length);
385 if (CGEN_INSN_LSB0_P)
386 shift = (start + 1) - length;
387 else
388 shift = (word_length - (start + length));
389 return x >> shift;
392 #endif /* ! CGEN_INT_INSN_P */
394 /* Default extraction routine.
396 INSN_VALUE is the first base_insn_bitsize bits of the insn in host order,
397 or sometimes less for cases like the m32r where the base insn size is 32
398 but some insns are 16 bits.
399 ATTRS is a mask of the boolean attributes. We only need `SIGNED',
400 but for generality we take a bitmask of all of them.
401 WORD_OFFSET is the offset in bits from the start of the insn of the value.
402 WORD_LENGTH is the length of the word in bits in which the value resides.
403 START is the starting bit number in the word, architecture origin.
404 LENGTH is the length of VALUE in bits.
405 TOTAL_LENGTH is the total length of the insn in bits.
407 Returns 1 for success, 0 for failure. */
409 /* ??? The return code isn't properly used. wip. */
411 /* ??? This doesn't handle bfd_vma's. Create another function when
412 necessary. */
414 static int
415 extract_normal (CGEN_CPU_DESC cd,
416 #if ! CGEN_INT_INSN_P
417 CGEN_EXTRACT_INFO *ex_info,
418 #else
419 CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED,
420 #endif
421 CGEN_INSN_INT insn_value,
422 unsigned int attrs,
423 unsigned int word_offset,
424 unsigned int start,
425 unsigned int length,
426 unsigned int word_length,
427 unsigned int total_length,
428 #if ! CGEN_INT_INSN_P
429 bfd_vma pc,
430 #else
431 bfd_vma pc ATTRIBUTE_UNUSED,
432 #endif
433 long *valuep)
435 long value, mask;
437 /* If LENGTH is zero, this operand doesn't contribute to the value
438 so give it a standard value of zero. */
439 if (length == 0)
441 *valuep = 0;
442 return 1;
445 if (word_length > 8 * sizeof (CGEN_INSN_INT))
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 + word_length > total_length)
453 word_length = total_length - word_offset;
456 /* Does the value reside in INSN_VALUE, and at the right alignment? */
458 if (CGEN_INT_INSN_P || (word_offset == 0 && word_length == total_length))
460 if (CGEN_INSN_LSB0_P)
461 value = insn_value >> ((word_offset + start + 1) - length);
462 else
463 value = insn_value >> (total_length - ( word_offset + start + length));
466 #if ! CGEN_INT_INSN_P
468 else
470 unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
472 if (word_length > 8 * sizeof (CGEN_INSN_INT))
473 abort ();
475 if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
476 return 0;
478 value = extract_1 (cd, ex_info, start, length, word_length, bufp, pc);
481 #endif /* ! CGEN_INT_INSN_P */
483 /* Written this way to avoid undefined behaviour. */
484 mask = (((1L << (length - 1)) - 1) << 1) | 1;
486 value &= mask;
487 /* sign extend? */
488 if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)
489 && (value & (1L << (length - 1))))
490 value |= ~mask;
492 *valuep = value;
494 return 1;
497 /* Default insn extractor.
499 INSN_VALUE is the first base_insn_bitsize bits, translated to host order.
500 The extracted fields are stored in FIELDS.
501 EX_INFO is used to handle reading variable length insns.
502 Return the length of the insn in bits, or 0 if no match,
503 or -1 if an error occurs fetching data (memory_error_func will have
504 been called). */
506 static int
507 extract_insn_normal (CGEN_CPU_DESC cd,
508 const CGEN_INSN *insn,
509 CGEN_EXTRACT_INFO *ex_info,
510 CGEN_INSN_INT insn_value,
511 CGEN_FIELDS *fields,
512 bfd_vma pc)
514 const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
515 const CGEN_SYNTAX_CHAR_TYPE *syn;
517 CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn);
519 CGEN_INIT_EXTRACT (cd);
521 for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn)
523 int length;
525 if (CGEN_SYNTAX_CHAR_P (*syn))
526 continue;
528 length = (* cd->extract_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
529 ex_info, insn_value, fields, pc);
530 if (length <= 0)
531 return length;
534 /* We recognized and successfully extracted this insn. */
535 return CGEN_INSN_BITSIZE (insn);
538 /* Machine generated code added here. */
540 const char * frv_cgen_insert_operand
541 (CGEN_CPU_DESC, int, CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma);
543 /* Main entry point for operand insertion.
545 This function is basically just a big switch statement. Earlier versions
546 used tables to look up the function to use, but
547 - if the table contains both assembler and disassembler functions then
548 the disassembler contains much of the assembler and vice-versa,
549 - there's a lot of inlining possibilities as things grow,
550 - using a switch statement avoids the function call overhead.
552 This function could be moved into `parse_insn_normal', but keeping it
553 separate makes clear the interface between `parse_insn_normal' and each of
554 the handlers. It's also needed by GAS to insert operands that couldn't be
555 resolved during parsing. */
557 const char *
558 frv_cgen_insert_operand (CGEN_CPU_DESC cd,
559 int opindex,
560 CGEN_FIELDS * fields,
561 CGEN_INSN_BYTES_PTR buffer,
562 bfd_vma pc ATTRIBUTE_UNUSED)
564 const char * errmsg = NULL;
565 unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
567 switch (opindex)
569 case FRV_OPERAND_A0 :
570 errmsg = insert_normal (cd, fields->f_A, 0, 0, 17, 1, 32, total_length, buffer);
571 break;
572 case FRV_OPERAND_A1 :
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_LRAD :
712 errmsg = insert_normal (cd, fields->f_LRAD, 0, 0, 4, 1, 32, total_length, buffer);
713 break;
714 case FRV_OPERAND_LRAE :
715 errmsg = insert_normal (cd, fields->f_LRAE, 0, 0, 5, 1, 32, total_length, buffer);
716 break;
717 case FRV_OPERAND_LRAS :
718 errmsg = insert_normal (cd, fields->f_LRAS, 0, 0, 3, 1, 32, total_length, buffer);
719 break;
720 case FRV_OPERAND_TLBPRL :
721 errmsg = insert_normal (cd, fields->f_TLBPRL, 0, 0, 25, 1, 32, total_length, buffer);
722 break;
723 case FRV_OPERAND_TLBPROPX :
724 errmsg = insert_normal (cd, fields->f_TLBPRopx, 0, 0, 28, 3, 32, total_length, buffer);
725 break;
726 case FRV_OPERAND_AE :
727 errmsg = insert_normal (cd, fields->f_ae, 0, 0, 25, 1, 32, total_length, buffer);
728 break;
729 case FRV_OPERAND_CALLANN :
730 errmsg = insert_normal (cd, fields->f_reloc_ann, 0, 0, 0, 0, 32, total_length, buffer);
731 break;
732 case FRV_OPERAND_CCOND :
733 errmsg = insert_normal (cd, fields->f_ccond, 0, 0, 12, 1, 32, total_length, buffer);
734 break;
735 case FRV_OPERAND_COND :
736 errmsg = insert_normal (cd, fields->f_cond, 0, 0, 8, 1, 32, total_length, buffer);
737 break;
738 case FRV_OPERAND_D12 :
739 errmsg = insert_normal (cd, fields->f_d12, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 12, 32, total_length, buffer);
740 break;
741 case FRV_OPERAND_DEBUG :
742 errmsg = insert_normal (cd, fields->f_debug, 0, 0, 25, 1, 32, total_length, buffer);
743 break;
744 case FRV_OPERAND_EIR :
745 errmsg = insert_normal (cd, fields->f_eir, 0, 0, 17, 6, 32, total_length, buffer);
746 break;
747 case FRV_OPERAND_HINT :
748 errmsg = insert_normal (cd, fields->f_hint, 0, 0, 17, 2, 32, total_length, buffer);
749 break;
750 case FRV_OPERAND_HINT_NOT_TAKEN :
751 errmsg = insert_normal (cd, fields->f_hint, 0, 0, 17, 2, 32, total_length, buffer);
752 break;
753 case FRV_OPERAND_HINT_TAKEN :
754 errmsg = insert_normal (cd, fields->f_hint, 0, 0, 17, 2, 32, total_length, buffer);
755 break;
756 case FRV_OPERAND_LABEL16 :
758 long value = fields->f_label16;
759 value = ((SI) (((value) - (pc))) >> (2));
760 errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 15, 16, 32, total_length, buffer);
762 break;
763 case FRV_OPERAND_LABEL24 :
766 FLD (f_labelH6) = ((SI) (((FLD (f_label24)) - (pc))) >> (20));
767 FLD (f_labelL18) = ((((UINT) (((FLD (f_label24)) - (pc))) >> (2))) & (262143));
769 errmsg = insert_normal (cd, fields->f_labelH6, 0|(1<<CGEN_IFLD_SIGNED), 0, 30, 6, 32, total_length, buffer);
770 if (errmsg)
771 break;
772 errmsg = insert_normal (cd, fields->f_labelL18, 0, 0, 17, 18, 32, total_length, buffer);
773 if (errmsg)
774 break;
776 break;
777 case FRV_OPERAND_LDANN :
778 errmsg = insert_normal (cd, fields->f_reloc_ann, 0, 0, 0, 0, 32, total_length, buffer);
779 break;
780 case FRV_OPERAND_LDDANN :
781 errmsg = insert_normal (cd, fields->f_reloc_ann, 0, 0, 0, 0, 32, total_length, buffer);
782 break;
783 case FRV_OPERAND_LOCK :
784 errmsg = insert_normal (cd, fields->f_lock, 0, 0, 25, 1, 32, total_length, buffer);
785 break;
786 case FRV_OPERAND_PACK :
787 errmsg = insert_normal (cd, fields->f_pack, 0, 0, 31, 1, 32, total_length, buffer);
788 break;
789 case FRV_OPERAND_S10 :
790 errmsg = insert_normal (cd, fields->f_s10, 0|(1<<CGEN_IFLD_SIGNED), 0, 9, 10, 32, total_length, buffer);
791 break;
792 case FRV_OPERAND_S12 :
793 errmsg = insert_normal (cd, fields->f_d12, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 12, 32, total_length, buffer);
794 break;
795 case FRV_OPERAND_S16 :
796 errmsg = insert_normal (cd, fields->f_s16, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, buffer);
797 break;
798 case FRV_OPERAND_S5 :
799 errmsg = insert_normal (cd, fields->f_s5, 0|(1<<CGEN_IFLD_SIGNED), 0, 4, 5, 32, total_length, buffer);
800 break;
801 case FRV_OPERAND_S6 :
802 errmsg = insert_normal (cd, fields->f_s6, 0|(1<<CGEN_IFLD_SIGNED), 0, 5, 6, 32, total_length, buffer);
803 break;
804 case FRV_OPERAND_S6_1 :
805 errmsg = insert_normal (cd, fields->f_s6_1, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 6, 32, total_length, buffer);
806 break;
807 case FRV_OPERAND_SLO16 :
808 errmsg = insert_normal (cd, fields->f_s16, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, buffer);
809 break;
810 case FRV_OPERAND_SPR :
813 FLD (f_spr_h) = ((UINT) (FLD (f_spr)) >> (6));
814 FLD (f_spr_l) = ((FLD (f_spr)) & (63));
816 errmsg = insert_normal (cd, fields->f_spr_h, 0, 0, 30, 6, 32, total_length, buffer);
817 if (errmsg)
818 break;
819 errmsg = insert_normal (cd, fields->f_spr_l, 0, 0, 17, 6, 32, total_length, buffer);
820 if (errmsg)
821 break;
823 break;
824 case FRV_OPERAND_U12 :
827 FLD (f_u12_h) = ((SI) (FLD (f_u12)) >> (6));
828 FLD (f_u12_l) = ((FLD (f_u12)) & (63));
830 errmsg = insert_normal (cd, fields->f_u12_h, 0|(1<<CGEN_IFLD_SIGNED), 0, 17, 6, 32, total_length, buffer);
831 if (errmsg)
832 break;
833 errmsg = insert_normal (cd, fields->f_u12_l, 0, 0, 5, 6, 32, total_length, buffer);
834 if (errmsg)
835 break;
837 break;
838 case FRV_OPERAND_U16 :
839 errmsg = insert_normal (cd, fields->f_u16, 0, 0, 15, 16, 32, total_length, buffer);
840 break;
841 case FRV_OPERAND_U6 :
842 errmsg = insert_normal (cd, fields->f_u6, 0, 0, 5, 6, 32, total_length, buffer);
843 break;
844 case FRV_OPERAND_UHI16 :
845 errmsg = insert_normal (cd, fields->f_u16, 0, 0, 15, 16, 32, total_length, buffer);
846 break;
847 case FRV_OPERAND_ULO16 :
848 errmsg = insert_normal (cd, fields->f_u16, 0, 0, 15, 16, 32, total_length, buffer);
849 break;
851 default :
852 /* xgettext:c-format */
853 fprintf (stderr, _("Unrecognized field %d while building insn.\n"),
854 opindex);
855 abort ();
858 return errmsg;
861 int frv_cgen_extract_operand
862 (CGEN_CPU_DESC, int, CGEN_EXTRACT_INFO *, CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma);
864 /* Main entry point for operand extraction.
865 The result is <= 0 for error, >0 for success.
866 ??? Actual values aren't well defined right now.
868 This function is basically just a big switch statement. Earlier versions
869 used tables to look up the function to use, but
870 - if the table contains both assembler and disassembler functions then
871 the disassembler contains much of the assembler and vice-versa,
872 - there's a lot of inlining possibilities as things grow,
873 - using a switch statement avoids the function call overhead.
875 This function could be moved into `print_insn_normal', but keeping it
876 separate makes clear the interface between `print_insn_normal' and each of
877 the handlers. */
880 frv_cgen_extract_operand (CGEN_CPU_DESC cd,
881 int opindex,
882 CGEN_EXTRACT_INFO *ex_info,
883 CGEN_INSN_INT insn_value,
884 CGEN_FIELDS * fields,
885 bfd_vma pc)
887 /* Assume success (for those operands that are nops). */
888 int length = 1;
889 unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
891 switch (opindex)
893 case FRV_OPERAND_A0 :
894 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 1, 32, total_length, pc, & fields->f_A);
895 break;
896 case FRV_OPERAND_A1 :
897 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 1, 32, total_length, pc, & fields->f_A);
898 break;
899 case FRV_OPERAND_ACC40SI :
900 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_ACC40Si);
901 break;
902 case FRV_OPERAND_ACC40SK :
903 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_ACC40Sk);
904 break;
905 case FRV_OPERAND_ACC40UI :
906 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_ACC40Ui);
907 break;
908 case FRV_OPERAND_ACC40UK :
909 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_ACC40Uk);
910 break;
911 case FRV_OPERAND_ACCGI :
912 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_ACCGi);
913 break;
914 case FRV_OPERAND_ACCGK :
915 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_ACCGk);
916 break;
917 case FRV_OPERAND_CCI :
918 length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 3, 32, total_length, pc, & fields->f_CCi);
919 break;
920 case FRV_OPERAND_CPRDOUBLEK :
921 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_CPRk);
922 break;
923 case FRV_OPERAND_CPRI :
924 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_CPRi);
925 break;
926 case FRV_OPERAND_CPRJ :
927 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_CPRj);
928 break;
929 case FRV_OPERAND_CPRK :
930 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_CPRk);
931 break;
932 case FRV_OPERAND_CRI :
933 length = extract_normal (cd, ex_info, insn_value, 0, 0, 14, 3, 32, total_length, pc, & fields->f_CRi);
934 break;
935 case FRV_OPERAND_CRJ :
936 length = extract_normal (cd, ex_info, insn_value, 0, 0, 2, 3, 32, total_length, pc, & fields->f_CRj);
937 break;
938 case FRV_OPERAND_CRJ_FLOAT :
939 length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & fields->f_CRj_float);
940 break;
941 case FRV_OPERAND_CRJ_INT :
943 long value;
944 length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & value);
945 value = ((value) + (4));
946 fields->f_CRj_int = value;
948 break;
949 case FRV_OPERAND_CRK :
950 length = extract_normal (cd, ex_info, insn_value, 0, 0, 27, 3, 32, total_length, pc, & fields->f_CRk);
951 break;
952 case FRV_OPERAND_FCCI_1 :
953 length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 2, 32, total_length, pc, & fields->f_FCCi_1);
954 break;
955 case FRV_OPERAND_FCCI_2 :
956 length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & fields->f_FCCi_2);
957 break;
958 case FRV_OPERAND_FCCI_3 :
959 length = extract_normal (cd, ex_info, insn_value, 0, 0, 1, 2, 32, total_length, pc, & fields->f_FCCi_3);
960 break;
961 case FRV_OPERAND_FCCK :
962 length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & fields->f_FCCk);
963 break;
964 case FRV_OPERAND_FRDOUBLEI :
965 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_FRi);
966 break;
967 case FRV_OPERAND_FRDOUBLEJ :
968 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_FRj);
969 break;
970 case FRV_OPERAND_FRDOUBLEK :
971 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk);
972 break;
973 case FRV_OPERAND_FRI :
974 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_FRi);
975 break;
976 case FRV_OPERAND_FRINTI :
977 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_FRi);
978 break;
979 case FRV_OPERAND_FRINTIEVEN :
980 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_FRi);
981 break;
982 case FRV_OPERAND_FRINTJ :
983 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_FRj);
984 break;
985 case FRV_OPERAND_FRINTJEVEN :
986 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_FRj);
987 break;
988 case FRV_OPERAND_FRINTK :
989 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk);
990 break;
991 case FRV_OPERAND_FRINTKEVEN :
992 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk);
993 break;
994 case FRV_OPERAND_FRJ :
995 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_FRj);
996 break;
997 case FRV_OPERAND_FRK :
998 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk);
999 break;
1000 case FRV_OPERAND_FRKHI :
1001 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk);
1002 break;
1003 case FRV_OPERAND_FRKLO :
1004 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk);
1005 break;
1006 case FRV_OPERAND_GRDOUBLEK :
1007 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_GRk);
1008 break;
1009 case FRV_OPERAND_GRI :
1010 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_GRi);
1011 break;
1012 case FRV_OPERAND_GRJ :
1013 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_GRj);
1014 break;
1015 case FRV_OPERAND_GRK :
1016 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_GRk);
1017 break;
1018 case FRV_OPERAND_GRKHI :
1019 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_GRk);
1020 break;
1021 case FRV_OPERAND_GRKLO :
1022 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_GRk);
1023 break;
1024 case FRV_OPERAND_ICCI_1 :
1025 length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 2, 32, total_length, pc, & fields->f_ICCi_1);
1026 break;
1027 case FRV_OPERAND_ICCI_2 :
1028 length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & fields->f_ICCi_2);
1029 break;
1030 case FRV_OPERAND_ICCI_3 :
1031 length = extract_normal (cd, ex_info, insn_value, 0, 0, 1, 2, 32, total_length, pc, & fields->f_ICCi_3);
1032 break;
1033 case FRV_OPERAND_LI :
1034 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_LI);
1035 break;
1036 case FRV_OPERAND_LRAD :
1037 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 1, 32, total_length, pc, & fields->f_LRAD);
1038 break;
1039 case FRV_OPERAND_LRAE :
1040 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 1, 32, total_length, pc, & fields->f_LRAE);
1041 break;
1042 case FRV_OPERAND_LRAS :
1043 length = extract_normal (cd, ex_info, insn_value, 0, 0, 3, 1, 32, total_length, pc, & fields->f_LRAS);
1044 break;
1045 case FRV_OPERAND_TLBPRL :
1046 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_TLBPRL);
1047 break;
1048 case FRV_OPERAND_TLBPROPX :
1049 length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 3, 32, total_length, pc, & fields->f_TLBPRopx);
1050 break;
1051 case FRV_OPERAND_AE :
1052 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_ae);
1053 break;
1054 case FRV_OPERAND_CALLANN :
1055 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 0, 32, total_length, pc, & fields->f_reloc_ann);
1056 break;
1057 case FRV_OPERAND_CCOND :
1058 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 1, 32, total_length, pc, & fields->f_ccond);
1059 break;
1060 case FRV_OPERAND_COND :
1061 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 1, 32, total_length, pc, & fields->f_cond);
1062 break;
1063 case FRV_OPERAND_D12 :
1064 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 12, 32, total_length, pc, & fields->f_d12);
1065 break;
1066 case FRV_OPERAND_DEBUG :
1067 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_debug);
1068 break;
1069 case FRV_OPERAND_EIR :
1070 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_eir);
1071 break;
1072 case FRV_OPERAND_HINT :
1073 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 2, 32, total_length, pc, & fields->f_hint);
1074 break;
1075 case FRV_OPERAND_HINT_NOT_TAKEN :
1076 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 2, 32, total_length, pc, & fields->f_hint);
1077 break;
1078 case FRV_OPERAND_HINT_TAKEN :
1079 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 2, 32, total_length, pc, & fields->f_hint);
1080 break;
1081 case FRV_OPERAND_LABEL16 :
1083 long value;
1084 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);
1085 value = ((((value) << (2))) + (pc));
1086 fields->f_label16 = value;
1088 break;
1089 case FRV_OPERAND_LABEL24 :
1091 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 30, 6, 32, total_length, pc, & fields->f_labelH6);
1092 if (length <= 0) break;
1093 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 18, 32, total_length, pc, & fields->f_labelL18);
1094 if (length <= 0) break;
1096 FLD (f_label24) = ((((((((FLD (f_labelH6)) << (18))) | (FLD (f_labelL18)))) << (2))) + (pc));
1099 break;
1100 case FRV_OPERAND_LDANN :
1101 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 0, 32, total_length, pc, & fields->f_reloc_ann);
1102 break;
1103 case FRV_OPERAND_LDDANN :
1104 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 0, 32, total_length, pc, & fields->f_reloc_ann);
1105 break;
1106 case FRV_OPERAND_LOCK :
1107 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_lock);
1108 break;
1109 case FRV_OPERAND_PACK :
1110 length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 1, 32, total_length, pc, & fields->f_pack);
1111 break;
1112 case FRV_OPERAND_S10 :
1113 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 9, 10, 32, total_length, pc, & fields->f_s10);
1114 break;
1115 case FRV_OPERAND_S12 :
1116 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 12, 32, total_length, pc, & fields->f_d12);
1117 break;
1118 case FRV_OPERAND_S16 :
1119 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, pc, & fields->f_s16);
1120 break;
1121 case FRV_OPERAND_S5 :
1122 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 4, 5, 32, total_length, pc, & fields->f_s5);
1123 break;
1124 case FRV_OPERAND_S6 :
1125 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 5, 6, 32, total_length, pc, & fields->f_s6);
1126 break;
1127 case FRV_OPERAND_S6_1 :
1128 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 6, 32, total_length, pc, & fields->f_s6_1);
1129 break;
1130 case FRV_OPERAND_SLO16 :
1131 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, pc, & fields->f_s16);
1132 break;
1133 case FRV_OPERAND_SPR :
1135 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_spr_h);
1136 if (length <= 0) break;
1137 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_spr_l);
1138 if (length <= 0) break;
1140 FLD (f_spr) = ((((FLD (f_spr_h)) << (6))) | (FLD (f_spr_l)));
1143 break;
1144 case FRV_OPERAND_U12 :
1146 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 17, 6, 32, total_length, pc, & fields->f_u12_h);
1147 if (length <= 0) break;
1148 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_u12_l);
1149 if (length <= 0) break;
1151 FLD (f_u12) = ((((FLD (f_u12_h)) << (6))) | (FLD (f_u12_l)));
1154 break;
1155 case FRV_OPERAND_U16 :
1156 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_u16);
1157 break;
1158 case FRV_OPERAND_U6 :
1159 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_u6);
1160 break;
1161 case FRV_OPERAND_UHI16 :
1162 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_u16);
1163 break;
1164 case FRV_OPERAND_ULO16 :
1165 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_u16);
1166 break;
1168 default :
1169 /* xgettext:c-format */
1170 fprintf (stderr, _("Unrecognized field %d while decoding insn.\n"),
1171 opindex);
1172 abort ();
1175 return length;
1178 cgen_insert_fn * const frv_cgen_insert_handlers[] =
1180 insert_insn_normal,
1183 cgen_extract_fn * const frv_cgen_extract_handlers[] =
1185 extract_insn_normal,
1188 int frv_cgen_get_int_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *);
1189 bfd_vma frv_cgen_get_vma_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *);
1191 /* Getting values from cgen_fields is handled by a collection of functions.
1192 They are distinguished by the type of the VALUE argument they return.
1193 TODO: floating point, inlining support, remove cases where result type
1194 not appropriate. */
1197 frv_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1198 int opindex,
1199 const CGEN_FIELDS * fields)
1201 int value;
1203 switch (opindex)
1205 case FRV_OPERAND_A0 :
1206 value = fields->f_A;
1207 break;
1208 case FRV_OPERAND_A1 :
1209 value = fields->f_A;
1210 break;
1211 case FRV_OPERAND_ACC40SI :
1212 value = fields->f_ACC40Si;
1213 break;
1214 case FRV_OPERAND_ACC40SK :
1215 value = fields->f_ACC40Sk;
1216 break;
1217 case FRV_OPERAND_ACC40UI :
1218 value = fields->f_ACC40Ui;
1219 break;
1220 case FRV_OPERAND_ACC40UK :
1221 value = fields->f_ACC40Uk;
1222 break;
1223 case FRV_OPERAND_ACCGI :
1224 value = fields->f_ACCGi;
1225 break;
1226 case FRV_OPERAND_ACCGK :
1227 value = fields->f_ACCGk;
1228 break;
1229 case FRV_OPERAND_CCI :
1230 value = fields->f_CCi;
1231 break;
1232 case FRV_OPERAND_CPRDOUBLEK :
1233 value = fields->f_CPRk;
1234 break;
1235 case FRV_OPERAND_CPRI :
1236 value = fields->f_CPRi;
1237 break;
1238 case FRV_OPERAND_CPRJ :
1239 value = fields->f_CPRj;
1240 break;
1241 case FRV_OPERAND_CPRK :
1242 value = fields->f_CPRk;
1243 break;
1244 case FRV_OPERAND_CRI :
1245 value = fields->f_CRi;
1246 break;
1247 case FRV_OPERAND_CRJ :
1248 value = fields->f_CRj;
1249 break;
1250 case FRV_OPERAND_CRJ_FLOAT :
1251 value = fields->f_CRj_float;
1252 break;
1253 case FRV_OPERAND_CRJ_INT :
1254 value = fields->f_CRj_int;
1255 break;
1256 case FRV_OPERAND_CRK :
1257 value = fields->f_CRk;
1258 break;
1259 case FRV_OPERAND_FCCI_1 :
1260 value = fields->f_FCCi_1;
1261 break;
1262 case FRV_OPERAND_FCCI_2 :
1263 value = fields->f_FCCi_2;
1264 break;
1265 case FRV_OPERAND_FCCI_3 :
1266 value = fields->f_FCCi_3;
1267 break;
1268 case FRV_OPERAND_FCCK :
1269 value = fields->f_FCCk;
1270 break;
1271 case FRV_OPERAND_FRDOUBLEI :
1272 value = fields->f_FRi;
1273 break;
1274 case FRV_OPERAND_FRDOUBLEJ :
1275 value = fields->f_FRj;
1276 break;
1277 case FRV_OPERAND_FRDOUBLEK :
1278 value = fields->f_FRk;
1279 break;
1280 case FRV_OPERAND_FRI :
1281 value = fields->f_FRi;
1282 break;
1283 case FRV_OPERAND_FRINTI :
1284 value = fields->f_FRi;
1285 break;
1286 case FRV_OPERAND_FRINTIEVEN :
1287 value = fields->f_FRi;
1288 break;
1289 case FRV_OPERAND_FRINTJ :
1290 value = fields->f_FRj;
1291 break;
1292 case FRV_OPERAND_FRINTJEVEN :
1293 value = fields->f_FRj;
1294 break;
1295 case FRV_OPERAND_FRINTK :
1296 value = fields->f_FRk;
1297 break;
1298 case FRV_OPERAND_FRINTKEVEN :
1299 value = fields->f_FRk;
1300 break;
1301 case FRV_OPERAND_FRJ :
1302 value = fields->f_FRj;
1303 break;
1304 case FRV_OPERAND_FRK :
1305 value = fields->f_FRk;
1306 break;
1307 case FRV_OPERAND_FRKHI :
1308 value = fields->f_FRk;
1309 break;
1310 case FRV_OPERAND_FRKLO :
1311 value = fields->f_FRk;
1312 break;
1313 case FRV_OPERAND_GRDOUBLEK :
1314 value = fields->f_GRk;
1315 break;
1316 case FRV_OPERAND_GRI :
1317 value = fields->f_GRi;
1318 break;
1319 case FRV_OPERAND_GRJ :
1320 value = fields->f_GRj;
1321 break;
1322 case FRV_OPERAND_GRK :
1323 value = fields->f_GRk;
1324 break;
1325 case FRV_OPERAND_GRKHI :
1326 value = fields->f_GRk;
1327 break;
1328 case FRV_OPERAND_GRKLO :
1329 value = fields->f_GRk;
1330 break;
1331 case FRV_OPERAND_ICCI_1 :
1332 value = fields->f_ICCi_1;
1333 break;
1334 case FRV_OPERAND_ICCI_2 :
1335 value = fields->f_ICCi_2;
1336 break;
1337 case FRV_OPERAND_ICCI_3 :
1338 value = fields->f_ICCi_3;
1339 break;
1340 case FRV_OPERAND_LI :
1341 value = fields->f_LI;
1342 break;
1343 case FRV_OPERAND_LRAD :
1344 value = fields->f_LRAD;
1345 break;
1346 case FRV_OPERAND_LRAE :
1347 value = fields->f_LRAE;
1348 break;
1349 case FRV_OPERAND_LRAS :
1350 value = fields->f_LRAS;
1351 break;
1352 case FRV_OPERAND_TLBPRL :
1353 value = fields->f_TLBPRL;
1354 break;
1355 case FRV_OPERAND_TLBPROPX :
1356 value = fields->f_TLBPRopx;
1357 break;
1358 case FRV_OPERAND_AE :
1359 value = fields->f_ae;
1360 break;
1361 case FRV_OPERAND_CALLANN :
1362 value = fields->f_reloc_ann;
1363 break;
1364 case FRV_OPERAND_CCOND :
1365 value = fields->f_ccond;
1366 break;
1367 case FRV_OPERAND_COND :
1368 value = fields->f_cond;
1369 break;
1370 case FRV_OPERAND_D12 :
1371 value = fields->f_d12;
1372 break;
1373 case FRV_OPERAND_DEBUG :
1374 value = fields->f_debug;
1375 break;
1376 case FRV_OPERAND_EIR :
1377 value = fields->f_eir;
1378 break;
1379 case FRV_OPERAND_HINT :
1380 value = fields->f_hint;
1381 break;
1382 case FRV_OPERAND_HINT_NOT_TAKEN :
1383 value = fields->f_hint;
1384 break;
1385 case FRV_OPERAND_HINT_TAKEN :
1386 value = fields->f_hint;
1387 break;
1388 case FRV_OPERAND_LABEL16 :
1389 value = fields->f_label16;
1390 break;
1391 case FRV_OPERAND_LABEL24 :
1392 value = fields->f_label24;
1393 break;
1394 case FRV_OPERAND_LDANN :
1395 value = fields->f_reloc_ann;
1396 break;
1397 case FRV_OPERAND_LDDANN :
1398 value = fields->f_reloc_ann;
1399 break;
1400 case FRV_OPERAND_LOCK :
1401 value = fields->f_lock;
1402 break;
1403 case FRV_OPERAND_PACK :
1404 value = fields->f_pack;
1405 break;
1406 case FRV_OPERAND_S10 :
1407 value = fields->f_s10;
1408 break;
1409 case FRV_OPERAND_S12 :
1410 value = fields->f_d12;
1411 break;
1412 case FRV_OPERAND_S16 :
1413 value = fields->f_s16;
1414 break;
1415 case FRV_OPERAND_S5 :
1416 value = fields->f_s5;
1417 break;
1418 case FRV_OPERAND_S6 :
1419 value = fields->f_s6;
1420 break;
1421 case FRV_OPERAND_S6_1 :
1422 value = fields->f_s6_1;
1423 break;
1424 case FRV_OPERAND_SLO16 :
1425 value = fields->f_s16;
1426 break;
1427 case FRV_OPERAND_SPR :
1428 value = fields->f_spr;
1429 break;
1430 case FRV_OPERAND_U12 :
1431 value = fields->f_u12;
1432 break;
1433 case FRV_OPERAND_U16 :
1434 value = fields->f_u16;
1435 break;
1436 case FRV_OPERAND_U6 :
1437 value = fields->f_u6;
1438 break;
1439 case FRV_OPERAND_UHI16 :
1440 value = fields->f_u16;
1441 break;
1442 case FRV_OPERAND_ULO16 :
1443 value = fields->f_u16;
1444 break;
1446 default :
1447 /* xgettext:c-format */
1448 fprintf (stderr, _("Unrecognized field %d while getting int operand.\n"),
1449 opindex);
1450 abort ();
1453 return value;
1456 bfd_vma
1457 frv_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1458 int opindex,
1459 const CGEN_FIELDS * fields)
1461 bfd_vma value;
1463 switch (opindex)
1465 case FRV_OPERAND_A0 :
1466 value = fields->f_A;
1467 break;
1468 case FRV_OPERAND_A1 :
1469 value = fields->f_A;
1470 break;
1471 case FRV_OPERAND_ACC40SI :
1472 value = fields->f_ACC40Si;
1473 break;
1474 case FRV_OPERAND_ACC40SK :
1475 value = fields->f_ACC40Sk;
1476 break;
1477 case FRV_OPERAND_ACC40UI :
1478 value = fields->f_ACC40Ui;
1479 break;
1480 case FRV_OPERAND_ACC40UK :
1481 value = fields->f_ACC40Uk;
1482 break;
1483 case FRV_OPERAND_ACCGI :
1484 value = fields->f_ACCGi;
1485 break;
1486 case FRV_OPERAND_ACCGK :
1487 value = fields->f_ACCGk;
1488 break;
1489 case FRV_OPERAND_CCI :
1490 value = fields->f_CCi;
1491 break;
1492 case FRV_OPERAND_CPRDOUBLEK :
1493 value = fields->f_CPRk;
1494 break;
1495 case FRV_OPERAND_CPRI :
1496 value = fields->f_CPRi;
1497 break;
1498 case FRV_OPERAND_CPRJ :
1499 value = fields->f_CPRj;
1500 break;
1501 case FRV_OPERAND_CPRK :
1502 value = fields->f_CPRk;
1503 break;
1504 case FRV_OPERAND_CRI :
1505 value = fields->f_CRi;
1506 break;
1507 case FRV_OPERAND_CRJ :
1508 value = fields->f_CRj;
1509 break;
1510 case FRV_OPERAND_CRJ_FLOAT :
1511 value = fields->f_CRj_float;
1512 break;
1513 case FRV_OPERAND_CRJ_INT :
1514 value = fields->f_CRj_int;
1515 break;
1516 case FRV_OPERAND_CRK :
1517 value = fields->f_CRk;
1518 break;
1519 case FRV_OPERAND_FCCI_1 :
1520 value = fields->f_FCCi_1;
1521 break;
1522 case FRV_OPERAND_FCCI_2 :
1523 value = fields->f_FCCi_2;
1524 break;
1525 case FRV_OPERAND_FCCI_3 :
1526 value = fields->f_FCCi_3;
1527 break;
1528 case FRV_OPERAND_FCCK :
1529 value = fields->f_FCCk;
1530 break;
1531 case FRV_OPERAND_FRDOUBLEI :
1532 value = fields->f_FRi;
1533 break;
1534 case FRV_OPERAND_FRDOUBLEJ :
1535 value = fields->f_FRj;
1536 break;
1537 case FRV_OPERAND_FRDOUBLEK :
1538 value = fields->f_FRk;
1539 break;
1540 case FRV_OPERAND_FRI :
1541 value = fields->f_FRi;
1542 break;
1543 case FRV_OPERAND_FRINTI :
1544 value = fields->f_FRi;
1545 break;
1546 case FRV_OPERAND_FRINTIEVEN :
1547 value = fields->f_FRi;
1548 break;
1549 case FRV_OPERAND_FRINTJ :
1550 value = fields->f_FRj;
1551 break;
1552 case FRV_OPERAND_FRINTJEVEN :
1553 value = fields->f_FRj;
1554 break;
1555 case FRV_OPERAND_FRINTK :
1556 value = fields->f_FRk;
1557 break;
1558 case FRV_OPERAND_FRINTKEVEN :
1559 value = fields->f_FRk;
1560 break;
1561 case FRV_OPERAND_FRJ :
1562 value = fields->f_FRj;
1563 break;
1564 case FRV_OPERAND_FRK :
1565 value = fields->f_FRk;
1566 break;
1567 case FRV_OPERAND_FRKHI :
1568 value = fields->f_FRk;
1569 break;
1570 case FRV_OPERAND_FRKLO :
1571 value = fields->f_FRk;
1572 break;
1573 case FRV_OPERAND_GRDOUBLEK :
1574 value = fields->f_GRk;
1575 break;
1576 case FRV_OPERAND_GRI :
1577 value = fields->f_GRi;
1578 break;
1579 case FRV_OPERAND_GRJ :
1580 value = fields->f_GRj;
1581 break;
1582 case FRV_OPERAND_GRK :
1583 value = fields->f_GRk;
1584 break;
1585 case FRV_OPERAND_GRKHI :
1586 value = fields->f_GRk;
1587 break;
1588 case FRV_OPERAND_GRKLO :
1589 value = fields->f_GRk;
1590 break;
1591 case FRV_OPERAND_ICCI_1 :
1592 value = fields->f_ICCi_1;
1593 break;
1594 case FRV_OPERAND_ICCI_2 :
1595 value = fields->f_ICCi_2;
1596 break;
1597 case FRV_OPERAND_ICCI_3 :
1598 value = fields->f_ICCi_3;
1599 break;
1600 case FRV_OPERAND_LI :
1601 value = fields->f_LI;
1602 break;
1603 case FRV_OPERAND_LRAD :
1604 value = fields->f_LRAD;
1605 break;
1606 case FRV_OPERAND_LRAE :
1607 value = fields->f_LRAE;
1608 break;
1609 case FRV_OPERAND_LRAS :
1610 value = fields->f_LRAS;
1611 break;
1612 case FRV_OPERAND_TLBPRL :
1613 value = fields->f_TLBPRL;
1614 break;
1615 case FRV_OPERAND_TLBPROPX :
1616 value = fields->f_TLBPRopx;
1617 break;
1618 case FRV_OPERAND_AE :
1619 value = fields->f_ae;
1620 break;
1621 case FRV_OPERAND_CALLANN :
1622 value = fields->f_reloc_ann;
1623 break;
1624 case FRV_OPERAND_CCOND :
1625 value = fields->f_ccond;
1626 break;
1627 case FRV_OPERAND_COND :
1628 value = fields->f_cond;
1629 break;
1630 case FRV_OPERAND_D12 :
1631 value = fields->f_d12;
1632 break;
1633 case FRV_OPERAND_DEBUG :
1634 value = fields->f_debug;
1635 break;
1636 case FRV_OPERAND_EIR :
1637 value = fields->f_eir;
1638 break;
1639 case FRV_OPERAND_HINT :
1640 value = fields->f_hint;
1641 break;
1642 case FRV_OPERAND_HINT_NOT_TAKEN :
1643 value = fields->f_hint;
1644 break;
1645 case FRV_OPERAND_HINT_TAKEN :
1646 value = fields->f_hint;
1647 break;
1648 case FRV_OPERAND_LABEL16 :
1649 value = fields->f_label16;
1650 break;
1651 case FRV_OPERAND_LABEL24 :
1652 value = fields->f_label24;
1653 break;
1654 case FRV_OPERAND_LDANN :
1655 value = fields->f_reloc_ann;
1656 break;
1657 case FRV_OPERAND_LDDANN :
1658 value = fields->f_reloc_ann;
1659 break;
1660 case FRV_OPERAND_LOCK :
1661 value = fields->f_lock;
1662 break;
1663 case FRV_OPERAND_PACK :
1664 value = fields->f_pack;
1665 break;
1666 case FRV_OPERAND_S10 :
1667 value = fields->f_s10;
1668 break;
1669 case FRV_OPERAND_S12 :
1670 value = fields->f_d12;
1671 break;
1672 case FRV_OPERAND_S16 :
1673 value = fields->f_s16;
1674 break;
1675 case FRV_OPERAND_S5 :
1676 value = fields->f_s5;
1677 break;
1678 case FRV_OPERAND_S6 :
1679 value = fields->f_s6;
1680 break;
1681 case FRV_OPERAND_S6_1 :
1682 value = fields->f_s6_1;
1683 break;
1684 case FRV_OPERAND_SLO16 :
1685 value = fields->f_s16;
1686 break;
1687 case FRV_OPERAND_SPR :
1688 value = fields->f_spr;
1689 break;
1690 case FRV_OPERAND_U12 :
1691 value = fields->f_u12;
1692 break;
1693 case FRV_OPERAND_U16 :
1694 value = fields->f_u16;
1695 break;
1696 case FRV_OPERAND_U6 :
1697 value = fields->f_u6;
1698 break;
1699 case FRV_OPERAND_UHI16 :
1700 value = fields->f_u16;
1701 break;
1702 case FRV_OPERAND_ULO16 :
1703 value = fields->f_u16;
1704 break;
1706 default :
1707 /* xgettext:c-format */
1708 fprintf (stderr, _("Unrecognized field %d while getting vma operand.\n"),
1709 opindex);
1710 abort ();
1713 return value;
1716 void frv_cgen_set_int_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, int);
1717 void frv_cgen_set_vma_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, bfd_vma);
1719 /* Stuffing values in cgen_fields is handled by a collection of functions.
1720 They are distinguished by the type of the VALUE argument they accept.
1721 TODO: floating point, inlining support, remove cases where argument type
1722 not appropriate. */
1724 void
1725 frv_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1726 int opindex,
1727 CGEN_FIELDS * fields,
1728 int value)
1730 switch (opindex)
1732 case FRV_OPERAND_A0 :
1733 fields->f_A = value;
1734 break;
1735 case FRV_OPERAND_A1 :
1736 fields->f_A = value;
1737 break;
1738 case FRV_OPERAND_ACC40SI :
1739 fields->f_ACC40Si = value;
1740 break;
1741 case FRV_OPERAND_ACC40SK :
1742 fields->f_ACC40Sk = value;
1743 break;
1744 case FRV_OPERAND_ACC40UI :
1745 fields->f_ACC40Ui = value;
1746 break;
1747 case FRV_OPERAND_ACC40UK :
1748 fields->f_ACC40Uk = value;
1749 break;
1750 case FRV_OPERAND_ACCGI :
1751 fields->f_ACCGi = value;
1752 break;
1753 case FRV_OPERAND_ACCGK :
1754 fields->f_ACCGk = value;
1755 break;
1756 case FRV_OPERAND_CCI :
1757 fields->f_CCi = value;
1758 break;
1759 case FRV_OPERAND_CPRDOUBLEK :
1760 fields->f_CPRk = value;
1761 break;
1762 case FRV_OPERAND_CPRI :
1763 fields->f_CPRi = value;
1764 break;
1765 case FRV_OPERAND_CPRJ :
1766 fields->f_CPRj = value;
1767 break;
1768 case FRV_OPERAND_CPRK :
1769 fields->f_CPRk = value;
1770 break;
1771 case FRV_OPERAND_CRI :
1772 fields->f_CRi = value;
1773 break;
1774 case FRV_OPERAND_CRJ :
1775 fields->f_CRj = value;
1776 break;
1777 case FRV_OPERAND_CRJ_FLOAT :
1778 fields->f_CRj_float = value;
1779 break;
1780 case FRV_OPERAND_CRJ_INT :
1781 fields->f_CRj_int = value;
1782 break;
1783 case FRV_OPERAND_CRK :
1784 fields->f_CRk = value;
1785 break;
1786 case FRV_OPERAND_FCCI_1 :
1787 fields->f_FCCi_1 = value;
1788 break;
1789 case FRV_OPERAND_FCCI_2 :
1790 fields->f_FCCi_2 = value;
1791 break;
1792 case FRV_OPERAND_FCCI_3 :
1793 fields->f_FCCi_3 = value;
1794 break;
1795 case FRV_OPERAND_FCCK :
1796 fields->f_FCCk = value;
1797 break;
1798 case FRV_OPERAND_FRDOUBLEI :
1799 fields->f_FRi = value;
1800 break;
1801 case FRV_OPERAND_FRDOUBLEJ :
1802 fields->f_FRj = value;
1803 break;
1804 case FRV_OPERAND_FRDOUBLEK :
1805 fields->f_FRk = value;
1806 break;
1807 case FRV_OPERAND_FRI :
1808 fields->f_FRi = value;
1809 break;
1810 case FRV_OPERAND_FRINTI :
1811 fields->f_FRi = value;
1812 break;
1813 case FRV_OPERAND_FRINTIEVEN :
1814 fields->f_FRi = value;
1815 break;
1816 case FRV_OPERAND_FRINTJ :
1817 fields->f_FRj = value;
1818 break;
1819 case FRV_OPERAND_FRINTJEVEN :
1820 fields->f_FRj = value;
1821 break;
1822 case FRV_OPERAND_FRINTK :
1823 fields->f_FRk = value;
1824 break;
1825 case FRV_OPERAND_FRINTKEVEN :
1826 fields->f_FRk = value;
1827 break;
1828 case FRV_OPERAND_FRJ :
1829 fields->f_FRj = value;
1830 break;
1831 case FRV_OPERAND_FRK :
1832 fields->f_FRk = value;
1833 break;
1834 case FRV_OPERAND_FRKHI :
1835 fields->f_FRk = value;
1836 break;
1837 case FRV_OPERAND_FRKLO :
1838 fields->f_FRk = value;
1839 break;
1840 case FRV_OPERAND_GRDOUBLEK :
1841 fields->f_GRk = value;
1842 break;
1843 case FRV_OPERAND_GRI :
1844 fields->f_GRi = value;
1845 break;
1846 case FRV_OPERAND_GRJ :
1847 fields->f_GRj = value;
1848 break;
1849 case FRV_OPERAND_GRK :
1850 fields->f_GRk = value;
1851 break;
1852 case FRV_OPERAND_GRKHI :
1853 fields->f_GRk = value;
1854 break;
1855 case FRV_OPERAND_GRKLO :
1856 fields->f_GRk = value;
1857 break;
1858 case FRV_OPERAND_ICCI_1 :
1859 fields->f_ICCi_1 = value;
1860 break;
1861 case FRV_OPERAND_ICCI_2 :
1862 fields->f_ICCi_2 = value;
1863 break;
1864 case FRV_OPERAND_ICCI_3 :
1865 fields->f_ICCi_3 = value;
1866 break;
1867 case FRV_OPERAND_LI :
1868 fields->f_LI = value;
1869 break;
1870 case FRV_OPERAND_LRAD :
1871 fields->f_LRAD = value;
1872 break;
1873 case FRV_OPERAND_LRAE :
1874 fields->f_LRAE = value;
1875 break;
1876 case FRV_OPERAND_LRAS :
1877 fields->f_LRAS = value;
1878 break;
1879 case FRV_OPERAND_TLBPRL :
1880 fields->f_TLBPRL = value;
1881 break;
1882 case FRV_OPERAND_TLBPROPX :
1883 fields->f_TLBPRopx = value;
1884 break;
1885 case FRV_OPERAND_AE :
1886 fields->f_ae = value;
1887 break;
1888 case FRV_OPERAND_CALLANN :
1889 fields->f_reloc_ann = value;
1890 break;
1891 case FRV_OPERAND_CCOND :
1892 fields->f_ccond = value;
1893 break;
1894 case FRV_OPERAND_COND :
1895 fields->f_cond = value;
1896 break;
1897 case FRV_OPERAND_D12 :
1898 fields->f_d12 = value;
1899 break;
1900 case FRV_OPERAND_DEBUG :
1901 fields->f_debug = value;
1902 break;
1903 case FRV_OPERAND_EIR :
1904 fields->f_eir = value;
1905 break;
1906 case FRV_OPERAND_HINT :
1907 fields->f_hint = value;
1908 break;
1909 case FRV_OPERAND_HINT_NOT_TAKEN :
1910 fields->f_hint = value;
1911 break;
1912 case FRV_OPERAND_HINT_TAKEN :
1913 fields->f_hint = value;
1914 break;
1915 case FRV_OPERAND_LABEL16 :
1916 fields->f_label16 = value;
1917 break;
1918 case FRV_OPERAND_LABEL24 :
1919 fields->f_label24 = value;
1920 break;
1921 case FRV_OPERAND_LDANN :
1922 fields->f_reloc_ann = value;
1923 break;
1924 case FRV_OPERAND_LDDANN :
1925 fields->f_reloc_ann = value;
1926 break;
1927 case FRV_OPERAND_LOCK :
1928 fields->f_lock = value;
1929 break;
1930 case FRV_OPERAND_PACK :
1931 fields->f_pack = value;
1932 break;
1933 case FRV_OPERAND_S10 :
1934 fields->f_s10 = value;
1935 break;
1936 case FRV_OPERAND_S12 :
1937 fields->f_d12 = value;
1938 break;
1939 case FRV_OPERAND_S16 :
1940 fields->f_s16 = value;
1941 break;
1942 case FRV_OPERAND_S5 :
1943 fields->f_s5 = value;
1944 break;
1945 case FRV_OPERAND_S6 :
1946 fields->f_s6 = value;
1947 break;
1948 case FRV_OPERAND_S6_1 :
1949 fields->f_s6_1 = value;
1950 break;
1951 case FRV_OPERAND_SLO16 :
1952 fields->f_s16 = value;
1953 break;
1954 case FRV_OPERAND_SPR :
1955 fields->f_spr = value;
1956 break;
1957 case FRV_OPERAND_U12 :
1958 fields->f_u12 = value;
1959 break;
1960 case FRV_OPERAND_U16 :
1961 fields->f_u16 = value;
1962 break;
1963 case FRV_OPERAND_U6 :
1964 fields->f_u6 = value;
1965 break;
1966 case FRV_OPERAND_UHI16 :
1967 fields->f_u16 = value;
1968 break;
1969 case FRV_OPERAND_ULO16 :
1970 fields->f_u16 = value;
1971 break;
1973 default :
1974 /* xgettext:c-format */
1975 fprintf (stderr, _("Unrecognized field %d while setting int operand.\n"),
1976 opindex);
1977 abort ();
1981 void
1982 frv_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1983 int opindex,
1984 CGEN_FIELDS * fields,
1985 bfd_vma value)
1987 switch (opindex)
1989 case FRV_OPERAND_A0 :
1990 fields->f_A = value;
1991 break;
1992 case FRV_OPERAND_A1 :
1993 fields->f_A = value;
1994 break;
1995 case FRV_OPERAND_ACC40SI :
1996 fields->f_ACC40Si = value;
1997 break;
1998 case FRV_OPERAND_ACC40SK :
1999 fields->f_ACC40Sk = value;
2000 break;
2001 case FRV_OPERAND_ACC40UI :
2002 fields->f_ACC40Ui = value;
2003 break;
2004 case FRV_OPERAND_ACC40UK :
2005 fields->f_ACC40Uk = value;
2006 break;
2007 case FRV_OPERAND_ACCGI :
2008 fields->f_ACCGi = value;
2009 break;
2010 case FRV_OPERAND_ACCGK :
2011 fields->f_ACCGk = value;
2012 break;
2013 case FRV_OPERAND_CCI :
2014 fields->f_CCi = value;
2015 break;
2016 case FRV_OPERAND_CPRDOUBLEK :
2017 fields->f_CPRk = value;
2018 break;
2019 case FRV_OPERAND_CPRI :
2020 fields->f_CPRi = value;
2021 break;
2022 case FRV_OPERAND_CPRJ :
2023 fields->f_CPRj = value;
2024 break;
2025 case FRV_OPERAND_CPRK :
2026 fields->f_CPRk = value;
2027 break;
2028 case FRV_OPERAND_CRI :
2029 fields->f_CRi = value;
2030 break;
2031 case FRV_OPERAND_CRJ :
2032 fields->f_CRj = value;
2033 break;
2034 case FRV_OPERAND_CRJ_FLOAT :
2035 fields->f_CRj_float = value;
2036 break;
2037 case FRV_OPERAND_CRJ_INT :
2038 fields->f_CRj_int = value;
2039 break;
2040 case FRV_OPERAND_CRK :
2041 fields->f_CRk = value;
2042 break;
2043 case FRV_OPERAND_FCCI_1 :
2044 fields->f_FCCi_1 = value;
2045 break;
2046 case FRV_OPERAND_FCCI_2 :
2047 fields->f_FCCi_2 = value;
2048 break;
2049 case FRV_OPERAND_FCCI_3 :
2050 fields->f_FCCi_3 = value;
2051 break;
2052 case FRV_OPERAND_FCCK :
2053 fields->f_FCCk = value;
2054 break;
2055 case FRV_OPERAND_FRDOUBLEI :
2056 fields->f_FRi = value;
2057 break;
2058 case FRV_OPERAND_FRDOUBLEJ :
2059 fields->f_FRj = value;
2060 break;
2061 case FRV_OPERAND_FRDOUBLEK :
2062 fields->f_FRk = value;
2063 break;
2064 case FRV_OPERAND_FRI :
2065 fields->f_FRi = value;
2066 break;
2067 case FRV_OPERAND_FRINTI :
2068 fields->f_FRi = value;
2069 break;
2070 case FRV_OPERAND_FRINTIEVEN :
2071 fields->f_FRi = value;
2072 break;
2073 case FRV_OPERAND_FRINTJ :
2074 fields->f_FRj = value;
2075 break;
2076 case FRV_OPERAND_FRINTJEVEN :
2077 fields->f_FRj = value;
2078 break;
2079 case FRV_OPERAND_FRINTK :
2080 fields->f_FRk = value;
2081 break;
2082 case FRV_OPERAND_FRINTKEVEN :
2083 fields->f_FRk = value;
2084 break;
2085 case FRV_OPERAND_FRJ :
2086 fields->f_FRj = value;
2087 break;
2088 case FRV_OPERAND_FRK :
2089 fields->f_FRk = value;
2090 break;
2091 case FRV_OPERAND_FRKHI :
2092 fields->f_FRk = value;
2093 break;
2094 case FRV_OPERAND_FRKLO :
2095 fields->f_FRk = value;
2096 break;
2097 case FRV_OPERAND_GRDOUBLEK :
2098 fields->f_GRk = value;
2099 break;
2100 case FRV_OPERAND_GRI :
2101 fields->f_GRi = value;
2102 break;
2103 case FRV_OPERAND_GRJ :
2104 fields->f_GRj = value;
2105 break;
2106 case FRV_OPERAND_GRK :
2107 fields->f_GRk = value;
2108 break;
2109 case FRV_OPERAND_GRKHI :
2110 fields->f_GRk = value;
2111 break;
2112 case FRV_OPERAND_GRKLO :
2113 fields->f_GRk = value;
2114 break;
2115 case FRV_OPERAND_ICCI_1 :
2116 fields->f_ICCi_1 = value;
2117 break;
2118 case FRV_OPERAND_ICCI_2 :
2119 fields->f_ICCi_2 = value;
2120 break;
2121 case FRV_OPERAND_ICCI_3 :
2122 fields->f_ICCi_3 = value;
2123 break;
2124 case FRV_OPERAND_LI :
2125 fields->f_LI = value;
2126 break;
2127 case FRV_OPERAND_LRAD :
2128 fields->f_LRAD = value;
2129 break;
2130 case FRV_OPERAND_LRAE :
2131 fields->f_LRAE = value;
2132 break;
2133 case FRV_OPERAND_LRAS :
2134 fields->f_LRAS = value;
2135 break;
2136 case FRV_OPERAND_TLBPRL :
2137 fields->f_TLBPRL = value;
2138 break;
2139 case FRV_OPERAND_TLBPROPX :
2140 fields->f_TLBPRopx = value;
2141 break;
2142 case FRV_OPERAND_AE :
2143 fields->f_ae = value;
2144 break;
2145 case FRV_OPERAND_CALLANN :
2146 fields->f_reloc_ann = value;
2147 break;
2148 case FRV_OPERAND_CCOND :
2149 fields->f_ccond = value;
2150 break;
2151 case FRV_OPERAND_COND :
2152 fields->f_cond = value;
2153 break;
2154 case FRV_OPERAND_D12 :
2155 fields->f_d12 = value;
2156 break;
2157 case FRV_OPERAND_DEBUG :
2158 fields->f_debug = value;
2159 break;
2160 case FRV_OPERAND_EIR :
2161 fields->f_eir = value;
2162 break;
2163 case FRV_OPERAND_HINT :
2164 fields->f_hint = value;
2165 break;
2166 case FRV_OPERAND_HINT_NOT_TAKEN :
2167 fields->f_hint = value;
2168 break;
2169 case FRV_OPERAND_HINT_TAKEN :
2170 fields->f_hint = value;
2171 break;
2172 case FRV_OPERAND_LABEL16 :
2173 fields->f_label16 = value;
2174 break;
2175 case FRV_OPERAND_LABEL24 :
2176 fields->f_label24 = value;
2177 break;
2178 case FRV_OPERAND_LDANN :
2179 fields->f_reloc_ann = value;
2180 break;
2181 case FRV_OPERAND_LDDANN :
2182 fields->f_reloc_ann = value;
2183 break;
2184 case FRV_OPERAND_LOCK :
2185 fields->f_lock = value;
2186 break;
2187 case FRV_OPERAND_PACK :
2188 fields->f_pack = value;
2189 break;
2190 case FRV_OPERAND_S10 :
2191 fields->f_s10 = value;
2192 break;
2193 case FRV_OPERAND_S12 :
2194 fields->f_d12 = value;
2195 break;
2196 case FRV_OPERAND_S16 :
2197 fields->f_s16 = value;
2198 break;
2199 case FRV_OPERAND_S5 :
2200 fields->f_s5 = value;
2201 break;
2202 case FRV_OPERAND_S6 :
2203 fields->f_s6 = value;
2204 break;
2205 case FRV_OPERAND_S6_1 :
2206 fields->f_s6_1 = value;
2207 break;
2208 case FRV_OPERAND_SLO16 :
2209 fields->f_s16 = value;
2210 break;
2211 case FRV_OPERAND_SPR :
2212 fields->f_spr = value;
2213 break;
2214 case FRV_OPERAND_U12 :
2215 fields->f_u12 = value;
2216 break;
2217 case FRV_OPERAND_U16 :
2218 fields->f_u16 = value;
2219 break;
2220 case FRV_OPERAND_U6 :
2221 fields->f_u6 = value;
2222 break;
2223 case FRV_OPERAND_UHI16 :
2224 fields->f_u16 = value;
2225 break;
2226 case FRV_OPERAND_ULO16 :
2227 fields->f_u16 = value;
2228 break;
2230 default :
2231 /* xgettext:c-format */
2232 fprintf (stderr, _("Unrecognized field %d while setting vma operand.\n"),
2233 opindex);
2234 abort ();
2238 /* Function to call before using the instruction builder tables. */
2240 void
2241 frv_cgen_init_ibld_table (CGEN_CPU_DESC cd)
2243 cd->insert_handlers = & frv_cgen_insert_handlers[0];
2244 cd->extract_handlers = & frv_cgen_extract_handlers[0];
2246 cd->insert_operand = frv_cgen_insert_operand;
2247 cd->extract_operand = frv_cgen_extract_operand;
2249 cd->get_int_operand = frv_cgen_get_int_operand;
2250 cd->set_int_operand = frv_cgen_set_int_operand;
2251 cd->get_vma_operand = frv_cgen_get_vma_operand;
2252 cd->set_vma_operand = frv_cgen_set_vma_operand;