| /* ===-- clzsi2.c - Implement __clzsi2 -------------------------------------=== |
| * The LLVM Compiler Infrastructure |
| * This file is dual licensed under the MIT and the University of Illinois Open |
| * Source Licenses. See LICENSE.TXT for details. |
| * ===----------------------------------------------------------------------=== |
| * This file implements count leading zeros for 32bit arguments. |
| * ===----------------------------------------------------------------------=== |
| #if __ARM_ARCH_ISA_THUMB == 2 |
| #if __ARM_ARCH_ISA_THUMB == 2 |
| DEFINE_COMPILERRT_THUMB_FUNCTION(__clzsi2) |
| DEFINE_COMPILERRT_FUNCTION(__clzsi2) |
| * r1: count of leading zeros in n + 1 |
| * r2: scratch register for shifted r0 |
| * if ((r0 >> SHIFT) == 0) |
| * for descending powers of two as SHIFT. |
| * The basic block invariants at this point are (r0 >> 2) == 0 and |
| * r0 != 0. This means 1 <= r0 <= 3 and 0 <= (r0 >> 1) <= 1. |
| * r0 | (r0 >> 1) == 0 | (r0 >> 1) == 1 | -(r0 >> 1) | 1 - (r0 >> 1) |
| * ---+----------------+----------------+------------+-------------- |
| * The r1's initial value of 1 compensates for the 1 here. |
| #endif // __ARM_FEATURE_CLZ |
| END_COMPILERRT_FUNCTION(__clzsi2) |