]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | \r | |
3 | Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r | |
4 | \r | |
5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
6 | \r | |
7 | **/\r | |
8 | /**\r | |
9 | University of Illinois/NCSA\r | |
10 | Open Source License\r | |
11 | \r | |
12 | Copyright (c) 2003-2008 University of Illinois at Urbana-Champaign.\r | |
13 | All rights reserved.\r | |
14 | \r | |
15 | Developed by:\r | |
16 | \r | |
17 | LLVM Team\r | |
18 | \r | |
19 | University of Illinois at Urbana-Champaign\r | |
20 | \r | |
21 | http://llvm.org\r | |
22 | \r | |
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 | |
29 | \r | |
30 | * Redistributions of source code must retain the above copyright notice,\r | |
31 | this list of conditions and the following disclaimers.\r | |
32 | \r | |
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 | |
36 | \r | |
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 | |
41 | \r | |
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: logical a >> b\r | |
54 | \r | |
55 | // Precondition: 0 <= b < bits_in_dword\r | |
56 | \r | |
57 | INT64\r | |
58 | __lshrdi3(INT64 a, INT32 b)\r | |
59 | {\r | |
60 | const int bits_in_word = (int)(sizeof(INT32) * CHAR_BIT);\r | |
61 | udwords input;\r | |
62 | udwords 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.high = 0;\r | |
67 | result.low = input.high >> (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.high = input.high >> b;\r | |
74 | result.low = (input.high << (bits_in_word - b)) | (input.low >> b);\r | |
75 | }\r | |
76 | return result.all;\r | |
77 | }\r |