================
@@ -84,3 +96,73 @@ RegisterInfoPOSIXDynamic_riscv32::GetRegisterInfo(
     llvm::StringRef reg_name) const {
   return m_dyn_reg_infos.GetRegisterInfo(reg_name);
 }
+
+void RegisterInfoPOSIXDynamic_riscv32::BuildCSRegInfos(
+    llvm::ArrayRef<std::string> features,
+    llvm::SmallVectorImpl<lldb_private::RegisterInfo> &cs_reg_infos) {
+  cs_reg_infos.clear();
+
+  // Sort and deduplicate the feature list to make the resulting CSR metadata
+  // independent of caller ordering.
+  llvm::SmallVector<llvm::StringRef> normalized_features(features.begin(),
+                                                         features.end());
+  llvm::sort(normalized_features);
+  normalized_features.erase(llvm::unique(normalized_features),
+                            normalized_features.end());
+
+  const uint32_t k_num_csr_registers = csr_last_riscv - csr_first_riscv + 1;
+  cs_reg_infos.reserve(k_num_csr_registers);
+
+  // Construct default CS register information. CS register information entries
+  // are stored in CSR-address order. For each entry at slot 'reg',
+  //   kinds[eRegisterKindLLDB] = csr_first_riscv + reg.
+  // So, patch entries can recover the slot as:
+  //   idx = lldb_reg - csr_first_riscv.
----------------
ayushsahay1837 wrote:

> It might be worth documenting that that each entry's kinds[eRegisterKindLLDB] 
> doubles as its slot index: e.g. `idx = lldb_reg - csr_first_riscv`.

@JDevlieghere, I added this in response to your earlier suggestion to document 
that each entry's _kinds[eRegisterKindLLDB]_ doubles as its slot index. I 
placed it here because this is where each entry's _kinds[eRegisterKindLLDB]_ is 
set but I'm happy to move or reword it if you think that there's a more 
appropriate location. Do you have a recommendation?

https://github.com/llvm/llvm-project/pull/203234
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to