1 //===-- MSSchedule.h - Schedule ------- -------------------------*- 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 //===----------------------------------------------------------------------===//
10 // The schedule generated by a scheduling algorithm
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_MSSCHEDULE_H
15 #define LLVM_MSSCHEDULE_H
17 #include "MSchedGraph.h"
24 std::map<int, std::vector<MSchedGraphNode*> > schedule;
27 //Internal map to keep track of explicit resources
28 std::map<int, std::map<int, int> > resourceNumPerCycle;
30 //Check if all resources are free
31 bool resourcesFree(MSchedGraphNode*, int, int II);
32 bool resourceAvailable(int resourceNum, int cycle);
33 void useResource(int resourceNum, int cycle);
36 std::vector<std::pair<MachineInstr*, int> > kernel;
41 //add at the right spot in the schedule
42 void addToSchedule(int, MSchedGraphNode*);
45 MSSchedule(int num) : numIssue(num) {}
46 MSSchedule() : numIssue(4) {}
47 bool insert(MSchedGraphNode *node, int cycle, int II);
48 int getStartCycle(MSchedGraphNode *node);
49 void clear() { schedule.clear(); resourceNumPerCycle.clear(); kernel.clear(); }
50 std::vector<std::pair<MachineInstr*, int> >* getKernel() { return &kernel; }
51 bool constructKernel(int II, std::vector<MSchedGraphNode*> &branches, std::map<const MachineInstr*, unsigned> &indVar);
52 int getMaxStage() { return maxStage; }
53 bool defPreviousStage(Value *def, int stage);
56 typedef std::map<int, std::vector<MSchedGraphNode*> >::iterator schedule_iterator;
57 typedef std::map<int, std::vector<MSchedGraphNode*> >::const_iterator schedule_const_iterator;
58 schedule_iterator begin() { return schedule.begin(); };
59 schedule_iterator end() { return schedule.end(); };
60 void print(std::ostream &os) const;
62 typedef std::vector<std::pair<MachineInstr*, int> >::iterator kernel_iterator;
63 typedef std::vector<std::pair<MachineInstr*, int> >::const_iterator kernel_const_iterator;
64 kernel_iterator kernel_begin() { return kernel.begin(); }
65 kernel_iterator kernel_end() { return kernel.end(); }