Skip to content

Commit e242c05

Browse files
committed
RISC-V: Add intrinsics support for SiFive Xsfvcp extensions.
1 parent d3558fe commit e242c05

15 files changed

+1298
-22
lines changed

gcc/config/riscv/constraints.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,3 +295,13 @@
295295
"Shifting immediate for SIMD shufflei3."
296296
(and (match_code "const_int")
297297
(match_test "IN_RANGE (ival, -64, -1)")))
298+
299+
(define_constraint "B"
300+
"A 2-bit unsigned immediate for CSR access instructions."
301+
(and (match_code "const_int")
302+
(match_test "IN_RANGE (ival, 0, 3)")))
303+
304+
(define_constraint "O"
305+
"A 1-bit unsigned immediate for CSR access instructions."
306+
(and (match_code "const_int")
307+
(match_test "IN_RANGE (ival, 0, 1)")))

gcc/config/riscv/generic-vector-ooo.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,7 @@
141141
(eq_attr "type" "rdvlenb,rdvl")
142142
"vxu_ooo_issue,vxu_ooo_issue")
143143

144+
;; Vector sf_vcp.
145+
(define_insn_reservation "vec_sf_vcp" 2
146+
(eq_attr "type" "sf_vc,sf_vc_se")
147+
"vxu_ooo_issue")

gcc/config/riscv/genrvv-type-indexer.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ main (int argc, const char **argv)
290290
fprintf (fp, " /*UNSIGNED_EEW%d_LMUL1_INTERPRET*/ %s,\n", eew,
291291
inttype (eew, LMUL1_LOG2, /* unsigned_p */true).c_str ());
292292

293+
fprintf (fp, " /*X2*/ INVALID,\n");
294+
293295
for (unsigned lmul_log2_offset : {1, 2, 3, 4, 5, 6})
294296
{
295297
unsigned multiple_of_lmul = 1 << lmul_log2_offset;
@@ -411,6 +413,9 @@ main (int argc, const char **argv)
411413
fprintf (fp, " /*UNSIGNED_EEW%d_LMUL1_INTERPRET*/ INVALID,\n",
412414
eew);
413415

416+
fprintf (fp, " /*X2*/ %s,\n",
417+
inttype (sew * 2, lmul_log2 + 1, /*unsigned_p*/ true).c_str ());
418+
414419
for (unsigned lmul_log2_offset : {1, 2, 3, 4, 5, 6})
415420
{
416421
unsigned multiple_of_lmul = 1 << lmul_log2_offset;
@@ -485,6 +490,8 @@ main (int argc, const char **argv)
485490
for (unsigned eew : EEW_SIZE_LIST)
486491
fprintf (fp, " /*UNSIGNED_EEW%d_LMUL1_INTERPRET*/ INVALID,\n", eew);
487492

493+
fprintf (fp, " /*X2*/ INVALID,\n");
494+
488495
for (unsigned lmul_log2_offset : {1, 2, 3, 4, 5, 6})
489496
{
490497
unsigned multiple_of_lmul = 1 << lmul_log2_offset;
@@ -571,6 +578,8 @@ main (int argc, const char **argv)
571578
fprintf (fp, " /*UNSIGNED_EEW%d_LMUL1_INTERPRET*/ INVALID,\n",
572579
eew);
573580

581+
fprintf (fp, " /*X2*/ INVALID,\n");
582+
574583
for (unsigned lmul_log2_offset : {1, 2, 3, 4, 5, 6})
575584
{
576585
unsigned multiple_of_lmul = 1 << lmul_log2_offset;

gcc/config/riscv/riscv-vector-builtins-shapes.cc

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,6 +1343,51 @@ struct sf_vfnrclip_def : public build_base
13431343
}
13441344
};
13451345

1346+
/* sf_vcix_se_def class. */
1347+
struct sf_vcix_se_def : public build_base
1348+
{
1349+
const char *get_name (function_builder &b, const function_instance &instance,
1350+
bool overloaded_p) const override
1351+
{
1352+
/* Return nullptr if it can not be overloaded. */
1353+
if (overloaded_p)
1354+
return nullptr;
1355+
1356+
b.append_base_name (instance.base_name);
1357+
1358+
/* vop --> vop<op>_se_<type>. */
1359+
if (!overloaded_p)
1360+
{
1361+
b.append_name (operand_suffixes[instance.op_info->op]);
1362+
b.append_name ("_se");
1363+
b.append_name (type_suffixes[instance.type.index].vector);
1364+
}
1365+
return b.finish_name ();
1366+
}
1367+
};
1368+
1369+
/* sf_vcix_def class. */
1370+
struct sf_vcix_def : public build_base
1371+
{
1372+
const char *get_name (function_builder &b, const function_instance &instance,
1373+
bool overloaded_p) const override
1374+
{
1375+
/* Return nullptr if it can not be overloaded. */
1376+
if (overloaded_p)
1377+
return nullptr;
1378+
1379+
b.append_base_name (instance.base_name);
1380+
1381+
/* vop --> vop_<type>. */
1382+
if (!overloaded_p)
1383+
{
1384+
b.append_name (operand_suffixes[instance.op_info->op]);
1385+
b.append_name (type_suffixes[instance.type.index].vector);
1386+
}
1387+
return b.finish_name ();
1388+
}
1389+
};
1390+
13461391
SHAPE(vsetvl, vsetvl)
13471392
SHAPE(vsetvl, vsetvlmax)
13481393
SHAPE(loadstore, loadstore)
@@ -1379,4 +1424,6 @@ SHAPE(crypto_vi, crypto_vi)
13791424
SHAPE(crypto_vv_no_op_type, crypto_vv_no_op_type)
13801425
SHAPE (sf_vqmacc, sf_vqmacc)
13811426
SHAPE (sf_vfnrclip, sf_vfnrclip)
1427+
SHAPE(sf_vcix_se, sf_vcix_se)
1428+
SHAPE(sf_vcix, sf_vcix)
13821429
} // end namespace riscv_vector

gcc/config/riscv/riscv-vector-builtins-shapes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ extern const function_shape *const crypto_vv_no_op_type;
6262
/* Sifive vendor extension. */
6363
extern const function_shape *const sf_vqmacc;
6464
extern const function_shape *const sf_vfnrclip;
65+
extern const function_shape *const sf_vcix_se;
66+
extern const function_shape *const sf_vcix;
6567
}
6668

6769
} // end namespace riscv_vector

gcc/config/riscv/riscv-vector-builtins-types.def

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,18 @@ along with GCC; see the file COPYING3. If not see
363363
#define DEF_RVV_QMACC_OPS(TYPE, REQUIRE)
364364
#endif
365365

366+
/* Use "DEF_RVV_X2_U_OPS" macro include unsigned integer which will
367+
be iterated and registered as intrinsic functions. */
368+
#ifndef DEF_RVV_X2_U_OPS
369+
#define DEF_RVV_X2_U_OPS(TYPE, REQUIRE)
370+
#endif
371+
372+
/* Use "DEF_RVV_X2_WU_OPS" macro include widen unsigned integer which will
373+
be iterated and registered as intrinsic functions. */
374+
#ifndef DEF_RVV_X2_WU_OPS
375+
#define DEF_RVV_X2_WU_OPS(TYPE, REQUIRE)
376+
#endif
377+
366378
DEF_RVV_I_OPS (vint8mf8_t, RVV_REQUIRE_MIN_VLEN_64)
367379
DEF_RVV_I_OPS (vint8mf4_t, 0)
368380
DEF_RVV_I_OPS (vint8mf2_t, 0)
@@ -1451,6 +1463,32 @@ DEF_RVV_QMACC_OPS (vint32m2_t, 0)
14511463
DEF_RVV_QMACC_OPS (vint32m4_t, 0)
14521464
DEF_RVV_QMACC_OPS (vint32m8_t, 0)
14531465

1466+
DEF_RVV_X2_U_OPS (vuint8mf8_t, RVV_REQUIRE_MIN_VLEN_64)
1467+
DEF_RVV_X2_U_OPS (vuint8mf4_t, 0)
1468+
DEF_RVV_X2_U_OPS (vuint8mf2_t, 0)
1469+
DEF_RVV_X2_U_OPS (vuint8m1_t, 0)
1470+
DEF_RVV_X2_U_OPS (vuint8m2_t, 0)
1471+
DEF_RVV_X2_U_OPS (vuint8m4_t, 0)
1472+
DEF_RVV_X2_U_OPS (vuint16mf4_t, RVV_REQUIRE_MIN_VLEN_64)
1473+
DEF_RVV_X2_U_OPS (vuint16mf2_t, 0)
1474+
DEF_RVV_X2_U_OPS (vuint16m1_t, 0)
1475+
DEF_RVV_X2_U_OPS (vuint16m2_t, 0)
1476+
DEF_RVV_X2_U_OPS (vuint16m4_t, 0)
1477+
DEF_RVV_X2_U_OPS (vuint32mf2_t, RVV_REQUIRE_MIN_VLEN_64)
1478+
DEF_RVV_X2_U_OPS (vuint32m1_t, 0)
1479+
DEF_RVV_X2_U_OPS (vuint32m2_t, 0)
1480+
DEF_RVV_X2_U_OPS (vuint32m4_t, 0)
1481+
1482+
DEF_RVV_X2_WU_OPS (vuint16mf4_t, RVV_REQUIRE_MIN_VLEN_64)
1483+
DEF_RVV_X2_WU_OPS (vuint16mf2_t, 0)
1484+
DEF_RVV_X2_WU_OPS (vuint16m1_t, 0)
1485+
DEF_RVV_X2_WU_OPS (vuint16m2_t, 0)
1486+
DEF_RVV_X2_WU_OPS (vuint16m4_t, 0)
1487+
DEF_RVV_X2_WU_OPS (vuint32mf2_t, RVV_REQUIRE_MIN_VLEN_64)
1488+
DEF_RVV_X2_WU_OPS (vuint32m1_t, 0)
1489+
DEF_RVV_X2_WU_OPS (vuint32m2_t, 0)
1490+
DEF_RVV_X2_WU_OPS (vuint32m4_t, 0)
1491+
14541492
#undef DEF_RVV_I_OPS
14551493
#undef DEF_RVV_U_OPS
14561494
#undef DEF_RVV_F_OPS
@@ -1506,3 +1544,5 @@ DEF_RVV_QMACC_OPS (vint32m8_t, 0)
15061544
#undef DEF_RVV_CRYPTO_SEW64_OPS
15071545
#undef DEF_RVV_F32_OPS
15081546
#undef DEF_RVV_QMACC_OPS
1547+
#undef DEF_RVV_X2_U_OPS
1548+
#undef DEF_RVV_X2_WU_OPS

0 commit comments

Comments
 (0)