MachineInstr* mi = ... ; // pointer to a MachineInstr object unsigned opIndex = ... ; // index of the load memory operand MachineMemOperand* mmo = mi->getMachineMemOperand(opIndex);
MachineInstr* mi = ... ; // pointer to a MachineInstr object unsigned opIndex = ... ; // index of the load memory operand MachineMemOperand* mmo = mi->getMachineMemOperand(opIndex); unsigned baseReg = mmo->getReg(); int64_t offset = mmo->getOffset();In this example, we again get a pointer to a MachineMemOperand object for a load instruction, but this time we also extract the base register and offset used in the memory access. We can use these values to generate code that correctly loads data from the specified memory address. Overall, the getMachineMemOperand method is a useful tool for working with LLVM-generated machine code, and it is part of the LLVM core library.