Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RISC-V] Fix GetArgLoc #88657

Merged
merged 1 commit into from
Jul 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 4 additions & 56 deletions src/coreclr/vm/callingconvention.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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
Expand Down