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 | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 17 | #include "IceDefs.h" |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame] | 18 | #include "IceTypes.h" |
Karl Schimpf | 5ee234a | 2014-09-12 10:41:40 -0700 | [diff] [blame] | 19 | |
Karl Schimpf | 8d7abae | 2014-07-07 14:50:30 -0700 | [diff] [blame] | 20 | namespace Ice { |
| 21 | |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 22 | class ClFlagsExtra; |
| 23 | |
Karl Schimpf | 8d7abae | 2014-07-07 14:50:30 -0700 | [diff] [blame] | 24 | class ClFlags { |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 25 | ClFlags(const ClFlags &) = delete; |
| 26 | ClFlags &operator=(const ClFlags &) = delete; |
| 27 | |
Karl Schimpf | 8d7abae | 2014-07-07 14:50:30 -0700 | [diff] [blame] | 28 | public: |
Karl Schimpf | d8b3289 | 2015-04-16 15:47:25 -0700 | [diff] [blame] | 29 | ClFlags() { resetClFlags(*this); } |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 30 | |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 31 | static void parseFlags(int argc, char *argv[]); |
Karl Schimpf | d8b3289 | 2015-04-16 15:47:25 -0700 | [diff] [blame] | 32 | static void resetClFlags(ClFlags &OutFlags); |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 33 | static void getParsedClFlags(ClFlags &OutFlags); |
| 34 | static void getParsedClFlagsExtra(ClFlagsExtra &OutFlagsExtra); |
| 35 | |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 36 | // bool accessors. |
| 37 | |
| 38 | bool getAllowErrorRecovery() const { return AllowErrorRecovery; } |
| 39 | void setAllowErrorRecovery(bool NewValue) { AllowErrorRecovery = NewValue; } |
| 40 | |
| 41 | bool getAllowUninitializedGlobals() const { |
| 42 | return AllowUninitializedGlobals; |
| 43 | } |
| 44 | void setAllowUninitializedGlobals(bool NewValue) { |
| 45 | AllowUninitializedGlobals = NewValue; |
| 46 | } |
| 47 | |
| 48 | bool getDataSections() const { return DataSections; } |
| 49 | void setDataSections(bool NewValue) { DataSections = NewValue; } |
| 50 | |
| 51 | bool getDecorateAsm() const { return DecorateAsm; } |
| 52 | void setDecorateAsm(bool NewValue) { DecorateAsm = NewValue; } |
| 53 | |
| 54 | bool getDisableInternal() const { return DisableInternal; } |
| 55 | void setDisableInternal(bool NewValue) { DisableInternal = NewValue; } |
| 56 | |
| 57 | bool getDisableIRGeneration() const { |
Jim Stichnoth | 20b71f5 | 2015-06-24 15:52:24 -0700 | [diff] [blame] | 58 | return BuildDefs::disableIrGen() && DisableIRGeneration; |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 59 | } |
| 60 | void setDisableIRGeneration(bool NewValue) { DisableIRGeneration = NewValue; } |
| 61 | |
| 62 | bool getDisableTranslation() const { return DisableTranslation; } |
| 63 | void setDisableTranslation(bool NewValue) { DisableTranslation = NewValue; } |
| 64 | |
Jim Stichnoth | 20b71f5 | 2015-06-24 15:52:24 -0700 | [diff] [blame] | 65 | bool getDumpStats() const { return BuildDefs::dump() && DumpStats; } |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 66 | void setDumpStats(bool NewValue) { DumpStats = NewValue; } |
| 67 | |
John Porto | f8b4cc8 | 2015-06-09 18:06:19 -0700 | [diff] [blame] | 68 | bool getEnableBlockProfile() const { return EnableBlockProfile; } |
| 69 | void setEnableBlockProfile(bool NewValue) { EnableBlockProfile = NewValue; } |
| 70 | |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 71 | bool getFunctionSections() const { return FunctionSections; } |
| 72 | void setFunctionSections(bool NewValue) { FunctionSections = NewValue; } |
| 73 | |
| 74 | bool getGenerateUnitTestMessages() const { |
| 75 | // Note: If dump routines have been turned off, the error messages |
| 76 | // will not be readable. Hence, turn off. |
Jim Stichnoth | 20b71f5 | 2015-06-24 15:52:24 -0700 | [diff] [blame] | 77 | return !BuildDefs::dump() || GenerateUnitTestMessages; |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 78 | } |
| 79 | void setGenerateUnitTestMessages(bool NewValue) { |
| 80 | GenerateUnitTestMessages = NewValue; |
| 81 | } |
| 82 | |
| 83 | bool getPhiEdgeSplit() const { return PhiEdgeSplit; } |
| 84 | void setPhiEdgeSplit(bool NewValue) { PhiEdgeSplit = NewValue; } |
| 85 | |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame] | 86 | bool shouldDoNopInsertion() const { return RandomNopInsertion; } |
| 87 | void setShouldDoNopInsertion(bool NewValue) { RandomNopInsertion = NewValue; } |
| 88 | |
| 89 | bool shouldRandomizeRegAlloc() const { return RandomRegAlloc; } |
| 90 | void setShouldRandomizeRegAlloc(bool NewValue) { RandomRegAlloc = NewValue; } |
| 91 | |
Jan Voung | b2d5084 | 2015-05-12 09:53:50 -0700 | [diff] [blame] | 92 | bool getSkipUnimplemented() const { return SkipUnimplemented; } |
| 93 | void setSkipUnimplemented(bool NewValue) { SkipUnimplemented = NewValue; } |
| 94 | |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 95 | bool getSubzeroTimingEnabled() const { return SubzeroTimingEnabled; } |
| 96 | void setSubzeroTimingEnabled(bool NewValue) { |
| 97 | SubzeroTimingEnabled = NewValue; |
| 98 | } |
| 99 | |
Jim Stichnoth | 20b71f5 | 2015-06-24 15:52:24 -0700 | [diff] [blame] | 100 | bool getTimeEachFunction() const { |
| 101 | return BuildDefs::dump() && TimeEachFunction; |
| 102 | } |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 103 | void setTimeEachFunction(bool NewValue) { TimeEachFunction = NewValue; } |
| 104 | |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 105 | bool getUseSandboxing() const { return UseSandboxing; } |
| 106 | void setUseSandboxing(bool NewValue) { UseSandboxing = NewValue; } |
| 107 | |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame] | 108 | // Enum and integer accessors. |
| 109 | OptLevel getOptLevel() const { return Opt; } |
| 110 | void setOptLevel(OptLevel NewValue) { Opt = NewValue; } |
| 111 | |
Jim Stichnoth | d442e7e | 2015-02-12 14:01:48 -0800 | [diff] [blame] | 112 | FileType getOutFileType() const { return OutFileType; } |
| 113 | void setOutFileType(FileType NewValue) { OutFileType = NewValue; } |
| 114 | |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame] | 115 | int getMaxNopsPerInstruction() const { return RandomMaxNopsPerInstruction; } |
| 116 | void setMaxNopsPerInstruction(int NewValue) { |
| 117 | RandomMaxNopsPerInstruction = NewValue; |
| 118 | } |
| 119 | |
| 120 | int getNopProbabilityAsPercentage() const { |
| 121 | return RandomNopProbabilityAsPercentage; |
| 122 | } |
| 123 | void setNopProbabilityAsPercentage(int NewValue) { |
| 124 | RandomNopProbabilityAsPercentage = NewValue; |
| 125 | } |
| 126 | |
| 127 | TargetArch getTargetArch() const { return TArch; } |
| 128 | void setTargetArch(TargetArch NewValue) { TArch = NewValue; } |
| 129 | |
| 130 | TargetInstructionSet getTargetInstructionSet() const { return TInstrSet; } |
| 131 | void setTargetInstructionSet(TargetInstructionSet NewValue) { |
| 132 | TInstrSet = NewValue; |
| 133 | } |
| 134 | |
Mircea Trofin | 59c6f5a | 2015-04-06 16:06:47 -0700 | [diff] [blame] | 135 | VerboseMask getVerbose() const { |
Jim Stichnoth | 20b71f5 | 2015-06-24 15:52:24 -0700 | [diff] [blame] | 136 | return BuildDefs::dump() ? VMask : (VerboseMask)IceV_None; |
Mircea Trofin | 59c6f5a | 2015-04-06 16:06:47 -0700 | [diff] [blame] | 137 | } |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame] | 138 | void setVerbose(VerboseMask NewValue) { VMask = NewValue; } |
| 139 | |
Qining Lu | 253dc8a | 2015-06-22 10:10:23 -0700 | [diff] [blame] | 140 | void |
| 141 | setRandomizeAndPoolImmediatesOption(RandomizeAndPoolImmediatesEnum Option) { |
| 142 | RandomizeAndPoolImmediatesOption = Option; |
| 143 | } |
| 144 | |
| 145 | RandomizeAndPoolImmediatesEnum getRandomizeAndPoolImmediatesOption() const { |
| 146 | return RandomizeAndPoolImmediatesOption; |
| 147 | } |
| 148 | |
| 149 | void setRandomizeAndPoolImmediatesThreshold(uint32_t Threshold) { |
| 150 | RandomizeAndPoolImmediatesThreshold = Threshold; |
| 151 | } |
| 152 | uint32_t getRandomizeAndPoolImmediatesThreshold() const { |
| 153 | return RandomizeAndPoolImmediatesThreshold; |
| 154 | } |
| 155 | |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 156 | // IceString accessors. |
| 157 | |
| 158 | const IceString &getDefaultFunctionPrefix() const { |
| 159 | return DefaultFunctionPrefix; |
| 160 | } |
| 161 | void setDefaultFunctionPrefix(const IceString &NewValue) { |
| 162 | DefaultFunctionPrefix = NewValue; |
| 163 | } |
| 164 | |
| 165 | const IceString &getDefaultGlobalPrefix() const { |
| 166 | return DefaultGlobalPrefix; |
| 167 | } |
| 168 | void setDefaultGlobalPrefix(const IceString &NewValue) { |
| 169 | DefaultGlobalPrefix = NewValue; |
| 170 | } |
| 171 | |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame] | 172 | const IceString &getTestPrefix() const { return TestPrefix; } |
| 173 | void setTestPrefix(const IceString &NewValue) { TestPrefix = NewValue; } |
| 174 | |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 175 | const IceString &getTimingFocusOn() const { return TimingFocusOn; } |
| 176 | void setTimingFocusOn(const IceString &NewValue) { TimingFocusOn = NewValue; } |
| 177 | |
| 178 | const IceString &getTranslateOnly() const { return TranslateOnly; } |
| 179 | void setTranslateOnly(const IceString &NewValue) { TranslateOnly = NewValue; } |
| 180 | |
| 181 | const IceString &getVerboseFocusOn() const { return VerboseFocusOn; } |
| 182 | void setVerboseFocusOn(const IceString &NewValue) { |
| 183 | VerboseFocusOn = NewValue; |
| 184 | } |
| 185 | |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame] | 186 | // size_t and 64-bit accessors. |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 187 | |
| 188 | size_t getNumTranslationThreads() const { return NumTranslationThreads; } |
Jim Stichnoth | bbca754 | 2015-02-11 16:08:31 -0800 | [diff] [blame] | 189 | bool isSequential() const { return NumTranslationThreads == 0; } |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 190 | void setNumTranslationThreads(size_t NewValue) { |
| 191 | NumTranslationThreads = NewValue; |
| 192 | } |
| 193 | |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame] | 194 | uint64_t getRandomSeed() const { return RandomSeed; } |
| 195 | void setRandomSeed(size_t NewValue) { RandomSeed = NewValue; } |
| 196 | |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 197 | private: |
| 198 | bool AllowErrorRecovery; |
| 199 | bool AllowUninitializedGlobals; |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 200 | bool DataSections; |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 201 | bool DecorateAsm; |
| 202 | bool DisableInternal; |
| 203 | bool DisableIRGeneration; |
| 204 | bool DisableTranslation; |
| 205 | bool DumpStats; |
John Porto | f8b4cc8 | 2015-06-09 18:06:19 -0700 | [diff] [blame] | 206 | bool EnableBlockProfile; |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 207 | bool FunctionSections; |
| 208 | bool GenerateUnitTestMessages; |
| 209 | bool PhiEdgeSplit; |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame] | 210 | bool RandomNopInsertion; |
| 211 | bool RandomRegAlloc; |
Jan Voung | b2d5084 | 2015-05-12 09:53:50 -0700 | [diff] [blame] | 212 | bool SkipUnimplemented; |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 213 | bool SubzeroTimingEnabled; |
| 214 | bool TimeEachFunction; |
Jim Stichnoth | bfb03e5 | 2014-08-26 10:29:05 -0700 | [diff] [blame] | 215 | bool UseSandboxing; |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 216 | |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame] | 217 | OptLevel Opt; |
Jim Stichnoth | d442e7e | 2015-02-12 14:01:48 -0800 | [diff] [blame] | 218 | FileType OutFileType; |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame] | 219 | int RandomMaxNopsPerInstruction; |
| 220 | int RandomNopProbabilityAsPercentage; |
| 221 | TargetArch TArch; |
| 222 | TargetInstructionSet TInstrSet; |
| 223 | VerboseMask VMask; |
Jim Stichnoth | d442e7e | 2015-02-12 14:01:48 -0800 | [diff] [blame] | 224 | |
Karl Schimpf | 5ee234a | 2014-09-12 10:41:40 -0700 | [diff] [blame] | 225 | IceString DefaultFunctionPrefix; |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 226 | IceString DefaultGlobalPrefix; |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame] | 227 | IceString TestPrefix; |
Jim Stichnoth | 8363a06 | 2014-10-07 10:02:38 -0700 | [diff] [blame] | 228 | IceString TimingFocusOn; |
Jim Stichnoth | 088b2be | 2014-10-23 12:02:08 -0700 | [diff] [blame] | 229 | IceString TranslateOnly; |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 230 | IceString VerboseFocusOn; |
| 231 | |
Qining Lu | 253dc8a | 2015-06-22 10:10:23 -0700 | [diff] [blame] | 232 | // Immediates Randomization and Pooling options |
| 233 | RandomizeAndPoolImmediatesEnum RandomizeAndPoolImmediatesOption; |
| 234 | uint32_t RandomizeAndPoolImmediatesThreshold; |
| 235 | |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 236 | size_t NumTranslationThreads; // 0 means completely sequential |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame] | 237 | uint64_t RandomSeed; |
Karl Schimpf | 8d7abae | 2014-07-07 14:50:30 -0700 | [diff] [blame] | 238 | }; |
Jim Stichnoth | 989a703 | 2014-08-08 10:13:44 -0700 | [diff] [blame] | 239 | |
| 240 | } // end of namespace Ice |
Karl Schimpf | 8d7abae | 2014-07-07 14:50:30 -0700 | [diff] [blame] | 241 | |
| 242 | #endif // SUBZERO_SRC_ICECLFLAGS_H |