Skip to content

Commit 3508da0

Browse files
4vtomattopperc
authored andcommitted
Automerge: [RISCV][clang] Support Zvfbfa C intrinsics (#164094)
Co-authored-by: Craig Topper <[email protected]>
2 parents 97a82b8 + 04e8edc commit 3508da0

File tree

168 files changed

+69141
-20
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+69141
-20
lines changed

clang/include/clang/Basic/riscv_vector.td

Lines changed: 68 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,32 +1013,32 @@ let ManualCodegen = [{
10131013
}] in {
10141014
let HasFRMRoundModeOp = true in {
10151015
// 13.2. Vector Single-Width Floating-Point Add/Subtract Instructions
1016-
defm vfadd : RVVFloatingBinBuiltinSetRoundingMode;
1017-
defm vfsub : RVVFloatingBinBuiltinSetRoundingMode;
1018-
defm vfrsub : RVVFloatingBinVFBuiltinSetRoundingMode;
1016+
defm vfadd : RVVFloatingBinBuiltinSetRoundingMode<HasBF=1>;
1017+
defm vfsub : RVVFloatingBinBuiltinSetRoundingMode<HasBF=1>;
1018+
defm vfrsub : RVVFloatingBinVFBuiltinSetRoundingMode<HasBF=1>;
10191019

10201020
// 13.3. Vector Widening Floating-Point Add/Subtract Instructions
10211021
// Widening FP add/subtract, 2*SEW = 2*SEW +/- SEW
10221022
defm vfwadd : RVVFloatingWidenOp0BinBuiltinSetRoundingMode;
10231023
defm vfwsub : RVVFloatingWidenOp0BinBuiltinSetRoundingMode;
10241024

10251025
// 13.4. Vector Single-Width Floating-Point Multiply/Divide Instructions
1026-
defm vfmul : RVVFloatingBinBuiltinSetRoundingMode;
1026+
defm vfmul : RVVFloatingBinBuiltinSetRoundingMode<HasBF=1>;
10271027
defm vfdiv : RVVFloatingBinBuiltinSetRoundingMode;
10281028
defm vfrdiv : RVVFloatingBinVFBuiltinSetRoundingMode;
10291029
}
10301030
// 13.2. Vector Single-Width Floating-Point Add/Subtract Instructions
1031-
defm vfadd : RVVFloatingBinBuiltinSet;
1032-
defm vfsub : RVVFloatingBinBuiltinSet;
1033-
defm vfrsub : RVVFloatingBinVFBuiltinSet;
1031+
defm vfadd : RVVFloatingBinBuiltinSet<HasBF=1>;
1032+
defm vfsub : RVVFloatingBinBuiltinSet<HasBF=1>;
1033+
defm vfrsub : RVVFloatingBinVFBuiltinSet<HasBF=1>;
10341034

10351035
// 13.3. Vector Widening Floating-Point Add/Subtract Instructions
10361036
// Widening FP add/subtract, 2*SEW = 2*SEW +/- SEW
10371037
defm vfwadd : RVVFloatingWidenOp0BinBuiltinSet;
10381038
defm vfwsub : RVVFloatingWidenOp0BinBuiltinSet;
10391039

10401040
// 13.4. Vector Single-Width Floating-Point Multiply/Divide Instructions
1041-
defm vfmul : RVVFloatingBinBuiltinSet;
1041+
defm vfmul : RVVFloatingBinBuiltinSet<HasBF=1>;
10421042
defm vfdiv : RVVFloatingBinBuiltinSet;
10431043
defm vfrdiv : RVVFloatingBinVFBuiltinSet;
10441044
}
@@ -1065,6 +1065,10 @@ let ManualCodegen = [{
10651065
defm vfwmul : RVVOutOp0Op1BuiltinSet<"vfwmul", "x",
10661066
[["vv", "w", "wvvu"],
10671067
["vf", "w", "wveu"]]>;
1068+
let RequiredFeatures = ["zvfbfa"] in
1069+
defm vfwmul : RVVOutOp0Op1BuiltinSet<"vfwmul", "y",
1070+
[["vv", "vw", "wvvu"],
1071+
["vf", "vw", "wveu"]]>;
10681072
}
10691073
}
10701074
// 13.3. Vector Widening Floating-Point Add/Subtract Instructions
@@ -1081,6 +1085,10 @@ let ManualCodegen = [{
10811085
defm vfwmul : RVVOutOp0Op1BuiltinSet<"vfwmul", "x",
10821086
[["vv", "w", "wvv"],
10831087
["vf", "w", "wve"]]>;
1088+
let RequiredFeatures = ["zvfbfa"] in
1089+
defm vfwmul : RVVOutOp0Op1BuiltinSet<"vfwmul", "y",
1090+
[["vv", "vw", "wvv"],
1091+
["vf", "vw", "wve"]]>;
10841092
}
10851093
}
10861094
}
@@ -1170,6 +1178,8 @@ let ManualCodegen = [{
11701178
defm vfrec7 : RVVOutBuiltinSet<"vfrec7", "fd", [["v", "v", "vvu"]]>;
11711179
let RequiredFeatures = ["zvfh"] in
11721180
defm vfrec7 : RVVOutBuiltinSet<"vfrec7", "x", [["v", "v", "vvu"]]>;
1181+
let RequiredFeatures = ["zvfbfa"] in
1182+
defm vfrec7 : RVVOutBuiltinSet<"vfrec7", "y", [["v", "v", "vvu"]]>;
11731183
}
11741184
// 13.8. Vector Floating-Point Square-Root Instruction
11751185
defm vfsqrt : RVVOutBuiltinSet<"vfsqrt", "fd", [["v", "v", "vv"]]>;
@@ -1180,21 +1190,26 @@ let ManualCodegen = [{
11801190
defm vfrec7 : RVVOutBuiltinSet<"vfrec7", "fd", [["v", "v", "vv"]]>;
11811191
let RequiredFeatures = ["zvfh"] in
11821192
defm vfrec7 : RVVOutBuiltinSet<"vfrec7", "x", [["v", "v", "vv"]]>;
1193+
let RequiredFeatures = ["zvfbfa"] in
1194+
defm vfrec7 : RVVOutBuiltinSet<"vfrec7", "y", [["v", "v", "vv"]]>;
11831195
}
11841196

11851197
// 13.9. Vector Floating-Point Reciprocal Square-Root Estimate Instruction
11861198
defm vfrsqrt7 : RVVOutBuiltinSet<"vfrsqrt7", "fd", [["v", "v", "vv"]]>;
11871199
let RequiredFeatures = ["zvfh"] in
11881200
defm vfrsqrt7 : RVVOutBuiltinSet<"vfrsqrt7", "x", [["v", "v", "vv"]]>;
1201+
let RequiredFeatures = ["zvfbfa"] in
1202+
defm vfrsqrt7 : RVVOutBuiltinSet<"vfrsqrt7", "y", [["v", "v", "vv"]]>;
1203+
11891204

11901205
// 13.11. Vector Floating-Point MIN/MAX Instructions
1191-
defm vfmin : RVVFloatingBinBuiltinSet;
1192-
defm vfmax : RVVFloatingBinBuiltinSet;
1206+
defm vfmin : RVVFloatingBinBuiltinSet<HasBF=1>;
1207+
defm vfmax : RVVFloatingBinBuiltinSet<HasBF=1>;
11931208

11941209
// 13.12. Vector Floating-Point Sign-Injection Instructions
1195-
defm vfsgnj : RVVFloatingBinBuiltinSet;
1196-
defm vfsgnjn : RVVFloatingBinBuiltinSet;
1197-
defm vfsgnjx : RVVFloatingBinBuiltinSet;
1210+
defm vfsgnj : RVVFloatingBinBuiltinSet<HasBF=1>;
1211+
defm vfsgnjn : RVVFloatingBinBuiltinSet<HasBF=1>;
1212+
defm vfsgnjx : RVVFloatingBinBuiltinSet<HasBF=1>;
11981213
}
11991214
defm vfneg_v : RVVPseudoVFUnaryBuiltin<"vfsgnjn", "fd">;
12001215
let RequiredFeatures = ["zvfh"] in
@@ -1219,6 +1234,8 @@ let UnMaskedPolicyScheme = HasPassthruOperand in {
12191234
defm vfclass : RVVOp0BuiltinSet<"vfclass", "fd", [["v", "Uv", "Uvv"]]>;
12201235
let RequiredFeatures = ["zvfh"] in
12211236
defm vfclass : RVVOp0BuiltinSet<"vfclass", "x", [["v", "Uv", "Uvv"]]>;
1237+
let RequiredFeatures = ["zvfbfa"] in
1238+
defm vfclass : RVVOp0BuiltinSet<"vfclass", "y", [["v", "vUv", "Uvv"]]>;
12221239
}
12231240

12241241
// 13.15. Vector Floating-Point Merge Instruction
@@ -1239,6 +1256,9 @@ let HasMasked = false,
12391256
let RequiredFeatures = ["zvfh"] in
12401257
defm vfmerge : RVVOutOp1BuiltinSet<"vfmerge", "x",
12411258
[["vfm", "v", "vvem"]]>;
1259+
let RequiredFeatures = ["zvfbfa"] in
1260+
defm vfmerge : RVVOutOp1BuiltinSet<"vfmerge", "y",
1261+
[["vfm", "v", "vvem"]]>;
12421262
}
12431263

12441264
// 13.16. Vector Floating-Point Move Instruction
@@ -1252,6 +1272,9 @@ let HasMasked = false,
12521272
let RequiredFeatures = ["zvfh"] in
12531273
defm vfmv_v : RVVOutBuiltinSet<"vfmv_v_f", "x",
12541274
[["f", "v", "ve"]]>;
1275+
let RequiredFeatures = ["zvfbfa"] in
1276+
defm vfmv_v : RVVOutBuiltinSet<"vfmv_v_f", "y",
1277+
[["f", "v", "ve"]]>;
12551278
}
12561279

12571280
// 13.17. Single-Width Floating-Point/Integer Type-Convert Instructions
@@ -1287,10 +1310,16 @@ let Log2LMUL = [-3, -2, -1, 0, 1, 2] in {
12871310
defm : RVVConvBuiltinSet<"vfwcvt_f_x_v", "c", [["Fw", "Fwv"]]>;
12881311
}
12891312
}
1313+
let RequiredFeatures = ["zvfbfa"], OverloadedName = "vfwcvt_f_bf16" in {
1314+
defm : RVVConvBuiltinSet<"vfwcvt_f_xu_v", "c", [["Yw", "YwUv"]]>;
1315+
defm : RVVConvBuiltinSet<"vfwcvt_f_x_v", "c", [["Yw", "Ywv"]]>;
1316+
}
12901317
let OverloadedName = "vfwcvt_f" in {
12911318
defm : RVVConvBuiltinSet<"vfwcvt_f_f_v", "f", [["w", "wv"]]>;
12921319
let RequiredFeatures = ["zvfhmin"] in
12931320
defm : RVVConvBuiltinSet<"vfwcvt_f_f_v", "x", [["w", "wv"]]>;
1321+
let RequiredFeatures = ["zvfbfa"] in
1322+
defm : RVVConvBuiltinSet<"vfwcvt_f_f_v", "y", [["vw", "wv"]]>;
12941323
}
12951324
}
12961325

@@ -1300,17 +1329,23 @@ let Log2LMUL = [-3, -2, -1, 0, 1, 2] in {
13001329
defm : RVVConvBuiltinSet<"vfncvt_rtz_xu_f_w", "si", [["Uv", "UvFw"]]>;
13011330
let RequiredFeatures = ["zvfh"] in
13021331
defm : RVVConvBuiltinSet<"vfncvt_rtz_xu_f_w", "c", [["Uv", "UvFw"]]>;
1332+
let RequiredFeatures = ["zvfbfa"] in
1333+
defm : RVVConvBuiltinSet<"vfncvt_rtz_xu_f_w", "c", [["YwUv", "UvYw"]]>;
13031334
}
13041335
let OverloadedName = "vfncvt_rtz_x" in {
13051336
defm : RVVConvBuiltinSet<"vfncvt_rtz_x_f_w", "si", [["Iv", "IvFw"]]>;
13061337
let RequiredFeatures = ["zvfh"] in
13071338
defm : RVVConvBuiltinSet<"vfncvt_rtz_x_f_w", "c", [["Iv", "IvFw"]]>;
1339+
let RequiredFeatures = ["zvfbfa"] in
1340+
defm : RVVConvBuiltinSet<"vfncvt_rtz_x_f_w", "c", [["YwIv", "IvYw"]]>;
13081341
}
13091342
let OverloadedName = "vfncvt_rod_f" in {
13101343
defm : RVVConvBuiltinSet<"vfncvt_rod_f_f_w", "f", [["v", "vw"]]>;
13111344
let RequiredFeatures = ["zvfh"] in
13121345
defm : RVVConvBuiltinSet<"vfncvt_rod_f_f_w", "x", [["v", "vw"]]>;
13131346
}
1347+
let RequiredFeatures = ["zvfbfa"], OverloadedName = "vfncvt_rod_f_bf16" in
1348+
defm : RVVConvBuiltinSet<"vfncvt_rod_f_f_w", "y", [["v", "vw"]]>;
13141349
}
13151350

13161351
// Zvfbfmin - Vector convert BF16 to FP32
@@ -1363,11 +1398,15 @@ let ManualCodegen = [{
13631398
defm : RVVConvBuiltinSet<"vfncvt_x_f_w", "si", [["Iv", "IvFwu"]]>;
13641399
let RequiredFeatures = ["zvfh"] in
13651400
defm : RVVConvBuiltinSet<"vfncvt_x_f_w", "c", [["Iv", "IvFwu"]]>;
1401+
let RequiredFeatures = ["zvfbfa"] in
1402+
defm : RVVConvBuiltinSet<"vfncvt_x_f_w", "c", [["YwIv", "IvYwu"]]>;
13661403
}
13671404
let OverloadedName = "vfncvt_xu" in {
13681405
defm : RVVConvBuiltinSet<"vfncvt_xu_f_w", "si", [["Uv", "UvFwu"]]>;
13691406
let RequiredFeatures = ["zvfh"] in
13701407
defm : RVVConvBuiltinSet<"vfncvt_xu_f_w", "c", [["Uv", "UvFwu"]]>;
1408+
let RequiredFeatures = ["zvfbfa"] in
1409+
defm : RVVConvBuiltinSet<"vfncvt_xu_f_w", "c", [["YwUv", "UvYwu"]]>;
13711410
}
13721411
let OverloadedName = "vfncvt_f" in {
13731412
defm : RVVConvBuiltinSet<"vfncvt_f_x_w", "f", [["v", "vIwu"]]>;
@@ -1382,6 +1421,8 @@ let ManualCodegen = [{
13821421
let RequiredFeatures = ["zvfhmin"] in
13831422
defm : RVVConvBuiltinSet<"vfncvt_f_f_w", "x", [["v", "vwu"]]>;
13841423
}
1424+
let RequiredFeatures = ["zvfbfa"], OverloadedName = "vfncvt_f_bf16" in
1425+
defm : RVVConvBuiltinSet<"vfncvt_f_f_w", "y", [["v", "vwu"]]>;
13851426
}
13861427

13871428
// Zvfbfmin - Vector convert FP32 to BF16
@@ -1430,11 +1471,15 @@ let ManualCodegen = [{
14301471
defm : RVVConvBuiltinSet<"vfncvt_x_f_w", "si", [["Iv", "IvFw"]]>;
14311472
let RequiredFeatures = ["zvfh"] in
14321473
defm : RVVConvBuiltinSet<"vfncvt_x_f_w", "c", [["Iv", "IvFw"]]>;
1474+
let RequiredFeatures = ["zvfbfa"] in
1475+
defm : RVVConvBuiltinSet<"vfncvt_x_f_w", "c", [["YwIv", "IvYw"]]>;
14331476
}
14341477
let OverloadedName = "vfncvt_xu" in {
14351478
defm : RVVConvBuiltinSet<"vfncvt_xu_f_w", "si", [["Uv", "UvFw"]]>;
14361479
let RequiredFeatures = ["zvfh"] in
14371480
defm : RVVConvBuiltinSet<"vfncvt_xu_f_w", "c", [["Uv", "UvFw"]]>;
1481+
let RequiredFeatures = ["zvfbfa"] in
1482+
defm : RVVConvBuiltinSet<"vfncvt_xu_f_w", "c", [["YwUv", "UvYw"]]>;
14381483
}
14391484
let OverloadedName = "vfncvt_f" in {
14401485
defm : RVVConvBuiltinSet<"vfncvt_f_x_w", "f", [["v", "vIw"]]>;
@@ -1449,6 +1494,8 @@ let ManualCodegen = [{
14491494
let RequiredFeatures = ["zvfhmin"] in
14501495
defm : RVVConvBuiltinSet<"vfncvt_f_f_w", "x", [["v", "vw"]]>;
14511496
}
1497+
let RequiredFeatures = ["zvfbfa"], OverloadedName = "vfncvt_f_bf16" in
1498+
defm : RVVConvBuiltinSet<"vfncvt_f_f_w", "y", [["v", "vw"]]>;
14521499
}
14531500

14541501
// Zvfbfmin - Vector convert FP32 to BF16
@@ -1578,6 +1625,9 @@ let HasMasked = false, MaskedPolicyScheme = NonePolicy in {
15781625
let RequiredFeatures = ["zvfh"] in
15791626
defm vfmv_f : RVVOp0BuiltinSet<"vfmv_f_s", "x",
15801627
[["s", "ve", "ev"]]>;
1628+
let RequiredFeatures = ["zvfbfa"] in
1629+
defm vfmv_f : RVVOp0BuiltinSet<"vfmv_f_s", "y",
1630+
[["s", "ve", "ev"]]>;
15811631
}
15821632
let OverloadedName = "vfmv_s",
15831633
UnMaskedPolicyScheme = HasPassthruOperand,
@@ -1589,6 +1639,9 @@ let HasMasked = false, MaskedPolicyScheme = NonePolicy in {
15891639
defm vfmv_s : RVVOutBuiltinSet<"vfmv_s_f", "x",
15901640
[["f", "v", "ve"],
15911641
["x", "Uv", "UvUe"]]>;
1642+
let RequiredFeatures = ["zvfbfa"] in
1643+
defm vfmv_s : RVVOutBuiltinSet<"vfmv_s_f", "y",
1644+
[["f", "v", "ve"]]>;
15921645
}
15931646
}
15941647

@@ -1601,11 +1654,11 @@ defm vslidedown : RVVSlideDownBuiltinSet;
16011654
// 16.3.3. Vector Slide1up Instructions
16021655
let UnMaskedPolicyScheme = HasPassthruOperand in {
16031656
defm vslide1up : RVVSlideOneBuiltinSet;
1604-
defm vfslide1up : RVVFloatingBinVFBuiltinSet;
1657+
defm vfslide1up : RVVFloatingBinVFBuiltinSet<HasBF=1>;
16051658

16061659
// 16.3.4. Vector Slide1down Instruction
16071660
defm vslide1down : RVVSlideOneBuiltinSet;
1608-
defm vfslide1down : RVVFloatingBinVFBuiltinSet;
1661+
defm vfslide1down : RVVFloatingBinVFBuiltinSet<HasBF=1>;
16091662

16101663
// 16.4. Vector Register Gather Instructions
16111664
// signed and floating type

0 commit comments

Comments
 (0)