LLVM API Documentation
00001 //===-- MSSchedule.h - Schedule ------- -------------------------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by the LLVM research group and is distributed under 00006 // the University of Illinois Open Source License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // The schedule generated by a scheduling algorithm 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_MSSCHEDULE_H 00015 #define LLVM_MSSCHEDULE_H 00016 00017 #include "MSchedGraph.h" 00018 #include <vector> 00019 00020 namespace llvm { 00021 00022 class MSSchedule { 00023 std::map<int, std::vector<MSchedGraphNode*> > schedule; 00024 unsigned numIssue; 00025 00026 //Internal map to keep track of explicit resources 00027 std::map<int, std::map<int, int> > resourceNumPerCycle; 00028 00029 //Check if all resources are free 00030 bool resourcesFree(MSchedGraphNode*, int); 00031 00032 //Resulting kernel 00033 std::vector<std::pair<MSchedGraphNode*, int> > kernel; 00034 00035 //Max stage count 00036 int maxStage; 00037 00038 //add at the right spot in the schedule 00039 void addToSchedule(int, MSchedGraphNode*); 00040 00041 public: 00042 MSSchedule(int num) : numIssue(num) {} 00043 MSSchedule() : numIssue(4) {} 00044 bool insert(MSchedGraphNode *node, int cycle); 00045 int getStartCycle(MSchedGraphNode *node); 00046 void clear() { schedule.clear(); resourceNumPerCycle.clear(); kernel.clear(); } 00047 std::vector<std::pair<MSchedGraphNode*, int> >* getKernel() { return &kernel; } 00048 bool constructKernel(int II); 00049 int getMaxStage() { return maxStage; } 00050 00051 00052 //iterators 00053 typedef std::map<int, std::vector<MSchedGraphNode*> >::iterator schedule_iterator; 00054 typedef std::map<int, std::vector<MSchedGraphNode*> >::const_iterator schedule_const_iterator; 00055 schedule_iterator begin() { return schedule.begin(); }; 00056 schedule_iterator end() { return schedule.end(); }; 00057 void print(std::ostream &os) const; 00058 00059 typedef std::vector<std::pair<MSchedGraphNode*, int> >::iterator kernel_iterator; 00060 typedef std::vector<std::pair<MSchedGraphNode*, int> >::const_iterator kernel_const_iterator; 00061 kernel_iterator kernel_begin() { return kernel.begin(); } 00062 kernel_iterator kernel_end() { return kernel.end(); } 00063 00064 }; 00065 00066 } 00067 00068 00069 #endif