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

[LoongArch64] coreclr-vm directory #62885

Merged
merged 49 commits into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
47d106f
Merge pull request #1 from dotnet/main
shushanhf Apr 27, 2021
411b59e
Merge branch 'dotnet:main' into master
shushanhf Oct 25, 2021
7eed4eb
Merge branch 'dotnet:main' into master
shushanhf Dec 6, 2021
0d7c9e4
Merge branch 'dotnet:main' into master
shushanhf Dec 10, 2021
2c534c5
Merge branch 'dotnet:main' into master
shushanhf Dec 14, 2021
6e14d76
Merge branch 'dotnet:main' into master
shushanhf Dec 15, 2021
359875d
Merge branch 'dotnet:main' into master
shushanhf Dec 15, 2021
192b095
Merge branch 'dotnet:main' into main
shushanhf Dec 16, 2021
8a9d654
Part6-2: -add the coreclr-vm directory for LoongArch64. (#59561)
shushanhf Dec 15, 2021
4606899
[LoongArch64] revert the syncblk.cpp.
Dec 17, 2021
e62a6cd
[LoongArch64] delete some unused codes.
Dec 18, 2021
cdb7606
[LoongArch64] add vm/CMakeLists.txt from #62889.
Dec 18, 2021
ad3b666
[LoongArch64] add related files from #62886 and #62893.
Dec 20, 2021
7d03307
[LoongArch64] moved vm/jitinterface.cpp from #62893.
Dec 20, 2021
f6ec562
[LoongArch64] run the file `src/coreclr/tools/Common/JitInterface/Thu…
shushanhf Dec 20, 2021
277de6f
[LoongArch64] revert vm/ceeload.h.
shushanhf Dec 20, 2021
d6dabd7
[LoongArch64] add empty interfaces within `CorInfoImpl.cs`.
Dec 21, 2021
63073dc
[LoongArch64] Fix the compiling error on Windows.
Dec 21, 2021
6aa5e1a
[LoongArch64] Fix the compiling error for memory unaligned m_currentB…
Dec 21, 2021
3e3c3b3
[LoongArch64] Delete the !TARGET_LOONGARCH64 for m_currentByteStackIn…
Dec 22, 2021
55eeb95
[LoongArch64] move ToolBox from #62886.
Dec 22, 2021
21040b8
[LoongArch64] amend the args when needs unsigned extending within Cal…
Dec 23, 2021
19e4357
[LoongArch64] add bool type for args' unsigned extention.
Dec 24, 2021
743c518
[LoongArch64] adding char type for args' unsigned extention.
Dec 24, 2021
cb91556
[LoongArch64] amend renaming `TARGET_LOONGARCH64` to `UNIX_LOONGARCH6…
Dec 24, 2021
1f790f4
[LoongArch64] remove the JIT/EE interface to #62893.
Dec 24, 2021
42fd640
[LoongArch64] revert the rename `TARGET_LOONGARCH64` to `UNIX_LOONGAR…
shushanhf Dec 25, 2021
7757e09
[LoongArch64] refactor the `ArgDestination and ArgLocDesc`.
Jan 7, 2022
ba9fba0
Merge branch 'main' into main_loongarch64_2
shushanhf Jan 12, 2022
86d4546
[LoongArch64] rename the `m_flag` and `getFieldTypeByHnd`.
shushanhf Jan 13, 2022
56b0a79
[LoongArch64] add `NATIVE_SYMBOL_READER_DLL` for compiling error.
shushanhf Jan 14, 2022
5798329
[LoongArch64] update the version of the `LICENSE description`.
Jan 19, 2022
c747f93
Merge branch 'main' into main_loongarch64_2
Feb 15, 2022
48b4734
[LoongArch64] keep same with the comment in `jit/targetloongarch64.h`
Feb 16, 2022
a96f159
Merge branch 'main' into main_loongarch64_2
Feb 18, 2022
aa96fba
[LoongArch64] amend the code for reviewing.
shushanhf Feb 21, 2022
cc96589
[LoongArch64] refactor LoongArch64-ABI within `vm`,
Feb 22, 2022
d3e6ca7
Merge branch 'main' into main_loongarch64_2
shushanhf Feb 23, 2022
4b32677
[LoongArch64] delete unused codes.
shushanhf Feb 23, 2022
9bb6899
Merge branch 'main' into main_loongarch64_2
Feb 25, 2022
c01407f
[LoongArch64] merge main for #65869.
Feb 25, 2022
14669dc
Merge branch 'main' into main_loongarch64_2
shushanhf Mar 1, 2022
7b8b887
[LoongArch64] amend the format for reviewing.
shushanhf Mar 1, 2022
ceee54a
[LoongArch64] delete some unused code for reviewing.
shushanhf Mar 1, 2022
00fdee0
[LoongArch64] amend code for CR feedback @jkotas @janvorli
shushanhf Mar 2, 2022
a623961
[LoongArch64] add class type for LoongArch64-ABI.
Mar 3, 2022
6566991
[LoongArch64] Amend the LoongArch64's ABI
shushanhf Mar 4, 2022
9f39e13
Merge branch 'main' into main_loongarch64_2
shushanhf Mar 22, 2022
d6c7080
[LoongArch64] Fix the assert error
shushanhf Apr 2, 2022
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
35 changes: 33 additions & 2 deletions src/coreclr/vm/argdestination.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class ArgDestination
LIMITED_METHOD_CONTRACT;
#if defined(UNIX_AMD64_ABI)
_ASSERTE((argLocDescForStructInRegs != NULL) || (offset != TransitionBlock::StructInRegsOffset));
#elif defined(TARGET_ARM64)
// This assert is not interesting on arm64. argLocDescForStructInRegs could be
#elif defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64)
// This assert is not interesting on arm64/loongarch64. argLocDescForStructInRegs could be
// initialized if the args are being enregistered.
#else
_ASSERTE(argLocDescForStructInRegs == NULL);
Expand Down Expand Up @@ -83,6 +83,37 @@ class ArgDestination
#endif // !DACCESS_COMPILE
#endif // defined(TARGET_ARM64)

#if defined(TARGET_LOONGARCH64)
bool IsStructPassedInRegs()
{
return m_argLocDescForStructInRegs != NULL;
}

#ifndef DACCESS_COMPILE
void CopyStructToRegisters(void *src, int fieldBytes)
{
_ASSERTE(IsStructPassedInRegs());
_ASSERTE(m_argLocDescForStructInRegs->m_cFloatReg == 1);
Copy link
Member

@jkotas jkotas Dec 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the case of struct passed in two floating registers handled?

Copy link
Contributor Author

@shushanhf shushanhf Dec 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the case of struct passed in two floating registers handled?

A struct containing just one floating-point real is passed as though it were a standalone floating-point real.
It's related with the ABI, similar with the PR #62893 ,
#62893 (comment)

This case is also the same with the RISC-V: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc

_ASSERTE(m_argLocDescForStructInRegs->m_cGenReg == 1);
_ASSERTE(fieldBytes <= 16);

int argOfs = TransitionBlock::GetOffsetOfFloatArgumentRegisters() + m_argLocDescForStructInRegs->m_idxFloatReg * 8;
*(UINT64*)((char*)m_base + argOfs) = *(UINT64*)src;

////TODO:maybe optimize ?
argOfs = TransitionBlock::GetOffsetOfArgumentRegisters() + m_argLocDescForStructInRegs->m_idxGenReg * 8;
*(UINT64*)((char*)m_base + argOfs) = *((UINT64*)src + 1);
}
#endif // !DACCESS_COMPILE

PTR_VOID GetStructGenRegDestinationAddress()
{
_ASSERTE(IsStructPassedInRegs());
int argOfs = TransitionBlock::GetOffsetOfArgumentRegisters() + m_argLocDescForStructInRegs->m_idxGenReg * 8;
return dac_cast<PTR_VOID>(dac_cast<TADDR>(m_base) + argOfs);
}
#endif // defined(TARGET_LOONGARCH64)

#if defined(UNIX_AMD64_ABI)

// Returns true if the ArgDestination represents a struct passed in registers.
Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/vm/callhelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,11 @@ void MethodDescCallSite::CallTargetWorker(const ARG_SLOT *pArguments, ARG_SLOT *
case 1:
case 2:
case 4:
#if defined(TARGET_LOONGARCH64)
jkotas marked this conversation as resolved.
Show resolved Hide resolved
*((INT64*)pDest) = (INT32)pArguments[arg];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is not right now that we have established in loongson/LoongArch-Documentation#32 that signed integers should be sign-extended and unsigned integers should be zero-extended.

Copy link
Contributor Author

@shushanhf shushanhf Dec 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loongson/LoongArch-Documentation#32 (comment)

So we can simplify it by signed extexd.

Copy link
Member

@jkotas jkotas Dec 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment you have quoted talks about one specific example. The specific example has signed integer and so the value is sign-extended.

The general rule in the current version of the ABI doc is:

When passed in registers or on the stack, the unsigned integer scalars narrower than GRLEN bits are zero-extended to GRLEN bits, and the signed integer scalars are sign-extended.

https://github.com/loongson/LoongArch-Documentation/pull/32/files#diff-711b3e7b6a005b492898ac6d93f2d8d37c00e0831e210993a6f9dbb26c043717R711

This rule has to be applied here and in other places.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment you have quoted talks about one specific example. The specific example has signed integer and so the value is sign-extended.

The general rule in the current version of the ABI doc is:

When passed in registers or on the stack, the unsigned integer scalars narrower than GRLEN bits are zero-extended to GRLEN bits, and the signed integer scalars are sign-extended.

https://github.com/loongson/LoongArch-Documentation/pull/32/files#diff-711b3e7b6a005b492898ac6d93f2d8d37c00e0831e210993a6f9dbb26c043717R711

This rule has to be applied here and in other places.

Thanks, I agree with you.
It's better to fit the signed and unsigned.
I will amend it.

#else
*((INT32*)pDest) = (INT32)pArguments[arg];
#endif
break;

case 8:
Expand Down
Loading