gas/testsuite/
[external/binutils.git] / opcodes / i386-dis.c
index 4a01441..43d7ac3 100644 (file)
@@ -1,6 +1,6 @@
 /* Print i386 instructions for GDB, the GNU debugger.
    Copyright 1988, 1989, 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
 
    This file is part of the GNU opcodes library.
@@ -257,7 +257,7 @@ fetch_data (struct disassemble_info *info, bfd_byte *addr)
 #define sIb { OP_sI, b_mode }  /* sign extened byte */
 #define sIbT { OP_sI, b_T_mode } /* sign extened byte like 'T' */
 #define Iv { OP_I, v_mode }
-#define sIv { OP_sI, v_mode } 
+#define sIv { OP_sI, v_mode }
 #define Iq { OP_I, q_mode }
 #define Iv64 { OP_I64, v_mode }
 #define Iw { OP_I, w_mode }
@@ -851,6 +851,7 @@ enum
   PREFIX_0F38DF,
   PREFIX_0F38F0,
   PREFIX_0F38F1,
+  PREFIX_0F38F6,
   PREFIX_0F3A08,
   PREFIX_0F3A09,
   PREFIX_0F3A0A,
@@ -1318,6 +1319,14 @@ enum
   VEX_LEN_0F3A7F_P_2,
   VEX_LEN_0F3ADF_P_2,
   VEX_LEN_0F3AF0_P_3,
+  VEX_LEN_0FXOP_08_CC,
+  VEX_LEN_0FXOP_08_CD,
+  VEX_LEN_0FXOP_08_CE,
+  VEX_LEN_0FXOP_08_CF,
+  VEX_LEN_0FXOP_08_EC,
+  VEX_LEN_0FXOP_08_ED,
+  VEX_LEN_0FXOP_08_EE,
+  VEX_LEN_0FXOP_08_EF,
   VEX_LEN_0FXOP_09_80,
   VEX_LEN_0FXOP_09_81
 };
@@ -2881,9 +2890,9 @@ static const struct dis386 prefix_table[][4] = {
 
   /* PREFIX_0F2E */
   {
-    { "ucomiss",{ XM, EXd } }, 
+    { "ucomiss",{ XM, EXd } },
     { Bad_Opcode },
-    { "ucomisd",{ XM, EXq } }, 
+    { "ucomisd",{ XM, EXq } },
   },
 
   /* PREFIX_0F2F */
@@ -3474,7 +3483,7 @@ static const struct dis386 prefix_table[][4] = {
     { "movbeS",        { Gv, { MOVBE_Fixup, v_mode } } },
     { Bad_Opcode },
     { "movbeS",        { Gv, { MOVBE_Fixup, v_mode } } },
-    { "crc32", { Gdq, { CRC32_Fixup, b_mode } } },     
+    { "crc32", { Gdq, { CRC32_Fixup, b_mode } } },
   },
 
   /* PREFIX_0F38F1 */
@@ -3482,7 +3491,15 @@ static const struct dis386 prefix_table[][4] = {
     { "movbeS",        { { MOVBE_Fixup, v_mode }, Gv } },
     { Bad_Opcode },
     { "movbeS",        { { MOVBE_Fixup, v_mode }, Gv } },
-    { "crc32", { Gdq, { CRC32_Fixup, v_mode } } },     
+    { "crc32", { Gdq, { CRC32_Fixup, v_mode } } },
+  },
+
+  /* PREFIX_0F38F6 */
+  {
+    { Bad_Opcode },
+    { "adoxS", { Gdq, Edq} },
+    { "adcxS", { Gdq, Edq} },
+    { Bad_Opcode },
   },
 
   /* PREFIX_0F3A08 */
@@ -6055,7 +6072,7 @@ static const struct dis386 three_byte_table[][256] = {
     { Bad_Opcode },
     { Bad_Opcode },
     { Bad_Opcode },
-    { Bad_Opcode },
+    { PREFIX_TABLE (PREFIX_0F38F6) },
     { Bad_Opcode },
     /* f8 */
     { Bad_Opcode },
@@ -6885,10 +6902,10 @@ static const struct dis386 xop_table[][256] = {
     { Bad_Opcode },
     { Bad_Opcode },
     { Bad_Opcode },
-    { "vpcomb",        { XM, Vex128, EXx, Ib } },
-    { "vpcomw",        { XM, Vex128, EXx, Ib } },
-    { "vpcomd",        { XM, Vex128, EXx, Ib } },
-    { "vpcomq",        { XM, Vex128, EXx, Ib } },
+    { VEX_LEN_TABLE (VEX_LEN_0FXOP_08_CC) },
+    { VEX_LEN_TABLE (VEX_LEN_0FXOP_08_CD) },
+    { VEX_LEN_TABLE (VEX_LEN_0FXOP_08_CE) },
+    { VEX_LEN_TABLE (VEX_LEN_0FXOP_08_CF) },
     /* d0 */
     { Bad_Opcode },
     { Bad_Opcode },
@@ -6921,10 +6938,10 @@ static const struct dis386 xop_table[][256] = {
     { Bad_Opcode },
     { Bad_Opcode },
     { Bad_Opcode },
-    { "vpcomub",       { XM, Vex128, EXx, Ib } },
-    { "vpcomuw",       { XM, Vex128, EXx, Ib } },
-    { "vpcomud",       { XM, Vex128, EXx, Ib } },
-    { "vpcomuq",       { XM, Vex128, EXx, Ib } },
+    { VEX_LEN_TABLE (VEX_LEN_0FXOP_08_EC) },
+    { VEX_LEN_TABLE (VEX_LEN_0FXOP_08_ED) },
+    { VEX_LEN_TABLE (VEX_LEN_0FXOP_08_EE) },
+    { VEX_LEN_TABLE (VEX_LEN_0FXOP_08_EF) },
     /* f0 */
     { Bad_Opcode },
     { Bad_Opcode },
@@ -8993,6 +9010,46 @@ static const struct dis386 vex_len_table[][2] = {
     { "rorxS",         { Gdq, Edq, Ib } },
   },
 
+  /* VEX_LEN_0FXOP_08_CC */
+  {
+     { "vpcomb",       { XM, Vex128, EXx, Ib } },
+  },
+
+  /* VEX_LEN_0FXOP_08_CD */
+  {
+     { "vpcomw",       { XM, Vex128, EXx, Ib } },
+  },
+
+  /* VEX_LEN_0FXOP_08_CE */
+  {
+     { "vpcomd",       { XM, Vex128, EXx, Ib } },
+  },
+
+  /* VEX_LEN_0FXOP_08_CF */
+  {
+     { "vpcomq",       { XM, Vex128, EXx, Ib } },
+  },
+
+  /* VEX_LEN_0FXOP_08_EC */
+  {
+     { "vpcomub",      { XM, Vex128, EXx, Ib } },
+  },
+
+  /* VEX_LEN_0FXOP_08_ED */
+  {
+     { "vpcomuw",      { XM, Vex128, EXx, Ib } },
+  },
+
+  /* VEX_LEN_0FXOP_08_EE */
+  {
+     { "vpcomud",      { XM, Vex128, EXx, Ib } },
+  },
+
+  /* VEX_LEN_0FXOP_08_EF */
+  {
+     { "vpcomuq",      { XM, Vex128, EXx, Ib } },
+  },
+
   /* VEX_LEN_0FXOP_09_80 */
   {
     { "vfrczps",       { XM, EXxmm } },
@@ -9105,11 +9162,11 @@ static const struct dis386 vex_w_table[][2] = {
   },
   {
     /* VEX_W_0F2E_P_0 */
-    { "vucomiss",      { XMScalar, EXdScalar } }, 
+    { "vucomiss",      { XMScalar, EXdScalar } },
   },
   {
     /* VEX_W_0F2E_P_2 */
-    { "vucomisd",      { XMScalar, EXqScalar } }, 
+    { "vucomisd",      { XMScalar, EXqScalar } },
   },
   {
     /* VEX_W_0F2F_P_0 */
@@ -10185,7 +10242,7 @@ static const struct dis386 mod_table[][2] = {
   },
   {
     /* MOD_0F24 */
-    { Bad_Opcode },    
+    { Bad_Opcode },
     { "movL",          { Rd, Td } },
   },
   {
@@ -10323,6 +10380,7 @@ static const struct dis386 mod_table[][2] = {
   {
     /* MOD_0FC7_REG_7 */
     { "vmptrst",       { Mq } },
+    { "rdseed",                { Ev } },
   },
   {
     /* MOD_0FD7 */
@@ -10929,7 +10987,7 @@ get_valid_dis386 (const struct dis386 *dp, disassemble_info *info)
              break;
            }
        }
-      else 
+      else
        {
          vindex = 0;
          used_prefixes |= (prefixes & PREFIX_REPZ);
@@ -12217,7 +12275,7 @@ case_L:
        case 'T':
          if (!intel_syntax
              && address_mode == mode_64bit
-             && (sizeflag & DFLAG))
+             && ((sizeflag & DFLAG) || (rex & REX_W)))
            {
              *obufp++ = 'q';
              break;
@@ -12255,7 +12313,8 @@ case_L:
        case 'U':
          if (intel_syntax)
            break;
-         if (address_mode == mode_64bit && (sizeflag & DFLAG))
+         if (address_mode == mode_64bit
+              && ((sizeflag & DFLAG) || (rex & REX_W)))
            {
              if (modrm.mod != 3 || (sizeflag & SUFFIX_ALWAYS))
                *obufp++ = 'q';
@@ -12327,7 +12386,8 @@ case_Q:
            {
              if (intel_syntax)
                break;
-             if (address_mode == mode_64bit && (sizeflag & DFLAG))
+             if (address_mode == mode_64bit
+                  && ((sizeflag & DFLAG) || (rex & REX_W)))
                {
                  if (sizeflag & SUFFIX_ALWAYS)
                    *obufp++ = 'q';
@@ -12663,7 +12723,7 @@ intel_operand_size (int bytemode, int sizeflag)
       oappend ("WORD PTR ");
       break;
     case stack_v_mode:
-      if (address_mode == mode_64bit && (sizeflag & DFLAG))
+      if (address_mode == mode_64bit && ((sizeflag & DFLAG) || (rex & REX_W)))
        {
          oappend ("QWORD PTR ");
          break;
@@ -12940,7 +13000,7 @@ OP_E_register (int bytemode, int sizeflag)
       names = address_mode == mode_64bit ? names64 : names32;
       break;
     case stack_v_mode:
-      if (address_mode == mode_64bit && (sizeflag & DFLAG))
+      if (address_mode == mode_64bit && ((sizeflag & DFLAG) || (rex & REX_W)))
        {
          names = names64;
          break;
@@ -12958,7 +13018,7 @@ OP_E_register (int bytemode, int sizeflag)
        names = names64;
       else
        {
-         if ((sizeflag & DFLAG) 
+         if ((sizeflag & DFLAG)
              || (bytemode != v_mode
                  && bytemode != v_swap_mode))
            names = names32;
@@ -13025,13 +13085,13 @@ OP_E_memory (int bytemode, int sizeflag)
              switch (vex.length)
                {
                case 128:
-                 indexes64 = indexes32 = names_xmm; 
+                 indexes64 = indexes32 = names_xmm;
                  break;
                case 256:
                  if (!vex.w || bytemode == vex_vsib_q_w_dq_mode)
-                   indexes64 = indexes32 = names_ymm; 
+                   indexes64 = indexes32 = names_ymm;
                  else
-                   indexes64 = indexes32 = names_xmm; 
+                   indexes64 = indexes32 = names_xmm;
                  break;
                default:
                  abort ();
@@ -13124,11 +13184,11 @@ OP_E_memory (int bytemode, int sizeflag)
                      *obufp = '\0';
                    }
                  if (haveindex)
-                   oappend (address_mode == mode_64bit 
+                   oappend (address_mode == mode_64bit
                             && (sizeflag & AFLAG)
                             ? indexes64[vindex] : indexes32[vindex]);
                  else
-                   oappend (address_mode == mode_64bit 
+                   oappend (address_mode == mode_64bit
                             && (sizeflag & AFLAG)
                             ? index64 : index32);
 
@@ -13437,7 +13497,8 @@ OP_REG (int code, int sizeflag)
       break;
     case rAX_reg: case rCX_reg: case rDX_reg: case rBX_reg:
     case rSP_reg: case rBP_reg: case rSI_reg: case rDI_reg:
-      if (address_mode == mode_64bit && (sizeflag & DFLAG))
+      if (address_mode == mode_64bit
+          && ((sizeflag & DFLAG) || (rex & REX_W)))
        {
          s = names64[code - rAX_reg + add];
          break;
@@ -13652,9 +13713,10 @@ OP_sI (int bytemode, int sizeflag)
       if (bytemode == b_T_mode)
        {
          if (address_mode != mode_64bit
-             || !(sizeflag & DFLAG))
+             || !((sizeflag & DFLAG) || (rex & REX_W)))
            {
-             if (sizeflag & DFLAG)
+              /* The operand-size prefix is overridden by a REX prefix.  */
+              if ((sizeflag & DFLAG) || (rex & REX_W))
                op &= 0xffffffff;
              else
                op &= 0xffff;
@@ -13672,7 +13734,8 @@ OP_sI (int bytemode, int sizeflag)
        }
       break;
     case v_mode:
-      if (sizeflag & DFLAG)
+      /* The operand-size prefix is overridden by a REX prefix.  */
+      if ((sizeflag & DFLAG) || (rex & REX_W))
        op = get32s ();
       else
        op = get16 ();
@@ -14101,7 +14164,7 @@ OP_EX (int bytemode, int sizeflag)
   if ((sizeflag & SUFFIX_ALWAYS)
       && (bytemode == x_swap_mode
          || bytemode == d_swap_mode
-         || bytemode == d_scalar_swap_mode 
+         || bytemode == d_scalar_swap_mode
          || bytemode == q_swap_mode
          || bytemode == q_scalar_swap_mode))
     swap_operand ();
@@ -14116,7 +14179,7 @@ OP_EX (int bytemode, int sizeflag)
       && bytemode != xmm_mq_mode
       && bytemode != xmmq_mode
       && bytemode != d_scalar_mode
-      && bytemode != d_scalar_swap_mode 
+      && bytemode != d_scalar_swap_mode
       && bytemode != q_scalar_mode
       && bytemode != q_scalar_swap_mode
       && bytemode != vex_scalar_w_dq_mode)
@@ -14535,7 +14598,7 @@ CRC32_Fixup (int bytemode, int sizeflag)
       USED_REX (REX_W);
       if (rex & REX_W)
        *p++ = 'q';
-      else 
+      else
        {
          if (sizeflag & DFLAG)
            *p++ = 'l';
@@ -15087,7 +15150,7 @@ PCLMUL_Fixup (int bytemode ATTRIBUTE_UNUSED,
       break;
     default:
       break;
-    } 
+    }
   if (pclmul_type < ARRAY_SIZE (pclmul_op))
     {
       char suffix [4];
@@ -15182,4 +15245,3 @@ OP_LWP_E (int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
 
   oappend (names[vex.register_specifier]);
 }
-