From patchwork Sat Nov 16 17:53:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Meissner X-Patchwork-Id: 2012368 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=U5xXU5NB; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XrM3G4TqRz1xty for ; Sun, 17 Nov 2024 04:54:34 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A27A93857BB6 for ; Sat, 16 Nov 2024 17:54:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A27A93857BB6 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=U5xXU5NB X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 779253858D21 for ; Sat, 16 Nov 2024 17:53:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 779253858D21 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 779253858D21 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731779636; cv=none; b=ZQUspdbhBc/LUhxud7L6N0QsFzbMfxSHjNnSgg3vNXz8XETdSjOQuxLcL5negv2J7goWkuuj6/v8mJk+clyJKYIWCT13LPUjCyjGvaHWHolJxOH3cFJUef0ubhsBk+4P07AG+rO8Ulcg9vgkO3PyU5GGI1XBAKhxOPCGTQNL8wI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731779636; c=relaxed/simple; bh=5tTVfg0YOuwaCB3nO9qDlJz4w2MbJX9ruCy8vjeM2+4=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=df3MKUB0biDOrkiB9IMm1mviS+ytQjIW3d1DfsKyXqetiq0u/++SPh4prPohutn3Ovy2iYIBlvyhM5Gz280RaSd4QCw49YoBDt/NDqBju6OkVZdWSQ1Ra99XeOVveLmZH9Hy+wXLZ9zwgT7hSWrOawLiIWoL34jsOST/I00jlJg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 779253858D21 Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AG4SCPf025647; Sat, 16 Nov 2024 17:53:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h= content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=pp1; bh=ZMUSb6b5Z73KnrT6+ALUQkn/RvTYfF 5dDwxTkxDWZOQ=; b=U5xXU5NBnniSu/YykqGPgD5H50kcLv/lcLkQk4KhIe2lQM Po2+3Q4XtDpe6oXTYTb9mxFIwUkXQWx8JER0riaOyw3R1/OY2EMx8e1mgQG3PN/C XoBSqnGO+Kk3Go9WoaeyMx4PULLxnDq9yc9mK59Nni5jYSUzqpAscKiYXdqLbc8m gfQccW+4/QwL9UbwMYabIHJcCoJMRx7PYD8JQpyN45yEt7zuGsBYJVo1OPvDekCS WS0NZ5PB0Qu3wp+wjIuTrtUTDpwgndfh6ZB4xXBb5iYYDFV4ZPUSrDbSFpfTtDK2 8DTP4rn2i0Afx8d5sSpeAl0IwwZgfDQCMzTWl6Zw== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 42xgtstmjk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 16 Nov 2024 17:53:55 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4AG6ujjH002777; Sat, 16 Nov 2024 17:53:55 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 42tms1ce0s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 16 Nov 2024 17:53:55 +0000 Received: from smtpav02.dal12v.mail.ibm.com (smtpav02.dal12v.mail.ibm.com [10.241.53.101]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4AGHrs9T59638194 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 16 Nov 2024 17:53:54 GMT Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 243E45805A; Sat, 16 Nov 2024 17:53:54 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B28CE58051; Sat, 16 Nov 2024 17:53:53 +0000 (GMT) Received: from cowardly-lion.the-meissners.org (unknown [9.61.98.188]) by smtpav02.dal12v.mail.ibm.com (Postfix) with ESMTPS; Sat, 16 Nov 2024 17:53:53 +0000 (GMT) Date: Sat, 16 Nov 2024 12:53:52 -0500 From: Michael Meissner To: Michael Meissner , gcc-patches@gcc.gnu.org, Segher Boessenkool , Peter Bergner Subject: [PATCH V4 1/2] Add rs6000 architecture masks. Message-ID: Mail-Followup-To: Michael Meissner , gcc-patches@gcc.gnu.org, Segher Boessenkool , Peter Bergner References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-TM-AS-GCONF: 00 X-Proofpoint-GUID: wTKs3NJFakQE_jSM31t6NaaQ6YK5Mw2d X-Proofpoint-ORIG-GUID: wTKs3NJFakQE_jSM31t6NaaQ6YK5Mw2d X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 mlxscore=0 malwarescore=0 mlxlogscore=754 adultscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2411160151 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org This patch moves the architecture bits that are not user ISA options from rs6000_isa_flags to a new targt variable rs6000_arch_flags. The intention is to remove switches that are currently isa options, but the user should not be using this particular option. For example, we want users to use -mcpu=power10 and not just -mpower10. This patch also changes the target_clones support to use an architecture mask instead of isa bits. This patch also switches the handling of .machine to use architecture masks if they exist (power4 through power11). All of the other PowerPCs will continue to use the existing code for setting the .machine option. I have built both big endian and little endian bootstrap compilers and there were no regressions. I have built GCC with the patches in this patch set applied on both little and big endian PowerPC systems and there were no regressions. Can I apply this patch to GCC 15? 2024-11-16 Michael Meissner gcc/ * config/rs6000/default64.h (TARGET_CPU_DEFAULT): Set default cpu name. * config/rs6000/rs6000-arch.def: New file. * config/rs6000/rs6000.cc (struct clone_map): Switch to using architecture masks instead of ISA masks. (rs6000_clone_map): Likewise. (rs6000_print_isa_options): Add an architecture flags argument, change all callers. (get_arch_flag): New function. (rs6000_debug_reg_global): Update rs6000_print_isa_options calls. (rs6000_option_override_internal): Likewise. (rs6000_machine_from_flags): Switch to using architecture masks instead of ISA masks. (struct rs6000_arch_mask): New structure. (rs6000_arch_masks): New table of architecutre masks and names. (rs6000_function_specific_save): Save architecture flags. (rs6000_function_specific_restore): Restore architecture flags. (rs6000_function_specific_print): Update rs6000_print_isa_options calls. (rs6000_print_options_internal): Add architecture flags options. (rs6000_clone_priority): Switch to using architecture masks instead of ISA masks. (rs6000_can_inline_p): Don't allow inling if the callee requires a newer architecture than the caller. * config/rs6000/rs6000.h: Use rs6000-arch.def to create the architecture masks. * config/rs6000/rs6000.opt (rs6000_arch_flags): New target variable. (x_rs6000_arch_flags): New save/restore field for rs6000_arch_flags. --- gcc/config/rs6000/default64.h | 11 ++ gcc/config/rs6000/rs6000-arch.def | 49 +++++++ gcc/config/rs6000/rs6000.cc | 222 +++++++++++++++++++++++++----- gcc/config/rs6000/rs6000.h | 24 ++++ gcc/config/rs6000/rs6000.opt | 8 ++ 5 files changed, 277 insertions(+), 37 deletions(-) create mode 100644 gcc/config/rs6000/rs6000-arch.def diff --git a/gcc/config/rs6000/default64.h b/gcc/config/rs6000/default64.h index 10e3dec78ac..afa6542e040 100644 --- a/gcc/config/rs6000/default64.h +++ b/gcc/config/rs6000/default64.h @@ -21,6 +21,7 @@ along with GCC; see the file COPYING3. If not see #define RS6000_CPU(NAME, CPU, FLAGS) #include "rs6000-cpus.def" #undef RS6000_CPU +#undef TARGET_CPU_DEFAULT #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN) #undef TARGET_DEFAULT @@ -28,10 +29,20 @@ along with GCC; see the file COPYING3. If not see | MASK_LITTLE_ENDIAN) #undef ASM_DEFAULT_SPEC #define ASM_DEFAULT_SPEC "-mpower8" +#define TARGET_CPU_DEFAULT "power8" + #else #undef TARGET_DEFAULT #define TARGET_DEFAULT (OPTION_MASK_PPC_GFXOPT | OPTION_MASK_PPC_GPOPT \ | OPTION_MASK_MFCRF | MASK_POWERPC64 | MASK_64BIT) #undef ASM_DEFAULT_SPEC #define ASM_DEFAULT_SPEC "-mpower4" + +#if (TARGET_DEFAULT & MASK_POWERPC64) +#define TARGET_CPU_DEFAULT "powerpc64" + +#else +#define TARGET_CPU_DEFAULT "powerpc" +#endif + #endif diff --git a/gcc/config/rs6000/rs6000-arch.def b/gcc/config/rs6000/rs6000-arch.def new file mode 100644 index 00000000000..c0dbc583433 --- /dev/null +++ b/gcc/config/rs6000/rs6000-arch.def @@ -0,0 +1,49 @@ +/* IBM RS/6000 CPU architecture features by processor type. + Copyright (C) 2024 Free Software Foundation, Inc. + Contributed by Michael Meissner (meissner@linux.ibm.com) + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GCC is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + . */ + +/* This file defines architecture features that are based on the -mcpu= + option, and not on user options that can be turned on or off. The intention + is for newer processors (power7 and above) to not add new ISA bits for the + particular processor, but add these bits. Otherwise we have to add a bunch + of hidden options, just so we have the proper ISA bits. + + For example, in the past we added -mpower8-internal, so that on power8, + power9, and power10 would inherit the option, but we had to mark the option + generate a warning if the user actually used it. These options have been + moved from the ISA flags to the arch flags. + + To use this, define the macro ARCH_EXPAND which takes 2 arguments. The + first argument is the processor name in upper case, and the second argument + is a text name for the processor. + + The function get_arch_flags when passed a processor index number will set up + the appropriate architecture flags based on the actual processor + enumeration. */ + +ARCH_EXPAND(POWER4, "power4") +ARCH_EXPAND(POWER5, "power5") +ARCH_EXPAND(POWER5X, "power5+") +ARCH_EXPAND(POWER6, "power6") +ARCH_EXPAND(POWER7, "power7") +ARCH_EXPAND(POWER8, "power8") +ARCH_EXPAND(POWER9, "power9") +ARCH_EXPAND(POWER10, "power10") +ARCH_EXPAND(POWER11, "power11") +ARCH_EXPAND(FUTURE, "future") diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 214c8f326e3..603c72472b0 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -252,17 +252,17 @@ enum { /* Map compiler ISA bits into HWCAP names. */ struct clone_map { - HOST_WIDE_INT isa_mask; /* rs6000_isa mask */ + HOST_WIDE_INT arch_mask; /* rs6000_arch_mask. */ const char *name; /* name to use in __builtin_cpu_supports. */ }; static const struct clone_map rs6000_clone_map[CLONE_MAX] = { - { 0, "" }, /* Default options. */ - { OPTION_MASK_CMPB, "arch_2_05" }, /* ISA 2.05 (power6). */ - { OPTION_MASK_POPCNTD, "arch_2_06" }, /* ISA 2.06 (power7). */ - { OPTION_MASK_P8_VECTOR, "arch_2_07" }, /* ISA 2.07 (power8). */ - { OPTION_MASK_P9_VECTOR, "arch_3_00" }, /* ISA 3.0 (power9). */ - { OPTION_MASK_POWER10, "arch_3_1" }, /* ISA 3.1 (power10). */ + { 0, "" }, /* Default options. */ + { ARCH_MASK_POWER6, "arch_2_05" }, /* ISA 2.05 (power6). */ + { ARCH_MASK_POWER7, "arch_2_06" }, /* ISA 2.06 (power7). */ + { ARCH_MASK_POWER8, "arch_2_07" }, /* ISA 2.07 (power8). */ + { ARCH_MASK_POWER9, "arch_3_00" }, /* ISA 3.0 (power9). */ + { ARCH_MASK_POWER10, "arch_3_1" }, /* ISA 3.1 (power10). */ }; @@ -1171,7 +1171,7 @@ enum reg_class (*rs6000_preferred_reload_class_ptr) (rtx, enum reg_class) const int INSN_NOT_AVAILABLE = -1; static void rs6000_print_isa_options (FILE *, int, const char *, - HOST_WIDE_INT); + HOST_WIDE_INT, HOST_WIDE_INT); static HOST_WIDE_INT rs6000_disable_incompatible_switches (void); static enum rs6000_reg_type register_to_reg_type (rtx, bool *); @@ -1818,6 +1818,87 @@ rs6000_cpu_name_lookup (const char *name) return -1; } + +/* Map the processor into the arch bits that are set off of -mcpu= instead + of having an internal -m option. */ + +static HOST_WIDE_INT +get_arch_flags (int cpu_index) +{ + HOST_WIDE_INT ret = 0; + + const HOST_WIDE_INT ARCH_COMBO_POWER4 = ARCH_MASK_POWER4; + const HOST_WIDE_INT ARCH_COMBO_POWER5 = ARCH_MASK_POWER5 | ARCH_COMBO_POWER4; + const HOST_WIDE_INT ARCH_COMBO_POWER5X = ARCH_MASK_POWER5X | ARCH_COMBO_POWER5; + const HOST_WIDE_INT ARCH_COMBO_POWER6 = ARCH_MASK_POWER6 | ARCH_COMBO_POWER5X; + const HOST_WIDE_INT ARCH_COMBO_POWER7 = ARCH_MASK_POWER7 | ARCH_COMBO_POWER6; + const HOST_WIDE_INT ARCH_COMBO_POWER8 = ARCH_MASK_POWER8 | ARCH_COMBO_POWER7; + const HOST_WIDE_INT ARCH_COMBO_POWER9 = ARCH_MASK_POWER9 | ARCH_COMBO_POWER8; + const HOST_WIDE_INT ARCH_COMBO_POWER10 = ARCH_MASK_POWER10 | ARCH_COMBO_POWER9; + const HOST_WIDE_INT ARCH_COMBO_POWER11 = ARCH_MASK_POWER11 | ARCH_COMBO_POWER10; + const HOST_WIDE_INT ARCH_COMBO_FUTURE = ARCH_MASK_FUTURE | ARCH_COMBO_POWER11; + + if (cpu_index >= 0) + switch (processor_target_table[cpu_index].processor) + { + case PROCESSOR_FUTURE: + ret = ARCH_COMBO_FUTURE; + break; + + case PROCESSOR_POWER11: + ret = ARCH_COMBO_POWER11; + break; + + case PROCESSOR_POWER10: + ret = ARCH_COMBO_POWER10; + break; + + case PROCESSOR_POWER9: + ret = ARCH_COMBO_POWER9; + break; + + case PROCESSOR_POWER8: + ret = ARCH_COMBO_POWER8; + break; + + case PROCESSOR_POWER7: + ret = ARCH_COMBO_POWER7; + break; + + case PROCESSOR_PPCA2: + case PROCESSOR_POWER6: + ret = ARCH_COMBO_POWER6; + break; + + case PROCESSOR_POWER5: + ret = ARCH_COMBO_POWER5; + if (TARGET_FPRND) + ret |= ARCH_MASK_POWER5X; + break; + + case PROCESSOR_POWER4: + ret = ARCH_COMBO_POWER4; + break; + + default: + /* For other processors, set the arch flags based on the ISA bits. */ + if (TARGET_MFCRF) + ret |= ARCH_MASK_POWER4; + + if (TARGET_POPCNTB) + ret |= ARCH_MASK_POWER5; + + if (TARGET_FPRND) + ret |= ARCH_MASK_POWER5X; + + if (TARGET_CMPB) + ret |= ARCH_MASK_POWER6; + break; + } + + return ret; +} + /* Return number of consecutive hard regs needed starting at reg REGNO to hold something of mode MODE. @@ -2399,9 +2480,10 @@ rs6000_debug_reg_global (void) const char *name = processor_target_table[rs6000_cpu_index].name; HOST_WIDE_INT flags = processor_target_table[rs6000_cpu_index].target_enable; + HOST_WIDE_INT arch_flags = get_arch_flags (rs6000_cpu_index); sprintf (flags_buffer, "-mcpu=%s flags", name); - rs6000_print_isa_options (stderr, 0, flags_buffer, flags); + rs6000_print_isa_options (stderr, 0, flags_buffer, flags, arch_flags); } else fprintf (stderr, DEBUG_FMT_S, "cpu", ""); @@ -2411,21 +2493,26 @@ rs6000_debug_reg_global (void) const char *name = processor_target_table[rs6000_tune_index].name; HOST_WIDE_INT flags = processor_target_table[rs6000_tune_index].target_enable; + HOST_WIDE_INT arch_flags = get_arch_flags (rs6000_tune_index); sprintf (flags_buffer, "-mtune=%s flags", name); - rs6000_print_isa_options (stderr, 0, flags_buffer, flags); + rs6000_print_isa_options (stderr, 0, flags_buffer, flags, arch_flags); } else fprintf (stderr, DEBUG_FMT_S, "tune", ""); cl_target_option_save (&cl_opts, &global_options, &global_options_set); rs6000_print_isa_options (stderr, 0, "rs6000_isa_flags", - rs6000_isa_flags); + rs6000_isa_flags, 0); rs6000_print_isa_options (stderr, 0, "rs6000_isa_flags_explicit", - rs6000_isa_flags_explicit); + rs6000_isa_flags_explicit, 0); - rs6000_print_isa_options (stderr, 0, "TARGET_DEFAULT", TARGET_DEFAULT); + if (rs6000_arch_flags) + rs6000_print_isa_options (stderr, 0, "rs6000_arch_flags", 0, + rs6000_arch_flags); + + rs6000_print_isa_options (stderr, 0, "TARGET_DEFAULT", TARGET_DEFAULT, 0); fprintf (stderr, DEBUG_FMT_S, "--with-cpu default", OPTION_TARGET_CPU_DEFAULT ? OPTION_TARGET_CPU_DEFAULT : ""); @@ -3622,7 +3709,7 @@ rs6000_option_override_internal (bool global_init_p) /* Print defaults. */ if ((TARGET_DEBUG_REG || TARGET_DEBUG_TARGET) && global_init_p) - rs6000_print_isa_options (stderr, 0, "TARGET_DEFAULT", TARGET_DEFAULT); + rs6000_print_isa_options (stderr, 0, "TARGET_DEFAULT", TARGET_DEFAULT, 0); /* Remember the explicit arguments. */ if (global_init_p) @@ -3753,6 +3840,8 @@ rs6000_option_override_internal (bool global_init_p) rs6000_isa_flags |= (flags & ~rs6000_isa_flags_explicit); } + rs6000_arch_flags = get_arch_flags (cpu_index); + /* Don't expect powerpc64 enabled on those OSes with OS_MISSING_POWERPC64, since they do not save and restore the high half of the GPRs correctly in all cases. If the user explicitly specifies it, we won't interfere @@ -3879,7 +3968,8 @@ rs6000_option_override_internal (bool global_init_p) & ~rs6000_isa_flags_explicit); if (TARGET_DEBUG_REG || TARGET_DEBUG_TARGET) - rs6000_print_isa_options (stderr, 0, "before defaults", rs6000_isa_flags); + rs6000_print_isa_options (stderr, 0, "before defaults", rs6000_isa_flags, + rs6000_arch_flags); #ifdef XCOFF_DEBUGGING_INFO /* For AIX default to 64-bit DWARF. */ @@ -4241,7 +4331,8 @@ rs6000_option_override_internal (bool global_init_p) /* Print the options after updating the defaults. */ if (TARGET_DEBUG_REG || TARGET_DEBUG_TARGET) - rs6000_print_isa_options (stderr, 0, "after defaults", rs6000_isa_flags); + rs6000_print_isa_options (stderr, 0, "after defaults", rs6000_isa_flags, + rs6000_arch_flags); /* E500mc does "better" if we inline more aggressively. Respect the user's opinion, though. */ @@ -4348,7 +4439,8 @@ rs6000_option_override_internal (bool global_init_p) TARGET_NO_FP_IN_TOC = 1; if (TARGET_DEBUG_REG || TARGET_DEBUG_TARGET) - rs6000_print_isa_options (stderr, 0, "before subtarget", rs6000_isa_flags); + rs6000_print_isa_options (stderr, 0, "before subtarget", rs6000_isa_flags, + rs6000_arch_flags); #ifdef SUBTARGET_OVERRIDE_OPTIONS SUBTARGET_OVERRIDE_OPTIONS; @@ -4416,7 +4508,8 @@ rs6000_option_override_internal (bool global_init_p) rs6000_isa_flags &= ~OPTION_MASK_PCREL_OPT; if (TARGET_DEBUG_REG || TARGET_DEBUG_TARGET) - rs6000_print_isa_options (stderr, 0, "after subtarget", rs6000_isa_flags); + rs6000_print_isa_options (stderr, 0, "after subtarget", rs6000_isa_flags, + rs6000_arch_flags); rs6000_always_hint = (rs6000_tune != PROCESSOR_POWER4 && rs6000_tune != PROCESSOR_POWER5 @@ -5910,29 +6003,30 @@ rs6000_machine_from_flags (void) return "ppc64"; #endif + HOST_WIDE_INT arch_flags = rs6000_arch_flags; HOST_WIDE_INT flags = rs6000_isa_flags; /* Disable the flags that should never influence the .machine selection. */ flags &= ~(OPTION_MASK_PPC_GFXOPT | OPTION_MASK_PPC_GPOPT | OPTION_MASK_ISEL | OPTION_MASK_ALTIVEC | OPTION_MASK_BLOCK_OPS_VECTOR_PAIR); - if ((flags & (FUTURE_MASKS_SERVER & ~ISA_3_1_MASKS_SERVER)) != 0) + if ((arch_flags & ARCH_MASK_FUTURE) != 0) return "future"; - if ((flags & (POWER11_MASKS_SERVER & ~ISA_3_1_MASKS_SERVER)) != 0) + if ((arch_flags & ARCH_MASK_POWER11) != 0) return "power11"; - if ((flags & (ISA_3_1_MASKS_SERVER & ~ISA_3_0_MASKS_SERVER)) != 0) + if ((arch_flags & ARCH_MASK_POWER10) != 0) return "power10"; - if ((flags & (ISA_3_0_MASKS_SERVER & ~ISA_2_7_MASKS_SERVER)) != 0) + if ((arch_flags & ARCH_MASK_POWER9) != 0) return "power9"; - if ((flags & (ISA_2_7_MASKS_SERVER & ~ISA_2_6_MASKS_SERVER)) != 0) + if ((arch_flags & ARCH_MASK_POWER8) != 0) return "power8"; - if ((flags & (ISA_2_6_MASKS_SERVER & ~ISA_2_5_MASKS_SERVER)) != 0) + if ((arch_flags & ARCH_MASK_POWER7) != 0) return "power7"; - if ((flags & (ISA_2_5_MASKS_SERVER & ~ISA_2_4_MASKS)) != 0) + if ((arch_flags & ARCH_MASK_POWER6) != 0) return "power6"; - if ((flags & (ISA_2_4_MASKS & ~ISA_2_1_MASKS)) != 0) + if ((arch_flags & ARCH_MASK_POWER5) != 0) return "power5"; - if ((flags & ISA_2_1_MASKS) != 0) + if ((arch_flags & ARCH_MASK_POWER4) != 0) return "power4"; if ((flags & OPTION_MASK_POWERPC64) != 0) return "ppc64"; @@ -24570,6 +24664,23 @@ static struct rs6000_opt_mask const rs6000_opt_masks[] = { "string", 0, false, false }, }; +/* Similar structure for the arch bits that are set via -mcpu= and not via + a separate -m option. */ +struct rs6000_arch_mask { + const char *name; /* option name */ + const HOST_WIDE_INT mask; /* mask to set */ +}; + +#undef ARCH_EXPAND +#define ARCH_EXPAND(PROC, NAME) { NAME, ARCH_MASK_ ## PROC }, + +static struct rs6000_arch_mask const rs6000_arch_masks[] = +{ +#include "rs6000-arch.def" +}; + +#undef ARCH_EXPAND + /* Option variables that we want to support inside attribute((target)) and #pragma GCC target operations. */ @@ -25108,6 +25219,7 @@ rs6000_function_specific_save (struct cl_target_option *ptr, { ptr->x_rs6000_isa_flags = opts->x_rs6000_isa_flags; ptr->x_rs6000_isa_flags_explicit = opts->x_rs6000_isa_flags_explicit; + ptr->x_rs6000_arch_flags = opts->x_rs6000_arch_flags; } /* Restore the current options */ @@ -25120,6 +25232,7 @@ rs6000_function_specific_restore (struct gcc_options *opts, { opts->x_rs6000_isa_flags = ptr->x_rs6000_isa_flags; opts->x_rs6000_isa_flags_explicit = ptr->x_rs6000_isa_flags_explicit; + opts->x_rs6000_arch_flags = ptr->x_rs6000_arch_flags; (void) rs6000_option_override_internal (false); } @@ -25130,10 +25243,12 @@ rs6000_function_specific_print (FILE *file, int indent, struct cl_target_option *ptr) { rs6000_print_isa_options (file, indent, "Isa options set", - ptr->x_rs6000_isa_flags); + ptr->x_rs6000_isa_flags, + ptr->x_rs6000_arch_flags); rs6000_print_isa_options (file, indent, "Isa options explicit", - ptr->x_rs6000_isa_flags_explicit); + ptr->x_rs6000_isa_flags_explicit, + ptr->x_rs6000_arch_flags); } /* Helper function to print the current isa or misc options on a line. */ @@ -25145,13 +25260,18 @@ rs6000_print_options_internal (FILE *file, HOST_WIDE_INT flags, const char *prefix, const struct rs6000_opt_mask *opts, - size_t num_elements) + size_t num_elements, + HOST_WIDE_INT arch_flags, + const char *arch_prefix, + const struct rs6000_arch_mask *arch_masks, + size_t num_arch) { size_t i; size_t start_column = 0; size_t cur_column; size_t max_column = 120; size_t prefix_len = strlen (prefix); + size_t arch_prefix_len = strlen (arch_prefix); size_t comma_len = 0; const char *comma = ""; @@ -25211,6 +25331,29 @@ rs6000_print_options_internal (FILE *file, comma_len = strlen (", "); } + /* Put out the architecture flag bits that are set via -mcpu= and that + might not have a -m option. */ + for (i = 0; i < num_arch; i++) + { + if ((arch_flags & arch_masks[i].mask) != 0) + { + const char *name = arch_masks[i].name; + size_t len = comma_len + arch_prefix_len + strlen (name); + + cur_column += len; + if (cur_column > max_column) + { + fprintf (stderr, ", \\\n%*s", (int)start_column, ""); + cur_column = start_column + len; + comma = ""; + } + + fprintf (file, "%s%s%s", comma, arch_prefix, name); + comma = ", "; + comma_len = strlen (", "); + } + } + fputs ("\n", file); } @@ -25218,11 +25361,13 @@ rs6000_print_options_internal (FILE *file, static void rs6000_print_isa_options (FILE *file, int indent, const char *string, - HOST_WIDE_INT flags) + HOST_WIDE_INT flags, HOST_WIDE_INT arch_flags) { rs6000_print_options_internal (file, indent, string, flags, "-m", &rs6000_opt_masks[0], - ARRAY_SIZE (rs6000_opt_masks)); + ARRAY_SIZE (rs6000_opt_masks), + arch_flags, "arch=", &rs6000_arch_masks[0], + ARRAY_SIZE (rs6000_arch_masks)); } /* If the user used -mno-vsx, we need turn off all of the implicit ISA 2.06, @@ -25312,7 +25457,7 @@ static int rs6000_clone_priority (tree fndecl) { tree fn_opts = DECL_FUNCTION_SPECIFIC_TARGET (fndecl); - HOST_WIDE_INT isa_masks; + HOST_WIDE_INT arch_masks; int ret = CLONE_DEFAULT; tree attrs = lookup_attribute ("target", DECL_ATTRIBUTES (fndecl)); const char *attrs_str = NULL; @@ -25328,12 +25473,12 @@ rs6000_clone_priority (tree fndecl) fn_opts = target_option_default_node; if (!fn_opts || !TREE_TARGET_OPTION (fn_opts)) - isa_masks = rs6000_isa_flags; + arch_masks = rs6000_arch_flags; else - isa_masks = TREE_TARGET_OPTION (fn_opts)->x_rs6000_isa_flags; + arch_masks = TREE_TARGET_OPTION (fn_opts)->x_rs6000_arch_flags; for (ret = CLONE_MAX - 1; ret != 0; ret--) - if ((rs6000_clone_map[ret].isa_mask & isa_masks) != 0) + if ((rs6000_clone_map[ret].arch_mask & arch_masks) != 0) break; } @@ -25813,6 +25958,8 @@ rs6000_can_inline_p (tree caller, tree callee) HOST_WIDE_INT callee_isa = callee_opts->x_rs6000_isa_flags; HOST_WIDE_INT caller_isa = caller_opts->x_rs6000_isa_flags; HOST_WIDE_INT explicit_isa = callee_opts->x_rs6000_isa_flags_explicit; + HOST_WIDE_INT callee_arch = callee_opts->x_rs6000_arch_flags; + HOST_WIDE_INT caller_arch = caller_opts->x_rs6000_arch_flags; cgraph_node *callee_node = cgraph_node::get (callee); if (ipa_fn_summaries && ipa_fn_summaries->get (callee_node) != NULL) @@ -25836,7 +25983,8 @@ rs6000_can_inline_p (tree caller, tree callee) callee has explicitly enabled or disabled, then we must enforce that the callee's and caller's options match exactly; see PR70010. */ if (((caller_isa & callee_isa) == callee_isa) - && (caller_isa & explicit_isa) == (callee_isa & explicit_isa)) + && (caller_isa & explicit_isa) == (callee_isa & explicit_isa) + && (caller_arch & callee_arch) == callee_arch) ret = true; if (TARGET_DEBUG_TARGET) diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index daf1a1d41e8..382d7824064 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -2491,3 +2491,27 @@ while (0) issues have been resolved. */ #define RS6000_DISABLE_SCALAR_MODULO 1 + + +/* Create the architecture flags. */ +/* Define an enumeration to number the architecture masks. */ +#ifdef GCC_HWINT_H +#undef ARCH_EXPAND +#define ARCH_EXPAND(PROC, NAME) ARCH_ENUM_ ## PROC, + +enum { +#include "rs6000-arch.def" + ARCH_ENUM_LAST +}; + +/* Create an architecture mask for the newer architectures (power6 and + up).. */ +#undef ARCH_EXPAND +#define ARCH_EXPAND(PROC, NAME) \ + static const HOST_WIDE_INT ARCH_MASK_ ## PROC \ + = HOST_WIDE_INT_1 << ARCH_ENUM_ ## PROC; + +#include "rs6000-arch.def" + +#undef ARCH_EXPAND +#endif /* GCC_HWINT_H. */ diff --git a/gcc/config/rs6000/rs6000.opt b/gcc/config/rs6000/rs6000.opt index 876b9f0d4af..66c432f1384 100644 --- a/gcc/config/rs6000/rs6000.opt +++ b/gcc/config/rs6000/rs6000.opt @@ -36,6 +36,14 @@ HOST_WIDE_INT rs6000_isa_flags_explicit TargetSave HOST_WIDE_INT x_rs6000_isa_flags_explicit +;; Arch bits that are set via -mcpu= but don't have a user -m +;; option +Variable +HOST_WIDE_INT rs6000_arch_flags = 0 + +TargetSave +HOST_WIDE_INT x_rs6000_arch_flags + ;; Current processor TargetVariable enum processor_type rs6000_cpu = PROCESSOR_PPC603 From patchwork Sat Nov 16 17:56:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Meissner X-Patchwork-Id: 2012369 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=OR0csrHO; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XrM6K475Bz1xxN for ; Sun, 17 Nov 2024 04:57:13 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 520A8385772A for ; Sat, 16 Nov 2024 17:57:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 520A8385772A Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=OR0csrHO X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 656DA3858D21 for ; Sat, 16 Nov 2024 17:56:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 656DA3858D21 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 656DA3858D21 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731779797; cv=none; b=CQvnpZZPGtNLn0zEqSRXrLCaDJTkVh9MxPYslgFzR+T/Dc4srPgLlPdq5PcHXwf19TaU/iJhjg6u2PaRfdGtlxpTliCttjb/KjWQBy1YC1dEwqWpbdLbgN9fpp43oULxImUpWQKDKQJ0dqQRgHZcH7tsE6yK/ZEhX8gjHKYFOBI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731779797; c=relaxed/simple; bh=3N2GQMgfvwLTb7exgKkmdgAtel6DH/idgUv3abfLhaA=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=gClveHJWsr7SPZ5Lbm6HBVoIkxjoL5D+TgZQOGc0d4p8Hu9M2YG9s9RnduRvqGLEAfQ70n0mBaXm1b6Q6k9kvvxIIwtsgmMKjGUZDNCHrtHuvSemVVaX2S4mwvGRZzSUlk2RTgGwUeu+lUU/6qnC6j2mPi52azuBb44kSrT5GF8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 656DA3858D21 Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AG9t4j8029752; Sat, 16 Nov 2024 17:56:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h= content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=pp1; bh=Wgx1LVvrj2Qu4hZxxuMDsdytmcTsPN BH7PB+FyHFAOA=; b=OR0csrHOnUgeb3OaKTPPg1ky/FvP1ZcV2UamUOb5xQM74g J7udbEjocWWQGTfVIVYx0qyAkKJ2KuCEh+CBoQD2zV9N7cHWP5yXx0IFIz3ohcTl ZTZZhqV9/uAP9SeZUozLmsb9rmn6/7Hw0pC7t8VyMwRe0iOzX2QIXhGVnN852a0r yos3CeBsNugzM3sFsGjlJ0ImEoFX2TYz7KfLWok5XPMT9piO1AKuqJ/4LVEpnmBF +0PU4jP+2NJV2wRlKtEy3eM1dhdP/zXDy7bTubi+8yp87vnEFnVWrlkGFfP4elcd Hs1KNyuurFB7mvShgg0R0C7yfTAZRID0rYnAQ+og== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 42xhtjae54-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 16 Nov 2024 17:56:36 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4AG6qRgu007703; Sat, 16 Nov 2024 17:56:35 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 42tm9jmf85-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 16 Nov 2024 17:56:35 +0000 Received: from smtpav01.dal12v.mail.ibm.com (smtpav01.dal12v.mail.ibm.com [10.241.53.100]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4AGHuZd458786070 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 16 Nov 2024 17:56:35 GMT Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1C7AD58064; Sat, 16 Nov 2024 17:56:35 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AC76F5805D; Sat, 16 Nov 2024 17:56:34 +0000 (GMT) Received: from cowardly-lion.the-meissners.org (unknown [9.61.98.188]) by smtpav01.dal12v.mail.ibm.com (Postfix) with ESMTPS; Sat, 16 Nov 2024 17:56:34 +0000 (GMT) Date: Sat, 16 Nov 2024 12:56:33 -0500 From: Michael Meissner To: Michael Meissner , gcc-patches@gcc.gnu.org, Segher Boessenkool , Peter Bergner Subject: [PATCH V4 2/2] Use architecture flags for defining _ARCH_PWR macros. Message-ID: Mail-Followup-To: Michael Meissner , gcc-patches@gcc.gnu.org, Segher Boessenkool , Peter Bergner References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Z7I8WSlWc0cj4lMr6My2wa3TE_CgP8_t X-Proofpoint-GUID: Z7I8WSlWc0cj4lMr6My2wa3TE_CgP8_t X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=999 clxscore=1015 malwarescore=0 spamscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 mlxscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2411160151 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org For the newer architectures, this patch changes GCC to define the _ARCH_PWR macros using the new architecture flags instead of relying on isa options like -mpower10. The -mpower8-internal, -mpower10, -mpower11, and -mfuture options were removed. The -mpower11 and -mfuture options were removed completely, since they were just added in GCC 15. The other two options were marked as WarnRemoved, and the various ISA bits were removed. TARGET_POWER8, TARGET_POWER10, TARGET_POWER11, and TARGET_FUTURE were re-defined to use the architeture bits instead of the ISA bits. There are other internal isa bits that aren't removed with this patch because the built-in function support uses those bits. I have built both big endian and little endian bootstrap compilers and there were no regressions. Can I install this patch on the GCC 15 trunk? 2024-11-16 Michael Meissner gcc/ * config/rs6000/rs6000-c.cc (rs6000_target_modify_macros) Add support to use architecture flags instead of ISA flags for setting most of the _ARCH_PWR* macros. (rs6000_cpu_cpp_builtins): Update rs6000_target_modify_macros call. * config/rs6000/rs6000-cpus.def (ISA_2_7_MASKS_SERVER): Remove OPTION_MASK_POWER8. (ISA_3_1_MASKS_SERVER): Remove OPTION_MASK_POWER10. (POWER11_MASKS_SERVER): Remove OPTION_MASK_POWER11. (FUTURE_MASKS_SERVER): Remove OPTION_MASK_FUTURE. (POWERPC_MASKS): Remove OPTION_MASK_POWER8, OPTION_MASK_POWER10, OPTION_MASK_POWER11, and OPTION_MASK_FUTURE. * config/rs6000/rs6000-protos.h (rs6000_target_modify_macros): Update declaration. (rs6000_target_modify_macros_ptr): Likewise. * config/rs6000/rs6000.cc (rs6000_target_modify_macros_ptr): Likewise. (rs6000_option_override_internal): Use architecture flags instead of ISA flags. (rs6000_opt_masks): Remove -mpower10, -mpower11, and -mfuture which are no longer in the ISA flags. (rs6000_pragma_target_parse): Use architecture flags as well as ISA flags. * config/rs6000/rs6000.h (TARGET_POWER5): Redefine to use architecture flags. (TARGET_POWER5X): Likewise. (TARGET_POWER6): Likewise. (TARGET_POWER7): Likewise. (TARGET_POWER8): Likewise. (TARGET_POWER9): Likewise. (TARGET_POWER10): New macro. (TARGET_POWER11): Likewise. (TARGET_FUTURE): Likewise. * config/rs6000/rs6000.opt (-mpower8-internal): Remove ISA flag bits. (-mpower10): Likewise. (-mpower11): Likewise. (-mfuture): Likewise. --- gcc/config/rs6000/rs6000-c.cc | 29 ++++++++++++++++------------- gcc/config/rs6000/rs6000-cpus.def | 10 +--------- gcc/config/rs6000/rs6000-protos.h | 5 +++-- gcc/config/rs6000/rs6000.cc | 20 +++++++++++--------- gcc/config/rs6000/rs6000.h | 19 +++++++++++++------ gcc/config/rs6000/rs6000.opt | 17 ++--------------- 6 files changed, 46 insertions(+), 54 deletions(-) diff --git a/gcc/config/rs6000/rs6000-c.cc b/gcc/config/rs6000/rs6000-c.cc index b0b5701c7fa..30ea1d64326 100644 --- a/gcc/config/rs6000/rs6000-c.cc +++ b/gcc/config/rs6000/rs6000-c.cc @@ -339,7 +339,8 @@ rs6000_define_or_undefine_macro (bool define_p, const char *name) #pragma GCC target, we need to adjust the macros dynamically. */ void -rs6000_target_modify_macros (bool define_p, HOST_WIDE_INT flags) +rs6000_target_modify_macros (bool define_p, HOST_WIDE_INT flags, + HOST_WIDE_INT arch_flags) { if (TARGET_DEBUG_BUILTIN || TARGET_DEBUG_TARGET) fprintf (stderr, @@ -412,7 +413,7 @@ rs6000_target_modify_macros (bool define_p, HOST_WIDE_INT flags) summary of the flags associated with particular cpu definitions. */ - /* rs6000_isa_flags based options. */ + /* rs6000_isa_flags and rs6000_arch_flags based options. */ rs6000_define_or_undefine_macro (define_p, "_ARCH_PPC"); if ((flags & OPTION_MASK_PPC_GPOPT) != 0) rs6000_define_or_undefine_macro (define_p, "_ARCH_PPCSQ"); @@ -420,25 +421,27 @@ rs6000_target_modify_macros (bool define_p, HOST_WIDE_INT flags) rs6000_define_or_undefine_macro (define_p, "_ARCH_PPCGR"); if ((flags & OPTION_MASK_POWERPC64) != 0) rs6000_define_or_undefine_macro (define_p, "_ARCH_PPC64"); - if ((flags & OPTION_MASK_MFCRF) != 0) + if ((flags & OPTION_MASK_POWERPC64) != 0) + rs6000_define_or_undefine_macro (define_p, "_ARCH_PPC64"); + if ((arch_flags & ARCH_MASK_POWER4) != 0) rs6000_define_or_undefine_macro (define_p, "_ARCH_PWR4"); - if ((flags & OPTION_MASK_POPCNTB) != 0) + if ((arch_flags & ARCH_MASK_POWER5) != 0) rs6000_define_or_undefine_macro (define_p, "_ARCH_PWR5"); - if ((flags & OPTION_MASK_FPRND) != 0) + if ((arch_flags & ARCH_MASK_POWER5X) != 0) rs6000_define_or_undefine_macro (define_p, "_ARCH_PWR5X"); - if ((flags & OPTION_MASK_CMPB) != 0) + if ((arch_flags & ARCH_MASK_POWER6) != 0) rs6000_define_or_undefine_macro (define_p, "_ARCH_PWR6"); - if ((flags & OPTION_MASK_POPCNTD) != 0) + if ((arch_flags & ARCH_MASK_POWER7) != 0) rs6000_define_or_undefine_macro (define_p, "_ARCH_PWR7"); - if ((flags & OPTION_MASK_POWER8) != 0) + if ((arch_flags & ARCH_MASK_POWER8) != 0) rs6000_define_or_undefine_macro (define_p, "_ARCH_PWR8"); - if ((flags & OPTION_MASK_MODULO) != 0) + if ((arch_flags & ARCH_MASK_POWER9) != 0) rs6000_define_or_undefine_macro (define_p, "_ARCH_PWR9"); - if ((flags & OPTION_MASK_POWER10) != 0) + if ((arch_flags & ARCH_MASK_POWER10) != 0) rs6000_define_or_undefine_macro (define_p, "_ARCH_PWR10"); - if ((flags & OPTION_MASK_POWER11) != 0) + if ((arch_flags & ARCH_MASK_POWER11) != 0) rs6000_define_or_undefine_macro (define_p, "_ARCH_PWR11"); - if ((flags & OPTION_MASK_FUTURE) != 0) + if ((arch_flags & ARCH_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"); @@ -608,7 +611,7 @@ void rs6000_cpu_cpp_builtins (cpp_reader *pfile) { /* Define all of the common macros. */ - rs6000_target_modify_macros (true, rs6000_isa_flags); + rs6000_target_modify_macros (true, rs6000_isa_flags, rs6000_arch_flags); if (TARGET_FRE) builtin_define ("__RECIP__"); diff --git a/gcc/config/rs6000/rs6000-cpus.def b/gcc/config/rs6000/rs6000-cpus.def index 62e6c9d3b58..74151be4048 100644 --- a/gcc/config/rs6000/rs6000-cpus.def +++ b/gcc/config/rs6000/rs6000-cpus.def @@ -47,7 +47,6 @@ fusion here, instead set it in rs6000.cc if we are tuning for a power8 system. */ #define ISA_2_7_MASKS_SERVER (ISA_2_6_MASKS_SERVER \ - | OPTION_MASK_POWER8 \ | OPTION_MASK_P8_VECTOR \ | OPTION_MASK_CRYPTO \ | OPTION_MASK_EFFICIENT_UNALIGNED_VSX \ @@ -83,14 +82,11 @@ | OPTION_MASK_PREFIXED) #define ISA_3_1_MASKS_SERVER (ISA_3_0_MASKS_SERVER \ - | OPTION_MASK_POWER10 \ | OTHER_POWER10_MASKS) -#define POWER11_MASKS_SERVER (ISA_3_1_MASKS_SERVER \ - | OPTION_MASK_POWER11) +#define POWER11_MASKS_SERVER ISA_3_1_MASKS_SERVER #define FUTURE_MASKS_SERVER (POWER11_MASKS_SERVER \ - | OPTION_MASK_FUTURE \ | OPTION_MASK_BLOCK_OPS_VECTOR_PAIR) /* Flags that need to be turned off if -mno-vsx. */ @@ -130,9 +126,6 @@ | OPTION_MASK_FLOAT128_HW \ | OPTION_MASK_FLOAT128_KEYWORD \ | OPTION_MASK_FPRND \ - | OPTION_MASK_FUTURE \ - | OPTION_MASK_POWER10 \ - | OPTION_MASK_POWER11 \ | OPTION_MASK_P10_FUSION \ | OPTION_MASK_HTM \ | OPTION_MASK_ISEL \ @@ -141,7 +134,6 @@ | OPTION_MASK_MODULO \ | OPTION_MASK_MULHW \ | OPTION_MASK_NO_UPDATE \ - | OPTION_MASK_POWER8 \ | OPTION_MASK_P8_FUSION \ | OPTION_MASK_P8_VECTOR \ | OPTION_MASK_P9_MINMAX \ diff --git a/gcc/config/rs6000/rs6000-protos.h b/gcc/config/rs6000/rs6000-protos.h index b40557a8557..da658cd5ab2 100644 --- a/gcc/config/rs6000/rs6000-protos.h +++ b/gcc/config/rs6000/rs6000-protos.h @@ -323,8 +323,9 @@ extern void rs6000_cpu_cpp_builtins (struct cpp_reader *); extern bool rs6000_pragma_target_parse (tree, tree); #endif extern void rs6000_activate_target_options (tree new_tree); -extern void rs6000_target_modify_macros (bool, HOST_WIDE_INT); -extern void (*rs6000_target_modify_macros_ptr) (bool, HOST_WIDE_INT); +extern void rs6000_target_modify_macros (bool, HOST_WIDE_INT, HOST_WIDE_INT); +extern void (*rs6000_target_modify_macros_ptr) (bool, HOST_WIDE_INT, + HOST_WIDE_INT); #ifdef NO_DOLLAR_IN_LABEL const char * rs6000_xcoff_strip_dollar (const char *); diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 603c72472b0..dc5b7eb74d4 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -278,7 +278,7 @@ bool cpu_builtin_p = false; /* Pointer to function (in rs6000-c.cc) that can define or undefine target macros that have changed. Languages that don't support the preprocessor don't link in rs6000-c.cc, so we can't call it directly. */ -void (*rs6000_target_modify_macros_ptr) (bool, HOST_WIDE_INT); +void (*rs6000_target_modify_macros_ptr) (bool, HOST_WIDE_INT, HOST_WIDE_INT); /* Simplfy register classes into simpler classifications. We assume GPR_REG_TYPE - FPR_REG_TYPE are ordered so that we can use a simple range @@ -3909,8 +3909,7 @@ rs6000_option_override_internal (bool global_init_p) /* If little-endian, default to -mstrict-align on older processors. */ if (!BYTES_BIG_ENDIAN - && !(processor_target_table[tune_index].target_enable - & OPTION_MASK_POWER8)) + && (get_arch_flags (tune_index) & ARCH_MASK_POWER8) == 0) rs6000_isa_flags |= ~rs6000_isa_flags_explicit & OPTION_MASK_STRICT_ALIGN; /* Add some warnings for VSX. */ @@ -24605,9 +24604,6 @@ static struct rs6000_opt_mask const rs6000_opt_masks[] = { "float128", OPTION_MASK_FLOAT128_KEYWORD, false, true }, { "float128-hardware", OPTION_MASK_FLOAT128_HW, false, true }, { "fprnd", OPTION_MASK_FPRND, false, true }, - { "future", OPTION_MASK_FUTURE, false, false }, - { "power10", OPTION_MASK_POWER10, false, true }, - { "power11", OPTION_MASK_POWER11, false, false }, { "hard-dfp", OPTION_MASK_DFP, false, true }, { "htm", OPTION_MASK_HTM, false, true }, { "isel", OPTION_MASK_ISEL, false, true }, @@ -25039,6 +25035,7 @@ rs6000_pragma_target_parse (tree args, tree pop_target) tree cur_tree; struct cl_target_option *prev_opt, *cur_opt; HOST_WIDE_INT prev_flags, cur_flags, diff_flags; + HOST_WIDE_INT prev_arch, cur_arch, diff_arch; if (TARGET_DEBUG_TARGET) { @@ -25091,21 +25088,26 @@ rs6000_pragma_target_parse (tree args, tree pop_target) { prev_opt = TREE_TARGET_OPTION (prev_tree); prev_flags = prev_opt->x_rs6000_isa_flags; + prev_arch = prev_opt->x_rs6000_arch_flags; cur_opt = TREE_TARGET_OPTION (cur_tree); cur_flags = cur_opt->x_rs6000_isa_flags; + cur_arch = cur_opt->x_rs6000_arch_flags; diff_flags = (prev_flags ^ cur_flags); + diff_arch = (prev_arch ^ cur_arch); - if (diff_flags != 0) + if (diff_flags != 0 || diff_arch != 0) { /* Delete old macros. */ rs6000_target_modify_macros_ptr (false, - prev_flags & diff_flags); + prev_flags & diff_flags, + prev_arch & diff_arch); /* Define new macros. */ rs6000_target_modify_macros_ptr (true, - cur_flags & diff_flags); + cur_flags & diff_flags, + cur_arch & diff_arch); } } diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index 382d7824064..f95318dd553 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -502,12 +502,19 @@ extern int rs6000_vector_align[]; #define TARGET_MINMAX (TARGET_HARD_FLOAT && TARGET_PPC_GFXOPT \ && (TARGET_P9_MINMAX || !flag_trapping_math)) -/* Convert ISA bits like POPCNTB to PowerPC processors like POWER5. */ -#define TARGET_POWER5 TARGET_POPCNTB -#define TARGET_POWER5X TARGET_FPRND -#define TARGET_POWER6 TARGET_CMPB -#define TARGET_POWER7 TARGET_POPCNTD -#define TARGET_POWER9 TARGET_MODULO +/* In the past we represented the various power cpus (power4, power5, power6, + etc.) via ISA bits that highlighted a new instruction or we used an extra + option to represent the hardware (i.e. -mpower8-internal or -mpower10). Now + we use architecture flags for this. */ +#define TARGET_POWER5 ((rs6000_arch_flags & ARCH_MASK_POWER5) != 0) +#define TARGET_POWER5X ((rs6000_arch_flags & ARCH_MASK_POWER5X) != 0) +#define TARGET_POWER6 ((rs6000_arch_flags & ARCH_MASK_POWER6) != 0) +#define TARGET_POWER7 ((rs6000_arch_flags & ARCH_MASK_POWER7) != 0) +#define TARGET_POWER8 ((rs6000_arch_flags & ARCH_MASK_POWER8) != 0) +#define TARGET_POWER9 ((rs6000_arch_flags & ARCH_MASK_POWER9) != 0) +#define TARGET_POWER10 ((rs6000_arch_flags & ARCH_MASK_POWER10) != 0) +#define TARGET_POWER11 ((rs6000_arch_flags & ARCH_MASK_POWER11) != 0) +#define TARGET_FUTURE ((rs6000_arch_flags & ARCH_MASK_FUTURE) != 0) /* In switching from using target_flags to using rs6000_isa_flags, the options machinery creates OPTION_MASK_ instead of MASK_. The MASK_ diff --git a/gcc/config/rs6000/rs6000.opt b/gcc/config/rs6000/rs6000.opt index 66c432f1384..0d71dbaf2fc 100644 --- a/gcc/config/rs6000/rs6000.opt +++ b/gcc/config/rs6000/rs6000.opt @@ -478,9 +478,8 @@ Save the TOC in the prologue for indirect calls rather than inline. mvsx-timode Target RejectNegative Undocumented Ignore -;; This option exists only to create its MASK. It is not intended for users. mpower8-internal -Target Undocumented Mask(POWER8) Var(rs6000_isa_flags) Warn(Do not use %<-mpower8-internal%>; use %<-mcpu=power8%> instead) +Target Undocumented WarnRemoved mpower8-fusion Target Mask(P8_FUSION) Var(rs6000_isa_flags) @@ -591,13 +590,7 @@ mspeculate-indirect-jumps Target Undocumented Var(rs6000_speculate_indirect_jumps) Init(1) Save mpower10 -Target Undocumented Mask(POWER10) Var(rs6000_isa_flags) WarnRemoved - -;; Users should not use -mpower11, but we need to use a bit to identify when -;; the user changes the default cpu via #pragma GCC target("cpu=power11") -;; and then resets it later. -mpower11 -Target Undocumented Mask(POWER11) Var(rs6000_isa_flags) WarnRemoved +Target Undocumented WarnRemoved mprefixed Target Mask(PREFIXED) Var(rs6000_isa_flags) @@ -638,12 +631,6 @@ 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=