1 /* i387-specific utility functions, for the remote server for GDB.
2 Copyright (C) 2000-2017 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #include "x86-xstate.h"
23 static const int num_mpx_bnd_registers
= 4;
24 static const int num_mpx_cfg_registers
= 2;
25 static const int num_avx512_k_registers
= 8;
26 static const int num_avx512_zmmh_low_registers
= 16;
27 static const int num_avx512_zmmh_high_registers
= 16;
28 static const int num_avx512_ymmh_registers
= 16;
29 static const int num_avx512_xmm_registers
= 16;
31 /* Note: These functions preserve the reserved bits in control registers.
32 However, gdbserver promptly throws away that information. */
34 /* These structs should have the proper sizes and alignment on both
35 i386 and x86-64 machines. */
38 /* All these are only sixteen bits, plus padding, except for fop (which
39 is only eleven bits), and fooff / fioff (which are 32 bits each). */
53 /* Space for eight 80-bit FP values. */
54 unsigned char st_space
[80];
58 /* All these are only sixteen bits, plus padding, except for fop (which
59 is only eleven bits), and fooff / fioff (which are 32 bits each). */
74 /* Space for eight 80-bit FP values in 128-bit spaces. */
75 unsigned char st_space
[128];
77 /* Space for eight 128-bit XMM values, or 16 on x86-64. */
78 unsigned char xmm_space
[256];
82 /* All these are only sixteen bits, plus padding, except for fop (which
83 is only eleven bits), and fooff / fioff (which are 32 bits each). */
96 unsigned int mxcsr_mask
;
98 /* Space for eight 80-bit FP values in 128-bit spaces. */
99 unsigned char st_space
[128];
101 /* Space for eight 128-bit XMM values, or 16 on x86-64. */
102 unsigned char xmm_space
[256];
104 unsigned char reserved1
[48];
106 /* The extended control register 0 (the XFEATURE_ENABLED_MASK
108 unsigned long long xcr0
;
110 unsigned char reserved2
[40];
112 /* The XSTATE_BV bit vector. */
113 unsigned long long xstate_bv
;
115 unsigned char reserved3
[56];
117 /* Space for eight upper 128-bit YMM values, or 16 on x86-64. */
118 unsigned char ymmh_space
[256];
120 unsigned char reserved4
[128];
122 /* Space for 4 bound registers values of 128 bits. */
123 unsigned char mpx_bnd_space
[64];
125 /* Space for 2 MPX configuration registers of 64 bits
126 plus reserved space. */
127 unsigned char mpx_cfg_space
[16];
129 unsigned char reserved5
[48];
131 /* Space for 8 OpMask register values of 64 bits. */
132 unsigned char k_space
[64];
134 /* Space for 16 256-bit zmm0-15. */
135 unsigned char zmmh_low_space
[512];
137 /* Space for 16 512-bit zmm16-31 values. */
138 unsigned char zmmh_high_space
[1024];
142 i387_cache_to_fsave (struct regcache
*regcache
, void *buf
)
144 struct i387_fsave
*fp
= (struct i387_fsave
*) buf
;
146 int st0_regnum
= find_regno (regcache
->tdesc
, "st0");
147 unsigned long val
, val2
;
149 for (i
= 0; i
< 8; i
++)
150 collect_register (regcache
, i
+ st0_regnum
,
151 ((char *) &fp
->st_space
[0]) + i
* 10);
153 collect_register_by_name (regcache
, "fioff", &fp
->fioff
);
154 collect_register_by_name (regcache
, "fooff", &fp
->fooff
);
156 /* This one's 11 bits... */
157 collect_register_by_name (regcache
, "fop", &val2
);
158 fp
->fop
= (val2
& 0x7FF) | (fp
->fop
& 0xF800);
160 /* Some registers are 16-bit. */
161 collect_register_by_name (regcache
, "fctrl", &val
);
164 collect_register_by_name (regcache
, "fstat", &val
);
168 collect_register_by_name (regcache
, "ftag", &val
);
172 collect_register_by_name (regcache
, "fiseg", &val
);
176 collect_register_by_name (regcache
, "foseg", &val
);
182 i387_fsave_to_cache (struct regcache
*regcache
, const void *buf
)
184 struct i387_fsave
*fp
= (struct i387_fsave
*) buf
;
186 int st0_regnum
= find_regno (regcache
->tdesc
, "st0");
189 for (i
= 0; i
< 8; i
++)
190 supply_register (regcache
, i
+ st0_regnum
,
191 ((char *) &fp
->st_space
[0]) + i
* 10);
193 supply_register_by_name (regcache
, "fioff", &fp
->fioff
);
194 supply_register_by_name (regcache
, "fooff", &fp
->fooff
);
196 /* Some registers are 16-bit. */
197 val
= fp
->fctrl
& 0xFFFF;
198 supply_register_by_name (regcache
, "fctrl", &val
);
200 val
= fp
->fstat
& 0xFFFF;
201 supply_register_by_name (regcache
, "fstat", &val
);
203 val
= fp
->ftag
& 0xFFFF;
204 supply_register_by_name (regcache
, "ftag", &val
);
206 val
= fp
->fiseg
& 0xFFFF;
207 supply_register_by_name (regcache
, "fiseg", &val
);
209 val
= fp
->foseg
& 0xFFFF;
210 supply_register_by_name (regcache
, "foseg", &val
);
212 /* fop has only 11 valid bits. */
213 val
= (fp
->fop
) & 0x7FF;
214 supply_register_by_name (regcache
, "fop", &val
);
218 i387_cache_to_fxsave (struct regcache
*regcache
, void *buf
)
220 struct i387_fxsave
*fp
= (struct i387_fxsave
*) buf
;
222 int st0_regnum
= find_regno (regcache
->tdesc
, "st0");
223 int xmm0_regnum
= find_regno (regcache
->tdesc
, "xmm0");
224 unsigned long val
, val2
;
225 /* Amd64 has 16 xmm regs; I386 has 8 xmm regs. */
226 int num_xmm_registers
= register_size (regcache
->tdesc
, 0) == 8 ? 16 : 8;
228 for (i
= 0; i
< 8; i
++)
229 collect_register (regcache
, i
+ st0_regnum
,
230 ((char *) &fp
->st_space
[0]) + i
* 16);
231 for (i
= 0; i
< num_xmm_registers
; i
++)
232 collect_register (regcache
, i
+ xmm0_regnum
,
233 ((char *) &fp
->xmm_space
[0]) + i
* 16);
235 collect_register_by_name (regcache
, "fioff", &fp
->fioff
);
236 collect_register_by_name (regcache
, "fooff", &fp
->fooff
);
237 collect_register_by_name (regcache
, "mxcsr", &fp
->mxcsr
);
239 /* This one's 11 bits... */
240 collect_register_by_name (regcache
, "fop", &val2
);
241 fp
->fop
= (val2
& 0x7FF) | (fp
->fop
& 0xF800);
243 /* Some registers are 16-bit. */
244 collect_register_by_name (regcache
, "fctrl", &val
);
247 collect_register_by_name (regcache
, "fstat", &val
);
250 /* Convert to the simplifed tag form stored in fxsave data. */
251 collect_register_by_name (regcache
, "ftag", &val
);
254 for (i
= 7; i
>= 0; i
--)
256 int tag
= (val
>> (i
* 2)) & 3;
263 collect_register_by_name (regcache
, "fiseg", &val
);
266 collect_register_by_name (regcache
, "foseg", &val
);
271 i387_cache_to_xsave (struct regcache
*regcache
, void *buf
)
273 struct i387_xsave
*fp
= (struct i387_xsave
*) buf
;
275 unsigned long val
, val2
;
276 unsigned long long xstate_bv
= 0;
277 unsigned long long clear_bv
= 0;
280 /* Amd64 has 16 xmm regs; I386 has 8 xmm regs. */
281 int num_xmm_registers
= register_size (regcache
->tdesc
, 0) == 8 ? 16 : 8;
283 /* The supported bits in `xstat_bv' are 8 bytes. Clear part in
284 vector registers if its bit in xstat_bv is zero. */
285 clear_bv
= (~fp
->xstate_bv
) & x86_xcr0
;
287 /* Clear part in x87 and vector registers if its bit in xstat_bv is
291 if ((clear_bv
& X86_XSTATE_X87
))
292 for (i
= 0; i
< 8; i
++)
293 memset (((char *) &fp
->st_space
[0]) + i
* 16, 0, 10);
295 if ((clear_bv
& X86_XSTATE_SSE
))
296 for (i
= 0; i
< num_xmm_registers
; i
++)
297 memset (((char *) &fp
->xmm_space
[0]) + i
* 16, 0, 16);
299 if ((clear_bv
& X86_XSTATE_AVX
))
300 for (i
= 0; i
< num_xmm_registers
; i
++)
301 memset (((char *) &fp
->ymmh_space
[0]) + i
* 16, 0, 16);
303 if ((clear_bv
& X86_XSTATE_BNDREGS
))
304 for (i
= 0; i
< num_mpx_bnd_registers
; i
++)
305 memset (((char *) &fp
->mpx_bnd_space
[0]) + i
* 16, 0, 16);
307 if ((clear_bv
& X86_XSTATE_BNDCFG
))
308 for (i
= 0; i
< num_mpx_cfg_registers
; i
++)
309 memset (((char *) &fp
->mpx_cfg_space
[0]) + i
* 8, 0, 8);
311 if ((clear_bv
& X86_XSTATE_K
))
312 for (i
= 0; i
< num_avx512_k_registers
; i
++)
313 memset (((char *) &fp
->k_space
[0]) + i
* 8, 0, 8);
315 if ((clear_bv
& X86_XSTATE_ZMM_H
))
316 for (i
= 0; i
< num_avx512_zmmh_low_registers
; i
++)
317 memset (((char *) &fp
->zmmh_low_space
[0]) + i
* 32, 0, 32);
319 if ((clear_bv
& X86_XSTATE_ZMM
))
321 for (i
= 0; i
< num_avx512_zmmh_high_registers
; i
++)
322 memset (((char *) &fp
->zmmh_low_space
[0]) + 32 + i
* 64, 0, 32);
323 for (i
= 0; i
< num_avx512_xmm_registers
; i
++)
324 memset (((char *) &fp
->zmmh_high_space
[0]) + i
* 64, 0, 16);
325 for (i
= 0; i
< num_avx512_ymmh_registers
; i
++)
326 memset (((char *) &fp
->zmmh_high_space
[0]) + 16 + i
* 64, 0, 16);
330 /* Check if any x87 registers are changed. */
331 if ((x86_xcr0
& X86_XSTATE_X87
))
333 int st0_regnum
= find_regno (regcache
->tdesc
, "st0");
335 for (i
= 0; i
< 8; i
++)
337 collect_register (regcache
, i
+ st0_regnum
, raw
);
338 p
= ((char *) &fp
->st_space
[0]) + i
* 16;
339 if (memcmp (raw
, p
, 10))
341 xstate_bv
|= X86_XSTATE_X87
;
347 /* Check if any SSE registers are changed. */
348 if ((x86_xcr0
& X86_XSTATE_SSE
))
350 int xmm0_regnum
= find_regno (regcache
->tdesc
, "xmm0");
352 for (i
= 0; i
< num_xmm_registers
; i
++)
354 collect_register (regcache
, i
+ xmm0_regnum
, raw
);
355 p
= ((char *) &fp
->xmm_space
[0]) + i
* 16;
356 if (memcmp (raw
, p
, 16))
358 xstate_bv
|= X86_XSTATE_SSE
;
364 /* Check if any AVX registers are changed. */
365 if ((x86_xcr0
& X86_XSTATE_AVX
))
367 int ymm0h_regnum
= find_regno (regcache
->tdesc
, "ymm0h");
369 for (i
= 0; i
< num_xmm_registers
; i
++)
371 collect_register (regcache
, i
+ ymm0h_regnum
, raw
);
372 p
= ((char *) &fp
->ymmh_space
[0]) + i
* 16;
373 if (memcmp (raw
, p
, 16))
375 xstate_bv
|= X86_XSTATE_AVX
;
381 /* Check if any bound register has changed. */
382 if ((x86_xcr0
& X86_XSTATE_BNDREGS
))
384 int bnd0r_regnum
= find_regno (regcache
->tdesc
, "bnd0raw");
386 for (i
= 0; i
< num_mpx_bnd_registers
; i
++)
388 collect_register (regcache
, i
+ bnd0r_regnum
, raw
);
389 p
= ((char *) &fp
->mpx_bnd_space
[0]) + i
* 16;
390 if (memcmp (raw
, p
, 16))
392 xstate_bv
|= X86_XSTATE_BNDREGS
;
398 /* Check if any status register has changed. */
399 if ((x86_xcr0
& X86_XSTATE_BNDCFG
))
401 int bndcfg_regnum
= find_regno (regcache
->tdesc
, "bndcfgu");
403 for (i
= 0; i
< num_mpx_cfg_registers
; i
++)
405 collect_register (regcache
, i
+ bndcfg_regnum
, raw
);
406 p
= ((char *) &fp
->mpx_cfg_space
[0]) + i
* 8;
407 if (memcmp (raw
, p
, 8))
409 xstate_bv
|= X86_XSTATE_BNDCFG
;
415 /* Check if any K registers are changed. */
416 if ((x86_xcr0
& X86_XSTATE_K
))
418 int k0_regnum
= find_regno (regcache
->tdesc
, "k0");
420 for (i
= 0; i
< num_avx512_k_registers
; i
++)
422 collect_register (regcache
, i
+ k0_regnum
, raw
);
423 p
= ((char *) &fp
->k_space
[0]) + i
* 8;
424 if (memcmp (raw
, p
, 8) != 0)
426 xstate_bv
|= X86_XSTATE_K
;
432 /* Check if any of ZMM0H-ZMM15H registers are changed. */
433 if ((x86_xcr0
& X86_XSTATE_ZMM_H
))
435 int zmm0h_regnum
= find_regno (regcache
->tdesc
, "zmm0h");
437 for (i
= 0; i
< num_avx512_zmmh_low_registers
; i
++)
439 collect_register (regcache
, i
+ zmm0h_regnum
, raw
);
440 p
= ((char *) &fp
->zmmh_low_space
[0]) + i
* 32;
441 if (memcmp (raw
, p
, 32) != 0)
443 xstate_bv
|= X86_XSTATE_ZMM_H
;
449 /* Check if any of ZMM16H-ZMM31H registers are changed. */
450 if ((x86_xcr0
& X86_XSTATE_ZMM
))
452 int zmm16h_regnum
= find_regno (regcache
->tdesc
, "zmm16h");
454 for (i
= 0; i
< num_avx512_zmmh_high_registers
; i
++)
456 collect_register (regcache
, i
+ zmm16h_regnum
, raw
);
457 p
= ((char *) &fp
->zmmh_high_space
[0]) + 32 + i
* 64;
458 if (memcmp (raw
, p
, 32) != 0)
460 xstate_bv
|= X86_XSTATE_ZMM
;
466 /* Check if any XMM_AVX512 registers are changed. */
467 if ((x86_xcr0
& X86_XSTATE_ZMM
))
469 int xmm_avx512_regnum
= find_regno (regcache
->tdesc
, "xmm16");
471 for (i
= 0; i
< num_avx512_xmm_registers
; i
++)
473 collect_register (regcache
, i
+ xmm_avx512_regnum
, raw
);
474 p
= ((char *) &fp
->zmmh_high_space
[0]) + i
* 64;
475 if (memcmp (raw
, p
, 16) != 0)
477 xstate_bv
|= X86_XSTATE_ZMM
;
483 /* Check if any YMMH_AVX512 registers are changed. */
484 if ((x86_xcr0
& X86_XSTATE_ZMM
))
486 int ymmh_avx512_regnum
= find_regno (regcache
->tdesc
, "ymm16h");
488 for (i
= 0; i
< num_avx512_ymmh_registers
; i
++)
490 collect_register (regcache
, i
+ ymmh_avx512_regnum
, raw
);
491 p
= ((char *) &fp
->zmmh_high_space
[0]) + 16 + i
* 64;
492 if (memcmp (raw
, p
, 16) != 0)
494 xstate_bv
|= X86_XSTATE_ZMM
;
500 /* Update the corresponding bits in xstate_bv if any SSE/AVX
501 registers are changed. */
502 fp
->xstate_bv
|= xstate_bv
;
504 collect_register_by_name (regcache
, "fioff", &fp
->fioff
);
505 collect_register_by_name (regcache
, "fooff", &fp
->fooff
);
506 collect_register_by_name (regcache
, "mxcsr", &fp
->mxcsr
);
508 /* This one's 11 bits... */
509 collect_register_by_name (regcache
, "fop", &val2
);
510 fp
->fop
= (val2
& 0x7FF) | (fp
->fop
& 0xF800);
512 /* Some registers are 16-bit. */
513 collect_register_by_name (regcache
, "fctrl", &val
);
516 collect_register_by_name (regcache
, "fstat", &val
);
519 /* Convert to the simplifed tag form stored in fxsave data. */
520 collect_register_by_name (regcache
, "ftag", &val
);
523 for (i
= 7; i
>= 0; i
--)
525 int tag
= (val
>> (i
* 2)) & 3;
532 collect_register_by_name (regcache
, "fiseg", &val
);
535 collect_register_by_name (regcache
, "foseg", &val
);
540 i387_ftag (struct i387_fxsave
*fp
, int regno
)
542 unsigned char *raw
= &fp
->st_space
[regno
* 16];
543 unsigned int exponent
;
544 unsigned long fraction
[2];
547 integer
= raw
[7] & 0x80;
548 exponent
= (((raw
[9] & 0x7f) << 8) | raw
[8]);
549 fraction
[0] = ((raw
[3] << 24) | (raw
[2] << 16) | (raw
[1] << 8) | raw
[0]);
550 fraction
[1] = (((raw
[7] & 0x7f) << 24) | (raw
[6] << 16)
551 | (raw
[5] << 8) | raw
[4]);
553 if (exponent
== 0x7fff)
558 else if (exponent
== 0x0000)
560 if (fraction
[0] == 0x0000 && fraction
[1] == 0x0000 && !integer
)
587 i387_fxsave_to_cache (struct regcache
*regcache
, const void *buf
)
589 struct i387_fxsave
*fp
= (struct i387_fxsave
*) buf
;
591 int st0_regnum
= find_regno (regcache
->tdesc
, "st0");
592 int xmm0_regnum
= find_regno (regcache
->tdesc
, "xmm0");
594 /* Amd64 has 16 xmm regs; I386 has 8 xmm regs. */
595 int num_xmm_registers
= register_size (regcache
->tdesc
, 0) == 8 ? 16 : 8;
597 for (i
= 0; i
< 8; i
++)
598 supply_register (regcache
, i
+ st0_regnum
,
599 ((char *) &fp
->st_space
[0]) + i
* 16);
600 for (i
= 0; i
< num_xmm_registers
; i
++)
601 supply_register (regcache
, i
+ xmm0_regnum
,
602 ((char *) &fp
->xmm_space
[0]) + i
* 16);
604 supply_register_by_name (regcache
, "fioff", &fp
->fioff
);
605 supply_register_by_name (regcache
, "fooff", &fp
->fooff
);
606 supply_register_by_name (regcache
, "mxcsr", &fp
->mxcsr
);
608 /* Some registers are 16-bit. */
609 val
= fp
->fctrl
& 0xFFFF;
610 supply_register_by_name (regcache
, "fctrl", &val
);
612 val
= fp
->fstat
& 0xFFFF;
613 supply_register_by_name (regcache
, "fstat", &val
);
615 /* Generate the form of ftag data that GDB expects. */
616 top
= (fp
->fstat
>> 11) & 0x7;
618 for (i
= 7; i
>= 0; i
--)
621 if (fp
->ftag
& (1 << i
))
622 tag
= i387_ftag (fp
, (i
+ 8 - top
) % 8);
625 val
|= tag
<< (2 * i
);
627 supply_register_by_name (regcache
, "ftag", &val
);
629 val
= fp
->fiseg
& 0xFFFF;
630 supply_register_by_name (regcache
, "fiseg", &val
);
632 val
= fp
->foseg
& 0xFFFF;
633 supply_register_by_name (regcache
, "foseg", &val
);
635 val
= (fp
->fop
) & 0x7FF;
636 supply_register_by_name (regcache
, "fop", &val
);
640 i387_xsave_to_cache (struct regcache
*regcache
, const void *buf
)
642 struct i387_xsave
*fp
= (struct i387_xsave
*) buf
;
643 struct i387_fxsave
*fxp
= (struct i387_fxsave
*) buf
;
646 unsigned long long clear_bv
;
648 /* Amd64 has 16 xmm regs; I386 has 8 xmm regs. */
649 int num_xmm_registers
= register_size (regcache
->tdesc
, 0) == 8 ? 16 : 8;
651 /* The supported bits in `xstat_bv' are 8 bytes. Clear part in
652 vector registers if its bit in xstat_bv is zero. */
653 clear_bv
= (~fp
->xstate_bv
) & x86_xcr0
;
655 /* Check if any x87 registers are changed. */
656 if ((x86_xcr0
& X86_XSTATE_X87
) != 0)
658 int st0_regnum
= find_regno (regcache
->tdesc
, "st0");
660 if ((clear_bv
& X86_XSTATE_X87
) != 0)
662 for (i
= 0; i
< 8; i
++)
663 supply_register_zeroed (regcache
, i
+ st0_regnum
);
667 p
= (gdb_byte
*) &fp
->st_space
[0];
668 for (i
= 0; i
< 8; i
++)
669 supply_register (regcache
, i
+ st0_regnum
, p
+ i
* 16);
673 if ((x86_xcr0
& X86_XSTATE_SSE
) != 0)
675 int xmm0_regnum
= find_regno (regcache
->tdesc
, "xmm0");
677 if ((clear_bv
& X86_XSTATE_SSE
))
679 for (i
= 0; i
< num_xmm_registers
; i
++)
680 supply_register_zeroed (regcache
, i
+ xmm0_regnum
);
684 p
= (gdb_byte
*) &fp
->xmm_space
[0];
685 for (i
= 0; i
< num_xmm_registers
; i
++)
686 supply_register (regcache
, i
+ xmm0_regnum
, p
+ i
* 16);
690 if ((x86_xcr0
& X86_XSTATE_AVX
) != 0)
692 int ymm0h_regnum
= find_regno (regcache
->tdesc
, "ymm0h");
694 if ((clear_bv
& X86_XSTATE_AVX
) != 0)
696 for (i
= 0; i
< num_xmm_registers
; i
++)
697 supply_register_zeroed (regcache
, i
+ ymm0h_regnum
);
701 p
= (gdb_byte
*) &fp
->ymmh_space
[0];
702 for (i
= 0; i
< num_xmm_registers
; i
++)
703 supply_register (regcache
, i
+ ymm0h_regnum
, p
+ i
* 16);
707 if ((x86_xcr0
& X86_XSTATE_BNDREGS
))
709 int bnd0r_regnum
= find_regno (regcache
->tdesc
, "bnd0raw");
712 if ((clear_bv
& X86_XSTATE_BNDREGS
) != 0)
714 for (i
= 0; i
< num_mpx_bnd_registers
; i
++)
715 supply_register_zeroed (regcache
, i
+ bnd0r_regnum
);
719 p
= (gdb_byte
*) &fp
->mpx_bnd_space
[0];
720 for (i
= 0; i
< num_mpx_bnd_registers
; i
++)
721 supply_register (regcache
, i
+ bnd0r_regnum
, p
+ i
* 16);
726 if ((x86_xcr0
& X86_XSTATE_BNDCFG
))
728 int bndcfg_regnum
= find_regno (regcache
->tdesc
, "bndcfgu");
730 if ((clear_bv
& X86_XSTATE_BNDCFG
) != 0)
732 for (i
= 0; i
< num_mpx_cfg_registers
; i
++)
733 supply_register_zeroed (regcache
, i
+ bndcfg_regnum
);
737 p
= (gdb_byte
*) &fp
->mpx_cfg_space
[0];
738 for (i
= 0; i
< num_mpx_cfg_registers
; i
++)
739 supply_register (regcache
, i
+ bndcfg_regnum
, p
+ i
* 8);
743 if ((x86_xcr0
& X86_XSTATE_K
) != 0)
745 int k0_regnum
= find_regno (regcache
->tdesc
, "k0");
747 if ((clear_bv
& X86_XSTATE_K
) != 0)
749 for (i
= 0; i
< num_avx512_k_registers
; i
++)
750 supply_register_zeroed (regcache
, i
+ k0_regnum
);
754 p
= (gdb_byte
*) &fp
->k_space
[0];
755 for (i
= 0; i
< num_avx512_k_registers
; i
++)
756 supply_register (regcache
, i
+ k0_regnum
, p
+ i
* 8);
760 if ((x86_xcr0
& X86_XSTATE_ZMM_H
) != 0)
762 int zmm0h_regnum
= find_regno (regcache
->tdesc
, "zmm0h");
764 if ((clear_bv
& X86_XSTATE_ZMM_H
) != 0)
766 for (i
= 0; i
< num_avx512_zmmh_low_registers
; i
++)
767 supply_register_zeroed (regcache
, i
+ zmm0h_regnum
);
771 p
= (gdb_byte
*) &fp
->zmmh_low_space
[0];
772 for (i
= 0; i
< num_avx512_zmmh_low_registers
; i
++)
773 supply_register (regcache
, i
+ zmm0h_regnum
, p
+ i
* 32);
777 if ((x86_xcr0
& X86_XSTATE_ZMM
) != 0)
779 int zmm16h_regnum
= find_regno (regcache
->tdesc
, "zmm16h");
780 int ymm16h_regnum
= find_regno (regcache
->tdesc
, "ymm16h");
781 int xmm16_regnum
= find_regno (regcache
->tdesc
, "xmm16");
783 if ((clear_bv
& X86_XSTATE_ZMM
) != 0)
785 for (i
= 0; i
< num_avx512_zmmh_high_registers
; i
++)
786 supply_register_zeroed (regcache
, i
+ zmm16h_regnum
);
787 for (i
= 0; i
< num_avx512_ymmh_registers
; i
++)
788 supply_register_zeroed (regcache
, i
+ ymm16h_regnum
);
789 for (i
= 0; i
< num_avx512_xmm_registers
; i
++)
790 supply_register_zeroed (regcache
, i
+ xmm16_regnum
);
794 p
= (gdb_byte
*) &fp
->zmmh_high_space
[0];
795 for (i
= 0; i
< num_avx512_zmmh_high_registers
; i
++)
796 supply_register (regcache
, i
+ zmm16h_regnum
, p
+ 32 + i
* 64);
797 for (i
= 0; i
< num_avx512_ymmh_registers
; i
++)
798 supply_register (regcache
, i
+ ymm16h_regnum
, p
+ 16 + i
* 64);
799 for (i
= 0; i
< num_avx512_xmm_registers
; i
++)
800 supply_register (regcache
, i
+ xmm16_regnum
, p
+ i
* 64);
804 supply_register_by_name (regcache
, "fioff", &fp
->fioff
);
805 supply_register_by_name (regcache
, "fooff", &fp
->fooff
);
806 supply_register_by_name (regcache
, "mxcsr", &fp
->mxcsr
);
808 /* Some registers are 16-bit. */
809 val
= fp
->fctrl
& 0xFFFF;
810 supply_register_by_name (regcache
, "fctrl", &val
);
812 val
= fp
->fstat
& 0xFFFF;
813 supply_register_by_name (regcache
, "fstat", &val
);
815 /* Generate the form of ftag data that GDB expects. */
816 top
= (fp
->fstat
>> 11) & 0x7;
818 for (i
= 7; i
>= 0; i
--)
821 if (fp
->ftag
& (1 << i
))
822 tag
= i387_ftag (fxp
, (i
+ 8 - top
) % 8);
825 val
|= tag
<< (2 * i
);
827 supply_register_by_name (regcache
, "ftag", &val
);
829 val
= fp
->fiseg
& 0xFFFF;
830 supply_register_by_name (regcache
, "fiseg", &val
);
832 val
= fp
->foseg
& 0xFFFF;
833 supply_register_by_name (regcache
, "foseg", &val
);
835 val
= (fp
->fop
) & 0x7FF;
836 supply_register_by_name (regcache
, "fop", &val
);
839 /* Default to SSE. */
840 unsigned long long x86_xcr0
= X86_XSTATE_SSE_MASK
;