[LLVMdev] The source & result operands of an instruction

Chris Lattner sabre at nondot.org
Thu Dec 30 11:09:01 PST 2004


On Thu, 30 Dec 2004, zhou feng wrote:

> hi, all
> I'm reading LLVM code, but there is one thing bothering me a lot: How
> are the source & result operands of an instruction organised? Is the
> operand(0) the result operand and others are the source operand? thanks

The "operands" of an instruction are the values that it uses.  The result 
is always implicitly the instruction itself.  For example, consider this 
LLVM instruction:

   %X = add int %Y, %Z

This instruction will have two operands, one for Y and one for Z.  The %X 
value is actually the *add instruction itself*.  Because LLVM uses SSA 
form, each value can only be defined by a single instruction. 
Additionally, each instruction defines at most one value.

You might find some of the information in the programmer's manual useful, 
such as this section:
http://llvm.cs.uiuc.edu/docs/ProgrammersManual.html#iterate_chains

If you haven't looked at it, the Programmer's Manual has lots of useful 
gems in it.

-Chris

-- 
http://nondot.org/sabre/
http://llvm.cs.uiuc.edu/




More information about the llvm-dev mailing list