x86: improve handling of insns with ambiguous operand sizes
[deliverable/binutils-gdb.git] / gas / config / tc-i386.c
index 87ab43bbce017ed338a388b3e6e8ca7331d0dfa4..0b7542f99dc0ad87811fbeeb29149e3d58c7f047 100644 (file)
@@ -6395,9 +6395,7 @@ process_suffix (void)
   else if (i.tm.opcode_modifier.defaultsize
           && !i.suffix
           /* exclude fldenv/frstor/fsave/fstenv */
-          && i.tm.opcode_modifier.no_ssuf
-          /* exclude sysret */
-          && i.tm.base_opcode != 0x0f07)
+          && i.tm.opcode_modifier.no_ssuf)
     {
       i.suffix = stackop_size;
       if (stackop_size == LONG_MNEM_SUFFIX)
@@ -6418,8 +6416,7 @@ process_suffix (void)
                     i.tm.name);
        }
     }
-  else if (intel_syntax
-          && !i.suffix
+  else if (!i.suffix
           && (i.tm.opcode_modifier.jump == JUMP_ABSOLUTE
               || i.tm.opcode_modifier.jump == JUMP_BYTE
               || i.tm.opcode_modifier.jump == JUMP_INTERSEGMENT
@@ -6446,42 +6443,49 @@ process_suffix (void)
        }
     }
 
-  if (!i.suffix)
+  if (!i.suffix
+      && !i.tm.opcode_modifier.defaultsize
+      && !i.tm.opcode_modifier.ignoresize)
     {
-      if (!intel_syntax)
+      unsigned int suffixes;
+
+      suffixes = !i.tm.opcode_modifier.no_bsuf;
+      if (!i.tm.opcode_modifier.no_wsuf)
+       suffixes |= 1 << 1;
+      if (!i.tm.opcode_modifier.no_lsuf)
+       suffixes |= 1 << 2;
+      if (!i.tm.opcode_modifier.no_ldsuf)
+       suffixes |= 1 << 3;
+      if (!i.tm.opcode_modifier.no_ssuf)
+       suffixes |= 1 << 4;
+      if (flag_code == CODE_64BIT && !i.tm.opcode_modifier.no_qsuf)
+       suffixes |= 1 << 5;
+
+      /* Are multiple suffixes allowed?  */
+      if (suffixes & (suffixes - 1))
        {
-         if (i.tm.opcode_modifier.w)
+         if (intel_syntax)
            {
-             as_bad (_("no instruction mnemonic suffix given and "
-                       "no register operands; can't size instruction"));
+             as_bad (_("ambiguous operand size for `%s'"), i.tm.name);
              return 0;
            }
-       }
-      else
-       {
-         unsigned int suffixes;
-
-         suffixes = !i.tm.opcode_modifier.no_bsuf;
-         if (!i.tm.opcode_modifier.no_wsuf)
-           suffixes |= 1 << 1;
-         if (!i.tm.opcode_modifier.no_lsuf)
-           suffixes |= 1 << 2;
-         if (!i.tm.opcode_modifier.no_ldsuf)
-           suffixes |= 1 << 3;
-         if (!i.tm.opcode_modifier.no_ssuf)
-           suffixes |= 1 << 4;
-         if (flag_code == CODE_64BIT && !i.tm.opcode_modifier.no_qsuf)
-           suffixes |= 1 << 5;
-
-         /* There are more than suffix matches.  */
-         if (i.tm.opcode_modifier.w
-             || ((suffixes & (suffixes - 1))
-                 && !i.tm.opcode_modifier.defaultsize
-                 && !i.tm.opcode_modifier.ignoresize))
+         if (operand_check == check_error)
            {
-             as_bad (_("ambiguous operand size for `%s'"), i.tm.name);
+             as_bad (_("no instruction mnemonic suffix given and "
+                       "no register operands; can't size `%s'"), i.tm.name);
              return 0;
            }
+         if (operand_check == check_warning)
+           as_warn (_("no instruction mnemonic suffix given and "
+                      "no register operands; using default for `%s'"),
+                    i.tm.name);
+
+         if (i.tm.opcode_modifier.floatmf)
+           i.suffix = SHORT_MNEM_SUFFIX;
+         else if (flag_code == CODE_16BIT)
+           i.suffix = WORD_MNEM_SUFFIX;
+         else
+           i.suffix = LONG_MNEM_SUFFIX;
        }
     }
 
This page took 0.028139 seconds and 4 git commands to generate.