Fix skip.exp test failure observed with gcc-9.2.0
[deliverable/binutils-gdb.git] / bfd / xtensa-isa.c
index 362e47c31797a04ef9f69525d49f2137d06dad34..172de6f41e9b8a535abd6e107de712db33bbe97f 100644 (file)
@@ -1,11 +1,11 @@
 /* Configurable Xtensa ISA support.
 /* Configurable Xtensa ISA support.
-   Copyright 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 
    This file is part of BFD, the Binary File Descriptor library.
 
    This program 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 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -15,7 +15,8 @@
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
 
    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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
 
 #include "sysdep.h"
 #include "bfd.h"
 
 #include "sysdep.h"
 #include "bfd.h"
@@ -179,7 +180,7 @@ xtensa_insnbuf_to_chars (xtensa_isa isa,
 /* Inward conversion from byte stream to xtensa_insnbuf.  See
    xtensa_insnbuf_to_chars for a discussion of why this is complicated
    by endianness.  */
 /* Inward conversion from byte stream to xtensa_insnbuf.  See
    xtensa_insnbuf_to_chars for a discussion of why this is complicated
    by endianness.  */
-    
+
 void
 xtensa_insnbuf_from_chars (xtensa_isa isa,
                           xtensa_insnbuf insn,
 void
 xtensa_insnbuf_from_chars (xtensa_isa isa,
                           xtensa_insnbuf insn,
@@ -291,11 +292,12 @@ xtensa_isa_init (xtensa_isa_status *errno_p, char **error_msg_p)
       xtensa_sysreg_internal *sreg = &isa->sysregs[n];
       is_user = sreg->is_user;
 
       xtensa_sysreg_internal *sreg = &isa->sysregs[n];
       is_user = sreg->is_user;
 
-      isa->sysreg_table[is_user][sreg->number] = n;
+      if (sreg->number >= 0)
+       isa->sysreg_table[is_user][sreg->number] = n;
     }
 
   /* Set up the interface lookup table.  */
     }
 
   /* Set up the interface lookup table.  */
-  isa->interface_lookup_table = 
+  isa->interface_lookup_table =
     bfd_malloc (isa->num_interfaces * sizeof (xtensa_lookup_entry));
   CHECK_ALLOC_FOR_INIT (isa->interface_lookup_table, NULL, errno_p,
                        error_msg_p);
     bfd_malloc (isa->num_interfaces * sizeof (xtensa_lookup_entry));
   CHECK_ALLOC_FOR_INIT (isa->interface_lookup_table, NULL, errno_p,
                        error_msg_p);
@@ -308,7 +310,7 @@ xtensa_isa_init (xtensa_isa_status *errno_p, char **error_msg_p)
         sizeof (xtensa_lookup_entry), xtensa_isa_name_compare);
 
   /* Set up the funcUnit lookup table.  */
         sizeof (xtensa_lookup_entry), xtensa_isa_name_compare);
 
   /* Set up the funcUnit lookup table.  */
-  isa->funcUnit_lookup_table = 
+  isa->funcUnit_lookup_table =
     bfd_malloc (isa->num_funcUnits * sizeof (xtensa_lookup_entry));
   CHECK_ALLOC_FOR_INIT (isa->funcUnit_lookup_table, NULL, errno_p,
                        error_msg_p);
     bfd_malloc (isa->num_funcUnits * sizeof (xtensa_lookup_entry));
   CHECK_ALLOC_FOR_INIT (isa->funcUnit_lookup_table, NULL, errno_p,
                        error_msg_p);
@@ -405,12 +407,17 @@ xtensa_isa_length_from_chars (xtensa_isa isa, const unsigned char *cp)
 
 
 int
 
 
 int
-xtensa_isa_num_pipe_stages (xtensa_isa isa) 
+xtensa_isa_num_pipe_stages (xtensa_isa isa)
 {
   xtensa_opcode opcode;
   xtensa_funcUnit_use *use;
   int num_opcodes, num_uses;
 {
   xtensa_opcode opcode;
   xtensa_funcUnit_use *use;
   int num_opcodes, num_uses;
-  int i, stage, max_stage = XTENSA_UNDEFINED;
+  int i, stage;
+  static int max_stage = XTENSA_UNDEFINED;
+
+  /* Only compute the value once.  */
+  if (max_stage != XTENSA_UNDEFINED)
+    return max_stage + 1;
 
   num_opcodes = xtensa_isa_num_opcodes (isa);
   for (opcode = 0; opcode < num_opcodes; opcode++)
 
   num_opcodes = xtensa_isa_num_opcodes (isa);
   for (opcode = 0; opcode < num_opcodes; opcode++)
@@ -538,7 +545,7 @@ xtensa_format_lookup (xtensa_isa isa, const char *fmtname)
       if (strcasecmp (fmtname, intisa->formats[fmt].name) == 0)
        return fmt;
     }
       if (strcasecmp (fmtname, intisa->formats[fmt].name) == 0)
        return fmt;
     }
-  
+
   xtisa_errno = xtensa_isa_bad_format;
   sprintf (xtisa_error_msg, "format \"%s\" not recognized", fmtname);
   return XTENSA_UNDEFINED;
   xtisa_errno = xtensa_isa_bad_format;
   sprintf (xtisa_error_msg, "format \"%s\" not recognized", fmtname);
   return XTENSA_UNDEFINED;
@@ -1022,15 +1029,14 @@ xtensa_operand_encode (xtensa_isa isa, xtensa_opcode opc, int opnd,
   uint32 test_val, orig_val;
 
   intop = get_operand (intisa, opc, opnd);
   uint32 test_val, orig_val;
 
   intop = get_operand (intisa, opc, opnd);
-  if (!intop) return -1;
+  if (!intop)
+    return -1;
 
   if (!intop->encode)
     {
       /* This is a default operand for a field.  How can we tell if the
         value fits in the field?  Write the value into the field,
         read it back, and then make sure we get the same value.  */
 
   if (!intop->encode)
     {
       /* This is a default operand for a field.  How can we tell if the
         value fits in the field?  Write the value into the field,
         read it back, and then make sure we get the same value.  */
-
-      xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
       static xtensa_insnbuf tmpbuf = 0;
       int slot_id;
 
       static xtensa_insnbuf tmpbuf = 0;
       int slot_id;
 
@@ -1075,9 +1081,9 @@ xtensa_operand_encode (xtensa_isa isa, xtensa_opcode opc, int opnd,
      was successfully encoded is to decode it and check if it matches
      the original value.  */
   orig_val = *valp;
      was successfully encoded is to decode it and check if it matches
      the original value.  */
   orig_val = *valp;
-  if ((*intop->encode) (valp) ||
-      (test_val = *valp, (*intop->decode) (&test_val)) ||
-      test_val != orig_val)
+  if ((*intop->encode) (valp)
+      || (test_val = *valp, (*intop->decode) (&test_val))
+      || test_val != orig_val)
     {
       xtisa_errno = xtensa_isa_bad_value;
       sprintf (xtisa_error_msg, "cannot encode operand value 0x%08x", *valp);
     {
       xtisa_errno = xtensa_isa_bad_value;
       sprintf (xtisa_error_msg, "cannot encode operand value 0x%08x", *valp);
@@ -1359,7 +1365,7 @@ xtensa_regfile_lookup (xtensa_isa isa, const char *name)
   /* The expected number of regfiles is small; use a linear search.  */
   for (n = 0; n < intisa->num_regfiles; n++)
     {
   /* The expected number of regfiles is small; use a linear search.  */
   for (n = 0; n < intisa->num_regfiles; n++)
     {
-      if (!strcmp (intisa->regfiles[n].name, name))
+      if (!filename_cmp (intisa->regfiles[n].name, name))
        return n;
     }
 
        return n;
     }
 
@@ -1389,7 +1395,7 @@ xtensa_regfile_lookup_shortname (xtensa_isa isa, const char *shortname)
         as their parents.  */
       if (intisa->regfiles[n].parent != n)
        continue;
         as their parents.  */
       if (intisa->regfiles[n].parent != n)
        continue;
-      if (!strcmp (intisa->regfiles[n].shortname, shortname))
+      if (!filename_cmp (intisa->regfiles[n].shortname, shortname))
        return n;
     }
 
        return n;
     }
 
@@ -1520,6 +1526,17 @@ xtensa_state_is_exported (xtensa_isa isa, xtensa_state st)
 }
 
 
 }
 
 
+int
+xtensa_state_is_shared_or (xtensa_isa isa, xtensa_state st)
+{
+  xtensa_isa_internal *intisa = (xtensa_isa_internal *) isa;
+  CHECK_STATE (intisa, st, XTENSA_UNDEFINED);
+  if ((intisa->states[st].flags & XTENSA_STATE_IS_SHARED_OR) != 0)
+    return 1;
+  return 0;
+}
+
+
 \f
 /* Sysregs.  */
 
 \f
 /* Sysregs.  */
 
This page took 0.025715 seconds and 4 git commands to generate.