https://gcc.gnu.org/g:777bcd6059e031450bb0c068446d070954979895
commit 777bcd6059e031450bb0c068446d070954979895 Author: Michael Meissner <meiss...@linux.ibm.com> Date: Tue Jun 24 21:19:28 2025 -0400 Add -mcpu=future support. This is patch #1 of 3 that adds the support that can be used in developing GCC support for potential future PowerPC processors. With all 3 patches, the tuning for the 'future' processor is the same as power10 and power11. It may be in the future this tuning will change as any future PowerPC processor evolves. Patch #2 will change the tuning support in power10.md to treat -mtune=future the same as -mtune=power10. Patch #3 will add tests for -mcpu=future. These changes are being added so that hardware designers can evaluate potential new features to be added to the PowerPC processors in the future. It may be these features will be incorporated into real hardware using a different name in the future. Or it may be these features will not be incoporated into actual PowerPC hardware in the future. I have rewritten these patches to make it easier in the future to add new processors that scheduled like power10 and power11 systems, or remove the 'future' cpu from being scheduled like a power10 if we add new tuning characteristics for potential future processors. I added a new macro (CASE_PROCESSOR_POWER10_TUNING) that expands to a set of PROCESSOR_<xxx> cases for processors that should be tuned like a power10 processor. In this patch, power10, power11, and future are selected. I also added a new inline function (power10_tuning_p) that returns true if the processor is to be scheduled like a power10. I have modified the various ASM_CPU_SPEC macros to pass -mfuture to the assembler if -mcpu=future wa used. I have updated config.guess to allow the user to configure the GCC compiler using the --with-cpu=future option. I have tested these patches on both big endian and little endian PowerPC servers, with no regressions. Can I check these patchs into the trunk? 2025-06-24 Michael Meissner <meiss...@linux.ibm.com> gcc/ * config.guess (powerpc*-*-*): Add support for using --with-cpu=future. * config/rs6000/aix71.h (ASM_CPU_SPEC): Pass -mfuture to the assembler if -mcpu=future was used on the command line. * config/rs6000/aix72.h (ASM_CPU_SPEC): Likewise. * config/rs6000/aix73.h (ASM_CPU_SPEC): Likewise. * config/rs6000/driver-rs6000.c (asm_names): Likewise. * config/rs6000/rs6000-c.cc (rs6000_target_modify_macros): If -mcpu=future, define the macro _ARCH_FUTURE. * config/rs6000/rs6000-cpus.def (FUTURE_MASKS_SERVER): New macro. (POWERPC_MASKS): Add support for the internal -mfuture that is set by the -mcpu=future option. (future cpu): Add support for -mcpu=future. * config/rs6000/rs6000-opts.h (enum processor_type): Add PROCESSOR_FUTURE. (CASE_PROCESSOR_POWER10_TUNING): New macro. (power10_tuning_p): New inline helper function. * config/rs6000/rs6000-string.cc (expand_compare_loop): Convert PROCESSOR_POWER10 and PROCESSOR_POWER11 cases into CASE_PROCESSOR_POWER10_TUNING to allow -mcpu=future as well. * config/rs6000/rs6000-tables.opt: Regenerate the table, adding the future cpu to the enumeration. * config/rs6000/rs6000.cc (rs6000_option_override_internal): Change tests against PROCESSOR_POWER10 and PROCESSOR_POWER11 to include PROCESSOR_FUTURE as well. (rs6000_reassociation_width): Likewise. (rs6000_adjust_cost): Likewise. (rs6000_issue_rate): Likewise. (rs6000_sched_reorder): Likewise. (rs6000_sched_reorder2): Likewise. (rs6000_register_move_cost): Likewise. * config/rs6000/rs6000.md (cpu attribute): Add future cpu. * config/rs6000/rs6000.h (ASM_CPU_SPEC): Pass -mfuture to the assembler if -mcpu=future was used on the command line. * config/rs6000/rs6000.opt (-mfuture): New internal ISA bit for -mcpu=future. Diff: --- gcc/config.gcc | 4 ++-- gcc/config/rs6000/aix71.h | 1 + gcc/config/rs6000/aix72.h | 1 + gcc/config/rs6000/aix73.h | 1 + gcc/config/rs6000/driver-rs6000.cc | 2 ++ gcc/config/rs6000/rs6000-c.cc | 2 ++ gcc/config/rs6000/rs6000-cpus.def | 5 +++++ gcc/config/rs6000/rs6000-opts.h | 22 +++++++++++++++++++++ gcc/config/rs6000/rs6000-string.cc | 3 +-- gcc/config/rs6000/rs6000-tables.opt | 11 +++++++---- gcc/config/rs6000/rs6000.cc | 39 +++++++++++++------------------------ gcc/config/rs6000/rs6000.h | 1 + gcc/config/rs6000/rs6000.md | 2 +- gcc/config/rs6000/rs6000.opt | 6 ++++++ 14 files changed, 65 insertions(+), 35 deletions(-) diff --git a/gcc/config.gcc b/gcc/config.gcc index a6f6efec4e10..d9318f257e7f 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -533,7 +533,7 @@ powerpc*-*-*) extra_headers="${extra_headers} ppu_intrinsics.h spu2vmx.h vec_types.h si2vmx.h" extra_headers="${extra_headers} amo.h" case x$with_cpu in - xpowerpc64|xdefault64|x6[23]0|x970|xG5|xpower[3456789]|xpower1[01]|xpower6x|xrs64a|xcell|xa2|xe500mc64|xe5500|xe6500) + xpowerpc64|xdefault64|x6[23]0|x970|xG5|xpower[3456789]|xpower1[01]|xpower6x|xrs64a|xcell|xa2|xe500mc64|xe5500|xe6500|xfuture) cpu_is_64bit=yes ;; esac @@ -5694,7 +5694,7 @@ case "${target}" in tm_defines="${tm_defines} CONFIG_PPC405CR" eval "with_$which=405" ;; - "" | common | native \ + "" | common | native | future \ | power[3456789] | power1[01] | power5+ | power6x \ | powerpc | powerpc64 | powerpc64le \ | rs64 \ diff --git a/gcc/config/rs6000/aix71.h b/gcc/config/rs6000/aix71.h index 2b21dd7cd1e0..77651f5ea309 100644 --- a/gcc/config/rs6000/aix71.h +++ b/gcc/config/rs6000/aix71.h @@ -79,6 +79,7 @@ do { \ #undef ASM_CPU_SPEC #define ASM_CPU_SPEC \ "%{mcpu=native: %(asm_cpu_native); \ + mcpu=future: -mfuture; \ mcpu=power11: -mpwr11; \ mcpu=power10: -mpwr10; \ mcpu=power9: -mpwr9; \ diff --git a/gcc/config/rs6000/aix72.h b/gcc/config/rs6000/aix72.h index 53c0bde5ad4a..652f60c7f494 100644 --- a/gcc/config/rs6000/aix72.h +++ b/gcc/config/rs6000/aix72.h @@ -79,6 +79,7 @@ do { \ #undef ASM_CPU_SPEC #define ASM_CPU_SPEC \ "%{mcpu=native: %(asm_cpu_native); \ + mcpu=future: -mfuture; \ mcpu=power11: -mpwr11; \ mcpu=power10: -mpwr10; \ mcpu=power9: -mpwr9; \ diff --git a/gcc/config/rs6000/aix73.h b/gcc/config/rs6000/aix73.h index c7639368a264..3c66ac1d9171 100644 --- a/gcc/config/rs6000/aix73.h +++ b/gcc/config/rs6000/aix73.h @@ -79,6 +79,7 @@ do { \ #undef ASM_CPU_SPEC #define ASM_CPU_SPEC \ "%{mcpu=native: %(asm_cpu_native); \ + mcpu=future: -mfuture; \ mcpu=power11: -mpwr11; \ mcpu=power10: -mpwr10; \ mcpu=power9: -mpwr9; \ diff --git a/gcc/config/rs6000/driver-rs6000.cc b/gcc/config/rs6000/driver-rs6000.cc index 2ab675e6d042..d20332d76f1a 100644 --- a/gcc/config/rs6000/driver-rs6000.cc +++ b/gcc/config/rs6000/driver-rs6000.cc @@ -452,6 +452,7 @@ static const struct asm_name asm_names[] = { { "power9", "-mpwr9" }, { "power10", "-mpwr10" }, { "power11", "-mpwr11" }, + { "future", "-mfuture" }, { "powerpc", "-mppc" }, { "rs64", "-mppc" }, { "603", "-m603" }, @@ -481,6 +482,7 @@ static const struct asm_name asm_names[] = { { "power9", "-mpower9" }, { "power10", "-mpower10" }, { "power11", "-mpower11" }, + { "future", "-mfuture" }, { "a2", "-ma2" }, { "powerpc", "-mppc" }, { "powerpc64", "-mppc64" }, diff --git a/gcc/config/rs6000/rs6000-c.cc b/gcc/config/rs6000/rs6000-c.cc index d3b0a5668212..6757a2477ad1 100644 --- a/gcc/config/rs6000/rs6000-c.cc +++ b/gcc/config/rs6000/rs6000-c.cc @@ -437,6 +437,8 @@ rs6000_target_modify_macros (bool define_p, HOST_WIDE_INT flags) rs6000_define_or_undefine_macro (define_p, "_ARCH_PWR10"); if ((flags & OPTION_MASK_POWER11) != 0) rs6000_define_or_undefine_macro (define_p, "_ARCH_PWR11"); + if ((flags & OPTION_MASK_FUTURE) != 0) + rs6000_define_or_undefine_macro (define_p, "_ARCH_FUTURE"); if ((flags & OPTION_MASK_SOFT_FLOAT) != 0) rs6000_define_or_undefine_macro (define_p, "_SOFT_FLOAT"); if ((flags & OPTION_MASK_RECIP_PRECISION) != 0) diff --git a/gcc/config/rs6000/rs6000-cpus.def b/gcc/config/rs6000/rs6000-cpus.def index 4a1037616d7f..228d0b5e7b54 100644 --- a/gcc/config/rs6000/rs6000-cpus.def +++ b/gcc/config/rs6000/rs6000-cpus.def @@ -83,6 +83,9 @@ #define POWER11_MASKS_SERVER (ISA_3_1_MASKS_SERVER \ | OPTION_MASK_POWER11) +#define FUTURE_MASKS_SERVER (POWER11_MASKS_SERVER \ + | OPTION_MASK_FUTURE) + /* Flags that need to be turned off if -mno-vsx. */ #define OTHER_VSX_VECTOR_MASKS (OPTION_MASK_EFFICIENT_UNALIGNED_VSX \ | OPTION_MASK_FLOAT128_KEYWORD \ @@ -119,6 +122,7 @@ | OPTION_MASK_FLOAT128_HW \ | OPTION_MASK_FLOAT128_KEYWORD \ | OPTION_MASK_FPRND \ + | OPTION_MASK_FUTURE \ | OPTION_MASK_POWER10 \ | OPTION_MASK_POWER11 \ | OPTION_MASK_P10_FUSION \ @@ -249,6 +253,7 @@ RS6000_CPU ("power9", PROCESSOR_POWER9, MASK_POWERPC64 | ISA_3_0_MASKS_SERVER | OPTION_MASK_HTM) RS6000_CPU ("power10", PROCESSOR_POWER10, MASK_POWERPC64 | ISA_3_1_MASKS_SERVER) RS6000_CPU ("power11", PROCESSOR_POWER11, MASK_POWERPC64 | POWER11_MASKS_SERVER) +RS6000_CPU ("future", PROCESSOR_FUTURE, MASK_POWERPC64 | FUTURE_MASKS_SERVER) RS6000_CPU ("powerpc", PROCESSOR_POWERPC, 0) RS6000_CPU ("powerpc64", PROCESSOR_POWERPC64, OPTION_MASK_PPC_GFXOPT | MASK_POWERPC64) diff --git a/gcc/config/rs6000/rs6000-opts.h b/gcc/config/rs6000/rs6000-opts.h index c31d2975f046..0ec2016a4d20 100644 --- a/gcc/config/rs6000/rs6000-opts.h +++ b/gcc/config/rs6000/rs6000-opts.h @@ -63,6 +63,7 @@ enum processor_type PROCESSOR_POWER9, PROCESSOR_POWER10, PROCESSOR_POWER11, + PROCESSOR_FUTURE, PROCESSOR_RS64A, PROCESSOR_MPCCORE, @@ -72,6 +73,27 @@ enum processor_type }; +/* Processors that tune the same as a power10 in terms of tuning that will be + added to switch statements. */ +#define CASE_PROCESSOR_POWER10_TUNING \ + case PROCESSOR_POWER10: \ + case PROCESSOR_POWER11: \ + case PROCESSOR_FUTURE + +/* Return true if the processor uses the same tuning as power10. */ +static inline bool +power10_tuning_p (enum processor_type processor) +{ + switch (processor) + { + CASE_PROCESSOR_POWER10_TUNING: + return true; + + default: + return false; + } +} + /* Types of costly dependences. */ enum rs6000_dependence_cost { diff --git a/gcc/config/rs6000/rs6000-string.cc b/gcc/config/rs6000/rs6000-string.cc index 3d2911ca08a0..16107c909f3d 100644 --- a/gcc/config/rs6000/rs6000-string.cc +++ b/gcc/config/rs6000/rs6000-string.cc @@ -963,8 +963,7 @@ expand_compare_loop (rtx operands[]) max_bytes = 64; break; case PROCESSOR_POWER9: - case PROCESSOR_POWER10: - case PROCESSOR_POWER11: + CASE_PROCESSOR_POWER10_TUNING: if (bytes_is_const) max_bytes = 191; else diff --git a/gcc/config/rs6000/rs6000-tables.opt b/gcc/config/rs6000/rs6000-tables.opt index f5bbed5ea746..518324e7aead 100644 --- a/gcc/config/rs6000/rs6000-tables.opt +++ b/gcc/config/rs6000/rs6000-tables.opt @@ -189,14 +189,17 @@ EnumValue Enum(rs6000_cpu_opt_value) String(power11) Value(53) EnumValue -Enum(rs6000_cpu_opt_value) String(powerpc) Value(54) +Enum(rs6000_cpu_opt_value) String(future) Value(54) EnumValue -Enum(rs6000_cpu_opt_value) String(powerpc64) Value(55) +Enum(rs6000_cpu_opt_value) String(powerpc) Value(55) EnumValue -Enum(rs6000_cpu_opt_value) String(powerpc64le) Value(56) +Enum(rs6000_cpu_opt_value) String(powerpc64) Value(56) EnumValue -Enum(rs6000_cpu_opt_value) String(rs64) Value(57) +Enum(rs6000_cpu_opt_value) String(powerpc64le) Value(57) + +EnumValue +Enum(rs6000_cpu_opt_value) String(rs64) Value(58) diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 7ee26e52b138..ec789f869328 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -4387,8 +4387,7 @@ rs6000_option_override_internal (bool global_init_p) generating power10 instructions. */ if (!(rs6000_isa_flags_explicit & OPTION_MASK_P10_FUSION)) { - if (rs6000_tune == PROCESSOR_POWER10 - || rs6000_tune == PROCESSOR_POWER11) + if (power10_tuning_p (rs6000_tune)) rs6000_isa_flags |= OPTION_MASK_P10_FUSION; else rs6000_isa_flags &= ~OPTION_MASK_P10_FUSION; @@ -4416,8 +4415,7 @@ rs6000_option_override_internal (bool global_init_p) && rs6000_tune != PROCESSOR_POWER7 && rs6000_tune != PROCESSOR_POWER8 && rs6000_tune != PROCESSOR_POWER9 - && rs6000_tune != PROCESSOR_POWER10 - && rs6000_tune != PROCESSOR_POWER11 + && !power10_tuning_p (rs6000_tune) && rs6000_tune != PROCESSOR_PPCA2 && rs6000_tune != PROCESSOR_CELL && rs6000_tune != PROCESSOR_PPC476); @@ -4431,8 +4429,7 @@ rs6000_option_override_internal (bool global_init_p) || rs6000_tune == PROCESSOR_POWER7 || rs6000_tune == PROCESSOR_POWER8 || rs6000_tune == PROCESSOR_POWER9 - || rs6000_tune == PROCESSOR_POWER10 - || rs6000_tune == PROCESSOR_POWER11 + || power10_tuning_p (rs6000_tune) || rs6000_tune == PROCESSOR_PPCE500MC || rs6000_tune == PROCESSOR_PPCE500MC64 || rs6000_tune == PROCESSOR_PPCE5500 @@ -4731,8 +4728,7 @@ rs6000_option_override_internal (bool global_init_p) rs6000_cost = &power9_cost; break; - case PROCESSOR_POWER10: - case PROCESSOR_POWER11: + CASE_PROCESSOR_POWER10_TUNING: rs6000_cost = &power10_cost; break; @@ -10153,8 +10149,7 @@ rs6000_reassociation_width (unsigned int opc ATTRIBUTE_UNUSED, { case PROCESSOR_POWER8: case PROCESSOR_POWER9: - case PROCESSOR_POWER10: - case PROCESSOR_POWER11: + CASE_PROCESSOR_POWER10_TUNING: if (DECIMAL_FLOAT_MODE_P (mode)) return 1; if (VECTOR_MODE_P (mode)) @@ -18196,8 +18191,7 @@ rs6000_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep_insn, int cost, /* Separate a load from a narrower, dependent store. */ if ((rs6000_sched_groups || rs6000_tune == PROCESSOR_POWER9 - || rs6000_tune == PROCESSOR_POWER10 - || rs6000_tune == PROCESSOR_POWER11) + || power10_tuning_p (rs6000_tune)) && GET_CODE (PATTERN (insn)) == SET && GET_CODE (PATTERN (dep_insn)) == SET && MEM_P (XEXP (PATTERN (insn), 1)) @@ -18235,8 +18229,7 @@ rs6000_adjust_cost (rtx_insn *insn, int dep_type, rtx_insn *dep_insn, int cost, || rs6000_tune == PROCESSOR_POWER7 || rs6000_tune == PROCESSOR_POWER8 || rs6000_tune == PROCESSOR_POWER9 - || rs6000_tune == PROCESSOR_POWER10 - || rs6000_tune == PROCESSOR_POWER11 + || power10_tuning_p (rs6000_tune) || rs6000_tune == PROCESSOR_CELL) && recog_memoized (dep_insn) && (INSN_CODE (dep_insn) >= 0)) @@ -18810,8 +18803,7 @@ rs6000_issue_rate (void) return 7; case PROCESSOR_POWER9: return 6; - case PROCESSOR_POWER10: - case PROCESSOR_POWER11: + CASE_PROCESSOR_POWER10_TUNING: return 8; default: return 1; @@ -19527,10 +19519,8 @@ rs6000_sched_reorder (FILE *dump ATTRIBUTE_UNUSED, int sched_verbose, if (rs6000_tune == PROCESSOR_POWER6) load_store_pendulum = 0; - /* Do Power10/Power11 dependent reordering. */ - if (last_scheduled_insn - && (rs6000_tune == PROCESSOR_POWER10 - || rs6000_tune == PROCESSOR_POWER11)) + /* Do Power10 and similar processors dependent reordering. */ + if (last_scheduled_insn && power10_tuning_p (rs6000_tune)) power10_sched_reorder (ready, n_ready - 1); return rs6000_issue_rate (); @@ -19554,10 +19544,8 @@ rs6000_sched_reorder2 (FILE *dump, int sched_verbose, rtx_insn **ready, && recog_memoized (last_scheduled_insn) >= 0) return power9_sched_reorder2 (ready, *pn_ready - 1); - /* Do Power10/Power11 dependent reordering. */ - if (last_scheduled_insn - && (rs6000_tune == PROCESSOR_POWER10 - || rs6000_tune == PROCESSOR_POWER11)) + /* Do Power10 and similar processors dependent reordering. */ + if (last_scheduled_insn && power10_tuning_p (rs6000_tune)) return power10_sched_reorder (ready, *pn_ready - 1); return cached_can_issue_more; @@ -22779,8 +22767,7 @@ rs6000_register_move_cost (machine_mode mode, allocation a move within the same class might turn out to be a nop. */ if (rs6000_tune == PROCESSOR_POWER9 - || rs6000_tune == PROCESSOR_POWER10 - || rs6000_tune == PROCESSOR_POWER11) + || power10_tuning_p (rs6000_tune)) ret = 3 * hard_regno_nregs (FIRST_GPR_REGNO, mode); else ret = 4 * hard_regno_nregs (FIRST_GPR_REGNO, mode); diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index db6112a09e11..76c6cd1ab8ef 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -101,6 +101,7 @@ you make changes here, make them also there. */ #define ASM_CPU_SPEC \ "%{mcpu=native: %(asm_cpu_native); \ + mcpu=future: -mfuture; \ mcpu=power11: -mpower11; \ mcpu=power10: -mpower10; \ mcpu=power9: -mpower9; \ diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index 9c718ca2a226..605047f99a87 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -364,7 +364,7 @@ ppc750,ppc7400,ppc7450, ppc403,ppc405,ppc440,ppc476, ppc8540,ppc8548,ppce300c2,ppce300c3,ppce500mc,ppce500mc64,ppce5500,ppce6500, - power4,power5,power6,power7,power8,power9,power10,power11, + power4,power5,power6,power7,power8,power9,power10,power11,future, rs64a,mpccore,cell,ppca2,titan" (const (symbol_ref "(enum attr_cpu) rs6000_tune"))) diff --git a/gcc/config/rs6000/rs6000.opt b/gcc/config/rs6000/rs6000.opt index 88cf16ca581a..7e1af7120bcc 100644 --- a/gcc/config/rs6000/rs6000.opt +++ b/gcc/config/rs6000/rs6000.opt @@ -634,6 +634,12 @@ mieee128-constant Target Var(TARGET_IEEE128_CONSTANT) Init(1) Save Generate (do not generate) code that uses the LXVKQ instruction. +;; Users should not use -mfuture, but we need to use a bit to identify when +;; the user changes the default cpu via #pragma GCC target("cpu=future") +;; and then resets it later. +mfuture +Target Undocumented Mask(FUTURE) Var(rs6000_isa_flags) WarnRemoved + ; Documented parameters -param=rs6000-vect-unroll-limit=