~ubuntu-branches/ubuntu/precise/eglibc/precise-201308281639

« back to all changes in this revision

Viewing changes to sysdeps/powerpc/powerpc32/power7/strcasecmp.S

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-02-08 01:58:09 UTC
  • mfrom: (1.5.3) (288.1.12 precise)
  • Revision ID: package-import@ubuntu.com-20120208015809-ulscst7uteq3e22z
Tags: 2.15~pre6-0ubuntu10
Merge from Debian (r5151, 2.13-26).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Optimized strcasecmp implementation for PowerPC32.
 
2
   Copyright (C) 2011 Free Software Foundation, Inc.
 
3
   This file is part of the GNU C Library.
 
4
 
 
5
   The GNU C Library is free software; you can redistribute it and/or
 
6
   modify it under the terms of the GNU Lesser General Public
 
7
   License as published by the Free Software Foundation; either
 
8
   version 2.1 of the License, or (at your option) any later version.
 
9
 
 
10
   The GNU C Library is distributed in the hope that it will be useful,
 
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
   Lesser General Public License for more details.
 
14
 
 
15
   You should have received a copy of the GNU Lesser General Public
 
16
   License along with the GNU C Library; if not, write to the Free
 
17
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 
18
   02111-1307 USA.  */
 
19
 
 
20
#include <sysdep.h>
 
21
#include <bp-sym.h>
 
22
#include <bp-asm.h>
 
23
#include <locale-defines.h>
 
24
 
 
25
/* int [r3] strcasecmp (const char *s1 [r3], const char *s2 [r4] )
 
26
 
 
27
   or if defined USE_IN_EXTENDED_LOCALE_MODEL:
 
28
 
 
29
   int [r3] strcasecmp_l (const char *s1 [r3], const char *s2 [r4],
 
30
                          __locale_t loc [r5]) */
 
31
 
 
32
#ifndef STRCMP
 
33
# define __STRCMP __strcasecmp
 
34
# define STRCMP   strcasecmp
 
35
#endif
 
36
 
 
37
ENTRY (BP_SYM (__STRCMP))
 
38
 
 
39
#define rRTN    r3      /* Return value */
 
40
#define rSTR1   r5      /* 1st string */
 
41
#define rSTR2   r4      /* 2nd string */
 
42
#define rLOCARG r5      /* 3rd argument: locale_t */
 
43
#define rCHAR1  r6      /* Byte readed from 1st string */
 
44
#define rCHAR2  r7      /* Byte readed from 2nd string */
 
45
#define rADDR1  r8      /* Address of tolower(rCHAR1) */
 
46
#define rADDR2  r12     /* Address of tolower(rCHAR2) */
 
47
#define rLWR1   r8      /* Byte tolower(rCHAR1) */
 
48
#define rLWR2   r12     /* Byte tolower(rCHAR2) */
 
49
#define rTMP    r0
 
50
#define rGOT    r9      /* Address of the Global Offset Table */
 
51
#define rLOC    r11     /* Default locale address */
 
52
 
 
53
        cmpw    cr7, r3, r4
 
54
#ifndef USE_IN_EXTENDED_LOCALE_MODEL
 
55
# ifdef SHARED
 
56
        mflr    rTMP
 
57
        bcl     20,31,.L1
 
58
.L1:    mflr    rGOT
 
59
        addis   rGOT, rGOT, _GLOBAL_OFFSET_TABLE_-.L1@ha
 
60
        addi    rGOT, rGOT, _GLOBAL_OFFSET_TABLE_-.L1@l
 
61
        lwz     rLOC, __libc_tsd_LOCALE@got@tprel(rGOT)
 
62
        add     rLOC, rLOC, __libc_tsd_LOCALE@tls
 
63
        lwz     rLOC, 0(rLOC)
 
64
        mtlr    rTMP
 
65
# else
 
66
        lis     rTMP,_GLOBAL_OFFSET_TABLE_@ha
 
67
        la      rLOC,_GLOBAL_OFFSET_TABLE_@l(rTMP)
 
68
        lwz     rLOC, __libc_tsd_LOCALE@got@tprel(rGOT)
 
69
        add     rLOC, rLOC, __libc_tsd_LOCALE@tls
 
70
        lwz     rLOC, 0(rLOC)
 
71
# endif /* SHARED */
 
72
#else
 
73
        mr      rLOC, rLOCARG
 
74
#endif
 
75
        mr      rSTR1, rRTN
 
76
        lwz     rLOC, LOCALE_CTYPE_TOLOWER(rLOC)
 
77
        li      rRTN, 0
 
78
        beqlr   cr7
 
79
 
 
80
        /* Unrolling loop for POWER: loads are done with 'lbz' plus
 
81
        offset and string descriptors are only updated in the end
 
82
        of loop unrolling. */
 
83
 
 
84
L(loop):
 
85
        lbz     rCHAR1, 0(rSTR1)        /* Load char from s1 */
 
86
        lbz     rCHAR2, 0(rSTR2)        /* Load char from s2 */
 
87
        sldi    rADDR1, rCHAR1, 2       /* Calculate address for tolower(*s1) */
 
88
        sldi    rADDR2, rCHAR2, 2       /* Calculate address for tolower(*s2) */
 
89
        lwzx    rLWR1, rLOC, rADDR1     /* Load tolower(*s1) */
 
90
        lwzx    rLWR2, rLOC, rADDR2     /* Load tolower(*s2) */
 
91
        cmpwi   cr7, rCHAR1, 0          /* *s1 == '\0' ? */
 
92
        subf.   r3, rLWR2, rLWR1
 
93
        bnelr
 
94
        beqlr   cr7
 
95
        lbz     rCHAR1, 1(rSTR1)
 
96
        lbz     rCHAR2, 1(rSTR2)
 
97
        sldi    rADDR1, rCHAR1, 2
 
98
        sldi    rADDR2, rCHAR2, 2
 
99
        lwzx    rLWR1, rLOC, rADDR1
 
100
        lwzx    rLWR2, rLOC, rADDR2
 
101
        cmpwi   cr7, rCHAR1, 0
 
102
        subf.   r3, rLWR2, rLWR1
 
103
        bnelr
 
104
        beqlr   cr7
 
105
        lbz     rCHAR1, 2(rSTR1)
 
106
        lbz     rCHAR2, 2(rSTR2)
 
107
        sldi    rADDR1, rCHAR1, 2
 
108
        sldi    rADDR2, rCHAR2, 2
 
109
        lwzx    rLWR1, rLOC, rADDR1
 
110
        lwzx    rLWR2, rLOC, rADDR2
 
111
        cmpwi   cr7, rCHAR1, 0
 
112
        subf.   r3, rLWR2, rLWR1
 
113
        bnelr
 
114
        beqlr   cr7
 
115
        lbz     rCHAR1, 3(rSTR1)
 
116
        lbz     rCHAR2, 3(rSTR2)
 
117
        /* Increment both string descriptors */
 
118
        addi    rSTR1, rSTR1, 4
 
119
        addi    rSTR2, rSTR2, 4
 
120
        sldi    rADDR1, rCHAR1, 2
 
121
        sldi    rADDR2, rCHAR2, 2
 
122
        lwzx    rLWR1, rLOC, rADDR1
 
123
        lwzx    rLWR2, rLOC, rADDR2
 
124
        cmpwi   cr7, rCHAR1, 0
 
125
        subf.   r3, rLWR2, rLWR1
 
126
        bnelr
 
127
        bne     cr7,L(loop)
 
128
        blr
 
129
END (BP_SYM (__STRCMP))
 
130
 
 
131
weak_alias (BP_SYM (__STRCMP), BP_SYM (STRCMP))
 
132
libc_hidden_builtin_def (__STRCMP)