11.1Sjoerg/* ====-- ashldi3.c - Implement __ashldi3 -----------------------------------===
21.1Sjoerg *
31.1Sjoerg *                     The LLVM Compiler Infrastructure
41.1Sjoerg *
51.1Sjoerg * This file is dual licensed under the MIT and the University of Illinois Open
61.1Sjoerg * Source Licenses. See LICENSE.TXT for details.
71.1Sjoerg *
81.1Sjoerg * ===----------------------------------------------------------------------===
91.1Sjoerg *
101.1Sjoerg * This file implements __ashldi3 for the compiler_rt library.
111.1Sjoerg *
121.1Sjoerg * ===----------------------------------------------------------------------===
131.1Sjoerg */
141.1Sjoerg
151.1Sjoerg#include "int_lib.h"
161.1Sjoerg
171.1Sjoerg/* Returns: a << b */
181.1Sjoerg
191.1Sjoerg/* Precondition:  0 <= b < bits_in_dword */
201.1Sjoerg
211.1SjoergCOMPILER_RT_ABI di_int
221.1Sjoerg__ashldi3(di_int a, si_int b)
231.1Sjoerg{
241.1Sjoerg    const int bits_in_word = (int)(sizeof(si_int) * CHAR_BIT);
251.1Sjoerg    dwords input;
261.1Sjoerg    dwords result;
271.1Sjoerg    input.all = a;
281.1Sjoerg    if (b & bits_in_word)  /* bits_in_word <= b < bits_in_dword */
291.1Sjoerg    {
301.1Sjoerg        result.s.low = 0;
311.1Sjoerg        result.s.high = input.s.low << (b - bits_in_word);
321.1Sjoerg    }
331.1Sjoerg    else  /* 0 <= b < bits_in_word */
341.1Sjoerg    {
351.1Sjoerg        if (b == 0)
361.1Sjoerg            return a;
371.1Sjoerg        result.s.low  = input.s.low << b;
381.1Sjoerg        result.s.high = (input.s.high << b) | (input.s.low >> (bits_in_word - b));
391.1Sjoerg    }
401.1Sjoerg    return result.all;
411.1Sjoerg}
421.2Srin
431.2Srin#if defined(__ARM_EABI__)
441.3SrinAEABI_RTABI di_int __aeabi_llsl(di_int a, si_int b) COMPILER_RT_ALIAS(__ashldi3);
451.2Srin#endif
46