From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 0CF64386101C for ; Fri, 8 Jan 2021 00:18:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0CF64386101C Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 10805dsd174071 for ; Thu, 7 Jan 2021 19:18:07 -0500 Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 35xcb2gh99-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 07 Jan 2021 19:18:07 -0500 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 1080CXRb014146 for ; Fri, 8 Jan 2021 00:18:05 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma03ams.nl.ibm.com with ESMTP id 35tgf8ddnd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 08 Jan 2021 00:18:05 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1080I2wI29229422 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 8 Jan 2021 00:18:02 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4EE6442049; Fri, 8 Jan 2021 00:18:02 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EAB4C42045; Fri, 8 Jan 2021 00:18:01 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.39.19]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 8 Jan 2021 00:18:01 +0000 (GMT) From: Ilya Leoshkevich To: krebbel@linux.ibm.com, stli@linux.ibm.com Cc: gcc-patches@gcc.gnu.org, Ilya Leoshkevich Subject: [PATCH] IBM Z: Introduce __LONG_DOUBLE_VX__ macro Date: Fri, 8 Jan 2021 01:17:53 +0100 Message-Id: <20210108001753.1706076-1-iii@linux.ibm.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343, 18.0.737 definitions=2021-01-07_11:2021-01-07, 2021-01-07 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 adultscore=0 bulkscore=0 malwarescore=0 clxscore=1015 priorityscore=1501 phishscore=0 mlxscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101070132 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jan 2021 00:18:19 -0000 Bootstrapped and regtested on s390x-redhat-linux. Ok for master? Give end users the opportunity to find out whether long doubles are stored in floating-point register pairs or in vector registers, so that they could fine-tune their asm statements. gcc/ChangeLog: 2020-12-14 Ilya Leoshkevich * config/s390/s390-c.c (s390_def_or_undef_macro): Accept callables instead of mask values. (struct target_flag_set_p): New predicate. (s390_cpu_cpp_builtins_internal): Define or undefine __LONG_DOUBLE_VX__ macro. gcc/testsuite/ChangeLog: 2020-12-14 Ilya Leoshkevich * gcc.target/s390/vector/long-double-vx-macro-off.c: New test. * gcc.target/s390/vector/long-double-vx-macro-on.c: New test. --- gcc/config/s390/s390-c.c | 59 ++++++++++++------- .../s390/vector/long-double-vx-macro-off-on.c | 11 ++++ .../s390/vector/long-double-vx-macro-on-off.c | 11 ++++ 3 files changed, 60 insertions(+), 21 deletions(-) create mode 100644 gcc/testsuite/gcc.target/s390/vector/long-double-vx-macro-off-on.c create mode 100644 gcc/testsuite/gcc.target/s390/vector/long-double-vx-macro-on-off.c diff --git a/gcc/config/s390/s390-c.c b/gcc/config/s390/s390-c.c index 95cd2df505d..29b87d76ab1 100644 --- a/gcc/config/s390/s390-c.c +++ b/gcc/config/s390/s390-c.c @@ -294,9 +294,9 @@ s390_macro_to_expand (cpp_reader *pfile, const cpp_token *tok) /* Helper function that defines or undefines macros. If SET is true, the macro MACRO_DEF is defined. If SET is false, the macro MACRO_UNDEF is undefined. Nothing is done if SET and WAS_SET have the same value. */ +template static void -s390_def_or_undef_macro (cpp_reader *pfile, - unsigned int mask, +s390_def_or_undef_macro (cpp_reader *pfile, F is_set, const struct cl_target_option *old_opts, const struct cl_target_option *new_opts, const char *macro_def, const char *macro_undef) @@ -304,8 +304,8 @@ s390_def_or_undef_macro (cpp_reader *pfile, bool was_set; bool set; - was_set = (!old_opts) ? false : old_opts->x_target_flags & mask; - set = new_opts->x_target_flags & mask; + was_set = (!old_opts) ? false : is_set (old_opts); + set = is_set (new_opts); if (was_set == set) return; if (set) @@ -314,6 +314,19 @@ s390_def_or_undef_macro (cpp_reader *pfile, cpp_undef (pfile, macro_undef); } +struct target_flag_set_p +{ + target_flag_set_p (unsigned int mask) : m_mask (mask) {} + + bool + operator() (const struct cl_target_option *opts) const + { + return opts->x_target_flags & m_mask; + } + + unsigned int m_mask; +}; + /* Internal function to either define or undef the appropriate system macros. */ static void @@ -321,18 +334,18 @@ s390_cpu_cpp_builtins_internal (cpp_reader *pfile, struct cl_target_option *opts, const struct cl_target_option *old_opts) { - s390_def_or_undef_macro (pfile, MASK_OPT_HTM, old_opts, opts, - "__HTM__", "__HTM__"); - s390_def_or_undef_macro (pfile, MASK_OPT_VX, old_opts, opts, - "__VX__", "__VX__"); - s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts, - "__VEC__=10303", "__VEC__"); - s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts, - "__vector=__attribute__((vector_size(16)))", + s390_def_or_undef_macro (pfile, target_flag_set_p (MASK_OPT_HTM), old_opts, + opts, "__HTM__", "__HTM__"); + s390_def_or_undef_macro (pfile, target_flag_set_p (MASK_OPT_VX), old_opts, + opts, "__VX__", "__VX__"); + s390_def_or_undef_macro (pfile, target_flag_set_p (MASK_ZVECTOR), old_opts, + opts, "__VEC__=10303", "__VEC__"); + s390_def_or_undef_macro (pfile, target_flag_set_p (MASK_ZVECTOR), old_opts, + opts, "__vector=__attribute__((vector_size(16)))", "__vector__"); - s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts, - "__bool=__attribute__((s390_vector_bool)) unsigned", - "__bool"); + s390_def_or_undef_macro ( + pfile, target_flag_set_p (MASK_ZVECTOR), old_opts, opts, + "__bool=__attribute__((s390_vector_bool)) unsigned", "__bool"); { char macro_def[64]; gcc_assert (s390_arch != PROCESSOR_NATIVE); @@ -340,16 +353,20 @@ s390_cpu_cpp_builtins_internal (cpp_reader *pfile, cpp_undef (pfile, "__ARCH__"); cpp_define (pfile, macro_def); } + s390_def_or_undef_macro ( + pfile, + [] (const struct cl_target_option *opts) { return TARGET_Z14_P (opts); }, + old_opts, opts, "__LONG_DOUBLE_VX__", "__LONG_DOUBLE_VX__"); if (!flag_iso) { - s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts, - "__VECTOR_KEYWORD_SUPPORTED__", + s390_def_or_undef_macro (pfile, target_flag_set_p (MASK_ZVECTOR), + old_opts, opts, "__VECTOR_KEYWORD_SUPPORTED__", "__VECTOR_KEYWORD_SUPPORTED__"); - s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts, - "vector=vector", "vector"); - s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts, - "bool=bool", "bool"); + s390_def_or_undef_macro (pfile, target_flag_set_p (MASK_ZVECTOR), + old_opts, opts, "vector=vector", "vector"); + s390_def_or_undef_macro (pfile, target_flag_set_p (MASK_ZVECTOR), + old_opts, opts, "bool=bool", "bool"); if (TARGET_ZVECTOR_P (opts->x_target_flags) && __vector_keyword == NULL) { __vector_keyword = get_identifier ("__vector"); diff --git a/gcc/testsuite/gcc.target/s390/vector/long-double-vx-macro-off-on.c b/gcc/testsuite/gcc.target/s390/vector/long-double-vx-macro-off-on.c new file mode 100644 index 00000000000..2d67679bb11 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/vector/long-double-vx-macro-off-on.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target target_attribute } */ +/* { dg-options "-march=z14" } */ +#if !defined(__LONG_DOUBLE_VX__) +#error +#endif + +#pragma GCC target("arch=zEC12") +#if defined(__LONG_DOUBLE_VX__) +#error +#endif diff --git a/gcc/testsuite/gcc.target/s390/vector/long-double-vx-macro-on-off.c b/gcc/testsuite/gcc.target/s390/vector/long-double-vx-macro-on-off.c new file mode 100644 index 00000000000..6f264313408 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/vector/long-double-vx-macro-on-off.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target target_attribute } */ +/* { dg-options "-march=z13" } */ +#if defined(__LONG_DOUBLE_VX__) +#error +#endif + +#pragma GCC target("arch=z15") +#if !defined(__LONG_DOUBLE_VX__) +#error +#endif -- 2.26.2