]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gas/config/tc-i386.c
Enable support to Intel Keylocker instructions
[thirdparty/binutils-gdb.git] / gas / config / tc-i386.c
index 7c21df8d9ace9110f46373cf2fce990c21b37f2a..60b2fea3265b5d5eb8e0ae7febf9010efcd2d9d3 100644 (file)
@@ -1232,6 +1232,10 @@ static const arch_entry cpu_arch[] =
     CPU_SEV_ES_FLAGS, 0 },
   { STRING_COMMA_LEN (".tsxldtrk"), PROCESSOR_UNKNOWN,
     CPU_TSXLDTRK_FLAGS, 0 },
+  { STRING_COMMA_LEN (".kl"), PROCESSOR_UNKNOWN,
+    CPU_KL_FLAGS, 0 },
+  { STRING_COMMA_LEN (".widekl"), PROCESSOR_UNKNOWN,
+    CPU_WIDEKL_FLAGS, 0 },
 };
 
 static const noarch_entry cpu_noarch[] =
@@ -1281,6 +1285,8 @@ static const noarch_entry cpu_noarch[] =
   { STRING_COMMA_LEN ("noenqcmd"), CPU_ANY_ENQCMD_FLAGS },
   { STRING_COMMA_LEN ("noserialize"), CPU_ANY_SERIALIZE_FLAGS },
   { STRING_COMMA_LEN ("notsxldtrk"), CPU_ANY_TSXLDTRK_FLAGS },
+  { STRING_COMMA_LEN ("nokl"), CPU_ANY_KL_FLAGS },
+  { STRING_COMMA_LEN ("nowidekl"), CPU_ANY_WIDEKL_FLAGS },
 };
 
 #ifdef I386COFF
@@ -1376,10 +1382,10 @@ const pseudo_typeS md_pseudo_table[] =
 extern char *input_line_pointer;
 
 /* Hash table for instruction mnemonic lookup.  */
-static struct hash_control *op_hash;
+static htab_t op_hash;
 
 /* Hash table for register lookup.  */
-static struct hash_control *reg_hash;
+static htab_t reg_hash;
 \f
   /* Various efficient no-op patterns for aligning code labels.
      Note: Don't try to assemble the instructions in the comments.
@@ -3026,13 +3032,11 @@ i386_mach (void)
 void
 md_begin (void)
 {
-  const char *hash_err;
-
   /* Support pseudo prefixes like {disp32}.  */
   lex_type ['{'] = LEX_BEGIN_NAME;
 
   /* Initialize op_hash hash table.  */
-  op_hash = hash_new ();
+  op_hash = str_htab_create ();
 
   {
     const insn_template *optab;
@@ -3052,15 +3056,9 @@ md_begin (void)
            /* different name --> ship out current template list;
               add to hash table; & begin anew.  */
            core_optab->end = optab;
-           hash_err = hash_insert (op_hash,
-                                   (optab - 1)->name,
-                                   (void *) core_optab);
-           if (hash_err)
-             {
-               as_fatal (_("can't hash %s: %s"),
-                         (optab - 1)->name,
-                         hash_err);
-             }
+           if (str_hash_insert (op_hash, (optab - 1)->name, core_optab, 0))
+             as_fatal (_("duplicate %s"), (optab - 1)->name);
+
            if (optab->name == NULL)
              break;
            core_optab = XNEW (templates);
@@ -3070,19 +3068,14 @@ md_begin (void)
   }
 
   /* Initialize reg_hash hash table.  */
-  reg_hash = hash_new ();
+  reg_hash = str_htab_create ();
   {
     const reg_entry *regtab;
     unsigned int regtab_size = i386_regtab_size;
 
     for (regtab = i386_regtab; regtab_size--; regtab++)
-      {
-       hash_err = hash_insert (reg_hash, regtab->reg_name, (void *) regtab);
-       if (hash_err)
-         as_fatal (_("can't hash %s: %s"),
-                   regtab->reg_name,
-                   hash_err);
-      }
+      if (str_hash_insert (reg_hash, regtab->reg_name, regtab, 0) != NULL)
+       as_fatal (_("duplicate %s"), regtab->reg_name);
   }
 
   /* Fill in lexical tables:  mnemonic_chars, operand_chars.  */
@@ -3173,8 +3166,8 @@ md_begin (void)
 void
 i386_print_statistics (FILE *file)
 {
-  hash_print_statistics (file, "i386 opcode", op_hash);
-  hash_print_statistics (file, "i386 register", reg_hash);
+  htab_print_statistics (file, "i386 opcode", op_hash);
+  htab_print_statistics (file, "i386 register", reg_hash);
 }
 \f
 #ifdef DEBUG386
@@ -5088,7 +5081,7 @@ parse_insn (char *line, char *mnemonic)
        }
 
       /* Look up instruction (or prefix) via hash table.  */
-      current_templates = (const templates *) hash_find (op_hash, mnemonic);
+      current_templates = (const templates *) str_hash_find (op_hash, mnemonic);
 
       if (*l != END_OF_INSN
          && (!is_space_char (*l) || l[1] != END_OF_INSN)
@@ -5214,7 +5207,7 @@ parse_insn (char *line, char *mnemonic)
        goto check_suffix;
       mnem_p = dot_p;
       *dot_p = '\0';
-      current_templates = (const templates *) hash_find (op_hash, mnemonic);
+      current_templates = (const templates *) str_hash_find (op_hash, mnemonic);
     }
 
   if (!current_templates)
@@ -5234,8 +5227,8 @@ parse_insn (char *line, char *mnemonic)
              case QWORD_MNEM_SUFFIX:
                i.suffix = mnem_p[-1];
              mnem_p[-1] = '\0';
-             current_templates = (const templates *) hash_find (op_hash,
-                                                                mnemonic);
+             current_templates
+               = (const templates *) str_hash_find (op_hash, mnemonic);
              break;
            case SHORT_MNEM_SUFFIX:
            case LONG_MNEM_SUFFIX:
@@ -5243,8 +5236,8 @@ parse_insn (char *line, char *mnemonic)
                {
                  i.suffix = mnem_p[-1];
                  mnem_p[-1] = '\0';
-                 current_templates = (const templates *) hash_find (op_hash,
-                                                                    mnemonic);
+                 current_templates
+                   = (const templates *) str_hash_find (op_hash, mnemonic);
                }
              break;
 
@@ -5257,8 +5250,8 @@ parse_insn (char *line, char *mnemonic)
                  else
                    i.suffix = LONG_MNEM_SUFFIX;
                  mnem_p[-1] = '\0';
-                 current_templates = (const templates *) hash_find (op_hash,
-                                                                    mnemonic);
+                 current_templates
+                   = (const templates *) str_hash_find (op_hash, mnemonic);
                }
              break;
            }
@@ -7564,7 +7557,7 @@ process_operands (void)
              i.flags[j] = i.flags[j - 1];
            }
          i.op[0].regs
-           = (const reg_entry *) hash_find (reg_hash, "xmm0");
+           = (const reg_entry *) str_hash_find (reg_hash, "xmm0");
          i.types[0] = regxmm;
          i.tm.operand_types[0] = regxmm;
 
@@ -9212,7 +9205,9 @@ output_insn (void)
          || i.tm.base_opcode == 0xf77 /* emms */
          || i.tm.base_opcode == 0xf0e /* femms */)
        x86_feature_2_used |= GNU_PROPERTY_X86_FEATURE_2_MMX;
-      if ((i.xstate & xstate_xmm))
+      if ((i.xstate & xstate_xmm)
+         || i.tm.cpu_flags.bitfield.cpuwidekl
+         || i.tm.cpu_flags.bitfield.cpukl)
        x86_feature_2_used |= GNU_PROPERTY_X86_FEATURE_2_XMM;
       if ((i.xstate & xstate_ymm) == xstate_ymm)
        x86_feature_2_used |= GNU_PROPERTY_X86_FEATURE_2_YMM;
@@ -10984,10 +10979,13 @@ i386_index_check (const char *operand_string)
                  && current_templates->end[-1].operand_types[1]
                     .bitfield.baseindex))
            op = 1;
-         expected_reg = hash_find (reg_hash, di_si[addr_mode][op == es_op]);
+         expected_reg
+           = (const reg_entry *) str_hash_find (reg_hash,
+                                                di_si[addr_mode][op == es_op]);
        }
       else
-       expected_reg = hash_find (reg_hash, bx[addr_mode]);
+       expected_reg
+         = (const reg_entry *)str_hash_find (reg_hash, bx[addr_mode]);
 
       if (i.base_reg != expected_reg
          || i.index_reg
@@ -12638,7 +12636,7 @@ parse_real_register (char *reg_string, char **end_op)
 
   *end_op = s;
 
-  r = (const reg_entry *) hash_find (reg_hash, reg_name_given);
+  r = (const reg_entry *) str_hash_find (reg_hash, reg_name_given);
 
   /* Handle floating point regs, allowing spaces in the (i) part.  */
   if (r == i386_regtab /* %st is first entry of table  */)
@@ -12665,7 +12663,7 @@ parse_real_register (char *reg_string, char **end_op)
              if (*s == ')')
                {
                  *end_op = s + 1;
-                 r = (const reg_entry *) hash_find (reg_hash, "st(0)");
+                 r = (const reg_entry *) str_hash_find (reg_hash, "st(0)");
                  know (r);
                  return r + fpr;
                }
@@ -13814,7 +13812,7 @@ md_undefined_symbol (char *name)
          if (symbol_find (name))
            as_bad (_("GOT already in symbol table"));
          GOT_symbol = symbol_new (name, undefined_section,
-                                  (valueT) 0, &zero_address_frag);
+                                  &zero_address_frag, 0);
        };
       return GOT_symbol;
     }