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 a
49 #define FPTEST2FPP2(FN) \
50 double test_##FN(double x, double *y) { return __builtin_##FN(x, y); } \
51 float test_##FN##f(float x, float *y) { return __builtin_##FN##f(x, y); } \
52 long double test_##FN##l(long double x, long double *y) { return __builtin_##FN##l(x, y); }
54 /* Test FP functions taking one FP argument and a supplied return
56 #define FPTEST1RET(FN, TYPE) \
57 TYPE test_##FN(double x) { return __builtin_##FN(x); } \
58 TYPE test_##FN##f(float x) { return __builtin_##FN##f(x); } \
59 TYPE test_##FN##l(long double x) { return __builtin_##FN##l(x); }
61 /* Test FP functions taking two FP arguments. */
63 double test_##FN(double x, double y) { return __builtin_##FN(x, y); } \
64 float test_##FN##f(float x, float y) { return __builtin_##FN##f(x, y); } \
65 long double test_##FN##l(long double x, long double y) { return __builtin_##FN##l(x, y); }
67 /* Test FP functions taking three FP arguments. */
69 double test_##FN(double x, double y, double z) { return __builtin_##FN(x, y, z); } \
70 float test_##FN##f(float x, float y, float z) { return __builtin_##FN##f(x, y, z); } \
71 long double test_##FN##l(long double x, long double y, long double z) { return __builtin_##FN##l(x, y, z); }
73 /* Test FP functions taking three arguments, two FP and the third is
74 of a supplied type. */
75 #define FPTEST3ARG3(FN, TYPE) \
76 double test_##FN(double x, double y, TYPE z) { return __builtin_##FN(x, y, z); } \
77 float test_##FN##f(float x, float y, TYPE z) { return __builtin_##FN##f(x, y, z); } \
78 long double test_##FN##l(long double x, long double y, TYPE z) { return __builtin_##FN##l(x, y, z); }
80 /* Test FP functions taking three FP arguments. The second and third
81 are FP pointers. The return type is void. */
82 #define FPTEST3FPP23VOID(FN) \
83 double test_##FN(double x, double *y, double *z) { __builtin_##FN(x, y, z); return *y * *z; } \
84 float test_##FN##f(float x, float *y, float *z) { __builtin_##FN##f(x, y, z); return *y * *z; } \
85 long double test_##FN##l(long double x, long double *y, long double *z) { __builtin_##FN##l(x, y, z); return *y * *z; }
87 /* Test Complex functions taking one Complex argument. */
89 _Complex double test_##FN(_Complex double x) { return __builtin_##FN(x); } \
90 _Complex float test_##FN##f(_Complex float x) { return __builtin_##FN##f(x); } \
91 _Complex long double test_##FN##l(_Complex long double x) { return __builtin_##FN##l(x); }
93 /* Test Complex functions taking one Complex argument and returning an FP type. */
94 #define CPTEST1RETFP(FN) \
95 double test_##FN(_Complex double x) { return __builtin_##FN(x); } \
96 float test_##FN##f(_Complex float x) { return __builtin_##FN##f(x); } \
97 long double test_##FN##l(_Complex long double x) { return __builtin_##FN##l(x); }
99 /* Test Complex functions taking two Complex arguments. */
100 #define CPTEST2(FN) \
101 _Complex double test_##FN(_Complex double x, _Complex double y) { return __builtin_##FN(x,y); } \
102 _Complex float test_##FN##f(_Complex float x, _Complex float y) { return __builtin_##FN##f(x,y); } \
103 _Complex long double test_##FN##l(_Complex long double x, _Complex long double y) { return __builtin_##FN##l(x,y); }
106 /* Keep this list sorted alphabetically by function name. */
133 FPTEST2ARG2 (frexp
, int *)
141 FPTEST2ARG1 (jn
, int)
142 FPTEST2ARG2 (ldexp
, int)
144 FPTEST1RET (llrint
, long long)
145 FPTEST1RET (llround
, long long)
151 FPTEST1RET (lrint
, long)
152 FPTEST1RET (lround
, long)
160 FPTEST3ARG3 (remquo
, int *)
164 FPTEST2ARG2 (scalbln
, int)
165 FPTEST2ARG2 (scalbn
, int)
166 FPTEST1RET (signbit
, int)
167 FPTEST1 (significand
)
169 FPTEST3FPP23VOID (sincos
)
178 FPTEST2ARG1 (yn
, int)
180 /* Keep this list sorted alphabetically by function name. */