libFirm
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
irnode.h
1 /*
2  * This file is part of libFirm.
3  * Copyright (C) 2012 University of Karlsruhe.
4  */
5 
11 #ifndef FIRM_IR_IRNODE_H
12 #define FIRM_IR_IRNODE_H
13 
14 #include <stddef.h>
15 
16 #include "firm_common.h"
17 #include "typerep.h"
18 #include "irop.h"
19 #include "irmode.h"
20 #include "begin.h"
21 #include "nodes.h"
22 
49 FIRM_API int get_irn_arity(const ir_node *node);
50 
55 FIRM_API ir_node *get_irn_n(const ir_node *node, int n);
56 
63 FIRM_API void set_irn_in(ir_node *node, int arity, ir_node *const in[]);
64 
66 FIRM_API void set_irn_n(ir_node *node, int n, ir_node *in);
72 FIRM_API int add_irn_n(ir_node *node, ir_node *in);
74 FIRM_API void set_irn_mode(ir_node *node, ir_mode *mode);
76 FIRM_API ir_mode *get_irn_mode(const ir_node *node);
78 FIRM_API ir_op *get_irn_op(const ir_node *node);
80 FIRM_API unsigned get_irn_opcode(const ir_node *node);
82 FIRM_API const char *get_irn_opname(const ir_node *node);
84 FIRM_API ident *get_irn_opident(const ir_node *node);
86 FIRM_API ir_visited_t get_irn_visited(const ir_node *node);
88 FIRM_API void set_irn_visited(ir_node *node, ir_visited_t visited);
90 FIRM_API void mark_irn_visited(ir_node *node);
92 FIRM_API int irn_visited(const ir_node *node);
95 FIRM_API int irn_visited_else_mark(ir_node *node);
96 
101 FIRM_API void set_irn_link(ir_node *node, void *link);
102 
104 FIRM_API void *get_irn_link(const ir_node *node);
105 
107 FIRM_API ir_graph *get_irn_irg(const ir_node *node);
108 
112 FIRM_API long get_irn_node_nr(const ir_node *node);
113 
120 FIRM_API int get_irn_pinned(const ir_node *node);
121 
124 FIRM_API void set_irn_pinned(ir_node *node, int pinned);
125 
141 FIRM_API ir_node *new_ir_node(dbg_info *db, ir_graph *irg, ir_node *block,
142  ir_op *op, ir_mode *mode,
143  int arity, ir_node *const *in);
144 
156 FIRM_API ir_node *get_nodes_block(const ir_node *node);
157 
159 FIRM_API void set_nodes_block(ir_node *node, ir_node *block);
160 
173 FIRM_API ir_node *get_Block_cfgpred_block(const ir_node *node, int pos);
174 
176 FIRM_API int get_Block_matured(const ir_node *block);
178 FIRM_API void set_Block_matured(ir_node *block, int matured);
179 
182 FIRM_API ir_visited_t get_Block_block_visited(const ir_node *block);
184 FIRM_API void set_Block_block_visited(ir_node *block, ir_visited_t visit);
185 
187 FIRM_API void mark_Block_block_visited(ir_node *node);
189 FIRM_API int Block_block_visited(const ir_node *node);
190 
192 FIRM_API ir_entity *create_Block_entity(ir_node *block);
194 FIRM_API ir_node *get_Block_phis(const ir_node *block);
196 FIRM_API void set_Block_phis(ir_node *block, ir_node *phi);
198 FIRM_API void add_Block_phi(ir_node *block, ir_node *phi);
200 FIRM_API unsigned get_Block_mark(const ir_node *block);
202 FIRM_API void set_Block_mark(ir_node *block, unsigned mark);
203 
211 FIRM_API void add_End_keepalive(ir_node *end, ir_node *ka);
212 
218 FIRM_API void set_End_keepalives(ir_node *end, int n, ir_node *in[]);
219 
221 FIRM_API void remove_End_keepalive(ir_node *end, const ir_node *irn);
222 
224 FIRM_API void remove_End_n(ir_node *end, int idx);
225 
227 FIRM_API void remove_End_Bads_and_doublets(ir_node *end);
228 
233 FIRM_API void free_End(ir_node *end);
234 
242 FIRM_API int is_Const_null(const ir_node *node);
243 
245 FIRM_API int is_Const_one(const ir_node *node);
246 
248 FIRM_API int is_Const_all_one(const ir_node *node);
249 
263 FIRM_API ir_entity *get_Call_callee(const ir_node *call);
264 
269 FIRM_API const char *get_builtin_kind_name(ir_builtin_kind kind);
270 
272 FIRM_API ir_node *get_binop_left(const ir_node *node);
274 FIRM_API void set_binop_left(ir_node *node, ir_node *left);
276 FIRM_API ir_node *get_binop_right(const ir_node *node);
278 FIRM_API void set_binop_right(ir_node *node, ir_node *right);
279 
283 FIRM_API int is_x_except_Proj(const ir_node *node);
284 
288 FIRM_API int is_x_regular_Proj(const ir_node *node);
289 
294 FIRM_API void ir_set_throws_exception(ir_node *node, int throws_exception);
295 
297 FIRM_API int ir_throws_exception(const ir_node *node);
298 
300 FIRM_API const char *get_relation_string(ir_relation relation);
301 
303 FIRM_API ir_relation get_negated_relation(ir_relation relation);
304 
307 
316 FIRM_API ir_node *get_Phi_next(const ir_node *phi);
320 FIRM_API void set_Phi_next(ir_node *phi, ir_node *next);
321 
329 FIRM_API int is_memop(const ir_node *node);
333 FIRM_API ir_node *get_memop_mem(const ir_node *node);
337 FIRM_API void set_memop_mem(ir_node *node, ir_node *mem);
338 
344 FIRM_API void add_Sync_pred(ir_node *node, ir_node *pred);
346 FIRM_API void remove_Sync_n(ir_node *n, int i);
347 
355 FIRM_API size_t get_ASM_n_output_constraints(const ir_node *node);
357 FIRM_API size_t get_ASM_n_clobbers(const ir_node *node);
358 
362 FIRM_API ir_node *skip_Proj(ir_node *node);
364 FIRM_API const ir_node *skip_Proj_const(const ir_node *node);
366 FIRM_API ir_node *skip_Id(ir_node *node);
368 FIRM_API ir_node *skip_Tuple(ir_node *node);
370 FIRM_API ir_node *skip_Pin(ir_node *node);
372 FIRM_API ir_node *skip_Confirm(ir_node *node);
374 FIRM_API int is_cfop(const ir_node *node);
377 FIRM_API int is_unknown_jump(const ir_node *node);
378 
384 FIRM_API int is_fragile_op(const ir_node *node);
385 
388 FIRM_API int is_irn_forking(const ir_node *node);
389 
392 FIRM_API int is_irn_const_memory(const ir_node *node);
393 
407 FIRM_API void copy_node_attr(ir_graph *irg, const ir_node *old_node, ir_node *new_node);
408 
411 FIRM_API ir_type *get_irn_type_attr(ir_node *n);
412 
415 
417 FIRM_API int is_irn_constlike(const ir_node *node);
418 
423 FIRM_API int is_irn_keep(const ir_node *node);
424 
428 FIRM_API int is_irn_start_block_placed(const ir_node *node);
429 
431 FIRM_API const char *get_cond_jmp_predicate_name(cond_jmp_predicate pred);
432 
437 FIRM_API void *get_irn_generic_attr(ir_node *node);
442 FIRM_API const void *get_irn_generic_attr_const(const ir_node *node);
443 
449 FIRM_API unsigned get_irn_idx(const ir_node *node);
450 
457 FIRM_API void set_irn_dbg_info(ir_node *n, dbg_info *db);
458 
464 FIRM_API dbg_info *get_irn_dbg_info(const ir_node *n);
465 
469 FIRM_API const char *gdb_node_helper(const void *firm_object);
470 
480 FIRM_API ir_switch_table *ir_new_switch_table(ir_graph *irg, size_t n_entries);
481 
485 FIRM_API size_t ir_switch_table_get_n_entries(const ir_switch_table *table);
486 
495 FIRM_API void ir_switch_table_set(ir_switch_table *table, size_t entry,
496  ir_tarval *min, ir_tarval *max, unsigned pn);
497 
499 FIRM_API ir_tarval *ir_switch_table_get_max(const ir_switch_table *table,
500  size_t entry);
501 
503 FIRM_API ir_tarval *ir_switch_table_get_min(const ir_switch_table *table,
504  size_t entry);
505 
507 FIRM_API unsigned ir_switch_table_get_pn(const ir_switch_table *table,
508  size_t entry);
509 
516 #include "end.h"
517 
518 #endif
ident * get_irn_opident(const ir_node *node)
Returns the ident for a string representation of the opcode.
ir_switch_table * ir_switch_table_duplicate(ir_graph *irg, const ir_switch_table *table)
Duplicates switch table table on obstack of irg.
int irn_visited_else_mark(ir_node *node)
Returns 1 if visited >= get_irg_visited(get_irn_irg(node)).
void add_Sync_pred(ir_node *node, ir_node *pred)
Adds pred to predecessor list of Sync node node.
ir_node * skip_Confirm(ir_node *node)
Returns operand of node if node is a Confirm.
struct ir_type ir_type
Type.
Definition: firm_types.h:71
ir_node * skip_Proj(ir_node *node)
Returns operand of node if node is a Proj.
struct dbg_info dbg_info
Source Reference.
Definition: firm_types.h:40
ir_node * skip_Tuple(ir_node *node)
Returns corresponding operand of Tuple if node is a Proj from a Tuple.
ir_node * get_memop_mem(const ir_node *node)
Returns the memory input of a memory operation.
int is_Const_null(const ir_node *node)
Returns non-zero if the given Const node represents the 0 constant.
int is_Const_all_one(const ir_node *node)
Returns non-zero if the given Const node represents the constant with all bits set.
void add_Block_phi(ir_node *block, ir_node *phi)
Add a Phi node to the list of Block Phi's.
ir_builtin_kind
Supported libFirm builtins.
Definition: firm_types.h:276
unsigned get_irn_opcode(const ir_node *node)
Returns the opcode-enum of the node.
int is_Const_one(const ir_node *node)
Returns non-zero if the given Const node represents the 1 constant.
void set_memop_mem(ir_node *node, ir_node *mem)
Sets the memory input of a memory operation.
void set_Block_mark(ir_node *block, unsigned mark)
Sets the Block mark (single bit).
void set_irn_dbg_info(ir_node *n, dbg_info *db)
Sets the debug information of a node.
void add_End_keepalive(ir_node *end, ir_node *ka)
Keep alive dedicated nodes.
int get_irn_arity(const ir_node *node)
Returns the number of predecessors without the block predecessor.
struct ir_graph ir_graph
Procedure Graph.
Definition: firm_types.h:74
void set_irn_n(ir_node *node, int n, ir_node *in)
Replaces the n-th predecessor of a node with a new one.
void set_irn_visited(ir_node *node, ir_visited_t visited)
Sets the visited counter of a node.
void * get_irn_link(const ir_node *node)
Returns the link of a node.
const char * get_relation_string(ir_relation relation)
Returns the name of an ir_relation.
unsigned get_irn_idx(const ir_node *node)
Returns the unique node index for the node in its graph.
int get_Block_matured(const ir_node *block)
Returns the matured flag of a block.
const char * gdb_node_helper(const void *firm_object)
Returns a descriptive name of a node (containing type+number)
int is_irn_forking(const ir_node *node)
Returns true if the operation is a forking control flow operation: Cond.
ir_node * skip_Id(ir_node *node)
Returns operand of node if node is a Id.
ir_type * get_irn_type_attr(ir_node *n)
Returns the type attribute of a node n (TypeConst, Call, Alloc, Free) or NULL.
int is_irn_constlike(const ir_node *node)
Returns non-zero for constant-like nodes.
const char * get_irn_opname(const ir_node *node)
Returns the string representation of the opcode.
void set_irn_mode(ir_node *node, ir_mode *mode)
Sets the mode struct of node.
ir_relation get_negated_relation(ir_relation relation)
Calculates the negated (Complement(R)) relation, i.e.
const void * get_irn_generic_attr_const(const ir_node *node)
Returns a pointer to the node attributes.
int add_irn_n(ir_node *node, ir_node *in)
Appends a new predecessor to a node.
void remove_End_Bads_and_doublets(ir_node *end)
Removes Bads, NoMem and doublets from the keep-alive set.
ir_node * get_Block_phis(const ir_node *block)
Returns the head of the Phi list for this block.
cond_jmp_predicate
A type to express conditional jump predictions.
Definition: firm_types.h:209
void * get_irn_generic_attr(ir_node *node)
Returns a pointer to the node attributes.
void set_irn_in(ir_node *node, int arity, ir_node *const in[])
Replaces the old in array by a new one that will contain the ins given in the parameters.
void ir_switch_table_set(ir_switch_table *table, size_t entry, ir_tarval *min, ir_tarval *max, unsigned pn)
Sets entry number entry in the switch table table.
ir_entity * get_Call_callee(const ir_node *call)
Convenience function: Return method that will be called by a call.
int is_fragile_op(const ir_node *node)
Returns true if the operation can change the control flow because of an exception: Call...
void set_Block_matured(ir_node *block, int matured)
set the matured flag of a block.
int irn_visited(const ir_node *node)
Returns 1 if visited >= get_irg_visited(get_irn_irg(node)).
ir_node * get_nodes_block(const ir_node *node)
Returns the block the node belongs to.
int is_memop(const ir_node *node)
Returns true if node is a memory operation.
struct ir_switch_table ir_switch_table
A switch table mapping integer numbers to proj-numbers of a Switch-node.
Definition: firm_types.h:102
ir_node * skip_Pin(ir_node *node)
Returns operand of node if node is a Pin.
ir_node * new_ir_node(dbg_info *db, ir_graph *irg, ir_node *block, ir_op *op, ir_mode *mode, int arity, ir_node *const *in)
IR node constructor.
void set_End_keepalives(ir_node *end, int n, ir_node *in[])
Sets new keep-alives.
ir_tarval * ir_switch_table_get_min(const ir_switch_table *table, size_t entry)
Returns minimum tarval value of switch table entry entry.
ir_entity * get_irn_entity_attr(ir_node *n)
Returns the entity attribute of a node n (Address, Offset, Sel) or NULL.
const char * get_cond_jmp_predicate_name(cond_jmp_predicate pred)
Returns the string representation of the jump prediction.
ir_node * get_Block_cfgpred_block(const ir_node *node, int pos)
Returns the predecessor block.
ir_node * get_binop_left(const ir_node *node)
Returns left operand of binary operation node.
unsigned ir_switch_table_get_pn(const ir_switch_table *table, size_t entry)
Returns proj number taken if switch table entry entry matches.
void set_nodes_block(ir_node *node, ir_node *block)
Sets the Block of a node.
ir_visited_t get_Block_block_visited(const ir_node *block)
A visited flag only for block nodes.
ir_op * get_irn_op(const ir_node *node)
Returns the opcode struct of the node.
struct ir_op ir_op
Node Opcode.
Definition: firm_types.h:56
int Block_block_visited(const ir_node *node)
Returns 1 if a block is marked as visited.
void set_irn_pinned(ir_node *node, int pinned)
Sets pin state for nodes with op pin state op_pin_state_exc_pinned.
size_t get_ASM_n_output_constraints(const ir_node *node)
Returns the number of output constraints for an ASM node.
long get_irn_node_nr(const ir_node *node)
Outputs a unique number for this node if libFIRM is compiled for debugging, (configure with –enable-d...
void copy_node_attr(ir_graph *irg, const ir_node *old_node, ir_node *new_node)
Copies attributes stored in the old node to a new node.
void set_Phi_next(ir_node *phi, ir_node *next)
Sets the next link of a block Phi list.
struct ir_entity ir_entity
Entity.
Definition: firm_types.h:83
const char * get_builtin_kind_name(ir_builtin_kind kind)
Returns a human readable string for the ir_builtin_kind.
size_t get_ASM_n_clobbers(const ir_node *node)
Returns the number of clobbered registers for an ASM node.
int is_x_regular_Proj(const ir_node *node)
Tests whether a node is the X_regular Proj of a fragile operation.
int is_unknown_jump(const ir_node *node)
Returns true if the operation jumps to an unknown destination.
void set_Block_block_visited(ir_node *block, ir_visited_t visit)
set block visited flag
ir_entity * create_Block_entity(ir_node *block)
Returns the entity for a Block (creating it if necessary)
int is_irn_start_block_placed(const ir_node *node)
Returns non-zero for nodes that are always placed in the start block.
void set_irn_link(ir_node *node, void *link)
Sets the link of a node.
struct ir_tarval ir_tarval
Target Machine Value.
Definition: firm_types.h:68
void set_binop_left(ir_node *node, ir_node *left)
Sets left operand of binary operation node.
ir_mode * get_irn_mode(const ir_node *node)
Returns the mode struct of a node.
ir_switch_table * ir_new_switch_table(ir_graph *irg, size_t n_entries)
Creates a new switch_table data structure with n_entries entries.
ir_tarval * ir_switch_table_get_max(const ir_switch_table *table, size_t entry)
Returns maximum tarval value of switch table entry entry.
void set_Block_phis(ir_node *block, ir_node *phi)
Sets the head of the Phi list for this block.
ir_node * get_Phi_next(const ir_node *phi)
Returns the next element of a block phi list.
ir_relation
Relations for comparing numbers.
Definition: firm_types.h:159
void remove_End_n(ir_node *end, int idx)
Removes predecessor (a keepalive) at index idx from End node end.
void mark_Block_block_visited(ir_node *node)
Marks a block as visited by setting its visited counter.
int ir_throws_exception(const ir_node *node)
Returns throws_exception attribute of a fragile node.
dbg_info * get_irn_dbg_info(const ir_node *n)
Returns the debug information of an node.
void set_binop_right(ir_node *node, ir_node *right)
Sets right operand of binary operation node.
int get_irn_pinned(const ir_node *node)
Returns whether a node is pinned.
unsigned get_Block_mark(const ir_node *block)
Returns the Block mark (single bit).
int is_cfop(const ir_node *node)
Returns true if the operation manipulates control flow.
ir_node * get_binop_right(const ir_node *node)
Returns rights operand of binary operation node.
void mark_irn_visited(ir_node *node)
Sets visited to get_irg_visited(get_irn_irg(node)).
struct ir_mode ir_mode
SSA Value mode.
Definition: firm_types.h:59
struct ir_node ir_node
Procedure Graph Node.
Definition: firm_types.h:53
ir_relation get_inversed_relation(ir_relation relation)
Calculates the inversed (R^-1) relation, i.e., "<" –> ">".
const char ident
Identifier.
Definition: firm_types.h:50
ir_visited_t get_irn_visited(const ir_node *node)
Returns the visited counter of a node.
size_t ir_switch_table_get_n_entries(const ir_switch_table *table)
Returns number of entries available in switch table table.
void remove_End_keepalive(ir_node *end, const ir_node *irn)
Removes irn from the keep-alive set.
int is_irn_const_memory(const ir_node *node)
Returns true if the operation does not change anymemory contents although it has a memory input/outpu...
const ir_node * skip_Proj_const(const ir_node *node)
Returns operand of node if node is a Proj.
int is_x_except_Proj(const ir_node *node)
Tests whether a node is the X_except Proj of a fragile operation.
ir_graph * get_irn_irg(const ir_node *node)
Returns the ir_graph this node belongs to.
ir_node * get_irn_n(const ir_node *node, int n)
Returns the n-th predecessor of a node.
void remove_Sync_n(ir_node *n, int i)
Removes predecessor i from Sync n.
void free_End(ir_node *end)
Some parts of the End node are allocated separately – their memory is not recovered by dead_node_elim...
int is_irn_keep(const ir_node *node)
Returns non-zero for nodes that are allowed to have keep-alives and are neither Block nor PhiM...
void ir_set_throws_exception(ir_node *node, int throws_exception)
Sets throws exception attribute of a fragile node throws_exception must be 0 or 1.