libFirm
Node Opcodes

This module specifies the opcodes for ir nodes. More...

Typedefs

typedef struct ir_op ir_op
 Node Opcode. More...
 
typedef void(* op_func) (void)
 A generic function pointer type. More...
 
typedef unsigned(* hash_func) (const ir_node *self)
 The hash operation. More...
 
typedef ir_tarval *(* computed_value_func) (const ir_node *self)
 The compute value operation. More...
 
typedef ir_node *(* equivalent_node_func) (ir_node *self)
 The equivalent node operation. More...
 
typedef ir_node *(* transform_node_func) (ir_node *self)
 The transform node operation. More...
 
typedef int(* node_attrs_equal_func) (const ir_node *a, const ir_node *b)
 The node attribute compare operation. More...
 
typedef int(* reassociate_func) (ir_node **n)
 The reassociation operation. More...
 
typedef void(* copy_attr_func) (ir_graph *irg, const ir_node *old_node, ir_node *new_node)
 The copy attribute operation. More...
 
typedef ir_type *(* get_type_attr_func) (const ir_node *self)
 The get_type_attr operation. More...
 
typedef ir_entity *(* get_entity_attr_func) (const ir_node *self)
 The get_entity_attr operation. More...
 
typedef int(* verify_node_func) (const ir_node *node)
 The verify_node operation. More...
 
typedef int(* verify_proj_node_func) (const ir_node *proj)
 The verify_node operation for Proj(X). More...
 
typedef void(* dump_node_func) (FILE *out, const ir_node *self, dump_reason_t reason)
 The dump_node operation. More...
 

Enumerations

enum  op_arity { oparity_invalid = 0, oparity_binary, oparity_dynamic, oparity_any }
 The allowed arities. More...
 
enum  irop_flags {
  irop_flag_none = 0, irop_flag_commutative = 1U << 0, irop_flag_cfopcode = 1U << 1, irop_flag_fragile = 1U << 2,
  irop_flag_forking = 1U << 3, irop_flag_constlike = 1U << 5, irop_flag_keep = 1U << 6, irop_flag_start_block = 1U << 7,
  irop_flag_uses_memory = 1U << 8, irop_flag_dump_noblock = 1U << 9, irop_flag_unknown_jump = 1U << 11, irop_flag_const_memory = 1U << 12
}
 The irop flags. More...
 
enum  dump_reason_t { dump_node_opcode_txt, dump_node_mode_txt, dump_node_nodeattr_txt, dump_node_info_txt }
 Reasons to call the dump_node operation: More...
 
enum  ir_opcode {
  iro_ASM, iro_Add, iro_Address, iro_Align,
  iro_Alloc, iro_Anchor, iro_And, iro_Bad,
  iro_Bitcast, iro_Block, iro_Builtin, iro_Call,
  iro_Cmp, iro_Cond, iro_Confirm, iro_Const,
  iro_Conv, iro_CopyB, iro_Deleted, iro_Div,
  iro_Dummy, iro_End, iro_Eor, iro_Free,
  iro_IJmp, iro_Id, iro_Jmp, iro_Load,
  iro_Member, iro_Minus, iro_Mod, iro_Mul,
  iro_Mulh, iro_Mux, iro_NoMem, iro_Not,
  iro_Offset, iro_Or, iro_Phi, iro_Pin,
  iro_Proj, iro_Raise, iro_Return, iro_Sel,
  iro_Shl, iro_Shr, iro_Shrs, iro_Size,
  iro_Start, iro_Store, iro_Sub, iro_Switch,
  iro_Sync, iro_Tuple, iro_Unknown, iro_first = iro_ASM,
  iro_last = iro_Unknown
}
 The opcodes of the libFirm predefined operations. More...
 

Functions

const char * get_op_name (const ir_op *op)
 Returns the string for the opcode. More...
 
unsigned get_op_code (const ir_op *op)
 Returns the enum for the opcode. More...
 
const char * get_op_pin_state_name (op_pin_state s)
 Returns a human readable name of an op_pin_state. More...
 
op_pin_state get_op_pinned (const ir_op *op)
 Returns pinned state of an opcode. More...
 
unsigned get_next_ir_opcode (void)
 Returns the next free IR opcode number, allows to register user ops. More...
 
unsigned get_next_ir_opcodes (unsigned num)
 Returns the next free n IR opcode number, allows to register a bunch of user ops. More...
 
op_func get_generic_function_ptr (const ir_op *op)
 Returns the generic function pointer from an IR operation. More...
 
void set_generic_function_ptr (ir_op *op, op_func func)
 Stores a generic function pointer into an IR operation. More...
 
irop_flags get_op_flags (const ir_op *op)
 Returns the irop flags of an IR opcode. More...
 
void set_op_hash (ir_op *op, hash_func func)
 Sets hash callback func for operation op. More...
 
void set_op_computed_value (ir_op *op, computed_value_func func)
 Sets computed_value callback func for operation op. More...
 
void set_op_computed_value_proj (ir_op *op, computed_value_func func)
 Sets compute_value for Proj callback func for operation op. More...
 
void set_op_equivalent_node (ir_op *op, equivalent_node_func func)
 Sets equivalent node callback func for operation op. More...
 
void set_op_equivalent_node_proj (ir_op *op, equivalent_node_func func)
 Sets equivalent Proj node callback func for operation op. More...
 
void set_op_transform_node (ir_op *op, transform_node_func func)
 Sets transform node callback func for operation op. More...
 
void set_op_transform_node_proj (ir_op *op, transform_node_func func)
 Sets transform Proj node callback func for operation op. More...
 
void set_op_attrs_equal (ir_op *op, node_attrs_equal_func func)
 Sets attrs_equal callback func for operation op. More...
 
void set_op_reassociate (ir_op *op, reassociate_func func)
 Sets reassociation callback func for operation op. More...
 
void set_op_copy_attr (ir_op *op, copy_attr_func func)
 Sets attribute copy callback func for operation op. More...
 
void set_op_get_type_attr (ir_op *op, get_type_attr_func func)
 Sets get type callback func for operation op. More...
 
void set_op_get_entity_attr (ir_op *op, get_entity_attr_func func)
 Sets get entity callback func for operation op. More...
 
void set_op_verify (ir_op *op, verify_node_func func)
 Sets verify callback func for operation op. More...
 
void set_op_verify_proj (ir_op *op, verify_proj_node_func func)
 Sets proj verify callback func for operation op. More...
 
void set_op_dump (ir_op *op, dump_node_func func)
 Sets dump callback func for operation op. More...
 
ir_opnew_ir_op (unsigned code, const char *name, op_pin_state p, irop_flags flags, op_arity opar, int op_index, size_t attr_size)
 Creates a new IR operation. More...
 
void free_ir_op (ir_op *code)
 Frees an ir operation. More...
 
unsigned ir_get_n_opcodes (void)
 Returns one more than the highest opcode code in use. More...
 
ir_opir_get_opcode (unsigned code)
 Returns the opcode with code code. More...
 
void ir_clear_opcodes_generic_func (void)
 Sets the generic function pointer of all opcodes to NULL. More...
 
void ir_op_set_memory_index (ir_op *op, int memory_index)
 Sets memory input of operation using memory. More...
 
void ir_op_set_fragile_indices (ir_op *op, unsigned pn_x_regular, unsigned pn_x_except)
 Sets proj-number for X_regular and X_except projs of fragile nodes. More...
 

Detailed Description

This module specifies the opcodes for ir nodes.

Each node has an associated opcode. An opcode specifies basic attributes and properties of a node.

Typedef Documentation

typedef ir_tarval*(* computed_value_func) (const ir_node *self)

The compute value operation.

If a node is known to always produce a specific value, this value is returned, if it is known to always throw an exception or produce undefined behaviour (like division by zero) tarval_bad is returned, otherwise tarval_unknown is returned.

Definition at line 117 of file irop.h.

typedef void(* copy_attr_func) (ir_graph *irg, const ir_node *old_node, ir_node *new_node)

The copy attribute operation.

Copy the node attributes from an 'old' node to a 'new' one.

Definition at line 159 of file irop.h.

typedef void(* dump_node_func) (FILE *out, const ir_node *self, dump_reason_t reason)

The dump_node operation.

Writes several informations requested by reason to an output file

Definition at line 208 of file irop.h.

typedef ir_node*(* equivalent_node_func) (ir_node *self)

The equivalent node operation.

This operation returns an equivalent node for the input node. It does not create new nodes. It is therefore safe to free self if the node returned is not self. If a node returns a Tuple we can not just skip it. If the size of the in array fits, we transform n into a tuple (e.g., possible for Div).

Definition at line 127 of file irop.h.

typedef ir_entity*(* get_entity_attr_func) (const ir_node *self)

The get_entity_attr operation.

Used to traverse all entities that can be accessed from an ir_graph. Returns the entity attribute of the node self.

Definition at line 173 of file irop.h.

typedef ir_type*(* get_type_attr_func) (const ir_node *self)

The get_type_attr operation.

Used to traverse all types that can be accessed from an ir_graph. Returns the type attribute of the node self.

Definition at line 166 of file irop.h.

typedef unsigned(* hash_func) (const ir_node *self)

The hash operation.

This operation calculates a hash value for a given IR node.

Definition at line 108 of file irop.h.

typedef struct ir_op ir_op

Node Opcode.

Definition at line 56 of file firm_types.h.

typedef int(* node_attrs_equal_func) (const ir_node *a, const ir_node *b)

The node attribute compare operation.

Compares the nodes attributes of two nodes of identical opcode and returns 1 if the attributes are identical, 0 if they differ.

Definition at line 144 of file irop.h.

typedef void(* op_func) (void)

A generic function pointer type.

Definition at line 87 of file irop.h.

typedef int(* reassociate_func) (ir_node **n)

The reassociation operation.

Called from a walker. Returns non-zero if a reassociation rule was applied. The pointer n is set to the newly created node, if some reassociation was applied.

Definition at line 153 of file irop.h.

typedef ir_node*(* transform_node_func) (ir_node *self)

The transform node operation.

This operation tries several [inplace] [optimizing] transformations and returns an equivalent node. The difference to equivalent_node() is that these transformations do generate new nodes, and thus the old node must not be freed even if the equivalent node isn't the old one.

Definition at line 137 of file irop.h.

typedef int(* verify_node_func) (const ir_node *node)

The verify_node operation.

Returns non-zero if the node verification is ok, else 0. Depending on the node verification settings, may even assert.

See also
do_node_verification()

Definition at line 182 of file irop.h.

typedef int(* verify_proj_node_func) (const ir_node *proj)

The verify_node operation for Proj(X).

Returns non-zero if the node verification is ok, else 0. Depending on the node verification settings, may even assert.

See also
do_node_verification()

Definition at line 191 of file irop.h.

Enumeration Type Documentation

Reasons to call the dump_node operation:

Enumerator
dump_node_opcode_txt 

Dump the opcode.

dump_node_mode_txt 

Dump the mode.

dump_node_nodeattr_txt 

Dump node attributes to be shown in the label.

dump_node_info_txt 

Dump node attributes into info1.

Definition at line 196 of file irop.h.

enum ir_opcode

The opcodes of the libFirm predefined operations.

Enumerator
iro_ASM 
iro_Add 
iro_Address 
iro_Align 
iro_Alloc 
iro_Anchor 
iro_And 
iro_Bad 
iro_Bitcast 
iro_Block 
iro_Builtin 
iro_Call 
iro_Cmp 
iro_Cond 
iro_Confirm 
iro_Const 
iro_Conv 
iro_CopyB 
iro_Deleted 
iro_Div 
iro_Dummy 
iro_End 
iro_Eor 
iro_Free 
iro_IJmp 
iro_Id 
iro_Jmp 
iro_Load 
iro_Member 
iro_Minus 
iro_Mod 
iro_Mul 
iro_Mulh 
iro_Mux 
iro_NoMem 
iro_Not 
iro_Offset 
iro_Or 
iro_Phi 
iro_Pin 
iro_Proj 
iro_Raise 
iro_Return 
iro_Sel 
iro_Shl 
iro_Shr 
iro_Shrs 
iro_Size 
iro_Start 
iro_Store 
iro_Sub 
iro_Switch 
iro_Sync 
iro_Tuple 
iro_Unknown 
iro_first 
iro_last 

Definition at line 11 of file nodes.h.

enum irop_flags

The irop flags.

Enumerator
irop_flag_none 

Nothing.

irop_flag_commutative 

This operation is commutative.

irop_flag_cfopcode 

This operation is a control flow operation.

irop_flag_fragile 

Set if the operation can change the control flow because of an exception.

irop_flag_forking 

Forking control flow at this operation.

irop_flag_constlike 

This operation has no arguments and is some kind of a constant.

irop_flag_keep 

This operation can be kept in End's keep-alive list.

irop_flag_start_block 

This operation is always placed in the Start block.

irop_flag_uses_memory 

This operation has a memory input and may change the memory state.

irop_flag_dump_noblock 

node should be dumped outside any blocks

irop_flag_unknown_jump 

This operation jumps to an unknown destination.

The CFG is a conservative approximation in this case. You cannot change the destination of an unknown_jump

irop_flag_const_memory 

The opcode has a memory input/output but does not actually change the contents of any memory block known to the program.

The input/output is just necessary for scheduling reasons. Implies irop_flag_uses_memory.

Definition at line 41 of file irop.h.

enum op_arity

The allowed arities.

Enumerator
oparity_invalid 
oparity_binary 

A binary operator – considering 'numeric' arguments.

oparity_dynamic 

The arity depends on state of Firm representation.

Can be changed by optimizations... We must allocate a dynamic in array for the node!

oparity_any 

Any other arity, either fixed for the opcode or known when creating the node.

Definition at line 29 of file irop.h.

Function Documentation

void free_ir_op ( ir_op code)

Frees an ir operation.

Obviously nodes with this op mustn't exist at this point.

op_func get_generic_function_ptr ( const ir_op op)

Returns the generic function pointer from an IR operation.

unsigned get_next_ir_opcode ( void  )

Returns the next free IR opcode number, allows to register user ops.

unsigned get_next_ir_opcodes ( unsigned  num)

Returns the next free n IR opcode number, allows to register a bunch of user ops.

unsigned get_op_code ( const ir_op op)

Returns the enum for the opcode.

irop_flags get_op_flags ( const ir_op op)

Returns the irop flags of an IR opcode.

const char* get_op_name ( const ir_op op)

Returns the string for the opcode.

const char* get_op_pin_state_name ( op_pin_state  s)

Returns a human readable name of an op_pin_state.

op_pin_state get_op_pinned ( const ir_op op)

Returns pinned state of an opcode.

void ir_clear_opcodes_generic_func ( void  )

Sets the generic function pointer of all opcodes to NULL.

unsigned ir_get_n_opcodes ( void  )

Returns one more than the highest opcode code in use.

ir_op* ir_get_opcode ( unsigned  code)

Returns the opcode with code code.

code has to be smaller than get_irp_n_opcode(), returns NULL if no opcode with the code exists.

void ir_op_set_fragile_indices ( ir_op op,
unsigned  pn_x_regular,
unsigned  pn_x_except 
)

Sets proj-number for X_regular and X_except projs of fragile nodes.

Note: should only be used immediately after new_ir_op

void ir_op_set_memory_index ( ir_op op,
int  memory_index 
)

Sets memory input of operation using memory.

ir_op* new_ir_op ( unsigned  code,
const char *  name,
op_pin_state  p,
irop_flags  flags,
op_arity  opar,
int  op_index,
size_t  attr_size 
)

Creates a new IR operation.

Parameters
codethe opcode, one of type opcode
namethe printable name of this opcode
pwhether operations of this opcode are op_pin_state_pinned or floating
flagsa bitmask of irop_flags describing the behavior of the IR operation
oparthe parity of this IR operation
op_indexif the parity is oparity_unary, oparity_binary or oparity_trinary the index of the left operand
attr_sizeattribute size for this IR operation
Returns
The generated IR operation.

This function can create all standard Firm opcode as well as new ones. The behavior of new opcode depends on the operations ops and the flags.

void set_generic_function_ptr ( ir_op op,
op_func  func 
)

Stores a generic function pointer into an IR operation.

void set_op_attrs_equal ( ir_op op,
node_attrs_equal_func  func 
)

Sets attrs_equal callback func for operation op.

void set_op_computed_value ( ir_op op,
computed_value_func  func 
)

Sets computed_value callback func for operation op.

void set_op_computed_value_proj ( ir_op op,
computed_value_func  func 
)

Sets compute_value for Proj callback func for operation op.

void set_op_copy_attr ( ir_op op,
copy_attr_func  func 
)

Sets attribute copy callback func for operation op.

void set_op_dump ( ir_op op,
dump_node_func  func 
)

Sets dump callback func for operation op.

void set_op_equivalent_node ( ir_op op,
equivalent_node_func  func 
)

Sets equivalent node callback func for operation op.

void set_op_equivalent_node_proj ( ir_op op,
equivalent_node_func  func 
)

Sets equivalent Proj node callback func for operation op.

void set_op_get_entity_attr ( ir_op op,
get_entity_attr_func  func 
)

Sets get entity callback func for operation op.

void set_op_get_type_attr ( ir_op op,
get_type_attr_func  func 
)

Sets get type callback func for operation op.

void set_op_hash ( ir_op op,
hash_func  func 
)

Sets hash callback func for operation op.

void set_op_reassociate ( ir_op op,
reassociate_func  func 
)

Sets reassociation callback func for operation op.

void set_op_transform_node ( ir_op op,
transform_node_func  func 
)

Sets transform node callback func for operation op.

void set_op_transform_node_proj ( ir_op op,
transform_node_func  func 
)

Sets transform Proj node callback func for operation op.

void set_op_verify ( ir_op op,
verify_node_func  func 
)

Sets verify callback func for operation op.

void set_op_verify_proj ( ir_op op,
verify_proj_node_func  func 
)

Sets proj verify callback func for operation op.