[llvm] [MachineInstr] add insert method for variadic instructions (PR #67699)
Matthias Braun via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 12 08:56:41 PDT 2023
================
@@ -2475,3 +2475,24 @@ MachineInstr::getFirst5RegLLTs() const {
Reg2, getRegInfo()->getType(Reg2), Reg3, getRegInfo()->getType(Reg3),
Reg4, getRegInfo()->getType(Reg4));
}
+
+void MachineInstr::insert(mop_iterator It, ArrayRef<MachineOperand> Ops) {
+ assert(isVariadic() && "can only modify variadic instructions");
+ assert(It->getParent() == this && "iterator points to operand of other inst");
+
+ const unsigned OpIdx = getOperandNo(It);
+ const unsigned NumOperands = getNumOperands();
+ const unsigned OpsToMove = NumOperands - OpIdx;
+
+ SmallVector<MachineOperand> MovingOps;
+ MovingOps.reserve(OpsToMove);
+
+ for (unsigned I = 0; I < OpsToMove; ++I) {
+ MovingOps.emplace_back(getOperand(OpIdx));
+ removeOperand(OpIdx);
+ }
+ for (const MachineOperand &MO : Ops)
----------------
MatzeB wrote:
I don't see why you would check. I'd just treat it as a list of operands. The fact that you need to respect some ordering etc. I would leave to callers of the APIs (or verifiers to catch problems).
https://github.com/llvm/llvm-project/pull/67699
More information about the llvm-commits
mailing list