Typo fix in most recent entry.
[binutils.git] / opcodes / mep-ibld.c
blobac44ee2535e69ea2235769038722feafa2515235
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)
14 any later version.
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.
26 Keep that in mind. */
28 #include "sysdep.h"
29 #include <stdio.h>
30 #include "ansidecl.h"
31 #include "dis-asm.h"
32 #include "bfd.h"
33 #include "symcat.h"
34 #include "mep-desc.h"
35 #include "mep-opc.h"
36 #include "opintl.h"
37 #include "safe-ctype.h"
39 #undef min
40 #define min(a,b) ((a) < (b) ? (a) : (b))
41 #undef max
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);
60 #if CGEN_INT_INSN_P
61 static void put_insn_int_value
62 (CGEN_CPU_DESC, CGEN_INSN_BYTES_PTR, int, int, CGEN_INSN_INT);
63 #endif
64 #if ! CGEN_INT_INSN_P
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);
71 #endif
73 /* Operand insertion. */
75 #if ! CGEN_INT_INSN_P
77 /* Subroutine of insert_normal. */
79 static CGEN_INLINE void
80 insert_1 (CGEN_CPU_DESC cd,
81 unsigned long value,
82 int start,
83 int length,
84 int word_length,
85 unsigned char *bufp)
87 unsigned long x,mask;
88 int shift;
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;
94 if (CGEN_INSN_LSB0_P)
95 shift = (start + 1) - length;
96 else
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
119 necessary. */
121 static const char *
122 insert_normal (CGEN_CPU_DESC cd,
123 long value,
124 unsigned int attrs,
125 unsigned int word_offset,
126 unsigned int start,
127 unsigned int length,
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. */
137 if (length == 0)
138 return NULL;
140 if (word_length > 32)
141 abort ();
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)
147 if (word_offset == 0
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)
159 || value < minval)
161 /* xgettext:c-format */
162 sprintf (errbuf,
163 _("operand out of range (%ld not between %ld and %lu)"),
164 value, minval, maxval);
165 return errbuf;
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))
178 val &= 0xFFFFFFFF;
180 if (val > maxval)
182 /* xgettext:c-format */
183 sprintf (errbuf,
184 _("operand out of range (0x%lx not between 0 and 0x%lx)"),
185 val, maxval);
186 return errbuf;
189 else
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)
198 sprintf
199 /* xgettext:c-format */
200 (errbuf, _("operand out of range (%ld not between %ld and %ld)"),
201 value, minval, maxval);
202 return errbuf;
207 #if CGEN_INT_INSN_P
210 int shift;
212 if (CGEN_INSN_LSB0_P)
213 shift = (word_offset + start + 1) - length;
214 else
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 */
229 return NULL;
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. */
239 static const char *
240 insert_insn_normal (CGEN_CPU_DESC cd,
241 const CGEN_INSN * insn,
242 CGEN_FIELDS * fields,
243 CGEN_INSN_BYTES_PTR buffer,
244 bfd_vma pc)
246 const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
247 unsigned long value;
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. */
256 #if CGEN_INT_INSN_P
258 put_insn_int_value (cd, buffer, cd->base_insn_bitsize,
259 CGEN_FIELDS_BITSIZE (fields), value);
261 #else
263 cgen_put_insn_value (cd, buffer, min ((unsigned) cd->base_insn_bitsize,
264 (unsigned) CGEN_FIELDS_BITSIZE (fields)),
265 value);
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)
276 const char *errmsg;
278 if (CGEN_SYNTAX_CHAR_P (* syn))
279 continue;
281 errmsg = (* cd->insert_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
282 fields, buffer, pc);
283 if (errmsg)
284 return errmsg;
287 return NULL;
290 #if CGEN_INT_INSN_P
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. */
294 static void
295 put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
296 CGEN_INSN_BYTES_PTR buf,
297 int length,
298 int insn_length,
299 CGEN_INSN_INT value)
301 /* For architectures with insns smaller than the base-insn-bitsize,
302 length may be too big. */
303 if (length > insn_length)
304 *buf = value;
305 else
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);
314 #endif
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,
329 int offset,
330 int bytes,
331 bfd_vma pc)
333 /* It's doubtful that the middle part has already been fetched so
334 we don't optimize that case. kiss. */
335 unsigned int mask;
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)
341 return 1;
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))
346 break;
348 if (bytes)
350 int status;
352 pc += offset;
353 status = (*info->read_memory_func)
354 (pc, ex_info->insn_bytes + offset, bytes, info);
356 if (status != 0)
358 (*info->memory_error_func) (status, pc, info);
359 return 0;
362 ex_info->valid |= ((1 << bytes) - 1) << offset;
365 return 1;
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,
373 int start,
374 int length,
375 int word_length,
376 unsigned char *bufp,
377 bfd_vma pc ATTRIBUTE_UNUSED)
379 unsigned long x;
380 int shift;
382 x = cgen_get_insn_value (cd, bufp, word_length);
384 if (CGEN_INSN_LSB0_P)
385 shift = (start + 1) - length;
386 else
387 shift = (word_length - (start + length));
388 return x >> shift;
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
411 necessary. */
413 static int
414 extract_normal (CGEN_CPU_DESC cd,
415 #if ! CGEN_INT_INSN_P
416 CGEN_EXTRACT_INFO *ex_info,
417 #else
418 CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED,
419 #endif
420 CGEN_INSN_INT insn_value,
421 unsigned int attrs,
422 unsigned int word_offset,
423 unsigned int start,
424 unsigned int length,
425 unsigned int word_length,
426 unsigned int total_length,
427 #if ! CGEN_INT_INSN_P
428 bfd_vma pc,
429 #else
430 bfd_vma pc ATTRIBUTE_UNUSED,
431 #endif
432 long *valuep)
434 long value, mask;
436 /* If LENGTH is zero, this operand doesn't contribute to the value
437 so give it a standard value of zero. */
438 if (length == 0)
440 *valuep = 0;
441 return 1;
444 if (word_length > 32)
445 abort ();
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);
461 else
462 value = insn_value >> (total_length - ( word_offset + start + length));
465 #if ! CGEN_INT_INSN_P
467 else
469 unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
471 if (word_length > 32)
472 abort ();
474 if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
475 return 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;
485 value &= mask;
486 /* sign extend? */
487 if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)
488 && (value & (1L << (length - 1))))
489 value |= ~mask;
491 *valuep = value;
493 return 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
503 been called). */
505 static int
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,
510 CGEN_FIELDS *fields,
511 bfd_vma pc)
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)
522 int length;
524 if (CGEN_SYNTAX_CHAR_P (*syn))
525 continue;
527 length = (* cd->extract_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
528 ex_info, insn_value, fields, pc);
529 if (length <= 0)
530 return length;
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. */
556 const char *
557 mep_cgen_insert_operand (CGEN_CPU_DESC cd,
558 int opindex,
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);
566 switch (opindex)
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);
575 if (errmsg)
576 break;
577 errmsg = insert_normal (cd, fields->f_24u8a4n_lo, 0, 0, 8, 6, 32, total_length, buffer);
578 if (errmsg)
579 break;
581 break;
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);
591 if (errmsg)
592 break;
593 errmsg = insert_normal (cd, fields->f_6, 0, 0, 6, 1, 32, total_length, buffer);
594 if (errmsg)
595 break;
596 errmsg = insert_normal (cd, fields->f_7, 0, 0, 7, 1, 32, total_length, buffer);
597 if (errmsg)
598 break;
599 errmsg = insert_normal (cd, fields->f_11, 0, 0, 11, 1, 32, total_length, buffer);
600 if (errmsg)
601 break;
603 break;
604 case MEP_OPERAND_CCCC :
605 errmsg = insert_normal (cd, fields->f_rm, 0, 0, 8, 4, 32, total_length, buffer);
606 break;
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);
614 if (errmsg)
615 break;
616 errmsg = insert_normal (cd, fields->f_ccrn_lo, 0, 0, 4, 4, 32, total_length, buffer);
617 if (errmsg)
618 break;
620 break;
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);
623 break;
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);
630 break;
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);
637 break;
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);
644 break;
645 case MEP_OPERAND_CIMM4 :
646 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
647 break;
648 case MEP_OPERAND_CIMM5 :
649 errmsg = insert_normal (cd, fields->f_5u24, 0, 0, 24, 5, 32, total_length, buffer);
650 break;
651 case MEP_OPERAND_CODE16 :
652 errmsg = insert_normal (cd, fields->f_16u16, 0, 0, 16, 16, 32, total_length, buffer);
653 break;
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);
661 if (errmsg)
662 break;
663 errmsg = insert_normal (cd, fields->f_24u4n_lo, 0, 0, 16, 16, 32, total_length, buffer);
664 if (errmsg)
665 break;
667 break;
668 case MEP_OPERAND_CP_FLAG :
669 break;
670 case MEP_OPERAND_CRN :
671 errmsg = insert_normal (cd, fields->f_crn, 0, 0, 4, 4, 32, total_length, buffer);
672 break;
673 case MEP_OPERAND_CRN64 :
674 errmsg = insert_normal (cd, fields->f_crn, 0, 0, 4, 4, 32, total_length, buffer);
675 break;
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);
683 if (errmsg)
684 break;
685 errmsg = insert_normal (cd, fields->f_crnx_lo, 0, 0, 4, 4, 32, total_length, buffer);
686 if (errmsg)
687 break;
689 break;
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);
697 if (errmsg)
698 break;
699 errmsg = insert_normal (cd, fields->f_crnx_lo, 0, 0, 4, 4, 32, total_length, buffer);
700 if (errmsg)
701 break;
703 break;
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);
711 if (errmsg)
712 break;
713 errmsg = insert_normal (cd, fields->f_csrn_lo, 0, 0, 8, 4, 32, total_length, buffer);
714 if (errmsg)
715 break;
717 break;
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);
725 if (errmsg)
726 break;
727 errmsg = insert_normal (cd, fields->f_csrn_lo, 0, 0, 8, 4, 32, total_length, buffer);
728 if (errmsg)
729 break;
731 break;
732 case MEP_OPERAND_DBG :
733 break;
734 case MEP_OPERAND_DEPC :
735 break;
736 case MEP_OPERAND_EPC :
737 break;
738 case MEP_OPERAND_EXC :
739 break;
740 case MEP_OPERAND_HI :
741 break;
742 case MEP_OPERAND_LO :
743 break;
744 case MEP_OPERAND_LP :
745 break;
746 case MEP_OPERAND_MB0 :
747 break;
748 case MEP_OPERAND_MB1 :
749 break;
750 case MEP_OPERAND_ME0 :
751 break;
752 case MEP_OPERAND_ME1 :
753 break;
754 case MEP_OPERAND_NPC :
755 break;
756 case MEP_OPERAND_OPT :
757 break;
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);
765 if (errmsg)
766 break;
767 errmsg = insert_normal (cd, fields->f_24u5a2n_lo, 0, 0, 5, 7, 32, total_length, buffer);
768 if (errmsg)
769 break;
771 break;
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);
778 break;
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);
785 break;
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);
794 if (errmsg)
795 break;
796 errmsg = insert_normal (cd, fields->f_24s5a2n_lo, 0|(1<<CGEN_IFLD_PCREL_ADDR), 0, 5, 7, 32, total_length, buffer);
797 if (errmsg)
798 break;
800 break;
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);
807 break;
808 case MEP_OPERAND_PSW :
809 break;
810 case MEP_OPERAND_R0 :
811 break;
812 case MEP_OPERAND_R1 :
813 break;
814 case MEP_OPERAND_RL :
815 errmsg = insert_normal (cd, fields->f_rl, 0, 0, 12, 4, 32, total_length, buffer);
816 break;
817 case MEP_OPERAND_RM :
818 errmsg = insert_normal (cd, fields->f_rm, 0, 0, 8, 4, 32, total_length, buffer);
819 break;
820 case MEP_OPERAND_RMA :
821 errmsg = insert_normal (cd, fields->f_rm, 0, 0, 8, 4, 32, total_length, buffer);
822 break;
823 case MEP_OPERAND_RN :
824 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
825 break;
826 case MEP_OPERAND_RN3 :
827 errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
828 break;
829 case MEP_OPERAND_RN3C :
830 errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
831 break;
832 case MEP_OPERAND_RN3L :
833 errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
834 break;
835 case MEP_OPERAND_RN3S :
836 errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
837 break;
838 case MEP_OPERAND_RN3UC :
839 errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
840 break;
841 case MEP_OPERAND_RN3UL :
842 errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
843 break;
844 case MEP_OPERAND_RN3US :
845 errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
846 break;
847 case MEP_OPERAND_RNC :
848 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
849 break;
850 case MEP_OPERAND_RNL :
851 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
852 break;
853 case MEP_OPERAND_RNS :
854 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
855 break;
856 case MEP_OPERAND_RNUC :
857 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
858 break;
859 case MEP_OPERAND_RNUL :
860 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
861 break;
862 case MEP_OPERAND_RNUS :
863 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
864 break;
865 case MEP_OPERAND_SAR :
866 break;
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);
869 break;
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);
872 break;
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);
875 break;
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);
878 break;
879 case MEP_OPERAND_SP :
880 break;
881 case MEP_OPERAND_SPR :
882 break;
883 case MEP_OPERAND_TP :
884 break;
885 case MEP_OPERAND_TPR :
886 break;
887 case MEP_OPERAND_UDISP2 :
888 errmsg = insert_normal (cd, fields->f_2u6, 0, 0, 6, 2, 32, total_length, buffer);
889 break;
890 case MEP_OPERAND_UDISP7 :
891 errmsg = insert_normal (cd, fields->f_7u9, 0, 0, 9, 7, 32, total_length, buffer);
892 break;
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);
899 break;
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);
906 break;
907 case MEP_OPERAND_UIMM16 :
908 errmsg = insert_normal (cd, fields->f_16u16, 0, 0, 16, 16, 32, total_length, buffer);
909 break;
910 case MEP_OPERAND_UIMM2 :
911 errmsg = insert_normal (cd, fields->f_2u10, 0, 0, 10, 2, 32, total_length, buffer);
912 break;
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);
920 if (errmsg)
921 break;
922 errmsg = insert_normal (cd, fields->f_24u8n_lo, 0, 0, 8, 8, 32, total_length, buffer);
923 if (errmsg)
924 break;
926 break;
927 case MEP_OPERAND_UIMM3 :
928 errmsg = insert_normal (cd, fields->f_3u5, 0, 0, 5, 3, 32, total_length, buffer);
929 break;
930 case MEP_OPERAND_UIMM4 :
931 errmsg = insert_normal (cd, fields->f_4u8, 0, 0, 8, 4, 32, total_length, buffer);
932 break;
933 case MEP_OPERAND_UIMM5 :
934 errmsg = insert_normal (cd, fields->f_5u8, 0, 0, 8, 5, 32, total_length, buffer);
935 break;
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);
942 break;
943 case MEP_OPERAND_ZERO :
944 break;
946 default :
947 /* xgettext:c-format */
948 fprintf (stderr, _("Unrecognized field %d while building insn.\n"),
949 opindex);
950 abort ();
953 return errmsg;
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
972 the handlers. */
975 mep_cgen_extract_operand (CGEN_CPU_DESC cd,
976 int opindex,
977 CGEN_EXTRACT_INFO *ex_info,
978 CGEN_INSN_INT insn_value,
979 CGEN_FIELDS * fields,
980 bfd_vma pc)
982 /* Assume success (for those operands that are nops). */
983 int length = 1;
984 unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
986 switch (opindex)
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))));
996 break;
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)))))));
1009 break;
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);
1012 break;
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)));
1021 break;
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);
1024 break;
1025 case MEP_OPERAND_CDISP8A2 :
1027 long value;
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;
1032 break;
1033 case MEP_OPERAND_CDISP8A4 :
1035 long value;
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;
1040 break;
1041 case MEP_OPERAND_CDISP8A8 :
1043 long value;
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;
1048 break;
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);
1051 break;
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);
1054 break;
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);
1057 break;
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)));
1066 break;
1067 case MEP_OPERAND_CP_FLAG :
1068 break;
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);
1071 break;
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);
1074 break;
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)));
1083 break;
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)));
1092 break;
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)));
1101 break;
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)));
1110 break;
1111 case MEP_OPERAND_DBG :
1112 break;
1113 case MEP_OPERAND_DEPC :
1114 break;
1115 case MEP_OPERAND_EPC :
1116 break;
1117 case MEP_OPERAND_EXC :
1118 break;
1119 case MEP_OPERAND_HI :
1120 break;
1121 case MEP_OPERAND_LO :
1122 break;
1123 case MEP_OPERAND_LP :
1124 break;
1125 case MEP_OPERAND_MB0 :
1126 break;
1127 case MEP_OPERAND_MB1 :
1128 break;
1129 case MEP_OPERAND_ME0 :
1130 break;
1131 case MEP_OPERAND_ME1 :
1132 break;
1133 case MEP_OPERAND_NPC :
1134 break;
1135 case MEP_OPERAND_OPT :
1136 break;
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))));
1145 break;
1146 case MEP_OPERAND_PCREL12A2 :
1148 long value;
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;
1153 break;
1154 case MEP_OPERAND_PCREL17A2 :
1156 long value;
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;
1161 break;
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));
1170 break;
1171 case MEP_OPERAND_PCREL8A2 :
1173 long value;
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;
1178 break;
1179 case MEP_OPERAND_PSW :
1180 break;
1181 case MEP_OPERAND_R0 :
1182 break;
1183 case MEP_OPERAND_R1 :
1184 break;
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);
1187 break;
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);
1190 break;
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);
1193 break;
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);
1196 break;
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);
1199 break;
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);
1202 break;
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);
1205 break;
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);
1208 break;
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);
1211 break;
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);
1214 break;
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);
1217 break;
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);
1220 break;
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);
1223 break;
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);
1226 break;
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);
1229 break;
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);
1232 break;
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);
1235 break;
1236 case MEP_OPERAND_SAR :
1237 break;
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);
1240 break;
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);
1243 break;
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);
1246 break;
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);
1249 break;
1250 case MEP_OPERAND_SP :
1251 break;
1252 case MEP_OPERAND_SPR :
1253 break;
1254 case MEP_OPERAND_TP :
1255 break;
1256 case MEP_OPERAND_TPR :
1257 break;
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);
1260 break;
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);
1263 break;
1264 case MEP_OPERAND_UDISP7A2 :
1266 long value;
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;
1271 break;
1272 case MEP_OPERAND_UDISP7A4 :
1274 long value;
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;
1279 break;
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);
1282 break;
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);
1285 break;
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)));
1294 break;
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);
1297 break;
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);
1300 break;
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);
1303 break;
1304 case MEP_OPERAND_UIMM7A4 :
1306 long value;
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;
1311 break;
1312 case MEP_OPERAND_ZERO :
1313 break;
1315 default :
1316 /* xgettext:c-format */
1317 fprintf (stderr, _("Unrecognized field %d while decoding insn.\n"),
1318 opindex);
1319 abort ();
1322 return length;
1325 cgen_insert_fn * const mep_cgen_insert_handlers[] =
1327 insert_insn_normal,
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
1341 not appropriate. */
1344 mep_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1345 int opindex,
1346 const CGEN_FIELDS * fields)
1348 int value;
1350 switch (opindex)
1352 case MEP_OPERAND_ADDR24A4 :
1353 value = fields->f_24u8a4n;
1354 break;
1355 case MEP_OPERAND_CALLNUM :
1356 value = fields->f_callnum;
1357 break;
1358 case MEP_OPERAND_CCCC :
1359 value = fields->f_rm;
1360 break;
1361 case MEP_OPERAND_CCRN :
1362 value = fields->f_ccrn;
1363 break;
1364 case MEP_OPERAND_CDISP8 :
1365 value = fields->f_8s24;
1366 break;
1367 case MEP_OPERAND_CDISP8A2 :
1368 value = fields->f_8s24a2;
1369 break;
1370 case MEP_OPERAND_CDISP8A4 :
1371 value = fields->f_8s24a4;
1372 break;
1373 case MEP_OPERAND_CDISP8A8 :
1374 value = fields->f_8s24a8;
1375 break;
1376 case MEP_OPERAND_CIMM4 :
1377 value = fields->f_rn;
1378 break;
1379 case MEP_OPERAND_CIMM5 :
1380 value = fields->f_5u24;
1381 break;
1382 case MEP_OPERAND_CODE16 :
1383 value = fields->f_16u16;
1384 break;
1385 case MEP_OPERAND_CODE24 :
1386 value = fields->f_24u4n;
1387 break;
1388 case MEP_OPERAND_CP_FLAG :
1389 value = 0;
1390 break;
1391 case MEP_OPERAND_CRN :
1392 value = fields->f_crn;
1393 break;
1394 case MEP_OPERAND_CRN64 :
1395 value = fields->f_crn;
1396 break;
1397 case MEP_OPERAND_CRNX :
1398 value = fields->f_crnx;
1399 break;
1400 case MEP_OPERAND_CRNX64 :
1401 value = fields->f_crnx;
1402 break;
1403 case MEP_OPERAND_CSRN :
1404 value = fields->f_csrn;
1405 break;
1406 case MEP_OPERAND_CSRN_IDX :
1407 value = fields->f_csrn;
1408 break;
1409 case MEP_OPERAND_DBG :
1410 value = 0;
1411 break;
1412 case MEP_OPERAND_DEPC :
1413 value = 0;
1414 break;
1415 case MEP_OPERAND_EPC :
1416 value = 0;
1417 break;
1418 case MEP_OPERAND_EXC :
1419 value = 0;
1420 break;
1421 case MEP_OPERAND_HI :
1422 value = 0;
1423 break;
1424 case MEP_OPERAND_LO :
1425 value = 0;
1426 break;
1427 case MEP_OPERAND_LP :
1428 value = 0;
1429 break;
1430 case MEP_OPERAND_MB0 :
1431 value = 0;
1432 break;
1433 case MEP_OPERAND_MB1 :
1434 value = 0;
1435 break;
1436 case MEP_OPERAND_ME0 :
1437 value = 0;
1438 break;
1439 case MEP_OPERAND_ME1 :
1440 value = 0;
1441 break;
1442 case MEP_OPERAND_NPC :
1443 value = 0;
1444 break;
1445 case MEP_OPERAND_OPT :
1446 value = 0;
1447 break;
1448 case MEP_OPERAND_PCABS24A2 :
1449 value = fields->f_24u5a2n;
1450 break;
1451 case MEP_OPERAND_PCREL12A2 :
1452 value = fields->f_12s4a2;
1453 break;
1454 case MEP_OPERAND_PCREL17A2 :
1455 value = fields->f_17s16a2;
1456 break;
1457 case MEP_OPERAND_PCREL24A2 :
1458 value = fields->f_24s5a2n;
1459 break;
1460 case MEP_OPERAND_PCREL8A2 :
1461 value = fields->f_8s8a2;
1462 break;
1463 case MEP_OPERAND_PSW :
1464 value = 0;
1465 break;
1466 case MEP_OPERAND_R0 :
1467 value = 0;
1468 break;
1469 case MEP_OPERAND_R1 :
1470 value = 0;
1471 break;
1472 case MEP_OPERAND_RL :
1473 value = fields->f_rl;
1474 break;
1475 case MEP_OPERAND_RM :
1476 value = fields->f_rm;
1477 break;
1478 case MEP_OPERAND_RMA :
1479 value = fields->f_rm;
1480 break;
1481 case MEP_OPERAND_RN :
1482 value = fields->f_rn;
1483 break;
1484 case MEP_OPERAND_RN3 :
1485 value = fields->f_rn3;
1486 break;
1487 case MEP_OPERAND_RN3C :
1488 value = fields->f_rn3;
1489 break;
1490 case MEP_OPERAND_RN3L :
1491 value = fields->f_rn3;
1492 break;
1493 case MEP_OPERAND_RN3S :
1494 value = fields->f_rn3;
1495 break;
1496 case MEP_OPERAND_RN3UC :
1497 value = fields->f_rn3;
1498 break;
1499 case MEP_OPERAND_RN3UL :
1500 value = fields->f_rn3;
1501 break;
1502 case MEP_OPERAND_RN3US :
1503 value = fields->f_rn3;
1504 break;
1505 case MEP_OPERAND_RNC :
1506 value = fields->f_rn;
1507 break;
1508 case MEP_OPERAND_RNL :
1509 value = fields->f_rn;
1510 break;
1511 case MEP_OPERAND_RNS :
1512 value = fields->f_rn;
1513 break;
1514 case MEP_OPERAND_RNUC :
1515 value = fields->f_rn;
1516 break;
1517 case MEP_OPERAND_RNUL :
1518 value = fields->f_rn;
1519 break;
1520 case MEP_OPERAND_RNUS :
1521 value = fields->f_rn;
1522 break;
1523 case MEP_OPERAND_SAR :
1524 value = 0;
1525 break;
1526 case MEP_OPERAND_SDISP16 :
1527 value = fields->f_16s16;
1528 break;
1529 case MEP_OPERAND_SIMM16 :
1530 value = fields->f_16s16;
1531 break;
1532 case MEP_OPERAND_SIMM6 :
1533 value = fields->f_6s8;
1534 break;
1535 case MEP_OPERAND_SIMM8 :
1536 value = fields->f_8s8;
1537 break;
1538 case MEP_OPERAND_SP :
1539 value = 0;
1540 break;
1541 case MEP_OPERAND_SPR :
1542 value = 0;
1543 break;
1544 case MEP_OPERAND_TP :
1545 value = 0;
1546 break;
1547 case MEP_OPERAND_TPR :
1548 value = 0;
1549 break;
1550 case MEP_OPERAND_UDISP2 :
1551 value = fields->f_2u6;
1552 break;
1553 case MEP_OPERAND_UDISP7 :
1554 value = fields->f_7u9;
1555 break;
1556 case MEP_OPERAND_UDISP7A2 :
1557 value = fields->f_7u9a2;
1558 break;
1559 case MEP_OPERAND_UDISP7A4 :
1560 value = fields->f_7u9a4;
1561 break;
1562 case MEP_OPERAND_UIMM16 :
1563 value = fields->f_16u16;
1564 break;
1565 case MEP_OPERAND_UIMM2 :
1566 value = fields->f_2u10;
1567 break;
1568 case MEP_OPERAND_UIMM24 :
1569 value = fields->f_24u8n;
1570 break;
1571 case MEP_OPERAND_UIMM3 :
1572 value = fields->f_3u5;
1573 break;
1574 case MEP_OPERAND_UIMM4 :
1575 value = fields->f_4u8;
1576 break;
1577 case MEP_OPERAND_UIMM5 :
1578 value = fields->f_5u8;
1579 break;
1580 case MEP_OPERAND_UIMM7A4 :
1581 value = fields->f_7u9a4;
1582 break;
1583 case MEP_OPERAND_ZERO :
1584 value = 0;
1585 break;
1587 default :
1588 /* xgettext:c-format */
1589 fprintf (stderr, _("Unrecognized field %d while getting int operand.\n"),
1590 opindex);
1591 abort ();
1594 return value;
1597 bfd_vma
1598 mep_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1599 int opindex,
1600 const CGEN_FIELDS * fields)
1602 bfd_vma value;
1604 switch (opindex)
1606 case MEP_OPERAND_ADDR24A4 :
1607 value = fields->f_24u8a4n;
1608 break;
1609 case MEP_OPERAND_CALLNUM :
1610 value = fields->f_callnum;
1611 break;
1612 case MEP_OPERAND_CCCC :
1613 value = fields->f_rm;
1614 break;
1615 case MEP_OPERAND_CCRN :
1616 value = fields->f_ccrn;
1617 break;
1618 case MEP_OPERAND_CDISP8 :
1619 value = fields->f_8s24;
1620 break;
1621 case MEP_OPERAND_CDISP8A2 :
1622 value = fields->f_8s24a2;
1623 break;
1624 case MEP_OPERAND_CDISP8A4 :
1625 value = fields->f_8s24a4;
1626 break;
1627 case MEP_OPERAND_CDISP8A8 :
1628 value = fields->f_8s24a8;
1629 break;
1630 case MEP_OPERAND_CIMM4 :
1631 value = fields->f_rn;
1632 break;
1633 case MEP_OPERAND_CIMM5 :
1634 value = fields->f_5u24;
1635 break;
1636 case MEP_OPERAND_CODE16 :
1637 value = fields->f_16u16;
1638 break;
1639 case MEP_OPERAND_CODE24 :
1640 value = fields->f_24u4n;
1641 break;
1642 case MEP_OPERAND_CP_FLAG :
1643 value = 0;
1644 break;
1645 case MEP_OPERAND_CRN :
1646 value = fields->f_crn;
1647 break;
1648 case MEP_OPERAND_CRN64 :
1649 value = fields->f_crn;
1650 break;
1651 case MEP_OPERAND_CRNX :
1652 value = fields->f_crnx;
1653 break;
1654 case MEP_OPERAND_CRNX64 :
1655 value = fields->f_crnx;
1656 break;
1657 case MEP_OPERAND_CSRN :
1658 value = fields->f_csrn;
1659 break;
1660 case MEP_OPERAND_CSRN_IDX :
1661 value = fields->f_csrn;
1662 break;
1663 case MEP_OPERAND_DBG :
1664 value = 0;
1665 break;
1666 case MEP_OPERAND_DEPC :
1667 value = 0;
1668 break;
1669 case MEP_OPERAND_EPC :
1670 value = 0;
1671 break;
1672 case MEP_OPERAND_EXC :
1673 value = 0;
1674 break;
1675 case MEP_OPERAND_HI :
1676 value = 0;
1677 break;
1678 case MEP_OPERAND_LO :
1679 value = 0;
1680 break;
1681 case MEP_OPERAND_LP :
1682 value = 0;
1683 break;
1684 case MEP_OPERAND_MB0 :
1685 value = 0;
1686 break;
1687 case MEP_OPERAND_MB1 :
1688 value = 0;
1689 break;
1690 case MEP_OPERAND_ME0 :
1691 value = 0;
1692 break;
1693 case MEP_OPERAND_ME1 :
1694 value = 0;
1695 break;
1696 case MEP_OPERAND_NPC :
1697 value = 0;
1698 break;
1699 case MEP_OPERAND_OPT :
1700 value = 0;
1701 break;
1702 case MEP_OPERAND_PCABS24A2 :
1703 value = fields->f_24u5a2n;
1704 break;
1705 case MEP_OPERAND_PCREL12A2 :
1706 value = fields->f_12s4a2;
1707 break;
1708 case MEP_OPERAND_PCREL17A2 :
1709 value = fields->f_17s16a2;
1710 break;
1711 case MEP_OPERAND_PCREL24A2 :
1712 value = fields->f_24s5a2n;
1713 break;
1714 case MEP_OPERAND_PCREL8A2 :
1715 value = fields->f_8s8a2;
1716 break;
1717 case MEP_OPERAND_PSW :
1718 value = 0;
1719 break;
1720 case MEP_OPERAND_R0 :
1721 value = 0;
1722 break;
1723 case MEP_OPERAND_R1 :
1724 value = 0;
1725 break;
1726 case MEP_OPERAND_RL :
1727 value = fields->f_rl;
1728 break;
1729 case MEP_OPERAND_RM :
1730 value = fields->f_rm;
1731 break;
1732 case MEP_OPERAND_RMA :
1733 value = fields->f_rm;
1734 break;
1735 case MEP_OPERAND_RN :
1736 value = fields->f_rn;
1737 break;
1738 case MEP_OPERAND_RN3 :
1739 value = fields->f_rn3;
1740 break;
1741 case MEP_OPERAND_RN3C :
1742 value = fields->f_rn3;
1743 break;
1744 case MEP_OPERAND_RN3L :
1745 value = fields->f_rn3;
1746 break;
1747 case MEP_OPERAND_RN3S :
1748 value = fields->f_rn3;
1749 break;
1750 case MEP_OPERAND_RN3UC :
1751 value = fields->f_rn3;
1752 break;
1753 case MEP_OPERAND_RN3UL :
1754 value = fields->f_rn3;
1755 break;
1756 case MEP_OPERAND_RN3US :
1757 value = fields->f_rn3;
1758 break;
1759 case MEP_OPERAND_RNC :
1760 value = fields->f_rn;
1761 break;
1762 case MEP_OPERAND_RNL :
1763 value = fields->f_rn;
1764 break;
1765 case MEP_OPERAND_RNS :
1766 value = fields->f_rn;
1767 break;
1768 case MEP_OPERAND_RNUC :
1769 value = fields->f_rn;
1770 break;
1771 case MEP_OPERAND_RNUL :
1772 value = fields->f_rn;
1773 break;
1774 case MEP_OPERAND_RNUS :
1775 value = fields->f_rn;
1776 break;
1777 case MEP_OPERAND_SAR :
1778 value = 0;
1779 break;
1780 case MEP_OPERAND_SDISP16 :
1781 value = fields->f_16s16;
1782 break;
1783 case MEP_OPERAND_SIMM16 :
1784 value = fields->f_16s16;
1785 break;
1786 case MEP_OPERAND_SIMM6 :
1787 value = fields->f_6s8;
1788 break;
1789 case MEP_OPERAND_SIMM8 :
1790 value = fields->f_8s8;
1791 break;
1792 case MEP_OPERAND_SP :
1793 value = 0;
1794 break;
1795 case MEP_OPERAND_SPR :
1796 value = 0;
1797 break;
1798 case MEP_OPERAND_TP :
1799 value = 0;
1800 break;
1801 case MEP_OPERAND_TPR :
1802 value = 0;
1803 break;
1804 case MEP_OPERAND_UDISP2 :
1805 value = fields->f_2u6;
1806 break;
1807 case MEP_OPERAND_UDISP7 :
1808 value = fields->f_7u9;
1809 break;
1810 case MEP_OPERAND_UDISP7A2 :
1811 value = fields->f_7u9a2;
1812 break;
1813 case MEP_OPERAND_UDISP7A4 :
1814 value = fields->f_7u9a4;
1815 break;
1816 case MEP_OPERAND_UIMM16 :
1817 value = fields->f_16u16;
1818 break;
1819 case MEP_OPERAND_UIMM2 :
1820 value = fields->f_2u10;
1821 break;
1822 case MEP_OPERAND_UIMM24 :
1823 value = fields->f_24u8n;
1824 break;
1825 case MEP_OPERAND_UIMM3 :
1826 value = fields->f_3u5;
1827 break;
1828 case MEP_OPERAND_UIMM4 :
1829 value = fields->f_4u8;
1830 break;
1831 case MEP_OPERAND_UIMM5 :
1832 value = fields->f_5u8;
1833 break;
1834 case MEP_OPERAND_UIMM7A4 :
1835 value = fields->f_7u9a4;
1836 break;
1837 case MEP_OPERAND_ZERO :
1838 value = 0;
1839 break;
1841 default :
1842 /* xgettext:c-format */
1843 fprintf (stderr, _("Unrecognized field %d while getting vma operand.\n"),
1844 opindex);
1845 abort ();
1848 return value;
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
1857 not appropriate. */
1859 void
1860 mep_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1861 int opindex,
1862 CGEN_FIELDS * fields,
1863 int value)
1865 switch (opindex)
1867 case MEP_OPERAND_ADDR24A4 :
1868 fields->f_24u8a4n = value;
1869 break;
1870 case MEP_OPERAND_CALLNUM :
1871 fields->f_callnum = value;
1872 break;
1873 case MEP_OPERAND_CCCC :
1874 fields->f_rm = value;
1875 break;
1876 case MEP_OPERAND_CCRN :
1877 fields->f_ccrn = value;
1878 break;
1879 case MEP_OPERAND_CDISP8 :
1880 fields->f_8s24 = value;
1881 break;
1882 case MEP_OPERAND_CDISP8A2 :
1883 fields->f_8s24a2 = value;
1884 break;
1885 case MEP_OPERAND_CDISP8A4 :
1886 fields->f_8s24a4 = value;
1887 break;
1888 case MEP_OPERAND_CDISP8A8 :
1889 fields->f_8s24a8 = value;
1890 break;
1891 case MEP_OPERAND_CIMM4 :
1892 fields->f_rn = value;
1893 break;
1894 case MEP_OPERAND_CIMM5 :
1895 fields->f_5u24 = value;
1896 break;
1897 case MEP_OPERAND_CODE16 :
1898 fields->f_16u16 = value;
1899 break;
1900 case MEP_OPERAND_CODE24 :
1901 fields->f_24u4n = value;
1902 break;
1903 case MEP_OPERAND_CP_FLAG :
1904 break;
1905 case MEP_OPERAND_CRN :
1906 fields->f_crn = value;
1907 break;
1908 case MEP_OPERAND_CRN64 :
1909 fields->f_crn = value;
1910 break;
1911 case MEP_OPERAND_CRNX :
1912 fields->f_crnx = value;
1913 break;
1914 case MEP_OPERAND_CRNX64 :
1915 fields->f_crnx = value;
1916 break;
1917 case MEP_OPERAND_CSRN :
1918 fields->f_csrn = value;
1919 break;
1920 case MEP_OPERAND_CSRN_IDX :
1921 fields->f_csrn = value;
1922 break;
1923 case MEP_OPERAND_DBG :
1924 break;
1925 case MEP_OPERAND_DEPC :
1926 break;
1927 case MEP_OPERAND_EPC :
1928 break;
1929 case MEP_OPERAND_EXC :
1930 break;
1931 case MEP_OPERAND_HI :
1932 break;
1933 case MEP_OPERAND_LO :
1934 break;
1935 case MEP_OPERAND_LP :
1936 break;
1937 case MEP_OPERAND_MB0 :
1938 break;
1939 case MEP_OPERAND_MB1 :
1940 break;
1941 case MEP_OPERAND_ME0 :
1942 break;
1943 case MEP_OPERAND_ME1 :
1944 break;
1945 case MEP_OPERAND_NPC :
1946 break;
1947 case MEP_OPERAND_OPT :
1948 break;
1949 case MEP_OPERAND_PCABS24A2 :
1950 fields->f_24u5a2n = value;
1951 break;
1952 case MEP_OPERAND_PCREL12A2 :
1953 fields->f_12s4a2 = value;
1954 break;
1955 case MEP_OPERAND_PCREL17A2 :
1956 fields->f_17s16a2 = value;
1957 break;
1958 case MEP_OPERAND_PCREL24A2 :
1959 fields->f_24s5a2n = value;
1960 break;
1961 case MEP_OPERAND_PCREL8A2 :
1962 fields->f_8s8a2 = value;
1963 break;
1964 case MEP_OPERAND_PSW :
1965 break;
1966 case MEP_OPERAND_R0 :
1967 break;
1968 case MEP_OPERAND_R1 :
1969 break;
1970 case MEP_OPERAND_RL :
1971 fields->f_rl = value;
1972 break;
1973 case MEP_OPERAND_RM :
1974 fields->f_rm = value;
1975 break;
1976 case MEP_OPERAND_RMA :
1977 fields->f_rm = value;
1978 break;
1979 case MEP_OPERAND_RN :
1980 fields->f_rn = value;
1981 break;
1982 case MEP_OPERAND_RN3 :
1983 fields->f_rn3 = value;
1984 break;
1985 case MEP_OPERAND_RN3C :
1986 fields->f_rn3 = value;
1987 break;
1988 case MEP_OPERAND_RN3L :
1989 fields->f_rn3 = value;
1990 break;
1991 case MEP_OPERAND_RN3S :
1992 fields->f_rn3 = value;
1993 break;
1994 case MEP_OPERAND_RN3UC :
1995 fields->f_rn3 = value;
1996 break;
1997 case MEP_OPERAND_RN3UL :
1998 fields->f_rn3 = value;
1999 break;
2000 case MEP_OPERAND_RN3US :
2001 fields->f_rn3 = value;
2002 break;
2003 case MEP_OPERAND_RNC :
2004 fields->f_rn = value;
2005 break;
2006 case MEP_OPERAND_RNL :
2007 fields->f_rn = value;
2008 break;
2009 case MEP_OPERAND_RNS :
2010 fields->f_rn = value;
2011 break;
2012 case MEP_OPERAND_RNUC :
2013 fields->f_rn = value;
2014 break;
2015 case MEP_OPERAND_RNUL :
2016 fields->f_rn = value;
2017 break;
2018 case MEP_OPERAND_RNUS :
2019 fields->f_rn = value;
2020 break;
2021 case MEP_OPERAND_SAR :
2022 break;
2023 case MEP_OPERAND_SDISP16 :
2024 fields->f_16s16 = value;
2025 break;
2026 case MEP_OPERAND_SIMM16 :
2027 fields->f_16s16 = value;
2028 break;
2029 case MEP_OPERAND_SIMM6 :
2030 fields->f_6s8 = value;
2031 break;
2032 case MEP_OPERAND_SIMM8 :
2033 fields->f_8s8 = value;
2034 break;
2035 case MEP_OPERAND_SP :
2036 break;
2037 case MEP_OPERAND_SPR :
2038 break;
2039 case MEP_OPERAND_TP :
2040 break;
2041 case MEP_OPERAND_TPR :
2042 break;
2043 case MEP_OPERAND_UDISP2 :
2044 fields->f_2u6 = value;
2045 break;
2046 case MEP_OPERAND_UDISP7 :
2047 fields->f_7u9 = value;
2048 break;
2049 case MEP_OPERAND_UDISP7A2 :
2050 fields->f_7u9a2 = value;
2051 break;
2052 case MEP_OPERAND_UDISP7A4 :
2053 fields->f_7u9a4 = value;
2054 break;
2055 case MEP_OPERAND_UIMM16 :
2056 fields->f_16u16 = value;
2057 break;
2058 case MEP_OPERAND_UIMM2 :
2059 fields->f_2u10 = value;
2060 break;
2061 case MEP_OPERAND_UIMM24 :
2062 fields->f_24u8n = value;
2063 break;
2064 case MEP_OPERAND_UIMM3 :
2065 fields->f_3u5 = value;
2066 break;
2067 case MEP_OPERAND_UIMM4 :
2068 fields->f_4u8 = value;
2069 break;
2070 case MEP_OPERAND_UIMM5 :
2071 fields->f_5u8 = value;
2072 break;
2073 case MEP_OPERAND_UIMM7A4 :
2074 fields->f_7u9a4 = value;
2075 break;
2076 case MEP_OPERAND_ZERO :
2077 break;
2079 default :
2080 /* xgettext:c-format */
2081 fprintf (stderr, _("Unrecognized field %d while setting int operand.\n"),
2082 opindex);
2083 abort ();
2087 void
2088 mep_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
2089 int opindex,
2090 CGEN_FIELDS * fields,
2091 bfd_vma value)
2093 switch (opindex)
2095 case MEP_OPERAND_ADDR24A4 :
2096 fields->f_24u8a4n = value;
2097 break;
2098 case MEP_OPERAND_CALLNUM :
2099 fields->f_callnum = value;
2100 break;
2101 case MEP_OPERAND_CCCC :
2102 fields->f_rm = value;
2103 break;
2104 case MEP_OPERAND_CCRN :
2105 fields->f_ccrn = value;
2106 break;
2107 case MEP_OPERAND_CDISP8 :
2108 fields->f_8s24 = value;
2109 break;
2110 case MEP_OPERAND_CDISP8A2 :
2111 fields->f_8s24a2 = value;
2112 break;
2113 case MEP_OPERAND_CDISP8A4 :
2114 fields->f_8s24a4 = value;
2115 break;
2116 case MEP_OPERAND_CDISP8A8 :
2117 fields->f_8s24a8 = value;
2118 break;
2119 case MEP_OPERAND_CIMM4 :
2120 fields->f_rn = value;
2121 break;
2122 case MEP_OPERAND_CIMM5 :
2123 fields->f_5u24 = value;
2124 break;
2125 case MEP_OPERAND_CODE16 :
2126 fields->f_16u16 = value;
2127 break;
2128 case MEP_OPERAND_CODE24 :
2129 fields->f_24u4n = value;
2130 break;
2131 case MEP_OPERAND_CP_FLAG :
2132 break;
2133 case MEP_OPERAND_CRN :
2134 fields->f_crn = value;
2135 break;
2136 case MEP_OPERAND_CRN64 :
2137 fields->f_crn = value;
2138 break;
2139 case MEP_OPERAND_CRNX :
2140 fields->f_crnx = value;
2141 break;
2142 case MEP_OPERAND_CRNX64 :
2143 fields->f_crnx = value;
2144 break;
2145 case MEP_OPERAND_CSRN :
2146 fields->f_csrn = value;
2147 break;
2148 case MEP_OPERAND_CSRN_IDX :
2149 fields->f_csrn = value;
2150 break;
2151 case MEP_OPERAND_DBG :
2152 break;
2153 case MEP_OPERAND_DEPC :
2154 break;
2155 case MEP_OPERAND_EPC :
2156 break;
2157 case MEP_OPERAND_EXC :
2158 break;
2159 case MEP_OPERAND_HI :
2160 break;
2161 case MEP_OPERAND_LO :
2162 break;
2163 case MEP_OPERAND_LP :
2164 break;
2165 case MEP_OPERAND_MB0 :
2166 break;
2167 case MEP_OPERAND_MB1 :
2168 break;
2169 case MEP_OPERAND_ME0 :
2170 break;
2171 case MEP_OPERAND_ME1 :
2172 break;
2173 case MEP_OPERAND_NPC :
2174 break;
2175 case MEP_OPERAND_OPT :
2176 break;
2177 case MEP_OPERAND_PCABS24A2 :
2178 fields->f_24u5a2n = value;
2179 break;
2180 case MEP_OPERAND_PCREL12A2 :
2181 fields->f_12s4a2 = value;
2182 break;
2183 case MEP_OPERAND_PCREL17A2 :
2184 fields->f_17s16a2 = value;
2185 break;
2186 case MEP_OPERAND_PCREL24A2 :
2187 fields->f_24s5a2n = value;
2188 break;
2189 case MEP_OPERAND_PCREL8A2 :
2190 fields->f_8s8a2 = value;
2191 break;
2192 case MEP_OPERAND_PSW :
2193 break;
2194 case MEP_OPERAND_R0 :
2195 break;
2196 case MEP_OPERAND_R1 :
2197 break;
2198 case MEP_OPERAND_RL :
2199 fields->f_rl = value;
2200 break;
2201 case MEP_OPERAND_RM :
2202 fields->f_rm = value;
2203 break;
2204 case MEP_OPERAND_RMA :
2205 fields->f_rm = value;
2206 break;
2207 case MEP_OPERAND_RN :
2208 fields->f_rn = value;
2209 break;
2210 case MEP_OPERAND_RN3 :
2211 fields->f_rn3 = value;
2212 break;
2213 case MEP_OPERAND_RN3C :
2214 fields->f_rn3 = value;
2215 break;
2216 case MEP_OPERAND_RN3L :
2217 fields->f_rn3 = value;
2218 break;
2219 case MEP_OPERAND_RN3S :
2220 fields->f_rn3 = value;
2221 break;
2222 case MEP_OPERAND_RN3UC :
2223 fields->f_rn3 = value;
2224 break;
2225 case MEP_OPERAND_RN3UL :
2226 fields->f_rn3 = value;
2227 break;
2228 case MEP_OPERAND_RN3US :
2229 fields->f_rn3 = value;
2230 break;
2231 case MEP_OPERAND_RNC :
2232 fields->f_rn = value;
2233 break;
2234 case MEP_OPERAND_RNL :
2235 fields->f_rn = value;
2236 break;
2237 case MEP_OPERAND_RNS :
2238 fields->f_rn = value;
2239 break;
2240 case MEP_OPERAND_RNUC :
2241 fields->f_rn = value;
2242 break;
2243 case MEP_OPERAND_RNUL :
2244 fields->f_rn = value;
2245 break;
2246 case MEP_OPERAND_RNUS :
2247 fields->f_rn = value;
2248 break;
2249 case MEP_OPERAND_SAR :
2250 break;
2251 case MEP_OPERAND_SDISP16 :
2252 fields->f_16s16 = value;
2253 break;
2254 case MEP_OPERAND_SIMM16 :
2255 fields->f_16s16 = value;
2256 break;
2257 case MEP_OPERAND_SIMM6 :
2258 fields->f_6s8 = value;
2259 break;
2260 case MEP_OPERAND_SIMM8 :
2261 fields->f_8s8 = value;
2262 break;
2263 case MEP_OPERAND_SP :
2264 break;
2265 case MEP_OPERAND_SPR :
2266 break;
2267 case MEP_OPERAND_TP :
2268 break;
2269 case MEP_OPERAND_TPR :
2270 break;
2271 case MEP_OPERAND_UDISP2 :
2272 fields->f_2u6 = value;
2273 break;
2274 case MEP_OPERAND_UDISP7 :
2275 fields->f_7u9 = value;
2276 break;
2277 case MEP_OPERAND_UDISP7A2 :
2278 fields->f_7u9a2 = value;
2279 break;
2280 case MEP_OPERAND_UDISP7A4 :
2281 fields->f_7u9a4 = value;
2282 break;
2283 case MEP_OPERAND_UIMM16 :
2284 fields->f_16u16 = value;
2285 break;
2286 case MEP_OPERAND_UIMM2 :
2287 fields->f_2u10 = value;
2288 break;
2289 case MEP_OPERAND_UIMM24 :
2290 fields->f_24u8n = value;
2291 break;
2292 case MEP_OPERAND_UIMM3 :
2293 fields->f_3u5 = value;
2294 break;
2295 case MEP_OPERAND_UIMM4 :
2296 fields->f_4u8 = value;
2297 break;
2298 case MEP_OPERAND_UIMM5 :
2299 fields->f_5u8 = value;
2300 break;
2301 case MEP_OPERAND_UIMM7A4 :
2302 fields->f_7u9a4 = value;
2303 break;
2304 case MEP_OPERAND_ZERO :
2305 break;
2307 default :
2308 /* xgettext:c-format */
2309 fprintf (stderr, _("Unrecognized field %d while setting vma operand.\n"),
2310 opindex);
2311 abort ();
2315 /* Function to call before using the instruction builder tables. */
2317 void
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;