Path: blob/main/contrib/llvm-project/compiler-rt/lib/builtins/clzti2.c
35260 views
//===-- clzti2.c - Implement __clzti2 -------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file implements __clzti2 for the compiler_rt library.9//10//===----------------------------------------------------------------------===//1112#include "int_lib.h"1314#ifdef CRT_HAS_128BIT1516// Returns: the number of leading 0-bits1718// Precondition: a != 01920COMPILER_RT_ABI int __clzti2(ti_int a) {21twords x;22x.all = a;23const di_int f = -(x.s.high == 0);24return __builtin_clzll((x.s.high & ~f) | (x.s.low & f)) +25((si_int)f & ((si_int)(sizeof(di_int) * CHAR_BIT)));26}2728#endif // CRT_HAS_128BIT293031