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_CG_INCLUDE_AARCH64_PHI_ELIMINATION_H 17 #define MAPLEBE_CG_INCLUDE_AARCH64_PHI_ELIMINATION_H 18 #include "cg_phi_elimination.h" 19 namespace maplebe { 20 class AArch64PhiEliminate : public PhiEliminate { 21 public: AArch64PhiEliminate(CGFunc & f,CGSSAInfo & ssaAnalysisResult,MemPool & mp)22 AArch64PhiEliminate(CGFunc &f, CGSSAInfo &ssaAnalysisResult, MemPool &mp) : PhiEliminate(f, ssaAnalysisResult, mp) 23 { 24 } 25 ~AArch64PhiEliminate() override = default; 26 RegOperand &GetCGVirtualOpearnd(RegOperand &ssaOpnd, const Insn &curInsn /* for remat */); 27 28 private: 29 void ReCreateRegOperand(Insn &insn) override; 30 Insn &CreateMov(RegOperand &destOpnd, RegOperand &fromOpnd) override; 31 void MaintainRematInfo(RegOperand &destOpnd, RegOperand &fromOpnd, bool isCopy) override; 32 RegOperand &CreateTempRegForCSSA(RegOperand &oriOpnd) override; 33 void AppendMovAfterLastVregDef(BB &bb, Insn &movInsn) const override; 34 }; 35 36 class A64OperandPhiElmVisitor : public OperandPhiElmVisitor { 37 public: A64OperandPhiElmVisitor(AArch64PhiEliminate * a64PhiElm,Insn & cInsn,uint32 idx)38 A64OperandPhiElmVisitor(AArch64PhiEliminate *a64PhiElm, Insn &cInsn, uint32 idx) 39 : a64PhiEliminator(a64PhiElm), insn(&cInsn), idx(idx) {}; 40 ~A64OperandPhiElmVisitor() override = default; 41 void Visit(RegOperand *v) final; 42 void Visit(ListOperand *v) final; 43 void Visit(MemOperand *v) final; 44 45 private: 46 AArch64PhiEliminate *a64PhiEliminator; 47 Insn *insn; 48 uint32 idx; 49 }; 50 } // namespace maplebe 51 #endif // MAPLEBE_CG_INCLUDE_AARCH64_PHI_ELIMINATION_H 52