Ruchira Sasanka | 683847f | 2001-07-24 17:14:13 +0000 | [diff] [blame^] | 1 | /* Title: ValueSet.h |
| 2 | Author: Ruchira Sasanka |
| 3 | Date: Jun 30, 01 |
| 4 | Purpose: This is a wrapper class for BasicBlock which is used by live |
| 5 | variable anaysis |
| 6 | */ |
| 7 | |
| 8 | #ifndef LIVE_VAR_BB_H |
| 9 | #define LIVE_VAR_BB_H |
| 10 | |
| 11 | #include "LiveVarSet.h" |
| 12 | #include "LiveVarMap.h" |
| 13 | |
| 14 | #include "llvm/BasicBlock.h" |
| 15 | #include "llvm/Instruction.h" |
| 16 | #include "llvm/CFG.h" |
| 17 | #include "llvm/Type.h" |
| 18 | #include "llvm/iOther.h" |
| 19 | |
| 20 | |
| 21 | class BBLiveVar |
| 22 | { |
| 23 | const BasicBlock* BaseBB; // pointer to BasicBlock |
| 24 | unsigned int POId; // Post-Order ID |
| 25 | |
| 26 | LiveVarSet DefSet; // Def set for LV analysis |
| 27 | LiveVarSet InSet, OutSet; // In & Out for LV analysis |
| 28 | bool InSetChanged, OutSetChanged; // set if the InSet/OutSet is modified |
| 29 | |
| 30 | // map that contains phi args->BB they came |
| 31 | hash_map<const Value *, const BasicBlock *, hashFuncValue> PhiArgMap; |
| 32 | |
| 33 | // method to propogate an InSet to OutSet of a predecessor |
| 34 | bool setPropagate( LiveVarSet *const OutSetOfPred, |
| 35 | const LiveVarSet *const InSetOfThisBB, |
| 36 | const BasicBlock *const PredBB); |
| 37 | |
| 38 | public: |
| 39 | |
| 40 | BBLiveVar( const BasicBlock* baseBB, unsigned int POId); |
| 41 | |
| 42 | inline bool isInSetChanged() const { return InSetChanged; } |
| 43 | inline bool isOutSetChanged() const { return OutSetChanged; } |
| 44 | |
| 45 | inline unsigned int getPOId() const { return POId; } |
| 46 | |
| 47 | void calcDefUseSets() ; // calculates the Def & Use sets for this BB |
| 48 | bool applyTransferFunc(); // calcultes the In in terms of Out |
| 49 | |
| 50 | // calculates Out set using In sets of the predecessors |
| 51 | bool applyFlowFunc(BBToBBLiveVarMapType LVMap); |
| 52 | |
| 53 | inline const LiveVarSet* getOutSet() const { return &OutSet; } |
| 54 | inline const LiveVarSet* getInSet() const { return &InSet; } |
| 55 | |
| 56 | void printAllSets() const; // for printing Def/In/Out sets |
| 57 | void printInOutSets() const; // for printing In/Out sets |
| 58 | |
| 59 | //TODO write a destructor to deallocate Def/In.Out sets and PhiArgMap |
| 60 | |
| 61 | }; |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | #endif |
| 69 | |