gas/
[deliverable/binutils-gdb.git] / gas / config / tc-i386.c
index 6cfb04f3d236ab60075493f79c84f94a2fdce90b..26684c8e9847fa7b8fd1ed035d483cbba01715ef 100644 (file)
@@ -32,7 +32,7 @@
 #include "subsegs.h"
 #include "dwarf2dbg.h"
 #include "dw2gencfi.h"
-#include "opcode/i386.h"
+#include "opcodes/i386-opc.h"
 #include "elf/x86-64.h"
 
 #ifndef REGISTER_WARNINGS
@@ -78,7 +78,7 @@ static const reg_entry *parse_register (char *, char **);
 static char *parse_insn (char *, char *);
 static char *parse_operands (char *, const char *);
 static void swap_operands (void);
-static void swap_imm_operands (void);
+static void swap_2_operands (int, int);
 static void optimize_imm (void);
 static void optimize_disp (void);
 static int match_template (void);
@@ -291,6 +291,9 @@ static int intel_syntax = 0;
 /* 1 if register prefix % not required.  */
 static int allow_naked_reg = 0;
 
+/* Register prefix used for error message.  */
+static const char *register_prefix = "%";
+
 /* Used in 16 bit gcc mode to add an l suffix to call, ret, enter,
    leave, push, and pop instructions so that gcc has the same stack
    frame as in 32 bit mode.  */
@@ -737,10 +740,11 @@ i386_align_code (fragS *fragP, int count)
 
   /* We need to decide which NOP sequence to use for 32bit and
      64bit. When -mtune= is used:
-  
+
      1. For PROCESSOR_I486, PROCESSOR_PENTIUM and PROCESSOR_GENERIC32,
      f32_patt will be used.
-     2. For PROCESSOR_K8 and PROCESSOR_AMDFAM10 in 64bit, NOPs with 0x66 prefix will be used.
+     2. For PROCESSOR_K8 and PROCESSOR_AMDFAM10 in 64bit, NOPs with
+     0x66 prefix will be used.
      3. For PROCESSOR_CORE2, alt_long_patt will be used.
      4. For PROCESSOR_PENTIUMPRO, PROCESSOR_PENTIUM4, PROCESSOR_NOCONA,
      PROCESSOR_CORE, PROCESSOR_CORE2, PROCESSOR_K6, PROCESSOR_ATHLON
@@ -769,7 +773,7 @@ i386_align_code (fragS *fragP, int count)
       int pos = 0;
 
       /* The recommended way to pad 64bit code is to use NOPs preceded
-         by maximally four 0x66 prefixes.  Balance the size of nops.  */
+        by maximally four 0x66 prefixes.  Balance the size of nops.  */
       for (i = 0; i < remains; i++)
        {
          memset (fragP->fr_literal + fragP->fr_fix + pos, 0x66, len);
@@ -811,7 +815,7 @@ i386_align_code (fragS *fragP, int count)
            case PROCESSOR_ATHLON:
            case PROCESSOR_K8:
            case PROCESSOR_GENERIC64:
-           case PROCESSOR_AMDFAM10:  
+           case PROCESSOR_AMDFAM10:
              patt = alt_short_patt;
              break;
            case PROCESSOR_I486:
@@ -819,7 +823,7 @@ i386_align_code (fragS *fragP, int count)
            case PROCESSOR_GENERIC32:
              patt = f32_patt;
              break;
-           } 
+           }
        }
       else
        {
@@ -840,7 +844,7 @@ i386_align_code (fragS *fragP, int count)
            case PROCESSOR_K6:
            case PROCESSOR_ATHLON:
            case PROCESSOR_K8:
-            case PROCESSOR_AMDFAM10:
+           case PROCESSOR_AMDFAM10:
            case PROCESSOR_GENERIC32:
              /* We use cpu_arch_isa_flags to check if we CAN optimize
                 for Cpu686.  */
@@ -858,7 +862,7 @@ i386_align_code (fragS *fragP, int count)
            case PROCESSOR_GENERIC64:
              patt = alt_short_patt;
              break;
-           } 
+           }
        }
 
       memcpy (fragP->fr_literal + fragP->fr_fix,
@@ -1104,6 +1108,7 @@ set_intel_syntax (int syntax_flag)
 
   identifier_chars['%'] = intel_syntax && allow_naked_reg ? '%' : 0;
   identifier_chars['$'] = intel_syntax ? '$' : 0;
+  register_prefix = allow_naked_reg ? "" : "%";
 }
 
 static void
@@ -1126,7 +1131,8 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED)
                  cpu_arch_name = cpu_arch[i].name;
                  cpu_sub_arch_name = NULL;
                  cpu_arch_flags = (cpu_arch[i].flags
-                                   | (flag_code == CODE_64BIT ? Cpu64 : CpuNo64));
+                                   | (flag_code == CODE_64BIT
+                                      ? Cpu64 : CpuNo64));
                  cpu_arch_isa = cpu_arch[i].type;
                  cpu_arch_isa_flags = cpu_arch[i].flags;
                  if (!cpu_arch_tune_set)
@@ -1233,9 +1239,7 @@ md_begin ()
   {
     const reg_entry *regtab;
 
-    for (regtab = i386_regtab;
-        regtab < i386_regtab + sizeof (i386_regtab) / sizeof (i386_regtab[0]);
-        regtab++)
+    for (regtab = i386_regtab; regtab->reg_name != NULL; regtab++)
       {
        hash_err = hash_insert (reg_hash, regtab->reg_name, (PTR) regtab);
        if (hash_err)
@@ -1710,14 +1714,14 @@ md_assemble (line)
   if (line == NULL)
     return;
 
-  /* The order of the immediates should be reversed 
+  /* The order of the immediates should be reversed
      for 2 immediates extrq and insertq instructions */
-  if ((i.imm_operands == 2) && 
-      ((strcmp (mnemonic, "extrq") == 0) 
-       || (strcmp (mnemonic, "insertq") == 0)))
+  if ((i.imm_operands == 2)
+      && ((strcmp (mnemonic, "extrq") == 0)
+         || (strcmp (mnemonic, "insertq") == 0)))
     {
-      swap_imm_operands ();  
-      /* "extrq" and insertq" are the only two instructions whose operands 
+      swap_2_operands (0, 1);
+      /* "extrq" and insertq" are the only two instructions whose operands
         have to be reversed even though they have two immediate operands.
       */
       if (intel_syntax)
@@ -1731,7 +1735,8 @@ md_assemble (line)
      "enter".  We also don't reverse intersegment "jmp" and "call"
      instructions with 2 immediate operands so that the immediate segment
      precedes the offset, as it does when in AT&T mode. */
-  if (intel_syntax && i.operands > 1
+  if (intel_syntax
+      && i.operands > 1
       && (strcmp (mnemonic, "bound") != 0)
       && (strcmp (mnemonic, "invlpga") != 0)
       && !((i.types[0] & Imm) && (i.types[1] & Imm)))
@@ -1759,7 +1764,7 @@ md_assemble (line)
       /* Undo SYSV386_COMPAT brokenness when in Intel mode.  See i386.h  */
       if (SYSV386_COMPAT
          && (i.tm.base_opcode & 0xfffffde0) == 0xdce0)
-       i.tm.base_opcode ^= FloatR;
+       i.tm.base_opcode ^= Opcode_FloatR;
 
       /* Zap movzx and movsx suffix.  The suffix may have been set from
         "word ptr" or "byte ptr" on the source operand, but we'll use
@@ -1897,7 +1902,8 @@ md_assemble (line)
            {
              /* In case it is "hi" register, give up.  */
              if (i.op[x].regs->reg_num > 3)
-               as_bad (_("can't encode register '%%%s' in an instruction requiring REX prefix."),
+               as_bad (_("can't encode register '%%%s' in an "
+                         "instruction requiring REX prefix."),
                        i.op[x].regs->reg_name);
 
              /* Otherwise it is equivalent to the extended register.
@@ -2254,14 +2260,12 @@ parse_operands (char *l, const char *mnemonic)
 }
 
 static void
-swap_imm_operands (void)
+swap_2_operands (int xchg1, int xchg2)
 {
   union i386_op temp_op;
   unsigned int temp_type;
   enum bfd_reloc_code_real temp_reloc;
-  int xchg1 = 0;
-  int xchg2 = 1;
-  
+
   temp_type = i.types[xchg2];
   i.types[xchg2] = i.types[xchg1];
   i.types[xchg1] = temp_type;
@@ -2273,42 +2277,16 @@ swap_imm_operands (void)
   i.reloc[xchg1] = temp_reloc;
 }
 
-
 static void
 swap_operands (void)
 {
-  union i386_op temp_op;
-  unsigned int temp_type;
-  enum bfd_reloc_code_real temp_reloc;
-  int xchg1, xchg2;
-
   switch (i.operands)
     {
     case 4:
-      xchg1 = 1;
-      xchg2 = i.operands - 2;
-      temp_type = i.types[xchg2];
-      i.types[xchg2] = i.types[xchg1];
-      i.types[xchg1] = temp_type;
-      temp_op = i.op[xchg2];
-      i.op[xchg2] = i.op[xchg1];
-      i.op[xchg1] = temp_op;
-      temp_reloc = i.reloc[xchg2];
-      i.reloc[xchg2] = i.reloc[xchg1];
-      i.reloc[xchg1] = temp_reloc;
+      swap_2_operands (1, i.operands - 2);
     case 3:
     case 2:
-      xchg1 = 0;
-      xchg2 = i.operands - 1;
-      temp_type = i.types[xchg2];
-      i.types[xchg2] = i.types[xchg1];
-      i.types[xchg1] = temp_type;
-      temp_op = i.op[xchg2];
-      i.op[xchg2] = i.op[xchg1];
-      i.op[xchg1] = temp_op;
-      temp_reloc = i.reloc[xchg2];
-      i.reloc[xchg2] = i.reloc[xchg1];
-      i.reloc[xchg1] = temp_reloc;
+      swap_2_operands (0, i.operands - 1);
       break;
     default:
       abort ();
@@ -2416,8 +2394,10 @@ optimize_imm (void)
              unsigned int mask, allowed = 0;
              const template *t;
 
-             for (t = current_templates->start; t < current_templates->end; ++t)
-               allowed |= t->operand_types[op];
+             for (t = current_templates->start;
+                  t < current_templates->end;
+                  ++t)
+               allowed |= t->operand_types[op];
              switch (guess_suffix)
                {
                case QWORD_MNEM_SUFFIX:
@@ -2675,7 +2655,14 @@ match_template (void)
                }
              /* found_reverse_match holds which of D or FloatDR
                 we've found.  */
-             found_reverse_match = t->opcode_modifier & (D | FloatDR);
+             if ((t->opcode_modifier & D))
+               found_reverse_match = Opcode_D;
+             else if ((t->opcode_modifier & FloatD))
+               found_reverse_match = Opcode_FloatD;
+             else
+               found_reverse_match = 0;
+             if ((t->opcode_modifier & FloatR))
+               found_reverse_match |= Opcode_FloatR;
            }
          else
            {
@@ -2909,7 +2896,8 @@ process_suffix (void)
        {
          if (i.tm.opcode_modifier & W)
            {
-             as_bad (_("no instruction mnemonic suffix given and no register operands; can't size instruction"));
+             as_bad (_("no instruction mnemonic suffix given and "
+                       "no register operands; can't size instruction"));
              return 0;
            }
        }
@@ -3028,8 +3016,8 @@ check_byte_reg (void)
          if (flag_code == CODE_64BIT
              && (i.tm.operand_types[op] & InOutPortReg) == 0)
            {
-             as_bad (_("Incorrect register `%%%s' used with `%c' suffix"),
-                     i.op[op].regs->reg_name,
+             as_bad (_("Incorrect register `%s%s' used with `%c' suffix"),
+                     register_prefix, i.op[op].regs->reg_name,
                      i.suffix);
              return 0;
            }
@@ -3087,8 +3075,8 @@ check_long_reg (void)
           lowering is more complicated.  */
        if (flag_code == CODE_64BIT)
          {
-           as_bad (_("Incorrect register `%%%s' used with `%c' suffix"),
-                   i.op[op].regs->reg_name,
+           as_bad (_("Incorrect register `%s%s' used with `%c' suffix"),
+                   register_prefix, i.op[op].regs->reg_name,
                    i.suffix);
            return 0;
          }
@@ -3104,8 +3092,8 @@ check_long_reg (void)
     else if ((i.types[op] & Reg64) != 0
             && (i.tm.operand_types[op] & (Reg32 | Acc)) != 0)
       {
-       as_bad (_("Incorrect register `%%%s' used with `%c' suffix"),
-               i.op[op].regs->reg_name,
+       as_bad (_("Incorrect register `%s%s' used with `%c' suffix"),
+               register_prefix, i.op[op].regs->reg_name,
                i.suffix);
        return 0;
       }
@@ -3136,8 +3124,8 @@ check_qword_reg (void)
       {
        /* Prohibit these changes in the 64bit mode, since the
           lowering is more complicated.  */
-       as_bad (_("Incorrect register `%%%s' used with `%c' suffix"),
-               i.op[op].regs->reg_name,
+       as_bad (_("Incorrect register `%s%s' used with `%c' suffix"),
+               register_prefix, i.op[op].regs->reg_name,
                i.suffix);
        return 0;
       }
@@ -3169,8 +3157,8 @@ check_word_reg (void)
           lowering is more complicated.  */
        if (flag_code == CODE_64BIT)
          {
-           as_bad (_("Incorrect register `%%%s' used with `%c' suffix"),
-                   i.op[op].regs->reg_name,
+           as_bad (_("Incorrect register `%s%s' used with `%c' suffix"),
+                   register_prefix, i.op[op].regs->reg_name,
                    i.suffix);
            return 0;
          }
@@ -3217,7 +3205,8 @@ finalize_imm (void)
          && overlap0 != Imm16 && overlap0 != Imm32S
          && overlap0 != Imm32 && overlap0 != Imm64)
        {
-         as_bad (_("no instruction mnemonic suffix given; can't determine immediate size"));
+         as_bad (_("no instruction mnemonic suffix given; "
+                   "can't determine immediate size"));
          return 0;
        }
     }
@@ -3250,7 +3239,9 @@ finalize_imm (void)
          && overlap1 != Imm16 && overlap1 != Imm32S
          && overlap1 != Imm32 && overlap1 != Imm64)
        {
-         as_bad (_("no instruction mnemonic suffix given; can't determine immediate size %x %c"),overlap1, i.suffix);
+         as_bad (_("no instruction mnemonic suffix given; "
+                   "can't determine immediate size %x %c"),
+                 overlap1, i.suffix);
          return 0;
        }
     }
@@ -3288,28 +3279,43 @@ process_operands (void)
 
   if (i.tm.opcode_modifier & ShortForm)
     {
-      /* The register or float register operand is in operand 0 or 1.  */
-      unsigned int op = (i.types[0] & (Reg | FloatReg)) ? 0 : 1;
-      /* Register goes in low 3 bits of opcode.  */
-      i.tm.base_opcode |= i.op[op].regs->reg_num;
-      if ((i.op[op].regs->reg_flags & RegRex) != 0)
-       i.rex |= REX_EXTZ;
-      if (!quiet_warnings && (i.tm.opcode_modifier & Ugh) != 0)
+      if (i.types[0] & (SReg2 | SReg3))
        {
-         /* Warn about some common errors, but press on regardless.
-            The first case can be generated by gcc (<= 2.8.1).  */
-         if (i.operands == 2)
+         if (i.tm.base_opcode == POP_SEG_SHORT
+             && i.op[0].regs->reg_num == 1)
            {
-             /* Reversed arguments on faddp, fsubp, etc.  */
-             as_warn (_("translating to `%s %%%s,%%%s'"), i.tm.name,
-                      i.op[1].regs->reg_name,
-                      i.op[0].regs->reg_name);
+             as_bad (_("you can't `pop %%cs'"));
+             return 0;
            }
-         else
+         i.tm.base_opcode |= (i.op[0].regs->reg_num << 3);
+         if ((i.op[0].regs->reg_flags & RegRex) != 0)
+           i.rex |= REX_EXTZ;
+       }
+      else
+       {
+         /* The register or float register operand is in operand 0 or 1.  */
+         unsigned int op = (i.types[0] & (Reg | FloatReg)) ? 0 : 1;
+         /* Register goes in low 3 bits of opcode.  */
+         i.tm.base_opcode |= i.op[op].regs->reg_num;
+         if ((i.op[op].regs->reg_flags & RegRex) != 0)
+           i.rex |= REX_EXTZ;
+         if (!quiet_warnings && (i.tm.opcode_modifier & Ugh) != 0)
            {
-             /* Extraneous `l' suffix on fp insn.  */
-             as_warn (_("translating to `%s %%%s'"), i.tm.name,
-                      i.op[0].regs->reg_name);
+             /* Warn about some common errors, but press on regardless.
+                The first case can be generated by gcc (<= 2.8.1).  */
+             if (i.operands == 2)
+               {
+                 /* Reversed arguments on faddp, fsubp, etc.  */
+                 as_warn (_("translating to `%s %%%s,%%%s'"), i.tm.name,
+                          i.op[1].regs->reg_name,
+                          i.op[0].regs->reg_name);
+               }
+             else
+               {
+                 /* Extraneous `l' suffix on fp insn.  */
+                 as_warn (_("translating to `%s %%%s'"), i.tm.name,
+                          i.op[0].regs->reg_name);
+               }
            }
        }
     }
@@ -3321,19 +3327,7 @@ process_operands (void)
 
       default_seg = build_modrm_byte ();
     }
-  else if (i.tm.opcode_modifier & (Seg2ShortForm | Seg3ShortForm))
-    {
-      if (i.tm.base_opcode == POP_SEG_SHORT
-         && i.op[0].regs->reg_num == 1)
-       {
-         as_bad (_("you can't `pop %%cs'"));
-         return 0;
-       }
-      i.tm.base_opcode |= (i.op[0].regs->reg_num << 3);
-      if ((i.op[0].regs->reg_flags & RegRex) != 0)
-       i.rex |= REX_EXTZ;
-    }
-  else if ((i.tm.base_opcode & ~(D | W)) == MOV_AX_DISP32)
+  else if ((i.tm.base_opcode & ~0x3) == MOV_AX_DISP32)
     {
       default_seg = &ds;
     }
@@ -3439,9 +3433,12 @@ build_modrm_byte (void)
       if (i.mem_operands)
        {
          unsigned int fake_zero_displacement = 0;
-         unsigned int op = ((i.types[0] & AnyMem)
-                            ? 0
-                            : (i.types[1] & AnyMem) ? 1 : 2);
+         unsigned int op;
+
+         for (op = 0; op < i.operands; op++)
+           if ((i.types[op] & AnyMem))
+             break;
+         assert (op < i.operands);
 
          default_seg = &ds;
 
@@ -3612,18 +3609,15 @@ build_modrm_byte (void)
         registers are coded into the i.rm.reg field.  */
       if (i.reg_operands)
        {
-         unsigned int op =
-           ((i.types[0]
-             & (Reg | RegMMX | RegXMM
-                | SReg2 | SReg3
-                | Control | Debug | Test))
-            ? 0
-            : ((i.types[1]
-                & (Reg | RegMMX | RegXMM
-                   | SReg2 | SReg3
-                   | Control | Debug | Test))
-               ? 1
-               : 2));
+         unsigned int op;
+
+         for (op = 0; op < i.operands; op++)
+           if ((i.types[op] & (Reg | RegMMX | RegXMM
+                               | SReg2 | SReg3
+                               | Control | Debug | Test)))
+             break;
+         assert (op < i.operands);
+
          /* If there is an extension opcode to put here, the register
             number must be put into the regmem field.  */
          if (i.tm.extension_opcode != None)
@@ -4300,23 +4294,57 @@ lex_got (enum bfd_reloc_code_real *reloc,
     const enum bfd_reloc_code_real rel[2];
     const unsigned int types64;
   } gotrel[] = {
-    { "PLTOFF",   { 0,                        BFD_RELOC_X86_64_PLTOFF64 }, Imm64 },
-    { "PLT",      { BFD_RELOC_386_PLT32,      BFD_RELOC_X86_64_PLT32    }, Imm32|Imm32S|Disp32 },
-    { "GOTPLT",   { 0,                        BFD_RELOC_X86_64_GOTPLT64 }, Imm64|Disp64 },
-    { "GOTOFF",   { BFD_RELOC_386_GOTOFF,     BFD_RELOC_X86_64_GOTOFF64 }, Imm64|Disp64 },
-    { "GOTPCREL", { 0,                        BFD_RELOC_X86_64_GOTPCREL }, Imm32|Imm32S|Disp32 },
-    { "TLSGD",    { BFD_RELOC_386_TLS_GD,     BFD_RELOC_X86_64_TLSGD    }, Imm32|Imm32S|Disp32 },
-    { "TLSLDM",   { BFD_RELOC_386_TLS_LDM,    0                         }, 0 },
-    { "TLSLD",    { 0,                        BFD_RELOC_X86_64_TLSLD    }, Imm32|Imm32S|Disp32 },
-    { "GOTTPOFF", { BFD_RELOC_386_TLS_IE_32,  BFD_RELOC_X86_64_GOTTPOFF }, Imm32|Imm32S|Disp32 },
-    { "TPOFF",    { BFD_RELOC_386_TLS_LE_32,  BFD_RELOC_X86_64_TPOFF32  }, Imm32|Imm32S|Imm64|Disp32|Disp64 },
-    { "NTPOFF",   { BFD_RELOC_386_TLS_LE,     0                         }, 0 },
-    { "DTPOFF",   { BFD_RELOC_386_TLS_LDO_32, BFD_RELOC_X86_64_DTPOFF32 }, Imm32|Imm32S|Imm64|Disp32|Disp64 },
-    { "GOTNTPOFF",{ BFD_RELOC_386_TLS_GOTIE,  0                         }, 0 },
-    { "INDNTPOFF",{ BFD_RELOC_386_TLS_IE,     0                         }, 0 },
-    { "GOT",      { BFD_RELOC_386_GOT32,      BFD_RELOC_X86_64_GOT32    }, Imm32|Imm32S|Disp32|Imm64 },
-    { "TLSDESC",  { BFD_RELOC_386_TLS_GOTDESC, BFD_RELOC_X86_64_GOTPC32_TLSDESC }, Imm32|Imm32S|Disp32 },
-    { "TLSCALL",  { BFD_RELOC_386_TLS_DESC_CALL, BFD_RELOC_X86_64_TLSDESC_CALL }, Imm32|Imm32S|Disp32 }
+    { "PLTOFF",   { 0,
+                   BFD_RELOC_X86_64_PLTOFF64 },
+      Imm64 },
+    { "PLT",      { BFD_RELOC_386_PLT32,
+                   BFD_RELOC_X86_64_PLT32    },
+      Imm32 | Imm32S | Disp32 },
+    { "GOTPLT",   { 0,
+                   BFD_RELOC_X86_64_GOTPLT64 },
+      Imm64 | Disp64 },
+    { "GOTOFF",   { BFD_RELOC_386_GOTOFF,
+                   BFD_RELOC_X86_64_GOTOFF64 },
+      Imm64 | Disp64 },
+    { "GOTPCREL", { 0,
+                   BFD_RELOC_X86_64_GOTPCREL },
+      Imm32 | Imm32S | Disp32 },
+    { "TLSGD",    { BFD_RELOC_386_TLS_GD,
+                   BFD_RELOC_X86_64_TLSGD    },
+      Imm32 | Imm32S | Disp32 },
+    { "TLSLDM",   { BFD_RELOC_386_TLS_LDM,
+                   0                         },
+      0 },
+    { "TLSLD",    { 0,
+                   BFD_RELOC_X86_64_TLSLD    },
+      Imm32 | Imm32S | Disp32 },
+    { "GOTTPOFF", { BFD_RELOC_386_TLS_IE_32,
+                   BFD_RELOC_X86_64_GOTTPOFF },
+      Imm32 | Imm32S | Disp32 },
+    { "TPOFF",    { BFD_RELOC_386_TLS_LE_32,
+                   BFD_RELOC_X86_64_TPOFF32  },
+      Imm32 | Imm32S | Imm64 | Disp32 | Disp64 },
+    { "NTPOFF",   { BFD_RELOC_386_TLS_LE,
+                   0                         },
+      0 },
+    { "DTPOFF",   { BFD_RELOC_386_TLS_LDO_32,
+                   BFD_RELOC_X86_64_DTPOFF32 },
+      Imm32 | Imm32S | Imm64 | Disp32 | Disp64 },
+    { "GOTNTPOFF",{ BFD_RELOC_386_TLS_GOTIE,
+                   0                         },
+      0 },
+    { "INDNTPOFF",{ BFD_RELOC_386_TLS_IE,
+                   0                         },
+      0 },
+    { "GOT",      { BFD_RELOC_386_GOT32,
+                   BFD_RELOC_X86_64_GOT32    },
+      Imm32 | Imm32S | Disp32 | Imm64 },
+    { "TLSDESC",  { BFD_RELOC_386_TLS_GOTDESC,
+                   BFD_RELOC_X86_64_GOTPC32_TLSDESC },
+      Imm32 | Imm32S | Disp32 },
+    { "TLSCALL",  { BFD_RELOC_386_TLS_DESC_CALL,
+                   BFD_RELOC_X86_64_TLSDESC_CALL },
+      Imm32 | Imm32S | Disp32 }
   };
   char *cp;
   unsigned int j;
@@ -4347,7 +4375,7 @@ lex_got (enum bfd_reloc_code_real *reloc,
              if (types)
                {
                  if (flag_code != CODE_64BIT)
-                   *types = Imm32|Disp32;
+                   *types = Imm32 | Disp32;
                  else
                    *types = gotrel[j].types64;
                }
@@ -4506,9 +4534,10 @@ i386_immediate (char *imm_start)
       /* Size it properly later.  */
       i.types[this_operand] |= Imm64;
       /* If BFD64, sign extend val.  */
-      if (!use_rela_relocations)
-       if ((exp->X_add_number & ~(((addressT) 2 << 31) - 1)) == 0)
-         exp->X_add_number = (exp->X_add_number ^ ((addressT) 1 << 31)) - ((addressT) 1 << 31);
+      if (!use_rela_relocations
+         && (exp->X_add_number & ~(((addressT) 2 << 31) - 1)) == 0)
+       exp->X_add_number
+         = (exp->X_add_number ^ ((addressT) 1 << 31)) - ((addressT) 1 << 31);
     }
 #if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT))
   else if (OUTPUT_FLAVOR == bfd_target_aout_flavour
@@ -4860,7 +4889,8 @@ i386_index_check (const char *operand_string)
             FIXME.  There doesn't seem to be any real need for separate
             Disp16 and Disp32 flags.  The same goes for Imm16 and Imm32.
             Removing them would probably clean up the code quite a lot.  */
-         if (flag_code != CODE_64BIT && (i.types[this_operand] & (Disp16 | Disp32)))
+         if (flag_code != CODE_64BIT
+             && (i.types[this_operand] & (Disp16 | Disp32)))
            i.types[this_operand] ^= (Disp16 | Disp32);
          fudged = 1;
          goto tryprefix;
@@ -5039,7 +5069,8 @@ i386_operand (char *operand_string)
            ++base_string;
 
          if (*base_string == ','
-             || ((i.base_reg = parse_register (base_string, &end_op)) != NULL))
+             || ((i.base_reg = parse_register (base_string, &end_op))
+                 != NULL))
            {
              displacement_string_end = temp_string;
 
@@ -5059,7 +5090,8 @@ i386_operand (char *operand_string)
                  if (is_space_char (*base_string))
                    ++base_string;
 
-                 if ((i.index_reg = parse_register (base_string, &end_op)) != NULL)
+                 if ((i.index_reg = parse_register (base_string, &end_op))
+                     != NULL)
                    {
                      base_string = end_op;
                      if (is_space_char (*base_string))
@@ -5072,7 +5104,8 @@ i386_operand (char *operand_string)
                        }
                      else if (*base_string != ')')
                        {
-                         as_bad (_("expecting `,' or `)' after index register in `%s'"),
+                         as_bad (_("expecting `,' or `)' "
+                                   "after index register in `%s'"),
                                  operand_string);
                          return 0;
                        }
@@ -5096,21 +5129,24 @@ i386_operand (char *operand_string)
                        ++base_string;
                      if (*base_string != ')')
                        {
-                         as_bad (_("expecting `)' after scale factor in `%s'"),
+                         as_bad (_("expecting `)' "
+                                   "after scale factor in `%s'"),
                                  operand_string);
                          return 0;
                        }
                    }
                  else if (!i.index_reg)
                    {
-                     as_bad (_("expecting index register or scale factor after `,'; got '%c'"),
+                     as_bad (_("expecting index register or scale factor "
+                               "after `,'; got '%c'"),
                              *base_string);
                      return 0;
                    }
                }
              else if (*base_string != ')')
                {
-                 as_bad (_("expecting `,' or `)' after base register in `%s'"),
+                 as_bad (_("expecting `,' or `)' "
+                           "after base register in `%s'"),
                          operand_string);
                  return 0;
                }
@@ -5326,7 +5362,8 @@ md_convert_frag (abfd, sec, fragP)
     {
       if (no_cond_jump_promotion
          && TYPE_FROM_RELAX_STATE (fragP->fr_subtype) != UNCOND_JUMP)
-       as_warn_where (fragP->fr_file, fragP->fr_line, _("long jump required"));
+       as_warn_where (fragP->fr_file, fragP->fr_line,
+                      _("long jump required"));
 
       switch (fragP->fr_subtype)
        {
@@ -5377,8 +5414,8 @@ md_convert_frag (abfd, sec, fragP)
   if (DISP_SIZE_FROM_RELAX_STATE (fragP->fr_subtype) == 4
       && object_64bit
       && ((addressT) (displacement_from_opcode_start - extension
-                      + ((addressT) 1 << 31))
-          > (((addressT) 2 << 31) - 1)))
+                     + ((addressT) 1 << 31))
+         > (((addressT) 2 << 31) - 1)))
     {
       as_bad_where (fragP->fr_file, fragP->fr_line,
                    _("jump target out of range"));
@@ -5753,7 +5790,8 @@ parse_register (char *reg_string, char **end_op)
          const expressionS *e = symbol_get_value_expression (symbolP);
 
          know (e->X_op == O_register);
-         know (e->X_add_number >= 0 && (valueT) e->X_add_number < ARRAY_SIZE (i386_regtab));
+         know (e->X_add_number >= 0
+               && (valueT) e->X_add_number < ARRAY_SIZE (i386_regtab));
          r = i386_regtab + e->X_add_number;
          *end_op = input_line_pointer;
        }
@@ -5980,7 +6018,7 @@ md_show_usage (stream)
   fprintf (stream, _("\
   -march=CPU/-mtune=CPU   generate code/optimize for CPU, where CPU is one of:\n\
                            i386, i486, pentium, pentiumpro, pentium4, nocona,\n\
-                          core, core2, k6, athlon, k8, generic32, generic64\n"));
+                           core, core2, k6, athlon, k8, generic32, generic64\n"));
 
 }
 
@@ -6529,8 +6567,8 @@ struct intel_parser_s
     int got_a_float;           /* Whether the operand is a float.  */
     int op_modifier;           /* Operand modifier.  */
     int is_mem;                        /* 1 if operand is memory reference.  */
-    int in_offset;                     /* >=1 if parsing operand of offset.  */
-    int in_bracket;                    /* >=1 if parsing operand in brackets.  */
+    int in_offset;             /* >=1 if parsing operand of offset.  */
+    int in_bracket;            /* >=1 if parsing operand in brackets.  */
     const reg_entry *reg;      /* Last register reference found.  */
     char *disp;                        /* Displacement string being built.  */
     char *next_operand;                /* Resume point when splitting operands.  */
@@ -6671,7 +6709,7 @@ i386_intel_operand (char *operand_string, int got_a_float)
        ret = i386_immediate (intel_parser.disp);
 
       if (intel_parser.next_operand && this_operand >= MAX_OPERANDS - 1)
-        ret = 0;
+       ret = 0;
       if (!ret || !intel_parser.next_operand)
        break;
       intel_parser.op_string = intel_parser.next_operand;
@@ -6740,7 +6778,9 @@ intel_e05 (void)
       if (!intel_e06())
        return 0;
 
-      if (cur_token.code == '&' || cur_token.code == '|' || cur_token.code == '^')
+      if (cur_token.code == '&'
+         || cur_token.code == '|'
+         || cur_token.code == '^')
        {
          char str[2];
 
@@ -6775,7 +6815,9 @@ intel_e06 (void)
       if (!intel_e09())
        return 0;
 
-      if (cur_token.code == '*' || cur_token.code == '/' || cur_token.code == '%')
+      if (cur_token.code == '*'
+         || cur_token.code == '/'
+         || cur_token.code == '%')
        {
          char str[2];
 
@@ -7087,7 +7129,8 @@ intel_bracket_expr (void)
                /* Defer the warning until all of the operand was parsed.  */
                intel_parser.is_mem = -1;
              else if (!quiet_warnings)
-               as_warn (_("`[%.*s]' taken to mean just `%.*s'"), len, start, len, start);
+               as_warn (_("`[%.*s]' taken to mean just `%.*s'"),
+                        len, start, len, start);
            }
        }
       intel_parser.op_modifier |= was_offset;
@@ -7177,7 +7220,8 @@ intel_e11 (void)
          {
            if (!(reg->reg_type & (SReg2 | SReg3)))
              {
-               as_bad (_("`%s' is not a valid segment register"), reg->reg_name);
+               as_bad (_("`%s' is not a valid segment register"),
+                       reg->reg_name);
                return 0;
              }
            else if (i.seg[i.mem_operands])
@@ -7367,7 +7411,8 @@ intel_e11 (void)
        /* Get the next token to check for register scaling.  */
        intel_match_token (cur_token.code);
 
-       /* Check if this constant is a scaling factor for an index register.  */
+       /* Check if this constant is a scaling factor for an
+          index register.  */
        if (cur_token.code == '*')
          {
            if (intel_match_token ('*') && cur_token.code == T_REG)
@@ -7376,14 +7421,17 @@ intel_e11 (void)
 
                if (!intel_parser.in_bracket)
                  {
-                   as_bad (_("Register scaling only allowed in memory operands"));
+                   as_bad (_("Register scaling only allowed "
+                             "in memory operands"));
                    return 0;
                  }
 
-               if (reg->reg_type & Reg16) /* Disallow things like [1*si]. */
-                 reg = i386_regtab + REGNAM_AX + 4; /* sp is invalid as index */
+                /* Disallow things like [1*si].
+                   sp and esp are invalid as index.  */
+               if (reg->reg_type & Reg16)
+                 reg = i386_regtab + REGNAM_AX + 4;
                else if (i.index_reg)
-                 reg = i386_regtab + REGNAM_EAX + 4; /* esp is invalid as index */
+                 reg = i386_regtab + REGNAM_EAX + 4;
 
                /* The constant is followed by `* reg', so it must be
                   a valid scale.  */
This page took 0.034744 seconds and 4 git commands to generate.