From patchwork Wed Mar 20 17:21:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Bolton X-Patchwork-Id: 229437 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 2557F2C00A7 for ; Thu, 21 Mar 2013 04:22:14 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=lANlnN3X0QxHfU5jbwMGyIifsfNr4tLD7NYGG10bu+MnbO0PkxLMK B1otO3PgAe7f11RGDREaHrdomGmUFQ12fq4APl4aKu+gWTshag2kVj4y/qltjdrK hNLrOM4eWd1LMJhzShQ9a8IPgrsF+/RHITlT7Cht/+s/hzh7dCN7d8= 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:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=+PLJ7XwX/GXGMIg8A8XsXbtVYEI=; b=G5lggGkAjpPpjlNBF3qO 4i3j5Z2hK7rYGXABOIWcvZ6y1TYKl9DDN+UBPutx5gti2Y9jIpDIofTxip4dlVWV eN6hqaeYsgaea9Boen/aD3iaXyObpfnq2IlDlwLHZU/7KmEM8gEaxExLvKnzeslo G77GO7wGUVejDF6s0CeeUgw= Received: (qmail 3427 invoked by alias); 20 Mar 2013 17:22:09 -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 3414 invoked by uid 89); 20 Mar 2013 17:22:01 -0000 X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00, MSGID_MULTIPLE_AT, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.1 Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 20 Mar 2013 17:21:58 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Wed, 20 Mar 2013 17:21:55 +0000 Received: from E102352xp ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.0); Wed, 20 Mar 2013 17:21:54 +0000 From: "Ian Bolton" To: Subject: [PATCH, AArch64] Make MOVK output operand 2 in hex Date: Wed, 20 Mar 2013 17:21:38 -0000 Message-ID: <000001ce258f$61932f70$24b98e50$@bolton@arm.com> MIME-Version: 1.0 X-MC-Unique: 113032017215505101 MOVK should not be generated with a negative immediate, which the assembler rightfully rejects. This patch makes MOVK output its 2nd operand in hex instead. Tested on bare-metal and linux. OK for trunk? Cheers, Ian 2013-03-20 Ian Bolton gcc/ * config/aarch64/aarch64.c (aarch64_print_operand): New format specifier for printing a constant in hex. * config/aarch64/aarch64.md (insv_imm): Use the X format specifier for printing second operand. testsuite/ * gcc.target/aarch64/movk.c: New test. diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 1404a70..5e51630 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -3365,6 +3365,16 @@ aarch64_print_operand (FILE *f, rtx x, char code) REGNO (x) - V0_REGNUM + (code - 'S')); break; + case 'X': + /* Print integer constant in hex. */ + if (GET_CODE (x) != CONST_INT) + { + output_operand_lossage ("invalid operand for '%%%c'", code); + return; + } + asm_fprintf (f, "0x%x", UINTVAL (x)); + break; + case 'w': case 'x': /* Print a general register name or the zero register (32-bit or diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index 40e66db..9c89413 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -850,8 +850,8 @@ (match_operand:GPI 2 "const_int_operand" "n"))] "INTVAL (operands[1]) < GET_MODE_BITSIZE (mode) && INTVAL (operands[1]) % 16 == 0 - && INTVAL (operands[2]) <= 0xffff" - "movk\\t%0, %2, lsl %1" + && UINTVAL (operands[2]) <= 0xffff" + "movk\\t%0, %X2, lsl %1" [(set_attr "v8type" "movk") (set_attr "mode" "")] ) diff --git a/gcc/testsuite/gcc.target/aarch64/movk.c b/gcc/testsuite/gcc.target/aarch64/movk.c new file mode 100644 index 0000000..e4b2209 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/movk.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ +/* { dg-options "-O2 --save-temps -fno-inline" } */ + +extern void abort (void); + +long long int +dummy_number_generator () +{ + /* { dg-final { scan-assembler "movk\tx\[0-9\]+, 0xefff, lsl 16" } } */ + /* { dg-final { scan-assembler "movk\tx\[0-9\]+, 0xc4cc, lsl 32" } } */ + /* { dg-final { scan-assembler "movk\tx\[0-9\]+, 0xfffe, lsl 48" } } */ + return -346565474575675; +} + +int +main (void) +{ + + long long int num = dummy_number_generator (); + if (num > 0) + abort (); + + /* { dg-final { scan-assembler "movk\tx\[0-9\]+, 0x4667, lsl 16" } } */ + /* { dg-final { scan-assembler "movk\tx\[0-9\]+, 0x7a3d, lsl 32" } } */ + if (num / 69313094915135 != -5) + abort (); + + return 0; +} + +/* { dg-final { cleanup-saved-temps } } */