llvm-project
39 строк · 1.2 Кб
1// ====-- ashldi3.c - Implement __ashldi3 ---------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements __ashldi3 for the compiler_rt library.
10//
11//===----------------------------------------------------------------------===//
12
13#include "int_lib.h"14
15// Returns: a << b
16
17// Precondition: 0 <= b < bits_in_dword
18
19COMPILER_RT_ABI di_int __ashldi3(di_int a, int b) {20const int bits_in_word = (int)(sizeof(si_int) * CHAR_BIT);21dwords input;22dwords result;23input.all = a;24if (b & bits_in_word) /* bits_in_word <= b < bits_in_dword */ {25result.s.low = 0;26result.s.high = input.s.low << (b - bits_in_word);27} else /* 0 <= b < bits_in_word */ {28if (b == 0)29return a;30result.s.low = input.s.low << b;31result.s.high =32((su_int)input.s.high << b) | (input.s.low >> (bits_in_word - b));33}34return result.all;35}
36
37#if defined(__ARM_EABI__)38COMPILER_RT_ALIAS(__ashldi3, __aeabi_llsl)39#endif40