From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16457 invoked by alias); 30 Aug 2013 18:06:23 -0000 Mailing-List: contact libc-ports-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: libc-ports-owner@sourceware.org Received: (qmail 16425 invoked by uid 89); 30 Aug 2013 18:06:22 -0000 Received: from toast.topped-with-meat.com (HELO topped-with-meat.com) (204.197.218.159) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 30 Aug 2013 18:06:22 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,NO_RELAYS autolearn=ham version=3.3.2 X-HELO: topped-with-meat.com Received: by topped-with-meat.com (Postfix, from userid 5281) id 77DD12C072; Fri, 30 Aug 2013 11:06:20 -0700 (PDT) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit From: Roland McGrath To: libc-ports@sourceware.org Subject: [PATCH roland/arm-strlen] Make armv6t2 strlen work in ARM mode too. Message-Id: <20130830180620.77DD12C072@topped-with-meat.com> Date: Fri, 30 Aug 2013 18:06:00 -0000 X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=QZT14Krv c=1 sm=1 tr=0 a=WkljmVdYkabdwxfqvArNOQ==:117 a=14OXPxybAAAA:8 a=vRBpMtCMYLIA:10 a=Z6MIti7PxpgA:10 a=kj9zAlcOel0A:10 a=hOe2yjtxAAAA:8 a=cn3Z1BeM6nwA:10 a=aI0trzYrRlaJbNjGjsQA:9 a=CjuIK1q_8ugA:10 X-SW-Source: 2013-08/txt/msg00093.txt.bz2 I tested that this has no effect (assembled code wholly unchanged) on arm-linux-gnueabihf. I tested that the ARM-mode support actually works by hacking in "#define NO_THUMB" at the top and verifying no failures from 'make check subdirs=string'. Incidentally, assembly writers really ought to write more comments! For example, I deduced the only plausible reason for using an explicit bne.w and added a comment about it, but it is exactly the sort of non-obvious subtle microoptimization that desperately needed clear comments in the first place. OK for trunk? Thanks, Roland ports/ChangeLog.arm 2013-08-30 Roland McGrath * sysdeps/arm/armv6t2/strlen.S: Include first thing. [NO_THUMB]: Adapt code for ARM mode. --- a/ports/sysdeps/arm/armv6t2/strlen.S +++ b/ports/sysdeps/arm/armv6t2/strlen.S @@ -21,6 +21,7 @@ */ +#include /* This might #define NO_THUMB. */ #include #ifdef __ARMEB__ @@ -31,9 +32,24 @@ #define S2HI lsl #endif - /* This code requires Thumb. */ +#ifndef NO_THUMB +/* This code is best on Thumb. */ .thumb - .syntax unified +#else +/* Using bne.w explicitly is desirable in Thumb mode because it helps + align the following label without a nop. In ARM mode there is no + such difference. */ +.macro bne.w label + bne \label +.endm + +/* This clobbers the condition codes, which the real Thumb cbnz instruction + does not do. But it doesn't matter for any of the uses here. */ +.macro cbnz reg, label + cmp \reg, #0 + bne \label +.endm +#endif /* Parameters and result. */ #define srcin r0 @@ -130,9 +146,16 @@ ENTRY(strlen) tst tmp1, #4 pld [src, #64] S2HI tmp2, const_m1, tmp2 +#ifdef NO_THUMB + mvn tmp1, tmp2 + orr data1a, data1a, tmp1 + itt ne + orrne data1b, data1b, tmp1 +#else orn data1a, data1a, tmp2 itt ne ornne data1b, data1b, tmp2 +#endif movne data1a, const_m1 mov const_0, #0 b .Lstart_realigned