Path: blob/main/contrib/llvm-project/compiler-rt/lib/builtins/ashrdi3.c
35260 views
//===-- ashrdi3.c - Implement __ashrdi3 -----------------------------------===//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 __ashrdi3 for the compiler_rt library.9//10//===----------------------------------------------------------------------===//1112#include "int_lib.h"1314// Returns: arithmetic a >> b1516// Precondition: 0 <= b < bits_in_dword1718COMPILER_RT_ABI di_int __ashrdi3(di_int a, int b) {19const int bits_in_word = (int)(sizeof(si_int) * CHAR_BIT);20dwords input;21dwords result;22input.all = a;23if (b & bits_in_word) /* bits_in_word <= b < bits_in_dword */ {24// result.s.high = input.s.high < 0 ? -1 : 025result.s.high = input.s.high >> (bits_in_word - 1);26result.s.low = input.s.high >> (b - bits_in_word);27} else /* 0 <= b < bits_in_word */ {28if (b == 0)29return a;30result.s.high = input.s.high >> b;31result.s.low =32((su_int)input.s.high << (bits_in_word - b)) | (input.s.low >> b);33}34return result.all;35}3637#if defined(__ARM_EABI__)38COMPILER_RT_ALIAS(__ashrdi3, __aeabi_lasr)39#endif404142