Browse Source

Use standard C++ initializers for fli_* constant tables

C99 array designators ([index] = value) are not valid C++ and trigger
-Wc99-designator under clang. C++20 designated initializers only cover
named members, not array indices, so use sequential static constexpr
tables and keep rs1 encodings in comments.

Signed-off-by: Jerry Zhang Jian <jerry.zhangjian@sifive.com>
pull/2362/head
Jerry Zhang Jian 2 days ago
parent
commit
0335d5480a
  1. 67
      riscv/insns/fli_d.h
  2. 67
      riscv/insns/fli_h.h
  3. 68
      riscv/insns/fli_q.h
  4. 67
      riscv/insns/fli_s.h

67
riscv/insns/fli_d.h

@ -2,39 +2,40 @@ require_extension('D');
require_extension(EXT_ZFA);
require_fp;
{
const uint64_t bits[32] = {
[0b00000] = 0xbff0000000000000ull, /* -1.0 */
[0b00001] = 0x0010000000000000ull, /* minimum positive normal */
[0b00010] = 0x3ef0000000000000ull, /* 1.0 * 2^-16 */
[0b00011] = 0x3f00000000000000ull, /* 1.0 * 2^-15 */
[0b00100] = 0x3f70000000000000ull, /* 1.0 * 2^-8 */
[0b00101] = 0x3f80000000000000ull, /* 1.0 * 2^-7 */
[0b00110] = 0x3fb0000000000000ull, /* 1.0 * 2^-4 */
[0b00111] = 0x3fc0000000000000ull, /* 1.0 * 2^-3 */
[0b01000] = 0x3fd0000000000000ull, /* 0.25 */
[0b01001] = 0x3fd4000000000000ull, /* 0.3125 */
[0b01010] = 0x3fd8000000000000ull, /* 0.375 */
[0b01011] = 0x3fdc000000000000ull, /* 0.4375 */
[0b01100] = 0x3fe0000000000000ull, /* 0.5 */
[0b01101] = 0x3fe4000000000000ull, /* 0.625 */
[0b01110] = 0x3fe8000000000000ull, /* 0.75 */
[0b01111] = 0x3fec000000000000ull, /* 0.875 */
[0b10000] = 0x3ff0000000000000ull, /* 1.0 */
[0b10001] = 0x3ff4000000000000ull, /* 1.25 */
[0b10010] = 0x3ff8000000000000ull, /* 1.5 */
[0b10011] = 0x3ffc000000000000ull, /* 1.75 */
[0b10100] = 0x4000000000000000ull, /* 2.0 */
[0b10101] = 0x4004000000000000ull, /* 2.5 */
[0b10110] = 0x4008000000000000ull, /* 3 */
[0b10111] = 0x4010000000000000ull, /* 4 */
[0b11000] = 0x4020000000000000ull, /* 8 */
[0b11001] = 0x4030000000000000ull, /* 16 */
[0b11010] = 0x4060000000000000ull, /* 2^7 */
[0b11011] = 0x4070000000000000ull, /* 2^8 */
[0b11100] = 0x40e0000000000000ull, /* 2^15 */
[0b11101] = 0x40f0000000000000ull, /* 2^16 */
[0b11110] = 0x7ff0000000000000ull, /* +inf */
[0b11111] = defaultNaNF64UI
/* Indexed by rs1; entries correspond to rs1 encodings 0b00000..0b11111. */
static constexpr uint64_t bits[32] = {
0xbff0000000000000ull, /* 0b00000: -1.0 */
0x0010000000000000ull, /* 0b00001: minimum positive normal */
0x3ef0000000000000ull, /* 0b00010: 1.0 * 2^-16 */
0x3f00000000000000ull, /* 0b00011: 1.0 * 2^-15 */
0x3f70000000000000ull, /* 0b00100: 1.0 * 2^-8 */
0x3f80000000000000ull, /* 0b00101: 1.0 * 2^-7 */
0x3fb0000000000000ull, /* 0b00110: 1.0 * 2^-4 */
0x3fc0000000000000ull, /* 0b00111: 1.0 * 2^-3 */
0x3fd0000000000000ull, /* 0b01000: 0.25 */
0x3fd4000000000000ull, /* 0b01001: 0.3125 */
0x3fd8000000000000ull, /* 0b01010: 0.375 */
0x3fdc000000000000ull, /* 0b01011: 0.4375 */
0x3fe0000000000000ull, /* 0b01100: 0.5 */
0x3fe4000000000000ull, /* 0b01101: 0.625 */
0x3fe8000000000000ull, /* 0b01110: 0.75 */
0x3fec000000000000ull, /* 0b01111: 0.875 */
0x3ff0000000000000ull, /* 0b10000: 1.0 */
0x3ff4000000000000ull, /* 0b10001: 1.25 */
0x3ff8000000000000ull, /* 0b10010: 1.5 */
0x3ffc000000000000ull, /* 0b10011: 1.75 */
0x4000000000000000ull, /* 0b10100: 2.0 */
0x4004000000000000ull, /* 0b10101: 2.5 */
0x4008000000000000ull, /* 0b10110: 3 */
0x4010000000000000ull, /* 0b10111: 4 */
0x4020000000000000ull, /* 0b11000: 8 */
0x4030000000000000ull, /* 0b11001: 16 */
0x4060000000000000ull, /* 0b11010: 2^7 */
0x4070000000000000ull, /* 0b11011: 2^8 */
0x40e0000000000000ull, /* 0b11100: 2^15 */
0x40f0000000000000ull, /* 0b11101: 2^16 */
0x7ff0000000000000ull, /* 0b11110: +inf */
defaultNaNF64UI /* 0b11111: canonical NaN */
};
WRITE_FRD_D(f64(bits[insn.rs1()]));
}

67
riscv/insns/fli_h.h

@ -2,39 +2,40 @@ require_either_extension(EXT_ZFH, EXT_ZVFH);
require_extension(EXT_ZFA);
require_fp;
{
static const uint16_t bits[32] = {
[0b00000] = 0xbc00, /* -1.0 */
[0b00001] = 0x0400, /* minimum positive normal */
[0b00010] = 0x0100, /* 1.0 * 2^-16 */
[0b00011] = 0x0200, /* 1.0 * 2^-15 */
[0b00100] = 0x1c00, /* 1.0 * 2^-8 */
[0b00101] = 0x2000, /* 1.0 * 2^-7 */
[0b00110] = 0x2c00, /* 1.0 * 2^-4 */
[0b00111] = 0x3000, /* 1.0 * 2^-3 */
[0b01000] = 0x3400, /* 0.25 */
[0b01001] = 0x3500, /* 0.3125 */
[0b01010] = 0x3600, /* 0.375 */
[0b01011] = 0x3700, /* 0.4375 */
[0b01100] = 0x3800, /* 0.5 */
[0b01101] = 0x3900, /* 0.625 */
[0b01110] = 0x3a00, /* 0.75 */
[0b01111] = 0x3b00, /* 0.875 */
[0b10000] = 0x3c00, /* 1.0 */
[0b10001] = 0x3d00, /* 1.25 */
[0b10010] = 0x3e00, /* 1.5 */
[0b10011] = 0x3f00, /* 1.75 */
[0b10100] = 0x4000, /* 2.0 */
[0b10101] = 0x4100, /* 2.5 */
[0b10110] = 0x4200, /* 3 */
[0b10111] = 0x4400, /* 4 */
[0b11000] = 0x4800, /* 8 */
[0b11001] = 0x4c00, /* 16 */
[0b11010] = 0x5800, /* 2^7 */
[0b11011] = 0x5c00, /* 2^8 */
[0b11100] = 0x7800, /* 2^15 */
[0b11101] = 0x7c00, /* +inf (2^16 is not expressible) */
[0b11110] = 0x7c00, /* +inf */
[0b11111] = defaultNaNF16UI
/* Indexed by rs1; entries correspond to rs1 encodings 0b00000..0b11111. */
static constexpr uint16_t bits[32] = {
0xbc00, /* 0b00000: -1.0 */
0x0400, /* 0b00001: minimum positive normal */
0x0100, /* 0b00010: 1.0 * 2^-16 */
0x0200, /* 0b00011: 1.0 * 2^-15 */
0x1c00, /* 0b00100: 1.0 * 2^-8 */
0x2000, /* 0b00101: 1.0 * 2^-7 */
0x2c00, /* 0b00110: 1.0 * 2^-4 */
0x3000, /* 0b00111: 1.0 * 2^-3 */
0x3400, /* 0b01000: 0.25 */
0x3500, /* 0b01001: 0.3125 */
0x3600, /* 0b01010: 0.375 */
0x3700, /* 0b01011: 0.4375 */
0x3800, /* 0b01100: 0.5 */
0x3900, /* 0b01101: 0.625 */
0x3a00, /* 0b01110: 0.75 */
0x3b00, /* 0b01111: 0.875 */
0x3c00, /* 0b10000: 1.0 */
0x3d00, /* 0b10001: 1.25 */
0x3e00, /* 0b10010: 1.5 */
0x3f00, /* 0b10011: 1.75 */
0x4000, /* 0b10100: 2.0 */
0x4100, /* 0b10101: 2.5 */
0x4200, /* 0b10110: 3 */
0x4400, /* 0b10111: 4 */
0x4800, /* 0b11000: 8 */
0x4c00, /* 0b11001: 16 */
0x5800, /* 0b11010: 2^7 */
0x5c00, /* 0b11011: 2^8 */
0x7800, /* 0b11100: 2^15 */
0x7c00, /* 0b11101: +inf (2^16 is not expressible) */
0x7c00, /* 0b11110: +inf */
defaultNaNF16UI /* 0b11111: canonical NaN */
};
WRITE_FRD_H(f16(bits[insn.rs1()]));
}

68
riscv/insns/fli_q.h

@ -2,39 +2,41 @@ require_extension('Q');
require_extension(EXT_ZFA);
require_fp;
{
const uint64_t bits[32] = {
[0b00000] = 0xBFFF000000000000ull, /* -1.0 */
[0b00001] = 0x0001000000000000ull, /* minimum positive normal */
[0b00010] = 0x3FEF000000000000ull, /* 1.0 * 2^-16 */
[0b00011] = 0x3FF0000000000000ull, /* 1.0 * 2^-15 */
[0b00100] = 0x3FF7000000000000ull, /* 1.0 * 2^-8 */
[0b00101] = 0x3FF8000000000000ull, /* 1.0 * 2^-7 */
[0b00110] = 0x3FFB000000000000ull, /* 1.0 * 2^-4 */
[0b00111] = 0x3FFC000000000000ull, /* 1.0 * 2^-3 */
[0b01000] = 0x3FFD000000000000ull, /* 0.25 */
[0b01001] = 0x3FFD400000000000ull, /* 0.3125 */
[0b01010] = 0x3FFD800000000000ull, /* 0.375 */
[0b01011] = 0x3FFDC00000000000ull, /* 0.4375 */
[0b01100] = 0x3FFE000000000000ull, /* 0.5 */
[0b01101] = 0x3FFE400000000000ull, /* 0.625 */
[0b01110] = 0x3FFE800000000000ull, /* 0.75 */
[0b01111] = 0x3FFEC00000000000ull, /* 0.875 */
[0b10000] = 0x3FFF000000000000ull, /* 1.0 */
[0b10001] = 0x3FFF400000000000ull, /* 1.25 */
[0b10010] = 0x3FFF800000000000ull, /* 1.5 */
[0b10011] = 0x3FFFC00000000000ull, /* 1.75 */
[0b10100] = 0x4000000000000000ull, /* 2.0 */
[0b10101] = 0x4000400000000000ull, /* 2.5 */
[0b10110] = 0x4000800000000000ull, /* 3 */
[0b10111] = 0x4001000000000000ull, /* 4 */
[0b11000] = 0x4002000000000000ull, /* 8 */
[0b11001] = 0x4003000000000000ull, /* 16 */
[0b11010] = 0x4006000000000000ull, /* 2^7 */
[0b11011] = 0x4007000000000000ull, /* 2^8 */
[0b11100] = 0x400E000000000000ull, /* 2^15 */
[0b11101] = 0x400F000000000000ull, /* 2^16 */
[0b11110] = 0x7FFF000000000000ull, /* +inf */
[0b11111] = defaultNaNF128UI64
/* Indexed by rs1; high 64 bits of f128 for rs1 encodings 0b00000..0b11111.
Low 64 bits are always zero for these constants. */
static constexpr uint64_t bits[32] = {
0xBFFF000000000000ull, /* 0b00000: -1.0 */
0x0001000000000000ull, /* 0b00001: minimum positive normal */
0x3FEF000000000000ull, /* 0b00010: 1.0 * 2^-16 */
0x3FF0000000000000ull, /* 0b00011: 1.0 * 2^-15 */
0x3FF7000000000000ull, /* 0b00100: 1.0 * 2^-8 */
0x3FF8000000000000ull, /* 0b00101: 1.0 * 2^-7 */
0x3FFB000000000000ull, /* 0b00110: 1.0 * 2^-4 */
0x3FFC000000000000ull, /* 0b00111: 1.0 * 2^-3 */
0x3FFD000000000000ull, /* 0b01000: 0.25 */
0x3FFD400000000000ull, /* 0b01001: 0.3125 */
0x3FFD800000000000ull, /* 0b01010: 0.375 */
0x3FFDC00000000000ull, /* 0b01011: 0.4375 */
0x3FFE000000000000ull, /* 0b01100: 0.5 */
0x3FFE400000000000ull, /* 0b01101: 0.625 */
0x3FFE800000000000ull, /* 0b01110: 0.75 */
0x3FFEC00000000000ull, /* 0b01111: 0.875 */
0x3FFF000000000000ull, /* 0b10000: 1.0 */
0x3FFF400000000000ull, /* 0b10001: 1.25 */
0x3FFF800000000000ull, /* 0b10010: 1.5 */
0x3FFFC00000000000ull, /* 0b10011: 1.75 */
0x4000000000000000ull, /* 0b10100: 2.0 */
0x4000400000000000ull, /* 0b10101: 2.5 */
0x4000800000000000ull, /* 0b10110: 3 */
0x4001000000000000ull, /* 0b10111: 4 */
0x4002000000000000ull, /* 0b11000: 8 */
0x4003000000000000ull, /* 0b11001: 16 */
0x4006000000000000ull, /* 0b11010: 2^7 */
0x4007000000000000ull, /* 0b11011: 2^8 */
0x400E000000000000ull, /* 0b11100: 2^15 */
0x400F000000000000ull, /* 0b11101: 2^16 */
0x7FFF000000000000ull, /* 0b11110: +inf */
defaultNaNF128UI64 /* 0b11111: canonical NaN */
};
static_assert(defaultNaNF128UI0 == 0, "LSBs of quad-precision NaN must be zero");

67
riscv/insns/fli_s.h

@ -2,39 +2,40 @@ require_extension('F');
require_extension(EXT_ZFA);
require_fp;
{
const uint32_t bits[32] = {
[0b00000] = 0xbf800000, /* -1.0 */
[0b00001] = 0x00800000, /* minimum positive normal */
[0b00010] = 0x37800000, /* 1.0 * 2^-16 */
[0b00011] = 0x38000000, /* 1.0 * 2^-15 */
[0b00100] = 0x3b800000, /* 1.0 * 2^-8 */
[0b00101] = 0x3c000000, /* 1.0 * 2^-7 */
[0b00110] = 0x3d800000, /* 1.0 * 2^-4 */
[0b00111] = 0x3e000000, /* 1.0 * 2^-3 */
[0b01000] = 0x3e800000, /* 0.25 */
[0b01001] = 0x3ea00000, /* 0.3125 */
[0b01010] = 0x3ec00000, /* 0.375 */
[0b01011] = 0x3ee00000, /* 0.4375 */
[0b01100] = 0x3f000000, /* 0.5 */
[0b01101] = 0x3f200000, /* 0.625 */
[0b01110] = 0x3f400000, /* 0.75 */
[0b01111] = 0x3f600000, /* 0.875 */
[0b10000] = 0x3f800000, /* 1.0 */
[0b10001] = 0x3fa00000, /* 1.25 */
[0b10010] = 0x3fc00000, /* 1.5 */
[0b10011] = 0x3fe00000, /* 1.75 */
[0b10100] = 0x40000000, /* 2.0 */
[0b10101] = 0x40200000, /* 2.5 */
[0b10110] = 0x40400000, /* 3 */
[0b10111] = 0x40800000, /* 4 */
[0b11000] = 0x41000000, /* 8 */
[0b11001] = 0x41800000, /* 16 */
[0b11010] = 0x43000000, /* 2^7 */
[0b11011] = 0x43800000, /* 2^8 */
[0b11100] = 0x47000000, /* 2^15 */
[0b11101] = 0x47800000, /* 2^16 */
[0b11110] = 0x7f800000, /* +inf */
[0b11111] = defaultNaNF32UI
/* Indexed by rs1; entries correspond to rs1 encodings 0b00000..0b11111. */
static constexpr uint32_t bits[32] = {
0xbf800000, /* 0b00000: -1.0 */
0x00800000, /* 0b00001: minimum positive normal */
0x37800000, /* 0b00010: 1.0 * 2^-16 */
0x38000000, /* 0b00011: 1.0 * 2^-15 */
0x3b800000, /* 0b00100: 1.0 * 2^-8 */
0x3c000000, /* 0b00101: 1.0 * 2^-7 */
0x3d800000, /* 0b00110: 1.0 * 2^-4 */
0x3e000000, /* 0b00111: 1.0 * 2^-3 */
0x3e800000, /* 0b01000: 0.25 */
0x3ea00000, /* 0b01001: 0.3125 */
0x3ec00000, /* 0b01010: 0.375 */
0x3ee00000, /* 0b01011: 0.4375 */
0x3f000000, /* 0b01100: 0.5 */
0x3f200000, /* 0b01101: 0.625 */
0x3f400000, /* 0b01110: 0.75 */
0x3f600000, /* 0b01111: 0.875 */
0x3f800000, /* 0b10000: 1.0 */
0x3fa00000, /* 0b10001: 1.25 */
0x3fc00000, /* 0b10010: 1.5 */
0x3fe00000, /* 0b10011: 1.75 */
0x40000000, /* 0b10100: 2.0 */
0x40200000, /* 0b10101: 2.5 */
0x40400000, /* 0b10110: 3 */
0x40800000, /* 0b10111: 4 */
0x41000000, /* 0b11000: 8 */
0x41800000, /* 0b11001: 16 */
0x43000000, /* 0b11010: 2^7 */
0x43800000, /* 0b11011: 2^8 */
0x47000000, /* 0b11100: 2^15 */
0x47800000, /* 0b11101: 2^16 */
0x7f800000, /* 0b11110: +inf */
defaultNaNF32UI /* 0b11111: canonical NaN */
};
WRITE_FRD_F(f32(bits[insn.rs1()]));
}

Loading…
Cancel
Save