From patchwork Mon Jul 2 21:50:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Bergner X-Patchwork-Id: 938252 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-480875-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="iHrihZrx"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41KLXN0bVFz9s29 for ; Tue, 3 Jul 2018 07:50:26 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:date:mime-version:content-type :content-transfer-encoding:message-id; q=dns; s=default; b=i9VPn 6FqxMx+nkUCcoe1StdofW1qbq2421ZKCk+UG356B9wKH7XlaeJpvV4U9nkB7TSuz qvPD9EyW16eRIeCAPuxpwPkoXPmJJ0GxZjOzij0Ifn2/V8eqdivtFOnvxKY5NjvG Y4nSAudRd0GHeBHcGexEhPpb72kOgnZYeoYWMQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:date:mime-version:content-type :content-transfer-encoding:message-id; s=default; bh=sH5GHXkdins kms0JT6y8C223338=; b=iHrihZrxxUDgy619aj4H8a+7PfclquXjntldNFV6c86 250gobqWJbmrbs4Y7uvZiWO/7XG57uubTs8YmifKO6+d95YjADBUhfk9+XT5miVb E1CbMcnV0eORQDmZcz1g/3QU/RVjUDnS1XbM8pPlFt0EYssF9E3yKIAUdD/Aqawk = Received: (qmail 18640 invoked by alias); 2 Jul 2018 21:50:20 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 18631 invoked by uid 89); 2 Jul 2018 21:50:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=prepared X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 02 Jul 2018 21:50:17 +0000 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w62Lo39P028966 for ; Mon, 2 Jul 2018 17:50:16 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0b-001b2d01.pphosted.com with ESMTP id 2jyqp6k6av-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 02 Jul 2018 17:50:15 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 2 Jul 2018 15:50:15 -0600 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 2 Jul 2018 15:50:13 -0600 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w62LoCtP11141418 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 2 Jul 2018 14:50:12 -0700 Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EB118BE054; Mon, 2 Jul 2018 15:50:11 -0600 (MDT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C8F27BE053; Mon, 2 Jul 2018 15:50:10 -0600 (MDT) Received: from otta.local (unknown [9.85.200.160]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 2 Jul 2018 15:50:10 -0600 (MDT) To: Segher Boessenkool , Joseph Myers Cc: GCC Patches , Jonathan Wakely , Michael Meissner , Bill Schmidt From: Peter Bergner Subject: [PING][PATCH, rs6000, C/C++] Fix PR target/86324: divkc3-1.c FAILs when compiling with -mabi=ieeelongdouble Date: Mon, 2 Jul 2018 16:50:09 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 x-cbid: 18070221-0004-0000-0000-0000145D9C54 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009297; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01055642; UDB=6.00541453; IPR=6.00833564; MB=3.00021968; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-02 21:50:14 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18070221-0005-0000-0000-000087F283E2 Message-Id: <209b9cc5-d464-0dd0-deae-b06452a3930f@linux.ibm.com> X-IsSubscribed: yes I'd like to PING: https://gcc.gnu.org/ml/gcc-patches/2018-06/msg01713.html I've included the entire patch below, since I missed the test cases in the original submission and Segher asked for some updated text for the hook documentation which I've included below. Peter gcc/ PR target/86324 * target.def (translate_mode_attribute): New hook. * targhooks.h (default_translate_mode_attribute): Declare. * targhooks.c (default_translate_mode_attribute): New function. * doc/tm.texi.in (TARGET_TRANSLATE_MODE_ATTRIBUTE): New hook. * doc/tm.texi: Regenerate. * config/rs6000/rs6000.c (TARGET_TRANSLATE_MODE_ATTRIBUTE): Define. (rs6000_translate_mode_attribute): New function. gcc/c-family/ PR target/86324 * c-attribs.c (handle_mode_attribute): Call new translate_mode_attribute target hook. gcc/testsuite/ PR target/86324 gcc.target/powerpc/pr86324-1.c: New test. gcc.target/powerpc/pr86324-2.c: Likewise. Index: gcc/target.def =================================================================== --- gcc/target.def (revision 262159) +++ gcc/target.def (working copy) @@ -3310,6 +3310,16 @@ constants can be done inline. The funct HOST_WIDE_INT, (const_tree constant, HOST_WIDE_INT basic_align), default_constant_alignment) +DEFHOOK +(translate_mode_attribute, + "Define this hook if during mode attribute processing, the port should\n\ +translate machine_mode @var{mode} to another mode. For example, rs6000's\n\ +@code{KFmode}, when it is the same as @code{TFmode}.\n\ +\n\ +The default version of the hook returns that mode that was passed in.", + machine_mode, (machine_mode mode), + default_translate_mode_attribute) + /* True if MODE is valid for the target. By "valid", we mean able to be manipulated in non-trivial ways. In particular, this means all the arithmetic is supported. */ Index: gcc/targhooks.c =================================================================== --- gcc/targhooks.c (revision 262159) +++ gcc/targhooks.c (working copy) @@ -393,6 +393,14 @@ default_mangle_assembler_name (const cha return get_identifier (stripped); } +/* The default implementation of TARGET_TRANSLATE_MODE_ATTRIBUTE. */ + +machine_mode +default_translate_mode_attribute (machine_mode mode) +{ + return mode; +} + /* True if MODE is valid for the target. By "valid", we mean able to be manipulated in non-trivial ways. In particular, this means all the arithmetic is supported. Index: gcc/targhooks.h =================================================================== --- gcc/targhooks.h (revision 262159) +++ gcc/targhooks.h (working copy) @@ -72,6 +72,7 @@ extern void default_print_operand_addres extern bool default_print_operand_punct_valid_p (unsigned char); extern tree default_mangle_assembler_name (const char *); +extern machine_mode default_translate_mode_attribute (machine_mode); extern bool default_scalar_mode_supported_p (scalar_mode); extern bool default_libgcc_floating_mode_supported_p (scalar_float_mode); extern opt_scalar_float_mode default_floatn_mode (int, bool); Index: gcc/doc/tm.texi.in =================================================================== --- gcc/doc/tm.texi.in (revision 262159) +++ gcc/doc/tm.texi.in (working copy) @@ -3336,6 +3336,8 @@ stack. @hook TARGET_REF_MAY_ALIAS_ERRNO +@hook TARGET_TRANSLATE_MODE_ATTRIBUTE + @hook TARGET_SCALAR_MODE_SUPPORTED_P @hook TARGET_VECTOR_MODE_SUPPORTED_P Index: gcc/doc/tm.texi =================================================================== --- gcc/doc/tm.texi (revision 262159) +++ gcc/doc/tm.texi (working copy) @@ -4255,6 +4255,14 @@ hook returns true for both @code{ptr_mod Define this to return nonzero if the memory reference @var{ref} may alias with the system C library errno location. The default version of this hook assumes the system C library errno location is either a declaration of type int or accessed by dereferencing a pointer to int. @end deftypefn +@deftypefn {Target Hook} machine_mode TARGET_TRANSLATE_MODE_ATTRIBUTE (machine_mode @var{mode}) +Define this hook if during mode attribute processing, the port should +translate machine_mode @var{mode} to another mode. For example, rs6000's +@code{KFmode}, when it is the same as @code{TFmode}. + +The default version of the hook returns that mode that was passed in. +@end deftypefn + @deftypefn {Target Hook} bool TARGET_SCALAR_MODE_SUPPORTED_P (scalar_mode @var{mode}) Define this to return nonzero if the port is prepared to handle insns involving scalar mode @var{mode}. For a scalar mode to be Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 262159) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -1802,6 +1802,9 @@ static const struct attribute_spec rs600 #undef TARGET_EH_RETURN_FILTER_MODE #define TARGET_EH_RETURN_FILTER_MODE rs6000_eh_return_filter_mode +#undef TARGET_TRANSLATE_MODE_ATTRIBUTE +#define TARGET_TRANSLATE_MODE_ATTRIBUTE rs6000_translate_mode_attribute + #undef TARGET_SCALAR_MODE_SUPPORTED_P #define TARGET_SCALAR_MODE_SUPPORTED_P rs6000_scalar_mode_supported_p @@ -35677,6 +35680,18 @@ rs6000_eh_return_filter_mode (void) return TARGET_32BIT ? SImode : word_mode; } +/* Target hook for translate_mode_attribute. */ +static machine_mode +rs6000_translate_mode_attribute (machine_mode mode) +{ + if ((FLOAT128_IEEE_P (mode) + && ieee128_float_type_node == long_double_type_node) + || (FLOAT128_IBM_P (mode) + && ibm128_float_type_node == long_double_type_node)) + return COMPLEX_MODE_P (mode) ? E_TCmode : E_TFmode; + return mode; +} + /* Target hook for scalar_mode_supported_p. */ static bool rs6000_scalar_mode_supported_p (scalar_mode mode) Index: gcc/c-family/c-attribs.c =================================================================== --- gcc/c-family/c-attribs.c (revision 262159) +++ gcc/c-family/c-attribs.c (working copy) @@ -1517,6 +1517,10 @@ handle_mode_attribute (tree *node, tree return NULL_TREE; } + /* Allow the target a chance to translate MODE into something supported. + See PR86324. */ + mode = targetm.translate_mode_attribute (mode); + valid_mode = false; switch (GET_MODE_CLASS (mode)) { Index: gcc/testsuite/gcc.target/powerpc/pr86324-1.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/pr86324-1.c (nonexistent) +++ gcc/testsuite/gcc.target/powerpc/pr86324-1.c (working copy) @@ -0,0 +1,10 @@ +/* { dg-do compile { target { powerpc*-*-linux* } } } */ +/* { dg-options "-mlong-double-128 -mabi=ieeelongdouble -Wno-psabi" } */ + +typedef __complex float cflt_t __attribute__((mode(KC))); + +cflt_t +divide (cflt_t *ptr) +{ + return *ptr; +} Index: gcc/testsuite/gcc.target/powerpc/pr86324-2.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/pr86324-2.c (nonexistent) +++ gcc/testsuite/gcc.target/powerpc/pr86324-2.c (working copy) @@ -0,0 +1,10 @@ +/* { dg-do compile { target { powerpc*-*-linux* } } } */ +/* { dg-options "-mlong-double-128 -mabi=ibmlongdouble -Wno-psabi" } */ + +typedef __complex float cflt_t __attribute__((mode(IC))); + +cflt_t +divide (cflt_t *ptr) +{ + return *ptr; +}