1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * x86 instruction attribute tables
5 * Written by Masami Hiramatsu <mhiramat@redhat.com>
7 #include <asm/insn.h> /* __ignore_sync_check__ */
9 /* Attribute tables are generated from opcode map */
10 #include "inat-tables.c"
12 /* Attribute search APIs */
13 insn_attr_t
inat_get_opcode_attribute(insn_byte_t opcode
)
15 return inat_primary_table
[opcode
];
18 int inat_get_last_prefix_id(insn_byte_t last_pfx
)
20 insn_attr_t lpfx_attr
;
22 lpfx_attr
= inat_get_opcode_attribute(last_pfx
);
23 return inat_last_prefix_id(lpfx_attr
);
26 insn_attr_t
inat_get_escape_attribute(insn_byte_t opcode
, int lpfx_id
,
29 const insn_attr_t
*table
;
32 n
= inat_escape_id(esc_attr
);
34 table
= inat_escape_tables
[n
][0];
37 if (inat_has_variant(table
[opcode
]) && lpfx_id
) {
38 table
= inat_escape_tables
[n
][lpfx_id
];
45 insn_attr_t
inat_get_group_attribute(insn_byte_t modrm
, int lpfx_id
,
48 const insn_attr_t
*table
;
51 n
= inat_group_id(grp_attr
);
53 table
= inat_group_tables
[n
][0];
55 return inat_group_common_attribute(grp_attr
);
56 if (inat_has_variant(table
[X86_MODRM_REG(modrm
)]) && lpfx_id
) {
57 table
= inat_group_tables
[n
][lpfx_id
];
59 return inat_group_common_attribute(grp_attr
);
61 return table
[X86_MODRM_REG(modrm
)] |
62 inat_group_common_attribute(grp_attr
);
65 insn_attr_t
inat_get_avx_attribute(insn_byte_t opcode
, insn_byte_t vex_m
,
68 const insn_attr_t
*table
;
69 if (vex_m
> X86_VEX_M_MAX
|| vex_p
> INAT_LSTPFX_MAX
)
71 /* At first, this checks the master table */
72 table
= inat_avx_tables
[vex_m
][0];
75 if (!inat_is_group(table
[opcode
]) && vex_p
) {
76 /* If this is not a group, get attribute directly */
77 table
= inat_avx_tables
[vex_m
][vex_p
];