RISC-V: Fix lui argument parsing.
[deliverable/binutils-gdb.git] / gas / config / tc-i386-intel.c
index b8874e4b8dd79db0705f2c6ba6344104eb72264b..a2cd286572d3fd7ab712fd3d49eba06755feb537 100644 (file)
@@ -1,5 +1,5 @@
 /* tc-i386.c -- Assemble Intel syntax code for ix86/x86-64
-   Copyright (C) 2009-2017 Free Software Foundation, Inc.
+   Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
@@ -270,6 +270,12 @@ i386_intel_simplify_register (expressionS *e)
   else
     reg_num = e->X_md - 1;
 
+  if (reg_num < 0 || reg_num >= (int) i386_regtab_size)
+    {
+      as_bad (_("invalid register number"));
+      return 0;
+    }
+
   if (!intel_state.in_bracket)
     {
       if (i.op[this_operand].regs)
@@ -286,11 +292,10 @@ i386_intel_simplify_register (expressionS *e)
       i.op[this_operand].regs = i386_regtab + reg_num;
     }
   else if (!intel_state.index
-          && (i386_regtab[reg_num].reg_type.bitfield.regxmm
-              || i386_regtab[reg_num].reg_type.bitfield.regymm
-              || i386_regtab[reg_num].reg_type.bitfield.regzmm
-              || i386_regtab[reg_num].reg_num == RegRiz
-              || i386_regtab[reg_num].reg_num == RegEiz))
+          && (i386_regtab[reg_num].reg_type.bitfield.xmmword
+              || i386_regtab[reg_num].reg_type.bitfield.ymmword
+              || i386_regtab[reg_num].reg_type.bitfield.zmmword
+              || i386_regtab[reg_num].reg_num == RegIZ))
     intel_state.index = i386_regtab + reg_num;
   else if (!intel_state.base && !intel_state.in_scale)
     intel_state.base = i386_regtab + reg_num;
@@ -413,7 +418,19 @@ static int i386_intel_simplify (expressionS *e)
                               intel_state.index))
        return 0;
       if (!intel_state.in_offset)
-       intel_state.seg = e->X_add_symbol;
+       {
+         if (!intel_state.seg)
+           intel_state.seg = e->X_add_symbol;
+         else
+           {
+             expressionS exp;
+
+             exp.X_op = O_full_ptr;
+             exp.X_add_symbol = e->X_add_symbol;
+             exp.X_op_symbol = intel_state.seg;
+             intel_state.seg = make_expr_symbol (&exp);
+           }
+       }
       i386_intel_fold (e, e->X_op_symbol);
       break;
 
@@ -439,7 +456,7 @@ static int i386_intel_simplify (expressionS *e)
            {
              resolve_expression (scale);
              if (scale->X_op != O_constant
-                 || intel_state.index->reg_type.bitfield.reg16)
+                 || intel_state.index->reg_type.bitfield.word)
                scale->X_add_number = 0;
              intel_state.scale_factor *= scale->X_add_number;
            }
@@ -580,12 +597,14 @@ i386_intel_operand (char *operand_string, int got_a_float)
 
   if (!is_end_of_line[(unsigned char) *input_line_pointer])
     {
-      as_bad (_("junk `%s' after expression"), input_line_pointer);
+      if (ret)
+       as_bad (_("junk `%s' after expression"), input_line_pointer);
       ret = 0;
     }
   else if (exp.X_op == O_illegal || exp.X_op == O_absent)
     {
-      as_bad (_("invalid expression"));
+      if (ret)
+       as_bad (_("invalid expression"));
       ret = 0;
     }
   else if (!intel_state.has_offset
@@ -684,17 +703,14 @@ i386_intel_operand (char *operand_string, int got_a_float)
        case O_oword_ptr:
        case O_xmmword_ptr:
          i.types[this_operand].bitfield.xmmword = 1;
-         suffix = XMMWORD_MNEM_SUFFIX;
          break;
 
        case O_ymmword_ptr:
          i.types[this_operand].bitfield.ymmword = 1;
-         suffix = YMMWORD_MNEM_SUFFIX;
          break;
 
        case O_zmmword_ptr:
          i.types[this_operand].bitfield.zmmword = 1;
-         suffix = ZMMWORD_MNEM_SUFFIX;
          break;
 
        case O_far_ptr:
@@ -864,7 +880,7 @@ i386_intel_operand (char *operand_string, int got_a_float)
                      i.mem_operands = 0;
                      i.disp_operands = 0;
                      i.imm_operands = 2;
-                     i.types[0].bitfield.mem = 0;
+                     i.flags[0] &= ~Operand_Mem;
                      i.types[0].bitfield.disp16 = 0;
                      i.types[0].bitfield.disp32 = 0;
                      i.types[0].bitfield.disp32s = 0;
@@ -883,8 +899,8 @@ i386_intel_operand (char *operand_string, int got_a_float)
         mode we have to do this here.  */
       if (intel_state.base
          && intel_state.index
-         && intel_state.base->reg_type.bitfield.reg16
-         && intel_state.index->reg_type.bitfield.reg16
+         && intel_state.base->reg_type.bitfield.word
+         && intel_state.index->reg_type.bitfield.word
          && intel_state.base->reg_num >= 6
          && intel_state.index->reg_num < 6)
        {
@@ -954,7 +970,15 @@ i386_intel_operand (char *operand_string, int got_a_float)
 
       if (intel_state.seg)
        {
-         expP = symbol_get_value_expression (intel_state.seg);
+         for (ret = check_none; ; ret = operand_check)
+           {
+             expP = symbol_get_value_expression (intel_state.seg);
+             if (expP->X_op != O_full_ptr 
+                 || symbol_get_value_expression (expP->X_op_symbol)->X_op
+                    != O_register)
+               break;
+             intel_state.seg = expP->X_add_symbol;
+           }
          if (expP->X_op != O_register)
            {
              as_bad (_("segment register name expected"));
@@ -966,6 +990,15 @@ i386_intel_operand (char *operand_string, int got_a_float)
              as_bad (_("invalid use of register"));
              return 0;
            }
+         switch (ret)
+           {
+           case check_error:
+             as_bad (_("redundant segment overrides"));
+             return 0;
+           case check_warning:
+             as_warn (_("redundant segment overrides"));
+             break;
+           }
          switch (i386_regtab[expP->X_add_number].reg_num)
            {
            case 0: i.seg[i.mem_operands] = &es; break;
@@ -981,7 +1014,7 @@ i386_intel_operand (char *operand_string, int got_a_float)
       if (!i386_index_check (operand_string))
        return 0;
 
-      i.types[this_operand].bitfield.mem = 1;
+      i.flags[this_operand] |= Operand_Mem;
       if (i.mem_operands == 0)
        i.memop1_string = xstrdup (operand_string);
       ++i.mem_operands;
This page took 0.025664 seconds and 4 git commands to generate.