Move some flag-like props from GlobalContext and TargetLowering to ClFlags. Simplifies the GlobalContext constructor so that a future change may just set up the flags and the GlobalContext before calling into what is currently "main". Namely this change: https://codereview.chromium.org/997773002/ This also moves all uses of LLVM's CommandLine.h to a single file, so that in the future we may be able to simplify the flags parsing (especially for the minimal build). BUG= https://code.google.com/p/nativeclient/issues/detail?id=4091 BUG= https://code.google.com/p/nativeclient/issues/detail?id=4084 R=stichnot@chromium.org Review URL: https://codereview.chromium.org/1024203002
diff --git a/src/IceClFlags.h b/src/IceClFlags.h index 6fcbbbb..1133f8c 100644 --- a/src/IceClFlags.h +++ b/src/IceClFlags.h
@@ -14,7 +14,7 @@ #ifndef SUBZERO_SRC_ICECLFLAGS_H #define SUBZERO_SRC_ICECLFLAGS_H -#include "IceTypes.def" +#include "IceTypes.h" namespace Ice { @@ -30,15 +30,18 @@ DecorateAsm(false), DisableInternal(false), DisableIRGeneration(false), DisableTranslation(false), DumpStats(false), FunctionSections(false), GenerateUnitTestMessages(false), PhiEdgeSplit(false), + RandomNopInsertion(false), RandomRegAlloc(false), SubzeroTimingEnabled(false), TimeEachFunction(false), UseSandboxing(false), - // FileType field - OutFileType(FT_Iasm), + // Enum and integer fields + Opt(Opt_m1), OutFileType(FT_Iasm), RandomMaxNopsPerInstruction(0), + RandomNopProbabilityAsPercentage(0), TArch(TargetArch_NUM), + VMask(IceV_None), // IceString fields. - DefaultFunctionPrefix(""), DefaultGlobalPrefix(""), TimingFocusOn(""), - TranslateOnly(""), VerboseFocusOn(""), - // size_t fields. - NumTranslationThreads(0) {} + DefaultFunctionPrefix(""), DefaultGlobalPrefix(""), TestPrefix(""), + TimingFocusOn(""), TranslateOnly(""), VerboseFocusOn(""), + // size_t and 64-bit fields. + NumTranslationThreads(0), RandomSeed(0) {} // bool accessors. @@ -87,6 +90,12 @@ bool getPhiEdgeSplit() const { return PhiEdgeSplit; } void setPhiEdgeSplit(bool NewValue) { PhiEdgeSplit = NewValue; } + bool shouldDoNopInsertion() const { return RandomNopInsertion; } + void setShouldDoNopInsertion(bool NewValue) { RandomNopInsertion = NewValue; } + + bool shouldRandomizeRegAlloc() const { return RandomRegAlloc; } + void setShouldRandomizeRegAlloc(bool NewValue) { RandomRegAlloc = NewValue; } + bool getSubzeroTimingEnabled() const { return SubzeroTimingEnabled; } void setSubzeroTimingEnabled(bool NewValue) { SubzeroTimingEnabled = NewValue; @@ -98,10 +107,36 @@ bool getUseSandboxing() const { return UseSandboxing; } void setUseSandboxing(bool NewValue) { UseSandboxing = NewValue; } - // FileType accessor. + // Enum and integer accessors. + OptLevel getOptLevel() const { return Opt; } + void setOptLevel(OptLevel NewValue) { Opt = NewValue; } + FileType getOutFileType() const { return OutFileType; } void setOutFileType(FileType NewValue) { OutFileType = NewValue; } + int getMaxNopsPerInstruction() const { return RandomMaxNopsPerInstruction; } + void setMaxNopsPerInstruction(int NewValue) { + RandomMaxNopsPerInstruction = NewValue; + } + + int getNopProbabilityAsPercentage() const { + return RandomNopProbabilityAsPercentage; + } + void setNopProbabilityAsPercentage(int NewValue) { + RandomNopProbabilityAsPercentage = NewValue; + } + + TargetArch getTargetArch() const { return TArch; } + void setTargetArch(TargetArch NewValue) { TArch = NewValue; } + + TargetInstructionSet getTargetInstructionSet() const { return TInstrSet; } + void setTargetInstructionSet(TargetInstructionSet NewValue) { + TInstrSet = NewValue; + } + + VerboseMask getVerbose() const { return ALLOW_DUMP ? VMask : IceV_None; } + void setVerbose(VerboseMask NewValue) { VMask = NewValue; } + // IceString accessors. const IceString &getDefaultFunctionPrefix() const { @@ -118,6 +153,9 @@ DefaultGlobalPrefix = NewValue; } + const IceString &getTestPrefix() const { return TestPrefix; } + void setTestPrefix(const IceString &NewValue) { TestPrefix = NewValue; } + const IceString &getTimingFocusOn() const { return TimingFocusOn; } void setTimingFocusOn(const IceString &NewValue) { TimingFocusOn = NewValue; } @@ -129,7 +167,7 @@ VerboseFocusOn = NewValue; } - // size_t accessors. + // size_t and 64-bit accessors. size_t getNumTranslationThreads() const { return NumTranslationThreads; } bool isSequential() const { return NumTranslationThreads == 0; } @@ -137,6 +175,9 @@ NumTranslationThreads = NewValue; } + uint64_t getRandomSeed() const { return RandomSeed; } + void setRandomSeed(size_t NewValue) { RandomSeed = NewValue; } + private: bool AllowErrorRecovery; bool AllowUninitializedGlobals; @@ -149,19 +190,29 @@ bool FunctionSections; bool GenerateUnitTestMessages; bool PhiEdgeSplit; + bool RandomNopInsertion; + bool RandomRegAlloc; bool SubzeroTimingEnabled; bool TimeEachFunction; bool UseSandboxing; + OptLevel Opt; FileType OutFileType; + int RandomMaxNopsPerInstruction; + int RandomNopProbabilityAsPercentage; + TargetArch TArch; + TargetInstructionSet TInstrSet; + VerboseMask VMask; IceString DefaultFunctionPrefix; IceString DefaultGlobalPrefix; + IceString TestPrefix; IceString TimingFocusOn; IceString TranslateOnly; IceString VerboseFocusOn; size_t NumTranslationThreads; // 0 means completely sequential + uint64_t RandomSeed; }; } // end of namespace Ice