MachineOperand Op = ... ; // initialize MachineOperand object if(Op.isReg()) { LLVM_DEBUG(dbgs() << "Operand is a register\n"); } else { LLVM_DEBUG(dbgs() << "Operand is not a register\n"); }
bool isRegisterOperand(MachineInstr* MI, unsigned OpIndex) { const MachineOperand& Op = MI->getOperand(OpIndex); return Op.isReg(); }Here, we have a function named "isRegisterOperand" which takes a MachineInstr pointer and an operand index as arguments. It retrieves the operand using the getOperand method and assigns it to a const reference named "Op". Then, it returns true if the operand is a register and false otherwise. This code is also part of the LLVM Core libraries.