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] Added designated output instruction emitters #96741

Merged
merged 120 commits into from
Jan 25, 2024

Conversation

Bajtazar
Copy link
Contributor

@Bajtazar Bajtazar commented Jan 10, 2024

IMPORTANT: Before this PR could be merge, it requires changes from #96136

This PR:

  • Adds a specialized instruction-type related emitters
  • Reinforces checks done during instruction emitting
  • Refactors emitOutputInstr function in order to use a newly added emitters
  • Improves readability of the code

This PR is a part of a larger scope of work aiming to move all output instruction emission to the emitOutputInstr from the emitIns_* functions

Part of #84834
cc @wscho77 @HJLeee @clamp03 @JongHeonChoi @t-mustafin @gbalykov @viewizard @ashaurtaev @brucehoult @sirntar @yurai007 @tomeksowi

src/coreclr/jit/emitriscv64.cpp Outdated Show resolved Hide resolved
src/coreclr/jit/emitriscv64.cpp Outdated Show resolved Hide resolved
Comment on lines +2285 to +2286
// This assert may be triggered by the untrimmed signed integers. Please refer to the TrimSigned helpers
assertCodeLength(imm21, 21);
Copy link
Contributor

@tomeksowi tomeksowi Jan 23, 2024

Choose a reason for hiding this comment

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

Maybe this should call TrimSigned instead? These helpers assert isValidSimm anyway.

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 this stage imm is unsigned since the sign extension has to be removed at this stage (explicitly done via TrimSigned functions or via LowerNBits etc.). This means that I should use isValidUimm or assertCodeLength and I think that the latter one is more versatile.

@Bajtazar Bajtazar requested a review from jakobbotsch January 24, 2024 16:01
Comment on lines +2734 to +2742
static ssize_t LowerNBitsOfWord(ssize_t word)
{
BYTE* const dst = *dp;
BYTE* dstRW = *dp + writeableOffset;
BYTE* dstRW2 = dstRW + 4; // addr for updating gc info if needed.
const BYTE* const odstRW = dstRW;
const BYTE* const odst = *dp;
code_t code = 0;
instruction ins;
size_t sz; // = emitSizeOfInsDsc(id);
static_assert(MaskSize < 32, "Given mask size is bigger than the word itself");
static_assert(MaskSize > 0, "Given mask size cannot be zero");

assert(REG_NA == (int)REG_NA);
static constexpr size_t kMask = NBitMask(MaskSize);

insOpts insOp = id->idInsOpt();
return word & kMask;
}
Copy link
Member

Choose a reason for hiding this comment

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

Isn't it strange that MaskSize can only be up to 32 when the word is a 64 bit value?

@jakobbotsch jakobbotsch merged commit 77fd98c into dotnet:main Jan 25, 2024
125 of 129 checks passed
Bajtazar added a commit to Bajtazar/runtime that referenced this pull request Feb 6, 2024
Bajtazar added a commit to Bajtazar/runtime that referenced this pull request Feb 7, 2024
jakobbotsch pushed a commit that referenced this pull request Feb 13, 2024
* [RISC-V] Fix mistakes in emitter

* Revert "[RISC-V] Added designated output instruction emitters (#96741)"

This reverts commit 77fd98c.

* Revert "Revert "[RISC-V] Added designated output instruction emitters (#96741)""

This reverts commit ecc044d.

* [RISC-V] Sync emitOutputIns with the latest ref branch

* [RISC-V] Formatted code

* [RISC-V] Fixes

* [RISC-V] Fixed sign cast in assert code len

* [RISC-V] Readed assert

* [RISC-V] Fixed fence sanity check and removed fence_i

---------

Co-authored-by: Dong-Heon Jung <clamp03@gmail.com>
@github-actions github-actions bot locked and limited conversation to collaborators Feb 25, 2024
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-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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants