From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32815 invoked by alias); 19 Jul 2017 21:02:59 -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 32733 invoked by uid 89); 19 Jul 2017 21:02:58 -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,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=tst, H*F:D*google.com, Hx-languages-length:1903, H*MI:google X-HELO: mail-wr0-f202.google.com Received: from mail-wr0-f202.google.com (HELO mail-wr0-f202.google.com) (209.85.128.202) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 19 Jul 2017 21:02:57 +0000 Received: by mail-wr0-f202.google.com with SMTP id 12so149695wrb.8 for ; Wed, 19 Jul 2017 14:02:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to:cc; bh=63QTzTDLubsnZoEufAVb8Z7ps/EaOoHQN8yRvc5LbNg=; b=cgi+eZ0IkPlCETapi/ROd7vTwj/UmItvhr7IjxdGTFmU1S58D3QVYgzCW3jFwmOZMy aHVDXYMiWWgJ0CoJjyNaRXSCZomXaCEE3OYPHEYYRqwo5YYb/WuebB0MXcKIhvi7L3ls +F80vZpODjuTibn2u3pFYJlUrh8d260Uvt7lCA+bNiB+LunZFPd6HGFfG7BMG+3TkUPj 2PQylg9kiOlZ19/QTi0qReYTEMjbpx8NPUfQkv6Hvyf2OGNcYBiiNWU7kyRfsG69sL8w LYEuMPS2M4eDn/Pm/EGwj/8EWOBTo11Qd8x1BL7d0AhR0y0l0nX7v+hPTDp7BA+AuabR 58EA== X-Gm-Message-State: AIVw113HAeriW8Q9wuJ6q5hQLbpFucieOzFxSZ7FvsVde1DYjUyVM0/j HYVr1s1fCHIrWBayTj3DpJTalXqSXSji/uFet3JxvCLyN8qiFbzAu1qvhe2G9RJolxM9xmprOiC cTfP+/eN9fVAKNwsrwCLJ4Dmt4zAlfeidAvhkkRDfqqtT8p7a5KltlEo2 MIME-Version: 1.0 X-Received: by 10.28.156.210 with SMTP id f201mr123101wme.14.1500498174732; Wed, 19 Jul 2017 14:02:54 -0700 (PDT) Date: Wed, 19 Jul 2017 21:02:00 -0000 Message-Id: <20170719210243.8975-1-itessier@google.com> Subject: [PATCH] arm: Update strcpy.c to use UAL syntax. From: "Ian Tessier via newlib" Reply-To: Ian Tessier To: newlib@sourceware.org Cc: Ian Tessier Content-Type: text/plain; charset="UTF-8" X-SW-Source: 2017/txt/msg00607.txt.bz2 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" -- 2.14.0.rc0.284.gd933b75aa4-goog