Skip to content

Conversation

shushanhf
Copy link
Contributor

Add supporting for LoongArch64.

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Dec 15, 2021
@ghost
Copy link

ghost commented Dec 15, 2021

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@ghost
Copy link

ghost commented Dec 15, 2021

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@dnfadmin
Copy link

dnfadmin commented Dec 15, 2021

CLA assistant check
All CLA requirements met.

@jkotas
Copy link
Member

jkotas commented Dec 15, 2021

@shushanhf Great to see this submitted! Could you please split this into one PR per part? It would be very hard to review and merge all parts together.

@shushanhf
Copy link
Contributor Author

@shushanhf Great to see this submitted! Could you please split this into one PR per part? It would be very hard to review and merge all parts together.

Thanks for your suggest.
I will recommit them again.

@shushanhf
Copy link
Contributor Author

shushanhf commented Dec 16, 2021

@shushanhf Great to see this submitted! Could you please split this into one PR per part? It would be very hard to review and merge all parts together.

I didn't know different PRs for each patch commiting well.
I pushed them again.

Liking the #62885 , Is it Ok ?

@jkotas
Copy link
Member

jkotas commented Dec 16, 2021

#62885 , Is it Ok ?

Yes, this PR is ok. I have updated the PR title to "[LoongArch64] coreclr-vm directory". Could you please use similar pattern for titles of the remaining LoongArch64 PRs?

Also, could you please sign the Contributor License Agreement?

@shushanhf
Copy link
Contributor Author

#62885 , Is it Ok ?

Yes, this PR is ok. I have updated the PR title to "[LoongArch64] coreclr-vm directory". Could you please use similar pattern for titles of the remaining LoongArch64 PRs?

Also, could you please sign the Contributor License Agreement?

Ok,Thanks.
I will push other patches now and update the CLA.

1 similar comment
@shushanhf
Copy link
Contributor Author

#62885 , Is it Ok ?

Yes, this PR is ok. I have updated the PR title to "[LoongArch64] coreclr-vm directory". Could you please use similar pattern for titles of the remaining LoongArch64 PRs?

Also, could you please sign the Contributor License Agreement?

Ok,Thanks.
I will push other patches now and update the CLA.

@jkotas jkotas changed the title Main loongarch64 [LoongArch64] coreclr-jit directory Dec 16, 2021
@jkotas jkotas added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Dec 16, 2021
@ghost
Copy link

ghost commented Dec 16, 2021

Tagging subscribers to this area: @JulieLeeMSFT
See info in area-owners.md if you want to be subscribed.

Issue Details

Add supporting for LoongArch64.

Author: shushanhf
Assignees: -
Labels:

area-CodeGen-coreclr, new-api-needs-documentation, community-contribution

Milestone: -

@shushanhf
Copy link
Contributor Author

I had finished a new patch for this PR based on the newest main branch.
If need, I will upload it to resolve conflicts.

@shushanhf
Copy link
Contributor Author

I will update later for compiling errorrs after merging from the main.

@shushanhf
Copy link
Contributor Author

closing & reopening for triger CI

@shushanhf shushanhf closed this Jan 11, 2022
@BruceForstall
Copy link
Contributor

Could you please give me some advices for next ?

I've been busy and/or sick the last few days. I plan to take a look at this PR again soon.

Assuming you've addressed all the comments and feedback, and I don't see anything new of concern, I expect to merge this soon.

@shushanhf
Copy link
Contributor Author

Could you please give me some advices for next ?

I've been busy and/or sick the last few days. I plan to take a look at this PR again soon.

Assuming you've addressed all the comments and feedback, and I don't see anything new of concern, I expect to merge this soon.

Thanks.
I hope you will soon recover.

Copy link
Contributor

@SingleAccretion SingleAccretion left a comment

Choose a reason for hiding this comment

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

More comments from me, next up will be morph, more lowering & LSRA, and I plan to take a cursory look at the LA-specific files as well (if time permits -- I will approve once I've looked at everything planned).

@BruceForstall
Copy link
Contributor

More comments from me, next up will be morph, more lowering & LSRA, and I plan to take a cursory look at the LA-specific files as well (if time permits -- I will approve once I've looked at everything planned).

@SingleAccretion Thanks for taking the time to review this. Please focus on the common files; we're not worried too much about the LA-specific files. (Ideally any place where LA adds significant new code to common files is a sign that we should refactor things to reduce platform-specific code in common files, if possible.)

@shushanhf
Copy link
Contributor Author

More comments from me, next up will be morph, more lowering & LSRA, and I plan to take a cursory look at the LA-specific files as well (if time permits -- I will approve once I've looked at everything planned).

Thanks very much for your review.
I will update now.

Comment on lines 4930 to 4932
// For LoongArch64's ABI, maybe there is a padding.
// e.g. `struct {float a; long b;}`
offset += TARGET_POINTER_SIZE;
Copy link
Contributor

Choose a reason for hiding this comment

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

I am curious: will LA try to pass the following struct without padding in two registers?

[StructLayout(LayoutKind.Sequential, Pack = 4)]
struct MixedMultiRegStructNoPad
{
    public int FltValue;
    public double DblValue;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this will pad as each slot on the stack is eight bytes for this case.

Copy link
Contributor

@SingleAccretion SingleAccretion Apr 1, 2022

Choose a reason for hiding this comment

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

It would be useful to confirm the behavior in this case is what we want/expect.

Note there are many variations of this "custom layout" problem, e. g.:

[StructLayout(LayoutKind.Explicit, Size = 16)]
struct OddStruct
{
    [FieldOffset(1)]
    public int FltValue;    // Misaligned
    [FieldOffset(7)]
    public double DblValue; // Also misaligned
}

Where the native ABI doesn't necessarily cover it (I suppose I would expect the struct above to be passed in two integer registers as a union-like thing)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think there are some cases within the coreclr's test cases.

I will add a test case tomorrow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It takes some time to rebuild the test env based on the latest runtime before testing.

Copy link
Contributor Author

@shushanhf shushanhf Apr 4, 2022

Choose a reason for hiding this comment

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

It takes some time to rebuild the test env based on the latest runtime before testing.

Now I have to build a new SDK7 for LA but this usually is very difficut when building an new version SDK at the first time, because the latest installer usually can be built on the x64-linux.

Now the SDK6.0.2 is OK for LA and had tested the runtime's test-cases and ASP's cases and also some real projects tested by other companies.

If I can get a SDK7 liking the CI's testing env I can focus on testing and debuging the latest runtime on LA more efficiently.

}

#if defined(TARGET_LOONGARCH64)
if (varTypeIsFloating(spillType) && emitter::isGeneralRegister(tree->GetRegNum()))
Copy link
Contributor

Choose a reason for hiding this comment

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

One way to interpret this code is to mean we now have LCL_VAR<V00 float> int nodes in the system.

Where do they come from?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On LoongArch64's ABI, Float type arg is passed by integer register while there is no float register left.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but that doesn't explain it fully.

For the caller (method being compiled), we would have LCL_VAR V00<float> float, i. e. both the local variable have TYP_FLOAT and the node. And obviously a TYP_FLOAT node cannot have an integer register assigned to it.

So is it the case for callees then? I. e. fgMorphArgs retyping?

Could you please share a JitDump where we will see this case?

Copy link
Contributor Author

@shushanhf shushanhf Apr 1, 2022

Choose a reason for hiding this comment

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

In test cases this is ok where LA's SDK6 is ok.

I will add some asm tomorrow.

@BruceForstall
Copy link
Contributor

/azp run runtime, runtime-coreclr superpmi-asmdiffs

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

when running hello-world within debug-mode.
@shushanhf
Copy link
Contributor Author

shushanhf commented Apr 8, 2022

Now I had tested the hello-world passed both the release and debug mode based on the latest main-LoongArch64.

@shushanhf
Copy link
Contributor Author

I am busying the publishing the SDK6.0-LoongArch64 for C# developers during the last two weeks.

I had finished a runtime-env only for LoongArch64 which not the whole SDK7.0 for LA and had passed the hello-world within both the release and debug mode.

Copy link
Contributor

@BruceForstall BruceForstall left a comment

Choose a reason for hiding this comment

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

This is ready to be merged. @shushanhf Thanks for incorporating all the feedback. After this, I expect we will see more updates, in (much) smaller pull requests.

@BruceForstall BruceForstall merged commit 51afa06 into dotnet:main Apr 8, 2022
@shushanhf
Copy link
Contributor Author

This is ready to be merged. @shushanhf Thanks for incorporating all the feedback. After this, I expect we will see more updates, in (much) smaller pull requests.

Thanks very much.
We will be constantly improving the LoongArch64's implementation.

@shushanhf shushanhf deleted the main_loongarch64 branch May 11, 2022 01:11
@ghost ghost locked as resolved and limited conversation to collaborators Jun 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-loongarch64 area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI community-contribution Indicates that the PR has been added by a community member new-api-needs-documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.