Skip to content

Commit 4d33211

Browse files
committed
[Zvbc32e] enabling 32-bit vclmul/vclmulh
1 parent 7dce838 commit 4d33211

File tree

9 files changed

+46
-15
lines changed

9 files changed

+46
-15
lines changed

disasm/disasm.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2157,7 +2157,8 @@ void disassembler_t::add_instructions(const isa_parser_t* isa)
21572157
#undef DISASM_VECTOR_VV_VX_VIU_ZIMM6
21582158
}
21592159

2160-
if (isa->extension_enabled(EXT_ZVBC)) {
2160+
if (isa->extension_enabled(EXT_ZVBC) ||
2161+
isa->extension_enabled(EXT_ZVBC32E)) {
21612162
#define DISASM_VECTOR_VV_VX(name) \
21622163
DEFINE_VECTOR_VV(name##_vv); \
21632164
DEFINE_VECTOR_VX(name##_vx)

disasm/isa_parser.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ isa_parser_t::isa_parser_t(const char* str, const char *priv)
253253
extension_table[EXT_ZVBB] = true;
254254
} else if (ext_str == "zvbc") {
255255
extension_table[EXT_ZVBC] = true;
256+
} else if (ext_str == "zvbc32e") {
257+
extension_table[EXT_ZVBC32E] = true;
256258
} else if (ext_str == "zvfbfmin") {
257259
extension_table[EXT_ZVFBFMIN] = true;
258260
} else if (ext_str == "zvfbfwma") {

riscv/decode_macros.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ static inline bool is_aligned(const unsigned val, const unsigned pos)
163163
#define require_rv32 require(xlen == 32)
164164
#define require_extension(s) require(p->extension_enabled(s))
165165
#define require_either_extension(A,B) require(p->extension_enabled(A) || p->extension_enabled(B));
166+
#define require_either_extension_condition(A,cA, B, cB) require(p->extension_enabled(A) && (cA) || p->extension_enabled(B) && (cB));
166167
#define require_impl(s) require(p->supports_impl(s))
167168
#define require_fs require(STATE.sstatus->enabled(SSTATUS_FS))
168169
#define require_fp STATE.fflags->verify_permissions(insn, false)

riscv/insns/vclmul_vv.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
#include "zvk_ext_macros.h"
44

5-
require_zvbc;
6-
require(P.VU.vsew == 64);
5+
require_any_zvbc;
6+
require_either_extension_condition(EXT_ZVBC, P.VU.vsew == 64, EXT_ZVBC32E, P.VU.vsew == 32);
77

88
VI_VV_ULOOP
99
({
10-
// Perform a carryless multiplication 64bx64b on each 64b element,
11-
// return the low 64b of the 128b product.
10+
// Perform a carryless multiplication SEW-bit x SEW-bit on each SEW-bit element,
11+
// return the low SEW bits of the (2.SEW)-bit product.
1212
// <https://en.wikipedia.org/wiki/Carry-less_product>
1313
vd = 0;
1414
for (std::size_t bit_idx = 0; bit_idx < sew; ++bit_idx) {

riscv/insns/vclmul_vx.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
#include "zvk_ext_macros.h"
44

5-
require_zvbc;
6-
require(P.VU.vsew == 64);
5+
require_any_zvbc;
6+
require_either_extension_condition(EXT_ZVBC, P.VU.vsew == 64, EXT_ZVBC32E, P.VU.vsew == 32);
77

88
VI_VX_ULOOP
99
({
10-
// Perform a carryless multiplication 64bx64b on each 64b element,
11-
// return the low 64b of the 128b product.
10+
// Perform a carryless multiplication SEW-bit x SEW-bit on each SEW-bit element,
11+
// return the low SEW bits of the (2.SEW)-bit product.
1212
// <https://en.wikipedia.org/wiki/Carry-less_product>
1313
vd = 0;
1414
for (std::size_t bit_idx = 0; bit_idx < sew; ++bit_idx) {

riscv/insns/vclmulh_vv.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
#include "zvk_ext_macros.h"
44

5-
require_zvbc;
6-
require(P.VU.vsew == 64);
5+
require_any_zvbc;
6+
require_either_extension_condition(EXT_ZVBC, P.VU.vsew == 64, EXT_ZVBC32E, P.VU.vsew == 32);
77

88
VI_VV_ULOOP
99
({

riscv/insns/vclmulh_vx.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
#include "zvk_ext_macros.h"
44

5-
require_zvbc;
6-
require(P.VU.vsew == 64);
5+
require_any_zvbc;
6+
require_either_extension_condition(EXT_ZVBC, P.VU.vsew == 64, EXT_ZVBC32E, P.VU.vsew == 32);
77

88
VI_VX_ULOOP
99
({
10-
// Perform a carryless multiplication 64bx64b on each 64b element,
11-
// return the high 64b of the 128b product.
10+
// Perform a carryless multiplication SEW-bit x SEW-bit on each SEW-bit element,
11+
// return the high SEW bits of the (2.SEW)-bit product.
1212
// <https://en.wikipedia.org/wiki/Carry-less_product>
1313
vd = 0;
1414
for (std::size_t bit_idx = 1; bit_idx < sew; ++bit_idx) {

riscv/isa_parser.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@ typedef enum {
5757
EXT_ZILSD,
5858
EXT_ZVBB,
5959
EXT_ZVBC,
60+
EXT_ZVBC32E,
6061
EXT_ZVFBFMIN,
6162
EXT_ZVFBFWMA,
6263
EXT_ZVKG,
64+
EXT_ZVKGS,
6365
EXT_ZVKNED,
6466
EXT_ZVKNHA,
6567
EXT_ZVKNHB,

riscv/zvk_ext_macros.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,23 @@
2929
require_extension(EXT_ZVBC); \
3030
} while (0)
3131

32+
// Ensures that the ZVBC32e extension (vector carryless multiplication
33+
// with 32-bit elements) is present, and the vector unit is enabled
34+
// and in a valid state.
35+
#define require_zvbc32e \
36+
do { \
37+
require_vector(true); \
38+
require_extension(EXT_ZVBC32E); \
39+
} while (0)
40+
41+
// Ensures that any ZVBC extensions (vector carryless multiplication)
42+
// is present, and the vector unit is enabled and in a valid state.
43+
#define require_any_zvbc \
44+
do { \
45+
require_vector(true); \
46+
require_either_extension(EXT_ZVBC, EXT_ZVBC32E); \
47+
} while (0)
48+
3249
// Ensures that the ZVKG extension (vector Galois Field Multiplication)
3350
// is present, and the vector unit is enabled and in a valid state.
3451
#define require_zvkg \
@@ -37,6 +54,14 @@
3754
require_extension(EXT_ZVKG); \
3855
} while (0)
3956

57+
// Ensures that the ZVKGS extension (vector Galois Field Multiplication
58+
// with vector-scalar variant) is present, and the vector unit is
59+
// enabled and in a valid state.
60+
#define require_zvkgs \
61+
do { \
62+
require_vector(true); \
63+
require_extension(EXT_ZVKGS); \
64+
} while (0)
4065
// Ensures that a ZVK extension supporting SHA-256 is present.
4166
// For SHA-256, this support is present in either Zvknha or Zvknhb.
4267
// Also ensures that the vector unit is enabled and in a valid state.

0 commit comments

Comments
 (0)