-
Notifications
You must be signed in to change notification settings - Fork 288
riscv: K extension (part 1), floating-point control and state register #1278
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
Conversation
sm4ed function; small typo fix
9777595
to
596762d
Compare
You don't need to restrict yourself to |
96df8f0
to
f61be77
Compare
Use `static_assert!` macro to constrain BS: u8 Thanks @Amanieu
f61be77
to
ad6287a
Compare
Thank you for your advice @Amanieu! I fixed with |
For the crypto intrinsics we should try to use LLVM intrinsics instead of inline assembly since it allows LLVM to schedule the instructions for better performance. These are supported in LLVM 14 which we should be upgrading to soon (rust-lang/rust#93577). It's fine to use inline assembly for now though. |
Yes, thanks for mentioning, these lines of intrinsics should be changed into LLVM intrinsics in newer versions of stdarch. |
Are the floating-point CSR intrinsics okay to have? AArch32 lacks them because of some worry about violating LLVM’s assumptions. |
@pthariensflame It might be useful in developing precise mathematical analysis software, where rounding modes would be necessary to decrease errors on strict floating point calculations. It provides a way to manually set or read the rounding mode and error flags under nightly; however if it resulted in a non-compliance to higher programming language assumptions under LLVM or other compiler framework, I suggest it would be designed in other ways (external crates instead, etc.) to achieve the above purpose like switching rounding modes, instead of building it into |
The problem is that currently LLVM assumes that the rounding mode is always the default unless you use special intrinsics for floating-point operations (which rustc doesn't currently expose). I think it's fine to leave them in for now, but we should review this before stabilization. See #781 for a similar discussion on x86. |
This pull request includes:
Zksh
,Zksed
extension in RISC-V K extension. There are four functions:sm3p0
,sm3p1
,sm4ed
andsm4ks
function.frcsr
,frrm
,frflags
, and three swap instructionsfscsr
,fsrm
,fsflags
as is defined in the RISC-V unprivileged specification.The features above are all defined as safe Rust functions. Four K extension functions operates like arithmetic functions and does not visit on any memory addresses. The floating point control operations only reads or writes to floating point control configurations of the current hart.
Note: choose of typeFixed: uses BS: u8 and static_assert! internal macro.i32
insm4ks<const BS: i32>(x: u32, k: u32) -> u32
is required by an internal macrostatis_assert_imm2
.r? @Amanieu