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