Power10 SIMD permute class operations
[deliverable/binutils-gdb.git] / opcodes / s12z-dis.c
index d4d5fd7217f03523d2f4a21c8a0998cd768d98e9..46d4d7c64cf99bf600ab1a84cee7758e17406524 100644 (file)
@@ -1,5 +1,5 @@
 /* s12z-dis.c -- Freescale S12Z disassembly
-   Copyright (C) 2018-2019 Free Software Foundation, Inc.
+   Copyright (C) 2018-2020 Free Software Foundation, Inc.
 
    This file is part of the GNU opcodes library.
 
 #include <assert.h>
 
 #include "opcode/s12z.h"
-
 #include "bfd.h"
 #include "dis-asm.h"
-
 #include "disassemble.h"
-
 #include "s12z-opc.h"
+#include "opintl.h"
 
 struct mem_read_abstraction
 {
@@ -61,16 +59,9 @@ abstract_read_memory (struct mem_read_abstraction_base *b,
 {
   struct mem_read_abstraction *mra = (struct mem_read_abstraction *) b;
 
-  int status =
-    (*mra->info->read_memory_func) (mra->memaddr + offset,
-                                   bytes, n, mra->info);
-
-  if (status != 0)
-    {
-      (*mra->info->memory_error_func) (status, mra->memaddr, mra->info);
-      return -1;
-    }
-  return 0;
+  int status = (*mra->info->read_memory_func) (mra->memaddr + offset,
+                                              bytes, n, mra->info);
+  return status != 0 ? -1 : 0;
 }
 
 /* Start of disassembly file.  */
@@ -255,7 +246,11 @@ opr_emit_disassembly (const struct operand *opr,
     case OPND_CL_REGISTER:
       {
         int r = ((struct register_operand*) opr)->reg;
-       (*info->fprintf_func) (info->stream, "%s", registers[r].name);
+
+       if (r < 0 || r >= S12Z_N_REGISTERS)
+         (*info->fprintf_func) (info->stream, _("<illegal reg num>"));
+       else
+         (*info->fprintf_func) (info->stream, "%s", registers[r].name);
       }
       break;
     case OPND_CL_REGISTER_ALL16:
@@ -306,14 +301,25 @@ opr_emit_disassembly (const struct operand *opr,
            break;
          }
        if (mo->n_regs > 0)
-         (*info->fprintf_func) (info->stream, fmt,
-                                registers[mo->regs[0]].name);
+         {
+           int r = mo->regs[0];
+
+           if (r < 0 || r >= S12Z_N_REGISTERS)
+             (*info->fprintf_func) (info->stream, fmt, _("<illegal reg num>"));
+           else
+             (*info->fprintf_func) (info->stream, fmt, registers[r].name);
+         }
        used_reg = 1;
 
         if (mo->n_regs > used_reg)
           {
-            (*info->fprintf_func) (info->stream, ",%s",
-                                  registers[mo->regs[used_reg]].name);
+           int r = mo->regs[used_reg];
+
+           if (r < 0 || r >= S12Z_N_REGISTERS)
+             (*info->fprintf_func) (info->stream, _("<illegal reg num>"));
+           else
+             (*info->fprintf_func) (info->stream, ",%s",
+                                    registers[r].name);
           }
 
        (*info->fprintf_func) (info->stream, "%c",
@@ -323,7 +329,9 @@ opr_emit_disassembly (const struct operand *opr,
     };
 }
 
-static const char shift_size_table[] = {
+#define S12Z_N_SIZES 4
+static const char shift_size_table[S12Z_N_SIZES] =
+{
   'b', 'w', 'p', 'l'
 };
 
@@ -331,7 +339,7 @@ int
 print_insn_s12z (bfd_vma memaddr, struct disassemble_info* info)
 {
   int o;
-  enum operator operator = OP_INVALID;
+  enum optr operator = OP_INVALID;
   int n_operands = 0;
 
   /* The longest instruction in S12Z can have 6 operands.
@@ -357,6 +365,7 @@ print_insn_s12z (bfd_vma memaddr, struct disassemble_info* info)
   if (osize == -1)
     {
       bool suffix = false;
+
       for (o = 0; o < n_operands; ++o)
        {
          if (operands[o] && operands[o]->osize != -1)
@@ -366,18 +375,26 @@ print_insn_s12z (bfd_vma memaddr, struct disassemble_info* info)
                  (*mra.info->fprintf_func) (mra.info->stream, "%c", '.');
                  suffix = true;
                }
-             (*mra.info->fprintf_func) (mra.info->stream, "%c",
-                                    shift_size_table[operands[o]->osize]);
+
+             osize = operands[o]->osize;
+
+             if (osize < 0 || osize >= S12Z_N_SIZES)
+               (*mra.info->fprintf_func) (mra.info->stream, _("<bad>"));
+             else
+               (*mra.info->fprintf_func) (mra.info->stream, "%c",
+                                          shift_size_table[osize]);
            }
        }
     }
   else
     {
-      (*mra.info->fprintf_func) (mra.info->stream, ".%c",
-                            shift_size_table[osize]);
+      if (osize < 0 || osize >= S12Z_N_SIZES)
+       (*mra.info->fprintf_func) (mra.info->stream, _(".<bad>"));
+      else
+       (*mra.info->fprintf_func) (mra.info->stream, ".%c",
+                                  shift_size_table[osize]);
     }
 
-
   /* Ship out the operands.  */
   for (o = 0; o < n_operands; ++o)
     {
This page took 0.027997 seconds and 4 git commands to generate.