Skip to content

Commit 8e239d8

Browse files
committed
RISC-V: Add intrinsics support for SiFive Xsfvcp extensions.
1 parent 5c5a2cb commit 8e239d8

16 files changed

+1257
-7
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 "Ou01"
300+
"A 1-bit unsigned immediate."
301+
(and (match_code "const_int")
302+
(match_test "IN_RANGE (ival, 0, 1)")))
303+
304+
(define_constraint "Ou02"
305+
"A 2-bit unsigned immediate."
306+
(and (match_code "const_int")
307+
(match_test "IN_RANGE (ival, 0, 3)")))

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
@@ -303,6 +303,8 @@ main (int argc, const char **argv)
303303
fprintf (fp, " /*UNSIGNED_EEW%d_LMUL1_INTERPRET*/ %s,\n", eew,
304304
inttype (eew, LMUL1_LOG2, /* unsigned_p */true).c_str ());
305305

306+
fprintf (fp, " /*X2*/ INVALID,\n");
307+
306308
for (unsigned lmul_log2_offset : {1, 2, 3, 4, 5, 6})
307309
{
308310
unsigned multiple_of_lmul = 1 << lmul_log2_offset;
@@ -426,6 +428,9 @@ main (int argc, const char **argv)
426428
fprintf (fp, " /*UNSIGNED_EEW%d_LMUL1_INTERPRET*/ INVALID,\n",
427429
eew);
428430

431+
fprintf (fp, " /*X2*/ %s,\n",
432+
inttype (sew * 2, lmul_log2 + 1, /*unsigned_p*/ true).c_str ());
433+
429434
for (unsigned lmul_log2_offset : {1, 2, 3, 4, 5, 6})
430435
{
431436
unsigned multiple_of_lmul = 1 << lmul_log2_offset;
@@ -501,6 +506,8 @@ main (int argc, const char **argv)
501506
for (unsigned eew : EEW_SIZE_LIST)
502507
fprintf (fp, " /*UNSIGNED_EEW%d_LMUL1_INTERPRET*/ INVALID,\n", eew);
503508

509+
fprintf (fp, " /*X2*/ INVALID,\n");
510+
504511
for (unsigned lmul_log2_offset : {1, 2, 3, 4, 5, 6})
505512
{
506513
unsigned multiple_of_lmul = 1 << lmul_log2_offset;
@@ -588,6 +595,8 @@ main (int argc, const char **argv)
588595
fprintf (fp, " /*UNSIGNED_EEW%d_LMUL1_INTERPRET*/ INVALID,\n",
589596
eew);
590597

598+
fprintf (fp, " /*X2*/ INVALID,\n");
599+
591600
for (unsigned lmul_log2_offset : {1, 2, 3, 4, 5, 6})
592601
{
593602
unsigned multiple_of_lmul = 1 << lmul_log2_offset;

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

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,6 +1343,52 @@ 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+
char *get_name (function_builder &b, const function_instance &instance,
1350+
bool overloaded_p) const override
1351+
{
1352+
/* Return nullptr if it is 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+
char *get_name (function_builder &b, const function_instance &instance,
1373+
bool overloaded_p) const override
1374+
{
1375+
/* Return nullptr if it is 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+
1391+
13461392
SHAPE(vsetvl, vsetvl)
13471393
SHAPE(vsetvl, vsetvlmax)
13481394
SHAPE(loadstore, loadstore)
@@ -1379,4 +1425,6 @@ SHAPE(crypto_vi, crypto_vi)
13791425
SHAPE(crypto_vv_no_op_type, crypto_vv_no_op_type)
13801426
SHAPE (sf_vqmacc, sf_vqmacc)
13811427
SHAPE (sf_vfnrclip, sf_vfnrclip)
1428+
SHAPE(sf_vcix_se, sf_vcix_se)
1429+
SHAPE(sf_vcix, sf_vcix)
13821430
} // 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
@@ -369,6 +369,18 @@ along with GCC; see the file COPYING3. If not see
369369
#define DEF_RVV_XFQF_OPS(TYPE, REQUIRE)
370370
#endif
371371

372+
/* Use "DEF_RVV_X2_U_OPS" macro include unsigned integer which will
373+
be iterated and registered as intrinsic functions. */
374+
#ifndef DEF_RVV_X2_U_OPS
375+
#define DEF_RVV_X2_U_OPS(TYPE, REQUIRE)
376+
#endif
377+
378+
/* Use "DEF_RVV_X2_WU_OPS" macro include widen unsigned integer which will
379+
be iterated and registered as intrinsic functions. */
380+
#ifndef DEF_RVV_X2_WU_OPS
381+
#define DEF_RVV_X2_WU_OPS(TYPE, REQUIRE)
382+
#endif
383+
372384
DEF_RVV_I_OPS (vint8mf8_t, RVV_REQUIRE_MIN_VLEN_64)
373385
DEF_RVV_I_OPS (vint8mf4_t, 0)
374386
DEF_RVV_I_OPS (vint8mf2_t, 0)
@@ -1463,6 +1475,32 @@ DEF_RVV_XFQF_OPS (vint8mf2_t, 0)
14631475
DEF_RVV_XFQF_OPS (vint8m1_t, 0)
14641476
DEF_RVV_XFQF_OPS (vint8m2_t, 0)
14651477

1478+
DEF_RVV_X2_U_OPS (vuint8mf8_t, RVV_REQUIRE_MIN_VLEN_64)
1479+
DEF_RVV_X2_U_OPS (vuint8mf4_t, 0)
1480+
DEF_RVV_X2_U_OPS (vuint8mf2_t, 0)
1481+
DEF_RVV_X2_U_OPS (vuint8m1_t, 0)
1482+
DEF_RVV_X2_U_OPS (vuint8m2_t, 0)
1483+
DEF_RVV_X2_U_OPS (vuint8m4_t, 0)
1484+
DEF_RVV_X2_U_OPS (vuint16mf4_t, RVV_REQUIRE_MIN_VLEN_64)
1485+
DEF_RVV_X2_U_OPS (vuint16mf2_t, 0)
1486+
DEF_RVV_X2_U_OPS (vuint16m1_t, 0)
1487+
DEF_RVV_X2_U_OPS (vuint16m2_t, 0)
1488+
DEF_RVV_X2_U_OPS (vuint16m4_t, 0)
1489+
DEF_RVV_X2_U_OPS (vuint32mf2_t, RVV_REQUIRE_MIN_VLEN_64)
1490+
DEF_RVV_X2_U_OPS (vuint32m1_t, 0)
1491+
DEF_RVV_X2_U_OPS (vuint32m2_t, 0)
1492+
DEF_RVV_X2_U_OPS (vuint32m4_t, 0)
1493+
1494+
DEF_RVV_X2_WU_OPS (vuint16mf4_t, RVV_REQUIRE_MIN_VLEN_64)
1495+
DEF_RVV_X2_WU_OPS (vuint16mf2_t, 0)
1496+
DEF_RVV_X2_WU_OPS (vuint16m1_t, 0)
1497+
DEF_RVV_X2_WU_OPS (vuint16m2_t, 0)
1498+
DEF_RVV_X2_WU_OPS (vuint16m4_t, 0)
1499+
DEF_RVV_X2_WU_OPS (vuint32mf2_t, RVV_REQUIRE_MIN_VLEN_64)
1500+
DEF_RVV_X2_WU_OPS (vuint32m1_t, 0)
1501+
DEF_RVV_X2_WU_OPS (vuint32m2_t, 0)
1502+
DEF_RVV_X2_WU_OPS (vuint32m4_t, 0)
1503+
14661504
#undef DEF_RVV_I_OPS
14671505
#undef DEF_RVV_U_OPS
14681506
#undef DEF_RVV_F_OPS
@@ -1519,3 +1557,5 @@ DEF_RVV_XFQF_OPS (vint8m2_t, 0)
15191557
#undef DEF_RVV_F32_OPS
15201558
#undef DEF_RVV_QMACC_OPS
15211559
#undef DEF_RVV_XFQF_OPS
1560+
#undef DEF_RVV_X2_U_OPS
1561+
#undef DEF_RVV_X2_WU_OPS

0 commit comments

Comments
 (0)