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