Add -Wshadow to the gcc command line options used when compiling the binutils.
[deliverable/binutils-gdb.git] / gas / config / tc-i386-intel.c
index ff20874b3f541c48e8c027717f12bd4237292515..b3cdcd36d58cf0153dc594474ed78f871dd64be2 100644 (file)
@@ -23,6 +23,7 @@ static struct
   {
     operatorT op_modifier;     /* Operand modifier.  */
     int is_mem;                        /* 1 if operand is memory reference.  */
+    int has_offset;            /* 1 if operand has offset.  */
     unsigned int in_offset;    /* >=1 if processing operand of offset.  */
     unsigned int in_bracket;   /* >=1 if processing operand in brackets.  */
     unsigned int in_scale;     /* >=1 if processing multipication operand
@@ -153,7 +154,7 @@ operatorT i386_operator (const char *name, unsigned int operands, char *pc)
     }
 
   for (j = 0; i386_operators[j].name; ++j)
-    if (strcasecmp(i386_operators[j].name, name) == 0)
+    if (strcasecmp (i386_operators[j].name, name) == 0)
       {
        if (i386_operators[j].operands
            && i386_operators[j].operands != operands)
@@ -162,16 +163,16 @@ operatorT i386_operator (const char *name, unsigned int operands, char *pc)
       }
 
   for (j = 0; i386_types[j].name; ++j)
-    if (strcasecmp(i386_types[j].name, name) == 0)
+    if (strcasecmp (i386_types[j].name, name) == 0)
       break;
   if (i386_types[j].name && *pc == ' ')
     {
-      char *name = ++input_line_pointer;
+      char *pname = ++input_line_pointer;
       char c = get_symbol_end ();
 
-      if (strcasecmp (name, "ptr") == 0)
+      if (strcasecmp (pname, "ptr") == 0)
        {
-         name[-1] = *pc;
+         pname[-1] = *pc;
          *pc = c;
          if (intel_syntax > 0 || operands != 1)
            return O_illegal;
@@ -179,7 +180,7 @@ operatorT i386_operator (const char *name, unsigned int operands, char *pc)
        }
 
       *input_line_pointer = c;
-      input_line_pointer = name - 1;
+      input_line_pointer = pname - 1;
     }
 
   return O_absent;
@@ -187,13 +188,13 @@ operatorT i386_operator (const char *name, unsigned int operands, char *pc)
 
 static int i386_intel_parse_name (const char *name, expressionS *e)
 {
-  unsigned int i;
+  unsigned int j;
 
-  for (i = 0; i386_types[i].name; ++i)
-    if (strcasecmp(i386_types[i].name, name) == 0)
+  for (j = 0; i386_types[j].name; ++j)
+    if (strcasecmp(i386_types[j].name, name) == 0)
       {
        e->X_op = O_constant;
-       e->X_add_number = i386_types[i].sz[flag_code];
+       e->X_add_number = i386_types[j].sz[flag_code];
        e->X_add_symbol = NULL;
        e->X_op_symbol = NULL;
        return 1;
@@ -202,12 +203,12 @@ static int i386_intel_parse_name (const char *name, expressionS *e)
   return 0;
 }
 
-static INLINE int i386_intel_check (const reg_entry *reg,
+static INLINE int i386_intel_check (const reg_entry *rreg,
                                    const reg_entry *base,
-                                   const reg_entry *index)
+                                   const reg_entry *iindex)
 {
-  if ((this_operand >= 0 && reg != i.op[this_operand].regs)
-      || base != intel_state.base || index != intel_state.index)
+  if ((this_operand >= 0 && rreg != i.op[this_operand].regs)
+      || base != intel_state.base || iindex != intel_state.index)
     {
       as_bad (_("invalid use of register"));
       return 0;
@@ -248,9 +249,9 @@ static INLINE int i386_intel_simplify_symbol(symbolS *sym)
 
 static int i386_intel_simplify (expressionS *e)
 {
-  const reg_entry *reg = this_operand >= 0 ? i.op[this_operand].regs : NULL;
+  const reg_entry *the_reg = this_operand >= 0 ? i.op[this_operand].regs : NULL;
   const reg_entry *base = intel_state.base;
-  const reg_entry *index = intel_state.index;
+  const reg_entry *state_index = intel_state.index;
   int ret;
 
   if (!intel_syntax)
@@ -262,7 +263,7 @@ static int i386_intel_simplify (expressionS *e)
       if (e->X_add_symbol)
        {
          if (!i386_intel_simplify_symbol (e->X_add_symbol)
-             || !i386_intel_check(reg, intel_state.base, intel_state.index))
+             || !i386_intel_check(the_reg, intel_state.base, intel_state.index))
            return 0;;
        }
       if (!intel_state.in_offset)
@@ -279,10 +280,11 @@ static int i386_intel_simplify (expressionS *e)
       break;
 
     case O_offset:
+      intel_state.has_offset = 1;
       ++intel_state.in_offset;
       ret = i386_intel_simplify_symbol (e->X_add_symbol);
       --intel_state.in_offset;
-      if (!ret || !i386_intel_check(reg, base, index))
+      if (!ret || !i386_intel_check(the_reg, base, state_index))
        return 0;
       i386_intel_fold (e, e->X_add_symbol);
       return ret;
@@ -319,7 +321,7 @@ static int i386_intel_simplify (expressionS *e)
          return 0;
        }
       if (!i386_intel_simplify_symbol (e->X_op_symbol)
-         || !i386_intel_check(reg, intel_state.base, intel_state.index))
+         || !i386_intel_check(the_reg, intel_state.base, intel_state.index))
        return 0;
       if (!intel_state.in_offset)
        intel_state.seg = e->X_add_symbol;
@@ -423,13 +425,13 @@ static int i386_intel_simplify (expressionS *e)
       if (e->X_op == O_add || e->X_op == O_subtract)
        {
          base = intel_state.base;
-         index = intel_state.index;
+         state_index = intel_state.index;
        }
-      if (!i386_intel_check (reg, base, index)
+      if (!i386_intel_check (the_reg, base, state_index)
          || (e->X_op_symbol && !i386_intel_simplify_symbol (e->X_op_symbol))
-         || !i386_intel_check (reg,
+         || !i386_intel_check (the_reg,
                                e->X_op != O_add ? base : intel_state.base,
-                               e->X_op != O_add ? index : intel_state.index))
+                               e->X_op != O_add ? state_index : intel_state.index))
        return 0;
       break;
     }
@@ -464,6 +466,7 @@ i386_intel_operand (char *operand_string, int got_a_float)
   /* Initialize state structure.  */
   intel_state.op_modifier = O_absent;
   intel_state.is_mem = 0;
+  intel_state.has_offset = 0;
   intel_state.base = NULL;
   intel_state.index = NULL;
   intel_state.seg = NULL;
@@ -497,6 +500,10 @@ i386_intel_operand (char *operand_string, int got_a_float)
       as_bad (_("invalid expression"));
       ret = 0;
     }
+  else if (!intel_state.has_offset
+          && input_line_pointer > buf
+          && *(input_line_pointer - 1) == ']')
+    intel_state.is_mem |= 1;
 
   input_line_pointer = saved_input_line_pointer;
   free (buf);
@@ -714,6 +721,51 @@ i386_intel_operand (char *operand_string, int got_a_float)
       if (i.mem_operands
          >= 2 - !current_templates->start->opcode_modifier.isstring)
        {
+         /* Handle
+
+            call       0x9090,0x90909090
+            lcall      0x9090,0x90909090
+            jmp        0x9090,0x90909090
+            ljmp       0x9090,0x90909090
+          */
+
+         if ((current_templates->start->opcode_modifier.jumpintersegment
+              || current_templates->start->opcode_modifier.jumpdword
+              || current_templates->start->opcode_modifier.jump)
+             && this_operand == 1
+             && intel_state.seg == NULL
+             && i.mem_operands == 1
+             && i.disp_operands == 1
+             && intel_state.op_modifier == O_absent)
+           {
+             /* Try to process the first operand as immediate,  */
+             this_operand = 0;
+             if (i386_finalize_immediate (exp_seg, i.op[0].imms,
+                                          intel_state.reloc_types,
+                                          NULL))
+               {
+                 this_operand = 1;
+                 expP = &im_expressions[0];
+                 i.op[this_operand].imms = expP;
+                 *expP = exp;
+
+                 /* Try to process the second operand as immediate,  */
+                 if (i386_finalize_immediate (exp_seg, expP,
+                                              intel_state.reloc_types,
+                                              NULL))
+                   {
+                     i.mem_operands = 0;
+                     i.disp_operands = 0;
+                     i.imm_operands = 2;
+                     i.types[0].bitfield.mem = 0;
+                     i.types[0].bitfield.disp16 = 0;
+                     i.types[0].bitfield.disp32 = 0;
+                     i.types[0].bitfield.disp32s = 0;
+                     return 1;
+                   }
+               }
+           }
+
          as_bad (_("too many memory references for `%s'"),
                  current_templates->start->name);
          return 0;
This page took 0.02599 seconds and 4 git commands to generate.