1 /* Test program for AVX registers. 2 3 Copyright 2010-2023 Free Software Foundation, Inc. 4 5 This file is part of GDB. 6 7 This program is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 3 of the License, or 10 (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 19 20 #include <stdio.h> 21 #include "nat/x86-cpuid.h" 22 23 /* Align sufficient to be able to use vmovaps. */ 24 #define ALIGN 32 25 26 typedef struct { 27 _Alignas (ALIGN) float f[8]; 28 } v8sf_t; 29 30 31 v8sf_t data_orig[] = 32 { 33 { { 0.0, 0.125, 0.25, 0.375, 0.50, 0.625, 0.75, 0.875 } }, 34 { { 1.0, 1.125, 1.25, 1.375, 1.50, 1.625, 1.75, 1.875 } }, 35 { { 2.0, 2.125, 2.25, 2.375, 2.50, 2.625, 2.75, 2.875 } }, 36 { { 3.0, 3.125, 3.25, 3.375, 3.50, 3.625, 3.75, 3.875 } }, 37 { { 4.0, 4.125, 4.25, 4.375, 4.50, 4.625, 4.75, 4.875 } }, 38 { { 5.0, 5.125, 5.25, 5.375, 5.50, 5.625, 5.75, 5.875 } }, 39 { { 6.0, 6.125, 6.25, 6.375, 6.50, 6.625, 6.75, 6.875 } }, 40 { { 7.0, 7.125, 7.25, 7.375, 7.50, 7.625, 7.75, 7.875 } }, 41 #ifdef __x86_64__ 42 { { 8.0, 8.125, 8.25, 8.375, 8.50, 8.625, 8.75, 8.875 } }, 43 { { 9.0, 9.125, 9.25, 9.375, 9.50, 9.625, 9.75, 9.875 } }, 44 { { 10.0, 10.125, 10.25, 10.375, 10.50, 10.625, 10.75, 10.875 } }, 45 { { 11.0, 11.125, 11.25, 11.375, 11.50, 11.625, 11.75, 11.875 } }, 46 { { 12.0, 12.125, 12.25, 12.375, 12.50, 12.625, 12.75, 12.875 } }, 47 { { 13.0, 13.125, 13.25, 13.375, 13.50, 13.625, 13.75, 13.875 } }, 48 { { 14.0, 14.125, 14.25, 14.375, 14.50, 14.625, 14.75, 14.875 } }, 49 { { 15.0, 15.125, 15.25, 15.375, 15.50, 15.625, 15.75, 15.875 } }, 50 #endif 51 }; 52 53 #include "../lib/precise-aligned-alloc.c" 54 55 int 56 main (int argc, char **argv) 57 { 58 void *allocated_ptr; 59 v8sf_t *data 60 = precise_aligned_dup (ALIGN, sizeof (data_orig), &allocated_ptr, 61 data_orig); 62 63 asm ("vmovaps 0(%0), %%ymm0\n\t" 64 "vmovaps 32(%0), %%ymm1\n\t" 65 "vmovaps 64(%0), %%ymm2\n\t" 66 "vmovaps 96(%0), %%ymm3\n\t" 67 "vmovaps 128(%0), %%ymm4\n\t" 68 "vmovaps 160(%0), %%ymm5\n\t" 69 "vmovaps 192(%0), %%ymm6\n\t" 70 "vmovaps 224(%0), %%ymm7\n\t" 71 : /* no output operands */ 72 : "r" (data) 73 : "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7"); 74 #ifdef __x86_64__ 75 asm ("vmovaps 256(%0), %%ymm8\n\t" 76 "vmovaps 288(%0), %%ymm9\n\t" 77 "vmovaps 320(%0), %%ymm10\n\t" 78 "vmovaps 352(%0), %%ymm11\n\t" 79 "vmovaps 384(%0), %%ymm12\n\t" 80 "vmovaps 416(%0), %%ymm13\n\t" 81 "vmovaps 448(%0), %%ymm14\n\t" 82 "vmovaps 480(%0), %%ymm15\n\t" 83 : /* no output operands */ 84 : "r" (data) 85 : "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15"); 86 #endif 87 88 asm ("nop"); /* first breakpoint here */ 89 90 asm ( 91 "vmovaps %%ymm0, 0(%0)\n\t" 92 "vmovaps %%ymm1, 32(%0)\n\t" 93 "vmovaps %%ymm2, 64(%0)\n\t" 94 "vmovaps %%ymm3, 96(%0)\n\t" 95 "vmovaps %%ymm4, 128(%0)\n\t" 96 "vmovaps %%ymm5, 160(%0)\n\t" 97 "vmovaps %%ymm6, 192(%0)\n\t" 98 "vmovaps %%ymm7, 224(%0)\n\t" 99 : /* no output operands */ 100 : "r" (data) 101 : "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7"); 102 #ifdef __x86_64__ 103 asm ( 104 "vmovaps %%ymm8, 256(%0)\n\t" 105 "vmovaps %%ymm9, 288(%0)\n\t" 106 "vmovaps %%ymm10, 320(%0)\n\t" 107 "vmovaps %%ymm11, 352(%0)\n\t" 108 "vmovaps %%ymm12, 384(%0)\n\t" 109 "vmovaps %%ymm13, 416(%0)\n\t" 110 "vmovaps %%ymm14, 448(%0)\n\t" 111 "vmovaps %%ymm15, 480(%0)\n\t" 112 : /* no output operands */ 113 : "r" (data) 114 : "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15"); 115 #endif 116 117 puts ("Bye!"); /* second breakpoint here */ 118 119 free (allocated_ptr); 120 121 return 0; 122 } 123