Subversion Repositories freemyipod

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 theseven 1
/***************************************************************************
2
 *             __________               __   ___.
3
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
4
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
5
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
6
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
7
 *                     \/            \/     \/    \/            \/
8
 * $Id$
9
 *
10
 * Copyright (C) 2008 by Jens Arnold
11
 * Copyright (C) 2009 by Andrew Mahone
12
 *
13
 * Optimised replacements for libgcc functions
14
 *
15
 * Based on: libgcc routines for ARM cpu, additional algorithms from ARM System
16
 *           Developer's Guide
17
 * Division routines, written by Richard Earnshaw, (rearnsha@armltd.co.uk)
18
 * Copyright 1995, 1996, 1998, 1999, 2000, 2003, 2004, 2005
19
 * Free Software Foundation, Inc.
20
 *
21
 * This program is free software; you can redistribute it and/or
22
 * modify it under the terms of the GNU General Public License
23
 * as published by the Free Software Foundation; either version 2
24
 * of the License, or (at your option) any later version.
25
 *
26
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
27
 * KIND, either express or implied.
28
 *
29
 ****************************************************************************/
30
 
31
#define ASM_FILE
32
#include "global.h"
33
 
34
.macro ARM_SDIV32_PRE numerator, divisor, sign
35
    /* sign[31] = divisor sign */
36
    ands    \sign, \divisor, #1<<31
37
    rsbeq   \divisor, \divisor, #0
38
    /* sign[31] = result sign, sign[0:30], C = numerator sign */
39
    eors    \sign, \sign, \numerator, asr #32
40
    rsbcs   \numerator, \numerator, #0
41
.endm
42
 
43
.macro ARM_SDIV32_POST quotient, remainder, sign
44
    movs    \sign, \sign, lsl #1
45
.ifnc "", "\quotient"
46
    rsbcs   \quotient, \quotient, #0
47
.endif
48
.ifnc "", "\remainder"
49
    rsbmi   \remainder, \remainder, #0
50
.endif
51
.endm
52
 
53
#if ARM_ARCH < 5
54
.macro ARMV4_UDIV32_BODY numerator, divisor, quotient, remainder, tmp, bits, div0label, return
55
.ifnc "", "\div0label"
56
    rsbs    \divisor, \divisor, #0
57
    beq     \div0label
58
.else
59
    rsb     \divisor, \divisor, #0
60
.endif
61
    /* This SWAR divider requires a numerator less than 1<<31, because it must
62
       be able to shift the remainder left at each step without shifting out
63
       topmost bit. Since a shift might be needed for the aligned remainder to
64
       exceed the divisor, the topmost bit must be unset at the start to avoid
65
       this overflow case. The original numerator is saved so that the result
66
       can be corrected after the reduced division completes. */
67
    cmn     \numerator, \divisor
68
.ifc "", "\quotient"
69
.ifc "\numerator", "\remainder"
70
.if \return
71
    bxcc    lr
72
.else
73
    b 99f
74
.endif
75
.else
76
    bcc     20f
77
.endif
78
.else
79
    bcc     20f
80
.endif
81
    movs    \tmp, \numerator
82
    movmi   \numerator, \numerator, lsr #1
83
    mov     \bits, #30
84
.set shift, 16
85
.rept 5
86
    cmn     \divisor, \numerator, lsr #shift
87
    subcs   \bits, \bits, #shift
88
    movcs   \divisor, \divisor, lsl #shift
89
.set shift, shift >> 1
90
.endr
91
    adds    \numerator, \numerator, \divisor
92
    subcc   \numerator, \numerator, \divisor
93
    add     pc, pc, \bits, lsl #3
94
    nop
95
.rept 30
96
    adcs    \numerator, \divisor, \numerator, lsl #1
97
    subcc   \numerator, \numerator, \divisor
98
.endr
99
    adc     \numerator, \numerator, \numerator
100
    movs    \tmp, \tmp, asr #1
101
    rsb     \bits, \bits, #31
102
    bmi     10f
103
.ifc "", "\quotient"
104
    mov     \remainder, \numerator, lsr \bits
105
.else
106
.ifc "", "\remainder"
107
    mov     \divisor, \numerator, lsr \bits
108
    eor     \quotient, \numerator, \divisor, lsl \bits
109
.else
110
    mov     \remainder, \numerator, lsr \bits
111
    eor     \quotient, \numerator, \remainder, lsl \bits
112
.endif
113
.endif
114
.ifne \return
115
    bx      lr
116
.else
117
    b       99f
118
.endif
119
10:
120
    mov     \tmp, \numerator, lsr \bits
121
    eor     \numerator, \numerator, \tmp, lsl \bits
122
    sub     \bits, \bits, #1
123
    adc     \tmp, \tmp, \tmp
124
    adds    \tmp, \tmp, \divisor, asr \bits
125
.ifnc "", "\quotient"
126
    adc     \quotient, \numerator, \numerator
127
.endif
128
.ifnc "", "\remainder"
129
    subcc   \remainder, \tmp, \divisor, asr \bits
130
    movcs   \remainder, \tmp
131
.endif
132
.ifne \return
133
    bx      lr
134
.else
135
    b       99f
136
.endif
137
20:
138
.ifnc "", "\remainder"
139
.ifnc "\remainder", "\numerator"
140
    mov     \remainder, \numerator
141
.endif
142
.endif
143
.ifnc "", "\quotient"
144
    mov   \quotient, #0
145
.endif
146
.ifne \return
147
    bx      lr
148
.else
149
99:
150
.endif
151
.endm
152
 
153
.macro ARMV4_SDIV32_BODY numerator, divisor, quotient, remainder, bits, sign, div0label, return
154
    /* When this is wrapped for signed division, the wrapper code will handle
155
       inverting the divisor, and also the zero divisor test. */
156
    ARM_SDIV32_PRE \numerator, \divisor, \sign
157
.ifnc "",   "\div0label"
158
    tst     \divisor, \divisor
159
    beq     \div0label
160
.endif
161
    /* This SWAR divider requires a numerator less than 1<<31, because it must
162
       be able to shift the remainder left at each step without shifting out
163
       topmost bit. With signed inputs, whose absolute value may not exceed
164
       1<<31,this may be accomplished simply by subtracting the divisor before
165
       beginning division, and adding 1 to the quotient. */
166
    adds    \numerator, \numerator, \divisor
167
    bcc     20f
168
    mov     \bits, #30
169
.set shift, 16
170
.rept 5
171
    cmn     \divisor, \numerator, lsr #shift
172
    subcs   \bits, \bits, #shift
173
    movcs   \divisor, \divisor, lsl #shift
174
.set shift, shift >> 1
175
.endr
176
    adds    \numerator, \numerator, \divisor
177
    subcc   \numerator, \numerator, \divisor
178
    add     pc, pc, \bits, lsl #3
179
    nop
180
.rept 30
181
    adcs    \numerator, \divisor, \numerator, lsl #1
182
    subcc   \numerator, \numerator, \divisor
183
.endr
184
    rsb     \bits, \bits, #31
185
    adc     \numerator, \numerator, \numerator
186
.ifc "", "\quotient"
187
    mov     \remainder, \numerator, lsr \bits
188
.else
189
.ifc "", "\remainder"
190
    mov     \divisor, \numerator, lsr \bits
191
    add     \numerator, \numerator, #1
192
    sub     \quotient, \numerator, \divisor, lsl \bits
193
.else
194
    mov     \remainder, \numerator, lsr \bits
195
    add     \numerator, \numerator, #1
196
    sub     \quotient, \numerator, \remainder, lsl \bits
197
.endif
198
.endif
199
.ifne \return
200
    ARM_SDIV32_POST \quotient, \remainder, \sign
201
    bx      lr
202
.else
203
    b       99f
204
.endif
205
20:
206
.ifnc "", "\remainder"
207
    sub     \remainder, \numerator, \divisor
208
.endif
209
.ifnc "", "\quotient"
210
    mov     \quotient, #0
211
.endif
212
.ifne \return
213
    ARM_SDIV32_POST "", \remainder, \sign
214
    bx      lr
215
.else
216
99:
217
    ARM_SDIV32_POST \quotient, \remainder, \sign
218
.endif
219
.endm
220
 
221
#else
222
.macro ARMV5_UDIV32_BODY numerator, divisor, quotient, remainder, bits, inv, neg, div0label, return
223
    cmp     \numerator, \divisor
224
    clz     \bits, \divisor
225
    bcc     30f
226
    mov     \inv, \divisor, lsl \bits
227
    add     \neg, pc, \inv, lsr #25
228
    /* Test whether divisor is 2^N */
229
    cmp     \inv, #1<<31
230
    /* Load approximate reciprocal */
231
    ldrhib  \inv, [\neg, #.L_udiv_est_table-.-64]
232
    bls     20f
233
    subs    \bits, \bits, #7
234
    rsb     \neg, \divisor, #0
235
    /* Scale approximate reciprocal, or else branch to large-divisor path */
236
    movpl   \divisor, \inv, lsl \bits
237
    bmi     10f
238
    /* Newton-Raphson iteration to improve reciprocal accuracy */
239
    mul     \inv, \divisor, \neg
240
    smlawt  \divisor, \divisor, \inv, \divisor
241
    mul     \inv, \divisor, \neg
242
    /* Complete N-R math and produce approximate quotient. Use smmla/smmul on
243
       ARMv6. */
244
#if ARM_ARCH >= 6
245
    tst     \numerator, \numerator
246
    smmla   \divisor, \divisor, \inv, \divisor
247
    /* Branch to large-numerator handler, or else use smmul if sign bit is not
248
       set. This wins on average with random numerators, and should be no
249
       slower than using umull for small numerator, even if prediction fails.
250
    */
251
    bmi     40f
252
    smmul   \inv, \numerator, \divisor
253
#else
254
    /* ARMv5e lacks smmul, so always uses umull. */
255
    mov     \bits, #0
256
    smlal   \bits, \divisor, \inv, \divisor
257
    umull   \bits, \inv, \numerator, \divisor
258
#endif
259
    /* Calculate remainder and correct result. */
260
    add     \numerator, \numerator, \neg
261
.ifnc "", "\remainder"
262
    mla     \remainder, \inv, \neg, \numerator
263
.ifnc "", "\quotient"
264
    mov     \quotient, \inv
265
    cmn     \remainder, \neg
266
    subcs   \remainder, \remainder, \neg
267
    addpl   \remainder, \remainder, \neg, lsl #1
268
    addcc   \quotient, \quotient, #1
269
    addpl   \quotient, \quotient, #2
270
.else
271
    cmn     \remainder, \neg
272
    subcs   \remainder, \remainder, \neg
273
    addpl   \remainder, \remainder, \neg, lsl #1
274
.endif
275
.else
276
    mla     \divisor, \inv, \neg, \numerator
277
    mov     \quotient, \inv
278
    cmn     \divisor, \neg
279
    addcc   \quotient, \quotient, #1
280
    addpl   \quotient, \quotient, #2
281
.endif
282
.if \return
283
    bx      lr
284
.else
285
    b       99f
286
.endif
287
10:
288
    /* Very large divisors can be handled without further improving the
289
       reciprocal. First the reciprocal must be reduced to ensure that it
290
       underestimates the correct value. */
291
    rsb     \bits, \bits, #0
292
    sub     \inv, \inv, #4
293
    mov     \divisor, \inv, lsr \bits
294
    /* Calculate approximate quotient and remainder */
295
    umull   \bits, \inv, \numerator, \divisor
296
    /* Correct quotient and remainder */
297
.ifnc "", "\remainder"
298
    mla     \remainder, \inv, \neg, \numerator
299
.ifnc "", "\quotient"
300
    mov     \quotient, \inv
301
    cmn     \neg, \remainder, lsr #1
302
    addcs   \remainder, \remainder, \neg, lsl #1
303
    addcs   \quotient, \quotient, #2
304
    cmn     \neg, \remainder
305
    addcs   \remainder, \remainder, \neg
306
    addcs   \quotient, \quotient, #1
307
.else
308
    cmn     \neg, \remainder, lsr #1
309
    addcs   \remainder, \remainder, \neg, lsl #1
310
    cmn     \neg, \remainder
311
    addcs   \remainder, \remainder, \neg
312
.endif
313
.else
314
    mla     \divisor, \inv, \neg, \numerator
315
    mov     \quotient, \inv
316
    cmn     \neg, \divisor, lsr #1
317
    addcs   \divisor, \divisor, \neg, lsl #1
318
    addcs   \quotient, \quotient, #2
319
    cmn     \neg, \divisor
320
    addcs   \quotient, \quotient, #1
321
.endif
322
.if \return
323
    bx      lr
324
.else
325
    b       99f
326
.endif
327
20:
328
    /* Handle division by powers of two by shifting right. Mod is handled
329
       by using divisor-1 as a bitmask. */
330
.ifnc "", "\remainder"
331
.ifnc "", "\div0label"
332
    bne     \div0label
333
.endif
334
.ifnc "", "\quotient"
335
    sub     \divisor, \divisor, #1
336
    rsb     \bits, \bits, #31
337
    and     \remainder, \numerator, \divisor
338
    mov     \quotient, \numerator, lsr \bits
339
.else
340
    sub     \divisor, \divisor, #1
341
    and     \remainder, \numerator, \divisor
342
.endif
343
.else
344
    rsb     \bits, \bits, #31
345
.ifnc "", "\div0label"
346
    bne     \div0label
347
.endif
348
    mov     \quotient, \numerator, lsr \bits
349
.endif
350
.if \return
351
    bx      lr
352
.else
353
    b       99f
354
.endif
355
30:
356
    /* Handle numerator < divisor - quotient is zero, remainder is numerator,
357
       which must be restored to its original value on ARMv6. */
358
.ifnc "", "\remainder"
359
    mov     \remainder, \numerator
360
.endif
361
.ifnc "", "\quotient"
362
    mov     \quotient, #0
363
.endif
364
.if \return
365
    bx      lr
366
.endif
367
#if ARM_ARCH >= 6
368
40:
369
    /* Handle large (sign bit set) numerators. Works exactly as the ARMv5e code
370
       above 10:. */
371
    umull   \bits, \inv, \numerator, \divisor
372
    add     \numerator, \numerator, \neg
373
.ifnc "", "\remainder"
374
    mla     \remainder, \inv, \neg, \numerator
375
.ifnc "", "\quotient"
376
    mla     \remainder, \inv, \neg, \numerator
377
    mov     \quotient, \inv
378
    cmn     \remainder, \neg
379
    subcs   \remainder, \remainder, \neg
380
    addpl   \remainder, \remainder, \neg, lsl #1
381
    addcc   \quotient, \quotient, #1
382
    addpl   \quotient, \quotient, #2
383
.else
384
    cmn     \remainder, \neg
385
    subcs   \remainder, \remainder, \neg
386
    addpl   \remainder, \remainder, \neg, lsl #1
387
.endif
388
.else
389
    mla     \divisor, \inv, \neg, \numerator
390
    mov     \quotient, \inv
391
    cmn     \divisor, \neg
392
    addcc   \quotient, \quotient, #1
393
    addpl   \quotient, \quotient, #2
394
.endif
395
.if \return
396
    bx      lr
397
.else
398
    b       99f
399
.endif
400
#endif
401
99:
402
.endm
403
 
404
.macro ARMV5_SDIV32_BODY numerator, divisor, quotient, remainder, bits, inv, neg, sign, div0label, return
405
    /* sign[31] = divisor sign */
406
    ands    \sign, \divisor, #1<<31
407
    rsbne   \divisor, \divisor, #0
408
    /* sign[31] = result sign, sign[0:30], C = numerator sign */
409
    eors    \sign, \sign, \numerator, asr #32
410
    clz     \bits, \divisor
411
    rsbcs   \numerator, \numerator, #0
412
    /* On ARMv6, subtract divisor before performing division, which ensures
413
       numerator sign bit is clear and smmul may be used in place of umull. The
414
       fixup for the results can be fit entirely into existing delay slots on
415
       the main division paths. It costs 1c in the num<div path if the
416
       the remainder is to be produced in the numerator's register, and 1c in
417
       the power-of-2-divisor path only if producing both remainder and
418
       quotient. */
419
#if ARM_ARCH >= 6
420
    subs    \numerator, \numerator, \divisor
421
#else
422
    cmp     \numerator, \divisor
423
#endif
424
    movcs   \inv, \divisor, lsl \bits
425
    bcc     30f
426
    /* Test whether divisor is 2^N */
427
    cmp     \inv, #1<<31
428
    add     \inv, pc, \inv, lsr #25
429
    bls     20f
430
    /* Load approximate reciprocal */
431
    ldrb    \inv, [\inv, #.L_udiv_est_table-.-64]
432
    subs    \bits, \bits, #7
433
    rsb     \neg, \divisor, #0
434
    /* Scale approximate reciprocal, or else branch to large-divisor path */
435
    movpl   \divisor, \inv, lsl \bits
436
    bmi     10f
437
    /* Newton-Raphson iteration to improve reciprocal accuracy */
438
    mul     \inv, \divisor, \neg
439
    smlawt  \divisor, \divisor, \inv, \divisor
440
    mul     \inv, \divisor, \neg
441
    /* Complete N-R math and produce approximate quotient. Use smmla/smmul on
442
       ARMv6. */
443
#if ARM_ARCH >= 6
444
    smmla   \divisor, \divisor, \inv, \divisor
445
    smmul   \inv, \numerator, \divisor
446
#else
447
    mov     \bits, #0
448
    smlal   \bits, \divisor, \inv, \divisor
449
    umull   \bits, \inv, \numerator, \divisor
450
#endif
451
    /* Calculate remainder and correct quotient. */
452
    add     \numerator, \numerator, \neg
453
.ifnc "", "\remainder"
454
    mla     \remainder, \inv, \neg, \numerator
455
.ifnc "", "\quotient"
456
#if ARM_ARCH >= 6
457
    add     \quotient, \inv, #1
458
#else
459
    mov     \quotient, \inv
460
#endif
461
    cmn     \remainder, \neg
462
    subcs   \remainder, \remainder, \neg
463
    addpl   \remainder, \remainder, \neg, lsl #1
464
    addcc   \quotient, \quotient, #1
465
    addpl   \quotient, \quotient, #2
466
.else
467
    cmn     \remainder, \neg
468
    subcs   \remainder, \remainder, \neg
469
    addpl   \remainder, \remainder, \neg, lsl #1
470
.endif
471
.else
472
    mla     \divisor, \inv, \neg, \numerator
473
#if ARM_ARCH >= 6
474
    add     \quotient, \inv, #1
475
#else
476
    mov     \quotient, \inv
477
#endif
478
    cmn     \divisor, \neg
479
    addcc   \quotient, \quotient, #1
480
    addpl   \quotient, \quotient, #2
481
.endif
482
    ARM_SDIV32_POST \quotient, \remainder, \sign
483
.ifnc "", "\return"
484
    \return
485
.else
486
    b       99f
487
.endif
488
10:
489
    /* Very large divisors can be handled without further improving the
490
       reciprocal. First the reciprocal must be reduced to ensure that it
491
       underestimates the correct value. */
492
    rsb     \bits, \bits, #0
493
    sub     \inv, \inv, #4
494
    mov     \divisor, \inv, lsr \bits
495
    /* Calculate approximate quotient and remainder */
496
#if ARM_ARCH >= 6
497
    smmul   \inv, \numerator, \divisor
498
#else
499
    umull   \bits, \inv, \numerator, \divisor
500
#endif
501
    /* Correct quotient and remainder */
502
.ifnc "", "\remainder"
503
    mla     \remainder, \inv, \neg, \numerator
504
.ifnc "", "\quotient"
505
#if ARM_ARCH >= 6
506
    add     \quotient, \inv, #1
507
#else
508
    mov     \quotient, \inv
509
#endif
510
    cmn     \neg, \remainder, lsr #1
511
    addcs   \remainder, \remainder, \neg, lsl #1
512
    addcs   \quotient, \quotient, #2
513
    cmn     \neg, \remainder
514
    addcs   \remainder, \remainder, \neg
515
    addcs   \quotient, \quotient, #1
516
.else
517
    cmn     \neg, \remainder, lsr #1
518
    addcs   \remainder, \remainder, \neg, lsl #1
519
    cmn     \neg, \remainder
520
    addcs   \remainder, \remainder, \neg
521
.endif
522
.else
523
    mla     \divisor, \inv, \neg, \numerator
524
#if ARM_ARCH >= 6
525
    add     \quotient, \inv, #1
526
#else
527
    mov     \quotient, \inv
528
#endif
529
    cmn     \neg, \divisor, lsr #1
530
    addcs   \divisor, \divisor, \neg, lsl #1
531
    addcs   \quotient, \quotient, #2
532
    cmn     \neg, \divisor
533
    addcs   \quotient, \quotient, #1
534
.endif
535
    ARM_SDIV32_POST \quotient, \remainder, \sign
536
.ifnc "", "\return"
537
    \return
538
.else
539
    b       99f
540
.endif
541
20:
542
    /* Handle division by powers of two by shifting right. Mod is handled
543
       by using divisor-1 as a bitmask. */
544
.ifnc "", "\div0label"
545
    bne     \div0label
546
.endif
547
.ifnc "", "\remainder"
548
.ifnc "", "\quotient"
549
    rsb     \bits, \bits, #31
550
#if ARM_ARCH >= 6
551
    add     \numerator, \numerator, \divisor
552
#endif
553
    sub     \divisor, \divisor, #1
554
    and     \remainder, \numerator, \divisor
555
    mov     \quotient, \numerator, lsr \bits
556
.else
557
    sub     \divisor, \divisor, #1
558
    and     \remainder, \numerator, \divisor
559
.endif
560
.else
561
    rsb     \bits, \bits, #31
562
#if ARM_ARCH >= 6
563
    add     \numerator, \numerator, \divisor
564
#endif
565
    mov     \quotient, \numerator, lsr \bits
566
.endif
567
    ARM_SDIV32_POST \quotient, \remainder, \sign
568
.ifnc "", "\return"
569
    \return
570
.else
571
    b       99f
572
.endif
573
30:
574
    /* Handle numerator < divisor - quotient is zero, remainder is numerator,
575
       which must be restored to its original value on ARMv6. */
576
.ifnc "", "\remainder"
577
#if ARM_ARCH >= 6
578
    add     \remainder, \numerator, \divisor
579
#else
580
.ifnc "\remainder", "\numerator"
581
    mov     \remainder, \numerator
582
.endif
583
#endif
584
.endif
585
.ifnc "", "\quotient"
586
    mov     \quotient, #0
587
.endif
588
.ifnc "", "\remainder"
589
    ARM_SDIV32_POST "", \remainder, \sign
590
.endif
591
.ifnc "", "\return"
592
    \return
593
.endif
594
99:
595
.endm
596
#endif
597
 
598
    .section .text.__div0_wrap_s
599
__div0_wrap_s:
600
    sub sp, sp, #4
601
    b       __div0
602
    .size __div0_wrap_s, . - __div0_wrap_s
603
 
604
    .section .text.__div0_wrap
605
__div0_wrap:
606
    str     lr, [sp, #-4]!
607
    b       __div0
608
    .size __div0_wrap, . - __div0_wrap
609
 
610
#ifndef __ARM_EABI__
611
    .global __divsi3
612
    .type   __divsi3,%function
613
    .global __udivsi3
614
    .type   __udivsi3,%function
615
    .global __udivsi3
616
    .type   __udivsi3,%function
617
#else
618
/* The div+mod averagess a fraction of a cycle worse for signed values, and
619
   slightly better for unsigned, so just alias div to divmod. */
620
    .global __aeabi_uidivmod
621
    .type   __aeabi_uidivmod,%function
622
    .global __aeabi_uidiv
623
    .type   __aeabi_uidiv,%function
624
    .set    __aeabi_uidiv,__aeabi_uidivmod
625
    .global __aeabi_idivmod
626
    .type   __aeabi_idivmod,%function
627
    .global __aeabi_idiv
628
    .type   __aeabi_idiv,%function
629
    .set    __aeabi_idiv,__aeabi_idivmod
630
#endif
631
 
632
 
633
#if ARM_ARCH < 5
634
    .section .text.__clzsi2
635
    .global __clzsi2
636
    .type   __clzsi2, %function
637
 
638
__clzsi2:
639
    orr r0, r0, r0, lsr #8
640
    orr r0, r0, r0, lsr #4
641
    orr r0, r0, r0, lsr #2
642
    orr r0, r0, r0, lsr #1
643
    bic r0, r0, r0, lsr #16
644
    rsb r0, r0, r0, lsl #14
645
    rsb r0, r0, r0, lsl #11
646
    rsb r0, r0, r0, lsl #9
647
    ldrb r0, [pc, r0, lsr #26]
648
    bx lr
649
    .byte 32, 20, 19,  0,  0, 18,  0,  7, 10, 17,  0,  0, 14,  0,  6,  0
650
    .byte  0,  9,  0, 16,  0,  0,  1, 26,  0, 13,  0,  0, 24,  5,  0,  0
651
    .byte  0, 21,  0,  8, 11,  0, 15,  0,  0,  0,  0,  2, 27,  0, 25,  0
652
    .byte 22,  0, 12,  0,  0,  3, 28,  0, 23,  0,  4, 29,  0,  0, 30, 31
653
    .size __clzsi2, .-__clzsi2
654
 
6 theseven 655
    .section .text.__divisionhelpers
2 theseven 656
#ifndef __ARM_EABI__
657
__udivsi3:
658
    ARMV4_UDIV32_BODY r0, r1, r0, "", r2, r3, __div0_wrap, 1
659
    .size __udivsi3, . - __udivsi3
660
 
661
__divsi3:
662
    ARMV4_SDIV32_BODY r0, r1, r0, "", r2, r3, __div0_wrap, 1
663
    .size __divsi3, . - __divsi3
664
 
665
#else
666
__aeabi_uidivmod:
667
    ARMV4_UDIV32_BODY r0, r1, r0, r1, r2, r3, __div0_wrap, 1
869 theseven 668
    .size __aeabi_uidivmod, . - __aeabi_uidivmod
2 theseven 669
 
670
__aeabi_idivmod:
671
    ARMV4_SDIV32_BODY r0, r1, r0, r1, r2, r3, __div0_wrap, 1
672
    .size __aeabi_idivmod, . - __aeabi_idivmod
673
#endif
674
 
675
#else
147 theseven 676
    .global __clzsi2
677
    .type   __clzsi2, %function
678
 
679
__clzsi2:
680
    clz	r0, r0
681
    bx lr
682
 
2 theseven 683
#ifndef __ARM_EABI__
684
__udivsi3:
685
    ARMV5_UDIV32_BODY r0, r1, r0, "", r2, r3, ip, __div0_wrap, 1
686
    .size __udivsi3, . - __udivsi3
687
 
688
__divsi3:
689
    str lr, [sp, #-4]
690
    ARMV5_SDIV32_BODY r0, r1, r0, "", r2, lr, ip, r3, __div0_wrap_s, "ldr pc, [sp, #-4]"
691
    .size __divsi3, . - __divsi3
692
 
693
#else
694
__aeabi_uidivmod:
695
    ARMV5_UDIV32_BODY r0, r1, r0, r1, r2, r3, ip, __div0_wrap, 1
869 theseven 696
    .size __aeabi_uidivmod, . - __aeabi_uidivmod
2 theseven 697
 
698
__aeabi_idivmod:
699
    str lr, [sp, #-4]
700
    ARMV5_SDIV32_BODY r0, r1, r0, r1, r2, lr, ip, r3, __div0_wrap_s, "ldr pc, [sp, #-4]"
701
    .size __aeabi_idivmod, . - __aeabi_idivmod
702
#endif
703
 
704
.L_udiv_est_table:
705
    .byte 0xff, 0xfc, 0xf8, 0xf4, 0xf0, 0xed, 0xea, 0xe6
706
    .byte 0xe3, 0xe0, 0xdd, 0xda, 0xd7, 0xd4, 0xd2, 0xcf
707
    .byte 0xcc, 0xca, 0xc7, 0xc5, 0xc3, 0xc0, 0xbe, 0xbc
708
    .byte 0xba, 0xb8, 0xb6, 0xb4, 0xb2, 0xb0, 0xae, 0xac
709
    .byte 0xaa, 0xa8, 0xa7, 0xa5, 0xa3, 0xa2, 0xa0, 0x9f
710
    .byte 0x9d, 0x9c, 0x9a, 0x99, 0x97, 0x96, 0x94, 0x93
711
    .byte 0x92, 0x90, 0x8f, 0x8e, 0x8d, 0x8c, 0x8a, 0x89
712
    .byte 0x88, 0x87, 0x86, 0x85, 0x84, 0x83, 0x82, 0x81
713
#endif