for (const MachineOperand& op : instr.operands()) { int index = op.getIndex(); std::cout << "Operand " << index << ": " << op << std::endl; }
int indexToRemove = 2; instr.RemoveOperand(indexToRemove); for (MachineOperand& op : instr.operands()) { int index = op.getIndex(); if (index > indexToRemove) { op.setIndex(index - 1); // decrement index } }In both examples, we call the `getIndex()` method on a `MachineOperand` object to get the index of the operand within its parent instruction. Overall, these examples use the LLVM IR library in C++ to analyze or modify machine-level instructions by accessing their operands using the `MachineOperand` class, and using `getIndex()` to get the index of each operand.