2004-05-26 06:27:36 +00:00
|
|
|
//===-- MSSchedule.h - Schedule ------- -------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// The schedule generated by a scheduling algorithm
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_MSSCHEDULE_H
|
|
|
|
#define LLVM_MSSCHEDULE_H
|
|
|
|
|
|
|
|
#include "MSchedGraph.h"
|
|
|
|
#include <vector>
|
2005-03-23 01:47:20 +00:00
|
|
|
#include <set>
|
2004-05-26 06:27:36 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class MSSchedule {
|
|
|
|
std::map<int, std::vector<MSchedGraphNode*> > schedule;
|
|
|
|
unsigned numIssue;
|
2005-04-21 23:30:14 +00:00
|
|
|
|
2004-05-26 06:27:36 +00:00
|
|
|
//Internal map to keep track of explicit resources
|
|
|
|
std::map<int, std::map<int, int> > resourceNumPerCycle;
|
|
|
|
|
|
|
|
//Check if all resources are free
|
2005-07-27 05:53:44 +00:00
|
|
|
bool resourcesFree(MSchedGraphNode*, int, int II);
|
2005-06-17 04:00:57 +00:00
|
|
|
bool resourceAvailable(int resourceNum, int cycle);
|
|
|
|
void useResource(int resourceNum, int cycle);
|
2004-05-26 06:27:36 +00:00
|
|
|
|
|
|
|
//Resulting kernel
|
2005-03-23 01:47:20 +00:00
|
|
|
std::vector<std::pair<MachineInstr*, int> > kernel;
|
2004-05-26 06:27:36 +00:00
|
|
|
|
2004-10-10 22:44:35 +00:00
|
|
|
//Max stage count
|
|
|
|
int maxStage;
|
|
|
|
|
2004-11-28 23:36:15 +00:00
|
|
|
//add at the right spot in the schedule
|
|
|
|
void addToSchedule(int, MSchedGraphNode*);
|
|
|
|
|
2004-05-26 06:27:36 +00:00
|
|
|
public:
|
|
|
|
MSSchedule(int num) : numIssue(num) {}
|
|
|
|
MSSchedule() : numIssue(4) {}
|
2005-06-17 04:00:57 +00:00
|
|
|
bool insert(MSchedGraphNode *node, int cycle, int II);
|
2004-05-26 06:27:36 +00:00
|
|
|
int getStartCycle(MSchedGraphNode *node);
|
|
|
|
void clear() { schedule.clear(); resourceNumPerCycle.clear(); kernel.clear(); }
|
2005-03-23 01:47:20 +00:00
|
|
|
std::vector<std::pair<MachineInstr*, int> >* getKernel() { return &kernel; }
|
|
|
|
bool constructKernel(int II, std::vector<MSchedGraphNode*> &branches, std::map<const MachineInstr*, unsigned> &indVar);
|
2004-10-10 22:44:35 +00:00
|
|
|
int getMaxStage() { return maxStage; }
|
2005-06-17 04:00:57 +00:00
|
|
|
bool defPreviousStage(Value *def, int stage);
|
2005-04-21 23:30:14 +00:00
|
|
|
|
2004-05-26 06:27:36 +00:00
|
|
|
//iterators
|
|
|
|
typedef std::map<int, std::vector<MSchedGraphNode*> >::iterator schedule_iterator;
|
|
|
|
typedef std::map<int, std::vector<MSchedGraphNode*> >::const_iterator schedule_const_iterator;
|
|
|
|
schedule_iterator begin() { return schedule.begin(); };
|
|
|
|
schedule_iterator end() { return schedule.end(); };
|
|
|
|
void print(std::ostream &os) const;
|
|
|
|
|
2005-03-23 01:47:20 +00:00
|
|
|
typedef std::vector<std::pair<MachineInstr*, int> >::iterator kernel_iterator;
|
|
|
|
typedef std::vector<std::pair<MachineInstr*, int> >::const_iterator kernel_const_iterator;
|
2004-05-26 06:27:36 +00:00
|
|
|
kernel_iterator kernel_begin() { return kernel.begin(); }
|
|
|
|
kernel_iterator kernel_end() { return kernel.end(); }
|
2005-04-21 23:30:14 +00:00
|
|
|
|
2004-05-26 06:27:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|