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 (C) 1996-2016 Free Software Foundation, Inc.
8 This file is part of libopcodes.
10 This library is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3, or (at your option)
15 It is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
18 License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software Foundation, Inc.,
22 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
24 /* ??? Eventually more and more of this stuff can go to cpu-independent files.
33 #include "epiphany-desc.h"
34 #include "epiphany-opc.h"
35 #include "cgen/basic-modes.h"
37 #include "safe-ctype.h"
40 #define min(a,b) ((a) < (b) ? (a) : (b))
42 #define max(a,b) ((a) > (b) ? (a) : (b))
44 /* Used by the ifield rtx function. */
45 #define FLD(f) (fields->f)
47 static const char * insert_normal
48 (CGEN_CPU_DESC, long, unsigned int, unsigned int, unsigned int,
49 unsigned int, unsigned int, unsigned int, CGEN_INSN_BYTES_PTR);
50 static const char * insert_insn_normal
51 (CGEN_CPU_DESC, const CGEN_INSN *,
52 CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma);
53 static int extract_normal
54 (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, CGEN_INSN_INT,
55 unsigned int, unsigned int, unsigned int, unsigned int,
56 unsigned int, unsigned int, bfd_vma, long *);
57 static int extract_insn_normal
58 (CGEN_CPU_DESC, const CGEN_INSN *, CGEN_EXTRACT_INFO *,
59 CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma);
61 static void put_insn_int_value
62 (CGEN_CPU_DESC, CGEN_INSN_BYTES_PTR, int, int, CGEN_INSN_INT);
65 static CGEN_INLINE void insert_1
66 (CGEN_CPU_DESC, unsigned long, int, int, int, unsigned char *);
67 static CGEN_INLINE int fill_cache
68 (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, int, int, bfd_vma);
69 static CGEN_INLINE long extract_1
70 (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, int, int, int, unsigned char *, bfd_vma);
73 /* Operand insertion. */
77 /* Subroutine of insert_normal. */
79 static CGEN_INLINE void
80 insert_1 (CGEN_CPU_DESC cd,
90 x = cgen_get_insn_value (cd, bufp, word_length);
92 /* Written this way to avoid undefined behaviour. */
93 mask = (((1L << (length - 1)) - 1) << 1) | 1;
95 shift = (start + 1) - length;
97 shift = (word_length - (start + length));
98 x = (x & ~(mask << shift)) | ((value & mask) << shift);
100 cgen_put_insn_value (cd, bufp, word_length, (bfd_vma) x);
103 #endif /* ! CGEN_INT_INSN_P */
105 /* Default insertion routine.
107 ATTRS is a mask of the boolean attributes.
108 WORD_OFFSET is the offset in bits from the start of the insn of the value.
109 WORD_LENGTH is the length of the word in bits in which the value resides.
110 START is the starting bit number in the word, architecture origin.
111 LENGTH is the length of VALUE in bits.
112 TOTAL_LENGTH is the total length of the insn in bits.
114 The result is an error message or NULL if success. */
116 /* ??? This duplicates functionality with bfd's howto table and
117 bfd_install_relocation. */
118 /* ??? This doesn't handle bfd_vma's. Create another function when
122 insert_normal (CGEN_CPU_DESC cd,
125 unsigned int word_offset,
128 unsigned int word_length,
129 unsigned int total_length,
130 CGEN_INSN_BYTES_PTR buffer)
132 static char errbuf[100];
133 /* Written this way to avoid undefined behaviour. */
134 unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
136 /* If LENGTH is zero, this operand doesn't contribute to the value. */
140 if (word_length > 8 * sizeof (CGEN_INSN_INT))
143 /* For architectures with insns smaller than the base-insn-bitsize,
144 word_length may be too big. */
145 if (cd->min_insn_bitsize < cd->base_insn_bitsize)
148 && word_length > total_length)
149 word_length = total_length;
152 /* Ensure VALUE will fit. */
153 if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGN_OPT))
155 long minval = - (1L << (length - 1));
156 unsigned long maxval = mask;
158 if ((value > 0 && (unsigned long) value > maxval)
161 /* xgettext:c-format */
163 _("operand out of range (%ld not between %ld and %lu)"),
164 value, minval, maxval);
168 else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED))
170 unsigned long maxval = mask;
171 unsigned long val = (unsigned long) value;
173 /* For hosts with a word size > 32 check to see if value has been sign
174 extended beyond 32 bits. If so then ignore these higher sign bits
175 as the user is attempting to store a 32-bit signed value into an
176 unsigned 32-bit field which is allowed. */
177 if (sizeof (unsigned long) > 4 && ((value >> 32) == -1))
182 /* xgettext:c-format */
184 _("operand out of range (0x%lx not between 0 and 0x%lx)"),
191 if (! cgen_signed_overflow_ok_p (cd))
193 long minval = - (1L << (length - 1));
194 long maxval = (1L << (length - 1)) - 1;
196 if (value < minval || value > maxval)
199 /* xgettext:c-format */
200 (errbuf, _("operand out of range (%ld not between %ld and %ld)"),
201 value, minval, maxval);
212 if (CGEN_INSN_LSB0_P)
213 shift = (word_offset + start + 1) - length;
215 shift = total_length - (word_offset + start + length);
216 *buffer = (*buffer & ~(mask << shift)) | ((value & mask) << shift);
219 #else /* ! CGEN_INT_INSN_P */
222 unsigned char *bufp = (unsigned char *) buffer + word_offset / 8;
224 insert_1 (cd, value, start, length, word_length, bufp);
227 #endif /* ! CGEN_INT_INSN_P */
232 /* Default insn builder (insert handler).
233 The instruction is recorded in CGEN_INT_INSN_P byte order (meaning
234 that if CGEN_INSN_BYTES_PTR is an int * and thus, the value is
235 recorded in host byte order, otherwise BUFFER is an array of bytes
236 and the value is recorded in target byte order).
237 The result is an error message or NULL if success. */
240 insert_insn_normal (CGEN_CPU_DESC cd,
241 const CGEN_INSN * insn,
242 CGEN_FIELDS * fields,
243 CGEN_INSN_BYTES_PTR buffer,
246 const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
248 const CGEN_SYNTAX_CHAR_TYPE * syn;
250 CGEN_INIT_INSERT (cd);
251 value = CGEN_INSN_BASE_VALUE (insn);
253 /* If we're recording insns as numbers (rather than a string of bytes),
254 target byte order handling is deferred until later. */
258 put_insn_int_value (cd, buffer, cd->base_insn_bitsize,
259 CGEN_FIELDS_BITSIZE (fields), value);
263 cgen_put_insn_value (cd, buffer, min ((unsigned) cd->base_insn_bitsize,
264 (unsigned) CGEN_FIELDS_BITSIZE (fields)),
267 #endif /* ! CGEN_INT_INSN_P */
269 /* ??? It would be better to scan the format's fields.
270 Still need to be able to insert a value based on the operand though;
271 e.g. storing a branch displacement that got resolved later.
272 Needs more thought first. */
274 for (syn = CGEN_SYNTAX_STRING (syntax); * syn; ++ syn)
278 if (CGEN_SYNTAX_CHAR_P (* syn))
281 errmsg = (* cd->insert_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
291 /* Cover function to store an insn value into an integral insn. Must go here
292 because it needs <prefix>-desc.h for CGEN_INT_INSN_P. */
295 put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
296 CGEN_INSN_BYTES_PTR buf,
301 /* For architectures with insns smaller than the base-insn-bitsize,
302 length may be too big. */
303 if (length > insn_length)
307 int shift = insn_length - length;
308 /* Written this way to avoid undefined behaviour. */
309 CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1;
311 *buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
316 /* Operand extraction. */
318 #if ! CGEN_INT_INSN_P
320 /* Subroutine of extract_normal.
321 Ensure sufficient bytes are cached in EX_INFO.
322 OFFSET is the offset in bytes from the start of the insn of the value.
323 BYTES is the length of the needed value.
324 Returns 1 for success, 0 for failure. */
326 static CGEN_INLINE int
327 fill_cache (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
328 CGEN_EXTRACT_INFO *ex_info,
333 /* It's doubtful that the middle part has already been fetched so
334 we don't optimize that case. kiss. */
336 disassemble_info *info = (disassemble_info *) ex_info->dis_info;
338 /* First do a quick check. */
339 mask = (1 << bytes) - 1;
340 if (((ex_info->valid >> offset) & mask) == mask)
343 /* Search for the first byte we need to read. */
344 for (mask = 1 << offset; bytes > 0; --bytes, ++offset, mask <<= 1)
345 if (! (mask & ex_info->valid))
353 status = (*info->read_memory_func)
354 (pc, ex_info->insn_bytes + offset, bytes, info);
358 (*info->memory_error_func) (status, pc, info);
362 ex_info->valid |= ((1 << bytes) - 1) << offset;
368 /* Subroutine of extract_normal. */
370 static CGEN_INLINE long
371 extract_1 (CGEN_CPU_DESC cd,
372 CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED,
377 bfd_vma pc ATTRIBUTE_UNUSED)
382 x = cgen_get_insn_value (cd, bufp, word_length);
384 if (CGEN_INSN_LSB0_P)
385 shift = (start + 1) - length;
387 shift = (word_length - (start + length));
391 #endif /* ! CGEN_INT_INSN_P */
393 /* Default extraction routine.
395 INSN_VALUE is the first base_insn_bitsize bits of the insn in host order,
396 or sometimes less for cases like the m32r where the base insn size is 32
397 but some insns are 16 bits.
398 ATTRS is a mask of the boolean attributes. We only need `SIGNED',
399 but for generality we take a bitmask of all of them.
400 WORD_OFFSET is the offset in bits from the start of the insn of the value.
401 WORD_LENGTH is the length of the word in bits in which the value resides.
402 START is the starting bit number in the word, architecture origin.
403 LENGTH is the length of VALUE in bits.
404 TOTAL_LENGTH is the total length of the insn in bits.
406 Returns 1 for success, 0 for failure. */
408 /* ??? The return code isn't properly used. wip. */
410 /* ??? This doesn't handle bfd_vma's. Create another function when
414 extract_normal (CGEN_CPU_DESC cd,
415 #if ! CGEN_INT_INSN_P
416 CGEN_EXTRACT_INFO *ex_info,
418 CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED,
420 CGEN_INSN_INT insn_value,
422 unsigned int word_offset,
425 unsigned int word_length,
426 unsigned int total_length,
427 #if ! CGEN_INT_INSN_P
430 bfd_vma pc ATTRIBUTE_UNUSED,
436 /* If LENGTH is zero, this operand doesn't contribute to the value
437 so give it a standard value of zero. */
444 if (word_length > 8 * sizeof (CGEN_INSN_INT))
447 /* For architectures with insns smaller than the insn-base-bitsize,
448 word_length may be too big. */
449 if (cd->min_insn_bitsize < cd->base_insn_bitsize)
451 if (word_offset + word_length > total_length)
452 word_length = total_length - word_offset;
455 /* Does the value reside in INSN_VALUE, and at the right alignment? */
457 if (CGEN_INT_INSN_P || (word_offset == 0 && word_length == total_length))
459 if (CGEN_INSN_LSB0_P)
460 value = insn_value >> ((word_offset + start + 1) - length);
462 value = insn_value >> (total_length - ( word_offset + start + length));
465 #if ! CGEN_INT_INSN_P
469 unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
471 if (word_length > 8 * sizeof (CGEN_INSN_INT))
474 if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
477 value = extract_1 (cd, ex_info, start, length, word_length, bufp, pc);
480 #endif /* ! CGEN_INT_INSN_P */
482 /* Written this way to avoid undefined behaviour. */
483 mask = (((1L << (length - 1)) - 1) << 1) | 1;
487 if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)
488 && (value & (1L << (length - 1))))
496 /* Default insn extractor.
498 INSN_VALUE is the first base_insn_bitsize bits, translated to host order.
499 The extracted fields are stored in FIELDS.
500 EX_INFO is used to handle reading variable length insns.
501 Return the length of the insn in bits, or 0 if no match,
502 or -1 if an error occurs fetching data (memory_error_func will have
506 extract_insn_normal (CGEN_CPU_DESC cd,
507 const CGEN_INSN *insn,
508 CGEN_EXTRACT_INFO *ex_info,
509 CGEN_INSN_INT insn_value,
513 const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
514 const CGEN_SYNTAX_CHAR_TYPE *syn;
516 CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn);
518 CGEN_INIT_EXTRACT (cd);
520 for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn)
524 if (CGEN_SYNTAX_CHAR_P (*syn))
527 length = (* cd->extract_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
528 ex_info, insn_value, fields, pc);
533 /* We recognized and successfully extracted this insn. */
534 return CGEN_INSN_BITSIZE (insn);
537 /* Machine generated code added here. */
539 const char * epiphany_cgen_insert_operand
540 (CGEN_CPU_DESC, int, CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma);
542 /* Main entry point for operand insertion.
544 This function is basically just a big switch statement. Earlier versions
545 used tables to look up the function to use, but
546 - if the table contains both assembler and disassembler functions then
547 the disassembler contains much of the assembler and vice-versa,
548 - there's a lot of inlining possibilities as things grow,
549 - using a switch statement avoids the function call overhead.
551 This function could be moved into `parse_insn_normal', but keeping it
552 separate makes clear the interface between `parse_insn_normal' and each of
553 the handlers. It's also needed by GAS to insert operands that couldn't be
554 resolved during parsing. */
557 epiphany_cgen_insert_operand (CGEN_CPU_DESC cd,
559 CGEN_FIELDS * fields,
560 CGEN_INSN_BYTES_PTR buffer,
561 bfd_vma pc ATTRIBUTE_UNUSED)
563 const char * errmsg = NULL;
564 unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
568 case EPIPHANY_OPERAND_DIRECTION :
569 errmsg = insert_normal (cd, fields->f_addsubx, 0, 0, 20, 1, 32, total_length, buffer);
571 case EPIPHANY_OPERAND_DISP11 :
574 FLD (f_disp8) = ((((UINT) (FLD (f_disp11)) >> (3))) & (255));
575 FLD (f_disp3) = ((FLD (f_disp11)) & (7));
577 errmsg = insert_normal (cd, fields->f_disp3, 0, 0, 9, 3, 32, total_length, buffer);
580 errmsg = insert_normal (cd, fields->f_disp8, 0, 0, 23, 8, 32, total_length, buffer);
585 case EPIPHANY_OPERAND_DISP3 :
586 errmsg = insert_normal (cd, fields->f_disp3, 0, 0, 9, 3, 32, total_length, buffer);
588 case EPIPHANY_OPERAND_DPMI :
589 errmsg = insert_normal (cd, fields->f_subd, 0, 0, 24, 1, 32, total_length, buffer);
591 case EPIPHANY_OPERAND_FRD :
592 errmsg = insert_normal (cd, fields->f_rd, 0, 0, 15, 3, 32, total_length, buffer);
594 case EPIPHANY_OPERAND_FRD6 :
597 FLD (f_rd) = ((FLD (f_rd6)) & (7));
598 FLD (f_rd_x) = ((UINT) (FLD (f_rd6)) >> (3));
600 errmsg = insert_normal (cd, fields->f_rd_x, 0, 0, 31, 3, 32, total_length, buffer);
603 errmsg = insert_normal (cd, fields->f_rd, 0, 0, 15, 3, 32, total_length, buffer);
608 case EPIPHANY_OPERAND_FRM :
609 errmsg = insert_normal (cd, fields->f_rm, 0, 0, 9, 3, 32, total_length, buffer);
611 case EPIPHANY_OPERAND_FRM6 :
614 FLD (f_rm) = ((FLD (f_rm6)) & (7));
615 FLD (f_rm_x) = ((UINT) (FLD (f_rm6)) >> (3));
617 errmsg = insert_normal (cd, fields->f_rm_x, 0, 0, 25, 3, 32, total_length, buffer);
620 errmsg = insert_normal (cd, fields->f_rm, 0, 0, 9, 3, 32, total_length, buffer);
625 case EPIPHANY_OPERAND_FRN :
626 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 12, 3, 32, total_length, buffer);
628 case EPIPHANY_OPERAND_FRN6 :
631 FLD (f_rn) = ((FLD (f_rn6)) & (7));
632 FLD (f_rn_x) = ((UINT) (FLD (f_rn6)) >> (3));
634 errmsg = insert_normal (cd, fields->f_rn_x, 0, 0, 28, 3, 32, total_length, buffer);
637 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 12, 3, 32, total_length, buffer);
642 case EPIPHANY_OPERAND_IMM16 :
645 FLD (f_imm8) = ((FLD (f_imm16)) & (255));
646 FLD (f_imm_27_8) = ((UINT) (FLD (f_imm16)) >> (8));
648 errmsg = insert_normal (cd, fields->f_imm8, 0, 0, 12, 8, 32, total_length, buffer);
651 errmsg = insert_normal (cd, fields->f_imm_27_8, 0, 0, 27, 8, 32, total_length, buffer);
656 case EPIPHANY_OPERAND_IMM8 :
657 errmsg = insert_normal (cd, fields->f_imm8, 0, 0, 12, 8, 32, total_length, buffer);
659 case EPIPHANY_OPERAND_RD :
660 errmsg = insert_normal (cd, fields->f_rd, 0, 0, 15, 3, 32, total_length, buffer);
662 case EPIPHANY_OPERAND_RD6 :
665 FLD (f_rd) = ((FLD (f_rd6)) & (7));
666 FLD (f_rd_x) = ((UINT) (FLD (f_rd6)) >> (3));
668 errmsg = insert_normal (cd, fields->f_rd_x, 0, 0, 31, 3, 32, total_length, buffer);
671 errmsg = insert_normal (cd, fields->f_rd, 0, 0, 15, 3, 32, total_length, buffer);
676 case EPIPHANY_OPERAND_RM :
677 errmsg = insert_normal (cd, fields->f_rm, 0, 0, 9, 3, 32, total_length, buffer);
679 case EPIPHANY_OPERAND_RM6 :
682 FLD (f_rm) = ((FLD (f_rm6)) & (7));
683 FLD (f_rm_x) = ((UINT) (FLD (f_rm6)) >> (3));
685 errmsg = insert_normal (cd, fields->f_rm_x, 0, 0, 25, 3, 32, total_length, buffer);
688 errmsg = insert_normal (cd, fields->f_rm, 0, 0, 9, 3, 32, total_length, buffer);
693 case EPIPHANY_OPERAND_RN :
694 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 12, 3, 32, total_length, buffer);
696 case EPIPHANY_OPERAND_RN6 :
699 FLD (f_rn) = ((FLD (f_rn6)) & (7));
700 FLD (f_rn_x) = ((UINT) (FLD (f_rn6)) >> (3));
702 errmsg = insert_normal (cd, fields->f_rn_x, 0, 0, 28, 3, 32, total_length, buffer);
705 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 12, 3, 32, total_length, buffer);
710 case EPIPHANY_OPERAND_SD :
711 errmsg = insert_normal (cd, fields->f_sd, 0, 0, 15, 3, 32, total_length, buffer);
713 case EPIPHANY_OPERAND_SD6 :
716 FLD (f_sd) = ((FLD (f_sd6)) & (7));
717 FLD (f_sd_x) = ((UINT) (FLD (f_sd6)) >> (3));
719 errmsg = insert_normal (cd, fields->f_sd_x, 0, 0, 31, 3, 32, total_length, buffer);
722 errmsg = insert_normal (cd, fields->f_sd, 0, 0, 15, 3, 32, total_length, buffer);
727 case EPIPHANY_OPERAND_SDDMA :
730 FLD (f_sd) = ((FLD (f_sd6)) & (7));
731 FLD (f_sd_x) = ((UINT) (FLD (f_sd6)) >> (3));
733 errmsg = insert_normal (cd, fields->f_sd_x, 0, 0, 31, 3, 32, total_length, buffer);
736 errmsg = insert_normal (cd, fields->f_sd, 0, 0, 15, 3, 32, total_length, buffer);
741 case EPIPHANY_OPERAND_SDMEM :
744 FLD (f_sd) = ((FLD (f_sd6)) & (7));
745 FLD (f_sd_x) = ((UINT) (FLD (f_sd6)) >> (3));
747 errmsg = insert_normal (cd, fields->f_sd_x, 0, 0, 31, 3, 32, total_length, buffer);
750 errmsg = insert_normal (cd, fields->f_sd, 0, 0, 15, 3, 32, total_length, buffer);
755 case EPIPHANY_OPERAND_SDMESH :
758 FLD (f_sd) = ((FLD (f_sd6)) & (7));
759 FLD (f_sd_x) = ((UINT) (FLD (f_sd6)) >> (3));
761 errmsg = insert_normal (cd, fields->f_sd_x, 0, 0, 31, 3, 32, total_length, buffer);
764 errmsg = insert_normal (cd, fields->f_sd, 0, 0, 15, 3, 32, total_length, buffer);
769 case EPIPHANY_OPERAND_SHIFT :
770 errmsg = insert_normal (cd, fields->f_shift, 0, 0, 9, 5, 32, total_length, buffer);
772 case EPIPHANY_OPERAND_SIMM11 :
775 FLD (f_disp8) = ((255) & (((USI) (FLD (f_sdisp11)) >> (3))));
776 FLD (f_disp3) = ((FLD (f_sdisp11)) & (7));
778 errmsg = insert_normal (cd, fields->f_disp3, 0, 0, 9, 3, 32, total_length, buffer);
781 errmsg = insert_normal (cd, fields->f_disp8, 0, 0, 23, 8, 32, total_length, buffer);
786 case EPIPHANY_OPERAND_SIMM24 :
788 long value = fields->f_simm24;
789 value = ((SI) (((value) - (pc))) >> (1));
790 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);
793 case EPIPHANY_OPERAND_SIMM3 :
794 errmsg = insert_normal (cd, fields->f_sdisp3, 0|(1<<CGEN_IFLD_SIGNED), 0, 9, 3, 32, total_length, buffer);
796 case EPIPHANY_OPERAND_SIMM8 :
798 long value = fields->f_simm8;
799 value = ((SI) (((value) - (pc))) >> (1));
800 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);
803 case EPIPHANY_OPERAND_SN :
804 errmsg = insert_normal (cd, fields->f_sn, 0, 0, 12, 3, 32, total_length, buffer);
806 case EPIPHANY_OPERAND_SN6 :
809 FLD (f_sn) = ((FLD (f_sn6)) & (7));
810 FLD (f_sn_x) = ((UINT) (FLD (f_sn6)) >> (3));
812 errmsg = insert_normal (cd, fields->f_sn_x, 0, 0, 28, 3, 32, total_length, buffer);
815 errmsg = insert_normal (cd, fields->f_sn, 0, 0, 12, 3, 32, total_length, buffer);
820 case EPIPHANY_OPERAND_SNDMA :
823 FLD (f_sn) = ((FLD (f_sn6)) & (7));
824 FLD (f_sn_x) = ((UINT) (FLD (f_sn6)) >> (3));
826 errmsg = insert_normal (cd, fields->f_sn_x, 0, 0, 28, 3, 32, total_length, buffer);
829 errmsg = insert_normal (cd, fields->f_sn, 0, 0, 12, 3, 32, total_length, buffer);
834 case EPIPHANY_OPERAND_SNMEM :
837 FLD (f_sn) = ((FLD (f_sn6)) & (7));
838 FLD (f_sn_x) = ((UINT) (FLD (f_sn6)) >> (3));
840 errmsg = insert_normal (cd, fields->f_sn_x, 0, 0, 28, 3, 32, total_length, buffer);
843 errmsg = insert_normal (cd, fields->f_sn, 0, 0, 12, 3, 32, total_length, buffer);
848 case EPIPHANY_OPERAND_SNMESH :
851 FLD (f_sn) = ((FLD (f_sn6)) & (7));
852 FLD (f_sn_x) = ((UINT) (FLD (f_sn6)) >> (3));
854 errmsg = insert_normal (cd, fields->f_sn_x, 0, 0, 28, 3, 32, total_length, buffer);
857 errmsg = insert_normal (cd, fields->f_sn, 0, 0, 12, 3, 32, total_length, buffer);
862 case EPIPHANY_OPERAND_SWI_NUM :
863 errmsg = insert_normal (cd, fields->f_trap_num, 0, 0, 15, 6, 32, total_length, buffer);
865 case EPIPHANY_OPERAND_TRAPNUM6 :
866 errmsg = insert_normal (cd, fields->f_trap_num, 0, 0, 15, 6, 32, total_length, buffer);
870 /* xgettext:c-format */
871 fprintf (stderr, _("Unrecognized field %d while building insn.\n"),
879 int epiphany_cgen_extract_operand
880 (CGEN_CPU_DESC, int, CGEN_EXTRACT_INFO *, CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma);
882 /* Main entry point for operand extraction.
883 The result is <= 0 for error, >0 for success.
884 ??? Actual values aren't well defined right now.
886 This function is basically just a big switch statement. Earlier versions
887 used tables to look up the function to use, but
888 - if the table contains both assembler and disassembler functions then
889 the disassembler contains much of the assembler and vice-versa,
890 - there's a lot of inlining possibilities as things grow,
891 - using a switch statement avoids the function call overhead.
893 This function could be moved into `print_insn_normal', but keeping it
894 separate makes clear the interface between `print_insn_normal' and each of
898 epiphany_cgen_extract_operand (CGEN_CPU_DESC cd,
900 CGEN_EXTRACT_INFO *ex_info,
901 CGEN_INSN_INT insn_value,
902 CGEN_FIELDS * fields,
905 /* Assume success (for those operands that are nops). */
907 unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
911 case EPIPHANY_OPERAND_DIRECTION :
912 length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 1, 32, total_length, pc, & fields->f_addsubx);
914 case EPIPHANY_OPERAND_DISP11 :
916 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_disp3);
917 if (length <= 0) break;
918 length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 8, 32, total_length, pc, & fields->f_disp8);
919 if (length <= 0) break;
921 FLD (f_disp11) = ((((FLD (f_disp8)) << (3))) | (FLD (f_disp3)));
925 case EPIPHANY_OPERAND_DISP3 :
926 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_disp3);
928 case EPIPHANY_OPERAND_DPMI :
929 length = extract_normal (cd, ex_info, insn_value, 0, 0, 24, 1, 32, total_length, pc, & fields->f_subd);
931 case EPIPHANY_OPERAND_FRD :
932 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_rd);
934 case EPIPHANY_OPERAND_FRD6 :
936 length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 3, 32, total_length, pc, & fields->f_rd_x);
937 if (length <= 0) break;
938 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_rd);
939 if (length <= 0) break;
941 FLD (f_rd6) = ((((FLD (f_rd_x)) << (3))) | (FLD (f_rd)));
945 case EPIPHANY_OPERAND_FRM :
946 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_rm);
948 case EPIPHANY_OPERAND_FRM6 :
950 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 3, 32, total_length, pc, & fields->f_rm_x);
951 if (length <= 0) break;
952 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_rm);
953 if (length <= 0) break;
955 FLD (f_rm6) = ((((FLD (f_rm_x)) << (3))) | (FLD (f_rm)));
959 case EPIPHANY_OPERAND_FRN :
960 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_rn);
962 case EPIPHANY_OPERAND_FRN6 :
964 length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 3, 32, total_length, pc, & fields->f_rn_x);
965 if (length <= 0) break;
966 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_rn);
967 if (length <= 0) break;
969 FLD (f_rn6) = ((((FLD (f_rn_x)) << (3))) | (FLD (f_rn)));
973 case EPIPHANY_OPERAND_IMM16 :
975 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 8, 32, total_length, pc, & fields->f_imm8);
976 if (length <= 0) break;
977 length = extract_normal (cd, ex_info, insn_value, 0, 0, 27, 8, 32, total_length, pc, & fields->f_imm_27_8);
978 if (length <= 0) break;
980 FLD (f_imm16) = ((((FLD (f_imm_27_8)) << (8))) | (FLD (f_imm8)));
984 case EPIPHANY_OPERAND_IMM8 :
985 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 8, 32, total_length, pc, & fields->f_imm8);
987 case EPIPHANY_OPERAND_RD :
988 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_rd);
990 case EPIPHANY_OPERAND_RD6 :
992 length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 3, 32, total_length, pc, & fields->f_rd_x);
993 if (length <= 0) break;
994 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_rd);
995 if (length <= 0) break;
997 FLD (f_rd6) = ((((FLD (f_rd_x)) << (3))) | (FLD (f_rd)));
1001 case EPIPHANY_OPERAND_RM :
1002 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_rm);
1004 case EPIPHANY_OPERAND_RM6 :
1006 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 3, 32, total_length, pc, & fields->f_rm_x);
1007 if (length <= 0) break;
1008 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_rm);
1009 if (length <= 0) break;
1011 FLD (f_rm6) = ((((FLD (f_rm_x)) << (3))) | (FLD (f_rm)));
1015 case EPIPHANY_OPERAND_RN :
1016 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_rn);
1018 case EPIPHANY_OPERAND_RN6 :
1020 length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 3, 32, total_length, pc, & fields->f_rn_x);
1021 if (length <= 0) break;
1022 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_rn);
1023 if (length <= 0) break;
1025 FLD (f_rn6) = ((((FLD (f_rn_x)) << (3))) | (FLD (f_rn)));
1029 case EPIPHANY_OPERAND_SD :
1030 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_sd);
1032 case EPIPHANY_OPERAND_SD6 :
1034 length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 3, 32, total_length, pc, & fields->f_sd_x);
1035 if (length <= 0) break;
1036 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_sd);
1037 if (length <= 0) break;
1039 FLD (f_sd6) = ((((FLD (f_sd_x)) << (3))) | (FLD (f_sd)));
1043 case EPIPHANY_OPERAND_SDDMA :
1045 length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 3, 32, total_length, pc, & fields->f_sd_x);
1046 if (length <= 0) break;
1047 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_sd);
1048 if (length <= 0) break;
1050 FLD (f_sd6) = ((((FLD (f_sd_x)) << (3))) | (FLD (f_sd)));
1054 case EPIPHANY_OPERAND_SDMEM :
1056 length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 3, 32, total_length, pc, & fields->f_sd_x);
1057 if (length <= 0) break;
1058 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_sd);
1059 if (length <= 0) break;
1061 FLD (f_sd6) = ((((FLD (f_sd_x)) << (3))) | (FLD (f_sd)));
1065 case EPIPHANY_OPERAND_SDMESH :
1067 length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 3, 32, total_length, pc, & fields->f_sd_x);
1068 if (length <= 0) break;
1069 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_sd);
1070 if (length <= 0) break;
1072 FLD (f_sd6) = ((((FLD (f_sd_x)) << (3))) | (FLD (f_sd)));
1076 case EPIPHANY_OPERAND_SHIFT :
1077 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 5, 32, total_length, pc, & fields->f_shift);
1079 case EPIPHANY_OPERAND_SIMM11 :
1081 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_disp3);
1082 if (length <= 0) break;
1083 length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 8, 32, total_length, pc, & fields->f_disp8);
1084 if (length <= 0) break;
1086 FLD (f_sdisp11) = ((SI) (((((((FLD (f_disp8)) << (3))) | (FLD (f_disp3)))) << (21))) >> (21));
1090 case EPIPHANY_OPERAND_SIMM24 :
1093 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);
1094 value = ((((value) << (1))) + (pc));
1095 fields->f_simm24 = value;
1098 case EPIPHANY_OPERAND_SIMM3 :
1099 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 9, 3, 32, total_length, pc, & fields->f_sdisp3);
1101 case EPIPHANY_OPERAND_SIMM8 :
1104 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);
1105 value = ((((value) << (1))) + (pc));
1106 fields->f_simm8 = value;
1109 case EPIPHANY_OPERAND_SN :
1110 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_sn);
1112 case EPIPHANY_OPERAND_SN6 :
1114 length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 3, 32, total_length, pc, & fields->f_sn_x);
1115 if (length <= 0) break;
1116 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_sn);
1117 if (length <= 0) break;
1119 FLD (f_sn6) = ((((FLD (f_sn_x)) << (3))) | (FLD (f_sn)));
1123 case EPIPHANY_OPERAND_SNDMA :
1125 length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 3, 32, total_length, pc, & fields->f_sn_x);
1126 if (length <= 0) break;
1127 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_sn);
1128 if (length <= 0) break;
1130 FLD (f_sn6) = ((((FLD (f_sn_x)) << (3))) | (FLD (f_sn)));
1134 case EPIPHANY_OPERAND_SNMEM :
1136 length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 3, 32, total_length, pc, & fields->f_sn_x);
1137 if (length <= 0) break;
1138 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_sn);
1139 if (length <= 0) break;
1141 FLD (f_sn6) = ((((FLD (f_sn_x)) << (3))) | (FLD (f_sn)));
1145 case EPIPHANY_OPERAND_SNMESH :
1147 length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 3, 32, total_length, pc, & fields->f_sn_x);
1148 if (length <= 0) break;
1149 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_sn);
1150 if (length <= 0) break;
1152 FLD (f_sn6) = ((((FLD (f_sn_x)) << (3))) | (FLD (f_sn)));
1156 case EPIPHANY_OPERAND_SWI_NUM :
1157 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 6, 32, total_length, pc, & fields->f_trap_num);
1159 case EPIPHANY_OPERAND_TRAPNUM6 :
1160 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 6, 32, total_length, pc, & fields->f_trap_num);
1164 /* xgettext:c-format */
1165 fprintf (stderr, _("Unrecognized field %d while decoding insn.\n"),
1173 cgen_insert_fn * const epiphany_cgen_insert_handlers[] =
1178 cgen_extract_fn * const epiphany_cgen_extract_handlers[] =
1180 extract_insn_normal,
1183 int epiphany_cgen_get_int_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *);
1184 bfd_vma epiphany_cgen_get_vma_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *);
1186 /* Getting values from cgen_fields is handled by a collection of functions.
1187 They are distinguished by the type of the VALUE argument they return.
1188 TODO: floating point, inlining support, remove cases where result type
1192 epiphany_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1194 const CGEN_FIELDS * fields)
1200 case EPIPHANY_OPERAND_DIRECTION :
1201 value = fields->f_addsubx;
1203 case EPIPHANY_OPERAND_DISP11 :
1204 value = fields->f_disp11;
1206 case EPIPHANY_OPERAND_DISP3 :
1207 value = fields->f_disp3;
1209 case EPIPHANY_OPERAND_DPMI :
1210 value = fields->f_subd;
1212 case EPIPHANY_OPERAND_FRD :
1213 value = fields->f_rd;
1215 case EPIPHANY_OPERAND_FRD6 :
1216 value = fields->f_rd6;
1218 case EPIPHANY_OPERAND_FRM :
1219 value = fields->f_rm;
1221 case EPIPHANY_OPERAND_FRM6 :
1222 value = fields->f_rm6;
1224 case EPIPHANY_OPERAND_FRN :
1225 value = fields->f_rn;
1227 case EPIPHANY_OPERAND_FRN6 :
1228 value = fields->f_rn6;
1230 case EPIPHANY_OPERAND_IMM16 :
1231 value = fields->f_imm16;
1233 case EPIPHANY_OPERAND_IMM8 :
1234 value = fields->f_imm8;
1236 case EPIPHANY_OPERAND_RD :
1237 value = fields->f_rd;
1239 case EPIPHANY_OPERAND_RD6 :
1240 value = fields->f_rd6;
1242 case EPIPHANY_OPERAND_RM :
1243 value = fields->f_rm;
1245 case EPIPHANY_OPERAND_RM6 :
1246 value = fields->f_rm6;
1248 case EPIPHANY_OPERAND_RN :
1249 value = fields->f_rn;
1251 case EPIPHANY_OPERAND_RN6 :
1252 value = fields->f_rn6;
1254 case EPIPHANY_OPERAND_SD :
1255 value = fields->f_sd;
1257 case EPIPHANY_OPERAND_SD6 :
1258 value = fields->f_sd6;
1260 case EPIPHANY_OPERAND_SDDMA :
1261 value = fields->f_sd6;
1263 case EPIPHANY_OPERAND_SDMEM :
1264 value = fields->f_sd6;
1266 case EPIPHANY_OPERAND_SDMESH :
1267 value = fields->f_sd6;
1269 case EPIPHANY_OPERAND_SHIFT :
1270 value = fields->f_shift;
1272 case EPIPHANY_OPERAND_SIMM11 :
1273 value = fields->f_sdisp11;
1275 case EPIPHANY_OPERAND_SIMM24 :
1276 value = fields->f_simm24;
1278 case EPIPHANY_OPERAND_SIMM3 :
1279 value = fields->f_sdisp3;
1281 case EPIPHANY_OPERAND_SIMM8 :
1282 value = fields->f_simm8;
1284 case EPIPHANY_OPERAND_SN :
1285 value = fields->f_sn;
1287 case EPIPHANY_OPERAND_SN6 :
1288 value = fields->f_sn6;
1290 case EPIPHANY_OPERAND_SNDMA :
1291 value = fields->f_sn6;
1293 case EPIPHANY_OPERAND_SNMEM :
1294 value = fields->f_sn6;
1296 case EPIPHANY_OPERAND_SNMESH :
1297 value = fields->f_sn6;
1299 case EPIPHANY_OPERAND_SWI_NUM :
1300 value = fields->f_trap_num;
1302 case EPIPHANY_OPERAND_TRAPNUM6 :
1303 value = fields->f_trap_num;
1307 /* xgettext:c-format */
1308 fprintf (stderr, _("Unrecognized field %d while getting int operand.\n"),
1317 epiphany_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1319 const CGEN_FIELDS * fields)
1325 case EPIPHANY_OPERAND_DIRECTION :
1326 value = fields->f_addsubx;
1328 case EPIPHANY_OPERAND_DISP11 :
1329 value = fields->f_disp11;
1331 case EPIPHANY_OPERAND_DISP3 :
1332 value = fields->f_disp3;
1334 case EPIPHANY_OPERAND_DPMI :
1335 value = fields->f_subd;
1337 case EPIPHANY_OPERAND_FRD :
1338 value = fields->f_rd;
1340 case EPIPHANY_OPERAND_FRD6 :
1341 value = fields->f_rd6;
1343 case EPIPHANY_OPERAND_FRM :
1344 value = fields->f_rm;
1346 case EPIPHANY_OPERAND_FRM6 :
1347 value = fields->f_rm6;
1349 case EPIPHANY_OPERAND_FRN :
1350 value = fields->f_rn;
1352 case EPIPHANY_OPERAND_FRN6 :
1353 value = fields->f_rn6;
1355 case EPIPHANY_OPERAND_IMM16 :
1356 value = fields->f_imm16;
1358 case EPIPHANY_OPERAND_IMM8 :
1359 value = fields->f_imm8;
1361 case EPIPHANY_OPERAND_RD :
1362 value = fields->f_rd;
1364 case EPIPHANY_OPERAND_RD6 :
1365 value = fields->f_rd6;
1367 case EPIPHANY_OPERAND_RM :
1368 value = fields->f_rm;
1370 case EPIPHANY_OPERAND_RM6 :
1371 value = fields->f_rm6;
1373 case EPIPHANY_OPERAND_RN :
1374 value = fields->f_rn;
1376 case EPIPHANY_OPERAND_RN6 :
1377 value = fields->f_rn6;
1379 case EPIPHANY_OPERAND_SD :
1380 value = fields->f_sd;
1382 case EPIPHANY_OPERAND_SD6 :
1383 value = fields->f_sd6;
1385 case EPIPHANY_OPERAND_SDDMA :
1386 value = fields->f_sd6;
1388 case EPIPHANY_OPERAND_SDMEM :
1389 value = fields->f_sd6;
1391 case EPIPHANY_OPERAND_SDMESH :
1392 value = fields->f_sd6;
1394 case EPIPHANY_OPERAND_SHIFT :
1395 value = fields->f_shift;
1397 case EPIPHANY_OPERAND_SIMM11 :
1398 value = fields->f_sdisp11;
1400 case EPIPHANY_OPERAND_SIMM24 :
1401 value = fields->f_simm24;
1403 case EPIPHANY_OPERAND_SIMM3 :
1404 value = fields->f_sdisp3;
1406 case EPIPHANY_OPERAND_SIMM8 :
1407 value = fields->f_simm8;
1409 case EPIPHANY_OPERAND_SN :
1410 value = fields->f_sn;
1412 case EPIPHANY_OPERAND_SN6 :
1413 value = fields->f_sn6;
1415 case EPIPHANY_OPERAND_SNDMA :
1416 value = fields->f_sn6;
1418 case EPIPHANY_OPERAND_SNMEM :
1419 value = fields->f_sn6;
1421 case EPIPHANY_OPERAND_SNMESH :
1422 value = fields->f_sn6;
1424 case EPIPHANY_OPERAND_SWI_NUM :
1425 value = fields->f_trap_num;
1427 case EPIPHANY_OPERAND_TRAPNUM6 :
1428 value = fields->f_trap_num;
1432 /* xgettext:c-format */
1433 fprintf (stderr, _("Unrecognized field %d while getting vma operand.\n"),
1441 void epiphany_cgen_set_int_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, int);
1442 void epiphany_cgen_set_vma_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, bfd_vma);
1444 /* Stuffing values in cgen_fields is handled by a collection of functions.
1445 They are distinguished by the type of the VALUE argument they accept.
1446 TODO: floating point, inlining support, remove cases where argument type
1450 epiphany_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1452 CGEN_FIELDS * fields,
1457 case EPIPHANY_OPERAND_DIRECTION :
1458 fields->f_addsubx = value;
1460 case EPIPHANY_OPERAND_DISP11 :
1461 fields->f_disp11 = value;
1463 case EPIPHANY_OPERAND_DISP3 :
1464 fields->f_disp3 = value;
1466 case EPIPHANY_OPERAND_DPMI :
1467 fields->f_subd = value;
1469 case EPIPHANY_OPERAND_FRD :
1470 fields->f_rd = value;
1472 case EPIPHANY_OPERAND_FRD6 :
1473 fields->f_rd6 = value;
1475 case EPIPHANY_OPERAND_FRM :
1476 fields->f_rm = value;
1478 case EPIPHANY_OPERAND_FRM6 :
1479 fields->f_rm6 = value;
1481 case EPIPHANY_OPERAND_FRN :
1482 fields->f_rn = value;
1484 case EPIPHANY_OPERAND_FRN6 :
1485 fields->f_rn6 = value;
1487 case EPIPHANY_OPERAND_IMM16 :
1488 fields->f_imm16 = value;
1490 case EPIPHANY_OPERAND_IMM8 :
1491 fields->f_imm8 = value;
1493 case EPIPHANY_OPERAND_RD :
1494 fields->f_rd = value;
1496 case EPIPHANY_OPERAND_RD6 :
1497 fields->f_rd6 = value;
1499 case EPIPHANY_OPERAND_RM :
1500 fields->f_rm = value;
1502 case EPIPHANY_OPERAND_RM6 :
1503 fields->f_rm6 = value;
1505 case EPIPHANY_OPERAND_RN :
1506 fields->f_rn = value;
1508 case EPIPHANY_OPERAND_RN6 :
1509 fields->f_rn6 = value;
1511 case EPIPHANY_OPERAND_SD :
1512 fields->f_sd = value;
1514 case EPIPHANY_OPERAND_SD6 :
1515 fields->f_sd6 = value;
1517 case EPIPHANY_OPERAND_SDDMA :
1518 fields->f_sd6 = value;
1520 case EPIPHANY_OPERAND_SDMEM :
1521 fields->f_sd6 = value;
1523 case EPIPHANY_OPERAND_SDMESH :
1524 fields->f_sd6 = value;
1526 case EPIPHANY_OPERAND_SHIFT :
1527 fields->f_shift = value;
1529 case EPIPHANY_OPERAND_SIMM11 :
1530 fields->f_sdisp11 = value;
1532 case EPIPHANY_OPERAND_SIMM24 :
1533 fields->f_simm24 = value;
1535 case EPIPHANY_OPERAND_SIMM3 :
1536 fields->f_sdisp3 = value;
1538 case EPIPHANY_OPERAND_SIMM8 :
1539 fields->f_simm8 = value;
1541 case EPIPHANY_OPERAND_SN :
1542 fields->f_sn = value;
1544 case EPIPHANY_OPERAND_SN6 :
1545 fields->f_sn6 = value;
1547 case EPIPHANY_OPERAND_SNDMA :
1548 fields->f_sn6 = value;
1550 case EPIPHANY_OPERAND_SNMEM :
1551 fields->f_sn6 = value;
1553 case EPIPHANY_OPERAND_SNMESH :
1554 fields->f_sn6 = value;
1556 case EPIPHANY_OPERAND_SWI_NUM :
1557 fields->f_trap_num = value;
1559 case EPIPHANY_OPERAND_TRAPNUM6 :
1560 fields->f_trap_num = value;
1564 /* xgettext:c-format */
1565 fprintf (stderr, _("Unrecognized field %d while setting int operand.\n"),
1572 epiphany_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1574 CGEN_FIELDS * fields,
1579 case EPIPHANY_OPERAND_DIRECTION :
1580 fields->f_addsubx = value;
1582 case EPIPHANY_OPERAND_DISP11 :
1583 fields->f_disp11 = value;
1585 case EPIPHANY_OPERAND_DISP3 :
1586 fields->f_disp3 = value;
1588 case EPIPHANY_OPERAND_DPMI :
1589 fields->f_subd = value;
1591 case EPIPHANY_OPERAND_FRD :
1592 fields->f_rd = value;
1594 case EPIPHANY_OPERAND_FRD6 :
1595 fields->f_rd6 = value;
1597 case EPIPHANY_OPERAND_FRM :
1598 fields->f_rm = value;
1600 case EPIPHANY_OPERAND_FRM6 :
1601 fields->f_rm6 = value;
1603 case EPIPHANY_OPERAND_FRN :
1604 fields->f_rn = value;
1606 case EPIPHANY_OPERAND_FRN6 :
1607 fields->f_rn6 = value;
1609 case EPIPHANY_OPERAND_IMM16 :
1610 fields->f_imm16 = value;
1612 case EPIPHANY_OPERAND_IMM8 :
1613 fields->f_imm8 = value;
1615 case EPIPHANY_OPERAND_RD :
1616 fields->f_rd = value;
1618 case EPIPHANY_OPERAND_RD6 :
1619 fields->f_rd6 = value;
1621 case EPIPHANY_OPERAND_RM :
1622 fields->f_rm = value;
1624 case EPIPHANY_OPERAND_RM6 :
1625 fields->f_rm6 = value;
1627 case EPIPHANY_OPERAND_RN :
1628 fields->f_rn = value;
1630 case EPIPHANY_OPERAND_RN6 :
1631 fields->f_rn6 = value;
1633 case EPIPHANY_OPERAND_SD :
1634 fields->f_sd = value;
1636 case EPIPHANY_OPERAND_SD6 :
1637 fields->f_sd6 = value;
1639 case EPIPHANY_OPERAND_SDDMA :
1640 fields->f_sd6 = value;
1642 case EPIPHANY_OPERAND_SDMEM :
1643 fields->f_sd6 = value;
1645 case EPIPHANY_OPERAND_SDMESH :
1646 fields->f_sd6 = value;
1648 case EPIPHANY_OPERAND_SHIFT :
1649 fields->f_shift = value;
1651 case EPIPHANY_OPERAND_SIMM11 :
1652 fields->f_sdisp11 = value;
1654 case EPIPHANY_OPERAND_SIMM24 :
1655 fields->f_simm24 = value;
1657 case EPIPHANY_OPERAND_SIMM3 :
1658 fields->f_sdisp3 = value;
1660 case EPIPHANY_OPERAND_SIMM8 :
1661 fields->f_simm8 = value;
1663 case EPIPHANY_OPERAND_SN :
1664 fields->f_sn = value;
1666 case EPIPHANY_OPERAND_SN6 :
1667 fields->f_sn6 = value;
1669 case EPIPHANY_OPERAND_SNDMA :
1670 fields->f_sn6 = value;
1672 case EPIPHANY_OPERAND_SNMEM :
1673 fields->f_sn6 = value;
1675 case EPIPHANY_OPERAND_SNMESH :
1676 fields->f_sn6 = value;
1678 case EPIPHANY_OPERAND_SWI_NUM :
1679 fields->f_trap_num = value;
1681 case EPIPHANY_OPERAND_TRAPNUM6 :
1682 fields->f_trap_num = value;
1686 /* xgettext:c-format */
1687 fprintf (stderr, _("Unrecognized field %d while setting vma operand.\n"),
1693 /* Function to call before using the instruction builder tables. */
1696 epiphany_cgen_init_ibld_table (CGEN_CPU_DESC cd)
1698 cd->insert_handlers = & epiphany_cgen_insert_handlers[0];
1699 cd->extract_handlers = & epiphany_cgen_extract_handlers[0];
1701 cd->insert_operand = epiphany_cgen_insert_operand;
1702 cd->extract_operand = epiphany_cgen_extract_operand;
1704 cd->get_int_operand = epiphany_cgen_get_int_operand;
1705 cd->set_int_operand = epiphany_cgen_set_int_operand;
1706 cd->get_vma_operand = epiphany_cgen_get_vma_operand;
1707 cd->set_vma_operand = epiphany_cgen_set_vma_operand;