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