1 /* Copyright (C) 2002, 2003 Free Software Foundation.
3 Verify that all the __builtin_ math functions are recognized
6 Written by Roger Sayle, 11th July 2002. */
8 /* { dg-do compile } */
9 /* { dg-options "" } */
10 /* { dg-final { scan-assembler-not "__builtin_" } } */
12 /* These helper macros ensure we also check the float and long double
15 /* Test FP functions taking void. */
17 double test_##FN(void) { return __builtin_##FN(); } \
18 float test_##FN##f(void) { return __builtin_##FN##f(); } \
19 long double test_##FN##l(void) { return __builtin_##FN##l(); }
21 /* Test FP functions taking one FP argument. */
23 double test_##FN(double x) { return __builtin_##FN(x); } \
24 float test_##FN##f(float x) { return __builtin_##FN##f(x); } \
25 long double test_##FN##l(long double x) { return __builtin_##FN##l(x); }
27 /* Test FP functions taking one argument of a supplied type. */
28 #define FPTEST1ARG(FN, TYPE) \
29 double test_##FN(TYPE x) { return __builtin_##FN(x); } \
30 float test_##FN##f(TYPE x) { return __builtin_##FN##f(x); } \
31 long double test_##FN##l(TYPE x) { return __builtin_##FN##l(x); }
33 /* Test FP functions taking two arguments, the first argument is of a
35 #define FPTEST2ARG1(FN, TYPE) \
36 double test_##FN(TYPE x, double y) { return __builtin_##FN(x, y); } \
37 float test_##FN##f(TYPE x, float y) { return __builtin_##FN##f(x, y); } \
38 long double test_##FN##l(TYPE x, long double y) { return __builtin_##FN##l(x, y); }
40 /* Test FP functions taking two arguments, the second argument is of a
42 #define FPTEST2ARG2(FN, TYPE) \
43 double test_##FN(double x, TYPE y) { return __builtin_##FN(x, y); } \
44 float test_##FN##f(float x, TYPE y) { return __builtin_##FN##f(x, y); } \
45 long double test_##FN##l(long double x, TYPE y) { return __builtin_##FN##l(x, y); }
47 /* Test FP functions taking two arguments, the second argument is of a
48 supplied type. The function is named reentrant style, meaning "_r"
49 appears after the possible f/l suffix. */
50 #define FPTEST2ARG2_REENT(FN, TYPE) \
51 double test_##FN##_r(double x, TYPE y) { return __builtin_##FN##_r(x, y); } \
52 float test_##FN##f_r(float x, TYPE y) { return __builtin_##FN##f_r(x, y); } \
53 long double test_##FN##l_r(long double x, TYPE y) { return __builtin_##FN##l_r(x, y); }
55 /* Test FP functions taking two arguments, the second argument is a
57 #define FPTEST2FPP2(FN) \
58 double test_##FN(double x, double *y) { return __builtin_##FN(x, y); } \
59 float test_##FN##f(float x, float *y) { return __builtin_##FN##f(x, y); } \
60 long double test_##FN##l(long double x, long double *y) { return __builtin_##FN##l(x, y); }
62 /* Test FP functions taking one FP argument and a supplied return
64 #define FPTEST1RET(FN, TYPE) \
65 TYPE test_##FN(double x) { return __builtin_##FN(x); } \
66 TYPE test_##FN##f(float x) { return __builtin_##FN##f(x); } \
67 TYPE test_##FN##l(long double x) { return __builtin_##FN##l(x); }
69 /* Test FP functions taking two FP arguments. */
71 double test_##FN(double x, double y) { return __builtin_##FN(x, y); } \
72 float test_##FN##f(float x, float y) { return __builtin_##FN##f(x, y); } \
73 long double test_##FN##l(long double x, long double y) { return __builtin_##FN##l(x, y); }
75 /* Test FP functions taking three FP arguments. */
77 double test_##FN(double x, double y, double z) { return __builtin_##FN(x, y, z); } \
78 float test_##FN##f(float x, float y, float z) { return __builtin_##FN##f(x, y, z); } \
79 long double test_##FN##l(long double x, long double y, long double z) { return __builtin_##FN##l(x, y, z); }
81 /* Test FP functions taking three arguments, two FP and the third is
82 of a supplied type. */
83 #define FPTEST3ARG3(FN, TYPE) \
84 double test_##FN(double x, double y, TYPE z) { return __builtin_##FN(x, y, z); } \
85 float test_##FN##f(float x, float y, TYPE z) { return __builtin_##FN##f(x, y, z); } \
86 long double test_##FN##l(long double x, long double y, TYPE z) { return __builtin_##FN##l(x, y, z); }
88 /* Test FP functions taking three FP arguments. The second and third
89 are FP pointers. The return type is void. */
90 #define FPTEST3FPP23VOID(FN) \
91 double test_##FN(double x, double *y, double *z) { __builtin_##FN(x, y, z); return *y * *z; } \
92 float test_##FN##f(float x, float *y, float *z) { __builtin_##FN##f(x, y, z); return *y * *z; } \
93 long double test_##FN##l(long double x, long double *y, long double *z) { __builtin_##FN##l(x, y, z); return *y * *z; }
95 /* Test Complex functions taking one Complex argument. */
97 _Complex double test_##FN(_Complex double x) { return __builtin_##FN(x); } \
98 _Complex float test_##FN##f(_Complex float x) { return __builtin_##FN##f(x); } \
99 _Complex long double test_##FN##l(_Complex long double x) { return __builtin_##FN##l(x); }
101 /* Test Complex functions taking one Complex argument and returning an FP type. */
102 #define CPTEST1RETFP(FN) \
103 double test_##FN(_Complex double x) { return __builtin_##FN(x); } \
104 float test_##FN##f(_Complex float x) { return __builtin_##FN##f(x); } \
105 long double test_##FN##l(_Complex long double x) { return __builtin_##FN##l(x); }
107 /* Test Complex functions taking two Complex arguments. */
108 #define CPTEST2(FN) \
109 _Complex double test_##FN(_Complex double x, _Complex double y) { return __builtin_##FN(x,y); } \
110 _Complex float test_##FN##f(_Complex float x, _Complex float y) { return __builtin_##FN##f(x,y); } \
111 _Complex long double test_##FN##l(_Complex long double x, _Complex long double y) { return __builtin_##FN##l(x,y); }
114 /* Keep this list sorted alphabetically by function name. */
141 FPTEST2ARG2 (frexp
, int *)
143 FPTEST2ARG2_REENT (gamma
, int *) /* gamma_r */
147 FPTEST0 (inf
) /* { dg-warning "target format does not support infinity" "inf" {target pdp11*-*-* } } */
150 FPTEST2ARG1 (jn
, int)
151 FPTEST2ARG2 (ldexp
, int)
153 FPTEST2ARG2_REENT (lgamma
, int *) /* lgamma_r */
154 FPTEST1RET (llrint
, long long)
155 FPTEST1RET (llround
, long long)
161 FPTEST1RET (lrint
, long)
162 FPTEST1RET (lround
, long)
170 FPTEST3ARG3 (remquo
, int *)
174 FPTEST2ARG2 (scalbln
, int)
175 FPTEST2ARG2 (scalbn
, int)
176 FPTEST1RET (signbit
, int)
177 FPTEST1 (significand
)
179 FPTEST3FPP23VOID (sincos
)
188 FPTEST2ARG1 (yn
, int)
190 /* Keep this list sorted alphabetically by function name. */