| 1 |
; libgcc1 routines for Synopsys DesignWare ARC cpu. |
| 2 |
|
| 3 |
/* Copyright (C) 1995-2025 Free Software Foundation, Inc. |
| 4 |
Contributor: Joern Rennecke <[email protected]> |
| 5 |
on behalf of Synopsys Inc. |
| 6 |
|
| 7 |
This file is part of GCC. |
| 8 |
|
| 9 |
GCC is free software; you can redistribute it and/or modify it under |
| 10 |
the terms of the GNU General Public License as published by the Free |
| 11 |
Software Foundation; either version 3, or (at your option) any later |
| 12 |
version. |
| 13 |
|
| 14 |
GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
| 15 |
WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 16 |
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 17 |
for more details. |
| 18 |
|
| 19 |
Under Section 7 of GPL version 3, you are granted additional |
| 20 |
permissions described in the GCC Runtime Library Exception, version |
| 21 |
3.1, as published by the Free Software Foundation. |
| 22 |
|
| 23 |
You should have received a copy of the GNU General Public License and |
| 24 |
a copy of the GCC Runtime Library Exception along with this program; |
| 25 |
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
| 26 |
<http://www.gnu.org/licenses/>. */ |
| 27 |
|
| 28 |
/* As a special exception, if you link this library with other files, |
| 29 |
some of which are compiled with GCC, to produce an executable, |
| 30 |
this library does not by itself cause the resulting executable |
| 31 |
to be covered by the GNU General Public License. |
| 32 |
This exception does not however invalidate any other reasons why |
| 33 |
the executable file might be covered by the GNU General Public License. */ |
| 34 |
|
| 35 |
|
| 36 |
/* ANSI concatenation macros. */ |
| 37 |
|
| 38 |
#define CONCAT1(a, b) CONCAT2(a, b) |
| 39 |
#define CONCAT2(a, b) a ## b |
| 40 |
|
| 41 |
/* Use the right prefix for global labels. */ |
| 42 |
|
| 43 |
#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) |
| 44 |
|
| 45 |
#ifndef WORKING_ASSEMBLER |
| 46 |
#define abs_l abs |
| 47 |
#define asl_l asl |
| 48 |
#define mov_l mov |
| 49 |
#endif |
| 50 |
|
| 51 |
#define FUNC(X) .type SYM(X),@function |
| 52 |
#define HIDDEN_FUNC(X) FUNC(X)` .hidden X |
| 53 |
#define ENDFUNC0(X) .Lfe_##X: .size X,.Lfe_##X-X |
| 54 |
#define ENDFUNC(X) ENDFUNC0(X) |
| 55 |
|
| 56 |
#ifdef __ARC_RF16__ |
| 57 |
/* Use object attributes to inform other tools this file is |
| 58 |
safe for RF16 configuration. */ |
| 59 |
.arc_attribute Tag_ARC_ABI_rf16, 1 |
| 60 |
#endif |
| 61 |
|
| 62 |
#ifdef L_mulsi3 |
| 63 |
.section .text |
| 64 |
.align 4 |
| 65 |
|
| 66 |
.global SYM(__mulsi3) |
| 67 |
SYM(__mulsi3): |
| 68 |
|
| 69 |
/* This the simple version. |
| 70 |
|
| 71 |
while (a) |
| 72 |
{ |
| 73 |
if (a & 1) |
| 74 |
r += b; |
| 75 |
a >>= 1; |
| 76 |
b <<= 1; |
| 77 |
} |
| 78 |
*/ |
| 79 |
|
| 80 |
#if defined (__ARC_MUL64__) |
| 81 |
FUNC(__mulsi3) |
| 82 |
mulu64 r0,r1 |
| 83 |
j_s.d [blink] |
| 84 |
mov_s r0,mlo |
| 85 |
ENDFUNC(__mulsi3) |
| 86 |
#elif defined (__ARC_MPY__) |
| 87 |
HIDDEN_FUNC(__mulsi3) |
| 88 |
mpyu r0,r0,r1 |
| 89 |
nop_s |
| 90 |
j_s [blink] |
| 91 |
ENDFUNC(__mulsi3) |
| 92 |
#elif defined (__ARC_NORM__) |
| 93 |
FUNC(__mulsi3) |
| 94 |
norm.f r2,r0 |
| 95 |
rsub lp_count,r2,31 |
| 96 |
mov.mi lp_count,32 |
| 97 |
mov_s r2,r0 |
| 98 |
mov_s r0,0 |
| 99 |
lpnz @.Lend ; loop is aligned |
| 100 |
lsr.f r2,r2 |
| 101 |
add.cs r0,r0,r1 |
| 102 |
add_s r1,r1,r1 |
| 103 |
.Lend: j_s [blink] |
| 104 |
ENDFUNC(__mulsi3) |
| 105 |
#elif !defined (__OPTIMIZE_SIZE__) && defined (__ARC_BARREL_SHIFTER__) |
| 106 |
/* Up to 3.5 times faster than the simpler code below, but larger. */ |
| 107 |
FUNC(__mulsi3) |
| 108 |
ror.f r2,r0,4 |
| 109 |
mov_s r0,0 |
| 110 |
add3.mi r0,r0,r1 |
| 111 |
asl.f r2,r2,2 |
| 112 |
add2.cs r0,r0,r1 |
| 113 |
jeq_s [blink] |
| 114 |
.Loop: |
| 115 |
add1.mi r0,r0,r1 |
| 116 |
asl.f r2,r2,2 |
| 117 |
add.cs r0,r0,r1 |
| 118 |
asl_s r1,r1,4 |
| 119 |
ror.f r2,r2,8 |
| 120 |
add3.mi r0,r0,r1 |
| 121 |
asl.f r2,r2,2 |
| 122 |
bne.d .Loop |
| 123 |
add2.cs r0,r0,r1 |
| 124 |
j_s [blink] |
| 125 |
ENDFUNC(__mulsi3) |
| 126 |
#elif !defined (__OPTIMIZE_SIZE__) /* __ARC601__ */ |
| 127 |
FUNC(__mulsi3) |
| 128 |
lsr.f r2,r0 |
| 129 |
mov_s r0,0 |
| 130 |
mov_s r3,0 |
| 131 |
add.cs r0,r0,r1 |
| 132 |
.Loop: |
| 133 |
lsr.f r2,r2 |
| 134 |
add1.cs r0,r0,r1 |
| 135 |
lsr.f r2,r2 |
| 136 |
add2.cs r0,r0,r1 |
| 137 |
lsr.f r2,r2 |
| 138 |
add3.cs r0,r0,r1 |
| 139 |
bne.d .Loop |
| 140 |
add3 r1,r3,r1 |
| 141 |
j_s [blink] |
| 142 |
ENDFUNC(__mulsi3) |
| 143 |
#else |
| 144 |
/********************************************************/ |
| 145 |
FUNC(__mulsi3) |
| 146 |
mov_s r2,0 ; Accumulate result here. |
| 147 |
.Lloop: |
| 148 |
bbit0 r0,0,@.Ly |
| 149 |
add_s r2,r2,r1 ; r += b |
| 150 |
.Ly: |
| 151 |
lsr_s r0,r0 ; a >>= 1 |
| 152 |
asl_s r1,r1 ; b <<= 1 |
| 153 |
brne_s r0,0,@.Lloop |
| 154 |
.Ldone: |
| 155 |
j_s.d [blink] |
| 156 |
mov_s r0,r2 |
| 157 |
ENDFUNC(__mulsi3) |
| 158 |
/********************************************************/ |
| 159 |
#endif |
| 160 |
|
| 161 |
#endif /* L_mulsi3 */ |
| 162 |
|
| 163 |
#ifdef L_umulsidi3 |
| 164 |
.section .text |
| 165 |
.align 4 |
| 166 |
|
| 167 |
.global SYM(__umulsidi3) |
| 168 |
SYM(__umulsidi3): |
| 169 |
HIDDEN_FUNC(__umulsidi3) |
| 170 |
/* We need ARC700 /ARC_MUL64 definitions of __umulsidi3 / __umulsi3_highpart |
| 171 |
in case some code has been compiled without multiply support enabled, |
| 172 |
but linked with the multiply-support enabled libraries. |
| 173 |
For ARC601 (i.e. without a barrel shifter), we also use umuldisi3 as our |
| 174 |
umulsi3_highpart implementation; the use of the latter label doesn't |
| 175 |
actually benefit ARC601 platforms, but is useful when ARC601 code is linked |
| 176 |
against other libraries. */ |
| 177 |
#if defined (__ARC_MPY__) || defined (__ARC_MUL64__) \ |
| 178 |
|| !defined (__ARC_BARREL_SHIFTER__) |
| 179 |
.global SYM(__umulsi3_highpart) |
| 180 |
SYM(__umulsi3_highpart): |
| 181 |
HIDDEN_FUNC(__umulsi3_highpart) |
| 182 |
#endif |
| 183 |
|
| 184 |
/* This the simple version. |
| 185 |
|
| 186 |
while (a) |
| 187 |
{ |
| 188 |
if (a & 1) |
| 189 |
r += b; |
| 190 |
a >>= 1; |
| 191 |
b <<= 1; |
| 192 |
} |
| 193 |
*/ |
| 194 |
#include "ieee-754/arc-ieee-754.h" |
| 195 |
|
| 196 |
#ifdef __ARC_MPY__ |
| 197 |
mov_s r12,DBL0L |
| 198 |
mpyu DBL0L,r12,DBL0H |
| 199 |
j_s.d [blink] |
| 200 |
MPYHU DBL0H,r12,DBL0H |
| 201 |
#elif defined (__ARC_MUL64__) |
| 202 |
/* Likewise for __ARC_MUL64__ */ |
| 203 |
mulu64 r0,r1 |
| 204 |
mov_s DBL0L,mlo |
| 205 |
j_s.d [blink] |
| 206 |
mov_s DBL0H,mhi |
| 207 |
#else /* !__ARC_MPY__ && !__ARC_MUL64__ */ |
| 208 |
/* Although it might look tempting to extend this to handle muldi3, |
| 209 |
using mulsi3 twice with 2.25 cycles per 32 bit add is faster |
| 210 |
than one loop with 3 or four cycles per 32 bit add. */ |
| 211 |
asl.f r12,0 ; Top part of b. |
| 212 |
mov_s r2,0 ; Accumulate result here. |
| 213 |
bbit1.d r0,0,@.Ladd |
| 214 |
mov_s r3,0 |
| 215 |
.Llooptst: |
| 216 |
rlc r12,r12 |
| 217 |
breq r0,0,@.Ldone ; while (a) |
| 218 |
.Lloop: |
| 219 |
asl.f r1,r1 ; b <<= 1 |
| 220 |
bbit0.d r0,1,@.Llooptst |
| 221 |
lsr r0,r0 ; a >>= 1 |
| 222 |
rlc r12,r12 |
| 223 |
.Ladd: |
| 224 |
add.f r3,r3,r1 ; r += b |
| 225 |
brne.d r0,0,@.Lloop ; while (a); |
| 226 |
adc r2,r2,r12 |
| 227 |
.Ldone: |
| 228 |
mov_s DBL0L,r3 |
| 229 |
j_s.d [blink] |
| 230 |
mov DBL0H,r2 |
| 231 |
#endif /* !__ARC_MPY__*/ |
| 232 |
ENDFUNC(__umulsidi3) |
| 233 |
#if defined (__ARC_MPY__) || defined (__ARC_MUL64__) \ |
| 234 |
|| !defined (__ARC_BARREL_SHIFTER__) |
| 235 |
ENDFUNC(__umulsi3_highpart) |
| 236 |
#endif |
| 237 |
#endif /* L_umulsidi3 */ |
| 238 |
|
| 239 |
#ifndef __ARC_RF16__ |
| 240 |
#ifdef L_muldi3 |
| 241 |
.section .text |
| 242 |
.align 4 |
| 243 |
.global SYM(__muldi3) |
| 244 |
SYM(__muldi3): |
| 245 |
#ifdef __LITTLE_ENDIAN__ |
| 246 |
push_s blink |
| 247 |
mov_s r4,r3 ;4 |
| 248 |
mov_s r5,r2 ;4 |
| 249 |
mov_s r9,r0 ;4 |
| 250 |
mov_s r8,r1 ;4 |
| 251 |
bl.d @__umulsidi3 |
| 252 |
mov_s r1,r2 ;4 |
| 253 |
mov_s r6,r0 ;4 |
| 254 |
mov_s r7,r1 ;4 |
| 255 |
mov_s r0,r9 ;4 |
| 256 |
bl.d @__mulsi3 |
| 257 |
mov_s r1,r4 ;4 |
| 258 |
mov_s r4,r0 ;4 |
| 259 |
mov_s r1,r8 ;4 |
| 260 |
bl.d @__mulsi3 |
| 261 |
mov_s r0,r5 ;4 |
| 262 |
pop_s blink |
| 263 |
add_s r0,r0,r4 ;2 |
| 264 |
add r1,r0,r7 |
| 265 |
j_s.d [blink] |
| 266 |
mov_s r0,r6 ;4 |
| 267 |
#else |
| 268 |
push_s blink |
| 269 |
mov_s r5,r3 |
| 270 |
mov_s r9,r2 |
| 271 |
mov_s r4,r1 |
| 272 |
mov_s r8,r0 |
| 273 |
mov_s r0,r1 |
| 274 |
bl.d @__umulsidi3 |
| 275 |
mov_s r1,r3 |
| 276 |
mov_s r7,r0 |
| 277 |
mov_s r6,r1 |
| 278 |
mov_s r0,r4 |
| 279 |
bl.d @__mulsi3 |
| 280 |
mov_s r1,r9 |
| 281 |
mov_s r4,r0 |
| 282 |
mov_s r1,r8 |
| 283 |
bl.d @__mulsi3 |
| 284 |
mov_s r0,r5 |
| 285 |
pop_s blink |
| 286 |
add_s r0,r0,r4 |
| 287 |
add_s r0,r0,r7 |
| 288 |
j_s.d [blink] |
| 289 |
mov_s r1,r6 |
| 290 |
#endif /* __LITTLE_ENDIAN__ */ |
| 291 |
ENDFUNC(__muldi3) |
| 292 |
#endif /* L_muldi3 */ |
| 293 |
#endif /* !__ARC_RF16__ */ |
| 294 |
|
| 295 |
#ifdef L_umulsi3_highpart |
| 296 |
#include "ieee-754/arc-ieee-754.h" |
| 297 |
/* For use without a barrel shifter, and for ARC700 / ARC_MUL64, the |
| 298 |
mulsidi3 algorithms above look better, so for these, there is an |
| 299 |
extra label up there. */ |
| 300 |
#if !defined (__ARC_MPY__) && !defined (__ARC_MUL64__) \ |
| 301 |
&& defined (__ARC_BARREL_SHIFTER__) |
| 302 |
.global SYM(__umulsi3_highpart) |
| 303 |
SYM(__umulsi3_highpart): |
| 304 |
HIDDEN_FUNC(__umulsi3_highpart) |
| 305 |
mov_s r2,0 |
| 306 |
mov_s r3,32 |
| 307 |
.Loop: |
| 308 |
lsr.f r0,r0 |
| 309 |
add.cs.f r2,r2,r1 |
| 310 |
sub_s r3,r3,1 |
| 311 |
brne.d r0,0,.Loop |
| 312 |
rrc r2,r2 |
| 313 |
j_s.d [blink] |
| 314 |
/* Make the result register peephole-compatible with mulsidi3. */ |
| 315 |
lsr DBL0H,r2,r3 |
| 316 |
ENDFUNC(__umulsi3_highpart) |
| 317 |
#endif /* !__ARC_MPY__ && __ARC_BARREL_SHIFTER__ */ |
| 318 |
#endif /* L_umulsi3_highpart */ |
| 319 |
|
| 320 |
#ifdef L_divmod_tools |
| 321 |
|
| 322 |
; Utilities used by all routines. |
| 323 |
|
| 324 |
.section .text |
| 325 |
|
| 326 |
/* |
| 327 |
unsigned long |
| 328 |
udivmodsi4(int modwanted, unsigned long num, unsigned long den) |
| 329 |
{ |
| 330 |
unsigned long bit = 1; |
| 331 |
unsigned long res = 0; |
| 332 |
|
| 333 |
while (den < num && bit && !(den & (1L<<31))) |
| 334 |
{ |
| 335 |
den <<=1; |
| 336 |
bit <<=1; |
| 337 |
} |
| 338 |
while (bit) |
| 339 |
{ |
| 340 |
if (num >= den) |
| 341 |
{ |
| 342 |
num -= den; |
| 343 |
res |= bit; |
| 344 |
} |
| 345 |
bit >>=1; |
| 346 |
den >>=1; |
| 347 |
} |
| 348 |
if (modwanted) return num; |
| 349 |
return res; |
| 350 |
} |
| 351 |
*/ |
| 352 |
|
| 353 |
; inputs: r0 = numerator, r1 = denominator |
| 354 |
; outputs: r0 = quotient, r1 = remainder, r2/r3 trashed |
| 355 |
|
| 356 |
.balign 4 |
| 357 |
.global SYM(__udivmodsi4) |
| 358 |
FUNC(__udivmodsi4) |
| 359 |
SYM(__udivmodsi4): |
| 360 |
|
| 361 |
#if defined (__ARC_EA__) |
| 362 |
/* Normalize divisor and divident, and then use the appropriate number of |
| 363 |
divaw (the number of result bits, or one more) to produce the result. |
| 364 |
There are some special conditions that need to be tested: |
| 365 |
- We can only directly normalize unsigned numbers that fit in 31 bit. For |
| 366 |
the divisor, we test early on that it is not 'negative'. |
| 367 |
- divaw can't corrrectly process a divident that is larger than the divisor. |
| 368 |
We handle this be checking that the divident prior to normalization is |
| 369 |
not larger than the normalized divisor. As we then already know then |
| 370 |
that the divisor fits 31 bit, this check also makes sure that the |
| 371 |
divident fits. |
| 372 |
- ordinary normalization of the divident could make it larger than the |
| 373 |
normalized divisor, which again would be unsuitable for divaw. |
| 374 |
Thus, we want to shift left the divident by one less, except that we |
| 375 |
want to leave it alone if it is already 31 bit. To this end, we |
| 376 |
double the input to norm with adds. |
| 377 |
- If the divident has less bits than the divisor, that would leave us |
| 378 |
with a negative number of divaw to execute. Although we could use a |
| 379 |
conditional loop to avoid excess divaw, and then the quotient could |
| 380 |
be extracted correctly as there'd be more than enough zero bits, the |
| 381 |
remainder would be shifted left too far, requiring a conditional shift |
| 382 |
right. The cost of that shift and the possible mispredict on the |
| 383 |
conditional loop cost as much as putting in an early check for a zero |
| 384 |
result. */ |
| 385 |
bmsk r3,r0,29 |
| 386 |
brne.d r3,r0,.Large_dividend |
| 387 |
norm.f r2,r1 |
| 388 |
brlo r0,r1,.Lret0 |
| 389 |
norm r3,r0 |
| 390 |
asl_s r1,r1,r2 |
| 391 |
sub_s r3,r3,1 |
| 392 |
asl_l r0,r0,r3 ; not short to keep loop aligned |
| 393 |
sub lp_count,r2,r3 |
| 394 |
lp .Ldiv_end |
| 395 |
divaw r0,r0,r1 |
| 396 |
.Ldiv_end:sub_s r3,r2,1 |
| 397 |
lsr r1,r0,r2 |
| 398 |
j_s.d [blink] |
| 399 |
bmsk r0,r0,r3 |
| 400 |
|
| 401 |
.balign 4 |
| 402 |
.Large_dividend: |
| 403 |
bmi .Ltrivial |
| 404 |
asl_s r1,r1,r2 |
| 405 |
mov_s r3,0 |
| 406 |
sub1.f r4,r0,r1 |
| 407 |
mov.lo r4,r0 |
| 408 |
mov.hs r3,2 |
| 409 |
cmp r4,r1 |
| 410 |
sub.hs r4,r4,r1 |
| 411 |
add.hs r3,r3,1 |
| 412 |
mov.f lp_count,r2 |
| 413 |
lpne .Ldiv_end2 |
| 414 |
divaw r4,r4,r1 |
| 415 |
.Ldiv_end2:asl r0,r3,r2 |
| 416 |
lsr r1,r4,r2 |
| 417 |
sub_s r2,r2,1 |
| 418 |
bmsk r4,r4,r2 |
| 419 |
j_s.d [blink] |
| 420 |
or.ne r0,r0,r4 |
| 421 |
|
| 422 |
.Lret0: |
| 423 |
mov_s r1,r0 |
| 424 |
j_s.d [blink] |
| 425 |
mov_l r0,0 |
| 426 |
.balign 4 |
| 427 |
.Ltrivial: |
| 428 |
sub.f r1,r0,r1 |
| 429 |
mov.c r1,r0 |
| 430 |
mov_s r0,1 |
| 431 |
j_s.d [blink] |
| 432 |
mov.c r0,0 |
| 433 |
#elif !defined (__OPTIMIZE_SIZE__) && !defined (__ARC_RF16__) |
| 434 |
#if defined (__ARC_NORM__) && defined (__ARC_BARREL_SHIFTER__) |
| 435 |
lsr_s r2,r0 |
| 436 |
brhs.d r1,r2,.Lret0_3 |
| 437 |
norm r2,r2 |
| 438 |
norm r3,r1 |
| 439 |
sub_s r3,r3,r2 |
| 440 |
asl_s r1,r1,r3 |
| 441 |
sub1.f 0,r0,r1 |
| 442 |
lsr.cs r1,r1,1 |
| 443 |
sbc r2,r3,0 |
| 444 |
sub1 r0,r0,r1 |
| 445 |
cmp_s r0,r1 |
| 446 |
mov.f lp_count,r2 |
| 447 |
#else /* ! __ARC_NORM__ */ |
| 448 |
lsr_s r2,r0 |
| 449 |
brhs.d r1,r2,.Lret0_3 |
| 450 |
mov lp_count,32 |
| 451 |
.Lloop1: |
| 452 |
asl_s r1,r1 ; den <<= 1 |
| 453 |
brls.d r1,r2,@.Lloop1 |
| 454 |
sub lp_count,lp_count,1 |
| 455 |
sub_s r0,r0,r1 |
| 456 |
lsr_s r1,r1 |
| 457 |
cmp_s r0,r1 |
| 458 |
xor.f r2,lp_count,31 |
| 459 |
#if !defined (__ARCEM__) && !defined (__ARCHS__) |
| 460 |
mov_s lp_count,r2 |
| 461 |
#else |
| 462 |
mov lp_count,r2 |
| 463 |
nop_s |
| 464 |
#endif /* !__ARCEM__ && !__ARCHS__ */ |
| 465 |
#endif /* !__ARC_NORM__ */ |
| 466 |
sub.cc r0,r0,r1 |
| 467 |
mov_s r3,3 |
| 468 |
sbc r3,r3,0 |
| 469 |
#if defined (__ARC_BARREL_SHIFTER__) |
| 470 |
asl_s r3,r3,r2 |
| 471 |
rsub r1,r1,1 |
| 472 |
lpne @.Lloop2_end |
| 473 |
add1.f r0,r1,r0 |
| 474 |
sub.cc r0,r0,r1 |
| 475 |
.Lloop2_end: |
| 476 |
lsr r1,r0,r2 |
| 477 |
#else |
| 478 |
rsub r1,r1,1 |
| 479 |
lpne @.Lloop2_end |
| 480 |
asl_s r3,r3 |
| 481 |
add1.f r0,r1,r0 |
| 482 |
sub.cc r0,r0,r1 |
| 483 |
.Lloop2_end: |
| 484 |
lsr_s r1,r0 |
| 485 |
lsr.f lp_count,r2 |
| 486 |
mov.cc r1,r0 |
| 487 |
lpnz 1f |
| 488 |
lsr_s r1,r1 |
| 489 |
lsr_s r1,r1 |
| 490 |
1: |
| 491 |
#endif |
| 492 |
bmsk r0,r0,r2 |
| 493 |
bclr r0,r0,r2 |
| 494 |
j_s.d [blink] |
| 495 |
or_s r0,r0,r3 |
| 496 |
.Lret0_3: |
| 497 |
#if 0 /* Slightly shorter, but slower. */ |
| 498 |
lp .Loop3_end |
| 499 |
brhi.d r1,r0,.Loop3_end |
| 500 |
sub_s r0,r0,r1 |
| 501 |
.Loop3_end |
| 502 |
add_s r1,r1,r0 |
| 503 |
j_s.d [blink] |
| 504 |
rsub r0,lp_count,32-1 |
| 505 |
#else |
| 506 |
mov_s r4,r1 |
| 507 |
sub.f r1,r0,r1 |
| 508 |
sbc r0,r0,r0 |
| 509 |
sub.cc.f r1,r1,r4 |
| 510 |
sbc r0,r0,0 |
| 511 |
sub.cc.f r1,r1,r4 |
| 512 |
sbc r0,r0,-3 |
| 513 |
j_s.d [blink] |
| 514 |
add.cs r1,r1,r4 |
| 515 |
#endif |
| 516 |
#else /* Arctangent-A5 */ |
| 517 |
breq_s r1,0,@.Ldivmodend |
| 518 |
mov_s r2,1 ; bit = 1 |
| 519 |
mov_s r3,0 ; res = 0 |
| 520 |
.Lloop1: |
| 521 |
brhs r1,r0,@.Lloop2 |
| 522 |
bbit1 r1,31,@.Lloop2 |
| 523 |
asl_s r1,r1 ; den <<= 1 |
| 524 |
b.d @.Lloop1 |
| 525 |
asl_s r2,r2 ; bit <<= 1 |
| 526 |
.Lloop2: |
| 527 |
brlo r0,r1,@.Lshiftdown |
| 528 |
sub_s r0,r0,r1 ; num -= den |
| 529 |
or_s r3,r3,r2 ; res |= bit |
| 530 |
.Lshiftdown: |
| 531 |
lsr_s r2,r2 ; bit >>= 1 |
| 532 |
lsr_s r1,r1 ; den >>= 1 |
| 533 |
brne_s r2,0,@.Lloop2 |
| 534 |
.Ldivmodend: |
| 535 |
mov_s r1,r0 ; r1 = mod |
| 536 |
j.d [blink] |
| 537 |
mov_s r0,r3 ; r0 = res |
| 538 |
/******************************************************/ |
| 539 |
#endif |
| 540 |
ENDFUNC(__udivmodsi4) |
| 541 |
|
| 542 |
#endif |
| 543 |
|
| 544 |
#ifdef L_udivsi3 |
| 545 |
.section .text |
| 546 |
.align 4 |
| 547 |
|
| 548 |
.global SYM(__udivsi3) |
| 549 |
FUNC(__udivsi3) |
| 550 |
SYM(__udivsi3): |
| 551 |
b @SYM(__udivmodsi4) |
| 552 |
ENDFUNC(__udivsi3) |
| 553 |
|
| 554 |
#endif /* L_udivsi3 */ |
| 555 |
|
| 556 |
#ifdef L_divsi3 |
| 557 |
.section .text |
| 558 |
.align 4 |
| 559 |
|
| 560 |
.global SYM(__divsi3) |
| 561 |
FUNC(__divsi3) |
| 562 |
|
| 563 |
#ifndef __ARC_EA__ |
| 564 |
SYM(__divsi3): |
| 565 |
/* A5 / ARC60? */ |
| 566 |
mov r12,blink |
| 567 |
xor r11,r0,r1 |
| 568 |
abs_s r0,r0 |
| 569 |
bl.d @SYM(__udivmodsi4) |
| 570 |
abs_s r1,r1 |
| 571 |
tst r11,r11 |
| 572 |
j.d [r12] |
| 573 |
neg.mi r0,r0 |
| 574 |
#else /* !ifndef __ARC_EA__ */ |
| 575 |
;; We can use the abs, norm, divaw and mpy instructions for ARC700 |
| 576 |
#define MULDIV |
| 577 |
#ifdef MULDIV |
| 578 |
/* This table has been generated by divtab-arc700.c. */ |
| 579 |
/* 1/512 .. 1/256, normalized. There is a leading 1 in bit 31. |
| 580 |
For powers of two, we list unnormalized numbers instead. The values |
| 581 |
for powers of 2 are loaded, but not used. The value for 1 is actually |
| 582 |
the first instruction after .Lmuldiv. */ |
| 583 |
.balign 4 |
| 584 |
.Ldivtab: |
| 585 |
|
| 586 |
.long 0x1000000 |
| 587 |
.long 0x80808081 |
| 588 |
.long 0x81020409 |
| 589 |
.long 0x81848DA9 |
| 590 |
.long 0x82082083 |
| 591 |
.long 0x828CBFBF |
| 592 |
.long 0x83126E98 |
| 593 |
.long 0x83993053 |
| 594 |
.long 0x84210843 |
| 595 |
.long 0x84A9F9C9 |
| 596 |
.long 0x85340854 |
| 597 |
.long 0x85BF3762 |
| 598 |
.long 0x864B8A7E |
| 599 |
.long 0x86D90545 |
| 600 |
.long 0x8767AB60 |
| 601 |
.long 0x87F78088 |
| 602 |
.long 0x88888889 |
| 603 |
.long 0x891AC73B |
| 604 |
.long 0x89AE408A |
| 605 |
.long 0x8A42F871 |
| 606 |
.long 0x8AD8F2FC |
| 607 |
.long 0x8B70344B |
| 608 |
.long 0x8C08C08D |
| 609 |
.long 0x8CA29C05 |
| 610 |
.long 0x8D3DCB09 |
| 611 |
.long 0x8DDA5203 |
| 612 |
.long 0x8E78356E |
| 613 |
.long 0x8F1779DA |
| 614 |
.long 0x8FB823EF |
| 615 |
.long 0x905A3864 |
| 616 |
.long 0x90FDBC0A |
| 617 |
.long 0x91A2B3C5 |
| 618 |
.long 0x92492493 |
| 619 |
.long 0x92F11385 |
| 620 |
.long 0x939A85C5 |
| 621 |
.long 0x94458095 |
| 622 |
.long 0x94F20950 |
| 623 |
.long 0x95A02569 |
| 624 |
.long 0x964FDA6D |
| 625 |
.long 0x97012E03 |
| 626 |
.long 0x97B425EE |
| 627 |
.long 0x9868C80A |
| 628 |
.long 0x991F1A52 |
| 629 |
.long 0x99D722DB |
| 630 |
.long 0x9A90E7DA |
| 631 |
.long 0x9B4C6F9F |
| 632 |
.long 0x9C09C09D |
| 633 |
.long 0x9CC8E161 |
| 634 |
.long 0x9D89D89E |
| 635 |
.long 0x9E4CAD24 |
| 636 |
.long 0x9F1165E8 |
| 637 |
.long 0x9FD809FE |
| 638 |
.long 0xA0A0A0A1 |
| 639 |
.long 0xA16B312F |
| 640 |
.long 0xA237C32C |
| 641 |
.long 0xA3065E40 |
| 642 |
.long 0xA3D70A3E |
| 643 |
.long 0xA4A9CF1E |
| 644 |
.long 0xA57EB503 |
| 645 |
.long 0xA655C43A |
| 646 |
.long 0xA72F053A |
| 647 |
.long 0xA80A80A9 |
| 648 |
.long 0xA8E83F58 |
| 649 |
.long 0xA9C84A48 |
| 650 |
.long 0xAAAAAAAB |
| 651 |
.long 0xAB8F69E3 |
| 652 |
.long 0xAC769185 |
| 653 |
.long 0xAD602B59 |
| 654 |
.long 0xAE4C415D |
| 655 |
.long 0xAF3ADDC7 |
| 656 |
.long 0xB02C0B03 |
| 657 |
.long 0xB11FD3B9 |
| 658 |
.long 0xB21642C9 |
| 659 |
.long 0xB30F6353 |
| 660 |
.long 0xB40B40B5 |
| 661 |
.long 0xB509E68B |
| 662 |
.long 0xB60B60B7 |
| 663 |
.long 0xB70FBB5B |
| 664 |
.long 0xB81702E1 |
| 665 |
.long 0xB92143FB |
| 666 |
.long 0xBA2E8BA3 |
| 667 |
.long 0xBB3EE722 |
| 668 |
.long 0xBC52640C |
| 669 |
.long 0xBD691048 |
| 670 |
.long 0xBE82FA0C |
| 671 |
.long 0xBFA02FE9 |
| 672 |
.long 0xC0C0C0C1 |
| 673 |
.long 0xC1E4BBD6 |
| 674 |
.long 0xC30C30C4 |
| 675 |
.long 0xC4372F86 |
| 676 |
.long 0xC565C87C |
| 677 |
.long 0xC6980C6A |
| 678 |
.long 0xC7CE0C7D |
| 679 |
.long 0xC907DA4F |
| 680 |
.long 0xCA4587E7 |
| 681 |
.long 0xCB8727C1 |
| 682 |
.long 0xCCCCCCCD |
| 683 |
.long 0xCE168A78 |
| 684 |
.long 0xCF6474A9 |
| 685 |
.long 0xD0B69FCC |
| 686 |
.long 0xD20D20D3 |
| 687 |
.long 0xD3680D37 |
| 688 |
.long 0xD4C77B04 |
| 689 |
.long 0xD62B80D7 |
| 690 |
.long 0xD79435E6 |
| 691 |
.long 0xD901B204 |
| 692 |
.long 0xDA740DA8 |
| 693 |
.long 0xDBEB61EF |
| 694 |
.long 0xDD67C8A7 |
| 695 |
.long 0xDEE95C4D |
| 696 |
.long 0xE070381D |
| 697 |
.long 0xE1FC780F |
| 698 |
.long 0xE38E38E4 |
| 699 |
.long 0xE525982B |
| 700 |
.long 0xE6C2B449 |
| 701 |
.long 0xE865AC7C |
| 702 |
.long 0xEA0EA0EB |
| 703 |
.long 0xEBBDB2A6 |
| 704 |
.long 0xED7303B6 |
| 705 |
.long 0xEF2EB720 |
| 706 |
.long 0xF0F0F0F1 |
| 707 |
.long 0xF2B9D649 |
| 708 |
.long 0xF4898D60 |
| 709 |
.long 0xF6603D99 |
| 710 |
.long 0xF83E0F84 |
| 711 |
.long 0xFA232CF3 |
| 712 |
.long 0xFC0FC0FD |
| 713 |
.long 0xFE03F810 |
| 714 |
.long 0x2000000 |
| 715 |
.long 0x81020409 |
| 716 |
.long 0x82082083 |
| 717 |
.long 0x83126E98 |
| 718 |
.long 0x84210843 |
| 719 |
.long 0x85340854 |
| 720 |
.long 0x864B8A7E |
| 721 |
.long 0x8767AB60 |
| 722 |
.long 0x88888889 |
| 723 |
.long 0x89AE408A |
| 724 |
.long 0x8AD8F2FC |
| 725 |
.long 0x8C08C08D |
| 726 |
.long 0x8D3DCB09 |
| 727 |
.long 0x8E78356E |
| 728 |
.long 0x8FB823EF |
| 729 |
.long 0x90FDBC0A |
| 730 |
.long 0x92492493 |
| 731 |
.long 0x939A85C5 |
| 732 |
.long 0x94F20950 |
| 733 |
.long 0x964FDA6D |
| 734 |
.long 0x97B425EE |
| 735 |
.long 0x991F1A52 |
| 736 |
.long 0x9A90E7DA |
| 737 |
.long 0x9C09C09D |
| 738 |
.long 0x9D89D89E |
| 739 |
.long 0x9F1165E8 |
| 740 |
.long 0xA0A0A0A1 |
| 741 |
.long 0xA237C32C |
| 742 |
.long 0xA3D70A3E |
| 743 |
.long 0xA57EB503 |
| 744 |
.long 0xA72F053A |
| 745 |
.long 0xA8E83F58 |
| 746 |
.long 0xAAAAAAAB |
| 747 |
.long 0xAC769185 |
| 748 |
.long 0xAE4C415D |
| 749 |
.long 0xB02C0B03 |
| 750 |
.long 0xB21642C9 |
| 751 |
.long 0xB40B40B5 |
| 752 |
.long 0xB60B60B7 |
| 753 |
.long 0xB81702E1 |
| 754 |
.long 0xBA2E8BA3 |
| 755 |
.long 0xBC52640C |
| 756 |
.long 0xBE82FA0C |
| 757 |
.long 0xC0C0C0C1 |
| 758 |
.long 0xC30C30C4 |
| 759 |
.long 0xC565C87C |
| 760 |
.long 0xC7CE0C7D |
| 761 |
.long 0xCA4587E7 |
| 762 |
.long 0xCCCCCCCD |
| 763 |
.long 0xCF6474A9 |
| 764 |
.long 0xD20D20D3 |
| 765 |
.long 0xD4C77B04 |
| 766 |
.long 0xD79435E6 |
| 767 |
.long 0xDA740DA8 |
| 768 |
.long 0xDD67C8A7 |
| 769 |
.long 0xE070381D |
| 770 |
.long 0xE38E38E4 |
| 771 |
.long 0xE6C2B449 |
| 772 |
.long 0xEA0EA0EB |
| 773 |
.long 0xED7303B6 |
| 774 |
.long 0xF0F0F0F1 |
| 775 |
.long 0xF4898D60 |
| 776 |
.long 0xF83E0F84 |
| 777 |
.long 0xFC0FC0FD |
| 778 |
.long 0x4000000 |
| 779 |
.long 0x82082083 |
| 780 |
.long 0x84210843 |
| 781 |
.long 0x864B8A7E |
| 782 |
.long 0x88888889 |
| 783 |
.long 0x8AD8F2FC |
| 784 |
.long 0x8D3DCB09 |
| 785 |
.long 0x8FB823EF |
| 786 |
.long 0x92492493 |
| 787 |
.long 0x94F20950 |
| 788 |
.long 0x97B425EE |
| 789 |
.long 0x9A90E7DA |
| 790 |
.long 0x9D89D89E |
| 791 |
.long 0xA0A0A0A1 |
| 792 |
.long 0xA3D70A3E |
| 793 |
.long 0xA72F053A |
| 794 |
.long 0xAAAAAAAB |
| 795 |
.long 0xAE4C415D |
| 796 |
.long 0xB21642C9 |
| 797 |
.long 0xB60B60B7 |
| 798 |
.long 0xBA2E8BA3 |
| 799 |
.long 0xBE82FA0C |
| 800 |
.long 0xC30C30C4 |
| 801 |
.long 0xC7CE0C7D |
| 802 |
.long 0xCCCCCCCD |
| 803 |
.long 0xD20D20D3 |
| 804 |
.long 0xD79435E6 |
| 805 |
.long 0xDD67C8A7 |
| 806 |
.long 0xE38E38E4 |
| 807 |
.long 0xEA0EA0EB |
| 808 |
.long 0xF0F0F0F1 |
| 809 |
.long 0xF83E0F84 |
| 810 |
.long 0x8000000 |
| 811 |
.long 0x84210843 |
| 812 |
.long 0x88888889 |
| 813 |
.long 0x8D3DCB09 |
| 814 |
.long 0x92492493 |
| 815 |
.long 0x97B425EE |
| 816 |
.long 0x9D89D89E |
| 817 |
.long 0xA3D70A3E |
| 818 |
.long 0xAAAAAAAB |
| 819 |
.long 0xB21642C9 |
| 820 |
.long 0xBA2E8BA3 |
| 821 |
.long 0xC30C30C4 |
| 822 |
.long 0xCCCCCCCD |
| 823 |
.long 0xD79435E6 |
| 824 |
.long 0xE38E38E4 |
| 825 |
.long 0xF0F0F0F1 |
| 826 |
.long 0x10000000 |
| 827 |
.long 0x88888889 |
| 828 |
.long 0x92492493 |
| 829 |
.long 0x9D89D89E |
| 830 |
.long 0xAAAAAAAB |
| 831 |
.long 0xBA2E8BA3 |
| 832 |
.long 0xCCCCCCCD |
| 833 |
.long 0xE38E38E4 |
| 834 |
.long 0x20000000 |
| 835 |
.long 0x92492493 |
| 836 |
.long 0xAAAAAAAB |
| 837 |
.long 0xCCCCCCCD |
| 838 |
.long 0x40000000 |
| 839 |
.long 0xAAAAAAAB |
| 840 |
.long 0x80000000 |
| 841 |
__muldiv: |
| 842 |
neg r4,r2 |
| 843 |
ld.as r5,[pcl,r4] |
| 844 |
abs_s r12,r0 |
| 845 |
bic.f 0,r2,r4 |
| 846 |
mpyhu.ne r12,r12,r5 |
| 847 |
norm r3,r2 |
| 848 |
xor.f 0,r0,r1 |
| 849 |
; write port allocation stall |
| 850 |
rsub r3,r3,30 |
| 851 |
lsr r0,r12,r3 |
| 852 |
j_s.d [blink] |
| 853 |
neg.mi r0,r0 |
| 854 |
|
| 855 |
.balign 4 |
| 856 |
SYM(__divsi3): |
| 857 |
norm r3,r1 |
| 858 |
abs_s r2,r1 |
| 859 |
brhs r3,23,__muldiv |
| 860 |
norm r4,r0 |
| 861 |
abs_l r12,r0 |
| 862 |
brhs r4,r3,.Lonebit |
| 863 |
asl_s r2,r2,r3 |
| 864 |
asl r12,r12,r4 |
| 865 |
sub lp_count,r3,r4 |
| 866 |
sub.f r12,r12,r2 |
| 867 |
brge.d r12,r2,.Lsbit |
| 868 |
sub r4,r3,r4 |
| 869 |
add.lo r12,r12,r2 |
| 870 |
lp .Ldivend |
| 871 |
.Ldivstart:divaw r12,r12,r2 |
| 872 |
.Ldivend:xor_s r1,r1,r0 |
| 873 |
sub r0,r4,1 |
| 874 |
bmsk r0,r12,r0 |
| 875 |
bset.hs r0,r0,r4 |
| 876 |
tst_s r1,r1 |
| 877 |
j_s.d [blink] |
| 878 |
neg.mi r0,r0 |
| 879 |
.Lonebit: |
| 880 |
xor_s r1,r1,r0 |
| 881 |
asr_s r1,r1,31 |
| 882 |
sub1.f 0,r12,r2 ; special case: -2**(n+1) / 2**n |
| 883 |
or r0,r1,1 |
| 884 |
add.eq r0,r0,r0 |
| 885 |
cmp_s r12,r2 |
| 886 |
j_s.d [blink] |
| 887 |
mov.lo r0,0 |
| 888 |
.Lsbit: |
| 889 |
; Need to handle special cases involving negative powers of two: |
| 890 |
; r12,r2 are normalized dividend / divisor; |
| 891 |
; divide anything by 0x80000000, or divide 0x80000000 by 0x40000000 |
| 892 |
add_s r12,r12,r2 |
| 893 |
xor_s r1,r1,r0 |
| 894 |
rsub r4,r4,-1 |
| 895 |
ror r0,r12,r4 |
| 896 |
tst_s r2,r2 |
| 897 |
bmsk r0,r0,r3 |
| 898 |
add.pl r0,r0,r0 |
| 899 |
tst_s r1,r1 |
| 900 |
j_s.d [blink] |
| 901 |
neg.mi r0,r0 |
| 902 |
#else /* !MULDIV */ |
| 903 |
/* This version requires that divaw works with a divisor of 0x80000000U */ |
| 904 |
abs_s r2,r1 |
| 905 |
norm r4,r0 |
| 906 |
neg_s r3,r2 |
| 907 |
norm r3,r3 |
| 908 |
abs_s r12,r0 |
| 909 |
brhs r4,r3,.Lonebit |
| 910 |
asl_s r2,r2,r3 |
| 911 |
asl r12,r12,r4 |
| 912 |
sub lp_count,r3,r4 |
| 913 |
cmp_s r12,r2 |
| 914 |
sub.hs r12,r12,r2 |
| 915 |
lp .Ldivend |
| 916 |
.Ldivstart:divaw r12,r12,r2 |
| 917 |
.Ldivend:xor_s r1,r1,r0 |
| 918 |
sub_s r0,r3,1 |
| 919 |
bmsk r0,r12,r0 |
| 920 |
bset.hs r0,r0,r3 |
| 921 |
tst_s r1,r1 |
| 922 |
j_s.d [blink] |
| 923 |
negmi r0,r0 |
| 924 |
.Lonebit: |
| 925 |
xor_s r1,r1,r0 |
| 926 |
asr_s r1,r1,31 |
| 927 |
cmp_s r12,r2 |
| 928 |
mov_s r0,0 |
| 929 |
j_s.d [blink] |
| 930 |
orhs r0,r1,1 |
| 931 |
#endif /* MULDIV */ |
| 932 |
|
| 933 |
#endif /* ifndef __ARC700__ */ |
| 934 |
ENDFUNC(__divsi3) |
| 935 |
|
| 936 |
|
| 937 |
#endif /* L_divsi3 */ |
| 938 |
|
| 939 |
#ifndef __ARC_RF16__ |
| 940 |
#ifdef L_umodsi3 |
| 941 |
.section .text |
| 942 |
.align 4 |
| 943 |
|
| 944 |
.global SYM(__umodsi3) |
| 945 |
FUNC(__umodsi3) |
| 946 |
SYM(__umodsi3): |
| 947 |
mov r7,blink |
| 948 |
bl.nd @SYM(__udivmodsi4) |
| 949 |
j.d [r7] |
| 950 |
mov r0,r1 |
| 951 |
ENDFUNC(__umodsi3) |
| 952 |
|
| 953 |
#endif /* L_umodsi3 */ |
| 954 |
#endif /* !__ARC_RF16__ */ |
| 955 |
|
| 956 |
#ifdef L_modsi3 |
| 957 |
.section .text |
| 958 |
.align 4 |
| 959 |
|
| 960 |
.global SYM (__modsi3) |
| 961 |
FUNC(__modsi3) |
| 962 |
SYM(__modsi3): |
| 963 |
#ifndef __ARC_EA__ |
| 964 |
/* A5 / ARC60? */ |
| 965 |
mov_s r12,blink |
| 966 |
mov_s r11,r0 |
| 967 |
abs_s r0,r0 |
| 968 |
bl.d @SYM(__udivmodsi4) |
| 969 |
abs_s r1,r1 |
| 970 |
tst r11,r11 |
| 971 |
neg_s r0,r1 |
| 972 |
j_s.d [r12] |
| 973 |
mov.pl r0,r1 |
| 974 |
#else /* __ARC_EA__ */ |
| 975 |
abs_s r2,r1 |
| 976 |
norm.f r4,r0 |
| 977 |
neg r5,r2 |
| 978 |
norm r3,r5 |
| 979 |
abs_l r12,r0 |
| 980 |
brhs r4,r3,.Lonebit |
| 981 |
asl_s r2,r2,r3 |
| 982 |
asl r12,r12,r4 |
| 983 |
sub lp_count,r3,r4 |
| 984 |
cmp_s r12,r2 |
| 985 |
sub.hs r12,r12,r2 |
| 986 |
tst_s r0,r0 |
| 987 |
lp .Ldivend |
| 988 |
.Ldivstart:divaw r12,r12,r2 |
| 989 |
.Ldivend: |
| 990 |
lsr r0,r12,r3 |
| 991 |
j_s.d [blink] |
| 992 |
neg.mi r0,r0 |
| 993 |
.balign 4 |
| 994 |
.Lonebit:neg.pl r5,r5 |
| 995 |
cmp_s r12,r2 |
| 996 |
j_s.d [blink] |
| 997 |
sub.hs r0,r0,r5 |
| 998 |
#endif /* !__ARC_EA__ */ |
| 999 |
ENDFUNC(__modsi3) |
| 1000 |
|
| 1001 |
#endif /* L_modsi3 */ |
| 1002 |
|
| 1003 |
#ifdef L_clzsi2 |
| 1004 |
.section .text |
| 1005 |
.align 4 |
| 1006 |
.global SYM (__clzsi2) |
| 1007 |
SYM(__clzsi2): |
| 1008 |
#ifdef __ARC_NORM__ |
| 1009 |
HIDDEN_FUNC(__clzsi2) |
| 1010 |
norm.f r0,r0 |
| 1011 |
mov.n r0,0 |
| 1012 |
j_s.d [blink] |
| 1013 |
add.pl r0,r0,1 |
| 1014 |
ENDFUNC(__clzsi2) |
| 1015 |
#elif !defined (__ARC_BARREL_SHIFTER__) |
| 1016 |
FUNC(__clzsi2) |
| 1017 |
mov lp_count,10 |
| 1018 |
mov_l r1,0 |
| 1019 |
bset r2,r1,29 |
| 1020 |
lp .Loop_end |
| 1021 |
brhs r0,r2,.Loop_end |
| 1022 |
add3 r0,r1,r0 |
| 1023 |
.Loop_end: |
| 1024 |
asl.f 0,r0 |
| 1025 |
sub2 r0,lp_count,lp_count |
| 1026 |
sub.cs.f r0,r0,1 |
| 1027 |
add r0,r0,31 |
| 1028 |
j_s.d [blink] |
| 1029 |
add.pl r0,r0,1 |
| 1030 |
ENDFUNC(__clzsi2) |
| 1031 |
#else |
| 1032 |
FUNC(__clzsi2) |
| 1033 |
asl.f 0,r0,2 |
| 1034 |
mov r1,-1 |
| 1035 |
.Lcheck: |
| 1036 |
bbit1.d r0,31,.Ldone |
| 1037 |
asl.pl r0,r0,3 |
| 1038 |
bcs.d .Ldone_1 |
| 1039 |
add_s r1,r1,3 |
| 1040 |
bpnz.d .Lcheck |
| 1041 |
asl.f 0,r0,2 |
| 1042 |
mov_s r0,32 |
| 1043 |
j_s.d [blink] |
| 1044 |
mov.ne r0,r1 |
| 1045 |
.Ldone: |
| 1046 |
j_s.d [blink] |
| 1047 |
add_s r0,r1,1 |
| 1048 |
.Ldone_1: |
| 1049 |
j_s.d [blink] |
| 1050 |
sub_s r0,r1,1 |
| 1051 |
ENDFUNC(__clzsi2) |
| 1052 |
#endif |
| 1053 |
#endif /* L_clzsi2 */ |
| 1054 |
.section .text |
| 1055 |
|
| 1056 |
|
| 1057 |
;;; MILLICODE THUNK LIB ;*************** |
| 1058 |
|
| 1059 |
;;; .macro push_regs from, to, offset |
| 1060 |
;;; st_s "\from", [sp, \offset] |
| 1061 |
;;; .if \to-\from |
| 1062 |
;;; push_regs "(\from+1)", \to, "(\offset+4)" |
| 1063 |
;;; .endif |
| 1064 |
;;; .endm |
| 1065 |
;;; push_regs 13, 18, 0 |
| 1066 |
;;; |
| 1067 |
|
| 1068 |
;;;; .macro sum from, to, three |
| 1069 |
;;;; .long \from |
| 1070 |
;;;; .long \three |
| 1071 |
;;;; .local regno |
| 1072 |
;;;; .set regno, \from+1 |
| 1073 |
;;;; .set shift, 32 |
| 1074 |
;;;; .set shift, shift - 1 |
| 1075 |
;;;; # st_s %shift @3 lsl #shift |
| 1076 |
;;;; .if \to-\from |
| 1077 |
;;;; sum "(\from+1)", \to, "(\three)" |
| 1078 |
;;;; .endif |
| 1079 |
;;;; .endm |
| 1080 |
;;;; |
| 1081 |
;;;; SUM 0,5, 9 |
| 1082 |
;;;; |
| 1083 |
; .altmacro |
| 1084 |
;; .macro push_regs from=0, to=3, offset |
| 1085 |
;; st_s r\from, [sp, \offset] |
| 1086 |
;; .if \to-\from |
| 1087 |
;; push_regs "\from+1 ",\to,"(\offset+4)" |
| 1088 |
;; .endif |
| 1089 |
;; .endm |
| 1090 |
;; |
| 1091 |
;; .macro expand_to_push from=13, to |
| 1092 |
;; ; .section .text |
| 1093 |
;; ; .align 4 |
| 1094 |
;; ; .global st_ |
| 1095 |
;; ; .type foo, |
| 1096 |
;; st_13_to_25: |
| 1097 |
;; ; push_regs \from, \to, 0 |
| 1098 |
;; push_regs 0,3 ; |
| 1099 |
;; .endm |
| 1100 |
;; |
| 1101 |
;; expand_to_push 13,18 |
| 1102 |
;; |
| 1103 |
;#endif |
| 1104 |
|
| 1105 |
#ifndef __ARC_RF16__ |
| 1106 |
#ifdef L_millicodethunk_st |
| 1107 |
.section .text |
| 1108 |
.align 4 |
| 1109 |
.global SYM(__st_r13_to_r15) |
| 1110 |
.global SYM(__st_r13_to_r16) |
| 1111 |
.global SYM(__st_r13_to_r17) |
| 1112 |
.global SYM(__st_r13_to_r18) |
| 1113 |
.global SYM(__st_r13_to_r19) |
| 1114 |
.global SYM(__st_r13_to_r20) |
| 1115 |
.global SYM(__st_r13_to_r21) |
| 1116 |
.global SYM(__st_r13_to_r22) |
| 1117 |
.global SYM(__st_r13_to_r23) |
| 1118 |
.global SYM(__st_r13_to_r24) |
| 1119 |
.global SYM(__st_r13_to_r25) |
| 1120 |
HIDDEN_FUNC(__st_r13_to_r15) |
| 1121 |
HIDDEN_FUNC(__st_r13_to_r16) |
| 1122 |
HIDDEN_FUNC(__st_r13_to_r17) |
| 1123 |
HIDDEN_FUNC(__st_r13_to_r18) |
| 1124 |
HIDDEN_FUNC(__st_r13_to_r19) |
| 1125 |
HIDDEN_FUNC(__st_r13_to_r20) |
| 1126 |
HIDDEN_FUNC(__st_r13_to_r21) |
| 1127 |
HIDDEN_FUNC(__st_r13_to_r22) |
| 1128 |
HIDDEN_FUNC(__st_r13_to_r23) |
| 1129 |
HIDDEN_FUNC(__st_r13_to_r24) |
| 1130 |
HIDDEN_FUNC(__st_r13_to_r25) |
| 1131 |
.align 4 |
| 1132 |
SYM(__st_r13_to_r25): |
| 1133 |
st r25, [sp,48] |
| 1134 |
SYM(__st_r13_to_r24): |
| 1135 |
st r24, [sp,44] |
| 1136 |
SYM(__st_r13_to_r23): |
| 1137 |
st r23, [sp,40] |
| 1138 |
SYM(__st_r13_to_r22): |
| 1139 |
st r22, [sp,36] |
| 1140 |
SYM(__st_r13_to_r21): |
| 1141 |
st r21, [sp,32] |
| 1142 |
SYM(__st_r13_to_r20): |
| 1143 |
st r20, [sp,28] |
| 1144 |
SYM(__st_r13_to_r19): |
| 1145 |
st r19, [sp,24] |
| 1146 |
SYM(__st_r13_to_r18): |
| 1147 |
st r18, [sp,20] |
| 1148 |
SYM(__st_r13_to_r17): |
| 1149 |
st r17, [sp,16] |
| 1150 |
SYM(__st_r13_to_r16): |
| 1151 |
st r16, [sp,12] |
| 1152 |
SYM(__st_r13_to_r15): |
| 1153 |
#ifdef __ARC700__ |
| 1154 |
st r15, [sp,8] ; minimum function size to avoid stall: 6 bytes. |
| 1155 |
#else |
| 1156 |
st_s r15, [sp,8] |
| 1157 |
#endif |
| 1158 |
st_s r14, [sp,4] |
| 1159 |
j_s.d [%blink] |
| 1160 |
st_s r13, [sp,0] |
| 1161 |
ENDFUNC(__st_r13_to_r15) |
| 1162 |
ENDFUNC(__st_r13_to_r16) |
| 1163 |
ENDFUNC(__st_r13_to_r17) |
| 1164 |
ENDFUNC(__st_r13_to_r18) |
| 1165 |
ENDFUNC(__st_r13_to_r19) |
| 1166 |
ENDFUNC(__st_r13_to_r20) |
| 1167 |
ENDFUNC(__st_r13_to_r21) |
| 1168 |
ENDFUNC(__st_r13_to_r22) |
| 1169 |
ENDFUNC(__st_r13_to_r23) |
| 1170 |
ENDFUNC(__st_r13_to_r24) |
| 1171 |
ENDFUNC(__st_r13_to_r25) |
| 1172 |
#endif /* L_millicodethunk_st */ |
| 1173 |
|
| 1174 |
|
| 1175 |
#ifdef L_millicodethunk_ld |
| 1176 |
.section .text |
| 1177 |
.align 4 |
| 1178 |
; ================================== |
| 1179 |
; the loads |
| 1180 |
|
| 1181 |
.global SYM(__ld_r13_to_r15) |
| 1182 |
.global SYM(__ld_r13_to_r16) |
| 1183 |
.global SYM(__ld_r13_to_r17) |
| 1184 |
.global SYM(__ld_r13_to_r18) |
| 1185 |
.global SYM(__ld_r13_to_r19) |
| 1186 |
.global SYM(__ld_r13_to_r20) |
| 1187 |
.global SYM(__ld_r13_to_r21) |
| 1188 |
.global SYM(__ld_r13_to_r22) |
| 1189 |
.global SYM(__ld_r13_to_r23) |
| 1190 |
.global SYM(__ld_r13_to_r24) |
| 1191 |
.global SYM(__ld_r13_to_r25) |
| 1192 |
HIDDEN_FUNC(__ld_r13_to_r15) |
| 1193 |
HIDDEN_FUNC(__ld_r13_to_r16) |
| 1194 |
HIDDEN_FUNC(__ld_r13_to_r17) |
| 1195 |
HIDDEN_FUNC(__ld_r13_to_r18) |
| 1196 |
HIDDEN_FUNC(__ld_r13_to_r19) |
| 1197 |
HIDDEN_FUNC(__ld_r13_to_r20) |
| 1198 |
HIDDEN_FUNC(__ld_r13_to_r21) |
| 1199 |
HIDDEN_FUNC(__ld_r13_to_r22) |
| 1200 |
HIDDEN_FUNC(__ld_r13_to_r23) |
| 1201 |
HIDDEN_FUNC(__ld_r13_to_r24) |
| 1202 |
HIDDEN_FUNC(__ld_r13_to_r25) |
| 1203 |
SYM(__ld_r13_to_r25): |
| 1204 |
ld r25, [sp,48] |
| 1205 |
SYM(__ld_r13_to_r24): |
| 1206 |
ld r24, [sp,44] |
| 1207 |
SYM(__ld_r13_to_r23): |
| 1208 |
ld r23, [sp,40] |
| 1209 |
SYM(__ld_r13_to_r22): |
| 1210 |
ld r22, [sp,36] |
| 1211 |
SYM(__ld_r13_to_r21): |
| 1212 |
ld r21, [sp,32] |
| 1213 |
SYM(__ld_r13_to_r20): |
| 1214 |
ld r20, [sp,28] |
| 1215 |
SYM(__ld_r13_to_r19): |
| 1216 |
ld r19, [sp,24] |
| 1217 |
SYM(__ld_r13_to_r18): |
| 1218 |
ld r18, [sp,20] |
| 1219 |
SYM(__ld_r13_to_r17): |
| 1220 |
ld r17, [sp,16] |
| 1221 |
SYM(__ld_r13_to_r16): |
| 1222 |
ld r16, [sp,12] |
| 1223 |
SYM(__ld_r13_to_r15): |
| 1224 |
#ifdef __ARC700__ |
| 1225 |
ld r15, [sp,8] ; minimum function size to avoid stall: 6 bytes. |
| 1226 |
#else |
| 1227 |
ld_s r15, [sp,8] |
| 1228 |
#endif |
| 1229 |
ld_s r14, [sp,4] |
| 1230 |
j_s.d [%blink] |
| 1231 |
ld_s r13, [sp,0] |
| 1232 |
ENDFUNC(__ld_r13_to_r15) |
| 1233 |
ENDFUNC(__ld_r13_to_r16) |
| 1234 |
ENDFUNC(__ld_r13_to_r17) |
| 1235 |
ENDFUNC(__ld_r13_to_r18) |
| 1236 |
ENDFUNC(__ld_r13_to_r19) |
| 1237 |
ENDFUNC(__ld_r13_to_r20) |
| 1238 |
ENDFUNC(__ld_r13_to_r21) |
| 1239 |
ENDFUNC(__ld_r13_to_r22) |
| 1240 |
ENDFUNC(__ld_r13_to_r23) |
| 1241 |
ENDFUNC(__ld_r13_to_r24) |
| 1242 |
ENDFUNC(__ld_r13_to_r25) |
| 1243 |
|
| 1244 |
#endif /* L_millicodethunk_ld */ |
| 1245 |
#ifdef L_millicodethunk_ret |
| 1246 |
.global SYM(__ld_r13_to_r14_ret) |
| 1247 |
.global SYM(__ld_r13_to_r15_ret) |
| 1248 |
.global SYM(__ld_r13_to_r16_ret) |
| 1249 |
.global SYM(__ld_r13_to_r17_ret) |
| 1250 |
.global SYM(__ld_r13_to_r18_ret) |
| 1251 |
.global SYM(__ld_r13_to_r19_ret) |
| 1252 |
.global SYM(__ld_r13_to_r20_ret) |
| 1253 |
.global SYM(__ld_r13_to_r21_ret) |
| 1254 |
.global SYM(__ld_r13_to_r22_ret) |
| 1255 |
.global SYM(__ld_r13_to_r23_ret) |
| 1256 |
.global SYM(__ld_r13_to_r24_ret) |
| 1257 |
.global SYM(__ld_r13_to_r25_ret) |
| 1258 |
HIDDEN_FUNC(__ld_r13_to_r14_ret) |
| 1259 |
HIDDEN_FUNC(__ld_r13_to_r15_ret) |
| 1260 |
HIDDEN_FUNC(__ld_r13_to_r16_ret) |
| 1261 |
HIDDEN_FUNC(__ld_r13_to_r17_ret) |
| 1262 |
HIDDEN_FUNC(__ld_r13_to_r18_ret) |
| 1263 |
HIDDEN_FUNC(__ld_r13_to_r19_ret) |
| 1264 |
HIDDEN_FUNC(__ld_r13_to_r20_ret) |
| 1265 |
HIDDEN_FUNC(__ld_r13_to_r21_ret) |
| 1266 |
HIDDEN_FUNC(__ld_r13_to_r22_ret) |
| 1267 |
HIDDEN_FUNC(__ld_r13_to_r23_ret) |
| 1268 |
HIDDEN_FUNC(__ld_r13_to_r24_ret) |
| 1269 |
HIDDEN_FUNC(__ld_r13_to_r25_ret) |
| 1270 |
.section .text |
| 1271 |
.align 4 |
| 1272 |
SYM(__ld_r13_to_r25_ret): |
| 1273 |
ld r25, [sp,48] |
| 1274 |
SYM(__ld_r13_to_r24_ret): |
| 1275 |
ld r24, [sp,44] |
| 1276 |
SYM(__ld_r13_to_r23_ret): |
| 1277 |
ld r23, [sp,40] |
| 1278 |
SYM(__ld_r13_to_r22_ret): |
| 1279 |
ld r22, [sp,36] |
| 1280 |
SYM(__ld_r13_to_r21_ret): |
| 1281 |
ld r21, [sp,32] |
| 1282 |
SYM(__ld_r13_to_r20_ret): |
| 1283 |
ld r20, [sp,28] |
| 1284 |
SYM(__ld_r13_to_r19_ret): |
| 1285 |
ld r19, [sp,24] |
| 1286 |
SYM(__ld_r13_to_r18_ret): |
| 1287 |
ld r18, [sp,20] |
| 1288 |
SYM(__ld_r13_to_r17_ret): |
| 1289 |
ld r17, [sp,16] |
| 1290 |
SYM(__ld_r13_to_r16_ret): |
| 1291 |
ld r16, [sp,12] |
| 1292 |
SYM(__ld_r13_to_r15_ret): |
| 1293 |
ld r15, [sp,8] |
| 1294 |
SYM(__ld_r13_to_r14_ret): |
| 1295 |
ld blink,[sp,r12] |
| 1296 |
ld_s r14, [sp,4] |
| 1297 |
ld.ab r13, [sp,r12] |
| 1298 |
j_s.d [%blink] |
| 1299 |
add_s sp,sp,4 |
| 1300 |
ENDFUNC(__ld_r13_to_r14_ret) |
| 1301 |
ENDFUNC(__ld_r13_to_r15_ret) |
| 1302 |
ENDFUNC(__ld_r13_to_r16_ret) |
| 1303 |
ENDFUNC(__ld_r13_to_r17_ret) |
| 1304 |
ENDFUNC(__ld_r13_to_r18_ret) |
| 1305 |
ENDFUNC(__ld_r13_to_r19_ret) |
| 1306 |
ENDFUNC(__ld_r13_to_r20_ret) |
| 1307 |
ENDFUNC(__ld_r13_to_r21_ret) |
| 1308 |
ENDFUNC(__ld_r13_to_r22_ret) |
| 1309 |
ENDFUNC(__ld_r13_to_r23_ret) |
| 1310 |
ENDFUNC(__ld_r13_to_r24_ret) |
| 1311 |
ENDFUNC(__ld_r13_to_r25_ret) |
| 1312 |
|
| 1313 |
#endif /* L_millicodethunk_ret */ |
| 1314 |
|
| 1315 |
#if defined (__ARC700__) || defined (__ARC_FPX_QUARK__) |
| 1316 |
#ifdef L_adddf3 |
| 1317 |
#ifdef __ARC_NORM__ |
| 1318 |
#include "ieee-754/adddf3.S" |
| 1319 |
#endif |
| 1320 |
#endif |
| 1321 |
|
| 1322 |
#ifdef L_muldf3 |
| 1323 |
#ifdef __ARC_MPY__ |
| 1324 |
#include "ieee-754/muldf3.S" |
| 1325 |
#elif defined (__ARC_NORM__) && defined(__ARC_MUL64__) |
| 1326 |
#include "ieee-754/arc600-mul64/muldf3.S" |
| 1327 |
#elif defined (__ARC_NORM__) && defined(__ARC_MUL32BY16__) |
| 1328 |
#include "ieee-754/arc600-dsp/muldf3.S" |
| 1329 |
#endif |
| 1330 |
#endif |
| 1331 |
|
| 1332 |
#ifdef L_addsf3 |
| 1333 |
#ifdef __ARC_NORM__ |
| 1334 |
#include "ieee-754/addsf3.S" |
| 1335 |
#endif |
| 1336 |
#endif |
| 1337 |
|
| 1338 |
#ifdef L_mulsf3 |
| 1339 |
#ifdef __ARC_MPY__ |
| 1340 |
#include "ieee-754/mulsf3.S" |
| 1341 |
#elif defined (__ARC_NORM__) && defined(__ARC_MUL64__) |
| 1342 |
#include "ieee-754/arc600-mul64/mulsf3.S" |
| 1343 |
#elif defined (__ARC_NORM__) && defined(__ARC_MUL32BY16__) |
| 1344 |
#include "ieee-754/arc600-dsp/mulsf3.S" |
| 1345 |
#elif defined (__ARC_NORM__) |
| 1346 |
#include "ieee-754/arc600/mulsf3.S" |
| 1347 |
#endif |
| 1348 |
#endif |
| 1349 |
|
| 1350 |
#ifdef L_divdf3 |
| 1351 |
#ifdef __ARC_MPY__ |
| 1352 |
#include "ieee-754/divdf3.S" |
| 1353 |
#elif defined (__ARC_NORM__) && defined(__ARC_MUL64__) |
| 1354 |
#include "ieee-754/arc600-mul64/divdf3.S" |
| 1355 |
#elif defined (__ARC_NORM__) && defined(__ARC_MUL32BY16__) |
| 1356 |
#include "ieee-754/arc600-dsp/divdf3.S" |
| 1357 |
#endif |
| 1358 |
#endif |
| 1359 |
|
| 1360 |
#ifdef L_divsf3 |
| 1361 |
#ifdef __ARC_MPY__ |
| 1362 |
#include "ieee-754/divsf3-stdmul.S" |
| 1363 |
#elif defined (__ARC_NORM__) && defined(__ARC_MUL64__) |
| 1364 |
#include "ieee-754/arc600-mul64/divsf3.S" |
| 1365 |
#elif defined (__ARC_NORM__) && defined(__ARC_MUL32BY16__) |
| 1366 |
#include "ieee-754/arc600-dsp/divsf3.S" |
| 1367 |
#elif defined (__ARC_NORM__) |
| 1368 |
#include "ieee-754/arc600/divsf3.S" |
| 1369 |
#endif |
| 1370 |
#endif |
| 1371 |
|
| 1372 |
#ifdef L_extendsfdf2 |
| 1373 |
#ifdef __ARC_NORM__ |
| 1374 |
#include "ieee-754/extendsfdf2.S" |
| 1375 |
#endif |
| 1376 |
#endif |
| 1377 |
|
| 1378 |
#ifdef L_truncdfsf2 |
| 1379 |
#ifdef __ARC_NORM__ |
| 1380 |
#include "ieee-754/truncdfsf2.S" |
| 1381 |
#endif |
| 1382 |
#endif |
| 1383 |
|
| 1384 |
#ifdef L_floatsidf |
| 1385 |
#ifdef __ARC_NORM__ |
| 1386 |
#include "ieee-754/floatsidf.S" |
| 1387 |
#endif |
| 1388 |
#endif |
| 1389 |
|
| 1390 |
#ifdef L_floatsisf |
| 1391 |
#ifdef __ARC_NORM__ |
| 1392 |
#include "ieee-754/floatsisf.S" |
| 1393 |
#endif |
| 1394 |
#endif |
| 1395 |
|
| 1396 |
#ifdef L_floatunsidf |
| 1397 |
#ifdef __ARC_NORM__ |
| 1398 |
#include "ieee-754/floatunsidf.S" |
| 1399 |
#endif |
| 1400 |
#endif |
| 1401 |
|
| 1402 |
#ifdef L_fixdfsi |
| 1403 |
#ifdef __ARC_NORM__ |
| 1404 |
#include "ieee-754/fixdfsi.S" |
| 1405 |
#endif |
| 1406 |
#endif |
| 1407 |
|
| 1408 |
#ifdef L_fixsfsi |
| 1409 |
#ifdef __ARC_NORM__ |
| 1410 |
#include "ieee-754/fixsfsi.S" |
| 1411 |
#endif |
| 1412 |
#endif |
| 1413 |
|
| 1414 |
#ifdef L_fixunsdfsi |
| 1415 |
#ifdef __ARC_NORM__ |
| 1416 |
#include "ieee-754/fixunsdfsi.S" |
| 1417 |
#endif |
| 1418 |
#endif |
| 1419 |
|
| 1420 |
#ifdef L_eqdf2 |
| 1421 |
#ifdef __ARC_NORM__ |
| 1422 |
#include "ieee-754/eqdf2.S" |
| 1423 |
#endif |
| 1424 |
#endif |
| 1425 |
|
| 1426 |
#ifdef L_eqsf2 |
| 1427 |
#ifdef __ARC_NORM__ |
| 1428 |
#include "ieee-754/eqsf2.S" |
| 1429 |
#endif |
| 1430 |
#endif |
| 1431 |
|
| 1432 |
#ifdef L_gtdf2 |
| 1433 |
#ifdef __ARC_NORM__ |
| 1434 |
#include "ieee-754/gtdf2.S" |
| 1435 |
#endif |
| 1436 |
#endif |
| 1437 |
|
| 1438 |
#ifdef L_gtsf2 |
| 1439 |
#ifdef __ARC_NORM__ |
| 1440 |
#include "ieee-754/gtsf2.S" |
| 1441 |
#endif |
| 1442 |
#endif |
| 1443 |
|
| 1444 |
#ifdef L_gedf2 |
| 1445 |
#ifdef __ARC_NORM__ |
| 1446 |
#include "ieee-754/gedf2.S" |
| 1447 |
#endif |
| 1448 |
#endif |
| 1449 |
|
| 1450 |
#ifdef L_gesf2 |
| 1451 |
#ifdef __ARC_NORM__ |
| 1452 |
#include "ieee-754/gesf2.S" |
| 1453 |
#endif |
| 1454 |
#endif |
| 1455 |
|
| 1456 |
#ifdef L_uneqdf2 |
| 1457 |
#ifdef __ARC_NORM__ |
| 1458 |
#include "ieee-754/uneqdf2.S" |
| 1459 |
#endif |
| 1460 |
#endif |
| 1461 |
|
| 1462 |
#ifdef L_uneqsf2 |
| 1463 |
#ifdef __ARC_NORM__ |
| 1464 |
#include "ieee-754/uneqsf2.S" |
| 1465 |
#endif |
| 1466 |
#endif |
| 1467 |
|
| 1468 |
#ifdef L_orddf2 |
| 1469 |
#ifdef __ARC_NORM__ |
| 1470 |
#include "ieee-754/orddf2.S" |
| 1471 |
#endif |
| 1472 |
#endif |
| 1473 |
|
| 1474 |
#ifdef L_ordsf2 |
| 1475 |
#ifdef __ARC_NORM__ |
| 1476 |
#include "ieee-754/ordsf2.S" |
| 1477 |
#endif |
| 1478 |
#endif |
| 1479 |
#endif /* ARC_OPTFPE */ |
| 1480 |
|
| 1481 |
#endif /* !__ARC_RF16__ */ |