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