* Iterates oven an pset.
*
* @param pset the pset
+ * @param type type of iterator variable
* @param entry the iterator
*/
#define foreach_pset(pset, type, entry) for (entry = (type)pset_first(pset); entry; entry = (type)pset_next(pset))
* Iterates over an set.
*
* @param set the set
+ * @param type type of iterator variable
* @param entry the iterator
*/
#define foreach_set(set, type, entry) for (entry = (type) set_first(set); entry; entry = (type) set_next(set))
#include "firm_types.h"
#include "begin.h"
-/* Methoden sind "frei", wenn ihr Funktionszeiger (potentiell)
- * "explizit" bekannt ist, d.h.:
- *
- * - die Methode ist von aussen sichtbar (external_visible).
- *
- * - ihr Funktionszeiger ist "frei", d.h. der Funktionszeiger wurde
- * nicht ausschliesslich an den entsprechenden Eingang eines
- * Call-Knotens weitergegeben, sondern z.B. in den Speicher
- * geschrieben, als Parameter uebergeben, ...
- *
- * Die main-Methode ist immer in der Menge enthalten.
- *
- * Die Links an den "ir_node"s werden geloescht.
- */
-
/** Analyses a rough estimation of the possible call graph.
*
* Determines for each Call node the set of possibly called methods.
* and Craig Chambers.
*
* Performs some optimizations possible by the analysed information:
- * - Replace SymConst-name nodes by SymConst-entity nodes if possible.
- * - Replace (Sel-method(Alloc)) by SymConst-entity.
- * - Replaces Sel-method by SymConst-entity if the method is never overwritten.
+ * - Replace SymConst-name nodes by SymConst-entity nodes if possible.
+ * - Replace (Sel-method(Alloc)) by SymConst-entity.
+ * - Replaces Sel-method by SymConst-entity if the method is never overwritten.
*/
FIRM_API size_t cgana(ir_entity ***free_methods);
-/** Free callee information.
+/**
+ * Free callee information.
*
- * Sets callee_info_state of the graph passed to none. Sets callee field
- * in all call nodes to NULL. Else it happens that the field contains
- * pointers to other than firm arrays.
+ * Sets callee_info_state of the graph passed to none. Sets callee field
+ * in all call nodes to NULL. Else it happens that the field contains
+ * pointers to other than firm arrays.
*/
FIRM_API void free_callee_info(ir_graph *irg);
FIRM_API void free_irp_callee_info(void);
-/* Optimize the address expressions passed to call nodes.
- * Performs only the optimizations done by cgana. */
+/**
+ * Optimize the address expressions passed to call nodes.
+ * Performs only the optimizations done by cgana.
+ */
FIRM_API void opt_call_addrs(void);
#include "end.h"
#include "firm_types.h"
#include "begin.h"
-/* A proj from a Cond that goes to an exception handler. */
+/** A proj from a Cond that goes to an exception handler. */
FIRM_API int is_fragile_Proj(ir_node *n);
/** Returns the number of times the block/region is executed according to
* The exec_freq_state in irp is consistent, if the state of all graphs is consistent.
* It is none, if the state of all graphs is none. Else it is inconsistent. */
typedef enum {
- exec_freq_none, /**< Execution frequencies are not computed, no memory is
- allocated, access fails. */
- exec_freq_consistent, /**< Execution frequency information is computed and correct. */
- exec_freq_inconsistent /**< Execution frequency is computed but the graph has been
- changed since. */
+ exec_freq_none, /**< Execution frequencies are not computed, no
+ memory is allocaaccess fails. */
+ exec_freq_consistent, /**< Execution frequency information is computed and
+ correct. */
+ exec_freq_inconsistent /**< Execution frequency is computed but the graph
+ has been changed since. */
} exec_freq_state;
FIRM_API exec_freq_state get_irg_exec_freq_state(ir_graph *irg);
FIRM_API void set_irg_exec_freq_state(ir_graph *irg,
exec_freq_state s);
-/* Sets irg and irp exec freq state to inconsistent if it is set to consistent. */
+/**
+ * Sets irg and irp exec freq state to inconsistent if it is set to consistent.
+ */
FIRM_API void set_irg_exec_freq_state_inconsistent(ir_graph *irg);
FIRM_API exec_freq_state get_irp_exec_freq_state(void);
-/* Sets irp and all irg exec freq states to inconsistent if it is set to consistent. */
+/**
+ * Sets irp and all irg exec freq states to inconsistent if it is set to
+ * consistent.
+ */
FIRM_API void set_irp_exec_freq_state_inconsistent(void);
#include "end.h"
#include "begin.h"
-/* The number of array elements we assume if not both bounds are given. */
+/** The number of array elements we assume if not both bounds are given. */
#define DEFAULT_N_ARRAY_ELEMENTS 1
FIRM_API int get_irn_loop_call_depth(ir_node *n);
FIRM_API int get_irn_cfloop_depth(ir_node *n);
FIRM_API int get_irn_recursion_depth(ir_node *n);
-/** Get the weighted interprocedural loop depth of the node.
- The depth is estimated by a heuristic. The heuristic considers
- loop and recursion depth. */
+/**
+ * Get the weighted interprocedural loop depth of the node.
+ * The depth is estimated by a heuristic. The heuristic considers
+ * loop and recursion depth.
+ */
FIRM_API int get_weighted_loop_depth(ir_node *n);
/** Heuristic merging recursion and loop depth. */
FIRM_API double get_class_estimated_n_upcasts(ir_type *clss);
FIRM_API double get_class_estimated_n_downcasts(ir_type *clss);
-/** Returns the number of accesses to the dispatch table.
+/**
+ * Returns the number of accesses to the dispatch table.
*
- * This includes the initialization of the pointer field, and accesses
- * to virtual fields (as instance marker in Java). Certainly this
- * includes virtual method calls. */
+ * This includes the initialization of the pointer field, and accesses
+ * to virtual fields (as instance marker in Java). Certainly this
+ * includes virtual method calls.
+ */
FIRM_API double get_class_estimated_n_dyncalls(ir_type *clss);
/** Returns the number of writes to the dispatch pointer.
* This is the same as the number of allocations. */
FIRM_API double get_entity_estimated_n_loads(ir_entity *ent);
FIRM_API double get_entity_estimated_n_stores(ir_entity *ent);
FIRM_API double get_entity_estimated_n_calls(ir_entity *ent);
-/** The number of accesses to dynamically called methods and
- * to other static fields that overwrite/are overwritten. */
-FIRM_API double get_entity_estimated_n_dyncalls(ir_entity *ent);
-/* ------------------------------------------------------------------------- */
-/* Accumulate information in the type hierarchy. */
-/* ------------------------------------------------------------------------- */
+/**
+ * The number of accesses to dynamically called methods and
+ * to other static fields that overwrite/are overwritten.
+ */
+FIRM_API double get_entity_estimated_n_dyncalls(ir_entity *ent);
typedef enum {
temperature_none,
FIRM_API void *get_region_in(void *region, int pos);
FIRM_API void add_region_in(void *region, void *in);
-
-/** The number of out edges of a region.
+/**
+ * The number of out edges of a region.
*
- * This number is useful for evaluation of execution frequencies.
+ * This number is useful for evaluation of execution frequencies.
*/
FIRM_API int get_region_n_outs(void *region);
-/** The number of exception out edges of a region.
+/**
+ * The number of exception out edges of a region.
*
- * This number is useful for evaluation of execution frequencies.
+ * This number is useful for evaluation of execution frequencies.
*/
FIRM_API int get_region_n_exc_outs(void *region);
-/** The control flow operation corresponding to the loop-region in at
- * position pos.
+/**
+ * The control flow operation corresponding to the loop-region in at
+ * position pos.
*/
FIRM_API void *get_loop_cfop(void *region, int pos);
-/** The algorithm to construct the interval graph.
+/**
+ * The algorithm to construct the interval graph.
*
- * Constructs the cf loop tree and leaves a valid version of it.
+ * Constructs the cf loop tree and leaves a valid version of it.
*/
FIRM_API void construct_intervals(ir_graph *irg);
/**
* Get the edge object of an outgoing edge at a node.
- * @param irg The graph, the node is in.
* @param irn The node at which the edge originates.
* @param pos The position of the edge.
* @param kind The kind of the edge.
FIRM_VERIFICATION_ERROR_ONLY = 3 /**< do node verification, but NEVER do assert nor report */
} firm_verification_t;
-/** Select verification of IR nodes and types.
+/**
+ * Select verification of IR nodes and types.
*
- * Per default the verification is in mode NODE_VERIFICATION_ASSERT.
- * Turn the verification off during development to check partial implementations.
+ * Per default the verification is in mode NODE_VERIFICATION_ASSERT.
+ * Turn the verification off during development to check partial
+ * implementations.
*/
FIRM_API void do_node_verification(firm_verification_t mode);
*/
FIRM_API void free_ir_graph(ir_graph *irg);
-/* --- access routines for all ir_graph attributes --- */
-
/**
* Checks whether a pointer points to a ir graph.
*
FIRM_API ir_node *get_idx_irn(const ir_graph *irg, unsigned idx);
-/******************************************************************************/
-/* States of an ir_graph. */
-/******************************************************************************/
-
-/*
- information associated with the graph. Optimizations invalidate these
- states. */
-
/** The states of an ir graph.
*
* state phase values: phase_building, phase_high, phase_low, phase_backend.
* if 2 parties try to use the flags.
*/
typedef enum ir_resources_t {
- /* local (irg) resources */
IR_RESOURCE_NONE = 0,
IR_RESOURCE_BLOCK_VISITED = 1 << 0, /**< Block visited flags are used. */
IR_RESOURCE_BLOCK_MARK = 1 << 1, /**< Block mark bits are used. */
#include "firm_common.h"
#include "begin.h"
-/* ------------------------------------------------------------------- */
-/*
- * Backedge information.
- *
- * Predecessors of Block and Phi nodes can have backedges.
- * If loop information is computed, this information is computed, too.
- * The backedge information can only be used if the graph is not in
- * phase phase_building.
- */
-/* ------------------------------------------------------------------- */
-
/** Returns non-zero if the predecessor pos is a backedge. */
FIRM_API int is_backedge(const ir_node *n, int pos);
/** Marks edge pos as a backedge. */
/** Set the outermost loop in ir graph as basic access to loop tree. */
FIRM_API void set_irg_loop(ir_graph *irg, ir_loop *l);
-/* Returns the root loop info (if exists) for an irg. */
+/** Returns the root loop info (if exists) for an irg. */
FIRM_API ir_loop *get_irg_loop(const ir_graph *irg);
/** Returns the loop n is contained in. NULL if node is in no loop. */
/** Returns nesting depth of this loop */
FIRM_API unsigned get_loop_depth(const ir_loop *loop);
-/* Sons are the inner loops contained in this loop. */
/** Returns the number of inner loops */
FIRM_API size_t get_loop_n_sons(const ir_loop *loop);
FIRM_API void set_loop_link(ir_loop *loop, void *link);
FIRM_API void *get_loop_link(const ir_loop *loop);
-/* ------------------------------------------------------------------- */
-/* Constructing and destructing the loop/backedge information. */
-/* ------------------------------------------------------------------- */
-
/** Constructs backedge information and loop tree for a graph.
*
* The algorithm views the program representation as a pure graph.
FIRM_API void free_loop_information(ir_graph *irg);
FIRM_API void free_all_loop_information (void);
-
-/* ------------------------------------------------------------------- */
-/* Simple analyses based on the loop information */
-/* ------------------------------------------------------------------- */
-
/** Test whether a value is loop invariant.
*
* @param n The node to be tested.
#include "firm_types.h"
#include "begin.h"
-/* ********** Predefined modes ********** */
-
/** Helper values for ir_mode_sort. */
enum ir_mode_sort_helper {
irmsh_is_num = 0x10, /**< mode represents a number */
* the mode_is
*/
typedef enum ir_mode_sort {
- /* Predefined sorts of modes */
irms_auxiliary = 0, /**< Only for Firm use. Not extensible. (irm_T) */
irms_control_flow = 1, /**< Marks all control flow modes. Not extensible. (irm_BB, irm_X) */
irms_memory = 2 | irmsh_is_dataM, /**< Marks the memory mode. Not extensible. (irm_M) */
Storing to memory impossible, convert first. (irm_b) */
irms_internal_boolean = 3 | irmsh_is_datab,
- /* user-extensible sorts of modes */
/** A mode to represent entities.
Restricted int computations can be performed */
irms_reference = 4 | irmsh_is_data | irmsh_is_datab | irmsh_is_dataM,
irms_float_number = 6 | irmsh_is_data | irmsh_is_datab | irmsh_is_dataM | irmsh_is_num,
} ir_mode_sort;
-/** These values represent the different arithmetic operations possible with a mode.
- Further arithmetics can be defined, e.g., for @@@ modes.
+/**
+ * These values represent the different arithmetic operations possible with a
+ * mode.
*/
typedef enum ir_mode_arithmetic {
irma_uninitialized = 0,
- irma_none = 1, /**< For modes for which no representation is specified.
- These are modes of sort auxiliary, internal_boolean and character. */
- irma_twos_complement = 2, /**< Values of the mode are represented as two's complement.
- Only legal for modes of sort int_number and reference. */
- irma_ones_complement, /**< Values of the mode are represented as one's complement.
- Only legal for modes of sort int_number and reference. */
- irma_int_BCD, /**< Values of the mode are represented as binary coded decimals.
- Only legal for modes of sort int_number and reference. */
- irma_ieee754 = 256, /**< Values of the mode are represented according to ieee754
- floating point standard. Only legal for modes of sort float_number. */
- irma_float_BCD, /**< Values of the mode are represented as binary coded decimals
- according to @@@ which standards??? Only legal for modes of
- sort float_number. */
+ irma_none = 1, /**< For modes for which no representation is
+ specified. These are modes of sort auxiliary,
+ internal_boolean and character. */
+ irma_twos_complement = 2, /**< Values of the mode are represented as two's
+ complement. Only legal for modes of sort
+ int_number and reference. */
+ irma_ones_complement, /**< Values of the mode are represented as one's
+ complement. Only legal for modes of sort
+ int_number and reference. */
+ irma_int_BCD, /**< Values of the mode are represented as binary
+ coded decimals. Only legal for modes of sort
+ int_number and reference. */
+ irma_ieee754 = 256, /**< Values of the mode are represented according
+ to ieee754 floating point standard. Only
+ legal for modes of sort float_number. */
+ irma_float_BCD, /**< Values of the mode are represented as binary
+ coded decimals according to @@@ which
+ standards??? Only legal for modes of sort
+ float_number. */
irma_max
} ir_mode_arithmetic;
/** Returns the name of the arithmetic type. */
FIRM_API const char *get_mode_arithmetic_name(ir_mode_arithmetic ari);
-/* ********** Constructor for user defined modes **************** */
/**
* Creates a new mode.
*
*
* @note
* It is allowed to construct the default modes. So, a call
- * new_ir_mode("Is", irms_int_number, 32, 1, irma_twos_complement, 32) will return mode_Is.
+ * new_ir_mode("Is", irms_int_number, 32, 1, irma_twos_complement, 32) will
+ * return mode_Is.
*/
FIRM_API ir_mode *new_ir_mode(const char *name, ir_mode_sort sort, int bit_size,
int sign, ir_mode_arithmetic arithmetic,
*/
FIRM_API int is_mode(const void *thing);
-/* ********** Access methods to read mode information *********** */
-
/** Returns the ident* of the mode */
FIRM_API ident *get_mode_ident(const ir_mode *mode);
FIRM_API ir_mode *mode_M; /**< memory */
-/* -- A set of predefined, numerical modes */
FIRM_API ir_mode *mode_F; /**< float (32) */
FIRM_API ir_mode *mode_D; /**< double (64) */
FIRM_API ir_mode *mode_E; /**< long double (80/128/...) */
represents the pointer size of the target machine data addresses. Is initialized
to mode_P. */
-/* -- Auxiliary modes necessary for the Firm representation -- */
FIRM_API ir_mode *mode_b; /**< internal boolean */
FIRM_API ir_mode *mode_X; /**< execution */
FIRM_API ir_mode *mode_ANY;/**< undefined mode */
FIRM_API ir_mode *mode_BAD;/**< bad mode */
-/*@{*/
FIRM_API ir_mode *get_modeF(void);
FIRM_API ir_mode *get_modeD(void);
FIRM_API ir_mode *get_modeE(void);
*/
FIRM_API void set_modeP_data(ir_mode *p);
-/*@{*/
-/**
+/*@{
Functions to check, whether a mode is signed, float, int, character,
reference, num, data, datab or dataM.
Vector "int" and "float" are defined by the arithmetic and vector_elem > 1.
*/
-/* Test for a certain class of modes. */
+
FIRM_API int mode_is_signed (const ir_mode *mode);
FIRM_API int mode_is_float (const ir_mode *mode);
FIRM_API int mode_is_int (const ir_mode *mode);
*/
/**
- * Checks whether a pointer points to a ir node.
+ * Checks whether a pointer points to a ir node. This is guessed by looking
+ * at the few bytes of the thing. Most things used in firm have a firm_kind
+ * attribute there. This function might falsely return true though for things
+ * without a firm_kind at the beginning.
*
- * @param thing an arbitrary pointer
- * @return non-zero if the thing is a ir mode, else zero
+ * @param thing an arbitrary pointer
+ * @return non-zero if the thing is a ir mode, else zero
*/
-FIRM_API int is_ir_node (const void *thing);
+FIRM_API int is_ir_node(const void *thing);
/**
* Returns the number of predecessors without the block predecessor.
*
* @param node the IR-node
*/
-FIRM_API int get_irn_arity (const ir_node *node);
-
-/** 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.
- Assumes that current_ir_graph is set to the graph containing "node".
- "in" must contain all predecessors except the block that are required for
- the nodes opcode. */
-FIRM_API void set_irn_in(ir_node *node, int arity, ir_node *in[]);
-
-/* to iterate through the predecessors without touching the array. No
- order of predecessors guaranteed.
- To iterate over the operands iterate from 0 to i < get_irn_arity(),
- to iterate including the Block predecessor iterate from i = -1 to
- i < get_irn_arity. */
-/* Access predecessor n */
+FIRM_API int get_irn_arity(const ir_node *node);
/**
* Get the n-th predecessor of a node.
*/
FIRM_API ir_node *get_irn_n(const ir_node *node, int n);
+/**
+ * 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.
+ * Assumes that current_ir_graph is set to the graph containing "node".
+ * "in" must contain all predecessors except the block that are required for
+ * the nodes opcode. */
+FIRM_API void set_irn_in(ir_node *node, int arity, ir_node *in[]);
+
/**
* Add a artificial dependency to the node.
* The dependency is only inserted if it is not there already.
* @returns the number of the new input
*/
FIRM_API int add_irn_n(ir_node *node, ir_node *in);
-/* Remove predecessor i from Sync n */
+/** Remove predecessor i from Sync n */
FIRM_API void del_Sync_n(ir_node *n, int i);
-/* Sets the mode struct of node. */
+/** Sets the mode struct of node. */
FIRM_API void set_irn_mode(ir_node *node, ir_mode *mode);
/** Gets the mode struct of a node. */
FIRM_API ir_mode *get_irn_mode(const ir_node *node);
* To express the difference to access routines that work for all
* nodes we use infix "nodes" and do not name this function
* get_irn_block(). */
-FIRM_API ir_node *get_nodes_block (const ir_node *node);
+FIRM_API ir_node *get_nodes_block(const ir_node *node);
/** Sets the Block of a node. */
-FIRM_API void set_nodes_block (ir_node *node, ir_node *block);
+FIRM_API void set_nodes_block(ir_node *node, ir_node *block);
/** Test whether arbitrary node is frame pointer.
*
/** A visited flag only for block nodes.
* @see also: get_irn_visited() inc_irg_visited() inc_irg_block_visited()*/
FIRM_API ir_visited_t get_Block_block_visited(const ir_node *block);
+/** set block visited flag */
FIRM_API void set_Block_block_visited(ir_node *block, ir_visited_t visit);
-/* For this current_ir_graph must be set. */
+/** mark a block as visited by setting its visited counter */
FIRM_API void mark_Block_block_visited(ir_node *node);
+/** returns 1 if a block is marked as visited */
FIRM_API int Block_block_visited(const ir_node *node);
/** Returns the extended basic block a block belongs to. */
/** Remove irn from the keep-alive set. */
FIRM_API void remove_End_keepalive(ir_node *end, ir_node *irn);
-/* Remove Bads, NoMem and doublets from the keep-alive set. */
+/** Remove Bads, NoMem and doublets from the keep-alive set. */
FIRM_API void remove_End_Bads_and_doublets(ir_node *end);
/** Some parts of the End node are allocated separately -- their memory
FIRM_API ir_enum_const *get_SymConst_enum(const ir_node *node);
FIRM_API void set_SymConst_enum(ir_node *node, ir_enum_const *ec);
-/** Sets both: type and ptrinfo. Needed to treat the node independent of
- its semantics. Does a memcpy for the memory sym points to. */
-/* write 'union': firmjni then does not create a method... */
FIRM_API union symconst_symbol get_SymConst_symbol(const ir_node *node);
FIRM_API void set_SymConst_symbol(ir_node *node,
union symconst_symbol sym);
/** Returns a human readable string for the ir_builtin_kind. */
FIRM_API const char *get_builtin_kind_name(ir_builtin_kind kind);
-/* For unary and binary arithmetic operations the access to the
- operands can be factored out. Left is the first, right the
- second arithmetic value as listed in tech report 1999-44.
- unops are: Minus, Abs, Not, Conv, Cast
- binops are: Add, Sub, Mul, Div, Mod, And, Or, Eor, Shl,
- Shr, Shrs, Rotl, Cmp */
FIRM_API int is_unop(const ir_node *node);
FIRM_API ir_node *get_unop_op(const ir_node *node);
FIRM_API void set_unop_op(ir_node *node, ir_node *op);
/** Return the number of clobbered registers for an ASM node. */
FIRM_API int get_ASM_n_clobbers(const ir_node *node);
-/*
- *
- * NAME Auxiliary routines
- *
- */
-
/** Returns operand of node if node is a Proj. */
FIRM_API ir_node *skip_Proj(ir_node *node);
/** Returns operand of node if node is a Proj. */
FIRM_API const ir_node *skip_Proj_const(const ir_node *node);
/** Returns operand of node if node is a Id. */
-FIRM_API ir_node *skip_Id(ir_node *node); /* Old name is skip_nop(). */
-/** Returns corresponding operand of Tuple if node is a Proj from
- a Tuple. */
+FIRM_API ir_node *skip_Id(ir_node *node);
+/** Returns corresponding operand of Tuple if node is a Proj from a Tuple. */
FIRM_API ir_node *skip_Tuple(ir_node *node);
/** Returns operand of node if node is a Cast. */
FIRM_API ir_node *skip_Cast(ir_node *node);
FIRM_API ir_node *skip_Confirm(ir_node *node);
/** Skip all high-level Operations (including Cast, Confirm). */
FIRM_API ir_node *skip_HighLevel_ops(ir_node *node);
-/** Returns true if the operation manipulates control flow:
- Start, End, Jmp, Cond, Return, Raise, Bad */
+/** Returns true if the operation manipulates control flow */
FIRM_API int is_cfop(const ir_node *node);
/** returns true if the operation jumps to an unknown destination.
* See irop_flag_unknown_jump for a detailed explanation */
FIRM_API int is_unknown_jump(const ir_node *node);
-/** 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. */
+/**
+ * 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.
+ */
FIRM_API int is_fragile_op(const ir_node *node);
/** Returns the memory operand of fragile operations. */
FIRM_API ir_node *get_fragile_op_mem(ir_node *node);
FIRM_API void copy_node_attr(ir_graph *irg, const ir_node *old_node, ir_node *new_node);
/** Return the type attribute of a node n (SymConst, Call, Alloc, Free,
- Cast) or NULL.*/
+ * Cast) or NULL.*/
FIRM_API ir_type *get_irn_type_attr(ir_node *n);
/** Return the entity attribute of a node n (SymConst, Sel) or NULL. */
/** Checks whether a node represents a global address. */
FIRM_API int is_Global(const ir_node *node);
-/* Returns the entity of a global address. */
+/** Returns the entity of a global address. */
FIRM_API ir_entity *get_Global_entity(const ir_node *node);
/**
*/
FIRM_API const char *gdb_node_helper(void *firm_object);
-/*@}*/ /* end of ir_node group definition */
+/*@}*/
#include "end.h"
* Creates an ir_prog pass for optimize_funccalls().
*
* @param name the name of this pass or NULL
- * @param force_run if non-zero, an optimization run is started even
- * if no const function graph was detected.
- * Else calls are only optimized if at least one
- * const function graph was detected.
- * @param callback a callback function to check whether a
- * given entity is a allocation call
- *
* @return the newly created ir_prog pass
*/
FIRM_API ir_prog_pass_t *optimize_funccalls_pass(const char *name);
#include "firm_types.h"
#include "begin.h"
-/*------------------------------------------------------------------*/
-/* Accessing the out datastructures. */
-/* These routines only work properly if the ir_graph is in state */
-/* outs_consistent or outs_inconsistent. */
-/*------------------------------------------------------------------*/
-
-/** To iterate through the successors iterate from 0 to i < get_irn_outs(). No
- order of successors guaranteed. Will return edges from block to floating
- nodes even if irgraph is in state "op_pin_state_floats". */
-/* returns the number of successors of the node: */
+/** returns the number of successors of the node: */
FIRM_API int get_irn_n_outs(const ir_node *node);
/** Get the User of a node from the Def-Use edge at position pos. */
*/
FIRM_API void set_irn_out(ir_node *def, int pos, ir_node *use, int in_pos);
-/* Methods to iterate through the control flow graph. Iterate from 0 to
- i < get_Block_cfg_outs(block). No order of successors guaranteed. */
-
/** Return the number of control flow successors, ignore keep-alives. */
FIRM_API int get_Block_n_cfg_outs(const ir_node *node);
/** Access predecessor n, honor keep-alives. */
FIRM_API ir_node *get_Block_cfg_out_ka(const ir_node *node, int pos);
-/** Walks over the graph starting at node. Walks also if graph is in state
- "outs_inconsistent". Assumes current_ir_graph is set properly. */
+/**
+ * Walks over the graph starting at node. Walks also if graph is in state
+ * "outs_inconsistent". Assumes current_ir_graph is set properly.
+ */
FIRM_API void irg_out_walk(ir_node *node, irg_walk_func *pre,
irg_walk_func *post, void *env);
-/** Walks only over Block nodes in the graph. Has its own visited
- flag, so that it can be interleaved with the other walker.
- node must be either op_Block or mode_X. */
+/**
+ * Walks only over Block nodes in the graph. Has its own visited
+ * flag, so that it can be interleaved with the other walker.
+ * node must be either op_Block or mode_X.
+ */
FIRM_API void irg_out_block_walk(ir_node *node, irg_walk_func *pre,
irg_walk_func *post, void *env);
/**
* returns 1 if outs have been computed for a node, 0 otherwise.
*
- * this is useful to detect newly created nodes that have no outs set yet
+ * this is useful to detect newly created nodes that have no outs set yet
*/
FIRM_API int get_irn_outs_computed(const ir_node *node);
-/*------------------------------------------------------------------*/
-/* Building and Removing the out datastructure */
-/*------------------------------------------------------------------*/
-
-/** Computes the out edges. Sets a flag in irg to "outs_consistent". If the
- graph is changed this flag must be set to "outs_inconsistent". Computes
- out edges from block to floating nodes even if graph is in state
- "op_pin_state_floats". Optimizes Tuple nodes. */
+/**
+ * Computes the out edges. Sets a flag in irg to "outs_consistent". If the
+ * graph is changed this flag must be set to "outs_inconsistent". Computes
+ * out edges from block to floating nodes even if graph is in state
+ * "op_pin_state_floats". Optimizes Tuple nodes.
+ */
FIRM_API void compute_irg_outs(ir_graph *irg);
FIRM_API void compute_irp_outs(void);
#include "begin.h"
-/*-----------------------------------------------------------------*/
-/* Accessing the trout datastructures. */
-/* These routines only work properly if firm is in state */
-/* trouts_consistent or trouts_inconsistent. */
-/*-----------------------------------------------------------------*/
-
-/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-/* entities */
-/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-
/** Number of Load/Store nodes that possibly access this entity. */
FIRM_API size_t get_entity_n_accesses(const ir_entity *ent);
/** Load/Store node that possibly access this entity. */
* Including references from constants. */
FIRM_API ir_node *get_entity_reference(const ir_entity *ent, size_t pos);
-/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-/* types */
-/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-
/** Number of Alloc nodes that create an instance of this type. */
FIRM_API size_t get_type_n_allocs(const ir_type *tp);
/** Alloc node that create an instance of this type. */
/** Return number of downcasts. O(\#casts). */
FIRM_API size_t get_class_n_downcasts(const ir_type *clss);
-/* Access all pointer types that point to tp. */
FIRM_API size_t get_type_n_pointertypes_to(const ir_type *tp);
FIRM_API ir_type *get_type_pointertype_to(const ir_type *tp, size_t pos);
FIRM_API void add_type_pointertype_to(const ir_type *tp, ir_type *ptp);
-/* Access all array types that contain elements of type tp.
- * Does not find subarrays, e.g., int[] being element of int[][]
- * for multi dimensional arrays. */
FIRM_API size_t get_type_n_arraytypes_of(const ir_type *tp);
FIRM_API ir_type *get_type_arraytype_of(const ir_type *tp, size_t pos);
FIRM_API void add_type_arraytype_of(const ir_type *tp, ir_type *atp);
-/*------------------------------------------------------------------*/
-/* Building and Removing the trout datastructure */
-/*------------------------------------------------------------------*/
-
/** Compute the outs of types and entities.
*
* Collects all reference from irnodes to types or entities in the
#include "begin.h"
-/* ************************ Constructors for tarvals ************************ */
-
/**
* Constructor function for new tarvals.
*
*/
FIRM_API int tarval_is_double(ir_tarval *tv);
-
-/** ********** Access routines for tarval fields ********** **/
-
-/*
- * NAME
- * get_tarval_mode
- * get_tarval_ ...
- *
- * SYNOPSIS
- * ir_mode *get_tarval_mode(tarval *tv)
- * ...
- *
- * DESCRIPTION
- * These are access function for tarval struct members. It is encouraged
- * to use them instead of direct access to the struct fields.
- *
- * PARAMETERS
- * tv - The tarval to access fields of
- *
- * RESULT
- * get_tv_mode: The mode of the tarval
- *
- * SEE ALSO
- * the struct tarval
- */
-
/**
* Returns the mode of the tarval.
*
/** Returns the 'bottom' tarval. */
#define get_tarval_bottom() get_tarval_bad()
-/* These functions calculate and return a tarval representing the requested
- * value.
- * The functions get_mode_{Max,Min,...} return tarvals retrieved from these
- * functions, but these are stored on initialization of the irmode module and
- * therefore the irmode functions should be preferred to the functions below. */
-
/** Returns the maximum value of a given mode. */
FIRM_API ir_tarval *get_tarval_max(ir_mode *mode);
/** Return -inf for float_number modes. */
FIRM_API ir_tarval *get_tarval_minus_inf(ir_mode *mode);
-/* ******************** Arithmetic operations on tarvals ******************** */
-
typedef enum tarval_int_overflow_mode_t {
TV_OVERFLOW_BAD, /**< tarval module will return tarval_bad if a overflow occurs */
TV_OVERFLOW_WRAP, /**< tarval module will overflow will be ignored, wrap around occurs */
*/
FIRM_API int tarval_carry(void);
-/* *********** Output of tarvals *********** */
-
/**
* The output mode for tarval values.
*
* However, we can do this in the tarval much simpler...
*/
typedef enum {
- TVO_NATIVE, /**< the default output mode, depends on the mode */
- TVO_HEX, /**< use hex representation, always possible */
- TVO_DECIMAL, /**< use decimal representation */
- TVO_OCTAL, /**< use octal representation */
- TVO_BINARY, /**< use binary representation */
- TVO_FLOAT, /**< use floating point representation (i.e 1.342e-2)*/
- TVO_HEXFLOAT /**< use hexadecimal floating point representation (i.e 0x1.ea32p-12)*/
+ TVO_NATIVE, /**< the default output mode, depends on the mode */
+ TVO_HEX, /**< use hex representation, always possible */
+ TVO_DECIMAL, /**< use decimal representation */
+ TVO_OCTAL, /**< use octal representation */
+ TVO_BINARY, /**< use binary representation */
+ TVO_FLOAT, /**< use floating point representation (i.e 1.342e-2)*/
+ TVO_HEXFLOAT /**< use hexadecimal floating point representation
+ (i.e 0x1.ea32p-12)*/
} tv_output_mode;
/**
* val2 = tarval_sub_bits(tv, 2);
* val3 = tarval_sub_bits(tv, 3); <- highest bits
*
- * Because this is the bit representation of the target machine, only the following
- * operations are legal on the result:
+ * Because this is the bit representation of the target machine, only the
+ * following operations are legal on the result:
*
* - concatenation (endian dependence MUST be handled by the CALLER)
* - bitwise logical operations to select/mask bits
* @param byte_ofs the byte offset from lower to higher
*
* @note
- * The result of this function is undefined if the mode is neither integer nor float.
+ * The result of this function is undefined if the mode is neither integer
+ * nor float.
*/
FIRM_API unsigned char get_tarval_sub_bits(ir_tarval *tv, unsigned byte_ofs);
*
* These fields can only be accessed via access functions.
*
+ * Overwrites is a field that specifies that an access to the overwritten
+ * entity in the supertype must use this entity. It's a list as with
+ * multiple inheritance several entities can be overwritten. This field
+ * is mostly useful for method entities.
+ * If a Sel node selects an entity that is overwritten by other entities it
+ * must return a pointer to the entity of the dynamic type of the pointer
+ * that is passed to it. Lowering of the Sel node must assure this.
+ * Overwrittenby is the inverse of overwrites. Both add routines add
+ * both relations, they only differ in the order of arguments.
+ *
* @see ir_type, ir_entity
*/
/** Stores new intermediate information. */
FIRM_API void set_entity_link(ir_entity *ent, void *l);
-/* -- Fields of method entities -- */
-/** The entity knows the corresponding irg if the entity is a method.
- This allows to get from a Call to the called irg. */
+/**
+ * The entity knows the corresponding irg if the entity is a method.
+ * This allows to get from a Call to the called irg.
+ */
FIRM_API ir_graph *get_entity_irg(const ir_entity *ent);
FIRM_API void set_entity_irg(ir_entity *ent, ir_graph *irg);
*/
FIRM_API void set_entity_parameter_number(ir_entity *entity, size_t n);
-/* -- Representation of constant values of entities -- */
/**
* Returns true if the the node is representable as code on
* const_code_irg.
*/
FIRM_API ir_node *copy_const_value(dbg_info *dbg, ir_node *n, ir_node *to_block);
-/* Set has no effect for existent entities of type method. */
FIRM_API ir_node *get_atomic_ent_value(ir_entity *ent);
FIRM_API void set_atomic_ent_value(ir_entity *ent, ir_node *val);
/** Return the new style initializers of an entity. */
FIRM_API ir_initializer_t *get_entity_initializer(const ir_entity *entity);
-/* --- Fields of entities with a class type as owner --- */
-/* Overwrites is a field that specifies that an access to the overwritten
- entity in the supertype must use this entity. It's a list as with
- multiple inheritance several entities can be overwritten. This field
- is mostly useful for method entities.
- If a Sel node selects an entity that is overwritten by other entities it
- must return a pointer to the entity of the dynamic type of the pointer
- that is passed to it. Lowering of the Sel node must assure this.
- Overwrittenby is the inverse of overwrites. Both add routines add
- both relations, they only differ in the order of arguments. */
FIRM_API void add_entity_overwrites(ir_entity *ent, ir_entity *overwritten);
FIRM_API size_t get_entity_n_overwrites(const ir_entity *ent);
FIRM_API size_t get_entity_overwrites_index(const ir_entity *ent, ir_entity *overwritten);
FIRM_API const tp_op *tpop_unknown;
FIRM_API const tp_op *get_tpop_unknown(void);
-/* ----------------------------------------------------------------------- */
-/* Classify pairs of types/entities in the inheritance relations. */
-/* ----------------------------------------------------------------------- */
-
/** Returns true if low is subclass of high.
*
* Low is a subclass of high if low == high or if low is a subclass of
FIRM_API ir_entity *resolve_ent_polymorphy(ir_type *dynamic_class,
ir_entity* static_ent);
-/* ----------------------------------------------------------------------- */
-/* Resolve implicit inheritance. */
-/* ----------------------------------------------------------------------- */
-
/** Default name mangling for inherited entities.
*
* Returns an ident that consists of the name of type followed by an
/** Free memory occupied by the transitive closure information. */
FIRM_API void free_inh_transitive_closure(void);
-
-/* - subtype ------------------------------------------------------------- */
-
/** Iterate over all transitive subtypes. */
FIRM_API ir_type *get_class_trans_subtype_first(const ir_type *tp);
FIRM_API ir_type *get_class_trans_subtype_next(const ir_type *tp);
FIRM_API int is_class_trans_subtype(const ir_type *tp, const ir_type *subtp);
-/* - supertype ----------------------------------------------------------- */
-
/** Iterate over all transitive supertypes. */
FIRM_API ir_type *get_class_trans_supertype_first(const ir_type *tp);
FIRM_API ir_type *get_class_trans_supertype_next(const ir_type *tp);
-/* - overwrittenby ------------------------------------------------------- */
-
/** Iterate over all entities that transitive overwrite this entities. */
FIRM_API ir_entity *get_entity_trans_overwrittenby_first(const ir_entity *ent);
FIRM_API ir_entity *get_entity_trans_overwrittenby_next(const ir_entity *ent);
-/* - overwrites ---------------------------------------------------------- */
-
/** Iterate over all transitive overwritten entities. */
FIRM_API ir_entity *get_entity_trans_overwrites_first(const ir_entity *ent);
FIRM_API ir_entity *get_entity_trans_overwrites_next(const ir_entity *ent);
-/* ----------------------------------------------------------------------- */
/** The state of Cast operations that cast class types or pointers to class
* types.
*
* relation. Example: (A)(new C()).
* any: Cast operations do not conform with the transitive inheritance
* relation. Example: (B2)(new B1())
- */
-/* ----------------------------------------------------------------------- */
-
-/** Flags for class cast state.
+ *
+ * Flags for class cast state.
*
* The state in irp is always smaller or equal to the state of any
* irg.
/** Creates a new class type with debug information. */
FIRM_API ir_type *new_d_type_class(ident *name, type_dbg_info *db);
-/* --- manipulate private fields of class type --- */
-
/** return identifier of the class type */
FIRM_API ident *get_class_ident(const ir_type *clss);
/** Finds subtype in the list of subtypes and removes it */
FIRM_API void remove_class_subtype(ir_type *clss, ir_type *subtype);
-/* Convenience macros */
#define add_class_derived_type(clss, drvtype) add_class_subtype(clss, drvtype)
#define get_class_n_derived_types(clss) get_class_n_subtypes(clss)
#define get_class_derived_type(clss, pos) get_class_subtype(clss, pos)
/** Creates a new type struct with debug information. */
FIRM_API ir_type *new_d_type_struct(ident *name, type_dbg_info* db);
-/* --- manipulate private fields of struct --- */
-
/** return struct identifier */
FIRM_API ident *get_struct_ident(const ir_type *strct);
* Return nodes. (See ircons.h for more information.)
*/
-/* These macros define the suffixes for the types and entities used
- to represent value parameters / results. */
-#define VALUE_PARAMS_SUFFIX "val_param"
-#define VALUE_RESS_SUFFIX "val_res"
-
/** Create a new method type.
*
* @param n_param the number of parameters
FIRM_API ir_type *new_d_type_method(size_t n_param, size_t n_res,
type_dbg_info *db);
-/* -- manipulate private fields of method. -- */
-
/** Returns the number of parameters of this method. */
FIRM_API size_t get_method_n_params(const ir_type *method);
cc_bits = (0xFF << 24)/**< The calling convention bits. */
} calling_convention;
-/* some often used cases: made as defines because firmjni cannot handle two
- equal enum values. */
-
/** cdecl calling convention */
#define cc_cdecl_set (0)
/** stdcall calling convention */
/** Creates a new type union with debug information. */
FIRM_API ir_type *new_d_type_union(ident *name, type_dbg_info* db);
-/* --- manipulate private fields of struct --- */
/** return union identifier */
FIRM_API ident *get_union_ident(const ir_type *uni);
FIRM_API ir_type *new_d_type_array(size_t n_dims, ir_type *element_type,
type_dbg_info* db);
-/* --- manipulate private fields of array type --- */
/** Returns the number of array dimensions of this type. */
FIRM_API size_t get_array_n_dimensions(const ir_type *array);
FIRM_API ir_type *new_d_type_enumeration(ident *name, size_t n_enums,
type_dbg_info *db);
-/* --- manipulate fields of enumeration type. --- */
/** return enumeration identifier */
FIRM_API ident *get_enumeration_ident(const ir_type *enumeration);
/** Creates a new type pointer with debug information. */
FIRM_API ir_type *new_d_type_pointer(ir_type *points_to, type_dbg_info* db);
-/* --- manipulate fields of type_pointer --- */
/** Sets the type to which a pointer points to. */
FIRM_API void set_pointer_points_to_type(ir_type *pointer, ir_type *tp);
*/
FIRM_API int is_atomic_type(const ir_type *tp);
-/* --- Support for compound types --- */
/**
* Gets the identifier of a compound type
FIRM_API ir_entity *frame_alloc_area(ir_type *frame_type, int size,
unsigned alignment, int at_start);
-/*-----------------------------------------------------------------*/
-/** Debug aides **/
-/*-----------------------------------------------------------------*/
-
/**
* Outputs a unique number for this type if libfirm is compiled for
* debugging, (configure with --enable-debug) else returns the address
*/
FIRM_API long get_type_nr(const ir_type *tp);
-/* ------------------------------------------------------------------------ */
-
/** Type for a function that compares two types.
*
* @param tp1 The first type to compare.
*/
typedef int (compare_types_func_t)(const void *tp1, const void *tp2);
-/* ------------------------------------------------------------------------ */
-
/** A data type to treat types and entities as the same. */
typedef union {
ir_type *typ; /**< points to a type */