From 2b045324b2ca3974b8acbcb2867dd39159a75ea3 Mon Sep 17 00:00:00 2001 From: Monk Chiang Date: Wed, 29 Jun 2022 23:17:57 -0700 Subject: [PATCH] [RISCV] Add scheduling resources for vector segment instructions. Add scheduling resources for vector segment instructions Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D128886 --- llvm/lib/Target/RISCV/RISCVInstrInfoV.td | 76 ++++++++++++++++++------ llvm/lib/Target/RISCV/RISCVScheduleV.td | 28 +++++++++ 2 files changed, 85 insertions(+), 19 deletions(-) diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoV.td b/llvm/lib/Target/RISCV/RISCVInstrInfoV.td index d466e278cafc..1ad634344c09 100644 --- a/llvm/lib/Target/RISCV/RISCVInstrInfoV.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoV.td @@ -115,6 +115,35 @@ class VSXSched : class VLFSched : Sched <[!cast("WriteVLDFF" # n), ReadVLDX, ReadVMask]>; +// Unit-Stride Segment Loads and Stores +class VLSEGSched : Sched<[ + !cast("WriteVLSEG" #nf #"e" #eew), ReadVLDX, ReadVMask]>; +class VSSEGSched : Sched<[ + !cast("WriteVSSEG" #nf #"e" #eew), + !cast("ReadVSTE" #eew #"V"), ReadVSTX, ReadVMask]>; +class VLSEGFFSched : Sched<[ + !cast("WriteVLSEGFF" #nf #"e" #eew), ReadVLDX, ReadVMask]>; +// Strided Segment Loads and Stores +class VLSSEGSched : Sched<[ + !cast("WriteVLSSEG" #nf #"e" #eew), ReadVLDX, ReadVLDSX, + ReadVMask]>; +class VSSSEGSched : Sched<[ + !cast("WriteVSSSEG" #nf #"e" #eew), + !cast("ReadVSTS" #eew #"V"), ReadVSTX, ReadVSTSX, ReadVMask]>; +// Indexed Segment Loads and Stores +class VLUXSEGSched : Sched<[ + !cast("WriteVLUXSEG" #nf #"e" #eew), ReadVLDX, ReadVLDUXV, + ReadVMask]>; +class VLOXSEGSched : Sched<[ + !cast("WriteVLOXSEG" #nf #"e" #eew), ReadVLDX, ReadVLDOXV, + ReadVMask]>; +class VSUXSEGSched : Sched<[ + !cast("WriteVSUXSEG" #nf #"e" #eew), + !cast("ReadVSTUX" #eew), ReadVSTX, ReadVSTUXV, ReadVMask]>; +class VSOXSEGSched : Sched<[ + !cast("WriteVSOXSEG" #nf #"e" #eew), + !cast("ReadVSTOX" #eew), ReadVSTX, ReadVSTOXV, ReadVMask]>; + //===----------------------------------------------------------------------===// // Instruction class templates //===----------------------------------------------------------------------===// @@ -1495,31 +1524,35 @@ let Predicates = [HasVInstructions] in { defvar w = !cast("LSWidth"#eew); def VLSEG#nf#E#eew#_V : - VUnitStrideSegmentLoad; + VUnitStrideSegmentLoad, + VLSEGSched; def VLSEG#nf#E#eew#FF_V : - VUnitStrideSegmentLoadFF; + VUnitStrideSegmentLoadFF, + VLSEGFFSched; def VSSEG#nf#E#eew#_V : - VUnitStrideSegmentStore; - + VUnitStrideSegmentStore, + VSSEGSched; // Vector Strided Instructions def VLSSEG#nf#E#eew#_V : - VStridedSegmentLoad; + VStridedSegmentLoad, + VLSSEGSched; def VSSSEG#nf#E#eew#_V : - VStridedSegmentStore; + VStridedSegmentStore, + VSSSEGSched; // Vector Indexed Instructions def VLUXSEG#nf#EI#eew#_V : VIndexedSegmentLoad; + "vluxseg"#nf#"ei"#eew#".v">, VLUXSEGSched; def VLOXSEG#nf#EI#eew#_V : VIndexedSegmentLoad; + "vloxseg"#nf#"ei"#eew#".v">, VLOXSEGSched; def VSUXSEG#nf#EI#eew#_V : VIndexedSegmentStore; + "vsuxseg"#nf#"ei"#eew#".v">, VSUXSEGSched; def VSOXSEG#nf#EI#eew#_V : VIndexedSegmentStore; + "vsoxseg"#nf#"ei"#eew#".v">, VSOXSEGSched; } } } // Predicates = [HasVInstructions] @@ -1528,17 +1561,22 @@ let Predicates = [HasVInstructionsI64] in { foreach nf=2-8 in { // Vector Unit-strided Segment Instructions def VLSEG#nf#E64_V : - VUnitStrideSegmentLoad; + VUnitStrideSegmentLoad, + VLSEGSched; def VLSEG#nf#E64FF_V : - VUnitStrideSegmentLoadFF; + VUnitStrideSegmentLoadFF, + VLSEGFFSched; def VSSEG#nf#E64_V : - VUnitStrideSegmentStore; + VUnitStrideSegmentStore, + VSSEGSched; // Vector Strided Segment Instructions def VLSSEG#nf#E64_V : - VStridedSegmentLoad; + VStridedSegmentLoad, + VLSSEGSched; def VSSSEG#nf#E64_V : - VStridedSegmentStore; + VStridedSegmentStore, + VSSSEGSched; } } // Predicates = [HasVInstructionsI64] let Predicates = [HasVInstructionsI64, IsRV64] in { @@ -1546,16 +1584,16 @@ let Predicates = [HasVInstructionsI64, IsRV64] in { // Vector Indexed Segment Instructions def VLUXSEG#nf#EI64_V : VIndexedSegmentLoad; + "vluxseg"#nf#"ei64.v">, VLUXSEGSched; def VLOXSEG#nf#EI64_V : VIndexedSegmentLoad; + "vloxseg"#nf#"ei64.v">, VLOXSEGSched; def VSUXSEG#nf#EI64_V : VIndexedSegmentStore; + "vsuxseg"#nf#"ei64.v">, VSUXSEGSched; def VSOXSEG#nf#EI64_V : VIndexedSegmentStore; + "vsoxseg"#nf#"ei64.v">, VSOXSEGSched; } } // Predicates = [HasVInstructionsI64, IsRV64] diff --git a/llvm/lib/Target/RISCV/RISCVScheduleV.td b/llvm/lib/Target/RISCV/RISCVScheduleV.td index 43af1802d706..bafcf47b82e4 100644 --- a/llvm/lib/Target/RISCV/RISCVScheduleV.td +++ b/llvm/lib/Target/RISCV/RISCVScheduleV.td @@ -53,6 +53,20 @@ def WriteVLDFF8 : SchedWrite; def WriteVLDFF16 : SchedWrite; def WriteVLDFF32 : SchedWrite; def WriteVLDFF64 : SchedWrite; +// 7.8. Vector Segment Instructions +foreach nf=2-8 in { + foreach eew = [8, 16, 32, 64] in { + def WriteVLSEG # nf # e # eew : SchedWrite; + def WriteVSSEG # nf # e # eew : SchedWrite; + def WriteVLSEGFF # nf # e # eew : SchedWrite; + def WriteVLSSEG # nf # e # eew : SchedWrite; + def WriteVSSSEG # nf # e # eew : SchedWrite; + def WriteVLUXSEG # nf # e # eew : SchedWrite; + def WriteVLOXSEG # nf # e # eew : SchedWrite; + def WriteVSUXSEG # nf # e # eew : SchedWrite; + def WriteVSOXSEG # nf # e # eew : SchedWrite; + } +} // 7.9. Vector Whole Register Instructions def WriteVLD1R8 : SchedWrite; def WriteVLD1R16 : SchedWrite; @@ -538,6 +552,20 @@ def : WriteRes; def : WriteRes; def : WriteRes; def : WriteRes; +// Vector Segment Loads and Stores +foreach nf=2-8 in { + foreach eew = [8, 16, 32, 64] in { + def : WriteRes ("WriteVLSEG" # nf # "e" # eew), []>; + def : WriteRes ("WriteVLSEGFF" # nf # "e" # eew), []>; + def : WriteRes ("WriteVSSEG" # nf # "e" # eew), []>; + def : WriteRes ("WriteVLSSEG" # nf # "e" # eew), []>; + def : WriteRes ("WriteVSSSEG" # nf # "e" # eew), []>; + def : WriteRes ("WriteVLUXSEG" # nf # "e" # eew), []>; + def : WriteRes ("WriteVLOXSEG" # nf # "e" # eew), []>; + def : WriteRes ("WriteVSUXSEG" # nf # "e" # eew), []>; + def : WriteRes ("WriteVSOXSEG" # nf # "e" # eew), []>; + } +} // 12. Vector Integer Arithmetic Instructions def : WriteRes;