Firm Logo

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
  • ir_asm_constraint* input_constraints input constraints

  • size_t n_output_constraints number of output constraints

  • ir_asm_constraint* output_constraints output constraints

  • size_t n_clobbers number of clobbered registers/memory

  • ident** clobbers list of clobbered registers/memory

  • ident* text assembler text

Add

returns the sum of its operands

Inputs
  • left first operand

  • right second operand

Address

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

Inputs

None

Attributes
  • ir_entity* entity entity to operate on

Align

A symbolic constant that represents the alignment of a type

Inputs

None

Attributes
  • ir_type* type type to operate on

Alloc

Allocates a block of memory on the stack.

Inputs
  • mem memory dependency

  • size size of the block in bytes

Output Tuple
  • M memory result

  • res pointer to newly allocated memory

Attributes
  • unsigned alignment alignment of the memory block (must be a power of 2)

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

And

returns the result of a bitwise and operation of its operands

Inputs
  • left first operand

  • right second operand

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

None

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

Block

A basic block

Inputs
  • … additional inputs (oparity_variable)

Attributes
  • ir_entity* entity entity representing this block

Flags: None

Builtin

performs a backend-specific builtin.

Inputs
  • mem memory dependency

  • … additional inputs (oparity_variable)

Output Tuple
  • M memory result

Attributes
  • ir_builtin_kind kind kind of builtin

  • ir_type* type method type for the builtin call

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)

Output Tuple
  • 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
  • ir_type* type type of the call (usually type of the called procedure)

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
  • ir_relation relation Comparison relation

Flags: None

Cond

Conditionally change control flow.

Inputs
  • selector condition parameter

Output Tuple
  • false control flow if operand is "false"

  • true control flow if operand is "true"

Attributes
  • cond_jmp_predicate jmp_pred can indicate the most likely jump

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
  • ir_relation relation relation of value to bound

Flags: None

Const

Returns a constant value.

Inputs

None

Attributes
  • ir_tarval* tarval constant value (a tarval object)

Conv

Converts values between modes

Inputs
  • op operand

Flags: None

CopyB

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

Inputs
  • mem memory dependency

  • dst destination address

  • src source address

Attributes
  • ir_type* type type of copied data

  • ir_volatility volatility volatile CopyB nodes have a visible side-effect and may not be optimized

Deleted

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

Inputs

None

Flags: None

Div

returns the quotient of its 2 operands

Inputs
  • mem memory dependency

  • left first operand

  • right second operand

Output Tuple
  • M memory result

  • res result of computation

  • X_regular control flow when no exception occurs

  • X_except control flow when exception occured

Attributes
  • ir_mode* resmode mode of the result value

  • int no_remainder

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

None

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

Free

Frees a block of memory previously allocated by an Alloc node

Inputs
  • mem memory dependency

  • ptr pointer to the object to free

IJmp

Jumps to the code in its argument. The code has to be in the same function and the destination must be one of the blocks reachable by the tuple results

Inputs
  • target target address of the 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: None

Jmp

Jumps to the block connected through the out-value

Inputs

None

Flags: cfopcode

Load

Loads a value from memory (heap or stack).

Inputs
  • mem memory dependency

  • ptr address to load from

Output Tuple
  • M memory result

  • res result of load operation

  • X_regular control flow when no exception occurs

  • X_except control flow when exception occurred

Attributes
  • ir_mode* mode mode of the value to be loaded

  • ir_type* type The type of the object which is stored at ptr (need not match with mode)

  • ir_volatility volatility volatile loads are a visible side-effect and may not be optimized

  • ir_align unaligned pointers to unaligned loads don’t need to respect the load-mode/type alignments

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
  • ir_entity* entity entity which is selected

Flags: None

Minus

returns the additive inverse of its operand

Inputs
  • op operand

Flags: None

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

Output Tuple
  • M memory result

  • res result of computation

  • X_regular control flow when no exception occurs

  • X_except control flow when exception occured

Attributes
  • ir_mode* resmode mode of the result

Mul

returns the product of its operands

Inputs
  • left first operand

  • right second operand

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

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

NoMem

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

Inputs

None

Not

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

Inputs
  • op operand

Flags: None

Offset

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

Inputs

None

Attributes
  • ir_entity* entity entity to operate on

Or

returns the result of a bitwise or operation of its operands

Inputs
  • left first operand

  • right second operand

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

Flags: None

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

Proj

returns an entry of a tuple value

Inputs
  • pred the tuple value from which a part is extracted

Attributes
  • unsigned num number of tuple component to be extracted

Flags: None

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

Output Tuple
  • M memory result

  • X control flow to exception handler

Flags: cfopcode

Return

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

Inputs
  • mem memory dependency

  • … additional inputs (oparity_variable)

Flags: cfopcode

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
  • ir_type* type array type

Flags: None

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

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

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

Size

A symbolic constant that represents the size of a type

Inputs

None

Attributes
  • ir_type* type type to operate on

Start

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

Inputs

None

Output Tuple
  • M initial memory

  • P_frame_base frame base pointer

  • T_args function arguments

Store

Stores a value into memory (heap or stack).

Inputs
  • mem memory dependency

  • ptr address to store to

  • value value to store

Output Tuple
  • M memory result

  • X_regular control flow when no exception occurs

  • X_except control flow when exception occured

Attributes
  • ir_type* type The type of the object which is stored at ptr (need not match with value’s type)

  • ir_volatility volatility volatile stores are a visible side-effect and may not be optimized

  • ir_align unaligned pointers to unaligned stores don’t need to respect the load-mode/type alignments

Sub

returns the difference of its operands

Inputs
  • left first operand

  • right second operand

Flags: None

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

Output Tuple
  • default control flow if no other case matches

Attributes
  • unsigned n_outs number of outputs (including pn_Switch_default)

  • ir_switch_table* table table describing mapping from input values to Proj numbers

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

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

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

None