blob: b677e1c1b746936b426f8625dab10290fdfa5fa3 [file] [log] [blame]
Karl Schimpf8d7abae2014-07-07 14:50:30 -07001//===- 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 Voung44c3a802015-03-27 16:29:08 -070017#include "IceDefs.h"
Jan Voung1f47ad02015-03-20 15:01:26 -070018#include "IceTypes.h"
Karl Schimpf5ee234a2014-09-12 10:41:40 -070019
Karl Schimpf8d7abae2014-07-07 14:50:30 -070020namespace Ice {
21
Jan Voung44c3a802015-03-27 16:29:08 -070022class ClFlagsExtra;
23
Karl Schimpf8d7abae2014-07-07 14:50:30 -070024class ClFlags {
Karl Schimpfdf80eb82015-02-09 14:20:22 -080025 ClFlags(const ClFlags &) = delete;
26 ClFlags &operator=(const ClFlags &) = delete;
27
Karl Schimpf8d7abae2014-07-07 14:50:30 -070028public:
Karl Schimpfd8b32892015-04-16 15:47:25 -070029 ClFlags() { resetClFlags(*this); }
Karl Schimpfdf80eb82015-02-09 14:20:22 -080030
Jan Voung44c3a802015-03-27 16:29:08 -070031 static void parseFlags(int argc, char *argv[]);
Karl Schimpfd8b32892015-04-16 15:47:25 -070032 static void resetClFlags(ClFlags &OutFlags);
Jan Voung44c3a802015-03-27 16:29:08 -070033 static void getParsedClFlags(ClFlags &OutFlags);
34 static void getParsedClFlagsExtra(ClFlagsExtra &OutFlagsExtra);
35
Karl Schimpfdf80eb82015-02-09 14:20:22 -080036 // 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 Stichnoth20b71f52015-06-24 15:52:24 -070058 return BuildDefs::disableIrGen() && DisableIRGeneration;
Karl Schimpfdf80eb82015-02-09 14:20:22 -080059 }
60 void setDisableIRGeneration(bool NewValue) { DisableIRGeneration = NewValue; }
61
62 bool getDisableTranslation() const { return DisableTranslation; }
63 void setDisableTranslation(bool NewValue) { DisableTranslation = NewValue; }
64
Jim Stichnoth20b71f52015-06-24 15:52:24 -070065 bool getDumpStats() const { return BuildDefs::dump() && DumpStats; }
Karl Schimpfdf80eb82015-02-09 14:20:22 -080066 void setDumpStats(bool NewValue) { DumpStats = NewValue; }
67
John Portof8b4cc82015-06-09 18:06:19 -070068 bool getEnableBlockProfile() const { return EnableBlockProfile; }
69 void setEnableBlockProfile(bool NewValue) { EnableBlockProfile = NewValue; }
70
Karl Schimpfdf80eb82015-02-09 14:20:22 -080071 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 Stichnoth20b71f52015-06-24 15:52:24 -070077 return !BuildDefs::dump() || GenerateUnitTestMessages;
Karl Schimpfdf80eb82015-02-09 14:20:22 -080078 }
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 Voung1f47ad02015-03-20 15:01:26 -070086 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 Voungb2d50842015-05-12 09:53:50 -070092 bool getSkipUnimplemented() const { return SkipUnimplemented; }
93 void setSkipUnimplemented(bool NewValue) { SkipUnimplemented = NewValue; }
94
Karl Schimpfdf80eb82015-02-09 14:20:22 -080095 bool getSubzeroTimingEnabled() const { return SubzeroTimingEnabled; }
96 void setSubzeroTimingEnabled(bool NewValue) {
97 SubzeroTimingEnabled = NewValue;
98 }
99
Jim Stichnoth20b71f52015-06-24 15:52:24 -0700100 bool getTimeEachFunction() const {
101 return BuildDefs::dump() && TimeEachFunction;
102 }
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800103 void setTimeEachFunction(bool NewValue) { TimeEachFunction = NewValue; }
104
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800105 bool getUseSandboxing() const { return UseSandboxing; }
106 void setUseSandboxing(bool NewValue) { UseSandboxing = NewValue; }
107
Jan Voung1f47ad02015-03-20 15:01:26 -0700108 // Enum and integer accessors.
109 OptLevel getOptLevel() const { return Opt; }
110 void setOptLevel(OptLevel NewValue) { Opt = NewValue; }
111
Jim Stichnothd442e7e2015-02-12 14:01:48 -0800112 FileType getOutFileType() const { return OutFileType; }
113 void setOutFileType(FileType NewValue) { OutFileType = NewValue; }
114
Jan Voung1f47ad02015-03-20 15:01:26 -0700115 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 Trofin59c6f5a2015-04-06 16:06:47 -0700135 VerboseMask getVerbose() const {
Jim Stichnoth20b71f52015-06-24 15:52:24 -0700136 return BuildDefs::dump() ? VMask : (VerboseMask)IceV_None;
Mircea Trofin59c6f5a2015-04-06 16:06:47 -0700137 }
Jan Voung1f47ad02015-03-20 15:01:26 -0700138 void setVerbose(VerboseMask NewValue) { VMask = NewValue; }
139
Qining Lu253dc8a2015-06-22 10:10:23 -0700140 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 Schimpfdf80eb82015-02-09 14:20:22 -0800156 // 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 Voung1f47ad02015-03-20 15:01:26 -0700172 const IceString &getTestPrefix() const { return TestPrefix; }
173 void setTestPrefix(const IceString &NewValue) { TestPrefix = NewValue; }
174
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800175 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 Voung1f47ad02015-03-20 15:01:26 -0700186 // size_t and 64-bit accessors.
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800187
188 size_t getNumTranslationThreads() const { return NumTranslationThreads; }
Jim Stichnothbbca7542015-02-11 16:08:31 -0800189 bool isSequential() const { return NumTranslationThreads == 0; }
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800190 void setNumTranslationThreads(size_t NewValue) {
191 NumTranslationThreads = NewValue;
192 }
193
Jan Voung1f47ad02015-03-20 15:01:26 -0700194 uint64_t getRandomSeed() const { return RandomSeed; }
195 void setRandomSeed(size_t NewValue) { RandomSeed = NewValue; }
196
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800197private:
198 bool AllowErrorRecovery;
199 bool AllowUninitializedGlobals;
Karl Schimpfe3f64d02014-10-07 10:38:22 -0700200 bool DataSections;
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800201 bool DecorateAsm;
202 bool DisableInternal;
203 bool DisableIRGeneration;
204 bool DisableTranslation;
205 bool DumpStats;
John Portof8b4cc82015-06-09 18:06:19 -0700206 bool EnableBlockProfile;
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800207 bool FunctionSections;
208 bool GenerateUnitTestMessages;
209 bool PhiEdgeSplit;
Jan Voung1f47ad02015-03-20 15:01:26 -0700210 bool RandomNopInsertion;
211 bool RandomRegAlloc;
Jan Voungb2d50842015-05-12 09:53:50 -0700212 bool SkipUnimplemented;
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800213 bool SubzeroTimingEnabled;
214 bool TimeEachFunction;
Jim Stichnothbfb03e52014-08-26 10:29:05 -0700215 bool UseSandboxing;
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800216
Jan Voung1f47ad02015-03-20 15:01:26 -0700217 OptLevel Opt;
Jim Stichnothd442e7e2015-02-12 14:01:48 -0800218 FileType OutFileType;
Jan Voung1f47ad02015-03-20 15:01:26 -0700219 int RandomMaxNopsPerInstruction;
220 int RandomNopProbabilityAsPercentage;
221 TargetArch TArch;
222 TargetInstructionSet TInstrSet;
223 VerboseMask VMask;
Jim Stichnothd442e7e2015-02-12 14:01:48 -0800224
Karl Schimpf5ee234a2014-09-12 10:41:40 -0700225 IceString DefaultFunctionPrefix;
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800226 IceString DefaultGlobalPrefix;
Jan Voung1f47ad02015-03-20 15:01:26 -0700227 IceString TestPrefix;
Jim Stichnoth8363a062014-10-07 10:02:38 -0700228 IceString TimingFocusOn;
Jim Stichnoth088b2be2014-10-23 12:02:08 -0700229 IceString TranslateOnly;
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800230 IceString VerboseFocusOn;
231
Qining Lu253dc8a2015-06-22 10:10:23 -0700232 // Immediates Randomization and Pooling options
233 RandomizeAndPoolImmediatesEnum RandomizeAndPoolImmediatesOption;
234 uint32_t RandomizeAndPoolImmediatesThreshold;
235
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800236 size_t NumTranslationThreads; // 0 means completely sequential
Jan Voung1f47ad02015-03-20 15:01:26 -0700237 uint64_t RandomSeed;
Karl Schimpf8d7abae2014-07-07 14:50:30 -0700238};
Jim Stichnoth989a7032014-08-08 10:13:44 -0700239
240} // end of namespace Ice
Karl Schimpf8d7abae2014-07-07 14:50:30 -0700241
242#endif // SUBZERO_SRC_ICECLFLAGS_H