• 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(LazyDeopt, false)                                                          \
40     V(FastModule, false)                                                         \
41     V(OptBranchProfiling, true)                                                  \
42     V(EscapeAnalysis, false)                                                     \
43     V(InductionVariableAnalysis, false)                                          \
44     V(VerifierPass, true)                                                        \
45     V(MergePoly, true)
46 
47 #define OPTION_BUILDER(NAME, DEFAULT)                                            \
48     Builder &Enable##NAME(bool value) {                                          \
49         options_.enable##NAME##_ = value;                                        \
50         return *this;                                                            \
51     }
52 
53 #define OPTIONS(NAME, DEFAULT) bool                                              \
54     enable##NAME##_{DEFAULT};
55 
56 #define GET_OPTION(NAME, DEFAULT)                                                \
57     bool Enable##NAME() const { return enable##NAME##_; }
58 
59 #define SET_OPTION(NAME, DEFAULT)                                                \
60     void Set##NAME(bool value) { enable##NAME##_ = value; }
61 
62 class PassOptions {
63 public:
64     PassOptions() = default;
65     class Builder;
66     OPTION_LIST(GET_OPTION)
67     OPTION_LIST(SET_OPTION)
68 
69 private:
70     OPTION_LIST(OPTIONS)
71 };
72 
73 class PassOptions::Builder {
74 public:
OPTION_LIST(OPTION_BUILDER)75     OPTION_LIST(OPTION_BUILDER)
76     PassOptions Build() { return options_; }
77 
78 private:
79     PassOptions options_{};
80 };
81 #undef OPTION_BUILDER
82 #undef GET_OPTION
83 #undef OPTIONS
84 #undef OPTION_LIST
85 } // namespace panda::ecmascript::kungfu
86 #endif // ECMASCRIPT_COMPILER_PASS_OPTIONS_H