]> Git Repo - qemu.git/blobdiff - disas/cris.c
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20210417' into...
[qemu.git] / disas / cris.c
index 9dfb4e3885511061f192d552c0f3c9ee831ede8c..0b0a3fb9165c8046efedbd2446952fd42185dedb 100644 (file)
    You should have received a copy of the GNU General Public License
    along with this program; if not, see <http://www.gnu.org/licenses/>. */
 
-#include "qemu-common.h"
-#include "disas/bfd.h"
-//#include "sysdep.h"
-#include "target-cris/opcode-cris.h"
-//#include "libiberty.h"
+#include "qemu/osdep.h"
+#include "disas/dis-asm.h"
+#include "target/cris/opcode-cris.h"
 
 #define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) == 0)
 
@@ -1210,21 +1208,10 @@ cris_cc_strings[] =
   "le",
   "a",
   /* This is a placeholder.  In v0, this would be "ext".  In v32, this
-     is "sb".  See cris_conds15.  */
+     is "sb". */
   "wf"
 };
 
-/* Different names and semantics for condition 1111 (0xf).  */
-const struct cris_cond15 cris_cond15s[] =
-{
-  /* FIXME: In what version did condition "ext" disappear?  */
-  {"ext", cris_ver_v0_3},
-  {"wf", cris_ver_v10},
-  {"sb", cris_ver_v32p},
-  {NULL, 0}
-};
-
-
 /*
  * Local variables:
  * eval: (c-set-style "gnu")
@@ -1307,24 +1294,17 @@ static int cris_constraint
 /* Parse disassembler options and store state in info.  FIXME: For the
    time being, we abuse static variables.  */
 
-static bfd_boolean
-cris_parse_disassembler_options (disassemble_info *info,
+static void
+cris_parse_disassembler_options (struct cris_disasm_data *disdata,
+                                char *disassembler_options,
                                 enum cris_disass_family distype)
 {
-  struct cris_disasm_data *disdata;
-
-  info->private_data = calloc (1, sizeof (struct cris_disasm_data));
-  disdata = (struct cris_disasm_data *) info->private_data;
-  if (disdata == NULL)
-    return false;
-
   /* Default true.  */
   disdata->trace_case
-    = (info->disassembler_options == NULL
-       || (strcmp (info->disassembler_options, "nocase") != 0));
+    = (disassembler_options == NULL
+       || (strcmp (disassembler_options, "nocase") != 0));
 
   disdata->distype = distype;
-  return true;
 }
 
 static const struct cris_spec_reg *
@@ -2021,7 +2001,7 @@ print_with_operands (const struct cris_opcode *opcodep,
       case 'n':
        {
          /* Like N but pc-relative to the start of the insn.  */
-         unsigned long number
+         uint32_t number
            = (buffer[2] + buffer[3] * 256 + buffer[4] * 65536
               + buffer[5] * 0x1000000 + addr);
 
@@ -2060,7 +2040,7 @@ print_with_operands (const struct cris_opcode *opcodep,
          {
            /* We're looking at [pc+], i.e. we need to output an immediate
               number, where the size can depend on different things.  */
-           long number;
+           int32_t number;
            int signedp
              = ((*cs == 'z' && (insn & 0x20))
                 || opcodep->match == BDAP_QUICK_OPCODE);
@@ -2213,7 +2193,7 @@ print_with_operands (const struct cris_opcode *opcodep,
                      {
                        /* It's [pc+].  This cannot possibly be anything
                           but an address.  */
-                       unsigned long number
+                       uint32_t number
                          = prefix_buffer[2] + prefix_buffer[3] * 256
                          + prefix_buffer[4] * 65536
                          + prefix_buffer[5] * 0x1000000;
@@ -2302,7 +2282,7 @@ print_with_operands (const struct cris_opcode *opcodep,
 
                    if ((prefix_insn & 0x400) && (prefix_insn & 15) == 15)
                      {
-                       long number;
+                       int32_t number;
                        unsigned int nbytes;
 
                        /* It's a value.  Get its size.  */
@@ -2502,8 +2482,8 @@ print_with_operands (const struct cris_opcode *opcodep,
        const struct cris_spec_reg *sregp
          = spec_reg_info ((insn >> 12) & 15, disdata->distype);
 
-       if (sregp->name == NULL)
-         /* Should have been caught as a non-match eariler.  */
+       if (sregp == NULL || sregp->name == NULL)
+         /* Should have been caught as a non-match earlier.  */
          *tp++ = '?';
        else
          {
@@ -2586,9 +2566,9 @@ print_insn_cris_generic (bfd_vma memaddr,
      If we can't get any data, or we do not get enough data, we print
      the error message.  */
 
-  nbytes = info->buffer_length;
-  if (nbytes > MAX_BYTES_PER_CRIS_INSN)
-         nbytes = MAX_BYTES_PER_CRIS_INSN;
+  nbytes = info->buffer_length ? info->buffer_length
+                               : MAX_BYTES_PER_CRIS_INSN;
+  nbytes = MIN(nbytes, MAX_BYTES_PER_CRIS_INSN);
   status = (*info->read_memory_func) (memaddr, buffer, nbytes, info);  
 
   /* If we did not get all we asked for, then clear the rest.
@@ -2749,9 +2729,10 @@ static int
 print_insn_cris_with_register_prefix (bfd_vma vma,
                                      disassemble_info *info)
 {
-  if (info->private_data == NULL
-      && !cris_parse_disassembler_options (info, cris_dis_v0_v10))
-    return -1;
+  struct cris_disasm_data disdata;
+  info->private_data = &disdata;
+  cris_parse_disassembler_options (&disdata, info->disassembler_options,
+                                  cris_dis_v0_v10);
   return print_insn_cris_generic (vma, info, true);
 }
 /* Disassemble, prefixing register names with `$'.  CRIS v32.  */
@@ -2760,9 +2741,10 @@ static int
 print_insn_crisv32_with_register_prefix (bfd_vma vma,
                                         disassemble_info *info)
 {
-  if (info->private_data == NULL
-      && !cris_parse_disassembler_options (info, cris_dis_v32))
-    return -1;
+  struct cris_disasm_data disdata;
+  info->private_data = &disdata;
+  cris_parse_disassembler_options (&disdata, info->disassembler_options,
+                                  cris_dis_v32);
   return print_insn_cris_generic (vma, info, true);
 }
 
@@ -2774,9 +2756,10 @@ static int
 print_insn_crisv10_v32_with_register_prefix (bfd_vma vma,
                                             disassemble_info *info)
 {
-  if (info->private_data == NULL
-      && !cris_parse_disassembler_options (info, cris_dis_common_v10_v32))
-    return -1;
+  struct cris_disasm_data disdata;
+  info->private_data = &disdata;
+  cris_parse_disassembler_options (&disdata, info->disassembler_options,
+                                  cris_dis_common_v10_v32);
   return print_insn_cris_generic (vma, info, true);
 }
 
@@ -2786,9 +2769,10 @@ static int
 print_insn_cris_without_register_prefix (bfd_vma vma,
                                         disassemble_info *info)
 {
-  if (info->private_data == NULL
-      && !cris_parse_disassembler_options (info, cris_dis_v0_v10))
-    return -1;
+  struct cris_disasm_data disdata;
+  info->private_data = &disdata;
+  cris_parse_disassembler_options (&disdata, info->disassembler_options,
+                                  cris_dis_v0_v10);
   return print_insn_cris_generic (vma, info, false);
 }
 
@@ -2798,9 +2782,10 @@ static int
 print_insn_crisv32_without_register_prefix (bfd_vma vma,
                                            disassemble_info *info)
 {
-  if (info->private_data == NULL
-      && !cris_parse_disassembler_options (info, cris_dis_v32))
-    return -1;
+  struct cris_disasm_data disdata;
+  info->private_data = &disdata;
+  cris_parse_disassembler_options (&disdata, info->disassembler_options,
+                                  cris_dis_v32);
   return print_insn_cris_generic (vma, info, false);
 }
 
@@ -2811,9 +2796,10 @@ static int
 print_insn_crisv10_v32_without_register_prefix (bfd_vma vma,
                                                disassemble_info *info)
 {
-  if (info->private_data == NULL
-      && !cris_parse_disassembler_options (info, cris_dis_common_v10_v32))
-    return -1;
+  struct cris_disasm_data disdata;
+  info->private_data = &disdata;
+  cris_parse_disassembler_options (&disdata, info->disassembler_options,
+                                  cris_dis_common_v10_v32);
   return print_insn_cris_generic (vma, info, false);
 }
 #endif
This page took 0.030683 seconds and 4 git commands to generate.