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 (C) 1996-2016 Free Software Foundation, Inc.
7 
8    This file is part of libopcodes.
9 
10    This library is free software; you can redistribute it and/or modify
11    it under the terms of the GNU General Public License as published by
12    the Free Software Foundation; either version 3, or (at your option)
13    any later version.
14 
15    It is distributed in the hope that it will be useful, but WITHOUT
16    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
18    License for more details.
19 
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software Foundation, Inc.,
22    51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
23 
24 /* ??? Eventually more and more of this stuff can go to cpu-independent files.
25    Keep that in mind.  */
26 
27 #include "sysdep.h"
28 #include <stdio.h>
29 #include "ansidecl.h"
30 #include "dis-asm.h"
31 #include "bfd.h"
32 #include "symcat.h"
33 #include "mep-desc.h"
34 #include "mep-opc.h"
35 #include "cgen/basic-modes.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 
73 /* Operand insertion.  */
74 
75 #if ! CGEN_INT_INSN_P
76 
77 /* Subroutine of insert_normal.  */
78 
79 static CGEN_INLINE void
insert_1(CGEN_CPU_DESC cd,unsigned long value,int start,int length,int word_length,unsigned char * bufp)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 *
insert_normal(CGEN_CPU_DESC cd,long value,unsigned int attrs,unsigned int word_offset,unsigned int start,unsigned int length,unsigned int word_length,unsigned int total_length,CGEN_INSN_BYTES_PTR buffer)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 > 8 * sizeof (CGEN_INSN_INT))
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_within_word, shift_to_word, shift;
211 
212     /* How to shift the value to BIT0 of the word.  */
213     shift_to_word = total_length - (word_offset + word_length);
214 
215     /* How to shift the value to the field within the word.  */
216     if (CGEN_INSN_LSB0_P)
217       shift_within_word = start + 1 - length;
218     else
219       shift_within_word = word_length - start - length;
220 
221     /* The total SHIFT, then mask in the value.  */
222     shift = shift_to_word + shift_within_word;
223     *buffer = (*buffer & ~(mask << shift)) | ((value & mask) << shift);
224   }
225 
226 #else /* ! CGEN_INT_INSN_P */
227 
228   {
229     unsigned char *bufp = (unsigned char *) buffer + word_offset / 8;
230 
231     insert_1 (cd, value, start, length, word_length, bufp);
232   }
233 
234 #endif /* ! CGEN_INT_INSN_P */
235 
236   return NULL;
237 }
238 
239 /* Default insn builder (insert handler).
240    The instruction is recorded in CGEN_INT_INSN_P byte order (meaning
241    that if CGEN_INSN_BYTES_PTR is an int * and thus, the value is
242    recorded in host byte order, otherwise BUFFER is an array of bytes
243    and the value is recorded in target byte order).
244    The result is an error message or NULL if success.  */
245 
246 static const char *
insert_insn_normal(CGEN_CPU_DESC cd,const CGEN_INSN * insn,CGEN_FIELDS * fields,CGEN_INSN_BYTES_PTR buffer,bfd_vma pc)247 insert_insn_normal (CGEN_CPU_DESC cd,
248 		    const CGEN_INSN * insn,
249 		    CGEN_FIELDS * fields,
250 		    CGEN_INSN_BYTES_PTR buffer,
251 		    bfd_vma pc)
252 {
253   const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
254   unsigned long value;
255   const CGEN_SYNTAX_CHAR_TYPE * syn;
256 
257   CGEN_INIT_INSERT (cd);
258   value = CGEN_INSN_BASE_VALUE (insn);
259 
260   /* If we're recording insns as numbers (rather than a string of bytes),
261      target byte order handling is deferred until later.  */
262 
263 #if CGEN_INT_INSN_P
264 
265   put_insn_int_value (cd, buffer, cd->base_insn_bitsize,
266 		      CGEN_FIELDS_BITSIZE (fields), value);
267 
268 #else
269 
270   cgen_put_insn_value (cd, buffer, min ((unsigned) cd->base_insn_bitsize,
271 					(unsigned) CGEN_FIELDS_BITSIZE (fields)),
272 		       value);
273 
274 #endif /* ! CGEN_INT_INSN_P */
275 
276   /* ??? It would be better to scan the format's fields.
277      Still need to be able to insert a value based on the operand though;
278      e.g. storing a branch displacement that got resolved later.
279      Needs more thought first.  */
280 
281   for (syn = CGEN_SYNTAX_STRING (syntax); * syn; ++ syn)
282     {
283       const char *errmsg;
284 
285       if (CGEN_SYNTAX_CHAR_P (* syn))
286 	continue;
287 
288       errmsg = (* cd->insert_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
289 				       fields, buffer, pc);
290       if (errmsg)
291 	return errmsg;
292     }
293 
294   return NULL;
295 }
296 
297 #if CGEN_INT_INSN_P
298 /* Cover function to store an insn value into an integral insn.  Must go here
299    because it needs <prefix>-desc.h for CGEN_INT_INSN_P.  */
300 
301 static void
put_insn_int_value(CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,CGEN_INSN_BYTES_PTR buf,int length,int insn_length,CGEN_INSN_INT value)302 put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
303 		    CGEN_INSN_BYTES_PTR buf,
304 		    int length,
305 		    int insn_length,
306 		    CGEN_INSN_INT value)
307 {
308   /* For architectures with insns smaller than the base-insn-bitsize,
309      length may be too big.  */
310   if (length > insn_length)
311     *buf = value;
312   else
313     {
314       int shift = insn_length - length;
315       /* Written this way to avoid undefined behaviour.  */
316       CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1;
317 
318       *buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
319     }
320 }
321 #endif
322 
323 /* Operand extraction.  */
324 
325 #if ! CGEN_INT_INSN_P
326 
327 /* Subroutine of extract_normal.
328    Ensure sufficient bytes are cached in EX_INFO.
329    OFFSET is the offset in bytes from the start of the insn of the value.
330    BYTES is the length of the needed value.
331    Returns 1 for success, 0 for failure.  */
332 
333 static CGEN_INLINE int
fill_cache(CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,CGEN_EXTRACT_INFO * ex_info,int offset,int bytes,bfd_vma pc)334 fill_cache (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
335 	    CGEN_EXTRACT_INFO *ex_info,
336 	    int offset,
337 	    int bytes,
338 	    bfd_vma pc)
339 {
340   /* It's doubtful that the middle part has already been fetched so
341      we don't optimize that case.  kiss.  */
342   unsigned int mask;
343   disassemble_info *info = (disassemble_info *) ex_info->dis_info;
344 
345   /* First do a quick check.  */
346   mask = (1 << bytes) - 1;
347   if (((ex_info->valid >> offset) & mask) == mask)
348     return 1;
349 
350   /* Search for the first byte we need to read.  */
351   for (mask = 1 << offset; bytes > 0; --bytes, ++offset, mask <<= 1)
352     if (! (mask & ex_info->valid))
353       break;
354 
355   if (bytes)
356     {
357       int status;
358 
359       pc += offset;
360       status = (*info->read_memory_func)
361 	(pc, ex_info->insn_bytes + offset, bytes, info);
362 
363       if (status != 0)
364 	{
365 	  (*info->memory_error_func) (status, pc, info);
366 	  return 0;
367 	}
368 
369       ex_info->valid |= ((1 << bytes) - 1) << offset;
370     }
371 
372   return 1;
373 }
374 
375 /* Subroutine of extract_normal.  */
376 
377 static CGEN_INLINE long
extract_1(CGEN_CPU_DESC cd,CGEN_EXTRACT_INFO * ex_info ATTRIBUTE_UNUSED,int start,int length,int word_length,unsigned char * bufp,bfd_vma pc ATTRIBUTE_UNUSED)378 extract_1 (CGEN_CPU_DESC cd,
379 	   CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED,
380 	   int start,
381 	   int length,
382 	   int word_length,
383 	   unsigned char *bufp,
384 	   bfd_vma pc ATTRIBUTE_UNUSED)
385 {
386   unsigned long x;
387   int shift;
388 
389   x = cgen_get_insn_value (cd, bufp, word_length);
390 
391   if (CGEN_INSN_LSB0_P)
392     shift = (start + 1) - length;
393   else
394     shift = (word_length - (start + length));
395   return x >> shift;
396 }
397 
398 #endif /* ! CGEN_INT_INSN_P */
399 
400 /* Default extraction routine.
401 
402    INSN_VALUE is the first base_insn_bitsize bits of the insn in host order,
403    or sometimes less for cases like the m32r where the base insn size is 32
404    but some insns are 16 bits.
405    ATTRS is a mask of the boolean attributes.  We only need `SIGNED',
406    but for generality we take a bitmask of all of them.
407    WORD_OFFSET is the offset in bits from the start of the insn of the value.
408    WORD_LENGTH is the length of the word in bits in which the value resides.
409    START is the starting bit number in the word, architecture origin.
410    LENGTH is the length of VALUE in bits.
411    TOTAL_LENGTH is the total length of the insn in bits.
412 
413    Returns 1 for success, 0 for failure.  */
414 
415 /* ??? The return code isn't properly used.  wip.  */
416 
417 /* ??? This doesn't handle bfd_vma's.  Create another function when
418    necessary.  */
419 
420 static int
extract_normal(CGEN_CPU_DESC cd,CGEN_EXTRACT_INFO * ex_info,CGEN_INSN_INT insn_value,unsigned int attrs,unsigned int word_offset,unsigned int start,unsigned int length,unsigned int word_length,unsigned int total_length,bfd_vma pc,long * valuep)421 extract_normal (CGEN_CPU_DESC cd,
422 #if ! CGEN_INT_INSN_P
423 		CGEN_EXTRACT_INFO *ex_info,
424 #else
425 		CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED,
426 #endif
427 		CGEN_INSN_INT insn_value,
428 		unsigned int attrs,
429 		unsigned int word_offset,
430 		unsigned int start,
431 		unsigned int length,
432 		unsigned int word_length,
433 		unsigned int total_length,
434 #if ! CGEN_INT_INSN_P
435 		bfd_vma pc,
436 #else
437 		bfd_vma pc ATTRIBUTE_UNUSED,
438 #endif
439 		long *valuep)
440 {
441   long value, mask;
442 
443   /* If LENGTH is zero, this operand doesn't contribute to the value
444      so give it a standard value of zero.  */
445   if (length == 0)
446     {
447       *valuep = 0;
448       return 1;
449     }
450 
451   if (word_length > 8 * sizeof (CGEN_INSN_INT))
452     abort ();
453 
454   /* For architectures with insns smaller than the insn-base-bitsize,
455      word_length may be too big.  */
456   if (cd->min_insn_bitsize < cd->base_insn_bitsize)
457     {
458       if (word_offset + word_length > total_length)
459 	word_length = total_length - word_offset;
460     }
461 
462   /* Does the value reside in INSN_VALUE, and at the right alignment?  */
463 
464   if (CGEN_INT_INSN_P || (word_offset == 0 && word_length == total_length))
465     {
466       if (CGEN_INSN_LSB0_P)
467 	value = insn_value >> ((word_offset + start + 1) - length);
468       else
469 	value = insn_value >> (total_length - ( word_offset + start + length));
470     }
471 
472 #if ! CGEN_INT_INSN_P
473 
474   else
475     {
476       unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
477 
478       if (word_length > 8 * sizeof (CGEN_INSN_INT))
479 	abort ();
480 
481       if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
482 	return 0;
483 
484       value = extract_1 (cd, ex_info, start, length, word_length, bufp, pc);
485     }
486 
487 #endif /* ! CGEN_INT_INSN_P */
488 
489   /* Written this way to avoid undefined behaviour.  */
490   mask = (((1L << (length - 1)) - 1) << 1) | 1;
491 
492   value &= mask;
493   /* sign extend? */
494   if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)
495       && (value & (1L << (length - 1))))
496     value |= ~mask;
497 
498   *valuep = value;
499 
500   return 1;
501 }
502 
503 /* Default insn extractor.
504 
505    INSN_VALUE is the first base_insn_bitsize bits, translated to host order.
506    The extracted fields are stored in FIELDS.
507    EX_INFO is used to handle reading variable length insns.
508    Return the length of the insn in bits, or 0 if no match,
509    or -1 if an error occurs fetching data (memory_error_func will have
510    been called).  */
511 
512 static int
extract_insn_normal(CGEN_CPU_DESC cd,const CGEN_INSN * insn,CGEN_EXTRACT_INFO * ex_info,CGEN_INSN_INT insn_value,CGEN_FIELDS * fields,bfd_vma pc)513 extract_insn_normal (CGEN_CPU_DESC cd,
514 		     const CGEN_INSN *insn,
515 		     CGEN_EXTRACT_INFO *ex_info,
516 		     CGEN_INSN_INT insn_value,
517 		     CGEN_FIELDS *fields,
518 		     bfd_vma pc)
519 {
520   const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
521   const CGEN_SYNTAX_CHAR_TYPE *syn;
522 
523   CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn);
524 
525   CGEN_INIT_EXTRACT (cd);
526 
527   for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn)
528     {
529       int length;
530 
531       if (CGEN_SYNTAX_CHAR_P (*syn))
532 	continue;
533 
534       length = (* cd->extract_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
535 					ex_info, insn_value, fields, pc);
536       if (length <= 0)
537 	return length;
538     }
539 
540   /* We recognized and successfully extracted this insn.  */
541   return CGEN_INSN_BITSIZE (insn);
542 }
543 
544 /* Machine generated code added here.  */
545 
546 const char * mep_cgen_insert_operand
547   (CGEN_CPU_DESC, int, CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma);
548 
549 /* Main entry point for operand insertion.
550 
551    This function is basically just a big switch statement.  Earlier versions
552    used tables to look up the function to use, but
553    - if the table contains both assembler and disassembler functions then
554      the disassembler contains much of the assembler and vice-versa,
555    - there's a lot of inlining possibilities as things grow,
556    - using a switch statement avoids the function call overhead.
557 
558    This function could be moved into `parse_insn_normal', but keeping it
559    separate makes clear the interface between `parse_insn_normal' and each of
560    the handlers.  It's also needed by GAS to insert operands that couldn't be
561    resolved during parsing.  */
562 
563 const char *
mep_cgen_insert_operand(CGEN_CPU_DESC cd,int opindex,CGEN_FIELDS * fields,CGEN_INSN_BYTES_PTR buffer,bfd_vma pc ATTRIBUTE_UNUSED)564 mep_cgen_insert_operand (CGEN_CPU_DESC cd,
565 			     int opindex,
566 			     CGEN_FIELDS * fields,
567 			     CGEN_INSN_BYTES_PTR buffer,
568 			     bfd_vma pc ATTRIBUTE_UNUSED)
569 {
570   const char * errmsg = NULL;
571   unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
572 
573   switch (opindex)
574     {
575     case MEP_OPERAND_ADDR24A4 :
576       {
577 {
578   FLD (f_24u8a4n_hi) = ((UINT) (FLD (f_24u8a4n)) >> (8));
579   FLD (f_24u8a4n_lo) = ((UINT) (((FLD (f_24u8a4n)) & (252))) >> (2));
580 }
581         errmsg = insert_normal (cd, fields->f_24u8a4n_hi, 0, 0, 16, 16, 32, total_length, buffer);
582         if (errmsg)
583           break;
584         errmsg = insert_normal (cd, fields->f_24u8a4n_lo, 0, 0, 8, 6, 32, total_length, buffer);
585         if (errmsg)
586           break;
587       }
588       break;
589     case MEP_OPERAND_C5RMUIMM20 :
590       {
591 {
592   FLD (f_c5_rm) = ((UINT) (FLD (f_c5_rmuimm20)) >> (16));
593   FLD (f_c5_16u16) = ((FLD (f_c5_rmuimm20)) & (65535));
594 }
595         errmsg = insert_normal (cd, fields->f_c5_rm, 0, 0, 8, 4, 32, total_length, buffer);
596         if (errmsg)
597           break;
598         errmsg = insert_normal (cd, fields->f_c5_16u16, 0, 0, 16, 16, 32, total_length, buffer);
599         if (errmsg)
600           break;
601       }
602       break;
603     case MEP_OPERAND_C5RNMUIMM24 :
604       {
605 {
606   FLD (f_c5_rnm) = ((UINT) (FLD (f_c5_rnmuimm24)) >> (16));
607   FLD (f_c5_16u16) = ((FLD (f_c5_rnmuimm24)) & (65535));
608 }
609         errmsg = insert_normal (cd, fields->f_c5_rnm, 0, 0, 4, 8, 32, total_length, buffer);
610         if (errmsg)
611           break;
612         errmsg = insert_normal (cd, fields->f_c5_16u16, 0, 0, 16, 16, 32, total_length, buffer);
613         if (errmsg)
614           break;
615       }
616       break;
617     case MEP_OPERAND_CALLNUM :
618       {
619 {
620   FLD (f_5) = ((((UINT) (FLD (f_callnum)) >> (3))) & (1));
621   FLD (f_6) = ((((UINT) (FLD (f_callnum)) >> (2))) & (1));
622   FLD (f_7) = ((((UINT) (FLD (f_callnum)) >> (1))) & (1));
623   FLD (f_11) = ((FLD (f_callnum)) & (1));
624 }
625         errmsg = insert_normal (cd, fields->f_5, 0, 0, 5, 1, 32, total_length, buffer);
626         if (errmsg)
627           break;
628         errmsg = insert_normal (cd, fields->f_6, 0, 0, 6, 1, 32, total_length, buffer);
629         if (errmsg)
630           break;
631         errmsg = insert_normal (cd, fields->f_7, 0, 0, 7, 1, 32, total_length, buffer);
632         if (errmsg)
633           break;
634         errmsg = insert_normal (cd, fields->f_11, 0, 0, 11, 1, 32, total_length, buffer);
635         if (errmsg)
636           break;
637       }
638       break;
639     case MEP_OPERAND_CCCC :
640       errmsg = insert_normal (cd, fields->f_rm, 0, 0, 8, 4, 32, total_length, buffer);
641       break;
642     case MEP_OPERAND_CCRN :
643       {
644 {
645   FLD (f_ccrn_hi) = ((((UINT) (FLD (f_ccrn)) >> (4))) & (3));
646   FLD (f_ccrn_lo) = ((FLD (f_ccrn)) & (15));
647 }
648         errmsg = insert_normal (cd, fields->f_ccrn_hi, 0, 0, 28, 2, 32, total_length, buffer);
649         if (errmsg)
650           break;
651         errmsg = insert_normal (cd, fields->f_ccrn_lo, 0, 0, 4, 4, 32, total_length, buffer);
652         if (errmsg)
653           break;
654       }
655       break;
656     case MEP_OPERAND_CDISP10 :
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))) & (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);
661       }
662       break;
663     case MEP_OPERAND_CDISP10A2 :
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))) & (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);
668       }
669       break;
670     case MEP_OPERAND_CDISP10A4 :
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))) & (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);
675       }
676       break;
677     case MEP_OPERAND_CDISP10A8 :
678       {
679         long value = fields->f_cdisp10;
680         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)));
681         errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED), 0, 22, 10, 32, total_length, buffer);
682       }
683       break;
684     case MEP_OPERAND_CDISP12 :
685       errmsg = insert_normal (cd, fields->f_12s20, 0|(1<<CGEN_IFLD_SIGNED), 0, 20, 12, 32, total_length, buffer);
686       break;
687     case MEP_OPERAND_CIMM4 :
688       errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
689       break;
690     case MEP_OPERAND_CIMM5 :
691       errmsg = insert_normal (cd, fields->f_5u24, 0, 0, 24, 5, 32, total_length, buffer);
692       break;
693     case MEP_OPERAND_CODE16 :
694       errmsg = insert_normal (cd, fields->f_16u16, 0, 0, 16, 16, 32, total_length, buffer);
695       break;
696     case MEP_OPERAND_CODE24 :
697       {
698 {
699   FLD (f_24u4n_hi) = ((UINT) (FLD (f_24u4n)) >> (16));
700   FLD (f_24u4n_lo) = ((FLD (f_24u4n)) & (65535));
701 }
702         errmsg = insert_normal (cd, fields->f_24u4n_hi, 0, 0, 4, 8, 32, total_length, buffer);
703         if (errmsg)
704           break;
705         errmsg = insert_normal (cd, fields->f_24u4n_lo, 0, 0, 16, 16, 32, total_length, buffer);
706         if (errmsg)
707           break;
708       }
709       break;
710     case MEP_OPERAND_CP_FLAG :
711       break;
712     case MEP_OPERAND_CRN :
713       errmsg = insert_normal (cd, fields->f_crn, 0, 0, 4, 4, 32, total_length, buffer);
714       break;
715     case MEP_OPERAND_CRN64 :
716       errmsg = insert_normal (cd, fields->f_crn, 0, 0, 4, 4, 32, total_length, buffer);
717       break;
718     case MEP_OPERAND_CRNX :
719       {
720 {
721   FLD (f_crnx_lo) = ((FLD (f_crnx)) & (15));
722   FLD (f_crnx_hi) = ((UINT) (FLD (f_crnx)) >> (4));
723 }
724         errmsg = insert_normal (cd, fields->f_crnx_hi, 0, 0, 28, 1, 32, total_length, buffer);
725         if (errmsg)
726           break;
727         errmsg = insert_normal (cd, fields->f_crnx_lo, 0, 0, 4, 4, 32, total_length, buffer);
728         if (errmsg)
729           break;
730       }
731       break;
732     case MEP_OPERAND_CRNX64 :
733       {
734 {
735   FLD (f_crnx_lo) = ((FLD (f_crnx)) & (15));
736   FLD (f_crnx_hi) = ((UINT) (FLD (f_crnx)) >> (4));
737 }
738         errmsg = insert_normal (cd, fields->f_crnx_hi, 0, 0, 28, 1, 32, total_length, buffer);
739         if (errmsg)
740           break;
741         errmsg = insert_normal (cd, fields->f_crnx_lo, 0, 0, 4, 4, 32, total_length, buffer);
742         if (errmsg)
743           break;
744       }
745       break;
746     case MEP_OPERAND_CROC :
747       errmsg = insert_normal (cd, fields->f_ivc2_5u7, 0, 0, 7, 5, 32, total_length, buffer);
748       break;
749     case MEP_OPERAND_CROP :
750       errmsg = insert_normal (cd, fields->f_ivc2_5u23, 0, 0, 23, 5, 32, total_length, buffer);
751       break;
752     case MEP_OPERAND_CRPC :
753       errmsg = insert_normal (cd, fields->f_ivc2_5u26, 0, 0, 26, 5, 32, total_length, buffer);
754       break;
755     case MEP_OPERAND_CRPP :
756       errmsg = insert_normal (cd, fields->f_ivc2_5u18, 0, 0, 18, 5, 32, total_length, buffer);
757       break;
758     case MEP_OPERAND_CRQC :
759       errmsg = insert_normal (cd, fields->f_ivc2_5u21, 0, 0, 21, 5, 32, total_length, buffer);
760       break;
761     case MEP_OPERAND_CRQP :
762       errmsg = insert_normal (cd, fields->f_ivc2_5u13, 0, 0, 13, 5, 32, total_length, buffer);
763       break;
764     case MEP_OPERAND_CSRN :
765       {
766 {
767   FLD (f_csrn_lo) = ((FLD (f_csrn)) & (15));
768   FLD (f_csrn_hi) = ((UINT) (FLD (f_csrn)) >> (4));
769 }
770         errmsg = insert_normal (cd, fields->f_csrn_hi, 0, 0, 15, 1, 32, total_length, buffer);
771         if (errmsg)
772           break;
773         errmsg = insert_normal (cd, fields->f_csrn_lo, 0, 0, 8, 4, 32, total_length, buffer);
774         if (errmsg)
775           break;
776       }
777       break;
778     case MEP_OPERAND_CSRN_IDX :
779       {
780 {
781   FLD (f_csrn_lo) = ((FLD (f_csrn)) & (15));
782   FLD (f_csrn_hi) = ((UINT) (FLD (f_csrn)) >> (4));
783 }
784         errmsg = insert_normal (cd, fields->f_csrn_hi, 0, 0, 15, 1, 32, total_length, buffer);
785         if (errmsg)
786           break;
787         errmsg = insert_normal (cd, fields->f_csrn_lo, 0, 0, 8, 4, 32, total_length, buffer);
788         if (errmsg)
789           break;
790       }
791       break;
792     case MEP_OPERAND_DBG :
793       break;
794     case MEP_OPERAND_DEPC :
795       break;
796     case MEP_OPERAND_EPC :
797       break;
798     case MEP_OPERAND_EXC :
799       break;
800     case MEP_OPERAND_HI :
801       break;
802     case MEP_OPERAND_IMM16P0 :
803       {
804 {
805   FLD (f_ivc2_8u0) = ((((UINT) (FLD (f_ivc2_imm16p0)) >> (8))) & (255));
806   FLD (f_ivc2_8u20) = ((FLD (f_ivc2_imm16p0)) & (255));
807 }
808         errmsg = insert_normal (cd, fields->f_ivc2_8u0, 0, 0, 0, 8, 32, total_length, buffer);
809         if (errmsg)
810           break;
811         errmsg = insert_normal (cd, fields->f_ivc2_8u20, 0, 0, 20, 8, 32, total_length, buffer);
812         if (errmsg)
813           break;
814       }
815       break;
816     case MEP_OPERAND_IMM3P12 :
817       errmsg = insert_normal (cd, fields->f_ivc2_3u12, 0, 0, 12, 3, 32, total_length, buffer);
818       break;
819     case MEP_OPERAND_IMM3P25 :
820       errmsg = insert_normal (cd, fields->f_ivc2_3u25, 0, 0, 25, 3, 32, total_length, buffer);
821       break;
822     case MEP_OPERAND_IMM3P4 :
823       errmsg = insert_normal (cd, fields->f_ivc2_3u4, 0, 0, 4, 3, 32, total_length, buffer);
824       break;
825     case MEP_OPERAND_IMM3P5 :
826       errmsg = insert_normal (cd, fields->f_ivc2_3u5, 0, 0, 5, 3, 32, total_length, buffer);
827       break;
828     case MEP_OPERAND_IMM3P9 :
829       errmsg = insert_normal (cd, fields->f_ivc2_3u9, 0, 0, 9, 3, 32, total_length, buffer);
830       break;
831     case MEP_OPERAND_IMM4P10 :
832       errmsg = insert_normal (cd, fields->f_ivc2_4u10, 0, 0, 10, 4, 32, total_length, buffer);
833       break;
834     case MEP_OPERAND_IMM4P4 :
835       errmsg = insert_normal (cd, fields->f_ivc2_4u4, 0, 0, 4, 4, 32, total_length, buffer);
836       break;
837     case MEP_OPERAND_IMM4P8 :
838       errmsg = insert_normal (cd, fields->f_ivc2_4u8, 0, 0, 8, 4, 32, total_length, buffer);
839       break;
840     case MEP_OPERAND_IMM5P23 :
841       errmsg = insert_normal (cd, fields->f_ivc2_5u23, 0, 0, 23, 5, 32, total_length, buffer);
842       break;
843     case MEP_OPERAND_IMM5P3 :
844       errmsg = insert_normal (cd, fields->f_ivc2_5u3, 0, 0, 3, 5, 32, total_length, buffer);
845       break;
846     case MEP_OPERAND_IMM5P7 :
847       errmsg = insert_normal (cd, fields->f_ivc2_5u7, 0, 0, 7, 5, 32, total_length, buffer);
848       break;
849     case MEP_OPERAND_IMM5P8 :
850       errmsg = insert_normal (cd, fields->f_ivc2_5u8, 0, 0, 8, 5, 32, total_length, buffer);
851       break;
852     case MEP_OPERAND_IMM6P2 :
853       errmsg = insert_normal (cd, fields->f_ivc2_6u2, 0, 0, 2, 6, 32, total_length, buffer);
854       break;
855     case MEP_OPERAND_IMM6P6 :
856       errmsg = insert_normal (cd, fields->f_ivc2_6u6, 0, 0, 6, 6, 32, total_length, buffer);
857       break;
858     case MEP_OPERAND_IMM8P0 :
859       errmsg = insert_normal (cd, fields->f_ivc2_8u0, 0, 0, 0, 8, 32, total_length, buffer);
860       break;
861     case MEP_OPERAND_IMM8P20 :
862       errmsg = insert_normal (cd, fields->f_ivc2_8u20, 0, 0, 20, 8, 32, total_length, buffer);
863       break;
864     case MEP_OPERAND_IMM8P4 :
865       errmsg = insert_normal (cd, fields->f_ivc2_8u4, 0, 0, 4, 8, 32, total_length, buffer);
866       break;
867     case MEP_OPERAND_IVC_X_0_2 :
868       errmsg = insert_normal (cd, fields->f_ivc2_2u0, 0, 0, 0, 2, 32, total_length, buffer);
869       break;
870     case MEP_OPERAND_IVC_X_0_3 :
871       errmsg = insert_normal (cd, fields->f_ivc2_3u0, 0, 0, 0, 3, 32, total_length, buffer);
872       break;
873     case MEP_OPERAND_IVC_X_0_4 :
874       errmsg = insert_normal (cd, fields->f_ivc2_4u0, 0, 0, 0, 4, 32, total_length, buffer);
875       break;
876     case MEP_OPERAND_IVC_X_0_5 :
877       errmsg = insert_normal (cd, fields->f_ivc2_5u0, 0, 0, 0, 5, 32, total_length, buffer);
878       break;
879     case MEP_OPERAND_IVC_X_6_1 :
880       errmsg = insert_normal (cd, fields->f_ivc2_1u6, 0, 0, 6, 1, 32, total_length, buffer);
881       break;
882     case MEP_OPERAND_IVC_X_6_2 :
883       errmsg = insert_normal (cd, fields->f_ivc2_2u6, 0, 0, 6, 2, 32, total_length, buffer);
884       break;
885     case MEP_OPERAND_IVC_X_6_3 :
886       errmsg = insert_normal (cd, fields->f_ivc2_3u6, 0, 0, 6, 3, 32, total_length, buffer);
887       break;
888     case MEP_OPERAND_IVC2_ACC0_0 :
889       break;
890     case MEP_OPERAND_IVC2_ACC0_1 :
891       break;
892     case MEP_OPERAND_IVC2_ACC0_2 :
893       break;
894     case MEP_OPERAND_IVC2_ACC0_3 :
895       break;
896     case MEP_OPERAND_IVC2_ACC0_4 :
897       break;
898     case MEP_OPERAND_IVC2_ACC0_5 :
899       break;
900     case MEP_OPERAND_IVC2_ACC0_6 :
901       break;
902     case MEP_OPERAND_IVC2_ACC0_7 :
903       break;
904     case MEP_OPERAND_IVC2_ACC1_0 :
905       break;
906     case MEP_OPERAND_IVC2_ACC1_1 :
907       break;
908     case MEP_OPERAND_IVC2_ACC1_2 :
909       break;
910     case MEP_OPERAND_IVC2_ACC1_3 :
911       break;
912     case MEP_OPERAND_IVC2_ACC1_4 :
913       break;
914     case MEP_OPERAND_IVC2_ACC1_5 :
915       break;
916     case MEP_OPERAND_IVC2_ACC1_6 :
917       break;
918     case MEP_OPERAND_IVC2_ACC1_7 :
919       break;
920     case MEP_OPERAND_IVC2_CC :
921       break;
922     case MEP_OPERAND_IVC2_COFA0 :
923       break;
924     case MEP_OPERAND_IVC2_COFA1 :
925       break;
926     case MEP_OPERAND_IVC2_COFR0 :
927       break;
928     case MEP_OPERAND_IVC2_COFR1 :
929       break;
930     case MEP_OPERAND_IVC2_CSAR0 :
931       break;
932     case MEP_OPERAND_IVC2_CSAR1 :
933       break;
934     case MEP_OPERAND_IVC2C3CCRN :
935       {
936 {
937   FLD (f_ivc2_ccrn_c3hi) = ((((UINT) (FLD (f_ivc2_ccrn_c3)) >> (4))) & (3));
938   FLD (f_ivc2_ccrn_c3lo) = ((FLD (f_ivc2_ccrn_c3)) & (15));
939 }
940         errmsg = insert_normal (cd, fields->f_ivc2_ccrn_c3hi, 0, 0, 28, 2, 32, total_length, buffer);
941         if (errmsg)
942           break;
943         errmsg = insert_normal (cd, fields->f_ivc2_ccrn_c3lo, 0, 0, 4, 4, 32, total_length, buffer);
944         if (errmsg)
945           break;
946       }
947       break;
948     case MEP_OPERAND_IVC2CCRN :
949       {
950 {
951   FLD (f_ivc2_ccrn_h2) = ((((UINT) (FLD (f_ivc2_ccrn)) >> (4))) & (3));
952   FLD (f_ivc2_ccrn_lo) = ((FLD (f_ivc2_ccrn)) & (15));
953 }
954         errmsg = insert_normal (cd, fields->f_ivc2_ccrn_h2, 0, 0, 20, 2, 32, total_length, buffer);
955         if (errmsg)
956           break;
957         errmsg = insert_normal (cd, fields->f_ivc2_ccrn_lo, 0, 0, 0, 4, 32, total_length, buffer);
958         if (errmsg)
959           break;
960       }
961       break;
962     case MEP_OPERAND_IVC2CRN :
963       {
964 {
965   FLD (f_ivc2_ccrn_h1) = ((((UINT) (FLD (f_ivc2_crnx)) >> (4))) & (1));
966   FLD (f_ivc2_ccrn_lo) = ((FLD (f_ivc2_crnx)) & (15));
967 }
968         errmsg = insert_normal (cd, fields->f_ivc2_ccrn_h1, 0, 0, 20, 1, 32, total_length, buffer);
969         if (errmsg)
970           break;
971         errmsg = insert_normal (cd, fields->f_ivc2_ccrn_lo, 0, 0, 0, 4, 32, total_length, buffer);
972         if (errmsg)
973           break;
974       }
975       break;
976     case MEP_OPERAND_IVC2RM :
977       errmsg = insert_normal (cd, fields->f_ivc2_crm, 0, 0, 4, 4, 32, total_length, buffer);
978       break;
979     case MEP_OPERAND_LO :
980       break;
981     case MEP_OPERAND_LP :
982       break;
983     case MEP_OPERAND_MB0 :
984       break;
985     case MEP_OPERAND_MB1 :
986       break;
987     case MEP_OPERAND_ME0 :
988       break;
989     case MEP_OPERAND_ME1 :
990       break;
991     case MEP_OPERAND_NPC :
992       break;
993     case MEP_OPERAND_OPT :
994       break;
995     case MEP_OPERAND_PCABS24A2 :
996       {
997 {
998   FLD (f_24u5a2n_lo) = ((UINT) (((FLD (f_24u5a2n)) & (255))) >> (1));
999   FLD (f_24u5a2n_hi) = ((UINT) (FLD (f_24u5a2n)) >> (8));
1000 }
1001         errmsg = insert_normal (cd, fields->f_24u5a2n_hi, 0, 0, 16, 16, 32, total_length, buffer);
1002         if (errmsg)
1003           break;
1004         errmsg = insert_normal (cd, fields->f_24u5a2n_lo, 0, 0, 5, 7, 32, total_length, buffer);
1005         if (errmsg)
1006           break;
1007       }
1008       break;
1009     case MEP_OPERAND_PCREL12A2 :
1010       {
1011         long value = fields->f_12s4a2;
1012         value = ((SI) (((value) - (pc))) >> (1));
1013         errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 4, 11, 32, total_length, buffer);
1014       }
1015       break;
1016     case MEP_OPERAND_PCREL17A2 :
1017       {
1018         long value = fields->f_17s16a2;
1019         value = ((SI) (((value) - (pc))) >> (1));
1020         errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 16, 16, 32, total_length, buffer);
1021       }
1022       break;
1023     case MEP_OPERAND_PCREL24A2 :
1024       {
1025 {
1026   FLD (f_24s5a2n) = ((FLD (f_24s5a2n)) - (pc));
1027   FLD (f_24s5a2n_lo) = ((UINT) (((FLD (f_24s5a2n)) & (254))) >> (1));
1028   FLD (f_24s5a2n_hi) = ((INT) (FLD (f_24s5a2n)) >> (8));
1029 }
1030         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);
1031         if (errmsg)
1032           break;
1033         errmsg = insert_normal (cd, fields->f_24s5a2n_lo, 0|(1<<CGEN_IFLD_PCREL_ADDR), 0, 5, 7, 32, total_length, buffer);
1034         if (errmsg)
1035           break;
1036       }
1037       break;
1038     case MEP_OPERAND_PCREL8A2 :
1039       {
1040         long value = fields->f_8s8a2;
1041         value = ((SI) (((value) - (pc))) >> (1));
1042         errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 8, 7, 32, total_length, buffer);
1043       }
1044       break;
1045     case MEP_OPERAND_PSW :
1046       break;
1047     case MEP_OPERAND_R0 :
1048       break;
1049     case MEP_OPERAND_R1 :
1050       break;
1051     case MEP_OPERAND_RL :
1052       errmsg = insert_normal (cd, fields->f_rl, 0, 0, 12, 4, 32, total_length, buffer);
1053       break;
1054     case MEP_OPERAND_RL5 :
1055       errmsg = insert_normal (cd, fields->f_rl5, 0, 0, 20, 4, 32, total_length, buffer);
1056       break;
1057     case MEP_OPERAND_RM :
1058       errmsg = insert_normal (cd, fields->f_rm, 0, 0, 8, 4, 32, total_length, buffer);
1059       break;
1060     case MEP_OPERAND_RMA :
1061       errmsg = insert_normal (cd, fields->f_rm, 0, 0, 8, 4, 32, total_length, buffer);
1062       break;
1063     case MEP_OPERAND_RN :
1064       errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
1065       break;
1066     case MEP_OPERAND_RN3 :
1067       errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
1068       break;
1069     case MEP_OPERAND_RN3C :
1070       errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
1071       break;
1072     case MEP_OPERAND_RN3L :
1073       errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
1074       break;
1075     case MEP_OPERAND_RN3S :
1076       errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
1077       break;
1078     case MEP_OPERAND_RN3UC :
1079       errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
1080       break;
1081     case MEP_OPERAND_RN3UL :
1082       errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
1083       break;
1084     case MEP_OPERAND_RN3US :
1085       errmsg = insert_normal (cd, fields->f_rn3, 0, 0, 5, 3, 32, total_length, buffer);
1086       break;
1087     case MEP_OPERAND_RNC :
1088       errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
1089       break;
1090     case MEP_OPERAND_RNL :
1091       errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
1092       break;
1093     case MEP_OPERAND_RNS :
1094       errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
1095       break;
1096     case MEP_OPERAND_RNUC :
1097       errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
1098       break;
1099     case MEP_OPERAND_RNUL :
1100       errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
1101       break;
1102     case MEP_OPERAND_RNUS :
1103       errmsg = insert_normal (cd, fields->f_rn, 0, 0, 4, 4, 32, total_length, buffer);
1104       break;
1105     case MEP_OPERAND_SAR :
1106       break;
1107     case MEP_OPERAND_SDISP16 :
1108       errmsg = insert_normal (cd, fields->f_16s16, 0|(1<<CGEN_IFLD_SIGNED), 0, 16, 16, 32, total_length, buffer);
1109       break;
1110     case MEP_OPERAND_SIMM16 :
1111       errmsg = insert_normal (cd, fields->f_16s16, 0|(1<<CGEN_IFLD_SIGNED), 0, 16, 16, 32, total_length, buffer);
1112       break;
1113     case MEP_OPERAND_SIMM16P0 :
1114       {
1115 {
1116   FLD (f_ivc2_8u0) = ((((UINT) (FLD (f_ivc2_simm16p0)) >> (8))) & (255));
1117   FLD (f_ivc2_8u20) = ((FLD (f_ivc2_simm16p0)) & (255));
1118 }
1119         errmsg = insert_normal (cd, fields->f_ivc2_8u0, 0, 0, 0, 8, 32, total_length, buffer);
1120         if (errmsg)
1121           break;
1122         errmsg = insert_normal (cd, fields->f_ivc2_8u20, 0, 0, 20, 8, 32, total_length, buffer);
1123         if (errmsg)
1124           break;
1125       }
1126       break;
1127     case MEP_OPERAND_SIMM6 :
1128       errmsg = insert_normal (cd, fields->f_6s8, 0|(1<<CGEN_IFLD_SIGNED), 0, 8, 6, 32, total_length, buffer);
1129       break;
1130     case MEP_OPERAND_SIMM8 :
1131       errmsg = insert_normal (cd, fields->f_8s8, 0|(1<<CGEN_IFLD_SIGNED), 0, 8, 8, 32, total_length, buffer);
1132       break;
1133     case MEP_OPERAND_SIMM8P0 :
1134       errmsg = insert_normal (cd, fields->f_ivc2_8s0, 0|(1<<CGEN_IFLD_SIGNED), 0, 0, 8, 32, total_length, buffer);
1135       break;
1136     case MEP_OPERAND_SIMM8P20 :
1137       errmsg = insert_normal (cd, fields->f_ivc2_8s20, 0|(1<<CGEN_IFLD_SIGNED), 0, 20, 8, 32, total_length, buffer);
1138       break;
1139     case MEP_OPERAND_SIMM8P4 :
1140       errmsg = insert_normal (cd, fields->f_ivc2_8s4, 0|(1<<CGEN_IFLD_SIGNED), 0, 4, 8, 32, total_length, buffer);
1141       break;
1142     case MEP_OPERAND_SP :
1143       break;
1144     case MEP_OPERAND_SPR :
1145       break;
1146     case MEP_OPERAND_TP :
1147       break;
1148     case MEP_OPERAND_TPR :
1149       break;
1150     case MEP_OPERAND_UDISP2 :
1151       errmsg = insert_normal (cd, fields->f_2u6, 0, 0, 6, 2, 32, total_length, buffer);
1152       break;
1153     case MEP_OPERAND_UDISP7 :
1154       errmsg = insert_normal (cd, fields->f_7u9, 0, 0, 9, 7, 32, total_length, buffer);
1155       break;
1156     case MEP_OPERAND_UDISP7A2 :
1157       {
1158         long value = fields->f_7u9a2;
1159         value = ((USI) (value) >> (1));
1160         errmsg = insert_normal (cd, value, 0, 0, 9, 6, 32, total_length, buffer);
1161       }
1162       break;
1163     case MEP_OPERAND_UDISP7A4 :
1164       {
1165         long value = fields->f_7u9a4;
1166         value = ((USI) (value) >> (2));
1167         errmsg = insert_normal (cd, value, 0, 0, 9, 5, 32, total_length, buffer);
1168       }
1169       break;
1170     case MEP_OPERAND_UIMM16 :
1171       errmsg = insert_normal (cd, fields->f_16u16, 0, 0, 16, 16, 32, total_length, buffer);
1172       break;
1173     case MEP_OPERAND_UIMM2 :
1174       errmsg = insert_normal (cd, fields->f_2u10, 0, 0, 10, 2, 32, total_length, buffer);
1175       break;
1176     case MEP_OPERAND_UIMM24 :
1177       {
1178 {
1179   FLD (f_24u8n_hi) = ((UINT) (FLD (f_24u8n)) >> (8));
1180   FLD (f_24u8n_lo) = ((FLD (f_24u8n)) & (255));
1181 }
1182         errmsg = insert_normal (cd, fields->f_24u8n_hi, 0, 0, 16, 16, 32, total_length, buffer);
1183         if (errmsg)
1184           break;
1185         errmsg = insert_normal (cd, fields->f_24u8n_lo, 0, 0, 8, 8, 32, total_length, buffer);
1186         if (errmsg)
1187           break;
1188       }
1189       break;
1190     case MEP_OPERAND_UIMM3 :
1191       errmsg = insert_normal (cd, fields->f_3u5, 0, 0, 5, 3, 32, total_length, buffer);
1192       break;
1193     case MEP_OPERAND_UIMM4 :
1194       errmsg = insert_normal (cd, fields->f_4u8, 0, 0, 8, 4, 32, total_length, buffer);
1195       break;
1196     case MEP_OPERAND_UIMM5 :
1197       errmsg = insert_normal (cd, fields->f_5u8, 0, 0, 8, 5, 32, total_length, buffer);
1198       break;
1199     case MEP_OPERAND_UIMM7A4 :
1200       {
1201         long value = fields->f_7u9a4;
1202         value = ((USI) (value) >> (2));
1203         errmsg = insert_normal (cd, value, 0, 0, 9, 5, 32, total_length, buffer);
1204       }
1205       break;
1206     case MEP_OPERAND_ZERO :
1207       break;
1208 
1209     default :
1210       /* xgettext:c-format */
1211       fprintf (stderr, _("Unrecognized field %d while building insn.\n"),
1212 	       opindex);
1213       abort ();
1214   }
1215 
1216   return errmsg;
1217 }
1218 
1219 int mep_cgen_extract_operand
1220   (CGEN_CPU_DESC, int, CGEN_EXTRACT_INFO *, CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma);
1221 
1222 /* Main entry point for operand extraction.
1223    The result is <= 0 for error, >0 for success.
1224    ??? Actual values aren't well defined right now.
1225 
1226    This function is basically just a big switch statement.  Earlier versions
1227    used tables to look up the function to use, but
1228    - if the table contains both assembler and disassembler functions then
1229      the disassembler contains much of the assembler and vice-versa,
1230    - there's a lot of inlining possibilities as things grow,
1231    - using a switch statement avoids the function call overhead.
1232 
1233    This function could be moved into `print_insn_normal', but keeping it
1234    separate makes clear the interface between `print_insn_normal' and each of
1235    the handlers.  */
1236 
1237 int
mep_cgen_extract_operand(CGEN_CPU_DESC cd,int opindex,CGEN_EXTRACT_INFO * ex_info,CGEN_INSN_INT insn_value,CGEN_FIELDS * fields,bfd_vma pc)1238 mep_cgen_extract_operand (CGEN_CPU_DESC cd,
1239 			     int opindex,
1240 			     CGEN_EXTRACT_INFO *ex_info,
1241 			     CGEN_INSN_INT insn_value,
1242 			     CGEN_FIELDS * fields,
1243 			     bfd_vma pc)
1244 {
1245   /* Assume success (for those operands that are nops).  */
1246   int length = 1;
1247   unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
1248 
1249   switch (opindex)
1250     {
1251     case MEP_OPERAND_ADDR24A4 :
1252       {
1253         length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_24u8a4n_hi);
1254         if (length <= 0) break;
1255         length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 6, 32, total_length, pc, & fields->f_24u8a4n_lo);
1256         if (length <= 0) break;
1257   FLD (f_24u8a4n) = ((((FLD (f_24u8a4n_hi)) << (8))) | (((FLD (f_24u8a4n_lo)) << (2))));
1258       }
1259       break;
1260     case MEP_OPERAND_C5RMUIMM20 :
1261       {
1262         length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_c5_rm);
1263         if (length <= 0) break;
1264         length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_c5_16u16);
1265         if (length <= 0) break;
1266 {
1267   FLD (f_c5_rmuimm20) = ((FLD (f_c5_16u16)) | (((FLD (f_c5_rm)) << (16))));
1268 }
1269       }
1270       break;
1271     case MEP_OPERAND_C5RNMUIMM24 :
1272       {
1273         length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 8, 32, total_length, pc, & fields->f_c5_rnm);
1274         if (length <= 0) break;
1275         length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_c5_16u16);
1276         if (length <= 0) break;
1277 {
1278   FLD (f_c5_rnmuimm24) = ((FLD (f_c5_16u16)) | (((FLD (f_c5_rnm)) << (16))));
1279 }
1280       }
1281       break;
1282     case MEP_OPERAND_CALLNUM :
1283       {
1284         length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 1, 32, total_length, pc, & fields->f_5);
1285         if (length <= 0) break;
1286         length = extract_normal (cd, ex_info, insn_value, 0, 0, 6, 1, 32, total_length, pc, & fields->f_6);
1287         if (length <= 0) break;
1288         length = extract_normal (cd, ex_info, insn_value, 0, 0, 7, 1, 32, total_length, pc, & fields->f_7);
1289         if (length <= 0) break;
1290         length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 1, 32, total_length, pc, & fields->f_11);
1291         if (length <= 0) break;
1292   FLD (f_callnum) = ((((FLD (f_5)) << (3))) | (((((FLD (f_6)) << (2))) | (((((FLD (f_7)) << (1))) | (FLD (f_11)))))));
1293       }
1294       break;
1295     case MEP_OPERAND_CCCC :
1296       length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_rm);
1297       break;
1298     case MEP_OPERAND_CCRN :
1299       {
1300         length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 2, 32, total_length, pc, & fields->f_ccrn_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_ccrn_lo);
1303         if (length <= 0) break;
1304   FLD (f_ccrn) = ((((FLD (f_ccrn_hi)) << (4))) | (FLD (f_ccrn_lo)));
1305       }
1306       break;
1307     case MEP_OPERAND_CDISP10 :
1308       {
1309         long value;
1310         length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 22, 10, 32, total_length, pc, & value);
1311         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)));
1312         fields->f_cdisp10 = value;
1313       }
1314       break;
1315     case MEP_OPERAND_CDISP10A2 :
1316       {
1317         long value;
1318         length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 22, 10, 32, total_length, pc, & value);
1319         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)));
1320         fields->f_cdisp10 = value;
1321       }
1322       break;
1323     case MEP_OPERAND_CDISP10A4 :
1324       {
1325         long value;
1326         length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 22, 10, 32, total_length, pc, & value);
1327         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)));
1328         fields->f_cdisp10 = value;
1329       }
1330       break;
1331     case MEP_OPERAND_CDISP10A8 :
1332       {
1333         long value;
1334         length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 22, 10, 32, total_length, pc, & value);
1335         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)));
1336         fields->f_cdisp10 = value;
1337       }
1338       break;
1339     case MEP_OPERAND_CDISP12 :
1340       length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 20, 12, 32, total_length, pc, & fields->f_12s20);
1341       break;
1342     case MEP_OPERAND_CIMM4 :
1343       length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1344       break;
1345     case MEP_OPERAND_CIMM5 :
1346       length = extract_normal (cd, ex_info, insn_value, 0, 0, 24, 5, 32, total_length, pc, & fields->f_5u24);
1347       break;
1348     case MEP_OPERAND_CODE16 :
1349       length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_16u16);
1350       break;
1351     case MEP_OPERAND_CODE24 :
1352       {
1353         length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 8, 32, total_length, pc, & fields->f_24u4n_hi);
1354         if (length <= 0) break;
1355         length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_24u4n_lo);
1356         if (length <= 0) break;
1357   FLD (f_24u4n) = ((((FLD (f_24u4n_hi)) << (16))) | (FLD (f_24u4n_lo)));
1358       }
1359       break;
1360     case MEP_OPERAND_CP_FLAG :
1361       break;
1362     case MEP_OPERAND_CRN :
1363       length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_crn);
1364       break;
1365     case MEP_OPERAND_CRN64 :
1366       length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_crn);
1367       break;
1368     case MEP_OPERAND_CRNX :
1369       {
1370         length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 1, 32, total_length, pc, & fields->f_crnx_hi);
1371         if (length <= 0) break;
1372         length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_crnx_lo);
1373         if (length <= 0) break;
1374   FLD (f_crnx) = ((((FLD (f_crnx_hi)) << (4))) | (FLD (f_crnx_lo)));
1375       }
1376       break;
1377     case MEP_OPERAND_CRNX64 :
1378       {
1379         length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 1, 32, total_length, pc, & fields->f_crnx_hi);
1380         if (length <= 0) break;
1381         length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_crnx_lo);
1382         if (length <= 0) break;
1383   FLD (f_crnx) = ((((FLD (f_crnx_hi)) << (4))) | (FLD (f_crnx_lo)));
1384       }
1385       break;
1386     case MEP_OPERAND_CROC :
1387       length = extract_normal (cd, ex_info, insn_value, 0, 0, 7, 5, 32, total_length, pc, & fields->f_ivc2_5u7);
1388       break;
1389     case MEP_OPERAND_CROP :
1390       length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 5, 32, total_length, pc, & fields->f_ivc2_5u23);
1391       break;
1392     case MEP_OPERAND_CRPC :
1393       length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 5, 32, total_length, pc, & fields->f_ivc2_5u26);
1394       break;
1395     case MEP_OPERAND_CRPP :
1396       length = extract_normal (cd, ex_info, insn_value, 0, 0, 18, 5, 32, total_length, pc, & fields->f_ivc2_5u18);
1397       break;
1398     case MEP_OPERAND_CRQC :
1399       length = extract_normal (cd, ex_info, insn_value, 0, 0, 21, 5, 32, total_length, pc, & fields->f_ivc2_5u21);
1400       break;
1401     case MEP_OPERAND_CRQP :
1402       length = extract_normal (cd, ex_info, insn_value, 0, 0, 13, 5, 32, total_length, pc, & fields->f_ivc2_5u13);
1403       break;
1404     case MEP_OPERAND_CSRN :
1405       {
1406         length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 1, 32, total_length, pc, & fields->f_csrn_hi);
1407         if (length <= 0) break;
1408         length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_csrn_lo);
1409         if (length <= 0) break;
1410   FLD (f_csrn) = ((((FLD (f_csrn_hi)) << (4))) | (FLD (f_csrn_lo)));
1411       }
1412       break;
1413     case MEP_OPERAND_CSRN_IDX :
1414       {
1415         length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 1, 32, total_length, pc, & fields->f_csrn_hi);
1416         if (length <= 0) break;
1417         length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_csrn_lo);
1418         if (length <= 0) break;
1419   FLD (f_csrn) = ((((FLD (f_csrn_hi)) << (4))) | (FLD (f_csrn_lo)));
1420       }
1421       break;
1422     case MEP_OPERAND_DBG :
1423       break;
1424     case MEP_OPERAND_DEPC :
1425       break;
1426     case MEP_OPERAND_EPC :
1427       break;
1428     case MEP_OPERAND_EXC :
1429       break;
1430     case MEP_OPERAND_HI :
1431       break;
1432     case MEP_OPERAND_IMM16P0 :
1433       {
1434         length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 8, 32, total_length, pc, & fields->f_ivc2_8u0);
1435         if (length <= 0) break;
1436         length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 8, 32, total_length, pc, & fields->f_ivc2_8u20);
1437         if (length <= 0) break;
1438 {
1439   FLD (f_ivc2_imm16p0) = ((FLD (f_ivc2_8u20)) | (((FLD (f_ivc2_8u0)) << (8))));
1440 }
1441       }
1442       break;
1443     case MEP_OPERAND_IMM3P12 :
1444       length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_ivc2_3u12);
1445       break;
1446     case MEP_OPERAND_IMM3P25 :
1447       length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 3, 32, total_length, pc, & fields->f_ivc2_3u25);
1448       break;
1449     case MEP_OPERAND_IMM3P4 :
1450       length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 3, 32, total_length, pc, & fields->f_ivc2_3u4);
1451       break;
1452     case MEP_OPERAND_IMM3P5 :
1453       length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_ivc2_3u5);
1454       break;
1455     case MEP_OPERAND_IMM3P9 :
1456       length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_ivc2_3u9);
1457       break;
1458     case MEP_OPERAND_IMM4P10 :
1459       length = extract_normal (cd, ex_info, insn_value, 0, 0, 10, 4, 32, total_length, pc, & fields->f_ivc2_4u10);
1460       break;
1461     case MEP_OPERAND_IMM4P4 :
1462       length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_ivc2_4u4);
1463       break;
1464     case MEP_OPERAND_IMM4P8 :
1465       length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_ivc2_4u8);
1466       break;
1467     case MEP_OPERAND_IMM5P23 :
1468       length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 5, 32, total_length, pc, & fields->f_ivc2_5u23);
1469       break;
1470     case MEP_OPERAND_IMM5P3 :
1471       length = extract_normal (cd, ex_info, insn_value, 0, 0, 3, 5, 32, total_length, pc, & fields->f_ivc2_5u3);
1472       break;
1473     case MEP_OPERAND_IMM5P7 :
1474       length = extract_normal (cd, ex_info, insn_value, 0, 0, 7, 5, 32, total_length, pc, & fields->f_ivc2_5u7);
1475       break;
1476     case MEP_OPERAND_IMM5P8 :
1477       length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 5, 32, total_length, pc, & fields->f_ivc2_5u8);
1478       break;
1479     case MEP_OPERAND_IMM6P2 :
1480       length = extract_normal (cd, ex_info, insn_value, 0, 0, 2, 6, 32, total_length, pc, & fields->f_ivc2_6u2);
1481       break;
1482     case MEP_OPERAND_IMM6P6 :
1483       length = extract_normal (cd, ex_info, insn_value, 0, 0, 6, 6, 32, total_length, pc, & fields->f_ivc2_6u6);
1484       break;
1485     case MEP_OPERAND_IMM8P0 :
1486       length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 8, 32, total_length, pc, & fields->f_ivc2_8u0);
1487       break;
1488     case MEP_OPERAND_IMM8P20 :
1489       length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 8, 32, total_length, pc, & fields->f_ivc2_8u20);
1490       break;
1491     case MEP_OPERAND_IMM8P4 :
1492       length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 8, 32, total_length, pc, & fields->f_ivc2_8u4);
1493       break;
1494     case MEP_OPERAND_IVC_X_0_2 :
1495       length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 2, 32, total_length, pc, & fields->f_ivc2_2u0);
1496       break;
1497     case MEP_OPERAND_IVC_X_0_3 :
1498       length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 3, 32, total_length, pc, & fields->f_ivc2_3u0);
1499       break;
1500     case MEP_OPERAND_IVC_X_0_4 :
1501       length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 4, 32, total_length, pc, & fields->f_ivc2_4u0);
1502       break;
1503     case MEP_OPERAND_IVC_X_0_5 :
1504       length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 5, 32, total_length, pc, & fields->f_ivc2_5u0);
1505       break;
1506     case MEP_OPERAND_IVC_X_6_1 :
1507       length = extract_normal (cd, ex_info, insn_value, 0, 0, 6, 1, 32, total_length, pc, & fields->f_ivc2_1u6);
1508       break;
1509     case MEP_OPERAND_IVC_X_6_2 :
1510       length = extract_normal (cd, ex_info, insn_value, 0, 0, 6, 2, 32, total_length, pc, & fields->f_ivc2_2u6);
1511       break;
1512     case MEP_OPERAND_IVC_X_6_3 :
1513       length = extract_normal (cd, ex_info, insn_value, 0, 0, 6, 3, 32, total_length, pc, & fields->f_ivc2_3u6);
1514       break;
1515     case MEP_OPERAND_IVC2_ACC0_0 :
1516       break;
1517     case MEP_OPERAND_IVC2_ACC0_1 :
1518       break;
1519     case MEP_OPERAND_IVC2_ACC0_2 :
1520       break;
1521     case MEP_OPERAND_IVC2_ACC0_3 :
1522       break;
1523     case MEP_OPERAND_IVC2_ACC0_4 :
1524       break;
1525     case MEP_OPERAND_IVC2_ACC0_5 :
1526       break;
1527     case MEP_OPERAND_IVC2_ACC0_6 :
1528       break;
1529     case MEP_OPERAND_IVC2_ACC0_7 :
1530       break;
1531     case MEP_OPERAND_IVC2_ACC1_0 :
1532       break;
1533     case MEP_OPERAND_IVC2_ACC1_1 :
1534       break;
1535     case MEP_OPERAND_IVC2_ACC1_2 :
1536       break;
1537     case MEP_OPERAND_IVC2_ACC1_3 :
1538       break;
1539     case MEP_OPERAND_IVC2_ACC1_4 :
1540       break;
1541     case MEP_OPERAND_IVC2_ACC1_5 :
1542       break;
1543     case MEP_OPERAND_IVC2_ACC1_6 :
1544       break;
1545     case MEP_OPERAND_IVC2_ACC1_7 :
1546       break;
1547     case MEP_OPERAND_IVC2_CC :
1548       break;
1549     case MEP_OPERAND_IVC2_COFA0 :
1550       break;
1551     case MEP_OPERAND_IVC2_COFA1 :
1552       break;
1553     case MEP_OPERAND_IVC2_COFR0 :
1554       break;
1555     case MEP_OPERAND_IVC2_COFR1 :
1556       break;
1557     case MEP_OPERAND_IVC2_CSAR0 :
1558       break;
1559     case MEP_OPERAND_IVC2_CSAR1 :
1560       break;
1561     case MEP_OPERAND_IVC2C3CCRN :
1562       {
1563         length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 2, 32, total_length, pc, & fields->f_ivc2_ccrn_c3hi);
1564         if (length <= 0) break;
1565         length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_ivc2_ccrn_c3lo);
1566         if (length <= 0) break;
1567   FLD (f_ivc2_ccrn_c3) = ((((FLD (f_ivc2_ccrn_c3hi)) << (4))) | (FLD (f_ivc2_ccrn_c3lo)));
1568       }
1569       break;
1570     case MEP_OPERAND_IVC2CCRN :
1571       {
1572         length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 2, 32, total_length, pc, & fields->f_ivc2_ccrn_h2);
1573         if (length <= 0) break;
1574         length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 4, 32, total_length, pc, & fields->f_ivc2_ccrn_lo);
1575         if (length <= 0) break;
1576   FLD (f_ivc2_ccrn) = ((((FLD (f_ivc2_ccrn_h2)) << (4))) | (FLD (f_ivc2_ccrn_lo)));
1577       }
1578       break;
1579     case MEP_OPERAND_IVC2CRN :
1580       {
1581         length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 1, 32, total_length, pc, & fields->f_ivc2_ccrn_h1);
1582         if (length <= 0) break;
1583         length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 4, 32, total_length, pc, & fields->f_ivc2_ccrn_lo);
1584         if (length <= 0) break;
1585   FLD (f_ivc2_crnx) = ((((FLD (f_ivc2_ccrn_h1)) << (4))) | (FLD (f_ivc2_ccrn_lo)));
1586       }
1587       break;
1588     case MEP_OPERAND_IVC2RM :
1589       length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_ivc2_crm);
1590       break;
1591     case MEP_OPERAND_LO :
1592       break;
1593     case MEP_OPERAND_LP :
1594       break;
1595     case MEP_OPERAND_MB0 :
1596       break;
1597     case MEP_OPERAND_MB1 :
1598       break;
1599     case MEP_OPERAND_ME0 :
1600       break;
1601     case MEP_OPERAND_ME1 :
1602       break;
1603     case MEP_OPERAND_NPC :
1604       break;
1605     case MEP_OPERAND_OPT :
1606       break;
1607     case MEP_OPERAND_PCABS24A2 :
1608       {
1609         length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_24u5a2n_hi);
1610         if (length <= 0) break;
1611         length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 7, 32, total_length, pc, & fields->f_24u5a2n_lo);
1612         if (length <= 0) break;
1613   FLD (f_24u5a2n) = ((((FLD (f_24u5a2n_hi)) << (8))) | (((FLD (f_24u5a2n_lo)) << (1))));
1614       }
1615       break;
1616     case MEP_OPERAND_PCREL12A2 :
1617       {
1618         long value;
1619         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);
1620         value = ((((value) << (1))) + (pc));
1621         fields->f_12s4a2 = value;
1622       }
1623       break;
1624     case MEP_OPERAND_PCREL17A2 :
1625       {
1626         long value;
1627         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);
1628         value = ((((value) << (1))) + (pc));
1629         fields->f_17s16a2 = value;
1630       }
1631       break;
1632     case MEP_OPERAND_PCREL24A2 :
1633       {
1634         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);
1635         if (length <= 0) break;
1636         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);
1637         if (length <= 0) break;
1638   FLD (f_24s5a2n) = ((((((FLD (f_24s5a2n_hi)) << (8))) | (((FLD (f_24s5a2n_lo)) << (1))))) + (pc));
1639       }
1640       break;
1641     case MEP_OPERAND_PCREL8A2 :
1642       {
1643         long value;
1644         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);
1645         value = ((((value) << (1))) + (pc));
1646         fields->f_8s8a2 = value;
1647       }
1648       break;
1649     case MEP_OPERAND_PSW :
1650       break;
1651     case MEP_OPERAND_R0 :
1652       break;
1653     case MEP_OPERAND_R1 :
1654       break;
1655     case MEP_OPERAND_RL :
1656       length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 4, 32, total_length, pc, & fields->f_rl);
1657       break;
1658     case MEP_OPERAND_RL5 :
1659       length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 4, 32, total_length, pc, & fields->f_rl5);
1660       break;
1661     case MEP_OPERAND_RM :
1662       length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_rm);
1663       break;
1664     case MEP_OPERAND_RMA :
1665       length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_rm);
1666       break;
1667     case MEP_OPERAND_RN :
1668       length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1669       break;
1670     case MEP_OPERAND_RN3 :
1671       length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1672       break;
1673     case MEP_OPERAND_RN3C :
1674       length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1675       break;
1676     case MEP_OPERAND_RN3L :
1677       length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1678       break;
1679     case MEP_OPERAND_RN3S :
1680       length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1681       break;
1682     case MEP_OPERAND_RN3UC :
1683       length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1684       break;
1685     case MEP_OPERAND_RN3UL :
1686       length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1687       break;
1688     case MEP_OPERAND_RN3US :
1689       length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_rn3);
1690       break;
1691     case MEP_OPERAND_RNC :
1692       length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1693       break;
1694     case MEP_OPERAND_RNL :
1695       length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1696       break;
1697     case MEP_OPERAND_RNS :
1698       length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1699       break;
1700     case MEP_OPERAND_RNUC :
1701       length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1702       break;
1703     case MEP_OPERAND_RNUL :
1704       length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1705       break;
1706     case MEP_OPERAND_RNUS :
1707       length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 4, 32, total_length, pc, & fields->f_rn);
1708       break;
1709     case MEP_OPERAND_SAR :
1710       break;
1711     case MEP_OPERAND_SDISP16 :
1712       length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 16, 16, 32, total_length, pc, & fields->f_16s16);
1713       break;
1714     case MEP_OPERAND_SIMM16 :
1715       length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 16, 16, 32, total_length, pc, & fields->f_16s16);
1716       break;
1717     case MEP_OPERAND_SIMM16P0 :
1718       {
1719         length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 8, 32, total_length, pc, & fields->f_ivc2_8u0);
1720         if (length <= 0) break;
1721         length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 8, 32, total_length, pc, & fields->f_ivc2_8u20);
1722         if (length <= 0) break;
1723 {
1724   FLD (f_ivc2_simm16p0) = ((FLD (f_ivc2_8u20)) | (((FLD (f_ivc2_8u0)) << (8))));
1725 }
1726       }
1727       break;
1728     case MEP_OPERAND_SIMM6 :
1729       length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 8, 6, 32, total_length, pc, & fields->f_6s8);
1730       break;
1731     case MEP_OPERAND_SIMM8 :
1732       length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 8, 8, 32, total_length, pc, & fields->f_8s8);
1733       break;
1734     case MEP_OPERAND_SIMM8P0 :
1735       length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 0, 8, 32, total_length, pc, & fields->f_ivc2_8s0);
1736       break;
1737     case MEP_OPERAND_SIMM8P20 :
1738       length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 20, 8, 32, total_length, pc, & fields->f_ivc2_8s20);
1739       break;
1740     case MEP_OPERAND_SIMM8P4 :
1741       length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 4, 8, 32, total_length, pc, & fields->f_ivc2_8s4);
1742       break;
1743     case MEP_OPERAND_SP :
1744       break;
1745     case MEP_OPERAND_SPR :
1746       break;
1747     case MEP_OPERAND_TP :
1748       break;
1749     case MEP_OPERAND_TPR :
1750       break;
1751     case MEP_OPERAND_UDISP2 :
1752       length = extract_normal (cd, ex_info, insn_value, 0, 0, 6, 2, 32, total_length, pc, & fields->f_2u6);
1753       break;
1754     case MEP_OPERAND_UDISP7 :
1755       length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 7, 32, total_length, pc, & fields->f_7u9);
1756       break;
1757     case MEP_OPERAND_UDISP7A2 :
1758       {
1759         long value;
1760         length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 6, 32, total_length, pc, & value);
1761         value = ((value) << (1));
1762         fields->f_7u9a2 = value;
1763       }
1764       break;
1765     case MEP_OPERAND_UDISP7A4 :
1766       {
1767         long value;
1768         length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 5, 32, total_length, pc, & value);
1769         value = ((value) << (2));
1770         fields->f_7u9a4 = value;
1771       }
1772       break;
1773     case MEP_OPERAND_UIMM16 :
1774       length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_16u16);
1775       break;
1776     case MEP_OPERAND_UIMM2 :
1777       length = extract_normal (cd, ex_info, insn_value, 0, 0, 10, 2, 32, total_length, pc, & fields->f_2u10);
1778       break;
1779     case MEP_OPERAND_UIMM24 :
1780       {
1781         length = extract_normal (cd, ex_info, insn_value, 0, 0, 16, 16, 32, total_length, pc, & fields->f_24u8n_hi);
1782         if (length <= 0) break;
1783         length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 8, 32, total_length, pc, & fields->f_24u8n_lo);
1784         if (length <= 0) break;
1785   FLD (f_24u8n) = ((((FLD (f_24u8n_hi)) << (8))) | (FLD (f_24u8n_lo)));
1786       }
1787       break;
1788     case MEP_OPERAND_UIMM3 :
1789       length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_3u5);
1790       break;
1791     case MEP_OPERAND_UIMM4 :
1792       length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 32, total_length, pc, & fields->f_4u8);
1793       break;
1794     case MEP_OPERAND_UIMM5 :
1795       length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 5, 32, total_length, pc, & fields->f_5u8);
1796       break;
1797     case MEP_OPERAND_UIMM7A4 :
1798       {
1799         long value;
1800         length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 5, 32, total_length, pc, & value);
1801         value = ((value) << (2));
1802         fields->f_7u9a4 = value;
1803       }
1804       break;
1805     case MEP_OPERAND_ZERO :
1806       break;
1807 
1808     default :
1809       /* xgettext:c-format */
1810       fprintf (stderr, _("Unrecognized field %d while decoding insn.\n"),
1811 	       opindex);
1812       abort ();
1813     }
1814 
1815   return length;
1816 }
1817 
1818 cgen_insert_fn * const mep_cgen_insert_handlers[] =
1819 {
1820   insert_insn_normal,
1821 };
1822 
1823 cgen_extract_fn * const mep_cgen_extract_handlers[] =
1824 {
1825   extract_insn_normal,
1826 };
1827 
1828 int mep_cgen_get_int_operand     (CGEN_CPU_DESC, int, const CGEN_FIELDS *);
1829 bfd_vma mep_cgen_get_vma_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *);
1830 
1831 /* Getting values from cgen_fields is handled by a collection of functions.
1832    They are distinguished by the type of the VALUE argument they return.
1833    TODO: floating point, inlining support, remove cases where result type
1834    not appropriate.  */
1835 
1836 int
mep_cgen_get_int_operand(CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,int opindex,const CGEN_FIELDS * fields)1837 mep_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
1838 			     int opindex,
1839 			     const CGEN_FIELDS * fields)
1840 {
1841   int value;
1842 
1843   switch (opindex)
1844     {
1845     case MEP_OPERAND_ADDR24A4 :
1846       value = fields->f_24u8a4n;
1847       break;
1848     case MEP_OPERAND_C5RMUIMM20 :
1849       value = fields->f_c5_rmuimm20;
1850       break;
1851     case MEP_OPERAND_C5RNMUIMM24 :
1852       value = fields->f_c5_rnmuimm24;
1853       break;
1854     case MEP_OPERAND_CALLNUM :
1855       value = fields->f_callnum;
1856       break;
1857     case MEP_OPERAND_CCCC :
1858       value = fields->f_rm;
1859       break;
1860     case MEP_OPERAND_CCRN :
1861       value = fields->f_ccrn;
1862       break;
1863     case MEP_OPERAND_CDISP10 :
1864       value = fields->f_cdisp10;
1865       break;
1866     case MEP_OPERAND_CDISP10A2 :
1867       value = fields->f_cdisp10;
1868       break;
1869     case MEP_OPERAND_CDISP10A4 :
1870       value = fields->f_cdisp10;
1871       break;
1872     case MEP_OPERAND_CDISP10A8 :
1873       value = fields->f_cdisp10;
1874       break;
1875     case MEP_OPERAND_CDISP12 :
1876       value = fields->f_12s20;
1877       break;
1878     case MEP_OPERAND_CIMM4 :
1879       value = fields->f_rn;
1880       break;
1881     case MEP_OPERAND_CIMM5 :
1882       value = fields->f_5u24;
1883       break;
1884     case MEP_OPERAND_CODE16 :
1885       value = fields->f_16u16;
1886       break;
1887     case MEP_OPERAND_CODE24 :
1888       value = fields->f_24u4n;
1889       break;
1890     case MEP_OPERAND_CP_FLAG :
1891       value = 0;
1892       break;
1893     case MEP_OPERAND_CRN :
1894       value = fields->f_crn;
1895       break;
1896     case MEP_OPERAND_CRN64 :
1897       value = fields->f_crn;
1898       break;
1899     case MEP_OPERAND_CRNX :
1900       value = fields->f_crnx;
1901       break;
1902     case MEP_OPERAND_CRNX64 :
1903       value = fields->f_crnx;
1904       break;
1905     case MEP_OPERAND_CROC :
1906       value = fields->f_ivc2_5u7;
1907       break;
1908     case MEP_OPERAND_CROP :
1909       value = fields->f_ivc2_5u23;
1910       break;
1911     case MEP_OPERAND_CRPC :
1912       value = fields->f_ivc2_5u26;
1913       break;
1914     case MEP_OPERAND_CRPP :
1915       value = fields->f_ivc2_5u18;
1916       break;
1917     case MEP_OPERAND_CRQC :
1918       value = fields->f_ivc2_5u21;
1919       break;
1920     case MEP_OPERAND_CRQP :
1921       value = fields->f_ivc2_5u13;
1922       break;
1923     case MEP_OPERAND_CSRN :
1924       value = fields->f_csrn;
1925       break;
1926     case MEP_OPERAND_CSRN_IDX :
1927       value = fields->f_csrn;
1928       break;
1929     case MEP_OPERAND_DBG :
1930       value = 0;
1931       break;
1932     case MEP_OPERAND_DEPC :
1933       value = 0;
1934       break;
1935     case MEP_OPERAND_EPC :
1936       value = 0;
1937       break;
1938     case MEP_OPERAND_EXC :
1939       value = 0;
1940       break;
1941     case MEP_OPERAND_HI :
1942       value = 0;
1943       break;
1944     case MEP_OPERAND_IMM16P0 :
1945       value = fields->f_ivc2_imm16p0;
1946       break;
1947     case MEP_OPERAND_IMM3P12 :
1948       value = fields->f_ivc2_3u12;
1949       break;
1950     case MEP_OPERAND_IMM3P25 :
1951       value = fields->f_ivc2_3u25;
1952       break;
1953     case MEP_OPERAND_IMM3P4 :
1954       value = fields->f_ivc2_3u4;
1955       break;
1956     case MEP_OPERAND_IMM3P5 :
1957       value = fields->f_ivc2_3u5;
1958       break;
1959     case MEP_OPERAND_IMM3P9 :
1960       value = fields->f_ivc2_3u9;
1961       break;
1962     case MEP_OPERAND_IMM4P10 :
1963       value = fields->f_ivc2_4u10;
1964       break;
1965     case MEP_OPERAND_IMM4P4 :
1966       value = fields->f_ivc2_4u4;
1967       break;
1968     case MEP_OPERAND_IMM4P8 :
1969       value = fields->f_ivc2_4u8;
1970       break;
1971     case MEP_OPERAND_IMM5P23 :
1972       value = fields->f_ivc2_5u23;
1973       break;
1974     case MEP_OPERAND_IMM5P3 :
1975       value = fields->f_ivc2_5u3;
1976       break;
1977     case MEP_OPERAND_IMM5P7 :
1978       value = fields->f_ivc2_5u7;
1979       break;
1980     case MEP_OPERAND_IMM5P8 :
1981       value = fields->f_ivc2_5u8;
1982       break;
1983     case MEP_OPERAND_IMM6P2 :
1984       value = fields->f_ivc2_6u2;
1985       break;
1986     case MEP_OPERAND_IMM6P6 :
1987       value = fields->f_ivc2_6u6;
1988       break;
1989     case MEP_OPERAND_IMM8P0 :
1990       value = fields->f_ivc2_8u0;
1991       break;
1992     case MEP_OPERAND_IMM8P20 :
1993       value = fields->f_ivc2_8u20;
1994       break;
1995     case MEP_OPERAND_IMM8P4 :
1996       value = fields->f_ivc2_8u4;
1997       break;
1998     case MEP_OPERAND_IVC_X_0_2 :
1999       value = fields->f_ivc2_2u0;
2000       break;
2001     case MEP_OPERAND_IVC_X_0_3 :
2002       value = fields->f_ivc2_3u0;
2003       break;
2004     case MEP_OPERAND_IVC_X_0_4 :
2005       value = fields->f_ivc2_4u0;
2006       break;
2007     case MEP_OPERAND_IVC_X_0_5 :
2008       value = fields->f_ivc2_5u0;
2009       break;
2010     case MEP_OPERAND_IVC_X_6_1 :
2011       value = fields->f_ivc2_1u6;
2012       break;
2013     case MEP_OPERAND_IVC_X_6_2 :
2014       value = fields->f_ivc2_2u6;
2015       break;
2016     case MEP_OPERAND_IVC_X_6_3 :
2017       value = fields->f_ivc2_3u6;
2018       break;
2019     case MEP_OPERAND_IVC2_ACC0_0 :
2020       value = 0;
2021       break;
2022     case MEP_OPERAND_IVC2_ACC0_1 :
2023       value = 0;
2024       break;
2025     case MEP_OPERAND_IVC2_ACC0_2 :
2026       value = 0;
2027       break;
2028     case MEP_OPERAND_IVC2_ACC0_3 :
2029       value = 0;
2030       break;
2031     case MEP_OPERAND_IVC2_ACC0_4 :
2032       value = 0;
2033       break;
2034     case MEP_OPERAND_IVC2_ACC0_5 :
2035       value = 0;
2036       break;
2037     case MEP_OPERAND_IVC2_ACC0_6 :
2038       value = 0;
2039       break;
2040     case MEP_OPERAND_IVC2_ACC0_7 :
2041       value = 0;
2042       break;
2043     case MEP_OPERAND_IVC2_ACC1_0 :
2044       value = 0;
2045       break;
2046     case MEP_OPERAND_IVC2_ACC1_1 :
2047       value = 0;
2048       break;
2049     case MEP_OPERAND_IVC2_ACC1_2 :
2050       value = 0;
2051       break;
2052     case MEP_OPERAND_IVC2_ACC1_3 :
2053       value = 0;
2054       break;
2055     case MEP_OPERAND_IVC2_ACC1_4 :
2056       value = 0;
2057       break;
2058     case MEP_OPERAND_IVC2_ACC1_5 :
2059       value = 0;
2060       break;
2061     case MEP_OPERAND_IVC2_ACC1_6 :
2062       value = 0;
2063       break;
2064     case MEP_OPERAND_IVC2_ACC1_7 :
2065       value = 0;
2066       break;
2067     case MEP_OPERAND_IVC2_CC :
2068       value = 0;
2069       break;
2070     case MEP_OPERAND_IVC2_COFA0 :
2071       value = 0;
2072       break;
2073     case MEP_OPERAND_IVC2_COFA1 :
2074       value = 0;
2075       break;
2076     case MEP_OPERAND_IVC2_COFR0 :
2077       value = 0;
2078       break;
2079     case MEP_OPERAND_IVC2_COFR1 :
2080       value = 0;
2081       break;
2082     case MEP_OPERAND_IVC2_CSAR0 :
2083       value = 0;
2084       break;
2085     case MEP_OPERAND_IVC2_CSAR1 :
2086       value = 0;
2087       break;
2088     case MEP_OPERAND_IVC2C3CCRN :
2089       value = fields->f_ivc2_ccrn_c3;
2090       break;
2091     case MEP_OPERAND_IVC2CCRN :
2092       value = fields->f_ivc2_ccrn;
2093       break;
2094     case MEP_OPERAND_IVC2CRN :
2095       value = fields->f_ivc2_crnx;
2096       break;
2097     case MEP_OPERAND_IVC2RM :
2098       value = fields->f_ivc2_crm;
2099       break;
2100     case MEP_OPERAND_LO :
2101       value = 0;
2102       break;
2103     case MEP_OPERAND_LP :
2104       value = 0;
2105       break;
2106     case MEP_OPERAND_MB0 :
2107       value = 0;
2108       break;
2109     case MEP_OPERAND_MB1 :
2110       value = 0;
2111       break;
2112     case MEP_OPERAND_ME0 :
2113       value = 0;
2114       break;
2115     case MEP_OPERAND_ME1 :
2116       value = 0;
2117       break;
2118     case MEP_OPERAND_NPC :
2119       value = 0;
2120       break;
2121     case MEP_OPERAND_OPT :
2122       value = 0;
2123       break;
2124     case MEP_OPERAND_PCABS24A2 :
2125       value = fields->f_24u5a2n;
2126       break;
2127     case MEP_OPERAND_PCREL12A2 :
2128       value = fields->f_12s4a2;
2129       break;
2130     case MEP_OPERAND_PCREL17A2 :
2131       value = fields->f_17s16a2;
2132       break;
2133     case MEP_OPERAND_PCREL24A2 :
2134       value = fields->f_24s5a2n;
2135       break;
2136     case MEP_OPERAND_PCREL8A2 :
2137       value = fields->f_8s8a2;
2138       break;
2139     case MEP_OPERAND_PSW :
2140       value = 0;
2141       break;
2142     case MEP_OPERAND_R0 :
2143       value = 0;
2144       break;
2145     case MEP_OPERAND_R1 :
2146       value = 0;
2147       break;
2148     case MEP_OPERAND_RL :
2149       value = fields->f_rl;
2150       break;
2151     case MEP_OPERAND_RL5 :
2152       value = fields->f_rl5;
2153       break;
2154     case MEP_OPERAND_RM :
2155       value = fields->f_rm;
2156       break;
2157     case MEP_OPERAND_RMA :
2158       value = fields->f_rm;
2159       break;
2160     case MEP_OPERAND_RN :
2161       value = fields->f_rn;
2162       break;
2163     case MEP_OPERAND_RN3 :
2164       value = fields->f_rn3;
2165       break;
2166     case MEP_OPERAND_RN3C :
2167       value = fields->f_rn3;
2168       break;
2169     case MEP_OPERAND_RN3L :
2170       value = fields->f_rn3;
2171       break;
2172     case MEP_OPERAND_RN3S :
2173       value = fields->f_rn3;
2174       break;
2175     case MEP_OPERAND_RN3UC :
2176       value = fields->f_rn3;
2177       break;
2178     case MEP_OPERAND_RN3UL :
2179       value = fields->f_rn3;
2180       break;
2181     case MEP_OPERAND_RN3US :
2182       value = fields->f_rn3;
2183       break;
2184     case MEP_OPERAND_RNC :
2185       value = fields->f_rn;
2186       break;
2187     case MEP_OPERAND_RNL :
2188       value = fields->f_rn;
2189       break;
2190     case MEP_OPERAND_RNS :
2191       value = fields->f_rn;
2192       break;
2193     case MEP_OPERAND_RNUC :
2194       value = fields->f_rn;
2195       break;
2196     case MEP_OPERAND_RNUL :
2197       value = fields->f_rn;
2198       break;
2199     case MEP_OPERAND_RNUS :
2200       value = fields->f_rn;
2201       break;
2202     case MEP_OPERAND_SAR :
2203       value = 0;
2204       break;
2205     case MEP_OPERAND_SDISP16 :
2206       value = fields->f_16s16;
2207       break;
2208     case MEP_OPERAND_SIMM16 :
2209       value = fields->f_16s16;
2210       break;
2211     case MEP_OPERAND_SIMM16P0 :
2212       value = fields->f_ivc2_simm16p0;
2213       break;
2214     case MEP_OPERAND_SIMM6 :
2215       value = fields->f_6s8;
2216       break;
2217     case MEP_OPERAND_SIMM8 :
2218       value = fields->f_8s8;
2219       break;
2220     case MEP_OPERAND_SIMM8P0 :
2221       value = fields->f_ivc2_8s0;
2222       break;
2223     case MEP_OPERAND_SIMM8P20 :
2224       value = fields->f_ivc2_8s20;
2225       break;
2226     case MEP_OPERAND_SIMM8P4 :
2227       value = fields->f_ivc2_8s4;
2228       break;
2229     case MEP_OPERAND_SP :
2230       value = 0;
2231       break;
2232     case MEP_OPERAND_SPR :
2233       value = 0;
2234       break;
2235     case MEP_OPERAND_TP :
2236       value = 0;
2237       break;
2238     case MEP_OPERAND_TPR :
2239       value = 0;
2240       break;
2241     case MEP_OPERAND_UDISP2 :
2242       value = fields->f_2u6;
2243       break;
2244     case MEP_OPERAND_UDISP7 :
2245       value = fields->f_7u9;
2246       break;
2247     case MEP_OPERAND_UDISP7A2 :
2248       value = fields->f_7u9a2;
2249       break;
2250     case MEP_OPERAND_UDISP7A4 :
2251       value = fields->f_7u9a4;
2252       break;
2253     case MEP_OPERAND_UIMM16 :
2254       value = fields->f_16u16;
2255       break;
2256     case MEP_OPERAND_UIMM2 :
2257       value = fields->f_2u10;
2258       break;
2259     case MEP_OPERAND_UIMM24 :
2260       value = fields->f_24u8n;
2261       break;
2262     case MEP_OPERAND_UIMM3 :
2263       value = fields->f_3u5;
2264       break;
2265     case MEP_OPERAND_UIMM4 :
2266       value = fields->f_4u8;
2267       break;
2268     case MEP_OPERAND_UIMM5 :
2269       value = fields->f_5u8;
2270       break;
2271     case MEP_OPERAND_UIMM7A4 :
2272       value = fields->f_7u9a4;
2273       break;
2274     case MEP_OPERAND_ZERO :
2275       value = 0;
2276       break;
2277 
2278     default :
2279       /* xgettext:c-format */
2280       fprintf (stderr, _("Unrecognized field %d while getting int operand.\n"),
2281 		       opindex);
2282       abort ();
2283   }
2284 
2285   return value;
2286 }
2287 
2288 bfd_vma
mep_cgen_get_vma_operand(CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,int opindex,const CGEN_FIELDS * fields)2289 mep_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
2290 			     int opindex,
2291 			     const CGEN_FIELDS * fields)
2292 {
2293   bfd_vma value;
2294 
2295   switch (opindex)
2296     {
2297     case MEP_OPERAND_ADDR24A4 :
2298       value = fields->f_24u8a4n;
2299       break;
2300     case MEP_OPERAND_C5RMUIMM20 :
2301       value = fields->f_c5_rmuimm20;
2302       break;
2303     case MEP_OPERAND_C5RNMUIMM24 :
2304       value = fields->f_c5_rnmuimm24;
2305       break;
2306     case MEP_OPERAND_CALLNUM :
2307       value = fields->f_callnum;
2308       break;
2309     case MEP_OPERAND_CCCC :
2310       value = fields->f_rm;
2311       break;
2312     case MEP_OPERAND_CCRN :
2313       value = fields->f_ccrn;
2314       break;
2315     case MEP_OPERAND_CDISP10 :
2316       value = fields->f_cdisp10;
2317       break;
2318     case MEP_OPERAND_CDISP10A2 :
2319       value = fields->f_cdisp10;
2320       break;
2321     case MEP_OPERAND_CDISP10A4 :
2322       value = fields->f_cdisp10;
2323       break;
2324     case MEP_OPERAND_CDISP10A8 :
2325       value = fields->f_cdisp10;
2326       break;
2327     case MEP_OPERAND_CDISP12 :
2328       value = fields->f_12s20;
2329       break;
2330     case MEP_OPERAND_CIMM4 :
2331       value = fields->f_rn;
2332       break;
2333     case MEP_OPERAND_CIMM5 :
2334       value = fields->f_5u24;
2335       break;
2336     case MEP_OPERAND_CODE16 :
2337       value = fields->f_16u16;
2338       break;
2339     case MEP_OPERAND_CODE24 :
2340       value = fields->f_24u4n;
2341       break;
2342     case MEP_OPERAND_CP_FLAG :
2343       value = 0;
2344       break;
2345     case MEP_OPERAND_CRN :
2346       value = fields->f_crn;
2347       break;
2348     case MEP_OPERAND_CRN64 :
2349       value = fields->f_crn;
2350       break;
2351     case MEP_OPERAND_CRNX :
2352       value = fields->f_crnx;
2353       break;
2354     case MEP_OPERAND_CRNX64 :
2355       value = fields->f_crnx;
2356       break;
2357     case MEP_OPERAND_CROC :
2358       value = fields->f_ivc2_5u7;
2359       break;
2360     case MEP_OPERAND_CROP :
2361       value = fields->f_ivc2_5u23;
2362       break;
2363     case MEP_OPERAND_CRPC :
2364       value = fields->f_ivc2_5u26;
2365       break;
2366     case MEP_OPERAND_CRPP :
2367       value = fields->f_ivc2_5u18;
2368       break;
2369     case MEP_OPERAND_CRQC :
2370       value = fields->f_ivc2_5u21;
2371       break;
2372     case MEP_OPERAND_CRQP :
2373       value = fields->f_ivc2_5u13;
2374       break;
2375     case MEP_OPERAND_CSRN :
2376       value = fields->f_csrn;
2377       break;
2378     case MEP_OPERAND_CSRN_IDX :
2379       value = fields->f_csrn;
2380       break;
2381     case MEP_OPERAND_DBG :
2382       value = 0;
2383       break;
2384     case MEP_OPERAND_DEPC :
2385       value = 0;
2386       break;
2387     case MEP_OPERAND_EPC :
2388       value = 0;
2389       break;
2390     case MEP_OPERAND_EXC :
2391       value = 0;
2392       break;
2393     case MEP_OPERAND_HI :
2394       value = 0;
2395       break;
2396     case MEP_OPERAND_IMM16P0 :
2397       value = fields->f_ivc2_imm16p0;
2398       break;
2399     case MEP_OPERAND_IMM3P12 :
2400       value = fields->f_ivc2_3u12;
2401       break;
2402     case MEP_OPERAND_IMM3P25 :
2403       value = fields->f_ivc2_3u25;
2404       break;
2405     case MEP_OPERAND_IMM3P4 :
2406       value = fields->f_ivc2_3u4;
2407       break;
2408     case MEP_OPERAND_IMM3P5 :
2409       value = fields->f_ivc2_3u5;
2410       break;
2411     case MEP_OPERAND_IMM3P9 :
2412       value = fields->f_ivc2_3u9;
2413       break;
2414     case MEP_OPERAND_IMM4P10 :
2415       value = fields->f_ivc2_4u10;
2416       break;
2417     case MEP_OPERAND_IMM4P4 :
2418       value = fields->f_ivc2_4u4;
2419       break;
2420     case MEP_OPERAND_IMM4P8 :
2421       value = fields->f_ivc2_4u8;
2422       break;
2423     case MEP_OPERAND_IMM5P23 :
2424       value = fields->f_ivc2_5u23;
2425       break;
2426     case MEP_OPERAND_IMM5P3 :
2427       value = fields->f_ivc2_5u3;
2428       break;
2429     case MEP_OPERAND_IMM5P7 :
2430       value = fields->f_ivc2_5u7;
2431       break;
2432     case MEP_OPERAND_IMM5P8 :
2433       value = fields->f_ivc2_5u8;
2434       break;
2435     case MEP_OPERAND_IMM6P2 :
2436       value = fields->f_ivc2_6u2;
2437       break;
2438     case MEP_OPERAND_IMM6P6 :
2439       value = fields->f_ivc2_6u6;
2440       break;
2441     case MEP_OPERAND_IMM8P0 :
2442       value = fields->f_ivc2_8u0;
2443       break;
2444     case MEP_OPERAND_IMM8P20 :
2445       value = fields->f_ivc2_8u20;
2446       break;
2447     case MEP_OPERAND_IMM8P4 :
2448       value = fields->f_ivc2_8u4;
2449       break;
2450     case MEP_OPERAND_IVC_X_0_2 :
2451       value = fields->f_ivc2_2u0;
2452       break;
2453     case MEP_OPERAND_IVC_X_0_3 :
2454       value = fields->f_ivc2_3u0;
2455       break;
2456     case MEP_OPERAND_IVC_X_0_4 :
2457       value = fields->f_ivc2_4u0;
2458       break;
2459     case MEP_OPERAND_IVC_X_0_5 :
2460       value = fields->f_ivc2_5u0;
2461       break;
2462     case MEP_OPERAND_IVC_X_6_1 :
2463       value = fields->f_ivc2_1u6;
2464       break;
2465     case MEP_OPERAND_IVC_X_6_2 :
2466       value = fields->f_ivc2_2u6;
2467       break;
2468     case MEP_OPERAND_IVC_X_6_3 :
2469       value = fields->f_ivc2_3u6;
2470       break;
2471     case MEP_OPERAND_IVC2_ACC0_0 :
2472       value = 0;
2473       break;
2474     case MEP_OPERAND_IVC2_ACC0_1 :
2475       value = 0;
2476       break;
2477     case MEP_OPERAND_IVC2_ACC0_2 :
2478       value = 0;
2479       break;
2480     case MEP_OPERAND_IVC2_ACC0_3 :
2481       value = 0;
2482       break;
2483     case MEP_OPERAND_IVC2_ACC0_4 :
2484       value = 0;
2485       break;
2486     case MEP_OPERAND_IVC2_ACC0_5 :
2487       value = 0;
2488       break;
2489     case MEP_OPERAND_IVC2_ACC0_6 :
2490       value = 0;
2491       break;
2492     case MEP_OPERAND_IVC2_ACC0_7 :
2493       value = 0;
2494       break;
2495     case MEP_OPERAND_IVC2_ACC1_0 :
2496       value = 0;
2497       break;
2498     case MEP_OPERAND_IVC2_ACC1_1 :
2499       value = 0;
2500       break;
2501     case MEP_OPERAND_IVC2_ACC1_2 :
2502       value = 0;
2503       break;
2504     case MEP_OPERAND_IVC2_ACC1_3 :
2505       value = 0;
2506       break;
2507     case MEP_OPERAND_IVC2_ACC1_4 :
2508       value = 0;
2509       break;
2510     case MEP_OPERAND_IVC2_ACC1_5 :
2511       value = 0;
2512       break;
2513     case MEP_OPERAND_IVC2_ACC1_6 :
2514       value = 0;
2515       break;
2516     case MEP_OPERAND_IVC2_ACC1_7 :
2517       value = 0;
2518       break;
2519     case MEP_OPERAND_IVC2_CC :
2520       value = 0;
2521       break;
2522     case MEP_OPERAND_IVC2_COFA0 :
2523       value = 0;
2524       break;
2525     case MEP_OPERAND_IVC2_COFA1 :
2526       value = 0;
2527       break;
2528     case MEP_OPERAND_IVC2_COFR0 :
2529       value = 0;
2530       break;
2531     case MEP_OPERAND_IVC2_COFR1 :
2532       value = 0;
2533       break;
2534     case MEP_OPERAND_IVC2_CSAR0 :
2535       value = 0;
2536       break;
2537     case MEP_OPERAND_IVC2_CSAR1 :
2538       value = 0;
2539       break;
2540     case MEP_OPERAND_IVC2C3CCRN :
2541       value = fields->f_ivc2_ccrn_c3;
2542       break;
2543     case MEP_OPERAND_IVC2CCRN :
2544       value = fields->f_ivc2_ccrn;
2545       break;
2546     case MEP_OPERAND_IVC2CRN :
2547       value = fields->f_ivc2_crnx;
2548       break;
2549     case MEP_OPERAND_IVC2RM :
2550       value = fields->f_ivc2_crm;
2551       break;
2552     case MEP_OPERAND_LO :
2553       value = 0;
2554       break;
2555     case MEP_OPERAND_LP :
2556       value = 0;
2557       break;
2558     case MEP_OPERAND_MB0 :
2559       value = 0;
2560       break;
2561     case MEP_OPERAND_MB1 :
2562       value = 0;
2563       break;
2564     case MEP_OPERAND_ME0 :
2565       value = 0;
2566       break;
2567     case MEP_OPERAND_ME1 :
2568       value = 0;
2569       break;
2570     case MEP_OPERAND_NPC :
2571       value = 0;
2572       break;
2573     case MEP_OPERAND_OPT :
2574       value = 0;
2575       break;
2576     case MEP_OPERAND_PCABS24A2 :
2577       value = fields->f_24u5a2n;
2578       break;
2579     case MEP_OPERAND_PCREL12A2 :
2580       value = fields->f_12s4a2;
2581       break;
2582     case MEP_OPERAND_PCREL17A2 :
2583       value = fields->f_17s16a2;
2584       break;
2585     case MEP_OPERAND_PCREL24A2 :
2586       value = fields->f_24s5a2n;
2587       break;
2588     case MEP_OPERAND_PCREL8A2 :
2589       value = fields->f_8s8a2;
2590       break;
2591     case MEP_OPERAND_PSW :
2592       value = 0;
2593       break;
2594     case MEP_OPERAND_R0 :
2595       value = 0;
2596       break;
2597     case MEP_OPERAND_R1 :
2598       value = 0;
2599       break;
2600     case MEP_OPERAND_RL :
2601       value = fields->f_rl;
2602       break;
2603     case MEP_OPERAND_RL5 :
2604       value = fields->f_rl5;
2605       break;
2606     case MEP_OPERAND_RM :
2607       value = fields->f_rm;
2608       break;
2609     case MEP_OPERAND_RMA :
2610       value = fields->f_rm;
2611       break;
2612     case MEP_OPERAND_RN :
2613       value = fields->f_rn;
2614       break;
2615     case MEP_OPERAND_RN3 :
2616       value = fields->f_rn3;
2617       break;
2618     case MEP_OPERAND_RN3C :
2619       value = fields->f_rn3;
2620       break;
2621     case MEP_OPERAND_RN3L :
2622       value = fields->f_rn3;
2623       break;
2624     case MEP_OPERAND_RN3S :
2625       value = fields->f_rn3;
2626       break;
2627     case MEP_OPERAND_RN3UC :
2628       value = fields->f_rn3;
2629       break;
2630     case MEP_OPERAND_RN3UL :
2631       value = fields->f_rn3;
2632       break;
2633     case MEP_OPERAND_RN3US :
2634       value = fields->f_rn3;
2635       break;
2636     case MEP_OPERAND_RNC :
2637       value = fields->f_rn;
2638       break;
2639     case MEP_OPERAND_RNL :
2640       value = fields->f_rn;
2641       break;
2642     case MEP_OPERAND_RNS :
2643       value = fields->f_rn;
2644       break;
2645     case MEP_OPERAND_RNUC :
2646       value = fields->f_rn;
2647       break;
2648     case MEP_OPERAND_RNUL :
2649       value = fields->f_rn;
2650       break;
2651     case MEP_OPERAND_RNUS :
2652       value = fields->f_rn;
2653       break;
2654     case MEP_OPERAND_SAR :
2655       value = 0;
2656       break;
2657     case MEP_OPERAND_SDISP16 :
2658       value = fields->f_16s16;
2659       break;
2660     case MEP_OPERAND_SIMM16 :
2661       value = fields->f_16s16;
2662       break;
2663     case MEP_OPERAND_SIMM16P0 :
2664       value = fields->f_ivc2_simm16p0;
2665       break;
2666     case MEP_OPERAND_SIMM6 :
2667       value = fields->f_6s8;
2668       break;
2669     case MEP_OPERAND_SIMM8 :
2670       value = fields->f_8s8;
2671       break;
2672     case MEP_OPERAND_SIMM8P0 :
2673       value = fields->f_ivc2_8s0;
2674       break;
2675     case MEP_OPERAND_SIMM8P20 :
2676       value = fields->f_ivc2_8s20;
2677       break;
2678     case MEP_OPERAND_SIMM8P4 :
2679       value = fields->f_ivc2_8s4;
2680       break;
2681     case MEP_OPERAND_SP :
2682       value = 0;
2683       break;
2684     case MEP_OPERAND_SPR :
2685       value = 0;
2686       break;
2687     case MEP_OPERAND_TP :
2688       value = 0;
2689       break;
2690     case MEP_OPERAND_TPR :
2691       value = 0;
2692       break;
2693     case MEP_OPERAND_UDISP2 :
2694       value = fields->f_2u6;
2695       break;
2696     case MEP_OPERAND_UDISP7 :
2697       value = fields->f_7u9;
2698       break;
2699     case MEP_OPERAND_UDISP7A2 :
2700       value = fields->f_7u9a2;
2701       break;
2702     case MEP_OPERAND_UDISP7A4 :
2703       value = fields->f_7u9a4;
2704       break;
2705     case MEP_OPERAND_UIMM16 :
2706       value = fields->f_16u16;
2707       break;
2708     case MEP_OPERAND_UIMM2 :
2709       value = fields->f_2u10;
2710       break;
2711     case MEP_OPERAND_UIMM24 :
2712       value = fields->f_24u8n;
2713       break;
2714     case MEP_OPERAND_UIMM3 :
2715       value = fields->f_3u5;
2716       break;
2717     case MEP_OPERAND_UIMM4 :
2718       value = fields->f_4u8;
2719       break;
2720     case MEP_OPERAND_UIMM5 :
2721       value = fields->f_5u8;
2722       break;
2723     case MEP_OPERAND_UIMM7A4 :
2724       value = fields->f_7u9a4;
2725       break;
2726     case MEP_OPERAND_ZERO :
2727       value = 0;
2728       break;
2729 
2730     default :
2731       /* xgettext:c-format */
2732       fprintf (stderr, _("Unrecognized field %d while getting vma operand.\n"),
2733 		       opindex);
2734       abort ();
2735   }
2736 
2737   return value;
2738 }
2739 
2740 void mep_cgen_set_int_operand  (CGEN_CPU_DESC, int, CGEN_FIELDS *, int);
2741 void mep_cgen_set_vma_operand  (CGEN_CPU_DESC, int, CGEN_FIELDS *, bfd_vma);
2742 
2743 /* Stuffing values in cgen_fields is handled by a collection of functions.
2744    They are distinguished by the type of the VALUE argument they accept.
2745    TODO: floating point, inlining support, remove cases where argument type
2746    not appropriate.  */
2747 
2748 void
mep_cgen_set_int_operand(CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,int opindex,CGEN_FIELDS * fields,int value)2749 mep_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
2750 			     int opindex,
2751 			     CGEN_FIELDS * fields,
2752 			     int value)
2753 {
2754   switch (opindex)
2755     {
2756     case MEP_OPERAND_ADDR24A4 :
2757       fields->f_24u8a4n = value;
2758       break;
2759     case MEP_OPERAND_C5RMUIMM20 :
2760       fields->f_c5_rmuimm20 = value;
2761       break;
2762     case MEP_OPERAND_C5RNMUIMM24 :
2763       fields->f_c5_rnmuimm24 = value;
2764       break;
2765     case MEP_OPERAND_CALLNUM :
2766       fields->f_callnum = value;
2767       break;
2768     case MEP_OPERAND_CCCC :
2769       fields->f_rm = value;
2770       break;
2771     case MEP_OPERAND_CCRN :
2772       fields->f_ccrn = value;
2773       break;
2774     case MEP_OPERAND_CDISP10 :
2775       fields->f_cdisp10 = value;
2776       break;
2777     case MEP_OPERAND_CDISP10A2 :
2778       fields->f_cdisp10 = value;
2779       break;
2780     case MEP_OPERAND_CDISP10A4 :
2781       fields->f_cdisp10 = value;
2782       break;
2783     case MEP_OPERAND_CDISP10A8 :
2784       fields->f_cdisp10 = value;
2785       break;
2786     case MEP_OPERAND_CDISP12 :
2787       fields->f_12s20 = value;
2788       break;
2789     case MEP_OPERAND_CIMM4 :
2790       fields->f_rn = value;
2791       break;
2792     case MEP_OPERAND_CIMM5 :
2793       fields->f_5u24 = value;
2794       break;
2795     case MEP_OPERAND_CODE16 :
2796       fields->f_16u16 = value;
2797       break;
2798     case MEP_OPERAND_CODE24 :
2799       fields->f_24u4n = value;
2800       break;
2801     case MEP_OPERAND_CP_FLAG :
2802       break;
2803     case MEP_OPERAND_CRN :
2804       fields->f_crn = value;
2805       break;
2806     case MEP_OPERAND_CRN64 :
2807       fields->f_crn = value;
2808       break;
2809     case MEP_OPERAND_CRNX :
2810       fields->f_crnx = value;
2811       break;
2812     case MEP_OPERAND_CRNX64 :
2813       fields->f_crnx = value;
2814       break;
2815     case MEP_OPERAND_CROC :
2816       fields->f_ivc2_5u7 = value;
2817       break;
2818     case MEP_OPERAND_CROP :
2819       fields->f_ivc2_5u23 = value;
2820       break;
2821     case MEP_OPERAND_CRPC :
2822       fields->f_ivc2_5u26 = value;
2823       break;
2824     case MEP_OPERAND_CRPP :
2825       fields->f_ivc2_5u18 = value;
2826       break;
2827     case MEP_OPERAND_CRQC :
2828       fields->f_ivc2_5u21 = value;
2829       break;
2830     case MEP_OPERAND_CRQP :
2831       fields->f_ivc2_5u13 = value;
2832       break;
2833     case MEP_OPERAND_CSRN :
2834       fields->f_csrn = value;
2835       break;
2836     case MEP_OPERAND_CSRN_IDX :
2837       fields->f_csrn = value;
2838       break;
2839     case MEP_OPERAND_DBG :
2840       break;
2841     case MEP_OPERAND_DEPC :
2842       break;
2843     case MEP_OPERAND_EPC :
2844       break;
2845     case MEP_OPERAND_EXC :
2846       break;
2847     case MEP_OPERAND_HI :
2848       break;
2849     case MEP_OPERAND_IMM16P0 :
2850       fields->f_ivc2_imm16p0 = value;
2851       break;
2852     case MEP_OPERAND_IMM3P12 :
2853       fields->f_ivc2_3u12 = value;
2854       break;
2855     case MEP_OPERAND_IMM3P25 :
2856       fields->f_ivc2_3u25 = value;
2857       break;
2858     case MEP_OPERAND_IMM3P4 :
2859       fields->f_ivc2_3u4 = value;
2860       break;
2861     case MEP_OPERAND_IMM3P5 :
2862       fields->f_ivc2_3u5 = value;
2863       break;
2864     case MEP_OPERAND_IMM3P9 :
2865       fields->f_ivc2_3u9 = value;
2866       break;
2867     case MEP_OPERAND_IMM4P10 :
2868       fields->f_ivc2_4u10 = value;
2869       break;
2870     case MEP_OPERAND_IMM4P4 :
2871       fields->f_ivc2_4u4 = value;
2872       break;
2873     case MEP_OPERAND_IMM4P8 :
2874       fields->f_ivc2_4u8 = value;
2875       break;
2876     case MEP_OPERAND_IMM5P23 :
2877       fields->f_ivc2_5u23 = value;
2878       break;
2879     case MEP_OPERAND_IMM5P3 :
2880       fields->f_ivc2_5u3 = value;
2881       break;
2882     case MEP_OPERAND_IMM5P7 :
2883       fields->f_ivc2_5u7 = value;
2884       break;
2885     case MEP_OPERAND_IMM5P8 :
2886       fields->f_ivc2_5u8 = value;
2887       break;
2888     case MEP_OPERAND_IMM6P2 :
2889       fields->f_ivc2_6u2 = value;
2890       break;
2891     case MEP_OPERAND_IMM6P6 :
2892       fields->f_ivc2_6u6 = value;
2893       break;
2894     case MEP_OPERAND_IMM8P0 :
2895       fields->f_ivc2_8u0 = value;
2896       break;
2897     case MEP_OPERAND_IMM8P20 :
2898       fields->f_ivc2_8u20 = value;
2899       break;
2900     case MEP_OPERAND_IMM8P4 :
2901       fields->f_ivc2_8u4 = value;
2902       break;
2903     case MEP_OPERAND_IVC_X_0_2 :
2904       fields->f_ivc2_2u0 = value;
2905       break;
2906     case MEP_OPERAND_IVC_X_0_3 :
2907       fields->f_ivc2_3u0 = value;
2908       break;
2909     case MEP_OPERAND_IVC_X_0_4 :
2910       fields->f_ivc2_4u0 = value;
2911       break;
2912     case MEP_OPERAND_IVC_X_0_5 :
2913       fields->f_ivc2_5u0 = value;
2914       break;
2915     case MEP_OPERAND_IVC_X_6_1 :
2916       fields->f_ivc2_1u6 = value;
2917       break;
2918     case MEP_OPERAND_IVC_X_6_2 :
2919       fields->f_ivc2_2u6 = value;
2920       break;
2921     case MEP_OPERAND_IVC_X_6_3 :
2922       fields->f_ivc2_3u6 = value;
2923       break;
2924     case MEP_OPERAND_IVC2_ACC0_0 :
2925       break;
2926     case MEP_OPERAND_IVC2_ACC0_1 :
2927       break;
2928     case MEP_OPERAND_IVC2_ACC0_2 :
2929       break;
2930     case MEP_OPERAND_IVC2_ACC0_3 :
2931       break;
2932     case MEP_OPERAND_IVC2_ACC0_4 :
2933       break;
2934     case MEP_OPERAND_IVC2_ACC0_5 :
2935       break;
2936     case MEP_OPERAND_IVC2_ACC0_6 :
2937       break;
2938     case MEP_OPERAND_IVC2_ACC0_7 :
2939       break;
2940     case MEP_OPERAND_IVC2_ACC1_0 :
2941       break;
2942     case MEP_OPERAND_IVC2_ACC1_1 :
2943       break;
2944     case MEP_OPERAND_IVC2_ACC1_2 :
2945       break;
2946     case MEP_OPERAND_IVC2_ACC1_3 :
2947       break;
2948     case MEP_OPERAND_IVC2_ACC1_4 :
2949       break;
2950     case MEP_OPERAND_IVC2_ACC1_5 :
2951       break;
2952     case MEP_OPERAND_IVC2_ACC1_6 :
2953       break;
2954     case MEP_OPERAND_IVC2_ACC1_7 :
2955       break;
2956     case MEP_OPERAND_IVC2_CC :
2957       break;
2958     case MEP_OPERAND_IVC2_COFA0 :
2959       break;
2960     case MEP_OPERAND_IVC2_COFA1 :
2961       break;
2962     case MEP_OPERAND_IVC2_COFR0 :
2963       break;
2964     case MEP_OPERAND_IVC2_COFR1 :
2965       break;
2966     case MEP_OPERAND_IVC2_CSAR0 :
2967       break;
2968     case MEP_OPERAND_IVC2_CSAR1 :
2969       break;
2970     case MEP_OPERAND_IVC2C3CCRN :
2971       fields->f_ivc2_ccrn_c3 = value;
2972       break;
2973     case MEP_OPERAND_IVC2CCRN :
2974       fields->f_ivc2_ccrn = value;
2975       break;
2976     case MEP_OPERAND_IVC2CRN :
2977       fields->f_ivc2_crnx = value;
2978       break;
2979     case MEP_OPERAND_IVC2RM :
2980       fields->f_ivc2_crm = value;
2981       break;
2982     case MEP_OPERAND_LO :
2983       break;
2984     case MEP_OPERAND_LP :
2985       break;
2986     case MEP_OPERAND_MB0 :
2987       break;
2988     case MEP_OPERAND_MB1 :
2989       break;
2990     case MEP_OPERAND_ME0 :
2991       break;
2992     case MEP_OPERAND_ME1 :
2993       break;
2994     case MEP_OPERAND_NPC :
2995       break;
2996     case MEP_OPERAND_OPT :
2997       break;
2998     case MEP_OPERAND_PCABS24A2 :
2999       fields->f_24u5a2n = value;
3000       break;
3001     case MEP_OPERAND_PCREL12A2 :
3002       fields->f_12s4a2 = value;
3003       break;
3004     case MEP_OPERAND_PCREL17A2 :
3005       fields->f_17s16a2 = value;
3006       break;
3007     case MEP_OPERAND_PCREL24A2 :
3008       fields->f_24s5a2n = value;
3009       break;
3010     case MEP_OPERAND_PCREL8A2 :
3011       fields->f_8s8a2 = value;
3012       break;
3013     case MEP_OPERAND_PSW :
3014       break;
3015     case MEP_OPERAND_R0 :
3016       break;
3017     case MEP_OPERAND_R1 :
3018       break;
3019     case MEP_OPERAND_RL :
3020       fields->f_rl = value;
3021       break;
3022     case MEP_OPERAND_RL5 :
3023       fields->f_rl5 = value;
3024       break;
3025     case MEP_OPERAND_RM :
3026       fields->f_rm = value;
3027       break;
3028     case MEP_OPERAND_RMA :
3029       fields->f_rm = value;
3030       break;
3031     case MEP_OPERAND_RN :
3032       fields->f_rn = value;
3033       break;
3034     case MEP_OPERAND_RN3 :
3035       fields->f_rn3 = value;
3036       break;
3037     case MEP_OPERAND_RN3C :
3038       fields->f_rn3 = value;
3039       break;
3040     case MEP_OPERAND_RN3L :
3041       fields->f_rn3 = value;
3042       break;
3043     case MEP_OPERAND_RN3S :
3044       fields->f_rn3 = value;
3045       break;
3046     case MEP_OPERAND_RN3UC :
3047       fields->f_rn3 = value;
3048       break;
3049     case MEP_OPERAND_RN3UL :
3050       fields->f_rn3 = value;
3051       break;
3052     case MEP_OPERAND_RN3US :
3053       fields->f_rn3 = value;
3054       break;
3055     case MEP_OPERAND_RNC :
3056       fields->f_rn = value;
3057       break;
3058     case MEP_OPERAND_RNL :
3059       fields->f_rn = value;
3060       break;
3061     case MEP_OPERAND_RNS :
3062       fields->f_rn = value;
3063       break;
3064     case MEP_OPERAND_RNUC :
3065       fields->f_rn = value;
3066       break;
3067     case MEP_OPERAND_RNUL :
3068       fields->f_rn = value;
3069       break;
3070     case MEP_OPERAND_RNUS :
3071       fields->f_rn = value;
3072       break;
3073     case MEP_OPERAND_SAR :
3074       break;
3075     case MEP_OPERAND_SDISP16 :
3076       fields->f_16s16 = value;
3077       break;
3078     case MEP_OPERAND_SIMM16 :
3079       fields->f_16s16 = value;
3080       break;
3081     case MEP_OPERAND_SIMM16P0 :
3082       fields->f_ivc2_simm16p0 = value;
3083       break;
3084     case MEP_OPERAND_SIMM6 :
3085       fields->f_6s8 = value;
3086       break;
3087     case MEP_OPERAND_SIMM8 :
3088       fields->f_8s8 = value;
3089       break;
3090     case MEP_OPERAND_SIMM8P0 :
3091       fields->f_ivc2_8s0 = value;
3092       break;
3093     case MEP_OPERAND_SIMM8P20 :
3094       fields->f_ivc2_8s20 = value;
3095       break;
3096     case MEP_OPERAND_SIMM8P4 :
3097       fields->f_ivc2_8s4 = value;
3098       break;
3099     case MEP_OPERAND_SP :
3100       break;
3101     case MEP_OPERAND_SPR :
3102       break;
3103     case MEP_OPERAND_TP :
3104       break;
3105     case MEP_OPERAND_TPR :
3106       break;
3107     case MEP_OPERAND_UDISP2 :
3108       fields->f_2u6 = value;
3109       break;
3110     case MEP_OPERAND_UDISP7 :
3111       fields->f_7u9 = value;
3112       break;
3113     case MEP_OPERAND_UDISP7A2 :
3114       fields->f_7u9a2 = value;
3115       break;
3116     case MEP_OPERAND_UDISP7A4 :
3117       fields->f_7u9a4 = value;
3118       break;
3119     case MEP_OPERAND_UIMM16 :
3120       fields->f_16u16 = value;
3121       break;
3122     case MEP_OPERAND_UIMM2 :
3123       fields->f_2u10 = value;
3124       break;
3125     case MEP_OPERAND_UIMM24 :
3126       fields->f_24u8n = value;
3127       break;
3128     case MEP_OPERAND_UIMM3 :
3129       fields->f_3u5 = value;
3130       break;
3131     case MEP_OPERAND_UIMM4 :
3132       fields->f_4u8 = value;
3133       break;
3134     case MEP_OPERAND_UIMM5 :
3135       fields->f_5u8 = value;
3136       break;
3137     case MEP_OPERAND_UIMM7A4 :
3138       fields->f_7u9a4 = value;
3139       break;
3140     case MEP_OPERAND_ZERO :
3141       break;
3142 
3143     default :
3144       /* xgettext:c-format */
3145       fprintf (stderr, _("Unrecognized field %d while setting int operand.\n"),
3146 		       opindex);
3147       abort ();
3148   }
3149 }
3150 
3151 void
mep_cgen_set_vma_operand(CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,int opindex,CGEN_FIELDS * fields,bfd_vma value)3152 mep_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
3153 			     int opindex,
3154 			     CGEN_FIELDS * fields,
3155 			     bfd_vma value)
3156 {
3157   switch (opindex)
3158     {
3159     case MEP_OPERAND_ADDR24A4 :
3160       fields->f_24u8a4n = value;
3161       break;
3162     case MEP_OPERAND_C5RMUIMM20 :
3163       fields->f_c5_rmuimm20 = value;
3164       break;
3165     case MEP_OPERAND_C5RNMUIMM24 :
3166       fields->f_c5_rnmuimm24 = value;
3167       break;
3168     case MEP_OPERAND_CALLNUM :
3169       fields->f_callnum = value;
3170       break;
3171     case MEP_OPERAND_CCCC :
3172       fields->f_rm = value;
3173       break;
3174     case MEP_OPERAND_CCRN :
3175       fields->f_ccrn = value;
3176       break;
3177     case MEP_OPERAND_CDISP10 :
3178       fields->f_cdisp10 = value;
3179       break;
3180     case MEP_OPERAND_CDISP10A2 :
3181       fields->f_cdisp10 = value;
3182       break;
3183     case MEP_OPERAND_CDISP10A4 :
3184       fields->f_cdisp10 = value;
3185       break;
3186     case MEP_OPERAND_CDISP10A8 :
3187       fields->f_cdisp10 = value;
3188       break;
3189     case MEP_OPERAND_CDISP12 :
3190       fields->f_12s20 = value;
3191       break;
3192     case MEP_OPERAND_CIMM4 :
3193       fields->f_rn = value;
3194       break;
3195     case MEP_OPERAND_CIMM5 :
3196       fields->f_5u24 = value;
3197       break;
3198     case MEP_OPERAND_CODE16 :
3199       fields->f_16u16 = value;
3200       break;
3201     case MEP_OPERAND_CODE24 :
3202       fields->f_24u4n = value;
3203       break;
3204     case MEP_OPERAND_CP_FLAG :
3205       break;
3206     case MEP_OPERAND_CRN :
3207       fields->f_crn = value;
3208       break;
3209     case MEP_OPERAND_CRN64 :
3210       fields->f_crn = value;
3211       break;
3212     case MEP_OPERAND_CRNX :
3213       fields->f_crnx = value;
3214       break;
3215     case MEP_OPERAND_CRNX64 :
3216       fields->f_crnx = value;
3217       break;
3218     case MEP_OPERAND_CROC :
3219       fields->f_ivc2_5u7 = value;
3220       break;
3221     case MEP_OPERAND_CROP :
3222       fields->f_ivc2_5u23 = value;
3223       break;
3224     case MEP_OPERAND_CRPC :
3225       fields->f_ivc2_5u26 = value;
3226       break;
3227     case MEP_OPERAND_CRPP :
3228       fields->f_ivc2_5u18 = value;
3229       break;
3230     case MEP_OPERAND_CRQC :
3231       fields->f_ivc2_5u21 = value;
3232       break;
3233     case MEP_OPERAND_CRQP :
3234       fields->f_ivc2_5u13 = value;
3235       break;
3236     case MEP_OPERAND_CSRN :
3237       fields->f_csrn = value;
3238       break;
3239     case MEP_OPERAND_CSRN_IDX :
3240       fields->f_csrn = value;
3241       break;
3242     case MEP_OPERAND_DBG :
3243       break;
3244     case MEP_OPERAND_DEPC :
3245       break;
3246     case MEP_OPERAND_EPC :
3247       break;
3248     case MEP_OPERAND_EXC :
3249       break;
3250     case MEP_OPERAND_HI :
3251       break;
3252     case MEP_OPERAND_IMM16P0 :
3253       fields->f_ivc2_imm16p0 = value;
3254       break;
3255     case MEP_OPERAND_IMM3P12 :
3256       fields->f_ivc2_3u12 = value;
3257       break;
3258     case MEP_OPERAND_IMM3P25 :
3259       fields->f_ivc2_3u25 = value;
3260       break;
3261     case MEP_OPERAND_IMM3P4 :
3262       fields->f_ivc2_3u4 = value;
3263       break;
3264     case MEP_OPERAND_IMM3P5 :
3265       fields->f_ivc2_3u5 = value;
3266       break;
3267     case MEP_OPERAND_IMM3P9 :
3268       fields->f_ivc2_3u9 = value;
3269       break;
3270     case MEP_OPERAND_IMM4P10 :
3271       fields->f_ivc2_4u10 = value;
3272       break;
3273     case MEP_OPERAND_IMM4P4 :
3274       fields->f_ivc2_4u4 = value;
3275       break;
3276     case MEP_OPERAND_IMM4P8 :
3277       fields->f_ivc2_4u8 = value;
3278       break;
3279     case MEP_OPERAND_IMM5P23 :
3280       fields->f_ivc2_5u23 = value;
3281       break;
3282     case MEP_OPERAND_IMM5P3 :
3283       fields->f_ivc2_5u3 = value;
3284       break;
3285     case MEP_OPERAND_IMM5P7 :
3286       fields->f_ivc2_5u7 = value;
3287       break;
3288     case MEP_OPERAND_IMM5P8 :
3289       fields->f_ivc2_5u8 = value;
3290       break;
3291     case MEP_OPERAND_IMM6P2 :
3292       fields->f_ivc2_6u2 = value;
3293       break;
3294     case MEP_OPERAND_IMM6P6 :
3295       fields->f_ivc2_6u6 = value;
3296       break;
3297     case MEP_OPERAND_IMM8P0 :
3298       fields->f_ivc2_8u0 = value;
3299       break;
3300     case MEP_OPERAND_IMM8P20 :
3301       fields->f_ivc2_8u20 = value;
3302       break;
3303     case MEP_OPERAND_IMM8P4 :
3304       fields->f_ivc2_8u4 = value;
3305       break;
3306     case MEP_OPERAND_IVC_X_0_2 :
3307       fields->f_ivc2_2u0 = value;
3308       break;
3309     case MEP_OPERAND_IVC_X_0_3 :
3310       fields->f_ivc2_3u0 = value;
3311       break;
3312     case MEP_OPERAND_IVC_X_0_4 :
3313       fields->f_ivc2_4u0 = value;
3314       break;
3315     case MEP_OPERAND_IVC_X_0_5 :
3316       fields->f_ivc2_5u0 = value;
3317       break;
3318     case MEP_OPERAND_IVC_X_6_1 :
3319       fields->f_ivc2_1u6 = value;
3320       break;
3321     case MEP_OPERAND_IVC_X_6_2 :
3322       fields->f_ivc2_2u6 = value;
3323       break;
3324     case MEP_OPERAND_IVC_X_6_3 :
3325       fields->f_ivc2_3u6 = value;
3326       break;
3327     case MEP_OPERAND_IVC2_ACC0_0 :
3328       break;
3329     case MEP_OPERAND_IVC2_ACC0_1 :
3330       break;
3331     case MEP_OPERAND_IVC2_ACC0_2 :
3332       break;
3333     case MEP_OPERAND_IVC2_ACC0_3 :
3334       break;
3335     case MEP_OPERAND_IVC2_ACC0_4 :
3336       break;
3337     case MEP_OPERAND_IVC2_ACC0_5 :
3338       break;
3339     case MEP_OPERAND_IVC2_ACC0_6 :
3340       break;
3341     case MEP_OPERAND_IVC2_ACC0_7 :
3342       break;
3343     case MEP_OPERAND_IVC2_ACC1_0 :
3344       break;
3345     case MEP_OPERAND_IVC2_ACC1_1 :
3346       break;
3347     case MEP_OPERAND_IVC2_ACC1_2 :
3348       break;
3349     case MEP_OPERAND_IVC2_ACC1_3 :
3350       break;
3351     case MEP_OPERAND_IVC2_ACC1_4 :
3352       break;
3353     case MEP_OPERAND_IVC2_ACC1_5 :
3354       break;
3355     case MEP_OPERAND_IVC2_ACC1_6 :
3356       break;
3357     case MEP_OPERAND_IVC2_ACC1_7 :
3358       break;
3359     case MEP_OPERAND_IVC2_CC :
3360       break;
3361     case MEP_OPERAND_IVC2_COFA0 :
3362       break;
3363     case MEP_OPERAND_IVC2_COFA1 :
3364       break;
3365     case MEP_OPERAND_IVC2_COFR0 :
3366       break;
3367     case MEP_OPERAND_IVC2_COFR1 :
3368       break;
3369     case MEP_OPERAND_IVC2_CSAR0 :
3370       break;
3371     case MEP_OPERAND_IVC2_CSAR1 :
3372       break;
3373     case MEP_OPERAND_IVC2C3CCRN :
3374       fields->f_ivc2_ccrn_c3 = value;
3375       break;
3376     case MEP_OPERAND_IVC2CCRN :
3377       fields->f_ivc2_ccrn = value;
3378       break;
3379     case MEP_OPERAND_IVC2CRN :
3380       fields->f_ivc2_crnx = value;
3381       break;
3382     case MEP_OPERAND_IVC2RM :
3383       fields->f_ivc2_crm = value;
3384       break;
3385     case MEP_OPERAND_LO :
3386       break;
3387     case MEP_OPERAND_LP :
3388       break;
3389     case MEP_OPERAND_MB0 :
3390       break;
3391     case MEP_OPERAND_MB1 :
3392       break;
3393     case MEP_OPERAND_ME0 :
3394       break;
3395     case MEP_OPERAND_ME1 :
3396       break;
3397     case MEP_OPERAND_NPC :
3398       break;
3399     case MEP_OPERAND_OPT :
3400       break;
3401     case MEP_OPERAND_PCABS24A2 :
3402       fields->f_24u5a2n = value;
3403       break;
3404     case MEP_OPERAND_PCREL12A2 :
3405       fields->f_12s4a2 = value;
3406       break;
3407     case MEP_OPERAND_PCREL17A2 :
3408       fields->f_17s16a2 = value;
3409       break;
3410     case MEP_OPERAND_PCREL24A2 :
3411       fields->f_24s5a2n = value;
3412       break;
3413     case MEP_OPERAND_PCREL8A2 :
3414       fields->f_8s8a2 = value;
3415       break;
3416     case MEP_OPERAND_PSW :
3417       break;
3418     case MEP_OPERAND_R0 :
3419       break;
3420     case MEP_OPERAND_R1 :
3421       break;
3422     case MEP_OPERAND_RL :
3423       fields->f_rl = value;
3424       break;
3425     case MEP_OPERAND_RL5 :
3426       fields->f_rl5 = value;
3427       break;
3428     case MEP_OPERAND_RM :
3429       fields->f_rm = value;
3430       break;
3431     case MEP_OPERAND_RMA :
3432       fields->f_rm = value;
3433       break;
3434     case MEP_OPERAND_RN :
3435       fields->f_rn = value;
3436       break;
3437     case MEP_OPERAND_RN3 :
3438       fields->f_rn3 = value;
3439       break;
3440     case MEP_OPERAND_RN3C :
3441       fields->f_rn3 = value;
3442       break;
3443     case MEP_OPERAND_RN3L :
3444       fields->f_rn3 = value;
3445       break;
3446     case MEP_OPERAND_RN3S :
3447       fields->f_rn3 = value;
3448       break;
3449     case MEP_OPERAND_RN3UC :
3450       fields->f_rn3 = value;
3451       break;
3452     case MEP_OPERAND_RN3UL :
3453       fields->f_rn3 = value;
3454       break;
3455     case MEP_OPERAND_RN3US :
3456       fields->f_rn3 = value;
3457       break;
3458     case MEP_OPERAND_RNC :
3459       fields->f_rn = value;
3460       break;
3461     case MEP_OPERAND_RNL :
3462       fields->f_rn = value;
3463       break;
3464     case MEP_OPERAND_RNS :
3465       fields->f_rn = value;
3466       break;
3467     case MEP_OPERAND_RNUC :
3468       fields->f_rn = value;
3469       break;
3470     case MEP_OPERAND_RNUL :
3471       fields->f_rn = value;
3472       break;
3473     case MEP_OPERAND_RNUS :
3474       fields->f_rn = value;
3475       break;
3476     case MEP_OPERAND_SAR :
3477       break;
3478     case MEP_OPERAND_SDISP16 :
3479       fields->f_16s16 = value;
3480       break;
3481     case MEP_OPERAND_SIMM16 :
3482       fields->f_16s16 = value;
3483       break;
3484     case MEP_OPERAND_SIMM16P0 :
3485       fields->f_ivc2_simm16p0 = value;
3486       break;
3487     case MEP_OPERAND_SIMM6 :
3488       fields->f_6s8 = value;
3489       break;
3490     case MEP_OPERAND_SIMM8 :
3491       fields->f_8s8 = value;
3492       break;
3493     case MEP_OPERAND_SIMM8P0 :
3494       fields->f_ivc2_8s0 = value;
3495       break;
3496     case MEP_OPERAND_SIMM8P20 :
3497       fields->f_ivc2_8s20 = value;
3498       break;
3499     case MEP_OPERAND_SIMM8P4 :
3500       fields->f_ivc2_8s4 = value;
3501       break;
3502     case MEP_OPERAND_SP :
3503       break;
3504     case MEP_OPERAND_SPR :
3505       break;
3506     case MEP_OPERAND_TP :
3507       break;
3508     case MEP_OPERAND_TPR :
3509       break;
3510     case MEP_OPERAND_UDISP2 :
3511       fields->f_2u6 = value;
3512       break;
3513     case MEP_OPERAND_UDISP7 :
3514       fields->f_7u9 = value;
3515       break;
3516     case MEP_OPERAND_UDISP7A2 :
3517       fields->f_7u9a2 = value;
3518       break;
3519     case MEP_OPERAND_UDISP7A4 :
3520       fields->f_7u9a4 = value;
3521       break;
3522     case MEP_OPERAND_UIMM16 :
3523       fields->f_16u16 = value;
3524       break;
3525     case MEP_OPERAND_UIMM2 :
3526       fields->f_2u10 = value;
3527       break;
3528     case MEP_OPERAND_UIMM24 :
3529       fields->f_24u8n = value;
3530       break;
3531     case MEP_OPERAND_UIMM3 :
3532       fields->f_3u5 = value;
3533       break;
3534     case MEP_OPERAND_UIMM4 :
3535       fields->f_4u8 = value;
3536       break;
3537     case MEP_OPERAND_UIMM5 :
3538       fields->f_5u8 = value;
3539       break;
3540     case MEP_OPERAND_UIMM7A4 :
3541       fields->f_7u9a4 = value;
3542       break;
3543     case MEP_OPERAND_ZERO :
3544       break;
3545 
3546     default :
3547       /* xgettext:c-format */
3548       fprintf (stderr, _("Unrecognized field %d while setting vma operand.\n"),
3549 		       opindex);
3550       abort ();
3551   }
3552 }
3553 
3554 /* Function to call before using the instruction builder tables.  */
3555 
3556 void
mep_cgen_init_ibld_table(CGEN_CPU_DESC cd)3557 mep_cgen_init_ibld_table (CGEN_CPU_DESC cd)
3558 {
3559   cd->insert_handlers = & mep_cgen_insert_handlers[0];
3560   cd->extract_handlers = & mep_cgen_extract_handlers[0];
3561 
3562   cd->insert_operand = mep_cgen_insert_operand;
3563   cd->extract_operand = mep_cgen_extract_operand;
3564 
3565   cd->get_int_operand = mep_cgen_get_int_operand;
3566   cd->set_int_operand = mep_cgen_set_int_operand;
3567   cd->get_vma_operand = mep_cgen_get_vma_operand;
3568   cd->set_vma_operand = mep_cgen_set_vma_operand;
3569 }
3570