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 #include "aarch64_cfgo.h" 17 18 namespace maplebe { 19 /* Initialize cfg optimization patterns */ InitOptimizePatterns()20void AArch64CFGOptimizer::InitOptimizePatterns() 21 { 22 diffPassPatterns.emplace_back(memPool->New<ChainingPattern>(*cgFunc)); 23 if (cgFunc->GetMirModule().IsCModule()) { 24 diffPassPatterns.emplace_back(memPool->New<SequentialJumpPattern>(*cgFunc)); 25 } 26 auto *brOpt = memPool->New<AArch64FlipBRPattern>(*cgFunc, loopInfo); 27 if (GetPhase() == kCfgoPostRegAlloc) { 28 brOpt->SetPhase(kCfgoPostRegAlloc); 29 } 30 diffPassPatterns.emplace_back(brOpt); 31 diffPassPatterns.emplace_back(memPool->New<DuplicateBBPattern>(*cgFunc)); 32 diffPassPatterns.emplace_back(memPool->New<UnreachBBPattern>(*cgFunc)); 33 diffPassPatterns.emplace_back(memPool->New<EmptyBBPattern>(*cgFunc)); 34 } 35 GetJumpTargetIdx(const Insn & insn)36uint32 AArch64FlipBRPattern::GetJumpTargetIdx(const Insn &insn) 37 { 38 return AArch64isa::GetJumpTargetIdx(insn); 39 } 40 FlipConditionOp(MOperator flippedOp)41MOperator AArch64FlipBRPattern::FlipConditionOp(MOperator flippedOp) 42 { 43 return AArch64isa::FlipConditionOp(flippedOp); 44 } 45 GetJumpTargetIdx(const Insn & insn) const46uint32 AArch64CrossJumpBBPattern::GetJumpTargetIdx(const Insn &insn) const 47 { 48 return AArch64isa::GetJumpTargetIdx(insn); 49 } 50 FlipConditionOp(MOperator flippedOp) const51MOperator AArch64CrossJumpBBPattern::FlipConditionOp(MOperator flippedOp) const 52 { 53 return AArch64isa::FlipConditionOp(flippedOp); 54 } 55 } // namespace maplebe 56