• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef MAPLEBE_INCLUDE_CG_BASE_SCHEDULE_H
16 #define MAPLEBE_INCLUDE_CG_BASE_SCHEDULE_H
17 
18 #include "cgfunc.h"
19 #include "control_dep_analysis.h"
20 #include "data_dep_analysis.h"
21 #include "list_scheduler.h"
22 
23 namespace maplebe {
24 class BaseSchedule {
25 public:
26     BaseSchedule(MemPool &mp, CGFunc &f, ControlDepAnalysis &cdAna, bool doDelay = false)
schedMP(mp)27         : schedMP(mp), schedAlloc(&mp), cgFunc(f), cda(cdAna), doDelayHeu(doDelay)
28     {
29     }
~BaseSchedule()30     virtual ~BaseSchedule()
31     {
32         listScheduler = nullptr;
33     }
34 
35     virtual void Run() = 0;
36     void InitInRegion(CDGRegion &region) const;
37     void DoLocalSchedule(CDGRegion &region);
DoDelayHeu()38     bool DoDelayHeu() const
39     {
40         return doDelayHeu;
41     }
SetDelayHeu()42     void SetDelayHeu()
43     {
44         doDelayHeu = true;
45     }
SetUnitTest(bool flag)46     void SetUnitTest(bool flag)
47     {
48         isUnitTest = flag;
49     }
50 
51 protected:
52     void InitInsnIdAndLocInsn();
53     // Using total number of machine instructions to control the end of the scheduling process
54     void InitMachineInsnNum(CDGNode &cdgNode) const;
55     uint32 CaculateOriginalCyclesOfBB(CDGNode &cdgNode) const;
56     void DumpRegionInfoBeforeSchedule(CDGRegion &region) const;
57     void DumpCDGNodeInfoBeforeSchedule(CDGNode &cdgNode) const;
58     void DumpCDGNodeInfoAfterSchedule(CDGNode &cdgNode) const;
59     void DumpInsnInfoByScheduledOrder(CDGNode &cdgNode) const;
60 
61     MemPool &schedMP;
62     MapleAllocator schedAlloc;
63     CGFunc &cgFunc;
64     ControlDepAnalysis &cda;
65     CommonScheduleInfo *commonSchedInfo = nullptr;
66     ListScheduler *listScheduler = nullptr;
67     bool doDelayHeu = false;
68     bool isUnitTest = false;
69 };
70 }  // namespace maplebe
71 
72 #endif  // MAPLEBE_INCLUDE_CG_BASE_SCHEDULE_H
73