[0/8] x86: work towards further opcode table compaction

Message ID d7901bea-c894-eba3-6003-201142782000@suse.com
Headers show
Series
  • x86: work towards further opcode table compaction
Related show

Message

H.J. Lu via Binutils March 22, 2021, 4:40 p.m.
This is partial work for now only, because I'm not sure how controversial
some of the later the changes might be, and hence I wouldn't want to
continue down this road without at least rough consensus. The bugs fixed
by the first patch were noticed simply in the course of doing this rework.

1: unbreak certain MPX insn operand forms
2: don't open-code PREFIX_NONE
3: don't use opcode_length to identify pseudo prefixes
4: split opcode prefix and opcode space representation
5: re-order two fields of struct insn_template
6: re-number PREFIX_0X<nn>
7: derive mandatory prefix attribute from base opcode
8: derive opcode length from opcode value

Jan

Comments

H.J. Lu via Binutils March 22, 2021, 6:02 p.m. | #1
On Mon, Mar 22, 2021 at 05:47:11PM +0100, Jan Beulich wrote:
> In the majority of cases we can easily determine the length from the

> encoding, irrespective of whether a prefix is specified there as well.

> We further don't even need to record the value in the table entries, as

> it's easy enough to determine it (without any guesswork, unless an insn

> with major opcode 00 appeared that requires a 2nd opcode byte to be

> specified explicitly) when installing the chosen template for further

> processing.

> 

> Should an encoding appear which

> - has a major opcode byte of 66, F3, or F2,

> - requires a 2nd opcode byte to be specified explicitly,

> - doesn't have a mandatory prefix

> we'd need to convert all templates presently encoding a mandatory prefix

> this way to the Prefix_0X<nn> model to eliminate the respective guessing

> i386-gen does.

> 

> gas/

> 2021-03-XX  Jan Beulich  <jbeulich@suse.com>

> 

> 	* config/tc-i386.c (struct _i386_insn): New field

> 	opcode_length.

> 	(md_begin): Drop assertion.

> 	(install_template): New.

> 	(build_vex_prefix): Call install_template.

> 	(match_template): Likewise.

> 	(process_operands): Use new opcode_length field.

> 	(output_jump): Likewise.

> 	(output_insn): Likewise. Adjust psedo prefix check.

> 

> opcodes/

> 2021-03-XX  Jan Beulich  <jbeulich@suse.com>

> 

> 	* i386-gen.c (output_i386_opcode): Drop processing of

> 	opcode_length. Calculate length from base_opcode. Adjust prefix

> 	encoding determination.

> 	(process_i386_opcodes): Drop output of fake opcode_length.

> 	* i386-opc.h (struct insn_template): Drop opcode_length field.

> 	* i386-opc.tbl: Drop opcode length field from all templates.

> 	* i386-tbl.h: Re-generate.

> 


OK.  Thanks.

H.J.
H.J. Lu via Binutils March 22, 2021, 6:04 p.m. | #2
On Mon, Mar 22, 2021 at 05:44:19PM +0100, Jan Beulich wrote:
> Commit 8b65b8953af2 ("x86: Remove the prefix byte from non-VEX/EVEX

> base_opcode") used the opcodeprefix field for two distinct purposes. In

> preparation of having VEX/XOP/EVEX and non-VEX templates become similar

> in the representatioon of both encoding space and opcode prefixes, split

> the field to have a separate one holding an insn's opcode space.

> 

> gas/

> 2021-03-XX  Jan Beulich  <jbeulich@suse.com>

> 

> 	* config/tc-i386.c (pte): Print prefix and encoding space.

> 	(build_vex_prefix): Check opcodespace instead of opcodeprefix.

> 	(build_evex_prefix): Likewise.

> 	(load_insn_p): Likewise.

> 

> opcodes/

> 2021-03-XX  Jan Beulich  <jbeulich@suse.com>

> 

> 	* i386-gen.c (opcode_modifiers): New OpcodeSpace element.

> 	* i386-opc.h (OpcodeSpace): New enumerator.

> 	(VEX0F, VEX0F38, VEX0F3A, XOP08, XOP09, XOP0A): Rename to ...

> 	(SPACE_BASE, SPACE_0F, SPACE_0F38, SPACE_0F3A, SPACE_XOP08,

> 	SPACE_XOP09, SPACE_XOP0A): ... respectively.

> 	(struct i386_opcode_modifier): New field opcodespace. Shrink

> 	opcodeprefix field.

> 	i386-opc.tbl (Space0F, Space0F38, Space0F3A, SpaceXOP08,

> 	SpaceXOP09, SpaceXOP0A): Define. Use them to replace

> 	OpcodePrefix uses.

> 	* i386-tbl.h: Re-generate.

> 


OK.  Thanks.

H.J.