diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoZc.td b/llvm/lib/Target/RISCV/RISCVInstrInfoZc.td --- a/llvm/lib/Target/RISCV/RISCVInstrInfoZc.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoZc.td @@ -129,10 +129,16 @@ let Constraints = "$rd = $rd_wb"; } -class RVInstZcCPPP - : RVInst16 { +class RVInstZcCPPP funct5, string opcodestr> + : RVInst16<(outs), (ins rlist:$rlist, spimm:$spimm), + opcodestr, "{$rlist}, $spimm", [], InstFormatOther> { + bits<4> rlist; + bits<16> spimm; let Inst{1-0} = 0b10; + let Inst{3-2} = spimm{5-4}; + let Inst{7-4} = rlist; + let Inst{12-8} = funct5; let Inst{15-13} = 0b101; } @@ -189,49 +195,17 @@ } // DecoderNamespace = "RVZcmp", Predicates = [HasStdExtZcmp]... let DecoderNamespace = "RVZcmp", Predicates = [HasStdExtZcmp] in { -let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in -def CM_PUSH : RVInstZcCPPP<(outs), (ins rlist:$rlist, spimm:$spimm), - "cm.push", "{$rlist}, $spimm"> { - bits<4> rlist; - bits<16> spimm; - - let Inst{12-8} = 0b11000; - let Inst{7-4} = rlist; - let Inst{3-2} = spimm{5-4}; -} - -let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in -def CM_POPRET : RVInstZcCPPP<(outs), (ins rlist:$rlist, spimm:$spimm), - "cm.popret", "{$rlist}, $spimm"> { - bits<4> rlist; - bits<16> spimm; - - let Inst{12-8} = 0b11110; - let Inst{7-4} = rlist; - let Inst{3-2} = spimm{5-4}; -} - -let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in -def CM_POPRETZ : RVInstZcCPPP<(outs), (ins rlist:$rlist, spimm:$spimm), - "cm.popretz", "{$rlist}, $spimm"> { - bits<4> rlist; - bits<16> spimm; +let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in +def CM_PUSH : RVInstZcCPPP<0b11000, "cm.push">; - let Inst{12-8} = 0b11100; - let Inst{7-4} = rlist; - let Inst{3-2} = spimm{5-4}; -} +let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in +def CM_POPRET : RVInstZcCPPP<0b11110, "cm.popret">; -let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in -def CM_POP : RVInstZcCPPP<(outs), (ins rlist:$rlist, spimm:$spimm), - "cm.pop", "{$rlist}, $spimm"> { - bits<4> rlist; - bits<16> spimm; +let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in +def CM_POPRETZ : RVInstZcCPPP<0b11100, "cm.popretz">; - let Inst{12-8} = 0b11010; - let Inst{7-4} = rlist; - let Inst{3-2} = spimm{5-4}; -} +let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in +def CM_POP : RVInstZcCPPP<0b11010, "cm.pop">; } // DecoderNamespace = "RVZcmp", Predicates = [HasStdExtZcmp]... let DecoderNamespace = "RVZcmt", Predicates = [HasStdExtZcmt],