libFirm
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 #include "firm_common.h"
16 #include "irmode.h"
17 #include "irop.h"
18 #include "nodes.h"
19 #include "typerep.h"
20 
21 #include "begin.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 
151 FIRM_API ir_node *exact_copy(const ir_node *node);
152 
162 FIRM_API ir_node *irn_copy_into_irg(const ir_node *node, ir_graph *irg);
163 
175 FIRM_API ir_node *get_nodes_block(const ir_node *node);
176 
178 FIRM_API void set_nodes_block(ir_node *node, ir_node *block);
179 
192 FIRM_API ir_node *get_Block_cfgpred_block(const ir_node *node, int pos);
193 
195 FIRM_API int get_Block_matured(const ir_node *block);
197 FIRM_API void set_Block_matured(ir_node *block, int matured);
198 
201 FIRM_API ir_visited_t get_Block_block_visited(const ir_node *block);
203 FIRM_API void set_Block_block_visited(ir_node *block, ir_visited_t visit);
204 
206 FIRM_API void mark_Block_block_visited(ir_node *node);
208 FIRM_API int Block_block_visited(const ir_node *node);
209 
211 FIRM_API ir_entity *create_Block_entity(ir_node *block);
213 FIRM_API ir_node *get_Block_phis(const ir_node *block);
215 FIRM_API void set_Block_phis(ir_node *block, ir_node *phi);
217 FIRM_API void add_Block_phi(ir_node *block, ir_node *phi);
219 FIRM_API unsigned get_Block_mark(const ir_node *block);
221 FIRM_API void set_Block_mark(ir_node *block, unsigned mark);
222 
230 FIRM_API void add_End_keepalive(ir_node *end, ir_node *ka);
231 
237 FIRM_API void set_End_keepalives(ir_node *end, int n, ir_node *in[]);
238 
240 FIRM_API void remove_End_keepalive(ir_node *end, const ir_node *irn);
241 
243 FIRM_API void remove_End_n(ir_node *end, int idx);
244 
246 FIRM_API void remove_End_Bads_and_doublets(ir_node *end);
247 
252 FIRM_API void free_End(ir_node *end);
253 
261 FIRM_API int is_Const_null(const ir_node *node);
262 
264 FIRM_API int is_Const_one(const ir_node *node);
265 
267 FIRM_API int is_Const_all_one(const ir_node *node);
268 
282 FIRM_API ir_entity *get_Call_callee(const ir_node *call);
283 
288 FIRM_API const char *get_builtin_kind_name(ir_builtin_kind kind);
289 
291 FIRM_API ir_node *get_binop_left(const ir_node *node);
293 FIRM_API void set_binop_left(ir_node *node, ir_node *left);
295 FIRM_API ir_node *get_binop_right(const ir_node *node);
297 FIRM_API void set_binop_right(ir_node *node, ir_node *right);
298 
302 FIRM_API int is_x_except_Proj(const ir_node *node);
303 
307 FIRM_API int is_x_regular_Proj(const ir_node *node);
308 
313 FIRM_API void ir_set_throws_exception(ir_node *node, int throws_exception);
314 
316 FIRM_API int ir_throws_exception(const ir_node *node);
317 
319 FIRM_API const char *get_relation_string(ir_relation relation);
320 
322 FIRM_API ir_relation get_negated_relation(ir_relation relation);
323 
326 
335 FIRM_API ir_node *get_Phi_next(const ir_node *phi);
339 FIRM_API void set_Phi_next(ir_node *phi, ir_node *next);
340 
348 FIRM_API int is_memop(const ir_node *node);
352 FIRM_API ir_node *get_memop_mem(const ir_node *node);
356 FIRM_API void set_memop_mem(ir_node *node, ir_node *mem);
357 
363 FIRM_API void add_Sync_pred(ir_node *node, ir_node *pred);
365 FIRM_API void remove_Sync_n(ir_node *n, int i);
366 
374 FIRM_API size_t get_ASM_n_constraints(const ir_node *node);
376 FIRM_API size_t get_ASM_n_clobbers(const ir_node *node);
377 
381 FIRM_API ir_node *skip_Proj(ir_node *node);
383 FIRM_API const ir_node *skip_Proj_const(const ir_node *node);
385 FIRM_API ir_node *skip_Id(ir_node *node);
387 FIRM_API ir_node *skip_Tuple(ir_node *node);
389 FIRM_API ir_node *skip_Pin(ir_node *node);
391 FIRM_API ir_node *skip_Confirm(ir_node *node);
393 FIRM_API int is_cfop(const ir_node *node);
396 FIRM_API int is_unknown_jump(const ir_node *node);
397 
403 FIRM_API int is_fragile_op(const ir_node *node);
404 
407 FIRM_API int is_irn_forking(const ir_node *node);
408 
411 FIRM_API int is_irn_const_memory(const ir_node *node);
412 
426 FIRM_API void copy_node_attr(ir_graph *irg, const ir_node *old_node, ir_node *new_node);
427 
430 FIRM_API ir_type *get_irn_type_attr(ir_node *n);
431 
434 
436 FIRM_API int is_irn_constlike(const ir_node *node);
437 
442 FIRM_API int is_irn_keep(const ir_node *node);
443 
447 FIRM_API int is_irn_start_block_placed(const ir_node *node);
448 
450 FIRM_API const char *get_cond_jmp_predicate_name(cond_jmp_predicate pred);
451 
456 FIRM_API void *get_irn_generic_attr(ir_node *node);
461 FIRM_API const void *get_irn_generic_attr_const(const ir_node *node);
462 
468 FIRM_API unsigned get_irn_idx(const ir_node *node);
469 
476 FIRM_API void set_irn_dbg_info(ir_node *n, dbg_info *db);
477 
483 FIRM_API dbg_info *get_irn_dbg_info(const ir_node *n);
484 
488 FIRM_API const char *gdb_node_helper(const void *firm_object);
489 
499 FIRM_API ir_switch_table *ir_new_switch_table(ir_graph *irg, size_t n_entries);
500 
504 FIRM_API size_t ir_switch_table_get_n_entries(const ir_switch_table *table);
505 
514 FIRM_API void ir_switch_table_set(ir_switch_table *table, size_t entry,
515  ir_tarval *min, ir_tarval *max, unsigned pn);
516 
518 FIRM_API ir_tarval *ir_switch_table_get_max(const ir_switch_table *table,
519  size_t entry);
520 
522 FIRM_API ir_tarval *ir_switch_table_get_min(const ir_switch_table *table,
523  size_t entry);
524 
526 FIRM_API unsigned ir_switch_table_get_pn(const ir_switch_table *table,
527  size_t entry);
528 
535 #include "end.h"
536 
537 #endif
void set_memop_mem(ir_node *node, ir_node *mem)
Sets the memory input of a memory operation.
const char ident
Identifier.
Definition: firm_types.h:50
ir_mode * get_irn_mode(const ir_node *node)
Returns the mode struct of a node.
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_irn_visited(ir_node *node, ir_visited_t visited)
Sets the visited counter of a node.
ir_visited_t get_Block_block_visited(const ir_node *block)
A visited flag only for block nodes.
const ir_node * skip_Proj_const(const ir_node *node)
Returns operand of node if node is a Proj.
ir_builtin_kind
Supported libFirm builtins.
Definition: firm_types.h:282
ir_relation
Relations for comparing numbers.
Definition: firm_types.h:162
unsigned get_irn_opcode(const ir_node *node)
Returns the opcode-enum of the node.
struct ir_tarval ir_tarval
Target Machine Value.
Definition: firm_types.h:68
void add_End_keepalive(ir_node *end, ir_node *ka)
Keep alive dedicated nodes.
ir_switch_table * ir_switch_table_duplicate(ir_graph *irg, const ir_switch_table *table)
Duplicates switch table table on obstack of irg.
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 set_binop_left(ir_node *node, ir_node *left)
Sets left operand of binary operation node.
int Block_block_visited(const ir_node *node)
Returns 1 if a block is marked as visited.
void set_irn_dbg_info(ir_node *n, dbg_info *db)
Sets the debug information of a node.
const char * get_cond_jmp_predicate_name(cond_jmp_predicate pred)
Returns the string representation of the jump prediction.
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 remove_Sync_n(ir_node *n, int i)
Removes predecessor i from Sync n.
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_n(ir_node *end, int idx)
Removes predecessor (a keepalive) at index idx from End node end.
void remove_End_Bads_and_doublets(ir_node *end)
Removes Bads, NoMem and doublets from the keep-alive set.
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.
ir_node * get_memop_mem(const ir_node *node)
Returns the memory input of a memory operation.
size_t get_ASM_n_constraints(const ir_node *node)
Returns the number of output constraints for an ASM node.
ir_node * get_irn_n(const ir_node *node, int n)
Returns the n-th predecessor of a node.
ir_relation get_negated_relation(ir_relation relation)
Calculates the negated (Complement(R)) relation, i.e.
void set_irn_link(ir_node *node, void *link)
Sets the link of a node.
ir_graph * get_irn_irg(const ir_node *node)
Returns the ir_graph this node belongs to.
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 free_End(ir_node *end)
Some parts of the End node are allocated separately – their memory is not recovered by dead_node_eli...
void set_irn_mode(ir_node *node, ir_mode *mode)
Sets the mode struct of node.
cond_jmp_predicate
A type to express conditional jump predictions.
Definition: firm_types.h:212
ir_relation get_inversed_relation(ir_relation relation)
Calculates the inversed (R^-1) relation, i.e., "<" –> ">".
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_pinned(ir_node *node, int pinned)
Sets pin state for nodes with op pin state op_pin_state_exc_pinned.
int get_irn_pinned(const ir_node *node)
Returns whether a node is pinned.
ir_node * skip_Pin(ir_node *node)
Returns operand of node if node is a Pin.
void set_Block_phis(ir_node *block, ir_node *phi)
Sets the head of the Phi list for this block.
int is_irn_constlike(const ir_node *node)
Returns non-zero for constant-like nodes.
unsigned get_irn_idx(const ir_node *node)
Returns the unique node index for the node in its graph.
unsigned get_Block_mark(const ir_node *block)
Returns the Block mark (single bit).
ir_node * skip_Confirm(ir_node *node)
Returns operand of node if node is a Confirm.
int is_cfop(const ir_node *node)
Returns true if the operation manipulates control flow.
ir_node * get_Block_phis(const ir_node *block)
Returns the head of the Phi list for this block.
void mark_irn_visited(ir_node *node)
Sets visited to get_irg_visited(get_irn_irg(node)).
ir_op * get_irn_op(const ir_node *node)
Returns the opcode struct of the node.
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.
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.
struct ir_type ir_type
Type.
Definition: firm_types.h:71
void set_Block_mark(ir_node *block, unsigned mark)
Sets the Block mark (single bit).
void * get_irn_link(const ir_node *node)
Returns the link of a node.
ir_node * get_binop_left(const ir_node *node)
Returns left operand of binary operation node.
void set_Phi_next(ir_node *phi, ir_node *next)
Sets the next link of a block Phi list.
int get_Block_matured(const ir_node *block)
Returns the matured flag of a block.
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_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)
size_t get_ASM_n_clobbers(const ir_node *node)
Returns the number of clobbered registers for an ASM node.
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.
const void * get_irn_generic_attr_const(const ir_node *node)
Returns a pointer to the node attributes.
int is_x_regular_Proj(const ir_node *node)
Tests whether a node is the X_regular Proj of a fragile operation.
ir_node * skip_Tuple(ir_node *node)
Returns corresponding operand of Tuple if node is a Proj from a Tuple.
int is_memop(const ir_node *node)
Returns true if node is a memory operation.
const char * get_irn_opname(const ir_node *node)
Returns the string representation of the opcode.
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_node * skip_Id(ir_node *node)
Returns operand of node if node is a Id.
ir_node * get_Phi_next(const ir_node *phi)
Returns the next element of a block phi list.
ir_node * skip_Proj(ir_node *node)
Returns operand of node if node is a Proj.
struct ir_node ir_node
Procedure Graph Node.
Definition: firm_types.h:53
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...
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_relation_string(ir_relation relation)
Returns the name of an ir_relation.
void add_Sync_pred(ir_node *node, ir_node *pred)
Adds pred to predecessor list of Sync node node.
ir_node * get_binop_right(const ir_node *node)
Returns rights operand of binary operation node.
void set_End_keepalives(ir_node *end, int n, ir_node *in[])
Sets new keep-alives.
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_unknown_jump(const ir_node *node)
Returns true if the operation jumps to an unknown destination.
int is_Const_one(const ir_node *node)
Returns non-zero if the given Const node represents the 1 constant.
const char * get_builtin_kind_name(ir_builtin_kind kind)
Returns a human readable string for the ir_builtin_kind.
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-...
int is_Const_null(const ir_node *node)
Returns non-zero if the given Const node represents the 0 constant.
ir_tarval * ir_switch_table_get_min(const ir_switch_table *table, size_t entry)
Returns minimum tarval value of switch table entry entry.
struct ir_entity ir_entity
Entity.
Definition: firm_types.h:83
void set_nodes_block(ir_node *node, ir_node *block)
Sets the Block of a node.
void set_binop_right(ir_node *node, ir_node *right)
Sets right operand of binary operation node.
void remove_End_keepalive(ir_node *end, const ir_node *irn)
Removes irn from the keep-alive set.
struct ir_op ir_op
Node Opcode.
Definition: firm_types.h:56
ir_node * get_nodes_block(const ir_node *node)
Returns the block the node belongs to.
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_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)).
int add_irn_n(ir_node *node, ir_node *in)
Appends a new predecessor to a node.
ir_node * exact_copy(const ir_node *node)
Creates an exact copy of node with same inputs and attributes in the same block.
ident * get_irn_opident(const ir_node *node)
Returns the ident for a string representation of the opcode.
int irn_visited_else_mark(ir_node *node)
Returns 1 if visited >= get_irg_visited(get_irn_irg(node)).
int is_x_except_Proj(const ir_node *node)
Tests whether a node is the X_except Proj of a fragile operation.
ir_tarval * ir_switch_table_get_max(const ir_switch_table *table, size_t entry)
Returns maximum tarval value of switch table entry entry.
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.
ir_entity * get_Call_callee(const ir_node *call)
Convenience function: Return method that will be called by a call.
ir_node * irn_copy_into_irg(const ir_node *node, ir_graph *irg)
Create an exact copy of node with same inputs and attributes in the same block but stored in the grap...
int is_irn_forking(const ir_node *node)
Returns true if the operation is a forking control flow operation: Cond.
struct ir_mode ir_mode
SSA Value mode.
Definition: firm_types.h:59
struct ir_graph ir_graph
Procedure Graph.
Definition: firm_types.h:74
int get_irn_arity(const ir_node *node)
Returns the number of predecessors without the block predecessor.
void mark_Block_block_visited(ir_node *node)
Marks a block as visited by setting its visited counter.
void add_Block_phi(ir_node *block, ir_node *phi)
Add a Phi node to the list of Block Phi&#39;s.
struct dbg_info dbg_info
Source Reference.
Definition: firm_types.h:40
const char * gdb_node_helper(const void *firm_object)
Returns a descriptive name of a node (containing type+number)
struct ir_switch_table ir_switch_table
A switch table mapping integer numbers to proj-numbers of a Switch-node.
Definition: firm_types.h:105
ir_visited_t get_irn_visited(const ir_node *node)
Returns the visited counter of a node.
ir_node * get_Block_cfgpred_block(const ir_node *node, int pos)
Returns the predecessor block.
void * get_irn_generic_attr(ir_node *node)
Returns a pointer to the node attributes.