MachineOperand Op = MI->getOperand(i); if (Op.isImm()) { int value = Op.getImm(); // work with the immediate value }
if (Op.isImm()) { APInt value(getImm()); ConstantInt *Imm = ConstantInt::get(Type::getInt32Ty(*M->getContext()), value); // work with the constant integer value }In this example, we convert the immediate value into a ConstantInt object using the getImm() function and then perform some operation on it. The MachineOperand class and its related functions are part of the LLVM library.