Skip to content

Commit 6c5039a

Browse files
author
luxufan
committed
[RISCV] add the assemble and disassemble support of Zvlsseg instructions
This implements the assemble and disassemble support of RISCV Vector extension Zvlsseg instructions, base on the 0.9 spec version. Reviewed by HsiangKai Differential Revision: https://reviews.llvm.org/D84416
1 parent c789939 commit 6c5039a

File tree

6 files changed

+4833
-2
lines changed

6 files changed

+4833
-2
lines changed

llvm/lib/Target/RISCV/RISCV.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ def HasStdExtV : Predicate<"Subtarget->hasStdExtV()">,
155155
AssemblerPredicate<(all_of FeatureStdExtV),
156156
"'V' (Vector Instructions)">;
157157

158+
def FeatureStdExtZvlsseg
159+
: SubtargetFeature<"experimental-zvlsseg", "HasStdExtZvlsseg", "true",
160+
"'Zvlsseg' (Vector segment load/store instructions)",
161+
[FeatureStdExtV]>;
162+
def HasStdExtZvlsseg : Predicate<"Subtarget->hasStdExtZvlsseg()">,
163+
AssemblerPredicate<(all_of FeatureStdExtZvlsseg),
164+
"'Zvlsseg' (Vector segment load/store instructions)">;
165+
158166
def Feature64Bit
159167
: SubtargetFeature<"64bit", "HasRV64", "true", "Implements RV64">;
160168
def IsRV64 : Predicate<"Subtarget->is64Bit()">,

llvm/lib/Target/RISCV/RISCVInstrInfoV.td

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,27 @@ class VWholeLoad<bits<3> nf, string opcodestr>
124124
let vm = 1;
125125
let Uses = [];
126126
}
127+
128+
// segment load vd, (rs1), vm
129+
class VUnitStrideSegmentLoad<bits<3> nf, RISCVLSUMOP lumop,
130+
RISCVWidth width, string opcodestr>
131+
: RVInstVLU<nf, width.Value{3}, lumop, width.Value{2-0},
132+
(outs VRegOp:$vd),
133+
(ins GPR:$rs1, VMaskOp:$vm), opcodestr, "$vd, (${rs1})$vm">;
134+
135+
// segment load vd, (rs1), rs2, vm
136+
class VStridedSegmentLoad<bits<3> nf, RISCVWidth width, string opcodestr>
137+
: RVInstVLS<nf, width.Value{3}, width.Value{2-0},
138+
(outs VRegOp:$vd),
139+
(ins GPR:$rs1, GPR:$rs2, VMaskOp:$vm), opcodestr,
140+
"$vd, (${rs1}), $rs2$vm">;
141+
142+
// segment load vd, (rs1), vs2, vm
143+
class VIndexedSegmentLoad<bits<3> nf, RISCVWidth width, string opcodestr>
144+
: RVInstVLX<nf, width.Value{3}, width.Value{2-0},
145+
(outs VRegOp:$vd),
146+
(ins GPR:$rs1, VRegOp:$vs2, VMaskOp:$vm), opcodestr,
147+
"$vd, (${rs1}), $vs2$vm">;
127148
} // hasSideEffects = 0, mayLoad = 1, mayStore = 0
128149

129150
let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in {
@@ -154,6 +175,24 @@ class VWholeStore<bits<3> nf, string opcodestr>
154175
let vm = 1;
155176
let Uses = [];
156177
}
178+
179+
// segment store vd, vs3, (rs1), vm
180+
class VUnitStrideSegmentStore<bits<3> nf, RISCVWidth width, string opcodestr>
181+
: RVInstVSU<nf, width.Value{3}, SUMOPUnitStride, width.Value{2-0},
182+
(outs), (ins VRegOp:$vs3, GPR:$rs1, VMaskOp:$vm), opcodestr,
183+
"$vs3, (${rs1})$vm">;
184+
185+
// segment store vd, vs3, (rs1), rs2, vm
186+
class VStridedSegmentStore<bits<3> nf, RISCVWidth width, string opcodestr>
187+
: RVInstVSS<nf, width.Value{3}, width.Value{2-0}, (outs),
188+
(ins VRegOp:$vs3, GPR:$rs1, GPR:$rs2, VMaskOp:$vm),
189+
opcodestr, "$vs3, (${rs1}), $rs2$vm">;
190+
191+
// segment store vd, vs3, (rs1), vs2, vm
192+
class VIndexedSegmentStore<bits<3> nf, RISCVWidth width, string opcodestr>
193+
: RVInstVSX<nf, width.Value{3}, MOPSTIndexedOrder, width.Value{2-0}, (outs),
194+
(ins VRegOp:$vs3, GPR:$rs1, VRegOp:$vs2, VMaskOp:$vm),
195+
opcodestr, "$vs3, (${rs1}), $vs2$vm">;
157196
} // hasSideEffects = 0, mayLoad = 0, mayStore = 1
158197

159198
let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
@@ -913,3 +952,72 @@ foreach nf = [1, 2, 4, 8] in {
913952
}
914953
} // hasSideEffects = 0, mayLoad = 0, mayStore = 0
915954
} // Predicates = [HasStdExtV]
955+
956+
let Predicates = [HasStdExtZvlsseg] in {
957+
foreach nf=2-8 in {
958+
def VLSEG#nf#E8_V : VUnitStrideSegmentLoad<!add(nf, -1), LUMOPUnitStride, LSWidth8, "vlseg"#nf#"e8.v">;
959+
def VLSEG#nf#E16_V : VUnitStrideSegmentLoad<!add(nf, -1), LUMOPUnitStride, LSWidth16, "vlseg"#nf#"e16.v">;
960+
def VLSEG#nf#E32_V : VUnitStrideSegmentLoad<!add(nf, -1), LUMOPUnitStride, LSWidth32, "vlseg"#nf#"e32.v">;
961+
def VLSEG#nf#E64_V : VUnitStrideSegmentLoad<!add(nf, -1), LUMOPUnitStride, LSWidth64, "vlseg"#nf#"e64.v">;
962+
def VLSEG#nf#E128_V : VUnitStrideSegmentLoad<!add(nf, -1), LUMOPUnitStride, LSWidth128, "vlseg"#nf#"e128.v">;
963+
def VLSEG#nf#E256_V : VUnitStrideSegmentLoad<!add(nf, -1), LUMOPUnitStride, LSWidth256, "vlseg"#nf#"e256.v">;
964+
def VLSEG#nf#E512_V : VUnitStrideSegmentLoad<!add(nf, -1), LUMOPUnitStride, LSWidth512, "vlseg"#nf#"e512.v">;
965+
def VLSEG#nf#E1024_V : VUnitStrideSegmentLoad<!add(nf, -1), LUMOPUnitStride, LSWidth1024, "vlseg"#nf#"e1024.v">;
966+
967+
def VLSEG#nf#E8FF_V : VUnitStrideSegmentLoad<!add(nf, -1), LUMOPUnitStrideFF, LSWidth8, "vlseg"#nf#"e8ff.v">;
968+
def VLSEG#nf#E16FF_V : VUnitStrideSegmentLoad<!add(nf, -1), LUMOPUnitStrideFF, LSWidth16, "vlseg"#nf#"e16ff.v">;
969+
def VLSEG#nf#E32FF_V : VUnitStrideSegmentLoad<!add(nf, -1), LUMOPUnitStrideFF, LSWidth32, "vlseg"#nf#"e32ff.v">;
970+
def VLSEG#nf#E64FF_V : VUnitStrideSegmentLoad<!add(nf, -1), LUMOPUnitStrideFF, LSWidth64, "vlseg"#nf#"e64ff.v">;
971+
def VLSEG#nf#E128FF_V : VUnitStrideSegmentLoad<!add(nf, -1), LUMOPUnitStrideFF, LSWidth128, "vlseg"#nf#"e128ff.v">;
972+
def VLSEG#nf#E256FF_V : VUnitStrideSegmentLoad<!add(nf, -1), LUMOPUnitStrideFF, LSWidth256, "vlseg"#nf#"e256ff.v">;
973+
def VLSEG#nf#E512FF_V : VUnitStrideSegmentLoad<!add(nf, -1), LUMOPUnitStrideFF, LSWidth512, "vlseg"#nf#"e512ff.v">;
974+
def VLSEG#nf#E1024FF_V : VUnitStrideSegmentLoad<!add(nf, -1), LUMOPUnitStrideFF, LSWidth1024, "vlseg"#nf#"e1024ff.v">;
975+
976+
def VSSEG#nf#E8_V : VUnitStrideSegmentStore<!add(nf, -1), LSWidth8, "vsseg"#nf#"e8.v">;
977+
def VSSEG#nf#E16_V : VUnitStrideSegmentStore<!add(nf, -1), LSWidth16, "vsseg"#nf#"e16.v">;
978+
def VSSEG#nf#E32_V : VUnitStrideSegmentStore<!add(nf, -1), LSWidth32, "vsseg"#nf#"e32.v">;
979+
def VSSEG#nf#E64_V : VUnitStrideSegmentStore<!add(nf, -1), LSWidth64, "vsseg"#nf#"e64.v">;
980+
def VSSEG#nf#E128_V : VUnitStrideSegmentStore<!add(nf, -1), LSWidth128, "vsseg"#nf#"e128.v">;
981+
def VSSEG#nf#E256_V : VUnitStrideSegmentStore<!add(nf, -1), LSWidth256, "vsseg"#nf#"e256.v">;
982+
def VSSEG#nf#E512_V : VUnitStrideSegmentStore<!add(nf, -1), LSWidth512, "vsseg"#nf#"e512.v">;
983+
def VSSEG#nf#E1024_V : VUnitStrideSegmentStore<!add(nf, -1), LSWidth1024, "vsseg"#nf#"e1024.v">;
984+
985+
// Vector Strided Instructions
986+
def VLSSEG#nf#E8_V : VStridedSegmentLoad<!add(nf, -1), LSWidth8, "vlsseg"#nf#"e8.v">;
987+
def VLSSEG#nf#E16_V : VStridedSegmentLoad<!add(nf, -1), LSWidth16, "vlsseg"#nf#"e16.v">;
988+
def VLSSEG#nf#E32_V : VStridedSegmentLoad<!add(nf, -1), LSWidth32, "vlsseg"#nf#"e32.v">;
989+
def VLSSEG#nf#E64_V : VStridedSegmentLoad<!add(nf, -1), LSWidth64, "vlsseg"#nf#"e64.v">;
990+
def VLSSEG#nf#E128_V : VStridedSegmentLoad<!add(nf, -1), LSWidth128, "vlsseg"#nf#"e128.v">;
991+
def VLSSEG#nf#E256_V : VStridedSegmentLoad<!add(nf, -1), LSWidth256, "vlsseg"#nf#"e256.v">;
992+
def VLSSEG#nf#E512_V : VStridedSegmentLoad<!add(nf, -1), LSWidth512, "vlsseg"#nf#"e512.v">;
993+
def VLSSEG#nf#E1024_V : VStridedSegmentLoad<!add(nf, -1), LSWidth1024, "vlsseg"#nf#"e1024.v">;
994+
995+
def VSSSEG#nf#E8_V : VStridedSegmentStore<!add(nf, -1), LSWidth8, "vssseg"#nf#"e8.v">;
996+
def VSSSEG#nf#E16_V : VStridedSegmentStore<!add(nf, -1), LSWidth16, "vssseg"#nf#"e16.v">;
997+
def VSSSEG#nf#E32_V : VStridedSegmentStore<!add(nf, -1), LSWidth32, "vssseg"#nf#"e32.v">;
998+
def VSSSEG#nf#E64_V : VStridedSegmentStore<!add(nf, -1), LSWidth64, "vssseg"#nf#"e64.v">;
999+
def VSSSEG#nf#E128_V : VStridedSegmentStore<!add(nf, -1), LSWidth128, "vssseg"#nf#"e128.v">;
1000+
def VSSSEG#nf#E256_V : VStridedSegmentStore<!add(nf, -1), LSWidth256, "vssseg"#nf#"e256.v">;
1001+
def VSSSEG#nf#E512_V : VStridedSegmentStore<!add(nf, -1), LSWidth512, "vssseg"#nf#"e512.v">;
1002+
def VSSSEG#nf#E1024_V : VStridedSegmentStore<!add(nf, -1), LSWidth1024, "vssseg"#nf#"e1024.v">;
1003+
1004+
// Vector Indexed Instructions
1005+
def VLXSEG#nf#EI8_V : VIndexedSegmentLoad<!add(nf, -1), LSWidth8, "vlxseg"#nf#"ei8.v">;
1006+
def VLXSEG#nf#EI16_V : VIndexedSegmentLoad<!add(nf, -1), LSWidth16, "vlxseg"#nf#"ei16.v">;
1007+
def VLXSEG#nf#EI32_V : VIndexedSegmentLoad<!add(nf, -1), LSWidth32, "vlxseg"#nf#"ei32.v">;
1008+
def VLXSEG#nf#EI64_V : VIndexedSegmentLoad<!add(nf, -1), LSWidth64, "vlxseg"#nf#"ei64.v">;
1009+
def VLXSEG#nf#EI128_V : VIndexedSegmentLoad<!add(nf, -1), LSWidth128, "vlxseg"#nf#"ei128.v">;
1010+
def VLXSEG#nf#EI256_V : VIndexedSegmentLoad<!add(nf, -1), LSWidth256, "vlxseg"#nf#"ei256.v">;
1011+
def VLXSEG#nf#EI512_V : VIndexedSegmentLoad<!add(nf, -1), LSWidth512, "vlxseg"#nf#"ei512.v">;
1012+
def VLXSEG#nf#EI1024_V : VIndexedSegmentLoad<!add(nf, -1), LSWidth1024, "vlxseg"#nf#"ei1024.v">;
1013+
1014+
def VSXSEG#nf#EI8_V : VIndexedSegmentStore<!add(nf, -1), LSWidth8, "vsxseg"#nf#"ei8.v">;
1015+
def VSXSEG#nf#EI16_V : VIndexedSegmentStore<!add(nf, -1), LSWidth16, "vsxseg"#nf#"ei16.v">;
1016+
def VSXSEG#nf#EI32_V : VIndexedSegmentStore<!add(nf, -1), LSWidth32, "vsxseg"#nf#"ei32.v">;
1017+
def VSXSEG#nf#EI64_V : VIndexedSegmentStore<!add(nf, -1), LSWidth64, "vsxseg"#nf#"ei64.v">;
1018+
def VSXSEG#nf#EI128_V : VIndexedSegmentStore<!add(nf, -1), LSWidth128, "vsxseg"#nf#"ei128.v">;
1019+
def VSXSEG#nf#EI256_V : VIndexedSegmentStore<!add(nf, -1), LSWidth256, "vsxseg"#nf#"ei256.v">;
1020+
def VSXSEG#nf#EI512_V : VIndexedSegmentStore<!add(nf, -1), LSWidth512, "vsxseg"#nf#"ei512.v">;
1021+
def VSXSEG#nf#EI1024_V : VIndexedSegmentStore<!add(nf, -1), LSWidth1024, "vsxseg"#nf#"ei1024.v">;
1022+
}
1023+
} // Predicates = [HasStdExtZvlsseg]

llvm/lib/Target/RISCV/RISCVSchedRocket32.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def Rocket32Model : SchedMachineModel {
1717
let LoadLatency = 3;
1818
let MispredictPenalty = 3;
1919
let CompleteModel = 1;
20-
let UnsupportedFeatures = [HasStdExtV];
20+
let UnsupportedFeatures = [HasStdExtV, HasStdExtZvlsseg];
2121
}
2222

2323
//===----------------------------------------------------------------------===//

llvm/lib/Target/RISCV/RISCVSchedRocket64.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def Rocket64Model : SchedMachineModel {
1616
let IssueWidth = 1; // 1 micro-ops are dispatched per cycle.
1717
let LoadLatency = 3;
1818
let MispredictPenalty = 3;
19-
let UnsupportedFeatures = [HasStdExtV];
19+
let UnsupportedFeatures = [HasStdExtV, HasStdExtZvlsseg];
2020
}
2121

2222
//===----------------------------------------------------------------------===//

llvm/lib/Target/RISCV/RISCVSubtarget.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class RISCVSubtarget : public RISCVGenSubtargetInfo {
5151
bool HasStdExtZbt = false;
5252
bool HasStdExtZbproposedc = false;
5353
bool HasStdExtV = false;
54+
bool HasStdExtZvlsseg = false;
5455
bool HasRV64 = false;
5556
bool IsRV32E = false;
5657
bool EnableLinkerRelax = false;
@@ -112,6 +113,7 @@ class RISCVSubtarget : public RISCVGenSubtargetInfo {
112113
bool hasStdExtZbt() const { return HasStdExtZbt; }
113114
bool hasStdExtZbproposedc() const { return HasStdExtZbproposedc; }
114115
bool hasStdExtV() const { return HasStdExtV; }
116+
bool hasStdExtZvlsseg() const { return HasStdExtZvlsseg; }
115117
bool is64Bit() const { return HasRV64; }
116118
bool isRV32E() const { return IsRV32E; }
117119
bool enableLinkerRelax() const { return EnableLinkerRelax; }

0 commit comments

Comments
 (0)