+ xstate_bv |= X86_XSTATE_AVX;
+ memcpy (p, raw, 16);
+ }
+ }
+ }
+
+ /* Check if any bound register has changed. */
+ if ((x86_xcr0 & X86_XSTATE_BNDREGS))
+ {
+ int bnd0r_regnum = find_regno (regcache->tdesc, "bnd0raw");
+
+ for (i = 0; i < num_mpx_bnd_registers; i++)
+ {
+ collect_register (regcache, i + bnd0r_regnum, raw);
+ p = ((char *) &fp->mpx_bnd_space[0]) + i * 16;
+ if (memcmp (raw, p, 16))
+ {
+ xstate_bv |= X86_XSTATE_BNDREGS;
+ memcpy (p, raw, 16);
+ }
+ }
+ }
+
+ /* Check if any status register has changed. */
+ if ((x86_xcr0 & X86_XSTATE_BNDCFG))
+ {
+ int bndcfg_regnum = find_regno (regcache->tdesc, "bndcfgu");
+
+ for (i = 0; i < num_mpx_cfg_registers; i++)
+ {
+ collect_register (regcache, i + bndcfg_regnum, raw);
+ p = ((char *) &fp->mpx_cfg_space[0]) + i * 8;
+ if (memcmp (raw, p, 8))
+ {
+ xstate_bv |= X86_XSTATE_BNDCFG;
+ memcpy (p, raw, 8);
+ }
+ }
+ }
+
+ /* Check if any K registers are changed. */
+ if ((x86_xcr0 & X86_XSTATE_K))
+ {
+ int k0_regnum = find_regno (regcache->tdesc, "k0");
+
+ for (i = 0; i < num_avx512_k_registers; i++)
+ {
+ collect_register (regcache, i + k0_regnum, raw);
+ p = ((char *) &fp->k_space[0]) + i * 8;
+ if (memcmp (raw, p, 8) != 0)
+ {
+ xstate_bv |= X86_XSTATE_K;
+ memcpy (p, raw, 8);
+ }
+ }
+ }
+
+ /* Check if any of ZMM0H-ZMM15H registers are changed. */
+ if ((x86_xcr0 & X86_XSTATE_ZMM_H))
+ {
+ int zmm0h_regnum = find_regno (regcache->tdesc, "zmm0h");
+
+ for (i = 0; i < num_avx512_zmmh_low_registers; i++)
+ {
+ collect_register (regcache, i + zmm0h_regnum, raw);
+ p = ((char *) &fp->zmmh_low_space[0]) + i * 32;
+ if (memcmp (raw, p, 32) != 0)
+ {
+ xstate_bv |= X86_XSTATE_ZMM_H;
+ memcpy (p, raw, 32);
+ }
+ }
+ }
+
+ /* Check if any of ZMM16H-ZMM31H registers are changed. */
+ if ((x86_xcr0 & X86_XSTATE_ZMM))
+ {
+ int zmm16h_regnum = find_regno (regcache->tdesc, "zmm16h");
+
+ for (i = 0; i < num_avx512_zmmh_high_registers; i++)
+ {
+ collect_register (regcache, i + zmm16h_regnum, raw);
+ p = ((char *) &fp->zmmh_high_space[0]) + 32 + i * 64;
+ if (memcmp (raw, p, 32) != 0)
+ {
+ xstate_bv |= X86_XSTATE_ZMM;
+ memcpy (p, raw, 32);
+ }
+ }
+ }
+
+ /* Check if any XMM_AVX512 registers are changed. */
+ if ((x86_xcr0 & X86_XSTATE_ZMM))
+ {
+ int xmm_avx512_regnum = find_regno (regcache->tdesc, "xmm16");
+
+ for (i = 0; i < num_avx512_xmm_registers; i++)
+ {
+ collect_register (regcache, i + xmm_avx512_regnum, raw);
+ p = ((char *) &fp->zmmh_high_space[0]) + i * 64;
+ if (memcmp (raw, p, 16) != 0)
+ {
+ xstate_bv |= X86_XSTATE_ZMM;
+ memcpy (p, raw, 16);
+ }
+ }
+ }
+
+ /* Check if any YMMH_AVX512 registers are changed. */
+ if ((x86_xcr0 & X86_XSTATE_ZMM))
+ {
+ int ymmh_avx512_regnum = find_regno (regcache->tdesc, "ymm16h");
+
+ for (i = 0; i < num_avx512_ymmh_registers; i++)
+ {
+ collect_register (regcache, i + ymmh_avx512_regnum, raw);
+ p = ((char *) &fp->zmmh_high_space[0]) + 16 + i * 64;
+ if (memcmp (raw, p, 16) != 0)
+ {
+ xstate_bv |= X86_XSTATE_ZMM;