1 /* Control when floating-point expressions are evaluated.  s390 version.
2    Copyright (C) 2019-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 S390_MATH_BARRIERS_H
20 #define S390_MATH_BARRIERS_H 1
21 
22 #ifdef HAVE_S390_VX_GCC_SUPPORT
23 # define ASM_CONSTRAINT_VR "v"
24 # ifdef __LONG_DOUBLE_VX__
25 /* Starting with gcc 11, long double values can also be processed in vector
26    registers if build with -march >= z14.  Then GCC defines the
27    __LONG_DOUBLE_VX__ macro.  */
28 #  define ASM_LONG_DOUBLE_IN_VR 1
29 # else
30 #  define ASM_LONG_DOUBLE_IN_VR 0
31 # endif
32 #else
33 # define ASM_CONSTRAINT_VR
34 # define ASM_LONG_DOUBLE_IN_VR 0
35 #endif
36 
37 #define math_opt_barrier(x)						\
38   ({ __typeof (x) __x = (x);						\
39     if (! ASM_LONG_DOUBLE_IN_VR						\
40 	&& (__builtin_types_compatible_p (__typeof (x), _Float128)	\
41 	    || __builtin_types_compatible_p (__typeof (x), long double)	\
42 	    )								\
43 	)								\
44       __asm__ ("# math_opt_barrier_f128 %0" : "+fm" (__x));		\
45     else								\
46       __asm__ ("# math_opt_barrier %0"					\
47 	       : "+f" ASM_CONSTRAINT_VR "m" (__x));			\
48     __x; })
49 #define math_force_eval(x)						\
50   ({ __typeof (x) __x = (x);						\
51     if (! ASM_LONG_DOUBLE_IN_VR						\
52 	&& (__builtin_types_compatible_p (__typeof (x), _Float128)	\
53 	    || __builtin_types_compatible_p (__typeof (x), long double) \
54 	    )								\
55 	)								\
56       __asm__ __volatile__ ("# math_force_eval_f128 %0"			\
57 			    : : "fm" (__x));				\
58     else								\
59       __asm__ __volatile__ ("# math_force_eval %0"			\
60 			    : : "f" ASM_CONSTRAINT_VR "m" (__x));	\
61   })
62 
63 #endif
64