From b54e1e689691d46e532e72546467c02da26a95f8 Mon Sep 17 00:00:00 2001 From: Kito Cheng Date: Mon, 14 Feb 2022 22:57:28 +0800 Subject: [PATCH] Explicitly write down the rule of architecture extension test macros We didn't write the rule explicitly, so people might not expect those marco to be available if it's not appear on the table. So let document that, and add more note to say people can expect that even not list on the table. --- riscv-c-api.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/riscv-c-api.md b/riscv-c-api.md index 0261913..f5c5ad1 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -102,6 +102,14 @@ availability and version for certain extension, however not all compilers are supported, so you should check `__riscv_arch_test` to make sure this compiler is supporting those preprocessor definitions. +The naming rule of architecture extension test macros is `__riscv_`, +e.g. `__riscv_zifencei` for `zifencei` extension and `__riscv_a` for `A` +extension. + +Compilers should define corresponding architecture extension test macros if the +extension is enabled, and we strongly suggest vendor extensions should follow +this rule. + The value of architecture extension test macro are defined as its version, which is compute by following formula: @@ -130,6 +138,11 @@ For example: | __riscv_zbs | Arch Version | `Zbs` extension is available. | | __riscv_zfh | Arch Version | `Zfh` extension is available. | +NOTE: The table might not list all architecture extension test macros for +ratified extensions due to not up-to-date, and might not list unratified +extensions, but you could assume there is a corresponding architecture extension +test macro available. + ### ABI Related Preprocessor Definitions | Name | Value | When defined |