• 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 #include "driver_options.h"
17 
18 namespace opts::mpl2mpl {
19 
20 maplecl::Option<std::string> dumpPhase({"--dump-phase"},
21                                        "  --dump-phase                \tEnable debug trace for"
22                                        " specified phase (can only specify once)\n"
23                                        "                              \t--dump-phase=PHASENAME\n",
24                                        {mpl2mplCategory});
25 
26 maplecl::Option<std::string> skipPhase(
27     {"--skip-phase"},
28     "  --skip-phase                \tSkip the phase when adding it to phase manager\n"
29     "                              \t--skip-phase=PHASENAME\n",
30     {mpl2mplCategory});
31 
32 maplecl::Option<std::string> skipFrom({"--skip-from"},
33                                       "  --skip-from                 \tSkip all remaining phases including PHASENAME\n"
34                                       "                              \t--skip-from=PHASENAME\n",
35                                       {mpl2mplCategory});
36 
37 maplecl::Option<std::string> skipAfter({"--skip-after"},
38                                        "  --skip-after                \tSkip all remaining phases after PHASENAME\n"
39                                        "                              \t--skip-after=PHASENAME\n",
40                                        {mpl2mplCategory});
41 
42 maplecl::Option<std::string> dumpFunc({"--dump-func"},
43                                       "  --dump-func                 \tDump/trace only for functions"
44                                       " whose names contain FUNCNAME as substring\n"
45                                       "                              \t(can only specify once)\n"
46                                       "                              \t--dump-func=FUNCNAME\n",
47                                       {mpl2mplCategory});
48 
49 maplecl::Option<bool> quiet({"--quiet"},
50                             "  --quiet                     \tDisable brief trace messages with phase/function names\n"
51                             "  --no-quiet                  \tEnable brief trace messages with phase/function names\n",
52                             {mpl2mplCategory}, maplecl::DisableWith("--no-quiet"));
53 
54 maplecl::Option<bool> maplelinker({"--maplelinker"},
55                                   "  --maplelinker               \tGenerate MUID symbol tables and references\n"
56                                   "  --no-maplelinker            \tDon't Generate MUID symbol tables and references\n",
57                                   {mpl2mplCategory}, maplecl::DisableWith("--no-maplelinker"));
58 
59 maplecl::Option<bool> regnativefunc({"--regnativefunc"},
60                                     "  --regnativefunc             \tGenerate native stub function"
61                                     " to support JNI registration and calling\n"
62                                     "  --no-regnativefunc          \tDisable regnativefunc\n",
63                                     {mpl2mplCategory}, maplecl::DisableWith("--no-regnativefunc"));
64 
65 maplecl::Option<bool> inlineWithProfile({"--inline-with-profile"},
66                                         "  --inline-with-profile       \tEnable profile-based inlining\n"
67                                         "  --no-inline-with-profile    \tDisable profile-based inlining\n",
68                                         {mpl2mplCategory}, maplecl::DisableWith("--no-inline-with-profile"));
69 
70 maplecl::Option<bool> inlineOpt({"--inline"},
71                                 "  --inline                    \tEnable function inlining\n"
72                                 "  --no-inline                 \tDisable function inlining\n",
73                                 {mpl2mplCategory}, maplecl::DisableWith("--no-inline"));
74 
75 maplecl::Option<bool> ipaClone({"--ipa-clone"},
76                                "  --ipa-clone                 \tEnable ipa constant_prop and clone\n"
77                                "  --no-ipa-clone              \tDisable ipa constant_prop and clone\n",
78                                {mpl2mplCategory}, maplecl::DisableWith("--no-ipa-clone"));
79 
80 maplecl::Option<std::string> noInlineFunc({"--no-inlinefunclist"},
81                                           "  --no-inlinefunclist=list    \tDo not inline function in this list\n",
82                                           {mpl2mplCategory});
83 
84 maplecl::Option<std::string> importFileList(
85     {"--importfilelist"}, "  --importfilelist=list    \tImport there files to do cross module analysis\n",
86     {mpl2mplCategory});
87 
88 maplecl::Option<bool> crossModuleInline({"--cross-module-inline"},
89                                         "  --cross-module-inline       \tEnable cross-module inlining\n"
90                                         "  --no-cross-module-inline    \tDisable cross-module inlining\n",
91                                         {mpl2mplCategory}, maplecl::DisableWith("--no-cross-module-inline"));
92 
93 maplecl::Option<uint32_t> inlineSmallFunctionThreshold({"--inline-small-function-threshold"},
94                                                        "  --inline-small-function-threshold=15"
95                                                        "            \tThreshold for inlining small function\n",
96                                                        {mpl2mplCategory});
97 
98 maplecl::Option<uint32_t> inlineHotFunctionThreshold({"--inline-hot-function-threshold"},
99                                                      "  --inline-hot-function-threshold=30"
100                                                      "              \tThreshold for inlining hot function\n",
101                                                      {mpl2mplCategory});
102 
103 maplecl::Option<uint32_t> inlineRecursiveFunctionThreshold(
104     {"--inline-recursive-function-threshold"},
105     "  --inline-recursive-function-threshold=15"
106     "              \tThreshold for inlining recursive function\n",
107     {mpl2mplCategory});
108 
109 maplecl::Option<uint32_t> inlineDepth({"--inline-depth"},
110                                       "  --inline-depth=8              \tMax call graph depth for inlining\n",
111                                       {mpl2mplCategory});
112 
113 maplecl::Option<uint32_t> inlineModuleGrow({"--inline-module-growth"},
114                                            "  --inline-module-growth=100000"
115                                            "                   \tThreshold for maxmium code size growth rate (10%)\n",
116                                            {mpl2mplCategory});
117 
118 maplecl::Option<uint32_t> inlineColdFuncThresh({"--inline-cold-function-threshold"},
119                                                "  --inline-cold-function-threshold=3"
120                                                "              \tThreshold for inlining hot function\n",
121                                                {mpl2mplCategory});
122 
123 maplecl::Option<uint32_t> profileHotCount({"--profile-hot-count"},
124                                           "  --profile-hot-count=1000"
125                                           "    \tA count is regarded as hot if it exceeds this number\n",
126                                           {mpl2mplCategory});
127 
128 maplecl::Option<uint32_t> profileColdCount({"--profile-cold-count"},
129                                            "  --profile-cold-count=10"
130                                            "     \tA count is regarded as cold if it is below this number\n",
131                                            {mpl2mplCategory});
132 
133 maplecl::Option<uint32_t> profileHotRate({"--profile-hot-rate"},
134                                          "  --profile-hot-rate=500000"
135                                          "   \tA count is regarded as hot if it is in the largest 50%\n",
136                                          {mpl2mplCategory});
137 
138 maplecl::Option<uint32_t> profileColdRate({"--profile-cold-rate"},
139                                           "  --profile-cold-rate=900000"
140                                           "  \tA count is regarded as cold if it is in the smallest 10%\n",
141                                           {mpl2mplCategory});
142 
143 maplecl::Option<bool> nativewrapper({"--nativewrapper"},
144                                     "  --nativewrapper             \tGenerate native wrappers [default]\n",
145                                     {mpl2mplCategory}, maplecl::DisableWith("--no-nativewrapper"));
146 
147 maplecl::Option<bool> regnativeDynamicOnly({"--regnative-dynamic-only"},
148                                            "  --regnative-dynamic-only    \tOnly Generate dynamic register code,"
149                                            " Report Fatal Msg if no implemented\n"
150                                            "  --no-regnative-dynamic-only \tDisable regnative-dynamic-only\n",
151                                            {mpl2mplCategory}, maplecl::DisableWith("--no-regnative-dynamic-only"));
152 
153 maplecl::Option<std::string> staticBindingList({"--static-binding-list"},
154                                                "  --static-bindig-list        \tOnly Generate static binding"
155                                                " function in file configure list\n"
156                                                "                              \t--static-bindig-list=file\n",
157                                                {mpl2mplCategory});
158 
159 maplecl::Option<bool> dumpBefore({"--dump-before"},
160                                  "  --dump-before               \tDo extra IR dump before the specified phase\n"
161                                  "  --no-dump-before            \tDon't extra IR dump before the specified phase\n",
162                                  {mpl2mplCategory}, maplecl::DisableWith("--no-dump-before"));
163 
164 maplecl::Option<bool> dumpAfter({"--dump-after"},
165                                 "  --dump-after                \tDo extra IR dump after the specified phase\n"
166                                 "  --no-dump-after             \tDon't extra IR dump after the specified phase\n",
167                                 {mpl2mplCategory}, maplecl::DisableWith("--no-dump-after"));
168 
169 maplecl::Option<bool> dumpMuid({"--dump-muid"},
170                                "  --dump-muid                 \tDump MUID def information into a .muid file\n"
171                                "  --no-dump-muid              \tDon't dump MUID def information into a .muid file\n",
172                                {mpl2mplCategory}, maplecl::DisableWith("--no-dump-muid"));
173 
174 maplecl::Option<bool> emitVtableImpl({"--emitVtableImpl"},
175                                      "  --emitVtableImpl            \tgenerate VtableImpl file\n"
176                                      "  --no-emitVtableImpl         \tDon't generate VtableImpl file\n",
177                                      {mpl2mplCategory}, maplecl::DisableWith("--no-emitVtableImpl"));
178 
179 #if MIR_JAVA
180 maplecl::Option<bool> skipvirtual({"--skipvirtual"},
181                                   "  --skipvirtual\n"
182                                   "  --no-skipvirtual\n",
183                                   {mpl2mplCategory}, maplecl::DisableWith("--no-skipvirtual"));
184 #endif
185 
186 maplecl::Option<bool> userc({"--userc"},
187                             "  --userc                     \tEnable reference counting [default]\n"
188                             "  --no-userc                  \tDisable reference counting [default]\n",
189                             {mpl2mplCategory}, maplecl::DisableWith("--no-userc"));
190 
191 maplecl::Option<bool> strictNaiveRc({"--strict-naiverc"},
192                                     "  --strict-naiverc            \tStrict Naive RC mode,"
193                                     " assume no unsafe multi-thread read/write racing\n"
194                                     "  --no-strict-naiverc         \tDisable strict-naiverc\n",
195                                     {mpl2mplCategory}, maplecl::DisableWith("--no-strict-naiverc"));
196 
197 maplecl::Option<bool> rcOpt1({"--rc-opt1"}, "  --rc-opt1                   \tEnable RC optimization1 [default]\n",
198                              {mpl2mplCategory}, maplecl::DisableWith("--no-rc-opt1"));
199 
200 maplecl::Option<bool> nativeopt({"--nativeopt"},
201                                 "  --nativeopt                 \tEnable native opt\n"
202                                 "  --no-nativeopt              \tDisable native opt\n",
203                                 {mpl2mplCategory}, maplecl::DisableWith("--no-nativeopt"));
204 
205 maplecl::Option<bool> o0({"-O0", "--O0"}, "  -O0                         \tDo some optimization.\n", {mpl2mplCategory});
206 
207 maplecl::Option<bool> o2({"-O2", "--O2"}, "  -O2                         \tDo some optimization.\n", {mpl2mplCategory});
208 
209 maplecl::Option<bool> os({"-Os", "--Os"}, "  -Os                         \tOptimize for size, based on O2.\n",
210                          {mpl2mplCategory});
211 
212 maplecl::Option<std::string> criticalNative({"--CriticalNative"},
213                                             "  --CriticalNative            \tFor CriticalNative optimization\n"
214                                             "                              \t--CriticalNative=list_file\n",
215                                             {mpl2mplCategory});
216 
217 maplecl::Option<std::string> fastNative({"--FastNative"},
218                                         "  --FastNative                \tFor FastNative optimization\n"
219                                         "                              \t--FastNative=list_file\n",
220                                         {mpl2mplCategory});
221 
222 maplecl::Option<bool> nodot({"--nodot"},
223                             "  --nodot                     \tDisable dot file generation from cfg\n"
224                             "  --no-nodot                  \tEnable dot file generation from cfg\n",
225                             {mpl2mplCategory}, maplecl::DisableWith("--no-nodot"));
226 
227 maplecl::Option<bool> genIrProfile({"--ir-profile-gen"},
228                                    "  --ir-profile-gen              \tGen IR level Profile\n"
229                                    "  --no-ir-profile-gen           \tDisable Gen IR level Profile\n",
230                                    {mpl2mplCategory}, maplecl::DisableWith("--no-ir-profile-gen"));
231 
232 maplecl::Option<bool> profileTest({"--profile-test"},
233                                   "  --profile-test              \tprofile test\n"
234                                   "  --no-profile-test           \tDisable profile test\n",
235                                   {mpl2mplCategory}, maplecl::DisableWith("--no-profile-test"));
236 
237 maplecl::Option<bool> barrier({"--barrier"},
238                               "  --barrier                   \tEnable barrier insertion instead of RC insertion\n"
239                               "  --no-barrier                \tDisable barrier insertion instead of RC insertion\n",
240                               {mpl2mplCategory}, maplecl::DisableWith("--no-barrier"));
241 
242 maplecl::Option<std::string> nativeFuncPropertyFile({"--nativefunc-property-list"},
243                                                     "  --nativefunc-property-list"
244                                                     "  \tGenerate native binding function stub\n"
245                                                     "                              \t--nativefunc-property-list=file\n",
246                                                     {mpl2mplCategory});
247 
248 maplecl::Option<bool> maplelinkerNolocal({"--maplelinker-nolocal"},
249                                          "  --maplelinker-nolocal       \tDo not turn functions"
250                                          " into local when maple linker is on\n"
251                                          "  --no-maplelinker-nolocal\n",
252                                          {mpl2mplCategory}, maplecl::DisableWith("--no-maplelinker-nolocal"));
253 
254 maplecl::Option<uint32_t> buildApp({"--build-app"},
255                                    "  --build-app[=0,1,2]         \tbuild the app bytecode"
256                                    " 0:off, 1:method1, 2:method2, ignore:method1\n",
257                                    {mpl2mplCategory}, maplecl::optionalValue, maplecl::Init(1));
258 
259 maplecl::Option<bool> partialAot({"--partialAot"},
260                                  "  --partialAot               \tenerate the detailed information for the partialAot\n",
261                                  {mpl2mplCategory}, maplecl::optionalValue);
262 
263 maplecl::Option<uint32_t> decoupleInit({"--decouple-init"},
264                                        "  --decouple-init          \tdecouple the constructor method\n",
265                                        {mpl2mplCategory}, maplecl::optionalValue, maplecl::Init(1));
266 
267 maplecl::Option<std::string> sourceMuid({"--source-muid"},
268                                         "  --source-muid="
269                                         "            \tWrite the source file muid into the mpl file\n",
270                                         {mpl2mplCategory}, maplecl::optionalValue);
271 
272 maplecl::Option<bool> deferredVisit({"--deferred-visit"},
273                                     "  --deferred-visit            \tGenerate deferred MCC call for undefined type\n"
274                                     "  --no-deferred-visit         \tDont't generate"
275                                     " deferred MCC call for undefined type\n",
276                                     {mpl2mplCategory}, maplecl::DisableWith("--no-deferred-visit"));
277 
278 maplecl::Option<bool> deferredVisit2({"--deferred-visit2"},
279                                      "  --deferred-visit2"
280                                      "           \tGenerate deferred MCC call(DAI2.0) for undefined type\n"
281                                      "  --no-deferred-visit2"
282                                      "        \tDon't generate deferred MCC call(DAI2.0) for undefined type\n",
283                                      {mpl2mplCategory}, maplecl::DisableWith("--no-deferred-visit2"));
284 
285 maplecl::Option<bool> decoupleSuper(
286     {"--decouple-super"},
287     "  --decouple-super            \tGenerate deferred MCC call for undefined type\n"
288     "  --no-decouple-super         \tDon't generate deferred MCC call for undefined type\n",
289     {mpl2mplCategory}, maplecl::DisableWith("--no-decouple-super"));
290 
291 maplecl::Option<bool> genDecoupleVtab({"--gen-decouple-vtab"},
292                                       "  --gen-decouple-vtab         \tGenerate the whole and complete vtab and itab\n"
293                                       "  --no-gen-decouple-vtab"
294                                       "      \tDon't generate the whole and complete vtab and itab\n",
295                                       {mpl2mplCategory}, maplecl::DisableWith("--no-gen-decouple-vtab"));
296 
297 maplecl::Option<bool> profileFunc({"--profile-func"},
298                                   "  --profile-func              \tProfile function usage\n"
299                                   "  --no-profile-func           \tDisable profile function usage\n",
300                                   {mpl2mplCategory}, maplecl::DisableWith("--no-profile-func"));
301 
302 maplecl::Option<std::string> dumpDevirtual({"--dump-devirtual-list"},
303                                            "  --dump-devirtual-list"
304                                            "       \tDump candidates of devirtualization into a specified file\n"
305                                            "                              \t--dump-devirtual-list=\n",
306                                            {mpl2mplCategory});
307 
308 maplecl::Option<std::string> readDevirtual(
309     {"--read-devirtual-list"},
310     "  --read-devirtual-list       \tRead in candidates of devirtualization from\n"
311     "                              \t a specified file and perform devirtualizatin\n"
312     "                              \t--read-devirtual-list=\n",
313     {mpl2mplCategory});
314 
315 maplecl::Option<bool> usewhiteclass({"--usewhiteclass"},
316                                     "  --usewhiteclass"
317                                     "             \tEnable use preloaded class list to reducing clinit check\n"
318                                     "  --no-usewhiteclass"
319                                     "          \tDisable use preloaded class list to reducing clinit check\n",
320                                     {mpl2mplCategory}, maplecl::DisableWith("--no-usewhiteclass"));
321 
322 maplecl::Option<std::string> appPackageName({"--app-package-name"},
323                                             "  --app-package-name          \tSet APP package name\n"
324                                             "                              \t--app-package-name=package_name\n",
325                                             {mpl2mplCategory}, maplecl::optionalValue);
326 
327 maplecl::Option<std::string> checkClInvocation({"--check_cl_invocation"},
328                                                "  --check_cl_invocation       \tFor classloader invocation checking\n"
329                                                "                              \t--check_cl_invocation=list_file\n",
330                                                {mpl2mplCategory});
331 
332 maplecl::Option<bool> dumpClInvocation(
333     {"--dump_cl_invocation"},
334     "  --dump_cl_invocation        \tFor classloader invocation dumping.\n"
335     "                              \tWork only if already set --check_cl_invocation\n"
336     "  --no-dump_cl_invocation     \tDisable dump_cl_invocation\n",
337     {mpl2mplCategory}, maplecl::DisableWith("--no-dump_cl_invocation"));
338 
339 maplecl::Option<uint32_t> warning({"--warning"}, "  --warning=level             \t--warning=level\n",
340                                   {mpl2mplCategory});
341 
342 maplecl::Option<bool> lazyBinding({"--lazy-binding"},
343                                   "  --lazy-binding              \tBind class symbols lazily[default off]\n"
344                                   "  --no-lazy-binding           \tDon't bind class symbols lazily\n",
345                                   {mpl2mplCategory}, maplecl::DisableWith("--no-lazy-binding"));
346 
347 maplecl::Option<bool> hotFix({"--hot-fix"},
348                              "  --hot-fix                   \tOpen for App hot fix[default off]\n"
349                              "  --no-hot-fix                \tDon't open for App hot fix\n",
350                              {mpl2mplCategory}, maplecl::DisableWith("--no-hot-fix"));
351 
352 maplecl::Option<bool> compactMeta({"--compact-meta"},
353                                   "  --compact-meta              \tEnable compact method and field meta\n"
354                                   "  --no-compact-meta           \tDisable compact method and field meta\n",
355                                   {mpl2mplCategory}, maplecl::DisableWith("--no-compact-meta"));
356 
357 maplecl::Option<bool> genPGOReport({"--gen-pgo-report"},
358                                    "  --gen-pgo-report            \tDisplay pgo report\n"
359                                    "  --no-gen-pgo-report\n",
360                                    {mpl2mplCategory}, maplecl::DisableWith("--no-gen-pgo-report"));
361 
362 maplecl::Option<uint32_t> inlineCache({"--inlineCache"}, "  --inlineCache            \tbuild inlineCache 0,1,2,3\n",
363                                       {mpl2mplCategory}, maplecl::optionalValue, maplecl::Init(0));
364 
365 maplecl::Option<bool> noComment({"--no-comment"}, "  --no-comment             \tbuild inlineCache 0:off, 1:open\n",
366                                 {mpl2mplCategory});
367 
368 maplecl::Option<bool> rmnousefunc({"--rmnousefunc"},
369                                   "  --rmnousefunc            \tEnable remove no-used file-static function\n"
370                                   "  --no-rmnousefunc         \tDisable remove no-used file-static function\n",
371                                   {mpl2mplCategory}, maplecl::DisableWith("--no-rmnousefunc"));
372 
373 maplecl::Option<bool> sideeffect({"--sideeffect"},
374                                  "  --sideeffect      \tIPA: analysis sideeffect\n"
375                                  "  --no-sideeffect          \n",
376                                  {mpl2mplCategory}, maplecl::DisableWith("--no-sideeffect"));
377 
378 maplecl::Option<bool> dumpIPA({"--dump-ipa"},
379                               "  --dump-ipa      \tIPA: dump\n"
380                               "  --no-dump-ipa          \n",
381                               {mpl2mplCategory}, maplecl::DisableWith("--no-dump-ipa"));
382 
383 maplecl::Option<bool> wpaa({"--wpaa"},
384                            "  --wpaa      \tWhole Program Alias Analysis\n"
385                            "  --no-wpaa          \n",
386                            {mpl2mplCategory}, maplecl::DisableWith("--no-wpaa"));
387 
388 maplecl::Option<uint32_t> numOfCloneVersions({"--num-of-clone-versions"},
389                                              "  --num-of-clone-versions=3        \tnum of clone versions\n",
390                                              {mpl2mplCategory});
391 
392 maplecl::Option<uint32_t> numOfImpExprLowBound({"--num-of-ImpExpr-LowBound"},
393                                                "  --num-of-ImpExpr-LowBound=3        \tnum of ImpExpr LowBound\n",
394                                                {mpl2mplCategory});
395 
396 maplecl::Option<uint32_t> numOfImpExprHighBound({"--num-of-ImpExpr-HighBound"},
397                                                 "  --num-of-ImpExpr-LowBound=3        \tnum of ImpExpr LowBound\n",
398                                                 {mpl2mplCategory});
399 
400 maplecl::Option<uint32_t> numOfCallSiteLowBound({"--num-of-CallSite-LowBound"},
401                                                 "  --num-of-CallSite-LowBound=3        \tnum of CallSite LowBound\n",
402                                                 {mpl2mplCategory});
403 
404 maplecl::Option<uint32_t> numOfCallSiteUpBound({"--num-of-CallSite-HighBound"},
405                                                "  --num-of-CallSite-HighBound=3        \tnum of CallSite HighBound\n",
406                                                {mpl2mplCategory});
407 
408 maplecl::Option<uint32_t> numOfConstpropValue({"--num-of-ConstProp-value"},
409                                               "  --num-of-CallSite-HighBound=3        \tnum of CallSite HighBound\n",
410                                               {mpl2mplCategory});
411 
412 }  // namespace opts::mpl2mpl
413