blob: c89e6959e62d9e30c2436b46f530c29486901bce [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 Schimpf187b3df2015-04-16 13:50:43 -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 Schimpf187b3df2015-04-16 13:50:43 -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
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 Voung1f47ad02015-03-20 15:01:26 -070083 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 Schimpfdf80eb82015-02-09 14:20:22 -080089 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 Schimpfdf80eb82015-02-09 14:20:22 -080097 bool getUseSandboxing() const { return UseSandboxing; }
98 void setUseSandboxing(bool NewValue) { UseSandboxing = NewValue; }
99
Jan Voung1f47ad02015-03-20 15:01:26 -0700100 // Enum and integer accessors.
101 OptLevel getOptLevel() const { return Opt; }
102 void setOptLevel(OptLevel NewValue) { Opt = NewValue; }
103
Jim Stichnothd442e7e2015-02-12 14:01:48 -0800104 FileType getOutFileType() const { return OutFileType; }
105 void setOutFileType(FileType NewValue) { OutFileType = NewValue; }
106
Jan Voung1f47ad02015-03-20 15:01:26 -0700107 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 Trofin59c6f5a2015-04-06 16:06:47 -0700127 VerboseMask getVerbose() const {
128 return ALLOW_DUMP ? VMask : (VerboseMask)IceV_None;
129 }
Jan Voung1f47ad02015-03-20 15:01:26 -0700130 void setVerbose(VerboseMask NewValue) { VMask = NewValue; }
131
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800132 // 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 Voung1f47ad02015-03-20 15:01:26 -0700148 const IceString &getTestPrefix() const { return TestPrefix; }
149 void setTestPrefix(const IceString &NewValue) { TestPrefix = NewValue; }
150
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800151 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 Voung1f47ad02015-03-20 15:01:26 -0700162 // size_t and 64-bit accessors.
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800163
164 size_t getNumTranslationThreads() const { return NumTranslationThreads; }
Jim Stichnothbbca7542015-02-11 16:08:31 -0800165 bool isSequential() const { return NumTranslationThreads == 0; }
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800166 void setNumTranslationThreads(size_t NewValue) {
167 NumTranslationThreads = NewValue;
168 }
169
Jan Voung1f47ad02015-03-20 15:01:26 -0700170 uint64_t getRandomSeed() const { return RandomSeed; }
171 void setRandomSeed(size_t NewValue) { RandomSeed = NewValue; }
172
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800173private:
174 bool AllowErrorRecovery;
175 bool AllowUninitializedGlobals;
Karl Schimpfe3f64d02014-10-07 10:38:22 -0700176 bool DataSections;
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800177 bool DecorateAsm;
178 bool DisableInternal;
179 bool DisableIRGeneration;
180 bool DisableTranslation;
181 bool DumpStats;
182 bool FunctionSections;
183 bool GenerateUnitTestMessages;
184 bool PhiEdgeSplit;
Jan Voung1f47ad02015-03-20 15:01:26 -0700185 bool RandomNopInsertion;
186 bool RandomRegAlloc;
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800187 bool SubzeroTimingEnabled;
188 bool TimeEachFunction;
Jim Stichnothbfb03e52014-08-26 10:29:05 -0700189 bool UseSandboxing;
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800190
Jan Voung1f47ad02015-03-20 15:01:26 -0700191 OptLevel Opt;
Jim Stichnothd442e7e2015-02-12 14:01:48 -0800192 FileType OutFileType;
Jan Voung1f47ad02015-03-20 15:01:26 -0700193 int RandomMaxNopsPerInstruction;
194 int RandomNopProbabilityAsPercentage;
195 TargetArch TArch;
196 TargetInstructionSet TInstrSet;
197 VerboseMask VMask;
Jim Stichnothd442e7e2015-02-12 14:01:48 -0800198
Karl Schimpf5ee234a2014-09-12 10:41:40 -0700199 IceString DefaultFunctionPrefix;
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800200 IceString DefaultGlobalPrefix;
Jan Voung1f47ad02015-03-20 15:01:26 -0700201 IceString TestPrefix;
Jim Stichnoth8363a062014-10-07 10:02:38 -0700202 IceString TimingFocusOn;
Jim Stichnoth088b2be2014-10-23 12:02:08 -0700203 IceString TranslateOnly;
Karl Schimpfdf80eb82015-02-09 14:20:22 -0800204 IceString VerboseFocusOn;
205
206 size_t NumTranslationThreads; // 0 means completely sequential
Jan Voung1f47ad02015-03-20 15:01:26 -0700207 uint64_t RandomSeed;
Karl Schimpf8d7abae2014-07-07 14:50:30 -0700208};
Jim Stichnoth989a7032014-08-08 10:13:44 -0700209
210} // end of namespace Ice
Karl Schimpf8d7abae2014-07-07 14:50:30 -0700211
212#endif // SUBZERO_SRC_ICECLFLAGS_H