Skip to content

Commit bfc60ac

Browse files
committed
[RISCV] Adjust RISCVInstrInfoVSDPatterns.td for different pseudo instructions for different FPR.
Move the Suffix string into the VTypeInfo class so we don't need a helper class to get to it. Adjust pseudo naming scheme for FPRs to put F16/F32/F64 in place of F in the pseudo instruction name rather than as a suffix. This avoids special cases like VFMERGE from the original patch. Differential Revision: https://reviews.llvm.org/D95404
1 parent b3b0acd commit bfc60ac

19 files changed

+61
-324
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td

Lines changed: 36 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,6 @@ def FPList {
103103
list<FPR_Info> fpinfo = [SCALAR_F16, SCALAR_F32, SCALAR_F64];
104104
}
105105

106-
class getScalarSuffix<ValueType type> {
107-
string suffix = !cond(!eq(type, XLenVT): "VX",
108-
!eq(type, f16): "VF_F16",
109-
!eq(type, f32): "VF_F32",
110-
!eq(type, f64): "VF_F64");
111-
}
112-
113-
class getWScalarSuffix<ValueType type> {
114-
string suffix = !cond(!eq(type, XLenVT): "WX",
115-
!eq(type, f16): "WF_F16",
116-
!eq(type, f32): "WF_F32",
117-
!eq(type, f64): "WF_F64");
118-
}
119-
120106
class MxSet<int eew> {
121107
list<LMULInfo> m = !cond(!eq(eew, 8) : [V_MF8, V_MF4, V_MF2, V_M1, V_M2, V_M4, V_M8],
122108
!eq(eew, 16) : [V_MF4, V_MF2, V_M1, V_M2, V_M4, V_M8],
@@ -186,6 +172,11 @@ class VTypeInfo<ValueType Vec, ValueType Mas, int Sew, VReg Reg, LMULInfo M,
186172
// The pattern fragment which produces the AVL operand, representing the
187173
// "natural" vector length for this type. For scalable vectors this is VLMax.
188174
OutPatFrag AVL = VLMax;
175+
176+
string ScalarSuffix = !cond(!eq(Scal, XLenVT) : "X",
177+
!eq(Scal, f16) : "F16",
178+
!eq(Scal, f32) : "F32",
179+
!eq(Scal, f64) : "F64");
189180
}
190181

191182
class GroupVTypeInfo<ValueType Vec, ValueType VecM1, ValueType Mas, int Sew,
@@ -467,9 +458,9 @@ class PseudoToVInst<string PseudoInst> {
467458
!subst("_B32", "",
468459
!subst("_B64", "",
469460
!subst("_MASK", "",
470-
!subst("_F16", "",
471-
!subst("_F32", "",
472-
!subst("_F64", "",
461+
!subst("F16", "F",
462+
!subst("F32", "F",
463+
!subst("F64", "F",
473464
!subst("Pseudo", "", PseudoInst)))))))))))))))))));
474465
}
475466

@@ -1408,8 +1399,8 @@ multiclass VPseudoBinaryV_VX<string Constraint = ""> {
14081399
multiclass VPseudoBinaryV_VF<string Constraint = ""> {
14091400
foreach m = MxList.m in
14101401
foreach f = FPList.fpinfo in
1411-
defm "_VF_" # f.FX : VPseudoBinary<m.vrclass, m.vrclass,
1412-
f.fprclass, m, Constraint>;
1402+
defm "_V" # f.FX : VPseudoBinary<m.vrclass, m.vrclass,
1403+
f.fprclass, m, Constraint>;
14131404
}
14141405

14151406
multiclass VPseudoBinaryV_VI<Operand ImmType = simm5, string Constraint = ""> {
@@ -1446,9 +1437,9 @@ multiclass VPseudoBinaryW_VX {
14461437
multiclass VPseudoBinaryW_VF {
14471438
foreach m = MxList.m[0-5] in
14481439
foreach f = FPList.fpinfo[0-1] in
1449-
defm "_VF_" # f.FX : VPseudoBinary<m.wvrclass, m.vrclass,
1450-
f.fprclass, m,
1451-
"@earlyclobber $rd">;
1440+
defm "_V" # f.FX : VPseudoBinary<m.wvrclass, m.vrclass,
1441+
f.fprclass, m,
1442+
"@earlyclobber $rd">;
14521443
}
14531444

14541445
multiclass VPseudoBinaryW_WV {
@@ -1466,9 +1457,9 @@ multiclass VPseudoBinaryW_WX {
14661457
multiclass VPseudoBinaryW_WF {
14671458
foreach m = MxList.m[0-5] in
14681459
foreach f = FPList.fpinfo[0-1] in
1469-
defm "_WF_" # f.FX : VPseudoBinary<m.wvrclass, m.wvrclass,
1470-
f.fprclass, m,
1471-
"@earlyclobber $rd">;
1460+
defm "_W" # f.FX : VPseudoBinary<m.wvrclass, m.wvrclass,
1461+
f.fprclass, m,
1462+
"@earlyclobber $rd">;
14721463
}
14731464

14741465
multiclass VPseudoBinaryV_WV {
@@ -1515,7 +1506,7 @@ multiclass VPseudoBinaryV_XM<bit CarryOut = 0, bit CarryIn = 1,
15151506
multiclass VPseudoBinaryV_FM {
15161507
foreach m = MxList.m in
15171508
foreach f = FPList.fpinfo in
1518-
def "_VFM_" # f.FX # "_" # m.MX :
1509+
def "_V" # f.FX # "M_" # m.MX :
15191510
VPseudoBinaryCarryIn<GetVRegNoV0<m.vrclass>.R,
15201511
m.vrclass, f.fprclass, m, /*CarryIn=*/1, "">;
15211512
}
@@ -1544,7 +1535,7 @@ multiclass VPseudoUnaryV_F_NoDummyMask {
15441535
foreach m = MxList.m in {
15451536
foreach f = FPList.fpinfo in {
15461537
let VLMul = m.value in {
1547-
def "_F_" # f.FX # "_" # m.MX : VPseudoUnaryNoDummyMask<m.vrclass, f.fprclass>;
1538+
def "_" # f.FX # "_" # m.MX : VPseudoUnaryNoDummyMask<m.vrclass, f.fprclass>;
15481539
}
15491540
}
15501541
}
@@ -1613,7 +1604,7 @@ multiclass VPseudoBinaryM_VX {
16131604
multiclass VPseudoBinaryM_VF {
16141605
foreach m = MxList.m in
16151606
foreach f = FPList.fpinfo in
1616-
defm "_VF_" # f.FX :
1607+
defm "_V" # f.FX :
16171608
VPseudoBinary<VR, m.vrclass, f.fprclass, m, "@earlyclobber $rd">;
16181609
}
16191610

@@ -1731,8 +1722,8 @@ multiclass VPseudoTernaryV_VX_AAXA<string Constraint = ""> {
17311722
multiclass VPseudoTernaryV_VF_AAXA<string Constraint = ""> {
17321723
foreach m = MxList.m in
17331724
foreach f = FPList.fpinfo in
1734-
defm "_VF_" # f.FX : VPseudoTernary<m.vrclass, f.fprclass, m.vrclass,
1735-
m, Constraint>;
1725+
defm "_V" # f.FX : VPseudoTernary<m.vrclass, f.fprclass, m.vrclass,
1726+
m, Constraint>;
17361727
}
17371728

17381729
multiclass VPseudoTernaryW_VV {
@@ -1751,8 +1742,8 @@ multiclass VPseudoTernaryW_VF {
17511742
defvar constraint = "@earlyclobber $rd";
17521743
foreach m = MxList.m[0-5] in
17531744
foreach f = FPList.fpinfo[0-1] in
1754-
defm "_VF_" # f.FX : VPseudoTernary<m.wvrclass, f.fprclass, m.vrclass, m,
1755-
constraint>;
1745+
defm "_V" # f.FX : VPseudoTernary<m.wvrclass, f.fprclass, m.vrclass, m,
1746+
constraint>;
17561747
}
17571748

17581749
multiclass VPseudoTernaryV_VI<Operand ImmType = simm5, string Constraint = ""> {
@@ -2510,7 +2501,7 @@ multiclass VPatBinaryV_VV_INT_EEW<string intrinsic, string instruction,
25102501
multiclass VPatBinaryV_VX<string intrinsic, string instruction,
25112502
list<VTypeInfo> vtilist> {
25122503
foreach vti = vtilist in {
2513-
defvar kind = getScalarSuffix<vti.Scalar>.suffix;
2504+
defvar kind = "V"#vti.ScalarSuffix;
25142505
defm : VPatBinary<intrinsic, instruction#"_"#kind#"_"#vti.LMul.MX,
25152506
vti.Vector, vti.Vector, vti.Scalar, vti.Mask,
25162507
vti.SEW, vti.RegClass,
@@ -2560,7 +2551,7 @@ multiclass VPatBinaryW_VX<string intrinsic, string instruction,
25602551
foreach VtiToWti = vtilist in {
25612552
defvar Vti = VtiToWti.Vti;
25622553
defvar Wti = VtiToWti.Wti;
2563-
defvar kind = getScalarSuffix<Vti.Scalar>.suffix;
2554+
defvar kind = "V"#Vti.ScalarSuffix;
25642555
defm : VPatBinary<intrinsic, instruction#"_"#kind#"_"#Vti.LMul.MX,
25652556
Wti.Vector, Vti.Vector, Vti.Scalar, Vti.Mask,
25662557
Vti.SEW, Wti.RegClass,
@@ -2585,7 +2576,7 @@ multiclass VPatBinaryW_WX<string intrinsic, string instruction,
25852576
foreach VtiToWti = vtilist in {
25862577
defvar Vti = VtiToWti.Vti;
25872578
defvar Wti = VtiToWti.Wti;
2588-
defvar kind = getWScalarSuffix<Vti.Scalar>.suffix;
2579+
defvar kind = "W"#Vti.ScalarSuffix;
25892580
defm : VPatBinary<intrinsic, instruction#"_"#kind#"_"#Vti.LMul.MX,
25902581
Wti.Vector, Wti.Vector, Vti.Scalar, Vti.Mask,
25912582
Vti.SEW, Wti.RegClass,
@@ -2610,7 +2601,7 @@ multiclass VPatBinaryV_WX<string intrinsic, string instruction,
26102601
foreach VtiToWti = vtilist in {
26112602
defvar Vti = VtiToWti.Vti;
26122603
defvar Wti = VtiToWti.Wti;
2613-
defvar kind = getWScalarSuffix<Vti.Scalar>.suffix;
2604+
defvar kind = "W"#Vti.ScalarSuffix;
26142605
defm : VPatBinary<intrinsic, instruction#"_"#kind#"_"#Vti.LMul.MX,
26152606
Vti.Vector, Wti.Vector, Vti.Scalar, Vti.Mask,
26162607
Vti.SEW, Vti.RegClass,
@@ -2646,10 +2637,7 @@ multiclass VPatBinaryV_XM<string intrinsic, string instruction,
26462637
list<VTypeInfo> vtilist = AllIntegerVectors> {
26472638
foreach vti = vtilist in
26482639
defm : VPatBinaryCarryIn<intrinsic, instruction,
2649-
!cond(!eq(vti.Scalar, XLenVT): "VXM",
2650-
!eq(vti.Scalar, f16): "VFM_F16",
2651-
!eq(vti.Scalar, f32): "VFM_F32",
2652-
!eq(vti.Scalar, f64): "VFM_F64"),
2640+
"V"#vti.ScalarSuffix#"M",
26532641
!if(CarryOut, vti.Mask, vti.Vector),
26542642
vti.Vector, vti.Scalar, vti.Mask,
26552643
vti.SEW, vti.LMul,
@@ -2702,7 +2690,7 @@ multiclass VPatBinaryM_VV<string intrinsic, string instruction,
27022690
multiclass VPatBinaryM_VX<string intrinsic, string instruction,
27032691
list<VTypeInfo> vtilist> {
27042692
foreach vti = vtilist in {
2705-
defvar kind = getScalarSuffix<vti.Scalar>.suffix;
2693+
defvar kind = "V"#vti.ScalarSuffix;
27062694
defm : VPatBinary<intrinsic, instruction#"_"#kind#"_"#vti.LMul.MX,
27072695
vti.Mask, vti.Vector, vti.Scalar, vti.Mask,
27082696
vti.SEW, VR,
@@ -2844,7 +2832,7 @@ multiclass VPatTernaryV_VX_AAXA<string intrinsic, string instruction,
28442832
list<VTypeInfo> vtilist> {
28452833
foreach vti = vtilist in
28462834
defm : VPatTernary<intrinsic, instruction,
2847-
getScalarSuffix<vti.Scalar>.suffix,
2835+
"V"#vti.ScalarSuffix,
28482836
vti.Vector, vti.Scalar, vti.Vector, vti.Mask,
28492837
vti.SEW, vti.LMul, vti.RegClass,
28502838
vti.ScalarRegClass, vti.RegClass>;
@@ -2877,7 +2865,7 @@ multiclass VPatTernaryW_VX<string intrinsic, string instruction,
28772865
defvar vti = vtiToWti.Vti;
28782866
defvar wti = vtiToWti.Wti;
28792867
defm : VPatTernary<intrinsic, instruction,
2880-
getScalarSuffix<vti.Scalar>.suffix,
2868+
"V"#vti.ScalarSuffix,
28812869
wti.Vector, vti.Scalar, vti.Vector,
28822870
vti.Mask, vti.SEW, vti.LMul,
28832871
wti.RegClass, vti.ScalarRegClass, vti.RegClass>;
@@ -3662,14 +3650,14 @@ let mayLoad = 0, mayStore = 0, hasSideEffects = 0, usesCustomInserter = 1,
36623650
foreach f = FPList.fpinfo in {
36633651
let VLMul = m.value in {
36643652
let HasSEWOp = 1, BaseInstr = VFMV_F_S in
3665-
def PseudoVFMV_F_S # "_" # f.FX # "_" # m.MX :
3653+
def "PseudoVFMV_" # f.FX # "_S_" # m.MX :
36663654
Pseudo<(outs f.fprclass:$rd),
36673655
(ins m.vrclass:$rs2,
36683656
ixlenimm:$sew),
36693657
[]>, RISCVVPseudo;
36703658
let HasVLOp = 1, HasSEWOp = 1, BaseInstr = VFMV_S_F, WritesElement0 = 1,
36713659
Constraints = "$rd = $rs1" in
3672-
def PseudoVFMV_S_F # "_" # f.FX #"_" # m.MX :
3660+
def "PseudoVFMV_S_" # f.FX # "_" # m.MX :
36733661
Pseudo<(outs m.vrclass:$rd),
36743662
(ins m.vrclass:$rs1, f.fprclass:$rs2,
36753663
GPR:$vl, ixlenimm:$sew),
@@ -4185,10 +4173,7 @@ foreach fvti = AllFloatVectors in {
41854173

41864174
def : Pat<(fvti.Vector (int_riscv_vfmv_v_f
41874175
(fvti.Scalar fvti.ScalarRegClass:$rs2), GPR:$vl)),
4188-
(!cast<Instruction>("PseudoVFMV_V_F_" #
4189-
!cond(!eq(fvti.Scalar, f16): "F16_",
4190-
!eq(fvti.Scalar, f32): "F32_",
4191-
!eq(fvti.Scalar, f64): "F64_") #
4176+
(!cast<Instruction>("PseudoVFMV_V_" # fvti.ScalarSuffix # "_" #
41924177
fvti.LMul.MX)
41934178
(fvti.Scalar fvti.ScalarRegClass:$rs2),
41944179
(NoX0 GPR:$vl), fvti.SEW)>;
@@ -4348,20 +4333,14 @@ foreach vti = AllIntegerVectors in {
43484333

43494334
let Predicates = [HasStdExtV, HasStdExtF] in {
43504335
foreach fvti = AllFloatVectors in {
4351-
defvar instr = !cast<Instruction>("PseudoVFMV_F_S_" #
4352-
!cond(!eq(fvti.Scalar, f16): "F16_",
4353-
!eq(fvti.Scalar, f32): "F32_",
4354-
!eq(fvti.Scalar, f64): "F64_") #
4336+
defvar instr = !cast<Instruction>("PseudoVFMV_"#fvti.ScalarSuffix#"_S_" #
43554337
fvti.LMul.MX);
43564338
def : Pat<(fvti.Scalar (int_riscv_vfmv_f_s (fvti.Vector fvti.RegClass:$rs2))),
43574339
(instr $rs2, fvti.SEW)>;
43584340

43594341
def : Pat<(fvti.Vector (int_riscv_vfmv_s_f (fvti.Vector fvti.RegClass:$rs1),
43604342
(fvti.Scalar fvti.ScalarRegClass:$rs2), GPR:$vl)),
4361-
(!cast<Instruction>("PseudoVFMV_S_F_" #
4362-
!cond(!eq(fvti.Scalar, f16): "F16_",
4363-
!eq(fvti.Scalar, f32): "F32_",
4364-
!eq(fvti.Scalar, f64): "F64_") #
4343+
(!cast<Instruction>("PseudoVFMV_S_"#fvti.ScalarSuffix#"_" #
43654344
fvti.LMul.MX)
43664345
(fvti.Vector $rs1),
43674346
(fvti.Scalar fvti.ScalarRegClass:$rs2),

0 commit comments

Comments
 (0)