LLVM API Documentation

MSScheduleSB.h

Go to the documentation of this file.
00001 //===-- MSScheduleSB.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_MSSCHEDULESB_H
00015 #define LLVM_MSSCHEDULESB_H
00016 
00017 #include "MSchedGraphSB.h"
00018 #include <vector>
00019 #include <set>
00020 
00021 namespace llvm {
00022 
00023   class MSScheduleSB {
00024     std::map<int, std::vector<MSchedGraphSBNode*> > schedule;
00025     unsigned numIssue;
00026 
00027     //Internal map to keep track of explicit resources
00028     std::map<int, std::map<int, int> > resourceNumPerCycle;
00029 
00030     //Check if all resources are free
00031     bool resourcesFree(MSchedGraphSBNode*, int, int II);
00032     bool resourceAvailable(int resourceNum, int cycle);
00033     void useResource(int resourceNum, int cycle);
00034 
00035     //Resulting kernel
00036     std::vector<std::pair<MachineInstr*, int> > kernel;
00037 
00038     //Max stage count
00039     int maxStage;
00040 
00041     //add at the right spot in the schedule
00042     void addToSchedule(int, MSchedGraphSBNode*);
00043 
00044   public:
00045     MSScheduleSB(int num) : numIssue(num) {}
00046     MSScheduleSB() : numIssue(4) {}
00047     bool insert(MSchedGraphSBNode *node, int cycle, int II);
00048     int getStartCycle(MSchedGraphSBNode *node);
00049     void clear() { schedule.clear(); resourceNumPerCycle.clear(); kernel.clear(); }
00050     std::vector<std::pair<MachineInstr*, int> >* getKernel() { return &kernel; }
00051     bool constructKernel(int II, std::vector<MSchedGraphSBNode*> &branches, std::map<const MachineInstr*, unsigned> &indVar);
00052     int getMaxStage() { return maxStage; }
00053     bool defPreviousStage(Value *def, int stage);
00054 
00055     //iterators
00056     typedef std::map<int, std::vector<MSchedGraphSBNode*> >::iterator schedule_iterator;
00057     typedef std::map<int, std::vector<MSchedGraphSBNode*> >::const_iterator schedule_const_iterator;
00058     schedule_iterator begin() { return schedule.begin(); };
00059     schedule_iterator end() { return schedule.end(); };
00060     void print(std::ostream &os) const;
00061     void printSchedule(std::ostream &os) const;
00062 
00063     typedef std::vector<std::pair<MachineInstr*, int> >::iterator kernel_iterator;
00064     typedef std::vector<std::pair<MachineInstr*, int> >::const_iterator kernel_const_iterator;
00065     kernel_iterator kernel_begin() { return kernel.begin(); }
00066     kernel_iterator kernel_end() { return kernel.end(); }
00067 
00068   };
00069 
00070 }
00071 
00072 
00073 #endif