]> git.proxmox.com Git - rustc.git/blob - library/stdarch/crates/core_arch/src/riscv64/mod.rs
New upstream version 1.74.1+dfsg1
[rustc.git] / library / stdarch / crates / core_arch / src / riscv64 / mod.rs
1 //! RISC-V RV64 specific intrinsics
2 use crate::arch::asm;
3
4 mod zk;
5
6 pub use zk::*;
7
8 /// Loads virtual machine memory by unsigned word integer
9 ///
10 /// This instruction performs an explicit memory access as though `V=1`;
11 /// i.e., with the address translation and protection, and the endianness, that apply to memory
12 /// accesses in either VS-mode or VU-mode.
13 ///
14 /// This operation is not available under RV32 base instruction set.
15 ///
16 /// This function is unsafe for it accesses the virtual supervisor or user via a `HLV.WU`
17 /// instruction which is effectively a dereference to any memory address.
18 #[inline]
19 pub unsafe fn hlv_wu(src: *const u32) -> u32 {
20 let value: u32;
21 asm!(".insn i 0x73, 0x4, {}, {}, 0x681", out(reg) value, in(reg) src, options(readonly, nostack));
22 value
23 }
24
25 /// Loads virtual machine memory by double integer
26 ///
27 /// This instruction performs an explicit memory access as though `V=1`;
28 /// i.e., with the address translation and protection, and the endianness, that apply to memory
29 /// accesses in either VS-mode or VU-mode.
30 ///
31 /// This operation is not available under RV32 base instruction set.
32 ///
33 /// This function is unsafe for it accesses the virtual supervisor or user via a `HLV.D`
34 /// instruction which is effectively a dereference to any memory address.
35 #[inline]
36 pub unsafe fn hlv_d(src: *const i64) -> i64 {
37 let value: i64;
38 asm!(".insn i 0x73, 0x4, {}, {}, 0x6C0", out(reg) value, in(reg) src, options(readonly, nostack));
39 value
40 }
41
42 /// Stores virtual machine memory by double integer
43 ///
44 /// This instruction performs an explicit memory access as though `V=1`;
45 /// i.e., with the address translation and protection, and the endianness, that apply to memory
46 /// accesses in either VS-mode or VU-mode.
47 ///
48 /// This function is unsafe for it accesses the virtual supervisor or user via a `HSV.D`
49 /// instruction which is effectively a dereference to any memory address.
50 #[inline]
51 pub unsafe fn hsv_d(dst: *mut i64, src: i64) {
52 asm!(".insn r 0x73, 0x4, 0x37, x0, {}, {}", in(reg) dst, in(reg) src, options(nostack));
53 }