Implement Read/Write constraints on system registers on AArch64
[deliverable/binutils-gdb.git] / opcodes / aarch64-dis.c
index e5fe61f51d13e06342947437ec80731f692e2628..b9c15594c01030edc0493c69c5bfcb00fc134507 100644 (file)
@@ -1,5 +1,5 @@
 /* aarch64-dis.c -- AArch64 disassembler.
-   Copyright (C) 2009-2017 Free Software Foundation, Inc.
+   Copyright (C) 2009-2018 Free Software Foundation, Inc.
    Contributed by ARM Ltd.
 
    This file is part of the GNU opcodes library.
@@ -20,7 +20,7 @@
 
 #include "sysdep.h"
 #include "bfd_stdint.h"
-#include "dis-asm.h"
+#include "disassemble.h"
 #include "libiberty.h"
 #include "opintl.h"
 #include "aarch64-dis.h"
@@ -46,7 +46,8 @@ static bfd_vma last_mapping_addr = 0;
 
 /* Other options */
 static int no_aliases = 0;     /* If set disassemble as most general inst.  */
-\f
+\fstatic int no_notes = 1;      /* If set do not print disassemble notes in the
+                                 output as comments.  */
 
 static void
 set_default_aarch64_dis_options (struct disassemble_info *info ATTRIBUTE_UNUSED)
@@ -69,6 +70,18 @@ parse_aarch64_dis_option (const char *option, unsigned int len ATTRIBUTE_UNUSED)
       return;
     }
 
+  if (CONST_STRNEQ (option, "no-notes"))
+    {
+      no_notes = 1;
+      return;
+    }
+
+  if (CONST_STRNEQ (option, "notes"))
+    {
+      no_notes = 0;
+      return;
+    }
+
 #ifdef DEBUG_AARCH64
   if (CONST_STRNEQ (option, "debug_dump"))
     {
@@ -78,7 +91,7 @@ parse_aarch64_dis_option (const char *option, unsigned int len ATTRIBUTE_UNUSED)
 #endif /* DEBUG_AARCH64 */
 
   /* Invalid option.  */
-  fprintf (stderr, _("Unrecognised disassembler option: %s\n"), option);
+  opcodes_error_handler (_("unrecognised disassembler option: %s"), option);
 }
 
 static void
@@ -242,31 +255,34 @@ get_expected_qualifier (const aarch64_inst *inst, int i)
 
 /* Operand extractors.  */
 
-int
+bfd_boolean
 aarch64_ext_regno (const aarch64_operand *self, aarch64_opnd_info *info,
                   const aarch64_insn code,
-                  const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                  const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                  aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   info->reg.regno = extract_field (self->fields[0], code, 0);
-  return 1;
+  return TRUE;
 }
 
-int
+bfd_boolean
 aarch64_ext_regno_pair (const aarch64_operand *self ATTRIBUTE_UNUSED, aarch64_opnd_info *info,
                   const aarch64_insn code ATTRIBUTE_UNUSED,
-                  const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                  const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                  aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   assert (info->idx == 1
          || info->idx ==3);
   info->reg.regno = inst->operands[info->idx - 1].reg.regno + 1;
-  return 1;
+  return TRUE;
 }
 
 /* e.g. IC <ic_op>{, <Xt>}.  */
-int
+bfd_boolean
 aarch64_ext_regrt_sysins (const aarch64_operand *self, aarch64_opnd_info *info,
                          const aarch64_insn code,
-                         const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                         const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                         aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   info->reg.regno = extract_field (self->fields[0], code, 0);
   assert (info->idx == 1
@@ -277,14 +293,15 @@ aarch64_ext_regrt_sysins (const aarch64_operand *self, aarch64_opnd_info *info,
      not.  */
   info->present = aarch64_sys_ins_reg_has_xt (inst->operands[0].sysins_op);
 
-  return 1;
+  return TRUE;
 }
 
 /* e.g. SQDMLAL <Va><d>, <Vb><n>, <Vm>.<Ts>[<index>].  */
-int
+bfd_boolean
 aarch64_ext_reglane (const aarch64_operand *self, aarch64_opnd_info *info,
                     const aarch64_insn code,
-                    const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                    const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                    aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   /* regno */
   info->reglane.regno = extract_field (self->fields[0], code,
@@ -320,11 +337,31 @@ aarch64_ext_reglane (const aarch64_operand *self, aarch64_opnd_info *info,
          while (++pos <= 3 && (value & 0x1) == 0)
            value >>= 1;
          if (pos > 3)
-           return 0;
+           return FALSE;
          info->qualifier = get_sreg_qualifier_from_value (pos);
          info->reglane.index = (unsigned) (value >> 1);
        }
     }
+  else if (inst->opcode->iclass == dotproduct)
+    {
+      /* Need information in other operand(s) to help decoding.  */
+      info->qualifier = get_expected_qualifier (inst, info->idx);
+      switch (info->qualifier)
+       {
+       case AARCH64_OPND_QLF_S_4B:
+         /* L:H */
+         info->reglane.index = extract_fields (code, 0, 2, FLD_H, FLD_L);
+         info->reglane.regno &= 0x1f;
+         break;
+       default:
+         return FALSE;
+       }
+    }
+  else if (inst->opcode->iclass == cryptosm3)
+    {
+      /* index for e.g. SM3TT2A <Vd>.4S, <Vn>.4S, <Vm>S[<imm2>].  */
+      info->reglane.index = extract_field (FLD_SM3_imm2, code, 0);
+    }
   else
     {
       /* Index only for e.g. SQDMLAL <Va><d>, <Vb><n>, <Vm>.<Ts>[<index>]
@@ -349,38 +386,40 @@ aarch64_ext_reglane (const aarch64_operand *self, aarch64_opnd_info *info,
          info->reglane.index = extract_field (FLD_H, code, 0);
          break;
        default:
-         return 0;
+         return FALSE;
        }
 
       if (inst->opcode->op == OP_FCMLA_ELEM)
        {
          /* Complex operand takes two elements.  */
          if (info->reglane.index & 1)
-           return 0;
+           return FALSE;
          info->reglane.index /= 2;
        }
     }
 
-  return 1;
+  return TRUE;
 }
 
-int
+bfd_boolean
 aarch64_ext_reglist (const aarch64_operand *self, aarch64_opnd_info *info,
                     const aarch64_insn code,
-                    const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                    const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                    aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   /* R */
   info->reglist.first_regno = extract_field (self->fields[0], code, 0);
   /* len */
   info->reglist.num_regs = extract_field (FLD_len, code, 0) + 1;
-  return 1;
+  return TRUE;
 }
 
 /* Decode Rt and opcode fields of Vt in AdvSIMD load/store instructions.  */
-int
+bfd_boolean
 aarch64_ext_ldst_reglist (const aarch64_operand *self ATTRIBUTE_UNUSED,
                          aarch64_opnd_info *info, const aarch64_insn code,
-                         const aarch64_inst *inst)
+                         const aarch64_inst *inst,
+                         aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   aarch64_insn value;
   /* Number of elements in each structure to be loaded/stored.  */
@@ -409,19 +448,23 @@ aarch64_ext_ldst_reglist (const aarch64_operand *self ATTRIBUTE_UNUSED,
   info->reglist.first_regno = extract_field (FLD_Rt, code, 0);
   /* opcode */
   value = extract_field (FLD_opcode, code, 0);
+  /* PR 21595: Check for a bogus value.  */
+  if (value >= ARRAY_SIZE (data))
+    return FALSE;
   if (expected_num != data[value].num_elements || data[value].is_reserved)
-    return 0;
+    return FALSE;
   info->reglist.num_regs = data[value].num_regs;
 
-  return 1;
+  return TRUE;
 }
 
 /* Decode Rt and S fields of Vt in AdvSIMD load single structure to all
    lanes instructions.  */
-int
+bfd_boolean
 aarch64_ext_ldst_reglist_r (const aarch64_operand *self ATTRIBUTE_UNUSED,
                            aarch64_opnd_info *info, const aarch64_insn code,
-                           const aarch64_inst *inst)
+                           const aarch64_inst *inst,
+                           aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   aarch64_insn value;
 
@@ -439,15 +482,16 @@ aarch64_ext_ldst_reglist_r (const aarch64_operand *self ATTRIBUTE_UNUSED,
   if (info->reglist.num_regs == 1 && value == (aarch64_insn) 1)
     info->reglist.num_regs = 2;
 
-  return 1;
+  return TRUE;
 }
 
 /* Decode Q, opcode<2:1>, S, size and Rt fields of Vt in AdvSIMD
    load/store single element instructions.  */
-int
+bfd_boolean
 aarch64_ext_ldst_elemlist (const aarch64_operand *self ATTRIBUTE_UNUSED,
                           aarch64_opnd_info *info, const aarch64_insn code,
-                          const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                          const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                          aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   aarch64_field field = {0, 0};
   aarch64_insn QSsize;         /* fields Q:S:size.  */
@@ -470,7 +514,7 @@ aarch64_ext_ldst_elemlist (const aarch64_operand *self ATTRIBUTE_UNUSED,
     case 0x1:
       if (QSsize & 0x1)
        /* UND.  */
-       return 0;
+       return FALSE;
       info->qualifier = AARCH64_OPND_QLF_S_H;
       /* Index encoded in "Q:S:size<1>".  */
       info->reglist.index = QSsize >> 1;
@@ -478,7 +522,7 @@ aarch64_ext_ldst_elemlist (const aarch64_operand *self ATTRIBUTE_UNUSED,
     case 0x2:
       if ((QSsize >> 1) & 0x1)
        /* UND.  */
-       return 0;
+       return FALSE;
       if ((QSsize & 0x1) == 0)
        {
          info->qualifier = AARCH64_OPND_QLF_S_S;
@@ -489,14 +533,14 @@ aarch64_ext_ldst_elemlist (const aarch64_operand *self ATTRIBUTE_UNUSED,
        {
          if (extract_field (FLD_S, code, 0))
            /* UND */
-           return 0;
+           return FALSE;
          info->qualifier = AARCH64_OPND_QLF_S_D;
          /* Index encoded in "Q".  */
          info->reglist.index = QSsize >> 3;
        }
       break;
     default:
-      return 0;
+      return FALSE;
     }
 
   info->reglist.has_index = 1;
@@ -506,17 +550,18 @@ aarch64_ext_ldst_elemlist (const aarch64_operand *self ATTRIBUTE_UNUSED,
   info->reglist.num_regs = get_opcode_dependent_value (inst->opcode);
   assert (info->reglist.num_regs >= 1 && info->reglist.num_regs <= 4);
 
-  return 1;
+  return TRUE;
 }
 
 /* Decode fields immh:immb and/or Q for e.g.
    SSHR <Vd>.<T>, <Vn>.<T>, #<shift>
    or SSHR <V><d>, <V><n>, #<shift>.  */
 
-int
+bfd_boolean
 aarch64_ext_advsimd_imm_shift (const aarch64_operand *self ATTRIBUTE_UNUSED,
                               aarch64_opnd_info *info, const aarch64_insn code,
-                              const aarch64_inst *inst)
+                              const aarch64_inst *inst,
+                              aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   int pos;
   aarch64_insn Q, imm, immh;
@@ -524,7 +569,7 @@ aarch64_ext_advsimd_imm_shift (const aarch64_operand *self ATTRIBUTE_UNUSED,
 
   immh = extract_field (FLD_immh, code, 0);
   if (immh == 0)
-    return 0;
+    return FALSE;
   imm = extract_fields (code, 0, 2, FLD_immh, FLD_immb);
   pos = 4;
   /* Get highest set bit in immh.  */
@@ -572,14 +617,15 @@ aarch64_ext_advsimd_imm_shift (const aarch64_operand *self ATTRIBUTE_UNUSED,
        1xxx    (UInt(immh:immb)-64)  */
     info->imm.value = imm - (8 << pos);
 
-  return 1;
+  return TRUE;
 }
 
 /* Decode shift immediate for e.g. sshr (imm).  */
-int
+bfd_boolean
 aarch64_ext_shll_imm (const aarch64_operand *self ATTRIBUTE_UNUSED,
                      aarch64_opnd_info *info, const aarch64_insn code,
-                     const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                     const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                     aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   int64_t imm;
   aarch64_insn val;
@@ -589,18 +635,19 @@ aarch64_ext_shll_imm (const aarch64_operand *self ATTRIBUTE_UNUSED,
     case 0: imm = 8; break;
     case 1: imm = 16; break;
     case 2: imm = 32; break;
-    default: return 0;
+    default: return FALSE;
     }
   info->imm.value = imm;
-  return 1;
+  return TRUE;
 }
 
 /* Decode imm for e.g. BFM <Wd>, <Wn>, #<immr>, #<imms>.
    value in the field(s) will be extracted as unsigned immediate value.  */
-int
+bfd_boolean
 aarch64_ext_imm (const aarch64_operand *self, aarch64_opnd_info *info,
                 const aarch64_insn code,
-                const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   int64_t imm;
 
@@ -616,28 +663,30 @@ aarch64_ext_imm (const aarch64_operand *self, aarch64_opnd_info *info,
     imm <<= 12;
 
   info->imm.value = imm;
-  return 1;
+  return TRUE;
 }
 
 /* Decode imm and its shifter for e.g. MOVZ <Wd>, #<imm16>{, LSL #<shift>}.  */
-int
+bfd_boolean
 aarch64_ext_imm_half (const aarch64_operand *self, aarch64_opnd_info *info,
                      const aarch64_insn code,
-                     const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                     const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                     aarch64_operand_error *errors)
 {
-  aarch64_ext_imm (self, info, code, inst);
+  aarch64_ext_imm (self, info, code, inst, errors);
   info->shifter.kind = AARCH64_MOD_LSL;
   info->shifter.amount = extract_field (FLD_hw, code, 0) << 4;
-  return 1;
+  return TRUE;
 }
 
 /* Decode cmode and "a:b:c:d:e:f:g:h" for e.g.
      MOVI <Vd>.<T>, #<imm8> {, LSL #<amount>}.  */
-int
+bfd_boolean
 aarch64_ext_advsimd_imm_modified (const aarch64_operand *self ATTRIBUTE_UNUSED,
                                  aarch64_opnd_info *info,
                                  const aarch64_insn code,
-                                 const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                                 const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                                 aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   uint64_t imm;
   enum aarch64_opnd_qualifier opnd0_qualifier = inst->operands[0].qualifier;
@@ -681,7 +730,7 @@ aarch64_ext_advsimd_imm_modified (const aarch64_operand *self ATTRIBUTE_UNUSED,
        case 4: gen_sub_field (FLD_cmode, 1, 2, &field); break; /* per word */
        case 2: gen_sub_field (FLD_cmode, 1, 1, &field); break; /* per half */
        case 1: gen_sub_field (FLD_cmode, 1, 0, &field); break; /* per byte */
-       default: assert (0); return 0;
+       default: assert (0); return FALSE;
        }
       /* 00: 0; 01: 8; 10:16; 11:24.  */
       info->shifter.amount = extract_field_2 (&field, code, 0) << 3;
@@ -694,63 +743,68 @@ aarch64_ext_advsimd_imm_modified (const aarch64_operand *self ATTRIBUTE_UNUSED,
       break;
     default:
       assert (0);
-      return 0;
+      return FALSE;
     }
 
-  return 1;
+  return TRUE;
 }
 
 /* Decode an 8-bit floating-point immediate.  */
-int
+bfd_boolean
 aarch64_ext_fpimm (const aarch64_operand *self, aarch64_opnd_info *info,
                   const aarch64_insn code,
-                  const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                  const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                  aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   info->imm.value = extract_all_fields (self, code);
   info->imm.is_fp = 1;
-  return 1;
+  return TRUE;
 }
 
 /* Decode a 1-bit rotate immediate (#90 or #270).  */
-int
+bfd_boolean
 aarch64_ext_imm_rotate1 (const aarch64_operand *self, aarch64_opnd_info *info,
                         const aarch64_insn code,
-                        const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                        const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                        aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   uint64_t rot = extract_field (self->fields[0], code, 0);
   assert (rot < 2U);
   info->imm.value = rot * 180 + 90;
-  return 1;
+  return TRUE;
 }
 
 /* Decode a 2-bit rotate immediate (#0, #90, #180 or #270).  */
-int
+bfd_boolean
 aarch64_ext_imm_rotate2 (const aarch64_operand *self, aarch64_opnd_info *info,
                         const aarch64_insn code,
-                        const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                        const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                        aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   uint64_t rot = extract_field (self->fields[0], code, 0);
   assert (rot < 4U);
   info->imm.value = rot * 90;
-  return 1;
+  return TRUE;
 }
 
 /* Decode scale for e.g. SCVTF <Dd>, <Wn>, #<fbits>.  */
-int
+bfd_boolean
 aarch64_ext_fbits (const aarch64_operand *self ATTRIBUTE_UNUSED,
                   aarch64_opnd_info *info, const aarch64_insn code,
-                  const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                  const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                  aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   info->imm.value = 64- extract_field (FLD_scale, code, 0);
-  return 1;
+  return TRUE;
 }
 
 /* Decode arithmetic immediate for e.g.
      SUBS <Wd>, <Wn|WSP>, #<imm> {, <shift>}.  */
-int
+bfd_boolean
 aarch64_ext_aimm (const aarch64_operand *self ATTRIBUTE_UNUSED,
                  aarch64_opnd_info *info, const aarch64_insn code,
-                 const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                 const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                 aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   aarch64_insn value;
 
@@ -758,18 +812,18 @@ aarch64_ext_aimm (const aarch64_operand *self ATTRIBUTE_UNUSED,
   /* shift */
   value = extract_field (FLD_shift, code, 0);
   if (value >= 2)
-    return 0;
+    return FALSE;
   info->shifter.amount = value ? 12 : 0;
   /* imm12 (unsigned) */
   info->imm.value = extract_field (FLD_imm12, code, 0);
 
-  return 1;
+  return TRUE;
 }
 
 /* Return true if VALUE is a valid logical immediate encoding, storing the
    decoded value in *RESULT if so.  ESIZE is the number of bytes in the
    decoded immediate.  */
-static int
+static bfd_boolean
 decode_limm (uint32_t esize, aarch64_insn value, int64_t *result)
 {
   uint64_t imm, mask;
@@ -797,7 +851,7 @@ decode_limm (uint32_t esize, aarch64_insn value, int64_t *result)
        case 0x30 ... 0x37: /* 110xxx */ simd_size =  8; S &= 0x7; break;
        case 0x38 ... 0x3b: /* 1110xx */ simd_size =  4; S &= 0x3; break;
        case 0x3c ... 0x3d: /* 11110x */ simd_size =  2; S &= 0x1; break;
-       default: return 0;
+       default: return FALSE;
        }
       mask = (1ull << simd_size) - 1;
       /* Top bits are IGNORED.  */
@@ -805,11 +859,11 @@ decode_limm (uint32_t esize, aarch64_insn value, int64_t *result)
     }
 
   if (simd_size > esize * 8)
-    return 0;
+    return FALSE;
 
   /* NOTE: if S = simd_size - 1 we get 0xf..f which is rejected.  */
   if (S == simd_size - 1)
-    return 0;
+    return FALSE;
   /* S+1 consecutive bits to 1.  */
   /* NOTE: S can't be 63 due to detection above.  */
   imm = (1ull << (S + 1)) - 1;
@@ -835,14 +889,15 @@ decode_limm (uint32_t esize, aarch64_insn value, int64_t *result)
 
   *result = imm & ~((uint64_t) -1 << (esize * 4) << (esize * 4));
 
-  return 1;
+  return TRUE;
 }
 
 /* Decode a logical immediate for e.g. ORR <Wd|WSP>, <Wn>, #<imm>.  */
-int
+bfd_boolean
 aarch64_ext_limm (const aarch64_operand *self,
                  aarch64_opnd_info *info, const aarch64_insn code,
-                 const aarch64_inst *inst)
+                 const aarch64_inst *inst,
+                 aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   uint32_t esize;
   aarch64_insn value;
@@ -854,23 +909,25 @@ aarch64_ext_limm (const aarch64_operand *self,
 }
 
 /* Decode a logical immediate for the BIC alias of AND (etc.).  */
-int
+bfd_boolean
 aarch64_ext_inv_limm (const aarch64_operand *self,
                      aarch64_opnd_info *info, const aarch64_insn code,
-                     const aarch64_inst *inst)
+                     const aarch64_inst *inst,
+                     aarch64_operand_error *errors)
 {
-  if (!aarch64_ext_limm (self, info, code, inst))
-    return 0;
+  if (!aarch64_ext_limm (self, info, code, inst, errors))
+    return FALSE;
   info->imm.value = ~info->imm.value;
-  return 1;
+  return TRUE;
 }
 
 /* Decode Ft for e.g. STR <Qt>, [<Xn|SP>, <R><m>{, <extend> {<amount>}}]
    or LDP <Qt1>, <Qt2>, [<Xn|SP>], #<imm>.  */
-int
+bfd_boolean
 aarch64_ext_ft (const aarch64_operand *self ATTRIBUTE_UNUSED,
                aarch64_opnd_info *info,
-               const aarch64_insn code, const aarch64_inst *inst)
+               const aarch64_insn code, const aarch64_inst *inst,
+               aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   aarch64_insn value;
 
@@ -890,7 +947,7 @@ aarch64_ext_ft (const aarch64_operand *self ATTRIBUTE_UNUSED,
        case 0: qualifier = AARCH64_OPND_QLF_S_S; break;
        case 1: qualifier = AARCH64_OPND_QLF_S_D; break;
        case 2: qualifier = AARCH64_OPND_QLF_S_Q; break;
-       default: return 0;
+       default: return FALSE;
        }
       info->qualifier = qualifier;
     }
@@ -899,31 +956,56 @@ aarch64_ext_ft (const aarch64_operand *self ATTRIBUTE_UNUSED,
       /* opc1:size */
       value = extract_fields (code, 0, 2, FLD_opc1, FLD_ldst_size);
       if (value > 0x4)
-       return 0;
+       return FALSE;
       info->qualifier = get_sreg_qualifier_from_value (value);
     }
 
-  return 1;
+  return TRUE;
 }
 
 /* Decode the address operand for e.g. STXRB <Ws>, <Wt>, [<Xn|SP>{,#0}].  */
-int
+bfd_boolean
 aarch64_ext_addr_simple (const aarch64_operand *self ATTRIBUTE_UNUSED,
                         aarch64_opnd_info *info,
                         aarch64_insn code,
-                        const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                        const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                        aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   /* Rn */
   info->addr.base_regno = extract_field (FLD_Rn, code, 0);
-  return 1;
+  return TRUE;
+}
+
+/* Decode the address operand for e.g.
+     stlur <Xt>, [<Xn|SP>{, <amount>}].  */
+bfd_boolean
+aarch64_ext_addr_offset (const aarch64_operand *self ATTRIBUTE_UNUSED,
+                        aarch64_opnd_info *info,
+                        aarch64_insn code, const aarch64_inst *inst,
+                        aarch64_operand_error *errors ATTRIBUTE_UNUSED)
+{
+  info->qualifier = get_expected_qualifier (inst, info->idx);
+
+  /* Rn */
+  info->addr.base_regno = extract_field (self->fields[0], code, 0);
+
+  /* simm9 */
+  aarch64_insn imm = extract_fields (code, 0, 1, self->fields[1]);
+  info->addr.offset.imm = sign_extend (imm, 8);
+  if (extract_field (self->fields[2], code, 0) == 1) {
+    info->addr.writeback = 1;
+    info->addr.preind = 1;
+  }
+  return TRUE;
 }
 
 /* Decode the address operand for e.g.
      STR <Qt>, [<Xn|SP>, <R><m>{, <extend> {<amount>}}].  */
-int
+bfd_boolean
 aarch64_ext_addr_regoff (const aarch64_operand *self ATTRIBUTE_UNUSED,
                         aarch64_opnd_info *info,
-                        aarch64_insn code, const aarch64_inst *inst)
+                        aarch64_insn code, const aarch64_inst *inst,
+                        aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   aarch64_insn S, value;
 
@@ -959,13 +1041,14 @@ aarch64_ext_addr_regoff (const aarch64_operand *self ATTRIBUTE_UNUSED,
       info->shifter.amount_present = 1;
     }
 
-  return 1;
+  return TRUE;
 }
 
 /* Decode the address operand for e.g. LDRSW <Xt>, [<Xn|SP>], #<simm>.  */
-int
+bfd_boolean
 aarch64_ext_addr_simm (const aarch64_operand *self, aarch64_opnd_info *info,
-                      aarch64_insn code, const aarch64_inst *inst)
+                      aarch64_insn code, const aarch64_inst *inst,
+                      aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   aarch64_insn imm;
   info->qualifier = get_expected_qualifier (inst, info->idx);
@@ -994,14 +1077,15 @@ aarch64_ext_addr_simm (const aarch64_operand *self, aarch64_opnd_info *info,
        info->addr.postind = 1;
     }
 
-  return 1;
+  return TRUE;
 }
 
 /* Decode the address operand for e.g. LDRSW <Xt>, [<Xn|SP>{, #<simm>}].  */
-int
+bfd_boolean
 aarch64_ext_addr_uimm12 (const aarch64_operand *self, aarch64_opnd_info *info,
                         aarch64_insn code,
-                        const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                        const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                        aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   int shift;
   info->qualifier = get_expected_qualifier (inst, info->idx);
@@ -1010,14 +1094,15 @@ aarch64_ext_addr_uimm12 (const aarch64_operand *self, aarch64_opnd_info *info,
   info->addr.base_regno = extract_field (self->fields[0], code, 0);
   /* uimm12 */
   info->addr.offset.imm = extract_field (self->fields[1], code, 0) << shift;
-  return 1;
+  return TRUE;
 }
 
 /* Decode the address operand for e.g. LDRAA <Xt>, [<Xn|SP>{, #<simm>}].  */
-int
+bfd_boolean
 aarch64_ext_addr_simm10 (const aarch64_operand *self, aarch64_opnd_info *info,
                         aarch64_insn code,
-                        const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                        const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                        aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   aarch64_insn imm;
 
@@ -1031,15 +1116,16 @@ aarch64_ext_addr_simm10 (const aarch64_operand *self, aarch64_opnd_info *info,
     info->addr.writeback = 1;
     info->addr.preind = 1;
   }
-  return 1;
+  return TRUE;
 }
 
 /* Decode the address operand for e.g.
      LD1 {<Vt>.<T>, <Vt2>.<T>, <Vt3>.<T>}, [<Xn|SP>], <Xm|#<amount>>.  */
-int
+bfd_boolean
 aarch64_ext_simd_addr_post (const aarch64_operand *self ATTRIBUTE_UNUSED,
                            aarch64_opnd_info *info,
-                           aarch64_insn code, const aarch64_inst *inst)
+                           aarch64_insn code, const aarch64_inst *inst,
+                           aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   /* The opcode dependent area stores the number of elements in
      each structure to be loaded/stored.  */
@@ -1065,57 +1151,76 @@ aarch64_ext_simd_addr_post (const aarch64_operand *self ATTRIBUTE_UNUSED,
     info->addr.offset.is_reg = 1;
   info->addr.writeback = 1;
 
-  return 1;
+  return TRUE;
 }
 
 /* Decode the condition operand for e.g. CSEL <Xd>, <Xn>, <Xm>, <cond>.  */
-int
+bfd_boolean
 aarch64_ext_cond (const aarch64_operand *self ATTRIBUTE_UNUSED,
                  aarch64_opnd_info *info,
-                 aarch64_insn code, const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                 aarch64_insn code, const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                 aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   aarch64_insn value;
   /* cond */
   value = extract_field (FLD_cond, code, 0);
   info->cond = get_cond_from_value (value);
-  return 1;
+  return TRUE;
 }
 
 /* Decode the system register operand for e.g. MRS <Xt>, <systemreg>.  */
-int
+bfd_boolean
 aarch64_ext_sysreg (const aarch64_operand *self ATTRIBUTE_UNUSED,
                    aarch64_opnd_info *info,
                    aarch64_insn code,
-                   const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                   const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                   aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   /* op0:op1:CRn:CRm:op2 */
-  info->sysreg = extract_fields (code, 0, 5, FLD_op0, FLD_op1, FLD_CRn,
-                                FLD_CRm, FLD_op2);
-  return 1;
+  info->sysreg.value = extract_fields (code, 0, 5, FLD_op0, FLD_op1, FLD_CRn,
+                                      FLD_CRm, FLD_op2);
+  info->sysreg.flags = 0;
+
+  /* If a system instruction, check which restrictions should be on the register
+     value during decoding, these will be enforced then.  */
+  if (inst->opcode->iclass == ic_system)
+    {
+      /* Check to see if it's read-only, else check if it's write only.
+        if it's both or unspecified don't care.  */
+      if ((inst->opcode->flags & (F_SYS_READ | F_SYS_WRITE)) == F_SYS_READ)
+       info->sysreg.flags = F_REG_READ;
+      else if ((inst->opcode->flags & (F_SYS_READ | F_SYS_WRITE))
+              == F_SYS_WRITE)
+       info->sysreg.flags = F_REG_WRITE;
+    }
+
+  return TRUE;
 }
 
 /* Decode the PSTATE field operand for e.g. MSR <pstatefield>, #<imm>.  */
-int
+bfd_boolean
 aarch64_ext_pstatefield (const aarch64_operand *self ATTRIBUTE_UNUSED,
                         aarch64_opnd_info *info, aarch64_insn code,
-                        const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                        const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                        aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   int i;
   /* op1:op2 */
   info->pstatefield = extract_fields (code, 0, 2, FLD_op1, FLD_op2);
   for (i = 0; aarch64_pstatefields[i].name != NULL; ++i)
     if (aarch64_pstatefields[i].value == (aarch64_insn)info->pstatefield)
-      return 1;
+      return TRUE;
   /* Reserved value in <pstatefield>.  */
-  return 0;
+  return FALSE;
 }
 
 /* Decode the system instruction op operand for e.g. AT <at_op>, <Xt>.  */
-int
+bfd_boolean
 aarch64_ext_sysins_op (const aarch64_operand *self ATTRIBUTE_UNUSED,
                       aarch64_opnd_info *info,
                       aarch64_insn code,
-                      const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                      const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                      aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   int i;
   aarch64_insn value;
@@ -1131,7 +1236,7 @@ aarch64_ext_sysins_op (const aarch64_operand *self ATTRIBUTE_UNUSED,
     case AARCH64_OPND_SYSREG_DC: sysins_ops = aarch64_sys_regs_dc; break;
     case AARCH64_OPND_SYSREG_IC: sysins_ops = aarch64_sys_regs_ic; break;
     case AARCH64_OPND_SYSREG_TLBI: sysins_ops = aarch64_sys_regs_tlbi; break;
-    default: assert (0); return 0;
+    default: assert (0); return FALSE;
     }
 
   for (i = 0; sysins_ops[i].name != NULL; ++i)
@@ -1142,46 +1247,49 @@ aarch64_ext_sysins_op (const aarch64_operand *self ATTRIBUTE_UNUSED,
                     info->sysins_op->name,
                     (unsigned)info->sysins_op->value,
                     aarch64_sys_ins_reg_has_xt (info->sysins_op), i);
-       return 1;
+       return TRUE;
       }
 
-  return 0;
+  return FALSE;
 }
 
 /* Decode the memory barrier option operand for e.g. DMB <option>|#<imm>.  */
 
-int
+bfd_boolean
 aarch64_ext_barrier (const aarch64_operand *self ATTRIBUTE_UNUSED,
                     aarch64_opnd_info *info,
                     aarch64_insn code,
-                    const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                    const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                    aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   /* CRm */
   info->barrier = aarch64_barrier_options + extract_field (FLD_CRm, code, 0);
-  return 1;
+  return TRUE;
 }
 
 /* Decode the prefetch operation option operand for e.g.
      PRFM <prfop>, [<Xn|SP>{, #<pimm>}].  */
 
-int
+bfd_boolean
 aarch64_ext_prfop (const aarch64_operand *self ATTRIBUTE_UNUSED,
                   aarch64_opnd_info *info,
-                  aarch64_insn code, const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                  aarch64_insn code, const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                  aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   /* prfop in Rt */
   info->prfop = aarch64_prfops + extract_field (FLD_Rt, code, 0);
-  return 1;
+  return TRUE;
 }
 
 /* Decode the hint number for an alias taking an operand.  Set info->hint_option
    to the matching name/value pair in aarch64_hint_options.  */
 
-int
+bfd_boolean
 aarch64_ext_hint (const aarch64_operand *self ATTRIBUTE_UNUSED,
                  aarch64_opnd_info *info,
                  aarch64_insn code,
-                 const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                 const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                 aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   /* CRm:op2.  */
   unsigned hint_number;
@@ -1194,20 +1302,21 @@ aarch64_ext_hint (const aarch64_operand *self ATTRIBUTE_UNUSED,
       if (hint_number == aarch64_hint_options[i].value)
        {
          info->hint_option = &(aarch64_hint_options[i]);
-         return 1;
+         return TRUE;
        }
     }
 
-  return 0;
+  return FALSE;
 }
 
 /* Decode the extended register operand for e.g.
      STR <Qt>, [<Xn|SP>, <R><m>{, <extend> {<amount>}}].  */
-int
+bfd_boolean
 aarch64_ext_reg_extended (const aarch64_operand *self ATTRIBUTE_UNUSED,
                          aarch64_opnd_info *info,
                          aarch64_insn code,
-                         const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                         const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                         aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   aarch64_insn value;
 
@@ -1231,16 +1340,17 @@ aarch64_ext_reg_extended (const aarch64_operand *self ATTRIBUTE_UNUSED,
          || info->shifter.kind == AARCH64_MOD_SXTX))
     info->qualifier = AARCH64_OPND_QLF_X;
 
-  return 1;
+  return TRUE;
 }
 
 /* Decode the shifted register operand for e.g.
      SUBS <Xd>, <Xn>, <Xm> {, <shift> #<amount>}.  */
-int
+bfd_boolean
 aarch64_ext_reg_shifted (const aarch64_operand *self ATTRIBUTE_UNUSED,
                         aarch64_opnd_info *info,
                         aarch64_insn code,
-                        const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                        const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                        aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   aarch64_insn value;
 
@@ -1254,21 +1364,21 @@ aarch64_ext_reg_shifted (const aarch64_operand *self ATTRIBUTE_UNUSED,
       && inst->opcode->iclass != log_shift)
     /* ROR is not available for the shifted register operand in arithmetic
        instructions.  */
-    return 0;
+    return FALSE;
   /* imm6 */
   info->shifter.amount = extract_field (FLD_imm6, code,  0);
 
   /* This makes the constraint checking happy.  */
   info->shifter.operator_present = 1;
 
-  return 1;
+  return TRUE;
 }
 
 /* Decode an SVE address [<base>, #<offset>*<factor>, MUL VL],
    where <offset> is given by the OFFSET parameter and where <factor> is
    1 plus SELF's operand-dependent value.  fields[0] specifies the field
    that holds <base>.  */
-static int
+static bfd_boolean
 aarch64_ext_sve_addr_reg_mul_vl (const aarch64_operand *self,
                                 aarch64_opnd_info *info, aarch64_insn code,
                                 int64_t offset)
@@ -1283,17 +1393,18 @@ aarch64_ext_sve_addr_reg_mul_vl (const aarch64_operand *self,
   info->shifter.amount = 1;
   info->shifter.operator_present = (info->addr.offset.imm != 0);
   info->shifter.amount_present = FALSE;
-  return 1;
+  return TRUE;
 }
 
 /* Decode an SVE address [<base>, #<simm4>*<factor>, MUL VL],
    where <simm4> is a 4-bit signed value and where <factor> is 1 plus
    SELF's operand-dependent value.  fields[0] specifies the field that
    holds <base>.  <simm4> is encoded in the SVE_imm4 field.  */
-int
+bfd_boolean
 aarch64_ext_sve_addr_ri_s4xvl (const aarch64_operand *self,
                               aarch64_opnd_info *info, aarch64_insn code,
-                              const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                              const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                              aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   int offset;
 
@@ -1306,10 +1417,11 @@ aarch64_ext_sve_addr_ri_s4xvl (const aarch64_operand *self,
    where <simm6> is a 6-bit signed value and where <factor> is 1 plus
    SELF's operand-dependent value.  fields[0] specifies the field that
    holds <base>.  <simm6> is encoded in the SVE_imm6 field.  */
-int
+bfd_boolean
 aarch64_ext_sve_addr_ri_s6xvl (const aarch64_operand *self,
                               aarch64_opnd_info *info, aarch64_insn code,
-                              const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                              const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                              aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   int offset;
 
@@ -1323,11 +1435,12 @@ aarch64_ext_sve_addr_ri_s6xvl (const aarch64_operand *self,
    SELF's operand-dependent value.  fields[0] specifies the field that
    holds <base>.  <simm9> is encoded in the concatenation of the SVE_imm6
    and imm3 fields, with imm3 being the less-significant part.  */
-int
+bfd_boolean
 aarch64_ext_sve_addr_ri_s9xvl (const aarch64_operand *self,
                               aarch64_opnd_info *info,
                               aarch64_insn code,
-                              const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                              const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                              aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   int offset;
 
@@ -1339,7 +1452,7 @@ aarch64_ext_sve_addr_ri_s9xvl (const aarch64_operand *self,
 /* Decode an SVE address [<base>, #<offset> << <shift>], where <offset>
    is given by the OFFSET parameter and where <shift> is SELF's operand-
    dependent value.  fields[0] specifies the base register field <base>.  */
-static int
+static bfd_boolean
 aarch64_ext_sve_addr_reg_imm (const aarch64_operand *self,
                              aarch64_opnd_info *info, aarch64_insn code,
                              int64_t offset)
@@ -1351,16 +1464,17 @@ aarch64_ext_sve_addr_reg_imm (const aarch64_operand *self,
   info->addr.preind = TRUE;
   info->shifter.operator_present = FALSE;
   info->shifter.amount_present = FALSE;
-  return 1;
+  return TRUE;
 }
 
 /* Decode an SVE address [X<n>, #<SVE_imm4> << <shift>], where <SVE_imm4>
    is a 4-bit signed number and where <shift> is SELF's operand-dependent
    value.  fields[0] specifies the base register field.  */
-int
+bfd_boolean
 aarch64_ext_sve_addr_ri_s4 (const aarch64_operand *self,
                            aarch64_opnd_info *info, aarch64_insn code,
-                           const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                           const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                           aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   int offset = sign_extend (extract_field (FLD_SVE_imm4, code, 0), 3);
   return aarch64_ext_sve_addr_reg_imm (self, info, code, offset);
@@ -1369,10 +1483,11 @@ aarch64_ext_sve_addr_ri_s4 (const aarch64_operand *self,
 /* Decode an SVE address [X<n>, #<SVE_imm6> << <shift>], where <SVE_imm6>
    is a 6-bit unsigned number and where <shift> is SELF's operand-dependent
    value.  fields[0] specifies the base register field.  */
-int
+bfd_boolean
 aarch64_ext_sve_addr_ri_u6 (const aarch64_operand *self,
                            aarch64_opnd_info *info, aarch64_insn code,
-                           const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                           const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                           aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   int offset = extract_field (FLD_SVE_imm6, code, 0);
   return aarch64_ext_sve_addr_reg_imm (self, info, code, offset);
@@ -1381,16 +1496,17 @@ aarch64_ext_sve_addr_ri_u6 (const aarch64_operand *self,
 /* Decode an SVE address [X<n>, X<m>{, LSL #<shift>}], where <shift>
    is SELF's operand-dependent value.  fields[0] specifies the base
    register field and fields[1] specifies the offset register field.  */
-int
+bfd_boolean
 aarch64_ext_sve_addr_rr_lsl (const aarch64_operand *self,
                             aarch64_opnd_info *info, aarch64_insn code,
-                            const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                            const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                            aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   int index_regno;
 
   index_regno = extract_field (self->fields[1], code, 0);
   if (index_regno == 31 && (self->flags & OPD_F_NO_ZR) != 0)
-    return 0;
+    return FALSE;
 
   info->addr.base_regno = extract_field (self->fields[0], code, 0);
   info->addr.offset.regno = index_regno;
@@ -1401,17 +1517,18 @@ aarch64_ext_sve_addr_rr_lsl (const aarch64_operand *self,
   info->shifter.amount = get_operand_specific_data (self);
   info->shifter.operator_present = (info->shifter.amount != 0);
   info->shifter.amount_present = (info->shifter.amount != 0);
-  return 1;
+  return TRUE;
 }
 
 /* Decode an SVE address [X<n>, Z<m>.<T>, (S|U)XTW {#<shift>}], where
    <shift> is SELF's operand-dependent value.  fields[0] specifies the
    base register field, fields[1] specifies the offset register field and
    fields[2] is a single-bit field that selects SXTW over UXTW.  */
-int
+bfd_boolean
 aarch64_ext_sve_addr_rz_xtw (const aarch64_operand *self,
                             aarch64_opnd_info *info, aarch64_insn code,
-                            const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                            const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                            aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   info->addr.base_regno = extract_field (self->fields[0], code, 0);
   info->addr.offset.regno = extract_field (self->fields[1], code, 0);
@@ -1425,16 +1542,17 @@ aarch64_ext_sve_addr_rz_xtw (const aarch64_operand *self,
   info->shifter.amount = get_operand_specific_data (self);
   info->shifter.operator_present = TRUE;
   info->shifter.amount_present = (info->shifter.amount != 0);
-  return 1;
+  return TRUE;
 }
 
 /* Decode an SVE address [Z<n>.<T>, #<imm5> << <shift>], where <imm5> is a
    5-bit unsigned number and where <shift> is SELF's operand-dependent value.
    fields[0] specifies the base register field.  */
-int
+bfd_boolean
 aarch64_ext_sve_addr_zi_u5 (const aarch64_operand *self,
                            aarch64_opnd_info *info, aarch64_insn code,
-                           const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                           const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                           aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   int offset = extract_field (FLD_imm5, code, 0);
   return aarch64_ext_sve_addr_reg_imm (self, info, code, offset);
@@ -1444,7 +1562,7 @@ aarch64_ext_sve_addr_zi_u5 (const aarch64_operand *self,
    where <modifier> is given by KIND and where <msz> is a 2-bit unsigned
    number.  fields[0] specifies the base register field and fields[1]
    specifies the offset register field.  */
-static int
+static bfd_boolean
 aarch64_ext_sve_addr_zz (const aarch64_operand *self, aarch64_opnd_info *info,
                         aarch64_insn code, enum aarch64_modifier_kind kind)
 {
@@ -1458,16 +1576,17 @@ aarch64_ext_sve_addr_zz (const aarch64_operand *self, aarch64_opnd_info *info,
   info->shifter.operator_present = (kind != AARCH64_MOD_LSL
                                    || info->shifter.amount != 0);
   info->shifter.amount_present = (info->shifter.amount != 0);
-  return 1;
+  return TRUE;
 }
 
 /* Decode an SVE address [Z<n>.<T>, Z<m>.<T>{, LSL #<msz>}], where
    <msz> is a 2-bit unsigned number.  fields[0] specifies the base register
    field and fields[1] specifies the offset register field.  */
-int
+bfd_boolean
 aarch64_ext_sve_addr_zz_lsl (const aarch64_operand *self,
                             aarch64_opnd_info *info, aarch64_insn code,
-                            const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                            const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                            aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   return aarch64_ext_sve_addr_zz (self, info, code, AARCH64_MOD_LSL);
 }
@@ -1475,10 +1594,11 @@ aarch64_ext_sve_addr_zz_lsl (const aarch64_operand *self,
 /* Decode an SVE address [Z<n>.<T>, Z<m>.<T>, SXTW {#<msz>}], where
    <msz> is a 2-bit unsigned number.  fields[0] specifies the base register
    field and fields[1] specifies the offset register field.  */
-int
+bfd_boolean
 aarch64_ext_sve_addr_zz_sxtw (const aarch64_operand *self,
                              aarch64_opnd_info *info, aarch64_insn code,
-                             const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                             const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                             aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   return aarch64_ext_sve_addr_zz (self, info, code, AARCH64_MOD_SXTW);
 }
@@ -1486,17 +1606,18 @@ aarch64_ext_sve_addr_zz_sxtw (const aarch64_operand *self,
 /* Decode an SVE address [Z<n>.<T>, Z<m>.<T>, UXTW {#<msz>}], where
    <msz> is a 2-bit unsigned number.  fields[0] specifies the base register
    field and fields[1] specifies the offset register field.  */
-int
+bfd_boolean
 aarch64_ext_sve_addr_zz_uxtw (const aarch64_operand *self,
                              aarch64_opnd_info *info, aarch64_insn code,
-                             const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                             const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                             aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   return aarch64_ext_sve_addr_zz (self, info, code, AARCH64_MOD_UXTW);
 }
 
 /* Finish decoding an SVE arithmetic immediate, given that INFO already
    has the raw field value and that the low 8 bits decode to VALUE.  */
-static int
+static bfd_boolean
 decode_sve_aimm (aarch64_opnd_info *info, int64_t value)
 {
   info->shifter.kind = AARCH64_MOD_LSL;
@@ -1512,82 +1633,88 @@ decode_sve_aimm (aarch64_opnd_info *info, int64_t value)
   info->shifter.operator_present = (info->shifter.amount != 0);
   info->shifter.amount_present = (info->shifter.amount != 0);
   info->imm.value = value;
-  return 1;
+  return TRUE;
 }
 
 /* Decode an SVE ADD/SUB immediate.  */
-int
+bfd_boolean
 aarch64_ext_sve_aimm (const aarch64_operand *self,
                      aarch64_opnd_info *info, const aarch64_insn code,
-                     const aarch64_inst *inst)
+                     const aarch64_inst *inst,
+                     aarch64_operand_error *errors)
 {
-  return (aarch64_ext_imm (self, info, code, inst)
+  return (aarch64_ext_imm (self, info, code, inst, errors)
          && decode_sve_aimm (info, (uint8_t) info->imm.value));
 }
 
 /* Decode an SVE CPY/DUP immediate.  */
-int
+bfd_boolean
 aarch64_ext_sve_asimm (const aarch64_operand *self,
                       aarch64_opnd_info *info, const aarch64_insn code,
-                      const aarch64_inst *inst)
+                      const aarch64_inst *inst,
+                      aarch64_operand_error *errors)
 {
-  return (aarch64_ext_imm (self, info, code, inst)
+  return (aarch64_ext_imm (self, info, code, inst, errors)
          && decode_sve_aimm (info, (int8_t) info->imm.value));
 }
 
 /* Decode a single-bit immediate that selects between #0.5 and #1.0.
    The fields array specifies which field to use.  */
-int
+bfd_boolean
 aarch64_ext_sve_float_half_one (const aarch64_operand *self,
                                aarch64_opnd_info *info, aarch64_insn code,
-                               const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                               const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                               aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   if (extract_field (self->fields[0], code, 0))
     info->imm.value = 0x3f800000;
   else
     info->imm.value = 0x3f000000;
   info->imm.is_fp = TRUE;
-  return 1;
+  return TRUE;
 }
 
 /* Decode a single-bit immediate that selects between #0.5 and #2.0.
    The fields array specifies which field to use.  */
-int
+bfd_boolean
 aarch64_ext_sve_float_half_two (const aarch64_operand *self,
                                aarch64_opnd_info *info, aarch64_insn code,
-                               const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                               const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                               aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   if (extract_field (self->fields[0], code, 0))
     info->imm.value = 0x40000000;
   else
     info->imm.value = 0x3f000000;
   info->imm.is_fp = TRUE;
-  return 1;
+  return TRUE;
 }
 
 /* Decode a single-bit immediate that selects between #0.0 and #1.0.
    The fields array specifies which field to use.  */
-int
+bfd_boolean
 aarch64_ext_sve_float_zero_one (const aarch64_operand *self,
                                aarch64_opnd_info *info, aarch64_insn code,
-                               const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                               const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                               aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   if (extract_field (self->fields[0], code, 0))
     info->imm.value = 0x3f800000;
   else
     info->imm.value = 0x0;
   info->imm.is_fp = TRUE;
-  return 1;
+  return TRUE;
 }
 
 /* Decode Zn[MM], where MM has a 7-bit triangular encoding.  The fields
    array specifies which field to use for Zn.  MM is encoded in the
    concatenation of imm5 and SVE_tszh, with imm5 being the less
    significant part.  */
-int
+bfd_boolean
 aarch64_ext_sve_index (const aarch64_operand *self,
                       aarch64_opnd_info *info, aarch64_insn code,
-                      const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                      const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                      aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   int val;
 
@@ -1598,66 +1725,69 @@ aarch64_ext_sve_index (const aarch64_operand *self,
   while ((val & 1) == 0)
     val /= 2;
   info->reglane.index = val / 2;
-  return 1;
+  return TRUE;
 }
 
 /* Decode a logical immediate for the MOV alias of SVE DUPM.  */
-int
+bfd_boolean
 aarch64_ext_sve_limm_mov (const aarch64_operand *self,
                          aarch64_opnd_info *info, const aarch64_insn code,
-                         const aarch64_inst *inst)
+                         const aarch64_inst *inst,
+                         aarch64_operand_error *errors)
 {
   int esize = aarch64_get_qualifier_esize (inst->operands[0].qualifier);
-  return (aarch64_ext_limm (self, info, code, inst)
+  return (aarch64_ext_limm (self, info, code, inst, errors)
          && aarch64_sve_dupm_mov_immediate_p (info->imm.value, esize));
 }
 
 /* Decode Zn[MM], where Zn occupies the least-significant part of the field
    and where MM occupies the most-significant part.  The operand-dependent
    value specifies the number of bits in Zn.  */
-int
+bfd_boolean
 aarch64_ext_sve_quad_index (const aarch64_operand *self,
                            aarch64_opnd_info *info, aarch64_insn code,
-                           const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                           const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                           aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   unsigned int reg_bits = get_operand_specific_data (self);
   unsigned int val = extract_all_fields (self, code);
   info->reglane.regno = val & ((1 << reg_bits) - 1);
   info->reglane.index = val >> reg_bits;
-  return 1;
+  return TRUE;
 }
 
 /* Decode {Zn.<T> - Zm.<T>}.  The fields array specifies which field
    to use for Zn.  The opcode-dependent value specifies the number
    of registers in the list.  */
-int
+bfd_boolean
 aarch64_ext_sve_reglist (const aarch64_operand *self,
                         aarch64_opnd_info *info, aarch64_insn code,
-                        const aarch64_inst *inst ATTRIBUTE_UNUSED)
+                        const aarch64_inst *inst ATTRIBUTE_UNUSED,
+                        aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   info->reglist.first_regno = extract_field (self->fields[0], code, 0);
   info->reglist.num_regs = get_opcode_dependent_value (inst->opcode);
-  return 1;
+  return TRUE;
 }
 
 /* Decode <pattern>{, MUL #<amount>}.  The fields array specifies which
    fields to use for <pattern>.  <amount> - 1 is encoded in the SVE_imm4
    field.  */
-int
+bfd_boolean
 aarch64_ext_sve_scale (const aarch64_operand *self,
                       aarch64_opnd_info *info, aarch64_insn code,
-                      const aarch64_inst *inst)
+                      const aarch64_inst *inst, aarch64_operand_error *errors)
 {
   int val;
 
-  if (!aarch64_ext_imm (self, info, code, inst))
-    return 0;
+  if (!aarch64_ext_imm (self, info, code, inst, errors))
+    return FALSE;
   val = extract_field (FLD_SVE_imm4, code, 0);
   info->shifter.kind = AARCH64_MOD_MUL;
   info->shifter.amount = val + 1;
   info->shifter.operator_present = (val != 0);
   info->shifter.amount_present = (val != 0);
-  return 1;
+  return TRUE;
 }
 
 /* Return the top set bit in VALUE, which is expected to be relatively
@@ -1671,31 +1801,31 @@ get_top_bit (uint64_t value)
 }
 
 /* Decode an SVE shift-left immediate.  */
-int
+bfd_boolean
 aarch64_ext_sve_shlimm (const aarch64_operand *self,
                        aarch64_opnd_info *info, const aarch64_insn code,
-                       const aarch64_inst *inst)
+                       const aarch64_inst *inst, aarch64_operand_error *errors)
 {
-  if (!aarch64_ext_imm (self, info, code, inst)
+  if (!aarch64_ext_imm (self, info, code, inst, errors)
       || info->imm.value == 0)
-    return 0;
+    return FALSE;
 
   info->imm.value -= get_top_bit (info->imm.value);
-  return 1;
+  return TRUE;
 }
 
 /* Decode an SVE shift-right immediate.  */
-int
+bfd_boolean
 aarch64_ext_sve_shrimm (const aarch64_operand *self,
                        aarch64_opnd_info *info, const aarch64_insn code,
-                       const aarch64_inst *inst)
+                       const aarch64_inst *inst, aarch64_operand_error *errors)
 {
-  if (!aarch64_ext_imm (self, info, code, inst)
+  if (!aarch64_ext_imm (self, info, code, inst, errors)
       || info->imm.value == 0)
-    return 0;
+    return FALSE;
 
   info->imm.value = get_top_bit (info->imm.value) * 2 - info->imm.value;
-  return 1;
+  return TRUE;
 }
 \f
 /* Bitfields that are commonly used to encode certain operands' information
@@ -2429,8 +2559,9 @@ convert_to_alias (aarch64_inst *inst, const aarch64_opcode *alias)
     }
 }
 
-static int aarch64_opcode_decode (const aarch64_opcode *, const aarch64_insn,
-                                 aarch64_inst *, int);
+static bfd_boolean
+aarch64_opcode_decode (const aarch64_opcode *, const aarch64_insn,
+                      aarch64_inst *, int, aarch64_operand_error *errors);
 
 /* Given the instruction information in *INST, check if the instruction has
    any alias form that can be used to represent *INST.  If the answer is yes,
@@ -2486,7 +2617,8 @@ static int aarch64_opcode_decode (const aarch64_opcode *, const aarch64_insn,
    aarch64_find_next_alias_opcode (in opcodes/aarch64-dis-2.c) to help.  */
 
 static void
-determine_disassembling_preference (struct aarch64_inst *inst)
+determine_disassembling_preference (struct aarch64_inst *inst,
+                                   aarch64_operand_error *errors)
 {
   const aarch64_opcode *opcode;
   const aarch64_opcode *alias;
@@ -2561,7 +2693,7 @@ determine_disassembling_preference (struct aarch64_inst *inst)
          /* Directly decode the alias opcode.  */
          aarch64_inst temp;
          memset (&temp, '\0', sizeof (aarch64_inst));
-         if (aarch64_opcode_decode (alias, inst->value, &temp, 1) == 1)
+         if (aarch64_opcode_decode (alias, inst->value, &temp, 1, errors) == 1)
            {
              DEBUG_TRACE ("succeed with %s via direct decoding", alias->name);
              memcpy (inst, &temp, sizeof (aarch64_inst));
@@ -2678,9 +2810,10 @@ aarch64_decode_variant_using_iclass (aarch64_inst *inst)
    determined and used to disassemble CODE; this is done just before the
    return.  */
 
-static int
+static bfd_boolean
 aarch64_opcode_decode (const aarch64_opcode *opcode, const aarch64_insn code,
-                      aarch64_inst *inst, int noaliases_p)
+                      aarch64_inst *inst, int noaliases_p,
+                      aarch64_operand_error *errors)
 {
   int i;
 
@@ -2688,6 +2821,9 @@ aarch64_opcode_decode (const aarch64_opcode *opcode, const aarch64_insn code,
 
   assert (opcode && inst);
 
+  /* Clear inst.  */
+  memset (inst, '\0', sizeof (aarch64_inst));
+
   /* Check the base opcode.  */
   if ((code & opcode->mask) != (opcode->opcode & opcode->mask))
     {
@@ -2695,9 +2831,6 @@ aarch64_opcode_decode (const aarch64_opcode *opcode, const aarch64_insn code,
       goto decode_fail;
     }
 
-  /* Clear inst.  */
-  memset (inst, '\0', sizeof (aarch64_inst));
-
   inst->opcode = opcode;
   inst->value = code;
 
@@ -2736,7 +2869,8 @@ aarch64_opcode_decode (const aarch64_opcode *opcode, const aarch64_insn code,
        break;
       opnd = &aarch64_operands[type];
       if (operand_has_extractor (opnd)
-         && (! aarch64_extract_operand (opnd, &inst->operands[i], code, inst)))
+         && (! aarch64_extract_operand (opnd, &inst->operands[i], code, inst,
+                                        errors)))
        {
          DEBUG_TRACE ("operand decoder FAIL at operand %d", i);
          goto decode_fail;
@@ -2759,9 +2893,9 @@ aarch64_opcode_decode (const aarch64_opcode *opcode, const aarch64_insn code,
         alias and should be disassembled in the form of its alias instead.
         If the answer is yes, *INST will be updated.  */
       if (!noaliases_p)
-       determine_disassembling_preference (inst);
+       determine_disassembling_preference (inst, errors);
       DEBUG_TRACE ("SUCCESS");
-      return 1;
+      return TRUE;
     }
   else
     {
@@ -2769,7 +2903,7 @@ aarch64_opcode_decode (const aarch64_opcode *opcode, const aarch64_insn code,
     }
 
 decode_fail:
-  return 0;
+  return FALSE;
 }
 \f
 /* This does some user-friendly fix-up to *INST.  It is currently focus on
@@ -2801,7 +2935,8 @@ user_friendly_fixup (aarch64_inst *inst)
 
 int
 aarch64_decode_insn (aarch64_insn insn, aarch64_inst *inst,
-                    bfd_boolean noaliases_p)
+                    bfd_boolean noaliases_p,
+                    aarch64_operand_error *errors)
 {
   const aarch64_opcode *opcode = aarch64_opcode_lookup (insn);
 
@@ -2828,7 +2963,7 @@ aarch64_decode_insn (aarch64_insn insn, aarch64_inst *inst,
     {
       /* But only one opcode can be decoded successfully for, as the
         decoding routine will check the constraint carefully.  */
-      if (aarch64_opcode_decode (opcode, insn, inst, noaliases_p) == 1)
+      if (aarch64_opcode_decode (opcode, insn, inst, noaliases_p, errors) == 1)
        return ERR_OK;
       opcode = aarch64_find_next_opcode (opcode);
     }
@@ -2843,6 +2978,7 @@ print_operands (bfd_vma pc, const aarch64_opcode *opcode,
                const aarch64_opnd_info *opnds, struct disassemble_info *info)
 {
   int i, pcrel_p, num_printed;
+  char *notes = NULL;
   for (i = 0, num_printed = 0; i < AARCH64_MAX_OPND_NUM; ++i)
     {
       char str[128];
@@ -2857,7 +2993,7 @@ print_operands (bfd_vma pc, const aarch64_opcode *opcode,
 
       /* Generate the operand string in STR.  */
       aarch64_print_operand (str, sizeof (str), pc, opcode, opnds, i, &pcrel_p,
-                            &info->target);
+                            &info->target, &notes);
 
       /* Print the delimiter (taking account of omitted operand(s)).  */
       if (str[0] != '\0')
@@ -2870,6 +3006,9 @@ print_operands (bfd_vma pc, const aarch64_opcode *opcode,
       else
        (*info->fprintf_func) (info->stream, "%s", str);
     }
+
+    if (notes && !no_notes)
+      (*info->fprintf_func) (info->stream, "\t; note: %s", notes);
 }
 
 /* Set NAME to a copy of INST's mnemonic with the "." suffix removed.  */
@@ -2943,7 +3082,8 @@ print_aarch64_insn (bfd_vma pc, const aarch64_inst *inst,
 static void
 print_insn_aarch64_word (bfd_vma pc,
                         uint32_t word,
-                        struct disassemble_info *info)
+                        struct disassemble_info *info,
+                        aarch64_operand_error *errors)
 {
   static const char *err_msg[6] =
     {
@@ -2970,7 +3110,7 @@ print_insn_aarch64_word (bfd_vma pc,
        addresses, since the addend is not currently pc-relative.  */
     pc = 0;
 
-  ret = aarch64_decode_insn (word, &inst, no_aliases);
+  ret = aarch64_decode_insn (word, &inst, no_aliases, errors);
 
   if (((word >> 21) & 0x3ff) == 1)
     {
@@ -3023,7 +3163,8 @@ aarch64_symbol_is_valid (asymbol * sym,
 static void
 print_insn_data (bfd_vma pc ATTRIBUTE_UNUSED,
                 uint32_t word,
-                struct disassemble_info *info)
+                struct disassemble_info *info,
+                aarch64_operand_error *errors ATTRIBUTE_UNUSED)
 {
   switch (info->bytes_per_chunk)
     {
@@ -3052,6 +3193,10 @@ get_sym_code_type (struct disassemble_info *info, int n,
   unsigned int type;
   const char *name;
 
+  /* If the symbol is in a different section, ignore it.  */
+  if (info->section != NULL && info->section != info->symtab[n]->section)
+    return FALSE;
+
   es = *(elf_symbol_type **)(info->symtab + n);
   type = ELF_ST_TYPE (es->internal_elf_sym.st_info);
 
@@ -3083,10 +3228,12 @@ print_insn_aarch64 (bfd_vma pc,
 {
   bfd_byte     buffer[INSNLEN];
   int          status;
-  void         (*printer) (bfd_vma, uint32_t, struct disassemble_info *);
+  void         (*printer) (bfd_vma, uint32_t, struct disassemble_info *,
+                           aarch64_operand_error *);
   bfd_boolean   found = FALSE;
   unsigned int size = 4;
   unsigned long        data;
+  aarch64_operand_error errors;
 
   if (info->disassembler_options)
     {
@@ -3126,9 +3273,7 @@ print_insn_aarch64 (bfd_vma pc,
          addr = bfd_asymbol_value (info->symtab[n]);
          if (addr > pc)
            break;
-         if ((info->section == NULL
-              || info->section == info->symtab[n]->section)
-             && get_sym_code_type (info, n, &type))
+         if (get_sym_code_type (info, n, &type))
            {
              last_sym = n;
              found = TRUE;
@@ -3206,7 +3351,7 @@ print_insn_aarch64 (bfd_vma pc,
   data = bfd_get_bits (buffer, size * 8,
                       info->display_endian == BFD_ENDIAN_BIG);
 
-  (*printer) (pc, data, info);
+  (*printer) (pc, data, info, &errors);
 
   return size;
 }
@@ -3224,6 +3369,12 @@ with the -M switch (multiple options should be separated by commas):\n"));
   fprintf (stream, _("\n\
   aliases            Do print instruction aliases.\n"));
 
+  fprintf (stream, _("\n\
+  no-notes         Don't print instruction notes.\n"));
+
+  fprintf (stream, _("\n\
+  notes            Do print instruction notes.\n"));
+
 #ifdef DEBUG_AARCH64
   fprintf (stream, _("\n\
   debug_dump         Temp switch for debug trace.\n"));
This page took 0.044266 seconds and 4 git commands to generate.