Repository navigation
[Wasm RyuJit] Refactor codegenwasm.cpp to separate div/mod ops and align function names - #122157
Merged
Merged
Conversation
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
- Move GT_DIV, GT_MOD, GT_UDIV, GT_UMOD cases from genCodeForBinary to new genCodeForDivMod function - Remove redundant genCodeForShiftOrRotate declaration in codegen.h - Rename genCodeForShiftOrRotate to genCodeForShift in codegenwasm.cpp - Update genCodeForTreeNode to call genCodeForDivMod for div/mod operations Co-authored-by: kg <[email protected]>
Update NYI_WASM error message from "genCodeForShiftOrRotate" to "genCodeForShift" to match the renamed function. Co-authored-by: kg <[email protected]>
Add assert(tree->OperIsShiftOrRotate()) to match the pattern used in other architectures and improve input validation. Co-authored-by: kg <[email protected]>
Copilot
AI
changed the title
[WIP] Update codegenwasm.cpp to improve code quality
[Wasm RyuJit] Refactor codegenwasm.cpp to separate div/mod ops and align function names
Dec 3, 2025
kg
approved these changes
Dec 3, 2025
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the WebAssembly RyuJIT backend to align its code structure with other architectures (ARM64, x64, RISC-V64) by separating division/modulus operations from basic arithmetic and standardizing function naming conventions.
Key changes:
- Extracted division and modulus operations (
GT_DIV,GT_MOD,GT_UDIV,GT_UMOD) fromgenCodeForBinaryinto a new dedicatedgenCodeForDivModfunction - Renamed
genCodeForShiftOrRotatetogenCodeForShiftto match the declaration incodegen.hand align with other architectures - Removed redundant
#ifdef TARGET_WASMdeclaration block incodegen.h
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/coreclr/jit/codegenwasm.cpp | Extracted div/mod operations to new genCodeForDivMod function, renamed shift function to genCodeForShift, updated dispatch logic in genCodeForTreeNode, added validation assert |
| src/coreclr/jit/codegen.h | Removed redundant #ifdef TARGET_WASM wrapped declaration for genCodeForShiftOrRotate |
Contributor
|
cc @dotnet/jit-contrib |
adamperlin
approved these changes
Dec 4, 2025
This was referenced Dec 4, 2025
Open
AndyAyersMS
approved these changes
Dec 4, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The WebAssembly RyuJIT backend mixed division/modulus operations with basic arithmetic in
genCodeForBinaryand used an inconsistent function namegenCodeForShiftOrRotatethat didn't match the declaration incodegen.h.Changes
GT_DIV,GT_MOD,GT_UDIV,GT_UMODfromgenCodeForBinaryto newgenCodeForDivModfunction, matching ARM64/x64/RISC-V64 architecturegenCodeForShiftOrRotate→genCodeForShiftto matchcodegen.hdeclaration and other targets#ifdef TARGET_WASMwrappedgenCodeForShiftOrRotatedeclaration incodegen.hassert(tree->OperIsShiftOrRotate())consistent with x64 implementationUpdated dispatch in
genCodeForTreeNode:Aligns WASM backend structure with established patterns across other architectures.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.