[PATCH 04/13] [APX EGPR] Add 16 new integer general purpose registers
From: Kong Lingling Extend GENERAL_REGS with extra r16-r31 registers like REX registers, named as REX2 registers. They will only be enabled under TARGET_APX_EGPR. gcc/ChangeLog: * config/i386/i386-protos.h (x86_extended_rex2reg_mentioned_p): New function prototype. * config/i386/i386.cc (regclass_map): Add mapping for 16 new general registers. (debugger64_register_map): Likewise. (ix86_conditional_register_usage): Clear REX2 register when APX disabled. (ix86_code_end): Add handling for REX2 reg. (print_reg): Likewise. (ix86_output_jmp_thunk_or_indirect): Likewise. (ix86_output_indirect_branch_via_reg): Likewise. (ix86_attr_length_vex_default): Likewise. (ix86_emit_save_regs): Adjust to allow saving r31. (ix86_register_priority): Set REX2 reg priority same as REX. (x86_extended_reg_mentioned_p): Add check for REX2 regs. (x86_extended_rex2reg_mentioned_p): New function. * config/i386/i386.h (CALL_USED_REGISTERS): Add new extended registers. (REG_ALLOC_ORDER): Likewise. (FIRST_REX2_INT_REG): Define. (LAST_REX2_INT_REG): Ditto. (GENERAL_REGS): Add 16 new registers. (INT_SSE_REGS): Likewise. (FLOAT_INT_REGS): Likewise. (FLOAT_INT_SSE_REGS): Likewise. (INT_MASK_REGS): Likewise. (ALL_REGS):Likewise. (REX2_INT_REG_P): Define. (REX2_INT_REGNO_P): Ditto. (GENERAL_REGNO_P): Add REX2_INT_REGNO_P. (REGNO_OK_FOR_INDEX_P): Ditto. (REG_OK_FOR_INDEX_NONSTRICT_P): Add new extended registers. * config/i386/i386.md: Add 16 new integer general registers. gcc/testsuite/ChangeLog: * gcc.target/i386/apx-egprs-names.c: New test. * gcc.target/i386/apx-spill_to_egprs-1.c: Likewise. * gcc.target/i386/apx-interrupt-1.c: Likewise. Co-authored-by: Hongyu Wang Co-authored-by: Hongtao Liu --- gcc/config/i386/i386-protos.h | 1 + gcc/config/i386/i386.cc | 67 ++-- gcc/config/i386/i386.h| 46 +--- gcc/config/i386/i386.md | 18 +++- .../gcc.target/i386/apx-egprs-names.c | 17 +++ .../gcc.target/i386/apx-interrupt-1.c | 102 ++ .../gcc.target/i386/apx-spill_to_egprs-1.c| 25 + 7 files changed, 252 insertions(+), 24 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/apx-egprs-names.c create mode 100644 gcc/testsuite/gcc.target/i386/apx-interrupt-1.c create mode 100644 gcc/testsuite/gcc.target/i386/apx-spill_to_egprs-1.c diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h index 9ffb125fc2b..bd4782800c4 100644 --- a/gcc/config/i386/i386-protos.h +++ b/gcc/config/i386/i386-protos.h @@ -64,6 +64,7 @@ extern bool symbolic_reference_mentioned_p (rtx); extern bool extended_reg_mentioned_p (rtx); extern bool x86_extended_QIreg_mentioned_p (rtx_insn *); extern bool x86_extended_reg_mentioned_p (rtx); +extern bool x86_extended_rex2reg_mentioned_p (rtx); extern bool x86_maybe_negate_const_int (rtx *, machine_mode); extern machine_mode ix86_cc_mode (enum rtx_code, rtx, rtx); diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index 477e6cecc38..fb1672f0b3d 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -169,7 +169,12 @@ enum reg_class const regclass_map[FIRST_PSEUDO_REGISTER] = ALL_SSE_REGS, ALL_SSE_REGS, ALL_SSE_REGS, ALL_SSE_REGS, /* Mask registers. */ ALL_MASK_REGS, MASK_REGS, MASK_REGS, MASK_REGS, - MASK_REGS, MASK_REGS, MASK_REGS, MASK_REGS + MASK_REGS, MASK_REGS, MASK_REGS, MASK_REGS, + /* REX2 registers */ + GENERAL_REGS, GENERAL_REGS, GENERAL_REGS, GENERAL_REGS, + GENERAL_REGS, GENERAL_REGS, GENERAL_REGS, GENERAL_REGS, + GENERAL_REGS, GENERAL_REGS, GENERAL_REGS, GENERAL_REGS, + GENERAL_REGS, GENERAL_REGS, GENERAL_REGS, GENERAL_REGS, }; /* The "default" register map used in 32bit mode. */ @@ -227,7 +232,10 @@ int const debugger64_register_map[FIRST_PSEUDO_REGISTER] = /* AVX-512 registers 24-31 */ 75, 76, 77, 78, 79, 80, 81, 82, /* Mask registers */ - 118, 119, 120, 121, 122, 123, 124, 125 + 118, 119, 120, 121, 122, 123, 124, 125, + /* rex2 extend interger registers */ + 130, 131, 132, 133, 134, 135, 136, 137, + 138, 139, 140, 141, 142, 143, 144, 145 }; /* Define the register numbers to be used in Dwarf debugging information. @@ -521,6 +529,13 @@ ix86_conditional_register_usage (void) accessible_reg_set &= ~reg_class_contents[ALL_MASK_REGS]; } + + /* If APX is disabled, disable the registers. */ + if (! (TARGET_APX_EGPR && TARGET_64BIT)) +{ + for (i = FIRST_REX2_INT_REG; i <= LAST_REX2_INT_REG; i++) + CLEAR_HARD_REG_BIT (accessible_reg_set, i); +} } /* Canonicalize a comparison from one we don't have to one we do have. */ @@ -6188,6 +6203,13 @@ ix86_co
[PATCH 04/13] [APX EGPR] Add 16 new integer general purpose registers
From: Kong Lingling Extend GENERAL_REGS with extra r16-r31 registers like REX registers, named as REX2 registers. They will only be enabled under TARGET_APX_EGPR. gcc/ChangeLog: * config/i386/i386-protos.h (x86_extended_rex2reg_mentioned_p): New function prototype. * config/i386/i386.cc (regclass_map): Add mapping for 16 new general registers. (debugger64_register_map): Likewise. (ix86_conditional_register_usage): Clear REX2 register when APX disabled. (ix86_code_end): Add handling for REX2 reg. (print_reg): Likewise. (ix86_output_jmp_thunk_or_indirect): Likewise. (ix86_output_indirect_branch_via_reg): Likewise. (ix86_attr_length_vex_default): Likewise. (ix86_emit_save_regs): Adjust to allow saving r31. (ix86_register_priority): Set REX2 reg priority same as REX. (x86_extended_reg_mentioned_p): Add check for REX2 regs. (x86_extended_rex2reg_mentioned_p): New function. * config/i386/i386.h (CALL_USED_REGISTERS): Add new extended registers. (REG_ALLOC_ORDER): Likewise. (FIRST_REX2_INT_REG): Define. (LAST_REX2_INT_REG): Ditto. (GENERAL_REGS): Add 16 new registers. (INT_SSE_REGS): Likewise. (FLOAT_INT_REGS): Likewise. (FLOAT_INT_SSE_REGS): Likewise. (INT_MASK_REGS): Likewise. (ALL_REGS):Likewise. (REX2_INT_REG_P): Define. (REX2_INT_REGNO_P): Ditto. (GENERAL_REGNO_P): Add REX2_INT_REGNO_P. (REGNO_OK_FOR_INDEX_P): Ditto. (REG_OK_FOR_INDEX_NONSTRICT_P): Add new extended registers. * config/i386/i386.md: Add 16 new integer general registers. gcc/testsuite/ChangeLog: * gcc.target/i386/apx-egprs-names.c: New test. * gcc.target/i386/apx-spill_to_egprs-1.c: Likewise. * gcc.target/i386/apx-interrupt-1.c: Likewise. --- gcc/config/i386/i386-protos.h | 1 + gcc/config/i386/i386.cc | 67 ++-- gcc/config/i386/i386.h| 47 +--- gcc/config/i386/i386.md | 18 +++- .../gcc.target/i386/apx-egprs-names.c | 17 +++ .../gcc.target/i386/apx-interrupt-1.c | 102 ++ .../gcc.target/i386/apx-spill_to_egprs-1.c| 25 + 7 files changed, 253 insertions(+), 24 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/apx-egprs-names.c create mode 100644 gcc/testsuite/gcc.target/i386/apx-interrupt-1.c create mode 100644 gcc/testsuite/gcc.target/i386/apx-spill_to_egprs-1.c diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h index 9ffb125fc2b..bd4782800c4 100644 --- a/gcc/config/i386/i386-protos.h +++ b/gcc/config/i386/i386-protos.h @@ -64,6 +64,7 @@ extern bool symbolic_reference_mentioned_p (rtx); extern bool extended_reg_mentioned_p (rtx); extern bool x86_extended_QIreg_mentioned_p (rtx_insn *); extern bool x86_extended_reg_mentioned_p (rtx); +extern bool x86_extended_rex2reg_mentioned_p (rtx); extern bool x86_maybe_negate_const_int (rtx *, machine_mode); extern machine_mode ix86_cc_mode (enum rtx_code, rtx, rtx); diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index 1bc3f11ff07..d26d9ab0d9d 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -169,7 +169,12 @@ enum reg_class const regclass_map[FIRST_PSEUDO_REGISTER] = ALL_SSE_REGS, ALL_SSE_REGS, ALL_SSE_REGS, ALL_SSE_REGS, /* Mask registers. */ ALL_MASK_REGS, MASK_REGS, MASK_REGS, MASK_REGS, - MASK_REGS, MASK_REGS, MASK_REGS, MASK_REGS + MASK_REGS, MASK_REGS, MASK_REGS, MASK_REGS, + /* REX2 registers */ + GENERAL_REGS, GENERAL_REGS, GENERAL_REGS, GENERAL_REGS, + GENERAL_REGS, GENERAL_REGS, GENERAL_REGS, GENERAL_REGS, + GENERAL_REGS, GENERAL_REGS, GENERAL_REGS, GENERAL_REGS, + GENERAL_REGS, GENERAL_REGS, GENERAL_REGS, GENERAL_REGS, }; /* The "default" register map used in 32bit mode. */ @@ -227,7 +232,10 @@ int const debugger64_register_map[FIRST_PSEUDO_REGISTER] = /* AVX-512 registers 24-31 */ 75, 76, 77, 78, 79, 80, 81, 82, /* Mask registers */ - 118, 119, 120, 121, 122, 123, 124, 125 + 118, 119, 120, 121, 122, 123, 124, 125, + /* rex2 extend interger registers */ + 130, 131, 132, 133, 134, 135, 136, 137, + 138, 139, 140, 141, 142, 143, 144, 145 }; /* Define the register numbers to be used in Dwarf debugging information. @@ -521,6 +529,13 @@ ix86_conditional_register_usage (void) accessible_reg_set &= ~reg_class_contents[ALL_MASK_REGS]; } + + /* If APX is disabled, disable the registers. */ + if (! (TARGET_APX_EGPR && TARGET_64BIT)) +{ + for (i = FIRST_REX2_INT_REG; i <= LAST_REX2_INT_REG; i++) + CLEAR_HARD_REG_BIT (accessible_reg_set, i); +} } /* Canonicalize a comparison from one we don't have to one we do have. */ @@ -6179,6 +6194,13 @@ ix86_code_end (void) regno