Canumalla Anirudh
2015-May-01 08:27 UTC
[LLVMdev] Questions regarding the LLVM IR and the Instruction class
I have two questions that I need answers to . Hope somebody can help me 1) The LLVM IR has three forms of representation - In memory, bitcode representation and the human readable form. I would like to know the differences between the two representations if any. 2) I will explain my situation and then get to the second question: I needed the operands of instructions represented in strings and hence I used "curr_Ins->getOperand(0)->getname()", where curr_Ins was a variable of type Instruction* If there is an instruction that has a direct integer as an operand, I was unable to do this. I had to cast that operand to a ConstInt and then obtain its value (by the getValue() function) and then convert it to a string. If getOperand always returned Value* then why is it that if there was a Numerical operand I was unable to invoke the getName() function with it. Is it because getOperand(1) returned an object of different type when there was a numerical operand. If so, what are the possible types that can come as operands to instructions. Thanks in advance. Anirudh -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150501/6d8b220b/attachment.html>
David Blaikie
2015-May-01 16:25 UTC
[LLVMdev] Questions regarding the LLVM IR and the Instruction class
On Fri, May 1, 2015 at 1:27 AM, Canumalla Anirudh <anirudh.c.93 at gmail.com> wrote:> I have two questions that I need answers to . Hope somebody can help me > > 1) The LLVM IR has three forms of representation - In memory, bitcode > representation and the human readable form. I would like to know the > differences between the two representations if any. > > 2) I will explain my situation and then get to the second question: > > I needed the operands of instructions represented in strings and hence I > used > "curr_Ins->getOperand(0)->getname()", where curr_Ins was a variable of > type Instruction* > If there is an instruction that has a direct integer as an operand, I was > unable to do this. I had to cast that operand to a ConstInt and then obtain > its value (by the getValue() function) and then convert it to a string. > If getOperand always returned Value* then why is it that if there was a > Numerical operand I was unable to invoke the getName() function with it. Is > it because getOperand(1) returned an object of different type when there > was a numerical operand. If so, what are the possible types that can come > as operands to instructions. >Lots of things are values, not all of them have names. Here's he full taxonomy of Values: http://llvm.org/docs/doxygen/html/classllvm_1_1Value.html> > Thanks in advance. > > Anirudh > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150501/35018b6a/attachment.html>
Duncan P. N. Exon Smith
2015-May-01 20:11 UTC
[LLVMdev] Questions regarding the LLVM IR and the Instruction class
> On 2015-May-01, at 01:27, Canumalla Anirudh <anirudh.c.93 at gmail.com> wrote: > > I have two questions that I need answers to . Hope somebody can help me > > 1) The LLVM IR has three forms of representationBy design, the legal IR should be equivalent between the three forms. In practice, there are probably some bugs (I've fixed some in the past).> - In memory,This can be manipulated via the C++ API (and, to some extent, the C API).> bitcode representationThis can be efficiently serialized to/from disk, and has upgrade support from old (archived) files.> and the human readable form.This is human readable/writable.> I would like to know the differences between the two representations if any.HTH.