1353358Sdim// ====-- ashldi3.c - Implement __ashldi3 ---------------------------------===// 2353358Sdim// 3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4353358Sdim// See https://llvm.org/LICENSE.txt for license information. 5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6353358Sdim// 7353358Sdim//===----------------------------------------------------------------------===// 8353358Sdim// 9353358Sdim// This file implements __ashldi3 for the compiler_rt library. 10353358Sdim// 11353358Sdim//===----------------------------------------------------------------------===// 12276789Sdim 13276789Sdim#include "int_lib.h" 14276789Sdim 15353358Sdim// Returns: a << b 16276789Sdim 17353358Sdim// Precondition: 0 <= b < bits_in_dword 18276789Sdim 19353358SdimCOMPILER_RT_ABI di_int __ashldi3(di_int a, si_int b) { 20353358Sdim const int bits_in_word = (int)(sizeof(si_int) * CHAR_BIT); 21353358Sdim dwords input; 22353358Sdim dwords result; 23353358Sdim input.all = a; 24353358Sdim if (b & bits_in_word) /* bits_in_word <= b < bits_in_dword */ { 25353358Sdim result.s.low = 0; 26353358Sdim result.s.high = input.s.low << (b - bits_in_word); 27353358Sdim } else /* 0 <= b < bits_in_word */ { 28353358Sdim if (b == 0) 29353358Sdim return a; 30353358Sdim result.s.low = input.s.low << b; 31353358Sdim result.s.high = (input.s.high << b) | (input.s.low >> (bits_in_word - b)); 32353358Sdim } 33353358Sdim return result.all; 34276789Sdim} 35321369Sdim 36321369Sdim#if defined(__ARM_EABI__) 37353358SdimCOMPILER_RT_ALIAS(__ashldi3, __aeabi_llsl) 38321369Sdim#endif 39