blob: 07dc1286014026940332791ba088e6c8c32cb6cf [file] [log] [blame]
Ruchira Sasanka683847f2001-07-24 17:14:13 +00001#include "llvm/Analysis/LiveVar/LiveVarSet.h"
Ruchira Sasankae27c3442001-08-20 21:12:49 +00002#include "llvm/CodeGen/MachineInstr.h"
Ruchira Sasanka683847f2001-07-24 17:14:13 +00003
4
Ruchira Sasankae27c3442001-08-20 21:12:49 +00005// 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.
Ruchira Sasanka683847f2001-07-24 17:14:13 +000010
Ruchira Sasankae27c3442001-08-20 21:12:49 +000011
12void LiveVarSet::applyTranferFuncForMInst(const MachineInstr *const MInst)
13{
14
15 for( MachineInstr::val_op_const_iterator OpI(MInst); !OpI.done() ; OpI++) {
16
17 if( OpI.isDef() ) { // kill only if this operand is a def
18 remove(*OpI); // this definition kills any uses
19 }
20
21 }
22
23 for( MachineInstr::val_op_const_iterator OpI(MInst); !OpI.done() ; OpI++) {
24
25 if ( ((*OpI)->getType())->isLabelType()) continue; // don't process labels
26
27 if( ! OpI.isDef() ) { // add only if this operand is a use
28 add( *OpI ); // An operand is a use - so add to use set
29 }
30 }
31}
32
33
34
35
36
37
38
39#if 0
Ruchira Sasanka683847f2001-07-24 17:14:13 +000040void LiveVarSet::applyTranferFuncForInst(const Instruction *const Inst)
41{
42
43 if( Inst->isDefinition() ) { // add to Defs iff this instr is a definition
44 remove(Inst); // this definition kills any uses
45 }
46 Instruction::op_const_iterator OpI = Inst->op_begin(); // get operand iterat
47
48 for( ; OpI != Inst->op_end() ; OpI++) { // iterate over operands
49 if ( ((*OpI)->getType())->isLabelType()) continue; // don't process labels
50 add( *OpI ); // An operand is a use - so add to use set
51 }
52
53}
Ruchira Sasankae27c3442001-08-20 21:12:49 +000054#endif