Firm Node Types

ASM

executes assembler fragments of the target machine.

The node contains a template for an assembler snippet. The compiler will replace occurences of %0 to %9 with input/output registers, %% with a single % char. Some backends allow additional specifiers (for example %w3, %l3, %h3 on x86 to get a 16bit, 8hit low, 8bit high part of a register). After the replacements the text is emitted into the final assembly.

The clobber list contains names of registers which have an undefined value after the assembler instruction is executed; it may also contain 'memory' or 'cc' if global state/memory changes or the condition code registers (some backends implicitely set cc, memory clobbers on all ASM statements).

Example (an i386 instruction):

ASM(text="btsl %1, %0",
        input_constraints = ["=m", "r"],
        clobbers = ["cc"])

As there are no output, the %0 references the first input which is just an address which the asm operation writes to. %1 references to an input which is passed as a register. The condition code register has an unknown value after the instruction.

(This format is inspired by the gcc extended asm syntax)

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
API

Add

returns the sum of its operands

Inputs
left
first operand
right
second operand
Flags
commutative
API

Address

Symbolic constant that represents the address of an entity (variable or method)

Inputs
Attributes
entity
entity to operate on (ir_entity*)
Flags
constlike, start_block
API

Align

A symbolic constant that represents the alignment of a type

Inputs
Attributes
type
type to operate on (ir_type*)
Flags
constlike, start_block
API

Alloc

Allocates a block of memory on the stack.

Inputs
mem
memory dependency
size
size of the block in bytes
Outputs
M
memory result
res
pointer to newly allocated memory
Attributes
alignment
alignment of the memory block (must be a power of 2) (unsigned)
Flags
uses_memory, const_memory
API

Anchor

Utility 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, ... are found by looking at the respective Anchor operand.

Inputs
end_block
block the end node belongs to
start_block
block the start node belongs to
end
end node of this ir_graph
start
start node of this ir_graph
frame
frame of this ir_graph
initial_mem
initial memory of this ir_graph
args
argument proj of the start node
no_mem
the only NoMem node of this ir_graph
Flags
dump_noblock
API

And

returns the result of a bitwise and operation of its operands

Inputs
left
first operand
right
second operand
Flags
commutative
API

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). Optimizations also set block predecessors to Bad when it becomes clear, that a control flow edge can never be executed.

The gigo optimizations ensures that nodes with Bad as their block, get replaced by Bad themselves. 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 optimization phase. Block, Phi, Tuple with only Bad inputs however are replaced by Bad right away.

In the future we may use the Bad node to model poison values that arise from undefined behaviour like reading uninitialized local variables in C.

Inputs
Flags
start_block, dump_noblock
API

Bitcast

Converts a value between modes with different arithmetics but same number of bits by reinterpreting the bits in the new mode

Inputs
op
operand
Flags
None
API

Block

A basic block

Inputs
...
additional inputs (oparity_variable)
Attributes
entity
entity representing this block (ir_entity*)
Flags
None
API

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
API

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
API

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
None
API

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
API

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
None
API

Const

Returns a constant value.

Inputs
Attributes
tarval
constant value (a tarval object) (ir_tarval*)
Flags
constlike, start_block
API

Conv

Converts values between modes

Inputs
op
operand
Flags
None
API

CopyB

Copies a block of memory with statically known size/type.

Inputs
mem
memory dependency
dst
destination address
src
source address
Attributes
type
type of copied data (ir_type*)
volatility
volatile CopyB nodes have a visible side-effect and may not be optimized (ir_volatility)
Flags
uses_memory
API

Deleted

Internal node which is temporary set to nodes which are already removed from the graph.

Inputs
Flags
None
API

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, const_memory
API

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
API

End

Last node of a graph. It references nodes in endless loops (so called keepalive edges)

Inputs
...
inputs dynamically mananged (oparity_dynamic)
Flags
cfopcode
API

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
API

Free

Frees a block of memory previously allocated by an Alloc node

Inputs
mem
memory dependency
ptr
pointer to the object to free
Flags
uses_memory, const_memory
API

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
API

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
None
API

Jmp

Jumps to the block connected through the out-value

Inputs
Flags
cfopcode
API

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*)
type
The type of the object which is stored at ptr (need not match with mode) (ir_type*)
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, const_memory
API

Member

Computes the address of a compound type member given the base address of an instance of the compound type.

A Member node must only produce a NULL pointer if the ptr input is NULL.

Inputs
ptr
pointer to object to select from
Attributes
entity
entity which is selected (ir_entity*)
Flags
None
API

Minus

returns the additive inverse of its operand

Inputs
op
operand
Flags
None
API

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, const_memory
API

Mul

returns the product of its operands

Inputs
left
first operand
right
second operand
Flags
commutative
API

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
API

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
None
API

NoMem

Placeholder node for cases where you don't need any memory input

Inputs
Flags
dump_noblock, start_block
API

Not

returns the bitwise complement of a value. Works for boolean values, too.

Inputs
op
operand
Flags
None
API

Offset

Symbolic constant that represents the offset of an entity in its owner type.

Inputs
Attributes
entity
entity to operate on (ir_entity*)
Flags
constlike, start_block
API

Or

returns the result of a bitwise or operation of its operands

Inputs
left
first operand
right
second operand
Flags
commutative
API

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)
Attributes
loop
wether Phi represents the observable effect of a (possibly) nonterminating loop (int)
Flags
None
API

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
None
API

Proj

returns an entry of a tuple value

Inputs
pred
the tuple value from which a part is extracted
Attributes
num
number of tuple component to be extracted (unsigned)
Flags
None
API

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
cfopcode
API

Return

Returns from the current function. Takes memory and return values as operands.

Inputs
mem
memory dependency
...
additional inputs (oparity_variable)
Flags
cfopcode
API

Sel

Computes the address of an array element from the array base pointer and an index.

A Sel node must only produce a NULL pointer if the ptr input is NULL.

Inputs
ptr
pointer to array to select from
index
index to select
Attributes
type
array type (ir_type*)
Flags
None
API

Shl

Returns its first operands bits shifted left by the amount of the 2nd operand. The right input (shift amount) must be an unsigned integer value. If the result mode has modulo_shift!=0, then the effective shift amount is the right input modulo this modulo_shift amount.

Inputs
left
first operand
right
second operand
Flags
None
API

Shr

Returns its first operands bits shifted right by the amount of the 2nd operand. No special handling for the sign bit is performed (zero extension). The right input (shift amount) must be an unsigned integer value. If the result mode has modulo_shift!=0, then the effective shift amount is the right input modulo this modulo_shift amount.

Inputs
left
first operand
right
second operand
Flags
None
API

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). The right input (shift amount) must be an unsigned integer value. If the result mode has modulo_shift!=0, then the effective shift amount is the right input modulo this modulo_shift amount.

Inputs
left
first operand
right
second operand
Flags
None
API

Size

A symbolic constant that represents the size of a type

Inputs
Attributes
type
type to operate on (ir_type*)
Flags
constlike, start_block
API

Start

The first node of a graph. Execution starts with this node.

Inputs
Outputs
M
initial memory
P_frame_base
frame base pointer
T_args
function arguments
Flags
start_block
API

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
type
The type of the object which is stored at ptr (need not match with value's type) (ir_type*)
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
API

Sub

returns the difference of its operands

Inputs
left
first operand
right
second operand
Flags
None
API

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
API

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
None
API

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
None
API

Unknown

Returns an unknown (at compile- and runtime) value. It is a valid optimization to replace an Unknown by any other constant value.

Be careful when optimising Unknown values, you cannot simply replace Unknown+x or Unknown<x with a new Unknown node if there are multiple users of the original unknown node!

Inputs
Flags
start_block, constlike, dump_noblock
API