1 | /* Control when floating-point expressions are evaluated. x86 version. |
2 | Copyright (C) 2007-2021 Free Software Foundation, Inc. |
3 | This file is part of the GNU C Library. |
4 | |
5 | The GNU C Library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2.1 of the License, or (at your option) any later version. |
9 | |
10 | The GNU C Library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Lesser General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Lesser General Public |
16 | License along with the GNU C Library; if not, see |
17 | <https://www.gnu.org/licenses/>. */ |
18 | |
19 | #ifndef X86_MATH_BARRIERS_H |
20 | #define X86_MATH_BARRIERS_H 1 |
21 | |
22 | #ifdef __SSE2_MATH__ |
23 | # define math_opt_barrier(x) \ |
24 | ({ __typeof(x) __x; \ |
25 | if (sizeof (x) <= sizeof (double) \ |
26 | || __builtin_types_compatible_p (__typeof (x), _Float128)) \ |
27 | __asm ("" : "=x" (__x) : "0" (x)); \ |
28 | else \ |
29 | __asm ("" : "=t" (__x) : "0" (x)); \ |
30 | __x; }) |
31 | # define math_force_eval(x) \ |
32 | do { \ |
33 | if (sizeof (x) <= sizeof (double) \ |
34 | || __builtin_types_compatible_p (__typeof (x), _Float128)) \ |
35 | __asm __volatile ("" : : "x" (x)); \ |
36 | else \ |
37 | __asm __volatile ("" : : "f" (x)); \ |
38 | } while (0) |
39 | #else |
40 | # define math_opt_barrier(x) \ |
41 | ({ __typeof (x) __x; \ |
42 | if (__builtin_types_compatible_p (__typeof (x), _Float128)) \ |
43 | { \ |
44 | __x = (x); \ |
45 | __asm ("" : "+m" (__x)); \ |
46 | } \ |
47 | else \ |
48 | __asm ("" : "=t" (__x) : "0" (x)); \ |
49 | __x; }) |
50 | # define math_force_eval(x) \ |
51 | do { \ |
52 | __typeof (x) __x = (x); \ |
53 | if (sizeof (x) <= sizeof (double) \ |
54 | || __builtin_types_compatible_p (__typeof (x), _Float128)) \ |
55 | __asm __volatile ("" : : "m" (__x)); \ |
56 | else \ |
57 | __asm __volatile ("" : : "f" (__x)); \ |
58 | } while (0) |
59 | #endif |
60 | |
61 | #endif |
62 | |