Path: blob/main/contrib/llvm-project/compiler-rt/lib/builtins/ashldi3.c
35260 views
// ====-- ashldi3.c - Implement __ashldi3 ---------------------------------===//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 __ashldi3 for the compiler_rt library.9//10//===----------------------------------------------------------------------===//1112#include "int_lib.h"1314// Returns: a << b1516// Precondition: 0 <= b < bits_in_dword1718COMPILER_RT_ABI di_int __ashldi3(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 */ {24result.s.low = 0;25result.s.high = input.s.low << (b - bits_in_word);26} else /* 0 <= b < bits_in_word */ {27if (b == 0)28return a;29result.s.low = input.s.low << b;30result.s.high =31((su_int)input.s.high << b) | (input.s.low >> (bits_in_word - b));32}33return result.all;34}3536#if defined(__ARM_EABI__)37COMPILER_RT_ALIAS(__ashldi3, __aeabi_llsl)38#endif394041