1 /* Instruction building/extraction support for epiphany. -*- 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)
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.
34 #include "epiphany-desc.h"
35 #include "epiphany-opc.h"
36 #include "cgen/basic-modes.h"
38 #include "safe-ctype.h"
41 #define min(a,b) ((a) < (b) ? (a) : (b))
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);
62 static void put_insn_int_value
63 (CGEN_CPU_DESC, CGEN_INSN_BYTES_PTR, int, int, CGEN_INSN_INT);
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);
74 /* Operand insertion. */
78 /* Subroutine of insert_normal. */
80 static CGEN_INLINE void
81 insert_1 (CGEN_CPU_DESC cd,
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;
96 shift = (start + 1) - length;
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
123 insert_normal (CGEN_CPU_DESC cd,
126 unsigned int word_offset,
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. */
141 if (word_length > 8 * sizeof (CGEN_INSN_INT))
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)
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)
162 /* xgettext:c-format */
164 _("operand out of range (%ld not between %ld and %lu)"),
165 value, minval, maxval);
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))
183 /* xgettext:c-format */
185 _("operand out of range (0x%lx not between 0 and 0x%lx)"),
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)
200 /* xgettext:c-format */
201 (errbuf, _("operand out of range (%ld not between %ld and %ld)"),
202 value, minval, maxval);
213 if (CGEN_INSN_LSB0_P)
214 shift = (word_offset + start + 1) - length;
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 */
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. */
241 insert_insn_normal (CGEN_CPU_DESC cd,
242 const CGEN_INSN * insn,
243 CGEN_FIELDS * fields,
244 CGEN_INSN_BYTES_PTR buffer,
247 const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
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. */
259 put_insn_int_value (cd, buffer, cd->base_insn_bitsize,
260 CGEN_FIELDS_BITSIZE (fields), value);
264 cgen_put_insn_value (cd, buffer, min ((unsigned) cd->base_insn_bitsize,
265 (unsigned) CGEN_FIELDS_BITSIZE (fields)),
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)
279 if (CGEN_SYNTAX_CHAR_P (* syn))
282 errmsg = (* cd->insert_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
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. */
296 put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
297 CGEN_INSN_BYTES_PTR buf,
302 /* For architectures with insns smaller than the base-insn-bitsize,
303 length may be too big. */
304 if (length > insn_length)
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);
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,
334 /* It's doubtful that the middle part has already been fetched so
335 we don't optimize that case. kiss. */
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)
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))
354 status = (*info->read_memory_func)
355 (pc, ex_info->insn_bytes + offset, bytes, info);
359 (*info->memory_error_func) (status, pc, info);
363 ex_info->valid |= ((1 << bytes) - 1) << offset;
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,
378 bfd_vma pc ATTRIBUTE_UNUSED)
383 x = cgen_get_insn_value (cd, bufp, word_length);
385 if (CGEN_INSN_LSB0_P)
386 shift = (start + 1) - length;
388 shift = (word_length - (start + length));
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
415 extract_normal (CGEN_CPU_DESC cd,
416 #if ! CGEN_INT_INSN_P
417 CGEN_EXTRACT_INFO *ex_info,
419 CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED,
421 CGEN_INSN_INT insn_value,
423 unsigned int word_offset,
426 unsigned int word_length,
427 unsigned int total_length,
428 #if ! CGEN_INT_INSN_P
431 bfd_vma pc ATTRIBUTE_UNUSED,
437 /* If LENGTH is zero, this operand doesn't contribute to the value
438 so give it a standard value of zero. */
445 if (word_length > 8 * sizeof (CGEN_INSN_INT))
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);
463 value = insn_value >> (total_length - ( word_offset + start + length));
466 #if ! CGEN_INT_INSN_P
470 unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
472 if (word_length > 8 * sizeof (CGEN_INSN_INT))
475 if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 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;
488 if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)
489 && (value & (1L << (length - 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
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,
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)
525 if (CGEN_SYNTAX_CHAR_P (*syn))
528 length = (* cd->extract_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
529 ex_info, insn_value, fields, pc);
534 /* We recognized and successfully extracted this insn. */
535 return CGEN_INSN_BITSIZE (insn);
538 /* Machine generated code added here. */
540 const char * epiphany_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. */
558 epiphany_cgen_insert_operand (CGEN_CPU_DESC cd,
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);
569 case EPIPHANY_OPERAND_DIRECTION :
570 errmsg = insert_normal (cd, fields->f_addsubx, 0, 0, 20, 1, 32, total_length, buffer);
572 case EPIPHANY_OPERAND_DISP11 :
575 FLD (f_disp8) = ((((UINT) (FLD (f_disp11)) >> (3))) & (255));
576 FLD (f_disp3) = ((FLD (f_disp11)) & (7));
578 errmsg = insert_normal (cd, fields->f_disp3, 0, 0, 9, 3, 32, total_length, buffer);
581 errmsg = insert_normal (cd, fields->f_disp8, 0, 0, 23, 8, 32, total_length, buffer);
586 case EPIPHANY_OPERAND_DISP3 :
587 errmsg = insert_normal (cd, fields->f_disp3, 0, 0, 9, 3, 32, total_length, buffer);
589 case EPIPHANY_OPERAND_DPMI :
590 errmsg = insert_normal (cd, fields->f_subd, 0, 0, 24, 1, 32, total_length, buffer);
592 case EPIPHANY_OPERAND_FRD :
593 errmsg = insert_normal (cd, fields->f_rd, 0, 0, 15, 3, 32, total_length, buffer);
595 case EPIPHANY_OPERAND_FRD6 :
598 FLD (f_rd) = ((FLD (f_rd6)) & (7));
599 FLD (f_rd_x) = ((UINT) (FLD (f_rd6)) >> (3));
601 errmsg = insert_normal (cd, fields->f_rd_x, 0, 0, 31, 3, 32, total_length, buffer);
604 errmsg = insert_normal (cd, fields->f_rd, 0, 0, 15, 3, 32, total_length, buffer);
609 case EPIPHANY_OPERAND_FRM :
610 errmsg = insert_normal (cd, fields->f_rm, 0, 0, 9, 3, 32, total_length, buffer);
612 case EPIPHANY_OPERAND_FRM6 :
615 FLD (f_rm) = ((FLD (f_rm6)) & (7));
616 FLD (f_rm_x) = ((UINT) (FLD (f_rm6)) >> (3));
618 errmsg = insert_normal (cd, fields->f_rm_x, 0, 0, 25, 3, 32, total_length, buffer);
621 errmsg = insert_normal (cd, fields->f_rm, 0, 0, 9, 3, 32, total_length, buffer);
626 case EPIPHANY_OPERAND_FRN :
627 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 12, 3, 32, total_length, buffer);
629 case EPIPHANY_OPERAND_FRN6 :
632 FLD (f_rn) = ((FLD (f_rn6)) & (7));
633 FLD (f_rn_x) = ((UINT) (FLD (f_rn6)) >> (3));
635 errmsg = insert_normal (cd, fields->f_rn_x, 0, 0, 28, 3, 32, total_length, buffer);
638 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 12, 3, 32, total_length, buffer);
643 case EPIPHANY_OPERAND_IMM16 :
646 FLD (f_imm8) = ((FLD (f_imm16)) & (255));
647 FLD (f_imm_27_8) = ((UINT) (FLD (f_imm16)) >> (8));
649 errmsg = insert_normal (cd, fields->f_imm8, 0, 0, 12, 8, 32, total_length, buffer);
652 errmsg = insert_normal (cd, fields->f_imm_27_8, 0, 0, 27, 8, 32, total_length, buffer);
657 case EPIPHANY_OPERAND_IMM8 :
658 errmsg = insert_normal (cd, fields->f_imm8, 0, 0, 12, 8, 32, total_length, buffer);
660 case EPIPHANY_OPERAND_RD :
661 errmsg = insert_normal (cd, fields->f_rd, 0, 0, 15, 3, 32, total_length, buffer);
663 case EPIPHANY_OPERAND_RD6 :
666 FLD (f_rd) = ((FLD (f_rd6)) & (7));
667 FLD (f_rd_x) = ((UINT) (FLD (f_rd6)) >> (3));
669 errmsg = insert_normal (cd, fields->f_rd_x, 0, 0, 31, 3, 32, total_length, buffer);
672 errmsg = insert_normal (cd, fields->f_rd, 0, 0, 15, 3, 32, total_length, buffer);
677 case EPIPHANY_OPERAND_RM :
678 errmsg = insert_normal (cd, fields->f_rm, 0, 0, 9, 3, 32, total_length, buffer);
680 case EPIPHANY_OPERAND_RM6 :
683 FLD (f_rm) = ((FLD (f_rm6)) & (7));
684 FLD (f_rm_x) = ((UINT) (FLD (f_rm6)) >> (3));
686 errmsg = insert_normal (cd, fields->f_rm_x, 0, 0, 25, 3, 32, total_length, buffer);
689 errmsg = insert_normal (cd, fields->f_rm, 0, 0, 9, 3, 32, total_length, buffer);
694 case EPIPHANY_OPERAND_RN :
695 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 12, 3, 32, total_length, buffer);
697 case EPIPHANY_OPERAND_RN6 :
700 FLD (f_rn) = ((FLD (f_rn6)) & (7));
701 FLD (f_rn_x) = ((UINT) (FLD (f_rn6)) >> (3));
703 errmsg = insert_normal (cd, fields->f_rn_x, 0, 0, 28, 3, 32, total_length, buffer);
706 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 12, 3, 32, total_length, buffer);
711 case EPIPHANY_OPERAND_SD :
712 errmsg = insert_normal (cd, fields->f_sd, 0, 0, 15, 3, 32, total_length, buffer);
714 case EPIPHANY_OPERAND_SD6 :
717 FLD (f_sd) = ((FLD (f_sd6)) & (7));
718 FLD (f_sd_x) = ((UINT) (FLD (f_sd6)) >> (3));
720 errmsg = insert_normal (cd, fields->f_sd_x, 0, 0, 31, 3, 32, total_length, buffer);
723 errmsg = insert_normal (cd, fields->f_sd, 0, 0, 15, 3, 32, total_length, buffer);
728 case EPIPHANY_OPERAND_SDDMA :
731 FLD (f_sd) = ((FLD (f_sd6)) & (7));
732 FLD (f_sd_x) = ((UINT) (FLD (f_sd6)) >> (3));
734 errmsg = insert_normal (cd, fields->f_sd_x, 0, 0, 31, 3, 32, total_length, buffer);
737 errmsg = insert_normal (cd, fields->f_sd, 0, 0, 15, 3, 32, total_length, buffer);
742 case EPIPHANY_OPERAND_SDMEM :
745 FLD (f_sd) = ((FLD (f_sd6)) & (7));
746 FLD (f_sd_x) = ((UINT) (FLD (f_sd6)) >> (3));
748 errmsg = insert_normal (cd, fields->f_sd_x, 0, 0, 31, 3, 32, total_length, buffer);
751 errmsg = insert_normal (cd, fields->f_sd, 0, 0, 15, 3, 32, total_length, buffer);
756 case EPIPHANY_OPERAND_SDMESH :
759 FLD (f_sd) = ((FLD (f_sd6)) & (7));
760 FLD (f_sd_x) = ((UINT) (FLD (f_sd6)) >> (3));
762 errmsg = insert_normal (cd, fields->f_sd_x, 0, 0, 31, 3, 32, total_length, buffer);
765 errmsg = insert_normal (cd, fields->f_sd, 0, 0, 15, 3, 32, total_length, buffer);
770 case EPIPHANY_OPERAND_SHIFT :
771 errmsg = insert_normal (cd, fields->f_shift, 0, 0, 9, 5, 32, total_length, buffer);
773 case EPIPHANY_OPERAND_SIMM11 :
776 FLD (f_disp8) = ((255) & (((USI) (FLD (f_sdisp11)) >> (3))));
777 FLD (f_disp3) = ((FLD (f_sdisp11)) & (7));
779 errmsg = insert_normal (cd, fields->f_disp3, 0, 0, 9, 3, 32, total_length, buffer);
782 errmsg = insert_normal (cd, fields->f_disp8, 0, 0, 23, 8, 32, total_length, buffer);
787 case EPIPHANY_OPERAND_SIMM24 :
789 long value = fields->f_simm24;
790 value = ((SI) (((value) - (pc))) >> (1));
791 errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 31, 24, 32, total_length, buffer);
794 case EPIPHANY_OPERAND_SIMM3 :
795 errmsg = insert_normal (cd, fields->f_sdisp3, 0|(1<<CGEN_IFLD_SIGNED), 0, 9, 3, 32, total_length, buffer);
797 case EPIPHANY_OPERAND_SIMM8 :
799 long value = fields->f_simm8;
800 value = ((SI) (((value) - (pc))) >> (1));
801 errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 15, 8, 32, total_length, buffer);
804 case EPIPHANY_OPERAND_SN :
805 errmsg = insert_normal (cd, fields->f_sn, 0, 0, 12, 3, 32, total_length, buffer);
807 case EPIPHANY_OPERAND_SN6 :
810 FLD (f_sn) = ((FLD (f_sn6)) & (7));
811 FLD (f_sn_x) = ((UINT) (FLD (f_sn6)) >> (3));
813 errmsg = insert_normal (cd, fields->f_sn_x, 0, 0, 28, 3, 32, total_length, buffer);
816 errmsg = insert_normal (cd, fields->f_sn, 0, 0, 12, 3, 32, total_length, buffer);
821 case EPIPHANY_OPERAND_SNDMA :
824 FLD (f_sn) = ((FLD (f_sn6)) & (7));
825 FLD (f_sn_x) = ((UINT) (FLD (f_sn6)) >> (3));
827 errmsg = insert_normal (cd, fields->f_sn_x, 0, 0, 28, 3, 32, total_length, buffer);
830 errmsg = insert_normal (cd, fields->f_sn, 0, 0, 12, 3, 32, total_length, buffer);
835 case EPIPHANY_OPERAND_SNMEM :
838 FLD (f_sn) = ((FLD (f_sn6)) & (7));
839 FLD (f_sn_x) = ((UINT) (FLD (f_sn6)) >> (3));
841 errmsg = insert_normal (cd, fields->f_sn_x, 0, 0, 28, 3, 32, total_length, buffer);
844 errmsg = insert_normal (cd, fields->f_sn, 0, 0, 12, 3, 32, total_length, buffer);
849 case EPIPHANY_OPERAND_SNMESH :
852 FLD (f_sn) = ((FLD (f_sn6)) & (7));
853 FLD (f_sn_x) = ((UINT) (FLD (f_sn6)) >> (3));
855 errmsg = insert_normal (cd, fields->f_sn_x, 0, 0, 28, 3, 32, total_length, buffer);
858 errmsg = insert_normal (cd, fields->f_sn, 0, 0, 12, 3, 32, total_length, buffer);
863 case EPIPHANY_OPERAND_SWI_NUM :
864 errmsg = insert_normal (cd, fields->f_trap_num, 0, 0, 15, 6, 32, total_length, buffer);
866 case EPIPHANY_OPERAND_TRAPNUM6 :
867 errmsg = insert_normal (cd, fields->f_trap_num, 0, 0, 15, 6, 32, total_length, buffer);
871 /* xgettext:c-format */
872 fprintf (stderr, _("Unrecognized field %d while building insn.\n"),
880 int epiphany_cgen_extract_operand
881 (CGEN_CPU_DESC, int, CGEN_EXTRACT_INFO *, CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma);
883 /* Main entry point for operand extraction.
884 The result is <= 0 for error, >0 for success.
885 ??? Actual values aren't well defined right now.
887 This function is basically just a big switch statement. Earlier versions
888 used tables to look up the function to use, but
889 - if the table contains both assembler and disassembler functions then
890 the disassembler contains much of the assembler and vice-versa,
891 - there's a lot of inlining possibilities as things grow,
892 - using a switch statement avoids the function call overhead.
894 This function could be moved into `print_insn_normal', but keeping it
895 separate makes clear the interface between `print_insn_normal' and each of
899 epiphany_cgen_extract_operand (CGEN_CPU_DESC cd,
901 CGEN_EXTRACT_INFO *ex_info,
902 CGEN_INSN_INT insn_value,
903 CGEN_FIELDS * fields,
906 /* Assume success (for those operands that are nops). */
908 unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
912 case EPIPHANY_OPERAND_DIRECTION :
913 length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 1, 32, total_length, pc, & fields->f_addsubx);
915 case EPIPHANY_OPERAND_DISP11 :
917 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_disp3);
918 if (length <= 0) break;
919 length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 8, 32, total_length, pc, & fields->f_disp8);
920 if (length <= 0) break;
922 FLD (f_disp11) = ((((FLD (f_disp8)) << (3))) | (FLD (f_disp3)));
926 case EPIPHANY_OPERAND_DISP3 :
927 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_disp3);
929 case EPIPHANY_OPERAND_DPMI :
930 length = extract_normal (cd, ex_info, insn_value, 0, 0, 24, 1, 32, total_length, pc, & fields->f_subd);
932 case EPIPHANY_OPERAND_FRD :
933 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_rd);
935 case EPIPHANY_OPERAND_FRD6 :
937 length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 3, 32, total_length, pc, & fields->f_rd_x);
938 if (length <= 0) break;
939 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_rd);
940 if (length <= 0) break;
942 FLD (f_rd6) = ((((FLD (f_rd_x)) << (3))) | (FLD (f_rd)));
946 case EPIPHANY_OPERAND_FRM :
947 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_rm);
949 case EPIPHANY_OPERAND_FRM6 :
951 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 3, 32, total_length, pc, & fields->f_rm_x);
952 if (length <= 0) break;
953 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_rm);
954 if (length <= 0) break;
956 FLD (f_rm6) = ((((FLD (f_rm_x)) << (3))) | (FLD (f_rm)));
960 case EPIPHANY_OPERAND_FRN :
961 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_rn);
963 case EPIPHANY_OPERAND_FRN6 :
965 length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 3, 32, total_length, pc, & fields->f_rn_x);
966 if (length <= 0) break;
967 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_rn);
968 if (length <= 0) break;
970 FLD (f_rn6) = ((((FLD (f_rn_x)) << (3))) | (FLD (f_rn)));
974 case EPIPHANY_OPERAND_IMM16 :
976 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 8, 32, total_length, pc, & fields->f_imm8);
977 if (length <= 0) break;
978 length = extract_normal (cd, ex_info, insn_value, 0, 0, 27, 8, 32, total_length, pc, & fields->f_imm_27_8);
979 if (length <= 0) break;
981 FLD (f_imm16) = ((((FLD (f_imm_27_8)) << (8))) | (FLD (f_imm8)));
985 case EPIPHANY_OPERAND_IMM8 :
986 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 8, 32, total_length, pc, & fields->f_imm8);
988 case EPIPHANY_OPERAND_RD :
989 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_rd);
991 case EPIPHANY_OPERAND_RD6 :
993 length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 3, 32, total_length, pc, & fields->f_rd_x);
994 if (length <= 0) break;
995 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_rd);
996 if (length <= 0) break;
998 FLD (f_rd6) = ((((FLD (f_rd_x)) << (3))) | (FLD (f_rd)));
1002 case EPIPHANY_OPERAND_RM :
1003 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_rm);
1005 case EPIPHANY_OPERAND_RM6 :
1007 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 3, 32, total_length, pc, & fields->f_rm_x);
1008 if (length <= 0) break;
1009 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_rm);
1010 if (length <= 0) break;
1012 FLD (f_rm6) = ((((FLD (f_rm_x)) << (3))) | (FLD (f_rm)));
1016 case EPIPHANY_OPERAND_RN :
1017 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_rn);
1019 case EPIPHANY_OPERAND_RN6 :
1021 length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 3, 32, total_length, pc, & fields->f_rn_x);
1022 if (length <= 0) break;
1023 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_rn);
1024 if (length <= 0) break;
1026 FLD (f_rn6) = ((((FLD (f_rn_x)) << (3))) | (FLD (f_rn)));
1030 case EPIPHANY_OPERAND_SD :
1031 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_sd);
1033 case EPIPHANY_OPERAND_SD6 :
1035 length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 3, 32, total_length, pc, & fields->f_sd_x);
1036 if (length <= 0) break;
1037 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_sd);
1038 if (length <= 0) break;
1040 FLD (f_sd6) = ((((FLD (f_sd_x)) << (3))) | (FLD (f_sd)));
1044 case EPIPHANY_OPERAND_SDDMA :
1046 length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 3, 32, total_length, pc, & fields->f_sd_x);
1047 if (length <= 0) break;
1048 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_sd);
1049 if (length <= 0) break;
1051 FLD (f_sd6) = ((((FLD (f_sd_x)) << (3))) | (FLD (f_sd)));
1055 case EPIPHANY_OPERAND_SDMEM :
1057 length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 3, 32, total_length, pc, & fields->f_sd_x);
1058 if (length <= 0) break;
1059 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_sd);
1060 if (length <= 0) break;
1062 FLD (f_sd6) = ((((FLD (f_sd_x)) << (3))) | (FLD (f_sd)));
1066 case EPIPHANY_OPERAND_SDMESH :
1068 length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 3, 32, total_length, pc, & fields->f_sd_x);
1069 if (length <= 0) break;
1070 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_sd);
1071 if (length <= 0) break;
1073 FLD (f_sd6) = ((((FLD (f_sd_x)) << (3))) | (FLD (f_sd)));
1077 case EPIPHANY_OPERAND_SHIFT :
1078 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 5, 32, total_length, pc, & fields->f_shift);
1080 case EPIPHANY_OPERAND_SIMM11 :
1082 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_disp3);
1083 if (length <= 0) break;
1084 length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 8, 32, total_length, pc, & fields->f_disp8);
1085 if (length <= 0) break;
1087 FLD (f_sdisp11) = ((SI) (((((((FLD (f_disp8)) << (3))) | (FLD (f_disp3)))) << (21))) >> (21));
1091 case EPIPHANY_OPERAND_SIMM24 :
1094 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 31, 24, 32, total_length, pc, & value);
1095 value = ((((value) << (1))) + (pc));
1096 fields->f_simm24 = value;
1099 case EPIPHANY_OPERAND_SIMM3 :
1100 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 9, 3, 32, total_length, pc, & fields->f_sdisp3);
1102 case EPIPHANY_OPERAND_SIMM8 :
1105 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 15, 8, 32, total_length, pc, & value);
1106 value = ((((value) << (1))) + (pc));
1107 fields->f_simm8 = value;
1110 case EPIPHANY_OPERAND_SN :
1111 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_sn);
1113 case EPIPHANY_OPERAND_SN6 :
1115 length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 3, 32, total_length, pc, & fields->f_sn_x);
1116 if (length <= 0) break;
1117 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_sn);
1118 if (length <= 0) break;
1120 FLD (f_sn6) = ((((FLD (f_sn_x)) << (3))) | (FLD (f_sn)));
1124 case EPIPHANY_OPERAND_SNDMA :
1126 length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 3, 32, total_length, pc, & fields->f_sn_x);
1127 if (length <= 0) break;
1128 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_sn);
1129 if (length <= 0) break;
1131 FLD (f_sn6) = ((((FLD (f_sn_x)) << (3))) | (FLD (f_sn)));
1135 case EPIPHANY_OPERAND_SNMEM :
1137 length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 3, 32, total_length, pc, & fields->f_sn_x);
1138 if (length <= 0) break;
1139 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_sn);
1140 if (length <= 0) break;
1142 FLD (f_sn6) = ((((FLD (f_sn_x)) << (3))) | (FLD (f_sn)));
1146 case EPIPHANY_OPERAND_SNMESH :
1148 length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 3, 32, total_length, pc, & fields->f_sn_x);
1149 if (length <= 0) break;
1150 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_sn);
1151 if (length <= 0) break;
1153 FLD (f_sn6) = ((((FLD (f_sn_x)) << (3))) | (FLD (f_sn)));
1157 case EPIPHANY_OPERAND_SWI_NUM :
1158 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 6, 32, total_length, pc, & fields->f_trap_num);
1160 case EPIPHANY_OPERAND_TRAPNUM6 :
1161 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 6, 32, total_length, pc, & fields->f_trap_num);
1165 /* xgettext:c-format */
1166 fprintf (stderr, _("Unrecognized field %d while decoding insn.\n"),
1174 cgen_insert_fn * const epiphany_cgen_insert_handlers[] =
1179 cgen_extract_fn * const epiphany_cgen_extract_handlers[] =
1181 extract_insn_normal,
1184 int epiphany_cgen_get_int_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *);
1185 bfd_vma epiphany_cgen_get_vma_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *);
1187 /* Getting values from cgen_fields is handled by a collection of functions.
1188 They are distinguished by the type of the VALUE argument they return.
1189 TODO: floating point, inlining support, remove cases where result type
1193 epiphany_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1195 const CGEN_FIELDS * fields)
1201 case EPIPHANY_OPERAND_DIRECTION :
1202 value = fields->f_addsubx;
1204 case EPIPHANY_OPERAND_DISP11 :
1205 value = fields->f_disp11;
1207 case EPIPHANY_OPERAND_DISP3 :
1208 value = fields->f_disp3;
1210 case EPIPHANY_OPERAND_DPMI :
1211 value = fields->f_subd;
1213 case EPIPHANY_OPERAND_FRD :
1214 value = fields->f_rd;
1216 case EPIPHANY_OPERAND_FRD6 :
1217 value = fields->f_rd6;
1219 case EPIPHANY_OPERAND_FRM :
1220 value = fields->f_rm;
1222 case EPIPHANY_OPERAND_FRM6 :
1223 value = fields->f_rm6;
1225 case EPIPHANY_OPERAND_FRN :
1226 value = fields->f_rn;
1228 case EPIPHANY_OPERAND_FRN6 :
1229 value = fields->f_rn6;
1231 case EPIPHANY_OPERAND_IMM16 :
1232 value = fields->f_imm16;
1234 case EPIPHANY_OPERAND_IMM8 :
1235 value = fields->f_imm8;
1237 case EPIPHANY_OPERAND_RD :
1238 value = fields->f_rd;
1240 case EPIPHANY_OPERAND_RD6 :
1241 value = fields->f_rd6;
1243 case EPIPHANY_OPERAND_RM :
1244 value = fields->f_rm;
1246 case EPIPHANY_OPERAND_RM6 :
1247 value = fields->f_rm6;
1249 case EPIPHANY_OPERAND_RN :
1250 value = fields->f_rn;
1252 case EPIPHANY_OPERAND_RN6 :
1253 value = fields->f_rn6;
1255 case EPIPHANY_OPERAND_SD :
1256 value = fields->f_sd;
1258 case EPIPHANY_OPERAND_SD6 :
1259 value = fields->f_sd6;
1261 case EPIPHANY_OPERAND_SDDMA :
1262 value = fields->f_sd6;
1264 case EPIPHANY_OPERAND_SDMEM :
1265 value = fields->f_sd6;
1267 case EPIPHANY_OPERAND_SDMESH :
1268 value = fields->f_sd6;
1270 case EPIPHANY_OPERAND_SHIFT :
1271 value = fields->f_shift;
1273 case EPIPHANY_OPERAND_SIMM11 :
1274 value = fields->f_sdisp11;
1276 case EPIPHANY_OPERAND_SIMM24 :
1277 value = fields->f_simm24;
1279 case EPIPHANY_OPERAND_SIMM3 :
1280 value = fields->f_sdisp3;
1282 case EPIPHANY_OPERAND_SIMM8 :
1283 value = fields->f_simm8;
1285 case EPIPHANY_OPERAND_SN :
1286 value = fields->f_sn;
1288 case EPIPHANY_OPERAND_SN6 :
1289 value = fields->f_sn6;
1291 case EPIPHANY_OPERAND_SNDMA :
1292 value = fields->f_sn6;
1294 case EPIPHANY_OPERAND_SNMEM :
1295 value = fields->f_sn6;
1297 case EPIPHANY_OPERAND_SNMESH :
1298 value = fields->f_sn6;
1300 case EPIPHANY_OPERAND_SWI_NUM :
1301 value = fields->f_trap_num;
1303 case EPIPHANY_OPERAND_TRAPNUM6 :
1304 value = fields->f_trap_num;
1308 /* xgettext:c-format */
1309 fprintf (stderr, _("Unrecognized field %d while getting int operand.\n"),
1318 epiphany_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1320 const CGEN_FIELDS * fields)
1326 case EPIPHANY_OPERAND_DIRECTION :
1327 value = fields->f_addsubx;
1329 case EPIPHANY_OPERAND_DISP11 :
1330 value = fields->f_disp11;
1332 case EPIPHANY_OPERAND_DISP3 :
1333 value = fields->f_disp3;
1335 case EPIPHANY_OPERAND_DPMI :
1336 value = fields->f_subd;
1338 case EPIPHANY_OPERAND_FRD :
1339 value = fields->f_rd;
1341 case EPIPHANY_OPERAND_FRD6 :
1342 value = fields->f_rd6;
1344 case EPIPHANY_OPERAND_FRM :
1345 value = fields->f_rm;
1347 case EPIPHANY_OPERAND_FRM6 :
1348 value = fields->f_rm6;
1350 case EPIPHANY_OPERAND_FRN :
1351 value = fields->f_rn;
1353 case EPIPHANY_OPERAND_FRN6 :
1354 value = fields->f_rn6;
1356 case EPIPHANY_OPERAND_IMM16 :
1357 value = fields->f_imm16;
1359 case EPIPHANY_OPERAND_IMM8 :
1360 value = fields->f_imm8;
1362 case EPIPHANY_OPERAND_RD :
1363 value = fields->f_rd;
1365 case EPIPHANY_OPERAND_RD6 :
1366 value = fields->f_rd6;
1368 case EPIPHANY_OPERAND_RM :
1369 value = fields->f_rm;
1371 case EPIPHANY_OPERAND_RM6 :
1372 value = fields->f_rm6;
1374 case EPIPHANY_OPERAND_RN :
1375 value = fields->f_rn;
1377 case EPIPHANY_OPERAND_RN6 :
1378 value = fields->f_rn6;
1380 case EPIPHANY_OPERAND_SD :
1381 value = fields->f_sd;
1383 case EPIPHANY_OPERAND_SD6 :
1384 value = fields->f_sd6;
1386 case EPIPHANY_OPERAND_SDDMA :
1387 value = fields->f_sd6;
1389 case EPIPHANY_OPERAND_SDMEM :
1390 value = fields->f_sd6;
1392 case EPIPHANY_OPERAND_SDMESH :
1393 value = fields->f_sd6;
1395 case EPIPHANY_OPERAND_SHIFT :
1396 value = fields->f_shift;
1398 case EPIPHANY_OPERAND_SIMM11 :
1399 value = fields->f_sdisp11;
1401 case EPIPHANY_OPERAND_SIMM24 :
1402 value = fields->f_simm24;
1404 case EPIPHANY_OPERAND_SIMM3 :
1405 value = fields->f_sdisp3;
1407 case EPIPHANY_OPERAND_SIMM8 :
1408 value = fields->f_simm8;
1410 case EPIPHANY_OPERAND_SN :
1411 value = fields->f_sn;
1413 case EPIPHANY_OPERAND_SN6 :
1414 value = fields->f_sn6;
1416 case EPIPHANY_OPERAND_SNDMA :
1417 value = fields->f_sn6;
1419 case EPIPHANY_OPERAND_SNMEM :
1420 value = fields->f_sn6;
1422 case EPIPHANY_OPERAND_SNMESH :
1423 value = fields->f_sn6;
1425 case EPIPHANY_OPERAND_SWI_NUM :
1426 value = fields->f_trap_num;
1428 case EPIPHANY_OPERAND_TRAPNUM6 :
1429 value = fields->f_trap_num;
1433 /* xgettext:c-format */
1434 fprintf (stderr, _("Unrecognized field %d while getting vma operand.\n"),
1442 void epiphany_cgen_set_int_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, int);
1443 void epiphany_cgen_set_vma_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, bfd_vma);
1445 /* Stuffing values in cgen_fields is handled by a collection of functions.
1446 They are distinguished by the type of the VALUE argument they accept.
1447 TODO: floating point, inlining support, remove cases where argument type
1451 epiphany_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1453 CGEN_FIELDS * fields,
1458 case EPIPHANY_OPERAND_DIRECTION :
1459 fields->f_addsubx = value;
1461 case EPIPHANY_OPERAND_DISP11 :
1462 fields->f_disp11 = value;
1464 case EPIPHANY_OPERAND_DISP3 :
1465 fields->f_disp3 = value;
1467 case EPIPHANY_OPERAND_DPMI :
1468 fields->f_subd = value;
1470 case EPIPHANY_OPERAND_FRD :
1471 fields->f_rd = value;
1473 case EPIPHANY_OPERAND_FRD6 :
1474 fields->f_rd6 = value;
1476 case EPIPHANY_OPERAND_FRM :
1477 fields->f_rm = value;
1479 case EPIPHANY_OPERAND_FRM6 :
1480 fields->f_rm6 = value;
1482 case EPIPHANY_OPERAND_FRN :
1483 fields->f_rn = value;
1485 case EPIPHANY_OPERAND_FRN6 :
1486 fields->f_rn6 = value;
1488 case EPIPHANY_OPERAND_IMM16 :
1489 fields->f_imm16 = value;
1491 case EPIPHANY_OPERAND_IMM8 :
1492 fields->f_imm8 = value;
1494 case EPIPHANY_OPERAND_RD :
1495 fields->f_rd = value;
1497 case EPIPHANY_OPERAND_RD6 :
1498 fields->f_rd6 = value;
1500 case EPIPHANY_OPERAND_RM :
1501 fields->f_rm = value;
1503 case EPIPHANY_OPERAND_RM6 :
1504 fields->f_rm6 = value;
1506 case EPIPHANY_OPERAND_RN :
1507 fields->f_rn = value;
1509 case EPIPHANY_OPERAND_RN6 :
1510 fields->f_rn6 = value;
1512 case EPIPHANY_OPERAND_SD :
1513 fields->f_sd = value;
1515 case EPIPHANY_OPERAND_SD6 :
1516 fields->f_sd6 = value;
1518 case EPIPHANY_OPERAND_SDDMA :
1519 fields->f_sd6 = value;
1521 case EPIPHANY_OPERAND_SDMEM :
1522 fields->f_sd6 = value;
1524 case EPIPHANY_OPERAND_SDMESH :
1525 fields->f_sd6 = value;
1527 case EPIPHANY_OPERAND_SHIFT :
1528 fields->f_shift = value;
1530 case EPIPHANY_OPERAND_SIMM11 :
1531 fields->f_sdisp11 = value;
1533 case EPIPHANY_OPERAND_SIMM24 :
1534 fields->f_simm24 = value;
1536 case EPIPHANY_OPERAND_SIMM3 :
1537 fields->f_sdisp3 = value;
1539 case EPIPHANY_OPERAND_SIMM8 :
1540 fields->f_simm8 = value;
1542 case EPIPHANY_OPERAND_SN :
1543 fields->f_sn = value;
1545 case EPIPHANY_OPERAND_SN6 :
1546 fields->f_sn6 = value;
1548 case EPIPHANY_OPERAND_SNDMA :
1549 fields->f_sn6 = value;
1551 case EPIPHANY_OPERAND_SNMEM :
1552 fields->f_sn6 = value;
1554 case EPIPHANY_OPERAND_SNMESH :
1555 fields->f_sn6 = value;
1557 case EPIPHANY_OPERAND_SWI_NUM :
1558 fields->f_trap_num = value;
1560 case EPIPHANY_OPERAND_TRAPNUM6 :
1561 fields->f_trap_num = value;
1565 /* xgettext:c-format */
1566 fprintf (stderr, _("Unrecognized field %d while setting int operand.\n"),
1573 epiphany_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1575 CGEN_FIELDS * fields,
1580 case EPIPHANY_OPERAND_DIRECTION :
1581 fields->f_addsubx = value;
1583 case EPIPHANY_OPERAND_DISP11 :
1584 fields->f_disp11 = value;
1586 case EPIPHANY_OPERAND_DISP3 :
1587 fields->f_disp3 = value;
1589 case EPIPHANY_OPERAND_DPMI :
1590 fields->f_subd = value;
1592 case EPIPHANY_OPERAND_FRD :
1593 fields->f_rd = value;
1595 case EPIPHANY_OPERAND_FRD6 :
1596 fields->f_rd6 = value;
1598 case EPIPHANY_OPERAND_FRM :
1599 fields->f_rm = value;
1601 case EPIPHANY_OPERAND_FRM6 :
1602 fields->f_rm6 = value;
1604 case EPIPHANY_OPERAND_FRN :
1605 fields->f_rn = value;
1607 case EPIPHANY_OPERAND_FRN6 :
1608 fields->f_rn6 = value;
1610 case EPIPHANY_OPERAND_IMM16 :
1611 fields->f_imm16 = value;
1613 case EPIPHANY_OPERAND_IMM8 :
1614 fields->f_imm8 = value;
1616 case EPIPHANY_OPERAND_RD :
1617 fields->f_rd = value;
1619 case EPIPHANY_OPERAND_RD6 :
1620 fields->f_rd6 = value;
1622 case EPIPHANY_OPERAND_RM :
1623 fields->f_rm = value;
1625 case EPIPHANY_OPERAND_RM6 :
1626 fields->f_rm6 = value;
1628 case EPIPHANY_OPERAND_RN :
1629 fields->f_rn = value;
1631 case EPIPHANY_OPERAND_RN6 :
1632 fields->f_rn6 = value;
1634 case EPIPHANY_OPERAND_SD :
1635 fields->f_sd = value;
1637 case EPIPHANY_OPERAND_SD6 :
1638 fields->f_sd6 = value;
1640 case EPIPHANY_OPERAND_SDDMA :
1641 fields->f_sd6 = value;
1643 case EPIPHANY_OPERAND_SDMEM :
1644 fields->f_sd6 = value;
1646 case EPIPHANY_OPERAND_SDMESH :
1647 fields->f_sd6 = value;
1649 case EPIPHANY_OPERAND_SHIFT :
1650 fields->f_shift = value;
1652 case EPIPHANY_OPERAND_SIMM11 :
1653 fields->f_sdisp11 = value;
1655 case EPIPHANY_OPERAND_SIMM24 :
1656 fields->f_simm24 = value;
1658 case EPIPHANY_OPERAND_SIMM3 :
1659 fields->f_sdisp3 = value;
1661 case EPIPHANY_OPERAND_SIMM8 :
1662 fields->f_simm8 = value;
1664 case EPIPHANY_OPERAND_SN :
1665 fields->f_sn = value;
1667 case EPIPHANY_OPERAND_SN6 :
1668 fields->f_sn6 = value;
1670 case EPIPHANY_OPERAND_SNDMA :
1671 fields->f_sn6 = value;
1673 case EPIPHANY_OPERAND_SNMEM :
1674 fields->f_sn6 = value;
1676 case EPIPHANY_OPERAND_SNMESH :
1677 fields->f_sn6 = value;
1679 case EPIPHANY_OPERAND_SWI_NUM :
1680 fields->f_trap_num = value;
1682 case EPIPHANY_OPERAND_TRAPNUM6 :
1683 fields->f_trap_num = value;
1687 /* xgettext:c-format */
1688 fprintf (stderr, _("Unrecognized field %d while setting vma operand.\n"),
1694 /* Function to call before using the instruction builder tables. */
1697 epiphany_cgen_init_ibld_table (CGEN_CPU_DESC cd)
1699 cd->insert_handlers = & epiphany_cgen_insert_handlers[0];
1700 cd->extract_handlers = & epiphany_cgen_extract_handlers[0];
1702 cd->insert_operand = epiphany_cgen_insert_operand;
1703 cd->extract_operand = epiphany_cgen_extract_operand;
1705 cd->get_int_operand = epiphany_cgen_get_int_operand;
1706 cd->set_int_operand = epiphany_cgen_set_int_operand;
1707 cd->get_vma_operand = epiphany_cgen_get_vma_operand;
1708 cd->set_vma_operand = epiphany_cgen_set_vma_operand;