[llvm-dev] Break nested instructions?

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


On 16 Oct 2015, at 12:55, Irini Stavrakantonaki via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> In case the operands of instructions are always meant to be constant exprs, then it's simple to handle them differently by having different adaptor classes
> as David proposed before.

The operands of instructions are always values.  There’s some confusion in the terminology here, because the language reference (along with the human-readable serialisation, and most SSA textbooks) refers to registers.

Every instruction that has a value (i.e. basically everything except call instructions that return void) implicitly defines a new register.  In the C++ form of the IR, the register value and the instruction are not distinct: the Instruction is a subclass of Value and is used directly.  This works because of the SSA form: registers are only defined once, by one instruction, so using a pointer to the Instruction works fine (the only book keeping required is to have a name associated with the instruction).

LLVM does not allow nested instructions.  Functions contain basic blocks, basic blocks contain instructions.  Instructions *refer to* other values as operands.  These values are either local registers (other instructions), global values, or constant expressions.  Constant expressions can only refer to globals or other constant expressions (and then, only to the address of the global, which is a constant, not to its value).

David



More information about the llvm-dev mailing list