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 {
38 } op_arity;
39 
40 
42 typedef enum {
45  irop_flag_cfopcode = 1U << 1,
46  irop_flag_fragile = 1U << 2,
49  irop_flag_forking = 1U << 3,
50  irop_flag_constlike = 1U << 5,
52  irop_flag_keep = 1U << 6,
64 } irop_flags;
65 ENUM_BITSET(irop_flags)
66 
67 
68 FIRM_API const char *get_op_name(const ir_op *op);
69 
71 FIRM_API unsigned get_op_code(const ir_op *op);
72 
74 FIRM_API const char *get_op_pin_state_name(op_pin_state s);
75 
77 FIRM_API op_pin_state get_op_pinned(const ir_op *op);
78 
80 FIRM_API unsigned get_next_ir_opcode(void);
81 
83 FIRM_API unsigned get_next_ir_opcodes(unsigned num);
84 
88 typedef void (*op_func)(void);
89 
93 FIRM_API op_func get_generic_function_ptr(const ir_op *op);
94 
98 FIRM_API void set_generic_function_ptr(ir_op *op, op_func func);
99 
103 FIRM_API irop_flags get_op_flags(const ir_op *op);
104 
109 typedef unsigned (*hash_func)(const ir_node *self);
110 
118 typedef ir_tarval *(*computed_value_func)(const ir_node *self);
119 
129 
139 
145 typedef int (*node_attrs_equal_func)(const ir_node *a, const ir_node *b);
146 
154 typedef int (*reassociate_func)(ir_node **n);
155 
160 typedef void (*copy_attr_func)(ir_graph *irg, const ir_node *old_node, ir_node *new_node);
161 
167 typedef ir_type *(*get_type_attr_func)(const ir_node *self);
168 
174 typedef ir_entity *(*get_entity_attr_func)(const ir_node *self);
175 
183 typedef int (*verify_node_func)(const ir_node *node);
184 
192 typedef int (*verify_proj_node_func)(const ir_node *proj);
193 
197 typedef enum {
202 } dump_reason_t;
203 
209 typedef void (*dump_node_func)(FILE *out, const ir_node *self, dump_reason_t reason);
210 
212 FIRM_API void set_op_hash(ir_op *op, hash_func func);
214 FIRM_API void set_op_computed_value(ir_op *op, computed_value_func func);
216 FIRM_API void set_op_computed_value_proj(ir_op *op, computed_value_func func);
218 FIRM_API void set_op_equivalent_node(ir_op *op, equivalent_node_func func);
222 FIRM_API void set_op_transform_node(ir_op *op, transform_node_func func);
224 FIRM_API void set_op_transform_node_proj(ir_op *op, transform_node_func func);
226 FIRM_API void set_op_attrs_equal(ir_op *op, node_attrs_equal_func func);
228 FIRM_API void set_op_reassociate(ir_op *op, reassociate_func func);
230 FIRM_API void set_op_copy_attr(ir_op *op, copy_attr_func func);
232 FIRM_API void set_op_get_type_attr(ir_op *op, get_type_attr_func func);
234 FIRM_API void set_op_get_entity_attr(ir_op *op, get_entity_attr_func func);
236 FIRM_API void set_op_verify(ir_op *op, verify_node_func func);
238 FIRM_API void set_op_verify_proj(ir_op *op, verify_proj_node_func func);
240 FIRM_API void set_op_dump(ir_op *op, dump_node_func func);
241 
259 FIRM_API ir_op *new_ir_op(unsigned code, const char *name, op_pin_state p,
260  irop_flags flags, op_arity opar, int op_index,
261  size_t attr_size);
262 
268 FIRM_API void free_ir_op(ir_op *code);
269 
271 FIRM_API unsigned ir_get_n_opcodes(void);
272 
279 FIRM_API ir_op *ir_get_opcode(unsigned code);
280 
282 FIRM_API void ir_clear_opcodes_generic_func(void);
283 
287 FIRM_API void ir_op_set_memory_index(ir_op *op, int memory_index);
288 
293 FIRM_API void ir_op_set_fragile_indices(ir_op *op, unsigned pn_x_regular,
294  unsigned pn_x_except);
295 
298 #include "end.h"
299 
300 #endif
void(* op_func)(void)
A generic function pointer type.
Definition: irop.h:88
int(* verify_node_func)(const ir_node *node)
The verify_node operation.
Definition: irop.h:183
Nothing.
Definition: irop.h:43
void ir_op_set_memory_index(ir_op *op, int memory_index)
Sets memory input of operation using memory.
Set if the operation can change the control flow because of an exception.
Definition: irop.h:46
void set_op_transform_node(ir_op *op, transform_node_func func)
Sets transform node callback func for operation op.
Forking control flow at this operation.
Definition: irop.h:49
unsigned ir_get_n_opcodes(void)
Returns one more than the highest opcode code in use.
struct ir_op ir_op
Node Opcode.
Definition: firm_types.h:56
ir_type *(* get_type_attr_func)(const ir_node *self)
The get_type_attr operation.
Definition: irop.h:167
op_func get_generic_function_ptr(const ir_op *op)
Returns the generic function pointer from an IR operation.
ir_op * ir_get_opcode(unsigned code)
Returns the opcode with code code.
Dump node attributes to be shown in the label.
Definition: irop.h:200
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.
Dump the mode.
Definition: irop.h:199
dump_reason_t
Reasons to call the dump_node operation:
Definition: irop.h:197
struct ir_type ir_type
Type.
Definition: firm_types.h:71
The opcode has a memory input/output but does not actually change the contents of any memory block kn...
Definition: irop.h:63
int(* reassociate_func)(ir_node **n)
The reassociation operation.
Definition: irop.h:154
irop_flags get_op_flags(const ir_op *op)
Returns the irop flags of an IR opcode.
This operation jumps to an unknown destination.
Definition: irop.h:59
struct ir_tarval ir_tarval
Target Machine Value.
Definition: firm_types.h:68
int(* verify_proj_node_func)(const ir_node *proj)
The verify_node operation for Proj(X).
Definition: irop.h:192
void set_op_verify(ir_op *op, verify_node_func func)
Sets verify callback func for operation op.
Dump node attributes into info1.
Definition: irop.h:201
node should be dumped outside any blocks
Definition: irop.h:55
void set_op_transform_node_proj(ir_op *op, transform_node_func func)
Sets transform Proj node callback func for operation op.
This operation is a control flow operation.
Definition: irop.h:45
op_pin_state
pinned states.
Definition: firm_types.h:198
A binary operator – considering &#39;numeric&#39; arguments.
Definition: irop.h:31
const char * get_op_name(const ir_op *op)
Returns the string for the opcode.
void set_op_equivalent_node(ir_op *op, equivalent_node_func func)
Sets equivalent node callback func for operation op.
unsigned get_op_code(const ir_op *op)
Returns the enum for the opcode.
This operation is always placed in the Start block.
Definition: irop.h:53
This operation is commutative.
Definition: irop.h:44
This operation can be kept in End&#39;s keep-alive list.
Definition: irop.h:52
void set_op_computed_value(ir_op *op, computed_value_func func)
Sets computed_value callback func for operation op.
This operation has a memory input and may change the memory state.
Definition: irop.h:54
void set_op_get_entity_attr(ir_op *op, get_entity_attr_func func)
Sets get entity callback func for operation op.
unsigned get_next_ir_opcode(void)
Returns the next free IR opcode number, allows to register user ops.
void set_op_copy_attr(ir_op *op, copy_attr_func func)
Sets attribute copy callback func for operation op.
unsigned(* hash_func)(const ir_node *self)
The hash operation.
Definition: irop.h:109
void set_op_verify_proj(ir_op *op, verify_proj_node_func func)
Sets proj verify callback func for operation op.
void set_op_hash(ir_op *op, hash_func func)
Sets hash callback func for operation op.
void set_generic_function_ptr(ir_op *op, op_func func)
Stores a generic function pointer into an IR operation.
The arity is not fixed by opcode, but statically known.
Definition: irop.h:32
const char * get_op_pin_state_name(op_pin_state s)
Returns a human readable name of an op_pin_state.
ir_node *(* transform_node_func)(ir_node *self)
The transform node operation.
Definition: irop.h:138
void(* dump_node_func)(FILE *out, const ir_node *self, dump_reason_t reason)
The dump_node operation.
Definition: irop.h:209
void set_op_computed_value_proj(ir_op *op, computed_value_func func)
Sets compute_value for Proj callback func for operation op.
void(* copy_attr_func)(ir_graph *irg, const ir_node *old_node, ir_node *new_node)
The copy attribute operation.
Definition: irop.h:160
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.
void set_op_get_type_attr(ir_op *op, get_type_attr_func func)
Sets get type callback func for operation op.
void ir_clear_opcodes_generic_func(void)
Sets the generic function pointer of all opcodes to NULL.
This operation has no arguments and is some kind of a constant.
Definition: irop.h:50
ir_node *(* equivalent_node_func)(ir_node *self)
The equivalent node operation.
Definition: irop.h:128
ir_tarval *(* computed_value_func)(const ir_node *self)
The compute value operation.
Definition: irop.h:118
irop_flags
The irop flags.
Definition: irop.h:42
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_dump(ir_op *op, dump_node_func func)
Sets dump callback func for operation op.
Dump the opcode.
Definition: irop.h:198
The arity depends on state of Firm representation.
Definition: irop.h:34
struct ir_entity ir_entity
Entity.
Definition: firm_types.h:83
struct ir_node ir_node
Procedure Graph Node.
Definition: firm_types.h:53
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:174
void free_ir_op(ir_op *code)
Frees an ir operation.
struct ir_graph ir_graph
Procedure Graph.
Definition: firm_types.h:74
void set_op_reassociate(ir_op *op, reassociate_func func)
Sets reassociation 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:145
Any other arity.
Definition: irop.h:37
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.