2009-06-12 Tristan Gingold <gingold@adacore.com>
[binutils.git] / opcodes / mep-ibld.c
blob05767bec7ebcf5acac15f0878a22893203734a71
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_C5RMUIMM20 :
585 FLD (f_c5_rm) = ((unsigned int) (FLD (f_c5_rmuimm20)) >> (16));
586 FLD (f_c5_16u16) = ((FLD (f_c5_rmuimm20)) & (65535));
588 errmsg = insert_normal (cd, fields->f_c5_rm, 0, 0, 8, 4, 32, total_length, buffer);
589 if (errmsg)
590 break;
591 errmsg = insert_normal (cd, fields->f_c5_16u16, 0, 0, 16, 16, 32, total_length, buffer);
592 if (errmsg)
593 break;
595 break;
596 case MEP_OPERAND_C5RNMUIMM24 :
599 FLD (f_c5_rnm) = ((unsigned int) (FLD (f_c5_rnmuimm24)) >> (16));
600 FLD (f_c5_16u16) = ((FLD (f_c5_rnmuimm24)) & (65535));
602 errmsg = insert_normal (cd, fields->f_c5_rnm, 0, 0, 4, 8, 32, total_length, buffer);
603 if (errmsg)
604 break;
605 errmsg = insert_normal (cd, fields->f_c5_16u16, 0, 0, 16, 16, 32, total_length, buffer);
606 if (errmsg)
607 break;
609 break;
610 case MEP_OPERAND_CALLNUM :
613 FLD (f_5) = ((((unsigned int) (FLD (f_callnum)) >> (3))) & (1));
614 FLD (f_6) = ((((unsigned int) (FLD (f_callnum)) >> (2))) & (1));
615 FLD (f_7) = ((((unsigned int) (FLD (f_callnum)) >> (1))) & (1));
616 FLD (f_11) = ((FLD (f_callnum)) & (1));
618 errmsg = insert_normal (cd, fields->f_5, 0, 0, 5, 1, 32, total_length, buffer);
619 if (errmsg)
620 break;
621 errmsg = insert_normal (cd, fields->f_6, 0, 0, 6, 1, 32, total_length, buffer);
622 if (errmsg)
623 break;
624 errmsg = insert_normal (cd, fields->f_7, 0, 0, 7, 1, 32, total_length, buffer);
625 if (errmsg)
626 break;
627 errmsg = insert_normal (cd, fields->f_11, 0, 0, 11, 1, 32, total_length, buffer);
628 if (errmsg)
629 break;
631 break;
632 case MEP_OPERAND_CCCC :
633 errmsg = insert_normal (cd, fields->f_rm, 0, 0, 8, 4, 32, total_length, buffer);
634 break;
635 case MEP_OPERAND_CCRN :
638 FLD (f_ccrn_hi) = ((((unsigned int) (FLD (f_ccrn)) >> (4))) & (3));
639 FLD (f_ccrn_lo) = ((FLD (f_ccrn)) & (15));
641 errmsg = insert_normal (cd, fields->f_ccrn_hi, 0, 0, 28, 2, 32, total_length, buffer);
642 if (errmsg)
643 break;
644 errmsg = insert_normal (cd, fields->f_ccrn_lo, 0, 0, 4, 4, 32, total_length, buffer);
645 if (errmsg)
646 break;
648 break;
649 case MEP_OPERAND_CDISP10 :
651 long value = fields->f_cdisp10;
652 value = (((((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value))) & (512))) ? (((((((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value))) & (1023))) - (1024))) : (((((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value))) & (1023)));
653 errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED), 0, 22, 10, 32, total_length, buffer);
655 break;
656 case MEP_OPERAND_CDISP10A2 :
658 long value = fields->f_cdisp10;
659 value = (((((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value))) & (512))) ? (((((((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value))) & (1023))) - (1024))) : (((((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value))) & (1023)));
660 errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED), 0, 22, 10, 32, total_length, buffer);
662 break;
663 case MEP_OPERAND_CDISP10A4 :
665 long value = fields->f_cdisp10;
666 value = (((((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value))) & (512))) ? (((((((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value))) & (1023))) - (1024))) : (((((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value))) & (1023)));
667 errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED), 0, 22, 10, 32, total_length, buffer);
669 break;
670 case MEP_OPERAND_CDISP10A8 :
672 long value = fields->f_cdisp10;
673 value = (((((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value))) & (512))) ? (((((((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value))) & (1023))) - (1024))) : (((((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value))) & (1023)));
674 errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED), 0, 22, 10, 32, total_length, buffer);
676 break;
677 case MEP_OPERAND_CDISP12 :
678 errmsg = insert_normal (cd, fields->f_12s20, 0|(1<<CGEN_IFLD_SIGNED), 0, 20, 12, 32, total_length, buffer);
679 break;
680 case MEP_OPERAND_CIMM4 :
681 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
682 break;
683 case MEP_OPERAND_CIMM5 :
684 errmsg = insert_normal (cd, fields->f_5u24, 0, 0, 24, 5, 32, total_length, buffer);
685 break;
686 case MEP_OPERAND_CODE16 :
687 errmsg = insert_normal (cd, fields->f_16u16, 0, 0, 16, 16, 32, total_length, buffer);
688 break;
689 case MEP_OPERAND_CODE24 :
692 FLD (f_24u4n_hi) = ((unsigned int) (FLD (f_24u4n)) >> (16));
693 FLD (f_24u4n_lo) = ((FLD (f_24u4n)) & (65535));
695 errmsg = insert_normal (cd, fields->f_24u4n_hi, 0, 0, 4, 8, 32, total_length, buffer);
696 if (errmsg)
697 break;
698 errmsg = insert_normal (cd, fields->f_24u4n_lo, 0, 0, 16, 16, 32, total_length, buffer);
699 if (errmsg)
700 break;
702 break;
703 case MEP_OPERAND_CP_FLAG :
704 break;
705 case MEP_OPERAND_CRN :
706 errmsg = insert_normal (cd, fields->f_crn, 0, 0, 4, 4, 32, total_length, buffer);
707 break;
708 case MEP_OPERAND_CRN64 :
709 errmsg = insert_normal (cd, fields->f_crn, 0, 0, 4, 4, 32, total_length, buffer);
710 break;
711 case MEP_OPERAND_CRNX :
714 FLD (f_crnx_lo) = ((FLD (f_crnx)) & (15));
715 FLD (f_crnx_hi) = ((unsigned int) (FLD (f_crnx)) >> (4));
717 errmsg = insert_normal (cd, fields->f_crnx_hi, 0, 0, 28, 1, 32, total_length, buffer);
718 if (errmsg)
719 break;
720 errmsg = insert_normal (cd, fields->f_crnx_lo, 0, 0, 4, 4, 32, total_length, buffer);
721 if (errmsg)
722 break;
724 break;
725 case MEP_OPERAND_CRNX64 :
728 FLD (f_crnx_lo) = ((FLD (f_crnx)) & (15));
729 FLD (f_crnx_hi) = ((unsigned int) (FLD (f_crnx)) >> (4));
731 errmsg = insert_normal (cd, fields->f_crnx_hi, 0, 0, 28, 1, 32, total_length, buffer);
732 if (errmsg)
733 break;
734 errmsg = insert_normal (cd, fields->f_crnx_lo, 0, 0, 4, 4, 32, total_length, buffer);
735 if (errmsg)
736 break;
738 break;
739 case MEP_OPERAND_CROC :
740 errmsg = insert_normal (cd, fields->f_ivc2_5u7, 0, 0, 7, 5, 32, total_length, buffer);
741 break;
742 case MEP_OPERAND_CROP :
743 errmsg = insert_normal (cd, fields->f_ivc2_5u23, 0, 0, 23, 5, 32, total_length, buffer);
744 break;
745 case MEP_OPERAND_CRPC :
746 errmsg = insert_normal (cd, fields->f_ivc2_5u26, 0, 0, 26, 5, 32, total_length, buffer);
747 break;
748 case MEP_OPERAND_CRPP :
749 errmsg = insert_normal (cd, fields->f_ivc2_5u18, 0, 0, 18, 5, 32, total_length, buffer);
750 break;
751 case MEP_OPERAND_CRQC :
752 errmsg = insert_normal (cd, fields->f_ivc2_5u21, 0, 0, 21, 5, 32, total_length, buffer);
753 break;
754 case MEP_OPERAND_CRQP :
755 errmsg = insert_normal (cd, fields->f_ivc2_5u13, 0, 0, 13, 5, 32, total_length, buffer);
756 break;
757 case MEP_OPERAND_CSRN :
760 FLD (f_csrn_lo) = ((FLD (f_csrn)) & (15));
761 FLD (f_csrn_hi) = ((unsigned int) (FLD (f_csrn)) >> (4));
763 errmsg = insert_normal (cd, fields->f_csrn_hi, 0, 0, 15, 1, 32, total_length, buffer);
764 if (errmsg)
765 break;
766 errmsg = insert_normal (cd, fields->f_csrn_lo, 0, 0, 8, 4, 32, total_length, buffer);
767 if (errmsg)
768 break;
770 break;
771 case MEP_OPERAND_CSRN_IDX :
774 FLD (f_csrn_lo) = ((FLD (f_csrn)) & (15));
775 FLD (f_csrn_hi) = ((unsigned int) (FLD (f_csrn)) >> (4));
777 errmsg = insert_normal (cd, fields->f_csrn_hi, 0, 0, 15, 1, 32, total_length, buffer);
778 if (errmsg)
779 break;
780 errmsg = insert_normal (cd, fields->f_csrn_lo, 0, 0, 8, 4, 32, total_length, buffer);
781 if (errmsg)
782 break;
784 break;
785 case MEP_OPERAND_DBG :
786 break;
787 case MEP_OPERAND_DEPC :
788 break;
789 case MEP_OPERAND_EPC :
790 break;
791 case MEP_OPERAND_EXC :
792 break;
793 case MEP_OPERAND_HI :
794 break;
795 case MEP_OPERAND_IMM16P0 :
798 FLD (f_ivc2_8u0) = ((((unsigned int) (FLD (f_ivc2_imm16p0)) >> (8))) & (255));
799 FLD (f_ivc2_8u20) = ((FLD (f_ivc2_imm16p0)) & (255));
801 errmsg = insert_normal (cd, fields->f_ivc2_8u0, 0, 0, 0, 8, 32, total_length, buffer);
802 if (errmsg)
803 break;
804 errmsg = insert_normal (cd, fields->f_ivc2_8u20, 0, 0, 20, 8, 32, total_length, buffer);
805 if (errmsg)
806 break;
808 break;
809 case MEP_OPERAND_IMM3P12 :
810 errmsg = insert_normal (cd, fields->f_ivc2_3u12, 0, 0, 12, 3, 32, total_length, buffer);
811 break;
812 case MEP_OPERAND_IMM3P25 :
813 errmsg = insert_normal (cd, fields->f_ivc2_3u25, 0, 0, 25, 3, 32, total_length, buffer);
814 break;
815 case MEP_OPERAND_IMM3P4 :
816 errmsg = insert_normal (cd, fields->f_ivc2_3u4, 0, 0, 4, 3, 32, total_length, buffer);
817 break;
818 case MEP_OPERAND_IMM3P5 :
819 errmsg = insert_normal (cd, fields->f_ivc2_3u5, 0, 0, 5, 3, 32, total_length, buffer);
820 break;
821 case MEP_OPERAND_IMM3P9 :
822 errmsg = insert_normal (cd, fields->f_ivc2_3u9, 0, 0, 9, 3, 32, total_length, buffer);
823 break;
824 case MEP_OPERAND_IMM4P10 :
825 errmsg = insert_normal (cd, fields->f_ivc2_4u10, 0, 0, 10, 4, 32, total_length, buffer);
826 break;
827 case MEP_OPERAND_IMM4P4 :
828 errmsg = insert_normal (cd, fields->f_ivc2_4u4, 0, 0, 4, 4, 32, total_length, buffer);
829 break;
830 case MEP_OPERAND_IMM4P8 :
831 errmsg = insert_normal (cd, fields->f_ivc2_4u8, 0, 0, 8, 4, 32, total_length, buffer);
832 break;
833 case MEP_OPERAND_IMM5P23 :
834 errmsg = insert_normal (cd, fields->f_ivc2_5u23, 0, 0, 23, 5, 32, total_length, buffer);
835 break;
836 case MEP_OPERAND_IMM5P3 :
837 errmsg = insert_normal (cd, fields->f_ivc2_5u3, 0, 0, 3, 5, 32, total_length, buffer);
838 break;
839 case MEP_OPERAND_IMM5P7 :
840 errmsg = insert_normal (cd, fields->f_ivc2_5u7, 0, 0, 7, 5, 32, total_length, buffer);
841 break;
842 case MEP_OPERAND_IMM5P8 :
843 errmsg = insert_normal (cd, fields->f_ivc2_5u8, 0, 0, 8, 5, 32, total_length, buffer);
844 break;
845 case MEP_OPERAND_IMM6P2 :
846 errmsg = insert_normal (cd, fields->f_ivc2_6u2, 0, 0, 2, 6, 32, total_length, buffer);
847 break;
848 case MEP_OPERAND_IMM6P6 :
849 errmsg = insert_normal (cd, fields->f_ivc2_6u6, 0, 0, 6, 6, 32, total_length, buffer);
850 break;
851 case MEP_OPERAND_IMM8P0 :
852 errmsg = insert_normal (cd, fields->f_ivc2_8u0, 0, 0, 0, 8, 32, total_length, buffer);
853 break;
854 case MEP_OPERAND_IMM8P20 :
855 errmsg = insert_normal (cd, fields->f_ivc2_8u20, 0, 0, 20, 8, 32, total_length, buffer);
856 break;
857 case MEP_OPERAND_IMM8P4 :
858 errmsg = insert_normal (cd, fields->f_ivc2_8u4, 0, 0, 4, 8, 32, total_length, buffer);
859 break;
860 case MEP_OPERAND_IVC_X_0_2 :
861 errmsg = insert_normal (cd, fields->f_ivc2_2u0, 0, 0, 0, 2, 32, total_length, buffer);
862 break;
863 case MEP_OPERAND_IVC_X_0_3 :
864 errmsg = insert_normal (cd, fields->f_ivc2_3u0, 0, 0, 0, 3, 32, total_length, buffer);
865 break;
866 case MEP_OPERAND_IVC_X_0_4 :
867 errmsg = insert_normal (cd, fields->f_ivc2_4u0, 0, 0, 0, 4, 32, total_length, buffer);
868 break;
869 case MEP_OPERAND_IVC_X_0_5 :
870 errmsg = insert_normal (cd, fields->f_ivc2_5u0, 0, 0, 0, 5, 32, total_length, buffer);
871 break;
872 case MEP_OPERAND_IVC_X_6_1 :
873 errmsg = insert_normal (cd, fields->f_ivc2_1u6, 0, 0, 6, 1, 32, total_length, buffer);
874 break;
875 case MEP_OPERAND_IVC_X_6_2 :
876 errmsg = insert_normal (cd, fields->f_ivc2_2u6, 0, 0, 6, 2, 32, total_length, buffer);
877 break;
878 case MEP_OPERAND_IVC_X_6_3 :
879 errmsg = insert_normal (cd, fields->f_ivc2_3u6, 0, 0, 6, 3, 32, total_length, buffer);
880 break;
881 case MEP_OPERAND_IVC2C3CCRN :
884 FLD (f_ivc2_ccrn_c3hi) = ((((unsigned int) (FLD (f_ivc2_ccrn_c3)) >> (4))) & (3));
885 FLD (f_ivc2_ccrn_c3lo) = ((FLD (f_ivc2_ccrn_c3)) & (15));
887 errmsg = insert_normal (cd, fields->f_ivc2_ccrn_c3hi, 0, 0, 28, 2, 32, total_length, buffer);
888 if (errmsg)
889 break;
890 errmsg = insert_normal (cd, fields->f_ivc2_ccrn_c3lo, 0, 0, 4, 4, 32, total_length, buffer);
891 if (errmsg)
892 break;
894 break;
895 case MEP_OPERAND_IVC2CCRN :
898 FLD (f_ivc2_ccrn_h2) = ((((unsigned int) (FLD (f_ivc2_ccrn)) >> (4))) & (3));
899 FLD (f_ivc2_ccrn_lo) = ((FLD (f_ivc2_ccrn)) & (15));
901 errmsg = insert_normal (cd, fields->f_ivc2_ccrn_h2, 0, 0, 20, 2, 32, total_length, buffer);
902 if (errmsg)
903 break;
904 errmsg = insert_normal (cd, fields->f_ivc2_ccrn_lo, 0, 0, 0, 4, 32, total_length, buffer);
905 if (errmsg)
906 break;
908 break;
909 case MEP_OPERAND_IVC2CRN :
912 FLD (f_ivc2_ccrn_h1) = ((((unsigned int) (FLD (f_ivc2_crnx)) >> (4))) & (1));
913 FLD (f_ivc2_ccrn_lo) = ((FLD (f_ivc2_crnx)) & (15));
915 errmsg = insert_normal (cd, fields->f_ivc2_ccrn_h1, 0, 0, 20, 1, 32, total_length, buffer);
916 if (errmsg)
917 break;
918 errmsg = insert_normal (cd, fields->f_ivc2_ccrn_lo, 0, 0, 0, 4, 32, total_length, buffer);
919 if (errmsg)
920 break;
922 break;
923 case MEP_OPERAND_IVC2RM :
924 errmsg = insert_normal (cd, fields->f_ivc2_crm, 0, 0, 4, 4, 32, total_length, buffer);
925 break;
926 case MEP_OPERAND_LO :
927 break;
928 case MEP_OPERAND_LP :
929 break;
930 case MEP_OPERAND_MB0 :
931 break;
932 case MEP_OPERAND_MB1 :
933 break;
934 case MEP_OPERAND_ME0 :
935 break;
936 case MEP_OPERAND_ME1 :
937 break;
938 case MEP_OPERAND_NPC :
939 break;
940 case MEP_OPERAND_OPT :
941 break;
942 case MEP_OPERAND_PCABS24A2 :
945 FLD (f_24u5a2n_lo) = ((unsigned int) (((FLD (f_24u5a2n)) & (255))) >> (1));
946 FLD (f_24u5a2n_hi) = ((unsigned int) (FLD (f_24u5a2n)) >> (8));
948 errmsg = insert_normal (cd, fields->f_24u5a2n_hi, 0, 0, 16, 16, 32, total_length, buffer);
949 if (errmsg)
950 break;
951 errmsg = insert_normal (cd, fields->f_24u5a2n_lo, 0, 0, 5, 7, 32, total_length, buffer);
952 if (errmsg)
953 break;
955 break;
956 case MEP_OPERAND_PCREL12A2 :
958 long value = fields->f_12s4a2;
959 value = ((int) (((value) - (pc))) >> (1));
960 errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 4, 11, 32, total_length, buffer);
962 break;
963 case MEP_OPERAND_PCREL17A2 :
965 long value = fields->f_17s16a2;
966 value = ((int) (((value) - (pc))) >> (1));
967 errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 16, 16, 32, total_length, buffer);
969 break;
970 case MEP_OPERAND_PCREL24A2 :
973 FLD (f_24s5a2n) = ((FLD (f_24s5a2n)) - (pc));
974 FLD (f_24s5a2n_lo) = ((unsigned int) (((FLD (f_24s5a2n)) & (254))) >> (1));
975 FLD (f_24s5a2n_hi) = ((int) (FLD (f_24s5a2n)) >> (8));
977 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);
978 if (errmsg)
979 break;
980 errmsg = insert_normal (cd, fields->f_24s5a2n_lo, 0|(1<<CGEN_IFLD_PCREL_ADDR), 0, 5, 7, 32, total_length, buffer);
981 if (errmsg)
982 break;
984 break;
985 case MEP_OPERAND_PCREL8A2 :
987 long value = fields->f_8s8a2;
988 value = ((int) (((value) - (pc))) >> (1));
989 errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 8, 7, 32, total_length, buffer);
991 break;
992 case MEP_OPERAND_PSW :
993 break;
994 case MEP_OPERAND_R0 :
995 break;
996 case MEP_OPERAND_R1 :
997 break;
998 case MEP_OPERAND_RL :
999 errmsg = insert_normal (cd, fields->f_rl, 0, 0, 12, 4, 32, total_length, buffer);
1000 break;
1001 case MEP_OPERAND_RL5 :
1002 errmsg = insert_normal (cd, fields->f_rl5, 0, 0, 20, 4, 32, total_length, buffer);
1003 break;
1004 case MEP_OPERAND_RM :
1005 errmsg = insert_normal (cd, fields->f_rm, 0, 0, 8, 4, 32, total_length, buffer);
1006 break;
1007 case MEP_OPERAND_RMA :
1008 errmsg = insert_normal (cd, fields->f_rm, 0, 0, 8, 4, 32, total_length, buffer);
1009 break;
1010 case MEP_OPERAND_RN :
1011 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
1012 break;
1013 case MEP_OPERAND_RN3 :
1014 errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
1015 break;
1016 case MEP_OPERAND_RN3C :
1017 errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
1018 break;
1019 case MEP_OPERAND_RN3L :
1020 errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
1021 break;
1022 case MEP_OPERAND_RN3S :
1023 errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
1024 break;
1025 case MEP_OPERAND_RN3UC :
1026 errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
1027 break;
1028 case MEP_OPERAND_RN3UL :
1029 errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
1030 break;
1031 case MEP_OPERAND_RN3US :
1032 errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
1033 break;
1034 case MEP_OPERAND_RNC :
1035 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
1036 break;
1037 case MEP_OPERAND_RNL :
1038 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
1039 break;
1040 case MEP_OPERAND_RNS :
1041 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
1042 break;
1043 case MEP_OPERAND_RNUC :
1044 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
1045 break;
1046 case MEP_OPERAND_RNUL :
1047 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
1048 break;
1049 case MEP_OPERAND_RNUS :
1050 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
1051 break;
1052 case MEP_OPERAND_SAR :
1053 break;
1054 case MEP_OPERAND_SDISP16 :
1055 errmsg = insert_normal (cd, fields->f_16s16, 0|(1<<CGEN_IFLD_SIGNED), 0, 16, 16, 32, total_length, buffer);
1056 break;
1057 case MEP_OPERAND_SIMM16 :
1058 errmsg = insert_normal (cd, fields->f_16s16, 0|(1<<CGEN_IFLD_SIGNED), 0, 16, 16, 32, total_length, buffer);
1059 break;
1060 case MEP_OPERAND_SIMM16P0 :
1063 FLD (f_ivc2_8u0) = ((((unsigned int) (FLD (f_ivc2_simm16p0)) >> (8))) & (255));
1064 FLD (f_ivc2_8u20) = ((FLD (f_ivc2_simm16p0)) & (255));
1066 errmsg = insert_normal (cd, fields->f_ivc2_8u0, 0, 0, 0, 8, 32, total_length, buffer);
1067 if (errmsg)
1068 break;
1069 errmsg = insert_normal (cd, fields->f_ivc2_8u20, 0, 0, 20, 8, 32, total_length, buffer);
1070 if (errmsg)
1071 break;
1073 break;
1074 case MEP_OPERAND_SIMM6 :
1075 errmsg = insert_normal (cd, fields->f_6s8, 0|(1<<CGEN_IFLD_SIGNED), 0, 8, 6, 32, total_length, buffer);
1076 break;
1077 case MEP_OPERAND_SIMM8 :
1078 errmsg = insert_normal (cd, fields->f_8s8, 0|(1<<CGEN_IFLD_SIGNED), 0, 8, 8, 32, total_length, buffer);
1079 break;
1080 case MEP_OPERAND_SIMM8P0 :
1081 errmsg = insert_normal (cd, fields->f_ivc2_8s0, 0|(1<<CGEN_IFLD_SIGNED), 0, 0, 8, 32, total_length, buffer);
1082 break;
1083 case MEP_OPERAND_SIMM8P20 :
1084 errmsg = insert_normal (cd, fields->f_ivc2_8s20, 0|(1<<CGEN_IFLD_SIGNED), 0, 20, 8, 32, total_length, buffer);
1085 break;
1086 case MEP_OPERAND_SIMM8P4 :
1087 errmsg = insert_normal (cd, fields->f_ivc2_8s4, 0|(1<<CGEN_IFLD_SIGNED), 0, 4, 8, 32, total_length, buffer);
1088 break;
1089 case MEP_OPERAND_SP :
1090 break;
1091 case MEP_OPERAND_SPR :
1092 break;
1093 case MEP_OPERAND_TP :
1094 break;
1095 case MEP_OPERAND_TPR :
1096 break;
1097 case MEP_OPERAND_UDISP2 :
1098 errmsg = insert_normal (cd, fields->f_2u6, 0, 0, 6, 2, 32, total_length, buffer);
1099 break;
1100 case MEP_OPERAND_UDISP7 :
1101 errmsg = insert_normal (cd, fields->f_7u9, 0, 0, 9, 7, 32, total_length, buffer);
1102 break;
1103 case MEP_OPERAND_UDISP7A2 :
1105 long value = fields->f_7u9a2;
1106 value = ((unsigned int) (value) >> (1));
1107 errmsg = insert_normal (cd, value, 0, 0, 9, 6, 32, total_length, buffer);
1109 break;
1110 case MEP_OPERAND_UDISP7A4 :
1112 long value = fields->f_7u9a4;
1113 value = ((unsigned int) (value) >> (2));
1114 errmsg = insert_normal (cd, value, 0, 0, 9, 5, 32, total_length, buffer);
1116 break;
1117 case MEP_OPERAND_UIMM16 :
1118 errmsg = insert_normal (cd, fields->f_16u16, 0, 0, 16, 16, 32, total_length, buffer);
1119 break;
1120 case MEP_OPERAND_UIMM2 :
1121 errmsg = insert_normal (cd, fields->f_2u10, 0, 0, 10, 2, 32, total_length, buffer);
1122 break;
1123 case MEP_OPERAND_UIMM24 :
1126 FLD (f_24u8n_hi) = ((unsigned int) (FLD (f_24u8n)) >> (8));
1127 FLD (f_24u8n_lo) = ((FLD (f_24u8n)) & (255));
1129 errmsg = insert_normal (cd, fields->f_24u8n_hi, 0, 0, 16, 16, 32, total_length, buffer);
1130 if (errmsg)
1131 break;
1132 errmsg = insert_normal (cd, fields->f_24u8n_lo, 0, 0, 8, 8, 32, total_length, buffer);
1133 if (errmsg)
1134 break;
1136 break;
1137 case MEP_OPERAND_UIMM3 :
1138 errmsg = insert_normal (cd, fields->f_3u5, 0, 0, 5, 3, 32, total_length, buffer);
1139 break;
1140 case MEP_OPERAND_UIMM4 :
1141 errmsg = insert_normal (cd, fields->f_4u8, 0, 0, 8, 4, 32, total_length, buffer);
1142 break;
1143 case MEP_OPERAND_UIMM5 :
1144 errmsg = insert_normal (cd, fields->f_5u8, 0, 0, 8, 5, 32, total_length, buffer);
1145 break;
1146 case MEP_OPERAND_UIMM7A4 :
1148 long value = fields->f_7u9a4;
1149 value = ((unsigned int) (value) >> (2));
1150 errmsg = insert_normal (cd, value, 0, 0, 9, 5, 32, total_length, buffer);
1152 break;
1153 case MEP_OPERAND_ZERO :
1154 break;
1156 default :
1157 /* xgettext:c-format */
1158 fprintf (stderr, _("Unrecognized field %d while building insn.\n"),
1159 opindex);
1160 abort ();
1163 return errmsg;
1166 int mep_cgen_extract_operand
1167 (CGEN_CPU_DESC, int, CGEN_EXTRACT_INFO *, CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma);
1169 /* Main entry point for operand extraction.
1170 The result is <= 0 for error, >0 for success.
1171 ??? Actual values aren't well defined right now.
1173 This function is basically just a big switch statement. Earlier versions
1174 used tables to look up the function to use, but
1175 - if the table contains both assembler and disassembler functions then
1176 the disassembler contains much of the assembler and vice-versa,
1177 - there's a lot of inlining possibilities as things grow,
1178 - using a switch statement avoids the function call overhead.
1180 This function could be moved into `print_insn_normal', but keeping it
1181 separate makes clear the interface between `print_insn_normal' and each of
1182 the handlers. */
1185 mep_cgen_extract_operand (CGEN_CPU_DESC cd,
1186 int opindex,
1187 CGEN_EXTRACT_INFO *ex_info,
1188 CGEN_INSN_INT insn_value,
1189 CGEN_FIELDS * fields,
1190 bfd_vma pc)
1192 /* Assume success (for those operands that are nops). */
1193 int length = 1;
1194 unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
1196 switch (opindex)
1198 case MEP_OPERAND_ADDR24A4 :
1200 length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_24u8a4n_hi);
1201 if (length <= 0) break;
1202 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 6, 32, total_length, pc, & fields->f_24u8a4n_lo);
1203 if (length <= 0) break;
1204 FLD (f_24u8a4n) = ((((FLD (f_24u8a4n_hi)) << (8))) | (((FLD (f_24u8a4n_lo)) << (2))));
1206 break;
1207 case MEP_OPERAND_C5RMUIMM20 :
1209 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_c5_rm);
1210 if (length <= 0) break;
1211 length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_c5_16u16);
1212 if (length <= 0) break;
1214 FLD (f_c5_rmuimm20) = ((FLD (f_c5_16u16)) | (((FLD (f_c5_rm)) << (16))));
1217 break;
1218 case MEP_OPERAND_C5RNMUIMM24 :
1220 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 8, 32, total_length, pc, & fields->f_c5_rnm);
1221 if (length <= 0) break;
1222 length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_c5_16u16);
1223 if (length <= 0) break;
1225 FLD (f_c5_rnmuimm24) = ((FLD (f_c5_16u16)) | (((FLD (f_c5_rnm)) << (16))));
1228 break;
1229 case MEP_OPERAND_CALLNUM :
1231 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 1, 32, total_length, pc, & fields->f_5);
1232 if (length <= 0) break;
1233 length = extract_normal (cd, ex_info, insn_value, 0, 0, 6, 1, 32, total_length, pc, & fields->f_6);
1234 if (length <= 0) break;
1235 length = extract_normal (cd, ex_info, insn_value, 0, 0, 7, 1, 32, total_length, pc, & fields->f_7);
1236 if (length <= 0) break;
1237 length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 1, 32, total_length, pc, & fields->f_11);
1238 if (length <= 0) break;
1239 FLD (f_callnum) = ((((FLD (f_5)) << (3))) | (((((FLD (f_6)) << (2))) | (((((FLD (f_7)) << (1))) | (FLD (f_11)))))));
1241 break;
1242 case MEP_OPERAND_CCCC :
1243 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_rm);
1244 break;
1245 case MEP_OPERAND_CCRN :
1247 length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 2, 32, total_length, pc, & fields->f_ccrn_hi);
1248 if (length <= 0) break;
1249 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_ccrn_lo);
1250 if (length <= 0) break;
1251 FLD (f_ccrn) = ((((FLD (f_ccrn_hi)) << (4))) | (FLD (f_ccrn_lo)));
1253 break;
1254 case MEP_OPERAND_CDISP10 :
1256 long value;
1257 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 22, 10, 32, total_length, pc, & value);
1258 value = (((((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value))) & (512))) ? (((((((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value))) & (1023))) - (1024))) : (((((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value))) & (1023)));
1259 fields->f_cdisp10 = value;
1261 break;
1262 case MEP_OPERAND_CDISP10A2 :
1264 long value;
1265 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 22, 10, 32, total_length, pc, & value);
1266 value = (((((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value))) & (512))) ? (((((((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value))) & (1023))) - (1024))) : (((((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value))) & (1023)));
1267 fields->f_cdisp10 = value;
1269 break;
1270 case MEP_OPERAND_CDISP10A4 :
1272 long value;
1273 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 22, 10, 32, total_length, pc, & value);
1274 value = (((((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value))) & (512))) ? (((((((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value))) & (1023))) - (1024))) : (((((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value))) & (1023)));
1275 fields->f_cdisp10 = value;
1277 break;
1278 case MEP_OPERAND_CDISP10A8 :
1280 long value;
1281 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 22, 10, 32, total_length, pc, & value);
1282 value = (((((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value))) & (512))) ? (((((((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value))) & (1023))) - (1024))) : (((((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value))) & (1023)));
1283 fields->f_cdisp10 = value;
1285 break;
1286 case MEP_OPERAND_CDISP12 :
1287 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 20, 12, 32, total_length, pc, & fields->f_12s20);
1288 break;
1289 case MEP_OPERAND_CIMM4 :
1290 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1291 break;
1292 case MEP_OPERAND_CIMM5 :
1293 length = extract_normal (cd, ex_info, insn_value, 0, 0, 24, 5, 32, total_length, pc, & fields->f_5u24);
1294 break;
1295 case MEP_OPERAND_CODE16 :
1296 length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_16u16);
1297 break;
1298 case MEP_OPERAND_CODE24 :
1300 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 8, 32, total_length, pc, & fields->f_24u4n_hi);
1301 if (length <= 0) break;
1302 length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_24u4n_lo);
1303 if (length <= 0) break;
1304 FLD (f_24u4n) = ((((FLD (f_24u4n_hi)) << (16))) | (FLD (f_24u4n_lo)));
1306 break;
1307 case MEP_OPERAND_CP_FLAG :
1308 break;
1309 case MEP_OPERAND_CRN :
1310 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_crn);
1311 break;
1312 case MEP_OPERAND_CRN64 :
1313 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_crn);
1314 break;
1315 case MEP_OPERAND_CRNX :
1317 length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 1, 32, total_length, pc, & fields->f_crnx_hi);
1318 if (length <= 0) break;
1319 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_crnx_lo);
1320 if (length <= 0) break;
1321 FLD (f_crnx) = ((((FLD (f_crnx_hi)) << (4))) | (FLD (f_crnx_lo)));
1323 break;
1324 case MEP_OPERAND_CRNX64 :
1326 length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 1, 32, total_length, pc, & fields->f_crnx_hi);
1327 if (length <= 0) break;
1328 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_crnx_lo);
1329 if (length <= 0) break;
1330 FLD (f_crnx) = ((((FLD (f_crnx_hi)) << (4))) | (FLD (f_crnx_lo)));
1332 break;
1333 case MEP_OPERAND_CROC :
1334 length = extract_normal (cd, ex_info, insn_value, 0, 0, 7, 5, 32, total_length, pc, & fields->f_ivc2_5u7);
1335 break;
1336 case MEP_OPERAND_CROP :
1337 length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 5, 32, total_length, pc, & fields->f_ivc2_5u23);
1338 break;
1339 case MEP_OPERAND_CRPC :
1340 length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 5, 32, total_length, pc, & fields->f_ivc2_5u26);
1341 break;
1342 case MEP_OPERAND_CRPP :
1343 length = extract_normal (cd, ex_info, insn_value, 0, 0, 18, 5, 32, total_length, pc, & fields->f_ivc2_5u18);
1344 break;
1345 case MEP_OPERAND_CRQC :
1346 length = extract_normal (cd, ex_info, insn_value, 0, 0, 21, 5, 32, total_length, pc, & fields->f_ivc2_5u21);
1347 break;
1348 case MEP_OPERAND_CRQP :
1349 length = extract_normal (cd, ex_info, insn_value, 0, 0, 13, 5, 32, total_length, pc, & fields->f_ivc2_5u13);
1350 break;
1351 case MEP_OPERAND_CSRN :
1353 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 1, 32, total_length, pc, & fields->f_csrn_hi);
1354 if (length <= 0) break;
1355 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_csrn_lo);
1356 if (length <= 0) break;
1357 FLD (f_csrn) = ((((FLD (f_csrn_hi)) << (4))) | (FLD (f_csrn_lo)));
1359 break;
1360 case MEP_OPERAND_CSRN_IDX :
1362 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 1, 32, total_length, pc, & fields->f_csrn_hi);
1363 if (length <= 0) break;
1364 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_csrn_lo);
1365 if (length <= 0) break;
1366 FLD (f_csrn) = ((((FLD (f_csrn_hi)) << (4))) | (FLD (f_csrn_lo)));
1368 break;
1369 case MEP_OPERAND_DBG :
1370 break;
1371 case MEP_OPERAND_DEPC :
1372 break;
1373 case MEP_OPERAND_EPC :
1374 break;
1375 case MEP_OPERAND_EXC :
1376 break;
1377 case MEP_OPERAND_HI :
1378 break;
1379 case MEP_OPERAND_IMM16P0 :
1381 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 8, 32, total_length, pc, & fields->f_ivc2_8u0);
1382 if (length <= 0) break;
1383 length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 8, 32, total_length, pc, & fields->f_ivc2_8u20);
1384 if (length <= 0) break;
1386 FLD (f_ivc2_imm16p0) = ((FLD (f_ivc2_8u20)) | (((FLD (f_ivc2_8u0)) << (8))));
1389 break;
1390 case MEP_OPERAND_IMM3P12 :
1391 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_ivc2_3u12);
1392 break;
1393 case MEP_OPERAND_IMM3P25 :
1394 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 3, 32, total_length, pc, & fields->f_ivc2_3u25);
1395 break;
1396 case MEP_OPERAND_IMM3P4 :
1397 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 3, 32, total_length, pc, & fields->f_ivc2_3u4);
1398 break;
1399 case MEP_OPERAND_IMM3P5 :
1400 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_ivc2_3u5);
1401 break;
1402 case MEP_OPERAND_IMM3P9 :
1403 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_ivc2_3u9);
1404 break;
1405 case MEP_OPERAND_IMM4P10 :
1406 length = extract_normal (cd, ex_info, insn_value, 0, 0, 10, 4, 32, total_length, pc, & fields->f_ivc2_4u10);
1407 break;
1408 case MEP_OPERAND_IMM4P4 :
1409 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_ivc2_4u4);
1410 break;
1411 case MEP_OPERAND_IMM4P8 :
1412 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_ivc2_4u8);
1413 break;
1414 case MEP_OPERAND_IMM5P23 :
1415 length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 5, 32, total_length, pc, & fields->f_ivc2_5u23);
1416 break;
1417 case MEP_OPERAND_IMM5P3 :
1418 length = extract_normal (cd, ex_info, insn_value, 0, 0, 3, 5, 32, total_length, pc, & fields->f_ivc2_5u3);
1419 break;
1420 case MEP_OPERAND_IMM5P7 :
1421 length = extract_normal (cd, ex_info, insn_value, 0, 0, 7, 5, 32, total_length, pc, & fields->f_ivc2_5u7);
1422 break;
1423 case MEP_OPERAND_IMM5P8 :
1424 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 5, 32, total_length, pc, & fields->f_ivc2_5u8);
1425 break;
1426 case MEP_OPERAND_IMM6P2 :
1427 length = extract_normal (cd, ex_info, insn_value, 0, 0, 2, 6, 32, total_length, pc, & fields->f_ivc2_6u2);
1428 break;
1429 case MEP_OPERAND_IMM6P6 :
1430 length = extract_normal (cd, ex_info, insn_value, 0, 0, 6, 6, 32, total_length, pc, & fields->f_ivc2_6u6);
1431 break;
1432 case MEP_OPERAND_IMM8P0 :
1433 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 8, 32, total_length, pc, & fields->f_ivc2_8u0);
1434 break;
1435 case MEP_OPERAND_IMM8P20 :
1436 length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 8, 32, total_length, pc, & fields->f_ivc2_8u20);
1437 break;
1438 case MEP_OPERAND_IMM8P4 :
1439 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 8, 32, total_length, pc, & fields->f_ivc2_8u4);
1440 break;
1441 case MEP_OPERAND_IVC_X_0_2 :
1442 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 2, 32, total_length, pc, & fields->f_ivc2_2u0);
1443 break;
1444 case MEP_OPERAND_IVC_X_0_3 :
1445 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 3, 32, total_length, pc, & fields->f_ivc2_3u0);
1446 break;
1447 case MEP_OPERAND_IVC_X_0_4 :
1448 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 4, 32, total_length, pc, & fields->f_ivc2_4u0);
1449 break;
1450 case MEP_OPERAND_IVC_X_0_5 :
1451 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 5, 32, total_length, pc, & fields->f_ivc2_5u0);
1452 break;
1453 case MEP_OPERAND_IVC_X_6_1 :
1454 length = extract_normal (cd, ex_info, insn_value, 0, 0, 6, 1, 32, total_length, pc, & fields->f_ivc2_1u6);
1455 break;
1456 case MEP_OPERAND_IVC_X_6_2 :
1457 length = extract_normal (cd, ex_info, insn_value, 0, 0, 6, 2, 32, total_length, pc, & fields->f_ivc2_2u6);
1458 break;
1459 case MEP_OPERAND_IVC_X_6_3 :
1460 length = extract_normal (cd, ex_info, insn_value, 0, 0, 6, 3, 32, total_length, pc, & fields->f_ivc2_3u6);
1461 break;
1462 case MEP_OPERAND_IVC2C3CCRN :
1464 length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 2, 32, total_length, pc, & fields->f_ivc2_ccrn_c3hi);
1465 if (length <= 0) break;
1466 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_ivc2_ccrn_c3lo);
1467 if (length <= 0) break;
1468 FLD (f_ivc2_ccrn_c3) = ((((FLD (f_ivc2_ccrn_c3hi)) << (4))) | (FLD (f_ivc2_ccrn_c3lo)));
1470 break;
1471 case MEP_OPERAND_IVC2CCRN :
1473 length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 2, 32, total_length, pc, & fields->f_ivc2_ccrn_h2);
1474 if (length <= 0) break;
1475 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 4, 32, total_length, pc, & fields->f_ivc2_ccrn_lo);
1476 if (length <= 0) break;
1477 FLD (f_ivc2_ccrn) = ((((FLD (f_ivc2_ccrn_h2)) << (4))) | (FLD (f_ivc2_ccrn_lo)));
1479 break;
1480 case MEP_OPERAND_IVC2CRN :
1482 length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 1, 32, total_length, pc, & fields->f_ivc2_ccrn_h1);
1483 if (length <= 0) break;
1484 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 4, 32, total_length, pc, & fields->f_ivc2_ccrn_lo);
1485 if (length <= 0) break;
1486 FLD (f_ivc2_crnx) = ((((FLD (f_ivc2_ccrn_h1)) << (4))) | (FLD (f_ivc2_ccrn_lo)));
1488 break;
1489 case MEP_OPERAND_IVC2RM :
1490 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_ivc2_crm);
1491 break;
1492 case MEP_OPERAND_LO :
1493 break;
1494 case MEP_OPERAND_LP :
1495 break;
1496 case MEP_OPERAND_MB0 :
1497 break;
1498 case MEP_OPERAND_MB1 :
1499 break;
1500 case MEP_OPERAND_ME0 :
1501 break;
1502 case MEP_OPERAND_ME1 :
1503 break;
1504 case MEP_OPERAND_NPC :
1505 break;
1506 case MEP_OPERAND_OPT :
1507 break;
1508 case MEP_OPERAND_PCABS24A2 :
1510 length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_24u5a2n_hi);
1511 if (length <= 0) break;
1512 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 7, 32, total_length, pc, & fields->f_24u5a2n_lo);
1513 if (length <= 0) break;
1514 FLD (f_24u5a2n) = ((((FLD (f_24u5a2n_hi)) << (8))) | (((FLD (f_24u5a2n_lo)) << (1))));
1516 break;
1517 case MEP_OPERAND_PCREL12A2 :
1519 long value;
1520 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);
1521 value = ((((value) << (1))) + (pc));
1522 fields->f_12s4a2 = value;
1524 break;
1525 case MEP_OPERAND_PCREL17A2 :
1527 long value;
1528 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);
1529 value = ((((value) << (1))) + (pc));
1530 fields->f_17s16a2 = value;
1532 break;
1533 case MEP_OPERAND_PCREL24A2 :
1535 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);
1536 if (length <= 0) break;
1537 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);
1538 if (length <= 0) break;
1539 FLD (f_24s5a2n) = ((((((FLD (f_24s5a2n_hi)) << (8))) | (((FLD (f_24s5a2n_lo)) << (1))))) + (pc));
1541 break;
1542 case MEP_OPERAND_PCREL8A2 :
1544 long value;
1545 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);
1546 value = ((((value) << (1))) + (pc));
1547 fields->f_8s8a2 = value;
1549 break;
1550 case MEP_OPERAND_PSW :
1551 break;
1552 case MEP_OPERAND_R0 :
1553 break;
1554 case MEP_OPERAND_R1 :
1555 break;
1556 case MEP_OPERAND_RL :
1557 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 4, 32, total_length, pc, & fields->f_rl);
1558 break;
1559 case MEP_OPERAND_RL5 :
1560 length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 4, 32, total_length, pc, & fields->f_rl5);
1561 break;
1562 case MEP_OPERAND_RM :
1563 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_rm);
1564 break;
1565 case MEP_OPERAND_RMA :
1566 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_rm);
1567 break;
1568 case MEP_OPERAND_RN :
1569 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1570 break;
1571 case MEP_OPERAND_RN3 :
1572 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1573 break;
1574 case MEP_OPERAND_RN3C :
1575 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1576 break;
1577 case MEP_OPERAND_RN3L :
1578 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1579 break;
1580 case MEP_OPERAND_RN3S :
1581 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1582 break;
1583 case MEP_OPERAND_RN3UC :
1584 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1585 break;
1586 case MEP_OPERAND_RN3UL :
1587 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1588 break;
1589 case MEP_OPERAND_RN3US :
1590 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1591 break;
1592 case MEP_OPERAND_RNC :
1593 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1594 break;
1595 case MEP_OPERAND_RNL :
1596 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1597 break;
1598 case MEP_OPERAND_RNS :
1599 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1600 break;
1601 case MEP_OPERAND_RNUC :
1602 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1603 break;
1604 case MEP_OPERAND_RNUL :
1605 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1606 break;
1607 case MEP_OPERAND_RNUS :
1608 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1609 break;
1610 case MEP_OPERAND_SAR :
1611 break;
1612 case MEP_OPERAND_SDISP16 :
1613 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 16, 16, 32, total_length, pc, & fields->f_16s16);
1614 break;
1615 case MEP_OPERAND_SIMM16 :
1616 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 16, 16, 32, total_length, pc, & fields->f_16s16);
1617 break;
1618 case MEP_OPERAND_SIMM16P0 :
1620 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 8, 32, total_length, pc, & fields->f_ivc2_8u0);
1621 if (length <= 0) break;
1622 length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 8, 32, total_length, pc, & fields->f_ivc2_8u20);
1623 if (length <= 0) break;
1625 FLD (f_ivc2_simm16p0) = ((FLD (f_ivc2_8u20)) | (((FLD (f_ivc2_8u0)) << (8))));
1628 break;
1629 case MEP_OPERAND_SIMM6 :
1630 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 8, 6, 32, total_length, pc, & fields->f_6s8);
1631 break;
1632 case MEP_OPERAND_SIMM8 :
1633 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 8, 8, 32, total_length, pc, & fields->f_8s8);
1634 break;
1635 case MEP_OPERAND_SIMM8P0 :
1636 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 0, 8, 32, total_length, pc, & fields->f_ivc2_8s0);
1637 break;
1638 case MEP_OPERAND_SIMM8P20 :
1639 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 20, 8, 32, total_length, pc, & fields->f_ivc2_8s20);
1640 break;
1641 case MEP_OPERAND_SIMM8P4 :
1642 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 4, 8, 32, total_length, pc, & fields->f_ivc2_8s4);
1643 break;
1644 case MEP_OPERAND_SP :
1645 break;
1646 case MEP_OPERAND_SPR :
1647 break;
1648 case MEP_OPERAND_TP :
1649 break;
1650 case MEP_OPERAND_TPR :
1651 break;
1652 case MEP_OPERAND_UDISP2 :
1653 length = extract_normal (cd, ex_info, insn_value, 0, 0, 6, 2, 32, total_length, pc, & fields->f_2u6);
1654 break;
1655 case MEP_OPERAND_UDISP7 :
1656 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 7, 32, total_length, pc, & fields->f_7u9);
1657 break;
1658 case MEP_OPERAND_UDISP7A2 :
1660 long value;
1661 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 6, 32, total_length, pc, & value);
1662 value = ((value) << (1));
1663 fields->f_7u9a2 = value;
1665 break;
1666 case MEP_OPERAND_UDISP7A4 :
1668 long value;
1669 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 5, 32, total_length, pc, & value);
1670 value = ((value) << (2));
1671 fields->f_7u9a4 = value;
1673 break;
1674 case MEP_OPERAND_UIMM16 :
1675 length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_16u16);
1676 break;
1677 case MEP_OPERAND_UIMM2 :
1678 length = extract_normal (cd, ex_info, insn_value, 0, 0, 10, 2, 32, total_length, pc, & fields->f_2u10);
1679 break;
1680 case MEP_OPERAND_UIMM24 :
1682 length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_24u8n_hi);
1683 if (length <= 0) break;
1684 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 8, 32, total_length, pc, & fields->f_24u8n_lo);
1685 if (length <= 0) break;
1686 FLD (f_24u8n) = ((((FLD (f_24u8n_hi)) << (8))) | (FLD (f_24u8n_lo)));
1688 break;
1689 case MEP_OPERAND_UIMM3 :
1690 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_3u5);
1691 break;
1692 case MEP_OPERAND_UIMM4 :
1693 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_4u8);
1694 break;
1695 case MEP_OPERAND_UIMM5 :
1696 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 5, 32, total_length, pc, & fields->f_5u8);
1697 break;
1698 case MEP_OPERAND_UIMM7A4 :
1700 long value;
1701 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 5, 32, total_length, pc, & value);
1702 value = ((value) << (2));
1703 fields->f_7u9a4 = value;
1705 break;
1706 case MEP_OPERAND_ZERO :
1707 break;
1709 default :
1710 /* xgettext:c-format */
1711 fprintf (stderr, _("Unrecognized field %d while decoding insn.\n"),
1712 opindex);
1713 abort ();
1716 return length;
1719 cgen_insert_fn * const mep_cgen_insert_handlers[] =
1721 insert_insn_normal,
1724 cgen_extract_fn * const mep_cgen_extract_handlers[] =
1726 extract_insn_normal,
1729 int mep_cgen_get_int_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *);
1730 bfd_vma mep_cgen_get_vma_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *);
1732 /* Getting values from cgen_fields is handled by a collection of functions.
1733 They are distinguished by the type of the VALUE argument they return.
1734 TODO: floating point, inlining support, remove cases where result type
1735 not appropriate. */
1738 mep_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1739 int opindex,
1740 const CGEN_FIELDS * fields)
1742 int value;
1744 switch (opindex)
1746 case MEP_OPERAND_ADDR24A4 :
1747 value = fields->f_24u8a4n;
1748 break;
1749 case MEP_OPERAND_C5RMUIMM20 :
1750 value = fields->f_c5_rmuimm20;
1751 break;
1752 case MEP_OPERAND_C5RNMUIMM24 :
1753 value = fields->f_c5_rnmuimm24;
1754 break;
1755 case MEP_OPERAND_CALLNUM :
1756 value = fields->f_callnum;
1757 break;
1758 case MEP_OPERAND_CCCC :
1759 value = fields->f_rm;
1760 break;
1761 case MEP_OPERAND_CCRN :
1762 value = fields->f_ccrn;
1763 break;
1764 case MEP_OPERAND_CDISP10 :
1765 value = fields->f_cdisp10;
1766 break;
1767 case MEP_OPERAND_CDISP10A2 :
1768 value = fields->f_cdisp10;
1769 break;
1770 case MEP_OPERAND_CDISP10A4 :
1771 value = fields->f_cdisp10;
1772 break;
1773 case MEP_OPERAND_CDISP10A8 :
1774 value = fields->f_cdisp10;
1775 break;
1776 case MEP_OPERAND_CDISP12 :
1777 value = fields->f_12s20;
1778 break;
1779 case MEP_OPERAND_CIMM4 :
1780 value = fields->f_rn;
1781 break;
1782 case MEP_OPERAND_CIMM5 :
1783 value = fields->f_5u24;
1784 break;
1785 case MEP_OPERAND_CODE16 :
1786 value = fields->f_16u16;
1787 break;
1788 case MEP_OPERAND_CODE24 :
1789 value = fields->f_24u4n;
1790 break;
1791 case MEP_OPERAND_CP_FLAG :
1792 value = 0;
1793 break;
1794 case MEP_OPERAND_CRN :
1795 value = fields->f_crn;
1796 break;
1797 case MEP_OPERAND_CRN64 :
1798 value = fields->f_crn;
1799 break;
1800 case MEP_OPERAND_CRNX :
1801 value = fields->f_crnx;
1802 break;
1803 case MEP_OPERAND_CRNX64 :
1804 value = fields->f_crnx;
1805 break;
1806 case MEP_OPERAND_CROC :
1807 value = fields->f_ivc2_5u7;
1808 break;
1809 case MEP_OPERAND_CROP :
1810 value = fields->f_ivc2_5u23;
1811 break;
1812 case MEP_OPERAND_CRPC :
1813 value = fields->f_ivc2_5u26;
1814 break;
1815 case MEP_OPERAND_CRPP :
1816 value = fields->f_ivc2_5u18;
1817 break;
1818 case MEP_OPERAND_CRQC :
1819 value = fields->f_ivc2_5u21;
1820 break;
1821 case MEP_OPERAND_CRQP :
1822 value = fields->f_ivc2_5u13;
1823 break;
1824 case MEP_OPERAND_CSRN :
1825 value = fields->f_csrn;
1826 break;
1827 case MEP_OPERAND_CSRN_IDX :
1828 value = fields->f_csrn;
1829 break;
1830 case MEP_OPERAND_DBG :
1831 value = 0;
1832 break;
1833 case MEP_OPERAND_DEPC :
1834 value = 0;
1835 break;
1836 case MEP_OPERAND_EPC :
1837 value = 0;
1838 break;
1839 case MEP_OPERAND_EXC :
1840 value = 0;
1841 break;
1842 case MEP_OPERAND_HI :
1843 value = 0;
1844 break;
1845 case MEP_OPERAND_IMM16P0 :
1846 value = fields->f_ivc2_imm16p0;
1847 break;
1848 case MEP_OPERAND_IMM3P12 :
1849 value = fields->f_ivc2_3u12;
1850 break;
1851 case MEP_OPERAND_IMM3P25 :
1852 value = fields->f_ivc2_3u25;
1853 break;
1854 case MEP_OPERAND_IMM3P4 :
1855 value = fields->f_ivc2_3u4;
1856 break;
1857 case MEP_OPERAND_IMM3P5 :
1858 value = fields->f_ivc2_3u5;
1859 break;
1860 case MEP_OPERAND_IMM3P9 :
1861 value = fields->f_ivc2_3u9;
1862 break;
1863 case MEP_OPERAND_IMM4P10 :
1864 value = fields->f_ivc2_4u10;
1865 break;
1866 case MEP_OPERAND_IMM4P4 :
1867 value = fields->f_ivc2_4u4;
1868 break;
1869 case MEP_OPERAND_IMM4P8 :
1870 value = fields->f_ivc2_4u8;
1871 break;
1872 case MEP_OPERAND_IMM5P23 :
1873 value = fields->f_ivc2_5u23;
1874 break;
1875 case MEP_OPERAND_IMM5P3 :
1876 value = fields->f_ivc2_5u3;
1877 break;
1878 case MEP_OPERAND_IMM5P7 :
1879 value = fields->f_ivc2_5u7;
1880 break;
1881 case MEP_OPERAND_IMM5P8 :
1882 value = fields->f_ivc2_5u8;
1883 break;
1884 case MEP_OPERAND_IMM6P2 :
1885 value = fields->f_ivc2_6u2;
1886 break;
1887 case MEP_OPERAND_IMM6P6 :
1888 value = fields->f_ivc2_6u6;
1889 break;
1890 case MEP_OPERAND_IMM8P0 :
1891 value = fields->f_ivc2_8u0;
1892 break;
1893 case MEP_OPERAND_IMM8P20 :
1894 value = fields->f_ivc2_8u20;
1895 break;
1896 case MEP_OPERAND_IMM8P4 :
1897 value = fields->f_ivc2_8u4;
1898 break;
1899 case MEP_OPERAND_IVC_X_0_2 :
1900 value = fields->f_ivc2_2u0;
1901 break;
1902 case MEP_OPERAND_IVC_X_0_3 :
1903 value = fields->f_ivc2_3u0;
1904 break;
1905 case MEP_OPERAND_IVC_X_0_4 :
1906 value = fields->f_ivc2_4u0;
1907 break;
1908 case MEP_OPERAND_IVC_X_0_5 :
1909 value = fields->f_ivc2_5u0;
1910 break;
1911 case MEP_OPERAND_IVC_X_6_1 :
1912 value = fields->f_ivc2_1u6;
1913 break;
1914 case MEP_OPERAND_IVC_X_6_2 :
1915 value = fields->f_ivc2_2u6;
1916 break;
1917 case MEP_OPERAND_IVC_X_6_3 :
1918 value = fields->f_ivc2_3u6;
1919 break;
1920 case MEP_OPERAND_IVC2C3CCRN :
1921 value = fields->f_ivc2_ccrn_c3;
1922 break;
1923 case MEP_OPERAND_IVC2CCRN :
1924 value = fields->f_ivc2_ccrn;
1925 break;
1926 case MEP_OPERAND_IVC2CRN :
1927 value = fields->f_ivc2_crnx;
1928 break;
1929 case MEP_OPERAND_IVC2RM :
1930 value = fields->f_ivc2_crm;
1931 break;
1932 case MEP_OPERAND_LO :
1933 value = 0;
1934 break;
1935 case MEP_OPERAND_LP :
1936 value = 0;
1937 break;
1938 case MEP_OPERAND_MB0 :
1939 value = 0;
1940 break;
1941 case MEP_OPERAND_MB1 :
1942 value = 0;
1943 break;
1944 case MEP_OPERAND_ME0 :
1945 value = 0;
1946 break;
1947 case MEP_OPERAND_ME1 :
1948 value = 0;
1949 break;
1950 case MEP_OPERAND_NPC :
1951 value = 0;
1952 break;
1953 case MEP_OPERAND_OPT :
1954 value = 0;
1955 break;
1956 case MEP_OPERAND_PCABS24A2 :
1957 value = fields->f_24u5a2n;
1958 break;
1959 case MEP_OPERAND_PCREL12A2 :
1960 value = fields->f_12s4a2;
1961 break;
1962 case MEP_OPERAND_PCREL17A2 :
1963 value = fields->f_17s16a2;
1964 break;
1965 case MEP_OPERAND_PCREL24A2 :
1966 value = fields->f_24s5a2n;
1967 break;
1968 case MEP_OPERAND_PCREL8A2 :
1969 value = fields->f_8s8a2;
1970 break;
1971 case MEP_OPERAND_PSW :
1972 value = 0;
1973 break;
1974 case MEP_OPERAND_R0 :
1975 value = 0;
1976 break;
1977 case MEP_OPERAND_R1 :
1978 value = 0;
1979 break;
1980 case MEP_OPERAND_RL :
1981 value = fields->f_rl;
1982 break;
1983 case MEP_OPERAND_RL5 :
1984 value = fields->f_rl5;
1985 break;
1986 case MEP_OPERAND_RM :
1987 value = fields->f_rm;
1988 break;
1989 case MEP_OPERAND_RMA :
1990 value = fields->f_rm;
1991 break;
1992 case MEP_OPERAND_RN :
1993 value = fields->f_rn;
1994 break;
1995 case MEP_OPERAND_RN3 :
1996 value = fields->f_rn3;
1997 break;
1998 case MEP_OPERAND_RN3C :
1999 value = fields->f_rn3;
2000 break;
2001 case MEP_OPERAND_RN3L :
2002 value = fields->f_rn3;
2003 break;
2004 case MEP_OPERAND_RN3S :
2005 value = fields->f_rn3;
2006 break;
2007 case MEP_OPERAND_RN3UC :
2008 value = fields->f_rn3;
2009 break;
2010 case MEP_OPERAND_RN3UL :
2011 value = fields->f_rn3;
2012 break;
2013 case MEP_OPERAND_RN3US :
2014 value = fields->f_rn3;
2015 break;
2016 case MEP_OPERAND_RNC :
2017 value = fields->f_rn;
2018 break;
2019 case MEP_OPERAND_RNL :
2020 value = fields->f_rn;
2021 break;
2022 case MEP_OPERAND_RNS :
2023 value = fields->f_rn;
2024 break;
2025 case MEP_OPERAND_RNUC :
2026 value = fields->f_rn;
2027 break;
2028 case MEP_OPERAND_RNUL :
2029 value = fields->f_rn;
2030 break;
2031 case MEP_OPERAND_RNUS :
2032 value = fields->f_rn;
2033 break;
2034 case MEP_OPERAND_SAR :
2035 value = 0;
2036 break;
2037 case MEP_OPERAND_SDISP16 :
2038 value = fields->f_16s16;
2039 break;
2040 case MEP_OPERAND_SIMM16 :
2041 value = fields->f_16s16;
2042 break;
2043 case MEP_OPERAND_SIMM16P0 :
2044 value = fields->f_ivc2_simm16p0;
2045 break;
2046 case MEP_OPERAND_SIMM6 :
2047 value = fields->f_6s8;
2048 break;
2049 case MEP_OPERAND_SIMM8 :
2050 value = fields->f_8s8;
2051 break;
2052 case MEP_OPERAND_SIMM8P0 :
2053 value = fields->f_ivc2_8s0;
2054 break;
2055 case MEP_OPERAND_SIMM8P20 :
2056 value = fields->f_ivc2_8s20;
2057 break;
2058 case MEP_OPERAND_SIMM8P4 :
2059 value = fields->f_ivc2_8s4;
2060 break;
2061 case MEP_OPERAND_SP :
2062 value = 0;
2063 break;
2064 case MEP_OPERAND_SPR :
2065 value = 0;
2066 break;
2067 case MEP_OPERAND_TP :
2068 value = 0;
2069 break;
2070 case MEP_OPERAND_TPR :
2071 value = 0;
2072 break;
2073 case MEP_OPERAND_UDISP2 :
2074 value = fields->f_2u6;
2075 break;
2076 case MEP_OPERAND_UDISP7 :
2077 value = fields->f_7u9;
2078 break;
2079 case MEP_OPERAND_UDISP7A2 :
2080 value = fields->f_7u9a2;
2081 break;
2082 case MEP_OPERAND_UDISP7A4 :
2083 value = fields->f_7u9a4;
2084 break;
2085 case MEP_OPERAND_UIMM16 :
2086 value = fields->f_16u16;
2087 break;
2088 case MEP_OPERAND_UIMM2 :
2089 value = fields->f_2u10;
2090 break;
2091 case MEP_OPERAND_UIMM24 :
2092 value = fields->f_24u8n;
2093 break;
2094 case MEP_OPERAND_UIMM3 :
2095 value = fields->f_3u5;
2096 break;
2097 case MEP_OPERAND_UIMM4 :
2098 value = fields->f_4u8;
2099 break;
2100 case MEP_OPERAND_UIMM5 :
2101 value = fields->f_5u8;
2102 break;
2103 case MEP_OPERAND_UIMM7A4 :
2104 value = fields->f_7u9a4;
2105 break;
2106 case MEP_OPERAND_ZERO :
2107 value = 0;
2108 break;
2110 default :
2111 /* xgettext:c-format */
2112 fprintf (stderr, _("Unrecognized field %d while getting int operand.\n"),
2113 opindex);
2114 abort ();
2117 return value;
2120 bfd_vma
2121 mep_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
2122 int opindex,
2123 const CGEN_FIELDS * fields)
2125 bfd_vma value;
2127 switch (opindex)
2129 case MEP_OPERAND_ADDR24A4 :
2130 value = fields->f_24u8a4n;
2131 break;
2132 case MEP_OPERAND_C5RMUIMM20 :
2133 value = fields->f_c5_rmuimm20;
2134 break;
2135 case MEP_OPERAND_C5RNMUIMM24 :
2136 value = fields->f_c5_rnmuimm24;
2137 break;
2138 case MEP_OPERAND_CALLNUM :
2139 value = fields->f_callnum;
2140 break;
2141 case MEP_OPERAND_CCCC :
2142 value = fields->f_rm;
2143 break;
2144 case MEP_OPERAND_CCRN :
2145 value = fields->f_ccrn;
2146 break;
2147 case MEP_OPERAND_CDISP10 :
2148 value = fields->f_cdisp10;
2149 break;
2150 case MEP_OPERAND_CDISP10A2 :
2151 value = fields->f_cdisp10;
2152 break;
2153 case MEP_OPERAND_CDISP10A4 :
2154 value = fields->f_cdisp10;
2155 break;
2156 case MEP_OPERAND_CDISP10A8 :
2157 value = fields->f_cdisp10;
2158 break;
2159 case MEP_OPERAND_CDISP12 :
2160 value = fields->f_12s20;
2161 break;
2162 case MEP_OPERAND_CIMM4 :
2163 value = fields->f_rn;
2164 break;
2165 case MEP_OPERAND_CIMM5 :
2166 value = fields->f_5u24;
2167 break;
2168 case MEP_OPERAND_CODE16 :
2169 value = fields->f_16u16;
2170 break;
2171 case MEP_OPERAND_CODE24 :
2172 value = fields->f_24u4n;
2173 break;
2174 case MEP_OPERAND_CP_FLAG :
2175 value = 0;
2176 break;
2177 case MEP_OPERAND_CRN :
2178 value = fields->f_crn;
2179 break;
2180 case MEP_OPERAND_CRN64 :
2181 value = fields->f_crn;
2182 break;
2183 case MEP_OPERAND_CRNX :
2184 value = fields->f_crnx;
2185 break;
2186 case MEP_OPERAND_CRNX64 :
2187 value = fields->f_crnx;
2188 break;
2189 case MEP_OPERAND_CROC :
2190 value = fields->f_ivc2_5u7;
2191 break;
2192 case MEP_OPERAND_CROP :
2193 value = fields->f_ivc2_5u23;
2194 break;
2195 case MEP_OPERAND_CRPC :
2196 value = fields->f_ivc2_5u26;
2197 break;
2198 case MEP_OPERAND_CRPP :
2199 value = fields->f_ivc2_5u18;
2200 break;
2201 case MEP_OPERAND_CRQC :
2202 value = fields->f_ivc2_5u21;
2203 break;
2204 case MEP_OPERAND_CRQP :
2205 value = fields->f_ivc2_5u13;
2206 break;
2207 case MEP_OPERAND_CSRN :
2208 value = fields->f_csrn;
2209 break;
2210 case MEP_OPERAND_CSRN_IDX :
2211 value = fields->f_csrn;
2212 break;
2213 case MEP_OPERAND_DBG :
2214 value = 0;
2215 break;
2216 case MEP_OPERAND_DEPC :
2217 value = 0;
2218 break;
2219 case MEP_OPERAND_EPC :
2220 value = 0;
2221 break;
2222 case MEP_OPERAND_EXC :
2223 value = 0;
2224 break;
2225 case MEP_OPERAND_HI :
2226 value = 0;
2227 break;
2228 case MEP_OPERAND_IMM16P0 :
2229 value = fields->f_ivc2_imm16p0;
2230 break;
2231 case MEP_OPERAND_IMM3P12 :
2232 value = fields->f_ivc2_3u12;
2233 break;
2234 case MEP_OPERAND_IMM3P25 :
2235 value = fields->f_ivc2_3u25;
2236 break;
2237 case MEP_OPERAND_IMM3P4 :
2238 value = fields->f_ivc2_3u4;
2239 break;
2240 case MEP_OPERAND_IMM3P5 :
2241 value = fields->f_ivc2_3u5;
2242 break;
2243 case MEP_OPERAND_IMM3P9 :
2244 value = fields->f_ivc2_3u9;
2245 break;
2246 case MEP_OPERAND_IMM4P10 :
2247 value = fields->f_ivc2_4u10;
2248 break;
2249 case MEP_OPERAND_IMM4P4 :
2250 value = fields->f_ivc2_4u4;
2251 break;
2252 case MEP_OPERAND_IMM4P8 :
2253 value = fields->f_ivc2_4u8;
2254 break;
2255 case MEP_OPERAND_IMM5P23 :
2256 value = fields->f_ivc2_5u23;
2257 break;
2258 case MEP_OPERAND_IMM5P3 :
2259 value = fields->f_ivc2_5u3;
2260 break;
2261 case MEP_OPERAND_IMM5P7 :
2262 value = fields->f_ivc2_5u7;
2263 break;
2264 case MEP_OPERAND_IMM5P8 :
2265 value = fields->f_ivc2_5u8;
2266 break;
2267 case MEP_OPERAND_IMM6P2 :
2268 value = fields->f_ivc2_6u2;
2269 break;
2270 case MEP_OPERAND_IMM6P6 :
2271 value = fields->f_ivc2_6u6;
2272 break;
2273 case MEP_OPERAND_IMM8P0 :
2274 value = fields->f_ivc2_8u0;
2275 break;
2276 case MEP_OPERAND_IMM8P20 :
2277 value = fields->f_ivc2_8u20;
2278 break;
2279 case MEP_OPERAND_IMM8P4 :
2280 value = fields->f_ivc2_8u4;
2281 break;
2282 case MEP_OPERAND_IVC_X_0_2 :
2283 value = fields->f_ivc2_2u0;
2284 break;
2285 case MEP_OPERAND_IVC_X_0_3 :
2286 value = fields->f_ivc2_3u0;
2287 break;
2288 case MEP_OPERAND_IVC_X_0_4 :
2289 value = fields->f_ivc2_4u0;
2290 break;
2291 case MEP_OPERAND_IVC_X_0_5 :
2292 value = fields->f_ivc2_5u0;
2293 break;
2294 case MEP_OPERAND_IVC_X_6_1 :
2295 value = fields->f_ivc2_1u6;
2296 break;
2297 case MEP_OPERAND_IVC_X_6_2 :
2298 value = fields->f_ivc2_2u6;
2299 break;
2300 case MEP_OPERAND_IVC_X_6_3 :
2301 value = fields->f_ivc2_3u6;
2302 break;
2303 case MEP_OPERAND_IVC2C3CCRN :
2304 value = fields->f_ivc2_ccrn_c3;
2305 break;
2306 case MEP_OPERAND_IVC2CCRN :
2307 value = fields->f_ivc2_ccrn;
2308 break;
2309 case MEP_OPERAND_IVC2CRN :
2310 value = fields->f_ivc2_crnx;
2311 break;
2312 case MEP_OPERAND_IVC2RM :
2313 value = fields->f_ivc2_crm;
2314 break;
2315 case MEP_OPERAND_LO :
2316 value = 0;
2317 break;
2318 case MEP_OPERAND_LP :
2319 value = 0;
2320 break;
2321 case MEP_OPERAND_MB0 :
2322 value = 0;
2323 break;
2324 case MEP_OPERAND_MB1 :
2325 value = 0;
2326 break;
2327 case MEP_OPERAND_ME0 :
2328 value = 0;
2329 break;
2330 case MEP_OPERAND_ME1 :
2331 value = 0;
2332 break;
2333 case MEP_OPERAND_NPC :
2334 value = 0;
2335 break;
2336 case MEP_OPERAND_OPT :
2337 value = 0;
2338 break;
2339 case MEP_OPERAND_PCABS24A2 :
2340 value = fields->f_24u5a2n;
2341 break;
2342 case MEP_OPERAND_PCREL12A2 :
2343 value = fields->f_12s4a2;
2344 break;
2345 case MEP_OPERAND_PCREL17A2 :
2346 value = fields->f_17s16a2;
2347 break;
2348 case MEP_OPERAND_PCREL24A2 :
2349 value = fields->f_24s5a2n;
2350 break;
2351 case MEP_OPERAND_PCREL8A2 :
2352 value = fields->f_8s8a2;
2353 break;
2354 case MEP_OPERAND_PSW :
2355 value = 0;
2356 break;
2357 case MEP_OPERAND_R0 :
2358 value = 0;
2359 break;
2360 case MEP_OPERAND_R1 :
2361 value = 0;
2362 break;
2363 case MEP_OPERAND_RL :
2364 value = fields->f_rl;
2365 break;
2366 case MEP_OPERAND_RL5 :
2367 value = fields->f_rl5;
2368 break;
2369 case MEP_OPERAND_RM :
2370 value = fields->f_rm;
2371 break;
2372 case MEP_OPERAND_RMA :
2373 value = fields->f_rm;
2374 break;
2375 case MEP_OPERAND_RN :
2376 value = fields->f_rn;
2377 break;
2378 case MEP_OPERAND_RN3 :
2379 value = fields->f_rn3;
2380 break;
2381 case MEP_OPERAND_RN3C :
2382 value = fields->f_rn3;
2383 break;
2384 case MEP_OPERAND_RN3L :
2385 value = fields->f_rn3;
2386 break;
2387 case MEP_OPERAND_RN3S :
2388 value = fields->f_rn3;
2389 break;
2390 case MEP_OPERAND_RN3UC :
2391 value = fields->f_rn3;
2392 break;
2393 case MEP_OPERAND_RN3UL :
2394 value = fields->f_rn3;
2395 break;
2396 case MEP_OPERAND_RN3US :
2397 value = fields->f_rn3;
2398 break;
2399 case MEP_OPERAND_RNC :
2400 value = fields->f_rn;
2401 break;
2402 case MEP_OPERAND_RNL :
2403 value = fields->f_rn;
2404 break;
2405 case MEP_OPERAND_RNS :
2406 value = fields->f_rn;
2407 break;
2408 case MEP_OPERAND_RNUC :
2409 value = fields->f_rn;
2410 break;
2411 case MEP_OPERAND_RNUL :
2412 value = fields->f_rn;
2413 break;
2414 case MEP_OPERAND_RNUS :
2415 value = fields->f_rn;
2416 break;
2417 case MEP_OPERAND_SAR :
2418 value = 0;
2419 break;
2420 case MEP_OPERAND_SDISP16 :
2421 value = fields->f_16s16;
2422 break;
2423 case MEP_OPERAND_SIMM16 :
2424 value = fields->f_16s16;
2425 break;
2426 case MEP_OPERAND_SIMM16P0 :
2427 value = fields->f_ivc2_simm16p0;
2428 break;
2429 case MEP_OPERAND_SIMM6 :
2430 value = fields->f_6s8;
2431 break;
2432 case MEP_OPERAND_SIMM8 :
2433 value = fields->f_8s8;
2434 break;
2435 case MEP_OPERAND_SIMM8P0 :
2436 value = fields->f_ivc2_8s0;
2437 break;
2438 case MEP_OPERAND_SIMM8P20 :
2439 value = fields->f_ivc2_8s20;
2440 break;
2441 case MEP_OPERAND_SIMM8P4 :
2442 value = fields->f_ivc2_8s4;
2443 break;
2444 case MEP_OPERAND_SP :
2445 value = 0;
2446 break;
2447 case MEP_OPERAND_SPR :
2448 value = 0;
2449 break;
2450 case MEP_OPERAND_TP :
2451 value = 0;
2452 break;
2453 case MEP_OPERAND_TPR :
2454 value = 0;
2455 break;
2456 case MEP_OPERAND_UDISP2 :
2457 value = fields->f_2u6;
2458 break;
2459 case MEP_OPERAND_UDISP7 :
2460 value = fields->f_7u9;
2461 break;
2462 case MEP_OPERAND_UDISP7A2 :
2463 value = fields->f_7u9a2;
2464 break;
2465 case MEP_OPERAND_UDISP7A4 :
2466 value = fields->f_7u9a4;
2467 break;
2468 case MEP_OPERAND_UIMM16 :
2469 value = fields->f_16u16;
2470 break;
2471 case MEP_OPERAND_UIMM2 :
2472 value = fields->f_2u10;
2473 break;
2474 case MEP_OPERAND_UIMM24 :
2475 value = fields->f_24u8n;
2476 break;
2477 case MEP_OPERAND_UIMM3 :
2478 value = fields->f_3u5;
2479 break;
2480 case MEP_OPERAND_UIMM4 :
2481 value = fields->f_4u8;
2482 break;
2483 case MEP_OPERAND_UIMM5 :
2484 value = fields->f_5u8;
2485 break;
2486 case MEP_OPERAND_UIMM7A4 :
2487 value = fields->f_7u9a4;
2488 break;
2489 case MEP_OPERAND_ZERO :
2490 value = 0;
2491 break;
2493 default :
2494 /* xgettext:c-format */
2495 fprintf (stderr, _("Unrecognized field %d while getting vma operand.\n"),
2496 opindex);
2497 abort ();
2500 return value;
2503 void mep_cgen_set_int_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, int);
2504 void mep_cgen_set_vma_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, bfd_vma);
2506 /* Stuffing values in cgen_fields is handled by a collection of functions.
2507 They are distinguished by the type of the VALUE argument they accept.
2508 TODO: floating point, inlining support, remove cases where argument type
2509 not appropriate. */
2511 void
2512 mep_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
2513 int opindex,
2514 CGEN_FIELDS * fields,
2515 int value)
2517 switch (opindex)
2519 case MEP_OPERAND_ADDR24A4 :
2520 fields->f_24u8a4n = value;
2521 break;
2522 case MEP_OPERAND_C5RMUIMM20 :
2523 fields->f_c5_rmuimm20 = value;
2524 break;
2525 case MEP_OPERAND_C5RNMUIMM24 :
2526 fields->f_c5_rnmuimm24 = value;
2527 break;
2528 case MEP_OPERAND_CALLNUM :
2529 fields->f_callnum = value;
2530 break;
2531 case MEP_OPERAND_CCCC :
2532 fields->f_rm = value;
2533 break;
2534 case MEP_OPERAND_CCRN :
2535 fields->f_ccrn = value;
2536 break;
2537 case MEP_OPERAND_CDISP10 :
2538 fields->f_cdisp10 = value;
2539 break;
2540 case MEP_OPERAND_CDISP10A2 :
2541 fields->f_cdisp10 = value;
2542 break;
2543 case MEP_OPERAND_CDISP10A4 :
2544 fields->f_cdisp10 = value;
2545 break;
2546 case MEP_OPERAND_CDISP10A8 :
2547 fields->f_cdisp10 = value;
2548 break;
2549 case MEP_OPERAND_CDISP12 :
2550 fields->f_12s20 = value;
2551 break;
2552 case MEP_OPERAND_CIMM4 :
2553 fields->f_rn = value;
2554 break;
2555 case MEP_OPERAND_CIMM5 :
2556 fields->f_5u24 = value;
2557 break;
2558 case MEP_OPERAND_CODE16 :
2559 fields->f_16u16 = value;
2560 break;
2561 case MEP_OPERAND_CODE24 :
2562 fields->f_24u4n = value;
2563 break;
2564 case MEP_OPERAND_CP_FLAG :
2565 break;
2566 case MEP_OPERAND_CRN :
2567 fields->f_crn = value;
2568 break;
2569 case MEP_OPERAND_CRN64 :
2570 fields->f_crn = value;
2571 break;
2572 case MEP_OPERAND_CRNX :
2573 fields->f_crnx = value;
2574 break;
2575 case MEP_OPERAND_CRNX64 :
2576 fields->f_crnx = value;
2577 break;
2578 case MEP_OPERAND_CROC :
2579 fields->f_ivc2_5u7 = value;
2580 break;
2581 case MEP_OPERAND_CROP :
2582 fields->f_ivc2_5u23 = value;
2583 break;
2584 case MEP_OPERAND_CRPC :
2585 fields->f_ivc2_5u26 = value;
2586 break;
2587 case MEP_OPERAND_CRPP :
2588 fields->f_ivc2_5u18 = value;
2589 break;
2590 case MEP_OPERAND_CRQC :
2591 fields->f_ivc2_5u21 = value;
2592 break;
2593 case MEP_OPERAND_CRQP :
2594 fields->f_ivc2_5u13 = value;
2595 break;
2596 case MEP_OPERAND_CSRN :
2597 fields->f_csrn = value;
2598 break;
2599 case MEP_OPERAND_CSRN_IDX :
2600 fields->f_csrn = value;
2601 break;
2602 case MEP_OPERAND_DBG :
2603 break;
2604 case MEP_OPERAND_DEPC :
2605 break;
2606 case MEP_OPERAND_EPC :
2607 break;
2608 case MEP_OPERAND_EXC :
2609 break;
2610 case MEP_OPERAND_HI :
2611 break;
2612 case MEP_OPERAND_IMM16P0 :
2613 fields->f_ivc2_imm16p0 = value;
2614 break;
2615 case MEP_OPERAND_IMM3P12 :
2616 fields->f_ivc2_3u12 = value;
2617 break;
2618 case MEP_OPERAND_IMM3P25 :
2619 fields->f_ivc2_3u25 = value;
2620 break;
2621 case MEP_OPERAND_IMM3P4 :
2622 fields->f_ivc2_3u4 = value;
2623 break;
2624 case MEP_OPERAND_IMM3P5 :
2625 fields->f_ivc2_3u5 = value;
2626 break;
2627 case MEP_OPERAND_IMM3P9 :
2628 fields->f_ivc2_3u9 = value;
2629 break;
2630 case MEP_OPERAND_IMM4P10 :
2631 fields->f_ivc2_4u10 = value;
2632 break;
2633 case MEP_OPERAND_IMM4P4 :
2634 fields->f_ivc2_4u4 = value;
2635 break;
2636 case MEP_OPERAND_IMM4P8 :
2637 fields->f_ivc2_4u8 = value;
2638 break;
2639 case MEP_OPERAND_IMM5P23 :
2640 fields->f_ivc2_5u23 = value;
2641 break;
2642 case MEP_OPERAND_IMM5P3 :
2643 fields->f_ivc2_5u3 = value;
2644 break;
2645 case MEP_OPERAND_IMM5P7 :
2646 fields->f_ivc2_5u7 = value;
2647 break;
2648 case MEP_OPERAND_IMM5P8 :
2649 fields->f_ivc2_5u8 = value;
2650 break;
2651 case MEP_OPERAND_IMM6P2 :
2652 fields->f_ivc2_6u2 = value;
2653 break;
2654 case MEP_OPERAND_IMM6P6 :
2655 fields->f_ivc2_6u6 = value;
2656 break;
2657 case MEP_OPERAND_IMM8P0 :
2658 fields->f_ivc2_8u0 = value;
2659 break;
2660 case MEP_OPERAND_IMM8P20 :
2661 fields->f_ivc2_8u20 = value;
2662 break;
2663 case MEP_OPERAND_IMM8P4 :
2664 fields->f_ivc2_8u4 = value;
2665 break;
2666 case MEP_OPERAND_IVC_X_0_2 :
2667 fields->f_ivc2_2u0 = value;
2668 break;
2669 case MEP_OPERAND_IVC_X_0_3 :
2670 fields->f_ivc2_3u0 = value;
2671 break;
2672 case MEP_OPERAND_IVC_X_0_4 :
2673 fields->f_ivc2_4u0 = value;
2674 break;
2675 case MEP_OPERAND_IVC_X_0_5 :
2676 fields->f_ivc2_5u0 = value;
2677 break;
2678 case MEP_OPERAND_IVC_X_6_1 :
2679 fields->f_ivc2_1u6 = value;
2680 break;
2681 case MEP_OPERAND_IVC_X_6_2 :
2682 fields->f_ivc2_2u6 = value;
2683 break;
2684 case MEP_OPERAND_IVC_X_6_3 :
2685 fields->f_ivc2_3u6 = value;
2686 break;
2687 case MEP_OPERAND_IVC2C3CCRN :
2688 fields->f_ivc2_ccrn_c3 = value;
2689 break;
2690 case MEP_OPERAND_IVC2CCRN :
2691 fields->f_ivc2_ccrn = value;
2692 break;
2693 case MEP_OPERAND_IVC2CRN :
2694 fields->f_ivc2_crnx = value;
2695 break;
2696 case MEP_OPERAND_IVC2RM :
2697 fields->f_ivc2_crm = value;
2698 break;
2699 case MEP_OPERAND_LO :
2700 break;
2701 case MEP_OPERAND_LP :
2702 break;
2703 case MEP_OPERAND_MB0 :
2704 break;
2705 case MEP_OPERAND_MB1 :
2706 break;
2707 case MEP_OPERAND_ME0 :
2708 break;
2709 case MEP_OPERAND_ME1 :
2710 break;
2711 case MEP_OPERAND_NPC :
2712 break;
2713 case MEP_OPERAND_OPT :
2714 break;
2715 case MEP_OPERAND_PCABS24A2 :
2716 fields->f_24u5a2n = value;
2717 break;
2718 case MEP_OPERAND_PCREL12A2 :
2719 fields->f_12s4a2 = value;
2720 break;
2721 case MEP_OPERAND_PCREL17A2 :
2722 fields->f_17s16a2 = value;
2723 break;
2724 case MEP_OPERAND_PCREL24A2 :
2725 fields->f_24s5a2n = value;
2726 break;
2727 case MEP_OPERAND_PCREL8A2 :
2728 fields->f_8s8a2 = value;
2729 break;
2730 case MEP_OPERAND_PSW :
2731 break;
2732 case MEP_OPERAND_R0 :
2733 break;
2734 case MEP_OPERAND_R1 :
2735 break;
2736 case MEP_OPERAND_RL :
2737 fields->f_rl = value;
2738 break;
2739 case MEP_OPERAND_RL5 :
2740 fields->f_rl5 = value;
2741 break;
2742 case MEP_OPERAND_RM :
2743 fields->f_rm = value;
2744 break;
2745 case MEP_OPERAND_RMA :
2746 fields->f_rm = value;
2747 break;
2748 case MEP_OPERAND_RN :
2749 fields->f_rn = value;
2750 break;
2751 case MEP_OPERAND_RN3 :
2752 fields->f_rn3 = value;
2753 break;
2754 case MEP_OPERAND_RN3C :
2755 fields->f_rn3 = value;
2756 break;
2757 case MEP_OPERAND_RN3L :
2758 fields->f_rn3 = value;
2759 break;
2760 case MEP_OPERAND_RN3S :
2761 fields->f_rn3 = value;
2762 break;
2763 case MEP_OPERAND_RN3UC :
2764 fields->f_rn3 = value;
2765 break;
2766 case MEP_OPERAND_RN3UL :
2767 fields->f_rn3 = value;
2768 break;
2769 case MEP_OPERAND_RN3US :
2770 fields->f_rn3 = value;
2771 break;
2772 case MEP_OPERAND_RNC :
2773 fields->f_rn = value;
2774 break;
2775 case MEP_OPERAND_RNL :
2776 fields->f_rn = value;
2777 break;
2778 case MEP_OPERAND_RNS :
2779 fields->f_rn = value;
2780 break;
2781 case MEP_OPERAND_RNUC :
2782 fields->f_rn = value;
2783 break;
2784 case MEP_OPERAND_RNUL :
2785 fields->f_rn = value;
2786 break;
2787 case MEP_OPERAND_RNUS :
2788 fields->f_rn = value;
2789 break;
2790 case MEP_OPERAND_SAR :
2791 break;
2792 case MEP_OPERAND_SDISP16 :
2793 fields->f_16s16 = value;
2794 break;
2795 case MEP_OPERAND_SIMM16 :
2796 fields->f_16s16 = value;
2797 break;
2798 case MEP_OPERAND_SIMM16P0 :
2799 fields->f_ivc2_simm16p0 = value;
2800 break;
2801 case MEP_OPERAND_SIMM6 :
2802 fields->f_6s8 = value;
2803 break;
2804 case MEP_OPERAND_SIMM8 :
2805 fields->f_8s8 = value;
2806 break;
2807 case MEP_OPERAND_SIMM8P0 :
2808 fields->f_ivc2_8s0 = value;
2809 break;
2810 case MEP_OPERAND_SIMM8P20 :
2811 fields->f_ivc2_8s20 = value;
2812 break;
2813 case MEP_OPERAND_SIMM8P4 :
2814 fields->f_ivc2_8s4 = value;
2815 break;
2816 case MEP_OPERAND_SP :
2817 break;
2818 case MEP_OPERAND_SPR :
2819 break;
2820 case MEP_OPERAND_TP :
2821 break;
2822 case MEP_OPERAND_TPR :
2823 break;
2824 case MEP_OPERAND_UDISP2 :
2825 fields->f_2u6 = value;
2826 break;
2827 case MEP_OPERAND_UDISP7 :
2828 fields->f_7u9 = value;
2829 break;
2830 case MEP_OPERAND_UDISP7A2 :
2831 fields->f_7u9a2 = value;
2832 break;
2833 case MEP_OPERAND_UDISP7A4 :
2834 fields->f_7u9a4 = value;
2835 break;
2836 case MEP_OPERAND_UIMM16 :
2837 fields->f_16u16 = value;
2838 break;
2839 case MEP_OPERAND_UIMM2 :
2840 fields->f_2u10 = value;
2841 break;
2842 case MEP_OPERAND_UIMM24 :
2843 fields->f_24u8n = value;
2844 break;
2845 case MEP_OPERAND_UIMM3 :
2846 fields->f_3u5 = value;
2847 break;
2848 case MEP_OPERAND_UIMM4 :
2849 fields->f_4u8 = value;
2850 break;
2851 case MEP_OPERAND_UIMM5 :
2852 fields->f_5u8 = value;
2853 break;
2854 case MEP_OPERAND_UIMM7A4 :
2855 fields->f_7u9a4 = value;
2856 break;
2857 case MEP_OPERAND_ZERO :
2858 break;
2860 default :
2861 /* xgettext:c-format */
2862 fprintf (stderr, _("Unrecognized field %d while setting int operand.\n"),
2863 opindex);
2864 abort ();
2868 void
2869 mep_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
2870 int opindex,
2871 CGEN_FIELDS * fields,
2872 bfd_vma value)
2874 switch (opindex)
2876 case MEP_OPERAND_ADDR24A4 :
2877 fields->f_24u8a4n = value;
2878 break;
2879 case MEP_OPERAND_C5RMUIMM20 :
2880 fields->f_c5_rmuimm20 = value;
2881 break;
2882 case MEP_OPERAND_C5RNMUIMM24 :
2883 fields->f_c5_rnmuimm24 = value;
2884 break;
2885 case MEP_OPERAND_CALLNUM :
2886 fields->f_callnum = value;
2887 break;
2888 case MEP_OPERAND_CCCC :
2889 fields->f_rm = value;
2890 break;
2891 case MEP_OPERAND_CCRN :
2892 fields->f_ccrn = value;
2893 break;
2894 case MEP_OPERAND_CDISP10 :
2895 fields->f_cdisp10 = value;
2896 break;
2897 case MEP_OPERAND_CDISP10A2 :
2898 fields->f_cdisp10 = value;
2899 break;
2900 case MEP_OPERAND_CDISP10A4 :
2901 fields->f_cdisp10 = value;
2902 break;
2903 case MEP_OPERAND_CDISP10A8 :
2904 fields->f_cdisp10 = value;
2905 break;
2906 case MEP_OPERAND_CDISP12 :
2907 fields->f_12s20 = value;
2908 break;
2909 case MEP_OPERAND_CIMM4 :
2910 fields->f_rn = value;
2911 break;
2912 case MEP_OPERAND_CIMM5 :
2913 fields->f_5u24 = value;
2914 break;
2915 case MEP_OPERAND_CODE16 :
2916 fields->f_16u16 = value;
2917 break;
2918 case MEP_OPERAND_CODE24 :
2919 fields->f_24u4n = value;
2920 break;
2921 case MEP_OPERAND_CP_FLAG :
2922 break;
2923 case MEP_OPERAND_CRN :
2924 fields->f_crn = value;
2925 break;
2926 case MEP_OPERAND_CRN64 :
2927 fields->f_crn = value;
2928 break;
2929 case MEP_OPERAND_CRNX :
2930 fields->f_crnx = value;
2931 break;
2932 case MEP_OPERAND_CRNX64 :
2933 fields->f_crnx = value;
2934 break;
2935 case MEP_OPERAND_CROC :
2936 fields->f_ivc2_5u7 = value;
2937 break;
2938 case MEP_OPERAND_CROP :
2939 fields->f_ivc2_5u23 = value;
2940 break;
2941 case MEP_OPERAND_CRPC :
2942 fields->f_ivc2_5u26 = value;
2943 break;
2944 case MEP_OPERAND_CRPP :
2945 fields->f_ivc2_5u18 = value;
2946 break;
2947 case MEP_OPERAND_CRQC :
2948 fields->f_ivc2_5u21 = value;
2949 break;
2950 case MEP_OPERAND_CRQP :
2951 fields->f_ivc2_5u13 = value;
2952 break;
2953 case MEP_OPERAND_CSRN :
2954 fields->f_csrn = value;
2955 break;
2956 case MEP_OPERAND_CSRN_IDX :
2957 fields->f_csrn = value;
2958 break;
2959 case MEP_OPERAND_DBG :
2960 break;
2961 case MEP_OPERAND_DEPC :
2962 break;
2963 case MEP_OPERAND_EPC :
2964 break;
2965 case MEP_OPERAND_EXC :
2966 break;
2967 case MEP_OPERAND_HI :
2968 break;
2969 case MEP_OPERAND_IMM16P0 :
2970 fields->f_ivc2_imm16p0 = value;
2971 break;
2972 case MEP_OPERAND_IMM3P12 :
2973 fields->f_ivc2_3u12 = value;
2974 break;
2975 case MEP_OPERAND_IMM3P25 :
2976 fields->f_ivc2_3u25 = value;
2977 break;
2978 case MEP_OPERAND_IMM3P4 :
2979 fields->f_ivc2_3u4 = value;
2980 break;
2981 case MEP_OPERAND_IMM3P5 :
2982 fields->f_ivc2_3u5 = value;
2983 break;
2984 case MEP_OPERAND_IMM3P9 :
2985 fields->f_ivc2_3u9 = value;
2986 break;
2987 case MEP_OPERAND_IMM4P10 :
2988 fields->f_ivc2_4u10 = value;
2989 break;
2990 case MEP_OPERAND_IMM4P4 :
2991 fields->f_ivc2_4u4 = value;
2992 break;
2993 case MEP_OPERAND_IMM4P8 :
2994 fields->f_ivc2_4u8 = value;
2995 break;
2996 case MEP_OPERAND_IMM5P23 :
2997 fields->f_ivc2_5u23 = value;
2998 break;
2999 case MEP_OPERAND_IMM5P3 :
3000 fields->f_ivc2_5u3 = value;
3001 break;
3002 case MEP_OPERAND_IMM5P7 :
3003 fields->f_ivc2_5u7 = value;
3004 break;
3005 case MEP_OPERAND_IMM5P8 :
3006 fields->f_ivc2_5u8 = value;
3007 break;
3008 case MEP_OPERAND_IMM6P2 :
3009 fields->f_ivc2_6u2 = value;
3010 break;
3011 case MEP_OPERAND_IMM6P6 :
3012 fields->f_ivc2_6u6 = value;
3013 break;
3014 case MEP_OPERAND_IMM8P0 :
3015 fields->f_ivc2_8u0 = value;
3016 break;
3017 case MEP_OPERAND_IMM8P20 :
3018 fields->f_ivc2_8u20 = value;
3019 break;
3020 case MEP_OPERAND_IMM8P4 :
3021 fields->f_ivc2_8u4 = value;
3022 break;
3023 case MEP_OPERAND_IVC_X_0_2 :
3024 fields->f_ivc2_2u0 = value;
3025 break;
3026 case MEP_OPERAND_IVC_X_0_3 :
3027 fields->f_ivc2_3u0 = value;
3028 break;
3029 case MEP_OPERAND_IVC_X_0_4 :
3030 fields->f_ivc2_4u0 = value;
3031 break;
3032 case MEP_OPERAND_IVC_X_0_5 :
3033 fields->f_ivc2_5u0 = value;
3034 break;
3035 case MEP_OPERAND_IVC_X_6_1 :
3036 fields->f_ivc2_1u6 = value;
3037 break;
3038 case MEP_OPERAND_IVC_X_6_2 :
3039 fields->f_ivc2_2u6 = value;
3040 break;
3041 case MEP_OPERAND_IVC_X_6_3 :
3042 fields->f_ivc2_3u6 = value;
3043 break;
3044 case MEP_OPERAND_IVC2C3CCRN :
3045 fields->f_ivc2_ccrn_c3 = value;
3046 break;
3047 case MEP_OPERAND_IVC2CCRN :
3048 fields->f_ivc2_ccrn = value;
3049 break;
3050 case MEP_OPERAND_IVC2CRN :
3051 fields->f_ivc2_crnx = value;
3052 break;
3053 case MEP_OPERAND_IVC2RM :
3054 fields->f_ivc2_crm = value;
3055 break;
3056 case MEP_OPERAND_LO :
3057 break;
3058 case MEP_OPERAND_LP :
3059 break;
3060 case MEP_OPERAND_MB0 :
3061 break;
3062 case MEP_OPERAND_MB1 :
3063 break;
3064 case MEP_OPERAND_ME0 :
3065 break;
3066 case MEP_OPERAND_ME1 :
3067 break;
3068 case MEP_OPERAND_NPC :
3069 break;
3070 case MEP_OPERAND_OPT :
3071 break;
3072 case MEP_OPERAND_PCABS24A2 :
3073 fields->f_24u5a2n = value;
3074 break;
3075 case MEP_OPERAND_PCREL12A2 :
3076 fields->f_12s4a2 = value;
3077 break;
3078 case MEP_OPERAND_PCREL17A2 :
3079 fields->f_17s16a2 = value;
3080 break;
3081 case MEP_OPERAND_PCREL24A2 :
3082 fields->f_24s5a2n = value;
3083 break;
3084 case MEP_OPERAND_PCREL8A2 :
3085 fields->f_8s8a2 = value;
3086 break;
3087 case MEP_OPERAND_PSW :
3088 break;
3089 case MEP_OPERAND_R0 :
3090 break;
3091 case MEP_OPERAND_R1 :
3092 break;
3093 case MEP_OPERAND_RL :
3094 fields->f_rl = value;
3095 break;
3096 case MEP_OPERAND_RL5 :
3097 fields->f_rl5 = value;
3098 break;
3099 case MEP_OPERAND_RM :
3100 fields->f_rm = value;
3101 break;
3102 case MEP_OPERAND_RMA :
3103 fields->f_rm = value;
3104 break;
3105 case MEP_OPERAND_RN :
3106 fields->f_rn = value;
3107 break;
3108 case MEP_OPERAND_RN3 :
3109 fields->f_rn3 = value;
3110 break;
3111 case MEP_OPERAND_RN3C :
3112 fields->f_rn3 = value;
3113 break;
3114 case MEP_OPERAND_RN3L :
3115 fields->f_rn3 = value;
3116 break;
3117 case MEP_OPERAND_RN3S :
3118 fields->f_rn3 = value;
3119 break;
3120 case MEP_OPERAND_RN3UC :
3121 fields->f_rn3 = value;
3122 break;
3123 case MEP_OPERAND_RN3UL :
3124 fields->f_rn3 = value;
3125 break;
3126 case MEP_OPERAND_RN3US :
3127 fields->f_rn3 = value;
3128 break;
3129 case MEP_OPERAND_RNC :
3130 fields->f_rn = value;
3131 break;
3132 case MEP_OPERAND_RNL :
3133 fields->f_rn = value;
3134 break;
3135 case MEP_OPERAND_RNS :
3136 fields->f_rn = value;
3137 break;
3138 case MEP_OPERAND_RNUC :
3139 fields->f_rn = value;
3140 break;
3141 case MEP_OPERAND_RNUL :
3142 fields->f_rn = value;
3143 break;
3144 case MEP_OPERAND_RNUS :
3145 fields->f_rn = value;
3146 break;
3147 case MEP_OPERAND_SAR :
3148 break;
3149 case MEP_OPERAND_SDISP16 :
3150 fields->f_16s16 = value;
3151 break;
3152 case MEP_OPERAND_SIMM16 :
3153 fields->f_16s16 = value;
3154 break;
3155 case MEP_OPERAND_SIMM16P0 :
3156 fields->f_ivc2_simm16p0 = value;
3157 break;
3158 case MEP_OPERAND_SIMM6 :
3159 fields->f_6s8 = value;
3160 break;
3161 case MEP_OPERAND_SIMM8 :
3162 fields->f_8s8 = value;
3163 break;
3164 case MEP_OPERAND_SIMM8P0 :
3165 fields->f_ivc2_8s0 = value;
3166 break;
3167 case MEP_OPERAND_SIMM8P20 :
3168 fields->f_ivc2_8s20 = value;
3169 break;
3170 case MEP_OPERAND_SIMM8P4 :
3171 fields->f_ivc2_8s4 = value;
3172 break;
3173 case MEP_OPERAND_SP :
3174 break;
3175 case MEP_OPERAND_SPR :
3176 break;
3177 case MEP_OPERAND_TP :
3178 break;
3179 case MEP_OPERAND_TPR :
3180 break;
3181 case MEP_OPERAND_UDISP2 :
3182 fields->f_2u6 = value;
3183 break;
3184 case MEP_OPERAND_UDISP7 :
3185 fields->f_7u9 = value;
3186 break;
3187 case MEP_OPERAND_UDISP7A2 :
3188 fields->f_7u9a2 = value;
3189 break;
3190 case MEP_OPERAND_UDISP7A4 :
3191 fields->f_7u9a4 = value;
3192 break;
3193 case MEP_OPERAND_UIMM16 :
3194 fields->f_16u16 = value;
3195 break;
3196 case MEP_OPERAND_UIMM2 :
3197 fields->f_2u10 = value;
3198 break;
3199 case MEP_OPERAND_UIMM24 :
3200 fields->f_24u8n = value;
3201 break;
3202 case MEP_OPERAND_UIMM3 :
3203 fields->f_3u5 = value;
3204 break;
3205 case MEP_OPERAND_UIMM4 :
3206 fields->f_4u8 = value;
3207 break;
3208 case MEP_OPERAND_UIMM5 :
3209 fields->f_5u8 = value;
3210 break;
3211 case MEP_OPERAND_UIMM7A4 :
3212 fields->f_7u9a4 = value;
3213 break;
3214 case MEP_OPERAND_ZERO :
3215 break;
3217 default :
3218 /* xgettext:c-format */
3219 fprintf (stderr, _("Unrecognized field %d while setting vma operand.\n"),
3220 opindex);
3221 abort ();
3225 /* Function to call before using the instruction builder tables. */
3227 void
3228 mep_cgen_init_ibld_table (CGEN_CPU_DESC cd)
3230 cd->insert_handlers = & mep_cgen_insert_handlers[0];
3231 cd->extract_handlers = & mep_cgen_extract_handlers[0];
3233 cd->insert_operand = mep_cgen_insert_operand;
3234 cd->extract_operand = mep_cgen_extract_operand;
3236 cd->get_int_operand = mep_cgen_get_int_operand;
3237 cd->set_int_operand = mep_cgen_set_int_operand;
3238 cd->get_vma_operand = mep_cgen_get_vma_operand;
3239 cd->set_vma_operand = mep_cgen_set_vma_operand;