Back to index

cell-binutils  2.17cvs20070401
xc16x-ibld.c
Go to the documentation of this file.
00001 /* Instruction building/extraction support for xc16x. -*- C -*-
00002 
00003    THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator.
00004    - the resultant file is machine generated, cgen-ibld.in isn't
00005 
00006    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005, 2006
00007    Free Software Foundation, Inc.
00008 
00009    This file is part of the GNU Binutils and GDB, the GNU debugger.
00010 
00011    This program is free software; you can redistribute it and/or modify
00012    it under the terms of the GNU General Public License as published by
00013    the Free Software Foundation; either version 2, or (at your option)
00014    any later version.
00015 
00016    This program is distributed in the hope that it will be useful,
00017    but WITHOUT ANY WARRANTY; without even the implied warranty of
00018    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019    GNU General Public License for more details.
00020 
00021    You should have received a copy of the GNU General Public License
00022    along with this program; if not, write to the Free Software Foundation, Inc.,
00023    51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
00024 
00025 /* ??? Eventually more and more of this stuff can go to cpu-independent files.
00026    Keep that in mind.  */
00027 
00028 #include "sysdep.h"
00029 #include <stdio.h>
00030 #include "ansidecl.h"
00031 #include "dis-asm.h"
00032 #include "bfd.h"
00033 #include "symcat.h"
00034 #include "xc16x-desc.h"
00035 #include "xc16x-opc.h"
00036 #include "opintl.h"
00037 #include "safe-ctype.h"
00038 
00039 #undef  min
00040 #define min(a,b) ((a) < (b) ? (a) : (b))
00041 #undef  max
00042 #define max(a,b) ((a) > (b) ? (a) : (b))
00043 
00044 /* Used by the ifield rtx function.  */
00045 #define FLD(f) (fields->f)
00046 
00047 static const char * insert_normal
00048   (CGEN_CPU_DESC, long, unsigned int, unsigned int, unsigned int,
00049    unsigned int, unsigned int, unsigned int, CGEN_INSN_BYTES_PTR);
00050 static const char * insert_insn_normal
00051   (CGEN_CPU_DESC, const CGEN_INSN *,
00052    CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma);
00053 static int extract_normal
00054   (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, CGEN_INSN_INT,
00055    unsigned int, unsigned int, unsigned int, unsigned int,
00056    unsigned int, unsigned int, bfd_vma, long *);
00057 static int extract_insn_normal
00058   (CGEN_CPU_DESC, const CGEN_INSN *, CGEN_EXTRACT_INFO *,
00059    CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma);
00060 #if CGEN_INT_INSN_P
00061 static void put_insn_int_value
00062   (CGEN_CPU_DESC, CGEN_INSN_BYTES_PTR, int, int, CGEN_INSN_INT);
00063 #endif
00064 #if ! CGEN_INT_INSN_P
00065 static CGEN_INLINE void insert_1
00066   (CGEN_CPU_DESC, unsigned long, int, int, int, unsigned char *);
00067 static CGEN_INLINE int fill_cache
00068   (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *,  int, int, bfd_vma);
00069 static CGEN_INLINE long extract_1
00070   (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, int, int, int, unsigned char *, bfd_vma);
00071 #endif
00072 
00073 /* Operand insertion.  */
00074 
00075 #if ! CGEN_INT_INSN_P
00076 
00077 /* Subroutine of insert_normal.  */
00078 
00079 static CGEN_INLINE void
00080 insert_1 (CGEN_CPU_DESC cd,
00081          unsigned long value,
00082          int start,
00083          int length,
00084          int word_length,
00085          unsigned char *bufp)
00086 {
00087   unsigned long x,mask;
00088   int shift;
00089 
00090   x = cgen_get_insn_value (cd, bufp, word_length);
00091 
00092   /* Written this way to avoid undefined behaviour.  */
00093   mask = (((1L << (length - 1)) - 1) << 1) | 1;
00094   if (CGEN_INSN_LSB0_P)
00095     shift = (start + 1) - length;
00096   else
00097     shift = (word_length - (start + length));
00098   x = (x & ~(mask << shift)) | ((value & mask) << shift);
00099 
00100   cgen_put_insn_value (cd, bufp, word_length, (bfd_vma) x);
00101 }
00102 
00103 #endif /* ! CGEN_INT_INSN_P */
00104 
00105 /* Default insertion routine.
00106 
00107    ATTRS is a mask of the boolean attributes.
00108    WORD_OFFSET is the offset in bits from the start of the insn of the value.
00109    WORD_LENGTH is the length of the word in bits in which the value resides.
00110    START is the starting bit number in the word, architecture origin.
00111    LENGTH is the length of VALUE in bits.
00112    TOTAL_LENGTH is the total length of the insn in bits.
00113 
00114    The result is an error message or NULL if success.  */
00115 
00116 /* ??? This duplicates functionality with bfd's howto table and
00117    bfd_install_relocation.  */
00118 /* ??? This doesn't handle bfd_vma's.  Create another function when
00119    necessary.  */
00120 
00121 static const char *
00122 insert_normal (CGEN_CPU_DESC cd,
00123               long value,
00124               unsigned int attrs,
00125               unsigned int word_offset,
00126               unsigned int start,
00127               unsigned int length,
00128               unsigned int word_length,
00129               unsigned int total_length,
00130               CGEN_INSN_BYTES_PTR buffer)
00131 {
00132   static char errbuf[100];
00133   /* Written this way to avoid undefined behaviour.  */
00134   unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
00135 
00136   /* If LENGTH is zero, this operand doesn't contribute to the value.  */
00137   if (length == 0)
00138     return NULL;
00139 
00140   if (word_length > 32)
00141     abort ();
00142 
00143   /* For architectures with insns smaller than the base-insn-bitsize,
00144      word_length may be too big.  */
00145   if (cd->min_insn_bitsize < cd->base_insn_bitsize)
00146     {
00147       if (word_offset == 0
00148          && word_length > total_length)
00149        word_length = total_length;
00150     }
00151 
00152   /* Ensure VALUE will fit.  */
00153   if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGN_OPT))
00154     {
00155       long minval = - (1L << (length - 1));
00156       unsigned long maxval = mask;
00157       
00158       if ((value > 0 && (unsigned long) value > maxval)
00159          || value < minval)
00160        {
00161          /* xgettext:c-format */
00162          sprintf (errbuf,
00163                  _("operand out of range (%ld not between %ld and %lu)"),
00164                  value, minval, maxval);
00165          return errbuf;
00166        }
00167     }
00168   else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED))
00169     {
00170       unsigned long maxval = mask;
00171       unsigned long val = (unsigned long) value;
00172 
00173       /* For hosts with a word size > 32 check to see if value has been sign
00174         extended beyond 32 bits.  If so then ignore these higher sign bits
00175         as the user is attempting to store a 32-bit signed value into an
00176         unsigned 32-bit field which is allowed.  */
00177       if (sizeof (unsigned long) > 4 && ((value >> 32) == -1))
00178        val &= 0xFFFFFFFF;
00179 
00180       if (val > maxval)
00181        {
00182          /* xgettext:c-format */
00183          sprintf (errbuf,
00184                  _("operand out of range (0x%lx not between 0 and 0x%lx)"),
00185                  val, maxval);
00186          return errbuf;
00187        }
00188     }
00189   else
00190     {
00191       if (! cgen_signed_overflow_ok_p (cd))
00192        {
00193          long minval = - (1L << (length - 1));
00194          long maxval =   (1L << (length - 1)) - 1;
00195          
00196          if (value < minval || value > maxval)
00197            {
00198              sprintf
00199               /* xgettext:c-format */
00200               (errbuf, _("operand out of range (%ld not between %ld and %ld)"),
00201                value, minval, maxval);
00202              return errbuf;
00203            }
00204        }
00205     }
00206 
00207 #if CGEN_INT_INSN_P
00208 
00209   {
00210     int shift;
00211 
00212     if (CGEN_INSN_LSB0_P)
00213       shift = (word_offset + start + 1) - length;
00214     else
00215       shift = total_length - (word_offset + start + length);
00216     *buffer = (*buffer & ~(mask << shift)) | ((value & mask) << shift);
00217   }
00218 
00219 #else /* ! CGEN_INT_INSN_P */
00220 
00221   {
00222     unsigned char *bufp = (unsigned char *) buffer + word_offset / 8;
00223 
00224     insert_1 (cd, value, start, length, word_length, bufp);
00225   }
00226 
00227 #endif /* ! CGEN_INT_INSN_P */
00228 
00229   return NULL;
00230 }
00231 
00232 /* Default insn builder (insert handler).
00233    The instruction is recorded in CGEN_INT_INSN_P byte order (meaning
00234    that if CGEN_INSN_BYTES_PTR is an int * and thus, the value is
00235    recorded in host byte order, otherwise BUFFER is an array of bytes
00236    and the value is recorded in target byte order).
00237    The result is an error message or NULL if success.  */
00238 
00239 static const char *
00240 insert_insn_normal (CGEN_CPU_DESC cd,
00241                   const CGEN_INSN * insn,
00242                   CGEN_FIELDS * fields,
00243                   CGEN_INSN_BYTES_PTR buffer,
00244                   bfd_vma pc)
00245 {
00246   const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
00247   unsigned long value;
00248   const CGEN_SYNTAX_CHAR_TYPE * syn;
00249 
00250   CGEN_INIT_INSERT (cd);
00251   value = CGEN_INSN_BASE_VALUE (insn);
00252 
00253   /* If we're recording insns as numbers (rather than a string of bytes),
00254      target byte order handling is deferred until later.  */
00255 
00256 #if CGEN_INT_INSN_P
00257 
00258   put_insn_int_value (cd, buffer, cd->base_insn_bitsize,
00259                     CGEN_FIELDS_BITSIZE (fields), value);
00260 
00261 #else
00262 
00263   cgen_put_insn_value (cd, buffer, min ((unsigned) cd->base_insn_bitsize,
00264                                    (unsigned) CGEN_FIELDS_BITSIZE (fields)),
00265                      value);
00266 
00267 #endif /* ! CGEN_INT_INSN_P */
00268 
00269   /* ??? It would be better to scan the format's fields.
00270      Still need to be able to insert a value based on the operand though;
00271      e.g. storing a branch displacement that got resolved later.
00272      Needs more thought first.  */
00273 
00274   for (syn = CGEN_SYNTAX_STRING (syntax); * syn; ++ syn)
00275     {
00276       const char *errmsg;
00277 
00278       if (CGEN_SYNTAX_CHAR_P (* syn))
00279        continue;
00280 
00281       errmsg = (* cd->insert_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
00282                                    fields, buffer, pc);
00283       if (errmsg)
00284        return errmsg;
00285     }
00286 
00287   return NULL;
00288 }
00289 
00290 #if CGEN_INT_INSN_P
00291 /* Cover function to store an insn value into an integral insn.  Must go here
00292    because it needs <prefix>-desc.h for CGEN_INT_INSN_P.  */
00293 
00294 static void
00295 put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
00296                   CGEN_INSN_BYTES_PTR buf,
00297                   int length,
00298                   int insn_length,
00299                   CGEN_INSN_INT value)
00300 {
00301   /* For architectures with insns smaller than the base-insn-bitsize,
00302      length may be too big.  */
00303   if (length > insn_length)
00304     *buf = value;
00305   else
00306     {
00307       int shift = insn_length - length;
00308       /* Written this way to avoid undefined behaviour.  */
00309       CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1;
00310 
00311       *buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
00312     }
00313 }
00314 #endif
00315 
00316 /* Operand extraction.  */
00317 
00318 #if ! CGEN_INT_INSN_P
00319 
00320 /* Subroutine of extract_normal.
00321    Ensure sufficient bytes are cached in EX_INFO.
00322    OFFSET is the offset in bytes from the start of the insn of the value.
00323    BYTES is the length of the needed value.
00324    Returns 1 for success, 0 for failure.  */
00325 
00326 static CGEN_INLINE int
00327 fill_cache (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
00328            CGEN_EXTRACT_INFO *ex_info,
00329            int offset,
00330            int bytes,
00331            bfd_vma pc)
00332 {
00333   /* It's doubtful that the middle part has already been fetched so
00334      we don't optimize that case.  kiss.  */
00335   unsigned int mask;
00336   disassemble_info *info = (disassemble_info *) ex_info->dis_info;
00337 
00338   /* First do a quick check.  */
00339   mask = (1 << bytes) - 1;
00340   if (((ex_info->valid >> offset) & mask) == mask)
00341     return 1;
00342 
00343   /* Search for the first byte we need to read.  */
00344   for (mask = 1 << offset; bytes > 0; --bytes, ++offset, mask <<= 1)
00345     if (! (mask & ex_info->valid))
00346       break;
00347 
00348   if (bytes)
00349     {
00350       int status;
00351 
00352       pc += offset;
00353       status = (*info->read_memory_func)
00354        (pc, ex_info->insn_bytes + offset, bytes, info);
00355 
00356       if (status != 0)
00357        {
00358          (*info->memory_error_func) (status, pc, info);
00359          return 0;
00360        }
00361 
00362       ex_info->valid |= ((1 << bytes) - 1) << offset;
00363     }
00364 
00365   return 1;
00366 }
00367 
00368 /* Subroutine of extract_normal.  */
00369 
00370 static CGEN_INLINE long
00371 extract_1 (CGEN_CPU_DESC cd,
00372           CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED,
00373           int start,
00374           int length,
00375           int word_length,
00376           unsigned char *bufp,
00377           bfd_vma pc ATTRIBUTE_UNUSED)
00378 {
00379   unsigned long x;
00380   int shift;
00381 
00382   x = cgen_get_insn_value (cd, bufp, word_length);
00383 
00384   if (CGEN_INSN_LSB0_P)
00385     shift = (start + 1) - length;
00386   else
00387     shift = (word_length - (start + length));
00388   return x >> shift;
00389 }
00390 
00391 #endif /* ! CGEN_INT_INSN_P */
00392 
00393 /* Default extraction routine.
00394 
00395    INSN_VALUE is the first base_insn_bitsize bits of the insn in host order,
00396    or sometimes less for cases like the m32r where the base insn size is 32
00397    but some insns are 16 bits.
00398    ATTRS is a mask of the boolean attributes.  We only need `SIGNED',
00399    but for generality we take a bitmask of all of them.
00400    WORD_OFFSET is the offset in bits from the start of the insn of the value.
00401    WORD_LENGTH is the length of the word in bits in which the value resides.
00402    START is the starting bit number in the word, architecture origin.
00403    LENGTH is the length of VALUE in bits.
00404    TOTAL_LENGTH is the total length of the insn in bits.
00405 
00406    Returns 1 for success, 0 for failure.  */
00407 
00408 /* ??? The return code isn't properly used.  wip.  */
00409 
00410 /* ??? This doesn't handle bfd_vma's.  Create another function when
00411    necessary.  */
00412 
00413 static int
00414 extract_normal (CGEN_CPU_DESC cd,
00415 #if ! CGEN_INT_INSN_P
00416               CGEN_EXTRACT_INFO *ex_info,
00417 #else
00418               CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED,
00419 #endif
00420               CGEN_INSN_INT insn_value,
00421               unsigned int attrs,
00422               unsigned int word_offset,
00423               unsigned int start,
00424               unsigned int length,
00425               unsigned int word_length,
00426               unsigned int total_length,
00427 #if ! CGEN_INT_INSN_P
00428               bfd_vma pc,
00429 #else
00430               bfd_vma pc ATTRIBUTE_UNUSED,
00431 #endif
00432               long *valuep)
00433 {
00434   long value, mask;
00435 
00436   /* If LENGTH is zero, this operand doesn't contribute to the value
00437      so give it a standard value of zero.  */
00438   if (length == 0)
00439     {
00440       *valuep = 0;
00441       return 1;
00442     }
00443 
00444   if (word_length > 32)
00445     abort ();
00446 
00447   /* For architectures with insns smaller than the insn-base-bitsize,
00448      word_length may be too big.  */
00449   if (cd->min_insn_bitsize < cd->base_insn_bitsize)
00450     {
00451       if (word_offset + word_length > total_length)
00452        word_length = total_length - word_offset;
00453     }
00454 
00455   /* Does the value reside in INSN_VALUE, and at the right alignment?  */
00456 
00457   if (CGEN_INT_INSN_P || (word_offset == 0 && word_length == total_length))
00458     {
00459       if (CGEN_INSN_LSB0_P)
00460        value = insn_value >> ((word_offset + start + 1) - length);
00461       else
00462        value = insn_value >> (total_length - ( word_offset + start + length));
00463     }
00464 
00465 #if ! CGEN_INT_INSN_P
00466 
00467   else
00468     {
00469       unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
00470 
00471       if (word_length > 32)
00472        abort ();
00473 
00474       if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
00475        return 0;
00476 
00477       value = extract_1 (cd, ex_info, start, length, word_length, bufp, pc);
00478     }
00479 
00480 #endif /* ! CGEN_INT_INSN_P */
00481 
00482   /* Written this way to avoid undefined behaviour.  */
00483   mask = (((1L << (length - 1)) - 1) << 1) | 1;
00484 
00485   value &= mask;
00486   /* sign extend? */
00487   if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)
00488       && (value & (1L << (length - 1))))
00489     value |= ~mask;
00490 
00491   *valuep = value;
00492 
00493   return 1;
00494 }
00495 
00496 /* Default insn extractor.
00497 
00498    INSN_VALUE is the first base_insn_bitsize bits, translated to host order.
00499    The extracted fields are stored in FIELDS.
00500    EX_INFO is used to handle reading variable length insns.
00501    Return the length of the insn in bits, or 0 if no match,
00502    or -1 if an error occurs fetching data (memory_error_func will have
00503    been called).  */
00504 
00505 static int
00506 extract_insn_normal (CGEN_CPU_DESC cd,
00507                    const CGEN_INSN *insn,
00508                    CGEN_EXTRACT_INFO *ex_info,
00509                    CGEN_INSN_INT insn_value,
00510                    CGEN_FIELDS *fields,
00511                    bfd_vma pc)
00512 {
00513   const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
00514   const CGEN_SYNTAX_CHAR_TYPE *syn;
00515 
00516   CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn);
00517 
00518   CGEN_INIT_EXTRACT (cd);
00519 
00520   for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn)
00521     {
00522       int length;
00523 
00524       if (CGEN_SYNTAX_CHAR_P (*syn))
00525        continue;
00526 
00527       length = (* cd->extract_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
00528                                    ex_info, insn_value, fields, pc);
00529       if (length <= 0)
00530        return length;
00531     }
00532 
00533   /* We recognized and successfully extracted this insn.  */
00534   return CGEN_INSN_BITSIZE (insn);
00535 }
00536 
00537 /* Machine generated code added here.  */
00538 
00539 const char * xc16x_cgen_insert_operand
00540   (CGEN_CPU_DESC, int, CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma);
00541 
00542 /* Main entry point for operand insertion.
00543 
00544    This function is basically just a big switch statement.  Earlier versions
00545    used tables to look up the function to use, but
00546    - if the table contains both assembler and disassembler functions then
00547      the disassembler contains much of the assembler and vice-versa,
00548    - there's a lot of inlining possibilities as things grow,
00549    - using a switch statement avoids the function call overhead.
00550 
00551    This function could be moved into `parse_insn_normal', but keeping it
00552    separate makes clear the interface between `parse_insn_normal' and each of
00553    the handlers.  It's also needed by GAS to insert operands that couldn't be
00554    resolved during parsing.  */
00555 
00556 const char *
00557 xc16x_cgen_insert_operand (CGEN_CPU_DESC cd,
00558                           int opindex,
00559                           CGEN_FIELDS * fields,
00560                           CGEN_INSN_BYTES_PTR buffer,
00561                           bfd_vma pc ATTRIBUTE_UNUSED)
00562 {
00563   const char * errmsg = NULL;
00564   unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
00565 
00566   switch (opindex)
00567     {
00568     case XC16X_OPERAND_REGNAM :
00569       errmsg = insert_normal (cd, fields->f_reg8, 0, 0, 15, 8, 32, total_length, buffer);
00570       break;
00571     case XC16X_OPERAND_BIT01 :
00572       errmsg = insert_normal (cd, fields->f_op_1bit, 0, 0, 8, 1, 32, total_length, buffer);
00573       break;
00574     case XC16X_OPERAND_BIT1 :
00575       errmsg = insert_normal (cd, fields->f_op_bit1, 0, 0, 11, 1, 32, total_length, buffer);
00576       break;
00577     case XC16X_OPERAND_BIT2 :
00578       errmsg = insert_normal (cd, fields->f_op_bit2, 0, 0, 11, 2, 32, total_length, buffer);
00579       break;
00580     case XC16X_OPERAND_BIT4 :
00581       errmsg = insert_normal (cd, fields->f_op_bit4, 0, 0, 11, 4, 32, total_length, buffer);
00582       break;
00583     case XC16X_OPERAND_BIT8 :
00584       errmsg = insert_normal (cd, fields->f_op_bit8, 0, 0, 31, 8, 32, total_length, buffer);
00585       break;
00586     case XC16X_OPERAND_BITONE :
00587       errmsg = insert_normal (cd, fields->f_op_onebit, 0, 0, 9, 1, 32, total_length, buffer);
00588       break;
00589     case XC16X_OPERAND_CADDR :
00590       errmsg = insert_normal (cd, fields->f_offset16, 0|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_ABS_ADDR), 0, 31, 16, 32, total_length, buffer);
00591       break;
00592     case XC16X_OPERAND_COND :
00593       errmsg = insert_normal (cd, fields->f_condcode, 0, 0, 7, 4, 32, total_length, buffer);
00594       break;
00595     case XC16X_OPERAND_DATA8 :
00596       errmsg = insert_normal (cd, fields->f_data8, 0, 0, 23, 8, 32, total_length, buffer);
00597       break;
00598     case XC16X_OPERAND_DATAHI8 :
00599       errmsg = insert_normal (cd, fields->f_datahi8, 0, 0, 31, 8, 32, total_length, buffer);
00600       break;
00601     case XC16X_OPERAND_DOT :
00602       break;
00603     case XC16X_OPERAND_DR :
00604       errmsg = insert_normal (cd, fields->f_r1, 0, 0, 15, 4, 32, total_length, buffer);
00605       break;
00606     case XC16X_OPERAND_DRB :
00607       errmsg = insert_normal (cd, fields->f_r1, 0, 0, 15, 4, 32, total_length, buffer);
00608       break;
00609     case XC16X_OPERAND_DRI :
00610       errmsg = insert_normal (cd, fields->f_r4, 0, 0, 11, 4, 32, total_length, buffer);
00611       break;
00612     case XC16X_OPERAND_EXTCOND :
00613       errmsg = insert_normal (cd, fields->f_extccode, 0, 0, 15, 5, 32, total_length, buffer);
00614       break;
00615     case XC16X_OPERAND_GENREG :
00616       errmsg = insert_normal (cd, fields->f_regb8, 0, 0, 15, 8, 32, total_length, buffer);
00617       break;
00618     case XC16X_OPERAND_HASH :
00619       break;
00620     case XC16X_OPERAND_ICOND :
00621       errmsg = insert_normal (cd, fields->f_icondcode, 0, 0, 15, 4, 32, total_length, buffer);
00622       break;
00623     case XC16X_OPERAND_LBIT2 :
00624       errmsg = insert_normal (cd, fields->f_op_lbit2, 0, 0, 15, 2, 32, total_length, buffer);
00625       break;
00626     case XC16X_OPERAND_LBIT4 :
00627       errmsg = insert_normal (cd, fields->f_op_lbit4, 0, 0, 15, 4, 32, total_length, buffer);
00628       break;
00629     case XC16X_OPERAND_MASK8 :
00630       errmsg = insert_normal (cd, fields->f_mask8, 0, 0, 23, 8, 32, total_length, buffer);
00631       break;
00632     case XC16X_OPERAND_MASKLO8 :
00633       errmsg = insert_normal (cd, fields->f_datahi8, 0, 0, 31, 8, 32, total_length, buffer);
00634       break;
00635     case XC16X_OPERAND_MEMGR8 :
00636       errmsg = insert_normal (cd, fields->f_memgr8, 0, 0, 31, 16, 32, total_length, buffer);
00637       break;
00638     case XC16X_OPERAND_MEMORY :
00639       errmsg = insert_normal (cd, fields->f_memory, 0, 0, 31, 16, 32, total_length, buffer);
00640       break;
00641     case XC16X_OPERAND_PAG :
00642       break;
00643     case XC16X_OPERAND_PAGENUM :
00644       errmsg = insert_normal (cd, fields->f_pagenum, 0, 0, 25, 10, 32, total_length, buffer);
00645       break;
00646     case XC16X_OPERAND_POF :
00647       break;
00648     case XC16X_OPERAND_QBIT :
00649       errmsg = insert_normal (cd, fields->f_qbit, 0, 0, 7, 4, 32, total_length, buffer);
00650       break;
00651     case XC16X_OPERAND_QHIBIT :
00652       errmsg = insert_normal (cd, fields->f_qhibit, 0, 0, 27, 4, 32, total_length, buffer);
00653       break;
00654     case XC16X_OPERAND_QLOBIT :
00655       errmsg = insert_normal (cd, fields->f_qlobit, 0, 0, 31, 4, 32, total_length, buffer);
00656       break;
00657     case XC16X_OPERAND_REG8 :
00658       errmsg = insert_normal (cd, fields->f_reg8, 0, 0, 15, 8, 32, total_length, buffer);
00659       break;
00660     case XC16X_OPERAND_REGB8 :
00661       errmsg = insert_normal (cd, fields->f_regb8, 0, 0, 15, 8, 32, total_length, buffer);
00662       break;
00663     case XC16X_OPERAND_REGBMEM8 :
00664       errmsg = insert_normal (cd, fields->f_regmem8, 0, 0, 15, 8, 32, total_length, buffer);
00665       break;
00666     case XC16X_OPERAND_REGHI8 :
00667       errmsg = insert_normal (cd, fields->f_reghi8, 0, 0, 23, 8, 32, total_length, buffer);
00668       break;
00669     case XC16X_OPERAND_REGMEM8 :
00670       errmsg = insert_normal (cd, fields->f_regmem8, 0, 0, 15, 8, 32, total_length, buffer);
00671       break;
00672     case XC16X_OPERAND_REGOFF8 :
00673       errmsg = insert_normal (cd, fields->f_regoff8, 0, 0, 15, 8, 32, total_length, buffer);
00674       break;
00675     case XC16X_OPERAND_REL :
00676       errmsg = insert_normal (cd, fields->f_rel8, 0|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 15, 8, 32, total_length, buffer);
00677       break;
00678     case XC16X_OPERAND_RELHI :
00679       errmsg = insert_normal (cd, fields->f_relhi8, 0|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 23, 8, 32, total_length, buffer);
00680       break;
00681     case XC16X_OPERAND_SEG :
00682       errmsg = insert_normal (cd, fields->f_seg8, 0, 0, 15, 8, 32, total_length, buffer);
00683       break;
00684     case XC16X_OPERAND_SEGHI8 :
00685       errmsg = insert_normal (cd, fields->f_segnum8, 0, 0, 23, 8, 32, total_length, buffer);
00686       break;
00687     case XC16X_OPERAND_SEGM :
00688       break;
00689     case XC16X_OPERAND_SOF :
00690       break;
00691     case XC16X_OPERAND_SR :
00692       errmsg = insert_normal (cd, fields->f_r2, 0, 0, 11, 4, 32, total_length, buffer);
00693       break;
00694     case XC16X_OPERAND_SR2 :
00695       errmsg = insert_normal (cd, fields->f_r0, 0, 0, 9, 2, 32, total_length, buffer);
00696       break;
00697     case XC16X_OPERAND_SRB :
00698       errmsg = insert_normal (cd, fields->f_r2, 0, 0, 11, 4, 32, total_length, buffer);
00699       break;
00700     case XC16X_OPERAND_SRC1 :
00701       errmsg = insert_normal (cd, fields->f_r1, 0, 0, 15, 4, 32, total_length, buffer);
00702       break;
00703     case XC16X_OPERAND_SRC2 :
00704       errmsg = insert_normal (cd, fields->f_r2, 0, 0, 11, 4, 32, total_length, buffer);
00705       break;
00706     case XC16X_OPERAND_SRDIV :
00707       errmsg = insert_normal (cd, fields->f_reg8, 0, 0, 15, 8, 32, total_length, buffer);
00708       break;
00709     case XC16X_OPERAND_U4 :
00710       errmsg = insert_normal (cd, fields->f_uimm4, 0, 0, 15, 4, 32, total_length, buffer);
00711       break;
00712     case XC16X_OPERAND_UIMM16 :
00713       errmsg = insert_normal (cd, fields->f_uimm16, 0, 0, 31, 16, 32, total_length, buffer);
00714       break;
00715     case XC16X_OPERAND_UIMM2 :
00716       errmsg = insert_normal (cd, fields->f_uimm2, 0, 0, 13, 2, 32, total_length, buffer);
00717       break;
00718     case XC16X_OPERAND_UIMM3 :
00719       errmsg = insert_normal (cd, fields->f_uimm3, 0, 0, 10, 3, 32, total_length, buffer);
00720       break;
00721     case XC16X_OPERAND_UIMM4 :
00722       errmsg = insert_normal (cd, fields->f_uimm4, 0, 0, 15, 4, 32, total_length, buffer);
00723       break;
00724     case XC16X_OPERAND_UIMM7 :
00725       errmsg = insert_normal (cd, fields->f_uimm7, 0|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 15, 7, 32, total_length, buffer);
00726       break;
00727     case XC16X_OPERAND_UIMM8 :
00728       errmsg = insert_normal (cd, fields->f_uimm8, 0, 0, 23, 8, 32, total_length, buffer);
00729       break;
00730     case XC16X_OPERAND_UPAG16 :
00731       errmsg = insert_normal (cd, fields->f_uimm16, 0, 0, 31, 16, 32, total_length, buffer);
00732       break;
00733     case XC16X_OPERAND_UPOF16 :
00734       errmsg = insert_normal (cd, fields->f_memory, 0, 0, 31, 16, 32, total_length, buffer);
00735       break;
00736     case XC16X_OPERAND_USEG16 :
00737       errmsg = insert_normal (cd, fields->f_offset16, 0|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_ABS_ADDR), 0, 31, 16, 32, total_length, buffer);
00738       break;
00739     case XC16X_OPERAND_USEG8 :
00740       errmsg = insert_normal (cd, fields->f_seg8, 0, 0, 15, 8, 32, total_length, buffer);
00741       break;
00742     case XC16X_OPERAND_USOF16 :
00743       errmsg = insert_normal (cd, fields->f_offset16, 0|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_ABS_ADDR), 0, 31, 16, 32, total_length, buffer);
00744       break;
00745 
00746     default :
00747       /* xgettext:c-format */
00748       fprintf (stderr, _("Unrecognized field %d while building insn.\n"),
00749               opindex);
00750       abort ();
00751   }
00752 
00753   return errmsg;
00754 }
00755 
00756 int xc16x_cgen_extract_operand
00757   (CGEN_CPU_DESC, int, CGEN_EXTRACT_INFO *, CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma);
00758 
00759 /* Main entry point for operand extraction.
00760    The result is <= 0 for error, >0 for success.
00761    ??? Actual values aren't well defined right now.
00762 
00763    This function is basically just a big switch statement.  Earlier versions
00764    used tables to look up the function to use, but
00765    - if the table contains both assembler and disassembler functions then
00766      the disassembler contains much of the assembler and vice-versa,
00767    - there's a lot of inlining possibilities as things grow,
00768    - using a switch statement avoids the function call overhead.
00769 
00770    This function could be moved into `print_insn_normal', but keeping it
00771    separate makes clear the interface between `print_insn_normal' and each of
00772    the handlers.  */
00773 
00774 int
00775 xc16x_cgen_extract_operand (CGEN_CPU_DESC cd,
00776                           int opindex,
00777                           CGEN_EXTRACT_INFO *ex_info,
00778                           CGEN_INSN_INT insn_value,
00779                           CGEN_FIELDS * fields,
00780                           bfd_vma pc)
00781 {
00782   /* Assume success (for those operands that are nops).  */
00783   int length = 1;
00784   unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
00785 
00786   switch (opindex)
00787     {
00788     case XC16X_OPERAND_REGNAM :
00789       length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 8, 32, total_length, pc, & fields->f_reg8);
00790       break;
00791     case XC16X_OPERAND_BIT01 :
00792       length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 1, 32, total_length, pc, & fields->f_op_1bit);
00793       break;
00794     case XC16X_OPERAND_BIT1 :
00795       length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 1, 32, total_length, pc, & fields->f_op_bit1);
00796       break;
00797     case XC16X_OPERAND_BIT2 :
00798       length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 2, 32, total_length, pc, & fields->f_op_bit2);
00799       break;
00800     case XC16X_OPERAND_BIT4 :
00801       length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 4, 32, total_length, pc, & fields->f_op_bit4);
00802       break;
00803     case XC16X_OPERAND_BIT8 :
00804       length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 8, 32, total_length, pc, & fields->f_op_bit8);
00805       break;
00806     case XC16X_OPERAND_BITONE :
00807       length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 1, 32, total_length, pc, & fields->f_op_onebit);
00808       break;
00809     case XC16X_OPERAND_CADDR :
00810       length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_ABS_ADDR), 0, 31, 16, 32, total_length, pc, & fields->f_offset16);
00811       break;
00812     case XC16X_OPERAND_COND :
00813       length = extract_normal (cd, ex_info, insn_value, 0, 0, 7, 4, 32, total_length, pc, & fields->f_condcode);
00814       break;
00815     case XC16X_OPERAND_DATA8 :
00816       length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 8, 32, total_length, pc, & fields->f_data8);
00817       break;
00818     case XC16X_OPERAND_DATAHI8 :
00819       length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 8, 32, total_length, pc, & fields->f_datahi8);
00820       break;
00821     case XC16X_OPERAND_DOT :
00822       break;
00823     case XC16X_OPERAND_DR :
00824       length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 4, 32, total_length, pc, & fields->f_r1);
00825       break;
00826     case XC16X_OPERAND_DRB :
00827       length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 4, 32, total_length, pc, & fields->f_r1);
00828       break;
00829     case XC16X_OPERAND_DRI :
00830       length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 4, 32, total_length, pc, & fields->f_r4);
00831       break;
00832     case XC16X_OPERAND_EXTCOND :
00833       length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 5, 32, total_length, pc, & fields->f_extccode);
00834       break;
00835     case XC16X_OPERAND_GENREG :
00836       length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 8, 32, total_length, pc, & fields->f_regb8);
00837       break;
00838     case XC16X_OPERAND_HASH :
00839       break;
00840     case XC16X_OPERAND_ICOND :
00841       length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 4, 32, total_length, pc, & fields->f_icondcode);
00842       break;
00843     case XC16X_OPERAND_LBIT2 :
00844       length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 2, 32, total_length, pc, & fields->f_op_lbit2);
00845       break;
00846     case XC16X_OPERAND_LBIT4 :
00847       length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 4, 32, total_length, pc, & fields->f_op_lbit4);
00848       break;
00849     case XC16X_OPERAND_MASK8 :
00850       length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 8, 32, total_length, pc, & fields->f_mask8);
00851       break;
00852     case XC16X_OPERAND_MASKLO8 :
00853       length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 8, 32, total_length, pc, & fields->f_datahi8);
00854       break;
00855     case XC16X_OPERAND_MEMGR8 :
00856       length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 16, 32, total_length, pc, & fields->f_memgr8);
00857       break;
00858     case XC16X_OPERAND_MEMORY :
00859       length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 16, 32, total_length, pc, & fields->f_memory);
00860       break;
00861     case XC16X_OPERAND_PAG :
00862       break;
00863     case XC16X_OPERAND_PAGENUM :
00864       length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 10, 32, total_length, pc, & fields->f_pagenum);
00865       break;
00866     case XC16X_OPERAND_POF :
00867       break;
00868     case XC16X_OPERAND_QBIT :
00869       length = extract_normal (cd, ex_info, insn_value, 0, 0, 7, 4, 32, total_length, pc, & fields->f_qbit);
00870       break;
00871     case XC16X_OPERAND_QHIBIT :
00872       length = extract_normal (cd, ex_info, insn_value, 0, 0, 27, 4, 32, total_length, pc, & fields->f_qhibit);
00873       break;
00874     case XC16X_OPERAND_QLOBIT :
00875       length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 4, 32, total_length, pc, & fields->f_qlobit);
00876       break;
00877     case XC16X_OPERAND_REG8 :
00878       length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 8, 32, total_length, pc, & fields->f_reg8);
00879       break;
00880     case XC16X_OPERAND_REGB8 :
00881       length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 8, 32, total_length, pc, & fields->f_regb8);
00882       break;
00883     case XC16X_OPERAND_REGBMEM8 :
00884       length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 8, 32, total_length, pc, & fields->f_regmem8);
00885       break;
00886     case XC16X_OPERAND_REGHI8 :
00887       length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 8, 32, total_length, pc, & fields->f_reghi8);
00888       break;
00889     case XC16X_OPERAND_REGMEM8 :
00890       length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 8, 32, total_length, pc, & fields->f_regmem8);
00891       break;
00892     case XC16X_OPERAND_REGOFF8 :
00893       length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 8, 32, total_length, pc, & fields->f_regoff8);
00894       break;
00895     case XC16X_OPERAND_REL :
00896       length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 15, 8, 32, total_length, pc, & fields->f_rel8);
00897       break;
00898     case XC16X_OPERAND_RELHI :
00899       length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 23, 8, 32, total_length, pc, & fields->f_relhi8);
00900       break;
00901     case XC16X_OPERAND_SEG :
00902       length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 8, 32, total_length, pc, & fields->f_seg8);
00903       break;
00904     case XC16X_OPERAND_SEGHI8 :
00905       length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 8, 32, total_length, pc, & fields->f_segnum8);
00906       break;
00907     case XC16X_OPERAND_SEGM :
00908       break;
00909     case XC16X_OPERAND_SOF :
00910       break;
00911     case XC16X_OPERAND_SR :
00912       length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 4, 32, total_length, pc, & fields->f_r2);
00913       break;
00914     case XC16X_OPERAND_SR2 :
00915       length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 2, 32, total_length, pc, & fields->f_r0);
00916       break;
00917     case XC16X_OPERAND_SRB :
00918       length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 4, 32, total_length, pc, & fields->f_r2);
00919       break;
00920     case XC16X_OPERAND_SRC1 :
00921       length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 4, 32, total_length, pc, & fields->f_r1);
00922       break;
00923     case XC16X_OPERAND_SRC2 :
00924       length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 4, 32, total_length, pc, & fields->f_r2);
00925       break;
00926     case XC16X_OPERAND_SRDIV :
00927       length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 8, 32, total_length, pc, & fields->f_reg8);
00928       break;
00929     case XC16X_OPERAND_U4 :
00930       length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 4, 32, total_length, pc, & fields->f_uimm4);
00931       break;
00932     case XC16X_OPERAND_UIMM16 :
00933       length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 16, 32, total_length, pc, & fields->f_uimm16);
00934       break;
00935     case XC16X_OPERAND_UIMM2 :
00936       length = extract_normal (cd, ex_info, insn_value, 0, 0, 13, 2, 32, total_length, pc, & fields->f_uimm2);
00937       break;
00938     case XC16X_OPERAND_UIMM3 :
00939       length = extract_normal (cd, ex_info, insn_value, 0, 0, 10, 3, 32, total_length, pc, & fields->f_uimm3);
00940       break;
00941     case XC16X_OPERAND_UIMM4 :
00942       length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 4, 32, total_length, pc, & fields->f_uimm4);
00943       break;
00944     case XC16X_OPERAND_UIMM7 :
00945       length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 15, 7, 32, total_length, pc, & fields->f_uimm7);
00946       break;
00947     case XC16X_OPERAND_UIMM8 :
00948       length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 8, 32, total_length, pc, & fields->f_uimm8);
00949       break;
00950     case XC16X_OPERAND_UPAG16 :
00951       length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 16, 32, total_length, pc, & fields->f_uimm16);
00952       break;
00953     case XC16X_OPERAND_UPOF16 :
00954       length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 16, 32, total_length, pc, & fields->f_memory);
00955       break;
00956     case XC16X_OPERAND_USEG16 :
00957       length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_ABS_ADDR), 0, 31, 16, 32, total_length, pc, & fields->f_offset16);
00958       break;
00959     case XC16X_OPERAND_USEG8 :
00960       length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 8, 32, total_length, pc, & fields->f_seg8);
00961       break;
00962     case XC16X_OPERAND_USOF16 :
00963       length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_ABS_ADDR), 0, 31, 16, 32, total_length, pc, & fields->f_offset16);
00964       break;
00965 
00966     default :
00967       /* xgettext:c-format */
00968       fprintf (stderr, _("Unrecognized field %d while decoding insn.\n"),
00969               opindex);
00970       abort ();
00971     }
00972 
00973   return length;
00974 }
00975 
00976 cgen_insert_fn * const xc16x_cgen_insert_handlers[] = 
00977 {
00978   insert_insn_normal,
00979 };
00980 
00981 cgen_extract_fn * const xc16x_cgen_extract_handlers[] = 
00982 {
00983   extract_insn_normal,
00984 };
00985 
00986 int xc16x_cgen_get_int_operand     (CGEN_CPU_DESC, int, const CGEN_FIELDS *);
00987 bfd_vma xc16x_cgen_get_vma_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *);
00988 
00989 /* Getting values from cgen_fields is handled by a collection of functions.
00990    They are distinguished by the type of the VALUE argument they return.
00991    TODO: floating point, inlining support, remove cases where result type
00992    not appropriate.  */
00993 
00994 int
00995 xc16x_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
00996                           int opindex,
00997                           const CGEN_FIELDS * fields)
00998 {
00999   int value;
01000 
01001   switch (opindex)
01002     {
01003     case XC16X_OPERAND_REGNAM :
01004       value = fields->f_reg8;
01005       break;
01006     case XC16X_OPERAND_BIT01 :
01007       value = fields->f_op_1bit;
01008       break;
01009     case XC16X_OPERAND_BIT1 :
01010       value = fields->f_op_bit1;
01011       break;
01012     case XC16X_OPERAND_BIT2 :
01013       value = fields->f_op_bit2;
01014       break;
01015     case XC16X_OPERAND_BIT4 :
01016       value = fields->f_op_bit4;
01017       break;
01018     case XC16X_OPERAND_BIT8 :
01019       value = fields->f_op_bit8;
01020       break;
01021     case XC16X_OPERAND_BITONE :
01022       value = fields->f_op_onebit;
01023       break;
01024     case XC16X_OPERAND_CADDR :
01025       value = fields->f_offset16;
01026       break;
01027     case XC16X_OPERAND_COND :
01028       value = fields->f_condcode;
01029       break;
01030     case XC16X_OPERAND_DATA8 :
01031       value = fields->f_data8;
01032       break;
01033     case XC16X_OPERAND_DATAHI8 :
01034       value = fields->f_datahi8;
01035       break;
01036     case XC16X_OPERAND_DOT :
01037       value = 0;
01038       break;
01039     case XC16X_OPERAND_DR :
01040       value = fields->f_r1;
01041       break;
01042     case XC16X_OPERAND_DRB :
01043       value = fields->f_r1;
01044       break;
01045     case XC16X_OPERAND_DRI :
01046       value = fields->f_r4;
01047       break;
01048     case XC16X_OPERAND_EXTCOND :
01049       value = fields->f_extccode;
01050       break;
01051     case XC16X_OPERAND_GENREG :
01052       value = fields->f_regb8;
01053       break;
01054     case XC16X_OPERAND_HASH :
01055       value = 0;
01056       break;
01057     case XC16X_OPERAND_ICOND :
01058       value = fields->f_icondcode;
01059       break;
01060     case XC16X_OPERAND_LBIT2 :
01061       value = fields->f_op_lbit2;
01062       break;
01063     case XC16X_OPERAND_LBIT4 :
01064       value = fields->f_op_lbit4;
01065       break;
01066     case XC16X_OPERAND_MASK8 :
01067       value = fields->f_mask8;
01068       break;
01069     case XC16X_OPERAND_MASKLO8 :
01070       value = fields->f_datahi8;
01071       break;
01072     case XC16X_OPERAND_MEMGR8 :
01073       value = fields->f_memgr8;
01074       break;
01075     case XC16X_OPERAND_MEMORY :
01076       value = fields->f_memory;
01077       break;
01078     case XC16X_OPERAND_PAG :
01079       value = 0;
01080       break;
01081     case XC16X_OPERAND_PAGENUM :
01082       value = fields->f_pagenum;
01083       break;
01084     case XC16X_OPERAND_POF :
01085       value = 0;
01086       break;
01087     case XC16X_OPERAND_QBIT :
01088       value = fields->f_qbit;
01089       break;
01090     case XC16X_OPERAND_QHIBIT :
01091       value = fields->f_qhibit;
01092       break;
01093     case XC16X_OPERAND_QLOBIT :
01094       value = fields->f_qlobit;
01095       break;
01096     case XC16X_OPERAND_REG8 :
01097       value = fields->f_reg8;
01098       break;
01099     case XC16X_OPERAND_REGB8 :
01100       value = fields->f_regb8;
01101       break;
01102     case XC16X_OPERAND_REGBMEM8 :
01103       value = fields->f_regmem8;
01104       break;
01105     case XC16X_OPERAND_REGHI8 :
01106       value = fields->f_reghi8;
01107       break;
01108     case XC16X_OPERAND_REGMEM8 :
01109       value = fields->f_regmem8;
01110       break;
01111     case XC16X_OPERAND_REGOFF8 :
01112       value = fields->f_regoff8;
01113       break;
01114     case XC16X_OPERAND_REL :
01115       value = fields->f_rel8;
01116       break;
01117     case XC16X_OPERAND_RELHI :
01118       value = fields->f_relhi8;
01119       break;
01120     case XC16X_OPERAND_SEG :
01121       value = fields->f_seg8;
01122       break;
01123     case XC16X_OPERAND_SEGHI8 :
01124       value = fields->f_segnum8;
01125       break;
01126     case XC16X_OPERAND_SEGM :
01127       value = 0;
01128       break;
01129     case XC16X_OPERAND_SOF :
01130       value = 0;
01131       break;
01132     case XC16X_OPERAND_SR :
01133       value = fields->f_r2;
01134       break;
01135     case XC16X_OPERAND_SR2 :
01136       value = fields->f_r0;
01137       break;
01138     case XC16X_OPERAND_SRB :
01139       value = fields->f_r2;
01140       break;
01141     case XC16X_OPERAND_SRC1 :
01142       value = fields->f_r1;
01143       break;
01144     case XC16X_OPERAND_SRC2 :
01145       value = fields->f_r2;
01146       break;
01147     case XC16X_OPERAND_SRDIV :
01148       value = fields->f_reg8;
01149       break;
01150     case XC16X_OPERAND_U4 :
01151       value = fields->f_uimm4;
01152       break;
01153     case XC16X_OPERAND_UIMM16 :
01154       value = fields->f_uimm16;
01155       break;
01156     case XC16X_OPERAND_UIMM2 :
01157       value = fields->f_uimm2;
01158       break;
01159     case XC16X_OPERAND_UIMM3 :
01160       value = fields->f_uimm3;
01161       break;
01162     case XC16X_OPERAND_UIMM4 :
01163       value = fields->f_uimm4;
01164       break;
01165     case XC16X_OPERAND_UIMM7 :
01166       value = fields->f_uimm7;
01167       break;
01168     case XC16X_OPERAND_UIMM8 :
01169       value = fields->f_uimm8;
01170       break;
01171     case XC16X_OPERAND_UPAG16 :
01172       value = fields->f_uimm16;
01173       break;
01174     case XC16X_OPERAND_UPOF16 :
01175       value = fields->f_memory;
01176       break;
01177     case XC16X_OPERAND_USEG16 :
01178       value = fields->f_offset16;
01179       break;
01180     case XC16X_OPERAND_USEG8 :
01181       value = fields->f_seg8;
01182       break;
01183     case XC16X_OPERAND_USOF16 :
01184       value = fields->f_offset16;
01185       break;
01186 
01187     default :
01188       /* xgettext:c-format */
01189       fprintf (stderr, _("Unrecognized field %d while getting int operand.\n"),
01190                      opindex);
01191       abort ();
01192   }
01193 
01194   return value;
01195 }
01196 
01197 bfd_vma
01198 xc16x_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
01199                           int opindex,
01200                           const CGEN_FIELDS * fields)
01201 {
01202   bfd_vma value;
01203 
01204   switch (opindex)
01205     {
01206     case XC16X_OPERAND_REGNAM :
01207       value = fields->f_reg8;
01208       break;
01209     case XC16X_OPERAND_BIT01 :
01210       value = fields->f_op_1bit;
01211       break;
01212     case XC16X_OPERAND_BIT1 :
01213       value = fields->f_op_bit1;
01214       break;
01215     case XC16X_OPERAND_BIT2 :
01216       value = fields->f_op_bit2;
01217       break;
01218     case XC16X_OPERAND_BIT4 :
01219       value = fields->f_op_bit4;
01220       break;
01221     case XC16X_OPERAND_BIT8 :
01222       value = fields->f_op_bit8;
01223       break;
01224     case XC16X_OPERAND_BITONE :
01225       value = fields->f_op_onebit;
01226       break;
01227     case XC16X_OPERAND_CADDR :
01228       value = fields->f_offset16;
01229       break;
01230     case XC16X_OPERAND_COND :
01231       value = fields->f_condcode;
01232       break;
01233     case XC16X_OPERAND_DATA8 :
01234       value = fields->f_data8;
01235       break;
01236     case XC16X_OPERAND_DATAHI8 :
01237       value = fields->f_datahi8;
01238       break;
01239     case XC16X_OPERAND_DOT :
01240       value = 0;
01241       break;
01242     case XC16X_OPERAND_DR :
01243       value = fields->f_r1;
01244       break;
01245     case XC16X_OPERAND_DRB :
01246       value = fields->f_r1;
01247       break;
01248     case XC16X_OPERAND_DRI :
01249       value = fields->f_r4;
01250       break;
01251     case XC16X_OPERAND_EXTCOND :
01252       value = fields->f_extccode;
01253       break;
01254     case XC16X_OPERAND_GENREG :
01255       value = fields->f_regb8;
01256       break;
01257     case XC16X_OPERAND_HASH :
01258       value = 0;
01259       break;
01260     case XC16X_OPERAND_ICOND :
01261       value = fields->f_icondcode;
01262       break;
01263     case XC16X_OPERAND_LBIT2 :
01264       value = fields->f_op_lbit2;
01265       break;
01266     case XC16X_OPERAND_LBIT4 :
01267       value = fields->f_op_lbit4;
01268       break;
01269     case XC16X_OPERAND_MASK8 :
01270       value = fields->f_mask8;
01271       break;
01272     case XC16X_OPERAND_MASKLO8 :
01273       value = fields->f_datahi8;
01274       break;
01275     case XC16X_OPERAND_MEMGR8 :
01276       value = fields->f_memgr8;
01277       break;
01278     case XC16X_OPERAND_MEMORY :
01279       value = fields->f_memory;
01280       break;
01281     case XC16X_OPERAND_PAG :
01282       value = 0;
01283       break;
01284     case XC16X_OPERAND_PAGENUM :
01285       value = fields->f_pagenum;
01286       break;
01287     case XC16X_OPERAND_POF :
01288       value = 0;
01289       break;
01290     case XC16X_OPERAND_QBIT :
01291       value = fields->f_qbit;
01292       break;
01293     case XC16X_OPERAND_QHIBIT :
01294       value = fields->f_qhibit;
01295       break;
01296     case XC16X_OPERAND_QLOBIT :
01297       value = fields->f_qlobit;
01298       break;
01299     case XC16X_OPERAND_REG8 :
01300       value = fields->f_reg8;
01301       break;
01302     case XC16X_OPERAND_REGB8 :
01303       value = fields->f_regb8;
01304       break;
01305     case XC16X_OPERAND_REGBMEM8 :
01306       value = fields->f_regmem8;
01307       break;
01308     case XC16X_OPERAND_REGHI8 :
01309       value = fields->f_reghi8;
01310       break;
01311     case XC16X_OPERAND_REGMEM8 :
01312       value = fields->f_regmem8;
01313       break;
01314     case XC16X_OPERAND_REGOFF8 :
01315       value = fields->f_regoff8;
01316       break;
01317     case XC16X_OPERAND_REL :
01318       value = fields->f_rel8;
01319       break;
01320     case XC16X_OPERAND_RELHI :
01321       value = fields->f_relhi8;
01322       break;
01323     case XC16X_OPERAND_SEG :
01324       value = fields->f_seg8;
01325       break;
01326     case XC16X_OPERAND_SEGHI8 :
01327       value = fields->f_segnum8;
01328       break;
01329     case XC16X_OPERAND_SEGM :
01330       value = 0;
01331       break;
01332     case XC16X_OPERAND_SOF :
01333       value = 0;
01334       break;
01335     case XC16X_OPERAND_SR :
01336       value = fields->f_r2;
01337       break;
01338     case XC16X_OPERAND_SR2 :
01339       value = fields->f_r0;
01340       break;
01341     case XC16X_OPERAND_SRB :
01342       value = fields->f_r2;
01343       break;
01344     case XC16X_OPERAND_SRC1 :
01345       value = fields->f_r1;
01346       break;
01347     case XC16X_OPERAND_SRC2 :
01348       value = fields->f_r2;
01349       break;
01350     case XC16X_OPERAND_SRDIV :
01351       value = fields->f_reg8;
01352       break;
01353     case XC16X_OPERAND_U4 :
01354       value = fields->f_uimm4;
01355       break;
01356     case XC16X_OPERAND_UIMM16 :
01357       value = fields->f_uimm16;
01358       break;
01359     case XC16X_OPERAND_UIMM2 :
01360       value = fields->f_uimm2;
01361       break;
01362     case XC16X_OPERAND_UIMM3 :
01363       value = fields->f_uimm3;
01364       break;
01365     case XC16X_OPERAND_UIMM4 :
01366       value = fields->f_uimm4;
01367       break;
01368     case XC16X_OPERAND_UIMM7 :
01369       value = fields->f_uimm7;
01370       break;
01371     case XC16X_OPERAND_UIMM8 :
01372       value = fields->f_uimm8;
01373       break;
01374     case XC16X_OPERAND_UPAG16 :
01375       value = fields->f_uimm16;
01376       break;
01377     case XC16X_OPERAND_UPOF16 :
01378       value = fields->f_memory;
01379       break;
01380     case XC16X_OPERAND_USEG16 :
01381       value = fields->f_offset16;
01382       break;
01383     case XC16X_OPERAND_USEG8 :
01384       value = fields->f_seg8;
01385       break;
01386     case XC16X_OPERAND_USOF16 :
01387       value = fields->f_offset16;
01388       break;
01389 
01390     default :
01391       /* xgettext:c-format */
01392       fprintf (stderr, _("Unrecognized field %d while getting vma operand.\n"),
01393                      opindex);
01394       abort ();
01395   }
01396 
01397   return value;
01398 }
01399 
01400 void xc16x_cgen_set_int_operand  (CGEN_CPU_DESC, int, CGEN_FIELDS *, int);
01401 void xc16x_cgen_set_vma_operand  (CGEN_CPU_DESC, int, CGEN_FIELDS *, bfd_vma);
01402 
01403 /* Stuffing values in cgen_fields is handled by a collection of functions.
01404    They are distinguished by the type of the VALUE argument they accept.
01405    TODO: floating point, inlining support, remove cases where argument type
01406    not appropriate.  */
01407 
01408 void
01409 xc16x_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
01410                           int opindex,
01411                           CGEN_FIELDS * fields,
01412                           int value)
01413 {
01414   switch (opindex)
01415     {
01416     case XC16X_OPERAND_REGNAM :
01417       fields->f_reg8 = value;
01418       break;
01419     case XC16X_OPERAND_BIT01 :
01420       fields->f_op_1bit = value;
01421       break;
01422     case XC16X_OPERAND_BIT1 :
01423       fields->f_op_bit1 = value;
01424       break;
01425     case XC16X_OPERAND_BIT2 :
01426       fields->f_op_bit2 = value;
01427       break;
01428     case XC16X_OPERAND_BIT4 :
01429       fields->f_op_bit4 = value;
01430       break;
01431     case XC16X_OPERAND_BIT8 :
01432       fields->f_op_bit8 = value;
01433       break;
01434     case XC16X_OPERAND_BITONE :
01435       fields->f_op_onebit = value;
01436       break;
01437     case XC16X_OPERAND_CADDR :
01438       fields->f_offset16 = value;
01439       break;
01440     case XC16X_OPERAND_COND :
01441       fields->f_condcode = value;
01442       break;
01443     case XC16X_OPERAND_DATA8 :
01444       fields->f_data8 = value;
01445       break;
01446     case XC16X_OPERAND_DATAHI8 :
01447       fields->f_datahi8 = value;
01448       break;
01449     case XC16X_OPERAND_DOT :
01450       break;
01451     case XC16X_OPERAND_DR :
01452       fields->f_r1 = value;
01453       break;
01454     case XC16X_OPERAND_DRB :
01455       fields->f_r1 = value;
01456       break;
01457     case XC16X_OPERAND_DRI :
01458       fields->f_r4 = value;
01459       break;
01460     case XC16X_OPERAND_EXTCOND :
01461       fields->f_extccode = value;
01462       break;
01463     case XC16X_OPERAND_GENREG :
01464       fields->f_regb8 = value;
01465       break;
01466     case XC16X_OPERAND_HASH :
01467       break;
01468     case XC16X_OPERAND_ICOND :
01469       fields->f_icondcode = value;
01470       break;
01471     case XC16X_OPERAND_LBIT2 :
01472       fields->f_op_lbit2 = value;
01473       break;
01474     case XC16X_OPERAND_LBIT4 :
01475       fields->f_op_lbit4 = value;
01476       break;
01477     case XC16X_OPERAND_MASK8 :
01478       fields->f_mask8 = value;
01479       break;
01480     case XC16X_OPERAND_MASKLO8 :
01481       fields->f_datahi8 = value;
01482       break;
01483     case XC16X_OPERAND_MEMGR8 :
01484       fields->f_memgr8 = value;
01485       break;
01486     case XC16X_OPERAND_MEMORY :
01487       fields->f_memory = value;
01488       break;
01489     case XC16X_OPERAND_PAG :
01490       break;
01491     case XC16X_OPERAND_PAGENUM :
01492       fields->f_pagenum = value;
01493       break;
01494     case XC16X_OPERAND_POF :
01495       break;
01496     case XC16X_OPERAND_QBIT :
01497       fields->f_qbit = value;
01498       break;
01499     case XC16X_OPERAND_QHIBIT :
01500       fields->f_qhibit = value;
01501       break;
01502     case XC16X_OPERAND_QLOBIT :
01503       fields->f_qlobit = value;
01504       break;
01505     case XC16X_OPERAND_REG8 :
01506       fields->f_reg8 = value;
01507       break;
01508     case XC16X_OPERAND_REGB8 :
01509       fields->f_regb8 = value;
01510       break;
01511     case XC16X_OPERAND_REGBMEM8 :
01512       fields->f_regmem8 = value;
01513       break;
01514     case XC16X_OPERAND_REGHI8 :
01515       fields->f_reghi8 = value;
01516       break;
01517     case XC16X_OPERAND_REGMEM8 :
01518       fields->f_regmem8 = value;
01519       break;
01520     case XC16X_OPERAND_REGOFF8 :
01521       fields->f_regoff8 = value;
01522       break;
01523     case XC16X_OPERAND_REL :
01524       fields->f_rel8 = value;
01525       break;
01526     case XC16X_OPERAND_RELHI :
01527       fields->f_relhi8 = value;
01528       break;
01529     case XC16X_OPERAND_SEG :
01530       fields->f_seg8 = value;
01531       break;
01532     case XC16X_OPERAND_SEGHI8 :
01533       fields->f_segnum8 = value;
01534       break;
01535     case XC16X_OPERAND_SEGM :
01536       break;
01537     case XC16X_OPERAND_SOF :
01538       break;
01539     case XC16X_OPERAND_SR :
01540       fields->f_r2 = value;
01541       break;
01542     case XC16X_OPERAND_SR2 :
01543       fields->f_r0 = value;
01544       break;
01545     case XC16X_OPERAND_SRB :
01546       fields->f_r2 = value;
01547       break;
01548     case XC16X_OPERAND_SRC1 :
01549       fields->f_r1 = value;
01550       break;
01551     case XC16X_OPERAND_SRC2 :
01552       fields->f_r2 = value;
01553       break;
01554     case XC16X_OPERAND_SRDIV :
01555       fields->f_reg8 = value;
01556       break;
01557     case XC16X_OPERAND_U4 :
01558       fields->f_uimm4 = value;
01559       break;
01560     case XC16X_OPERAND_UIMM16 :
01561       fields->f_uimm16 = value;
01562       break;
01563     case XC16X_OPERAND_UIMM2 :
01564       fields->f_uimm2 = value;
01565       break;
01566     case XC16X_OPERAND_UIMM3 :
01567       fields->f_uimm3 = value;
01568       break;
01569     case XC16X_OPERAND_UIMM4 :
01570       fields->f_uimm4 = value;
01571       break;
01572     case XC16X_OPERAND_UIMM7 :
01573       fields->f_uimm7 = value;
01574       break;
01575     case XC16X_OPERAND_UIMM8 :
01576       fields->f_uimm8 = value;
01577       break;
01578     case XC16X_OPERAND_UPAG16 :
01579       fields->f_uimm16 = value;
01580       break;
01581     case XC16X_OPERAND_UPOF16 :
01582       fields->f_memory = value;
01583       break;
01584     case XC16X_OPERAND_USEG16 :
01585       fields->f_offset16 = value;
01586       break;
01587     case XC16X_OPERAND_USEG8 :
01588       fields->f_seg8 = value;
01589       break;
01590     case XC16X_OPERAND_USOF16 :
01591       fields->f_offset16 = value;
01592       break;
01593 
01594     default :
01595       /* xgettext:c-format */
01596       fprintf (stderr, _("Unrecognized field %d while setting int operand.\n"),
01597                      opindex);
01598       abort ();
01599   }
01600 }
01601 
01602 void
01603 xc16x_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
01604                           int opindex,
01605                           CGEN_FIELDS * fields,
01606                           bfd_vma value)
01607 {
01608   switch (opindex)
01609     {
01610     case XC16X_OPERAND_REGNAM :
01611       fields->f_reg8 = value;
01612       break;
01613     case XC16X_OPERAND_BIT01 :
01614       fields->f_op_1bit = value;
01615       break;
01616     case XC16X_OPERAND_BIT1 :
01617       fields->f_op_bit1 = value;
01618       break;
01619     case XC16X_OPERAND_BIT2 :
01620       fields->f_op_bit2 = value;
01621       break;
01622     case XC16X_OPERAND_BIT4 :
01623       fields->f_op_bit4 = value;
01624       break;
01625     case XC16X_OPERAND_BIT8 :
01626       fields->f_op_bit8 = value;
01627       break;
01628     case XC16X_OPERAND_BITONE :
01629       fields->f_op_onebit = value;
01630       break;
01631     case XC16X_OPERAND_CADDR :
01632       fields->f_offset16 = value;
01633       break;
01634     case XC16X_OPERAND_COND :
01635       fields->f_condcode = value;
01636       break;
01637     case XC16X_OPERAND_DATA8 :
01638       fields->f_data8 = value;
01639       break;
01640     case XC16X_OPERAND_DATAHI8 :
01641       fields->f_datahi8 = value;
01642       break;
01643     case XC16X_OPERAND_DOT :
01644       break;
01645     case XC16X_OPERAND_DR :
01646       fields->f_r1 = value;
01647       break;
01648     case XC16X_OPERAND_DRB :
01649       fields->f_r1 = value;
01650       break;
01651     case XC16X_OPERAND_DRI :
01652       fields->f_r4 = value;
01653       break;
01654     case XC16X_OPERAND_EXTCOND :
01655       fields->f_extccode = value;
01656       break;
01657     case XC16X_OPERAND_GENREG :
01658       fields->f_regb8 = value;
01659       break;
01660     case XC16X_OPERAND_HASH :
01661       break;
01662     case XC16X_OPERAND_ICOND :
01663       fields->f_icondcode = value;
01664       break;
01665     case XC16X_OPERAND_LBIT2 :
01666       fields->f_op_lbit2 = value;
01667       break;
01668     case XC16X_OPERAND_LBIT4 :
01669       fields->f_op_lbit4 = value;
01670       break;
01671     case XC16X_OPERAND_MASK8 :
01672       fields->f_mask8 = value;
01673       break;
01674     case XC16X_OPERAND_MASKLO8 :
01675       fields->f_datahi8 = value;
01676       break;
01677     case XC16X_OPERAND_MEMGR8 :
01678       fields->f_memgr8 = value;
01679       break;
01680     case XC16X_OPERAND_MEMORY :
01681       fields->f_memory = value;
01682       break;
01683     case XC16X_OPERAND_PAG :
01684       break;
01685     case XC16X_OPERAND_PAGENUM :
01686       fields->f_pagenum = value;
01687       break;
01688     case XC16X_OPERAND_POF :
01689       break;
01690     case XC16X_OPERAND_QBIT :
01691       fields->f_qbit = value;
01692       break;
01693     case XC16X_OPERAND_QHIBIT :
01694       fields->f_qhibit = value;
01695       break;
01696     case XC16X_OPERAND_QLOBIT :
01697       fields->f_qlobit = value;
01698       break;
01699     case XC16X_OPERAND_REG8 :
01700       fields->f_reg8 = value;
01701       break;
01702     case XC16X_OPERAND_REGB8 :
01703       fields->f_regb8 = value;
01704       break;
01705     case XC16X_OPERAND_REGBMEM8 :
01706       fields->f_regmem8 = value;
01707       break;
01708     case XC16X_OPERAND_REGHI8 :
01709       fields->f_reghi8 = value;
01710       break;
01711     case XC16X_OPERAND_REGMEM8 :
01712       fields->f_regmem8 = value;
01713       break;
01714     case XC16X_OPERAND_REGOFF8 :
01715       fields->f_regoff8 = value;
01716       break;
01717     case XC16X_OPERAND_REL :
01718       fields->f_rel8 = value;
01719       break;
01720     case XC16X_OPERAND_RELHI :
01721       fields->f_relhi8 = value;
01722       break;
01723     case XC16X_OPERAND_SEG :
01724       fields->f_seg8 = value;
01725       break;
01726     case XC16X_OPERAND_SEGHI8 :
01727       fields->f_segnum8 = value;
01728       break;
01729     case XC16X_OPERAND_SEGM :
01730       break;
01731     case XC16X_OPERAND_SOF :
01732       break;
01733     case XC16X_OPERAND_SR :
01734       fields->f_r2 = value;
01735       break;
01736     case XC16X_OPERAND_SR2 :
01737       fields->f_r0 = value;
01738       break;
01739     case XC16X_OPERAND_SRB :
01740       fields->f_r2 = value;
01741       break;
01742     case XC16X_OPERAND_SRC1 :
01743       fields->f_r1 = value;
01744       break;
01745     case XC16X_OPERAND_SRC2 :
01746       fields->f_r2 = value;
01747       break;
01748     case XC16X_OPERAND_SRDIV :
01749       fields->f_reg8 = value;
01750       break;
01751     case XC16X_OPERAND_U4 :
01752       fields->f_uimm4 = value;
01753       break;
01754     case XC16X_OPERAND_UIMM16 :
01755       fields->f_uimm16 = value;
01756       break;
01757     case XC16X_OPERAND_UIMM2 :
01758       fields->f_uimm2 = value;
01759       break;
01760     case XC16X_OPERAND_UIMM3 :
01761       fields->f_uimm3 = value;
01762       break;
01763     case XC16X_OPERAND_UIMM4 :
01764       fields->f_uimm4 = value;
01765       break;
01766     case XC16X_OPERAND_UIMM7 :
01767       fields->f_uimm7 = value;
01768       break;
01769     case XC16X_OPERAND_UIMM8 :
01770       fields->f_uimm8 = value;
01771       break;
01772     case XC16X_OPERAND_UPAG16 :
01773       fields->f_uimm16 = value;
01774       break;
01775     case XC16X_OPERAND_UPOF16 :
01776       fields->f_memory = value;
01777       break;
01778     case XC16X_OPERAND_USEG16 :
01779       fields->f_offset16 = value;
01780       break;
01781     case XC16X_OPERAND_USEG8 :
01782       fields->f_seg8 = value;
01783       break;
01784     case XC16X_OPERAND_USOF16 :
01785       fields->f_offset16 = value;
01786       break;
01787 
01788     default :
01789       /* xgettext:c-format */
01790       fprintf (stderr, _("Unrecognized field %d while setting vma operand.\n"),
01791                      opindex);
01792       abort ();
01793   }
01794 }
01795 
01796 /* Function to call before using the instruction builder tables.  */
01797 
01798 void
01799 xc16x_cgen_init_ibld_table (CGEN_CPU_DESC cd)
01800 {
01801   cd->insert_handlers = & xc16x_cgen_insert_handlers[0];
01802   cd->extract_handlers = & xc16x_cgen_extract_handlers[0];
01803 
01804   cd->insert_operand = xc16x_cgen_insert_operand;
01805   cd->extract_operand = xc16x_cgen_extract_operand;
01806 
01807   cd->get_int_operand = xc16x_cgen_get_int_operand;
01808   cd->set_int_operand = xc16x_cgen_set_int_operand;
01809   cd->get_vma_operand = xc16x_cgen_get_vma_operand;
01810   cd->set_vma_operand = xc16x_cgen_set_vma_operand;
01811 }