OSDN Git Service

cpu/
[pf3gnuchains/pf3gnuchains3x.git] / opcodes / fr30-ibld.c
index 48dad67..077f0ac 100644 (file)
@@ -3,20 +3,20 @@
    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
-   Free Software Foundation, Inc.
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005, 2006, 2007,
+   2008, 2010  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 "fr30-desc.h"
 #include "fr30-opc.h"
+#include "cgen/basic-modes.h"
 #include "opintl.h"
 #include "safe-ctype.h"
 
@@ -168,13 +169,21 @@ insert_normal (CGEN_CPU_DESC cd,
   else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED))
     {
       unsigned long maxval = mask;
-      
-      if ((unsigned long) value > maxval)
+      unsigned long val = (unsigned long) value;
+
+      /* For hosts with a word size > 32 check to see if value has been sign
+        extended beyond 32 bits.  If so then ignore these higher sign bits
+        as the user is attempting to store a 32-bit signed value into an
+        unsigned 32-bit field which is allowed.  */
+      if (sizeof (unsigned long) > 4 && ((value >> 32) == -1))
+       val &= 0xFFFFFFFF;
+
+      if (val > maxval)
        {
          /* xgettext:c-format */
          sprintf (errbuf,
-                  _("operand out of range (%lu not between 0 and %lu)"),
-                  value, maxval);
+                  _("operand out of range (0x%lx not between 0 and 0x%lx)"),
+                  val, maxval);
          return errbuf;
        }
     }
@@ -440,9 +449,8 @@ extract_normal (CGEN_CPU_DESC cd,
      word_length may be too big.  */
   if (cd->min_insn_bitsize < cd->base_insn_bitsize)
     {
-      if (word_offset == 0
-         && word_length > total_length)
-       word_length = total_length;
+      if (word_offset + word_length > total_length)
+       word_length = total_length - word_offset;
     }
 
   /* Does the value reside in INSN_VALUE, and at the right alignment?  */
@@ -597,7 +605,7 @@ fr30_cgen_insert_operand (CGEN_CPU_DESC cd,
     case FR30_OPERAND_DIR10 :
       {
         long value = fields->f_dir10;
-        value = ((unsigned int) (value) >> (2));
+        value = ((USI) (value) >> (2));
         errmsg = insert_normal (cd, value, 0, 0, 8, 8, 16, total_length, buffer);
       }
       break;
@@ -607,14 +615,14 @@ fr30_cgen_insert_operand (CGEN_CPU_DESC cd,
     case FR30_OPERAND_DIR9 :
       {
         long value = fields->f_dir9;
-        value = ((unsigned int) (value) >> (1));
+        value = ((USI) (value) >> (1));
         errmsg = insert_normal (cd, value, 0, 0, 8, 8, 16, total_length, buffer);
       }
       break;
     case FR30_OPERAND_DISP10 :
       {
         long value = fields->f_disp10;
-        value = ((int) (value) >> (2));
+        value = ((SI) (value) >> (2));
         errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED), 0, 4, 8, 16, total_length, buffer);
       }
       break;
@@ -624,14 +632,14 @@ fr30_cgen_insert_operand (CGEN_CPU_DESC cd,
     case FR30_OPERAND_DISP9 :
       {
         long value = fields->f_disp9;
-        value = ((int) (value) >> (1));
+        value = ((SI) (value) >> (1));
         errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED), 0, 4, 8, 16, total_length, buffer);
       }
       break;
     case FR30_OPERAND_I20 :
       {
 {
-  FLD (f_i20_4) = ((unsigned int) (FLD (f_i20)) >> (16));
+  FLD (f_i20_4) = ((UINT) (FLD (f_i20)) >> (16));
   FLD (f_i20_16) = ((FLD (f_i20)) & (65535));
 }
         errmsg = insert_normal (cd, fields->f_i20_4, 0, 0, 8, 4, 16, total_length, buffer);
@@ -651,14 +659,14 @@ fr30_cgen_insert_operand (CGEN_CPU_DESC cd,
     case FR30_OPERAND_LABEL12 :
       {
         long value = fields->f_rel12;
-        value = ((int) (((value) - (((pc) + (2))))) >> (1));
+        value = ((SI) (((value) - (((pc) + (2))))) >> (1));
         errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 5, 11, 16, total_length, buffer);
       }
       break;
     case FR30_OPERAND_LABEL9 :
       {
         long value = fields->f_rel9;
-        value = ((int) (((value) - (((pc) + (2))))) >> (1));
+        value = ((SI) (((value) - (((pc) + (2))))) >> (1));
         errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 8, 8, 16, total_length, buffer);
       }
       break;
@@ -686,14 +694,14 @@ fr30_cgen_insert_operand (CGEN_CPU_DESC cd,
     case FR30_OPERAND_S10 :
       {
         long value = fields->f_s10;
-        value = ((int) (value) >> (2));
+        value = ((SI) (value) >> (2));
         errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED), 0, 8, 8, 16, total_length, buffer);
       }
       break;
     case FR30_OPERAND_U10 :
       {
         long value = fields->f_u10;
-        value = ((unsigned int) (value) >> (2));
+        value = ((USI) (value) >> (2));
         errmsg = insert_normal (cd, value, 0, 0, 8, 8, 16, total_length, buffer);
       }
       break;
@@ -709,7 +717,7 @@ fr30_cgen_insert_operand (CGEN_CPU_DESC cd,
     case FR30_OPERAND_UDISP6 :
       {
         long value = fields->f_udisp6;
-        value = ((unsigned int) (value) >> (2));
+        value = ((USI) (value) >> (2));
         errmsg = insert_normal (cd, value, 0, 0, 8, 4, 16, total_length, buffer);
       }
       break;