<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
On 02/17/2016 12:49 AM, Ahmed Bougacha wrote:<br>
<blockquote
cite="mid:CAOprbYRtHy+KvrV3WzGVSaVMbvZ0=hSAS3341z+7wbbB3j2jnQ@mail.gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<div dir="ltr"><br>
<div class="gmail_extra">
<div class="gmail_quote">On Tue, Feb 16, 2016 at 9:30 PM,
Ethan J. Johnson via llvm-dev <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:llvm-dev@lists.llvm.org" target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a></a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Hello
all,<br>
<br>
Is there an easy way to get the human-readable opcode
mnemonic (e.g., "MOV32ri64", "CMP32ri8", "JLE_1") for a
MachineInstr? I am writing a backend analysis pass for
security research, where the idea is for a researcher to
examine the output of my pass and identify instructions
from it for use in an attack. Right now I'm representing
unique instructions with nondescript numeric symbols, like
"i28" for the 28th instruction; but it would be nice to
give the reader something more helpful like
"i28_MOV32ri64".<br>
<br>
MachineInstr doesn't have a getName() function like many
other LLVM IR/MachineIR objects; is there anything roughly
equivalent to this? I'm already using
MachineInstr::print() for debugging output, but it's far
too verbose for this purpose. I thought about trying to
parse the opcode mnemonic out of the print() output, until
I realized just how nasty that would be (not to mention
that it prints to a raw_ostream, not an in-memory string).<br>
</blockquote>
<div><br>
</div>
<div>The name (as well as some other information) is in
MCInstrInfo; if you have any kind of *InstrInfo (as, e.g.,
X86InstrInfo isa TargetInstrInfo isa MCInstrInfo), you
should be able to do:</div>
<div><br>
</div>
<div> TII->getName(MI->getOpcode());</div>
<div> </div>
<div>-Ahmed</div>
</div>
</div>
</div>
</blockquote>
<br>
That's exactly what I was looking for - thanks!<br>
<br>
Ethan Johnson<br>
<br>
<pre class="moz-signature" cols="72">--
Ethan J. Johnson
Computer Science PhD student, Systems group, University of Rochester
<a class="moz-txt-link-abbreviated" href="mailto:ejohns48@cs.rochester.edu">ejohns48@cs.rochester.edu</a>
<a class="moz-txt-link-abbreviated" href="mailto:ethanjohnson@acm.org">ethanjohnson@acm.org</a>
PGP public key available from public directory or on request</pre>
</body>
</html>