1 /* Instruction building/extraction support for mep. -*- 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 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.
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
> 32)
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
> 32)
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
> 32)
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 * mep_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 mep_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 MEP_OPERAND_ADDR24A4
:
571 FLD (f_24u8a4n_hi
) = ((unsigned int) (FLD (f_24u8a4n
)) >> (8));
572 FLD (f_24u8a4n_lo
) = ((unsigned int) (((FLD (f_24u8a4n
)) & (252))) >> (2));
574 errmsg
= insert_normal (cd
, fields
->f_24u8a4n_hi
, 0, 0, 16, 16, 32, total_length
, buffer
);
577 errmsg
= insert_normal (cd
, fields
->f_24u8a4n_lo
, 0, 0, 8, 6, 32, total_length
, buffer
);
582 case MEP_OPERAND_CALLNUM
:
585 FLD (f_5
) = ((((unsigned int) (FLD (f_callnum
)) >> (3))) & (1));
586 FLD (f_6
) = ((((unsigned int) (FLD (f_callnum
)) >> (2))) & (1));
587 FLD (f_7
) = ((((unsigned int) (FLD (f_callnum
)) >> (1))) & (1));
588 FLD (f_11
) = ((FLD (f_callnum
)) & (1));
590 errmsg
= insert_normal (cd
, fields
->f_5
, 0, 0, 5, 1, 32, total_length
, buffer
);
593 errmsg
= insert_normal (cd
, fields
->f_6
, 0, 0, 6, 1, 32, total_length
, buffer
);
596 errmsg
= insert_normal (cd
, fields
->f_7
, 0, 0, 7, 1, 32, total_length
, buffer
);
599 errmsg
= insert_normal (cd
, fields
->f_11
, 0, 0, 11, 1, 32, total_length
, buffer
);
604 case MEP_OPERAND_CCCC
:
605 errmsg
= insert_normal (cd
, fields
->f_rm
, 0, 0, 8, 4, 32, total_length
, buffer
);
607 case MEP_OPERAND_CCRN
:
610 FLD (f_ccrn_hi
) = ((((unsigned int) (FLD (f_ccrn
)) >> (4))) & (3));
611 FLD (f_ccrn_lo
) = ((FLD (f_ccrn
)) & (15));
613 errmsg
= insert_normal (cd
, fields
->f_ccrn_hi
, 0, 0, 28, 2, 32, total_length
, buffer
);
616 errmsg
= insert_normal (cd
, fields
->f_ccrn_lo
, 0, 0, 4, 4, 32, total_length
, buffer
);
621 case MEP_OPERAND_CDISP8
:
622 errmsg
= insert_normal (cd
, fields
->f_8s24
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 24, 8, 32, total_length
, buffer
);
624 case MEP_OPERAND_CDISP8A2
:
626 long value
= fields
->f_8s24a2
;
627 value
= ((int) (value
) >> (1));
628 errmsg
= insert_normal (cd
, value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 24, 7, 32, total_length
, buffer
);
631 case MEP_OPERAND_CDISP8A4
:
633 long value
= fields
->f_8s24a4
;
634 value
= ((int) (value
) >> (2));
635 errmsg
= insert_normal (cd
, value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 24, 6, 32, total_length
, buffer
);
638 case MEP_OPERAND_CDISP8A8
:
640 long value
= fields
->f_8s24a8
;
641 value
= ((int) (value
) >> (3));
642 errmsg
= insert_normal (cd
, value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 24, 5, 32, total_length
, buffer
);
645 case MEP_OPERAND_CIMM4
:
646 errmsg
= insert_normal (cd
, fields
->f_rn
, 0, 0, 4, 4, 32, total_length
, buffer
);
648 case MEP_OPERAND_CIMM5
:
649 errmsg
= insert_normal (cd
, fields
->f_5u24
, 0, 0, 24, 5, 32, total_length
, buffer
);
651 case MEP_OPERAND_CODE16
:
652 errmsg
= insert_normal (cd
, fields
->f_16u16
, 0, 0, 16, 16, 32, total_length
, buffer
);
654 case MEP_OPERAND_CODE24
:
657 FLD (f_24u4n_hi
) = ((unsigned int) (FLD (f_24u4n
)) >> (16));
658 FLD (f_24u4n_lo
) = ((FLD (f_24u4n
)) & (65535));
660 errmsg
= insert_normal (cd
, fields
->f_24u4n_hi
, 0, 0, 4, 8, 32, total_length
, buffer
);
663 errmsg
= insert_normal (cd
, fields
->f_24u4n_lo
, 0, 0, 16, 16, 32, total_length
, buffer
);
668 case MEP_OPERAND_CP_FLAG
:
670 case MEP_OPERAND_CRN
:
671 errmsg
= insert_normal (cd
, fields
->f_crn
, 0, 0, 4, 4, 32, total_length
, buffer
);
673 case MEP_OPERAND_CRN64
:
674 errmsg
= insert_normal (cd
, fields
->f_crn
, 0, 0, 4, 4, 32, total_length
, buffer
);
676 case MEP_OPERAND_CRNX
:
679 FLD (f_crnx_lo
) = ((FLD (f_crnx
)) & (15));
680 FLD (f_crnx_hi
) = ((unsigned int) (FLD (f_crnx
)) >> (4));
682 errmsg
= insert_normal (cd
, fields
->f_crnx_hi
, 0, 0, 28, 1, 32, total_length
, buffer
);
685 errmsg
= insert_normal (cd
, fields
->f_crnx_lo
, 0, 0, 4, 4, 32, total_length
, buffer
);
690 case MEP_OPERAND_CRNX64
:
693 FLD (f_crnx_lo
) = ((FLD (f_crnx
)) & (15));
694 FLD (f_crnx_hi
) = ((unsigned int) (FLD (f_crnx
)) >> (4));
696 errmsg
= insert_normal (cd
, fields
->f_crnx_hi
, 0, 0, 28, 1, 32, total_length
, buffer
);
699 errmsg
= insert_normal (cd
, fields
->f_crnx_lo
, 0, 0, 4, 4, 32, total_length
, buffer
);
704 case MEP_OPERAND_CSRN
:
707 FLD (f_csrn_lo
) = ((FLD (f_csrn
)) & (15));
708 FLD (f_csrn_hi
) = ((unsigned int) (FLD (f_csrn
)) >> (4));
710 errmsg
= insert_normal (cd
, fields
->f_csrn_hi
, 0, 0, 15, 1, 32, total_length
, buffer
);
713 errmsg
= insert_normal (cd
, fields
->f_csrn_lo
, 0, 0, 8, 4, 32, total_length
, buffer
);
718 case MEP_OPERAND_CSRN_IDX
:
721 FLD (f_csrn_lo
) = ((FLD (f_csrn
)) & (15));
722 FLD (f_csrn_hi
) = ((unsigned int) (FLD (f_csrn
)) >> (4));
724 errmsg
= insert_normal (cd
, fields
->f_csrn_hi
, 0, 0, 15, 1, 32, total_length
, buffer
);
727 errmsg
= insert_normal (cd
, fields
->f_csrn_lo
, 0, 0, 8, 4, 32, total_length
, buffer
);
732 case MEP_OPERAND_DBG
:
734 case MEP_OPERAND_DEPC
:
736 case MEP_OPERAND_EPC
:
738 case MEP_OPERAND_EXC
:
740 case MEP_OPERAND_HI
:
742 case MEP_OPERAND_LO
:
744 case MEP_OPERAND_LP
:
746 case MEP_OPERAND_MB0
:
748 case MEP_OPERAND_MB1
:
750 case MEP_OPERAND_ME0
:
752 case MEP_OPERAND_ME1
:
754 case MEP_OPERAND_NPC
:
756 case MEP_OPERAND_OPT
:
758 case MEP_OPERAND_PCABS24A2
:
761 FLD (f_24u5a2n_lo
) = ((unsigned int) (((FLD (f_24u5a2n
)) & (255))) >> (1));
762 FLD (f_24u5a2n_hi
) = ((unsigned int) (FLD (f_24u5a2n
)) >> (8));
764 errmsg
= insert_normal (cd
, fields
->f_24u5a2n_hi
, 0, 0, 16, 16, 32, total_length
, buffer
);
767 errmsg
= insert_normal (cd
, fields
->f_24u5a2n_lo
, 0, 0, 5, 7, 32, total_length
, buffer
);
772 case MEP_OPERAND_PCREL12A2
:
774 long value
= fields
->f_12s4a2
;
775 value
= ((int) (((value
) - (pc
))) >> (1));
776 errmsg
= insert_normal (cd
, value
, 0|(1<<CGEN_IFLD_SIGNED
)|(1<<CGEN_IFLD_PCREL_ADDR
), 0, 4, 11, 32, total_length
, buffer
);
779 case MEP_OPERAND_PCREL17A2
:
781 long value
= fields
->f_17s16a2
;
782 value
= ((int) (((value
) - (pc
))) >> (1));
783 errmsg
= insert_normal (cd
, value
, 0|(1<<CGEN_IFLD_SIGNED
)|(1<<CGEN_IFLD_PCREL_ADDR
), 0, 16, 16, 32, total_length
, buffer
);
786 case MEP_OPERAND_PCREL24A2
:
789 FLD (f_24s5a2n
) = ((FLD (f_24s5a2n
)) - (pc
));
790 FLD (f_24s5a2n_lo
) = ((unsigned int) (((FLD (f_24s5a2n
)) & (254))) >> (1));
791 FLD (f_24s5a2n_hi
) = ((int) (FLD (f_24s5a2n
)) >> (8));
793 errmsg
= insert_normal (cd
, fields
->f_24s5a2n_hi
, 0|(1<<CGEN_IFLD_SIGNED
)|(1<<CGEN_IFLD_PCREL_ADDR
), 0, 16, 16, 32, total_length
, buffer
);
796 errmsg
= insert_normal (cd
, fields
->f_24s5a2n_lo
, 0|(1<<CGEN_IFLD_PCREL_ADDR
), 0, 5, 7, 32, total_length
, buffer
);
801 case MEP_OPERAND_PCREL8A2
:
803 long value
= fields
->f_8s8a2
;
804 value
= ((int) (((value
) - (pc
))) >> (1));
805 errmsg
= insert_normal (cd
, value
, 0|(1<<CGEN_IFLD_SIGNED
)|(1<<CGEN_IFLD_PCREL_ADDR
), 0, 8, 7, 32, total_length
, buffer
);
808 case MEP_OPERAND_PSW
:
810 case MEP_OPERAND_R0
:
812 case MEP_OPERAND_R1
:
814 case MEP_OPERAND_RL
:
815 errmsg
= insert_normal (cd
, fields
->f_rl
, 0, 0, 12, 4, 32, total_length
, buffer
);
817 case MEP_OPERAND_RM
:
818 errmsg
= insert_normal (cd
, fields
->f_rm
, 0, 0, 8, 4, 32, total_length
, buffer
);
820 case MEP_OPERAND_RMA
:
821 errmsg
= insert_normal (cd
, fields
->f_rm
, 0, 0, 8, 4, 32, total_length
, buffer
);
823 case MEP_OPERAND_RN
:
824 errmsg
= insert_normal (cd
, fields
->f_rn
, 0, 0, 4, 4, 32, total_length
, buffer
);
826 case MEP_OPERAND_RN3
:
827 errmsg
= insert_normal (cd
, fields
->f_rn3
, 0, 0, 5, 3, 32, total_length
, buffer
);
829 case MEP_OPERAND_RN3C
:
830 errmsg
= insert_normal (cd
, fields
->f_rn3
, 0, 0, 5, 3, 32, total_length
, buffer
);
832 case MEP_OPERAND_RN3L
:
833 errmsg
= insert_normal (cd
, fields
->f_rn3
, 0, 0, 5, 3, 32, total_length
, buffer
);
835 case MEP_OPERAND_RN3S
:
836 errmsg
= insert_normal (cd
, fields
->f_rn3
, 0, 0, 5, 3, 32, total_length
, buffer
);
838 case MEP_OPERAND_RN3UC
:
839 errmsg
= insert_normal (cd
, fields
->f_rn3
, 0, 0, 5, 3, 32, total_length
, buffer
);
841 case MEP_OPERAND_RN3UL
:
842 errmsg
= insert_normal (cd
, fields
->f_rn3
, 0, 0, 5, 3, 32, total_length
, buffer
);
844 case MEP_OPERAND_RN3US
:
845 errmsg
= insert_normal (cd
, fields
->f_rn3
, 0, 0, 5, 3, 32, total_length
, buffer
);
847 case MEP_OPERAND_RNC
:
848 errmsg
= insert_normal (cd
, fields
->f_rn
, 0, 0, 4, 4, 32, total_length
, buffer
);
850 case MEP_OPERAND_RNL
:
851 errmsg
= insert_normal (cd
, fields
->f_rn
, 0, 0, 4, 4, 32, total_length
, buffer
);
853 case MEP_OPERAND_RNS
:
854 errmsg
= insert_normal (cd
, fields
->f_rn
, 0, 0, 4, 4, 32, total_length
, buffer
);
856 case MEP_OPERAND_RNUC
:
857 errmsg
= insert_normal (cd
, fields
->f_rn
, 0, 0, 4, 4, 32, total_length
, buffer
);
859 case MEP_OPERAND_RNUL
:
860 errmsg
= insert_normal (cd
, fields
->f_rn
, 0, 0, 4, 4, 32, total_length
, buffer
);
862 case MEP_OPERAND_RNUS
:
863 errmsg
= insert_normal (cd
, fields
->f_rn
, 0, 0, 4, 4, 32, total_length
, buffer
);
865 case MEP_OPERAND_SAR
:
867 case MEP_OPERAND_SDISP16
:
868 errmsg
= insert_normal (cd
, fields
->f_16s16
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 16, 16, 32, total_length
, buffer
);
870 case MEP_OPERAND_SIMM16
:
871 errmsg
= insert_normal (cd
, fields
->f_16s16
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 16, 16, 32, total_length
, buffer
);
873 case MEP_OPERAND_SIMM6
:
874 errmsg
= insert_normal (cd
, fields
->f_6s8
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 8, 6, 32, total_length
, buffer
);
876 case MEP_OPERAND_SIMM8
:
877 errmsg
= insert_normal (cd
, fields
->f_8s8
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 8, 8, 32, total_length
, buffer
);
879 case MEP_OPERAND_SP
:
881 case MEP_OPERAND_SPR
:
883 case MEP_OPERAND_TP
:
885 case MEP_OPERAND_TPR
:
887 case MEP_OPERAND_UDISP2
:
888 errmsg
= insert_normal (cd
, fields
->f_2u6
, 0, 0, 6, 2, 32, total_length
, buffer
);
890 case MEP_OPERAND_UDISP7
:
891 errmsg
= insert_normal (cd
, fields
->f_7u9
, 0, 0, 9, 7, 32, total_length
, buffer
);
893 case MEP_OPERAND_UDISP7A2
:
895 long value
= fields
->f_7u9a2
;
896 value
= ((unsigned int) (value
) >> (1));
897 errmsg
= insert_normal (cd
, value
, 0, 0, 9, 6, 32, total_length
, buffer
);
900 case MEP_OPERAND_UDISP7A4
:
902 long value
= fields
->f_7u9a4
;
903 value
= ((unsigned int) (value
) >> (2));
904 errmsg
= insert_normal (cd
, value
, 0, 0, 9, 5, 32, total_length
, buffer
);
907 case MEP_OPERAND_UIMM16
:
908 errmsg
= insert_normal (cd
, fields
->f_16u16
, 0, 0, 16, 16, 32, total_length
, buffer
);
910 case MEP_OPERAND_UIMM2
:
911 errmsg
= insert_normal (cd
, fields
->f_2u10
, 0, 0, 10, 2, 32, total_length
, buffer
);
913 case MEP_OPERAND_UIMM24
:
916 FLD (f_24u8n_hi
) = ((unsigned int) (FLD (f_24u8n
)) >> (8));
917 FLD (f_24u8n_lo
) = ((FLD (f_24u8n
)) & (255));
919 errmsg
= insert_normal (cd
, fields
->f_24u8n_hi
, 0, 0, 16, 16, 32, total_length
, buffer
);
922 errmsg
= insert_normal (cd
, fields
->f_24u8n_lo
, 0, 0, 8, 8, 32, total_length
, buffer
);
927 case MEP_OPERAND_UIMM3
:
928 errmsg
= insert_normal (cd
, fields
->f_3u5
, 0, 0, 5, 3, 32, total_length
, buffer
);
930 case MEP_OPERAND_UIMM4
:
931 errmsg
= insert_normal (cd
, fields
->f_4u8
, 0, 0, 8, 4, 32, total_length
, buffer
);
933 case MEP_OPERAND_UIMM5
:
934 errmsg
= insert_normal (cd
, fields
->f_5u8
, 0, 0, 8, 5, 32, total_length
, buffer
);
936 case MEP_OPERAND_UIMM7A4
:
938 long value
= fields
->f_7u9a4
;
939 value
= ((unsigned int) (value
) >> (2));
940 errmsg
= insert_normal (cd
, value
, 0, 0, 9, 5, 32, total_length
, buffer
);
943 case MEP_OPERAND_ZERO
:
947 /* xgettext:c-format */
948 fprintf (stderr
, _("Unrecognized field %d while building insn.\n"),
956 int mep_cgen_extract_operand
957 (CGEN_CPU_DESC
, int, CGEN_EXTRACT_INFO
*, CGEN_INSN_INT
, CGEN_FIELDS
*, bfd_vma
);
959 /* Main entry point for operand extraction.
960 The result is <= 0 for error, >0 for success.
961 ??? Actual values aren't well defined right now.
963 This function is basically just a big switch statement. Earlier versions
964 used tables to look up the function to use, but
965 - if the table contains both assembler and disassembler functions then
966 the disassembler contains much of the assembler and vice-versa,
967 - there's a lot of inlining possibilities as things grow,
968 - using a switch statement avoids the function call overhead.
970 This function could be moved into `print_insn_normal', but keeping it
971 separate makes clear the interface between `print_insn_normal' and each of
975 mep_cgen_extract_operand (CGEN_CPU_DESC cd
,
977 CGEN_EXTRACT_INFO
*ex_info
,
978 CGEN_INSN_INT insn_value
,
979 CGEN_FIELDS
* fields
,
982 /* Assume success (for those operands that are nops). */
984 unsigned int total_length
= CGEN_FIELDS_BITSIZE (fields
);
988 case MEP_OPERAND_ADDR24A4
:
990 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 16, 16, 32, total_length
, pc
, & fields
->f_24u8a4n_hi
);
991 if (length
<= 0) break;
992 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 8, 6, 32, total_length
, pc
, & fields
->f_24u8a4n_lo
);
993 if (length
<= 0) break;
994 FLD (f_24u8a4n
) = ((((FLD (f_24u8a4n_hi
)) << (8))) | (((FLD (f_24u8a4n_lo
)) << (2))));
997 case MEP_OPERAND_CALLNUM
:
999 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 5, 1, 32, total_length
, pc
, & fields
->f_5
);
1000 if (length
<= 0) break;
1001 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 6, 1, 32, total_length
, pc
, & fields
->f_6
);
1002 if (length
<= 0) break;
1003 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 7, 1, 32, total_length
, pc
, & fields
->f_7
);
1004 if (length
<= 0) break;
1005 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 11, 1, 32, total_length
, pc
, & fields
->f_11
);
1006 if (length
<= 0) break;
1007 FLD (f_callnum
) = ((((FLD (f_5
)) << (3))) | (((((FLD (f_6
)) << (2))) | (((((FLD (f_7
)) << (1))) | (FLD (f_11
)))))));
1010 case MEP_OPERAND_CCCC
:
1011 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 8, 4, 32, total_length
, pc
, & fields
->f_rm
);
1013 case MEP_OPERAND_CCRN
:
1015 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 28, 2, 32, total_length
, pc
, & fields
->f_ccrn_hi
);
1016 if (length
<= 0) break;
1017 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_ccrn_lo
);
1018 if (length
<= 0) break;
1019 FLD (f_ccrn
) = ((((FLD (f_ccrn_hi
)) << (4))) | (FLD (f_ccrn_lo
)));
1022 case MEP_OPERAND_CDISP8
:
1023 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 24, 8, 32, total_length
, pc
, & fields
->f_8s24
);
1025 case MEP_OPERAND_CDISP8A2
:
1028 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 24, 7, 32, total_length
, pc
, & value
);
1029 value
= ((value
) << (1));
1030 fields
->f_8s24a2
= value
;
1033 case MEP_OPERAND_CDISP8A4
:
1036 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 24, 6, 32, total_length
, pc
, & value
);
1037 value
= ((value
) << (2));
1038 fields
->f_8s24a4
= value
;
1041 case MEP_OPERAND_CDISP8A8
:
1044 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 24, 5, 32, total_length
, pc
, & value
);
1045 value
= ((value
) << (3));
1046 fields
->f_8s24a8
= value
;
1049 case MEP_OPERAND_CIMM4
:
1050 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_rn
);
1052 case MEP_OPERAND_CIMM5
:
1053 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 24, 5, 32, total_length
, pc
, & fields
->f_5u24
);
1055 case MEP_OPERAND_CODE16
:
1056 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 16, 16, 32, total_length
, pc
, & fields
->f_16u16
);
1058 case MEP_OPERAND_CODE24
:
1060 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 8, 32, total_length
, pc
, & fields
->f_24u4n_hi
);
1061 if (length
<= 0) break;
1062 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 16, 16, 32, total_length
, pc
, & fields
->f_24u4n_lo
);
1063 if (length
<= 0) break;
1064 FLD (f_24u4n
) = ((((FLD (f_24u4n_hi
)) << (16))) | (FLD (f_24u4n_lo
)));
1067 case MEP_OPERAND_CP_FLAG
:
1069 case MEP_OPERAND_CRN
:
1070 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_crn
);
1072 case MEP_OPERAND_CRN64
:
1073 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_crn
);
1075 case MEP_OPERAND_CRNX
:
1077 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 28, 1, 32, total_length
, pc
, & fields
->f_crnx_hi
);
1078 if (length
<= 0) break;
1079 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_crnx_lo
);
1080 if (length
<= 0) break;
1081 FLD (f_crnx
) = ((((FLD (f_crnx_hi
)) << (4))) | (FLD (f_crnx_lo
)));
1084 case MEP_OPERAND_CRNX64
:
1086 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 28, 1, 32, total_length
, pc
, & fields
->f_crnx_hi
);
1087 if (length
<= 0) break;
1088 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_crnx_lo
);
1089 if (length
<= 0) break;
1090 FLD (f_crnx
) = ((((FLD (f_crnx_hi
)) << (4))) | (FLD (f_crnx_lo
)));
1093 case MEP_OPERAND_CSRN
:
1095 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 1, 32, total_length
, pc
, & fields
->f_csrn_hi
);
1096 if (length
<= 0) break;
1097 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 8, 4, 32, total_length
, pc
, & fields
->f_csrn_lo
);
1098 if (length
<= 0) break;
1099 FLD (f_csrn
) = ((((FLD (f_csrn_hi
)) << (4))) | (FLD (f_csrn_lo
)));
1102 case MEP_OPERAND_CSRN_IDX
:
1104 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 1, 32, total_length
, pc
, & fields
->f_csrn_hi
);
1105 if (length
<= 0) break;
1106 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 8, 4, 32, total_length
, pc
, & fields
->f_csrn_lo
);
1107 if (length
<= 0) break;
1108 FLD (f_csrn
) = ((((FLD (f_csrn_hi
)) << (4))) | (FLD (f_csrn_lo
)));
1111 case MEP_OPERAND_DBG
:
1113 case MEP_OPERAND_DEPC
:
1115 case MEP_OPERAND_EPC
:
1117 case MEP_OPERAND_EXC
:
1119 case MEP_OPERAND_HI
:
1121 case MEP_OPERAND_LO
:
1123 case MEP_OPERAND_LP
:
1125 case MEP_OPERAND_MB0
:
1127 case MEP_OPERAND_MB1
:
1129 case MEP_OPERAND_ME0
:
1131 case MEP_OPERAND_ME1
:
1133 case MEP_OPERAND_NPC
:
1135 case MEP_OPERAND_OPT
:
1137 case MEP_OPERAND_PCABS24A2
:
1139 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 16, 16, 32, total_length
, pc
, & fields
->f_24u5a2n_hi
);
1140 if (length
<= 0) break;
1141 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 5, 7, 32, total_length
, pc
, & fields
->f_24u5a2n_lo
);
1142 if (length
<= 0) break;
1143 FLD (f_24u5a2n
) = ((((FLD (f_24u5a2n_hi
)) << (8))) | (((FLD (f_24u5a2n_lo
)) << (1))));
1146 case MEP_OPERAND_PCREL12A2
:
1149 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
)|(1<<CGEN_IFLD_PCREL_ADDR
), 0, 4, 11, 32, total_length
, pc
, & value
);
1150 value
= ((((value
) << (1))) + (pc
));
1151 fields
->f_12s4a2
= value
;
1154 case MEP_OPERAND_PCREL17A2
:
1157 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
)|(1<<CGEN_IFLD_PCREL_ADDR
), 0, 16, 16, 32, total_length
, pc
, & value
);
1158 value
= ((((value
) << (1))) + (pc
));
1159 fields
->f_17s16a2
= value
;
1162 case MEP_OPERAND_PCREL24A2
:
1164 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
)|(1<<CGEN_IFLD_PCREL_ADDR
), 0, 16, 16, 32, total_length
, pc
, & fields
->f_24s5a2n_hi
);
1165 if (length
<= 0) break;
1166 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_PCREL_ADDR
), 0, 5, 7, 32, total_length
, pc
, & fields
->f_24s5a2n_lo
);
1167 if (length
<= 0) break;
1168 FLD (f_24s5a2n
) = ((((((FLD (f_24s5a2n_hi
)) << (8))) | (((FLD (f_24s5a2n_lo
)) << (1))))) + (pc
));
1171 case MEP_OPERAND_PCREL8A2
:
1174 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
)|(1<<CGEN_IFLD_PCREL_ADDR
), 0, 8, 7, 32, total_length
, pc
, & value
);
1175 value
= ((((value
) << (1))) + (pc
));
1176 fields
->f_8s8a2
= value
;
1179 case MEP_OPERAND_PSW
:
1181 case MEP_OPERAND_R0
:
1183 case MEP_OPERAND_R1
:
1185 case MEP_OPERAND_RL
:
1186 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 12, 4, 32, total_length
, pc
, & fields
->f_rl
);
1188 case MEP_OPERAND_RM
:
1189 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 8, 4, 32, total_length
, pc
, & fields
->f_rm
);
1191 case MEP_OPERAND_RMA
:
1192 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 8, 4, 32, total_length
, pc
, & fields
->f_rm
);
1194 case MEP_OPERAND_RN
:
1195 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_rn
);
1197 case MEP_OPERAND_RN3
:
1198 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 5, 3, 32, total_length
, pc
, & fields
->f_rn3
);
1200 case MEP_OPERAND_RN3C
:
1201 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 5, 3, 32, total_length
, pc
, & fields
->f_rn3
);
1203 case MEP_OPERAND_RN3L
:
1204 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 5, 3, 32, total_length
, pc
, & fields
->f_rn3
);
1206 case MEP_OPERAND_RN3S
:
1207 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 5, 3, 32, total_length
, pc
, & fields
->f_rn3
);
1209 case MEP_OPERAND_RN3UC
:
1210 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 5, 3, 32, total_length
, pc
, & fields
->f_rn3
);
1212 case MEP_OPERAND_RN3UL
:
1213 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 5, 3, 32, total_length
, pc
, & fields
->f_rn3
);
1215 case MEP_OPERAND_RN3US
:
1216 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 5, 3, 32, total_length
, pc
, & fields
->f_rn3
);
1218 case MEP_OPERAND_RNC
:
1219 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_rn
);
1221 case MEP_OPERAND_RNL
:
1222 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_rn
);
1224 case MEP_OPERAND_RNS
:
1225 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_rn
);
1227 case MEP_OPERAND_RNUC
:
1228 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_rn
);
1230 case MEP_OPERAND_RNUL
:
1231 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_rn
);
1233 case MEP_OPERAND_RNUS
:
1234 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_rn
);
1236 case MEP_OPERAND_SAR
:
1238 case MEP_OPERAND_SDISP16
:
1239 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 16, 16, 32, total_length
, pc
, & fields
->f_16s16
);
1241 case MEP_OPERAND_SIMM16
:
1242 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 16, 16, 32, total_length
, pc
, & fields
->f_16s16
);
1244 case MEP_OPERAND_SIMM6
:
1245 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 8, 6, 32, total_length
, pc
, & fields
->f_6s8
);
1247 case MEP_OPERAND_SIMM8
:
1248 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 8, 8, 32, total_length
, pc
, & fields
->f_8s8
);
1250 case MEP_OPERAND_SP
:
1252 case MEP_OPERAND_SPR
:
1254 case MEP_OPERAND_TP
:
1256 case MEP_OPERAND_TPR
:
1258 case MEP_OPERAND_UDISP2
:
1259 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 6, 2, 32, total_length
, pc
, & fields
->f_2u6
);
1261 case MEP_OPERAND_UDISP7
:
1262 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 9, 7, 32, total_length
, pc
, & fields
->f_7u9
);
1264 case MEP_OPERAND_UDISP7A2
:
1267 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 9, 6, 32, total_length
, pc
, & value
);
1268 value
= ((value
) << (1));
1269 fields
->f_7u9a2
= value
;
1272 case MEP_OPERAND_UDISP7A4
:
1275 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 9, 5, 32, total_length
, pc
, & value
);
1276 value
= ((value
) << (2));
1277 fields
->f_7u9a4
= value
;
1280 case MEP_OPERAND_UIMM16
:
1281 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 16, 16, 32, total_length
, pc
, & fields
->f_16u16
);
1283 case MEP_OPERAND_UIMM2
:
1284 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 10, 2, 32, total_length
, pc
, & fields
->f_2u10
);
1286 case MEP_OPERAND_UIMM24
:
1288 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 16, 16, 32, total_length
, pc
, & fields
->f_24u8n_hi
);
1289 if (length
<= 0) break;
1290 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 8, 8, 32, total_length
, pc
, & fields
->f_24u8n_lo
);
1291 if (length
<= 0) break;
1292 FLD (f_24u8n
) = ((((FLD (f_24u8n_hi
)) << (8))) | (FLD (f_24u8n_lo
)));
1295 case MEP_OPERAND_UIMM3
:
1296 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 5, 3, 32, total_length
, pc
, & fields
->f_3u5
);
1298 case MEP_OPERAND_UIMM4
:
1299 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 8, 4, 32, total_length
, pc
, & fields
->f_4u8
);
1301 case MEP_OPERAND_UIMM5
:
1302 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 8, 5, 32, total_length
, pc
, & fields
->f_5u8
);
1304 case MEP_OPERAND_UIMM7A4
:
1307 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 9, 5, 32, total_length
, pc
, & value
);
1308 value
= ((value
) << (2));
1309 fields
->f_7u9a4
= value
;
1312 case MEP_OPERAND_ZERO
:
1316 /* xgettext:c-format */
1317 fprintf (stderr
, _("Unrecognized field %d while decoding insn.\n"),
1325 cgen_insert_fn
* const mep_cgen_insert_handlers
[] =
1330 cgen_extract_fn
* const mep_cgen_extract_handlers
[] =
1332 extract_insn_normal
,
1335 int mep_cgen_get_int_operand (CGEN_CPU_DESC
, int, const CGEN_FIELDS
*);
1336 bfd_vma
mep_cgen_get_vma_operand (CGEN_CPU_DESC
, int, const CGEN_FIELDS
*);
1338 /* Getting values from cgen_fields is handled by a collection of functions.
1339 They are distinguished by the type of the VALUE argument they return.
1340 TODO: floating point, inlining support, remove cases where result type
1344 mep_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
1346 const CGEN_FIELDS
* fields
)
1352 case MEP_OPERAND_ADDR24A4
:
1353 value
= fields
->f_24u8a4n
;
1355 case MEP_OPERAND_CALLNUM
:
1356 value
= fields
->f_callnum
;
1358 case MEP_OPERAND_CCCC
:
1359 value
= fields
->f_rm
;
1361 case MEP_OPERAND_CCRN
:
1362 value
= fields
->f_ccrn
;
1364 case MEP_OPERAND_CDISP8
:
1365 value
= fields
->f_8s24
;
1367 case MEP_OPERAND_CDISP8A2
:
1368 value
= fields
->f_8s24a2
;
1370 case MEP_OPERAND_CDISP8A4
:
1371 value
= fields
->f_8s24a4
;
1373 case MEP_OPERAND_CDISP8A8
:
1374 value
= fields
->f_8s24a8
;
1376 case MEP_OPERAND_CIMM4
:
1377 value
= fields
->f_rn
;
1379 case MEP_OPERAND_CIMM5
:
1380 value
= fields
->f_5u24
;
1382 case MEP_OPERAND_CODE16
:
1383 value
= fields
->f_16u16
;
1385 case MEP_OPERAND_CODE24
:
1386 value
= fields
->f_24u4n
;
1388 case MEP_OPERAND_CP_FLAG
:
1391 case MEP_OPERAND_CRN
:
1392 value
= fields
->f_crn
;
1394 case MEP_OPERAND_CRN64
:
1395 value
= fields
->f_crn
;
1397 case MEP_OPERAND_CRNX
:
1398 value
= fields
->f_crnx
;
1400 case MEP_OPERAND_CRNX64
:
1401 value
= fields
->f_crnx
;
1403 case MEP_OPERAND_CSRN
:
1404 value
= fields
->f_csrn
;
1406 case MEP_OPERAND_CSRN_IDX
:
1407 value
= fields
->f_csrn
;
1409 case MEP_OPERAND_DBG
:
1412 case MEP_OPERAND_DEPC
:
1415 case MEP_OPERAND_EPC
:
1418 case MEP_OPERAND_EXC
:
1421 case MEP_OPERAND_HI
:
1424 case MEP_OPERAND_LO
:
1427 case MEP_OPERAND_LP
:
1430 case MEP_OPERAND_MB0
:
1433 case MEP_OPERAND_MB1
:
1436 case MEP_OPERAND_ME0
:
1439 case MEP_OPERAND_ME1
:
1442 case MEP_OPERAND_NPC
:
1445 case MEP_OPERAND_OPT
:
1448 case MEP_OPERAND_PCABS24A2
:
1449 value
= fields
->f_24u5a2n
;
1451 case MEP_OPERAND_PCREL12A2
:
1452 value
= fields
->f_12s4a2
;
1454 case MEP_OPERAND_PCREL17A2
:
1455 value
= fields
->f_17s16a2
;
1457 case MEP_OPERAND_PCREL24A2
:
1458 value
= fields
->f_24s5a2n
;
1460 case MEP_OPERAND_PCREL8A2
:
1461 value
= fields
->f_8s8a2
;
1463 case MEP_OPERAND_PSW
:
1466 case MEP_OPERAND_R0
:
1469 case MEP_OPERAND_R1
:
1472 case MEP_OPERAND_RL
:
1473 value
= fields
->f_rl
;
1475 case MEP_OPERAND_RM
:
1476 value
= fields
->f_rm
;
1478 case MEP_OPERAND_RMA
:
1479 value
= fields
->f_rm
;
1481 case MEP_OPERAND_RN
:
1482 value
= fields
->f_rn
;
1484 case MEP_OPERAND_RN3
:
1485 value
= fields
->f_rn3
;
1487 case MEP_OPERAND_RN3C
:
1488 value
= fields
->f_rn3
;
1490 case MEP_OPERAND_RN3L
:
1491 value
= fields
->f_rn3
;
1493 case MEP_OPERAND_RN3S
:
1494 value
= fields
->f_rn3
;
1496 case MEP_OPERAND_RN3UC
:
1497 value
= fields
->f_rn3
;
1499 case MEP_OPERAND_RN3UL
:
1500 value
= fields
->f_rn3
;
1502 case MEP_OPERAND_RN3US
:
1503 value
= fields
->f_rn3
;
1505 case MEP_OPERAND_RNC
:
1506 value
= fields
->f_rn
;
1508 case MEP_OPERAND_RNL
:
1509 value
= fields
->f_rn
;
1511 case MEP_OPERAND_RNS
:
1512 value
= fields
->f_rn
;
1514 case MEP_OPERAND_RNUC
:
1515 value
= fields
->f_rn
;
1517 case MEP_OPERAND_RNUL
:
1518 value
= fields
->f_rn
;
1520 case MEP_OPERAND_RNUS
:
1521 value
= fields
->f_rn
;
1523 case MEP_OPERAND_SAR
:
1526 case MEP_OPERAND_SDISP16
:
1527 value
= fields
->f_16s16
;
1529 case MEP_OPERAND_SIMM16
:
1530 value
= fields
->f_16s16
;
1532 case MEP_OPERAND_SIMM6
:
1533 value
= fields
->f_6s8
;
1535 case MEP_OPERAND_SIMM8
:
1536 value
= fields
->f_8s8
;
1538 case MEP_OPERAND_SP
:
1541 case MEP_OPERAND_SPR
:
1544 case MEP_OPERAND_TP
:
1547 case MEP_OPERAND_TPR
:
1550 case MEP_OPERAND_UDISP2
:
1551 value
= fields
->f_2u6
;
1553 case MEP_OPERAND_UDISP7
:
1554 value
= fields
->f_7u9
;
1556 case MEP_OPERAND_UDISP7A2
:
1557 value
= fields
->f_7u9a2
;
1559 case MEP_OPERAND_UDISP7A4
:
1560 value
= fields
->f_7u9a4
;
1562 case MEP_OPERAND_UIMM16
:
1563 value
= fields
->f_16u16
;
1565 case MEP_OPERAND_UIMM2
:
1566 value
= fields
->f_2u10
;
1568 case MEP_OPERAND_UIMM24
:
1569 value
= fields
->f_24u8n
;
1571 case MEP_OPERAND_UIMM3
:
1572 value
= fields
->f_3u5
;
1574 case MEP_OPERAND_UIMM4
:
1575 value
= fields
->f_4u8
;
1577 case MEP_OPERAND_UIMM5
:
1578 value
= fields
->f_5u8
;
1580 case MEP_OPERAND_UIMM7A4
:
1581 value
= fields
->f_7u9a4
;
1583 case MEP_OPERAND_ZERO
:
1588 /* xgettext:c-format */
1589 fprintf (stderr
, _("Unrecognized field %d while getting int operand.\n"),
1598 mep_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
1600 const CGEN_FIELDS
* fields
)
1606 case MEP_OPERAND_ADDR24A4
:
1607 value
= fields
->f_24u8a4n
;
1609 case MEP_OPERAND_CALLNUM
:
1610 value
= fields
->f_callnum
;
1612 case MEP_OPERAND_CCCC
:
1613 value
= fields
->f_rm
;
1615 case MEP_OPERAND_CCRN
:
1616 value
= fields
->f_ccrn
;
1618 case MEP_OPERAND_CDISP8
:
1619 value
= fields
->f_8s24
;
1621 case MEP_OPERAND_CDISP8A2
:
1622 value
= fields
->f_8s24a2
;
1624 case MEP_OPERAND_CDISP8A4
:
1625 value
= fields
->f_8s24a4
;
1627 case MEP_OPERAND_CDISP8A8
:
1628 value
= fields
->f_8s24a8
;
1630 case MEP_OPERAND_CIMM4
:
1631 value
= fields
->f_rn
;
1633 case MEP_OPERAND_CIMM5
:
1634 value
= fields
->f_5u24
;
1636 case MEP_OPERAND_CODE16
:
1637 value
= fields
->f_16u16
;
1639 case MEP_OPERAND_CODE24
:
1640 value
= fields
->f_24u4n
;
1642 case MEP_OPERAND_CP_FLAG
:
1645 case MEP_OPERAND_CRN
:
1646 value
= fields
->f_crn
;
1648 case MEP_OPERAND_CRN64
:
1649 value
= fields
->f_crn
;
1651 case MEP_OPERAND_CRNX
:
1652 value
= fields
->f_crnx
;
1654 case MEP_OPERAND_CRNX64
:
1655 value
= fields
->f_crnx
;
1657 case MEP_OPERAND_CSRN
:
1658 value
= fields
->f_csrn
;
1660 case MEP_OPERAND_CSRN_IDX
:
1661 value
= fields
->f_csrn
;
1663 case MEP_OPERAND_DBG
:
1666 case MEP_OPERAND_DEPC
:
1669 case MEP_OPERAND_EPC
:
1672 case MEP_OPERAND_EXC
:
1675 case MEP_OPERAND_HI
:
1678 case MEP_OPERAND_LO
:
1681 case MEP_OPERAND_LP
:
1684 case MEP_OPERAND_MB0
:
1687 case MEP_OPERAND_MB1
:
1690 case MEP_OPERAND_ME0
:
1693 case MEP_OPERAND_ME1
:
1696 case MEP_OPERAND_NPC
:
1699 case MEP_OPERAND_OPT
:
1702 case MEP_OPERAND_PCABS24A2
:
1703 value
= fields
->f_24u5a2n
;
1705 case MEP_OPERAND_PCREL12A2
:
1706 value
= fields
->f_12s4a2
;
1708 case MEP_OPERAND_PCREL17A2
:
1709 value
= fields
->f_17s16a2
;
1711 case MEP_OPERAND_PCREL24A2
:
1712 value
= fields
->f_24s5a2n
;
1714 case MEP_OPERAND_PCREL8A2
:
1715 value
= fields
->f_8s8a2
;
1717 case MEP_OPERAND_PSW
:
1720 case MEP_OPERAND_R0
:
1723 case MEP_OPERAND_R1
:
1726 case MEP_OPERAND_RL
:
1727 value
= fields
->f_rl
;
1729 case MEP_OPERAND_RM
:
1730 value
= fields
->f_rm
;
1732 case MEP_OPERAND_RMA
:
1733 value
= fields
->f_rm
;
1735 case MEP_OPERAND_RN
:
1736 value
= fields
->f_rn
;
1738 case MEP_OPERAND_RN3
:
1739 value
= fields
->f_rn3
;
1741 case MEP_OPERAND_RN3C
:
1742 value
= fields
->f_rn3
;
1744 case MEP_OPERAND_RN3L
:
1745 value
= fields
->f_rn3
;
1747 case MEP_OPERAND_RN3S
:
1748 value
= fields
->f_rn3
;
1750 case MEP_OPERAND_RN3UC
:
1751 value
= fields
->f_rn3
;
1753 case MEP_OPERAND_RN3UL
:
1754 value
= fields
->f_rn3
;
1756 case MEP_OPERAND_RN3US
:
1757 value
= fields
->f_rn3
;
1759 case MEP_OPERAND_RNC
:
1760 value
= fields
->f_rn
;
1762 case MEP_OPERAND_RNL
:
1763 value
= fields
->f_rn
;
1765 case MEP_OPERAND_RNS
:
1766 value
= fields
->f_rn
;
1768 case MEP_OPERAND_RNUC
:
1769 value
= fields
->f_rn
;
1771 case MEP_OPERAND_RNUL
:
1772 value
= fields
->f_rn
;
1774 case MEP_OPERAND_RNUS
:
1775 value
= fields
->f_rn
;
1777 case MEP_OPERAND_SAR
:
1780 case MEP_OPERAND_SDISP16
:
1781 value
= fields
->f_16s16
;
1783 case MEP_OPERAND_SIMM16
:
1784 value
= fields
->f_16s16
;
1786 case MEP_OPERAND_SIMM6
:
1787 value
= fields
->f_6s8
;
1789 case MEP_OPERAND_SIMM8
:
1790 value
= fields
->f_8s8
;
1792 case MEP_OPERAND_SP
:
1795 case MEP_OPERAND_SPR
:
1798 case MEP_OPERAND_TP
:
1801 case MEP_OPERAND_TPR
:
1804 case MEP_OPERAND_UDISP2
:
1805 value
= fields
->f_2u6
;
1807 case MEP_OPERAND_UDISP7
:
1808 value
= fields
->f_7u9
;
1810 case MEP_OPERAND_UDISP7A2
:
1811 value
= fields
->f_7u9a2
;
1813 case MEP_OPERAND_UDISP7A4
:
1814 value
= fields
->f_7u9a4
;
1816 case MEP_OPERAND_UIMM16
:
1817 value
= fields
->f_16u16
;
1819 case MEP_OPERAND_UIMM2
:
1820 value
= fields
->f_2u10
;
1822 case MEP_OPERAND_UIMM24
:
1823 value
= fields
->f_24u8n
;
1825 case MEP_OPERAND_UIMM3
:
1826 value
= fields
->f_3u5
;
1828 case MEP_OPERAND_UIMM4
:
1829 value
= fields
->f_4u8
;
1831 case MEP_OPERAND_UIMM5
:
1832 value
= fields
->f_5u8
;
1834 case MEP_OPERAND_UIMM7A4
:
1835 value
= fields
->f_7u9a4
;
1837 case MEP_OPERAND_ZERO
:
1842 /* xgettext:c-format */
1843 fprintf (stderr
, _("Unrecognized field %d while getting vma operand.\n"),
1851 void mep_cgen_set_int_operand (CGEN_CPU_DESC
, int, CGEN_FIELDS
*, int);
1852 void mep_cgen_set_vma_operand (CGEN_CPU_DESC
, int, CGEN_FIELDS
*, bfd_vma
);
1854 /* Stuffing values in cgen_fields is handled by a collection of functions.
1855 They are distinguished by the type of the VALUE argument they accept.
1856 TODO: floating point, inlining support, remove cases where argument type
1860 mep_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
1862 CGEN_FIELDS
* fields
,
1867 case MEP_OPERAND_ADDR24A4
:
1868 fields
->f_24u8a4n
= value
;
1870 case MEP_OPERAND_CALLNUM
:
1871 fields
->f_callnum
= value
;
1873 case MEP_OPERAND_CCCC
:
1874 fields
->f_rm
= value
;
1876 case MEP_OPERAND_CCRN
:
1877 fields
->f_ccrn
= value
;
1879 case MEP_OPERAND_CDISP8
:
1880 fields
->f_8s24
= value
;
1882 case MEP_OPERAND_CDISP8A2
:
1883 fields
->f_8s24a2
= value
;
1885 case MEP_OPERAND_CDISP8A4
:
1886 fields
->f_8s24a4
= value
;
1888 case MEP_OPERAND_CDISP8A8
:
1889 fields
->f_8s24a8
= value
;
1891 case MEP_OPERAND_CIMM4
:
1892 fields
->f_rn
= value
;
1894 case MEP_OPERAND_CIMM5
:
1895 fields
->f_5u24
= value
;
1897 case MEP_OPERAND_CODE16
:
1898 fields
->f_16u16
= value
;
1900 case MEP_OPERAND_CODE24
:
1901 fields
->f_24u4n
= value
;
1903 case MEP_OPERAND_CP_FLAG
:
1905 case MEP_OPERAND_CRN
:
1906 fields
->f_crn
= value
;
1908 case MEP_OPERAND_CRN64
:
1909 fields
->f_crn
= value
;
1911 case MEP_OPERAND_CRNX
:
1912 fields
->f_crnx
= value
;
1914 case MEP_OPERAND_CRNX64
:
1915 fields
->f_crnx
= value
;
1917 case MEP_OPERAND_CSRN
:
1918 fields
->f_csrn
= value
;
1920 case MEP_OPERAND_CSRN_IDX
:
1921 fields
->f_csrn
= value
;
1923 case MEP_OPERAND_DBG
:
1925 case MEP_OPERAND_DEPC
:
1927 case MEP_OPERAND_EPC
:
1929 case MEP_OPERAND_EXC
:
1931 case MEP_OPERAND_HI
:
1933 case MEP_OPERAND_LO
:
1935 case MEP_OPERAND_LP
:
1937 case MEP_OPERAND_MB0
:
1939 case MEP_OPERAND_MB1
:
1941 case MEP_OPERAND_ME0
:
1943 case MEP_OPERAND_ME1
:
1945 case MEP_OPERAND_NPC
:
1947 case MEP_OPERAND_OPT
:
1949 case MEP_OPERAND_PCABS24A2
:
1950 fields
->f_24u5a2n
= value
;
1952 case MEP_OPERAND_PCREL12A2
:
1953 fields
->f_12s4a2
= value
;
1955 case MEP_OPERAND_PCREL17A2
:
1956 fields
->f_17s16a2
= value
;
1958 case MEP_OPERAND_PCREL24A2
:
1959 fields
->f_24s5a2n
= value
;
1961 case MEP_OPERAND_PCREL8A2
:
1962 fields
->f_8s8a2
= value
;
1964 case MEP_OPERAND_PSW
:
1966 case MEP_OPERAND_R0
:
1968 case MEP_OPERAND_R1
:
1970 case MEP_OPERAND_RL
:
1971 fields
->f_rl
= value
;
1973 case MEP_OPERAND_RM
:
1974 fields
->f_rm
= value
;
1976 case MEP_OPERAND_RMA
:
1977 fields
->f_rm
= value
;
1979 case MEP_OPERAND_RN
:
1980 fields
->f_rn
= value
;
1982 case MEP_OPERAND_RN3
:
1983 fields
->f_rn3
= value
;
1985 case MEP_OPERAND_RN3C
:
1986 fields
->f_rn3
= value
;
1988 case MEP_OPERAND_RN3L
:
1989 fields
->f_rn3
= value
;
1991 case MEP_OPERAND_RN3S
:
1992 fields
->f_rn3
= value
;
1994 case MEP_OPERAND_RN3UC
:
1995 fields
->f_rn3
= value
;
1997 case MEP_OPERAND_RN3UL
:
1998 fields
->f_rn3
= value
;
2000 case MEP_OPERAND_RN3US
:
2001 fields
->f_rn3
= value
;
2003 case MEP_OPERAND_RNC
:
2004 fields
->f_rn
= value
;
2006 case MEP_OPERAND_RNL
:
2007 fields
->f_rn
= value
;
2009 case MEP_OPERAND_RNS
:
2010 fields
->f_rn
= value
;
2012 case MEP_OPERAND_RNUC
:
2013 fields
->f_rn
= value
;
2015 case MEP_OPERAND_RNUL
:
2016 fields
->f_rn
= value
;
2018 case MEP_OPERAND_RNUS
:
2019 fields
->f_rn
= value
;
2021 case MEP_OPERAND_SAR
:
2023 case MEP_OPERAND_SDISP16
:
2024 fields
->f_16s16
= value
;
2026 case MEP_OPERAND_SIMM16
:
2027 fields
->f_16s16
= value
;
2029 case MEP_OPERAND_SIMM6
:
2030 fields
->f_6s8
= value
;
2032 case MEP_OPERAND_SIMM8
:
2033 fields
->f_8s8
= value
;
2035 case MEP_OPERAND_SP
:
2037 case MEP_OPERAND_SPR
:
2039 case MEP_OPERAND_TP
:
2041 case MEP_OPERAND_TPR
:
2043 case MEP_OPERAND_UDISP2
:
2044 fields
->f_2u6
= value
;
2046 case MEP_OPERAND_UDISP7
:
2047 fields
->f_7u9
= value
;
2049 case MEP_OPERAND_UDISP7A2
:
2050 fields
->f_7u9a2
= value
;
2052 case MEP_OPERAND_UDISP7A4
:
2053 fields
->f_7u9a4
= value
;
2055 case MEP_OPERAND_UIMM16
:
2056 fields
->f_16u16
= value
;
2058 case MEP_OPERAND_UIMM2
:
2059 fields
->f_2u10
= value
;
2061 case MEP_OPERAND_UIMM24
:
2062 fields
->f_24u8n
= value
;
2064 case MEP_OPERAND_UIMM3
:
2065 fields
->f_3u5
= value
;
2067 case MEP_OPERAND_UIMM4
:
2068 fields
->f_4u8
= value
;
2070 case MEP_OPERAND_UIMM5
:
2071 fields
->f_5u8
= value
;
2073 case MEP_OPERAND_UIMM7A4
:
2074 fields
->f_7u9a4
= value
;
2076 case MEP_OPERAND_ZERO
:
2080 /* xgettext:c-format */
2081 fprintf (stderr
, _("Unrecognized field %d while setting int operand.\n"),
2088 mep_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
2090 CGEN_FIELDS
* fields
,
2095 case MEP_OPERAND_ADDR24A4
:
2096 fields
->f_24u8a4n
= value
;
2098 case MEP_OPERAND_CALLNUM
:
2099 fields
->f_callnum
= value
;
2101 case MEP_OPERAND_CCCC
:
2102 fields
->f_rm
= value
;
2104 case MEP_OPERAND_CCRN
:
2105 fields
->f_ccrn
= value
;
2107 case MEP_OPERAND_CDISP8
:
2108 fields
->f_8s24
= value
;
2110 case MEP_OPERAND_CDISP8A2
:
2111 fields
->f_8s24a2
= value
;
2113 case MEP_OPERAND_CDISP8A4
:
2114 fields
->f_8s24a4
= value
;
2116 case MEP_OPERAND_CDISP8A8
:
2117 fields
->f_8s24a8
= value
;
2119 case MEP_OPERAND_CIMM4
:
2120 fields
->f_rn
= value
;
2122 case MEP_OPERAND_CIMM5
:
2123 fields
->f_5u24
= value
;
2125 case MEP_OPERAND_CODE16
:
2126 fields
->f_16u16
= value
;
2128 case MEP_OPERAND_CODE24
:
2129 fields
->f_24u4n
= value
;
2131 case MEP_OPERAND_CP_FLAG
:
2133 case MEP_OPERAND_CRN
:
2134 fields
->f_crn
= value
;
2136 case MEP_OPERAND_CRN64
:
2137 fields
->f_crn
= value
;
2139 case MEP_OPERAND_CRNX
:
2140 fields
->f_crnx
= value
;
2142 case MEP_OPERAND_CRNX64
:
2143 fields
->f_crnx
= value
;
2145 case MEP_OPERAND_CSRN
:
2146 fields
->f_csrn
= value
;
2148 case MEP_OPERAND_CSRN_IDX
:
2149 fields
->f_csrn
= value
;
2151 case MEP_OPERAND_DBG
:
2153 case MEP_OPERAND_DEPC
:
2155 case MEP_OPERAND_EPC
:
2157 case MEP_OPERAND_EXC
:
2159 case MEP_OPERAND_HI
:
2161 case MEP_OPERAND_LO
:
2163 case MEP_OPERAND_LP
:
2165 case MEP_OPERAND_MB0
:
2167 case MEP_OPERAND_MB1
:
2169 case MEP_OPERAND_ME0
:
2171 case MEP_OPERAND_ME1
:
2173 case MEP_OPERAND_NPC
:
2175 case MEP_OPERAND_OPT
:
2177 case MEP_OPERAND_PCABS24A2
:
2178 fields
->f_24u5a2n
= value
;
2180 case MEP_OPERAND_PCREL12A2
:
2181 fields
->f_12s4a2
= value
;
2183 case MEP_OPERAND_PCREL17A2
:
2184 fields
->f_17s16a2
= value
;
2186 case MEP_OPERAND_PCREL24A2
:
2187 fields
->f_24s5a2n
= value
;
2189 case MEP_OPERAND_PCREL8A2
:
2190 fields
->f_8s8a2
= value
;
2192 case MEP_OPERAND_PSW
:
2194 case MEP_OPERAND_R0
:
2196 case MEP_OPERAND_R1
:
2198 case MEP_OPERAND_RL
:
2199 fields
->f_rl
= value
;
2201 case MEP_OPERAND_RM
:
2202 fields
->f_rm
= value
;
2204 case MEP_OPERAND_RMA
:
2205 fields
->f_rm
= value
;
2207 case MEP_OPERAND_RN
:
2208 fields
->f_rn
= value
;
2210 case MEP_OPERAND_RN3
:
2211 fields
->f_rn3
= value
;
2213 case MEP_OPERAND_RN3C
:
2214 fields
->f_rn3
= value
;
2216 case MEP_OPERAND_RN3L
:
2217 fields
->f_rn3
= value
;
2219 case MEP_OPERAND_RN3S
:
2220 fields
->f_rn3
= value
;
2222 case MEP_OPERAND_RN3UC
:
2223 fields
->f_rn3
= value
;
2225 case MEP_OPERAND_RN3UL
:
2226 fields
->f_rn3
= value
;
2228 case MEP_OPERAND_RN3US
:
2229 fields
->f_rn3
= value
;
2231 case MEP_OPERAND_RNC
:
2232 fields
->f_rn
= value
;
2234 case MEP_OPERAND_RNL
:
2235 fields
->f_rn
= value
;
2237 case MEP_OPERAND_RNS
:
2238 fields
->f_rn
= value
;
2240 case MEP_OPERAND_RNUC
:
2241 fields
->f_rn
= value
;
2243 case MEP_OPERAND_RNUL
:
2244 fields
->f_rn
= value
;
2246 case MEP_OPERAND_RNUS
:
2247 fields
->f_rn
= value
;
2249 case MEP_OPERAND_SAR
:
2251 case MEP_OPERAND_SDISP16
:
2252 fields
->f_16s16
= value
;
2254 case MEP_OPERAND_SIMM16
:
2255 fields
->f_16s16
= value
;
2257 case MEP_OPERAND_SIMM6
:
2258 fields
->f_6s8
= value
;
2260 case MEP_OPERAND_SIMM8
:
2261 fields
->f_8s8
= value
;
2263 case MEP_OPERAND_SP
:
2265 case MEP_OPERAND_SPR
:
2267 case MEP_OPERAND_TP
:
2269 case MEP_OPERAND_TPR
:
2271 case MEP_OPERAND_UDISP2
:
2272 fields
->f_2u6
= value
;
2274 case MEP_OPERAND_UDISP7
:
2275 fields
->f_7u9
= value
;
2277 case MEP_OPERAND_UDISP7A2
:
2278 fields
->f_7u9a2
= value
;
2280 case MEP_OPERAND_UDISP7A4
:
2281 fields
->f_7u9a4
= value
;
2283 case MEP_OPERAND_UIMM16
:
2284 fields
->f_16u16
= value
;
2286 case MEP_OPERAND_UIMM2
:
2287 fields
->f_2u10
= value
;
2289 case MEP_OPERAND_UIMM24
:
2290 fields
->f_24u8n
= value
;
2292 case MEP_OPERAND_UIMM3
:
2293 fields
->f_3u5
= value
;
2295 case MEP_OPERAND_UIMM4
:
2296 fields
->f_4u8
= value
;
2298 case MEP_OPERAND_UIMM5
:
2299 fields
->f_5u8
= value
;
2301 case MEP_OPERAND_UIMM7A4
:
2302 fields
->f_7u9a4
= value
;
2304 case MEP_OPERAND_ZERO
:
2308 /* xgettext:c-format */
2309 fprintf (stderr
, _("Unrecognized field %d while setting vma operand.\n"),
2315 /* Function to call before using the instruction builder tables. */
2318 mep_cgen_init_ibld_table (CGEN_CPU_DESC cd
)
2320 cd
->insert_handlers
= & mep_cgen_insert_handlers
[0];
2321 cd
->extract_handlers
= & mep_cgen_extract_handlers
[0];
2323 cd
->insert_operand
= mep_cgen_insert_operand
;
2324 cd
->extract_operand
= mep_cgen_extract_operand
;
2326 cd
->get_int_operand
= mep_cgen_get_int_operand
;
2327 cd
->set_int_operand
= mep_cgen_set_int_operand
;
2328 cd
->get_vma_operand
= mep_cgen_get_vma_operand
;
2329 cd
->set_vma_operand
= mep_cgen_set_vma_operand
;