You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Introduce `__riscv_min_vlen`, `__riscv_v_elen` and `__riscv_v_elen_fp`
macro, for let programer easier to get vector related information, like:
- What's the minimal VLEN value is guaranteed current architecture
extension?
- What's the maximal available ELEN is guaranteed current
architecture extension?
- What's the maximal available ELEN for floating-point operation is
guaranteed current architecture extension?
It's possible to get the information by testing serveral architecture extension
test macro, but the life can be simpler if toolchain can help, for
example, if you want to check the minimal VLEN value via those macro:
```c
#if defined(__riscv_zvl512b)
#define __riscv_min_vlen 512
#elif defined(__riscv_zvl256b)
#define __riscv_min_vlen 256
#elif defined(__riscv_zvl128b) || defined(__riscv_v)
#define __riscv_min_vlen 128
#elif defined(__riscv_zvl64b) || defined(__riscv_zve64x) || \
defined(__riscv_zve64f) || defined(__riscv_zve64d)
#define __riscv_min_vlen 64
#elif defined(__riscv_zvl32b) || defined(__riscv_zve32x) || \
defined(__riscv_zve32f)
#define __riscv_min_vlen 32
#endif
```
And it's not scalable solution since in theory we can have up to zvl32768b.
|__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. |
41
41
|__riscv_32e | 1 |`E` extension is available. |
42
42
|__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.
0 commit comments