xref: /openbsd/gnu/gcc/gcc/config/sparc/crtfastmath.c (revision 404b540a)
1*404b540aSrobert /*
2*404b540aSrobert  * Copyright (C) 2001 Free Software Foundation, Inc.
3*404b540aSrobert  * Contributed by David S. Miller (davem@redhat.com)
4*404b540aSrobert  *
5*404b540aSrobert  * This file is free software; you can redistribute it and/or modify it
6*404b540aSrobert  * under the terms of the GNU General Public License as published by the
7*404b540aSrobert  * Free Software Foundation; either version 2, or (at your option) any
8*404b540aSrobert  * later version.
9*404b540aSrobert  *
10*404b540aSrobert  * In addition to the permissions in the GNU General Public License, the
11*404b540aSrobert  * Free Software Foundation gives you unlimited permission to link the
12*404b540aSrobert  * compiled version of this file with other programs, and to distribute
13*404b540aSrobert  * those programs without any restriction coming from the use of this
14*404b540aSrobert  * file.  (The General Public License restrictions do apply in other
15*404b540aSrobert  * respects; for example, they cover modification of the file, and
16*404b540aSrobert  * distribution when not linked into another program.)
17*404b540aSrobert  *
18*404b540aSrobert  * This file is distributed in the hope that it will be useful, but
19*404b540aSrobert  * WITHOUT ANY WARRANTY; without even the implied warranty of
20*404b540aSrobert  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21*404b540aSrobert  * General Public License for more details.
22*404b540aSrobert  *
23*404b540aSrobert  * You should have received a copy of the GNU General Public License
24*404b540aSrobert  * along with this program; see the file COPYING.  If not, write to
25*404b540aSrobert  * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
26*404b540aSrobert  * Boston, MA 02110-1301, USA.
27*404b540aSrobert  *
28*404b540aSrobert  *    As a special exception, if you link this library with files
29*404b540aSrobert  *    compiled with GCC to produce an executable, this does not cause
30*404b540aSrobert  *    the resulting executable to be covered by the GNU General Public License.
31*404b540aSrobert  *    This exception does not however invalidate any other reasons why
32*404b540aSrobert  *    the executable file might be covered by the GNU General Public License.
33*404b540aSrobert  */
34*404b540aSrobert 
35*404b540aSrobert #define FPRS_NS		(1 << 22)	/* Non-Standard fpu results */
36*404b540aSrobert 
37*404b540aSrobert static void __attribute__((constructor))
set_fast_math(void)38*404b540aSrobert set_fast_math (void)
39*404b540aSrobert {
40*404b540aSrobert   unsigned int fsr;
41*404b540aSrobert 
42*404b540aSrobert   /* This works for the 64-bit case because, even if 32-bit ld/st of
43*404b540aSrobert      the fsr register modified the upper 32-bit, the only thing up there
44*404b540aSrobert      are the 3 other condition codes which are "do not care" at the time
45*404b540aSrobert      that this runs.  */
46*404b540aSrobert 
47*404b540aSrobert   __asm__("st %%fsr, %0"
48*404b540aSrobert 	  : "=m" (fsr));
49*404b540aSrobert 
50*404b540aSrobert   fsr |= FPRS_NS;
51*404b540aSrobert 
52*404b540aSrobert   __asm__("ld %0, %%fsr"
53*404b540aSrobert 	  : : "m" (fsr));
54*404b540aSrobert }
55