• 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 ECMASCRIPT_COMPILER_STATE_SPLIT_LINEARIZER_H
17 #define ECMASCRIPT_COMPILER_STATE_SPLIT_LINEARIZER_H
18 
19 #include <numeric>
20 
21 #include "ecmascript/compiler/circuit.h"
22 #include "ecmascript/compiler/gate_accessor.h"
23 #include "ecmascript/compiler/lcr_lowering.h"
24 #include "ecmascript/compiler/graph_linearizer.h"
25 #include "ecmascript/mem/chunk_containers.h"
26 
27 namespace panda::ecmascript::kungfu {
28 class StateSplitLinearizer {
29 public:
StateSplitLinearizer(Circuit * circuit,CompilationConfig * cmpCfg,bool enableLog,const std::string & name,Chunk * chunk)30     StateSplitLinearizer(Circuit *circuit, CompilationConfig *cmpCfg,
31                          bool enableLog, const std::string& name, Chunk* chunk)
32         : enableLog_(enableLog), methodName_(name), circuit_(circuit),
33         graphLinearizer_(circuit, enableLog, name, chunk),
34         lcrLowering_(circuit, cmpCfg, enableLog, name) {}
35 
36     void Run();
37 private:
IsLogEnabled()38     bool IsLogEnabled() const
39     {
40         return enableLog_;
41     }
42 
GetMethodName()43     const std::string& GetMethodName() const
44     {
45         return methodName_;
46     }
47 
48     void LinearizeStateSplit();
49 
50     bool enableLog_ {false};
51     std::string methodName_;
52     Circuit* circuit_ {nullptr};
53     GraphLinearizer graphLinearizer_;
54     LCRLowering lcrLowering_;
55     friend class StateDependBuilder;
56 };
57 };  // namespace panda::ecmascript::kungfu
58 
59 #endif  // ECMASCRIPT_COMPILER_STATE_SPLIT_LINEARIZER_H
60