[LLVMdev] get the value of a Constant in LLVM IR

Eirini Psallida eirini.psallida at gmail.com
Thu Oct 17 06:42:30 PDT 2013


Hello,
i parse the llvm IR (llvm-3.3 version) and when i meet a constant, i want
to get it's value.
eg i32 5,   i want to get the 5.
I am interested in ConstantInt-ConstantFP-ConstantArray-ConstantStruct
subclasses.
Things are a bit easier with ConstantInt and ConstantFP constants but how
could i get the value of a ConstantArray?
The
http://llvm.org/docs/ProgrammersManual.html#the-constant-class-and-subclasses
says:
ConstantArray : This represents a constant array.
const std::vector<Use> &getValues() const: Returns a vector of component
constants that makeup this array.
But i cannot find this method, i think that it is not implemented in the
3.3 version.
There is the method 'Value::print()' but this gives me also the type which
is not what i want.
I found also the 'static void WriteConstantInternal()' method in
llvm/lib/IR/AsmWriter.cpp which is called
by 'Value::print()' but it is 'static' so i cannot access it.  I need
something like the 'WriteConstantInternal' method.
Any ideas?

Thanks

Eirini
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131017/97f2c88a/attachment.html>


More information about the llvm-dev mailing list