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