]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Library/CompilerIntrinsicsLib/Arm/lshrdi3.c
BaseTools/VfrCompile: clean Framework Vfr support
[mirror_edk2.git] / ArmPkg / Library / CompilerIntrinsicsLib / Arm / lshrdi3.c
1 /** @file
2
3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8 /**
9 University of Illinois/NCSA
10 Open Source License
11
12 Copyright (c) 2003-2008 University of Illinois at Urbana-Champaign.
13 All rights reserved.
14
15 Developed by:
16
17 LLVM Team
18
19 University of Illinois at Urbana-Champaign
20
21 http://llvm.org
22
23 Permission is hereby granted, free of charge, to any person obtaining a copy of
24 this software and associated documentation files (the "Software"), to deal with
25 the Software without restriction, including without limitation the rights to
26 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
27 of the Software, and to permit persons to whom the Software is furnished to do
28 so, subject to the following conditions:
29
30 * Redistributions of source code must retain the above copyright notice,
31 this list of conditions and the following disclaimers.
32
33 * Redistributions in binary form must reproduce the above copyright notice,
34 this list of conditions and the following disclaimers in the
35 documentation and/or other materials provided with the distribution.
36
37 * Neither the names of the LLVM Team, University of Illinois at
38 Urbana-Champaign, nor the names of its contributors may be used to
39 endorse or promote products derived from this Software without specific
40 prior written permission.
41
42 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
44 FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
45 CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
46 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
47 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
48 SOFTWARE.
49 **/
50
51 #include "Llvm_int_lib.h"
52
53 // Returns: logical a >> b
54
55 // Precondition: 0 <= b < bits_in_dword
56
57 INT64
58 __lshrdi3(INT64 a, INT32 b)
59 {
60 const int bits_in_word = (int)(sizeof(INT32) * CHAR_BIT);
61 udwords input;
62 udwords result;
63 input.all = a;
64 if (b & bits_in_word) // bits_in_word <= b < bits_in_dword
65 {
66 result.high = 0;
67 result.low = input.high >> (b - bits_in_word);
68 }
69 else // 0 <= b < bits_in_word
70 {
71 if (b == 0)
72 return a;
73 result.high = input.high >> b;
74 result.low = (input.high << (bits_in_word - b)) | (input.low >> b);
75 }
76 return result.all;
77 }