RISC-V: Use symbolic instructions on inline assembly (part 2)#1936
Draft
a4lg wants to merge 2 commits intorust-lang:mainfrom
Draft
RISC-V: Use symbolic instructions on inline assembly (part 2)#1936a4lg wants to merge 2 commits intorust-lang:mainfrom
a4lg wants to merge 2 commits intorust-lang:mainfrom
Conversation
While many intrinsics use `.insn` to generate raw machine code from numbers, all ratified instructions can be symbolic using `.option` directives. By saving the assembler environment with `.option push` then modifying the architecture with `.option arch`, we can temporarily enable certain extensions (as we use `.option pop` immediately after the target instruction, surrounding environment is completely intact in this commit; *almost* completely intact in general). This commit modifies the `pause` *hint* intrinsic to use symbolic *instruction* because we want to expose it even if the Zihintpause extension is unavailable on the target.
While many intrinsics use `.insn` to generate raw machine code from numbers, all ratified instructions can be now symbolic. This is the part two (after the `pause` intrinsic) and uses a different way to use symbolic instructions. Normally, intrinsics require corresponding extensions and this commit uses newly added Rust target features `h` and `svinval` (both representing supervisor-mode extensions), along with the `#[target_feature(enable = ...)]` attribute. Note: `hinval.vvma` and `hinval.gvma` instructions are a part of the Svinval extension (the H extension is not directly required by LLVM) but denoted to require both `h` and `svinval` to show semantic context (they are useful only when the H extension is present and according to the documentation, they are provided only if the hypervisor extension is enabled).
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
While many intrinsics use
.insnto generate raw machine code from numbers, all ratified instructions can be now symbolic.This is the part two (after the
pauseintrinsic) and uses a different way to use symbolic instructions.Normally, intrinsics require corresponding extensions and this commit uses newly added Rust target features
handsvinval(both representing supervisor-mode extensions), along with the#[target_feature(enable = ...)]attribute.Note
hinval.vvmaandhinval.gvmainstructions are a part of the Svinval extension (the H extension is not directly required by LLVM) but denoted to require bothhandsvinvalto show semantic context (they are useful only when the H extension is present and according to the documentation, they are provided only if the hypervisor extension is enabled).This is the part two after #1927 (currently, this is the superset of it) and requires some Rust compiler changes (adding target features
handsvinval; so CI should fail as of this writing).