• 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(TypeInfer, false)                                                          \
27     V(OptInlining, false)                                                        \
28     V(OptNoGCCall, false)                                                        \
29     V(OptPGOType, false)                                                         \
30     V(NoCheck, false)                                                            \
31     V(OptString, true)                                                           \
32     V(OptTrackField, false)                                                      \
33     V(OptLoopPeeling, false)                                                     \
34     V(OptLoopInvariantCodeMotion, false)                                         \
35     V(CollectLiteralInfo, false)                                                 \
36     V(OptConstantFolding, true)                                                  \
37     V(LexenvSpecialization, false)                                               \
38     V(InlineNative, false)                                                       \
39     V(LoweringBuiltin, false)                                                    \
40     V(FastModule, false)                                                         \
41     V(OptBranchProfiling, true)
42 
43 #define OPTION_BUILDER(NAME, DEFAULT)                                            \
44     Builder &Enable##NAME(bool value) {                                          \
45         options_.enable##NAME##_ = value;                                        \
46         return *this;                                                            \
47     }
48 
49 #define OPTIONS(NAME, DEFAULT) bool                                              \
50     enable##NAME##_{DEFAULT};
51 
52 #define GET_OPTION(NAME, DEFAULT)                                                \
53     bool Enable##NAME() const { return enable##NAME##_; }
54 
55 class PassOptions {
56 public:
57     PassOptions() = default;
58     class Builder;
59     OPTION_LIST(GET_OPTION)
60 
61 private:
62     OPTION_LIST(OPTIONS)
63 };
64 
65 class PassOptions::Builder {
66 public:
OPTION_LIST(OPTION_BUILDER)67     OPTION_LIST(OPTION_BUILDER)
68     PassOptions Build() { return options_; }
69 
70 private:
71     PassOptions options_{};
72 };
73 #undef OPTION_BUILDER
74 #undef GET_OPTION
75 #undef OPTIONS
76 #undef OPTION_LIST
77 } // namespace panda::ecmascript::kungfu
78 #endif // ECMASCRIPT_COMPILER_PASS_OPTIONS_H