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