Skip to content

Commit 66cf1c5

Browse files
committed
Add atomic intrinsics
We need this when optimizing some locks' implementation, but using inline assembly will stop some optimizations. For example, if we use inline assembly, the compiler doesn't know `lr.w` will sign-extend the result. ARM provides similar intrinsics like `__builtin_arm_ldaex`. Currently, we only add intrinsics for `Zawrs`.
1 parent fbf5f4e commit 66cf1c5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/c-api.adoc

+11
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,17 @@ RISC-V intrinsics examples:
485485
vint8m1_t __riscv_vadd_vv_i8m1(vint8m1_t vs2, vint8m1_t vs1, size_t vl); // vadd.vv vd, vs2, vs1
486486
----
487487

488+
### Atomic Intrinsics
489+
In order to access the RISC-V atomic intrinsics, it is necessary to include the
490+
header file `riscv_atomic.h`.
491+
The functions are only available if the compiler's `-march` string enables the
492+
required ISA extension.
493+
The following table contains all the atomic intrinsics:
494+
| Prototype | Instruction | Extension | Notes |
495+
| --------- | ----------- | --------- | ----- |
496+
| `void __riscv_wrs_nto();` | `wrs.nto` | Zawrs | |
497+
| `void __riscv_wrs_sto();` | `wrs.sto` | Zawrs | |
498+
488499
=== NTLH Intrinsics
489500

490501

0 commit comments

Comments
 (0)