]>
Commit | Line | Data |
---|---|---|
d799c028 HL |
1 | /**\r |
2 | University of Illinois/NCSA\r | |
3 | Open Source License\r | |
4 | \r | |
5 | Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT\r | |
6 | \r | |
7 | All rights reserved.\r | |
8 | \r | |
9 | Developed by:\r | |
10 | \r | |
11 | LLVM Team\r | |
12 | \r | |
13 | University of Illinois at Urbana-Champaign\r | |
14 | \r | |
15 | http://llvm.org\r | |
16 | \r | |
17 | Permission is hereby granted, free of charge, to any person obtaining a copy of\r | |
18 | this software and associated documentation files (the "Software"), to deal with\r | |
19 | the Software without restriction, including without limitation the rights to\r | |
20 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\r | |
21 | of the Software, and to permit persons to whom the Software is furnished to do\r | |
22 | so, subject to the following conditions:\r | |
23 | \r | |
24 | * Redistributions of source code must retain the above copyright notice,\r | |
25 | this list of conditions and the following disclaimers.\r | |
26 | \r | |
27 | * Redistributions in binary form must reproduce the above copyright notice,\r | |
28 | this list of conditions and the following disclaimers in the\r | |
29 | documentation and/or other materials provided with the distribution.\r | |
30 | \r | |
31 | * Neither the names of the LLVM Team, University of Illinois at\r | |
32 | Urbana-Champaign, nor the names of its contributors may be used to\r | |
33 | endorse or promote products derived from this Software without specific\r | |
34 | prior written permission.\r | |
35 | \r | |
36 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r | |
37 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r | |
38 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r | |
39 | CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r | |
40 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r | |
41 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE\r | |
42 | SOFTWARE.\r | |
43 | **/\r | |
44 | \r | |
45 | #define DOUBLE_PRECISION\r | |
46 | #include "fp_lib.h"\r | |
47 | \r | |
48 | #include "int_lib.h"\r | |
49 | \r | |
50 | ARM_EABI_FNALIAS(ui2d, floatunsidf)\r | |
51 | \r | |
52 | COMPILER_RT_ABI fp_t\r | |
53 | __floatunsidf(unsigned int a) {\r | |
54 | \r | |
55 | const int aWidth = sizeof a * CHAR_BIT;\r | |
56 | \r | |
57 | // Handle zero as a special case to protect clz\r | |
58 | if (a == 0) return fromRep(0);\r | |
59 | \r | |
60 | // Exponent of (fp_t)a is the width of abs(a).\r | |
61 | const int exponent = (aWidth - 1) - __builtin_clz(a);\r | |
62 | rep_t result;\r | |
63 | \r | |
64 | // Shift a into the significand field and clear the implicit bit.\r | |
65 | const int shift = significandBits - exponent;\r | |
66 | result = (rep_t)a << shift ^ implicitBit;\r | |
67 | \r | |
68 | // Insert the exponent\r | |
69 | result += (rep_t)(exponent + exponentBias) << significandBits;\r | |
70 | return fromRep(result);\r | |
71 | }\r |