947390690b53306b47e58e2df369bee133889e78
[external/binutils.git] / opcodes / mep-ibld.c
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
6    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005, 2006, 2007,
7    2008  Free Software Foundation, Inc.
8
9    This file is part of libopcodes.
10
11    This library is free software; you can redistribute it and/or modify
12    it under the terms of the GNU General Public License as published by
13    the Free Software Foundation; either version 3, or (at your option)
14    any later version.
15
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.
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
47 static const char * insert_normal
48   (CGEN_CPU_DESC, long, unsigned int, unsigned int, unsigned int,
49    unsigned int, unsigned int, unsigned int, CGEN_INSN_BYTES_PTR);
50 static const char * insert_insn_normal
51   (CGEN_CPU_DESC, const CGEN_INSN *,
52    CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma);
53 static int extract_normal
54   (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, CGEN_INSN_INT,
55    unsigned int, unsigned int, unsigned int, unsigned int,
56    unsigned int, unsigned int, bfd_vma, long *);
57 static int extract_insn_normal
58   (CGEN_CPU_DESC, const CGEN_INSN *, CGEN_EXTRACT_INFO *,
59    CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma);
60 #if CGEN_INT_INSN_P
61 static void put_insn_int_value
62   (CGEN_CPU_DESC, CGEN_INSN_BYTES_PTR, int, int, CGEN_INSN_INT);
63 #endif
64 #if ! CGEN_INT_INSN_P
65 static CGEN_INLINE void insert_1
66   (CGEN_CPU_DESC, unsigned long, int, int, int, unsigned char *);
67 static CGEN_INLINE int fill_cache
68   (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *,  int, int, bfd_vma);
69 static CGEN_INLINE long extract_1
70   (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, int, int, int, unsigned char *, bfd_vma);
71 #endif
72 \f
73 /* Operand insertion.  */
74
75 #if ! CGEN_INT_INSN_P
76
77 /* Subroutine of insert_normal.  */
78
79 static CGEN_INLINE void
80 insert_1 (CGEN_CPU_DESC cd,
81           unsigned long value,
82           int start,
83           int length,
84           int word_length,
85           unsigned char *bufp)
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
121 static const char *
122 insert_normal (CGEN_CPU_DESC cd,
123                long value,
124                unsigned int attrs,
125                unsigned int word_offset,
126                unsigned int start,
127                unsigned int length,
128                unsigned int word_length,
129                unsigned int total_length,
130                CGEN_INSN_BYTES_PTR buffer)
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
239 static const char *
240 insert_insn_normal (CGEN_CPU_DESC cd,
241                     const CGEN_INSN * insn,
242                     CGEN_FIELDS * fields,
243                     CGEN_INSN_BYTES_PTR buffer,
244                     bfd_vma pc)
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
294 static void
295 put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
296                     CGEN_INSN_BYTES_PTR buf,
297                     int length,
298                     int insn_length,
299                     CGEN_INSN_INT value)
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
326 static CGEN_INLINE int
327 fill_cache (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
328             CGEN_EXTRACT_INFO *ex_info,
329             int offset,
330             int bytes,
331             bfd_vma pc)
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
370 static CGEN_INLINE long
371 extract_1 (CGEN_CPU_DESC cd,
372            CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED,
373            int start,
374            int length,
375            int word_length,
376            unsigned char *bufp,
377            bfd_vma pc ATTRIBUTE_UNUSED)
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
413 static int
414 extract_normal (CGEN_CPU_DESC cd,
415 #if ! CGEN_INT_INSN_P
416                 CGEN_EXTRACT_INFO *ex_info,
417 #else
418                 CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED,
419 #endif
420                 CGEN_INSN_INT insn_value,
421                 unsigned int attrs,
422                 unsigned int word_offset,
423                 unsigned int start,
424                 unsigned int length,
425                 unsigned int word_length,
426                 unsigned int total_length,
427 #if ! CGEN_INT_INSN_P
428                 bfd_vma pc,
429 #else
430                 bfd_vma pc ATTRIBUTE_UNUSED,
431 #endif
432                 long *valuep)
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
505 static int
506 extract_insn_normal (CGEN_CPU_DESC cd,
507                      const CGEN_INSN *insn,
508                      CGEN_EXTRACT_INFO *ex_info,
509                      CGEN_INSN_INT insn_value,
510                      CGEN_FIELDS *fields,
511                      bfd_vma pc)
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
539 const 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
556 const char *
557 mep_cgen_insert_operand (CGEN_CPU_DESC cd,
558                              int opindex,
559                              CGEN_FIELDS * fields,
560                              CGEN_INSN_BYTES_PTR buffer,
561                              bfd_vma pc ATTRIBUTE_UNUSED)
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;
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;
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;
649     case MEP_OPERAND_CDISP10 :
650       {
651         long value = fields->f_cdisp10;
652         value = ((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value));
653         errmsg = insert_normal (cd, value, 0, 0, 22, 10, 32, total_length, buffer);
654       }
655       break;
656     case MEP_OPERAND_CDISP10A2 :
657       {
658         long value = fields->f_cdisp10;
659         value = ((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value));
660         errmsg = insert_normal (cd, value, 0, 0, 22, 10, 32, total_length, buffer);
661       }
662       break;
663     case MEP_OPERAND_CDISP10A4 :
664       {
665         long value = fields->f_cdisp10;
666         value = ((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value));
667         errmsg = insert_normal (cd, value, 0, 0, 22, 10, 32, total_length, buffer);
668       }
669       break;
670     case MEP_OPERAND_CDISP10A8 :
671       {
672         long value = fields->f_cdisp10;
673         value = ((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value));
674         errmsg = insert_normal (cd, value, 0, 0, 22, 10, 32, total_length, buffer);
675       }
676       break;
677     case MEP_OPERAND_CDISP12 :
678       errmsg = insert_normal (cd, fields->f_12s20, 0, 0, 20, 12, 32, total_length, buffer);
679       break;
680     case MEP_OPERAND_CIMM4 :
681       errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
682       break;
683     case MEP_OPERAND_CIMM5 :
684       errmsg = insert_normal (cd, fields->f_5u24, 0, 0, 24, 5, 32, total_length, buffer);
685       break;
686     case MEP_OPERAND_CODE16 :
687       errmsg = insert_normal (cd, fields->f_16u16, 0, 0, 16, 16, 32, total_length, buffer);
688       break;
689     case MEP_OPERAND_CODE24 :
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;
739     case MEP_OPERAND_CSRN :
740       {
741 {
742   FLD (f_csrn_lo) = ((FLD (f_csrn)) & (15));
743   FLD (f_csrn_hi) = ((unsigned int) (FLD (f_csrn)) >> (4));
744 }
745         errmsg = insert_normal (cd, fields->f_csrn_hi, 0, 0, 15, 1, 32, total_length, buffer);
746         if (errmsg)
747           break;
748         errmsg = insert_normal (cd, fields->f_csrn_lo, 0, 0, 8, 4, 32, total_length, buffer);
749         if (errmsg)
750           break;
751       }
752       break;
753     case MEP_OPERAND_CSRN_IDX :
754       {
755 {
756   FLD (f_csrn_lo) = ((FLD (f_csrn)) & (15));
757   FLD (f_csrn_hi) = ((unsigned int) (FLD (f_csrn)) >> (4));
758 }
759         errmsg = insert_normal (cd, fields->f_csrn_hi, 0, 0, 15, 1, 32, total_length, buffer);
760         if (errmsg)
761           break;
762         errmsg = insert_normal (cd, fields->f_csrn_lo, 0, 0, 8, 4, 32, total_length, buffer);
763         if (errmsg)
764           break;
765       }
766       break;
767     case MEP_OPERAND_DBG :
768       break;
769     case MEP_OPERAND_DEPC :
770       break;
771     case MEP_OPERAND_EPC :
772       break;
773     case MEP_OPERAND_EXC :
774       break;
775     case MEP_OPERAND_HI :
776       break;
777     case MEP_OPERAND_LO :
778       break;
779     case MEP_OPERAND_LP :
780       break;
781     case MEP_OPERAND_MB0 :
782       break;
783     case MEP_OPERAND_MB1 :
784       break;
785     case MEP_OPERAND_ME0 :
786       break;
787     case MEP_OPERAND_ME1 :
788       break;
789     case MEP_OPERAND_NPC :
790       break;
791     case MEP_OPERAND_OPT :
792       break;
793     case MEP_OPERAND_PCABS24A2 :
794       {
795 {
796   FLD (f_24u5a2n_lo) = ((unsigned int) (((FLD (f_24u5a2n)) & (255))) >> (1));
797   FLD (f_24u5a2n_hi) = ((unsigned int) (FLD (f_24u5a2n)) >> (8));
798 }
799         errmsg = insert_normal (cd, fields->f_24u5a2n_hi, 0, 0, 16, 16, 32, total_length, buffer);
800         if (errmsg)
801           break;
802         errmsg = insert_normal (cd, fields->f_24u5a2n_lo, 0, 0, 5, 7, 32, total_length, buffer);
803         if (errmsg)
804           break;
805       }
806       break;
807     case MEP_OPERAND_PCREL12A2 :
808       {
809         long value = fields->f_12s4a2;
810         value = ((int) (((value) - (pc))) >> (1));
811         errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 4, 11, 32, total_length, buffer);
812       }
813       break;
814     case MEP_OPERAND_PCREL17A2 :
815       {
816         long value = fields->f_17s16a2;
817         value = ((int) (((value) - (pc))) >> (1));
818         errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 16, 16, 32, total_length, buffer);
819       }
820       break;
821     case MEP_OPERAND_PCREL24A2 :
822       {
823 {
824   FLD (f_24s5a2n) = ((FLD (f_24s5a2n)) - (pc));
825   FLD (f_24s5a2n_lo) = ((unsigned int) (((FLD (f_24s5a2n)) & (254))) >> (1));
826   FLD (f_24s5a2n_hi) = ((int) (FLD (f_24s5a2n)) >> (8));
827 }
828         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);
829         if (errmsg)
830           break;
831         errmsg = insert_normal (cd, fields->f_24s5a2n_lo, 0|(1<<CGEN_IFLD_PCREL_ADDR), 0, 5, 7, 32, total_length, buffer);
832         if (errmsg)
833           break;
834       }
835       break;
836     case MEP_OPERAND_PCREL8A2 :
837       {
838         long value = fields->f_8s8a2;
839         value = ((int) (((value) - (pc))) >> (1));
840         errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 8, 7, 32, total_length, buffer);
841       }
842       break;
843     case MEP_OPERAND_PSW :
844       break;
845     case MEP_OPERAND_R0 :
846       break;
847     case MEP_OPERAND_R1 :
848       break;
849     case MEP_OPERAND_RL :
850       errmsg = insert_normal (cd, fields->f_rl, 0, 0, 12, 4, 32, total_length, buffer);
851       break;
852     case MEP_OPERAND_RL5 :
853       errmsg = insert_normal (cd, fields->f_rl5, 0, 0, 20, 4, 32, total_length, buffer);
854       break;
855     case MEP_OPERAND_RM :
856       errmsg = insert_normal (cd, fields->f_rm, 0, 0, 8, 4, 32, total_length, buffer);
857       break;
858     case MEP_OPERAND_RMA :
859       errmsg = insert_normal (cd, fields->f_rm, 0, 0, 8, 4, 32, total_length, buffer);
860       break;
861     case MEP_OPERAND_RN :
862       errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
863       break;
864     case MEP_OPERAND_RN3 :
865       errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
866       break;
867     case MEP_OPERAND_RN3C :
868       errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
869       break;
870     case MEP_OPERAND_RN3L :
871       errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
872       break;
873     case MEP_OPERAND_RN3S :
874       errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
875       break;
876     case MEP_OPERAND_RN3UC :
877       errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
878       break;
879     case MEP_OPERAND_RN3UL :
880       errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
881       break;
882     case MEP_OPERAND_RN3US :
883       errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
884       break;
885     case MEP_OPERAND_RNC :
886       errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
887       break;
888     case MEP_OPERAND_RNL :
889       errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
890       break;
891     case MEP_OPERAND_RNS :
892       errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
893       break;
894     case MEP_OPERAND_RNUC :
895       errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
896       break;
897     case MEP_OPERAND_RNUL :
898       errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
899       break;
900     case MEP_OPERAND_RNUS :
901       errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
902       break;
903     case MEP_OPERAND_SAR :
904       break;
905     case MEP_OPERAND_SDISP16 :
906       errmsg = insert_normal (cd, fields->f_16s16, 0|(1<<CGEN_IFLD_SIGNED), 0, 16, 16, 32, total_length, buffer);
907       break;
908     case MEP_OPERAND_SIMM16 :
909       errmsg = insert_normal (cd, fields->f_16s16, 0|(1<<CGEN_IFLD_SIGNED), 0, 16, 16, 32, total_length, buffer);
910       break;
911     case MEP_OPERAND_SIMM6 :
912       errmsg = insert_normal (cd, fields->f_6s8, 0|(1<<CGEN_IFLD_SIGNED), 0, 8, 6, 32, total_length, buffer);
913       break;
914     case MEP_OPERAND_SIMM8 :
915       errmsg = insert_normal (cd, fields->f_8s8, 0|(1<<CGEN_IFLD_SIGNED), 0, 8, 8, 32, total_length, buffer);
916       break;
917     case MEP_OPERAND_SP :
918       break;
919     case MEP_OPERAND_SPR :
920       break;
921     case MEP_OPERAND_TP :
922       break;
923     case MEP_OPERAND_TPR :
924       break;
925     case MEP_OPERAND_UDISP2 :
926       errmsg = insert_normal (cd, fields->f_2u6, 0, 0, 6, 2, 32, total_length, buffer);
927       break;
928     case MEP_OPERAND_UDISP7 :
929       errmsg = insert_normal (cd, fields->f_7u9, 0, 0, 9, 7, 32, total_length, buffer);
930       break;
931     case MEP_OPERAND_UDISP7A2 :
932       {
933         long value = fields->f_7u9a2;
934         value = ((unsigned int) (value) >> (1));
935         errmsg = insert_normal (cd, value, 0, 0, 9, 6, 32, total_length, buffer);
936       }
937       break;
938     case MEP_OPERAND_UDISP7A4 :
939       {
940         long value = fields->f_7u9a4;
941         value = ((unsigned int) (value) >> (2));
942         errmsg = insert_normal (cd, value, 0, 0, 9, 5, 32, total_length, buffer);
943       }
944       break;
945     case MEP_OPERAND_UIMM16 :
946       errmsg = insert_normal (cd, fields->f_16u16, 0, 0, 16, 16, 32, total_length, buffer);
947       break;
948     case MEP_OPERAND_UIMM2 :
949       errmsg = insert_normal (cd, fields->f_2u10, 0, 0, 10, 2, 32, total_length, buffer);
950       break;
951     case MEP_OPERAND_UIMM24 :
952       {
953 {
954   FLD (f_24u8n_hi) = ((unsigned int) (FLD (f_24u8n)) >> (8));
955   FLD (f_24u8n_lo) = ((FLD (f_24u8n)) & (255));
956 }
957         errmsg = insert_normal (cd, fields->f_24u8n_hi, 0, 0, 16, 16, 32, total_length, buffer);
958         if (errmsg)
959           break;
960         errmsg = insert_normal (cd, fields->f_24u8n_lo, 0, 0, 8, 8, 32, total_length, buffer);
961         if (errmsg)
962           break;
963       }
964       break;
965     case MEP_OPERAND_UIMM3 :
966       errmsg = insert_normal (cd, fields->f_3u5, 0, 0, 5, 3, 32, total_length, buffer);
967       break;
968     case MEP_OPERAND_UIMM4 :
969       errmsg = insert_normal (cd, fields->f_4u8, 0, 0, 8, 4, 32, total_length, buffer);
970       break;
971     case MEP_OPERAND_UIMM5 :
972       errmsg = insert_normal (cd, fields->f_5u8, 0, 0, 8, 5, 32, total_length, buffer);
973       break;
974     case MEP_OPERAND_UIMM7A4 :
975       {
976         long value = fields->f_7u9a4;
977         value = ((unsigned int) (value) >> (2));
978         errmsg = insert_normal (cd, value, 0, 0, 9, 5, 32, total_length, buffer);
979       }
980       break;
981     case MEP_OPERAND_ZERO :
982       break;
983
984     default :
985       /* xgettext:c-format */
986       fprintf (stderr, _("Unrecognized field %d while building insn.\n"),
987                opindex);
988       abort ();
989   }
990
991   return errmsg;
992 }
993
994 int mep_cgen_extract_operand
995   (CGEN_CPU_DESC, int, CGEN_EXTRACT_INFO *, CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma);
996
997 /* Main entry point for operand extraction.
998    The result is <= 0 for error, >0 for success.
999    ??? Actual values aren't well defined right now.
1000
1001    This function is basically just a big switch statement.  Earlier versions
1002    used tables to look up the function to use, but
1003    - if the table contains both assembler and disassembler functions then
1004      the disassembler contains much of the assembler and vice-versa,
1005    - there's a lot of inlining possibilities as things grow,
1006    - using a switch statement avoids the function call overhead.
1007
1008    This function could be moved into `print_insn_normal', but keeping it
1009    separate makes clear the interface between `print_insn_normal' and each of
1010    the handlers.  */
1011
1012 int
1013 mep_cgen_extract_operand (CGEN_CPU_DESC cd,
1014                              int opindex,
1015                              CGEN_EXTRACT_INFO *ex_info,
1016                              CGEN_INSN_INT insn_value,
1017                              CGEN_FIELDS * fields,
1018                              bfd_vma pc)
1019 {
1020   /* Assume success (for those operands that are nops).  */
1021   int length = 1;
1022   unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
1023
1024   switch (opindex)
1025     {
1026     case MEP_OPERAND_ADDR24A4 :
1027       {
1028         length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_24u8a4n_hi);
1029         if (length <= 0) break;
1030         length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 6, 32, total_length, pc, & fields->f_24u8a4n_lo);
1031         if (length <= 0) break;
1032   FLD (f_24u8a4n) = ((((FLD (f_24u8a4n_hi)) << (8))) | (((FLD (f_24u8a4n_lo)) << (2))));
1033       }
1034       break;
1035     case MEP_OPERAND_C5RMUIMM20 :
1036       {
1037         length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_c5_rm);
1038         if (length <= 0) break;
1039         length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_c5_16u16);
1040         if (length <= 0) break;
1041 {
1042   FLD (f_c5_rmuimm20) = ((FLD (f_c5_16u16)) | (((FLD (f_c5_rm)) << (16))));
1043 }
1044       }
1045       break;
1046     case MEP_OPERAND_C5RNMUIMM24 :
1047       {
1048         length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 8, 32, total_length, pc, & fields->f_c5_rnm);
1049         if (length <= 0) break;
1050         length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_c5_16u16);
1051         if (length <= 0) break;
1052 {
1053   FLD (f_c5_rnmuimm24) = ((FLD (f_c5_16u16)) | (((FLD (f_c5_rnm)) << (16))));
1054 }
1055       }
1056       break;
1057     case MEP_OPERAND_CALLNUM :
1058       {
1059         length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 1, 32, total_length, pc, & fields->f_5);
1060         if (length <= 0) break;
1061         length = extract_normal (cd, ex_info, insn_value, 0, 0, 6, 1, 32, total_length, pc, & fields->f_6);
1062         if (length <= 0) break;
1063         length = extract_normal (cd, ex_info, insn_value, 0, 0, 7, 1, 32, total_length, pc, & fields->f_7);
1064         if (length <= 0) break;
1065         length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 1, 32, total_length, pc, & fields->f_11);
1066         if (length <= 0) break;
1067   FLD (f_callnum) = ((((FLD (f_5)) << (3))) | (((((FLD (f_6)) << (2))) | (((((FLD (f_7)) << (1))) | (FLD (f_11)))))));
1068       }
1069       break;
1070     case MEP_OPERAND_CCCC :
1071       length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_rm);
1072       break;
1073     case MEP_OPERAND_CCRN :
1074       {
1075         length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 2, 32, total_length, pc, & fields->f_ccrn_hi);
1076         if (length <= 0) break;
1077         length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_ccrn_lo);
1078         if (length <= 0) break;
1079   FLD (f_ccrn) = ((((FLD (f_ccrn_hi)) << (4))) | (FLD (f_ccrn_lo)));
1080       }
1081       break;
1082     case MEP_OPERAND_CDISP10 :
1083       {
1084         long value;
1085         length = extract_normal (cd, ex_info, insn_value, 0, 0, 22, 10, 32, total_length, pc, & value);
1086         value = ((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value));
1087         fields->f_cdisp10 = value;
1088       }
1089       break;
1090     case MEP_OPERAND_CDISP10A2 :
1091       {
1092         long value;
1093         length = extract_normal (cd, ex_info, insn_value, 0, 0, 22, 10, 32, total_length, pc, & value);
1094         value = ((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value));
1095         fields->f_cdisp10 = value;
1096       }
1097       break;
1098     case MEP_OPERAND_CDISP10A4 :
1099       {
1100         long value;
1101         length = extract_normal (cd, ex_info, insn_value, 0, 0, 22, 10, 32, total_length, pc, & value);
1102         value = ((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value));
1103         fields->f_cdisp10 = value;
1104       }
1105       break;
1106     case MEP_OPERAND_CDISP10A8 :
1107       {
1108         long value;
1109         length = extract_normal (cd, ex_info, insn_value, 0, 0, 22, 10, 32, total_length, pc, & value);
1110         value = ((((((value) & (128))) ? (((value) ^ (768))) : (value)) & (512))) ? ((((((value) & (128))) ? (((value) ^ (768))) : (value)) - (1024))) : ((((value) & (128))) ? (((value) ^ (768))) : (value));
1111         fields->f_cdisp10 = value;
1112       }
1113       break;
1114     case MEP_OPERAND_CDISP12 :
1115       length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 12, 32, total_length, pc, & fields->f_12s20);
1116       break;
1117     case MEP_OPERAND_CIMM4 :
1118       length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1119       break;
1120     case MEP_OPERAND_CIMM5 :
1121       length = extract_normal (cd, ex_info, insn_value, 0, 0, 24, 5, 32, total_length, pc, & fields->f_5u24);
1122       break;
1123     case MEP_OPERAND_CODE16 :
1124       length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_16u16);
1125       break;
1126     case MEP_OPERAND_CODE24 :
1127       {
1128         length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 8, 32, total_length, pc, & fields->f_24u4n_hi);
1129         if (length <= 0) break;
1130         length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_24u4n_lo);
1131         if (length <= 0) break;
1132   FLD (f_24u4n) = ((((FLD (f_24u4n_hi)) << (16))) | (FLD (f_24u4n_lo)));
1133       }
1134       break;
1135     case MEP_OPERAND_CP_FLAG :
1136       break;
1137     case MEP_OPERAND_CRN :
1138       length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_crn);
1139       break;
1140     case MEP_OPERAND_CRN64 :
1141       length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_crn);
1142       break;
1143     case MEP_OPERAND_CRNX :
1144       {
1145         length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 1, 32, total_length, pc, & fields->f_crnx_hi);
1146         if (length <= 0) break;
1147         length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_crnx_lo);
1148         if (length <= 0) break;
1149   FLD (f_crnx) = ((((FLD (f_crnx_hi)) << (4))) | (FLD (f_crnx_lo)));
1150       }
1151       break;
1152     case MEP_OPERAND_CRNX64 :
1153       {
1154         length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 1, 32, total_length, pc, & fields->f_crnx_hi);
1155         if (length <= 0) break;
1156         length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_crnx_lo);
1157         if (length <= 0) break;
1158   FLD (f_crnx) = ((((FLD (f_crnx_hi)) << (4))) | (FLD (f_crnx_lo)));
1159       }
1160       break;
1161     case MEP_OPERAND_CSRN :
1162       {
1163         length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 1, 32, total_length, pc, & fields->f_csrn_hi);
1164         if (length <= 0) break;
1165         length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_csrn_lo);
1166         if (length <= 0) break;
1167   FLD (f_csrn) = ((((FLD (f_csrn_hi)) << (4))) | (FLD (f_csrn_lo)));
1168       }
1169       break;
1170     case MEP_OPERAND_CSRN_IDX :
1171       {
1172         length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 1, 32, total_length, pc, & fields->f_csrn_hi);
1173         if (length <= 0) break;
1174         length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_csrn_lo);
1175         if (length <= 0) break;
1176   FLD (f_csrn) = ((((FLD (f_csrn_hi)) << (4))) | (FLD (f_csrn_lo)));
1177       }
1178       break;
1179     case MEP_OPERAND_DBG :
1180       break;
1181     case MEP_OPERAND_DEPC :
1182       break;
1183     case MEP_OPERAND_EPC :
1184       break;
1185     case MEP_OPERAND_EXC :
1186       break;
1187     case MEP_OPERAND_HI :
1188       break;
1189     case MEP_OPERAND_LO :
1190       break;
1191     case MEP_OPERAND_LP :
1192       break;
1193     case MEP_OPERAND_MB0 :
1194       break;
1195     case MEP_OPERAND_MB1 :
1196       break;
1197     case MEP_OPERAND_ME0 :
1198       break;
1199     case MEP_OPERAND_ME1 :
1200       break;
1201     case MEP_OPERAND_NPC :
1202       break;
1203     case MEP_OPERAND_OPT :
1204       break;
1205     case MEP_OPERAND_PCABS24A2 :
1206       {
1207         length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_24u5a2n_hi);
1208         if (length <= 0) break;
1209         length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 7, 32, total_length, pc, & fields->f_24u5a2n_lo);
1210         if (length <= 0) break;
1211   FLD (f_24u5a2n) = ((((FLD (f_24u5a2n_hi)) << (8))) | (((FLD (f_24u5a2n_lo)) << (1))));
1212       }
1213       break;
1214     case MEP_OPERAND_PCREL12A2 :
1215       {
1216         long value;
1217         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);
1218         value = ((((value) << (1))) + (pc));
1219         fields->f_12s4a2 = value;
1220       }
1221       break;
1222     case MEP_OPERAND_PCREL17A2 :
1223       {
1224         long value;
1225         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);
1226         value = ((((value) << (1))) + (pc));
1227         fields->f_17s16a2 = value;
1228       }
1229       break;
1230     case MEP_OPERAND_PCREL24A2 :
1231       {
1232         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);
1233         if (length <= 0) break;
1234         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);
1235         if (length <= 0) break;
1236   FLD (f_24s5a2n) = ((((((FLD (f_24s5a2n_hi)) << (8))) | (((FLD (f_24s5a2n_lo)) << (1))))) + (pc));
1237       }
1238       break;
1239     case MEP_OPERAND_PCREL8A2 :
1240       {
1241         long value;
1242         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);
1243         value = ((((value) << (1))) + (pc));
1244         fields->f_8s8a2 = value;
1245       }
1246       break;
1247     case MEP_OPERAND_PSW :
1248       break;
1249     case MEP_OPERAND_R0 :
1250       break;
1251     case MEP_OPERAND_R1 :
1252       break;
1253     case MEP_OPERAND_RL :
1254       length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 4, 32, total_length, pc, & fields->f_rl);
1255       break;
1256     case MEP_OPERAND_RL5 :
1257       length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 4, 32, total_length, pc, & fields->f_rl5);
1258       break;
1259     case MEP_OPERAND_RM :
1260       length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_rm);
1261       break;
1262     case MEP_OPERAND_RMA :
1263       length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_rm);
1264       break;
1265     case MEP_OPERAND_RN :
1266       length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1267       break;
1268     case MEP_OPERAND_RN3 :
1269       length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1270       break;
1271     case MEP_OPERAND_RN3C :
1272       length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1273       break;
1274     case MEP_OPERAND_RN3L :
1275       length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1276       break;
1277     case MEP_OPERAND_RN3S :
1278       length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1279       break;
1280     case MEP_OPERAND_RN3UC :
1281       length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1282       break;
1283     case MEP_OPERAND_RN3UL :
1284       length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1285       break;
1286     case MEP_OPERAND_RN3US :
1287       length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1288       break;
1289     case MEP_OPERAND_RNC :
1290       length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1291       break;
1292     case MEP_OPERAND_RNL :
1293       length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1294       break;
1295     case MEP_OPERAND_RNS :
1296       length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1297       break;
1298     case MEP_OPERAND_RNUC :
1299       length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1300       break;
1301     case MEP_OPERAND_RNUL :
1302       length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1303       break;
1304     case MEP_OPERAND_RNUS :
1305       length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1306       break;
1307     case MEP_OPERAND_SAR :
1308       break;
1309     case MEP_OPERAND_SDISP16 :
1310       length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 16, 16, 32, total_length, pc, & fields->f_16s16);
1311       break;
1312     case MEP_OPERAND_SIMM16 :
1313       length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 16, 16, 32, total_length, pc, & fields->f_16s16);
1314       break;
1315     case MEP_OPERAND_SIMM6 :
1316       length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 8, 6, 32, total_length, pc, & fields->f_6s8);
1317       break;
1318     case MEP_OPERAND_SIMM8 :
1319       length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 8, 8, 32, total_length, pc, & fields->f_8s8);
1320       break;
1321     case MEP_OPERAND_SP :
1322       break;
1323     case MEP_OPERAND_SPR :
1324       break;
1325     case MEP_OPERAND_TP :
1326       break;
1327     case MEP_OPERAND_TPR :
1328       break;
1329     case MEP_OPERAND_UDISP2 :
1330       length = extract_normal (cd, ex_info, insn_value, 0, 0, 6, 2, 32, total_length, pc, & fields->f_2u6);
1331       break;
1332     case MEP_OPERAND_UDISP7 :
1333       length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 7, 32, total_length, pc, & fields->f_7u9);
1334       break;
1335     case MEP_OPERAND_UDISP7A2 :
1336       {
1337         long value;
1338         length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 6, 32, total_length, pc, & value);
1339         value = ((value) << (1));
1340         fields->f_7u9a2 = value;
1341       }
1342       break;
1343     case MEP_OPERAND_UDISP7A4 :
1344       {
1345         long value;
1346         length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 5, 32, total_length, pc, & value);
1347         value = ((value) << (2));
1348         fields->f_7u9a4 = value;
1349       }
1350       break;
1351     case MEP_OPERAND_UIMM16 :
1352       length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_16u16);
1353       break;
1354     case MEP_OPERAND_UIMM2 :
1355       length = extract_normal (cd, ex_info, insn_value, 0, 0, 10, 2, 32, total_length, pc, & fields->f_2u10);
1356       break;
1357     case MEP_OPERAND_UIMM24 :
1358       {
1359         length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_24u8n_hi);
1360         if (length <= 0) break;
1361         length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 8, 32, total_length, pc, & fields->f_24u8n_lo);
1362         if (length <= 0) break;
1363   FLD (f_24u8n) = ((((FLD (f_24u8n_hi)) << (8))) | (FLD (f_24u8n_lo)));
1364       }
1365       break;
1366     case MEP_OPERAND_UIMM3 :
1367       length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_3u5);
1368       break;
1369     case MEP_OPERAND_UIMM4 :
1370       length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_4u8);
1371       break;
1372     case MEP_OPERAND_UIMM5 :
1373       length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 5, 32, total_length, pc, & fields->f_5u8);
1374       break;
1375     case MEP_OPERAND_UIMM7A4 :
1376       {
1377         long value;
1378         length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 5, 32, total_length, pc, & value);
1379         value = ((value) << (2));
1380         fields->f_7u9a4 = value;
1381       }
1382       break;
1383     case MEP_OPERAND_ZERO :
1384       break;
1385
1386     default :
1387       /* xgettext:c-format */
1388       fprintf (stderr, _("Unrecognized field %d while decoding insn.\n"),
1389                opindex);
1390       abort ();
1391     }
1392
1393   return length;
1394 }
1395
1396 cgen_insert_fn * const mep_cgen_insert_handlers[] = 
1397 {
1398   insert_insn_normal,
1399 };
1400
1401 cgen_extract_fn * const mep_cgen_extract_handlers[] = 
1402 {
1403   extract_insn_normal,
1404 };
1405
1406 int mep_cgen_get_int_operand     (CGEN_CPU_DESC, int, const CGEN_FIELDS *);
1407 bfd_vma mep_cgen_get_vma_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *);
1408
1409 /* Getting values from cgen_fields is handled by a collection of functions.
1410    They are distinguished by the type of the VALUE argument they return.
1411    TODO: floating point, inlining support, remove cases where result type
1412    not appropriate.  */
1413
1414 int
1415 mep_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1416                              int opindex,
1417                              const CGEN_FIELDS * fields)
1418 {
1419   int value;
1420
1421   switch (opindex)
1422     {
1423     case MEP_OPERAND_ADDR24A4 :
1424       value = fields->f_24u8a4n;
1425       break;
1426     case MEP_OPERAND_C5RMUIMM20 :
1427       value = fields->f_c5_rmuimm20;
1428       break;
1429     case MEP_OPERAND_C5RNMUIMM24 :
1430       value = fields->f_c5_rnmuimm24;
1431       break;
1432     case MEP_OPERAND_CALLNUM :
1433       value = fields->f_callnum;
1434       break;
1435     case MEP_OPERAND_CCCC :
1436       value = fields->f_rm;
1437       break;
1438     case MEP_OPERAND_CCRN :
1439       value = fields->f_ccrn;
1440       break;
1441     case MEP_OPERAND_CDISP10 :
1442       value = fields->f_cdisp10;
1443       break;
1444     case MEP_OPERAND_CDISP10A2 :
1445       value = fields->f_cdisp10;
1446       break;
1447     case MEP_OPERAND_CDISP10A4 :
1448       value = fields->f_cdisp10;
1449       break;
1450     case MEP_OPERAND_CDISP10A8 :
1451       value = fields->f_cdisp10;
1452       break;
1453     case MEP_OPERAND_CDISP12 :
1454       value = fields->f_12s20;
1455       break;
1456     case MEP_OPERAND_CIMM4 :
1457       value = fields->f_rn;
1458       break;
1459     case MEP_OPERAND_CIMM5 :
1460       value = fields->f_5u24;
1461       break;
1462     case MEP_OPERAND_CODE16 :
1463       value = fields->f_16u16;
1464       break;
1465     case MEP_OPERAND_CODE24 :
1466       value = fields->f_24u4n;
1467       break;
1468     case MEP_OPERAND_CP_FLAG :
1469       value = 0;
1470       break;
1471     case MEP_OPERAND_CRN :
1472       value = fields->f_crn;
1473       break;
1474     case MEP_OPERAND_CRN64 :
1475       value = fields->f_crn;
1476       break;
1477     case MEP_OPERAND_CRNX :
1478       value = fields->f_crnx;
1479       break;
1480     case MEP_OPERAND_CRNX64 :
1481       value = fields->f_crnx;
1482       break;
1483     case MEP_OPERAND_CSRN :
1484       value = fields->f_csrn;
1485       break;
1486     case MEP_OPERAND_CSRN_IDX :
1487       value = fields->f_csrn;
1488       break;
1489     case MEP_OPERAND_DBG :
1490       value = 0;
1491       break;
1492     case MEP_OPERAND_DEPC :
1493       value = 0;
1494       break;
1495     case MEP_OPERAND_EPC :
1496       value = 0;
1497       break;
1498     case MEP_OPERAND_EXC :
1499       value = 0;
1500       break;
1501     case MEP_OPERAND_HI :
1502       value = 0;
1503       break;
1504     case MEP_OPERAND_LO :
1505       value = 0;
1506       break;
1507     case MEP_OPERAND_LP :
1508       value = 0;
1509       break;
1510     case MEP_OPERAND_MB0 :
1511       value = 0;
1512       break;
1513     case MEP_OPERAND_MB1 :
1514       value = 0;
1515       break;
1516     case MEP_OPERAND_ME0 :
1517       value = 0;
1518       break;
1519     case MEP_OPERAND_ME1 :
1520       value = 0;
1521       break;
1522     case MEP_OPERAND_NPC :
1523       value = 0;
1524       break;
1525     case MEP_OPERAND_OPT :
1526       value = 0;
1527       break;
1528     case MEP_OPERAND_PCABS24A2 :
1529       value = fields->f_24u5a2n;
1530       break;
1531     case MEP_OPERAND_PCREL12A2 :
1532       value = fields->f_12s4a2;
1533       break;
1534     case MEP_OPERAND_PCREL17A2 :
1535       value = fields->f_17s16a2;
1536       break;
1537     case MEP_OPERAND_PCREL24A2 :
1538       value = fields->f_24s5a2n;
1539       break;
1540     case MEP_OPERAND_PCREL8A2 :
1541       value = fields->f_8s8a2;
1542       break;
1543     case MEP_OPERAND_PSW :
1544       value = 0;
1545       break;
1546     case MEP_OPERAND_R0 :
1547       value = 0;
1548       break;
1549     case MEP_OPERAND_R1 :
1550       value = 0;
1551       break;
1552     case MEP_OPERAND_RL :
1553       value = fields->f_rl;
1554       break;
1555     case MEP_OPERAND_RL5 :
1556       value = fields->f_rl5;
1557       break;
1558     case MEP_OPERAND_RM :
1559       value = fields->f_rm;
1560       break;
1561     case MEP_OPERAND_RMA :
1562       value = fields->f_rm;
1563       break;
1564     case MEP_OPERAND_RN :
1565       value = fields->f_rn;
1566       break;
1567     case MEP_OPERAND_RN3 :
1568       value = fields->f_rn3;
1569       break;
1570     case MEP_OPERAND_RN3C :
1571       value = fields->f_rn3;
1572       break;
1573     case MEP_OPERAND_RN3L :
1574       value = fields->f_rn3;
1575       break;
1576     case MEP_OPERAND_RN3S :
1577       value = fields->f_rn3;
1578       break;
1579     case MEP_OPERAND_RN3UC :
1580       value = fields->f_rn3;
1581       break;
1582     case MEP_OPERAND_RN3UL :
1583       value = fields->f_rn3;
1584       break;
1585     case MEP_OPERAND_RN3US :
1586       value = fields->f_rn3;
1587       break;
1588     case MEP_OPERAND_RNC :
1589       value = fields->f_rn;
1590       break;
1591     case MEP_OPERAND_RNL :
1592       value = fields->f_rn;
1593       break;
1594     case MEP_OPERAND_RNS :
1595       value = fields->f_rn;
1596       break;
1597     case MEP_OPERAND_RNUC :
1598       value = fields->f_rn;
1599       break;
1600     case MEP_OPERAND_RNUL :
1601       value = fields->f_rn;
1602       break;
1603     case MEP_OPERAND_RNUS :
1604       value = fields->f_rn;
1605       break;
1606     case MEP_OPERAND_SAR :
1607       value = 0;
1608       break;
1609     case MEP_OPERAND_SDISP16 :
1610       value = fields->f_16s16;
1611       break;
1612     case MEP_OPERAND_SIMM16 :
1613       value = fields->f_16s16;
1614       break;
1615     case MEP_OPERAND_SIMM6 :
1616       value = fields->f_6s8;
1617       break;
1618     case MEP_OPERAND_SIMM8 :
1619       value = fields->f_8s8;
1620       break;
1621     case MEP_OPERAND_SP :
1622       value = 0;
1623       break;
1624     case MEP_OPERAND_SPR :
1625       value = 0;
1626       break;
1627     case MEP_OPERAND_TP :
1628       value = 0;
1629       break;
1630     case MEP_OPERAND_TPR :
1631       value = 0;
1632       break;
1633     case MEP_OPERAND_UDISP2 :
1634       value = fields->f_2u6;
1635       break;
1636     case MEP_OPERAND_UDISP7 :
1637       value = fields->f_7u9;
1638       break;
1639     case MEP_OPERAND_UDISP7A2 :
1640       value = fields->f_7u9a2;
1641       break;
1642     case MEP_OPERAND_UDISP7A4 :
1643       value = fields->f_7u9a4;
1644       break;
1645     case MEP_OPERAND_UIMM16 :
1646       value = fields->f_16u16;
1647       break;
1648     case MEP_OPERAND_UIMM2 :
1649       value = fields->f_2u10;
1650       break;
1651     case MEP_OPERAND_UIMM24 :
1652       value = fields->f_24u8n;
1653       break;
1654     case MEP_OPERAND_UIMM3 :
1655       value = fields->f_3u5;
1656       break;
1657     case MEP_OPERAND_UIMM4 :
1658       value = fields->f_4u8;
1659       break;
1660     case MEP_OPERAND_UIMM5 :
1661       value = fields->f_5u8;
1662       break;
1663     case MEP_OPERAND_UIMM7A4 :
1664       value = fields->f_7u9a4;
1665       break;
1666     case MEP_OPERAND_ZERO :
1667       value = 0;
1668       break;
1669
1670     default :
1671       /* xgettext:c-format */
1672       fprintf (stderr, _("Unrecognized field %d while getting int operand.\n"),
1673                        opindex);
1674       abort ();
1675   }
1676
1677   return value;
1678 }
1679
1680 bfd_vma
1681 mep_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1682                              int opindex,
1683                              const CGEN_FIELDS * fields)
1684 {
1685   bfd_vma value;
1686
1687   switch (opindex)
1688     {
1689     case MEP_OPERAND_ADDR24A4 :
1690       value = fields->f_24u8a4n;
1691       break;
1692     case MEP_OPERAND_C5RMUIMM20 :
1693       value = fields->f_c5_rmuimm20;
1694       break;
1695     case MEP_OPERAND_C5RNMUIMM24 :
1696       value = fields->f_c5_rnmuimm24;
1697       break;
1698     case MEP_OPERAND_CALLNUM :
1699       value = fields->f_callnum;
1700       break;
1701     case MEP_OPERAND_CCCC :
1702       value = fields->f_rm;
1703       break;
1704     case MEP_OPERAND_CCRN :
1705       value = fields->f_ccrn;
1706       break;
1707     case MEP_OPERAND_CDISP10 :
1708       value = fields->f_cdisp10;
1709       break;
1710     case MEP_OPERAND_CDISP10A2 :
1711       value = fields->f_cdisp10;
1712       break;
1713     case MEP_OPERAND_CDISP10A4 :
1714       value = fields->f_cdisp10;
1715       break;
1716     case MEP_OPERAND_CDISP10A8 :
1717       value = fields->f_cdisp10;
1718       break;
1719     case MEP_OPERAND_CDISP12 :
1720       value = fields->f_12s20;
1721       break;
1722     case MEP_OPERAND_CIMM4 :
1723       value = fields->f_rn;
1724       break;
1725     case MEP_OPERAND_CIMM5 :
1726       value = fields->f_5u24;
1727       break;
1728     case MEP_OPERAND_CODE16 :
1729       value = fields->f_16u16;
1730       break;
1731     case MEP_OPERAND_CODE24 :
1732       value = fields->f_24u4n;
1733       break;
1734     case MEP_OPERAND_CP_FLAG :
1735       value = 0;
1736       break;
1737     case MEP_OPERAND_CRN :
1738       value = fields->f_crn;
1739       break;
1740     case MEP_OPERAND_CRN64 :
1741       value = fields->f_crn;
1742       break;
1743     case MEP_OPERAND_CRNX :
1744       value = fields->f_crnx;
1745       break;
1746     case MEP_OPERAND_CRNX64 :
1747       value = fields->f_crnx;
1748       break;
1749     case MEP_OPERAND_CSRN :
1750       value = fields->f_csrn;
1751       break;
1752     case MEP_OPERAND_CSRN_IDX :
1753       value = fields->f_csrn;
1754       break;
1755     case MEP_OPERAND_DBG :
1756       value = 0;
1757       break;
1758     case MEP_OPERAND_DEPC :
1759       value = 0;
1760       break;
1761     case MEP_OPERAND_EPC :
1762       value = 0;
1763       break;
1764     case MEP_OPERAND_EXC :
1765       value = 0;
1766       break;
1767     case MEP_OPERAND_HI :
1768       value = 0;
1769       break;
1770     case MEP_OPERAND_LO :
1771       value = 0;
1772       break;
1773     case MEP_OPERAND_LP :
1774       value = 0;
1775       break;
1776     case MEP_OPERAND_MB0 :
1777       value = 0;
1778       break;
1779     case MEP_OPERAND_MB1 :
1780       value = 0;
1781       break;
1782     case MEP_OPERAND_ME0 :
1783       value = 0;
1784       break;
1785     case MEP_OPERAND_ME1 :
1786       value = 0;
1787       break;
1788     case MEP_OPERAND_NPC :
1789       value = 0;
1790       break;
1791     case MEP_OPERAND_OPT :
1792       value = 0;
1793       break;
1794     case MEP_OPERAND_PCABS24A2 :
1795       value = fields->f_24u5a2n;
1796       break;
1797     case MEP_OPERAND_PCREL12A2 :
1798       value = fields->f_12s4a2;
1799       break;
1800     case MEP_OPERAND_PCREL17A2 :
1801       value = fields->f_17s16a2;
1802       break;
1803     case MEP_OPERAND_PCREL24A2 :
1804       value = fields->f_24s5a2n;
1805       break;
1806     case MEP_OPERAND_PCREL8A2 :
1807       value = fields->f_8s8a2;
1808       break;
1809     case MEP_OPERAND_PSW :
1810       value = 0;
1811       break;
1812     case MEP_OPERAND_R0 :
1813       value = 0;
1814       break;
1815     case MEP_OPERAND_R1 :
1816       value = 0;
1817       break;
1818     case MEP_OPERAND_RL :
1819       value = fields->f_rl;
1820       break;
1821     case MEP_OPERAND_RL5 :
1822       value = fields->f_rl5;
1823       break;
1824     case MEP_OPERAND_RM :
1825       value = fields->f_rm;
1826       break;
1827     case MEP_OPERAND_RMA :
1828       value = fields->f_rm;
1829       break;
1830     case MEP_OPERAND_RN :
1831       value = fields->f_rn;
1832       break;
1833     case MEP_OPERAND_RN3 :
1834       value = fields->f_rn3;
1835       break;
1836     case MEP_OPERAND_RN3C :
1837       value = fields->f_rn3;
1838       break;
1839     case MEP_OPERAND_RN3L :
1840       value = fields->f_rn3;
1841       break;
1842     case MEP_OPERAND_RN3S :
1843       value = fields->f_rn3;
1844       break;
1845     case MEP_OPERAND_RN3UC :
1846       value = fields->f_rn3;
1847       break;
1848     case MEP_OPERAND_RN3UL :
1849       value = fields->f_rn3;
1850       break;
1851     case MEP_OPERAND_RN3US :
1852       value = fields->f_rn3;
1853       break;
1854     case MEP_OPERAND_RNC :
1855       value = fields->f_rn;
1856       break;
1857     case MEP_OPERAND_RNL :
1858       value = fields->f_rn;
1859       break;
1860     case MEP_OPERAND_RNS :
1861       value = fields->f_rn;
1862       break;
1863     case MEP_OPERAND_RNUC :
1864       value = fields->f_rn;
1865       break;
1866     case MEP_OPERAND_RNUL :
1867       value = fields->f_rn;
1868       break;
1869     case MEP_OPERAND_RNUS :
1870       value = fields->f_rn;
1871       break;
1872     case MEP_OPERAND_SAR :
1873       value = 0;
1874       break;
1875     case MEP_OPERAND_SDISP16 :
1876       value = fields->f_16s16;
1877       break;
1878     case MEP_OPERAND_SIMM16 :
1879       value = fields->f_16s16;
1880       break;
1881     case MEP_OPERAND_SIMM6 :
1882       value = fields->f_6s8;
1883       break;
1884     case MEP_OPERAND_SIMM8 :
1885       value = fields->f_8s8;
1886       break;
1887     case MEP_OPERAND_SP :
1888       value = 0;
1889       break;
1890     case MEP_OPERAND_SPR :
1891       value = 0;
1892       break;
1893     case MEP_OPERAND_TP :
1894       value = 0;
1895       break;
1896     case MEP_OPERAND_TPR :
1897       value = 0;
1898       break;
1899     case MEP_OPERAND_UDISP2 :
1900       value = fields->f_2u6;
1901       break;
1902     case MEP_OPERAND_UDISP7 :
1903       value = fields->f_7u9;
1904       break;
1905     case MEP_OPERAND_UDISP7A2 :
1906       value = fields->f_7u9a2;
1907       break;
1908     case MEP_OPERAND_UDISP7A4 :
1909       value = fields->f_7u9a4;
1910       break;
1911     case MEP_OPERAND_UIMM16 :
1912       value = fields->f_16u16;
1913       break;
1914     case MEP_OPERAND_UIMM2 :
1915       value = fields->f_2u10;
1916       break;
1917     case MEP_OPERAND_UIMM24 :
1918       value = fields->f_24u8n;
1919       break;
1920     case MEP_OPERAND_UIMM3 :
1921       value = fields->f_3u5;
1922       break;
1923     case MEP_OPERAND_UIMM4 :
1924       value = fields->f_4u8;
1925       break;
1926     case MEP_OPERAND_UIMM5 :
1927       value = fields->f_5u8;
1928       break;
1929     case MEP_OPERAND_UIMM7A4 :
1930       value = fields->f_7u9a4;
1931       break;
1932     case MEP_OPERAND_ZERO :
1933       value = 0;
1934       break;
1935
1936     default :
1937       /* xgettext:c-format */
1938       fprintf (stderr, _("Unrecognized field %d while getting vma operand.\n"),
1939                        opindex);
1940       abort ();
1941   }
1942
1943   return value;
1944 }
1945
1946 void mep_cgen_set_int_operand  (CGEN_CPU_DESC, int, CGEN_FIELDS *, int);
1947 void mep_cgen_set_vma_operand  (CGEN_CPU_DESC, int, CGEN_FIELDS *, bfd_vma);
1948
1949 /* Stuffing values in cgen_fields is handled by a collection of functions.
1950    They are distinguished by the type of the VALUE argument they accept.
1951    TODO: floating point, inlining support, remove cases where argument type
1952    not appropriate.  */
1953
1954 void
1955 mep_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1956                              int opindex,
1957                              CGEN_FIELDS * fields,
1958                              int value)
1959 {
1960   switch (opindex)
1961     {
1962     case MEP_OPERAND_ADDR24A4 :
1963       fields->f_24u8a4n = value;
1964       break;
1965     case MEP_OPERAND_C5RMUIMM20 :
1966       fields->f_c5_rmuimm20 = value;
1967       break;
1968     case MEP_OPERAND_C5RNMUIMM24 :
1969       fields->f_c5_rnmuimm24 = value;
1970       break;
1971     case MEP_OPERAND_CALLNUM :
1972       fields->f_callnum = value;
1973       break;
1974     case MEP_OPERAND_CCCC :
1975       fields->f_rm = value;
1976       break;
1977     case MEP_OPERAND_CCRN :
1978       fields->f_ccrn = value;
1979       break;
1980     case MEP_OPERAND_CDISP10 :
1981       fields->f_cdisp10 = value;
1982       break;
1983     case MEP_OPERAND_CDISP10A2 :
1984       fields->f_cdisp10 = value;
1985       break;
1986     case MEP_OPERAND_CDISP10A4 :
1987       fields->f_cdisp10 = value;
1988       break;
1989     case MEP_OPERAND_CDISP10A8 :
1990       fields->f_cdisp10 = value;
1991       break;
1992     case MEP_OPERAND_CDISP12 :
1993       fields->f_12s20 = value;
1994       break;
1995     case MEP_OPERAND_CIMM4 :
1996       fields->f_rn = value;
1997       break;
1998     case MEP_OPERAND_CIMM5 :
1999       fields->f_5u24 = value;
2000       break;
2001     case MEP_OPERAND_CODE16 :
2002       fields->f_16u16 = value;
2003       break;
2004     case MEP_OPERAND_CODE24 :
2005       fields->f_24u4n = value;
2006       break;
2007     case MEP_OPERAND_CP_FLAG :
2008       break;
2009     case MEP_OPERAND_CRN :
2010       fields->f_crn = value;
2011       break;
2012     case MEP_OPERAND_CRN64 :
2013       fields->f_crn = value;
2014       break;
2015     case MEP_OPERAND_CRNX :
2016       fields->f_crnx = value;
2017       break;
2018     case MEP_OPERAND_CRNX64 :
2019       fields->f_crnx = value;
2020       break;
2021     case MEP_OPERAND_CSRN :
2022       fields->f_csrn = value;
2023       break;
2024     case MEP_OPERAND_CSRN_IDX :
2025       fields->f_csrn = value;
2026       break;
2027     case MEP_OPERAND_DBG :
2028       break;
2029     case MEP_OPERAND_DEPC :
2030       break;
2031     case MEP_OPERAND_EPC :
2032       break;
2033     case MEP_OPERAND_EXC :
2034       break;
2035     case MEP_OPERAND_HI :
2036       break;
2037     case MEP_OPERAND_LO :
2038       break;
2039     case MEP_OPERAND_LP :
2040       break;
2041     case MEP_OPERAND_MB0 :
2042       break;
2043     case MEP_OPERAND_MB1 :
2044       break;
2045     case MEP_OPERAND_ME0 :
2046       break;
2047     case MEP_OPERAND_ME1 :
2048       break;
2049     case MEP_OPERAND_NPC :
2050       break;
2051     case MEP_OPERAND_OPT :
2052       break;
2053     case MEP_OPERAND_PCABS24A2 :
2054       fields->f_24u5a2n = value;
2055       break;
2056     case MEP_OPERAND_PCREL12A2 :
2057       fields->f_12s4a2 = value;
2058       break;
2059     case MEP_OPERAND_PCREL17A2 :
2060       fields->f_17s16a2 = value;
2061       break;
2062     case MEP_OPERAND_PCREL24A2 :
2063       fields->f_24s5a2n = value;
2064       break;
2065     case MEP_OPERAND_PCREL8A2 :
2066       fields->f_8s8a2 = value;
2067       break;
2068     case MEP_OPERAND_PSW :
2069       break;
2070     case MEP_OPERAND_R0 :
2071       break;
2072     case MEP_OPERAND_R1 :
2073       break;
2074     case MEP_OPERAND_RL :
2075       fields->f_rl = value;
2076       break;
2077     case MEP_OPERAND_RL5 :
2078       fields->f_rl5 = value;
2079       break;
2080     case MEP_OPERAND_RM :
2081       fields->f_rm = value;
2082       break;
2083     case MEP_OPERAND_RMA :
2084       fields->f_rm = value;
2085       break;
2086     case MEP_OPERAND_RN :
2087       fields->f_rn = value;
2088       break;
2089     case MEP_OPERAND_RN3 :
2090       fields->f_rn3 = value;
2091       break;
2092     case MEP_OPERAND_RN3C :
2093       fields->f_rn3 = value;
2094       break;
2095     case MEP_OPERAND_RN3L :
2096       fields->f_rn3 = value;
2097       break;
2098     case MEP_OPERAND_RN3S :
2099       fields->f_rn3 = value;
2100       break;
2101     case MEP_OPERAND_RN3UC :
2102       fields->f_rn3 = value;
2103       break;
2104     case MEP_OPERAND_RN3UL :
2105       fields->f_rn3 = value;
2106       break;
2107     case MEP_OPERAND_RN3US :
2108       fields->f_rn3 = value;
2109       break;
2110     case MEP_OPERAND_RNC :
2111       fields->f_rn = value;
2112       break;
2113     case MEP_OPERAND_RNL :
2114       fields->f_rn = value;
2115       break;
2116     case MEP_OPERAND_RNS :
2117       fields->f_rn = value;
2118       break;
2119     case MEP_OPERAND_RNUC :
2120       fields->f_rn = value;
2121       break;
2122     case MEP_OPERAND_RNUL :
2123       fields->f_rn = value;
2124       break;
2125     case MEP_OPERAND_RNUS :
2126       fields->f_rn = value;
2127       break;
2128     case MEP_OPERAND_SAR :
2129       break;
2130     case MEP_OPERAND_SDISP16 :
2131       fields->f_16s16 = value;
2132       break;
2133     case MEP_OPERAND_SIMM16 :
2134       fields->f_16s16 = value;
2135       break;
2136     case MEP_OPERAND_SIMM6 :
2137       fields->f_6s8 = value;
2138       break;
2139     case MEP_OPERAND_SIMM8 :
2140       fields->f_8s8 = value;
2141       break;
2142     case MEP_OPERAND_SP :
2143       break;
2144     case MEP_OPERAND_SPR :
2145       break;
2146     case MEP_OPERAND_TP :
2147       break;
2148     case MEP_OPERAND_TPR :
2149       break;
2150     case MEP_OPERAND_UDISP2 :
2151       fields->f_2u6 = value;
2152       break;
2153     case MEP_OPERAND_UDISP7 :
2154       fields->f_7u9 = value;
2155       break;
2156     case MEP_OPERAND_UDISP7A2 :
2157       fields->f_7u9a2 = value;
2158       break;
2159     case MEP_OPERAND_UDISP7A4 :
2160       fields->f_7u9a4 = value;
2161       break;
2162     case MEP_OPERAND_UIMM16 :
2163       fields->f_16u16 = value;
2164       break;
2165     case MEP_OPERAND_UIMM2 :
2166       fields->f_2u10 = value;
2167       break;
2168     case MEP_OPERAND_UIMM24 :
2169       fields->f_24u8n = value;
2170       break;
2171     case MEP_OPERAND_UIMM3 :
2172       fields->f_3u5 = value;
2173       break;
2174     case MEP_OPERAND_UIMM4 :
2175       fields->f_4u8 = value;
2176       break;
2177     case MEP_OPERAND_UIMM5 :
2178       fields->f_5u8 = value;
2179       break;
2180     case MEP_OPERAND_UIMM7A4 :
2181       fields->f_7u9a4 = value;
2182       break;
2183     case MEP_OPERAND_ZERO :
2184       break;
2185
2186     default :
2187       /* xgettext:c-format */
2188       fprintf (stderr, _("Unrecognized field %d while setting int operand.\n"),
2189                        opindex);
2190       abort ();
2191   }
2192 }
2193
2194 void
2195 mep_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
2196                              int opindex,
2197                              CGEN_FIELDS * fields,
2198                              bfd_vma value)
2199 {
2200   switch (opindex)
2201     {
2202     case MEP_OPERAND_ADDR24A4 :
2203       fields->f_24u8a4n = value;
2204       break;
2205     case MEP_OPERAND_C5RMUIMM20 :
2206       fields->f_c5_rmuimm20 = value;
2207       break;
2208     case MEP_OPERAND_C5RNMUIMM24 :
2209       fields->f_c5_rnmuimm24 = value;
2210       break;
2211     case MEP_OPERAND_CALLNUM :
2212       fields->f_callnum = value;
2213       break;
2214     case MEP_OPERAND_CCCC :
2215       fields->f_rm = value;
2216       break;
2217     case MEP_OPERAND_CCRN :
2218       fields->f_ccrn = value;
2219       break;
2220     case MEP_OPERAND_CDISP10 :
2221       fields->f_cdisp10 = value;
2222       break;
2223     case MEP_OPERAND_CDISP10A2 :
2224       fields->f_cdisp10 = value;
2225       break;
2226     case MEP_OPERAND_CDISP10A4 :
2227       fields->f_cdisp10 = value;
2228       break;
2229     case MEP_OPERAND_CDISP10A8 :
2230       fields->f_cdisp10 = value;
2231       break;
2232     case MEP_OPERAND_CDISP12 :
2233       fields->f_12s20 = value;
2234       break;
2235     case MEP_OPERAND_CIMM4 :
2236       fields->f_rn = value;
2237       break;
2238     case MEP_OPERAND_CIMM5 :
2239       fields->f_5u24 = value;
2240       break;
2241     case MEP_OPERAND_CODE16 :
2242       fields->f_16u16 = value;
2243       break;
2244     case MEP_OPERAND_CODE24 :
2245       fields->f_24u4n = value;
2246       break;
2247     case MEP_OPERAND_CP_FLAG :
2248       break;
2249     case MEP_OPERAND_CRN :
2250       fields->f_crn = value;
2251       break;
2252     case MEP_OPERAND_CRN64 :
2253       fields->f_crn = value;
2254       break;
2255     case MEP_OPERAND_CRNX :
2256       fields->f_crnx = value;
2257       break;
2258     case MEP_OPERAND_CRNX64 :
2259       fields->f_crnx = value;
2260       break;
2261     case MEP_OPERAND_CSRN :
2262       fields->f_csrn = value;
2263       break;
2264     case MEP_OPERAND_CSRN_IDX :
2265       fields->f_csrn = value;
2266       break;
2267     case MEP_OPERAND_DBG :
2268       break;
2269     case MEP_OPERAND_DEPC :
2270       break;
2271     case MEP_OPERAND_EPC :
2272       break;
2273     case MEP_OPERAND_EXC :
2274       break;
2275     case MEP_OPERAND_HI :
2276       break;
2277     case MEP_OPERAND_LO :
2278       break;
2279     case MEP_OPERAND_LP :
2280       break;
2281     case MEP_OPERAND_MB0 :
2282       break;
2283     case MEP_OPERAND_MB1 :
2284       break;
2285     case MEP_OPERAND_ME0 :
2286       break;
2287     case MEP_OPERAND_ME1 :
2288       break;
2289     case MEP_OPERAND_NPC :
2290       break;
2291     case MEP_OPERAND_OPT :
2292       break;
2293     case MEP_OPERAND_PCABS24A2 :
2294       fields->f_24u5a2n = value;
2295       break;
2296     case MEP_OPERAND_PCREL12A2 :
2297       fields->f_12s4a2 = value;
2298       break;
2299     case MEP_OPERAND_PCREL17A2 :
2300       fields->f_17s16a2 = value;
2301       break;
2302     case MEP_OPERAND_PCREL24A2 :
2303       fields->f_24s5a2n = value;
2304       break;
2305     case MEP_OPERAND_PCREL8A2 :
2306       fields->f_8s8a2 = value;
2307       break;
2308     case MEP_OPERAND_PSW :
2309       break;
2310     case MEP_OPERAND_R0 :
2311       break;
2312     case MEP_OPERAND_R1 :
2313       break;
2314     case MEP_OPERAND_RL :
2315       fields->f_rl = value;
2316       break;
2317     case MEP_OPERAND_RL5 :
2318       fields->f_rl5 = value;
2319       break;
2320     case MEP_OPERAND_RM :
2321       fields->f_rm = value;
2322       break;
2323     case MEP_OPERAND_RMA :
2324       fields->f_rm = value;
2325       break;
2326     case MEP_OPERAND_RN :
2327       fields->f_rn = value;
2328       break;
2329     case MEP_OPERAND_RN3 :
2330       fields->f_rn3 = value;
2331       break;
2332     case MEP_OPERAND_RN3C :
2333       fields->f_rn3 = value;
2334       break;
2335     case MEP_OPERAND_RN3L :
2336       fields->f_rn3 = value;
2337       break;
2338     case MEP_OPERAND_RN3S :
2339       fields->f_rn3 = value;
2340       break;
2341     case MEP_OPERAND_RN3UC :
2342       fields->f_rn3 = value;
2343       break;
2344     case MEP_OPERAND_RN3UL :
2345       fields->f_rn3 = value;
2346       break;
2347     case MEP_OPERAND_RN3US :
2348       fields->f_rn3 = value;
2349       break;
2350     case MEP_OPERAND_RNC :
2351       fields->f_rn = value;
2352       break;
2353     case MEP_OPERAND_RNL :
2354       fields->f_rn = value;
2355       break;
2356     case MEP_OPERAND_RNS :
2357       fields->f_rn = value;
2358       break;
2359     case MEP_OPERAND_RNUC :
2360       fields->f_rn = value;
2361       break;
2362     case MEP_OPERAND_RNUL :
2363       fields->f_rn = value;
2364       break;
2365     case MEP_OPERAND_RNUS :
2366       fields->f_rn = value;
2367       break;
2368     case MEP_OPERAND_SAR :
2369       break;
2370     case MEP_OPERAND_SDISP16 :
2371       fields->f_16s16 = value;
2372       break;
2373     case MEP_OPERAND_SIMM16 :
2374       fields->f_16s16 = value;
2375       break;
2376     case MEP_OPERAND_SIMM6 :
2377       fields->f_6s8 = value;
2378       break;
2379     case MEP_OPERAND_SIMM8 :
2380       fields->f_8s8 = value;
2381       break;
2382     case MEP_OPERAND_SP :
2383       break;
2384     case MEP_OPERAND_SPR :
2385       break;
2386     case MEP_OPERAND_TP :
2387       break;
2388     case MEP_OPERAND_TPR :
2389       break;
2390     case MEP_OPERAND_UDISP2 :
2391       fields->f_2u6 = value;
2392       break;
2393     case MEP_OPERAND_UDISP7 :
2394       fields->f_7u9 = value;
2395       break;
2396     case MEP_OPERAND_UDISP7A2 :
2397       fields->f_7u9a2 = value;
2398       break;
2399     case MEP_OPERAND_UDISP7A4 :
2400       fields->f_7u9a4 = value;
2401       break;
2402     case MEP_OPERAND_UIMM16 :
2403       fields->f_16u16 = value;
2404       break;
2405     case MEP_OPERAND_UIMM2 :
2406       fields->f_2u10 = value;
2407       break;
2408     case MEP_OPERAND_UIMM24 :
2409       fields->f_24u8n = value;
2410       break;
2411     case MEP_OPERAND_UIMM3 :
2412       fields->f_3u5 = value;
2413       break;
2414     case MEP_OPERAND_UIMM4 :
2415       fields->f_4u8 = value;
2416       break;
2417     case MEP_OPERAND_UIMM5 :
2418       fields->f_5u8 = value;
2419       break;
2420     case MEP_OPERAND_UIMM7A4 :
2421       fields->f_7u9a4 = value;
2422       break;
2423     case MEP_OPERAND_ZERO :
2424       break;
2425
2426     default :
2427       /* xgettext:c-format */
2428       fprintf (stderr, _("Unrecognized field %d while setting vma operand.\n"),
2429                        opindex);
2430       abort ();
2431   }
2432 }
2433
2434 /* Function to call before using the instruction builder tables.  */
2435
2436 void
2437 mep_cgen_init_ibld_table (CGEN_CPU_DESC cd)
2438 {
2439   cd->insert_handlers = & mep_cgen_insert_handlers[0];
2440   cd->extract_handlers = & mep_cgen_extract_handlers[0];
2441
2442   cd->insert_operand = mep_cgen_insert_operand;
2443   cd->extract_operand = mep_cgen_extract_operand;
2444
2445   cd->get_int_operand = mep_cgen_get_int_operand;
2446   cd->set_int_operand = mep_cgen_set_int_operand;
2447   cd->get_vma_operand = mep_cgen_get_vma_operand;
2448   cd->set_vma_operand = mep_cgen_set_vma_operand;
2449 }