[llvm] [CodeGen] Add MO_LaneMask type and a new COPY_LANEMASK instruction (PR #151944)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 17 02:29:36 PST 2025
================
@@ -2428,6 +2428,46 @@ void MachineVerifier::visitMachineInstrBefore(const MachineInstr *MI) {
}
break;
}
+ case TargetOpcode::COPY_LANEMASK: {
+ const MachineOperand &DstOp = MI->getOperand(0);
+ const MachineOperand &SrcOp = MI->getOperand(1);
+ const MachineOperand &LaneMaskOp = MI->getOperand(2);
+ const Register SrcReg = SrcOp.getReg();
+ const LaneBitmask LaneMask = LaneMaskOp.getLaneMask();
+ LaneBitmask SrcMaxLaneMask = LaneBitmask::getAll();
+
+ if (DstOp.getSubReg())
+ report("COPY_LANEMASK must not use a subregister index", &DstOp, 0);
+
+ if (SrcOp.getSubReg())
+ report("COPY_LANEMASK must not use a subregister index", &SrcOp, 1);
+
+ if (LaneMask.none())
+ report("COPY_LANEMASK must read at least one lane", MI);
+
+ if (SrcReg.isPhysical()) {
+ const TargetRegisterClass *SrcRC = TRI->getMinimalPhysRegClass(SrcReg);
+ if (SrcRC)
+ SrcMaxLaneMask = SrcRC->getLaneMask();
+ } else {
+ SrcMaxLaneMask = MRI->getMaxLaneMaskForVReg(SrcReg);
+ }
+
+ // COPY_LANEMASK should be used only for partial copy. For full
+ // copy, one should strictly use the COPY instruction.
+ if (SrcMaxLaneMask == LaneMask)
+ report("COPY_LANEMASK cannot be used to do full copy", MI);
+
+ // If LaneMask is equal to OR greater than the SrcMaxLaneMask, it
----------------
jayfoad wrote:
```suggestion
// If LaneMask is greater than the SrcMaxLaneMask, it
```
https://github.com/llvm/llvm-project/pull/151944
More information about the llvm-commits
mailing list