@@ -346,22 +346,11 @@ static bool vlenb_exists(const struct target *target)
346346 return riscv_vlenb (target ) != 0 ;
347347}
348348
349- static bool mtopi_exists (const struct target * target )
349+ static bool reg_exists (const struct target * target , uint32_t regno )
350350{
351- RISCV_INFO (info )
352- /* TODO: The naming is quite unfortunate here. `mtopi_readable` refers
353- * to how the fact that `mtopi` exists was deduced during examine.
354- */
355- return info -> mtopi_readable ;
356- }
357-
358- static bool mtopei_exists (const struct target * target )
359- {
360- RISCV_INFO (info )
361- /* TODO: The naming is quite unfortunate here. `mtopei_readable` refers
362- * to how the fact that `mtopei` exists was deduced during examine.
363- */
364- return info -> mtopei_readable ;
351+ const struct reg * const reg = riscv_reg_impl_cache_entry (target , regno );
352+ assert (riscv_reg_impl_is_initialized (reg ));
353+ return reg -> exist ;
365354}
366355
367356static bool is_known_standard_csr (unsigned int csr_num )
@@ -508,25 +497,25 @@ bool riscv_reg_impl_gdb_regno_exist(const struct target *target, uint32_t regno)
508497 case CSR_MVIP :
509498 case CSR_MIEH :
510499 case CSR_MIPH :
511- return mtopi_exists (target );
500+ return reg_exists (target , GDB_REGNO_MTOPI );
512501 case CSR_MIDELEGH :
513502 case CSR_MVIENH :
514503 case CSR_MVIPH :
515- return mtopi_exists (target ) &&
504+ return reg_exists (target , GDB_REGNO_MTOPI ) &&
516505 riscv_xlen (target ) == 32 &&
517506 riscv_supports_extension (target , 'S' );
518507 /* Interrupts S-Mode CSRs. */
519508 case CSR_SISELECT :
520509 case CSR_SIREG :
521510 case CSR_STOPI :
522- return mtopi_exists (target ) &&
511+ return reg_exists (target , GDB_REGNO_MTOPI ) &&
523512 riscv_supports_extension (target , 'S' );
524513 case CSR_STOPEI :
525- return mtopei_exists (target ) &&
514+ return reg_exists (target , GDB_REGNO_MTOPEI ) &&
526515 riscv_supports_extension (target , 'S' );
527516 case CSR_SIEH :
528517 case CSR_SIPH :
529- return mtopi_exists (target ) &&
518+ return reg_exists (target , GDB_REGNO_MTOPI ) &&
530519 riscv_xlen (target ) == 32 &&
531520 riscv_supports_extension (target , 'S' );
532521 /* Interrupts Hypervisor and VS CSRs. */
@@ -537,10 +526,10 @@ bool riscv_reg_impl_gdb_regno_exist(const struct target *target, uint32_t regno)
537526 case CSR_VSISELECT :
538527 case CSR_VSIREG :
539528 case CSR_VSTOPI :
540- return mtopi_exists (target ) &&
529+ return reg_exists (target , GDB_REGNO_MTOPI ) &&
541530 riscv_supports_extension (target , 'H' );
542531 case CSR_VSTOPEI :
543- return mtopei_exists (target ) &&
532+ return reg_exists (target , GDB_REGNO_MTOPEI ) &&
544533 riscv_supports_extension (target , 'H' );
545534 case CSR_HIDELEGH :
546535 case CSR_HVIENH :
@@ -549,7 +538,7 @@ bool riscv_reg_impl_gdb_regno_exist(const struct target *target, uint32_t regno)
549538 case CSR_HVIPRIO2H :
550539 case CSR_VSIEH :
551540 case CSR_VSIPH :
552- return mtopi_exists (target ) &&
541+ return reg_exists (target , GDB_REGNO_MTOPI ) &&
553542 riscv_xlen (target ) == 32 &&
554543 riscv_supports_extension (target , 'H' );
555544 }
0 commit comments