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 #ifndef MAPLEBE_INCLUDE_CG_CG_OPTION_H 17 #define MAPLEBE_INCLUDE_CG_CG_OPTION_H 18 #include <vector> 19 #include <sys/stat.h> 20 #include "mempool.h" 21 #include "mempool_allocator.h" 22 #include "mir_module.h" 23 #include "types_def.h" 24 25 namespace maplebe { 26 using namespace maple; 27 struct Range { 28 bool enable; 29 uint64 begin; 30 uint64 end; 31 }; 32 33 typedef uint8 *(*MemoryManagerAllocateDataSectionCallback)(void *codeSpace, uint32 size, uint32 alignment, 34 const std::string §ionName); 35 36 typedef void (*MemoryManagerSaveFunc2AddressInfoCallback)(void *codeSpace, std::string funcName, uint32_t address); 37 38 typedef void (*MemoryManagerSaveFunc2FPtoPrevSPDeltaCallback)(void *object, std::string funcName, 39 int32_t fp2PrevSpDelta); 40 41 typedef void (*MemoryManagerSaveFunc2CalleeOffsetInfoCallback)(void *object, std::string funcName, 42 std::vector<std::pair<uint16_t, int32_t>> calleeRegInfo); 43 44 typedef void (*MemoryManagerSavePC2DeoptInfoCallback)(void *object, uint64_t pc, std::vector<uint8_t> deoptInfo); 45 46 typedef void (*MemoryManagerSavePC2CallSiteInfoCallback)(void *object, uint64_t pc, std::vector<uint8_t> callSiteInfo); 47 48 class CGOptions { 49 public: 50 enum OptionEnum : uint64 { 51 kUndefined = 0ULL, 52 kDoCg = 1ULL << 0, 53 kDoLinearScanRegAlloc = 1ULL << 1, 54 kDoColorRegAlloc = 1ULL << 2, 55 kConstFold = 1ULL << 3, 56 kGenPic = 1ULL << 4, 57 kGenPie = 1ULL << 5, 58 kVerboseAsm = 1ULL << 6, 59 kGenInsertCall = 1ULL << 7, 60 kAddDebugTrace = 1ULL << 8, 61 kGenYieldPoint = 1ULL << 9, 62 kGenLocalRc = 1ULL << 10, 63 kProEpilogueOpt = 1ULL << 11, 64 kVerboseCG = 1ULL << 12, 65 kDebugFriendly = 1ULL << 20, 66 kWithLoc = 1ULL << 21, 67 kWithDwarf = 1ULL << 22, 68 kWithMpl = 1ULL << 23, 69 kWithSrc = 1ULL << 24, 70 kWithAsm = 1ULL << 25, 71 kWithProfileCode = 1ULL << 30, 72 kUseStackProtectorStrong = 1ULL << 31, 73 kUseStackProtectorAll = 1ULL << 32, 74 kSoeCheckInsert = 1ULL << 33, 75 kAddFuncProfile = 1ULL << 34, 76 kPatchLongBranch = 1ULL << 35, 77 kTailCallOpt = 1ULL << 36, 78 /* undocumented */ 79 kDumpCFG = 1ULL << 61, 80 kDumpCgir = 1ULL << 62, 81 kSuppressFileInfo = 1ULL << 63, 82 }; 83 84 using OptionFlag = uint64; 85 86 enum GenerateEnum : uint64 { 87 kCMacroDef = 1ULL << 0, 88 kGctib = 1ULL << 1, 89 kGrootList = 1ULL << 2, 90 kPrimorList = 1ULL << 3, 91 }; 92 93 using GenerateFlag = uint64; 94 95 enum OptimizeLevel : uint8 { 96 kLevel0 = 0, 97 kLevelLiteCG = 1, 98 kLevel1 = 2, 99 kLevel2 = 3, 100 }; 101 102 enum ABIType : uint8 { kABIHard, kABISoft, kABISoftFP }; 103 104 struct EmitMemoryManager { 105 void *codeSpace; 106 MemoryManagerAllocateDataSectionCallback allocateDataSection; 107 MemoryManagerSaveFunc2AddressInfoCallback funcAddressSaver; 108 MemoryManagerSaveFunc2FPtoPrevSPDeltaCallback funcFpSPDeltaSaver; 109 MemoryManagerSaveFunc2CalleeOffsetInfoCallback funcCalleeOffsetSaver; 110 MemoryManagerSavePC2DeoptInfoCallback pc2DeoptInfoSaver; 111 MemoryManagerSavePC2CallSiteInfoCallback pc2CallSiteInfoSaver; 112 }; 113 /* 114 * The default CG option values are: 115 * Don't BE_QUITE; verbose, 116 * DO CG and generate .s file as output, 117 * Generate EH, 118 * Use frame pointer, 119 * Generate CFI directives, 120 * DO peephole optimization, 121 * Generate position-independent executable, 122 * Don't insert debug comments in .s file, 123 * Don't insert a call to the named (instrumentation) 124 * function at each function entry. 125 */ 126 static const OptionFlag kDefaultOptions = OptionFlag( 127 #if TARGAARCH64 || TARGARM32 || TARGRISCV64 128 kDoCg | kGenPie | kDoColorRegAlloc 129 #else 130 kDoCg 131 #endif 132 ); 133 134 /* 135 * The default metadata generation flags values are: 136 * Generate .macros.def for C preprocessors. 137 * Generate .groots.txt for GC. 138 * Generate .primordials.txt for GC. 139 * Generate yieldpoints for GC. 140 * Do not generate separate GCTIB file. 141 */ 142 static const GenerateFlag kDefaultGflags = GenerateFlag(0); 143 144 public: 145 static CGOptions &GetInstance(); 146 virtual ~CGOptions() = default; 147 bool SolveOptions(bool isDebug); 148 void DecideMplcgRealLevel(bool isDebug); 149 std::ostream& GetLogStream() const; 150 void DumpOptions(); GetSequence()151 std::vector<std::string> &GetSequence() 152 { 153 return phaseSequence; 154 } 155 GetEmitMemoryManager()156 const EmitMemoryManager &GetEmitMemoryManager() const 157 { 158 return emitMemoryManager; 159 } 160 SetupEmitMemoryManager(void * codeSpace,MemoryManagerAllocateDataSectionCallback allocateDataSection,MemoryManagerSaveFunc2AddressInfoCallback funcAddressSaver,MemoryManagerSaveFunc2FPtoPrevSPDeltaCallback funcFPSPDeltaSaver,MemoryManagerSaveFunc2CalleeOffsetInfoCallback funcCalleeOffsetSaver,MemoryManagerSavePC2DeoptInfoCallback pc2DeoptInfoSaver,MemoryManagerSavePC2CallSiteInfoCallback pc2CallSiteInfoSaver)161 void SetupEmitMemoryManager(void *codeSpace, MemoryManagerAllocateDataSectionCallback allocateDataSection, 162 MemoryManagerSaveFunc2AddressInfoCallback funcAddressSaver, 163 MemoryManagerSaveFunc2FPtoPrevSPDeltaCallback funcFPSPDeltaSaver, 164 MemoryManagerSaveFunc2CalleeOffsetInfoCallback funcCalleeOffsetSaver, 165 MemoryManagerSavePC2DeoptInfoCallback pc2DeoptInfoSaver, 166 MemoryManagerSavePC2CallSiteInfoCallback pc2CallSiteInfoSaver) 167 { 168 emitMemoryManager.codeSpace = codeSpace; 169 emitMemoryManager.allocateDataSection = allocateDataSection; 170 emitMemoryManager.funcAddressSaver = funcAddressSaver; 171 emitMemoryManager.funcFpSPDeltaSaver = funcFPSPDeltaSaver; 172 emitMemoryManager.funcCalleeOffsetSaver = funcCalleeOffsetSaver; 173 emitMemoryManager.pc2DeoptInfoSaver = pc2DeoptInfoSaver; 174 emitMemoryManager.pc2CallSiteInfoSaver = pc2CallSiteInfoSaver; 175 } 176 177 template <class T> SetOrClear(T & dest,uint64 flag,bool truth)178 void SetOrClear(T &dest, uint64 flag, bool truth) const 179 { 180 if (truth) { 181 dest |= flag; 182 } else { 183 dest &= ~flag; 184 } 185 } 186 187 void ParseExclusiveFunc(const std::string &fileName); 188 void ParseCyclePattern(const std::string &fileName); 189 190 void EnableO0(); 191 void EnableO1(); 192 void EnableO2(); 193 void EnableLiteCG(); 194 GenDef()195 bool GenDef() const 196 { 197 return generateFlag & kCMacroDef; 198 } 199 GenGctib()200 bool GenGctib() const 201 { 202 return generateFlag & kGctib; 203 } 204 GenGrootList()205 bool GenGrootList() const 206 { 207 return generateFlag & kGrootList; 208 } 209 GenPrimorList()210 bool GenPrimorList() const 211 { 212 return generateFlag & kPrimorList; 213 } 214 GenYieldPoint()215 bool GenYieldPoint() const 216 { 217 return generateFlag & kGenYieldPoint; 218 } 219 GenLocalRC()220 bool GenLocalRC() const 221 { 222 return (generateFlag & kGenLocalRc) && !gcOnly; 223 } 224 DoConstFold()225 bool DoConstFold() const 226 { 227 return options & kConstFold; 228 } 229 DoEmitCode()230 bool DoEmitCode() const 231 { 232 return (options & kDoCg) != 0; 233 } 234 GenerateExceptionHandlingCode()235 bool GenerateExceptionHandlingCode() const 236 { 237 return true; 238 } 239 DoLinearScanRegisterAllocation()240 bool DoLinearScanRegisterAllocation() const 241 { 242 return (options & kDoLinearScanRegAlloc) != 0; 243 } DoColoringBasedRegisterAllocation()244 bool DoColoringBasedRegisterAllocation() const 245 { 246 return (options & kDoColorRegAlloc) != 0; 247 } 248 GeneratePositionIndependentExecutable()249 bool GeneratePositionIndependentExecutable() const 250 { 251 return (options & kGenPie) != 0; 252 } 253 GenerateVerboseAsm()254 bool GenerateVerboseAsm() const 255 { 256 return (options & kVerboseAsm) != 0; 257 } 258 GenerateVerboseCG()259 bool GenerateVerboseCG() const 260 { 261 return (options & kVerboseCG) != 0; 262 } 263 GenerateDebugFriendlyCode()264 bool GenerateDebugFriendlyCode() const 265 { 266 return true; 267 } 268 DoPrologueEpilogue()269 bool DoPrologueEpilogue() const 270 { 271 return (options & kProEpilogueOpt) != 0; 272 } 273 IsStackProtectorStrong()274 bool IsStackProtectorStrong() const 275 { 276 return (options & kUseStackProtectorStrong) != 0; 277 } 278 IsStackProtectorAll()279 bool IsStackProtectorAll() const 280 { 281 return (options & kUseStackProtectorAll) != 0; 282 } 283 WithLoc()284 bool WithLoc() const 285 { 286 return (options & kWithLoc) != 0; 287 } 288 WithDwarf()289 bool WithDwarf() const 290 { 291 return (options & kWithDwarf) != 0; 292 } 293 WithSrc()294 bool WithSrc() const 295 { 296 return (options & kWithSrc) != 0; 297 } 298 WithMpl()299 bool WithMpl() const 300 { 301 return (options & kWithMpl) != 0; 302 } 303 WithAsm()304 bool WithAsm() const 305 { 306 return (options & kWithAsm) != 0; 307 } 308 NeedInsertInstrumentationFunction()309 bool NeedInsertInstrumentationFunction() const 310 { 311 return (options & kGenInsertCall) != 0; 312 } 313 InstrumentWithDebugTraceCall()314 bool InstrumentWithDebugTraceCall() const 315 { 316 return (options & kAddDebugTrace) != 0; 317 } 318 InstrumentWithProfile()319 bool InstrumentWithProfile() const 320 { 321 return (options & kAddFuncProfile) != 0; 322 } 323 DoPatchLongBranch()324 bool DoPatchLongBranch() const 325 { 326 return (options & kPatchLongBranch) != 0; 327 } 328 DoTailCall()329 bool DoTailCall() const 330 { 331 return (options & kTailCallOpt) != 0; 332 } 333 DoCheckSOE()334 bool DoCheckSOE() const 335 { 336 return (options & kSoeCheckInsert) != 0; 337 } 338 SuppressFileInfo()339 bool SuppressFileInfo() const 340 { 341 return (options & kSuppressFileInfo) != 0; 342 } 343 DoDumpCFG()344 bool DoDumpCFG() const 345 { 346 return (options & kDumpCFG) != 0; 347 } 348 349 void SetDefaultOptions(const MIRModule &mod); 350 static bool DumpPhase(const std::string &phase); 351 static bool FuncFilter(const std::string &name); 352 void SplitPhases(const std::string &str, std::unordered_set<std::string> &set); 353 void SetRange(const std::string &str, const std::string &cmd, Range &subRange); 354 void SetTargetMachine(const std::string &str); 355 GetOptimizeLevel()356 int32 GetOptimizeLevel() const 357 { 358 return optimizeLevel; 359 } 360 IsRunCG()361 bool IsRunCG() const 362 { 363 return runCGFlag; 364 } 365 SetRunCGFlag(bool cgFlag)366 void SetRunCGFlag(bool cgFlag) 367 { 368 runCGFlag = cgFlag; 369 } 370 IsAsmEmitterEnable()371 bool IsAsmEmitterEnable() const 372 { 373 return asmEmitterEnable; 374 } 375 SetAsmEmitterEnable(bool flag)376 void SetAsmEmitterEnable(bool flag) 377 { 378 asmEmitterEnable = flag; 379 } 380 IsInsertCall()381 bool IsInsertCall() const 382 { 383 return insertCall; 384 } 385 SetInsertCall(bool insertFlag)386 void SetInsertCall(bool insertFlag) 387 { 388 insertCall = insertFlag; 389 } 390 IsGenerateObjectMap()391 bool IsGenerateObjectMap() const 392 { 393 return generateObjectMap; 394 } 395 SetGenerateObjectMap(bool flag)396 void SetGenerateObjectMap(bool flag) 397 { 398 generateObjectMap = flag; 399 } 400 SetParserOption(uint32 option)401 void SetParserOption(uint32 option) 402 { 403 parserOption |= option; 404 } 405 GetParserOption()406 uint32 GetParserOption() const 407 { 408 return parserOption; 409 } 410 GetGenerateFlags()411 GenerateFlag &GetGenerateFlags() 412 { 413 return generateFlag; 414 } 415 GetGenerateFlags()416 const GenerateFlag &GetGenerateFlags() const 417 { 418 return generateFlag; 419 } 420 SetGenerateFlags(GenerateFlag flag)421 void SetGenerateFlags(GenerateFlag flag) 422 { 423 generateFlag |= flag; 424 } 425 SetOption(OptionFlag opFlag)426 void SetOption(OptionFlag opFlag) 427 { 428 options |= opFlag; 429 } 430 ClearOption(OptionFlag opFlag)431 void ClearOption(OptionFlag opFlag) 432 { 433 options &= ~opFlag; 434 } 435 GetInstrumentationFunction()436 const std::string &GetInstrumentationFunction() const 437 { 438 return instrumentationFunction; 439 } 440 SetInstrumentationFunction(const std::string & function)441 void SetInstrumentationFunction(const std::string &function) 442 { 443 instrumentationFunction = function; 444 } 445 GetClassListFile()446 const std::string &GetClassListFile() const 447 { 448 return classListFile; 449 } 450 SetClassListFile(const std::string & classList)451 void SetClassListFile(const std::string &classList) 452 { 453 classListFile = classList; 454 } 455 SetEHExclusiveFile(const std::string & ehExclusive)456 void SetEHExclusiveFile(const std::string &ehExclusive) 457 { 458 ehExclusiveFile = ehExclusive; 459 } 460 SetCyclePatternFile(const std::string & cyclePattern)461 void SetCyclePatternFile(const std::string &cyclePattern) 462 { 463 cyclePatternFile = cyclePattern; 464 } 465 IsQuiet()466 static bool IsQuiet() 467 { 468 return quiet; 469 } 470 SetQuiet(bool flag)471 static void SetQuiet(bool flag) 472 { 473 quiet = flag; 474 } 475 GetDumpPhases()476 static std::unordered_set<std::string> &GetDumpPhases() 477 { 478 return dumpPhases; 479 } 480 GetSkipPhases()481 static std::unordered_set<std::string> &GetSkipPhases() 482 { 483 return skipPhases; 484 } 485 IsSkipPhase(const std::string & phaseName)486 static bool IsSkipPhase(const std::string &phaseName) 487 { 488 return !(skipPhases.find(phaseName) == skipPhases.end()); 489 } 490 GetEHExclusiveFunctionNameVec()491 const std::vector<std::string> &GetEHExclusiveFunctionNameVec() const 492 { 493 return ehExclusiveFunctionName; 494 } 495 GetCyclePatternMap()496 static const std::unordered_map<std::string, std::vector<std::string>> &GetCyclePatternMap() 497 { 498 return cyclePatternMap; 499 } 500 IsSkipFromPhase(const std::string & phaseName)501 static bool IsSkipFromPhase(const std::string &phaseName) 502 { 503 return skipFrom.compare(phaseName) == 0; 504 } 505 GetSkipFromPhase()506 static const std::string GetSkipFromPhase() 507 { 508 return skipFrom; 509 } 510 SetSkipFrom(const std::string & phaseName)511 static void SetSkipFrom(const std::string &phaseName) 512 { 513 skipFrom = phaseName; 514 } 515 IsSkipAfterPhase(const std::string & phaseName)516 static bool IsSkipAfterPhase(const std::string &phaseName) 517 { 518 return skipAfter.compare(phaseName) == 0; 519 } 520 GetSkipAfterPhase()521 static const std::string GetSkipAfterPhase() 522 { 523 return skipAfter; 524 } 525 SetSkipAfter(const std::string & phaseName)526 static void SetSkipAfter(const std::string &phaseName) 527 { 528 skipAfter = phaseName; 529 } 530 GetDumpFunc()531 static const std::string &GetDumpFunc() 532 { 533 return dumpFunc; 534 } 535 IsDumpFunc(const std::string & func)536 static bool IsDumpFunc(const std::string &func) 537 { 538 return ((dumpFunc.compare("*") == 0) || (func.find(CGOptions::dumpFunc.c_str()) != std::string::npos)); 539 } 540 SetDumpFunc(const std::string & func)541 static void SetDumpFunc(const std::string &func) 542 { 543 dumpFunc = func; 544 } FindIndexInProfileData(char data)545 static size_t FindIndexInProfileData(char data) 546 { 547 return profileData.find(data); 548 } 549 SetProfileData(const std::string & path)550 static void SetProfileData(const std::string &path) 551 { 552 profileData = path; 553 } 554 GetProfileData()555 static std::string &GetProfileData() 556 { 557 return profileData; 558 } 559 GetProfileDataSubStr(size_t begin,size_t end)560 static const std::string GetProfileDataSubStr(size_t begin, size_t end) 561 { 562 return profileData.substr(begin, end); 563 } 564 GetProfileDataSubStr(size_t position)565 static const std::string GetProfileDataSubStr(size_t position) 566 { 567 return profileData.substr(position); 568 } 569 IsProfileDataEmpty()570 static bool IsProfileDataEmpty() 571 { 572 return profileData.empty(); 573 } 574 GetProfileFuncData()575 static const std::string &GetProfileFuncData() 576 { 577 return profileFuncData; 578 } 579 IsProfileFuncDataEmpty()580 static bool IsProfileFuncDataEmpty() 581 { 582 return profileFuncData.empty(); 583 } 584 SetProfileFuncData(const std::string & data)585 static void SetProfileFuncData(const std::string &data) 586 { 587 profileFuncData = data; 588 } 589 GetProfileClassData()590 static const std::string &GetProfileClassData() 591 { 592 return profileClassData; 593 } 594 SetProfileClassData(const std::string & data)595 static void SetProfileClassData(const std::string &data) 596 { 597 profileClassData = data; 598 } 599 GetDuplicateAsmFile()600 static const std::string &GetDuplicateAsmFile() 601 { 602 return duplicateAsmFile; 603 } 604 IsDuplicateAsmFileEmpty()605 static bool IsDuplicateAsmFileEmpty() 606 { 607 if (duplicateAsmFile.empty()) { 608 return true; 609 } 610 struct stat buffer; 611 if (stat(duplicateAsmFile.c_str(), &buffer) != 0) { 612 return true; 613 } 614 return false; 615 } 616 SetDuplicateAsmFile(const std::string & fileName)617 static void SetDuplicateAsmFile(const std::string &fileName) 618 { 619 duplicateAsmFile = fileName; 620 } 621 UseRange()622 static bool UseRange() 623 { 624 return range.enable; 625 } GetFastFuncsAsmFile()626 static const std::string &GetFastFuncsAsmFile() 627 { 628 return fastFuncsAsmFile; 629 } 630 IsFastFuncsAsmFileEmpty()631 static bool IsFastFuncsAsmFileEmpty() 632 { 633 return fastFuncsAsmFile.empty(); 634 } 635 SetFastFuncsAsmFile(const std::string & fileName)636 static void SetFastFuncsAsmFile(const std::string &fileName) 637 { 638 fastFuncsAsmFile = fileName; 639 } 640 GetRange()641 static Range &GetRange() 642 { 643 return range; 644 } 645 GetRangeBegin()646 static uint64 GetRangeBegin() 647 { 648 return range.begin; 649 } 650 GetRangeEnd()651 static uint64 GetRangeEnd() 652 { 653 return range.end; 654 } 655 GetSpillRanges()656 static Range &GetSpillRanges() 657 { 658 return spillRanges; 659 } 660 GetSpillRangesBegin()661 static uint64 GetSpillRangesBegin() 662 { 663 return spillRanges.begin; 664 } 665 GetSpillRangesEnd()666 static uint64 GetSpillRangesEnd() 667 { 668 return spillRanges.end; 669 } 670 GetLSRABBOptSize()671 static uint64 GetLSRABBOptSize() 672 { 673 return lsraBBOptSize; 674 } 675 SetLSRABBOptSize(uint64 size)676 static void SetLSRABBOptSize(uint64 size) 677 { 678 lsraBBOptSize = size; 679 } 680 SetLSRAInsnOptSize(uint64 size)681 static void SetLSRAInsnOptSize(uint64 size) 682 { 683 lsraInsnOptSize = size; 684 } 685 GetOverlapNum()686 static uint64 GetOverlapNum() 687 { 688 return overlapNum; 689 } 690 SetOverlapNum(uint64 num)691 static void SetOverlapNum(uint64 num) 692 { 693 overlapNum = num; 694 } 695 GetRematLevel()696 static uint8 GetRematLevel() 697 { 698 return rematLevel; 699 } 700 OptimizeForSize()701 static bool OptimizeForSize() 702 { 703 return optForSize; 704 } 705 SetRematLevel(uint8 level)706 static void SetRematLevel(uint8 level) 707 { 708 rematLevel = level; 709 } 710 GetFastAllocMode()711 static uint8 GetFastAllocMode() 712 { 713 return fastAllocMode; 714 } 715 SetFastAllocMode(uint8 mode)716 static void SetFastAllocMode(uint8 mode) 717 { 718 fastAllocMode = mode; 719 } 720 EnableBarriersForVolatile()721 static void EnableBarriersForVolatile() 722 { 723 useBarriersForVolatile = true; 724 } 725 DisableBarriersForVolatile()726 static void DisableBarriersForVolatile() 727 { 728 useBarriersForVolatile = false; 729 } 730 UseBarriersForVolatile()731 static bool UseBarriersForVolatile() 732 { 733 return useBarriersForVolatile; 734 } EnableFastAlloc()735 static void EnableFastAlloc() 736 { 737 fastAlloc = true; 738 } 739 IsFastAlloc()740 static bool IsFastAlloc() 741 { 742 return fastAlloc; 743 } 744 IsEnableTimePhases()745 static bool IsEnableTimePhases() 746 { 747 return timePhases; 748 } 749 EnableTimePhases()750 static void EnableTimePhases() 751 { 752 timePhases = true; 753 } 754 DisableTimePhases()755 static void DisableTimePhases() 756 { 757 timePhases = false; 758 } 759 EnableInRange()760 static void EnableInRange() 761 { 762 inRange = true; 763 } 764 DisableInRange()765 static void DisableInRange() 766 { 767 inRange = false; 768 } 769 IsInRange()770 static bool IsInRange() 771 { 772 return inRange; 773 } 774 EnableEBO()775 static void EnableEBO() 776 { 777 doEBO = true; 778 } 779 DisableEBO()780 static void DisableEBO() 781 { 782 doEBO = false; 783 } 784 DoEBO()785 static bool DoEBO() 786 { 787 return doEBO; 788 } 789 DisableCGSSA()790 static void DisableCGSSA() 791 { 792 doCGSSA = false; 793 } 794 EnableCGSSA()795 static void EnableCGSSA() 796 { 797 doCGSSA = true; 798 } 799 EnableSupportFuncSymbol()800 static void EnableSupportFuncSymbol() 801 { 802 supportFuncSymbol = true; 803 } 804 DisableSupportFuncSymbol()805 static void DisableSupportFuncSymbol() 806 { 807 supportFuncSymbol = false; 808 } 809 addFuncSymbol()810 static bool addFuncSymbol() 811 { 812 return supportFuncSymbol; 813 } 814 DoCGSSA()815 static bool DoCGSSA() 816 { 817 return doCGSSA; 818 } 819 DisableLocalSchedule()820 static void DisableLocalSchedule() 821 { 822 doLocalSchedule = false; 823 } 824 EnableLocalSchedule()825 static void EnableLocalSchedule() 826 { 827 doLocalSchedule = true; 828 } 829 DoLocalSchedule()830 static bool DoLocalSchedule() 831 { 832 return doLocalSchedule; 833 } 834 DoCGRegCoalecse()835 static bool DoCGRegCoalecse() 836 { 837 return doCGRegCoalesce; 838 } 839 DisableIPARA()840 static void DisableIPARA() 841 { 842 doIPARA = false; 843 } 844 DoIPARA()845 static bool DoIPARA() 846 { 847 return doIPARA; 848 } 849 EnableCFGO()850 static void EnableCFGO() 851 { 852 doCFGO = true; 853 } 854 DisableCFGO()855 static void DisableCFGO() 856 { 857 doCFGO = false; 858 } 859 DoCFGO()860 static bool DoCFGO() 861 { 862 return doCFGO; 863 } 864 EnableRegSavesOpt()865 static void EnableRegSavesOpt() 866 { 867 doRegSavesOpt = true; 868 } 869 DisableRegSavesOpt()870 static void DisableRegSavesOpt() 871 { 872 doRegSavesOpt = false; 873 } 874 DoRegSavesOpt()875 static bool DoRegSavesOpt() 876 { 877 return doRegSavesOpt; 878 } 879 SetUseJitCodeSign(bool isJitCodeSign)880 static void SetUseJitCodeSign(bool isJitCodeSign) 881 { 882 useJitCodeSign = isJitCodeSign; 883 } 884 UseJitCodeSign()885 static bool UseJitCodeSign() 886 { 887 return useJitCodeSign; 888 } 889 EnableSsaPreSave()890 static void EnableSsaPreSave() 891 { 892 useSsaPreSave = true; 893 } 894 DisableSsaPreSave()895 static void DisableSsaPreSave() 896 { 897 useSsaPreSave = false; 898 } 899 UseSsaPreSave()900 static bool UseSsaPreSave() 901 { 902 return useSsaPreSave; 903 } EnableSsuPreRestore()904 static void EnableSsuPreRestore() 905 { 906 useSsuPreRestore = true; 907 } 908 DisableSsuPreRestore()909 static void DisableSsuPreRestore() 910 { 911 useSsuPreRestore = false; 912 } 913 UseSsuPreRestore()914 static bool UseSsuPreRestore() 915 { 916 return useSsuPreRestore; 917 } 918 EnableICO()919 static void EnableICO() 920 { 921 doICO = true; 922 } 923 DisableICO()924 static void DisableICO() 925 { 926 doICO = false; 927 } 928 DoICO()929 static bool DoICO() 930 { 931 return doICO; 932 } 933 EnableStoreLoadOpt()934 static void EnableStoreLoadOpt() 935 { 936 doStoreLoadOpt = true; 937 } 938 DisableStoreLoadOpt()939 static void DisableStoreLoadOpt() 940 { 941 doStoreLoadOpt = false; 942 } 943 DoStoreLoadOpt()944 static bool DoStoreLoadOpt() 945 { 946 return doStoreLoadOpt; 947 } 948 EnableGlobalOpt()949 static void EnableGlobalOpt() 950 { 951 doGlobalOpt = true; 952 } 953 DisableGlobalOpt()954 static void DisableGlobalOpt() 955 { 956 doGlobalOpt = false; 957 } 958 EnableHotColdSplit()959 static void EnableHotColdSplit() 960 { 961 enableHotColdSplit = true; 962 } 963 DisableHotColdSplit()964 static void DisableHotColdSplit() 965 { 966 enableHotColdSplit = false; 967 } 968 DoEnableHotColdSplit()969 static bool DoEnableHotColdSplit() 970 { 971 return enableHotColdSplit; 972 } 973 DoGlobalOpt()974 static bool DoGlobalOpt() 975 { 976 return doGlobalOpt; 977 } 978 EnableAlignAnalysis()979 static void EnableAlignAnalysis() 980 { 981 doAlignAnalysis = true; 982 } 983 DisableAlignAnalysis()984 static void DisableAlignAnalysis() 985 { 986 doAlignAnalysis = false; 987 } 988 DoAlignAnalysis()989 static bool DoAlignAnalysis() 990 { 991 return doAlignAnalysis; 992 } 993 EnableCondBrAlign()994 static void EnableCondBrAlign() 995 { 996 doCondBrAlign = true; 997 } 998 DisableCondBrAlign()999 static void DisableCondBrAlign() 1000 { 1001 doCondBrAlign = false; 1002 } 1003 DoCondBrAlign()1004 static bool DoCondBrAlign() 1005 { 1006 return doCondBrAlign; 1007 } 1008 EnableBigEndianInCG()1009 static void EnableBigEndianInCG() 1010 { 1011 cgBigEndian = true; 1012 } 1013 DisableBigEndianInCG()1014 static void DisableBigEndianInCG() 1015 { 1016 cgBigEndian = false; 1017 } 1018 IsBigEndian()1019 static bool IsBigEndian() 1020 { 1021 return cgBigEndian; 1022 } 1023 EnableArm64ilp32()1024 static void EnableArm64ilp32() 1025 { 1026 arm64ilp32 = true; 1027 } 1028 DisableArm64ilp32()1029 static void DisableArm64ilp32() 1030 { 1031 arm64ilp32 = false; 1032 } 1033 IsArm64ilp32()1034 static bool IsArm64ilp32() 1035 { 1036 return arm64ilp32; 1037 } 1038 IsTargetX86_64()1039 static bool IsTargetX86_64() 1040 { 1041 return targetArch == "x86_64"; 1042 }; 1043 IsTargetAArch64()1044 static bool IsTargetAArch64() 1045 { 1046 return targetArch == "aarch64"; 1047 }; 1048 EnableVregRename()1049 static void EnableVregRename() 1050 { 1051 doVregRename = true; 1052 } 1053 DisableVregRename()1054 static void DisableVregRename() 1055 { 1056 doVregRename = false; 1057 } 1058 DoVregRename()1059 static bool DoVregRename() 1060 { 1061 return doVregRename; 1062 } 1063 EnableMultiPassColorRA()1064 static void EnableMultiPassColorRA() 1065 { 1066 doMultiPassColorRA = true; 1067 } 1068 DisableMultiPassColorRA()1069 static void DisableMultiPassColorRA() 1070 { 1071 doMultiPassColorRA = false; 1072 } 1073 DoMultiPassColorRA()1074 static bool DoMultiPassColorRA() 1075 { 1076 return doMultiPassColorRA; 1077 } 1078 EnablePreLSRAOpt()1079 static void EnablePreLSRAOpt() 1080 { 1081 doPreLSRAOpt = true; 1082 } 1083 DisablePreLSRAOpt()1084 static void DisablePreLSRAOpt() 1085 { 1086 doPreLSRAOpt = false; 1087 } 1088 DoPreLSRAOpt()1089 static bool DoPreLSRAOpt() 1090 { 1091 return doPreLSRAOpt; 1092 } 1093 EnablePrePeephole()1094 static void EnablePrePeephole() 1095 { 1096 doPrePeephole = true; 1097 } 1098 DisablePrePeephole()1099 static void DisablePrePeephole() 1100 { 1101 doPrePeephole = false; 1102 } 1103 DoPrePeephole()1104 static bool DoPrePeephole() 1105 { 1106 return doPrePeephole; 1107 } 1108 EnablePeephole()1109 static void EnablePeephole() 1110 { 1111 doPeephole = true; 1112 } 1113 DisablePeephole()1114 static void DisablePeephole() 1115 { 1116 doPeephole = false; 1117 } 1118 DoPeephole()1119 static bool DoPeephole() 1120 { 1121 return doPeephole; 1122 } 1123 EnableRetMerge()1124 static void EnableRetMerge() 1125 { 1126 doRetMerge = true; 1127 } 1128 DisableRetMerge()1129 static void DisableRetMerge() 1130 { 1131 doRetMerge = false; 1132 } 1133 DoRetMerge()1134 static bool DoRetMerge() 1135 { 1136 return doRetMerge; 1137 } 1138 EnablePreSchedule()1139 static void EnablePreSchedule() 1140 { 1141 doPreSchedule = true; 1142 } 1143 DisablePreSchedule()1144 static void DisablePreSchedule() 1145 { 1146 doPreSchedule = false; 1147 } 1148 DoPreSchedule()1149 static bool DoPreSchedule() 1150 { 1151 return doPreSchedule; 1152 } 1153 EnableSchedule()1154 static void EnableSchedule() 1155 { 1156 doSchedule = true; 1157 } 1158 DisableSchedule()1159 static void DisableSchedule() 1160 { 1161 doSchedule = false; 1162 } 1163 DoSchedule()1164 static bool DoSchedule() 1165 { 1166 return doSchedule; 1167 } EnableWriteRefFieldOpt()1168 static void EnableWriteRefFieldOpt() 1169 { 1170 doWriteRefFieldOpt = true; 1171 } 1172 DisableWriteRefFieldOpt()1173 static void DisableWriteRefFieldOpt() 1174 { 1175 doWriteRefFieldOpt = false; 1176 } DoWriteRefFieldOpt()1177 static bool DoWriteRefFieldOpt() 1178 { 1179 return doWriteRefFieldOpt; 1180 } 1181 EnableDumpOptimizeCommonLog()1182 static void EnableDumpOptimizeCommonLog() 1183 { 1184 dumpOptimizeCommonLog = true; 1185 } 1186 DisableDumpOptimizeCommonLog()1187 static void DisableDumpOptimizeCommonLog() 1188 { 1189 dumpOptimizeCommonLog = false; 1190 } 1191 IsDumpOptimizeCommonLog()1192 static bool IsDumpOptimizeCommonLog() 1193 { 1194 return dumpOptimizeCommonLog; 1195 } 1196 EnableCheckArrayStore()1197 static void EnableCheckArrayStore() 1198 { 1199 checkArrayStore = true; 1200 } 1201 DisableCheckArrayStore()1202 static void DisableCheckArrayStore() 1203 { 1204 checkArrayStore = false; 1205 } 1206 IsCheckArrayStore()1207 static bool IsCheckArrayStore() 1208 { 1209 return checkArrayStore; 1210 } 1211 EnableExclusiveEH()1212 static void EnableExclusiveEH() 1213 { 1214 exclusiveEH = true; 1215 } 1216 IsExclusiveEH()1217 static bool IsExclusiveEH() 1218 { 1219 return exclusiveEH; 1220 } 1221 EnablePIC()1222 static void EnablePIC() 1223 { 1224 doPIC = true; 1225 } 1226 DisablePIC()1227 static void DisablePIC() 1228 { 1229 doPIC = false; 1230 } 1231 IsPIC()1232 static bool IsPIC() 1233 { 1234 return doPIC; 1235 } 1236 EnableNoDupBB()1237 static void EnableNoDupBB() 1238 { 1239 noDupBB = true; 1240 } 1241 DisableNoDupBB()1242 static void DisableNoDupBB() 1243 { 1244 noDupBB = false; 1245 } 1246 IsNoDupBB()1247 static bool IsNoDupBB() 1248 { 1249 return noDupBB; 1250 } 1251 EnableNoCalleeCFI()1252 static void EnableNoCalleeCFI() 1253 { 1254 noCalleeCFI = true; 1255 } 1256 DisableNoCalleeCFI()1257 static void DisableNoCalleeCFI() 1258 { 1259 noCalleeCFI = false; 1260 } 1261 IsNoCalleeCFI()1262 static bool IsNoCalleeCFI() 1263 { 1264 return noCalleeCFI; 1265 } 1266 EnableEmitCyclePattern()1267 static void EnableEmitCyclePattern() 1268 { 1269 emitCyclePattern = true; 1270 } 1271 IsInsertYieldPoint()1272 static bool IsInsertYieldPoint() 1273 { 1274 return insertYieldPoint; 1275 } 1276 EnableMapleLinker()1277 static void EnableMapleLinker() 1278 { 1279 mapleLinker = true; 1280 } 1281 DisableMapleLinker()1282 static void DisableMapleLinker() 1283 { 1284 mapleLinker = false; 1285 } 1286 IsMapleLinker()1287 static bool IsMapleLinker() 1288 { 1289 return mapleLinker; 1290 } EnableReplaceASM()1291 static void EnableReplaceASM() 1292 { 1293 replaceASM = true; 1294 } 1295 DisableReplaceASM()1296 static void DisableReplaceASM() 1297 { 1298 replaceASM = false; 1299 } 1300 IsReplaceASM()1301 static bool IsReplaceASM() 1302 { 1303 return replaceASM; 1304 } 1305 EnableGeneralRegOnly()1306 static void EnableGeneralRegOnly() 1307 { 1308 generalRegOnly = true; 1309 } 1310 DisableGeneralRegOnly()1311 static void DisableGeneralRegOnly() 1312 { 1313 generalRegOnly = false; 1314 } 1315 UseGeneralRegOnly()1316 static bool UseGeneralRegOnly() 1317 { 1318 return generalRegOnly; 1319 } 1320 EnablePrintFunction()1321 static void EnablePrintFunction() 1322 { 1323 printFunction = true; 1324 } 1325 DisablePrintFunction()1326 static void DisablePrintFunction() 1327 { 1328 printFunction = false; 1329 } 1330 IsPrintFunction()1331 static bool IsPrintFunction() 1332 { 1333 return printFunction; 1334 } 1335 GetGlobalVarProFile()1336 static std::string &GetGlobalVarProFile() 1337 { 1338 return globalVarProfile; 1339 } 1340 IsGlobalVarProFileEmpty()1341 static bool IsGlobalVarProFileEmpty() 1342 { 1343 return globalVarProfile.empty(); 1344 } 1345 IsEmitBlockMarker()1346 static bool IsEmitBlockMarker() 1347 { 1348 return emitBlockMarker; 1349 } 1350 EnableNativeOpt()1351 static void EnableNativeOpt() 1352 { 1353 nativeOpt = true; 1354 } 1355 DisableNativeOpt()1356 static void DisableNativeOpt() 1357 { 1358 nativeOpt = false; 1359 } 1360 IsNativeOpt()1361 static bool IsNativeOpt() 1362 { 1363 return nativeOpt; 1364 } 1365 EnableLazyBinding()1366 static void EnableLazyBinding() 1367 { 1368 lazyBinding = true; 1369 } 1370 DisableLazyBinding()1371 static void DisableLazyBinding() 1372 { 1373 lazyBinding = false; 1374 } 1375 IsLazyBinding()1376 static bool IsLazyBinding() 1377 { 1378 return lazyBinding; 1379 } 1380 EnableHotFix()1381 static void EnableHotFix() 1382 { 1383 hotFix = true; 1384 } 1385 DisableHotFix()1386 static void DisableHotFix() 1387 { 1388 hotFix = false; 1389 } 1390 IsHotFix()1391 static bool IsHotFix() 1392 { 1393 return hotFix; 1394 } 1395 EnableDebugSched()1396 static void EnableDebugSched() 1397 { 1398 debugSched = true; 1399 } 1400 DisableDebugSched()1401 static void DisableDebugSched() 1402 { 1403 debugSched = false; 1404 } 1405 IsDebugSched()1406 static bool IsDebugSched() 1407 { 1408 return debugSched; 1409 } 1410 EnableDruteForceSched()1411 static void EnableDruteForceSched() 1412 { 1413 bruteForceSched = true; 1414 } 1415 DisableDruteForceSched()1416 static void DisableDruteForceSched() 1417 { 1418 bruteForceSched = false; 1419 } 1420 IsDruteForceSched()1421 static bool IsDruteForceSched() 1422 { 1423 return bruteForceSched; 1424 } 1425 EnableSimulateSched()1426 static void EnableSimulateSched() 1427 { 1428 simulateSched = true; 1429 } 1430 DisableSimulateSched()1431 static void DisableSimulateSched() 1432 { 1433 simulateSched = false; 1434 } 1435 IsSimulateSched()1436 static bool IsSimulateSched() 1437 { 1438 return simulateSched; 1439 } 1440 SetABIType(const std::string & type)1441 static void SetABIType(const std::string &type) 1442 { 1443 if (type == "hard") { 1444 abiType = kABIHard; 1445 } else if (type == "soft") { 1446 CHECK_FATAL(false, "float-abi=soft is not supported Currently."); 1447 } else if (type == "softfp") { 1448 abiType = kABISoftFP; 1449 } else { 1450 CHECK_FATAL(false, "unexpected abi-type, only hard, soft and softfp are supported"); 1451 } 1452 } 1453 GetABIType()1454 static ABIType GetABIType() 1455 { 1456 return abiType; 1457 } 1458 EnableLongCalls()1459 static void EnableLongCalls() 1460 { 1461 genLongCalls = true; 1462 } 1463 DisableLongCalls()1464 static void DisableLongCalls() 1465 { 1466 genLongCalls = false; 1467 } 1468 IsLongCalls()1469 static bool IsLongCalls() 1470 { 1471 return genLongCalls; 1472 } 1473 EnableFunctionSections()1474 static void EnableFunctionSections() 1475 { 1476 functionSections = true; 1477 } 1478 DisableFunctionSections()1479 static void DisableFunctionSections() 1480 { 1481 functionSections = false; 1482 } 1483 IsFunctionSections()1484 static bool IsFunctionSections() 1485 { 1486 return functionSections; 1487 } 1488 EnableFramePointer()1489 static void EnableFramePointer() 1490 { 1491 useFramePointer = true; 1492 } 1493 DisableFramePointer()1494 static void DisableFramePointer() 1495 { 1496 useFramePointer = false; 1497 } 1498 UseFramePointer()1499 static bool UseFramePointer() 1500 { 1501 return useFramePointer; 1502 } 1503 EnableGCOnly()1504 static void EnableGCOnly() 1505 { 1506 gcOnly = true; 1507 } 1508 DisableGCOnly()1509 static void DisableGCOnly() 1510 { 1511 gcOnly = false; 1512 } 1513 IsGCOnly()1514 static bool IsGCOnly() 1515 { 1516 return gcOnly; 1517 } 1518 GetOptionFlag()1519 const OptionFlag &GetOptionFlag() const 1520 { 1521 return options; 1522 } 1523 SetOptionFlag(const OptionFlag & flag)1524 void SetOptionFlag(const OptionFlag &flag) 1525 { 1526 options = flag; 1527 } 1528 EnableFastMath()1529 static void EnableFastMath() 1530 { 1531 fastMath = true; 1532 } 1533 DisableFastMath()1534 static void DisableFastMath() 1535 { 1536 fastMath = false; 1537 } 1538 IsFastMath()1539 static bool IsFastMath() 1540 { 1541 return fastMath; 1542 } 1543 EnableCommon()1544 static void EnableCommon() 1545 { 1546 noCommon = false; 1547 } 1548 DisableCommon()1549 static void DisableCommon() 1550 { 1551 noCommon = true; 1552 } 1553 IsNoCommon()1554 static bool IsNoCommon() 1555 { 1556 return noCommon; 1557 } 1558 SetAlignMinBBSize(uint32 minBBSize)1559 static void SetAlignMinBBSize(uint32 minBBSize) 1560 { 1561 alignMinBBSize = minBBSize; 1562 } 1563 GetAlignMinBBSize()1564 static uint32 GetAlignMinBBSize() 1565 { 1566 return alignMinBBSize; 1567 } 1568 SetAlignMaxBBSize(uint32 maxBBSize)1569 static void SetAlignMaxBBSize(uint32 maxBBSize) 1570 { 1571 alignMaxBBSize = maxBBSize; 1572 } 1573 GetAlignMaxBBSize()1574 static uint32 GetAlignMaxBBSize() 1575 { 1576 return alignMaxBBSize; 1577 } 1578 SetLoopAlignPow(uint32 loopPow)1579 static void SetLoopAlignPow(uint32 loopPow) 1580 { 1581 loopAlignPow = loopPow; 1582 } 1583 GetLoopAlignPow()1584 static uint32 GetLoopAlignPow() 1585 { 1586 return loopAlignPow; 1587 } 1588 SetJumpAlignPow(uint32 jumpPow)1589 static void SetJumpAlignPow(uint32 jumpPow) 1590 { 1591 jumpAlignPow = jumpPow; 1592 } 1593 GetJumpAlignPow()1594 static uint32 GetJumpAlignPow() 1595 { 1596 return jumpAlignPow; 1597 } 1598 SetFuncAlignPow(uint32 funcPow)1599 static void SetFuncAlignPow(uint32 funcPow) 1600 { 1601 funcAlignPow = funcPow; 1602 } 1603 GetFuncAlignPow()1604 static uint32 GetFuncAlignPow() 1605 { 1606 return funcAlignPow; 1607 } 1608 EnableOptimizedFrameLayout()1609 static void EnableOptimizedFrameLayout() 1610 { 1611 doOptimizedFrameLayout = true; 1612 } 1613 DisableOptimizedFrameLayout()1614 static void DisableOptimizedFrameLayout() 1615 { 1616 doOptimizedFrameLayout = false; 1617 } 1618 DoOptimizedFrameLayout()1619 static bool DoOptimizedFrameLayout() 1620 { 1621 return doOptimizedFrameLayout; 1622 } 1623 DoCGIRVerify()1624 static bool DoCGIRVerify() 1625 { 1626 return doCgirVerify; 1627 } 1628 private: 1629 std::vector<std::string> phaseSequence; 1630 EmitMemoryManager emitMemoryManager; 1631 1632 bool insertCall = false; 1633 bool runCGFlag = true; 1634 bool asmEmitterEnable = false; 1635 bool generateObjectMap = true; 1636 uint32 parserOption = 0; 1637 int32 optimizeLevel = 0; 1638 1639 GenerateFlag generateFlag = 0; 1640 OptionFlag options = kUndefined; 1641 std::string instrumentationFunction; 1642 1643 std::string classListFile; 1644 std::string ehExclusiveFile; 1645 std::string cyclePatternFile; 1646 /* we don't do exception handling in this list */ 1647 std::vector<std::string> ehExclusiveFunctionName; 1648 1649 static bool quiet; 1650 static std::string targetArch; 1651 static std::unordered_set<std::string> dumpPhases; 1652 static std::unordered_set<std::string> skipPhases; 1653 static std::unordered_map<std::string, std::vector<std::string>> cyclePatternMap; 1654 static std::string skipFrom; 1655 static std::string skipAfter; 1656 static std::string dumpFunc; 1657 static std::string duplicateAsmFile; 1658 static bool optForSize; 1659 static bool enableHotColdSplit; 1660 static bool useBarriersForVolatile; 1661 static bool timePhases; 1662 static bool cgBigEndian; 1663 static bool doEBO; 1664 static bool doCGSSA; 1665 static bool doLocalSchedule; 1666 static bool doCGRegCoalesce; 1667 static bool doIPARA; 1668 static bool doCFGO; 1669 static bool doICO; 1670 static bool doStoreLoadOpt; 1671 static bool doGlobalOpt; 1672 static bool doVregRename; 1673 static bool doMultiPassColorRA; 1674 static bool doPrePeephole; 1675 static bool doPeephole; 1676 static bool doRetMerge; 1677 static bool doSchedule; 1678 static bool doAlignAnalysis; 1679 static bool doCondBrAlign; 1680 static bool doWriteRefFieldOpt; 1681 static bool doRegSavesOpt; 1682 static bool useSsaPreSave; 1683 static bool useSsuPreRestore; 1684 static bool dumpOptimizeCommonLog; 1685 static bool checkArrayStore; 1686 static bool exclusiveEH; 1687 static bool doPIC; 1688 static bool noDupBB; 1689 static bool noCalleeCFI; 1690 static bool emitCyclePattern; 1691 static bool insertYieldPoint; 1692 static bool mapleLinker; 1693 static bool printFunction; 1694 static std::string globalVarProfile; 1695 static bool nativeOpt; 1696 static bool lazyBinding; 1697 static bool arm64ilp32; 1698 static bool hotFix; 1699 static bool useJitCodeSign; 1700 /* if true dump scheduling information */ 1701 static bool debugSched; 1702 /* if true do BruteForceSchedule */ 1703 static bool bruteForceSched; 1704 /* if true do SimulateSched */ 1705 static bool simulateSched; 1706 static ABIType abiType; 1707 /* if true generate adrp/ldr/blr */ 1708 static bool genLongCalls; 1709 static bool functionSections; 1710 static bool useFramePointer; 1711 static bool gcOnly; 1712 static bool doPreSchedule; 1713 static bool emitBlockMarker; 1714 static Range range; 1715 static bool inRange; 1716 static bool doPatchLongBranch; 1717 static std::string profileData; 1718 static std::string profileFuncData; 1719 static std::string profileClassData; 1720 static std::string fastFuncsAsmFile; 1721 static Range spillRanges; 1722 static uint64 lsraBBOptSize; 1723 static uint64 lsraInsnOptSize; 1724 static uint64 overlapNum; 1725 static uint8 rematLevel; 1726 static uint8 fastAllocMode; 1727 static bool fastAlloc; 1728 static bool doPreLSRAOpt; 1729 static bool replaceASM; 1730 static bool generalRegOnly; 1731 static std::string literalProfile; 1732 static bool fastMath; 1733 static bool noCommon; 1734 static uint32 alignMinBBSize; 1735 static uint32 alignMaxBBSize; 1736 static uint32 loopAlignPow; 1737 static uint32 jumpAlignPow; 1738 static uint32 funcAlignPow; 1739 static bool doOptimizedFrameLayout; 1740 static bool doCgirVerify; 1741 static bool supportFuncSymbol; 1742 }; 1743 } /* namespace maplebe */ 1744 1745 #define SET_FIND(SET, NAME) ((SET).find(NAME)) 1746 #define SET_END(SET) ((SET).end()) 1747 #define IS_STR_IN_SET(SET, NAME) (SET_FIND(SET, NAME) != SET_END(SET)) 1748 1749 #define CG_DEBUG_FUNC(f) \ 1750 (!maplebe::CGOptions::GetDumpPhases().empty() && maplebe::CGOptions::IsDumpFunc((f).GetName()) && \ 1751 maplebe::CGOptions::GetDumpPhases().find(PhaseName()) != maplebe::CGOptions::GetDumpPhases().end()) 1752 #ifndef TRACE_PHASE 1753 #define TRACE_PHASE (IS_STR_IN_SET(maplebe::CGOptions::GetDumpPhases(), PhaseName())) 1754 #endif 1755 1756 #endif /* MAPLEBE_INCLUDE_CG_CG_OPTION_H */ 1757