Karl Schimpf | 8d7abae | 2014-07-07 14:50:30 -0700 | [diff] [blame] | 1 | //===- subzero/src/IceClFlags.h - Cl Flags for translation ------*- C++ -*-===// |
| 2 | // |
| 3 | // The Subzero Code Generator |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file declares command line flags controlling translation. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef SUBZERO_SRC_ICECLFLAGS_H |
| 15 | #define SUBZERO_SRC_ICECLFLAGS_H |
| 16 | |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame^] | 17 | #include "IceTypes.h" |
Karl Schimpf | 5ee234a | 2014-09-12 10:41:40 -0700 | [diff] [blame] | 18 | |
Karl Schimpf | 8d7abae | 2014-07-07 14:50:30 -0700 | [diff] [blame] | 19 | namespace Ice { |
| 20 | |
| 21 | class ClFlags { |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 22 | ClFlags(const ClFlags &) = delete; |
| 23 | ClFlags &operator=(const ClFlags &) = delete; |
| 24 | |
Karl Schimpf | 8d7abae | 2014-07-07 14:50:30 -0700 | [diff] [blame] | 25 | public: |
| 26 | ClFlags() |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 27 | : // bool fields. |
| 28 | AllowErrorRecovery(false), |
| 29 | AllowUninitializedGlobals(false), DataSections(false), |
| 30 | DecorateAsm(false), DisableInternal(false), DisableIRGeneration(false), |
| 31 | DisableTranslation(false), DumpStats(false), FunctionSections(false), |
| 32 | GenerateUnitTestMessages(false), PhiEdgeSplit(false), |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame^] | 33 | RandomNopInsertion(false), RandomRegAlloc(false), |
Jan Voung | f644a4b | 2015-03-19 11:57:52 -0700 | [diff] [blame] | 34 | SubzeroTimingEnabled(false), TimeEachFunction(false), |
| 35 | UseSandboxing(false), |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame^] | 36 | // Enum and integer fields |
| 37 | Opt(Opt_m1), OutFileType(FT_Iasm), RandomMaxNopsPerInstruction(0), |
| 38 | RandomNopProbabilityAsPercentage(0), TArch(TargetArch_NUM), |
| 39 | VMask(IceV_None), |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 40 | // IceString fields. |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame^] | 41 | DefaultFunctionPrefix(""), DefaultGlobalPrefix(""), TestPrefix(""), |
| 42 | TimingFocusOn(""), TranslateOnly(""), VerboseFocusOn(""), |
| 43 | // size_t and 64-bit fields. |
| 44 | NumTranslationThreads(0), RandomSeed(0) {} |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 45 | |
| 46 | // bool accessors. |
| 47 | |
| 48 | bool getAllowErrorRecovery() const { return AllowErrorRecovery; } |
| 49 | void setAllowErrorRecovery(bool NewValue) { AllowErrorRecovery = NewValue; } |
| 50 | |
| 51 | bool getAllowUninitializedGlobals() const { |
| 52 | return AllowUninitializedGlobals; |
| 53 | } |
| 54 | void setAllowUninitializedGlobals(bool NewValue) { |
| 55 | AllowUninitializedGlobals = NewValue; |
| 56 | } |
| 57 | |
| 58 | bool getDataSections() const { return DataSections; } |
| 59 | void setDataSections(bool NewValue) { DataSections = NewValue; } |
| 60 | |
| 61 | bool getDecorateAsm() const { return DecorateAsm; } |
| 62 | void setDecorateAsm(bool NewValue) { DecorateAsm = NewValue; } |
| 63 | |
| 64 | bool getDisableInternal() const { return DisableInternal; } |
| 65 | void setDisableInternal(bool NewValue) { DisableInternal = NewValue; } |
| 66 | |
| 67 | bool getDisableIRGeneration() const { |
| 68 | return ALLOW_DISABLE_IR_GEN && DisableIRGeneration; |
| 69 | } |
| 70 | void setDisableIRGeneration(bool NewValue) { DisableIRGeneration = NewValue; } |
| 71 | |
| 72 | bool getDisableTranslation() const { return DisableTranslation; } |
| 73 | void setDisableTranslation(bool NewValue) { DisableTranslation = NewValue; } |
| 74 | |
| 75 | bool getDumpStats() const { return ALLOW_DUMP && DumpStats; } |
| 76 | void setDumpStats(bool NewValue) { DumpStats = NewValue; } |
| 77 | |
| 78 | bool getFunctionSections() const { return FunctionSections; } |
| 79 | void setFunctionSections(bool NewValue) { FunctionSections = NewValue; } |
| 80 | |
| 81 | bool getGenerateUnitTestMessages() const { |
| 82 | // Note: If dump routines have been turned off, the error messages |
| 83 | // will not be readable. Hence, turn off. |
| 84 | return !ALLOW_DUMP || GenerateUnitTestMessages; |
| 85 | } |
| 86 | void setGenerateUnitTestMessages(bool NewValue) { |
| 87 | GenerateUnitTestMessages = NewValue; |
| 88 | } |
| 89 | |
| 90 | bool getPhiEdgeSplit() const { return PhiEdgeSplit; } |
| 91 | void setPhiEdgeSplit(bool NewValue) { PhiEdgeSplit = NewValue; } |
| 92 | |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame^] | 93 | bool shouldDoNopInsertion() const { return RandomNopInsertion; } |
| 94 | void setShouldDoNopInsertion(bool NewValue) { RandomNopInsertion = NewValue; } |
| 95 | |
| 96 | bool shouldRandomizeRegAlloc() const { return RandomRegAlloc; } |
| 97 | void setShouldRandomizeRegAlloc(bool NewValue) { RandomRegAlloc = NewValue; } |
| 98 | |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 99 | bool getSubzeroTimingEnabled() const { return SubzeroTimingEnabled; } |
| 100 | void setSubzeroTimingEnabled(bool NewValue) { |
| 101 | SubzeroTimingEnabled = NewValue; |
| 102 | } |
| 103 | |
| 104 | bool getTimeEachFunction() const { return ALLOW_DUMP && TimeEachFunction; } |
| 105 | void setTimeEachFunction(bool NewValue) { TimeEachFunction = NewValue; } |
| 106 | |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 107 | bool getUseSandboxing() const { return UseSandboxing; } |
| 108 | void setUseSandboxing(bool NewValue) { UseSandboxing = NewValue; } |
| 109 | |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame^] | 110 | // Enum and integer accessors. |
| 111 | OptLevel getOptLevel() const { return Opt; } |
| 112 | void setOptLevel(OptLevel NewValue) { Opt = NewValue; } |
| 113 | |
Jim Stichnoth | d442e7e | 2015-02-12 14:01:48 -0800 | [diff] [blame] | 114 | FileType getOutFileType() const { return OutFileType; } |
| 115 | void setOutFileType(FileType NewValue) { OutFileType = NewValue; } |
| 116 | |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame^] | 117 | int getMaxNopsPerInstruction() const { return RandomMaxNopsPerInstruction; } |
| 118 | void setMaxNopsPerInstruction(int NewValue) { |
| 119 | RandomMaxNopsPerInstruction = NewValue; |
| 120 | } |
| 121 | |
| 122 | int getNopProbabilityAsPercentage() const { |
| 123 | return RandomNopProbabilityAsPercentage; |
| 124 | } |
| 125 | void setNopProbabilityAsPercentage(int NewValue) { |
| 126 | RandomNopProbabilityAsPercentage = NewValue; |
| 127 | } |
| 128 | |
| 129 | TargetArch getTargetArch() const { return TArch; } |
| 130 | void setTargetArch(TargetArch NewValue) { TArch = NewValue; } |
| 131 | |
| 132 | TargetInstructionSet getTargetInstructionSet() const { return TInstrSet; } |
| 133 | void setTargetInstructionSet(TargetInstructionSet NewValue) { |
| 134 | TInstrSet = NewValue; |
| 135 | } |
| 136 | |
| 137 | VerboseMask getVerbose() const { return ALLOW_DUMP ? VMask : IceV_None; } |
| 138 | void setVerbose(VerboseMask NewValue) { VMask = NewValue; } |
| 139 | |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 140 | // IceString accessors. |
| 141 | |
| 142 | const IceString &getDefaultFunctionPrefix() const { |
| 143 | return DefaultFunctionPrefix; |
| 144 | } |
| 145 | void setDefaultFunctionPrefix(const IceString &NewValue) { |
| 146 | DefaultFunctionPrefix = NewValue; |
| 147 | } |
| 148 | |
| 149 | const IceString &getDefaultGlobalPrefix() const { |
| 150 | return DefaultGlobalPrefix; |
| 151 | } |
| 152 | void setDefaultGlobalPrefix(const IceString &NewValue) { |
| 153 | DefaultGlobalPrefix = NewValue; |
| 154 | } |
| 155 | |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame^] | 156 | const IceString &getTestPrefix() const { return TestPrefix; } |
| 157 | void setTestPrefix(const IceString &NewValue) { TestPrefix = NewValue; } |
| 158 | |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 159 | const IceString &getTimingFocusOn() const { return TimingFocusOn; } |
| 160 | void setTimingFocusOn(const IceString &NewValue) { TimingFocusOn = NewValue; } |
| 161 | |
| 162 | const IceString &getTranslateOnly() const { return TranslateOnly; } |
| 163 | void setTranslateOnly(const IceString &NewValue) { TranslateOnly = NewValue; } |
| 164 | |
| 165 | const IceString &getVerboseFocusOn() const { return VerboseFocusOn; } |
| 166 | void setVerboseFocusOn(const IceString &NewValue) { |
| 167 | VerboseFocusOn = NewValue; |
| 168 | } |
| 169 | |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame^] | 170 | // size_t and 64-bit accessors. |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 171 | |
| 172 | size_t getNumTranslationThreads() const { return NumTranslationThreads; } |
Jim Stichnoth | bbca754 | 2015-02-11 16:08:31 -0800 | [diff] [blame] | 173 | bool isSequential() const { return NumTranslationThreads == 0; } |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 174 | void setNumTranslationThreads(size_t NewValue) { |
| 175 | NumTranslationThreads = NewValue; |
| 176 | } |
| 177 | |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame^] | 178 | uint64_t getRandomSeed() const { return RandomSeed; } |
| 179 | void setRandomSeed(size_t NewValue) { RandomSeed = NewValue; } |
| 180 | |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 181 | private: |
| 182 | bool AllowErrorRecovery; |
| 183 | bool AllowUninitializedGlobals; |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 184 | bool DataSections; |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 185 | bool DecorateAsm; |
| 186 | bool DisableInternal; |
| 187 | bool DisableIRGeneration; |
| 188 | bool DisableTranslation; |
| 189 | bool DumpStats; |
| 190 | bool FunctionSections; |
| 191 | bool GenerateUnitTestMessages; |
| 192 | bool PhiEdgeSplit; |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame^] | 193 | bool RandomNopInsertion; |
| 194 | bool RandomRegAlloc; |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 195 | bool SubzeroTimingEnabled; |
| 196 | bool TimeEachFunction; |
Jim Stichnoth | bfb03e5 | 2014-08-26 10:29:05 -0700 | [diff] [blame] | 197 | bool UseSandboxing; |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 198 | |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame^] | 199 | OptLevel Opt; |
Jim Stichnoth | d442e7e | 2015-02-12 14:01:48 -0800 | [diff] [blame] | 200 | FileType OutFileType; |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame^] | 201 | int RandomMaxNopsPerInstruction; |
| 202 | int RandomNopProbabilityAsPercentage; |
| 203 | TargetArch TArch; |
| 204 | TargetInstructionSet TInstrSet; |
| 205 | VerboseMask VMask; |
Jim Stichnoth | d442e7e | 2015-02-12 14:01:48 -0800 | [diff] [blame] | 206 | |
Karl Schimpf | 5ee234a | 2014-09-12 10:41:40 -0700 | [diff] [blame] | 207 | IceString DefaultFunctionPrefix; |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 208 | IceString DefaultGlobalPrefix; |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame^] | 209 | IceString TestPrefix; |
Jim Stichnoth | 8363a06 | 2014-10-07 10:02:38 -0700 | [diff] [blame] | 210 | IceString TimingFocusOn; |
Jim Stichnoth | 088b2be | 2014-10-23 12:02:08 -0700 | [diff] [blame] | 211 | IceString TranslateOnly; |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 212 | IceString VerboseFocusOn; |
| 213 | |
| 214 | size_t NumTranslationThreads; // 0 means completely sequential |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame^] | 215 | uint64_t RandomSeed; |
Karl Schimpf | 8d7abae | 2014-07-07 14:50:30 -0700 | [diff] [blame] | 216 | }; |
Jim Stichnoth | 989a703 | 2014-08-08 10:13:44 -0700 | [diff] [blame] | 217 | |
| 218 | } // end of namespace Ice |
Karl Schimpf | 8d7abae | 2014-07-07 14:50:30 -0700 | [diff] [blame] | 219 | |
| 220 | #endif // SUBZERO_SRC_ICECLFLAGS_H |