diff options
author | Soby Mathew <soby.mathew@arm.com> | 2018-11-07 16:56:03 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-07 16:56:03 +0000 |
commit | 621daddb60d7d4f7ab6b3244e0f57b5f8266a632 (patch) | |
tree | 5490d3d500d86de6a88aa5c8f7a20892b35875c9 /lib/compiler-rt/builtins/lshrdi3.c | |
parent | de4fc982a3a46448884fe1aac32e9773138a23c0 (diff) | |
parent | b56ec680800c851382777118e868c6a6d4996729 (diff) |
Merge pull request #1669 from sandrine-bailleux-arm/sb/rm-tzc-top-fn
Remove unneeded _tzc_get_max_top_addr() function
Diffstat (limited to 'lib/compiler-rt/builtins/lshrdi3.c')
-rw-r--r-- | lib/compiler-rt/builtins/lshrdi3.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/compiler-rt/builtins/lshrdi3.c b/lib/compiler-rt/builtins/lshrdi3.c new file mode 100644 index 00000000..67b2a766 --- /dev/null +++ b/lib/compiler-rt/builtins/lshrdi3.c @@ -0,0 +1,45 @@ +/* ===-- lshrdi3.c - Implement __lshrdi3 -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __lshrdi3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +/* Returns: logical a >> b */ + +/* Precondition: 0 <= b < bits_in_dword */ + +COMPILER_RT_ABI di_int +__lshrdi3(di_int a, si_int b) +{ + const int bits_in_word = (int)(sizeof(si_int) * CHAR_BIT); + udwords input; + udwords result; + input.all = a; + if (b & bits_in_word) /* bits_in_word <= b < bits_in_dword */ + { + result.s.high = 0; + result.s.low = input.s.high >> (b - bits_in_word); + } + else /* 0 <= b < bits_in_word */ + { + if (b == 0) + return a; + result.s.high = input.s.high >> b; + result.s.low = (input.s.high << (bits_in_word - b)) | (input.s.low >> b); + } + return result.all; +} + +#if defined(__ARM_EABI__) +AEABI_RTABI di_int __aeabi_llsr(di_int a, si_int b) COMPILER_RT_ALIAS(__lshrdi3); +#endif |