• 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_CFGO_H
17 #define MAPLEBE_INCLUDE_CG_AARCH64_AARCH64_CFGO_H
18 
19 #include "cfgo.h"
20 #include "aarch64_isa.h"
21 
22 namespace maplebe {
23 class AArch64CFGOptimizer : public CFGOptimizer {
24 public:
AArch64CFGOptimizer(CGFunc & func,MemPool & memPool,LoopAnalysis & loop)25     AArch64CFGOptimizer(CGFunc &func, MemPool &memPool, LoopAnalysis &loop) : CFGOptimizer(func, memPool, loop) {}
26     ~AArch64CFGOptimizer() override = default;
27     void InitOptimizePatterns() override;
28 };
29 
30 class AArch64FlipBRPattern : public FlipBRPattern {
31 public:
AArch64FlipBRPattern(CGFunc & func,LoopAnalysis & loop)32     explicit AArch64FlipBRPattern(CGFunc &func, LoopAnalysis &loop) : FlipBRPattern(func, loop) {}
33     ~AArch64FlipBRPattern() override = default;
34 
35 private:
36     uint32 GetJumpTargetIdx(const Insn &insn) override;
37     MOperator FlipConditionOp(MOperator flippedOp) override;
38 };
39 
40 class AArch64CrossJumpBBPattern : public CrossJumpBBPattern {
41 public:
AArch64CrossJumpBBPattern(CGFunc & func)42     explicit AArch64CrossJumpBBPattern(CGFunc &func) : CrossJumpBBPattern(func) {}
43     ~AArch64CrossJumpBBPattern() override = default;
44 
45 private:
46     uint32 GetJumpTargetIdx(const Insn &insn) const override;
47     MOperator FlipConditionOp(MOperator flippedOp) const override;
GetUnCondBranchMOP()48     MOperator GetUnCondBranchMOP() const override
49     {
50         return MOP_xuncond;
51     }
52 };
53 } /* namespace maplebe */
54 
55 #endif /* MAPLEBE_INCLUDE_CG_AARCH64_AARCH64_CFGO_H */
56