[llvm] cea9813 - [RISCV] Add an OperandType to VMaskOp. NFC (#171926)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 11 20:03:51 PST 2025
Author: Craig Topper
Date: 2025-12-11T20:03:47-08:00
New Revision: cea98135650a4a41a23b46868e54067271103116
URL: https://github.com/llvm/llvm-project/commit/cea98135650a4a41a23b46868e54067271103116
DIFF: https://github.com/llvm/llvm-project/commit/cea98135650a4a41a23b46868e54067271103116.diff
LOG: [RISCV] Add an OperandType to VMaskOp. NFC (#171926)
Use that instead of register class to detect the mask operand in
lowerRISCVVMachineInstrToMCInst.
There are other instructions like vmerge and vadc that have a VMV0
operand that isn't optional and do not reach this code. Having a
dedicated marker for the optional mask is more precise.
Added:
Modified:
llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
llvm/lib/Target/RISCV/RISCVInstrInfoV.td
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
index 74066c86d6ebe..a047324ef36fa 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
@@ -461,6 +461,8 @@ enum OperandType : unsigned {
// instructions to represent a value that be passed as AVL to either vsetvli
// or vsetivli.
OPERAND_AVL,
+
+ OPERAND_VMASK,
};
} // namespace RISCVOp
diff --git a/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp b/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
index de433e407a48f..25f34c825d5fb 100644
--- a/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
+++ b/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
@@ -1175,8 +1175,8 @@ static bool lowerRISCVVMachineInstrToMCInst(const MachineInstr *MI,
// V instructions. All V instructions are modeled as the masked version.
const MCInstrDesc &OutMCID = TII->get(OutMI.getOpcode());
if (OutMI.getNumOperands() < OutMCID.getNumOperands()) {
- assert(OutMCID.operands()[OutMI.getNumOperands()].RegClass ==
- RISCV::VMV0RegClassID &&
+ assert(OutMCID.operands()[OutMI.getNumOperands()].OperandType ==
+ RISCVOp::OPERAND_VMASK &&
"Expected only mask operand to be missing");
OutMI.addOperand(MCOperand::createReg(RISCV::NoRegister));
}
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoV.td b/llvm/lib/Target/RISCV/RISCVInstrInfoV.td
index 9354b63bced53..eb890be0d85f5 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoV.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoV.td
@@ -62,6 +62,8 @@ def VMaskOp : RegisterOperand<VMV0> {
let PrintMethod = "printVMaskReg";
let EncoderMethod = "getVMaskReg";
let DecoderMethod = "decodeVMaskReg";
+ let OperandNamespace = "RISCVOp";
+ let OperandType = "OPERAND_VMASK";
}
def VMaskCarryInOp : RegisterOperand<VMV0> {
More information about the llvm-commits
mailing list