Instruction¶
- class Instruction (abstract, logical)¶
An instruction within a control flow block.
Evaluation of an instruction happens in these separate steps:
fetching of input operands (SLoc currently not stored in IR)
computation of the address for the left (output) operand (SLoc via
Left_Physical)evaluation of the instruction = computation of the instruction’s value (SLoc via
Physical)storage of the value in the write operand (SLoc via
Physical_For_Assignment)
Some instructions are exceptions to this evaluation schema, e.g.:
Discard_Instruction does not fetch the input operands
Call_Instruction uses “alias semantics” for input operands and the output operand; and thus does not have step 1 or step 4 as such.
See those instructions for more details.
- Direct parents:
inherits Execution_Node
- Ancestor classes and implemented interfaces:
- Direct child classes:
subclass Exit_Scope_Instruction
subclass Copy_Assignment_Instruction
subclass Error_Instruction
subclass Assembler_Instruction
subclass Unary_Instruction
subclass Binary_Instruction
subclass Vector_Select_Instruction
subclass VLA_Allocate_Instruction
subclass Platform_Select_Instruction
subclass Literal_Instruction
subclass Call_Instruction
subclass Managed_New_Buffer_Instruction
subclass Managed_Type_Of_Instruction
Field
Kind
Type
Description
Left
syntactic
class Operand
Where the result will be stored. This is always a write operand. (can be NULL, e.g., for calls to void funcs or assertion instructions. Check cafe’s
can_omit_lhs()for the full list of instructions that can have Left equal toNoNode.)Left_Physical
semantic to physical
class Physical_IR_Root
This edge instead points to the expression that represents the left operand, i.e., the expression that computed the glvalue where the result of the instruction will be stored.
For example, in
v = 42;(a LIR Integer_Literal_Instruction):The
Physicaledge points to the PIR Integer_Literal.The
Left_Physicaledge points to the Unqualified_Direct_Object_Selection for the variablev.And the
Physical_For_Assignmentedge points to the Assignment expression.
Its_Type
semantic
class Type
Result type of the instruction, needed especially to distinguish assignments of complete structs from assignments of their first fields. Also needed to determine multiplication factor for pointer additions. For Cast_Instructions, this is the type casted to
Physical_For_Assignment
semantic to physical
class Physical_IR_Root
Returns a PIR node for the assignment of the value that was computed by this instruction.
For example, in
v = 42;(a LIR Integer_Literal_Instruction):The
Physicaledge points to the PIR Integer_Literal.The
Left_Physicaledge points to the Unqualified_Direct_Object_Selection for the variablev.And the
Physical_For_Assignmentedge points to the Assignment expression.
Parent (from Logical_IR_Root)
semantic
class CFG_Standard_Block
Physical (from Logical_IR_Root)
semantic to physical
class Physical_IR_Root