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