//===-- 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 #include namespace llvm { class MSSchedule { std::map > schedule; unsigned numIssue; //Internal map to keep track of explicit resources std::map > resourceNumPerCycle; //Check if all resources are free bool resourcesFree(MSchedGraphNode*, int, int II); bool resourceAvailable(int resourceNum, int cycle); void useResource(int resourceNum, int cycle); //Resulting kernel std::vector > kernel; //Max stage count int maxStage; //add at the right spot in the schedule void addToSchedule(int, MSchedGraphNode*); public: MSSchedule(int num) : numIssue(num) {} MSSchedule() : numIssue(4) {} bool insert(MSchedGraphNode *node, int cycle, int II); int getStartCycle(MSchedGraphNode *node); void clear() { schedule.clear(); resourceNumPerCycle.clear(); kernel.clear(); } std::vector >* getKernel() { return &kernel; } bool constructKernel(int II, std::vector &branches, std::map &indVar); int getMaxStage() { return maxStage; } bool defPreviousStage(Value *def, int stage); //iterators typedef std::map >::iterator schedule_iterator; typedef std::map >::const_iterator schedule_const_iterator; schedule_iterator begin() { return schedule.begin(); }; schedule_iterator end() { return schedule.end(); }; void print(std::ostream &os) const; typedef std::vector >::iterator kernel_iterator; typedef std::vector >::const_iterator kernel_const_iterator; kernel_iterator kernel_begin() { return kernel.begin(); } kernel_iterator kernel_end() { return kernel.end(); } }; } #endif