Skip to content

Commit aec3c3b

Browse files
authored
Merge pull request #21 from kito-cheng/v-ext-marco
Add misc macro for vector extensions.
2 parents 7005920 + 2a3b3a8 commit aec3c3b

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

riscv-c-api.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,60 @@ https://creativecommons.org/licenses/by/4.0/.
4040
| __riscv_flen | <ul><li>32 if the F extension is available **or**</li><li>64 if `D` extension available **or**</li><li>128 if `Q` extension available</li></ul> | `F` extension is available. |
4141
| __riscv_32e | 1 | `E` extension is available. |
4242
| __riscv_vector | 1 | Implies that any of the vector extensions (`v` or `zve*`) is available |
43+
| __riscv_v_min_vlen | <N> (see [__riscv_v_min_vlen](#__riscv_v_min_vlen)) | The `V` extension or one of the `Zve*` extensions is available. |
44+
| __riscv_v_elen | <N> (see [__riscv_v_elen](#__riscv_v_elen)) | The `V` extension or one of the `Zve*` extensions is available. |
45+
| __riscv_v_elen_fp | <N> (see [__riscv_v_elen_fp](#__riscv_v_elen_fp)) | The `V` extension or one of the `Zve*` extensions is available. |
46+
47+
### __riscv_v_min_vlen
48+
49+
The `__riscv_v_min_vlen` macro expands to the minimal VLEN, in bits, mandated
50+
by the available vector extension, if any.
51+
52+
The value of `__riscv_v_min_vlen` is defined by the following rules:
53+
- 128, if the `V` extension is present;
54+
- 32, if one of the `Zve32{x,f}` extensions is present;
55+
- 64, if one of the `Zve64{x,f,d}` extensions is present;
56+
- `N`, if one of the `Zvl<N>b` extensions, `N` in `{32,64,128,256,512,1024}`,
57+
is present.
58+
59+
If multiple rules apply, the maximum value is taken.
60+
If none of the rules apply, `__riscv_v_min_vlen` is undefined.
61+
62+
Examples:
63+
64+
- `__riscv_v_min_vlen` is 128 for `rv64gcv`
65+
- `__riscv_v_min_vlen` is 512 for `rv32gcv_zvl512b`
66+
- `__riscv_v_min_vlen` is 256 for `rv32gcv_zvl32b_zvl256b`
67+
- `__riscv_v_min_vlen` is 128 for `rv64gcv_zvl32b`
68+
69+
### __riscv_v_elen
70+
71+
The `__riscv_v_elen` macro expands to the supported element length, in bits,
72+
of any non-floating-point vector operand of any vector instruction in the
73+
available vector extension, if any. (Stricter upper bounds may apply to
74+
particular operands of particular instructions.)
75+
76+
77+
The value of `__riscv_v_elen` is defined by the following rules:
78+
- 64, if the `V` extension or one of the `Zve64{x,f,d}` extensions is present; and
79+
- 32, if one of the `Zve32{x,f}` extensions is present.
80+
If multiple rules apply, the maximum value is taken.
81+
If none of the rules apply, `__riscv_v_elen` is undefined.
82+
83+
### __riscv_v_elen_fp
84+
85+
The `__riscv_v_elen_fp` macro expands to the supported element length, in bits,
86+
of any floating-point vector operand of any vector instruction in the available
87+
vector extension, if any. (Stricter upper bounds may apply to particular
88+
operands of particular instructions.)
89+
90+
The value of `__riscv_v_elen_fp` is defined by the following rules:
91+
- 64, if one of the `V` or `Zve64d` extensions is present;
92+
- 32, if one of the `Zve{32,64}f` extensions is present; and
93+
- 0, if one of the `Zve{32,64}x` extensions is present.
94+
If multiple rules apply, the maximum value is taken.
95+
If none of the rules apply, `__riscv_v_elen_fp` is undefined.
96+
4397

4498
### Architecture Extension Test Macro
4599

0 commit comments

Comments
 (0)