1 /* DO NOT EDIT! -*- buffer-read-only: t -*- vi:set ro: */
2 /* Instruction building/extraction support for epiphany. -*- C -*-
4 THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator.
5 - the resultant file is machine generated, cgen-ibld.in isn't
7 Copyright (C) 1996-2024 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
,
88 unsigned long x
, mask
;
91 x
= cgen_get_insn_value (cd
, bufp
, word_length
, cd
->endian
);
93 /* Written this way to avoid undefined behaviour. */
94 mask
= (1UL << (length
- 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
, cd
->endian
);
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];
136 /* If LENGTH is zero, this operand doesn't contribute to the value. */
140 /* Written this way to avoid undefined behaviour. */
141 mask
= (1UL << (length
- 1) << 1) - 1;
143 if (word_length
> 8 * sizeof (CGEN_INSN_INT
))
146 /* For architectures with insns smaller than the base-insn-bitsize,
147 word_length may be too big. */
148 if (cd
->min_insn_bitsize
< cd
->base_insn_bitsize
)
151 && word_length
> total_length
)
152 word_length
= total_length
;
155 /* Ensure VALUE will fit. */
156 if (CGEN_BOOL_ATTR (attrs
, CGEN_IFLD_SIGN_OPT
))
158 long minval
= - (1UL << (length
- 1));
159 unsigned long maxval
= mask
;
161 if ((value
> 0 && (unsigned long) value
> maxval
)
164 /* xgettext:c-format */
166 _("operand out of range (%ld not between %ld and %lu)"),
167 value
, minval
, maxval
);
171 else if (! CGEN_BOOL_ATTR (attrs
, CGEN_IFLD_SIGNED
))
173 unsigned long maxval
= mask
;
174 unsigned long val
= (unsigned long) value
;
176 /* For hosts with a word size > 32 check to see if value has been sign
177 extended beyond 32 bits. If so then ignore these higher sign bits
178 as the user is attempting to store a 32-bit signed value into an
179 unsigned 32-bit field which is allowed. */
180 if (sizeof (unsigned long) > 4 && ((value
>> 32) == -1))
185 /* xgettext:c-format */
187 _("operand out of range (0x%lx not between 0 and 0x%lx)"),
194 if (! cgen_signed_overflow_ok_p (cd
))
196 long minval
= - (1UL << (length
- 1));
197 long maxval
= (1UL << (length
- 1)) - 1;
199 if (value
< minval
|| value
> maxval
)
202 /* xgettext:c-format */
203 (errbuf
, _("operand out of range (%ld not between %ld and %ld)"),
204 value
, minval
, maxval
);
213 int shift_within_word
, shift_to_word
, shift
;
215 /* How to shift the value to BIT0 of the word. */
216 shift_to_word
= total_length
- (word_offset
+ word_length
);
218 /* How to shift the value to the field within the word. */
219 if (CGEN_INSN_LSB0_P
)
220 shift_within_word
= start
+ 1 - length
;
222 shift_within_word
= word_length
- start
- length
;
224 /* The total SHIFT, then mask in the value. */
225 shift
= shift_to_word
+ shift_within_word
;
226 *buffer
= (*buffer
& ~(mask
<< shift
)) | ((value
& mask
) << shift
);
229 #else /* ! CGEN_INT_INSN_P */
232 unsigned char *bufp
= (unsigned char *) buffer
+ word_offset
/ 8;
234 insert_1 (cd
, value
, start
, length
, word_length
, bufp
);
237 #endif /* ! CGEN_INT_INSN_P */
242 /* Default insn builder (insert handler).
243 The instruction is recorded in CGEN_INT_INSN_P byte order (meaning
244 that if CGEN_INSN_BYTES_PTR is an int * and thus, the value is
245 recorded in host byte order, otherwise BUFFER is an array of bytes
246 and the value is recorded in target byte order).
247 The result is an error message or NULL if success. */
250 insert_insn_normal (CGEN_CPU_DESC cd
,
251 const CGEN_INSN
* insn
,
252 CGEN_FIELDS
* fields
,
253 CGEN_INSN_BYTES_PTR buffer
,
256 const CGEN_SYNTAX
*syntax
= CGEN_INSN_SYNTAX (insn
);
258 const CGEN_SYNTAX_CHAR_TYPE
* syn
;
260 CGEN_INIT_INSERT (cd
);
261 value
= CGEN_INSN_BASE_VALUE (insn
);
263 /* If we're recording insns as numbers (rather than a string of bytes),
264 target byte order handling is deferred until later. */
268 put_insn_int_value (cd
, buffer
, cd
->base_insn_bitsize
,
269 CGEN_FIELDS_BITSIZE (fields
), value
);
273 cgen_put_insn_value (cd
, buffer
, min ((unsigned) cd
->base_insn_bitsize
,
274 (unsigned) CGEN_FIELDS_BITSIZE (fields
)),
275 value
, cd
->insn_endian
);
277 #endif /* ! CGEN_INT_INSN_P */
279 /* ??? It would be better to scan the format's fields.
280 Still need to be able to insert a value based on the operand though;
281 e.g. storing a branch displacement that got resolved later.
282 Needs more thought first. */
284 for (syn
= CGEN_SYNTAX_STRING (syntax
); * syn
; ++ syn
)
288 if (CGEN_SYNTAX_CHAR_P (* syn
))
291 errmsg
= (* cd
->insert_operand
) (cd
, CGEN_SYNTAX_FIELD (*syn
),
301 /* Cover function to store an insn value into an integral insn. Must go here
302 because it needs <prefix>-desc.h for CGEN_INT_INSN_P. */
305 put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
306 CGEN_INSN_BYTES_PTR buf
,
311 /* For architectures with insns smaller than the base-insn-bitsize,
312 length may be too big. */
313 if (length
> insn_length
)
317 int shift
= insn_length
- length
;
318 /* Written this way to avoid undefined behaviour. */
319 CGEN_INSN_INT mask
= length
== 0 ? 0 : (1UL << (length
- 1) << 1) - 1;
321 *buf
= (*buf
& ~(mask
<< shift
)) | ((value
& mask
) << shift
);
326 /* Operand extraction. */
328 #if ! CGEN_INT_INSN_P
330 /* Subroutine of extract_normal.
331 Ensure sufficient bytes are cached in EX_INFO.
332 OFFSET is the offset in bytes from the start of the insn of the value.
333 BYTES is the length of the needed value.
334 Returns 1 for success, 0 for failure. */
336 static CGEN_INLINE
int
337 fill_cache (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
338 CGEN_EXTRACT_INFO
*ex_info
,
343 /* It's doubtful that the middle part has already been fetched so
344 we don't optimize that case. kiss. */
346 disassemble_info
*info
= (disassemble_info
*) ex_info
->dis_info
;
348 /* First do a quick check. */
349 mask
= (1 << bytes
) - 1;
350 if (((ex_info
->valid
>> offset
) & mask
) == mask
)
353 /* Search for the first byte we need to read. */
354 for (mask
= 1 << offset
; bytes
> 0; --bytes
, ++offset
, mask
<<= 1)
355 if (! (mask
& ex_info
->valid
))
363 status
= (*info
->read_memory_func
)
364 (pc
, ex_info
->insn_bytes
+ offset
, bytes
, info
);
368 (*info
->memory_error_func
) (status
, pc
, info
);
372 ex_info
->valid
|= ((1 << bytes
) - 1) << offset
;
378 /* Subroutine of extract_normal. */
380 static CGEN_INLINE
long
381 extract_1 (CGEN_CPU_DESC cd
,
382 CGEN_EXTRACT_INFO
*ex_info ATTRIBUTE_UNUSED
,
387 bfd_vma pc ATTRIBUTE_UNUSED
)
392 x
= cgen_get_insn_value (cd
, bufp
, word_length
, cd
->endian
);
394 if (CGEN_INSN_LSB0_P
)
395 shift
= (start
+ 1) - length
;
397 shift
= (word_length
- (start
+ length
));
401 #endif /* ! CGEN_INT_INSN_P */
403 /* Default extraction routine.
405 INSN_VALUE is the first base_insn_bitsize bits of the insn in host order,
406 or sometimes less for cases like the m32r where the base insn size is 32
407 but some insns are 16 bits.
408 ATTRS is a mask of the boolean attributes. We only need `SIGNED',
409 but for generality we take a bitmask of all of them.
410 WORD_OFFSET is the offset in bits from the start of the insn of the value.
411 WORD_LENGTH is the length of the word in bits in which the value resides.
412 START is the starting bit number in the word, architecture origin.
413 LENGTH is the length of VALUE in bits.
414 TOTAL_LENGTH is the total length of the insn in bits.
416 Returns 1 for success, 0 for failure. */
418 /* ??? The return code isn't properly used. wip. */
420 /* ??? This doesn't handle bfd_vma's. Create another function when
424 extract_normal (CGEN_CPU_DESC cd
,
425 #if ! CGEN_INT_INSN_P
426 CGEN_EXTRACT_INFO
*ex_info
,
428 CGEN_EXTRACT_INFO
*ex_info ATTRIBUTE_UNUSED
,
430 CGEN_INSN_INT insn_value
,
432 unsigned int word_offset
,
435 unsigned int word_length
,
436 unsigned int total_length
,
437 #if ! CGEN_INT_INSN_P
440 bfd_vma pc ATTRIBUTE_UNUSED
,
446 /* If LENGTH is zero, this operand doesn't contribute to the value
447 so give it a standard value of zero. */
454 if (word_length
> 8 * sizeof (CGEN_INSN_INT
))
457 /* For architectures with insns smaller than the insn-base-bitsize,
458 word_length may be too big. */
459 if (cd
->min_insn_bitsize
< cd
->base_insn_bitsize
)
461 if (word_offset
+ word_length
> total_length
)
462 word_length
= total_length
- word_offset
;
465 /* Does the value reside in INSN_VALUE, and at the right alignment? */
467 if (CGEN_INT_INSN_P
|| (word_offset
== 0 && word_length
== total_length
))
469 if (CGEN_INSN_LSB0_P
)
470 value
= insn_value
>> ((word_offset
+ start
+ 1) - length
);
472 value
= insn_value
>> (total_length
- ( word_offset
+ start
+ length
));
475 #if ! CGEN_INT_INSN_P
479 unsigned char *bufp
= ex_info
->insn_bytes
+ word_offset
/ 8;
481 if (word_length
> 8 * sizeof (CGEN_INSN_INT
))
484 if (fill_cache (cd
, ex_info
, word_offset
/ 8, word_length
/ 8, pc
) == 0)
490 value
= extract_1 (cd
, ex_info
, start
, length
, word_length
, bufp
, pc
);
493 #endif /* ! CGEN_INT_INSN_P */
495 /* Written this way to avoid undefined behaviour. */
496 mask
= (1UL << (length
- 1) << 1) - 1;
500 if (CGEN_BOOL_ATTR (attrs
, CGEN_IFLD_SIGNED
)
501 && (value
& (1UL << (length
- 1))))
509 /* Default insn extractor.
511 INSN_VALUE is the first base_insn_bitsize bits, translated to host order.
512 The extracted fields are stored in FIELDS.
513 EX_INFO is used to handle reading variable length insns.
514 Return the length of the insn in bits, or 0 if no match,
515 or -1 if an error occurs fetching data (memory_error_func will have
519 extract_insn_normal (CGEN_CPU_DESC cd
,
520 const CGEN_INSN
*insn
,
521 CGEN_EXTRACT_INFO
*ex_info
,
522 CGEN_INSN_INT insn_value
,
526 const CGEN_SYNTAX
*syntax
= CGEN_INSN_SYNTAX (insn
);
527 const CGEN_SYNTAX_CHAR_TYPE
*syn
;
529 CGEN_FIELDS_BITSIZE (fields
) = CGEN_INSN_BITSIZE (insn
);
531 CGEN_INIT_EXTRACT (cd
);
533 for (syn
= CGEN_SYNTAX_STRING (syntax
); *syn
; ++syn
)
537 if (CGEN_SYNTAX_CHAR_P (*syn
))
540 length
= (* cd
->extract_operand
) (cd
, CGEN_SYNTAX_FIELD (*syn
),
541 ex_info
, insn_value
, fields
, pc
);
546 /* We recognized and successfully extracted this insn. */
547 return CGEN_INSN_BITSIZE (insn
);
550 /* Machine generated code added here. */
552 const char * epiphany_cgen_insert_operand
553 (CGEN_CPU_DESC
, int, CGEN_FIELDS
*, CGEN_INSN_BYTES_PTR
, bfd_vma
);
555 /* Main entry point for operand insertion.
557 This function is basically just a big switch statement. Earlier versions
558 used tables to look up the function to use, but
559 - if the table contains both assembler and disassembler functions then
560 the disassembler contains much of the assembler and vice-versa,
561 - there's a lot of inlining possibilities as things grow,
562 - using a switch statement avoids the function call overhead.
564 This function could be moved into `parse_insn_normal', but keeping it
565 separate makes clear the interface between `parse_insn_normal' and each of
566 the handlers. It's also needed by GAS to insert operands that couldn't be
567 resolved during parsing. */
570 epiphany_cgen_insert_operand (CGEN_CPU_DESC cd
,
572 CGEN_FIELDS
* fields
,
573 CGEN_INSN_BYTES_PTR buffer
,
574 bfd_vma pc ATTRIBUTE_UNUSED
)
576 const char * errmsg
= NULL
;
577 unsigned int total_length
= CGEN_FIELDS_BITSIZE (fields
);
581 case EPIPHANY_OPERAND_DIRECTION
:
582 errmsg
= insert_normal (cd
, fields
->f_addsubx
, 0, 0, 20, 1, 32, total_length
, buffer
);
584 case EPIPHANY_OPERAND_DISP11
:
587 FLD (f_disp8
) = ((((UINT
) (FLD (f_disp11
)) >> (3))) & (255));
588 FLD (f_disp3
) = ((FLD (f_disp11
)) & (7));
590 errmsg
= insert_normal (cd
, fields
->f_disp3
, 0, 0, 9, 3, 32, total_length
, buffer
);
593 errmsg
= insert_normal (cd
, fields
->f_disp8
, 0, 0, 23, 8, 32, total_length
, buffer
);
598 case EPIPHANY_OPERAND_DISP3
:
599 errmsg
= insert_normal (cd
, fields
->f_disp3
, 0, 0, 9, 3, 32, total_length
, buffer
);
601 case EPIPHANY_OPERAND_DPMI
:
602 errmsg
= insert_normal (cd
, fields
->f_subd
, 0, 0, 24, 1, 32, total_length
, buffer
);
604 case EPIPHANY_OPERAND_FRD
:
605 errmsg
= insert_normal (cd
, fields
->f_rd
, 0, 0, 15, 3, 32, total_length
, buffer
);
607 case EPIPHANY_OPERAND_FRD6
:
610 FLD (f_rd
) = ((FLD (f_rd6
)) & (7));
611 FLD (f_rd_x
) = ((UINT
) (FLD (f_rd6
)) >> (3));
613 errmsg
= insert_normal (cd
, fields
->f_rd_x
, 0, 0, 31, 3, 32, total_length
, buffer
);
616 errmsg
= insert_normal (cd
, fields
->f_rd
, 0, 0, 15, 3, 32, total_length
, buffer
);
621 case EPIPHANY_OPERAND_FRM
:
622 errmsg
= insert_normal (cd
, fields
->f_rm
, 0, 0, 9, 3, 32, total_length
, buffer
);
624 case EPIPHANY_OPERAND_FRM6
:
627 FLD (f_rm
) = ((FLD (f_rm6
)) & (7));
628 FLD (f_rm_x
) = ((UINT
) (FLD (f_rm6
)) >> (3));
630 errmsg
= insert_normal (cd
, fields
->f_rm_x
, 0, 0, 25, 3, 32, total_length
, buffer
);
633 errmsg
= insert_normal (cd
, fields
->f_rm
, 0, 0, 9, 3, 32, total_length
, buffer
);
638 case EPIPHANY_OPERAND_FRN
:
639 errmsg
= insert_normal (cd
, fields
->f_rn
, 0, 0, 12, 3, 32, total_length
, buffer
);
641 case EPIPHANY_OPERAND_FRN6
:
644 FLD (f_rn
) = ((FLD (f_rn6
)) & (7));
645 FLD (f_rn_x
) = ((UINT
) (FLD (f_rn6
)) >> (3));
647 errmsg
= insert_normal (cd
, fields
->f_rn_x
, 0, 0, 28, 3, 32, total_length
, buffer
);
650 errmsg
= insert_normal (cd
, fields
->f_rn
, 0, 0, 12, 3, 32, total_length
, buffer
);
655 case EPIPHANY_OPERAND_IMM16
:
658 FLD (f_imm8
) = ((FLD (f_imm16
)) & (255));
659 FLD (f_imm_27_8
) = ((UINT
) (FLD (f_imm16
)) >> (8));
661 errmsg
= insert_normal (cd
, fields
->f_imm8
, 0, 0, 12, 8, 32, total_length
, buffer
);
664 errmsg
= insert_normal (cd
, fields
->f_imm_27_8
, 0, 0, 27, 8, 32, total_length
, buffer
);
669 case EPIPHANY_OPERAND_IMM8
:
670 errmsg
= insert_normal (cd
, fields
->f_imm8
, 0, 0, 12, 8, 32, total_length
, buffer
);
672 case EPIPHANY_OPERAND_RD
:
673 errmsg
= insert_normal (cd
, fields
->f_rd
, 0, 0, 15, 3, 32, total_length
, buffer
);
675 case EPIPHANY_OPERAND_RD6
:
678 FLD (f_rd
) = ((FLD (f_rd6
)) & (7));
679 FLD (f_rd_x
) = ((UINT
) (FLD (f_rd6
)) >> (3));
681 errmsg
= insert_normal (cd
, fields
->f_rd_x
, 0, 0, 31, 3, 32, total_length
, buffer
);
684 errmsg
= insert_normal (cd
, fields
->f_rd
, 0, 0, 15, 3, 32, total_length
, buffer
);
689 case EPIPHANY_OPERAND_RM
:
690 errmsg
= insert_normal (cd
, fields
->f_rm
, 0, 0, 9, 3, 32, total_length
, buffer
);
692 case EPIPHANY_OPERAND_RM6
:
695 FLD (f_rm
) = ((FLD (f_rm6
)) & (7));
696 FLD (f_rm_x
) = ((UINT
) (FLD (f_rm6
)) >> (3));
698 errmsg
= insert_normal (cd
, fields
->f_rm_x
, 0, 0, 25, 3, 32, total_length
, buffer
);
701 errmsg
= insert_normal (cd
, fields
->f_rm
, 0, 0, 9, 3, 32, total_length
, buffer
);
706 case EPIPHANY_OPERAND_RN
:
707 errmsg
= insert_normal (cd
, fields
->f_rn
, 0, 0, 12, 3, 32, total_length
, buffer
);
709 case EPIPHANY_OPERAND_RN6
:
712 FLD (f_rn
) = ((FLD (f_rn6
)) & (7));
713 FLD (f_rn_x
) = ((UINT
) (FLD (f_rn6
)) >> (3));
715 errmsg
= insert_normal (cd
, fields
->f_rn_x
, 0, 0, 28, 3, 32, total_length
, buffer
);
718 errmsg
= insert_normal (cd
, fields
->f_rn
, 0, 0, 12, 3, 32, total_length
, buffer
);
723 case EPIPHANY_OPERAND_SD
:
724 errmsg
= insert_normal (cd
, fields
->f_sd
, 0, 0, 15, 3, 32, total_length
, buffer
);
726 case EPIPHANY_OPERAND_SD6
:
729 FLD (f_sd
) = ((FLD (f_sd6
)) & (7));
730 FLD (f_sd_x
) = ((UINT
) (FLD (f_sd6
)) >> (3));
732 errmsg
= insert_normal (cd
, fields
->f_sd_x
, 0, 0, 31, 3, 32, total_length
, buffer
);
735 errmsg
= insert_normal (cd
, fields
->f_sd
, 0, 0, 15, 3, 32, total_length
, buffer
);
740 case EPIPHANY_OPERAND_SDDMA
:
743 FLD (f_sd
) = ((FLD (f_sd6
)) & (7));
744 FLD (f_sd_x
) = ((UINT
) (FLD (f_sd6
)) >> (3));
746 errmsg
= insert_normal (cd
, fields
->f_sd_x
, 0, 0, 31, 3, 32, total_length
, buffer
);
749 errmsg
= insert_normal (cd
, fields
->f_sd
, 0, 0, 15, 3, 32, total_length
, buffer
);
754 case EPIPHANY_OPERAND_SDMEM
:
757 FLD (f_sd
) = ((FLD (f_sd6
)) & (7));
758 FLD (f_sd_x
) = ((UINT
) (FLD (f_sd6
)) >> (3));
760 errmsg
= insert_normal (cd
, fields
->f_sd_x
, 0, 0, 31, 3, 32, total_length
, buffer
);
763 errmsg
= insert_normal (cd
, fields
->f_sd
, 0, 0, 15, 3, 32, total_length
, buffer
);
768 case EPIPHANY_OPERAND_SDMESH
:
771 FLD (f_sd
) = ((FLD (f_sd6
)) & (7));
772 FLD (f_sd_x
) = ((UINT
) (FLD (f_sd6
)) >> (3));
774 errmsg
= insert_normal (cd
, fields
->f_sd_x
, 0, 0, 31, 3, 32, total_length
, buffer
);
777 errmsg
= insert_normal (cd
, fields
->f_sd
, 0, 0, 15, 3, 32, total_length
, buffer
);
782 case EPIPHANY_OPERAND_SHIFT
:
783 errmsg
= insert_normal (cd
, fields
->f_shift
, 0, 0, 9, 5, 32, total_length
, buffer
);
785 case EPIPHANY_OPERAND_SIMM11
:
788 FLD (f_disp8
) = ((255) & (((USI
) (FLD (f_sdisp11
)) >> (3))));
789 FLD (f_disp3
) = ((FLD (f_sdisp11
)) & (7));
791 errmsg
= insert_normal (cd
, fields
->f_disp3
, 0, 0, 9, 3, 32, total_length
, buffer
);
794 errmsg
= insert_normal (cd
, fields
->f_disp8
, 0, 0, 23, 8, 32, total_length
, buffer
);
799 case EPIPHANY_OPERAND_SIMM24
:
801 long value
= fields
->f_simm24
;
802 value
= ((SI
) (((value
) - (pc
))) >> (1));
803 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
);
806 case EPIPHANY_OPERAND_SIMM3
:
807 errmsg
= insert_normal (cd
, fields
->f_sdisp3
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 9, 3, 32, total_length
, buffer
);
809 case EPIPHANY_OPERAND_SIMM8
:
811 long value
= fields
->f_simm8
;
812 value
= ((SI
) (((value
) - (pc
))) >> (1));
813 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
);
816 case EPIPHANY_OPERAND_SN
:
817 errmsg
= insert_normal (cd
, fields
->f_sn
, 0, 0, 12, 3, 32, total_length
, buffer
);
819 case EPIPHANY_OPERAND_SN6
:
822 FLD (f_sn
) = ((FLD (f_sn6
)) & (7));
823 FLD (f_sn_x
) = ((UINT
) (FLD (f_sn6
)) >> (3));
825 errmsg
= insert_normal (cd
, fields
->f_sn_x
, 0, 0, 28, 3, 32, total_length
, buffer
);
828 errmsg
= insert_normal (cd
, fields
->f_sn
, 0, 0, 12, 3, 32, total_length
, buffer
);
833 case EPIPHANY_OPERAND_SNDMA
:
836 FLD (f_sn
) = ((FLD (f_sn6
)) & (7));
837 FLD (f_sn_x
) = ((UINT
) (FLD (f_sn6
)) >> (3));
839 errmsg
= insert_normal (cd
, fields
->f_sn_x
, 0, 0, 28, 3, 32, total_length
, buffer
);
842 errmsg
= insert_normal (cd
, fields
->f_sn
, 0, 0, 12, 3, 32, total_length
, buffer
);
847 case EPIPHANY_OPERAND_SNMEM
:
850 FLD (f_sn
) = ((FLD (f_sn6
)) & (7));
851 FLD (f_sn_x
) = ((UINT
) (FLD (f_sn6
)) >> (3));
853 errmsg
= insert_normal (cd
, fields
->f_sn_x
, 0, 0, 28, 3, 32, total_length
, buffer
);
856 errmsg
= insert_normal (cd
, fields
->f_sn
, 0, 0, 12, 3, 32, total_length
, buffer
);
861 case EPIPHANY_OPERAND_SNMESH
:
864 FLD (f_sn
) = ((FLD (f_sn6
)) & (7));
865 FLD (f_sn_x
) = ((UINT
) (FLD (f_sn6
)) >> (3));
867 errmsg
= insert_normal (cd
, fields
->f_sn_x
, 0, 0, 28, 3, 32, total_length
, buffer
);
870 errmsg
= insert_normal (cd
, fields
->f_sn
, 0, 0, 12, 3, 32, total_length
, buffer
);
875 case EPIPHANY_OPERAND_SWI_NUM
:
876 errmsg
= insert_normal (cd
, fields
->f_trap_num
, 0, 0, 15, 6, 32, total_length
, buffer
);
878 case EPIPHANY_OPERAND_TRAPNUM6
:
879 errmsg
= insert_normal (cd
, fields
->f_trap_num
, 0, 0, 15, 6, 32, total_length
, buffer
);
883 /* xgettext:c-format */
884 opcodes_error_handler
885 (_("internal error: unrecognized field %d while building insn"),
893 int epiphany_cgen_extract_operand
894 (CGEN_CPU_DESC
, int, CGEN_EXTRACT_INFO
*, CGEN_INSN_INT
, CGEN_FIELDS
*, bfd_vma
);
896 /* Main entry point for operand extraction.
897 The result is <= 0 for error, >0 for success.
898 ??? Actual values aren't well defined right now.
900 This function is basically just a big switch statement. Earlier versions
901 used tables to look up the function to use, but
902 - if the table contains both assembler and disassembler functions then
903 the disassembler contains much of the assembler and vice-versa,
904 - there's a lot of inlining possibilities as things grow,
905 - using a switch statement avoids the function call overhead.
907 This function could be moved into `print_insn_normal', but keeping it
908 separate makes clear the interface between `print_insn_normal' and each of
912 epiphany_cgen_extract_operand (CGEN_CPU_DESC cd
,
914 CGEN_EXTRACT_INFO
*ex_info
,
915 CGEN_INSN_INT insn_value
,
916 CGEN_FIELDS
* fields
,
919 /* Assume success (for those operands that are nops). */
921 unsigned int total_length
= CGEN_FIELDS_BITSIZE (fields
);
925 case EPIPHANY_OPERAND_DIRECTION
:
926 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 20, 1, 32, total_length
, pc
, & fields
->f_addsubx
);
928 case EPIPHANY_OPERAND_DISP11
:
930 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 9, 3, 32, total_length
, pc
, & fields
->f_disp3
);
931 if (length
<= 0) break;
932 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 23, 8, 32, total_length
, pc
, & fields
->f_disp8
);
933 if (length
<= 0) break;
935 FLD (f_disp11
) = ((((FLD (f_disp8
)) << (3))) | (FLD (f_disp3
)));
939 case EPIPHANY_OPERAND_DISP3
:
940 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 9, 3, 32, total_length
, pc
, & fields
->f_disp3
);
942 case EPIPHANY_OPERAND_DPMI
:
943 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 24, 1, 32, total_length
, pc
, & fields
->f_subd
);
945 case EPIPHANY_OPERAND_FRD
:
946 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 3, 32, total_length
, pc
, & fields
->f_rd
);
948 case EPIPHANY_OPERAND_FRD6
:
950 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 31, 3, 32, total_length
, pc
, & fields
->f_rd_x
);
951 if (length
<= 0) break;
952 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 3, 32, total_length
, pc
, & fields
->f_rd
);
953 if (length
<= 0) break;
955 FLD (f_rd6
) = ((((FLD (f_rd_x
)) << (3))) | (FLD (f_rd
)));
959 case EPIPHANY_OPERAND_FRM
:
960 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 9, 3, 32, total_length
, pc
, & fields
->f_rm
);
962 case EPIPHANY_OPERAND_FRM6
:
964 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 25, 3, 32, total_length
, pc
, & fields
->f_rm_x
);
965 if (length
<= 0) break;
966 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 9, 3, 32, total_length
, pc
, & fields
->f_rm
);
967 if (length
<= 0) break;
969 FLD (f_rm6
) = ((((FLD (f_rm_x
)) << (3))) | (FLD (f_rm
)));
973 case EPIPHANY_OPERAND_FRN
:
974 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 12, 3, 32, total_length
, pc
, & fields
->f_rn
);
976 case EPIPHANY_OPERAND_FRN6
:
978 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 28, 3, 32, total_length
, pc
, & fields
->f_rn_x
);
979 if (length
<= 0) break;
980 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 12, 3, 32, total_length
, pc
, & fields
->f_rn
);
981 if (length
<= 0) break;
983 FLD (f_rn6
) = ((((FLD (f_rn_x
)) << (3))) | (FLD (f_rn
)));
987 case EPIPHANY_OPERAND_IMM16
:
989 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 12, 8, 32, total_length
, pc
, & fields
->f_imm8
);
990 if (length
<= 0) break;
991 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 27, 8, 32, total_length
, pc
, & fields
->f_imm_27_8
);
992 if (length
<= 0) break;
994 FLD (f_imm16
) = ((((FLD (f_imm_27_8
)) << (8))) | (FLD (f_imm8
)));
998 case EPIPHANY_OPERAND_IMM8
:
999 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 12, 8, 32, total_length
, pc
, & fields
->f_imm8
);
1001 case EPIPHANY_OPERAND_RD
:
1002 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 3, 32, total_length
, pc
, & fields
->f_rd
);
1004 case EPIPHANY_OPERAND_RD6
:
1006 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 31, 3, 32, total_length
, pc
, & fields
->f_rd_x
);
1007 if (length
<= 0) break;
1008 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 3, 32, total_length
, pc
, & fields
->f_rd
);
1009 if (length
<= 0) break;
1011 FLD (f_rd6
) = ((((FLD (f_rd_x
)) << (3))) | (FLD (f_rd
)));
1015 case EPIPHANY_OPERAND_RM
:
1016 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 9, 3, 32, total_length
, pc
, & fields
->f_rm
);
1018 case EPIPHANY_OPERAND_RM6
:
1020 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 25, 3, 32, total_length
, pc
, & fields
->f_rm_x
);
1021 if (length
<= 0) break;
1022 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 9, 3, 32, total_length
, pc
, & fields
->f_rm
);
1023 if (length
<= 0) break;
1025 FLD (f_rm6
) = ((((FLD (f_rm_x
)) << (3))) | (FLD (f_rm
)));
1029 case EPIPHANY_OPERAND_RN
:
1030 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 12, 3, 32, total_length
, pc
, & fields
->f_rn
);
1032 case EPIPHANY_OPERAND_RN6
:
1034 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 28, 3, 32, total_length
, pc
, & fields
->f_rn_x
);
1035 if (length
<= 0) break;
1036 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 12, 3, 32, total_length
, pc
, & fields
->f_rn
);
1037 if (length
<= 0) break;
1039 FLD (f_rn6
) = ((((FLD (f_rn_x
)) << (3))) | (FLD (f_rn
)));
1043 case EPIPHANY_OPERAND_SD
:
1044 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 3, 32, total_length
, pc
, & fields
->f_sd
);
1046 case EPIPHANY_OPERAND_SD6
:
1048 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 31, 3, 32, total_length
, pc
, & fields
->f_sd_x
);
1049 if (length
<= 0) break;
1050 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 3, 32, total_length
, pc
, & fields
->f_sd
);
1051 if (length
<= 0) break;
1053 FLD (f_sd6
) = ((((FLD (f_sd_x
)) << (3))) | (FLD (f_sd
)));
1057 case EPIPHANY_OPERAND_SDDMA
:
1059 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 31, 3, 32, total_length
, pc
, & fields
->f_sd_x
);
1060 if (length
<= 0) break;
1061 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 3, 32, total_length
, pc
, & fields
->f_sd
);
1062 if (length
<= 0) break;
1064 FLD (f_sd6
) = ((((FLD (f_sd_x
)) << (3))) | (FLD (f_sd
)));
1068 case EPIPHANY_OPERAND_SDMEM
:
1070 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 31, 3, 32, total_length
, pc
, & fields
->f_sd_x
);
1071 if (length
<= 0) break;
1072 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 3, 32, total_length
, pc
, & fields
->f_sd
);
1073 if (length
<= 0) break;
1075 FLD (f_sd6
) = ((((FLD (f_sd_x
)) << (3))) | (FLD (f_sd
)));
1079 case EPIPHANY_OPERAND_SDMESH
:
1081 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 31, 3, 32, total_length
, pc
, & fields
->f_sd_x
);
1082 if (length
<= 0) break;
1083 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 3, 32, total_length
, pc
, & fields
->f_sd
);
1084 if (length
<= 0) break;
1086 FLD (f_sd6
) = ((((FLD (f_sd_x
)) << (3))) | (FLD (f_sd
)));
1090 case EPIPHANY_OPERAND_SHIFT
:
1091 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 9, 5, 32, total_length
, pc
, & fields
->f_shift
);
1093 case EPIPHANY_OPERAND_SIMM11
:
1095 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 9, 3, 32, total_length
, pc
, & fields
->f_disp3
);
1096 if (length
<= 0) break;
1097 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 23, 8, 32, total_length
, pc
, & fields
->f_disp8
);
1098 if (length
<= 0) break;
1100 FLD (f_sdisp11
) = ((((((((((FLD (f_disp8
)) << (3))) | (FLD (f_disp3
)))) & (2047))) ^ (1024))) - (1024));
1104 case EPIPHANY_OPERAND_SIMM24
:
1107 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
);
1108 value
= ((((value
) * (2))) + (pc
));
1109 fields
->f_simm24
= value
;
1112 case EPIPHANY_OPERAND_SIMM3
:
1113 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 9, 3, 32, total_length
, pc
, & fields
->f_sdisp3
);
1115 case EPIPHANY_OPERAND_SIMM8
:
1118 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
);
1119 value
= ((((value
) * (2))) + (pc
));
1120 fields
->f_simm8
= value
;
1123 case EPIPHANY_OPERAND_SN
:
1124 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 12, 3, 32, total_length
, pc
, & fields
->f_sn
);
1126 case EPIPHANY_OPERAND_SN6
:
1128 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 28, 3, 32, total_length
, pc
, & fields
->f_sn_x
);
1129 if (length
<= 0) break;
1130 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 12, 3, 32, total_length
, pc
, & fields
->f_sn
);
1131 if (length
<= 0) break;
1133 FLD (f_sn6
) = ((((FLD (f_sn_x
)) << (3))) | (FLD (f_sn
)));
1137 case EPIPHANY_OPERAND_SNDMA
:
1139 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 28, 3, 32, total_length
, pc
, & fields
->f_sn_x
);
1140 if (length
<= 0) break;
1141 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 12, 3, 32, total_length
, pc
, & fields
->f_sn
);
1142 if (length
<= 0) break;
1144 FLD (f_sn6
) = ((((FLD (f_sn_x
)) << (3))) | (FLD (f_sn
)));
1148 case EPIPHANY_OPERAND_SNMEM
:
1150 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 28, 3, 32, total_length
, pc
, & fields
->f_sn_x
);
1151 if (length
<= 0) break;
1152 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 12, 3, 32, total_length
, pc
, & fields
->f_sn
);
1153 if (length
<= 0) break;
1155 FLD (f_sn6
) = ((((FLD (f_sn_x
)) << (3))) | (FLD (f_sn
)));
1159 case EPIPHANY_OPERAND_SNMESH
:
1161 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 28, 3, 32, total_length
, pc
, & fields
->f_sn_x
);
1162 if (length
<= 0) break;
1163 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 12, 3, 32, total_length
, pc
, & fields
->f_sn
);
1164 if (length
<= 0) break;
1166 FLD (f_sn6
) = ((((FLD (f_sn_x
)) << (3))) | (FLD (f_sn
)));
1170 case EPIPHANY_OPERAND_SWI_NUM
:
1171 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 6, 32, total_length
, pc
, & fields
->f_trap_num
);
1173 case EPIPHANY_OPERAND_TRAPNUM6
:
1174 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 6, 32, total_length
, pc
, & fields
->f_trap_num
);
1178 /* xgettext:c-format */
1179 opcodes_error_handler
1180 (_("internal error: unrecognized field %d while decoding insn"),
1188 cgen_insert_fn
* const epiphany_cgen_insert_handlers
[] =
1193 cgen_extract_fn
* const epiphany_cgen_extract_handlers
[] =
1195 extract_insn_normal
,
1198 int epiphany_cgen_get_int_operand (CGEN_CPU_DESC
, int, const CGEN_FIELDS
*);
1199 bfd_vma
epiphany_cgen_get_vma_operand (CGEN_CPU_DESC
, int, const CGEN_FIELDS
*);
1201 /* Getting values from cgen_fields is handled by a collection of functions.
1202 They are distinguished by the type of the VALUE argument they return.
1203 TODO: floating point, inlining support, remove cases where result type
1207 epiphany_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
1209 const CGEN_FIELDS
* fields
)
1215 case EPIPHANY_OPERAND_DIRECTION
:
1216 value
= fields
->f_addsubx
;
1218 case EPIPHANY_OPERAND_DISP11
:
1219 value
= fields
->f_disp11
;
1221 case EPIPHANY_OPERAND_DISP3
:
1222 value
= fields
->f_disp3
;
1224 case EPIPHANY_OPERAND_DPMI
:
1225 value
= fields
->f_subd
;
1227 case EPIPHANY_OPERAND_FRD
:
1228 value
= fields
->f_rd
;
1230 case EPIPHANY_OPERAND_FRD6
:
1231 value
= fields
->f_rd6
;
1233 case EPIPHANY_OPERAND_FRM
:
1234 value
= fields
->f_rm
;
1236 case EPIPHANY_OPERAND_FRM6
:
1237 value
= fields
->f_rm6
;
1239 case EPIPHANY_OPERAND_FRN
:
1240 value
= fields
->f_rn
;
1242 case EPIPHANY_OPERAND_FRN6
:
1243 value
= fields
->f_rn6
;
1245 case EPIPHANY_OPERAND_IMM16
:
1246 value
= fields
->f_imm16
;
1248 case EPIPHANY_OPERAND_IMM8
:
1249 value
= fields
->f_imm8
;
1251 case EPIPHANY_OPERAND_RD
:
1252 value
= fields
->f_rd
;
1254 case EPIPHANY_OPERAND_RD6
:
1255 value
= fields
->f_rd6
;
1257 case EPIPHANY_OPERAND_RM
:
1258 value
= fields
->f_rm
;
1260 case EPIPHANY_OPERAND_RM6
:
1261 value
= fields
->f_rm6
;
1263 case EPIPHANY_OPERAND_RN
:
1264 value
= fields
->f_rn
;
1266 case EPIPHANY_OPERAND_RN6
:
1267 value
= fields
->f_rn6
;
1269 case EPIPHANY_OPERAND_SD
:
1270 value
= fields
->f_sd
;
1272 case EPIPHANY_OPERAND_SD6
:
1273 value
= fields
->f_sd6
;
1275 case EPIPHANY_OPERAND_SDDMA
:
1276 value
= fields
->f_sd6
;
1278 case EPIPHANY_OPERAND_SDMEM
:
1279 value
= fields
->f_sd6
;
1281 case EPIPHANY_OPERAND_SDMESH
:
1282 value
= fields
->f_sd6
;
1284 case EPIPHANY_OPERAND_SHIFT
:
1285 value
= fields
->f_shift
;
1287 case EPIPHANY_OPERAND_SIMM11
:
1288 value
= fields
->f_sdisp11
;
1290 case EPIPHANY_OPERAND_SIMM24
:
1291 value
= fields
->f_simm24
;
1293 case EPIPHANY_OPERAND_SIMM3
:
1294 value
= fields
->f_sdisp3
;
1296 case EPIPHANY_OPERAND_SIMM8
:
1297 value
= fields
->f_simm8
;
1299 case EPIPHANY_OPERAND_SN
:
1300 value
= fields
->f_sn
;
1302 case EPIPHANY_OPERAND_SN6
:
1303 value
= fields
->f_sn6
;
1305 case EPIPHANY_OPERAND_SNDMA
:
1306 value
= fields
->f_sn6
;
1308 case EPIPHANY_OPERAND_SNMEM
:
1309 value
= fields
->f_sn6
;
1311 case EPIPHANY_OPERAND_SNMESH
:
1312 value
= fields
->f_sn6
;
1314 case EPIPHANY_OPERAND_SWI_NUM
:
1315 value
= fields
->f_trap_num
;
1317 case EPIPHANY_OPERAND_TRAPNUM6
:
1318 value
= fields
->f_trap_num
;
1322 /* xgettext:c-format */
1323 opcodes_error_handler
1324 (_("internal error: unrecognized field %d while getting int operand"),
1333 epiphany_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
1335 const CGEN_FIELDS
* fields
)
1341 case EPIPHANY_OPERAND_DIRECTION
:
1342 value
= fields
->f_addsubx
;
1344 case EPIPHANY_OPERAND_DISP11
:
1345 value
= fields
->f_disp11
;
1347 case EPIPHANY_OPERAND_DISP3
:
1348 value
= fields
->f_disp3
;
1350 case EPIPHANY_OPERAND_DPMI
:
1351 value
= fields
->f_subd
;
1353 case EPIPHANY_OPERAND_FRD
:
1354 value
= fields
->f_rd
;
1356 case EPIPHANY_OPERAND_FRD6
:
1357 value
= fields
->f_rd6
;
1359 case EPIPHANY_OPERAND_FRM
:
1360 value
= fields
->f_rm
;
1362 case EPIPHANY_OPERAND_FRM6
:
1363 value
= fields
->f_rm6
;
1365 case EPIPHANY_OPERAND_FRN
:
1366 value
= fields
->f_rn
;
1368 case EPIPHANY_OPERAND_FRN6
:
1369 value
= fields
->f_rn6
;
1371 case EPIPHANY_OPERAND_IMM16
:
1372 value
= fields
->f_imm16
;
1374 case EPIPHANY_OPERAND_IMM8
:
1375 value
= fields
->f_imm8
;
1377 case EPIPHANY_OPERAND_RD
:
1378 value
= fields
->f_rd
;
1380 case EPIPHANY_OPERAND_RD6
:
1381 value
= fields
->f_rd6
;
1383 case EPIPHANY_OPERAND_RM
:
1384 value
= fields
->f_rm
;
1386 case EPIPHANY_OPERAND_RM6
:
1387 value
= fields
->f_rm6
;
1389 case EPIPHANY_OPERAND_RN
:
1390 value
= fields
->f_rn
;
1392 case EPIPHANY_OPERAND_RN6
:
1393 value
= fields
->f_rn6
;
1395 case EPIPHANY_OPERAND_SD
:
1396 value
= fields
->f_sd
;
1398 case EPIPHANY_OPERAND_SD6
:
1399 value
= fields
->f_sd6
;
1401 case EPIPHANY_OPERAND_SDDMA
:
1402 value
= fields
->f_sd6
;
1404 case EPIPHANY_OPERAND_SDMEM
:
1405 value
= fields
->f_sd6
;
1407 case EPIPHANY_OPERAND_SDMESH
:
1408 value
= fields
->f_sd6
;
1410 case EPIPHANY_OPERAND_SHIFT
:
1411 value
= fields
->f_shift
;
1413 case EPIPHANY_OPERAND_SIMM11
:
1414 value
= fields
->f_sdisp11
;
1416 case EPIPHANY_OPERAND_SIMM24
:
1417 value
= fields
->f_simm24
;
1419 case EPIPHANY_OPERAND_SIMM3
:
1420 value
= fields
->f_sdisp3
;
1422 case EPIPHANY_OPERAND_SIMM8
:
1423 value
= fields
->f_simm8
;
1425 case EPIPHANY_OPERAND_SN
:
1426 value
= fields
->f_sn
;
1428 case EPIPHANY_OPERAND_SN6
:
1429 value
= fields
->f_sn6
;
1431 case EPIPHANY_OPERAND_SNDMA
:
1432 value
= fields
->f_sn6
;
1434 case EPIPHANY_OPERAND_SNMEM
:
1435 value
= fields
->f_sn6
;
1437 case EPIPHANY_OPERAND_SNMESH
:
1438 value
= fields
->f_sn6
;
1440 case EPIPHANY_OPERAND_SWI_NUM
:
1441 value
= fields
->f_trap_num
;
1443 case EPIPHANY_OPERAND_TRAPNUM6
:
1444 value
= fields
->f_trap_num
;
1448 /* xgettext:c-format */
1449 opcodes_error_handler
1450 (_("internal error: unrecognized field %d while getting vma operand"),
1458 void epiphany_cgen_set_int_operand (CGEN_CPU_DESC
, int, CGEN_FIELDS
*, int);
1459 void epiphany_cgen_set_vma_operand (CGEN_CPU_DESC
, int, CGEN_FIELDS
*, bfd_vma
);
1461 /* Stuffing values in cgen_fields is handled by a collection of functions.
1462 They are distinguished by the type of the VALUE argument they accept.
1463 TODO: floating point, inlining support, remove cases where argument type
1467 epiphany_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
1469 CGEN_FIELDS
* fields
,
1474 case EPIPHANY_OPERAND_DIRECTION
:
1475 fields
->f_addsubx
= value
;
1477 case EPIPHANY_OPERAND_DISP11
:
1478 fields
->f_disp11
= value
;
1480 case EPIPHANY_OPERAND_DISP3
:
1481 fields
->f_disp3
= value
;
1483 case EPIPHANY_OPERAND_DPMI
:
1484 fields
->f_subd
= value
;
1486 case EPIPHANY_OPERAND_FRD
:
1487 fields
->f_rd
= value
;
1489 case EPIPHANY_OPERAND_FRD6
:
1490 fields
->f_rd6
= value
;
1492 case EPIPHANY_OPERAND_FRM
:
1493 fields
->f_rm
= value
;
1495 case EPIPHANY_OPERAND_FRM6
:
1496 fields
->f_rm6
= value
;
1498 case EPIPHANY_OPERAND_FRN
:
1499 fields
->f_rn
= value
;
1501 case EPIPHANY_OPERAND_FRN6
:
1502 fields
->f_rn6
= value
;
1504 case EPIPHANY_OPERAND_IMM16
:
1505 fields
->f_imm16
= value
;
1507 case EPIPHANY_OPERAND_IMM8
:
1508 fields
->f_imm8
= value
;
1510 case EPIPHANY_OPERAND_RD
:
1511 fields
->f_rd
= value
;
1513 case EPIPHANY_OPERAND_RD6
:
1514 fields
->f_rd6
= value
;
1516 case EPIPHANY_OPERAND_RM
:
1517 fields
->f_rm
= value
;
1519 case EPIPHANY_OPERAND_RM6
:
1520 fields
->f_rm6
= value
;
1522 case EPIPHANY_OPERAND_RN
:
1523 fields
->f_rn
= value
;
1525 case EPIPHANY_OPERAND_RN6
:
1526 fields
->f_rn6
= value
;
1528 case EPIPHANY_OPERAND_SD
:
1529 fields
->f_sd
= value
;
1531 case EPIPHANY_OPERAND_SD6
:
1532 fields
->f_sd6
= value
;
1534 case EPIPHANY_OPERAND_SDDMA
:
1535 fields
->f_sd6
= value
;
1537 case EPIPHANY_OPERAND_SDMEM
:
1538 fields
->f_sd6
= value
;
1540 case EPIPHANY_OPERAND_SDMESH
:
1541 fields
->f_sd6
= value
;
1543 case EPIPHANY_OPERAND_SHIFT
:
1544 fields
->f_shift
= value
;
1546 case EPIPHANY_OPERAND_SIMM11
:
1547 fields
->f_sdisp11
= value
;
1549 case EPIPHANY_OPERAND_SIMM24
:
1550 fields
->f_simm24
= value
;
1552 case EPIPHANY_OPERAND_SIMM3
:
1553 fields
->f_sdisp3
= value
;
1555 case EPIPHANY_OPERAND_SIMM8
:
1556 fields
->f_simm8
= value
;
1558 case EPIPHANY_OPERAND_SN
:
1559 fields
->f_sn
= value
;
1561 case EPIPHANY_OPERAND_SN6
:
1562 fields
->f_sn6
= value
;
1564 case EPIPHANY_OPERAND_SNDMA
:
1565 fields
->f_sn6
= value
;
1567 case EPIPHANY_OPERAND_SNMEM
:
1568 fields
->f_sn6
= value
;
1570 case EPIPHANY_OPERAND_SNMESH
:
1571 fields
->f_sn6
= value
;
1573 case EPIPHANY_OPERAND_SWI_NUM
:
1574 fields
->f_trap_num
= value
;
1576 case EPIPHANY_OPERAND_TRAPNUM6
:
1577 fields
->f_trap_num
= value
;
1581 /* xgettext:c-format */
1582 opcodes_error_handler
1583 (_("internal error: unrecognized field %d while setting int operand"),
1590 epiphany_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
1592 CGEN_FIELDS
* fields
,
1597 case EPIPHANY_OPERAND_DIRECTION
:
1598 fields
->f_addsubx
= value
;
1600 case EPIPHANY_OPERAND_DISP11
:
1601 fields
->f_disp11
= value
;
1603 case EPIPHANY_OPERAND_DISP3
:
1604 fields
->f_disp3
= value
;
1606 case EPIPHANY_OPERAND_DPMI
:
1607 fields
->f_subd
= value
;
1609 case EPIPHANY_OPERAND_FRD
:
1610 fields
->f_rd
= value
;
1612 case EPIPHANY_OPERAND_FRD6
:
1613 fields
->f_rd6
= value
;
1615 case EPIPHANY_OPERAND_FRM
:
1616 fields
->f_rm
= value
;
1618 case EPIPHANY_OPERAND_FRM6
:
1619 fields
->f_rm6
= value
;
1621 case EPIPHANY_OPERAND_FRN
:
1622 fields
->f_rn
= value
;
1624 case EPIPHANY_OPERAND_FRN6
:
1625 fields
->f_rn6
= value
;
1627 case EPIPHANY_OPERAND_IMM16
:
1628 fields
->f_imm16
= value
;
1630 case EPIPHANY_OPERAND_IMM8
:
1631 fields
->f_imm8
= value
;
1633 case EPIPHANY_OPERAND_RD
:
1634 fields
->f_rd
= value
;
1636 case EPIPHANY_OPERAND_RD6
:
1637 fields
->f_rd6
= value
;
1639 case EPIPHANY_OPERAND_RM
:
1640 fields
->f_rm
= value
;
1642 case EPIPHANY_OPERAND_RM6
:
1643 fields
->f_rm6
= value
;
1645 case EPIPHANY_OPERAND_RN
:
1646 fields
->f_rn
= value
;
1648 case EPIPHANY_OPERAND_RN6
:
1649 fields
->f_rn6
= value
;
1651 case EPIPHANY_OPERAND_SD
:
1652 fields
->f_sd
= value
;
1654 case EPIPHANY_OPERAND_SD6
:
1655 fields
->f_sd6
= value
;
1657 case EPIPHANY_OPERAND_SDDMA
:
1658 fields
->f_sd6
= value
;
1660 case EPIPHANY_OPERAND_SDMEM
:
1661 fields
->f_sd6
= value
;
1663 case EPIPHANY_OPERAND_SDMESH
:
1664 fields
->f_sd6
= value
;
1666 case EPIPHANY_OPERAND_SHIFT
:
1667 fields
->f_shift
= value
;
1669 case EPIPHANY_OPERAND_SIMM11
:
1670 fields
->f_sdisp11
= value
;
1672 case EPIPHANY_OPERAND_SIMM24
:
1673 fields
->f_simm24
= value
;
1675 case EPIPHANY_OPERAND_SIMM3
:
1676 fields
->f_sdisp3
= value
;
1678 case EPIPHANY_OPERAND_SIMM8
:
1679 fields
->f_simm8
= value
;
1681 case EPIPHANY_OPERAND_SN
:
1682 fields
->f_sn
= value
;
1684 case EPIPHANY_OPERAND_SN6
:
1685 fields
->f_sn6
= value
;
1687 case EPIPHANY_OPERAND_SNDMA
:
1688 fields
->f_sn6
= value
;
1690 case EPIPHANY_OPERAND_SNMEM
:
1691 fields
->f_sn6
= value
;
1693 case EPIPHANY_OPERAND_SNMESH
:
1694 fields
->f_sn6
= value
;
1696 case EPIPHANY_OPERAND_SWI_NUM
:
1697 fields
->f_trap_num
= value
;
1699 case EPIPHANY_OPERAND_TRAPNUM6
:
1700 fields
->f_trap_num
= value
;
1704 /* xgettext:c-format */
1705 opcodes_error_handler
1706 (_("internal error: unrecognized field %d while setting vma operand"),
1712 /* Function to call before using the instruction builder tables. */
1715 epiphany_cgen_init_ibld_table (CGEN_CPU_DESC cd
)
1717 cd
->insert_handlers
= & epiphany_cgen_insert_handlers
[0];
1718 cd
->extract_handlers
= & epiphany_cgen_extract_handlers
[0];
1720 cd
->insert_operand
= epiphany_cgen_insert_operand
;
1721 cd
->extract_operand
= epiphany_cgen_extract_operand
;
1723 cd
->get_int_operand
= epiphany_cgen_get_int_operand
;
1724 cd
->set_int_operand
= epiphany_cgen_set_int_operand
;
1725 cd
->get_vma_operand
= epiphany_cgen_get_vma_operand
;
1726 cd
->set_vma_operand
= epiphany_cgen_set_vma_operand
;