指令:
vfclass.v vd, vs2, vm # Vector-vector
解析:
cpp
if (vl > vlmax(e32, mf2)) vl = __riscv_vsetvl_e32mf2(vl);
vuint32mf2_t res;
for (size_t i = 0; i < vl; i++) {
uint32_t t = 0;
float32_t a = op1[i];
bool sub = is_subnormal(op1[i]); // false for ±0
if (a == -∞) t |= 1<<0; //负无穷 == 1 == 0x001
if (a<0 && !sub) t |= 1<<1; //负正规数 == 2 == 0x002; false for ±0.0
if (a<0 && sub) t |= 1<<2; //负非正规数(指数) == 4 == 0x004; false for ±0.0
if (a === -0.0) t |= 1<<3; //负零 == 8 == 0x008
if (a === +0.0) t |= 1<<4; //正零 == 16 == 0x010
if (a>0 && sub) t |= 1<<5; //正非正规数 == 32 == 0x020
if (a>0 && !sub) t |= 1<<6; //正正规数 == 64 == 0x040
if (a == +∞) t |= 1<<7; //正无穷 == 128 == 0x080
if (isSNaN(a)) t |= 1<<8; //信号 == 256 == 0x100
if (isQNaN(a)) t |= 1<<9; //静默 == 512 == 0x200
res[i] = t;
}
for (size_t i = vl; i < vlmax; i++) res[i] = anything();
return res;
对应表格
| 代码逻辑判断 (伪代码) | 分类名称 | 对应位 | 返回值 (十进制) | 返回值 (十六进制) |
|---|---|---|---|---|
a == -∞ |
负无穷 (Negative Infinity) | Bit 0 | 1 | 0x001 |
a < 0 && !sub (负数且非非正规数) |
负正规数 (Negative Normal) | Bit 1 | 2 | 0x002 |
a < 0 && sub (负数且为非正规数) |
负非正规数 (Negative Subnormal) | Bit 2 | 4 | 0x004 |
a === -0.0 |
负零 (Negative Zero) | Bit 3 | 8 | 0x008 |
a === +0.0 |
正零 (Positive Zero) | Bit 4 | 16 | 0x010 |
a > 0 && sub (正数且为非正规数) |
正非正规数 (Positive Subnormal) | Bit 5 | 32 | 0x020 |
a > 0 && !sub (正数且非非正规数) |
正正规数 (Positive Normal) | Bit 6 | 64 | 0x040 |
a == +∞ |
正无穷 (Positive Infinity) | Bit 7 | 128 | 0x080 |
isSNaN(a) |
信号型 NaN (Signaling NaN) | Bit 8 | 256 | 0x100 |
isQNaN(a) |
静默型 NaN (Quiet NaN) | Bit 9 | 512 | 0x200 |
举例:
cpp
const float32_t vec1[DATALEN] = { 16.0, 16.50, -16.5000, -16.5001, +0.0, -0.0, -1e-38, 1e-38 };
结果:
cpp
res[8] = {64, 64, 2, 2, 16, 8, 4, 32}