- int regno = FIRST_UISA_SP_REGNUM;
-
- gdb_assert (sizeof (*iar) == REGISTER_RAW_SIZE (regno));
-
- if (register_cached (regno))
- regcache_collect (regno, iar);
- if (register_cached (regno + 1))
- regcache_collect (regno + 1, msr);
- if (register_cached (regno + 2))
- regcache_collect (regno + 2, cr);
- if (register_cached (regno + 3))
- regcache_collect (regno + 3, lr);
- if (register_cached (regno + 4))
- regcache_collect (regno + 4, ctr);
- if (register_cached (regno + 5))
- regcache_collect (regno + 5, xer);
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+ /* Verify that the size of the size of the IAR buffer is the
+ same as the raw size of the PC (in the register cache). If
+ they're not, then either GDB has been built incorrectly, or
+ there's some other kind of internal error. To be really safe,
+ we should check all of the sizes. */
+ gdb_assert (sizeof (*iar) == register_size
+ (gdbarch, gdbarch_pc_regnum (gdbarch)));
+
+ if (regcache_valid_p (regcache, gdbarch_pc_regnum (gdbarch)))
+ regcache_raw_collect (regcache, gdbarch_pc_regnum (gdbarch), iar);
+ if (regcache_valid_p (regcache, tdep->ppc_ps_regnum))
+ regcache_raw_collect (regcache, tdep->ppc_ps_regnum, msr);
+ if (regcache_valid_p (regcache, tdep->ppc_cr_regnum))
+ regcache_raw_collect (regcache, tdep->ppc_cr_regnum, cr);
+ if (regcache_valid_p (regcache, tdep->ppc_lr_regnum))
+ regcache_raw_collect (regcache, tdep->ppc_lr_regnum, lr);
+ if (regcache_valid_p (regcache, tdep->ppc_ctr_regnum))
+ regcache_raw_collect (regcache, tdep->ppc_ctr_regnum, ctr);
+ if (regcache_valid_p (regcache, tdep->ppc_xer_regnum))
+ regcache_raw_collect (regcache, tdep->ppc_xer_regnum, xer);
+ if (tdep->ppc_fpscr_regnum >= 0
+ && regcache_valid_p (regcache, tdep->ppc_fpscr_regnum))
+ regcache_raw_collect (regcache, tdep->ppc_fpscr_regnum, fpscr);