blob: 076200266b581fcc67132fe020222fb05df9d397 [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 Schimpf85f1ffe2015-04-16 15:11:07 -070029 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 Schimpfdf80eb82015-02-09 14:20:22 -080048
Jan Voung44c3a802015-03-27 16:29:08 -070049 static void parseFlags(int argc, char *argv[]);
50 static void getParsedClFlags(ClFlags &OutFlags);
51 static void getParsedClFlagsExtra(ClFlagsExtra &OutFlagsExtra);
52
Karl Schimpfdf80eb82015-02-09 14:20:22 -080053 // 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 Voung1f47ad02015-03-20 15:01:26 -0700100 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 Schimpfdf80eb82015-02-09 14:20:22 -0800106 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 Schimpfdf80eb82015-02-09 14:20:22 -0800114 bool getUseSandboxing() const { return UseSandboxing; }
115 void setUseSandboxing(bool NewValue) { UseSandboxing = NewValue; }
116
Jan Voung1f47ad02015-03-20 15:01:26 -0700117 // Enum and integer accessors.
118 OptLevel getOptLevel() const { return Opt; }
119 void setOptLevel(OptLevel NewValue) { Opt = NewValue; }
120
Jim Stichnothd442e7e2015-02-12 14:01:48 -0800121 FileType getOutFileType() const { return OutFileType; }
122 void setOutFileType(FileType NewValue) { OutFileType = NewValue; }
123
Jan Voung1f47ad02015-03-20 15:01:26 -0700124 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 Trofin59c6f5a2015-04-06 16:06:47 -0700144 VerboseMask getVerbose() const {
145 return ALLOW_DUMP ? VMask : (VerboseMask)IceV_None;
146 }
Jan Voung1f47ad02015-03-20 15:01:26 -0700147 void setVerbose(VerboseMask NewValue) { VMask = NewValue; }
148
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800149 // 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 Voung1f47ad02015-03-20 15:01:26 -0700165 const IceString &getTestPrefix() const { return TestPrefix; }
166 void setTestPrefix(const IceString &NewValue) { TestPrefix = NewValue; }
167
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800168 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 Voung1f47ad02015-03-20 15:01:26 -0700179 // size_t and 64-bit accessors.
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800180
181 size_t getNumTranslationThreads() const { return NumTranslationThreads; }
Jim Stichnothbbca7542015-02-11 16:08:31 -0800182 bool isSequential() const { return NumTranslationThreads == 0; }
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800183 void setNumTranslationThreads(size_t NewValue) {
184 NumTranslationThreads = NewValue;
185 }
186
Jan Voung1f47ad02015-03-20 15:01:26 -0700187 uint64_t getRandomSeed() const { return RandomSeed; }
188 void setRandomSeed(size_t NewValue) { RandomSeed = NewValue; }
189
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800190private:
191 bool AllowErrorRecovery;
192 bool AllowUninitializedGlobals;
Karl Schimpfe3f64d02014-10-07 10:38:22 -0700193 bool DataSections;
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800194 bool DecorateAsm;
195 bool DisableInternal;
196 bool DisableIRGeneration;
197 bool DisableTranslation;
198 bool DumpStats;
199 bool FunctionSections;
200 bool GenerateUnitTestMessages;
201 bool PhiEdgeSplit;
Jan Voung1f47ad02015-03-20 15:01:26 -0700202 bool RandomNopInsertion;
203 bool RandomRegAlloc;
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800204 bool SubzeroTimingEnabled;
205 bool TimeEachFunction;
Jim Stichnothbfb03e52014-08-26 10:29:05 -0700206 bool UseSandboxing;
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800207
Jan Voung1f47ad02015-03-20 15:01:26 -0700208 OptLevel Opt;
Jim Stichnothd442e7e2015-02-12 14:01:48 -0800209 FileType OutFileType;
Jan Voung1f47ad02015-03-20 15:01:26 -0700210 int RandomMaxNopsPerInstruction;
211 int RandomNopProbabilityAsPercentage;
212 TargetArch TArch;
213 TargetInstructionSet TInstrSet;
214 VerboseMask VMask;
Jim Stichnothd442e7e2015-02-12 14:01:48 -0800215
Karl Schimpf5ee234a2014-09-12 10:41:40 -0700216 IceString DefaultFunctionPrefix;
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800217 IceString DefaultGlobalPrefix;
Jan Voung1f47ad02015-03-20 15:01:26 -0700218 IceString TestPrefix;
Jim Stichnoth8363a062014-10-07 10:02:38 -0700219 IceString TimingFocusOn;
Jim Stichnoth088b2be2014-10-23 12:02:08 -0700220 IceString TranslateOnly;
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800221 IceString VerboseFocusOn;
222
223 size_t NumTranslationThreads; // 0 means completely sequential
Jan Voung1f47ad02015-03-20 15:01:26 -0700224 uint64_t RandomSeed;
Karl Schimpf8d7abae2014-07-07 14:50:30 -0700225};
Jim Stichnoth989a7032014-08-08 10:13:44 -0700226
227} // end of namespace Ice
Karl Schimpf8d7abae2014-07-07 14:50:30 -0700228
229#endif // SUBZERO_SRC_ICECLFLAGS_H