Firm Node Types
ASM
executes assembler fragments of the target machine
Inputs
- mem
- memory dependency
- ...
- additional inputs (oparity_variable)
Attributes
- input_constraints
- input constraints (ir_asm_constraint*)
- n_output_constraints
- number of output constraints (size_t)
- output_constraints
- output constraints (ir_asm_constraint*)
- n_clobbers
- number of clobbered registers/memory (size_t)
- clobbers
- list of clobbered registers/memory (ident**)
- text
- assembler text (ident*)
Flags
keep,
uses_memory
Add
returns the sum of its operands
Inputs
- left
- first operand
- right
- second operand
Flags
commutative
Alloc
allocates a block of memory.
It can be specified whether the memory should be allocated to the stack
or to the heap.
Allocates memory for one or more objects (depending on value on count input).
Inputs
- mem
- memory dependency
- count
- number of objects to allocate
Outputs
- M
- memory result
- res
- pointer to newly allocated memory
- X_regular
- control flow when no exception occurs
- X_except
- control flow when exception occured
Attributes
- type
- type of the objects to allocate (ir_type*)
- where
- whether to allocate the variable on the stack or heap (ir_where_alloc)
Flags
fragile,
uses_memory
Anchor
utiliy node used to "hold" nodes in a graph that might possibly not be
reachable by other means or which should be reachable immediately without
searching through the graph.
Each firm-graph contains exactly one anchor node whose address is always
known. All other well-known graph-nodes like Start, End, NoMem, Bad, ...
are found by looking at the respective Anchor operand.
Inputs
- ...
- additional inputs (oparity_variable)
Flags
dump_noblock
And
returns the result of a bitwise and operation of its operands
Inputs
- left
- first operand
- right
- second operand
Flags
commutative
Bad
Bad nodes indicate invalid input, which is values which should never be
computed.
The typical use case for the Bad node is removing unreachable code.
Frontends should set the current_block to Bad when it is clear that
following code must be unreachable (ie. after a goto or return statement).
Optimisations also set block predecessors to Bad when it becomes clear,
that a control flow edge can never be executed.
The gigo optimisations ensures that nodes with Bad as their block, get
replaced by Bad themselfes. Nodes with at least 1 Bad input get exchanged
with Bad too. Exception to this rule are Block, Phi, Tuple and End node;
This is because removing inputs from a Block is hairy operation (requiring,
Phis to be shortened too for example). So instead of removing block inputs
they are set to Bad, and the actual removal is left to the control flow
optimisation phase. Block, Phi, Tuple with only Bad inputs however are
replaced by Bad right away.
Inputs
Flags
start_block,
dump_noblock
Block
A basic block
Inputs
- ...
- additional inputs (oparity_variable)
Attributes
- entity
- entity representing this block (ir_entity*)
Flags
labeled
Borrow
Returns the borrow bit from and implied subtractions of its 2 operands
Inputs
- left
- first operand
- right
- second operand
Flags
Bound
Performs a bounds-check: if lower <= index < upper then return index,
otherwise throw an exception.
Inputs
- mem
- memory dependency
- index
- value to test
- lower
- lower bound (inclusive)
- upper
- upper bound (exclusive)
Outputs
- M
- memory result
- res
- the checked index
- X_regular
- control flow when no exception occurs
- X_except
- control flow when exception occured
Flags
fragile,
highlevel
Builtin
performs a backend-specific builtin.
Inputs
- mem
- memory dependency
- ...
- additional inputs (oparity_variable)
Outputs
- M
- memory result
Attributes
- kind
- kind of builtin (ir_builtin_kind)
- type
- method type for the builtin call (ir_type*)
Flags
uses_memory
Call
Calls other code. Control flow is transfered to ptr, additional
operands are passed to the called code. Called code usually performs a
return operation. The operands of this return operation are the result
of the Call node.
Inputs
- mem
- memory dependency
- ptr
- pointer to called code
- ...
- additional inputs (oparity_variable)
Outputs
- M
- memory result
- T_result
- tuple containing all results
- X_regular
- control flow when no exception occurs
- X_except
- control flow when exception occured
Attributes
- type
- type of the call (usually type of the called procedure) (ir_type*)
Flags
fragile,
uses_memory
Carry
Computes the value of the carry-bit that would result when adding the 2
operands
Inputs
- left
- first operand
- right
- second operand
Flags
commutative
Cast
perform a high-level type cast
Inputs
- op
- operand
Attributes
- type
- target type of the case (ir_type*)
Flags
highlevel
Cmp
Compares its two operands and checks whether a specified
relation (like less or equal) is fulfilled.
Inputs
- left
- first operand
- right
- second operand
Attributes
- relation
- Comparison relation (ir_relation)
Flags
Cond
Conditionally change control flow.
Inputs
- selector
- condition parameter
Outputs
- false
- control flow if operand is "false"
- true
- control flow if operand is "true"
Attributes
- jmp_pred
- can indicate the most likely jump (cond_jmp_predicate)
Flags
cfopcode,
forking
Confirm
Specifies constraints for a value. This allows explicit representation
of path-sensitive properties. (Example: This value is always >= 0 on 1
if-branch then all users within that branch are rerouted to a confirm-node
specifying this property).
A constraint is specified for the relation between value and bound.
value is always returned.
Note that this node does NOT check or assert the constraint, it merely
specifies it.
Inputs
- value
- value to express a constraint for
- bound
- value to compare against
Attributes
- relation
- relation of value to bound (ir_relation)
Flags
highlevel
Const
Returns a constant value.
Inputs
Attributes
- tarval
- constant value (a tarval object) (ir_tarval*)
Flags
constlike,
start_block
Conv
Converts values between modes
Inputs
- op
- operand
Attributes
- strict
- force floating point to restrict precision even if backend computes in higher precision (deprecated) (int)
Flags
CopyB
Copies a block of memory with statically known size/type.
Inputs
- mem
- memory dependency
- dst
- destination address
- src
- source address
Outputs
- M
- memory result
- X_regular
- control flow when no exception occurs
- X_except
- control flow when exception occured
Attributes
- type
- type of copied data (ir_type*)
Flags
fragile,
uses_memory
Deleted
Internal node which is temporary set to nodes which are already removed
from the graph.
Inputs
Flags
Div
returns the quotient of its 2 operands
Inputs
- mem
- memory dependency
- left
- first operand
- right
- second operand
Outputs
- M
- memory result
- res
- result of computation
- X_regular
- control flow when no exception occurs
- X_except
- control flow when exception occured
Attributes
- resmode
- mode of the result value (ir_mode*)
- no_remainder
- (int)
Flags
fragile,
uses_memory
Dummy
A placeholder value. This is used when constructing cyclic graphs where
you have cases where not all predecessors of a phi-node are known. Dummy
nodes are used for the unknown predecessors and replaced later.
Inputs
Flags
cfopcode,
start_block,
constlike,
dump_noblock
End
Last node of a graph. It references nodes in endless loops (so called
keepalive edges)
Inputs
- ...
- inputs dynamically mananged (oparity_dynamic)
Flags
cfopcode
Eor
returns the result of a bitwise exclusive or operation of its operands.
This is also known as the Xor operation.
Inputs
- left
- first operand
- right
- second operand
Flags
commutative
Free
Frees a block of memory previously allocated by an Alloc node
Inputs
- mem
- memory dependency
- ptr
- pointer to the object to free
- count
- number of objects to allocate
Attributes
- type
- type of the allocated variable (ir_type*)
- where
- whether allocation was on the stack or heap (ir_where_alloc)
Flags
uses_memory
IJmp
Jumps to the code in its argument. The code has to be in the same
function and the the destination must be one of the blocks reachable
by the tuple results
Inputs
- target
- target address of the jump
Flags
cfopcode,
forking,
keep,
unknown_jump
Id
Returns its operand unchanged.
This is mainly used when exchanging nodes. Usually you shouldn't see Id
nodes since the getters/setters for node inputs skip them automatically.
Inputs
- pred
- the value which is returned unchanged
Flags
InstOf
Tests whether an object is an instance of a class-type
Inputs
- store
- memory dependency
- obj
- pointer to object being queried
Outputs
- M
- memory result
- res
- checked object pointer
- X_regular
- control flow when no exception occurs
- X_except
- control flow when exception occured
Attributes
- type
- type to check ptr for (ir_type*)
Flags
highlevel
Jmp
Jumps to the block connected through the out-value
Inputs
Flags
cfopcode
Load
Loads a value from memory (heap or stack).
Inputs
- mem
- memory dependency
- ptr
- address to load from
Outputs
- M
- memory result
- res
- result of load operation
- X_regular
- control flow when no exception occurs
- X_except
- control flow when exception occured
Attributes
- mode
- mode of the value to be loaded (ir_mode*)
- volatility
- volatile loads are a visible side-effect and may not be optimized (ir_volatility)
- unaligned
- pointers to unaligned loads don't need to respect the load-mode/type alignments (ir_align)
Flags
fragile,
uses_memory
Minus
returns the difference between its operands
Inputs
- op
- operand
Flags
Mod
returns the remainder of its operands from an implied division.
Examples:
- mod(5,3) produces 2
- mod(5,-3) produces 2
- mod(-5,3) produces -2
- mod(-5,-3) produces -2
Inputs
- mem
- memory dependency
- left
- first operand
- right
- second operand
Outputs
- M
- memory result
- res
- result of computation
- X_regular
- control flow when no exception occurs
- X_except
- control flow when exception occured
Attributes
- resmode
- mode of the result (ir_mode*)
Flags
fragile,
uses_memory
Mul
returns the product of its operands
Inputs
- left
- first operand
- right
- second operand
Flags
commutative
Mulh
returns the upper word of the product of its operands (the part which
would not fit into the result mode of a normal Mul anymore)
Inputs
- left
- first operand
- right
- second operand
Flags
commutative
Mux
returns the false or true operand depending on the value of the sel
operand
Inputs
- sel
- value making the output selection
- false
- selected if sel input is false
- true
- selected if sel input is true
Flags
Not
returns the bitwise complement of a value. Works for boolean values, too.
Inputs
- op
- operand
Flags
Or
returns the result of a bitwise or operation of its operands
Inputs
- left
- first operand
- right
- second operand
Flags
commutative
Phi
Choose a value based on control flow. A phi node has 1 input for each
predecessor of its block. If a block is entered from its nth predecessor
all phi nodes produce their nth input as result.
Inputs
- ...
- additional inputs (oparity_variable)
Flags
Pin
Pin the value of the node node in the current block. No users of the Pin
node can float above the Block of the Pin. The node cannot float behind
this block. Often used to Pin the NoMem node.
Inputs
- op
- value which is pinned
Flags
highlevel
Proj
returns an entry of a tuple value
Inputs
- pred
- the tuple value from which a part is extracted
Attributes
- proj
- number of tuple component to be extracted (long)
Flags
Raise
Raises an exception. Unconditional change of control flow. Writes an
explicit Except variable to memory to pass it to the exception handler.
Must be lowered to a Call to a runtime check function.
Inputs
- mem
- memory dependency
- exo_ptr
- pointer to exception object to be thrown
Outputs
- M
- memory result
- X
- control flow to exception handler
Flags
highlevel,
cfopcode
Return
Returns from the current function. Takes memory and return values as
operands.
Inputs
- mem
- memory dependency
- ...
- additional inputs (oparity_variable)
Flags
cfopcode
Rotl
Returns its first operand bits rotated left by the amount in the 2nd
operand
Inputs
- left
- first operand
- right
- second operand
Flags
Sel
Computes the address of a entity of a compound type given the base
address of an instance of the compound type.
Optimisations assume that a Sel node can only produce a NULL pointer if the
ptr input was NULL.
Inputs
- mem
- memory dependency
- ptr
- pointer to object to select from
- ...
- additional inputs (oparity_variable)
Attributes
- entity
- entity which is selected (ir_entity*)
Flags
Shl
Returns its first operands bits shifted left by the amount of the 2nd
operand
Inputs
- left
- first operand
- right
- second operand
Flags
Shr
Returns its first operands bits shifted right by the amount of the 2nd
operand. No special handling for the sign bit (zero extension)
Inputs
- left
- first operand
- right
- second operand
Flags
Shrs
Returns its first operands bits shifted right by the amount of the 2nd
operand. The leftmost bit (usually the sign bit) stays the same
(sign extension)
Inputs
- left
- first operand
- right
- second operand
Flags
Start
The first node of a graph. Execution starts with this node.
Inputs
Outputs
- X_initial_exec
- control flow
- M
- initial memory
- P_frame_base
- frame base pointer
- T_args
- function arguments
Flags
cfopcode
Store
Stores a value into memory (heap or stack).
Inputs
- mem
- memory dependency
- ptr
- address to store to
- value
- value to store
Outputs
- M
- memory result
- X_regular
- control flow when no exception occurs
- X_except
- control flow when exception occured
Attributes
- volatility
- volatile stores are a visible side-effect and may not be optimized (ir_volatility)
- unaligned
- pointers to unaligned stores don't need to respect the load-mode/type alignments (ir_align)
Flags
fragile,
uses_memory
Sub
returns the difference of its operands
Inputs
- left
- first operand
- right
- second operand
Flags
Switch
Change control flow. The destination is choosen based on an integer input value which is looked up in a table.
Backends can implement this efficiently using a jump table.
Inputs
- selector
- input selector
Outputs
- default
- control flow if no other case matches
Attributes
- n_outs
- number of outputs (including pn_Switch_default) (unsigned)
- table
- table describing mapping from input values to Proj numbers (ir_switch_table*)
Flags
cfopcode,
forking
SymConst
A symbolic constant.
- symconst_type_size The symbolic constant represents the size of a type.
The type of which the constant represents the size
is given explicitly.
- symconst_type_align The symbolic constant represents the alignment of a
type. The type of which the constant represents the
size is given explicitly.
- symconst_addr_ent The symbolic constant represents the address of an
entity (variable or method). The variable is given
explicitly by a firm entity.
- symconst_ofs_ent The symbolic constant represents the offset of an
entity in its owner type.
- symconst_enum_const The symbolic constant is a enumeration constant of
an enumeration type.
Inputs
Attributes
- entity
- entity whose address is returned (ir_entity*)
Flags
constlike,
start_block
Sync
The Sync operation unifies several partial memory blocks. These blocks
have to be pairwise disjunct or the values in common locations have to
be identical. This operation allows to specify all operations that
eventually need several partial memory blocks as input with a single
entrance by unifying the memories with a preceding Sync operation.
Inputs
- ...
- inputs dynamically mananged (oparity_dynamic)
Flags
Tuple
Builds a Tuple from single values.
This is needed to implement optimizations that remove a node that produced
a tuple. The node can be replaced by the Tuple operation so that the
following Proj nodes have not to be changed. (They are hard to find due to
the implementation with pointers in only one direction.) The Tuple node is
smaller than any other node, so that a node can be changed into a Tuple by
just changing its opcode and giving it a new in array.
Inputs
- ...
- additional inputs (oparity_variable)
Flags
labeled
Unknown
Returns an unknown (at compile- and runtime) value. It is a valid
optimisation to replace an Unknown by any other constant value.
Inputs
Flags
start_block,
constlike,
dump_noblock