1156cd587Sjoerg /* ====-- ashldi3.c - Implement __ashldi3 -----------------------------------=== 2156cd587Sjoerg * 3156cd587Sjoerg * The LLVM Compiler Infrastructure 4156cd587Sjoerg * 5156cd587Sjoerg * This file is dual licensed under the MIT and the University of Illinois Open 6156cd587Sjoerg * Source Licenses. See LICENSE.TXT for details. 7156cd587Sjoerg * 8156cd587Sjoerg * ===----------------------------------------------------------------------=== 9156cd587Sjoerg * 10156cd587Sjoerg * This file implements __ashldi3 for the compiler_rt library. 11156cd587Sjoerg * 12156cd587Sjoerg * ===----------------------------------------------------------------------=== 13156cd587Sjoerg */ 14156cd587Sjoerg 15156cd587Sjoerg #include "int_lib.h" 16156cd587Sjoerg 17156cd587Sjoerg /* Returns: a << b */ 18156cd587Sjoerg 19156cd587Sjoerg /* Precondition: 0 <= b < bits_in_dword */ 20156cd587Sjoerg 21156cd587Sjoerg COMPILER_RT_ABI di_int __ashldi3(di_int a,si_int b)22156cd587Sjoerg__ashldi3(di_int a, si_int b) 23156cd587Sjoerg { 24156cd587Sjoerg const int bits_in_word = (int)(sizeof(si_int) * CHAR_BIT); 25156cd587Sjoerg dwords input; 26156cd587Sjoerg dwords result; 27156cd587Sjoerg input.all = a; 28156cd587Sjoerg if (b & bits_in_word) /* bits_in_word <= b < bits_in_dword */ 29156cd587Sjoerg { 30156cd587Sjoerg result.s.low = 0; 31156cd587Sjoerg result.s.high = input.s.low << (b - bits_in_word); 32156cd587Sjoerg } 33156cd587Sjoerg else /* 0 <= b < bits_in_word */ 34156cd587Sjoerg { 35156cd587Sjoerg if (b == 0) 36156cd587Sjoerg return a; 37156cd587Sjoerg result.s.low = input.s.low << b; 38156cd587Sjoerg result.s.high = (input.s.high << b) | (input.s.low >> (bits_in_word - b)); 39156cd587Sjoerg } 40156cd587Sjoerg return result.all; 41156cd587Sjoerg } 423044ee7eSrin 433044ee7eSrin #if defined(__ARM_EABI__) 44*d3143459Srin AEABI_RTABI di_int __aeabi_llsl(di_int a, si_int b) COMPILER_RT_ALIAS(__ashldi3); 453044ee7eSrin #endif 46