libFirm
irop.h
1 /*
2  * This file is part of libFirm.
3  * Copyright (C) 2012 University of Karlsruhe.
4  */
5 
12 #ifndef FIRM_IR_IROP_H
13 #define FIRM_IR_IROP_H
14 
15 #include <stdio.h>
16 #include "firm_types.h"
17 #include "begin.h"
18 
29 typedef enum {
37 } op_arity;
38 
39 
41 typedef enum {
44  irop_flag_cfopcode = 1U << 1,
45  irop_flag_fragile = 1U << 2,
48  irop_flag_forking = 1U << 3,
49  irop_flag_constlike = 1U << 5,
51  irop_flag_keep = 1U << 6,
63 } irop_flags;
64 ENUM_BITSET(irop_flags)
65 
66 
67 FIRM_API const char *get_op_name(const ir_op *op);
68 
70 FIRM_API unsigned get_op_code(const ir_op *op);
71 
73 FIRM_API const char *get_op_pin_state_name(op_pin_state s);
74 
76 FIRM_API op_pin_state get_op_pinned(const ir_op *op);
77 
79 FIRM_API unsigned get_next_ir_opcode(void);
80 
82 FIRM_API unsigned get_next_ir_opcodes(unsigned num);
83 
87 typedef void (*op_func)(void);
88 
92 FIRM_API op_func get_generic_function_ptr(const ir_op *op);
93 
97 FIRM_API void set_generic_function_ptr(ir_op *op, op_func func);
98 
102 FIRM_API irop_flags get_op_flags(const ir_op *op);
103 
108 typedef unsigned (*hash_func)(const ir_node *self);
109 
117 typedef ir_tarval *(*computed_value_func)(const ir_node *self);
118 
128 
138 
144 typedef int (*node_attrs_equal_func)(const ir_node *a, const ir_node *b);
145 
153 typedef int (*reassociate_func)(ir_node **n);
154 
159 typedef void (*copy_attr_func)(ir_graph *irg, const ir_node *old_node, ir_node *new_node);
160 
166 typedef ir_type *(*get_type_attr_func)(const ir_node *self);
167 
173 typedef ir_entity *(*get_entity_attr_func)(const ir_node *self);
174 
182 typedef int (*verify_node_func)(const ir_node *node);
183 
191 typedef int (*verify_proj_node_func)(const ir_node *proj);
192 
196 typedef enum {
201 } dump_reason_t;
202 
208 typedef void (*dump_node_func)(FILE *out, const ir_node *self, dump_reason_t reason);
209 
211 FIRM_API void set_op_hash(ir_op *op, hash_func func);
213 FIRM_API void set_op_computed_value(ir_op *op, computed_value_func func);
215 FIRM_API void set_op_computed_value_proj(ir_op *op, computed_value_func func);
217 FIRM_API void set_op_equivalent_node(ir_op *op, equivalent_node_func func);
221 FIRM_API void set_op_transform_node(ir_op *op, transform_node_func func);
223 FIRM_API void set_op_transform_node_proj(ir_op *op, transform_node_func func);
225 FIRM_API void set_op_attrs_equal(ir_op *op, node_attrs_equal_func func);
227 FIRM_API void set_op_reassociate(ir_op *op, reassociate_func func);
229 FIRM_API void set_op_copy_attr(ir_op *op, copy_attr_func func);
231 FIRM_API void set_op_get_type_attr(ir_op *op, get_type_attr_func func);
233 FIRM_API void set_op_get_entity_attr(ir_op *op, get_entity_attr_func func);
235 FIRM_API void set_op_verify(ir_op *op, verify_node_func func);
237 FIRM_API void set_op_verify_proj(ir_op *op, verify_proj_node_func func);
239 FIRM_API void set_op_dump(ir_op *op, dump_node_func func);
240 
258 FIRM_API ir_op *new_ir_op(unsigned code, const char *name, op_pin_state p,
259  irop_flags flags, op_arity opar, int op_index,
260  size_t attr_size);
261 
267 FIRM_API void free_ir_op(ir_op *code);
268 
270 FIRM_API unsigned ir_get_n_opcodes(void);
271 
278 FIRM_API ir_op *ir_get_opcode(unsigned code);
279 
281 FIRM_API void ir_clear_opcodes_generic_func(void);
282 
286 FIRM_API void ir_op_set_memory_index(ir_op *op, int memory_index);
287 
292 FIRM_API void ir_op_set_fragile_indices(ir_op *op, unsigned pn_x_regular,
293  unsigned pn_x_except);
294 
297 #include "end.h"
298 
299 #endif
A binary operator – considering &#39;numeric&#39; arguments.
Definition: irop.h:31
irop_flags get_op_flags(const ir_op *op)
Returns the irop flags of an IR opcode.
Dump node attributes into info1.
Definition: irop.h:200
int(* verify_proj_node_func)(const ir_node *proj)
The verify_node operation for Proj(X).
Definition: irop.h:191
void set_op_verify(ir_op *op, verify_node_func func)
Sets verify callback func for operation op.
ir_node *(* equivalent_node_func)(ir_node *self)
The equivalent node operation.
Definition: irop.h:127
void set_op_transform_node_proj(ir_op *op, transform_node_func func)
Sets transform Proj node callback func for operation op.
const char * get_op_name(const ir_op *op)
Returns the string for the opcode.
int(* reassociate_func)(ir_node **n)
The reassociation operation.
Definition: irop.h:153
This operation has no arguments and is some kind of a constant.
Definition: irop.h:49
unsigned get_op_code(const ir_op *op)
Returns the enum for the opcode.
unsigned get_next_ir_opcodes(unsigned num)
Returns the next free n IR opcode number, allows to register a bunch of user ops. ...
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_verify_proj(ir_op *op, verify_proj_node_func func)
Sets proj verify 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_hash(ir_op *op, hash_func func)
Sets hash callback func for operation op.
ir_node *(* transform_node_func)(ir_node *self)
The transform node operation.
Definition: irop.h:137
void(* dump_node_func)(FILE *out, const ir_node *self, dump_reason_t reason)
The dump_node operation.
Definition: irop.h:208
void set_op_computed_value_proj(ir_op *op, computed_value_func func)
Sets compute_value for Proj callback func for operation op.
struct ir_graph ir_graph
Procedure Graph.
Definition: firm_types.h:74
unsigned get_next_ir_opcode(void)
Returns the next free IR opcode number, allows to register user ops.
void(* op_func)(void)
A generic function pointer type.
Definition: irop.h:87
void set_op_copy_attr(ir_op *op, copy_attr_func func)
Sets attribute copy callback func for operation op.
Any other arity, either fixed for the opcode or known when creating the node.
Definition: irop.h:36
void set_generic_function_ptr(ir_op *op, op_func func)
Stores a generic function pointer into an IR operation.
Nothing.
Definition: irop.h:42
Set if the operation can change the control flow because of an exception.
Definition: irop.h:45
struct ir_op ir_op
Node Opcode.
Definition: firm_types.h:56
Forking control flow at this operation.
Definition: irop.h:48
struct ir_tarval ir_tarval
Target Machine Value.
Definition: firm_types.h:68
void set_op_get_type_attr(ir_op *op, get_type_attr_func func)
Sets get type callback func for operation op.
Dump the opcode.
Definition: irop.h:197
ir_op * ir_get_opcode(unsigned code)
Returns the opcode with code code.
The arity depends on state of Firm representation.
Definition: irop.h:32
struct ir_node ir_node
Procedure Graph Node.
Definition: firm_types.h:53
dump_reason_t
Reasons to call the dump_node operation:
Definition: irop.h:196
op_func get_generic_function_ptr(const ir_op *op)
Returns the generic function pointer from an IR operation.
ir_tarval *(* computed_value_func)(const ir_node *self)
The compute value operation.
Definition: irop.h:117
irop_flags
The irop flags.
Definition: irop.h:41
void free_ir_op(ir_op *code)
Frees an ir operation.
void set_op_dump(ir_op *op, dump_node_func func)
Sets dump callback func for operation op.
int(* node_attrs_equal_func)(const ir_node *a, const ir_node *b)
The node attribute compare operation.
Definition: irop.h:144
op_pin_state get_op_pinned(const ir_op *op)
Returns pinned state of an opcode.
op_arity
The allowed arities.
Definition: irop.h:29
void set_op_attrs_equal(ir_op *op, node_attrs_equal_func func)
Sets attrs_equal callback func for operation op.
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.
void set_op_equivalent_node_proj(ir_op *op, equivalent_node_func func)
Sets equivalent Proj node callback func for operation op.
ir_entity *(* get_entity_attr_func)(const ir_node *self)
The get_entity_attr operation.
Definition: irop.h:173
int(* verify_node_func)(const ir_node *node)
The verify_node operation.
Definition: irop.h:182
Dump the mode.
Definition: irop.h:198
void set_op_reassociate(ir_op *op, reassociate_func func)
Sets reassociation 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_transform_node(ir_op *op, transform_node_func func)
Sets transform node callback func for operation op.
unsigned ir_get_n_opcodes(void)
Returns one more than the highest opcode code in use.
void ir_op_set_memory_index(ir_op *op, int memory_index)
Sets memory input of operation using memory.
The opcode has a memory input/output but does not actually change the contents of any memory block kn...
Definition: irop.h:62
ir_type *(* get_type_attr_func)(const ir_node *self)
The get_type_attr operation.
Definition: irop.h:166
This operation is always placed in the Start block.
Definition: irop.h:52
node should be dumped outside any blocks
Definition: irop.h:54
This operation is a control flow operation.
Definition: irop.h:44
Dump node attributes to be shown in the label.
Definition: irop.h:199
struct ir_entity ir_entity
Entity.
Definition: firm_types.h:83
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.
This operation has a memory input and may change the memory state.
Definition: irop.h:53
This operation is commutative.
Definition: irop.h:43
unsigned(* hash_func)(const ir_node *self)
The hash operation.
Definition: irop.h:108
This operation can be kept in End&#39;s keep-alive list.
Definition: irop.h:51
const char * get_op_pin_state_name(op_pin_state s)
Returns a human readable name of an op_pin_state.
op_pin_state
pinned states.
Definition: firm_types.h:201
void ir_clear_opcodes_generic_func(void)
Sets the generic function pointer of all opcodes to NULL.
struct ir_type ir_type
Type.
Definition: firm_types.h:71
This operation jumps to an unknown destination.
Definition: irop.h:58
void(* copy_attr_func)(ir_graph *irg, const ir_node *old_node, ir_node *new_node)
The copy attribute operation.
Definition: irop.h:159