diff options
author | Ruchira Sasanka <sasanka@students.uiuc.edu> | 2001-08-20 21:12:49 +0000 |
---|---|---|
committer | Ruchira Sasanka <sasanka@students.uiuc.edu> | 2001-08-20 21:12:49 +0000 |
commit | e27c344b5657eb225688c2adb163d6064cc9cf8f (patch) | |
tree | 4c45ad1188bbea9b127712b06971911302f4ea7a /lib/Analysis/LiveVar/LiveVarSet.cpp | |
parent | 91661812573e2f2a3d5bf254665615c86f7a00fe (diff) |
LV code on machine instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/LiveVar/LiveVarSet.cpp')
-rw-r--r-- | lib/Analysis/LiveVar/LiveVarSet.cpp | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/lib/Analysis/LiveVar/LiveVarSet.cpp b/lib/Analysis/LiveVar/LiveVarSet.cpp index c893817549..07dc128601 100644 --- a/lib/Analysis/LiveVar/LiveVarSet.cpp +++ b/lib/Analysis/LiveVar/LiveVarSet.cpp @@ -1,9 +1,42 @@ #include "llvm/Analysis/LiveVar/LiveVarSet.h" +#include "llvm/CodeGen/MachineInstr.h" -// This function applies an instruction to a live var set (accepts OutSet) and -// makes necessary changes to it (produces InSet) +// 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 *const MInst) +{ + + for( MachineInstr::val_op_const_iterator OpI(MInst); !OpI.done() ; OpI++) { + + if( OpI.isDef() ) { // kill only if this operand is a def + remove(*OpI); // this definition kills any uses + } + + } + + for( MachineInstr::val_op_const_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 + add( *OpI ); // An operand is a use - so add to use set + } + } +} + + + + + + + +#if 0 void LiveVarSet::applyTranferFuncForInst(const Instruction *const Inst) { @@ -18,3 +51,4 @@ void LiveVarSet::applyTranferFuncForInst(const Instruction *const Inst) } } +#endif |