Commit df80eb86 by Karl Schimpf

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
parent c9ec5793
......@@ -54,10 +54,12 @@ ifdef MINIMAL
NOASSERT = 1
OBJDIR := $(OBJDIR)+Min
CXX_DEFINES += -DALLOW_DUMP=0 -DALLOW_LLVM_CL=0 -DALLOW_LLVM_IR=0 \
-DALLOW_LLVM_IR_AS_INPUT=0 -DALLOW_DISABLE_IR_GEN=0
-DALLOW_LLVM_IR_AS_INPUT=0 -DALLOW_DISABLE_IR_GEN=0 \
-DALLOW_MINIMAL_BUILD=1
else
CXX_DEFINES += -DALLOW_DUMP=1 -DALLOW_LLVM_CL=1 -DALLOW_LLVM_IR=1 \
-DALLOW_LLVM_IR_AS_INPUT=1 -DALLOW_DISABLE_IR_GEN=1
-DALLOW_LLVM_IR_AS_INPUT=1 -DALLOW_DISABLE_IR_GEN=1 \
-DALLOW_MINIMAL_BUILD=0
endif
ifdef NOASSERT
......
......@@ -81,14 +81,15 @@ void Cfg::translate() {
// 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 @@ void Cfg::contractEmptyNodes() {
// 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 @@ void Cfg::emitTextHeader(const IceString &MangledName) {
// 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 @@ void Cfg::emit() {
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::emit() {
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 @@ void Cfg::emitIAS() {
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 @@ void Cfg::dump(const IceString &Message) {
// 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) {
......
......@@ -859,7 +859,8 @@ void CfgNode::emit(Cfg *Func) const {
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)
......
......@@ -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 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 SubzeroTimingEnabled;
bool DisableIRGeneration;
bool DisableTranslation;
bool DumpStats;
bool FunctionSections;
bool DataSections;
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
......
......@@ -716,7 +716,7 @@ void LLVM2ICEGlobalsConverter::convertGlobalsToIce(
}
if (!GV->hasInitializer()) {
if (Ctx->getFlags().AllowUninitializedGlobals)
if (Ctx->getFlags().getAllowUninitializedGlobals())
continue;
else {
std::string Buffer;
......@@ -801,7 +801,7 @@ void LLVM2ICEGlobalsConverter::addGlobalInitializer(
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::nameUnnamedGlobalVariables(Module *Mod) {
}
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 @@ void Converter::convertFunctions() {
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);
......
......@@ -296,7 +296,8 @@ void ELFObjectWriter::writeDataSection(const VariableDeclarationList &Vars,
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 @@ void ELFObjectWriter::writeDataOfType(SectionType ST,
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,
......
......@@ -134,8 +134,8 @@ GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit,
: 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 @@ GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit,
newTimerStackID("Per-function summary");
}
Timers.initInto(MyTLS->Timers);
if (Flags.UseELFWriter) {
if (Flags.getUseELFWriter()) {
ObjectWriter.reset(new ELFObjectWriter(*this, *ELFStr));
}
}
......@@ -169,14 +169,16 @@ void GlobalContext::translateFunctions() {
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 @@ void GlobalContext::translateFunctions() {
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 @@ std::unique_ptr<Cfg> GlobalContext::cfgQueueBlockingPop() {
}
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 GlobalContext::dumpTimers(TimerStackIdT StackID, bool DumpCumulative) {
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::push() {
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);
}
......
......@@ -202,7 +202,7 @@ public:
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 @@ public:
}
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 @@ public:
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();
......
......@@ -313,7 +313,7 @@ TargetX8632::TargetX8632(Cfg *Func)
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 @@ void TargetX8632::translateO2() {
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 @@ void TargetX8632::lowerIntrinsicCall(const InstIntrinsicCall *Instr) {
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 @@ TargetDataX8632::TargetDataX8632(GlobalContext *Ctx)
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 @@ void TargetDataX8632::lowerGlobal(const VariableDeclaration &Var) const {
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::emitConstantPool(GlobalContext *Ctx) {
}
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);
......
......@@ -55,7 +55,7 @@ bool Translator::checkIfUnnamedNameSafe(const IceString &Name, const char *Kind,
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::transferErrorCode() const {
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 @@ Translator::lowerGlobals(const VariableDeclarationList &VariableDeclarations) {
}
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) {
......
......@@ -191,8 +191,7 @@ public:
/// 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 @@ bool TopLevelParser::Error(const std::string &Message) {
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 @@ protected:
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 @@ bool BlockParserBaseClass::Error(const std::string &Message) {
// 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 @@ public:
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 @@ void FunctionParser::ProcessRecord() {
}
}
} else {
if (getFlags().StubConstantCalls &&
if (getFlags().getStubConstantCalls() &&
llvm::isa<Ice::ConstantInteger32>(Callee)) {
Callee = Context->getStubbedConstCallValue(Callee);
}
......@@ -2811,14 +2809,15 @@ private:
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 :
......
......@@ -228,10 +228,11 @@ static struct {
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 @@ int main(int argc, char **argv) {
}
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";
......
......@@ -26,8 +26,8 @@ bool IceTest::SubzeroBitcodeMunger::runTest(const char *TestName,
setupTest(TestName, Munges, MungeSize, AddHeader);
Ice::ClFlags Flags;
Flags.AllowErrorRecovery = true;
Flags.GenerateUnitTestMessages = true;
Flags.setAllowErrorRecovery(true);
Flags.setGenerateUnitTestMessages(true);
Ice::GlobalContext Ctx(DumpStream, DumpStream, nullptr,
Ice::IceV_Instructions, Ice::Target_X8632, Ice::Opt_m1,
"", Flags);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment