Back to index

cell-binutils  2.17cvs20070401
frv-ibld.c
Go to the documentation of this file.
00001 /* Instruction building/extraction support for frv. -*- 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 "frv-desc.h"
00035 #include "frv-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 * frv_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 frv_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 FRV_OPERAND_A0 :
00569       errmsg = insert_normal (cd, fields->f_A, 0, 0, 17, 1, 32, total_length, buffer);
00570       break;
00571     case FRV_OPERAND_A1 :
00572       errmsg = insert_normal (cd, fields->f_A, 0, 0, 17, 1, 32, total_length, buffer);
00573       break;
00574     case FRV_OPERAND_ACC40SI :
00575       errmsg = insert_normal (cd, fields->f_ACC40Si, 0, 0, 17, 6, 32, total_length, buffer);
00576       break;
00577     case FRV_OPERAND_ACC40SK :
00578       errmsg = insert_normal (cd, fields->f_ACC40Sk, 0, 0, 30, 6, 32, total_length, buffer);
00579       break;
00580     case FRV_OPERAND_ACC40UI :
00581       errmsg = insert_normal (cd, fields->f_ACC40Ui, 0, 0, 17, 6, 32, total_length, buffer);
00582       break;
00583     case FRV_OPERAND_ACC40UK :
00584       errmsg = insert_normal (cd, fields->f_ACC40Uk, 0, 0, 30, 6, 32, total_length, buffer);
00585       break;
00586     case FRV_OPERAND_ACCGI :
00587       errmsg = insert_normal (cd, fields->f_ACCGi, 0, 0, 17, 6, 32, total_length, buffer);
00588       break;
00589     case FRV_OPERAND_ACCGK :
00590       errmsg = insert_normal (cd, fields->f_ACCGk, 0, 0, 30, 6, 32, total_length, buffer);
00591       break;
00592     case FRV_OPERAND_CCI :
00593       errmsg = insert_normal (cd, fields->f_CCi, 0, 0, 11, 3, 32, total_length, buffer);
00594       break;
00595     case FRV_OPERAND_CPRDOUBLEK :
00596       errmsg = insert_normal (cd, fields->f_CPRk, 0, 0, 30, 6, 32, total_length, buffer);
00597       break;
00598     case FRV_OPERAND_CPRI :
00599       errmsg = insert_normal (cd, fields->f_CPRi, 0, 0, 17, 6, 32, total_length, buffer);
00600       break;
00601     case FRV_OPERAND_CPRJ :
00602       errmsg = insert_normal (cd, fields->f_CPRj, 0, 0, 5, 6, 32, total_length, buffer);
00603       break;
00604     case FRV_OPERAND_CPRK :
00605       errmsg = insert_normal (cd, fields->f_CPRk, 0, 0, 30, 6, 32, total_length, buffer);
00606       break;
00607     case FRV_OPERAND_CRI :
00608       errmsg = insert_normal (cd, fields->f_CRi, 0, 0, 14, 3, 32, total_length, buffer);
00609       break;
00610     case FRV_OPERAND_CRJ :
00611       errmsg = insert_normal (cd, fields->f_CRj, 0, 0, 2, 3, 32, total_length, buffer);
00612       break;
00613     case FRV_OPERAND_CRJ_FLOAT :
00614       errmsg = insert_normal (cd, fields->f_CRj_float, 0, 0, 26, 2, 32, total_length, buffer);
00615       break;
00616     case FRV_OPERAND_CRJ_INT :
00617       {
00618         long value = fields->f_CRj_int;
00619         value = ((value) - (4));
00620         errmsg = insert_normal (cd, value, 0, 0, 26, 2, 32, total_length, buffer);
00621       }
00622       break;
00623     case FRV_OPERAND_CRK :
00624       errmsg = insert_normal (cd, fields->f_CRk, 0, 0, 27, 3, 32, total_length, buffer);
00625       break;
00626     case FRV_OPERAND_FCCI_1 :
00627       errmsg = insert_normal (cd, fields->f_FCCi_1, 0, 0, 11, 2, 32, total_length, buffer);
00628       break;
00629     case FRV_OPERAND_FCCI_2 :
00630       errmsg = insert_normal (cd, fields->f_FCCi_2, 0, 0, 26, 2, 32, total_length, buffer);
00631       break;
00632     case FRV_OPERAND_FCCI_3 :
00633       errmsg = insert_normal (cd, fields->f_FCCi_3, 0, 0, 1, 2, 32, total_length, buffer);
00634       break;
00635     case FRV_OPERAND_FCCK :
00636       errmsg = insert_normal (cd, fields->f_FCCk, 0, 0, 26, 2, 32, total_length, buffer);
00637       break;
00638     case FRV_OPERAND_FRDOUBLEI :
00639       errmsg = insert_normal (cd, fields->f_FRi, 0, 0, 17, 6, 32, total_length, buffer);
00640       break;
00641     case FRV_OPERAND_FRDOUBLEJ :
00642       errmsg = insert_normal (cd, fields->f_FRj, 0, 0, 5, 6, 32, total_length, buffer);
00643       break;
00644     case FRV_OPERAND_FRDOUBLEK :
00645       errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer);
00646       break;
00647     case FRV_OPERAND_FRI :
00648       errmsg = insert_normal (cd, fields->f_FRi, 0, 0, 17, 6, 32, total_length, buffer);
00649       break;
00650     case FRV_OPERAND_FRINTI :
00651       errmsg = insert_normal (cd, fields->f_FRi, 0, 0, 17, 6, 32, total_length, buffer);
00652       break;
00653     case FRV_OPERAND_FRINTIEVEN :
00654       errmsg = insert_normal (cd, fields->f_FRi, 0, 0, 17, 6, 32, total_length, buffer);
00655       break;
00656     case FRV_OPERAND_FRINTJ :
00657       errmsg = insert_normal (cd, fields->f_FRj, 0, 0, 5, 6, 32, total_length, buffer);
00658       break;
00659     case FRV_OPERAND_FRINTJEVEN :
00660       errmsg = insert_normal (cd, fields->f_FRj, 0, 0, 5, 6, 32, total_length, buffer);
00661       break;
00662     case FRV_OPERAND_FRINTK :
00663       errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer);
00664       break;
00665     case FRV_OPERAND_FRINTKEVEN :
00666       errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer);
00667       break;
00668     case FRV_OPERAND_FRJ :
00669       errmsg = insert_normal (cd, fields->f_FRj, 0, 0, 5, 6, 32, total_length, buffer);
00670       break;
00671     case FRV_OPERAND_FRK :
00672       errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer);
00673       break;
00674     case FRV_OPERAND_FRKHI :
00675       errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer);
00676       break;
00677     case FRV_OPERAND_FRKLO :
00678       errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer);
00679       break;
00680     case FRV_OPERAND_GRDOUBLEK :
00681       errmsg = insert_normal (cd, fields->f_GRk, 0, 0, 30, 6, 32, total_length, buffer);
00682       break;
00683     case FRV_OPERAND_GRI :
00684       errmsg = insert_normal (cd, fields->f_GRi, 0, 0, 17, 6, 32, total_length, buffer);
00685       break;
00686     case FRV_OPERAND_GRJ :
00687       errmsg = insert_normal (cd, fields->f_GRj, 0, 0, 5, 6, 32, total_length, buffer);
00688       break;
00689     case FRV_OPERAND_GRK :
00690       errmsg = insert_normal (cd, fields->f_GRk, 0, 0, 30, 6, 32, total_length, buffer);
00691       break;
00692     case FRV_OPERAND_GRKHI :
00693       errmsg = insert_normal (cd, fields->f_GRk, 0, 0, 30, 6, 32, total_length, buffer);
00694       break;
00695     case FRV_OPERAND_GRKLO :
00696       errmsg = insert_normal (cd, fields->f_GRk, 0, 0, 30, 6, 32, total_length, buffer);
00697       break;
00698     case FRV_OPERAND_ICCI_1 :
00699       errmsg = insert_normal (cd, fields->f_ICCi_1, 0, 0, 11, 2, 32, total_length, buffer);
00700       break;
00701     case FRV_OPERAND_ICCI_2 :
00702       errmsg = insert_normal (cd, fields->f_ICCi_2, 0, 0, 26, 2, 32, total_length, buffer);
00703       break;
00704     case FRV_OPERAND_ICCI_3 :
00705       errmsg = insert_normal (cd, fields->f_ICCi_3, 0, 0, 1, 2, 32, total_length, buffer);
00706       break;
00707     case FRV_OPERAND_LI :
00708       errmsg = insert_normal (cd, fields->f_LI, 0, 0, 25, 1, 32, total_length, buffer);
00709       break;
00710     case FRV_OPERAND_LRAD :
00711       errmsg = insert_normal (cd, fields->f_LRAD, 0, 0, 4, 1, 32, total_length, buffer);
00712       break;
00713     case FRV_OPERAND_LRAE :
00714       errmsg = insert_normal (cd, fields->f_LRAE, 0, 0, 5, 1, 32, total_length, buffer);
00715       break;
00716     case FRV_OPERAND_LRAS :
00717       errmsg = insert_normal (cd, fields->f_LRAS, 0, 0, 3, 1, 32, total_length, buffer);
00718       break;
00719     case FRV_OPERAND_TLBPRL :
00720       errmsg = insert_normal (cd, fields->f_TLBPRL, 0, 0, 25, 1, 32, total_length, buffer);
00721       break;
00722     case FRV_OPERAND_TLBPROPX :
00723       errmsg = insert_normal (cd, fields->f_TLBPRopx, 0, 0, 28, 3, 32, total_length, buffer);
00724       break;
00725     case FRV_OPERAND_AE :
00726       errmsg = insert_normal (cd, fields->f_ae, 0, 0, 25, 1, 32, total_length, buffer);
00727       break;
00728     case FRV_OPERAND_CALLANN :
00729       errmsg = insert_normal (cd, fields->f_reloc_ann, 0, 0, 0, 0, 32, total_length, buffer);
00730       break;
00731     case FRV_OPERAND_CCOND :
00732       errmsg = insert_normal (cd, fields->f_ccond, 0, 0, 12, 1, 32, total_length, buffer);
00733       break;
00734     case FRV_OPERAND_COND :
00735       errmsg = insert_normal (cd, fields->f_cond, 0, 0, 8, 1, 32, total_length, buffer);
00736       break;
00737     case FRV_OPERAND_D12 :
00738       errmsg = insert_normal (cd, fields->f_d12, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 12, 32, total_length, buffer);
00739       break;
00740     case FRV_OPERAND_DEBUG :
00741       errmsg = insert_normal (cd, fields->f_debug, 0, 0, 25, 1, 32, total_length, buffer);
00742       break;
00743     case FRV_OPERAND_EIR :
00744       errmsg = insert_normal (cd, fields->f_eir, 0, 0, 17, 6, 32, total_length, buffer);
00745       break;
00746     case FRV_OPERAND_HINT :
00747       errmsg = insert_normal (cd, fields->f_hint, 0, 0, 17, 2, 32, total_length, buffer);
00748       break;
00749     case FRV_OPERAND_HINT_NOT_TAKEN :
00750       errmsg = insert_normal (cd, fields->f_hint, 0, 0, 17, 2, 32, total_length, buffer);
00751       break;
00752     case FRV_OPERAND_HINT_TAKEN :
00753       errmsg = insert_normal (cd, fields->f_hint, 0, 0, 17, 2, 32, total_length, buffer);
00754       break;
00755     case FRV_OPERAND_LABEL16 :
00756       {
00757         long value = fields->f_label16;
00758         value = ((int) (((value) - (pc))) >> (2));
00759         errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 15, 16, 32, total_length, buffer);
00760       }
00761       break;
00762     case FRV_OPERAND_LABEL24 :
00763       {
00764 {
00765   FLD (f_labelH6) = ((int) (((FLD (f_label24)) - (pc))) >> (20));
00766   FLD (f_labelL18) = ((((unsigned int) (((FLD (f_label24)) - (pc))) >> (2))) & (262143));
00767 }
00768         errmsg = insert_normal (cd, fields->f_labelH6, 0|(1<<CGEN_IFLD_SIGNED), 0, 30, 6, 32, total_length, buffer);
00769         if (errmsg)
00770           break;
00771         errmsg = insert_normal (cd, fields->f_labelL18, 0, 0, 17, 18, 32, total_length, buffer);
00772         if (errmsg)
00773           break;
00774       }
00775       break;
00776     case FRV_OPERAND_LDANN :
00777       errmsg = insert_normal (cd, fields->f_reloc_ann, 0, 0, 0, 0, 32, total_length, buffer);
00778       break;
00779     case FRV_OPERAND_LDDANN :
00780       errmsg = insert_normal (cd, fields->f_reloc_ann, 0, 0, 0, 0, 32, total_length, buffer);
00781       break;
00782     case FRV_OPERAND_LOCK :
00783       errmsg = insert_normal (cd, fields->f_lock, 0, 0, 25, 1, 32, total_length, buffer);
00784       break;
00785     case FRV_OPERAND_PACK :
00786       errmsg = insert_normal (cd, fields->f_pack, 0, 0, 31, 1, 32, total_length, buffer);
00787       break;
00788     case FRV_OPERAND_S10 :
00789       errmsg = insert_normal (cd, fields->f_s10, 0|(1<<CGEN_IFLD_SIGNED), 0, 9, 10, 32, total_length, buffer);
00790       break;
00791     case FRV_OPERAND_S12 :
00792       errmsg = insert_normal (cd, fields->f_d12, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 12, 32, total_length, buffer);
00793       break;
00794     case FRV_OPERAND_S16 :
00795       errmsg = insert_normal (cd, fields->f_s16, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, buffer);
00796       break;
00797     case FRV_OPERAND_S5 :
00798       errmsg = insert_normal (cd, fields->f_s5, 0|(1<<CGEN_IFLD_SIGNED), 0, 4, 5, 32, total_length, buffer);
00799       break;
00800     case FRV_OPERAND_S6 :
00801       errmsg = insert_normal (cd, fields->f_s6, 0|(1<<CGEN_IFLD_SIGNED), 0, 5, 6, 32, total_length, buffer);
00802       break;
00803     case FRV_OPERAND_S6_1 :
00804       errmsg = insert_normal (cd, fields->f_s6_1, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 6, 32, total_length, buffer);
00805       break;
00806     case FRV_OPERAND_SLO16 :
00807       errmsg = insert_normal (cd, fields->f_s16, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, buffer);
00808       break;
00809     case FRV_OPERAND_SPR :
00810       {
00811 {
00812   FLD (f_spr_h) = ((unsigned int) (FLD (f_spr)) >> (6));
00813   FLD (f_spr_l) = ((FLD (f_spr)) & (63));
00814 }
00815         errmsg = insert_normal (cd, fields->f_spr_h, 0, 0, 30, 6, 32, total_length, buffer);
00816         if (errmsg)
00817           break;
00818         errmsg = insert_normal (cd, fields->f_spr_l, 0, 0, 17, 6, 32, total_length, buffer);
00819         if (errmsg)
00820           break;
00821       }
00822       break;
00823     case FRV_OPERAND_U12 :
00824       {
00825 {
00826   FLD (f_u12_h) = ((int) (FLD (f_u12)) >> (6));
00827   FLD (f_u12_l) = ((FLD (f_u12)) & (63));
00828 }
00829         errmsg = insert_normal (cd, fields->f_u12_h, 0|(1<<CGEN_IFLD_SIGNED), 0, 17, 6, 32, total_length, buffer);
00830         if (errmsg)
00831           break;
00832         errmsg = insert_normal (cd, fields->f_u12_l, 0, 0, 5, 6, 32, total_length, buffer);
00833         if (errmsg)
00834           break;
00835       }
00836       break;
00837     case FRV_OPERAND_U16 :
00838       errmsg = insert_normal (cd, fields->f_u16, 0, 0, 15, 16, 32, total_length, buffer);
00839       break;
00840     case FRV_OPERAND_U6 :
00841       errmsg = insert_normal (cd, fields->f_u6, 0, 0, 5, 6, 32, total_length, buffer);
00842       break;
00843     case FRV_OPERAND_UHI16 :
00844       errmsg = insert_normal (cd, fields->f_u16, 0, 0, 15, 16, 32, total_length, buffer);
00845       break;
00846     case FRV_OPERAND_ULO16 :
00847       errmsg = insert_normal (cd, fields->f_u16, 0, 0, 15, 16, 32, total_length, buffer);
00848       break;
00849 
00850     default :
00851       /* xgettext:c-format */
00852       fprintf (stderr, _("Unrecognized field %d while building insn.\n"),
00853               opindex);
00854       abort ();
00855   }
00856 
00857   return errmsg;
00858 }
00859 
00860 int frv_cgen_extract_operand
00861   (CGEN_CPU_DESC, int, CGEN_EXTRACT_INFO *, CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma);
00862 
00863 /* Main entry point for operand extraction.
00864    The result is <= 0 for error, >0 for success.
00865    ??? Actual values aren't well defined right now.
00866 
00867    This function is basically just a big switch statement.  Earlier versions
00868    used tables to look up the function to use, but
00869    - if the table contains both assembler and disassembler functions then
00870      the disassembler contains much of the assembler and vice-versa,
00871    - there's a lot of inlining possibilities as things grow,
00872    - using a switch statement avoids the function call overhead.
00873 
00874    This function could be moved into `print_insn_normal', but keeping it
00875    separate makes clear the interface between `print_insn_normal' and each of
00876    the handlers.  */
00877 
00878 int
00879 frv_cgen_extract_operand (CGEN_CPU_DESC cd,
00880                           int opindex,
00881                           CGEN_EXTRACT_INFO *ex_info,
00882                           CGEN_INSN_INT insn_value,
00883                           CGEN_FIELDS * fields,
00884                           bfd_vma pc)
00885 {
00886   /* Assume success (for those operands that are nops).  */
00887   int length = 1;
00888   unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
00889 
00890   switch (opindex)
00891     {
00892     case FRV_OPERAND_A0 :
00893       length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 1, 32, total_length, pc, & fields->f_A);
00894       break;
00895     case FRV_OPERAND_A1 :
00896       length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 1, 32, total_length, pc, & fields->f_A);
00897       break;
00898     case FRV_OPERAND_ACC40SI :
00899       length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_ACC40Si);
00900       break;
00901     case FRV_OPERAND_ACC40SK :
00902       length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_ACC40Sk);
00903       break;
00904     case FRV_OPERAND_ACC40UI :
00905       length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_ACC40Ui);
00906       break;
00907     case FRV_OPERAND_ACC40UK :
00908       length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_ACC40Uk);
00909       break;
00910     case FRV_OPERAND_ACCGI :
00911       length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_ACCGi);
00912       break;
00913     case FRV_OPERAND_ACCGK :
00914       length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_ACCGk);
00915       break;
00916     case FRV_OPERAND_CCI :
00917       length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 3, 32, total_length, pc, & fields->f_CCi);
00918       break;
00919     case FRV_OPERAND_CPRDOUBLEK :
00920       length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_CPRk);
00921       break;
00922     case FRV_OPERAND_CPRI :
00923       length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_CPRi);
00924       break;
00925     case FRV_OPERAND_CPRJ :
00926       length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_CPRj);
00927       break;
00928     case FRV_OPERAND_CPRK :
00929       length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_CPRk);
00930       break;
00931     case FRV_OPERAND_CRI :
00932       length = extract_normal (cd, ex_info, insn_value, 0, 0, 14, 3, 32, total_length, pc, & fields->f_CRi);
00933       break;
00934     case FRV_OPERAND_CRJ :
00935       length = extract_normal (cd, ex_info, insn_value, 0, 0, 2, 3, 32, total_length, pc, & fields->f_CRj);
00936       break;
00937     case FRV_OPERAND_CRJ_FLOAT :
00938       length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & fields->f_CRj_float);
00939       break;
00940     case FRV_OPERAND_CRJ_INT :
00941       {
00942         long value;
00943         length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & value);
00944         value = ((value) + (4));
00945         fields->f_CRj_int = value;
00946       }
00947       break;
00948     case FRV_OPERAND_CRK :
00949       length = extract_normal (cd, ex_info, insn_value, 0, 0, 27, 3, 32, total_length, pc, & fields->f_CRk);
00950       break;
00951     case FRV_OPERAND_FCCI_1 :
00952       length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 2, 32, total_length, pc, & fields->f_FCCi_1);
00953       break;
00954     case FRV_OPERAND_FCCI_2 :
00955       length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & fields->f_FCCi_2);
00956       break;
00957     case FRV_OPERAND_FCCI_3 :
00958       length = extract_normal (cd, ex_info, insn_value, 0, 0, 1, 2, 32, total_length, pc, & fields->f_FCCi_3);
00959       break;
00960     case FRV_OPERAND_FCCK :
00961       length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & fields->f_FCCk);
00962       break;
00963     case FRV_OPERAND_FRDOUBLEI :
00964       length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_FRi);
00965       break;
00966     case FRV_OPERAND_FRDOUBLEJ :
00967       length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_FRj);
00968       break;
00969     case FRV_OPERAND_FRDOUBLEK :
00970       length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk);
00971       break;
00972     case FRV_OPERAND_FRI :
00973       length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_FRi);
00974       break;
00975     case FRV_OPERAND_FRINTI :
00976       length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_FRi);
00977       break;
00978     case FRV_OPERAND_FRINTIEVEN :
00979       length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_FRi);
00980       break;
00981     case FRV_OPERAND_FRINTJ :
00982       length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_FRj);
00983       break;
00984     case FRV_OPERAND_FRINTJEVEN :
00985       length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_FRj);
00986       break;
00987     case FRV_OPERAND_FRINTK :
00988       length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk);
00989       break;
00990     case FRV_OPERAND_FRINTKEVEN :
00991       length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk);
00992       break;
00993     case FRV_OPERAND_FRJ :
00994       length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_FRj);
00995       break;
00996     case FRV_OPERAND_FRK :
00997       length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk);
00998       break;
00999     case FRV_OPERAND_FRKHI :
01000       length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk);
01001       break;
01002     case FRV_OPERAND_FRKLO :
01003       length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk);
01004       break;
01005     case FRV_OPERAND_GRDOUBLEK :
01006       length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_GRk);
01007       break;
01008     case FRV_OPERAND_GRI :
01009       length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_GRi);
01010       break;
01011     case FRV_OPERAND_GRJ :
01012       length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_GRj);
01013       break;
01014     case FRV_OPERAND_GRK :
01015       length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_GRk);
01016       break;
01017     case FRV_OPERAND_GRKHI :
01018       length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_GRk);
01019       break;
01020     case FRV_OPERAND_GRKLO :
01021       length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_GRk);
01022       break;
01023     case FRV_OPERAND_ICCI_1 :
01024       length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 2, 32, total_length, pc, & fields->f_ICCi_1);
01025       break;
01026     case FRV_OPERAND_ICCI_2 :
01027       length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & fields->f_ICCi_2);
01028       break;
01029     case FRV_OPERAND_ICCI_3 :
01030       length = extract_normal (cd, ex_info, insn_value, 0, 0, 1, 2, 32, total_length, pc, & fields->f_ICCi_3);
01031       break;
01032     case FRV_OPERAND_LI :
01033       length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_LI);
01034       break;
01035     case FRV_OPERAND_LRAD :
01036       length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 1, 32, total_length, pc, & fields->f_LRAD);
01037       break;
01038     case FRV_OPERAND_LRAE :
01039       length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 1, 32, total_length, pc, & fields->f_LRAE);
01040       break;
01041     case FRV_OPERAND_LRAS :
01042       length = extract_normal (cd, ex_info, insn_value, 0, 0, 3, 1, 32, total_length, pc, & fields->f_LRAS);
01043       break;
01044     case FRV_OPERAND_TLBPRL :
01045       length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_TLBPRL);
01046       break;
01047     case FRV_OPERAND_TLBPROPX :
01048       length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 3, 32, total_length, pc, & fields->f_TLBPRopx);
01049       break;
01050     case FRV_OPERAND_AE :
01051       length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_ae);
01052       break;
01053     case FRV_OPERAND_CALLANN :
01054       length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 0, 32, total_length, pc, & fields->f_reloc_ann);
01055       break;
01056     case FRV_OPERAND_CCOND :
01057       length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 1, 32, total_length, pc, & fields->f_ccond);
01058       break;
01059     case FRV_OPERAND_COND :
01060       length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 1, 32, total_length, pc, & fields->f_cond);
01061       break;
01062     case FRV_OPERAND_D12 :
01063       length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 12, 32, total_length, pc, & fields->f_d12);
01064       break;
01065     case FRV_OPERAND_DEBUG :
01066       length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_debug);
01067       break;
01068     case FRV_OPERAND_EIR :
01069       length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_eir);
01070       break;
01071     case FRV_OPERAND_HINT :
01072       length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 2, 32, total_length, pc, & fields->f_hint);
01073       break;
01074     case FRV_OPERAND_HINT_NOT_TAKEN :
01075       length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 2, 32, total_length, pc, & fields->f_hint);
01076       break;
01077     case FRV_OPERAND_HINT_TAKEN :
01078       length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 2, 32, total_length, pc, & fields->f_hint);
01079       break;
01080     case FRV_OPERAND_LABEL16 :
01081       {
01082         long value;
01083         length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 15, 16, 32, total_length, pc, & value);
01084         value = ((((value) << (2))) + (pc));
01085         fields->f_label16 = value;
01086       }
01087       break;
01088     case FRV_OPERAND_LABEL24 :
01089       {
01090         length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 30, 6, 32, total_length, pc, & fields->f_labelH6);
01091         if (length <= 0) break;
01092         length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 18, 32, total_length, pc, & fields->f_labelL18);
01093         if (length <= 0) break;
01094 {
01095   FLD (f_label24) = ((((((((FLD (f_labelH6)) << (18))) | (FLD (f_labelL18)))) << (2))) + (pc));
01096 }
01097       }
01098       break;
01099     case FRV_OPERAND_LDANN :
01100       length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 0, 32, total_length, pc, & fields->f_reloc_ann);
01101       break;
01102     case FRV_OPERAND_LDDANN :
01103       length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 0, 32, total_length, pc, & fields->f_reloc_ann);
01104       break;
01105     case FRV_OPERAND_LOCK :
01106       length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_lock);
01107       break;
01108     case FRV_OPERAND_PACK :
01109       length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 1, 32, total_length, pc, & fields->f_pack);
01110       break;
01111     case FRV_OPERAND_S10 :
01112       length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 9, 10, 32, total_length, pc, & fields->f_s10);
01113       break;
01114     case FRV_OPERAND_S12 :
01115       length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 12, 32, total_length, pc, & fields->f_d12);
01116       break;
01117     case FRV_OPERAND_S16 :
01118       length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, pc, & fields->f_s16);
01119       break;
01120     case FRV_OPERAND_S5 :
01121       length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 4, 5, 32, total_length, pc, & fields->f_s5);
01122       break;
01123     case FRV_OPERAND_S6 :
01124       length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 5, 6, 32, total_length, pc, & fields->f_s6);
01125       break;
01126     case FRV_OPERAND_S6_1 :
01127       length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 6, 32, total_length, pc, & fields->f_s6_1);
01128       break;
01129     case FRV_OPERAND_SLO16 :
01130       length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, pc, & fields->f_s16);
01131       break;
01132     case FRV_OPERAND_SPR :
01133       {
01134         length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_spr_h);
01135         if (length <= 0) break;
01136         length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_spr_l);
01137         if (length <= 0) break;
01138 {
01139   FLD (f_spr) = ((((FLD (f_spr_h)) << (6))) | (FLD (f_spr_l)));
01140 }
01141       }
01142       break;
01143     case FRV_OPERAND_U12 :
01144       {
01145         length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 17, 6, 32, total_length, pc, & fields->f_u12_h);
01146         if (length <= 0) break;
01147         length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_u12_l);
01148         if (length <= 0) break;
01149 {
01150   FLD (f_u12) = ((((FLD (f_u12_h)) << (6))) | (FLD (f_u12_l)));
01151 }
01152       }
01153       break;
01154     case FRV_OPERAND_U16 :
01155       length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_u16);
01156       break;
01157     case FRV_OPERAND_U6 :
01158       length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_u6);
01159       break;
01160     case FRV_OPERAND_UHI16 :
01161       length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_u16);
01162       break;
01163     case FRV_OPERAND_ULO16 :
01164       length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_u16);
01165       break;
01166 
01167     default :
01168       /* xgettext:c-format */
01169       fprintf (stderr, _("Unrecognized field %d while decoding insn.\n"),
01170               opindex);
01171       abort ();
01172     }
01173 
01174   return length;
01175 }
01176 
01177 cgen_insert_fn * const frv_cgen_insert_handlers[] = 
01178 {
01179   insert_insn_normal,
01180 };
01181 
01182 cgen_extract_fn * const frv_cgen_extract_handlers[] = 
01183 {
01184   extract_insn_normal,
01185 };
01186 
01187 int frv_cgen_get_int_operand     (CGEN_CPU_DESC, int, const CGEN_FIELDS *);
01188 bfd_vma frv_cgen_get_vma_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *);
01189 
01190 /* Getting values from cgen_fields is handled by a collection of functions.
01191    They are distinguished by the type of the VALUE argument they return.
01192    TODO: floating point, inlining support, remove cases where result type
01193    not appropriate.  */
01194 
01195 int
01196 frv_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
01197                           int opindex,
01198                           const CGEN_FIELDS * fields)
01199 {
01200   int value;
01201 
01202   switch (opindex)
01203     {
01204     case FRV_OPERAND_A0 :
01205       value = fields->f_A;
01206       break;
01207     case FRV_OPERAND_A1 :
01208       value = fields->f_A;
01209       break;
01210     case FRV_OPERAND_ACC40SI :
01211       value = fields->f_ACC40Si;
01212       break;
01213     case FRV_OPERAND_ACC40SK :
01214       value = fields->f_ACC40Sk;
01215       break;
01216     case FRV_OPERAND_ACC40UI :
01217       value = fields->f_ACC40Ui;
01218       break;
01219     case FRV_OPERAND_ACC40UK :
01220       value = fields->f_ACC40Uk;
01221       break;
01222     case FRV_OPERAND_ACCGI :
01223       value = fields->f_ACCGi;
01224       break;
01225     case FRV_OPERAND_ACCGK :
01226       value = fields->f_ACCGk;
01227       break;
01228     case FRV_OPERAND_CCI :
01229       value = fields->f_CCi;
01230       break;
01231     case FRV_OPERAND_CPRDOUBLEK :
01232       value = fields->f_CPRk;
01233       break;
01234     case FRV_OPERAND_CPRI :
01235       value = fields->f_CPRi;
01236       break;
01237     case FRV_OPERAND_CPRJ :
01238       value = fields->f_CPRj;
01239       break;
01240     case FRV_OPERAND_CPRK :
01241       value = fields->f_CPRk;
01242       break;
01243     case FRV_OPERAND_CRI :
01244       value = fields->f_CRi;
01245       break;
01246     case FRV_OPERAND_CRJ :
01247       value = fields->f_CRj;
01248       break;
01249     case FRV_OPERAND_CRJ_FLOAT :
01250       value = fields->f_CRj_float;
01251       break;
01252     case FRV_OPERAND_CRJ_INT :
01253       value = fields->f_CRj_int;
01254       break;
01255     case FRV_OPERAND_CRK :
01256       value = fields->f_CRk;
01257       break;
01258     case FRV_OPERAND_FCCI_1 :
01259       value = fields->f_FCCi_1;
01260       break;
01261     case FRV_OPERAND_FCCI_2 :
01262       value = fields->f_FCCi_2;
01263       break;
01264     case FRV_OPERAND_FCCI_3 :
01265       value = fields->f_FCCi_3;
01266       break;
01267     case FRV_OPERAND_FCCK :
01268       value = fields->f_FCCk;
01269       break;
01270     case FRV_OPERAND_FRDOUBLEI :
01271       value = fields->f_FRi;
01272       break;
01273     case FRV_OPERAND_FRDOUBLEJ :
01274       value = fields->f_FRj;
01275       break;
01276     case FRV_OPERAND_FRDOUBLEK :
01277       value = fields->f_FRk;
01278       break;
01279     case FRV_OPERAND_FRI :
01280       value = fields->f_FRi;
01281       break;
01282     case FRV_OPERAND_FRINTI :
01283       value = fields->f_FRi;
01284       break;
01285     case FRV_OPERAND_FRINTIEVEN :
01286       value = fields->f_FRi;
01287       break;
01288     case FRV_OPERAND_FRINTJ :
01289       value = fields->f_FRj;
01290       break;
01291     case FRV_OPERAND_FRINTJEVEN :
01292       value = fields->f_FRj;
01293       break;
01294     case FRV_OPERAND_FRINTK :
01295       value = fields->f_FRk;
01296       break;
01297     case FRV_OPERAND_FRINTKEVEN :
01298       value = fields->f_FRk;
01299       break;
01300     case FRV_OPERAND_FRJ :
01301       value = fields->f_FRj;
01302       break;
01303     case FRV_OPERAND_FRK :
01304       value = fields->f_FRk;
01305       break;
01306     case FRV_OPERAND_FRKHI :
01307       value = fields->f_FRk;
01308       break;
01309     case FRV_OPERAND_FRKLO :
01310       value = fields->f_FRk;
01311       break;
01312     case FRV_OPERAND_GRDOUBLEK :
01313       value = fields->f_GRk;
01314       break;
01315     case FRV_OPERAND_GRI :
01316       value = fields->f_GRi;
01317       break;
01318     case FRV_OPERAND_GRJ :
01319       value = fields->f_GRj;
01320       break;
01321     case FRV_OPERAND_GRK :
01322       value = fields->f_GRk;
01323       break;
01324     case FRV_OPERAND_GRKHI :
01325       value = fields->f_GRk;
01326       break;
01327     case FRV_OPERAND_GRKLO :
01328       value = fields->f_GRk;
01329       break;
01330     case FRV_OPERAND_ICCI_1 :
01331       value = fields->f_ICCi_1;
01332       break;
01333     case FRV_OPERAND_ICCI_2 :
01334       value = fields->f_ICCi_2;
01335       break;
01336     case FRV_OPERAND_ICCI_3 :
01337       value = fields->f_ICCi_3;
01338       break;
01339     case FRV_OPERAND_LI :
01340       value = fields->f_LI;
01341       break;
01342     case FRV_OPERAND_LRAD :
01343       value = fields->f_LRAD;
01344       break;
01345     case FRV_OPERAND_LRAE :
01346       value = fields->f_LRAE;
01347       break;
01348     case FRV_OPERAND_LRAS :
01349       value = fields->f_LRAS;
01350       break;
01351     case FRV_OPERAND_TLBPRL :
01352       value = fields->f_TLBPRL;
01353       break;
01354     case FRV_OPERAND_TLBPROPX :
01355       value = fields->f_TLBPRopx;
01356       break;
01357     case FRV_OPERAND_AE :
01358       value = fields->f_ae;
01359       break;
01360     case FRV_OPERAND_CALLANN :
01361       value = fields->f_reloc_ann;
01362       break;
01363     case FRV_OPERAND_CCOND :
01364       value = fields->f_ccond;
01365       break;
01366     case FRV_OPERAND_COND :
01367       value = fields->f_cond;
01368       break;
01369     case FRV_OPERAND_D12 :
01370       value = fields->f_d12;
01371       break;
01372     case FRV_OPERAND_DEBUG :
01373       value = fields->f_debug;
01374       break;
01375     case FRV_OPERAND_EIR :
01376       value = fields->f_eir;
01377       break;
01378     case FRV_OPERAND_HINT :
01379       value = fields->f_hint;
01380       break;
01381     case FRV_OPERAND_HINT_NOT_TAKEN :
01382       value = fields->f_hint;
01383       break;
01384     case FRV_OPERAND_HINT_TAKEN :
01385       value = fields->f_hint;
01386       break;
01387     case FRV_OPERAND_LABEL16 :
01388       value = fields->f_label16;
01389       break;
01390     case FRV_OPERAND_LABEL24 :
01391       value = fields->f_label24;
01392       break;
01393     case FRV_OPERAND_LDANN :
01394       value = fields->f_reloc_ann;
01395       break;
01396     case FRV_OPERAND_LDDANN :
01397       value = fields->f_reloc_ann;
01398       break;
01399     case FRV_OPERAND_LOCK :
01400       value = fields->f_lock;
01401       break;
01402     case FRV_OPERAND_PACK :
01403       value = fields->f_pack;
01404       break;
01405     case FRV_OPERAND_S10 :
01406       value = fields->f_s10;
01407       break;
01408     case FRV_OPERAND_S12 :
01409       value = fields->f_d12;
01410       break;
01411     case FRV_OPERAND_S16 :
01412       value = fields->f_s16;
01413       break;
01414     case FRV_OPERAND_S5 :
01415       value = fields->f_s5;
01416       break;
01417     case FRV_OPERAND_S6 :
01418       value = fields->f_s6;
01419       break;
01420     case FRV_OPERAND_S6_1 :
01421       value = fields->f_s6_1;
01422       break;
01423     case FRV_OPERAND_SLO16 :
01424       value = fields->f_s16;
01425       break;
01426     case FRV_OPERAND_SPR :
01427       value = fields->f_spr;
01428       break;
01429     case FRV_OPERAND_U12 :
01430       value = fields->f_u12;
01431       break;
01432     case FRV_OPERAND_U16 :
01433       value = fields->f_u16;
01434       break;
01435     case FRV_OPERAND_U6 :
01436       value = fields->f_u6;
01437       break;
01438     case FRV_OPERAND_UHI16 :
01439       value = fields->f_u16;
01440       break;
01441     case FRV_OPERAND_ULO16 :
01442       value = fields->f_u16;
01443       break;
01444 
01445     default :
01446       /* xgettext:c-format */
01447       fprintf (stderr, _("Unrecognized field %d while getting int operand.\n"),
01448                      opindex);
01449       abort ();
01450   }
01451 
01452   return value;
01453 }
01454 
01455 bfd_vma
01456 frv_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
01457                           int opindex,
01458                           const CGEN_FIELDS * fields)
01459 {
01460   bfd_vma value;
01461 
01462   switch (opindex)
01463     {
01464     case FRV_OPERAND_A0 :
01465       value = fields->f_A;
01466       break;
01467     case FRV_OPERAND_A1 :
01468       value = fields->f_A;
01469       break;
01470     case FRV_OPERAND_ACC40SI :
01471       value = fields->f_ACC40Si;
01472       break;
01473     case FRV_OPERAND_ACC40SK :
01474       value = fields->f_ACC40Sk;
01475       break;
01476     case FRV_OPERAND_ACC40UI :
01477       value = fields->f_ACC40Ui;
01478       break;
01479     case FRV_OPERAND_ACC40UK :
01480       value = fields->f_ACC40Uk;
01481       break;
01482     case FRV_OPERAND_ACCGI :
01483       value = fields->f_ACCGi;
01484       break;
01485     case FRV_OPERAND_ACCGK :
01486       value = fields->f_ACCGk;
01487       break;
01488     case FRV_OPERAND_CCI :
01489       value = fields->f_CCi;
01490       break;
01491     case FRV_OPERAND_CPRDOUBLEK :
01492       value = fields->f_CPRk;
01493       break;
01494     case FRV_OPERAND_CPRI :
01495       value = fields->f_CPRi;
01496       break;
01497     case FRV_OPERAND_CPRJ :
01498       value = fields->f_CPRj;
01499       break;
01500     case FRV_OPERAND_CPRK :
01501       value = fields->f_CPRk;
01502       break;
01503     case FRV_OPERAND_CRI :
01504       value = fields->f_CRi;
01505       break;
01506     case FRV_OPERAND_CRJ :
01507       value = fields->f_CRj;
01508       break;
01509     case FRV_OPERAND_CRJ_FLOAT :
01510       value = fields->f_CRj_float;
01511       break;
01512     case FRV_OPERAND_CRJ_INT :
01513       value = fields->f_CRj_int;
01514       break;
01515     case FRV_OPERAND_CRK :
01516       value = fields->f_CRk;
01517       break;
01518     case FRV_OPERAND_FCCI_1 :
01519       value = fields->f_FCCi_1;
01520       break;
01521     case FRV_OPERAND_FCCI_2 :
01522       value = fields->f_FCCi_2;
01523       break;
01524     case FRV_OPERAND_FCCI_3 :
01525       value = fields->f_FCCi_3;
01526       break;
01527     case FRV_OPERAND_FCCK :
01528       value = fields->f_FCCk;
01529       break;
01530     case FRV_OPERAND_FRDOUBLEI :
01531       value = fields->f_FRi;
01532       break;
01533     case FRV_OPERAND_FRDOUBLEJ :
01534       value = fields->f_FRj;
01535       break;
01536     case FRV_OPERAND_FRDOUBLEK :
01537       value = fields->f_FRk;
01538       break;
01539     case FRV_OPERAND_FRI :
01540       value = fields->f_FRi;
01541       break;
01542     case FRV_OPERAND_FRINTI :
01543       value = fields->f_FRi;
01544       break;
01545     case FRV_OPERAND_FRINTIEVEN :
01546       value = fields->f_FRi;
01547       break;
01548     case FRV_OPERAND_FRINTJ :
01549       value = fields->f_FRj;
01550       break;
01551     case FRV_OPERAND_FRINTJEVEN :
01552       value = fields->f_FRj;
01553       break;
01554     case FRV_OPERAND_FRINTK :
01555       value = fields->f_FRk;
01556       break;
01557     case FRV_OPERAND_FRINTKEVEN :
01558       value = fields->f_FRk;
01559       break;
01560     case FRV_OPERAND_FRJ :
01561       value = fields->f_FRj;
01562       break;
01563     case FRV_OPERAND_FRK :
01564       value = fields->f_FRk;
01565       break;
01566     case FRV_OPERAND_FRKHI :
01567       value = fields->f_FRk;
01568       break;
01569     case FRV_OPERAND_FRKLO :
01570       value = fields->f_FRk;
01571       break;
01572     case FRV_OPERAND_GRDOUBLEK :
01573       value = fields->f_GRk;
01574       break;
01575     case FRV_OPERAND_GRI :
01576       value = fields->f_GRi;
01577       break;
01578     case FRV_OPERAND_GRJ :
01579       value = fields->f_GRj;
01580       break;
01581     case FRV_OPERAND_GRK :
01582       value = fields->f_GRk;
01583       break;
01584     case FRV_OPERAND_GRKHI :
01585       value = fields->f_GRk;
01586       break;
01587     case FRV_OPERAND_GRKLO :
01588       value = fields->f_GRk;
01589       break;
01590     case FRV_OPERAND_ICCI_1 :
01591       value = fields->f_ICCi_1;
01592       break;
01593     case FRV_OPERAND_ICCI_2 :
01594       value = fields->f_ICCi_2;
01595       break;
01596     case FRV_OPERAND_ICCI_3 :
01597       value = fields->f_ICCi_3;
01598       break;
01599     case FRV_OPERAND_LI :
01600       value = fields->f_LI;
01601       break;
01602     case FRV_OPERAND_LRAD :
01603       value = fields->f_LRAD;
01604       break;
01605     case FRV_OPERAND_LRAE :
01606       value = fields->f_LRAE;
01607       break;
01608     case FRV_OPERAND_LRAS :
01609       value = fields->f_LRAS;
01610       break;
01611     case FRV_OPERAND_TLBPRL :
01612       value = fields->f_TLBPRL;
01613       break;
01614     case FRV_OPERAND_TLBPROPX :
01615       value = fields->f_TLBPRopx;
01616       break;
01617     case FRV_OPERAND_AE :
01618       value = fields->f_ae;
01619       break;
01620     case FRV_OPERAND_CALLANN :
01621       value = fields->f_reloc_ann;
01622       break;
01623     case FRV_OPERAND_CCOND :
01624       value = fields->f_ccond;
01625       break;
01626     case FRV_OPERAND_COND :
01627       value = fields->f_cond;
01628       break;
01629     case FRV_OPERAND_D12 :
01630       value = fields->f_d12;
01631       break;
01632     case FRV_OPERAND_DEBUG :
01633       value = fields->f_debug;
01634       break;
01635     case FRV_OPERAND_EIR :
01636       value = fields->f_eir;
01637       break;
01638     case FRV_OPERAND_HINT :
01639       value = fields->f_hint;
01640       break;
01641     case FRV_OPERAND_HINT_NOT_TAKEN :
01642       value = fields->f_hint;
01643       break;
01644     case FRV_OPERAND_HINT_TAKEN :
01645       value = fields->f_hint;
01646       break;
01647     case FRV_OPERAND_LABEL16 :
01648       value = fields->f_label16;
01649       break;
01650     case FRV_OPERAND_LABEL24 :
01651       value = fields->f_label24;
01652       break;
01653     case FRV_OPERAND_LDANN :
01654       value = fields->f_reloc_ann;
01655       break;
01656     case FRV_OPERAND_LDDANN :
01657       value = fields->f_reloc_ann;
01658       break;
01659     case FRV_OPERAND_LOCK :
01660       value = fields->f_lock;
01661       break;
01662     case FRV_OPERAND_PACK :
01663       value = fields->f_pack;
01664       break;
01665     case FRV_OPERAND_S10 :
01666       value = fields->f_s10;
01667       break;
01668     case FRV_OPERAND_S12 :
01669       value = fields->f_d12;
01670       break;
01671     case FRV_OPERAND_S16 :
01672       value = fields->f_s16;
01673       break;
01674     case FRV_OPERAND_S5 :
01675       value = fields->f_s5;
01676       break;
01677     case FRV_OPERAND_S6 :
01678       value = fields->f_s6;
01679       break;
01680     case FRV_OPERAND_S6_1 :
01681       value = fields->f_s6_1;
01682       break;
01683     case FRV_OPERAND_SLO16 :
01684       value = fields->f_s16;
01685       break;
01686     case FRV_OPERAND_SPR :
01687       value = fields->f_spr;
01688       break;
01689     case FRV_OPERAND_U12 :
01690       value = fields->f_u12;
01691       break;
01692     case FRV_OPERAND_U16 :
01693       value = fields->f_u16;
01694       break;
01695     case FRV_OPERAND_U6 :
01696       value = fields->f_u6;
01697       break;
01698     case FRV_OPERAND_UHI16 :
01699       value = fields->f_u16;
01700       break;
01701     case FRV_OPERAND_ULO16 :
01702       value = fields->f_u16;
01703       break;
01704 
01705     default :
01706       /* xgettext:c-format */
01707       fprintf (stderr, _("Unrecognized field %d while getting vma operand.\n"),
01708                      opindex);
01709       abort ();
01710   }
01711 
01712   return value;
01713 }
01714 
01715 void frv_cgen_set_int_operand  (CGEN_CPU_DESC, int, CGEN_FIELDS *, int);
01716 void frv_cgen_set_vma_operand  (CGEN_CPU_DESC, int, CGEN_FIELDS *, bfd_vma);
01717 
01718 /* Stuffing values in cgen_fields is handled by a collection of functions.
01719    They are distinguished by the type of the VALUE argument they accept.
01720    TODO: floating point, inlining support, remove cases where argument type
01721    not appropriate.  */
01722 
01723 void
01724 frv_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
01725                           int opindex,
01726                           CGEN_FIELDS * fields,
01727                           int value)
01728 {
01729   switch (opindex)
01730     {
01731     case FRV_OPERAND_A0 :
01732       fields->f_A = value;
01733       break;
01734     case FRV_OPERAND_A1 :
01735       fields->f_A = value;
01736       break;
01737     case FRV_OPERAND_ACC40SI :
01738       fields->f_ACC40Si = value;
01739       break;
01740     case FRV_OPERAND_ACC40SK :
01741       fields->f_ACC40Sk = value;
01742       break;
01743     case FRV_OPERAND_ACC40UI :
01744       fields->f_ACC40Ui = value;
01745       break;
01746     case FRV_OPERAND_ACC40UK :
01747       fields->f_ACC40Uk = value;
01748       break;
01749     case FRV_OPERAND_ACCGI :
01750       fields->f_ACCGi = value;
01751       break;
01752     case FRV_OPERAND_ACCGK :
01753       fields->f_ACCGk = value;
01754       break;
01755     case FRV_OPERAND_CCI :
01756       fields->f_CCi = value;
01757       break;
01758     case FRV_OPERAND_CPRDOUBLEK :
01759       fields->f_CPRk = value;
01760       break;
01761     case FRV_OPERAND_CPRI :
01762       fields->f_CPRi = value;
01763       break;
01764     case FRV_OPERAND_CPRJ :
01765       fields->f_CPRj = value;
01766       break;
01767     case FRV_OPERAND_CPRK :
01768       fields->f_CPRk = value;
01769       break;
01770     case FRV_OPERAND_CRI :
01771       fields->f_CRi = value;
01772       break;
01773     case FRV_OPERAND_CRJ :
01774       fields->f_CRj = value;
01775       break;
01776     case FRV_OPERAND_CRJ_FLOAT :
01777       fields->f_CRj_float = value;
01778       break;
01779     case FRV_OPERAND_CRJ_INT :
01780       fields->f_CRj_int = value;
01781       break;
01782     case FRV_OPERAND_CRK :
01783       fields->f_CRk = value;
01784       break;
01785     case FRV_OPERAND_FCCI_1 :
01786       fields->f_FCCi_1 = value;
01787       break;
01788     case FRV_OPERAND_FCCI_2 :
01789       fields->f_FCCi_2 = value;
01790       break;
01791     case FRV_OPERAND_FCCI_3 :
01792       fields->f_FCCi_3 = value;
01793       break;
01794     case FRV_OPERAND_FCCK :
01795       fields->f_FCCk = value;
01796       break;
01797     case FRV_OPERAND_FRDOUBLEI :
01798       fields->f_FRi = value;
01799       break;
01800     case FRV_OPERAND_FRDOUBLEJ :
01801       fields->f_FRj = value;
01802       break;
01803     case FRV_OPERAND_FRDOUBLEK :
01804       fields->f_FRk = value;
01805       break;
01806     case FRV_OPERAND_FRI :
01807       fields->f_FRi = value;
01808       break;
01809     case FRV_OPERAND_FRINTI :
01810       fields->f_FRi = value;
01811       break;
01812     case FRV_OPERAND_FRINTIEVEN :
01813       fields->f_FRi = value;
01814       break;
01815     case FRV_OPERAND_FRINTJ :
01816       fields->f_FRj = value;
01817       break;
01818     case FRV_OPERAND_FRINTJEVEN :
01819       fields->f_FRj = value;
01820       break;
01821     case FRV_OPERAND_FRINTK :
01822       fields->f_FRk = value;
01823       break;
01824     case FRV_OPERAND_FRINTKEVEN :
01825       fields->f_FRk = value;
01826       break;
01827     case FRV_OPERAND_FRJ :
01828       fields->f_FRj = value;
01829       break;
01830     case FRV_OPERAND_FRK :
01831       fields->f_FRk = value;
01832       break;
01833     case FRV_OPERAND_FRKHI :
01834       fields->f_FRk = value;
01835       break;
01836     case FRV_OPERAND_FRKLO :
01837       fields->f_FRk = value;
01838       break;
01839     case FRV_OPERAND_GRDOUBLEK :
01840       fields->f_GRk = value;
01841       break;
01842     case FRV_OPERAND_GRI :
01843       fields->f_GRi = value;
01844       break;
01845     case FRV_OPERAND_GRJ :
01846       fields->f_GRj = value;
01847       break;
01848     case FRV_OPERAND_GRK :
01849       fields->f_GRk = value;
01850       break;
01851     case FRV_OPERAND_GRKHI :
01852       fields->f_GRk = value;
01853       break;
01854     case FRV_OPERAND_GRKLO :
01855       fields->f_GRk = value;
01856       break;
01857     case FRV_OPERAND_ICCI_1 :
01858       fields->f_ICCi_1 = value;
01859       break;
01860     case FRV_OPERAND_ICCI_2 :
01861       fields->f_ICCi_2 = value;
01862       break;
01863     case FRV_OPERAND_ICCI_3 :
01864       fields->f_ICCi_3 = value;
01865       break;
01866     case FRV_OPERAND_LI :
01867       fields->f_LI = value;
01868       break;
01869     case FRV_OPERAND_LRAD :
01870       fields->f_LRAD = value;
01871       break;
01872     case FRV_OPERAND_LRAE :
01873       fields->f_LRAE = value;
01874       break;
01875     case FRV_OPERAND_LRAS :
01876       fields->f_LRAS = value;
01877       break;
01878     case FRV_OPERAND_TLBPRL :
01879       fields->f_TLBPRL = value;
01880       break;
01881     case FRV_OPERAND_TLBPROPX :
01882       fields->f_TLBPRopx = value;
01883       break;
01884     case FRV_OPERAND_AE :
01885       fields->f_ae = value;
01886       break;
01887     case FRV_OPERAND_CALLANN :
01888       fields->f_reloc_ann = value;
01889       break;
01890     case FRV_OPERAND_CCOND :
01891       fields->f_ccond = value;
01892       break;
01893     case FRV_OPERAND_COND :
01894       fields->f_cond = value;
01895       break;
01896     case FRV_OPERAND_D12 :
01897       fields->f_d12 = value;
01898       break;
01899     case FRV_OPERAND_DEBUG :
01900       fields->f_debug = value;
01901       break;
01902     case FRV_OPERAND_EIR :
01903       fields->f_eir = value;
01904       break;
01905     case FRV_OPERAND_HINT :
01906       fields->f_hint = value;
01907       break;
01908     case FRV_OPERAND_HINT_NOT_TAKEN :
01909       fields->f_hint = value;
01910       break;
01911     case FRV_OPERAND_HINT_TAKEN :
01912       fields->f_hint = value;
01913       break;
01914     case FRV_OPERAND_LABEL16 :
01915       fields->f_label16 = value;
01916       break;
01917     case FRV_OPERAND_LABEL24 :
01918       fields->f_label24 = value;
01919       break;
01920     case FRV_OPERAND_LDANN :
01921       fields->f_reloc_ann = value;
01922       break;
01923     case FRV_OPERAND_LDDANN :
01924       fields->f_reloc_ann = value;
01925       break;
01926     case FRV_OPERAND_LOCK :
01927       fields->f_lock = value;
01928       break;
01929     case FRV_OPERAND_PACK :
01930       fields->f_pack = value;
01931       break;
01932     case FRV_OPERAND_S10 :
01933       fields->f_s10 = value;
01934       break;
01935     case FRV_OPERAND_S12 :
01936       fields->f_d12 = value;
01937       break;
01938     case FRV_OPERAND_S16 :
01939       fields->f_s16 = value;
01940       break;
01941     case FRV_OPERAND_S5 :
01942       fields->f_s5 = value;
01943       break;
01944     case FRV_OPERAND_S6 :
01945       fields->f_s6 = value;
01946       break;
01947     case FRV_OPERAND_S6_1 :
01948       fields->f_s6_1 = value;
01949       break;
01950     case FRV_OPERAND_SLO16 :
01951       fields->f_s16 = value;
01952       break;
01953     case FRV_OPERAND_SPR :
01954       fields->f_spr = value;
01955       break;
01956     case FRV_OPERAND_U12 :
01957       fields->f_u12 = value;
01958       break;
01959     case FRV_OPERAND_U16 :
01960       fields->f_u16 = value;
01961       break;
01962     case FRV_OPERAND_U6 :
01963       fields->f_u6 = value;
01964       break;
01965     case FRV_OPERAND_UHI16 :
01966       fields->f_u16 = value;
01967       break;
01968     case FRV_OPERAND_ULO16 :
01969       fields->f_u16 = value;
01970       break;
01971 
01972     default :
01973       /* xgettext:c-format */
01974       fprintf (stderr, _("Unrecognized field %d while setting int operand.\n"),
01975                      opindex);
01976       abort ();
01977   }
01978 }
01979 
01980 void
01981 frv_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
01982                           int opindex,
01983                           CGEN_FIELDS * fields,
01984                           bfd_vma value)
01985 {
01986   switch (opindex)
01987     {
01988     case FRV_OPERAND_A0 :
01989       fields->f_A = value;
01990       break;
01991     case FRV_OPERAND_A1 :
01992       fields->f_A = value;
01993       break;
01994     case FRV_OPERAND_ACC40SI :
01995       fields->f_ACC40Si = value;
01996       break;
01997     case FRV_OPERAND_ACC40SK :
01998       fields->f_ACC40Sk = value;
01999       break;
02000     case FRV_OPERAND_ACC40UI :
02001       fields->f_ACC40Ui = value;
02002       break;
02003     case FRV_OPERAND_ACC40UK :
02004       fields->f_ACC40Uk = value;
02005       break;
02006     case FRV_OPERAND_ACCGI :
02007       fields->f_ACCGi = value;
02008       break;
02009     case FRV_OPERAND_ACCGK :
02010       fields->f_ACCGk = value;
02011       break;
02012     case FRV_OPERAND_CCI :
02013       fields->f_CCi = value;
02014       break;
02015     case FRV_OPERAND_CPRDOUBLEK :
02016       fields->f_CPRk = value;
02017       break;
02018     case FRV_OPERAND_CPRI :
02019       fields->f_CPRi = value;
02020       break;
02021     case FRV_OPERAND_CPRJ :
02022       fields->f_CPRj = value;
02023       break;
02024     case FRV_OPERAND_CPRK :
02025       fields->f_CPRk = value;
02026       break;
02027     case FRV_OPERAND_CRI :
02028       fields->f_CRi = value;
02029       break;
02030     case FRV_OPERAND_CRJ :
02031       fields->f_CRj = value;
02032       break;
02033     case FRV_OPERAND_CRJ_FLOAT :
02034       fields->f_CRj_float = value;
02035       break;
02036     case FRV_OPERAND_CRJ_INT :
02037       fields->f_CRj_int = value;
02038       break;
02039     case FRV_OPERAND_CRK :
02040       fields->f_CRk = value;
02041       break;
02042     case FRV_OPERAND_FCCI_1 :
02043       fields->f_FCCi_1 = value;
02044       break;
02045     case FRV_OPERAND_FCCI_2 :
02046       fields->f_FCCi_2 = value;
02047       break;
02048     case FRV_OPERAND_FCCI_3 :
02049       fields->f_FCCi_3 = value;
02050       break;
02051     case FRV_OPERAND_FCCK :
02052       fields->f_FCCk = value;
02053       break;
02054     case FRV_OPERAND_FRDOUBLEI :
02055       fields->f_FRi = value;
02056       break;
02057     case FRV_OPERAND_FRDOUBLEJ :
02058       fields->f_FRj = value;
02059       break;
02060     case FRV_OPERAND_FRDOUBLEK :
02061       fields->f_FRk = value;
02062       break;
02063     case FRV_OPERAND_FRI :
02064       fields->f_FRi = value;
02065       break;
02066     case FRV_OPERAND_FRINTI :
02067       fields->f_FRi = value;
02068       break;
02069     case FRV_OPERAND_FRINTIEVEN :
02070       fields->f_FRi = value;
02071       break;
02072     case FRV_OPERAND_FRINTJ :
02073       fields->f_FRj = value;
02074       break;
02075     case FRV_OPERAND_FRINTJEVEN :
02076       fields->f_FRj = value;
02077       break;
02078     case FRV_OPERAND_FRINTK :
02079       fields->f_FRk = value;
02080       break;
02081     case FRV_OPERAND_FRINTKEVEN :
02082       fields->f_FRk = value;
02083       break;
02084     case FRV_OPERAND_FRJ :
02085       fields->f_FRj = value;
02086       break;
02087     case FRV_OPERAND_FRK :
02088       fields->f_FRk = value;
02089       break;
02090     case FRV_OPERAND_FRKHI :
02091       fields->f_FRk = value;
02092       break;
02093     case FRV_OPERAND_FRKLO :
02094       fields->f_FRk = value;
02095       break;
02096     case FRV_OPERAND_GRDOUBLEK :
02097       fields->f_GRk = value;
02098       break;
02099     case FRV_OPERAND_GRI :
02100       fields->f_GRi = value;
02101       break;
02102     case FRV_OPERAND_GRJ :
02103       fields->f_GRj = value;
02104       break;
02105     case FRV_OPERAND_GRK :
02106       fields->f_GRk = value;
02107       break;
02108     case FRV_OPERAND_GRKHI :
02109       fields->f_GRk = value;
02110       break;
02111     case FRV_OPERAND_GRKLO :
02112       fields->f_GRk = value;
02113       break;
02114     case FRV_OPERAND_ICCI_1 :
02115       fields->f_ICCi_1 = value;
02116       break;
02117     case FRV_OPERAND_ICCI_2 :
02118       fields->f_ICCi_2 = value;
02119       break;
02120     case FRV_OPERAND_ICCI_3 :
02121       fields->f_ICCi_3 = value;
02122       break;
02123     case FRV_OPERAND_LI :
02124       fields->f_LI = value;
02125       break;
02126     case FRV_OPERAND_LRAD :
02127       fields->f_LRAD = value;
02128       break;
02129     case FRV_OPERAND_LRAE :
02130       fields->f_LRAE = value;
02131       break;
02132     case FRV_OPERAND_LRAS :
02133       fields->f_LRAS = value;
02134       break;
02135     case FRV_OPERAND_TLBPRL :
02136       fields->f_TLBPRL = value;
02137       break;
02138     case FRV_OPERAND_TLBPROPX :
02139       fields->f_TLBPRopx = value;
02140       break;
02141     case FRV_OPERAND_AE :
02142       fields->f_ae = value;
02143       break;
02144     case FRV_OPERAND_CALLANN :
02145       fields->f_reloc_ann = value;
02146       break;
02147     case FRV_OPERAND_CCOND :
02148       fields->f_ccond = value;
02149       break;
02150     case FRV_OPERAND_COND :
02151       fields->f_cond = value;
02152       break;
02153     case FRV_OPERAND_D12 :
02154       fields->f_d12 = value;
02155       break;
02156     case FRV_OPERAND_DEBUG :
02157       fields->f_debug = value;
02158       break;
02159     case FRV_OPERAND_EIR :
02160       fields->f_eir = value;
02161       break;
02162     case FRV_OPERAND_HINT :
02163       fields->f_hint = value;
02164       break;
02165     case FRV_OPERAND_HINT_NOT_TAKEN :
02166       fields->f_hint = value;
02167       break;
02168     case FRV_OPERAND_HINT_TAKEN :
02169       fields->f_hint = value;
02170       break;
02171     case FRV_OPERAND_LABEL16 :
02172       fields->f_label16 = value;
02173       break;
02174     case FRV_OPERAND_LABEL24 :
02175       fields->f_label24 = value;
02176       break;
02177     case FRV_OPERAND_LDANN :
02178       fields->f_reloc_ann = value;
02179       break;
02180     case FRV_OPERAND_LDDANN :
02181       fields->f_reloc_ann = value;
02182       break;
02183     case FRV_OPERAND_LOCK :
02184       fields->f_lock = value;
02185       break;
02186     case FRV_OPERAND_PACK :
02187       fields->f_pack = value;
02188       break;
02189     case FRV_OPERAND_S10 :
02190       fields->f_s10 = value;
02191       break;
02192     case FRV_OPERAND_S12 :
02193       fields->f_d12 = value;
02194       break;
02195     case FRV_OPERAND_S16 :
02196       fields->f_s16 = value;
02197       break;
02198     case FRV_OPERAND_S5 :
02199       fields->f_s5 = value;
02200       break;
02201     case FRV_OPERAND_S6 :
02202       fields->f_s6 = value;
02203       break;
02204     case FRV_OPERAND_S6_1 :
02205       fields->f_s6_1 = value;
02206       break;
02207     case FRV_OPERAND_SLO16 :
02208       fields->f_s16 = value;
02209       break;
02210     case FRV_OPERAND_SPR :
02211       fields->f_spr = value;
02212       break;
02213     case FRV_OPERAND_U12 :
02214       fields->f_u12 = value;
02215       break;
02216     case FRV_OPERAND_U16 :
02217       fields->f_u16 = value;
02218       break;
02219     case FRV_OPERAND_U6 :
02220       fields->f_u6 = value;
02221       break;
02222     case FRV_OPERAND_UHI16 :
02223       fields->f_u16 = value;
02224       break;
02225     case FRV_OPERAND_ULO16 :
02226       fields->f_u16 = value;
02227       break;
02228 
02229     default :
02230       /* xgettext:c-format */
02231       fprintf (stderr, _("Unrecognized field %d while setting vma operand.\n"),
02232                      opindex);
02233       abort ();
02234   }
02235 }
02236 
02237 /* Function to call before using the instruction builder tables.  */
02238 
02239 void
02240 frv_cgen_init_ibld_table (CGEN_CPU_DESC cd)
02241 {
02242   cd->insert_handlers = & frv_cgen_insert_handlers[0];
02243   cd->extract_handlers = & frv_cgen_extract_handlers[0];
02244 
02245   cd->insert_operand = frv_cgen_insert_operand;
02246   cd->extract_operand = frv_cgen_extract_operand;
02247 
02248   cd->get_int_operand = frv_cgen_get_int_operand;
02249   cd->set_int_operand = frv_cgen_set_int_operand;
02250   cd->get_vma_operand = frv_cgen_get_vma_operand;
02251   cd->set_vma_operand = frv_cgen_set_vma_operand;
02252 }