• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_PASS_OPTIONS_H
17 #define ECMASCRIPT_COMPILER_PASS_OPTIONS_H
18 
19 namespace panda::ecmascript::kungfu {
20 #define OPTION_LIST(V)                                                           \
21     V(ArrayBoundsCheckElimination, true)                                         \
22     V(TypeLowering, true)                                                        \
23     V(EarlyElimination, true)                                                    \
24     V(LaterElimination, true)                                                    \
25     V(ValueNumbering, false)                                                     \
26     V(OptInlining, false)                                                        \
27     V(OptNoGCCall, false)                                                        \
28     V(OptPGOType, false)                                                         \
29     V(NoCheck, false)                                                            \
30     V(OptString, true)                                                           \
31     V(OptTrackField, false)                                                      \
32     V(OptLoopPeeling, false)                                                     \
33     V(OptLoopInvariantCodeMotion, false)                                         \
34     V(CollectLiteralInfo, false)                                                 \
35     V(OptConstantFolding, true)                                                  \
36     V(LexenvSpecialization, false)                                               \
37     V(InlineNative, false)                                                       \
38     V(LoweringBuiltin, false)                                                    \
39     V(FastModule, false)                                                         \
40     V(OptBranchProfiling, true)                                                  \
41     V(EscapeAnalysis, false)                                                     \
42     V(InductionVariableAnalysis, false)                                          \
43     V(VerifierPass, true)
44 
45 #define OPTION_BUILDER(NAME, DEFAULT)                                            \
46     Builder &Enable##NAME(bool value) {                                          \
47         options_.enable##NAME##_ = value;                                        \
48         return *this;                                                            \
49     }
50 
51 #define OPTIONS(NAME, DEFAULT) bool                                              \
52     enable##NAME##_{DEFAULT};
53 
54 #define GET_OPTION(NAME, DEFAULT)                                                \
55     bool Enable##NAME() const { return enable##NAME##_; }
56 
57 #define SET_OPTION(NAME, DEFAULT)                                                \
58     void Set##NAME(bool value) { enable##NAME##_ = value; }
59 
60 class PassOptions {
61 public:
62     PassOptions() = default;
63     class Builder;
64     OPTION_LIST(GET_OPTION)
65     OPTION_LIST(SET_OPTION)
66 
67 private:
68     OPTION_LIST(OPTIONS)
69 };
70 
71 class PassOptions::Builder {
72 public:
OPTION_LIST(OPTION_BUILDER)73     OPTION_LIST(OPTION_BUILDER)
74     PassOptions Build() { return options_; }
75 
76 private:
77     PassOptions options_{};
78 };
79 #undef OPTION_BUILDER
80 #undef GET_OPTION
81 #undef OPTIONS
82 #undef OPTION_LIST
83 } // namespace panda::ecmascript::kungfu
84 #endif // ECMASCRIPT_COMPILER_PASS_OPTIONS_H