ashldi3.c revision 276789
1168404Spjd/* ====-- ashldi3.c - Implement __ashldi3 -----------------------------------=== 2168404Spjd * 3168404Spjd * The LLVM Compiler Infrastructure 4168404Spjd * 5168404Spjd * This file is dual licensed under the MIT and the University of Illinois Open 6168404Spjd * Source Licenses. See LICENSE.TXT for details. 7168404Spjd * 8168404Spjd * ===----------------------------------------------------------------------=== 9168404Spjd * 10168404Spjd * This file implements __ashldi3 for the compiler_rt library. 11168404Spjd * 12168404Spjd * ===----------------------------------------------------------------------=== 13168404Spjd */ 14168404Spjd 15168404Spjd#include "int_lib.h" 16168404Spjd 17168404Spjd/* Returns: a << b */ 18168404Spjd 19168404Spjd/* Precondition: 0 <= b < bits_in_dword */ 20168404Spjd 21168404SpjdARM_EABI_FNALIAS(llsl, ashldi3) 22168404Spjd 23219089SpjdCOMPILER_RT_ABI di_int 24219089Spjd__ashldi3(di_int a, si_int b) 25223623Smm{ 26168404Spjd const int bits_in_word = (int)(sizeof(si_int) * CHAR_BIT); 27168404Spjd dwords input; 28168404Spjd dwords result; 29168404Spjd input.all = a; 30168404Spjd if (b & bits_in_word) /* bits_in_word <= b < bits_in_dword */ 31168404Spjd { 32168404Spjd result.s.low = 0; 33168404Spjd result.s.high = input.s.low << (b - bits_in_word); 34168404Spjd } 35168404Spjd else /* 0 <= b < bits_in_word */ 36185029Spjd { 37168404Spjd if (b == 0) 38168404Spjd return a; 39168404Spjd result.s.low = input.s.low << b; 40168404Spjd result.s.high = (input.s.high << b) | (input.s.low >> (bits_in_word - b)); 41185029Spjd } 42185029Spjd return result.all; 43185029Spjd} 44185029Spjd