Adds accessor methods to class ClFlags.
Allows one to define explicit overrides in get accessors, based on
compilation features. To show usage, modified SubConstantCalls to
never be enabled if building a minimal llvm2ice.
BUG=None
R=stichnot@chromium.org
Review URL: https://codereview.chromium.org/905463003
diff --git a/src/IceCfg.cpp b/src/IceCfg.cpp
index b284d06..6526da2 100644
--- a/src/IceCfg.cpp
+++ b/src/IceCfg.cpp
@@ -81,14 +81,15 @@
// TimeEachFunction is enabled.
std::unique_ptr<TimerMarker> FunctionTimer;
if (ALLOW_DUMP) {
- const IceString &TimingFocusOn = getContext()->getFlags().TimingFocusOn;
+ const IceString &TimingFocusOn =
+ getContext()->getFlags().getTimingFocusOn();
const IceString &Name = getFunctionName();
if (TimingFocusOn == "*" || TimingFocusOn == Name) {
setFocusedTiming();
getContext()->resetTimer(GlobalContext::TSK_Default);
getContext()->setTimerName(GlobalContext::TSK_Default, Name);
}
- if (getContext()->getFlags().TimeEachFunction)
+ if (getContext()->getFlags().getTimeEachFunction())
FunctionTimer.reset(new TimerMarker(
getContext()->getTimerID(GlobalContext::TSK_Funcs, Name),
getContext(), GlobalContext::TSK_Funcs));
@@ -399,7 +400,7 @@
// such, we disable this pass when DecorateAsm is specified. This
// may make the resulting code look more branchy, but it should have
// no effect on the register assignments.
- if (Ctx->getFlags().DecorateAsm)
+ if (Ctx->getFlags().getDecorateAsm())
return;
for (CfgNode *Node : Nodes) {
Node->contractIfEmpty();
@@ -421,9 +422,9 @@
// Note: Still used by emit IAS.
Ostream &Str = Ctx->getStrEmit();
Str << "\t.text\n";
- if (Ctx->getFlags().FunctionSections)
+ if (Ctx->getFlags().getFunctionSections())
Str << "\t.section\t.text." << MangledName << ",\"ax\",@progbits\n";
- if (!getInternal() || Ctx->getFlags().DisableInternal) {
+ if (!getInternal() || Ctx->getFlags().getDisableInternal()) {
Str << "\t.globl\t" << MangledName << "\n";
Str << "\t.type\t" << MangledName << ",@function\n";
}
@@ -439,7 +440,7 @@
if (!ALLOW_DUMP)
return;
TimerMarker T(TimerStack::TT_emit, this);
- if (Ctx->getFlags().DecorateAsm) {
+ if (Ctx->getFlags().getDecorateAsm()) {
renumberInstructions();
getVMetadata()->init(VMK_Uses);
liveness(Liveness_Basic);
@@ -456,7 +457,7 @@
void Cfg::emitIAS() {
TimerMarker T(TimerStack::TT_emit, this);
- assert(!Ctx->getFlags().DecorateAsm);
+ assert(!Ctx->getFlags().getDecorateAsm());
IceString MangledName = getContext()->mangleName(getFunctionName());
// The emitIAS() routines emit into the internal assembler buffer,
// so there's no need to lock the streams until we're ready to call
@@ -464,7 +465,7 @@
for (CfgNode *Node : Nodes)
Node->emitIAS(this);
// Now write the function to the file and track.
- if (Ctx->getFlags().UseELFWriter) {
+ if (Ctx->getFlags().getUseELFWriter()) {
getAssembler<Assembler>()->alignFunction();
Ctx->getObjectWriter()->writeFunctionCode(MangledName, getInternal(),
getAssembler<Assembler>());
@@ -489,7 +490,7 @@
// Print function name+args
if (isVerbose(IceV_Instructions)) {
Str << "define ";
- if (getInternal() && !Ctx->getFlags().DisableInternal)
+ if (getInternal() && !Ctx->getFlags().getDisableInternal())
Str << "internal ";
Str << ReturnType << " @" << Ctx->mangleName(getFunctionName()) << "(";
for (SizeT i = 0; i < Args.size(); ++i) {
diff --git a/src/IceCfgNode.cpp b/src/IceCfgNode.cpp
index 8fb06b8..077866b 100644
--- a/src/IceCfgNode.cpp
+++ b/src/IceCfgNode.cpp
@@ -859,7 +859,8 @@
Func->setCurrentNode(this);
Ostream &Str = Func->getContext()->getStrEmit();
Liveness *Liveness = Func->getLiveness();
- bool DecorateAsm = Liveness && Func->getContext()->getFlags().DecorateAsm;
+ bool DecorateAsm =
+ Liveness && Func->getContext()->getFlags().getDecorateAsm();
Str << getAsmName() << ":\n";
std::vector<SizeT> LiveRegCount(Func->getTarget()->getNumRegisters());
if (DecorateAsm)
diff --git a/src/IceClFlags.h b/src/IceClFlags.h
index c5b7d4b..774a40f 100644
--- a/src/IceClFlags.h
+++ b/src/IceClFlags.h
@@ -19,41 +19,157 @@
namespace Ice {
class ClFlags {
+ ClFlags(const ClFlags &) = delete;
+ ClFlags &operator=(const ClFlags &) = delete;
+
public:
ClFlags()
- : DisableInternal(false), SubzeroTimingEnabled(false),
- DisableTranslation(false), FunctionSections(false), DataSections(false),
- UseELFWriter(false), UseIntegratedAssembler(false),
- UseSandboxing(false), PhiEdgeSplit(false), DecorateAsm(false),
- DumpStats(false), AllowUninitializedGlobals(false),
- TimeEachFunction(false), DisableIRGeneration(false),
- AllowErrorRecovery(false), StubConstantCalls(false),
- GenerateUnitTestMessages(false), NumTranslationThreads(0),
- DefaultGlobalPrefix(""), DefaultFunctionPrefix(""), TimingFocusOn(""),
- VerboseFocusOn(""), TranslateOnly("") {}
- bool DisableInternal;
- bool SubzeroTimingEnabled;
- bool DisableTranslation;
- bool FunctionSections;
+ : // bool fields.
+ AllowErrorRecovery(false),
+ AllowUninitializedGlobals(false), DataSections(false),
+ DecorateAsm(false), DisableInternal(false), DisableIRGeneration(false),
+ DisableTranslation(false), DumpStats(false), FunctionSections(false),
+ GenerateUnitTestMessages(false), PhiEdgeSplit(false),
+ StubConstantCalls(false), SubzeroTimingEnabled(false),
+ TimeEachFunction(false), UseELFWriter(false),
+ UseIntegratedAssembler(false), UseSandboxing(false),
+ // IceString fields.
+ DefaultFunctionPrefix(""), DefaultGlobalPrefix(""), TimingFocusOn(""),
+ TranslateOnly(""), VerboseFocusOn(""),
+ // size_t fields.
+ NumTranslationThreads(0) {}
+
+ // bool accessors.
+
+ bool getAllowErrorRecovery() const { return AllowErrorRecovery; }
+ void setAllowErrorRecovery(bool NewValue) { AllowErrorRecovery = NewValue; }
+
+ bool getAllowUninitializedGlobals() const {
+ return AllowUninitializedGlobals;
+ }
+ void setAllowUninitializedGlobals(bool NewValue) {
+ AllowUninitializedGlobals = NewValue;
+ }
+
+ bool getDataSections() const { return DataSections; }
+ void setDataSections(bool NewValue) { DataSections = NewValue; }
+
+ bool getDecorateAsm() const { return DecorateAsm; }
+ void setDecorateAsm(bool NewValue) { DecorateAsm = NewValue; }
+
+ bool getDisableInternal() const { return DisableInternal; }
+ void setDisableInternal(bool NewValue) { DisableInternal = NewValue; }
+
+ bool getDisableIRGeneration() const {
+ return ALLOW_DISABLE_IR_GEN && DisableIRGeneration;
+ }
+ void setDisableIRGeneration(bool NewValue) { DisableIRGeneration = NewValue; }
+
+ bool getDisableTranslation() const { return DisableTranslation; }
+ void setDisableTranslation(bool NewValue) { DisableTranslation = NewValue; }
+
+ bool getDumpStats() const { return ALLOW_DUMP && DumpStats; }
+ void setDumpStats(bool NewValue) { DumpStats = NewValue; }
+
+ bool getFunctionSections() const { return FunctionSections; }
+ void setFunctionSections(bool NewValue) { FunctionSections = NewValue; }
+
+ bool getGenerateUnitTestMessages() const {
+ // Note: If dump routines have been turned off, the error messages
+ // will not be readable. Hence, turn off.
+ return !ALLOW_DUMP || GenerateUnitTestMessages;
+ }
+ void setGenerateUnitTestMessages(bool NewValue) {
+ GenerateUnitTestMessages = NewValue;
+ }
+
+ bool getPhiEdgeSplit() const { return PhiEdgeSplit; }
+ void setPhiEdgeSplit(bool NewValue) { PhiEdgeSplit = NewValue; }
+
+ bool getStubConstantCalls() const {
+ return !ALLOW_MINIMAL_BUILD && StubConstantCalls;
+ }
+ void setStubConstantCalls(bool NewValue) { StubConstantCalls = NewValue; }
+
+ bool getSubzeroTimingEnabled() const { return SubzeroTimingEnabled; }
+ void setSubzeroTimingEnabled(bool NewValue) {
+ SubzeroTimingEnabled = NewValue;
+ }
+
+ bool getTimeEachFunction() const { return ALLOW_DUMP && TimeEachFunction; }
+ void setTimeEachFunction(bool NewValue) { TimeEachFunction = NewValue; }
+
+ bool getUseELFWriter() const { return UseELFWriter; }
+ void setUseELFWriter(bool NewValue) { UseELFWriter = NewValue; }
+
+ bool getUseIntegratedAssembler() const { return UseIntegratedAssembler; }
+ void setUseIntegratedAssembler(bool NewValue) {
+ UseIntegratedAssembler = NewValue;
+ }
+
+ bool getUseSandboxing() const { return UseSandboxing; }
+ void setUseSandboxing(bool NewValue) { UseSandboxing = NewValue; }
+
+ // IceString accessors.
+
+ const IceString &getDefaultFunctionPrefix() const {
+ return DefaultFunctionPrefix;
+ }
+ void setDefaultFunctionPrefix(const IceString &NewValue) {
+ DefaultFunctionPrefix = NewValue;
+ }
+
+ const IceString &getDefaultGlobalPrefix() const {
+ return DefaultGlobalPrefix;
+ }
+ void setDefaultGlobalPrefix(const IceString &NewValue) {
+ DefaultGlobalPrefix = NewValue;
+ }
+
+ const IceString &getTimingFocusOn() const { return TimingFocusOn; }
+ void setTimingFocusOn(const IceString &NewValue) { TimingFocusOn = NewValue; }
+
+ const IceString &getTranslateOnly() const { return TranslateOnly; }
+ void setTranslateOnly(const IceString &NewValue) { TranslateOnly = NewValue; }
+
+ const IceString &getVerboseFocusOn() const { return VerboseFocusOn; }
+ void setVerboseFocusOn(const IceString &NewValue) {
+ VerboseFocusOn = NewValue;
+ }
+
+ // size_t accessors.
+
+ size_t getNumTranslationThreads() const { return NumTranslationThreads; }
+ void setNumTranslationThreads(size_t NewValue) {
+ NumTranslationThreads = NewValue;
+ }
+
+private:
+ bool AllowErrorRecovery;
+ bool AllowUninitializedGlobals;
bool DataSections;
+ bool DecorateAsm;
+ bool DisableInternal;
+ bool DisableIRGeneration;
+ bool DisableTranslation;
+ bool DumpStats;
+ bool FunctionSections;
+ bool GenerateUnitTestMessages;
+ bool PhiEdgeSplit;
+ bool StubConstantCalls;
+ bool SubzeroTimingEnabled;
+ bool TimeEachFunction;
bool UseELFWriter;
bool UseIntegratedAssembler;
bool UseSandboxing;
- bool PhiEdgeSplit;
- bool DecorateAsm;
- bool DumpStats;
- bool AllowUninitializedGlobals;
- bool TimeEachFunction;
- bool DisableIRGeneration;
- bool AllowErrorRecovery;
- bool StubConstantCalls;
- bool GenerateUnitTestMessages;
- size_t NumTranslationThreads; // 0 means completely sequential
- IceString DefaultGlobalPrefix;
+
IceString DefaultFunctionPrefix;
+ IceString DefaultGlobalPrefix;
IceString TimingFocusOn;
- IceString VerboseFocusOn;
IceString TranslateOnly;
+ IceString VerboseFocusOn;
+
+ size_t NumTranslationThreads; // 0 means completely sequential
};
} // end of namespace Ice
diff --git a/src/IceConverter.cpp b/src/IceConverter.cpp
index 5316db6..7cc8d5a 100644
--- a/src/IceConverter.cpp
+++ b/src/IceConverter.cpp
@@ -716,7 +716,7 @@
}
if (!GV->hasInitializer()) {
- if (Ctx->getFlags().AllowUninitializedGlobals)
+ if (Ctx->getFlags().getAllowUninitializedGlobals())
continue;
else {
std::string Buffer;
@@ -801,7 +801,7 @@
namespace Ice {
void Converter::nameUnnamedGlobalVariables(Module *Mod) {
- const IceString &GlobalPrefix = Flags.DefaultGlobalPrefix;
+ const IceString &GlobalPrefix = Flags.getDefaultGlobalPrefix();
if (GlobalPrefix.empty())
return;
uint32_t NameIndex = 0;
@@ -816,7 +816,7 @@
}
void Converter::nameUnnamedFunctions(Module *Mod) {
- const IceString &FunctionPrefix = Flags.DefaultFunctionPrefix;
+ const IceString &FunctionPrefix = Flags.getDefaultFunctionPrefix();
if (FunctionPrefix.empty())
return;
uint32_t NameIndex = 0;
@@ -895,8 +895,7 @@
continue;
TimerIdT TimerID = 0;
- const bool TimeThisFunction =
- ALLOW_DUMP && Ctx->getFlags().TimeEachFunction;
+ const bool TimeThisFunction = Ctx->getFlags().getTimeEachFunction();
if (TimeThisFunction) {
TimerID = Ctx->getTimerID(StackID, I.getName());
Ctx->pushTimer(TimerID, StackID);
diff --git a/src/IceELFObjectWriter.cpp b/src/IceELFObjectWriter.cpp
index bd0d089..6fbf1df 100644
--- a/src/IceELFObjectWriter.cpp
+++ b/src/IceELFObjectWriter.cpp
@@ -296,7 +296,8 @@
VariableDeclarationList VarsBySection[ELFObjectWriter::NumSectionTypes];
for (auto &SectionList : VarsBySection)
SectionList.reserve(Vars.size());
- partitionGlobalsBySection(Vars, VarsBySection, Ctx.getFlags().TranslateOnly);
+ partitionGlobalsBySection(Vars, VarsBySection,
+ Ctx.getFlags().getTranslateOnly());
bool IsELF64 = isELF64(Ctx.getTargetArch());
size_t I = 0;
for (auto &SectionList : VarsBySection) {
@@ -371,7 +372,7 @@
Elf64_Xword Align = Var->getAlignment();
Section->padToAlignment(Str, Align);
SizeT SymbolSize = Var->getNumBytes();
- bool IsExternal = Var->isExternal() || Ctx.getFlags().DisableInternal;
+ bool IsExternal = Var->isExternal() || Ctx.getFlags().getDisableInternal();
const uint8_t SymbolBinding = IsExternal ? STB_GLOBAL : STB_LOCAL;
IceString MangledName = Var->mangleName(&Ctx);
SymTab->createDefinedSym(MangledName, SymbolType, SymbolBinding, Section,
diff --git a/src/IceGlobalContext.cpp b/src/IceGlobalContext.cpp
index 4324f97..3ca8524 100644
--- a/src/IceGlobalContext.cpp
+++ b/src/IceGlobalContext.cpp
@@ -134,8 +134,8 @@
: ConstPool(new ConstantPool()), ErrorStatus(), StrDump(OsDump),
StrEmit(OsEmit), VMask(Mask), Arch(Arch), Opt(Opt),
TestPrefix(TestPrefix), Flags(Flags), RNG(""), ObjectWriter(),
- CfgQ(/*MaxSize=*/Flags.NumTranslationThreads,
- /*Sequential=*/(Flags.NumTranslationThreads == 0)) {
+ CfgQ(/*MaxSize=*/Flags.getNumTranslationThreads(),
+ /*Sequential=*/(Flags.getNumTranslationThreads() == 0)) {
// Make sure thread_local fields are properly initialized before any
// accesses are made. Do this here instead of at the start of
// main() so that all clients (e.g. unit tests) can benefit for
@@ -156,7 +156,7 @@
newTimerStackID("Per-function summary");
}
Timers.initInto(MyTLS->Timers);
- if (Flags.UseELFWriter) {
+ if (Flags.getUseELFWriter()) {
ObjectWriter.reset(new ELFObjectWriter(*this, *ELFStr));
}
}
@@ -169,14 +169,16 @@
resetStats();
// Set verbose level to none if the current function does NOT
// match the -verbose-focus command-line option.
- if (!matchSymbolName(Func->getFunctionName(), getFlags().VerboseFocusOn))
+ if (!matchSymbolName(Func->getFunctionName(),
+ getFlags().getVerboseFocusOn()))
Func->setVerbose(IceV_None);
// Disable translation if -notranslate is specified, or if the
// current function matches the -translate-only option. If
// translation is disabled, just dump the high-level IR and
// continue.
- if (getFlags().DisableTranslation ||
- !matchSymbolName(Func->getFunctionName(), getFlags().TranslateOnly)) {
+ if (getFlags().getDisableTranslation() ||
+ !matchSymbolName(Func->getFunctionName(),
+ getFlags().getTranslateOnly())) {
Func->dump();
} else {
Func->translate();
@@ -185,7 +187,7 @@
OstreamLocker L(this);
getStrDump() << "ICE translation error: " << Func->getError() << "\n";
} else {
- if (getFlags().UseIntegratedAssembler)
+ if (getFlags().getUseIntegratedAssembler())
Func->emitIAS();
else
Func->emit();
@@ -562,7 +564,7 @@
}
void GlobalContext::dumpStats(const IceString &Name, bool Final) {
- if (!ALLOW_DUMP || !getFlags().DumpStats)
+ if (!getFlags().getDumpStats())
return;
OstreamLocker OL(this);
if (Final) {
@@ -584,10 +586,10 @@
void TimerMarker::push() {
switch (StackID) {
case GlobalContext::TSK_Default:
- Active = Ctx->getFlags().SubzeroTimingEnabled;
+ Active = Ctx->getFlags().getSubzeroTimingEnabled();
break;
case GlobalContext::TSK_Funcs:
- Active = Ctx->getFlags().TimeEachFunction;
+ Active = Ctx->getFlags().getTimeEachFunction();
break;
default:
break;
@@ -598,7 +600,8 @@
void TimerMarker::pushCfg(const Cfg *Func) {
Ctx = Func->getContext();
- Active = Func->getFocusedTiming() || Ctx->getFlags().SubzeroTimingEnabled;
+ Active =
+ Func->getFocusedTiming() || Ctx->getFlags().getSubzeroTimingEnabled();
if (Active)
Ctx->pushTimer(ID, StackID);
}
diff --git a/src/IceGlobalContext.h b/src/IceGlobalContext.h
index e3e0810..280bbd0 100644
--- a/src/IceGlobalContext.h
+++ b/src/IceGlobalContext.h
@@ -202,7 +202,7 @@
const ClFlags &getFlags() const { return Flags; }
bool isIRGenerationDisabled() const {
- return ALLOW_DISABLE_IR_GEN ? getFlags().DisableIRGeneration : false;
+ return getFlags().getDisableIRGeneration();
}
// Allocate data of type T using the global allocator.
@@ -223,35 +223,35 @@
}
void dumpStats(const IceString &Name, bool Final = false);
void statsUpdateEmitted(uint32_t InstCount) {
- if (!ALLOW_DUMP || !getFlags().DumpStats)
+ if (!getFlags().getDumpStats())
return;
ThreadContext *TLS = ICE_TLS_GET_FIELD(TLS);
TLS->StatsFunction.update(CodeStats::CS_InstCount, InstCount);
TLS->StatsCumulative.update(CodeStats::CS_InstCount, InstCount);
}
void statsUpdateRegistersSaved(uint32_t Num) {
- if (!ALLOW_DUMP || !getFlags().DumpStats)
+ if (!getFlags().getDumpStats())
return;
ThreadContext *TLS = ICE_TLS_GET_FIELD(TLS);
TLS->StatsFunction.update(CodeStats::CS_RegsSaved, Num);
TLS->StatsCumulative.update(CodeStats::CS_RegsSaved, Num);
}
void statsUpdateFrameBytes(uint32_t Bytes) {
- if (!ALLOW_DUMP || !getFlags().DumpStats)
+ if (!getFlags().getDumpStats())
return;
ThreadContext *TLS = ICE_TLS_GET_FIELD(TLS);
TLS->StatsFunction.update(CodeStats::CS_FrameByte, Bytes);
TLS->StatsCumulative.update(CodeStats::CS_FrameByte, Bytes);
}
void statsUpdateSpills() {
- if (!ALLOW_DUMP || !getFlags().DumpStats)
+ if (!getFlags().getDumpStats())
return;
ThreadContext *TLS = ICE_TLS_GET_FIELD(TLS);
TLS->StatsFunction.update(CodeStats::CS_NumSpills);
TLS->StatsCumulative.update(CodeStats::CS_NumSpills);
}
void statsUpdateFills() {
- if (!ALLOW_DUMP || !getFlags().DumpStats)
+ if (!getFlags().getDumpStats())
return;
ThreadContext *TLS = ICE_TLS_GET_FIELD(TLS);
TLS->StatsFunction.update(CodeStats::CS_NumFills);
@@ -290,7 +290,7 @@
void cfgQueueNotifyEnd() { CfgQ.notifyEnd(); }
void startWorkerThreads() {
- size_t NumWorkers = getFlags().NumTranslationThreads;
+ size_t NumWorkers = getFlags().getNumTranslationThreads();
auto Timers = getTimers();
for (size_t i = 0; i < NumWorkers; ++i) {
ThreadContext *WorkerTLS = new ThreadContext();
diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp
index 8e57ba6..9fd0106 100644
--- a/src/IceTargetLoweringX8632.cpp
+++ b/src/IceTargetLoweringX8632.cpp
@@ -313,7 +313,7 @@
void TargetX8632::translateO2() {
TimerMarker T(TimerStack::TT_O2, Func);
- if (!Ctx->getFlags().PhiEdgeSplit) {
+ if (!Ctx->getFlags().getPhiEdgeSplit()) {
// Lower Phi instructions.
Func->placePhiLoads();
if (Func->hasError())
@@ -377,7 +377,7 @@
return;
Func->dump("After linear scan regalloc");
- if (Ctx->getFlags().PhiEdgeSplit) {
+ if (Ctx->getFlags().getPhiEdgeSplit()) {
Func->advancedPhiLowering();
Func->dump("After advanced Phi lowering");
}
@@ -3067,7 +3067,7 @@
return;
}
case Intrinsics::NaClReadTP: {
- if (Ctx->getFlags().UseSandboxing) {
+ if (Ctx->getFlags().getUseSandboxing()) {
Constant *Zero = Ctx->getConstantZero(IceType_i32);
Operand *Src =
OperandX8632Mem::create(Func, IceType_i32, nullptr, Zero, nullptr, 0,
@@ -4566,7 +4566,7 @@
void TargetDataX8632::lowerGlobal(const VariableDeclaration &Var) const {
// If external and not initialized, this must be a cross test.
// Don't generate a declaration for such cases.
- bool IsExternal = Var.isExternal() || Ctx->getFlags().DisableInternal;
+ bool IsExternal = Var.isExternal() || Ctx->getFlags().getDisableInternal();
if (IsExternal && !Var.hasInitializer())
return;
@@ -4579,7 +4579,7 @@
SizeT Size = Var.getNumBytes();
IceString MangledName = Var.mangleName(Ctx);
IceString SectionSuffix = "";
- if (Ctx->getFlags().DataSections)
+ if (Ctx->getFlags().getDataSections())
SectionSuffix = "." + MangledName;
Str << "\t.type\t" << MangledName << ",@object\n";
@@ -4702,11 +4702,11 @@
}
void TargetDataX8632::lowerConstants(GlobalContext *Ctx) const {
- if (Ctx->getFlags().DisableTranslation)
+ if (Ctx->getFlags().getDisableTranslation())
return;
// No need to emit constants from the int pool since (for x86) they
// are embedded as immediates in the instructions, just emit float/double.
- if (Ctx->getFlags().UseELFWriter) {
+ if (Ctx->getFlags().getUseELFWriter()) {
ELFObjectWriter *Writer = Ctx->getObjectWriter();
Writer->writeConstantPool<ConstantFloat>(IceType_f32);
Writer->writeConstantPool<ConstantDouble>(IceType_f64);
diff --git a/src/IceTranslator.cpp b/src/IceTranslator.cpp
index 4753b22..c47769d 100644
--- a/src/IceTranslator.cpp
+++ b/src/IceTranslator.cpp
@@ -55,7 +55,7 @@
void Translator::translateFcn(std::unique_ptr<Cfg> Func) {
Ctx->cfgQueueBlockingPush(std::move(Func));
- if (Ctx->getFlags().NumTranslationThreads == 0) {
+ if (Ctx->getFlags().getNumTranslationThreads() == 0) {
Ctx->translateFunctions();
}
}
@@ -73,10 +73,10 @@
void
Translator::lowerGlobals(const VariableDeclarationList &VariableDeclarations) {
TimerMarker T(TimerStack::TT_emitGlobalInitializers, Ctx);
- bool DisableTranslation = Ctx->getFlags().DisableTranslation;
- const bool DumpGlobalVariables =
- ALLOW_DUMP && Ctx->getVerbose() && Ctx->getFlags().VerboseFocusOn.empty();
- if (Ctx->getFlags().UseELFWriter) {
+ bool DisableTranslation = Ctx->getFlags().getDisableTranslation();
+ const bool DumpGlobalVariables = ALLOW_DUMP && Ctx->getVerbose() &&
+ Ctx->getFlags().getVerboseFocusOn().empty();
+ if (Ctx->getFlags().getUseELFWriter()) {
// Dump all globals if requested, but don't interleave w/ emission.
if (DumpGlobalVariables) {
OstreamLocker L(Ctx);
@@ -87,7 +87,7 @@
}
DataLowering->lowerGlobalsELF(VariableDeclarations);
} else {
- const IceString &TranslateOnly = Ctx->getFlags().TranslateOnly;
+ const IceString &TranslateOnly = Ctx->getFlags().getTranslateOnly();
OstreamLocker L(Ctx);
Ostream &Stream = Ctx->getStrDump();
for (const Ice::VariableDeclaration *Global : VariableDeclarations) {
diff --git a/src/PNaClTranslator.cpp b/src/PNaClTranslator.cpp
index 552ee60..46bd261 100644
--- a/src/PNaClTranslator.cpp
+++ b/src/PNaClTranslator.cpp
@@ -191,8 +191,7 @@
/// Returns true if generation of Subzero IR is disabled.
bool isIRGenerationDisabled() const {
- return ALLOW_DISABLE_IR_GEN ? Translator.getFlags().DisableIRGeneration
- : false;
+ return Translator.getFlags().getDisableIRGeneration();
}
/// Returns the undefined type associated with type ID.
@@ -458,7 +457,7 @@
raw_ostream &OldErrStream = setErrStream(Context->getStrDump());
NaClBitcodeParser::Error(Message);
setErrStream(OldErrStream);
- if (!Translator.getFlags().AllowErrorRecovery)
+ if (!Translator.getFlags().getAllowErrorRecovery())
report_fatal_error("Unable to continue");
return true;
}
@@ -552,8 +551,7 @@
const Ice::ClFlags &getFlags() const { return getTranslator().getFlags(); }
bool isIRGenerationDisabled() const {
- return ALLOW_DISABLE_IR_GEN ? getTranslator().getFlags().DisableIRGeneration
- : false;
+ return getTranslator().getFlags().getDisableIRGeneration();
}
// Default implementation. Reports that block is unknown and skips
@@ -632,14 +630,14 @@
// Note: If dump routines have been turned off, the error messages
// will not be readable. Hence, replace with simple error. We also
// use the simple form for unit tests.
- if (ALLOW_DUMP && !getFlags().GenerateUnitTestMessages) {
- StrBuf << Message;
- } else {
+ if (getFlags().getGenerateUnitTestMessages()) {
StrBuf << "Invalid " << getBlockName() << " record: <" << Record.GetCode();
for (const uint64_t Val : Record.GetValues()) {
StrBuf << " " << Val;
}
StrBuf << ">";
+ } else {
+ StrBuf << Message;
}
return Context->Error(StrBuf.str());
}
@@ -1091,7 +1089,7 @@
bool convertFunction() {
const Ice::TimerStackIdT StackID = Ice::GlobalContext::TSK_Funcs;
Ice::TimerIdT TimerID = 0;
- const bool TimeThisFunction = ALLOW_DUMP && getFlags().TimeEachFunction;
+ const bool TimeThisFunction = getFlags().getTimeEachFunction();
if (TimeThisFunction) {
TimerID = getTranslator().getContext()->getTimerID(StackID,
FuncDecl->getName());
@@ -2461,7 +2459,7 @@
}
}
} else {
- if (getFlags().StubConstantCalls &&
+ if (getFlags().getStubConstantCalls() &&
llvm::isa<Ice::ConstantInteger32>(Callee)) {
Callee = Context->getStubbedConstCallValue(Callee);
}
@@ -2811,14 +2809,15 @@
void InstallGlobalNamesAndGlobalVarInitializers() {
if (!GlobalDeclarationNamesAndInitializersInstalled) {
Ice::Translator &Trans = getTranslator();
- const Ice::IceString &GlobalPrefix = getFlags().DefaultGlobalPrefix;
+ const Ice::IceString &GlobalPrefix = getFlags().getDefaultGlobalPrefix();
if (!GlobalPrefix.empty()) {
uint32_t NameIndex = 0;
for (Ice::VariableDeclaration *Var : Context->getGlobalVariables()) {
installDeclarationName(Trans, Var, GlobalPrefix, "global", NameIndex);
}
}
- const Ice::IceString &FunctionPrefix = getFlags().DefaultFunctionPrefix;
+ const Ice::IceString &FunctionPrefix =
+ getFlags().getDefaultFunctionPrefix();
if (!FunctionPrefix.empty()) {
uint32_t NameIndex = 0;
for (Ice::FunctionDeclaration *Func :
diff --git a/src/llvm2ice.cpp b/src/llvm2ice.cpp
index 2f31765..f83b253 100644
--- a/src/llvm2ice.cpp
+++ b/src/llvm2ice.cpp
@@ -228,10 +228,11 @@
const char *FlagName;
int FlagValue;
} ConditionalBuildAttributes[] = {{"dump", ALLOW_DUMP},
+ {"disable_ir_gen", ALLOW_DISABLE_IR_GEN},
{"llvm_cl", ALLOW_LLVM_CL},
{"llvm_ir", ALLOW_LLVM_IR},
{"llvm_ir_as_input", ALLOW_LLVM_IR_AS_INPUT},
- {"disable_ir_gen", ALLOW_DISABLE_IR_GEN}};
+ {"minimal_build", ALLOW_MINIMAL_BUILD}};
// Validates values of build attributes. Prints them to Stream if
// Stream is non-null.
@@ -298,28 +299,28 @@
}
Ice::ClFlags Flags;
- Flags.DisableInternal = DisableInternal;
- Flags.SubzeroTimingEnabled = SubzeroTimingEnabled;
- Flags.DisableTranslation = DisableTranslation;
- Flags.FunctionSections = FunctionSections;
- Flags.DataSections = DataSections;
- Flags.UseELFWriter = UseELFWriter;
- Flags.UseIntegratedAssembler = UseIntegratedAssembler;
- Flags.UseSandboxing = UseSandboxing;
- Flags.PhiEdgeSplit = EnablePhiEdgeSplit;
- Flags.DecorateAsm = DecorateAsm;
- Flags.DumpStats = DumpStats;
- Flags.AllowUninitializedGlobals = AllowUninitializedGlobals;
- Flags.TimeEachFunction = TimeEachFunction;
- Flags.NumTranslationThreads = NumThreads;
- Flags.DefaultGlobalPrefix = DefaultGlobalPrefix;
- Flags.DefaultFunctionPrefix = DefaultFunctionPrefix;
- Flags.TimingFocusOn = TimingFocusOn;
- Flags.VerboseFocusOn = VerboseFocusOn;
- Flags.TranslateOnly = TranslateOnly;
- Flags.DisableIRGeneration = DisableIRGeneration;
- Flags.AllowErrorRecovery = AllowErrorRecovery;
- Flags.StubConstantCalls = StubConstantCalls;
+ Flags.setAllowErrorRecovery(AllowErrorRecovery);
+ Flags.setAllowUninitializedGlobals(AllowUninitializedGlobals);
+ Flags.setDataSections(DataSections);
+ Flags.setDecorateAsm(DecorateAsm);
+ Flags.setDefaultFunctionPrefix(DefaultFunctionPrefix);
+ Flags.setDefaultGlobalPrefix(DefaultGlobalPrefix);
+ Flags.setDisableInternal(DisableInternal);
+ Flags.setDisableIRGeneration(DisableIRGeneration);
+ Flags.setDisableTranslation(DisableTranslation);
+ Flags.setDumpStats(DumpStats);
+ Flags.setFunctionSections(FunctionSections);
+ Flags.setNumTranslationThreads(NumThreads);
+ Flags.setPhiEdgeSplit(EnablePhiEdgeSplit);
+ Flags.setStubConstantCalls(StubConstantCalls);
+ Flags.setSubzeroTimingEnabled(SubzeroTimingEnabled);
+ Flags.setTimeEachFunction(TimeEachFunction);
+ Flags.setTimingFocusOn(TimingFocusOn);
+ Flags.setTranslateOnly(TranslateOnly);
+ Flags.setUseELFWriter(UseELFWriter);
+ Flags.setUseIntegratedAssembler(UseIntegratedAssembler);
+ Flags.setUseSandboxing(UseSandboxing);
+ Flags.setVerboseFocusOn(VerboseFocusOn);
// Force -build-on-read=0 for .ll files.
const std::string LLSuffix = ".ll";