• 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_ICO_H
17 #define MAPLEBE_INCLUDE_CG_ICO_H
18 #include "optimize_common.h"
19 #include "live.h"
20 
21 namespace maplebe {
22 class IfConversionOptimizer : public Optimizer {
23 public:
IfConversionOptimizer(CGFunc & func,MemPool & memPool)24     IfConversionOptimizer(CGFunc &func, MemPool &memPool) : Optimizer(func, memPool)
25     {
26         name = "ICO";
27     }
28 
29     ~IfConversionOptimizer() override = default;
30 };
31 
32 /* If-Then-Else pattern */
33 class ICOPattern : public OptimizationPattern {
34 public:
ICOPattern(CGFunc & func)35     explicit ICOPattern(CGFunc &func) : OptimizationPattern(func)
36     {
37         dotColor = kIcoIte;
38         patternName = "If-Then-Else";
39     }
40     ~ICOPattern() override = default;
41     static constexpr int kThreshold = 2;
42 
43 protected:
44     Insn *FindLastCmpInsn(BB &bb) const;
45     std::vector<LabelOperand *> GetLabelOpnds(Insn &insn) const;
46 };
47 
48 MAPLE_FUNC_PHASE_DECLARE(CgIco, maplebe::CGFunc)
49 } /* namespace maplebe */
50 
51 #endif /* MAPLEBE_INCLUDE_CG_ICO_H */
52