Commit b6c96af1 by Karl Schimpf

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
parent 70d0a054
...@@ -14,6 +14,6 @@ include $(LEVEL)/Makefile.common ...@@ -14,6 +14,6 @@ include $(LEVEL)/Makefile.common
CXX.Flags += -std=c++11 CXX.Flags += -std=c++11
CPP.Defines += -DALLOW_TEXT_ASM=1 -DALLOW_DUMP=1 -DALLOW_LLVM_CL=1 \ CPP.Defines += -DALLOW_DUMP=1 -DALLOW_LLVM_CL=1 -DALLOW_LLVM_IR=1 \
-DALLOW_LLVM_IR=1 -DALLOW_LLVM_IR_AS_INPUT=1 -DALLOW_LLVM_IR_AS_INPUT=1 -DALLOW_DISABLE_IR_GEN=1
...@@ -50,13 +50,11 @@ CXX_DEFINES = ...@@ -50,13 +50,11 @@ CXX_DEFINES =
ifdef MINIMAL ifdef MINIMAL
OBJDIR := $(OBJDIR)+Min OBJDIR := $(OBJDIR)+Min
CXX_DEFINES += -DALLOW_TEXT_ASM=0 -DALLOW_DUMP=0 -DALLOW_LLVM_CL=0 \ CXX_DEFINES += -DALLOW_DUMP=0 -DALLOW_LLVM_CL=0 -DALLOW_LLVM_IR=0 \
-DALLOW_LLVM_IR=0 -DALLOW_LLVM_IR_AS_INPUT=0 \ -DALLOW_LLVM_IR_AS_INPUT=0 -DALLOW_DISABLE_IR_GEN=0
-DALLOW_DISABLE_IR_GEN=0
else else
CXX_DEFINES += -DALLOW_TEXT_ASM=1 -DALLOW_DUMP=1 -DALLOW_LLVM_CL=1 \ CXX_DEFINES += -DALLOW_DUMP=1 -DALLOW_LLVM_CL=1 -DALLOW_LLVM_IR=1 \
-DALLOW_LLVM_IR=1 -DALLOW_LLVM_IR_AS_INPUT=1 \ -DALLOW_LLVM_IR_AS_INPUT=1 -DALLOW_DISABLE_IR_GEN=1
-DALLOW_DISABLE_IR_GEN=1
endif endif
ifdef NOASSERT ifdef NOASSERT
......
...@@ -396,6 +396,7 @@ void Cfg::doBranchOpt() { ...@@ -396,6 +396,7 @@ void Cfg::doBranchOpt() {
// ======================== Dump routines ======================== // // ======================== Dump routines ======================== //
void Cfg::emitTextHeader(const IceString &MangledName) { void Cfg::emitTextHeader(const IceString &MangledName) {
// Note: Still used by emit IAS.
Ostream &Str = Ctx->getStrEmit(); Ostream &Str = Ctx->getStrEmit();
Str << "\t.text\n"; Str << "\t.text\n";
if (Ctx->getFlags().FunctionSections) if (Ctx->getFlags().FunctionSections)
...@@ -412,6 +413,8 @@ void Cfg::emitTextHeader(const IceString &MangledName) { ...@@ -412,6 +413,8 @@ void Cfg::emitTextHeader(const IceString &MangledName) {
} }
void Cfg::emit() { void Cfg::emit() {
if (!ALLOW_DUMP)
return;
TimerMarker T(TimerStack::TT_emit, this); TimerMarker T(TimerStack::TT_emit, this);
if (Ctx->getFlags().DecorateAsm) { if (Ctx->getFlags().DecorateAsm) {
renumberInstructions(); renumberInstructions();
...@@ -449,6 +452,8 @@ void Cfg::emitIAS() { ...@@ -449,6 +452,8 @@ void Cfg::emitIAS() {
// Dumps the IR with an optional introductory message. // Dumps the IR with an optional introductory message.
void Cfg::dump(const IceString &Message) { void Cfg::dump(const IceString &Message) {
if (!ALLOW_DUMP)
return;
if (!Ctx->isVerbose()) if (!Ctx->isVerbose())
return; return;
Ostream &Str = Ctx->getStrDump(); Ostream &Str = Ctx->getStrDump();
......
...@@ -798,6 +798,8 @@ namespace { ...@@ -798,6 +798,8 @@ namespace {
void emitRegisterUsage(Ostream &Str, const Cfg *Func, const CfgNode *Node, void emitRegisterUsage(Ostream &Str, const Cfg *Func, const CfgNode *Node,
bool IsLiveIn, std::vector<SizeT> &LiveRegCount) { bool IsLiveIn, std::vector<SizeT> &LiveRegCount) {
if (!ALLOW_DUMP)
return;
Liveness *Liveness = Func->getLiveness(); Liveness *Liveness = Func->getLiveness();
const LivenessBV *Live; const LivenessBV *Live;
if (IsLiveIn) { if (IsLiveIn) {
...@@ -828,6 +830,8 @@ void emitRegisterUsage(Ostream &Str, const Cfg *Func, const CfgNode *Node, ...@@ -828,6 +830,8 @@ void emitRegisterUsage(Ostream &Str, const Cfg *Func, const CfgNode *Node,
void emitLiveRangesEnded(Ostream &Str, const Cfg *Func, const Inst *Instr, void emitLiveRangesEnded(Ostream &Str, const Cfg *Func, const Inst *Instr,
std::vector<SizeT> &LiveRegCount) { std::vector<SizeT> &LiveRegCount) {
if (!ALLOW_DUMP)
return;
bool First = true; bool First = true;
Variable *Dest = Instr->getDest(); Variable *Dest = Instr->getDest();
if (Dest && Dest->hasReg()) if (Dest && Dest->hasReg())
...@@ -873,6 +877,8 @@ void updateStats(Cfg *Func, const Inst *I) { ...@@ -873,6 +877,8 @@ void updateStats(Cfg *Func, const Inst *I) {
} // end of anonymous namespace } // end of anonymous namespace
void CfgNode::emit(Cfg *Func) const { void CfgNode::emit(Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Func->setCurrentNode(this); Func->setCurrentNode(this);
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
Liveness *Liveness = Func->getLiveness(); Liveness *Liveness = Func->getLiveness();
...@@ -930,6 +936,8 @@ void CfgNode::emitIAS(Cfg *Func) const { ...@@ -930,6 +936,8 @@ void CfgNode::emitIAS(Cfg *Func) const {
} }
void CfgNode::dump(Cfg *Func) const { void CfgNode::dump(Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Func->setCurrentNode(this); Func->setCurrentNode(this);
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Liveness *Liveness = Func->getLiveness(); Liveness *Liveness = Func->getLiveness();
......
...@@ -439,6 +439,8 @@ void GlobalContext::setTimerName(TimerStackIdT StackID, ...@@ -439,6 +439,8 @@ void GlobalContext::setTimerName(TimerStackIdT StackID,
} }
void GlobalContext::dumpStats(const IceString &Name, bool Final) { void GlobalContext::dumpStats(const IceString &Name, bool Final) {
if (!ALLOW_DUMP)
return;
if (Flags.DumpStats) { if (Flags.DumpStats) {
if (Final) { if (Final) {
StatsCumulative.dump(Name, getStrDump()); StatsCumulative.dump(Name, getStrDump());
...@@ -450,6 +452,8 @@ void GlobalContext::dumpStats(const IceString &Name, bool Final) { ...@@ -450,6 +452,8 @@ void GlobalContext::dumpStats(const IceString &Name, bool Final) {
} }
void GlobalContext::dumpTimers(TimerStackIdT StackID, bool DumpCumulative) { void GlobalContext::dumpTimers(TimerStackIdT StackID, bool DumpCumulative) {
if (!ALLOW_DUMP)
return;
assert(Timers.size() > StackID); assert(Timers.size() > StackID);
Timers[StackID].dump(getStrDump(), DumpCumulative); Timers[StackID].dump(getStrDump(), DumpCumulative);
} }
......
...@@ -48,6 +48,8 @@ public: ...@@ -48,6 +48,8 @@ public:
void updateSpills() { ++Spills; } void updateSpills() { ++Spills; }
void updateFills() { ++Fills; } void updateFills() { ++Fills; }
void dump(const IceString &Name, Ostream &Str) { void dump(const IceString &Name, Ostream &Str) {
if (!ALLOW_DUMP)
return;
Str << "|" << Name << "|Inst Count |" << InstructionsEmitted << "\n"; Str << "|" << Name << "|Inst Count |" << InstructionsEmitted << "\n";
Str << "|" << Name << "|Regs Saved |" << RegistersSaved << "\n"; Str << "|" << Name << "|Regs Saved |" << RegistersSaved << "\n";
Str << "|" << Name << "|Frame Bytes |" << FrameBytes << "\n"; Str << "|" << Name << "|Frame Bytes |" << FrameBytes << "\n";
......
...@@ -27,6 +27,8 @@ char hexdigit(unsigned X) { return X < 10 ? '0' + X : 'A' + X - 10; } ...@@ -27,6 +27,8 @@ char hexdigit(unsigned X) { return X < 10 ? '0' + X : 'A' + X - 10; }
void dumpLinkage(Ice::Ostream &Stream, void dumpLinkage(Ice::Ostream &Stream,
llvm::GlobalValue::LinkageTypes Linkage) { llvm::GlobalValue::LinkageTypes Linkage) {
if (!ALLOW_DUMP)
return;
switch (Linkage) { switch (Linkage) {
case llvm::GlobalValue::ExternalLinkage: case llvm::GlobalValue::ExternalLinkage:
Stream << "external"; Stream << "external";
...@@ -44,6 +46,8 @@ void dumpLinkage(Ice::Ostream &Stream, ...@@ -44,6 +46,8 @@ void dumpLinkage(Ice::Ostream &Stream,
} }
void dumpCallingConv(Ice::Ostream &, llvm::CallingConv::ID CallingConv) { void dumpCallingConv(Ice::Ostream &, llvm::CallingConv::ID CallingConv) {
if (!ALLOW_DUMP)
return;
if (CallingConv == llvm::CallingConv::C) if (CallingConv == llvm::CallingConv::C)
return; return;
std::string Buffer; std::string Buffer;
...@@ -65,10 +69,14 @@ FunctionDeclaration::create(GlobalContext *Ctx, const FuncSigType &Signature, ...@@ -65,10 +69,14 @@ FunctionDeclaration::create(GlobalContext *Ctx, const FuncSigType &Signature,
} }
void FunctionDeclaration::dumpType(Ostream &Stream) const { void FunctionDeclaration::dumpType(Ostream &Stream) const {
if (!ALLOW_DUMP)
return;
Stream << Signature; Stream << Signature;
} }
void FunctionDeclaration::dump(GlobalContext *Ctx, Ostream &Stream) const { void FunctionDeclaration::dump(GlobalContext *Ctx, Ostream &Stream) const {
if (!ALLOW_DUMP)
return;
if (IsProto) if (IsProto)
Stream << "declare "; Stream << "declare ";
::dumpLinkage(Stream, Linkage); ::dumpLinkage(Stream, Linkage);
...@@ -95,6 +103,8 @@ VariableDeclaration::~VariableDeclaration() { ...@@ -95,6 +103,8 @@ VariableDeclaration::~VariableDeclaration() {
} }
void VariableDeclaration::dumpType(Ostream &Stream) const { void VariableDeclaration::dumpType(Ostream &Stream) const {
if (!ALLOW_DUMP)
return;
if (Initializers.size() == 1) { if (Initializers.size() == 1) {
Initializers.front()->dumpType(Stream); Initializers.front()->dumpType(Stream);
} else { } else {
...@@ -113,6 +123,8 @@ void VariableDeclaration::dumpType(Ostream &Stream) const { ...@@ -113,6 +123,8 @@ void VariableDeclaration::dumpType(Ostream &Stream) const {
} }
void VariableDeclaration::dump(GlobalContext *Ctx, Ostream &Stream) const { void VariableDeclaration::dump(GlobalContext *Ctx, Ostream &Stream) const {
if (!ALLOW_DUMP)
return;
Stream << "@" << ((Ctx && !getSuppressMangling()) Stream << "@" << ((Ctx && !getSuppressMangling())
? Ctx->mangleName(Name) : Name) << " = "; ? Ctx->mangleName(Name) : Name) << " = ";
::dumpLinkage(Stream, Linkage); ::dumpLinkage(Stream, Linkage);
...@@ -143,11 +155,15 @@ void VariableDeclaration::dump(GlobalContext *Ctx, Ostream &Stream) const { ...@@ -143,11 +155,15 @@ void VariableDeclaration::dump(GlobalContext *Ctx, Ostream &Stream) const {
} }
void VariableDeclaration::Initializer::dumpType(Ostream &Stream) const { void VariableDeclaration::Initializer::dumpType(Ostream &Stream) const {
if (!ALLOW_DUMP)
return;
Stream << "[" << getNumBytes() << " x " << Ice::IceType_i8 << "]"; Stream << "[" << getNumBytes() << " x " << Ice::IceType_i8 << "]";
} }
void VariableDeclaration::DataInitializer::dump( void VariableDeclaration::DataInitializer::dump(
GlobalContext *, Ostream &Stream) const { GlobalContext *, Ostream &Stream) const {
if (!ALLOW_DUMP)
return;
dumpType(Stream); dumpType(Stream);
Stream << " c\""; Stream << " c\"";
// Code taken from PrintEscapedString() in AsmWriter.cpp. Keep // Code taken from PrintEscapedString() in AsmWriter.cpp. Keep
...@@ -164,16 +180,22 @@ void VariableDeclaration::DataInitializer::dump( ...@@ -164,16 +180,22 @@ void VariableDeclaration::DataInitializer::dump(
void VariableDeclaration::ZeroInitializer::dump( void VariableDeclaration::ZeroInitializer::dump(
GlobalContext *, Ostream &Stream) const { GlobalContext *, Ostream &Stream) const {
if (!ALLOW_DUMP)
return;
dumpType(Stream); dumpType(Stream);
Stream << " zeroinitializer"; Stream << " zeroinitializer";
} }
void VariableDeclaration::RelocInitializer::dumpType(Ostream &Stream) const { void VariableDeclaration::RelocInitializer::dumpType(Ostream &Stream) const {
if (!ALLOW_DUMP)
return;
Stream << Ice::IceType_i32; Stream << Ice::IceType_i32;
} }
void VariableDeclaration::RelocInitializer::dump( void VariableDeclaration::RelocInitializer::dump(
GlobalContext *Ctx, Ostream &Stream) const { GlobalContext *Ctx, Ostream &Stream) const {
if (!ALLOW_DUMP)
return;
if (Offset != 0) { if (Offset != 0) {
dumpType(Stream); dumpType(Stream);
Stream << " add ("; Stream << " add (";
......
...@@ -61,6 +61,8 @@ public: ...@@ -61,6 +61,8 @@ public:
/// Prints out the global declaration. /// Prints out the global declaration.
virtual void dump(GlobalContext *Ctx, Ostream &Stream) const = 0; virtual void dump(GlobalContext *Ctx, Ostream &Stream) const = 0;
void dump(Ostream &Stream) const { void dump(Ostream &Stream) const {
if (!ALLOW_DUMP)
return;
GlobalContext *const Ctx = nullptr; GlobalContext *const Ctx = nullptr;
dump(Ctx, Stream); dump(Ctx, Stream);
} }
...@@ -149,6 +151,7 @@ public: ...@@ -149,6 +151,7 @@ public:
virtual SizeT getNumBytes() const = 0; virtual SizeT getNumBytes() const = 0;
virtual void dump(GlobalContext *Ctx, Ostream &Stream) const = 0; virtual void dump(GlobalContext *Ctx, Ostream &Stream) const = 0;
void dump(Ostream &Stream) const { void dump(Ostream &Stream) const {
if (ALLOW_DUMP)
dump(nullptr, Stream); dump(nullptr, Stream);
} }
virtual void dumpType(Ostream &Stream) const; virtual void dumpType(Ostream &Stream) const;
......
...@@ -449,9 +449,17 @@ InstFakeUse::InstFakeUse(Cfg *Func, Variable *Src) ...@@ -449,9 +449,17 @@ InstFakeUse::InstFakeUse(Cfg *Func, Variable *Src)
InstFakeKill::InstFakeKill(Cfg *Func, const Inst *Linked) InstFakeKill::InstFakeKill(Cfg *Func, const Inst *Linked)
: InstHighLevel(Func, Inst::FakeKill, 0, NULL), Linked(Linked) {} : InstHighLevel(Func, Inst::FakeKill, 0, NULL), Linked(Linked) {}
Type InstCall::getReturnType() const {
if (Dest == NULL)
return IceType_void;
return Dest->getType();
}
// ======================== Dump routines ======================== // // ======================== Dump routines ======================== //
void Inst::dumpDecorated(const Cfg *Func) const { void Inst::dumpDecorated(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
if (!Func->getContext()->isVerbose(IceV_Deleted) && if (!Func->getContext()->isVerbose(IceV_Deleted) &&
(isDeleted() || isRedundantAssign())) (isDeleted() || isRedundantAssign()))
...@@ -474,6 +482,8 @@ void Inst::dumpDecorated(const Cfg *Func) const { ...@@ -474,6 +482,8 @@ void Inst::dumpDecorated(const Cfg *Func) const {
} }
void Inst::dump(const Cfg *Func) const { void Inst::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " =~ "; Str << " =~ ";
...@@ -481,6 +491,8 @@ void Inst::dump(const Cfg *Func) const { ...@@ -481,6 +491,8 @@ void Inst::dump(const Cfg *Func) const {
} }
void Inst::dumpExtras(const Cfg *Func) const { void Inst::dumpExtras(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
bool First = true; bool First = true;
// Print "LIVEEND={a,b,c}" for all source operands whose live ranges // Print "LIVEEND={a,b,c}" for all source operands whose live ranges
...@@ -507,6 +519,8 @@ void Inst::dumpExtras(const Cfg *Func) const { ...@@ -507,6 +519,8 @@ void Inst::dumpExtras(const Cfg *Func) const {
} }
void Inst::dumpSources(const Cfg *Func) const { void Inst::dumpSources(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
for (SizeT I = 0; I < getSrcSize(); ++I) { for (SizeT I = 0; I < getSrcSize(); ++I) {
if (I > 0) if (I > 0)
...@@ -516,6 +530,8 @@ void Inst::dumpSources(const Cfg *Func) const { ...@@ -516,6 +530,8 @@ void Inst::dumpSources(const Cfg *Func) const {
} }
void Inst::emitSources(const Cfg *Func) const { void Inst::emitSources(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
for (SizeT I = 0; I < getSrcSize(); ++I) { for (SizeT I = 0; I < getSrcSize(); ++I) {
if (I > 0) if (I > 0)
...@@ -525,11 +541,15 @@ void Inst::emitSources(const Cfg *Func) const { ...@@ -525,11 +541,15 @@ void Inst::emitSources(const Cfg *Func) const {
} }
void Inst::dumpDest(const Cfg *Func) const { void Inst::dumpDest(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
if (getDest()) if (getDest())
getDest()->dump(Func); getDest()->dump(Func);
} }
void InstAlloca::dump(const Cfg *Func) const { void InstAlloca::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = alloca i8, i32 "; Str << " = alloca i8, i32 ";
...@@ -539,6 +559,8 @@ void InstAlloca::dump(const Cfg *Func) const { ...@@ -539,6 +559,8 @@ void InstAlloca::dump(const Cfg *Func) const {
} }
void InstArithmetic::dump(const Cfg *Func) const { void InstArithmetic::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = " << InstArithmeticAttributes[getOp()].DisplayString << " " Str << " = " << InstArithmeticAttributes[getOp()].DisplayString << " "
...@@ -547,6 +569,8 @@ void InstArithmetic::dump(const Cfg *Func) const { ...@@ -547,6 +569,8 @@ void InstArithmetic::dump(const Cfg *Func) const {
} }
void InstAssign::dump(const Cfg *Func) const { void InstAssign::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = " << getDest()->getType() << " "; Str << " = " << getDest()->getType() << " ";
...@@ -554,6 +578,8 @@ void InstAssign::dump(const Cfg *Func) const { ...@@ -554,6 +578,8 @@ void InstAssign::dump(const Cfg *Func) const {
} }
void InstBr::dump(const Cfg *Func) const { void InstBr::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << "br "; Str << "br ";
...@@ -565,13 +591,9 @@ void InstBr::dump(const Cfg *Func) const { ...@@ -565,13 +591,9 @@ void InstBr::dump(const Cfg *Func) const {
Str << "label %" << getTargetFalse()->getName(); Str << "label %" << getTargetFalse()->getName();
} }
Type InstCall::getReturnType() const {
if (Dest == NULL)
return IceType_void;
return Dest->getType();
}
void InstCall::dump(const Cfg *Func) const { void InstCall::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
if (getDest()) { if (getDest()) {
dumpDest(Func); dumpDest(Func);
...@@ -595,6 +617,8 @@ void InstCall::dump(const Cfg *Func) const { ...@@ -595,6 +617,8 @@ void InstCall::dump(const Cfg *Func) const {
} }
void InstCast::dump(const Cfg *Func) const { void InstCast::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = " << InstCastAttributes[getCastKind()].DisplayString << " " Str << " = " << InstCastAttributes[getCastKind()].DisplayString << " "
...@@ -604,6 +628,8 @@ void InstCast::dump(const Cfg *Func) const { ...@@ -604,6 +628,8 @@ void InstCast::dump(const Cfg *Func) const {
} }
void InstIcmp::dump(const Cfg *Func) const { void InstIcmp::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = icmp " << InstIcmpAttributes[getCondition()].DisplayString << " " Str << " = icmp " << InstIcmpAttributes[getCondition()].DisplayString << " "
...@@ -612,6 +638,8 @@ void InstIcmp::dump(const Cfg *Func) const { ...@@ -612,6 +638,8 @@ void InstIcmp::dump(const Cfg *Func) const {
} }
void InstExtractElement::dump(const Cfg *Func) const { void InstExtractElement::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = extractelement "; Str << " = extractelement ";
...@@ -623,6 +651,8 @@ void InstExtractElement::dump(const Cfg *Func) const { ...@@ -623,6 +651,8 @@ void InstExtractElement::dump(const Cfg *Func) const {
} }
void InstInsertElement::dump(const Cfg *Func) const { void InstInsertElement::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = insertelement "; Str << " = insertelement ";
...@@ -637,6 +667,8 @@ void InstInsertElement::dump(const Cfg *Func) const { ...@@ -637,6 +667,8 @@ void InstInsertElement::dump(const Cfg *Func) const {
} }
void InstFcmp::dump(const Cfg *Func) const { void InstFcmp::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = fcmp " << InstFcmpAttributes[getCondition()].DisplayString << " " Str << " = fcmp " << InstFcmpAttributes[getCondition()].DisplayString << " "
...@@ -645,6 +677,8 @@ void InstFcmp::dump(const Cfg *Func) const { ...@@ -645,6 +677,8 @@ void InstFcmp::dump(const Cfg *Func) const {
} }
void InstLoad::dump(const Cfg *Func) const { void InstLoad::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Type Ty = getDest()->getType(); Type Ty = getDest()->getType();
...@@ -654,6 +688,8 @@ void InstLoad::dump(const Cfg *Func) const { ...@@ -654,6 +688,8 @@ void InstLoad::dump(const Cfg *Func) const {
} }
void InstStore::dump(const Cfg *Func) const { void InstStore::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Type Ty = getData()->getType(); Type Ty = getData()->getType();
Str << "store " << Ty << " "; Str << "store " << Ty << " ";
...@@ -664,6 +700,8 @@ void InstStore::dump(const Cfg *Func) const { ...@@ -664,6 +700,8 @@ void InstStore::dump(const Cfg *Func) const {
} }
void InstSwitch::dump(const Cfg *Func) const { void InstSwitch::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Type Ty = getComparison()->getType(); Type Ty = getComparison()->getType();
Str << "switch " << Ty << " "; Str << "switch " << Ty << " ";
...@@ -677,6 +715,8 @@ void InstSwitch::dump(const Cfg *Func) const { ...@@ -677,6 +715,8 @@ void InstSwitch::dump(const Cfg *Func) const {
} }
void InstPhi::dump(const Cfg *Func) const { void InstPhi::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = phi " << getDest()->getType() << " "; Str << " = phi " << getDest()->getType() << " ";
...@@ -690,6 +730,8 @@ void InstPhi::dump(const Cfg *Func) const { ...@@ -690,6 +730,8 @@ void InstPhi::dump(const Cfg *Func) const {
} }
void InstRet::dump(const Cfg *Func) const { void InstRet::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Type Ty = hasRetValue() ? getRetValue()->getType() : IceType_void; Type Ty = hasRetValue() ? getRetValue()->getType() : IceType_void;
Str << "ret " << Ty; Str << "ret " << Ty;
...@@ -700,6 +742,8 @@ void InstRet::dump(const Cfg *Func) const { ...@@ -700,6 +742,8 @@ void InstRet::dump(const Cfg *Func) const {
} }
void InstSelect::dump(const Cfg *Func) const { void InstSelect::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Operand *Condition = getCondition(); Operand *Condition = getCondition();
...@@ -714,11 +758,15 @@ void InstSelect::dump(const Cfg *Func) const { ...@@ -714,11 +758,15 @@ void InstSelect::dump(const Cfg *Func) const {
} }
void InstUnreachable::dump(const Cfg *Func) const { void InstUnreachable::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Str << "unreachable"; Str << "unreachable";
} }
void InstFakeDef::emit(const Cfg *Func) const { void InstFakeDef::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
// Go ahead and "emit" these for now, since they are relatively // Go ahead and "emit" these for now, since they are relatively
// rare. // rare.
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
...@@ -729,6 +777,8 @@ void InstFakeDef::emit(const Cfg *Func) const { ...@@ -729,6 +777,8 @@ void InstFakeDef::emit(const Cfg *Func) const {
} }
void InstFakeDef::dump(const Cfg *Func) const { void InstFakeDef::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = def.pseudo "; Str << " = def.pseudo ";
...@@ -738,6 +788,8 @@ void InstFakeDef::dump(const Cfg *Func) const { ...@@ -738,6 +788,8 @@ void InstFakeDef::dump(const Cfg *Func) const {
void InstFakeUse::emit(const Cfg *Func) const { (void)Func; } void InstFakeUse::emit(const Cfg *Func) const { (void)Func; }
void InstFakeUse::dump(const Cfg *Func) const { void InstFakeUse::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Str << "use.pseudo "; Str << "use.pseudo ";
dumpSources(Func); dumpSources(Func);
...@@ -746,6 +798,8 @@ void InstFakeUse::dump(const Cfg *Func) const { ...@@ -746,6 +798,8 @@ void InstFakeUse::dump(const Cfg *Func) const {
void InstFakeKill::emit(const Cfg *Func) const { (void)Func; } void InstFakeKill::emit(const Cfg *Func) const { (void)Func; }
void InstFakeKill::dump(const Cfg *Func) const { void InstFakeKill::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
if (Linked->isDeleted()) if (Linked->isDeleted())
Str << "// "; Str << "// ";
...@@ -753,6 +807,8 @@ void InstFakeKill::dump(const Cfg *Func) const { ...@@ -753,6 +807,8 @@ void InstFakeKill::dump(const Cfg *Func) const {
} }
void InstTarget::dump(const Cfg *Func) const { void InstTarget::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Str << "[TARGET] "; Str << "[TARGET] ";
Inst::dump(Func); Inst::dump(Func);
......
...@@ -838,8 +838,8 @@ protected: ...@@ -838,8 +838,8 @@ protected:
// Override the default ilist traits so that Inst's private ctor and // Override the default ilist traits so that Inst's private ctor and
// deleted dtor aren't invoked. // deleted dtor aren't invoked.
template <> template <>
struct llvm::ilist_traits<Ice::Inst> : public llvm::ilist_default_traits< struct llvm::ilist_traits<Ice::Inst>
Ice::Inst> { : public llvm::ilist_default_traits<Ice::Inst> {
Ice::Inst *createSentinel() const { Ice::Inst *createSentinel() const {
return static_cast<Ice::Inst *>(&Sentinel); return static_cast<Ice::Inst *>(&Sentinel);
} }
......
...@@ -343,12 +343,16 @@ InstX8632Xchg::InstX8632Xchg(Cfg *Func, Operand *Dest, Variable *Source) ...@@ -343,12 +343,16 @@ InstX8632Xchg::InstX8632Xchg(Cfg *Func, Operand *Dest, Variable *Source)
// ======================== Dump routines ======================== // // ======================== Dump routines ======================== //
void InstX8632::dump(const Cfg *Func) const { void InstX8632::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Str << "[X8632] "; Str << "[X8632] ";
Inst::dump(Func); Inst::dump(Func);
} }
void InstX8632Label::emit(const Cfg *Func) const { void InstX8632Label::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
Str << getName(Func) << ":"; Str << getName(Func) << ":";
} }
...@@ -359,11 +363,15 @@ void InstX8632Label::emitIAS(const Cfg *Func) const { ...@@ -359,11 +363,15 @@ void InstX8632Label::emitIAS(const Cfg *Func) const {
} }
void InstX8632Label::dump(const Cfg *Func) const { void InstX8632Label::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Str << getName(Func) << ":"; Str << getName(Func) << ":";
} }
void InstX8632Br::emit(const Cfg *Func) const { void InstX8632Br::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
Str << "\t"; Str << "\t";
...@@ -420,6 +428,8 @@ void InstX8632Br::emitIAS(const Cfg *Func) const { ...@@ -420,6 +428,8 @@ void InstX8632Br::emitIAS(const Cfg *Func) const {
} }
void InstX8632Br::dump(const Cfg *Func) const { void InstX8632Br::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Str << "br "; Str << "br ";
...@@ -441,6 +451,8 @@ void InstX8632Br::dump(const Cfg *Func) const { ...@@ -441,6 +451,8 @@ void InstX8632Br::dump(const Cfg *Func) const {
} }
void InstX8632Call::emit(const Cfg *Func) const { void InstX8632Call::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1); assert(getSrcSize() == 1);
Str << "\tcall\t"; Str << "\tcall\t";
...@@ -489,6 +501,8 @@ void InstX8632Call::emitIAS(const Cfg *Func) const { ...@@ -489,6 +501,8 @@ void InstX8632Call::emitIAS(const Cfg *Func) const {
} }
void InstX8632Call::dump(const Cfg *Func) const { void InstX8632Call::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
if (getDest()) { if (getDest()) {
dumpDest(Func); dumpDest(Func);
...@@ -504,6 +518,8 @@ void InstX8632Call::dump(const Cfg *Func) const { ...@@ -504,6 +518,8 @@ void InstX8632Call::dump(const Cfg *Func) const {
// template issues. // template issues.
void emitTwoAddress(const char *Opcode, const Inst *Inst, const Cfg *Func, void emitTwoAddress(const char *Opcode, const Inst *Inst, const Cfg *Func,
bool ShiftHack) { bool ShiftHack) {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(Inst->getSrcSize() == 2); assert(Inst->getSrcSize() == 2);
Variable *Dest = Inst->getDest(); Variable *Dest = Inst->getDest();
...@@ -1036,6 +1052,8 @@ const x86::AssemblerX86::XmmEmitterShiftOp InstX8632Psra::Emitter = { ...@@ -1036,6 +1052,8 @@ const x86::AssemblerX86::XmmEmitterShiftOp InstX8632Psra::Emitter = {
&x86::AssemblerX86::psra}; &x86::AssemblerX86::psra};
template <> void InstX8632Sqrtss::emit(const Cfg *Func) const { template <> void InstX8632Sqrtss::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1); assert(getSrcSize() == 1);
Type Ty = getSrc(0)->getType(); Type Ty = getSrc(0)->getType();
...@@ -1047,6 +1065,8 @@ template <> void InstX8632Sqrtss::emit(const Cfg *Func) const { ...@@ -1047,6 +1065,8 @@ template <> void InstX8632Sqrtss::emit(const Cfg *Func) const {
} }
template <> void InstX8632Addss::emit(const Cfg *Func) const { template <> void InstX8632Addss::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
char buf[30]; char buf[30];
snprintf(buf, llvm::array_lengthof(buf), "add%s", snprintf(buf, llvm::array_lengthof(buf), "add%s",
TypeX8632Attributes[getDest()->getType()].SdSsString); TypeX8632Attributes[getDest()->getType()].SdSsString);
...@@ -1054,6 +1074,8 @@ template <> void InstX8632Addss::emit(const Cfg *Func) const { ...@@ -1054,6 +1074,8 @@ template <> void InstX8632Addss::emit(const Cfg *Func) const {
} }
template <> void InstX8632Padd::emit(const Cfg *Func) const { template <> void InstX8632Padd::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
char buf[30]; char buf[30];
snprintf(buf, llvm::array_lengthof(buf), "padd%s", snprintf(buf, llvm::array_lengthof(buf), "padd%s",
TypeX8632Attributes[getDest()->getType()].PackString); TypeX8632Attributes[getDest()->getType()].PackString);
...@@ -1061,6 +1083,8 @@ template <> void InstX8632Padd::emit(const Cfg *Func) const { ...@@ -1061,6 +1083,8 @@ template <> void InstX8632Padd::emit(const Cfg *Func) const {
} }
template <> void InstX8632Pmull::emit(const Cfg *Func) const { template <> void InstX8632Pmull::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
char buf[30]; char buf[30];
bool TypesAreValid = getDest()->getType() == IceType_v4i32 || bool TypesAreValid = getDest()->getType() == IceType_v4i32 ||
getDest()->getType() == IceType_v8i16; getDest()->getType() == IceType_v8i16;
...@@ -1094,6 +1118,8 @@ template <> void InstX8632Pmull::emitIAS(const Cfg *Func) const { ...@@ -1094,6 +1118,8 @@ template <> void InstX8632Pmull::emitIAS(const Cfg *Func) const {
} }
template <> void InstX8632Subss::emit(const Cfg *Func) const { template <> void InstX8632Subss::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
char buf[30]; char buf[30];
snprintf(buf, llvm::array_lengthof(buf), "sub%s", snprintf(buf, llvm::array_lengthof(buf), "sub%s",
TypeX8632Attributes[getDest()->getType()].SdSsString); TypeX8632Attributes[getDest()->getType()].SdSsString);
...@@ -1101,6 +1127,8 @@ template <> void InstX8632Subss::emit(const Cfg *Func) const { ...@@ -1101,6 +1127,8 @@ template <> void InstX8632Subss::emit(const Cfg *Func) const {
} }
template <> void InstX8632Psub::emit(const Cfg *Func) const { template <> void InstX8632Psub::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
char buf[30]; char buf[30];
snprintf(buf, llvm::array_lengthof(buf), "psub%s", snprintf(buf, llvm::array_lengthof(buf), "psub%s",
TypeX8632Attributes[getDest()->getType()].PackString); TypeX8632Attributes[getDest()->getType()].PackString);
...@@ -1108,6 +1136,8 @@ template <> void InstX8632Psub::emit(const Cfg *Func) const { ...@@ -1108,6 +1136,8 @@ template <> void InstX8632Psub::emit(const Cfg *Func) const {
} }
template <> void InstX8632Mulss::emit(const Cfg *Func) const { template <> void InstX8632Mulss::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
char buf[30]; char buf[30];
snprintf(buf, llvm::array_lengthof(buf), "mul%s", snprintf(buf, llvm::array_lengthof(buf), "mul%s",
TypeX8632Attributes[getDest()->getType()].SdSsString); TypeX8632Attributes[getDest()->getType()].SdSsString);
...@@ -1115,12 +1145,16 @@ template <> void InstX8632Mulss::emit(const Cfg *Func) const { ...@@ -1115,12 +1145,16 @@ template <> void InstX8632Mulss::emit(const Cfg *Func) const {
} }
template <> void InstX8632Pmuludq::emit(const Cfg *Func) const { template <> void InstX8632Pmuludq::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
assert(getSrc(0)->getType() == IceType_v4i32 && assert(getSrc(0)->getType() == IceType_v4i32 &&
getSrc(1)->getType() == IceType_v4i32); getSrc(1)->getType() == IceType_v4i32);
emitTwoAddress(Opcode, this, Func); emitTwoAddress(Opcode, this, Func);
} }
template <> void InstX8632Divss::emit(const Cfg *Func) const { template <> void InstX8632Divss::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
char buf[30]; char buf[30];
snprintf(buf, llvm::array_lengthof(buf), "div%s", snprintf(buf, llvm::array_lengthof(buf), "div%s",
TypeX8632Attributes[getDest()->getType()].SdSsString); TypeX8632Attributes[getDest()->getType()].SdSsString);
...@@ -1128,6 +1162,8 @@ template <> void InstX8632Divss::emit(const Cfg *Func) const { ...@@ -1128,6 +1162,8 @@ template <> void InstX8632Divss::emit(const Cfg *Func) const {
} }
template <> void InstX8632Div::emit(const Cfg *Func) const { template <> void InstX8632Div::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 3); assert(getSrcSize() == 3);
Operand *Src1 = getSrc(1); Operand *Src1 = getSrc(1);
...@@ -1145,6 +1181,8 @@ template <> void InstX8632Div::emitIAS(const Cfg *Func) const { ...@@ -1145,6 +1181,8 @@ template <> void InstX8632Div::emitIAS(const Cfg *Func) const {
} }
template <> void InstX8632Idiv::emit(const Cfg *Func) const { template <> void InstX8632Idiv::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 3); assert(getSrcSize() == 3);
Operand *Src1 = getSrc(1); Operand *Src1 = getSrc(1);
...@@ -1166,6 +1204,8 @@ namespace { ...@@ -1166,6 +1204,8 @@ namespace {
// pblendvb and blendvps take xmm0 as a final implicit argument. // pblendvb and blendvps take xmm0 as a final implicit argument.
void emitVariableBlendInst(const char *Opcode, const Inst *Inst, void emitVariableBlendInst(const char *Opcode, const Inst *Inst,
const Cfg *Func) { const Cfg *Func) {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(Inst->getSrcSize() == 3); assert(Inst->getSrcSize() == 3);
assert(llvm::cast<Variable>(Inst->getSrc(2))->getRegNum() == assert(llvm::cast<Variable>(Inst->getSrc(2))->getRegNum() ==
...@@ -1190,6 +1230,8 @@ emitIASVariableBlendInst(const Inst *Inst, const Cfg *Func, ...@@ -1190,6 +1230,8 @@ emitIASVariableBlendInst(const Inst *Inst, const Cfg *Func,
} // end anonymous namespace } // end anonymous namespace
template <> void InstX8632Blendvps::emit(const Cfg *Func) const { template <> void InstX8632Blendvps::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
assert(static_cast<TargetX8632 *>(Func->getTarget())->getInstructionSet() >= assert(static_cast<TargetX8632 *>(Func->getTarget())->getInstructionSet() >=
TargetX8632::SSE4_1); TargetX8632::SSE4_1);
emitVariableBlendInst(Opcode, this, Func); emitVariableBlendInst(Opcode, this, Func);
...@@ -1204,6 +1246,8 @@ template <> void InstX8632Blendvps::emitIAS(const Cfg *Func) const { ...@@ -1204,6 +1246,8 @@ template <> void InstX8632Blendvps::emitIAS(const Cfg *Func) const {
} }
template <> void InstX8632Pblendvb::emit(const Cfg *Func) const { template <> void InstX8632Pblendvb::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
assert(static_cast<TargetX8632 *>(Func->getTarget())->getInstructionSet() >= assert(static_cast<TargetX8632 *>(Func->getTarget())->getInstructionSet() >=
TargetX8632::SSE4_1); TargetX8632::SSE4_1);
emitVariableBlendInst(Opcode, this, Func); emitVariableBlendInst(Opcode, this, Func);
...@@ -1218,6 +1262,8 @@ template <> void InstX8632Pblendvb::emitIAS(const Cfg *Func) const { ...@@ -1218,6 +1262,8 @@ template <> void InstX8632Pblendvb::emitIAS(const Cfg *Func) const {
} }
template <> void InstX8632Imul::emit(const Cfg *Func) const { template <> void InstX8632Imul::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 2); assert(getSrcSize() == 2);
Variable *Dest = getDest(); Variable *Dest = getDest();
...@@ -1280,6 +1326,8 @@ template <> void InstX8632Insertps::emitIAS(const Cfg *Func) const { ...@@ -1280,6 +1326,8 @@ template <> void InstX8632Insertps::emitIAS(const Cfg *Func) const {
} }
template <> void InstX8632Cbwdq::emit(const Cfg *Func) const { template <> void InstX8632Cbwdq::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1); assert(getSrcSize() == 1);
Operand *Src0 = getSrc(0); Operand *Src0 = getSrc(0);
...@@ -1330,6 +1378,8 @@ template <> void InstX8632Cbwdq::emitIAS(const Cfg *Func) const { ...@@ -1330,6 +1378,8 @@ template <> void InstX8632Cbwdq::emitIAS(const Cfg *Func) const {
} }
void InstX8632Mul::emit(const Cfg *Func) const { void InstX8632Mul::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 2); assert(getSrcSize() == 2);
assert(llvm::isa<Variable>(getSrc(0))); assert(llvm::isa<Variable>(getSrc(0)));
...@@ -1352,6 +1402,8 @@ void InstX8632Mul::emitIAS(const Cfg *Func) const { ...@@ -1352,6 +1402,8 @@ void InstX8632Mul::emitIAS(const Cfg *Func) const {
} }
void InstX8632Mul::dump(const Cfg *Func) const { void InstX8632Mul::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = mul." << getDest()->getType() << " "; Str << " = mul." << getDest()->getType() << " ";
...@@ -1359,6 +1411,8 @@ void InstX8632Mul::dump(const Cfg *Func) const { ...@@ -1359,6 +1411,8 @@ void InstX8632Mul::dump(const Cfg *Func) const {
} }
void InstX8632Shld::emit(const Cfg *Func) const { void InstX8632Shld::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
Variable *Dest = getDest(); Variable *Dest = getDest();
assert(getSrcSize() == 3); assert(getSrcSize() == 3);
...@@ -1389,6 +1443,8 @@ void InstX8632Shld::emitIAS(const Cfg *Func) const { ...@@ -1389,6 +1443,8 @@ void InstX8632Shld::emitIAS(const Cfg *Func) const {
} }
void InstX8632Shld::dump(const Cfg *Func) const { void InstX8632Shld::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = shld." << getDest()->getType() << " "; Str << " = shld." << getDest()->getType() << " ";
...@@ -1396,6 +1452,8 @@ void InstX8632Shld::dump(const Cfg *Func) const { ...@@ -1396,6 +1452,8 @@ void InstX8632Shld::dump(const Cfg *Func) const {
} }
void InstX8632Shrd::emit(const Cfg *Func) const { void InstX8632Shrd::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
Variable *Dest = getDest(); Variable *Dest = getDest();
assert(getSrcSize() == 3); assert(getSrcSize() == 3);
...@@ -1426,6 +1484,8 @@ void InstX8632Shrd::emitIAS(const Cfg *Func) const { ...@@ -1426,6 +1484,8 @@ void InstX8632Shrd::emitIAS(const Cfg *Func) const {
} }
void InstX8632Shrd::dump(const Cfg *Func) const { void InstX8632Shrd::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = shrd." << getDest()->getType() << " "; Str << " = shrd." << getDest()->getType() << " ";
...@@ -1433,6 +1493,8 @@ void InstX8632Shrd::dump(const Cfg *Func) const { ...@@ -1433,6 +1493,8 @@ void InstX8632Shrd::dump(const Cfg *Func) const {
} }
void InstX8632Cmov::emit(const Cfg *Func) const { void InstX8632Cmov::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
Variable *Dest = getDest(); Variable *Dest = getDest();
Str << "\t"; Str << "\t";
...@@ -1459,6 +1521,8 @@ void InstX8632Cmov::emitIAS(const Cfg *Func) const { ...@@ -1459,6 +1521,8 @@ void InstX8632Cmov::emitIAS(const Cfg *Func) const {
} }
void InstX8632Cmov::dump(const Cfg *Func) const { void InstX8632Cmov::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Str << "cmov" << InstX8632BrAttributes[Condition].DisplayString << "."; Str << "cmov" << InstX8632BrAttributes[Condition].DisplayString << ".";
Str << getDest()->getType() << " "; Str << getDest()->getType() << " ";
...@@ -1468,6 +1532,8 @@ void InstX8632Cmov::dump(const Cfg *Func) const { ...@@ -1468,6 +1532,8 @@ void InstX8632Cmov::dump(const Cfg *Func) const {
} }
void InstX8632Cmpps::emit(const Cfg *Func) const { void InstX8632Cmpps::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 2); assert(getSrcSize() == 2);
assert(Condition < CondX86::Cmpps_Invalid); assert(Condition < CondX86::Cmpps_Invalid);
...@@ -1499,6 +1565,8 @@ void InstX8632Cmpps::emitIAS(const Cfg *Func) const { ...@@ -1499,6 +1565,8 @@ void InstX8632Cmpps::emitIAS(const Cfg *Func) const {
} }
void InstX8632Cmpps::dump(const Cfg *Func) const { void InstX8632Cmpps::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
assert(Condition < CondX86::Cmpps_Invalid); assert(Condition < CondX86::Cmpps_Invalid);
dumpDest(Func); dumpDest(Func);
...@@ -1508,6 +1576,8 @@ void InstX8632Cmpps::dump(const Cfg *Func) const { ...@@ -1508,6 +1576,8 @@ void InstX8632Cmpps::dump(const Cfg *Func) const {
} }
void InstX8632Cmpxchg::emit(const Cfg *Func) const { void InstX8632Cmpxchg::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 3); assert(getSrcSize() == 3);
if (Locked) { if (Locked) {
...@@ -1538,6 +1608,8 @@ void InstX8632Cmpxchg::emitIAS(const Cfg *Func) const { ...@@ -1538,6 +1608,8 @@ void InstX8632Cmpxchg::emitIAS(const Cfg *Func) const {
} }
void InstX8632Cmpxchg::dump(const Cfg *Func) const { void InstX8632Cmpxchg::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
if (Locked) { if (Locked) {
Str << "lock "; Str << "lock ";
...@@ -1547,6 +1619,8 @@ void InstX8632Cmpxchg::dump(const Cfg *Func) const { ...@@ -1547,6 +1619,8 @@ void InstX8632Cmpxchg::dump(const Cfg *Func) const {
} }
void InstX8632Cmpxchg8b::emit(const Cfg *Func) const { void InstX8632Cmpxchg8b::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 5); assert(getSrcSize() == 5);
if (Locked) { if (Locked) {
...@@ -1569,6 +1643,8 @@ void InstX8632Cmpxchg8b::emitIAS(const Cfg *Func) const { ...@@ -1569,6 +1643,8 @@ void InstX8632Cmpxchg8b::emitIAS(const Cfg *Func) const {
} }
void InstX8632Cmpxchg8b::dump(const Cfg *Func) const { void InstX8632Cmpxchg8b::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
if (Locked) { if (Locked) {
Str << "lock "; Str << "lock ";
...@@ -1578,6 +1654,8 @@ void InstX8632Cmpxchg8b::dump(const Cfg *Func) const { ...@@ -1578,6 +1654,8 @@ void InstX8632Cmpxchg8b::dump(const Cfg *Func) const {
} }
void InstX8632Cvt::emit(const Cfg *Func) const { void InstX8632Cvt::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1); assert(getSrcSize() == 1);
Str << "\tcvt"; Str << "\tcvt";
...@@ -1650,6 +1728,8 @@ void InstX8632Cvt::emitIAS(const Cfg *Func) const { ...@@ -1650,6 +1728,8 @@ void InstX8632Cvt::emitIAS(const Cfg *Func) const {
} }
void InstX8632Cvt::dump(const Cfg *Func) const { void InstX8632Cvt::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = cvt"; Str << " = cvt";
...@@ -1661,6 +1741,8 @@ void InstX8632Cvt::dump(const Cfg *Func) const { ...@@ -1661,6 +1741,8 @@ void InstX8632Cvt::dump(const Cfg *Func) const {
} }
void InstX8632Icmp::emit(const Cfg *Func) const { void InstX8632Icmp::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 2); assert(getSrcSize() == 2);
Str << "\tcmp" << getWidthString(getSrc(0)->getType()) << "\t"; Str << "\tcmp" << getWidthString(getSrc(0)->getType()) << "\t";
...@@ -1690,12 +1772,16 @@ void InstX8632Icmp::emitIAS(const Cfg *Func) const { ...@@ -1690,12 +1772,16 @@ void InstX8632Icmp::emitIAS(const Cfg *Func) const {
} }
void InstX8632Icmp::dump(const Cfg *Func) const { void InstX8632Icmp::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Str << "cmp." << getSrc(0)->getType() << " "; Str << "cmp." << getSrc(0)->getType() << " ";
dumpSources(Func); dumpSources(Func);
} }
void InstX8632Ucomiss::emit(const Cfg *Func) const { void InstX8632Ucomiss::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 2); assert(getSrcSize() == 2);
Str << "\tucomi" << TypeX8632Attributes[getSrc(0)->getType()].SdSsString Str << "\tucomi" << TypeX8632Attributes[getSrc(0)->getType()].SdSsString
...@@ -1719,12 +1805,16 @@ void InstX8632Ucomiss::emitIAS(const Cfg *Func) const { ...@@ -1719,12 +1805,16 @@ void InstX8632Ucomiss::emitIAS(const Cfg *Func) const {
} }
void InstX8632Ucomiss::dump(const Cfg *Func) const { void InstX8632Ucomiss::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Str << "ucomiss." << getSrc(0)->getType() << " "; Str << "ucomiss." << getSrc(0)->getType() << " ";
dumpSources(Func); dumpSources(Func);
} }
void InstX8632UD2::emit(const Cfg *Func) const { void InstX8632UD2::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 0); assert(getSrcSize() == 0);
Str << "\tud2"; Str << "\tud2";
...@@ -1736,11 +1826,15 @@ void InstX8632UD2::emitIAS(const Cfg *Func) const { ...@@ -1736,11 +1826,15 @@ void InstX8632UD2::emitIAS(const Cfg *Func) const {
} }
void InstX8632UD2::dump(const Cfg *Func) const { void InstX8632UD2::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Str << "ud2\n"; Str << "ud2\n";
} }
void InstX8632Test::emit(const Cfg *Func) const { void InstX8632Test::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 2); assert(getSrcSize() == 2);
Str << "\ttest" << getWidthString(getSrc(0)->getType()) << "\t"; Str << "\ttest" << getWidthString(getSrc(0)->getType()) << "\t";
...@@ -1771,12 +1865,16 @@ void InstX8632Test::emitIAS(const Cfg *Func) const { ...@@ -1771,12 +1865,16 @@ void InstX8632Test::emitIAS(const Cfg *Func) const {
} }
void InstX8632Test::dump(const Cfg *Func) const { void InstX8632Test::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Str << "test." << getSrc(0)->getType() << " "; Str << "test." << getSrc(0)->getType() << " ";
dumpSources(Func); dumpSources(Func);
} }
void InstX8632Mfence::emit(const Cfg *Func) const { void InstX8632Mfence::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 0); assert(getSrcSize() == 0);
Str << "\tmfence"; Str << "\tmfence";
...@@ -1788,11 +1886,15 @@ void InstX8632Mfence::emitIAS(const Cfg *Func) const { ...@@ -1788,11 +1886,15 @@ void InstX8632Mfence::emitIAS(const Cfg *Func) const {
} }
void InstX8632Mfence::dump(const Cfg *Func) const { void InstX8632Mfence::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Str << "mfence\n"; Str << "mfence\n";
} }
void InstX8632Store::emit(const Cfg *Func) const { void InstX8632Store::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 2); assert(getSrcSize() == 2);
Type Ty = getSrc(0)->getType(); Type Ty = getSrc(0)->getType();
...@@ -1834,6 +1936,8 @@ void InstX8632Store::emitIAS(const Cfg *Func) const { ...@@ -1834,6 +1936,8 @@ void InstX8632Store::emitIAS(const Cfg *Func) const {
} }
void InstX8632Store::dump(const Cfg *Func) const { void InstX8632Store::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Str << "mov." << getSrc(0)->getType() << " "; Str << "mov." << getSrc(0)->getType() << " ";
getSrc(1)->dump(Func); getSrc(1)->dump(Func);
...@@ -1842,6 +1946,8 @@ void InstX8632Store::dump(const Cfg *Func) const { ...@@ -1842,6 +1946,8 @@ void InstX8632Store::dump(const Cfg *Func) const {
} }
void InstX8632StoreP::emit(const Cfg *Func) const { void InstX8632StoreP::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 2); assert(getSrcSize() == 2);
Str << "\tmovups\t"; Str << "\tmovups\t";
...@@ -1862,6 +1968,8 @@ void InstX8632StoreP::emitIAS(const Cfg *Func) const { ...@@ -1862,6 +1968,8 @@ void InstX8632StoreP::emitIAS(const Cfg *Func) const {
} }
void InstX8632StoreP::dump(const Cfg *Func) const { void InstX8632StoreP::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Str << "storep." << getSrc(0)->getType() << " "; Str << "storep." << getSrc(0)->getType() << " ";
getSrc(1)->dump(Func); getSrc(1)->dump(Func);
...@@ -1870,6 +1978,8 @@ void InstX8632StoreP::dump(const Cfg *Func) const { ...@@ -1870,6 +1978,8 @@ void InstX8632StoreP::dump(const Cfg *Func) const {
} }
void InstX8632StoreQ::emit(const Cfg *Func) const { void InstX8632StoreQ::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 2); assert(getSrcSize() == 2);
assert(getSrc(1)->getType() == IceType_i64 || assert(getSrc(1)->getType() == IceType_i64 ||
...@@ -1892,6 +2002,8 @@ void InstX8632StoreQ::emitIAS(const Cfg *Func) const { ...@@ -1892,6 +2002,8 @@ void InstX8632StoreQ::emitIAS(const Cfg *Func) const {
} }
void InstX8632StoreQ::dump(const Cfg *Func) const { void InstX8632StoreQ::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Str << "storeq." << getSrc(0)->getType() << " "; Str << "storeq." << getSrc(0)->getType() << " ";
getSrc(1)->dump(Func); getSrc(1)->dump(Func);
...@@ -1900,6 +2012,8 @@ void InstX8632StoreQ::dump(const Cfg *Func) const { ...@@ -1900,6 +2012,8 @@ void InstX8632StoreQ::dump(const Cfg *Func) const {
} }
template <> void InstX8632Lea::emit(const Cfg *Func) const { template <> void InstX8632Lea::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1); assert(getSrcSize() == 1);
assert(getDest()->hasReg()); assert(getDest()->hasReg());
...@@ -1918,6 +2032,8 @@ template <> void InstX8632Lea::emit(const Cfg *Func) const { ...@@ -1918,6 +2032,8 @@ template <> void InstX8632Lea::emit(const Cfg *Func) const {
} }
template <> void InstX8632Mov::emit(const Cfg *Func) const { template <> void InstX8632Mov::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1); assert(getSrcSize() == 1);
Operand *Src = getSrc(0); Operand *Src = getSrc(0);
...@@ -2046,6 +2162,8 @@ template <> void InstX8632Movd::emitIAS(const Cfg *Func) const { ...@@ -2046,6 +2162,8 @@ template <> void InstX8632Movd::emitIAS(const Cfg *Func) const {
} }
template <> void InstX8632Movp::emit(const Cfg *Func) const { template <> void InstX8632Movp::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
// TODO(wala,stichnot): movups works with all vector operands, but // TODO(wala,stichnot): movups works with all vector operands, but
// there exist other instructions (movaps, movdqa, movdqu) that may // there exist other instructions (movaps, movdqa, movdqu) that may
// perform better, depending on the data type and alignment of the // perform better, depending on the data type and alignment of the
...@@ -2071,6 +2189,8 @@ template <> void InstX8632Movp::emitIAS(const Cfg *Func) const { ...@@ -2071,6 +2189,8 @@ template <> void InstX8632Movp::emitIAS(const Cfg *Func) const {
} }
template <> void InstX8632Movq::emit(const Cfg *Func) const { template <> void InstX8632Movq::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1); assert(getSrcSize() == 1);
assert(getDest()->getType() == IceType_i64 || assert(getDest()->getType() == IceType_i64 ||
...@@ -2130,6 +2250,8 @@ template <> void InstX8632Movzx::emitIAS(const Cfg *Func) const { ...@@ -2130,6 +2250,8 @@ template <> void InstX8632Movzx::emitIAS(const Cfg *Func) const {
} }
void InstX8632Nop::emit(const Cfg *Func) const { void InstX8632Nop::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
// TODO: Emit the right code for each variant. // TODO: Emit the right code for each variant.
Str << "\tnop\t# variant = " << Variant; Str << "\tnop\t# variant = " << Variant;
...@@ -2142,11 +2264,15 @@ void InstX8632Nop::emitIAS(const Cfg *Func) const { ...@@ -2142,11 +2264,15 @@ void InstX8632Nop::emitIAS(const Cfg *Func) const {
} }
void InstX8632Nop::dump(const Cfg *Func) const { void InstX8632Nop::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Str << "nop (variant = " << Variant << ")"; Str << "nop (variant = " << Variant << ")";
} }
void InstX8632Fld::emit(const Cfg *Func) const { void InstX8632Fld::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1); assert(getSrcSize() == 1);
Type Ty = getSrc(0)->getType(); Type Ty = getSrc(0)->getType();
...@@ -2200,12 +2326,16 @@ void InstX8632Fld::emitIAS(const Cfg *Func) const { ...@@ -2200,12 +2326,16 @@ void InstX8632Fld::emitIAS(const Cfg *Func) const {
} }
void InstX8632Fld::dump(const Cfg *Func) const { void InstX8632Fld::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Str << "fld." << getSrc(0)->getType() << " "; Str << "fld." << getSrc(0)->getType() << " ";
dumpSources(Func); dumpSources(Func);
} }
void InstX8632Fstp::emit(const Cfg *Func) const { void InstX8632Fstp::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 0); assert(getSrcSize() == 0);
// TODO(jvoung,stichnot): Utilize this by setting Dest to nullptr to // TODO(jvoung,stichnot): Utilize this by setting Dest to nullptr to
...@@ -2269,6 +2399,8 @@ void InstX8632Fstp::emitIAS(const Cfg *Func) const { ...@@ -2269,6 +2399,8 @@ void InstX8632Fstp::emitIAS(const Cfg *Func) const {
} }
void InstX8632Fstp::dump(const Cfg *Func) const { void InstX8632Fstp::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = fstp." << getDest()->getType() << ", st(0)"; Str << " = fstp." << getDest()->getType() << ", st(0)";
...@@ -2276,6 +2408,8 @@ void InstX8632Fstp::dump(const Cfg *Func) const { ...@@ -2276,6 +2408,8 @@ void InstX8632Fstp::dump(const Cfg *Func) const {
} }
template <> void InstX8632Pcmpeq::emit(const Cfg *Func) const { template <> void InstX8632Pcmpeq::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
char buf[30]; char buf[30];
snprintf(buf, llvm::array_lengthof(buf), "pcmpeq%s", snprintf(buf, llvm::array_lengthof(buf), "pcmpeq%s",
TypeX8632Attributes[getDest()->getType()].PackString); TypeX8632Attributes[getDest()->getType()].PackString);
...@@ -2283,6 +2417,8 @@ template <> void InstX8632Pcmpeq::emit(const Cfg *Func) const { ...@@ -2283,6 +2417,8 @@ template <> void InstX8632Pcmpeq::emit(const Cfg *Func) const {
} }
template <> void InstX8632Pcmpgt::emit(const Cfg *Func) const { template <> void InstX8632Pcmpgt::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
char buf[30]; char buf[30];
snprintf(buf, llvm::array_lengthof(buf), "pcmpgt%s", snprintf(buf, llvm::array_lengthof(buf), "pcmpgt%s",
TypeX8632Attributes[getDest()->getType()].PackString); TypeX8632Attributes[getDest()->getType()].PackString);
...@@ -2290,6 +2426,8 @@ template <> void InstX8632Pcmpgt::emit(const Cfg *Func) const { ...@@ -2290,6 +2426,8 @@ template <> void InstX8632Pcmpgt::emit(const Cfg *Func) const {
} }
template <> void InstX8632Pextr::emit(const Cfg *Func) const { template <> void InstX8632Pextr::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 2); assert(getSrcSize() == 2);
// pextrb and pextrd are SSE4.1 instructions. // pextrb and pextrd are SSE4.1 instructions.
...@@ -2334,6 +2472,8 @@ template <> void InstX8632Pextr::emitIAS(const Cfg *Func) const { ...@@ -2334,6 +2472,8 @@ template <> void InstX8632Pextr::emitIAS(const Cfg *Func) const {
} }
template <> void InstX8632Pinsr::emit(const Cfg *Func) const { template <> void InstX8632Pinsr::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 3); assert(getSrcSize() == 3);
// pinsrb and pinsrd are SSE4.1 instructions. // pinsrb and pinsrd are SSE4.1 instructions.
...@@ -2407,6 +2547,8 @@ template <> void InstX8632Shufps::emitIAS(const Cfg *Func) const { ...@@ -2407,6 +2547,8 @@ template <> void InstX8632Shufps::emitIAS(const Cfg *Func) const {
} }
void InstX8632Pop::emit(const Cfg *Func) const { void InstX8632Pop::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 0); assert(getSrcSize() == 0);
Str << "\tpop\t"; Str << "\tpop\t";
...@@ -2425,12 +2567,16 @@ void InstX8632Pop::emitIAS(const Cfg *Func) const { ...@@ -2425,12 +2567,16 @@ void InstX8632Pop::emitIAS(const Cfg *Func) const {
} }
void InstX8632Pop::dump(const Cfg *Func) const { void InstX8632Pop::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = pop." << getDest()->getType() << " "; Str << " = pop." << getDest()->getType() << " ";
} }
void InstX8632AdjustStack::emit(const Cfg *Func) const { void InstX8632AdjustStack::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
Str << "\tsubl\t$" << Amount << ", %esp"; Str << "\tsubl\t$" << Amount << ", %esp";
Func->getTarget()->updateStackAdjustment(Amount); Func->getTarget()->updateStackAdjustment(Amount);
...@@ -2443,11 +2589,15 @@ void InstX8632AdjustStack::emitIAS(const Cfg *Func) const { ...@@ -2443,11 +2589,15 @@ void InstX8632AdjustStack::emitIAS(const Cfg *Func) const {
} }
void InstX8632AdjustStack::dump(const Cfg *Func) const { void InstX8632AdjustStack::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Str << "esp = sub.i32 esp, " << Amount; Str << "esp = sub.i32 esp, " << Amount;
} }
void InstX8632Push::emit(const Cfg *Func) const { void InstX8632Push::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1); assert(getSrcSize() == 1);
// Push is currently only used for saving GPRs. // Push is currently only used for saving GPRs.
...@@ -2467,12 +2617,16 @@ void InstX8632Push::emitIAS(const Cfg *Func) const { ...@@ -2467,12 +2617,16 @@ void InstX8632Push::emitIAS(const Cfg *Func) const {
} }
void InstX8632Push::dump(const Cfg *Func) const { void InstX8632Push::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Str << "push." << getSrc(0)->getType() << " "; Str << "push." << getSrc(0)->getType() << " ";
dumpSources(Func); dumpSources(Func);
} }
template <> void InstX8632Psll::emit(const Cfg *Func) const { template <> void InstX8632Psll::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
assert(getDest()->getType() == IceType_v8i16 || assert(getDest()->getType() == IceType_v8i16 ||
getDest()->getType() == IceType_v8i1 || getDest()->getType() == IceType_v8i1 ||
getDest()->getType() == IceType_v4i32 || getDest()->getType() == IceType_v4i32 ||
...@@ -2484,6 +2638,8 @@ template <> void InstX8632Psll::emit(const Cfg *Func) const { ...@@ -2484,6 +2638,8 @@ template <> void InstX8632Psll::emit(const Cfg *Func) const {
} }
template <> void InstX8632Psra::emit(const Cfg *Func) const { template <> void InstX8632Psra::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
assert(getDest()->getType() == IceType_v8i16 || assert(getDest()->getType() == IceType_v8i16 ||
getDest()->getType() == IceType_v8i1 || getDest()->getType() == IceType_v8i1 ||
getDest()->getType() == IceType_v4i32 || getDest()->getType() == IceType_v4i32 ||
...@@ -2495,6 +2651,8 @@ template <> void InstX8632Psra::emit(const Cfg *Func) const { ...@@ -2495,6 +2651,8 @@ template <> void InstX8632Psra::emit(const Cfg *Func) const {
} }
void InstX8632Ret::emit(const Cfg *Func) const { void InstX8632Ret::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
Str << "\tret"; Str << "\tret";
} }
...@@ -2505,6 +2663,8 @@ void InstX8632Ret::emitIAS(const Cfg *Func) const { ...@@ -2505,6 +2663,8 @@ void InstX8632Ret::emitIAS(const Cfg *Func) const {
} }
void InstX8632Ret::dump(const Cfg *Func) const { void InstX8632Ret::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Type Ty = (getSrcSize() == 0 ? IceType_void : getSrc(0)->getType()); Type Ty = (getSrcSize() == 0 ? IceType_void : getSrc(0)->getType());
Str << "ret." << Ty << " "; Str << "ret." << Ty << " ";
...@@ -2512,6 +2672,8 @@ void InstX8632Ret::dump(const Cfg *Func) const { ...@@ -2512,6 +2672,8 @@ void InstX8632Ret::dump(const Cfg *Func) const {
} }
void InstX8632Xadd::emit(const Cfg *Func) const { void InstX8632Xadd::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
if (Locked) { if (Locked) {
Str << "\tlock"; Str << "\tlock";
...@@ -2540,6 +2702,8 @@ void InstX8632Xadd::emitIAS(const Cfg *Func) const { ...@@ -2540,6 +2702,8 @@ void InstX8632Xadd::emitIAS(const Cfg *Func) const {
} }
void InstX8632Xadd::dump(const Cfg *Func) const { void InstX8632Xadd::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
if (Locked) { if (Locked) {
Str << "lock "; Str << "lock ";
...@@ -2550,6 +2714,8 @@ void InstX8632Xadd::dump(const Cfg *Func) const { ...@@ -2550,6 +2714,8 @@ void InstX8632Xadd::dump(const Cfg *Func) const {
} }
void InstX8632Xchg::emit(const Cfg *Func) const { void InstX8632Xchg::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
Str << "\txchg" << getWidthString(getSrc(0)->getType()) << "\t"; Str << "\txchg" << getWidthString(getSrc(0)->getType()) << "\t";
getSrc(1)->emit(Func); getSrc(1)->emit(Func);
...@@ -2572,6 +2738,8 @@ void InstX8632Xchg::emitIAS(const Cfg *Func) const { ...@@ -2572,6 +2738,8 @@ void InstX8632Xchg::emitIAS(const Cfg *Func) const {
} }
void InstX8632Xchg::dump(const Cfg *Func) const { void InstX8632Xchg::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Type Ty = getSrc(0)->getType(); Type Ty = getSrc(0)->getType();
Str << "xchg." << Ty << " "; Str << "xchg." << Ty << " ";
...@@ -2579,6 +2747,8 @@ void InstX8632Xchg::dump(const Cfg *Func) const { ...@@ -2579,6 +2747,8 @@ void InstX8632Xchg::dump(const Cfg *Func) const {
} }
void OperandX8632Mem::emit(const Cfg *Func) const { void OperandX8632Mem::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
if (SegmentReg != DefaultSegment) { if (SegmentReg != DefaultSegment) {
assert(SegmentReg >= 0 && SegmentReg < SegReg_NUM); assert(SegmentReg >= 0 && SegmentReg < SegReg_NUM);
...@@ -2613,6 +2783,8 @@ void OperandX8632Mem::emit(const Cfg *Func) const { ...@@ -2613,6 +2783,8 @@ void OperandX8632Mem::emit(const Cfg *Func) const {
} }
void OperandX8632Mem::dump(const Cfg *Func, Ostream &Str) const { void OperandX8632Mem::dump(const Cfg *Func, Ostream &Str) const {
if (!ALLOW_DUMP)
return;
if (SegmentReg != DefaultSegment) { if (SegmentReg != DefaultSegment) {
assert(SegmentReg >= 0 && SegmentReg < SegReg_NUM); assert(SegmentReg >= 0 && SegmentReg < SegReg_NUM);
Str << InstX8632SegmentRegNames[SegmentReg] << ":"; Str << InstX8632SegmentRegNames[SegmentReg] << ":";
...@@ -2712,6 +2884,8 @@ x86::Address VariableSplit::toAsmAddress(const Cfg *Func) const { ...@@ -2712,6 +2884,8 @@ x86::Address VariableSplit::toAsmAddress(const Cfg *Func) const {
} }
void VariableSplit::emit(const Cfg *Func) const { void VariableSplit::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(!Var->hasReg()); assert(!Var->hasReg());
// The following is copied/adapted from TargetX8632::emitVariable(). // The following is copied/adapted from TargetX8632::emitVariable().
...@@ -2725,6 +2899,8 @@ void VariableSplit::emit(const Cfg *Func) const { ...@@ -2725,6 +2899,8 @@ void VariableSplit::emit(const Cfg *Func) const {
} }
void VariableSplit::dump(const Cfg *Func, Ostream &Str) const { void VariableSplit::dump(const Cfg *Func, Ostream &Str) const {
if (!ALLOW_DUMP)
return;
switch (Part) { switch (Part) {
case Low: case Low:
Str << "low"; Str << "low";
......
...@@ -41,6 +41,7 @@ public: ...@@ -41,6 +41,7 @@ public:
}; };
using Operand::dump; using Operand::dump;
void dump(const Cfg *, Ostream &Str) const override { void dump(const Cfg *, Ostream &Str) const override {
if (ALLOW_DUMP)
Str << "<OperandX8632>"; Str << "<OperandX8632>";
} }
...@@ -465,6 +466,8 @@ public: ...@@ -465,6 +466,8 @@ public:
InstX8632InplaceopGPR(Func, SrcDest); InstX8632InplaceopGPR(Func, SrcDest);
} }
void emit(const Cfg *Func) const override { void emit(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1); assert(getSrcSize() == 1);
Str << "\t" << Opcode << "\t"; Str << "\t" << Opcode << "\t";
...@@ -477,6 +480,8 @@ public: ...@@ -477,6 +480,8 @@ public:
emitIASOpTyGPR(Func, Ty, Var, Emitter); emitIASOpTyGPR(Func, Ty, Var, Emitter);
} }
void dump(const Cfg *Func) const override { void dump(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = " << Opcode << "." << getDest()->getType() << " "; Str << " = " << Opcode << "." << getDest()->getType() << " ";
...@@ -513,6 +518,8 @@ public: ...@@ -513,6 +518,8 @@ public:
InstX8632UnaryopGPR(Func, Dest, Src); InstX8632UnaryopGPR(Func, Dest, Src);
} }
void emit(const Cfg *Func) const override { void emit(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1); assert(getSrcSize() == 1);
Type SrcTy = getSrc(0)->getType(); Type SrcTy = getSrc(0)->getType();
...@@ -536,6 +543,8 @@ public: ...@@ -536,6 +543,8 @@ public:
emitIASRegOpTyGPR(Func, Ty, Var, Src, Emitter); emitIASRegOpTyGPR(Func, Ty, Var, Src, Emitter);
} }
void dump(const Cfg *Func) const override { void dump(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = " << Opcode << "." << getSrc(0)->getType() << " "; Str << " = " << Opcode << "." << getSrc(0)->getType() << " ";
...@@ -568,6 +577,8 @@ public: ...@@ -568,6 +577,8 @@ public:
InstX8632UnaryopXmm(Func, Dest, Src); InstX8632UnaryopXmm(Func, Dest, Src);
} }
void emit(const Cfg *Func) const override { void emit(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1); assert(getSrcSize() == 1);
Str << "\t" << Opcode << "\t"; Str << "\t" << Opcode << "\t";
...@@ -581,6 +592,8 @@ public: ...@@ -581,6 +592,8 @@ public:
emitIASRegOpTyXMM(Func, Ty, getDest(), getSrc(0), Emitter); emitIASRegOpTyXMM(Func, Ty, getDest(), getSrc(0), Emitter);
} }
void dump(const Cfg *Func) const override { void dump(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = " << Opcode << "." << getDest()->getType() << " "; Str << " = " << Opcode << "." << getDest()->getType() << " ";
...@@ -620,6 +633,8 @@ public: ...@@ -620,6 +633,8 @@ public:
InstX8632BinopGPRShift(Func, Dest, Source); InstX8632BinopGPRShift(Func, Dest, Source);
} }
void emit(const Cfg *Func) const override { void emit(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
const bool ShiftHack = true; const bool ShiftHack = true;
emitTwoAddress(Opcode, this, Func, ShiftHack); emitTwoAddress(Opcode, this, Func, ShiftHack);
} }
...@@ -629,6 +644,8 @@ public: ...@@ -629,6 +644,8 @@ public:
emitIASGPRShift(Func, Ty, getDest(), getSrc(1), Emitter); emitIASGPRShift(Func, Ty, getDest(), getSrc(1), Emitter);
} }
void dump(const Cfg *Func) const override { void dump(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = " << Opcode << "." << getDest()->getType() << " "; Str << " = " << Opcode << "." << getDest()->getType() << " ";
...@@ -659,6 +676,8 @@ public: ...@@ -659,6 +676,8 @@ public:
InstX8632BinopGPR(Func, Dest, Source); InstX8632BinopGPR(Func, Dest, Source);
} }
void emit(const Cfg *Func) const override { void emit(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
const bool ShiftHack = false; const bool ShiftHack = false;
emitTwoAddress(Opcode, this, Func, ShiftHack); emitTwoAddress(Opcode, this, Func, ShiftHack);
} }
...@@ -668,6 +687,8 @@ public: ...@@ -668,6 +687,8 @@ public:
emitIASRegOpTyGPR(Func, Ty, getDest(), getSrc(1), Emitter); emitIASRegOpTyGPR(Func, Ty, getDest(), getSrc(1), Emitter);
} }
void dump(const Cfg *Func) const override { void dump(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = " << Opcode << "." << getDest()->getType() << " "; Str << " = " << Opcode << "." << getDest()->getType() << " ";
...@@ -698,6 +719,8 @@ public: ...@@ -698,6 +719,8 @@ public:
InstX8632BinopXmm(Func, Dest, Source); InstX8632BinopXmm(Func, Dest, Source);
} }
void emit(const Cfg *Func) const override { void emit(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
const bool ShiftHack = false; const bool ShiftHack = false;
emitTwoAddress(Opcode, this, Func, ShiftHack); emitTwoAddress(Opcode, this, Func, ShiftHack);
} }
...@@ -709,6 +732,8 @@ public: ...@@ -709,6 +732,8 @@ public:
emitIASRegOpTyXMM(Func, Ty, getDest(), getSrc(1), Emitter); emitIASRegOpTyXMM(Func, Ty, getDest(), getSrc(1), Emitter);
} }
void dump(const Cfg *Func) const override { void dump(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = " << Opcode << "." << getDest()->getType() << " "; Str << " = " << Opcode << "." << getDest()->getType() << " ";
...@@ -744,6 +769,8 @@ public: ...@@ -744,6 +769,8 @@ public:
InstX8632BinopXmmShift(Func, Dest, Source); InstX8632BinopXmmShift(Func, Dest, Source);
} }
void emit(const Cfg *Func) const override { void emit(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
const bool ShiftHack = false; const bool ShiftHack = false;
emitTwoAddress(Opcode, this, Func, ShiftHack); emitTwoAddress(Opcode, this, Func, ShiftHack);
} }
...@@ -756,6 +783,8 @@ public: ...@@ -756,6 +783,8 @@ public:
emitIASXmmShift(Func, ElementTy, getDest(), getSrc(1), Emitter); emitIASXmmShift(Func, ElementTy, getDest(), getSrc(1), Emitter);
} }
void dump(const Cfg *Func) const override { void dump(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = " << Opcode << "." << getDest()->getType() << " "; Str << " = " << Opcode << "." << getDest()->getType() << " ";
...@@ -786,6 +815,8 @@ public: ...@@ -786,6 +815,8 @@ public:
InstX8632Ternop(Func, Dest, Source1, Source2); InstX8632Ternop(Func, Dest, Source1, Source2);
} }
void emit(const Cfg *Func) const override { void emit(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 3); assert(getSrcSize() == 3);
Str << "\t" << Opcode << "\t"; Str << "\t" << Opcode << "\t";
...@@ -797,6 +828,8 @@ public: ...@@ -797,6 +828,8 @@ public:
} }
void emitIAS(const Cfg *Func) const override; void emitIAS(const Cfg *Func) const override;
void dump(const Cfg *Func) const override { void dump(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = " << Opcode << "." << getDest()->getType() << " "; Str << " = " << Opcode << "." << getDest()->getType() << " ";
...@@ -828,6 +861,8 @@ public: ...@@ -828,6 +861,8 @@ public:
InstX8632ThreeAddressop(Func, Dest, Source0, Source1); InstX8632ThreeAddressop(Func, Dest, Source0, Source1);
} }
void emit(const Cfg *Func) const override { void emit(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 2); assert(getSrcSize() == 2);
Str << "\t" << Opcode << "\t"; Str << "\t" << Opcode << "\t";
...@@ -839,6 +874,8 @@ public: ...@@ -839,6 +874,8 @@ public:
} }
void emitIAS(const Cfg *Func) const override; void emitIAS(const Cfg *Func) const override;
void dump(const Cfg *Func) const override { void dump(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = " << Opcode << "." << getDest()->getType() << " "; Str << " = " << Opcode << "." << getDest()->getType() << " ";
...@@ -877,6 +914,8 @@ public: ...@@ -877,6 +914,8 @@ public:
void emit(const Cfg *Func) const override; void emit(const Cfg *Func) const override;
void emitIAS(const Cfg *Func) const override; void emitIAS(const Cfg *Func) const override;
void dump(const Cfg *Func) const override { void dump(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Str << Opcode << "." << getDest()->getType() << " "; Str << Opcode << "." << getDest()->getType() << " ";
dumpDest(Func); dumpDest(Func);
......
...@@ -427,10 +427,13 @@ const InstDefList VariablesMetadata::NoDefinitions; ...@@ -427,10 +427,13 @@ const InstDefList VariablesMetadata::NoDefinitions;
// ======================== dump routines ======================== // // ======================== dump routines ======================== //
void Variable::emit(const Cfg *Func) const { void Variable::emit(const Cfg *Func) const {
if (ALLOW_DUMP)
Func->getTarget()->emitVariable(this); Func->getTarget()->emitVariable(this);
} }
void Variable::dump(const Cfg *Func, Ostream &Str) const { void Variable::dump(const Cfg *Func, Ostream &Str) const {
if (!ALLOW_DUMP)
return;
if (Func == NULL) { if (Func == NULL) {
Str << "%" << getName(); Str << "%" << getName();
return; return;
...@@ -458,6 +461,8 @@ void Variable::dump(const Cfg *Func, Ostream &Str) const { ...@@ -458,6 +461,8 @@ void Variable::dump(const Cfg *Func, Ostream &Str) const {
} }
void ConstantRelocatable::emitWithoutDollar(GlobalContext *Ctx) const { void ConstantRelocatable::emitWithoutDollar(GlobalContext *Ctx) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Ctx->getStrEmit(); Ostream &Str = Ctx->getStrEmit();
if (SuppressMangling) if (SuppressMangling)
Str << Name; Str << Name;
...@@ -471,12 +476,16 @@ void ConstantRelocatable::emitWithoutDollar(GlobalContext *Ctx) const { ...@@ -471,12 +476,16 @@ void ConstantRelocatable::emitWithoutDollar(GlobalContext *Ctx) const {
} }
void ConstantRelocatable::emit(GlobalContext *Ctx) const { void ConstantRelocatable::emit(GlobalContext *Ctx) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Ctx->getStrEmit(); Ostream &Str = Ctx->getStrEmit();
Str << "$"; Str << "$";
emitWithoutDollar(Ctx); emitWithoutDollar(Ctx);
} }
void ConstantRelocatable::dump(const Cfg *Func, Ostream &Str) const { void ConstantRelocatable::dump(const Cfg *Func, Ostream &Str) const {
if (!ALLOW_DUMP)
return;
Str << "@"; Str << "@";
if (Func && !SuppressMangling) { if (Func && !SuppressMangling) {
Str << Func->getContext()->mangleName(Name); Str << Func->getContext()->mangleName(Name);
...@@ -488,6 +497,8 @@ void ConstantRelocatable::dump(const Cfg *Func, Ostream &Str) const { ...@@ -488,6 +497,8 @@ void ConstantRelocatable::dump(const Cfg *Func, Ostream &Str) const {
} }
void LiveRange::dump(Ostream &Str) const { void LiveRange::dump(Ostream &Str) const {
if (!ALLOW_DUMP)
return;
Str << "(weight=" << Weight << ") "; Str << "(weight=" << Weight << ") ";
bool First = true; bool First = true;
for (const RangeElementType &I : Range) { for (const RangeElementType &I : Range) {
...@@ -499,11 +510,15 @@ void LiveRange::dump(Ostream &Str) const { ...@@ -499,11 +510,15 @@ void LiveRange::dump(Ostream &Str) const {
} }
Ostream &operator<<(Ostream &Str, const LiveRange &L) { Ostream &operator<<(Ostream &Str, const LiveRange &L) {
if (!ALLOW_DUMP)
return Str;
L.dump(Str); L.dump(Str);
return Str; return Str;
} }
Ostream &operator<<(Ostream &Str, const RegWeight &W) { Ostream &operator<<(Ostream &Str, const RegWeight &W) {
if (!ALLOW_DUMP)
return Str;
if (W.getWeight() == RegWeight::Inf) if (W.getWeight() == RegWeight::Inf)
Str << "Inf"; Str << "Inf";
else else
......
...@@ -65,10 +65,15 @@ public: ...@@ -65,10 +65,15 @@ public:
// situation where Func==NULL. // situation where Func==NULL.
virtual void dump(const Cfg *Func, Ostream &Str) const = 0; virtual void dump(const Cfg *Func, Ostream &Str) const = 0;
void dump(const Cfg *Func) const { void dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
assert(Func); assert(Func);
dump(Func, Func->getContext()->getStrDump()); 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 // Query whether this object was allocated in isolation, or added to
// some higher-level pool. This determines whether a containing // some higher-level pool. This determines whether a containing
...@@ -148,7 +153,10 @@ public: ...@@ -148,7 +153,10 @@ public:
// specialization. // specialization.
void emit(GlobalContext *Ctx) const override; void emit(GlobalContext *Ctx) const override;
using Constant::dump; 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) { static bool classof(const Operand *Operand) {
return Operand->getKind() == K; return Operand->getKind() == K;
...@@ -167,6 +175,8 @@ typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat; ...@@ -167,6 +175,8 @@ typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat;
typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble; typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble;
template <> inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const { template <> inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const {
if (!ALLOW_DUMP)
return;
if (getType() == IceType_i1) if (getType() == IceType_i1)
Str << (getValue() ? "true" : "false"); Str << (getValue() ? "true" : "false");
else else
...@@ -174,6 +184,8 @@ template <> inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const ...@@ -174,6 +184,8 @@ template <> inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const
} }
template <> inline void ConstantInteger64::dump(const Cfg *, Ostream &Str) const { template <> inline void ConstantInteger64::dump(const Cfg *, Ostream &Str) const {
if (!ALLOW_DUMP)
return;
assert(getType() == IceType_i64); assert(getType() == IceType_i64);
Str << static_cast<int64_t>(getValue()); Str << static_cast<int64_t>(getValue());
} }
...@@ -259,7 +271,10 @@ public: ...@@ -259,7 +271,10 @@ public:
using Constant::dump; using Constant::dump;
// The target needs to implement this. // The target needs to implement this.
void emit(GlobalContext *Ctx) const override; 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) { static bool classof(const Operand *Operand) {
return Operand->getKind() == kConstUndef; return Operand->getKind() == kConstUndef;
......
...@@ -46,6 +46,8 @@ bool overlapsDefs(const Cfg *Func, const Variable *Item, const Variable *Var) { ...@@ -46,6 +46,8 @@ bool overlapsDefs(const Cfg *Func, const Variable *Item, const Variable *Var) {
void dumpDisableOverlap(const Cfg *Func, const Variable *Var, void dumpDisableOverlap(const Cfg *Func, const Variable *Var,
const char *Reason) { const char *Reason) {
if (!ALLOW_DUMP)
return;
if (Func->getContext()->isVerbose(IceV_LinearScan)) { if (Func->getContext()->isVerbose(IceV_LinearScan)) {
VariablesMetadata *VMetadata = Func->getVMetadata(); VariablesMetadata *VMetadata = Func->getVMetadata();
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
...@@ -62,6 +64,8 @@ void dumpDisableOverlap(const Cfg *Func, const Variable *Var, ...@@ -62,6 +64,8 @@ void dumpDisableOverlap(const Cfg *Func, const Variable *Var,
} }
void dumpLiveRange(const Variable *Var, const Cfg *Func) { void dumpLiveRange(const Variable *Var, const Cfg *Func) {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
const static size_t BufLen = 30; const static size_t BufLen = 30;
char buf[BufLen]; char buf[BufLen];
...@@ -252,7 +256,8 @@ void LinearScan::scan(const llvm::SmallBitVector &RegMaskFull) { ...@@ -252,7 +256,8 @@ void LinearScan::scan(const llvm::SmallBitVector &RegMaskFull) {
TimerMarker T(TimerStack::TT_linearScan, Func); TimerMarker T(TimerStack::TT_linearScan, Func);
assert(RegMaskFull.any()); // Sanity check assert(RegMaskFull.any()); // Sanity check
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
bool Verbose = Func->getContext()->isVerbose(IceV_LinearScan); const bool Verbose =
ALLOW_DUMP && Func->getContext()->isVerbose(IceV_LinearScan);
Func->resetCurrentNode(); Func->resetCurrentNode();
VariablesMetadata *VMetadata = Func->getVMetadata(); VariablesMetadata *VMetadata = Func->getVMetadata();
...@@ -691,6 +696,8 @@ void LinearScan::scan(const llvm::SmallBitVector &RegMaskFull) { ...@@ -691,6 +696,8 @@ void LinearScan::scan(const llvm::SmallBitVector &RegMaskFull) {
// ======================== Dump routines ======================== // // ======================== Dump routines ======================== //
void LinearScan::dump(Cfg *Func) const { void LinearScan::dump(Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
if (!Func->getContext()->isVerbose(IceV_LinearScan)) if (!Func->getContext()->isVerbose(IceV_LinearScan))
return; return;
......
...@@ -898,7 +898,7 @@ void TargetX8632::addProlog(CfgNode *Node) { ...@@ -898,7 +898,7 @@ void TargetX8632::addProlog(CfgNode *Node) {
Var->setStackOffset(Linked->getStackOffset()); Var->setStackOffset(Linked->getStackOffset());
} }
if (Func->getContext()->isVerbose(IceV_Frame)) { if (ALLOW_DUMP && Func->getContext()->isVerbose(IceV_Frame)) {
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Str << "Stack layout:\n"; Str << "Stack layout:\n";
...@@ -996,6 +996,7 @@ const char *PoolTypeConverter<double>::AsmTag = ".quad"; ...@@ -996,6 +996,7 @@ const char *PoolTypeConverter<double>::AsmTag = ".quad";
const char *PoolTypeConverter<double>::PrintfString = "0x%llx"; const char *PoolTypeConverter<double>::PrintfString = "0x%llx";
template <typename T> void TargetX8632::emitConstantPool() const { template <typename T> void TargetX8632::emitConstantPool() const {
// Note: Still used by emit IAS.
Ostream &Str = Ctx->getStrEmit(); Ostream &Str = Ctx->getStrEmit();
Type Ty = T::Ty; Type Ty = T::Ty;
SizeT Align = typeAlignInBytes(Ty); SizeT Align = typeAlignInBytes(Ty);
...@@ -1024,6 +1025,7 @@ template <typename T> void TargetX8632::emitConstantPool() const { ...@@ -1024,6 +1025,7 @@ template <typename T> void TargetX8632::emitConstantPool() const {
} }
void TargetX8632::emitConstants() const { void TargetX8632::emitConstants() const {
// Note: Still used by emit IAS.
emitConstantPool<PoolTypeConverter<float> >(); emitConstantPool<PoolTypeConverter<float> >();
emitConstantPool<PoolTypeConverter<double> >(); emitConstantPool<PoolTypeConverter<double> >();
...@@ -3561,6 +3563,8 @@ bool isAdd(const Inst *Inst) { ...@@ -3561,6 +3563,8 @@ bool isAdd(const Inst *Inst) {
void dumpAddressOpt(const Cfg *Func, const Variable *Base, void dumpAddressOpt(const Cfg *Func, const Variable *Base,
const Variable *Index, uint16_t Shift, int32_t Offset, const Variable *Index, uint16_t Shift, int32_t Offset,
const Inst *Reason) { const Inst *Reason) {
if (!ALLOW_DUMP)
return;
if (!Func->getContext()->isVerbose(IceV_AddrOpt)) if (!Func->getContext()->isVerbose(IceV_AddrOpt))
return; return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
...@@ -4528,6 +4532,8 @@ void TargetX8632::postLower() { ...@@ -4528,6 +4532,8 @@ void TargetX8632::postLower() {
} }
template <> void ConstantInteger32::emit(GlobalContext *Ctx) const { template <> void ConstantInteger32::emit(GlobalContext *Ctx) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Ctx->getStrEmit(); Ostream &Str = Ctx->getStrEmit();
Str << "$" << (int32_t)getValue(); Str << "$" << (int32_t)getValue();
} }
...@@ -4537,11 +4543,15 @@ template <> void ConstantInteger64::emit(GlobalContext *) const { ...@@ -4537,11 +4543,15 @@ template <> void ConstantInteger64::emit(GlobalContext *) const {
} }
template <> void ConstantFloat::emit(GlobalContext *Ctx) const { template <> void ConstantFloat::emit(GlobalContext *Ctx) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Ctx->getStrEmit(); Ostream &Str = Ctx->getStrEmit();
Str << ".L$" << IceType_f32 << "$" << getPoolEntryID(); Str << ".L$" << IceType_f32 << "$" << getPoolEntryID();
} }
template <> void ConstantDouble::emit(GlobalContext *Ctx) const { template <> void ConstantDouble::emit(GlobalContext *Ctx) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Ctx->getStrEmit(); Ostream &Str = Ctx->getStrEmit();
Str << ".L$" << IceType_f64 << "$" << getPoolEntryID(); Str << ".L$" << IceType_f64 << "$" << getPoolEntryID();
} }
......
...@@ -127,6 +127,8 @@ typedef std::multimap<double, IceString> DumpMapType; ...@@ -127,6 +127,8 @@ typedef std::multimap<double, IceString> DumpMapType;
// Dump the Map items in reverse order of their time contribution. // Dump the Map items in reverse order of their time contribution.
void dumpHelper(Ostream &Str, const DumpMapType &Map, double TotalTime) { void dumpHelper(Ostream &Str, const DumpMapType &Map, double TotalTime) {
if (!ALLOW_DUMP)
return;
// TODO(stichnot): Use llvm::make_range with LLVM 3.5. // TODO(stichnot): Use llvm::make_range with LLVM 3.5.
for (auto I = Map.rbegin(), E = Map.rend(); I != E; ++I) { for (auto I = Map.rbegin(), E = Map.rend(); I != E; ++I) {
char buf[80]; char buf[80];
...@@ -142,6 +144,8 @@ void dumpHelper(Ostream &Str, const DumpMapType &Map, double TotalTime) { ...@@ -142,6 +144,8 @@ void dumpHelper(Ostream &Str, const DumpMapType &Map, double TotalTime) {
// MaxVal=5 ==> "[%1lu] " // MaxVal=5 ==> "[%1lu] "
// MaxVal=9876 ==> "[%4lu] " // MaxVal=9876 ==> "[%4lu] "
void makePrintfFormatString(char *Buf, size_t BufLen, size_t MaxVal) { void makePrintfFormatString(char *Buf, size_t BufLen, size_t MaxVal) {
if (!ALLOW_DUMP)
return;
int NumDigits = 0; int NumDigits = 0;
do { do {
++NumDigits; ++NumDigits;
...@@ -153,6 +157,8 @@ void makePrintfFormatString(char *Buf, size_t BufLen, size_t MaxVal) { ...@@ -153,6 +157,8 @@ void makePrintfFormatString(char *Buf, size_t BufLen, size_t MaxVal) {
} // end of anonymous namespace } // end of anonymous namespace
void TimerStack::dump(Ostream &Str, bool DumpCumulative) { void TimerStack::dump(Ostream &Str, bool DumpCumulative) {
if (!ALLOW_DUMP)
return;
const bool UpdateCounts = true; const bool UpdateCounts = true;
update(UpdateCounts); update(UpdateCounts);
double TotalTime = LastTimestamp - FirstTimestamp; double TotalTime = LastTimestamp - FirstTimestamp;
......
...@@ -106,8 +106,8 @@ void Translator::lowerGlobals( ...@@ -106,8 +106,8 @@ void Translator::lowerGlobals(
llvm::OwningPtr<TargetGlobalInitLowering> GlobalLowering( llvm::OwningPtr<TargetGlobalInitLowering> GlobalLowering(
TargetGlobalInitLowering::createLowering(Ctx->getTargetArch(), Ctx)); TargetGlobalInitLowering::createLowering(Ctx->getTargetArch(), Ctx));
bool DisableTranslation = Ctx->getFlags().DisableTranslation; bool DisableTranslation = Ctx->getFlags().DisableTranslation;
bool DumpGlobalVariables = const bool DumpGlobalVariables =
Ctx->isVerbose() && Ctx->getFlags().VerboseFocusOn.empty(); ALLOW_DUMP && Ctx->isVerbose() && Ctx->getFlags().VerboseFocusOn.empty();
Ostream &Stream = Ctx->getStrDump(); Ostream &Stream = Ctx->getStrDump();
const IceString &TranslateOnly = Ctx->getFlags().TranslateOnly; const IceString &TranslateOnly = Ctx->getFlags().TranslateOnly;
for (const Ice::VariableDeclaration *Global : VariableDeclarations) { for (const Ice::VariableDeclaration *Global : VariableDeclarations) {
......
...@@ -260,6 +260,8 @@ const char *typeString(Type Ty) { ...@@ -260,6 +260,8 @@ const char *typeString(Type Ty) {
} }
void FuncSigType::dump(Ostream &Stream) const { void FuncSigType::dump(Ostream &Stream) const {
if (!ALLOW_DUMP)
return;
Stream << ReturnType << " ("; Stream << ReturnType << " (";
bool IsFirst = true; bool IsFirst = true;
for (const Type ArgTy : ArgList) { for (const Type ArgTy : ArgList) {
......
...@@ -87,11 +87,15 @@ private: ...@@ -87,11 +87,15 @@ private:
}; };
Ice::Ostream &operator<<(Ice::Ostream &Stream, const ExtendedType &Ty) { Ice::Ostream &operator<<(Ice::Ostream &Stream, const ExtendedType &Ty) {
if (!ALLOW_DUMP)
return Stream;
Ty.dump(Stream); Ty.dump(Stream);
return Stream; return Stream;
} }
Ice::Ostream &operator<<(Ice::Ostream &Stream, ExtendedType::TypeKind Kind) { Ice::Ostream &operator<<(Ice::Ostream &Stream, ExtendedType::TypeKind Kind) {
if (!ALLOW_DUMP)
return Stream;
Stream << "ExtendedType::"; Stream << "ExtendedType::";
switch (Kind) { switch (Kind) {
case ExtendedType::Undefined: case ExtendedType::Undefined:
...@@ -138,6 +142,8 @@ public: ...@@ -138,6 +142,8 @@ public:
}; };
void ExtendedType::dump(Ice::Ostream &Stream) const { void ExtendedType::dump(Ice::Ostream &Stream) const {
if (!ALLOW_DUMP)
return;
Stream << Kind; Stream << Kind;
switch (Kind) { switch (Kind) {
case Simple: { case Simple: {
...@@ -545,7 +551,13 @@ protected: ...@@ -545,7 +551,13 @@ protected:
std::string Buffer; std::string Buffer;
raw_string_ostream StrBuf(Buffer); raw_string_ostream StrBuf(Buffer);
StrBuf << "(" << format("%" PRIu64 ":%u", (Bit / 8), 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()); return Context->Error(StrBuf.str());
} }
...@@ -1394,6 +1406,8 @@ private: ...@@ -1394,6 +1406,8 @@ private:
void dumpVectorIndexCheckValue(raw_ostream &Stream, void dumpVectorIndexCheckValue(raw_ostream &Stream,
VectorIndexCheckValue Value) const { VectorIndexCheckValue Value) const {
if (!ALLOW_DUMP)
return;
switch (Value) { switch (Value) {
default: default:
report_fatal_error("Unknown VectorIndexCheckValue"); report_fatal_error("Unknown VectorIndexCheckValue");
......
...@@ -192,8 +192,7 @@ static int GetReturnValue(int Val) { ...@@ -192,8 +192,7 @@ static int GetReturnValue(int Val) {
static struct { static struct {
const char *FlagName; const char *FlagName;
int FlagValue; int FlagValue;
} ConditionalBuildAttributes[] = {{"text_asm", ALLOW_TEXT_ASM}, } ConditionalBuildAttributes[] = {{"dump", ALLOW_DUMP},
{"dump", ALLOW_DUMP},
{"llvm_cl", ALLOW_LLVM_CL}, {"llvm_cl", ALLOW_LLVM_CL},
{"llvm_ir", ALLOW_LLVM_IR}, {"llvm_ir", ALLOW_LLVM_IR},
{"llvm_ir_as_input", ALLOW_LLVM_IR_AS_INPUT}, {"llvm_ir_as_input", ALLOW_LLVM_IR_AS_INPUT},
...@@ -236,8 +235,12 @@ int main(int argc, char **argv) { ...@@ -236,8 +235,12 @@ int main(int argc, char **argv) {
DisableTranslation = true; DisableTranslation = true;
Ice::VerboseMask VMask = Ice::IceV_None; Ice::VerboseMask VMask = Ice::IceV_None;
// Don't generate verbose messages if routines
// to dump messages are not available.
if (ALLOW_DUMP) {
for (unsigned i = 0; i != VerboseList.size(); ++i) for (unsigned i = 0; i != VerboseList.size(); ++i)
VMask |= VerboseList[i]; VMask |= VerboseList[i];
}
std::ofstream Ofs; std::ofstream Ofs;
if (OutputFilename != "-") { if (OutputFilename != "-") {
......
; This is a very early test that just checks the representation of i32 ; This is a very early test that just checks the representation of i32
; arithmetic instructions. No assembly tests are done. ; arithmetic instructions. No assembly tests are done.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --args --verbose inst -ias=0 | FileCheck %s ; RUN: %p2i -i %s --args --verbose inst -ias=0 | FileCheck %s
define i32 @Add(i32 %a, i32 %b) { define i32 @Add(i32 %a, i32 %b) {
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
; we don't lower to a cmp instructions with an immediate as the first ; we don't lower to a cmp instructions with an immediate as the first
; source operand. ; source operand.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --args -O2 --verbose inst | FileCheck %s ; RUN: %p2i -i %s --args -O2 --verbose inst | FileCheck %s
; RUN: %p2i -i %s --args -Om1 --verbose inst | FileCheck %s ; RUN: %p2i -i %s --args -Om1 --verbose inst | FileCheck %s
......
; Test of global initializers. ; Test of global initializers.
; REQUIRES: allow_dump
; Test -ias=0 to test the lea "hack" until we are fully confident in -ias=1 ; Test -ias=0 to test the lea "hack" until we are fully confident in -ias=1
; RUN: %p2i -i %s --args --verbose none -ias=0 | FileCheck %s ; RUN: %p2i -i %s --args --verbose none -ias=0 | FileCheck %s
......
; Tests if we handle global variables with relocation initializers. ; Tests if we handle global variables with relocation initializers.
; REQUIRES: allow_dump
; Test that we handle it in the ICE converter. ; Test that we handle it in the ICE converter.
; RUN: %lc2i -i %s --args -verbose inst | %iflc FileCheck %s ; RUN: %lc2i -i %s --args -verbose inst | %iflc FileCheck %s
......
; Simple test of the load instruction. ; Simple test of the load instruction.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --args --verbose inst | FileCheck %s ; RUN: %p2i -i %s --args --verbose inst | FileCheck %s
define void @load_i64(i32 %addr_arg) { define void @load_i64(i32 %addr_arg) {
......
; This is a smoke test of nop insertion. ; This is a smoke test of nop insertion.
; REQUIRES: allow_dump
; Don't use integrated-as because this currently depends on the # variant ; Don't use integrated-as because this currently depends on the # variant
; assembler comment. ; assembler comment.
; RUN: %p2i -i %s -a -rng-seed=1 -nop-insertion -nop-insertion-percentage=50 \ ; RUN: %p2i -i %s -a -rng-seed=1 -nop-insertion -nop-insertion-percentage=50 \
......
; Simple test of the store instruction. ; Simple test of the store instruction.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --args --verbose inst | FileCheck %s ; RUN: %p2i -i %s --args --verbose inst | FileCheck %s
define void @store_i64(i32 %addr_arg) { define void @store_i64(i32 %addr_arg) {
......
; Test if we can read alloca instructions. ; Test if we can read alloca instructions.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
; Tests if we can read binary operators. ; Tests if we can read binary operators.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %l2i -i %s --insts | %ifl FileCheck %s ; RUN: %l2i -i %s --insts | %ifl FileCheck %s
; RUN: %lc2i -i %s --insts | %iflc FileCheck %s ; RUN: %lc2i -i %s --insts | %iflc FileCheck %s
......
; Tests if we handle a branch instructions. ; Tests if we handle a branch instructions.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
; Test parsing indirect calls in Subzero. ; Test parsing indirect calls in Subzero.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
; Test handling of call instructions. ; Test handling of call instructions.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
; Tests if we can read cast operations. ; Tests if we can read cast operations.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts --no-local-syms | FileCheck %s ; RUN: %p2i -i %s --insts --no-local-syms | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
; Test if we can read compare instructions. ; Test if we can read compare instructions.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
; Test handling of constants in function blocks. ; Test handling of constants in function blocks.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
; Test use forward type references in function blocks. ; Test use forward type references in function blocks.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: llvm-as < %s | pnacl-freeze | pnacl-bcdis -no-records \ ; RUN: llvm-as < %s | pnacl-freeze | pnacl-bcdis -no-records \
; RUN: | FileCheck --check-prefix=DUMP %s ; RUN: | FileCheck --check-prefix=DUMP %s
......
; Test of global initializers. ; Test of global initializers.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %l2i -i %s --insts | %ifl FileCheck %s ; RUN: %l2i -i %s --insts | %ifl FileCheck %s
; RUN: %lc2i -i %s --insts | %iflc FileCheck %s ; RUN: %lc2i -i %s --insts | %iflc FileCheck %s
......
; Tests if we handle global variables with relocation initializers. ; Tests if we handle global variables with relocation initializers.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %l2i -i %s --insts | %ifl FileCheck %s ; RUN: %l2i -i %s --insts | %ifl FileCheck %s
; RUN: %lc2i -i %s --insts | %iflc FileCheck %s ; RUN: %lc2i -i %s --insts | %iflc FileCheck %s
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
; errors when malformed. Note: We can only test literal indexing since ; errors when malformed. Note: We can only test literal indexing since
; llvm-as will not allow other bad forms of these instructions. ; llvm-as will not allow other bad forms of these instructions.
; RUN: llvm-as < %s | pnacl-freeze | not %llvm2ice -notranslate \ ; REQUIRES: allow_dump
; RUN: llvm-as < %s | pnacl-freeze \
; RUN: | not %llvm2ice -notranslate -build-on-read \
; RUN: -allow-pnacl-reader-error-recovery | FileCheck %s ; RUN: -allow-pnacl-reader-error-recovery | FileCheck %s
define void @ExtractV4xi1(<4 x i1> %v, i32 %i) { define void @ExtractV4xi1(<4 x i1> %v, i32 %i) {
......
; Tests insertelement and extractelement vector instructions. ; Tests insertelement and extractelement vector instructions.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %l2i -i %s --insts | %ifl FileCheck %s ; RUN: %l2i -i %s --insts | %ifl FileCheck %s
; RUN: %lc2i -i %s --insts | %iflc FileCheck %s ; RUN: %lc2i -i %s --insts | %iflc FileCheck %s
......
; Test if we can read load instructions. ; Test if we can read load instructions.
; REQUIRES: allow_dump
; RUN: %p2i --no-local-syms -i %s --insts | FileCheck %s ; RUN: %p2i --no-local-syms -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
; Test parsing NaCl atomic instructions. ; Test parsing NaCl atomic instructions.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
...@@ -3,11 +3,26 @@ ...@@ -3,11 +3,26 @@
; TODO(kschimpf) Find way to run this through p2i. Note: Can't do this ; TODO(kschimpf) Find way to run this through p2i. Note: Can't do this
; currently because run-llvm2ice.py raises exception on error, ; currently because run-llvm2ice.py raises exception on error,
; and output is lost. ; and output is lost.
; RUN: llvm-as < %s | pnacl-freeze -allow-local-symbol-tables \ ; RUN: %if --need=allow_dump --command \
; RUN: | not %llvm2ice -notranslate -verbose=inst \ ; RUN: llvm-as < %s \
; RUN: | %if --need=allow_dump --command \
; RUN: pnacl-freeze -allow-local-symbol-tables \
; RUN: | %if --need=allow_dump --command \
; RUN: not %llvm2ice -notranslate -verbose=inst -build-on-read \
; RUN: -allow-pnacl-reader-error-recovery \ ; RUN: -allow-pnacl-reader-error-recovery \
; RUN: -allow-local-symbol-tables \ ; RUN: -allow-local-symbol-tables \
; RUN: | FileCheck %s ; RUN: | %if --need=allow_dump --command \
; RUN: FileCheck %s
; RUN: %if --need=no_dump --command \
; RUN: llvm-as < %s \
; RUN: | %if --need=no_dump --command \
; RUN: pnacl-freeze -allow-local-symbol-tables \
; RUN: | %if --need=no_dump --command \
; RUN: not %llvm2ice -notranslate -verbose=inst -build-on-read \
; RUN: -allow-pnacl-reader-error-recovery -allow-local-symbol-tables \
; RUN: | %if --need=no_dump --command \
; RUN: FileCheck --check-prefix=MIN %s
declare i32 @llvm.fake.i32(i32) declare i32 @llvm.fake.i32(i32)
...@@ -16,5 +31,6 @@ define i32 @testFake(i32 %v) { ...@@ -16,5 +31,6 @@ define i32 @testFake(i32 %v) {
ret i32 %r ret i32 %r
} }
; CHECK: Error: (218:6) Invalid PNaCl intrinsic call to llvm.fake.i32 ; CHECK: Error: ({{.*}}) Invalid PNaCl intrinsic call to llvm.fake.i32
; MIN: Error: ({{.*}}) Invalid input record
; This tests parsing NaCl intrinsics not related to atomic operations. ; This tests parsing NaCl intrinsics not related to atomic operations.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
; Test reading phi instructions. ; Test reading phi instructions.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
; Tests if we can read select instructions. ; Tests if we can read select instructions.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
; Test if we can read store instructions. ; Test if we can read store instructions.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts --no-local-syms | FileCheck %s ; RUN: %p2i -i %s --insts --no-local-syms | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
; Test switch instructions. ; Test switch instructions.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
; Tests that we name unnamed global addresses. ; Tests that we name unnamed global addresses.
; REQUIRES: allow_dump
; Check that Subzero's bitcode reader handles renaming correctly. ; Check that Subzero's bitcode reader handles renaming correctly.
; RUN: %p2i --no-local-syms -i %s --insts | FileCheck %s ; RUN: %p2i --no-local-syms -i %s --insts | FileCheck %s
; RUN: %l2i --no-local-syms -i %s --insts | %ifl FileCheck %s ; RUN: %l2i --no-local-syms -i %s --insts | %ifl FileCheck %s
......
; Test parsing unreachable instruction. ; Test parsing unreachable instruction.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
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