@@ -98,6 +98,40 @@ class PLUI_i<bits<7> funct7, string opcodestr>
9898 let Inst{23-15} = imm10{9-1};
9999}
100100
101+ // Common base for widening Binary/Ternary ops
102+ class RVPWideningBase<bits<2> w, bit arith_shift, dag outs, dag ins,
103+ string opcodestr>
104+ : RVInst<outs, ins, opcodestr, "$rd, $rs1, $rs2", [], InstFormatOther> {
105+ bits<5> rs2;
106+ bits<5> rs1;
107+ bits<5> rd;
108+
109+ let Inst{31} = 0b0;
110+ let Inst{26-25} = w;
111+ let Inst{24-20} = rs2;
112+ let Inst{19-15} = rs1;
113+ let Inst{14-12} = 0b010;
114+ let Inst{11-8} = rd{4-1};
115+ let Inst{7} = arith_shift;
116+ let Inst{6-0} = OPC_OP_IMM_32.Value;
117+ }
118+
119+ // Common base for narrowing ops
120+ class RVPNarrowingBase<bits<3> f, bit r, bits<4> funct4, dag outs, dag ins,
121+ string opcodestr, string argstr>
122+ : RVInst<outs, ins, opcodestr, argstr, [], InstFormatOther> {
123+ bits<5> rs1;
124+ bits<5> rd;
125+
126+ let Inst{31} = 0b0;
127+ let Inst{30-28} = f;
128+ let Inst{27} = r;
129+ let Inst{19-16} = rs1{4-1};
130+ let Inst{15-12} = funct4;
131+ let Inst{11-7} = rd;
132+ let Inst{6-0} = OPC_OP_IMM_32.Value;
133+ }
134+
101135let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
102136class RVPShift_ri<bits<3> f, bits<3> funct3, string opcodestr, Operand ImmType>
103137 : RVInstIBase<funct3, OPC_OP_IMM_32, (outs GPR:$rd),
@@ -140,6 +174,100 @@ class RVPShiftB_ri<bits<3> f, bits<3> funct3, string opcodestr>
140174 let Inst{22-20} = shamt;
141175}
142176
177+ let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
178+ class RVPWideningShift_ri<bits<3> f, string opcodestr, Operand ImmType>
179+ : RVInst<(outs GPRPairRV32:$rd), (ins GPR:$rs1, ImmType:$shamt), opcodestr,
180+ "$rd, $rs1, $shamt", [], InstFormatOther> {
181+ bits<5> rs1;
182+ bits<5> rd;
183+
184+ let Inst{31} = 0b0;
185+ let Inst{30-28} = f;
186+ let Inst{27} = 0b0;
187+ let Inst{19-15} = rs1;
188+ let Inst{14-12} = 0b010;
189+ let Inst{11-8} = rd{4-1};
190+ let Inst{7} = 0b0;
191+ let Inst{6-0} = OPC_OP_IMM_32.Value;
192+
193+ let hasSideEffects = 0;
194+ let mayLoad = 0;
195+ let mayStore = 0;
196+ }
197+
198+ class RVPWideningShiftW_ri<bits<3> f, string opcodestr>
199+ : RVPWideningShift_ri<f, opcodestr, uimm6> {
200+ bits<6> shamt;
201+
202+ let Inst{26} = 0b1;
203+ let Inst{25-20} = shamt;
204+ }
205+
206+ class RVPWideningShiftH_ri<bits<3> f, string opcodestr>
207+ : RVPWideningShift_ri<f, opcodestr, uimm5> {
208+ bits<5> shamt;
209+
210+ let Inst{26-25} = 0b01;
211+ let Inst{24-20} = shamt;
212+ }
213+
214+ class RVPWideningShiftB_ri<bits<3> f, string opcodestr>
215+ : RVPWideningShift_ri<f, opcodestr, uimm4> {
216+ bits<4> shamt;
217+
218+ let Inst{26-24} = 0b001;
219+ let Inst{23-20} = shamt;
220+ }
221+
222+ let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
223+ class RVPNarrowingShift_ri<bits<3> f, string opcodestr, Operand ImmType>
224+ : RVPNarrowingBase<f, 0b0, 0b1100, (outs GPR:$rd),
225+ (ins GPRPairRV32:$rs1, ImmType:$shamt), opcodestr,
226+ "$rd, $rs1, $shamt">;
227+
228+ class RVPNarrowingShiftW_ri<bits<3> f, string opcodestr>
229+ : RVPNarrowingShift_ri<f, opcodestr, uimm6> {
230+ bits<6> shamt;
231+
232+ let Inst{26} = 0b1;
233+ let Inst{25-20} = shamt;
234+ }
235+
236+ class RVPNarrowingShiftH_ri<bits<3> f, string opcodestr>
237+ : RVPNarrowingShift_ri<f, opcodestr, uimm5> {
238+ bits<5> shamt;
239+
240+ let Inst{26-25} = 0b01;
241+ let Inst{24-20} = shamt;
242+ }
243+
244+ class RVPNarrowingShiftB_ri<bits<3> f, string opcodestr>
245+ : RVPNarrowingShift_ri<f, opcodestr, uimm4> {
246+ bits<4> shamt;
247+
248+ let Inst{26-24} = 0b001;
249+ let Inst{23-20} = shamt;
250+ }
251+
252+ let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
253+ class RVPNarrowingShift_rr<bits<3> f, bits<2> w, string opcodestr>
254+ : RVPNarrowingBase<f, 0b1, 0b1100, (outs GPR:$rd),
255+ (ins GPRPairRV32:$rs1, GPR:$rs2), opcodestr,
256+ "$rd, $rs1, $rs2"> {
257+ bits<5> rs2;
258+
259+ let Inst{26-25} = w;
260+ let Inst{24-20} = rs2;
261+ }
262+
263+ let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
264+ class RVPWideningShift_rr<bits<3> f, bits<2> w, string opcodestr>
265+ : RVPWideningBase<w, 0b0, (outs GPRPairRV32:$rd), (ins GPR:$rs1, GPR:$rs2),
266+ opcodestr> {
267+ let Inst{30-28} = f;
268+ let Inst{27} = 0b1;
269+ }
270+
143271let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
144272class RVPUnary_ri<bits<2> w, bits<5> uf, string opcodestr>
145273 : RVInstIBase<0b010, OPC_OP_IMM_32, (outs GPR:$rd), (ins GPR:$rs1),
@@ -168,6 +296,24 @@ class RVPBinary_rr<bits<4> f, bits<2> w, bits<3> funct3, string opcodestr>
168296 let Inst{26-25} = w;
169297}
170298
299+ let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
300+ class RVPWideningBinary_rr<bits<4> f, bits<2> w, string opcodestr>
301+ : RVPWideningBase<w, 0b1, (outs GPRPairRV32:$rd), (ins GPR:$rs1, GPR:$rs2),
302+ opcodestr> {
303+ let Inst{30-27} = f;
304+ }
305+
306+ let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
307+ class RVPNarrowingBinary_rr<bits<3> f, bits<2> w, string opcodestr>
308+ : RVPNarrowingBase<f, 0b1, 0b0100, (outs GPR:$rd),
309+ (ins GPRPairRV32:$rs1, GPR:$rs2), opcodestr,
310+ "$rd, $rs1, $rs2"> {
311+ bits<5> rs2;
312+
313+ let Inst{26-25} = w;
314+ let Inst{24-20} = rs2;
315+ }
316+
171317let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
172318class RVPTernary_rrr<bits<4> f, bits<2> w, bits<3> funct3, string opcodestr>
173319 : RVInstRBase<funct3, OPC_OP_32, (outs GPR:$rd_wb),
@@ -180,6 +326,15 @@ class RVPTernary_rrr<bits<4> f, bits<2> w, bits<3> funct3, string opcodestr>
180326 let Constraints = "$rd = $rd_wb";
181327}
182328
329+ let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
330+ class RVPWideningTernary_rrr<bits<4> f, bits<2> w, string opcodestr>
331+ : RVPWideningBase<w, 0b1, (outs GPRPairRV32:$rd_wb),
332+ (ins GPR:$rd, GPR:$rs1, GPR:$rs2), opcodestr> {
333+ let Inst{30-27} = f;
334+
335+ let Constraints = "$rd = $rd_wb";
336+ }
337+
183338// Common base for pli.db/h/w and plui.dh/w
184339class RVPPairLoadImm_i<bits<7> funct7, dag ins, string opcodestr,
185340 string argstr>
@@ -889,3 +1044,156 @@ let Predicates = [HasStdExtP, IsRV32] in {
8891044 let Inst{23-15} = imm10{9-1};
8901045 }
8911046}
1047+
1048+ let Predicates = [HasStdExtP, IsRV32] in {
1049+ def PWSLLI_B : RVPWideningShiftB_ri<0b000, "pwslli.b">;
1050+ def PWSLLI_H : RVPWideningShiftH_ri<0b000, "pwslli.h">;
1051+ def WSLLI : RVPWideningShiftW_ri<0b000, "wslli">;
1052+
1053+ def PWSLAI_B : RVPWideningShiftB_ri<0b100, "pwslai.b">;
1054+ def PWSLAI_H : RVPWideningShiftH_ri<0b100, "pwslai.h">;
1055+ def WSLAI : RVPWideningShiftW_ri<0b100, "wslai">;
1056+
1057+ def PWSLL_BS : RVPWideningShift_rr<0b000, 0b00, "pwsll.bs">;
1058+ def PWSLL_HS : RVPWideningShift_rr<0b000, 0b01, "pwsll.hs">;
1059+ def WSLL : RVPWideningShift_rr<0b000, 0b11, "wsll">;
1060+
1061+ def PWSLA_BS : RVPWideningShift_rr<0b100, 0b00, "pwsla.bs">;
1062+ def PWSLA_HS : RVPWideningShift_rr<0b100, 0b01, "pwsla.hs">;
1063+ def WSLA : RVPWideningShift_rr<0b100, 0b11, "wsla">;
1064+
1065+ def WZIP8P : RVPWideningShift_rr<0b111, 0b00, "wzip8p">;
1066+ def WZIP16P : RVPWideningShift_rr<0b111, 0b01, "wzip16p">;
1067+
1068+ def PWADD_H : RVPWideningBinary_rr<0b0000, 0b00, "pwadd.h">;
1069+ def WADD : RVPWideningBinary_rr<0b0000, 0b01, "wadd">;
1070+ def PWADD_B : RVPWideningBinary_rr<0b0000, 0b10, "pwadd.b">;
1071+ def PM2WADD_H : RVPWideningBinary_rr<0b0000, 0b11, "pm2wadd.h">;
1072+
1073+ def PWADDA_H : RVPWideningTernary_rrr<0b0001, 0b00, "pwadda.h">;
1074+ def WADDA : RVPWideningTernary_rrr<0b0001, 0b01, "wadda">;
1075+ def PWADDA_B : RVPWideningTernary_rrr<0b0001, 0b10, "pwadda.b">;
1076+ def PM2WADDA_H : RVPWideningTernary_rrr<0b0001, 0b11, "pm2wadda.h">;
1077+
1078+ def PWADDU_H : RVPWideningBinary_rr<0b0010, 0b00, "pwaddu.h">;
1079+ def WADDU : RVPWideningBinary_rr<0b0010, 0b01, "waddu">;
1080+ def PWADDU_B : RVPWideningBinary_rr<0b0010, 0b10, "pwaddu.b">;
1081+ def PM2WADD_HX : RVPWideningBinary_rr<0b0010, 0b11, "pm2wadd.hx">;
1082+
1083+ def PWADDAU_H : RVPWideningTernary_rrr<0b0011, 0b00, "pwaddau.h">;
1084+ def WADDAU : RVPWideningTernary_rrr<0b0011, 0b01, "waddau">;
1085+ def PWADDAU_B : RVPWideningTernary_rrr<0b0011, 0b10, "pwaddau.b">;
1086+ def PM2WADDA_HX : RVPWideningTernary_rrr<0b0011, 0b11, "pm2wadda.hx">;
1087+
1088+ def PWMUL_H : RVPWideningBinary_rr<0b0100, 0b00, "pwmul.h">;
1089+ def WMUL : RVPWideningBinary_rr<0b0100, 0b01, "wmul">;
1090+ def PWMUL_B : RVPWideningBinary_rr<0b0100, 0b10, "pwmul.b">;
1091+ def PM2WADDU_H : RVPWideningBinary_rr<0b0100, 0b11, "pm2waddu.h">;
1092+
1093+ def PWMACC_H : RVPWideningTernary_rrr<0b0101, 0b00, "pwmacc.h">;
1094+ def WMACC : RVPWideningTernary_rrr<0b0101, 0b01, "wmacc">;
1095+ def PM2WADDAU_H : RVPWideningTernary_rrr<0b0101, 0b11, "pm2waddau.h">;
1096+
1097+ def PWMULU_H : RVPWideningBinary_rr<0b0110, 0b00, "pwmulu.h">;
1098+ def WMULU : RVPWideningBinary_rr<0b0110, 0b01, "wmulu">;
1099+ def PWMULU_B : RVPWideningBinary_rr<0b0110, 0b10, "pwmulu.b">;
1100+
1101+ def PWMACCU_H : RVPWideningTernary_rrr<0b0111, 0b00, "pwmaccu.h">;
1102+ def WMACCU : RVPWideningTernary_rrr<0b0111, 0b01, "wmaccu">;
1103+
1104+ def PWSUB_H : RVPWideningBinary_rr<0b1000, 0b00, "pwsub.h">;
1105+ def WSUB : RVPWideningBinary_rr<0b1000, 0b01, "wsub">;
1106+ def PWSUB_B : RVPWideningBinary_rr<0b1000, 0b10, "pwsub.b">;
1107+ def PM2WSUB_H : RVPWideningBinary_rr<0b1000, 0b11, "pm2wsub.h">;
1108+
1109+ def PWSUBA_H : RVPWideningTernary_rrr<0b1001, 0b00, "pwsuba.h">;
1110+ def WSUBA : RVPWideningTernary_rrr<0b1001, 0b01, "wsuba">;
1111+ def PWSUBA_B : RVPWideningTernary_rrr<0b1001, 0b10, "pwsuba.b">;
1112+ def PM2WSUBA_H : RVPWideningTernary_rrr<0b1001, 0b11, "pm2wsuba.h">;
1113+
1114+ def PWSUBU_H : RVPWideningBinary_rr<0b1010, 0b00, "pwsubu.h">;
1115+ def WSUBU : RVPWideningBinary_rr<0b1010, 0b01, "wsubu">;
1116+ def PWSUBU_B : RVPWideningBinary_rr<0b1010, 0b10, "pwsubu.b">;
1117+ def PM2WSUB_HX : RVPWideningBinary_rr<0b1010, 0b11, "pm2wsub.hx">;
1118+
1119+ def PWSUBAU_H : RVPWideningTernary_rrr<0b1011, 0b00, "pwsubau.h">;
1120+ def WSUBAU : RVPWideningTernary_rrr<0b1011, 0b01, "wsubau">;
1121+ def PWSUBAU_B : RVPWideningTernary_rrr<0b1011, 0b10, "pwsubau.b">;
1122+ def PM2WSUBA_HX : RVPWideningTernary_rrr<0b1011, 0b11, "pm2wsuba.hx">;
1123+
1124+ def PWMULSU_H : RVPWideningBinary_rr<0b1100, 0b00, "pwmulsu.h">;
1125+ def WMULSU : RVPWideningBinary_rr<0b1100, 0b01, "wmulsu">;
1126+ def PWMULSU_B : RVPWideningBinary_rr<0b1100, 0b10, "pwmulsu.b">;
1127+ def PM2WADDSU_H : RVPWideningBinary_rr<0b1100, 0b11, "pm2waddsu.h">;
1128+
1129+ def PWMACCSU_H : RVPWideningTernary_rrr<0b1101, 0b00, "pwmaccsu.h">;
1130+ def WMACCSU : RVPWideningTernary_rrr<0b1101, 0b01, "wmaccsu">;
1131+ def PM2WADDASU_H : RVPWideningTernary_rrr<0b1101, 0b11, "pm2waddasu.h">;
1132+
1133+ def PMQWACC_H : RVPWideningTernary_rrr<0b1111, 0b00, "pmqwacc.h">;
1134+ def PMQWACC : RVPWideningTernary_rrr<0b1111, 0b01, "pmqwacc">;
1135+ def PMQRWACC_H : RVPWideningTernary_rrr<0b1111, 0b10, "pmqrwacc.h">;
1136+ def PMQRWACC : RVPWideningTernary_rrr<0b1111, 0b11, "pmqrwacc">;
1137+
1138+ def PREDSUM_DHS : RVPNarrowingBinary_rr<0b001, 0b00, "predsum.dhs">;
1139+ def PREDSUM_DBS : RVPNarrowingBinary_rr<0b001, 0b10, "predsum.dbs">;
1140+
1141+ def PREDSUMU_DHS : RVPNarrowingBinary_rr<0b011, 0b00, "predsumu.dhs">;
1142+ def PREDSUMU_DBS : RVPNarrowingBinary_rr<0b011, 0b10, "predsumu.dbs">;
1143+
1144+ def PNSRLI_B : RVPNarrowingShiftB_ri<0b000, "pnsrli.b">;
1145+ def PNSRLI_H : RVPNarrowingShiftH_ri<0b000, "pnsrli.h">;
1146+ def NSRLI : RVPNarrowingShiftW_ri<0b000, "nsrli">;
1147+
1148+ def PNCLIPIU_B : RVPNarrowingShiftB_ri<0b010, "pnclipiu.b">;
1149+ def PNCLIPIU_H : RVPNarrowingShiftH_ri<0b010, "pnclipiu.h">;
1150+ def NCLIPIU : RVPNarrowingShiftW_ri<0b010, "nclipiu">;
1151+
1152+ def PNCLIPRIU_B : RVPNarrowingShiftB_ri<0b011, "pnclipriu.b">;
1153+ def PNCLIPRIU_H : RVPNarrowingShiftH_ri<0b011, "pnclipriu.h">;
1154+ def NCLIPRIU : RVPNarrowingShiftW_ri<0b011, "nclipriu">;
1155+
1156+ def PNSRAI_B : RVPNarrowingShiftB_ri<0b100, "pnsrai.b">;
1157+ def PNSRAI_H : RVPNarrowingShiftH_ri<0b100, "pnsrai.h">;
1158+ def NSRAI : RVPNarrowingShiftW_ri<0b100, "nsrai">;
1159+
1160+ def PNSARI_B : RVPNarrowingShiftB_ri<0b101, "pnsari.b">;
1161+ def PNSARI_H : RVPNarrowingShiftH_ri<0b101, "pnsari.h">;
1162+ def NSARI : RVPNarrowingShiftW_ri<0b101, "nsari">;
1163+
1164+ def PNCLIPI_B : RVPNarrowingShiftB_ri<0b110, "pnclipi.b">;
1165+ def PNCLIPI_H : RVPNarrowingShiftH_ri<0b110, "pnclipi.h">;
1166+ def NCLIPI : RVPNarrowingShiftW_ri<0b110, "nclipi">;
1167+
1168+ def PNCLIPRI_B : RVPNarrowingShiftB_ri<0b111, "pnclipri.b">;
1169+ def PNCLIPRI_H : RVPNarrowingShiftH_ri<0b111, "pnclipri.h">;
1170+ def NCLIPRI : RVPNarrowingShiftW_ri<0b111, "nclipri">;
1171+
1172+ def PNSRL_BS : RVPNarrowingShift_rr<0b000, 0b00, "pnsrl.bs">;
1173+ def PNSRL_HS : RVPNarrowingShift_rr<0b000, 0b01, "pnsrl.hs">;
1174+ def NSRL : RVPNarrowingShift_rr<0b000, 0b11, "nsrl">;
1175+
1176+ def PNCLIPU_BS : RVPNarrowingShift_rr<0b010, 0b00, "pnclipu.bs">;
1177+ def PNCLIPU_HS : RVPNarrowingShift_rr<0b010, 0b01, "pnclipu.hs">;
1178+ def NCLIPU : RVPNarrowingShift_rr<0b010, 0b11, "nclipu">;
1179+
1180+ def PNCLIPRU_BS : RVPNarrowingShift_rr<0b011, 0b00, "pnclipru.bs">;
1181+ def PNCLIPRU_HS : RVPNarrowingShift_rr<0b011, 0b01, "pnclipru.hs">;
1182+ def NCLIPRU : RVPNarrowingShift_rr<0b011, 0b11, "nclipru">;
1183+
1184+ def PNSRA_BS : RVPNarrowingShift_rr<0b100, 0b00, "pnsra.bs">;
1185+ def PNSRA_HS : RVPNarrowingShift_rr<0b100, 0b01, "pnsra.hs">;
1186+ def NSRA : RVPNarrowingShift_rr<0b100, 0b11, "nsra">;
1187+
1188+ def PNSRAR_BS : RVPNarrowingShift_rr<0b101, 0b00, "pnsrar.bs">;
1189+ def PNSRAR_HS : RVPNarrowingShift_rr<0b101, 0b01, "pnsrar.hs">;
1190+ def NSRAR : RVPNarrowingShift_rr<0b101, 0b11, "nsrar">;
1191+
1192+ def PNCLIP_BS : RVPNarrowingShift_rr<0b110, 0b00, "pnclip.bs">;
1193+ def PNCLIP_HS : RVPNarrowingShift_rr<0b110, 0b01, "pnclip.hs">;
1194+ def NCLIP : RVPNarrowingShift_rr<0b110, 0b11, "nclip">;
1195+
1196+ def PNCLIPR_BS : RVPNarrowingShift_rr<0b111, 0b00, "pnclipr.bs">;
1197+ def PNCLIPR_HS : RVPNarrowingShift_rr<0b111, 0b01, "pnclipr.hs">;
1198+ def NCLIPR : RVPNarrowingShift_rr<0b111, 0b11, "nclipr">;
1199+ } // Predicates = [HasStdExtP, IsRV32]
0 commit comments