[RISC-V] Fix GetArgLoc (#88657)
authort-mustafin <66252296+t-mustafin@users.noreply.github.com>
Fri, 21 Jul 2023 11:04:50 +0000 (14:04 +0300)
committerGitHub <noreply@github.com>
Fri, 21 Jul 2023 11:04:50 +0000 (04:04 -0700)
src/coreclr/vm/callingconvention.h

index 3f38cc5..716cb8f 100644 (file)
@@ -849,8 +849,9 @@ public:
     }
 #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 @@ public:
             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 @@ public:
         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