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 #elif (defined __arm__) 92 static void 93 ext_reg_load (void) 94 { 95 char in[8]; 96 97 asm ("vldr d0, [%0]" : : "r" (in)); 98 asm ("vldr s3, [%0]" : : "r" (in)); 99 100 asm ("vldm %0, {d3-d4}" : : "r" (in)); 101 asm ("vldm %0, {s9-s11}" : : "r" (in)); 102 } 103 104 static void 105 ext_reg_mov (void) 106 { 107 int i, j; 108 double d; 109 110 i = 1; 111 j = 2; 112 113 asm ("vmov s4, s5, %0, %1" : "=r" (i), "=r" (j): ); 114 asm ("vmov s7, s8, %0, %1" : "=r" (i), "=r" (j): ); 115 asm ("vmov %0, %1, s10, s11" : : "r" (i), "r" (j)); 116 asm ("vmov %0, %1, s1, s2" : : "r" (i), "r" (j)); 117 118 asm ("vmov %P2, %0, %1" : "=r" (i), "=r" (j): "w" (d)); 119 asm ("vmov %1, %2, %P0" : "=w" (d) : "r" (i), "r" (j)); 120 } 121 122 static void 123 ext_reg_push_pop (void) 124 { 125 double d; 126 127 asm ("vpush {%P0}" : : "w" (d)); 128 asm ("vpop {%P0}" : : "w" (d)); 129 } 130 #endif 131 132 typedef void (*testcase_ftype) (void); 133 134 /* Functions testing instruction decodings. GDB will read n_testcases 135 to know how many functions to test. */ 136 137 static testcase_ftype testcases[] = 138 { 139 #if (defined __aarch64__) 140 load, 141 move, 142 adv_simd_mod_imm, 143 adv_simd_scalar_index, 144 adv_simd_smlal, 145 adv_simd_vect_shift, 146 #elif (defined __arm__) 147 ext_reg_load, 148 ext_reg_mov, 149 ext_reg_push_pop, 150 #endif 151 }; 152 153 static int n_testcases = (sizeof (testcases) / sizeof (testcase_ftype)); 154 155 int 156 main () 157 { 158 int i = 0; 159 160 for (i = 0; i < n_testcases; i++) 161 testcases[i] (); 162 163 return 0; 164 } 165