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 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_FMAX_CCRN
:
741 errmsg
= insert_normal (cd
, fields
->f_fmax_4_4
, 0, 0, 4, 4, 32, total_length
, buffer
);
743 case MEP_OPERAND_FMAX_FRD
:
746 FLD (f_fmax_4_4
) = ((FLD (f_fmax_frd
)) & (15));
747 FLD (f_fmax_28_1
) = ((unsigned int) (FLD (f_fmax_frd
)) >> (4));
749 errmsg
= insert_normal (cd
, fields
->f_fmax_28_1
, 0, 0, 28, 1, 32, total_length
, buffer
);
752 errmsg
= insert_normal (cd
, fields
->f_fmax_4_4
, 0, 0, 4, 4, 32, total_length
, buffer
);
757 case MEP_OPERAND_FMAX_FRD_INT
:
760 FLD (f_fmax_4_4
) = ((FLD (f_fmax_frd
)) & (15));
761 FLD (f_fmax_28_1
) = ((unsigned int) (FLD (f_fmax_frd
)) >> (4));
763 errmsg
= insert_normal (cd
, fields
->f_fmax_28_1
, 0, 0, 28, 1, 32, total_length
, buffer
);
766 errmsg
= insert_normal (cd
, fields
->f_fmax_4_4
, 0, 0, 4, 4, 32, total_length
, buffer
);
771 case MEP_OPERAND_FMAX_FRM
:
774 FLD (f_fmax_24_4
) = ((FLD (f_fmax_frm
)) & (15));
775 FLD (f_fmax_30_1
) = ((unsigned int) (FLD (f_fmax_frm
)) >> (4));
777 errmsg
= insert_normal (cd
, fields
->f_fmax_30_1
, 0, 0, 30, 1, 32, total_length
, buffer
);
780 errmsg
= insert_normal (cd
, fields
->f_fmax_24_4
, 0, 0, 24, 4, 32, total_length
, buffer
);
785 case MEP_OPERAND_FMAX_FRN
:
788 FLD (f_fmax_20_4
) = ((FLD (f_fmax_frn
)) & (15));
789 FLD (f_fmax_29_1
) = ((unsigned int) (FLD (f_fmax_frn
)) >> (4));
791 errmsg
= insert_normal (cd
, fields
->f_fmax_29_1
, 0, 0, 29, 1, 32, total_length
, buffer
);
794 errmsg
= insert_normal (cd
, fields
->f_fmax_20_4
, 0, 0, 20, 4, 32, total_length
, buffer
);
799 case MEP_OPERAND_FMAX_FRN_INT
:
802 FLD (f_fmax_20_4
) = ((FLD (f_fmax_frn
)) & (15));
803 FLD (f_fmax_29_1
) = ((unsigned int) (FLD (f_fmax_frn
)) >> (4));
805 errmsg
= insert_normal (cd
, fields
->f_fmax_29_1
, 0, 0, 29, 1, 32, total_length
, buffer
);
808 errmsg
= insert_normal (cd
, fields
->f_fmax_20_4
, 0, 0, 20, 4, 32, total_length
, buffer
);
813 case MEP_OPERAND_FMAX_RM
:
814 errmsg
= insert_normal (cd
, fields
->f_fmax_rm
, 0, 0, 8, 4, 32, total_length
, buffer
);
816 case MEP_OPERAND_HI
:
818 case MEP_OPERAND_LO
:
820 case MEP_OPERAND_LP
:
822 case MEP_OPERAND_MB0
:
824 case MEP_OPERAND_MB1
:
826 case MEP_OPERAND_ME0
:
828 case MEP_OPERAND_ME1
:
830 case MEP_OPERAND_NPC
:
832 case MEP_OPERAND_OPT
:
834 case MEP_OPERAND_PCABS24A2
:
837 FLD (f_24u5a2n_lo
) = ((unsigned int) (((FLD (f_24u5a2n
)) & (255))) >> (1));
838 FLD (f_24u5a2n_hi
) = ((unsigned int) (FLD (f_24u5a2n
)) >> (8));
840 errmsg
= insert_normal (cd
, fields
->f_24u5a2n_hi
, 0, 0, 16, 16, 32, total_length
, buffer
);
843 errmsg
= insert_normal (cd
, fields
->f_24u5a2n_lo
, 0, 0, 5, 7, 32, total_length
, buffer
);
848 case MEP_OPERAND_PCREL12A2
:
850 long value
= fields
->f_12s4a2
;
851 value
= ((int) (((value
) - (pc
))) >> (1));
852 errmsg
= insert_normal (cd
, value
, 0|(1<<CGEN_IFLD_SIGNED
)|(1<<CGEN_IFLD_PCREL_ADDR
), 0, 4, 11, 32, total_length
, buffer
);
855 case MEP_OPERAND_PCREL17A2
:
857 long value
= fields
->f_17s16a2
;
858 value
= ((int) (((value
) - (pc
))) >> (1));
859 errmsg
= insert_normal (cd
, value
, 0|(1<<CGEN_IFLD_SIGNED
)|(1<<CGEN_IFLD_PCREL_ADDR
), 0, 16, 16, 32, total_length
, buffer
);
862 case MEP_OPERAND_PCREL24A2
:
865 FLD (f_24s5a2n
) = ((FLD (f_24s5a2n
)) - (pc
));
866 FLD (f_24s5a2n_lo
) = ((unsigned int) (((FLD (f_24s5a2n
)) & (254))) >> (1));
867 FLD (f_24s5a2n_hi
) = ((int) (FLD (f_24s5a2n
)) >> (8));
869 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
);
872 errmsg
= insert_normal (cd
, fields
->f_24s5a2n_lo
, 0|(1<<CGEN_IFLD_PCREL_ADDR
), 0, 5, 7, 32, total_length
, buffer
);
877 case MEP_OPERAND_PCREL8A2
:
879 long value
= fields
->f_8s8a2
;
880 value
= ((int) (((value
) - (pc
))) >> (1));
881 errmsg
= insert_normal (cd
, value
, 0|(1<<CGEN_IFLD_SIGNED
)|(1<<CGEN_IFLD_PCREL_ADDR
), 0, 8, 7, 32, total_length
, buffer
);
884 case MEP_OPERAND_PSW
:
886 case MEP_OPERAND_R0
:
888 case MEP_OPERAND_R1
:
890 case MEP_OPERAND_RL
:
891 errmsg
= insert_normal (cd
, fields
->f_rl
, 0, 0, 12, 4, 32, total_length
, buffer
);
893 case MEP_OPERAND_RM
:
894 errmsg
= insert_normal (cd
, fields
->f_rm
, 0, 0, 8, 4, 32, total_length
, buffer
);
896 case MEP_OPERAND_RMA
:
897 errmsg
= insert_normal (cd
, fields
->f_rm
, 0, 0, 8, 4, 32, total_length
, buffer
);
899 case MEP_OPERAND_RN
:
900 errmsg
= insert_normal (cd
, fields
->f_rn
, 0, 0, 4, 4, 32, total_length
, buffer
);
902 case MEP_OPERAND_RN3
:
903 errmsg
= insert_normal (cd
, fields
->f_rn3
, 0, 0, 5, 3, 32, total_length
, buffer
);
905 case MEP_OPERAND_RN3C
:
906 errmsg
= insert_normal (cd
, fields
->f_rn3
, 0, 0, 5, 3, 32, total_length
, buffer
);
908 case MEP_OPERAND_RN3L
:
909 errmsg
= insert_normal (cd
, fields
->f_rn3
, 0, 0, 5, 3, 32, total_length
, buffer
);
911 case MEP_OPERAND_RN3S
:
912 errmsg
= insert_normal (cd
, fields
->f_rn3
, 0, 0, 5, 3, 32, total_length
, buffer
);
914 case MEP_OPERAND_RN3UC
:
915 errmsg
= insert_normal (cd
, fields
->f_rn3
, 0, 0, 5, 3, 32, total_length
, buffer
);
917 case MEP_OPERAND_RN3UL
:
918 errmsg
= insert_normal (cd
, fields
->f_rn3
, 0, 0, 5, 3, 32, total_length
, buffer
);
920 case MEP_OPERAND_RN3US
:
921 errmsg
= insert_normal (cd
, fields
->f_rn3
, 0, 0, 5, 3, 32, total_length
, buffer
);
923 case MEP_OPERAND_RNC
:
924 errmsg
= insert_normal (cd
, fields
->f_rn
, 0, 0, 4, 4, 32, total_length
, buffer
);
926 case MEP_OPERAND_RNL
:
927 errmsg
= insert_normal (cd
, fields
->f_rn
, 0, 0, 4, 4, 32, total_length
, buffer
);
929 case MEP_OPERAND_RNS
:
930 errmsg
= insert_normal (cd
, fields
->f_rn
, 0, 0, 4, 4, 32, total_length
, buffer
);
932 case MEP_OPERAND_RNUC
:
933 errmsg
= insert_normal (cd
, fields
->f_rn
, 0, 0, 4, 4, 32, total_length
, buffer
);
935 case MEP_OPERAND_RNUL
:
936 errmsg
= insert_normal (cd
, fields
->f_rn
, 0, 0, 4, 4, 32, total_length
, buffer
);
938 case MEP_OPERAND_RNUS
:
939 errmsg
= insert_normal (cd
, fields
->f_rn
, 0, 0, 4, 4, 32, total_length
, buffer
);
941 case MEP_OPERAND_SAR
:
943 case MEP_OPERAND_SDISP16
:
944 errmsg
= insert_normal (cd
, fields
->f_16s16
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 16, 16, 32, total_length
, buffer
);
946 case MEP_OPERAND_SIMM16
:
947 errmsg
= insert_normal (cd
, fields
->f_16s16
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 16, 16, 32, total_length
, buffer
);
949 case MEP_OPERAND_SIMM6
:
950 errmsg
= insert_normal (cd
, fields
->f_6s8
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 8, 6, 32, total_length
, buffer
);
952 case MEP_OPERAND_SIMM8
:
953 errmsg
= insert_normal (cd
, fields
->f_8s8
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 8, 8, 32, total_length
, buffer
);
955 case MEP_OPERAND_SP
:
957 case MEP_OPERAND_SPR
:
959 case MEP_OPERAND_TP
:
961 case MEP_OPERAND_TPR
:
963 case MEP_OPERAND_UDISP2
:
964 errmsg
= insert_normal (cd
, fields
->f_2u6
, 0, 0, 6, 2, 32, total_length
, buffer
);
966 case MEP_OPERAND_UDISP7
:
967 errmsg
= insert_normal (cd
, fields
->f_7u9
, 0, 0, 9, 7, 32, total_length
, buffer
);
969 case MEP_OPERAND_UDISP7A2
:
971 long value
= fields
->f_7u9a2
;
972 value
= ((unsigned int) (value
) >> (1));
973 errmsg
= insert_normal (cd
, value
, 0, 0, 9, 6, 32, total_length
, buffer
);
976 case MEP_OPERAND_UDISP7A4
:
978 long value
= fields
->f_7u9a4
;
979 value
= ((unsigned int) (value
) >> (2));
980 errmsg
= insert_normal (cd
, value
, 0, 0, 9, 5, 32, total_length
, buffer
);
983 case MEP_OPERAND_UIMM16
:
984 errmsg
= insert_normal (cd
, fields
->f_16u16
, 0, 0, 16, 16, 32, total_length
, buffer
);
986 case MEP_OPERAND_UIMM2
:
987 errmsg
= insert_normal (cd
, fields
->f_2u10
, 0, 0, 10, 2, 32, total_length
, buffer
);
989 case MEP_OPERAND_UIMM24
:
992 FLD (f_24u8n_hi
) = ((unsigned int) (FLD (f_24u8n
)) >> (8));
993 FLD (f_24u8n_lo
) = ((FLD (f_24u8n
)) & (255));
995 errmsg
= insert_normal (cd
, fields
->f_24u8n_hi
, 0, 0, 16, 16, 32, total_length
, buffer
);
998 errmsg
= insert_normal (cd
, fields
->f_24u8n_lo
, 0, 0, 8, 8, 32, total_length
, buffer
);
1003 case MEP_OPERAND_UIMM3
:
1004 errmsg
= insert_normal (cd
, fields
->f_3u5
, 0, 0, 5, 3, 32, total_length
, buffer
);
1006 case MEP_OPERAND_UIMM4
:
1007 errmsg
= insert_normal (cd
, fields
->f_4u8
, 0, 0, 8, 4, 32, total_length
, buffer
);
1009 case MEP_OPERAND_UIMM5
:
1010 errmsg
= insert_normal (cd
, fields
->f_5u8
, 0, 0, 8, 5, 32, total_length
, buffer
);
1012 case MEP_OPERAND_UIMM7A4
:
1014 long value
= fields
->f_7u9a4
;
1015 value
= ((unsigned int) (value
) >> (2));
1016 errmsg
= insert_normal (cd
, value
, 0, 0, 9, 5, 32, total_length
, buffer
);
1019 case MEP_OPERAND_ZERO
:
1023 /* xgettext:c-format */
1024 fprintf (stderr
, _("Unrecognized field %d while building insn.\n"),
1032 int mep_cgen_extract_operand
1033 (CGEN_CPU_DESC
, int, CGEN_EXTRACT_INFO
*, CGEN_INSN_INT
, CGEN_FIELDS
*, bfd_vma
);
1035 /* Main entry point for operand extraction.
1036 The result is <= 0 for error, >0 for success.
1037 ??? Actual values aren't well defined right now.
1039 This function is basically just a big switch statement. Earlier versions
1040 used tables to look up the function to use, but
1041 - if the table contains both assembler and disassembler functions then
1042 the disassembler contains much of the assembler and vice-versa,
1043 - there's a lot of inlining possibilities as things grow,
1044 - using a switch statement avoids the function call overhead.
1046 This function could be moved into `print_insn_normal', but keeping it
1047 separate makes clear the interface between `print_insn_normal' and each of
1051 mep_cgen_extract_operand (CGEN_CPU_DESC cd
,
1053 CGEN_EXTRACT_INFO
*ex_info
,
1054 CGEN_INSN_INT insn_value
,
1055 CGEN_FIELDS
* fields
,
1058 /* Assume success (for those operands that are nops). */
1060 unsigned int total_length
= CGEN_FIELDS_BITSIZE (fields
);
1064 case MEP_OPERAND_ADDR24A4
:
1066 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 16, 16, 32, total_length
, pc
, & fields
->f_24u8a4n_hi
);
1067 if (length
<= 0) break;
1068 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 8, 6, 32, total_length
, pc
, & fields
->f_24u8a4n_lo
);
1069 if (length
<= 0) break;
1070 FLD (f_24u8a4n
) = ((((FLD (f_24u8a4n_hi
)) << (8))) | (((FLD (f_24u8a4n_lo
)) << (2))));
1073 case MEP_OPERAND_CALLNUM
:
1075 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 5, 1, 32, total_length
, pc
, & fields
->f_5
);
1076 if (length
<= 0) break;
1077 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 6, 1, 32, total_length
, pc
, & fields
->f_6
);
1078 if (length
<= 0) break;
1079 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 7, 1, 32, total_length
, pc
, & fields
->f_7
);
1080 if (length
<= 0) break;
1081 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 11, 1, 32, total_length
, pc
, & fields
->f_11
);
1082 if (length
<= 0) break;
1083 FLD (f_callnum
) = ((((FLD (f_5
)) << (3))) | (((((FLD (f_6
)) << (2))) | (((((FLD (f_7
)) << (1))) | (FLD (f_11
)))))));
1086 case MEP_OPERAND_CCCC
:
1087 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 8, 4, 32, total_length
, pc
, & fields
->f_rm
);
1089 case MEP_OPERAND_CCRN
:
1091 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 28, 2, 32, total_length
, pc
, & fields
->f_ccrn_hi
);
1092 if (length
<= 0) break;
1093 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_ccrn_lo
);
1094 if (length
<= 0) break;
1095 FLD (f_ccrn
) = ((((FLD (f_ccrn_hi
)) << (4))) | (FLD (f_ccrn_lo
)));
1098 case MEP_OPERAND_CDISP8
:
1099 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 24, 8, 32, total_length
, pc
, & fields
->f_8s24
);
1101 case MEP_OPERAND_CDISP8A2
:
1104 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 24, 7, 32, total_length
, pc
, & value
);
1105 value
= ((value
) << (1));
1106 fields
->f_8s24a2
= value
;
1109 case MEP_OPERAND_CDISP8A4
:
1112 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 24, 6, 32, total_length
, pc
, & value
);
1113 value
= ((value
) << (2));
1114 fields
->f_8s24a4
= value
;
1117 case MEP_OPERAND_CDISP8A8
:
1120 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 24, 5, 32, total_length
, pc
, & value
);
1121 value
= ((value
) << (3));
1122 fields
->f_8s24a8
= value
;
1125 case MEP_OPERAND_CIMM4
:
1126 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_rn
);
1128 case MEP_OPERAND_CIMM5
:
1129 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 24, 5, 32, total_length
, pc
, & fields
->f_5u24
);
1131 case MEP_OPERAND_CODE16
:
1132 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 16, 16, 32, total_length
, pc
, & fields
->f_16u16
);
1134 case MEP_OPERAND_CODE24
:
1136 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 8, 32, total_length
, pc
, & fields
->f_24u4n_hi
);
1137 if (length
<= 0) break;
1138 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 16, 16, 32, total_length
, pc
, & fields
->f_24u4n_lo
);
1139 if (length
<= 0) break;
1140 FLD (f_24u4n
) = ((((FLD (f_24u4n_hi
)) << (16))) | (FLD (f_24u4n_lo
)));
1143 case MEP_OPERAND_CP_FLAG
:
1145 case MEP_OPERAND_CRN
:
1146 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_crn
);
1148 case MEP_OPERAND_CRN64
:
1149 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_crn
);
1151 case MEP_OPERAND_CRNX
:
1153 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 28, 1, 32, total_length
, pc
, & fields
->f_crnx_hi
);
1154 if (length
<= 0) break;
1155 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_crnx_lo
);
1156 if (length
<= 0) break;
1157 FLD (f_crnx
) = ((((FLD (f_crnx_hi
)) << (4))) | (FLD (f_crnx_lo
)));
1160 case MEP_OPERAND_CRNX64
:
1162 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 28, 1, 32, total_length
, pc
, & fields
->f_crnx_hi
);
1163 if (length
<= 0) break;
1164 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_crnx_lo
);
1165 if (length
<= 0) break;
1166 FLD (f_crnx
) = ((((FLD (f_crnx_hi
)) << (4))) | (FLD (f_crnx_lo
)));
1169 case MEP_OPERAND_CSRN
:
1171 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 1, 32, total_length
, pc
, & fields
->f_csrn_hi
);
1172 if (length
<= 0) break;
1173 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 8, 4, 32, total_length
, pc
, & fields
->f_csrn_lo
);
1174 if (length
<= 0) break;
1175 FLD (f_csrn
) = ((((FLD (f_csrn_hi
)) << (4))) | (FLD (f_csrn_lo
)));
1178 case MEP_OPERAND_CSRN_IDX
:
1180 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 1, 32, total_length
, pc
, & fields
->f_csrn_hi
);
1181 if (length
<= 0) break;
1182 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 8, 4, 32, total_length
, pc
, & fields
->f_csrn_lo
);
1183 if (length
<= 0) break;
1184 FLD (f_csrn
) = ((((FLD (f_csrn_hi
)) << (4))) | (FLD (f_csrn_lo
)));
1187 case MEP_OPERAND_DBG
:
1189 case MEP_OPERAND_DEPC
:
1191 case MEP_OPERAND_EPC
:
1193 case MEP_OPERAND_EXC
:
1195 case MEP_OPERAND_FMAX_CCRN
:
1196 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_fmax_4_4
);
1198 case MEP_OPERAND_FMAX_FRD
:
1200 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 28, 1, 32, total_length
, pc
, & fields
->f_fmax_28_1
);
1201 if (length
<= 0) break;
1202 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_fmax_4_4
);
1203 if (length
<= 0) break;
1204 FLD (f_fmax_frd
) = ((((FLD (f_fmax_28_1
)) << (4))) | (FLD (f_fmax_4_4
)));
1207 case MEP_OPERAND_FMAX_FRD_INT
:
1209 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 28, 1, 32, total_length
, pc
, & fields
->f_fmax_28_1
);
1210 if (length
<= 0) break;
1211 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_fmax_4_4
);
1212 if (length
<= 0) break;
1213 FLD (f_fmax_frd
) = ((((FLD (f_fmax_28_1
)) << (4))) | (FLD (f_fmax_4_4
)));
1216 case MEP_OPERAND_FMAX_FRM
:
1218 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 30, 1, 32, total_length
, pc
, & fields
->f_fmax_30_1
);
1219 if (length
<= 0) break;
1220 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 24, 4, 32, total_length
, pc
, & fields
->f_fmax_24_4
);
1221 if (length
<= 0) break;
1222 FLD (f_fmax_frm
) = ((((FLD (f_fmax_30_1
)) << (4))) | (FLD (f_fmax_24_4
)));
1225 case MEP_OPERAND_FMAX_FRN
:
1227 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 29, 1, 32, total_length
, pc
, & fields
->f_fmax_29_1
);
1228 if (length
<= 0) break;
1229 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 20, 4, 32, total_length
, pc
, & fields
->f_fmax_20_4
);
1230 if (length
<= 0) break;
1231 FLD (f_fmax_frn
) = ((((FLD (f_fmax_29_1
)) << (4))) | (FLD (f_fmax_20_4
)));
1234 case MEP_OPERAND_FMAX_FRN_INT
:
1236 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 29, 1, 32, total_length
, pc
, & fields
->f_fmax_29_1
);
1237 if (length
<= 0) break;
1238 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 20, 4, 32, total_length
, pc
, & fields
->f_fmax_20_4
);
1239 if (length
<= 0) break;
1240 FLD (f_fmax_frn
) = ((((FLD (f_fmax_29_1
)) << (4))) | (FLD (f_fmax_20_4
)));
1243 case MEP_OPERAND_FMAX_RM
:
1244 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 8, 4, 32, total_length
, pc
, & fields
->f_fmax_rm
);
1246 case MEP_OPERAND_HI
:
1248 case MEP_OPERAND_LO
:
1250 case MEP_OPERAND_LP
:
1252 case MEP_OPERAND_MB0
:
1254 case MEP_OPERAND_MB1
:
1256 case MEP_OPERAND_ME0
:
1258 case MEP_OPERAND_ME1
:
1260 case MEP_OPERAND_NPC
:
1262 case MEP_OPERAND_OPT
:
1264 case MEP_OPERAND_PCABS24A2
:
1266 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 16, 16, 32, total_length
, pc
, & fields
->f_24u5a2n_hi
);
1267 if (length
<= 0) break;
1268 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 5, 7, 32, total_length
, pc
, & fields
->f_24u5a2n_lo
);
1269 if (length
<= 0) break;
1270 FLD (f_24u5a2n
) = ((((FLD (f_24u5a2n_hi
)) << (8))) | (((FLD (f_24u5a2n_lo
)) << (1))));
1273 case MEP_OPERAND_PCREL12A2
:
1276 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
);
1277 value
= ((((value
) << (1))) + (pc
));
1278 fields
->f_12s4a2
= value
;
1281 case MEP_OPERAND_PCREL17A2
:
1284 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
);
1285 value
= ((((value
) << (1))) + (pc
));
1286 fields
->f_17s16a2
= value
;
1289 case MEP_OPERAND_PCREL24A2
:
1291 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
);
1292 if (length
<= 0) break;
1293 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
);
1294 if (length
<= 0) break;
1295 FLD (f_24s5a2n
) = ((((((FLD (f_24s5a2n_hi
)) << (8))) | (((FLD (f_24s5a2n_lo
)) << (1))))) + (pc
));
1298 case MEP_OPERAND_PCREL8A2
:
1301 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
);
1302 value
= ((((value
) << (1))) + (pc
));
1303 fields
->f_8s8a2
= value
;
1306 case MEP_OPERAND_PSW
:
1308 case MEP_OPERAND_R0
:
1310 case MEP_OPERAND_R1
:
1312 case MEP_OPERAND_RL
:
1313 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 12, 4, 32, total_length
, pc
, & fields
->f_rl
);
1315 case MEP_OPERAND_RM
:
1316 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 8, 4, 32, total_length
, pc
, & fields
->f_rm
);
1318 case MEP_OPERAND_RMA
:
1319 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 8, 4, 32, total_length
, pc
, & fields
->f_rm
);
1321 case MEP_OPERAND_RN
:
1322 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_rn
);
1324 case MEP_OPERAND_RN3
:
1325 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 5, 3, 32, total_length
, pc
, & fields
->f_rn3
);
1327 case MEP_OPERAND_RN3C
:
1328 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 5, 3, 32, total_length
, pc
, & fields
->f_rn3
);
1330 case MEP_OPERAND_RN3L
:
1331 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 5, 3, 32, total_length
, pc
, & fields
->f_rn3
);
1333 case MEP_OPERAND_RN3S
:
1334 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 5, 3, 32, total_length
, pc
, & fields
->f_rn3
);
1336 case MEP_OPERAND_RN3UC
:
1337 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 5, 3, 32, total_length
, pc
, & fields
->f_rn3
);
1339 case MEP_OPERAND_RN3UL
:
1340 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 5, 3, 32, total_length
, pc
, & fields
->f_rn3
);
1342 case MEP_OPERAND_RN3US
:
1343 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 5, 3, 32, total_length
, pc
, & fields
->f_rn3
);
1345 case MEP_OPERAND_RNC
:
1346 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_rn
);
1348 case MEP_OPERAND_RNL
:
1349 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_rn
);
1351 case MEP_OPERAND_RNS
:
1352 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_rn
);
1354 case MEP_OPERAND_RNUC
:
1355 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_rn
);
1357 case MEP_OPERAND_RNUL
:
1358 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_rn
);
1360 case MEP_OPERAND_RNUS
:
1361 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 4, 32, total_length
, pc
, & fields
->f_rn
);
1363 case MEP_OPERAND_SAR
:
1365 case MEP_OPERAND_SDISP16
:
1366 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 16, 16, 32, total_length
, pc
, & fields
->f_16s16
);
1368 case MEP_OPERAND_SIMM16
:
1369 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 16, 16, 32, total_length
, pc
, & fields
->f_16s16
);
1371 case MEP_OPERAND_SIMM6
:
1372 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 8, 6, 32, total_length
, pc
, & fields
->f_6s8
);
1374 case MEP_OPERAND_SIMM8
:
1375 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 8, 8, 32, total_length
, pc
, & fields
->f_8s8
);
1377 case MEP_OPERAND_SP
:
1379 case MEP_OPERAND_SPR
:
1381 case MEP_OPERAND_TP
:
1383 case MEP_OPERAND_TPR
:
1385 case MEP_OPERAND_UDISP2
:
1386 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 6, 2, 32, total_length
, pc
, & fields
->f_2u6
);
1388 case MEP_OPERAND_UDISP7
:
1389 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 9, 7, 32, total_length
, pc
, & fields
->f_7u9
);
1391 case MEP_OPERAND_UDISP7A2
:
1394 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 9, 6, 32, total_length
, pc
, & value
);
1395 value
= ((value
) << (1));
1396 fields
->f_7u9a2
= value
;
1399 case MEP_OPERAND_UDISP7A4
:
1402 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 9, 5, 32, total_length
, pc
, & value
);
1403 value
= ((value
) << (2));
1404 fields
->f_7u9a4
= value
;
1407 case MEP_OPERAND_UIMM16
:
1408 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 16, 16, 32, total_length
, pc
, & fields
->f_16u16
);
1410 case MEP_OPERAND_UIMM2
:
1411 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 10, 2, 32, total_length
, pc
, & fields
->f_2u10
);
1413 case MEP_OPERAND_UIMM24
:
1415 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 16, 16, 32, total_length
, pc
, & fields
->f_24u8n_hi
);
1416 if (length
<= 0) break;
1417 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 8, 8, 32, total_length
, pc
, & fields
->f_24u8n_lo
);
1418 if (length
<= 0) break;
1419 FLD (f_24u8n
) = ((((FLD (f_24u8n_hi
)) << (8))) | (FLD (f_24u8n_lo
)));
1422 case MEP_OPERAND_UIMM3
:
1423 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 5, 3, 32, total_length
, pc
, & fields
->f_3u5
);
1425 case MEP_OPERAND_UIMM4
:
1426 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 8, 4, 32, total_length
, pc
, & fields
->f_4u8
);
1428 case MEP_OPERAND_UIMM5
:
1429 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 8, 5, 32, total_length
, pc
, & fields
->f_5u8
);
1431 case MEP_OPERAND_UIMM7A4
:
1434 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 9, 5, 32, total_length
, pc
, & value
);
1435 value
= ((value
) << (2));
1436 fields
->f_7u9a4
= value
;
1439 case MEP_OPERAND_ZERO
:
1443 /* xgettext:c-format */
1444 fprintf (stderr
, _("Unrecognized field %d while decoding insn.\n"),
1452 cgen_insert_fn
* const mep_cgen_insert_handlers
[] =
1457 cgen_extract_fn
* const mep_cgen_extract_handlers
[] =
1459 extract_insn_normal
,
1462 int mep_cgen_get_int_operand (CGEN_CPU_DESC
, int, const CGEN_FIELDS
*);
1463 bfd_vma
mep_cgen_get_vma_operand (CGEN_CPU_DESC
, int, const CGEN_FIELDS
*);
1465 /* Getting values from cgen_fields is handled by a collection of functions.
1466 They are distinguished by the type of the VALUE argument they return.
1467 TODO: floating point, inlining support, remove cases where result type
1471 mep_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
1473 const CGEN_FIELDS
* fields
)
1479 case MEP_OPERAND_ADDR24A4
:
1480 value
= fields
->f_24u8a4n
;
1482 case MEP_OPERAND_CALLNUM
:
1483 value
= fields
->f_callnum
;
1485 case MEP_OPERAND_CCCC
:
1486 value
= fields
->f_rm
;
1488 case MEP_OPERAND_CCRN
:
1489 value
= fields
->f_ccrn
;
1491 case MEP_OPERAND_CDISP8
:
1492 value
= fields
->f_8s24
;
1494 case MEP_OPERAND_CDISP8A2
:
1495 value
= fields
->f_8s24a2
;
1497 case MEP_OPERAND_CDISP8A4
:
1498 value
= fields
->f_8s24a4
;
1500 case MEP_OPERAND_CDISP8A8
:
1501 value
= fields
->f_8s24a8
;
1503 case MEP_OPERAND_CIMM4
:
1504 value
= fields
->f_rn
;
1506 case MEP_OPERAND_CIMM5
:
1507 value
= fields
->f_5u24
;
1509 case MEP_OPERAND_CODE16
:
1510 value
= fields
->f_16u16
;
1512 case MEP_OPERAND_CODE24
:
1513 value
= fields
->f_24u4n
;
1515 case MEP_OPERAND_CP_FLAG
:
1518 case MEP_OPERAND_CRN
:
1519 value
= fields
->f_crn
;
1521 case MEP_OPERAND_CRN64
:
1522 value
= fields
->f_crn
;
1524 case MEP_OPERAND_CRNX
:
1525 value
= fields
->f_crnx
;
1527 case MEP_OPERAND_CRNX64
:
1528 value
= fields
->f_crnx
;
1530 case MEP_OPERAND_CSRN
:
1531 value
= fields
->f_csrn
;
1533 case MEP_OPERAND_CSRN_IDX
:
1534 value
= fields
->f_csrn
;
1536 case MEP_OPERAND_DBG
:
1539 case MEP_OPERAND_DEPC
:
1542 case MEP_OPERAND_EPC
:
1545 case MEP_OPERAND_EXC
:
1548 case MEP_OPERAND_FMAX_CCRN
:
1549 value
= fields
->f_fmax_4_4
;
1551 case MEP_OPERAND_FMAX_FRD
:
1552 value
= fields
->f_fmax_frd
;
1554 case MEP_OPERAND_FMAX_FRD_INT
:
1555 value
= fields
->f_fmax_frd
;
1557 case MEP_OPERAND_FMAX_FRM
:
1558 value
= fields
->f_fmax_frm
;
1560 case MEP_OPERAND_FMAX_FRN
:
1561 value
= fields
->f_fmax_frn
;
1563 case MEP_OPERAND_FMAX_FRN_INT
:
1564 value
= fields
->f_fmax_frn
;
1566 case MEP_OPERAND_FMAX_RM
:
1567 value
= fields
->f_fmax_rm
;
1569 case MEP_OPERAND_HI
:
1572 case MEP_OPERAND_LO
:
1575 case MEP_OPERAND_LP
:
1578 case MEP_OPERAND_MB0
:
1581 case MEP_OPERAND_MB1
:
1584 case MEP_OPERAND_ME0
:
1587 case MEP_OPERAND_ME1
:
1590 case MEP_OPERAND_NPC
:
1593 case MEP_OPERAND_OPT
:
1596 case MEP_OPERAND_PCABS24A2
:
1597 value
= fields
->f_24u5a2n
;
1599 case MEP_OPERAND_PCREL12A2
:
1600 value
= fields
->f_12s4a2
;
1602 case MEP_OPERAND_PCREL17A2
:
1603 value
= fields
->f_17s16a2
;
1605 case MEP_OPERAND_PCREL24A2
:
1606 value
= fields
->f_24s5a2n
;
1608 case MEP_OPERAND_PCREL8A2
:
1609 value
= fields
->f_8s8a2
;
1611 case MEP_OPERAND_PSW
:
1614 case MEP_OPERAND_R0
:
1617 case MEP_OPERAND_R1
:
1620 case MEP_OPERAND_RL
:
1621 value
= fields
->f_rl
;
1623 case MEP_OPERAND_RM
:
1624 value
= fields
->f_rm
;
1626 case MEP_OPERAND_RMA
:
1627 value
= fields
->f_rm
;
1629 case MEP_OPERAND_RN
:
1630 value
= fields
->f_rn
;
1632 case MEP_OPERAND_RN3
:
1633 value
= fields
->f_rn3
;
1635 case MEP_OPERAND_RN3C
:
1636 value
= fields
->f_rn3
;
1638 case MEP_OPERAND_RN3L
:
1639 value
= fields
->f_rn3
;
1641 case MEP_OPERAND_RN3S
:
1642 value
= fields
->f_rn3
;
1644 case MEP_OPERAND_RN3UC
:
1645 value
= fields
->f_rn3
;
1647 case MEP_OPERAND_RN3UL
:
1648 value
= fields
->f_rn3
;
1650 case MEP_OPERAND_RN3US
:
1651 value
= fields
->f_rn3
;
1653 case MEP_OPERAND_RNC
:
1654 value
= fields
->f_rn
;
1656 case MEP_OPERAND_RNL
:
1657 value
= fields
->f_rn
;
1659 case MEP_OPERAND_RNS
:
1660 value
= fields
->f_rn
;
1662 case MEP_OPERAND_RNUC
:
1663 value
= fields
->f_rn
;
1665 case MEP_OPERAND_RNUL
:
1666 value
= fields
->f_rn
;
1668 case MEP_OPERAND_RNUS
:
1669 value
= fields
->f_rn
;
1671 case MEP_OPERAND_SAR
:
1674 case MEP_OPERAND_SDISP16
:
1675 value
= fields
->f_16s16
;
1677 case MEP_OPERAND_SIMM16
:
1678 value
= fields
->f_16s16
;
1680 case MEP_OPERAND_SIMM6
:
1681 value
= fields
->f_6s8
;
1683 case MEP_OPERAND_SIMM8
:
1684 value
= fields
->f_8s8
;
1686 case MEP_OPERAND_SP
:
1689 case MEP_OPERAND_SPR
:
1692 case MEP_OPERAND_TP
:
1695 case MEP_OPERAND_TPR
:
1698 case MEP_OPERAND_UDISP2
:
1699 value
= fields
->f_2u6
;
1701 case MEP_OPERAND_UDISP7
:
1702 value
= fields
->f_7u9
;
1704 case MEP_OPERAND_UDISP7A2
:
1705 value
= fields
->f_7u9a2
;
1707 case MEP_OPERAND_UDISP7A4
:
1708 value
= fields
->f_7u9a4
;
1710 case MEP_OPERAND_UIMM16
:
1711 value
= fields
->f_16u16
;
1713 case MEP_OPERAND_UIMM2
:
1714 value
= fields
->f_2u10
;
1716 case MEP_OPERAND_UIMM24
:
1717 value
= fields
->f_24u8n
;
1719 case MEP_OPERAND_UIMM3
:
1720 value
= fields
->f_3u5
;
1722 case MEP_OPERAND_UIMM4
:
1723 value
= fields
->f_4u8
;
1725 case MEP_OPERAND_UIMM5
:
1726 value
= fields
->f_5u8
;
1728 case MEP_OPERAND_UIMM7A4
:
1729 value
= fields
->f_7u9a4
;
1731 case MEP_OPERAND_ZERO
:
1736 /* xgettext:c-format */
1737 fprintf (stderr
, _("Unrecognized field %d while getting int operand.\n"),
1746 mep_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
1748 const CGEN_FIELDS
* fields
)
1754 case MEP_OPERAND_ADDR24A4
:
1755 value
= fields
->f_24u8a4n
;
1757 case MEP_OPERAND_CALLNUM
:
1758 value
= fields
->f_callnum
;
1760 case MEP_OPERAND_CCCC
:
1761 value
= fields
->f_rm
;
1763 case MEP_OPERAND_CCRN
:
1764 value
= fields
->f_ccrn
;
1766 case MEP_OPERAND_CDISP8
:
1767 value
= fields
->f_8s24
;
1769 case MEP_OPERAND_CDISP8A2
:
1770 value
= fields
->f_8s24a2
;
1772 case MEP_OPERAND_CDISP8A4
:
1773 value
= fields
->f_8s24a4
;
1775 case MEP_OPERAND_CDISP8A8
:
1776 value
= fields
->f_8s24a8
;
1778 case MEP_OPERAND_CIMM4
:
1779 value
= fields
->f_rn
;
1781 case MEP_OPERAND_CIMM5
:
1782 value
= fields
->f_5u24
;
1784 case MEP_OPERAND_CODE16
:
1785 value
= fields
->f_16u16
;
1787 case MEP_OPERAND_CODE24
:
1788 value
= fields
->f_24u4n
;
1790 case MEP_OPERAND_CP_FLAG
:
1793 case MEP_OPERAND_CRN
:
1794 value
= fields
->f_crn
;
1796 case MEP_OPERAND_CRN64
:
1797 value
= fields
->f_crn
;
1799 case MEP_OPERAND_CRNX
:
1800 value
= fields
->f_crnx
;
1802 case MEP_OPERAND_CRNX64
:
1803 value
= fields
->f_crnx
;
1805 case MEP_OPERAND_CSRN
:
1806 value
= fields
->f_csrn
;
1808 case MEP_OPERAND_CSRN_IDX
:
1809 value
= fields
->f_csrn
;
1811 case MEP_OPERAND_DBG
:
1814 case MEP_OPERAND_DEPC
:
1817 case MEP_OPERAND_EPC
:
1820 case MEP_OPERAND_EXC
:
1823 case MEP_OPERAND_FMAX_CCRN
:
1824 value
= fields
->f_fmax_4_4
;
1826 case MEP_OPERAND_FMAX_FRD
:
1827 value
= fields
->f_fmax_frd
;
1829 case MEP_OPERAND_FMAX_FRD_INT
:
1830 value
= fields
->f_fmax_frd
;
1832 case MEP_OPERAND_FMAX_FRM
:
1833 value
= fields
->f_fmax_frm
;
1835 case MEP_OPERAND_FMAX_FRN
:
1836 value
= fields
->f_fmax_frn
;
1838 case MEP_OPERAND_FMAX_FRN_INT
:
1839 value
= fields
->f_fmax_frn
;
1841 case MEP_OPERAND_FMAX_RM
:
1842 value
= fields
->f_fmax_rm
;
1844 case MEP_OPERAND_HI
:
1847 case MEP_OPERAND_LO
:
1850 case MEP_OPERAND_LP
:
1853 case MEP_OPERAND_MB0
:
1856 case MEP_OPERAND_MB1
:
1859 case MEP_OPERAND_ME0
:
1862 case MEP_OPERAND_ME1
:
1865 case MEP_OPERAND_NPC
:
1868 case MEP_OPERAND_OPT
:
1871 case MEP_OPERAND_PCABS24A2
:
1872 value
= fields
->f_24u5a2n
;
1874 case MEP_OPERAND_PCREL12A2
:
1875 value
= fields
->f_12s4a2
;
1877 case MEP_OPERAND_PCREL17A2
:
1878 value
= fields
->f_17s16a2
;
1880 case MEP_OPERAND_PCREL24A2
:
1881 value
= fields
->f_24s5a2n
;
1883 case MEP_OPERAND_PCREL8A2
:
1884 value
= fields
->f_8s8a2
;
1886 case MEP_OPERAND_PSW
:
1889 case MEP_OPERAND_R0
:
1892 case MEP_OPERAND_R1
:
1895 case MEP_OPERAND_RL
:
1896 value
= fields
->f_rl
;
1898 case MEP_OPERAND_RM
:
1899 value
= fields
->f_rm
;
1901 case MEP_OPERAND_RMA
:
1902 value
= fields
->f_rm
;
1904 case MEP_OPERAND_RN
:
1905 value
= fields
->f_rn
;
1907 case MEP_OPERAND_RN3
:
1908 value
= fields
->f_rn3
;
1910 case MEP_OPERAND_RN3C
:
1911 value
= fields
->f_rn3
;
1913 case MEP_OPERAND_RN3L
:
1914 value
= fields
->f_rn3
;
1916 case MEP_OPERAND_RN3S
:
1917 value
= fields
->f_rn3
;
1919 case MEP_OPERAND_RN3UC
:
1920 value
= fields
->f_rn3
;
1922 case MEP_OPERAND_RN3UL
:
1923 value
= fields
->f_rn3
;
1925 case MEP_OPERAND_RN3US
:
1926 value
= fields
->f_rn3
;
1928 case MEP_OPERAND_RNC
:
1929 value
= fields
->f_rn
;
1931 case MEP_OPERAND_RNL
:
1932 value
= fields
->f_rn
;
1934 case MEP_OPERAND_RNS
:
1935 value
= fields
->f_rn
;
1937 case MEP_OPERAND_RNUC
:
1938 value
= fields
->f_rn
;
1940 case MEP_OPERAND_RNUL
:
1941 value
= fields
->f_rn
;
1943 case MEP_OPERAND_RNUS
:
1944 value
= fields
->f_rn
;
1946 case MEP_OPERAND_SAR
:
1949 case MEP_OPERAND_SDISP16
:
1950 value
= fields
->f_16s16
;
1952 case MEP_OPERAND_SIMM16
:
1953 value
= fields
->f_16s16
;
1955 case MEP_OPERAND_SIMM6
:
1956 value
= fields
->f_6s8
;
1958 case MEP_OPERAND_SIMM8
:
1959 value
= fields
->f_8s8
;
1961 case MEP_OPERAND_SP
:
1964 case MEP_OPERAND_SPR
:
1967 case MEP_OPERAND_TP
:
1970 case MEP_OPERAND_TPR
:
1973 case MEP_OPERAND_UDISP2
:
1974 value
= fields
->f_2u6
;
1976 case MEP_OPERAND_UDISP7
:
1977 value
= fields
->f_7u9
;
1979 case MEP_OPERAND_UDISP7A2
:
1980 value
= fields
->f_7u9a2
;
1982 case MEP_OPERAND_UDISP7A4
:
1983 value
= fields
->f_7u9a4
;
1985 case MEP_OPERAND_UIMM16
:
1986 value
= fields
->f_16u16
;
1988 case MEP_OPERAND_UIMM2
:
1989 value
= fields
->f_2u10
;
1991 case MEP_OPERAND_UIMM24
:
1992 value
= fields
->f_24u8n
;
1994 case MEP_OPERAND_UIMM3
:
1995 value
= fields
->f_3u5
;
1997 case MEP_OPERAND_UIMM4
:
1998 value
= fields
->f_4u8
;
2000 case MEP_OPERAND_UIMM5
:
2001 value
= fields
->f_5u8
;
2003 case MEP_OPERAND_UIMM7A4
:
2004 value
= fields
->f_7u9a4
;
2006 case MEP_OPERAND_ZERO
:
2011 /* xgettext:c-format */
2012 fprintf (stderr
, _("Unrecognized field %d while getting vma operand.\n"),
2020 void mep_cgen_set_int_operand (CGEN_CPU_DESC
, int, CGEN_FIELDS
*, int);
2021 void mep_cgen_set_vma_operand (CGEN_CPU_DESC
, int, CGEN_FIELDS
*, bfd_vma
);
2023 /* Stuffing values in cgen_fields is handled by a collection of functions.
2024 They are distinguished by the type of the VALUE argument they accept.
2025 TODO: floating point, inlining support, remove cases where argument type
2029 mep_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
2031 CGEN_FIELDS
* fields
,
2036 case MEP_OPERAND_ADDR24A4
:
2037 fields
->f_24u8a4n
= value
;
2039 case MEP_OPERAND_CALLNUM
:
2040 fields
->f_callnum
= value
;
2042 case MEP_OPERAND_CCCC
:
2043 fields
->f_rm
= value
;
2045 case MEP_OPERAND_CCRN
:
2046 fields
->f_ccrn
= value
;
2048 case MEP_OPERAND_CDISP8
:
2049 fields
->f_8s24
= value
;
2051 case MEP_OPERAND_CDISP8A2
:
2052 fields
->f_8s24a2
= value
;
2054 case MEP_OPERAND_CDISP8A4
:
2055 fields
->f_8s24a4
= value
;
2057 case MEP_OPERAND_CDISP8A8
:
2058 fields
->f_8s24a8
= value
;
2060 case MEP_OPERAND_CIMM4
:
2061 fields
->f_rn
= value
;
2063 case MEP_OPERAND_CIMM5
:
2064 fields
->f_5u24
= value
;
2066 case MEP_OPERAND_CODE16
:
2067 fields
->f_16u16
= value
;
2069 case MEP_OPERAND_CODE24
:
2070 fields
->f_24u4n
= value
;
2072 case MEP_OPERAND_CP_FLAG
:
2074 case MEP_OPERAND_CRN
:
2075 fields
->f_crn
= value
;
2077 case MEP_OPERAND_CRN64
:
2078 fields
->f_crn
= value
;
2080 case MEP_OPERAND_CRNX
:
2081 fields
->f_crnx
= value
;
2083 case MEP_OPERAND_CRNX64
:
2084 fields
->f_crnx
= value
;
2086 case MEP_OPERAND_CSRN
:
2087 fields
->f_csrn
= value
;
2089 case MEP_OPERAND_CSRN_IDX
:
2090 fields
->f_csrn
= value
;
2092 case MEP_OPERAND_DBG
:
2094 case MEP_OPERAND_DEPC
:
2096 case MEP_OPERAND_EPC
:
2098 case MEP_OPERAND_EXC
:
2100 case MEP_OPERAND_FMAX_CCRN
:
2101 fields
->f_fmax_4_4
= value
;
2103 case MEP_OPERAND_FMAX_FRD
:
2104 fields
->f_fmax_frd
= value
;
2106 case MEP_OPERAND_FMAX_FRD_INT
:
2107 fields
->f_fmax_frd
= value
;
2109 case MEP_OPERAND_FMAX_FRM
:
2110 fields
->f_fmax_frm
= value
;
2112 case MEP_OPERAND_FMAX_FRN
:
2113 fields
->f_fmax_frn
= value
;
2115 case MEP_OPERAND_FMAX_FRN_INT
:
2116 fields
->f_fmax_frn
= value
;
2118 case MEP_OPERAND_FMAX_RM
:
2119 fields
->f_fmax_rm
= value
;
2121 case MEP_OPERAND_HI
:
2123 case MEP_OPERAND_LO
:
2125 case MEP_OPERAND_LP
:
2127 case MEP_OPERAND_MB0
:
2129 case MEP_OPERAND_MB1
:
2131 case MEP_OPERAND_ME0
:
2133 case MEP_OPERAND_ME1
:
2135 case MEP_OPERAND_NPC
:
2137 case MEP_OPERAND_OPT
:
2139 case MEP_OPERAND_PCABS24A2
:
2140 fields
->f_24u5a2n
= value
;
2142 case MEP_OPERAND_PCREL12A2
:
2143 fields
->f_12s4a2
= value
;
2145 case MEP_OPERAND_PCREL17A2
:
2146 fields
->f_17s16a2
= value
;
2148 case MEP_OPERAND_PCREL24A2
:
2149 fields
->f_24s5a2n
= value
;
2151 case MEP_OPERAND_PCREL8A2
:
2152 fields
->f_8s8a2
= value
;
2154 case MEP_OPERAND_PSW
:
2156 case MEP_OPERAND_R0
:
2158 case MEP_OPERAND_R1
:
2160 case MEP_OPERAND_RL
:
2161 fields
->f_rl
= value
;
2163 case MEP_OPERAND_RM
:
2164 fields
->f_rm
= value
;
2166 case MEP_OPERAND_RMA
:
2167 fields
->f_rm
= value
;
2169 case MEP_OPERAND_RN
:
2170 fields
->f_rn
= value
;
2172 case MEP_OPERAND_RN3
:
2173 fields
->f_rn3
= value
;
2175 case MEP_OPERAND_RN3C
:
2176 fields
->f_rn3
= value
;
2178 case MEP_OPERAND_RN3L
:
2179 fields
->f_rn3
= value
;
2181 case MEP_OPERAND_RN3S
:
2182 fields
->f_rn3
= value
;
2184 case MEP_OPERAND_RN3UC
:
2185 fields
->f_rn3
= value
;
2187 case MEP_OPERAND_RN3UL
:
2188 fields
->f_rn3
= value
;
2190 case MEP_OPERAND_RN3US
:
2191 fields
->f_rn3
= value
;
2193 case MEP_OPERAND_RNC
:
2194 fields
->f_rn
= value
;
2196 case MEP_OPERAND_RNL
:
2197 fields
->f_rn
= value
;
2199 case MEP_OPERAND_RNS
:
2200 fields
->f_rn
= value
;
2202 case MEP_OPERAND_RNUC
:
2203 fields
->f_rn
= value
;
2205 case MEP_OPERAND_RNUL
:
2206 fields
->f_rn
= value
;
2208 case MEP_OPERAND_RNUS
:
2209 fields
->f_rn
= value
;
2211 case MEP_OPERAND_SAR
:
2213 case MEP_OPERAND_SDISP16
:
2214 fields
->f_16s16
= value
;
2216 case MEP_OPERAND_SIMM16
:
2217 fields
->f_16s16
= value
;
2219 case MEP_OPERAND_SIMM6
:
2220 fields
->f_6s8
= value
;
2222 case MEP_OPERAND_SIMM8
:
2223 fields
->f_8s8
= value
;
2225 case MEP_OPERAND_SP
:
2227 case MEP_OPERAND_SPR
:
2229 case MEP_OPERAND_TP
:
2231 case MEP_OPERAND_TPR
:
2233 case MEP_OPERAND_UDISP2
:
2234 fields
->f_2u6
= value
;
2236 case MEP_OPERAND_UDISP7
:
2237 fields
->f_7u9
= value
;
2239 case MEP_OPERAND_UDISP7A2
:
2240 fields
->f_7u9a2
= value
;
2242 case MEP_OPERAND_UDISP7A4
:
2243 fields
->f_7u9a4
= value
;
2245 case MEP_OPERAND_UIMM16
:
2246 fields
->f_16u16
= value
;
2248 case MEP_OPERAND_UIMM2
:
2249 fields
->f_2u10
= value
;
2251 case MEP_OPERAND_UIMM24
:
2252 fields
->f_24u8n
= value
;
2254 case MEP_OPERAND_UIMM3
:
2255 fields
->f_3u5
= value
;
2257 case MEP_OPERAND_UIMM4
:
2258 fields
->f_4u8
= value
;
2260 case MEP_OPERAND_UIMM5
:
2261 fields
->f_5u8
= value
;
2263 case MEP_OPERAND_UIMM7A4
:
2264 fields
->f_7u9a4
= value
;
2266 case MEP_OPERAND_ZERO
:
2270 /* xgettext:c-format */
2271 fprintf (stderr
, _("Unrecognized field %d while setting int operand.\n"),
2278 mep_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
,
2280 CGEN_FIELDS
* fields
,
2285 case MEP_OPERAND_ADDR24A4
:
2286 fields
->f_24u8a4n
= value
;
2288 case MEP_OPERAND_CALLNUM
:
2289 fields
->f_callnum
= value
;
2291 case MEP_OPERAND_CCCC
:
2292 fields
->f_rm
= value
;
2294 case MEP_OPERAND_CCRN
:
2295 fields
->f_ccrn
= value
;
2297 case MEP_OPERAND_CDISP8
:
2298 fields
->f_8s24
= value
;
2300 case MEP_OPERAND_CDISP8A2
:
2301 fields
->f_8s24a2
= value
;
2303 case MEP_OPERAND_CDISP8A4
:
2304 fields
->f_8s24a4
= value
;
2306 case MEP_OPERAND_CDISP8A8
:
2307 fields
->f_8s24a8
= value
;
2309 case MEP_OPERAND_CIMM4
:
2310 fields
->f_rn
= value
;
2312 case MEP_OPERAND_CIMM5
:
2313 fields
->f_5u24
= value
;
2315 case MEP_OPERAND_CODE16
:
2316 fields
->f_16u16
= value
;
2318 case MEP_OPERAND_CODE24
:
2319 fields
->f_24u4n
= value
;
2321 case MEP_OPERAND_CP_FLAG
:
2323 case MEP_OPERAND_CRN
:
2324 fields
->f_crn
= value
;
2326 case MEP_OPERAND_CRN64
:
2327 fields
->f_crn
= value
;
2329 case MEP_OPERAND_CRNX
:
2330 fields
->f_crnx
= value
;
2332 case MEP_OPERAND_CRNX64
:
2333 fields
->f_crnx
= value
;
2335 case MEP_OPERAND_CSRN
:
2336 fields
->f_csrn
= value
;
2338 case MEP_OPERAND_CSRN_IDX
:
2339 fields
->f_csrn
= value
;
2341 case MEP_OPERAND_DBG
:
2343 case MEP_OPERAND_DEPC
:
2345 case MEP_OPERAND_EPC
:
2347 case MEP_OPERAND_EXC
:
2349 case MEP_OPERAND_FMAX_CCRN
:
2350 fields
->f_fmax_4_4
= value
;
2352 case MEP_OPERAND_FMAX_FRD
:
2353 fields
->f_fmax_frd
= value
;
2355 case MEP_OPERAND_FMAX_FRD_INT
:
2356 fields
->f_fmax_frd
= value
;
2358 case MEP_OPERAND_FMAX_FRM
:
2359 fields
->f_fmax_frm
= value
;
2361 case MEP_OPERAND_FMAX_FRN
:
2362 fields
->f_fmax_frn
= value
;
2364 case MEP_OPERAND_FMAX_FRN_INT
:
2365 fields
->f_fmax_frn
= value
;
2367 case MEP_OPERAND_FMAX_RM
:
2368 fields
->f_fmax_rm
= value
;
2370 case MEP_OPERAND_HI
:
2372 case MEP_OPERAND_LO
:
2374 case MEP_OPERAND_LP
:
2376 case MEP_OPERAND_MB0
:
2378 case MEP_OPERAND_MB1
:
2380 case MEP_OPERAND_ME0
:
2382 case MEP_OPERAND_ME1
:
2384 case MEP_OPERAND_NPC
:
2386 case MEP_OPERAND_OPT
:
2388 case MEP_OPERAND_PCABS24A2
:
2389 fields
->f_24u5a2n
= value
;
2391 case MEP_OPERAND_PCREL12A2
:
2392 fields
->f_12s4a2
= value
;
2394 case MEP_OPERAND_PCREL17A2
:
2395 fields
->f_17s16a2
= value
;
2397 case MEP_OPERAND_PCREL24A2
:
2398 fields
->f_24s5a2n
= value
;
2400 case MEP_OPERAND_PCREL8A2
:
2401 fields
->f_8s8a2
= value
;
2403 case MEP_OPERAND_PSW
:
2405 case MEP_OPERAND_R0
:
2407 case MEP_OPERAND_R1
:
2409 case MEP_OPERAND_RL
:
2410 fields
->f_rl
= value
;
2412 case MEP_OPERAND_RM
:
2413 fields
->f_rm
= value
;
2415 case MEP_OPERAND_RMA
:
2416 fields
->f_rm
= value
;
2418 case MEP_OPERAND_RN
:
2419 fields
->f_rn
= value
;
2421 case MEP_OPERAND_RN3
:
2422 fields
->f_rn3
= value
;
2424 case MEP_OPERAND_RN3C
:
2425 fields
->f_rn3
= value
;
2427 case MEP_OPERAND_RN3L
:
2428 fields
->f_rn3
= value
;
2430 case MEP_OPERAND_RN3S
:
2431 fields
->f_rn3
= value
;
2433 case MEP_OPERAND_RN3UC
:
2434 fields
->f_rn3
= value
;
2436 case MEP_OPERAND_RN3UL
:
2437 fields
->f_rn3
= value
;
2439 case MEP_OPERAND_RN3US
:
2440 fields
->f_rn3
= value
;
2442 case MEP_OPERAND_RNC
:
2443 fields
->f_rn
= value
;
2445 case MEP_OPERAND_RNL
:
2446 fields
->f_rn
= value
;
2448 case MEP_OPERAND_RNS
:
2449 fields
->f_rn
= value
;
2451 case MEP_OPERAND_RNUC
:
2452 fields
->f_rn
= value
;
2454 case MEP_OPERAND_RNUL
:
2455 fields
->f_rn
= value
;
2457 case MEP_OPERAND_RNUS
:
2458 fields
->f_rn
= value
;
2460 case MEP_OPERAND_SAR
:
2462 case MEP_OPERAND_SDISP16
:
2463 fields
->f_16s16
= value
;
2465 case MEP_OPERAND_SIMM16
:
2466 fields
->f_16s16
= value
;
2468 case MEP_OPERAND_SIMM6
:
2469 fields
->f_6s8
= value
;
2471 case MEP_OPERAND_SIMM8
:
2472 fields
->f_8s8
= value
;
2474 case MEP_OPERAND_SP
:
2476 case MEP_OPERAND_SPR
:
2478 case MEP_OPERAND_TP
:
2480 case MEP_OPERAND_TPR
:
2482 case MEP_OPERAND_UDISP2
:
2483 fields
->f_2u6
= value
;
2485 case MEP_OPERAND_UDISP7
:
2486 fields
->f_7u9
= value
;
2488 case MEP_OPERAND_UDISP7A2
:
2489 fields
->f_7u9a2
= value
;
2491 case MEP_OPERAND_UDISP7A4
:
2492 fields
->f_7u9a4
= value
;
2494 case MEP_OPERAND_UIMM16
:
2495 fields
->f_16u16
= value
;
2497 case MEP_OPERAND_UIMM2
:
2498 fields
->f_2u10
= value
;
2500 case MEP_OPERAND_UIMM24
:
2501 fields
->f_24u8n
= value
;
2503 case MEP_OPERAND_UIMM3
:
2504 fields
->f_3u5
= value
;
2506 case MEP_OPERAND_UIMM4
:
2507 fields
->f_4u8
= value
;
2509 case MEP_OPERAND_UIMM5
:
2510 fields
->f_5u8
= value
;
2512 case MEP_OPERAND_UIMM7A4
:
2513 fields
->f_7u9a4
= value
;
2515 case MEP_OPERAND_ZERO
:
2519 /* xgettext:c-format */
2520 fprintf (stderr
, _("Unrecognized field %d while setting vma operand.\n"),
2526 /* Function to call before using the instruction builder tables. */
2529 mep_cgen_init_ibld_table (CGEN_CPU_DESC cd
)
2531 cd
->insert_handlers
= & mep_cgen_insert_handlers
[0];
2532 cd
->extract_handlers
= & mep_cgen_extract_handlers
[0];
2534 cd
->insert_operand
= mep_cgen_insert_operand
;
2535 cd
->extract_operand
= mep_cgen_extract_operand
;
2537 cd
->get_int_operand
= mep_cgen_get_int_operand
;
2538 cd
->set_int_operand
= mep_cgen_set_int_operand
;
2539 cd
->get_vma_operand
= mep_cgen_get_vma_operand
;
2540 cd
->set_vma_operand
= mep_cgen_set_vma_operand
;