@@ -149,6 +149,15 @@ class RVPBinaryScalar_rr<bits<3> f, bits<2> w, bits<3> funct3, string opcodestr>
149149 let Inst{26-25} = w;
150150}
151151
152+ let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
153+ class RVPBinary_rr<bits<4> f, bits<2> w, bits<3> funct3, string opcodestr>
154+ : RVInstRBase<funct3, OPC_OP_32, (outs GPR:$rd),
155+ (ins GPR:$rs1, GPR:$rs2), opcodestr, "$rd, $rs1, $rs2"> {
156+ let Inst{31} = 0b1;
157+ let Inst{30-27} = f;
158+ let Inst{26-25} = w;
159+ }
160+
152161//===----------------------------------------------------------------------===//
153162// Instructions
154163//===----------------------------------------------------------------------===//
@@ -292,3 +301,250 @@ let Predicates = [HasStdExtP, IsRV64] in {
292301
293302 def PSRA_WS : RVPBinaryScalar_rr<0b100, 0b01, 0b100, "psra.ws">;
294303} // Predicates = [HasStdExtP, IsRV64]
304+
305+ let Predicates = [HasStdExtP] in {
306+ def PADD_H : RVPBinary_rr<0b0000, 0b00, 0b000, "padd.h">;
307+ def PADD_B : RVPBinary_rr<0b0000, 0b10, 0b000, "padd.b">;
308+
309+ def PSADD_H : RVPBinary_rr<0b0010, 0b00, 0b000, "psadd.h">;
310+ def PSADD_B : RVPBinary_rr<0b0010, 0b10, 0b000, "psadd.b">;
311+
312+ def PAADD_H : RVPBinary_rr<0b0011, 0b00, 0b000, "paadd.h">;
313+ def PAADD_B : RVPBinary_rr<0b0011, 0b10, 0b000, "paadd.b">;
314+
315+ def PSADDU_H : RVPBinary_rr<0b0110, 0b00, 0b000, "psaddu.h">;
316+ def PSADDU_B : RVPBinary_rr<0b0110, 0b10, 0b000, "psaddu.b">;
317+
318+ def PAADDU_H : RVPBinary_rr<0b0111, 0b00, 0b000, "paaddu.h">;
319+ def PAADDU_B : RVPBinary_rr<0b0111, 0b10, 0b000, "paaddu.b">;
320+
321+ def PSUB_H : RVPBinary_rr<0b1000, 0b00, 0b000, "psub.h">;
322+ def PSUB_B : RVPBinary_rr<0b1000, 0b10, 0b000, "psub.b">;
323+
324+ def PDIF_H : RVPBinary_rr<0b1001, 0b00, 0b000, "pdif.h">;
325+ def PDIF_B : RVPBinary_rr<0b1001, 0b10, 0b000, "pdif.b">;
326+
327+ def PSSUB_H : RVPBinary_rr<0b1010, 0b00, 0b000, "pssub.h">;
328+ def PSSUB_B : RVPBinary_rr<0b1010, 0b10, 0b000, "pssub.b">;
329+
330+ def PASUB_H : RVPBinary_rr<0b1011, 0b00, 0b000, "pasub.h">;
331+ def PASUB_B : RVPBinary_rr<0b1011, 0b10, 0b000, "pasub.b">;
332+
333+ def PDIFU_H : RVPBinary_rr<0b1101, 0b00, 0b000, "pdifu.h">;
334+ def PDIFU_B : RVPBinary_rr<0b1101, 0b10, 0b000, "pdifu.b">;
335+
336+ def PSSUBU_H : RVPBinary_rr<0b1110, 0b00, 0b000, "pssubu.h">;
337+ def PSSUBU_B : RVPBinary_rr<0b1110, 0b10, 0b000, "pssubu.b">;
338+
339+ def PASUBU_H : RVPBinary_rr<0b1111, 0b00, 0b000, "pasubu.h">;
340+ def PASUBU_B : RVPBinary_rr<0b1111, 0b10, 0b000, "pasubu.b">;
341+ } // Predicates = [HasStdExtP]
342+ let Predicates = [HasStdExtP, IsRV32], DecoderNamespace = "RV32Only" in {
343+ def SADD : RVPBinary_rr<0b0010, 0b01, 0b000, "sadd">;
344+
345+ def AADD : RVPBinary_rr<0b0011, 0b01, 0b000, "aadd">;
346+
347+ def SADDU : RVPBinary_rr<0b0110, 0b01, 0b000, "saddu">;
348+
349+ def AADDU : RVPBinary_rr<0b0111, 0b01, 0b000, "aaddu">;
350+
351+ def SSUB : RVPBinary_rr<0b1010, 0b01, 0b000, "ssub">;
352+
353+ def ASUB : RVPBinary_rr<0b1011, 0b01, 0b000, "asub">;
354+
355+ def SSUBU : RVPBinary_rr<0b1110, 0b01, 0b000, "ssubu">;
356+
357+ def ASUBU : RVPBinary_rr<0b1111, 0b01, 0b000, "asubu">;
358+ } // Predicates = [HasStdExtP, IsRV32], DecoderNamespace = "RV32Only"
359+ let Predicates = [HasStdExtP, IsRV64] in {
360+ def PADD_W : RVPBinary_rr<0b0000, 0b01, 0b000, "padd.w">;
361+
362+ def PSADD_W : RVPBinary_rr<0b0010, 0b01, 0b000, "psadd.w">;
363+
364+ def PAADD_W : RVPBinary_rr<0b0011, 0b01, 0b000, "paadd.w">;
365+
366+ def PSADDU_W : RVPBinary_rr<0b0110, 0b01, 0b000, "psaddu.w">;
367+
368+ def PAADDU_W : RVPBinary_rr<0b0111, 0b01, 0b000, "paaddu.w">;
369+
370+ def PSUB_W : RVPBinary_rr<0b1000, 0b01, 0b000, "psub.w">;
371+
372+ def PSSUB_W : RVPBinary_rr<0b1010, 0b01, 0b000, "pssub.w">;
373+
374+ def PASUB_W : RVPBinary_rr<0b1011, 0b01, 0b000, "pasub.w">;
375+
376+ def PSSUBU_W : RVPBinary_rr<0b1110, 0b01, 0b000, "pssubu.w">;
377+
378+ def PASUBU_W : RVPBinary_rr<0b1111, 0b01, 0b000, "pasubu.w">;
379+ } // Predicates = [HasStdExtP, IsRV64]
380+
381+ let Predicates = [HasStdExtP] in {
382+ def SLX : RVPBinary_rr<0b0001, 0b11, 0b001, "slx">;
383+
384+ def PMUL_H_B01 : RVPBinary_rr<0b0010, 0b00, 0b001, "pmul.h.b01">;
385+
386+ def MVM : RVPBinary_rr<0b0101, 0b00, 0b001, "mvm">;
387+ def MVMN : RVPBinary_rr<0b0101, 0b01, 0b001, "mvmn">;
388+ def MERGE : RVPBinary_rr<0b0101, 0b10, 0b001, "merge">;
389+ def SRX : RVPBinary_rr<0b0101, 0b11, 0b001, "srx">;
390+
391+ def PMULU_H_B01 : RVPBinary_rr<0b0110, 0b00, 0b001, "pmulu.h.b01">;
392+ def PDIFSUMU_B : RVPBinary_rr<0b0110, 0b10, 0b001, "pdifsumu.b">;
393+
394+ def PDIFSUMAU_B : RVPBinary_rr<0b0111, 0b10, 0b001, "pdifsumau.b">;
395+ } // Predicates = [HasStdExtP]
396+ let Predicates = [HasStdExtP, IsRV32], DecoderNamespace = "RV32Only" in {
397+ def MUL_H01 : RVPBinary_rr<0b0010, 0b01, 0b001, "mul.h01">;
398+
399+ def MACC_H01 : RVPBinary_rr<0b0011, 0b01, 0b001, "macc.h01">;
400+
401+ def MULU_H01 : RVPBinary_rr<0b0110, 0b01, 0b001, "mulu.h01">;
402+
403+ def MACCU_H01 : RVPBinary_rr<0b0111, 0b01, 0b001, "maccu.h01">;
404+ } // Predicates = [HasStdExtP, IsRV32], DecoderNamespace = "RV32Only"
405+ let Predicates = [HasStdExtP, IsRV64] in {
406+ def PMUL_W_H01 : RVPBinary_rr<0b0010, 0b01, 0b001, "pmul.w.h01">;
407+ def MUL_W01 : RVPBinary_rr<0b0010, 0b11, 0b001, "mul.w01">;
408+
409+ def PMACC_W_H01 : RVPBinary_rr<0b0011, 0b01, 0b001, "pmacc.w.h01">;
410+ def MACC_W01 : RVPBinary_rr<0b0011, 0b11, 0b001, "macc.w01">;
411+
412+ def PMULU_W_H01 : RVPBinary_rr<0b0110, 0b01, 0b001, "pmulu.w.h01">;
413+ def MULU_W01 : RVPBinary_rr<0b0110, 0b11, 0b001, "mulu.w01">;
414+
415+ def PMACCU_W_H01 : RVPBinary_rr<0b0111, 0b01, 0b001, "pmaccu.w.h01">;
416+ def MACCU_W01 : RVPBinary_rr<0b0111, 0b11, 0b001, "maccu.w01">;
417+ } // Predicates = [HasStdExtP, IsRV64]
418+
419+ // Note the spec has a 3-bit f field in bits 30:28 with 0 in bit 27.
420+ // Here we include the 0 in the f field to reduce number of tablegen classes.
421+ let Predicates = [HasStdExtP] in {
422+ def PSH1ADD_H : RVPBinary_rr<0b0100, 0b00, 0b010, "psh1add.h">;
423+
424+ def PSSH1SADD_H : RVPBinary_rr<0b0110, 0b00, 0b010, "pssh1sadd.h">;
425+ } // Predicates = [HasStdExtP]
426+ let Predicates = [HasStdExtP, IsRV32], DecoderNamespace = "RV32Only" in {
427+ def SSH1SADD : RVPBinary_rr<0b0110, 0b01, 0b010, "ssh1sadd">;
428+ } // Predicates = [HasStdExtP, IsRV32], DecoderNamespace = "RV32Only"
429+ let Predicates = [HasStdExtP, IsRV64] in {
430+ def PSH1ADD_W : RVPBinary_rr<0b0100, 0b01, 0b010, "psh1add.w">;
431+
432+ def PSSH1SADD_W : RVPBinary_rr<0b0110, 0b01, 0b010, "pssh1sadd.w">;
433+
434+ def UNZIP8P : RVPBinary_rr<0b1100, 0b00, 0b010, "unzip8p">;
435+ def UNZIP16P : RVPBinary_rr<0b1100, 0b01, 0b010, "unzip16p">;
436+ def UNZIP8HP : RVPBinary_rr<0b1100, 0b10, 0b010, "unzip8hp">;
437+ def UNZIP16HP : RVPBinary_rr<0b1100, 0b11, 0b010, "unzip16hp">;
438+
439+ def ZIP8P : RVPBinary_rr<0b1110, 0b00, 0b010, "zip8p">;
440+ def ZIP16P : RVPBinary_rr<0b1110, 0b01, 0b010, "zip16p">;
441+ def ZIP8HP : RVPBinary_rr<0b1110, 0b10, 0b010, "zip8hp">;
442+ def ZIP16HP : RVPBinary_rr<0b1110, 0b11, 0b010, "zip16hp">;
443+ } // Predicates = [HasStdExtP, IsRV64]
444+
445+ let Predicates = [HasStdExtP] in {
446+ def PMUL_H_B00 : RVPBinary_rr<0b0000, 0b00, 0b011, "pmul.h.b00">;
447+
448+ def PMUL_H_B11 : RVPBinary_rr<0b0010, 0b00, 0b011, "pmul.h.b11">;
449+
450+ def PMULU_H_B00 : RVPBinary_rr<0b0100, 0b00, 0b011, "pmulu.h.b00">;
451+
452+ def PMULU_H_B11 : RVPBinary_rr<0b0110, 0b00, 0b011, "pmulu.h.b11">;
453+
454+ def PMULSU_H_B00 : RVPBinary_rr<0b1100, 0b00, 0b011, "pmulsu.h.b00">;
455+
456+ def PMULSU_H_B11 : RVPBinary_rr<0b1110, 0b00, 0b011, "pmulsu.h.b11">;
457+ } // Predicates = [HasStdExtP]
458+ let Predicates = [HasStdExtP, IsRV32], DecoderNamespace = "RV32Only" in {
459+ def MUL_H00 : RVPBinary_rr<0b0000, 0b01, 0b011, "mul.h00">;
460+
461+ def MACC_H00 : RVPBinary_rr<0b0001, 0b01, 0b011, "macc.h00">;
462+
463+ def MUL_H11 : RVPBinary_rr<0b0010, 0b01, 0b011, "mul.h11">;
464+
465+ def MACC_H11 : RVPBinary_rr<0b0011, 0b01, 0b011, "macc.h11">;
466+
467+ def MULU_H00 : RVPBinary_rr<0b0100, 0b01, 0b011, "mulu.h00">;
468+
469+ def MACCU_H00 : RVPBinary_rr<0b0101, 0b01, 0b011, "maccu.h00">;
470+
471+ def MULU_H11 : RVPBinary_rr<0b0110, 0b01, 0b011, "mulu.h11">;
472+
473+ def MACCU_H11 : RVPBinary_rr<0b0111, 0b01, 0b011, "maccu.h11">;
474+
475+ def MULSU_H00 : RVPBinary_rr<0b1100, 0b01, 0b011, "mulsu.h00">;
476+
477+ def MACCSU_H00 : RVPBinary_rr<0b1101, 0b01, 0b011, "maccsu.h00">;
478+
479+ def MULSU_H11 : RVPBinary_rr<0b1110, 0b01, 0b011, "mulsu.h11">;
480+
481+ def MACCSU_H11 : RVPBinary_rr<0b1111, 0b01, 0b011, "maccsu.h11">;
482+ } // Predicates = [HasStdExtP, IsRV32], DecoderNamespace = "RV32Only"
483+ let Predicates = [HasStdExtP, IsRV64] in {
484+ def PMUL_W_H00 : RVPBinary_rr<0b0000, 0b01, 0b011, "pmul.w.h00">;
485+ def MUL_W00 : RVPBinary_rr<0b0000, 0b11, 0b011, "mul.w00">;
486+
487+ def PMACC_W_H00 : RVPBinary_rr<0b0001, 0b01, 0b011, "pmacc.w.h00">;
488+ def MACC_W00 : RVPBinary_rr<0b0001, 0b11, 0b011, "macc.w00">;
489+
490+ def PMUL_W_H11 : RVPBinary_rr<0b0010, 0b01, 0b011, "pmul.w.h11">;
491+ def MUL_W11 : RVPBinary_rr<0b0010, 0b11, 0b011, "mul.w11">;
492+
493+ def PMACC_W_H11 : RVPBinary_rr<0b0011, 0b01, 0b011, "pmacc.w.h11">;
494+ def MACC_W11 : RVPBinary_rr<0b0011, 0b11, 0b011, "macc.w11">;
495+
496+ def PMULU_W_H00 : RVPBinary_rr<0b0100, 0b01, 0b011, "pmulu.w.h00">;
497+ def MULU_W00 : RVPBinary_rr<0b0100, 0b11, 0b011, "mulu.w00">;
498+
499+ def PMACCU_W_H00 : RVPBinary_rr<0b0101, 0b01, 0b011, "pmaccu.w.h00">;
500+ def MACCU_W00 : RVPBinary_rr<0b0101, 0b11, 0b011, "maccu.w00">;
501+
502+ def PMULU_W_H11 : RVPBinary_rr<0b0110, 0b01, 0b011, "pmulu.w.h11">;
503+ def MULU_W11 : RVPBinary_rr<0b0110, 0b11, 0b011, "mulu.w11">;
504+
505+ def PMACCU_W_H11 : RVPBinary_rr<0b0111, 0b01, 0b011, "pmaccu.w.h11">;
506+ def MACCU_W11 : RVPBinary_rr<0b0111, 0b11, 0b011, "maccu.w11">;
507+
508+ def PMULSU_W_H00 : RVPBinary_rr<0b1100, 0b01, 0b011, "pmulsu.w.h00">;
509+ def MULSU_W00 : RVPBinary_rr<0b1100, 0b11, 0b011, "mulsu.w00">;
510+
511+ def PMACCSU_W_H00 : RVPBinary_rr<0b1101, 0b01, 0b011, "pmaccsu.w.h00">;
512+ def MACCSU_W00 : RVPBinary_rr<0b1101, 0b11, 0b011, "maccsu.w00">;
513+
514+ def PMULSU_W_H11 : RVPBinary_rr<0b1110, 0b01, 0b011, "pmulsu.w.h11">;
515+ def MULSU_W11 : RVPBinary_rr<0b1110, 0b11, 0b011, "mulsu.w11">;
516+
517+ def PMACCSU_W_H11 : RVPBinary_rr<0b1111, 0b01, 0b011, "pmaccsu.w.h11">;
518+ def MACCSU_W11 : RVPBinary_rr<0b1111, 0b11, 0b011, "maccsu.w11">;
519+ } // Predicates = [HasStdExtP, IsRV64]
520+
521+ // Note the spec has a 3-bit f field in bits 30:28 with 0 in bit 27.
522+ // Here we include the 0 in the f field to reduce number of tablegen classes.
523+ let Predicates = [HasStdExtP] in {
524+ def PPACK_H : RVPBinary_rr<0b0000, 0b00, 0b100, "ppack.h">;
525+
526+ def PPACKBT_H : RVPBinary_rr<0b0010, 0b00, 0b100, "ppackbt.h">;
527+
528+ def PPACKTB_H : RVPBinary_rr<0b0100, 0b00, 0b100, "ppacktb.h">;
529+
530+ def PPACKT_H : RVPBinary_rr<0b0110, 0b00, 0b100, "ppackt.h">;
531+ } // Predicates = [HasStdExtP]
532+ let Predicates = [HasStdExtP, IsRV32], DecoderNamespace = "RV32Only" in {
533+ def PACKBT_RV32 : RVPBinary_rr<0b0010, 0b01, 0b100, "packbt">;
534+
535+ def PACKTB_RV32 : RVPBinary_rr<0b0100, 0b01, 0b100, "packtb">;
536+
537+ def PACKT_RV32 : RVPBinary_rr<0b0110, 0b01, 0b100, "packt">;
538+ } // Predicates = [HasStdExtP, IsRV32], DecoderNamespace = "RV32Only"
539+ let Predicates = [HasStdExtP, IsRV64] in {
540+ def PPACK_W : RVPBinary_rr<0b0000, 0b01, 0b100, "ppack.w">;
541+
542+ def PPACKBT_W : RVPBinary_rr<0b0010, 0b01, 0b100, "ppackbt.w">;
543+ def PACKBT_RV64 : RVPBinary_rr<0b0010, 0b11, 0b100, "packbt">;
544+
545+ def PPACKTB_W : RVPBinary_rr<0b0100, 0b01, 0b100, "ppacktb.w">;
546+ def PACKTB_RV64 : RVPBinary_rr<0b0100, 0b11, 0b100, "packtb">;
547+
548+ def PPACKT_W : RVPBinary_rr<0b0110, 0b01, 0b100, "ppackt.w">;
549+ def PACKT_RV64 : RVPBinary_rr<0b0110, 0b11, 0b100, "packt">;
550+ } // Predicates = [HasStdExtP, IsRV64]
0 commit comments