Skip to content

Commit d59d265

Browse files
authored
[RISCV] Add scheduling info for XSfvfnrclipxfqf instructions (#147586)
This patch adds scheduling data for the XSfvfnrclipxfqf instruction, which narrows / clips FP32 data to INT8 according to value range specified by a scalar register. Three new SchedReadWrites are introduced.
1 parent 6631665 commit d59d265

19 files changed

+220
-2
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoXSf.td

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ class CustomSiFiveVMACC<bits<6> funct6, RISCVVFormat opv, string opcodestr>
177177
}
178178

179179
class CustomSiFiveVFNRCLIP<bits<6> funct6, RISCVVFormat opv, string opcodestr>
180-
: VALUVF<funct6, opv, opcodestr> {
180+
: VALUVF<funct6, opv, opcodestr>,
181+
SchedBinaryMC<"WriteSF_VFNRClipV", "ReadSF_VFNRClipV", "ReadSF_VFNRClipF"> {
181182
let Inst{6-0} = OPC_CUSTOM_2.Value;
182183
}
183184

@@ -403,7 +404,10 @@ multiclass VPseudoSiFiveVFNRCLIP<string Constraint = "@earlyclobber $rd"> {
403404
MxListVF4[i].vrclass,
404405
FPR32, MxListW[i],
405406
Constraint, /*sew*/0,
406-
UsesVXRM=0>;
407+
UsesVXRM=0>,
408+
SchedBinary<"WriteSF_VFNRClipV", "ReadSF_VFNRClipV",
409+
"ReadSF_VFNRClipF",
410+
MxListW[i].MX>;
407411
}
408412

409413
let Predicates = [HasVendorXSfvcp] in {

llvm/lib/Target/RISCV/RISCVSchedAndes45.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ defm : UnsupportedSchedQ;
331331
defm : UnsupportedSchedSFB;
332332
defm : UnsupportedSchedV;
333333
defm : UnsupportedSchedXsfvcp;
334+
defm : UnsupportedSchedXSfvfnrclipxfqf;
334335
defm : UnsupportedSchedZabha;
335336
defm : UnsupportedSchedZbkb;
336337
defm : UnsupportedSchedZbkx;

llvm/lib/Target/RISCV/RISCVSchedGenericOOO.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,4 +498,5 @@ defm : UnsupportedSchedZfaWithQ;
498498
defm : UnsupportedSchedZvk;
499499
defm : UnsupportedSchedSFB;
500500
defm : UnsupportedSchedXsfvcp;
501+
defm : UnsupportedSchedXSfvfnrclipxfqf;
501502
}

llvm/lib/Target/RISCV/RISCVSchedMIPSP8700.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,5 +274,6 @@ defm : UnsupportedSchedZfhmin;
274274
defm : UnsupportedSchedSFB;
275275
defm : UnsupportedSchedZabha;
276276
defm : UnsupportedSchedXsfvcp;
277+
defm : UnsupportedSchedXSfvfnrclipxfqf;
277278
defm : UnsupportedSchedZvk;
278279
}

llvm/lib/Target/RISCV/RISCVSchedRocket.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,5 +263,6 @@ defm : UnsupportedSchedZfa;
263263
defm : UnsupportedSchedZfhmin;
264264
defm : UnsupportedSchedSFB;
265265
defm : UnsupportedSchedXsfvcp;
266+
defm : UnsupportedSchedXSfvfnrclipxfqf;
266267
defm : UnsupportedSchedZvk;
267268
}

llvm/lib/Target/RISCV/RISCVSchedSiFive7.td

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,20 @@ class SiFive7GetOrderedReductionCycles<string mx, int sew, int VLEN> {
169169
int c = !mul(6, VLUpperBound);
170170
}
171171

172+
class SiFive7GetSiFiveVFNRClipCycles<string mx, int VLEN> {
173+
int latency = !cond(
174+
!eq(mx, "MF8"): 7,
175+
!eq(mx, "MF4"): 8,
176+
!eq(mx, "MF2"): 10,
177+
!eq(mx, "M1"): 13,
178+
!eq(mx, "M2"): 19,
179+
);
180+
181+
defvar DLEN = !div(VLEN, 2);
182+
int occupancy = SiFive7GetCyclesOnePerElement<mx, sew=!div(DLEN, 4),
183+
VLEN=VLEN>.c;
184+
}
185+
172186
class SiFive7FPLatencies {
173187
int BasicFP16ALU;
174188
int BasicFP32ALU;
@@ -1049,6 +1063,15 @@ multiclass SiFive7WriteResBase<int VLEN,
10491063
}
10501064
}
10511065
}
1066+
1067+
foreach mx = !listremove(SchedMxListW, ["M4"]) in {
1068+
defvar Cycles = SiFive7GetSiFiveVFNRClipCycles<mx, VLEN>;
1069+
let Latency = Cycles.latency,
1070+
AcquireAtCycles = [0, 1],
1071+
ReleaseAtCycles = [1, !add(1, Cycles.occupancy)] in
1072+
defm : LMULWriteResMX<"WriteSF_VFNRClipV", [VCQ, VA1], mx,
1073+
IsWorstCase=!eq(mx, "M2")>;
1074+
}
10521075
}
10531076

10541077
//===----------------------------------------------------------------------===//
@@ -1326,6 +1349,10 @@ multiclass SiFive7ReadAdvance {
13261349
def : ReadAdvance<ReadVMov4V, 0>;
13271350
def : ReadAdvance<ReadVMov8V, 0>;
13281351

1352+
// XSfvfnrclipxfqf
1353+
defm : LMULReadAdvance<"ReadSF_VFNRClipV", 0>;
1354+
defm : LMULReadAdvance<"ReadSF_VFNRClipF", 0>;
1355+
13291356
// Others
13301357
def : ReadAdvance<ReadVMask, 0>;
13311358
def : ReadAdvance<ReadVPassthru_WorstCase, 0>;

llvm/lib/Target/RISCV/RISCVSchedSiFiveP400.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,4 +1239,5 @@ defm : UnsupportedSchedZbkx;
12391239
defm : UnsupportedSchedSFB;
12401240
defm : UnsupportedSchedZfa;
12411241
defm : UnsupportedSchedXsfvcp;
1242+
defm : UnsupportedSchedXSfvfnrclipxfqf;
12421243
}

llvm/lib/Target/RISCV/RISCVSchedSiFiveP500.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,4 +359,5 @@ defm : UnsupportedSchedSFB;
359359
defm : UnsupportedSchedZfa;
360360
defm : UnsupportedSchedZvk;
361361
defm : UnsupportedSchedXsfvcp;
362+
defm : UnsupportedSchedXSfvfnrclipxfqf;
362363
}

llvm/lib/Target/RISCV/RISCVSchedSiFiveP600.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,4 +1495,5 @@ defm : UnsupportedSchedZbkx;
14951495
defm : UnsupportedSchedSFB;
14961496
defm : UnsupportedSchedZfa;
14971497
defm : UnsupportedSchedXsfvcp;
1498+
defm : UnsupportedSchedXSfvfnrclipxfqf;
14981499
}

llvm/lib/Target/RISCV/RISCVSchedSiFiveP800.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,4 +1184,5 @@ defm : UnsupportedSchedZbkx;
11841184
defm : UnsupportedSchedSFB;
11851185
defm : UnsupportedSchedZfaWithQ;
11861186
defm : UnsupportedSchedXsfvcp;
1187+
defm : UnsupportedSchedXSfvfnrclipxfqf;
11871188
}

0 commit comments

Comments
 (0)