From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 106655 invoked by alias); 20 Jul 2017 14:19:16 -0000 Mailing-List: contact newlib-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-cvs-owner@sourceware.org Received: (qmail 106589 invoked by uid 9078); 20 Jul 2017 14:19:15 -0000 Date: Thu, 20 Jul 2017 14:19:00 -0000 Message-ID: <20170720141915.106587.qmail@sourceware.org> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] arm: Update strcpy.c to use UAL syntax. X-Act-Checkin: newlib-cygwin X-Git-Author: Ian Tessier via newlib X-Git-Refname: refs/heads/master X-Git-Oldrev: d2ae2f00b8459d47be8996b2e0f76cdc89aae37e X-Git-Newrev: 4bce7ecbe19c1c264e3b5b3eac9582c429f12caa X-SW-Source: 2017-q3/txt/msg00018.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=4bce7ecbe19c1c264e3b5b3eac9582c429f12caa commit 4bce7ecbe19c1c264e3b5b3eac9582c429f12caa Author: Ian Tessier via newlib Date: Wed Jul 19 14:02:43 2017 -0700 arm: Update strcpy.c to use UAL syntax. 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. Diff: --- 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 f1205b9..1544511 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"