1 #include "llvm/Analysis/LiveVar/LiveVarSet.h"
2 #include "llvm/CodeGen/MachineInstr.h"
5 // This function applies a machine instr to a live var set (accepts OutSet) and
6 // makes necessary changes to it (produces InSet). Note that two for loops are
7 // used to first kill all defs and then to add all uses. This is because there
8 // can be instructions like Val = Val + 1 since we allow multipe defs to a
9 // machine instruction operand.
12 void LiveVarSet::applyTranferFuncForMInst(const MachineInstr *MInst) {
13 for (MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done(); ++OpI) {
14 if (OpI.isDef()) // kill only if this operand is a def
15 insert(*OpI); // this definition kills any uses
18 // do for implicit operands as well
19 for ( unsigned i=0; i < MInst->getNumImplicitRefs(); ++i) {
20 if (MInst->implicitRefIsDefined(i))
21 erase(MInst->getImplicitRef(i));
25 for (MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done(); ++OpI) {
26 if ((*OpI)->getType()->isLabelType()) continue; // don't process labels
28 if (!OpI.isDef()) // add only if this operand is a use
29 insert(*OpI); // An operand is a use - so add to use set
32 // do for implicit operands as well
33 for (unsigned i=0; i < MInst->getNumImplicitRefs(); ++i) {
34 if (!MInst->implicitRefIsDefined(i))
35 insert(MInst->getImplicitRef(i));