blob: 16cbab13f29c17251586310c6c373cdaa2bc6312 [file] [log] [blame]
Tanya Lattner642685a2004-05-26 06:27:36 +00001//===-- MSSchedule.h - Schedule ------- -------------------------*- 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// The schedule generated by a scheduling algorithm
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_MSSCHEDULE_H
15#define LLVM_MSSCHEDULE_H
16
17#include "MSchedGraph.h"
18#include <vector>
Tanya Lattner13417b52005-03-23 01:47:20 +000019#include <set>
Tanya Lattner642685a2004-05-26 06:27:36 +000020
21namespace llvm {
22
23 class MSSchedule {
24 std::map<int, std::vector<MSchedGraphNode*> > schedule;
25 unsigned numIssue;
26
27 //Internal map to keep track of explicit resources
28 std::map<int, std::map<int, int> > resourceNumPerCycle;
29
30 //Check if all resources are free
31 bool resourcesFree(MSchedGraphNode*, int);
32
33 //Resulting kernel
Tanya Lattner13417b52005-03-23 01:47:20 +000034 std::vector<std::pair<MachineInstr*, int> > kernel;
Tanya Lattner642685a2004-05-26 06:27:36 +000035
Tanya Lattnerdbac0cb2004-10-10 22:44:35 +000036 //Max stage count
37 int maxStage;
38
Tanya Lattner341828e2004-11-28 23:36:15 +000039 //add at the right spot in the schedule
40 void addToSchedule(int, MSchedGraphNode*);
41
Tanya Lattner642685a2004-05-26 06:27:36 +000042 public:
43 MSSchedule(int num) : numIssue(num) {}
44 MSSchedule() : numIssue(4) {}
45 bool insert(MSchedGraphNode *node, int cycle);
46 int getStartCycle(MSchedGraphNode *node);
47 void clear() { schedule.clear(); resourceNumPerCycle.clear(); kernel.clear(); }
Tanya Lattner13417b52005-03-23 01:47:20 +000048 std::vector<std::pair<MachineInstr*, int> >* getKernel() { return &kernel; }
49 bool constructKernel(int II, std::vector<MSchedGraphNode*> &branches, std::map<const MachineInstr*, unsigned> &indVar);
Tanya Lattnerdbac0cb2004-10-10 22:44:35 +000050 int getMaxStage() { return maxStage; }
Tanya Lattner642685a2004-05-26 06:27:36 +000051
52
53 //iterators
54 typedef std::map<int, std::vector<MSchedGraphNode*> >::iterator schedule_iterator;
55 typedef std::map<int, std::vector<MSchedGraphNode*> >::const_iterator schedule_const_iterator;
56 schedule_iterator begin() { return schedule.begin(); };
57 schedule_iterator end() { return schedule.end(); };
58 void print(std::ostream &os) const;
59
Tanya Lattner13417b52005-03-23 01:47:20 +000060 typedef std::vector<std::pair<MachineInstr*, int> >::iterator kernel_iterator;
61 typedef std::vector<std::pair<MachineInstr*, int> >::const_iterator kernel_const_iterator;
Tanya Lattner642685a2004-05-26 06:27:36 +000062 kernel_iterator kernel_begin() { return kernel.begin(); }
63 kernel_iterator kernel_end() { return kernel.end(); }
64
65 };
66
67}
68
69
70#endif