@@ -485,6 +485,48 @@ RISC-V intrinsics examples:
485
485
vint8m1_t __riscv_vadd_vv_i8m1(vint8m1_t vs2, vint8m1_t vs1, size_t vl); // vadd.vv vd, vs2, vs1
486
486
----
487
487
488
+ === CMO Intrinsics
489
+
490
+ The RISC-V CMO extension provides instruction for perform operations on copies
491
+ of data in the memory hierarchy.
492
+
493
+ In order to access the RISC-V CMO intrinsics, it is necessary to
494
+ include the header file `riscv_cmo.h`.
495
+
496
+ The functions are only available if the compiler's `-march` string enables the
497
+ required ISA extension.
498
+
499
+ .CMO Extension Intrinsics
500
+ [%autowidth]
501
+ |===
502
+ |*Prototype* |*Instruction* |*Extension* |*Notes*
503
+ |`+void __riscv_cmo_clean(void *addr);+` |`cbo.clean` |Zicbom |
504
+ |`+void __riscv_cmo_flush(void *addr);+` |`cbo.flush` |Zicbom |
505
+ |`+void __riscv_cmo_inval(void *addr);+` |`cbo.inval` |Zicbom |
506
+ |`+void __riscv_cmo_zero(void *addr);+` |`cbo.zero` |Zicboz |
507
+ |`+void __riscv_cmo_prefetch(void *addr, const int rw, const int locality);+` |`prefetch.[r][w]` |Zicbop | `rw`= [0,1], `locality` = [0..3].
508
+ |`+int __riscv_cmo_prefetchi(const int locality);+` |`prefetch.i` |Zicbop |
509
+ |===
510
+
511
+ Note: riscv_cmo_prefetch is a wrapper around builtin_prefetch.
512
+ Similar to Prefetch Intrinsics, the following table presents the mapping from
513
+ the riscv_cmo_prefetch function to the corresponding assembly instructions,
514
+ assuming the presence of the Zihintntl and Zicbop extensions.
515
+
516
+ .CMO Functions to Assembly Mapping with Zihintntl
517
+ [%autowidth]
518
+ |===
519
+ |*Prefetch function* |*Assembly*
520
+ |`+__riscv_cmo_prefetch(ptr, 0, 0 /* locality */);+` |`ntl.all + prefetch.r (ptr)`
521
+ |`+__riscv_cmo_prefetch(ptr, 0, 1 /* locality */);+` |`ntl.pall + prefetch.r (ptr)`
522
+ |`+__riscv_cmo_prefetch(ptr, 0, 2 /* locality */);+` |`ntl.p1 + prefetch.r (ptr)`
523
+ |`+__riscv_cmo_prefetch(ptr, 0, 3 /* locality */);+` |`prefetch.r (ptr)`
524
+ |`+__riscv_cmo_prefetch(ptr, 1, 0 /* locality */);+` |`ntl.all + prefetch.w (ptr)`
525
+ |`+__riscv_cmo_prefetch(ptr, 1, 1 /* locality */);+` |`ntl.pall + prefetch.w (ptr)`
526
+ |`+__riscv_cmo_prefetch(ptr, 1, 2 /* locality */);+` |`ntl.p1 + prefetch.w (ptr)`
527
+ |`+__riscv_cmo_prefetch(ptr, 1, 3 /* locality */);+` |`prefetch.w (ptr)`
528
+ |===
529
+
488
530
=== NTLH Intrinsics
489
531
490
532
0 commit comments