• 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 
16 #ifndef MAPLEBE_INCLUDE_CG_DEPS_H
17 #define MAPLEBE_INCLUDE_CG_DEPS_H
18 
19 #include <array>
20 #include "mad.h"
21 #ifndef ONLY_C
22 #include "pressure.h"
23 #endif
24 #include "cgfunc.h"
25 namespace maplebe {
26 #define PRINT_STR_VAL(STR, VAL) (LogInfo::MapleLogger() << std::left << std::setw(12) << (STR) << (VAL) << " | ")
27 #define PRINT_VAL(VAL) (LogInfo::MapleLogger() << std::left << std::setw(12) << (VAL) << " | ")
28 
29 constexpr uint8 kNumOne = 1;
30 constexpr uint8 kNumTwo = 2;
31 constexpr uint8 kNumThree = 3;
32 constexpr uint8 kNumFour = 4;
33 constexpr uint8 kNumEight = 8;
34 constexpr uint8 kNumTen = 10;
35 constexpr uint8 kNumTwelve = 12;
36 constexpr uint8 kNumFifteen = 15;
37 
38 enum DepType : uint8 {
39     kDependenceTypeTrue,
40     kDependenceTypeOutput,
41     kDependenceTypeAnti,
42     kDependenceTypeControl,
43     kDependenceTypeMemAccess,  // for dependencies between insns of def-use memory operations (alternative true
44                                // dependency)
45     kDependenceTypeMembar,
46     kDependenceTypeThrow,
47     kDependenceTypeSeparator,
48     kDependenceTypeNone
49 };
50 
51 inline const std::array<std::string, kDependenceTypeNone + 1> kDepTypeName = {
52     "true-dep",   "output-dep", "anti-dep",      "control-dep", "memaccess-dep",
53     "membar-dep", "throw-dep",  "separator-dep", "none-dep",
54 };
55 
56 enum NodeType : uint8 { kNodeTypeNormal, kNodeTypeSeparator, kNodeTypeEmpty };
57 
58 enum ScheduleState : uint8 {
59     kNormal,
60     kCandidate,
61     kWaiting,
62     kReady,
63     kScheduled,
64 };
65 
66 enum SimulateState : uint8 {
67     kStateUndef,
68     kRunning,  // the instruction is running
69     kRetired,  // the instruction is executed and returns result
70     kUndefined,
71 };
72 
73 class DepNode;
74 
75 class DepLink {
76 public:
DepLink(DepNode & fromNode,DepNode & toNode,DepType typ)77     DepLink(DepNode &fromNode, DepNode &toNode, DepType typ) : from(fromNode), to(toNode), depType(typ), latency(0) {}
78     virtual ~DepLink() = default;
79 
GetFrom()80     DepNode &GetFrom() const
81     {
82         return from;
83     }
GetTo()84     DepNode &GetTo() const
85     {
86         return to;
87     }
SetDepType(DepType dType)88     void SetDepType(DepType dType)
89     {
90         depType = dType;
91     }
GetDepType()92     DepType GetDepType() const
93     {
94         return depType;
95     }
SetLatency(uint32 lat)96     void SetLatency(uint32 lat)
97     {
98         latency = lat;
99     }
GetLatency()100     uint32 GetLatency() const
101     {
102         return latency;
103     }
104 
105 private:
106     DepNode &from;
107     DepNode &to;
108     DepType depType;
109     uint32 latency;
110 };
111 
112 class RegPressure;
113 class DepNode {
114 public:
DepNode(Insn & insn,MapleAllocator & alloc)115     DepNode(Insn &insn, MapleAllocator &alloc)
116         : insn(&insn),
117           units(nullptr),
118           reservation(nullptr),
119           unitNum(0),
120           eStart(0),
121           lStart(0),
122           visit(0),
123           type(kNodeTypeNormal),
124           state(kNormal),
125           index(0),
126           simulateCycle(0),
127           schedCycle(0),
128           bruteForceSchedCycle(0),
129           validPredsSize(0),
130           validSuccsSize(0),
131           topoPredsSize(0),
132           preds(alloc.Adapter()),
133           succs(alloc.Adapter()),
134           comments(alloc.Adapter()),
135           cfiInsns(alloc.Adapter()),
136           clinitInsns(alloc.Adapter()),
137           locInsn(nullptr),
138           useRegnos(alloc.Adapter()),
139           defRegnos(alloc.Adapter()),
140           regPressure(nullptr)
141     {
142     }
143 
DepNode(Insn & insn,MapleAllocator & alloc,Unit * const * unit,uint32 num,Reservation & rev)144     DepNode(Insn &insn, MapleAllocator &alloc, Unit *const *unit, uint32 num, Reservation &rev)
145         : insn(&insn),
146           units(unit),
147           reservation(&rev),
148           unitNum(num),
149           eStart(0),
150           lStart(0),
151           visit(0),
152           type(kNodeTypeNormal),
153           state(kNormal),
154           index(0),
155           simulateCycle(0),
156           schedCycle(0),
157           bruteForceSchedCycle(0),
158           validPredsSize(0),
159           validSuccsSize(0),
160           topoPredsSize(0),
161           preds(alloc.Adapter()),
162           succs(alloc.Adapter()),
163           comments(alloc.Adapter()),
164           cfiInsns(alloc.Adapter()),
165           clinitInsns(alloc.Adapter()),
166           locInsn(nullptr),
167           useRegnos(alloc.Adapter()),
168           defRegnos(alloc.Adapter()),
169           regPressure(nullptr)
170     {
171     }
172 
173     virtual ~DepNode() = default;
174 
175     /* If the cpu units required by the reservation type of the instruction are
176      * idle, return true.
177      */
IsResourceIdle()178     bool IsResourceIdle() const
179     {
180         // The 'i' indicates cpu cycles, that 0 indicates the current cycle
181         uint32 cycles = reservation->GetUnitNum();
182         Unit *const *requiredUnits = reservation->GetUnit();
183         for (uint32 i = 0; i < cycles; ++i) {
184             Unit *unit = requiredUnits[i];
185             if (unit != nullptr) {
186                 if (!unit->IsIdle(i)) {
187                     return false;
188                 }
189             }
190         }
191         return true;
192     }
193 
194     /* When an instruction is issued, occupy all units required in the specific
195      * cycle
196      */
OccupyRequiredUnits()197     void OccupyRequiredUnits() const
198     {
199         // The 'i' indicates cpu cycles, that 0 indicates the current cycle
200         uint32 cycles = reservation->GetUnitNum();
201         Unit *const *requiredUnits = reservation->GetUnit();
202         for (uint32 i = 0; i < cycles; ++i) {
203             Unit *unit = requiredUnits[i];
204             if (unit != nullptr) {
205                 unit->Occupy(i);
206             }
207         }
208     }
209 
210     /* Get unit kind of this node's units[0] */
GetUnitKind()211     uint32 GetUnitKind() const
212     {
213         uint32 retValue = 0;
214         if ((units == nullptr) || (units[0] == nullptr)) {
215             return retValue;
216         }
217 
218         switch (units[0]->GetUnitId()) {
219             case kUnitIdSlotD:
220                 retValue |= kUnitKindSlot0;
221                 break;
222             case kUnitIdAgen:
223             case kUnitIdSlotSAgen:
224                 retValue |= kUnitKindAgen;
225                 break;
226             case kUnitIdSlotDAgen:
227                 retValue |= kUnitKindAgen;
228                 retValue |= kUnitKindSlot0;
229                 break;
230             case kUnitIdHazard:
231             case kUnitIdSlotSHazard:
232                 retValue |= kUnitKindHazard;
233                 break;
234             case kUnitIdCrypto:
235                 retValue |= kUnitKindCrypto;
236                 break;
237             case kUnitIdMul:
238             case kUnitIdSlotSMul:
239                 retValue |= kUnitKindMul;
240                 break;
241             case kUnitIdDiv:
242                 retValue |= kUnitKindDiv;
243                 break;
244             case kUnitIdBranch:
245             case kUnitIdSlotSBranch:
246                 retValue |= kUnitKindBranch;
247                 break;
248             case kUnitIdStAgu:
249                 retValue |= kUnitKindStAgu;
250                 break;
251             case kUnitIdLdAgu:
252                 retValue |= kUnitKindLdAgu;
253                 break;
254             case kUnitIdFpAluS:
255             case kUnitIdFpAluD:
256                 retValue |= kUnitKindFpAlu;
257                 break;
258             case kUnitIdFpMulS:
259             case kUnitIdFpMulD:
260                 retValue |= kUnitKindFpMul;
261                 break;
262             case kUnitIdFpDivS:
263             case kUnitIdFpDivD:
264                 retValue |= kUnitKindFpDiv;
265                 break;
266             case kUnitIdSlot0LdAgu:
267                 retValue |= kUnitKindSlot0;
268                 retValue |= kUnitKindLdAgu;
269                 break;
270             case kUnitIdSlot0StAgu:
271                 retValue |= kUnitKindSlot0;
272                 retValue |= kUnitKindStAgu;
273                 break;
274             default:
275                 break;
276         }
277 
278         return retValue;
279     }
280 
GetInsn()281     Insn *GetInsn() const
282     {
283         return insn;
284     }
SetInsn(Insn & rvInsn)285     void SetInsn(Insn &rvInsn)
286     {
287         insn = &rvInsn;
288     }
SetUnits(Unit * const * unit)289     void SetUnits(Unit *const *unit)
290     {
291         units = unit;
292     }
GetUnitByIndex(uint32 idx)293     const Unit *GetUnitByIndex(uint32 idx) const
294     {
295         DEBUG_ASSERT(idx < unitNum, "out of units");
296         return units[idx];
297     }
GetReservation()298     Reservation *GetReservation() const
299     {
300         return reservation;
301     }
SetReservation(Reservation & rev)302     void SetReservation(Reservation &rev)
303     {
304         reservation = &rev;
305     }
GetUnitNum()306     uint32 GetUnitNum() const
307     {
308         return unitNum;
309     }
SetUnitNum(uint32 num)310     void SetUnitNum(uint32 num)
311     {
312         unitNum = num;
313     }
GetEStart()314     uint32 GetEStart() const
315     {
316         return eStart;
317     }
SetEStart(uint32 start)318     void SetEStart(uint32 start)
319     {
320         eStart = start;
321     }
GetLStart()322     uint32 GetLStart() const
323     {
324         return lStart;
325     }
SetLStart(uint32 start)326     void SetLStart(uint32 start)
327     {
328         lStart = start;
329     }
GetDelay()330     uint32 GetDelay() const
331     {
332         return delay;
333     }
SetDelay(uint32 prio)334     void SetDelay(uint32 prio)
335     {
336         delay = prio;
337     }
GetVisit()338     uint32 GetVisit() const
339     {
340         return visit;
341     }
SetVisit(uint32 visitVal)342     void SetVisit(uint32 visitVal)
343     {
344         visit = visitVal;
345     }
IncreaseVisit()346     void IncreaseVisit()
347     {
348         ++visit;
349     }
GetType()350     NodeType GetType() const
351     {
352         return type;
353     }
SetType(NodeType nodeType)354     void SetType(NodeType nodeType)
355     {
356         type = nodeType;
357     }
GetState()358     ScheduleState GetState() const
359     {
360         return state;
361     }
SetState(ScheduleState scheduleState)362     void SetState(ScheduleState scheduleState)
363     {
364         state = scheduleState;
365     }
GetIndex()366     uint32 GetIndex() const
367     {
368         return index;
369     }
SetIndex(uint32 idx)370     void SetIndex(uint32 idx)
371     {
372         index = idx;
373     }
SetSchedCycle(uint32 cycle)374     void SetSchedCycle(uint32 cycle)
375     {
376         schedCycle = cycle;
377     }
GetSchedCycle()378     uint32 GetSchedCycle() const
379     {
380         return schedCycle;
381     }
SetSimulateCycle(uint32 cycle)382     void SetSimulateCycle(uint32 cycle)
383     {
384         simulateCycle = cycle;
385     }
GetSimulateCycle()386     uint32 GetSimulateCycle() const
387     {
388         return simulateCycle;
389     }
SetBruteForceSchedCycle(uint32 cycle)390     void SetBruteForceSchedCycle(uint32 cycle)
391     {
392         bruteForceSchedCycle = cycle;
393     }
GetBruteForceSchedCycle()394     uint32 GetBruteForceSchedCycle() const
395     {
396         return bruteForceSchedCycle;
397     }
SetValidPredsSize(uint32 validSize)398     void SetValidPredsSize(uint32 validSize)
399     {
400         validPredsSize = validSize;
401     }
GetValidPredsSize()402     uint32 GetValidPredsSize() const
403     {
404         return validPredsSize;
405     }
DecreaseValidPredsSize()406     void DecreaseValidPredsSize()
407     {
408         --validPredsSize;
409     }
IncreaseValidPredsSize()410     void IncreaseValidPredsSize()
411     {
412         ++validPredsSize;
413     }
GetValidSuccsSize()414     uint32 GetValidSuccsSize() const
415     {
416         return validSuccsSize;
417     }
SetValidSuccsSize(uint32 size)418     void SetValidSuccsSize(uint32 size)
419     {
420         validSuccsSize = size;
421     }
DecreaseValidSuccsSize()422     void DecreaseValidSuccsSize()
423     {
424         --validSuccsSize;
425     }
GetTopoPredsSize()426     uint32 GetTopoPredsSize()
427     {
428         return topoPredsSize;
429     }
SetTopoPredsSize(uint32 size)430     void SetTopoPredsSize(uint32 size)
431     {
432         topoPredsSize = size;
433     }
IncreaseTopoPredsSize()434     void IncreaseTopoPredsSize()
435     {
436         ++topoPredsSize;
437     }
DecreaseTopoPredsSize()438     void DecreaseTopoPredsSize()
439     {
440         --topoPredsSize;
441     }
GetPreds()442     const MapleVector<DepLink *> &GetPreds() const
443     {
444         return preds;
445     }
GetPredsBegin()446     MapleVector<DepLink *>::iterator GetPredsBegin()
447     {
448         return preds.begin();
449     }
GetPredsEnd()450     MapleVector<DepLink *>::iterator GetPredsEnd()
451     {
452         return preds.end();
453     }
ReservePreds(size_t size)454     void ReservePreds(size_t size)
455     {
456         preds.reserve(size);
457     }
AddPred(DepLink & depLink)458     void AddPred(DepLink &depLink)
459     {
460         preds.emplace_back(&depLink);
461     }
RemovePred()462     void RemovePred()
463     {
464         preds.pop_back();
465     }
466     /* For mock data dependency graph, do not use in normal process */
ErasePred(const DepLink & predLink)467     void ErasePred(const DepLink &predLink)
468     {
469         for (auto iter = preds.begin(); iter != preds.end(); ++iter) {
470             DepNode &predNode = (*iter)->GetFrom();
471             if (predNode.GetInsn()->GetId() == predLink.GetFrom().GetInsn()->GetId()) {
472                 (void)preds.erase(iter);
473                 return;
474             }
475         }
476     }
GetSuccs()477     const MapleVector<DepLink *> &GetSuccs() const
478     {
479         return succs;
480     }
GetSuccsBegin()481     MapleVector<DepLink *>::iterator GetSuccsBegin()
482     {
483         return succs.begin();
484     }
GetSuccsEnd()485     MapleVector<DepLink *>::iterator GetSuccsEnd()
486     {
487         return succs.end();
488     }
ReserveSuccs(size_t size)489     void ReserveSuccs(size_t size)
490     {
491         succs.reserve(size);
492     }
AddSucc(DepLink & depLink)493     void AddSucc(DepLink &depLink)
494     {
495         succs.emplace_back(&depLink);
496     }
RemoveSucc()497     void RemoveSucc()
498     {
499         succs.pop_back();
500     }
501     /* For mock data dependency graph */
EraseSucc(const MapleVector<DepLink * >::iterator iter)502     MapleVector<DepLink *>::iterator EraseSucc(const MapleVector<DepLink *>::iterator iter)
503     {
504         return succs.erase(iter);
505     }
GetComments()506     const MapleVector<Insn *> &GetComments() const
507     {
508         return comments;
509     }
SetComments(MapleVector<Insn * > com)510     void SetComments(MapleVector<Insn *> com)
511     {
512         comments = com;
513     }
AddComments(Insn & addInsn)514     void AddComments(Insn &addInsn)
515     {
516         comments.emplace_back(&addInsn);
517     }
ClearComments()518     void ClearComments()
519     {
520         comments.clear();
521     }
GetCfiInsns()522     const MapleVector<Insn *> &GetCfiInsns() const
523     {
524         return cfiInsns;
525     }
SetCfiInsns(MapleVector<Insn * > insns)526     void SetCfiInsns(MapleVector<Insn *> insns)
527     {
528         cfiInsns = insns;
529     }
AddCfiInsn(Insn & curInsn)530     void AddCfiInsn(Insn &curInsn)
531     {
532         (void)cfiInsns.emplace_back(&curInsn);
533     }
ClearCfiInsns()534     void ClearCfiInsns()
535     {
536         cfiInsns.clear();
537     }
GetClinitInsns()538     const MapleVector<Insn *> &GetClinitInsns() const
539     {
540         return clinitInsns;
541     }
SetClinitInsns(MapleVector<Insn * > insns)542     void SetClinitInsns(MapleVector<Insn *> insns)
543     {
544         clinitInsns = insns;
545     }
AddClinitInsn(Insn & addInsn)546     void AddClinitInsn(Insn &addInsn)
547     {
548         (void)clinitInsns.emplace_back(&addInsn);
549     }
GetRegPressure()550     const RegPressure *GetRegPressure() const
551     {
552         return regPressure;
553     }
SetRegPressure(RegPressure & pressure)554     void SetRegPressure(RegPressure &pressure)
555     {
556         regPressure = &pressure;
557     }
DumpRegPressure()558     void DumpRegPressure() const
559     {
560         if (regPressure) {
561             regPressure->DumpRegPressure();
562         }
563     }
InitPressure()564     void InitPressure() const
565     {
566 #ifndef ONLY_C
567         regPressure->InitPressure();
568 #endif
569     }
570 #ifndef ONLY_C
GetPressure()571     const MapleVector<int32> &GetPressure() const
572     {
573         return regPressure->GetPressure();
574     }
575 #endif
576 
IncPressureByIndex(int32 idx)577     void IncPressureByIndex(int32 idx) const
578     {
579 #ifndef ONLY_C
580         regPressure->IncPressureByIndex(static_cast<uint32>(idx));
581 #endif
582     }
DecPressureByIndex(int32 idx)583     void DecPressureByIndex(int32 idx) const
584     {
585 #ifndef ONLY_C
586         regPressure->DecPressureByIndex(static_cast<uint32>(idx));
587 #endif
588     }
589 #ifndef ONLY_C
GetDeadDefNum()590     const MapleVector<int32> &GetDeadDefNum() const
591     {
592         return regPressure->GetDeadDefNum();
593     }
594 #endif
IncDeadDefByIndex(int32 idx)595     void IncDeadDefByIndex(int32 idx) const
596     {
597 #ifndef ONLY_C
598         regPressure->IncDeadDefByIndex(static_cast<uint32>(idx));
599 #endif
600     }
601 
SetRegUses(RegList & regList)602     void SetRegUses(RegList &regList) const
603     {
604 #ifndef ONLY_C
605         regPressure->SetRegUses(&regList);
606 #endif
607     }
SetRegDefs(size_t idx,RegList * regList)608     void SetRegDefs(size_t idx, RegList *regList) const
609     {
610 #ifndef ONLY_C
611         regPressure->SetRegDefs(idx, regList);
612 #endif
613     }
614 
GetIncPressure()615     bool GetIncPressure() const
616     {
617 #ifndef ONLY_C
618         return regPressure->GetIncPressure();
619 #else
620         return false;
621 #endif
622     }
SetIncPressure(bool value)623     void SetIncPressure(bool value) const
624     {
625 #ifndef ONLY_C
626         regPressure->SetIncPressure(value);
627 #endif
628     }
GetMaxDepth()629     int32 GetMaxDepth() const
630     {
631 #ifndef ONLY_C
632         return regPressure->GetMaxDepth();
633 #else
634         return 0;
635 #endif
636     }
SetMaxDepth(int32 value)637     void SetMaxDepth(int32 value) const
638     {
639 #ifndef ONLY_C
640         regPressure->SetMaxDepth(value);
641 #endif
642     }
GetNear()643     int32 GetNear() const
644     {
645 #ifndef ONLY_C
646         return regPressure->GetNear();
647 #else
648         return 0;
649 #endif
650     }
SetNear(int32 value)651     void SetNear(int32 value) const
652     {
653 #ifndef ONLY_C
654         regPressure->SetNear(value);
655 #endif
656     }
GetPriority()657     int32 GetPriority() const
658     {
659 #ifndef ONLY_C
660         return regPressure->GetPriority();
661 #else
662         return 0;
663 #endif
664     }
SetPriority(int32 value)665     void SetPriority(int32 value) const
666     {
667 #ifndef ONLY_C
668         regPressure->SetPriority(value);
669 #endif
670     }
GetRegUses(size_t idx)671     RegList *GetRegUses(size_t idx) const
672     {
673 #ifndef ONLY_C
674         return regPressure->GetRegUses(idx);
675 #else
676         return nullptr;
677 #endif
678     }
InitRegUsesSize(size_t size)679     void InitRegUsesSize(size_t size) const
680     {
681 #ifndef ONLY_C
682         regPressure->InitRegUsesSize(size);
683 #endif
684     }
GetRegDefs(size_t idx)685     RegList *GetRegDefs(size_t idx) const
686     {
687 #ifndef ONLY_C
688         return regPressure->GetRegDefs(idx);
689 #else
690         return nullptr;
691 #endif
692     }
InitRegDefsSize(size_t size)693     void InitRegDefsSize(size_t size) const
694     {
695 #ifndef ONLY_C
696         regPressure->InitRegDefsSize(size);
697 #endif
698     }
699 
SetNumCall(int32 value)700     void SetNumCall(int32 value) const
701     {
702 #ifndef ONLY_C
703         regPressure->SetNumCall(value);
704 #endif
705     }
706 
GetNumCall()707     int32 GetNumCall() const
708     {
709 #ifndef ONLY_C
710         return regPressure->GetNumCall();
711 #else
712         return 0;
713 #endif
714     }
715 
SetHasNativeCallRegister(bool value)716     void SetHasNativeCallRegister(bool value) const
717     {
718 #ifndef ONLY_C
719         regPressure->SetHasNativeCallRegister(value);
720 #endif
721     }
722 
GetHasNativeCallRegister()723     bool GetHasNativeCallRegister() const
724     {
725 #ifndef ONLY_C
726         return regPressure->GetHasNativeCallRegister();
727 #else
728         return false;
729 #endif
730     }
731 
GetLocInsn()732     const Insn *GetLocInsn() const
733     {
734         return locInsn;
735     }
SetLocInsn(const Insn & locationInsn)736     void SetLocInsn(const Insn &locationInsn)
737     {
738         locInsn = &locationInsn;
739     }
740 
741     /* printf dep-node's information of scheduling */
DumpSchedInfo()742     void DumpSchedInfo() const
743     {
744         PRINT_STR_VAL("estart: ", eStart);
745         PRINT_STR_VAL("lstart: ", lStart);
746         PRINT_STR_VAL("visit: ", visit);
747         PRINT_STR_VAL("state: ", state);
748         PRINT_STR_VAL("index: ", index);
749         PRINT_STR_VAL("validPredsSize: ", validPredsSize);
750         PRINT_STR_VAL("validSuccsSize: ", validSuccsSize);
751         LogInfo::MapleLogger() << '\n';
752 
753         constexpr int32 width = 12;
754         LogInfo::MapleLogger() << std::left << std::setw(width) << "usereg: ";
755         for (const auto &useReg : useRegnos) {
756             LogInfo::MapleLogger() << "R" << useReg << " ";
757         }
758         LogInfo::MapleLogger() << "\n";
759         LogInfo::MapleLogger() << std::left << std::setw(width) << "defreg: ";
760         for (const auto &defReg : defRegnos) {
761             LogInfo::MapleLogger() << "R" << defReg << " ";
762         }
763         LogInfo::MapleLogger() << "\n";
764     }
765 
SetHasPreg(bool value)766     void SetHasPreg(bool value) const
767     {
768 #ifndef ONLY_C
769         regPressure->SetHasPreg(value);
770 #endif
771     }
772 
GetHasPreg()773     bool GetHasPreg() const
774     {
775 #ifndef ONLY_C
776         return regPressure->GetHasPreg();
777 #else
778         return false;
779 #endif
780     }
781 
AddUseReg(regno_t reg)782     void AddUseReg(regno_t reg)
783     {
784         useRegnos.emplace_back(reg);
785     }
786 
GetUseRegnos()787     const MapleVector<regno_t> &GetUseRegnos() const
788     {
789         return useRegnos;
790     }
791 
AddDefReg(regno_t reg)792     void AddDefReg(regno_t reg)
793     {
794         defRegnos.emplace_back(reg);
795     }
796 
GetDefRegnos()797     const MapleVector<regno_t> &GetDefRegnos() const
798     {
799         return defRegnos;
800     }
801 
SetSimulateState(SimulateState simulateState)802     void SetSimulateState(SimulateState simulateState)
803     {
804         simuState = simulateState;
805     }
806 
GetSimulateState()807     SimulateState GetSimulateState() const
808     {
809         return simuState;
810     }
811 
SetSimulateIssueCycle(uint32 cycle)812     void SetSimulateIssueCycle(uint32 cycle)
813     {
814         simulateIssueCycle = cycle;
815     }
816 
GetSimulateIssueCycle()817     uint32 GetSimulateIssueCycle() const
818     {
819         return simulateIssueCycle;
820     }
821 
822 private:
823     Insn *insn;
824     Unit *const *units;
825     Reservation *reservation;
826     uint32 unitNum;
827     uint32 eStart;
828     uint32 lStart;
829     uint32 delay = 0;  // Identify the critical path priority
830     uint32 visit;
831     NodeType type;
832     ScheduleState state;
833     uint32 index;
834     uint32 simulateCycle;
835     uint32 schedCycle;
836     uint32 bruteForceSchedCycle;
837 
838     /* For scheduling, denotes unscheduled preds/succs number. */
839     uint32 validPredsSize;
840     uint32 validSuccsSize;
841 
842     /* For compute eStart by topological order */
843     uint32 topoPredsSize;
844 
845     /* Dependence links. */
846     MapleVector<DepLink *> preds;
847     MapleVector<DepLink *> succs;
848 
849     /* Non-machine instructions prior to insn, such as comments. */
850     MapleVector<Insn *> comments;
851 
852     /* Non-machine instructions which follows insn, such as cfi instructions. */
853     MapleVector<Insn *> cfiInsns;
854 
855     /* Special instructions which follows insn, such as clinit instructions. */
856     MapleVector<Insn *> clinitInsns;
857 
858     /* loc insn which indicate insn location in source file */
859     const Insn *locInsn;
860 
861     MapleVector<regno_t> useRegnos;
862     MapleVector<regno_t> defRegnos;
863 
864     /* For register pressure analysis */
865     RegPressure *regPressure;
866     SimulateState simuState = kUndefined;  // For calculating original cycles of BB
867     uint32 simulateIssueCycle = 0;  // For calculating original cycles of BB, record the cycle when the insn issuing
868 };
869 } /* namespace maplebe */
870 
871 #endif /* MAPLEBE_INCLUDE_CG_DEPS_H */
872