blob: 1133f8ccc9eecc1ed63ee89589e6e6b2037ff17f [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 Voung1f47ad02015-03-20 15:01:26 -070017#include "IceTypes.h"
Karl Schimpf5ee234a2014-09-12 10:41:40 -070018
Karl Schimpf8d7abae2014-07-07 14:50:30 -070019namespace Ice {
20
21class ClFlags {
Karl Schimpfdf80eb82015-02-09 14:20:22 -080022 ClFlags(const ClFlags &) = delete;
23 ClFlags &operator=(const ClFlags &) = delete;
24
Karl Schimpf8d7abae2014-07-07 14:50:30 -070025public:
26 ClFlags()
Karl Schimpfdf80eb82015-02-09 14:20:22 -080027 : // bool fields.
28 AllowErrorRecovery(false),
29 AllowUninitializedGlobals(false), DataSections(false),
30 DecorateAsm(false), DisableInternal(false), DisableIRGeneration(false),
31 DisableTranslation(false), DumpStats(false), FunctionSections(false),
32 GenerateUnitTestMessages(false), PhiEdgeSplit(false),
Jan Voung1f47ad02015-03-20 15:01:26 -070033 RandomNopInsertion(false), RandomRegAlloc(false),
Jan Voungf644a4b2015-03-19 11:57:52 -070034 SubzeroTimingEnabled(false), TimeEachFunction(false),
35 UseSandboxing(false),
Jan Voung1f47ad02015-03-20 15:01:26 -070036 // Enum and integer fields
37 Opt(Opt_m1), OutFileType(FT_Iasm), RandomMaxNopsPerInstruction(0),
38 RandomNopProbabilityAsPercentage(0), TArch(TargetArch_NUM),
39 VMask(IceV_None),
Karl Schimpfdf80eb82015-02-09 14:20:22 -080040 // IceString fields.
Jan Voung1f47ad02015-03-20 15:01:26 -070041 DefaultFunctionPrefix(""), DefaultGlobalPrefix(""), TestPrefix(""),
42 TimingFocusOn(""), TranslateOnly(""), VerboseFocusOn(""),
43 // size_t and 64-bit fields.
44 NumTranslationThreads(0), RandomSeed(0) {}
Karl Schimpfdf80eb82015-02-09 14:20:22 -080045
46 // bool accessors.
47
48 bool getAllowErrorRecovery() const { return AllowErrorRecovery; }
49 void setAllowErrorRecovery(bool NewValue) { AllowErrorRecovery = NewValue; }
50
51 bool getAllowUninitializedGlobals() const {
52 return AllowUninitializedGlobals;
53 }
54 void setAllowUninitializedGlobals(bool NewValue) {
55 AllowUninitializedGlobals = NewValue;
56 }
57
58 bool getDataSections() const { return DataSections; }
59 void setDataSections(bool NewValue) { DataSections = NewValue; }
60
61 bool getDecorateAsm() const { return DecorateAsm; }
62 void setDecorateAsm(bool NewValue) { DecorateAsm = NewValue; }
63
64 bool getDisableInternal() const { return DisableInternal; }
65 void setDisableInternal(bool NewValue) { DisableInternal = NewValue; }
66
67 bool getDisableIRGeneration() const {
68 return ALLOW_DISABLE_IR_GEN && DisableIRGeneration;
69 }
70 void setDisableIRGeneration(bool NewValue) { DisableIRGeneration = NewValue; }
71
72 bool getDisableTranslation() const { return DisableTranslation; }
73 void setDisableTranslation(bool NewValue) { DisableTranslation = NewValue; }
74
75 bool getDumpStats() const { return ALLOW_DUMP && DumpStats; }
76 void setDumpStats(bool NewValue) { DumpStats = NewValue; }
77
78 bool getFunctionSections() const { return FunctionSections; }
79 void setFunctionSections(bool NewValue) { FunctionSections = NewValue; }
80
81 bool getGenerateUnitTestMessages() const {
82 // Note: If dump routines have been turned off, the error messages
83 // will not be readable. Hence, turn off.
84 return !ALLOW_DUMP || GenerateUnitTestMessages;
85 }
86 void setGenerateUnitTestMessages(bool NewValue) {
87 GenerateUnitTestMessages = NewValue;
88 }
89
90 bool getPhiEdgeSplit() const { return PhiEdgeSplit; }
91 void setPhiEdgeSplit(bool NewValue) { PhiEdgeSplit = NewValue; }
92
Jan Voung1f47ad02015-03-20 15:01:26 -070093 bool shouldDoNopInsertion() const { return RandomNopInsertion; }
94 void setShouldDoNopInsertion(bool NewValue) { RandomNopInsertion = NewValue; }
95
96 bool shouldRandomizeRegAlloc() const { return RandomRegAlloc; }
97 void setShouldRandomizeRegAlloc(bool NewValue) { RandomRegAlloc = NewValue; }
98
Karl Schimpfdf80eb82015-02-09 14:20:22 -080099 bool getSubzeroTimingEnabled() const { return SubzeroTimingEnabled; }
100 void setSubzeroTimingEnabled(bool NewValue) {
101 SubzeroTimingEnabled = NewValue;
102 }
103
104 bool getTimeEachFunction() const { return ALLOW_DUMP && TimeEachFunction; }
105 void setTimeEachFunction(bool NewValue) { TimeEachFunction = NewValue; }
106
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800107 bool getUseSandboxing() const { return UseSandboxing; }
108 void setUseSandboxing(bool NewValue) { UseSandboxing = NewValue; }
109
Jan Voung1f47ad02015-03-20 15:01:26 -0700110 // Enum and integer accessors.
111 OptLevel getOptLevel() const { return Opt; }
112 void setOptLevel(OptLevel NewValue) { Opt = NewValue; }
113
Jim Stichnothd442e7e2015-02-12 14:01:48 -0800114 FileType getOutFileType() const { return OutFileType; }
115 void setOutFileType(FileType NewValue) { OutFileType = NewValue; }
116
Jan Voung1f47ad02015-03-20 15:01:26 -0700117 int getMaxNopsPerInstruction() const { return RandomMaxNopsPerInstruction; }
118 void setMaxNopsPerInstruction(int NewValue) {
119 RandomMaxNopsPerInstruction = NewValue;
120 }
121
122 int getNopProbabilityAsPercentage() const {
123 return RandomNopProbabilityAsPercentage;
124 }
125 void setNopProbabilityAsPercentage(int NewValue) {
126 RandomNopProbabilityAsPercentage = NewValue;
127 }
128
129 TargetArch getTargetArch() const { return TArch; }
130 void setTargetArch(TargetArch NewValue) { TArch = NewValue; }
131
132 TargetInstructionSet getTargetInstructionSet() const { return TInstrSet; }
133 void setTargetInstructionSet(TargetInstructionSet NewValue) {
134 TInstrSet = NewValue;
135 }
136
137 VerboseMask getVerbose() const { return ALLOW_DUMP ? VMask : IceV_None; }
138 void setVerbose(VerboseMask NewValue) { VMask = NewValue; }
139
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800140 // IceString accessors.
141
142 const IceString &getDefaultFunctionPrefix() const {
143 return DefaultFunctionPrefix;
144 }
145 void setDefaultFunctionPrefix(const IceString &NewValue) {
146 DefaultFunctionPrefix = NewValue;
147 }
148
149 const IceString &getDefaultGlobalPrefix() const {
150 return DefaultGlobalPrefix;
151 }
152 void setDefaultGlobalPrefix(const IceString &NewValue) {
153 DefaultGlobalPrefix = NewValue;
154 }
155
Jan Voung1f47ad02015-03-20 15:01:26 -0700156 const IceString &getTestPrefix() const { return TestPrefix; }
157 void setTestPrefix(const IceString &NewValue) { TestPrefix = NewValue; }
158
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800159 const IceString &getTimingFocusOn() const { return TimingFocusOn; }
160 void setTimingFocusOn(const IceString &NewValue) { TimingFocusOn = NewValue; }
161
162 const IceString &getTranslateOnly() const { return TranslateOnly; }
163 void setTranslateOnly(const IceString &NewValue) { TranslateOnly = NewValue; }
164
165 const IceString &getVerboseFocusOn() const { return VerboseFocusOn; }
166 void setVerboseFocusOn(const IceString &NewValue) {
167 VerboseFocusOn = NewValue;
168 }
169
Jan Voung1f47ad02015-03-20 15:01:26 -0700170 // size_t and 64-bit accessors.
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800171
172 size_t getNumTranslationThreads() const { return NumTranslationThreads; }
Jim Stichnothbbca7542015-02-11 16:08:31 -0800173 bool isSequential() const { return NumTranslationThreads == 0; }
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800174 void setNumTranslationThreads(size_t NewValue) {
175 NumTranslationThreads = NewValue;
176 }
177
Jan Voung1f47ad02015-03-20 15:01:26 -0700178 uint64_t getRandomSeed() const { return RandomSeed; }
179 void setRandomSeed(size_t NewValue) { RandomSeed = NewValue; }
180
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800181private:
182 bool AllowErrorRecovery;
183 bool AllowUninitializedGlobals;
Karl Schimpfe3f64d02014-10-07 10:38:22 -0700184 bool DataSections;
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800185 bool DecorateAsm;
186 bool DisableInternal;
187 bool DisableIRGeneration;
188 bool DisableTranslation;
189 bool DumpStats;
190 bool FunctionSections;
191 bool GenerateUnitTestMessages;
192 bool PhiEdgeSplit;
Jan Voung1f47ad02015-03-20 15:01:26 -0700193 bool RandomNopInsertion;
194 bool RandomRegAlloc;
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