• 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_AARCH64_AARCH64_REGCOALESCE_H
17 #define MAPLEBE_INCLUDE_CG_AARCH64_AARCH64_REGCOALESCE_H
18 #include "reg_coalesce.h"
19 #include "aarch64_isa.h"
20 #include "live.h"
21 
22 namespace maplebe {
23 class AArch64LiveIntervalAnalysis : public LiveIntervalAnalysis {
24 public:
AArch64LiveIntervalAnalysis(CGFunc & func,MemPool & memPool)25     AArch64LiveIntervalAnalysis(CGFunc &func, MemPool &memPool)
26         : LiveIntervalAnalysis(func, memPool), vregLive(alloc.Adapter()), candidates(alloc.Adapter())
27     {
28     }
29 
30     ~AArch64LiveIntervalAnalysis() override = default;
31 
32     void ComputeLiveIntervals() override;
33     bool IsUnconcernedReg(const RegOperand &regOpnd) const;
34     LiveInterval *GetOrCreateLiveInterval(regno_t regNO);
35     void UpdateCallInfo();
36     void SetupLiveIntervalByOp(Operand &op, Insn &insn, bool isDef);
37     void ComputeLiveIntervalsForEachDefOperand(Insn &insn);
38     void ComputeLiveIntervalsForEachUseOperand(Insn &insn);
39     void SetupLiveIntervalInLiveOut(regno_t liveOut, const BB &bb, uint32 currPoint);
40     void CoalesceRegPair(RegOperand &regDest, RegOperand &regSrc);
41     void CoalesceRegisters() override;
42     void CollectMoveForEachBB(BB &bb, std::vector<Insn *> &movInsns) const;
43     void CoalesceMoves(std::vector<Insn *> &movInsns, bool phiOnly);
44     void CheckInterference(LiveInterval &li1, LiveInterval &li2) const;
45     void CollectCandidate();
PhaseName()46     std::string PhaseName() const
47     {
48         return "regcoalesce";
49     }
50 
51 private:
52     static bool IsRegistersCopy(Insn &insn);
53     MapleUnorderedSet<regno_t> vregLive;
54     MapleSet<regno_t> candidates;
55 };
56 
57 } /* namespace maplebe */
58 
59 #endif /* MAPLEBE_INCLUDE_CG_AARCH64_AARCH64_REGCOALESCE_H */
60