Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 1 | //===- ModuloSchedGraph.h - Modulo Scheduling Graph and Set -*- C++ -*-----===// |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 2 | // |
| 3 | // This header defines the primative classes that make up a data structure |
| 4 | // graph. |
| 5 | // |
| 6 | //===----------------------------------------------------------------------===// |
| 7 | |
| 8 | #ifndef LLVM_CODEGEN_MODULO_SCHED_GRAPH_H |
| 9 | #define LLVM_CODEGEN_MODULO_SCHED_GRAPH_H |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 10 | |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 11 | #include "llvm/Instruction.h" |
| 12 | #include "llvm/Target/TargetMachine.h" |
Guochun Shi | 6fbe5fb | 2003-04-06 23:56:19 +0000 | [diff] [blame] | 13 | #include "llvm/Target/TargetInstrInfo.h" |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 14 | #include "Support/HashExtras.h" |
| 15 | #include "Support/GraphTraits.h" |
Misha Brukman | 2c821cc | 2003-04-10 19:19:23 +0000 | [diff] [blame^] | 16 | #include "Support/hash_map" |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 17 | #include "../InstrSched/SchedGraphCommon.h" |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 18 | #include <iostream> |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 19 | |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 20 | //===----------------------------------------------------------------------===// |
| 21 | // ModuloSchedGraphNode - Implement a data structure based on the |
| 22 | // SchedGraphNodeCommon this class stores informtion needed later to order the |
| 23 | // nodes in modulo scheduling |
| 24 | // |
| 25 | class ModuloSchedGraphNode:public SchedGraphNodeCommon { |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 26 | private: |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 27 | // the corresponding instruction |
| 28 | const Instruction *inst; |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 29 | |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 30 | // whether this node's property(ASAP,ALAP, ...) has been computed |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 31 | bool propertyComputed; |
| 32 | |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 33 | // ASAP: the earliest time the node could be scheduled |
| 34 | // ALAP: the latest time the node couldbe scheduled |
| 35 | // depth: the depth of the node |
| 36 | // height: the height of the node |
| 37 | // mov: the mobility function, computed as ALAP - ASAP |
| 38 | // scheTime: the scheduled time if this node has been scheduled |
| 39 | // earlyStart: the earliest time to be tried to schedule the node |
| 40 | // lateStart: the latest time to be tried to schedule the node |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 41 | int ASAP, ALAP, depth, height, mov; |
| 42 | int schTime; |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 43 | int earlyStart, lateStart; |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 44 | |
| 45 | public: |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 46 | |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 47 | //get the instruction |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 48 | const Instruction *getInst() const { |
| 49 | return inst; |
| 50 | } |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 51 | //get the instruction op-code name |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 52 | const char *getInstOpcodeName() const { |
| 53 | return inst->getOpcodeName(); |
| 54 | } |
| 55 | //get the instruction op-code |
| 56 | const unsigned getInstOpcode() const { |
| 57 | return inst->getOpcode(); |
| 58 | } |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 59 | //return whether the node is NULL |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 60 | bool isNullNode() const { |
| 61 | return (inst == NULL); |
| 62 | } |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 63 | //return whether the property of the node has been computed |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 64 | bool getPropertyComputed() { |
| 65 | return propertyComputed; |
| 66 | } |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 67 | //set the propertyComputed |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 68 | void setPropertyComputed(bool _propertyComputed) { |
| 69 | propertyComputed = _propertyComputed; |
| 70 | } |
| 71 | |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 72 | //get the corresponding property |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 73 | int getASAP() { |
| 74 | return ASAP; |
| 75 | } |
| 76 | int getALAP() { |
| 77 | return ALAP; |
| 78 | } |
| 79 | int getMov() { |
| 80 | return mov; |
| 81 | } |
| 82 | int getDepth() { |
| 83 | return depth; |
| 84 | } |
| 85 | int getHeight() { |
| 86 | return height; |
| 87 | } |
| 88 | int getSchTime() { |
| 89 | return schTime; |
| 90 | } |
| 91 | int getEarlyStart() { |
| 92 | return earlyStart; |
| 93 | } |
| 94 | int getLateStart() { |
| 95 | return lateStart; |
| 96 | } |
| 97 | void setEarlyStart(int _earlyStart) { |
| 98 | earlyStart = _earlyStart; |
| 99 | } |
| 100 | void setLateStart(int _lateStart) { |
| 101 | lateStart = _lateStart; |
| 102 | } |
| 103 | void setSchTime(int _time) { |
| 104 | schTime = _time; |
| 105 | } |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 106 | |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 107 | private: |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 108 | friend class ModuloSchedGraph; |
| 109 | friend class SchedGraphNode; |
| 110 | |
| 111 | //constructor: |
| 112 | //nodeId: the node id, unique within the each BasicBlock |
| 113 | //_bb: which BasicBlock the corresponding instruction belongs to |
| 114 | //_inst: the corresponding instruction |
| 115 | //indexInBB: the corresponding instruction's index in the BasicBlock |
| 116 | //target: the targetMachine |
| 117 | ModuloSchedGraphNode(unsigned int _nodeId, |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 118 | const BasicBlock * _bb, |
| 119 | const Instruction * _inst, |
| 120 | int indexInBB, const TargetMachine &target); |
| 121 | |
| 122 | |
| 123 | friend std::ostream & operator<<(std::ostream & os, |
| 124 | const ModuloSchedGraphNode & edge); |
| 125 | |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 126 | }; |
| 127 | |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 128 | //FIXME: these two value should not be used |
| 129 | #define MAXNODE 100 |
| 130 | #define MAXCC 100 |
| 131 | |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 132 | //===----------------------------------------------------------------------===// |
| 133 | /// ModuloSchedGraph- the data structure to store dependence between nodes |
| 134 | /// it catches data dependence and constrol dependence |
| 135 | /// |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 136 | class ModuloSchedGraph : |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 137 | public SchedGraphCommon, |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 138 | protected hash_map<const Instruction*,ModuloSchedGraphNode*> { |
| 139 | |
| 140 | private: |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 141 | //iteration Interval |
| 142 | int MII; |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 143 | |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 144 | //target machine |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 145 | const TargetMachine & target; |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 146 | |
| 147 | //the circuits in the dependence graph |
| 148 | unsigned circuits[MAXCC][MAXNODE]; |
| 149 | |
| 150 | //the order nodes |
| 151 | std::vector<ModuloSchedGraphNode*> oNodes; |
| 152 | |
| 153 | typedef std::vector<ModuloSchedGraphNode*> NodeVec; |
| 154 | |
| 155 | //the function to compute properties |
Misha Brukman | 2c821cc | 2003-04-10 19:19:23 +0000 | [diff] [blame^] | 156 | void computeNodeASAP(const BasicBlock *bb); |
| 157 | void computeNodeALAP(const BasicBlock *bb); |
| 158 | void computeNodeMov(const BasicBlock *bb); |
| 159 | void computeNodeDepth(const BasicBlock *bb); |
| 160 | void computeNodeHeight(const BasicBlock *bb); |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 161 | |
| 162 | //the function to compute node property |
Misha Brukman | 2c821cc | 2003-04-10 19:19:23 +0000 | [diff] [blame^] | 163 | void computeNodeProperty(const BasicBlock *bb); |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 164 | |
| 165 | //the function to sort nodes |
| 166 | void orderNodes(); |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 167 | |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 168 | //add the resource usage |
Misha Brukman | 2c821cc | 2003-04-10 19:19:23 +0000 | [diff] [blame^] | 169 | void addResourceUsage(std::vector<std::pair<int,int> > &, int); |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 170 | |
| 171 | //debug functions: |
| 172 | //dump circuits |
| 173 | void dumpCircuits(); |
| 174 | //dump the input set of nodes |
| 175 | void dumpSet(std::vector<ModuloSchedGraphNode*> set); |
| 176 | //dump the input resource usage table |
Misha Brukman | 2c821cc | 2003-04-10 19:19:23 +0000 | [diff] [blame^] | 177 | void dumpResourceUsage(std::vector<std::pair<int,int> > &); |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 178 | |
| 179 | public: |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 180 | //help functions |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 181 | |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 182 | //get the maxium the delay between two nodes |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 183 | SchedGraphEdge *getMaxDelayEdge(unsigned srcId, unsigned sinkId); |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 184 | |
| 185 | //FIXME: |
| 186 | //get the predessor Set of the set |
| 187 | NodeVec predSet(NodeVec set, unsigned, unsigned); |
| 188 | NodeVec predSet(NodeVec set); |
| 189 | |
| 190 | //get the predessor set of the node |
Misha Brukman | 2c821cc | 2003-04-10 19:19:23 +0000 | [diff] [blame^] | 191 | NodeVec predSet(ModuloSchedGraphNode *node, unsigned, unsigned); |
| 192 | NodeVec predSet(ModuloSchedGraphNode *node); |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 193 | |
| 194 | //get the successor set of the set |
| 195 | NodeVec succSet(NodeVec set, unsigned, unsigned); |
| 196 | NodeVec succSet(NodeVec set); |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 197 | |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 198 | //get the succssor set of the node |
Misha Brukman | 2c821cc | 2003-04-10 19:19:23 +0000 | [diff] [blame^] | 199 | NodeVec succSet(ModuloSchedGraphNode *node, unsigned, unsigned); |
| 200 | NodeVec succSet(ModuloSchedGraphNode *node); |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 201 | |
| 202 | //return the uniton of the two vectors |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 203 | NodeVec vectorUnion(NodeVec set1, NodeVec set2); |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 204 | |
| 205 | //return the consjuction of the two vectors |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 206 | NodeVec vectorConj(NodeVec set1, NodeVec set2); |
| 207 | |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 208 | //return all nodes in set1 but not set2 |
| 209 | NodeVec vectorSub(NodeVec set1, NodeVec set2); |
| 210 | |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 211 | typedef hash_map<const Instruction*,ModuloSchedGraphNode*> map_base; |
| 212 | |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 213 | public: |
| 214 | using map_base::iterator; |
| 215 | using map_base::const_iterator; |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 216 | |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 217 | public: |
| 218 | |
| 219 | //get target machine |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 220 | const TargetMachine & getTarget() { |
| 221 | return target; |
| 222 | } |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 223 | //get the iteration interval |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 224 | const int getMII() { |
| 225 | return MII; |
| 226 | } |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 227 | |
| 228 | //get the ordered nodes |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 229 | const NodeVec & getONodes() { |
| 230 | return oNodes; |
| 231 | } |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 232 | |
| 233 | //get the number of nodes (including the root and leaf) |
| 234 | //note: actually root and leaf is not used |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 235 | const unsigned int getNumNodes() const { |
| 236 | return size() + 2; |
| 237 | } |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 238 | //return wether the BasicBlock 'bb' contains a loop |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 239 | bool isLoop(const BasicBlock * bb); |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 240 | |
| 241 | //return this basibBlock contains a loop |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 242 | bool isLoop(); |
| 243 | |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 244 | //return the node for the input instruction |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 245 | ModuloSchedGraphNode *getGraphNodeForInst(const Instruction * inst) const { |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 246 | const_iterator onePair = this->find(inst); |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 247 | return (onePair != this->end()) ? (*onePair).second : NULL; |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 248 | } |
Misha Brukman | 2c821cc | 2003-04-10 19:19:23 +0000 | [diff] [blame^] | 249 | |
| 250 | // Debugging support |
| 251 | //dump the graph |
| 252 | void dump() const; |
| 253 | |
| 254 | // dump the basicBlock |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 255 | void dump(const BasicBlock * bb); |
Misha Brukman | 2c821cc | 2003-04-10 19:19:23 +0000 | [diff] [blame^] | 256 | |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 257 | //dump the basicBlock into 'os' stream |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 258 | void dump(const BasicBlock * bb, std::ostream & os); |
Misha Brukman | 2c821cc | 2003-04-10 19:19:23 +0000 | [diff] [blame^] | 259 | |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 260 | //dump the node property |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 261 | void dumpNodeProperty() const; |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 262 | |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 263 | private: |
| 264 | friend class ModuloSchedGraphSet; //give access to ctor |
| 265 | |
| 266 | public: |
| 267 | ModuloSchedGraph(const BasicBlock *bb, const TargetMachine &_target) |
Misha Brukman | 2c821cc | 2003-04-10 19:19:23 +0000 | [diff] [blame^] | 268 | :SchedGraphCommon(bb), target(_target) |
| 269 | { |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 270 | buildGraph(target); |
| 271 | } |
| 272 | |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 273 | ~ModuloSchedGraph() { |
| 274 | for (const_iterator I = begin(); I != end(); ++I) |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 275 | delete I->second; |
| 276 | } |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 277 | |
Misha Brukman | 2c821cc | 2003-04-10 19:19:23 +0000 | [diff] [blame^] | 278 | // Unorder iterators |
| 279 | // return values are pair<const Instruction*, ModuloSchedGraphNode*> |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 280 | using map_base::begin; |
| 281 | using map_base::end; |
| 282 | |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 283 | void noteModuloSchedGraphNodeForInst(const Instruction *inst, |
| 284 | ModuloSchedGraphNode *node) |
| 285 | { |
| 286 | assert((*this)[inst] == NULL); |
| 287 | (*this)[inst] = node; |
| 288 | } |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 289 | |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 290 | //Graph builder |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 291 | |
| 292 | ModuloSchedGraphNode *getNode(const unsigned nodeId) const; |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 293 | |
| 294 | //build the graph from the basicBlock |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 295 | void buildGraph(const TargetMachine & target); |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 296 | |
| 297 | //Build nodes for BasicBlock |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 298 | void buildNodesforBB(const TargetMachine &target, |
| 299 | const BasicBlock *bb, |
| 300 | NodeVec &memNode, |
| 301 | RegToRefVecMap ®ToRefVecMap, |
| 302 | ValueToDefVecMap &valueToDefVecMap); |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 303 | |
| 304 | //find definitiona and use information for all nodes |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 305 | void findDefUseInfoAtInstr(const TargetMachine &target, |
| 306 | ModuloSchedGraphNode *node, |
| 307 | NodeVec &memNode, |
| 308 | RegToRefVecMap ®ToRefVecMap, |
| 309 | ValueToDefVecMap &valueToDefVecMap); |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 310 | |
| 311 | //add def-use edge |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 312 | void addDefUseEdges(const BasicBlock *bb); |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 313 | |
| 314 | //add control dependence edges |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 315 | void addCDEdges(const BasicBlock *bb); |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 316 | |
| 317 | //add memory dependence dges |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 318 | void addMemEdges(const BasicBlock *bb); |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 319 | |
| 320 | //add dummy edges |
| 321 | void addDummyEdges(); |
| 322 | |
| 323 | //computer source restrictoin II |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 324 | int computeResII(const BasicBlock *bb); |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 325 | |
| 326 | //computer recurrence II |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 327 | int computeRecII(const BasicBlock *bb); |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 328 | }; |
| 329 | |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 330 | //==================================- |
| 331 | // Graph set |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 332 | |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 333 | class ModuloSchedGraphSet : public std::vector<ModuloSchedGraph*> { |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 334 | private: |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 335 | const Function *method; |
| 336 | |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 337 | public: |
| 338 | typedef std::vector<ModuloSchedGraph*> baseVector; |
| 339 | using baseVector::iterator; |
| 340 | using baseVector::const_iterator; |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 341 | |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 342 | public: |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 343 | ModuloSchedGraphSet(const Function *function, const TargetMachine &target); |
| 344 | ~ModuloSchedGraphSet(); |
| 345 | |
| 346 | // Iterators |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 347 | using baseVector::begin; |
| 348 | using baseVector::end; |
| 349 | |
Misha Brukman | 2c821cc | 2003-04-10 19:19:23 +0000 | [diff] [blame^] | 350 | // Debugging support |
| 351 | void dump() const; |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 352 | |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 353 | private: |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 354 | void addGraph(ModuloSchedGraph *graph) { |
| 355 | assert(graph != NULL); |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 356 | this->push_back(graph); |
| 357 | } |
Guochun Shi | f1c154f | 2003-03-27 17:57:44 +0000 | [diff] [blame] | 358 | |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 359 | // Graph builder |
| 360 | void buildGraphsForMethod(const Function *F, |
| 361 | const TargetMachine &target); |
Misha Brukman | 2c821cc | 2003-04-10 19:19:23 +0000 | [diff] [blame^] | 362 | }; |
Misha Brukman | 8baa01c | 2003-04-09 21:51:34 +0000 | [diff] [blame] | 363 | |
| 364 | #endif |