Testsuite: Add gdb_simple_compile
[deliverable/binutils-gdb.git] / opcodes / ppc-opc.c
index 5edb1adac9fdda48f51f24e32e629961d2403199..e303efa8c980fcca37f8835f7ace74492aca82a1 100644 (file)
@@ -1,5 +1,5 @@
 /* ppc-opc.c -- PowerPC opcode list
-   Copyright (C) 1994-2017 Free Software Foundation, Inc.
+   Copyright (C) 1994-2018 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Cygnus Support
 
    This file is part of the GNU opcodes library.
@@ -39,9 +39,9 @@
 
 /* The ARX, ARY, RX and RY operands are alternate encodings of GPRs.  */
 
-static unsigned long
-insert_arx (unsigned long insn,
-           long value,
+static uint64_t
+insert_arx (uint64_t insn,
+           int64_t value,
            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
            const char **errmsg ATTRIBUTE_UNUSED)
 {
@@ -54,17 +54,17 @@ insert_arx (unsigned long insn,
     }
 }
 
-static long
-extract_arx (unsigned long insn,
+static int64_t
+extract_arx (uint64_t insn,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             int *invalid ATTRIBUTE_UNUSED)
 {
   return (insn & 0xf) + 8;
 }
 
-static unsigned long
-insert_ary (unsigned long insn,
-           long value,
+static uint64_t
+insert_ary (uint64_t insn,
+           int64_t value,
            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
            const char **errmsg ATTRIBUTE_UNUSED)
 {
@@ -77,17 +77,17 @@ insert_ary (unsigned long insn,
     }
 }
 
-static long
-extract_ary (unsigned long insn,
+static int64_t
+extract_ary (uint64_t insn,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             int *invalid ATTRIBUTE_UNUSED)
 {
   return ((insn >> 4) & 0xf) + 8;
 }
 
-static unsigned long
-insert_rx (unsigned long insn,
-          long value,
+static uint64_t
+insert_rx (uint64_t insn,
+          int64_t value,
           ppc_cpu_t dialect ATTRIBUTE_UNUSED,
           const char **errmsg)
 {
@@ -102,21 +102,21 @@ insert_rx (unsigned long insn,
     }
 }
 
-static long
-extract_rx (unsigned long insn,
+static int64_t
+extract_rx (uint64_t insn,
            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
            int *invalid ATTRIBUTE_UNUSED)
 {
-  int value = insn & 0xf;
+  int64_t value = insn & 0xf;
   if (value >= 0 && value < 8)
     return value;
   else
     return value + 16;
 }
 
-static unsigned long
-insert_ry (unsigned long insn,
-          long value,
+static uint64_t
+insert_ry (uint64_t insn,
+          int64_t value,
           ppc_cpu_t dialect ATTRIBUTE_UNUSED,
           const char **errmsg)
 {
@@ -131,66 +131,71 @@ insert_ry (unsigned long insn,
     }
 }
 
-static long
-extract_ry (unsigned long insn,
+static int64_t
+extract_ry (uint64_t insn,
            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
            int *invalid ATTRIBUTE_UNUSED)
 {
-  int value = (insn >> 4) & 0xf;
+  int64_t value = (insn >> 4) & 0xf;
   if (value >= 0 && value < 8)
     return value;
   else
     return value + 16;
 }
 
-/* The BA field in an XL form instruction when it must be the same as
-   the BT field in the same instruction.  This operand is marked FAKE.
-   The insertion function just copies the BT field into the BA field,
-   and the extraction function just checks that the fields are the
-   same.  */
+/* The BA and BB fields in an XL form instruction or the RA and RB fields or
+   VRA and VRB fields in a VX form instruction when they must be the same.
+   This is used for extended mnemonics like crclr.  The extraction function
+   enforces that the fields are the same.  */
 
-static unsigned long
-insert_bat (unsigned long insn,
-           long value ATTRIBUTE_UNUSED,
+static uint64_t
+insert_bab (uint64_t insn,
+           int64_t value,
            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
            const char **errmsg ATTRIBUTE_UNUSED)
 {
-  return insn | (((insn >> 21) & 0x1f) << 16);
+  value &= 0x1f;
+  return insn | (value << 16) | (value << 11);
 }
 
-static long
-extract_bat (unsigned long insn,
+static int64_t
+extract_bab (uint64_t insn,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             int *invalid)
 {
-  if (((insn >> 21) & 0x1f) != ((insn >> 16) & 0x1f))
+  int64_t ba = (insn >> 16) & 0x1f;
+  int64_t bb = (insn >> 11) & 0x1f;
+
+  if (ba != bb)
     *invalid = 1;
-  return 0;
+  return ba;
 }
 
-/* The BB field in an XL form instruction when it must be the same as
-   the BA field in the same instruction.  This operand is marked FAKE.
-   The insertion function just copies the BA field into the BB field,
-   and the extraction function just checks that the fields are the
-   same.  */
+/* The BT, BA and BB fields in an XL form instruction when they must all be
+   the same.  This is used for extended mnemonics like crclr.  The extraction
+   function enforces that the fields are the same.  */
 
-static unsigned long
-insert_bba (unsigned long insn,
-           long value ATTRIBUTE_UNUSED,
-           ppc_cpu_t dialect ATTRIBUTE_UNUSED,
-           const char **errmsg ATTRIBUTE_UNUSED)
+static uint64_t
+insert_btab (uint64_t insn,
+            int64_t value,
+            ppc_cpu_t dialect,
+            const char **errmsg)
 {
-  return insn | (((insn >> 16) & 0x1f) << 11);
+  value &= 0x1f;
+  return (value << 21) | insert_bab (insn, value, dialect, errmsg);
 }
 
-static long
-extract_bba (unsigned long insn,
-            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
+static int64_t
+extract_btab (uint64_t insn,
+            ppc_cpu_t dialect,
             int *invalid)
 {
-  if (((insn >> 16) & 0x1f) != ((insn >> 11) & 0x1f))
+  int64_t bt = (insn >> 21) & 0x1f;
+  int64_t bab = extract_bab (insn, dialect, invalid);
+
+  if (bt != bab)
     *invalid = 1;
-  return 0;
+  return bt;
 }
 
 /* The BD field in a B form instruction when the - modifier is used.
@@ -212,9 +217,9 @@ extract_bba (unsigned long insn,
 
 #define ISA_V2 (PPC_OPCODE_POWER4 | PPC_OPCODE_E500MC | PPC_OPCODE_TITAN)
 
-static unsigned long
-insert_bdm (unsigned long insn,
-           long value,
+static uint64_t
+insert_bdm (uint64_t insn,
+           int64_t value,
            ppc_cpu_t dialect,
            const char **errmsg ATTRIBUTE_UNUSED)
 {
@@ -233,8 +238,8 @@ insert_bdm (unsigned long insn,
   return insn | (value & 0xfffc);
 }
 
-static long
-extract_bdm (unsigned long insn,
+static int64_t
+extract_bdm (uint64_t insn,
             ppc_cpu_t dialect,
             int *invalid)
 {
@@ -257,9 +262,9 @@ extract_bdm (unsigned long insn,
    This is like BDM, above, except that the branch is expected to be
    taken.  */
 
-static unsigned long
-insert_bdp (unsigned long insn,
-           long value,
+static uint64_t
+insert_bdp (uint64_t insn,
+           int64_t value,
            ppc_cpu_t dialect,
            const char **errmsg ATTRIBUTE_UNUSED)
 {
@@ -278,8 +283,8 @@ insert_bdp (unsigned long insn,
   return insn | (value & 0xfffc);
 }
 
-static long
-extract_bdp (unsigned long insn,
+static int64_t
+extract_bdp (uint64_t insn,
             ppc_cpu_t dialect,
             int *invalid)
 {
@@ -299,7 +304,7 @@ extract_bdp (unsigned long insn,
 }
 
 static inline int
-valid_bo_pre_v2 (long value)
+valid_bo_pre_v2 (int64_t value)
 {
   /* Certain encodings have bits that are required to be zero.
      These are (z must be zero, y may be anything):
@@ -324,7 +329,7 @@ valid_bo_pre_v2 (long value)
 }
 
 static inline int
-valid_bo_post_v2 (long value)
+valid_bo_post_v2 (int64_t value)
 {
   /* Certain encodings have bits that are required to be zero.
      These are (z must be zero, a & t may be anything):
@@ -349,7 +354,7 @@ valid_bo_post_v2 (long value)
 /* Check for legal values of a BO field.  */
 
 static int
-valid_bo (long value, ppc_cpu_t dialect, int extract)
+valid_bo (int64_t value, ppc_cpu_t dialect, int extract)
 {
   int valid_y = valid_bo_pre_v2 (value);
   int valid_at = valid_bo_post_v2 (value);
@@ -367,9 +372,9 @@ valid_bo (long value, ppc_cpu_t dialect, int extract)
 /* The BO field in a B form instruction.  Warn about attempts to set
    the field to an illegal value.  */
 
-static unsigned long
-insert_bo (unsigned long insn,
-          long value,
+static uint64_t
+insert_bo (uint64_t insn,
+          int64_t value,
           ppc_cpu_t dialect,
           const char **errmsg)
 {
@@ -380,14 +385,12 @@ insert_bo (unsigned long insn,
   return insn | ((value & 0x1f) << 21);
 }
 
-static long
-extract_bo (unsigned long insn,
+static int64_t
+extract_bo (uint64_t insn,
            ppc_cpu_t dialect,
            int *invalid)
 {
-  long value;
-
-  value = (insn >> 21) & 0x1f;
+  int64_t value = (insn >> 21) & 0x1f;
   if (!valid_bo (value, dialect, 1))
     *invalid = 1;
   return value;
@@ -397,9 +400,9 @@ extract_bo (unsigned long insn,
    used.  This is like the BO field, but it must be even.  When
    extracting it, we force it to be even.  */
 
-static unsigned long
-insert_boe (unsigned long insn,
-           long value,
+static uint64_t
+insert_boe (uint64_t insn,
+           int64_t value,
            ppc_cpu_t dialect,
            const char **errmsg)
 {
@@ -413,14 +416,12 @@ insert_boe (unsigned long insn,
   return insn | ((value & 0x1f) << 21);
 }
 
-static long
-extract_boe (unsigned long insn,
+static int64_t
+extract_boe (uint64_t insn,
             ppc_cpu_t dialect,
             int *invalid)
 {
-  long value;
-
-  value = (insn >> 21) & 0x1f;
+  int64_t value = (insn >> 21) & 0x1f;
   if (!valid_bo (value, dialect, 1))
     *invalid = 1;
   return value & 0x1e;
@@ -429,9 +430,9 @@ extract_boe (unsigned long insn,
 /* The DCMX field in a X form instruction when the field is split
    into separate DC, DM and DX fields.  */
 
-static unsigned long
-insert_dcmxs (unsigned long insn,
-             long value,
+static uint64_t
+insert_dcmxs (uint64_t insn,
+             int64_t value,
              ppc_cpu_t dialect ATTRIBUTE_UNUSED,
              const char **errmsg ATTRIBUTE_UNUSED)
 {
@@ -441,8 +442,8 @@ insert_dcmxs (unsigned long insn,
          | (value & 0x40));
 }
 
-static long
-extract_dcmxs (unsigned long insn,
+static int64_t
+extract_dcmxs (uint64_t insn,
               ppc_cpu_t dialect ATTRIBUTE_UNUSED,
               int *invalid ATTRIBUTE_UNUSED)
 {
@@ -452,46 +453,46 @@ extract_dcmxs (unsigned long insn,
 /* The D field in a DX form instruction when the field is split
    into separate D0, D1 and D2 fields.  */
 
-static unsigned long
-insert_dxd (unsigned long insn,
-           long value,
+static uint64_t
+insert_dxd (uint64_t insn,
+           int64_t value,
            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
            const char **errmsg ATTRIBUTE_UNUSED)
 {
   return insn | (value & 0xffc1) | ((value & 0x3e) << 15);
 }
 
-static long
-extract_dxd (unsigned long insn,
+static int64_t
+extract_dxd (uint64_t insn,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             int *invalid ATTRIBUTE_UNUSED)
 {
-  unsigned long dxd = (insn & 0xffc1) | ((insn >> 15) & 0x3e);
+  uint64_t dxd = (insn & 0xffc1) | ((insn >> 15) & 0x3e);
   return (dxd ^ 0x8000) - 0x8000;
 }
 
-static unsigned long
-insert_dxdn (unsigned long insn,
-            long value,
+static uint64_t
+insert_dxdn (uint64_t insn,
+            int64_t value,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             const char **errmsg ATTRIBUTE_UNUSED)
 {
   return insert_dxd (insn, -value, dialect, errmsg);
 }
 
-static long
-extract_dxdn (unsigned long insn,
+static int64_t
+extract_dxdn (uint64_t insn,
              ppc_cpu_t dialect ATTRIBUTE_UNUSED,
-             int *invalid ATTRIBUTE_UNUSED)
+             int *invalid)
 {
   return -extract_dxd (insn, dialect, invalid);
 }
 
 /* FXM mask in mfcr and mtcrf instructions.  */
 
-static unsigned long
-insert_fxm (unsigned long insn,
-           long value,
+static uint64_t
+insert_fxm (uint64_t insn,
+           int64_t value,
            ppc_cpu_t dialect,
            const char **errmsg)
 {
@@ -531,13 +532,17 @@ insert_fxm (unsigned long insn,
   return insn | ((value & 0xff) << 12);
 }
 
-static long
-extract_fxm (unsigned long insn,
+static int64_t
+extract_fxm (uint64_t insn,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             int *invalid)
 {
-  long mask = (insn >> 12) & 0xff;
+  /* Return a value of -1 for a missing optional operand, which is
+     used as a flag by insert_fxm.  */
+  if (*invalid < 0)
+    return -1;
 
+  int64_t mask = (insn >> 12) & 0xff;
   /* Is this a Power4 insn?  */
   if ((insn & (1 << 20)) != 0)
     {
@@ -558,9 +563,9 @@ extract_fxm (unsigned long insn,
   return mask;
 }
 
-static unsigned long
-insert_li20 (unsigned long insn,
-            long value,
+static uint64_t
+insert_li20 (uint64_t insn,
+            int64_t value,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             const char **errmsg ATTRIBUTE_UNUSED)
 {
@@ -570,18 +575,14 @@ insert_li20 (unsigned long insn,
          | (value & 0x7ff));
 }
 
-static long
-extract_li20 (unsigned long insn,
+static int64_t
+extract_li20 (uint64_t insn,
              ppc_cpu_t dialect ATTRIBUTE_UNUSED,
              int *invalid ATTRIBUTE_UNUSED)
 {
-  long ext = ((insn & 0x4000) == 0x4000) ? 0xfff00000 : 0x00000000;
-
-  return (ext
-         | (((insn >> 11) & 0xf) << 16)
-         | (((insn >> 17) & 0xf) << 12)
-         | (((insn >> 16) & 0x1) << 11)
-         | (insn & 0x7ff));
+  return ((((insn << 5) & 0xf0000)
+          | ((insn >> 5) & 0xf800)
+          | (insn & 0x7ff)) ^ 0x80000) - 0x80000;
 }
 
 /* The 2-bit L field in a SYNC or WC field in a WAIT instruction.
@@ -589,16 +590,16 @@ extract_li20 (unsigned long insn,
      * Value 3 is reserved on newer server cpus.
      * Values 2 and 3 are reserved on all other cpus.  */
 
-static unsigned long
-insert_ls (unsigned long insn,
-          long value,
+static uint64_t
+insert_ls (uint64_t insn,
+          int64_t value,
           ppc_cpu_t dialect,
           const char **errmsg)
 {
   /* For SYNC, some L values are illegal.  */
   if (((insn >> 1) & 0x3ff) == 598)
     {
-      long max_lvalue = (dialect & PPC_OPCODE_POWER4) ? 2 : 1;
+      int64_t max_lvalue = (dialect & PPC_OPCODE_POWER4) ? 2 : 1;
       if (value > max_lvalue)
        {
          *errmsg = _("illegal L operand value");
@@ -609,16 +610,19 @@ insert_ls (unsigned long insn,
   return insn | ((value & 0x3) << 21);
 }
 
-static long
-extract_ls (unsigned long insn,
+static int64_t
+extract_ls (uint64_t insn,
            ppc_cpu_t dialect,
            int *invalid)
 {
-  unsigned long lvalue = (insn >> 21) & 3;
+  /* Missing optional operands have a value of zero.  */
+  if (*invalid < 0)
+    return 0;
 
+  uint64_t lvalue = (insn >> 21) & 3;
   if (((insn >> 1) & 0x3ff) == 598)
     {
-      unsigned long max_lvalue = (dialect & PPC_OPCODE_POWER4) ? 2 : 1;
+      uint64_t max_lvalue = (dialect & PPC_OPCODE_POWER4) ? 2 : 1;
       if (lvalue > max_lvalue)
        *invalid = 1;
     }
@@ -629,48 +633,35 @@ extract_ls (unsigned long insn,
    If ESYNC is non-zero, then the L field must be either 0 or 1 and
    the complement of ESYNC-bit2.  */
 
-static unsigned long
-insert_esync (unsigned long insn,
-             long value,
-             ppc_cpu_t dialect,
+static uint64_t
+insert_esync (uint64_t insn,
+             int64_t value,
+             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
              const char **errmsg)
 {
-  unsigned long ls = (insn >> 21) & 0x03;
+  uint64_t ls = (insn >> 21) & 0x03;
 
-  if (value == 0)
-    {
-      if (((dialect & PPC_OPCODE_E6500) != 0 && ls > 1)
-         || ((dialect & PPC_OPCODE_POWER9) != 0 && ls > 2))
-       *errmsg = _("illegal L operand value");
-      return insn;
-    }
-
-  if ((ls & ~0x1)
-      || (((value >> 1) & 0x1) ^ ls) == 0)
+  if (value != 0
+      && ((~value >> 1) & 0x1) != ls)
     *errmsg = _("incompatible L operand value");
 
   return insn | ((value & 0xf) << 16);
 }
 
-static long
-extract_esync (unsigned long insn,
-              ppc_cpu_t dialect,
+static int64_t
+extract_esync (uint64_t insn,
+              ppc_cpu_t dialect ATTRIBUTE_UNUSED,
               int *invalid)
 {
-  unsigned long ls = (insn >> 21) & 0x3;
-  unsigned long lvalue = (insn >> 16) & 0xf;
+  if (*invalid < 0)
+    return 0;
 
-  if (lvalue == 0)
-    {
-      if (((dialect & PPC_OPCODE_E6500) != 0 && ls > 1)
-         || ((dialect & PPC_OPCODE_POWER9) != 0 && ls > 2))
-       *invalid = 1;
-    }
-  else if ((ls & ~0x1)
-          || (((lvalue >> 1) & 0x1) ^ ls) == 0)
+  uint64_t ls = (insn >> 21) & 0x3;
+  uint64_t value = (insn >> 16) & 0xf;
+  if (value != 0
+      && ((~value >> 1) & 0x1) != ls)
     *invalid = 1;
-
-  return lvalue;
+  return value;
 }
 
 /* The MB and ME fields in an M form instruction expressed as a single
@@ -678,14 +669,14 @@ extract_esync (unsigned long insn,
    marks it as invalid, since we never want to recognize an
    instruction which uses a field of this type.  */
 
-static unsigned long
-insert_mbe (unsigned long insn,
-           long value,
+static uint64_t
+insert_mbe (uint64_t insn,
+           int64_t value,
            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
            const char **errmsg)
 {
-  unsigned long uval, mask;
-  int mb, me, mx, count, last;
+  uint64_t uval, mask;
+  long mb, me, mx, count, last;
 
   uval = value;
 
@@ -707,7 +698,7 @@ insert_mbe (unsigned long insn,
   /* me: location of last 1->0 transition */
   /* count: # transitions */
 
-  for (mx = 0, mask = 1L << 31; mx < 32; ++mx, mask >>= 1)
+  for (mx = 0, mask = (uint64_t) 1 << 31; mx < 32; ++mx, mask >>= 1)
     {
       if ((uval & mask) && !last)
        {
@@ -731,14 +722,14 @@ insert_mbe (unsigned long insn,
   return insn | (mb << 6) | ((me - 1) << 1);
 }
 
-static long
-extract_mbe (unsigned long insn,
+static int64_t
+extract_mbe (uint64_t insn,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             int *invalid)
 {
-  long ret;
-  int mb, me;
-  int i;
+  int64_t ret;
+  long mb, me;
+  long i;
 
   *invalid = 1;
 
@@ -748,7 +739,7 @@ extract_mbe (unsigned long insn,
     {
       ret = 0;
       for (i = mb; i <= me; i++)
-       ret |= 1L << (31 - i);
+       ret |= (uint64_t) 1 << (31 - i);
     }
   else if (mb == me + 1)
     ret = ~0;
@@ -756,7 +747,7 @@ extract_mbe (unsigned long insn,
     {
       ret = ~0;
       for (i = me + 1; i < mb; i++)
-       ret &= ~(1L << (31 - i));
+       ret &= ~((uint64_t) 1 << (31 - i));
     }
   return ret;
 }
@@ -764,17 +755,17 @@ extract_mbe (unsigned long insn,
 /* The MB or ME field in an MD or MDS form instruction.  The high bit
    is wrapped to the low end.  */
 
-static unsigned long
-insert_mb6 (unsigned long insn,
-           long value,
+static uint64_t
+insert_mb6 (uint64_t insn,
+           int64_t value,
            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
            const char **errmsg ATTRIBUTE_UNUSED)
 {
   return insn | ((value & 0x1f) << 6) | (value & 0x20);
 }
 
-static long
-extract_mb6 (unsigned long insn,
+static int64_t
+extract_mb6 (uint64_t insn,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             int *invalid ATTRIBUTE_UNUSED)
 {
@@ -784,12 +775,12 @@ extract_mb6 (unsigned long insn,
 /* The NB field in an X form instruction.  The value 32 is stored as
    0.  */
 
-static long
-extract_nb (unsigned long insn,
+static int64_t
+extract_nb (uint64_t insn,
            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
            int *invalid ATTRIBUTE_UNUSED)
 {
-  long ret;
+  int64_t ret;
 
   ret = (insn >> 11) & 0x1f;
   if (ret == 0)
@@ -800,14 +791,14 @@ extract_nb (unsigned long insn,
 /* The NB field in an lswi instruction, which has special value
    restrictions.  The value 32 is stored as 0.  */
 
-static unsigned long
-insert_nbi (unsigned long insn,
-           long value,
+static uint64_t
+insert_nbi (uint64_t insn,
+           int64_t value,
            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
            const char **errmsg ATTRIBUTE_UNUSED)
 {
-  long rtvalue = (insn >> 21) & 0x1f;
-  long ravalue = (insn >> 16) & 0x1f;
+  int64_t rtvalue = (insn >> 21) & 0x1f;
+  int64_t ravalue = (insn >> 16) & 0x1f;
 
   if (value == 0)
     value = 32;
@@ -822,17 +813,17 @@ insert_nbi (unsigned long insn,
    invalid, since we never want to recognize an instruction which uses
    a field of this type.  */
 
-static unsigned long
-insert_nsi (unsigned long insn,
-           long value,
+static uint64_t
+insert_nsi (uint64_t insn,
+           int64_t value,
            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
            const char **errmsg ATTRIBUTE_UNUSED)
 {
   return insn | (-value & 0xffff);
 }
 
-static long
-extract_nsi (unsigned long insn,
+static int64_t
+extract_nsi (uint64_t insn,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             int *invalid)
 {
@@ -844,25 +835,25 @@ extract_nsi (unsigned long insn,
    load, which means that the RA field may not be zero and may not
    equal the RT field.  */
 
-static unsigned long
-insert_ral (unsigned long insn,
-           long value,
+static uint64_t
+insert_ral (uint64_t insn,
+           int64_t value,
            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
            const char **errmsg)
 {
   if (value == 0
-      || (unsigned long) value == ((insn >> 21) & 0x1f))
+      || (uint64_t) value == ((insn >> 21) & 0x1f))
     *errmsg = "invalid register operand when updating";
   return insn | ((value & 0x1f) << 16);
 }
 
-static long
-extract_ral (unsigned long insn,
+static int64_t
+extract_ral (uint64_t insn,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             int *invalid)
 {
-  long rtvalue = (insn >> 21) & 0x1f;
-  long ravalue = (insn >> 16) & 0x1f;
+  int64_t rtvalue = (insn >> 21) & 0x1f;
+  int64_t ravalue = (insn >> 16) & 0x1f;
 
   if (rtvalue == ravalue || ravalue == 0)
     *invalid = 1;
@@ -872,24 +863,24 @@ extract_ral (unsigned long insn,
 /* The RA field in an lmw instruction, which has special value
    restrictions.  */
 
-static unsigned long
-insert_ram (unsigned long insn,
-           long value,
+static uint64_t
+insert_ram (uint64_t insn,
+           int64_t value,
            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
            const char **errmsg)
 {
-  if ((unsigned long) value >= ((insn >> 21) & 0x1f))
+  if ((uint64_t) value >= ((insn >> 21) & 0x1f))
     *errmsg = _("index register in load range");
   return insn | ((value & 0x1f) << 16);
 }
 
-static long
-extract_ram (unsigned long insn,
+static int64_t
+extract_ram (uint64_t insn,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             int *invalid)
 {
-  unsigned long rtvalue = (insn >> 21) & 0x1f;
-  unsigned long ravalue = (insn >> 16) & 0x1f;
+  uint64_t rtvalue = (insn >> 21) & 0x1f;
+  uint64_t ravalue = (insn >> 16) & 0x1f;
 
   if (ravalue >= rtvalue)
     *invalid = 1;
@@ -899,27 +890,29 @@ extract_ram (unsigned long insn,
 /* The RA field in the DQ form lq or an lswx instruction, which have special
    value restrictions.  */
 
-static unsigned long
-insert_raq (unsigned long insn,
-           long value,
+static uint64_t
+insert_raq (uint64_t insn,
+           int64_t value,
            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
            const char **errmsg)
 {
-  long rtvalue = (insn >> 21) & 0x1f;
+  int64_t rtvalue = (insn >> 21) & 0x1f;
 
   if (value == rtvalue)
     *errmsg = _("source and target register operands must be different");
   return insn | ((value & 0x1f) << 16);
 }
 
-static long
-extract_raq (unsigned long insn,
+static int64_t
+extract_raq (uint64_t insn,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             int *invalid)
 {
-  unsigned long rtvalue = (insn >> 21) & 0x1f;
-  unsigned long ravalue = (insn >> 16) & 0x1f;
+  if (*invalid < 0)
+    return 0;
 
+  uint64_t rtvalue = (insn >> 21) & 0x1f;
+  uint64_t ravalue = (insn >> 16) & 0x1f;
   if (ravalue == rtvalue)
     *invalid = 1;
   return ravalue;
@@ -929,9 +922,9 @@ extract_raq (unsigned long insn,
    store or an updating floating point load, which means that the RA
    field may not be zero.  */
 
-static unsigned long
-insert_ras (unsigned long insn,
-           long value,
+static uint64_t
+insert_ras (uint64_t insn,
+           int64_t value,
            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
            const char **errmsg)
 {
@@ -940,66 +933,68 @@ insert_ras (unsigned long insn,
   return insn | ((value & 0x1f) << 16);
 }
 
-static long
-extract_ras (unsigned long insn,
+static int64_t
+extract_ras (uint64_t insn,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             int *invalid)
 {
-  unsigned long ravalue = (insn >> 16) & 0x1f;
+  uint64_t ravalue = (insn >> 16) & 0x1f;
 
   if (ravalue == 0)
     *invalid = 1;
   return ravalue;
 }
 
-/* The RB field in an X form instruction when it must be the same as
-   the RS field in the instruction.  This is used for extended
-   mnemonics like mr.  This operand is marked FAKE.  The insertion
-   function just copies the BT field into the BA field, and the
-   extraction function just checks that the fields are the same.  */
+/* The RS and RB fields in an X form instruction when they must be the same.
+   This is used for extended mnemonics like mr.  The extraction function
+   enforces that the fields are the same.  */
 
-static unsigned long
-insert_rbs (unsigned long insn,
-           long value ATTRIBUTE_UNUSED,
+static uint64_t
+insert_rsb (uint64_t insn,
+           int64_t value,
            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
            const char **errmsg ATTRIBUTE_UNUSED)
 {
-  return insn | (((insn >> 21) & 0x1f) << 11);
+  value &= 0x1f;
+  return insn | (value << 21) | (value << 11);
 }
 
-static long
-extract_rbs (unsigned long insn,
+static int64_t
+extract_rsb (uint64_t insn,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             int *invalid)
 {
-  if (((insn >> 21) & 0x1f) != ((insn >> 11) & 0x1f))
+  int64_t rs = (insn >> 21) & 0x1f;
+  int64_t rb = (insn >> 11) & 0x1f;
+
+  if (rs != rb)
     *invalid = 1;
-  return 0;
+  return rs;
 }
 
 /* The RB field in an lswx instruction, which has special value
    restrictions.  */
 
-static unsigned long
-insert_rbx (unsigned long insn,
-           long value,
+static uint64_t
+insert_rbx (uint64_t insn,
+           int64_t value,
            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
            const char **errmsg)
 {
-  long rtvalue = (insn >> 21) & 0x1f;
+  int64_t rtvalue = (insn >> 21) & 0x1f;
 
   if (value == rtvalue)
     *errmsg = _("source and target register operands must be different");
   return insn | ((value & 0x1f) << 11);
 }
 
-static long
-extract_rbx (unsigned long insn,
+static int64_t
+extract_rbx (uint64_t insn,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             int *invalid)
 {
-  unsigned long rtvalue = (insn >> 21) & 0x1f;
-  unsigned long rbvalue = (insn >> 11) & 0x1f;
+  uint64_t rtvalue = (insn >> 21) & 0x1f;
+  uint64_t rbvalue = (insn >> 11) & 0x1f;
 
   if (rbvalue == rtvalue)
     *invalid = 1;
@@ -1007,14 +1002,14 @@ extract_rbx (unsigned long insn,
 }
 
 /* The SCI8 field is made up of SCL and {U,N}I8 fields.  */
-static unsigned long
-insert_sci8 (unsigned long insn,
-            long value,
+static uint64_t
+insert_sci8 (uint64_t insn,
+            int64_t value,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             const char **errmsg)
 {
-  unsigned int fill_scale = 0;
-  unsigned long ui8 = value;
+  uint64_t fill_scale = 0;
+  uint64_t ui8 = value;
 
   if ((ui8 & 0xffffff00) == 0)
     ;
@@ -1059,82 +1054,82 @@ insert_sci8 (unsigned long insn,
   return insn | fill_scale | (ui8 & 0xff);
 }
 
-static long
-extract_sci8 (unsigned long insn,
+static int64_t
+extract_sci8 (uint64_t insn,
              ppc_cpu_t dialect ATTRIBUTE_UNUSED,
              int *invalid ATTRIBUTE_UNUSED)
 {
-  int fill = insn & 0x400;
-  int scale_factor = (insn & 0x300) >> 5;
-  long value = (insn & 0xff) << scale_factor;
+  int64_t fill = insn & 0x400;
+  int64_t scale_factor = (insn & 0x300) >> 5;
+  int64_t value = (insn & 0xff) << scale_factor;
 
   if (fill != 0)
-    value |= ~((long) 0xff << scale_factor);
+    value |= ~((int64_t) 0xff << scale_factor);
   return value;
 }
 
-static unsigned long
-insert_sci8n (unsigned long insn,
-             long value,
+static uint64_t
+insert_sci8n (uint64_t insn,
+             int64_t value,
              ppc_cpu_t dialect,
              const char **errmsg)
 {
   return insert_sci8 (insn, -value, dialect, errmsg);
 }
 
-static long
-extract_sci8n (unsigned long insn,
+static int64_t
+extract_sci8n (uint64_t insn,
               ppc_cpu_t dialect,
               int *invalid)
 {
   return -extract_sci8 (insn, dialect, invalid);
 }
 
-static unsigned long
-insert_sd4h (unsigned long insn,
-            long value,
+static uint64_t
+insert_sd4h (uint64_t insn,
+            int64_t value,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             const char **errmsg ATTRIBUTE_UNUSED)
 {
   return insn | ((value & 0x1e) << 7);
 }
 
-static long
-extract_sd4h (unsigned long insn,
+static int64_t
+extract_sd4h (uint64_t insn,
              ppc_cpu_t dialect ATTRIBUTE_UNUSED,
              int *invalid ATTRIBUTE_UNUSED)
 {
   return ((insn >> 8) & 0xf) << 1;
 }
 
-static unsigned long
-insert_sd4w (unsigned long insn,
-            long value,
+static uint64_t
+insert_sd4w (uint64_t insn,
+            int64_t value,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             const char **errmsg ATTRIBUTE_UNUSED)
 {
   return insn | ((value & 0x3c) << 6);
 }
 
-static long
-extract_sd4w (unsigned long insn,
+static int64_t
+extract_sd4w (uint64_t insn,
              ppc_cpu_t dialect ATTRIBUTE_UNUSED,
              int *invalid ATTRIBUTE_UNUSED)
 {
   return ((insn >> 8) & 0xf) << 2;
 }
 
-static unsigned long
-insert_oimm (unsigned long insn,
-            long value,
+static uint64_t
+insert_oimm (uint64_t insn,
+            int64_t value,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             const char **errmsg ATTRIBUTE_UNUSED)
 {
   return insn | (((value - 1) & 0x1f) << 4);
 }
 
-static long
-extract_oimm (unsigned long insn,
+static int64_t
+extract_oimm (uint64_t insn,
              ppc_cpu_t dialect ATTRIBUTE_UNUSED,
              int *invalid ATTRIBUTE_UNUSED)
 {
@@ -1143,9 +1138,9 @@ extract_oimm (unsigned long insn,
 
 /* The SH field in an MD form instruction.  This is split.  */
 
-static unsigned long
-insert_sh6 (unsigned long insn,
-           long value,
+static uint64_t
+insert_sh6 (uint64_t insn,
+           int64_t value,
            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
            const char **errmsg ATTRIBUTE_UNUSED)
 {
@@ -1156,8 +1151,8 @@ insert_sh6 (unsigned long insn,
     return insn | ((value & 0x1f) << 11) | ((value & 0x20) >> 4);
 }
 
-static long
-extract_sh6 (unsigned long insn,
+static int64_t
+extract_sh6 (uint64_t insn,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             int *invalid ATTRIBUTE_UNUSED)
 {
@@ -1171,29 +1166,64 @@ extract_sh6 (unsigned long insn,
 /* The SPR field in an XFX form instruction.  This is flipped--the
    lower 5 bits are stored in the upper 5 and vice- versa.  */
 
-static unsigned long
-insert_spr (unsigned long insn,
-           long value,
+static uint64_t
+insert_spr (uint64_t insn,
+           int64_t value,
            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
            const char **errmsg ATTRIBUTE_UNUSED)
 {
   return insn | ((value & 0x1f) << 16) | ((value & 0x3e0) << 6);
 }
 
-static long
-extract_spr (unsigned long insn,
+static int64_t
+extract_spr (uint64_t insn,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             int *invalid ATTRIBUTE_UNUSED)
 {
   return ((insn >> 16) & 0x1f) | ((insn >> 6) & 0x3e0);
 }
 
+/* Some dialects have 8 [DI]BAT registers instead of the standard 4.  */
+#define ALLOW8_BAT (PPC_OPCODE_750)
+
+static uint64_t
+insert_sprbat (uint64_t insn,
+              int64_t value,
+              ppc_cpu_t dialect,
+              const char **errmsg)
+{
+  if (value > 7
+      || (value > 3 && (dialect & ALLOW8_BAT) == 0))
+    *errmsg = _("invalid bat number");
+
+  /* If this is [di]bat4..7 then use spr 560..575, otherwise 528..543.  */
+  if (value > 3)
+    value = ((value & 3) << 6) | 1;
+  else
+    value = value << 6;
+
+  return insn | (value << 11);
+}
+
+static int64_t
+extract_sprbat (uint64_t insn,
+               ppc_cpu_t dialect,
+               int *invalid)
+{
+  uint64_t val = (insn >> 17) & 0x3;
+
+  val = val + ((insn >> 9) & 0x4);
+  if (val > 3 && (dialect & ALLOW8_BAT) == 0)
+    *invalid = 1;
+  return val;
+}
+
 /* Some dialects have 8 SPRG registers instead of the standard 4.  */
 #define ALLOW8_SPRG (PPC_OPCODE_BOOKE | PPC_OPCODE_405)
 
-static unsigned long
-insert_sprg (unsigned long insn,
-            long value,
+static uint64_t
+insert_sprg (uint64_t insn,
+            int64_t value,
             ppc_cpu_t dialect,
             const char **errmsg)
 {
@@ -1209,12 +1239,12 @@ insert_sprg (unsigned long insn,
   return insn | ((value & 0x17) << 16);
 }
 
-static long
-extract_sprg (unsigned long insn,
+static int64_t
+extract_sprg (uint64_t insn,
              ppc_cpu_t dialect,
              int *invalid)
 {
-  unsigned long val = (insn >> 16) & 0x1f;
+  uint64_t val = (insn >> 16) & 0x1f;
 
   /* mfsprg can use 260..263 and 272..279.  mtsprg only uses spr 272..279
      If not BOOKE, 405 or VLE, then both use only 272..275.  */
@@ -1229,9 +1259,9 @@ extract_sprg (unsigned long insn,
 /* The TBR field in an XFX instruction.  This is just like SPR, but it
    is optional.  */
 
-static unsigned long
-insert_tbr (unsigned long insn,
-           long value,
+static uint64_t
+insert_tbr (uint64_t insn,
+           int64_t value,
            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
            const char **errmsg)
 {
@@ -1240,14 +1270,15 @@ insert_tbr (unsigned long insn,
   return insn | ((value & 0x1f) << 16) | ((value & 0x3e0) << 6);
 }
 
-static long
-extract_tbr (unsigned long insn,
+static int64_t
+extract_tbr (uint64_t insn,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             int *invalid)
 {
-  long ret;
+  if (*invalid < 0)
+    return 268;
 
-  ret = ((insn >> 16) & 0x1f) | ((insn >> 6) & 0x3e0);
+  int64_t ret = ((insn >> 16) & 0x1f) | ((insn >> 6) & 0x3e0);
   if (ret != 268 && ret != 269)
     *invalid = 1;
   return ret;
@@ -1255,17 +1286,17 @@ extract_tbr (unsigned long insn,
 
 /* The XT and XS fields in an XX1 or XX3 form instruction.  This is split.  */
 
-static unsigned long
-insert_xt6 (unsigned long insn,
-           long value,
+static uint64_t
+insert_xt6 (uint64_t insn,
+           int64_t value,
            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
            const char **errmsg ATTRIBUTE_UNUSED)
 {
   return insn | ((value & 0x1f) << 21) | ((value & 0x20) >> 5);
 }
 
-static long
-extract_xt6 (unsigned long insn,
+static int64_t
+extract_xt6 (uint64_t insn,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             int *invalid ATTRIBUTE_UNUSED)
 {
@@ -1273,17 +1304,17 @@ extract_xt6 (unsigned long insn,
 }
 
 /* The XT and XS fields in an DQ form VSX instruction.  This is split.  */
-static unsigned long
-insert_xtq6 (unsigned long insn,
-            long value,
+static uint64_t
+insert_xtq6 (uint64_t insn,
+            int64_t value,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             const char **errmsg ATTRIBUTE_UNUSED)
 {
   return insn | ((value & 0x1f) << 21) | ((value & 0x20) >> 2);
 }
 
-static long
-extract_xtq6 (unsigned long insn,
+static int64_t
+extract_xtq6 (uint64_t insn,
              ppc_cpu_t dialect ATTRIBUTE_UNUSED,
              int *invalid ATTRIBUTE_UNUSED)
 {
@@ -1292,17 +1323,17 @@ extract_xtq6 (unsigned long insn,
 
 /* The XA field in an XX3 form instruction.  This is split.  */
 
-static unsigned long
-insert_xa6 (unsigned long insn,
-           long value,
+static uint64_t
+insert_xa6 (uint64_t insn,
+           int64_t value,
            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
            const char **errmsg ATTRIBUTE_UNUSED)
 {
   return insn | ((value & 0x1f) << 16) | ((value & 0x20) >> 3);
 }
 
-static long
-extract_xa6 (unsigned long insn,
+static int64_t
+extract_xa6 (uint64_t insn,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             int *invalid ATTRIBUTE_UNUSED)
 {
@@ -1311,71 +1342,72 @@ extract_xa6 (unsigned long insn,
 
 /* The XB field in an XX3 form instruction.  This is split.  */
 
-static unsigned long
-insert_xb6 (unsigned long insn,
-           long value,
+static uint64_t
+insert_xb6 (uint64_t insn,
+           int64_t value,
            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
            const char **errmsg ATTRIBUTE_UNUSED)
 {
   return insn | ((value & 0x1f) << 11) | ((value & 0x20) >> 4);
 }
 
-static long
-extract_xb6 (unsigned long insn,
+static int64_t
+extract_xb6 (uint64_t insn,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             int *invalid ATTRIBUTE_UNUSED)
 {
   return ((insn << 4) & 0x20) | ((insn >> 11) & 0x1f);
 }
 
-/* The XB field in an XX3 form instruction when it must be the same as
-   the XA field in the instruction.  This is used for extended
-   mnemonics like xvmovdp.  This operand is marked FAKE.  The insertion
-   function just copies the XA field into the XB field, and the
-   extraction function just checks that the fields are the same.  */
+/* The XA and XB fields in an XX3 form instruction when they must be the same.
+   This is used for extended mnemonics like xvmovdp.  The extraction function
+   enforces that the fields are the same.  */
 
-static unsigned long
-insert_xb6s (unsigned long insn,
-            long value ATTRIBUTE_UNUSED,
-            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
-            const char **errmsg ATTRIBUTE_UNUSED)
+static uint64_t
+insert_xab6 (uint64_t insn,
+            int64_t value,
+            ppc_cpu_t dialect,
+            const char **errmsg)
 {
-  return insn | (((insn >> 16) & 0x1f) << 11) | (((insn >> 2) & 0x1) << 1);
+  return insert_xa6 (insn, value, dialect, errmsg)
+        | insert_xb6 (insn, value, dialect, errmsg);
 }
 
-static long
-extract_xb6s (unsigned long insn,
-             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
+static int64_t
+extract_xab6 (uint64_t insn,
+             ppc_cpu_t dialect,
              int *invalid)
 {
-  if ((((insn >> 16) & 0x1f) != ((insn >> 11) & 0x1f))
-      || (((insn >> 2) & 0x1) != ((insn >> 1) & 0x1)))
+  int64_t xa6 = extract_xa6 (insn, dialect, invalid);
+  int64_t xb6 = extract_xb6 (insn, dialect, invalid);
+
+  if (xa6 != xb6)
     *invalid = 1;
-  return 0;
+  return xa6;
 }
 
 /* The XC field in an XX4 form instruction.  This is split.  */
 
-static unsigned long
-insert_xc6 (unsigned long insn,
-           long value,
+static uint64_t
+insert_xc6 (uint64_t insn,
+           int64_t value,
            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
            const char **errmsg ATTRIBUTE_UNUSED)
 {
   return insn | ((value & 0x1f) << 6) | ((value & 0x20) >> 2);
 }
 
-static long
-extract_xc6 (unsigned long insn,
+static int64_t
+extract_xc6 (uint64_t insn,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             int *invalid ATTRIBUTE_UNUSED)
 {
   return ((insn << 2) & 0x20) | ((insn >> 6) & 0x1f);
 }
 
-static unsigned long
-insert_dm (unsigned long insn,
-          long value,
+static uint64_t
+insert_dm (uint64_t insn,
+          int64_t value,
           ppc_cpu_t dialect ATTRIBUTE_UNUSED,
           const char **errmsg)
 {
@@ -1384,14 +1416,12 @@ insert_dm (unsigned long insn,
   return insn | (((value) ? 3 : 0) << 8);
 }
 
-static long
-extract_dm (unsigned long insn,
+static int64_t
+extract_dm (uint64_t insn,
            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
            int *invalid)
 {
-  long value;
-
-  value = (insn >> 8) & 3;
+  int64_t value = (insn >> 8) & 3;
   if (value != 0 && value != 3)
     *invalid = 1;
   return (value) ? 1 : 0;
@@ -1399,40 +1429,40 @@ extract_dm (unsigned long insn,
 
 /* The VLESIMM field in an I16A form instruction.  This is split.  */
 
-static unsigned long
-insert_vlesi (unsigned long insn,
-             long value,
+static uint64_t
+insert_vlesi (uint64_t insn,
+             int64_t value,
              ppc_cpu_t dialect ATTRIBUTE_UNUSED,
              const char **errmsg ATTRIBUTE_UNUSED)
 {
   return insn | ((value & 0xf800) << 10) | (value & 0x7ff);
 }
 
-static long
-extract_vlesi (unsigned long insn,
+static int64_t
+extract_vlesi (uint64_t insn,
               ppc_cpu_t dialect ATTRIBUTE_UNUSED,
               int *invalid ATTRIBUTE_UNUSED)
 {
-  long value = ((insn >> 10) & 0xf800) | (insn & 0x7ff);
+  int64_t value = ((insn >> 10) & 0xf800) | (insn & 0x7ff);
   value = (value ^ 0x8000) - 0x8000;
   return value;
 }
 
-static unsigned long
-insert_vlensi (unsigned long insn,
-              long value,
+static uint64_t
+insert_vlensi (uint64_t insn,
+              int64_t value,
               ppc_cpu_t dialect ATTRIBUTE_UNUSED,
               const char **errmsg ATTRIBUTE_UNUSED)
 {
   value = -value;
   return insn | ((value & 0xf800) << 10) | (value & 0x7ff);
 }
-static long
-extract_vlensi (unsigned long insn,
+static int64_t
+extract_vlensi (uint64_t insn,
                ppc_cpu_t dialect ATTRIBUTE_UNUSED,
-               int *invalid ATTRIBUTE_UNUSED)
+               int *invalid)
 {
-  long value = ((insn >> 10) & 0xf800) | (insn & 0x7ff);
+  int64_t value = ((insn >> 10) & 0xf800) | (insn & 0x7ff);
   value = (value ^ 0x8000) - 0x8000;
   /* Don't use for disassembly.  */
   *invalid = 1;
@@ -1441,17 +1471,17 @@ extract_vlensi (unsigned long insn,
 
 /* The VLEUIMM field in an I16A form instruction.  This is split.  */
 
-static unsigned long
-insert_vleui (unsigned long insn,
-             long value,
+static uint64_t
+insert_vleui (uint64_t insn,
+             int64_t value,
              ppc_cpu_t dialect ATTRIBUTE_UNUSED,
              const char **errmsg ATTRIBUTE_UNUSED)
 {
   return insn | ((value & 0xf800) << 10) | (value & 0x7ff);
 }
 
-static long
-extract_vleui (unsigned long insn,
+static int64_t
+extract_vleui (uint64_t insn,
               ppc_cpu_t dialect ATTRIBUTE_UNUSED,
               int *invalid ATTRIBUTE_UNUSED)
 {
@@ -1460,26 +1490,26 @@ extract_vleui (unsigned long insn,
 
 /* The VLEUIMML field in an I16L form instruction.  This is split.  */
 
-static unsigned long
-insert_vleil (unsigned long insn,
-             long value,
+static uint64_t
+insert_vleil (uint64_t insn,
+             int64_t value,
              ppc_cpu_t dialect ATTRIBUTE_UNUSED,
              const char **errmsg ATTRIBUTE_UNUSED)
 {
   return insn | ((value & 0xf800) << 5) | (value & 0x7ff);
 }
 
-static long
-extract_vleil (unsigned long insn,
+static int64_t
+extract_vleil (uint64_t insn,
               ppc_cpu_t dialect ATTRIBUTE_UNUSED,
               int *invalid ATTRIBUTE_UNUSED)
 {
   return ((insn >> 5) & 0xf800) | (insn & 0x7ff);
 }
 
-static unsigned long
-insert_evuimm1_ex0 (unsigned long insn,
-                   long value,
+static uint64_t
+insert_evuimm1_ex0 (uint64_t insn,
+                   int64_t value,
                    ppc_cpu_t dialect ATTRIBUTE_UNUSED,
                    const char **errmsg)
 {
@@ -1492,21 +1522,21 @@ insert_evuimm1_ex0 (unsigned long insn,
     }
 }
 
-static long
-extract_evuimm1_ex0 (unsigned long insn,
+static int64_t
+extract_evuimm1_ex0 (uint64_t insn,
                     ppc_cpu_t dialect ATTRIBUTE_UNUSED,
                     int *invalid)
 {
-  long value = ((insn >> 11) & 0x1f);
+  int64_t value = ((insn >> 11) & 0x1f);
   if (value == 0)
     *invalid = 1;
 
   return value;
 }
 
-static unsigned long
-insert_evuimm2_ex0 (unsigned long insn,
-                   long value,
+static uint64_t
+insert_evuimm2_ex0 (uint64_t insn,
+                   int64_t value,
                    ppc_cpu_t dialect ATTRIBUTE_UNUSED,
                    const char **errmsg)
 {
@@ -1519,21 +1549,21 @@ insert_evuimm2_ex0 (unsigned long insn,
     }
 }
 
-static long
-extract_evuimm2_ex0 (unsigned long insn,
+static int64_t
+extract_evuimm2_ex0 (uint64_t insn,
                     ppc_cpu_t dialect ATTRIBUTE_UNUSED,
                     int *invalid)
 {
-  long value = ((insn >> 10) & 0x3e);
+  int64_t value = ((insn >> 10) & 0x3e);
   if (value == 0)
     *invalid = 1;
 
   return value;
 }
 
-static unsigned long
-insert_evuimm4_ex0 (unsigned long insn,
-                   long value,
+static uint64_t
+insert_evuimm4_ex0 (uint64_t insn,
+                   int64_t value,
                    ppc_cpu_t dialect ATTRIBUTE_UNUSED,
                    const char **errmsg)
 {
@@ -1546,21 +1576,21 @@ insert_evuimm4_ex0 (unsigned long insn,
     }
 }
 
-static long
-extract_evuimm4_ex0 (unsigned long insn,
+static int64_t
+extract_evuimm4_ex0 (uint64_t insn,
                     ppc_cpu_t dialect ATTRIBUTE_UNUSED,
                     int *invalid)
 {
-  long value = ((insn >> 9) & 0x7c);
+  int64_t value = ((insn >> 9) & 0x7c);
   if (value == 0)
     *invalid = 1;
 
   return value;
 }
 
-static unsigned long
-insert_evuimm8_ex0 (unsigned long insn,
-                   long value,
+static uint64_t
+insert_evuimm8_ex0 (uint64_t insn,
+                   int64_t value,
                    ppc_cpu_t dialect ATTRIBUTE_UNUSED,
                    const char **errmsg)
 {
@@ -1573,21 +1603,21 @@ insert_evuimm8_ex0 (unsigned long insn,
     }
 }
 
-static long
-extract_evuimm8_ex0 (unsigned long insn,
+static int64_t
+extract_evuimm8_ex0 (uint64_t insn,
                     ppc_cpu_t dialect ATTRIBUTE_UNUSED,
                     int *invalid)
 {
-  long value = ((insn >> 8) & 0xf8);
+  int64_t value = ((insn >> 8) & 0xf8);
   if (value == 0)
     *invalid = 1;
 
   return value;
 }
 
-static unsigned long
-insert_evuimm_lt8 (unsigned long insn,
-                  long value,
+static uint64_t
+insert_evuimm_lt8 (uint64_t insn,
+                  int64_t value,
                   ppc_cpu_t dialect ATTRIBUTE_UNUSED,
                   const char **errmsg)
 {
@@ -1600,21 +1630,21 @@ insert_evuimm_lt8 (unsigned long insn,
     }
 }
 
-static long
-extract_evuimm_lt8 (unsigned long insn,
+static int64_t
+extract_evuimm_lt8 (uint64_t insn,
                    ppc_cpu_t dialect ATTRIBUTE_UNUSED,
                    int *invalid)
 {
-  long value = ((insn >> 11) & 0x1f);
+  int64_t value = ((insn >> 11) & 0x1f);
   if (value > 7)
     *invalid = 1;
 
   return value;
 }
 
-static unsigned long
-insert_evuimm_lt16 (unsigned long insn,
-                   long value,
+static uint64_t
+insert_evuimm_lt16 (uint64_t insn,
+                   int64_t value,
                    ppc_cpu_t dialect ATTRIBUTE_UNUSED,
                    const char **errmsg)
 {
@@ -1627,21 +1657,21 @@ insert_evuimm_lt16 (unsigned long insn,
     }
 }
 
-static long
-extract_evuimm_lt16 (unsigned long insn,
+static int64_t
+extract_evuimm_lt16 (uint64_t insn,
                     ppc_cpu_t dialect ATTRIBUTE_UNUSED,
                     int *invalid)
 {
-  long value = ((insn >> 11) & 0x1f);
+  int64_t value = ((insn >> 11) & 0x1f);
   if (value > 15)
     *invalid = 1;
 
   return value;
 }
 
-static unsigned long
-insert_rD_rS_even (unsigned long insn,
-                  long value,
+static uint64_t
+insert_rD_rS_even (uint64_t insn,
+                  int64_t value,
                   ppc_cpu_t dialect ATTRIBUTE_UNUSED,
                   const char **errmsg)
 {
@@ -1654,21 +1684,21 @@ insert_rD_rS_even (unsigned long insn,
     }
 }
 
-static long
-extract_rD_rS_even (unsigned long insn,
+static int64_t
+extract_rD_rS_even (uint64_t insn,
                    ppc_cpu_t dialect ATTRIBUTE_UNUSED,
                    int *invalid)
 {
-  long value = ((insn >> 21) & 0x1f);
+  int64_t value = ((insn >> 21) & 0x1f);
   if ((value & 0x1) != 0)
     *invalid = 1;
 
   return value;
 }
 
-static unsigned long
-insert_off_lsp (unsigned long insn,
-               long value,
+static uint64_t
+insert_off_lsp (uint64_t insn,
+               int64_t value,
                ppc_cpu_t dialect ATTRIBUTE_UNUSED,
                const char **errmsg)
 {
@@ -1681,21 +1711,21 @@ insert_off_lsp (unsigned long insn,
     }
 }
 
-static long
-extract_off_lsp (unsigned long insn,
+static int64_t
+extract_off_lsp (uint64_t insn,
                 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
                 int *invalid)
 {
-  long value = (insn & 0x3);
+  int64_t value = (insn & 0x3);
   if (value == 0)
     *invalid = 1;
 
   return value;
 }
 
-static unsigned long
-insert_off_spe2 (unsigned long insn,
-                long value,
+static uint64_t
+insert_off_spe2 (uint64_t insn,
+                int64_t value,
                 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
                 const char **errmsg)
 {
@@ -1708,21 +1738,21 @@ insert_off_spe2 (unsigned long insn,
     }
 }
 
-static long
-extract_off_spe2 (unsigned long insn,
+static int64_t
+extract_off_spe2 (uint64_t insn,
                  ppc_cpu_t dialect ATTRIBUTE_UNUSED,
                  int *invalid)
 {
-  long value = (insn & 0x7);
+  int64_t value = (insn & 0x7);
   if (value == 0)
     *invalid = 1;
 
   return value;
 }
 
-static unsigned long
-insert_Ddd (unsigned long insn,
-           long value,
+static uint64_t
+insert_Ddd (uint64_t insn,
+           int64_t value,
            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
            const char **errmsg)
 {
@@ -1735,13 +1765,32 @@ insert_Ddd (unsigned long insn,
     }
 }
 
-static long
-extract_Ddd (unsigned long insn,
+static int64_t
+extract_Ddd (uint64_t insn,
             ppc_cpu_t dialect ATTRIBUTE_UNUSED,
             int *invalid ATTRIBUTE_UNUSED)
 {
   return ((insn >> 11) & 0x3) | ((insn << 2) & 0x4);
 }
+
+static uint64_t
+insert_sxl (uint64_t insn,
+           int64_t value,
+           ppc_cpu_t dialect ATTRIBUTE_UNUSED,
+           const char **errmsg ATTRIBUTE_UNUSED)
+{
+  return insn | ((value & 0x1) << 11);
+}
+
+static int64_t
+extract_sxl (uint64_t insn,
+            ppc_cpu_t dialect ATTRIBUTE_UNUSED,
+            int *invalid)
+{
+  if (*invalid < 0)
+    return 1;
+  return (insn >> 11) & 0x1;
+}
 \f
 /* The operands table.
 
@@ -1768,27 +1817,34 @@ const struct powerpc_operand powerpc_operands[] =
 #define BI_MASK (0x1f << 16)
   { 0x1f, 16, NULL, NULL, PPC_OPERAND_CR_BIT },
 
-  /* The BA field in an XL form instruction when it must be the same
-     as the BT field in the same instruction.  */
-#define BAT BA + 1
-  { 0x1f, 16, insert_bat, extract_bat, PPC_OPERAND_FAKE },
+  /* The BT, BA and BB fields in a XL form instruction when they must all
+     be the same.  */
+#define BTAB BA + 1
+  { 0x1f, 21, insert_btab, extract_btab, PPC_OPERAND_CR_BIT },
 
   /* The BB field in an XL form instruction.  */
-#define BB BAT + 1
+#define BB BTAB + 1
 #define BB_MASK (0x1f << 11)
   { 0x1f, 11, NULL, NULL, PPC_OPERAND_CR_BIT },
 
-  /* The BB field in an XL form instruction when it must be the same
-     as the BA field in the same instruction.  */
-#define BBA BB + 1
-  /* The VB field in a VX form instruction when it must be the same
-     as the VA field in the same instruction.  */
-#define VBA BBA
-  { 0x1f, 11, insert_bba, extract_bba, PPC_OPERAND_FAKE },
+  /* The BA and BB fields in a XL form instruction when they must be
+     the same.  */
+#define BAB BB + 1
+  { 0x1f, 16, insert_bab, extract_bab, PPC_OPERAND_CR_BIT },
+
+  /* The VRA and VRB fields in a VX form instruction when they must be the same.
+     This is used for extended mnemonics like vmr.  */
+#define VAB BAB + 1
+  { 0x1f, 16, insert_bab, extract_bab, PPC_OPERAND_VR },
+
+  /* The RA and RB fields in a VX form instruction when they must be the same.
+     This is used for extended mnemonics like evmr.  */
+#define RAB VAB + 1
+  { 0x1f, 16, insert_bab, extract_bab, PPC_OPERAND_GPR },
 
   /* The BD field in a B form instruction.  The lower two bits are
      forced to zero.  */
-#define BD BBA + 1
+#define BD RAB + 1
   { 0xfffc, 0, NULL, NULL, PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED },
 
   /* The BD field in a B form instruction when absolute addressing is
@@ -2033,13 +2089,10 @@ const struct powerpc_operand powerpc_operands[] =
 
   /* Power4 version for mfcr.  */
 #define FXM4 FXM + 1
-  { 0xff, 12, insert_fxm, extract_fxm,
-    PPC_OPERAND_OPTIONAL | PPC_OPERAND_OPTIONAL_VALUE},
-  /* If the FXM4 operand is ommitted, use the sentinel value -1.  */
-  { -1, -1, NULL, NULL, 0},
+  { 0xff, 12, insert_fxm, extract_fxm, PPC_OPERAND_OPTIONAL },
 
   /* The IMM20 field in an LI instruction.  */
-#define IMM20 FXM4 + 2
+#define IMM20 FXM4 + 1
   { 0xfffff, PPC_OPSHIFT_INV, insert_li20, extract_li20, PPC_OPERAND_SIGNED},
 
   /* The L field in a D or X form instruction.  */
@@ -2167,15 +2220,14 @@ const struct powerpc_operand powerpc_operands[] =
 #define RB_MASK (0x1f << 11)
   { 0x1f, 11, NULL, NULL, PPC_OPERAND_GPR },
 
-  /* The RB field in an X form instruction when it must be the same as
-     the RS field in the instruction.  This is used for extended
-     mnemonics like mr.  */
-#define RBS RB + 1
-  { 0x1f, 11, insert_rbs, extract_rbs, PPC_OPERAND_FAKE },
+  /* The RS and RB fields in an X form instruction when they must be the same.
+     This is used for extended mnemonics like mr.  */
+#define RSB RB + 1
+  { 0x1f, 11, insert_rsb, extract_rsb, PPC_OPERAND_GPR },
 
   /* The RB field in an lswx instruction, which has special value
      restrictions.  */
-#define RBX RBS + 1
+#define RBX RSB + 1
   { 0x1f, 11, insert_rbx, extract_rbx, PPC_OPERAND_GPR },
 
   /* The RB field of the dccci and iccci instructions, which are optional.  */
@@ -2303,11 +2355,16 @@ const struct powerpc_operand powerpc_operands[] =
 
   /* The BAT index number in an XFX form m[ft]ibat[lu] instruction.  */
 #define SPRBAT SPR + 1
-#define SPRBAT_MASK (0x3 << 17)
-  { 0x3, 17, NULL, NULL, 0 },
+#define SPRBAT_MASK (0xc1 << 11)
+  { 0x7, PPC_OPSHIFT_INV, insert_sprbat, extract_sprbat, PPC_OPERAND_SPR },
+
+  /* The GQR index number in an XFX form m[ft]gqr instruction.  */
+#define SPRGQR SPRBAT + 1
+#define SPRGQR_MASK (0x7 << 16)
+  { 0x7, 16, NULL, NULL, PPC_OPERAND_GQR },
 
   /* The SPRG register number in an XFX form m[ft]sprg instruction.  */
-#define SPRG SPRBAT + 1
+#define SPRG SPRGQR + 1
   { 0x1f, 16, insert_sprg, extract_sprg, PPC_OPERAND_SPR },
 
   /* The SR field in an X form instruction.  */
@@ -2336,12 +2393,10 @@ const struct powerpc_operand powerpc_operands[] =
      field, but it is optional.  */
 #define TBR SV + 1
   { 0x3ff, 11, insert_tbr, extract_tbr,
-    PPC_OPERAND_SPR | PPC_OPERAND_OPTIONAL | PPC_OPERAND_OPTIONAL_VALUE},
-  /* If the TBR operand is ommitted, use the value 268.  */
-  { -1, 268, NULL, NULL, 0},
+    PPC_OPERAND_SPR | PPC_OPERAND_OPTIONAL },
 
   /* The TO field in a D or X form instruction.  */
-#define TO TBR + 2
+#define TO TBR + 1
 #define DUI TO
 #define TO_MASK (0x1f << 21)
   { 0x1f, 21, NULL, NULL, 0 },
@@ -2495,12 +2550,10 @@ const struct powerpc_operand powerpc_operands[] =
 
   /* The S field in a XL form instruction.  */
 #define SXL S + 1
-  { 0x1, 11, NULL, NULL, PPC_OPERAND_OPTIONAL | PPC_OPERAND_OPTIONAL_VALUE},
-  /* If the SXL operand is ommitted, use the value 1.  */
-  { -1, 1, NULL, NULL, 0},
+  { 0x1, 11, insert_sxl, extract_sxl, PPC_OPERAND_OPTIONAL },
 
   /* SH field starting at bit position 16.  */
-#define SH16 SXL + 2
+#define SH16 SXL + 1
   /* The DCM and DGM fields in a Z form instruction.  */
 #define DCM SH16
 #define DGM DCM
@@ -2576,14 +2629,13 @@ const struct powerpc_operand powerpc_operands[] =
 #define XB6 XA6 + 1
   { 0x3f, PPC_OPSHIFT_INV, insert_xb6, extract_xb6, PPC_OPERAND_VSR },
 
-  /* The XB field in an XX3 form instruction when it must be the same as
-     the XA field in the instruction.  This is used in extended mnemonics
-     like xvmovdp.  This is split.  */
-#define XB6S XB6 + 1
-  { 0x3f, PPC_OPSHIFT_INV, insert_xb6s, extract_xb6s, PPC_OPERAND_FAKE },
+  /* The XA and XB fields in an XX3 form instruction when they must be the same.
+     This is used in extended mnemonics like xvmovdp.  This is split.  */
+#define XAB6 XB6 + 1
+  { 0x3f, PPC_OPSHIFT_INV, insert_xab6, extract_xab6, PPC_OPERAND_VSR },
 
   /* The XC field in an XX4 form instruction.  This is split.  */
-#define XC6 XB6S + 1
+#define XC6 XAB6 + 1
   { 0x3f, PPC_OPSHIFT_INV, insert_xc6, extract_xc6, PPC_OPERAND_VSR },
 
   /* The DM or SHW field in an XX3 form instruction.  */
@@ -2636,24 +2688,24 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
 /* Macros used to form opcodes.  */
 
 /* The main opcode.  */
-#define OP(x) ((((unsigned long)(x)) & 0x3f) << 26)
+#define OP(x) ((((uint64_t)(x)) & 0x3f) << 26)
 #define OP_MASK OP (0x3f)
 
 /* The main opcode combined with a trap code in the TO field of a D
    form instruction.  Used for extended mnemonics for the trap
    instructions.  */
-#define OPTO(x,to) (OP (x) | ((((unsigned long)(to)) & 0x1f) << 21))
+#define OPTO(x,to) (OP (x) | ((((uint64_t)(to)) & 0x1f) << 21))
 #define OPTO_MASK (OP_MASK | TO_MASK)
 
 /* The main opcode combined with a comparison size bit in the L field
    of a D form or X form instruction.  Used for extended mnemonics for
    the comparison instructions.  */
-#define OPL(x,l) (OP (x) | ((((unsigned long)(l)) & 1) << 21))
+#define OPL(x,l) (OP (x) | ((((uint64_t)(l)) & 1) << 21))
 #define OPL_MASK OPL (0x3f,1)
 
 /* The main opcode combined with an update code in D form instruction.
    Used for extended mnemonics for VLE memory instructions.  */
-#define OPVUP(x,vup) (OP (x) | ((((unsigned long)(vup)) & 0xff) << 8))
+#define OPVUP(x,vup) (OP (x) | ((((uint64_t)(vup)) & 0xff) << 8))
 #define OPVUP_MASK OPVUP (0x3f,  0xff)
 
 /* The main opcode combined with an update code and the RT fields
@@ -2661,14 +2713,14 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
    save/restore instructions.  */
 #define OPVUPRT(x,vup,rt)                      \
   (OPVUP (x, vup)                              \
-   | ((((unsigned long)(rt)) & 0x1f) << 21))
+   | ((((uint64_t)(rt)) & 0x1f) << 21))
 #define OPVUPRT_MASK OPVUPRT (0x3f, 0xff, 0x1f)
 
 /* An A form instruction.  */
 #define A(op, xop, rc)                         \
   (OP (op)                                     \
-   | ((((unsigned long)(xop)) & 0x1f) << 1)    \
-   | (((unsigned long)(rc)) & 1))
+   | ((((uint64_t)(xop)) & 0x1f) << 1) \
+   | (((uint64_t)(rc)) & 1))
 #define A_MASK A (0x3f, 0x1f, 1)
 
 /* An A_MASK with the FRB field fixed.  */
@@ -2681,24 +2733,24 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
 #define AFRAFRC_MASK (A_MASK | FRA_MASK | FRC_MASK)
 
 /* An AFRAFRC_MASK, but with L bit clear.  */
-#define AFRALFRC_MASK (AFRAFRC_MASK & ~((unsigned long) 1 << 16))
+#define AFRALFRC_MASK (AFRAFRC_MASK & ~((uint64_t) 1 << 16))
 
 /* A B form instruction.  */
 #define B(op, aa, lk)                          \
   (OP (op)                                     \
-   | ((((unsigned long)(aa)) & 1) << 1)                \
+   | ((((uint64_t)(aa)) & 1) << 1)             \
    | ((lk) & 1))
 #define B_MASK B (0x3f, 1, 1)
 
 /* A BD8 form instruction.  This is a 16-bit instruction.  */
 #define BD8(op, aa, lk)                                \
-  (((((unsigned long)(op)) & 0x3f) << 10)      \
+  (((((uint64_t)(op)) & 0x3f) << 10)   \
    | (((aa) & 1) << 9)                         \
    | (((lk) & 1) << 8))
 #define BD8_MASK BD8 (0x3f, 1, 1)
 
 /* Another BD8 form instruction.  This is a 16-bit instruction.  */
-#define BD8IO(op) ((((unsigned long)(op)) & 0x1f) << 11)
+#define BD8IO(op) ((((uint64_t)(op)) & 0x1f) << 11)
 #define BD8IO_MASK BD8IO (0x1f)
 
 /* A BD8 form instruction for simplified mnemonics.  */
@@ -2713,7 +2765,7 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
 /* A BD15 form instruction.  */
 #define BD15(op, aa, lk)                       \
   (OP (op)                                     \
-   | ((((unsigned long)(aa)) & 0xf) << 22)     \
+   | ((((uint64_t)(aa)) & 0xf) << 22)  \
    | ((lk) & 1))
 #define BD15_MASK BD15 (0x3f, 0xf, 1)
 
@@ -2739,29 +2791,29 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
 /* A BD24 form instruction.  */
 #define BD24(op, aa, lk)                       \
   (OP (op)                                     \
-   | ((((unsigned long)(aa)) & 1) << 25)       \
+   | ((((uint64_t)(aa)) & 1) << 25)    \
    | ((lk) & 1))
 #define BD24_MASK BD24 (0x3f, 1, 1)
 
 /* A B form instruction setting the BO field.  */
 #define BBO(op, bo, aa, lk)                    \
   (B ((op), (aa), (lk))                                \
-   | ((((unsigned long)(bo)) & 0x1f) << 21))
+   | ((((uint64_t)(bo)) & 0x1f) << 21))
 #define BBO_MASK BBO (0x3f, 0x1f, 1, 1)
 
 /* A BBO_MASK with the y bit of the BO field removed.  This permits
    matching a conditional branch regardless of the setting of the y
    bit.  Similarly for the 'at' bits used for power4 branch hints.  */
-#define Y_MASK  (((unsigned long) 1) << 21)
-#define AT1_MASK (((unsigned long) 3) << 21)
-#define AT2_MASK (((unsigned long) 9) << 21)
+#define Y_MASK  (((uint64_t) 1) << 21)
+#define AT1_MASK (((uint64_t) 3) << 21)
+#define AT2_MASK (((uint64_t) 9) << 21)
 #define BBOY_MASK  (BBO_MASK &~ Y_MASK)
 #define BBOAT_MASK (BBO_MASK &~ AT1_MASK)
 
 /* A B form instruction setting the BO field and the condition bits of
    the BI field.  */
 #define BBOCB(op, bo, cb, aa, lk) \
-  (BBO ((op), (bo), (aa), (lk)) | ((((unsigned long)(cb)) & 0x3) << 16))
+  (BBO ((op), (bo), (aa), (lk)) | ((((uint64_t)(cb)) & 0x3) << 16))
 #define BBOCB_MASK BBOCB (0x3f, 0x1f, 0x3, 1, 1)
 
 /* A BBOCB_MASK with the y bit of the BO field removed.  */
@@ -2774,17 +2826,17 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
 #define BBOATBI_MASK (BBOAT2CB_MASK | BI_MASK)
 
 /* A VLE C form instruction.  */
-#define C_LK(x, lk) (((((unsigned long)(x)) & 0x7fff) << 1) | ((lk) & 1))
+#define C_LK(x, lk) (((((uint64_t)(x)) & 0x7fff) << 1) | ((lk) & 1))
 #define C_LK_MASK C_LK(0x7fff, 1)
-#define C(x) ((((unsigned long)(x)) & 0xffff))
+#define C(x) ((((uint64_t)(x)) & 0xffff))
 #define C_MASK C(0xffff)
 
 /* An Context form instruction.  */
-#define CTX(op, xop)   (OP (op) | (((unsigned long)(xop)) & 0x7))
+#define CTX(op, xop)   (OP (op) | (((uint64_t)(xop)) & 0x7))
 #define CTX_MASK CTX(0x3f, 0x7)
 
 /* An User Context form instruction.  */
-#define UCTX(op, xop)  (OP (op) | (((unsigned long)(xop)) & 0x1f))
+#define UCTX(op, xop)  (OP (op) | (((uint64_t)(xop)) & 0x1f))
 #define UCTX_MASK UCTX(0x3f, 0x1f)
 
 /* The main opcode mask with the RA field clear.  */
@@ -2799,29 +2851,29 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
 #define DS_MASK DSO (0x3f, 3)
 
 /* An DX form instruction.  */
-#define DX(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x1f) << 1))
+#define DX(op, xop) (OP (op) | ((((uint64_t)(xop)) & 0x1f) << 1))
 #define DX_MASK DX (0x3f, 0x1f)
 /* An DX form instruction with the D bits specified.  */
 #define NODX_MASK (DX_MASK | 0x1fffc1)
 
 /* An EVSEL form instruction.  */
-#define EVSEL(op, xop) (OP (op) | (((unsigned long)(xop)) & 0xff) << 3)
+#define EVSEL(op, xop) (OP (op) | (((uint64_t)(xop)) & 0xff) << 3)
 #define EVSEL_MASK EVSEL(0x3f, 0xff)
 
 /* An IA16 form instruction.  */
-#define IA16(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x1f) << 11)
+#define IA16(op, xop) (OP (op) | (((uint64_t)(xop)) & 0x1f) << 11)
 #define IA16_MASK IA16(0x3f, 0x1f)
 
 /* An I16A form instruction.  */
-#define I16A(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x1f) << 11)
+#define I16A(op, xop) (OP (op) | (((uint64_t)(xop)) & 0x1f) << 11)
 #define I16A_MASK I16A(0x3f, 0x1f)
 
 /* An I16L form instruction.  */
-#define I16L(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x1f) << 11)
+#define I16L(op, xop) (OP (op) | (((uint64_t)(xop)) & 0x1f) << 11)
 #define I16L_MASK I16L(0x3f, 0x1f)
 
 /* An IM7 form instruction.  */
-#define IM7(op) ((((unsigned long)(op)) & 0x1f) << 11)
+#define IM7(op) ((((uint64_t)(op)) & 0x1f) << 11)
 #define IM7_MASK IM7(0x1f)
 
 /* An M form instruction.  */
@@ -2829,13 +2881,13 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
 #define M_MASK M (0x3f, 1)
 
 /* An LI20 form instruction.  */
-#define LI20(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x1) << 15)
+#define LI20(op, xop) (OP (op) | (((uint64_t)(xop)) & 0x1) << 15)
 #define LI20_MASK LI20(0x3f, 0x1)
 
 /* An M form instruction with the ME field specified.  */
 #define MME(op, me, rc)                                \
   (M ((op), (rc))                              \
-   | ((((unsigned long)(me)) & 0x1f) << 1))
+   | ((((uint64_t)(me)) & 0x1f) << 1))
 
 /* An M_MASK with the MB and ME fields fixed.  */
 #define MMBME_MASK (M_MASK | MB_MASK | ME_MASK)
@@ -2846,7 +2898,7 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
 /* An MD form instruction.  */
 #define MD(op, xop, rc)                                \
   (OP (op)                                     \
-   | ((((unsigned long)(xop)) & 0x7) << 2)     \
+   | ((((uint64_t)(xop)) & 0x7) << 2)  \
    | ((rc) & 1))
 #define MD_MASK MD (0x3f, 0x7, 1)
 
@@ -2859,7 +2911,7 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
 /* An MDS form instruction.  */
 #define MDS(op, xop, rc)                       \
   (OP (op)                                     \
-   | ((((unsigned long)(xop)) & 0xf) << 1)     \
+   | ((((uint64_t)(xop)) & 0xf) << 1)  \
    | ((rc) & 1))
 #define MDS_MASK MDS (0x3f, 0xf, 1)
 
@@ -2869,55 +2921,55 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
 /* An SC form instruction.  */
 #define SC(op, sa, lk)                         \
   (OP (op)                                     \
-   | ((((unsigned long)(sa)) & 1) << 1)                \
+   | ((((uint64_t)(sa)) & 1) << 1)             \
    | ((lk) & 1))
 #define SC_MASK                                        \
   (OP_MASK                                     \
-   | (((unsigned long) 0x3ff) << 16)           \
-   | (((unsigned long) 1) << 1)                        \
+   | (((uint64_t) 0x3ff) << 16)                \
+   | (((uint64_t) 1) << 1)                     \
    | 1)
 
 /* An SCI8 form instruction.  */
-#define SCI8(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x1f) << 11))
+#define SCI8(op, xop) (OP (op) | ((((uint64_t)(xop)) & 0x1f) << 11))
 #define SCI8_MASK SCI8(0x3f, 0x1f)
 
 /* An SCI8 form instruction.  */
 #define SCI8BF(op, fop, xop)                   \
   (OP (op)                                     \
-   | ((((unsigned long)(xop)) & 0x1f) << 11)   \
+   | ((((uint64_t)(xop)) & 0x1f) << 11)        \
    | (((fop) & 7) << 23))
 #define SCI8BF_MASK SCI8BF(0x3f, 7, 0x1f)
 
 /* An SD4 form instruction.  This is a 16-bit instruction.  */
-#define SD4(op) ((((unsigned long)(op)) & 0xf) << 12)
+#define SD4(op) ((((uint64_t)(op)) & 0xf) << 12)
 #define SD4_MASK SD4(0xf)
 
 /* An SE_IM5 form instruction.  This is a 16-bit instruction.  */
 #define SE_IM5(op, xop)                                \
-  (((((unsigned long)(op)) & 0x3f) << 10)      \
+  (((((uint64_t)(op)) & 0x3f) << 10)   \
    | (((xop) & 0x1) << 9))
 #define SE_IM5_MASK SE_IM5(0x3f, 1)
 
 /* An SE_R form instruction.  This is a 16-bit instruction.  */
 #define SE_R(op, xop)                          \
-  (((((unsigned long)(op)) & 0x3f) << 10)      \
+  (((((uint64_t)(op)) & 0x3f) << 10)   \
    | (((xop) & 0x3f) << 4))
 #define SE_R_MASK SE_R(0x3f, 0x3f)
 
 /* An SE_RR form instruction.  This is a 16-bit instruction.  */
 #define SE_RR(op, xop)                         \
-  (((((unsigned long)(op)) & 0x3f) << 10)      \
+  (((((uint64_t)(op)) & 0x3f) << 10)   \
    | (((xop) & 0x3) << 8))
 #define SE_RR_MASK SE_RR(0x3f, 3)
 
 /* A VX form instruction.  */
-#define VX(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x7ff))
+#define VX(op, xop) (OP (op) | (((uint64_t)(xop)) & 0x7ff))
 
 /* The mask for an VX form instruction.  */
 #define VX_MASK        VX(0x3f, 0x7ff)
 
 /* A VX LSP form instruction.  */
-#define VX_LSP(op, xop) (OP (op) | (((unsigned long)(xop)) & 0xffff))
+#define VX_LSP(op, xop) (OP (op) | (((uint64_t)(xop)) & 0xffff))
 
 /* The mask for an VX LSP form instruction.  */
 #define VX_LSP_MASK    VX_LSP(0x3f, 0xffff)
@@ -2926,62 +2978,62 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
 /* Additional format of VX SPE2 form instruction.   */
 #define VX_RA_CONST(op, xop, bits11_15)                        \
   (OP (op)                                             \
-   | (((unsigned long)(bits11_15) & 0x1f) << 16)       \
-   | (((unsigned long)(xop)) & 0x7ff))
+   | (((uint64_t)(bits11_15) & 0x1f) << 16)    \
+   | (((uint64_t)(xop)) & 0x7ff))
 #define VX_RA_CONST_MASK VX_RA_CONST(0x3f, 0x7ff, 0x1f)
 
 #define VX_RB_CONST(op, xop, bits16_20)                        \
   (OP (op)                                             \
-   | (((unsigned long)(bits16_20) & 0x1f) << 11)       \
-   | (((unsigned long)(xop)) & 0x7ff))
+   | (((uint64_t)(bits16_20) & 0x1f) << 11)    \
+   | (((uint64_t)(xop)) & 0x7ff))
 #define VX_RB_CONST_MASK VX_RB_CONST(0x3f, 0x7ff, 0x1f)
 
 #define VX_OFF_SPE2_MASK VX(0x3f, 0x7f8)
 
 #define VX_SPE_CRFD(op, xop, bits9_10)                 \
   (OP (op)                                             \
-   | (((unsigned long)(bits9_10) & 0x3) << 21)         \
-   | (((unsigned long)(xop)) & 0x7ff))
+   | (((uint64_t)(bits9_10) & 0x3) << 21)              \
+   | (((uint64_t)(xop)) & 0x7ff))
 #define VX_SPE_CRFD_MASK VX_SPE_CRFD(0x3f, 0x7ff, 0x3)
 
 #define VX_SPE2_CLR(op, xop, bit16)                    \
   (OP (op)                                             \
-   | (((unsigned long)(bit16) & 0x1) << 15)            \
-   | (((unsigned long)(xop)) & 0x7ff))
+   | (((uint64_t)(bit16) & 0x1) << 15)         \
+   | (((uint64_t)(xop)) & 0x7ff))
 #define VX_SPE2_CLR_MASK VX_SPE2_CLR(0x3f, 0x7ff, 0x1)
 
 #define VX_SPE2_SPLATB(op, xop, bits19_20)             \
   (OP (op)                                             \
-   | (((unsigned long)(bits19_20) & 0x3) << 11)                \
-   | (((unsigned long)(xop)) & 0x7ff))
+   | (((uint64_t)(bits19_20) & 0x3) << 11)             \
+   | (((uint64_t)(xop)) & 0x7ff))
 #define VX_SPE2_SPLATB_MASK VX_SPE2_SPLATB(0x3f, 0x7ff, 0x3)
 
 #define VX_SPE2_OCTET(op, xop, bits16_17)              \
   (OP (op)                                             \
-   | (((unsigned long)(bits16_17) & 0x3) << 14)                \
-   | (((unsigned long)(xop)) & 0x7ff))
+   | (((uint64_t)(bits16_17) & 0x3) << 14)             \
+   | (((uint64_t)(xop)) & 0x7ff))
 #define VX_SPE2_OCTET_MASK VX_SPE2_OCTET(0x3f, 0x7ff, 0x7)
 
 #define VX_SPE2_DDHH(op, xop, bit16)                   \
   (OP (op)                                             \
-   | (((unsigned long)(bit16) & 0x1) << 15)            \
-   | (((unsigned long)(xop)) & 0x7ff))
+   | (((uint64_t)(bit16) & 0x1) << 15)         \
+   | (((uint64_t)(xop)) & 0x7ff))
 #define VX_SPE2_DDHH_MASK VX_SPE2_DDHH(0x3f, 0x7ff, 0x1)
 
 #define VX_SPE2_HH(op, xop, bit16, bits19_20)          \
   (OP (op)                                             \
-   | (((unsigned long)(bit16) & 0x1) << 15)            \
-   | (((unsigned long)(bits19_20) & 0x3) << 11)        \
-   | (((unsigned long)(xop)) & 0x7ff))
+   | (((uint64_t)(bit16) & 0x1) << 15)         \
+   | (((uint64_t)(bits19_20) & 0x3) << 11)     \
+   | (((uint64_t)(xop)) & 0x7ff))
 #define VX_SPE2_HH_MASK VX_SPE2_HH(0x3f, 0x7ff, 0x1, 0x3)
 
 #define VX_SPE2_EVMAR(op, xop)                         \
   (OP (op)                                             \
-   | ((unsigned long)(0x1) << 11)                      \
-   | (((unsigned long)(xop)) & 0x7ff))
+   | ((uint64_t)(0x1) << 11)                   \
+   | (((uint64_t)(xop)) & 0x7ff))
 #define VX_SPE2_EVMAR_MASK                             \
   (VX_SPE2_EVMAR(0x3f, 0x7ff)                          \
-   | ((unsigned long)(0x1) << 11))
+   | ((uint64_t)(0x1) << 11))
 
 /* A VX_MASK with the VA field fixed.  */
 #define VXVA_MASK (VX_MASK | (0x1f << 16))
@@ -3011,7 +3063,7 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
 #define VXVAPS_MASK ((VX_MASK | (0x1f << 16)) & ~(0x1 << 9))
 
 /* A VA form instruction.  */
-#define VXA(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x03f))
+#define VXA(op, xop) (OP (op) | (((uint64_t)(xop)) & 0x03f))
 
 /* The mask for an VA form instruction.  */
 #define VXA_MASK VXA(0x3f, 0x3f)
@@ -3022,8 +3074,8 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
 /* A VXR form instruction.  */
 #define VXR(op, xop, rc)                       \
   (OP (op)                                     \
-   | (((rc) & 1) << 10)                                \
-   | (((unsigned long)(xop)) & 0x3ff))
+   | (((uint64_t)(rc) & 1) << 10)              \
+   | (((uint64_t)(xop)) & 0x3ff))
 
 /* The mask for a VXR form instruction.  */
 #define VXR_MASK VXR(0x3f, 0x3ff, 1)
@@ -3031,41 +3083,41 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
 /* A VX form instruction with a VA tertiary opcode.  */
 #define VXVA(op, xop, vaop) (VX(op,xop) | (((vaop) & 0x1f) << 16))
 
-#define VXASH(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x1f) << 1))
+#define VXASH(op, xop) (OP (op) | ((((uint64_t)(xop)) & 0x1f) << 1))
 #define VXASH_MASK VXASH (0x3f, 0x1f)
 
 /* An X form instruction.  */
-#define X(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x3ff) << 1))
+#define X(op, xop) (OP (op) | ((((uint64_t)(xop)) & 0x3ff) << 1))
 
 /* A X form instruction for Quad-Precision FP Instructions.  */
 #define XVA(op, xop, vaop) (X(op,xop) | (((vaop) & 0x1f) << 16))
 
 /* An EX form instruction.  */
-#define EX(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x7ff))
+#define EX(op, xop) (OP (op) | (((uint64_t)(xop)) & 0x7ff))
 
 /* The mask for an EX form instruction.  */
 #define EX_MASK EX (0x3f, 0x7ff)
 
 /* An XX2 form instruction.  */
-#define XX2(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x1ff) << 2))
+#define XX2(op, xop) (OP (op) | ((((uint64_t)(xop)) & 0x1ff) << 2))
 
 /* A XX2 form instruction with the VA bits specified.  */
 #define XX2VA(op, xop, vaop) (XX2(op,xop) | (((vaop) & 0x1f) << 16))
 
 /* An XX3 form instruction.  */
-#define XX3(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0xff) << 3))
+#define XX3(op, xop) (OP (op) | ((((uint64_t)(xop)) & 0xff) << 3))
 
 /* An XX3 form instruction with the RC bit specified.  */
 #define XX3RC(op, xop, rc)                     \
   (OP (op)                                     \
-   | (((rc) & 1) << 10)                                \
-   | ((((unsigned long)(xop)) & 0x7f) << 3))
+   | (((uint64_t)(rc) & 1) << 10)              \
+   | ((((uint64_t)(xop)) & 0x7f) << 3))
 
 /* An XX4 form instruction.  */
-#define XX4(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x3) << 4))
+#define XX4(op, xop) (OP (op) | ((((uint64_t)(xop)) & 0x3) << 4))
 
 /* A Z form instruction.  */
-#define Z(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x1ff) << 1))
+#define Z(op, xop) (OP (op) | ((((uint64_t)(xop)) & 0x1ff) << 1))
 
 /* An X form instruction with the RC bit specified.  */
 #define XRC(op, xop, rc) (X ((op), (xop)) | ((rc) & 1))
@@ -3148,7 +3200,7 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
 #define XVA_MASK XRA_MASK
 
 /* An XRA_MASK with the A_L/W field clear.  */
-#define XWRA_MASK (XRA_MASK & ~((unsigned long) 1 << 16))
+#define XWRA_MASK (XRA_MASK & ~((uint64_t) 1 << 16))
 #define XRLA_MASK XWRA_MASK
 
 /* An X_MASK with the RB field fixed.  */
@@ -3158,7 +3210,7 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
 #define XRT_MASK (X_MASK | RT_MASK)
 
 /* An XRT_MASK mask with the L bits clear.  */
-#define XLRT_MASK (XRT_MASK & ~((unsigned long) 0x3 << 21))
+#define XLRT_MASK (XRT_MASK & ~((uint64_t) 0x3 << 21))
 
 /* An X_MASK with the RA and RB fields fixed.  */
 #define XRARB_MASK (X_MASK | RA_MASK | RB_MASK)
@@ -3167,10 +3219,10 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
 #define XBFRARB_MASK (XBF_MASK | RA_MASK | RB_MASK)
 
 /* An XRARB_MASK, but with the L bit clear.  */
-#define XRLARB_MASK (XRARB_MASK & ~((unsigned long) 1 << 16))
+#define XRLARB_MASK (XRARB_MASK & ~((uint64_t) 1 << 16))
 
 /* An XRARB_MASK, but with the L bits in a darn instruction clear.  */
-#define XLRAND_MASK (XRARB_MASK & ~((unsigned long) 3 << 16))
+#define XLRAND_MASK (XRARB_MASK & ~((uint64_t) 3 << 16))
 
 /* An X_MASK with the RT and RA fields fixed.  */
 #define XRTRA_MASK (X_MASK | RT_MASK | RA_MASK)
@@ -3179,69 +3231,69 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
 #define XRTRB_MASK (X_MASK | RT_MASK | RB_MASK)
 
 /* An XRTRA_MASK, but with L bit clear.  */
-#define XRTLRA_MASK (XRTRA_MASK & ~((unsigned long) 1 << 21))
+#define XRTLRA_MASK (XRTRA_MASK & ~((uint64_t) 1 << 21))
 
 /* An X_MASK with the RT, RA and RB fields fixed.  */
 #define XRTRARB_MASK (X_MASK | RT_MASK | RA_MASK | RB_MASK)
 
 /* An XRTRARB_MASK, but with L bit clear.  */
-#define XRTLRARB_MASK (XRTRARB_MASK & ~((unsigned long) 1 << 21))
+#define XRTLRARB_MASK (XRTRARB_MASK & ~((uint64_t) 1 << 21))
 
 /* An XRTRARB_MASK, but with A bit clear.  */
-#define XRTARARB_MASK (XRTRARB_MASK & ~((unsigned long) 1 << 25))
+#define XRTARARB_MASK (XRTRARB_MASK & ~((uint64_t) 1 << 25))
 
 /* An XRTRARB_MASK, but with BF bits clear.  */
-#define XRTBFRARB_MASK (XRTRARB_MASK & ~((unsigned long) 7 << 23))
+#define XRTBFRARB_MASK (XRTRARB_MASK & ~((uint64_t) 7 << 23))
 
 /* An X form instruction with the L bit specified.  */
 #define XOPL(op, xop, l)                       \
   (X ((op), (xop))                             \
-   | ((((unsigned long)(l)) & 1) << 21))
+   | ((((uint64_t)(l)) & 1) << 21))
 
 /* An X form instruction with the L bits specified.  */
 #define XOPL2(op, xop, l)                      \
   (X ((op), (xop))                             \
-   | ((((unsigned long)(l)) & 3) << 21))
+   | ((((uint64_t)(l)) & 3) << 21))
 
 /* An X form instruction with the L bit and RC bit specified.  */
 #define XRCL(op, xop, l, rc)                   \
   (XRC ((op), (xop), (rc))                     \
-   | ((((unsigned long)(l)) & 1) << 21))
+   | ((((uint64_t)(l)) & 1) << 21))
 
 /* An X form instruction with RT fields specified */
 #define XRT(op, xop, rt)                       \
   (X ((op), (xop))                             \
-   | ((((unsigned long)(rt)) & 0x1f) << 21))
+   | ((((uint64_t)(rt)) & 0x1f) << 21))
 
 /* An X form instruction with RT and RA fields specified */
 #define XRTRA(op, xop, rt, ra)                 \
   (X ((op), (xop))                             \
-   | ((((unsigned long)(rt)) & 0x1f) << 21)    \
-   | ((((unsigned long)(ra)) & 0x1f) << 16))
+   | ((((uint64_t)(rt)) & 0x1f) << 21) \
+   | ((((uint64_t)(ra)) & 0x1f) << 16))
 
 /* The mask for an X form comparison instruction.  */
-#define XCMP_MASK (X_MASK | (((unsigned long)1) << 22))
+#define XCMP_MASK (X_MASK | (((uint64_t)1) << 22))
 
 /* The mask for an X form comparison instruction with the L field
    fixed.  */
-#define XCMPL_MASK (XCMP_MASK | (((unsigned long)1) << 21))
+#define XCMPL_MASK (XCMP_MASK | (((uint64_t)1) << 21))
 
 /* An X form trap instruction with the TO field specified.  */
 #define XTO(op, xop, to)                       \
   (X ((op), (xop))                             \
-   | ((((unsigned long)(to)) & 0x1f) << 21))
+   | ((((uint64_t)(to)) & 0x1f) << 21))
 #define XTO_MASK (X_MASK | TO_MASK)
 
 /* An X form tlb instruction with the SH field specified.  */
 #define XTLB(op, xop, sh)                      \
   (X ((op), (xop))                             \
-   | ((((unsigned long)(sh)) & 0x1f) << 11))
+   | ((((uint64_t)(sh)) & 0x1f) << 11))
 #define XTLB_MASK (X_MASK | SH_MASK)
 
 /* An X form sync instruction.  */
 #define XSYNC(op, xop, l)                      \
   (X ((op), (xop))                             \
-   | ((((unsigned long)(l)) & 3) << 21))
+   | ((((uint64_t)(l)) & 3) << 21))
 
 /* An X form sync instruction with everything filled in except the LS
    field.  */
@@ -3252,25 +3304,25 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
 #define XSYNCLE_MASK (0xff90ffff)
 
 /* An X_MASK, but with the EH bit clear.  */
-#define XEH_MASK (X_MASK & ~((unsigned long )1))
+#define XEH_MASK (X_MASK & ~((uint64_t )1))
 
 /* An X form AltiVec dss instruction.  */
-#define XDSS(op, xop, a) (X ((op), (xop)) | ((((unsigned long)(a)) & 1) << 25))
+#define XDSS(op, xop, a) (X ((op), (xop)) | ((((uint64_t)(a)) & 1) << 25))
 #define XDSS_MASK XDSS(0x3f, 0x3ff, 1)
 
 /* An XFL form instruction.  */
 #define XFL(op, xop, rc)                       \
   (OP (op)                                     \
-   | ((((unsigned long)(xop)) & 0x3ff) << 1)   \
-   | (((unsigned long)(rc)) & 1))
+   | ((((uint64_t)(xop)) & 0x3ff) << 1)        \
+   | (((uint64_t)(rc)) & 1))
 #define XFL_MASK XFL (0x3f, 0x3ff, 1)
 
 /* An X form isel instruction.  */
-#define XISEL(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x1f) << 1))
+#define XISEL(op, xop) (OP (op) | ((((uint64_t)(xop)) & 0x1f) << 1))
 #define XISEL_MASK     XISEL(0x3f, 0x1f)
 
 /* An XL form instruction with the LK field set to 0.  */
-#define XL(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x3ff) << 1))
+#define XL(op, xop) (OP (op) | ((((uint64_t)(xop)) & 0x3ff) << 1))
 
 /* An XL form instruction which uses the LK field.  */
 #define XLLK(op, xop, lk) (XL ((op), (xop)) | ((lk) & 1))
@@ -3283,20 +3335,20 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
 
 /* An XL form instruction which explicitly sets the BO field.  */
 #define XLO(op, bo, xop, lk) \
-  (XLLK ((op), (xop), (lk)) | ((((unsigned long)(bo)) & 0x1f) << 21))
+  (XLLK ((op), (xop), (lk)) | ((((uint64_t)(bo)) & 0x1f) << 21))
 #define XLO_MASK (XL_MASK | BO_MASK)
 
 /* An XL form instruction which explicitly sets the y bit of the BO
    field.  */
 #define XLYLK(op, xop, y, lk)                  \
   (XLLK ((op), (xop), (lk))                    \
-   | ((((unsigned long)(y)) & 1) << 21))
+   | ((((uint64_t)(y)) & 1) << 21))
 #define XLYLK_MASK (XL_MASK | Y_MASK)
 
 /* An XL form instruction which sets the BO field and the condition
    bits of the BI field.  */
 #define XLOCB(op, bo, cb, xop, lk) \
-  (XLO ((op), (bo), (xop), (lk)) | ((((unsigned long)(cb)) & 3) << 16))
+  (XLO ((op), (bo), (xop), (lk)) | ((((uint64_t)(cb)) & 3) << 16))
 #define XLOCB_MASK XLOCB (0x3f, 0x1f, 0x3, 0x3ff, 1)
 
 /* An XL_MASK or XLYLK_MASK or XLOCB_MASK with the BB field fixed.  */
@@ -3316,13 +3368,13 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
 /* An X form mbar instruction with MO field.  */
 #define XMBAR(op, xop, mo)                     \
   (X ((op), (xop))                             \
-   | ((((unsigned long)(mo)) & 1) << 21))
+   | ((((uint64_t)(mo)) & 1) << 21))
 
 /* An XO form instruction.  */
 #define XO(op, xop, oe, rc)                    \
   (OP (op)                                     \
-   | ((((unsigned long)(xop)) & 0x1ff) << 1)   \
-   | ((((unsigned long)(oe)) & 1) << 10)       \
+   | ((((uint64_t)(xop)) & 0x1ff) << 1)        \
+   | ((((uint64_t)(oe)) & 1) << 10)    \
    | (((unsigned long)(rc)) & 1))
 #define XO_MASK XO (0x3f, 0x1ff, 1, 1)
 
@@ -3332,16 +3384,16 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
 /* An XOPS form instruction for paired singles.  */
 #define XOPS(op, xop, rc)                      \
   (OP (op)                                     \
-   | ((((unsigned long)(xop)) & 0x3ff) << 1)   \
-   | (((unsigned long)(rc)) & 1))
+   | ((((uint64_t)(xop)) & 0x3ff) << 1)        \
+   | (((uint64_t)(rc)) & 1))
 #define XOPS_MASK XOPS (0x3f, 0x3ff, 1)
 
 
 /* An XS form instruction.  */
 #define XS(op, xop, rc)                                \
   (OP (op)                                     \
-   | ((((unsigned long)(xop)) & 0x1ff) << 2)   \
-   | (((unsigned long)(rc)) & 1))
+   | ((((uint64_t)(xop)) & 0x1ff) << 2)        \
+   | (((uint64_t)(rc)) & 1))
 #define XS_MASK XS (0x3f, 0x1ff, 1)
 
 /* A mask for the FXM version of an XFX form instruction.  */
@@ -3350,20 +3402,24 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
 /* An XFX form instruction with the FXM field filled in.  */
 #define XFXM(op, xop, fxm, p4)                 \
   (X ((op), (xop))                             \
-   | ((((unsigned long)(fxm)) & 0xff) << 12)   \
-   | ((unsigned long)(p4) << 20))
+   | ((((uint64_t)(fxm)) & 0xff) << 12)        \
+   | ((uint64_t)(p4) << 20))
 
 /* An XFX form instruction with the SPR field filled in.  */
 #define XSPR(op, xop, spr)                     \
   (X ((op), (xop))                             \
-   | ((((unsigned long)(spr)) & 0x1f) << 16)   \
-   | ((((unsigned long)(spr)) & 0x3e0) << 6))
+   | ((((uint64_t)(spr)) & 0x1f) << 16)        \
+   | ((((uint64_t)(spr)) & 0x3e0) << 6))
 #define XSPR_MASK (X_MASK | SPR_MASK)
 
 /* An XFX form instruction with the SPR field filled in except for the
    SPRBAT field.  */
 #define XSPRBAT_MASK (XSPR_MASK &~ SPRBAT_MASK)
 
+/* An XFX form instruction with the SPR field filled in except for the
+   SPRGQR field.  */
+#define XSPRGQR_MASK (XSPR_MASK &~ SPRGQR_MASK)
+
 /* An XFX form instruction with the SPR field filled in except for the
    SPRG field.  */
 #define XSPRG_MASK (XSPR_MASK & ~(0x1f << 16))
@@ -3372,13 +3428,13 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
 #define XE_MASK (0xffff7fff)
 
 /* An X form user context instruction.  */
-#define XUC(op, xop)  (OP (op) | (((unsigned long)(xop)) & 0x1f))
+#define XUC(op, xop)  (OP (op) | (((uint64_t)(xop)) & 0x1f))
 #define XUC_MASK      XUC(0x3f, 0x1f)
 
 /* An XW form instruction.  */
 #define XW(op, xop, rc)                                \
   (OP (op)                                     \
-   | ((((unsigned long)(xop)) & 0x3f) << 1)    \
+   | ((((uint64_t)(xop)) & 0x3f) << 1) \
    | ((rc) & 1))
 /* The mask for a G form instruction. rc not supported at present.  */
 #define XW_MASK XW (0x3f, 0x3f, 0)
@@ -3386,7 +3442,7 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
 /* An APU form instruction.  */
 #define APU(op, xop, rc)                       \
   (OP (op)                                     \
-   | (((unsigned long)(xop)) & 0x3ff) << 1     \
+   | (((uint64_t)(xop)) & 0x3ff) << 1  \
    | ((rc) & 1))
 
 /* The mask for an APU form instruction.  */
@@ -3479,6 +3535,8 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
 #define PPC464 PPC440
 #define PPC476 PPC_OPCODE_476
 #define PPC750 PPC_OPCODE_750
+#define GEKKO  PPC_OPCODE_750
+#define BROADWAY PPC_OPCODE_750
 #define PPC7450 PPC_OPCODE_7450
 #define PPC860 PPC_OPCODE_860
 #define PPCPS  PPC_OPCODE_PPCPS
@@ -3511,7 +3569,7 @@ const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
 #define PPCPMR PPC_OPCODE_PMR
 #define PPCTMR  PPC_OPCODE_TMR
 #define PPCCHLK PPC_OPCODE_CACHELCK
-#define PPCRFMCI       PPC_OPCODE_RFMCI
+#define PPCRFMCI PPC_OPCODE_RFMCI
 #define E500MC  PPC_OPCODE_E500MC
 #define PPCA2  PPC_OPCODE_A2
 #define TITAN   PPC_OPCODE_TITAN
@@ -3804,10 +3862,10 @@ const struct powerpc_opcode powerpc_opcodes[] = {
 {"evand",      VX (4, 529),    VX_MASK,     PPCSPE,    0,              {RS, RA, RB}},
 {"evandc",     VX (4, 530),    VX_MASK,     PPCSPE,    0,              {RS, RA, RB}},
 {"evxor",      VX (4, 534),    VX_MASK,     PPCSPE,    0,              {RS, RA, RB}},
-{"evmr",       VX (4, 535),    VX_MASK,     PPCSPE,    0,              {RS, RA, BBA}},
+{"evmr",       VX (4, 535),    VX_MASK,     PPCSPE,    0,              {RS, RAB}},
 {"evor",       VX (4, 535),    VX_MASK,     PPCSPE,    0,              {RS, RA, RB}},
+{"evnot",      VX (4, 536),    VX_MASK,     PPCSPE,    0,              {RS, RAB}},
 {"evnor",      VX (4, 536),    VX_MASK,     PPCSPE,    0,              {RS, RA, RB}},
-{"evnot",      VX (4, 536),    VX_MASK,     PPCSPE,    0,              {RS, RA, BBA}},
 {"get",                APU(4, 268,0),  APU_RA_MASK, PPC405,    0,              {RT, FSL}},
 {"eveqv",      VX (4, 537),    VX_MASK,     PPCSPE,    0,              {RS, RA, RB}},
 {"evorc",      VX (4, 539),    VX_MASK,     PPCSPE,    0,              {RS, RA, RB}},
@@ -4151,7 +4209,7 @@ const struct powerpc_opcode powerpc_opcodes[] = {
 {"bcdus.",     VX (4,1153),    VX_MASK,     PPCVEC3,   0,              {VD, VA, VB}},
 {"vavguw",     VX (4,1154),    VX_MASK,     PPCVEC,    0,              {VD, VA, VB}},
 {"vabsduw",    VX (4,1155),    VX_MASK,     PPCVEC2,   0,              {VD, VA, VB}},
-{"vmr",                VX (4,1156),    VX_MASK,     PPCVEC,    0,              {VD, VA, VBA}},
+{"vmr",                VX (4,1156),    VX_MASK,     PPCVEC,    0,              {VD, VAB}},
 {"vor",                VX (4,1156),    VX_MASK,     PPCVEC,    0,              {VD, VA, VB}},
 {"vcmpnew.",   VXR(4, 135,1),  VXR_MASK,    PPCVEC3,   0,              {VD, VA, VB}},
 {"vpmsumw",    VX (4,1160),    VX_MASK,     PPCVEC2,   0,              {VD, VA, VB}},
@@ -4195,7 +4253,7 @@ const struct powerpc_opcode powerpc_opcodes[] = {
 {"vavgsb",     VX (4,1282),    VX_MASK,     PPCVEC,    0,              {VD, VA, VB}},
 {"evmhessfaaw",        VX (4,1283),    VX_MASK,     PPCSPE,    0,              {RS, RA, RB}},
 {"evmhousiaaw",        VX (4,1284),    VX_MASK,     PPCSPE,    0,              {RS, RA, RB}},
-{"vnot",       VX (4,1284),    VX_MASK,     PPCVEC,    0,              {VD, VA, VBA}},
+{"vnot",       VX (4,1284),    VX_MASK,     PPCVEC,    0,              {VD, VAB}},
 {"vnor",       VX (4,1284),    VX_MASK,     PPCVEC,    0,              {VD, VA, VB}},
 {"evmhossiaaw",        VX (4,1285),    VX_MASK,     PPCSPE,    0,              {RS, RA, RB}},
 {"udi4fcm.",   APU(4, 643,0),  APU_MASK, PPC405|PPC440, 0,             {URT, URA, URB}},
@@ -4967,7 +5025,7 @@ const struct powerpc_opcode powerpc_opcodes[] = {
 
 {"rfid",       XL(19,18),      0xffffffff,  PPC64,     PPCVLE, {0}},
 
-{"crnot",      XL(19,33),      XL_MASK,     PPCCOM,    PPCVLE,         {BT, BA, BBA}},
+{"crnot",      XL(19,33),      XL_MASK,     PPCCOM,    PPCVLE,         {BT, BAB}},
 {"crnor",      XL(19,33),      XL_MASK,     COM,       PPCVLE,         {BT, BA, BB}},
 {"rfmci",      X(19,38),    0xffffffff, PPCRFMCI|PPCA2|PPC476, PPCVLE, {0}},
 
@@ -4987,7 +5045,7 @@ const struct powerpc_opcode powerpc_opcodes[] = {
 {"isync",      XL(19,150),     0xffffffff,  PPCCOM,    PPCVLE,         {0}},
 {"ics",                XL(19,150),     0xffffffff,  PWRCOM,    PPCVLE,         {0}},
 
-{"crclr",      XL(19,193),     XL_MASK,     PPCCOM,    PPCVLE,         {BT, BAT, BBA}},
+{"crclr",      XL(19,193),     XL_MASK,     PPCCOM,    PPCVLE,         {BTAB}},
 {"crxor",      XL(19,193),     XL_MASK,     COM,       PPCVLE,         {BT, BA, BB}},
 
 {"dnh",                X(19,198),      X_MASK,      E500MC,    PPCVLE,         {DUI, DUIS}},
@@ -4998,7 +5056,7 @@ const struct powerpc_opcode powerpc_opcodes[] = {
 
 {"hrfid",      XL(19,274),    0xffffffff, POWER5|CELL, PPC476|PPCVLE,  {0}},
 
-{"crset",      XL(19,289),     XL_MASK,     PPCCOM,    PPCVLE,         {BT, BAT, BBA}},
+{"crset",      XL(19,289),     XL_MASK,     PPCCOM,    PPCVLE,         {BTAB}},
 {"creqv",      XL(19,289),     XL_MASK,     COM,       PPCVLE,         {BT, BA, BB}},
 
 {"urfid",      XL(19,306),     0xffffffff,  POWER9,    PPCVLE,         {0}},
@@ -5010,7 +5068,7 @@ const struct powerpc_opcode powerpc_opcodes[] = {
 
 {"nap",                XL(19,434),     0xffffffff,  POWER6,    POWER9|PPCVLE,  {0}},
 
-{"crmove",     XL(19,449),     XL_MASK,     PPCCOM,    PPCVLE,         {BT, BA, BBA}},
+{"crmove",     XL(19,449),     XL_MASK,     PPCCOM,    PPCVLE,         {BT, BAB}},
 {"cror",       XL(19,449),     XL_MASK,     COM,       PPCVLE,         {BT, BA, BB}},
 
 {"sleep",      XL(19,466),     0xffffffff,  POWER6,    POWER9|PPCVLE,  {0}},
@@ -5475,9 +5533,9 @@ const struct powerpc_opcode powerpc_opcodes[] = {
 
 {"popcntb",    X(31,122),      XRB_MASK,    POWER5,    0,              {RA, RS}},
 
-{"not",                XRC(31,124,0),  X_MASK,      COM,       0,              {RA, RS, RBS}},
+{"not",                XRC(31,124,0),  X_MASK,      COM,       0,              {RA, RSB}},
 {"nor",                XRC(31,124,0),  X_MASK,      COM,       0,              {RA, RS, RB}},
-{"not.",       XRC(31,124,1),  X_MASK,      COM,       0,              {RA, RS, RBS}},
+{"not.",       XRC(31,124,1),  X_MASK,      COM,       0,              {RA, RSB}},
 {"nor.",       XRC(31,124,1),  X_MASK,      COM,       0,              {RA, RS, RB}},
 
 {"dcbfep",     XRT(31,127,0),  XRT_MASK, E500MC|PPCA2, 0,              {RA0, RB}},
@@ -5899,6 +5957,18 @@ const struct powerpc_opcode powerpc_opcodes[] = {
 {"mfdpdr",     XSPR(31,339,630), XSPR_MASK, PPC860,    0,              {RT}},
 {"mfdpir",     XSPR(31,339,631), XSPR_MASK, PPC860,    0,              {RT}},
 {"mfimmr",     XSPR(31,339,638), XSPR_MASK, PPC860,    0,              {RT}},
+{"mfupmc1",    XSPR(31,339,771), XSPR_MASK, POWER9,    0,              {RT}},
+{"mfpmc1",     XSPR(31,339,771), XSPR_MASK, POWER9,    0,              {RT}},
+{"mfupmc2",    XSPR(31,339,772), XSPR_MASK, POWER9,    0,              {RT}},
+{"mfpmc2",     XSPR(31,339,772), XSPR_MASK, POWER9,    0,              {RT}},
+{"mfupmc3",    XSPR(31,339,773), XSPR_MASK, POWER9,    0,              {RT}},
+{"mfpmc3",     XSPR(31,339,773), XSPR_MASK, POWER9,    0,              {RT}},
+{"mfupmc4",    XSPR(31,339,774), XSPR_MASK, POWER9,    0,              {RT}},
+{"mfpmc4",     XSPR(31,339,774), XSPR_MASK, POWER9,    0,              {RT}},
+{"mfupmc5",    XSPR(31,339,775), XSPR_MASK, POWER9,    0,              {RT}},
+{"mfpmc5",     XSPR(31,339,775), XSPR_MASK, POWER9,    0,              {RT}},
+{"mfupmc6",    XSPR(31,339,776), XSPR_MASK, POWER9,    0,              {RT}},
+{"mfpmc6",     XSPR(31,339,776), XSPR_MASK, POWER9,    0,              {RT}},
 {"mfmi_ctr",   XSPR(31,339,784), XSPR_MASK, PPC860,    0,              {RT}},
 {"mfmi_ap",    XSPR(31,339,786), XSPR_MASK, PPC860,    0,              {RT}},
 {"mfmi_epn",   XSPR(31,339,787), XSPR_MASK, PPC860,    0,              {RT}},
@@ -5926,6 +5996,11 @@ const struct powerpc_opcode powerpc_opcodes[] = {
 {"mfccr1",     XSPR(31,339,888), XSPR_MASK, TITAN,     0,              {RT}},
 {"mfppr",      XSPR(31,339,896), XSPR_MASK, POWER7,    0,              {RT}},
 {"mfppr32",    XSPR(31,339,898), XSPR_MASK, POWER7,    0,              {RT}},
+{"mfgqr",      XSPR(31,339,912), XSPRGQR_MASK, PPCPS,  0,              {RT, SPRGQR}},
+{"mfhid2",     XSPR(31,339,920), XSPR_MASK, GEKKO,     0,              {RT}},
+{"mfwpar",     XSPR(31,339,921), XSPR_MASK, GEKKO,     0,              {RT}},
+{"mfdmau",     XSPR(31,339,922), XSPR_MASK, GEKKO,     0,              {RT}},
+{"mfdmal",     XSPR(31,339,923), XSPR_MASK, GEKKO,     0,              {RT}},
 {"mfrstcfg",   XSPR(31,339,923), XSPR_MASK, TITAN,     0,              {RT}},
 {"mfdcdbtrl",  XSPR(31,339,924), XSPR_MASK, TITAN,     0,              {RT}},
 {"mfdcdbtrh",  XSPR(31,339,925), XSPR_MASK, TITAN,     0,              {RT}},
@@ -5970,10 +6045,15 @@ const struct powerpc_opcode powerpc_opcodes[] = {
 {"mfsrr2",     XSPR(31,339,990), XSPR_MASK, PPC403,    0,              {RT}},
 {"mfsrr3",     XSPR(31,339,991), XSPR_MASK, PPC403,    0,              {RT}},
 {"mfdbsr",     XSPR(31,339,1008), XSPR_MASK, PPC403,   0,              {RT}},
+{"mfhid0",     XSPR(31,339,1008), XSPR_MASK, GEKKO,    0,              {RT}},
+{"mfhid1",     XSPR(31,339,1009), XSPR_MASK, GEKKO,    0,              {RT}},
 {"mfdbcr0",    XSPR(31,339,1010), XSPR_MASK, PPC405,   0,              {RT}},
+{"mfiabr",     XSPR(31,339,1010), XSPR_MASK, GEKKO,    0,              {RT}},
+{"mfhid4",     XSPR(31,339,1011), XSPR_MASK, BROADWAY, 0,              {RT}},
 {"mfdbdr",     XSPR(31,339,1011), XSPR_MASK, TITAN,    0,              {RS}},
 {"mfiac1",     XSPR(31,339,1012), XSPR_MASK, PPC403,   0,              {RT}},
 {"mfiac2",     XSPR(31,339,1013), XSPR_MASK, PPC403,   0,              {RT}},
+{"mfdabr",     XSPR(31,339,1013), XSPR_MASK, PPC750,   0,              {RT}},
 {"mfdac1",     XSPR(31,339,1014), XSPR_MASK, PPC403,   0,              {RT}},
 {"mfdac2",     XSPR(31,339,1015), XSPR_MASK, PPC403,   0,              {RT}},
 {"mfl2cr",     XSPR(31,339,1017), XSPR_MASK, PPC750,   0,              {RT}},
@@ -6085,9 +6165,9 @@ const struct powerpc_opcode powerpc_opcodes[] = {
 {"yield",      0x7f7bdb78,     0xffffffff,  POWER7,    0,              {0}},
 {"mdoio",      0x7fbdeb78,     0xffffffff,  POWER7,    0,              {0}},
 {"mdoom",      0x7fdef378,     0xffffffff,  POWER7,    0,              {0}},
-{"mr",         XRC(31,444,0),  X_MASK,      COM,       0,              {RA, RS, RBS}},
+{"mr",         XRC(31,444,0),  X_MASK,      COM,       0,              {RA, RSB}},
 {"or",         XRC(31,444,0),  X_MASK,      COM,       0,              {RA, RS, RB}},
-{"mr.",                XRC(31,444,1),  X_MASK,      COM,       0,              {RA, RS, RBS}},
+{"mr.",                XRC(31,444,1),  X_MASK,      COM,       0,              {RA, RSB}},
 {"or.",                XRC(31,444,1),  X_MASK,      COM,       0,              {RA, RS, RB}},
 
 {"mtexisr",    XSPR(31,451, 64), XSPR_MASK, PPC403,    0,              {RS}},
@@ -6242,6 +6322,12 @@ const struct powerpc_opcode powerpc_opcodes[] = {
 {"mtmcsrr0",   XSPR(31,467,570), XSPR_MASK, PPCRFMCI,  0,              {RS}},
 {"mtmcsrr1",   XSPR(31,467,571), XSPR_MASK, PPCRFMCI,  0,              {RS}},
 {"mtmcsr",     XSPR(31,467,572), XSPR_MASK, PPCRFMCI,  0,              {RS}},
+{"mtupmc1",    XSPR(31,467,771), XSPR_MASK, POWER9,    0,              {RS}},
+{"mtupmc2",    XSPR(31,467,772), XSPR_MASK, POWER9,    0,              {RS}},
+{"mtupmc3",    XSPR(31,467,773), XSPR_MASK, POWER9,    0,              {RS}},
+{"mtupmc4",    XSPR(31,467,774), XSPR_MASK, POWER9,    0,              {RS}},
+{"mtupmc5",    XSPR(31,467,775), XSPR_MASK, POWER9,    0,              {RS}},
+{"mtupmc6",    XSPR(31,467,776), XSPR_MASK, POWER9,    0,              {RS}},
 {"mtivndx",    XSPR(31,467,880), XSPR_MASK, TITAN,     0,              {RS}},
 {"mtdvndx",    XSPR(31,467,881), XSPR_MASK, TITAN,     0,              {RS}},
 {"mtivlim",    XSPR(31,467,882), XSPR_MASK, TITAN,     0,              {RS}},
@@ -6250,6 +6336,11 @@ const struct powerpc_opcode powerpc_opcodes[] = {
 {"mtccr1",     XSPR(31,467,888), XSPR_MASK, TITAN,     0,              {RS}},
 {"mtppr",      XSPR(31,467,896), XSPR_MASK, POWER7,    0,              {RS}},
 {"mtppr32",    XSPR(31,467,898), XSPR_MASK, POWER7,    0,              {RS}},
+{"mtgqr",      XSPR(31,467,912), XSPRGQR_MASK, PPCPS,  0,              {SPRGQR, RS}},
+{"mthid2",     XSPR(31,467,920), XSPR_MASK, GEKKO,     0,              {RS}},
+{"mtwpar",     XSPR(31,467,921), XSPR_MASK, GEKKO,     0,              {RS}},
+{"mtdmau",     XSPR(31,467,922), XSPR_MASK, GEKKO,     0,              {RS}},
+{"mtdmal",     XSPR(31,467,923), XSPR_MASK, GEKKO,     0,              {RS}},
 {"mtummcr0",   XSPR(31,467,936), XSPR_MASK, PPC750,    0,              {RS}},
 {"mtupmc1",    XSPR(31,467,937), XSPR_MASK, PPC750,    0,              {RS}},
 {"mtupmc2",    XSPR(31,467,938), XSPR_MASK, PPC750,    0,              {RS}},
@@ -6290,10 +6381,15 @@ const struct powerpc_opcode powerpc_opcodes[] = {
 {"mtsrr2",     XSPR(31,467,990), XSPR_MASK, PPC403,    0,              {RS}},
 {"mtsrr3",     XSPR(31,467,991), XSPR_MASK, PPC403,    0,              {RS}},
 {"mtdbsr",     XSPR(31,467,1008), XSPR_MASK, PPC403,   0,              {RS}},
-{"mtdbdr",     XSPR(31,467,1011), XSPR_MASK, TITAN,    0,              {RS}},
+{"mthid0",     XSPR(31,467,1008), XSPR_MASK, GEKKO,    0,              {RS}},
+{"mthid1",     XSPR(31,467,1009), XSPR_MASK, GEKKO,    0,              {RS}},
 {"mtdbcr0",    XSPR(31,467,1010), XSPR_MASK, PPC405,   0,              {RS}},
+{"mtiabr",     XSPR(31,467,1010), XSPR_MASK, GEKKO,    0,              {RS}},
+{"mthid4",     XSPR(31,467,1011), XSPR_MASK, BROADWAY, 0,              {RS}},
+{"mtdbdr",     XSPR(31,467,1011), XSPR_MASK, TITAN,    0,              {RS}},
 {"mtiac1",     XSPR(31,467,1012), XSPR_MASK, PPC403,   0,              {RS}},
 {"mtiac2",     XSPR(31,467,1013), XSPR_MASK, PPC403,   0,              {RS}},
+{"mtdabr",     XSPR(31,467,1013), XSPR_MASK, PPC750,   0,              {RS}},
 {"mtdac1",     XSPR(31,467,1014), XSPR_MASK, PPC403,   0,              {RS}},
 {"mtdac2",     XSPR(31,467,1015), XSPR_MASK, PPC403,   0,              {RS}},
 {"mtl2cr",     XSPR(31,467,1017), XSPR_MASK, PPC750,   0,              {RS}},
@@ -7064,9 +7160,9 @@ const struct powerpc_opcode powerpc_opcodes[] = {
 {"xxsel",      XX4(60,3),      XX4_MASK,    PPCVSX,    PPCVLE,         {XT6, XA6, XB6, XC6}},
 {"xssubsp",    XX3(60,8),      XX3_MASK,    PPCVSX2,   PPCVLE,         {XT6, XA6, XB6}},
 {"xsmaddmsp",  XX3(60,9),      XX3_MASK,    PPCVSX2,   PPCVLE,         {XT6, XA6, XB6}},
-{"xxspltd",    XX3(60,10),     XX3DM_MASK,  PPCVSX,    PPCVLE,         {XT6, XA6, XB6S, DMEX}},
+{"xxspltd",    XX3(60,10),     XX3DM_MASK,  PPCVSX,    PPCVLE,         {XT6, XAB6, DMEX}},
 {"xxmrghd",    XX3(60,10),     XX3_MASK,    PPCVSX,    PPCVLE,         {XT6, XA6, XB6}},
-{"xxswapd",    XX3(60,10)|(2<<8), XX3_MASK, PPCVSX,    PPCVLE,         {XT6, XA6, XB6S}},
+{"xxswapd",    XX3(60,10)|(2<<8), XX3_MASK, PPCVSX,    PPCVLE,         {XT6, XAB6}},
 {"xxmrgld",    XX3(60,10)|(3<<8), XX3_MASK, PPCVSX,    PPCVLE,         {XT6, XA6, XB6}},
 {"xxpermdi",   XX3(60,10),     XX3DM_MASK,  PPCVSX,    PPCVLE,         {XT6, XA6, XB6, DM}},
 {"xscmpgtdp",  XX3(60,11),     XX3_MASK,    PPCVSX3,   PPCVLE,         {XT6, XA6, XB6}},
@@ -7214,7 +7310,7 @@ const struct powerpc_opcode powerpc_opcodes[] = {
 {"xvnmaddmsp", XX3(60,201),    XX3_MASK,    PPCVSX,    PPCVLE,         {XT6, XA6, XB6}},
 {"xvcvspsxds", XX2(60,408),    XX2_MASK,    PPCVSX,    PPCVLE,         {XT6, XB6}},
 {"xvabssp",    XX2(60,409),    XX2_MASK,    PPCVSX,    PPCVLE,         {XT6, XB6}},
-{"xvmovsp",    XX3(60,208),    XX3_MASK,    PPCVSX,    PPCVLE,         {XT6, XA6, XB6S}},
+{"xvmovsp",    XX3(60,208),    XX3_MASK,    PPCVSX,    PPCVLE,         {XT6, XAB6}},
 {"xvcpsgnsp",  XX3(60,208),    XX3_MASK,    PPCVSX,    PPCVLE,         {XT6, XA6, XB6}},
 {"xvnmsubasp", XX3(60,209),    XX3_MASK,    PPCVSX,    PPCVLE,         {XT6, XA6, XB6}},
 {"xvcvuxdsp",  XX2(60,424),    XX2_MASK,    PPCVSX,    PPCVLE,         {XT6, XB6}},
@@ -7243,7 +7339,7 @@ const struct powerpc_opcode powerpc_opcodes[] = {
 {"xvcvhpsp",   XX2VA(60,475,24),XX2_MASK,   PPCVSX3,   PPCVLE,         {XT6, XB6}},
 {"xvcvsphp",   XX2VA(60,475,25),XX2_MASK,   PPCVSX3,   PPCVLE,         {XT6, XB6}},
 {"xxbrq",      XX2VA(60,475,31),XX2_MASK,   PPCVSX3,   PPCVLE,         {XT6, XB6}},
-{"xvmovdp",    XX3(60,240),    XX3_MASK,    PPCVSX,    PPCVLE,         {XT6, XA6, XB6S}},
+{"xvmovdp",    XX3(60,240),    XX3_MASK,    PPCVSX,    PPCVLE,         {XT6, XAB6}},
 {"xvcpsgndp",  XX3(60,240),    XX3_MASK,    PPCVSX,    PPCVLE,         {XT6, XA6, XB6}},
 {"xvnmsubadp", XX3(60,241),    XX3_MASK,    PPCVSX,    PPCVLE,         {XT6, XA6, XB6}},
 {"xvcvuxddp",  XX2(60,488),    XX2_MASK,    PPCVSX,    PPCVLE,         {XT6, XB6}},
@@ -7563,7 +7659,7 @@ const struct powerpc_opcode powerpc_opcodes[] = {
 {"fcfidu.",    XRC(63,974,1),  XRA_MASK, POWER7|PPCA2, PPCVLE,         {FRT, FRB}},
 };
 
-const int powerpc_num_opcodes =
+const unsigned int powerpc_num_opcodes =
   sizeof (powerpc_opcodes) / sizeof (powerpc_opcodes[0]);
 \f
 /* The VLE opcode table.
@@ -8315,16 +8411,23 @@ const struct powerpc_opcode vle_opcodes[] = {
 {"e_sthu",     OPVUP(6,5),     OPVUP_MASK,     PPCVLE, 0,              {RT, D8, RA0}},
 {"e_stwu",     OPVUP(6,6),     OPVUP_MASK,     PPCVLE, 0,              {RT, D8, RA0}},
 {"e_stmw",     OPVUP(6,9),     OPVUP_MASK,     PPCVLE, 0,              {RT, D8, RA0}},
+{"e_lmvgprw",  OPVUPRT(6,16,0),OPVUPRT_MASK,   PPCVLE, 0,              {D8, RA0}},
 {"e_ldmvgprw", OPVUPRT(6,16,0),OPVUPRT_MASK,   PPCVLE, 0,              {D8, RA0}},
 {"e_stmvgprw", OPVUPRT(6,17,0),OPVUPRT_MASK,   PPCVLE, 0,              {D8, RA0}},
+{"e_lmvsprw",  OPVUPRT(6,16,1),OPVUPRT_MASK,   PPCVLE, 0,              {D8, RA0}},
 {"e_ldmvsprw", OPVUPRT(6,16,1),OPVUPRT_MASK,   PPCVLE, 0,              {D8, RA0}},
 {"e_stmvsprw", OPVUPRT(6,17,1),OPVUPRT_MASK,   PPCVLE, 0,              {D8, RA0}},
+{"e_lmvsrrw",  OPVUPRT(6,16,4),OPVUPRT_MASK,   PPCVLE, 0,              {D8, RA0}},
 {"e_ldmvsrrw", OPVUPRT(6,16,4),OPVUPRT_MASK,   PPCVLE, 0,              {D8, RA0}},
 {"e_stmvsrrw", OPVUPRT(6,17,4),OPVUPRT_MASK,   PPCVLE, 0,              {D8, RA0}},
+{"e_lmvcsrrw", OPVUPRT(6,16,5),OPVUPRT_MASK,   PPCVLE, 0,              {D8, RA0}},
 {"e_ldmvcsrrw",        OPVUPRT(6,16,5),OPVUPRT_MASK,   PPCVLE, 0,              {D8, RA0}},
 {"e_stmvcsrrw",        OPVUPRT(6,17,5),OPVUPRT_MASK,   PPCVLE, 0,              {D8, RA0}},
+{"e_lmvdsrrw", OPVUPRT(6,16,6),OPVUPRT_MASK,   PPCVLE, 0,              {D8, RA0}},
 {"e_ldmvdsrrw",        OPVUPRT(6,16,6),OPVUPRT_MASK,   PPCVLE, 0,              {D8, RA0}},
 {"e_stmvdsrrw",        OPVUPRT(6,17,6),OPVUPRT_MASK,   PPCVLE, 0,              {D8, RA0}},
+{"e_lmvmcsrrw",        OPVUPRT(6,16,7),OPVUPRT_MASK,   PPCVLE, 0,              {D8, RA0}},
+{"e_stmvmcsrrw",       OPVUPRT(6,17,7),OPVUPRT_MASK,   PPCVLE, 0,              {D8, RA0}},
 {"e_add16i",   OP(7),          OP_MASK,        PPCVLE, 0,              {RT, RA, SI}},
 {"e_la",       OP(7),          OP_MASK,        PPCVLE, 0,              {RT, D, RA0}},
 {"e_sub16i",   OP(7),          OP_MASK,        PPCVLE, 0,              {RT, RA, NSI}},
@@ -8424,9 +8527,9 @@ const struct powerpc_opcode vle_opcodes[] = {
 {"e_cmphl",    X(31,46),       X_MASK,         PPCVLE, 0,              {CRD, RA, RB}},
 {"e_crandc",   XL(31,129),     XL_MASK,        PPCVLE, 0,              {BT, BA, BB}},
 {"e_crnand",   XL(31,225),     XL_MASK,        PPCVLE, 0,              {BT, BA, BB}},
-{"e_crnot",    XL(31,33),      XL_MASK,        PPCVLE, 0,              {BT, BA, BBA}},
+{"e_crnot",    XL(31,33),      XL_MASK,        PPCVLE, 0,              {BT, BAB}},
 {"e_crnor",    XL(31,33),      XL_MASK,        PPCVLE, 0,              {BT, BA, BB}},
-{"e_crclr",    XL(31,193),     XL_MASK,        PPCVLE, 0,              {BT, BAT, BBA}},
+{"e_crclr",    XL(31,193),     XL_MASK,        PPCVLE, 0,              {BTAB}},
 {"e_crxor",    XL(31,193),     XL_MASK,        PPCVLE, 0,              {BT, BA, BB}},
 {"e_mcrf",     XL(31,16),      XL_MASK,        PPCVLE, 0,              {CRD, CR}},
 {"e_slwi",     EX(31,112),     EX_MASK,        PPCVLE, 0,              {RA, RS, SH}},
@@ -8437,7 +8540,7 @@ const struct powerpc_opcode vle_opcodes[] = {
 {"e_rlw",      EX(31,560),     EX_MASK,        PPCVLE, 0,              {RA, RS, RB}},
 {"e_rlw.",     EX(31,561),     EX_MASK,        PPCVLE, 0,              {RA, RS, RB}},
 
-{"e_crset",    XL(31,289),     XL_MASK,        PPCVLE, 0,              {BT, BAT, BBA}},
+{"e_crset",    XL(31,289),     XL_MASK,        PPCVLE, 0,              {BTAB}},
 {"e_creqv",    XL(31,289),     XL_MASK,        PPCVLE, 0,              {BT, BA, BB}},
 
 {"e_rlwi",     EX(31,624),     EX_MASK,        PPCVLE, 0,              {RA, RS, SH}},
@@ -8445,7 +8548,7 @@ const struct powerpc_opcode vle_opcodes[] = {
 
 {"e_crorc",    XL(31,417),     XL_MASK,        PPCVLE, 0,              {BT, BA, BB}},
 
-{"e_crmove",   XL(31,449),     XL_MASK,        PPCVLE, 0,              {BT, BA, BBA}},
+{"e_crmove",   XL(31,449),     XL_MASK,        PPCVLE, 0,              {BT, BAB}},
 {"e_cror",     XL(31,449),     XL_MASK,        PPCVLE, 0,              {BT, BA, BB}},
 
 {"mtmas1",     XSPR(31,467,625), XSPR_MASK,    PPCVLE, 0,              {RS}},
@@ -8484,7 +8587,7 @@ const struct powerpc_opcode vle_opcodes[] = {
 {"se_bl",      BD8(58,0,1),    BD8_MASK,       PPCVLE, 0,              {B8}},
 };
 
-const int vle_num_opcodes =
+const unsigned int vle_num_opcodes =
   sizeof (vle_opcodes) / sizeof (vle_opcodes[0]);
 \f
 /* The macro table.  This is only used by the assembler.  */
@@ -9375,5 +9478,5 @@ const struct powerpc_opcode spe2_opcodes[] = {
 {"evavgdsr",             VX (4, 1663),         VX_MASK,                PPCSPE2, 0, {RD, RA, RB}},
 };
 
-const int spe2_num_opcodes =
+const unsigned int spe2_num_opcodes =
   sizeof (spe2_opcodes) / sizeof (spe2_opcodes[0]);
This page took 0.071529 seconds and 4 git commands to generate.