<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 6/12/17 1:09 AM, Dipanjan Das via
llvm-dev wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAEK-7JJjqTxq5Ra59i_6upUy2XhEECgjHvbo=YaBv9oevJ88PQ@mail.gmail.com">
<div dir="ltr"><br>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 11 June 2017 at 23:03, Craig
Topper <span dir="ltr"><<a
href="mailto:craig.topper@gmail.com" target="_blank"
moz-do-not-send="true">craig.topper@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Try value->dump() assuming you're using
a debug build.</div>
<div class="gmail_extra"><br clear="all">
</div>
</blockquote>
<div><br>
</div>
<div>The information displayed is non-uniform. There are two
different cases based on my sample program:</div>
<div><br>
</div>
<div> (1) dump() shows the Type and *some* value
which I don't understand what it is</div>
<div> (2) dump() shows the instruction that creates
the Value*</div>
<div><br>
</div>
<div>But, it doesn't display the concrete sub-class.</div>
</div>
</div>
</div>
</blockquote>
<br>
The LLVM class names are largely one-to-one with the instructions
defined in the LLVM Language Reference. The main exception is the
class of operators that get bundled into the BinaryOperator class
(e.g., add, or, xor, fadd, etc.), and BinaryOperator is one of those
classes that Doxygen completely chokes on since it's so macro-heavy.
Browsing the subclass list of llvm::Instruction on Doxygen for
something that looks like the name of the instruction in question.<br>
<br>
The other main set of values are the constants. In the dump output,
constant scalars (such as ConstantFP, ConstantInt,
ConstantPointerNull) show up as <type> <val>, e.g., i64
0 or double 0.0. The ConstantAggregateZero class shows up as
zeroinitializer, and ConstantExprs show up as something like trunc
(<expr> to <ty>). Again, you can read the language
manual to see examples, it's usually pretty clear what type
something is.<br>
<br>
If you're dead set on actually printing the name of the class of a
Value, there's no canned method to do that. Something like this code
would work (untested):<br>
const char *kind_name = nullptr;<br>
switch(val->getValueID()) {<br>
#define HANDLE_VALUE(name) case Value::name##Val: kind_name = #name;
break;<br>
default: kind_name = "well this was unexpected";<br>
}<br>
<pre class="moz-signature" cols="72">--
Joshua Cranmer
Thunderbird and DXR developer
Source code archæologist</pre>
</body>
</html>