UnimplementedLoweringError's message now includes the instruction name.
R=jpp@chromium.org
Review URL: https://codereview.chromium.org/1639063002 .
diff --git a/src/IceInst.cpp b/src/IceInst.cpp
index 1db9cee..27f5349 100644
--- a/src/IceInst.cpp
+++ b/src/IceInst.cpp
@@ -77,6 +77,45 @@
: Kind(Kind), Number(Func->newInstNumber()), Dest(Dest), MaxSrcs(MaxSrcs),
Srcs(Func->allocateArrayOf<Operand *>(MaxSrcs)), LiveRangesEnded(0) {}
+IceString Inst::getInstName() const {
+ if (!BuildDefs::dump())
+ return "???";
+
+ switch (Kind) {
+#define X(InstrKind, name) \
+ case InstrKind: \
+ return name
+ X(Unreachable, "unreachable");
+ X(Alloca, "alloca");
+ X(Arithmetic, "arithmetic");
+ X(Br, "br");
+ X(Call, "call");
+ X(Cast, "cast");
+ X(ExtractElement, "extractelement");
+ X(Fcmp, "fcmp");
+ X(Icmp, "icmp");
+ X(IntrinsicCall, "intrinsiccall");
+ X(InsertElement, "insertelement");
+ X(Load, "load");
+ X(Phi, "phi");
+ X(Ret, "ret");
+ X(Select, "select");
+ X(Store, "store");
+ X(Switch, "switch");
+ X(Assign, "assign");
+ X(BundleLock, "bundlelock");
+ X(BundleUnlock, "bundleunlock");
+ X(FakeDef, "fakedef");
+ X(FakeUse, "fakeuse");
+ X(FakeKill, "fakekill");
+ X(JumpTable, "jumptable");
+#undef X
+ default:
+ assert(Kind >= Target);
+ return "target";
+ }
+}
+
// Assign the instruction a new number.
void Inst::renumber(Cfg *Func) {
Number = isDeleted() ? NumberDeleted : Func->newInstNumber();
@@ -233,6 +272,13 @@
addSource(Source2);
}
+IceString InstArithmetic::getInstName() const {
+ if (!BuildDefs::dump())
+ return "???";
+
+ return InstArithmeticAttributes[getOp()].DisplayString;
+}
+
const char *InstArithmetic::getOpName(OpKind Op) {
size_t OpIndex = static_cast<size_t>(Op);
return OpIndex < InstArithmetic::_num
@@ -558,7 +604,7 @@
return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
- Str << " =~ ";
+ Str << " =~ " << getInstName() << " ";
dumpSources(Func);
}
@@ -630,8 +676,7 @@
return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
- Str << " = " << InstArithmeticAttributes[getOp()].DisplayString << " "
- << getDest()->getType() << " ";
+ Str << " = " << getInstName() << " " << getDest()->getType() << " ";
dumpSources(Func);
}
diff --git a/src/IceInst.h b/src/IceInst.h
index 85fde52..c1d5bcc 100644
--- a/src/IceInst.h
+++ b/src/IceInst.h
@@ -76,6 +76,7 @@
};
static_assert(Target <= Target_Max, "Must not be above max.");
InstKind getKind() const { return Kind; }
+ virtual IceString getInstName() const;
InstNumberT getNumber() const { return Number; }
void renumber(Cfg *Func);
@@ -288,6 +289,9 @@
InstArithmetic(Func, Op, Dest, Source1, Source2);
}
OpKind getOp() const { return Op; }
+
+ virtual IceString getInstName() const override;
+
static const char *getOpName(OpKind Op);
bool isCommutative() const;
void dump(const Cfg *Func) const override;
diff --git a/src/IceTargetLowering.h b/src/IceTargetLowering.h
index f8355b9..3d3452e 100644
--- a/src/IceTargetLowering.h
+++ b/src/IceTargetLowering.h
@@ -55,7 +55,8 @@
} else { \
/* Use llvm_unreachable instead of report_fatal_error, which gives \
better stack traces. */ \
- llvm_unreachable("Not yet implemented"); \
+ llvm_unreachable( \
+ ("Not yet implemented: " + Instr->getInstName()).c_str()); \
abort(); \
} \
} while (0)