The getNumOperands function is a part of cpp MachineInstr class that retrieves the number of operands for the instruction. This function allows analyzing the number of operands of the instruction which is essential for the compiler's optimization process.
Example 1:
`MachineInstr* MI = ...;`
`unsigned int num_ops = MI->getNumOperands();`
This code snippet retrieves the number of operands of a specific machine instruction and assigns it to the "num_ops" variable.
Example 2:
`for(MachineBasicBlock::iterator I = MBB.begin(), IE = MBB.end(); I!= IE; ++I)`
`{`
`for(int i=0, e = I->getNumOperands(); i < e; ++i)`
This code snippet uses the getNumOperands function to loop through all the operands of a specific basic block in a machine function. The code then checks if the operand is a register and if it matches some specific register, it performs some operations.
Package/Library: LLVM (Low-Level Virtual Machine) - a collection of modular and reusable compiler and toolchain technologies used both in research and industrial settings.
C++ (Cpp) MachineInstr::getNumOperands - 30 examples found. These are the top rated real world C++ (Cpp) examples of MachineInstr::getNumOperands extracted from open source projects. You can rate examples to help us improve the quality of examples.