1 /*
2  * Copyright (c) 2014 Advanced Micro Devices, Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 
23 #define SNAN 0x001
24 #define QNAN 0x002
25 #define NINF 0x004
26 #define NNOR 0x008
27 #define NSUB 0x010
28 #define NZER 0x020
29 #define PZER 0x040
30 #define PSUB 0x080
31 #define PNOR 0x100
32 #define PINF 0x200
33 
34 #define HAVE_HW_FMA32() (1)
35 #define HAVE_BITALIGN() (0)
36 #define HAVE_FAST_FMA32() (0)
37 
38 #define MATH_DIVIDE(X, Y) ((X) / (Y))
39 #define MATH_RECIP(X) (1.0f / (X))
40 #define MATH_SQRT(X) sqrt(X)
41 
42 #define SIGNBIT_SP32      0x80000000
43 #define EXSIGNBIT_SP32    0x7fffffff
44 #define EXPBITS_SP32      0x7f800000
45 #define MANTBITS_SP32     0x007fffff
46 #define ONEEXPBITS_SP32   0x3f800000
47 #define TWOEXPBITS_SP32   0x40000000
48 #define HALFEXPBITS_SP32  0x3f000000
49 #define IMPBIT_SP32       0x00800000
50 #define QNANBITPATT_SP32  0x7fc00000
51 #define INDEFBITPATT_SP32 0xffc00000
52 #define PINFBITPATT_SP32  0x7f800000
53 #define NINFBITPATT_SP32  0xff800000
54 #define EXPBIAS_SP32      127
55 #define EXPSHIFTBITS_SP32 23
56 #define BIASEDEMIN_SP32   1
57 #define EMIN_SP32         -126
58 #define BIASEDEMAX_SP32   254
59 #define EMAX_SP32         127
60 #define LAMBDA_SP32       1.0e30
61 #define MANTLENGTH_SP32   24
62 #define BASEDIGITS_SP32   7
63 
64 #ifdef cl_khr_fp64
65 
66 #define SIGNBIT_DP64      0x8000000000000000L
67 #define EXSIGNBIT_DP64    0x7fffffffffffffffL
68 #define EXPBITS_DP64      0x7ff0000000000000L
69 #define MANTBITS_DP64     0x000fffffffffffffL
70 #define ONEEXPBITS_DP64   0x3ff0000000000000L
71 #define TWOEXPBITS_DP64   0x4000000000000000L
72 #define HALFEXPBITS_DP64  0x3fe0000000000000L
73 #define IMPBIT_DP64       0x0010000000000000L
74 #define QNANBITPATT_DP64  0x7ff8000000000000L
75 #define INDEFBITPATT_DP64 0xfff8000000000000L
76 #define PINFBITPATT_DP64  0x7ff0000000000000L
77 #define NINFBITPATT_DP64  0xfff0000000000000L
78 #define EXPBIAS_DP64      1023
79 #define EXPSHIFTBITS_DP64 52
80 #define BIASEDEMIN_DP64   1
81 #define EMIN_DP64         -1022
82 #define BIASEDEMAX_DP64   2046 /* 0x7fe */
83 #define EMAX_DP64         1023 /* 0x3ff */
84 #define LAMBDA_DP64       1.0e300
85 #define MANTLENGTH_DP64   53
86 #define BASEDIGITS_DP64   15
87 
88 #endif // cl_khr_fp64
89 
90 #define ALIGNED(x)	__attribute__((aligned(x)))
91