Skip to content

Commit

Permalink
[RISC-V] Fix GetArgLoc (#88657)
Browse files Browse the repository at this point in the history
  • Loading branch information
t-mustafin authored Jul 21, 2023
1 parent 03acd23 commit ba34a13
Showing 1 changed file with 4 additions and 56 deletions.
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

0 comments on commit ba34a13

Please sign in to comment.