[llvm-dev] Break nested instructions?

David Chisnall via llvm-dev llvm-dev at lists.llvm.org
Fri Oct 16 05:37:08 PDT 2015

On 16 Oct 2015, at 13:28, Irini Stavrakantonaki <istavrak at ics.forth.gr> wrote:
> The language of LLVM allows an operand (as it is a Value) to refer to an Argument, Basic Block , User (-> Constant, Instruction, Operator). 
> So, an operand of an instruction can be an instruction. But, doesn't this mean that we CAN have an "inlined" instruction inside another one?!
> How can we say that LLVM doesn't allow nested instructions?!
> Sorry, if I miss something here, but this confuses me.

The operand is not the instruction, it’s the *result* of the instruction.  In LLVM IR’s C++ representation, the result of the instruction is represented as a pointer to the instruction, but there is no nesting.  In particular, the same instruction result can be used as operands multiple instructions (or multiple times as operands to the same instruction), but there is no nesting - the instruction only exists in one place (with a basic block as the parent) and is simply *referenced* from other instructions.

In contrast, constant expressions (because they are atemporal - they do not have to be evaluated at any a particular point, as long as the results are available at the relevant instruction) are referenced directly from within an instruction, they are not contained within a basic block.

In code generation, constant expressions will be turned into either a single numeric value or into a combination of relocations.


More information about the llvm-dev mailing list