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 Shuffling Thunks part 2 #90707

Merged
merged 3 commits into from
Aug 17, 2023

Conversation

tomeksowi
Copy link
Contributor

Fixes TestMRB6 from ./Regressions/coreclr/GitHub_16833/Test16833/Test16833.sh

This validates the floating registers shuffling adapted from loongarch64.

Apart from the fix, I cleaned up the code around Emit* a bit.

Part of #84834
cc @wscho77 @HJLeee @JongHeonChoi @t-mustafin @alpencolt @gbalykov @clamp03 @jkotas

That script was removed in commit 7d6b73e.
* Don't offset ShuffleEntry's by 10, because that is likely to go out of bounds.
* Base for floating argument regs (fa) is 10 on RISC-V, not 1.
* Src and dst registers in emit fld were reversed
* Restore arguments stashed in temporary registers
* Remove unused Emit* methods
* Centralize instruction creation in *TypeInstr functions to limit the potential for mistakes in hard-coded shifts, masks, etc
* Replace Emit32 calls with hard-coded opcodes with proper Emit* names.
@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Aug 16, 2023
@clamp03 clamp03 added the arch-riscv Related to the RISC-V architecture label Aug 17, 2023
@@ -1276,7 +1276,6 @@ else
fi

scriptPath=$(dirname $0)
${scriptPath}/setup-stress-dependencies.sh --arch=$ARCH --outputDir=$coreOverlayDir
Copy link
Member

Choose a reason for hiding this comment

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

Why do you remove this part in the script?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because setup-stress-dependencies.sh has been removed, details in commit message.

Copy link
Member

Choose a reason for hiding this comment

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

I see. The script is removed.

@jkotas jkotas merged commit ce54acd into dotnet:main Aug 17, 2023

void EmitCallRegister(IntReg reg);
void EmitRet(IntReg reg);

Choose a reason for hiding this comment

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

Probably, you need to remove EmitRet() declaration too since removed implementation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, will add to next PR.

}

void StubLinkerCPU::EmitCmpReg(IntReg Xn, IntReg Xm)
// Instruction types as per RISC-V Spec, Chapter 24 RV32/64G Instruction Set Listings
static unsigned ITypeInstr(unsigned opcode, unsigned funct3, unsigned rd, unsigned rs1, int imm12)

Choose a reason for hiding this comment

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

*TypeInstr functions are very useful, I think they should be available in JIT as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can be moved. Since I'm fairly new to the codebase, what's a good place to put code shared between VM and JIT? utilcode?

There's some more redundancy between the JIT and VM emitter code, e.g. isValid*imm*(), that would be worth factoring out to a common place.

Choose a reason for hiding this comment

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

src/coreclr/utilcode/util.cpp looks more suitable.
@jkotas any thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

The duplication of instruction encoding helpers is very small and it is there on all platforms. I do not think that it is worth fixing. The instruction encoding support in the JIT has to support nearly all instruction. The stublinker needs to be able to encode just a few instructions and so it can be very simple.

@tomeksowi tomeksowi changed the title Fix Shuffling Thunks part 2 [RISC-V] Fix Shuffling Thunks part 2 Aug 18, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Sep 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-riscv Related to the RISC-V architecture area-VM-coreclr community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants