Add some missing 64-bit math functions for gcc
[mirror_edk2.git] / ArmPkg / Library / CompilerIntrinsicsLib / Arm / ctzsi2.S
1 #------------------------------------------------------------------------------
2 #
3 # Copyright (c) 2008-2010 Apple Inc. All rights reserved.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are licensed and made available under the terms and conditions of the BSD License
7 # which accompanies this distribution. The full text of the license may be found at
8 # http://opensource.org/licenses/bsd-license.php
9 #
10 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 #
13 #------------------------------------------------------------------------------
14
15 .text
16 .align 2
17 .globl ___ctzsi2
18 ___ctzsi2:
19 @ args = 0, pretend = 0, frame = 0
20 @ frame_needed = 0, uses_anonymous_args = 0
21 @ link register save eliminated.
22 uxth r3, r0
23 cmp r3, #0
24 moveq ip, #16
25 movne ip, #0
26 @ lr needed for prologue
27 mov r0, r0, lsr ip
28 tst r0, #255
29 movne r3, #0
30 moveq r3, #8
31 mov r0, r0, lsr r3
32 tst r0, #15
33 movne r1, #0
34 moveq r1, #4
35 add r3, r3, ip
36 mov r0, r0, lsr r1
37 tst r0, #3
38 movne r2, #0
39 moveq r2, #2
40 add r3, r3, r1
41 mov r0, r0, lsr r2
42 and r0, r0, #3
43 add r2, r3, r2
44 eor r3, r0, #1
45 mov r0, r0, lsr #1
46 ands r3, r3, #1
47 mvnne r3, #0
48 rsb r0, r0, #2
49 and r0, r3, r0
50 add r0, r2, r0
51 bx lr