[llvm] 152fcf6 - [RISCV] Add validation of SPIMM for cm.push/pop. (#84989)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 28 08:38:23 PDT 2024
Author: Craig Topper
Date: 2024-03-28T08:38:18-07:00
New Revision: 152fcf6e77c9b83ac5cae1c0d7c0a9cf5680c7bd
URL: https://github.com/llvm/llvm-project/commit/152fcf6e77c9b83ac5cae1c0d7c0a9cf5680c7bd
DIFF: https://github.com/llvm/llvm-project/commit/152fcf6e77c9b83ac5cae1c0d7c0a9cf5680c7bd.diff
LOG: [RISCV] Add validation of SPIMM for cm.push/pop. (#84989)
This checks the immediate is a multiple of 16 bytes.
Added:
Modified:
llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
index c65b5121877254..92f405b5f6acbf 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
@@ -297,7 +297,8 @@ enum OperandType : unsigned {
OPERAND_RVKRNUM_0_7,
OPERAND_RVKRNUM_1_10,
OPERAND_RVKRNUM_2_14,
- OPERAND_LAST_RISCV_IMM = OPERAND_RVKRNUM_2_14,
+ OPERAND_SPIMM,
+ OPERAND_LAST_RISCV_IMM = OPERAND_SPIMM,
// Operand is either a register or uimm5, this is used by V extension pseudo
// instructions to represent a value that be passed as AVL to either vsetvli
// or vsetivli.
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
index 14c2d41e80f150..5582de51b17d19 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
@@ -2050,6 +2050,9 @@ bool RISCVInstrInfo::verifyInstruction(const MachineInstr &MI,
case RISCVOp::OPERAND_RVKRNUM_2_14:
Ok = Imm >= 2 && Imm <= 14;
break;
+ case RISCVOp::OPERAND_SPIMM:
+ Ok = (Imm & 0xf) == 0;
+ break;
}
if (!Ok) {
ErrInfo = "Invalid immediate";
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoZc.td b/llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
index a327bd3d0c28ae..2a4448d7881fb5 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
@@ -71,10 +71,11 @@ def rlist : Operand<OtherVT> {
}];
}
-def stackadj : Operand<OtherVT> {
+def stackadj : RISCVOp<OtherVT> {
let ParserMatchClass = StackAdjAsmOperand;
let PrintMethod = "printStackAdj";
let DecoderMethod = "decodeZcmpSpimm";
+ let OperandType = "OPERAND_SPIMM";
let MCOperandPredicate = [{
int64_t Imm;
if (!MCOp.evaluateAsConstantImm(Imm))
@@ -83,10 +84,11 @@ def stackadj : Operand<OtherVT> {
}];
}
-def negstackadj : Operand<OtherVT> {
+def negstackadj : RISCVOp<OtherVT> {
let ParserMatchClass = NegStackAdjAsmOperand;
let PrintMethod = "printNegStackAdj";
let DecoderMethod = "decodeZcmpSpimm";
+ let OperandType = "OPERAND_SPIMM";
let MCOperandPredicate = [{
int64_t Imm;
if (!MCOp.evaluateAsConstantImm(Imm))
More information about the llvm-commits
mailing list