Turn off dump/emit routines when building minimal subzero.
Remove the dump/emit routines when ALLOW_DUMP=0. Also fixes some
verbosity messages to not print if ALLOW_DUMP=0. Note: emit routines
needed for emitIAS are not turned off.
BUG=None
R=stichnot@chromium.org
Review URL: https://codereview.chromium.org/686913005
diff --git a/src/IceCfg.cpp b/src/IceCfg.cpp
index b461d68..950a3f8 100644
--- a/src/IceCfg.cpp
+++ b/src/IceCfg.cpp
@@ -396,6 +396,7 @@
// ======================== Dump routines ======================== //
void Cfg::emitTextHeader(const IceString &MangledName) {
+ // Note: Still used by emit IAS.
Ostream &Str = Ctx->getStrEmit();
Str << "\t.text\n";
if (Ctx->getFlags().FunctionSections)
@@ -412,6 +413,8 @@
}
void Cfg::emit() {
+ if (!ALLOW_DUMP)
+ return;
TimerMarker T(TimerStack::TT_emit, this);
if (Ctx->getFlags().DecorateAsm) {
renumberInstructions();
@@ -449,6 +452,8 @@
// Dumps the IR with an optional introductory message.
void Cfg::dump(const IceString &Message) {
+ if (!ALLOW_DUMP)
+ return;
if (!Ctx->isVerbose())
return;
Ostream &Str = Ctx->getStrDump();
diff --git a/src/IceCfgNode.cpp b/src/IceCfgNode.cpp
index e41f114..59035f8 100644
--- a/src/IceCfgNode.cpp
+++ b/src/IceCfgNode.cpp
@@ -798,6 +798,8 @@
void emitRegisterUsage(Ostream &Str, const Cfg *Func, const CfgNode *Node,
bool IsLiveIn, std::vector<SizeT> &LiveRegCount) {
+ if (!ALLOW_DUMP)
+ return;
Liveness *Liveness = Func->getLiveness();
const LivenessBV *Live;
if (IsLiveIn) {
@@ -828,6 +830,8 @@
void emitLiveRangesEnded(Ostream &Str, const Cfg *Func, const Inst *Instr,
std::vector<SizeT> &LiveRegCount) {
+ if (!ALLOW_DUMP)
+ return;
bool First = true;
Variable *Dest = Instr->getDest();
if (Dest && Dest->hasReg())
@@ -873,6 +877,8 @@
} // end of anonymous namespace
void CfgNode::emit(Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Func->setCurrentNode(this);
Ostream &Str = Func->getContext()->getStrEmit();
Liveness *Liveness = Func->getLiveness();
@@ -930,6 +936,8 @@
}
void CfgNode::dump(Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Func->setCurrentNode(this);
Ostream &Str = Func->getContext()->getStrDump();
Liveness *Liveness = Func->getLiveness();
diff --git a/src/IceGlobalContext.cpp b/src/IceGlobalContext.cpp
index 951de47..95378ca 100644
--- a/src/IceGlobalContext.cpp
+++ b/src/IceGlobalContext.cpp
@@ -439,6 +439,8 @@
}
void GlobalContext::dumpStats(const IceString &Name, bool Final) {
+ if (!ALLOW_DUMP)
+ return;
if (Flags.DumpStats) {
if (Final) {
StatsCumulative.dump(Name, getStrDump());
@@ -450,6 +452,8 @@
}
void GlobalContext::dumpTimers(TimerStackIdT StackID, bool DumpCumulative) {
+ if (!ALLOW_DUMP)
+ return;
assert(Timers.size() > StackID);
Timers[StackID].dump(getStrDump(), DumpCumulative);
}
diff --git a/src/IceGlobalContext.h b/src/IceGlobalContext.h
index bdc461e..43f65ad 100644
--- a/src/IceGlobalContext.h
+++ b/src/IceGlobalContext.h
@@ -48,6 +48,8 @@
void updateSpills() { ++Spills; }
void updateFills() { ++Fills; }
void dump(const IceString &Name, Ostream &Str) {
+ if (!ALLOW_DUMP)
+ return;
Str << "|" << Name << "|Inst Count |" << InstructionsEmitted << "\n";
Str << "|" << Name << "|Regs Saved |" << RegistersSaved << "\n";
Str << "|" << Name << "|Frame Bytes |" << FrameBytes << "\n";
diff --git a/src/IceGlobalInits.cpp b/src/IceGlobalInits.cpp
index aaebddf..6cf78aa 100644
--- a/src/IceGlobalInits.cpp
+++ b/src/IceGlobalInits.cpp
@@ -27,6 +27,8 @@
void dumpLinkage(Ice::Ostream &Stream,
llvm::GlobalValue::LinkageTypes Linkage) {
+ if (!ALLOW_DUMP)
+ return;
switch (Linkage) {
case llvm::GlobalValue::ExternalLinkage:
Stream << "external";
@@ -44,6 +46,8 @@
}
void dumpCallingConv(Ice::Ostream &, llvm::CallingConv::ID CallingConv) {
+ if (!ALLOW_DUMP)
+ return;
if (CallingConv == llvm::CallingConv::C)
return;
std::string Buffer;
@@ -65,10 +69,14 @@
}
void FunctionDeclaration::dumpType(Ostream &Stream) const {
+ if (!ALLOW_DUMP)
+ return;
Stream << Signature;
}
void FunctionDeclaration::dump(GlobalContext *Ctx, Ostream &Stream) const {
+ if (!ALLOW_DUMP)
+ return;
if (IsProto)
Stream << "declare ";
::dumpLinkage(Stream, Linkage);
@@ -95,6 +103,8 @@
}
void VariableDeclaration::dumpType(Ostream &Stream) const {
+ if (!ALLOW_DUMP)
+ return;
if (Initializers.size() == 1) {
Initializers.front()->dumpType(Stream);
} else {
@@ -113,6 +123,8 @@
}
void VariableDeclaration::dump(GlobalContext *Ctx, Ostream &Stream) const {
+ if (!ALLOW_DUMP)
+ return;
Stream << "@" << ((Ctx && !getSuppressMangling())
? Ctx->mangleName(Name) : Name) << " = ";
::dumpLinkage(Stream, Linkage);
@@ -143,11 +155,15 @@
}
void VariableDeclaration::Initializer::dumpType(Ostream &Stream) const {
+ if (!ALLOW_DUMP)
+ return;
Stream << "[" << getNumBytes() << " x " << Ice::IceType_i8 << "]";
}
void VariableDeclaration::DataInitializer::dump(
GlobalContext *, Ostream &Stream) const {
+ if (!ALLOW_DUMP)
+ return;
dumpType(Stream);
Stream << " c\"";
// Code taken from PrintEscapedString() in AsmWriter.cpp. Keep
@@ -164,16 +180,22 @@
void VariableDeclaration::ZeroInitializer::dump(
GlobalContext *, Ostream &Stream) const {
+ if (!ALLOW_DUMP)
+ return;
dumpType(Stream);
Stream << " zeroinitializer";
}
void VariableDeclaration::RelocInitializer::dumpType(Ostream &Stream) const {
+ if (!ALLOW_DUMP)
+ return;
Stream << Ice::IceType_i32;
}
void VariableDeclaration::RelocInitializer::dump(
GlobalContext *Ctx, Ostream &Stream) const {
+ if (!ALLOW_DUMP)
+ return;
if (Offset != 0) {
dumpType(Stream);
Stream << " add (";
diff --git a/src/IceGlobalInits.h b/src/IceGlobalInits.h
index d5974b4..082be3c 100644
--- a/src/IceGlobalInits.h
+++ b/src/IceGlobalInits.h
@@ -61,6 +61,8 @@
/// Prints out the global declaration.
virtual void dump(GlobalContext *Ctx, Ostream &Stream) const = 0;
void dump(Ostream &Stream) const {
+ if (!ALLOW_DUMP)
+ return;
GlobalContext *const Ctx = nullptr;
dump(Ctx, Stream);
}
@@ -149,7 +151,8 @@
virtual SizeT getNumBytes() const = 0;
virtual void dump(GlobalContext *Ctx, Ostream &Stream) const = 0;
void dump(Ostream &Stream) const {
- dump(nullptr, Stream);
+ if (ALLOW_DUMP)
+ dump(nullptr, Stream);
}
virtual void dumpType(Ostream &Stream) const;
diff --git a/src/IceInst.cpp b/src/IceInst.cpp
index 5030f5f..89c57e8 100644
--- a/src/IceInst.cpp
+++ b/src/IceInst.cpp
@@ -449,9 +449,17 @@
InstFakeKill::InstFakeKill(Cfg *Func, const Inst *Linked)
: InstHighLevel(Func, Inst::FakeKill, 0, NULL), Linked(Linked) {}
+Type InstCall::getReturnType() const {
+ if (Dest == NULL)
+ return IceType_void;
+ return Dest->getType();
+}
+
// ======================== Dump routines ======================== //
void Inst::dumpDecorated(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
if (!Func->getContext()->isVerbose(IceV_Deleted) &&
(isDeleted() || isRedundantAssign()))
@@ -474,6 +482,8 @@
}
void Inst::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " =~ ";
@@ -481,6 +491,8 @@
}
void Inst::dumpExtras(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
bool First = true;
// Print "LIVEEND={a,b,c}" for all source operands whose live ranges
@@ -507,6 +519,8 @@
}
void Inst::dumpSources(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
for (SizeT I = 0; I < getSrcSize(); ++I) {
if (I > 0)
@@ -516,6 +530,8 @@
}
void Inst::emitSources(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
for (SizeT I = 0; I < getSrcSize(); ++I) {
if (I > 0)
@@ -525,11 +541,15 @@
}
void Inst::dumpDest(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
if (getDest())
getDest()->dump(Func);
}
void InstAlloca::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " = alloca i8, i32 ";
@@ -539,6 +559,8 @@
}
void InstArithmetic::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " = " << InstArithmeticAttributes[getOp()].DisplayString << " "
@@ -547,6 +569,8 @@
}
void InstAssign::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " = " << getDest()->getType() << " ";
@@ -554,6 +578,8 @@
}
void InstBr::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << "br ";
@@ -565,13 +591,9 @@
Str << "label %" << getTargetFalse()->getName();
}
-Type InstCall::getReturnType() const {
- if (Dest == NULL)
- return IceType_void;
- return Dest->getType();
-}
-
void InstCall::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
if (getDest()) {
dumpDest(Func);
@@ -595,6 +617,8 @@
}
void InstCast::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " = " << InstCastAttributes[getCastKind()].DisplayString << " "
@@ -604,6 +628,8 @@
}
void InstIcmp::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " = icmp " << InstIcmpAttributes[getCondition()].DisplayString << " "
@@ -612,6 +638,8 @@
}
void InstExtractElement::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " = extractelement ";
@@ -623,6 +651,8 @@
}
void InstInsertElement::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " = insertelement ";
@@ -637,6 +667,8 @@
}
void InstFcmp::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " = fcmp " << InstFcmpAttributes[getCondition()].DisplayString << " "
@@ -645,6 +677,8 @@
}
void InstLoad::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Type Ty = getDest()->getType();
@@ -654,6 +688,8 @@
}
void InstStore::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
Type Ty = getData()->getType();
Str << "store " << Ty << " ";
@@ -664,6 +700,8 @@
}
void InstSwitch::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
Type Ty = getComparison()->getType();
Str << "switch " << Ty << " ";
@@ -677,6 +715,8 @@
}
void InstPhi::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " = phi " << getDest()->getType() << " ";
@@ -690,6 +730,8 @@
}
void InstRet::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
Type Ty = hasRetValue() ? getRetValue()->getType() : IceType_void;
Str << "ret " << Ty;
@@ -700,6 +742,8 @@
}
void InstSelect::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Operand *Condition = getCondition();
@@ -714,11 +758,15 @@
}
void InstUnreachable::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
Str << "unreachable";
}
void InstFakeDef::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
// Go ahead and "emit" these for now, since they are relatively
// rare.
Ostream &Str = Func->getContext()->getStrEmit();
@@ -729,6 +777,8 @@
}
void InstFakeDef::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " = def.pseudo ";
@@ -738,6 +788,8 @@
void InstFakeUse::emit(const Cfg *Func) const { (void)Func; }
void InstFakeUse::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
Str << "use.pseudo ";
dumpSources(Func);
@@ -746,6 +798,8 @@
void InstFakeKill::emit(const Cfg *Func) const { (void)Func; }
void InstFakeKill::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
if (Linked->isDeleted())
Str << "// ";
@@ -753,6 +807,8 @@
}
void InstTarget::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
Str << "[TARGET] ";
Inst::dump(Func);
diff --git a/src/IceInst.h b/src/IceInst.h
index 5d5101b..16b1b65 100644
--- a/src/IceInst.h
+++ b/src/IceInst.h
@@ -838,8 +838,8 @@
// Override the default ilist traits so that Inst's private ctor and
// deleted dtor aren't invoked.
template <>
-struct llvm::ilist_traits<Ice::Inst> : public llvm::ilist_default_traits<
- Ice::Inst> {
+struct llvm::ilist_traits<Ice::Inst>
+ : public llvm::ilist_default_traits<Ice::Inst> {
Ice::Inst *createSentinel() const {
return static_cast<Ice::Inst *>(&Sentinel);
}
diff --git a/src/IceInstX8632.cpp b/src/IceInstX8632.cpp
index 7ebf187..3da2aa2 100644
--- a/src/IceInstX8632.cpp
+++ b/src/IceInstX8632.cpp
@@ -343,12 +343,16 @@
// ======================== Dump routines ======================== //
void InstX8632::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
Str << "[X8632] ";
Inst::dump(Func);
}
void InstX8632Label::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
Str << getName(Func) << ":";
}
@@ -359,11 +363,15 @@
}
void InstX8632Label::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
Str << getName(Func) << ":";
}
void InstX8632Br::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
Str << "\t";
@@ -420,6 +428,8 @@
}
void InstX8632Br::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
Str << "br ";
@@ -441,6 +451,8 @@
}
void InstX8632Call::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1);
Str << "\tcall\t";
@@ -489,6 +501,8 @@
}
void InstX8632Call::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
if (getDest()) {
dumpDest(Func);
@@ -504,6 +518,8 @@
// template issues.
void emitTwoAddress(const char *Opcode, const Inst *Inst, const Cfg *Func,
bool ShiftHack) {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(Inst->getSrcSize() == 2);
Variable *Dest = Inst->getDest();
@@ -1036,6 +1052,8 @@
&x86::AssemblerX86::psra};
template <> void InstX8632Sqrtss::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1);
Type Ty = getSrc(0)->getType();
@@ -1047,6 +1065,8 @@
}
template <> void InstX8632Addss::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
char buf[30];
snprintf(buf, llvm::array_lengthof(buf), "add%s",
TypeX8632Attributes[getDest()->getType()].SdSsString);
@@ -1054,6 +1074,8 @@
}
template <> void InstX8632Padd::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
char buf[30];
snprintf(buf, llvm::array_lengthof(buf), "padd%s",
TypeX8632Attributes[getDest()->getType()].PackString);
@@ -1061,6 +1083,8 @@
}
template <> void InstX8632Pmull::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
char buf[30];
bool TypesAreValid = getDest()->getType() == IceType_v4i32 ||
getDest()->getType() == IceType_v8i16;
@@ -1094,6 +1118,8 @@
}
template <> void InstX8632Subss::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
char buf[30];
snprintf(buf, llvm::array_lengthof(buf), "sub%s",
TypeX8632Attributes[getDest()->getType()].SdSsString);
@@ -1101,6 +1127,8 @@
}
template <> void InstX8632Psub::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
char buf[30];
snprintf(buf, llvm::array_lengthof(buf), "psub%s",
TypeX8632Attributes[getDest()->getType()].PackString);
@@ -1108,6 +1136,8 @@
}
template <> void InstX8632Mulss::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
char buf[30];
snprintf(buf, llvm::array_lengthof(buf), "mul%s",
TypeX8632Attributes[getDest()->getType()].SdSsString);
@@ -1115,12 +1145,16 @@
}
template <> void InstX8632Pmuludq::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
assert(getSrc(0)->getType() == IceType_v4i32 &&
getSrc(1)->getType() == IceType_v4i32);
emitTwoAddress(Opcode, this, Func);
}
template <> void InstX8632Divss::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
char buf[30];
snprintf(buf, llvm::array_lengthof(buf), "div%s",
TypeX8632Attributes[getDest()->getType()].SdSsString);
@@ -1128,6 +1162,8 @@
}
template <> void InstX8632Div::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 3);
Operand *Src1 = getSrc(1);
@@ -1145,6 +1181,8 @@
}
template <> void InstX8632Idiv::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 3);
Operand *Src1 = getSrc(1);
@@ -1166,6 +1204,8 @@
// pblendvb and blendvps take xmm0 as a final implicit argument.
void emitVariableBlendInst(const char *Opcode, const Inst *Inst,
const Cfg *Func) {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(Inst->getSrcSize() == 3);
assert(llvm::cast<Variable>(Inst->getSrc(2))->getRegNum() ==
@@ -1190,6 +1230,8 @@
} // end anonymous namespace
template <> void InstX8632Blendvps::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
assert(static_cast<TargetX8632 *>(Func->getTarget())->getInstructionSet() >=
TargetX8632::SSE4_1);
emitVariableBlendInst(Opcode, this, Func);
@@ -1204,6 +1246,8 @@
}
template <> void InstX8632Pblendvb::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
assert(static_cast<TargetX8632 *>(Func->getTarget())->getInstructionSet() >=
TargetX8632::SSE4_1);
emitVariableBlendInst(Opcode, this, Func);
@@ -1218,6 +1262,8 @@
}
template <> void InstX8632Imul::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 2);
Variable *Dest = getDest();
@@ -1280,6 +1326,8 @@
}
template <> void InstX8632Cbwdq::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1);
Operand *Src0 = getSrc(0);
@@ -1330,6 +1378,8 @@
}
void InstX8632Mul::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 2);
assert(llvm::isa<Variable>(getSrc(0)));
@@ -1352,6 +1402,8 @@
}
void InstX8632Mul::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " = mul." << getDest()->getType() << " ";
@@ -1359,6 +1411,8 @@
}
void InstX8632Shld::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
Variable *Dest = getDest();
assert(getSrcSize() == 3);
@@ -1389,6 +1443,8 @@
}
void InstX8632Shld::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " = shld." << getDest()->getType() << " ";
@@ -1396,6 +1452,8 @@
}
void InstX8632Shrd::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
Variable *Dest = getDest();
assert(getSrcSize() == 3);
@@ -1426,6 +1484,8 @@
}
void InstX8632Shrd::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " = shrd." << getDest()->getType() << " ";
@@ -1433,6 +1493,8 @@
}
void InstX8632Cmov::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
Variable *Dest = getDest();
Str << "\t";
@@ -1459,6 +1521,8 @@
}
void InstX8632Cmov::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
Str << "cmov" << InstX8632BrAttributes[Condition].DisplayString << ".";
Str << getDest()->getType() << " ";
@@ -1468,6 +1532,8 @@
}
void InstX8632Cmpps::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 2);
assert(Condition < CondX86::Cmpps_Invalid);
@@ -1499,6 +1565,8 @@
}
void InstX8632Cmpps::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
assert(Condition < CondX86::Cmpps_Invalid);
dumpDest(Func);
@@ -1508,6 +1576,8 @@
}
void InstX8632Cmpxchg::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 3);
if (Locked) {
@@ -1538,6 +1608,8 @@
}
void InstX8632Cmpxchg::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
if (Locked) {
Str << "lock ";
@@ -1547,6 +1619,8 @@
}
void InstX8632Cmpxchg8b::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 5);
if (Locked) {
@@ -1569,6 +1643,8 @@
}
void InstX8632Cmpxchg8b::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
if (Locked) {
Str << "lock ";
@@ -1578,6 +1654,8 @@
}
void InstX8632Cvt::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1);
Str << "\tcvt";
@@ -1650,6 +1728,8 @@
}
void InstX8632Cvt::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " = cvt";
@@ -1661,6 +1741,8 @@
}
void InstX8632Icmp::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 2);
Str << "\tcmp" << getWidthString(getSrc(0)->getType()) << "\t";
@@ -1690,12 +1772,16 @@
}
void InstX8632Icmp::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
Str << "cmp." << getSrc(0)->getType() << " ";
dumpSources(Func);
}
void InstX8632Ucomiss::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 2);
Str << "\tucomi" << TypeX8632Attributes[getSrc(0)->getType()].SdSsString
@@ -1719,12 +1805,16 @@
}
void InstX8632Ucomiss::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
Str << "ucomiss." << getSrc(0)->getType() << " ";
dumpSources(Func);
}
void InstX8632UD2::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 0);
Str << "\tud2";
@@ -1736,11 +1826,15 @@
}
void InstX8632UD2::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
Str << "ud2\n";
}
void InstX8632Test::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 2);
Str << "\ttest" << getWidthString(getSrc(0)->getType()) << "\t";
@@ -1771,12 +1865,16 @@
}
void InstX8632Test::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
Str << "test." << getSrc(0)->getType() << " ";
dumpSources(Func);
}
void InstX8632Mfence::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 0);
Str << "\tmfence";
@@ -1788,11 +1886,15 @@
}
void InstX8632Mfence::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
Str << "mfence\n";
}
void InstX8632Store::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 2);
Type Ty = getSrc(0)->getType();
@@ -1834,6 +1936,8 @@
}
void InstX8632Store::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
Str << "mov." << getSrc(0)->getType() << " ";
getSrc(1)->dump(Func);
@@ -1842,6 +1946,8 @@
}
void InstX8632StoreP::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 2);
Str << "\tmovups\t";
@@ -1862,6 +1968,8 @@
}
void InstX8632StoreP::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
Str << "storep." << getSrc(0)->getType() << " ";
getSrc(1)->dump(Func);
@@ -1870,6 +1978,8 @@
}
void InstX8632StoreQ::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 2);
assert(getSrc(1)->getType() == IceType_i64 ||
@@ -1892,6 +2002,8 @@
}
void InstX8632StoreQ::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
Str << "storeq." << getSrc(0)->getType() << " ";
getSrc(1)->dump(Func);
@@ -1900,6 +2012,8 @@
}
template <> void InstX8632Lea::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1);
assert(getDest()->hasReg());
@@ -1918,6 +2032,8 @@
}
template <> void InstX8632Mov::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1);
Operand *Src = getSrc(0);
@@ -2046,6 +2162,8 @@
}
template <> void InstX8632Movp::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
// TODO(wala,stichnot): movups works with all vector operands, but
// there exist other instructions (movaps, movdqa, movdqu) that may
// perform better, depending on the data type and alignment of the
@@ -2071,6 +2189,8 @@
}
template <> void InstX8632Movq::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1);
assert(getDest()->getType() == IceType_i64 ||
@@ -2130,6 +2250,8 @@
}
void InstX8632Nop::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
// TODO: Emit the right code for each variant.
Str << "\tnop\t# variant = " << Variant;
@@ -2142,11 +2264,15 @@
}
void InstX8632Nop::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
Str << "nop (variant = " << Variant << ")";
}
void InstX8632Fld::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1);
Type Ty = getSrc(0)->getType();
@@ -2200,12 +2326,16 @@
}
void InstX8632Fld::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
Str << "fld." << getSrc(0)->getType() << " ";
dumpSources(Func);
}
void InstX8632Fstp::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 0);
// TODO(jvoung,stichnot): Utilize this by setting Dest to nullptr to
@@ -2269,6 +2399,8 @@
}
void InstX8632Fstp::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " = fstp." << getDest()->getType() << ", st(0)";
@@ -2276,6 +2408,8 @@
}
template <> void InstX8632Pcmpeq::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
char buf[30];
snprintf(buf, llvm::array_lengthof(buf), "pcmpeq%s",
TypeX8632Attributes[getDest()->getType()].PackString);
@@ -2283,6 +2417,8 @@
}
template <> void InstX8632Pcmpgt::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
char buf[30];
snprintf(buf, llvm::array_lengthof(buf), "pcmpgt%s",
TypeX8632Attributes[getDest()->getType()].PackString);
@@ -2290,6 +2426,8 @@
}
template <> void InstX8632Pextr::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 2);
// pextrb and pextrd are SSE4.1 instructions.
@@ -2334,6 +2472,8 @@
}
template <> void InstX8632Pinsr::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 3);
// pinsrb and pinsrd are SSE4.1 instructions.
@@ -2407,6 +2547,8 @@
}
void InstX8632Pop::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 0);
Str << "\tpop\t";
@@ -2425,12 +2567,16 @@
}
void InstX8632Pop::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " = pop." << getDest()->getType() << " ";
}
void InstX8632AdjustStack::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
Str << "\tsubl\t$" << Amount << ", %esp";
Func->getTarget()->updateStackAdjustment(Amount);
@@ -2443,11 +2589,15 @@
}
void InstX8632AdjustStack::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
Str << "esp = sub.i32 esp, " << Amount;
}
void InstX8632Push::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1);
// Push is currently only used for saving GPRs.
@@ -2467,12 +2617,16 @@
}
void InstX8632Push::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
Str << "push." << getSrc(0)->getType() << " ";
dumpSources(Func);
}
template <> void InstX8632Psll::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
assert(getDest()->getType() == IceType_v8i16 ||
getDest()->getType() == IceType_v8i1 ||
getDest()->getType() == IceType_v4i32 ||
@@ -2484,6 +2638,8 @@
}
template <> void InstX8632Psra::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
assert(getDest()->getType() == IceType_v8i16 ||
getDest()->getType() == IceType_v8i1 ||
getDest()->getType() == IceType_v4i32 ||
@@ -2495,6 +2651,8 @@
}
void InstX8632Ret::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
Str << "\tret";
}
@@ -2505,6 +2663,8 @@
}
void InstX8632Ret::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
Type Ty = (getSrcSize() == 0 ? IceType_void : getSrc(0)->getType());
Str << "ret." << Ty << " ";
@@ -2512,6 +2672,8 @@
}
void InstX8632Xadd::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
if (Locked) {
Str << "\tlock";
@@ -2540,6 +2702,8 @@
}
void InstX8632Xadd::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
if (Locked) {
Str << "lock ";
@@ -2550,6 +2714,8 @@
}
void InstX8632Xchg::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
Str << "\txchg" << getWidthString(getSrc(0)->getType()) << "\t";
getSrc(1)->emit(Func);
@@ -2572,6 +2738,8 @@
}
void InstX8632Xchg::dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
Type Ty = getSrc(0)->getType();
Str << "xchg." << Ty << " ";
@@ -2579,6 +2747,8 @@
}
void OperandX8632Mem::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
if (SegmentReg != DefaultSegment) {
assert(SegmentReg >= 0 && SegmentReg < SegReg_NUM);
@@ -2613,6 +2783,8 @@
}
void OperandX8632Mem::dump(const Cfg *Func, Ostream &Str) const {
+ if (!ALLOW_DUMP)
+ return;
if (SegmentReg != DefaultSegment) {
assert(SegmentReg >= 0 && SegmentReg < SegReg_NUM);
Str << InstX8632SegmentRegNames[SegmentReg] << ":";
@@ -2712,6 +2884,8 @@
}
void VariableSplit::emit(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(!Var->hasReg());
// The following is copied/adapted from TargetX8632::emitVariable().
@@ -2725,6 +2899,8 @@
}
void VariableSplit::dump(const Cfg *Func, Ostream &Str) const {
+ if (!ALLOW_DUMP)
+ return;
switch (Part) {
case Low:
Str << "low";
diff --git a/src/IceInstX8632.h b/src/IceInstX8632.h
index 6b1acc7..5d10a54 100644
--- a/src/IceInstX8632.h
+++ b/src/IceInstX8632.h
@@ -41,7 +41,8 @@
};
using Operand::dump;
void dump(const Cfg *, Ostream &Str) const override {
- Str << "<OperandX8632>";
+ if (ALLOW_DUMP)
+ Str << "<OperandX8632>";
}
protected:
@@ -465,6 +466,8 @@
InstX8632InplaceopGPR(Func, SrcDest);
}
void emit(const Cfg *Func) const override {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1);
Str << "\t" << Opcode << "\t";
@@ -477,6 +480,8 @@
emitIASOpTyGPR(Func, Ty, Var, Emitter);
}
void dump(const Cfg *Func) const override {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " = " << Opcode << "." << getDest()->getType() << " ";
@@ -513,6 +518,8 @@
InstX8632UnaryopGPR(Func, Dest, Src);
}
void emit(const Cfg *Func) const override {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1);
Type SrcTy = getSrc(0)->getType();
@@ -536,6 +543,8 @@
emitIASRegOpTyGPR(Func, Ty, Var, Src, Emitter);
}
void dump(const Cfg *Func) const override {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " = " << Opcode << "." << getSrc(0)->getType() << " ";
@@ -568,6 +577,8 @@
InstX8632UnaryopXmm(Func, Dest, Src);
}
void emit(const Cfg *Func) const override {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1);
Str << "\t" << Opcode << "\t";
@@ -581,6 +592,8 @@
emitIASRegOpTyXMM(Func, Ty, getDest(), getSrc(0), Emitter);
}
void dump(const Cfg *Func) const override {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " = " << Opcode << "." << getDest()->getType() << " ";
@@ -620,6 +633,8 @@
InstX8632BinopGPRShift(Func, Dest, Source);
}
void emit(const Cfg *Func) const override {
+ if (!ALLOW_DUMP)
+ return;
const bool ShiftHack = true;
emitTwoAddress(Opcode, this, Func, ShiftHack);
}
@@ -629,6 +644,8 @@
emitIASGPRShift(Func, Ty, getDest(), getSrc(1), Emitter);
}
void dump(const Cfg *Func) const override {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " = " << Opcode << "." << getDest()->getType() << " ";
@@ -659,6 +676,8 @@
InstX8632BinopGPR(Func, Dest, Source);
}
void emit(const Cfg *Func) const override {
+ if (!ALLOW_DUMP)
+ return;
const bool ShiftHack = false;
emitTwoAddress(Opcode, this, Func, ShiftHack);
}
@@ -668,6 +687,8 @@
emitIASRegOpTyGPR(Func, Ty, getDest(), getSrc(1), Emitter);
}
void dump(const Cfg *Func) const override {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " = " << Opcode << "." << getDest()->getType() << " ";
@@ -698,6 +719,8 @@
InstX8632BinopXmm(Func, Dest, Source);
}
void emit(const Cfg *Func) const override {
+ if (!ALLOW_DUMP)
+ return;
const bool ShiftHack = false;
emitTwoAddress(Opcode, this, Func, ShiftHack);
}
@@ -709,6 +732,8 @@
emitIASRegOpTyXMM(Func, Ty, getDest(), getSrc(1), Emitter);
}
void dump(const Cfg *Func) const override {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " = " << Opcode << "." << getDest()->getType() << " ";
@@ -744,6 +769,8 @@
InstX8632BinopXmmShift(Func, Dest, Source);
}
void emit(const Cfg *Func) const override {
+ if (!ALLOW_DUMP)
+ return;
const bool ShiftHack = false;
emitTwoAddress(Opcode, this, Func, ShiftHack);
}
@@ -756,6 +783,8 @@
emitIASXmmShift(Func, ElementTy, getDest(), getSrc(1), Emitter);
}
void dump(const Cfg *Func) const override {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " = " << Opcode << "." << getDest()->getType() << " ";
@@ -786,6 +815,8 @@
InstX8632Ternop(Func, Dest, Source1, Source2);
}
void emit(const Cfg *Func) const override {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 3);
Str << "\t" << Opcode << "\t";
@@ -797,6 +828,8 @@
}
void emitIAS(const Cfg *Func) const override;
void dump(const Cfg *Func) const override {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " = " << Opcode << "." << getDest()->getType() << " ";
@@ -828,6 +861,8 @@
InstX8632ThreeAddressop(Func, Dest, Source0, Source1);
}
void emit(const Cfg *Func) const override {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 2);
Str << "\t" << Opcode << "\t";
@@ -839,6 +874,8 @@
}
void emitIAS(const Cfg *Func) const override;
void dump(const Cfg *Func) const override {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " = " << Opcode << "." << getDest()->getType() << " ";
@@ -877,6 +914,8 @@
void emit(const Cfg *Func) const override;
void emitIAS(const Cfg *Func) const override;
void dump(const Cfg *Func) const override {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
Str << Opcode << "." << getDest()->getType() << " ";
dumpDest(Func);
diff --git a/src/IceOperand.cpp b/src/IceOperand.cpp
index b2af752..583a6bc 100644
--- a/src/IceOperand.cpp
+++ b/src/IceOperand.cpp
@@ -427,10 +427,13 @@
// ======================== dump routines ======================== //
void Variable::emit(const Cfg *Func) const {
- Func->getTarget()->emitVariable(this);
+ if (ALLOW_DUMP)
+ Func->getTarget()->emitVariable(this);
}
void Variable::dump(const Cfg *Func, Ostream &Str) const {
+ if (!ALLOW_DUMP)
+ return;
if (Func == NULL) {
Str << "%" << getName();
return;
@@ -458,6 +461,8 @@
}
void ConstantRelocatable::emitWithoutDollar(GlobalContext *Ctx) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Ctx->getStrEmit();
if (SuppressMangling)
Str << Name;
@@ -471,12 +476,16 @@
}
void ConstantRelocatable::emit(GlobalContext *Ctx) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Ctx->getStrEmit();
Str << "$";
emitWithoutDollar(Ctx);
}
void ConstantRelocatable::dump(const Cfg *Func, Ostream &Str) const {
+ if (!ALLOW_DUMP)
+ return;
Str << "@";
if (Func && !SuppressMangling) {
Str << Func->getContext()->mangleName(Name);
@@ -488,6 +497,8 @@
}
void LiveRange::dump(Ostream &Str) const {
+ if (!ALLOW_DUMP)
+ return;
Str << "(weight=" << Weight << ") ";
bool First = true;
for (const RangeElementType &I : Range) {
@@ -499,11 +510,15 @@
}
Ostream &operator<<(Ostream &Str, const LiveRange &L) {
+ if (!ALLOW_DUMP)
+ return Str;
L.dump(Str);
return Str;
}
Ostream &operator<<(Ostream &Str, const RegWeight &W) {
+ if (!ALLOW_DUMP)
+ return Str;
if (W.getWeight() == RegWeight::Inf)
Str << "Inf";
else
diff --git a/src/IceOperand.h b/src/IceOperand.h
index c37b195..13e5324 100644
--- a/src/IceOperand.h
+++ b/src/IceOperand.h
@@ -65,10 +65,15 @@
// situation where Func==NULL.
virtual void dump(const Cfg *Func, Ostream &Str) const = 0;
void dump(const Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
assert(Func);
dump(Func, Func->getContext()->getStrDump());
}
- void dump(Ostream &Str) const { dump(NULL, Str); }
+ void dump(Ostream &Str) const {
+ if (ALLOW_DUMP)
+ dump(NULL, Str);
+ }
// Query whether this object was allocated in isolation, or added to
// some higher-level pool. This determines whether a containing
@@ -148,7 +153,10 @@
// specialization.
void emit(GlobalContext *Ctx) const override;
using Constant::dump;
- void dump(const Cfg *, Ostream &Str) const override { Str << getValue(); }
+ void dump(const Cfg *, Ostream &Str) const override {
+ if (ALLOW_DUMP)
+ Str << getValue();
+ }
static bool classof(const Operand *Operand) {
return Operand->getKind() == K;
@@ -167,6 +175,8 @@
typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble;
template <> inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const {
+ if (!ALLOW_DUMP)
+ return;
if (getType() == IceType_i1)
Str << (getValue() ? "true" : "false");
else
@@ -174,6 +184,8 @@
}
template <> inline void ConstantInteger64::dump(const Cfg *, Ostream &Str) const {
+ if (!ALLOW_DUMP)
+ return;
assert(getType() == IceType_i64);
Str << static_cast<int64_t>(getValue());
}
@@ -259,7 +271,10 @@
using Constant::dump;
// The target needs to implement this.
void emit(GlobalContext *Ctx) const override;
- void dump(const Cfg *, Ostream &Str) const override { Str << "undef"; }
+ void dump(const Cfg *, Ostream &Str) const override {
+ if (ALLOW_DUMP)
+ Str << "undef";
+ }
static bool classof(const Operand *Operand) {
return Operand->getKind() == kConstUndef;
diff --git a/src/IceRegAlloc.cpp b/src/IceRegAlloc.cpp
index 569a616..2a30034 100644
--- a/src/IceRegAlloc.cpp
+++ b/src/IceRegAlloc.cpp
@@ -46,6 +46,8 @@
void dumpDisableOverlap(const Cfg *Func, const Variable *Var,
const char *Reason) {
+ if (!ALLOW_DUMP)
+ return;
if (Func->getContext()->isVerbose(IceV_LinearScan)) {
VariablesMetadata *VMetadata = Func->getVMetadata();
Ostream &Str = Func->getContext()->getStrDump();
@@ -62,6 +64,8 @@
}
void dumpLiveRange(const Variable *Var, const Cfg *Func) {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
const static size_t BufLen = 30;
char buf[BufLen];
@@ -252,7 +256,8 @@
TimerMarker T(TimerStack::TT_linearScan, Func);
assert(RegMaskFull.any()); // Sanity check
Ostream &Str = Func->getContext()->getStrDump();
- bool Verbose = Func->getContext()->isVerbose(IceV_LinearScan);
+ const bool Verbose =
+ ALLOW_DUMP && Func->getContext()->isVerbose(IceV_LinearScan);
Func->resetCurrentNode();
VariablesMetadata *VMetadata = Func->getVMetadata();
@@ -691,6 +696,8 @@
// ======================== Dump routines ======================== //
void LinearScan::dump(Cfg *Func) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Func->getContext()->getStrDump();
if (!Func->getContext()->isVerbose(IceV_LinearScan))
return;
diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp
index cd40e09..82d20b4 100644
--- a/src/IceTargetLoweringX8632.cpp
+++ b/src/IceTargetLoweringX8632.cpp
@@ -898,7 +898,7 @@
Var->setStackOffset(Linked->getStackOffset());
}
- if (Func->getContext()->isVerbose(IceV_Frame)) {
+ if (ALLOW_DUMP && Func->getContext()->isVerbose(IceV_Frame)) {
Ostream &Str = Func->getContext()->getStrDump();
Str << "Stack layout:\n";
@@ -996,6 +996,7 @@
const char *PoolTypeConverter<double>::PrintfString = "0x%llx";
template <typename T> void TargetX8632::emitConstantPool() const {
+ // Note: Still used by emit IAS.
Ostream &Str = Ctx->getStrEmit();
Type Ty = T::Ty;
SizeT Align = typeAlignInBytes(Ty);
@@ -1024,6 +1025,7 @@
}
void TargetX8632::emitConstants() const {
+ // Note: Still used by emit IAS.
emitConstantPool<PoolTypeConverter<float> >();
emitConstantPool<PoolTypeConverter<double> >();
@@ -3561,6 +3563,8 @@
void dumpAddressOpt(const Cfg *Func, const Variable *Base,
const Variable *Index, uint16_t Shift, int32_t Offset,
const Inst *Reason) {
+ if (!ALLOW_DUMP)
+ return;
if (!Func->getContext()->isVerbose(IceV_AddrOpt))
return;
Ostream &Str = Func->getContext()->getStrDump();
@@ -4528,6 +4532,8 @@
}
template <> void ConstantInteger32::emit(GlobalContext *Ctx) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Ctx->getStrEmit();
Str << "$" << (int32_t)getValue();
}
@@ -4537,11 +4543,15 @@
}
template <> void ConstantFloat::emit(GlobalContext *Ctx) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Ctx->getStrEmit();
Str << ".L$" << IceType_f32 << "$" << getPoolEntryID();
}
template <> void ConstantDouble::emit(GlobalContext *Ctx) const {
+ if (!ALLOW_DUMP)
+ return;
Ostream &Str = Ctx->getStrEmit();
Str << ".L$" << IceType_f64 << "$" << getPoolEntryID();
}
diff --git a/src/IceTimerTree.cpp b/src/IceTimerTree.cpp
index 1fb098d..cc25baf 100644
--- a/src/IceTimerTree.cpp
+++ b/src/IceTimerTree.cpp
@@ -127,6 +127,8 @@
// Dump the Map items in reverse order of their time contribution.
void dumpHelper(Ostream &Str, const DumpMapType &Map, double TotalTime) {
+ if (!ALLOW_DUMP)
+ return;
// TODO(stichnot): Use llvm::make_range with LLVM 3.5.
for (auto I = Map.rbegin(), E = Map.rend(); I != E; ++I) {
char buf[80];
@@ -142,6 +144,8 @@
// MaxVal=5 ==> "[%1lu] "
// MaxVal=9876 ==> "[%4lu] "
void makePrintfFormatString(char *Buf, size_t BufLen, size_t MaxVal) {
+ if (!ALLOW_DUMP)
+ return;
int NumDigits = 0;
do {
++NumDigits;
@@ -153,6 +157,8 @@
} // end of anonymous namespace
void TimerStack::dump(Ostream &Str, bool DumpCumulative) {
+ if (!ALLOW_DUMP)
+ return;
const bool UpdateCounts = true;
update(UpdateCounts);
double TotalTime = LastTimestamp - FirstTimestamp;
diff --git a/src/IceTranslator.cpp b/src/IceTranslator.cpp
index 08e5697..954da47 100644
--- a/src/IceTranslator.cpp
+++ b/src/IceTranslator.cpp
@@ -106,8 +106,8 @@
llvm::OwningPtr<TargetGlobalInitLowering> GlobalLowering(
TargetGlobalInitLowering::createLowering(Ctx->getTargetArch(), Ctx));
bool DisableTranslation = Ctx->getFlags().DisableTranslation;
- bool DumpGlobalVariables =
- Ctx->isVerbose() && Ctx->getFlags().VerboseFocusOn.empty();
+ const bool DumpGlobalVariables =
+ ALLOW_DUMP && Ctx->isVerbose() && Ctx->getFlags().VerboseFocusOn.empty();
Ostream &Stream = Ctx->getStrDump();
const IceString &TranslateOnly = Ctx->getFlags().TranslateOnly;
for (const Ice::VariableDeclaration *Global : VariableDeclarations) {
diff --git a/src/IceTypes.cpp b/src/IceTypes.cpp
index 975001d..455aa0c 100644
--- a/src/IceTypes.cpp
+++ b/src/IceTypes.cpp
@@ -260,6 +260,8 @@
}
void FuncSigType::dump(Ostream &Stream) const {
+ if (!ALLOW_DUMP)
+ return;
Stream << ReturnType << " (";
bool IsFirst = true;
for (const Type ArgTy : ArgList) {
diff --git a/src/PNaClTranslator.cpp b/src/PNaClTranslator.cpp
index 07fd5af..0f4feac 100644
--- a/src/PNaClTranslator.cpp
+++ b/src/PNaClTranslator.cpp
@@ -87,11 +87,15 @@
};
Ice::Ostream &operator<<(Ice::Ostream &Stream, const ExtendedType &Ty) {
+ if (!ALLOW_DUMP)
+ return Stream;
Ty.dump(Stream);
return Stream;
}
Ice::Ostream &operator<<(Ice::Ostream &Stream, ExtendedType::TypeKind Kind) {
+ if (!ALLOW_DUMP)
+ return Stream;
Stream << "ExtendedType::";
switch (Kind) {
case ExtendedType::Undefined:
@@ -138,6 +142,8 @@
};
void ExtendedType::dump(Ice::Ostream &Stream) const {
+ if (!ALLOW_DUMP)
+ return;
Stream << Kind;
switch (Kind) {
case Simple: {
@@ -545,7 +551,13 @@
std::string Buffer;
raw_string_ostream StrBuf(Buffer);
StrBuf << "(" << format("%" PRIu64 ":%u", (Bit / 8),
- static_cast<unsigned>(Bit % 8)) << ") " << Message;
+ static_cast<unsigned>(Bit % 8)) << ") ";
+ // Note: If dump routines have been turned off, the error messages
+ // will not be readable. Hence, replace with simple error.
+ if (ALLOW_DUMP)
+ StrBuf << Message;
+ else
+ StrBuf << "Invalid input record";
return Context->Error(StrBuf.str());
}
@@ -1394,6 +1406,8 @@
void dumpVectorIndexCheckValue(raw_ostream &Stream,
VectorIndexCheckValue Value) const {
+ if (!ALLOW_DUMP)
+ return;
switch (Value) {
default:
report_fatal_error("Unknown VectorIndexCheckValue");
diff --git a/src/llvm2ice.cpp b/src/llvm2ice.cpp
index 12c241a..774a8e6 100644
--- a/src/llvm2ice.cpp
+++ b/src/llvm2ice.cpp
@@ -192,8 +192,7 @@
static struct {
const char *FlagName;
int FlagValue;
-} ConditionalBuildAttributes[] = {{"text_asm", ALLOW_TEXT_ASM},
- {"dump", ALLOW_DUMP},
+} ConditionalBuildAttributes[] = {{"dump", ALLOW_DUMP},
{"llvm_cl", ALLOW_LLVM_CL},
{"llvm_ir", ALLOW_LLVM_IR},
{"llvm_ir_as_input", ALLOW_LLVM_IR_AS_INPUT},
@@ -236,8 +235,12 @@
DisableTranslation = true;
Ice::VerboseMask VMask = Ice::IceV_None;
- for (unsigned i = 0; i != VerboseList.size(); ++i)
- VMask |= VerboseList[i];
+ // Don't generate verbose messages if routines
+ // to dump messages are not available.
+ if (ALLOW_DUMP) {
+ for (unsigned i = 0; i != VerboseList.size(); ++i)
+ VMask |= VerboseList[i];
+ }
std::ofstream Ofs;
if (OutputFilename != "-") {