Commit e37076a1 by Eric Holk

UnimplementedLoweringError's message now includes the instruction name.

R=jpp@chromium.org Review URL: https://codereview.chromium.org/1639063002 .
parent 9aedc2e9
......@@ -77,6 +77,45 @@ Inst::Inst(Cfg *Func, InstKind Kind, SizeT MaxSrcs, Variable *Dest)
: 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 @@ InstArithmetic::InstArithmetic(Cfg *Func, OpKind Op, Variable *Dest,
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 @@ void Inst::dump(const Cfg *Func) const {
return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " =~ ";
Str << " =~ " << getInstName() << " ";
dumpSources(Func);
}
......@@ -630,8 +676,7 @@ void InstArithmetic::dump(const Cfg *Func) const {
return;
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " = " << InstArithmeticAttributes[getOp()].DisplayString << " "
<< getDest()->getType() << " ";
Str << " = " << getInstName() << " " << getDest()->getType() << " ";
dumpSources(Func);
}
......
......@@ -76,6 +76,7 @@ public:
};
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 @@ public:
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;
......
......@@ -55,7 +55,8 @@ namespace Ice {
} 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)
......
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