From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14973 invoked by alias); 21 Jul 2017 10:21:40 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Received: (qmail 14944 invoked by uid 89); 21 Jul 2017 10:21:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: foss.arm.com Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 21 Jul 2017 10:21:37 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 18CE180D; Fri, 21 Jul 2017 03:21:36 -0700 (PDT) Received: from e105689-lin.cambridge.arm.com (e105689-lin.cambridge.arm.com [10.2.207.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6A32E3F483; Fri, 21 Jul 2017 03:21:35 -0700 (PDT) Subject: Re: [PATCH] arm: Update strcpy.c to use UAL syntax. To: Ian Tessier , newlib@sourceware.org References: <20170719210243.8975-1-itessier@google.com> From: "Richard Earnshaw (lists)" Message-ID: <931f1851-2170-c1f0-2b0c-ee5a4f6e41bd@arm.com> Date: Fri, 21 Jul 2017 10:21:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170719210243.8975-1-itessier@google.com> Content-Type: multipart/mixed; boundary="------------C6B11EF840FCA6EB7EB3F693" X-SW-Source: 2017/txt/msg00614.txt.bz2 This is a multi-part message in MIME format. --------------C6B11EF840FCA6EB7EB3F693 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-length: 2552 On 19/07/17 22:02, Ian Tessier via newlib wrote: > With this change the arm platform can now be fully compiled with Clang. > > Tested by comparing the output with GCC 4.8.2, and Clang 4.0, using a > variety of arches, big/little endianness, and arm/thumb mode to verify > the generated assembly output matches between GCC vs Clang with UAL, and > also GCC with UAL vs GCC with non-UAL, for all preprocessor code blocks. > > The only difference found is an extra nop at the end of the function > when compiled with GCC using armv7-a/thumb/little-endian/-O2 compared to > Clang. The nop is not emitted when compiled in big-endian mode. > --- > newlib/libc/machine/arm/strcpy.c | 13 +++++++------ > 1 file changed, 7 insertions(+), 6 deletions(-) > > diff --git a/newlib/libc/machine/arm/strcpy.c b/newlib/libc/machine/arm/strcpy.c > index f1205b9c1..154451110 100644 > --- a/newlib/libc/machine/arm/strcpy.c > +++ b/newlib/libc/machine/arm/strcpy.c > @@ -42,6 +42,7 @@ char* __attribute__((naked)) > strcpy (char* dst, const char* src) > { > asm ( > + ".syntax unified\n\t" > #if !(defined(__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED) || \ > (defined (__thumb__) && !defined (__thumb2__))) > #ifdef _ISA_ARM_7 > @@ -127,15 +128,15 @@ strcpy (char* dst, const char* src) > #ifdef __ARMEB__ > "tst r2, #0xff00\n\t" > "iteet ne\n\t" > - "strneh r2, [ip], #2\n\t" > + "strhne r2, [ip], #2\n\t" > "lsreq r2, r2, #8\n\t" > - "streqb r2, [ip]\n\t" > + "strbeq r2, [ip]\n\t" > "tstne r2, #0xff\n\t" > #else > "tst r2, #0xff\n\t" > "itet ne\n\t" > - "strneh r2, [ip], #2\n\t" > - "streqb r2, [ip]\n\t" > + "strhne r2, [ip], #2\n\t" > + "strbeq r2, [ip]\n\t" > "tstne r2, #0xff00\n\t" > #endif > "bne 5b\n\t" > @@ -162,9 +163,9 @@ strcpy (char* dst, const char* src) > "mov r3, r0\n\t" > "1:\n\t" > "ldrb r2, [r1]\n\t" > - "add r1, r1, #1\n\t" > + "adds r1, #1\n\t" > "strb r2, [r3]\n\t" > - "add r3, r3, #1\n\t" > + "adds r3, #1\n\t" > "cmp r2, #0\n\t" > "bne 1b\n\t" > "bx lr\n\t" > This doesn't compile on ARMv4t - you've missed the "mov r3, r0" instruction in the final hunk. Fixed thusly (pushed). ------------- ARMv4t does not support mov between two low registers. Now we use unified syntax mov instructions need converting to movs. --- newlib/libc/machine/arm/strcpy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --------------C6B11EF840FCA6EB7EB3F693 Content-Type: text/x-patch; name="strcpy.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="strcpy.patch" Content-length: 410 diff --git a/newlib/libc/machine/arm/strcpy.c b/newlib/libc/machine/arm/strcpy.c index 1544511..111528e 100644 --- a/newlib/libc/machine/arm/strcpy.c +++ b/newlib/libc/machine/arm/strcpy.c @@ -160,7 +160,7 @@ strcpy (char* dst, const char* src) "bne 1b\n\t" "bx lr\n\t" #else - "mov r3, r0\n\t" + "movs r3, r0\n\t" "1:\n\t" "ldrb r2, [r1]\n\t" "adds r1, #1\n\t" --------------C6B11EF840FCA6EB7EB3F693--