1*c5af58b7SGuo Ren/* SPDX-License-Identifier: GPL-2.0 */ 2*c5af58b7SGuo Ren// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd. 3*c5af58b7SGuo Ren 4*c5af58b7SGuo Ren#include <linux/linkage.h> 5*c5af58b7SGuo Ren#include "sysdep.h" 6*c5af58b7SGuo Ren 7*c5af58b7SGuo RenENTRY(strlen) 8*c5af58b7SGuo Ren /* Check if the start addr is aligned. */ 9*c5af58b7SGuo Ren mov r3, r0 10*c5af58b7SGuo Ren andi r1, r0, 3 11*c5af58b7SGuo Ren movi r2, 4 12*c5af58b7SGuo Ren movi r0, 0 13*c5af58b7SGuo Ren bnez r1, .L_start_not_aligned 14*c5af58b7SGuo Ren 15*c5af58b7SGuo Ren LABLE_ALIGN 16*c5af58b7SGuo Ren.L_start_addr_aligned: 17*c5af58b7SGuo Ren /* Check if all the bytes in the word are not zero. */ 18*c5af58b7SGuo Ren ldw r1, (r3) 19*c5af58b7SGuo Ren tstnbz r1 20*c5af58b7SGuo Ren bf .L_string_tail 21*c5af58b7SGuo Ren 22*c5af58b7SGuo Ren ldw r1, (r3, 4) 23*c5af58b7SGuo Ren addi r0, 4 24*c5af58b7SGuo Ren tstnbz r1 25*c5af58b7SGuo Ren bf .L_string_tail 26*c5af58b7SGuo Ren 27*c5af58b7SGuo Ren ldw r1, (r3, 8) 28*c5af58b7SGuo Ren addi r0, 4 29*c5af58b7SGuo Ren tstnbz r1 30*c5af58b7SGuo Ren bf .L_string_tail 31*c5af58b7SGuo Ren 32*c5af58b7SGuo Ren ldw r1, (r3, 12) 33*c5af58b7SGuo Ren addi r0, 4 34*c5af58b7SGuo Ren tstnbz r1 35*c5af58b7SGuo Ren bf .L_string_tail 36*c5af58b7SGuo Ren 37*c5af58b7SGuo Ren ldw r1, (r3, 16) 38*c5af58b7SGuo Ren addi r0, 4 39*c5af58b7SGuo Ren tstnbz r1 40*c5af58b7SGuo Ren bf .L_string_tail 41*c5af58b7SGuo Ren 42*c5af58b7SGuo Ren ldw r1, (r3, 20) 43*c5af58b7SGuo Ren addi r0, 4 44*c5af58b7SGuo Ren tstnbz r1 45*c5af58b7SGuo Ren bf .L_string_tail 46*c5af58b7SGuo Ren 47*c5af58b7SGuo Ren ldw r1, (r3, 24) 48*c5af58b7SGuo Ren addi r0, 4 49*c5af58b7SGuo Ren tstnbz r1 50*c5af58b7SGuo Ren bf .L_string_tail 51*c5af58b7SGuo Ren 52*c5af58b7SGuo Ren ldw r1, (r3, 28) 53*c5af58b7SGuo Ren addi r0, 4 54*c5af58b7SGuo Ren tstnbz r1 55*c5af58b7SGuo Ren bf .L_string_tail 56*c5af58b7SGuo Ren 57*c5af58b7SGuo Ren addi r0, 4 58*c5af58b7SGuo Ren addi r3, 32 59*c5af58b7SGuo Ren br .L_start_addr_aligned 60*c5af58b7SGuo Ren 61*c5af58b7SGuo Ren.L_string_tail: 62*c5af58b7SGuo Ren# ifdef __CSKYBE__ 63*c5af58b7SGuo Ren xtrb0 r3, r1 64*c5af58b7SGuo Ren bez r3, .L_return 65*c5af58b7SGuo Ren addi r0, 1 66*c5af58b7SGuo Ren xtrb1 r3, r1 67*c5af58b7SGuo Ren bez r3, .L_return 68*c5af58b7SGuo Ren addi r0, 1 69*c5af58b7SGuo Ren xtrb2 r3, r1 70*c5af58b7SGuo Ren bez r3, .L_return 71*c5af58b7SGuo Ren addi r0, 1 72*c5af58b7SGuo Ren# else 73*c5af58b7SGuo Ren xtrb3 r3, r1 74*c5af58b7SGuo Ren bez r3, .L_return 75*c5af58b7SGuo Ren addi r0, 1 76*c5af58b7SGuo Ren xtrb2 r3, r1 77*c5af58b7SGuo Ren bez r3, .L_return 78*c5af58b7SGuo Ren addi r0, 1 79*c5af58b7SGuo Ren xtrb1 r3, r1 80*c5af58b7SGuo Ren bez r3, .L_return 81*c5af58b7SGuo Ren addi r0, 1 82*c5af58b7SGuo Ren# endif /* !__CSKYBE__ */ 83*c5af58b7SGuo Ren 84*c5af58b7SGuo Ren.L_return: 85*c5af58b7SGuo Ren rts 86*c5af58b7SGuo Ren 87*c5af58b7SGuo Ren.L_start_not_aligned: 88*c5af58b7SGuo Ren sub r2, r2, r1 89*c5af58b7SGuo Ren.L_start_not_aligned_loop: 90*c5af58b7SGuo Ren ldb r1, (r3) 91*c5af58b7SGuo Ren PRE_BNEZAD (r2) 92*c5af58b7SGuo Ren addi r3, 1 93*c5af58b7SGuo Ren bez r1, .L_return 94*c5af58b7SGuo Ren addi r0, 1 95*c5af58b7SGuo Ren BNEZAD (r2, .L_start_not_aligned_loop) 96*c5af58b7SGuo Ren br .L_start_addr_aligned 97*c5af58b7SGuo RenENDPROC(strlen) 98