[Clang][SME2] Enable multi-vector loads & stores for SME2 (#75821)
[llvm-project.git] / compiler-rt / lib / builtins / ashrdi3.c
blobc0879b8b252dea2360577b6ed2517889f09521b9
1 //===-- ashrdi3.c - Implement __ashrdi3 -----------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements __ashrdi3 for the compiler_rt library.
11 //===----------------------------------------------------------------------===//
13 #include "int_lib.h"
15 // Returns: arithmetic a >> b
17 // Precondition: 0 <= b < bits_in_dword
19 COMPILER_RT_ABI di_int __ashrdi3(di_int a, int b) {
20 const int bits_in_word = (int)(sizeof(si_int) * CHAR_BIT);
21 dwords input;
22 dwords result;
23 input.all = a;
24 if (b & bits_in_word) /* bits_in_word <= b < bits_in_dword */ {
25 // result.s.high = input.s.high < 0 ? -1 : 0
26 result.s.high = input.s.high >> (bits_in_word - 1);
27 result.s.low = input.s.high >> (b - bits_in_word);
28 } else /* 0 <= b < bits_in_word */ {
29 if (b == 0)
30 return a;
31 result.s.high = input.s.high >> b;
32 result.s.low =
33 ((su_int)input.s.high << (bits_in_word - b)) | (input.s.low >> b);
35 return result.all;
38 #if defined(__ARM_EABI__)
39 COMPILER_RT_ALIAS(__ashrdi3, __aeabi_lasr)
40 #endif