[llvm] 2398e26 - [RISCV] Add a common class for cm.push, cm.popret, cm.popretz and cm.pop.

Jim Lin via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 24 19:12:28 PDT 2023


Author: Jim Lin
Date: 2023-07-25T10:11:36+08:00
New Revision: 2398e260806f8beabe017e408225b30897b29198

URL: https://github.com/llvm/llvm-project/commit/2398e260806f8beabe017e408225b30897b29198
DIFF: https://github.com/llvm/llvm-project/commit/2398e260806f8beabe017e408225b30897b29198.diff

LOG: [RISCV] Add a common class for cm.push, cm.popret, cm.popretz and cm.pop.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D156092

Added: 
    

Modified: 
    llvm/lib/Target/RISCV/RISCVInstrInfoZc.td

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfoZc.td b/llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
index ff7cdeff98c70a..6687343086da61 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
@@ -129,10 +129,16 @@ class RVZcArith_r<bits<5> funct5, string OpcodeStr> :
   let Constraints = "$rd = $rd_wb";
 }
 
-class RVInstZcCPPP<dag outs, dag ins, string opcodestr, string argstr>
-    : RVInst16<outs, ins, opcodestr, argstr, [], InstFormatOther> {
+class RVInstZcCPPP<bits<5> 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 @@ def CM_MVSA01 : RVInst16CA<0b101011, 0b01, 0b10, (outs SR07:$rs1, SR07:$rs2),
 } // 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],


        


More information about the llvm-commits mailing list