<gas changes>
[deliverable/binutils-gdb.git] / opcodes / mep-ibld.c
CommitLineData
bd2f2e55
DB
1/* Instruction building/extraction support for mep. -*- C -*-
2
3 THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator.
4 - the resultant file is machine generated, cgen-ibld.in isn't
5
6f3b91a6
AM
6 Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005, 2006, 2007,
7 2008 Free Software Foundation, Inc.
bd2f2e55 8
9b201bb5 9 This file is part of libopcodes.
bd2f2e55 10
9b201bb5 11 This library is free software; you can redistribute it and/or modify
bd2f2e55 12 it under the terms of the GNU General Public License as published by
9b201bb5 13 the Free Software Foundation; either version 3, or (at your option)
bd2f2e55
DB
14 any later version.
15
9b201bb5
NC
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.
bd2f2e55
DB
20
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. */
24
25/* ??? Eventually more and more of this stuff can go to cpu-independent files.
26 Keep that in mind. */
27
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"
38
39#undef min
40#define min(a,b) ((a) < (b) ? (a) : (b))
41#undef max
42#define max(a,b) ((a) > (b) ? (a) : (b))
43
44/* Used by the ifield rtx function. */
45#define FLD(f) (fields->f)
46
47static 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);
50static const char * insert_insn_normal
51 (CGEN_CPU_DESC, const CGEN_INSN *,
52 CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma);
53static 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 *);
57static 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
61static 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
65static CGEN_INLINE void insert_1
66 (CGEN_CPU_DESC, unsigned long, int, int, int, unsigned char *);
67static CGEN_INLINE int fill_cache
68 (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, int, int, bfd_vma);
69static CGEN_INLINE long extract_1
70 (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, int, int, int, unsigned char *, bfd_vma);
71#endif
72\f
73/* Operand insertion. */
74
75#if ! CGEN_INT_INSN_P
76
77/* Subroutine of insert_normal. */
78
79static CGEN_INLINE void
80insert_1 (CGEN_CPU_DESC cd,
81 unsigned long value,
82 int start,
83 int length,
84 int word_length,
85 unsigned char *bufp)
86{
87 unsigned long x,mask;
88 int shift;
89
90 x = cgen_get_insn_value (cd, bufp, word_length);
91
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);
99
100 cgen_put_insn_value (cd, bufp, word_length, (bfd_vma) x);
101}
102
103#endif /* ! CGEN_INT_INSN_P */
104
105/* Default insertion routine.
106
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.
113
114 The result is an error message or NULL if success. */
115
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. */
120
121static const char *
122insert_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)
131{
132 static char errbuf[100];
133 /* Written this way to avoid undefined behaviour. */
134 unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
135
136 /* If LENGTH is zero, this operand doesn't contribute to the value. */
137 if (length == 0)
138 return NULL;
139
140 if (word_length > 32)
141 abort ();
142
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)
146 {
147 if (word_offset == 0
148 && word_length > total_length)
149 word_length = total_length;
150 }
151
152 /* Ensure VALUE will fit. */
153 if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGN_OPT))
154 {
155 long minval = - (1L << (length - 1));
156 unsigned long maxval = mask;
157
158 if ((value > 0 && (unsigned long) value > maxval)
159 || value < minval)
160 {
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;
166 }
167 }
168 else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED))
169 {
170 unsigned long maxval = mask;
171 unsigned long val = (unsigned long) value;
172
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;
179
180 if (val > maxval)
181 {
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;
187 }
188 }
189 else
190 {
191 if (! cgen_signed_overflow_ok_p (cd))
192 {
193 long minval = - (1L << (length - 1));
194 long maxval = (1L << (length - 1)) - 1;
195
196 if (value < minval || value > maxval)
197 {
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;
203 }
204 }
205 }
206
207#if CGEN_INT_INSN_P
208
209 {
210 int shift;
211
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);
217 }
218
219#else /* ! CGEN_INT_INSN_P */
220
221 {
222 unsigned char *bufp = (unsigned char *) buffer + word_offset / 8;
223
224 insert_1 (cd, value, start, length, word_length, bufp);
225 }
226
227#endif /* ! CGEN_INT_INSN_P */
228
229 return NULL;
230}
231
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. */
238
239static const char *
240insert_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)
245{
246 const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
247 unsigned long value;
248 const CGEN_SYNTAX_CHAR_TYPE * syn;
249
250 CGEN_INIT_INSERT (cd);
251 value = CGEN_INSN_BASE_VALUE (insn);
252
253 /* If we're recording insns as numbers (rather than a string of bytes),
254 target byte order handling is deferred until later. */
255
256#if CGEN_INT_INSN_P
257
258 put_insn_int_value (cd, buffer, cd->base_insn_bitsize,
259 CGEN_FIELDS_BITSIZE (fields), value);
260
261#else
262
263 cgen_put_insn_value (cd, buffer, min ((unsigned) cd->base_insn_bitsize,
264 (unsigned) CGEN_FIELDS_BITSIZE (fields)),
265 value);
266
267#endif /* ! CGEN_INT_INSN_P */
268
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. */
273
274 for (syn = CGEN_SYNTAX_STRING (syntax); * syn; ++ syn)
275 {
276 const char *errmsg;
277
278 if (CGEN_SYNTAX_CHAR_P (* syn))
279 continue;
280
281 errmsg = (* cd->insert_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
282 fields, buffer, pc);
283 if (errmsg)
284 return errmsg;
285 }
286
287 return NULL;
288}
289
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. */
293
294static void
295put_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)
300{
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
306 {
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;
310
311 *buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
312 }
313}
314#endif
315\f
316/* Operand extraction. */
317
318#if ! CGEN_INT_INSN_P
319
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. */
325
326static CGEN_INLINE int
327fill_cache (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
328 CGEN_EXTRACT_INFO *ex_info,
329 int offset,
330 int bytes,
331 bfd_vma pc)
332{
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;
337
338 /* First do a quick check. */
339 mask = (1 << bytes) - 1;
340 if (((ex_info->valid >> offset) & mask) == mask)
341 return 1;
342
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;
347
348 if (bytes)
349 {
350 int status;
351
352 pc += offset;
353 status = (*info->read_memory_func)
354 (pc, ex_info->insn_bytes + offset, bytes, info);
355
356 if (status != 0)
357 {
358 (*info->memory_error_func) (status, pc, info);
359 return 0;
360 }
361
362 ex_info->valid |= ((1 << bytes) - 1) << offset;
363 }
364
365 return 1;
366}
367
368/* Subroutine of extract_normal. */
369
370static CGEN_INLINE long
371extract_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)
378{
379 unsigned long x;
380 int shift;
381
382 x = cgen_get_insn_value (cd, bufp, word_length);
383
384 if (CGEN_INSN_LSB0_P)
385 shift = (start + 1) - length;
386 else
387 shift = (word_length - (start + length));
388 return x >> shift;
389}
390
391#endif /* ! CGEN_INT_INSN_P */
392
393/* Default extraction routine.
394
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.
405
406 Returns 1 for success, 0 for failure. */
407
408/* ??? The return code isn't properly used. wip. */
409
410/* ??? This doesn't handle bfd_vma's. Create another function when
411 necessary. */
412
413static int
414extract_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)
433{
434 long value, mask;
435
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)
439 {
440 *valuep = 0;
441 return 1;
442 }
443
444 if (word_length > 32)
445 abort ();
446
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)
450 {
451 if (word_offset + word_length > total_length)
452 word_length = total_length - word_offset;
453 }
454
455 /* Does the value reside in INSN_VALUE, and at the right alignment? */
456
457 if (CGEN_INT_INSN_P || (word_offset == 0 && word_length == total_length))
458 {
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));
463 }
464
465#if ! CGEN_INT_INSN_P
466
467 else
468 {
469 unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
470
471 if (word_length > 32)
472 abort ();
473
474 if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
475 return 0;
476
477 value = extract_1 (cd, ex_info, start, length, word_length, bufp, pc);
478 }
479
480#endif /* ! CGEN_INT_INSN_P */
481
482 /* Written this way to avoid undefined behaviour. */
483 mask = (((1L << (length - 1)) - 1) << 1) | 1;
484
485 value &= mask;
486 /* sign extend? */
487 if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)
488 && (value & (1L << (length - 1))))
489 value |= ~mask;
490
491 *valuep = value;
492
493 return 1;
494}
495
496/* Default insn extractor.
497
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). */
504
505static int
506extract_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)
512{
513 const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
514 const CGEN_SYNTAX_CHAR_TYPE *syn;
515
516 CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn);
517
518 CGEN_INIT_EXTRACT (cd);
519
520 for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn)
521 {
522 int length;
523
524 if (CGEN_SYNTAX_CHAR_P (*syn))
525 continue;
526
527 length = (* cd->extract_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
528 ex_info, insn_value, fields, pc);
529 if (length <= 0)
530 return length;
531 }
532
533 /* We recognized and successfully extracted this insn. */
534 return CGEN_INSN_BITSIZE (insn);
535}
536\f
537/* Machine generated code added here. */
538
539const char * mep_cgen_insert_operand
540 (CGEN_CPU_DESC, int, CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma);
541
542/* Main entry point for operand insertion.
543
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.
550
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. */
555
556const char *
557mep_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)
562{
563 const char * errmsg = NULL;
564 unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
565
566 switch (opindex)
567 {
568 case MEP_OPERAND_ADDR24A4 :
569 {
570{
571 FLD (f_24u8a4n_hi) = ((unsigned int) (FLD (f_24u8a4n)) >> (8));
572 FLD (f_24u8a4n_lo) = ((unsigned int) (((FLD (f_24u8a4n)) & (252))) >> (2));
573}
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;
580 }
581 break;
40493983
DD
582 case MEP_OPERAND_C5RMUIMM20 :
583 {
584{
585 FLD (f_c5_rm) = ((unsigned int) (FLD (f_c5_rmuimm20)) >> (16));
586 FLD (f_c5_16u16) = ((FLD (f_c5_rmuimm20)) & (65535));
587}
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;
594 }
595 break;
596 case MEP_OPERAND_C5RNMUIMM24 :
597 {
598{
599 FLD (f_c5_rnm) = ((unsigned int) (FLD (f_c5_rnmuimm24)) >> (16));
600 FLD (f_c5_16u16) = ((FLD (f_c5_rnmuimm24)) & (65535));
601}
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;
608 }
609 break;
bd2f2e55
DB
610 case MEP_OPERAND_CALLNUM :
611 {
612{
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));
617}
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;
630 }
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 :
636 {
637{
638 FLD (f_ccrn_hi) = ((((unsigned int) (FLD (f_ccrn)) >> (4))) & (3));
639 FLD (f_ccrn_lo) = ((FLD (f_ccrn)) & (15));
640}
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;
647 }
648 break;
40493983
DD
649 case MEP_OPERAND_CDISP10 :
650 {
651 long value = fields->f_cdisp10;
45be3704
DD
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);
40493983 654 }
bd2f2e55 655 break;
40493983 656 case MEP_OPERAND_CDISP10A2 :
bd2f2e55 657 {
40493983 658 long value = fields->f_cdisp10;
45be3704
DD
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);
bd2f2e55
DB
661 }
662 break;
40493983 663 case MEP_OPERAND_CDISP10A4 :
bd2f2e55 664 {
40493983 665 long value = fields->f_cdisp10;
45be3704
DD
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);
bd2f2e55
DB
668 }
669 break;
40493983 670 case MEP_OPERAND_CDISP10A8 :
bd2f2e55 671 {
40493983 672 long value = fields->f_cdisp10;
45be3704
DD
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);
bd2f2e55
DB
675 }
676 break;
40493983 677 case MEP_OPERAND_CDISP12 :
45be3704 678 errmsg = insert_normal (cd, fields->f_12s20, 0|(1<<CGEN_IFLD_SIGNED), 0, 20, 12, 32, total_length, buffer);
40493983 679 break;
bd2f2e55
DB
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 :
690 {
691{
692 FLD (f_24u4n_hi) = ((unsigned int) (FLD (f_24u4n)) >> (16));
693 FLD (f_24u4n_lo) = ((FLD (f_24u4n)) & (65535));
694}
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;
701 }
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 :
712 {
713{
714 FLD (f_crnx_lo) = ((FLD (f_crnx)) & (15));
715 FLD (f_crnx_hi) = ((unsigned int) (FLD (f_crnx)) >> (4));
716}
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;
723 }
724 break;
725 case MEP_OPERAND_CRNX64 :
726 {
727{
728 FLD (f_crnx_lo) = ((FLD (f_crnx)) & (15));
729 FLD (f_crnx_hi) = ((unsigned int) (FLD (f_crnx)) >> (4));
730}
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;
737 }
738 break;
3526b680
DD
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;
bd2f2e55
DB
757 case MEP_OPERAND_CSRN :
758 {
759{
760 FLD (f_csrn_lo) = ((FLD (f_csrn)) & (15));
761 FLD (f_csrn_hi) = ((unsigned int) (FLD (f_csrn)) >> (4));
762}
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;
769 }
770 break;
771 case MEP_OPERAND_CSRN_IDX :
772 {
773{
774 FLD (f_csrn_lo) = ((FLD (f_csrn)) & (15));
775 FLD (f_csrn_hi) = ((unsigned int) (FLD (f_csrn)) >> (4));
776}
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;
783 }
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;
bd2f2e55
DB
793 case MEP_OPERAND_HI :
794 break;
3526b680
DD
795 case MEP_OPERAND_IMM16P0 :
796 {
797{
798 FLD (f_ivc2_8u0) = ((((unsigned int) (FLD (f_ivc2_imm16p0)) >> (8))) & (255));
799 FLD (f_ivc2_8u20) = ((FLD (f_ivc2_imm16p0)) & (255));
800}
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;
807 }
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_IVC2CCRN :
882 {
883{
884 FLD (f_ivc2_ccrn_h2) = ((((unsigned int) (FLD (f_ivc2_ccrn)) >> (4))) & (3));
885 FLD (f_ivc2_ccrn_lo) = ((FLD (f_ivc2_ccrn)) & (15));
886}
887 errmsg = insert_normal (cd, fields->f_ivc2_ccrn_h2, 0, 0, 20, 2, 32, total_length, buffer);
888 if (errmsg)
889 break;
890 errmsg = insert_normal (cd, fields->f_ivc2_ccrn_lo, 0, 0, 0, 4, 32, total_length, buffer);
891 if (errmsg)
892 break;
893 }
894 break;
895 case MEP_OPERAND_IVC2CRN :
896 {
897{
898 FLD (f_ivc2_ccrn_h1) = ((((unsigned int) (FLD (f_ivc2_crnx)) >> (4))) & (1));
899 FLD (f_ivc2_ccrn_lo) = ((FLD (f_ivc2_crnx)) & (15));
900}
901 errmsg = insert_normal (cd, fields->f_ivc2_ccrn_h1, 0, 0, 20, 1, 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;
907 }
908 break;
909 case MEP_OPERAND_IVC2RM :
910 errmsg = insert_normal (cd, fields->f_ivc2_crm, 0, 0, 4, 4, 32, total_length, buffer);
911 break;
bd2f2e55
DB
912 case MEP_OPERAND_LO :
913 break;
914 case MEP_OPERAND_LP :
915 break;
916 case MEP_OPERAND_MB0 :
917 break;
918 case MEP_OPERAND_MB1 :
919 break;
920 case MEP_OPERAND_ME0 :
921 break;
922 case MEP_OPERAND_ME1 :
923 break;
924 case MEP_OPERAND_NPC :
925 break;
926 case MEP_OPERAND_OPT :
927 break;
928 case MEP_OPERAND_PCABS24A2 :
929 {
930{
931 FLD (f_24u5a2n_lo) = ((unsigned int) (((FLD (f_24u5a2n)) & (255))) >> (1));
932 FLD (f_24u5a2n_hi) = ((unsigned int) (FLD (f_24u5a2n)) >> (8));
933}
934 errmsg = insert_normal (cd, fields->f_24u5a2n_hi, 0, 0, 16, 16, 32, total_length, buffer);
935 if (errmsg)
936 break;
937 errmsg = insert_normal (cd, fields->f_24u5a2n_lo, 0, 0, 5, 7, 32, total_length, buffer);
938 if (errmsg)
939 break;
940 }
941 break;
942 case MEP_OPERAND_PCREL12A2 :
943 {
944 long value = fields->f_12s4a2;
945 value = ((int) (((value) - (pc))) >> (1));
946 errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 4, 11, 32, total_length, buffer);
947 }
948 break;
949 case MEP_OPERAND_PCREL17A2 :
950 {
951 long value = fields->f_17s16a2;
952 value = ((int) (((value) - (pc))) >> (1));
953 errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 16, 16, 32, total_length, buffer);
954 }
955 break;
956 case MEP_OPERAND_PCREL24A2 :
957 {
958{
959 FLD (f_24s5a2n) = ((FLD (f_24s5a2n)) - (pc));
960 FLD (f_24s5a2n_lo) = ((unsigned int) (((FLD (f_24s5a2n)) & (254))) >> (1));
961 FLD (f_24s5a2n_hi) = ((int) (FLD (f_24s5a2n)) >> (8));
962}
963 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);
964 if (errmsg)
965 break;
966 errmsg = insert_normal (cd, fields->f_24s5a2n_lo, 0|(1<<CGEN_IFLD_PCREL_ADDR), 0, 5, 7, 32, total_length, buffer);
967 if (errmsg)
968 break;
969 }
970 break;
971 case MEP_OPERAND_PCREL8A2 :
972 {
973 long value = fields->f_8s8a2;
974 value = ((int) (((value) - (pc))) >> (1));
975 errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 8, 7, 32, total_length, buffer);
976 }
977 break;
978 case MEP_OPERAND_PSW :
979 break;
980 case MEP_OPERAND_R0 :
981 break;
982 case MEP_OPERAND_R1 :
983 break;
984 case MEP_OPERAND_RL :
985 errmsg = insert_normal (cd, fields->f_rl, 0, 0, 12, 4, 32, total_length, buffer);
986 break;
40493983
DD
987 case MEP_OPERAND_RL5 :
988 errmsg = insert_normal (cd, fields->f_rl5, 0, 0, 20, 4, 32, total_length, buffer);
989 break;
bd2f2e55
DB
990 case MEP_OPERAND_RM :
991 errmsg = insert_normal (cd, fields->f_rm, 0, 0, 8, 4, 32, total_length, buffer);
992 break;
993 case MEP_OPERAND_RMA :
994 errmsg = insert_normal (cd, fields->f_rm, 0, 0, 8, 4, 32, total_length, buffer);
995 break;
996 case MEP_OPERAND_RN :
997 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
998 break;
999 case MEP_OPERAND_RN3 :
1000 errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
1001 break;
1002 case MEP_OPERAND_RN3C :
1003 errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
1004 break;
1005 case MEP_OPERAND_RN3L :
1006 errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
1007 break;
1008 case MEP_OPERAND_RN3S :
1009 errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
1010 break;
1011 case MEP_OPERAND_RN3UC :
1012 errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
1013 break;
1014 case MEP_OPERAND_RN3UL :
1015 errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
1016 break;
1017 case MEP_OPERAND_RN3US :
1018 errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
1019 break;
1020 case MEP_OPERAND_RNC :
1021 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
1022 break;
1023 case MEP_OPERAND_RNL :
1024 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
1025 break;
1026 case MEP_OPERAND_RNS :
1027 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
1028 break;
1029 case MEP_OPERAND_RNUC :
1030 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
1031 break;
1032 case MEP_OPERAND_RNUL :
1033 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
1034 break;
1035 case MEP_OPERAND_RNUS :
1036 errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
1037 break;
1038 case MEP_OPERAND_SAR :
1039 break;
1040 case MEP_OPERAND_SDISP16 :
1041 errmsg = insert_normal (cd, fields->f_16s16, 0|(1<<CGEN_IFLD_SIGNED), 0, 16, 16, 32, total_length, buffer);
1042 break;
1043 case MEP_OPERAND_SIMM16 :
1044 errmsg = insert_normal (cd, fields->f_16s16, 0|(1<<CGEN_IFLD_SIGNED), 0, 16, 16, 32, total_length, buffer);
1045 break;
3526b680
DD
1046 case MEP_OPERAND_SIMM16P0 :
1047 {
1048{
1049 FLD (f_ivc2_8u0) = ((((unsigned int) (FLD (f_ivc2_simm16p0)) >> (8))) & (255));
1050 FLD (f_ivc2_8u20) = ((FLD (f_ivc2_simm16p0)) & (255));
1051}
1052 errmsg = insert_normal (cd, fields->f_ivc2_8u0, 0, 0, 0, 8, 32, total_length, buffer);
1053 if (errmsg)
1054 break;
1055 errmsg = insert_normal (cd, fields->f_ivc2_8u20, 0, 0, 20, 8, 32, total_length, buffer);
1056 if (errmsg)
1057 break;
1058 }
1059 break;
bd2f2e55
DB
1060 case MEP_OPERAND_SIMM6 :
1061 errmsg = insert_normal (cd, fields->f_6s8, 0|(1<<CGEN_IFLD_SIGNED), 0, 8, 6, 32, total_length, buffer);
1062 break;
1063 case MEP_OPERAND_SIMM8 :
1064 errmsg = insert_normal (cd, fields->f_8s8, 0|(1<<CGEN_IFLD_SIGNED), 0, 8, 8, 32, total_length, buffer);
1065 break;
3526b680
DD
1066 case MEP_OPERAND_SIMM8P0 :
1067 errmsg = insert_normal (cd, fields->f_ivc2_8s0, 0|(1<<CGEN_IFLD_SIGNED), 0, 0, 8, 32, total_length, buffer);
1068 break;
1069 case MEP_OPERAND_SIMM8P4 :
1070 errmsg = insert_normal (cd, fields->f_ivc2_8s4, 0|(1<<CGEN_IFLD_SIGNED), 0, 4, 8, 32, total_length, buffer);
1071 break;
bd2f2e55
DB
1072 case MEP_OPERAND_SP :
1073 break;
1074 case MEP_OPERAND_SPR :
1075 break;
1076 case MEP_OPERAND_TP :
1077 break;
1078 case MEP_OPERAND_TPR :
1079 break;
1080 case MEP_OPERAND_UDISP2 :
1081 errmsg = insert_normal (cd, fields->f_2u6, 0, 0, 6, 2, 32, total_length, buffer);
1082 break;
1083 case MEP_OPERAND_UDISP7 :
1084 errmsg = insert_normal (cd, fields->f_7u9, 0, 0, 9, 7, 32, total_length, buffer);
1085 break;
1086 case MEP_OPERAND_UDISP7A2 :
1087 {
1088 long value = fields->f_7u9a2;
1089 value = ((unsigned int) (value) >> (1));
1090 errmsg = insert_normal (cd, value, 0, 0, 9, 6, 32, total_length, buffer);
1091 }
1092 break;
1093 case MEP_OPERAND_UDISP7A4 :
1094 {
1095 long value = fields->f_7u9a4;
1096 value = ((unsigned int) (value) >> (2));
1097 errmsg = insert_normal (cd, value, 0, 0, 9, 5, 32, total_length, buffer);
1098 }
1099 break;
1100 case MEP_OPERAND_UIMM16 :
1101 errmsg = insert_normal (cd, fields->f_16u16, 0, 0, 16, 16, 32, total_length, buffer);
1102 break;
1103 case MEP_OPERAND_UIMM2 :
1104 errmsg = insert_normal (cd, fields->f_2u10, 0, 0, 10, 2, 32, total_length, buffer);
1105 break;
1106 case MEP_OPERAND_UIMM24 :
1107 {
1108{
1109 FLD (f_24u8n_hi) = ((unsigned int) (FLD (f_24u8n)) >> (8));
1110 FLD (f_24u8n_lo) = ((FLD (f_24u8n)) & (255));
1111}
1112 errmsg = insert_normal (cd, fields->f_24u8n_hi, 0, 0, 16, 16, 32, total_length, buffer);
1113 if (errmsg)
1114 break;
1115 errmsg = insert_normal (cd, fields->f_24u8n_lo, 0, 0, 8, 8, 32, total_length, buffer);
1116 if (errmsg)
1117 break;
1118 }
1119 break;
1120 case MEP_OPERAND_UIMM3 :
1121 errmsg = insert_normal (cd, fields->f_3u5, 0, 0, 5, 3, 32, total_length, buffer);
1122 break;
1123 case MEP_OPERAND_UIMM4 :
1124 errmsg = insert_normal (cd, fields->f_4u8, 0, 0, 8, 4, 32, total_length, buffer);
1125 break;
1126 case MEP_OPERAND_UIMM5 :
1127 errmsg = insert_normal (cd, fields->f_5u8, 0, 0, 8, 5, 32, total_length, buffer);
1128 break;
1129 case MEP_OPERAND_UIMM7A4 :
1130 {
1131 long value = fields->f_7u9a4;
1132 value = ((unsigned int) (value) >> (2));
1133 errmsg = insert_normal (cd, value, 0, 0, 9, 5, 32, total_length, buffer);
1134 }
1135 break;
1136 case MEP_OPERAND_ZERO :
1137 break;
1138
1139 default :
1140 /* xgettext:c-format */
1141 fprintf (stderr, _("Unrecognized field %d while building insn.\n"),
1142 opindex);
1143 abort ();
1144 }
1145
1146 return errmsg;
1147}
1148
1149int mep_cgen_extract_operand
1150 (CGEN_CPU_DESC, int, CGEN_EXTRACT_INFO *, CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma);
1151
1152/* Main entry point for operand extraction.
1153 The result is <= 0 for error, >0 for success.
1154 ??? Actual values aren't well defined right now.
1155
1156 This function is basically just a big switch statement. Earlier versions
1157 used tables to look up the function to use, but
1158 - if the table contains both assembler and disassembler functions then
1159 the disassembler contains much of the assembler and vice-versa,
1160 - there's a lot of inlining possibilities as things grow,
1161 - using a switch statement avoids the function call overhead.
1162
1163 This function could be moved into `print_insn_normal', but keeping it
1164 separate makes clear the interface between `print_insn_normal' and each of
1165 the handlers. */
1166
1167int
1168mep_cgen_extract_operand (CGEN_CPU_DESC cd,
1169 int opindex,
1170 CGEN_EXTRACT_INFO *ex_info,
1171 CGEN_INSN_INT insn_value,
1172 CGEN_FIELDS * fields,
1173 bfd_vma pc)
1174{
1175 /* Assume success (for those operands that are nops). */
1176 int length = 1;
1177 unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
1178
1179 switch (opindex)
1180 {
1181 case MEP_OPERAND_ADDR24A4 :
1182 {
1183 length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_24u8a4n_hi);
1184 if (length <= 0) break;
1185 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 6, 32, total_length, pc, & fields->f_24u8a4n_lo);
1186 if (length <= 0) break;
1187 FLD (f_24u8a4n) = ((((FLD (f_24u8a4n_hi)) << (8))) | (((FLD (f_24u8a4n_lo)) << (2))));
1188 }
1189 break;
40493983
DD
1190 case MEP_OPERAND_C5RMUIMM20 :
1191 {
1192 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_c5_rm);
1193 if (length <= 0) break;
1194 length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_c5_16u16);
1195 if (length <= 0) break;
1196{
1197 FLD (f_c5_rmuimm20) = ((FLD (f_c5_16u16)) | (((FLD (f_c5_rm)) << (16))));
1198}
1199 }
1200 break;
1201 case MEP_OPERAND_C5RNMUIMM24 :
1202 {
1203 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 8, 32, total_length, pc, & fields->f_c5_rnm);
1204 if (length <= 0) break;
1205 length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_c5_16u16);
1206 if (length <= 0) break;
1207{
1208 FLD (f_c5_rnmuimm24) = ((FLD (f_c5_16u16)) | (((FLD (f_c5_rnm)) << (16))));
1209}
1210 }
1211 break;
bd2f2e55
DB
1212 case MEP_OPERAND_CALLNUM :
1213 {
1214 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 1, 32, total_length, pc, & fields->f_5);
1215 if (length <= 0) break;
1216 length = extract_normal (cd, ex_info, insn_value, 0, 0, 6, 1, 32, total_length, pc, & fields->f_6);
1217 if (length <= 0) break;
1218 length = extract_normal (cd, ex_info, insn_value, 0, 0, 7, 1, 32, total_length, pc, & fields->f_7);
1219 if (length <= 0) break;
1220 length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 1, 32, total_length, pc, & fields->f_11);
1221 if (length <= 0) break;
1222 FLD (f_callnum) = ((((FLD (f_5)) << (3))) | (((((FLD (f_6)) << (2))) | (((((FLD (f_7)) << (1))) | (FLD (f_11)))))));
1223 }
1224 break;
1225 case MEP_OPERAND_CCCC :
1226 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_rm);
1227 break;
1228 case MEP_OPERAND_CCRN :
1229 {
1230 length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 2, 32, total_length, pc, & fields->f_ccrn_hi);
1231 if (length <= 0) break;
1232 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_ccrn_lo);
1233 if (length <= 0) break;
1234 FLD (f_ccrn) = ((((FLD (f_ccrn_hi)) << (4))) | (FLD (f_ccrn_lo)));
1235 }
1236 break;
40493983
DD
1237 case MEP_OPERAND_CDISP10 :
1238 {
1239 long value;
45be3704
DD
1240 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 22, 10, 32, total_length, pc, & value);
1241 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)));
40493983
DD
1242 fields->f_cdisp10 = value;
1243 }
bd2f2e55 1244 break;
40493983 1245 case MEP_OPERAND_CDISP10A2 :
bd2f2e55
DB
1246 {
1247 long value;
45be3704
DD
1248 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 22, 10, 32, total_length, pc, & value);
1249 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)));
40493983 1250 fields->f_cdisp10 = value;
bd2f2e55
DB
1251 }
1252 break;
40493983 1253 case MEP_OPERAND_CDISP10A4 :
bd2f2e55
DB
1254 {
1255 long value;
45be3704
DD
1256 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 22, 10, 32, total_length, pc, & value);
1257 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)));
40493983 1258 fields->f_cdisp10 = value;
bd2f2e55
DB
1259 }
1260 break;
40493983 1261 case MEP_OPERAND_CDISP10A8 :
bd2f2e55
DB
1262 {
1263 long value;
45be3704
DD
1264 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 22, 10, 32, total_length, pc, & value);
1265 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)));
40493983 1266 fields->f_cdisp10 = value;
bd2f2e55
DB
1267 }
1268 break;
40493983 1269 case MEP_OPERAND_CDISP12 :
45be3704 1270 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 20, 12, 32, total_length, pc, & fields->f_12s20);
40493983 1271 break;
bd2f2e55
DB
1272 case MEP_OPERAND_CIMM4 :
1273 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1274 break;
1275 case MEP_OPERAND_CIMM5 :
1276 length = extract_normal (cd, ex_info, insn_value, 0, 0, 24, 5, 32, total_length, pc, & fields->f_5u24);
1277 break;
1278 case MEP_OPERAND_CODE16 :
1279 length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_16u16);
1280 break;
1281 case MEP_OPERAND_CODE24 :
1282 {
1283 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 8, 32, total_length, pc, & fields->f_24u4n_hi);
1284 if (length <= 0) break;
1285 length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_24u4n_lo);
1286 if (length <= 0) break;
1287 FLD (f_24u4n) = ((((FLD (f_24u4n_hi)) << (16))) | (FLD (f_24u4n_lo)));
1288 }
1289 break;
1290 case MEP_OPERAND_CP_FLAG :
1291 break;
1292 case MEP_OPERAND_CRN :
1293 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_crn);
1294 break;
1295 case MEP_OPERAND_CRN64 :
1296 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_crn);
1297 break;
1298 case MEP_OPERAND_CRNX :
1299 {
1300 length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 1, 32, total_length, pc, & fields->f_crnx_hi);
1301 if (length <= 0) break;
1302 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_crnx_lo);
1303 if (length <= 0) break;
1304 FLD (f_crnx) = ((((FLD (f_crnx_hi)) << (4))) | (FLD (f_crnx_lo)));
1305 }
1306 break;
1307 case MEP_OPERAND_CRNX64 :
1308 {
1309 length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 1, 32, total_length, pc, & fields->f_crnx_hi);
1310 if (length <= 0) break;
1311 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_crnx_lo);
1312 if (length <= 0) break;
1313 FLD (f_crnx) = ((((FLD (f_crnx_hi)) << (4))) | (FLD (f_crnx_lo)));
1314 }
1315 break;
3526b680
DD
1316 case MEP_OPERAND_CROC :
1317 length = extract_normal (cd, ex_info, insn_value, 0, 0, 7, 5, 32, total_length, pc, & fields->f_ivc2_5u7);
1318 break;
1319 case MEP_OPERAND_CROP :
1320 length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 5, 32, total_length, pc, & fields->f_ivc2_5u23);
1321 break;
1322 case MEP_OPERAND_CRPC :
1323 length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 5, 32, total_length, pc, & fields->f_ivc2_5u26);
1324 break;
1325 case MEP_OPERAND_CRPP :
1326 length = extract_normal (cd, ex_info, insn_value, 0, 0, 18, 5, 32, total_length, pc, & fields->f_ivc2_5u18);
1327 break;
1328 case MEP_OPERAND_CRQC :
1329 length = extract_normal (cd, ex_info, insn_value, 0, 0, 21, 5, 32, total_length, pc, & fields->f_ivc2_5u21);
1330 break;
1331 case MEP_OPERAND_CRQP :
1332 length = extract_normal (cd, ex_info, insn_value, 0, 0, 13, 5, 32, total_length, pc, & fields->f_ivc2_5u13);
1333 break;
bd2f2e55
DB
1334 case MEP_OPERAND_CSRN :
1335 {
1336 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 1, 32, total_length, pc, & fields->f_csrn_hi);
1337 if (length <= 0) break;
1338 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_csrn_lo);
1339 if (length <= 0) break;
1340 FLD (f_csrn) = ((((FLD (f_csrn_hi)) << (4))) | (FLD (f_csrn_lo)));
1341 }
1342 break;
1343 case MEP_OPERAND_CSRN_IDX :
1344 {
1345 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 1, 32, total_length, pc, & fields->f_csrn_hi);
1346 if (length <= 0) break;
1347 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_csrn_lo);
1348 if (length <= 0) break;
1349 FLD (f_csrn) = ((((FLD (f_csrn_hi)) << (4))) | (FLD (f_csrn_lo)));
1350 }
1351 break;
1352 case MEP_OPERAND_DBG :
1353 break;
1354 case MEP_OPERAND_DEPC :
1355 break;
1356 case MEP_OPERAND_EPC :
1357 break;
1358 case MEP_OPERAND_EXC :
1359 break;
bd2f2e55
DB
1360 case MEP_OPERAND_HI :
1361 break;
3526b680
DD
1362 case MEP_OPERAND_IMM16P0 :
1363 {
1364 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 8, 32, total_length, pc, & fields->f_ivc2_8u0);
1365 if (length <= 0) break;
1366 length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 8, 32, total_length, pc, & fields->f_ivc2_8u20);
1367 if (length <= 0) break;
1368{
1369 FLD (f_ivc2_imm16p0) = ((FLD (f_ivc2_8u20)) | (((FLD (f_ivc2_8u0)) << (8))));
1370}
1371 }
1372 break;
1373 case MEP_OPERAND_IMM3P12 :
1374 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_ivc2_3u12);
1375 break;
1376 case MEP_OPERAND_IMM3P25 :
1377 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 3, 32, total_length, pc, & fields->f_ivc2_3u25);
1378 break;
1379 case MEP_OPERAND_IMM3P4 :
1380 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 3, 32, total_length, pc, & fields->f_ivc2_3u4);
1381 break;
1382 case MEP_OPERAND_IMM3P5 :
1383 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_ivc2_3u5);
1384 break;
1385 case MEP_OPERAND_IMM3P9 :
1386 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_ivc2_3u9);
1387 break;
1388 case MEP_OPERAND_IMM4P10 :
1389 length = extract_normal (cd, ex_info, insn_value, 0, 0, 10, 4, 32, total_length, pc, & fields->f_ivc2_4u10);
1390 break;
1391 case MEP_OPERAND_IMM4P4 :
1392 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_ivc2_4u4);
1393 break;
1394 case MEP_OPERAND_IMM4P8 :
1395 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_ivc2_4u8);
1396 break;
1397 case MEP_OPERAND_IMM5P23 :
1398 length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 5, 32, total_length, pc, & fields->f_ivc2_5u23);
1399 break;
1400 case MEP_OPERAND_IMM5P3 :
1401 length = extract_normal (cd, ex_info, insn_value, 0, 0, 3, 5, 32, total_length, pc, & fields->f_ivc2_5u3);
1402 break;
1403 case MEP_OPERAND_IMM5P7 :
1404 length = extract_normal (cd, ex_info, insn_value, 0, 0, 7, 5, 32, total_length, pc, & fields->f_ivc2_5u7);
1405 break;
1406 case MEP_OPERAND_IMM5P8 :
1407 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 5, 32, total_length, pc, & fields->f_ivc2_5u8);
1408 break;
1409 case MEP_OPERAND_IMM6P2 :
1410 length = extract_normal (cd, ex_info, insn_value, 0, 0, 2, 6, 32, total_length, pc, & fields->f_ivc2_6u2);
1411 break;
1412 case MEP_OPERAND_IMM6P6 :
1413 length = extract_normal (cd, ex_info, insn_value, 0, 0, 6, 6, 32, total_length, pc, & fields->f_ivc2_6u6);
1414 break;
1415 case MEP_OPERAND_IMM8P0 :
1416 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 8, 32, total_length, pc, & fields->f_ivc2_8u0);
1417 break;
1418 case MEP_OPERAND_IMM8P20 :
1419 length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 8, 32, total_length, pc, & fields->f_ivc2_8u20);
1420 break;
1421 case MEP_OPERAND_IMM8P4 :
1422 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 8, 32, total_length, pc, & fields->f_ivc2_8u4);
1423 break;
1424 case MEP_OPERAND_IVC_X_0_2 :
1425 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 2, 32, total_length, pc, & fields->f_ivc2_2u0);
1426 break;
1427 case MEP_OPERAND_IVC_X_0_3 :
1428 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 3, 32, total_length, pc, & fields->f_ivc2_3u0);
1429 break;
1430 case MEP_OPERAND_IVC_X_0_4 :
1431 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 4, 32, total_length, pc, & fields->f_ivc2_4u0);
1432 break;
1433 case MEP_OPERAND_IVC_X_0_5 :
1434 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 5, 32, total_length, pc, & fields->f_ivc2_5u0);
1435 break;
1436 case MEP_OPERAND_IVC_X_6_1 :
1437 length = extract_normal (cd, ex_info, insn_value, 0, 0, 6, 1, 32, total_length, pc, & fields->f_ivc2_1u6);
1438 break;
1439 case MEP_OPERAND_IVC_X_6_2 :
1440 length = extract_normal (cd, ex_info, insn_value, 0, 0, 6, 2, 32, total_length, pc, & fields->f_ivc2_2u6);
1441 break;
1442 case MEP_OPERAND_IVC_X_6_3 :
1443 length = extract_normal (cd, ex_info, insn_value, 0, 0, 6, 3, 32, total_length, pc, & fields->f_ivc2_3u6);
1444 break;
1445 case MEP_OPERAND_IVC2CCRN :
1446 {
1447 length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 2, 32, total_length, pc, & fields->f_ivc2_ccrn_h2);
1448 if (length <= 0) break;
1449 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 4, 32, total_length, pc, & fields->f_ivc2_ccrn_lo);
1450 if (length <= 0) break;
1451 FLD (f_ivc2_ccrn) = ((((FLD (f_ivc2_ccrn_h2)) << (4))) | (FLD (f_ivc2_ccrn_lo)));
1452 }
1453 break;
1454 case MEP_OPERAND_IVC2CRN :
1455 {
1456 length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 1, 32, total_length, pc, & fields->f_ivc2_ccrn_h1);
1457 if (length <= 0) break;
1458 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 4, 32, total_length, pc, & fields->f_ivc2_ccrn_lo);
1459 if (length <= 0) break;
1460 FLD (f_ivc2_crnx) = ((((FLD (f_ivc2_ccrn_h1)) << (4))) | (FLD (f_ivc2_ccrn_lo)));
1461 }
1462 break;
1463 case MEP_OPERAND_IVC2RM :
1464 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_ivc2_crm);
1465 break;
bd2f2e55
DB
1466 case MEP_OPERAND_LO :
1467 break;
1468 case MEP_OPERAND_LP :
1469 break;
1470 case MEP_OPERAND_MB0 :
1471 break;
1472 case MEP_OPERAND_MB1 :
1473 break;
1474 case MEP_OPERAND_ME0 :
1475 break;
1476 case MEP_OPERAND_ME1 :
1477 break;
1478 case MEP_OPERAND_NPC :
1479 break;
1480 case MEP_OPERAND_OPT :
1481 break;
1482 case MEP_OPERAND_PCABS24A2 :
1483 {
1484 length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_24u5a2n_hi);
1485 if (length <= 0) break;
1486 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 7, 32, total_length, pc, & fields->f_24u5a2n_lo);
1487 if (length <= 0) break;
1488 FLD (f_24u5a2n) = ((((FLD (f_24u5a2n_hi)) << (8))) | (((FLD (f_24u5a2n_lo)) << (1))));
1489 }
1490 break;
1491 case MEP_OPERAND_PCREL12A2 :
1492 {
1493 long value;
1494 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);
1495 value = ((((value) << (1))) + (pc));
1496 fields->f_12s4a2 = value;
1497 }
1498 break;
1499 case MEP_OPERAND_PCREL17A2 :
1500 {
1501 long value;
1502 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);
1503 value = ((((value) << (1))) + (pc));
1504 fields->f_17s16a2 = value;
1505 }
1506 break;
1507 case MEP_OPERAND_PCREL24A2 :
1508 {
1509 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);
1510 if (length <= 0) break;
1511 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);
1512 if (length <= 0) break;
1513 FLD (f_24s5a2n) = ((((((FLD (f_24s5a2n_hi)) << (8))) | (((FLD (f_24s5a2n_lo)) << (1))))) + (pc));
1514 }
1515 break;
1516 case MEP_OPERAND_PCREL8A2 :
1517 {
1518 long value;
1519 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);
1520 value = ((((value) << (1))) + (pc));
1521 fields->f_8s8a2 = value;
1522 }
1523 break;
1524 case MEP_OPERAND_PSW :
1525 break;
1526 case MEP_OPERAND_R0 :
1527 break;
1528 case MEP_OPERAND_R1 :
1529 break;
1530 case MEP_OPERAND_RL :
1531 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 4, 32, total_length, pc, & fields->f_rl);
1532 break;
40493983
DD
1533 case MEP_OPERAND_RL5 :
1534 length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 4, 32, total_length, pc, & fields->f_rl5);
1535 break;
bd2f2e55
DB
1536 case MEP_OPERAND_RM :
1537 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_rm);
1538 break;
1539 case MEP_OPERAND_RMA :
1540 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_rm);
1541 break;
1542 case MEP_OPERAND_RN :
1543 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1544 break;
1545 case MEP_OPERAND_RN3 :
1546 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1547 break;
1548 case MEP_OPERAND_RN3C :
1549 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1550 break;
1551 case MEP_OPERAND_RN3L :
1552 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1553 break;
1554 case MEP_OPERAND_RN3S :
1555 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1556 break;
1557 case MEP_OPERAND_RN3UC :
1558 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1559 break;
1560 case MEP_OPERAND_RN3UL :
1561 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1562 break;
1563 case MEP_OPERAND_RN3US :
1564 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1565 break;
1566 case MEP_OPERAND_RNC :
1567 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1568 break;
1569 case MEP_OPERAND_RNL :
1570 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1571 break;
1572 case MEP_OPERAND_RNS :
1573 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1574 break;
1575 case MEP_OPERAND_RNUC :
1576 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1577 break;
1578 case MEP_OPERAND_RNUL :
1579 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1580 break;
1581 case MEP_OPERAND_RNUS :
1582 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1583 break;
1584 case MEP_OPERAND_SAR :
1585 break;
1586 case MEP_OPERAND_SDISP16 :
1587 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 16, 16, 32, total_length, pc, & fields->f_16s16);
1588 break;
1589 case MEP_OPERAND_SIMM16 :
1590 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 16, 16, 32, total_length, pc, & fields->f_16s16);
1591 break;
3526b680
DD
1592 case MEP_OPERAND_SIMM16P0 :
1593 {
1594 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 8, 32, total_length, pc, & fields->f_ivc2_8u0);
1595 if (length <= 0) break;
1596 length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 8, 32, total_length, pc, & fields->f_ivc2_8u20);
1597 if (length <= 0) break;
1598{
1599 FLD (f_ivc2_simm16p0) = ((FLD (f_ivc2_8u20)) | (((FLD (f_ivc2_8u0)) << (8))));
1600}
1601 }
1602 break;
bd2f2e55
DB
1603 case MEP_OPERAND_SIMM6 :
1604 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 8, 6, 32, total_length, pc, & fields->f_6s8);
1605 break;
1606 case MEP_OPERAND_SIMM8 :
1607 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 8, 8, 32, total_length, pc, & fields->f_8s8);
1608 break;
3526b680
DD
1609 case MEP_OPERAND_SIMM8P0 :
1610 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 0, 8, 32, total_length, pc, & fields->f_ivc2_8s0);
1611 break;
1612 case MEP_OPERAND_SIMM8P4 :
1613 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 4, 8, 32, total_length, pc, & fields->f_ivc2_8s4);
1614 break;
bd2f2e55
DB
1615 case MEP_OPERAND_SP :
1616 break;
1617 case MEP_OPERAND_SPR :
1618 break;
1619 case MEP_OPERAND_TP :
1620 break;
1621 case MEP_OPERAND_TPR :
1622 break;
1623 case MEP_OPERAND_UDISP2 :
1624 length = extract_normal (cd, ex_info, insn_value, 0, 0, 6, 2, 32, total_length, pc, & fields->f_2u6);
1625 break;
1626 case MEP_OPERAND_UDISP7 :
1627 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 7, 32, total_length, pc, & fields->f_7u9);
1628 break;
1629 case MEP_OPERAND_UDISP7A2 :
1630 {
1631 long value;
1632 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 6, 32, total_length, pc, & value);
1633 value = ((value) << (1));
1634 fields->f_7u9a2 = value;
1635 }
1636 break;
1637 case MEP_OPERAND_UDISP7A4 :
1638 {
1639 long value;
1640 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 5, 32, total_length, pc, & value);
1641 value = ((value) << (2));
1642 fields->f_7u9a4 = value;
1643 }
1644 break;
1645 case MEP_OPERAND_UIMM16 :
1646 length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_16u16);
1647 break;
1648 case MEP_OPERAND_UIMM2 :
1649 length = extract_normal (cd, ex_info, insn_value, 0, 0, 10, 2, 32, total_length, pc, & fields->f_2u10);
1650 break;
1651 case MEP_OPERAND_UIMM24 :
1652 {
1653 length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_24u8n_hi);
1654 if (length <= 0) break;
1655 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 8, 32, total_length, pc, & fields->f_24u8n_lo);
1656 if (length <= 0) break;
1657 FLD (f_24u8n) = ((((FLD (f_24u8n_hi)) << (8))) | (FLD (f_24u8n_lo)));
1658 }
1659 break;
1660 case MEP_OPERAND_UIMM3 :
1661 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_3u5);
1662 break;
1663 case MEP_OPERAND_UIMM4 :
1664 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_4u8);
1665 break;
1666 case MEP_OPERAND_UIMM5 :
1667 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 5, 32, total_length, pc, & fields->f_5u8);
1668 break;
1669 case MEP_OPERAND_UIMM7A4 :
1670 {
1671 long value;
1672 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 5, 32, total_length, pc, & value);
1673 value = ((value) << (2));
1674 fields->f_7u9a4 = value;
1675 }
1676 break;
1677 case MEP_OPERAND_ZERO :
1678 break;
1679
1680 default :
1681 /* xgettext:c-format */
1682 fprintf (stderr, _("Unrecognized field %d while decoding insn.\n"),
1683 opindex);
1684 abort ();
1685 }
1686
1687 return length;
1688}
1689
1690cgen_insert_fn * const mep_cgen_insert_handlers[] =
1691{
1692 insert_insn_normal,
1693};
1694
1695cgen_extract_fn * const mep_cgen_extract_handlers[] =
1696{
1697 extract_insn_normal,
1698};
1699
1700int mep_cgen_get_int_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *);
1701bfd_vma mep_cgen_get_vma_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *);
1702
1703/* Getting values from cgen_fields is handled by a collection of functions.
1704 They are distinguished by the type of the VALUE argument they return.
1705 TODO: floating point, inlining support, remove cases where result type
1706 not appropriate. */
1707
1708int
1709mep_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1710 int opindex,
1711 const CGEN_FIELDS * fields)
1712{
1713 int value;
1714
1715 switch (opindex)
1716 {
1717 case MEP_OPERAND_ADDR24A4 :
1718 value = fields->f_24u8a4n;
1719 break;
40493983
DD
1720 case MEP_OPERAND_C5RMUIMM20 :
1721 value = fields->f_c5_rmuimm20;
1722 break;
1723 case MEP_OPERAND_C5RNMUIMM24 :
1724 value = fields->f_c5_rnmuimm24;
1725 break;
bd2f2e55
DB
1726 case MEP_OPERAND_CALLNUM :
1727 value = fields->f_callnum;
1728 break;
1729 case MEP_OPERAND_CCCC :
1730 value = fields->f_rm;
1731 break;
1732 case MEP_OPERAND_CCRN :
1733 value = fields->f_ccrn;
1734 break;
40493983
DD
1735 case MEP_OPERAND_CDISP10 :
1736 value = fields->f_cdisp10;
bd2f2e55 1737 break;
40493983
DD
1738 case MEP_OPERAND_CDISP10A2 :
1739 value = fields->f_cdisp10;
bd2f2e55 1740 break;
40493983
DD
1741 case MEP_OPERAND_CDISP10A4 :
1742 value = fields->f_cdisp10;
bd2f2e55 1743 break;
40493983
DD
1744 case MEP_OPERAND_CDISP10A8 :
1745 value = fields->f_cdisp10;
1746 break;
1747 case MEP_OPERAND_CDISP12 :
1748 value = fields->f_12s20;
bd2f2e55
DB
1749 break;
1750 case MEP_OPERAND_CIMM4 :
1751 value = fields->f_rn;
1752 break;
1753 case MEP_OPERAND_CIMM5 :
1754 value = fields->f_5u24;
1755 break;
1756 case MEP_OPERAND_CODE16 :
1757 value = fields->f_16u16;
1758 break;
1759 case MEP_OPERAND_CODE24 :
1760 value = fields->f_24u4n;
1761 break;
1762 case MEP_OPERAND_CP_FLAG :
1763 value = 0;
1764 break;
1765 case MEP_OPERAND_CRN :
1766 value = fields->f_crn;
1767 break;
1768 case MEP_OPERAND_CRN64 :
1769 value = fields->f_crn;
1770 break;
1771 case MEP_OPERAND_CRNX :
1772 value = fields->f_crnx;
1773 break;
1774 case MEP_OPERAND_CRNX64 :
1775 value = fields->f_crnx;
1776 break;
3526b680
DD
1777 case MEP_OPERAND_CROC :
1778 value = fields->f_ivc2_5u7;
1779 break;
1780 case MEP_OPERAND_CROP :
1781 value = fields->f_ivc2_5u23;
1782 break;
1783 case MEP_OPERAND_CRPC :
1784 value = fields->f_ivc2_5u26;
1785 break;
1786 case MEP_OPERAND_CRPP :
1787 value = fields->f_ivc2_5u18;
1788 break;
1789 case MEP_OPERAND_CRQC :
1790 value = fields->f_ivc2_5u21;
1791 break;
1792 case MEP_OPERAND_CRQP :
1793 value = fields->f_ivc2_5u13;
1794 break;
bd2f2e55
DB
1795 case MEP_OPERAND_CSRN :
1796 value = fields->f_csrn;
1797 break;
1798 case MEP_OPERAND_CSRN_IDX :
1799 value = fields->f_csrn;
1800 break;
1801 case MEP_OPERAND_DBG :
1802 value = 0;
1803 break;
1804 case MEP_OPERAND_DEPC :
1805 value = 0;
1806 break;
1807 case MEP_OPERAND_EPC :
1808 value = 0;
1809 break;
1810 case MEP_OPERAND_EXC :
1811 value = 0;
1812 break;
bd2f2e55
DB
1813 case MEP_OPERAND_HI :
1814 value = 0;
1815 break;
3526b680
DD
1816 case MEP_OPERAND_IMM16P0 :
1817 value = fields->f_ivc2_imm16p0;
1818 break;
1819 case MEP_OPERAND_IMM3P12 :
1820 value = fields->f_ivc2_3u12;
1821 break;
1822 case MEP_OPERAND_IMM3P25 :
1823 value = fields->f_ivc2_3u25;
1824 break;
1825 case MEP_OPERAND_IMM3P4 :
1826 value = fields->f_ivc2_3u4;
1827 break;
1828 case MEP_OPERAND_IMM3P5 :
1829 value = fields->f_ivc2_3u5;
1830 break;
1831 case MEP_OPERAND_IMM3P9 :
1832 value = fields->f_ivc2_3u9;
1833 break;
1834 case MEP_OPERAND_IMM4P10 :
1835 value = fields->f_ivc2_4u10;
1836 break;
1837 case MEP_OPERAND_IMM4P4 :
1838 value = fields->f_ivc2_4u4;
1839 break;
1840 case MEP_OPERAND_IMM4P8 :
1841 value = fields->f_ivc2_4u8;
1842 break;
1843 case MEP_OPERAND_IMM5P23 :
1844 value = fields->f_ivc2_5u23;
1845 break;
1846 case MEP_OPERAND_IMM5P3 :
1847 value = fields->f_ivc2_5u3;
1848 break;
1849 case MEP_OPERAND_IMM5P7 :
1850 value = fields->f_ivc2_5u7;
1851 break;
1852 case MEP_OPERAND_IMM5P8 :
1853 value = fields->f_ivc2_5u8;
1854 break;
1855 case MEP_OPERAND_IMM6P2 :
1856 value = fields->f_ivc2_6u2;
1857 break;
1858 case MEP_OPERAND_IMM6P6 :
1859 value = fields->f_ivc2_6u6;
1860 break;
1861 case MEP_OPERAND_IMM8P0 :
1862 value = fields->f_ivc2_8u0;
1863 break;
1864 case MEP_OPERAND_IMM8P20 :
1865 value = fields->f_ivc2_8u20;
1866 break;
1867 case MEP_OPERAND_IMM8P4 :
1868 value = fields->f_ivc2_8u4;
1869 break;
1870 case MEP_OPERAND_IVC_X_0_2 :
1871 value = fields->f_ivc2_2u0;
1872 break;
1873 case MEP_OPERAND_IVC_X_0_3 :
1874 value = fields->f_ivc2_3u0;
1875 break;
1876 case MEP_OPERAND_IVC_X_0_4 :
1877 value = fields->f_ivc2_4u0;
1878 break;
1879 case MEP_OPERAND_IVC_X_0_5 :
1880 value = fields->f_ivc2_5u0;
1881 break;
1882 case MEP_OPERAND_IVC_X_6_1 :
1883 value = fields->f_ivc2_1u6;
1884 break;
1885 case MEP_OPERAND_IVC_X_6_2 :
1886 value = fields->f_ivc2_2u6;
1887 break;
1888 case MEP_OPERAND_IVC_X_6_3 :
1889 value = fields->f_ivc2_3u6;
1890 break;
1891 case MEP_OPERAND_IVC2CCRN :
1892 value = fields->f_ivc2_ccrn;
1893 break;
1894 case MEP_OPERAND_IVC2CRN :
1895 value = fields->f_ivc2_crnx;
1896 break;
1897 case MEP_OPERAND_IVC2RM :
1898 value = fields->f_ivc2_crm;
1899 break;
bd2f2e55
DB
1900 case MEP_OPERAND_LO :
1901 value = 0;
1902 break;
1903 case MEP_OPERAND_LP :
1904 value = 0;
1905 break;
1906 case MEP_OPERAND_MB0 :
1907 value = 0;
1908 break;
1909 case MEP_OPERAND_MB1 :
1910 value = 0;
1911 break;
1912 case MEP_OPERAND_ME0 :
1913 value = 0;
1914 break;
1915 case MEP_OPERAND_ME1 :
1916 value = 0;
1917 break;
1918 case MEP_OPERAND_NPC :
1919 value = 0;
1920 break;
1921 case MEP_OPERAND_OPT :
1922 value = 0;
1923 break;
1924 case MEP_OPERAND_PCABS24A2 :
1925 value = fields->f_24u5a2n;
1926 break;
1927 case MEP_OPERAND_PCREL12A2 :
1928 value = fields->f_12s4a2;
1929 break;
1930 case MEP_OPERAND_PCREL17A2 :
1931 value = fields->f_17s16a2;
1932 break;
1933 case MEP_OPERAND_PCREL24A2 :
1934 value = fields->f_24s5a2n;
1935 break;
1936 case MEP_OPERAND_PCREL8A2 :
1937 value = fields->f_8s8a2;
1938 break;
1939 case MEP_OPERAND_PSW :
1940 value = 0;
1941 break;
1942 case MEP_OPERAND_R0 :
1943 value = 0;
1944 break;
1945 case MEP_OPERAND_R1 :
1946 value = 0;
1947 break;
1948 case MEP_OPERAND_RL :
1949 value = fields->f_rl;
1950 break;
40493983
DD
1951 case MEP_OPERAND_RL5 :
1952 value = fields->f_rl5;
1953 break;
bd2f2e55
DB
1954 case MEP_OPERAND_RM :
1955 value = fields->f_rm;
1956 break;
1957 case MEP_OPERAND_RMA :
1958 value = fields->f_rm;
1959 break;
1960 case MEP_OPERAND_RN :
1961 value = fields->f_rn;
1962 break;
1963 case MEP_OPERAND_RN3 :
1964 value = fields->f_rn3;
1965 break;
1966 case MEP_OPERAND_RN3C :
1967 value = fields->f_rn3;
1968 break;
1969 case MEP_OPERAND_RN3L :
1970 value = fields->f_rn3;
1971 break;
1972 case MEP_OPERAND_RN3S :
1973 value = fields->f_rn3;
1974 break;
1975 case MEP_OPERAND_RN3UC :
1976 value = fields->f_rn3;
1977 break;
1978 case MEP_OPERAND_RN3UL :
1979 value = fields->f_rn3;
1980 break;
1981 case MEP_OPERAND_RN3US :
1982 value = fields->f_rn3;
1983 break;
1984 case MEP_OPERAND_RNC :
1985 value = fields->f_rn;
1986 break;
1987 case MEP_OPERAND_RNL :
1988 value = fields->f_rn;
1989 break;
1990 case MEP_OPERAND_RNS :
1991 value = fields->f_rn;
1992 break;
1993 case MEP_OPERAND_RNUC :
1994 value = fields->f_rn;
1995 break;
1996 case MEP_OPERAND_RNUL :
1997 value = fields->f_rn;
1998 break;
1999 case MEP_OPERAND_RNUS :
2000 value = fields->f_rn;
2001 break;
2002 case MEP_OPERAND_SAR :
2003 value = 0;
2004 break;
2005 case MEP_OPERAND_SDISP16 :
2006 value = fields->f_16s16;
2007 break;
2008 case MEP_OPERAND_SIMM16 :
2009 value = fields->f_16s16;
2010 break;
3526b680
DD
2011 case MEP_OPERAND_SIMM16P0 :
2012 value = fields->f_ivc2_simm16p0;
2013 break;
bd2f2e55
DB
2014 case MEP_OPERAND_SIMM6 :
2015 value = fields->f_6s8;
2016 break;
2017 case MEP_OPERAND_SIMM8 :
2018 value = fields->f_8s8;
2019 break;
3526b680
DD
2020 case MEP_OPERAND_SIMM8P0 :
2021 value = fields->f_ivc2_8s0;
2022 break;
2023 case MEP_OPERAND_SIMM8P4 :
2024 value = fields->f_ivc2_8s4;
2025 break;
bd2f2e55
DB
2026 case MEP_OPERAND_SP :
2027 value = 0;
2028 break;
2029 case MEP_OPERAND_SPR :
2030 value = 0;
2031 break;
2032 case MEP_OPERAND_TP :
2033 value = 0;
2034 break;
2035 case MEP_OPERAND_TPR :
2036 value = 0;
2037 break;
2038 case MEP_OPERAND_UDISP2 :
2039 value = fields->f_2u6;
2040 break;
2041 case MEP_OPERAND_UDISP7 :
2042 value = fields->f_7u9;
2043 break;
2044 case MEP_OPERAND_UDISP7A2 :
2045 value = fields->f_7u9a2;
2046 break;
2047 case MEP_OPERAND_UDISP7A4 :
2048 value = fields->f_7u9a4;
2049 break;
2050 case MEP_OPERAND_UIMM16 :
2051 value = fields->f_16u16;
2052 break;
2053 case MEP_OPERAND_UIMM2 :
2054 value = fields->f_2u10;
2055 break;
2056 case MEP_OPERAND_UIMM24 :
2057 value = fields->f_24u8n;
2058 break;
2059 case MEP_OPERAND_UIMM3 :
2060 value = fields->f_3u5;
2061 break;
2062 case MEP_OPERAND_UIMM4 :
2063 value = fields->f_4u8;
2064 break;
2065 case MEP_OPERAND_UIMM5 :
2066 value = fields->f_5u8;
2067 break;
2068 case MEP_OPERAND_UIMM7A4 :
2069 value = fields->f_7u9a4;
2070 break;
2071 case MEP_OPERAND_ZERO :
2072 value = 0;
2073 break;
2074
2075 default :
2076 /* xgettext:c-format */
2077 fprintf (stderr, _("Unrecognized field %d while getting int operand.\n"),
2078 opindex);
2079 abort ();
2080 }
2081
2082 return value;
2083}
2084
2085bfd_vma
2086mep_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
2087 int opindex,
2088 const CGEN_FIELDS * fields)
2089{
2090 bfd_vma value;
2091
2092 switch (opindex)
2093 {
2094 case MEP_OPERAND_ADDR24A4 :
2095 value = fields->f_24u8a4n;
2096 break;
40493983
DD
2097 case MEP_OPERAND_C5RMUIMM20 :
2098 value = fields->f_c5_rmuimm20;
2099 break;
2100 case MEP_OPERAND_C5RNMUIMM24 :
2101 value = fields->f_c5_rnmuimm24;
2102 break;
bd2f2e55
DB
2103 case MEP_OPERAND_CALLNUM :
2104 value = fields->f_callnum;
2105 break;
2106 case MEP_OPERAND_CCCC :
2107 value = fields->f_rm;
2108 break;
2109 case MEP_OPERAND_CCRN :
2110 value = fields->f_ccrn;
2111 break;
40493983
DD
2112 case MEP_OPERAND_CDISP10 :
2113 value = fields->f_cdisp10;
bd2f2e55 2114 break;
40493983
DD
2115 case MEP_OPERAND_CDISP10A2 :
2116 value = fields->f_cdisp10;
bd2f2e55 2117 break;
40493983
DD
2118 case MEP_OPERAND_CDISP10A4 :
2119 value = fields->f_cdisp10;
bd2f2e55 2120 break;
40493983
DD
2121 case MEP_OPERAND_CDISP10A8 :
2122 value = fields->f_cdisp10;
2123 break;
2124 case MEP_OPERAND_CDISP12 :
2125 value = fields->f_12s20;
bd2f2e55
DB
2126 break;
2127 case MEP_OPERAND_CIMM4 :
2128 value = fields->f_rn;
2129 break;
2130 case MEP_OPERAND_CIMM5 :
2131 value = fields->f_5u24;
2132 break;
2133 case MEP_OPERAND_CODE16 :
2134 value = fields->f_16u16;
2135 break;
2136 case MEP_OPERAND_CODE24 :
2137 value = fields->f_24u4n;
2138 break;
2139 case MEP_OPERAND_CP_FLAG :
2140 value = 0;
2141 break;
2142 case MEP_OPERAND_CRN :
2143 value = fields->f_crn;
2144 break;
2145 case MEP_OPERAND_CRN64 :
2146 value = fields->f_crn;
2147 break;
2148 case MEP_OPERAND_CRNX :
2149 value = fields->f_crnx;
2150 break;
2151 case MEP_OPERAND_CRNX64 :
2152 value = fields->f_crnx;
2153 break;
3526b680
DD
2154 case MEP_OPERAND_CROC :
2155 value = fields->f_ivc2_5u7;
2156 break;
2157 case MEP_OPERAND_CROP :
2158 value = fields->f_ivc2_5u23;
2159 break;
2160 case MEP_OPERAND_CRPC :
2161 value = fields->f_ivc2_5u26;
2162 break;
2163 case MEP_OPERAND_CRPP :
2164 value = fields->f_ivc2_5u18;
2165 break;
2166 case MEP_OPERAND_CRQC :
2167 value = fields->f_ivc2_5u21;
2168 break;
2169 case MEP_OPERAND_CRQP :
2170 value = fields->f_ivc2_5u13;
2171 break;
bd2f2e55
DB
2172 case MEP_OPERAND_CSRN :
2173 value = fields->f_csrn;
2174 break;
2175 case MEP_OPERAND_CSRN_IDX :
2176 value = fields->f_csrn;
2177 break;
2178 case MEP_OPERAND_DBG :
2179 value = 0;
2180 break;
2181 case MEP_OPERAND_DEPC :
2182 value = 0;
2183 break;
2184 case MEP_OPERAND_EPC :
2185 value = 0;
2186 break;
2187 case MEP_OPERAND_EXC :
2188 value = 0;
2189 break;
bd2f2e55
DB
2190 case MEP_OPERAND_HI :
2191 value = 0;
2192 break;
3526b680
DD
2193 case MEP_OPERAND_IMM16P0 :
2194 value = fields->f_ivc2_imm16p0;
2195 break;
2196 case MEP_OPERAND_IMM3P12 :
2197 value = fields->f_ivc2_3u12;
2198 break;
2199 case MEP_OPERAND_IMM3P25 :
2200 value = fields->f_ivc2_3u25;
2201 break;
2202 case MEP_OPERAND_IMM3P4 :
2203 value = fields->f_ivc2_3u4;
2204 break;
2205 case MEP_OPERAND_IMM3P5 :
2206 value = fields->f_ivc2_3u5;
2207 break;
2208 case MEP_OPERAND_IMM3P9 :
2209 value = fields->f_ivc2_3u9;
2210 break;
2211 case MEP_OPERAND_IMM4P10 :
2212 value = fields->f_ivc2_4u10;
2213 break;
2214 case MEP_OPERAND_IMM4P4 :
2215 value = fields->f_ivc2_4u4;
2216 break;
2217 case MEP_OPERAND_IMM4P8 :
2218 value = fields->f_ivc2_4u8;
2219 break;
2220 case MEP_OPERAND_IMM5P23 :
2221 value = fields->f_ivc2_5u23;
2222 break;
2223 case MEP_OPERAND_IMM5P3 :
2224 value = fields->f_ivc2_5u3;
2225 break;
2226 case MEP_OPERAND_IMM5P7 :
2227 value = fields->f_ivc2_5u7;
2228 break;
2229 case MEP_OPERAND_IMM5P8 :
2230 value = fields->f_ivc2_5u8;
2231 break;
2232 case MEP_OPERAND_IMM6P2 :
2233 value = fields->f_ivc2_6u2;
2234 break;
2235 case MEP_OPERAND_IMM6P6 :
2236 value = fields->f_ivc2_6u6;
2237 break;
2238 case MEP_OPERAND_IMM8P0 :
2239 value = fields->f_ivc2_8u0;
2240 break;
2241 case MEP_OPERAND_IMM8P20 :
2242 value = fields->f_ivc2_8u20;
2243 break;
2244 case MEP_OPERAND_IMM8P4 :
2245 value = fields->f_ivc2_8u4;
2246 break;
2247 case MEP_OPERAND_IVC_X_0_2 :
2248 value = fields->f_ivc2_2u0;
2249 break;
2250 case MEP_OPERAND_IVC_X_0_3 :
2251 value = fields->f_ivc2_3u0;
2252 break;
2253 case MEP_OPERAND_IVC_X_0_4 :
2254 value = fields->f_ivc2_4u0;
2255 break;
2256 case MEP_OPERAND_IVC_X_0_5 :
2257 value = fields->f_ivc2_5u0;
2258 break;
2259 case MEP_OPERAND_IVC_X_6_1 :
2260 value = fields->f_ivc2_1u6;
2261 break;
2262 case MEP_OPERAND_IVC_X_6_2 :
2263 value = fields->f_ivc2_2u6;
2264 break;
2265 case MEP_OPERAND_IVC_X_6_3 :
2266 value = fields->f_ivc2_3u6;
2267 break;
2268 case MEP_OPERAND_IVC2CCRN :
2269 value = fields->f_ivc2_ccrn;
2270 break;
2271 case MEP_OPERAND_IVC2CRN :
2272 value = fields->f_ivc2_crnx;
2273 break;
2274 case MEP_OPERAND_IVC2RM :
2275 value = fields->f_ivc2_crm;
2276 break;
bd2f2e55
DB
2277 case MEP_OPERAND_LO :
2278 value = 0;
2279 break;
2280 case MEP_OPERAND_LP :
2281 value = 0;
2282 break;
2283 case MEP_OPERAND_MB0 :
2284 value = 0;
2285 break;
2286 case MEP_OPERAND_MB1 :
2287 value = 0;
2288 break;
2289 case MEP_OPERAND_ME0 :
2290 value = 0;
2291 break;
2292 case MEP_OPERAND_ME1 :
2293 value = 0;
2294 break;
2295 case MEP_OPERAND_NPC :
2296 value = 0;
2297 break;
2298 case MEP_OPERAND_OPT :
2299 value = 0;
2300 break;
2301 case MEP_OPERAND_PCABS24A2 :
2302 value = fields->f_24u5a2n;
2303 break;
2304 case MEP_OPERAND_PCREL12A2 :
2305 value = fields->f_12s4a2;
2306 break;
2307 case MEP_OPERAND_PCREL17A2 :
2308 value = fields->f_17s16a2;
2309 break;
2310 case MEP_OPERAND_PCREL24A2 :
2311 value = fields->f_24s5a2n;
2312 break;
2313 case MEP_OPERAND_PCREL8A2 :
2314 value = fields->f_8s8a2;
2315 break;
2316 case MEP_OPERAND_PSW :
2317 value = 0;
2318 break;
2319 case MEP_OPERAND_R0 :
2320 value = 0;
2321 break;
2322 case MEP_OPERAND_R1 :
2323 value = 0;
2324 break;
2325 case MEP_OPERAND_RL :
2326 value = fields->f_rl;
2327 break;
40493983
DD
2328 case MEP_OPERAND_RL5 :
2329 value = fields->f_rl5;
2330 break;
bd2f2e55
DB
2331 case MEP_OPERAND_RM :
2332 value = fields->f_rm;
2333 break;
2334 case MEP_OPERAND_RMA :
2335 value = fields->f_rm;
2336 break;
2337 case MEP_OPERAND_RN :
2338 value = fields->f_rn;
2339 break;
2340 case MEP_OPERAND_RN3 :
2341 value = fields->f_rn3;
2342 break;
2343 case MEP_OPERAND_RN3C :
2344 value = fields->f_rn3;
2345 break;
2346 case MEP_OPERAND_RN3L :
2347 value = fields->f_rn3;
2348 break;
2349 case MEP_OPERAND_RN3S :
2350 value = fields->f_rn3;
2351 break;
2352 case MEP_OPERAND_RN3UC :
2353 value = fields->f_rn3;
2354 break;
2355 case MEP_OPERAND_RN3UL :
2356 value = fields->f_rn3;
2357 break;
2358 case MEP_OPERAND_RN3US :
2359 value = fields->f_rn3;
2360 break;
2361 case MEP_OPERAND_RNC :
2362 value = fields->f_rn;
2363 break;
2364 case MEP_OPERAND_RNL :
2365 value = fields->f_rn;
2366 break;
2367 case MEP_OPERAND_RNS :
2368 value = fields->f_rn;
2369 break;
2370 case MEP_OPERAND_RNUC :
2371 value = fields->f_rn;
2372 break;
2373 case MEP_OPERAND_RNUL :
2374 value = fields->f_rn;
2375 break;
2376 case MEP_OPERAND_RNUS :
2377 value = fields->f_rn;
2378 break;
2379 case MEP_OPERAND_SAR :
2380 value = 0;
2381 break;
2382 case MEP_OPERAND_SDISP16 :
2383 value = fields->f_16s16;
2384 break;
2385 case MEP_OPERAND_SIMM16 :
2386 value = fields->f_16s16;
2387 break;
3526b680
DD
2388 case MEP_OPERAND_SIMM16P0 :
2389 value = fields->f_ivc2_simm16p0;
2390 break;
bd2f2e55
DB
2391 case MEP_OPERAND_SIMM6 :
2392 value = fields->f_6s8;
2393 break;
2394 case MEP_OPERAND_SIMM8 :
2395 value = fields->f_8s8;
2396 break;
3526b680
DD
2397 case MEP_OPERAND_SIMM8P0 :
2398 value = fields->f_ivc2_8s0;
2399 break;
2400 case MEP_OPERAND_SIMM8P4 :
2401 value = fields->f_ivc2_8s4;
2402 break;
bd2f2e55
DB
2403 case MEP_OPERAND_SP :
2404 value = 0;
2405 break;
2406 case MEP_OPERAND_SPR :
2407 value = 0;
2408 break;
2409 case MEP_OPERAND_TP :
2410 value = 0;
2411 break;
2412 case MEP_OPERAND_TPR :
2413 value = 0;
2414 break;
2415 case MEP_OPERAND_UDISP2 :
2416 value = fields->f_2u6;
2417 break;
2418 case MEP_OPERAND_UDISP7 :
2419 value = fields->f_7u9;
2420 break;
2421 case MEP_OPERAND_UDISP7A2 :
2422 value = fields->f_7u9a2;
2423 break;
2424 case MEP_OPERAND_UDISP7A4 :
2425 value = fields->f_7u9a4;
2426 break;
2427 case MEP_OPERAND_UIMM16 :
2428 value = fields->f_16u16;
2429 break;
2430 case MEP_OPERAND_UIMM2 :
2431 value = fields->f_2u10;
2432 break;
2433 case MEP_OPERAND_UIMM24 :
2434 value = fields->f_24u8n;
2435 break;
2436 case MEP_OPERAND_UIMM3 :
2437 value = fields->f_3u5;
2438 break;
2439 case MEP_OPERAND_UIMM4 :
2440 value = fields->f_4u8;
2441 break;
2442 case MEP_OPERAND_UIMM5 :
2443 value = fields->f_5u8;
2444 break;
2445 case MEP_OPERAND_UIMM7A4 :
2446 value = fields->f_7u9a4;
2447 break;
2448 case MEP_OPERAND_ZERO :
2449 value = 0;
2450 break;
2451
2452 default :
2453 /* xgettext:c-format */
2454 fprintf (stderr, _("Unrecognized field %d while getting vma operand.\n"),
2455 opindex);
2456 abort ();
2457 }
2458
2459 return value;
2460}
2461
2462void mep_cgen_set_int_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, int);
2463void mep_cgen_set_vma_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, bfd_vma);
2464
2465/* Stuffing values in cgen_fields is handled by a collection of functions.
2466 They are distinguished by the type of the VALUE argument they accept.
2467 TODO: floating point, inlining support, remove cases where argument type
2468 not appropriate. */
2469
2470void
2471mep_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
2472 int opindex,
2473 CGEN_FIELDS * fields,
2474 int value)
2475{
2476 switch (opindex)
2477 {
2478 case MEP_OPERAND_ADDR24A4 :
2479 fields->f_24u8a4n = value;
2480 break;
40493983
DD
2481 case MEP_OPERAND_C5RMUIMM20 :
2482 fields->f_c5_rmuimm20 = value;
2483 break;
2484 case MEP_OPERAND_C5RNMUIMM24 :
2485 fields->f_c5_rnmuimm24 = value;
2486 break;
bd2f2e55
DB
2487 case MEP_OPERAND_CALLNUM :
2488 fields->f_callnum = value;
2489 break;
2490 case MEP_OPERAND_CCCC :
2491 fields->f_rm = value;
2492 break;
2493 case MEP_OPERAND_CCRN :
2494 fields->f_ccrn = value;
2495 break;
40493983
DD
2496 case MEP_OPERAND_CDISP10 :
2497 fields->f_cdisp10 = value;
2498 break;
2499 case MEP_OPERAND_CDISP10A2 :
2500 fields->f_cdisp10 = value;
bd2f2e55 2501 break;
40493983
DD
2502 case MEP_OPERAND_CDISP10A4 :
2503 fields->f_cdisp10 = value;
bd2f2e55 2504 break;
40493983
DD
2505 case MEP_OPERAND_CDISP10A8 :
2506 fields->f_cdisp10 = value;
bd2f2e55 2507 break;
40493983
DD
2508 case MEP_OPERAND_CDISP12 :
2509 fields->f_12s20 = value;
bd2f2e55
DB
2510 break;
2511 case MEP_OPERAND_CIMM4 :
2512 fields->f_rn = value;
2513 break;
2514 case MEP_OPERAND_CIMM5 :
2515 fields->f_5u24 = value;
2516 break;
2517 case MEP_OPERAND_CODE16 :
2518 fields->f_16u16 = value;
2519 break;
2520 case MEP_OPERAND_CODE24 :
2521 fields->f_24u4n = value;
2522 break;
2523 case MEP_OPERAND_CP_FLAG :
2524 break;
2525 case MEP_OPERAND_CRN :
2526 fields->f_crn = value;
2527 break;
2528 case MEP_OPERAND_CRN64 :
2529 fields->f_crn = value;
2530 break;
2531 case MEP_OPERAND_CRNX :
2532 fields->f_crnx = value;
2533 break;
2534 case MEP_OPERAND_CRNX64 :
2535 fields->f_crnx = value;
2536 break;
3526b680
DD
2537 case MEP_OPERAND_CROC :
2538 fields->f_ivc2_5u7 = value;
2539 break;
2540 case MEP_OPERAND_CROP :
2541 fields->f_ivc2_5u23 = value;
2542 break;
2543 case MEP_OPERAND_CRPC :
2544 fields->f_ivc2_5u26 = value;
2545 break;
2546 case MEP_OPERAND_CRPP :
2547 fields->f_ivc2_5u18 = value;
2548 break;
2549 case MEP_OPERAND_CRQC :
2550 fields->f_ivc2_5u21 = value;
2551 break;
2552 case MEP_OPERAND_CRQP :
2553 fields->f_ivc2_5u13 = value;
2554 break;
bd2f2e55
DB
2555 case MEP_OPERAND_CSRN :
2556 fields->f_csrn = value;
2557 break;
2558 case MEP_OPERAND_CSRN_IDX :
2559 fields->f_csrn = value;
2560 break;
2561 case MEP_OPERAND_DBG :
2562 break;
2563 case MEP_OPERAND_DEPC :
2564 break;
2565 case MEP_OPERAND_EPC :
2566 break;
2567 case MEP_OPERAND_EXC :
2568 break;
bd2f2e55
DB
2569 case MEP_OPERAND_HI :
2570 break;
3526b680
DD
2571 case MEP_OPERAND_IMM16P0 :
2572 fields->f_ivc2_imm16p0 = value;
2573 break;
2574 case MEP_OPERAND_IMM3P12 :
2575 fields->f_ivc2_3u12 = value;
2576 break;
2577 case MEP_OPERAND_IMM3P25 :
2578 fields->f_ivc2_3u25 = value;
2579 break;
2580 case MEP_OPERAND_IMM3P4 :
2581 fields->f_ivc2_3u4 = value;
2582 break;
2583 case MEP_OPERAND_IMM3P5 :
2584 fields->f_ivc2_3u5 = value;
2585 break;
2586 case MEP_OPERAND_IMM3P9 :
2587 fields->f_ivc2_3u9 = value;
2588 break;
2589 case MEP_OPERAND_IMM4P10 :
2590 fields->f_ivc2_4u10 = value;
2591 break;
2592 case MEP_OPERAND_IMM4P4 :
2593 fields->f_ivc2_4u4 = value;
2594 break;
2595 case MEP_OPERAND_IMM4P8 :
2596 fields->f_ivc2_4u8 = value;
2597 break;
2598 case MEP_OPERAND_IMM5P23 :
2599 fields->f_ivc2_5u23 = value;
2600 break;
2601 case MEP_OPERAND_IMM5P3 :
2602 fields->f_ivc2_5u3 = value;
2603 break;
2604 case MEP_OPERAND_IMM5P7 :
2605 fields->f_ivc2_5u7 = value;
2606 break;
2607 case MEP_OPERAND_IMM5P8 :
2608 fields->f_ivc2_5u8 = value;
2609 break;
2610 case MEP_OPERAND_IMM6P2 :
2611 fields->f_ivc2_6u2 = value;
2612 break;
2613 case MEP_OPERAND_IMM6P6 :
2614 fields->f_ivc2_6u6 = value;
2615 break;
2616 case MEP_OPERAND_IMM8P0 :
2617 fields->f_ivc2_8u0 = value;
2618 break;
2619 case MEP_OPERAND_IMM8P20 :
2620 fields->f_ivc2_8u20 = value;
2621 break;
2622 case MEP_OPERAND_IMM8P4 :
2623 fields->f_ivc2_8u4 = value;
2624 break;
2625 case MEP_OPERAND_IVC_X_0_2 :
2626 fields->f_ivc2_2u0 = value;
2627 break;
2628 case MEP_OPERAND_IVC_X_0_3 :
2629 fields->f_ivc2_3u0 = value;
2630 break;
2631 case MEP_OPERAND_IVC_X_0_4 :
2632 fields->f_ivc2_4u0 = value;
2633 break;
2634 case MEP_OPERAND_IVC_X_0_5 :
2635 fields->f_ivc2_5u0 = value;
2636 break;
2637 case MEP_OPERAND_IVC_X_6_1 :
2638 fields->f_ivc2_1u6 = value;
2639 break;
2640 case MEP_OPERAND_IVC_X_6_2 :
2641 fields->f_ivc2_2u6 = value;
2642 break;
2643 case MEP_OPERAND_IVC_X_6_3 :
2644 fields->f_ivc2_3u6 = value;
2645 break;
2646 case MEP_OPERAND_IVC2CCRN :
2647 fields->f_ivc2_ccrn = value;
2648 break;
2649 case MEP_OPERAND_IVC2CRN :
2650 fields->f_ivc2_crnx = value;
2651 break;
2652 case MEP_OPERAND_IVC2RM :
2653 fields->f_ivc2_crm = value;
2654 break;
bd2f2e55
DB
2655 case MEP_OPERAND_LO :
2656 break;
2657 case MEP_OPERAND_LP :
2658 break;
2659 case MEP_OPERAND_MB0 :
2660 break;
2661 case MEP_OPERAND_MB1 :
2662 break;
2663 case MEP_OPERAND_ME0 :
2664 break;
2665 case MEP_OPERAND_ME1 :
2666 break;
2667 case MEP_OPERAND_NPC :
2668 break;
2669 case MEP_OPERAND_OPT :
2670 break;
2671 case MEP_OPERAND_PCABS24A2 :
2672 fields->f_24u5a2n = value;
2673 break;
2674 case MEP_OPERAND_PCREL12A2 :
2675 fields->f_12s4a2 = value;
2676 break;
2677 case MEP_OPERAND_PCREL17A2 :
2678 fields->f_17s16a2 = value;
2679 break;
2680 case MEP_OPERAND_PCREL24A2 :
2681 fields->f_24s5a2n = value;
2682 break;
2683 case MEP_OPERAND_PCREL8A2 :
2684 fields->f_8s8a2 = value;
2685 break;
2686 case MEP_OPERAND_PSW :
2687 break;
2688 case MEP_OPERAND_R0 :
2689 break;
2690 case MEP_OPERAND_R1 :
2691 break;
2692 case MEP_OPERAND_RL :
2693 fields->f_rl = value;
2694 break;
40493983
DD
2695 case MEP_OPERAND_RL5 :
2696 fields->f_rl5 = value;
2697 break;
bd2f2e55
DB
2698 case MEP_OPERAND_RM :
2699 fields->f_rm = value;
2700 break;
2701 case MEP_OPERAND_RMA :
2702 fields->f_rm = value;
2703 break;
2704 case MEP_OPERAND_RN :
2705 fields->f_rn = value;
2706 break;
2707 case MEP_OPERAND_RN3 :
2708 fields->f_rn3 = value;
2709 break;
2710 case MEP_OPERAND_RN3C :
2711 fields->f_rn3 = value;
2712 break;
2713 case MEP_OPERAND_RN3L :
2714 fields->f_rn3 = value;
2715 break;
2716 case MEP_OPERAND_RN3S :
2717 fields->f_rn3 = value;
2718 break;
2719 case MEP_OPERAND_RN3UC :
2720 fields->f_rn3 = value;
2721 break;
2722 case MEP_OPERAND_RN3UL :
2723 fields->f_rn3 = value;
2724 break;
2725 case MEP_OPERAND_RN3US :
2726 fields->f_rn3 = value;
2727 break;
2728 case MEP_OPERAND_RNC :
2729 fields->f_rn = value;
2730 break;
2731 case MEP_OPERAND_RNL :
2732 fields->f_rn = value;
2733 break;
2734 case MEP_OPERAND_RNS :
2735 fields->f_rn = value;
2736 break;
2737 case MEP_OPERAND_RNUC :
2738 fields->f_rn = value;
2739 break;
2740 case MEP_OPERAND_RNUL :
2741 fields->f_rn = value;
2742 break;
2743 case MEP_OPERAND_RNUS :
2744 fields->f_rn = value;
2745 break;
2746 case MEP_OPERAND_SAR :
2747 break;
2748 case MEP_OPERAND_SDISP16 :
2749 fields->f_16s16 = value;
2750 break;
2751 case MEP_OPERAND_SIMM16 :
2752 fields->f_16s16 = value;
2753 break;
3526b680
DD
2754 case MEP_OPERAND_SIMM16P0 :
2755 fields->f_ivc2_simm16p0 = value;
2756 break;
bd2f2e55
DB
2757 case MEP_OPERAND_SIMM6 :
2758 fields->f_6s8 = value;
2759 break;
2760 case MEP_OPERAND_SIMM8 :
2761 fields->f_8s8 = value;
2762 break;
3526b680
DD
2763 case MEP_OPERAND_SIMM8P0 :
2764 fields->f_ivc2_8s0 = value;
2765 break;
2766 case MEP_OPERAND_SIMM8P4 :
2767 fields->f_ivc2_8s4 = value;
2768 break;
bd2f2e55
DB
2769 case MEP_OPERAND_SP :
2770 break;
2771 case MEP_OPERAND_SPR :
2772 break;
2773 case MEP_OPERAND_TP :
2774 break;
2775 case MEP_OPERAND_TPR :
2776 break;
2777 case MEP_OPERAND_UDISP2 :
2778 fields->f_2u6 = value;
2779 break;
2780 case MEP_OPERAND_UDISP7 :
2781 fields->f_7u9 = value;
2782 break;
2783 case MEP_OPERAND_UDISP7A2 :
2784 fields->f_7u9a2 = value;
2785 break;
2786 case MEP_OPERAND_UDISP7A4 :
2787 fields->f_7u9a4 = value;
2788 break;
2789 case MEP_OPERAND_UIMM16 :
2790 fields->f_16u16 = value;
2791 break;
2792 case MEP_OPERAND_UIMM2 :
2793 fields->f_2u10 = value;
2794 break;
2795 case MEP_OPERAND_UIMM24 :
2796 fields->f_24u8n = value;
2797 break;
2798 case MEP_OPERAND_UIMM3 :
2799 fields->f_3u5 = value;
2800 break;
2801 case MEP_OPERAND_UIMM4 :
2802 fields->f_4u8 = value;
2803 break;
2804 case MEP_OPERAND_UIMM5 :
2805 fields->f_5u8 = value;
2806 break;
2807 case MEP_OPERAND_UIMM7A4 :
2808 fields->f_7u9a4 = value;
2809 break;
2810 case MEP_OPERAND_ZERO :
2811 break;
2812
2813 default :
2814 /* xgettext:c-format */
2815 fprintf (stderr, _("Unrecognized field %d while setting int operand.\n"),
2816 opindex);
2817 abort ();
2818 }
2819}
2820
2821void
2822mep_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
2823 int opindex,
2824 CGEN_FIELDS * fields,
2825 bfd_vma value)
2826{
2827 switch (opindex)
2828 {
2829 case MEP_OPERAND_ADDR24A4 :
2830 fields->f_24u8a4n = value;
2831 break;
40493983
DD
2832 case MEP_OPERAND_C5RMUIMM20 :
2833 fields->f_c5_rmuimm20 = value;
2834 break;
2835 case MEP_OPERAND_C5RNMUIMM24 :
2836 fields->f_c5_rnmuimm24 = value;
2837 break;
bd2f2e55
DB
2838 case MEP_OPERAND_CALLNUM :
2839 fields->f_callnum = value;
2840 break;
2841 case MEP_OPERAND_CCCC :
2842 fields->f_rm = value;
2843 break;
2844 case MEP_OPERAND_CCRN :
2845 fields->f_ccrn = value;
2846 break;
40493983
DD
2847 case MEP_OPERAND_CDISP10 :
2848 fields->f_cdisp10 = value;
2849 break;
2850 case MEP_OPERAND_CDISP10A2 :
2851 fields->f_cdisp10 = value;
bd2f2e55 2852 break;
40493983
DD
2853 case MEP_OPERAND_CDISP10A4 :
2854 fields->f_cdisp10 = value;
bd2f2e55 2855 break;
40493983
DD
2856 case MEP_OPERAND_CDISP10A8 :
2857 fields->f_cdisp10 = value;
bd2f2e55 2858 break;
40493983
DD
2859 case MEP_OPERAND_CDISP12 :
2860 fields->f_12s20 = value;
bd2f2e55
DB
2861 break;
2862 case MEP_OPERAND_CIMM4 :
2863 fields->f_rn = value;
2864 break;
2865 case MEP_OPERAND_CIMM5 :
2866 fields->f_5u24 = value;
2867 break;
2868 case MEP_OPERAND_CODE16 :
2869 fields->f_16u16 = value;
2870 break;
2871 case MEP_OPERAND_CODE24 :
2872 fields->f_24u4n = value;
2873 break;
2874 case MEP_OPERAND_CP_FLAG :
2875 break;
2876 case MEP_OPERAND_CRN :
2877 fields->f_crn = value;
2878 break;
2879 case MEP_OPERAND_CRN64 :
2880 fields->f_crn = value;
2881 break;
2882 case MEP_OPERAND_CRNX :
2883 fields->f_crnx = value;
2884 break;
2885 case MEP_OPERAND_CRNX64 :
2886 fields->f_crnx = value;
2887 break;
3526b680
DD
2888 case MEP_OPERAND_CROC :
2889 fields->f_ivc2_5u7 = value;
2890 break;
2891 case MEP_OPERAND_CROP :
2892 fields->f_ivc2_5u23 = value;
2893 break;
2894 case MEP_OPERAND_CRPC :
2895 fields->f_ivc2_5u26 = value;
2896 break;
2897 case MEP_OPERAND_CRPP :
2898 fields->f_ivc2_5u18 = value;
2899 break;
2900 case MEP_OPERAND_CRQC :
2901 fields->f_ivc2_5u21 = value;
2902 break;
2903 case MEP_OPERAND_CRQP :
2904 fields->f_ivc2_5u13 = value;
2905 break;
bd2f2e55
DB
2906 case MEP_OPERAND_CSRN :
2907 fields->f_csrn = value;
2908 break;
2909 case MEP_OPERAND_CSRN_IDX :
2910 fields->f_csrn = value;
2911 break;
2912 case MEP_OPERAND_DBG :
2913 break;
2914 case MEP_OPERAND_DEPC :
2915 break;
2916 case MEP_OPERAND_EPC :
2917 break;
2918 case MEP_OPERAND_EXC :
2919 break;
bd2f2e55
DB
2920 case MEP_OPERAND_HI :
2921 break;
3526b680
DD
2922 case MEP_OPERAND_IMM16P0 :
2923 fields->f_ivc2_imm16p0 = value;
2924 break;
2925 case MEP_OPERAND_IMM3P12 :
2926 fields->f_ivc2_3u12 = value;
2927 break;
2928 case MEP_OPERAND_IMM3P25 :
2929 fields->f_ivc2_3u25 = value;
2930 break;
2931 case MEP_OPERAND_IMM3P4 :
2932 fields->f_ivc2_3u4 = value;
2933 break;
2934 case MEP_OPERAND_IMM3P5 :
2935 fields->f_ivc2_3u5 = value;
2936 break;
2937 case MEP_OPERAND_IMM3P9 :
2938 fields->f_ivc2_3u9 = value;
2939 break;
2940 case MEP_OPERAND_IMM4P10 :
2941 fields->f_ivc2_4u10 = value;
2942 break;
2943 case MEP_OPERAND_IMM4P4 :
2944 fields->f_ivc2_4u4 = value;
2945 break;
2946 case MEP_OPERAND_IMM4P8 :
2947 fields->f_ivc2_4u8 = value;
2948 break;
2949 case MEP_OPERAND_IMM5P23 :
2950 fields->f_ivc2_5u23 = value;
2951 break;
2952 case MEP_OPERAND_IMM5P3 :
2953 fields->f_ivc2_5u3 = value;
2954 break;
2955 case MEP_OPERAND_IMM5P7 :
2956 fields->f_ivc2_5u7 = value;
2957 break;
2958 case MEP_OPERAND_IMM5P8 :
2959 fields->f_ivc2_5u8 = value;
2960 break;
2961 case MEP_OPERAND_IMM6P2 :
2962 fields->f_ivc2_6u2 = value;
2963 break;
2964 case MEP_OPERAND_IMM6P6 :
2965 fields->f_ivc2_6u6 = value;
2966 break;
2967 case MEP_OPERAND_IMM8P0 :
2968 fields->f_ivc2_8u0 = value;
2969 break;
2970 case MEP_OPERAND_IMM8P20 :
2971 fields->f_ivc2_8u20 = value;
2972 break;
2973 case MEP_OPERAND_IMM8P4 :
2974 fields->f_ivc2_8u4 = value;
2975 break;
2976 case MEP_OPERAND_IVC_X_0_2 :
2977 fields->f_ivc2_2u0 = value;
2978 break;
2979 case MEP_OPERAND_IVC_X_0_3 :
2980 fields->f_ivc2_3u0 = value;
2981 break;
2982 case MEP_OPERAND_IVC_X_0_4 :
2983 fields->f_ivc2_4u0 = value;
2984 break;
2985 case MEP_OPERAND_IVC_X_0_5 :
2986 fields->f_ivc2_5u0 = value;
2987 break;
2988 case MEP_OPERAND_IVC_X_6_1 :
2989 fields->f_ivc2_1u6 = value;
2990 break;
2991 case MEP_OPERAND_IVC_X_6_2 :
2992 fields->f_ivc2_2u6 = value;
2993 break;
2994 case MEP_OPERAND_IVC_X_6_3 :
2995 fields->f_ivc2_3u6 = value;
2996 break;
2997 case MEP_OPERAND_IVC2CCRN :
2998 fields->f_ivc2_ccrn = value;
2999 break;
3000 case MEP_OPERAND_IVC2CRN :
3001 fields->f_ivc2_crnx = value;
3002 break;
3003 case MEP_OPERAND_IVC2RM :
3004 fields->f_ivc2_crm = value;
3005 break;
bd2f2e55
DB
3006 case MEP_OPERAND_LO :
3007 break;
3008 case MEP_OPERAND_LP :
3009 break;
3010 case MEP_OPERAND_MB0 :
3011 break;
3012 case MEP_OPERAND_MB1 :
3013 break;
3014 case MEP_OPERAND_ME0 :
3015 break;
3016 case MEP_OPERAND_ME1 :
3017 break;
3018 case MEP_OPERAND_NPC :
3019 break;
3020 case MEP_OPERAND_OPT :
3021 break;
3022 case MEP_OPERAND_PCABS24A2 :
3023 fields->f_24u5a2n = value;
3024 break;
3025 case MEP_OPERAND_PCREL12A2 :
3026 fields->f_12s4a2 = value;
3027 break;
3028 case MEP_OPERAND_PCREL17A2 :
3029 fields->f_17s16a2 = value;
3030 break;
3031 case MEP_OPERAND_PCREL24A2 :
3032 fields->f_24s5a2n = value;
3033 break;
3034 case MEP_OPERAND_PCREL8A2 :
3035 fields->f_8s8a2 = value;
3036 break;
3037 case MEP_OPERAND_PSW :
3038 break;
3039 case MEP_OPERAND_R0 :
3040 break;
3041 case MEP_OPERAND_R1 :
3042 break;
3043 case MEP_OPERAND_RL :
3044 fields->f_rl = value;
3045 break;
40493983
DD
3046 case MEP_OPERAND_RL5 :
3047 fields->f_rl5 = value;
3048 break;
bd2f2e55
DB
3049 case MEP_OPERAND_RM :
3050 fields->f_rm = value;
3051 break;
3052 case MEP_OPERAND_RMA :
3053 fields->f_rm = value;
3054 break;
3055 case MEP_OPERAND_RN :
3056 fields->f_rn = value;
3057 break;
3058 case MEP_OPERAND_RN3 :
3059 fields->f_rn3 = value;
3060 break;
3061 case MEP_OPERAND_RN3C :
3062 fields->f_rn3 = value;
3063 break;
3064 case MEP_OPERAND_RN3L :
3065 fields->f_rn3 = value;
3066 break;
3067 case MEP_OPERAND_RN3S :
3068 fields->f_rn3 = value;
3069 break;
3070 case MEP_OPERAND_RN3UC :
3071 fields->f_rn3 = value;
3072 break;
3073 case MEP_OPERAND_RN3UL :
3074 fields->f_rn3 = value;
3075 break;
3076 case MEP_OPERAND_RN3US :
3077 fields->f_rn3 = value;
3078 break;
3079 case MEP_OPERAND_RNC :
3080 fields->f_rn = value;
3081 break;
3082 case MEP_OPERAND_RNL :
3083 fields->f_rn = value;
3084 break;
3085 case MEP_OPERAND_RNS :
3086 fields->f_rn = value;
3087 break;
3088 case MEP_OPERAND_RNUC :
3089 fields->f_rn = value;
3090 break;
3091 case MEP_OPERAND_RNUL :
3092 fields->f_rn = value;
3093 break;
3094 case MEP_OPERAND_RNUS :
3095 fields->f_rn = value;
3096 break;
3097 case MEP_OPERAND_SAR :
3098 break;
3099 case MEP_OPERAND_SDISP16 :
3100 fields->f_16s16 = value;
3101 break;
3102 case MEP_OPERAND_SIMM16 :
3103 fields->f_16s16 = value;
3104 break;
3526b680
DD
3105 case MEP_OPERAND_SIMM16P0 :
3106 fields->f_ivc2_simm16p0 = value;
3107 break;
bd2f2e55
DB
3108 case MEP_OPERAND_SIMM6 :
3109 fields->f_6s8 = value;
3110 break;
3111 case MEP_OPERAND_SIMM8 :
3112 fields->f_8s8 = value;
3113 break;
3526b680
DD
3114 case MEP_OPERAND_SIMM8P0 :
3115 fields->f_ivc2_8s0 = value;
3116 break;
3117 case MEP_OPERAND_SIMM8P4 :
3118 fields->f_ivc2_8s4 = value;
3119 break;
bd2f2e55
DB
3120 case MEP_OPERAND_SP :
3121 break;
3122 case MEP_OPERAND_SPR :
3123 break;
3124 case MEP_OPERAND_TP :
3125 break;
3126 case MEP_OPERAND_TPR :
3127 break;
3128 case MEP_OPERAND_UDISP2 :
3129 fields->f_2u6 = value;
3130 break;
3131 case MEP_OPERAND_UDISP7 :
3132 fields->f_7u9 = value;
3133 break;
3134 case MEP_OPERAND_UDISP7A2 :
3135 fields->f_7u9a2 = value;
3136 break;
3137 case MEP_OPERAND_UDISP7A4 :
3138 fields->f_7u9a4 = value;
3139 break;
3140 case MEP_OPERAND_UIMM16 :
3141 fields->f_16u16 = value;
3142 break;
3143 case MEP_OPERAND_UIMM2 :
3144 fields->f_2u10 = value;
3145 break;
3146 case MEP_OPERAND_UIMM24 :
3147 fields->f_24u8n = value;
3148 break;
3149 case MEP_OPERAND_UIMM3 :
3150 fields->f_3u5 = value;
3151 break;
3152 case MEP_OPERAND_UIMM4 :
3153 fields->f_4u8 = value;
3154 break;
3155 case MEP_OPERAND_UIMM5 :
3156 fields->f_5u8 = value;
3157 break;
3158 case MEP_OPERAND_UIMM7A4 :
3159 fields->f_7u9a4 = value;
3160 break;
3161 case MEP_OPERAND_ZERO :
3162 break;
3163
3164 default :
3165 /* xgettext:c-format */
3166 fprintf (stderr, _("Unrecognized field %d while setting vma operand.\n"),
3167 opindex);
3168 abort ();
3169 }
3170}
3171
3172/* Function to call before using the instruction builder tables. */
3173
3174void
3175mep_cgen_init_ibld_table (CGEN_CPU_DESC cd)
3176{
3177 cd->insert_handlers = & mep_cgen_insert_handlers[0];
3178 cd->extract_handlers = & mep_cgen_extract_handlers[0];
3179
3180 cd->insert_operand = mep_cgen_insert_operand;
3181 cd->extract_operand = mep_cgen_extract_operand;
3182
3183 cd->get_int_operand = mep_cgen_get_int_operand;
3184 cd->set_int_operand = mep_cgen_set_int_operand;
3185 cd->get_vma_operand = mep_cgen_get_vma_operand;
3186 cd->set_vma_operand = mep_cgen_set_vma_operand;
3187}
This page took 0.521105 seconds and 4 git commands to generate.