gdb: fix vfork with multiple threads
[deliverable/binutils-gdb.git] / opcodes / frv-ibld.c
index 2283371fc1af0191d81fe2c59dee854ffd9b7c4e..e9c18ee7f269fa04da2f2db59b870d7a6c92ca29 100644 (file)
@@ -1,22 +1,22 @@
+/* DO NOT EDIT!  -*- buffer-read-only: t -*- vi:set ro:  */
 /* Instruction building/extraction support for frv. -*- C -*-
 
    THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator.
    - the resultant file is machine generated, cgen-ibld.in isn't
 
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005, 2006
-   Free Software Foundation, Inc.
+   Copyright (C) 1996-2021 Free Software Foundation, Inc.
 
-   This file is part of the GNU Binutils and GDB, the GNU debugger.
+   This file is part of libopcodes.
 
-   This program is free software; you can redistribute it and/or modify
+   This library is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
+   the Free Software Foundation; either version 3, or (at your option)
    any later version.
 
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
+   It is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software Foundation, Inc.,
@@ -33,6 +33,7 @@
 #include "symcat.h"
 #include "frv-desc.h"
 #include "frv-opc.h"
+#include "cgen/basic-modes.h"
 #include "opintl.h"
 #include "safe-ctype.h"
 
@@ -84,20 +85,20 @@ insert_1 (CGEN_CPU_DESC cd,
          int word_length,
          unsigned char *bufp)
 {
-  unsigned long x,mask;
+  unsigned long x, mask;
   int shift;
 
-  x = cgen_get_insn_value (cd, bufp, word_length);
+  x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
 
   /* Written this way to avoid undefined behaviour.  */
-  mask = (((1L << (length - 1)) - 1) << 1) | 1;
+  mask = (1UL << (length - 1) << 1) - 1;
   if (CGEN_INSN_LSB0_P)
     shift = (start + 1) - length;
   else
     shift = (word_length - (start + length));
   x = (x & ~(mask << shift)) | ((value & mask) << shift);
 
-  cgen_put_insn_value (cd, bufp, word_length, (bfd_vma) x);
+  cgen_put_insn_value (cd, bufp, word_length, (bfd_vma) x, cd->endian);
 }
 
 #endif /* ! CGEN_INT_INSN_P */
@@ -130,14 +131,16 @@ insert_normal (CGEN_CPU_DESC cd,
               CGEN_INSN_BYTES_PTR buffer)
 {
   static char errbuf[100];
-  /* Written this way to avoid undefined behaviour.  */
-  unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
+  unsigned long mask;
 
   /* If LENGTH is zero, this operand doesn't contribute to the value.  */
   if (length == 0)
     return NULL;
 
-  if (word_length > 32)
+  /* Written this way to avoid undefined behaviour.  */
+  mask = (1UL << (length - 1) << 1) - 1;
+
+  if (word_length > 8 * sizeof (CGEN_INSN_INT))
     abort ();
 
   /* For architectures with insns smaller than the base-insn-bitsize,
@@ -152,9 +155,9 @@ insert_normal (CGEN_CPU_DESC cd,
   /* Ensure VALUE will fit.  */
   if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGN_OPT))
     {
-      long minval = - (1L << (length - 1));
+      long minval = - (1UL << (length - 1));
       unsigned long maxval = mask;
-      
+
       if ((value > 0 && (unsigned long) value > maxval)
          || value < minval)
        {
@@ -190,9 +193,9 @@ insert_normal (CGEN_CPU_DESC cd,
     {
       if (! cgen_signed_overflow_ok_p (cd))
        {
-         long minval = - (1L << (length - 1));
-         long maxval =   (1L << (length - 1)) - 1;
-         
+         long minval = - (1UL << (length - 1));
+         long maxval =   (1UL << (length - 1)) - 1;
+
          if (value < minval || value > maxval)
            {
              sprintf
@@ -207,12 +210,19 @@ insert_normal (CGEN_CPU_DESC cd,
 #if CGEN_INT_INSN_P
 
   {
-    int shift;
+    int shift_within_word, shift_to_word, shift;
 
+    /* How to shift the value to BIT0 of the word.  */
+    shift_to_word = total_length - (word_offset + word_length);
+
+    /* How to shift the value to the field within the word.  */
     if (CGEN_INSN_LSB0_P)
-      shift = (word_offset + start + 1) - length;
+      shift_within_word = start + 1 - length;
     else
-      shift = total_length - (word_offset + start + length);
+      shift_within_word = word_length - start - length;
+
+    /* The total SHIFT, then mask in the value.  */
+    shift = shift_to_word + shift_within_word;
     *buffer = (*buffer & ~(mask << shift)) | ((value & mask) << shift);
   }
 
@@ -261,8 +271,8 @@ insert_insn_normal (CGEN_CPU_DESC cd,
 #else
 
   cgen_put_insn_value (cd, buffer, min ((unsigned) cd->base_insn_bitsize,
-                                       (unsigned) CGEN_FIELDS_BITSIZE (fields)),
-                      value);
+                                        (unsigned) CGEN_FIELDS_BITSIZE (fields)),
+                      value, cd->insn_endian);
 
 #endif /* ! CGEN_INT_INSN_P */
 
@@ -306,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
     {
       int shift = insn_length - length;
       /* Written this way to avoid undefined behaviour.  */
-      CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1;
+      CGEN_INSN_INT mask = length == 0 ? 0 : (1UL << (length - 1) << 1) - 1;
 
       *buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
     }
@@ -379,7 +389,7 @@ extract_1 (CGEN_CPU_DESC cd,
   unsigned long x;
   int shift;
 
-  x = cgen_get_insn_value (cd, bufp, word_length);
+  x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
 
   if (CGEN_INSN_LSB0_P)
     shift = (start + 1) - length;
@@ -441,7 +451,7 @@ extract_normal (CGEN_CPU_DESC cd,
       return 1;
     }
 
-  if (word_length > 32)
+  if (word_length > 8 * sizeof (CGEN_INSN_INT))
     abort ();
 
   /* For architectures with insns smaller than the insn-base-bitsize,
@@ -468,11 +478,14 @@ extract_normal (CGEN_CPU_DESC cd,
     {
       unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
 
-      if (word_length > 32)
+      if (word_length > 8 * sizeof (CGEN_INSN_INT))
        abort ();
 
       if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
-       return 0;
+       {
+         *valuep = 0;
+         return 0;
+       }
 
       value = extract_1 (cd, ex_info, start, length, word_length, bufp, pc);
     }
@@ -480,12 +493,12 @@ extract_normal (CGEN_CPU_DESC cd,
 #endif /* ! CGEN_INT_INSN_P */
 
   /* Written this way to avoid undefined behaviour.  */
-  mask = (((1L << (length - 1)) - 1) << 1) | 1;
+  mask = (1UL << (length - 1) << 1) - 1;
 
   value &= mask;
   /* sign extend? */
   if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)
-      && (value & (1L << (length - 1))))
+      && (value & (1UL << (length - 1))))
     value |= ~mask;
 
   *valuep = value;
@@ -755,15 +768,15 @@ frv_cgen_insert_operand (CGEN_CPU_DESC cd,
     case FRV_OPERAND_LABEL16 :
       {
         long value = fields->f_label16;
-        value = ((int) (((value) - (pc))) >> (2));
+        value = ((SI) (((value) - (pc))) >> (2));
         errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 15, 16, 32, total_length, buffer);
       }
       break;
     case FRV_OPERAND_LABEL24 :
       {
 {
-  FLD (f_labelH6) = ((int) (((FLD (f_label24)) - (pc))) >> (20));
-  FLD (f_labelL18) = ((((unsigned int) (((FLD (f_label24)) - (pc))) >> (2))) & (262143));
+  FLD (f_labelH6) = ((SI) (((FLD (f_label24)) - (pc))) >> (20));
+  FLD (f_labelL18) = ((((UINT) (((FLD (f_label24)) - (pc))) >> (2))) & (262143));
 }
         errmsg = insert_normal (cd, fields->f_labelH6, 0|(1<<CGEN_IFLD_SIGNED), 0, 30, 6, 32, total_length, buffer);
         if (errmsg)
@@ -809,7 +822,7 @@ frv_cgen_insert_operand (CGEN_CPU_DESC cd,
     case FRV_OPERAND_SPR :
       {
 {
-  FLD (f_spr_h) = ((unsigned int) (FLD (f_spr)) >> (6));
+  FLD (f_spr_h) = ((UINT) (FLD (f_spr)) >> (6));
   FLD (f_spr_l) = ((FLD (f_spr)) & (63));
 }
         errmsg = insert_normal (cd, fields->f_spr_h, 0, 0, 30, 6, 32, total_length, buffer);
@@ -823,7 +836,7 @@ frv_cgen_insert_operand (CGEN_CPU_DESC cd,
     case FRV_OPERAND_U12 :
       {
 {
-  FLD (f_u12_h) = ((int) (FLD (f_u12)) >> (6));
+  FLD (f_u12_h) = ((SI) (FLD (f_u12)) >> (6));
   FLD (f_u12_l) = ((FLD (f_u12)) & (63));
 }
         errmsg = insert_normal (cd, fields->f_u12_h, 0|(1<<CGEN_IFLD_SIGNED), 0, 17, 6, 32, total_length, buffer);
@@ -849,8 +862,9 @@ frv_cgen_insert_operand (CGEN_CPU_DESC cd,
 
     default :
       /* xgettext:c-format */
-      fprintf (stderr, _("Unrecognized field %d while building insn.\n"),
-              opindex);
+      opcodes_error_handler
+       (_("internal error: unrecognized field %d while building insn"),
+        opindex);
       abort ();
   }
 
@@ -1081,7 +1095,7 @@ frv_cgen_extract_operand (CGEN_CPU_DESC cd,
       {
         long value;
         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);
-        value = ((((value) << (2))) + (pc));
+        value = ((((value) * (4))) + (pc));
         fields->f_label16 = value;
       }
       break;
@@ -1092,7 +1106,7 @@ frv_cgen_extract_operand (CGEN_CPU_DESC cd,
         length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 18, 32, total_length, pc, & fields->f_labelL18);
         if (length <= 0) break;
 {
-  FLD (f_label24) = ((((((((FLD (f_labelH6)) << (18))) | (FLD (f_labelL18)))) << (2))) + (pc));
+  FLD (f_label24) = ((((((((FLD (f_labelH6)) * (((1) << (18))))) | (FLD (f_labelL18)))) * (4))) + (pc));
 }
       }
       break;
@@ -1147,7 +1161,7 @@ frv_cgen_extract_operand (CGEN_CPU_DESC cd,
         length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_u12_l);
         if (length <= 0) break;
 {
-  FLD (f_u12) = ((((FLD (f_u12_h)) << (6))) | (FLD (f_u12_l)));
+  FLD (f_u12) = ((((FLD (f_u12_h)) * (64))) | (FLD (f_u12_l)));
 }
       }
       break;
@@ -1166,20 +1180,21 @@ frv_cgen_extract_operand (CGEN_CPU_DESC cd,
 
     default :
       /* xgettext:c-format */
-      fprintf (stderr, _("Unrecognized field %d while decoding insn.\n"),
-              opindex);
+      opcodes_error_handler
+       (_("internal error: unrecognized field %d while decoding insn"),
+        opindex);
       abort ();
     }
 
   return length;
 }
 
-cgen_insert_fn * const frv_cgen_insert_handlers[] = 
+cgen_insert_fn * const frv_cgen_insert_handlers[] =
 {
   insert_insn_normal,
 };
 
-cgen_extract_fn * const frv_cgen_extract_handlers[] = 
+cgen_extract_fn * const frv_cgen_extract_handlers[] =
 {
   extract_insn_normal,
 };
@@ -1444,8 +1459,9 @@ frv_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
 
     default :
       /* xgettext:c-format */
-      fprintf (stderr, _("Unrecognized field %d while getting int operand.\n"),
-                      opindex);
+      opcodes_error_handler
+       (_("internal error: unrecognized field %d while getting int operand"),
+        opindex);
       abort ();
   }
 
@@ -1704,8 +1720,9 @@ frv_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
 
     default :
       /* xgettext:c-format */
-      fprintf (stderr, _("Unrecognized field %d while getting vma operand.\n"),
-                      opindex);
+      opcodes_error_handler
+       (_("internal error: unrecognized field %d while getting vma operand"),
+        opindex);
       abort ();
   }
 
@@ -1971,8 +1988,9 @@ frv_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
 
     default :
       /* xgettext:c-format */
-      fprintf (stderr, _("Unrecognized field %d while setting int operand.\n"),
-                      opindex);
+      opcodes_error_handler
+       (_("internal error: unrecognized field %d while setting int operand"),
+        opindex);
       abort ();
   }
 }
@@ -2228,8 +2246,9 @@ frv_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
 
     default :
       /* xgettext:c-format */
-      fprintf (stderr, _("Unrecognized field %d while setting vma operand.\n"),
-                      opindex);
+      opcodes_error_handler
+       (_("internal error: unrecognized field %d while setting vma operand"),
+        opindex);
       abort ();
   }
 }
This page took 0.027529 seconds and 4 git commands to generate.