Hi, I am curious to know the design decision on why operands of LLVM IR instructions are type annotated. Why wasn't the C style of explicit declaration of variables (or values in LLVM context) followed by their uses model not adopted here? or may be even annotate the value (result of the Instruction) with type rather than annotating each operands on the Instruction? Just felt that by annotating each operand with types may make the Instruction 'complex' to understand. May be I am wrong. Thanks for any explanation, -- Rekha -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141027/51ee72ed/attachment.html>
On 27 Oct 2014, at 12:46, Rekha R <rekharamapai at nitc.ac.in> wrote:> Why wasn't the C style of explicit declaration of variables (or values in LLVM context) followed by their uses model not adopted here?For the simple reason that there are no variables in LLVM IR. The SSA form means that every value is declared and initialised exactly once. Some values, such as constant integers, are created (in the text serialisation) inline in their use so there is no point where they are declared.> or may be even annotate the value (result of the Instruction) with type rather than annotating each operands on the Instruction? > > Just felt that by annotating each operand with types may make the Instruction 'complex' to understand. May be I am wrong.You will find it much easier to read when you are debugging. The IR is not intended to be read or written by humans, the text serialisation is there as a debugging aid when something has gone wrong. It is *very* useful to be able to look at a single instruction and see all of the types, without having to chase through a load of other parts of the code to find where things were declared. David
Hi, Thank you David. My question was from a machine independent code analyzer/optimizer perspective where types are of less importance. Hence I felt difficult to understand the IR with the types. Rekha On Mon, Oct 27, 2014 at 6:44 PM, David Chisnall <David.Chisnall at cl.cam.ac.uk> wrote:> On 27 Oct 2014, at 12:46, Rekha R <rekharamapai at nitc.ac.in> wrote: > > > Why wasn't the C style of explicit declaration of variables (or values > in LLVM context) followed by their uses model not adopted here? > > For the simple reason that there are no variables in LLVM IR. The SSA > form means that every value is declared and initialised exactly once. Some > values, such as constant integers, are created (in the text serialisation) > inline in their use so there is no point where they are declared. > > > or may be even annotate the value (result of the Instruction) with type > rather than annotating each operands on the Instruction? > > > > Just felt that by annotating each operand with types may make the > Instruction 'complex' to understand. May be I am wrong. > > You will find it much easier to read when you are debugging. The IR is > not intended to be read or written by humans, the text serialisation is > there as a debugging aid when something has gone wrong. It is *very* > useful to be able to look at a single instruction and see all of the types, > without having to chase through a load of other parts of the code to find > where things were declared. > > David > >-- Rekha -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141027/83c3e984/attachment.html>