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 maplecl::Option<bool> userc({"--userc"}, 180 " --userc \tEnable reference counting [default]\n" 181 " --no-userc \tDisable reference counting [default]\n", 182 {mpl2mplCategory}, maplecl::DisableWith("--no-userc")); 183 184 maplecl::Option<bool> strictNaiveRc({"--strict-naiverc"}, 185 " --strict-naiverc \tStrict Naive RC mode," 186 " assume no unsafe multi-thread read/write racing\n" 187 " --no-strict-naiverc \tDisable strict-naiverc\n", 188 {mpl2mplCategory}, maplecl::DisableWith("--no-strict-naiverc")); 189 190 maplecl::Option<bool> rcOpt1({"--rc-opt1"}, " --rc-opt1 \tEnable RC optimization1 [default]\n", 191 {mpl2mplCategory}, maplecl::DisableWith("--no-rc-opt1")); 192 193 maplecl::Option<bool> nativeopt({"--nativeopt"}, 194 " --nativeopt \tEnable native opt\n" 195 " --no-nativeopt \tDisable native opt\n", 196 {mpl2mplCategory}, maplecl::DisableWith("--no-nativeopt")); 197 198 maplecl::Option<bool> o0({"-O0", "--O0"}, " -O0 \tDo some optimization.\n", {mpl2mplCategory}); 199 200 maplecl::Option<bool> o2({"-O2", "--O2"}, " -O2 \tDo some optimization.\n", {mpl2mplCategory}); 201 202 maplecl::Option<bool> os({"-Os", "--Os"}, " -Os \tOptimize for size, based on O2.\n", 203 {mpl2mplCategory}); 204 205 maplecl::Option<std::string> criticalNative({"--CriticalNative"}, 206 " --CriticalNative \tFor CriticalNative optimization\n" 207 " \t--CriticalNative=list_file\n", 208 {mpl2mplCategory}); 209 210 maplecl::Option<std::string> fastNative({"--FastNative"}, 211 " --FastNative \tFor FastNative optimization\n" 212 " \t--FastNative=list_file\n", 213 {mpl2mplCategory}); 214 215 maplecl::Option<bool> nodot({"--nodot"}, 216 " --nodot \tDisable dot file generation from cfg\n" 217 " --no-nodot \tEnable dot file generation from cfg\n", 218 {mpl2mplCategory}, maplecl::DisableWith("--no-nodot")); 219 220 maplecl::Option<bool> genIrProfile({"--ir-profile-gen"}, 221 " --ir-profile-gen \tGen IR level Profile\n" 222 " --no-ir-profile-gen \tDisable Gen IR level Profile\n", 223 {mpl2mplCategory}, maplecl::DisableWith("--no-ir-profile-gen")); 224 225 maplecl::Option<bool> profileTest({"--profile-test"}, 226 " --profile-test \tprofile test\n" 227 " --no-profile-test \tDisable profile test\n", 228 {mpl2mplCategory}, maplecl::DisableWith("--no-profile-test")); 229 230 maplecl::Option<bool> barrier({"--barrier"}, 231 " --barrier \tEnable barrier insertion instead of RC insertion\n" 232 " --no-barrier \tDisable barrier insertion instead of RC insertion\n", 233 {mpl2mplCategory}, maplecl::DisableWith("--no-barrier")); 234 235 maplecl::Option<std::string> nativeFuncPropertyFile({"--nativefunc-property-list"}, 236 " --nativefunc-property-list" 237 " \tGenerate native binding function stub\n" 238 " \t--nativefunc-property-list=file\n", 239 {mpl2mplCategory}); 240 241 maplecl::Option<bool> maplelinkerNolocal({"--maplelinker-nolocal"}, 242 " --maplelinker-nolocal \tDo not turn functions" 243 " into local when maple linker is on\n" 244 " --no-maplelinker-nolocal\n", 245 {mpl2mplCategory}, maplecl::DisableWith("--no-maplelinker-nolocal")); 246 247 maplecl::Option<uint32_t> buildApp({"--build-app"}, 248 " --build-app[=0,1,2] \tbuild the app bytecode" 249 " 0:off, 1:method1, 2:method2, ignore:method1\n", 250 {mpl2mplCategory}, maplecl::optionalValue, maplecl::Init(1)); 251 252 maplecl::Option<bool> partialAot({"--partialAot"}, 253 " --partialAot \tenerate the detailed information for the partialAot\n", 254 {mpl2mplCategory}, maplecl::optionalValue); 255 256 maplecl::Option<uint32_t> decoupleInit({"--decouple-init"}, 257 " --decouple-init \tdecouple the constructor method\n", 258 {mpl2mplCategory}, maplecl::optionalValue, maplecl::Init(1)); 259 260 maplecl::Option<std::string> sourceMuid({"--source-muid"}, 261 " --source-muid=" 262 " \tWrite the source file muid into the mpl file\n", 263 {mpl2mplCategory}, maplecl::optionalValue); 264 265 maplecl::Option<bool> deferredVisit({"--deferred-visit"}, 266 " --deferred-visit \tGenerate deferred MCC call for undefined type\n" 267 " --no-deferred-visit \tDont't generate" 268 " deferred MCC call for undefined type\n", 269 {mpl2mplCategory}, maplecl::DisableWith("--no-deferred-visit")); 270 271 maplecl::Option<bool> deferredVisit2({"--deferred-visit2"}, 272 " --deferred-visit2" 273 " \tGenerate deferred MCC call(DAI2.0) for undefined type\n" 274 " --no-deferred-visit2" 275 " \tDon't generate deferred MCC call(DAI2.0) for undefined type\n", 276 {mpl2mplCategory}, maplecl::DisableWith("--no-deferred-visit2")); 277 278 maplecl::Option<bool> decoupleSuper( 279 {"--decouple-super"}, 280 " --decouple-super \tGenerate deferred MCC call for undefined type\n" 281 " --no-decouple-super \tDon't generate deferred MCC call for undefined type\n", 282 {mpl2mplCategory}, maplecl::DisableWith("--no-decouple-super")); 283 284 maplecl::Option<bool> genDecoupleVtab({"--gen-decouple-vtab"}, 285 " --gen-decouple-vtab \tGenerate the whole and complete vtab and itab\n" 286 " --no-gen-decouple-vtab" 287 " \tDon't generate the whole and complete vtab and itab\n", 288 {mpl2mplCategory}, maplecl::DisableWith("--no-gen-decouple-vtab")); 289 290 maplecl::Option<bool> profileFunc({"--profile-func"}, 291 " --profile-func \tProfile function usage\n" 292 " --no-profile-func \tDisable profile function usage\n", 293 {mpl2mplCategory}, maplecl::DisableWith("--no-profile-func")); 294 295 maplecl::Option<std::string> dumpDevirtual({"--dump-devirtual-list"}, 296 " --dump-devirtual-list" 297 " \tDump candidates of devirtualization into a specified file\n" 298 " \t--dump-devirtual-list=\n", 299 {mpl2mplCategory}); 300 301 maplecl::Option<std::string> readDevirtual( 302 {"--read-devirtual-list"}, 303 " --read-devirtual-list \tRead in candidates of devirtualization from\n" 304 " \t a specified file and perform devirtualizatin\n" 305 " \t--read-devirtual-list=\n", 306 {mpl2mplCategory}); 307 308 maplecl::Option<bool> usewhiteclass({"--usewhiteclass"}, 309 " --usewhiteclass" 310 " \tEnable use preloaded class list to reducing clinit check\n" 311 " --no-usewhiteclass" 312 " \tDisable use preloaded class list to reducing clinit check\n", 313 {mpl2mplCategory}, maplecl::DisableWith("--no-usewhiteclass")); 314 315 maplecl::Option<std::string> appPackageName({"--app-package-name"}, 316 " --app-package-name \tSet APP package name\n" 317 " \t--app-package-name=package_name\n", 318 {mpl2mplCategory}, maplecl::optionalValue); 319 320 maplecl::Option<std::string> checkClInvocation({"--check_cl_invocation"}, 321 " --check_cl_invocation \tFor classloader invocation checking\n" 322 " \t--check_cl_invocation=list_file\n", 323 {mpl2mplCategory}); 324 325 maplecl::Option<bool> dumpClInvocation( 326 {"--dump_cl_invocation"}, 327 " --dump_cl_invocation \tFor classloader invocation dumping.\n" 328 " \tWork only if already set --check_cl_invocation\n" 329 " --no-dump_cl_invocation \tDisable dump_cl_invocation\n", 330 {mpl2mplCategory}, maplecl::DisableWith("--no-dump_cl_invocation")); 331 332 maplecl::Option<uint32_t> warning({"--warning"}, " --warning=level \t--warning=level\n", 333 {mpl2mplCategory}); 334 335 maplecl::Option<bool> lazyBinding({"--lazy-binding"}, 336 " --lazy-binding \tBind class symbols lazily[default off]\n" 337 " --no-lazy-binding \tDon't bind class symbols lazily\n", 338 {mpl2mplCategory}, maplecl::DisableWith("--no-lazy-binding")); 339 340 maplecl::Option<bool> hotFix({"--hot-fix"}, 341 " --hot-fix \tOpen for App hot fix[default off]\n" 342 " --no-hot-fix \tDon't open for App hot fix\n", 343 {mpl2mplCategory}, maplecl::DisableWith("--no-hot-fix")); 344 345 maplecl::Option<bool> compactMeta({"--compact-meta"}, 346 " --compact-meta \tEnable compact method and field meta\n" 347 " --no-compact-meta \tDisable compact method and field meta\n", 348 {mpl2mplCategory}, maplecl::DisableWith("--no-compact-meta")); 349 350 maplecl::Option<bool> genPGOReport({"--gen-pgo-report"}, 351 " --gen-pgo-report \tDisplay pgo report\n" 352 " --no-gen-pgo-report\n", 353 {mpl2mplCategory}, maplecl::DisableWith("--no-gen-pgo-report")); 354 355 maplecl::Option<uint32_t> inlineCache({"--inlineCache"}, " --inlineCache \tbuild inlineCache 0,1,2,3\n", 356 {mpl2mplCategory}, maplecl::optionalValue, maplecl::Init(0)); 357 358 maplecl::Option<bool> noComment({"--no-comment"}, " --no-comment \tbuild inlineCache 0:off, 1:open\n", 359 {mpl2mplCategory}); 360 361 maplecl::Option<bool> rmnousefunc({"--rmnousefunc"}, 362 " --rmnousefunc \tEnable remove no-used file-static function\n" 363 " --no-rmnousefunc \tDisable remove no-used file-static function\n", 364 {mpl2mplCategory}, maplecl::DisableWith("--no-rmnousefunc")); 365 366 maplecl::Option<bool> sideeffect({"--sideeffect"}, 367 " --sideeffect \tIPA: analysis sideeffect\n" 368 " --no-sideeffect \n", 369 {mpl2mplCategory}, maplecl::DisableWith("--no-sideeffect")); 370 371 maplecl::Option<bool> dumpIPA({"--dump-ipa"}, 372 " --dump-ipa \tIPA: dump\n" 373 " --no-dump-ipa \n", 374 {mpl2mplCategory}, maplecl::DisableWith("--no-dump-ipa")); 375 376 maplecl::Option<bool> wpaa({"--wpaa"}, 377 " --wpaa \tWhole Program Alias Analysis\n" 378 " --no-wpaa \n", 379 {mpl2mplCategory}, maplecl::DisableWith("--no-wpaa")); 380 381 maplecl::Option<uint32_t> numOfCloneVersions({"--num-of-clone-versions"}, 382 " --num-of-clone-versions=3 \tnum of clone versions\n", 383 {mpl2mplCategory}); 384 385 maplecl::Option<uint32_t> numOfImpExprLowBound({"--num-of-ImpExpr-LowBound"}, 386 " --num-of-ImpExpr-LowBound=3 \tnum of ImpExpr LowBound\n", 387 {mpl2mplCategory}); 388 389 maplecl::Option<uint32_t> numOfImpExprHighBound({"--num-of-ImpExpr-HighBound"}, 390 " --num-of-ImpExpr-LowBound=3 \tnum of ImpExpr LowBound\n", 391 {mpl2mplCategory}); 392 393 maplecl::Option<uint32_t> numOfCallSiteLowBound({"--num-of-CallSite-LowBound"}, 394 " --num-of-CallSite-LowBound=3 \tnum of CallSite LowBound\n", 395 {mpl2mplCategory}); 396 397 maplecl::Option<uint32_t> numOfCallSiteUpBound({"--num-of-CallSite-HighBound"}, 398 " --num-of-CallSite-HighBound=3 \tnum of CallSite HighBound\n", 399 {mpl2mplCategory}); 400 401 maplecl::Option<uint32_t> numOfConstpropValue({"--num-of-ConstProp-value"}, 402 " --num-of-CallSite-HighBound=3 \tnum of CallSite HighBound\n", 403 {mpl2mplCategory}); 404 405 } // namespace opts::mpl2mpl 406