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