From ba34a138286bfaef38f40c6c484e98e80ceb7af5 Mon Sep 17 00:00:00 2001 From: t-mustafin <66252296+t-mustafin@users.noreply.github.com> Date: Fri, 21 Jul 2023 14:04:50 +0300 Subject: [PATCH] [RISC-V] Fix GetArgLoc (#88657) --- src/coreclr/vm/callingconvention.h | 60 ++---------------------------- 1 file changed, 4 insertions(+), 56 deletions(-) diff --git a/src/coreclr/vm/callingconvention.h b/src/coreclr/vm/callingconvention.h index 3f38cc57f566c..716cb8f582f4e 100644 --- a/src/coreclr/vm/callingconvention.h +++ b/src/coreclr/vm/callingconvention.h @@ -849,8 +849,9 @@ class ArgIteratorTemplate : public ARGITERATOR_BASE } #endif // TARGET_AMD64 -#ifdef TARGET_LOONGARCH64 +#if defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64) // Get layout information for the argument that the ArgIterator is currently visiting. + // TODO-RISCV64: support SIMD. void GetArgLoc(int argOffset, ArgLocDesc *pLoc) { LIMITED_METHOD_CONTRACT; @@ -869,7 +870,7 @@ class ArgIteratorTemplate : public ARGITERATOR_BASE const int floatRegOfsInBytes = argOffset - TransitionBlock::GetOffsetOfFloatArgumentRegisters(); _ASSERTE((floatRegOfsInBytes % FLOAT_REGISTER_SIZE) == 0); - pLoc->m_idxFloatReg = floatRegOfsInBytes / 8; + pLoc->m_idxFloatReg = floatRegOfsInBytes / FLOAT_REGISTER_SIZE; pLoc->m_cFloatReg = 1; @@ -899,60 +900,7 @@ class ArgIteratorTemplate : public ARGITERATOR_BASE return; } -#endif // TARGET_LOONGARCH64 - -#ifdef TARGET_RISCV64 - // Get layout information for the argument that the ArgIterator is currently visiting. - void GetArgLoc(int argOffset, ArgLocDesc *pLoc) - { - LIMITED_METHOD_CONTRACT; - - pLoc->Init(); - - if (m_hasArgLocDescForStructInRegs) - { - *pLoc = m_argLocDescForStructInRegs; - return; - } - - if (TransitionBlock::IsFloatArgumentRegisterOffset(argOffset)) - { - // TODO-RISCV64: support SIMD. - // Dividing by 8 as size of each register in FloatArgumentRegisters is 8 bytes. - const int floatRegOfsInBytes = (argOffset - TransitionBlock::GetOffsetOfFloatArgumentRegisters()); - _ASSERTE((floatRegOfsInBytes % FLOAT_REGISTER_SIZE) == 0); - pLoc->m_idxFloatReg = floatRegOfsInBytes / FLOAT_REGISTER_SIZE; - - assert(!m_argTypeHandle.IsHFA()); - - pLoc->m_cFloatReg = 1; - - return; - } - - int cSlots = (GetArgSize() + 7)/ 8; - - // Composites greater than 16bytes are passed by reference - if (GetArgType() == ELEMENT_TYPE_VALUETYPE && GetArgSize() > ENREGISTERED_PARAMTYPE_MAXSIZE) - { - cSlots = 1; - } - - if (!TransitionBlock::IsStackArgumentOffset(argOffset)) - { - // At least one used integer register passed. - pLoc->m_idxGenReg = TransitionBlock::GetArgumentIndexFromOffset(argOffset); - pLoc->m_cGenReg = cSlots; - } - else - { - pLoc->m_byteStackIndex = TransitionBlock::GetStackArgumentByteIndexFromOffset(argOffset); - pLoc->m_byteStackSize = cSlots << 3; - } - - return; - } -#endif // TARGET_RISCV64 +#endif // TARGET_LOONGARCH64 || TARGET_RISCV64 protected: DWORD m_dwFlags; // Cached flags int m_nSizeOfArgStack; // Cached value of SizeOfArgStack