CWG 616, 1213 - value category of subobject references.
[official-gcc.git] / libgcc / config / rl78 / bit-count.S
blob64619f7aabcb164adcfd2c192a63ea91b341ec13
1 ;   Copyright (C) 2012-2018 Free Software Foundation, Inc.
2 ;   Contributed by Red Hat.
3
4 ; This file is free software; you can redistribute it and/or modify it
5 ; under the terms of the GNU General Public License as published by the
6 ; Free Software Foundation; either version 3, or (at your option) any
7 ; later version.
8
9 ; This file is distributed in the hope that it will be useful, but
10 ; WITHOUT ANY WARRANTY; without even the implied warranty of
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 ; General Public License for more details.
13
14 ; Under Section 7 of GPL version 3, you are granted additional
15 ; permissions described in the GCC Runtime Library Exception, version
16 ; 3.1, as published by the Free Software Foundation.
18 ; You should have received a copy of the GNU General Public License and
19 ; a copy of the GCC Runtime Library Exception along with this program;
20 ; see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
21 ; <http://www.gnu.org/licenses/>.
23 #include "vregs.h"
25 START_FUNC      ___clzhi2
26         ;; Argument is in [SP+4], return in R8.
27         movw    ax, [SP+4]
29         .global __clzhi2_internal
30 __clzhi2_internal:
31         movw    r8, #16
32         cmpw    ax, #0
33         bz      $clzhi2_is_zero
34         mov     e, #0xff
36         inc     e
37         shlw    ax, 1
38         bnc     $1b
39         mov     a, e
40         mov     r8, a
41 clzhi2_is_zero:
42         ret
43 END_FUNC        ___clzhi2
46 START_FUNC      ___clzsi2
47         ;; Argument is in [SP+6]:[SP+4], return in R8.
48         movw    ax, [SP+6]
49         cmpw    ax, #0
50         bnz     $__clzhi2_internal
51         movw    ax, [SP+4]
52         call    !__clzhi2_internal
53         movw    ax, r8
54         addw    ax, #16
55         movw    r8, ax
56         ret
57 END_FUNC        ___clzsi2
60 START_FUNC      ___ctzhi2
61         ;; Argument is in [SP+4], return in R8.
62         movw    ax, [SP+4]
64         .global __ctzhi2_internal
65 __ctzhi2_internal:
66         movw    r8, #16
67         cmpw    ax, #0
68         bz      $ctzhi2_is_zero
69         mov     e, #0xff
71         inc     e
72         shrw    ax, 1
73         bnc     $1b
74         mov     a, e
75         mov     r8, a
76 ctzhi2_is_zero:
77         ret
78 END_FUNC        ___ctzhi2
81 START_FUNC      ___ctzsi2
82         ;; Argument is in [SP+6]:[SP+4], return in R8.
83         movw    ax, [SP+4]
84         cmpw    ax, #0
85         bnz     $__ctzhi2_internal
86         movw    ax, [SP+6]
87         call    !__ctzhi2_internal
88         movw    ax, r8
89         addw    ax, #16
90         movw    r8, ax
91         ret
92 END_FUNC        ___ctzsi2
95 START_FUNC      ___ffshi2
96         ;; Argument is in [SP+4], return in R8.
97         movw    ax, [SP+4]
99         .global __ffshi2_internal
100 __ffshi2_internal:
101         movw    r8, #0
102         cmpw    ax, #0
103         bz      $ffshi2_is_zero
104         mov     e, #0
106         inc     e
107         shrw    ax, 1
108         bnc     $1b
109         mov     a, e
110         mov     r8, a
111 ffshi2_is_zero:
112         ret
113 END_FUNC        ___ffshi2
116 START_FUNC      ___ffssi2
117         ;; Argument is in [SP+6]:[SP+4], return in R8.
118         movw    ax, [SP+4]
119         cmpw    ax, #0
120         bnz     $__ffshi2_internal
121         movw    ax, [SP+6]
122         cmpw    ax, #0
123         bz      $1f
124         call    !__ffshi2_internal
125         movw    ax, r8
126         addw    ax, #16
127 1:      
128         movw    r8, ax
129         ret
130 END_FUNC        ___ffssi2
133 START_FUNC      ___parityqi_internal
134         mov1    cy, a.0
135         xor1    cy, a.1
136         xor1    cy, a.2
137         xor1    cy, a.3
138         xor1    cy, a.4
139         xor1    cy, a.5
140         xor1    cy, a.6
141         xor1    cy, a.7
142         movw    ax, #0
143         bnc     $1f
144         incw    ax
146         movw    r8, ax
147         ret
148 END_FUNC        ___parityqi_internal
151 START_FUNC      ___parityhi2
152         ;; Argument is in [SP+4], return in R8.
153         movw    ax, [SP+4]
154         xor     a, x
155         br      $___parityqi_internal
156 END_FUNC        ___parityhi2
159 START_FUNC      ___paritysi2
160         ;; Argument is in [SP+6]:[SP+4], return in R8.
161         movw    ax, [SP+4]
162         xor     a, x
163         mov     b, a
164         movw    ax, [SP+6]
165         xor     a, x
166         xor     a, b
167         br      $___parityqi_internal
168 END_FUNC        ___paritysi2
172 START_FUNC      ___popcounthi2
173         ;; Argument is in [SP+4], return in R8.
174         mov     d, #2
175         br      $___popcountqi_internal
176 END_FUNC        ___popcounthi2
179 START_FUNC      ___popcountsi2
180         ;; Argument is in [SP+6]:[SP+4], return in R8.
181         mov     d, #4
182         br      $___popcountqi_internal
183 END_FUNC        ___popcountsi2
186 START_FUNC      ___popcountqi_internal
187         ;; There are D bytes starting at [HL]
188         ;; store count in R8.
190         movw    ax, sp
191         addw    ax, #4
192         movw    hl, ax
193         mov     a, #0
195         xch     a, b
196         mov     a, [hl]
197         xch     a, b
198         mov     e, #8
199 2:      
200         shl     b,1
201         addc    a, #0
202         dec     e
203         bnz     $2b
205         incw    hl
206         dec     d
207         bnz     $1b
209         mov     x, a
210         mov     a, #0
211         movw    r8, ax
212         ret     
213 END_FUNC        ___popcountqi_internal