irnode.h 17.3 KB
Newer Older
Christian Würdig's avatar
Christian Würdig committed
1
2
/*
 * This file is part of libFirm.
3
 * Copyright (C) 2012 University of Karlsruhe.
Christian Würdig's avatar
Christian Würdig committed
4
5
 */

Matthias Braun's avatar
Matthias Braun committed
6
7
8
9
/**
 * @file
 * @brief   Representation of an intermediate operation.
 * @author  Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Michael Beck
Michael Beck's avatar
Michael Beck committed
10
 */
Matthias Braun's avatar
Matthias Braun committed
11
12
#ifndef FIRM_IR_IRNODE_H
#define FIRM_IR_IRNODE_H
Christian Schäfer's avatar
Christian Schäfer committed
13

14
15
#include <stddef.h>

Michael Beck's avatar
Michael Beck committed
16
#include "firm_common.h"
17
#include "typerep.h"
Michael Beck's avatar
Michael Beck committed
18
19
#include "irop.h"
#include "irmode.h"
20
#include "begin.h"
21
#include "nodes.h"
Michael Beck's avatar
Michael Beck committed
22
23

/**
Matthias Braun's avatar
Matthias Braun committed
24
 * @ingroup ir_graph
Matthias Braun's avatar
Matthias Braun committed
25
 * @defgroup ir_node Nodes
Götz Lindenmaier's avatar
Götz Lindenmaier committed
26
 *
Michael Beck's avatar
Michael Beck committed
27
 * ir_node - a datatype representing a Firm node
Götz Lindenmaier's avatar
Götz Lindenmaier committed
28
 *
Michael Beck's avatar
Michael Beck committed
29
30
31
32
33
34
35
36
37
38
39
40
41
 *  The common fields are:
 *
 *  - arity     - The number of predecessors in the Firm graph.
 *  - in        - A list with the predecessors in the Firm graph.  There are
 *                routines to access individual elements and to obtain the
 *                array.  The method returning the array should not be used.
 *  - mode      - The mode of the node.  There are routines to get the mode
 *                but also to access the mode's fields directly.
 *  - opcode    - The opcode of the node. There are routines to get the opcode
 *                but also to access the opcode's fields directly.
 *  - node_nr   - A unique number for the node.  Available only if debugging
 *                is turned on.
 * @{
Götz Lindenmaier's avatar
Götz Lindenmaier committed
42
 */
Michael Beck's avatar
Michael Beck committed
43

44
45
46
47
48
/**
 * Returns the number of predecessors without the block predecessor.
 *
 * @param node   the IR-node
 */
49
FIRM_API int get_irn_arity(const ir_node *node);
50
51

/**
52
 * Returns the n-th predecessor of a node.
53
54
 * This function removes Id predecessors.
 */
Michael Beck's avatar
Michael Beck committed
55
FIRM_API ir_node *get_irn_n(const ir_node *node, int n);
Michael Beck's avatar
Michael Beck committed
56

57
58
59
60
61
62
/**
 * Replaces the old in array by a new one that will contain the ins given in
 * the parameters. Conserves the block predecessor. It copies the array passed.
 * This function is necessary to adjust in arrays of blocks, calls and phis.
 * "in" must contain all predecessors except the block that are required for
 * the nodes opcode. */
63
FIRM_API void set_irn_in(ir_node *node, int arity, ir_node *const in[]);
64

65
/** Replaces the n-th predecessor of a node with a new one. */
Michael Beck's avatar
Michael Beck committed
66
FIRM_API void set_irn_n(ir_node *node, int n, ir_node *in);
67
68
/**
 * Appends a new predecessor to a node. This only works for nodes with
69
 * dynamic arity!
70
71
 * @returns   the number of the new input
 */
Michael Beck's avatar
Michael Beck committed
72
FIRM_API int add_irn_n(ir_node *node, ir_node *in);
73
/** Sets the mode struct of node.  */
Michael Beck's avatar
Michael Beck committed
74
FIRM_API void set_irn_mode(ir_node *node, ir_mode *mode);
75
/** Returns the mode struct of a node.  */
Michael Beck's avatar
Michael Beck committed
76
FIRM_API ir_mode *get_irn_mode(const ir_node *node);
77
/** Returns the opcode struct of the node. */
Michael Beck's avatar
Michael Beck committed
78
FIRM_API ir_op *get_irn_op(const ir_node *node);
79
/** Returns the opcode-enum of the node. */
Michael Beck's avatar
Michael Beck committed
80
FIRM_API unsigned get_irn_opcode(const ir_node *node);
81
/** Returns the string representation of the opcode. */
Michael Beck's avatar
Michael Beck committed
82
FIRM_API const char *get_irn_opname(const ir_node *node);
83
/** Returns the ident for a string representation of the opcode. */
Michael Beck's avatar
Michael Beck committed
84
FIRM_API ident *get_irn_opident(const ir_node *node);
85
/** Returns the visited counter of a node. */
Michael Beck's avatar
Michael Beck committed
86
FIRM_API ir_visited_t get_irn_visited(const ir_node *node);
87
/** Sets the visited counter of a node. */
Michael Beck's avatar
Michael Beck committed
88
FIRM_API void set_irn_visited(ir_node *node, ir_visited_t visited);
89
/** Sets visited to get_irg_visited(get_irn_irg(node)). */
Michael Beck's avatar
Michael Beck committed
90
FIRM_API void mark_irn_visited(ir_node *node);
91
/** Returns 1 if visited >= get_irg_visited(get_irn_irg(node)). */
Michael Beck's avatar
Michael Beck committed
92
FIRM_API int irn_visited(const ir_node *node);
93
/** Returns 1 if visited >= get_irg_visited(get_irn_irg(node)). Marks the node
94
 * visited, if it was not. */
Michael Beck's avatar
Michael Beck committed
95
FIRM_API int irn_visited_else_mark(ir_node *node);
96
97
98
99
100

/**
 * Sets the link of a node.
 * Only allowed if the graph is NOT in phase_building.
 */
Michael Beck's avatar
Michael Beck committed
101
FIRM_API void set_irn_link(ir_node *node, void *link);
102
103

/** Returns the link of a node.  */
Michael Beck's avatar
Michael Beck committed
104
FIRM_API void *get_irn_link(const ir_node *node);
105

106
/** Returns the ir_graph this node belongs to. */
Michael Beck's avatar
Michael Beck committed
107
FIRM_API ir_graph *get_irn_irg(const ir_node *node);
Michael Beck's avatar
Michael Beck committed
108

109
/** Outputs a unique number for this node if libFIRM is compiled for
110
111
   debugging, (configure with --enable-debug) else returns address
   of node cast to long. */
Michael Beck's avatar
Michael Beck committed
112
FIRM_API long get_irn_node_nr(const ir_node *node);
Michael Beck's avatar
Michael Beck committed
113

114
115
116
117
118
119
120
/** Returns the pinned state of a node.
 *
 *  Returns whether the node _always_ must be pinned.
 *  I.e., the node is not floating after global cse.
 *
 * @returns Either state op_pin_state_pinned or op_pin_state_floats.
 */
Michael Beck's avatar
Michael Beck committed
121
FIRM_API op_pin_state get_irn_pinned(const ir_node *node);
Michael Beck's avatar
Michael Beck committed
122

123
/** Sets pin state for nodes with op pin state op_pin_state_exc_pinned */
Michael Beck's avatar
Michael Beck committed
124
FIRM_API void set_irn_pinned(ir_node *node, op_pin_state state);
Götz Lindenmaier's avatar
Götz Lindenmaier committed
125

Michael Beck's avatar
Michael Beck committed
126
/**
127
128
129
 * IR node constructor.
 * Create a new IR node in irg, with an op, mode, arity and
 * some incoming IR nodes.
Matthias Braun's avatar
Matthias Braun committed
130
131
 * Normally you should not use this constructor directly unless you registered
 * custom opcodes. For the default opcodes firm provides specific constructors.
132
133
134
 *
 * @param db    Debug info.
 * @param irg   IR-graph on with this new node should be constructed.
Michael Beck's avatar
Michael Beck committed
135
 * @param block The block the new node belongs to
136
137
 * @param op    The opcode of the new node.
 * @param mode  The mode of the new node.
138
 * @param arity The arity of the new node, <0 if can be changed dynamically.
139
 * @param in    An array of arity predecessor nodes.
Michael Beck's avatar
Michael Beck committed
140
 */
Michael Beck's avatar
Michael Beck committed
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);
Christian Schäfer's avatar
Christian Schäfer committed
144

145
/**
146
 * Returns the block the node belongs to.  This is only
147
148
149
 * possible for pinned nodes or if the graph is in pinned state.
 * Otherwise the block may be incorrect.  This condition is
 * now checked by an assertion.
Götz Lindenmaier's avatar
Götz Lindenmaier committed
150
151
152
153
154
 *
 * This works for all except Block.  It can return Blocks or the Bad node.
 *
 * To express the difference to access routines that work for all
 * nodes we use infix "nodes" and do not name this function
155
 * get_irn_block(). */
156
FIRM_API ir_node *get_nodes_block(const ir_node *node);
Michael Beck's avatar
Michael Beck committed
157
158

/** Sets the Block of a node. */
159
FIRM_API void set_nodes_block(ir_node *node, ir_node *block);
Götz Lindenmaier's avatar
Götz Lindenmaier committed
160

Matthias Braun's avatar
Matthias Braun committed
161
162
163
164
165
/**
 * @addtogroup Block
 * @{
 */

166
167
/**
 * Returns the predecessor block.
168
 *
169
 * Returns the block corresponding to the predecessor pos of block.
170
 *
171
 * If we encounter the Bad node as controlflow predecessor NULL is returned.
172
 */
Michael Beck's avatar
Michael Beck committed
173
FIRM_API ir_node *get_Block_cfgpred_block(const ir_node *node, int pos);
174

175
/** Returns the matured flag of a block */
Michael Beck's avatar
Michael Beck committed
176
FIRM_API int get_Block_matured(const ir_node *block);
177
/** set the matured flag of a block. */
Michael Beck's avatar
Michael Beck committed
178
FIRM_API void set_Block_matured(ir_node *block, int matured);
Götz Lindenmaier's avatar
Götz Lindenmaier committed
179
180
181

/** A visited flag only for block nodes.
 *  @see also: get_irn_visited() inc_irg_visited() inc_irg_block_visited()*/
Michael Beck's avatar
Michael Beck committed
182
FIRM_API ir_visited_t get_Block_block_visited(const ir_node *block);
183
/** set block visited flag */
Michael Beck's avatar
Michael Beck committed
184
FIRM_API void set_Block_block_visited(ir_node *block, ir_visited_t visit);
185

186
/** Marks a block as visited by setting its visited counter */
Michael Beck's avatar
Michael Beck committed
187
FIRM_API void mark_Block_block_visited(ir_node *node);
188
/** Returns 1 if a block is marked as visited */
Michael Beck's avatar
Michael Beck committed
189
FIRM_API int Block_block_visited(const ir_node *node);
Christian Schäfer's avatar
Christian Schäfer committed
190

191
/** Returns the entity for a Block (creating it if necessary) */
Michael Beck's avatar
Michael Beck committed
192
FIRM_API ir_entity *create_Block_entity(ir_node *block);
193
/** Returns the head of the Phi list for this block. */
Michael Beck's avatar
Michael Beck committed
194
FIRM_API ir_node *get_Block_phis(const ir_node *block);
195
/** Sets the head of the Phi list for this block. */
Michael Beck's avatar
Michael Beck committed
196
FIRM_API void set_Block_phis(ir_node *block, ir_node *phi);
Michael Beck's avatar
Michael Beck committed
197
/** Add a Phi node to the list of Block Phi's. */
Michael Beck's avatar
Michael Beck committed
198
FIRM_API void add_Block_phi(ir_node *block, ir_node *phi);
199
/** Returns the Block mark (single bit). */
Michael Beck's avatar
Michael Beck committed
200
FIRM_API unsigned get_Block_mark(const ir_node *block);
201
/** Sets the Block mark (single bit). */
Michael Beck's avatar
Michael Beck committed
202
FIRM_API void set_Block_mark(ir_node *block, unsigned mark);
Michael Beck's avatar
Michael Beck committed
203

Matthias Braun's avatar
Matthias Braun committed
204
205
206
207
208
209
/** @} */

/** @addtogroup End
 * @{
 */

Michael Beck's avatar
Michael Beck committed
210
/** Keep alive dedicated nodes.  These must be either PhiM or Block nodes. */
Michael Beck's avatar
Michael Beck committed
211
FIRM_API void add_End_keepalive(ir_node *end, ir_node *ka);
212
213

/**
214
 * Sets new keep-alives.
215
216
217
 * Beware: This might be an expensive operation if dynamic edges are enabled,
 * so avoid it in the backend.
 */
Michael Beck's avatar
Michael Beck committed
218
FIRM_API void set_End_keepalives(ir_node *end, int n, ir_node *in[]);
219

220
/** Removes irn from the keep-alive set. */
Matthias Braun's avatar
Matthias Braun committed
221
FIRM_API void remove_End_keepalive(ir_node *end, const ir_node *irn);
222

223
224
225
/** Removes predecessor (a keepalive) at index @p idx from End node @p end. */
FIRM_API void remove_End_n(ir_node *end, int idx);

226
/** Removes Bads, NoMem and doublets from the keep-alive set. */
Michael Beck's avatar
Michael Beck committed
227
FIRM_API void remove_End_Bads_and_doublets(ir_node *end);
228

Michael Beck's avatar
Michael Beck committed
229
/** Some parts of the End node are allocated separately -- their memory
230
231
232
 * is not recovered by dead_node_elimination if a End node is dead.
 * free_End() frees these data structures.
 */
Michael Beck's avatar
Michael Beck committed
233
FIRM_API void free_End(ir_node *end);
234

Matthias Braun's avatar
Matthias Braun committed
235
236
237
238
239
240
/** @} */

/** @addtogroup Const
 * @{
 */

241
/** Returns non-zero if the given Const node represents the 0 constant. */
Michael Beck's avatar
Michael Beck committed
242
FIRM_API int is_Const_null(const ir_node *node);
243

244
/** Returns non-zero if the given Const node represents the 1 constant. */
Michael Beck's avatar
Michael Beck committed
245
FIRM_API int is_Const_one(const ir_node *node);
246

247
/** Returns non-zero if the given Const node represents the constant with all bits set. */
Michael Beck's avatar
Michael Beck committed
248
FIRM_API int is_Const_all_one(const ir_node *node);
Sebastian Hack's avatar
Sebastian Hack committed
249

Matthias Braun's avatar
Matthias Braun committed
250
251
/** @} */

252
253
254
255
256
257
258
259
/**
 * @addtogroup Call
 * @{
 */

/**
 * Convenience function: Return method that will be called by a call.
 *
260
 * This matches for an address at the Call ptr input, return
261
262
263
264
265
266
267
 * the referenced entity if it has a method type.
 */
FIRM_API ir_entity *get_Call_callee(const ir_node *call);

/** @} */


268
/** Returns a human readable string for the ir_builtin_kind. */
Michael Beck's avatar
Michael Beck committed
269
FIRM_API const char *get_builtin_kind_name(ir_builtin_kind kind);
270

271
/** Returns left operand of binary operation @p node. */
Michael Beck's avatar
Michael Beck committed
272
FIRM_API ir_node *get_binop_left(const ir_node *node);
273
274
275
/** Sets left operand of binary operation @p node. */
FIRM_API void set_binop_left(ir_node *node, ir_node *left);
/** Returns rights operand of binary operation @p node. */
Michael Beck's avatar
Michael Beck committed
276
FIRM_API ir_node *get_binop_right(const ir_node *node);
277
278
/** Sets right operand of binary operation @p node. */
FIRM_API void set_binop_right(ir_node *node, ir_node *right);
Michael Beck's avatar
Michael Beck committed
279

Matthias Braun's avatar
Matthias Braun committed
280
/**
281
 * Tests whether a node is the X_except Proj of a fragile operation
Matthias Braun's avatar
Matthias Braun committed
282
 */
283
FIRM_API int is_x_except_Proj(const ir_node *node);
Matthias Braun's avatar
Matthias Braun committed
284
285

/**
286
 * Tests whether a node is the X_regular Proj of a fragile operation
Matthias Braun's avatar
Matthias Braun committed
287
 */
288
FIRM_API int is_x_regular_Proj(const ir_node *node);
289
290

/**
291
 * Sets throws exception attribute of a fragile node
292
293
 * @p throws_exception must be 0 or 1
 */
294
FIRM_API void ir_set_throws_exception(ir_node *node, int throws_exception);
295

296
297
/** Returns throws_exception attribute of a fragile node */
FIRM_API int ir_throws_exception(const ir_node *node);
Matthias Braun's avatar
Matthias Braun committed
298

299
/** Returns the name of an ir_relation */
300
FIRM_API const char *get_relation_string(ir_relation relation);
Michael Beck's avatar
Michael Beck committed
301

302
303
/** Calculates the negated (Complement(R)) relation, i.e. "<" --> ">=" */
FIRM_API ir_relation get_negated_relation(ir_relation relation);
Michael Beck's avatar
Michael Beck committed
304

305
306
/** Calculates the inversed (R^-1) relation, i.e., "<" --> ">" */
FIRM_API ir_relation get_inversed_relation(ir_relation relation);
307

Matthias Braun's avatar
Matthias Braun committed
308
309
310
311
312
/**
 * @addtogroup Phi
 * @{
 */

313
314
315
/**
 * Returns the next element of a block phi list.
 */
316
FIRM_API ir_node *get_Phi_next(const ir_node *phi);
317
318
319
/**
 * Sets the next link of a block Phi list.
 */
320
FIRM_API void set_Phi_next(ir_node *phi, ir_node *next);
321

Matthias Braun's avatar
Matthias Braun committed
322
323
/** @} */

324
/** Returns true if @p node is a memory operation.
325
 *
326
327
328
329
330
331
 * A memory operation is a node with an opcode that has irop_flag_uses_memory
 * set. It is guaranteed to have (exactly) one memory input.
 */
FIRM_API int is_memop(const ir_node *node);
/**
 * Returns the memory input of a memory operation.
332
 */
Michael Beck's avatar
Michael Beck committed
333
FIRM_API ir_node *get_memop_mem(const ir_node *node);
334
335
336
337
338
339
340
341
/**
 * Sets the memory input of a memory operation.
 */
FIRM_API void set_memop_mem(ir_node *node, ir_node *mem);

/** @addtogroup Sync
 * @{
 */
342

343
344
/** Adds @p pred to predecessor list of Sync node @p node. */
FIRM_API void add_Sync_pred(ir_node *node, ir_node *pred);
345
346
/** Removes predecessor @p i from Sync @p n */
FIRM_API void remove_Sync_n(ir_node *n, int i);
347
348

/** @} */
349

Matthias Braun's avatar
Matthias Braun committed
350
351
352
353
/** @addtogroup ASM
 * @{
 */

354
/** Returns the number of output constraints for an ASM node.  */
355
FIRM_API size_t get_ASM_n_output_constraints(const ir_node *node);
356
/** Returns the number of clobbered registers for an ASM node.  */
357
FIRM_API size_t get_ASM_n_clobbers(const ir_node *node);
Michael Beck's avatar
Michael Beck committed
358

Matthias Braun's avatar
Matthias Braun committed
359
360
/** @} */

Michael Beck's avatar
Michael Beck committed
361
/** Returns operand of node if node is a Proj. */
Michael Beck's avatar
Michael Beck committed
362
FIRM_API ir_node *skip_Proj(ir_node *node);
Michael Beck's avatar
Michael Beck committed
363
/** Returns operand of node if node is a Proj. */
Michael Beck's avatar
Michael Beck committed
364
FIRM_API const ir_node *skip_Proj_const(const ir_node *node);
Michael Beck's avatar
Michael Beck committed
365
/** Returns operand of node if node is a Id. */
366
367
FIRM_API ir_node *skip_Id(ir_node *node);
/** Returns corresponding operand of Tuple if node is a Proj from a Tuple. */
Michael Beck's avatar
Michael Beck committed
368
FIRM_API ir_node *skip_Tuple(ir_node *node);
Michael Beck's avatar
Michael Beck committed
369
/** Returns operand of node if node is a Pin. */
Michael Beck's avatar
Michael Beck committed
370
FIRM_API ir_node *skip_Pin(ir_node *node);
Michael Beck's avatar
Michael Beck committed
371
/** Returns operand of node if node is a Confirm */
Michael Beck's avatar
Michael Beck committed
372
FIRM_API ir_node *skip_Confirm(ir_node *node);
373
/** Returns true if the operation manipulates control flow */
Michael Beck's avatar
Michael Beck committed
374
FIRM_API int is_cfop(const ir_node *node);
375
/** Returns true if the operation jumps to an unknown destination.
376
377
 * See irop_flag_unknown_jump for a detailed explanation */
FIRM_API int is_unknown_jump(const ir_node *node);
378

379
380
381
382
383
/**
 * Returns true if the operation can change the control flow because
 * of an exception: Call, Div, Mod, Load, Store, Alloc,
 * Bad. Raise is not fragile, but a unconditional jump.
 */
Michael Beck's avatar
Michael Beck committed
384
FIRM_API int is_fragile_op(const ir_node *node);
Christian Schäfer's avatar
Christian Schäfer committed
385

Michael Beck's avatar
Michael Beck committed
386
387
/** Returns true if the operation is a forking control flow
 *  operation: Cond. */
Michael Beck's avatar
Michael Beck committed
388
FIRM_API int is_irn_forking(const ir_node *node);
Michael Beck's avatar
Michael Beck committed
389

390
391
392
393
/** Returns true if the operation does not change anymemory contents although
 * it has a memory input/output. */
FIRM_API int is_irn_const_memory(const ir_node *node);

394
/**
395
 * Copies attributes stored in the old node to a new node.
396
 * Assumes both have the same opcode and sufficient size.
397
398
399
400
401
402
403
 *
 * @param irg       The irg of the new_node (get_irn_irg on it might not work
 *                  yet)
 * @param old_node  the node where the attributes are copied from
 * @param new_node  node the attributes get copies to.
 *
 * This copies all essential information to the new node. It does not copy
404
405
 * temporary or calculated information like visited flags or results of
 * dominance or loop calculations.
406
 */
Michael Beck's avatar
Michael Beck committed
407
FIRM_API void copy_node_attr(ir_graph *irg, const ir_node *old_node, ir_node *new_node);
408

409
/** Returns the type attribute of a node n (TypeConst, Call, Alloc, Free)
Matthias Braun's avatar
Matthias Braun committed
410
 *  or NULL.*/
Michael Beck's avatar
Michael Beck committed
411
FIRM_API ir_type *get_irn_type_attr(ir_node *n);
Michael Beck's avatar
Michael Beck committed
412

413
/** Returns the entity attribute of a node n (Address, Offset, Sel) or NULL. */
Michael Beck's avatar
Michael Beck committed
414
FIRM_API ir_entity *get_irn_entity_attr(ir_node *n);
415

Michael Beck's avatar
Michael Beck committed
416
/** Returns non-zero for constant-like nodes. */
Michael Beck's avatar
Michael Beck committed
417
FIRM_API int is_irn_constlike(const ir_node *node);
Michael Beck's avatar
Michael Beck committed
418

Michael Beck's avatar
Michael Beck committed
419
420
421
422
/**
 * Returns non-zero for nodes that are allowed to have keep-alives and
 * are neither Block nor PhiM.
 */
Michael Beck's avatar
Michael Beck committed
423
FIRM_API int is_irn_keep(const ir_node *node);
Michael Beck's avatar
Michael Beck committed
424

425
426
427
/**
 * Returns non-zero for nodes that are always placed in the start block.
 */
Michael Beck's avatar
Michael Beck committed
428
FIRM_API int is_irn_start_block_placed(const ir_node *node);
429

430
/** Returns the string representation of the jump prediction. */
Michael Beck's avatar
Michael Beck committed
431
FIRM_API const char *get_cond_jmp_predicate_name(cond_jmp_predicate pred);
432

433
/**
434
435
 * Returns a pointer to the node attributes.
 * Used for accessing attributes of user-defined nodes.
436
 */
Michael Beck's avatar
Michael Beck committed
437
FIRM_API void *get_irn_generic_attr(ir_node *node);
438
439
440
441
/**
 * Returns a pointer to the node attributes.
 * Used for accessing attributes of user-defined nodes.
 */
Michael Beck's avatar
Michael Beck committed
442
FIRM_API const void *get_irn_generic_attr_const(const ir_node *node);
443

444
445
446
/**
 * Returns the unique node index for the node in its graph.
 * This index is used to access phase information for this node.
447
 * @see get_idx_irn()
448
 */
Michael Beck's avatar
Michael Beck committed
449
FIRM_API unsigned get_irn_idx(const ir_node *node);
450

451
452
453
454
455
456
/**
 * Sets the debug information of a node.
 *
 * @param n   The node.
 * @param db  The debug info.
 */
Michael Beck's avatar
Michael Beck committed
457
FIRM_API void set_irn_dbg_info(ir_node *n, dbg_info *db);
458
459
460
461
462
463

/**
 * Returns the debug information of an node.
 *
 * @param n   The node.
 */
Michael Beck's avatar
Michael Beck committed
464
FIRM_API dbg_info *get_irn_dbg_info(const ir_node *n);
465

466
/**
467
 * Returns a descriptive name of a node (containing type+number)
468
 */
469
FIRM_API const char *gdb_node_helper(const void *firm_object);
470

471
472
473
474
475
476
477
478
479
/**
 * @addtogroup Switch
 * @{
 */

/**
 * Creates a new switch_table datastructure with @p n_entries entries.
 * The datastructure is allocated on the obstack of @p irg.
 */
Matthias Braun's avatar
Matthias Braun committed
480
481
FIRM_API ir_switch_table *ir_new_switch_table(ir_graph *irg, size_t n_entries);

482
483
484
/**
 * Returns number of entries available in switch table @p table.
 */
Matthias Braun's avatar
Matthias Braun committed
485
486
FIRM_API size_t ir_switch_table_get_n_entries(const ir_switch_table *table);

487
488
489
490
491
492
493
494
/**
 * Sets entry number @p entry in the switch table @p table.
 * @param table  the switch table
 * @param entry  entry number to set
 * @param min    The minimum tarval that matches this entry
 * @param max    The maximum tarval that matches this entry
 * @param pn     Proj number taken on match
 */
Matthias Braun's avatar
Matthias Braun committed
495
FIRM_API void ir_switch_table_set(ir_switch_table *table, size_t entry,
496
                                  ir_tarval *min, ir_tarval *max, unsigned pn);
Matthias Braun's avatar
Matthias Braun committed
497

498
/** Returns maximum tarval value of switch table entry @p entry */
Matthias Braun's avatar
Matthias Braun committed
499
500
501
FIRM_API ir_tarval *ir_switch_table_get_max(const ir_switch_table *table,
                                            size_t entry);

502
/** Returns minimum tarval value of switch table entry @p entry */
Matthias Braun's avatar
Matthias Braun committed
503
504
505
FIRM_API ir_tarval *ir_switch_table_get_min(const ir_switch_table *table,
                                            size_t entry);

506
/** Returns proj number taken if switch table entry @p entry matches */
507
508
FIRM_API unsigned ir_switch_table_get_pn(const ir_switch_table *table,
                                         size_t entry);
Matthias Braun's avatar
Matthias Braun committed
509

510
/** Duplicates switch table @p table on obstack of @p irg */
Matthias Braun's avatar
Matthias Braun committed
511
FIRM_API ir_switch_table *ir_switch_table_duplicate(ir_graph *irg, const ir_switch_table *table);
512
/** @} */
Matthias Braun's avatar
Matthias Braun committed
513

514
/** @} */
515

516
517
#include "end.h"

Matthias Braun's avatar
Matthias Braun committed
518
#endif