@@ -136,6 +136,10 @@ const RegisterInfo *ABISysV_riscv::GetRegisterInfoArray(uint32_t &count) {
136136// Static Functions
137137// ------------------------------------------------------------------
138138
139+ static inline size_t DeriveRegSizeInBytes (bool is_rv64) {
140+ return is_rv64 ? 8 : 4 ;
141+ }
142+
139143ABISP
140144ABISysV_riscv::CreateInstance (ProcessSP process_sp, const ArchSpec &arch) {
141145 llvm::Triple::ArchType machine = arch.GetTriple ().getArch ();
@@ -151,14 +155,14 @@ ABISysV_riscv::CreateInstance(ProcessSP process_sp, const ArchSpec &arch) {
151155}
152156
153157static inline size_t AugmentArgSize (bool is_rv64, size_t size_in_bytes) {
154- size_t word_size = is_rv64 ? 8 : 4 ;
158+ size_t word_size = DeriveRegSizeInBytes ( is_rv64) ;
155159 return llvm::alignTo (size_in_bytes, word_size);
156160}
157161
158162static size_t
159163TotalArgsSizeInWords (bool is_rv64,
160164 const llvm::ArrayRef<ABI::CallArgument> &args) {
161- size_t reg_size = is_rv64 ? 8 : 4 ;
165+ size_t reg_size = DeriveRegSizeInBytes ( is_rv64) ;
162166 size_t word_size = reg_size;
163167 size_t total_size = 0 ;
164168 for (const auto &arg : args)
@@ -275,7 +279,7 @@ bool ABISysV_riscv::PrepareTrivialCall(
275279 if (!process)
276280 return false ;
277281
278- size_t reg_size = m_is_rv64 ? 8 : 4 ;
282+ size_t reg_size = DeriveRegSizeInBytes ( m_is_rv64) ;
279283 size_t word_size = reg_size;
280284 // Push host data onto target.
281285 for (const auto &arg : args) {
@@ -397,7 +401,7 @@ Status ABISysV_riscv::SetReturnValueObject(StackFrameSP &frame_sp,
397401 return result;
398402 }
399403
400- size_t reg_size = m_is_rv64 ? 8 : 4 ;
404+ size_t reg_size = DeriveRegSizeInBytes ( m_is_rv64) ;
401405 if (num_bytes <= 2 * reg_size) {
402406 offset_t offset = 0 ;
403407 uint64_t raw_value = data.GetMaxU64 (&offset, num_bytes);
@@ -754,7 +758,7 @@ ABISysV_riscv::GetReturnValueObjectSimple(Thread &thread,
754758 }
755759 // Aggregate return type
756760 if (compiler_type.IsAggregateType ()) {
757- size_t xlen_byte_size = m_is_rv64 ? 8 : 4 ;
761+ size_t xlen_byte_size = DeriveRegSizeInBytes ( m_is_rv64) ;
758762
759763 return GetAggregateObj (thread, reg_ctx, compiler_type, xlen_byte_size,
760764 byte_size);
@@ -803,9 +807,7 @@ UnwindPlanSP ABISysV_riscv::CreateDefaultUnwindPlan() {
803807 // Define the CFA as the current frame pointer value.
804808 row.GetCFAValue ().SetIsRegisterPlusOffset (fp_reg_num, 0 );
805809
806- int reg_size = 4 ;
807- if (m_is_rv64)
808- reg_size = 8 ;
810+ int reg_size = DeriveRegSizeInBytes (m_is_rv64);
809811
810812 // Assume the ra reg (return pc) and caller's frame pointer
811813 // have been spilled to stack already.
0 commit comments