• 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 MPL2MPL_INCLUDE_EXTCONSTANTFOLD_H
17 #define MPL2MPL_INCLUDE_EXTCONSTANTFOLD_H
18 #include "mir_nodes.h"
19 #include "phase_impl.h"
20 
21 namespace maple {
22 class ExtConstantFold {
23 public:
ExtConstantFold(MIRModule * mod)24     explicit ExtConstantFold(MIRModule *mod) : mirModule(mod) {}
25     BaseNode *ExtFoldUnary(UnaryNode *node);
26     BaseNode *ExtFoldBinary(BinaryNode *node);
27     BaseNode *ExtFoldTernary(TernaryNode *node);
28     StmtNode *ExtSimplify(StmtNode *node);
29     BaseNode *ExtFold(BaseNode *node);
30     StmtNode *ExtSimplifyBlock(BlockNode *node);
31     StmtNode *ExtSimplifyIf(IfStmtNode *node);
32     StmtNode *ExtSimplifyDassign(DassignNode *node);
33     StmtNode *ExtSimplifyIassign(IassignNode *node);
34     StmtNode *ExtSimplifyWhile(WhileStmtNode *node);
35     BaseNode *DispatchFold(BaseNode *node);
36 
37     MIRModule *mirModule;
38 };
39 }  // namespace maple
40 #endif  // MPL2MPL_INCLUDE_EXTCONSTANTFOLD_H
41