]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - opcodes/cgen-asm.c
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / opcodes / cgen-asm.c
index 7231e2d7aedfded367f70cfb8de7ffdae28a6296..4bfab4e32611de5e27b4ebe5b41aa0035287dfc4 100644 (file)
@@ -1,22 +1,22 @@
 /* CGEN generic assembler support code.
+   Copyright (C) 1996-2021 Free Software Foundation, Inc.
 
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+   This file is part of libopcodes.
 
-   This file is part of the GNU Binutils and GDB, the GNU debugger.
-
-   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.,
-   59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+   51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 #include "sysdep.h"
 #include <stdio.h>
@@ -60,7 +60,7 @@ cgen_init_parse_operand (CGEN_CPU_DESC cd)
    The result is a pointer to the next entry to use.
 
    The table is scanned backwards as additions are made to the front of the
-   list and we want earlier ones to be prefered.  */
+   list and we want earlier ones to be preferred.  */
 
 static CGEN_INSN_LIST *
 hash_insn_array (CGEN_CPU_DESC cd,
@@ -156,7 +156,7 @@ build_asm_hash_table (CGEN_CPU_DESC cd)
                                    asm_hash_table, hash_entry_buf);
 
   /* Add runtime added insns.
-     Later added insns will be prefered over earlier ones.  */
+     Later added insns will be preferred over earlier ones.  */
 
   hash_entry_buf = hash_insn_list (cd, insn_table->new_entries,
                                   asm_hash_table, hash_entry_buf);
@@ -212,7 +212,7 @@ cgen_parse_keyword (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
      character of the suffix ('.') is special.  */
   if (*p)
     ++p;
-  
+
   /* Allow letters, digits, and any special characters.  */
   while (((p - start) < (int) sizeof (buf))
         && *p
@@ -267,7 +267,23 @@ cgen_parse_signed_integer (CGEN_CPU_DESC cd,
      &result, &value);
   /* FIXME: Examine `result'.  */
   if (!errmsg)
-    *valuep = value;
+    {
+      /* Handle the case where a hex value is parsed on a 64-bit host.
+        A value like 0xffffe000 is clearly intended to be a negative
+        16-bit value, but on a 64-bit host it will be parsed by gas
+        as 0x00000000ffffe000.
+
+        The shifts below are designed not to produce compile time
+        warnings on a 32-bit host.  */
+      if (sizeof (value) > 4
+         && result == CGEN_PARSE_OPERAND_RESULT_NUMBER
+         && value > 0
+         && (value & 0x80000000)
+         && ((value >> 31) == 1))
+       value |= ((bfd_vma) -1) << 31;
+
+      *valuep = value;
+    }
   return errmsg;
 }