Tanya Lattner | 9b3cbdb | 2004-03-01 02:50:57 +0000 | [diff] [blame^] | 1 | //===-- ModuloScheduling.h - Swing Modulo Scheduling------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by the LLVM research group and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #ifndef LLVM_MODULOSCHEDULING_H |
| 14 | #define LLVM_MODULOSCHEDULING_H |
| 15 | |
| 16 | #include "MSchedGraph.h" |
| 17 | #include "llvm/Function.h" |
| 18 | #include "llvm/Pass.h" |
| 19 | #include <set> |
| 20 | |
| 21 | namespace llvm { |
| 22 | |
| 23 | |
| 24 | //Struct to contain ModuloScheduling Specific Information for each node |
| 25 | struct MSNodeAttributes { |
| 26 | int ASAP; //Earliest time at which the opreation can be scheduled |
| 27 | int ALAP; //Latest time at which the operation can be scheduled. |
| 28 | int MOB; |
| 29 | int depth; |
| 30 | int height; |
| 31 | MSNodeAttributes(int asap=-1, int alap=-1, int mob=-1, |
| 32 | int d=-1, int h=-1) : ASAP(asap), ALAP(alap), |
| 33 | MOB(mob), depth(d), |
| 34 | height(h) {} |
| 35 | }; |
| 36 | |
| 37 | |
| 38 | class ModuloSchedulingPass : public FunctionPass { |
| 39 | const TargetMachine ⌖ |
| 40 | |
| 41 | //Map that holds node to node attribute information |
| 42 | std::map<MSchedGraphNode*, MSNodeAttributes> nodeToAttributesMap; |
| 43 | |
| 44 | //Internal functions |
| 45 | bool MachineBBisValid(const MachineBasicBlock *BI); |
| 46 | int calculateResMII(const MachineBasicBlock *BI); |
| 47 | void calculateNodeAttributes(MSchedGraph *graph, int MII); |
| 48 | void calculateASAP(MSchedGraphNode *node, MSNodeAttributes &attributes, |
| 49 | int MII,std::set<MSchedGraphNode*> &visitedNodes); |
| 50 | void calculateALAP(MSchedGraphNode *node, MSNodeAttributes &attributes, int MII, |
| 51 | int maxASAP, std::set<MSchedGraphNode*> &visitedNodes); |
| 52 | void calculateHeight(MSchedGraphNode *node, |
| 53 | MSNodeAttributes &attributes, std::set<MSchedGraphNode*> &visitedNodes); |
| 54 | void calculateDepth(MSchedGraphNode *node, MSNodeAttributes &attributes, |
| 55 | std::set<MSchedGraphNode*> &visitedNodes); |
| 56 | |
| 57 | int findMaxASAP(); |
| 58 | void ModuloSchedulingPass::orderNodes(); |
| 59 | void findAllReccurrences(MSchedGraphNode *node, std::vector<MSchedGraphNode*> &visitedNodes); |
| 60 | public: |
| 61 | ModuloSchedulingPass(TargetMachine &targ) : target(targ) {} |
| 62 | virtual bool runOnFunction(Function &F); |
| 63 | }; |
| 64 | |
| 65 | } |
| 66 | |
| 67 | |
| 68 | #endif |