Index: src/IceInst.cpp |
diff --git a/src/IceInst.cpp b/src/IceInst.cpp |
index 1db9cee5261d3854c1ca9fcd5d6294cbf1e0e9c4..27f5349de9213c2c0d3de05f9d94478218859659 100644 |
--- a/src/IceInst.cpp |
+++ b/src/IceInst.cpp |
@@ -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) \ |
Jim Stichnoth
2016/01/27 22:31:51
If you want to take the X() approach, I would add
|
+ case InstrKind: \ |
+ return name |
John
2016/01/27 21:14:46
You could have just returned a capitalized version
Eric Holk
2016/01/27 21:28:10
Jim wanted them to be lowercase for use in dump(),
|
+ 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); |
} |