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_X64_LOCALO_H 17 #define MAPLEBE_INCLUDE_X64_LOCALO_H 18 19 #include "local_opt.h" 20 namespace maplebe { 21 class X64LocalOpt : public LocalOpt { 22 public: X64LocalOpt(MemPool & memPool,CGFunc & func,ReachingDefinition & rd)23 X64LocalOpt(MemPool &memPool, CGFunc &func, ReachingDefinition &rd) : LocalOpt(memPool, func, rd) {} 24 ~X64LocalOpt() = default; 25 26 private: 27 void DoLocalCopyProp() override; 28 }; 29 30 class LocalCopyRegProp : public LocalPropOptimizePattern { 31 public: LocalCopyRegProp(CGFunc & cgFunc,ReachingDefinition & rd)32 LocalCopyRegProp (CGFunc &cgFunc, ReachingDefinition &rd) : LocalPropOptimizePattern(cgFunc, rd) {} 33 ~LocalCopyRegProp () override = default; 34 bool CheckCondition(Insn &insn) final; 35 void Optimize(BB &bb, Insn &insn) final; 36 37 private: 38 bool propagateOperand(Insn &insn, RegOperand &oldOpnd, RegOperand &replaceOpnd); 39 }; 40 41 class X64RedundantDefRemove : public RedundantDefRemove { 42 public: X64RedundantDefRemove(CGFunc & cgFunc,ReachingDefinition & rd)43 X64RedundantDefRemove(CGFunc &cgFunc, ReachingDefinition &rd) : RedundantDefRemove(cgFunc, rd) {} 44 ~X64RedundantDefRemove() override = default; 45 void Optimize(BB &bb, Insn &insn) final; 46 }; 47 48 } // namespace maplebe 49 50 #endif /* MAPLEBE_INCLUDE_X64_LOCALO_H */ 51