diff --git a/src/c-api.adoc b/src/c-api.adoc index 1c8219b..1f5ec59 100644 --- a/src/c-api.adoc +++ b/src/c-api.adoc @@ -485,6 +485,48 @@ RISC-V intrinsics examples: vint8m1_t __riscv_vadd_vv_i8m1(vint8m1_t vs2, vint8m1_t vs1, size_t vl); // vadd.vv vd, vs2, vs1 ---- +=== CMO Intrinsics + +The RISC-V CMO extension provides instruction for perform operations on copies +of data in the memory hierarchy. + +In order to access the RISC-V CMO intrinsics, it is necessary to +include the header file `riscv_cmo.h`. + +The functions are only available if the compiler's `-march` string enables the +required ISA extension. + +.CMO Extension Intrinsics +[%autowidth] +|=== +|*Prototype* |*Instruction* |*Extension* |*Notes* +|`+void __riscv_cmo_clean(void *addr);+` |`cbo.clean` |Zicbom | +|`+void __riscv_cmo_flush(void *addr);+` |`cbo.flush` |Zicbom | +|`+void __riscv_cmo_inval(void *addr);+` |`cbo.inval` |Zicbom | +|`+void __riscv_cmo_zero(void *addr);+` |`cbo.zero` |Zicboz | +|`+void __riscv_cmo_prefetch(void *addr, const int rw, const int locality);+` |`prefetch.[r][w]` |Zicbop | `rw`= [0,1], `locality` = [0..3]. +|`+int __riscv_cmo_prefetchi(const int locality);+` |`prefetch.i` |Zicbop | +|=== + +Note: riscv_cmo_prefetch is a wrapper around builtin_prefetch. +Similar to Prefetch Intrinsics, the following table presents the mapping from +the riscv_cmo_prefetch function to the corresponding assembly instructions, +assuming the presence of the Zihintntl and Zicbop extensions. + +.CMO Functions to Assembly Mapping with Zihintntl +[%autowidth] +|=== +|*Prefetch function* |*Assembly* +|`+__riscv_cmo_prefetch(ptr, 0, 0 /* locality */);+` |`ntl.all + prefetch.r (ptr)` +|`+__riscv_cmo_prefetch(ptr, 0, 1 /* locality */);+` |`ntl.pall + prefetch.r (ptr)` +|`+__riscv_cmo_prefetch(ptr, 0, 2 /* locality */);+` |`ntl.p1 + prefetch.r (ptr)` +|`+__riscv_cmo_prefetch(ptr, 0, 3 /* locality */);+` |`prefetch.r (ptr)` +|`+__riscv_cmo_prefetch(ptr, 1, 0 /* locality */);+` |`ntl.all + prefetch.w (ptr)` +|`+__riscv_cmo_prefetch(ptr, 1, 1 /* locality */);+` |`ntl.pall + prefetch.w (ptr)` +|`+__riscv_cmo_prefetch(ptr, 1, 2 /* locality */);+` |`ntl.p1 + prefetch.w (ptr)` +|`+__riscv_cmo_prefetch(ptr, 1, 3 /* locality */);+` |`prefetch.w (ptr)` +|=== + === NTLH Intrinsics