Merge aosp-toolchain/gcc/gcc-4_9 changes.
[official-gcc.git] / gcc-4_9 / gcc / testsuite / gcc.target / nios2 / custom-fp-conversion.c
blob20b2159960e7d93f922c88b62c346acb3f02f88b
1 /* Test generation of conversion custom instructions. */
3 /* { dg-do compile } */
4 /* { dg-options "-O1 -ffinite-math-only -funsafe-math-optimizations" } */
6 /* -O1 in the options is significant. Without it FP operations may not be
7 optimized to custom instructions. */
9 #include <stdio.h>
10 #include <math.h>
12 #pragma GCC target ("custom-frdxhi=40")
13 #pragma GCC target ("custom-frdxlo=41")
14 #pragma GCC target ("custom-frdy=42")
15 #pragma GCC target ("custom-fwrx=43")
16 #pragma GCC target ("custom-fwry=44")
18 #pragma GCC target ("custom-fextsd=100")
19 #pragma GCC target ("custom-fixdi=101")
20 #pragma GCC target ("custom-fixdu=102")
21 #pragma GCC target ("custom-fixsi=103")
22 #pragma GCC target ("custom-fixsu=104")
23 #pragma GCC target ("custom-floatid=105")
24 #pragma GCC target ("custom-floatis=106")
25 #pragma GCC target ("custom-floatud=107")
26 #pragma GCC target ("custom-floatus=108")
27 #pragma GCC target ("custom-ftruncds=109")
29 typedef struct data {
30 double fextsd;
31 int fixdi;
32 unsigned fixdu;
33 int fixsi;
34 unsigned fixsu;
35 double floatid;
36 float floatis;
37 double floatud;
38 float floatus;
39 float ftruncds;
40 } data_t;
42 void
43 custom_fp (int i, unsigned u, float f, double d, data_t *out)
45 out->fextsd = (double) f;
46 out->fixdi = (int) d;
47 out->fixdu = (unsigned) d;
48 out->fixsi = (int) f;
49 out->fixsu = (unsigned) f;
50 out->floatid = (double) i;
51 out->floatis = (float) i;
52 out->floatud = (double) u;
53 out->floatus = (float) u;
54 out->ftruncds = (float) d;
57 /* { dg-final { scan-assembler "custom\\t100, .* # fextsd .*" } } */
58 /* { dg-final { scan-assembler "custom\\t101, .* # fixdi .*" } } */
59 /* { dg-final { scan-assembler "custom\\t102, .* # fixdu .*" } } */
60 /* { dg-final { scan-assembler "custom\\t103, .* # fixsi .*" } } */
61 /* { dg-final { scan-assembler "custom\\t104, .* # fixsu .*" } } */
62 /* { dg-final { scan-assembler "custom\\t105, .* # floatid .*" } } */
63 /* { dg-final { scan-assembler "custom\\t106, .* # floatis .*" } } */
64 /* { dg-final { scan-assembler "custom\\t107, .* # floatud .*" } } */
65 /* { dg-final { scan-assembler "custom\\t108, .* # floatus .*" } } */
66 /* { dg-final { scan-assembler "custom\\t109, .* # ftruncds .*" } } */