• 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_X64_X64_PEEP_H
17 #define MAPLEBE_INCLUDE_CG_X64_X64_PEEP_H
18 
19 #include <vector>
20 #include "peep.h"
21 
22 namespace maplebe {
23 class X64CGPeepHole : public CGPeepHole {
24 public:
25     /* normal constructor */
X64CGPeepHole(CGFunc & f,MemPool * memPool)26     X64CGPeepHole(CGFunc &f, MemPool *memPool) : CGPeepHole(f, memPool) {};
27     /* constructor for ssa */
X64CGPeepHole(CGFunc & f,MemPool * memPool,CGSSAInfo * cgssaInfo)28     X64CGPeepHole(CGFunc &f, MemPool *memPool, CGSSAInfo *cgssaInfo) : CGPeepHole(f, memPool, cgssaInfo) {};
29     ~X64CGPeepHole() = default;
30     void Run() override;
31     bool DoSSAOptimize(BB &bb, Insn &insn) override;
32     void DoNormalOptimize(BB &bb, Insn &insn) override;
33 };
34 
35 class X64RemoveMovingtoSameRegPattern : public CGPeepPattern {
36 public:
X64RemoveMovingtoSameRegPattern(CGFunc & cgFunc,BB & currBB,Insn & currInsn)37     X64RemoveMovingtoSameRegPattern(CGFunc &cgFunc,
38         BB &currBB, Insn &currInsn) : CGPeepPattern(cgFunc, currBB, currInsn)
39     {
40     }
41     ~X64RemoveMovingtoSameRegPattern() override = default;
42     void Run(BB &bb, Insn &insn) override;
43     bool CheckCondition(Insn &insn) override;
GetPatternName()44     std::string GetPatternName() override
45     {
46         return "X64RemoveMovingtoSameRegPattern";
47     }
48 };
49 
50 } /* namespace maplebe */
51 #endif /* MAPLEBE_INCLUDE_CG_AARCH64_AARCH64_PEEP_H */
52