1bfb8b0676795fcfdd90e4ecba0042c6ed66e18e
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.reverse / insn-reverse.c
1 /* This testcase is part of GDB, the GNU debugger.
2
3 Copyright 2015-2016 Free Software Foundation, Inc.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program 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
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18 #if (defined __aarch64__)
19 #include <arm_neon.h>
20 #endif
21
22 #if (defined __aarch64__)
23 static void
24 load (void)
25 {
26 int buf[8];
27
28 asm ("ld1 { v1.8b }, [%[buf]]\n"
29 "ld1 { v2.8b, v3.8b }, [%[buf]]\n"
30 "ld1 { v3.8b, v4.8b, v5.8b }, [%[buf]]\n"
31 :
32 : [buf] "r" (buf)
33 : /* No clobbers */);
34 }
35
36 static void
37 move (void)
38 {
39 float32x2_t b1_ = vdup_n_f32(123.0f);
40 float32_t a1_ = 0;
41 float64x1_t b2_ = vdup_n_f64(456.0f);
42 float64_t a2_ = 0;
43
44 asm ("ins %0.s[0], %w1\n"
45 : "=w"(b1_)
46 : "r"(a1_), "0"(b1_)
47 : /* No clobbers */);
48
49 asm ("ins %0.d[1], %x1\n"
50 : "=w"(b2_)
51 : "r"(a2_), "0"(b2_)
52 : /* No clobbers */);
53 }
54
55 static void
56 adv_simd_mod_imm (void)
57 {
58 float32x2_t a1 = {2.0, 4.0};
59
60 asm ("bic %0.2s, #1\n"
61 "bic %0.2s, #1, lsl #8\n"
62 : "=w"(a1)
63 : "0"(a1)
64 : /* No clobbers */);
65 }
66
67 static void
68 adv_simd_scalar_index (void)
69 {
70 float64x2_t b_ = {0.0, 0.0};
71 float64_t a_ = 1.0;
72 float64_t result;
73
74 asm ("fmla %d0,%d1,%2.d[1]"
75 : "=w"(result)
76 : "w"(a_), "w"(b_)
77 : /* No clobbers */);
78 }
79
80 static void
81 adv_simd_smlal (void)
82 {
83 asm ("smlal v13.2d, v8.2s, v0.2s");
84 }
85
86 static void
87 adv_simd_vect_shift (void)
88 {
89 asm ("fcvtzs s0, s0, #1");
90 }
91 #endif
92
93 typedef void (*testcase_ftype) (void);
94
95 /* Functions testing instruction decodings. GDB will read n_testcases
96 to know how many functions to test. */
97
98 static testcase_ftype testcases[] =
99 {
100 #if (defined __aarch64__)
101 load,
102 move,
103 adv_simd_mod_imm,
104 adv_simd_scalar_index,
105 adv_simd_smlal,
106 adv_simd_vect_shift,
107 #endif
108 };
109
110 static int n_testcases = (sizeof (testcases) / sizeof (testcase_ftype));
111
112 int
113 main ()
114 {
115 int i = 0;
116
117 for (i = 0; i < n_testcases; i++)
118 testcases[i] ();
119
120 return 0;
121 }
This page took 0.034357 seconds and 3 git commands to generate.