From patchwork Tue Sep 2 15:33:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyrylo Tkachov X-Patchwork-Id: 385195 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 25F7F14018A for ; Wed, 3 Sep 2014 01:34:07 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=A2n+tgoHCBxwgXvhuSN0ccYPa9l2X0T4w7WGF2hdKQg 1M5E93uPHHOqauSxk5kQttP/0WTcg7keV4v46bMwHEopWF4lQXp7YrHAwyQRQZ8l CpRm244Z4ChQugCpPlXCen4zXao6Ush+fG0HsTaohSdwcjbLRDjRCYJ2yXvPLvPo = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=DkW7NFsJfGuy5Y04pbtW3PH3bwg=; b=J6ABwzy+iFffwuwRn 1nKbTDKbqrpFqyrm54F0CQbSaiDIaWOcbaVs2Z9Yy5nnMgxsugjGmnK5VwV8IBMI J6TBBoKaGAuTi/NQBrPxvpUts70jck5NMIaTd5lkbXfzXIMzJm1czgpEUTWpRX7N 8NJpJcloq5sNc2/t5M7bm56eBs= Received: (qmail 677 invoked by alias); 2 Sep 2014 15:34:00 -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 662 invoked by uid 89); 2 Sep 2014 15:34:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: service87.mimecast.com Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 02 Sep 2014 15:33:57 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Tue, 02 Sep 2014 16:33:54 +0100 Received: from [10.1.208.24] ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 2 Sep 2014 16:33:53 +0100 Message-ID: <5405E360.4010506@arm.com> Date: Tue, 02 Sep 2014 16:33:52 +0100 From: Kyrill Tkachov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: GCC Patches CC: Ramana Radhakrishnan , Richard Earnshaw Subject: [PATCH][ARM] Fix %N output modifier X-MC-Unique: 114090216335409201 X-IsSubscribed: yes Hi all, Following the transition to UAL I noticed that the %N output modifier doesn't really work. It calls fp_const_from_val to get the VFP encoding from a real value, but fp_const_from_val only supports the floating point zero constant and ICEs for all other values, making it useless for pretty much all purposes. For example, the testcase in this patch ICEs. With the conversion to UAL we no longer output the VFP encoded form of floating point constants but rather their natural representation. This patch makes sure that %N negates its operand properly and outputs it as a normal floating point number. It also handles operand lossage (if, for example, the user passed in a register instead of a constant). Ok for upstream? 2014-09-02 Kyrylo Tkachov * config/arm/arm.c (fp_const_from_val): Delete prototype and definition. (arm_print_operand): Don't use fp_const_from_val in the 'N' case. Report unsupported operand. 2014-09-02 Kyrylo Tkachov * gcc.target/arm/n_output_modifier_1.c: New test. commit 592aa40e87285c53229ccf544691611e9c78b578 Author: Kyrylo Tkachov Date: Wed Aug 13 14:08:02 2014 +0100 [ARM] Fix %N output modifier diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 5f7cbb1..a48ca4e 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -100,7 +100,6 @@ static void arm_atomic_assign_expand_fenv (tree *hold, tree *clear, tree *update static void arm_print_operand (FILE *, rtx, int); static void arm_print_operand_address (FILE *, rtx); static bool arm_print_operand_punct_valid_p (unsigned char code); -static const char *fp_const_from_val (REAL_VALUE_TYPE *); static arm_cc get_arm_condition_code (rtx); static HOST_WIDE_INT int_log2 (HOST_WIDE_INT); static const char *output_multi_immediate (rtx *, const char *, const char *, @@ -17534,17 +17533,6 @@ arm_reorg (void) /* Routines to output assembly language. */ -/* Return string representation of passed in real value. */ -static const char * -fp_const_from_val (REAL_VALUE_TYPE *r) -{ - if (!fp_consts_inited) - init_fp_table (); - - gcc_assert (REAL_VALUES_EQUAL (*r, value_fp0)); - return "0"; -} - /* OPERANDS[0] is the entire list of insns that constitute pop, OPERANDS[1] is the base register, RETURN_PC is true iff return insn is in the list, UPDATE is true iff the list contains explicit @@ -21533,13 +21521,21 @@ arm_print_operand (FILE *stream, rtx x, int code) case 'N': { - REAL_VALUE_TYPE r; - REAL_VALUE_FROM_CONST_DOUBLE (r, x); - r = real_value_negate (&r); - fprintf (stream, "%s", fp_const_from_val (&r)); - } - return; + if (CONST_DOUBLE_P (x)) + { + char fpstr[20]; + REAL_VALUE_TYPE r; + + REAL_VALUE_FROM_CONST_DOUBLE (r, x); + r = real_value_negate (&r); + real_to_decimal (fpstr, &r, sizeof (fpstr), 0, 1); + fprintf (stream, "%s", fpstr); + } + else + output_operand_lossage ("Unsupported operand for code '%c'", code); + return; + } /* An integer or symbol address without a preceding # sign. */ case 'c': switch (GET_CODE (x)) diff --git a/gcc/testsuite/gcc.target/arm/n_output_modifier_1.c b/gcc/testsuite/gcc.target/arm/n_output_modifier_1.c new file mode 100644 index 0000000..e94914b --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/n_output_modifier_1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target arm_vfp_ok } */ +/* { dg-final { scan-assembler-times "-5.0e-1" 1 } } */ + + +int +foo (int a) +{ + int result = 0; + __asm__ ("%0, %N1" + : "=r"(result) + : "Dt"(0.5) + : ); + return result; +} +