mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 20:29:48 +00:00
1164632c7e
* Convert over to valueset interface that uses insert & erase insead of add and remove * the -> operator really isn't that hard to use! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1687 91177308-0d34-0410-b5e6-96231b3b80d8
38 lines
1.4 KiB
C++
38 lines
1.4 KiB
C++
#include "llvm/Analysis/LiveVar/LiveVarSet.h"
|
|
#include "llvm/CodeGen/MachineInstr.h"
|
|
#include "llvm/Type.h"
|
|
|
|
// This function applies a machine instr to a live var set (accepts OutSet) and
|
|
// makes necessary changes to it (produces InSet). Note that two for loops are
|
|
// used to first kill all defs and then to add all uses. This is because there
|
|
// can be instructions like Val = Val + 1 since we allow multipe defs to a
|
|
// machine instruction operand.
|
|
|
|
|
|
void LiveVarSet::applyTranferFuncForMInst(const MachineInstr *MInst) {
|
|
for (MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done(); ++OpI) {
|
|
if (OpI.isDef()) // kill only if this operand is a def
|
|
insert(*OpI); // this definition kills any uses
|
|
}
|
|
|
|
// do for implicit operands as well
|
|
for ( unsigned i=0; i < MInst->getNumImplicitRefs(); ++i) {
|
|
if (MInst->implicitRefIsDefined(i))
|
|
erase(MInst->getImplicitRef(i));
|
|
}
|
|
|
|
|
|
for (MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done(); ++OpI) {
|
|
if ((*OpI)->getType()->isLabelType()) continue; // don't process labels
|
|
|
|
if (!OpI.isDef()) // add only if this operand is a use
|
|
insert(*OpI); // An operand is a use - so add to use set
|
|
}
|
|
|
|
// do for implicit operands as well
|
|
for (unsigned i=0; i < MInst->getNumImplicitRefs(); ++i) {
|
|
if (!MInst->implicitRefIsDefined(i))
|
|
insert(MInst->getImplicitRef(i));
|
|
}
|
|
}
|