Support APX GPR32 with rex2 prefix
authorCui, Lili <lili.cui@intel.com>
Thu, 28 Dec 2023 01:06:39 +0000 (01:06 +0000)
committerCui, Lili <lili.cui@intel.com>
Thu, 28 Dec 2023 11:14:41 +0000 (11:14 +0000)
commit80d61d8d614d68a0b1932ed3a86d4cda01e5633e
treed96a3481c4563e2fd0fee9ae049626ee9dea6053
parentfcd5cdd5aeecf7eae91a402755c260bb64a0fe0f
Support APX GPR32 with rex2 prefix

APX uses the REX2 prefix to support EGPR for map0 and map1 of legacy
instructions. We added the NoEgpr flag in i386-gen.c for instructions
that do not support EGPR.

gas/ChangeLog:

2023-12-28  Lingling Kong <lingling.kong@intel.com>
    H.J. Lu  <hongjiu.lu@intel.com>
    Lili Cui <lili.cui@intel.com>
    Lin Hu   <lin1.hu@intel.com>

* config/tc-i386.c
(enum i386_error): Add unsupported_EGPR_for_addressing
and invalid_pseudo_prefix.
(struct _i386_insn): Add rex2 and rex2_encoding for
gpr32.
(cpu_arch): Add apx_f.
(is_cpu): Ditto.
(register_number): Handle RegRex2 for gpr32.
(is_apx_rex2_encoding): New func. Test rex2 prefix encoding.
(build_rex2_prefix): New func. Build legacy insn in
opcode 0/1 use gpr32 with rex2 prefix.
(establish_rex): Handle rex2 and rex2_encoding.
(optimize_encoding): Handel add r16-r31 for registers.
(md_assemble): Handle apx encoding.
(parse_insn): Handle Prefix_REX2.
(check_EgprOperands): New func. Check if Egprs operands
are valid for the instruction
(match_template):  Handle Egpr operands check.
(set_rex_rex2):  New func. set i.rex and i.rex2.
(build_modrm_byte): Ditto.
(output_insn): Handle rex2 2-byte prefix output.
(check_register): Handle check egpr illegal without
target apx, 64-bit mode and with rex_prefix.
* doc/c-i386.texi: Document .apx.
* testsuite/gas/i386/ilp32/x86-64-opcode-inval-intel.d: D5 valid
in 64-bit mode.
* testsuite/gas/i386/ilp32/x86-64-opcode-inval.d: Ditto.
* testsuite/gas/i386/rex-bad: Adjust rex testcase.
* testsuite/gas/i386/x86-64-opcode-inval-intel.d: Ditto.
* testsuite/gas/i386/x86-64-opcode-inval.d: Ditto.
* testsuite/gas/i386/x86-64-opcode-inval.s: Ditto.
* testsuite/gas/i386/x86-64-pseudos-bad.l: Add illegal rex2 test.
* testsuite/gas/i386/x86-64-pseudos-bad.s: Ditto.
* testsuite/gas/i386/x86-64-pseudos.d: Add rex2 test.
* testsuite/gas/i386/x86-64-pseudos.s: Ditto.
* testsuite/gas/i386/x86-64.exp: Run APX tests.
* testsuite/gas/i386/x86-64-apx-egpr-inval.l: New test.
* testsuite/gas/i386/x86-64-apx-egpr-inval.s: New test.
* testsuite/gas/i386/x86-64-apx-rex2.d: New test.
* testsuite/gas/i386/x86-64-apx-rex2.s: New test.

include/ChangeLog:

* opcode/i386.h (REX2_OPCODE): New.
(REX2_M): Ditto.

opcodes/ChangeLog:

* i386-dis.c (struct instr_info): Add erex for gpr32.
Add last_erex_prefix for rex2 prefix.
(REX2_M): Extend for gpr32.
(PREFIX_REX2): Ditto.
(PREFIX_REX2_ILLEGAL): Ditto.
(ckprefix): Ditto.
(prefix_name): Ditto.
(print_insn): Ditto.
(print_register): Ditto.
(OP_E_memory): Ditto.
(OP_REG): Ditto.
(OP_EX): Ditto.
* i386-gen.c (rex2_disallowed): Some instructions are not allowed rex2 prefix.
(process_i386_opcode_modifier): Set NoEgpr for VEX and some special instructions.
(output_i386_opcode): Handle if_entry_needs_special_handle.
* i386-init.h : Regenerated.
* i386-mnem.h : Regenerated.
* i386-opc.h (enum i386_cpu): Add CpuAPX_F.
(NoEgpr): New.
(Prefix_NoOptimize): Ditto.
(Prefix_REX2): Ditto.
(RegRex2): Ditto.
* i386-opc.tbl: Add rex2 prefix.
* i386-reg.tbl: Add egprs (r16-r31).
* i386-tbl.h: Regenerated.
26 files changed:
gas/config/tc-i386.c
gas/doc/c-i386.texi
gas/testsuite/gas/i386/ilp32/x86-64-opcode-inval-intel.d
gas/testsuite/gas/i386/ilp32/x86-64-opcode-inval.d
gas/testsuite/gas/i386/rex-bad.l
gas/testsuite/gas/i386/x86-64-apx-egpr-inval.l [new file with mode: 0644]
gas/testsuite/gas/i386/x86-64-apx-egpr-inval.s [new file with mode: 0644]
gas/testsuite/gas/i386/x86-64-apx-rex2.d [new file with mode: 0644]
gas/testsuite/gas/i386/x86-64-apx-rex2.s [new file with mode: 0644]
gas/testsuite/gas/i386/x86-64-opcode-inval-intel.d
gas/testsuite/gas/i386/x86-64-opcode-inval.d
gas/testsuite/gas/i386/x86-64-opcode-inval.s
gas/testsuite/gas/i386/x86-64-pseudos-bad.l
gas/testsuite/gas/i386/x86-64-pseudos-bad.s
gas/testsuite/gas/i386/x86-64-pseudos.d
gas/testsuite/gas/i386/x86-64-pseudos.s
gas/testsuite/gas/i386/x86-64.exp
include/opcode/i386.h
opcodes/i386-dis.c
opcodes/i386-gen.c
opcodes/i386-init.h
opcodes/i386-mnem.h
opcodes/i386-opc.h
opcodes/i386-opc.tbl
opcodes/i386-reg.tbl
opcodes/i386-tbl.h