1 //===-- ModuloScheduling.h - Swing Modulo Scheduling------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_MODULOSCHEDULING_H
14 #define LLVM_MODULOSCHEDULING_H
16 #include "MSchedGraph.h"
17 #include "llvm/Function.h"
18 #include "llvm/Pass.h"
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.
31 MSNodeAttributes(int asap=-1, int alap=-1, int mob=-1,
32 int d=-1, int h=-1) : ASAP(asap), ALAP(alap),
38 class ModuloSchedulingPass : public FunctionPass {
39 const TargetMachine ⌖
41 //Map that holds node to node attribute information
42 std::map<MSchedGraphNode*, MSNodeAttributes> nodeToAttributesMap;
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);
58 void ModuloSchedulingPass::orderNodes();
59 void findAllReccurrences(MSchedGraphNode *node, std::vector<MSchedGraphNode*> &visitedNodes);
61 ModuloSchedulingPass(TargetMachine &targ) : target(targ) {}
62 virtual bool runOnFunction(Function &F);