blob: 7df697303c5d6a5d77cae079e25f88a770743aaf [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 {
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
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.
77 return !ALLOW_DUMP || GenerateUnitTestMessages;
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 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
100 bool getTimeEachFunction() const { return ALLOW_DUMP && TimeEachFunction; }
101 void setTimeEachFunction(bool NewValue) { TimeEachFunction = NewValue; }
102
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800103 bool getUseSandboxing() const { return UseSandboxing; }
104 void setUseSandboxing(bool NewValue) { UseSandboxing = NewValue; }
105
Jan Voung1f47ad02015-03-20 15:01:26 -0700106 // Enum and integer accessors.
107 OptLevel getOptLevel() const { return Opt; }
108 void setOptLevel(OptLevel NewValue) { Opt = NewValue; }
109
Jim Stichnothd442e7e2015-02-12 14:01:48 -0800110 FileType getOutFileType() const { return OutFileType; }
111 void setOutFileType(FileType NewValue) { OutFileType = NewValue; }
112
Jan Voung1f47ad02015-03-20 15:01:26 -0700113 int getMaxNopsPerInstruction() const { return RandomMaxNopsPerInstruction; }
114 void setMaxNopsPerInstruction(int NewValue) {
115 RandomMaxNopsPerInstruction = NewValue;
116 }
117
118 int getNopProbabilityAsPercentage() const {
119 return RandomNopProbabilityAsPercentage;
120 }
121 void setNopProbabilityAsPercentage(int NewValue) {
122 RandomNopProbabilityAsPercentage = NewValue;
123 }
124
125 TargetArch getTargetArch() const { return TArch; }
126 void setTargetArch(TargetArch NewValue) { TArch = NewValue; }
127
128 TargetInstructionSet getTargetInstructionSet() const { return TInstrSet; }
129 void setTargetInstructionSet(TargetInstructionSet NewValue) {
130 TInstrSet = NewValue;
131 }
132
Mircea Trofin59c6f5a2015-04-06 16:06:47 -0700133 VerboseMask getVerbose() const {
134 return ALLOW_DUMP ? VMask : (VerboseMask)IceV_None;
135 }
Jan Voung1f47ad02015-03-20 15:01:26 -0700136 void setVerbose(VerboseMask NewValue) { VMask = NewValue; }
137
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800138 // IceString accessors.
139
140 const IceString &getDefaultFunctionPrefix() const {
141 return DefaultFunctionPrefix;
142 }
143 void setDefaultFunctionPrefix(const IceString &NewValue) {
144 DefaultFunctionPrefix = NewValue;
145 }
146
147 const IceString &getDefaultGlobalPrefix() const {
148 return DefaultGlobalPrefix;
149 }
150 void setDefaultGlobalPrefix(const IceString &NewValue) {
151 DefaultGlobalPrefix = NewValue;
152 }
153
Jan Voung1f47ad02015-03-20 15:01:26 -0700154 const IceString &getTestPrefix() const { return TestPrefix; }
155 void setTestPrefix(const IceString &NewValue) { TestPrefix = NewValue; }
156
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800157 const IceString &getTimingFocusOn() const { return TimingFocusOn; }
158 void setTimingFocusOn(const IceString &NewValue) { TimingFocusOn = NewValue; }
159
160 const IceString &getTranslateOnly() const { return TranslateOnly; }
161 void setTranslateOnly(const IceString &NewValue) { TranslateOnly = NewValue; }
162
163 const IceString &getVerboseFocusOn() const { return VerboseFocusOn; }
164 void setVerboseFocusOn(const IceString &NewValue) {
165 VerboseFocusOn = NewValue;
166 }
167
Jan Voung1f47ad02015-03-20 15:01:26 -0700168 // size_t and 64-bit accessors.
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800169
170 size_t getNumTranslationThreads() const { return NumTranslationThreads; }
Jim Stichnothbbca7542015-02-11 16:08:31 -0800171 bool isSequential() const { return NumTranslationThreads == 0; }
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800172 void setNumTranslationThreads(size_t NewValue) {
173 NumTranslationThreads = NewValue;
174 }
175
Jan Voung1f47ad02015-03-20 15:01:26 -0700176 uint64_t getRandomSeed() const { return RandomSeed; }
177 void setRandomSeed(size_t NewValue) { RandomSeed = NewValue; }
178
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800179private:
180 bool AllowErrorRecovery;
181 bool AllowUninitializedGlobals;
Karl Schimpfe3f64d02014-10-07 10:38:22 -0700182 bool DataSections;
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800183 bool DecorateAsm;
184 bool DisableInternal;
185 bool DisableIRGeneration;
186 bool DisableTranslation;
187 bool DumpStats;
John Portof8b4cc82015-06-09 18:06:19 -0700188 bool EnableBlockProfile;
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800189 bool FunctionSections;
190 bool GenerateUnitTestMessages;
191 bool PhiEdgeSplit;
Jan Voung1f47ad02015-03-20 15:01:26 -0700192 bool RandomNopInsertion;
193 bool RandomRegAlloc;
Jan Voungb2d50842015-05-12 09:53:50 -0700194 bool SkipUnimplemented;
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800195 bool SubzeroTimingEnabled;
196 bool TimeEachFunction;
Jim Stichnothbfb03e52014-08-26 10:29:05 -0700197 bool UseSandboxing;
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800198
Jan Voung1f47ad02015-03-20 15:01:26 -0700199 OptLevel Opt;
Jim Stichnothd442e7e2015-02-12 14:01:48 -0800200 FileType OutFileType;
Jan Voung1f47ad02015-03-20 15:01:26 -0700201 int RandomMaxNopsPerInstruction;
202 int RandomNopProbabilityAsPercentage;
203 TargetArch TArch;
204 TargetInstructionSet TInstrSet;
205 VerboseMask VMask;
Jim Stichnothd442e7e2015-02-12 14:01:48 -0800206
Karl Schimpf5ee234a2014-09-12 10:41:40 -0700207 IceString DefaultFunctionPrefix;
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800208 IceString DefaultGlobalPrefix;
Jan Voung1f47ad02015-03-20 15:01:26 -0700209 IceString TestPrefix;
Jim Stichnoth8363a062014-10-07 10:02:38 -0700210 IceString TimingFocusOn;
Jim Stichnoth088b2be2014-10-23 12:02:08 -0700211 IceString TranslateOnly;
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800212 IceString VerboseFocusOn;
213
214 size_t NumTranslationThreads; // 0 means completely sequential
Jan Voung1f47ad02015-03-20 15:01:26 -0700215 uint64_t RandomSeed;
Karl Schimpf8d7abae2014-07-07 14:50:30 -0700216};
Jim Stichnoth989a7032014-08-08 10:13:44 -0700217
218} // end of namespace Ice
Karl Schimpf8d7abae2014-07-07 14:50:30 -0700219
220#endif // SUBZERO_SRC_ICECLFLAGS_H