From f0cb8cc47048b38bd74bbf9a12f34329b899052b Mon Sep 17 00:00:00 2001 From: Vineet Gupta Date: Wed, 10 May 2023 12:23:30 -0700 Subject: [PATCH] Add macros for unaligned access https://github.com/riscv-non-isa/riscv-c-api-doc/issues/32 Signed-off-by: Vineet Gupta --- riscv-c-api.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/riscv-c-api.md b/riscv-c-api.md index 6a85b29..74008b4 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -43,6 +43,9 @@ https://creativecommons.org/licenses/by/4.0/. | __riscv_v_min_vlen | (see [__riscv_v_min_vlen](#__riscv_v_min_vlen)) | The `V` extension or one of the `Zve*` extensions is available. | | __riscv_v_elen | (see [__riscv_v_elen](#__riscv_v_elen)) | The `V` extension or one of the `Zve*` extensions is available. | | __riscv_v_elen_fp | (see [__riscv_v_elen_fp](#__riscv_v_elen_fp)) | The `V` extension or one of the `Zve*` extensions is available. | +| __riscv_misaligned_fast | 1 | Misaligned access on cpu are fast. | +| __riscv_misaligned_slow | 1 | Misaligned access on cpu may not be as fast as aligned access. | +| __riscv_misaligned_bad | 1 | Misaligned access are not supported by cpu and could trap. (see [ __riscv_misaligned_{fast,slow,bad}](#__riscv_misaligned_{fast,slow,bad}) | ### __riscv_v_min_vlen @@ -94,6 +97,15 @@ The value of `__riscv_v_elen_fp` is defined by the following rules: If multiple rules apply, the maximum value is taken. If none of the rules apply, `__riscv_v_elen_fp` is undefined. +### __riscv_misaligned_{fast,slow,bad} + +These can be used in common library code to compile time segregate code which relies +on misaligned access being fast or not. +A typical complier could (but not necessarily) map fast variant to -mno-strict-align +and bad to -mstrict-align, if specified. +Perhaps obvious, but these are mutually exclusive, so only one is defined at a time +for a compilation unit. + ### Architecture Extension Test Macro