plugin_subdirs := @plugin_subdirs@
build_subdirs := ir/adt ir/net ir/debug ir/tv ir/common ir/ident ir/ir \
- ir/opt ir/tr ir/ana ir/stat ir/ana2 ir/arch ir/lower \
+ ir/opt ir/tr ir/ana ir/stat ir/arch ir/lower include/libfirm \
$(plugin_subdirs)
ifeq ($(enable_external_effects),yes)
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Definition of opaque firm types
+ * @author Michael Beck
+ * @version $Id$
+ */
+#ifndef FIRM_COMMON_FIRM_TYPES_H
+#define FIRM_COMMON_FIRM_TYPES_H
+
+#ifdef _MSC_VER
+typedef __int64 long64;
+typedef unsigned __int64 ulong64;
+
+#define LL_FMT "i64"
+#define ULL_FMT "ui64"
+
+#else
+typedef long long long64;
+typedef unsigned long long ulong64;
+
+#define LL_FMT "ll"
+#define ULL_FMT "llu"
+
+#endif /* _MSC_VER */
+
+#ifndef _IDENT_TYPEDEF_
+#define _IDENT_TYPEDEF_
+typedef const struct _ident ident, *ir_ident_ptr;
+#endif
+
+#ifndef _IR_NODE_TYPEDEF_
+#define _IR_NODE_TYPEDEF_
+typedef struct ir_node ir_node, *ir_node_ptr;
+#endif
+
+#ifndef _IR_OP_TYPEDEF_
+#define _IR_OP_TYPEDEF_
+typedef struct ir_op ir_op, *ir_op_ptr;
+#endif
+
+#ifndef _IR_MODE_TYPEDEF_
+#define _IR_MODE_TYPEDEF_
+typedef struct ir_mode ir_mode, *ir_mode_ptr;
+#endif
+
+#ifndef _IR_EDGE_TYPEDEF_
+#define _IR_EDGE_TYPEDEF_
+typedef struct _ir_edge_t ir_edge_t, *ir_edge_ptr;
+#endif
+
+#ifndef _TARVAL_TYPEDEF_
+#define _TARVAL_TYPEDEF_
+typedef struct tarval tarval, *ir_tarval_ptr;
+#endif
+
+#ifndef _IR_ENUM_CONST_TYPEDEF_
+#define _IR_ENUM_CONST_TYPEDEF_
+typedef struct ir_enum_const ir_enum_const, *ir_enum_const_ptr;
+#endif
+
+#ifndef _IR_TYPE_TYPEDEF_
+#define _IR_TYPE_TYPEDEF_
+typedef struct ir_type ir_type, *ir_type_ptr;
+#endif
+
+#ifndef _IR_GRAPH_TYPEDEF_
+#define _IR_GRAPH_TYPEDEF_
+typedef struct ir_graph ir_graph, *ir_graph_ptr;
+#endif
+
+#ifndef _IR_LOOP_TYPEDEF_
+#define _IR_LOOP_TYPEDEF_
+typedef struct ir_loop ir_loop, *ir_loop_ptr;
+#endif
+
+#ifndef _IR_REGION_TYPEDEF_
+#define _IR_REGION_TYPEDEF_
+typedef struct ir_region ir_region, *ir_region_ptr;
+#endif
+
+#ifndef _IR_REG_TREE_TYPEDEF_
+#define _IR_REG_TREE_TYPEDEF_
+typedef struct ir_reg_tree ir_reg_tree, *ir_reg_tree_ptr;
+#endif
+
+#ifndef _ENTITY_TYPEDEF_
+#define _ENTITY_TYPEDEF_
+typedef struct ir_entity ir_entity, *ir_entity_ptr;
+#endif
+
+#ifndef _COMPOUND_GRAPH_PATH_TYPEDEF_
+#define _COMPOUND_GRAPH_PATH_TYPEDEF_
+typedef struct compound_graph_path compound_graph_path, *ir_compound_graph_path_ptr;
+#endif
+
+#ifndef _IR_PHASE_TYPEDEF_
+#define _IR_PHASE_TYPEDEF_
+typedef struct _ir_phase ir_phase, *ir_phase_ptr;
+#endif
+
+#ifndef _IR_EXTBB_TYPEDEF_
+#define _IR_EXTBB_TYPEDEF_
+typedef struct _ir_extblk ir_extblk, *ir_extblk_ptr;
+#endif
+
+#ifndef _IRG_WALK_FUNC_TYPEDEF_
+#define _IRG_WALK_FUNC_TYPEDEF_
+typedef void irg_walk_func(ir_node *, void *);
+#endif
+
+#ifndef _IRG_REG_WALK_FUNC_TYPEDEF_
+#define _IRG_REG_WALK_FUNC_TYPEDEF_
+typedef void irg_reg_walk_func(ir_region *, void *);
+#endif
+
+#ifndef _SEQNO_T_TYPEDEF_
+#define _SEQNO_T_TYPEDEF_
+typedef struct sn_entry *seqno_t;
+#endif
+
+#ifndef _EXECFREQ_TYPEDEF
+#define _EXECFREQ_TYPEDEF
+typedef struct ir_exec_freq ir_exec_freq, *ir_exec_freq_ptr;
+#endif
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file absgraph.h
+ * @author Sebastian Hack
+ * @date 20.04.2007
+ * @version $Id$
+ * @summary
+ *
+ * An abstract graph "interface". Currently
+ * only used by the DFS facility.
+ *
+ * This is just that we can do some graph algos
+ * on the CFG, dominance tree, etc.
+ */
+#ifndef FIRM_ANA_ABSGRAPH_H
+#define FIRM_ANA_ABSGRAPH_H
+
+#include "obst.h"
+
+typedef struct _absgraph_t {
+ void *(*get_root)(void *self);
+ void (*grow_succs)(void *self, void *node, struct obstack *obst);
+} absgraph_t;
+
+extern const absgraph_t absgraph_irg_cfg_succ;
+extern const absgraph_t absgraph_irg_cfg_pred;
+
+#endif /* FIRM_ANA_ABSGRAPH_H */
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief read/write analyze of graph argument, which have mode reference
+ * @author Beyhan Veliev
+ * @version $Id$
+ */
+#ifndef FIRM_ANA_ANALYZE_IRG_ARGS_H
+#define FIRM_ANA_ANALYZE_IRG_ARGS_H
+
+#include "irgraph.h"
+#include "firm_types.h"
+
+/**
+ * Returns for a method with pointer parameter
+ * if they will be read or written.
+ *
+ * @param ent The entity that represent this method.
+ * @param pos The position of method's parameter for that
+ * we need information.
+
+ * If the pos'th parameter is NOT of a pointer type, ptr_access_none
+ * is returned;
+ */
+ptr_access_kind get_method_param_access(ir_entity *ent, int pos);
+
+/**
+ * Analyze how pointer arguments of a given
+ * ir graph are accessed.
+ *
+ * @param irg The ir graph to analyze.
+ */
+void analyze_irg_args(ir_graph *irg);
+
+/**
+ * Returns for a method the 'weight' that every parameter
+ * has on optimization possibility. Higher values allows
+ * higher optimization with procedure cloning.
+ *
+ * The values are calculation on demand only.
+ */
+float get_method_param_weight(ir_entity *ent, int pos);
+
+/**
+ * Analyze the parameters of a given ir graph.
+ *
+ * @param irg The ir graph to analyze.
+ */
+void analyze_irg_args_weight(ir_graph *irg);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Architecture dependand IR operations
+ * @version $Id$
+ */
+#ifndef FIRM_ARCH_ARCHOP_H
+#define FIRM_ARCH_ARCHOP_H
+
+#include "firm_types.h"
+#include "dbginfo.h"
+
+/**
+ * Mask defining which architecture depend
+ * operations are supported.
+ */
+typedef enum _arch_ops_mask {
+ ARCH_OPS_NONE = 0, /**< no additional Operations */
+ ARCH_OPS_MINMAX = 1 /**< use the Min/Max Operation */
+} arch_ops_mask;
+
+typedef struct _arch_ops_info {
+ arch_ops_mask enabled_ops; /**< a mask of enabled IR-opcodes */
+ unsigned minmax_handle_NaN:1; /**< if set, Min(a,a) == a, else unknown */
+} arch_ops_info;
+
+extern ir_op *op_Min, *op_Max;
+
+ir_op *get_op_Min(void);
+ir_op *get_op_Max(void);
+
+/** construct a Min: Min(a,b) = a < b ? a : b */
+ir_node *
+new_rd_Min(dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** construct a Max: Max(a,b) = a > b ? a : b */
+ir_node *
+new_rd_Max(dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *op1, ir_node *op2, ir_mode *mode);
+
+ir_node *
+new_r_Min(ir_graph *irg, ir_node *block,
+ ir_node *op1, ir_node *op2, ir_mode *mode);
+
+ir_node *
+new_r_Max(ir_graph *irg, ir_node *block,
+ ir_node *op1, ir_node *op2, ir_mode *mode);
+
+ir_node *
+new_Min(ir_node *op1, ir_node *op2, ir_mode *mode);
+
+ir_node *
+new_Max(ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/**
+ * Create Min and Mux from Mux nodes
+ */
+ir_node *arch_transform_node_Mux(ir_node *mux);
+
+/**
+ * initialize the ops.
+ */
+void firm_archops_init(const arch_ops_info *info);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Generic backend types and interfaces.
+ * @author Sebastian Hack
+ * @version $Id$
+ */
+#ifndef FIRM_BE_MAIN_H
+#define FIRM_BE_MAIN_H
+
+#include <stdio.h>
+#include "irarch.h"
+#include "archop.h"
+#include "lower_dw.h"
+#include "dbginfo.h"
+#include "iroptimize.h"
+
+#include <libcore/lc_timing.h>
+
+#define LC_STOP_AND_RESET_TIMER(timer) do { lc_timer_stop(timer); lc_timer_reset(timer); } while(0)
+
+/** For inline assembler: get a register from a name and encode it into a backend specific value. */
+typedef unsigned (get_register_fkt)(const char *reg);
+
+/**
+ * This structure contains parameters that should be
+ * propagated to the libFirm parameter set.
+ */
+typedef struct backend_params {
+ /** if set, the backend cannot handle DWORD access */
+ unsigned do_dw_lowering:1;
+ /** if set, the backend supports inline assembly */
+ unsigned support_inline_asm:1;
+
+ /** Additional opcodes settings. */
+ const arch_ops_info *arch_op_settings;
+
+ /** Settings for architecture dependent optimizations */
+ const arch_dep_params_t *dep_param;
+
+ /** the architecture specific intrinsic function creator */
+ create_intrinsic_fkt *arch_create_intrinsic_fkt;
+
+ /** the context parameter for the create intrinsic function */
+ void *create_intrinsic_ctx;
+
+ /** backend settings for if-conversion */
+ const opt_if_conv_info_t *if_conv_info;
+
+ /** get the backend specific register encoding for a register name */
+ get_register_fkt *get_register_from_name;
+} backend_params;
+
+/**
+ * Register the Firm backend command line options.
+ */
+void be_opt_register(void);
+
+/**
+ * Parse one backend argument.
+ */
+int be_parse_arg(const char *arg);
+
+/**
+ * Initialize the Firm backend. Must be run BEFORE init_firm()!
+ *
+ * @return libFirm configuration parameters for the selected
+ * backend
+ */
+const backend_params *be_init(void);
+
+/**
+ * Main interface to the frontend.
+ */
+void be_main(FILE *file_handle, const char *cup_name);
+
+/** The type of the debug info retriever function. */
+typedef const char *(*retrieve_dbg_func)(const dbg_info *dbg, unsigned *line);
+
+/**
+ * Sets a debug info retriever.
+ *
+ * @param func the debug retriever function.
+ */
+void be_set_debug_retrieve(retrieve_dbg_func func);
+
+/**
+ * Retrieve the debug info.
+ */
+const char *be_retrieve_dbg_info(const dbg_info *dbg, unsigned *line);
+
+typedef struct be_main_env_t be_main_env_t;
+typedef struct be_options_t be_options_t;
+
+#endif /* FIRM_BE_MAIN_H */
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Representation and computation of the callgraph.
+ * @author Goetz Lindenmaier
+ * @date 21.7.2004
+ * @version $Id$
+ * @summary
+ * This file contains the representation of the callgraph.
+ * The nodes of the call graph are ir_graphs. The edges between
+ * the nodes are calling relations. I.e., if method a calls method
+ * b at some point, there is an edge between a and b.
+ *
+ * Further this file contains an algorithm to construct the call
+ * graph. The construction of the callgraph uses the callee
+ * information in Call nodes to determine which methods are called.
+ *
+ * Finally this file contains an algorithm that computes backedges
+ * in the callgraph, i.e., the algorithm finds possibly recursive calls.
+ * The algorithm computes an upper bound of all recursive calls.
+ */
+#ifndef FIRM_ANA_CALLGRAPH_H
+#define FIRM_ANA_CALLGRAPH_H
+
+#include "firm_types.h"
+
+/** Flag to indicate state of callgraph. */
+typedef enum {
+ irp_callgraph_none, /**< No callgraph allocated. */
+ irp_callgraph_consistent, /**< Callgraph constistent but calltree is inconsistent */
+ irp_callgraph_inconsistent, /**< Callgraph is allocated but inconsistent. */
+ irp_callgraph_and_calltree_consistent /**< Both callgraph and calltree are consistent. */
+} irp_callgraph_state;
+
+/** Returns the callgraph state of the program representation. */
+irp_callgraph_state get_irp_callgraph_state(void);
+
+/** Sets the callgraph state of the program representation. */
+void set_irp_callgraph_state(irp_callgraph_state s);
+
+/** Returns the number of procedures that call the given irg. */
+int get_irg_n_callers(ir_graph *irg);
+
+/** Returns the caller at position pos. */
+ir_graph *get_irg_caller(ir_graph *irg, int pos);
+
+/** Returns non-zero if the caller at position pos is "a backedge", i.e. a recursion. */
+int is_irg_caller_backedge(ir_graph *irg, int pos);
+
+/** Returns non-zero if the irg has a backedge caller. */
+int has_irg_caller_backedge(ir_graph *irg);
+
+/** Returns the maximal loop depth of call nodes that call along this edge. */
+int get_irg_caller_loop_depth(ir_graph *irg, int pos);
+
+/** Returns the number of procedures that are called by the given irg. */
+int get_irg_n_callees(ir_graph *irg);
+
+/** Returns the callee at position pos. */
+ir_graph *get_irg_callee(ir_graph *irg, int pos);
+
+/** Returns non-zero if the callee at position pos is "a backedge", i.e. a recursion. */
+int is_irg_callee_backedge(ir_graph *irg, int pos);
+
+/** Returns non-zero if the irg has a backedge callee. */
+int has_irg_callee_backedge(ir_graph *irg);
+
+/** Returns the maximal loop depth of call nodes that call along this edge. */
+int get_irg_callee_loop_depth(ir_graph *irg, int pos);
+
+/** Returns the maximal loop depth of all paths from an external visible method to
+ this irg. */
+int get_irg_loop_depth(ir_graph *irg);
+
+/** Returns the maximal recursion depth of all paths from an external visible method to
+ this irg. */
+int get_irg_recursion_depth(ir_graph *irg);
+
+/** Returns the method execution frequency of a graph. */
+double get_irg_method_execution_frequency(ir_graph *irg);
+
+/**
+ * Construct the callgraph. Expects callee information, i.e.,
+ * irg_callee_info_consistent must be set. This can be computed with
+ * cgana().
+ */
+void compute_callgraph(void);
+
+/** Destruct the callgraph. */
+void free_callgraph(void);
+
+
+/** A function type for functions passed to the callgraph walker. */
+typedef void callgraph_walk_func(ir_graph *g, void *env);
+
+/**
+ * Walks over the callgraph.
+ *
+ * Walks over the callgraph, starting at the irp main graph.
+ * Visits ALL graphs in the irp, even if not reached by the main irg, but for
+ * those the call order is not guaranteed.
+ *
+ * Executes pre before visiting the predecessor of a node, post after.
+ * The void* env can be used to pass status information between the
+ * pre and post functions.
+ *
+ * @param pre - walker function, executed before the predecessor of a node are visited
+ * @param post - walker function, executed after the predecessor of a node are visited
+ * @param env - environment, passed to pre and post
+ */
+void callgraph_walk(callgraph_walk_func *pre, callgraph_walk_func *post, void *env);
+
+/**
+ * Compute the backedges that represent recursions and a looptree.
+ */
+void find_callgraph_recursions(void);
+
+/** Compute interprocedural performance estimates.
+ *
+ * Computes
+ * - the loop depth of the method.
+ * The loop depth of an edge between two methods is the
+ * maximal loop depth of the Call nodes that call along this edge.
+ * The loop depth of the method is the loop depth of the most expensive
+ * path from main().
+ * - The recursion depth. The maximal number of recursions passed
+ * on all paths reaching this method.
+ * - The execution frequency. As loop depth, but the edge weight is the sum
+ * of the execution frequencies of all Calls along the edge.
+ *
+ * Expects the main irg is set, see set_irp_main_irg();
+ **/
+void compute_performance_estimates(void);
+
+/** Computes the interprocedural loop nesting information.
+ *
+ * Computes two numbers for each irg: the depth it is called in 'normal'
+ * loops and the depth of recursions it is in.
+ *
+ * Computes callee info and the callgraph if
+ * this information is not available.
+ *
+ * Expects the main irg is set, see set_irp_main_irg();
+ */
+void analyse_loop_nesting_depth(void);
+
+/** The state of loop nesting depth. */
+typedef enum {
+ loop_nesting_depth_none, /**< Loop nesting depths are not computed, no memory is
+ allocated, access fails. */
+ loop_nesting_depth_consistent, /**< Loop nesting depth information is computed and correct. */
+ loop_nesting_depth_inconsistent /**< Loop nesting depth is computed but the graphs have been
+ changed since. */
+} loop_nesting_depth_state;
+
+/** Returns the nesting depth state of the program representation. */
+loop_nesting_depth_state get_irp_loop_nesting_depth_state(void);
+
+/** Sets the nesting depth state of the program representation. */
+void set_irp_loop_nesting_depth_state(loop_nesting_depth_state s);
+
+/** Marks the nesting depth state of the program representation as inconsistent. */
+void set_irp_loop_nesting_depth_state_inconsistent(void);
+
+
+#endif /* _CALLGRAPH_H_ */
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief control dependence analysis
+ * @author Chrsitoph Mallon
+ * @version $Id$
+ */
+#ifndef FIRM_ANA_CDEP_H
+#define FIRM_ANA_CDEP_H
+
+#include "firm_types.h"
+
+typedef struct cdep cdep;
+struct cdep {
+ ir_node *node;
+ cdep *next;
+};
+
+/** Compute the control dependence graph for a graph. */
+void compute_cdep(ir_graph *irg);
+void free_cdep(ir_graph *irg);
+
+cdep *find_cdep(const ir_node *block);
+
+void exchange_cdep(ir_node *old, const ir_node *nw);
+
+int is_cdep_on(const ir_node *dependee, const ir_node *candidate);
+
+int is_iterated_cdep_on(ir_node *dependee, ir_node *candidate);
+
+ir_node *get_unique_cdep(const ir_node *block);
+int has_multiple_cdep(const ir_node *block);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Intraprozedural analyses to estimate the call graph.
+ * @author Hubert Schmid
+ * @date 09.06.2002
+ * @version $Id$
+ * @summary
+ * @summary
+ * Interprocedural analysis to estimate the calling relation.
+ *
+ * This analysis computes all entities representing methods that
+ * can be called at a Call node. Further it computes a set of
+ * methods that are 'free', i.e., their adress is handled by
+ * the program directly, or they are visible external.
+ */
+#ifndef FIRM_ANA_CGANA_H
+#define FIRM_ANA_CGANA_H
+
+#include "firm_types.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.
+ * Stores the result in the field 'callees' of the Call node. If the
+ * address can not be analysed, e.g. because it is loaded from a
+ * variable, the array contains the unknown_entity. (See
+ * "set_Call_callee"). cgana returns the set of 'free' methods, i.e.,
+ * the methods that can be called from external or via function
+ * pointers. This datastructure must be freed with 'free()' by the
+ * caller of cgana.
+ *
+ * cgana sets the callee_info_state of each graph and the program to
+ * consistent.
+ *
+ * The algorithm implements roughly Static Class Hierarchy Analysis
+ * as described in "Optimization of Object-Oriented Programs Using
+ * Static Class Hierarchy Analysis" by Jeffrey Dean and David Grove
+ * 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 nodes by Bad if there is no implementation for the
+ * selected entity.
+ * - Replaces Sel-method by SymConst-entity if the method is never overwritten.
+ * - Replaces Calls by Tuple containing Bads if callee array is empty
+ * (there is no implementation to call)
+ *
+ * Leaves Bad control predecessors in the graph!
+ */
+void cgana(int *len, ir_entity ***free_methods);
+
+/** 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.
+ */
+void free_callee_info(ir_graph *irg);
+void free_irp_callee_info(void);
+
+/* Optimize the address expressions passed to call nodes.
+ * Performs only the optimizations done by cgana. */
+void opt_call_addrs(void);
+
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Construct some loop infromation.
+ * @author Beyhan Veliev
+ * @version $Id$
+ */
+#ifndef FIRM_ANA_COMPUTE_LOOP_INFO_H
+#define FIRM_ANA_COMPUTE_LOOP_INFO_H
+
+#include "irgraph.h"
+
+void compute_loop_info(ir_graph *irg);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Implements the Firm interface to debug information.
+ * @author Goetz Lindenmaier, Michael Beck
+ * @date 2001
+ * @version $Id$
+ * @summary
+ * Firm requires a debugging module fulfilling this interface, else no
+ * debugging information is passed to the backend.
+ * The interface requires a datatype representing the debugging
+ * information. Firm supports administrating a reference to the debug
+ * information in every Firm node. Further Firm optimizations call
+ * routines to propagate debug information from old nodes to new nodes
+ * if the optimization replaces the old ones by the new ones.
+ */
+#ifndef FIRM_DEBUG_DBGINFO_H
+#define FIRM_DEBUG_DBGINFO_H
+
+#include "firm_types.h"
+#include "ident.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup debug The Firm interface to debugging support.
+ *
+ * @{
+ */
+
+/**
+ * @typedef dbg_info
+ *
+ * An abstract data type containing information for
+ * debugging support.
+ *
+ * This opaque data type is not defined anywhere in the Firm library,
+ * but pointers to this type can be stored in Firm nodes.
+ */
+
+/**
+ * Sets the debug information of a node.
+ *
+ * @param n The node.
+ * @param db The debug info.
+ */
+void set_irn_dbg_info(ir_node *n, dbg_info *db);
+
+/**
+ * Returns the debug information of an node.
+ *
+ * @param n The node.
+ */
+dbg_info *get_irn_dbg_info(const ir_node *n);
+
+/**
+ * Sets the debug information of an entity.
+ *
+ * @param ent The entity.
+ * @param db The debug info.
+ */
+void set_entity_dbg_info(ir_entity *ent, dbg_info *db);
+
+/**
+ * Returns the debug information of an entity.
+ *
+ * @param ent The entity.
+ */
+dbg_info *get_entity_dbg_info(const ir_entity *ent);
+
+/**
+ * Sets the debug information of a type.
+ *
+ * @param tp The type.
+ * @param db The debug info.
+ */
+void set_type_dbg_info(ir_type *tp, dbg_info *db);
+
+/**
+ * Returns the debug information of a type.
+ *
+ * @param tp The type.
+ */
+dbg_info *get_type_dbg_info(const ir_type *tp);
+
+/**
+ * An enumeration indicating the action performed by a transformation.
+ */
+typedef enum {
+ dbg_error = 0,
+ dbg_opt_ssa, /**< Optimization of the SSA representation, e.g. removal of superfluent Phi nodes. */
+ dbg_opt_auxnode, /**< Removal of unnecessary auxiliary nodes. */
+ dbg_const_eval, /**< A Firm subgraph was evaluated to a single constant. */
+ dbg_opt_cse, /**< A Firm node was replaced due to common subexpression elimination. */
+ dbg_straightening, /**< A Firm subgraph was replaced by a single, existing block. */
+ dbg_if_simplification, /**< The control flow of an if is changed as either the
+ else, the then or both blocks are empty. */
+ dbg_algebraic_simplification, /**< A Firm subgraph was replaced because of an algebraic
+ simplification. */
+ dbg_write_after_write, /**< A Firm subgraph was replaced because of a write
+ after write optimization. */
+ dbg_write_after_read, /**< A Firm subgraph was replaced because of a write
+ after read optimization. */
+ dbg_read_after_write, /**< A Firm subgraph was replaced because of a read
+ after write optimization. */
+ dbg_read_after_read, /**< A Firm subgraph was replaced because of a read
+ after read optimization. */
+ dbg_read_a_const, /**< A Firm subgraph was replaced because of a read
+ a constant optimization. */
+ dbg_rem_poly_call, /**< Remove polymorphic call. */
+ dbg_dead_code, /**< Removing unreachable code, I.e. blocks that are never executed. */
+ dbg_opt_confirm, /**< A Firm subgraph was replace because of a Confirmation. */
+ dbg_backend, /**< A Firm subgraph was replaced because of a Backend transformation */
+ dbg_max /**< Maximum value. */
+} dbg_action;
+
+/**
+ * Converts a debug_action into a string.
+ *
+ * @param a the debug action
+ */
+const char *dbg_action_2_str(dbg_action a);
+
+/**
+ * The type of the debug info merge function.
+ *
+ * @param new_node the new ir node
+ * @param old_node the old ir node
+ * @param action the action that triggers the merge
+ *
+ * @see dbg_init()
+ */
+typedef void merge_pair_func(ir_node *new_node, ir_node *old_node, dbg_action action);
+
+/**
+ * The type of the debug info merge sets function.
+ *
+ * @param new_node_array array of new nodes
+ * @param new_num_entries number of entries in new_node_array
+ * @param old_node_array array of old nodes
+ * @param old_num_entries number of entries in old_node_array
+ * @param action the action that triggers the merge
+ *
+ * @see dbg_init()
+ */
+typedef void merge_sets_func(ir_node **new_node_array, int new_num_entries, ir_node **old_node_array, int old_num_entries, dbg_action action);
+
+/**
+ * The type of the debug info to human readable string function.
+ *
+ * @param buf pointer to a buffer that will hold the info
+ * @param len length of the buffer
+ * @param dbg the debug info
+ *
+ * @return Number of written characters to the buffer.
+ *
+ * @see dbg_init()
+ */
+typedef unsigned snprint_dbg_func(char *buf, unsigned len, const dbg_info *dbg);
+
+/**
+ * Initializes the debug support.
+ *
+ * @param dbg_info_merge_pair see function description
+ * @param dbg_info_merge_sets see function description
+ * @param snprint_dbg see function description
+ *
+ * This function takes pointers to two functions that merge the
+ * debug information when a
+ * transformation of a Firm graph is performed.
+ * Firm transformations call one of these functions.
+ *
+ * - dbg_info_merge_pair() is called in the following situation:
+ * The optimization replaced the old node by the new one. The new node
+ * might be a recent allocated node not containing any debug information,
+ * or just another node from somewhere in the graph with the same
+ * semantics.
+ * - dbg_info_merge_sets() is called in the following situation:
+ * The optimization replaced a subgraph by another subgraph. There is no
+ * obviously mapping between single nodes in both subgraphs. The optimization
+ * simply passes two lists to the debug module, one containing the nodes in
+ * the old subgraph, the other containing the nodes in the new subgraph.
+ * The same node can be in both lists.
+ *
+ * Further both functions pass an enumeration indicating the action
+ * performed by the transformation, e.g. the kind of optimization performed.
+ *
+ * The third argument snprint_dbg is called to convert a debug info into a human readable string.
+ * This string is the dumped in the dumper functions.
+ *
+ * Note that if NULL is passed for dbg_info_merge_pair or dbg_info_merge_sets, the default
+ * implementations default_dbg_info_merge_pair() and default_dbg_info_merge_sets() are used.
+ * NULL passed for snprint_dbg means no output.
+ */
+void dbg_init(merge_pair_func *dbg_info_merge_pair, merge_sets_func *dbg_info_merge_sets, snprint_dbg_func *snprint_dbg);
+
+/**
+ * The default merge_pair_func implementation, simply copies the debug info
+ * from the old Firm node to the new one if the new one does not have debug info yet.
+ *
+ * @param nw The new Firm node.
+ * @param old The old Firm node.
+ * @param info The action that cause old node to be replaced by new one.
+ */
+void default_dbg_info_merge_pair(ir_node *nw, ir_node *old, dbg_action info);
+
+/**
+ * The default merge_sets_func implementation. If n_old_nodes is equal 1, copies
+ * the debug info from the old node to all new ones (if they do not have one), else does nothing.
+ *
+ * @param new_nodes An array of new Firm nodes.
+ * @param n_new_nodes The length of the new_nodes array.
+ * @param old_nodes An array of old (replaced) Firm nodes.
+ * @param n_old_nodes The length of the old_nodes array.
+ * @param info The action that cause old node to be replaced by new one.
+ */
+void default_dbg_info_merge_sets(ir_node **new_nodes, int n_new_nodes,
+ ir_node **old_nodes, int n_old_nodes,
+ dbg_action info);
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file dfs.h
+ * @author Sebastian Hack
+ * @date 20.04.2007
+ * @version $Id$
+ * @summary
+ *
+ * Primitive depth-first search on the CFG.
+ */
+#ifndef FIRM_ANA_DFS_H
+#define FIRM_ANA_DFS_H
+
+#include "absgraph.h"
+
+typedef struct _dfs_t dfs_t;
+typedef struct _dfs_node_t dfs_node_t;
+typedef struct _dfs_edge_t dfs_edge_t;
+
+typedef enum {
+ DFS_EDGE_ANC,
+ DFS_EDGE_FWD,
+ DFS_EDGE_CROSS,
+ DFS_EDGE_BACK
+} dfs_edge_kind_t;
+
+extern dfs_edge_kind_t dfs_get_edge_kind(const dfs_t *dfs, void *src, void *tgt);
+
+extern dfs_t *dfs_new(const absgraph_t *graph_impl, void *graph);
+extern void dfs_free(dfs_t *dfs);
+extern void dfs_dump(const dfs_t *dfs, FILE *file);
+
+#endif /* FIRM_ANA_DFS_H */
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Compute an estimate of basic block executions.
+ * @author Adam M. Szalkowski
+ * @date 28.05.2006
+ * @version $Id$
+ */
+#ifndef FIRM_ANA_EXECFREQ_H
+#define FIRM_ANA_EXECFREQ_H
+
+#include "firm_types.h"
+
+struct ir_exec_freq;
+
+/**
+ * Create execfreq structure (to be used with set_execfreq)
+ */
+ir_exec_freq *create_execfreq(ir_graph *irg);
+
+/**
+ * Set execution frequency of a basic block
+ */
+void set_execfreq(ir_exec_freq *ef, const ir_node *block, double freq);
+
+/**
+ * Create execfreq structure and initialize with estimated frequencies
+ */
+ir_exec_freq *compute_execfreq(ir_graph *irg, double loop_weight);
+
+void free_execfreq(ir_exec_freq *ef);
+
+double get_block_execfreq(const ir_exec_freq *ef, const ir_node *block);
+unsigned long get_block_execfreq_ulong(const ir_exec_freq *ef, const ir_node *block);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Compute an estimate of basic block executions.
+ * @author Goetz Lindenmaier
+ * @date 5.11.2004
+ * @version $Id$
+ * @summary
+ * We assume the start block of a procedure is executed once. Based on this we
+ * compute the execution freqency of all blocks.
+ *
+ * The computation of the frequencies depends on the count of exception control
+ * flow computed during the interval analysis. The interval analysis again
+ * depends on stuff computed here.
+ */
+#ifndef FIRM_ANA_EXECUTION_FREQUENCY_H
+#define FIRM_ANA_EXECUTION_FREQUENCY_H
+
+#include "firm_types.h"
+
+/* A proj from a Cond that goes to an exception handler. */
+int is_fragile_Proj(ir_node *n);
+
+/** Returns the number of times the block/region is executed according to
+ * our estimate. Gives a number relative to the Start node of the procedure
+ * the block is in, which is weighted with 1. */
+double get_irn_exec_freq (ir_node *n);
+double get_Block_exec_freq (ir_node *b);
+double get_region_exec_freq(void *reg);
+
+/** Compute the execution frequency for all blocks in the given
+ * graph.
+ *
+ * @param irg The graph to be analyzed.
+ * @param default_loop_weight The default number of executions of a loop.
+ * @param exception_probability The probability that a fragile operation causes an exception.
+ *
+ * Uses link field.
+ */
+void compute_execution_frequency(ir_graph *irg, int default_loop_weight, double exception_probability);
+
+/** Compute the execution frequency for all graphs.
+ *
+ * @param default_loop_weight The default number of executions of a loop.
+ * @param exception_probability The probability that a fragile operation causes an exception.
+ *
+ */
+void compute_execution_frequencies(int default_loop_weight, double exception_probability);
+
+/** Free occupied memory, reset for all graphs. */
+void free_execution_frequency(void);
+
+/** State of execution frequencies for graphs and the whole program.
+ *
+ * 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_state;
+
+exec_freq_state get_irg_exec_freq_state(ir_graph *irg);
+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. */
+void set_irg_exec_freq_state_inconsistent(ir_graph *irg);
+
+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. */
+void set_irp_exec_freq_state_inconsistent(void);
+
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Compute an estimate of field temperature, i.e., field access heuristic.
+ * @author Goetz Lindenmaier
+ * @date 21.7.2004
+ * @version $Id$
+ * @note
+ * Watch it! This is highly java dependent.
+ *
+ * - All Sel nodes get an array with possibly accessed entities.
+ * (resolve polymorphy on base of inherited entities.)
+ * (the mentioned entity in first approximation.)
+ *
+ * - We compute a value for the entity based on the Sel nodes.
+ */
+#ifndef FIRM_ANA_FIELD_TEMPERATURE_H
+#define FIRM_ANA_FIELD_TEMPERATURE_H
+
+#include "firm_types.h"
+
+/* The number of array elements we assume if not both bounds are given. */
+#define DEFAULT_N_ARRAY_ELEMENTS 1
+
+/** The entities that can be accessed by this Sel node. *
+int get_Sel_n_accessed_entities(ir_node *sel);
+ir_entity *get_Sel_accessed_entity (ir_node *sel, int pos);
+*/
+
+int get_irn_loop_call_depth(ir_node *n);
+/** Return loop depth of node.
+ *
+ * Returns the loop depth of n in the control flow. I.e., we
+ * go from the node to the block to the loop the block is in,
+ * and return its depth. */
+int get_irn_cfloop_depth(ir_node *n);
+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. */
+int get_weighted_loop_depth(ir_node *n);
+
+/** Heuristic merging recursion and loop depth. */
+double get_irn_final_cost(ir_node *n);
+
+/** Get accumulated(really?) execution frequencies.
+ * A heuristic weights the recursions. */
+double get_type_estimated_n_instances(ir_type *clss);
+double get_type_estimated_mem_consumption_bytes(ir_type *tp);
+/** Estimates the size of an object.
+ *
+ * The heuristic mainly affects array sizes.
+ * Further this ignores padding for alignment, especially of small fields. */
+int get_type_estimated_size_bytes(ir_type *tp);
+/** Estimates the number of fields of a single Object.
+ * The heuristic mainly affects array sizes.
+ * @@@ Misses inherited fields! */
+int get_type_estimated_n_fields(ir_type *tp);
+double get_type_estimated_n_casts(ir_type *clss);
+
+double get_class_estimated_n_upcasts(ir_type *clss);
+double get_class_estimated_n_downcasts(ir_type *clss);
+/** 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. */
+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. */
+double get_class_estimated_dispatch_writes(ir_type *clss);
+/** Returns the number of reads of the dispatch pointer. */
+double get_class_estimated_dispatch_reads (ir_type *clss);
+
+double get_entity_estimated_n_loads(ir_entity *ent);
+double get_entity_estimated_n_stores(ir_entity *ent);
+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. */
+double get_entity_estimated_n_dyncalls(ir_entity *ent);
+
+/* ------------------------------------------------------------------------- */
+/* Accumulate information in the type hierarchy. */
+/* ------------------------------------------------------------------------- */
+
+typedef enum {
+ temperature_none,
+ temperature_consistent,
+ temperature_inconsistent
+} irp_temperature_state;
+
+/** An auxiliary/temporary function */
+int is_jack_rts_class(ir_type *t);
+int is_jack_rts_entity(ir_entity *e);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Central firm header.
+ * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier
+ * @version $Id$
+ * @summary
+ * Central FIRM header.
+ *
+ * FIRM is a full graph based intermediate representation in SSA Form
+ * with a novel concept to model side effects. It allows fast, aggressive
+ * optimizations.
+ *
+ * This header is the central header of the library implementation of this
+ * IR.
+ *
+ * The internal representation of a program in firm is separated into five
+ * different modules:
+ * - Firm Graphs representing the code of a program. (Subdirectory ir.)
+ * Firm Graphs are assembled out of several data structures:
+ * irprog: represents a program. Allows access to all types and all
+ * FIRM graphs for procedures and other global things.
+ * irgraph: represents a procedure. Allows access to the code of the
+ * procedure, the actual FIRM graph.
+ * irnode: A node of a FIRM graph. Nodes are typed with an opcode and a mode
+ * and represent instructions in a program.
+ * irop: The opcode of FIRM nodes.
+ * irmode: The mode of FIRM nodes. Most modes correspond to machine known
+ * data types (int, float, pointer).
+ * - Entities representing program known objects. (Subdirectory tr.)
+ * All variables and procedures are entities.
+ * - Types describing the type system for the program. (Subdirectory tr.)
+ * - Target Values representing program known constants. (Subdirectory tv.)
+ * - Identifiers representing any Strings used in the program. (Subdirectory ident.)
+ *
+ * Further this library supplies functionality to build and optimize FIRM graphs
+ * and further functionality needed in a compiler. Finally there is more
+ * generic functionality to support implementations using firm. (Code generation,
+ * further optimizations).
+ */
+#ifndef FIRM_COMMON_FIRM_H
+#define FIRM_COMMON_FIRM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* The representations */
+#include "firm_common.h" /* common type tags. */
+#include "irprog.h" /* control flow and data of a program */
+#include "irgraph.h" /* graphs */
+#include "typerep.h" /* type representation */
+#include "tv.h" /* target values */
+#include "ident.h" /* source code identificators */
+
+/* Functionality */
+#include "ircons.h" /* construct ir */
+#include "ircgcons.h" /* construct interprocedural graph */
+
+/* Optimizations */
+#include "irflag.h" /* optimization flags */
+#include "irgopt.h" /* optimize ir */
+#include "iroptimize.h" /* optimize ir by reassociation */
+#include "ircgopt.h" /* Optimizations based on interprocedural graph */
+
+/* Lowering */
+#include "lower_calls.h" /* lowering of different calls */
+#include "lower_intrinsics.h" /* lowering of intrinsic calls */
+#include "lower_dw.h" /* double word types lowering */
+#include "lower_hl.h" /* lowering of high-level constructs */
+
+/* Analyses */
+#include "irouts.h" /* Graph reversal / out edges. */
+#include "trouts.h" /* Graph reversal / out edges for types. */
+#include "irdom.h" /* Dominator analysis */
+#include "cgana.h" /* Analysis to construct interprocedural graph */
+ /* including some optimizations */
+#include "irloop.h" /* loop and backedge analysis */
+#include "callgraph.h" /* Callgraph construction */
+#include "irconsconfirm.h" /* Confirm nodes */
+#include "analyze_irg_args.h" /* Simple pointer parameter analysis */
+#include "irtypeinfo.h" /* type information for nodes */
+#include "irmemory.h" /* memory disambiguation */
+#include "interval_analysis.h"
+#include "field_temperature.h"
+#include "execution_frequency.h"
+
+/* Support */
+#include "irgmod.h" /* Support to modify ir */
+#include "irgwalk.h" /* Support to walk ir */
+
+#include "irarch.h" /* architecture dependent optimizations */
+#include "archop.h" /* architecture dependent opcodes */
+
+#include "firmstat.h" /* statistics */
+
+#include "seqnumbers.h" /* debug support */
+#include "firm_ycomp.h" /* ycomp debugging support */
+
+
+/* @@@ temporarily for jni builder until preprocessor works.
+ Then it should be sufficient to include <file.h> instead
+ of firm.h as not all enums are needed in the implementation
+ files. */
+#include "irdump.h"
+#include "irprintf.h"
+#include "irvrfy.h"
+
+#include "irarch.h"
+
+#include "iredges.h"
+
+/* Macros that define the old function names we decided to rename.
+ Use for compatibility with old implementations. */
+/*#include "old_fctnames.h"*/
+
+/**
+ * libFirm initialization parameters.
+ */
+struct _firm_parameter_t {
+ /**
+ * The size of this structure. init_firm() will only initialize
+ * this amount of data. This allows to add more fields to this structure
+ * without breaking compatibility to older source.
+ */
+ unsigned int size;
+
+ /**
+ * Statistic options. If statistic function where enabled, these
+ * flags configure it, see enum firmstat_options_t.
+ */
+ unsigned enable_statistics;
+
+ /**
+ * This function is called, whenever a local variable is
+ * used before definition. The function should insert a default value,
+ * and/or raise a compiler error/warning. Note that returning
+ * an Unknown is allowed here.
+ */
+ uninitialized_local_variable_func_t *initialize_local_func;
+
+ /**
+ * The interface functions for the type identification module.
+ * If not set, the default implementation with compare_strict() and
+ * firm_hash_name() will be used.
+ */
+ type_identify_if_t *ti_if;
+
+ /**
+ * The interface for the ident module.
+ * If not set, the default libFirm ident module (using hash sets).
+ */
+ ident_if_t *id_if;
+
+ /**
+ * The architecture dependent opcode settings.
+ * If not set, no architecture dependent operations will be used.
+ */
+ const arch_ops_info *arch_op_settings;
+
+ /**
+ * The default calling convention.
+ */
+ unsigned cc_mask;
+
+ /**
+ * The debug info that should be used for "builtin" objects.
+ */
+ dbg_info *builtin_dbg;
+};
+
+typedef struct _firm_parameter_t firm_parameter_t;
+
+#define libFirm_VERSION_MAJOR 1
+#define libFirm_VERSION_MINOR 4
+
+/**
+ * The Firm version number.
+ */
+typedef struct _firm_version_t {
+ unsigned major;
+ unsigned minor;
+} firm_version_t;
+
+/**
+ * Initialize the firm library.
+ *
+ * Initializes the firm library. Allocates default data structures.
+ * Initializes configurable behavior of the library.
+ *
+ * @param params A structure containing the parameters of the libFirm.
+ *
+ * The parameter struct may be NULL. In that case, the original FIRM behavior
+ * is conserved.
+ */
+void init_firm(const firm_parameter_t *params);
+
+/**
+ * Frees all memory occupied by the firm library.
+ */
+void free_firm(void);
+
+/**
+ * Returns the libFirm version number.
+ * If statically linked, always libFirm_VERSION_MAJOR, libFirm_VERSION_MINOR
+ */
+void firm_get_version(firm_version_t *version);
+
+#ifdef WITH_LIBCORE
+/**
+ * Read initializations arguments from the .init file.
+ */
+void firm_init_options(const char *arg_prefix, int argc, const char **argv);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief common firm declarations
+ * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier
+ * @version $Id$
+ */
+#ifndef FIRM_COMMON_FIRM_COMMON_H
+#define FIRM_COMMON_FIRM_COMMON_H
+
+/** a list of firm kinds
+ @@@ not all datatypes are tagged yet. */
+typedef enum {
+ k_BAD = 0, /**< An invalid firm node. */
+ k_entity, /**< An entity. */
+ k_type, /**< A type. */
+ k_ir_graph, /**< An IR graph. */
+ k_ir_node, /**< An IR node. */
+ k_ir_mode, /**< An IR mode. */
+ k_ir_op, /**< An IR opcode. */
+ k_tarval, /**< A tarval. */
+ k_ir_loop, /**< A loop. */
+ k_ir_compound_graph_path, /**< A compound graph path, see entity.h. */
+ k_ir_extblk, /**< An extended basic block. */
+ k_ir_prog, /**< A program representation (irp). */
+ k_ir_region, /**< A region. */
+ k_ir_max /**< maximum value -- illegal for firm nodes. */
+} firm_kind;
+
+/**
+ * Returns the kind of a thing.
+ *
+ * @param firm_thing pointer representing a firm object
+ */
+firm_kind get_kind(const void *firm_thing);
+
+/** Returns the kind of a thing as a string. */
+const char *print_firm_kind(void *firm_thing);
+
+/** Print an identification of a firm thing. */
+void firm_identify_thing(void *X);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Definition of opaque firm types
+ * @author Michael Beck
+ * @version $Id$
+ */
+#ifndef FIRM_COMMON_FIRM_TYPES_H
+#define FIRM_COMMON_FIRM_TYPES_H
+
+#ifdef _MSC_VER
+typedef __int64 long64;
+typedef unsigned __int64 ulong64;
+
+#define LL_FMT "i64"
+#define ULL_FMT "ui64"
+
+#else
+typedef long long long64;
+typedef unsigned long long ulong64;
+
+#define LL_FMT "ll"
+#define ULL_FMT "llu"
+
+#endif /* _MSC_VER */
+
+typedef struct dbg_info dbg_info, *dbg_info_ptr;
+typedef const struct _ident ident, *ir_ident_ptr;
+typedef struct ir_node ir_node, *ir_node_ptr;
+typedef struct ir_op ir_op, *ir_op_ptr;
+typedef struct ir_mode ir_mode, *ir_mode_ptr;
+typedef struct _ir_edge_t ir_edge_t, *ir_edge_ptr;
+typedef struct tarval tarval, *ir_tarval_ptr;
+typedef struct ir_enum_const ir_enum_const, *ir_enum_const_ptr;
+typedef struct ir_type ir_type, *ir_type_ptr;
+typedef struct ir_graph ir_graph, *ir_graph_ptr;
+typedef struct ir_loop ir_loop, *ir_loop_ptr;
+typedef struct ir_region ir_region, *ir_region_ptr;
+typedef struct ir_reg_tree ir_reg_tree, *ir_reg_tree_ptr;
+typedef struct ir_entity ir_entity, *ir_entity_ptr;
+typedef struct compound_graph_path compound_graph_path, *ir_compound_graph_path_ptr;
+typedef struct _ir_phase ir_phase, *ir_phase_ptr;
+typedef struct _ir_extblk ir_extblk, *ir_extblk_ptr;
+typedef struct ir_exec_freq ir_exec_freq, *ir_exec_freq_ptr;
+typedef struct sn_entry *seqno_t;
+
+
+typedef void irg_walk_func(ir_node *, void *);
+typedef void irg_reg_walk_func(ir_region *, void *);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Connect firm to ycomp
+ * @author Christian Wuerdig
+ * @date 16.11.2006
+ * @version $Id$
+ */
+#ifndef FIRM_DEBUG_FIRM_YCOMP_H
+#define FIRM_DEBUG_FIRM_YCOMP_H
+
+#define FIRM_YCOMP_DEFAULT_HOST "localhost"
+#define FIRM_YCOMP_DEFAULT_PORT 4242
+
+/**
+ * Establish connection to yComp and register debugger hooks.
+ * @param host Hostname where yComp is running
+ * @param port Port on which yComp is listening
+ */
+void firm_init_ycomp_debugger(const char *host, unsigned port);
+
+/**
+ * Close connection to yComp and unregister debugger hooks.
+ */
+void firm_finish_ycomp_debugger(void);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Statistics for Firm.
+ * @author Michael Beck
+ * @version $Id$
+ */
+#ifndef FIRM_STAT_FIRMSTAT_H
+#define FIRM_STAT_FIRMSTAT_H
+
+#include "irhooks.h"
+
+/**
+ * Statistic options, can be or'ed.
+ */
+enum firmstat_options_t {
+ FIRMSTAT_ENABLED = 0x00000001, /**< enable statistics */
+ FIRMSTAT_PATTERN_ENABLED = 0x00000002, /**< enable pattern calculation */
+ FIRMSTAT_COUNT_STRONG_OP = 0x00000004, /**< if set, count Mul/Div/Mod/DivMod by constant */
+ FIRMSTAT_COUNT_DAG = 0x00000008, /**< if set, count DAG statistics */
+ FIRMSTAT_COUNT_DELETED = 0x00000010, /**< if set, count deleted graphs */
+ FIRMSTAT_COUNT_SELS = 0x00000020, /**< if set, count Sel(Sel(..)) differently */
+ FIRMSTAT_COUNT_CONSTS = 0x00000040, /**< if set, count Const statistics */
+ FIRMSTAT_COUNT_EXTBB = 0x00000080, /**< if set, count extended Basic Block statistics */
+ FIRMSTAT_CSV_OUTPUT = 0x10000000 /**< CSV output of some mini-statistic */
+};
+
+/**
+ * Additional flags for statistics.
+ */
+enum firmstat_optimizations_t {
+ FS_OPT_NEUTRAL_0 = HOOK_OPT_LAST, /**< a op 0 = 0 op a = a */
+ FS_OPT_NEUTRAL_1, /**< a op 1 = 1 op a = a */
+ FS_OPT_ADD_A_A, /**< a + a = a * 2 */
+ FS_OPT_ADD_A_MINUS_B, /**< a + -b = a - b */
+ FS_OPT_ADD_SUB, /**< (a + x) - x = (a - x) + x */
+ FS_OPT_ADD_MUL_A_X_A, /**< a * x + a = a * (x + 1) */
+ FS_OPT_SUB_0_A, /**< 0 - a = -a */
+ FS_OPT_SUB_MUL_A_X_A, /**< a * x - a = a * (x - 1) */
+ FS_OPT_SUB_SUB_X_Y_Z, /**< (x - y) - z = x - (y + z) */
+ FS_OPT_MUL_MINUS_1, /**< a * -1 = -a */
+ FS_OPT_OR, /**< a | a = a | 0 = 0 | a = a */
+ FS_OPT_AND, /**< a & 0b1...1 = 0b1...1 & a = a & a = a */
+ FS_OPT_EOR_A_A, /**< a ^ a = 0 */
+ FS_OPT_EOR_TO_NOT_BOOL, /**< bool ^ 1 = !bool */
+ FS_OPT_EOR_TO_NOT, /**< x ^ 0b1..1 = ~x */
+ FS_OPT_NOT_CMP, /**< !(a cmp b) = a !cmp b */
+ FS_OPT_OR_SHFT_TO_ROT, /**< (x << c) | (x >> (bits - c)) == Rot(x, c) */
+ FS_OPT_REASSOC_SHIFT, /**< (x SHF c1) SHF c2 = x SHF (c1+c2) */
+ FS_OPT_CONV, /**< a Conv could be removed */
+ FS_OPT_CAST, /**< a Cast could be removed */
+ FS_OPT_MIN_MAX_EQ, /**< Min(a,a) = Max(a,a) = a */
+ FS_OPT_MUX_C, /**< Mux(C, f, t) = C ? t : f */
+ FS_OPT_MUX_EQ, /**< Mux(v, x, x) = x */
+ FS_OPT_MUX_TRANSFORM, /**< Mux(a, b, c) = b OR Mux(a,b, c) = c */
+ FS_OPT_MUX_TO_MIN, /**< Mux(a < b, a, b) = Min(a,b) */
+ FS_OPT_MUX_TO_MAX, /**< Mux(a > b, a, b) = Max(a,b) */
+ FS_OPT_MUX_TO_ABS, /**< Mux(a > b, a, b) = Abs(a,b) */
+ FS_OPT_MUX_TO_SHR, /**< Mux(a > b, a, b) = a >> b */
+ FS_OPT_CONST_PHI, /**< Constant evaluation on Phi */
+ FS_BE_IA32_LEA, /**< Lea was created */
+ FS_BE_IA32_LOAD_LEA, /**< Load merged with a Lea */
+ FS_BE_IA32_STORE_LEA, /**< Store merged with a Lea */
+ FS_BE_IA32_AM_S, /**< Source address mode node created */
+ FS_BE_IA32_AM_D, /**< Destination address mode node created */
+ FS_BE_IA32_CJMP, /**< CJmp created to save a cmp/test */
+ FS_BE_IA32_2ADDRCPY, /**< Copy created due to 2-Addresscode constraints */
+ FS_BE_IA32_SPILL2ST, /**< Created Store for a Spill */
+ FS_BE_IA32_RELOAD2LD, /**< Created Load for a Reload */
+ FS_BE_IA32_SUB2NEGADD, /**< Created Neg-Add for a Sub due to 2-Addresscode constraints */
+ FS_BE_IA32_LEA2ADD, /**< Transformed Lea back into Add */
+ FS_OPT_MAX
+};
+
+/**
+ * Dump a snapshot of the statistic values.
+ * Never called from libFirm should be called from user.
+ *
+ * @param name base name of the statistic output file
+ * @param phase a phase name. Prefix will be firmstat-<phase>-
+ */
+void stat_dump_snapshot(const char *name, const char *phase);
+
+/**
+ * initialize the statistics module.
+ *
+ * @param enable_options a bitmask containing the statistic options
+ */
+void firm_init_stat(unsigned enable_options);
+
+/**
+ * terminates the statistics module, frees all memory
+ */
+void stat_term(void);
+
+/**
+ * returns 1 if statistic module is active, 0 otherwise
+ */
+int stat_is_active(void);
+
+#endif /* FIRM_STAT_FIRMSTAT_H */
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Compute heights of nodes inside basic blocks
+ * @author Sebastian Hack
+ * @date 19.04.2006
+ * @version $Id$
+ */
+#ifndef FIRM_ANA_HEIGHTS_H
+#define FIRM_ANA_HEIGHTS_H
+
+typedef struct _heights_t heights_t;
+
+/**
+ * Get the height of a node inside a basic block.
+ * The height of the node is the maximal number of edges between a sink node in that block and the node itself (plus 1).
+ * @param h The heights object.
+ * @param irn The node.
+ * @return The height of the node.
+ */
+unsigned get_irn_height(heights_t *h, const ir_node *irn);
+
+/**
+ * Check, if a certain node is reachable according to data dependence edges from another node.
+ * @param h The heights object.
+ * @param n The first node.
+ * @param m The other node.
+ * @return 1, if n is data dependent on m, 0 if not.
+ */
+int heights_reachable_in_block(heights_t *h, const ir_node *n, const ir_node *m);
+
+/**
+ * Recompute the height information.
+ * This can be used to recompute the height information if the graph has changed since the last computation.
+ * @param h The heights object.
+ */
+void heights_recompute(heights_t *h);
+
+/**
+ * Recompute the height information for a certain block.
+ * This can be used to recompute the height information of a block.
+ * @param h The heights object.
+ * @param block The block
+ * @return The maximum over all heights in the block.
+ */
+unsigned heights_recompute_block(heights_t *h, ir_node *block);
+
+/**
+ * Make a new heights object.
+ * This also computes the heights for each block in the graph.
+ * @param irg The graph.
+ */
+heights_t *heights_new(ir_graph *irg);
+
+/**
+ * Free a heights object.
+ * @param h The heights object.
+ */
+void heights_free(heights_t *h);
+
+
+#endif /* FIRM_ANA_HEIGHTS_H */
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Data type for unique names.
+ * @author Goetz Lindenmaier
+ * @version $Id$
+ * @summary
+ * Declarations for identifiers in the firm library
+ *
+ * Identifiers are used in the firm library. This is the interface to it.
+ */
+#ifndef FIRM_IDENT_IDENT_H
+#define FIRM_IDENT_IDENT_H
+
+#include "firm_config.h"
+#include "firm_types.h"
+
+#ifdef FIRM_ENABLE_WCHAR
+#include <wchar.h>
+#endif
+
+/* Identifiers */
+
+/**
+ * The ident module interface.
+ */
+typedef struct _ident_if_t {
+ /** The handle. */
+ void *handle;
+
+ /**
+ * Store a string and create an ident.
+ * This function may be NULL, new_id_from_chars()
+ * is then used to emulate it's behavior.
+ *
+ * @param str - the string which shall be stored
+ */
+ ident *(*new_id_from_str)(void *handle, const char *str);
+
+ /**
+ * Store a string and create an ident.
+ *
+ * @param str - the string (or whatever) which shall be stored
+ * @param len - the length of the data in bytes
+ */
+ ident *(*new_id_from_chars)(void *handle, const char *str, int len);
+
+ /**
+ * Returns a string represented by an ident.
+ */
+ const char *(*get_id_str)(void *handle, ident *id);
+
+ /**
+ * Returns the length of the string represented by an ident.
+ * This function may be NULL, get_id_str() is then used
+ * to emulate it's behavior.
+ *
+ * @param id - the ident
+ */
+ int (*get_id_strlen)(void *handle, ident *id);
+
+ /**
+ * Finish the ident module and frees all idents, may be NULL.
+ */
+ void (*finish_ident)(void *handle);
+
+#ifdef FIRM_ENABLE_WCHAR
+ /**
+ * Store a wide character string and create an ident.
+ * This function may be NULL, new_id_from_wchars()
+ * is then used to emulate it's behavior.
+ *
+ * @param wstr - the string which shall be stored
+ */
+ ident *(*new_id_from_wcs)(void *handle, const wchar_t *wstr);
+
+ /**
+ * Store a wide character string and create an ident.
+ * This function may be NULL, new_id_from_chars() is then used appropriate.
+ * Beware: the string might not be stored at a right alignment!
+ *
+ * @param wstr - the wide character string which shall be stored
+ * @param len - the length of the string
+ */
+ ident *(*new_id_from_wchars)(void *handle, const wchar_t *wstr, int len);
+
+ /**
+ * Returns a wide character string represented by an ident.
+ * This function may be NULL, get_id_str() is then used.
+ * This assume that the strings are stored at an address aligned
+ * for wchar_t, so beware!
+ */
+ const wchar_t *(*get_id_wcs)(void *handle, ident *id);
+
+ /**
+ * Returns the length of the string represented by an ident.
+ * This function may be NULL, get_id_wcs() is then used
+ * to emulate it's behavior.
+ *
+ * @param id - the ident
+ */
+ int (*get_id_wcslen)(void *handle, ident *id);
+#endif
+} ident_if_t;
+
+/**
+ * Store a string and create an ident.
+ *
+ * Stores a string in the ident module and returns a handle for the string.
+ *
+ * Copies the string. @p str must be zero terminated
+ *
+ * @param str - the string which shall be stored
+ *
+ * @return id - a handle for the generated ident
+ *
+ * @see get_id_str(), get_id_strlen()
+ */
+ident *new_id_from_str (const char *str);
+
+/** Store a string and create an ident.
+ *
+ * Stores a string in the ident module and returns a handle for the string.
+ * Copies the string. This version takes non-zero-terminated strings.
+ *
+ * @param str - the string (or whatever) which shall be stored
+ * @param len - the length of the data in bytes
+ *
+ * @return id - a handle for the generated ident
+ *
+ * @see new_id_from_str(), get_id_strlen()
+ */
+ident *new_id_from_chars (const char *str, int len);
+
+/**
+ * Returns a string represented by an ident.
+ *
+ * Returns the string represented by id. This string is
+ * NULL terminated. The string may not be changed.
+ *
+ * @param id - the ident
+ *
+ * @return cp - a string
+ *
+ * @see new_id_from_str(), new_id_from_chars(), get_id_strlen()
+ */
+const char *get_id_str (ident *id);
+
+/**
+ * Returns the length of the string represented by an ident.
+ *
+ * @param id - the ident
+ *
+ * @return len - the length of the string
+ *
+ * @see new_id_from_str(), new_id_from_chars(), get_id_str()
+ */
+int get_id_strlen(ident *id);
+
+/**
+ * Returns true if prefix is a prefix of an ident.
+ *
+ * @param prefix - the prefix
+ * @param id - the ident
+ *
+ * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix()
+ */
+int id_is_prefix (ident *prefix, ident *id);
+
+/**
+ * Returns true if suffix is a suffix of an ident.
+ *
+ * @param suffix - the suffix
+ * @param id - the ident
+ *
+ * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix()
+ */
+int id_is_suffix (ident *suffix, ident *id);
+
+/**
+ * Returns true if infix is contained in id. (Can be suffix or prefix)
+ *
+ * @param infix - the infix
+ * @param id - the ident to search in
+ *
+ * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix()
+ */
+/* int id_contains(ident *infix, ident *id); */
+
+/**
+ * Return true if an ident contains a given character.
+ *
+ * @param id - the ident
+ * @param c - the character
+ *
+ * @see new_id_from_str(), new_id_from_chars(), get_id_str()
+ */
+int id_contains_char (ident *id, char c);
+
+#ifdef FIRM_ENABLE_WCHAR
+/**
+ * Store a wide character string and create an ident.
+ *
+ * Stores a string in the ident module and returns a handle for the string.
+ *
+ * Copies the string. @p str must be zero terminated
+ *
+ * @param str - the wide character string which shall be stored
+ *
+ * @return id - a handle for the generated ident
+ *
+ * @see get_id_wcs(), get_id_wcs()
+ */
+ident *new_id_from_wcs (const wchar_t *str);
+
+/** Store a wide character string and create an ident.
+ *
+ * Stores a string in the ident module and returns a handle for the string.
+ * Copies the string. This version takes non-zero-terminated strings.
+ *
+ * @param wstr - the wide character string (or whatever) which shall be stored
+ * @param len - the length of string
+ *
+ * @return id - a handle for the generated ident
+ *
+ * @see new_id_from_str(), get_id_strlen()
+ */
+ident *new_id_from_wchars (const wchar_t *str, int len);
+
+/**
+ * Returns a wide character string represented by an ident.
+ *
+ * Returns the string represented by id. This string is
+ * NULL terminated. The string may not be changed.
+ *
+ * @param id - the ident
+ *
+ * @return cp - a string
+ *
+ * @see new_id_from_wcs(), new_id_from_wchars(), get_id_wcslen()
+ */
+const wchar_t *get_id_wcs(ident *id);
+
+/**
+ * Returns the length of the wide character string represented by an ident.
+ *
+ * @param id - the ident
+ *
+ * @return len - the length of the string
+ *
+ * @see new_id_from_wcs(), new_id_from_wchars(), get_id_wcs()
+ */
+int get_id_wcslen(ident *id);
+
+/**
+ * Return true if an ident contains a given character.
+ *
+ * @param id - the ident
+ * @param c - the character
+ *
+ * @see new_id_from_wcs(), new_id_from_chars(), get_id_str()
+ */
+int id_contains_wchar (ident *id, wchar_t c);
+
+#endif /* FIRM_ENABLE_WCHAR */
+
+/** initializes the name mangling code */
+void firm_init_mangle (void);
+
+/** Computes a definite name for this entity by concatenating
+ the name of the owner type and the name of the entity with
+ a separating "_". */
+ident *mangle_entity (ir_entity *ent);
+
+/** mangle underscore: Returns a new ident that represents first_scnd. */
+ident *mangle_u (ident *first, ident* scnd);
+
+/** mangle dot: Returns a new ident that represents first.scnd. */
+ident *mangle_dot (ident *first, ident* scnd);
+
+/** mangle: Returns a new ident that represents firstscnd. */
+ident *mangle (ident *first, ident* scnd);
+
+/** returns a mangled name for a Win32 function using it's calling convention */
+ident *decorate_win32_c_fkt(ir_entity *ent, ident *id);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Decompost control flow graph into acylic, hierarchic intervals.
+ * @author Goetz Lindenmaier
+ * @date 5.11.2004
+ * @version $Id$
+ * @summary
+ * Decompost control flow graph into acylic, hierarchic intervals.
+ *
+ * The analysis is based on the control flow looptree. An intervall
+ * are basically all nodes in a single ir_loop entry, i.e., basic
+ * blocks and inner loop nodes. The analysis computes a new set of
+ * edges that link all nodes of a loop to an acyclic graph.
+ *
+ * The interval analysis counts the number of exception control flow
+ * operations leaving a block. This depends on stuff computed in
+ * execution_freqencies.
+ */
+#ifndef FIRM_ANA_INTERVAL_ANALYSIS_H
+#define FIRM_ANA_INTERVAL_ANALYSIS_H
+
+#include "firm_types.h"
+
+/** The ins of regions: regions are loops or blocks.
+ *
+ * @todo: we should make a type for the regions, or reuse loop_element.
+ */
+int get_region_n_ins(void *region);
+void *get_region_in (void *region, int pos);
+void add_region_in (void *region, void *in);
+
+
+/** The number of out edges of a region.
+ *
+ * This number is useful for evaluation of execution frequencies.
+ */
+int get_region_n_outs(void *region);
+
+/** The number of exception out edges of a region.
+ *
+ * This number is useful for evaluation of execution frequencies.
+ */
+int get_region_n_exc_outs(void *region);
+
+/** The control flow operation corresponding to the loop-region in at
+ * position pos.
+ */
+void *get_loop_cfop(void *region, int pos);
+
+
+/** The algorithm to construct the interval graph.
+ *
+ * Constructs the cf loop tree and leaves a valid version of it.
+ *
+ * @todo: @@@ add flag that states correctness of interval analysis information
+ * to irg.
+ **/
+void construct_intervals(ir_graph *irg);
+
+
+/** frees interval information of all graphs. */
+void free_intervals(void);
+
+
+/** dump a graph with the intervals. File name suffix "-interval". */
+void dump_interval_graph(ir_graph *irg, const char *suffix);
+
+
+#define DDMR(X) if(is_ir_node(X)) DDMN(X); else DDML(X)
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Some machine dependent optimizations.
+ * @date 1.10.2004
+ * @author Sebastian Hack
+ * @version $Id$
+ */
+#ifndef FIRM_IR_IRARCH_H
+#define FIRM_IR_IRARCH_H
+
+#include "firm_types.h"
+
+/**
+ * A parameter structure that drives the machine dependent Firm
+ * optimizations.
+ */
+typedef struct {
+ /* Mul optimization */
+ unsigned also_use_subs : 1; /**< Use also Subs when resolving Muls to shifts */
+ int maximum_shifts; /**< The maximum number of shifts that shall be inserted for a mul. */
+ unsigned highest_shift_amount; /**< The highest shift amount you want to
+ tolerate. Muls which would require a higher
+ shift constant are left. */
+
+ /* Div/Mod optimization */
+ unsigned allow_mulhs : 1; /**< Use the Mulhs operation for division by constant */
+ unsigned allow_mulhu : 1; /**< Use the Mulhu operation for division by constant */
+ int max_bits_for_mulh; /**< Maximum number of bits the Mulh operation can take.
+ Modes with higher amount of bits will use Mulh */
+} arch_dep_params_t;
+
+/**
+ * A factory function, that provides architecture parameters for
+ * machine dependent optimizations.
+ */
+typedef const arch_dep_params_t *(*arch_dep_params_factory_t)(void);
+
+/**
+ * A default parameter factory for testing purposes.
+ */
+const arch_dep_params_t *arch_dep_default_factory(void);
+
+/**
+ * Optimization flags.
+ */
+typedef enum {
+ arch_dep_none = 0,
+ arch_dep_mul_to_shift = 1, /**< optimize Mul into Shift/Add/Sub */
+ arch_dep_div_by_const = 2, /**< optimize Div into Shift/Add/Mulh */
+ arch_dep_mod_by_const = 4 /**< optimize Mod into Shift/Add/Mulh */
+} arch_dep_opts_t;
+
+/**
+ * Initialize the machine dependent optimizations.
+ * @param factory A factory that delivers parameters for these
+ * optimizations. If NULL is passed, or this method
+ * is not called, the machine dependent optimizations
+ * are not enabled at all.
+ */
+void arch_dep_init(arch_dep_params_factory_t factory);
+
+/**
+ * Set the optimizations that shall be applied.
+ * @param opts An optimization bit mask.
+ */
+void arch_dep_set_opts(arch_dep_opts_t opts);
+
+/**
+ * Replace Muls with Shifts and Add/Subs.
+ * This function is driven by the 3 parameters:
+ * - also_use_subs
+ * - maximum_shifts
+ * - highest_shift_amount
+ *
+ * If irn is a Mul with a Const, the constant is inspected if it meets the
+ * requirements of the three variables stated above. If a Shl/Add/Sub
+ * sequence can be generated that meets these requirements, this expression
+ * is returned. In each other case irn is returned unmodified.
+ *
+ * @param irn The Firm node to inspect.
+ * @return A replacement expression for irn.
+ */
+ir_node *arch_dep_replace_mul_with_shifts(ir_node *irn);
+
+/**
+ * Replace Divs with Shifts and Add/Subs and Mulh.
+ * This function is driven by the 3 parameters:
+ * - allow_mulhu
+ * - allow_mulhs
+ * - max_bits_for_mulh
+ *
+ * If irn is a Div with a Const, the constant is inspected if it meets the
+ * requirements of the variables stated above. If a Shl/Add/Sub/Mulh
+ * sequence can be generated that meets these requirements, this expression
+ * is returned. In each other case irn is returned unmodified.
+ *
+ * @param irn The Firm node to inspect.
+ * @return A replacement expression for irn.
+ */
+ir_node *arch_dep_replace_div_by_const(ir_node *irn);
+
+/**
+ * Replace Mods with Shifts and Add/Subs and Mulh.
+ * This function is driven by the 3 parameters:
+ * - allow_mulhu
+ * - allow_mulhs
+ * - max_bits_for_mulh
+ *
+ * If irn is a Mod with a Const, the constant is inspected if it meets the
+ * requirements of the variables stated above. If a Shl/Add/Sub/Mulh
+ * sequence can be generated that meets these requirements, this expression
+ * is returned. In each other case irn is returned unmodified.
+ *
+ * @param irn The Firm node to inspect.
+ * @return A replacement expression for irn.
+ */
+ir_node *arch_dep_replace_mod_by_const(ir_node *irn);
+
+/**
+ * Replace DivMods with Shifts and Add/Subs and Mulh.
+ * This function is driven by the 3 parameters:
+ * - allow_mulhu
+ * - allow_mulhs
+ * - max_bits_for_mulh
+ *
+ * If irn is a DivMod with a Const, the constant is inspected if it meets the
+ * requirements of the variables stated above. If a Shl/Add/Sub/Mulh
+ * sequence can be generated that meets these requirements, this expression
+ * is returned. In each other case irn is returned unmodified.
+ *
+ * @param div After call contains the Firm node div result or NULL.
+ * @param mod After call contains the Firm node mod result or NULL.
+ * @param irn The Firm node to inspect.
+ */
+void arch_dep_replace_divmod_by_const(ir_node **div, ir_node **mod, ir_node *irn);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Construction and removal of interprocedural representation
+ * (explicit interprocedural dependencies).
+ * @author Hubert Schmid
+ * @date 09.06.2002
+ * @version $Id$
+ */
+#ifndef FIRM_IR_IRCGCONS_H
+#define FIRM_IR_IRCGCONS_H
+
+#include "firm_types.h"
+
+/** The state of the interprocedural view.
+ *
+ * This value indicates the state of the interprocedural view.
+ */
+typedef enum {
+ ip_view_no, /**< The interprocedural view is not constructed. There are no
+ view specific nodes (EndReg, Filter, Break ...) in any graph. */
+ ip_view_valid, /**< The interprocedural view is valid. */
+ ip_view_invalid /**< The interprocedural view is invalid. Specific nodes are
+ all still in the representation, but the graph is no more complete. */
+} ip_view_state;
+
+/** Return the current state of the interprocedural view. */
+ip_view_state get_irp_ip_view_state(void);
+/** Set the state of the interprocedural view to invalid. */
+void set_irp_ip_view_invalid(void);
+
+/** Construction of the interprocedural view.
+ *
+ * Construction of the interprocedural view. A prior analysis must have set
+ * all possible callees in the corresponding fields of Call nodes. Sets
+ * ip_view_valid in irp.
+ *
+ * @arg free_methods_arr: An array of all free methods, i.e., methods that
+ * are external visible. These methods get an 'Unknown'
+ * caller.
+ * @arg arr_len The number of free methods. */
+void cg_construct(int arr_len, ir_entity *free_methods_arr[]);
+
+
+/** Deconstruction of the interprocedural view. Reduces memory consumption of
+ the ir. Sets ip_view_no in irp. */
+void cg_destruct(void);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Removal of unreachable methods.
+ * @author Hubert Schmid
+ * @date 09.06.2002
+ * @version $Id$
+ * @summary
+ * (TODO: translate to english)
+ * Entfernen von nicht erreichbaren (aufrufbaren) Methoden. Die Menge
+ * der nicht erreichbaren Methoden wird aus der Abschätzung der
+ * Aufrufrelation bestimmt.
+ */
+#ifndef FIRM_IR_ICGOPT_H
+#define FIRM_IR_ICGOPT_H
+
+#include "firm_types.h"
+
+/* Entfernt alle Methoden, die von den Methoden aus "keep_arr"
+ * (bezgl. der Abschaetzung get_Call_callee) nicht erreichbar sind. Die
+ * Abschaetzung der Aufrufrelation muss entsprechend an den
+ * Call-Operationen gespeichert sein. Die "entity->link"s werden dabei
+ * ueberschrieben.
+ *
+ * Frees all interprocedural loop information. */
+void gc_irgs(int n_keep, ir_entity *keep_arr[]);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Various irnode constructors. Automatic construction of SSA
+ * representation.
+ * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Boris Boesler,
+ * Michael Beck
+ * @version $Id$
+ */
+
+/**@todo
+ Ideas for improvement:
+ -# Handle construction of exceptions more comfortable:
+ Add new constructors that pass the exception region (or better the
+ Phi for the memories, the ex. region can be found from there) as parameter,
+ constructor then adds all Proj nodes and returns the pointer
+ to the Proj node that selects the result of the arithmetic operation.
+ -# Maybe hide the exception region in a global variable, especially if
+ it is always unambiguous.
+*/
+
+/**
+ * @file
+ *
+ * documentation no more supported since 2001
+ *
+ * ir node construction.
+ *
+ * This file documents all datatypes and constructors needed to
+ * build a FIRM representation of a procedure. The constructors are
+ * also implemented in this file.
+ *
+ * The documentation also gives a short manual how to use the library.
+ *
+ * For extensive documentation of FIRM see UKA Techreport 1999-14.
+ *
+ *
+ * Three kinds of nodes
+ * --------------------
+ *
+ * There are three kinds of nodes known to the ir: entities,
+ * types, and ir_nodes
+ *
+ * + ir_nodes are the actual nodes of the FIRM intermediate representation.
+ * They represent operations on the data of the program and control flow
+ * operations.
+ *
+ * + entity ==> implemented in entity.h
+ * Refers to a single entity of the compiled program, e.g. a field of a
+ * class or a method. If a method or variable can not be assigned to
+ * a method or class or the like, it is a global object.
+ *
+ * + types ==> implemented in type.h
+ * With types type information is represented. There are several type
+ * nodes.
+ *
+ * Implementation of the FIRM operations: ir_node
+ * ----------------------------------------------
+ *
+ * Ir_nodes represent operations on the data of the program and control flow
+ * operations. Examples of ir_nodes: Add, Jmp, Cmp
+ *
+ * FIRM is a dataflow graph. A dataflow graph is a directed graph,
+ * so that every node has incoming and outgoing edges. A node is
+ * executable if every input at it's incoming edges is available.
+ * Execution of the dataflow graph is started at the Start node which
+ * has no incoming edges and ends when the End node executes, even if
+ * there are still executable or not executed nodes. (Is this true,
+ * or must all executable nodes be executed?) (There are exceptions
+ * to the dataflow paradigma that all inputs have to be available
+ * before a node can execute: Phi, Block. See UKA Techreport
+ * 1999-14.)
+ *
+ * The implementation of FIRM differs from the view as a dataflow
+ * graph. To allow fast traversion of the graph edges are
+ * implemented as C-pointers. Inputs to nodes are not ambiguous, the
+ * results can be used by several other nodes. Each input can be
+ * implemented as a single pointer to a predecessor node, outputs
+ * need to be lists of pointers to successors. Therefore a node
+ * contains pointers to it's predecessor so that the implementation is a
+ * dataflow graph with reversed edges. It has to be traversed bottom
+ * up.
+ *
+ * All nodes of the ir have the same basic structure. They are
+ * distinguished by a field containing the opcode.
+ *
+ * The fields of an ir_node:
+ *
+ * kind A firm_kind tag containing k_ir_node. This is useful for
+ * dynamically checking the type of a node.
+ *
+ * *op This ir_op gives the opcode as a tag and a string
+ * and the number of attributes of an ir_node. There is
+ * one statically allocated struct ir_op for each opcode.
+ *
+ * *mode The ir_mode of the operation represented by this firm
+ * node. The mode of the operation is the mode of it's
+ * result. A Firm mode is a datatype as known to the target,
+ * not a type of the source language.
+ *
+ * visit A flag for traversing the ir.
+ *
+ * **in An array with pointers to the node's predecessors.
+ *
+ * *link A pointer to an ir_node. With this pointer all Phi nodes
+ * are attached to a Block, i.e., a Block points to it's
+ * first Phi node, this node points to the second Phi node
+ * in the Block and so fourth. Used in mature_immBlock
+ * to find all Phi nodes to be matured. It's also used to
+ * annotate a node with a better, optimized version of it.
+ *
+ * attr An attr struct containing the attributes of the nodes. The
+ * attributes depend on the opcode of the node. The number
+ * of these attributes is given in op.
+ *
+ * The struct ir_op
+ * ----------------
+ * Not yet documented. See irop.h.
+ *
+ * The struct ir_mode
+ * ------------------
+ * Not yet documented. See irmode.h.
+ *
+ * GLOBAL VARIABLES -- now also fields of ir_graph.
+ * ================
+ *
+ * current_ir_graph Points to the current ir_graph. All constructors for
+ * nodes add nodes to this graph.
+ *
+ * ir_visited An int used as flag to traverse the ir_graph.
+ *
+ * block_visited An int used as a flag to traverse block nodes in the
+ * graph.
+ *
+ * Others not yet documented.
+ *
+ *
+ *
+ * CONSTRUCTOR FOR IR_GRAPH --> see irgraph.h
+ * ========================
+ *
+ *
+ * PROCEDURE TO CONSTRUCT AN IR GRAPH --> see also Firm tutorial
+ * ==================================
+ *
+ * This library supplies several interfaces to construct a FIRM graph for
+ * a program:
+ * - A "comfortable" interface generating SSA automatically. Automatically
+ * computed predecessors of nodes need not be specified in the constructors.
+ * (new_<Node> constructurs and a set of additional routines.)
+ * - A less comfortable interface where all predecessors except the block
+ * an operation belongs to need to be specified. SSA must be constructed
+ * by hand. (new_<Node> constructors and set_cur_block()). This interface
+ * is called "block oriented". It automatically calles the local optimizations
+ * for each new node.
+ * - An even less comfortable interface where the block needs to be specified
+ * explicitly. This is called the "raw" interface. (new_r_<Node>
+ * constructors). These nodes are not optimized.
+ *
+ * To use the functionality of the comfortable interface correctly the Front
+ * End needs to follow certain protocols. This is explained in the following.
+ * To build a correct IR with the other interfaces study the semantics of
+ * the firm node (See tech-reprot UKA 1999-14). For the construction of
+ * types and entities see the documentation in those modules.
+ *
+ * First the Frontend needs to decide which variables and values used in
+ * a procedure can be represented by dataflow edges. These are variables
+ * that need not be saved to memory as they cause no side effects visible
+ * out of the procedure. Often these are all compiler generated
+ * variables and simple local variables of the procedure as integers,
+ * reals and pointers. The frontend has to count and number these variables.
+ *
+ * First an ir_graph needs to be constructed with new_ir_graph. The
+ * constructor gets the number of local variables. The graph is hold in the
+ * global variable irg.
+ *
+ * Now the construction of the procedure can start. Several basic blocks can
+ * be constructed in parallel, but the code within each block needs to
+ * be constructed (almost) in program order.
+ *
+ * A global variable holds the current basic block. All (non block) nodes
+ * generated are added to this block. The current block can be set with
+ * set_cur_block(block). If several blocks are constructed in parallel block
+ * switches need to be performed constantly.
+ *
+ * To generate a Block node (with the comfortable interface) it's predecessor
+ * control flow nodes need not be known. In case of cyclic control flow these
+ * can not be known when the block is constructed. With add_immBlock_pred(block,
+ * cfnode) predecessors can be added to the block. If all predecessors are
+ * added to the block mature_immBlock(b) needs to be called. Calling mature_immBlock
+ * early improves the efficiency of the Phi node construction algorithm.
+ * But if several blocks are constructed at once, mature_immBlock must only
+ * be called after performing all set_values and set_stores in the block!
+ * (See documentation of new_immBlock constructor.)
+ *
+ * The constructors of arithmetic nodes require that their predecessors
+ * are mentioned. Sometimes these are available in the Frontend as the
+ * predecessors have just been generated by the frontend. If they are local
+ * values the predecessors can be obtained from the library with a call to
+ * get_value(local_val_nr). (local_val_nr needs to be administered by
+ * the Frontend.) A call to get_value triggers the generation of Phi nodes.
+ * If an arithmetic operation produces a local value this value needs to be
+ * passed to the library by set_value(node, local_val_nr).
+ * In straight line code these two operations just remember and return the
+ * pointer to nodes producing the value. If the value passes block boundaries
+ * Phi nodes can be inserted.
+ * Similar routines exist to manage the Memory operands: set_store and
+ * get_store.
+ *
+ * Several nodes produce more than one result. An example is the Div node.
+ * Such nodes return tuples of values. From these individual values can be
+ * extracted by proj nodes.
+ *
+ * The following example illustrates the construction of a simple basic block
+ * with two predecessors stored in variables cf_pred1 and cf_pred2, containing
+ * the code
+ * a = a div a;
+ * and finally jumping to an other block. The variable a got the local_val_nr
+ * 42 by the frontend.
+ *
+ * ir_node *this_block, *cf_pred1, *cf_pred2, *a_val, *mem, *div, *res, *cf_op;
+ *
+ * this_block = new_immBlock();
+ * add_immBlock_pred(this_block, cf_pred1);
+ * add_immBlock_pred(this_block, cf_pred2);
+ * mature_immBlock(this_block);
+ * a_val = get_value(42, mode_Iu);
+ * mem = get_store();
+ * div = new_Div(mem, a_val, a_val, mode_Iu);
+ * mem = new_Proj(div, mode_M, pn_Div_M); * for the numbers for Proj see docu *
+ * res = new_Proj(div, mode_Iu, pn_Div_res);
+ * set_store(mem);
+ * set_value(res, 42);
+ * cf_op = new_Jmp();
+ *
+ * For further information look at the documentation of the nodes and
+ * constructors and at the paragraph COPING WITH DATA OBJECTS at the
+ * end of this documentation.
+ *
+ * The comfortable interface contains the following routines further explained
+ * below:
+ *
+ * ir_node *new_immBlock (void);
+ * ir_node *new_Start (void);
+ * ir_node *new_End (void);
+ * ir_node *new_Jmp (void);
+ * ir_node *new_IJmp (ir_node *tgt);
+ * ir_node *new_Cond (ir_node *c);
+ * ir_node *new_Return (ir_node *store, int arity, ir_node **in);
+ * ir_node *new_Const (ir_mode *mode, tarval *con);
+ * ir_node *new_SymConst (symconst_symbol value, symconst_kind kind);
+ * ir_node *new_simpleSel (ir_node *store, ir_node *objptr, ir_entity *ent);
+ * ir_node *new_Sel (ir_node *store, ir_node *objptr, int arity,
+ * ir_node **in, ir_entity *ent);
+ * ir_node *new_Call (ir_node *store, ir_node *callee, int arity,
+ * ir_node **in, type_method *type);
+ * ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode);
+ * ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode);
+ * ir_node *new_Minus (ir_node *op, ir_mode *mode);
+ * ir_node *new_Mul (ir_node *op1, ir_node *op2, ir_mode *mode);
+ * ir_node *new_Quot (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
+ * ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
+ * ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
+ * ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
+ * ir_node *new_Abs (ir_node *op, ir_mode *mode);
+ * ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode);
+ * ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode);
+ * ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode);
+ * ir_node *new_Not (ir_node *op, ir_mode *mode);
+ * ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode);
+ * ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode);
+ * ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode);
+ * ir_node *new_Rot (ir_node *op, ir_node *k, ir_mode *mode);
+ * ir_node *new_Cmp (ir_node *op1, ir_node *op2);
+ * ir_node *new_Conv (ir_node *op, ir_mode *mode);
+ * ir_node *new_Cast (ir_node *op, ir_type *to_tp);
+ * ir_node *new_Carry (ir_node *op1, ir_node *op2, ir_mode *mode);
+ * ir_node *new_Borrow (ir_node *op1, ir_node *op2, ir_mode *mode);
+ * ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode);
+ * ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val);
+ * ir_node *new_Alloc (ir_node *store, ir_node *size, ir_type *alloc_type,
+ * where_alloc where);
+ * ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size,
+ * ir_type *free_type, where_alloc where);
+ * ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj);
+ * ir_node *new_NoMem (void);
+ * ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
+ * ir_node *new_Psi (int arity, ir_node *conds[], ir_node *vals[], ir_mode *mode);
+ * ir_node *new_CopyB (ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
+ * ir_node *new_InstOf (ir_node *store, ir_node obj, ir_type *ent);
+ * ir_node *new_Raise (ir_node *store, ir_node *obj);
+ * ir_node *new_Bound (ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
+ * ir_node *new_Pin (ir_node *node);
+ *
+ * void add_immBlock_pred (ir_node *block, ir_node *jmp);
+ * void mature_immBlock (ir_node *block);
+ * void set_cur_block (ir_node *target);
+ * ir_node *get_value (int pos, ir_mode *mode);
+ * void set_value (int pos, ir_node *value);
+ * ir_node *get_store (void);
+ * void set_store (ir_node *store);
+ * keep_alive (ir_node ka)
+ *
+ * IR_NODES AND CONSTRUCTORS FOR IR_NODES
+ * =======================================
+ *
+ * All ir_nodes are defined by a common data structure. They are distinguished
+ * by their opcode and differ in the number of their attributes.
+ *
+ * The constructor for the block node sets current_block to itself.
+ * Const nodes are always added to the start block.
+ * All other constructors add the created node to the current_block.
+ * swich_block(block) allows to set the current block to block.
+ *
+ * Watch for my inconsistent use of input and predecessor (dataflow view)
+ * and `the node points to' (implementation view).
+ *
+ * The following description of the nodes lists four properties them if these
+ * are of interest:
+ * - the parameters to the constructor
+ * - the inputs of the Firm node
+ * - the outputs of the Firm node
+ * - attributes to the node
+ *
+ * ------------
+ *
+ * ir_node *new_immBlock (void)
+ * ----------------------------
+ *
+ * Creates a new block. Sets current_block to itself. When a new block is
+ * created it cannot be known how many predecessors this block will have in the
+ * control flow graph. Therefore the list of inputs can not be fixed at
+ * creation. Predecessors can be added with add_immBlock_pred (block, control flow
+ * operation). With every added predecessor the number of inputs to Phi nodes
+ * also changes.
+ *
+ * The block can be completed by mature_immBlock(block) if all predecessors are
+ * known. If several blocks are built at once, mature_immBlock can only be called
+ * after set_value has been called for all values that are life at the end
+ * of the block. This is necessary so that Phi nodes created mature_immBlock
+ * get the right predecessors in case of cyclic dependencies. If all set_values
+ * of this block are called after maturing it and before calling get_value
+ * in some block that is control flow dependent on this block, the construction
+ * is correct.
+ *
+ * Example for faulty ir construction: (draw the graph on a paper and you'll
+ * get it ;-)
+ *
+ * block_before_loop = new_block();
+ * set_value(x);
+ * mature_immBlock(block_before_loop);
+ * before2header = new_Jmp;
+ *
+ * loop_header = new_block ();
+ * header2body - new_Jmp();
+ *
+ * loop_body = new_block ();
+ * body2header = new_Jmp();
+ *
+ * add_immBlock_pred(loop_header, before2header);
+ * add_immBlock_pred(loop_header, body2header);
+ * add_immBlock_pred(loop_body, header2body);
+ *
+ * mature_immBlock(loop_header);
+ * mature_immBlock(loop_body);
+ *
+ * get_value(loop_body, x); // gets the Phi in loop_header
+ * set_value(loop_header, x); // sets the value the above get_value should
+ * // have returned!!!
+ *
+ * Mature_immBlock also fixes the number of inputs to the Phi nodes. Mature_immBlock
+ * should be called as early as possible, as afterwards the generation of Phi
+ * nodes is more efficient.
+ *
+ * Inputs:
+ * There is an input for each control flow predecessor of the block.
+ * The input points to an instruction producing an output of type X.
+ * Possible predecessors: Start, Jmp, Cond, Raise or Return or any node
+ * possibly causing an exception. (Often the real predecessors are Projs.)
+ * Output:
+ * Mode BB (R), all nodes belonging to this block should consume this output.
+ * As they are strict (except Block and Phi node) it is a necessary condition
+ * that the block node executed before any other node in this block executes.
+ * Attributes:
+ * block.matured Indicates whether the block is mature.
+ * block.**graph_arr
+ * This attribute contains all local values valid in this
+ * block. This is needed to build the Phi nodes and removed
+ * if the graph is complete. This field is used by the
+ * internal construction algorithm and should not be accessed
+ * from outside.
+ *
+ *
+ * ir_node *new_Block (int arity, ir_node **in)
+ * --------------------------------------------
+ *
+ * Creates a new Block with the given list of predecessors. This block
+ * is mature. As other constructors calls optimization and vrfy for the
+ * block. If one of the predecessors is Unknown (as it has to be filled in
+ * later) optimizations are skipped. This is necessary to
+ * construct Blocks in loops. Leaving Unknown in the Block after finishing
+ * the construction may have strange effects, especially for interprocedural
+ * representation and analysis.
+ *
+ *
+ * CONTROL FLOW OPERATIONS
+ * -----------------------
+ *
+ * In each block there must be exactly one of the control flow
+ * operations Start, End, Jmp, Cond, Return or Raise. The output of a
+ * control flow operation points to the block to be executed next.
+ *
+ * ir_node *new_Start (void)
+ * -------------------------
+ *
+ * Creates a start node. Not actually needed public. There is only one such
+ * node in each procedure which is automatically created by new_ir_graph.
+ *
+ * Inputs:
+ * No inputs except the block it belogns to.
+ * Output:
+ * A tuple of 4 (5, 6) distinct values. These are labeled by the following
+ * projection numbers (pn_Start):
+ * * pn_Start_X_initial_exec mode X, points to the first block to be exe * cuted.
+ * * pn_Start_M mode M, the global store
+ * * pn_Start_P_frame_base mode P, a pointer to the base of the proce * dures stack frame.
+ * * pn_Start_P_globals mode P, a pointer to the part of the memory * containing_all_ global things.
+ * * pn_Start_T_args mode T, a tuple containing all arguments of * the procedure.
+ *
+ *
+ * ir_node *new_End (void)
+ * -----------------------
+ *
+ * Creates an end node. Not actually needed public. There is only one such
+ * node in each procedure which is automatically created by new_ir_graph.
+ *
+ * Inputs:
+ * No inputs except the block it belongs to.
+ * Output:
+ * No output.
+ *
+ * ir_node *new_Jmp (void)
+ * -----------------------
+ *
+ * Creates a Jmp node.
+ *
+ * Inputs:
+ * The block the node belongs to
+ * Output:
+ * Control flow to the next block.
+ *
+ * ir_node *new_IJmp (ir_node *tgt)
+ * -----------------------
+ *
+ * Creates an IJmp node.
+ *
+ * Inputs:
+ * The node that represents the target jump address
+ * Output:
+ * Control flow to an unknown target, must be pinned by
+ * the End node.
+ *
+ * ir_node *new_Cond (ir_node *c)
+ * ------------------------------
+ *
+ * Creates a Cond node. There are two versions of this node.
+ *
+ * The Boolean Cond:
+ * Input:
+ * A value of mode b.
+ * Output:
+ * A tuple of two control flows. The first is taken if the input is
+ * false, the second if it is true.
+ *
+ * The Switch Cond:
+ * Input:
+ * A value of mode I_u. (i)
+ * Output:
+ * A tuple of n control flows. If the Cond's input is i, control
+ * flow will procede along output i. If the input is >= n control
+ * flow proceeds along output n.
+ *
+ * ir_node *new_Return (ir_node *store, int arity, ir_node **in)
+ * -------------------------------------------------------------
+ *
+ * The return node has as inputs the results of the procedure. It
+ * passes the control flow to the end_block.
+ *
+ * Inputs:
+ * The memory state.
+ * All results.
+ * Output
+ * Control flow to the end block.
+ *
+ * ---------
+ *
+ * ir_node *new_Const (ir_mode *mode, tarval *con)
+ * -----------------------------------------------
+ *
+ * Creates a constant in the constant table and adds a Const node
+ * returning this value to the start block.
+ *
+ * Parameters:
+ * *mode The mode of the constant.
+ * *con Points to an entry in the constant table.
+ * This pointer is added to the attributes of
+ * the node (self->attr.con)
+ * Inputs:
+ * No inputs except the block it belogns to.
+ * Output:
+ * The constant value.
+ * Attribute:
+ * attr.con A tarval* pointer to the proper entry in the constant
+ * table.
+ *
+ * ir_node *new_SymConst (union symconst_symbol value, symconst_addr_ent kind)
+ * ---------------------------------------------------------------------------
+ *
+ * There are three kinds of symbolic constants:
+ * symconst_type_tag The symbolic constant represents a type tag.
+ * symconst_type_size The symbolic constant represents the size of a type.
+ * symconst_type_align The symbolic constant represents the alignment of a type.
+ * symconst_addr_name Information for the linker, e.g. the name of a global
+ * variable.
+ * symconst_addr_name The symbolic constant represents the address of an entity.
+ *
+ * To represent a pointer to an entity that is represented by an entity
+ * datastructure don't use
+ * new_SymConst((type_or_id*)get_entity_ld_ident(ent), symconst_addr_name);.
+ * Use a real const instead:
+ * new_SymConst(ent, symconst_addr_ent);
+ * This makes the Constant independent of name changes of the entity due to
+ * mangling.
+ *
+ * Parameters
+ * kind The kind of the symbolic constant: type_tag, size or link_info.
+ * *type_or_id Points to the type the tag stands for or to the type
+ * whose size is represented by the constant or to an ident
+ * representing the linkage info.
+ *
+ * Inputs:
+ * No inputs except the block it belogns to.
+ * Output:
+ * An unsigned integer (I_u) or a pointer (P).
+ *
+ * Attributes:
+ * attr.i.num The symconst_addr_ent, i.e. one of
+ * -symconst_type_tag
+ * -symconst_type_size
+ * -symconst_type_align
+ * -symconst_addr_name
+ *
+ * If the attr.i.num is symconst_type_tag, symconst_type_size or symconst_type_align,
+ * the node contains an attribute:
+ *
+ * attr.i.*type, a pointer to a type_class. The mode of the node is mode_Is.
+ * if it is linkage_ptr_info it contains
+ * attr.i.*ptrinfo, an ident holding information for the linker. The mode
+ * of the node is mode_P_mach.
+ *
+ * ---------------
+ *
+ * ir_node *new_simpleSel (ir_node *store, ir_node *frame, ir_entity *sel)
+ * -----------------------------------------------------------------------
+ *
+ *
+ * Selects an entity from a compound type. This entity can be a field or
+ * a method.
+ *
+ * Parameters:
+ * *store The memory in which the object the entity should be selected
+ * from is allocated.
+ * *frame The pointer to the object.
+ * *sel The entity to select.
+ *
+ * Inputs:
+ * The memory containing the object.
+ * A pointer to the object.
+ * An unsigned integer.
+ * Output:
+ * A pointer to the selected entity.
+ * Attributes:
+ * attr.sel Pointer to the entity
+ *
+ *
+ * ir_node *new_Sel (ir_node *store, ir_node *frame, int arity, ir_node **in,
+ * --------------------------------------------------------------------------
+ * ir_entity *sel)
+ * ---------------
+ *
+ * Selects a field from an array type. The entity has as owner the array, as
+ * type the arrays element type. The indices to access an array element are
+ * given also.
+ *
+ * Parameters:
+ * *store The memory in which the object the entity should be selected from
+ * is allocated.
+ * *frame The pointer to the object.
+ * *arity number of array indices.
+ * *in array with index inputs to the node.
+ * *sel The entity to select.
+ *
+ * Inputs:
+ * The memory containing the object.
+ * A pointer to the object.
+ * As much unsigned integer as there are array expressions.
+ * Output:
+ * A pointer to the selected entity.
+ * Attributes:
+ * attr.sel Pointer to the entity
+ *
+ * The constructors new_Sel and new_simpleSel generate the same ir nodes.
+ * simpleSel just sets the arity of the index inputs to zero.
+ *
+ *
+ * ARITHMETIC OPERATIONS
+ * ---------------------
+ *
+ * ir_node *new_Call (ir_node *store, ir_node *callee, int arity, ir_node **in,
+ * ----------------------------------------------------------------------------
+ * type_method *type)
+ * ------------------
+ *
+ * Creates a procedure call.
+ *
+ * Parameters
+ * *store The actual store.
+ * *callee A pointer to the called procedure.
+ * arity The number of procedure parameters.
+ * **in An array with the pointers to the parameters.
+ * The constructor copies this array.
+ * *type Type information of the procedure called.
+ *
+ * Inputs:
+ * The store, the callee and the parameters.
+ * Output:
+ * A tuple containing the eventually changed store and the procedure
+ * results.
+ * Attributes:
+ * attr.call Contains the type information for the procedure.
+ *
+ *
+ * ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode)
+ * ------------------------------------------------------------
+ *
+ * Trivial.
+ *
+ * ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode)
+ * ------------------------------------------------------------
+ *
+ * Trivial.
+ *
+ * ir_node *new_Minus (ir_node *op, ir_mode *mode)
+ * -----------------------------------------------
+ *
+ * Unary Minus operations on integer and floating point values.
+ *
+ * ir_node *new_Mul (ir_node *op1, ir_node *op2, ir_mode *mode)
+ * ------------------------------------------------------------
+ *
+ * Trivial.
+ *
+ * ir_node *new_Quot (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode)
+ * -----------------------------------------------------------------------------
+ *
+ * Quot performs exact division of floating point numbers. It's mode
+ * is Tuple, the mode of the result must match the Proj mode
+ * that extracts the result of the arithmetic operations.
+ *
+ * Inputs:
+ * The store needed to model exceptions and the two operands.
+ * Output:
+ * A tuple containing a memory and a execution for modeling exceptions
+ * and the result of the arithmetic operation.
+ *
+ * ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode)
+ * -------------------------------------------------------------------------------
+ *
+ * Performs Div and Mod on integer values.
+ *
+ * Output:
+ * A tuple containing a memory and a execution for modeling exceptions
+ * and the two result of the arithmetic operations.
+ *
+ * ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode)
+ * ----------------------------------------------------------------------------
+ *
+ * Trivial.
+ *
+ * ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode)
+ * ----------------------------------------------------------------------------
+ *
+ * Trivial.
+ *
+ * ir_node *new_Abs (ir_node *op, ir_mode *mode)
+ * ---------------------------------------------
+ *
+ * Trivial.
+ *
+ * ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode)
+ * ------------------------------------------------------------
+ *
+ * Trivial.
+ *
+ * ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode)
+ * -----------------------------------------------------------
+ *
+ * Trivial.
+ *
+ * ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode)
+ * ------------------------------------------------------------
+ *
+ * Trivial.
+ *
+ * ir_node *new_Not (ir_node *op, ir_mode *mode)
+ * ---------------------------------------------
+ *
+ * This node constructs a constant where all bits are set to one
+ * and a Eor of this constant and the operator. This simulates a
+ * Not operation.
+ *
+ * ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode)
+ * ---------------------------------------------------------
+ *
+ * Trivial.
+ *
+ * ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode)
+ * ---------------------------------------------------------
+ *
+ * Logic shift right, i.e., zero extended.
+ *
+ *
+ * ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode)
+ * ----------------------------------------------------------
+ *
+ * Arithmetic shift right, i.e., sign extended.
+ *
+ * ir_node *new_Rot (ir_node *op, ir_node *k, ir_mode *mode)
+ * ---------------------------------------------------------
+ *
+ * Rotates the operand to the (right??) by k bits.
+ *
+ * ir_node *new_Carry (ir_node *op1, ir_node *op2, ir_mode *mode)
+ * ------------------------------------------------------------
+ *
+ * Calculates the Carry value for integer addition. Used only
+ * in lowering code.
+ *
+ * ir_node *new_Borrow (ir_node *op1, ir_node *op2, ir_mode *mode)
+ * ------------------------------------------------------------
+ *
+ * Calculates the Borrow value for integer substraction. Used only
+ * in lowering code.
+ *
+ * ir_node *new_Conv (ir_node *op, ir_mode *mode)
+ * ---------------------------------------------
+ *
+ * Mode conversion. For allowed conversions see UKA Tech Report
+ * 1999-14.
+ *
+ * ir_node *new_Cmp (ir_node *op1, ir_node *op2)
+ * ---------------------------------------------
+ *
+ * Input:
+ * The two values to be compared.
+ * Output:
+ * A 16-tuple containing the results of the 16 different comparisons.
+ * The following is a list giving the comparisons and a projection
+ * number (pn_Cmp) to use in Proj nodes to extract the proper result.
+ * pn_Cmp_False false
+ * pn_Cmp_Eq equal
+ * pn_Cmp_Lt less
+ * pn_Cmp_Le less or equal
+ * pn_Cmp_Gt greater
+ * pn_Cmp_Ge greater of equal
+ * pn_Cmp_Lg less or greater
+ * pn_Cmp_Leg less, equal or greater = ordered
+ * pn_Cmp_Uo unordered
+ * pn_Cmp_Ue unordered or equal
+ * pn_Cmp_Ul unordered or less
+ * pn_Cmp_Ule unordered, less or equal
+ * pn_Cmp_Ug unordered or greater
+ * pn_Cmp_Uge unordered, greater or equal
+ * pn_Cmp_Ne unordered, less or greater = not equal
+ * pn_Cmp_True true
+ *
+ *
+ *
+ * ------------
+ *
+ * In general, Phi nodes are automaitcally inserted. In some cases, if
+ * all predecessors of a block are known, an explicit Phi node constructor
+ * is needed. E.g., to construct a FIRM graph for a statement as
+ * a = (b==c) ? 2 : 5;
+ *
+ * ir_node *new_Phi (int arity, ir_node **in, ir_mode *mode)
+ * ---------------------------------------------------------
+ *
+ * Creates a Phi node. The in's order has to correspond to the order
+ * of in's of current_block. This is not checked by the library!
+ * If one of the predecessors is Unknown (as it has to be filled in
+ * later) optimizations are skipped. This is necessary to
+ * construct Phi nodes in loops. Leaving Unknown in the Phi after finishing
+ * the construction may have strange effects, especially for interprocedural
+ * representation and analysis.
+ *
+ * Parameter
+ * arity number of predecessors
+ * **in array with predecessors
+ * *mode The mode of it's inputs and output.
+ * Inputs:
+ * A Phi node has as many inputs as the block it belongs to.
+ * Each input points to a definition of the same value on a
+ * different path in the control flow.
+ * Output
+ * The definition valid in this block.
+ *
+ * ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode)
+ * -----------------------------------------------------------------------------
+ *
+ * Creates a Mux node. This node implements the following semantic:
+ * If the sel node (which must be of mode_b) evaluates to true, its value is
+ * ir_true, else ir_false;
+ *
+ *
+ * ir_node *new_Psi (int arity, ir_node *conds[], ir_node *vals[], ir_mode *mode)
+ * -----------------------------------------------------------------------------
+ *
+ * Creates a Psi node. This node implements the following semantic:
+ * Enter it here!!!
+ *
+ *
+ * OPERATIONS TO MANAGE MEMORY EXPLICITLY
+ * --------------------------------------
+ *
+ * ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode)
+ * ----------------------------------------------------------------
+ *
+ * The Load operation reads a value from memory.
+ *
+ * Parameters:
+ * *store The current memory.
+ * *addr A pointer to the variable to be read in this memory.
+ * *mode The mode of the value to be loaded.
+ *
+ * Inputs:
+ * The memory and a pointer to a variable in this memory.
+ * Output:
+ * A tuple of the memory, a control flow to be taken in case of
+ * an exception and the loaded value.
+ *
+ * ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val)
+ * ----------------------------------------------------------------
+ *
+ * The Store operation writes a value to a variable in memory.
+ *
+ * Inputs:
+ * The memory, a pointer to a variable in this memory and the value
+ * to write to this variable.
+ * Output:
+ * A tuple of the changed memory and a control flow to be taken in
+ * case of an exception.
+ *
+ * ir_node *new_Alloc (ir_node *store, ir_node *size, ir_type *alloc_type,
+ * -----------------------------------------------------------------------
+ * where_alloc where)
+ * ------------------
+ *
+ * The Alloc node allocates a new variable. It can be specified whether the
+ * variable should be allocated to the stack or to the heap.
+ *
+ * Parameters:
+ * *store The memory which shall contain the new variable.
+ * ** *size The number of bytes to allocate. Old. **
+ * *size We decided that the size easily can be derived from the type.
+ * This field is for allocating arrays, i.e., it gives the multiple
+ * of the size of alloc_type to allocate memory for.
+ * *alloc_type The type of the allocated variable.
+ * where Where to allocate the variable, either heap_alloc or stack_alloc.
+ *
+ * Inputs:
+ * A memory and an unsigned integer.
+ * Output:
+ * A tuple of the changed memory, a control flow to be taken in
+ * case of an exception and the pointer to the new variable.
+ * Attributes:
+ * a.where Indicates where the variable is allocated.
+ * a.*type A pointer to the class the allocated data object
+ * belongs to.
+ *
+ * ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size, ir_type *free_type,
+ * -----------------------------------------------------------------------------------
+ * where_alloc where)
+ * ------------------
+ *
+ * The Free node frees memory of the given variable.
+ *
+ * Parameters:
+ * *store The memory which shall contain the new variable.
+ * *ptr The pointer to the object to free.
+ * *size The number of objects of type free_type to free in a sequence.
+ * *free_type The type of the freed variable.
+ * where Where the variable was allocated, either heap_alloc or stack_alloc.
+ *
+ * Inputs:
+ * A memory, a pointer and an unsigned integer.
+ * Output:
+ * The changed memory.
+ * Attributes:
+ * f.*type A pointer to the type information of the freed data object.
+ *
+ * Not Implemented!
+ *
+ * ir_node *new_Sync (int arity, ir_node **in)
+ * -------------------------------------------
+ *
+ * The Sync operation unifies several partial memory blocks. These blocks
+ * have to be pairwise disjunct or the values in common locations have to
+ * be identical. This operation allows to specify all operations that eventually
+ * need several partial memory blocks as input with a single entrance by
+ * unifying the memories with a preceding Sync operation.
+ *
+ * Parameters
+ * arity The number of memories to synchronize.
+ * **in An array of pointers to nodes that produce an output of
+ * type memory.
+ * Inputs
+ * Several memories.
+ * Output
+ * The unified memory.
+ *
+ *
+ * SPECIAL OPERATIONS
+ * ------------------
+ *
+ * ir_node *new_Bad (void)
+ * -----------------------
+ *
+ * Returns the unique Bad node current_ir_graph->bad.
+ * This node is used to express results of dead code elimination.
+ *
+ * ir_node *new_NoMem (void)
+ * -----------------------------------------------------------------------------------
+ *
+ * Returns the unique NoMem node current_ir_graph->no_mem.
+ * This node is used as input for operations that need a Memory, but do not
+ * change it like Div by const != 0, analyzed calls etc.
+ *
+ * ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj)
+ * ----------------------------------------------------------
+ *
+ * Selects one entry of a tuple. This is a hidden edge with attributes.
+ *
+ * Parameters
+ * *arg A node producing a tuple.
+ * *mode The mode of the value to project.
+ * proj The position of the value in the tuple.
+ * Input:
+ * The tuple.
+ * Output:
+ * The value.
+ *
+ * ir_node *new_Tuple (int arity, ir_node **in)
+ * --------------------------------------------
+ *
+ * Builds a Tuple from single values. This is needed to implement
+ * optimizations that remove a node that produced a tuple. The node can be
+ * replaced by the Tuple operation so that the following Proj nodes have not to
+ * be changed. (They are hard to find due to the implementation with pointers
+ * in only one direction.) The Tuple node is smaller than any other
+ * node, so that a node can be changed into a Tuple by just changing it's
+ * opcode and giving it a new in array.
+ *
+ * Parameters
+ * arity The number of tuple elements.
+ * **in An array containing pointers to the nodes producing the
+ * tuple elements.
+ *
+ * ir_node *new_Id (ir_node *val, ir_mode *mode)
+ * ---------------------------------------------
+ *
+ * The single output of the Id operation is it's input. Also needed
+ * for optimizations.
+ *
+ *
+ * HIGH LEVEL OPERATIONS
+ * ---------------------
+ *
+ * ir_node *new_CopyB (ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type)
+ * -----------------------------------------------------------------------------------
+ *
+ * Describes a high level block copy of a compound type from address src to
+ * address dst. Must be lowered to a Call to a runtime memory copy function.
+ *
+ *
+ * HIGH LEVEL OPERATIONS: Exception Support
+ * ----------------------------------------
+ * See TechReport 1999-14, chapter Exceptions.
+ *
+ * ir_node *new_InstOf(ir_node *store, ir_node *ptr, ir_type *type);
+ * -----------------------------------------------------------------------------------
+ *
+ * Describes a high level type check. Must be lowered to a Call to a runtime check
+ * function.
+ *
+ * ir_node *new_Raise (ir_node *store, ir_node *obj)
+ * -------------------------------------------------
+ *
+ * Raises an exception. Unconditional change of control flow. Writes
+ * an explicit Except variable to memory to pass it to the exception
+ * handler. Must be lowered to a Call to a runtime check
+ * function.
+ *
+ * Inputs:
+ * The memory state.
+ * A pointer to the Except variable.
+ * Output:
+ * A tuple of control flow and the changed memory state. The control flow
+ * points to the exception handler if it is definied in this procedure,
+ * else it points to the end_block.
+ *
+ * ir_node *new_Bound (ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
+ * -----------------------------------------------------------------------------------
+ *
+ * Describes a high level bounds check. Must be lowered to a Call to a runtime check
+ * function.
+ *
+ * ir_node *new_Pin (ir_node *node);
+ * -----------------------------------------------------------------------------------
+ *
+ * Pin the value of the node node in the current block No users of the Pin node can
+ * float above the Block of the Pin. The node cannot float behind this block. Often
+ * used to Pin the NoMem node.
+ *
+ *
+ * COPING WITH DATA OBJECTS
+ * ========================
+ *
+ * Two kinds of data objects have to be distinguished for generating
+ * FIRM. First there are local variables other than arrays that are
+ * known to be alias free. Second there are all other data objects.
+ * For the first a common SSA representation is built, the second
+ * are modeled by saving them to memory. The memory is treated as
+ * a single local variable, the alias problem is hidden in the
+ * content of this variable.
+ *
+ * All values known in a Block are listed in the block's attribute,
+ * block.**graph_arr which is used to automatically insert Phi nodes.
+ * The following two functions can be used to add a newly computed value
+ * to the array, or to get the producer of a value, i.e., the current
+ * live value.
+ *
+ * inline void set_value (int pos, ir_node *value)
+ * -----------------------------------------------
+ *
+ * Has to be called for every assignment to a local variable. It
+ * adds the value to the array of used values at position pos. Pos
+ * has to be a unique identifier for an entry in the procedure's
+ * definition table. It can be used to access the value again.
+ * Requires current_block to be set correctly.
+ *
+ * ir_node *get_value (int pos, ir_mode *mode)
+ * -------------------------------------------
+ *
+ * Returns the node defining the value referred to by pos. If the
+ * value is not defined in this block a Phi node is generated and
+ * all definitions reaching this Phi node are collected. It can
+ * happen that the algorithm allocates an unnecessary Phi node,
+ * e.g. if there is only one definition of this value, but this
+ * definition reaches the currend block on several different
+ * paths. This Phi node will be eliminated if optimizations are
+ * turned on right after it's creation.
+ * Requires current_block to be set correctly.
+ *
+ * There are two special routines for the global store:
+ *
+ * void set_store (ir_node *store)
+ * -------------------------------
+ *
+ * Adds the store to the array of known values at a reserved
+ * position.
+ * Requires current_block to be set correctly.
+ *
+ * ir_node *get_store (void)
+ * -------------------------
+ *
+ * Returns the node defining the actual store.
+ * Requires current_block to be set correctly.
+ *
+ *
+ * inline void keep_alive (ir_node *ka)
+ * ------------------------------------
+ *
+ * Keep this node alive because it is (might be) not in the control
+ * flow from Start to End. Adds the node to the list in the end
+ * node.
+ *
+ */
+#ifndef FIRM_IR_IRCONS_H
+#define FIRM_IR_IRCONS_H
+
+#include "firm_common.h"
+#include "irnode.h"
+#include "irgraph.h"
+#include "dbginfo.h"
+
+/*-------------------------------------------------------------------------*/
+/* The raw interface */
+/*-------------------------------------------------------------------------*/
+
+/** Constructor for a Block node.
+ *
+ * Constructs a mature block with the given predecessors. Use Unknown
+ * nodes as predecessors to construct a block if the number of
+ * predecessors is known, but not the predecessors themselves. This
+ * constructor does not set current_block. It not be used with
+ * automatic Phi node construction.
+ *
+ * @param *db A Pointer for debug information.
+ * @param irg The ir graph the block belongs to.
+ * @param arity The number of control predecessors.
+ * @param in[] An array of control predecessors. The length of
+ * the array must be 'arity'. The constructor copies this array.
+ */
+ir_node *new_rd_Block (dbg_info *db, ir_graph *irg, int arity, ir_node *in[]);
+
+/** Constructor for a Start node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ */
+ir_node *new_rd_Start (dbg_info *db, ir_graph *irg, ir_node *block);
+
+/** Constructor for a End node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ */
+ir_node *new_rd_End (dbg_info *db, ir_graph *irg, ir_node *block);
+
+/** Constructor for a Jmp node.
+ *
+ * Jmp represents control flow to a single control successor.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ */
+ir_node *new_rd_Jmp (dbg_info *db, ir_graph *irg, ir_node *block);
+
+/** Constructor for an IJmp node.
+ *
+ * IJmp represents control flow to a single control successor not
+ * statically known i.e. an indirect Jmp.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *tgt The ir node representing the target address.
+ */
+ir_node *new_rd_IJmp (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *tgt);
+
+/** Constructor for a Break node.
+ *
+ * Break represents control flow to a single control successor just as Jmp.
+ * The blocks separated by a break may not be concatenated by an optimization.
+ * It is used for the interprocedural representation where blocks are parted
+ * behind Call nodes to represent the control flow to called procedures.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belong to.
+ * @param *block The block the node belong to.
+ */
+ir_node *new_rd_Break (dbg_info *db, ir_graph *irg, ir_node *block);
+
+/** Constructor for a Cond node.
+ *
+ * If c is mode_b represents a conditional branch (if/else). If c is
+ * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
+ * node, default Proj is 0.)
+ *
+ * This is not consistent: Input to Cond is Is, Proj has as proj number
+ * longs.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *c The conditions parameter. Can be of mode b or I_u.
+ */
+ir_node *new_rd_Cond (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *c);
+
+/** Constructor for a Return node.
+ *
+ * Returns the memory an zero or more return values. Only node that
+ * can end regular control flow.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *store The state of memory.
+ * @param arity Number of return values.
+ * @param *in Array of length arity with return values. The constructor copies this array.
+ */
+ir_node *new_rd_Return (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *store, int arity, ir_node *in[]);
+
+/** Constructor for a Const_type node.
+ *
+ * The constant represents a target value. This constructor sets high
+ * level type information for the constant value.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *mode The mode of the operands and results.
+ * @param *con Points to an entry in the constant table.
+ * @param *tp The type of the constant.
+ */
+ir_node *new_rd_Const_type (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_mode *mode, tarval *con, ir_type *tp);
+
+/** Constructor for a Const node.
+ *
+ * Constructor for a Const node. The constant represents a target
+ * value. Sets the type information to type_unknown. (No more
+ * supported: If tv is entity derives a somehow useful type.)
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *mode The mode of the operands and results.
+ * @param *con Points to an entry in the constant table.
+ */
+ir_node *new_rd_Const (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_mode *mode, tarval *con);
+
+/** Constructor for a SymConst_type node.
+ *
+ * This is the constructor for a symbolic constant.
+ * There are four kinds of symbolic constants:
+ * - type_tag The symbolic constant represents a type tag. The type the
+ * tag stands for is given explicitly.
+ * - type_size The symbolic constant represents the size of a type. The
+ * type of which the constant represents the size is given
+ * explicitly.
+ * - type_align The symbolic constant represents the alignment of a type. The
+ * type of which the constant represents the size is given
+ * explicitly.
+ * - addr_name The symbolic constant represents the address of an entity
+ * (variable or method). The variable is indicated by a name
+ * that is valid for linking.
+ * - addr_ent The symbolic constant represents the address of an entity
+ * (variable or method). The variable is given explicitly by
+ * a firm entity.
+ *
+ * Inputs to the node:
+ * No inputs except the block it belongs to.
+ * Outputs of the node.
+ * An unsigned integer (I_u) or a pointer (P).
+ *
+ * Mention union in declaration so that the firmjni generator recognizes that
+ * it can not cast the argument to an int.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param symkind The kind of the symbolic constant: type_tag, size, addr_name or addr_ent.
+ * @param value A type, entity or a ident depending on the SymConst kind.
+ * @param tp The source type of the constant.
+ */
+ir_node *new_rd_SymConst_type (dbg_info *db, ir_graph *irg, ir_node *block, union symconst_symbol value,
+ symconst_kind symkind, ir_type *tp);
+
+/** Constructor for a SymConst node.
+ *
+ * Same as new_rd_SymConst_type, except that it sets the type to type_unknown. */
+ir_node *new_rd_SymConst (dbg_info *db, ir_graph *irg, ir_node *block,
+ union symconst_symbol value, symconst_kind symkind);
+
+/** Constructor for a SymConst addr_ent node.
+ *
+ * Same as new_rd_SymConst_type, except that the constructor is tailored for
+ * symconst_addr_ent.
+ * Adds the SymConst to the start block of irg. */
+ir_node *new_rd_SymConst_addr_ent (dbg_info *db, ir_graph *irg, ir_entity *symbol, ir_type *tp);
+
+/** Constructor for a SymConst ofs_ent node.
+ *
+ * Same as new_rd_SymConst_type, except that the constructor is tailored for
+ * symconst_ofs_ent.
+ * Adds the SymConst to the start block of irg. */
+ir_node *new_rd_SymConst_ofs_ent (dbg_info *db, ir_graph *irg, ir_entity *symbol, ir_type *tp);
+
+/** Constructor for a SymConst addr_name node.
+ *
+ * Same as new_rd_SymConst_type, except that the constructor is tailored for
+ * symconst_addr_ent.
+ * Adds the SymConst to the start block of irg. */
+ir_node *new_rd_SymConst_addr_name (dbg_info *db, ir_graph *irg, ident *symbol, ir_type *tp);
+
+/** Constructor for a SymConst type_tag node.
+ *
+ * Same as new_rd_SymConst_type, except that the constructor is tailored for
+ * symconst_addr_ent.
+ * Adds the SymConst to the start block of irg. */
+ir_node *new_rd_SymConst_type_tag (dbg_info *db, ir_graph *irg, ir_type *symbol, ir_type *tp);
+
+/** Constructor for a SymConst size node.
+ *
+ * Same as new_rd_SymConst_type, except that the constructor is tailored for
+ * symconst_type_size.
+ * Adds the SymConst to the start block of irg. */
+ir_node *new_rd_SymConst_size (dbg_info *db, ir_graph *irg, ir_type *symbol, ir_type *tp);
+
+/** Constructor for a SymConst size node.
+ *
+ * Same as new_rd_SymConst_type, except that the constructor is tailored for
+ * symconst_type_align.
+ * Adds the SymConst to the start block of irg. */
+ir_node *new_rd_SymConst_align (dbg_info *db, ir_graph *irg, ir_type *symbol, ir_type *tp);
+
+/** Constructor for a simpleSel node.
+ *
+ * This is a shortcut for the new_rd_Sel() constructor. To be used for
+ * Sel nodes that do not select from an array, i.e., have no index
+ * inputs. It adds the two parameters 0, NULL.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *store The memory in which the object the entity should be
+ * selected from is allocated.
+ * @param *objptr The object from that the Sel operation selects a
+ * single attribute out.
+ * @param *ent The entity to select.
+ */
+ir_node *new_rd_simpleSel (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *store, ir_node *objptr, ir_entity *ent);
+
+/** Constructor for a Sel node.
+ *
+ * The select node selects an entity (field or method) from an entity
+ * with a compound type. It explicitly specifies the entity selected.
+ * Dynamically the node may select entities that overwrite the given
+ * entity. If the selected entity is an array element entity the Sel
+ * node takes the required array indices as inputs.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *store The memory in which the object the entity should be selected
+ * from is allocated.
+ * @param *objptr A pointer to a compound entity the Sel operation selects a
+ * single attribute from.
+ * @param *n_index The number of array indices needed to select an array element entity.
+ * @param *index[] If the compound entity is an array the indices of the selected
+ * element entity. The constructor copies this array.
+ * @param *ent The entity to select.
+ */
+ir_node *new_rd_Sel (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
+ ir_node *objptr, int n_index, ir_node *index[], ir_entity *ent);
+
+/** Constructor for a Call node.
+ *
+ * Represents all kinds of method and function calls.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *store The current memory state.
+ * @param *callee A pointer to the called procedure.
+ * @param arity The number of procedure parameters.
+ * @param *in[] An array with the procedure parameters. The constructor copies this array.
+ * @param *tp Type information of the procedure called.
+ */
+ir_node *new_rd_Call (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
+ ir_node *callee, int arity, ir_node *in[], ir_type *tp);
+
+/** Constructor for a Add node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_rd_Add (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Sub node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_rd_Sub (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Minus node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op The operand .
+ * @param *mode The mode of the operand and the result.
+ */
+ir_node *new_rd_Minus (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *op, ir_mode *mode);
+
+/** Constructor for a Mul node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_rd_Mul (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Quot node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *memop The store needed to model exceptions
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the result.
+ */
+ir_node *new_rd_Quot (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a DivMod node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *memop The store needed to model exceptions
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the results.
+ */
+ir_node *new_rd_DivMod (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Div node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *memop The store needed to model exceptions
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the result.
+ */
+ir_node *new_rd_Div (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Mod node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *memop The store needed to model exceptions
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the result.
+ */
+ir_node *new_rd_Mod (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Abs node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op The operand
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_rd_Abs (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *op, ir_mode *mode);
+
+/** Constructor for a And node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_rd_And (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Or node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_rd_Or (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Eor node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the results.
+ */
+ir_node *new_rd_Eor (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Not node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op The operand.
+ * @param *mode The mode of the operand and the result.
+ */
+ir_node *new_rd_Not (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *op, ir_mode *mode);
+
+/** Constructor for a Cmp node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ */
+ir_node *new_rd_Cmp (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *op1, ir_node *op2);
+
+/** Constructor for a Shl node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op The operand.
+ * @param *k The number of bits to shift the operand .
+ * @param *mode The mode of the operand and the result.
+ */
+ir_node *new_rd_Shl (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *op, ir_node *k, ir_mode *mode);
+
+/** Constructor for a Shr node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op The operand.
+ * @param *k The number of bits to shift the operand .
+ * @param *mode The mode of the operand and the result.
+ */
+ir_node *new_rd_Shr (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *op, ir_node *k, ir_mode *mode);
+
+/** Constructor for a Shrs node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op The operand.
+ * @param *k The number of bits to shift the operand.
+ * @param *mode The mode of the operand and the result.
+ */
+ir_node *new_rd_Shrs (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *op, ir_node *k, ir_mode *mode);
+
+/** Constructor for a Rot node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op The operand.
+ * @param *k The number of bits to rotate the operand.
+ * @param *mode The mode of the operand.
+ */
+ir_node *new_rd_Rot (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *op, ir_node *k, ir_mode *mode);
+
+
+/** Constructor for a Conv node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op The operand.
+ * @param *mode The mode of this the operand muss be converted .
+ */
+ir_node *new_rd_Conv (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *op, ir_mode *mode);
+
+/** Constructor for a Cast node.
+ *
+ * High level type cast.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op The operand.
+ * @param *to_tp The type of this the operand muss be casted .
+ */
+ir_node *new_rd_Cast (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *op, ir_type *to_tp);
+
+/** Constructor for a Carry node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_rd_Carry (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Borrow node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_rd_Borrow (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Phi node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param arity The number of predecessors
+ * @param *in[] Array with predecessors. The constructor copies this array.
+ * @param *mode The mode of it's inputs and output.
+ */
+ir_node *new_rd_Phi (dbg_info *db, ir_graph *irg, ir_node *block, int arity,
+ ir_node *in[], ir_mode *mode);
+
+/** Constructor for a Load node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *store The current memory
+ * @param *adr A pointer to the variable to be read in this memory.
+ * @param *mode The mode of the value to be loaded.
+ */
+ir_node *new_rd_Load (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *store, ir_node *adr, ir_mode *mode);
+
+/** Constructor for a Store node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *store The current memory
+ * @param *adr A pointer to the variable to be read in this memory.
+ * @param *val The value to write to this variable.
+ */
+ir_node *new_rd_Store (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *store, ir_node *adr, ir_node *val);
+
+/** Constructor for a Alloc node.
+ *
+ * The Alloc node extends the memory by space for an entity of type alloc_type.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *store The memory which shall contain the new variable.
+ * @param *size The number of bytes to allocate.
+ * @param *alloc_type The type of the allocated variable.
+ * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
+ */
+ir_node *new_rd_Alloc (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
+ ir_node *size, ir_type *alloc_type, where_alloc where);
+
+/** Constructor for a Free node.
+ *
+ * Frees the memory occupied by the entity pointed to by the pointer
+ * arg. Type indicates the type of the entity the argument points to.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *store The memory which shall contain the new variable.
+ * @param *ptr The pointer to the object to free.
+ * @param *size The number of objects of type free_type to free in a sequence.
+ * @param *free_type The type of the freed variable.
+ * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
+ */
+ir_node *new_rd_Free (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
+ ir_node *ptr, ir_node *size, ir_type *free_type, where_alloc where);
+
+/** Constructor for a Sync node.
+ *
+ * Merges several memory values. The node assumes that a variable
+ * either occurs only in one of the memories, or it contains the same
+ * value in all memories where it occurs.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param arity The number of memories to synchronize.
+ * @param *in[] An array of pointers to nodes that produce an output of type
+ * memory. The constructor copies this array.
+ */
+ir_node *new_rd_Sync (dbg_info *db, ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
+
+/** Constructor for a Proj node.
+ *
+ * Projects a single value out of a tuple. The parameter proj gives the
+ * position of the value within the tuple.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param arg A node producing a tuple. The node must have mode_T.
+ * @param *mode The mode of the value to project.
+ * @param proj The position of the value in the tuple.
+ */
+ir_node *new_rd_Proj (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
+ ir_mode *mode, long proj);
+
+/** Constructor for a defaultProj node.
+ *
+ * Represents the default control flow of a Switch-Cond node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param arg A node producing a tuple.
+ * @param max_proj The end position of the value in the tuple.
+ */
+ir_node *new_rd_defaultProj (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
+ long max_proj);
+
+/** Constructor for a Tuple node.
+ *
+ * This is an auxiliary node to replace a node that returns a tuple
+ * without changing the corresponding Proj nodes.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param arity The number of tuple elements.
+ * @param *in[] An array containing pointers to the nodes producing the tuple
+ * elements. The constructor copies this array.
+ */
+ir_node *new_rd_Tuple (dbg_info *db, ir_graph *irg, ir_node *block,
+ int arity, ir_node *in[]);
+
+/** Constructor for a Id node.
+ *
+ * This is an auxiliary node to replace a node that returns a single
+ * value.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *val The value
+ * @param *mode The mode of *val.
+ */
+ir_node *new_rd_Id (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *val, ir_mode *mode);
+
+/** Constructor for a Bad node.
+ *
+ * Returns the unique Bad node of the graph. The same as
+ * get_irg_bad().
+ *
+ * @param *irg The ir graph the node belongs to.
+ */
+ir_node *new_rd_Bad (ir_graph *irg);
+
+/** Constructor for a Confirm node.
+ *
+ * Specifies constraints for a value. To support dataflow analyses.
+ *
+ * Example: If the value never exceeds '100' this is expressed by placing a
+ * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
+ *
+ * @param *irg The ir graph the node belong to.
+ * @param *block The ir block the node belong to.
+ * @param *db A pointer for debug information.
+ * @param *val The value we express a constraint for
+ * @param *bound The value to compare against. Must be a firm node, typically a constant.
+ * @param cmp The compare operation.
+ */
+ir_node *new_rd_Confirm (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *val, ir_node *bound, pn_Cmp cmp);
+
+/** Constructor for an Unknown node.
+ *
+ * Represents an arbitrary value. Places the node in the start block.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *m The mode of the unknown value.
+ */
+ir_node *new_rd_Unknown(ir_graph *irg, ir_mode *m);
+
+/** Constructor for a CallBegin node.
+ *
+ * CallBegin represents control flow depending of the pointer value
+ * representing the called method to the called methods. The
+ * constructor copies the method pointer input from the passed Call
+ * node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belong to.
+ * @param *block The block the node belong to.
+ * @param *callee The call node visible in the intra procedural view.
+ */
+ir_node *new_rd_CallBegin(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *callee);
+
+/** Constructor for a EndReg node.
+ *
+ * Used to represent regular procedure end in interprocedual view.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belong to.
+ * @param *block The block the node belong to.
+ */
+ir_node *new_rd_EndReg (dbg_info *db, ir_graph *irg, ir_node *block);
+
+/** Constructor for a EndExcept node.
+ *
+ * Used to represent exceptional procedure end in interprocedural view.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belong to.
+ * @param *block The block the node belong to.
+ */
+ir_node *new_rd_EndExcept(dbg_info *db, ir_graph *irg, ir_node *block);
+
+/** Constructor for a Filter node.
+ *
+ * Adds the node to the block in current_ir_block. Filter is a node
+ * with two views used to construct the interprocedural view. In
+ * intraprocedural view its semantics are identical to the Proj node.
+ * In interprocedural view the Filter performs the Phi operation on
+ * method parameters or results. Other than a Phi a Filter node may
+ * not be removed if it has only a single input.
+ *
+ * The constructor builds the Filter in intraprocedural view.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belong to.
+ * @param *block The block the node belong to.
+ * @param *arg The tuple value to project from.
+ * @param *mode The mode of the projected value.
+ * @param proj The position in the tuple to project from.
+ */
+ir_node *new_rd_Filter (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
+ ir_mode *mode, long proj);
+
+/** Constructor for a NoMem node.
+ *
+ * Returns the unique NoMem node of the graph. The same as
+ * get_irg_no_mem().
+ *
+ * @param *irg The ir graph the node belongs to.
+ */
+ir_node *new_rd_NoMem (ir_graph *irg);
+
+/** Constructor for a Mux node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belong to.
+ * @param *block The block the node belong to.
+ * @param *sel The ir_node that calculates the boolean select.
+ * @param *ir_true The ir_node that calculates the true result.
+ * @param *ir_false The ir_node that calculates the false result.
+ * @param *mode The mode of the node (and it_true and ir_false).
+ */
+ir_node *new_rd_Mux (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
+
+/** Constructor for a Psi node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belong to.
+ * @param *block The block the node belong to.
+ * @param *arity The arity of the conditions
+ * @param *conds The array of mode_b conditions, length must be equal arity
+ * @param *vals The array of mode values, length must be equal arity + 1
+ * @param *mode The mode of the node (must be the mode of all vals).
+ */
+ir_node *new_rd_Psi (dbg_info *db, ir_graph *irg, ir_node *block,
+ int arity, ir_node *conds[], ir_node *vals[], ir_mode *mode);
+
+/** Constructor for a CopyB node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belong to.
+ * @param *block The block the node belong to.
+ * @param *store The current memory
+ * @param *dst The ir_node that represents the destination address.
+ * @param *src The ir_node that represents the source address.
+ * @param *data_type The type of the copied data
+ */
+ir_node *new_rd_CopyB(dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
+
+/** Constructor for a InstOf node.
+ *
+ * A High-Level Type check.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *store The memory in which the object the entity should be selected
+ * from is allocated.
+ * @param *objptr A pointer to a object of a class type.
+ * @param *type The type of which objptr must be.
+ */
+ir_node *new_rd_InstOf (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
+ ir_node *objptr, ir_type *type);
+
+/** Constructor for a Raise node.
+ *
+ * A High-Level Exception throw.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *store The current memory.
+ * @param *obj A pointer to the Except variable.
+ */
+ir_node *new_rd_Raise (dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *store, ir_node *obj);
+
+/** Constructor for a Bound node.
+ *
+ * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belong to.
+ * @param *block The block the node belong to.
+ * @param *store The current memory.
+ * @param *idx The ir_node that represents an index.
+ * @param *lower The ir_node that represents the lower bound for the index.
+ * @param *upper The ir_node that represents the upper bound for the index.
+ */
+ir_node *new_rd_Bound(dbg_info *db, ir_graph *irg, ir_node *block,
+ ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
+
+/** Constructor for a Pin node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belong to.
+ * @param *block The block the node belong to.
+ * @param *node The node which value should be pinned.
+ */
+ir_node *new_rd_Pin(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *node);
+
+/** Constructor for an ASM pseudo node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *irg The ir graph the node belong to.
+ * @param *block The block the node belong to.
+ * @param arity The number of data inputs to the node.
+ * @param *in The array of length arity of data inputs.
+ * @param *inputs The array of length arity of input constraints.
+ * @param n_outs The number of data outputs to the node.
+ * @param *outputs The array of length n_outs of output constraints.
+ * @param n_clobber The number of clobbered registers.
+ * @param *clobber The array of length n_clobber of clobbered registers.
+ * @param *asm_text The assembler text.
+ */
+ir_node *new_rd_ASM(dbg_info *db, ir_graph *irg, ir_node *block,
+ int arity, ir_node *in[], ir_asm_constraint *inputs,
+ int n_outs, ir_asm_constraint *outputs,
+ int n_clobber, ident *clobber[], ident *asm_text);
+
+/*-------------------------------------------------------------------------*/
+/* The raw interface without debug support */
+/*-------------------------------------------------------------------------*/
+
+/** Constructor for a Block node.
+ *
+ * Constructs a mature block with the given predecessors. Use Unknown
+ * nodes as predecessors to construct a block if the number of
+ * predecessors is known, but not the predecessors themselves. This
+ * constructor does not set current_block. It not be used with
+ * automatic Phi node construction.
+ *
+ *
+ * @param irg The ir graph the block belongs to.
+ * @param arity The number of control predecessors.
+ * @param in[] An array of control predecessors. The length of
+ * the array must be 'arity'. The constructor copies this array.
+ */
+ir_node *new_r_Block (ir_graph *irg, int arity, ir_node *in[]);
+
+/** Constructor for a Start node.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ */
+ir_node *new_r_Start (ir_graph *irg, ir_node *block);
+
+/** Constructor for a End node.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ */
+ir_node *new_r_End (ir_graph *irg, ir_node *block);
+
+/** Constructor for a Jmp node.
+ *
+ * Jmp represents control flow to a single control successor.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ */
+ir_node *new_r_Jmp (ir_graph *irg, ir_node *block);
+
+/** Constructor for an IJmp node.
+ *
+ * IJmp represents control flow to a single control successor not
+ * statically known i.e. an indirect Jmp.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *tgt The ir node representing the target address.
+ */
+ir_node *new_r_IJmp (ir_graph *irg, ir_node *block, ir_node *tgt);
+
+/** Constructor for a Cond node.
+ *
+ * If c is mode_b represents a conditional branch (if/else). If c is
+ * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
+ * node, default Proj is 0.)
+ *
+ * This is not consistent: Input to Cond is Is, Proj has as proj number
+ * longs.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *c The conditions parameter.Can be of mode b or I_u.
+ */
+ir_node *new_r_Cond (ir_graph *irg, ir_node *block, ir_node *c);
+
+/** Constructor for a Return node.
+ *
+ * Returns the memory an zero or more return values. Only node that
+ * can end regular control flow.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *store The state of memory.
+ * @param arity Number of array indices.
+ * @param *in[] Array with index inputs to the node. The constructor copies this array.
+ */
+ir_node *new_r_Return (ir_graph *irg, ir_node *block,
+ ir_node *store, int arity, ir_node *in[]);
+
+/** Constructor for a Const node.
+ *
+ * Constructor for a Const node. The constant represents a target
+ * value. Sets the type information to type_unknown. (No more
+ * supported: If tv is entity derives a somehow useful type.)
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *mode The mode of the operands and the results.
+ * @param *con Points to an entry in the constant table.
+ */
+ir_node *new_r_Const (ir_graph *irg, ir_node *block,
+ ir_mode *mode, tarval *con);
+
+/** Constructor for a Const node.
+ *
+ * Constructor for a Const node. The constant represents a target
+ * value. Sets the type information to type_unknown. (No more
+ * supported: If tv is entity derives a somehow useful type.)
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *mode The mode of the operands and the results.
+ * @param value A value from which the tarval is made.
+ */
+ir_node *new_r_Const_long(ir_graph *irg, ir_node *block,
+ ir_mode *mode, long value);
+
+/** Constructor for a Const_type node.
+ *
+ * The constant represents a target value. This constructor sets high
+ * level type information for the constant value.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *mode The mode of the operands and results.
+ * @param *con Points to an entry in the constant table.
+ * @param *tp The type of the constant.
+ */
+ir_node *new_r_Const_type(ir_graph *irg, ir_node *block,
+ ir_mode *mode, tarval *con, ir_type *tp);
+
+/** Constructor for a SymConst node.
+ *
+ * This is the constructor for a symbolic constant.
+ * There are four kinds of symbolic constants:
+ * - type_tag The symbolic constant represents a type tag. The type the
+ * tag stands for is given explicitly.
+ * - size The symbolic constant represents the size of a type. The
+ * type of which the constant represents the size is given
+ * explicitly.
+ * - addr_name The symbolic constant represents the address of an entity
+ * (variable or method). The variable is indicated by a name
+ * that is valid for linking.
+ * - addr_ent The symbolic constant represents the address of an entity
+ * (variable or method). The variable is given explicitly by
+ * a firm entity.
+ *
+ * Inputs to the node:
+ * No inputs except the block it belongs to.
+ * Outputs of the node.
+ * An unsigned integer (I_u) or a pointer (P).
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param value A type, entity or a ident depending on the SymConst kind.
+ * @param symkind The kind of the symbolic constant: type_tag, size or link_info.
+ */
+ir_node *new_r_SymConst (ir_graph *irg, ir_node *block,
+ union symconst_symbol value, symconst_kind symkind);
+
+/** Constructor for a simpleSel node.
+ *
+ * This is a shortcut for the new_d_Sel() constructor. To be used for
+ * Sel nodes that do not select from an array, i.e., have no index
+ * inputs. It adds the two parameters 0, NULL.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *store The memory in which the object the entity should be selected
+ * from is allocated.
+ * @param *objptr The object from that the Sel operation selects a
+ * single attribute out.
+ * @param *ent The entity to select.
+ */
+ir_node *new_r_simpleSel(ir_graph *irg, ir_node *block, ir_node *store,
+ ir_node *objptr, ir_entity *ent);
+
+/** Constructor for a Sel node.
+ *
+ * The select node selects an entity (field or method) from an entity
+ * with a compound type. It explicitly specifies the entity selected.
+ * Dynamically the node may select entities that overwrite the given
+ * entity. If the selected entity is an array element entity the Sel
+ * node takes the required array indices as inputs.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *store The memory in which the object the entity should be selected
+ * from is allocated.
+ * @param *objptr A pointer to a compound entity the Sel operation selects a
+ * single attribute from.
+ * @param *n_index The number of array indices needed to select an array element entity.
+ * @param *index[] If the compound entity is an array the indices of the selected
+ * element entity. The constructor copies this array.
+ * @param *ent The entity to select.
+ */
+ir_node *new_r_Sel (ir_graph *irg, ir_node *block, ir_node *store,
+ ir_node *objptr, int n_index, ir_node *index[],
+ ir_entity *ent);
+
+/** Constructor for a Call node.
+ *
+ * Represents all kinds of method and function calls.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *store The actual store.
+ * @param *callee A pointer to the called procedure.
+ * @param arity The number of procedure parameters.
+ * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
+ * @param *tp Type information of the procedure called.
+ */
+ir_node *new_r_Call (ir_graph *irg, ir_node *block, ir_node *store,
+ ir_node *callee, int arity, ir_node *in[],
+ ir_type *tp);
+
+/** Constructor for a Add node.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_r_Add (ir_graph *irg, ir_node *block,
+ ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/**
+ * Constructor for a Sub node.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the results.
+ */
+ir_node *new_r_Sub (ir_graph *irg, ir_node *block,
+ ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Minus node.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op The operand.
+ * @param *mode The mode of the operand and the result.
+ */
+ir_node *new_r_Minus (ir_graph *irg, ir_node *block,
+ ir_node *op, ir_mode *mode);
+/** Constructor for a Mul node.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_r_Mul (ir_graph *irg, ir_node *block,
+ ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Quot node.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *memop The store needed to model exceptions
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the result.
+ */
+ir_node *new_r_Quot (ir_graph *irg, ir_node *block,
+ ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a DivMod node.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *memop The store needed to model exceptions
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the results.
+ */
+ir_node *new_r_DivMod (ir_graph *irg, ir_node *block,
+ ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Div node.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *memop The store needed to model exceptions
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the result.
+ */
+ir_node *new_r_Div (ir_graph *irg, ir_node *block,
+ ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Mod node.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *memop The store needed to model exceptions
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the result.
+ */
+ir_node *new_r_Mod (ir_graph *irg, ir_node *block,
+ ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Abs node.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op The operand
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_r_Abs (ir_graph *irg, ir_node *block,
+ ir_node *op, ir_mode *mode);
+
+/** Constructor for a And node.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_r_And (ir_graph *irg, ir_node *block,
+ ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Or node.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_r_Or (ir_graph *irg, ir_node *block,
+ ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Eor node.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the results.
+ */
+ir_node *new_r_Eor (ir_graph *irg, ir_node *block,
+ ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Not node.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op The operand.
+ * @param *mode The mode of the operand and the result.
+ */
+ir_node *new_r_Not (ir_graph *irg, ir_node *block,
+ ir_node *op, ir_mode *mode);
+
+/** Constructor for a Cmp node.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ */
+ir_node *new_r_Cmp (ir_graph *irg, ir_node *block,
+ ir_node *op1, ir_node *op2);
+
+/** Constructor for a Shl node.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op The operand.
+ * @param *k The number of bits to shift the operand .
+ * @param *mode The mode of the operand and the result.
+ */
+ir_node *new_r_Shl (ir_graph *irg, ir_node *block,
+ ir_node *op, ir_node *k, ir_mode *mode);
+
+/** Constructor for a Shr node.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op The operand.
+ * @param *k The number of bits to shift the operand .
+ * @param *mode The mode of the operand and the result.
+ */
+ir_node *new_r_Shr (ir_graph *irg, ir_node *block,
+ ir_node *op, ir_node *k, ir_mode *mode);
+
+/**
+ * Constructor for a Shrs node.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op The operand.
+ * @param *k The number of bits to shift the operand.
+ * @param *mode The mode of the operand and the result.
+ */
+ir_node *new_r_Shrs (ir_graph *irg, ir_node *block,
+ ir_node *op, ir_node *k, ir_mode *mode);
+
+/** Constructor for a Rot node.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op The operand.
+ * @param *k The number of bits to rotate the operand.
+ * @param *mode The mode of the operand.
+ */
+ir_node *new_r_Rot (ir_graph *irg, ir_node *block,
+ ir_node *op, ir_node *k, ir_mode *mode);
+
+/** Constructor for a Conv node.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op The operand.
+ * @param *mode The mode of this the operand muss be converted .
+ */
+ir_node *new_r_Conv (ir_graph *irg, ir_node *block,
+ ir_node *op, ir_mode *mode);
+
+/** Constructor for a Cast node.
+ *
+ * High level type cast
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op The operand.
+ * @param *to_tp The type of this the operand muss be casted .
+ */
+ir_node *new_r_Cast (ir_graph *irg, ir_node *block,
+ ir_node *op, ir_type *to_tp);
+
+/** Constructor for a Carry node.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_r_Carry (ir_graph *irg, ir_node *block,
+ ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/**
+ * Constructor for a Borrow node.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the results.
+ */
+ir_node *new_r_Borrow (ir_graph *irg, ir_node *block,
+ ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Phi node.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param arity The number of predecessors
+ * @param *in[] Array with predecessors. The constructor copies this array.
+ * @param *mode The mode of it's inputs and output.
+ */
+ir_node *new_r_Phi (ir_graph *irg, ir_node *block, int arity,
+ ir_node *in[], ir_mode *mode);
+
+/** Constructor for a Load node.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *store The current memory
+ * @param *adr A pointer to the variable to be read in this memory.
+ * @param *mode The mode of the value to be loaded.
+ */
+ir_node *new_r_Load (ir_graph *irg, ir_node *block,
+ ir_node *store, ir_node *adr, ir_mode *mode);
+
+/** Constructor for a Store node.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *store The current memory
+ * @param *adr A pointer to the variable to be read in this memory.
+ * @param *val The value to write to this variable.
+ */
+ir_node *new_r_Store (ir_graph *irg, ir_node *block,
+ ir_node *store, ir_node *adr, ir_node *val);
+
+/** Constructor for a Alloc node.
+ *
+ * The Alloc node extends the memory by space for an entity of type alloc_type.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *store The memory which shall contain the new variable.
+ * @param *size The number of bytes to allocate.
+ * @param *alloc_type The type of the allocated variable.
+ * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
+ */
+ir_node *new_r_Alloc (ir_graph *irg, ir_node *block, ir_node *store,
+ ir_node *size, ir_type *alloc_type, where_alloc where);
+
+/** Constructor for a Free node.
+ *
+ * Frees the memory occupied by the entity pointed to by the pointer
+ * arg. Type indicates the type of the entity the argument points to.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *store The memory which shall contain the new variable.
+ * @param *ptr The pointer to the object to free.
+ * @param *size The number of objects of type free_type to free in a sequence.
+ * @param *free_type The type of the freed variable.
+ * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
+ */
+ir_node *new_r_Free (ir_graph *irg, ir_node *block, ir_node *store,
+ ir_node *ptr, ir_node *size, ir_type *free_type, where_alloc where);
+
+/** Constructor for a Sync node.
+ *
+ * Merges several memory values. The node assumes that a variable
+ * either occurs only in one of the memories, or it contains the same
+ * value in all memories where it occurs.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param arity The number of memories to synchronize.
+ * @param *in[] An array of pointers to nodes that produce an output of type memory.
+ * The constructor copies this array.
+ */
+ir_node *new_r_Sync (ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
+
+/** Constructor for a Proj node.
+ *
+ * Projects a single value out of a tuple. The parameter proj gives the
+ * position of the value within the tuple.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param arg A node producing a tuple.
+ * @param *mode The mode of the value to project.
+ * @param proj The position of the value in the tuple.
+ */
+ir_node *new_r_Proj (ir_graph *irg, ir_node *block, ir_node *arg,
+ ir_mode *mode, long proj);
+
+/** Constructor for a defaultProj node.
+ *
+ * Represents the default control flow of a Switch-Cond node.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param arg A node producing a tuple.
+ * @param max_proj The end position of the value in the tuple.
+ */
+ir_node *new_r_defaultProj (ir_graph *irg, ir_node *block, ir_node *arg, long max_proj);
+
+
+/** Constructor for a Tuple node.
+ *
+ * This is an auxiliary node to replace a node that returns a tuple
+ * without changing the corresponding Proj nodes.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param arity The number of tuple elements.
+ * @param *in[] An array containing pointers to the nodes producing the tuple elements.
+ * The constructor copies this array.
+ */
+ir_node *new_r_Tuple (ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
+
+/** Constructor for a Id node.
+ *
+ * This is an auxiliary node to replace a node that returns a single
+ * value.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *val The operand to Id.
+ * @param *mode The mode of *val.
+ */
+ir_node *new_r_Id (ir_graph *irg, ir_node *block,
+ ir_node *val, ir_mode *mode);
+
+/** Constructor for a Bad node.
+ *
+ * Returns the unique Bad node of the graph. The same as
+ * get_irg_bad().
+ *
+ * @param *irg The ir graph the node belongs to.
+ *
+ */
+ir_node *new_r_Bad (ir_graph *irg);
+
+/** Constructor for a Confirm node.
+ *
+ * Specifies constraints for a value. To support dataflow analyses.
+ *
+ * Example: If the value never exceeds '100' this is expressed by placing a
+ * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
+ *
+ * @param *irg The ir graph the node belong to.
+ * @param *block The ir block the node belong to.
+ * @param *val The value we express a constraint for
+ * @param *bound The value to compare against. Must be a firm node, typically a constant.
+ * @param cmp The compare operation.
+ */
+ir_node *new_r_Confirm (ir_graph *irg, ir_node *block,
+ ir_node *val, ir_node *bound, pn_Cmp cmp);
+
+/** Constructor for a Unknown node.
+ *
+ * Represents an arbitrary value. Places the node in
+ * the start block.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *m The mode of the unknown value.
+ */
+ir_node *new_r_Unknown(ir_graph *irg, ir_mode *m);
+
+/** Constructor for a CallBegin node.
+ *
+ * CallBegin represents control flow depending of the pointer value
+ * representing the called method to the called methods. The
+ * constructor copies the method pointer input from the passed Call
+ * node.
+ *
+ * @param *irg The ir graph the node belong to.
+ * @param *block The block the node belong to.
+ * @param *callee The call node visible in the intra procedural view.
+ */
+ir_node *new_r_CallBegin(ir_graph *irg, ir_node *block, ir_node *callee);
+
+/** Constructor for a EndReg node.
+ *
+ * Used to represent regular procedure end in interprocedual view.
+ *
+ * @param *irg The ir graph the node belong to.
+ * @param *block The block the node belong to.
+ */
+ir_node *new_r_EndReg (ir_graph *irg, ir_node *block);
+
+/** Constructor for a EndExcept node.
+ *
+ * Used to represent exceptional procedure end in interprocedural view.
+ *
+ * @param *irg The ir graph the node belong to.
+ * @param *block The block the node belong to.
+ */
+ir_node *new_r_EndExcept(ir_graph *irg, ir_node *block);
+
+/** Constructor for a Break node.
+ *
+ * Break represents control flow to a single control successor just as Jmp.
+ * The blocks separated by a break may not be concatenated by an optimization.
+ * It is used for the interprocedural representation where blocks are parted
+ * behind Call nodes to represent the control flow to called procedures.
+ *
+ * @param *irg The ir graph the node belong to.
+ * @param *block The block the node belong to.
+ */
+ir_node *new_r_Break (ir_graph *irg, ir_node *block);
+
+/** Constructor for a Filter node.
+ *
+ * Constructor for a Filter node. Adds the node to the block in current_ir_block.
+ * Filter is a node with two views used to construct the interprocedural view.
+ * In intraprocedural view its semantics are identical to the Proj node.
+ * In interprocedural view the Filter performs the Phi operation on method
+ * parameters or results. Other than a Phi a Filter node may not be removed
+ * if it has only a single input.
+ *
+ * The constructor builds the Filter in intraprocedural view.
+ *
+ * @param *irg The ir graph the node belong to.
+ * @param *block The block the node belong to.
+ * @param *arg The tuple value to project from.
+ * @param *mode The mode of the projected value.
+ * @param proj The position in the tuple to project from.
+ */
+ir_node *new_r_Filter (ir_graph *irg, ir_node *block, ir_node *arg,
+ ir_mode *mode, long proj);
+
+/** Constructor for a NoMem node.
+ *
+ * Returns the unique NoMem node of the graph. The same as
+ * get_irg_no_mem().
+ *
+ * @param *irg The ir graph the node belongs to.
+ */
+ir_node *new_r_NoMem (ir_graph *irg);
+
+/** Constructor for a Mux node.
+ *
+ * @param *irg The ir graph the node belong to.
+ * @param *block The block the node belong to.
+ * @param *sel The ir_node that calculates the boolean select.
+ * @param *ir_true The ir_node that calculates the true result.
+ * @param *ir_false The ir_node that calculates the false result.
+ * @param *mode The mode of the node (and it_true and ir_false).
+ */
+ir_node *new_r_Mux (ir_graph *irg, ir_node *block,
+ ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
+
+/** Constructor for a Psi node.
+ *
+ * @param *irg The ir graph the node belong to.
+ * @param *block The block the node belong to.
+ * @param *arity The arity of the conditions
+ * @param *conds The array of mode_b conditions, length must be equal arity
+ * @param *vals The array of mode values, length must be equal arity + 1
+ * @param *mode The mode of the node (must be the mode of all vals).
+ */
+ir_node *new_r_Psi (ir_graph *irg, ir_node *block,
+ int arity, ir_node *conds[], ir_node *vals[], ir_mode *mode);
+
+/** Constructor for a CopyB node.
+ *
+ * @param *irg The ir graph the node belong to.
+ * @param *block The block the node belong to.
+ * @param *store The current memory
+ * @param *dst The ir_node that represents the destination address.
+ * @param *src The ir_node that represents the source address.
+ * @param *data_type The type of the copied data
+ */
+ir_node *new_r_CopyB(ir_graph *irg, ir_node *block,
+ ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
+
+/** Constructor for a InstOf node.
+ *
+ * A High-Level Type check.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *store The memory in which the object the entity should be selected
+ * from is allocated.
+ * @param *objptr A pointer to a object of a class type.
+ * @param *type The type of which objptr must be.
+ */
+ir_node *new_r_InstOf(ir_graph *irg, ir_node *block, ir_node *store,
+ ir_node *objptr, ir_type *type);
+
+/** Constructor for a Raise node.
+ *
+ * A High-Level Exception throw.
+ *
+ * @param *irg The ir graph the node belongs to.
+ * @param *block The ir block the node belongs to.
+ * @param *store The current memory.
+ * @param *obj A pointer to the Except variable.
+ */
+ir_node *new_r_Raise(ir_graph *irg, ir_node *block,
+ ir_node *store, ir_node *obj);
+
+/** Constructor for a Bound node.
+ *
+ * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
+ *
+ * @param *irg The ir graph the node belong to.
+ * @param *block The block the node belong to.
+ * @param *store The current memory.
+ * @param *idx The ir_node that represents an index.
+ * @param *lower The ir_node that represents the lower bound for the index.
+ * @param *upper The ir_node that represents the upper bound for the index.
+ */
+ir_node *new_r_Bound(ir_graph *irg, ir_node *block,
+ ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
+
+/** Constructor for a Pin node.
+ *
+ * @param *irg The ir graph the node belong to.
+ * @param *block The block the node belong to.
+ * @param *node The node which value should be pinned.
+ */
+ir_node *new_r_Pin(ir_graph *irg, ir_node *block, ir_node *node);
+
+/** Constructor for an ASM pseudo node.
+ *
+ * @param *irg The ir graph the node belong to.
+ * @param *block The block the node belong to.
+ * @param arity The number of data inputs to the node.
+ * @param *in The array of length arity of data inputs.
+ * @param *inputs The array of length arity of input constraints.
+ * @param n_outs The number of data outputs to the node.
+ * @param *outputs The array of length n_outs of output constraints.
+ * @param n_clobber The number of clobbered registers.
+ * @param *clobber The array of length n_clobber of clobbered registers.
+ * @param *asm_text The assembler text.
+ */
+ir_node *new_r_ASM(ir_graph *irg, ir_node *block,
+ int arity, ir_node *in[], ir_asm_constraint *inputs,
+ int n_outs, ir_asm_constraint *outputs,
+ int n_clobber, ident *clobber[], ident *asm_text);
+
+/*-----------------------------------------------------------------------*/
+/* The block oriented interface */
+/*-----------------------------------------------------------------------*/
+
+/** Sets the current block in which the following constructors place the
+ * nodes they construct.
+ *
+ * @param target The new current block.
+ */
+void set_cur_block (ir_node *target);
+
+/** Returns the current block of the current graph. */
+ir_node *get_cur_block(void);
+
+/** Returns the fixed nodes of the current graph. */
+#define get_cur_end_block() get_irg_end_block(current_ir_graph)
+#define get_cur_end() get_irg_end(current_ir_graph)
+#define get_cur_start_block() get_irg_start_block(current_ir_graph)
+#define get_cur_start() get_irg_start(current_ir_graph)
+
+/** Constructor for a Block node.
+ *
+ * Adds the block to the graph in current_ir_graph. Constructs a Block
+ * with a fixed number of predecessors. Does set current_block. Can
+ * be used with automatic Phi node construction.
+ *
+ * @param *db A Pointer for debug information.
+ * @param arity The number of control predecessors.
+ * @param in[] An array of control predecessors. The length of
+ * the array must be 'arity'.
+ */
+ir_node *new_d_Block(dbg_info *db, int arity, ir_node *in[]);
+
+/** Constructor for a Start node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ */
+ir_node *new_d_Start (dbg_info *db);
+
+/** Constructor for a End node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ */
+ir_node *new_d_End (dbg_info *db);
+
+/** Constructor for a Jmp node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * Jmp represents control flow to a single control successor.
+ *
+ * @param *db A pointer for debug information.
+ */
+ir_node *new_d_Jmp (dbg_info *db);
+
+/** Constructor for an IJmp node.
+ *
+ * IJmp represents control flow to a single control successor not
+ * statically known i.e. an indirect Jmp.
+ *
+ * @param *db A pointer for debug information.
+ * @param *tgt The ir node representing the target address.
+ */
+ir_node *new_d_IJmp (dbg_info *db, ir_node *tgt);
+
+/** Constructor for a Cond node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * If c is mode_b represents a conditional branch (if/else). If c is
+ * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
+ * node, default Proj is 0.)
+ *
+ * This is not consistent: Input to Cond is Is, Proj has as proj number
+ * longs.
+ *
+ * @param *db A pointer for debug information.
+ * @param *c The conditions parameter.Can be of mode b or I_u.
+ */
+ir_node *new_d_Cond (dbg_info *db, ir_node *c);
+
+/** Constructor for a Return node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * Returns the memory an zero or more return values. Only node that
+ * can end regular control flow.
+ *
+ * @param *db A pointer for debug information.
+ * @param *store The state of memory.
+ * @param arity Number of array indices.
+ * @param *in Array with index inputs to the node.
+ */
+ir_node *new_d_Return (dbg_info *db, ir_node *store, int arity, ir_node *in[]);
+
+/** Constructor for a Const_type node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * The constant represents a target value. This constructor sets high
+ * level type information for the constant value.
+ *
+ * @param *db A pointer for debug information.
+ * @param *mode The mode of the operands and results.
+ * @param *con Points to an entry in the constant table. This pointer is
+ added to the attributes of the node.
+ * @param *tp The type of the constant.
+ */
+ir_node *new_d_Const_type (dbg_info *db, ir_mode *mode, tarval *con, ir_type *tp);
+
+/** Constructor for a Const node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * Constructor for a Const node. The constant represents a target
+ * value. Sets the type information to type_unknown. (No more
+ * supported: If tv is entity derives a somehow useful type.)
+ *
+ * @param *db A pointer for debug information.
+ * @param *mode The mode of the operands and results.
+ * @param *con Points to an entry in the constant table. This pointer is added
+ * to the attributes of the node.
+ */
+ir_node *new_d_Const (dbg_info *db, ir_mode *mode, tarval *con);
+
+/** Constructor for a SymConst_type node.
+ *
+ * Adds the node to the block in current_ir_block.
+ * This is the constructor for a symbolic constant.
+ * There are four kinds of symbolic constants:
+ * - type_tag The symbolic constant represents a type tag. The type the
+ * tag stands for is given explicitly.
+ * - size The symbolic constant represents the size of a type. The
+ * type of which the constant represents the size is given
+ * explicitly.
+ * - addr_name The symbolic constant represents the address of an entity
+ * (variable or method). The variable is indicated by a name
+ * that is valid for linking.
+ * - addr_ent The symbolic constant represents the address of an entity
+ * (variable or method). The variable is given explicitly by
+ * a firm entity.
+ *
+ * Inputs to the node:
+ * No inputs except the block it belongs to.
+ * Outputs of the node.
+ * An unsigned integer (I_u) or a pointer (P).
+ *
+ * @param *db A pointer for debug information.
+ * @param value A type, entity or ident depending on the SymConst kind.
+ * @param kind The kind of the symbolic constant: symconst_type_tag, symconst_type_size,
+ * symconst_type_align, symconst_addr_name or symconst_addr_ent.
+ * @param tp The source type of the constant.
+ */
+ir_node *new_d_SymConst_type (dbg_info *db, union symconst_symbol value, symconst_kind kind, ir_type *tp);
+
+/** Constructor for a SymConst node.
+ *
+ * Same as new_d_SymConst_type, except that it sets the type to type_unknown. */
+ir_node *new_d_SymConst (dbg_info *db, union symconst_symbol value, symconst_kind kind);
+
+/** Constructor for a simpleSel node.
+ *
+ * This is a shortcut for the new_d_Sel() constructor. To be used for
+ * Sel nodes that do not select from an array, i.e., have no index
+ * inputs. It adds the two parameters 0, NULL.
+ *
+ * @param *db A pointer for debug information.
+ * @param *store The memory in which the object the entity should be
+ * selected from is allocated.
+ * @param *objptr The object from that the Sel operation selects a
+ * single attribute out.
+ * @param *ent The entity to select.
+ */
+ir_node *new_d_simpleSel(dbg_info *db, ir_node *store, ir_node *objptr, ir_entity *ent);
+
+/** Constructor for a Sel node.
+ *
+ * The select node selects an entity (field or method) from an entity
+ * with a compound type. It explicitly specifies the entity selected.
+ * Dynamically the node may select entities that overwrite the given
+ * entity. If the selected entity is an array element entity the Sel
+ * node takes the required array indices as inputs.
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *store The memory in which the object the entity should be selected
+ * from is allocated.
+ * @param *objptr A pointer to a compound entity the Sel operation selects a
+ * single attribute from.
+ * @param arity The number of array indices needed to select an array element entity.
+ * @param *in[] If the compound entity is an array the indices of the selected
+ * element entity. The constructor copies this array.
+ * @param *ent The entity to select.
+ */
+ir_node *new_d_Sel (dbg_info *db, ir_node *store, ir_node *objptr, int arity, ir_node *in[],
+ ir_entity *ent);
+
+/** Constructor for a Call node.
+ *
+ * Represents all kinds of method and function calls.
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *store The actual store.
+ * @param *callee A pointer to the called procedure.
+ * @param arity The number of procedure parameters.
+ * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
+ * @param *tp Type information of the procedure called.
+ */
+ir_node *new_d_Call (dbg_info *db, ir_node *store, ir_node *callee, int arity, ir_node *in[],
+ ir_type *tp);
+
+/** Constructor for a Add node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_d_Add (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Sub node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_d_Sub (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Minus node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *op The operand .
+ * @param *mode The mode of the operand and the result.
+ */
+ir_node *new_d_Minus (dbg_info *db, ir_node *op, ir_mode *mode);
+
+/** Constructor for a Mul node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_d_Mul (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Quot node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *memop The store needed to model exceptions
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the result.
+ */
+ir_node *new_d_Quot (dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a DivMod node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *memop The store needed to model exceptions
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the results.
+ */
+ir_node *new_d_DivMod (dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Div node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *memop The store needed to model exceptions
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the result.
+ */
+ir_node *new_d_Div (dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Mod node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *memop The store needed to model exceptions
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the result.
+ */
+ir_node *new_d_Mod (dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Abs node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *op The operand
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_d_Abs (dbg_info *db, ir_node *op, ir_mode *mode);
+
+/** Constructor for a And node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_d_And (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Or node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_d_Or (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Eor node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the results.
+ */
+ir_node *new_d_Eor (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Not node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *op The operand.
+ * @param *mode The mode of the operand and the result.
+ */
+ir_node *new_d_Not (dbg_info *db, ir_node *op, ir_mode *mode);
+
+/** Constructor for a Shl node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *op The operand.
+ * @param *k The number of bits to shift the operand .
+ * @param *mode The mode of the operand and the result.
+ */
+ir_node *new_d_Shl (dbg_info *db, ir_node *op, ir_node *k, ir_mode *mode);
+
+/** Constructor for a Shr node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *op The operand.
+ * @param *k The number of bits to shift the operand .
+ * @param *mode The mode of the operand and the result.
+ */
+ir_node *new_d_Shr (dbg_info *db, ir_node *op, ir_node *k, ir_mode *mode);
+
+/** Constructor for a Shrs node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *op The operand.
+ * @param *k The number of bits to shift the operand .
+ * @param *mode The mode of the operand and the result.
+ */
+ir_node *new_d_Shrs (dbg_info *db, ir_node *op, ir_node *k, ir_mode *mode);
+
+/** Constructor for a Rot node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *op The operand.
+ * @param *k The number of bits to rotate the operand.
+ * @param *mode The mode of the operand.
+ */
+ir_node *new_d_Rot (dbg_info *db, ir_node *op, ir_node *k, ir_mode *mode);
+
+/** Constructor for a Cmp node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ */
+ir_node *new_d_Cmp (dbg_info *db, ir_node *op1, ir_node *op2);
+
+/** Constructor for a Conv node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *op The operand.
+ * @param *mode The mode of this the operand muss be converted .
+ */
+ir_node *new_d_Conv (dbg_info *db, ir_node *op, ir_mode *mode);
+
+/** Constructor for a strict Conv node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *op The operand.
+ * @param *mode The mode of this the operand muss be converted .
+ */
+ir_node *new_d_strictConv (dbg_info *db, ir_node *op, ir_mode *mode);
+
+/** Constructor for a Cast node.
+ *
+ * High level type cast
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *op The operand.
+ * @param *to_tp The type of this the operand muss be casted .
+ */
+ir_node *new_d_Cast (dbg_info *db, ir_node *op, ir_type *to_tp);
+
+/** Constructor for a Carry node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_d_Carry (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Borrow node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_d_Borrow (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Phi node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param arity The number of predecessors
+ * @param *in Array with predecessors
+ * @param *mode The mode of it's inputs and output.
+ */
+ir_node *new_d_Phi (dbg_info *db, int arity, ir_node *in[], ir_mode *mode);
+
+/** Constructor for a Load node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *store The current memory
+ * @param *addr A pointer to the variable to be read in this memory.
+ * @param *mode The mode of the value to be loaded.
+ */
+ir_node *new_d_Load (dbg_info *db, ir_node *store, ir_node *addr, ir_mode *mode);
+
+/** Constructor for a Store node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *store The current memory
+ * @param *addr A pointer to the variable to be read in this memory.
+ * @param *val The value to write to this variable.
+ */
+ir_node *new_d_Store (dbg_info *db, ir_node *store, ir_node *addr, ir_node *val);
+
+/** Constructor for a Alloc node.
+ *
+ * The Alloc node extends the memory by space for an entity of type alloc_type.
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *store The memory which shall contain the new variable.
+ * @param *size The number of bytes to allocate.
+ * @param *alloc_type The type of the allocated variable.
+ * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
+ */
+ir_node *new_d_Alloc (dbg_info *db, ir_node *store, ir_node *size, ir_type *alloc_type,
+ where_alloc where);
+
+ /** Constructor for a Free node.
+ *
+ * Frees the memory occupied by the entity pointed to by the pointer
+ * arg. Type indicates the type of the entity the argument points to.
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *store The memory which shall contain the new variable.
+ * @param *ptr The pointer to the object to free.
+ * @param *size The number of objects of type free_type to free in a sequence.
+ * @param *free_type The type of the freed variable.
+ * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
+ */
+ir_node *new_d_Free (dbg_info *db, ir_node *store, ir_node *ptr, ir_node *size,
+ ir_type *free_type, where_alloc where);
+
+/** Constructor for a Sync node.
+ *
+ * Merges several memory values. The node assumes that a variable
+ * either occurs only in one of the memories, or it contains the same
+ * value in all memories where it occurs.
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param arity The number of memories to synchronize.
+ * @param **in An array of pointers to nodes that produce an output of type
+ * memory. The constructor copies this array.
+ */
+ir_node *new_d_Sync (dbg_info *db, int arity, ir_node *in[]);
+
+/** Constructor for a Proj node.
+ *
+ * Projects a single value out of a tuple. The parameter proj gives the
+ * position of the value within the tuple.
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for deubug information.
+ * @param arg A node producing a tuple.
+ * @param *mode The mode of the value to project.
+ * @param proj The position of the value in the tuple.
+ */
+ir_node *new_d_Proj (dbg_info *db, ir_node *arg, ir_mode *mode, long proj);
+
+/** Constructor for a defaultProj node.
+ *
+ * Represents the default control flow of a Switch-Cond node.
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param arg A node producing a tuple.
+ * @param max_proj The end position of the value in the tuple.
+ */
+ir_node *new_d_defaultProj (dbg_info *db, ir_node *arg, long max_proj);
+
+/** Constructor for a Tuple node.
+ *
+ * This is an auxiliary node to replace a node that returns a tuple
+ * without changing the corresponding Proj nodes.
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param arity The number of tuple elements.
+ * @param **in An array containing pointers to the nodes producing the tuple elements.
+ */
+ir_node *new_d_Tuple (dbg_info *db, int arity, ir_node *in[]);
+
+/** Constructor for a Id node.
+ *
+ * This is an auxiliary node to replace a node that returns a single
+ * value. Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *val The operand to Id.
+ * @param *mode The mode of *val.
+ */
+ir_node *new_d_Id (dbg_info *db, ir_node *val, ir_mode *mode);
+
+/** Constructor for a Bad node.
+ *
+ * Returns the unique Bad node of the graph. The same as
+ * get_irg_bad().
+ */
+ir_node *new_d_Bad (void);
+
+/** Constructor for a Confirm node.
+ *
+ * Constructor for a Confirm node. Adds the node to the block in current_ir_block.
+ * Specifies constraints for a value. To support dataflow analyses.
+ *
+ * Example: If the value never exceeds '100' this is expressed by placing a
+ * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
+ *
+ * @param *db A pointer for debug information.
+ * @param *val The value we express a constraint for
+ * @param *bound The value to compare against. Must be a firm node, typically a constant.
+ * @param cmp The compare operation.
+ */
+ir_node *new_d_Confirm (dbg_info *db, ir_node *val, ir_node *bound, pn_Cmp cmp);
+
+/** Constructor for an Unknown node.
+ *
+ * Represents an arbitrary value. Places the node in
+ * the start block.
+ *
+ * @param *m The mode of the unknown value.
+ */
+ir_node *new_d_Unknown(ir_mode *m);
+
+/** Constructor for a CallBegin node.
+ *
+ * CallBegin represents control flow depending of the pointer value
+ * representing the called method to the called methods. The
+ * constructor copies the method pointer input from the passed Call
+ * node.Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ * @param *callee The call node visible in the intra procedural view.
+ */
+ir_node *new_d_CallBegin(dbg_info *db, ir_node *callee);
+
+/** Constructor for an EndReg node.
+ *
+ *Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ */
+ir_node *new_d_EndReg (dbg_info *db);
+
+/** Constructor for an EndExcept node.
+ *
+ * Used to represent regular procedure end in interprocedual view.
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *db A pointer for debug information.
+ */
+ir_node *new_d_EndExcept(dbg_info *db);
+
+/** Constructor for a Break node.
+ *
+ * Used to represent exceptional procedure end in interprocedural view.
+ * Adds the node to the block in current_ir_block.
+ *
+ * Break represents control flow to a single control successor just as Jmp.
+ * The blocks separated by a break may not be concatenated by an optimization.
+ * It is used for the interprocedural representation where blocks are parted
+ * behind Call nodes to represent the control flow to called procedures.
+ *
+ * @param *db A pointer for debug information.
+ */
+ir_node *new_d_Break (dbg_info *db);
+
+/** Constructor for a Filter node.
+ *
+ * Constructor for a Filter node. Adds the node to the block in
+ * current_ir_block. Filter is a node with two views used to
+ * construct the interprocedural view. In intraprocedural view its
+ * semantics are identical to the Proj node. In interprocedural view
+ * the Filter performs the Phi operation on method parameters or
+ * results. Other than a Phi a Filter node may not be removed if it
+ * has only a single input.
+ *
+ * The constructor builds the Filter in intraprocedural view.
+ *
+ * @param *db A pointer for debug information.
+ * @param *arg The tuple value to project from.
+ * @param *mode The mode of the projected value.
+ * @param proj The position in the tuple to project from.
+ */
+ir_node *new_d_Filter (dbg_info *db, ir_node *arg, ir_mode *mode, long proj);
+
+
+/** Constructor for a NoMem node.
+ *
+ * Returns the unique NoMem node of the graph. The same as
+ * get_irg_no_mem().
+ */
+ir_node *new_d_NoMem (void);
+
+/** Constructor for a Mux node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *sel The ir_node that calculates the boolean select.
+ * @param *ir_true The ir_node that calculates the true result.
+ * @param *ir_false The ir_node that calculates the false result.
+ * @param *mode The mode of the node (and it_true and ir_false).
+ */
+ir_node *new_d_Mux (dbg_info *db, ir_node *sel,
+ ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
+
+/** Constructor for a Psi node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *arity The arity of the conditions
+ * @param *conds The array of mode_b conditions, length must be equal arity
+ * @param *vals The array of mode values, length must be equal arity + 1
+ * @param *mode The mode of the node (must be the mode of all vals).
+ */
+ir_node *new_d_Psi (dbg_info *db,
+ int arity, ir_node *conds[], ir_node *vals[], ir_mode *mode);
+
+/** Constructor for a CopyB node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *store The current memory
+ * @param *dst The ir_node that represents the destination address.
+ * @param *src The ir_node that represents the source address.
+ * @param *data_type The type of the copied data
+ */
+ir_node *new_d_CopyB(dbg_info *db, ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
+
+/** Constructor for a InstOf node.
+ *
+ * A High-Level Type check.
+ *
+ * @param *db A pointer for debug information.
+ * @param *store The memory in which the object the entity should be selected
+ * from is allocated.
+ * @param *objptr A pointer to a object of a class type.
+ * @param *type The type of which objptr must be.
+ */
+ir_node *new_d_InstOf (dbg_info *db, ir_node *store, ir_node *objptr, ir_type *type);
+
+/** Constructor for a Raise node.
+ *
+ * A High-Level Exception throw.
+ *
+ * @param *db A pointer for debug information.
+ * @param *store The current memory.
+ * @param *obj A pointer to the Except variable.
+ */
+ir_node *new_d_Raise (dbg_info *db, ir_node *store, ir_node *obj);
+
+/** Constructor for a Bound node.
+ *
+ * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
+ *
+ * @param *db A pointer for debug information.
+ * @param *store The current memory
+ * @param *idx The ir_node that represents an index.
+ * @param *lower The ir_node that represents the lower bound for the index.
+ * @param *upper The ir_node that represents the upper bound for the index.
+ */
+ir_node *new_d_Bound(dbg_info *db, ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
+
+/** Constructor for a Pin node.
+ *
+ * @param *db A pointer for debug information.
+ * @param *node The node which value should be pinned.
+ */
+ir_node *new_d_Pin(dbg_info *db, ir_node *node);
+
+/** Constructor for an ASM pseudo node.
+ *
+ * @param *db A pointer for debug information.
+ * @param arity The number of data inputs to the node.
+ * @param *in The array of length arity of data inputs.
+ * @param *inputs The array of length arity of input constraints.
+ * @param n_outs The number of data outputs to the node.
+ * @param *outputs The array of length n_outs of output constraints.
+ * @param n_clobber The number of clobbered registers.
+ * @param *clobber The array of length n_clobber of clobbered registers.
+ * @param *asm_text The assembler text.
+ */
+ir_node *new_d_ASM(dbg_info *db, int arity, ir_node *in[], ir_asm_constraint *inputs,
+ int n_outs, ir_asm_constraint *outputs,
+ int n_clobber, ident *clobber[], ident *asm_text);
+
+/*-----------------------------------------------------------------------*/
+/* The block oriented interface without debug support */
+/*-----------------------------------------------------------------------*/
+
+/* Needed from the interface with debug support:
+void set_cur_block (ir_node *target); */
+
+/** Constructor for a Block node.
+ *
+ * Constructor for a Block node. Adds the block to the graph in
+ * current_ir_graph. Constructs a Block with a fixed number of
+ * predecessors. Does set current_block. Can be used with automatic
+ * Phi node construction.
+ *
+ * @param arity The number of control predecessors.
+ * @param in An array of control predecessors. The length of
+ * the array must be 'arity'.
+ */
+ir_node *new_Block(int arity, ir_node *in[]);
+
+/** Constructor for a Start node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ */
+ir_node *new_Start (void);
+
+/** Constructor for an End node.
+ *
+ * Adds the node to the block in current_ir_block.
+ */
+ir_node *new_End (void);
+
+/** Constructor for an EndReg node.
+ *
+ * Used to represent regular procedure end in interprocedual view.
+ * Adds the node to the block in current_ir_block.
+ */
+ir_node *new_EndReg (void);
+
+/** Constructor for an EndExpcept node.
+ *
+ * Used to represent exceptional procedure end in interprocedural view.
+ * Adds the node to the block in current_ir_block.
+ */
+ir_node *new_EndExcept(void);
+
+/** Constructor for a Jump node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * Jmp represents control flow to a single control successor.
+ */
+ir_node *new_Jmp (void);
+
+/** Constructor for an IJmp node.
+ *
+ * IJmp represents control flow to a single control successor not
+ * statically known i.e. an indirect Jmp.
+ *
+ * @param *tgt The ir node representing the target address.
+ */
+ir_node *new_IJmp (ir_node *tgt);
+
+/** Constructor for a Break node.
+ * Break represents control flow to a single control successor just as Jmp.
+ * The blocks separated by a break may not be concatenated by an optimization.
+ * It is used for the interprocedural representation where blocks are parted
+ * behind Call nodes to represent the control flow to called procedures.
+ * Adds the node to the block in current_ir_block.
+ */
+ir_node *new_Break (void);
+
+/** Constructor for a Cond node.
+ *
+ * If c is mode_b represents a conditional branch (if/else). If c is
+ * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
+ * node, default Proj is 0.). Adds the node to the block in current_ir_block.
+ *
+ * This is not consistent: Input to Cond is Is, Proj has as proj number
+ * longs.
+ *
+ *
+ * @param *c The conditions parameter.Can be of mode b or I_u.
+ */
+ir_node *new_Cond (ir_node *c);
+
+/** Constructor for a Return node.
+ *
+ * Returns the memory an zero or more return values. Only node that
+ * can end regular control flow. Adds the node to the block in current_ir_block.
+ *
+ * @param *store The state of memory.
+ * @param arity Number of array indices.
+ * @param *in Array with index inputs to the node.
+ */
+ir_node *new_Return (ir_node *store, int arity, ir_node *in[]);
+
+/** Constructor for a Const node.
+ *
+ * Constructor for a Const node. The constant represents a target
+ * value. Sets the type information to type_unknown. (No more
+ * supported: If tv is entity derives a somehow useful type.)
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *mode The mode of the operands and results.
+ * @param *con Points to an entry in the constant table. This pointer is
+ * added to the attributes of the node.
+ */
+ir_node *new_Const (ir_mode *mode, tarval *con);
+
+/**
+ * Make a const from a long.
+ * This is just convenience for the usual
+ * <code>
+ * new_Const(mode, tarval_from_long(mode, ...))
+ * </code>
+ * pain.
+ * @param mode The mode for the const.
+ * @param value The value of the constant.
+ * @return A new const node.
+ */
+ir_node *new_Const_long(ir_mode *mode, long value);
+
+/** Constructor for a Const node.
+ *
+ * Derives mode from passed type. */
+ir_node *new_Const_type(tarval *con, ir_type *tp);
+
+/** Constructor for a SymConst node.
+ *
+ * Adds the node to the block in current_ir_block.
+ * This is the constructor for a symbolic constant.
+ * There are four kinds of symbolic constants:
+ * -# type_tag The symbolic constant represents a type tag. The type the
+ * tag stands for is given explicitly.
+ * -# size The symbolic constant represents the size of a type. The
+ * type of which the constant represents the size is given
+ * explicitly.
+ * -# align The symbolic constant represents the alignment of a type. The
+ * type of which the constant represents the size is given
+ * explicitly.
+ * -# addr_name The symbolic constant represents the address of an entity
+ * (variable or method). The variable is indicated by a name
+ * that is valid for linking.
+ * -# addr_ent The symbolic constant represents the address of an entity
+ * (variable or method). The variable is given explicitly by
+ * a firm entity.
+ *
+ * Inputs to the node:
+ * No inputs except the block it belongs to.
+ * Outputs of the node.
+ * An unsigned integer (I_u) or a pointer (P).
+ *
+ * @param value A type or a ident depending on the SymConst kind.
+ * @param kind The kind of the symbolic constant: symconst_type_tag, symconst_type_size
+ * symconst_type_align, symconst_addr_name or symconst_addr_ent.
+ * @param tp The source type of the constant.
+ */
+ir_node *new_SymConst_type (union symconst_symbol value, symconst_kind kind, ir_type *tp);
+
+/** Constructor for a SymConst node.
+ *
+ * Adds the node to the block in current_ir_block.
+ * This is the constructor for a symbolic constant.
+ * There are four kinds of symbolic constants:
+ * -# type_tag The symbolic constant represents a type tag. The type the
+ * tag stands for is given explicitly.
+ * -# size The symbolic constant represents the size of a type. The
+ * type of which the constant represents the size is given
+ * explicitly.
+ * -# align The symbolic constant represents the alignment of a type. The
+ * type of which the constant represents the size is given
+ * explicitly.
+ * -# addr_name The symbolic constant represents the address of an entity
+ * (variable or method). The variable is indicated by a name
+ * that is valid for linking.
+ * -# addr_ent The symbolic constant represents the address of an entity
+ * (variable or method). The variable is given explicitly by
+ * a firm entity.
+ *
+ * Inputs to the node:
+ * No inputs except the block it belongs to.
+ * Outputs of the node.
+ * An unsigned integer (I_u) or a pointer (P).
+ *
+ * @param value A type or a ident depending on the SymConst kind.
+ * @param kind The kind of the symbolic constant: symconst_type_tag, symconst_type_size
+ * symconst_type_align, symconst_addr_name or symconst_addr_ent.
+ */
+ir_node *new_SymConst (union symconst_symbol value, symconst_kind kind);
+
+/** Constructor for a simpelSel node.
+ *
+ * This is a shortcut for the new_Sel() constructor. To be used for
+ * Sel nodes that do not select from an array, i.e., have no index
+ * inputs. It adds the two parameters 0, NULL.
+ *
+ * @param *store The memory in which the object the entity should be selected from is allocated.
+ * @param *objptr The object from that the Sel operation selects a single attribute out.
+ * @param *ent The entity to select.
+ */
+ir_node *new_simpleSel(ir_node *store, ir_node *objptr, ir_entity *ent);
+
+/** Constructor for a Sel node.
+ *
+ * The select node selects an entity (field or method) from an entity
+ * with a compound type. It explicitly specifies the entity selected.
+ * Dynamically the node may select entities that overwrite the given
+ * entity. If the selected entity is an array element entity the Sel
+ * node takes the required array indices as inputs.
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *store The memory in which the object the entity should be selected
+ * from is allocated.
+ * @param *objptr A pointer to a compound entity the Sel operation selects a
+ * single attribute from.
+ * @param arity The number of array indices needed to select an array element entity.
+ * @param *in[] If the compound entity is an array the indices of the selected
+ * element entity. The constructor copies this array.
+ * @param *ent The entity to select.
+ */
+ir_node *new_Sel (ir_node *store, ir_node *objptr, int arity, ir_node *in[],
+ ir_entity *ent);
+
+/** Constructor for a Call node.
+ *
+ * Adds the node to the block in current_ir_block.
+ * Represents all kinds of method and function calls.
+ *
+ * @param *store The actual store.
+ * @param *callee A pointer to the called procedure.
+ * @param arity The number of procedure parameters.
+ * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
+ * @param *tp Type information of the procedure called.
+ */
+ir_node *new_Call (ir_node *store, ir_node *callee, int arity, ir_node *in[],
+ ir_type *tp);
+
+/** Constructor for a CallBegin node.
+ *
+ * CallBegin represents control flow depending of the pointer value
+ * representing the called method to the called methods. The
+ * constructor copies the method pointer input from the passed Call
+ * node. Adds the node to the block in current_ir_block.
+ *
+ * @param *callee A pointer to the called procedure.
+ */
+ir_node *new_CallBegin(ir_node *callee);
+
+/** Constructor for a Add node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Sub node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Minus node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *op The operand .
+ * @param *mode The mode of the operand and the result.
+ */
+ir_node *new_Minus (ir_node *op, ir_mode *mode);
+
+/**
+ * Constructor for a Mul node. Adds the node to the block in current_ir_block.
+ *
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_Mul (ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Quot node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *memop The store needed to model exceptions
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the result.
+ */
+ir_node *new_Quot (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a DivMod node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *memop The store needed to model exceptions
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the results.
+ */
+ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Div node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *memop The store needed to model exceptions
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the result.
+ */
+ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Mod node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *memop The store needed to model exceptions
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the result.
+ */
+ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Abs node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *op The operand
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_Abs (ir_node *op, ir_mode *mode);
+
+/** Constructor for a And node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/**
+ * Constructor for a Or node. Adds the node to the block in current_ir_block.
+ *
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/**
+ * Constructor for a Eor node. Adds the node to the block in current_ir_block.
+ *
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the results.
+ */
+ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Not node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *op The operand.
+ * @param *mode The mode of the operand and the result.
+ */
+ir_node *new_Not (ir_node *op, ir_mode *mode);
+
+/** Constructor for a Shl node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *op The operand.
+ * @param *k The number of bits to shift the operand .
+ * @param *mode The mode of the operand and the result.
+ */
+ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode);
+
+/**
+ * Constructor for a Shr node. Adds the node to the block in current_ir_block.
+ *
+ * @param *op The operand.
+ * @param *k The number of bits to shift the operand .
+ * @param *mode The mode of the operand and the result.
+ */
+ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode);
+
+/** Constructor for a Shrs node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *op The operand.
+ * @param *k The number of bits to shift the operand .
+ * @param *mode The mode of the operand and the result.
+ */
+ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode);
+
+/** Constructor for a Rot node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *op The operand.
+ * @param *k The number of bits to rotate the operand.
+ * @param *mode The mode of the operand.
+ */
+ir_node *new_Rot (ir_node *op, ir_node *k, ir_mode *mode);
+
+/** Constructor for a Cmp node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ */
+ir_node *new_Cmp (ir_node *op1, ir_node *op2);
+
+/** Constructor for a Conv node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *op The operand.
+ * @param *mode The mode of this the operand muss be converted.
+ */
+ir_node *new_Conv (ir_node *op, ir_mode *mode);
+
+/** Constructor for a strict Conv node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *op The operand.
+ * @param *mode The mode of this the operand muss be converted.
+ */
+ir_node *new_strictConv (ir_node *op, ir_mode *mode);
+
+/** Constructor for a Cast node.
+ *
+ * Adds the node to the block in current_ir_block.
+ * High level type cast
+ *
+ * @param *op The operand.
+ * @param *to_tp The type of this the operand muss be casted .
+ */
+ir_node *new_Cast (ir_node *op, ir_type *to_tp);
+
+/** Constructor for a Carry node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_Carry (ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Borrow node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *op1 The first operand.
+ * @param *op2 The second operand.
+ * @param *mode The mode of the operands and the result.
+ */
+ir_node *new_Borrow (ir_node *op1, ir_node *op2, ir_mode *mode);
+
+/** Constructor for a Phi node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param arity The number of predecessors.
+ * @param *in Array with predecessors.
+ * @param *mode The mode of it's inputs and output.
+ */
+ir_node *new_Phi (int arity, ir_node *in[], ir_mode *mode);
+
+/** Constructor for a Load node.
+ *
+ * @param *store The current memory.
+ * @param *addr A pointer to the variable to be read in this memory.
+ * @param *mode The mode of the value to be loaded.
+ */
+ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode);
+
+/** Constructor for a Store node.
+ *
+ * @param *store The current memory.
+ * @param *addr A pointer to the variable to be read in this memory.
+ * @param *val The value to write to this variable.
+ */
+ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val);
+
+/** Constructor for a Alloc node.
+ *
+ * The Alloc node extends the memory by space for an entity of type alloc_type.
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *store The memory which shall contain the new variable.
+ * @param *size The number of bytes to allocate.
+ * @param *alloc_type The type of the allocated variable.
+ * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
+ */
+ir_node *new_Alloc (ir_node *store, ir_node *size, ir_type *alloc_type,
+ where_alloc where);
+
+/** Constructor for a Free node.
+ *
+ * Frees the memory occupied by the entity pointed to by the pointer
+ * arg. Type indicates the type of the entity the argument points to.
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *store The memory which shall contain the new variable.
+ * @param *ptr The pointer to the object to free.
+ * @param *size The number of objects of type free_type to free in a sequence.
+ * @param *free_type The type of the freed variable.
+ * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
+ */
+ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size,
+ ir_type *free_type, where_alloc where);
+
+/** Constructor for a Sync node.
+ *
+ * Merges several memory values. The node assumes that a variable
+ * either occurs only in one of the memories, or it contains the same
+ * value in all memories where it occurs.
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param arity The number of memories to synchronize.
+ * @param **in An array of pointers to nodes that produce an output of type
+ * memory. The constructor copies this array.
+ */
+ir_node *new_Sync (int arity, ir_node *in[]);
+
+/** Constructor for a Proj node.
+ *
+ * Projects a single value out of a tuple. The parameter proj gives the
+ * position of the value within the tuple.
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param arg A node producing a tuple.
+ * @param *mode The mode of the value to project.
+ * @param proj The position of the value in the tuple.
+ */
+ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj);
+
+/** Constructor for a Filter node.
+ *
+ * Constructor for a Filter node. Adds the node to the block in current_ir_block.
+ * Filter is a node with two views used to construct the interprocedural view.
+ * In intraprocedural view its semantics are identical to the Proj node.
+ * In interprocedural view the Filter performs the Phi operation on method
+ * parameters or results. Other than a Phi a Filter node may not be removed
+ * if it has only a single input.
+ *
+ * The constructor builds the Filter in intraprocedural view.
+ *
+ * @param *arg The tuple value to project from.
+ * @param *mode The mode of the projected value.
+ * @param proj The position in the tuple to project from.
+ */
+ir_node *new_Filter (ir_node *arg, ir_mode *mode, long proj);
+
+/** Constructor for a defaultProj node.
+ *
+ * Represents the default control flow of a Switch-Cond node.
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param arg A node producing a tuple.
+ * @param max_proj The end position of the value in the tuple.
+ */
+ir_node *new_defaultProj (ir_node *arg, long max_proj);
+
+/** Constructor for a Tuple node.
+ *
+ * This is an auxiliary node to replace a node that returns a tuple
+ * without changing the corresponding Proj nodes.
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param arity The number of tuple elements.
+ * @param **in An array containing pointers to the nodes producing the tuple elements.
+ */
+ir_node *new_Tuple (int arity, ir_node *in[]);
+
+/** Constructor for an Id node.
+ *
+ * This is an auxiliary node to replace a node that returns a single
+ * value. Adds the node to the block in current_ir_block.
+ *
+ * @param *val The operand to Id.
+ * @param *mode The mode of *val.
+ */
+ir_node *new_Id (ir_node *val, ir_mode *mode);
+
+/** Constructor for a Bad node.
+ *
+ * Returns the unique Bad node of the graph. The same as
+ * get_irg_bad().
+ */
+ir_node *new_Bad (void);
+
+/** Constructor for a Confirm node.
+ *
+ * Specifies constraints for a value. To support dataflow analyses.
+ * Adds the node to the block in current_ir_block.
+ *
+ * Example: If the value never exceeds '100' this is expressed by placing a
+ * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
+ *
+ * @param *val The value we express a constraint for
+ * @param *bound The value to compare against. Must be a firm node, typically a constant.
+ * @param cmp The compare operation.
+ */
+ir_node *new_Confirm (ir_node *val, ir_node *bound, pn_Cmp cmp);
+
+/** Constructor for an Unknown node.
+ *
+ * Represents an arbitrary value. Places the node in
+ * the start block.
+ *
+ * @param *m The mode of the unknown value.
+ */
+ir_node *new_Unknown(ir_mode *m);
+
+/** Constructor for a NoMem node.
+ *
+ * Returns the unique NoMem node of the graph. The same as
+ * get_irg_no_mem().
+ */
+ir_node *new_NoMem (void);
+
+/** Constructor for a Mux node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *sel The ir_node that calculates the boolean select.
+ * @param *ir_true The ir_node that calculates the true result.
+ * @param *ir_false The ir_node that calculates the false result.
+ * @param *mode The mode of the node (and it_true and ir_false).
+ */
+ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
+
+/** Constructor for a Psi node.
+ *
+ * @param *arity The arity of the conditions
+ * @param *conds The array of mode_b conditions, length must be equal arity
+ * @param *vals The array of mode values, length must be equal arity + 1
+ * @param *mode The mode of the node (must be the mode of all vals).
+ */
+ir_node *new_Psi (int arity, ir_node *conds[], ir_node *vals[], ir_mode *mode);
+
+/** Constructor for a CopyB node.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *store The current memory
+ * @param *dst The ir_node that represents the destination address.
+ * @param *src The ir_node that represents the source address.
+ * @param *data_type The type of the copied data
+ */
+ir_node *new_CopyB(ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
+
+/** Constructor for a InstOf node.
+ *
+ * A High-Level Type check.
+ *
+ * @param *store The memory in which the object the entity should be selected
+ * from is allocated.
+ * @param *objptr A pointer to a object of a class type.
+ * @param *type The type of which objptr must be.
+ */
+ir_node *new_InstOf (ir_node *store, ir_node *objptr, ir_type *type);
+
+/**Constructor for a Raise node.
+ *
+ * A High-Level Exception throw.
+ *
+ * @param *store The current memory.
+ * @param *obj A pointer to the Except variable.
+ */
+ir_node *new_Raise (ir_node *store, ir_node *obj);
+
+/** Constructor for a Bound node.
+ *
+ * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
+ *
+ * Adds the node to the block in current_ir_block.
+ *
+ * @param *store The current memory
+ * @param *idx The ir_node that represents an index.
+ * @param *lower The ir_node that represents the lower bound for the index.
+ * @param *upper The ir_node that represents the upper bound for the index.
+ */
+ir_node *new_Bound (ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
+
+/** Constructor for a Pin node.
+ *
+ * @param *node The node which value should be pinned.
+ */
+ir_node *new_Pin (ir_node *node);
+
+/** Constructor for an ASM pseudo node.
+ *
+ * @param arity The number of data inputs to the node.
+ * @param *in The array of length arity of data inputs.
+ * @param *inputs The array of length arity of input constraints.
+ * @param n_outs The number of data outputs to the node.
+ * @param *outputs The array of length n_outs of output constraints.
+ * @param n_clobber The number of clobbered registers.
+ * @param *clobber The array of length n_clobber of clobbered registers.
+ * @param *asm_text The assembler text.
+ */
+ir_node *new_ASM(int arity, ir_node *in[], ir_asm_constraint *inputs,
+ int n_outs, ir_asm_constraint *outputs,
+ int n_clobber, ident *clobber[], ident *asm_text);
+
+/*---------------------------------------------------------------------*/
+/* The comfortable interface. */
+/* Supports automatic Phi node construction. */
+/* All routines of the block oriented interface except new_Block are */
+/* needed also. */
+/*---------------------------------------------------------------------*/
+
+/** Create an immature Block.
+ *
+ * An immature Block has an unknown number of predecessors. Predecessors
+ * can be added with add_immBlock_pred(). Once all predecessors are
+ * added the block must be matured.
+ *
+ * Adds the block to the graph in current_ir_graph. Does set
+ * current_block. Can be used with automatic Phi node construction.
+ * This constructor can only be used if the graph is in
+ * state_building.
+ */
+ir_node *new_d_immBlock(dbg_info *db);
+ir_node *new_immBlock(void);
+
+/** Create an immature PartBlock.
+ *
+ * An immature block has only one Block or PartBlock predecessor.
+ * A PartBlock forms together with one BLock and possibly other
+ * PartBlocks a MacroBlock.
+ *
+ * Adds the PartBlock to the graph in current_ir_graph. Does set
+ * current_block. Can be used with automatic Phi node construction.
+ * This constructor can only be used if the graph is in
+ * state_building.
+ */
+ir_node *new_d_immPartBlock(dbg_info *db, ir_node *pred_jmp);
+ir_node *new_immPartBlock(ir_node *pred_jmp);
+
+/** Add a control flow edge to an immature block. */
+void add_immBlock_pred(ir_node *immblock, ir_node *jmp);
+
+/** Finalize a Block node, when all control flows are known. */
+void mature_immBlock(ir_node *block);
+#define mature_cur_block() mature_immBlock(get_cur_block());
+
+
+/** Get the current value of a local variable.
+ *
+ * Use this function to obtain the last definition of the local variable
+ * associated with pos. Pos may not exceed the value passed as n_loc
+ * to new_ir_graph. This call automatically inserts Phi nodes.
+ *
+ * @param *db A pointer for debug information.
+ * @param pos The position/id of the local variable.
+ * @param *mode The mode of the value to get.
+ */
+ir_node *get_d_value(dbg_info *db, int pos, ir_mode *mode);
+ir_node *get_value(int pos, ir_mode *mode);
+
+/** Remark a new definition of a variable.
+ *
+ * Use this function to remember a new definition of the value
+ * associated with pos. Pos may not exceed the value passed as n_loc
+ * to new_ir_graph. This call is needed to automatically inserts Phi
+ * nodes.
+ *
+ * @param pos The position/id of the local variable.
+ * @param *value The new value written to the local variable.
+ */
+void set_value(int pos, ir_node *value);
+
+/** Find the value number for a node in the current block.
+ *
+ * This function searches all values in the current block for
+ * a given value and returns its value number if it was found, else
+ * -1.
+ * Note that this does not mean that the value does not exists,
+ * it's just not equal the node (for instance behind a Phi/Confirm ...)
+ *
+ * @param *value The value to find.
+ */
+int find_value(ir_node *value);
+
+/** Get the current memory state.
+ *
+ * Use this function to obtain the last definition of the memory
+ * state. This call automatically inserts Phi nodes for the memory
+ * state value.
+ */
+ir_node *get_store(void);
+
+/** Remark a new definition of the memory state.
+ *
+ * Use this function to remember a new definition of the memory state.
+ * This call is needed to automatically inserts Phi nodes.
+ *
+ * @param *store The new memory state.
+ */
+void set_store(ir_node *store);
+
+/** keep this node alive even if End is not control-reachable from it
+ *
+ * @param ka The node to keep alive.
+ */
+void keep_alive(ir_node *ka);
+
+/** Returns the frame type of the current graph */
+ir_type *get_cur_frame_type(void);
+
+
+/* --- initialize and finalize ir construction --- */
+
+/** Puts the graph into state "phase_high" */
+#define irg_finalize_cons(irg) set_irg_phase_state(irg, phase_high)
+
+/** Puts the program and all graphs into state phase_high.
+ *
+ * This also remarks, the construction of types is finished,
+ * e.g., that no more subtypes will be added. */
+void irp_finalize_cons(void);
+
+/* --- Initialization --- */
+
+/**
+ * This function is called, whenever a local variable is used before definition
+ *
+ * @param irg the IR graph on which this happens
+ * @param mode the mode of the local var
+ * @param pos position chosen be the frontend for this variable (n_loc)
+ *
+ * @return a firm node of mode @p mode that initializes the var at position pos
+ *
+ * @note
+ * Do not return NULL!
+ * If this function is not set, FIRM will create a const node with tarval BAD.
+ * Use set_irg_loc_description()/get_irg_loc_description() to assign additional
+ * informations to local variables.
+ */
+typedef ir_node *uninitialized_local_variable_func_t(ir_graph *irg, ir_mode *mode, int pos);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Construction of Confirm nodes
+ * @author Michael Beck
+ * @date 6.2005
+ * @version $Id$
+ */
+#ifndef FIRM_ANA_IRCONSCONFIRM_H
+#define FIRM_ANA_IRCONSCONFIRM_H
+
+#include "firm_types.h"
+
+/**
+ * Inject Confirm nodes into a graph.
+ *
+ * @param irg the graph
+ *
+ * Confirm nodes carry confirmation information, such as
+ * a relation between a value a and another value (or a constant)
+ * b.
+ *
+ * These allows to do some range dependent optimizations for Cmp,
+ * Abs, Min, Max nodes as well as bounds checking deletion.
+ *
+ * The heap analysis might profit also. On the other side, Confirm
+ * nodes disturb local optimizations, because patterns are destroyed.
+ *
+ * It is possible to avoid this by skipping Confirm nodes, but this
+ * is not implemented and is not cheap. The same happens with Casts
+ * nodes too. The current solution is to remove Confirms at a later
+ * pass.
+ */
+void construct_confirms(ir_graph *irg);
+
+/**
+ * Remove all Confirm nodes from a graph.
+ *
+ * Note that local_optimize() can handle this if
+ * the remove Confirm node setting is on (set_opt_remove_Confirm(1)).
+ */
+void remove_confirms(ir_graph *irg);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Construct and access dominator tree.
+ * @author Goetz Lindenmaier
+ * @date 2.2002
+ * @version $Id$
+ * @summary
+ * This file contains routines to construct and access dominator information.
+ *
+ * The dominator information is stored in three fields of block nodes:
+ * - idom: a reference to the block that is the immediate dominator of
+ * this block.
+ * - dom_depth: a number giving the depth of the block in the dominator
+ * tree.
+ * - pre_num: Number in preorder traversal.
+ */
+#ifndef FIRM_ANA_IRDOM_H
+#define FIRM_ANA_IRDOM_H
+
+#include "firm_types.h"
+
+
+/** Accessing the dominator data structure.
+ *
+ * These routines only work properly if the ir_graph is in state
+ * dom_consistent or dom_inconsistent.
+ *
+ * If the block is not reachable from Start, returns a Bad node.
+ */
+ir_node *get_Block_idom(const ir_node *bl);
+void set_Block_idom(ir_node *bl, ir_node *n);
+
+int get_Block_dom_depth(const ir_node *bl);
+void set_Block_dom_depth(ir_node *bl, int depth);
+
+int get_Block_dom_pre_num(const ir_node *bl);
+void set_Block_dom_pre_num(ir_node *bl, int num);
+
+/** Accessing the post dominator data structure.
+ *
+ * These routines only work properly if the ir_graph is in state
+ * dom_consistent or dom_inconsistent.
+ *
+ * If the block is not reachable from End, returns a Bad node.
+ */
+ir_node *get_Block_ipostdom(const ir_node *bl);
+void set_Block_ipostdom(ir_node *bl, ir_node *n);
+
+int get_Block_postdom_depth(const ir_node *bl);
+void set_Block_postdom_depth(ir_node *bl, int depth);
+
+int get_Block_postdom_pre_num(const ir_node *bl);
+void set_Block_postdom_pre_num(ir_node *bl, int num);
+
+/**
+ * Get the pre-order number of a block resulting from a
+ * Depth-First-Search walkover the dominator tree.
+ *
+ * @param bl The block.
+ * @return The pre-order number.
+ */
+unsigned get_Block_dom_tree_pre_num(const ir_node *bl);
+
+/**
+ * Get the largest pre-order number found in the subtree of the
+ * dominator tree rooted at a given block.
+ * @param bl The block.
+ * @return The largest pre-order number of block's dominator subtree.
+ */
+unsigned get_Block_dom_max_subtree_pre_num(const ir_node *bl);
+
+/**
+ * Get the first node in the list of nodes dominated by a given block.
+ *
+ * Each node keeps a list of nodes which it immediately dominates. The
+ * nodes are queued using the @c next pointer in the @c dom_info struct.
+ * Each node keeps a head of this list using the pointer @c first in the
+ * same structure.
+ *
+ * @param bl The block for which to get the first node dominated by @c bl.
+ * @return The first node dominated by @p bl.
+ */
+ir_node *get_Block_dominated_first(const ir_node *bl);
+
+/**
+ * Get the next node in a list of nodes which are dominated by some
+ * other node.
+ * @see get_Block_dominated_first().
+ * @param dom The previous node.
+ * @return The next node in this list or NULL if it was the last.
+ */
+ir_node *get_Block_dominated_next(const ir_node *dom);
+
+/**
+ * Iterate over all nodes which are immediately dominated by a given
+ * node.
+ * @param bl The block whose dominated blocks shall be iterated on.
+ * @param curr An iterator variable of type ir_node*
+ */
+#define dominates_for_each(bl,curr) \
+ for(curr = get_Block_dominated_first(bl); curr; \
+ curr = get_Block_dominated_next(curr))
+
+/**
+ * Iterate over all nodes which are immediately post dominated by a given
+ * node.
+ * @param bl The block whose post dominated blocks shall be iterated on.
+ * @param curr An iterator variable of type ir_node*
+ */
+#define postdominates_for_each(bl,curr) \
+ for(curr = get_Block_postdominated_first(bl); curr; \
+ curr = get_Block_postdominated_next(curr))
+
+/**
+ * Check, if a block dominates another block.
+ * @param a The first block.
+ * @param b The second block.
+ * @return 1, if @p a dominates @p b, else 0.
+ */
+int block_dominates(const ir_node *a, const ir_node *b);
+
+/**
+ * Returns the smallest common dominator block of two nodes.
+ * @param a A node.
+ * @param b Another node.
+ * @return The first block dominating @p a and @p b
+ */
+ir_node *node_smallest_common_dominator(ir_node *a, ir_node *b);
+
+/**
+ * Returns the smallest common dominator block of all users of a node
+ * BEWARE: @p irn must not be a block
+ * If on or more users are Phi nodes, one can request special handling
+ * with @p handle_phi = 1. In this case the cfg predecessor block
+ * corresponding to the position of the irn in the argument list of the
+ * Phi is determined and treated as user.
+ *
+ * @param irn A node.
+ * @param handle_phi 1 if Phis should be handled different
+ * @return The first block dominating all users of @irn
+ */
+ir_node *node_users_smallest_common_dominator(ir_node *irn, int handle_phi);
+
+/**
+ * Check, if a block post dominates another block.
+ * @param a The first block.
+ * @param b The second block.
+ * @return 1, if @p a post dominates @p b, else 0.
+ */
+int block_postdominates(const ir_node *a, const ir_node *b);
+
+/**
+ * Visit all nodes in the dominator subtree of a given node.
+ * Call a pre-visitor before descending to the children and call a
+ * post-visitor after returning from them.
+ * @param n The node to start walking from.
+ * @param pre The pre-visitor callback.
+ * @param post The post-visitor callback.
+ * @param env Some custom data passed to the visitors.
+ */
+void dom_tree_walk(ir_node *n, irg_walk_func *pre,
+ irg_walk_func *post, void *env);
+
+/**
+ * Visit all nodes in the post dominator subtree of a given node.
+ * Call a pre-visitor before descending to the children and call a
+ * post-visitor after returning from them.
+ * @param n The node to start walking from.
+ * @param pre The pre-visitor callback.
+ * @param post The post-visitor callback.
+ * @param env Some custom data passed to the visitors.
+ */
+void postdom_tree_walk(ir_node *n, irg_walk_func *pre,
+ irg_walk_func *post, void *env);
+
+/**
+ * Walk over the dominator tree of an irg starting at the root.
+ * @param irg The graph.
+ * @param pre A pre-visitor to call.
+ * @param post A post-visitor to call.
+ * @param env Some private data to give to the visitors.
+ */
+void dom_tree_walk_irg(ir_graph *irg, irg_walk_func *pre,
+ irg_walk_func *post, void *env);
+
+/**
+ * Walk over the post dominator tree of an irg starting at the root.
+ * @param irg The graph.
+ * @param pre A pre-visitor to call.
+ * @param post A post-visitor to call.
+ * @param env Some private data to give to the visitors.
+ */
+void postdom_tree_walk_irg(ir_graph *irg, irg_walk_func *pre,
+ irg_walk_func *post, void *env);
+
+/* ------------ Building and Removing the dominator data structure ----------- */
+
+/** Computes the dominator trees.
+ *
+ * Sets a flag in irg to "dom_consistent".
+ * If the control flow of the graph is changed this flag must be set to
+ * "dom_inconsistent".
+ * Does not compute dominator information for control dead code. Blocks
+ * not reachable from Start contain the following information:
+ * @code
+ * idom = NULL;
+ * dom_depth = -1;
+ * pre_num = -1;
+ * @endcode
+ * Also constructs outs information. As this information is correct after
+ * the run does not free the outs information.
+ */
+void compute_doms(ir_graph *irg);
+
+/** Computes the dominator trees on demand */
+void assure_doms(ir_graph *irg);
+
+/** Computes the post dominator trees.
+ *
+ * Sets a flag in irg to "dom_consistent".
+ * If the control flow of the graph is changed this flag must be set to
+ * "dom_inconsistent".
+ * Does not compute post dominator information for endless lops. Blocks
+ * not reachable from End contain the following information:
+ * @code
+ * idom = NULL;
+ * dom_depth = -1;
+ * pre_num = -1;
+ * @endcode
+ * Also constructs outs information. As this information is correct after
+ * the run does not free the outs information.
+ */
+void compute_postdoms(ir_graph *irg);
+
+/** Computes the dominator trees on demand */
+void assure_postdoms(ir_graph *irg);
+
+/** Frees the dominator data structures. Sets the flag in irg to "dom_none". */
+void free_dom(ir_graph *irg);
+
+/** Frees the post dominator data structures. Sets the flag in irg to "dom_none". */
+void free_postdom(ir_graph *irg);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Write vcg representation of firm to file.
+ * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Hubert Schmidt
+ * @version $Id$
+ * @summary
+ * Dump routines for the ir graph and all type information.
+ *
+ * The dump format of most functions is vcg. This is a text based graph
+ * representation. Some use the original format,
+ * but most generate an extended format that is only read by some special
+ * versions of xvcg or by the comercialized version now calles aiSee.
+ * A test version of aiSee is available at
+ * http://www.absint.de/aisee/download/index.htm.
+ *
+ * We have developed an own advanced viewer called ycomp:
+ * http://www.info.uni-karlsruhe.de/software.php/id=6&lang=en
+ *
+ * Most routines use the name of the passed entity as the name of the
+ * file dumped to.
+ */
+#ifndef FIRM_IR_IRDUMP_H
+#define FIRM_IR_IRDUMP_H
+
+#include "irnode.h"
+#include "irgraph.h"
+#include "irloop.h"
+
+/**
+ * Names of the 32 supported colors
+ */
+typedef enum {
+ ird_color_default = -1,
+ ird_color_white = 0,
+ ird_color_blue = 1,
+ ird_color_red = 2,
+ ird_color_green = 3,
+ ird_color_yellow = 4,
+ ird_color_magenta = 5,
+ ird_color_cyan = 6,
+ ird_color_darkgray = 7,
+ ird_color_darkblue = 8,
+ ird_color_darkred = 9,
+ ird_color_darkgreen = 10,
+ ird_color_darkyellow = 11,
+ ird_color_darkmagenta = 12,
+ ird_color_darkcyan = 13,
+ ird_color_gold = 14,
+ ird_color_lightgray = 15,
+ ird_color_lightblue = 16,
+ ird_color_lightred = 17,
+ ird_color_lightgreen = 18,
+ ird_color_lightyellow = 19,
+ ird_color_lightmagenta = 20,
+ ird_color_lightcyan = 21,
+ ird_color_lilac = 22,
+ ird_color_turquoise = 23,
+ ird_color_aquamarine = 24,
+ ird_color_khaki = 25,
+ ird_color_purple = 26,
+ ird_color_yellowgreen = 27,
+ ird_color_pink = 28,
+ ird_color_orange = 29,
+ ird_color_orchid = 30,
+ ird_color_black = 31
+} dumper_colors;
+
+/**
+ * Edge kinds
+ */
+typedef enum {
+ data_edge = 0x01, /**< a data edge between two basic blocks */
+ block_edge = 0x02, /**< an edge from a node to its basic block */
+ cf_edge = 0x03, /**< regularly control flow edge */
+ exc_cf_edge = 0x04, /**< exceptional control flow edge */
+ mem_edge = 0x05, /**< memory edge */
+ dominator_edge = 0x06, /**< dominator edge */
+ node2type_edge = 0x07, /**< an edge from an IR node to a type */
+
+ ent_type_edge = 0x11, /**< an edge from an entity to its type */
+ ent_own_edge = 0x12, /**< an edge from an entity to its owner type */
+ ent_overwrites_edge = 0x13, /**< an edge from an entity to the entity it overwrites */
+ ent_value_edge = 0x14, /**< an edge from an entity to its value entity */
+ ent_corr_edge = 0x15, /**< an edge from an entity to the member entity its initializes */
+
+ meth_par_edge = 0x21, /**< an edge from a method type to one of its parameter types */
+ meth_res_edge = 0x22, /**< an edge from a method type to one of its result types */
+ type_super_edge = 0x23, /**< an edge from a class type to its super/basis type */
+ union_edge = 0x24, /**< an edge from a union type to its member types */
+ ptr_pts_to_edge = 0x25, /**< an edge from a pointer type to its points-to type */
+ arr_elt_type_edge = 0x26, /**< an edge from an array type to its element type */
+ arr_ent_edge = 0x27, /**< an edge from a array type to its element entity */
+ type_member_edge = 0x28, /**< an edge from a compound type to its member entities */
+
+ /* additional flags */
+ intra_edge = 0, /**< intra edge flag: edge do not cross basic block boundaries */
+ inter_edge = 0x40, /**< inter edge flag: edge cross basic block boundaries */
+ back_edge = 0x80 /**< backwards edge flag */
+} edge_kind;
+
+/* **************************************************************************** */
+/* GRAPH DUMPERS */
+/* **************************************************************************** */
+
+/**
+ * This hook is called to insert some special nodes into dumped graph
+ */
+typedef int (*DUMP_IR_GRAPH_FUNC)(FILE *F, ir_graph *irg);
+/**
+ * This hook is called to dump the vcg attributes of a node to a file.
+ * If this function returns zero, the default attributes are added, else
+ * removed.
+ */
+typedef int (*DUMP_NODE_VCGATTR_FUNC)(FILE *F, ir_node *node, ir_node *local);
+/**
+ * This hook is called to dump the vcg attributes of an edge to a file.
+ * If this function returns zero, the default attributes are added, else
+ * removed.
+ */
+typedef int (*DUMP_EDGE_VCGATTR_FUNC)(FILE *F, ir_node *node, int to);
+
+/** Set the ir graph dump hook. */
+void set_dump_ir_graph_hook(DUMP_IR_GRAPH_FUNC hook);
+/** Set the node_vcgattr hook. */
+void set_dump_node_vcgattr_hook(DUMP_NODE_VCGATTR_FUNC hook);
+/** Set the edge_vcgattr hook. */
+void set_dump_edge_vcgattr_hook(DUMP_EDGE_VCGATTR_FUNC hook);
+
+typedef int (*DUMP_NODE_EDGE_FUNC)(FILE *f, ir_node *node);
+
+/**
+ * Set the hook to be called to dump additional edges to a node.
+ * @param func The hook to be called.
+ */
+void set_dump_node_edge_hook(DUMP_NODE_EDGE_FUNC func);
+
+/**
+ * Get the additional edge dump hook.
+ * @return The current additional edge dump hook.]
+ */
+DUMP_NODE_EDGE_FUNC get_dump_node_edge_hook(void);
+
+/**
+ * Set the hook to be called to dump additional edges to a block.
+ * @param func The hook to be called.
+ */
+void set_dump_block_edge_hook(DUMP_NODE_EDGE_FUNC func);
+
+/**
+ * Get the additional block edge dump hook.
+ * @return The current additional block edge dump hook.
+ */
+DUMP_NODE_EDGE_FUNC get_dump_block_edge_hook(void);
+
+/** Dump a firm graph.
+ *
+ * @param irg The firm graph to be dumped.
+ * @param suffix A suffix for the file name.
+ *
+ * @return
+ * A file containing the firm graph in vcg format.
+ *
+ * Dumps all Firm nodes of a single graph for a single procedure in
+ * standard xvcg format. Dumps the graph to a file. The file name
+ * is constructed from the name of the entity describing the
+ * procedure (irg->entity) and the ending -pure<-ip>.vcg. Eventually
+ * overwrites existing files. Visits all nodes in
+ * interprocedural_view.
+ *
+ * @see turn_off_edge_labels()
+ */
+void dump_ir_graph (ir_graph *irg, const char *suffix);
+
+/** Dump a firm graph without explicit block nodes.
+ *
+ * @param irg The firm graph to be dumped.
+ * @param suffix A suffix for the file name.
+ *
+ * @return
+ * A file containing the firm graph in vcg format.
+ *
+ * Dumps all Firm nodes of a single graph for a single procedure in
+ * extended xvcg format.
+ * Dumps the graph to a file. The file name is constructed from the
+ * name of the entity describing the procedure (irg->entity) and the
+ * ending <-ip>.vcg. Eventually overwrites existing files. Dumps several
+ * procedures in boxes if interprocedural_view.
+ *
+ * @see turn_off_edge_labels()
+ */
+void dump_ir_block_graph (ir_graph *irg, const char *suffix);
+
+/** Dump a firm graph without explicit block nodes but grouped in extended blocks.
+ *
+ * @param irg The firm graph to be dumped.
+ *
+ * @return
+ * A file containing the firm graph in vcg format.
+ *
+ * Dumps all Firm nodes of a single graph for a single procedure in
+ * extended xvcg format.
+ * Dumps the graph to a file. The file name is constructed from the
+ * name of the entity describing the procedure (irg->entity) and the
+ * ending <-ip>.vcg. Eventually overwrites existing files. Dumps several
+ * procedures in boxes if interprocedural_view.
+ *
+ * @see turn_off_edge_labels()
+ */
+void dump_ir_extblock_graph (ir_graph *irg, const char *suffix);
+
+/** Dumps all graphs in interprocedural view to a file named All_graphs<suffix>.vcg.
+ *
+ * @param suffix A suffix for the file name.
+ */
+void dump_all_cg_block_graph(const char *suffix);
+
+/** Dumps a firm graph and all the type information needed for Calls,
+ * Sels, ... in this graph.
+ *
+ * @param irg The firm graph to be dumped with its type information.
+ * @param suffix A suffix for the file name.
+ *
+ * @return
+ * A file containing the firm graph and the type information of the firm graph in vcg format.
+ *
+ * Dumps the graph to a file. The file name is constructed from the
+ * name of the entity describing the procedure (irg->entity) and the
+ * ending -all.vcg. Eventually overwrites existing files.
+ *
+ * @see turn_off_edge_labels()
+ */
+void dump_ir_graph_w_types (ir_graph *irg, const char *suffix);
+
+/** Dumps a firm graph and all the type information needed for Calls,
+ * Sels, ... in this graph.
+ *
+ * @param irg The firm graph to be dumped with its type information.
+ * @param suffix A suffix for the file name.
+ *
+ * @return
+ * A file containing the firm graph and the type information of the firm graph in vcg format.
+ *
+ * The graph is in blocked format.
+ * Dumps the graph to a file. The file name is constructed from the
+ * name of the entity describing the procedure (irg->entity) and the
+ * ending -all.vcg. Eventually overwrites existing files.
+ *
+ * @see turn_off_edge_labels()
+ */
+void dump_ir_block_graph_w_types (ir_graph *irg, const char *suffix);
+
+/** The type of a dump function that is called for each graph.
+ *
+ * @param irg current visited graph
+ * @param suffix A suffix for the file name.
+ */
+typedef void dump_graph_func(ir_graph *irg, const char *suffix);
+
+/**
+ * A walker that calls a dumper for each graph.
+ *
+ * @param dump_graph The dumper to be used for dumping.
+ * @param suffix A suffix for the file name.
+ *
+ * @return
+ * Whatever the dumper creates.
+ *
+ * Walks over all firm graphs and calls a dumper for each graph.
+ * The following dumpers can be passed as arguments:
+ * - dump_ir_graph()
+ * - dump_ir_block_graph()
+ * - dump_cfg()
+ * - dump_type_graph()
+ * - dump_ir_graph_w_types()
+ *
+ * @see turn_off_edge_labels()
+ */
+void dump_all_ir_graphs (dump_graph_func *dump_graph, const char *suffix);
+
+
+/**
+ * Dump the control flow graph of a procedure.
+ *
+ * @param irg The firm graph whose CFG shall be dumped.
+ * @param suffix A suffix for the file name.
+ *
+ * @return
+ * A file containing the CFG in vcg format.
+ *
+ * Dumps the control flow graph of a procedure in standard xvcg format.
+ * Dumps the graph to a file. The file name is constructed from the
+ * name of the entity describing the procedure (irg->entity) and the
+ * ending -cfg.vcg. Eventually overwrites existing files.
+ *
+ * @see turn_off_edge_labels()
+ */
+void dump_cfg (ir_graph *irg, const char *suffix);
+
+/**
+ * Dump a node and its predecessors forming a subgraph to a vcg file.
+ *
+ * @param root The node serving as root for the subgraph.
+ * @param depth Dump nodes on paths starting at root with length depth.
+ * @param suffix A suffix for the file name.
+ *
+ * Dumps the graph to a file. The file name is constructed from the
+ * name of the entity describing the procedure the passed node is
+ * in, suffix and the ending -subg_<nr>.vcg. nr is a unique number
+ * for each graph dumped. Eventually overwrites existing files.
+ *
+ * @return
+ * A file containing the subgraph in vcg format.
+ */
+void dump_subgraph (ir_node *root, int depth, const char *suffix);
+
+/* **************************************************************************** */
+/* CALLGRAPH DUMPERS */
+/* **************************************************************************** */
+
+
+/** Dump the call graph.
+ *
+ * Dumps the callgraph to a file "Callgraph"<suffix>".vcg".
+ *
+ * @param suffix A suffix for the file name.
+ *
+ * @see dump_callgraph_loop_tree(const char *suffix)
+ */
+void dump_callgraph(const char *suffix);
+
+/* **************************************************************************** */
+/* TYPEGRAPH DUMPERS */
+/* **************************************************************************** */
+
+/**
+ * Dumps all the type information needed for Calls, Sels, ... in this graph.
+ * Does not dump the graph!
+ *
+ * @param irg The firm graph whose type information is to be dumped.
+ * @param suffix A suffix for the file name.
+ *
+ * @return
+ * A file containing the type information of the firm graph in vcg format.
+ *
+ * Dumps this graph to a file. The file name is constructed from the
+ * name of the entity describing the procedure (irg->entity) and the
+ * ending -type.vcg. Eventually overwrites existing files.
+ *
+ * @see turn_off_edge_labels()
+ */
+void dump_type_graph (ir_graph *irg, const char *suffix);
+
+/**
+ * Dumps all type information.
+ *
+ * @param suffix A suffix for the file name.
+ *
+ * @return
+ * A file containing all type information for the program in standard
+ * vcg format.
+ *
+ * Dumps all type information that is somehow reachable in standard vcg
+ * format.
+ * Dumps the graph to a file named All_types.vcg.
+ *
+ * @see turn_off_edge_labels()
+ */
+void dump_all_types (const char *suffix);
+
+/**
+ * Dumps the class hierarchy with or without entities.
+ *
+ * @param entities Flag whether to dump the entities.
+ * @param suffix A suffix for the file name.
+ *
+ * @return
+ * A file containing the class hierarchy tree for the program in standard
+ * vcg format.
+ *
+ * Does not dump the global type.
+ * Dumps a node for all classes and the sub/supertype relations. If
+ * entities is set to true also dumps the entities of classes, but without
+ * any additional information as the entities type. The overwrites relation
+ * is dumped along with the entities.
+ * Dumps to a file class_hierarchy.vcg
+ */
+void dump_class_hierarchy (int entities, const char *suffix);
+
+/* **************************************************************************** */
+/* LOOPTREE DUMPERS */
+/* **************************************************************************** */
+
+/**
+ * Dump a standalone loop tree, which contains the loop nodes and the firm nodes
+ * belonging to one loop packed together in one subgraph. Dumps to file
+ * <name of irg><suffix>-looptree.vcg
+ * Turns on edge labels by default.
+ *
+ * Implementing this dumper was stimulated by Florian Liekwegs similar dumper.
+ *
+ * @param irg Dump the loop tree for this graph.
+ * @param suffix A suffix for the file name.
+ */
+void dump_loop_tree(ir_graph *irg, const char *suffix);
+
+/** Dumps the firm nodes in the sub-loop-tree of loop to a graph.
+ *
+ * Dumps the loop nodes if dump_loop_information() is set.
+ * The name of the file is loop_<loop_nr><suffix>.vcg.
+ *
+ * @param l Dump the loop tree for this loop.
+ * @param suffix A suffix for the file name.
+ */
+void dump_loop (ir_loop *l, const char *suffix);
+
+/** Dumps the loop tree over the call graph.
+ *
+ * See for yourself what you can use this for.
+ * The filename is "Callgraph_looptree<suffix>.vcg".
+ *
+ * @param suffix A suffix for the file name.
+ */
+void dump_callgraph_loop_tree(const char *suffix);
+
+
+/* **************************************************************************** */
+/* TEXT DUMPERS */
+/* **************************************************************************** */
+
+
+/** Write the irnode and all its attributes to the file passed.
+ * */
+int dump_irnode_to_file (FILE *f, ir_node *n);
+
+/** Write the irnode and all its attributes to stdout.
+ * */
+void dump_irnode (ir_node *n);
+
+/** Write the graph and all its attributes to the file passed.
+ * Does not write the nodes.
+ * */
+void dump_graph_to_file(FILE *F, ir_graph *irg);
+
+/** Write the graph and all its attributes to stdout.
+ * Does not write the nodes.
+ * */
+void dump_graph(ir_graph *g);
+
+
+/** Dump graph information as text.
+ *
+ * Often graphs are unhandy in their vcg representation. The text
+ * dumper represents the information for the firm nodes more compact,
+ * but the relations between the nodes only implicitly.
+ *
+ * The file name is the graph name (get_entity_name()), appended by
+ * <suffix>.txt.
+ */
+void dump_graph_as_text(ir_graph *irg, const char *suffix);
+
+
+/** Verbosity for text dumpers */
+typedef enum {
+ dump_verbosity_onlynames = 0x00000001, /**< only dump names. turns off all other
+ flags up to 0x00010000. */
+ dump_verbosity_fields = 0x00000002, /**< dump types and fields (like a type declaration) */
+ dump_verbosity_methods = 0x00000004, /**< dump types and methods (like a type declaration) */
+ dump_verbosity_nostatic = 0x00000040, /**< dump types and dynamic allocated fields (like a
+ type declaration). This excludes methods and
+ static, polymorphic fields. */
+ dump_verbosity_typeattrs = 0x00000008, /**< dump all type attributes */
+ dump_verbosity_entattrs = 0x00000010, /**< dump all entity attributes */
+ dump_verbosity_entconsts = 0x00000020, /**< dump entity constants */
+
+ dump_verbosity_accessStats = 0x00000100, /**< dump entity access statistics */
+ dump_verbosity_csv = 0x00000200, /**< dump access statistics as comma separated list */
+
+ dump_verbosity_noClassTypes = 0x00001000, /**< dump no class types */
+ dump_verbosity_noStructTypes = 0x00002000, /**< dump no struct types */
+ dump_verbosity_noUnionTypes = 0x00004000, /**< dump no union types */
+ dump_verbosity_noArrayTypes = 0x00008000, /**< dump no array types */
+ dump_verbosity_noPointerTypes = 0x00010000, /**< dump no pointer types */
+ dump_verbosity_noMethodTypes = 0x00020000, /**< dump no method types */
+ dump_verbosity_noPrimitiveTypes = 0x00040000, /**< dump no primitive types */
+ dump_verbosity_noEnumerationTypes= 0x00080000, /**< dump no enumeration types */
+
+ dump_verbosity_onlyClassTypes = 0x000FE000, /**< dump only class types */
+ dump_verbosity_onlyStructTypes = 0x000FD000, /**< dump only struct types */
+ dump_verbosity_onlyUnionTypes = 0x000FB000, /**< dump only union types */
+ dump_verbosity_onlyArrayTypes = 0x000F7000, /**< dump only array types */
+ dump_verbosity_onlyPointerTypes = 0x000EF000, /**< dump only pointer types */
+ dump_verbosity_onlyMethodTypes = 0x000DF000, /**< dump only method types */
+ dump_verbosity_onlyPrimitiveTypes = 0x000BF000, /**< dump only primitive types */
+ dump_verbosity_onlyEnumerationTypes=0x0007F000, /**< dump only enumeration types */
+
+ dump_verbosity_max = 0x4FF00FBE /**< turn on all verbosity.
+ Do not turn on negative flags!
+ @@@ Because of a bug in gcc 3.2 we can not set the
+ first two bits. */
+} dump_verbosity;
+
+
+/** Write the entity and all its attributes to the passed file.
+ * */
+void dump_entity_to_file (FILE *F, ir_entity *ent, unsigned verbosity);
+
+/** Write the entity and all its attributes to the stdout.
+ *
+ * Calls dump_entity_to_file(). */
+void dump_entity (ir_entity *ent);
+
+/** Write the type and all its attributes to the file passed.
+ * */
+void dump_type_to_file (FILE *f, ir_type *tp, dump_verbosity verbosity);
+
+/** Write the type and all its attributes to stdout.
+ * */
+void dump_type (ir_type *tp);
+
+
+/** Dump type information as text.
+ *
+ * Often type graphs are unhandy in their vcg representation. The text
+ * dumper represents the information for a single type more compact, but
+ * the relations between the types only implicitly.
+ * Dumps only 'real' types, i.e., those in the type list. Does not dump
+ * the global type nor frame types or the like.
+ *
+ * The file name is the program name (get_irp_name()), or 'TextTypes'
+ * if the program name is not set, appended by <suffix>-types.txt.
+ * For verbosity see the documentation of the verbosity flags above.
+ */
+void dump_types_as_text(unsigned verbosity, const char *suffix);
+
+/** Dumps all global variables as text.
+ *
+ * @param suffix A suffix for the file name.
+ *
+ * Dumps a text representation of the entities in the global type.
+ *
+ * The file name is the program name (get_irp_name()), or 'TextTypes'
+ * if the program name is not set, appended by <suffix>-globals.txt.
+ * For verbosity see the documentation of the verbosity flags above.
+ */
+void dump_globals_as_text(unsigned verbosity, const char *suffix);
+
+/* **************************************************************************** */
+/* FLAGS */
+/* **************************************************************************** */
+
+/** Set a prefix filter for output functions.
+ *
+ * All graph dumpers check this name. If the name is != "" and
+ * not a prefix of the graph to be dumped, the dumper does not
+ * dump the graph.
+ *
+ * @param name The prefix of the name (not the ld_name) of the method
+ * entity to be dumped.
+ */
+void only_dump_method_with_name(ident *name);
+
+/** Returns the prefix filter set with only_dump_method_with_name(). */
+ident *get_dump_file_filter_ident(void);
+
+/** Returns true if dump file filter is not set, or if it is a
+ * prefix of name. */
+int is_filtered_dump_name(ident *name);
+
+/** Sets the vcg flag "display_edge_labels" to no.
+ *
+ * This is necessary as xvcg and aisee both fail to display graphs
+ * with self-edges if these edges have labels.
+ */
+void turn_off_edge_labels(void);
+
+/**
+ * If set to non-zero constants will be replicated for every use. In non
+ * blocked view edges from constant to block are skipped. Vcg then
+ * layouts the graphs more compact, this makes them better readable.
+ * The flag is automatically and temporarily set to false if other
+ * edges are dumped, as outs, loop, ...
+ * Default setting: false.
+ */
+void dump_consts_local(int flag);
+
+/**
+ * Returns 0 if dump_out_edge_flag or dump_loop_information_flag
+ * are set, else returns dump_const_local_flag.
+ */
+int get_opt_dump_const_local(void);
+
+/** Turns off dumping the values of constant entities. Makes type graphs
+ * better readable.
+ */
+void dump_constant_entity_values(int flag);
+
+/** Turns on dumping the edges from the End node to nodes to be kept
+ * alive.
+ */
+void dump_keepalive_edges(int flag);
+int get_opt_dump_keepalive_edges(void);
+
+/** Turns on dumping the out edges starting from the Start block in
+ * dump_ir_graph.
+ *
+ * To test the consistency of the out data structure.
+ */
+void dump_out_edges(int flag);
+
+/** If this flag is set the dumper dumps edges to immediate dominator in cfg.
+ */
+void dump_dominator_information(int flag);
+
+/** If this flag is set the dumper dumps loop nodes and edges from
+ * these nodes to the contained ir nodes.
+ *
+ * If the loops are interprocedural nodes can be missing.
+ */
+void dump_loop_information(int flag);
+
+/** If set and backedge info is computed, backedges are dumped dashed
+ * and as vcg 'backedge' construct.
+ *
+ * Default: set.
+ */
+void dump_backedge_information(int flag);
+
+/** Dump the information of type field specified in ana/irtypeinfo.h.
+ *
+ * If the flag is set, the type name is output in [] in the node label,
+ * else it is output as info.
+ */
+void set_opt_dump_analysed_type_info(int flag);
+
+/** Write the address of a node into the vcg info.
+ *
+ * This is off per default for automatic comparisons of
+ * vcg graphs -- these will differ in the pointer values!
+ */
+void dump_pointer_values_to_info(int flag);
+
+/** Dumps ld_names of entities instead of there names.
+ *
+ * This option is on per default.
+ */
+void dump_ld_names(int flag);
+
+/** Dumps all graph anchor nodes, even if they
+ * are dead.
+ *
+ * This option is off per default.
+ */
+void dump_all_anchors(int flag);
+
+/** A node info dumper callback. */
+typedef void (dump_node_info_cb_t)(void *data, FILE *f, const ir_node *n);
+
+/**
+ * Adds a new node info dumper callback. It is possible to add an unlimited
+ * number of callbacks. The callbacks are called at the end of the default
+ * info dumper.
+ *
+ * @param cb the callback function to be called
+ * @param data a context parameter
+ *
+ * @return A callback handle.
+ *
+ * @note This functionality is only available, if Firm hooks are enabled (default).
+ */
+void *dump_add_node_info_callback(dump_node_info_cb_t *cb, void *data);
+
+/**
+ * Remove a previously added info dumper callback.
+ *
+ * @param handle the callback handle returned from dump_add_node_info_callback()
+ */
+void dump_remv_node_info_callback(void *handle);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @breif Declares different kind of edges between nodes
+ * @date 29.08.2006
+ * @author Sebastian Hack
+ */
+#ifndef FIRM_IR_IREDGEKINDS_H
+#define FIRM_IR_IREDGEKINDS_H
+
+/** Supported Edge kinds. */
+enum _ir_edge_kind_t {
+ EDGE_KIND_NORMAL, /**< Normal data flow edges. */
+ EDGE_KIND_BLOCK, /**< Block to Block control flow edges. */
+ EDGE_KIND_DEP, /**< Dependency edges. */
+ EDGE_KIND_LAST
+};
+
+typedef enum _ir_edge_kind_t ir_edge_kind_t;
+
+/*
+ * It's ugly but we need this forward ref.
+ */
+
+void edges_notify_edge_kind(ir_node *src, int pos, ir_node *tgt, ir_node *old_tgt, ir_edge_kind_t kind, ir_graph *irg);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Public header for the automatically updating outs.
+ * @author Sebastian Hack
+ * @date 3.2.2005
+ * @version $Id$
+ */
+#ifndef FIRM_IR_IREDGES_H
+#define FIRM_IR_IREDGES_H
+
+#include "firm_types.h"
+#include "iredgekinds.h"
+
+/**
+ * Get the first edge pointing to some node.
+ * @note There is no order on out edges. First in this context only
+ * means, that you get some starting point into the list of edges.
+ * @param irn The node.
+ * @param kind The kind of the edge.
+ * @return The first out edge that points to this node.
+ */
+const ir_edge_t *get_irn_out_edge_first_kind(const ir_node *irn, ir_edge_kind_t kind);
+
+/**
+ * Get the next edge in the out list of some node.
+ * @param irn The node.
+ * @param last The last out edge you have seen.
+ * @return The next out edge in @p irn 's out list after @p last.
+ */
+const ir_edge_t *get_irn_out_edge_next(const ir_node *irn, const ir_edge_t *last);
+
+/**
+ * A convenience iteration macro over all out edges of a node.
+ * @param irn The node.
+ * @param kind The edge's kind.
+ * @param edge An ir_edge_t pointer which shall be set to the current
+ * edge.
+ */
+#define foreach_out_edge_kind(irn, edge, kind) \
+ for(edge = get_irn_out_edge_first_kind(irn, kind); edge; edge = get_irn_out_edge_next(irn, edge))
+
+/**
+ * A convenience iteration macro over all out edges of a node, which is safe
+ * against alteration of the current edge.
+ *
+ * @param irn The node.
+ * @param edge An ir_edge_t pointer which shall be set to the current edge.
+ * @param ne The next edge, enables alteration safe edge processing.
+ */
+#define foreach_out_edge_kind_safe(irn, edge, ne, kind) \
+ for((edge) = (get_irn_out_edge_first_kind(irn, kind)), (ne) = ((edge) ? (get_irn_out_edge_next(irn, edge)) : NULL); \
+ edge; (edge) = (ne), (ne) = ((edge) ? (get_irn_out_edge_next(irn, edge)) : NULL))
+
+/**
+ * Convenience macro for normal out edges.
+ */
+#define foreach_out_edge(irn, edge) foreach_out_edge_kind(irn, edge, EDGE_KIND_NORMAL)
+
+/**
+ * Convenience macro for normal out edges.
+ */
+#define foreach_out_edge_safe(irn, edge, tmp) foreach_out_edge_kind_safe(irn, edge, tmp, EDGE_KIND_NORMAL)
+
+/**
+ * A convenience iteration macro for all control flow edges.
+ */
+#define foreach_block_succ(bl, edge) foreach_out_edge_kind(bl, edge, EDGE_KIND_BLOCK)
+
+/*
+ * Get the source node of an edge.
+ * @param edge The edge.
+ * @return The source node of that edge.
+ */
+ir_node *get_edge_src_irn(const ir_edge_t *edge);
+
+/**
+ * Get the number of edges pointing to a node.
+ * @param irn The node.
+ * @return The number of edges pointing to this node.
+ */
+int get_irn_n_edges(const ir_node *irn);
+
+/**
+ * Get the position of an edge.
+ * @param edge The edge.
+ * @return The position in the in array of that edges source.
+ */
+extern int get_edge_src_pos(const ir_edge_t *edge);
+
+/**
+ * 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.
+ * @return The corresponding edge object or NULL,
+ * if no such edge exists.
+ */
+const ir_edge_t *get_irn_edge_kind(ir_graph *irg, const ir_node *irn, int pos, ir_edge_kind_t kind);
+
+/**
+ * Get the number of registered out edges for a specific kind.
+ * @param irn The node.
+ * @param kind The kind.
+ */
+extern int get_irn_n_edges_kind(const ir_node *irn, ir_edge_kind_t kind);
+
+
+/**
+ * Check, if the out edges are activated.
+ * @param irg The graph.
+ * @param kind The edge kind.
+ * @return 1, if the edges are present for the given irg, 0 if not.
+ */
+extern int edges_activated_kind(const ir_graph *irg, ir_edge_kind_t kind);
+
+/**
+ * Activate the edges for an irg.
+ * @param irg The graph to activate the edges for.
+ * @param kind The edge kind.
+ */
+extern void edges_activate_kind(ir_graph *irg, ir_edge_kind_t kind);
+
+/**
+ * Deactivate the edges for an irg.
+ * @param irg The graph.
+ * @param kind The edge kind.
+ */
+extern void edges_deactivate_kind(ir_graph *irg, ir_edge_kind_t kind);
+
+extern void edges_reroute_kind(ir_node *old, ir_node *nw, ir_edge_kind_t kind, ir_graph *irg);
+
+/**
+ * Verifies the out edges of graph @p irg.
+ * @return 1 if a problem was found, 0 otherwise
+ */
+int edges_verify(ir_graph *irg);
+
+/**
+
+ * Set edge verification flag.
+
+ */
+void edges_init_dbg(int do_dbg);
+
+/************************************************************************/
+/* Begin Old Interface */
+/************************************************************************/
+
+const ir_edge_t *get_irn_edge(ir_graph *irg, const ir_node *src, int pos);
+
+#define edges_reroute(old, nw, irg) edges_reroute_kind(old, nw, EDGE_KIND_NORMAL, irg)
+#define edges_activated(irg) (edges_activated_kind(irg, EDGE_KIND_NORMAL) && edges_activated_kind(irg, EDGE_KIND_BLOCK))
+
+#ifndef get_irn_n_edges
+#define get_irn_n_edges(irn) get_irn_n_edges_kind(irn, EDGE_KIND_NORMAL)
+#endif
+
+#ifndef get_irn_out_edge_first
+#define get_irn_out_edge_first(irn) get_irn_out_edge_first_kind(irn, EDGE_KIND_NORMAL)
+#endif
+
+#ifndef get_block_succ_first
+#define get_block_succ_first(irn) get_irn_out_edge_first_kind(irn, EDGE_KIND_BLOCK)
+#endif
+
+#ifndef get_block_succ_next
+#define get_block_succ_next(irn, last) get_irn_out_edge_next(irn, last)
+#endif
+
+/**
+* Activate all the edges for an irg.
+* @param irg The graph to activate the edges for.
+*/
+extern void edges_activate(ir_graph *irg);
+
+/**
+* Deactivate all the edges for an irg.
+* @param irg The graph.
+*/
+extern void edges_deactivate(ir_graph *irg);
+
+extern int edges_assure(ir_graph *irg);
+
+extern void edges_node_deleted(ir_node *irn, ir_graph *irg);
+
+/**
+* Notify normal and block edges.
+*/
+extern void edges_notify_edge(ir_node *src, int pos, ir_node *tgt, ir_node *old_tgt, ir_graph *irg);
+
+void edges_reset_private_data(ir_graph *irg, int offset, size_t size);
+
+/************************************************************************/
+/* End Old Interface */
+/************************************************************************/
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Extended basis block support.
+ * @author Michael Beck
+ * @date 5.2005
+ * @version $Id$
+ */
+#ifndef FIRM_ANA_IREXTBB_H
+#define FIRM_ANA_IREXTBB_H
+
+#include "firm_types.h"
+#include "execfreq.h"
+
+/** Flags for extended basic block state. */
+typedef enum {
+ ir_extblk_info_none = 0, /**< No extended basic block information is constructed. Default. */
+ ir_extblk_info_valid = 1, /**< Extended basic block information is valid. */
+ ir_extblk_info_invalid = 2 /**< Extended basic block information is constructed but invalid. */
+} irg_extblk_info_state;
+
+/* type of callback function for ir_graph walk */
+#ifndef _EXTBB_WALK_FUNC_TYPEDEF_
+#define _EXTBB_WALK_FUNC_TYPEDEF_
+/**
+ * The type of a walk function. Does not use the link field.
+ *
+ * @param blk - the extended basic block that is just visited
+ * @param env - an environment pointer passed by the walk functions
+ */
+typedef void extbb_walk_func(ir_extblk *blk, void *env);
+#endif
+
+/**
+ * Checks whether a pointer points to a extended basic block.
+ * Intern version for libFirm.
+ */
+int is_ir_extbb(const void *thing);
+
+/**
+ * Compute the extended basic blocks for a graph.
+ */
+void compute_extbb(ir_graph *irg);
+
+/**
+ * Compute the extended basic blocks for a graph based on execution frequencies.
+ */
+void compute_extbb_execfreqs(ir_graph *irg, ir_exec_freq *execfreqs);
+
+/**
+ * free all extended block info.
+ */
+void free_extbb(ir_graph *irg);
+
+/**
+ * Return the extended block of a node.
+ *
+ * @param node the node
+ */
+ir_extblk *get_nodes_extbb(ir_node *node);
+
+/**
+ * Gets the visited counter of an extended block.
+ *
+ * @param blk the extended basic block
+ */
+unsigned long get_extbb_visited(const ir_extblk *blk);
+
+/**
+ * Sets the visited counter of an extended block.
+ *
+ * @param blk the extended basic block
+ */
+void set_extbb_visited(ir_extblk *blk, unsigned long visited);
+
+/**
+ * Mark an extended block as visited in a graph.
+ * Uses the block visit flag.
+ *
+ * @param blk the extended basic block
+ */
+void mark_extbb_visited(ir_extblk *blk);
+
+/**
+ * Returns non-zero if an extended was visited.
+ * Uses the block visit flag.
+ *
+ * @param blk the extended basic block
+ */
+int extbb_visited(const ir_extblk *blk);
+
+/**
+ * Returns non-zero if an extended block was NOT visited.
+ * Uses the block visit flag.
+ *
+ * @param blk the extended basic block
+ */
+int extbb_not_visited(const ir_extblk *blk);
+
+/**
+ * Returns the link field of an extended block.
+ *
+ * @param blk the extended basic block
+ */
+void *get_extbb_link(const ir_extblk *blk);
+
+/**
+ * Sets the link field of an extended block.
+ *
+ * @param blk the extended basic block
+ * @param link the new link value
+ */
+void set_extbb_link(ir_extblk *blk, void *link);
+
+/**
+ * Return the number of basic blocks of an extended block.
+ *
+ * @param blk the extended basic block
+ */
+int get_extbb_n_blocks(const ir_extblk *blk);
+
+/**
+ * Return the i'th basic block of an extended block.
+ *
+ * @param blk the extended basic block
+ * @param pos the position
+ */
+ir_node *get_extbb_block(ir_extblk *blk, int pos);
+
+/**
+ * Return the leader basic block of an extended block.
+ *
+ * @param blk the extended basic block
+ */
+ir_node *get_extbb_leader(ir_extblk *blk);
+
+/**
+ * Return the node number of an extended block.
+ * Its the block number of the leader block
+ *
+ * @param blk the extended basic block
+ */
+long get_extbb_node_nr(ir_extblk *blk);
+
+/**
+ * Walks only over Extended Basic Block nodes in the graph.
+ *
+ * @param blk - the start extended block node
+ * @param pre - walker function, executed before the predecessor of a node are visited
+ * @param post - walker function, executed after the predecessor of a node are visited
+ * @param env - environment, passed to pre and post
+ *
+ * This function Walks only over Block nodes in the graph. Has it's own visited
+ * flag, so that it can be interleaved with the other walker.
+ * If a none block is passed, starts at the block this node belongs to.
+ * If end is passed also visits kept alive blocks. Does not use the link field.
+ */
+void irg_extblock_walk(ir_extblk *blk, extbb_walk_func *pre, extbb_walk_func *post, void *env);
+
+/**
+ * Walks only over reachable Extended Basic Block nodes in the graph.
+ * Ensures, that the extended block containing the End node is visited last
+ * and the block containing Start visited first (in post order).
+ *
+ * @param irg - the irg graph
+ * @param pre - walker function, executed before the predecessor of a block are visited
+ * @param post - walker function, executed after the predecessor of a block are visited
+ * @param env - environment, passed to pre and post
+ */
+void irg_extblock_walk_graph(ir_graph *irg, extbb_walk_func *pre, extbb_walk_func *post, void *env);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Flags to control optimizations.
+ * @author Christian Schaefer, Goetz Lindenmaier, Michael Beck
+ * @version $Id$
+ * @summary
+ * Flags to customize the behavior of libfirm.
+ *
+ * There are the following groups of flags:
+ * 1. Optimization flags.
+ * a) There is a flag, 'optimize' to turn on/off all optimizations.
+ * b) There are flags for each individual optimization. Some flags turns
+ * transformations in several algorithms on/off.
+ * 2. Normalization flags.
+ * These flags steer transformations of the ir that improve it, as removing
+ * dump Phi nodes (one predecessor, all predecessors are equal ...), Ids, Tuples ...
+ * 3. Verbosity flags.
+ * a) Flags to steer the level of the information.
+ * b) Flags to steer in which phase information should be dumped.
+ * 4. Verification flag
+ * This one controls the behavior of node and type verifications
+ */
+#ifndef FIRM_IR_IRFLAG_H
+#define FIRM_IR_IRFLAG_H
+
+#include "firm_types.h"
+
+/**
+ * A container type to load/restore all optimizations
+ */
+typedef unsigned optimization_state_t;
+
+/**
+ * This function enables/disables optimizations globally.
+ *
+ * If optimize == 0 no optimizations are performed at all.
+ * Default: optimize == 1.
+ */
+void set_optimize (int value);
+int get_optimize(void);
+
+/** This function enables/disables output of information about phases and
+ * controls the verbosity level.
+ *
+ * 0: no output at all.
+ * 1: very short output
+ * >>1: very verbose output.
+ */
+void set_firm_verbosity (int value);
+int get_firm_verbosity (void);
+
+/** Enables/Disables constant folding optimization.
+ *
+ * If opt_constant_folding == 1 perform
+ * - constant expression evaluation (2 + 5 ==> 7, 3 < 2 ==> false)
+ * - algebraic simplification (a * 0 ==> 0, a or a ==> a)
+ * - simplification of tests ( !(a < b) ==> (a >= b))
+ * Default: opt_constant_folding == 1.
+ */
+void set_opt_constant_folding (int value);
+
+/** Enables/Disables loop unrolling.
+ *
+ * If opt_loop_unrolling == 1 perform loop_unrolling.
+ * See loop_unrolling.h.
+ *
+ * Default: opt_loop_unrolling = 1;
+ */
+void set_opt_loop_unrolling (int value);
+
+/** Enables/Disables output of information about loop unrolling.
+ */
+void set_opt_loop_unrolling_verbose (int value);
+
+/** Enables/Disables removal of redundant Loads and Stores.
+ *
+ * - Remove Store that overwrites a just stored value (WAW).
+ * - Remove Store if it stores a value just loaded (WAR with the same value).
+ * - Remove Load that loads a value just saved (RAW with the same value).
+ * - remove Load that loads a value already loaded (RAR)
+ * - replace Load of constant values with constants (RC)
+ */
+void set_opt_redundant_loadstore(int value);
+
+/** Enables/Disables common subexpression elimination.
+ *
+ * If opt_cse == 1 perform common subexpression elimination.
+ * Default: opt_cse == 1.
+ */
+void set_opt_cse (int value);
+
+/** Returns constant folding optimization setting. */
+int get_opt_cse(void);
+
+/** Enables/Disables global constant subexpression elimination.
+ *
+ * If opt_global_cse == 1 and opt_cse == 1 perform intra procedure
+ * constant subexpression elimination for floating nodes. Intra
+ * procedure cse gets the graph into state "floating". It is necessary
+ * to run pre/code motion to get the graph back into state "op_pin_state_pinned".
+ * right after a call to local_optimize with global cse turned on.
+ * Default: opt_global_cse == 0.
+ */
+void set_opt_global_cse (int value);
+
+/** Enables/Disables strength reduction.
+ *
+ * If opt_strength_red == 1 perform strength reduction.
+ * See strenth_red.h.
+ *
+ * Default: opt_strength_red = 1;
+ */
+void set_opt_strength_red (int value);
+
+/** Enables/Disables output of information about strength reduction.
+ */
+void set_opt_strength_red_verbose (int value);
+
+/** Enables/Disables unreachable code elimination.
+ *
+ * If set, evaluate conditions of conditional branch and replace the
+ * branch with a Jmp/Bad Tuple.
+ *
+ * If opt_unreachable_code == 1 replace nodes (except Block,
+ * Phi and Tuple) with a Bad predecessor by the Bad node.
+ * Default: opt_unreachable_code == 1.
+ */
+void set_opt_unreachable_code(int value);
+
+/** Enables/Disables control flow optimizations.
+ *
+ * Performs Straightening, if simplifications and loop simplifications.
+ * Sets all separate control flow flags (control_flow_straightening,
+ * weak_simplification, strong_simplification and critical_edges).
+ */
+void set_opt_control_flow(int value);
+
+/** Enables/Disables Straightening. */
+void set_opt_control_flow_straightening(int value);
+
+/** Enables/Disables if simplifications in local optimizations. */
+void set_opt_control_flow_weak_simplification(int value);
+
+/** Enables/Disables strong if and loop simplification (in optimize_cf). */
+void set_opt_control_flow_strong_simplification(int value);
+
+/** Enables/Disables reassociation.
+ *
+ * If opt_reassociation == 1 reassociation is performed.
+ * Default: opt_reassociation == 1.
+ */
+void set_opt_reassociation(int value);
+
+/** Enables/Disables dead node elimination.
+ *
+ * If opt_dead_node_elimination == 1 deallocate all dead nodes
+ * by copying the firm graph.
+ * Default: opt_dead_node_elimination == 1. */
+void set_opt_dead_node_elimination (int value);
+
+/** Enables/Disables dead method elimination.
+ *
+ * If opt_dead_method_elimination == 1 methods never called are
+ * removed.
+ * Default: opt_dead_method_elimination == 1.
+ */
+void set_opt_dead_method_elimination (int value);
+void set_opt_dead_method_elimination_verbose (int value);
+
+/** Enable/Disables method inlining.
+ *
+ * If opt_inline == 1 the inlining transformation is performed.
+ */
+void set_opt_inline (int value);
+
+/** Enable/Disable optimization of dynamic method dispatch.
+ *
+ * This flag enables/disables the optimization of dynamic method dispatch.
+ * If the flag is turned on Sel nodes can be replaced by Const nodes representing
+ * the address of a function.
+ */
+void set_opt_dyn_meth_dispatch (int value);
+int get_opt_dyn_meth_dispatch (void);
+
+/** Enable/Disable type optimization of cast nodes.
+ *
+ * Controls the optimizations in tropt.h. Default: on.
+ */
+void set_opt_optimize_class_casts (int value);
+void set_opt_optimize_class_casts_verbose (int value);
+
+/** Restricts the behavior of cast optimization.
+ *
+ * If set, downcast are not optimized if they might be
+ * illegal as in (Super)(Sub) (new Super()). Default:
+ * 0 == not suppressed.
+ */
+void set_opt_suppress_downcast_optimization(int value);
+int get_opt_suppress_downcast_optimization(void);
+
+/** Enable/Disable optimization of tail-recursion calls.
+ *
+ * This flag enables/disables the optimization tail-recursion call.
+ * If the flag is turned on tail-recursion calls are optimized into loops.
+ */
+void set_opt_tail_recursion(int value);
+void set_opt_tail_recursion_verbose(int value);
+
+/** Enable/Disable floating of fragile ops.
+ *
+ * This flags enables/disables the floating of fragile operations.
+ * If this flag is on, fragile operations which are known to NOT raise
+ * an exception can be place to other basic blocks.
+ * Otherwise they remain in the block they were created.
+ */
+void set_opt_fragile_ops(int value);
+
+/**
+ * Enable/Disable if conversion.
+ *
+ * If conversion tries to turn Conds into Mux nodes to eliminate
+ * control flow.
+ */
+void set_opt_if_conversion(int value);
+
+/**
+ * Enable/Disable function call optimization.
+ *
+ * Function call optimization detects const and pure functions and
+ * allows the CSE of Call nodes. A const function is one that
+ * do only evaluate it's parameters and did not read or write memory
+ * to compute its results. Pure functions are allowed to read global memory.
+ */
+void set_opt_function_call(int value);
+
+/**
+ * Enable/Disable Confirm node removal during local optimization.
+ */
+void set_opt_remove_confirm(int value);
+
+/**
+ * Enable/Disable scalar replacement optimization.
+ */
+void set_opt_scalar_replacement(int value);
+void set_opt_scalar_replacement_verbose(int value);
+
+/**
+ * Enable/Disable Null exception in Load and Store nodes only.
+ *
+ * If enabled, only Null pointer exception can occur at Load and
+ * store nodes. If it can be proved that the address input of these
+ * nodes is non-null, the exception edge can safely be removed.
+ * If disabled, other exceptions (like unaligned access, read-only memory,
+ * etc.) can occur.
+ *
+ * This flag is enabled by default.
+ */
+void set_opt_ldst_only_null_ptr_exceptions(int value);
+
+/**
+ * Enable/Disable Selection based Null pointer check elimination.
+ *
+ * In languages, where all addresses are always Sel nodes, Null
+ * pointers can only occur as input to Sel nodes.
+ * If Null pointers are the only source for exceptions in Load and
+ * Store nodes (as typical in high level languages), we can eliminate
+ * exception edges from Load and Store when can prove that the Sel
+ * nodes representing the Load/Store address have non-null inputs.
+ * Enabling this flag enables this elimination.
+ *
+ * Enabling this flag is meaningless if ldst_non_null_exceptions is
+ * enabled.
+ *
+ * This flags should be set for Java style languages.
+ */
+void set_opt_sel_based_null_check_elim(int value);
+
+/**
+ * Enable/Disable Automatic construction of Sync nodes during
+ * Firm construction.
+ *
+ * If this flags is set, sequential non-volatile Loads are automatically
+ * rearranged so that they can be executed in parallel by creating Sync nodes.
+ *
+ * This flags should be set for Java style languages.
+ */
+void set_opt_auto_create_sync(int value);
+
+/** Enable/Disable normalizations of the firm representation.
+ *
+ * This flag guards transformations that normalize the Firm representation
+ * as removing Ids and Tuples, useless Phis, replacing SymConst(id) by
+ * Const(entity) and others.
+ * The transformations guarded by this flag are not guarded by flag
+ * "optimize".
+ * Many algorithms operating on Firm can not deal with constructs in
+ * the non-normalized representation.
+ * default: ON
+ *
+ * @note ATTENTION: not all such transformations are guarded by a flag.
+ */
+void set_opt_normalize (int value);
+
+/** Enable/Disable precise exception context.
+ *
+ * If enabled, all exceptions form a barrier for values, as in the
+ * following example:
+ *
+ * @code
+ * a = 1;
+ * b = 3 / 0;
+ * a = 2;
+ * @endcode
+ *
+ * If precise exception handling is enabled, an exception handler see a == 1,
+ * else it might see a == 2.
+ * Enable this for languages with strict exception order like Java.
+ */
+void set_opt_precise_exc_context(int value);
+
+/** Enable/Disable Alias analysis.
+ *
+ * If enabled, memory disambiguation by alias analysis is used.
+ */
+void set_opt_alias_analysis(int value);
+
+/** Enable/Disable closed world assumption.
+ *
+ * If enabled, optimizations expect to know the "whole world", i.e. no
+ * external types or callers exist.
+ * This enables some powerful optimizations.
+ */
+void set_opt_closed_world(int value);
+
+/**
+ * Save the current optimization state.
+ */
+void save_optimization_state(optimization_state_t *state);
+
+/**
+ * Restore the current optimization state.
+ */
+void restore_optimization_state(const optimization_state_t *state);
+
+/**
+ * Switches ALL optimizations off.
+ */
+void all_optimizations_off(void);
+
+/**
+ * Possible verification modes.
+ */
+typedef enum _firm_verification_t {
+ FIRM_VERIFICATION_OFF = 0, /**< do not verify nodes at all */
+ FIRM_VERIFICATION_ON = 1, /**< do node verification and assert on error in debug version */
+ FIRM_VERIFICATION_REPORT = 2, /**< do node verification, but report to stderr only */
+ FIRM_VERIFICATION_ERROR_ONLY = 3 /**< do node verification, but NEVER do assert nor report */
+} firm_verification_t;
+
+/** 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.
+ */
+void do_node_verification(firm_verification_t mode);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Support for ir graph modification.
+ * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier
+ * @version $Id$
+ */
+#ifndef FIRM_IR_IRGMOD_H
+#define FIRM_IR_IRGMOD_H
+
+#include "firm_types.h"
+
+/** Exchanges two nodes by conserving edges leaving old (i.e.,
+ pointers pointing to old). Turns the old node into an Id. */
+void exchange(ir_node *old, ir_node *nw);
+
+/** Turns a node into a "useless" Tuple.
+ *
+ * Turns a node into a "useless" Tuple. The Tuple node just forms a tuple
+ * from several inputs. The predecessors of the tuple have to be
+ * set by hand. The block predecessor automatically remains the same.
+ * This is useful if a node returning a tuple is removed, but the Projs
+ * extracting values from the tuple are not available.
+ *
+ * @param node The node to be turned into a tuple.
+ * @param arity The number of values formed into a Tuple.
+ */
+void turn_into_tuple(ir_node *node, int arity);
+
+/** Walks over the passed ir graph and collects all Phi nodes as a
+ * list built with the link field in their corresponding block.
+ * Further it collects all Proj nodes in a list of the node producing
+ * the tuple. In case of nested tuples the Projs are collected in the
+ * node producing the outermost Tuple.
+ * All other link fields are cleared afterwards.
+ */
+void collect_phiprojs(ir_graph *irg);
+
+/** Parts a block into two. This is useful to insert other blocks within a
+ * given block.
+ *
+ * Adds a new block (new_block) in the control flow before the block
+ * (old_block) of node. Moves node and its predecessors from old_block to
+ * new_block. Moves all Projs that depend on moved nodes and are in old_block
+ * to new_block. Moves all Phi nodes from old_block to new_block. To achieve
+ * this the routine assumes that all Phi nodes are in a list (using the link
+ * field) in the link field of old_block. Further it assumes that all Proj nodes
+ * are accessible by the link field of the nodes producing the Tuple. This
+ * can be established by collect_phiprojs(). part_block conserves this property.
+ * Adds a Jmp node to new_block that jumps to old_block.
+ * Assumes that node is contained in current_ir_graph. Sets current_block in
+ * this ir_graph to new_block.
+ *
+ * @param node The node were to break the block
+ */
+void part_block(ir_node *node);
+
+#endif /* FIRM_IR_IRGMOD_H */
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Optimizations for a whole ir graph, i.e., a procedure.
+ * @author Christian Schaefer, Goetz Lindenmaier, Sebastian Felis
+ * @version $Id$
+ */
+#ifndef FIRM_IR_IRGOPT_H
+#define FIRM_IR_IRGOPT_H
+
+#include "firm_types.h"
+
+/** Applies local optimizations (see iropt.h) to all nodes reachable from node n.
+ *
+ * @param n The node to be optimized.
+ */
+void local_optimize_node(ir_node *n);
+
+/** Applies local optimizations (see iropt.h) to all nodes in the graph.
+ *
+ * @param irg The graph to be optimized.
+ *
+ * After applying local_optimize_graph() to a IR-graph, Bad nodes
+ * only occure as predecessor of Block and Phi nodes.
+ */
+void local_optimize_graph (ir_graph *irg);
+
+/** Applies local optimizations (see iropt.h) to all nodes in the graph.
+ *
+ * @param irg The graph to be optimized.
+ *
+ * After applying local_optimize_graph() to a IR-graph, Bad nodes
+ * only occure as predecessor of Block and Phi nodes.
+ *
+ * This version used a fixpoint iteration.
+ */
+void optimize_graph_df(ir_graph *irg);
+
+/** Performs dead node elimination by copying the ir graph to a new obstack.
+ *
+ * The major intention of this pass is to free memory occupied by
+ * dead nodes and outdated analyzes information. Further this
+ * function removes Bad predecessors from Blocks and the corresponding
+ * inputs to Phi nodes. This opens optimization potential for other
+ * optimizations. Further this phase reduces dead Block<->Jmp
+ * self-cycles to Bad nodes.
+ *
+ * Dead_node_elimination is only performed if options `optimize' and
+ * `opt_dead_node_elimination' are set. The graph may
+ * not be in state phase_building. The outs datasturcture is freed,
+ * the outs state set to outs_none. Backedge information is conserved.
+ * Removes old attributes of nodes. Sets link field to NULL.
+ * Callee information must be freed (irg_callee_info_none).
+ *
+ * @param irg The graph to be optimized.
+ */
+void dead_node_elimination(ir_graph *irg);
+
+typedef struct _survive_dce_t survive_dce_t;
+
+/**
+ * Make a new Survive DCE environment.
+ */
+survive_dce_t *new_survive_dce(void);
+
+/**
+ * Free a Survive DCE environment.
+ */
+void free_survive_dce(survive_dce_t *sd);
+
+/**
+ * Register a node pointer to be patched upon DCE.
+ * When DCE occurs, the node pointer specified by @p place will be
+ * patched to the new address of the node it is pointing to.
+ *
+ * @param sd The Survive DCE environment.
+ * @param place The address of the node pointer.
+ */
+void survive_dce_register_irn(survive_dce_t *sd, ir_node **place);
+
+/** Cleans the control flow from Bad predecessors.
+ *
+ * Removes Bad predecessors from Blocks and the corresponding
+ * inputs to Phi nodes as in dead_node_elimination but without
+ * copying the graph.
+ *
+ * Conserves loop information.
+ *
+ * @param irg The graph to be optimized.
+ */
+void remove_bad_predecessors(ir_graph *irg);
+
+/** Inlines a method at the given call site.
+ *
+ * Removes the call node and splits the basic block the call node
+ * belongs to. Inserts a copy of the called graph between these nodes.
+ * Assumes that call is a Call node in current_ir_graph and that
+ * the type in the Call nodes type attribute is the same as the
+ * type of the called graph.
+ * Further it assumes that all Phi nodes in a block of current_ir_graph
+ * are assembled in a "link" list in the link field of the corresponding
+ * block nodes. Further assumes that all Proj nodes are in a "link" list
+ * in the nodes producing the tuple. (This is only an optical feature
+ * for the graph.) Conserves this feature for the old
+ * nodes of the graph. This precondition can be established by a call to
+ * collect_phisprojs(), see irgmod.h.
+ * As dead_node_elimination this function reduces dead Block<->Jmp
+ * self-cycles to Bad nodes.
+ *
+ * Called_graph must be unequal to current_ir_graph. Will not inline
+ * if they are equal.
+ * Sets visited masterflag in current_ir_graph to the max of the flag in
+ * current and called graph.
+ * Assumes that both, the called and the calling graph are in state
+ * "op_pin_state_pinned".
+ * It is recommended to call local_optimize_graph() after inlining as this
+ * function leaves a set of obscure Tuple nodes, e.g. a Proj-Tuple-Jmp
+ * combination as control flow operation.
+ *
+ * @param call the call node that should be inlined
+ * @param called_graph the IR-graph that is called at call
+ *
+ * @return zero if method could not be inlined (recursion for instance),
+ * non-zero if all went ok
+ */
+int inline_method(ir_node *call, ir_graph *called_graph);
+
+/** Inlines all small methods at call sites where the called address comes
+ * from a SymConst node that references the entity representing the called
+ * method.
+ *
+ * The size argument is a rough measure for the code size of the method:
+ * Methods where the obstack containing the firm graph is smaller than
+ * size are inlined. Further only a limited number of calls are inlined.
+ * If the method contains more than 1024 inlineable calls none will be
+ * inlined.
+ * Inlining is only performed if flags `optimize' and `inlineing' are set.
+ * The graph may not be in state phase_building.
+ * It is recommended to call local_optimize_graph() after inlining as this
+ * function leaves a set of obscure Tuple nodes, e.g. a Proj-Tuple-Jmp
+ * combination as control flow operation.
+ */
+void inline_small_irgs(ir_graph *irg, int size);
+
+
+/** Inlineing with a different heuristic than inline_small_irgs().
+ *
+ * Inlines leave functions. If inlinening creates new leave
+ * function inlines these, too. (If g calls f, and f calls leave h,
+ * h is first inlined in f and then f in g.)
+ *
+ * Then inlines all small functions (this is not recursive).
+ *
+ * For a heuristic this inlineing uses firm node counts. It does
+ * not count auxiliary nodes as Proj, Tuple, End, Start, Id, Sync.
+ * If the ignore_runtime flag is set, calls to functions marked with the
+ * mtp_property_runtime property are ignored.
+ *
+ * @param maxsize Do not inline any calls if a method has more than
+ * maxsize firm nodes. It may reach this limit by
+ * inlineing.
+ * @param leavesize Inline leave functions if they have less than leavesize
+ * nodes.
+ * @param size Inline all function smaller than size.
+ * @param ignore_runtime count a function only calling runtime functions as
+ * leave
+ */
+void inline_leave_functions(int maxsize, int leavesize, int size, int ignore_runtime);
+
+/** Code Placement.
+ *
+ * Pins all floating nodes to a block where they
+ * will be executed only if needed. Depends on the flag opt_global_cse.
+ * Graph may not be in phase_building. Does not schedule control dead
+ * code. Uses dominator information which it computes if the irg is not
+ * in state dom_consistent. Destroys the out information as it moves nodes
+ * to other blocks. Optimizes Tuples in Control edges.
+ * @todo This is not tested!
+ *
+ * Call remove_critical_cf_edges() before place_code(). This normalizes
+ * the control flow graph so that for all operations a basic block exists
+ * where they can be optimally placed.
+ *
+ * @todo A more powerful code placement would move operations past Phi nodes
+ * out of loops.
+ */
+void place_code(ir_graph *irg);
+
+/** Places an empty basic block on critical control flow edges thereby
+ * removing them.
+ *
+ * A critical control flow edge is an edge from a block with several
+ * control exits to a block with several control entries (See Muchnic
+ * p. 407).
+ *
+ * @param irg IR Graph
+ */
+void remove_critical_cf_edges(ir_graph *irg);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Entry point to the representation of procedure code.
+ * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier
+ * @version $Id$
+ */
+#ifndef FIRM_IR_IRGRAPH_H
+#define FIRM_IR_IRGRAPH_H
+
+#include <stddef.h>
+
+#include "firm_types.h"
+#include "irop.h"
+#include "iropt.h"
+#include "irextbb.h"
+#include "typerep.h"
+
+/**
+ * @page ir_graph The struct ir_graph
+ *
+ * This struct contains all information about a procedure.
+ * It's allocated directly to memory.
+ *
+ * The fields of ir_graph:
+ *
+ * - ent The entity describing this procedure.
+ *
+ * The beginning and end of a graph:
+ *
+ * - start_block This ir_node is the block that contains the unique
+ * start node of the procedure. With it it contains
+ * the Proj's on starts results.
+ * Further all Const nodes are placed in the start block.
+ * - start This ir_node is the unique start node of the procedure.
+ *
+ * - end_block This ir_node is the block that contains the unique
+ * end node of the procedure. This block contains no
+ * further nodes.
+ * - end This ir_node is the unique end node of the procedure.
+ *
+ * The following nodes are Projs from the Start node, held in ir_graph for
+ * simple access:
+ *
+ * - frame The ir_node producing the pointer to the stack frame of
+ * the procedure as output. This is the Proj node on the
+ * third output of the start node. This output of the start
+ * node is tagged as pns_frame_base. In FIRM most local
+ * variables are modeled as data flow edges. Static
+ * allocated arrays can not be represented as data flow
+ * edges. Therefore FIRM has to represent them in the stack
+ * frame.
+ *
+ * - globals This models a pointer to a space in the memory where
+ * _all_ global things are held. Select from this pointer
+ * with a Sel node the pointer to a global variable /
+ * procedure / compiler known function... .
+ *
+ * - tls This models a pointer to a space in the memory where
+ * thread local things are held. Select from this pointer
+ * with a Sel node the pointer to a thread local variable.
+ *
+ * - args The ir_node that produces the arguments of the method as
+ * it's result. This is a Proj node on the fourth output of
+ * the start node. This output is tagged as pn_Start_T_args.
+ *
+ * - proj_args The proj nodes of the args node.
+ *
+ * - bad The Bad node is an auxiliary node. It is needed only once,
+ * so there is this globally reachable node.
+ *
+ * - no_mem The NoMem node is an auxiliary node. It is needed only once,
+ * so there is this globally reachable node.
+ *
+ * Data structures that are private to a graph:
+ *
+ * - obst An obstack that contains all nodes.
+ *
+ * - current_block A pointer to the current block. Any node created with
+ * one of the node constructors (new_<opcode>) are assigned
+ * to this block. It can be set with set_cur_block(block).
+ * Only needed for ir construction.
+ *
+ * - params/n_loc An int giving the number of local variables in this
+ * procedure. This is needed for ir construction. Name will
+ * be changed.
+ *
+ * - value_table This hash table (pset) is used for global value numbering
+ * for optimizing use in iropt.c.
+ *
+ * - Phi_in_stack; a stack needed for automatic Phi construction, needed only
+ * during ir construction.
+ *
+ * - visited A int used as flag to traverse the ir_graph.
+ *
+ * - block_visited A int used as a flag to traverse block nodes in the graph.
+ */
+
+/** Global variable holding the current ir graph.
+ *
+ * This global variable is used by the ir construction
+ * interface in ircons and by the optimizations.
+ * Further it is set by all walker functions.
+ */
+extern ir_graph *current_ir_graph;
+
+ir_graph *get_current_ir_graph(void);
+void set_current_ir_graph(ir_graph *graph);
+
+/** This flag indicate the current view. The behavior of some methods
+ * (get_irn_*, set_irn_*) is influenced by this flag. */
+int get_interprocedural_view(void);
+void set_interprocedural_view(int state);
+
+/**
+ * Create a new ir graph to build ir for a procedure.
+ *
+ * @param ent A pointer to an entity representing the procedure,
+ * i.e., the type of the entity must be of a method type.
+ *
+ * @param n_loc The number of local variables in this procedure including
+ * the procedure parameters.
+ *
+ * This constructor generates the basic infrastructure needed to
+ * represent a procedure in FIRM.
+ *
+ * It allocates an ir_graph and sets the field irg of the entity ent
+ * as well as current_ir_graph to point to this graph.
+ * Further it allocates the following nodes needed for every
+ * procedure:
+ *
+ * - The start block containing a start node and Proj nodes for it's
+ * seven results (X, M, P, P, P, T, P).
+ * - The end block containing an end node. This block is not matured
+ * after executing new_ir_graph() as predecessors need to be added to it.
+ * (Maturing a block means fixing it's number of predecessors.)
+ * - The current block, which is empty and also not matured.
+ *
+ * Further it enters the global store into the data structure of the start
+ * block that contains all valid values in this block (set_store()). This
+ * data structure is used to build the Phi nodes and removed after
+ * completion of the graph. There is no path from end to start in the
+ * graph after calling ir_graph.
+ *
+ * The op_pin_state of the graph is set to "op_pin_state_pinned"
+ * if no global cse was performed on the graph.
+ * It is set to "op_pin_state_floats" if global cse was performed
+ * (and during construction: did actually change something).
+ * Code placement is necessary.
+ *
+ * @see new_pseudo_ir_graph()
+ */
+ir_graph *new_ir_graph (ir_entity *ent, int n_loc);
+
+/** Frees the passed irgraph.
+ * Deallocates all nodes in this graph and the ir_graph structure.
+ * Sets the field irgraph in the corresponding entity to NULL.
+ * Does not remove the irgraph from the list in irprog (requires
+ * inefficient search, call remove_irp_irg by hand).
+ * Does not free types, entities or modes that are used only by this
+ * graph, nor the entity standing for this graph.
+ */
+void free_ir_graph (ir_graph *irg);
+
+/* --- access routines for all ir_graph attributes --- */
+
+/**
+ * Checks whether a pointer points to a ir graph.
+ *
+ * @param thing an arbitrary pointer
+ *
+ * @return
+ * true if the thing is a ir graph, else false
+ */
+int is_ir_graph(const void *thing);
+
+/* #define get_irg_entity get_irg_ent */
+/* #define set_irg_entity set_irg_ent */
+ir_entity *get_irg_entity (const ir_graph *irg);
+void set_irg_entity (ir_graph *irg, ir_entity *ent);
+
+ir_type *get_irg_frame_type (ir_graph *irg);
+void set_irg_frame_type (ir_graph *irg, ir_type *ftp);
+
+ir_node *get_irg_start_block (const ir_graph *irg);
+void set_irg_start_block (ir_graph *irg, ir_node *node);
+
+ir_node *get_irg_start (const ir_graph *irg);
+void set_irg_start (ir_graph *irg, ir_node *node);
+
+ir_node *get_irg_end_block (const ir_graph *irg);
+void set_irg_end_block (ir_graph *irg, ir_node *node);
+
+ir_node *get_irg_end (const ir_graph *irg);
+void set_irg_end (ir_graph *irg, ir_node *node);
+
+/* The fields end_reg and end_except contain the end nodes of the
+ interprocedural view. If the view is not constructed they contain
+ the normal end node. */
+ir_node *get_irg_end_reg (const ir_graph *irg);
+void set_irg_end_reg (ir_graph *irg, ir_node *node);
+
+ir_node *get_irg_end_except (const ir_graph *irg);
+void set_irg_end_except (ir_graph *irg, ir_node *node);
+
+/** Returns the node that represents the frame pointer. */
+ir_node *get_irg_frame (const ir_graph *irg);
+/** Sets the node that represents the frame pointer. */
+void set_irg_frame (ir_graph *irg, ir_node *node);
+
+/** Returns the node that represents the global pointer. */
+ir_node *get_irg_globals (const ir_graph *irg);
+/** Sets the node that represents the global pointer. */
+void set_irg_globals (ir_graph *irg, ir_node *node);
+
+/** Returns the node that represents the tls pointer. */
+ir_node *get_irg_tls (const ir_graph *irg);
+/** Sets the node that represents the tls pointer. */
+void set_irg_tls (ir_graph *irg, ir_node *node);
+
+/** Returns the node that represents the initial memory. */
+ir_node *get_irg_initial_mem (const ir_graph *irg);
+/** Sets the node that represents the initial memory. */
+void set_irg_initial_mem (ir_graph *irg, ir_node *node);
+
+/** Returns the node that represents the argument pointer. */
+ir_node *get_irg_args (const ir_graph *irg);
+/** Sets the node that represents the argument pointer. */
+void set_irg_args (ir_graph *irg, ir_node *node);
+
+/** Returns the node that represents the value parameter base pointer. */
+ir_node *get_irg_value_param_base (const ir_graph *irg);
+/** Sets the node that represents the value parameter base pointer. */
+void set_irg_value_param_base (ir_graph *irg, ir_node *node);
+
+/** Returns an array of the nodes of the argument pointer. */
+ir_node **get_irg_proj_args (const ir_graph *irg);
+/** Sets the array of the nodes of the argument pointer. */
+void set_irg_proj_args (ir_graph *irg, ir_node **nodes);
+
+/** Returns the current block of a graph. */
+ir_node *get_irg_current_block (const ir_graph *irg);
+/** Sets the current block of a graph. */
+void set_irg_current_block (ir_graph *irg, ir_node *node);
+
+/** Returns the Bad node. Use new_Bad() instead!! */
+ir_node *get_irg_bad (const ir_graph *irg);
+void set_irg_bad (ir_graph *irg, ir_node *node);
+
+/** Returns the NoMem node. Use new_NoMem() instead!! */
+ir_node *get_irg_no_mem (const ir_graph *irg);
+void set_irg_no_mem (ir_graph *irg, ir_node *node);
+
+/** Returns the number of value numbers of a graph. */
+int get_irg_n_locs (ir_graph *irg);
+
+/** Returns the graph number. */
+long get_irg_graph_nr(ir_graph *irg);
+
+/********************************************************************************/
+/* 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.
+ *
+ * The graph is in phase_building during construction of the irgraph.
+ * The construction is finished by a call to finalize_cons().
+ *
+ * Finalize_cons() sets the state to phase_high. All standard Firm nodes are
+ * allowed.
+ *
+ * To get the irgraph into phase_low all Sel nodes must be removed and
+ * replaced by explicit address computations. SymConst size and
+ * type tag nodes must be removed (@@@ really?). Initialization of
+ * memory allocated by Alloc must be explicit. @@@ More conditions?
+ *
+ * phase_backend is set if architecture specific machine nodes are inserted
+ * (and probably most standard Firm are removed).
+ */
+typedef enum {
+ phase_building,
+ phase_high,
+ phase_low,
+ phase_backend
+} irg_phase_state;
+
+/** returns the phase_state of an IR graph. */
+irg_phase_state get_irg_phase_state (const ir_graph *irg);
+
+/** sets the phase state of an IR graph. */
+void set_irg_phase_state(ir_graph *irg, irg_phase_state state);
+
+#define set_irg_phase_low(irg) set_irg_phase_state(irg, phase_low)
+
+/** state: op_pin_state_pinned
+ The graph is "op_pin_state_pinned" if all nodes are associated with a basic block.
+ It is in state "op_pin_state_floats" if nodes are in arbitrary blocks. In state
+ "op_pin_state_floats" the block predecessor is set in all nodes, but this can be an
+ invalid block, i.e., the block is not a dominator of all the uses of
+ the node.
+ The enum op_pin_state is defined in irop.h. */
+op_pin_state get_irg_pinned (const ir_graph *irg);
+
+/** state: outs_state
+ * Outs are the back edges or def-use edges of ir nodes.
+ * Values: outs_none, outs_consistent, outs_inconsistent */
+typedef enum {
+ outs_none, /**< Outs are not computed, no memory is allocated. */
+ outs_consistent, /**< Outs are computed and correct. */
+ outs_inconsistent /**< Outs have been computed, memory is still allocated,
+ but the graph has been changed since. */
+} irg_outs_state;
+irg_outs_state get_irg_outs_state(const ir_graph *irg);
+void set_irg_outs_inconsistent(ir_graph *irg);
+
+/** state: extended basic block state. */
+typedef enum {
+ extblk_none = 0, /**< No extended basic block information is constructed. Default. */
+ extblk_valid = 1, /**< Extended basic block information is valid. */
+ extblk_invalid = 2 /**< Extended basic block information is constructed but invalid. */
+} irg_extblk_state;
+irg_extblk_state get_irg_extblk_state(const ir_graph *irg);
+void set_irg_extblk_inconsistent(ir_graph *irg);
+
+/** state: dom_state
+ * Signals the state of the dominator / post dominator information.
+ */
+typedef enum {
+ dom_none, /**< dominator are not computed, no memory is allocated */
+ dom_consistent, /**< dominator information is computed and correct */
+ dom_inconsistent /**< dominator information is computed but the graph has been changed since */
+} irg_dom_state;
+
+/** returns the dominator state of an IR graph. */
+irg_dom_state get_irg_dom_state(const ir_graph *irg);
+
+/** returns the post dominator state of an IR graph. */
+irg_dom_state get_irg_postdom_state(const ir_graph *irg);
+
+/** sets the dominator and post dominator state of an IR graph to inconsistent. */
+void set_irg_doms_inconsistent(ir_graph *irg);
+
+/** state: loopinfo_state
+ * Loop information describes the loops within the control and
+ * data flow of the procedure.
+ */
+typedef enum {
+ loopinfo_none = 0, /**< No loop information is constructed. Default. */
+ loopinfo_constructed = 1, /**< Some kind of loop information is constructed. */
+ loopinfo_valid = 2, /**< Loop information is valid. */
+ loopinfo_cf = 4, /**< Loop information constructed for control flow only. */
+ loopinfo_inter = 8, /**< Loop information for interprocedural view. */
+
+ loopinfo_for_firmjni = 16, /**< A hack for firmjni: all enums must differ as they
+ are used in a switch. */
+
+ /** IntRAprocedural loop information constructed and valid. */
+ loopinfo_consistent = loopinfo_constructed | loopinfo_for_firmjni | loopinfo_valid,
+ /** IntRAprocedural loop information constructed and invalid. */
+ loopinfo_inconsistent = loopinfo_constructed | loopinfo_for_firmjni,
+
+ /** IntERprocedural loop information constructed and valid. */
+ loopinfo_ip_consistent = loopinfo_constructed | loopinfo_inter | loopinfo_valid,
+ /** IntERprocedural loop information constructed and invalid. */
+ loopinfo_ip_inconsistent = loopinfo_constructed | loopinfo_inter,
+
+ /** IntRAprocedural control loop information constructed and valid. */
+ loopinfo_cf_consistent = loopinfo_constructed | loopinfo_cf | loopinfo_valid,
+ /** IntRAprocedural control loop information constructed and invalid. */
+ loopinfo_cf_inconsistent = loopinfo_constructed | loopinfo_cf,
+
+ /** IntERprocedural control loop information constructed and valid. */
+ loopinfo_cf_ip_consistent = loopinfo_constructed | loopinfo_cf | loopinfo_inter | loopinfo_valid,
+ /** IntERprocedural control loop information constructed and invalid. */
+ loopinfo_cf_ip_inconsistent = loopinfo_constructed | loopinfo_cf | loopinfo_inter
+} irg_loopinfo_state;
+
+/** Return the current loop information state. */
+irg_loopinfo_state get_irg_loopinfo_state(const ir_graph *irg);
+
+/** Sets the current loop information state. */
+void set_irg_loopinfo_state(ir_graph *irg, irg_loopinfo_state s);
+
+/** Sets the loop information state to the appropriate inconsistent state.
+ * If state is 'none' does not change. */
+void set_irg_loopinfo_inconsistent(ir_graph *irg);
+/** Sets the loop information state to the appropriate inconsistent state.
+ * If state is 'none' does not change.
+ * Does this for all irgs. */
+void set_irp_loopinfo_inconsistent(void);
+
+/** state: callee_information_state
+ * Call nodes contain a list of possible callees. This list must be
+ * computed by an analysis.
+ *
+ * It's strange that this state is administered on irg basis, as the
+ * information must be computed for the whole program, or not?
+ */
+typedef enum {
+ irg_callee_info_none,
+ irg_callee_info_consistent,
+ irg_callee_info_inconsistent
+} irg_callee_info_state;
+
+/** returns the callee_info_state of an IR graph. */
+irg_callee_info_state get_irg_callee_info_state(const ir_graph *irg);
+
+/** sets the callee_info_state of an IR graph. */
+void set_irg_callee_info_state(ir_graph *irg, irg_callee_info_state s);
+
+/** property:
+ * Tells how to handle an ir graph in inlineing.
+ */
+typedef enum {
+ irg_inline_any, /**< No restriction on inlineing. Default. */
+ irg_inline_forbidden, /**< The graph may not be inlined. */
+ irg_inline_recomended, /**< The graph should be inlined. */
+ irg_inline_forced, /**< The graph must be inlined. */
+ irg_inline_forced_no_body /**< The graph must be inlined. No body is allowed
+ to be emitted. */
+} irg_inline_property;
+
+/** Returns the inline property of a graph. */
+irg_inline_property get_irg_inline_property(const ir_graph *irg);
+/** Sets the inline property of a graph. */
+void set_irg_inline_property(ir_graph *irg, irg_inline_property s);
+
+/**
+ * Returns the mask of the additional graph properties.
+ * The properties are automatically inherited from the method type
+ * if they were not set using set_irg_additional_properties() or
+ * set_irg_additional_property().
+ */
+unsigned get_irg_additional_properties(const ir_graph *irg);
+
+/** Sets the mask of the additional graph properties. */
+void set_irg_additional_properties(ir_graph *irg, unsigned property_mask);
+
+/** Sets one additional graph property. */
+void set_irg_additional_property(ir_graph *irg, mtp_additional_property flag);
+
+/** A void * field to link arbitrary information to the node. */
+void set_irg_link (ir_graph *irg, void *thing);
+void *get_irg_link (const ir_graph *irg);
+
+/** Increments visited flag by one.
+ * @see also: get_irn_visited() get_irg_block_visited(). */
+void inc_irg_visited (ir_graph *irg);
+unsigned long get_irg_visited (const ir_graph *irg);
+void set_irg_visited (ir_graph *irg, unsigned long i);
+/** An interprocedural flag valid for all irgs.
+ * @see also: get_irn_visited() get_irg_block_visited(). */
+unsigned long get_max_irg_visited (void);
+void set_max_irg_visited (int val);
+unsigned long inc_max_irg_visited (void);
+
+/** Increments block_visited by one.
+ * @see also: get_irn_visited() get_irg_block_visited(). */
+void inc_irg_block_visited (ir_graph *irg);
+unsigned long get_irg_block_visited (const ir_graph *irg);
+void set_irg_block_visited (ir_graph *irg, unsigned long i);
+
+/**
+ * Debug helpers: You can indicate wether you are currently using visited or
+ * block_visited flags. If NDEBUG is not defined, then the compiler will abort
+ * if 2 parties try to use the flags.
+ */
+#ifndef NDEBUG
+void set_using_block_visited(ir_graph *irg);
+void clear_using_block_visited(ir_graph *irg);
+int using_block_visited(const ir_graph *irg);
+void set_using_visited(ir_graph *irg);
+void clear_using_visited(ir_graph *irg);
+int using_visited(const ir_graph *irg);
+void set_using_irn_link(ir_graph *irg);
+void clear_using_irn_link(ir_graph *irg);
+int using_irn_link(const ir_graph *irg);
+#else
+static INLINE void set_using_block_visited(ir_graph *irg) { (void) irg; }
+static INLINE void clear_using_block_visited(ir_graph *irg) { (void) irg; }
+static INLINE int using_block_visited(const ir_graph *irg) { (void) irg; return 0; }
+static INLINE void set_using_visited(ir_graph *irg) { (void) irg; }
+static INLINE void clear_using_visited(ir_graph *irg) { (void) irg; }
+static INLINE int using_visited(const ir_graph *irg) { (void) irg; return 0; }
+static INLINE void set_using_irn_link(ir_graph *irg) { (void) irg; }
+static INLINE void clear_using_irn_link(ir_graph *irg) { (void) irg; }
+static INLINE int using_irn_link(const ir_graph *irg) { (void) irg; return 0; }
+#endif
+
+/** move Proj nodes into the same block as its predecessors */
+void normalize_proj_nodes(ir_graph *irg);
+
+/** set a description for local value n */
+void set_irg_loc_description(ir_graph *irg, int n, void *description);
+
+/** get the description for local value n */
+void *get_irg_loc_description(ir_graph *irg, int n);
+
+/** Returns a estimated node count of the irg. This count is updated
+ * after every irg_walk_graph().
+ */
+unsigned get_irg_estimated_node_cnt(const ir_graph *irg);
+
+/** Returns the last irn index for this graph. */
+unsigned get_irg_last_idx(const ir_graph *irg);
+
+/** Returns the floating point model of this graph. */
+unsigned get_irg_fp_model(const ir_graph *irg);
+
+/** Sets a floating point model for this graph. */
+void set_irg_fp_model(ir_graph *irg, unsigned model);
+
+/**
+ * Access custom graph data.
+ * The data must have been registered with
+ * register_additional_graph_data() before.
+ * @param graph The graph to get the data from.
+ * @param type The type of the data you registered.
+ * @param off The value returned by register_additional_graph_data().
+ * @return A pointer of type @p type.
+ */
+#define get_irg_data(graph,type,off) \
+ (assert(off > 0 && "Invalid graph data offset"), (type *) ((char *) (graph) - (off)))
+
+/**
+ * Get the pointer to the node some custom data belongs to.
+ * @param data The pointer to the custom data.
+ * @param off The number as returned by register_additional_graph_data().
+ * @return A pointer to the ir node the custom data belongs to.
+ */
+#define get_irg_data_base(data,off) \
+ (assert(off > 0 && "Invalid graph data offset"), (ir_graph *) ((char *) (data) + (off)))
+
+/**
+ * Request additional data to be allocated with an ir graph.
+ * @param size The size of the additional data required.
+ * @return A positive number, if the operation was successful, which
+ * must be passed to the access macro get_irg_data(), 0 if the
+ * registration failed.
+ */
+size_t register_additional_graph_data(size_t size);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Traverse an ir graph
+ * @author Boris Boesler, Goetz Lindenmaier
+ * @version $Id$
+ * @summary
+ * Traverse an ir graph:
+ * - execute the pre function before recursion
+ * - execute the post function after recursion
+ *
+ * Uses current_ir_graph (from irgraph.h)!!! Set it to the proper
+ * graph before starting the walker.
+ */
+#ifndef FIRM_IR_IRGWALK_H
+#define FIRM_IR_IRGWALK_H
+
+#include "firm_types.h"
+
+/**
+ * Walks over the ir graph.
+ *
+ * Walks over the ir graph, starting at the node given as first argument.
+ * Executes pre before visiting the predecessor of a node, post after.
+ * irg_walk uses the visited flag in irg and the nodes to determine visited
+ * nodes. It executes inc_irg_visited(current_ir_graph) to generate a new
+ * flag. Therefore current_ir_graph must be set before calling the walker.
+ * It marks the node as visited before executing pre.
+ * The void* env can be used to pass status information between the
+ * pre and post functions. Does not use the link fields.
+ *
+ * @param node - the start node
+ * @param pre - walker function, executed before the predecessor of a node are visited
+ * @param post - walker function, executed after the predecessor of a node are visited
+ * @param env - environment, passed to pre and post
+ *
+ */
+void irg_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env);
+
+/**
+ * Walks over all reachable nodes in the ir graph.
+ *
+ * @param irg - the irg graph
+ * @param pre - walker function, executed before the predecessor of a node are visited
+ * @param post - walker function, executed after the predecessor of a node are visited
+ * @param env - environment, passed to pre and post
+ *
+ * Like irg_walk(), but walks over all reachable nodes in the ir
+ * graph, starting at the end operation. During the walk current_ir_graph
+ * is set to irg. Does not use the link field. If interprocedural_view
+ * is set, visits all reachable irgs.
+ */
+void irg_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
+
+/**
+ * Walks over the ir graph.
+ *
+ * Walks over the ir graph, starting at the node given as first argument.
+ * Executes pre before visiting the predecessor of a node, post after.
+ * irg_walk uses the visited flag in irg and the nodes to determine visited
+ * nodes. It executes inc_irg_visited(current_ir_graph) to generate a new
+ * flag. Therefore current_ir_graph must be set before calling the walker.
+ * It marks the node as visited before executing pre.
+ * The void* env can be used to pass status information between the
+ * pre and post functions. Does not use the link fields.
+ * This walker also follows additional dependency egdes.
+ *
+ * @param node - the start node
+ * @param pre - walker function, executed before the predecessor of a node are visited
+ * @param post - walker function, executed after the predecessor of a node are visited
+ * @param env - environment, passed to pre and post
+ *
+ */
+void irg_walk_in_or_dep(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env);
+
+/**
+ * Walks over all reachable nodes in the ir graph.
+ *
+ * @param irg - the irg graph
+ * @param pre - walker function, executed before the predecessor of a node are visited
+ * @param post - walker function, executed after the predecessor of a node are visited
+ * @param env - environment, passed to pre and post
+ *
+ * Like irg_walk(), but walks over all reachable nodes in the ir
+ * graph, starting at the end operation. During the walk current_ir_graph
+ * is set to irg. Does not use the link field.
+ * This walker also follows additional dependency egdes.
+ * interprocedural_view is not yet supported.
+ */
+void irg_walk_in_or_dep_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
+
+/**
+ * Executes irg_walk(end, pre, post, env) for all irgraphs in irprog.
+ *
+ * @param pre - walker function, executed before the predecessor of a node are visited
+ * @param post - walker function, executed after the predecessor of a node are visited
+ * @param env - environment, passed to pre and post
+ *
+ * This function executes irg_walk(end, pre, post, env) for all irgraphs in irprog.
+ * Sets current_ir_graph properly for each walk. Conserves current
+ * current_ir_graph. In interprocedural view nodes can be visited several
+ * times. Does not use the link field.
+ */
+void all_irg_walk(irg_walk_func *pre, irg_walk_func *post, void *env);
+
+/**
+ * Walks all irgs in interprocedural view.
+ *
+ * @param pre - walker function, executed before the predecessor of a node are visited
+ * @param post - walker function, executed after the predecessor of a node are visited
+ * @param env - environment, passed to pre and post
+ *
+ * This function walks all irgs in interprocedural view.
+ * Visits each node only once. Sets current_ir_graph properly. Does not use the link field.
+ */
+void cg_walk(irg_walk_func *pre, irg_walk_func *post, void *env);
+
+/** Walks only over Block nodes in the graph.
+ *
+ * @param node - the start node
+ * @param pre - walker function, executed before the predecessor of a node are visited
+ * @param post - walker function, executed after the predecessor of a node are visited
+ * @param env - environment, passed to pre and post
+ *
+ * This function Walks only over Block nodes in the graph. Has it's own visited
+ * flag, so that it can be interleaved with the other walker.
+ * If a none block is passed, starts at the block this node belongs to.
+ * If end is passed also visits kept alive blocks. Does not use the link field.
+ */
+void irg_block_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env);
+
+/**
+ * Walks only over reachable Block nodes in the graph.
+ *
+ * @param irg - the irg graph
+ * @param pre - walker function, executed before the predecessor of a node are visited
+ * @param post - walker function, executed after the predecessor of a node are visited
+ * @param env - environment, passed to pre and post
+ *
+ * Like irg_block_walk(), but walks over all reachable blocks in the
+ * ir graph, starting at the end block. Does not use the link field.
+ */
+void irg_block_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
+
+/**
+ * Walks over all code in const_code_irg.
+ *
+ * @param pre - walker function, executed before the predecessor of a node are visited
+ * @param post - walker function, executed after the predecessor of a node are visited
+ * @param env - environment, passed to pre and post
+ *
+ * This function walks over all code in const_code_irg.
+ * Uses visited flag in const_code_irg. Does not use the link field.
+ */
+void walk_const_code(irg_walk_func *pre, irg_walk_func *post, void *env);
+
+/**
+ * Walks over reachable nodes in block-wise order, i.e. visit all nodes in a block
+ * before going to another block, starting at the end operation.
+ * Executes pre before visiting the predecessor of a node, post after.
+ * irg_walk_blkwise_graph() uses the visited flag in irg and the nodes to
+ * determine visited nodes.
+ * It executes inc_irg_visited(current_ir_graph) to generate a new
+ * flag. It marks the node as visited before executing pre.
+ * The void *env can be used to pass status information between the
+ * pre and post functions. Does not use the link fields.
+ * Walks only intraprocedural, even in interprocedural view.
+ *
+ * @param irg - the irg graph
+ * @param pre - walker function, executed before the predecessor of a node are visited
+ * @param post - walker function, executed after the predecessor of a node are visited
+ * @param env - environment, passed to pre and post
+ */
+void irg_walk_blkwise_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
+
+/**
+ * Walks over reachable nodes in block-wise order, i.e. visit all nodes in a block
+ * before going to another block, starting at the end operation.
+ * Executes pre before visiting the predecessor of a node, post after.
+ * irg_walk_blkwise_graph() uses the visited flag in irg and the nodes to
+ * determine visited nodes.
+ * It executes inc_irg_visited(current_ir_graph) to generate a new
+ * flag. It marks the node as visited before executing pre.
+ * The void *env can be used to pass status information between the
+ * pre and post functions. Does not use the link fields.
+ * Walks only intraprocedural, even in interprocedural view.
+ * This walker also follows dependency edges.
+ *
+ * @param irg - the irg graph
+ * @param pre - walker function, executed before the predecessor of a node are visited
+ * @param post - walker function, executed after the predecessor of a node are visited
+ * @param env - environment, passed to pre and post
+ */
+void irg_walk_in_or_dep_blkwise_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
+
+/**
+ * Additionally walk over all anchors. Do NOT increase the visit flag.
+ * This function visits all anchor nodes that otherwise might not been visited in a
+ * walk, for instance the Bad() node.
+ *
+ * @param irg - the irg graph
+ * @param pre - walker function, executed before the predecessor of a node are visited
+ * @param post - walker function, executed after the predecessor of a node are visited
+ * @param env - environment, passed to pre and post
+ */
+void irg_walk_anchors(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Generic hooks for various libFirm functions.
+ * @author Michael Beck
+ * @version $Id$
+ */
+#ifndef FIRM_IR_IRHOOKS_H
+#define FIRM_IR_IRHOOKS_H
+
+#include "firm_config.h"
+#include "irop.h"
+#include "irnode.h"
+#include "irgraph.h"
+
+/**
+ * options for the hook_merge_nodes hook
+ */
+typedef enum {
+ HOOK_OPT_DEAD_BLOCK, /**< a block was removed because it's dead */
+ HOOK_OPT_STG, /**< straightening optimization */
+ HOOK_OPT_IFSIM, /**< if simplification */
+ HOOK_OPT_CONST_EVAL, /**< constant evaluation */
+ HOOK_OPT_ALGSIM, /**< algebraic simplification */
+ HOOK_OPT_PHI, /**< Phi optmization */
+ HOOK_OPT_SYNC, /**< Sync optmization */
+ HOOK_OPT_WAW, /**< Write-After-Write optimization */
+ HOOK_OPT_WAR, /**< Write-After-Read optimization */
+ HOOK_OPT_RAW, /**< Read-After-Write optimization */
+ HOOK_OPT_RAR, /**< Read-After-Read optimization */
+ HOOK_OPT_RC, /**< Read-a-Const optimization */
+ HOOK_OPT_TUPLE, /**< Tuple optimization */
+ HOOK_OPT_ID, /**< ID optimization */
+ HOOK_OPT_CSE, /**< common subexpression elimination */
+ HOOK_OPT_STRENGTH_RED,/**< strength reduction */
+ HOOK_OPT_ARCH_DEP, /**< architecture dependent optimization */
+ HOOK_OPT_REASSOC, /**< reassociation */
+ HOOK_OPT_POLY_CALL, /**< polymorphic call optimization */
+ HOOK_OPT_IF_CONV, /**< an if conversion was tried */
+ HOOK_OPT_FUNC_CALL, /**< a real function call was removed */
+ HOOK_OPT_CONFIRM, /**< a value was substituted by another due to a Confirm */
+ HOOK_OPT_CONFIRM_C, /**< a value was substituted by a const due to a Confirm */
+ HOOK_OPT_CONFIRM_E, /**< a value was evaluated due to a Confirm */
+ HOOK_OPT_EXC_REM, /**< a exception edge was removed due to a Confirmation prove */
+ HOOK_LOWERED, /**< lowered */
+ HOOK_BACKEND, /**< a backend transformation */
+ HOOK_OPT_LAST
+} hook_opt_kind;
+
+typedef enum _if_result_t {
+ IF_RESULT_SUCCESS = 0, /**< if conversion could be done */
+ IF_RESULT_SIDE_EFFECT = 1, /**< if conversion failed because of side effect */
+ IF_RESULT_SIDE_EFFECT_PHI = 2, /**< if conversion failed because of Phi node found */
+ IF_RESULT_TOO_DEEP = 3, /**< if conversion failed because of to deep DAG's */
+ IF_RESULT_BAD_CF = 4, /**< if conversion failed because of bad control flow */
+ IF_RESULT_DENIED = 5, /**< if conversion failed because of architecture deny */
+ IF_RESULT_LAST
+} if_result_t;
+
+/**
+ * A generic function type.
+ */
+typedef void (generic_func)(void);
+
+/**
+ * a hook entry
+ */
+typedef struct hook_entry {
+ /** A union of all possible hook types. */
+ union {
+ /** This hook is called, after a new ir_op was created. */
+ void (*_hook_new_ir_op)(void *context, ir_op *op);
+
+ /** This hook is called, before am ir_op is destroyed. */
+ void (*_hook_free_ir_op)(void *context, ir_op *op);
+
+ /** This hook is called, after a new IR-node was created and before it is optimized. */
+ void (*_hook_new_node)(void *context, ir_graph *graph, ir_node *node);
+
+ /** This hook is called, before a node input was changed. */
+ void (*_hook_set_irn_n)(void *context, ir_node *src,
+ int pos, ir_node *tgt, ir_node *old_tgt);
+
+ /** This hook is called, before a node is replaced (exchange()) by another. */
+ void (*_hook_replace)(void *context, ir_node *old_node, ir_node *new_node);
+
+ /** This hook is called, before a node is changed into an Id node. */
+ void (*_hook_turn_into_id)(void *context, ir_node *node);
+
+ /** This hook is called, after a new graph was created and before the first block
+ * on this graph is build. */
+ void (*_hook_new_graph)(void *context, ir_graph *irg, ir_entity *ent);
+
+ /** This hook is called before a graph is freed. */
+ void (*_hook_free_graph)(void *context, ir_graph *irg);
+
+ /** This hook is called before an irg walk is started. */
+ void (*_hook_irg_walk)(void *context, ir_graph *irg, generic_func *pre, generic_func *post);
+
+ /** This hook is called before an block wise irg walk is started. */
+ void (*_hook_irg_walk_blkwise)(void *context, ir_graph *irg, generic_func *pre, generic_func *post);
+
+ /** This hook is called before an block walk is started. */
+ void (*_hook_irg_block_walk)(void *context, ir_graph *irg, ir_node *node, generic_func *pre, generic_func *post);
+
+ /** This hook is called, when debug info must be merged. */
+ void (*_hook_merge_nodes)(void *context, ir_node **new_node_array, int new_num_entries,
+ ir_node **old_node_array, int old_num_entries, hook_opt_kind opt);
+
+ /** This hook is called, when reassociation is started/stopped. */
+ void (*_hook_reassociate)(void *context, int start);
+
+ /** This hook is called, before a node is lowered. */
+ void (*_hook_lower)(void *context, ir_node *node);
+
+ /** This hook is called, before a graph is inlined. */
+ void (*_hook_inline)(void *context, ir_node *call, ir_graph *irg);
+
+ /** This hook is called, before tail recursion is applied to a graph. */
+ void (*_hook_tail_rec)(void *context, ir_graph *irg, int n_calls);
+
+ /** This hook is called, before a node is replaced due to strength reduction */
+ void (*_hook_strength_red)(void *context, ir_graph *irg, ir_node *node);
+
+ /** This hook is called, when dead node elimination is started/stopped. */
+ void (*_hook_dead_node_elim)(void *context, ir_graph *irg, int start);
+
+ /** This hook is called, when a node is substituted during dead node elimination. */
+ void (*_hook_dead_node_elim_subst)(void *context, ir_graph *irg, ir_node *old, ir_node *nw);
+
+ /** This hook is called after if conversion has run. */
+ void (*_hook_if_conversion)(void *context, ir_graph *irg, ir_node *phi, int pos, ir_node *mux, if_result_t reason);
+
+ /** This hook is called after a call was detected as const call */
+ void (*_hook_func_call)(void *context, ir_graph *irg, ir_node *call);
+
+ /** This hook is called after a Mul was replaced by a series of Shift and Add/Sub operations. */
+ void (*_hook_arch_dep_replace_mul_with_shifts)(void *context, ir_node *irn);
+
+ /** This hook is called after a Div/Mod/DivMod by a constant value was replaced. */
+ void (*_hook_arch_dep_replace_division_by_const)(void *context, ir_node *irn);
+
+ /** This hook is called after a new mode was registered. */
+ void (*_hook_new_mode)(void *context, const ir_mode *tmpl, ir_mode *mode);
+
+ /** This hook is called after a new entity was created. */
+ void (*_hook_new_entity)(void *context, ir_entity *ent);
+
+ /** This hook is called after a new type was created. */
+ void (*_hook_new_type)(void *context, ir_type *tp);
+
+ /** This hook is called at the end of the node info dumper to dump additional node info. */
+ void (*_hook_node_info)(void *context, FILE *f, const ir_node *n);
+ } hook;
+
+ /** the context for every hook */
+ void *context;
+
+ /** needed for chaining */
+ struct hook_entry *next;
+} hook_entry_t;
+
+/**
+ * possible hooks
+ */
+typedef enum {
+ hook_new_ir_op,
+ hook_free_ir_op,
+ hook_new_node,
+ hook_set_irn_n,
+ hook_replace,
+ hook_turn_into_id,
+ hook_new_graph,
+ hook_free_graph,
+ hook_irg_walk,
+ hook_irg_walk_blkwise,
+ hook_irg_block_walk,
+ hook_merge_nodes,
+ hook_reassociate,
+ hook_lower,
+ hook_inline,
+ hook_tail_rec,
+ hook_strength_red,
+ hook_dead_node_elim,
+ hook_dead_node_elim_subst,
+ hook_if_conversion,
+ hook_func_call,
+ hook_arch_dep_replace_mul_with_shifts,
+ hook_arch_dep_replace_division_by_const,
+ hook_new_mode,
+ hook_new_entity,
+ hook_new_type,
+ hook_node_info,
+ hook_last
+} hook_type_t;
+
+/**
+ * register a hook entry.
+ *
+ * @param hook the hook type
+ * @param entry the hook entry
+ */
+void register_hook(hook_type_t hook, hook_entry_t *entry);
+
+/**
+ * unregister a hook entry.
+ *
+ * @param hook the hook type
+ * @param entry the hook entry
+ */
+void unregister_hook(hook_type_t hook, hook_entry_t *entry);
+
+#ifdef FIRM_ENABLE_HOOKS
+
+extern hook_entry_t *hooks[hook_last];
+
+/**
+ * execute the hook what with the args args
+ * Do not use this macro directly.
+ */
+#define hook_exec(what, args) do { \
+ hook_entry_t *p; \
+ for (p = hooks[what]; p; p = p->next){ \
+ void *ctx = p->context; \
+ p->hook._##what args; \
+ } \
+} while (0)
+
+#else
+
+#define hook_exec(what, args)
+
+#endif /* FIRM_ENABLE_HOOKS */
+
+#define hook_new_ir_op(op) hook_exec(hook_new_ir_op, (ctx, op))
+#define hook_free_ir_op(op) hook_exec(hook_free_ir_op, (ctx, op))
+#define hook_new_node(graph, node) hook_exec(hook_new_node, (ctx, graph, node))
+#define hook_set_irn_n(src, pos, tgt, old_tgt) \
+ hook_exec(hook_set_irn_n, (ctx, src, pos, tgt, old_tgt))
+#define hook_replace(old, nw) hook_exec(hook_replace, (ctx, old, nw))
+#define hook_turn_into_id(node) hook_exec(hook_turn_into_id, (ctx, node))
+#define hook_new_graph(irg, ent) hook_exec(hook_new_graph, (ctx, irg, ent))
+#define hook_free_graph(irg) hook_exec(hook_free_graph, (ctx, irg))
+#define hook_irg_walk(irg, pre, post) hook_exec(hook_irg_walk, (ctx, irg, pre, post))
+#define hook_irg_walk_blkwise(irg, pre, post) \
+ hook_exec(hook_irg_walk_blkwise, (ctx, irg, pre, post))
+#define hook_irg_block_walk(irg, node, pre, post) \
+ hook_exec(hook_irg_block_walk, (ctx, irg, node, pre, post))
+#define hook_merge_nodes(new_node_array, new_num_entries, old_node_array, old_num_entries, opt) \
+ hook_exec(hook_merge_nodes, (ctx, new_node_array, new_num_entries, old_node_array, old_num_entries, opt))
+#define hook_reassociate(start) hook_exec(hook_reassociate, (ctx, start))
+#define hook_lower(node) hook_exec(hook_lower, (ctx, node))
+#define hook_inline(call, irg) hook_exec(hook_inline, (ctx, call, irg))
+#define hook_tail_rec(irg, n_calls) hook_exec(hook_tail_rec, (ctx, irg, n_calls))
+#define hook_strength_red(irg, node) \
+ hook_exec(hook_strength_red, (ctx, irg, node))
+#define hook_dead_node_elim(irg, start) hook_exec(hook_dead_node_elim, (ctx, irg, start))
+#define hook_dead_node_elim_subst(irg, old, nw) \
+ hook_exec(hook_dead_node_elim_subst, (ctx, irg, old, nw))
+#define hook_if_conversion(irg, phi, pos, mux, reason) \
+ hook_exec(hook_if_conversion, (ctx, irg, phi, pos, mux, reason))
+#define hook_func_call(irg, call) \
+ hook_exec(hook_func_call, (ctx, irg, call))
+#define hook_arch_dep_replace_mul_with_shifts(irn) \
+ hook_exec(hook_arch_dep_replace_mul_with_shifts, (ctx, irn))
+#define hook_arch_dep_replace_division_by_const(irn) \
+ hook_exec(hook_arch_dep_replace_division_by_const, (ctx, irn))
+#define hook_new_mode(tmpl, mode) hook_exec(hook_new_mode, (ctx, tmpl, mode))
+#define hook_new_entity(ent) hook_exec(hook_new_entity, (ctx, ent))
+#define hook_new_type(tp) hook_exec(hook_new_type, (ctx, tp))
+#define hook_node_info(F, node) hook_exec(hook_node_info, (ctx, F, node))
+
+/* the initializer, move to hooks_t.h some day */
+int firm_init_hooks(void);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file irlivechk.h
+ * @author Sebastian Hack
+ * @date 22.04.2007
+ * @version $Id$
+ * @summary
+ *
+ * Live in/end checks whose only precomputation concerns the structure of the CFG.
+ * Hence, nothing has to be updated if the program is modified unless the CFG is touched.
+ * See .c file for more comments.
+ */
+#ifndef FIRM_ANA_IRLIVECHK_H
+#define FIRM_ANA_IRLIVECHK_H
+
+#include "irgraph.h"
+#include "irnode.h"
+
+typedef struct _lv_chk_t lv_chk_t;
+
+/**
+ * Make a new liveness check environment.
+ * @param irg The graph.
+ * @return The environment.
+ */
+extern lv_chk_t *lv_chk_new(ir_graph *irg);
+
+/**
+ * Free liveness check information.
+ * @param lv The liveness check information.
+ */
+extern void lv_chk_free(lv_chk_t *lv);
+
+/**
+ * Check, if a node is live end of a given block.
+ * @param lv The liveness environment.
+ * @param bl The block to investigate.
+ * @param irn The node to check for.
+ * @return 1, if @p what is live end at @p bl, 0 else.
+ */
+extern int lv_chk_bl_end(const lv_chk_t *lv, const ir_node *bl, const ir_node *irn);
+
+/**
+ * Check, if a node is live out of a given block.
+ * @param lv The liveness environment.
+ * @param bl The block to investigate.
+ * @param irn The node to check for.
+ * @return 1, if @p what is live out at @p bl, 0 else.
+ */
+extern int lv_chk_bl_out(const lv_chk_t *lv, const ir_node *bl, const ir_node *irn);
+
+/**
+ * Check, if a node is live in of a given block.
+ * @param lv The liveness environment.
+ * @param bl The block to investigate.
+ * @param irn The node to check for.
+ * @return 1, if @p what is live in at @p bl, 0 else.
+ */
+extern int lv_chk_bl_in(const lv_chk_t *lv, const ir_node *bl, const ir_node *irn);
+
+#endif /* FIRM_ANA_IRLIVECHK_H */
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Loop datastructure and access functions.
+ * @author Goetz Lindenmaier
+ * @date 7.2002
+ * @version $Id$
+ * @summary
+ * Computes backedges in the control and data flow.
+ *
+ * @note
+ * Only Block and Phi/Filter nodes can have incoming backedges.
+ * Constructs loops data structure: indicates loop nesting.
+ */
+# ifndef FIRM_ANA_IRLOOP_H
+# define FIRM_ANA_IRLOOP_H
+
+# include "irgraph.h"
+# include "irnode.h"
+
+/* ------------------------------------------------------------------- */
+/*
+ * Backedge information.
+ *
+ * Predecessors of Block, Phi and interprocedural Filter 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 true if the predecessor pos is a backedge in the interprozeduralem view. */
+int is_inter_backedge(ir_node *n, int pos);
+/** Returns true if the predecessor pos is a backedge in the intraprocedural view. */
+int is_intra_backedge(ir_node *n, int pos);
+/** Returns non-zero if the predecessor pos is a backedge. */
+int is_backedge (ir_node *n, int pos);
+/** Marks edge pos as a backedge. */
+void set_backedge (ir_node *n, int pos);
+/** Marks edge pos as a non-backedge. */
+void set_not_backedge (ir_node *n, int pos);
+/** Returns non-zero if n has backedges. */
+int has_backedges (ir_node *n);
+/** Clears all backedge information. */
+void clear_backedges (ir_node *n);
+
+
+
+/** Loop elements: loop nodes and ir nodes */
+typedef union {
+ firm_kind *kind; /**< is either k_ir_node or k_ir_loop */
+ ir_node *node; /**< Pointer to an ir_node element */
+ ir_loop *son; /**< Pointer to an ir_loop element */
+} loop_element;
+
+int is_ir_loop(const void *thing);
+
+/** Set the outermost loop in ir graph as basic access to loop tree. */
+void set_irg_loop(ir_graph *irg, ir_loop *l);
+
+/* Returns the root loop info (if exists) for an irg. */
+ir_loop *get_irg_loop(ir_graph *irg);
+
+/** Returns the loop n is contained in. NULL if node is in no loop. */
+ir_loop *get_irn_loop(const ir_node *n);
+
+/** Returns outer loop, itself if outermost. */
+ir_loop *get_loop_outer_loop (const ir_loop *loop);
+/** Returns nesting depth of this loop */
+int get_loop_depth (const ir_loop *loop);
+
+/* Sons are the inner loops contained in this loop. */
+/** Returns the number of inner loops */
+int get_loop_n_sons (const ir_loop *loop);
+
+/** Returns the pos`th son loop (inner loop) of a loop.
+ Returns NULL if there is not a pos`th loop_node. */
+ir_loop *get_loop_son (ir_loop *loop, int pos);
+
+/** Returns the number of nodes contained in loop. */
+int get_loop_n_nodes (ir_loop *loop);
+
+/** Returns the pos`th ir_node of a loop.
+ Returns NULL if there is not a pos`th ir_node. */
+ir_node *get_loop_node (ir_loop *loop, int pos);
+
+/** Returns the number of elements contained in loop. */
+int get_loop_n_elements (const ir_loop *loop);
+
+/** Returns a loop element. A loop element can be interpreted as a
+ kind pointer, an ir_node* or an ir_loop*. */
+loop_element get_loop_element (const ir_loop *loop, int pos);
+
+/** Returns the element number of the loop son in loop.
+ * Returns -1 if not found. O(|elements|). */
+int get_loop_element_pos(const ir_loop *loop, void *le);
+
+/** Returns a unique node number for the loop node to make output
+ readable. If libfirm_debug is not set it returns the loop cast to
+ int. */
+int get_loop_loop_nr(const ir_loop *loop);
+
+/** A field to connect additional information to a loop. Only valid
+ if libfirm_debug is set, else returns NULL. */
+void set_loop_link (ir_loop *loop, void *link);
+void *get_loop_link (const ir_loop *loop);
+
+/* ------------------------------------------------------------------- */
+/* Constructing and destructing the loop/backedge information. */
+/* ------------------------------------------------------------------- */
+
+/** Constructs backedge information and loop tree for a graph in intraprocedural view.
+ *
+ * The algorithm views the program representation as a pure graph.
+ * It assumes that only block and phi nodes may be loop headers.
+ * The resulting loop tree is a possible visiting order for dataflow
+ * analysis.
+ *
+ * This algorithm destoyes the link field of block nodes.
+ *
+ * @returns Maximal depth of loop tree.
+ *
+ * @remark
+ * One assumes, the Phi nodes in a block with a backedge have backedges
+ * at the same positions as the block. This is not the case, as
+ * the scc algorithms does not respect the program semantics in this case.
+ * Take a swap in a loop (t = i; i = j; j = t;) This results in two Phi
+ * nodes. They form a cycle. Once the scc algorithm deleted one of the
+ * edges, the cycle is removed. The second Phi node does not get a
+ * backedge!
+ */
+/* @@@ Well, maybe construct_loop_information or analyze_loops ? */
+int construct_backedges(ir_graph *irg);
+
+/** Constructs backedges for all irgs in interprocedural view.
+ *
+ * @see As construct_backedges(), but for interprocedural view.
+ *
+ * @remark
+ * All loops in the graph will be marked as such, not only
+ * realizeable loops and recursions in the program. E.g., if the
+ * same funcion is called twice, there is a loop between the first
+ * function return and the second call.
+ *
+ * @returns Maximal depth of loop tree.
+*/
+int construct_ip_backedges(void);
+
+/** Construct loop tree only for control flow.
+ *
+ * This constructs loop information resembling the program structure.
+ * It is useful for loop optimizations and analyses, as, e.g., finding
+ * iteration variables or loop invariant code motion.
+ *
+ * This algorithm computes only back edge information for Block nodes, not
+ * for Phi nodes.
+ *
+ * This algorithm destoyes the link field of block nodes.
+ *
+ * @returns Maximal depth of loop tree.
+ */
+int construct_cf_backedges(ir_graph *irg);
+
+/** Construct interprocedural loop tree for control flow.
+ *
+ * @see construct_cf_backedges() and construct_ip_backedges().
+ */
+int construct_ip_cf_backedges (void);
+
+/** Removes all loop information.
+ * Resets all backedges. Works for any construction algorithm.
+ */
+void free_loop_information(ir_graph *irg);
+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.
+ * @param block A block node.
+ *
+ * Returns non-zero, if the node n is not changed in the loop block
+ * belongs to or in inner loops of this block. */
+int is_loop_invariant(ir_node *n, ir_node *block);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Memory disambiguator
+ * @author Michael Beck
+ * @date 27.12.2006
+ * @version $Id$
+ */
+#ifndef FIRM_ANA_IRMEMORY_H
+#define FIRM_ANA_IRMEMORY_H
+
+#include "firm_types.h"
+
+/** The alias relation of two memory addresses. */
+typedef enum {
+ no_alias, /**< No alias. */
+ may_alias, /**< Unknown state, may alias. */
+ sure_alias /**< Sure alias. */
+} ir_alias_relation;
+
+/** The state of the address taken flags. */
+typedef enum {
+ ir_address_taken_not_computed, /**< Address taken flag is not computed. */
+ ir_address_taken_computed /**< Address taken flag is computed. */
+} ir_address_taken_computed_state;
+
+/** Possible options for the memory disambiguator. */
+typedef enum {
+ aa_opt_no_opt = 0, /**< no options: most conservative */
+ aa_opt_type_based = 1, /**< use type based alias analysis: strict typed source language */
+ aa_opt_byte_type_may_alias = 2, /**< if type based analysis is enabled: bytes types may alias other types */
+ aa_opt_no_alias = 4, /**< two addresses NEVER alias, use with CAUTION (gcc -fno-alias) */
+ aa_opt_inherited = 128 /**< only for implementation: options from a graph are inherited from global */
+} disambuigator_options;
+
+/**
+ * A source language specific memory disambiguator function.
+ * Called by get_alias_relation().
+ */
+typedef ir_alias_relation (*DISAMBIGUATOR_FUNC)(
+ ir_graph *irg,
+ ir_node *adr1, ir_mode *mode1,
+ ir_node *adr2, ir_mode *mode2);
+
+/**
+ * Determine the alias relation between two addresses.
+ *
+ * @param irg The current graph.
+ * @param adr1 The first address.
+ * @param mode1 The mode of the first memory access.
+ * @param adr2 The second address.
+ * @param mode2 The mode of the second memory access.
+ *
+ * The memory disambiguator tries to determine the alias state between
+ * two memory addresses. The following rules are used:
+ *
+ * - variables from different segments never alias (R1)
+ * - a global variable and a local one never alias (R1 b)
+ * - a global variable and a TLS one never alias (R1 c)
+ * - a local variable and a TLS one never alias (R1 d)
+ * - a local variable and a parameter never alias (R1 e)
+ * - two different variables never alias (R2)
+ * - if one is a variable whose address has never been taken
+ * there is no alias (R3)
+ * - if two memory addresses have the same base and their offsets
+ * do not describe overlapping regions there is no alias (R4)
+ * - if opt_strong_typed is set and both addresses describe entities,
+ * different types never alias (R5)
+ *
+ * If none of these rules apply, the points-to framework must be
+ * interrogated to detect the alias relation.
+ */
+ir_alias_relation get_alias_relation(
+ ir_graph *irg,
+ ir_node *adr1, ir_mode *mode1,
+ ir_node *adr2, ir_mode *mode2);
+
+/**
+ * Set a source language specific memory disambiguator function.
+ *
+ * @param func The callback.
+ */
+void set_language_memory_disambiguator(DISAMBIGUATOR_FUNC func);
+
+/**
+ * Initialize the relation cache.
+ */
+void mem_disambig_init(void);
+
+/*
+ * Determine the alias relation between two addresses and
+ * cache the result.
+ *
+ * @param irg The current graph.
+ * @param adr1 The first address.
+ * @param mode1 The mode of the first memory access.
+ * @param adr2 The second address.
+ * @param mode2 The mode of the second memory access.
+ *
+ * @see get_alias_relation()
+ */
+ir_alias_relation get_alias_relation_ex(
+ ir_graph *irg,
+ ir_node *adr1, ir_mode *mode1,
+ ir_node *adr2, ir_mode *mode2);
+
+/**
+ * Free the relation cache.
+ */
+void mem_disambig_term(void);
+
+/**
+ * Returns the current address taken state of the graph.
+ */
+ir_address_taken_computed_state get_irg_address_taken_state(const ir_graph *irg);
+
+/**
+ * Sets the current address taken state of the graph.
+ *
+ * @param irg the graph
+ * @param state the new state
+ */
+void set_irg_address_taken_state(ir_graph *irg, ir_address_taken_computed_state state);
+
+/**
+ * Assure that the address taken flag is computed for the given graph.
+ *
+ * This is an intraprocedural analysis that computes the address_taken state
+ * for all local variables.
+ *
+ * Note that this is a conservative estimation that by no Firm transformation
+ * can be invalidated, so it's only recomputed if manually triggered by calling
+ * set_irg_address_taken_state(irg, ir_address_taken_not_computed).
+ * Even then the information is not cleaned from the variables, call
+ * assure_irg_address_taken_computed() again for recomputation.
+ */
+void assure_irg_address_taken_computed(ir_graph *irg);
+
+/**
+ * Returns the current address taken state of the globals.
+ */
+ir_address_taken_computed_state get_irp_globals_address_taken_state(void);
+
+/**
+ * Sets the current address taken state of the globals.
+ *
+ * @param state the new state
+ */
+void set_irp_globals_address_taken_state(ir_address_taken_computed_state state);
+
+/**
+ * Assure that the address taken flag is computed for the global and TLS entities (variables).
+ *
+ * This is an interprocedural analysis that computes the address_taken state
+ * for all global and TLS variables.
+ *
+ * Note that this is a conservative estimation that by no Firm transformation
+ * can be invalidated, so it's only recomputed if manually triggered by calling
+ * set_irp_globals_address_taken_state(ir_address_taken_not_computed).
+ * Even then the information is not cleaned from the variables, call
+ * assure_irp_globals_address_taken_computed() again for recomputation.
+ */
+void assure_irp_globals_address_taken_computed(void);
+
+/**
+ * Get the memory disambiguator options for a graph.
+ *
+ * @param irg the graph
+ */
+unsigned get_irg_memory_disambiguator_options(ir_graph *irg);
+
+/**
+ * Set the memory disambiguator options for a graph.
+ *
+ * @param irg the graph
+ * @param option a set of options
+ */
+void set_irg_memory_disambiguator_options(ir_graph *irg, unsigned options);
+
+/**
+ * Set the global disambiguator options for all graphs not having local options.
+ *
+ * @param option a set of options
+ */
+void set_irp_memory_disambiguator_options(unsigned options);
+
+#endif /* FIRM_ANA_IRMEMORY_H */
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Data modes of operations.
+ * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Mathias Heil,
+ * Michael Beck
+ * @version $Id$
+ * @summary
+ * This module specifies the modes that type the firm nodes. It defines
+ * a datasturcture that describes a mode and implements constructors and
+ * access routines to this datastructure. Further it defines a set of
+ * predefined modes.
+ *
+ * SEE ALSO:
+ * UKA tech report 1999-44 for more information about modes.
+ */
+#ifndef FIRM_IR_IRMODE_H
+#define FIRM_IR_IRMODE_H
+
+#include "firm_types.h"
+#include "ident.h"
+
+/* ********** Predefined modes ********** */
+
+/**
+ * Predefined mode according to tech report 1999-14.
+ */
+typedef enum { /* irm is short for `ir mode' */
+ irm_BB, /**< basic block */
+ irm_X, /**< execution */
+ irm_F, /**< float(32) */
+ irm_D, /**< double(64) */
+ irm_E, /**< extended(80) */
+ irm_Bs, /**< signed byte(8) */
+ irm_Bu, /**< unsigned byte(8) */
+ irm_Hs, /**< signed short(16) */
+ irm_Hu, /**< unsigned short(16) */
+ irm_Is, /**< signed int(32) */
+ irm_Iu, /**< unsigned int(32) */
+ irm_Ls, /**< signed long(64) */
+ irm_Lu, /**< unsigned long(64) */
+ irm_LLs, /**< signed long long(128) */
+ irm_LLu, /**< unsigned long long(128) */
+ irm_C, /**< character */
+ irm_P, /**< pointer */
+ irm_b, /**< internal boolean */
+ irm_M, /**< memory */
+ irm_T, /**< tuple */
+ irm_U, /**< unicode character */
+ irm_ANY, /**< undefined mode */
+ irm_BAD, /**< bad mode */
+ irm_max /**< maximum value for modecode */
+} modecode;
+
+/** These values represent the different mode classes of value representations.
+ */
+typedef enum {
+ /* Predefined sorts of modes */
+ irms_auxiliary, /**< Only for Firm use. Not extensible. (irm_T) */
+ irms_control_flow, /**< Marks all control flow modes. Not extensible. (irm_BB, irm_X) */
+ irms_memory, /**< Marks the memory mode. Not extensible. (irm_M) */
+ irms_internal_boolean, /**< Internal boolean representation.
+ Storing to memory impossible, convert first. (irm_b) */
+ /* user-extensible sorts of modes */
+ irms_int_number, /**< A mode to represent int numbers.
+ Integer computations can be performed. */
+ irms_float_number, /**< A mode to represent float numbers.
+ Floating point computations can be performed. */
+ irms_reference, /**< A mode to represent entities.
+ Restricted int computations can be performed */
+ irms_character /**< A mode to represent characters/symbols
+ ?? Are computations allowed? as int?? */
+} mode_sort;
+
+/** These values represent the different arithmetic operations possible with a mode.
+ Further arithmetics can be defined, e.g., for @@@ modes.
+ */
+typedef enum {
+ 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
+ floatingpoint 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
+} mode_arithmetic;
+
+
+/* ********** Constructor for user defined modes **************** */
+/**
+ * Creates a new mode.
+ *
+ * @param name the name of the mode to be created
+ * @param sort the mode_sort of the mode to be created
+ * @param bit_size number of bits this mode allocate
+ * @param sign non-zero if this is a signed mode
+ * @param arithmetic arithmetic operations possible with a mode
+ * @param modulo_shift Is ignored for modes other than integer.
+ *
+ * This function constructs a new mode given by the parameters.
+ * If the parameters match an already defined mode, this mode is returned
+ * (including the default modes).
+ * If the mode is newly allocated, a new unique mode_code is chosen.
+ * Also, special value tarvals will be calculated such as null,
+ * min, max and can be retrieved using the get_mode_* functions
+ *
+ * @return
+ * The new mode or NULL on error.
+ *
+ * @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.
+ */
+ir_mode *new_ir_mode(const char *name, mode_sort sort, int bit_size, int sign, mode_arithmetic arithmetic, unsigned int modulo_shift);
+
+/**
+ * Creates a new vector mode.
+ *
+ * @param name the name of the mode to be created
+ * @param sort the mode_sort of the mode to be created
+ * @param bit_size number of bits for one element of this mode
+ * @param num_of_elem number of elements in this vector mode
+ * @param sign non-zero if this is a signed mode
+ * @param arithmetic arithmetic operations possible with a mode
+ * @param modulo_shift Is ignored for modes other than integer.
+ *
+ * This function constructs a new vector mode given by the parameters.
+ * If the parameters match an already defined mode, this mode is returned.
+ * If the mode is newly allocated, a new unique mode_code is chosen.
+ * Also, special value tarvals will be calculated such as null,
+ * min, max and can be retrieved using the get_mode_* functions
+ *
+ * @return
+ * The new mode or NULL on error.
+ */
+ir_mode *new_ir_vector_mode(const char *name, mode_sort sort, int bit_size, unsigned num_of_elem, int sign,
+ mode_arithmetic arithmetic, unsigned int modulo_shift);
+
+/**
+ * Checks whether a pointer points to a mode.
+ *
+ * @param thing an arbitrary pointer
+ *
+ * @return
+ * true if the thing is a mode, else false
+ */
+int is_mode(void *thing);
+
+/* ********** Access methods to read mode information *********** */
+
+/** Returns the classification of the mode */
+modecode get_mode_modecode(const ir_mode *mode);
+
+/** Returns the ident* of the mode */
+ident *get_mode_ident(const ir_mode *mode);
+
+/** Returns the null-terminated name of this mode. */
+const char *get_mode_name(const ir_mode *mode);
+
+/** Returns a coarse classification of the mode. */
+mode_sort get_mode_sort(const ir_mode *mode);
+
+/** Returns the size of values of the mode in bits. */
+int get_mode_size_bits(const ir_mode *mode);
+
+/** Returns the size of values of the mode in bytes.
+ * If the size is not dividable by 8 returns -1. */
+int get_mode_size_bytes(const ir_mode *mode);
+
+/** Returns the signess of a mode.
+ *
+ * Returns the signess of a mode: 1 if mode is signed. */
+int get_mode_sign(const ir_mode *mode);
+
+/** Returns the arithmetic of a mode */
+int get_mode_arithmetic(const ir_mode *mode);
+
+/** Get the modulo shift attribute.
+ *
+ * Attribute modulo shift specifies for modes of kind irms_int_number
+ * whether shift applies modulo to value of bits to shift. Zero for
+ * modes that are not integer.
+ */
+unsigned int get_mode_modulo_shift(const ir_mode *mode);
+
+/** Return the number of vector elements.
+ *
+ * Attribute vector_elem specifies the number of vector elements of
+ * a vector mode. For non-vector modes it returns 1 for data and 0
+ * for all other modes
+ */
+unsigned int get_mode_n_vector_elems(const ir_mode *mode);
+
+/** Returns the stored intermediate information. */
+void *get_mode_link(const ir_mode *mode);
+
+/** Stores new intermediate information. */
+void set_mode_link(ir_mode *mode, void *l);
+
+/**
+ * Returns the smallest representable value of a given mode.
+ *
+ * For modes of the sort float_number this is the most negative value
+ * bigger than -infinite.
+ */
+tarval *get_mode_min(ir_mode *mode);
+
+/**
+ * Returns the biggest representable value o f a given mode.
+ *
+ * For modes of the sort float_number this is the largest value lower
+ * than infinite.
+ */
+tarval *get_mode_max(ir_mode *mode);
+
+/**
+ * Returns the value Zero represented in this mode.
+ *
+ * Zero is the additive neutral element and as such
+ * is defined only for modes allowing addition, i.e.
+ * op_pin_state_floats and ints, and references (NULL-Pointer)
+ * else returns tarval_bad.
+ */
+tarval *get_mode_null(ir_mode *mode);
+
+/**
+ * Returns the value One, represented in this mode.
+ *
+ * One, being the multiplicative neutral element,
+ * is defined only for modes allowing multiplication,
+ * i.e. ints and floats.
+ */
+tarval *get_mode_one(ir_mode *mode);
+
+/**
+ * Returns the value Minus One, represented in this mode.
+ *
+ * Minus One is defined only for modes allowing
+ * multiplication with signed values, i.e. signed ints and floats.
+ */
+tarval *get_mode_minus_one(ir_mode *mode);
+
+/**
+ * Returns the positive infinite value of a mode.
+ *
+ * This is only valid for float_numbers, other modes
+ * will result in tarval_bad.
+ */
+tarval *get_mode_infinite(ir_mode *mode);
+
+/**
+ * Returns the NAN value of a given mode.
+ *
+ * This is only valid for float_numbers, other modes
+ * will result in tarval_bad.
+ */
+tarval *get_mode_NAN(ir_mode *mode);
+
+extern ir_mode *mode_M; /**< memory */
+
+/* -- A set of predefined, numerical modes according to Techreport 1999-44 -- */
+extern ir_mode *mode_F; /**< signed float(32) */
+extern ir_mode *mode_D; /**< signed double(64) */
+extern ir_mode *mode_E; /**< signed extended(80) */
+extern ir_mode *mode_Bs; /**< signed byte (former char) */
+extern ir_mode *mode_Bu; /**< unsigned byte (former char) */
+extern ir_mode *mode_Hs; /**< signed short integer */
+extern ir_mode *mode_Hu; /**< unsigned short integer */
+extern ir_mode *mode_Is; /**< signed integer */
+extern ir_mode *mode_Iu; /**< unsigned integer */
+extern ir_mode *mode_Ls; /**< signed long integer */
+extern ir_mode *mode_Lu; /**< unsigned long integer */
+extern ir_mode *mode_LLs; /**< signed long long integer */
+extern ir_mode *mode_LLu; /**< unsigned long long integer */
+
+extern ir_mode *mode_C; /**< 8 bit char */
+extern ir_mode *mode_U; /**< 16 bit unicode char */
+
+extern ir_mode *mode_P; /**< pointer */
+extern ir_mode *mode_P_code; /**< A pointer mode that is set by the client of libfirm. This mode
+ represents the pointer size of the target machine code addresses. Is initialized
+ to mode_P. */
+extern ir_mode *mode_P_data; /**< A pointer mode that is set by the client of libfirm. This mode
+ represents the pointer size of the target machine data addresses. Is initialized
+ to mode_P. */
+
+/* -- Auxiliary modes necessary for the Firm representation -- */
+extern ir_mode *mode_b; /**< internal boolean */
+
+extern ir_mode *mode_X; /**< execution */
+extern ir_mode *mode_BB; /**< block */
+
+extern ir_mode *mode_T; /**< tuple (none) */
+extern ir_mode *mode_ANY;/**< undefined mode */
+extern ir_mode *mode_BAD;/**< bad mode */
+
+/*@{*/
+/** Access routines for JNI Interface */
+ir_mode *get_modeF(void);
+ir_mode *get_modeD(void);
+ir_mode *get_modeE(void);
+ir_mode *get_modeBs(void);
+ir_mode *get_modeBu(void);
+ir_mode *get_modeHs(void);
+ir_mode *get_modeHu(void);
+ir_mode *get_modeIs(void);
+ir_mode *get_modeIu(void);
+ir_mode *get_modeLs(void);
+ir_mode *get_modeLu(void);
+ir_mode *get_modeLLs(void);
+ir_mode *get_modeLLu(void);
+ir_mode *get_modeC(void);
+ir_mode *get_modeU(void);
+ir_mode *get_modeP(void);
+ir_mode *get_modeb(void);
+ir_mode *get_modeX(void);
+ir_mode *get_modeBB(void);
+ir_mode *get_modeM(void);
+ir_mode *get_modeT(void);
+ir_mode *get_modeANY(void);
+ir_mode *get_modeBAD(void);
+
+/** Returns the machine specific pointer mode for code addresses. */
+ir_mode *get_modeP_code(void);
+
+/** Returns the machine specific pointer mode for data addresses. */
+ir_mode *get_modeP_data(void);
+
+/**
+ * Sets the machine specific pointer mode for code addresses.
+ * If not set, the predefined mode mode_P will be used.
+ */
+void set_modeP_code(ir_mode *p);
+
+/**
+ * Sets the machine specific pointer mode for data addresses.
+ * If not set, the predefined mode mode_P will be used.
+ */
+void set_modeP_data(ir_mode *p);
+
+/**
+ Functions to check, whether a modecode is signed, float, int, character,
+ reference, num, numP, data, datab or dataM.
+
+ For more exact definitions read the corresponding pages
+ in the firm documentation or the following enumeration
+
+ The set of "float" is defined as:
+ float = {irm_F, irm_D, irm_E}
+
+ The set of "int" is defined as:
+ int = {irm_Bs, irm_Bu, irm_Hs, irm_Hu, irm_Is, irm_Iu, irm_Ls, irm_Lu}
+
+ The set of "character" is defined as:
+ character = {irm_C, irm_U}
+
+ The set of "reference" is defined as:
+ reference = {irm_P}
+
+ The set of "num" is defined as:
+ num = {float || int}
+
+ The set of "numP" is defined as:
+ numP = {float || int || reference}
+
+ The set of "data" is defined as:
+ data = {num || character || reference}
+
+ The set of "datab" is defined as:
+ datab = {data || irm_b }
+
+ The set of "dataM" is defined as:
+ dataM = {data || irm_M}
+
+ Vector "int" and "float" are defined by the arithmetic and vector_elem > 1.
+*/
+/*@}*/
+/* Test for a certain class of modes. */
+int mode_is_signed (const ir_mode *mode);
+int mode_is_float (const ir_mode *mode);
+int mode_is_int (const ir_mode *mode);
+int mode_is_character (const ir_mode *mode);
+int mode_is_reference (const ir_mode *mode);
+int mode_is_num (const ir_mode *mode);
+int mode_is_numP (const ir_mode *mode);
+int mode_is_data (const ir_mode *mode);
+int mode_is_datab (const ir_mode *mode);
+int mode_is_dataM (const ir_mode *mode);
+int mode_is_float_vector (const ir_mode *mode);
+int mode_is_int_vector (const ir_mode *mode);
+
+/** Returns true if sm can be converted to lm without loss
+ according to firm definiton */
+int smaller_mode(const ir_mode *sm, const ir_mode *lm);
+
+/**
+ * Returns a matching unsigned mode for a given integer signed mode.
+ * Returns NULL if no matching mode exists.
+ */
+ir_mode *find_unsigned_mode(const ir_mode *mode);
+
+/**
+ * Returns a matching signed mode for a given integer unsigned mode.
+ * Returns NULL if no matching mode exists.
+ */
+ir_mode *find_signed_mode(const ir_mode *mode);
+
+/**
+ * Returns an integer mode with 2*n bits for a given integer mode with n bits.
+ * Returns NULL if no matching mode exists.
+ */
+ir_mode *find_double_bits_int_mode(const ir_mode *mode);
+
+/**
+ * Returns non-zero if the given mode honors signed zero's, i.e.,
+ * a +0 and a -0 exists and handled differently.
+ */
+int mode_honor_signed_zeros(const ir_mode *mode);
+
+/**
+ * Returns non-zero if the given mode might overflow on unary Minus.
+ */
+int mode_overflow_on_unary_Minus(const ir_mode *mode);
+
+/**
+ * Returns non-zero if the mode has a reversed wrap-around
+ * logic, especially (a + x) - x == a.
+ * This is normally true for integer modes, not for floating
+ * point modes.
+ */
+int mode_wrap_around(const ir_mode *mode);
+
+/**
+ * Return the signed integer equivalent mode for an reference mode.
+ */
+ir_mode *get_reference_mode_signed_eq(ir_mode *mode);
+
+/**
+ * Sets the signed integer equivalent mode for an reference mode.
+ */
+void set_reference_mode_signed_eq(ir_mode *ref_mode, ir_mode *int_mode);
+
+/**
+ * Return the unsigned integer equivalent mode for an reference mode.
+ */
+ir_mode *get_reference_mode_unsigned_eq(ir_mode *mode);
+
+/**
+ * Sets the unsigned integer equivalent mode for an reference mode.
+ */
+void set_reference_mode_unsigned_eq(ir_mode *ref_mode, ir_mode *int_mode);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Representation of an intermediate operation.
+ * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Michael Beck
+ * @version $Id$
+ */
+#ifndef FIRM_IR_IRNODE_H
+#define FIRM_IR_IRNODE_H
+
+#include <stddef.h>
+
+#include "firm_common.h"
+#include "typerep.h"
+#include "irop.h"
+#include "irmode.h"
+#include "dbginfo.h"
+
+/**
+ * @file irnode.h
+ *
+ * @author Martin Trapp, Christian Schaefer
+ *
+ * Declarations of an ir node.
+ */
+
+/**
+ * @defgroup ir_node Declarations of an ir node.
+ *
+ * The type definition of ir_node is also in irgraph.h to resolve
+ * recursion between irnode.h and irgraph.h
+ *
+ * ir_node - a datatype representing a Firm node
+ *
+ * The common fields are:
+ *
+ * - firm_kind - A firm_kind tag containing k_type. This is useful
+ * for dynamically checking whether a node is a ir_node.
+ * - 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.
+ * @{
+ */
+
+/**
+ * you can work on the graph without considering the different types
+ * of nodes, it's just a big graph.
+ */
+
+/**
+ * Checks whether a pointer points to a ir node.
+ *
+ * @param thing an arbitrary pointer
+ * @return non-zero if the thing is a ir mode, else zero
+ */
+int is_ir_node (const void *thing);
+
+/**
+ * Returns the number of predecessors without the block predecessor.
+ *
+ * @param node the IR-node
+ */
+int get_irn_arity (const ir_node *node);
+int get_irn_intra_arity(const ir_node *node);
+int get_irn_inter_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. */
+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 */
+
+/**
+ * Get the n-th predecessor of a node.
+ * This function removes Id predecessors.
+ * This function automatically handles intra- and interprocedural views.
+ */
+ir_node *get_irn_n(const ir_node *node, int n);
+
+/**
+* Add a artificial dependency to the node.
+* The dependency is only inserted if it is not there already.
+* @param node The node.
+* @param dep The dependency target.
+* @return The index in the array (get_irn_dep() with that index returns @p dep).
+*/
+int add_irn_dep(ir_node *node, ir_node *dep);
+
+/**
+ * Copy all dependencies from a node to another.
+ * @param tgt The node which should be enriched.
+ * @param src The node whose dependencies shall be copied.
+ */
+void add_irn_deps(ir_node *tgt, ir_node *src);
+
+/**
+* Get the length of the dependency array.
+* @param node The node.
+* @return The length of the dependency array or 0 if it has not yet been allocated.
+*/
+int get_irn_deps(const ir_node *node);
+
+/**
+* Get an entry of the dependency array.
+* @param node The node.
+* @param pos The position.
+* @return The node at that position.
+*/
+ir_node *get_irn_dep(const ir_node *node, int pos);
+
+/**
+* Set an entry of the dependency array.
+* @param node The node.
+* @param pos The position.
+* @param dep The dependency target.
+*/
+void set_irn_dep(ir_node *node, int pos, ir_node *dep);
+
+
+/**
+ * Get the n-th predecessor of a node in intraprocedural view.
+ * Can be used always if it's know that node is not a split one.
+ */
+ir_node *get_irn_intra_n(const ir_node *node, int n);
+
+/**
+ * Get the n-th predecessor of a node in interprocedural view.
+ */
+ir_node *get_irn_inter_n(const ir_node *node, int n);
+
+/** Replace the n-th predecessor of a node with a new one. */
+void set_irn_n(ir_node *node, int n, ir_node *in);
+/**
+ * Appends a new predecessor to a node. This only works for nodes with
+ * variable arity!
+ * @returns the number of the new input
+ */
+int add_irn_n(ir_node *node, ir_node *in);
+/* Sets the mode struct of node. */
+void set_irn_mode(ir_node *node, ir_mode *mode);
+/** Gets the mode struct of a node. */
+ir_mode *get_irn_mode(const ir_node *node);
+/** Gets the mode-enum modecode. */
+modecode get_irn_modecode(const ir_node *node);
+/** Gets the ident for a string representation of the mode .*/
+ident *get_irn_modeident(const ir_node *node);
+/** Gets the string representation of the mode .*/
+const char *get_irn_modename(const ir_node *node);
+/** Gets the opcode struct of the node. */
+ir_op *get_irn_op(const ir_node *node);
+/** Sets the opcode struct of the node. */
+void set_irn_op(ir_node *node, ir_op *op);
+/** Gets the opcode-enum of the node. */
+ir_opcode get_irn_opcode(const ir_node *node);
+/** Get the string representation of the opcode. */
+const char *get_irn_opname(const ir_node *node);
+/** Get the ident for a string representation of the opcode. */
+ident *get_irn_opident(const ir_node *node);
+/** If arg is an argument of the node, returns it's position, -1 otherwise */
+int get_irn_pred_pos(ir_node *node, ir_node *arg);
+/** Gets the visited counter of a node. */
+unsigned long get_irn_visited(const ir_node *node);
+/** Sets the visited counter of a node. */
+void set_irn_visited(ir_node *node, unsigned long visited);
+/** Sets visited to get_irg_visited(current_ir_graph). */
+void mark_irn_visited(ir_node *node);
+/** Returns 1 if visited < get_irg_visited(current_ir_graph). */
+int irn_not_visited(const ir_node *node);
+/** Returns 1 if visited >= get_irg_visited(current_ir_graph). */
+int irn_visited(const ir_node *node);
+
+/**
+ * Sets the link of a node.
+ * Only allowed if the graph is NOT in phase_building.
+ */
+void set_irn_link(ir_node *node, void *link);
+
+/** Returns the link of a node. */
+void *get_irn_link(const ir_node *node);
+
+/** Returns the ir_graph this node belongs to. Only valid if irg
+ * is in state op_pin_state_pinned (irg is only stored in the block. */
+ir_graph *get_irn_irg(const ir_node *node);
+
+/** Outputs a unique number for this node if libFIRM is compiled for
+ debugging, (configure with --enable-debug) else returns address
+ of node cast to long. */
+long get_irn_node_nr(const ir_node *node);
+
+/** 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.
+ */
+op_pin_state get_irn_pinned(const ir_node *node);
+
+/** Set pin state for nodes with op pin state op_pin_state_exc_pinned */
+void set_irn_pinned(ir_node *node, op_pin_state state);
+
+/** Returns whether the node is currently pinned.
+ *
+ * If get_irn_pinned returns op_pin_state_floats and the graph the
+ * node belongs to is in state op_poin_state_floats then this function
+ * returns 'floats', else 'pinned'.
+ */
+op_pin_state is_irn_pinned_in_irg(const ir_node *node);
+
+/**
+ * IR node constructor.
+ * Create a new IR node in irg, with an op, mode, arity and
+ * some incoming IR nodes.
+ * This constructor is used in every specific IR node constructor.
+ *
+ * @param db Debug info.
+ * @param irg IR-graph on with this new node should be constructed.
+ * @param block The block the new node belongs to
+ * @param op The opcode of the new node.
+ * @param mode The mode of the new node.
+ * @param arity The arity of the new node, <0 if can be changed dynamically.
+ * @param in An array of arity predecessor nodes.
+ */
+ir_node *
+new_ir_node(dbg_info *db,
+ ir_graph *irg,
+ ir_node *block,
+ ir_op *op,
+ ir_mode *mode,
+ int arity,
+ ir_node *in[]);
+
+/**
+ * Return the block the node belongs to. This is only
+ * 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.
+ *
+ * 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
+ * get_irn_block(). */
+ir_node *get_nodes_block (const ir_node *node);
+
+/** Sets the Block of a node. */
+void set_nodes_block (ir_node *node, ir_node *block);
+
+/**
+ * @function get_irn_block()
+ * @see get_nodes_block()
+ */
+
+/**
+ * Projection numbers for result of Start node: use for Proj nodes!
+ */
+typedef enum {
+ pn_Start_X_initial_exec, /**< Projection on the initial control flow. */
+ pn_Start_M, /**< Projection on the initial memory. */
+ pn_Start_P_frame_base, /**< Projection on the frame base pointer. */
+ pn_Start_P_globals, /**< Projection on the pointer to the data segment
+ containing _all_ global entities. Use for
+ position independent data/code access. */
+ pn_Start_P_tls, /**< Projection on the pointer to the thread local store
+ segment containing _all_thread local variables. */
+ pn_Start_T_args, /**< Projection on all arguments. */
+ pn_Start_P_value_arg_base, /**< Pointer to region of compound value arguments as defined by
+ type of this method. */
+ pn_Start_max /**< number of projections from a Start */
+} pn_Start; /* Projection numbers for Start. */
+
+/** Test whether arbitrary node is frame pointer.
+ *
+ * Test whether arbitrary node is frame pointer, i.e. Proj(pn_Start_P_frame_base)
+ * from Start. If so returns frame type, else Null. */
+ir_type *is_frame_pointer(ir_node *n);
+
+/** Test whether arbitrary node is globals pointer.
+ *
+ * Test whether arbitrary node is globals pointer, i.e. Proj(pn_Start_P_globals)
+ * from Start. If so returns global type, else Null. */
+ir_type *is_globals_pointer(ir_node *n);
+
+/** Test whether arbitrary node is tls pointer.
+ *
+ * Test whether arbitrary node is tls pointer, i.e. Proj(pn_Start_P_tls)
+ * from Start. If so returns tls type, else Null. */
+ir_type *is_tls_pointer(ir_node *n);
+
+/** Test whether arbitrary node is value arg base.
+ *
+ * Test whether arbitrary node is value arg base, i.e. Proj(pn_Start_P_value_arg_base)
+ * from Start. If so returns 1, else 0. */
+int is_value_arg_pointer(ir_node *n);
+
+
+/* @@@ no more supported */
+ir_node **get_Block_cfgpred_arr(ir_node *node);
+int get_Block_n_cfgpreds(const ir_node *node);
+ir_node *get_Block_cfgpred(ir_node *node, int pos);
+void set_Block_cfgpred(ir_node *node, int pos, ir_node *pred);
+/** Get the predecessor block.
+ *
+ * Returns the block corresponding to the predecessor pos of block.
+ *
+ * There are several ambiguities we resolve with this function:
+ * - The direct predecessor can be a Proj, which is not pinned.
+ * We walk from the predecessor to the next pinned node
+ * (skip_Proj) and return the block that node is in.
+ * - If we encounter the Bad node, this function does not return
+ * Start, but the Bad node.
+ */
+ir_node *get_Block_cfgpred_block(ir_node *node, int pos);
+int get_Block_matured(ir_node *node);
+void set_Block_matured(ir_node *node, int matured);
+
+/** A visited flag only for block nodes.
+ * @see also: get_irn_visited() inc_irg_visited() inc_irg_block_visited()*/
+unsigned long get_Block_block_visited(const ir_node *node);
+void set_Block_block_visited(ir_node *node, unsigned long visit);
+
+/**
+ * Marks a block as dead but do not replace it with a Bad node.
+ * Dead blocks are removed in the con
+ */
+ir_node *set_Block_dead(ir_node *block);
+int is_Block_dead(const ir_node *block);
+
+/* For this current_ir_graph must be set. */
+void mark_Block_block_visited(ir_node *node);
+int Block_not_block_visited(const ir_node *node);
+int Block_block_visited(const ir_node *node);
+
+/* Set and remove interprocedural predecessors. If the interprocedural
+ * predecessors are removed, the node has the same predecessors in
+ * both views.
+ * @@@ Maybe better: arity is zero if no cg preds. */
+void set_Block_cg_cfgpred_arr(ir_node *node, int arity, ir_node *in[]);
+void set_Block_cg_cfgpred(ir_node *node, int pos, ir_node *pred);
+/* @@@ not supported */
+ir_node **get_Block_cg_cfgpred_arr(ir_node *node);
+/** Returns the number of interprocedural predecessors. 0 if none. */
+int get_Block_cg_n_cfgpreds(ir_node *node);
+/** Return the interprocedural predecessor at position pos. */
+ir_node *get_Block_cg_cfgpred(ir_node *node, int pos);
+/** Frees the memory allocated for interprocedural predecessors. */
+void remove_Block_cg_cfgpred_arr(ir_node *node);
+
+/** Returns the extended basic block a block belongs to. */
+ir_extblk *get_Block_extbb(const ir_node *block);
+/** Sets the extended basic block a block belongs to. */
+void set_Block_extbb(ir_node *block, ir_extblk *extblk);
+
+/** Get the Macro Block header of a (sub-) block. */
+ir_node *get_Block_MacroBlock(const ir_node *block);
+
+/** Return the number of Keep alive node. */
+int get_End_n_keepalives(ir_node *end);
+
+/** Return the Keep alive node a position pos. */
+ir_node *get_End_keepalive(ir_node *end, int pos);
+
+/** Keep alive dedicated nodes. These must be either PhiM or Block nodes. */
+void add_End_keepalive (ir_node *end, ir_node *ka);
+
+/** Set the Keep alive node at position pos. */
+void set_End_keepalive(ir_node *end, int pos, ir_node *ka);
+
+/** Set new keep-alives */
+void set_End_keepalives(ir_node *end, int n, ir_node *in[]);
+
+/* Set new keep-alives from old keep-alives, skipping irn */
+void remove_End_keepalive(ir_node *end, ir_node *irn);
+
+/** Some parts of the End node are allocated separately -- their memory
+ is not recovered by dead_node_elimination if a End node is dead.
+ free_End() frees these data structures. */
+void free_End(ir_node *end);
+
+/** Return the target address of an IJmp */
+ir_node *get_IJmp_target(ir_node *ijmp);
+
+/** Sets the target address of an IJmp */
+void set_IJmp_target(ir_node *ijmp, ir_node *tgt);
+
+/* We distinguish three kinds of Cond nodes. These can be distinguished
+ by the mode of the selector operand and an internal flag of type cond_kind.
+ First we distinguish binary Conds and switch Conds.
+ A binary Cond has as selector a boolean value. Proj(0) projects the control
+ flow for case "False", Proj(1) the control flow for "True". A binary Cond
+ is recognized by the boolean selector.
+ The switch Cond has as selector an unsigned integer. It produces as result
+ an n+1 Tuple (cf0, ... , cfn) of control flows.
+ We differ two flavors of this Cond. The first, the dense Cond, passes
+ control along output i if the selector value is i, 0 <= i <= n. If the
+ selector value is >n it passes control along output n.
+ The second Cond flavor differences in the treatment of cases not specified in
+ the source program. It magically knows about the existence of Proj nodes.
+ It only passes control along output i, 0 <= i <= n, if a node Proj(Cond, i)
+ exists. Else it passes control along output n (even if this Proj does not
+ exist.) This Cond we call "fragmentary". There is a special constructor
+ new_defaultProj that automatically sets the flavor.
+ The two switch flavors are distinguished by a flag of type cond_kind.
+ Default flavor is "dense"
+*/
+typedef enum {
+ dense, /**< Default. Missing Proj nodes are dead control flow. */
+ fragmentary /**< Special. No control flow optimizations allowed. Missing
+ Proj nodes mean default control flow, i.e., Proj(n). */
+} cond_kind;
+
+ir_node *get_Cond_selector(ir_node *node);
+void set_Cond_selector(ir_node *node, ir_node *selector);
+cond_kind get_Cond_kind(ir_node *node);
+void set_Cond_kind(ir_node *node, cond_kind kind);
+long get_Cond_defaultProj(ir_node *node);
+
+/**
+ * Projection numbers for conditions.
+ */
+typedef enum {
+ pn_Cond_false, /**< Control flow if operand is "false". */
+ pn_Cond_true, /**< Control flow if operand is "true". */
+ pn_Cond_max /**< number of projections from a Cond */
+} pn_Cond; /* Projection numbers for Cond. */
+
+ir_node *get_Return_mem(ir_node *node);
+void set_Return_mem(ir_node *node, ir_node *mem);
+ir_node **get_Return_res_arr(ir_node *node);
+int get_Return_n_ress(ir_node *node);
+ir_node *get_Return_res(ir_node *node, int pos);
+void set_Return_res(ir_node *node, int pos, ir_node *res);
+
+/**
+ * Possible classes for constant classification.
+ */
+typedef enum {
+ CNST_NULL = 0, /**< The node is a const(0). */
+ CNST_ONE = +1, /**< The node is a const(1). */
+ CNST_ALL_ONE = -1, /**< The node is a const(11111...). */
+ CNST_OTHER = 2, /**< The tarval of the const has another value. */
+ CNST_SYMCONST = 3, /**< The node is symconst. */
+ CNST_NO_CONST = 4 /**< The node is no const at all. */
+} cnst_classify_t;
+
+tarval *get_Const_tarval(const ir_node *node);
+void set_Const_tarval(ir_node *node, tarval *con);
+
+/**
+ * Classify a node concerning constant properties.
+ * @param irn A node to check for.
+ * @return Constant properties of that node.
+ */
+cnst_classify_t classify_Const(ir_node *irn);
+
+/** Returns the source language type of a Const node.
+ * Must be an atomic type. Mode of type must be mode of node.
+ */
+ir_type *get_Const_type(ir_node *node);
+
+/** Sets the source language type of a Const node. */
+void set_Const_type(ir_node *node, ir_type *tp);
+
+/** This enum names the three different kinds of symbolic Constants
+ represented by SymConst. The content of the attribute type_or_id
+ depends on this tag. Use the proper access routine after testing
+ this flag. */
+typedef enum {
+ symconst_type_tag, /**< The SymConst is a type tag for the given type.
+ symconst_symbol is type *. */
+ symconst_type_size, /**< The SymConst is the size of the given type.
+ symconst_symbol is type *. */
+ symconst_type_align, /**< The SymConst is the alignment of the given type.
+ symconst_symbol is type *. */
+ symconst_addr_name, /**< The SymConst is a symbolic pointer to be filled in
+ by the linker. The pointer is represented by a string.
+ symconst_symbol is ident *. */
+ symconst_addr_ent, /**< The SymConst is a symbolic pointer to be filled in
+ by the linker. The pointer is represented by an entity.
+ symconst_symbol is entity *. */
+ symconst_ofs_ent, /**< The SymConst is the offset of its entity in the entities
+ owner type. */
+ symconst_enum_const /**< The SymConst is a enumeration constant of an
+ enumeration type. */
+} symconst_kind;
+
+/** Returns non-zero if s symconst kind has a type attribute */
+#define SYMCONST_HAS_TYPE(kind) ((kind) <= symconst_type_align)
+
+/** Returns non-zero if s symconst kind has an ident attribute */
+#define SYMCONST_HAS_ID(kind) ((kind) == symconst_addr_name)
+
+/** Returns non-zero if s symconst kind has an entity attribute */
+#define SYMCONST_HAS_ENT(kind) ((kind) == symconst_addr_ent || (kind) == symconst_ofs_ent)
+
+/** Returns non-zero if s symconst kind has an enum_const attribute */
+#define SYMCONST_HAS_ENUM(kind) ((kind) == symconst_enum_const)
+
+/** SymConst attribute.
+ *
+ * This union contains the symbolic information represented by the node.
+ */
+typedef union symconst_symbol {
+ ir_type *type_p; /**< the type of a symconst */
+ ident *ident_p; /**< the ident of a symconst */
+ ir_entity *entity_p; /**< the entity of a symconst */
+ ir_enum_const *enum_p; /**< the enumeration constant of a symconst */
+} symconst_symbol;
+
+/** Get the kind of the SymConst. */
+symconst_kind get_SymConst_kind(const ir_node *node);
+/** Set the kind of the SymConst. */
+void set_SymConst_kind(ir_node *node, symconst_kind num);
+
+/** Only to access SymConst of kind type_tag or size. Else assertion: */
+ir_type *get_SymConst_type(ir_node *node);
+void set_SymConst_type(ir_node *node, ir_type *tp);
+
+/** Only to access SymConst of kind addr_name. Else assertion: */
+ident *get_SymConst_name(const ir_node *node);
+void set_SymConst_name(ir_node *node, ident *name);
+
+/** Only to access SymConst of kind addr_ent. Else assertion: */
+ir_entity *get_SymConst_entity(const ir_node *node);
+void set_SymConst_entity(ir_node *node, ir_entity *ent);
+
+/** Only to access SymConst of kind symconst_enum_const. Else assertion: */
+ir_enum_const *get_SymConst_enum(const ir_node *node);
+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... */
+union symconst_symbol get_SymConst_symbol(const ir_node *node);
+void set_SymConst_symbol(ir_node *node,
+ union symconst_symbol sym);
+
+/** Access the type of the value represented by the SymConst.
+ *
+ * Example: primitive type int for SymConst size. */
+ir_type *get_SymConst_value_type(ir_node *node);
+void set_SymConst_value_type(ir_node *node, ir_type *tp);
+
+ir_node *get_Sel_mem(ir_node *node);
+void set_Sel_mem(ir_node *node, ir_node *mem);
+ir_node *get_Sel_ptr(ir_node *node); /* ptr to the object to select from */
+void set_Sel_ptr(ir_node *node, ir_node *ptr);
+ir_node **get_Sel_index_arr(ir_node *node);
+int get_Sel_n_indexs(ir_node *node);
+ir_node *get_Sel_index(ir_node *node, int pos);
+void set_Sel_index(ir_node *node, int pos, ir_node *index);
+ir_entity *get_Sel_entity(ir_node *node); /* entity to select */
+void set_Sel_entity (ir_node *node, ir_entity *ent);
+
+/**
+ * Projection numbers for result of Call node: use for Proj nodes!
+ */
+typedef enum {
+ pn_Call_M_regular = 0, /**< The memory result. */
+ pn_Call_X_regular = 1, /**< The control flow result when no exception occurs. */
+ pn_Call_X_except = 2, /**< The control flow result branching to the exception handler. */
+ pn_Call_T_result = 3, /**< The tuple containing all (0, 1, 2, ...) results. */
+ pn_Call_M_except = 4, /**< The memory result in case the called method terminated with
+ an exception. */
+ pn_Call_P_value_res_base = 5,/**< A pointer to the memory region containing copied results
+ passed by value (for compound result types). */
+ pn_Call_max = 6 /**< number of projections from a Call */
+} pn_Call; /* Projection numbers for Call. */
+#define pn_Call_M pn_Call_M_regular
+
+ir_node *get_Call_mem(ir_node *node);
+void set_Call_mem(ir_node *node, ir_node *mem);
+ir_node *get_Call_ptr(ir_node *node);
+void set_Call_ptr(ir_node *node, ir_node *ptr);
+ir_node **get_Call_param_arr(ir_node *node);
+/** Gets the number of parameters of a call. */
+int get_Call_n_params(ir_node *node);
+/** Gets the call parameter at position pos. */
+ir_node *get_Call_param(ir_node *node, int pos);
+/** Sets the call parameter at position pos. */
+void set_Call_param(ir_node *node, int pos, ir_node *param);
+/** Gets the type of a call. */
+ir_type *get_Call_type(ir_node *node);
+/** Sets the type of a call. */
+void set_Call_type(ir_node *node, ir_type *tp);
+/** Gets the arity of a call. Identical to get_Call_n_params(). */
+int get_Call_arity(ir_node *node);
+
+/** Set, get and remove the callee information for a Call node.
+ *
+ * The callee information lists all method entities that can be called
+ * from this node. If the address expression can not be analyzed fully,
+ * e.g., as entities can be called that are not in the compilation unit,
+ * the array contains the unknown_entity. The array contains only entities
+ * with peculiarity_existent, but with all kinds of visibility. The entities
+ * not necessarily contain an irg.
+ *
+ * The array is only accessible if callee information is valid. See flag
+ * in graph.
+ *
+ * The memory allocated for the array is managed automatically, i.e., it must
+ * not be freed if the Call node is removed from the graph.
+ *
+ * @param node A Call node.
+ */
+int Call_has_callees(ir_node *node);
+int get_Call_n_callees(ir_node *node);
+ir_entity *get_Call_callee(ir_node *node, int pos);
+
+/** Set the full callee array.
+ *
+ * The passed array is copied. Assumes current_ir_graph set properly! */
+void set_Call_callee_arr(ir_node *node, const int n, ir_entity **arr);
+void remove_Call_callee_arr(ir_node *node);
+
+ir_node *get_CallBegin_ptr(ir_node *node);
+void set_CallBegin_ptr(ir_node *node, ir_node *ptr);
+ir_node *get_CallBegin_call(ir_node *node);
+void set_CallBegin_call(ir_node *node, ir_node *call);
+
+/* 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, Quot, DivMod, Div, Mod, And, Or, Eor, Shl,
+ Shr, Shrs, Rot, Cmp */
+int is_unop(const ir_node *node);
+ir_node *get_unop_op(const ir_node *node);
+void set_unop_op(ir_node *node, ir_node *op);
+int is_binop(const ir_node *node);
+ir_node *get_binop_left(const ir_node *node);
+void set_binop_left(ir_node *node, ir_node *left);
+ir_node *get_binop_right(const ir_node *node);
+void set_binop_right(ir_node *node, ir_node *right);
+
+ir_node *get_Add_left(const ir_node *node);
+void set_Add_left(ir_node *node, ir_node *left);
+ir_node *get_Add_right(const ir_node *node);
+void set_Add_right(ir_node *node, ir_node *right);
+
+ir_node *get_Sub_left(const ir_node *node);
+void set_Sub_left(ir_node *node, ir_node *left);
+ir_node *get_Sub_right(const ir_node *node);
+void set_Sub_right(ir_node *node, ir_node *right);
+
+ir_node *get_Minus_op(const ir_node *node);
+void set_Minus_op(ir_node *node, ir_node *op);
+
+ir_node *get_Mul_left(const ir_node *node);
+void set_Mul_left(ir_node *node, ir_node *left);
+ir_node *get_Mul_right(const ir_node *node);
+void set_Mul_right(ir_node *node, ir_node *right);
+
+ir_node *get_Quot_left(const ir_node *node);
+void set_Quot_left(ir_node *node, ir_node *left);
+ir_node *get_Quot_right(const ir_node *node);
+void set_Quot_right(ir_node *node, ir_node *right);
+ir_node *get_Quot_mem(ir_node *node);
+void set_Quot_mem(ir_node *node, ir_node *mem);
+ir_mode *get_Quot_resmode(const ir_node *node);
+void set_Quot_resmode(ir_node *node, ir_mode *mode);
+
+/**
+ * Projection numbers for Quot: use for Proj nodes!
+ */
+typedef enum {
+ pn_Quot_M, /**< Memory result. */
+ pn_Quot_X_regular, /**< Execution result if no exception occurred. */
+ pn_Quot_X_except, /**< Execution result if exception occurred. */
+ pn_Quot_res, /**< Result of computation. */
+ pn_Quot_max /**< number of projections from a Quot */
+} pn_Quot; /* Projection numbers for Quot. */
+
+ir_node *get_DivMod_left(const ir_node *node);
+void set_DivMod_left(ir_node *node, ir_node *left);
+ir_node *get_DivMod_right(const ir_node *node);
+void set_DivMod_right(ir_node *node, ir_node *right);
+ir_node *get_DivMod_mem(ir_node *node);
+void set_DivMod_mem(ir_node *node, ir_node *mem);
+ir_mode *get_DivMod_resmode(const ir_node *node);
+void set_DivMod_resmode(ir_node *node, ir_mode *mode);
+
+/**
+ * Projection numbers for DivMod: use for Proj nodes!
+ */
+typedef enum {
+ pn_DivMod_M, /**< Memory result. */
+ pn_DivMod_X_regular, /**< Execution result if no exception occurred. */
+ pn_DivMod_X_except, /**< Execution result if exception occurred. */
+ pn_DivMod_res_div, /**< Result of computation a / b. */
+ pn_DivMod_res_mod, /**< Result of computation a % b. */
+ pn_DivMod_max /**< number of projections from a DivMod */
+} pn_DivMod; /* Projection numbers for DivMod. */
+
+ir_node *get_Div_left(const ir_node *node);
+void set_Div_left(ir_node *node, ir_node *left);
+ir_node *get_Div_right(const ir_node *node);
+void set_Div_right(ir_node *node, ir_node *right);
+ir_node *get_Div_mem(ir_node *node);
+void set_Div_mem(ir_node *node, ir_node *mem);
+ir_mode *get_Div_resmode(const ir_node *node);
+void set_Div_resmode(ir_node *node, ir_mode *mode);
+
+/**
+ * Projection numbers for Div: use for Proj nodes!
+ */
+typedef enum {
+ pn_Div_M, /**< Memory result. */
+ pn_Div_X_regular, /**< Execution result if no exception occurred. */
+ pn_Div_X_except, /**< Execution result if exception occurred. */
+ pn_Div_res, /**< Result of computation. */
+ pn_Div_max /**< number of projections from a Div */
+} pn_Div; /* Projection numbers for Div. */
+
+ir_node *get_Mod_left(const ir_node *node);
+void set_Mod_left(ir_node *node, ir_node *left);
+ir_node *get_Mod_right(const ir_node *node);
+void set_Mod_right(ir_node *node, ir_node *right);
+ir_node *get_Mod_mem(ir_node *node);
+void set_Mod_mem(ir_node *node, ir_node *mem);
+ir_mode *get_Mod_resmode(const ir_node *node);
+void set_Mod_resmode(ir_node *node, ir_mode *mode);
+
+/**
+ * Projection numbers for Mod: use for Proj nodes!
+ */
+typedef enum {
+ pn_Mod_M, /**< Memory result. */
+ pn_Mod_X_regular, /**< Execution result if no exception occurred. */
+ pn_Mod_X_except, /**< Execution result if exception occurred. */
+ pn_Mod_res, /**< Result of computation. */
+ pn_Mod_max /**< number of projections from a Mod */
+} pn_Mod; /* Projection numbers for Mod. */
+
+ir_node *get_Abs_op(const ir_node *node);
+void set_Abs_op(ir_node *node, ir_node *op);
+
+ir_node *get_And_left(const ir_node *node);
+void set_And_left(ir_node *node, ir_node *left);
+ir_node *get_And_right(const ir_node *node);
+void set_And_right(ir_node *node, ir_node *right);
+
+ir_node *get_Or_left(const ir_node *node);
+void set_Or_left(ir_node *node, ir_node *left);
+ir_node *get_Or_right(const ir_node *node);
+void set_Or_right(ir_node *node, ir_node *right);
+
+ir_node *get_Eor_left(const ir_node *node);
+void set_Eor_left(ir_node *node, ir_node *left);
+ir_node *get_Eor_right(const ir_node *node);
+void set_Eor_right(ir_node *node, ir_node *right);
+
+ir_node *get_Not_op(const ir_node *node);
+void set_Not_op(ir_node *node, ir_node *op);
+
+/**
+ * Projection numbers for Cmp are defined several times.
+ * The bit patterns are used for various tests, so don't change.
+ * The "unordered" values are possible results of comparing
+ * floating point numbers.
+ * Note that the encoding is imported, so do NOT change the order.
+ */
+typedef enum {
+ pn_Cmp_False = 0, /**< false */
+ pn_Cmp_Eq = 1, /**< equal */
+ pn_Cmp_Lt = 2, /**< less */
+ pn_Cmp_Le = pn_Cmp_Eq|pn_Cmp_Lt, /**< less or equal */
+ pn_Cmp_Gt = 4, /**< greater */
+ pn_Cmp_Ge = pn_Cmp_Eq|pn_Cmp_Gt, /**< greater or equal */
+ pn_Cmp_Lg = pn_Cmp_Lt|pn_Cmp_Gt, /**< less or greater */
+ pn_Cmp_Leg = pn_Cmp_Lt|pn_Cmp_Eq|pn_Cmp_Gt, /**< less, equal or greater = ordered */
+ pn_Cmp_Uo = 8, /**< unordered */
+ pn_Cmp_Ue = pn_Cmp_Uo|pn_Cmp_Eq, /**< unordered or equal */
+ pn_Cmp_Ul = pn_Cmp_Uo|pn_Cmp_Lt, /**< unordered or less */
+ pn_Cmp_Ule = pn_Cmp_Uo|pn_Cmp_Eq|pn_Cmp_Lt, /**< unordered, less or equal */
+ pn_Cmp_Ug = pn_Cmp_Uo|pn_Cmp_Gt, /**< unordered or greater */
+ pn_Cmp_Uge = pn_Cmp_Uo|pn_Cmp_Eq|pn_Cmp_Gt, /**< unordered, greater or equal */
+ pn_Cmp_Ne = pn_Cmp_Uo|pn_Cmp_Lt|pn_Cmp_Gt, /**< unordered, less or greater = not equal */
+ pn_Cmp_True = 15 /**< true */
+ /* not_mask = Leg*/ /* bits to flip to negate comparison * @@ hack for JNI interface */
+} pn_Cmp; /* Projection numbers for Cmp */
+/* #define not_mask pn_Cmp_Leg */
+
+/** returns the pnc name from an pnc constant */
+const char *get_pnc_string(int pnc);
+
+/** Calculates the negated (Complement(R)) pnc condition. */
+int get_negated_pnc(int pnc, ir_mode *mode);
+
+/** Calculates the inversed (R^-1) pnc condition, i.e., "<" --> ">" */
+int get_inversed_pnc(int pnc);
+
+ir_node *get_Cmp_left(const ir_node *node);
+void set_Cmp_left(ir_node *node, ir_node *left);
+ir_node *get_Cmp_right(const ir_node *node);
+void set_Cmp_right(ir_node *node, ir_node *right);
+
+ir_node *get_Shl_left(const ir_node *node);
+void set_Shl_left(ir_node *node, ir_node *left);
+ir_node *get_Shl_right(const ir_node *node);
+void set_Shl_right(ir_node *node, ir_node *right);
+
+ir_node *get_Shr_left(const ir_node *node);
+void set_Shr_left(ir_node *node, ir_node *left);
+ir_node *get_Shr_right(const ir_node *node);
+void set_Shr_right(ir_node *node, ir_node *right);
+
+ir_node *get_Shrs_left(const ir_node *node);
+void set_Shrs_left(ir_node *node, ir_node *left);
+ir_node *get_Shrs_right(const ir_node *node);
+void set_Shrs_right(ir_node *node, ir_node *right);
+
+ir_node *get_Rot_left(const ir_node *node);
+void set_Rot_left(ir_node *node, ir_node *left);
+ir_node *get_Rot_right(const ir_node *node);
+void set_Rot_right(ir_node *node, ir_node *right);
+
+ir_node *get_Conv_op(const ir_node *node);
+void set_Conv_op(ir_node *node, ir_node *op);
+int get_Conv_strict(ir_node *node);
+void set_Conv_strict(ir_node *node, int flag);
+
+/* Does Cast need a mem operator?
+ * Cast should only depend on the type, not on the state of an
+ * entity. But: we initialize various fields after Alloc, that
+ * are accessed in the cast. This required some precaution, to
+ * get the right memory into the Loads generated from the cast.
+ */
+ir_node *get_Cast_op(const ir_node *node);
+void set_Cast_op(ir_node *node, ir_node *op);
+ir_type *get_Cast_type(ir_node *node);
+void set_Cast_type(ir_node *node, ir_type *to_tp);
+
+/** Checks for upcast.
+ *
+ * Returns true if the Cast node casts a class type to a super type.
+ * Works also for pointers to classes (recursively).
+ *
+ * Needs typeinfo calculated.
+ */
+int is_Cast_upcast(ir_node *node);
+
+/** Checks for downcast.
+ *
+ * Returns true if the Cast node casts a class type to a sub type.
+ * Works also for pointers to classes (recursively).
+ *
+ * Needs typeinfo calculated.
+ */
+int is_Cast_downcast(ir_node *node);
+
+
+/** Returns true if n is Phi or Filter in interprocedural_view.
+ Returns false if irg in phase building and the Phi has zero
+ predecessors: it's a Phi0. */
+int is_Phi(const ir_node *n);
+/** Returns true if irg in phase building and the Phi has zero
+ predecessors: it's a Phi0. */
+int is_Phi0(const ir_node *n);
+/* These routines also work for Filter nodes in interprocedural view. */
+ir_node **get_Phi_preds_arr(ir_node *node);
+int get_Phi_n_preds(const ir_node *node);
+ir_node *get_Phi_pred(const ir_node *node, int pos);
+void set_Phi_pred(ir_node *node, int pos, ir_node *pred);
+
+ir_node *get_Filter_pred(ir_node *node);
+void set_Filter_pred(ir_node *node, ir_node *pred);
+long get_Filter_proj(ir_node *node);
+void set_Filter_proj(ir_node *node, long proj);
+/* set the interprocedural predecessors, ...d_arr uses current_ir_graph.
+ * @@@ Maybe better: arity is zero if no cg preds. */
+void set_Filter_cg_pred_arr(ir_node * node, int arity, ir_node ** in);
+void set_Filter_cg_pred(ir_node * node, int pos, ir_node * pred);
+int get_Filter_n_cg_preds(ir_node *node);
+ir_node *get_Filter_cg_pred(ir_node *node, int pos);
+
+/** Return true if parameter is a memory operation.
+ *
+ * A memory operation is an operation that changes the
+ * memory. I.e., a Load or a Store operation.
+ */
+int is_memop(ir_node *node);
+ir_node *get_memop_mem(ir_node *node);
+void set_memop_mem(ir_node *node, ir_node *mem);
+ir_node *get_memop_ptr(ir_node *node);
+void set_memop_ptr(ir_node *node, ir_node *ptr);
+
+/**
+ * Projection numbers for Load: use for Proj nodes!
+ */
+typedef enum {
+ pn_Load_M, /**< Memory result. */
+ pn_Load_X_regular, /**< Execution result if no exception occurred. */
+ pn_Load_X_except, /**< Execution result if exception occurred. */
+ pn_Load_res, /**< Result of load operation. */
+ pn_Load_max /**< number of projections from a Load */
+} pn_Load; /* Projection numbers for Load. */
+
+ir_node *get_Load_mem(ir_node *node);
+void set_Load_mem(ir_node *node, ir_node *mem);
+ir_node *get_Load_ptr(ir_node *node);
+void set_Load_ptr(ir_node *node, ir_node *ptr);
+ir_mode *get_Load_mode(ir_node *node);
+void set_Load_mode(ir_node *node, ir_mode *mode);
+ir_volatility get_Load_volatility(ir_node *node);
+void set_Load_volatility(ir_node *node, ir_volatility volatility);
+
+/**
+ * Projection numbers for Store: use for Proj nodes!
+ */
+typedef enum {
+ pn_Store_M, /**< Memory result. */
+ pn_Store_X_regular, /**< Execution result if no exception occurred. */
+ pn_Store_X_except, /**< Execution result if exception occurred. */
+ pn_Store_max /**< number of projections from a Store */
+} pn_Store; /* Projection numbers for Store. */
+
+ir_node *get_Store_mem(ir_node *node);
+void set_Store_mem(ir_node *node, ir_node *mem);
+ir_node *get_Store_ptr(ir_node *node);
+void set_Store_ptr(ir_node *node, ir_node *ptr);
+ir_node *get_Store_value(ir_node *node);
+void set_Store_value(ir_node *node, ir_node *value);
+ir_volatility get_Store_volatility(ir_node *node);
+void set_Store_volatility(ir_node *node, ir_volatility volatility);
+
+/**
+ * Projection numbers for Alloc: use for Proj nodes!
+ */
+typedef enum {
+ pn_Alloc_M, /**< Memory result. */
+ pn_Alloc_X_regular, /**< Execution result if no exception occurred. */
+ pn_Alloc_X_except, /**< Execution result if exception occurred. */
+ pn_Alloc_res, /**< Result of allocation. */
+ pn_Alloc_max /**< number of projections from an Alloc */
+} pn_Alloc; /* Projection numbers for Alloc. */
+
+ir_node *get_Alloc_mem(ir_node *node);
+void set_Alloc_mem(ir_node *node, ir_node *mem);
+ir_node *get_Alloc_size(ir_node *node);
+void set_Alloc_size(ir_node *node, ir_node *size);
+ir_type *get_Alloc_type(ir_node *node);
+void set_Alloc_type(ir_node *node, ir_type *tp);
+
+/** The allocation place. */
+typedef enum {
+ stack_alloc, /**< Alloc allocates the object on the stack. */
+ heap_alloc /**< Alloc allocates the object on the heap. */
+} where_alloc;
+
+where_alloc get_Alloc_where(ir_node *node);
+void set_Alloc_where(ir_node *node, where_alloc where);
+
+ir_node *get_Free_mem(ir_node *node);
+void set_Free_mem(ir_node *node, ir_node *mem);
+ir_node *get_Free_ptr(ir_node *node);
+void set_Free_ptr(ir_node *node, ir_node *ptr);
+ir_node *get_Free_size(ir_node *node);
+void set_Free_size(ir_node *node, ir_node *size);
+ir_type *get_Free_type(ir_node *node);
+void set_Free_type(ir_node *node, ir_type *tp);
+
+where_alloc get_Free_where(ir_node *node);
+void set_Free_where(ir_node *node, where_alloc where);
+
+ir_node **get_Sync_preds_arr(ir_node *node);
+int get_Sync_n_preds(ir_node *node);
+ir_node *get_Sync_pred(ir_node *node, int pos);
+void set_Sync_pred(ir_node *node, int pos, ir_node *pred);
+void add_Sync_pred(ir_node *node, ir_node *pred);
+
+/** Returns the source language type of a Proj node.
+ * Must be an atomic type. Mode of type must be mode of node.
+ */
+ir_type *get_Proj_type(ir_node *node);
+
+/** Return the predecessor of a Proj node. */
+ir_node *get_Proj_pred(const ir_node *node);
+void set_Proj_pred(ir_node *node, ir_node *pred);
+/** Return the projection number of a Proj node. */
+long get_Proj_proj(const ir_node *node);
+void set_Proj_proj(ir_node *node, long proj);
+long get_VProj_proj(const ir_node *node);
+void set_VProj_proj(ir_node *node, long value);
+
+
+ir_node **get_Tuple_preds_arr(ir_node *node);
+int get_Tuple_n_preds(ir_node *node);
+ir_node *get_Tuple_pred(ir_node *node, int pos);
+void set_Tuple_pred(ir_node *node, int pos, ir_node *pred);
+
+ir_node *get_Id_pred(ir_node *node);
+void set_Id_pred(ir_node *node, ir_node *pred);
+
+/** Confirm has a single result and returns 'value' unchanged.
+ * The node expresses a restriction on 'value':
+ * 'value' 'cmp' 'bound' == true. */
+ir_node *get_Confirm_value(ir_node *node);
+void set_Confirm_value(ir_node *node, ir_node *value);
+ir_node *get_Confirm_bound(ir_node *node);
+void set_Confirm_bound(ir_node *node, ir_node *bound);
+pn_Cmp get_Confirm_cmp(ir_node *node);
+void set_Confirm_cmp(ir_node *node, pn_Cmp cmp);
+
+/*
+ * Mux Support: Note that Psi nodes with one condition can be handled
+ * like Mux nodes, and the access functions work as expected.
+ */
+ir_node *get_Mux_sel(ir_node *node);
+void set_Mux_sel(ir_node *node, ir_node *sel);
+ir_node *get_Mux_false(ir_node *node);
+void set_Mux_false(ir_node *node, ir_node *ir_false);
+ir_node *get_Mux_true (ir_node *node);
+void set_Mux_true (ir_node *node, ir_node *ir_true);
+
+ir_node *get_Psi_cond(ir_node *node, int pos);
+void set_Psi_cond(ir_node *node, int pos, ir_node *cond);
+ir_node *get_Psi_val(ir_node *node, int pos);
+void set_Psi_val(ir_node *node, int pos, ir_node *val);
+ir_node *get_Psi_default(ir_node *node);
+void set_Psi_default(ir_node *node, ir_node *val);
+int get_Psi_n_conds(ir_node *node);
+
+/**
+ * Projection numbers for result of CopyB node: use for Proj nodes!
+ */
+typedef enum {
+ pn_CopyB_M_regular = 0, /**< The memory result. */
+ pn_CopyB_X_regular = 1, /**< Execution result if no exception occurred. */
+ pn_CopyB_X_except = 2, /**< The control flow result branching to the exception handler */
+ pn_CopyB_M_except = 3, /**< The memory result in case the runtime function terminated with
+ an exception */
+ pn_CopyB_max = 4 /**< number of projections from a CopyB */
+} pn_CopyB; /* Projection numbers for CopyB. */
+#define pn_CopyB_M pn_CopyB_M_regular
+
+ir_node *get_CopyB_mem(ir_node *node);
+void set_CopyB_mem(ir_node *node, ir_node *mem);
+ir_node *get_CopyB_dst(ir_node *node);
+void set_CopyB_dst(ir_node *node, ir_node *dst);
+ir_node *get_CopyB_src(ir_node *node);
+void set_CopyB_src(ir_node *node, ir_node *src);
+ir_type *get_CopyB_type(ir_node *node);
+void set_CopyB_type(ir_node *node, ir_type *data_type);
+
+/**
+ * Projection numbers for result of InstOf node: use for Proj nodes!
+ */
+typedef enum {
+ pn_InstOf_M_regular = 0, /**< The memory result. */
+ pn_InstOf_X_regular = 1, /**< Execution result if no exception occurred. */
+ pn_InstOf_X_except = 2, /**< The control flow result branching to the exception handler */
+ pn_InstOf_res = 3, /**< The checked object pointer. */
+ pn_InstOf_M_except = 4, /**< The memory result in case the runtime function terminated with
+ an exception */
+ pn_InstOf_max = 5 /**< number of projections from an InstOf */
+} pn_InstOf;
+#define pn_InstOf_M pn_InstOf_M_regular
+
+/** InstOf access */
+ir_type *get_InstOf_type(ir_node *node);
+void set_InstOf_type(ir_node *node, ir_type *type);
+ir_node *get_InstOf_store(ir_node *node);
+void set_InstOf_store(ir_node *node, ir_node *obj);
+ir_node *get_InstOf_obj(ir_node *node);
+void set_InstOf_obj(ir_node *node, ir_node *obj);
+
+/**
+ * Projection numbers for Raise.
+ */
+typedef enum {
+ pn_Raise_X = 0, /**< The control flow to the exception handler. */
+ pn_Raise_M = 1, /**< The Memory result. */
+ pn_Raise_max /**< number of projections from a Raise */
+} pn_Raise; /* Projection numbers for Raise. */
+
+ir_node *get_Raise_mem(ir_node *node);
+void set_Raise_mem(ir_node *node, ir_node *mem);
+ir_node *get_Raise_exo_ptr(ir_node *node); /* PoinTeR to EXception Object */
+void set_Raise_exo_ptr(ir_node *node, ir_node *exoptr);
+
+/**
+ * Projection numbers for result of Bound node: use for Proj nodes!
+ */
+typedef enum {
+ pn_Bound_M = 0, /**< The memory result. */
+ pn_Bound_X_regular = 1, /**< Execution result if no exception occurred. */
+ pn_Bound_X_except = 2, /**< The control flow result branching to the exception handler */
+ pn_Bound_res = 3, /**< The checked index. */
+ pn_Bound_max = 4 /**< number of projections from a Bound */
+} pn_Bound;
+
+/** Returns the memory input of a Bound operation. */
+ir_node *get_Bound_mem(ir_node *bound);
+void set_Bound_mem(ir_node *bound, ir_node *mem);
+
+/** Returns the index input of a Bound operation. */
+ir_node *get_Bound_index(ir_node *bound);
+void set_Bound_index(ir_node *bound, ir_node *idx);
+
+/** Returns the lower bound input of a Bound operation. */
+ir_node *get_Bound_lower(ir_node *bound);
+void set_Bound_lower(ir_node *bound, ir_node *lower);
+
+/** Returns the upper bound input of a Bound operation. */
+ir_node *get_Bound_upper(ir_node *bound);
+void set_Bound_upper(ir_node *bound, ir_node *upper);
+
+/** Return the operand of a Pin node. */
+ir_node *get_Pin_op(const ir_node *pin);
+void set_Pin_op(ir_node *pin, ir_node *node);
+
+/** A input/output constraint attribute */
+typedef struct {
+ unsigned pos; /**< The inputs/output position for this constraint. */
+ ident *constraint; /**< The constraint for this input/output. */
+} ir_asm_constraint;
+
+/** Return the assembler text of an ASM pseudo node. */
+const char *get_ASM_text(const ir_node *node);
+/** Return the number of input constraints for an ASM node. */
+int get_ASM_n_input_constraints(const ir_node *node);
+/** Return the input constraints for an ASM node. */
+const ir_asm_constraint *get_ASM_input_constraints(const ir_node *node);
+/** Return the number of output constraints for an ASM node. */
+int get_ASM_n_output_constraints(const ir_node *node);
+/** Return the output constraints for an ASM node. */
+const ir_asm_constraint *get_ASM_output_constraints(const ir_node *node);
+/** Return the number of clobbered registers for an ASM node. */
+int get_ASM_n_clobbers(const ir_node *node);
+/** Return the list of clobbered registers for an ASM node. */
+ident **get_ASM_clobbers(const ir_node *node);
+
+/*
+ *
+ * NAME Auxiliary routines
+ *
+ */
+
+/** Returns operand of node if node is a Proj. */
+ir_node *skip_Proj(ir_node *node);
+/** Returns operand of node if node is a Proj. */
+const ir_node *skip_Proj_const(const ir_node *node);
+/** Returns operand of node if node is a Id. */
+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. */
+ir_node *skip_Tuple(ir_node *node);
+/** returns operand of node if node is a Cast. */
+ir_node *skip_Cast(ir_node *node);
+/** Returns operand of node if node is a Confirm */
+ir_node *skip_Confirm(ir_node *node);
+/** Skip all high-level Operations. */
+ir_node *skip_HighLevel(ir_node *node);
+/** Returns true if irn is a Const node. */
+int is_Const(const ir_node *node);
+/** Returns true if a node is a Conv node. */
+int is_Conv(const ir_node *node);
+/** Returns true if node is a Bad node. */
+int is_Bad(const ir_node *node);
+/** Returns true if node is a NoMem node. */
+int is_NoMem(const ir_node *node);
+/** Returns true if node is a Start node. */
+int is_Start(const ir_node *node);
+/** Returns true if node is a Mod node. */
+int is_Mod(const ir_node *node);
+/** Returns true if node is a Div node. */
+int is_Div(const ir_node *node);
+/** Returns true if node is a DivMod node. */
+int is_DivMod(const ir_node *node);
+/** Returns true if node is a Quot node. */
+int is_Quot(const ir_node *node);
+/** Returns true if node is an Add node. */
+int is_Add(const ir_node *node);
+/** Returns true if node is a Sub node. */
+int is_Sub(const ir_node *node);
+/** Returns true if the node is not a Block */
+int is_no_Block(const ir_node *node);
+/** Returns true if the node is a Block */
+int is_Block(const ir_node *node);
+/** Returns true if node is an Unknown node. */
+int is_Unknown(const ir_node *node);
+/** Returns true if node is a Return node. */
+int is_Return(const ir_node *node);
+/** Returns true if node is a Call node. */
+int is_Call(const ir_node *node);
+/** Returns true if node is a Sel node. */
+int is_Sel(const ir_node *node);
+/** Returns true if node is a Mul node. */
+int is_Mul(const ir_node *node);
+/** Returns true if node is a Mux node or a Psi with only one condition. */
+int is_Mux(const ir_node *node);
+/** Returns true if node is a Load node. */
+int is_Load(const ir_node *node);
+/** Returns true if node is a Store node. */
+int is_Store(const ir_node *node);
+/** Returns true if node is a Sync node. */
+int is_Sync(const ir_node *node);
+/** Returns true if node is a Confirm node. */
+int is_Confirm(const ir_node *node);
+/** Returns true if node is a Pin node. */
+int is_Pin(const ir_node *node);
+/** Returns true if node is a SymConst node. */
+int is_SymConst(const ir_node *node);
+/** Returns true if node is a Cond node. */
+int is_Cond(const ir_node *node);
+/** Returns true of node is a CopyB node */
+int is_CopyB(const ir_node *node);
+/** Returns true if node is a Cmp node. */
+int is_Cmp(const ir_node *node);
+/** Returns true if node is an Alloc node */
+int is_Alloc(const ir_node *node);
+/** Returns true if a node is a Jmp node */
+int is_Jmp(const ir_node *node);
+/** Returns true if a node is a Raise node */
+int is_Raise(const ir_node *node);
+/** Returns true if a node is an ASM node */
+int is_ASM(const ir_node *node);
+/** Returns true if node is a Proj node or a Filter node in
+ * intraprocedural view */
+int is_Proj(const ir_node *node);
+/** Returns true if the operation manipulates control flow:
+ Start, End, Jmp, Cond, Return, Raise, Bad, CallBegin, EndReg, EndExcept */
+int is_cfop(const ir_node *node);
+
+/** Returns true if the operation manipulates interprocedural control flow:
+ CallBegin, EndReg, EndExcept */
+int is_ip_cfop(const ir_node *node);
+/** Returns true if the operation can change the control flow because
+ of an exception: Call, Quot, DivMod, Div, Mod, Load, Store, Alloc,
+ Bad. Raise is not fragile, but a unconditional jump. */
+int is_fragile_op(const ir_node *node);
+/** Returns the memory operand of fragile operations. */
+ir_node *get_fragile_op_mem(ir_node *node);
+/** Returns the result mode of a Div operation. */
+ir_mode *get_divop_resmod(const ir_node *node);
+
+/** Returns true if the operation is a forking control flow
+ * operation: Cond. */
+int is_irn_forking(const ir_node *node);
+
+/** Return the type associated with the value produced by n
+ * if the node remarks this type as it is the case for
+ * Cast, Const, SymConst and some Proj nodes or unknown_type. */
+ir_type *get_irn_type(ir_node *n);
+
+/** Return the type attribute of a node n (SymConst, Call, Alloc, Free,
+ Cast) or NULL.*/
+ir_type *get_irn_type_attr(ir_node *n);
+
+/** Return the entity attribute of a node n (SymConst, Sel) or NULL. */
+ir_entity *get_irn_entity_attr(ir_node *n);
+
+/** Returns non-zero for constant-like nodes. */
+int is_irn_constlike(const ir_node *node);
+
+/**
+ * Returns non-zero for nodes that must be always optimized
+ * (Phi, Id. Proj, Cond, Block, Confirm ...).
+ */
+int is_irn_always_opt(const ir_node *node);
+
+/**
+ * Returns non-zero for nodes that are allowed to have keep-alives and
+ * are neither Block nor PhiM.
+ */
+int is_irn_keep(const ir_node *node);
+
+/**
+ * Returns non-zero for nodes that are always placed in the start block.
+ */
+int is_irn_start_block_placed(const ir_node *node);
+
+/**
+ * Returns non-zero for nodes that are machine operations.
+ */
+int is_irn_machine_op(const ir_node *node);
+
+/**
+ * Returns non-zero for nodes that are machine operands.
+ */
+int is_irn_machine_operand(const ir_node *node);
+
+/**
+ * Returns non-zero for nodes that have the n'th user machine flag set.
+ */
+int is_irn_machine_user(const ir_node *node, unsigned n);
+
+/**
+ * A type to express conditional jump predictions.
+ */
+typedef enum {
+ COND_JMP_PRED_NONE, /**< No jump prediction. Default. */
+ COND_JMP_PRED_TRUE, /**< The True case is predicted. */
+ COND_JMP_PRED_FALSE /**< The False case is predicted. */
+} cond_jmp_predicate;
+
+/** Gets the string representation of the jump prediction .*/
+const char *get_cond_jmp_predicate_name(cond_jmp_predicate pred);
+
+/** Returns the conditional jump prediction of a Cond node. */
+cond_jmp_predicate get_Cond_jmp_pred(const ir_node *cond);
+
+/** Sets a new conditional jump prediction. */
+void set_Cond_jmp_pred(ir_node *cond, cond_jmp_predicate pred);
+
+/**
+ * Access custom node data.
+ * The data must have been registered with
+ * register_additional_node_data() before.
+ * @param node The ir node to get the data from.
+ * @param type The type of the data you registered.
+ * @param off The value returned by register_additional_node_data().
+ * @return A pointer of type @p type.
+ */
+#define get_irn_data(node,type,off) \
+ (assert(off > 0 && "Invalid node data offset"), (type *) ((char *) (node) - (off)))
+
+/**
+ * Get the pointer to the node some custom data belongs to.
+ * @param data The pointer to the custom data.
+ * @param off The number as returned by register_additional_node_data().
+ * @return A pointer to the ir node the custom data belongs to.
+ */
+#define get_irn_data_base(data,off) \
+ (assert(off > 0 && "Invalid node data offset"), (ir_node *) ((char *) (data) + (off)))
+
+/**
+ * Request additional data to be allocated with an ir node.
+ * @param size The size of the additional data required.
+ * @return A positive number, if the operation was successful, which
+ * must be passed to the access macro get_irn_data(), 0 if the
+ * registration failed.
+ */
+unsigned register_additional_node_data(unsigned size);
+
+/**
+ * Return a pointer to the node attributes.
+ * Needed for user-defined nodes.
+ */
+void *get_irn_generic_attr(ir_node *node);
+const void *get_irn_generic_attr_const(const ir_node *node);
+
+/**
+ * Returns the unique node index for the node in its graph.
+ * This index is used to access phase information for this node.
+ */
+unsigned get_irn_idx(const ir_node *node);
+
+/*-----------------------------------------------------------------*/
+/** Debug aides **/
+/*-----------------------------------------------------------------*/
+
+
+/** Debug print the node.
+ *
+ * Writes the node, all its attributes and the predecessors to stdout if DEBUG_libfirm
+ * is set. Else does nothing. */
+void dump_irn(ir_node *n);
+
+/*@}*/ /* end of ir_node group definition */
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Representation of opcode of intermediate operation.
+ * @author Christian Schaefer, Goetz Lindenmaier, Michael Beck
+ * @version $Id$
+ * @summary
+ * Operators of firm nodes.
+ *
+ * This module specifies the opcodes possible for ir nodes. Their
+ * definition is close to the operations specified in UKA Tech-Report
+ * 1999-14
+ */
+#ifndef FIRM_IR_IROP_H
+#define FIRM_IR_IROP_H
+
+#include "firm_types.h"
+
+#include <stdio.h>
+#include "ident.h"
+
+/** The allowed parities */
+typedef enum {
+ oparity_invalid = 0,
+ oparity_unary, /**< an unary operator -- considering 'numeric' arguments. */
+ oparity_binary, /**< an binary operator -- considering 'numeric' arguments.*/
+ oparity_trinary, /**< an trinary operator -- considering 'numeric' arguments.*/
+ oparity_zero, /**< no operators, as e.g. Const. */
+ oparity_variable, /**< arity not fixed by opcode, but statically
+ known. E.g., number of arguments to call. */
+ oparity_dynamic, /**< arity depends on state of firm representation.
+ Can change by optimizations...
+ We must allocate a dynamic in array for the node! */
+ oparity_any /**< other arity */
+} op_arity;
+
+
+/** The irop flags */
+typedef enum {
+ irop_flag_none = 0x00000000, /**< Nothing. */
+ irop_flag_labeled = 0x00000001, /**< If set, output edge labels on in-edges in vcg graph. */
+ irop_flag_commutative = 0x00000002, /**< This operation is commutative. */
+ irop_flag_cfopcode = 0x00000004, /**< This operation is a control flow operation. */
+ irop_flag_ip_cfopcode = 0x00000008, /**< This operation manipulates the interprocedural control flow. */
+ irop_flag_fragile = 0x00000010, /**< Set if the operation can change the control flow because
+ of an exception. */
+ irop_flag_forking = 0x00000020, /**< Forking control flow at this operation. */
+ irop_flag_highlevel = 0x00000040, /**< This operation is a pure high-level one and can be
+ skipped in low-level optimizations. */
+ irop_flag_constlike = 0x00000080, /**< This operation has no arguments and is some
+ kind of a constant. */
+ irop_flag_always_opt = 0x00000100, /**< This operation must always be optimized .*/
+ irop_flag_keep = 0x00000200, /**< This operation can be kept in End's keep-alive list. */
+ irop_flag_start_block = 0x00000400, /**< This operation is always placed in the Start block. */
+ irop_flag_machine = 0x00000800, /**< This operation is a machine operation. */
+ irop_flag_machine_op = 0x00001000, /**< This operation is a machine operand. */
+ irop_flag_user = 0x00002000 /**< This flag and all higher ones are free for machine user. */
+} irop_flags;
+
+/** The opcodes of the libFirm predefined operations. */
+typedef enum {
+ iro_Block,
+ iro_Start, iro_End, iro_Jmp, iro_IJmp, iro_Cond, iro_Return,
+ iro_Const, iro_SymConst,
+ iro_Sel,
+ iro_Call, iro_Add, iro_Sub, iro_Minus, iro_Mul, iro_Quot, iro_DivMod,
+ iro_Div, iro_Mod, iro_Abs, iro_And, iro_Or, iro_Eor, iro_Not,
+ iro_Cmp, iro_Shl, iro_Shr, iro_Shrs, iro_Rot, iro_Conv, iro_Cast,
+ iro_Carry, iro_Borrow,
+ iro_Phi,
+ iro_Load, iro_Store, iro_Alloc, iro_Free, iro_Sync,
+ iro_Proj, iro_Tuple, iro_Id, iro_Bad, iro_Confirm,
+ iro_Unknown, iro_Filter, iro_Break, iro_CallBegin, iro_EndReg, iro_EndExcept,
+ iro_NoMem, iro_Mux, iro_Psi, iro_CopyB,
+ iro_InstOf, iro_Raise, iro_Bound,
+ iro_Pin,
+ iro_ASM,
+ iro_MaxOpcode
+} ir_opcode;
+
+extern ir_op *op_Block; ir_op *get_op_Block (void);
+
+extern ir_op *op_Start; ir_op *get_op_Start (void);
+extern ir_op *op_End; ir_op *get_op_End (void);
+extern ir_op *op_Jmp; ir_op *get_op_Jmp (void);
+extern ir_op *op_IJmp; ir_op *get_op_IJmp (void);
+extern ir_op *op_Cond; ir_op *get_op_Cond (void);
+extern ir_op *op_Return; ir_op *get_op_Return (void);
+extern ir_op *op_Sel; ir_op *get_op_Sel (void);
+
+extern ir_op *op_Const; ir_op *get_op_Const (void);
+extern ir_op *op_SymConst; ir_op *get_op_SymConst (void);
+
+extern ir_op *op_Call; ir_op *get_op_Call (void);
+extern ir_op *op_Add; ir_op *get_op_Add (void);
+extern ir_op *op_Sub; ir_op *get_op_Sub (void);
+extern ir_op *op_Minus; ir_op *get_op_Minus (void);
+extern ir_op *op_Mul; ir_op *get_op_Mul (void);
+extern ir_op *op_Quot; ir_op *get_op_Quot (void);
+extern ir_op *op_DivMod; ir_op *get_op_DivMod (void);
+extern ir_op *op_Div; ir_op *get_op_Div (void);
+extern ir_op *op_Mod; ir_op *get_op_Mod (void);
+extern ir_op *op_Abs; ir_op *get_op_Abs (void);
+extern ir_op *op_And; ir_op *get_op_And (void);
+extern ir_op *op_Or; ir_op *get_op_Or (void);
+extern ir_op *op_Eor; ir_op *get_op_Eor (void);
+extern ir_op *op_Not; ir_op *get_op_Not (void);
+extern ir_op *op_Cmp; ir_op *get_op_Cmp (void);
+extern ir_op *op_Shl; ir_op *get_op_Shl (void);
+extern ir_op *op_Shr; ir_op *get_op_Shr (void);
+extern ir_op *op_Shrs; ir_op *get_op_Shrs (void);
+extern ir_op *op_Rot; ir_op *get_op_Rot (void);
+extern ir_op *op_Conv; ir_op *get_op_Conv (void);
+extern ir_op *op_Cast; ir_op *get_op_Cast (void);
+extern ir_op *op_Carry; ir_op *get_op_Carry (void);
+extern ir_op *op_Borrow; ir_op *get_op_Borrow (void);
+
+extern ir_op *op_Phi; ir_op *get_op_Phi (void);
+
+extern ir_op *op_Load; ir_op *get_op_Load (void);
+extern ir_op *op_Store; ir_op *get_op_Store (void);
+extern ir_op *op_Alloc; ir_op *get_op_Alloc (void);
+extern ir_op *op_Free; ir_op *get_op_Free (void);
+
+extern ir_op *op_Sync; ir_op *get_op_Sync (void);
+
+extern ir_op *op_Tuple; ir_op *get_op_Tuple (void);
+extern ir_op *op_Proj; ir_op *get_op_Proj (void);
+extern ir_op *op_Id; ir_op *get_op_Id (void);
+extern ir_op *op_Bad; ir_op *get_op_Bad (void);
+extern ir_op *op_Confirm; ir_op *get_op_Confirm (void);
+
+extern ir_op *op_Unknown; ir_op *get_op_Unknown (void);
+extern ir_op *op_Filter; ir_op *get_op_Filter (void);
+extern ir_op *op_Break; ir_op *get_op_Break (void);
+extern ir_op *op_CallBegin; ir_op *get_op_CallBegin (void);
+extern ir_op *op_EndReg; ir_op *get_op_EndReg (void);
+extern ir_op *op_EndExcept; ir_op *get_op_EndExcept (void);
+
+extern ir_op *op_NoMem; ir_op *get_op_NoMem (void);
+extern ir_op *op_Mux; ir_op *get_op_Mux (void);
+extern ir_op *op_Psi; ir_op *get_op_Psi (void);
+extern ir_op *op_CopyB; ir_op *get_op_CopyB (void);
+
+extern ir_op *op_InstOf; ir_op *get_op_InstOf (void);
+extern ir_op *op_Raise; ir_op *get_op_Raise (void);
+extern ir_op *op_Bound; ir_op *get_op_Bound (void);
+
+extern ir_op *op_Pin; ir_op *get_op_Pin (void);
+
+extern ir_op *op_ASM; ir_op *get_op_ASM (void);
+
+/** Returns the ident for the opcode name */
+ident *get_op_ident(const ir_op *op);
+
+/** Returns the string for the opcode. */
+const char *get_op_name(const ir_op *op);
+
+/** Returns the enum for the opcode */
+ir_opcode get_op_code(const ir_op *op);
+
+/** op_pin_state_pinned states */
+typedef enum {
+ op_pin_state_floats = 0, /**< Nodes of this opcode can be placed in any basic block. */
+ op_pin_state_pinned = 1, /**< Nodes must remain in this basic block. */
+ op_pin_state_exc_pinned, /**< Node must be remain in this basic block if it can throw an
+ exception, else can float. Used internally. */
+ op_pin_state_mem_pinned /**< Node must be remain in this basic block if it can throw an
+ exception or uses memory, else can float. Used internally. */
+} op_pin_state;
+
+const char *get_op_pin_state_name(op_pin_state s);
+
+/** gets pinned state of an opcode */
+op_pin_state get_op_pinned(const ir_op *op);
+
+/** Sets pinned in the opcode. Setting it to floating has no effect
+ for Block, Phi and control flow nodes. */
+void set_op_pinned(ir_op *op, op_pin_state pinned);
+
+/** Returns the next free IR opcode number, allows to register user ops */
+unsigned get_next_ir_opcode(void);
+
+/** Returns the next free n IR opcode number, allows to register a bunch of user ops */
+unsigned get_next_ir_opcodes(unsigned num);
+
+/**
+ * A generic function pointer.
+ */
+typedef void (*op_func)(void);
+
+/** The NULL-function. */
+#define NULL_FUNC ((generic_func)(NULL))
+
+/**
+ * Returns the generic function pointer from an ir operation.
+ */
+op_func get_generic_function_ptr(const ir_op *op);
+
+/**
+ * Store a generic function pointer into an ir operation.
+ */
+void set_generic_function_ptr(ir_op *op, op_func func);
+
+/**
+ * The compute value operation.
+ * This operation evaluates an IR node into a tarval if possible,
+ * returning tarval_bad otherwise.
+ */
+typedef tarval *(*computed_value_func)(ir_node *self);
+
+/**
+ * The equivalent node operation.
+ * This operation returns an equivalent node for the input node.
+ * It does not create new nodes. It is therefore safe to free self
+ * if the node returned is not self.
+ * If a node returns a Tuple we can not just skip it. If the size of the
+ * in array fits, we transform n into a tuple (e.g., possible for Div).
+ */
+typedef ir_node *(*equivalent_node_func)(ir_node *self);
+
+/**
+ * The transform node operation.
+ * This operation tries several [inplace] [optimizing] transformations
+ * and returns an equivalent node.
+ * The difference to equivalent_node() is that these
+ * transformations _do_ generate new nodes, and thus the old node must
+ * not be freed even if the equivalent node isn't the old one.
+ */
+typedef ir_node *(*transform_node_func)(ir_node *self);
+
+/**
+ * The node attribute compare operation.
+ * Compares the nodes attributes of two nodes of identical opcode
+ * and returns 0 if the attributes are identical, 1 if they differ.
+ */
+typedef int (*node_cmp_attr_func)(ir_node *a, ir_node *b);
+
+/**
+ * The reassociation operation.
+ * Called from a walker. Returns non-zero if
+ * a reassociation rule was applied.
+ * The pointer n is set to the newly created node, if some reassociation
+ * was applied.
+ */
+typedef int (*reassociate_func)(ir_node **n);
+
+/**
+ * The copy attribute operation.
+ * Copy the node attributes from a 'old' node to a 'new' one.
+ */
+typedef void (*copy_attr_func)(const ir_node *old_node, ir_node *new_node);
+
+/**
+ * The get_type operation.
+ * Return the type of the node self.
+ */
+typedef ir_type *(*get_type_func)(ir_node *self);
+
+/**
+ * The get_type_attr operation. Used to traverse all types that can be
+ * accessed from an ir_graph.
+ * Return the type attribute of the node self.
+ */
+typedef ir_type *(*get_type_attr_func)(ir_node *self);
+
+/**
+ * The get_entity_attr operation. Used to traverse all entities that can be
+ * accessed from an ir_graph.
+ * Return the entity attribute of the node self.
+ */
+typedef ir_entity *(*get_entity_attr_func)(ir_node *self);
+
+/**
+ * The verify_node operation.
+ * Return non-zero if the node verification is ok, else 0.
+ * Depending on the node verification settings, may even assert.
+ *
+ * @see do_node_verification()
+ */
+typedef int (*verify_node_func)(ir_node *self, ir_graph *irg);
+
+/**
+ * The verify_node operation for Proj(X).
+ * Return non-zero if the node verification is ok, else 0.
+ * Depending on the node verification settings, may even assert.
+ *
+ * @see do_node_verification()
+ */
+typedef int (*verify_proj_node_func)(ir_node *self, ir_node *proj);
+
+/**
+ * Reasons to call the dump_node operation:
+ */
+typedef enum {
+ dump_node_opcode_txt, /**< dump the opcode */
+ dump_node_mode_txt, /**< dump the mode */
+ dump_node_nodeattr_txt, /**< dump node attributes to be shown in the label */
+ dump_node_info_txt /**< dump node attributes into info1 */
+} dump_reason_t;
+
+/**
+ * The dump_node operation.
+ * Writes several informations requested by reason to
+ * an output file
+ */
+typedef int (*dump_node_func)(ir_node *self, FILE *F, dump_reason_t reason);
+
+/**
+ * io_op Operations.
+ */
+typedef struct {
+ computed_value_func computed_value; /**< evaluates a node into a tarval if possible. */
+ equivalent_node_func equivalent_node; /**< optimizes the node by returning an equivalent one. */
+ transform_node_func transform_node; /**< optimizes the node by transforming it. */
+ node_cmp_attr_func node_cmp_attr; /**< compares two node attributes. */
+ reassociate_func reassociate; /**< reassociate a tree */
+ copy_attr_func copy_attr; /**< copy node attributes */
+ get_type_func get_type; /**< return the type of a node */
+ get_type_attr_func get_type_attr; /**< return the type attribute of a node */
+ get_entity_attr_func get_entity_attr; /**< return the entity attribute of a node */
+ verify_node_func verify_node; /**< verify the node */
+ verify_proj_node_func verify_proj_node; /**< verify the Proj node */
+ dump_node_func dump_node; /**< dump a node */
+ op_func generic; /**< a generic function */
+} ir_op_ops;
+
+/**
+ * Creates a new ir operation.
+ *
+ * @param code the opcode, one of type \c opcode
+ * @param name the printable name of this opcode
+ * @param p whether operations of this opcode are op_pin_state_pinned or floating
+ * @param flags a bitmask of irop_flags describing the behavior of the ir operation
+ * @param opar the parity of this ir operation
+ * @param op_index if the parity is oparity_unary, oparity_binary or oparity_trinary the index
+ * of the left operand
+ * @param ops operations for this opcode, iff NULL default operations are used
+ * @param attr_size attribute size for this ir operation
+ *
+ * @return The generated ir operation.
+ *
+ * This function can create all standard Firm opcode as well as new ones.
+ * The behavior of new opcode depends on the operations \c ops and the \c flags.
+ */
+ir_op *new_ir_op(ir_opcode code, const char *name, op_pin_state p,
+ unsigned flags, op_arity opar, int op_index, size_t attr_size,
+ const ir_op_ops *ops);
+
+/** Returns the ir_op_ops of an ir_op. */
+const ir_op_ops *get_op_ops(const ir_op *op);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief iropt --- optimizations of an ir node.
+ * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Michael Beck
+ * @version $Id$
+ */
+#ifndef FIRM_IR_IROPT_H
+#define FIRM_IR_IROPT_H
+
+#include "firm_types.h"
+
+/**
+ * The Floating point model.
+ *
+ * Several basic properties are defined:
+ * - fp_explicit_rounding
+ * - fp_strict_algebraic
+ * - fp_contradictions
+ * - fp_strict_eval_order
+ * - fp_exceptions
+ * - fp_environment_access
+ *
+ * From those basic properties three general models are defined,
+ * compatible to the VC8 compiler:
+ * - fp_model_precise:
+ * Default mode. Associative and distributive law forbidden unless a transformation
+ * is guaranteed to produce the same result.
+ * No FPU environment access. No FP exception semantics.
+ * - fp_model_strict:
+ * Slowest mode. Additionally to fp_model_precise allows correct handling of
+ * FP exceptions and FPU environment access.
+ * - fp_model_fast:
+ * Fastest mode. Associative and distributive law allowed at the expense
+ * of floating point accuracy and correctness. Explicit rounding is disabled.
+ */
+typedef enum _fp_model_t {
+ fp_explicit_rounding = 1, /**< Explicit rounding at assignments, typecasts, return
+ and function calls. Conv nodes may NOT be removed, even
+ if they look useless. */
+ fp_strict_algebraic = 2, /**< Strict adherence to non-associative and non-distributive
+ algebra unless the same result is guaranteed. */
+ fp_contradictions = 4, /**< FP contradictions are enabled. Only for backend. */
+ fp_strict_eval_order = 8, /**< FP instructions must be strict evaluated in given order. */
+ fp_exceptions = 16, /**< FP exceptions are supported. No reordering that changes
+ the exception flow are allowed. Backends must generate
+ synchronized exception code. */
+ fp_environment_access = 32, /**< FPU environment can be accessed. Even Constant folding
+ cannot be done. */
+
+ /** Precise floating point model. Default. */
+ fp_model_precise = fp_explicit_rounding|fp_strict_algebraic|fp_contradictions,
+ /** Strict floating point model. */
+ fp_model_strict = fp_explicit_rounding|fp_strict_algebraic|fp_strict_eval_order|
+ fp_exceptions|fp_environment_access,
+ /** Fast floating point model. */
+ fp_model_fast = fp_contradictions,
+} fp_model_t;
+
+/** If the expression referenced can be evaluated statically
+ * computed_value returns a tarval representing the result.
+ * Else returns tarval_bad. */
+tarval *computed_value(ir_node *n);
+
+/** Applies all optimizations to n that are expressible as a pattern
+ * in Firm, i.e., they need not a walk of the graph.
+ * Returns a better node for n. Does not free n -- other nodes could
+ * reference n.
+ *
+ * An equivalent optimization is applied in the constructors defined in
+ * ircons.ch. There n is freed if a better node could be found.
+ */
+ir_node *optimize_in_place(ir_node *n);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Debug makros used in iropt.
+ * @author Goetz Lindenmaier
+ * @version $Id$
+ */
+#ifndef FIRM_IR_IROPT_DBG_H
+#define FIRM_IR_IROPT_DBG_H
+
+#include "dbginfo_t.h"
+#include "irhooks.h"
+#include "firmstat.h"
+
+/* This file contains makros that generate the calls to
+ update the debug information after a transformation. */
+
+#define SIZ(x) sizeof(x)/sizeof((x)[0])
+
+
+/**
+ * Merge the debug info due to dead block elimination.
+ *
+ * @param oldn the block that it is eliminated
+ * @param n the new node for this block, may be equal to oldn
+ */
+#define DBG_OPT_DEAD_BLOCK(oldn, n) \
+ do { \
+ hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_DEAD_BLOCK); \
+ __dbg_info_merge_pair(n, oldn, dbg_dead_code); \
+ } while(0)
+
+
+/**
+ * Merge the debug info due to a straightening optimization.
+ * Block oldn is merged with n.
+ *
+ * @param oldn the old block
+ * @param n the new block the merges with oldn
+ */
+#define DBG_OPT_STG(oldn, n) \
+ do { \
+ ir_node *ons[2]; \
+ ons[0] = oldn; \
+ ons[1] = get_Block_cfgpred(oldn, 0); \
+ hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_STG); \
+ __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_straightening); \
+ } while(0)
+
+/**
+ * Merge the debug info due to an if simplification.
+ *
+ * @param oldn the old Block
+ * @param proj1 the first ProjX predecessor
+ * @param proj2 the second ProjX predecessor
+ * @param n the new Block
+ */
+#define DBG_OPT_IFSIM1(oldn, proj1, proj2, n) \
+ do { \
+ ir_node *ons[4]; \
+ ons[0] = oldn; \
+ ons[1] = proj1; \
+ ons[2] = proj2; \
+ ons[3] = get_Proj_pred(proj1); \
+ hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_IFSIM); \
+ __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_if_simplification); \
+ } while(0)
+
+/**
+ * Merge the debug info due to an if simplification.
+ * @param oldn the old Cond
+ * @param n the new Jmp
+ */
+#define DBG_OPT_IFSIM2(oldn, n) \
+ do { \
+ hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_IFSIM); \
+ __dbg_info_merge_pair(n, oldn, dbg_if_simplification); \
+ } while(0)
+
+/**
+ * Merge the debug info due to an algebraic_simplification.
+ * A node could be avaluated into a Constant.
+ *
+ * @param oldn the node
+ * @param n the new constant holding the value
+ */
+#define DBG_OPT_CSTEVAL(oldn, n) \
+ do { \
+ hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_CONST_EVAL); \
+ __dbg_info_merge_pair(n, oldn, dbg_const_eval); \
+ } while(0)
+
+/**
+ * Merge the debug info due to an algebraic_simplification.
+ *
+ * @param oldn the old node
+ * @param n the new node replacing oldn
+ * @param flag firm statistics option
+ */
+#define DBG_OPT_ALGSIM0(oldn, n, flag) \
+ do { \
+ hook_merge_nodes(&n, 1, &oldn, 1, flag); \
+ __dbg_info_merge_pair(n, oldn, dbg_algebraic_simplification); \
+ } while(0)
+
+/**
+ * Merge the debug info due to an algebraic_simplification.
+ *
+ * @param oldn the old node
+ * @param a a predecessor of oldn
+ * @param b a predecessor of oldn
+ * @param n the new node replacing oldn
+ * @param flag firm statistics option
+ */
+#define DBG_OPT_ALGSIM1(oldn, a, b, n, flag) \
+ do { \
+ ir_node *ons[3]; \
+ ons[0] = oldn; \
+ ons[1] = a; \
+ ons[2] = b; \
+ hook_merge_nodes(&n, 1, ons, SIZ(ons), flag); \
+ __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
+ } while(0)
+
+/**
+ * Merge the debug info due to an algebraic_simplification.
+ */
+#define DBG_OPT_ALGSIM2(oldn, pred, n) \
+ do { \
+ ir_node *ons[3]; \
+ ons[0] = oldn; \
+ ons[1] = pred; \
+ ons[2] = n; \
+ hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_ALGSIM); \
+ __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
+ } while(0)
+
+/**
+ * Merge the debug info due to an algebraic_simplification.
+ */
+#define DBG_OPT_ALGSIM3(oldn, a, n) \
+ do { \
+ ir_node *ons[2]; \
+ ons[0] = oldn; \
+ ons[1] = a; \
+ hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_ALGSIM); \
+ __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
+ } while(0)
+
+/**
+ * Merge the debug info due to a Phi optimization.
+ * A Phi node was replaced by one of its input (the only meaningful)
+ *
+ * @param phi the Phi node that will be replaced
+ * @param n in Phi Input that will replace Phi
+ */
+#define DBG_OPT_PHI(phi, n) \
+ do { \
+ hook_merge_nodes(&n, 1, &phi, 1, HOOK_OPT_PHI); \
+ __dbg_info_merge_sets(&n, 1, &phi, 1, dbg_opt_ssa); \
+ } while(0)
+
+
+/**
+ * Merge the debug info due to a Sync optimization.
+ * A Sync node was replaced by one of its input (the only meaningful)
+ *
+ * @param sync the Sync node that will be replaced
+ * @param n in Sync Input that will replace Sync
+ */
+#define DBG_OPT_SYNC(sync, n) \
+ do { \
+ hook_merge_nodes(&n, 1, &sync, 1, HOOK_OPT_SYNC); \
+ __dbg_info_merge_sets(&n, 1, &sync, 1, dbg_opt_ssa); \
+ } while(0)
+
+
+/**
+ * Merge the debug info due to Write-after-Write optimization:
+ * Store oldst will be removed, because Store st overwrites it.
+ *
+ * @param oldst the old store that will be removed
+ * @param st the other store that overwrites oldst
+ */
+#define DBG_OPT_WAW(oldst, st) \
+ do { \
+ ir_node *ons[2]; \
+ ons[0] = oldst; \
+ ons[1] = st; \
+ hook_merge_nodes(&st, 1, ons, SIZ(ons), HOOK_OPT_WAW); \
+ __dbg_info_merge_sets(&st, 1, ons, SIZ(ons), dbg_write_after_write); \
+ } while(0)
+
+/**
+ * Merge the debug info due to Write-after-Read optimization:
+ * A store will be removed because it rite a value just read back.
+ *
+ * @param store the store that will be removed
+ * @param load the load that produces the value that store will write back
+ */
+#define DBG_OPT_WAR(store, load) \
+ do { \
+ ir_node *ons[2]; \
+ ons[0] = store; \
+ ons[1] = load; \
+ hook_merge_nodes(&load, 1, ons, SIZ(ons), HOOK_OPT_WAR); \
+ __dbg_info_merge_sets(&load, 1, ons, SIZ(ons), dbg_write_after_read); \
+ } while(0)
+
+/**
+ * Merge the debug info due to Read-after-Write optimization:
+ * A load will be replaced by a value that was just stored.
+ *
+ * @param load the load that will be replaced
+ * @param value the value that will replace the load
+ */
+#define DBG_OPT_RAW(load, value) \
+ do { \
+ ir_node *ons[2]; \
+ ons[0] = load; \
+ ons[1] = value; \
+ hook_merge_nodes(&value, 1, ons, SIZ(ons), HOOK_OPT_RAW); \
+ __dbg_info_merge_sets(&value, 1, ons, SIZ(ons), dbg_read_after_write); \
+ } while(0)
+
+/**
+ * Merge the debug info due to Read-after-Read optimization:
+ * Load oldld will be replace by a reference to Load ld.
+ *
+ * @param oldld the old load that can be replaced
+ * @param ld the load that produces the same values
+ */
+#define DBG_OPT_RAR(oldld, ld) \
+ do { \
+ ir_node *ons[2]; \
+ ons[0] = oldld; \
+ ons[1] = ld; \
+ hook_merge_nodes(&ld, 1, ons, SIZ(ons), HOOK_OPT_RAR); \
+ __dbg_info_merge_sets(&ld, 1, ons, SIZ(ons), dbg_read_after_read); \
+ } while(0)
+
+/**
+ * Merge the debug info due to Read-a-Const optimization:
+ * Load ld will be replace by a Constant if the value that
+ * will be loaded is known and immutable.
+ *
+ * @param ld the load
+ * @param c the constant value that will replace the load's result
+ */
+#define DBG_OPT_RC(ld, c) \
+ do { \
+ ir_node *ons[2]; \
+ ons[0] = ld; \
+ ons[1] = c; \
+ hook_merge_nodes(&c, 1, ons, SIZ(ons), HOOK_OPT_RC); \
+ __dbg_info_merge_sets(&ld, 1, ons, SIZ(ons), dbg_read_a_const); \
+ } while(0)
+
+/**
+ * Merge the debug info after a tuple optimization.
+ * a Proj(Tuple) is replaced by the associated tuple value.
+ *
+ * @param proj the Proj node
+ * @param tuple the Tuple node
+ * @param n the Proj(Tuple) value
+ */
+#define DBG_OPT_TUPLE(proj, tuple, n) \
+ do { \
+ ir_node *ons[3]; \
+ ons[0] = proj; \
+ ons[1] = tuple; \
+ ons[2] = n; \
+ hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_TUPLE); \
+ __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_auxnode); \
+ } while(0)
+
+/**
+ * Merge the debug info after an Id optimization.
+ * An Id node was replaced by its non-Id predecessor.
+ *
+ * @param id the Id node
+ * @param n the predecessor
+ */
+#define DBG_OPT_ID(id, n) \
+ do { \
+ ir_node *ons[2]; \
+ ons[0] = id; \
+ ons[1] = n; \
+ hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_ID); \
+ __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_auxnode); \
+ } while(0)
+
+/**
+ * Merge the debug info due to common-subexpression elimination.
+ *
+ * @param oldn the old node
+ * @param n the node that replaces oldn
+ */
+#define DBG_OPT_CSE(oldn, n) \
+ do { \
+ ir_node *ons[2]; \
+ ons[0] = oldn; \
+ ons[1] = n; \
+ hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_CSE); \
+ __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_cse); \
+ } while(0)
+
+/**
+ * Merge the debug info due to polymorphic call optimization.
+ * A Sel node was replaced by a constant.
+ *
+ * @param sel the Sel node that will be replaced.
+ * @param c the constant node that replaces sel
+ */
+#define DBG_OPT_POLY(sel, c) \
+ do { \
+ ir_node *ons[3]; \
+ ons[0] = sel; \
+ ons[1] = skip_Proj(get_Sel_ptr(sel)); \
+ ons[2] = c; \
+ hook_merge_nodes(&c, 1, ons, SIZ(ons), HOOK_OPT_POLY_CALL); \
+ __dbg_info_merge_sets(&c, 1, ons, SIZ(ons), dbg_rem_poly_call); \
+ } while(0)
+
+/**
+ * A node was replaced by another node due to a Confirmation.
+ *
+ * @param oldn the old node
+ * @param n the new node
+ */
+#define DBG_OPT_CONFIRM(oldn, n) \
+ do { \
+ hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_CONFIRM); \
+ __dbg_info_merge_pair(n, oldn, dbg_opt_confirm); \
+ } while(0)
+
+/**
+ * A node was replaced by a constant due to a Confimation.
+ *
+ * @param oldn the old node
+ * @param c the new constant node
+ */
+#define DBG_OPT_CONFIRM_C(oldn, c) \
+ do { \
+ hook_merge_nodes(&c, 1, &oldn, 1, HOOK_OPT_CONFIRM_C); \
+ __dbg_info_merge_pair(c, oldn, dbg_opt_confirm); \
+ } while(0)
+
+/**
+ * A exception exdge was removed due to a Confirmation prove.
+ *
+ * @param oldn the old node
+ */
+#define DBG_OPT_EXC_REM(oldn) \
+ do { \
+ hook_merge_nodes(NULL, 0, &oldn, 1, HOOK_OPT_EXC_REM); \
+ } while(0)
+
+/**
+ * A node could be evaluated to a value due to a Confirm.
+ * This will lead to a constant evaluation.
+ *
+ * @param n the node that could be evaluated
+ */
+#define DBG_EVAL_CONFIRM(n) \
+ do { \
+ hook_merge_nodes(NULL, 0, &n, 1, HOOK_OPT_CONFIRM_E); \
+ } while(0)
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Optimisations
+ * @version $Id: cfopt.h 13543 2007-04-29 19:29:02Z beck $
+ */
+#ifndef FIRM_IROPTIMIZE_H
+#define FIRM_IROPTIMIZE_H
+
+#include "firm_types.h"
+
+/**
+ * Control flow optimization.
+ *
+ * Removes empty blocks doing if simplifications and loop simplifications.
+ * A block is empty if it contains only a Jmp node and Phi nodes.
+ * Merges single entry single exit blocks with their predecessor
+ * and propagates dead control flow by calling equivalent_node().
+ * Independent of compiler flag it removes Tuples from cf edges,
+ * Bad predecessors from Blocks and Phis, and unnecessary predecessors of End.
+ *
+ * @bug So far destroys backedge information.
+ * @bug Chokes on Id nodes if called in a certain order with other
+ * optimizations. Call local_optimize_graph() before to remove
+ * Ids.
+ */
+void optimize_cf(ir_graph *irg);
+
+/**
+ * Perform partial conditionla evaluation on the given graph.
+ *
+ * @param irg the graph
+ */
+void opt_cond_eval(ir_graph* irg);
+
+/**
+ * Try to reduce the number of conv nodes in the given ir graph.
+ *
+ * @param irg the graph
+ */
+void conv_opt(ir_graph *irg);
+
+/**
+ * Do the scalar replacement optimization.
+ * Make a date flow analyze and split the
+ * data flow edges.
+ *
+ * @param irg the graph which should be optimized
+ */
+void data_flow_scalar_replacement_opt(ir_graph *irg);
+
+/**
+ * A callback that checks whether a entity is an allocation
+ * routine.
+ */
+typedef int (*check_alloc_entity_func)(ir_entity *ent);
+
+/**
+ * Do simple and fast escape analysis for one graph.
+ *
+ * @param irg the graph
+ * @param callback a callback function to check whether a
+ * given entity is a allocation call
+ */
+void escape_enalysis_irg(ir_graph *irg, check_alloc_entity_func callback);
+
+/**
+ * Do simple and fast escape analysis for all graphs.
+ *
+ * This optimization implements a simple and fast but inexact
+ * escape analysis. Some addresses might be marked as 'escaped' even
+ * if they are not.
+ * The advantage is a low memory footprint and fast speed.
+ *
+ * @param run_scalar_replace if this flag in non-zero, scalar
+ * replacement optimization is run on graphs with removed
+ * allocation
+ * @param callback a callback function to check whether a
+ * given entity is a allocation call
+ *
+ * This optimization removes allocation which are not used (rare) and replace
+ * allocation that can be proved dead at the end of the graph which stack variables.
+ *
+ * The creation of stack variable allows scalar replacement to be run only
+ * on those graphs that have been changed.
+ *
+ * This is most effective on Java where no other stack variables exists.
+ */
+void escape_analysis(int run_scalar_replace, check_alloc_entity_func callback);
+
+/**
+ * Optimize function calls by handling const functions.
+ *
+ * This optimization first detects all "const functions", i.e.,
+ * IR graphs that neither read nor write memory (and hence did
+ * not create exceptions, as these use memory in Firm).
+ *
+ * The result of calls to such functions depends only on its
+ * arguments, hence those calls are no more pinned.
+ *
+ * This is a rather strong criteria, so do not expect that a
+ * lot of functions will be found. Moreover, all of them might
+ * already be inlined if inlining is activated.
+ * Anyway, it might be good for handling builtin's or pseudo-graphs,
+ * even if the later read/write memory (but we know how).
+ *
+ * This optimizations read the irg_const_function property of
+ * entities and and sets the irg_const_function property of
+ * graphs.
+ *
+ * If callee information is valid, we also optimize polymorphic Calls.
+ *
+ * @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.
+ *
+ * If the fontend created external entities with the irg_const_function
+ * property set, the force_run parameter should be set, else
+ * should be unset.
+ *
+ * @note This optimization destroys the link fields of nodes.
+ */
+void optimize_funccalls(int force_run);
+
+/**
+ * Does Partial Redundancy Elimination combined with
+ * Global Value Numbering.
+ * Can be used to replace place_code() completely.
+ *
+ * Based on VanDrunen and Hosking 2004.
+ *
+ * @param irg the graph
+ *
+ * @note
+ * Currently completely broken because the used sets do NOT
+ * preserve the topological sort of its elements.
+ */
+void do_gvn_pre(ir_graph *irg);
+
+/**
+ * This function is called to evaluate, if a mux can build
+ * of the current architecture.
+ * If it returns non-zero, a mux is created, else the code
+ * is not modified.
+ * @param sel A selector of a Cond.
+ * @param phi_list List of Phi nodes about to be converted (linked via link field)
+ * @param i First data predecessor involved in if conversion
+ * @param j Second data predecessor involved in if conversion
+ */
+typedef int (*arch_allow_ifconv_func)(ir_node *sel, ir_node* phi_list, int i, int j);
+
+/**
+ * The parameters structure.
+ */
+typedef struct _opt_if_conv_info_t {
+ int max_depth; /**< The maximum depth up to which expressions
+ are examined when it has to be decided if they
+ can be placed into another block. */
+ arch_allow_ifconv_func allow_ifconv; /**< Evaluator function, if not set all possible Psi
+ nodes will be created. */
+} opt_if_conv_info_t;
+
+/**
+ * Perform If conversion on a graph.
+ *
+ * @param irg The graph.
+ * @param params The parameters for the if conversion.
+ *
+ * Cannot handle blocks with Bad control predecessors, so call it after control
+ * flow optimization.
+ */
+void opt_if_conv(ir_graph *irg, const opt_if_conv_info_t *params);
+
+void opt_ldst2(ir_graph *irg);
+
+/**
+ * Load/Store optimization.
+ *
+ * Removes redundant non-volatile Loads and Stores.
+ * May introduce Bad nodes if exceptional control flow
+ * is removed. The following cases are optimized:
+ *
+ * Load without result: A Load which has only a memory use
+ * is removed.
+ *
+ * Load after Store: A Load after a Store is removed, if
+ * the Load doesn't have an exception handler OR is in
+ * the same block as the Store.
+ *
+ * Load after Load: A Load after a Load is removed, if the
+ * Load doesn't have an exception handler OR is in the
+ * same block as the previous Load.
+ *
+ * Store before Store: A Store immediately before another
+ * Store in the same block is removed, if the Store doesn't
+ * have an exception handler.
+ *
+ * Store after Load: A Store after a Load is removed, if the
+ * Store doesn't have an exception handler.
+ */
+void optimize_load_store(ir_graph *irg);
+
+/**
+ * Do Loop unrolling in the given graph.
+ */
+void optimize_loop_unrolling(ir_graph *irg);
+
+/**
+ * Optimize the frame type of an irg by removing
+ * never touched entities.
+ *
+ * @param irg The graph whose frame type will be optimized
+ *
+ * This function did not change the graph, only it's frame type.
+ * The layout state of the frame type will be set to layout_undefined
+ * if entities were removed.
+ */
+void opt_frame_irg(ir_graph *irg);
+
+/** Possible flags for the Operator Scalar Replacement. */
+typedef enum osr_flags {
+ osr_flag_none = 0, /**< no additional flags */
+ osr_flag_lftr_with_ov_check = 1, /**< do linear function test replacement
+ only if no overflow can occur. */
+ osr_flag_ignore_x86_shift = 2 /**< ignore Multiplications by 2, 4, 8 */
+} osr_flags;
+
+/* FirmJNI cannot handle identical enum values... */
+
+/** default setting */
+#define osr_flag_default osr_flag_lftr_with_ov_check
+
+/**
+ * Do the Operator Scalar Replacement optimization and linear
+ * function test replacement for loop control.
+ * Can be switched off using the set_opt_strength_red() flag.
+ * In that case, only remove_phi_cycles() is executed.
+ *
+ * @param irg the graph which should be optimized
+ * @param flags set of osr_flags
+ *
+ * The linear function replacement test is controlled by the flags.
+ * If the osr_flag_lftr_with_ov_check is set, the replacement is only
+ * done if do overflow can occur.
+ * Otherwise it is ALWAYS done which might be insecure.
+ *
+ * For instance:
+ *
+ * for (i = 0; i < 100; ++i)
+ *
+ * might be replaced by
+ *
+ * for (i = 0; i < 400; i += 4)
+ *
+ * But
+ *
+ * for (i = 0; i < 0x7FFFFFFF; ++i)
+ *
+ * will not be replaced by
+ *
+ * for (i = 0; i < 0xFFFFFFFC; i += 4)
+ *
+ * because of overflow.
+ *
+ * More bad cases:
+ *
+ * for (i = 0; i <= 0xF; ++i)
+ *
+ * will NOT be transformed into
+ *
+ * for (i = 0xFFFFFFF0; i <= 0xFFFFFFFF; ++i)
+ *
+ * although here is no direct overflow. The OV occurs when the ++i
+ * is executed (and would created an endless loop here!).
+ *
+ * For the same reason, a loop
+ *
+ * for (i = 0; i <= 9; i += x)
+ *
+ * will NOT be transformed because we cannot estimate whether an overflow
+ * might happen adding x.
+ *
+ * Note that i < a + 400 is also not possible with the current implementation
+ * although this might be allowed by other compilers...
+ *
+ * Note further that tests for equality can be handled some simpler (but are not
+ * implemented yet).
+ *
+ * This algorithm destroys the link field of nodes.
+ */
+void opt_osr(ir_graph *irg, unsigned flags);
+
+/**
+ * Removes useless Phi cycles, i.e cycles of Phi nodes with only one
+ * non-Phi node.
+ * This is automatically done in opt_osr(), so there is no need to call it
+ * additionally.
+ *
+ * @param irg the graph which should be optimized
+ *
+ * This algorithm destroys the link field of nodes.
+ */
+void remove_phi_cycles(ir_graph *irg);
+
+/** A default threshold. */
+#define DEFAULT_CLONE_THRESHOLD 300
+
+/**
+ * Do procedure cloning. Evaluate a heuristic weight for every
+ * Call(..., Const, ...). If the weight is bigger than threshold,
+ * clone the entity and fix the calls.
+ *
+ * @param threshold the threshold for cloning
+ *
+ * The threshold is an estimation of how many instructions are saved
+ * when executing a cloned method. If threshold is 0.0, every possible
+ * call is cloned.
+ */
+void proc_cloning(float threshold);
+
+/**
+ * Reassociation.
+ *
+ * Applies Reassociation rules to integer expressions.
+ * Beware: Works only if integer overflow might be ignored, as for C, Java
+ * and for address expression.
+ * Works only if Constant folding is activated.
+ *
+ * Uses loop information to detect loop-invariant (ie contant
+ * inside the loop) values.
+ *
+ * See Muchnik 12.3.1 Algebraic Simplification and Reassociation of
+ * Addressing Expressions.
+ *
+ *
+ */
+void optimize_reassociation(ir_graph *irg);
+
+/**
+ * Normalize the Returns of a graph by creating a new End block
+ * with One Return(Phi).
+ * This is the preferred input for the if-conversion.
+ *
+ * In pseudocode, it means:
+ *
+ * if (a)
+ * return b;
+ * else
+ * return c;
+ *
+ * is transformed into
+ *
+ * if (a)
+ * res = b;
+ * else
+ * res = c;
+ * return res;
+ */
+void normalize_one_return(ir_graph *irg);
+
+/**
+ * Normalize the Returns of a graph by moving
+ * the Returns upwards as much as possible.
+ * This might be preferred for code generation.
+ *
+ * In pseudocode, it means:
+ *
+ * if (a)
+ * res = b;
+ * else
+ * res = c;
+ * return res;
+ *
+ * is transformed into
+ *
+ * if (a)
+ * return b;
+ * else
+ * return c;
+ */
+void normalize_n_returns(ir_graph *irg);
+
+/**
+ * Do the scalar replacement optimization.
+ * Replace local compound entities (like structures and arrays)
+ * with atomic values if possible. Does not handle classes yet.
+ *
+ * @param irg the graph which should be optimized
+ */
+void scalar_replacement_opt(ir_graph *irg);
+
+/** Performs strength reduction for the passed graph. */
+void reduce_strength(ir_graph *irg);
+
+/**
+ * Optimizes simple tail-recursion calls by
+ * converting them into loops. Depends on the flag opt_tail_recursion.
+ *
+ * Does not work for Calls that use the exception stuff.
+ *
+ * @param irg the graph to be optimized
+ *
+ * @return non-zero if the optimization could be applied, 0 else
+ */
+int opt_tail_rec_irg(ir_graph *irg);
+
+/*
+ * Optimize tail-recursion calls for all IR-Graphs.
+ * Depends on the flag opt_tail_recursion.
+ */
+void opt_tail_recursion(void);
+
+/** This is the type for a method, that returns a pointer type to
+ * tp. This is needed in the normalization. */
+typedef ir_type *(*gen_pointer_type_to_func)(ir_type *tp);
+
+/** Insert Casts so that class type casts conform exactly with the type hierarchy.
+ *
+ * Formulated in Java, this achieves the following:
+ *
+ * For a class hierarchy
+ * class A {}
+ * class B extends A {}
+ * class C extends B {}
+ * we transforms a cast
+ * (A)new C()
+ * to
+ * (A)((B)new C()).
+ *
+ * The algorithm works for Casts with class types, but also for Casts
+ * with all pointer types that point (over several indirections,
+ * i.e. ***A) to a class type. Normalizes all graphs. Computes type
+ * information (@see irtypeinfo.h) if not available.
+ * Invalidates trout information as new casts are generated.
+ *
+ * @param gppt_fct A function that returns a pointer type that points
+ * to the type given as argument. If this parameter is NULL, a default
+ * function is used that either uses trout information or performs a O(n)
+ * search to find an existing pointer type. If it can not find a type,
+ * generates a pointer type with mode_P_mach and suffix "cc_ptr_tp".
+ */
+void normalize_irp_class_casts(gen_pointer_type_to_func gppt_fct);
+
+
+/** Insert Casts so that class type casts conform exactly with the type hierarchy
+ * in given graph.
+ *
+ * For more details see normalize_irp_class_casts().
+ *
+ * This transformation requires that type information is computed. @see irtypeinfo.h.
+ */
+void normalize_irg_class_casts(ir_graph *irg, gen_pointer_type_to_func gppt_fct);
+
+
+/** Optimize casting between class types.
+ *
+ * class A { m(); }
+ * class B extends A { }
+ * class C extends B {}
+ * Performs the following transformations:
+ * C c = (C)(B)(A)(B)new C() --> C c = (C)(B)newC() --> C c = new C()
+ * (Optimizing downcasts as A a = (A)(B)(new A()) --> A a = new A() can
+ * be suppressed by setting the flag opt_suppress_downcast_optimization.
+ * Downcasting A to B might cause an exception. It is not clear
+ * whether this is modeled by the Firm Cast node, as it has no exception
+ * outputs.);
+ * If there is inh_m() that overwrites m() in B:
+ * ((A) new B()).m() --> (new B()).inh_m()
+ * Phi((A)x, (A)y) --> (A) Phi (x, y) if (A) is an upcast.
+ *
+ * Computes type information if not available. @see irtypeinfo.h.
+ * Typeinformation is valid after optimization.
+ * Invalidates trout information.
+ */
+void optimize_class_casts(void);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Compute and access out edges (also called def-use edges).
+ * @author Goetz Lindenmaier, Michael Beck
+ * @date 1.2002
+ * @version $Id$
+ */
+#ifndef FIRM_ANA_IROUTS_H
+#define FIRM_ANA_IROUTS_H
+
+#include "firm_types.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: */
+int get_irn_n_outs(ir_node *node);
+
+/** Get predecessor n */
+ir_node *get_irn_out(ir_node *node, int pos);
+
+/** Set predecessor n */
+void set_irn_out(ir_node *node, int pos, ir_node *out);
+
+/* 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. */
+int get_Block_n_cfg_outs(ir_node *node);
+
+/** Return the number of control flow successors, honor keep-alives. */
+int get_Block_n_cfg_outs_ka(ir_node *node);
+
+/** Access predecessor n, ignore keep-alives. */
+ir_node *get_Block_cfg_out(ir_node *node, int pos);
+
+/** Access predecessor n, honor keep-alives. */
+ir_node *get_Block_cfg_out_ka(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. */
+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 it's own visited
+ flag, so that it can be interleaved with the other walker.
+ node must be either op_Block or mode_X. */
+void irg_out_block_walk(ir_node *node,
+ irg_walk_func *pre, irg_walk_func *post,
+ void *env);
+
+/*------------------------------------------------------------------*/
+/* 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. */
+void compute_irg_outs(ir_graph *irg);
+void compute_irp_outs(void);
+
+void assure_irg_outs(ir_graph *irg);
+
+/** Computes the out edges in interprocedural view */
+void compute_ip_outs(void);
+/** Frees the out datastructures. Sets the flag in irg to "outs_none". */
+void free_ip_outs(void);
+void free_irg_outs(ir_graph *irg);
+void free_irp_outs(void);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief A little printf understanding some firm types.
+ * @author Sebastian Hack
+ * @date 29.11.2004
+ * @version $Id$
+ */
+#ifndef FIRM_IR_IRPRINTF_H
+#define FIRM_IR_IRPRINTF_H
+
+#include "firm_config.h"
+
+#include <stddef.h>
+#include <stdarg.h>
+#include <stdio.h>
+
+/* forward definition */
+struct obstack;
+
+/**
+ * Something that can append strings and chars to something.
+ */
+typedef struct _appender_t {
+ void (*init)(void *object, size_t n);
+ void (*append_char)(void *object, size_t n, char ch);
+ void (*append_str)(void *object, size_t n, const char *str);
+} appender_t;
+
+/**
+ * A callback function type to add something to an appender.
+ *
+ * @param app The appender.
+ * @param object The object for the appender.
+ * @param limit The limit for the appender.
+ * @param arg The thing to append.
+ */
+typedef void (ir_printf_cb_t)(const appender_t *app, void *object, size_t limit, const void *arg);
+
+/**
+ * A string formatting routine for ir objects.
+ *
+ * @param fmt The format string.
+ *
+ * This function rudimentary implements a kind of printf(3) for ir
+ * nodes. Following conversion specifiers. No length, special or field
+ * width specifiers are accepted.
+ * - @%% Print a '%' character.
+ * - @%> Print as many white spaces as given in the parameter.
+ * - @%c Print a character
+ * - @%s A string.
+ * - @%p A pointer.
+ * - @%d A decimal integer.
+ * - @%x A hexadecimal integer.
+ * - @%o An octal integer.
+ * - @%I An ident.
+ * - @%t A type name.
+ * - @%e An entity name.
+ * - @%E An entity ld name.
+ * - @%T A tarval.
+ * - @%n A full description of a node.
+ * - @%O The opcode name of an ir node.
+ * - @%N The node number of an ir node.
+ * - @%m The mode name of an ir mode.
+ * - @%B The block node number of the nodes block.
+ * - @%b A bitset.
+ * - @%= A pnc value
+ * - @%G A debug info (if available)
+ * - @%P A compound graph path
+ *
+ * Each of these can be prepend by a '+' which means, that the given
+ * pointer is a collection of items specified by the format. In this
+ * case you also have to pass an iterator interface to ir_printf()
+ * suitable for the instance of the collection. So, imagine you have a
+ * @c pset of ir_nodes and want to dump it, you write:
+ * @code
+ * pset *nodes;
+ * ...
+ * ir_printf("Some nodes: %*n\n", it_pset, nodes);
+ * @endcode
+ * The @c it_pset is an iterator interface (of type
+ * @c iterator_t that allows the dumper to traverse the set.
+ *
+ * As special case when working with collections, you can also give a
+ * callback function which will be invoked on each element in the
+ * collection. It gets the appender (the thing where the textual
+ * representation of the element is written to) and its parameters
+ * passed by the dumping function. Suppose you have your own data type
+ * @c xyz_t and want to dump a pset of it, you have:
+ * @code
+ * void xyz_dump(const appender_t *app, void *object, size_t limit,
+ * const void *arg)
+ * {
+ * const xyz_t *xyz = arg;
+ * app->append_str(object, limit, xyz->name);
+ * }
+ * ...
+ * pset *xyzs;
+ *
+ * ir_printf("A set of xyz\'s: %*C\n", it_pset, xyzs, xyz_dump);
+ * @endcode
+ */
+void ir_printf(const char *fmt, ...);
+
+/**
+ * @see irn_printf.
+ */
+void ir_fprintf(FILE *f, const char *fmt, ...);
+
+/**
+ * @see irn_printf.
+ */
+void ir_snprintf(char *buf, size_t n, const char *fmt, ...);
+
+/**
+ * @see irn_printf.
+ */
+void ir_vprintf(const char *fmt, va_list args);
+
+/**
+ * @see irn_printf.
+ */
+void ir_vfprintf(FILE *f, const char *fmt, va_list args);
+
+/**
+ * @see irn_printf.
+ */
+void ir_vsnprintf(char *buf, size_t len, const char *fmt, va_list args);
+
+/**
+ * @see irn_printf.
+ */
+void ir_obst_vprintf(struct obstack *obst, const char *fmt, va_list args);
+
+#ifdef WITH_LIBCORE
+#include <libcore/lc_printf.h>
+#endif /* WITH_LIBCORE */
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Entry point to the representation of a whole program.
+ * @author Goetz Lindenmaier
+ * @date 2000
+ * @version $Id$
+ * @summary
+ * ir representation of a program.
+ *
+ * This file defines a construct that keeps all information about a
+ * program:
+ * - A reference point to the method to be executed on program start.
+ * - A list of all procedures.
+ * - A list of all types.
+ * - A global type that contais all global variables and procedures that do
+ * not belong to a class. This type represents the data segment of the
+ * program. It is not the base class of
+ * all classes in a class hierarchy (as, e.g., "object" in java).
+ * - A degenerated graph that contains constant expressions.
+ * - interprocedural outs state.
+ * - a flag indicating validity of the interprocedural representation.
+ * - the output file name
+ */
+#ifndef FIRM_IR_IRPROG_H
+#define FIRM_IR_IRPROG_H
+
+#include "firm_types.h"
+#include "irgraph.h"
+
+
+/**
+ * Datastructure that holds central information about a program
+ *
+ * Preliminary documentation ;-)
+ *
+ * - main_irg: The ir graph that is the entry point to the program.
+ * (Anything not reachable from here may be optimized away.
+ * If we want to translate libraries or the like correctly
+ * we must replace this by a list.)
+ * - irg: List of all ir graphs in the program.
+ * - type: A list containing all types known to the translated program.
+ * Some types can have several entries in this list (as a result of
+ * using exchange_types()).
+ * - glob_type: The unique global type that is owner of all global entities.
+ *
+ */
+typedef struct ir_prog ir_prog;
+
+/**
+ * A variable from where everything in the ir can be accessed.
+ * This variable contains the irp, the "immediate representation program".
+ * This variable should be considered constant. Moreover, one should use get_irp()
+ * to get access the the irp.
+ *
+ * @note
+ * Think of the irp as the "handle" of libFirm.
+ */
+extern ir_prog *irp;
+
+/**
+ * Returns the access points from where everything in the ir can be accessed.
+ *
+ * @see irp
+ */
+ir_prog *get_irp(void);
+
+/** Creates a new ir_prog, returns it and sets irp with it.
+ * Automatically called by init_firm() through init_irprog. */
+ir_prog *new_ir_prog (void);
+
+/** frees all memory used by irp. Types in type list and irgs in irg
+ * list must be freed by hand before. */
+void free_ir_prog(void);
+
+/** Sets the file name / executable name or the like. Initially the
+ ident 'no_name_set'. */
+void set_irp_prog_name (ident *name);
+
+/** Returns true if the user ever set a program name */
+int irp_prog_name_is_set(void);
+
+/** Gets the file name / executable name or the like.
+ */
+ident *get_irp_prog_ident(void);
+
+/** Gets the file name / executable name or the like.
+ */
+const char *get_irp_prog_name (void);
+
+/** Gets the main routine of the compiled program. */
+ir_graph *get_irp_main_irg(void);
+
+/** Sets the main routine of the compiled program. */
+void set_irp_main_irg(ir_graph *main_irg);
+
+/** Adds irg to the list of ir graphs in irp. */
+void add_irp_irg(ir_graph *irg);
+
+/** Removes irg from the list of irgs and
+ shrinks the list by one. */
+void remove_irp_irg_from_list(ir_graph *irg);
+/** Removes irg from the list of irgs, deallocates it and
+ shrinks the list by one. */
+void remove_irp_irg(ir_graph *irg);
+
+/** Returns the number of ir graphs in the irp. */
+int get_irp_n_irgs(void);
+
+/** Returns the ir graph at position pos in the irp. */
+ir_graph *get_irp_irg(int pos);
+
+/** Sets the ir graph at position pos. */
+void set_irp_irg(int pos, ir_graph *irg);
+
+/** Gets the number of graphs _and_ pseudo graphs. */
+int get_irp_n_allirgs(void);
+
+/** Returns the ir graph at position pos of all graphs (including
+ pseudo graphs). Visits first graphs, then pseudo graphs. */
+ir_graph *get_irp_allirg(int pos);
+
+/**
+ * Returns the "global" type of the irp.
+ * Upon creation this is an empty class type.
+ */
+ir_type *get_glob_type(void);
+
+/**
+ * Returns the "thread local storage" type of the irp.
+ * Upon creation this is an empty struct type.
+ */
+ir_type *get_tls_type(void);
+
+/** Adds type to the list of types in irp. */
+void add_irp_type(ir_type *typ);
+
+/** Removes type from the list of types, deallocates it and
+ shrinks the list by one. */
+void remove_irp_type(ir_type *typ);
+
+/** Returns the number of all types in the irp. */
+int get_irp_n_types(void);
+
+/** Returns the type at position pos in the irp. */
+ir_type *get_irp_type(int pos);
+
+/** Overwrites the type at position pos with another type. */
+void set_irp_type(int pos, ir_type *typ);
+
+/** Returns the number of all modes in the irp. */
+int get_irp_n_modes(void);
+
+/** Returns the mode at position pos in the irp. */
+ir_mode *get_irp_mode(int pos);
+
+/** Adds opcode to the list of opcodes in irp. */
+void add_irp_opcode(ir_op *opcode);
+
+/** Removes opcode from the list of opcodes, deallocates it and
+ shrinks the list by one. */
+void remove_irp_opcode(ir_op *opcode);
+
+/** Returns the number of all opcodes in the irp. */
+int get_irp_n_opcodes(void);
+
+/** Returns the opcode at position pos in the irp. */
+ir_op *get_irp_opcode(int pos);
+
+/** Sets the generic function pointer of all opcodes to NULL */
+void clear_irp_opcodes_generic_func(void);
+
+
+/** Return the graph for global constants.
+ *
+ * Returns an irgraph that only contains constant expressions for
+ * constant entities. Do not use any access function for this
+ * graph, do not generate code for this graph. This graph contains
+ * only one block. The constant expressions may not contain control
+ * flow.
+ * Walking the graph starting from any node will not reach the block
+ * or any controlflow.
+ * See also copy_const_code() in entity.h.
+ */
+ir_graph *get_const_code_irg(void);
+
+
+/** The phase state for the program.
+ *
+ * The phase state of the whole program is
+ * building: if at least one graph is state_building
+ * or one type is incomplete.
+ * high: all graphs are in state high or low, all types are constructed.
+ * low: all graphs are in state low, all types are in state layout fixed.
+ */
+irg_phase_state get_irp_phase_state(void);
+void set_irp_phase_state(irg_phase_state s);
+
+irg_outs_state get_irp_ip_outs_state(void);
+void set_irp_ip_outs_inconsistent(void);
+
+
+irg_callee_info_state get_irp_callee_info_state(void);
+void set_irp_callee_info_state(irg_callee_info_state s);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Run most simple type analyses.
+ * @author Goetz Lindenmaier
+ * @date 22.8.2003
+ * @version $Id$
+ * @summary
+ * We compute type information for each node. It is derived from the
+ * types of the origines of values, e.g. parameter types can be derived
+ * from the method type.
+ * The type information so far is saved in the link field.
+ */
+#ifndef FIRM_ANA_IRSIMPLETYPE_H
+#define FIRM_ANA_IRSIMPLETYPE_H
+
+#include "irgraph.h"
+#include "irnode.h"
+#include "typerep.h"
+
+
+
+/* ------------ Building and Removing the type information ----------- */
+
+/** Computes type information for each node in all ir graphs.
+ *
+ * Computes type information for each node. Stores the information in the
+ * field defined in irtypeinfo.h. Sets typestate in irg to irg_typeinfo_consistent.
+ *
+ * Derives the information from nodes/patterns that give hints about the
+ * type, as projecting an argument from the Start node. Deletes all previous
+ * type information.
+ *
+ * If a non-pointer type is specified for a pointer value (as the Alloc node does:
+ * it contains the type allocated, but to type the result we need the type that
+ * describes a pointer to the allocated type) searches for a corresponding pointer
+ * type. If several exist, uses one of them. If none exists, uses unknown_type.
+ *
+ * Uses the link field of types. Sets this field of each type to point to a
+ * pointer type that points to the type (Got it? ;-)).
+ */
+void simple_analyse_types(void);
+
+/** Frees all type information datastructures. Sets the flag in irg to "???". */
+void free_simple_type_information(void);
+
+/** Computes type information for a node.
+ *
+ * Computes type information for a node. Does not remark this type information
+ * in the ir. Computes the type information by analysing the predecessors.
+ * Calls the same basic analyses routine for a node as simple_analyse_types,
+ * but returns unknown_type for Phi nodes.
+ * Each call is theoretically O(n).
+ *
+ * Not yet implemented, but I guess we want this for iropt, to find the
+ * type for newly allocated constants.
+ */
+/* type *analyse_irn_type(ir_node *node); */
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Data structure to hold type information for nodes.
+ * @author Goetz Lindenmaier
+ * @date 28.8.2003
+ * @version $Id$
+ * @summary
+ * Data structure to hold type information for nodes.
+ *
+ * This module defines a field "type" of type "type *" for each ir node.
+ * It defines a flag for irgraphs to mark whether the type info of the
+ * graph is valid. Further it defines an auxiliary type "init_type".
+ */
+#ifndef FIRM_ANA_IRTYPEINFO_H
+#define FIRM_ANA_IRTYPEINFO_H
+
+#include "firm_types.h"
+
+/* ------------ Auxiliary type. --------------------------------------- */
+
+/** An auxiliary type used to express that a field is uninitialized.
+ *
+ * This auxiliary type expresses that a field is uninitialized. The
+ * variable is initialized by init_irtypeinfo(). The type is freed by
+ * free_irtypeinfo().
+ */
+extern ir_type *initial_type;
+
+
+
+/* ------------ Initializing this module. ----------------------------- */
+
+/** Initializes the type information module.
+ *
+ * Initializes the type information module.
+ * Generates a type inititial_type and sets the type of all nodes to this type.
+ * Calling set/get_irn_typeinfo_type() is invalid before calling init. Requires memory
+ * in the order of MIN(<calls to set_irn_typeinfo_type>, #irnodes).
+ */
+void init_irtypeinfo(void);
+void free_irtypeinfo(void);
+
+/* ------------ Irgraph state handling. ------------------------------- */
+
+/*
+#define irg_typeinfo_none ir_typeinfo_none
+#define irg_typeinfo_consistent ir_typeinfo_consistent
+#define irg_typeinfo_inconsistent ir_typeinfo_inconsistent
+#define irg_typeinfo_state ir_typeinfo_state
+*/
+
+typedef enum {
+ ir_typeinfo_none, /**< No typeinfo computed, calls to set/get_irn_typeinfo_type()
+ are invalid. */
+ ir_typeinfo_consistent, /**< Type info valid, calls to set/get_irn_typeinfo_type() return
+ the proper type. */
+ ir_typeinfo_inconsistent /**< Type info can be accessed, but it can be invalid
+ because of other transformations. */
+} ir_typeinfo_state;
+
+void set_irg_typeinfo_state(ir_graph *irg, ir_typeinfo_state s);
+ir_typeinfo_state get_irg_typeinfo_state(ir_graph *irg);
+
+/** Returns accumulated type information state information.
+ *
+ * Returns ir_typeinfo_consistent if the type information of all irgs is
+ * consistent. Returns ir_typeinfo_inconsistent if at least one irg has inconsistent
+ * or no type information. Returns ir_typeinfo_none if no irg contains type information.
+ */
+ir_typeinfo_state get_irp_typeinfo_state(void);
+void set_irp_typeinfo_state(ir_typeinfo_state s);
+/** If typeinfo is consistent, sets it to inconsistent. */
+void set_irp_typeinfo_inconsistent(void);
+
+/* ------------ Irnode type information. ------------------------------ */
+
+/** Accessing the type information.
+ *
+ * These routines only work properly if the ir_graph is in state
+ * ir_typeinfo_consistent or ir_typeinfo_inconsistent. They
+ * assume current_ir_graph set properly.
+ */
+ir_type *get_irn_typeinfo_type(ir_node *n);
+void set_irn_typeinfo_type(ir_node *n, ir_type *tp);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Check irnodes for correctness.
+ * @author Christian Schaefer, Goetz Lindenmaier, Till Riedel
+ * @version $Id$
+ */
+#ifndef FIRM_IR_IRVRFY_H
+#define FIRM_IR_IRVRFY_H
+
+#include "firm_types.h"
+
+/**
+ * Tests the modes of checknode and its predecessors.
+ * checknode must be in current_ir_graph.
+ *
+ * @return
+ * NON-zero on success
+ */
+int irn_vrfy(ir_node *checknode);
+
+/**
+ * Tests the modes of checknode and its predecessors.
+ * checknode must be in given ir_graph.
+ *
+ * @return
+ * NON-zero on success
+ */
+int irn_vrfy_irg(ir_node *checknode, ir_graph *irg);
+
+/**
+ * Same as irn_vrfy_irg, but temporary sets verification mode to
+ * NODE_VERIFICATION_ERROR_ONLY.
+ * @return
+ * NON-zero on success
+ */
+int irn_vrfy_irg_dump(ir_node *checknode, ir_graph *irg, const char **bad_string);
+
+/**
+ * Flags for irg_verify().
+ */
+typedef enum _irg_verify_flags_t {
+ VRFY_NORMAL = 0, /**< check SSA property only if dominance information is available */
+ VRFY_ENFORCE_SSA = 1 /**< check SSA property by enforcing the dominance information recalculation */
+} irg_verify_flags_t;
+
+/**
+ * Calls irn_vrfy() for each node in irg.
+ * Graph must be in state "op_pin_state_pinned".
+ *
+ * @return
+ * NON-zero on success.
+ */
+int irg_verify(ir_graph *irg, unsigned flags);
+
+/**
+ * Compatibility macro. Deprecated soon.
+ */
+#define irg_vrfy(irg) irg_verify(irg, 0)
+
+/**
+ * Possible flags for irg_vrfy_bads().
+ */
+enum verify_bad_flags_t {
+ BAD_CF = 1, /**< Bad nodes are allowed as predecessors of Blocks and Phis. */
+ BAD_DF = 2, /**< Bad nodes are allowed as dataflow predecessors. */
+ BAD_BLOCK = 4, /**< Bad nodes are allowed as Block input. */
+ TUPLE = 8 /**< Tuple nodes are allowed. */
+};
+
+/**
+ * Verify occurrence of bad nodes in a graph.
+ *
+ * @param irg The graph to verify
+ * @param flags combination of verify_bad_flags_t flags describing
+ * which Bads are allowed
+ * @returns a value combined of verify_bad_flags_t indicating the problems found.
+ */
+int irg_vrfy_bads(ir_graph *irg, int flags);
+
+/**
+ * Enable/disable verification of Load/Store nodes with
+ * its entities. If disabled, Store(SymConst(array)) will be allowed
+ * (C-frontend builds this :-)
+ */
+void vrfy_enable_entity_tests(int enable);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Lowering of Calls with compound parameters and return types.
+ * @author Michael Beck
+ * @version $Id$
+ */
+#ifndef FIRM_LOWER_LOWER_CALLS_H
+#define FIRM_LOWER_LOWER_CALLS_H
+
+/**
+ * A type telling where to add hidden parameters.
+ */
+typedef enum add_hidden_params {
+ ADD_HIDDEN_ALWAYS_IN_FRONT = 0, /**< always add hidden parameters in front (default). */
+ ADD_HIDDEN_ALWAYS_LAST = 1, /**< always add hidden parameters last, did not work for variadic functions. */
+ ADD_HIDDEN_SMART = 2 /**< add hidden parameters last for non-variadic and first for variadic functions. */
+} add_hidden;
+
+/**
+ * Additional flags for the lowering.
+ */
+enum lowering_flags {
+ LF_NONE = 0, /**< no additional flags */
+ LF_COMPOUND_PARAM = 1, /**< lower calls with compound parameters */
+ LF_COMPOUND_RETURN = 2, /**< lower calls with compound returns */
+ LF_RETURN_HIDDEN = 4, /**< return the hidden address instead of void */
+ LF_SMALL_CMP_IN_REGS = 8 /**< return small compound values in registers */
+};
+
+/** Maximum number of registers that can be used to return compound values. */
+#define MAX_REGISTER_RET_VAL 2
+
+/**
+ * A struct containing all control parameters for
+ * lower_compound_ret_calls().
+ */
+typedef struct {
+ int def_ptr_alignment; /**< Default alignment for data pointer. */
+ unsigned flags; /**< A bitmask of enum lowering_flags. */
+ add_hidden hidden_params; /**< Where to add hidden parameters. */
+
+ /**
+ * A function returning a pointer type for a given type.
+ * If this pointer is NULL, a new pointer type is always created.
+ */
+ ir_type *(*find_pointer_type)(ir_type *e_type, ir_mode *mode, int alignment);
+
+ /**
+ * If the LF_SMALL_CMP_IN_REGS flag is set, this function will be called
+ * to decide, whether a compound value should be returned in registers.
+ * This function must return the number of used registers and fill in the modes
+ * of the registers to use. Up to MAX_REGISTER_RET_VAL registers can be used.
+ */
+ int (*ret_compound_in_regs)(ir_type *compound_tp, ir_mode **modes);
+} lower_params_t;
+
+/**
+ * Lower calls with compound parameter and return types.
+ * This function does the following transformations:
+ *
+ * If LF_COMPOUND_PARAM is set:
+ *
+ * - Copy compound parameters to a new location on the callers
+ * stack and transmit the address of this new location
+ *
+ * If LF_COMPOUND_RETURN is set:
+ *
+ * - Adds a new (hidden) pointer parameter for
+ * any return compound type. The return type is replaced by void
+ * or if LOWERING_FLAGS_RETURN_HIDDEN is set by the address.
+ *
+ * - Use of the hidden parameters in the function code.
+ *
+ * - Change all calls to functions with compound return
+ * by providing space for the hidden parameter on the callers
+ * stack.
+ *
+ * - Replace a possible block copy after the function call.
+ *
+ * General:
+ *
+ * - Changes the types of methods and calls to the lowered ones
+ *
+ * - lower all method types of existing entities
+ *
+ * In pseudo-code, the following transformation is done:
+ *
+ @code
+ struct x ret = func(a, b);
+ @endcode
+ *
+ * is translated into
+ @code
+ struct x ret;
+ func(&ret, a, b);
+ @endcode
+ *
+ * If the function returns only one possible result, the copy-on-return
+ * optimization is done, ie.
+ @code
+ struct x func(a) {
+ struct x ret;
+ ret.a = a;
+ return ret;
+ }
+ @endcode
+ *
+ * is transformed into
+ *
+ @code
+ void func(struct x *ret, a) {
+ ret->a = a;
+ }
+ @endcode
+ *
+ * @param params A structure containing the control parameter for this
+ * transformation.
+ *
+ * During the transformation, pointer types must be created or reused.
+ * The caller can provide params->find_pointer_type for this task to
+ * reduce the number of created pointer types.
+ * If params->find_pointer_type is NULL, new pointer types
+ * are always created automatically.
+ */
+void lower_calls_with_compounds(const lower_params_t *params);
+
+#endif /* FIRM_LOWER_LOWER_CALLS_H */
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Lower Double word operations, ie 64bit -> 32bit, 32bit -> 16bit etc.
+ * @date 8.10.2004
+ * @author Michael Beck
+ * @version $Id$
+ */
+#ifndef FIRM_LOWER_LOWER_DW_H
+#define FIRM_LOWER_LOWER_DW_H
+
+#include "firm_types.h"
+
+/**
+ * A callback type for creating an intrinsic entity for a given opcode.
+ *
+ * @param method the method type of the emulation function entity
+ * @param op the emulated ir_op
+ * @param imode the input mode of the emulated opcode
+ * @param omode the output mode of the emulated opcode
+ * @param context the context parameter
+ */
+typedef ir_entity *(create_intrinsic_fkt)(ir_type *method, const ir_op *op,
+ const ir_mode *imode, const ir_mode *omode,
+ void *context);
+
+/**
+ * The lowering parameter description.
+ */
+typedef struct _lwrdw_param_t {
+ int enable; /**< if true lowering is enabled */
+ int little_endian; /**< if true should be lowered for little endian, else big endian */
+ ir_mode *high_signed; /**< the double word signed mode to be lowered, typically Ls */
+ ir_mode *high_unsigned; /**< the double word unsigned mode to be lowered, typically Lu */
+ ir_mode *low_signed; /**< the word signed mode to be used, typically Is */
+ ir_mode *low_unsigned; /**< the word unsigned mode to be used, typically Iu */
+
+ /** callback that creates the intrinsic entity */
+ create_intrinsic_fkt *create_intrinsic;
+ void *ctx; /**< context parameter for the creator function */
+} lwrdw_param_t;
+
+/**
+ * Lower all double word operations.
+ */
+void lower_dw_ops(const lwrdw_param_t *param);
+
+/**
+ * Default implementation. Context is unused.
+ */
+ir_entity *def_create_intrinsic_fkt(ir_type *method, const ir_op *op,
+ const ir_mode *imode, const ir_mode *omode,
+ void *context);
+
+#endif /* FIRM_LOWER_LOWER_DW_H */
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Lower some High-level constructs, moved from the firmlower.
+ * @author Boris Boesler, Goetz Lindenmaier, Michael Beck
+ * @version $Id$
+ */
+#ifndef FIRM_LOWER_LOWER_HL_H
+#define FIRM_LOWER_LOWER_HL_H
+
+/**
+ * Replaces SymConsts by a real constant if possible.
+ * Replace Sel nodes by address computation. Also resolves array access.
+ * Handle Bitfields by added And/Or calculations.
+ *
+ * @Note: There is NO lowering ob objects oriented types. This is highly compiler
+ * and ABI specific and should be placed directly in the compiler.
+ */
+void lower_highlevel(void);
+
+#endif /* FIRM_LOWER_LOWER_HL_H */
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief lowering of Calls of intrinsic functions
+ * @author Michael Beck
+ * @version $Id$
+ */
+#ifndef FIRM_LOWER_LOWER_INTRINSICS_H
+#define FIRM_LOWER_LOWER_INTRINSICS_H
+
+#include "firm_types.h"
+
+/**
+ * An intrinsic mapper function.
+ *
+ * @param node the IR-node that will be mapped
+ * @param ctx a context
+ *
+ * @return non-zero if the call was mapped
+ */
+typedef int (*i_mapper_func)(ir_node *node, void *ctx);
+
+enum ikind {
+ INTRINSIC_CALL = 0, /**< the record represents an intrinsic call */
+ INTRINSIC_INSTR /**< the record represents an intrinsic instruction */
+};
+
+/**
+ * An intrinsic call record.
+ */
+typedef struct _i_call_record {
+ enum ikind kind; /**< must be INTRINSIC_CALL */
+ ir_entity *i_ent; /**< the entity representing an intrinsic call */
+ i_mapper_func i_mapper; /**< the mapper function to call */
+ void *ctx; /**< mapper context */
+ void *link; /**< used in the construction algorithm, must be NULL */
+} i_call_record;
+
+/**
+ * An intrinsic instruction record.
+ */
+typedef struct _i_instr_record {
+ enum ikind kind; /**< must be INTRINSIC_INSTR */
+ ir_op *op; /**< the opcode that must be mapped. */
+ i_mapper_func i_mapper; /**< the mapper function to call */
+ void *ctx; /**< mapper context */
+ void *link; /**< used in the construction algorithm, must be NULL */
+} i_instr_record;
+
+/**
+ * An intrinsic record.
+ */
+typedef union _i_record {
+ i_call_record i_call;
+ i_instr_record i_instr;
+} i_record;
+
+/**
+ * Go through all graphs and map calls to intrinsic functions and instructions.
+ *
+ * Every call or instruction is reported to its mapper function,
+ * which is responsible for rebuilding the graph.
+ *
+ * current_ir_graph is always set.
+ *
+ * @param list an array of intrinsic map records
+ * @param length the length of the array
+ *
+ * @return number of found intrinsics.
+ */
+unsigned lower_intrinsics(i_record *list, int length);
+
+/**
+ * A mapper for the integer absolute value: inttype abs(inttype v).
+ * Replaces the call by a Abs node.
+ *
+ * @return always 1
+ */
+int i_mapper_Abs(ir_node *call, void *ctx);
+
+/**
+ * A mapper for the alloca() function: pointer alloca(inttype size)
+ * Replaces the call by a Alloca(stack_alloc) node.
+ *
+ * @return always 1
+ */
+int i_mapper_Alloca(ir_node *call, void *ctx);
+
+/**
+ * A runtime routine description.
+ */
+typedef struct _runtime_rt {
+ ir_entity *ent; /**< The entity representing the runtime routine. */
+ ir_mode *mode; /**< The operation mode of the mapped instruction. */
+ ir_mode *res_mode; /**< The result mode of the mapped instruction or NULL. */
+ long mem_proj_nr; /**< if >= 0, create a memory ProjM() */
+ long regular_proj_nr; /**< if >= 0, create a regular ProjX() */
+ long exc_proj_nr; /**< if >= 0, create a exception ProjX() */
+ long exc_mem_proj_nr; /**< if >= 0, create a exception memory ProjM() */
+ long res_proj_nr; /**< if >= 0, first result projection number */
+} runtime_rt;
+
+/**
+ * A mapper for mapping unsupported instructions to runtime calls.
+ * Maps a op(arg_0, ..., arg_n) into a call to a runtime function
+ * rt(arg_0, ..., arg_n).
+ *
+ * The mapping is only done, if the modes of all arguments matches the
+ * modes of rt's argument.
+ * Further, if op has a memory input, the generated Call uses it, else
+ * it gets a NoMem.
+ * The pinned state of the Call will be set to the pinned state of op.
+ *
+ * Note that i_mapper_RuntimeCall() must be used with a i_instr_record.
+ *
+ * @return 1 if an op was mapped, 0 else
+ *
+ * Some examples:
+ *
+ * - Maps signed Div nodes to calls to rt_Div():
+ @code
+ runtime_rt rt_Div = {
+ ent("int rt_Div(int, int)"),
+ mode_T,
+ mode_Is,
+ pn_Div_M,
+ pn_Div_X_regular,
+ pn_Div_X_except,
+ pn_Div_M,
+ pn_Div_res
+ };
+ i_instr_record map_Div = {
+ INTRINSIC_INSTR,
+ op_Div,
+ i_mapper_RuntimeCall,
+ &rt_Div,
+ NULL
+ };
+ @endcode
+ *
+ * - Maps ConvD(F) to calls to rt_Float2Div():
+ @code
+ runtime_rt rt_Float2Double = {
+ ent("double rt_Float2Div(float)"),
+ get_type_mode("double"),
+ NULL,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1
+ };
+ i_instr_record map_Float2Double = {
+ INTRINSIC_INSTR,
+ op_Conv,
+ i_mapper_RuntimeCall,
+ &rt_Float2Double,
+ NULL
+ };
+ @endcode
+ */
+int i_mapper_RuntimeCall(ir_node *node, runtime_rt *rt);
+
+#endif /* FIRM_LOWER_LOWER_INTRINSICS_H */
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Some makros supporting old function names.
+ * @author Goetz Lindenmaier
+ * @version $Id$
+ */
+#ifndef FIRM_COMMON_OLD_FCTNAMES_H
+#define FIRM_COMMON_OLD_FCTNAMES_H
+
+/* firmstat */
+#define stat_init init_stat
+
+/* ircons */
+#define add_in_edge(X, Y) add_immBlock_pred(X, Y)
+#define mature_block(X) mature_immBlock(X)
+#define switch_block(X) set_cur_block(X)
+#define finalize_cons(X) irg_finalize_cons(X)
+
+/* irgraph */
+#define get_irg_ent(X) get_irg_entity(X)
+#define get_irg_params get_irg_n_locs
+#define get_irg_n_loc get_irg_n_locs
+#define set_irg_ent(X, Y) set_irg_entity(X, Y)
+#define set_irg_params set_irg_n_loc
+#define no_dom dom_none
+#define no_outs outs_none
+
+/* irnode.h */
+#define get_Return_n_res get_Return_n_ress
+#define get_Sel_n_index get_Sel_n_indexs
+#define get_SymConst_ptrinfo get_SymConst_name
+#define set_SymConst_ptrinfo set_SymConst_name
+#define type_tag symconst_type_tag
+#define size symconst_type_size
+#define symconst_size symconst_type_size
+#define linkage_ptr_info symconst_addr_name
+
+#define get_nodes_Block(X) get_nodes_block(X)
+#define set_nodes_Block(X, Y) set_nodes_block(X, Y)
+#define get_Start_irg(X) get_irn_irg(X)
+#define get_EndReg_irg(X) get_irn_irg(X)
+#define get_EndExcept_irg(X) get_irn_irg(X)
+#define get_CallBegin_irg(X) get_irn_irg(X)
+#define get_ip_cfop_irg(X) get_irn_irg(X)
+#define skip_nop(X) skip_Id(X)
+
+#define pns_initial_exec pn_Start_X_initial_exec
+#define pns_global_store pn_Start_M
+#define pns_frame_base pn_Start_P_frame_base
+#define pns_args pn_Start_T_args
+#define pns_value_arg_base pn_Start_P_value_arg_base
+
+#define pnc_number pn_Cmp
+#define False pn_Cmp_False
+#define Eq pn_Cmp_Eq
+#define Lt pn_Cmp_Lt
+#define Le pn_Cmp_Le
+#define Gt pn_Cmp_Gt
+#define Ge pn_Cmp_Ge
+#define Lg pn_Cmp_Lg
+#define Leg pn_Cmp_Leg
+#define Uo pn_Cmp_Uo
+#define Ue pn_Cmp_Ue
+#define Ul pn_Cmp_Ul
+#define Ule pn_Cmp_Ule
+#define Ug pn_Cmp_Ug
+#define Uge pn_Cmp_Uge
+#define Ne pn_Cmp_Ne
+#define True pn_Cmp_True
+
+/* irmode.h */
+#define get_ident_of_mode get_mode_ident
+#define get_size_of_mode get_mode_size
+#define get_ld_align_of_mode get_mode_ld_align
+#define get_min_of_mode get_mode_min
+#define get_max_of_mode get_mode_max
+#define get_mode_vector_elems(X) get_mode_n_vector_elems(X)
+#define get_null_of_mode get_mode_null
+#define get_fsigned_of_mode get_mode_fsigned
+#define get_ffloat_of_mode get_mode_ffloat
+#define get_mode_size(X) (assert(get_mode_size_bytes(X) != -1), get_mode_size_bytes(X))
+
+
+/* irop */
+#define floats op_pin_state_floats
+#define pinned op_pin_state_pinned
+#define op_pinned op_pin_state
+
+/* irdump */
+#define dump_cg_graph dump_ir_graph
+#define dump_cg_block_graph dump_ir_block_graph
+#define dont_dump_loop_information() dump_loop_information(0)
+
+/* type.h */
+typedef ir_type type;
+#define get_type_nameid(_t_) get_type_ident(_t_)
+#define set_type_nameid(_t_,_i_) set_type_ident(_t_,_i_)
+#define get_class_n_member get_class_n_members
+#define get_class_n_subtype get_class_n_subtypes
+#define get_class_n_supertype get_class_n_supertypes
+#define get_struct_n_member get_struct_n_members
+
+#define get_method_n_res(X) get_method_n_ress(X)
+
+/* entity.h */
+#define ent_visibility ir_visibility
+#define ent_allocation ir_allocation
+#define ent_stickyness ir_stickyness
+#define ent_volatility ir_volatility
+#define peculiarity ir_peculiarity
+#define entity ir_entity
+#define get_entity_offset_bytes(ent) get_entity_offset(ent)
+#define set_entity_offset_bytes(ent, ofs) set_entity_offset(ent, ofs)
+
+/* tv.h */
+#define tarval_from_long(X, Y) new_tarval_from_long(Y, X)
+#define tarval_P_from_entity(X) new_tarval_from_entity(X, mode_P_mach)
+#define tarval_to_entity(X) get_tarval_entity(X)
+#define tarval_to_long(X) get_tarval_long(X)
+#define tarval_to_double(X) get_tarval_double(X)
+#define tarval_set_mode_output_option(X, Y) set_tarval_mode_output_option(X, Y)
+#define tarval_get_mode_output_option(X) get_tarval_mode_output_option(X)
+#define tarval_bitpattern(X) get_tarval_bitpattern(X)
+#define tarval_sub_bits(X, Y) get_tarval_sub_bits(X, Y)
+#define tarval_classify(X) classify_tarval(X)
+#define get_tarval_P_void() get_tarval_null(mode_P)
+#define tarval_P_void get_tarval_null(mode_P)
+
+#define tarval_is_entity(X) 0
+#define get_tarval_entity(X) ((ir_entity *)NULL)
+
+/* ident.h */
+#define id_to_strlen(X) get_id_strlen(X)
+#define id_to_str(X) get_id_str(X)
+#define id_from_str(X, Y) new_id_from_chars(X, Y)
+
+/* irouts.h */
+#define compute_outs(X) compute_irg_outs(X)
+
+/* tr_inheritance.h */
+#define is_subclass_of(low, high) is_SubClass_of(low, high)
+#define is_subclass_ptr_of(low, high) is_SubClass_ptr_of(low, high)
+#define is_superclass_of(high, low) is_SuperClass_of(high, low)
+#define is_superclass_ptr_of(low, high) is_SuperClass_ptr_of(low, high)
+
+/* previously in irvrfy.h, now in irflag.h */
+#define NODE_VERIFICATION_OFF FIRM_VERIFICATION_OFF
+#define NODE_VERIFICATION_ON FIRM_VERIFICATION_ON
+#define NODE_VERIFICATION_REPORT FIRM_VERIFICATION_REPORT
+#define NODE_VERIFICATION_ERROR_ONLY FIRM_VERIFICATION_ERROR_ONLY
+
+/* execfreq.h */
+#define exec_freq_t ir_exec_freq
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Analysis to compute phi congruence classes.
+ * @author Daniel Grund
+ * @version $Id$
+ * @date 15.01.2005
+ */
+#ifndef FIRM_ANA_PHICLASS_H
+#define FIRM_ANA_PHICLASS_H
+
+#include "pset.h"
+#include "irgraph.h"
+#include "irnode.h"
+#include "irnodeset.h"
+
+typedef struct _phi_classes_t phi_classes_t;
+
+/**
+ * Return the array containing all nodes assigned to the same Phi class as @p irn.
+ */
+ir_node **get_phi_class(phi_classes_t *pc, ir_node *irn);
+
+/**
+ * Assigns a new array of nodes representing the new Phi class to @p irn.
+ */
+void set_phi_class(phi_classes_t *pc, ir_node *irn, ir_node **cls);
+
+/**
+ * Returns a set containing all computed Phi classes.
+ */
+pset *get_all_phi_classes(phi_classes_t *pc);
+
+/**
+ * Builds the Phi classes for all Phis in @p irg.
+ * @param irg The irg the classes should be build for
+ * @param pure_phi_classes Set to one if Phi classes should only contain Phi nodes.
+ * Beware: This might result in different (more) Phi classes as if not set
+ * @return The Phi class object for the @p irg.
+ */
+phi_classes_t *phi_class_new_from_irg(ir_graph *irg, int pure_phi_classes);
+
+/**
+ * Builds all Phi classes for the given set of Phis.
+ * @param irg The irg, the Phis are from
+ * @param all_phis An ir_nodeset containing all Phis nodes to build the classes for
+ * @param pure_phi_classes Set to one if Phi classes should only contain Phi nodes.
+ * Beware: This might result in different (more) Phi classes as if not set
+ * @return The Phis class object for @p all_phis.
+ */
+phi_classes_t *phi_class_new_from_set(ir_graph *irg, ir_nodeset_t *all_phis, int pure_phi_classes);
+
+/**
+ * Free all allocated data.
+ */
+void phi_class_free(phi_classes_t *pc);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Interprocedural analysis to improve the call graph estimate.
+ * @author Florian
+ * @date 09.06.2002
+ * @version $Id$
+ * @summary
+ * (TODO translate to english)
+ * Intraprozedurale Analyse zur Abschätzung der Aufrufrelation. Es wird
+ * die Menge der instantiierten Klassen bestimmt, und daraus eine Abschätzung
+ * der aufgerufenen Methoden.
+ *
+ * Voraussetzung ist, dass das Programm keine Methodenzeiger handhaben kann.
+ * In diesem Fall koennten Methoden verloren gehen. Oder wir muessen nach
+ * allen "freien" Methoden suchen (siehe cgana).
+ *
+ * @@@ Die Analyse sollte wissen, von welchen Klassen Instanzen ausserhalb
+ * der Uebersetzungseinheit alloziert werden koennen. Diese muessen in
+ * die initiale Menge allozierter Klassen aufgenommern werden.
+ *
+ * Nach: David F. Bacon and Peter F. Sweeney,
+ * Fast static analysis of C++ virtual function calls
+ * OOPSLA 1996
+ */
+#ifndef FIRM_ANA_RTA_H
+#define FIRM_ANA_RTA_H
+
+#include "firm_types.h"
+
+/**
+ * Initialise the RTA data structures and perform RTA.
+ *
+ * @param do_verbose If == 1, print statistics, if > 1, chatter about every detail
+ */
+void rta_init(int do_verbose);
+
+/**
+ * Delete all graphs that have been found to be dead.
+ */
+void rta_delete_dead_graphs (void);
+
+/** Clean up our data structures.
+ * Finishes the RTA.
+ */
+void rta_cleanup(void);
+
+/** Returns non-zero if the given class is alive. */
+int rta_is_alive_class(ir_type *clazz);
+
+/** Returns non-zero if the given graph is alive. */
+int rta_is_alive_graph(ir_graph *graph);
+
+/** report for all graphs and types whether they are alive */
+void rta_report(void);
+
+#endif
+
+/*
+ * $Log$
+ * Revision 1.15 2006/12/18 16:02:21 beck
+ * removed useles include
+ *
+ * Revision 1.14 2006/01/13 21:52:00 beck
+ * renamed all types 'type' to 'ir_type'
+ *
+ * Revision 1.13 2004/10/21 07:23:34 goetz
+ * comments
+ *
+ * Revision 1.12 2004/10/20 14:59:27 liekweg
+ * Removed ecg
+ *
+ * Revision 1.11 2004/10/18 12:47:46 liekweg
+ * minor fix
+ *
+ * Revision 1.10 2004/09/24 13:59:04 beck
+ * fixed doxygen comments, removed initialization for description entities
+ *
+ * Revision 1.9 2004/08/19 16:51:02 goetz
+ * fixed some errors, pushed closer to inteded firm semantics
+ *
+ * Revision 1.8 2004/06/18 17:34:31 liekweg
+ * Removed field checks --flo
+ *
+ * Revision 1.7 2004/06/18 13:12:43 liekweg
+ * final bug fix (calls via consts)
+ *
+ * Revision 1.6 2004/06/17 14:21:14 liekweg
+ * major bugfix
+ *
+ * Revision 1.5 2004/06/17 08:33:01 liekweg
+ * Added comments; added remove_irg
+ *
+ * Revision 1.4 2004/06/15 11:44:54 beck
+ * New inlining schema implemented:
+ *
+ * small functions that should be inlined in libFirm are implemented in _t.h files
+ * with a __ prefix.
+ * Preprocessor magic is used to automatically inline these functions whenever a _t.h
+ * file is included instead of a .h file.
+ * Note that this magic did not work outside libFirm without accessing _t.h files.
+ *
+ * Revision 1.3 2004/06/13 15:03:45 liekweg
+ * RTA auf Iterative RTA aufgebohrt --flo
+ *
+ * Revision 1.2 2004/06/12 17:09:46 liekweg
+ * RTA works, outedges breaks. "Yay." --flo
+ *
+ * Revision 1.1 2004/06/11 18:24:18 liekweg
+ * Added RTA --flo
+ *
+ */
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Implements simple sequence numbers for Firm debug info.
+ * @author Michael Beck
+ * @date 2005
+ * @version $Id$
+ * @summary
+ * Sequence numbers for Firm.
+ *
+ * A sequence number is an unique number representing a filename
+ * and a line number. The number 0 represents empty information.
+ * This module is an optional "snap-in" for the Firm debug info.
+ * In simple cases it should be possible to use sequence numbers
+ * as dbg_info.
+ */
+#ifndef FIRM_DEBUG_SEQNUMBERS_H
+#define FIRM_DEBUG_SEQNUMBERS_H
+
+#include "ident.h"
+
+/**
+ * @typedef seqno_t
+ *
+ * An opaque type for a sequence number.
+ */
+
+/**
+ * Create a new sequence number from a filename and a line number.
+ *
+ * @param filename a file name
+ * @param lineno a line number
+ *
+ * @return a sequence number for this position.
+ */
+seqno_t firm_seqno_enter(const char *filename, unsigned lineno);
+
+/**
+ * Create a new sequence number from a filename ident and a line number.
+ *
+ * @param filename an ident
+ * @param lineno a line number
+ *
+ * @return a sequence number for this position.
+ */
+seqno_t firm_seqno_enter_id(ident *filename, unsigned lineno);
+
+/**
+ * Retrieve filename and line number from a sequence number.
+ *
+ * @param seqno a sequence number
+ * @param lineno after return contains the line number of this position
+ *
+ * @return the file name of this position.
+ */
+const char *firm_seqno_retrieve(seqno_t seqno, unsigned *lineno);
+
+/**
+ * Creates the sequence number pool.
+ * Is not called by init_firm(), because the sequence number
+ * support is optional. Call firm_seqno_init() after init_firm()
+ * if sequence numbers should be used.
+ */
+void firm_seqno_init(void);
+
+/**
+ * Terminates the sequence number pool.
+ * Sequence numbers cannot be resolved anymore.
+ * Call this function to terminate the sequence
+ * pool.
+ */
+void firm_seqno_term(void);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief structure analysis
+ * @author Michael Beck
+ * @date 05.04.2007
+ * @version $Id$
+ */
+#ifndef FIRM_ANA_STRUCTURE_H
+#define FIRM_ANA_STRUCTURE_H
+
+#include "firm_types.h"
+
+/**
+ * This enum describes the different regions constructed by the structural analysis.
+ */
+typedef enum ir_region_kind {
+ ir_rk_Unknown, /**< Unknown region kind. */
+ ir_rk_BasicBlock, /**< A Basic Block simply wraps a firm basic block, needed for the construction. */
+ /*
+ * part0->part1->...->partn->XXX
+ */
+ ir_rk_Sequence, /**< A sequence of regions. */
+ /*
+ * part0
+ * / |
+ * part1 |
+ * \ |
+ * XXX
+ */
+ ir_rk_IfThen, /**< An if-then. */
+ /*
+ * part0
+ * / \
+ * part1 part2
+ * \ /
+ * XXX
+ */
+ ir_rk_IfThenElse, /**< An if-then-else. */
+ /*
+ * part0
+ * / \
+ * part1 ... partn
+ * \ /
+ * XXX
+ */
+ ir_rk_Case, /**< A Case like in Pascal. No fall through is allowed. */
+ /*
+ * part0
+ * / | \
+ * part1->part2 partn
+ * \ /
+ * XXX
+ */
+ ir_rk_Switch, /**< A Switch like in C. At least one fall through exists. */
+ ir_rk_Proper, /**< A proper region. Any other DAG. */
+ ir_rk_TryCatch, /**< A TryCatch Exception handling. */
+ ir_rk_TryCatchFinally, /**< A TryCatchFinally Exception handling. */
+ /*
+ * +-+
+ * v |
+ * part0
+ */
+ ir_rk_SelfLoop, /**< A self loop. In Firm always a repeat or endless loop. */
+ /*
+ * part0
+ * | ^
+ * v |
+ * part1
+ * |
+ * v
+ * XXX
+ */
+ ir_rk_RepeatLoop, /**< A Repeat loop. */
+ /*
+ * part0 ---> XXX
+ * | ^
+ * v |
+ * part1
+ */
+ ir_rk_WhileLoop, /**< A While loop. */
+ /*
+ * Arbitrary loop with single head.
+ */
+ ir_rk_NaturalLoop, /**< A natural loop. */
+ ir_rk_Improper, /**< An improper region. May contain everything. */
+} ir_region_kind;
+
+/** Returns non-zero if a region contains loops. */
+#define is_loop_region(type) ((type) >= ir_rk_SelfLoop)
+
+/**
+ * Returns the link of a region.
+ *
+ * @param reg the region
+ */
+void *get_region_link(const ir_region *reg);
+
+/**
+ * Sets the link of a region.
+ *
+ * @param reg the region
+ * @param data the data
+ */
+void set_region_link(ir_region *reg, void *data);
+
+/**
+ * Get the immediate region of a block.
+ *
+ * @param block a block node
+ */
+ir_region *get_block_region(const ir_node *block);
+
+/**
+ * Sets the immediate region of a block.
+ *
+ * @param block a block node
+ * @param reg the region
+ */
+void set_block_region(ir_node *block, ir_region *reg);
+
+/**
+ * Get the immediate region of a node.
+ *
+ * @param n a Firm IR node
+ */
+ir_region *get_irn_region(ir_node *n);
+
+/**
+ * Return non-if a given firm thing is a region.
+ *
+ * @param thing a Firm object address
+ */
+int is_region(const void *thing);
+
+/**
+ * Return the number of predecessors in a region.
+ *
+ * @param reg the region
+ */
+int get_region_n_preds(const ir_region *reg);
+
+/**
+ * Return the predecessor region at position pos.
+ *
+ * @param reg the region
+ */
+ir_region *get_region_pred(const ir_region *reg, int pos);
+
+/**
+ * Set the predecessor region at position pos.
+ *
+ * @param reg the region
+ * @param pos the position number
+ * @param n the new predecessor region
+ */
+void set_region_pred(ir_region *reg, int pos, ir_region *n);
+
+/**
+ * Return the number of successors in a region.
+ *
+ * @param reg the region
+ */
+int get_region_n_succs(const ir_region *reg);
+
+/**
+ * Return the successor region at position pos.
+ *
+ * @param reg the region
+ * @param pos the position number
+ */
+ir_region *get_region_succ(const ir_region *reg, int pos);
+
+/**
+ * Set the successor region at position pos.
+ *
+ * @param reg the region
+ * @param pos the position number
+ * @param n the new successor region
+ */
+void set_region_succ(ir_region *reg, int pos, ir_region *n);
+
+/**
+ * Construct the region tree of a graph by doing
+ * structural analysis.
+ *
+ * Uses link fields of nodes.
+ *
+ * @param irg the graph
+ *
+ * @return the region tree
+ */
+ir_reg_tree *construct_region_tree(ir_graph *irg);
+
+/**
+ * Walk over the region tree.
+ *
+ * @param tree the tree
+ * @param pre walker function, executed before the children of a tree node are visited
+ * @param post walker function, executed after the children of a tree node are visited
+ * @param env environment, passed to pre and post
+ */
+void region_tree_walk(ir_reg_tree *tree, irg_reg_walk_func *pre, irg_reg_walk_func *post, void *env);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Reverse edges that reference types/entities.
+ * @author Goetz Lindenmaier
+ * @date 29.10.2004
+ * @version $Id$
+ * @summary
+ * Trouts list all uses of types and entities.
+ * Each type gets a list of all Alloc nodes allocating it.
+ * Each entity gets two lists:
+ * - one containing all accesses (Load, (Call), Store),
+ * - and one containing all uses to get a reference (Sel, SymConst).
+ *
+ * @todo
+ * To list all uses of entities of a type, we also should list all
+ * static/automatic allocated entities in types. The Alloc nodes
+ * represent only the dynamic allocated entities.
+ */
+#ifndef FIRM_ANA_TROUTS_H
+#define FIRM_ANA_TROUTS_H
+
+#include "firm_types.h"
+#include "irgraph.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. */
+int get_entity_n_accesses(ir_entity *ent);
+/** Load/Store node that possibly access this entity. */
+ir_node *get_entity_access(ir_entity *ent, int pos);
+
+/** Number of references to an entity, in form of SymConst/Sel.
+ * Including references from constant entities and the like. */
+int get_entity_n_references(ir_entity *ent);
+/** References to an entity, in form of SymConst/Sel
+ * Including references from constants. */
+ir_node *get_entity_reference(ir_entity *ent, int pos);
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+/* types */
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+/** Number of Alloc nodes that create an instance of this type. */
+int get_type_n_allocs(ir_type *tp);
+/** Alloc node that create an instance of this type. */
+ir_node *get_type_alloc(ir_type *tp, int pos);
+
+/** Number of Cast nodes that cast a pointer to this type. */
+int get_type_n_casts(ir_type *tp);
+/** Cast node that cast a pointer to this type. */
+ir_node *get_type_cast(ir_type *tp, int pos);
+void add_type_cast(ir_type *tp, ir_node *cast);
+/** Return number of upcasts. O(#casts). */
+int get_class_n_upcasts(ir_type *clss);
+/** Return number of downcasts. O(#casts). */
+int get_class_n_downcasts(ir_type *clss);
+
+/* Access all pointer types that point to tp. */
+int get_type_n_pointertypes_to(ir_type *tp);
+ir_type *get_type_pointertype_to(ir_type *tp, int pos);
+void add_type_pointertype_to(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. */
+int get_type_n_arraytypes_of(ir_type *tp);
+ir_type *get_type_arraytype_of(ir_type *tp, int pos);
+void add_type_arraytype_of(ir_type *tp, ir_type *atp);
+
+
+
+/* @@@ TODO: compute all entities that use a type. */
+
+/*------------------------------------------------------------------*/
+/* Building and Removing the trout datastructure */
+/*------------------------------------------------------------------*/
+
+/** The state of the tr_out datastructure.
+ *
+ * We reuse the enum of irouts.
+ * @see irouts.h. */
+irg_outs_state get_trouts_state(void);
+/** Set the tr out state to inconsistent if it is consistent. */
+void set_trouts_inconsistent(void);
+
+/** Compute the outs of types and entities.
+ *
+ * Collects all reference from irnodes to types or entities in the
+ * corresponding types/entities. Further reverses references between
+ * types and entities.
+ *
+ * Annotates the following nodes:
+ * Alloc --> get_Alloc_type()
+ * Cast --> get_Cast_type()
+ * Sel --> get_Sel_entity()
+ * SymConst --> get_SymConst_entity()
+ * Load(addr) --> get_addr_entity() \ ent von SymConst, oder falls Sel: ent von
+ * Store(addr) --> get_addr_entity() / outermost im compound. Ansonsten: nirgends.
+ * d.h. wir bekommen die array Elementzugriffe
+ * an die jack array Klasse annotiert.
+ * Call(Sel) --> get_Sel_entity() // ev. Tabellenzugriff --> Load.
+ *
+ * type --> pointer type refering to this type.
+ * type --> entity of this type. @@@ to be implemented.
+ *
+ * Sets trout state to outs_consistent.
+ */
+void compute_trouts(void);
+
+/** Free trout data. */
+void free_trouts(void);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Representation of and static computations on target machine
+ * values.
+ * @date 2003
+ * @author Mathias Heil
+ * @version $Id$
+ * @summary
+ * Tarvals represent target machine values. They are typed by modes.
+ * Tarvals only represent values of mode_sort:
+ * - int_number,
+ * - float_number,
+ * - boolean,
+ * - reference,
+ * - character
+ *
+ * In case of references the module accepts an entity to represent the
+ * value.
+ * Furthermore, computations and conversions of these values can
+ * be performed.
+ *
+ * HISTORY
+ * The original tv module originated in the fiasco compiler written ...
+ * This is the new version, described in the tech report 1999-14 by ...
+ *
+ * @sa
+ * Techreport 1999-14
+ * irmode.h for the modes definitions
+ * irnode.h for the pn_Cmp table
+ */
+#ifndef FIRM_TV_TV_H
+#define FIRM_TV_TV_H
+
+#include "firm_types.h"
+#include "irnode.h"
+
+/* ************************ Constructors for tarvals ************************ */
+
+/**
+ * Constructor function for new tarvals.
+ *
+ * @param str The string representing the target value
+ * @param len The length of the string
+ * @param mode The mode requested for the result tarval
+ *
+ * This function creates a new tarval representing the value represented
+ * by a CString, aka char array. If a tarval representing this value already
+ * exists, this tarval is returned instead of a new one. So tarvals are
+ * directly comparable since their representation is unique.
+ *
+ * This function accepts the following strings:
+ *
+ * if mode is int_number:
+ * - 0(x|X)[0-9a-fA-F]+ (hexadecimal representation)
+ * - 0[0-7]* (octal representation)
+ * - (+|-)?[1-9][0-9]* (decimal representation)
+ *
+ * if mode if float_number:
+ * - (+|-)?(decimal int) (. (decimal int))? ((e|E)(+|-)?(decimal int))?
+ *
+ * if mode is boolean: true, True, TRUE ... False... 0, 1,
+ *
+ * if mode is reference: hexadecimal of decimal number as int
+ *
+ * if mode is character: hex or dec
+ *
+ * Leading and/or trailing spaces are ignored
+ *
+ * @return
+ * A tarval of proper type representing the requested value is returned.
+ * Tarvals are unique, so for any value/mode pair at most one tarval will
+ * exist, which will be returned upon further requests with an identical
+ * value/mode pair.
+ *
+ * @note
+ * If the string is not representable in the given mode an assertion is
+ * thrown in assert build.
+ *
+ * @sa
+ * irmode.h for predefined modes
+ * new_tarval_from_long()
+ * new_tarval_from_double()
+ */
+tarval *new_tarval_from_str(const char *str, size_t len, ir_mode *mode);
+
+/**
+ * Constructor function for new tarvals
+ *
+ * @param l The long representing the value
+ * @param mode The mode requested for the result tarval
+ *
+ * This function creates a new tarval representing the value represented
+ * by a long integer. If a tarval representing this value already exists,
+ * this tarval is returned instead of a new one. So tarvals are directly
+ * comparable since their representation is unique.
+ *
+ * @return
+ * A tarval of proper type representing the requested value is returned.
+ * Tarvals are unique, so for any value/mode pair at most one tarval will
+ * exist, which will be returned upon further requests with an identical
+ * value/mode pair.
+ *
+ * @note
+ * If the long is not representable in the given mode an assertion is
+ * thrown in assert build.
+ *
+ * @sa
+ * irmode.h for predefined modes
+ * new_tarval_from_str()
+ * new_tarval_from_double()
+ *
+ */
+tarval *new_tarval_from_long(long l, ir_mode *mode);
+
+/** Return value as long if possible.
+ *
+ * This returns a long int with the value represented value, or
+ * gibberish, depending on the size of long int and the size of the
+ * stored value. It works for e.g. 1 as mode_Ls, but might not work for
+ * get_mode_max(mode_Ls).
+ * This will overflow silently, so use only if you know what
+ * you are doing! (better check with tarval_is_long()...)
+ * Works only for int modes, even not for character modes!
+ */
+long get_tarval_long(tarval *tv);
+
+/**
+ * This validates if get_tarval_long() will return a satisfying
+ * result. I.e. if tv is an int_number and between min, max
+ * of long int (signed!)
+ */
+int tarval_is_long(tarval *tv);
+
+/**
+ * Constructor function for new tarvals.
+ *
+ * @param d The (long) double representing the value
+ * @param mode The mode requested for the result tarval
+ *
+ * This function creates a new tarval representing the value represented
+ * by a (long) double. If a tarval representing this value already exists,
+ * this tarval is returned instead of a new one. So tarvals are directly
+ * comparable since their representation is unique.
+ * Only modes of sort float_number can be constructed this way.
+ *
+ * @return
+ * A tarval of proper type representing the requested value is returned.
+ * Tarvals are unique, so for any value/mode pair at most one tarval will
+ * exist, which will be returned upon further requests with an identical
+ * value/mode pair.
+ *
+ * @note
+ * If the (long) double is not representable in the given mode an assertion
+ * is thrown. This will happen for any mode not of sort float_number.
+ *
+ * @sa
+ * irmode.h for predefined values
+ * new_tarval_from_str()
+ * new_tarval_from_long()
+ */
+tarval *new_tarval_from_double(long double d, ir_mode *mode);
+
+/**
+ * This returns a double with the value represented value, or
+ * gibberish, depending on the size of double and the size of the
+ * stored value.
+ * This will overflow silently, so use only if you know what
+ * you are doing! (better check with tarval_is_long...)
+ */
+long double get_tarval_double(tarval *tv);
+
+/**
+ * This validates if tarval_to_double() will return a satisfying
+ * result. I.e. if tv is an float_number and between min, max
+ * of double
+ */
+int tarval_is_double(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. */
+ir_mode *get_tarval_mode (const tarval *tv);
+
+/** Returns the contents of the 'link' field of the tarval */
+/* void *get_tarval_link (tarval*); */
+
+/* Testing properties of the represented values */
+
+/**
+ * Returns 1 if tv is negative
+ *
+ * @param a the tarval
+ */
+int tarval_is_negative(tarval *a);
+
+/**
+ * Returns 1 if tv is null
+ *
+ * @param a the tarval
+ */
+int tarval_is_null(tarval *a);
+
+/**
+ * Returns 1 if tv is the "one"
+ *
+ * @param a the tarval
+ */
+int tarval_is_one(tarval *a);
+
+/** The 'bad' tarval. */
+extern tarval *tarval_bad;
+/** Returns the 'bad tarval. */
+tarval *get_tarval_bad(void);
+
+/** The 'undefined' tarval. */
+extern tarval *tarval_undefined;
+/** Returns the 'undefined' tarval. */
+tarval *get_tarval_undefined(void);
+
+/** The mode_b tarval 'false'. */
+extern tarval *tarval_b_false;
+
+/** Returns the mode_b tarval 'false'. */
+tarval *get_tarval_b_false(void);
+
+/** The mode_b tarval 'true'. */
+extern tarval *tarval_b_true;
+/** Returns the mode_b tarval 'true'. */
+tarval *get_tarval_b_true(void);
+
+/* 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. */
+tarval *get_tarval_max(ir_mode *mode);
+
+/** Returns the minimum value of a given mode. */
+tarval *get_tarval_min(ir_mode *mode);
+
+/** Returns the 0 value (additive neutral) of a given mode.
+ For reference modes, the NULL value is returned (old tarval_P_void) */
+tarval *get_tarval_null(ir_mode *mode);
+
+/** Returns the 1 value (multiplicative neutral) of a given mode. */
+tarval *get_tarval_one(ir_mode *mode);
+
+/** Returns the -1 value (multiplicative neutral) of a given mode.
+ * Returns tarval bad for unsigned modes */
+tarval *get_tarval_minus_one(ir_mode *mode);
+
+/** Return quite nan for float_number modes. */
+tarval *get_tarval_nan(ir_mode *mode);
+
+/** Return +inf for float_number modes. */
+tarval *get_tarval_plus_inf(ir_mode *mode);
+
+/** Return -inf for float_number modes. */
+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 */
+ TV_OVERFLOW_SATURATE /**< tarval module will saturate the overflow */
+} tarval_int_overflow_mode_t;
+
+/**
+ * Sets the overflow mode for integer operations.
+ */
+void tarval_set_integer_overflow_mode(tarval_int_overflow_mode_t ov_mode);
+
+/**
+ * Get the overflow mode for integer operations.
+ */
+tarval_int_overflow_mode_t tarval_get_integer_overflow_mode(void);
+
+/**
+ * Compares two tarvals
+ *
+ * Compare a with b and return a pn_Cmp describing the relation
+ * between a and b. This is either pn_Cmp_Uo, pn_Cmp_Lt, pn_Cmp_Eq, pn_Cmp_Gt,
+ * or pn_Cmp_False if a or b are symbolic pointers which can not be compared at all.
+ *
+ * @param a A tarval to be compared
+ * @param b A tarval to be compared
+ *
+ * @return
+ * The pn_Cmp best describing the relation between a and b is returned.
+ * This means the mode with the least bits set is returned, e.g. if the
+ * tarvals are equal the pn_Cmp 'pn_Cmp_Eq' is returned, not 'pn_Cmp_Ge' which
+ * indicates 'greater or equal'
+ *
+ * @sa
+ * irnode.h for the definition of pn_Cmp
+ */
+pn_Cmp tarval_cmp(tarval *a, tarval *b);
+
+/**
+ * Converts a tarval to another mode.
+ *
+ * Convert tarval 'src' to mode 'mode', this will succeed if and only if mode
+ * 'mode' is wider than the mode of src, as defined in the firm documentation
+ * and as returned by the function mode_is_smaller defined in irmode.h.
+ *
+ * @param src The tarval to convert
+ * @param mode Tho mode to convert to
+ *
+ * @return
+ * If a tarval of mode 'mode' with the result of the conversion of the 'src'
+ * tarvals value already exists, it will be returned, else a new tarval is
+ * constructed and returned
+ *
+ * @note
+ * Illegal conversations will trigger an assertion
+ *
+ * @sa
+ * FIRM documentation for conversion rules
+ * mode_is_smaller defined in irmode.h
+ */
+tarval *tarval_convert_to(tarval *src, ir_mode *mode);
+
+/*
+ * These function implement basic computations representable as opcodes
+ * in FIRM nodes.
+ *
+ * PARAMETERS
+ * tarval_neg:
+ * traval_abs:
+ * a - the tarval to operate on
+ *
+ * all others:
+ * a - the first operand tarval
+ * b - the second operand tarval
+ *
+ * RESULT
+ * If necessary a new tarval is constructed for the resulting value,
+ * or the one already carrying the computation result is retrieved and
+ * returned as result.
+ *
+ * NOTES
+ * The order the arguments are given in is important, imagine postfix
+ * notation.
+ * Illegal operations will trigger an assertion.
+ * The sort member of the struct mode defines which operations are valid
+ */
+
+/** bitwise Negation of a tarval. */
+tarval *tarval_not(tarval *a);
+
+/** arithmetic Negation of a tarval. */
+tarval *tarval_neg(tarval *a);
+
+/** Addition of two tarvals. */
+tarval *tarval_add(tarval *a, tarval *b);
+
+/** Subtraction from a tarval. */
+tarval *tarval_sub(tarval *a, tarval *b);
+
+/** Multiplication of tarvals. */
+tarval *tarval_mul(tarval *a, tarval *b);
+
+/** 'Exact' division. */
+tarval *tarval_quo(tarval *a, tarval *b);
+
+/** Integer division. */
+tarval *tarval_div(tarval *a, tarval *b);
+
+/** Remainder of integer division. */
+tarval *tarval_mod(tarval *a, tarval *b);
+
+/** Absolute value. */
+tarval *tarval_abs(tarval *a);
+
+/** Bitwise and. */
+tarval *tarval_and(tarval *a, tarval *b);
+
+/** Bitwise or. */
+tarval *tarval_or(tarval *a, tarval *b);
+
+/** Bitwise exclusive or. */
+tarval *tarval_eor(tarval *a, tarval *b);
+
+/** Left shift. */
+tarval *tarval_shl(tarval *a, tarval *b);
+
+/** Unsigned (logical) right shift. */
+tarval *tarval_shr(tarval *a, tarval *b);
+
+/** Signed (arithmetic) right shift. */
+tarval *tarval_shrs(tarval *a, tarval *b);
+
+/** Rotation. */
+tarval *tarval_rot(tarval *a, tarval *b);
+
+/** Carry flag of the last operation */
+int tarval_carry(void);
+
+/* *********** Output of tarvals *********** */
+
+/**
+ * The output mode for tarval values.
+ *
+ * Some modes allow more that one representation, for instance integers
+ * can be represented hex or decimal. Of course it would be enough to have
+ * one and let every backend convert it into the 'right' one.
+ * 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)*/
+} tv_output_mode;
+
+/**
+ * This structure contains helper information to format the output
+ * of a tarval of a mode.
+ */
+typedef struct tarval_mode_info {
+ tv_output_mode mode_output; /**< if != TVO_NATIVE select a special mode */
+ const char *mode_prefix; /**< if set, this prefix will be printed
+ before a value of this mode */
+ const char *mode_suffix; /**< if set, this suffix will be printed
+ after a value of this mode */
+} tarval_mode_info;
+
+/**
+ * Specify the output options of one mode.
+ *
+ * This functions stores the mode info, so DO NOT DESTROY it.
+ *
+ * @param mode a ir_mode that should be associated
+ * @param modeinfo the output format info
+ *
+ * @return zero on success.
+ */
+int set_tarval_mode_output_option(ir_mode *mode, const tarval_mode_info *modeinfo);
+
+/**
+ * Returns the output options of one mode.
+ *
+ * This functions returns the mode info of a given mode.
+ *
+ * @param mode a ir_mode that should be associated
+ *
+ * @return the output option
+ */
+const tarval_mode_info *get_tarval_mode_output_option(ir_mode *mode);
+
+/**
+ * Returns Bit representation of a tarval value, as string of '0' and '1'
+ *
+ * @param tv The tarval
+ *
+ * This function returns a printable bit representation of any value
+ * stored as tarval. This representation is a null terminated C string.
+ *
+ * @return
+ * As usual in C a pointer to a char is returned. The length of the
+ * returned string if fixed, just read as many chars as the mode defines
+ * as size.
+ *
+ * @note
+ * The string is allocated using malloc() and is free()ed on the next call
+ * of this function.
+ * The string consists of the ASCII characters '0' and '1' and is
+ * null terminated
+ *
+ * @sa
+ * irmode.h for the definition of the ir_mode struct
+ * the size member of aforementioned struct
+ */
+char *get_tarval_bitpattern(tarval *tv);
+
+/**
+ * Returns the bitpattern of the bytes_ofs byte.
+ *
+ * This function succeeds even if the mode of the tarval uses lesser bits
+ * than requested, in that case the bitpattern is filled with zero bits.
+ *
+ * To query a 32bit value the following code can be used:
+ *
+ * val0 = tarval_sub_bits(tv, 0);
+ * val1 = tarval_sub_bits(tv, 1);
+ * val2 = tarval_sub_bits(tv, 2);
+ * val3 = tarval_sub_bits(tv, 3);
+ *
+ * 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 tv the tarval
+ * @param byte_ofs the byte offset
+ *
+ * @note
+ * The result of this function is undefined if the mode is neither integer nor float.
+ */
+unsigned char get_tarval_sub_bits(tarval *tv, unsigned byte_ofs);
+
+/**
+ * Return values of tarval classify
+ */
+typedef enum _tarval_classification_t {
+ TV_CLASSIFY_NULL = 0, /**< the tarval represents the additive neutral element */
+ TV_CLASSIFY_ONE = +1, /**< the tarval represents the multiplicative neutral element */
+ TV_CLASSIFY_ALL_ONE = -1, /**< the tarval represents the bitwise-and neutral element */
+ TV_CLASSIFY_OTHER = 2 /**< all other tarvals */
+} tarval_classification_t;
+
+/**
+ * Identifying tarvals values for algebraic simplifications.
+ *
+ * @param tv the tarval
+ *
+ * @return
+ * - TV_CLASSIFY_NULL for additive neutral or the NULL tarval for reference modes,
+ * - TV_CLASSIFY_ONE for multiplicative neutral,
+ * - TV_CLASSIFY_ALL_ONE for bitwise-and neutral
+ * - TV_CLASSIFY_OTHER else
+ */
+tarval_classification_t classify_tarval(tarval *tv);
+
+/**
+ * Returns non-zero if a given (integer) tarval has only one single bit
+ * set.
+ */
+int is_single_bit_tarval(tarval *tv);
+
+/**
+ * Output of tarvals to a buffer.
+ */
+int tarval_snprintf(char *buf, size_t buflen, tarval *tv);
+
+/**
+ * Output of tarvals to stdio.
+ */
+int tarval_printf(tarval *tv);
+
+#endif /* FIRM_TV_TV_H */
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+#ifndef FIRM_TYPEREP_H
+#define FIRM_TYPEREP_H
+
+#include "firm_types.h"
+
+/**
+ * @page entity Entity representation
+ *
+ * An entity is the representation of program known objects in Firm.
+ * The primary concept of entities is to represent members of complex
+ * types, i.e., fields and methods of classes. As not all programming
+ * language model all variables and methods as members of some class,
+ * the concept of entities is extended to cover also local and global
+ * variables, and arbitrary procedures.
+ *
+ * An entity always specifies the type of the object it represents and
+ * the type of the object it is a part of, the owner of the entity.
+ * Originally this is the type of the class of which the entity is a
+ * member.
+ * The owner of local variables is the procedure they are defined in.
+ * The owner of global variables and procedures visible in the whole
+ * program is a universally defined class type "GlobalType". The owner
+ * of procedures defined in the scope of an other procedure is the
+ * enclosing procedure.
+ *
+ * The type ir_entity is an abstract data type to represent program entities.
+ * If contains the following attributes:
+ *
+ * - owner: A compound type this entity is a part of.
+ * - type: The type of this entity.
+ * - name: The string that represents this entity in the source program. * - allocation: A flag saying whether the entity is dynamically or statically * allocated (values: dynamic_allocated, static_allocated,
+ * automatic_allocated).
+ * - visibility: A flag indicating the visibility of this entity (values: local,
+ * external_visible, external_allocated)
+ * - variability: A flag indicating the variability of this entity (values:
+ * uninitialized, initialized, part_constant, constant)
+ * - volatility: @@@
+ * - offset: The offset of the entity within the compound object in bytes. Only set
+ * if the owner in the state "layout_fixed".
+ * - offset_bits_remainder: The offset bit remainder of a bitfield entity (in a compound)
+ * in bits. Only set if the owner in the state "layout_fixed".
+ * - overwrites: A list of entities overwritten by this entity. This list is only
+ * existent if the owner of this entity is a class. The members in
+ * this list must be entities of super classes.
+ * - overwrittenby: A list of entities that overwrite this entity. This list is only
+ * existent if the owner of this entity is a class. The members in
+ * this list must be entities of sub classes.
+ * - link: A void* to associate some additional information with the entity.
+ * - irg: If the entity is a method this is the ir graph that represents the
+ * code of the method.
+ * - peculiarity: The peculiarity of the entity. If the entity is a method this
+ * indicates whether the entity represents
+ * a real method or whether it only exists to describe an interface.
+ * In that case there nowhere exists code for this entity and this entity
+ * is never dynamically used in the code.
+ * Values: description, existent. Default: existent.
+ * - visited: visited flag. Master flag is type_visited.
+ *
+ * These fields can only be accessed via access functions.
+ *
+ * @see ir_type, ir_entity
+ */
+
+/** This enumeration flags the visibility of entities and types.
+ *
+ * This is necessary for partial compilation.
+ * We rely on the ordering of the flags.
+ */
+typedef enum {
+ visibility_local, /**< The entity is only visible locally. This is the default for
+ entities.
+ The type is only visible locally. All instances are allocated
+ locally, and no pointer to entities of this type are passed
+ out of this compilation unit. */
+ visibility_external_visible, /**< The entity is visible to other external program parts, but
+ it is defined here. It may not be optimized away. The entity must
+ be static_allocated.
+ For types: entities of this type can be accessed externally. No
+ instances of this type are allocated externally. */
+ visibility_external_allocated /**< The entity is defined and allocated externally. This compilation
+ must not allocate memory for this entity. The entity must
+ be static_allocated. This can also be an external defined
+ method.
+ For types: entities of this type are allocated and accessed from
+ external code. Default for types. */
+} ir_visibility;
+
+/** This enumeration flags the peculiarity of entities and types. */
+typedef enum {
+ peculiarity_description, /**< Represents only a description. The entity/type is never
+ allocated, no code/data exists for this entity/type.
+ @@@ eventually rename to descriptive (adjective as the others!)*/
+ peculiarity_inherited, /**< Describes explicitly that other entities are
+ inherited to the owner of this entity.
+ Overwrites must refer to at least one other
+ entity. If this is a method entity there exists
+ no irg for this entity, only for one of the
+ overwritten ones.
+ Only for entity. */
+ peculiarity_existent /**< The entity/type (can) exist.
+ @@@ eventually rename to 'real' i.e., 'echt'
+ This serves better as opposition to description _and_ inherited.*/
+} ir_peculiarity;
+
+/**
+ * Additional method type properties:
+ * Tell about special properties of a method type. Some
+ * of these may be discovered by analyses.
+ */
+typedef enum {
+ mtp_no_property = 0x00000000, /**< no additional properties, default */
+ mtp_property_const = 0x00000001, /**< This method did not access memory and calculates
+ its return values solely from its parameters.
+ GCC: __attribute__((const)). */
+ mtp_property_pure = 0x00000002, /**< This method did NOT write to memory and calculates
+ its return values solely from its parameters and
+ the memory they points to (or global vars).
+ GCC: __attribute__((pure)). */
+ mtp_property_noreturn = 0x00000004, /**< This method did not return due to an aborting system
+ call.
+ GCC: __attribute__((noreturn)). */
+ mtp_property_nothrow = 0x00000008, /**< This method cannot throw an exception.
+ GCC: __attribute__((nothrow)). */
+ mtp_property_naked = 0x00000010, /**< This method is naked.
+ GCC: __attribute__((naked)). */
+ mtp_property_malloc = 0x00000020, /**< This method returns newly allocate memory.
+ GCC: __attribute__((malloc)). */
+ mtp_property_intrinsic = 0x00000040, /**< This method is intrinsic. It is expected that
+ a lowering phase will remove all calls to it. */
+ mtp_property_runtime = 0x00000080, /**< This method represents a runtime routine. */
+ mtp_property_inherited = (1<<31) /**< Internal. Used only in irg's, means property is
+ inherited from type. */
+} mtp_additional_property;
+
+/**
+ * Creates a new entity.
+ *
+ * Automatically inserts the entity as a member of owner.
+ * Entity is automatic_allocated and uninitialized except if the type
+ * is type_method, then it is static_allocated and constant. The constant
+ * value is a pointer to the method.
+ * Visibility is local, offset -1, and it is not volatile.
+ */
+ir_entity *new_entity(ir_type *owner, ident *name, ir_type *tp);
+
+/**
+ * Creates a new entity.
+ *
+ * Automatically inserts the entity as a member of owner.
+ * The entity is automatic allocated and uninitialized except if the type
+ * is type_method, then it is static allocated and constant. The constant
+ * value is a pointer to the method.
+ * Visibility is local, offset -1, and it is not volatile.
+ */
+ir_entity *new_d_entity(ir_type *owner, ident *name, ir_type *tp, dbg_info *db);
+
+/**
+ * Copies the entity if the new_owner is different from the
+ * owner of the old entity, else returns the old entity.
+ *
+ * Automatically inserts the new entity as a member of owner.
+ * Resets the overwrites/overwritten_by fields.
+ * Keeps the old atomic value.
+ * @@@ Maybe we should change this. If peculiarity of a method
+ * is existent, we should add a new SymConst that points to
+ * itself and not to the origin. Right now we have to change
+ * the peculiarity and then set a new atomic value by hand.
+ */
+ir_entity *copy_entity_own(ir_entity *old, ir_type *new_owner);
+
+/**
+ * Copies the entity if the new_name is different from the
+ * name of the old entity, else returns the old entity.
+ *
+ * Automatically inserts the new entity as a member of owner.
+ * The mangled name ld_name is set to NULL.
+ * Overwrites relation is copied from old.
+ */
+ir_entity *copy_entity_name(ir_entity *old, ident *new_name);
+
+/**
+ * Frees the entity.
+ *
+ * The owner will still contain the pointer to this
+ * entity, as well as all other references!
+ */
+void free_entity(ir_entity *ent);
+
+/** Returns the name of an entity. */
+const char *get_entity_name(const ir_entity *ent);
+
+/** Returns the ident of an entity. */
+ident *get_entity_ident(const ir_entity *ent);
+
+/** Sets the ident of the entity. */
+void set_entity_ident(ir_entity *ent, ident *id);
+
+/** Returns the mangled name of the entity.
+ *
+ * If the mangled name is set it returns the existing name.
+ * Else it generates a name with mangle_entity()
+ * and remembers this new name internally.
+ */
+ident *get_entity_ld_ident(ir_entity *ent);
+
+/** Sets the mangled name of the entity. */
+void set_entity_ld_ident(ir_entity *ent, ident *ld_ident);
+
+/** Returns the mangled name of the entity as a string. */
+const char *get_entity_ld_name(ir_entity *ent);
+
+/** Returns the owner of the entity. */
+ir_type *get_entity_owner(ir_entity *ent);
+
+/** Sets the owner field in entity to owner. Don't forget to add
+ ent to owner!! */
+void set_entity_owner(ir_entity *ent, ir_type *owner);
+
+/** Returns the type of an entity. */
+ir_type *get_entity_type(ir_entity *ent);
+
+/** Sets the type of an entity. */
+void set_entity_type(ir_entity *ent, ir_type *tp);
+
+/** The allocation type. */
+typedef enum {
+ allocation_automatic, /**< The entity is allocated during runtime, implicitly
+ as component of a compound type. This is the default. */
+ allocation_parameter, /**< The entity is a parameter. It is also automatic allocated.
+ We distinguish the allocation of parameters from the allocation
+ of local variables as their placement depends on the calling
+ conventions. */
+ allocation_dynamic, /**< The entity is allocated during runtime, explicitly
+ by an Alloc node. */
+ allocation_static /**< The entity is allocated statically. We can use a
+ Const as address of the entity. This is the default for methods. */
+} ir_allocation;
+
+/** Returns the allocation type of an entity. */
+ir_allocation get_entity_allocation(const ir_entity *ent);
+
+/** Sets the allocation type of an entity. */
+void set_entity_allocation(ir_entity *ent, ir_allocation al);
+
+/** Return the name of the allocation type. */
+const char *get_allocation_name(ir_allocation vis);
+
+/** Returns the visibility of an entity. */
+ir_visibility get_entity_visibility(const ir_entity *ent);
+
+/** Sets the visibility of an entity. */
+void set_entity_visibility(ir_entity *ent, ir_visibility vis);
+
+/** Return the name of the visibility */
+const char *get_visibility_name(ir_visibility vis);
+
+/** This enumeration flags the variability of entities. */
+typedef enum {
+ variability_uninitialized, /**< The content of the entity is completely unknown. Default. */
+ variability_initialized, /**< After allocation the entity is initialized with the
+ value given somewhere in the entity. */
+ variability_part_constant, /**< For entities of compound types.
+ The members of the entity are mixed constant,
+ initialized or uninitialized. */
+ variability_constant /**< The entity is constant. */
+} ir_variability;
+
+/** Returns the variability of an entity. */
+ir_variability get_entity_variability(const ir_entity *ent);
+
+/** Sets the variability of an entity. */
+void set_entity_variability(ir_entity *ent, ir_variability var);
+
+/** Return the name of the variability. */
+const char *get_variability_name(ir_variability var);
+
+/** This enumeration flags the volatility of entities. */
+typedef enum {
+ volatility_non_volatile, /**< The entity is not volatile. Default. */
+ volatility_is_volatile /**< The entity is volatile */
+} ir_volatility;
+
+/** Returns the volatility of an entity. */
+ir_volatility get_entity_volatility(const ir_entity *ent);
+
+/** Sets the volatility of an entity. */
+void set_entity_volatility(ir_entity *ent, ir_volatility vol);
+
+/** Return the name of the volatility. */
+const char *get_volatility_name(ir_volatility var);
+
+/** This enumeration flags the stickyness of an entity. */
+typedef enum {
+ stickyness_unsticky, /**< The entity can be removed from
+ the program, unless contraindicated
+ by other attributes. Default. */
+ stickyness_sticky /**< The entity must remain in the
+ program in any case. */
+} ir_stickyness;
+
+/** Get the entity's stickyness. */
+ir_stickyness get_entity_stickyness(const ir_entity *ent);
+
+/** Set the entity's stickyness. */
+void set_entity_stickyness(ir_entity *ent, ir_stickyness stickyness);
+
+/** Returns the offset of an entity (in a compound) in bytes. Only set if layout = fixed. */
+int get_entity_offset(const ir_entity *ent);
+
+/** Sets the offset of an entity (in a compound) in bytes. */
+void set_entity_offset(ir_entity *ent, int offset);
+
+/** Returns the offset bit remainder of a bitfield entity (in a compound) in bits. Only set if layout = fixed. */
+unsigned char get_entity_offset_bits_remainder(const ir_entity *ent);
+
+/** Sets the offset bit remainder of a bitfield entity (in a compound) in bits. */
+void set_entity_offset_bits_remainder(ir_entity *ent, unsigned char offset);
+
+/** Returns the stored intermediate information. */
+void *get_entity_link(const ir_entity *ent);
+
+/** Stores new intermediate information. */
+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.
+ Only entities of peculiarity "existent" can have a corresponding irg,
+ else the field is fixed to NULL. (Get returns NULL, set asserts.) */
+ir_graph *get_entity_irg(const ir_entity *ent);
+void set_entity_irg(ir_entity *ent, ir_graph *irg);
+
+/** Gets the entity vtable number. */
+unsigned get_entity_vtable_number(const ir_entity *ent);
+
+/** Sets the entity vtable number. */
+void set_entity_vtable_number(ir_entity *ent, unsigned vtable_number);
+
+/** Return the peculiarity of an entity. */
+ir_peculiarity get_entity_peculiarity(const ir_entity *ent);
+
+/** Sets the peculiarity of an entity. */
+void set_entity_peculiarity(ir_entity *ent, ir_peculiarity pec);
+
+/** Checks if an entity cannot be overridden anymore. */
+int is_entity_final(const ir_entity *ent);
+
+/** Sets/resets the final flag of an entity. */
+void set_entity_final(ir_entity *ent, int final);
+
+/** Checks if an entity is compiler generated. */
+int is_entity_compiler_generated(const ir_entity *ent);
+
+/** Sets/resets the compiler generated flag. */
+void set_entity_compiler_generated(ir_entity *ent, int flag);
+
+/**
+ * The state of the address_taken flag.
+ */
+typedef enum {
+ ir_address_not_taken = 0, /**< The address is NOT taken. */
+ ir_address_taken_unknown = 1, /**< The state of the address taken flag is unknown. */
+ ir_address_taken = 2 /**< The address IS taken. */
+} ir_address_taken_state;
+
+/** Return the state of the address taken flag of an entity. */
+ir_address_taken_state get_entity_address_taken(const ir_entity *ent);
+
+/** Sets/resets the state of the address taken flag of an entity. */
+void set_entity_address_taken(ir_entity *ent, ir_address_taken_state flag);
+
+/** Return the name of the address_taken state. */
+const char *get_address_taken_state_name(ir_address_taken_state state);
+
+/* -- Representation of constant values of entities -- */
+/**
+ * Returns true if the the node is representable as code on
+ * const_code_irg.
+ *
+ * @deprecated This function is not used by libFirm and stays here
+ * only as a helper for the old Jack frontend.
+ */
+int is_irn_const_expression(ir_node *n);
+
+/**
+ * Copies a Firm subgraph that complies to the restrictions for
+ * constant expressions to current_block in current_ir_graph.
+ *
+ * @param dbg debug info for all newly created nodes
+ * @param n the node
+ *
+ * Set current_ir_graph to get_const_code_irg() to generate a constant
+ * expression.
+ */
+ir_node *copy_const_value(dbg_info *dbg, ir_node *n);
+
+/* Set has no effect for existent entities of type method. */
+ir_node *get_atomic_ent_value(ir_entity *ent);
+void set_atomic_ent_value(ir_entity *ent, ir_node *val);
+
+/** Creates a new compound graph path. */
+compound_graph_path *new_compound_graph_path(ir_type *tp, int length);
+
+/** Returns non-zero if an object is a compound graph path */
+int is_compound_graph_path(const void *thing);
+
+/** Frees a graph path object */
+void free_compound_graph_path (compound_graph_path *gr);
+
+/** Returns the length of a graph path */
+int get_compound_graph_path_length(const compound_graph_path *gr);
+
+ir_entity *get_compound_graph_path_node(const compound_graph_path *gr, int pos);
+void set_compound_graph_path_node(compound_graph_path *gr, int pos, ir_entity *node);
+int get_compound_graph_path_array_index(const compound_graph_path *gr, int pos);
+void set_compound_graph_path_array_index(compound_graph_path *gr, int pos, int index);
+
+/** Checks whether the path up to pos is correct. If the path contains a NULL,
+ * assumes the path is not complete and returns non-zero. */
+int is_proper_compound_graph_path(compound_graph_path *gr, int pos);
+
+/* A value of a compound entity is a pair of a value and the description of the
+ corresponding access path to the member of the compound. */
+void add_compound_ent_value_w_path(ir_entity *ent, ir_node *val, compound_graph_path *path);
+void set_compound_ent_value_w_path(ir_entity *ent, ir_node *val, compound_graph_path *path, int pos);
+/** Returns the number of constant values needed to initialize the entity.
+ *
+ * Asserts if the entity has variability_uninitialized.
+ * */
+int get_compound_ent_n_values(ir_entity *ent);
+/** Returns a constant value given the position. */
+ir_node *get_compound_ent_value(ir_entity *ent, int pos);
+/** Returns the access path for value at position pos. */
+compound_graph_path *get_compound_ent_value_path(ir_entity *ent, int pos);
+/** Returns a constant value given the access path.
+ * The path must contain array indices for all array element entities. */
+ir_node *get_compound_ent_value_by_path(ir_entity *ent, compound_graph_path *path);
+
+/** Removes all constant entries where the path ends at value_ent. Does not
+ free the memory of the paths. (The same path might be used for several
+ constant entities. */
+void remove_compound_ent_value(ir_entity *ent, ir_entity *value_ent);
+
+/* Some languages support only trivial access paths, i.e., the member is a
+ direct, atomic member of the constant entities type. In this case the
+ corresponding entity can be accessed directly. The following functions
+ allow direct access. */
+
+/** Generates a Path with length 1.
+ Beware: Has a bad runtime for array elements (O(|array|) and should be
+ avoided there. Use add_compound_ent_value_w_path() instead and create
+ the path manually. */
+void add_compound_ent_value(ir_entity *ent, ir_node *val, ir_entity *member);
+
+/** Returns the last member in the path */
+ir_entity *get_compound_ent_value_member(ir_entity *ent, int pos);
+
+/** Sets the path at pos 0 */
+void set_compound_ent_value(ir_entity *ent, ir_node *val, ir_entity *member, int pos);
+
+/** Initializes the entity ent which must be of a one dimensional
+ array type with the values given in the values array.
+ The array must have a lower and an upper bound. Keeps the
+ order of values. Does not test whether the number of values
+ fits into the given array size. Does not test whether the
+ values have the proper mode for the array. */
+void set_array_entity_values(ir_entity *ent, tarval **values, int num_vals);
+
+/**
+ * Return the offset in bits from the last byte address.
+ *
+ * This requires that the layout of all concerned types is fixed.
+ *
+ * @param ent Any entity of compound type with at least pos initialization values.
+ * @param pos The position of the value for which the offset is requested.
+ */
+int get_compound_ent_value_offset_bit_remainder(ir_entity *ent, int pos);
+
+/** Return the overall offset of value at position pos in bytes.
+ *
+ * This requires that the layout of all concerned types is fixed.
+ * Asserts if bit offset is not byte aligned.
+ *
+ * @param ent Any entity of compound type with at least pos initialization values.
+ * @param pos The position of the value for which the offset is requested.
+ */
+int get_compound_ent_value_offset_bytes(ir_entity *ent, int pos);
+
+/* --- 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. */
+void add_entity_overwrites (ir_entity *ent, ir_entity *overwritten);
+int get_entity_n_overwrites (ir_entity *ent);
+int get_entity_overwrites_index(ir_entity *ent, ir_entity *overwritten);
+ir_entity *get_entity_overwrites (ir_entity *ent, int pos);
+void set_entity_overwrites (ir_entity *ent, int pos, ir_entity *overwritten);
+void remove_entity_overwrites(ir_entity *ent, ir_entity *overwritten);
+
+void add_entity_overwrittenby (ir_entity *ent, ir_entity *overwrites);
+int get_entity_n_overwrittenby (ir_entity *ent);
+int get_entity_overwrittenby_index(ir_entity *ent, ir_entity *overwrites);
+ir_entity *get_entity_overwrittenby (ir_entity *ent, int pos);
+void set_entity_overwrittenby (ir_entity *ent, int pos, ir_entity *overwrites);
+void remove_entity_overwrittenby(ir_entity *ent, ir_entity *overwrites);
+
+/**
+ * Checks whether a pointer points to an entity.
+ *
+ * @param thing an arbitrary pointer
+ *
+ * @return
+ * true if the thing is an entity, else false
+ */
+int is_entity (const void *thing);
+
+/** Returns true if the type of the entity is a primitive, pointer
+ * enumeration or method type.
+ *
+ * @Note This is a different classification than from is_primitive_type().
+ */
+int is_atomic_entity(ir_entity *ent);
+/** Returns true if the type of the entity is a class, structure,
+ array or union type. */
+int is_compound_entity(ir_entity *ent);
+/** Returns true if the type of the entity is a Method type. */
+int is_method_entity(ir_entity *ent);
+
+/** Returns non-zero if ent1 and ent2 have are equal except for their owner.
+ Two entities are equal if
+ - they have the same type (the same C-struct)
+ - ...?
+*/
+int equal_entity(ir_entity *ent1, ir_entity *ent2);
+
+/** Outputs a unique number for this entity if libfirm is compiled for
+ * debugging, (configure with --enable-debug) else returns the address
+ * of the type cast to long.
+ */
+long get_entity_nr(const ir_entity *ent);
+
+/** Returns the entities visited count. */
+unsigned long get_entity_visited(ir_entity *ent);
+
+/** Sets the entities visited count. */
+void set_entity_visited(ir_entity *ent, unsigned long num);
+
+/** Sets visited field in entity to entity_visited. */
+void mark_entity_visited(ir_entity *ent);
+
+/** Returns true if this entity was visited. */
+int entity_visited(ir_entity *ent);
+
+/** Returns true if this entity was not visited. */
+int entity_not_visited(ir_entity *ent);
+
+/**
+ * Returns the mask of the additional entity properties.
+ * The properties are automatically inherited from the irg if available
+ * or from the method type if they were not set using
+ * set_entity_additional_properties() or
+ * set_entity_additional_property().
+ */
+unsigned get_entity_additional_properties(ir_entity *ent);
+
+/** Sets the mask of the additional graph properties. */
+void set_entity_additional_properties(ir_entity *ent, unsigned property_mask);
+
+/** Sets one additional graph property. */
+void set_entity_additional_property(ir_entity *ent, mtp_additional_property flag);
+
+/** Returns the class type that this type info entity represents or NULL
+ if ent is no type info entity. */
+ir_type *get_entity_repr_class(const ir_entity *ent);
+
+/**
+ * @page unknown_entity The Unknown entity
+ *
+ * This entity is an auxiliary entity dedicated to support analyses.
+ *
+ * The unknown entity represents that there could be an entity, but it is not
+ * known. This entity can be used to initialize fields before an analysis (not known
+ * yet) or to represent the top of a lattice (could not be determined). There exists
+ * exactly one entity unknown. This entity has as owner and as type the unknown type. It is
+ * allocated when initializing the entity module.
+ *
+ * The entity can take the role of any entity, also methods. It returns default
+ * values in these cases.
+ *
+ * The following values are set:
+ *
+ * - name = "unknown_entity"
+ * - ld_name = "unknown_entity"
+ * - owner = unknown_type
+ * - type = unknown_type
+ * - allocation = allocation_automatic
+ * - visibility = visibility_external_allocated
+ * - offset = -1
+ * - variability = variability_uninitialized
+ * - value = SymConst(unknown_entity)
+ * - values = NULL
+ * - val_paths = NULL
+ * - peculiarity = peculiarity_existent
+ * - volatility = volatility_non_volatile
+ * - stickyness = stickyness_unsticky
+ * - ld_name = NULL
+ * - overwrites = NULL
+ * - overwrittenby = NULL
+ * - irg = NULL
+ * - link = NULL
+ */
+/* A variable that contains the only unknown entity. */
+extern ir_entity *unknown_entity;
+
+/** Returns the @link unknown_entity unknown entity @endlink. */
+ir_entity *get_unknown_entity(void);
+
+/** Encodes how a pointer parameter is accessed. */
+typedef enum acc_bits {
+ ptr_access_none = 0, /**< no access */
+ ptr_access_read = 1, /**< read access */
+ ptr_access_write = 2, /**< write access */
+ ptr_access_rw = ptr_access_read|ptr_access_write, /**< read AND write access */
+ ptr_access_store = 4, /**< the pointer is stored */
+ ptr_access_all = ptr_access_rw|ptr_access_store /**< all possible access */
+} ptr_access_kind;
+
+#define IS_READ(a) ((a) & ptr_access_read)
+#define IS_WRITTEN(a) ((a) & ptr_access_write)
+#define IS_STORED(a) ((a) & ptr_access_store)
+
+/**
+ * Supported image sections.
+ * Currently only methods can be placed in different sections.
+ */
+typedef enum {
+ section_text, /**< The code segment. This is the default for methods. */
+ section_constructors /**< The constructor section. */
+} ir_img_section;
+
+/** Returns the section of a method. */
+ir_img_section get_method_img_section(const ir_entity *method);
+
+/** Sets the section of a method. */
+void set_method_img_section(ir_entity *method, ir_img_section section);
+
+
+
+
+/**
+ * @page tyop type operations
+ * This module specifies the kinds of types available in firm.
+ *
+ * They are called type opcodes. These include classes, structs, methods, unions,
+ * arrays, enumerations, pointers and primitive types.
+ * Special types with own opcodes are the id type, a type representing an unknown
+ * type and a type used to specify that something has no type.
+ *
+ * @see type.h
+ */
+
+/**
+ * An enum for the type kinds.
+ * For each type kind exists a typecode to identify it.
+ */
+typedef enum {
+ tpo_uninitialized = 0, /* not a type opcode */
+ tpo_class, /**< A class type. */
+ tpo_struct, /**< A struct type. */
+ tpo_method, /**< A method type. */
+ tpo_union, /**< An union type. */
+ tpo_array, /**< An array type. */
+ tpo_enumeration, /**< An enumeration type. */
+ tpo_pointer, /**< A pointer type. */
+ tpo_primitive, /**< A primitive type. */
+ tpo_id, /**< Special Id tag used for type replacement. */
+ tpo_none, /**< Special type for the None type. */
+ tpo_unknown, /**< Special code for the Unknown type. */
+ tpo_max /* not a type opcode */
+} tp_opcode;
+
+/**
+ * A structure containing information about a kind of type.
+ * A structure containing information about a kind of type. So far
+ * this is only the kind name, an enum for case-switching and some
+ * internal values.
+ *
+ * @see get_tpop_name(), get_tpop_code(), get_tpop_ident()
+ */
+typedef struct tp_op tp_op;
+
+
+/**
+ * Returns the string for the type opcode.
+ *
+ * @param op The type opcode to get the string from.
+ * @return a string. (@todo Null terminated???)
+ */
+const char *get_tpop_name (const tp_op *op);
+
+/**
+ * Returns an enum for the type opcode.
+ *
+ * @param op The type opcode to get the enum from.
+ * @return the enum.
+ */
+tp_opcode get_tpop_code (const tp_op *op);
+
+/**
+ * Returns the ident for the type opcode.
+ *
+ * @param op The type opcode to get the ident from.
+ * @return The ident.
+ */
+ident *get_tpop_ident (const tp_op *op);
+
+/**
+ * This type opcode marks that the corresponding type is a class type.
+ *
+ * Consequently the type refers to supertypes, subtypes and entities.
+ * Entities can be any fields, but also methods.
+ * @@@ value class or not???
+ * This struct is dynamically allocated but constant for the lifetime
+ * of the library.
+ */
+extern tp_op *type_class;
+tp_op *get_tpop_class(void);
+
+/**
+ * This type opcode marks that the corresponding type is a compound type
+ * as a struct in C.
+ *
+ * Consequently the type refers to a list of entities
+ * which may not be methods (but pointers to methods).
+ * This struct is dynamically allocated but constant for the lifetime
+ * of the library.
+ */
+extern tp_op *type_struct;
+tp_op *get_tpop_struct(void);
+
+/**
+ * This type opcode marks that the corresponding type is a method type.
+ *
+ * Consequently it refers to a list of arguments and results.
+ * This struct is dynamically allocated but constant for the lifetime
+ * of the library.
+ */
+extern tp_op *type_method;
+tp_op *get_tpop_method(void);
+
+/**
+ * This type opcode marks that the corresponding type is a union type.
+ *
+ * Consequently it refers to a list of unioned types.
+ * This struct is dynamically allocated but constant for the lifetime
+ * of the library.
+ */
+extern tp_op *type_union;
+tp_op *get_tpop_union(void);
+
+/**
+ * This type opcode marks that the corresponding type is an array type.
+ *
+ * Consequently it contains a list of dimensions (lower and upper bounds)
+ * and an element type.
+ * This struct is dynamically allocated but constant for the lifetime
+ * of the library.
+ */
+extern tp_op *type_array;
+tp_op *get_tpop_array(void);
+
+/**
+ * This type opcode marks that the corresponding type is an enumeration type.
+ *
+ * Consequently it contains a list of idents for the enumeration identifiers
+ * and a list of target values that are the constants used to implement
+ * the enumerators.
+ * This struct is dynamically allocated but constant for the lifetime
+ * of the library.
+ */
+extern tp_op *type_enumeration;
+tp_op *get_tpop_enumeration(void);
+
+/**
+ * This type opcode marks that the corresponding type is a pointer type.
+ *
+ * It contains a reference to the type the pointer points to.
+ * This struct is dynamically allocated but constant for the lifetime
+ * of the library.
+ */
+extern tp_op *type_pointer;
+tp_op *get_tpop_pointer(void);
+
+/**
+ * This type opcode marks that the corresponding type is a primitive type.
+ *
+ * Primitive types are types that are directly mapped to target machine
+ * modes.
+ * This struct is dynamically allocated but constant for the lifetime
+ * of the library.
+ */
+extern tp_op *type_primitive;
+tp_op *get_tpop_primitive(void);
+
+/**
+ * This type opcode is an auxiliary opcode dedicated to support transformations
+ * of the type structure.
+ *
+ * If a type is changed to another type with another
+ * opcode the new type will be allocated with new memory. All nodes refering
+ * to the old type need to be changed to refer to the new one. This is simplified
+ * by turning the old type into an id type that merely forwards to the new type
+ * that now replaces the old one.
+ * type_ids should never be visible out of the type module. All access routines
+ * should automatically check for type_id and eventually follow the forward in
+ * type_id. Two types are exchanged by a call to exchange_types.
+ * If a type_id is visible externally report this as bug. If it is assured that
+ * this never happens this extern variable can be moved to tpop_t.h.
+ * This struct is dynamically allocated but constant for the lifetime
+ * of the library.
+ */
+extern tp_op *type_id;
+tp_op *get_tpop_id(void);
+
+/**
+ * This type opcode is an auxiliary opcode dedicated to support type analyses.
+ *
+ * Types with this opcode represents that there is no type.
+ * The type can be used to initialize fields of the type* that actually can not
+ * contain a type or that are initialized for an analysis. There exists exactly
+ * one type with this opcode.
+ */
+extern tp_op *tpop_none;
+tp_op *get_tpop_none(void);
+
+/**
+ * This type opcode is an auxiliary opcode dedicated to support type analyses.
+ *
+ * Types with this opcode represents that there could be a type, but it is not
+ * known. This type can be used to initialize fields before an analysis (not known
+ * yet) or to represent the top of a lattice (could not be determined). There exists
+ * exactly one type with this opcode.
+ */
+extern tp_op *tpop_unknown;
+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
+ * a subclass of high. I.e, we search in all subtypes of high for low.
+ * @@@ this can be implemented more efficient if we know the set of all
+ * subclasses of high. */
+int is_SubClass_of(ir_type *low, ir_type *high);
+
+/** Subclass check for pointers to classes.
+ *
+ * Dereferences at both types the same amount of pointer types (as
+ * many as possible). If the remaining types are both class types
+ * and subclasses, returns true, else false. Can also be called with
+ * two class types. */
+int is_SubClass_ptr_of(ir_type *low, ir_type *high);
+
+/** Returns true if high is superclass of low.
+ *
+ * Low is a subclass of high if low == high or if low is a subclass of
+ * a subclass of high. I.e, we search in all subtypes of high for low.
+ * @@@ this can be implemented more efficient if we know the set of all
+ * subclasses of high. */
+#define is_SuperClass_of(high, low) is_SubClass_of(low, high)
+
+/** Superclass check for pointers to classes.
+ *
+ * Dereferences at both types the same amount of pointer types (as
+ * many as possible). If the remaining types are both class types
+ * and superclasses, returns true, else false. Can also be called with
+ * two class types. */
+#define is_SuperClass_ptr_of(low, high) is_SubClass_ptr_of(high, low)
+
+/** Returns true if high is (transitive) overwritten by low.
+ *
+ * Returns false if high == low. */
+int is_overwritten_by(ir_entity *high, ir_entity *low);
+
+/** Resolve polymorphism in the inheritance relation.
+ *
+ * Returns the dynamically referenced entity if the static entity and the
+ * dynamic type are given.
+ * Searches downwards in overwritten tree. */
+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
+ * underscore and the name (not ld_name) of the entity. */
+ident *default_mangle_inherited_name(ir_entity *ent, ir_type *clss);
+
+/** Type of argument functions for inheritance resolver.
+ *
+ * @param ent The entity in the super type that will be overwritten
+ * by the newly generated entity, for which this name is
+ * used.
+ * @param clss The class type in which the new entity will be placed.
+ */
+typedef ident *mangle_inherited_name_func(ir_entity *ent, ir_type *clss);
+
+/** Resolve implicit inheritance.
+ *
+ * Resolves the implicit inheritance supplied by firm. Firm defines,
+ * that each entity that is not overwritten in a subclass is
+ * inherited to this subclass without change implicitly. This
+ * function generates entities that explicitly represent this
+ * inheritance. It generates for each entity overwriting entities in
+ * all subclasses of the owner of the entity, if the entity is not
+ * overwritten in that subclass.
+ *
+ * The name of the new entity is generated with the function passed.
+ * If the function is NULL, the default_mangle_inherited_name() is
+ * used.
+ *
+ * This function was moved here from firmlower 3/2005.
+ */
+void resolve_inheritance(mangle_inherited_name_func *mfunc);
+
+
+/* ----------------------------------------------------------------------- */
+/* The transitive closure of the subclass/superclass and */
+/* overwrites/overwrittenby relation. */
+/* */
+/* A walk over the ir (O(#types+#entities)) computes the transitive */
+/* closure. Adding a new type/entity or changing the basic relations in */
+/* some other way invalidates the transitive closure, i.e., it is not */
+/* updated by the basic functions. */
+/* */
+/* The transitive edges are held in a set, not in an array as the */
+/* underlying relation. */
+/* */
+/* Do the sets contain the node itself? I assume NOT! */
+/* ----------------------------------------------------------------------- */
+
+/** The state of the transitive closure.
+ *
+ * @todo: we could manage the state for each relation separately. Invalidating
+ * the entity relations does not mean invalidating the class relation. */
+typedef enum {
+ inh_transitive_closure_none, /**< Closure is not computed, can not be accessed. */
+ inh_transitive_closure_valid, /**< Closure computed and valid. */
+ inh_transitive_closure_invalid, /**< Closure invalid, but can be accessed. */
+ inh_transitive_closure_max /**< Invalid value. */
+} inh_transitive_closure_state;
+
+void set_irp_inh_transitive_closure_state(inh_transitive_closure_state s);
+void invalidate_irp_inh_transitive_closure_state(void);
+inh_transitive_closure_state get_irp_inh_transitive_closure_state(void);
+
+
+/** Compute transitive closure of the subclass/superclass and
+ * overwrites/overwrittenby relation.
+ *
+ * This function walks over the ir (O(#types+#entities)) to compute the
+ * transitive closure. */
+void compute_inh_transitive_closure(void);
+
+/** Free memory occupied by the transitive closure information. */
+void free_inh_transitive_closure(void);
+
+
+/* - subtype ------------------------------------------------------------- */
+
+/** Iterate over all transitive subtypes. */
+ir_type *get_class_trans_subtype_first(ir_type *tp);
+ir_type *get_class_trans_subtype_next (ir_type *tp);
+int is_class_trans_subtype (ir_type *tp, ir_type *subtp);
+
+/* - supertype ----------------------------------------------------------- */
+
+/** Iterate over all transitive supertypes. */
+ir_type *get_class_trans_supertype_first(ir_type *tp);
+ir_type *get_class_trans_supertype_next (ir_type *tp);
+
+/* - overwrittenby ------------------------------------------------------- */
+
+/** Iterate over all entities that transitive overwrite this entities. */
+ir_entity *get_entity_trans_overwrittenby_first(ir_entity *ent);
+ir_entity *get_entity_trans_overwrittenby_next (ir_entity *ent);
+
+/* - overwrites ---------------------------------------------------------- */
+
+/** Iterate over all transitive overwritten entities. */
+ir_entity *get_entity_trans_overwrites_first(ir_entity *ent);
+ir_entity *get_entity_trans_overwrites_next (ir_entity *ent);
+
+
+/* ----------------------------------------------------------------------- */
+/** The state of Cast operations that cast class types or pointers to class
+ * types.
+ *
+ * The state expresses, how far Cast operations conform with the class
+ * hierarchy.
+ *
+ * class A {}
+ * class B1 extends A {}
+ * class B2 extends A {}
+ * class C extends B1 {}
+ * normalized: Cast operations conform with the inheritance relation.
+ * I.e., the type of the operand of a Cast is either a super= or a sub-
+ * type of the type casted to. Example: (A)((B2) (new C())).
+ * transitive: Cast operations conform with the transitive inheritance
+ * relation. Example: (A)(new C()).
+ * any: Cast operations do not conform with the transitive inheritance
+ * relation. Example: (B2)(new B1())
+ *
+ * @see: tropt.h
+ */
+/* ----------------------------------------------------------------------- */
+
+/** Flags for class cast state.
+ *
+ * The state in irp is always smaller or equal to the state of any
+ * irg.
+ *
+ * We rely on the ordering of the enum. */
+typedef enum {
+ ir_class_casts_any = 0, /**< There are class casts that do not cast in conformance with
+ the class hierarchy. @@@ So far this does not happen in Firm. */
+ ir_class_casts_transitive = 1, /**< Class casts conform to transitive inheritance edges. Default. */
+ ir_class_casts_normalized = 2, /**< Class casts conform to inheritance edges. */
+ ir_class_casts_state_max
+} ir_class_cast_state;
+char *get_class_cast_state_string(ir_class_cast_state s);
+
+void set_irg_class_cast_state(ir_graph *irg, ir_class_cast_state s);
+ir_class_cast_state get_irg_class_cast_state(ir_graph *irg);
+void set_irp_class_cast_state(ir_class_cast_state s);
+ir_class_cast_state get_irp_class_cast_state(void);
+
+/** Verify the class cast state of an irg.
+ *
+ * Asserts if state is to high, outputs warning if state is to low
+ * and firm verbosity is set.
+ */
+void verify_irg_class_cast_state(ir_graph *irg);
+
+/**
+ * possible trvrfy() error codes
+ */
+enum trvrfy_error_codes {
+ no_error = 0, /**< no error */
+ error_ent_not_cont, /**< overwritten entity not in superclass */
+ error_null_mem, /**< compound contains NULL member */
+ error_const_on_wrong_irg, /**< constant placed on wrong IRG */
+ error_existent_entity_without_irg, /**< Method entities with pecularity_exist must have an irg */
+ error_wrong_ent_overwrites, /**< number of entity overwrites exceeds number of class overwrites */
+ error_inherited_ent_without_const, /**< inherited method entity not pointing to existent entity */
+ error_glob_ent_allocation, /**< wrong allocation of a global entity */
+ error_ent_const_mode, /**< Mode of constant in entity did not match entities type. */
+ error_ent_wrong_owner /**< Mode of constant in entity did not match entities type. */
+};
+
+/**
+ * Checks a type.
+ *
+ * @return
+ * 0 if no error encountered
+ */
+int check_type(ir_type *tp);
+
+/**
+ * Check an entity. Currently, we check only if initialized constants
+ * are build on the const irg graph.
+ *
+ * @return
+ * 0 if no error encountered
+ * != 0 a trvrfy_error_codes code
+ */
+int check_entity(ir_entity *ent);
+
+/**
+ * Walks the type information and performs a set of sanity checks.
+ *
+ * Currently, the following checks are executed:
+ * - values of initialized entities must be allocated on the constant IRG
+ * - class types: doesn't have NULL members
+ * - class types: all overwrites are existent in the super type
+ *
+ * @return
+ * 0 if graph is correct
+ * else error code.
+ */
+int tr_vrfy(void);
+
+/**
+ * If NDEBUG is defined performs nothing, else calls the tr_vrfy() function.
+ */
+#ifdef NDEBUG
+#define TR_VRFY() 0
+#else
+#define TR_VRFY() tr_vrfy()
+#endif
+
+/**
+ *
+ * @file typegmod.h
+ * This module supplies routines that support changing the type graph.
+ */
+
+/** Replaces one type by the other.
+ *
+ * Old type is replaced by new_type. All references to old_type
+ * now point to new_type. The memory for the old type is destroyed,
+ * but still used. Therefore it is not freed.
+ * All referenced to this memory will be lost after a certain while.
+ * An exception is the list of types in irp (irprog.h).
+ * In the future there might be a routine to recover the memory, but
+ * this will be at considerable runtime cost.
+ *
+ * @param old_type - The old type that shall be replaced by the new type.
+ * @param new_type - The new type that will replace old_type.
+ *
+ */
+void exchange_types(ir_type *old_type, ir_type *new_type);
+
+/** Skip id types until a useful type is reached.
+ *
+ * @param tp - A type of arbitrary kind.
+ *
+ * @return
+ * tp if it is not an id type.
+ * If tp is an id type returns the real type it stands for.
+ */
+ir_type *skip_tid(ir_type *tp);
+
+/**
+ * @page type representation of types
+ *
+ * Datastructure to hold type information.
+ *
+ * This module supplies a datastructure to represent all types
+ * known in the compiled program. This includes types specified
+ * in the program as well as types defined by the language. In the
+ * view of the intermediate representation there is no difference
+ * between these types. Finally it specifies some auxiliary types.
+ *
+ * There exist several kinds of types, arranged by the structure of
+ * the type. A type is described by a set of attributes. Some of
+ * these attributes are common to all types, others depend on the
+ * kind of the type.
+ *
+ * Types are different from the modes defined in irmode: Types are
+ * on the level of the programming language, modes at the level of
+ * the target processor.
+ *
+ * @see tpop.h
+ */
+
+#include "typerep.h"
+
+/** Frees all entities associated with a type.
+ * Does not free the array entity.
+ * Warning: ensure these entities are not referenced anywhere else.
+ */
+void free_type_entities(ir_type *tp);
+
+/** Frees the memory used by the type.
+ *
+ * Removes the type from the type list. Does not free the entities
+ * belonging to the type, except for the array element entity. Does
+ * not free if tp is "none" or "unknown". Frees entities in value
+ * param subtypes of method types!!! Make sure these are not
+ * referenced any more. Further make sure there is no pointer type
+ * that refers to this type. */
+void free_type(ir_type *tp);
+
+const tp_op*get_type_tpop(const ir_type *tp);
+ident* get_type_tpop_nameid(const ir_type *tp);
+const char* get_type_tpop_name(const ir_type *tp);
+tp_opcode get_type_tpop_code(const ir_type *tp);
+
+ident* get_type_ident(const ir_type *tp);
+void set_type_ident(ir_type *tp, ident* id);
+const char* get_type_name(const ir_type *tp);
+
+/** The visibility of a type.
+ *
+ * The visibility of a type indicates, whether entities of this type
+ * are accessed or allocated in external code.
+ *
+ * An entity of a type is allocated in external code, if the external
+ * code declares a variable of this type, or dynamically allocates
+ * an entity of this type. If the external code declares a (compound)
+ * type, that contains entities of this type, the visibility also
+ * must be external_allocated.
+ *
+ * The visibility must be higher than that of all entities, if the
+ * type is a compound. Here it is questionable, what happens with
+ * static entities. If these are accessed external by direct reference,
+ * (a static call to a method, that is also in the dispatch table)
+ * it should not affect the visibility of the type.
+ *
+ *
+ * @@@ Do we need a visibility for types?
+ * I change the layout of types radically when doing type splitting.
+ * I need to know, which fields of classes are accessed in the RTS,
+ * e.g., [_length. I may not move [_length to the split part.
+ * The layout though, is a property of the type.
+ *
+ * One could also think of changing the mode of a type ...
+ *
+ * But, we could also output macros to access the fields, e.g.,
+ * ACCESS_[_length (X) X->length // conventional
+ * ACCESS_[_length (X) X->_split_ref->length // with type splitting
+ *
+ * For now I implement this function, that returns the visibility
+ * based on the visibility of the entities of a compound ...
+ *
+ * This function returns visibility_external_visible if one or more
+ * entities of a compound type have visibility_external_visible.
+ * Entities of types are never visibility_external_allocated (right?).
+ * Else returns visibility_local.
+ */
+ir_visibility get_type_visibility(const ir_type *tp);
+void set_type_visibility(ir_type *tp, ir_visibility v);
+
+
+
+/** The state of the type layout. */
+typedef enum {
+ layout_undefined, /**< The layout of this type is not defined.
+ Address computation to access fields is not
+ possible, fields must be accessed by Sel
+ nodes. Enumeration constants might be undefined.
+ This is the default value except for
+ pointer, primitive and method types. */
+ layout_fixed /**< The layout is fixed, all component/member entities
+ have an offset assigned. Size of the type is known.
+ Arrays can be accessed by explicit address
+ computation. Enumeration constants must be defined.
+ Default for pointer, primitive and method types. */
+} type_state;
+
+/** Returns a human readable string for the enum entry. */
+const char *get_type_state_name(type_state s);
+
+/** Returns the type layout state of a type. */
+type_state get_type_state(const ir_type *tp);
+
+/** Sets the type layout state of a type.
+ *
+ * For primitives, pointer and method types the layout is always fixed.
+ * This call is legal but has no effect.
+ */
+void set_type_state(ir_type *tp, type_state state);
+
+/** Returns the mode of a type.
+ *
+ * Returns NULL for all non atomic types.
+ */
+ir_mode* get_type_mode(const ir_type *tp);
+
+/** Sets the mode of a type.
+ *
+ * Only has an effect on primitive, enumeration and pointer types.
+ */
+void set_type_mode(ir_type *tp, ir_mode* m);
+
+/** Returns the size of a type in bytes, returns -1 if the size is NOT
+ * a byte size, i.e. not dividable by 8. */
+int get_type_size_bytes(const ir_type *tp);
+
+/** Returns the size of a type in bits. */
+int get_type_size_bits(const ir_type *tp);
+
+/** Sets the size of a type in bytes.
+ *
+ * For primitive, enumeration, pointer and method types the size
+ * is always fixed. This call is legal but has no effect.
+ */
+void set_type_size_bytes(ir_type *tp, int size);
+
+/** Sets the size of a type in bits.
+ *
+ * For primitive, enumeration, pointer and method types the size
+ * is always fixed. This call is legal but has no effect.
+ */
+void set_type_size_bits(ir_type *tp, int size);
+
+/** Returns the alignment of a type in bytes.
+ *
+ * Returns -1 if the alignment is NOT
+ * a byte size, i.e. not dividable by 8. Calls get_type_alignment_bits(). */
+int get_type_alignment_bytes(ir_type *tp);
+
+/** Returns the alignment of a type in bits.
+ *
+ * If the alignment of a type is
+ * not set, it is calculated here according to the following rules:
+ * -#.) if a type has a mode, the alignment is the mode size.
+ * -#.) compound types have the alignment of there biggest member.
+ * -#.) array types have the alignment of there element type.
+ * -#.) method types return 0 here.
+ * -#.) all other types return 8 here (i.e. aligned at byte).
+ */
+int get_type_alignment_bits(ir_type *tp);
+
+/** Sets the alignment of a type in bytes. */
+void set_type_alignment_bytes(ir_type *tp, int size);
+
+/** Sets the alignment of a type in bits.
+ *
+ * For method types the alignment is always fixed.
+ * This call is legal but has no effect.
+ */
+void set_type_alignment_bits(ir_type *tp, int size);
+
+/** Returns the visited count of a type. */
+unsigned long get_type_visited(const ir_type *tp);
+/** Sets the visited count of a type to num. */
+void set_type_visited(ir_type *tp, unsigned long num);
+/** Sets visited field in type to type_visited. */
+void mark_type_visited(ir_type *tp);
+/** Returns non-zero if the type is already visited */
+int type_visited(const ir_type *tp);
+/** Returns non-zero if the type is not yet visited */
+int type_not_visited(const ir_type *tp);
+
+/** Returns the associated link field of a type. */
+void* get_type_link(const ir_type *tp);
+/** Sets the associated link field of a type. */
+void set_type_link(ir_type *tp, void *l);
+
+/**
+ * Visited flag to traverse the type information.
+ *
+ * Increase this flag by one before traversing the type information
+ * using inc_master_type_visited().
+ * Mark type nodes as visited by mark_type_visited(ir_type).
+ * Check whether node was already visited by type_visited(ir_type)
+ * and type_not_visited(ir_type).
+ * Or use the function to walk all types.
+ *
+ * @see typewalk
+ */
+void set_master_type_visited(unsigned long val);
+unsigned long get_master_type_visited(void);
+void inc_master_type_visited(void);
+
+/**
+ * Checks whether a pointer points to a type.
+ *
+ * @param thing an arbitrary pointer
+ *
+ * @return
+ * true if the thing is a type, else false
+ */
+int is_type(const void *thing);
+
+/**
+ * Checks whether two types are structurally equal.
+ *
+ * @param typ1 the first type
+ * @param typ2 the second type
+ *
+ * @return
+ * true if the types are equal, else false.
+ *
+ * Types are equal if :
+ * - they are the same type kind
+ * - they have the same name
+ * - they have the same mode (if applicable)
+ * - they have the same type_state and, ev., the same size
+ * - they are class types and have:
+ * - the same members (see same_entity in entity.h)
+ * - the same supertypes -- the C-pointers are compared --> no recursive call.
+ * - the same number of subtypes. Subtypes are not compared,
+ * as this could cause a cyclic test.
+ * - the same peculiarity
+ * - they are structure types and have the same members
+ * - they are method types and have
+ * - the same parameter types
+ * - the same result types
+ * - they are union types and have the same members
+ * - they are array types and have
+ * - the same number of dimensions
+ * - the same dimension bounds
+ * - the same dimension order
+ * - the same element type
+ * - they are enumeration types and have the same enumerator names
+ * - they are pointer types and have the identical points_to type
+ * (i.e., the same C-struct to represent the type, type_id is skipped.
+ * This is to avoid endless recursions; with pointer types cyclic
+ * type graphs are possible.)
+ */
+int equal_type(ir_type *typ1, ir_type *typ2);
+
+/**
+ * Checks whether two types are structural comparable.
+ *
+ * @param st pointer type
+ * @param lt pointer type
+ *
+ * @return
+ * true if type st is smaller than type lt, i.e. whenever
+ * lt is expected a st can be used.
+ * This is true if
+ * - they are the same type kind
+ * - mode(st) < mode (lt) (if applicable)
+ * - they are class types and st is (transitive) subtype of lt,
+ * - they are structure types and
+ * - the members of st have exactly one counterpart in lt with the same name,
+ * - the counterpart has a bigger type.
+ * - they are method types and have
+ * - the same number of parameter and result types,
+ * - the parameter types of st are smaller than those of lt,
+ * - the result types of st are smaller than those of lt
+ * - they are union types and have the members of st have exactly one
+ * @return counterpart in lt and the type is smaller
+ * - they are array types and have
+ * - the same number of dimensions
+ * - all bounds of lt are bound of st
+ * - the same dimension order
+ * - the same element type
+ * @return or
+ * - the element type of st is smaller than that of lt
+ * - the element types have the same size and fixed layout.
+ * - they are enumeration types and have the same enumerator names
+ * - they are pointer types and have the points_to type of st is
+ * @return smaller than the points_to type of lt.
+ *
+ */
+int smaller_type(ir_type *st, ir_type *lt);
+
+/**
+ * @page class_type Representation of a class type
+ *
+ * If the type opcode is set to type_class the type represents class
+ * types. A list of fields and methods is associated with a class.
+ * Further a class can inherit from and bequest to other classes.
+ *
+ * The following attributes are private to this type kind:
+ * - member: All entities belonging to this class. This are method entities
+ * which have type_method or fields that can have any of the
+ * following type kinds: type_class, type_struct, type_union,
+ * type_array, type_enumeration, type_pointer, type_primitive.
+ *
+ * The following two are dynamic lists that can be grown with an "add_" function,
+ * but not shrinked:
+ *
+ * - subtypes: A list of direct subclasses.
+ *
+ * - supertypes: A list of direct superclasses.
+ *
+ * - peculiarity: The peculiarity of this class. If the class is of peculiarity
+ * "description" it only is a description of requirements to a class,
+ * as, e.g., a Java interface. The class will never be allocated.
+ * Peculiarity inherited is only possible for entities. An entity
+ * is of peculiarity inherited if the compiler generated the entity
+ * to explicitly resolve inheritance. An inherited method entity has
+ * no value for irg.
+ * Values: description, existent, inherited. Default: existent.
+ *
+ * - type_info: An entity representing the type information of this class.
+ * This entity can be of arbitrari type, Firm did not use it yet.
+ * It allows to express the coupling of a type with an entity
+ * representing this type. This information is useful for lowering
+ * of InstOf and TypeChk nodes. Default: NULL
+ *
+ * - vtable_size: The size of this class virtual function table.
+ * Default: 0
+ *
+ * - final: A final class is always a leaf in the class hierarchy. Final
+ * classes cannot be super classes of other ones. As this information
+ * can only be computed in whole world compilations, we allow to
+ * set this flag. It is used in optimizations if get_opt_closed_world()
+ * is false. Default: false
+ *
+ * - interface: The class represents an interface. This flag can be set to distinguish
+ * between interfaces, abstract classes and other classes that all may
+ * have the peculiarity peculiarity_description. Depending on this flag
+ * the lowering might do different actions. Default: false
+ *
+ * - abstract : The class represents an abstract class. This flag can be set to distinguish
+ * between interfaces, abstract classes and other classes that all may
+ * have the peculiarity peculiarity_description. Depending on this flag
+ * the lowering might do different actions. Default: false
+ */
+
+/** Creates a new class type. */
+ir_type *new_type_class (ident *name);
+
+/** Creates a new class type with debug information. */
+ir_type *new_d_type_class (ident *name, dbg_info *db);
+
+/* --- manipulate private fields of class type --- */
+
+/** Adds the entity as member of the class. */
+void add_class_member (ir_type *clss, ir_entity *member);
+
+/** Returns the number of members of this class. */
+int get_class_n_members (const ir_type *clss);
+
+/** Returns the member at position pos, 0 <= pos < n_member */
+ir_entity *get_class_member (const ir_type *clss, int pos);
+
+/** Returns index of mem in clss, -1 if not contained. */
+int get_class_member_index(const ir_type *clss, ir_entity *mem);
+
+/** Finds the member with name 'name'. If several members with the same
+ * name returns one of them. Returns NULL if no member found. */
+ir_entity *get_class_member_by_name(ir_type *clss, ident *name);
+
+/** Overwrites the member at position pos, 0 <= pos < n_member with
+ * the passed entity. */
+void set_class_member (ir_type *clss, ir_entity *member, int pos);
+
+/** Replaces complete member list in class type by the list passed.
+ *
+ * Copies the list passed. This function is necessary to reduce the number of members.
+ * members is an array of entities, num the size of this array. Sets all
+ * owners of the members passed to clss. */
+void set_class_members (ir_type *clss, ir_entity *members[], int arity);
+
+/** Finds member in the list of members and removes it.
+ *
+ * Shrinks the member list, so iterate from the end!!!
+ * Does not deallocate the entity. */
+void remove_class_member(ir_type *clss, ir_entity *member);
+
+
+/** Adds subtype as subtype to clss.
+ *
+ * Checks whether clss is a supertype of subtype. If not
+ * adds also clss as supertype to subtype. */
+void add_class_subtype (ir_type *clss, ir_type *subtype);
+
+/** Returns the number of subtypes */
+int get_class_n_subtypes (const ir_type *clss);
+
+/** Gets the subtype at position pos, 0 <= pos < n_subtype. */
+ir_type *get_class_subtype (ir_type *clss, int pos);
+
+/** Returns the index to access subclass as subtype of class.
+ *
+ * If subclass is no direct subtype of class returns -1.
+ */
+int get_class_subtype_index(ir_type *clss, const ir_type *subclass);
+
+/** Sets the subtype at position pos, 0 <= pos < n_subtype.
+ *
+ * Does not set the corresponding supertype relation for subtype: this might
+ * be a different position! */
+void set_class_subtype (ir_type *clss, ir_type *subtype, int pos);
+
+/** Finds subtype in the list of subtypes and removes it */
+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)
+#define get_class_derived_type_index(clss, drvtype) get_class_subtype_index(clss, drvtype)
+#define set_class_derived_type(clss, drvtype, pos) set_class_subtype(clss, drvtype, pos)
+#define remove_class_derived_type(clss, drvtype) remove_class_subtype(clss, drvtype)
+
+/** Adds supertype as supertype to class.
+ *
+ * Checks whether clss is a subtype of supertype. If not
+ * adds also clss as subtype to supertype. */
+void add_class_supertype (ir_type *clss, ir_type *supertype);
+
+/** Returns the number of supertypes */
+int get_class_n_supertypes (const ir_type *clss);
+
+/** Returns the index to access superclass as supertype of class.
+ *
+ * If superclass is no direct supertype of class returns -1.
+ */
+int get_class_supertype_index(ir_type *clss, ir_type *super_clss);
+
+/** Gets the supertype at position pos, 0 <= pos < n_supertype. */
+ir_type *get_class_supertype (ir_type *clss, int pos);
+
+/** Sets the supertype at position pos, 0 <= pos < n_supertype.
+ *
+ * Does not set the corresponding subtype relation for supertype: this might
+ * be at a different position! */
+void set_class_supertype (ir_type *clss, ir_type *supertype, int pos);
+
+/** Finds supertype in the list of supertypes and removes it */
+void remove_class_supertype(ir_type *clss, ir_type *supertype);
+
+/** Convenience macro */
+#define add_class_base_type(clss, basetype) add_class_supertype(clss, basetype)
+#define get_class_n_base_types(clss) get_class_n_supertypes(clss)
+#define get_class_base_type_index(clss, base_clss) get_class_supertype_index(clss, base_clss)
+#define get_class_base_type(clss, pos) get_class_supertype(clss, pos)
+#define set_class_base_type(clss, basetype, pos) set_class_supertype(clss, basetype, pos)
+#define remove_class_base_type(clss, basetype) remove_class_supertype(clss, basetype)
+
+/** Convenience macro */
+#define add_class_base_type(clss, basetype) add_class_supertype(clss, basetype)
+#define get_class_n_base_types(clss) get_class_n_supertypes(clss)
+#define get_class_base_type_index(clss, base_clss) get_class_supertype_index(clss, base_clss)
+#define get_class_base_type(clss, pos) get_class_supertype(clss, pos)
+#define set_class_base_type(clss, basetype, pos) set_class_supertype(clss, basetype, pos)
+#define remove_class_base_type(clss, basetype) remove_class_supertype(clss, basetype)
+
+/** Returns a human readable string for a peculiarity. */
+const char *get_peculiarity_name(ir_peculiarity p);
+
+/** Returns the peculiarity of the class. */
+ir_peculiarity get_class_peculiarity (const ir_type *clss);
+/** Sets the peculiarity of the class. */
+void set_class_peculiarity (ir_type *clss, ir_peculiarity pec);
+
+/** Returns the type info entity of a class. */
+ir_entity *get_class_type_info(const ir_type *clss);
+
+/** Set a type info entity for the class. */
+void set_class_type_info(ir_type *clss, ir_entity *ent);
+
+/** Returns the size of the virtual function table. */
+unsigned get_class_vtable_size(const ir_type *clss);
+
+/** Sets a new size of the virtual function table. */
+void set_class_vtable_size(ir_type *clss, unsigned size);
+
+/** Returns non-zero if a class is final. */
+int is_class_final(const ir_type *clss);
+
+/** Sets the class final flag. */
+void set_class_final(ir_type *clss, int flag);
+
+/** Return non-zero if a class is an interface */
+int is_class_interface(const ir_type *clss);
+
+/** Sets the class interface flag. */
+void set_class_interface(ir_type *clss, int flag);
+
+/** Return non-zero if a class is an abstract class. */
+int is_class_abstract(const ir_type *clss);
+
+/** Sets the class abstract flag. */
+void set_class_abstract(ir_type *clss, int flag);
+
+/** Set and get a class' dfn --
+ @todo This is an undocumented field, subject to change! */
+void set_class_dfn (ir_type *clss, int dfn);
+int get_class_dfn (const ir_type *clss);
+
+/** Returns true if a type is a class type. */
+int is_Class_type(const ir_type *clss);
+
+/**
+ * @page struct_type Representation of a struct type
+ *
+ * A struct type represents aggregate types that consist of a list
+ * of fields.
+ *
+ * The following attributes are private to this type kind:
+ * - member: All entities belonging to this class. This are the fields
+ * that can have any of the following types: type_class,
+ * type_struct, type_union, type_array, type_enumeration,
+ * type_pointer, type_primitive.
+ * This is a dynamic list that can be grown with an "add_" function,
+ * but not shrinked.
+ * This is a dynamic list that can be grown with an "add_" function,
+ * but not shrinked.
+ */
+/** Creates a new type struct */
+ir_type *new_type_struct (ident *name);
+/** Creates a new type struct with debug information. */
+ir_type *new_d_type_struct (ident *name, dbg_info* db);
+
+/* --- manipulate private fields of struct --- */
+
+/** Adds the entity as member of the struct. */
+void add_struct_member (ir_type *strct, ir_entity *member);
+
+/** Returns the number of members of this struct. */
+int get_struct_n_members (const ir_type *strct);
+
+/** Returns the member at position pos, 0 <= pos < n_member */
+ir_entity *get_struct_member (const ir_type *strct, int pos);
+
+/** Returns index of member in strct, -1 if not contained. */
+int get_struct_member_index(const ir_type *strct, ir_entity *member);
+
+/** Overwrites the member at position pos, 0 <= pos < n_member with
+ the passed entity. */
+void set_struct_member (ir_type *strct, int pos, ir_entity *member);
+
+/** Finds member in the list of members and removes it. */
+void remove_struct_member (ir_type *strct, ir_entity *member);
+
+/** Returns true if a type is a struct type. */
+int is_Struct_type(const ir_type *strct);
+
+/**
+ * @page method_type Representation of a method type
+ *
+ * A method type represents a method, function or procedure type.
+ * It contains a list of the parameter and result types, as these
+ * are part of the type description. These lists should not
+ * be changed by a optimization, as a change creates a new method
+ * type. Therefore optimizations should allocated new method types.
+ * The set_ routines are only for construction by a frontend.
+ *
+ * - n_params: Number of parameters to the procedure.
+ * A procedure in FIRM has only call by value parameters.
+ *
+ * - param_type: A list with the types of parameters. This list is ordered.
+ * The nth type in this list corresponds to the nth element
+ * in the parameter tuple that is a result of the start node.
+ * (See ircons.h for more information.)
+ *
+ * - value_param_ents
+ * A list of entities (whose owner is a struct private to the
+ * method type) that represent parameters passed by value.
+ *
+ * - n_res: The number of results of the method. In general, procedures
+ * have zero results, functions one.
+ *
+ * - res_type: A list with the types of parameters. This list is ordered.
+ * The nth type in this list corresponds to the nth input to
+ * Return nodes. (See ircons.h for more information.)
+ *
+ * - value_res_ents
+ * A list of entities (whose owner is a struct private to the
+ * method type) that represent results passed by value.
+ */
+
+/* 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 name the name (ident) of this type
+ * @param n_param the number of parameters
+ * @param n_res the number of results
+ *
+ * The arrays for the parameter and result types are not initialized by
+ * the constructor.
+ */
+ir_type *new_type_method (ident *name, int n_param, int n_res);
+
+/** Create a new method type with debug information.
+ *
+ * @param name the name (ident) of this type
+ * @param n_param the number of parameters
+ * @param n_res the number of results
+ * @param db user defined debug information
+ *
+ * The arrays for the parameter and result types are not initialized by
+ * the constructor.
+ */
+ir_type *new_d_type_method (ident *name, int n_param, int n_res, dbg_info* db);
+
+/* -- manipulate private fields of method. -- */
+
+/** Returns the number of parameters of this method. */
+int get_method_n_params (const ir_type *method);
+
+/** Returns the type of the parameter at position pos of a method. */
+ir_type *get_method_param_type(ir_type *method, int pos);
+/** Sets the type of the parameter at position pos of a method.
+ Also changes the type in the pass-by-value representation by just
+ changing the type of the corresponding entity if the representation is constructed. */
+void set_method_param_type(ir_type *method, int pos, ir_type *tp);
+/** Returns an entity that represents the copied value argument. Only necessary
+ for compounds passed by value. This information is constructed only on demand. */
+ir_entity *get_method_value_param_ent(ir_type *method, int pos);
+/**
+ * Returns a type that represents the copied value arguments if one
+ * was allocated, else NULL.
+ */
+ir_type *get_method_value_param_type(const ir_type *method);
+/** Returns an ident representing the parameters name. Returns NULL if not set.
+ For debug support only. */
+ident *get_method_param_ident(ir_type *method, int pos);
+/** Returns a string representing the parameters name. Returns NULL if not set.
+ For debug support only. */
+const char *get_method_param_name(ir_type *method, int pos);
+/** Sets an ident representing the parameters name. For debug support only. */
+void set_method_param_ident(ir_type *method, int pos, ident *id);
+
+/** Returns the number of results of a method type. */
+int get_method_n_ress (const ir_type *method);
+/** Returns the return type of a method type at position pos. */
+ir_type *get_method_res_type(ir_type *method, int pos);
+/** Sets the type of the result at position pos of a method.
+ Also changes the type in the pass-by-value representation by just
+ changing the type of the corresponding entity if the representation is constructed. */
+void set_method_res_type(ir_type *method, int pos, ir_type *tp);
+/** Returns an entity that represents the copied value result. Only necessary
+ for compounds passed by value. This information is constructed only on demand. */
+ir_entity *get_method_value_res_ent(ir_type *method, int pos);
+
+/**
+ * Returns a type that represents the copied value results.
+ */
+ir_type *get_method_value_res_type(const ir_type *method);
+
+/**
+ * This enum flags the variadicity of methods (methods with a
+ * variable amount of arguments (e.g. C's printf). Default is
+ * non_variadic.
+ */
+typedef enum variadicity {
+ variadicity_non_variadic, /**< non variadic */
+ variadicity_variadic /**< variadic */
+} variadicity;
+
+/** Returns the null-terminated name of this variadicity. */
+const char *get_variadicity_name(variadicity vari);
+
+/** Returns the variadicity of a method. */
+variadicity get_method_variadicity(const ir_type *method);
+
+/** Sets the variadicity of a method. */
+void set_method_variadicity(ir_type *method, variadicity vari);
+
+/**
+ * Returns the first variadic parameter index of a type.
+ * If this index was NOT set, the index of the last parameter
+ * of the method type plus one is returned for variadic functions.
+ * Non-variadic function types always return -1 here.
+ */
+int get_method_first_variadic_param_index(const ir_type *method);
+
+/**
+ * Sets the first variadic parameter index. This allows to specify
+ * a complete call type (containing the type of all parameters)
+ * but still have the knowledge, which parameter must be passed as
+ * variadic one.
+ */
+void set_method_first_variadic_param_index(ir_type *method, int index);
+
+/** Returns the mask of the additional graph properties. */
+unsigned get_method_additional_properties(const ir_type *method);
+
+/** Sets the mask of the additional graph properties. */
+void set_method_additional_properties(ir_type *method, unsigned property_mask);
+
+/** Sets one additional graph property. */
+void set_method_additional_property(ir_type *method, mtp_additional_property flag);
+
+/**
+ * Calling conventions: lower 24 bits are the number of register parameters,
+ * upper 8 encode the calling conventions.
+ */
+typedef enum {
+ cc_reg_param = 0x01000000, /**< Transmit parameters in registers, else the stack is used.
+ This flag may be set as default on some architectures. */
+ cc_last_on_top = 0x02000000, /**< The last non-register parameter is transmitted on top of
+ the stack. This is equivalent to the pascal
+ calling convention. If this flag is not set, the first
+ non-register parameter is used (stdcall or cdecl
+ calling convention) */
+ cc_callee_clear_stk = 0x04000000, /**< The callee clears the stack. This forbids variadic
+ function calls (stdcall). */
+ cc_this_call = 0x08000000, /**< The first parameter is a this pointer and is transmitted
+ in a special way. */
+
+ 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 */
+#define cc_stdcall_set cc_callee_clear_stk
+/** fastcall calling convention */
+#define cc_fastcall_set (cc_reg_param|cc_callee_clear_stk)
+
+/** Returns the default calling convention for method types. */
+unsigned get_default_cc_mask(void);
+
+/**
+ * check for the CDECL calling convention
+ */
+#define IS_CDECL(cc_mask) (((cc_mask) & cc_bits) == cc_cdecl_set)
+
+/**
+ * check for the STDCALL calling convention
+ */
+#define IS_STDCALL(cc_mask) (((cc_mask) & cc_bits) == cc_stdcall_set)
+
+/**
+ * check for the FASTCALL calling convention
+ */
+#define IS_FASTCALL(cc_mask) (((cc_mask) & cc_bits) == cc_fastcall_set)
+
+/**
+ * Sets the CDECL convention bits.
+ */
+#define SET_CDECL(cc_mask) (((cc_mask) & ~cc_bits) | cc_cdecl_set)
+
+/**
+ * Set. the STDCALL convention bits.
+ */
+#define SET_STDCALL(cc_mask) (((cc_mask) & ~cc_bits) | cc_stdcall_set)
+
+/**
+ * Sets the FASTCALL convention bits.
+ */
+#define SET_FASTCALL(cc_mask) (((cc_mask) & ~cc_bits) | cc_fastcall_set)
+
+/** Returns the calling convention of an entities graph. */
+unsigned get_method_calling_convention(const ir_type *method);
+
+/** Sets the calling convention of an entities graph. */
+void set_method_calling_convention(ir_type *method, unsigned cc_mask);
+
+/** Returns the number of registers parameters, 0 means default. */
+unsigned get_method_n_regparams(ir_type *method);
+
+/** Sets the number of registers parameters, 0 means default. */
+void set_method_n_regparams(ir_type *method, unsigned n_regs);
+
+/** Returns true if a type is a method type. */
+int is_Method_type (const ir_type *method);
+
+/**
+ * @page union_type Representation of a union (variant) type.
+ *
+ * The union type represents union types. Note that this representation
+ * resembles the C union type. For tagged variant types like in Pascal or Modula
+ * a combination of a struct and a union type must be used.
+ *
+ * - n_types: Number of unioned types.
+ * - members: Entities for unioned types. Fixed length array.
+ * This is a dynamic list that can be grown with an "add_" function,
+ * but not shrinked.
+ */
+/** Creates a new type union. */
+ir_type *new_type_union (ident *name);
+
+/** Creates a new type union with debug information. */
+ir_type *new_d_type_union (ident *name, dbg_info* db);
+
+/* --- manipulate private fields of struct --- */
+
+/** Returns the number of unioned types of this union */
+int get_union_n_members (const ir_type *uni);
+
+/** Adds a new entity to a union type */
+void add_union_member (ir_type *uni, ir_entity *member);
+
+/** Returns the entity at position pos of a union */
+ir_entity *get_union_member (const ir_type *uni, int pos);
+
+/** Returns index of member in uni, -1 if not contained. */
+int get_union_member_index(const ir_type *uni, ir_entity *member);
+
+/** Overwrites a entity at position pos in a union type. */
+void set_union_member (ir_type *uni, int pos, ir_entity *member);
+
+/** Finds member in the list of members and removes it. */
+void remove_union_member (ir_type *uni, ir_entity *member);
+
+/** Returns true if a type is a union type. */
+int is_Union_type (const ir_type *uni);
+
+/**
+ * @page array_type Representation of an array type
+ *
+ * The array type represents rectangular multi dimensional arrays.
+ * The constants representing the bounds must be allocated to
+ * get_const_code_irg() by setting current_ir_graph accordingly.
+ *
+ * - n_dimensions: Number of array dimensions.
+ * - *lower_bound: Lower bounds of dimensions. Usually all 0.
+ * - *upper_bound: Upper bounds or dimensions.
+ * - *element_type: The type of the array elements.
+ * - *element_ent: An entity for the array elements to be used for
+ * element selection with Sel.
+ * @todo
+ * Do we need several entities? One might want
+ * to select a dimension and not a single element in case of multi
+ * dimensional arrays.
+ */
+
+/** Create a new type array.
+ *
+ * Sets n_dimension to dimension and all dimension entries to NULL.
+ * Initializes order to the order of the dimensions.
+ * The entity for array elements is built automatically.
+ * Set dimension sizes after call to constructor with set_* routines.
+ */
+ir_type *new_type_array (ident *name, int n_dimensions,
+ ir_type *element_type);
+
+/** Create a new type array with debug information.
+ *
+ * Sets n_dimension to dimension and all dimension entries to NULL.
+ * Initializes order to the order of the dimensions.
+ * The entity for array elements is built automatically.
+ * Set dimension sizes after call to constructor with set_* routines.
+ * A legal array type must have at least one dimension set.
+ */
+ir_type *new_d_type_array (ident *name, int n_dimensions,
+ ir_type *element_type, dbg_info* db);
+
+/* --- manipulate private fields of array type --- */
+
+/** Returns the number of array dimensions of this type. */
+int get_array_n_dimensions (const ir_type *array);
+
+/**
+ * Allocates Const nodes of mode_Is for one array dimension.
+ * Upper bound in Firm is the element next to the last, i.e. [lower,upper[
+ */
+void set_array_bounds_int (ir_type *array, int dimension, int lower_bound,
+ int upper_bound);
+/**
+ * Sets the bounds for one array dimension.
+ * Upper bound in Firm is the element next to the last, i.e. [lower,upper[
+ */
+void set_array_bounds (ir_type *array, int dimension, ir_node *lower_bound,
+ ir_node *upper_bound);
+/** Sets the lower bound for one array dimension, i.e. [lower,upper[ */
+void set_array_lower_bound (ir_type *array, int dimension, ir_node *lower_bound);
+
+/** Allocates Const nodes of mode_Is for the lower bound of an array
+ dimension, i.e. [lower,upper[ */
+void set_array_lower_bound_int (ir_type *array, int dimension, int lower_bound);
+
+/** Sets the upper bound for one array dimension, i.e. [lower,upper[ */
+void set_array_upper_bound (ir_type *array, int dimension, ir_node *upper_bound);
+
+/** Allocates Const nodes of mode_Is for the upper bound of an array
+ dimension, i.e. [lower,upper[. */
+void set_array_upper_bound_int (ir_type *array, int dimension, int upper_bound);
+
+/** Returns true if lower bound != Unknown. */
+int has_array_lower_bound (const ir_type *array, int dimension);
+/** Returns the lower bound of an array. */
+ir_node * get_array_lower_bound (const ir_type *array, int dimension);
+/** Works only if bound is Const node with tarval that can be converted to long. */
+long get_array_lower_bound_int (const ir_type *array, int dimension);
+/** returns true if lower bound != Unknown */
+int has_array_upper_bound (const ir_type *array, int dimension);
+/** Returns the upper bound of an array. */
+ir_node * get_array_upper_bound (const ir_type *array, int dimension);
+/** Works only if bound is Const node with tarval that can be converted to long. */
+long get_array_upper_bound_int (const ir_type *array, int dimension);
+
+/** Sets an array dimension to a specific order. */
+void set_array_order (ir_type *array, int dimension, int order);
+
+/** Returns the order of an array dimension. */
+int get_array_order (const ir_type *array, int dimension);
+
+/** Find the array dimension that is placed at order order. */
+int find_array_dimension(const ir_type *array, int order);
+
+/** Sets the array element type. */
+void set_array_element_type (ir_type *array, ir_type* tp);
+
+/** Gets the array element type. */
+ir_type *get_array_element_type (ir_type *array);
+
+/** Sets the array element entity. */
+void set_array_element_entity (ir_type *array, ir_entity *ent);
+
+/** Get the array element entity. */
+ir_entity *get_array_element_entity (const ir_type *array);
+
+/** Returns true if a type is an array type. */
+int is_Array_type(const ir_type *array);
+
+/**
+ * @page enumeration_type Representation of an enumeration type
+ *
+ * Enumeration types need not necessarily be represented explicitly
+ * by Firm types, as the frontend can lower them to integer constants as
+ * well. For debugging purposes or similar tasks this information is useful.
+ * The type state layout_fixed is set, if all enumeration constant have
+ * there tarvals assigned. Until then
+ *
+ * - *const: The target values representing the constants used to
+ * represent individual enumerations.
+ */
+
+/** Create a new type enumeration -- set the enumerators independently. */
+ir_type *new_type_enumeration(ident *name, int n_enums);
+
+/** Create a new type enumeration with debug information -- set the enumerators independently. */
+ir_type *new_d_type_enumeration(ident *name, int n_enums, dbg_info *db);
+
+/* --- manipulate fields of enumeration type. --- */
+
+/** Set an enumeration constant to a enumeration type at a given position. */
+void set_enumeration_const(ir_type *enumeration, int pos, ident *nameid, tarval *con);
+
+/** Returns the number of enumeration values of this enumeration */
+int get_enumeration_n_enums(const ir_type *enumeration);
+
+/** Returns the enumeration constant at a given position. */
+ir_enum_const *get_enumeration_const(const ir_type *enumeration, int pos);
+
+/** Returns the enumeration type owner of an enumeration constant. */
+ir_type *get_enumeration_owner(const ir_enum_const *enum_cnst);
+
+/** Sets the enumeration constant value. */
+void set_enumeration_value(ir_enum_const *enum_cnst, tarval *con);
+
+/** Returns the enumeration constant value. */
+tarval *get_enumeration_value(const ir_enum_const *enum_cnst);
+
+/** Assign an ident to an enumeration constant. */
+void set_enumeration_nameid(ir_enum_const *enum_cnst, ident *id);
+
+/** Returns the assigned ident of an enumeration constant. */
+ident *get_enumeration_nameid(const ir_enum_const *enum_cnst);
+
+/** Returns the assigned name of an enumeration constant. */
+const char *get_enumeration_name(const ir_enum_const *enum_cnst);
+
+/** Returns true if a type is a enumeration type. */
+int is_Enumeration_type(const ir_type *enumeration);
+
+/**
+ * @page pointer_type Representation of a pointer type
+ *
+ * The mode of the pointer type must be a reference mode.
+ *
+ * Pointer types:
+ * - points_to: The type of the entity this pointer points to.
+ */
+
+/** Creates a new type pointer. */
+ir_type *new_type_pointer (ident *name, ir_type *points_to, ir_mode *ptr_mode);
+
+/** Creates a new type pointer with debug information. */
+ir_type *new_d_type_pointer (ident *name, ir_type *points_to, ir_mode *ptr_mode, dbg_info* db);
+
+/* --- manipulate fields of type_pointer --- */
+
+/** Sets the type to which a pointer points to. */
+void set_pointer_points_to_type (ir_type *pointer, ir_type *tp);
+
+/** Returns the type to which a pointer points to. */
+ir_type *get_pointer_points_to_type (ir_type *pointer);
+
+/** Returns true if a type is a pointer type. */
+int is_Pointer_type (const ir_type *pointer);
+
+/** Returns the first pointer type that has as points_to tp.
+ * Not efficient: O(#types).
+ * If not found returns firm_unknown_type. */
+ir_type *find_pointer_type_to_type (ir_type *tp);
+
+/**
+ * @page primitive_type Representation of a primitive type
+ *
+ * Primitive types are types that represent atomic data values that
+ * map directly to modes. They don't have private attributes. The
+ * important information they carry is held in the common mode field.
+ */
+/** Creates a new primitive type. */
+ir_type *new_type_primitive(ident *name, ir_mode *mode);
+
+/** Creates a new primitive type with debug information. */
+ir_type *new_d_type_primitive(ident *name, ir_mode *mode, dbg_info* db);
+
+/** Returns true if a type is a primitive type. */
+int is_Primitive_type(const ir_type *primitive);
+
+
+/**
+ * @page none_type The None type
+ *
+ * This type is an auxiliary type dedicated to support type analyses.
+ *
+ * The none type represents that there is no type. The type can be used to
+ * initialize fields of type* that actually can not contain a type or that
+ * are initialized for an analysis. There exists exactly one type none.
+ * This type is not on the type list in ir_prog. It is
+ * allocated when initializing the type module.
+ *
+ * The following values are set:
+ * - mode: mode_BAD
+ * - name: "type_none"
+ * - state: layout_fixed
+ * - size: 0
+ */
+/** A variable that contains the only none type. */
+extern ir_type *firm_none_type;
+
+/** Returns the none type. */
+ir_type *get_none_type(void);
+
+/**
+ * @page unknown_type The Unknown type
+ *
+ * This type is an auxiliary type dedicated to support type analyses.
+ *
+ * The unknown type represents that there could be a type, but it is not
+ * known. This type can be used to initialize fields before an analysis (not known
+ * yet) or to represent the top of a lattice (could not be determined). There exists
+ * exactly one type unknown. This type is not on the type list in ir_prog. It is
+ * allocated when initializing the type module.
+ *
+ * The following values are set:
+ * - mode: mode_ANY
+ * - name: "type_unknown"
+ * - state: layout_fixed
+ * - size: 0
+ */
+/** A variable that contains the only unknown type. */
+extern ir_type *firm_unknown_type;
+
+/** Returns the unknown type. */
+ir_type *get_unknown_type(void);
+
+
+/**
+ * Checks whether a type is atomic.
+ * @param tp any type
+ * @return true if type is primitive, pointer or enumeration
+ */
+int is_atomic_type(const ir_type *tp);
+
+/* --- Support for compound types --- */
+
+/**
+ * Gets the number of elements in a Firm compound type.
+ *
+ * This is just a comfortability function, because structs and
+ * classes can often be treated be the same code, but they have
+ * different access functions to their members.
+ *
+ * @param tp The type (must be struct, union or class).
+ *
+ * @return Number of members in the compound type.
+ */
+int get_compound_n_members(const ir_type *tp);
+
+/**
+ * Gets the member of a Firm compound type at position pos.
+ *
+ * @param tp The type (must be struct, union or class).
+ * @param pos The number of the member.
+ *
+ * @return The member entity at position pos.
+ *
+ * @see get_compound_n_members() for justification of existence.
+ */
+ir_entity *get_compound_member(const ir_type *tp, int pos);
+
+/** Returns index of member in tp, -1 if not contained. */
+int get_compound_member_index(const ir_type *tp, ir_entity *member);
+
+/**
+ * Checks whether a type is a compound type.
+ *
+ * @param tp - any type
+ *
+ * @return true if the type is class, structure, union or array type.
+ */
+int is_compound_type(const ir_type *tp);
+
+/**
+ * Checks, whether a type is a frame type.
+ */
+int is_frame_type(const ir_type *tp);
+
+/**
+ * Checks, whether a type is a value parameter type.
+ */
+int is_value_param_type(const ir_type *tp);
+
+/**
+ * Checks, whether a type is a lowered type.
+ */
+int is_lowered_type(const ir_type *tp);
+
+/**
+ * Makes a new frame type. Frame types are class types,
+ * so all class access functions work.
+ * Frame types are not in the global list of types.
+ */
+ir_type *new_type_frame(ident *name);
+
+/**
+ * Sets a lowered type for a type. This sets both associations
+ * and marks lowered_type as a "lowered" one.
+ */
+void set_lowered_type(ir_type *tp, ir_type *lowered_type);
+
+/**
+ * Gets the lowered/unlowered type of a type or NULL if this type
+ * has no lowered/unlowered one.
+ */
+ir_type *get_associated_type(const ir_type *tp);
+
+/**
+ * Allocate an area of size bytes aligned at alignment
+ * at the start or the end of a frame type.
+ * The frame type must already have a fixed layout.
+ *
+ * @param frame_type a frame type
+ * @param size the size of the entity
+ * @param alignment the alignment of the entity
+ * @param at_start if true, put the area at the frame type's start, else at end
+ *
+ * @return the entity representing the area
+ */
+ir_entity *frame_alloc_area(ir_type *frame_type, int size, int 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
+ * of the type cast to long.
+ */
+long get_type_nr(const ir_type *tp);
+
+/* ------------------------------------------------------------------------ */
+
+/** Type for a function that compares two types.
+ *
+ * @param tp1 The first type to compare.
+ * @param tp2 The second type to compare.
+ */
+typedef int (compare_types_func_t)(const void *tp1, const void *tp2);
+
+/** Compares two types by their name.
+ *
+ * Compares the opcode and the name of the types. If these are
+ * equal returns 0, else non-zero.
+ */
+int compare_names (const void *tp1, const void *tp2);
+
+/** Compares two types strict.
+ *
+ * returns 0 if tp1 == tp2, else non-zero
+ */
+int compare_strict (const void *tp1, const void *tp2);
+
+/* ------------------------------------------------------------------------ */
+
+/** Type for a function that computes a hash value for a type.
+ *
+ * @param tp The type to compute a hash for.
+ */
+typedef int (hash_types_func_t)(ir_type *tp);
+
+/** Computes a hash value by the type name.
+ *
+ * Uses the name of the type and the type opcode to compute the hash.
+ */
+int firm_hash_name (ir_type *tp);
+
+/* ------------------------------------------------------------------------ */
+
+/** Finalize type construction.
+ *
+ * Indicate that a type is so far completed that it can be
+ * distinguished from other types. Mature_type hashes the type into a
+ * table. It uses the function in compare_types_func to compare the
+ * types.
+ *
+ * If it finds a type identical to tp it returns this type. It turns
+ * tp into the Id type. All places formerly pointing to tp will now
+ * point to the found type. All entities of tp now refer to the found
+ * type as their owner, but they are not a member of this type. This
+ * is invalid firm -- the entities must be replaced by entities of the
+ * found type. The Id type will be removed from the representation
+ * automatically, but within an unknown time span. It occupies memory
+ * for this time.
+ *
+ * @param tp The type to mature.
+ */
+ir_type * mature_type(ir_type *tp);
+
+/** Finalize type construction.
+ *
+ * Indicate that a type is so far completed that it can be
+ * distinguished from other types. Mature_type hashes the type into a
+ * table. It uses the function in compare_types_func to compare the
+ * types.
+ *
+ * If it finds a type identical to tp it returns this type. It frees
+ * type tp and all its entities.
+ *
+ * @param tp The type to mature.
+ */
+ir_type * mature_type_free(ir_type *tp);
+
+/** Finalize type construction.
+ *
+ * Indicate that a type is so far completed that it can be
+ * distinguished from other types. Mature_type hashes the type into a
+ * table. It uses the function in compare_types_func to compare the
+ * types.
+ *
+ * If it find a type identical to tp it returns this type. It frees
+ * the entities and turns the type into an Id type. All places
+ * formerly pointing to tp will now point to the found type. The Id
+ * type will be removed from the representation automatically, but
+ * within an unknown time span. It occupies memory for this time.
+ *
+ * @param tp The type to mature.
+ */
+ir_type * mature_type_free_entities(ir_type *tp);
+
+/**
+ * The interface type for the type identify module;
+ */
+typedef struct _type_identify_if_t {
+ compare_types_func_t *cmp; /**< The function that should be used to compare two types.
+ If NULL, compare_strict() will be used. */
+ hash_types_func_t *hash; /**< The function that should be used to calculate a hash
+ value of a type. If NULL, hash_name() will be used. */
+} type_identify_if_t;
+
+/**
+ * Initialise the type identifier module.
+ *
+ * @param ti_if The interface functions for this module.
+ *
+ * If the parameter ti_if is NULL, the default functions compare_strict() and
+ * firm_hash_name() will be used.
+ */
+void init_type_identify(type_identify_if_t *ti_if);
+
+/** A data type to treat types and entities as the same. */
+typedef union {
+ ir_type *typ; /**< points to a type */
+ ir_entity *ent; /**< points to an entity */
+} type_or_ent;
+
+/** Type of argument functions for type walkers.
+ *
+ * @param tore points to the visited type or entity
+ * @param env free environment pointer
+ */
+typedef void type_walk_func(type_or_ent *tore, void *env);
+
+/** The class walk function
+ *
+ * @param clss points to the visited class
+ * @param env free environment pointer
+ */
+typedef void class_walk_func(ir_type *clss, void *env);
+
+/** Touches every type and entity in unspecified order. If new
+ * types/entities are created during the traversal these will
+ * be visited, too.
+ * Does not touch frame types or types for value params ... */
+void type_walk(type_walk_func *pre, type_walk_func *post, void *env);
+
+/** Walks over all type information reachable from an ir graph.
+ *
+ * Walks over all type information reachable from irg, i.e., starts a
+ * type walk at the irgs entity, the irgs frame type and all types and
+ * entities that are attributes to firm nodes. */
+void type_walk_irg(ir_graph *irg, type_walk_func *pre, type_walk_func *post,
+ void *env);
+
+/**
+ Touches every class in specified order:
+ - first the super class
+ - second the class itself
+ - third the sub classes. If new classes are created
+ during the traversal these will be visited, too.
+
+ @todo should be named class-walk
+
+ @deprecated will be removed?
+*/
+void type_walk_super2sub(type_walk_func *pre, type_walk_func *post, void *env);
+
+/** Walker for class types in inheritance order.
+ *
+ * Touches every class in specified order:
+ * - first the super class
+ * - second the class itself
+ * If new classes are created during the traversal these
+ * will be visited, too.
+ * Starts the walk at arbitrary classes.
+ * Executes pre when first visiting a class. Executes post after
+ * visiting all superclasses.
+ *
+ * The arguments pre, post, env may be NULL. */
+void type_walk_super(type_walk_func *pre, type_walk_func *post, void *env);
+
+/** Same as type_walk_super2sub, but visits only class types.
+ Executes pre for a class if all superclasses have been visited.
+ Then iterates to subclasses. Executes post after return from
+ subclass.
+ Does not visit global type, frame types.
+
+ @bug ?? something is wrong with this.
+*/
+void class_walk_super2sub(class_walk_func *pre, class_walk_func *post,
+ void *env);
+
+/**
+ * the entity walk function. A function type for entity walkers.
+ *
+ * @param ent points to the visited entity
+ * @param env free environment pointer
+ */
+typedef void entity_walk_func(ir_entity *ent, void *env);
+
+/**
+ * Walks over all entities in the type.
+ *
+ * @param tp the type
+ * @param doit the entity walker function
+ * @param env environment, will be passed to the walker function
+ */
+void walk_types_entities(ir_type *tp, entity_walk_func *doit, void *env);
+
+#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file absgraph.h
- * @author Sebastian Hack
- * @date 20.04.2007
- * @version $Id$
- * @summary
- *
- * An abstract graph "interface". Currently
- * only used by the DFS facility.
- *
- * This is just that we can do some graph algos
- * on the CFG, dominance tree, etc.
- */
-#ifndef FIRM_ANA_ABSGRAPH_H
-#define FIRM_ANA_ABSGRAPH_H
-
-#include "obst.h"
-
-typedef struct _absgraph_t {
- void *(*get_root)(void *self);
- void (*grow_succs)(void *self, void *node, struct obstack *obst);
-} absgraph_t;
-
-extern const absgraph_t absgraph_irg_cfg_succ;
-extern const absgraph_t absgraph_irg_cfg_pred;
-
-#endif /* FIRM_ANA_ABSGRAPH_H */
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief read/write analyze of graph argument, which have mode reference
- * @author Beyhan Veliev
- * @version $Id$
- */
-#ifndef FIRM_ANA_ANALYZE_IRG_ARGS_H
-#define FIRM_ANA_ANALYZE_IRG_ARGS_H
-
-#include "irgraph.h"
-#include "entity.h"
-
-/**
- * Returns for a method with pointer parameter
- * if they will be read or written.
- *
- * @param ent The entity that represent this method.
- * @param pos The position of method's parameter for that
- * we need information.
-
- * If the pos'th parameter is NOT of a pointer type, ptr_access_none
- * is returned;
- */
-ptr_access_kind get_method_param_access(ir_entity *ent, int pos);
-
-/**
- * Analyze how pointer arguments of a given
- * ir graph are accessed.
- *
- * @param irg The ir graph to analyze.
- */
-void analyze_irg_args(ir_graph *irg);
-
-/**
- * Returns for a method the 'weight' that every parameter
- * has on optimization possibility. Higher values allows
- * higher optimization with procedure cloning.
- *
- * The values are calculation on demand only.
- */
-float get_method_param_weight(ir_entity *ent, int pos);
-
-/**
- * Analyze the parameters of a given ir graph.
- *
- * @param irg The ir graph to analyze.
- */
-void analyze_irg_args_weight(ir_graph *irg);
-
-#endif
some_outof_loop = 1;
} else {
if (get_irg_uplink(pred) < get_irg_uplink(root)) {
- DDMG(pred); DDMG(root);
assert(get_irg_uplink(pred) >= get_irg_uplink(root));
}
some_in_loop = 1;
some_outof_loop = 1;
} else {
if(get_irg_uplink(pred) < get_irg_uplink(root)) {
- DDMG(pred); DDMG(root);
assert(get_irg_uplink(pred) >= get_irg_uplink(root));
}
some_in_loop = 1;
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Representation and computation of the callgraph.
- * @author Goetz Lindenmaier
- * @date 21.7.2004
- * @version $Id$
- * @summary
- * This file contains the representation of the callgraph.
- * The nodes of the call graph are ir_graphs. The edges between
- * the nodes are calling relations. I.e., if method a calls method
- * b at some point, there is an edge between a and b.
- *
- * Further this file contains an algorithm to construct the call
- * graph. The construction of the callgraph uses the callee
- * information in Call nodes to determine which methods are called.
- *
- * Finally this file contains an algorithm that computes backedges
- * in the callgraph, i.e., the algorithm finds possibly recursive calls.
- * The algorithm computes an upper bound of all recursive calls.
- */
-#ifndef FIRM_ANA_CALLGRAPH_H
-#define FIRM_ANA_CALLGRAPH_H
-
-#include "firm_types.h"
-
-/** Flag to indicate state of callgraph. */
-typedef enum {
- irp_callgraph_none, /**< No callgraph allocated. */
- irp_callgraph_consistent, /**< Callgraph constistent but calltree is inconsistent */
- irp_callgraph_inconsistent, /**< Callgraph is allocated but inconsistent. */
- irp_callgraph_and_calltree_consistent /**< Both callgraph and calltree are consistent. */
-} irp_callgraph_state;
-
-/** Returns the callgraph state of the program representation. */
-irp_callgraph_state get_irp_callgraph_state(void);
-
-/** Sets the callgraph state of the program representation. */
-void set_irp_callgraph_state(irp_callgraph_state s);
-
-/** Returns the number of procedures that call the given irg. */
-int get_irg_n_callers(ir_graph *irg);
-
-/** Returns the caller at position pos. */
-ir_graph *get_irg_caller(ir_graph *irg, int pos);
-
-/** Returns non-zero if the caller at position pos is "a backedge", i.e. a recursion. */
-int is_irg_caller_backedge(ir_graph *irg, int pos);
-
-/** Returns non-zero if the irg has a backedge caller. */
-int has_irg_caller_backedge(ir_graph *irg);
-
-/** Returns the maximal loop depth of call nodes that call along this edge. */
-int get_irg_caller_loop_depth(ir_graph *irg, int pos);
-
-/** Returns the number of procedures that are called by the given irg. */
-int get_irg_n_callees(ir_graph *irg);
-
-/** Returns the callee at position pos. */
-ir_graph *get_irg_callee(ir_graph *irg, int pos);
-
-/** Returns non-zero if the callee at position pos is "a backedge", i.e. a recursion. */
-int is_irg_callee_backedge(ir_graph *irg, int pos);
-
-/** Returns non-zero if the irg has a backedge callee. */
-int has_irg_callee_backedge(ir_graph *irg);
-
-/** Returns the maximal loop depth of call nodes that call along this edge. */
-int get_irg_callee_loop_depth(ir_graph *irg, int pos);
-
-/** Returns the maximal loop depth of all paths from an external visible method to
- this irg. */
-int get_irg_loop_depth(ir_graph *irg);
-
-/** Returns the maximal recursion depth of all paths from an external visible method to
- this irg. */
-int get_irg_recursion_depth(ir_graph *irg);
-
-/** Returns the method execution frequency of a graph. */
-double get_irg_method_execution_frequency(ir_graph *irg);
-
-/**
- * Construct the callgraph. Expects callee information, i.e.,
- * irg_callee_info_consistent must be set. This can be computed with
- * cgana().
- */
-void compute_callgraph(void);
-
-/** Destruct the callgraph. */
-void free_callgraph(void);
-
-
-/** A function type for functions passed to the callgraph walker. */
-typedef void callgraph_walk_func(ir_graph *g, void *env);
-
-/**
- * Walks over the callgraph.
- *
- * Walks over the callgraph, starting at the irp main graph.
- * Visits ALL graphs in the irp, even if not reached by the main irg, but for
- * those the call order is not guaranteed.
- *
- * Executes pre before visiting the predecessor of a node, post after.
- * The void* env can be used to pass status information between the
- * pre and post functions.
- *
- * @param pre - walker function, executed before the predecessor of a node are visited
- * @param post - walker function, executed after the predecessor of a node are visited
- * @param env - environment, passed to pre and post
- */
-void callgraph_walk(callgraph_walk_func *pre, callgraph_walk_func *post, void *env);
-
-/**
- * Compute the backedges that represent recursions and a looptree.
- */
-void find_callgraph_recursions(void);
-
-/** Compute interprocedural performance estimates.
- *
- * Computes
- * - the loop depth of the method.
- * The loop depth of an edge between two methods is the
- * maximal loop depth of the Call nodes that call along this edge.
- * The loop depth of the method is the loop depth of the most expensive
- * path from main().
- * - The recursion depth. The maximal number of recursions passed
- * on all paths reaching this method.
- * - The execution frequency. As loop depth, but the edge weight is the sum
- * of the execution frequencies of all Calls along the edge.
- *
- * Expects the main irg is set, see set_irp_main_irg();
- **/
-void compute_performance_estimates(void);
-
-/** Computes the interprocedural loop nesting information.
- *
- * Computes two numbers for each irg: the depth it is called in 'normal'
- * loops and the depth of recursions it is in.
- *
- * Computes callee info and the callgraph if
- * this information is not available.
- *
- * Expects the main irg is set, see set_irp_main_irg();
- */
-void analyse_loop_nesting_depth(void);
-
-/** The state of loop nesting depth. */
-typedef enum {
- loop_nesting_depth_none, /**< Loop nesting depths are not computed, no memory is
- allocated, access fails. */
- loop_nesting_depth_consistent, /**< Loop nesting depth information is computed and correct. */
- loop_nesting_depth_inconsistent /**< Loop nesting depth is computed but the graphs have been
- changed since. */
-} loop_nesting_depth_state;
-
-/** Returns the nesting depth state of the program representation. */
-loop_nesting_depth_state get_irp_loop_nesting_depth_state(void);
-
-/** Sets the nesting depth state of the program representation. */
-void set_irp_loop_nesting_depth_state(loop_nesting_depth_state s);
-
-/** Marks the nesting depth state of the program representation as inconsistent. */
-void set_irp_loop_nesting_depth_state_inconsistent(void);
-
-
-#endif /* _CALLGRAPH_H_ */
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief control dependence analysis
- * @author Chrsitoph Mallon
- * @version $Id$
- */
-#ifndef FIRM_ANA_CDEP_H
-#define FIRM_ANA_CDEP_H
-
-#include "firm_types.h"
-
-typedef struct cdep cdep;
-struct cdep {
- ir_node *node;
- cdep *next;
-};
-
-/** Compute the control dependence graph for a graph. */
-void compute_cdep(ir_graph *irg);
-void free_cdep(ir_graph *irg);
-
-cdep *find_cdep(const ir_node *block);
-
-void exchange_cdep(ir_node *old, const ir_node *nw);
-
-int is_cdep_on(const ir_node *dependee, const ir_node *candidate);
-
-int is_iterated_cdep_on(ir_node *dependee, ir_node *candidate);
-
-ir_node *get_unique_cdep(const ir_node *block);
-int has_multiple_cdep(const ir_node *block);
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Intraprozedural analyses to estimate the call graph.
- * @author Hubert Schmid
- * @date 09.06.2002
- * @version $Id$
- * @summary
- * @summary
- * Interprocedural analysis to estimate the calling relation.
- *
- * This analysis computes all entities representing methods that
- * can be called at a Call node. Further it computes a set of
- * methods that are 'free', i.e., their adress is handled by
- * the program directly, or they are visible external.
- */
-#ifndef FIRM_ANA_CGANA_H
-#define FIRM_ANA_CGANA_H
-
-#include "entity.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.
- * Stores the result in the field 'callees' of the Call node. If the
- * address can not be analysed, e.g. because it is loaded from a
- * variable, the array contains the unknown_entity. (See
- * "set_Call_callee"). cgana returns the set of 'free' methods, i.e.,
- * the methods that can be called from external or via function
- * pointers. This datastructure must be freed with 'free()' by the
- * caller of cgana.
- *
- * cgana sets the callee_info_state of each graph and the program to
- * consistent.
- *
- * The algorithm implements roughly Static Class Hierarchy Analysis
- * as described in "Optimization of Object-Oriented Programs Using
- * Static Class Hierarchy Analysis" by Jeffrey Dean and David Grove
- * 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 nodes by Bad if there is no implementation for the
- * selected entity.
- * - Replaces Sel-method by SymConst-entity if the method is never overwritten.
- * - Replaces Calls by Tuple containing Bads if callee array is empty
- * (there is no implementation to call)
- *
- * Leaves Bad control predecessors in the graph!
- */
-void cgana(int *len, ir_entity ***free_methods);
-
-/** 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.
- */
-void free_callee_info(ir_graph *irg);
-void free_irp_callee_info(void);
-
-/* Optimize the address expressions passed to call nodes.
- * Performs only the optimizations done by cgana. */
-void opt_call_addrs(void);
-
-
-#endif
#endif
#include "compute_loop_info.h"
-#include "strength_red.h"
+#include "strength_red_t.h"
#include "tv.h"
#include "irgwalk.h"
#include "irnode_t.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Construct some loop infromation.
- * @author Beyhan Veliev
- * @version $Id$
- */
-#ifndef FIRM_ANA_COMPUTE_LOOP_INFO_H
-#define FIRM_ANA_COMPUTE_LOOP_INFO_H
-
-#include "irgraph.h"
-
-void compute_loop_info(ir_graph *irg);
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file dfs.h
- * @author Sebastian Hack
- * @date 20.04.2007
- * @version $Id$
- * @summary
- *
- * Primitive depth-first search on the CFG.
- */
-#ifndef FIRM_ANA_DFS_H
-#define FIRM_ANA_DFS_H
-
-#include "absgraph.h"
-
-typedef struct _dfs_t dfs_t;
-typedef struct _dfs_node_t dfs_node_t;
-typedef struct _dfs_edge_t dfs_edge_t;
-
-typedef enum {
- DFS_EDGE_ANC,
- DFS_EDGE_FWD,
- DFS_EDGE_CROSS,
- DFS_EDGE_BACK
-} dfs_edge_kind_t;
-
-extern dfs_edge_kind_t dfs_get_edge_kind(const dfs_t *dfs, void *src, void *tgt);
-
-extern dfs_t *dfs_new(const absgraph_t *graph_impl, void *graph);
-extern void dfs_free(dfs_t *dfs);
-extern void dfs_dump(const dfs_t *dfs, FILE *file);
-
-#endif /* FIRM_ANA_DFS_H */
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Compute an estimate of basic block executions.
- * @author Adam M. Szalkowski
- * @date 28.05.2006
- * @version $Id$
- */
-#ifndef FIRM_ANA_EXECFREQ_H
-#define FIRM_ANA_EXECFREQ_H
-
-#include "firm_types.h"
-
-struct ir_exec_freq;
-
-#ifndef _EXECFREQ_TYPEDEF
-#define _EXECFREQ_TYPEDEF
-typedef struct ir_exec_freq ir_exec_freq;
-#endif
-
-/**
- * Create execfreq structure (to be used with set_execfreq)
- */
-ir_exec_freq *create_execfreq(ir_graph *irg);
-
-/**
- * Set execution frequency of a basic block
- */
-void set_execfreq(ir_exec_freq *ef, const ir_node *block, double freq);
-
-/**
- * Create execfreq structure and initialize with estimated frequencies
- */
-ir_exec_freq *compute_execfreq(ir_graph *irg, double loop_weight);
-
-void free_execfreq(ir_exec_freq *ef);
-
-double get_block_execfreq(const ir_exec_freq *ef, const ir_node *block);
-unsigned long get_block_execfreq_ulong(const ir_exec_freq *ef, const ir_node *block);
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Compute an estimate of basic block executions.
- * @author Goetz Lindenmaier
- * @date 5.11.2004
- * @version $Id$
- * @summary
- * We assume the start block of a procedure is executed once. Based on this we
- * compute the execution freqency of all blocks.
- *
- * The computation of the frequencies depends on the count of exception control
- * flow computed during the interval analysis. The interval analysis again
- * depends on stuff computed here.
- */
-#ifndef FIRM_ANA_EXECUTION_FREQUENCY_H
-#define FIRM_ANA_EXECUTION_FREQUENCY_H
-
-#include "firm_types.h"
-
-/* A proj from a Cond that goes to an exception handler. */
-int is_fragile_Proj(ir_node *n);
-
-/** Returns the number of times the block/region is executed according to
- * our estimate. Gives a number relative to the Start node of the procedure
- * the block is in, which is weighted with 1. */
-double get_irn_exec_freq (ir_node *n);
-double get_Block_exec_freq (ir_node *b);
-double get_region_exec_freq(void *reg);
-
-/** Compute the execution frequency for all blocks in the given
- * graph.
- *
- * @param irg The graph to be analyzed.
- * @param default_loop_weight The default number of executions of a loop.
- * @param exception_probability The probability that a fragile operation causes an exception.
- *
- * Uses link field.
- */
-void compute_execution_frequency(ir_graph *irg, int default_loop_weight, double exception_probability);
-
-/** Compute the execution frequency for all graphs.
- *
- * @param default_loop_weight The default number of executions of a loop.
- * @param exception_probability The probability that a fragile operation causes an exception.
- *
- */
-void compute_execution_frequencies(int default_loop_weight, double exception_probability);
-
-/** Free occupied memory, reset for all graphs. */
-void free_execution_frequency(void);
-
-/** State of execution frequencies for graphs and the whole program.
- *
- * 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_state;
-
-exec_freq_state get_irg_exec_freq_state(ir_graph *irg);
-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. */
-void set_irg_exec_freq_state_inconsistent(ir_graph *irg);
-
-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. */
-void set_irp_exec_freq_state_inconsistent(void);
-
-
-#endif
#include "irprog_t.h"
#include "entity_t.h"
#include "irgwalk.h"
+#include "error.h"
#include "array.h"
s = n_elt;
} break;
- default: DDMT(tp); assert(0);
+ default:
+ panic("Unsupported type in get_type_estimated_n_fields %+F", tp);
}
return s;
break;
}
- default: DDMT(tp); assert(0);
+ default: assert(0);
}
return s;
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Compute an estimate of field temperature, i.e., field access heuristic.
- * @author Goetz Lindenmaier
- * @date 21.7.2004
- * @version $Id$
- * @note
- * Watch it! This is highly java dependent.
- *
- * - All Sel nodes get an array with possibly accessed entities.
- * (resolve polymorphy on base of inherited entities.)
- * (the mentioned entity in first approximation.)
- *
- * - We compute a value for the entity based on the Sel nodes.
- */
-#ifndef FIRM_ANA_FIELD_TEMPERATURE_H
-#define FIRM_ANA_FIELD_TEMPERATURE_H
-
-#include "firm_types.h"
-
-/* The number of array elements we assume if not both bounds are given. */
-#define DEFAULT_N_ARRAY_ELEMENTS 1
-
-/** The entities that can be accessed by this Sel node. *
-int get_Sel_n_accessed_entities(ir_node *sel);
-ir_entity *get_Sel_accessed_entity (ir_node *sel, int pos);
-*/
-
-int get_irn_loop_call_depth(ir_node *n);
-/** Return loop depth of node.
- *
- * Returns the loop depth of n in the control flow. I.e., we
- * go from the node to the block to the loop the block is in,
- * and return its depth. */
-int get_irn_cfloop_depth(ir_node *n);
-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. */
-int get_weighted_loop_depth(ir_node *n);
-
-/** Heuristic merging recursion and loop depth. */
-double get_irn_final_cost(ir_node *n);
-
-/** Get accumulated(really?) execution frequencies.
- * A heuristic weights the recursions. */
-double get_type_estimated_n_instances(ir_type *clss);
-double get_type_estimated_mem_consumption_bytes(ir_type *tp);
-/** Estimates the size of an object.
- *
- * The heuristic mainly affects array sizes.
- * Further this ignores padding for alignment, especially of small fields. */
-int get_type_estimated_size_bytes(ir_type *tp);
-/** Estimates the number of fields of a single Object.
- * The heuristic mainly affects array sizes.
- * @@@ Misses inherited fields! */
-int get_type_estimated_n_fields(ir_type *tp);
-double get_type_estimated_n_casts(ir_type *clss);
-
-double get_class_estimated_n_upcasts(ir_type *clss);
-double get_class_estimated_n_downcasts(ir_type *clss);
-/** 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. */
-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. */
-double get_class_estimated_dispatch_writes(ir_type *clss);
-/** Returns the number of reads of the dispatch pointer. */
-double get_class_estimated_dispatch_reads (ir_type *clss);
-
-double get_entity_estimated_n_loads(ir_entity *ent);
-double get_entity_estimated_n_stores(ir_entity *ent);
-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. */
-double get_entity_estimated_n_dyncalls(ir_entity *ent);
-
-/* ------------------------------------------------------------------------- */
-/* Accumulate information in the type hierarchy. */
-/* ------------------------------------------------------------------------- */
-
-typedef enum {
- temperature_none,
- temperature_consistent,
- temperature_inconsistent
-} irp_temperature_state;
-
-/** An auxiliary/temporary function */
-int is_jack_rts_class(ir_type *t);
-int is_jack_rts_entity(ir_entity *e);
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Compute heights of nodes inside basic blocks
- * @author Sebastian Hack
- * @date 19.04.2006
- * @version $Id$
- */
-#ifndef FIRM_ANA_HEIGHTS_H
-#define FIRM_ANA_HEIGHTS_H
-
-typedef struct _heights_t heights_t;
-
-/**
- * Get the height of a node inside a basic block.
- * The height of the node is the maximal number of edges between a sink node in that block and the node itself (plus 1).
- * @param h The heights object.
- * @param irn The node.
- * @return The height of the node.
- */
-unsigned get_irn_height(heights_t *h, const ir_node *irn);
-
-/**
- * Check, if a certain node is reachable according to data dependence edges from another node.
- * @param h The heights object.
- * @param n The first node.
- * @param m The other node.
- * @return 1, if n is data dependent on m, 0 if not.
- */
-int heights_reachable_in_block(heights_t *h, const ir_node *n, const ir_node *m);
-
-/**
- * Recompute the height information.
- * This can be used to recompute the height information if the graph has changed since the last computation.
- * @param h The heights object.
- */
-void heights_recompute(heights_t *h);
-
-/**
- * Recompute the height information for a certain block.
- * This can be used to recompute the height information of a block.
- * @param h The heights object.
- * @param block The block
- * @return The maximum over all heights in the block.
- */
-unsigned heights_recompute_block(heights_t *h, ir_node *block);
-
-/**
- * Make a new heights object.
- * This also computes the heights for each block in the graph.
- * @param irg The graph.
- */
-heights_t *heights_new(ir_graph *irg);
-
-/**
- * Free a heights object.
- * @param h The heights object.
- */
-void heights_free(heights_t *h);
-
-
-#endif /* FIRM_ANA_HEIGHTS_H */
#include "irdump_t.h"
#include "irdom.h"
#include "irflag.h"
+#include "irprintf.h"
#include "hashptr.h"
/*------------------------------------------------------------------*/
}
}
- if (!found) {
- DDMG(current_ir_graph);
- DDML(l);
- DDML(pred_l);
- DDMN(b);
- DDMN(pred_b);
- }
-
return found;
}
if (is_backedge(b, i)) {
if (b != get_loop_element(l, 0).node) {
if (get_firm_verbosity()) {
- printf("Loophead not at loop position 0. "); DDMN(b);
+ ir_printf("Loophead not at loop position 0. %+F\n", b);
}
}
/* There are no backedges in the interval decomposition. */
if (!found) {
if (b != get_loop_element(l, 0).node) {
if (get_firm_verbosity()) {
- printf("Loop entry not at loop position 0. "); DDMN(b);
+ ir_printf("Loop entry not at loop position 0. %+F\n", b);
}
}
found = find_outer_loop(l, pred_l, pred, cfop);
found = find_previous_loop(l, pred_l, b, pred, cfop);
}
if (!found) {
- DDMG(current_ir_graph);
- DDMN(b);
- DDMN(pred);
assert(is_backedge(b, i));
assert(found && "backedge from inner loop");
}
if (b != get_loop_element(l, 0).node) {
/* Check for improper region */
if (has_backedges(b)) {
- printf("Improper Region!!!!!!\n");
- DDMG(current_ir_graph);
- DDMN(b);
- DDML(l);
+ ir_fprintf(stderr, "Improper Region!!!!!! %+F\n", b);
}
}
}
if (is_ir_node(reg)) {
if (get_Block_n_cfgpreds((ir_node *)reg) != get_region_n_ins(reg)) {
- printf("n_cfgpreds = %d, n_ins = %d\n", get_Block_n_cfgpreds((ir_node *)reg), get_region_n_ins(reg));
- DDMN((ir_node *)reg);
+ ir_printf("n_cfgpreds = %d, n_ins = %d\n %+F\n", get_Block_n_cfgpreds((ir_node *)reg), get_region_n_ins(reg), (ir_node*) reg);
}
}
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Decompost control flow graph into acylic, hierarchic intervals.
- * @author Goetz Lindenmaier
- * @date 5.11.2004
- * @version $Id$
- * @summary
- * Decompost control flow graph into acylic, hierarchic intervals.
- *
- * The analysis is based on the control flow looptree. An intervall
- * are basically all nodes in a single ir_loop entry, i.e., basic
- * blocks and inner loop nodes. The analysis computes a new set of
- * edges that link all nodes of a loop to an acyclic graph.
- *
- * The interval analysis counts the number of exception control flow
- * operations leaving a block. This depends on stuff computed in
- * execution_freqencies.
- */
-#ifndef FIRM_ANA_INTERVAL_ANALYSIS_H
-#define FIRM_ANA_INTERVAL_ANALYSIS_H
-
-#include "firm_types.h"
-
-/** The ins of regions: regions are loops or blocks.
- *
- * @todo: we should make a type for the regions, or reuse loop_element.
- */
-int get_region_n_ins(void *region);
-void *get_region_in (void *region, int pos);
-void add_region_in (void *region, void *in);
-
-
-/** The number of out edges of a region.
- *
- * This number is useful for evaluation of execution frequencies.
- */
-int get_region_n_outs(void *region);
-
-/** The number of exception out edges of a region.
- *
- * This number is useful for evaluation of execution frequencies.
- */
-int get_region_n_exc_outs(void *region);
-
-/** The control flow operation corresponding to the loop-region in at
- * position pos.
- */
-void *get_loop_cfop(void *region, int pos);
-
-
-/** The algorithm to construct the interval graph.
- *
- * Constructs the cf loop tree and leaves a valid version of it.
- *
- * @todo: @@@ add flag that states correctness of interval analysis information
- * to irg.
- **/
-void construct_intervals(ir_graph *irg);
-
-
-/** frees interval information of all graphs. */
-void free_intervals(void);
-
-
-/** dump a graph with the intervals. File name suffix "-interval". */
-void dump_interval_graph(ir_graph *irg, const char *suffix);
-
-
-#define DDMR(X) if(is_ir_node(X)) DDMN(X); else DDML(X)
-
-#endif
some_outof_loop = 1;
} else {
if (get_irn_uplink(pred) < get_irn_uplink(root)) {
- DDMN(pred); DDMN(root);
assert(get_irn_uplink(pred) >= get_irn_uplink(root));
}
some_in_loop = 1;
some_outof_loop = 1; //printf(" some out of loop ");
} else {
if(get_irn_uplink(pred) < get_irn_uplink(root)) {
- DDMN(pred); DDMN(root);
assert(get_irn_uplink(pred) >= get_irn_uplink(root));
}
some_in_loop = 1;
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Construction of Confirm nodes
- * @author Michael Beck
- * @date 6.2005
- * @version $Id$
- */
-#ifndef FIRM_ANA_IRCONSCONFIRM_H
-#define FIRM_ANA_IRCONSCONFIRM_H
-
-#include "firm_types.h"
-
-/**
- * Inject Confirm nodes into a graph.
- *
- * @param irg the graph
- *
- * Confirm nodes carry confirmation information, such as
- * a relation between a value a and another value (or a constant)
- * b.
- *
- * These allows to do some range dependent optimizations for Cmp,
- * Abs, Min, Max nodes as well as bounds checking deletion.
- *
- * The heap analysis might profit also. On the other side, Confirm
- * nodes disturb local optimizations, because patterns are destroyed.
- *
- * It is possible to avoid this by skipping Confirm nodes, but this
- * is not implemented and is not cheap. The same happens with Casts
- * nodes too. The current solution is to remove Confirms at a later
- * pass.
- */
-void construct_confirms(ir_graph *irg);
-
-/**
- * Remove all Confirm nodes from a graph.
- *
- * Note that local_optimize() can handle this if
- * the remove Confirm node setting is on (set_opt_remove_Confirm(1)).
- */
-void remove_confirms(ir_graph *irg);
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Construct and access dominator tree.
- * @author Goetz Lindenmaier
- * @date 2.2002
- * @version $Id$
- * @summary
- * This file contains routines to construct and access dominator information.
- *
- * The dominator information is stored in three fields of block nodes:
- * - idom: a reference to the block that is the immediate dominator of
- * this block.
- * - dom_depth: a number giving the depth of the block in the dominator
- * tree.
- * - pre_num: Number in preorder traversal.
- */
-#ifndef FIRM_ANA_IRDOM_H
-#define FIRM_ANA_IRDOM_H
-
-#include "firm_types.h"
-
-
-/** Accessing the dominator data structure.
- *
- * These routines only work properly if the ir_graph is in state
- * dom_consistent or dom_inconsistent.
- *
- * If the block is not reachable from Start, returns a Bad node.
- */
-ir_node *get_Block_idom(const ir_node *bl);
-void set_Block_idom(ir_node *bl, ir_node *n);
-
-int get_Block_dom_depth(const ir_node *bl);
-void set_Block_dom_depth(ir_node *bl, int depth);
-
-int get_Block_dom_pre_num(const ir_node *bl);
-void set_Block_dom_pre_num(ir_node *bl, int num);
-
-/** Accessing the post dominator data structure.
- *
- * These routines only work properly if the ir_graph is in state
- * dom_consistent or dom_inconsistent.
- *
- * If the block is not reachable from End, returns a Bad node.
- */
-ir_node *get_Block_ipostdom(const ir_node *bl);
-void set_Block_ipostdom(ir_node *bl, ir_node *n);
-
-int get_Block_postdom_depth(const ir_node *bl);
-void set_Block_postdom_depth(ir_node *bl, int depth);
-
-int get_Block_postdom_pre_num(const ir_node *bl);
-void set_Block_postdom_pre_num(ir_node *bl, int num);
-
-/**
- * Get the pre-order number of a block resulting from a
- * Depth-First-Search walkover the dominator tree.
- *
- * @param bl The block.
- * @return The pre-order number.
- */
-unsigned get_Block_dom_tree_pre_num(const ir_node *bl);
-
-/**
- * Get the largest pre-order number found in the subtree of the
- * dominator tree rooted at a given block.
- * @param bl The block.
- * @return The largest pre-order number of block's dominator subtree.
- */
-unsigned get_Block_dom_max_subtree_pre_num(const ir_node *bl);
-
-/**
- * Get the first node in the list of nodes dominated by a given block.
- *
- * Each node keeps a list of nodes which it immediately dominates. The
- * nodes are queued using the @c next pointer in the @c dom_info struct.
- * Each node keeps a head of this list using the pointer @c first in the
- * same structure.
- *
- * @param bl The block for which to get the first node dominated by @c bl.
- * @return The first node dominated by @p bl.
- */
-ir_node *get_Block_dominated_first(const ir_node *bl);
-
-/**
- * Get the next node in a list of nodes which are dominated by some
- * other node.
- * @see get_Block_dominated_first().
- * @param dom The previous node.
- * @return The next node in this list or NULL if it was the last.
- */
-ir_node *get_Block_dominated_next(const ir_node *dom);
-
-/**
- * Iterate over all nodes which are immediately dominated by a given
- * node.
- * @param bl The block whose dominated blocks shall be iterated on.
- * @param curr An iterator variable of type ir_node*
- */
-#define dominates_for_each(bl,curr) \
- for(curr = get_Block_dominated_first(bl); curr; \
- curr = get_Block_dominated_next(curr))
-
-/**
- * Iterate over all nodes which are immediately post dominated by a given
- * node.
- * @param bl The block whose post dominated blocks shall be iterated on.
- * @param curr An iterator variable of type ir_node*
- */
-#define postdominates_for_each(bl,curr) \
- for(curr = get_Block_postdominated_first(bl); curr; \
- curr = get_Block_postdominated_next(curr))
-
-/**
- * Check, if a block dominates another block.
- * @param a The first block.
- * @param b The second block.
- * @return 1, if @p a dominates @p b, else 0.
- */
-int block_dominates(const ir_node *a, const ir_node *b);
-
-/**
- * Returns the smallest common dominator block of two nodes.
- * @param a A node.
- * @param b Another node.
- * @return The first block dominating @p a and @p b
- */
-ir_node *node_smallest_common_dominator(ir_node *a, ir_node *b);
-
-/**
- * Returns the smallest common dominator block of all users of a node
- * BEWARE: @p irn must not be a block
- * If on or more users are Phi nodes, one can request special handling
- * with @p handle_phi = 1. In this case the cfg predecessor block
- * corresponding to the position of the irn in the argument list of the
- * Phi is determined and treated as user.
- *
- * @param irn A node.
- * @param handle_phi 1 if Phis should be handled different
- * @return The first block dominating all users of @irn
- */
-ir_node *node_users_smallest_common_dominator(ir_node *irn, int handle_phi);
-
-/**
- * Check, if a block post dominates another block.
- * @param a The first block.
- * @param b The second block.
- * @return 1, if @p a post dominates @p b, else 0.
- */
-int block_postdominates(const ir_node *a, const ir_node *b);
-
-/**
- * Visit all nodes in the dominator subtree of a given node.
- * Call a pre-visitor before descending to the children and call a
- * post-visitor after returning from them.
- * @param n The node to start walking from.
- * @param pre The pre-visitor callback.
- * @param post The post-visitor callback.
- * @param env Some custom data passed to the visitors.
- */
-void dom_tree_walk(ir_node *n, irg_walk_func *pre,
- irg_walk_func *post, void *env);
-
-/**
- * Visit all nodes in the post dominator subtree of a given node.
- * Call a pre-visitor before descending to the children and call a
- * post-visitor after returning from them.
- * @param n The node to start walking from.
- * @param pre The pre-visitor callback.
- * @param post The post-visitor callback.
- * @param env Some custom data passed to the visitors.
- */
-void postdom_tree_walk(ir_node *n, irg_walk_func *pre,
- irg_walk_func *post, void *env);
-
-/**
- * Walk over the dominator tree of an irg starting at the root.
- * @param irg The graph.
- * @param pre A pre-visitor to call.
- * @param post A post-visitor to call.
- * @param env Some private data to give to the visitors.
- */
-void dom_tree_walk_irg(ir_graph *irg, irg_walk_func *pre,
- irg_walk_func *post, void *env);
-
-/**
- * Walk over the post dominator tree of an irg starting at the root.
- * @param irg The graph.
- * @param pre A pre-visitor to call.
- * @param post A post-visitor to call.
- * @param env Some private data to give to the visitors.
- */
-void postdom_tree_walk_irg(ir_graph *irg, irg_walk_func *pre,
- irg_walk_func *post, void *env);
-
-/* ------------ Building and Removing the dominator data structure ----------- */
-
-/** Computes the dominator trees.
- *
- * Sets a flag in irg to "dom_consistent".
- * If the control flow of the graph is changed this flag must be set to
- * "dom_inconsistent".
- * Does not compute dominator information for control dead code. Blocks
- * not reachable from Start contain the following information:
- * @code
- * idom = NULL;
- * dom_depth = -1;
- * pre_num = -1;
- * @endcode
- * Also constructs outs information. As this information is correct after
- * the run does not free the outs information.
- */
-void compute_doms(ir_graph *irg);
-
-/** Computes the dominator trees on demand */
-void assure_doms(ir_graph *irg);
-
-/** Computes the post dominator trees.
- *
- * Sets a flag in irg to "dom_consistent".
- * If the control flow of the graph is changed this flag must be set to
- * "dom_inconsistent".
- * Does not compute post dominator information for endless lops. Blocks
- * not reachable from End contain the following information:
- * @code
- * idom = NULL;
- * dom_depth = -1;
- * pre_num = -1;
- * @endcode
- * Also constructs outs information. As this information is correct after
- * the run does not free the outs information.
- */
-void compute_postdoms(ir_graph *irg);
-
-/** Computes the dominator trees on demand */
-void assure_postdoms(ir_graph *irg);
-
-/** Frees the dominator data structures. Sets the flag in irg to "dom_none". */
-void free_dom(ir_graph *irg);
-
-/** Frees the post dominator data structures. Sets the flag in irg to "dom_none". */
-void free_postdom(ir_graph *irg);
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Extended basis block support.
- * @author Michael Beck
- * @date 5.2005
- * @version $Id$
- */
-#ifndef FIRM_ANA_IREXTBB_H
-#define FIRM_ANA_IREXTBB_H
-
-#include "firm_types.h"
-#include "execfreq.h"
-
-#ifndef _IR_EXTBB_TYPEDEF_
-#define _IR_EXTBB_TYPEDEF_
-typedef struct _ir_extblk ir_extblk;
-#endif
-
-/** Flags for extended basic block state. */
-typedef enum {
- ir_extblk_info_none = 0, /**< No extended basic block information is constructed. Default. */
- ir_extblk_info_valid = 1, /**< Extended basic block information is valid. */
- ir_extblk_info_invalid = 2 /**< Extended basic block information is constructed but invalid. */
-} irg_extblk_info_state;
-
-/* type of callback function for ir_graph walk */
-#ifndef _EXTBB_WALK_FUNC_TYPEDEF_
-#define _EXTBB_WALK_FUNC_TYPEDEF_
-/**
- * The type of a walk function. Does not use the link field.
- *
- * @param blk - the extended basic block that is just visited
- * @param env - an environment pointer passed by the walk functions
- */
-typedef void extbb_walk_func(ir_extblk *blk, void *env);
-#endif
-
-/**
- * Checks whether a pointer points to a extended basic block.
- * Intern version for libFirm.
- */
-int is_ir_extbb(const void *thing);
-
-/**
- * Compute the extended basic blocks for a graph.
- */
-void compute_extbb(ir_graph *irg);
-
-/**
- * Compute the extended basic blocks for a graph based on execution frequencies.
- */
-void compute_extbb_execfreqs(ir_graph *irg, ir_exec_freq *execfreqs);
-
-/**
- * free all extended block info.
- */
-void free_extbb(ir_graph *irg);
-
-/**
- * Return the extended block of a node.
- *
- * @param node the node
- */
-ir_extblk *get_nodes_extbb(ir_node *node);
-
-/**
- * Gets the visited counter of an extended block.
- *
- * @param blk the extended basic block
- */
-unsigned long get_extbb_visited(const ir_extblk *blk);
-
-/**
- * Sets the visited counter of an extended block.
- *
- * @param blk the extended basic block
- */
-void set_extbb_visited(ir_extblk *blk, unsigned long visited);
-
-/**
- * Mark an extended block as visited in a graph.
- * Uses the block visit flag.
- *
- * @param blk the extended basic block
- */
-void mark_extbb_visited(ir_extblk *blk);
-
-/**
- * Returns non-zero if an extended was visited.
- * Uses the block visit flag.
- *
- * @param blk the extended basic block
- */
-int extbb_visited(const ir_extblk *blk);
-
-/**
- * Returns non-zero if an extended block was NOT visited.
- * Uses the block visit flag.
- *
- * @param blk the extended basic block
- */
-int extbb_not_visited(const ir_extblk *blk);
-
-/**
- * Returns the link field of an extended block.
- *
- * @param blk the extended basic block
- */
-void *get_extbb_link(const ir_extblk *blk);
-
-/**
- * Sets the link field of an extended block.
- *
- * @param blk the extended basic block
- * @param link the new link value
- */
-void set_extbb_link(ir_extblk *blk, void *link);
-
-/**
- * Return the number of basic blocks of an extended block.
- *
- * @param blk the extended basic block
- */
-int get_extbb_n_blocks(const ir_extblk *blk);
-
-/**
- * Return the i'th basic block of an extended block.
- *
- * @param blk the extended basic block
- * @param pos the position
- */
-ir_node *get_extbb_block(ir_extblk *blk, int pos);
-
-/**
- * Return the leader basic block of an extended block.
- *
- * @param blk the extended basic block
- */
-ir_node *get_extbb_leader(ir_extblk *blk);
-
-/**
- * Return the node number of an extended block.
- * Its the block number of the leader block
- *
- * @param blk the extended basic block
- */
-long get_extbb_node_nr(ir_extblk *blk);
-
-/**
- * Walks only over Extended Basic Block nodes in the graph.
- *
- * @param blk - the start extended block node
- * @param pre - walker function, executed before the predecessor of a node are visited
- * @param post - walker function, executed after the predecessor of a node are visited
- * @param env - environment, passed to pre and post
- *
- * This function Walks only over Block nodes in the graph. Has it's own visited
- * flag, so that it can be interleaved with the other walker.
- * If a none block is passed, starts at the block this node belongs to.
- * If end is passed also visits kept alive blocks. Does not use the link field.
- */
-void irg_extblock_walk(ir_extblk *blk, extbb_walk_func *pre, extbb_walk_func *post, void *env);
-
-/**
- * Walks only over reachable Extended Basic Block nodes in the graph.
- * Ensures, that the extended block containing the End node is visited last
- * and the block containing Start visited first (in post order).
- *
- * @param irg - the irg graph
- * @param pre - walker function, executed before the predecessor of a block are visited
- * @param post - walker function, executed after the predecessor of a block are visited
- * @param env - environment, passed to pre and post
- */
-void irg_extblock_walk_graph(ir_graph *irg, extbb_walk_func *pre, extbb_walk_func *post, void *env);
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file irlivechk.h
- * @author Sebastian Hack
- * @date 22.04.2007
- * @version $Id$
- * @summary
- *
- * Live in/end checks whose only precomputation concerns the structure of the CFG.
- * Hence, nothing has to be updated if the program is modified unless the CFG is touched.
- * See .c file for more comments.
- */
-#ifndef FIRM_ANA_IRLIVECHK_H
-#define FIRM_ANA_IRLIVECHK_H
-
-#include "irgraph.h"
-#include "irnode.h"
-
-typedef struct _lv_chk_t lv_chk_t;
-
-/**
- * Make a new liveness check environment.
- * @param irg The graph.
- * @return The environment.
- */
-extern lv_chk_t *lv_chk_new(ir_graph *irg);
-
-/**
- * Free liveness check information.
- * @param lv The liveness check information.
- */
-extern void lv_chk_free(lv_chk_t *lv);
-
-/**
- * Check, if a node is live end of a given block.
- * @param lv The liveness environment.
- * @param bl The block to investigate.
- * @param irn The node to check for.
- * @return 1, if @p what is live end at @p bl, 0 else.
- */
-extern int lv_chk_bl_end(const lv_chk_t *lv, const ir_node *bl, const ir_node *irn);
-
-/**
- * Check, if a node is live out of a given block.
- * @param lv The liveness environment.
- * @param bl The block to investigate.
- * @param irn The node to check for.
- * @return 1, if @p what is live out at @p bl, 0 else.
- */
-extern int lv_chk_bl_out(const lv_chk_t *lv, const ir_node *bl, const ir_node *irn);
-
-/**
- * Check, if a node is live in of a given block.
- * @param lv The liveness environment.
- * @param bl The block to investigate.
- * @param irn The node to check for.
- * @return 1, if @p what is live in at @p bl, 0 else.
- */
-extern int lv_chk_bl_in(const lv_chk_t *lv, const ir_node *bl, const ir_node *irn);
-
-#endif /* FIRM_ANA_IRLIVECHK_H */
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Loop datastructure and access functions.
- * @author Goetz Lindenmaier
- * @date 7.2002
- * @version $Id$
- * @summary
- * Computes backedges in the control and data flow.
- *
- * @note
- * Only Block and Phi/Filter nodes can have incoming backedges.
- * Constructs loops data structure: indicates loop nesting.
- */
-# ifndef FIRM_ANA_IRLOOP_H
-# define FIRM_ANA_IRLOOP_H
-
-# include "irgraph.h"
-# include "irnode.h"
-
-/* ------------------------------------------------------------------- */
-/*
- * Backedge information.
- *
- * Predecessors of Block, Phi and interprocedural Filter 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 true if the predecessor pos is a backedge in the interprozeduralem view. */
-int is_inter_backedge(ir_node *n, int pos);
-/** Returns true if the predecessor pos is a backedge in the intraprocedural view. */
-int is_intra_backedge(ir_node *n, int pos);
-/** Returns non-zero if the predecessor pos is a backedge. */
-int is_backedge (ir_node *n, int pos);
-/** Marks edge pos as a backedge. */
-void set_backedge (ir_node *n, int pos);
-/** Marks edge pos as a non-backedge. */
-void set_not_backedge (ir_node *n, int pos);
-/** Returns non-zero if n has backedges. */
-int has_backedges (ir_node *n);
-/** Clears all backedge information. */
-void clear_backedges (ir_node *n);
-
-/* ------------------------------------------------------------------- */
-/**
- * The loops data structure.
- *
- * The loops data structure represents circles in the intermediate
- * representation. It does not represent loops in the terms of a
- * source program.
- * Each ir_graph can contain one outermost loop data structure.
- * loop is the entry point to the nested loops.
- * The loop data structure contains a field indicating the depth of
- * the loop within the nesting. Further it contains a list of the
- * loops with nesting depth -1. Finally it contains a list of all
- * nodes in the loop.
- *
- * @todo We could add a field pointing from a node to the containing loop,
- * this would cost a lot of memory, though.
- */
-/* ------------------------------------------------------------------- */
-#ifndef _IR_LOOP_TYPEDEF_
-#define _IR_LOOP_TYPEDEF_
-typedef struct ir_loop ir_loop;
-#endif
-
-/** Loop elements: loop nodes and ir nodes */
-typedef union {
- firm_kind *kind; /**< is either k_ir_node or k_ir_loop */
- ir_node *node; /**< Pointer to an ir_node element */
- ir_loop *son; /**< Pointer to an ir_loop element */
-} loop_element;
-
-int is_ir_loop(const void *thing);
-
-/** Set the outermost loop in ir graph as basic access to loop tree. */
-void set_irg_loop(ir_graph *irg, ir_loop *l);
-
-/* Returns the root loop info (if exists) for an irg. */
-ir_loop *get_irg_loop(ir_graph *irg);
-
-/** Returns the loop n is contained in. NULL if node is in no loop. */
-ir_loop *get_irn_loop(const ir_node *n);
-
-/** Returns outer loop, itself if outermost. */
-ir_loop *get_loop_outer_loop (const ir_loop *loop);
-/** Returns nesting depth of this loop */
-int get_loop_depth (const ir_loop *loop);
-
-/* Sons are the inner loops contained in this loop. */
-/** Returns the number of inner loops */
-int get_loop_n_sons (const ir_loop *loop);
-
-/** Returns the pos`th son loop (inner loop) of a loop.
- Returns NULL if there is not a pos`th loop_node. */
-ir_loop *get_loop_son (ir_loop *loop, int pos);
-
-/** Returns the number of nodes contained in loop. */
-int get_loop_n_nodes (ir_loop *loop);
-
-/** Returns the pos`th ir_node of a loop.
- Returns NULL if there is not a pos`th ir_node. */
-ir_node *get_loop_node (ir_loop *loop, int pos);
-
-/** Returns the number of elements contained in loop. */
-int get_loop_n_elements (const ir_loop *loop);
-
-/** Returns a loop element. A loop element can be interpreted as a
- kind pointer, an ir_node* or an ir_loop*. */
-loop_element get_loop_element (const ir_loop *loop, int pos);
-
-/** Returns the element number of the loop son in loop.
- * Returns -1 if not found. O(|elements|). */
-int get_loop_element_pos(const ir_loop *loop, void *le);
-
-/** Returns a unique node number for the loop node to make output
- readable. If libfirm_debug is not set it returns the loop cast to
- int. */
-int get_loop_loop_nr(const ir_loop *loop);
-
-/** A field to connect additional information to a loop. Only valid
- if libfirm_debug is set, else returns NULL. */
-void set_loop_link (ir_loop *loop, void *link);
-void *get_loop_link (const ir_loop *loop);
-
-/* ------------------------------------------------------------------- */
-/* Constructing and destructing the loop/backedge information. */
-/* ------------------------------------------------------------------- */
-
-/** Constructs backedge information and loop tree for a graph in intraprocedural view.
- *
- * The algorithm views the program representation as a pure graph.
- * It assumes that only block and phi nodes may be loop headers.
- * The resulting loop tree is a possible visiting order for dataflow
- * analysis.
- *
- * This algorithm destoyes the link field of block nodes.
- *
- * @returns Maximal depth of loop tree.
- *
- * @remark
- * One assumes, the Phi nodes in a block with a backedge have backedges
- * at the same positions as the block. This is not the case, as
- * the scc algorithms does not respect the program semantics in this case.
- * Take a swap in a loop (t = i; i = j; j = t;) This results in two Phi
- * nodes. They form a cycle. Once the scc algorithm deleted one of the
- * edges, the cycle is removed. The second Phi node does not get a
- * backedge!
- */
-/* @@@ Well, maybe construct_loop_information or analyze_loops ? */
-int construct_backedges(ir_graph *irg);
-
-/** Constructs backedges for all irgs in interprocedural view.
- *
- * @see As construct_backedges(), but for interprocedural view.
- *
- * @remark
- * All loops in the graph will be marked as such, not only
- * realizeable loops and recursions in the program. E.g., if the
- * same funcion is called twice, there is a loop between the first
- * function return and the second call.
- *
- * @returns Maximal depth of loop tree.
-*/
-int construct_ip_backedges(void);
-
-/** Construct loop tree only for control flow.
- *
- * This constructs loop information resembling the program structure.
- * It is useful for loop optimizations and analyses, as, e.g., finding
- * iteration variables or loop invariant code motion.
- *
- * This algorithm computes only back edge information for Block nodes, not
- * for Phi nodes.
- *
- * This algorithm destoyes the link field of block nodes.
- *
- * @returns Maximal depth of loop tree.
- */
-int construct_cf_backedges(ir_graph *irg);
-
-/** Construct interprocedural loop tree for control flow.
- *
- * @see construct_cf_backedges() and construct_ip_backedges().
- */
-int construct_ip_cf_backedges (void);
-
-/** Removes all loop information.
- * Resets all backedges. Works for any construction algorithm.
- */
-void free_loop_information(ir_graph *irg);
-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.
- * @param block A block node.
- *
- * Returns non-zero, if the node n is not changed in the loop block
- * belongs to or in inner loops of this block. */
-int is_loop_invariant(ir_node *n, ir_node *block);
-
-#endif
once = 0x00000080, /**< this is a do loop, with a false condition.It itarate once */
} loop_flags_t;
-/** The loops datastructure. */
+/**
+ * The loops data structure.
+ *
+ * The loops data structure represents circles in the intermediate
+ * representation. It does not represent loops in the terms of a
+ * source program.
+ * Each ir_graph can contain one outermost loop data structure.
+ * loop is the entry point to the nested loops.
+ * The loop data structure contains a field indicating the depth of
+ * the loop within the nesting. Further it contains a list of the
+ * loops with nesting depth -1. Finally it contains a list of all
+ * nodes in the loop.
+ *
+ * @todo We could add a field pointing from a node to the containing loop,
+ * this would cost a lot of memory, though.
+ */
struct ir_loop {
firm_kind kind; /**< A type tag, set to k_ir_loop. */
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Memory disambiguator
- * @author Michael Beck
- * @date 27.12.2006
- * @version $Id$
- */
-#ifndef FIRM_ANA_IRMEMORY_H
-#define FIRM_ANA_IRMEMORY_H
-
-#include "firm_types.h"
-
-/** The alias relation of two memory addresses. */
-typedef enum {
- no_alias, /**< No alias. */
- may_alias, /**< Unknown state, may alias. */
- sure_alias /**< Sure alias. */
-} ir_alias_relation;
-
-/** The state of the address taken flags. */
-typedef enum {
- ir_address_taken_not_computed, /**< Address taken flag is not computed. */
- ir_address_taken_computed /**< Address taken flag is computed. */
-} ir_address_taken_computed_state;
-
-/** Possible options for the memory disambiguator. */
-typedef enum {
- aa_opt_no_opt = 0, /**< no options: most conservative */
- aa_opt_type_based = 1, /**< use type based alias analysis: strict typed source language */
- aa_opt_byte_type_may_alias = 2, /**< if type based analysis is enabled: bytes types may alias other types */
- aa_opt_no_alias = 4, /**< two addresses NEVER alias, use with CAUTION (gcc -fno-alias) */
- aa_opt_inherited = 128 /**< only for implementation: options from a graph are inherited from global */
-} disambuigator_options;
-
-/**
- * A source language specific memory disambiguator function.
- * Called by get_alias_relation().
- */
-typedef ir_alias_relation (*DISAMBIGUATOR_FUNC)(
- ir_graph *irg,
- ir_node *adr1, ir_mode *mode1,
- ir_node *adr2, ir_mode *mode2);
-
-/**
- * Determine the alias relation between two addresses.
- *
- * @param irg The current graph.
- * @param adr1 The first address.
- * @param mode1 The mode of the first memory access.
- * @param adr2 The second address.
- * @param mode2 The mode of the second memory access.
- *
- * The memory disambiguator tries to determine the alias state between
- * two memory addresses. The following rules are used:
- *
- * - variables from different segments never alias (R1)
- * - a global variable and a local one never alias (R1 b)
- * - a global variable and a TLS one never alias (R1 c)
- * - a local variable and a TLS one never alias (R1 d)
- * - a local variable and a parameter never alias (R1 e)
- * - two different variables never alias (R2)
- * - if one is a variable whose address has never been taken
- * there is no alias (R3)
- * - if two memory addresses have the same base and their offsets
- * do not describe overlapping regions there is no alias (R4)
- * - if opt_strong_typed is set and both addresses describe entities,
- * different types never alias (R5)
- *
- * If none of these rules apply, the points-to framework must be
- * interrogated to detect the alias relation.
- */
-ir_alias_relation get_alias_relation(
- ir_graph *irg,
- ir_node *adr1, ir_mode *mode1,
- ir_node *adr2, ir_mode *mode2);
-
-/**
- * Set a source language specific memory disambiguator function.
- *
- * @param func The callback.
- */
-void set_language_memory_disambiguator(DISAMBIGUATOR_FUNC func);
-
-/**
- * Initialize the relation cache.
- */
-void mem_disambig_init(void);
-
-/*
- * Determine the alias relation between two addresses and
- * cache the result.
- *
- * @param irg The current graph.
- * @param adr1 The first address.
- * @param mode1 The mode of the first memory access.
- * @param adr2 The second address.
- * @param mode2 The mode of the second memory access.
- *
- * @see get_alias_relation()
- */
-ir_alias_relation get_alias_relation_ex(
- ir_graph *irg,
- ir_node *adr1, ir_mode *mode1,
- ir_node *adr2, ir_mode *mode2);
-
-/**
- * Free the relation cache.
- */
-void mem_disambig_term(void);
-
-/**
- * Returns the current address taken state of the graph.
- */
-ir_address_taken_computed_state get_irg_address_taken_state(const ir_graph *irg);
-
-/**
- * Sets the current address taken state of the graph.
- *
- * @param irg the graph
- * @param state the new state
- */
-void set_irg_address_taken_state(ir_graph *irg, ir_address_taken_computed_state state);
-
-/**
- * Assure that the address taken flag is computed for the given graph.
- *
- * This is an intraprocedural analysis that computes the address_taken state
- * for all local variables.
- *
- * Note that this is a conservative estimation that by no Firm transformation
- * can be invalidated, so it's only recomputed if manually triggered by calling
- * set_irg_address_taken_state(irg, ir_address_taken_not_computed).
- * Even then the information is not cleaned from the variables, call
- * assure_irg_address_taken_computed() again for recomputation.
- */
-void assure_irg_address_taken_computed(ir_graph *irg);
-
-/**
- * Returns the current address taken state of the globals.
- */
-ir_address_taken_computed_state get_irp_globals_address_taken_state(void);
-
-/**
- * Sets the current address taken state of the globals.
- *
- * @param state the new state
- */
-void set_irp_globals_address_taken_state(ir_address_taken_computed_state state);
-
-/**
- * Assure that the address taken flag is computed for the global and TLS entities (variables).
- *
- * This is an interprocedural analysis that computes the address_taken state
- * for all global and TLS variables.
- *
- * Note that this is a conservative estimation that by no Firm transformation
- * can be invalidated, so it's only recomputed if manually triggered by calling
- * set_irp_globals_address_taken_state(ir_address_taken_not_computed).
- * Even then the information is not cleaned from the variables, call
- * assure_irp_globals_address_taken_computed() again for recomputation.
- */
-void assure_irp_globals_address_taken_computed(void);
-
-/**
- * Get the memory disambiguator options for a graph.
- *
- * @param irg the graph
- */
-unsigned get_irg_memory_disambiguator_options(ir_graph *irg);
-
-/**
- * Set the memory disambiguator options for a graph.
- *
- * @param irg the graph
- * @param option a set of options
- */
-void set_irg_memory_disambiguator_options(ir_graph *irg, unsigned options);
-
-/**
- * Set the global disambiguator options for all graphs not having local options.
- *
- * @param option a set of options
- */
-void set_irp_memory_disambiguator_options(unsigned options);
-
-#endif /* FIRM_ANA_IRMEMORY_H */
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Compute and access out edges (also called def-use edges).
- * @author Goetz Lindenmaier, Michael Beck
- * @date 1.2002
- * @version $Id$
- */
-#ifndef FIRM_ANA_IROUTS_H
-#define FIRM_ANA_IROUTS_H
-
-#include "firm_types.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: */
-int get_irn_n_outs(ir_node *node);
-
-/** Get predecessor n */
-ir_node *get_irn_out(ir_node *node, int pos);
-
-/** Set predecessor n */
-void set_irn_out(ir_node *node, int pos, ir_node *out);
-
-/* 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. */
-int get_Block_n_cfg_outs(ir_node *node);
-
-/** Return the number of control flow successors, honor keep-alives. */
-int get_Block_n_cfg_outs_ka(ir_node *node);
-
-/** Access predecessor n, ignore keep-alives. */
-ir_node *get_Block_cfg_out(ir_node *node, int pos);
-
-/** Access predecessor n, honor keep-alives. */
-ir_node *get_Block_cfg_out_ka(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. */
-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 it's own visited
- flag, so that it can be interleaved with the other walker.
- node must be either op_Block or mode_X. */
-void irg_out_block_walk(ir_node *node,
- irg_walk_func *pre, irg_walk_func *post,
- void *env);
-
-/*------------------------------------------------------------------*/
-/* 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. */
-void compute_irg_outs(ir_graph *irg);
-void compute_irp_outs(void);
-
-void assure_irg_outs(ir_graph *irg);
-
-/** Computes the out edges in interprocedural view */
-void compute_ip_outs(void);
-/** Frees the out datastructures. Sets the flag in irg to "outs_none". */
-void free_ip_outs(void);
-void free_irg_outs(ir_graph *irg);
-void free_irp_outs(void);
-
-#endif
static INLINE void
push (ir_node *n)
{
- /*DDMN(n);*/
-
if (tos == ARR_LEN (stack)) {
int nlen = ARR_LEN (stack) * 2;
ARR_RESIZE (ir_node *, stack, nlen);
do {
m = pop();
- //printf(" dfn: %d, upl %d upl-new %d ", get_irn_dfn(m), get_irn_uplink(m), loop_node_cnt+1); DDMN(m);
-
loop_node_cnt++;
set_irn_dfn(m, loop_node_cnt);
add_loop_node(current_loop, m);
if(node_nr == pos)
return(loop -> children[child_nr].node);
}
- DDML(loop);
- printf("pos: %d\n", pos);
+
assert(0 && "no child at pos found");
return NULL;
}
#endif
}
-
-#if 0
-static void test(ir_node *pred, ir_node *root, ir_node *this) {
- int i;
- if (get_irn_uplink(pred) >= get_irn_uplink(root)) return;
-
- printf("this: %d ", get_irn_uplink(this)); DDMN(this);
- printf("pred: %d ", get_irn_uplink(pred)); DDMN(pred);
- printf("root: %d ", get_irn_uplink(root)); DDMN(root);
-
- printf("tos: %d\n", tos);
-
- for (i = tos; i >= 0; i--) {
- ir_node *n = stack[i];
- if (!n) continue;
- printf(" uplink: %d, pos: %d ", get_irn_uplink(n), i); DDMN(n);
- }
-}
-#endif
-
/* Test for legal loop header: Block, Phi, ... */
static INLINE int is_possible_loop_head(ir_node *n) {
ir_op *op = get_irn_op(n);
some_outof_loop = 1;
} else {
if(get_irn_uplink(pred) < get_irn_uplink(root)) {
- DDMN(n); DDMN(pred); DDMN(root);
assert(get_irn_uplink(pred) >= get_irn_uplink(root));
}
some_in_loop = 1;
some_outof_loop = 1; //printf(" some out of loop ");
} else {
if(get_irn_uplink(pred) < get_irn_uplink(root)) {
- DDMN(pred); DDMN(root);
assert(get_irn_uplink(pred) >= get_irn_uplink(root));
}
some_in_loop = 1;
assert(is_Block(start_block));
for(i = tos - 1; i >= 0; --i)
{
- DDMN(stack[i]);
if(get_irn_op(stack[i]) == op_Proj && get_irn_mode(stack[i]) == mode_X &&
get_irn_op(get_irn_n(stack[i], 0)) == op_EndReg)
{
{
ir_node *begin_projx = get_Block_cfgpred(get_irg_start_block(get_irn_irg(end_projx)),
get_Proj_proj(end_projx));
- DDMN(begin_projx);
if(get_irn_n(start_block, j) == begin_projx)
{
printf("FOUND IT!!!!!!!!!!!!!!!!!!\n");
ir_node *end_projx = n;
ir_node *begin_projx = get_Block_cfgpred(get_irg_start_block(get_irn_irg(end_projx)),
get_Proj_proj(end_projx));
- printf("Linked the following ProjxNodes:\n");
- DDMN(begin_projx);
- DDMN(end_projx);
set_projx_link(begin_projx, end_projx);
}
}
assert(l && l->kind == k_ir_loop);
if (get_loop_n_elements(l) == 0) {
- printf(" Loop completely empty! "); DDML(l);
found_problem = 1;
dump_loop(l, "-ha");
}
le = get_loop_element(l, 0);
if (*(le.kind) != k_ir_node) {
assert(le.kind && *(le.kind) == k_ir_loop);
- printf(" First loop element is not a node! "); DDML(l);
- printf(" "); DDML(le.son);
found_problem = 1;
dump_loop(l, "-ha");
}
if ((*(le.kind) == k_ir_node) && !is_possible_loop_head(le.node)) {
- printf(" Wrong node as head! "); DDML(l);
- printf(" "); DDMN(le.node);
found_problem = 1;
dump_loop(l, "-ha");
}
if ((get_loop_depth(l) != 0) &&
(*(le.kind) == k_ir_node) && !has_backedges(le.node)) {
- printf(" Loop head has no backedges! "); DDML(l);
- printf(" "); DDMN(le.node);
found_problem = 1;
dump_loop(l, "-ha");
}
}
if (has_node == 0) {
- printf(" Loop has no firm node! "); DDML(l);
found_problem = 1;
dump_loop(l, "-ha");
}
*/
void find_strange_loop_nodes(ir_loop *l) {
int found_problem = 0;
- printf("\nTesting loop "); DDML(l);
found_problem = test_loop_node(l);
printf("Finished Test\n\n");
if (found_problem) exit(0);
#include "irgwalk.h"
#include "ident.h"
#include "trouts.h"
+#include "error.h"
#define VERBOSE_UNKNOWN_TYPE(s) printf s
break;
}
- printf(" not implemented: "); DDMN(n);
+ panic(" not implemented: %+F", n);
} break; /* default */
} /* end switch */
- /* printf (" found %s ", get_type_name(tp)); DDM; */
-
return tp;
}
set_irn_typeinfo_type(n, tp);
}
- /* printf (" found %s ", get_type_name(tp)); DDM; */
-
return tp;
}
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Run most simple type analyses.
- * @author Goetz Lindenmaier
- * @date 22.8.2003
- * @version $Id$
- * @summary
- * We compute type information for each node. It is derived from the
- * types of the origines of values, e.g. parameter types can be derived
- * from the method type.
- * The type information so far is saved in the link field.
- */
-#ifndef FIRM_ANA_IRSIMPLETYPE_H
-#define FIRM_ANA_IRSIMPLETYPE_H
-
-#include "irgraph.h"
-#include "irnode.h"
-#include "type.h"
-
-
-
-/* ------------ Building and Removing the type information ----------- */
-
-/** Computes type information for each node in all ir graphs.
- *
- * Computes type information for each node. Stores the information in the
- * field defined in irtypeinfo.h. Sets typestate in irg to irg_typeinfo_consistent.
- *
- * Derives the information from nodes/patterns that give hints about the
- * type, as projecting an argument from the Start node. Deletes all previous
- * type information.
- *
- * If a non-pointer type is specified for a pointer value (as the Alloc node does:
- * it contains the type allocated, but to type the result we need the type that
- * describes a pointer to the allocated type) searches for a corresponding pointer
- * type. If several exist, uses one of them. If none exists, uses unknown_type.
- *
- * Uses the link field of types. Sets this field of each type to point to a
- * pointer type that points to the type (Got it? ;-)).
- */
-void simple_analyse_types(void);
-
-/** Frees all type information datastructures. Sets the flag in irg to "???". */
-void free_simple_type_information(void);
-
-/** Computes type information for a node.
- *
- * Computes type information for a node. Does not remark this type information
- * in the ir. Computes the type information by analysing the predecessors.
- * Calls the same basic analyses routine for a node as simple_analyse_types,
- * but returns unknown_type for Phi nodes.
- * Each call is theoretically O(n).
- *
- * Not yet implemented, but I guess we want this for iropt, to find the
- * type for newly allocated constants.
- */
-/* type *analyse_irn_type(ir_node *node); */
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Data structure to hold type information for nodes.
- * @author Goetz Lindenmaier
- * @date 28.8.2003
- * @version $Id$
- * @summary
- * Data structure to hold type information for nodes.
- *
- * This module defines a field "type" of type "type *" for each ir node.
- * It defines a flag for irgraphs to mark whether the type info of the
- * graph is valid. Further it defines an auxiliary type "init_type".
- */
-#ifndef FIRM_ANA_IRTYPEINFO_H
-#define FIRM_ANA_IRTYPEINFO_H
-
-#include "firm_types.h"
-
-/* ------------ Auxiliary type. --------------------------------------- */
-
-/** An auxiliary type used to express that a field is uninitialized.
- *
- * This auxiliary type expresses that a field is uninitialized. The
- * variable is initialized by init_irtypeinfo(). The type is freed by
- * free_irtypeinfo().
- */
-extern ir_type *initial_type;
-
-
-
-/* ------------ Initializing this module. ----------------------------- */
-
-/** Initializes the type information module.
- *
- * Initializes the type information module.
- * Generates a type inititial_type and sets the type of all nodes to this type.
- * Calling set/get_irn_typeinfo_type() is invalid before calling init. Requires memory
- * in the order of MIN(<calls to set_irn_typeinfo_type>, #irnodes).
- */
-void init_irtypeinfo(void);
-void free_irtypeinfo(void);
-
-/* ------------ Irgraph state handling. ------------------------------- */
-
-/*
-#define irg_typeinfo_none ir_typeinfo_none
-#define irg_typeinfo_consistent ir_typeinfo_consistent
-#define irg_typeinfo_inconsistent ir_typeinfo_inconsistent
-#define irg_typeinfo_state ir_typeinfo_state
-*/
-
-typedef enum {
- ir_typeinfo_none, /**< No typeinfo computed, calls to set/get_irn_typeinfo_type()
- are invalid. */
- ir_typeinfo_consistent, /**< Type info valid, calls to set/get_irn_typeinfo_type() return
- the proper type. */
- ir_typeinfo_inconsistent /**< Type info can be accessed, but it can be invalid
- because of other transformations. */
-} ir_typeinfo_state;
-
-void set_irg_typeinfo_state(ir_graph *irg, ir_typeinfo_state s);
-ir_typeinfo_state get_irg_typeinfo_state(ir_graph *irg);
-
-/** Returns accumulated type information state information.
- *
- * Returns ir_typeinfo_consistent if the type information of all irgs is
- * consistent. Returns ir_typeinfo_inconsistent if at least one irg has inconsistent
- * or no type information. Returns ir_typeinfo_none if no irg contains type information.
- */
-ir_typeinfo_state get_irp_typeinfo_state(void);
-void set_irp_typeinfo_state(ir_typeinfo_state s);
-/** If typeinfo is consistent, sets it to inconsistent. */
-void set_irp_typeinfo_inconsistent(void);
-
-/* ------------ Irnode type information. ------------------------------ */
-
-/** Accessing the type information.
- *
- * These routines only work properly if the ir_graph is in state
- * ir_typeinfo_consistent or ir_typeinfo_inconsistent. They
- * assume current_ir_graph set properly.
- */
-ir_type *get_irn_typeinfo_type(ir_node *n);
-void set_irn_typeinfo_type(ir_node *n, ir_type *tp);
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Analysis to compute phi congruence classes.
- * @author Daniel Grund
- * @version $Id$
- * @date 15.01.2005
- */
-#ifndef FIRM_ANA_PHICLASS_H
-#define FIRM_ANA_PHICLASS_H
-
-#include "pset.h"
-#include "irgraph.h"
-#include "irnode.h"
-#include "irnodeset.h"
-
-typedef struct _phi_classes_t phi_classes_t;
-
-/**
- * Return the array containing all nodes assigned to the same Phi class as @p irn.
- */
-ir_node **get_phi_class(phi_classes_t *pc, ir_node *irn);
-
-/**
- * Assigns a new array of nodes representing the new Phi class to @p irn.
- */
-void set_phi_class(phi_classes_t *pc, ir_node *irn, ir_node **cls);
-
-/**
- * Returns a set containing all computed Phi classes.
- */
-pset *get_all_phi_classes(phi_classes_t *pc);
-
-/**
- * Builds the Phi classes for all Phis in @p irg.
- * @param irg The irg the classes should be build for
- * @param pure_phi_classes Set to one if Phi classes should only contain Phi nodes.
- * Beware: This might result in different (more) Phi classes as if not set
- * @return The Phi class object for the @p irg.
- */
-phi_classes_t *phi_class_new_from_irg(ir_graph *irg, int pure_phi_classes);
-
-/**
- * Builds all Phi classes for the given set of Phis.
- * @param irg The irg, the Phis are from
- * @param all_phis An ir_nodeset containing all Phis nodes to build the classes for
- * @param pure_phi_classes Set to one if Phi classes should only contain Phi nodes.
- * Beware: This might result in different (more) Phi classes as if not set
- * @return The Phis class object for @p all_phis.
- */
-phi_classes_t *phi_class_new_from_set(ir_graph *irg, ir_nodeset_t *all_phis, int pure_phi_classes);
-
-/**
- * Free all allocated data.
- */
-void phi_class_free(phi_classes_t *pc);
-
-#endif
#include "eset.h"
#include "irgwalk.h"
#include "irgmod.h"
-#include "typewalk.h"
#include "irvrfy.h"
-#include "trvrfy.h"
+#include "irprintf.h"
# ifndef TRUE
# define TRUE 1
{
if (!eset_contains (_live_graphs, graph)) {
if (verbose > 1) {
- fprintf(stdout, "RTA: new graph of ");
- DDMEO(get_irg_entity (graph));
+ ir_fprintf(stdout, "RTA: new graph of %+F\n", graph);
}
eset_insert (_live_graphs, graph);
{
if (!eset_contains (_live_classes, clazz)) {
if (verbose > 1) {
- fprintf(stdout, "RTA: new class: ");
- DDMT(clazz);
+ ir_fprintf(stdout, "RTA: new class: %+F\n", clazz);
}
eset_insert (_live_classes, clazz);
}
if (verbose > 1) {
- fprintf(stdout, "RTA: new call to ");
- DDMEO(method);
+ ir_fprintf(stdout, "RTA: new call to %+F\n", method);
}
if (rta_is_alive_class (get_entity_owner (method))) {
/* STRANGE */
} else {
- DDMN(ptr);
assert(0 && "Unexpected address expression: can not analyse, therefore can not do correct rta!");
}
graph = eset_next (live_graphs)) {
if (verbose > 1) {
- fprintf(stdout, "RTA: RUN %i: considering graph of ", n_runs);
- DDMEO(get_irg_entity (graph));
+ ir_fprintf(stdout, "RTA: RUN %i: considering graph of %+F\n", n_runs,
+ graph);
}
rerun |= rta_fill_graph (graph);
for (i = 0; i < get_irp_n_types(); ++i) {
ir_type *tp = get_irp_type(i);
if (is_Class_type(tp) && rta_is_alive_class(tp)) {
- fprintf(stdout, "RTA: considered allocated: "); DDMT(tp);
+ ir_fprintf(stdout, "RTA: considered allocated: %+F\n", tp);
}
}
for (i = 0; i < get_irp_n_irgs(); i++) {
if (rta_is_alive_graph (get_irp_irg(i))) {
- fprintf(stdout, "RTA: considered called: graph of ");
- DDMEO(get_irg_entity (get_irp_irg(i)));
+ ir_fprintf(stdout, "RTA: considered called: graph of %+F\n", get_irp_irg(i));
}
}
}
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Interprocedural analysis to improve the call graph estimate.
- * @author Florian
- * @date 09.06.2002
- * @version $Id$
- * @summary
- * (TODO translate to english)
- * Intraprozedurale Analyse zur Abschätzung der Aufrufrelation. Es wird
- * die Menge der instantiierten Klassen bestimmt, und daraus eine Abschätzung
- * der aufgerufenen Methoden.
- *
- * Voraussetzung ist, dass das Programm keine Methodenzeiger handhaben kann.
- * In diesem Fall koennten Methoden verloren gehen. Oder wir muessen nach
- * allen "freien" Methoden suchen (siehe cgana).
- *
- * @@@ Die Analyse sollte wissen, von welchen Klassen Instanzen ausserhalb
- * der Uebersetzungseinheit alloziert werden koennen. Diese muessen in
- * die initiale Menge allozierter Klassen aufgenommern werden.
- *
- * Nach: David F. Bacon and Peter F. Sweeney,
- * Fast static analysis of C++ virtual function calls
- * OOPSLA 1996
- */
-#ifndef FIRM_ANA_RTA_H
-#define FIRM_ANA_RTA_H
-
-#include "firm_types.h"
-
-/**
- * Initialise the RTA data structures and perform RTA.
- *
- * @param do_verbose If == 1, print statistics, if > 1, chatter about every detail
- */
-void rta_init(int do_verbose);
-
-/**
- * Delete all graphs that have been found to be dead.
- */
-void rta_delete_dead_graphs (void);
-
-/** Clean up our data structures.
- * Finishes the RTA.
- */
-void rta_cleanup(void);
-
-/** Returns non-zero if the given class is alive. */
-int rta_is_alive_class(ir_type *clazz);
-
-/** Returns non-zero if the given graph is alive. */
-int rta_is_alive_graph(ir_graph *graph);
-
-/** report for all graphs and types whether they are alive */
-void rta_report(void);
-
-#endif
-
-/*
- * $Log$
- * Revision 1.15 2006/12/18 16:02:21 beck
- * removed useles include
- *
- * Revision 1.14 2006/01/13 21:52:00 beck
- * renamed all types 'type' to 'ir_type'
- *
- * Revision 1.13 2004/10/21 07:23:34 goetz
- * comments
- *
- * Revision 1.12 2004/10/20 14:59:27 liekweg
- * Removed ecg
- *
- * Revision 1.11 2004/10/18 12:47:46 liekweg
- * minor fix
- *
- * Revision 1.10 2004/09/24 13:59:04 beck
- * fixed doxygen comments, removed initialization for description entities
- *
- * Revision 1.9 2004/08/19 16:51:02 goetz
- * fixed some errors, pushed closer to inteded firm semantics
- *
- * Revision 1.8 2004/06/18 17:34:31 liekweg
- * Removed field checks --flo
- *
- * Revision 1.7 2004/06/18 13:12:43 liekweg
- * final bug fix (calls via consts)
- *
- * Revision 1.6 2004/06/17 14:21:14 liekweg
- * major bugfix
- *
- * Revision 1.5 2004/06/17 08:33:01 liekweg
- * Added comments; added remove_irg
- *
- * Revision 1.4 2004/06/15 11:44:54 beck
- * New inlining schema implemented:
- *
- * small functions that should be inlined in libFirm are implemented in _t.h files
- * with a __ prefix.
- * Preprocessor magic is used to automatically inline these functions whenever a _t.h
- * file is included instead of a .h file.
- * Note that this magic did not work outside libFirm without accessing _t.h files.
- *
- * Revision 1.3 2004/06/13 15:03:45 liekweg
- * RTA auf Iterative RTA aufgebohrt --flo
- *
- * Revision 1.2 2004/06/12 17:09:46 liekweg
- * RTA works, outedges breaks. "Yay." --flo
- *
- * Revision 1.1 2004/06/11 18:24:18 liekweg
- * Added RTA --flo
- *
- */
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief structure analysis
- * @author Michael Beck
- * @date 05.04.2007
- * @version $Id$
- */
-#ifndef FIRM_ANA_STRUCTURE_H
-#define FIRM_ANA_STRUCTURE_H
-
-#include "firm_types.h"
-
-/**
- * This enum describes the different regions constructed by the structural analysis.
- */
-typedef enum ir_region_kind {
- ir_rk_Unknown, /**< Unknown region kind. */
- ir_rk_BasicBlock, /**< A Basic Block simply wraps a firm basic block, needed for the construction. */
- /*
- * part0->part1->...->partn->XXX
- */
- ir_rk_Sequence, /**< A sequence of regions. */
- /*
- * part0
- * / |
- * part1 |
- * \ |
- * XXX
- */
- ir_rk_IfThen, /**< An if-then. */
- /*
- * part0
- * / \
- * part1 part2
- * \ /
- * XXX
- */
- ir_rk_IfThenElse, /**< An if-then-else. */
- /*
- * part0
- * / \
- * part1 ... partn
- * \ /
- * XXX
- */
- ir_rk_Case, /**< A Case like in Pascal. No fall through is allowed. */
- /*
- * part0
- * / | \
- * part1->part2 partn
- * \ /
- * XXX
- */
- ir_rk_Switch, /**< A Switch like in C. At least one fall through exists. */
- ir_rk_Proper, /**< A proper region. Any other DAG. */
- ir_rk_TryCatch, /**< A TryCatch Exception handling. */
- ir_rk_TryCatchFinally, /**< A TryCatchFinally Exception handling. */
- /*
- * +-+
- * v |
- * part0
- */
- ir_rk_SelfLoop, /**< A self loop. In Firm always a repeat or endless loop. */
- /*
- * part0
- * | ^
- * v |
- * part1
- * |
- * v
- * XXX
- */
- ir_rk_RepeatLoop, /**< A Repeat loop. */
- /*
- * part0 ---> XXX
- * | ^
- * v |
- * part1
- */
- ir_rk_WhileLoop, /**< A While loop. */
- /*
- * Arbitrary loop with single head.
- */
- ir_rk_NaturalLoop, /**< A natural loop. */
- ir_rk_Improper, /**< An improper region. May contain everything. */
-} ir_region_kind;
-
-/** Returns non-zero if a region contains loops. */
-#define is_loop_region(type) ((type) >= ir_rk_SelfLoop)
-
-/**
- * Returns the link of a region.
- *
- * @param reg the region
- */
-void *get_region_link(const ir_region *reg);
-
-/**
- * Sets the link of a region.
- *
- * @param reg the region
- * @param data the data
- */
-void set_region_link(ir_region *reg, void *data);
-
-/**
- * Get the immediate region of a block.
- *
- * @param block a block node
- */
-ir_region *get_block_region(const ir_node *block);
-
-/**
- * Sets the immediate region of a block.
- *
- * @param block a block node
- * @param reg the region
- */
-void set_block_region(ir_node *block, ir_region *reg);
-
-/**
- * Get the immediate region of a node.
- *
- * @param n a Firm IR node
- */
-ir_region *get_irn_region(ir_node *n);
-
-/**
- * Return non-if a given firm thing is a region.
- *
- * @param thing a Firm object address
- */
-int is_region(const void *thing);
-
-/**
- * Return the number of predecessors in a region.
- *
- * @param reg the region
- */
-int get_region_n_preds(const ir_region *reg);
-
-/**
- * Return the predecessor region at position pos.
- *
- * @param reg the region
- */
-ir_region *get_region_pred(const ir_region *reg, int pos);
-
-/**
- * Set the predecessor region at position pos.
- *
- * @param reg the region
- * @param pos the position number
- * @param n the new predecessor region
- */
-void set_region_pred(ir_region *reg, int pos, ir_region *n);
-
-/**
- * Return the number of successors in a region.
- *
- * @param reg the region
- */
-int get_region_n_succs(const ir_region *reg);
-
-/**
- * Return the successor region at position pos.
- *
- * @param reg the region
- * @param pos the position number
- */
-ir_region *get_region_succ(const ir_region *reg, int pos);
-
-/**
- * Set the successor region at position pos.
- *
- * @param reg the region
- * @param pos the position number
- * @param n the new successor region
- */
-void set_region_succ(ir_region *reg, int pos, ir_region *n);
-
-/**
- * Construct the region tree of a graph by doing
- * structural analysis.
- *
- * Uses link fields of nodes.
- *
- * @param irg the graph
- *
- * @return the region tree
- */
-ir_reg_tree *construct_region_tree(ir_graph *irg);
-
-/**
- * Walk over the region tree.
- *
- * @param tree the tree
- * @param pre walker function, executed before the children of a tree node are visited
- * @param post walker function, executed after the children of a tree node are visited
- * @param env environment, passed to pre and post
- */
-void region_tree_walk(ir_reg_tree *tree, irg_reg_walk_func *pre, irg_reg_walk_func *post, void *env);
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Reverse edges that reference types/entities.
- * @author Goetz Lindenmaier
- * @date 29.10.2004
- * @version $Id$
- * @summary
- * Trouts list all uses of types and entities.
- * Each type gets a list of all Alloc nodes allocating it.
- * Each entity gets two lists:
- * - one containing all accesses (Load, (Call), Store),
- * - and one containing all uses to get a reference (Sel, SymConst).
- *
- * @todo
- * To list all uses of entities of a type, we also should list all
- * static/automatic allocated entities in types. The Alloc nodes
- * represent only the dynamic allocated entities.
- */
-#ifndef FIRM_ANA_TROUTS_H
-#define FIRM_ANA_TROUTS_H
-
-#include "firm_types.h"
-#include "irgraph.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. */
-int get_entity_n_accesses(ir_entity *ent);
-/** Load/Store node that possibly access this entity. */
-ir_node *get_entity_access(ir_entity *ent, int pos);
-
-/** Number of references to an entity, in form of SymConst/Sel.
- * Including references from constant entities and the like. */
-int get_entity_n_references(ir_entity *ent);
-/** References to an entity, in form of SymConst/Sel
- * Including references from constants. */
-ir_node *get_entity_reference(ir_entity *ent, int pos);
-
-/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-/* types */
-/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-
-/** Number of Alloc nodes that create an instance of this type. */
-int get_type_n_allocs(ir_type *tp);
-/** Alloc node that create an instance of this type. */
-ir_node *get_type_alloc(ir_type *tp, int pos);
-
-/** Number of Cast nodes that cast a pointer to this type. */
-int get_type_n_casts(ir_type *tp);
-/** Cast node that cast a pointer to this type. */
-ir_node *get_type_cast(ir_type *tp, int pos);
-void add_type_cast(ir_type *tp, ir_node *cast);
-/** Return number of upcasts. O(#casts). */
-int get_class_n_upcasts(ir_type *clss);
-/** Return number of downcasts. O(#casts). */
-int get_class_n_downcasts(ir_type *clss);
-
-/* Access all pointer types that point to tp. */
-int get_type_n_pointertypes_to(ir_type *tp);
-ir_type *get_type_pointertype_to(ir_type *tp, int pos);
-void add_type_pointertype_to(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. */
-int get_type_n_arraytypes_of(ir_type *tp);
-ir_type *get_type_arraytype_of(ir_type *tp, int pos);
-void add_type_arraytype_of(ir_type *tp, ir_type *atp);
-
-
-
-/* @@@ TODO: compute all entities that use a type. */
-
-/*------------------------------------------------------------------*/
-/* Building and Removing the trout datastructure */
-/*------------------------------------------------------------------*/
-
-/** The state of the tr_out datastructure.
- *
- * We reuse the enum of irouts.
- * @see irouts.h. */
-irg_outs_state get_trouts_state(void);
-/** Set the tr out state to inconsistent if it is consistent. */
-void set_trouts_inconsistent(void);
-
-/** Compute the outs of types and entities.
- *
- * Collects all reference from irnodes to types or entities in the
- * corresponding types/entities. Further reverses references between
- * types and entities.
- *
- * Annotates the following nodes:
- * Alloc --> get_Alloc_type()
- * Cast --> get_Cast_type()
- * Sel --> get_Sel_entity()
- * SymConst --> get_SymConst_entity()
- * Load(addr) --> get_addr_entity() \ ent von SymConst, oder falls Sel: ent von
- * Store(addr) --> get_addr_entity() / outermost im compound. Ansonsten: nirgends.
- * d.h. wir bekommen die array Elementzugriffe
- * an die jack array Klasse annotiert.
- * Call(Sel) --> get_Sel_entity() // ev. Tabellenzugriff --> Load.
- *
- * type --> pointer type refering to this type.
- * type --> entity of this type. @@@ to be implemented.
- *
- * Sets trout state to outs_consistent.
- */
-void compute_trouts(void);
-
-/** Free trout data. */
-void free_trouts(void);
-
-#endif
+++ /dev/null
-#
-# Project: libFIRM
-# File name: ir/ana/Makefile.in
-# Purpose:
-# Author: Boris Boesler, Till Riedel
-# Modified by:
-# Created:
-# CVS-ID: $Id$
-# Copyright: (c) 1999-2003 Universität Karlsruhe
-# Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
-#
-
-top_srcdir := @top_srcdir@
-srcdir = @srcdir@
-topdir = ../..
-subdir := ir/ana2
-
-INSTALL_HEADERS = ecg.h irmemwalk.h lset.h typalise.h pto.h pto_comp.h \
- pto_ctx.h pto_debug.h pto_init.h pto_name.h pto_util.h pto_mod.h \
- qset.h gnu_ext.h
-
-SOURCES = $(INSTALL_HEADERS)
-
-SOURCES += Makefile.in \
- ecg.c irmemwalk.c lset.c typalise.c \
- pto.c \
- pto_comp.c pto_ctx.c pto_debug.c pto_init.c pto_name.c pto_util.c \
- pto_mod.c \
- qset.c
-
-include $(topdir)/MakeRules
-
-CPPFLAGS += -I$(top_srcdir)/ir/adt -I$(top_srcdir)/ir/ir -I$(top_srcdir)/ir/common \
- -I$(top_srcdir)/ir/ident -I$(top_srcdir)/ir/tr -I$(top_srcdir)/ir/tv \
- -I$(top_srcdir)/ir/debug -I$(top_srcdir)/ir/ana -I$(top_srcdir)/ir/st \
- -I$(top_srcdir)/ir/opt -I$(top_srcdir)/ir/arch -I$(top_srcdir)/ir/stat \
- -I$(top_srcdir)/ir/external -I$(topdir)/ir/config -I$(top_srcdir)/ir/arch
-
-include $(top_srcdir)/MakeTargets
-
-all: subdir.o
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Extended Call Graph
- * @author Florian
- * @date 14.09.2004
- * @version $Id$
- */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <assert.h>
-
-/**
- Erweiterter Aufrufgraph.
-*/
-
-#include "irnode.h"
-#include "pmap.h"
-/* #include "eset.h" */
-#include "irgwalk.h"
-#include "irgmod.h"
-#include "irvrfy.h"
-#include "trvrfy.h"
-#include "xmalloc.h"
-#include "irdump.h"
-#include "irprog_t.h"
-
-# ifndef TRUE
-# define TRUE 1
-# define FALSE 0
-# endif /* not defined TRUE */
-
-# define BUF_SIZE 1024
-
-# include "ecg.h"
-# include "typalise.h"
-# include "lset.h"
-
-# include "gnu_ext.h"
-
-# define HERE(msg) fprintf (stdout, "%s:%i %s\n", __FUNCTION__, __LINE__, msg)
-
-/*
- le flag
-*/
-/* static int verbose = 0; */
-static int do_typalise = 0;
-
-/*
- globals
-*/
-
-/* Ids for the ctxs */
-static int ctx_id = 0;
-ctx_info_t *main_ctx = NULL;
-
-/* mapping from method graphs (callR) to method graphs (lset_ts of callEds) */
-/* static pmap *calls; */
-static pmap *graph_infos;
-
-/* linked list of all graph_infos: */
-static graph_info_t *graph_infos_list = NULL;
-
-/* Counters for ecg_ecg and friends */
-static long _graphs = 0;
-static long _calls = 0;
-static long _allocs = 0;
-
-static int _depth = 0;
-static int _max_depth = 0;
-
-static int _max_callEds = 0;
-static ir_entity* _max_callEds_callR = NULL;
-
-/* Protos */
-void set_main_ctx (ctx_info_t*);
-
-/* ====================
- Alloc stuff
- ==================== */
-static void append_alloc (graph_info_t *ginfo, ir_node *alloc, ir_type *tp)
-{
- alloc_info_t *ainfo = xmalloc (sizeof (alloc_info_t));
-
- ainfo->graph = ginfo->graph;
- ainfo->alloc = alloc;
- ainfo->tp = tp;
-
- ainfo->prev = ginfo->allocs;
- ginfo->allocs = ainfo;
-}
-
-
-/* ====================
- CallEd stuff
- ==================== */
-/**
- Create a new call info struct from the given values.
-*/
-static call_info_t *new_call_info (ir_node *call,
- callEd_info_t *callEds,
- call_info_t *prev)
-{
- call_info_t *cinfo = xmalloc (sizeof (call_info_t));
- cinfo->call = call;
- cinfo->callEds = callEds;
- cinfo->prev = prev;
-
- return (cinfo);
-}
-
-/**
- Append the given callEd to the given callEd info.
-*/
-static callEd_info_t *append_callEd_info (callEd_info_t *ced, ir_graph *callEd)
-{
- callEd_info_t *nced = xmalloc (sizeof (callEd_info_t));
-
- assert (NULL != callEd);
-
- nced->callEd = callEd;
- nced->prev = ced;
-
- return (nced);
-}
-
-/**
- Append all callEd methods of the given (call) node to the given graph_info.
-*/
-static void append_calls (graph_info_t *info, ir_node *call, lset_t *callEds)
-{
- ir_graph *callEd = NULL;
- call_info_t *cinfo = new_call_info (call, NULL, info->calls);
-
- info->calls = cinfo;
-
- /* enter */
- callEd = lset_first (callEds);
-
- while (NULL != callEd) {
- cinfo->callEds = append_callEd_info (cinfo->callEds, callEd);
- callEd = lset_next(callEds);
- }
-
-}
-
-/**
- Append the (single) callEd to the given (call) node of the given graph_info.
-*/
-static void append_call (graph_info_t *info, ir_node *call, ir_graph *callEd)
-{
- call_info_t *cinfo = new_call_info (call, NULL, info->calls);
-
- info->calls = cinfo;
-
- cinfo->callEds = append_callEd_info (cinfo->callEds, callEd);
-}
-
-/**
- Given a method, find the firm graph that implements that method.
- Return NULL for abstract and native methods.
-*/
-static ir_graph *_get_implementing_graph (ir_entity *method)
-{
- ir_graph *graph = NULL;
-
- /* What's up with the fenced out stuff in rta? */
- if (peculiarity_existent == get_entity_peculiarity (method)) {
- if (visibility_external_allocated == get_entity_visibility (method)) {
- /* Todo: native implementation */
-
- return (NULL);
- } else {
- graph = get_entity_irg (get_SymConst_entity (get_atomic_ent_value (method)));
- assert (graph && "no graph");
-
- return (graph);
- }
- } else if (0 && (peculiarity_description == get_entity_peculiarity (method))) {
- /* abstract --- can't find an implementation */
- graph = get_entity_irg (method);
- assert (!graph && "graph in abstract method");
-
- return (NULL);
- } else if ((peculiarity_description == get_entity_peculiarity (method)) ||
- (peculiarity_inherited == get_entity_peculiarity (method))) {
- /* search UPWARDS */
- int i;
- int n_over = get_entity_n_overwrites (method);
-
- assert (!graph);
-
- for (i = 0; (NULL == graph) && (i < n_over); i ++) {
- ir_entity *over = get_entity_overwrites (method, i);
-
- graph = _get_implementing_graph (over);
- }
- } else {
- assert (0 && "invalid peculiarity");
- }
-
-
- return (graph);
-}
-
-/**
- Collect all graphs of 'method' in the given set.
-*/
-static void _collect_implementing_graphs (ir_entity *method, lset_t *set)
-{
- /* search DOWN-wards in clazz hierarchy */
- int i;
- int n_over = get_entity_n_overwrittenby (method);
- ir_graph *graph = get_entity_irg (method);
-
- if (NULL == graph) {
- graph = _get_implementing_graph (method);
- }
-
- if (graph) {
- lset_insert (set, graph);
- }
-
- for (i = 0; i < n_over; i ++) {
- ir_entity *over = get_entity_overwrittenby (method, i);
-
- _collect_implementing_graphs (over, set);
- }
-}
-
-
-/**
- Collect all graphs that could possibly be executed when 'method' is called.
-*/
-static lset_t *get_implementing_graphs (ir_entity *method, ir_node *select)
-{
- /* const char *name = get_entity_name (method); */
- /* fprintf (stdout, "%s (ent %s)\n", __FUNCTION__, name); */
-
- int n_graphs;
- lset_t *set = lset_create ();
- {
- ir_graph *impl = _get_implementing_graph (method);
-
- if (NULL != impl) {
- lset_insert (set, impl);
- } else {
- /* actually, abstract OR native */
- }
- }
-
- _collect_implementing_graphs (method, set);
-
- if (lset_empty (set)) {
- /* then it's a method which is only implemented natively, and we
- don' bother to analyse anything */
- return (set);
- }
-
- /* void *tmp = lset_first (set); */
- n_graphs = lset_n_entries (set);
-
-
- if (visibility_external_allocated != get_entity_visibility (method)) {
- if (0 == n_graphs) {
- ir_graph *graph = get_irn_irg (select);
-
- dump_ir_block_graph (graph, "-typealise");
-
- /* fprintf (stdout, "no graphs for method %s\n", get_entity_name (method)); */
- assert (n_graphs && "no graphs for method");
- }
- }
- /* typalise select_in */
- if (do_typalise) {
- ir_node *select_in = get_Sel_ptr (select);
- typalise_t *ta = typalise (select_in);
- /* assert (ta && "typalise failed (go figure)"); */
-
- /*
- fprintf (stdout, "typalyse res = ");
-
- if (NULL != ta) {
- if (type_invalid == ta->kind) {
- fprintf (stdout, "invalid");
- } else if (type_exact == ta->kind) {
- const char *name = get_type_name (ta->res.type);
-
- fprintf (stdout, "exact [");
- fprintf (stdout, "%s", name);
- fprintf (stdout, "]\n");
- } else if (type_types == ta->kind) {
- fprintf (stdout, "types [");
- fprintf (stdout, "...");
- fprintf (stdout, "]\n");
- } else if (type_type == ta->kind) {
- const char *name = get_type_name (ta->res.type);
- fprintf (stdout, "type [");
- fprintf (stdout, "%s", name);
- fprintf (stdout, "]\n");
- }
- } else {
- fprintf (stdout, "(null)\n");
- }
- */
-
- if (1 != n_graphs) {
- int n_filtered_graphs;
-
- set = filter_for_ta (set, ta);
- n_filtered_graphs = lset_n_entries (set);
-
- /*
- fprintf (stdout, "%s: %02d %02d\n",
- __FUNCTION__,
- n_graphs,
- n_filtered_graphs,
- n_graphs - n_filtered_graphs);
- */
- n_graphs = n_filtered_graphs;
- }
-
- if (visibility_external_allocated != get_entity_visibility (method)) {
- if (0 == n_graphs) {
- ir_graph *graph = get_irn_irg (select);
-
- dump_ir_block_graph (graph, "-ecg");
- /* fprintf (stdout, "no graphs for method %s\n", get_entity_name (method)); */
- assert (n_graphs && "no graphs for method");
- }
- }
-
- }
-
- if (n_graphs > _max_callEds) {
- _max_callEds = n_graphs;
- _max_callEds_callR = method;
- }
-
-
- return (set);
-}
-
-/**
- Determine whether a call is actually a call or if it is being
- abused for some b/d-ed reason.
-*/
-static int call_is_call (ir_node *call, ir_node *ptr)
-{
- if (op_SymConst != get_irn_op (ptr)) {
- return (TRUE);
- } else if (get_SymConst_kind (ptr) != symconst_addr_name) {
- return (TRUE);
- }
-
- return (FALSE);
-}
-
-/**
- Action for the graph.
-*/
-static void ecg_calls_act (ir_node *node, void *env)
-{
- ir_op *op = get_irn_op(node);
- graph_info_t *graph_info = (graph_info_t*) env;
-
- if (op_Call == op) { /* CALL */
- ir_entity *ent = NULL;
- ir_node *ptr = get_Call_ptr (node);
-
- if (!call_is_call (node, ptr)) {
- /*
- fprintf (stdout, "not a call: %s[%li]\n",
- get_op_name (get_irn_op (node)),
- get_irn_node_nr (node)); */
- return;
- }
-
- /* CALL SEL */
- if (op_Sel == get_irn_op (ptr)) {
- lset_t *graphs;
- ent = get_Sel_entity (ptr);
- graphs = get_implementing_graphs (ent, ptr);
-
- append_calls (graph_info, node, graphs);
- } else if (op_SymConst == get_irn_op (ptr)) {
- if (get_SymConst_kind (ptr) == symconst_addr_ent) {
- ir_graph *graph;
- ent = get_SymConst_entity (ptr);
- graph = get_entity_irg (ent);
-
- if (graph) {
- append_call (graph_info, node, graph);
- } else {
- /* it's an externally allocated thingy */
- }
- } else if (get_SymConst_kind (ptr) == symconst_addr_name) {
- /* If this SymConst refers to a method the method is external_visible
- and therefore must be considered live anyways. */
- if (get_SymConst_name (ptr) != new_id_from_str ("iro_Catch")) {
- assert (ent && "couldn't determine entity of call to symConst");
- }
- } else {
- /* other symconst. */
- assert (0 && "This SymConst can not be an address for a method call.");
- }
-
- /* STRANGE, no less ... */
- } else {
- DDMN (ptr);
- assert (0 && "Unexpected address expression");
- }
- } else if (op_Alloc == op) {
- ir_type *tp = get_Alloc_type (node);
- /* const char *name = get_type_name (tp); */
-
- append_alloc (graph_info, node, tp);
-
- /* fprintf (stdout, "NEW \"%s\"\n", name); */
- }
-}
-
-/**
- Collect called graphs for the given graph.
-*/
-static void ecg_fill_graph_calls (ir_graph *graph)
-{
- graph_info_t *ginfo = xmalloc (sizeof (graph_info_t));
-
- /* memset (ginfo, 0x00, sizeof (graph_info_t)); */
- assert (ginfo != graph_infos_list);
-
- ginfo->graph = graph;
- ginfo->calls = NULL;
- ginfo->allocs = NULL;
- ginfo->ctxs = NULL;
- ginfo->n_ctxs = 0;
- ginfo->ecg_seen = 0;
- ginfo->allocs_seen = 0;
- ginfo->prev = NULL;
-
- /* link up into global list */
- ginfo->prev = graph_infos_list;
- graph_infos_list = ginfo;
-
- assert (ginfo != ginfo->prev);
-
- irg_walk_graph (graph, ecg_calls_act, NULL, ginfo);
-
- pmap_insert (graph_infos, graph, ginfo);
-}
-
-/**
- For each graph, collect called graphs, and enter them into calls.
-*/
-static void ecg_fill_calls (void)
-{
- int i;
-
- for (i = 0; i < get_irp_n_irgs (); i++) {
- ir_graph *graph = get_irp_irg (i);
-
- ecg_fill_graph_calls (graph);
- }
-}
-
-/**
- Allocate a new ctx for the given graph and the given enclosing ctx.
-*/
-static ctx_info_t *new_ctx (ir_graph *graph, ir_node *call, ctx_info_t *enc)
-{
- ctx_info_t *res = xmalloc (sizeof (ctx_info_t));
-
- res->graph = graph;
- res->call = call;
- res->enc = enc;
- res->id = ctx_id ++;
-
- return (res);
-}
-
-
-/**
- Fill in the ctxs parts of the graph_infos
-*/
-static void ecg_fill_ctxs_count (ir_graph *graph)
-{
- graph_info_t *ginfo = ecg_get_info (graph);
-
- /* count how many ctxs we have per graph */
- if (0 == ginfo->ecg_seen) {
- call_info_t *cinfo = ginfo->calls;
-
- ginfo->ecg_seen = 1;
-
- while (NULL != cinfo) {
- callEd_info_t *ced = cinfo->callEds;
-
- while (NULL != ced) {
- ir_graph *callEd_graph = ced->callEd;
-
- /* first step: we have a new ctx */
- graph_info_t *callEd_info = ecg_get_info (callEd_graph);
- callEd_info->n_ctxs ++;
-
- /* CallR graph -> CallEd_graph */
- ecg_fill_ctxs_count (callEd_graph);
-
- ced = ced->prev;
- } /* end forall callEds (call) */
-
- cinfo = cinfo->prev;
- } /* end forall (calls(graph)) */
-
- ginfo->ecg_seen = 0;
- }
-}
-
-static void ecg_fill_ctxs_alloc (void)
-{
- /* allocate the memory needed for the ctxts: */
- graph_info_t *ginfo = graph_infos_list;
-
- while (NULL != ginfo) {
- ginfo->ctxs = xcalloc (ginfo->n_ctxs, sizeof (ctx_info_t *));
-
- /*
- fprintf (stdout, "graph of \"%s\": n_ctxs = %i\n",
- get_entity_name (get_irg_entity (ginfo->graph)), ginfo->n_ctxs);
- */
- ginfo->n_ctxs = 0;
-
- assert (ginfo != ginfo->prev);
- ginfo = ginfo->prev;
- }
-}
-
-/**
- Fill in the ctxs parts of the graph_infos
-*/
-static void ecg_fill_ctxs_write (ir_graph *graph, ctx_info_t *enc_ctx)
-{
- graph_info_t *ginfo = ecg_get_info (graph);
-
- /* enter a new ctx for all callEds along the call edges of this graph */
- if (0 == ginfo->ecg_seen) {
- call_info_t *cinfo = ginfo->calls;
- ginfo->ecg_seen = 1;
-
- while (NULL != cinfo) {
- callEd_info_t *ced = cinfo->callEds;
-
- while (NULL != ced) {
- ctx_info_t *ctx = new_ctx (graph, cinfo->call, enc_ctx);
-
- ir_graph *callEd_graph = ced->callEd;
-
- /* write the ctx of this call into the callEd graph */
- graph_info_t *callEd_info = ecg_get_info (callEd_graph);
-
- callEd_info->ctxs [callEd_info->n_ctxs] = ctx;
- callEd_info->n_ctxs ++;
-
- /* CallR graph -> callEd_graph */
- ecg_fill_ctxs_write (callEd_graph, ctx);
-
- ced = ced->prev;
- } /* end forall callEds (call) */
-
- cinfo = cinfo->prev;
- } /* end forall (calls(graph)) */
-
- ginfo->ecg_seen = 0;
- }
-}
-
-/**
- Fill in the ctxs parts of the graph_infos
-*/
-static void ecg_fill_ctxs (void)
-{
- ctx_info_t *main_ctx;
- ir_graph *main_irg;
- graph_info_t *ginfo;
-
- ecg_fill_ctxs_count (get_irp_main_irg ());
- ecg_fill_ctxs_alloc ();
-
- main_ctx = new_ctx (get_irp_main_irg (), NULL, NULL);
- main_irg = get_irp_main_irg ();
-
- set_main_ctx (main_ctx);
-
- /* Grrr, have to add this ctx manually to main.ginfo ... */
- ginfo = ecg_get_info (main_irg);
- ginfo->n_ctxs = 1;
- ginfo->ctxs = xcalloc (1, sizeof (ctx_info_t *));
- ginfo->ctxs [0] = main_ctx;
-
- ecg_fill_ctxs_write (main_irg, main_ctx);
-}
-
-/* ====================
- CTX stuff
- ==================== */
-/*
- Nicely print a ctx_info_t to the given output stream
-*/
-void ecg_print_ctx (ctx_info_t *ctx, FILE *stream)
-{
- ir_entity *ent = get_irg_entity(ctx->graph);
- ir_node *call = ctx->call;
- const char *ent_name = get_entity_name (ent);
- const char *own_name = get_type_name (get_entity_owner (ent));
-
- fprintf (stream, "CTX[%i](%s.%s->%s[%li])",
- ctx->id, own_name, ent_name,
- get_op_name (get_irn_op (call)),
- get_irn_node_nr (call));
-
- if (NULL != ctx->enc) {
- fprintf (stream, "->%i", ctx->enc->id);
- }
-
- fprintf (stream, "\n");
-}
-
-/*
- Get a ctx of the given graph info
-*/
-ctx_info_t *get_ctx (graph_info_t *ginfo, int ctx_idx)
-{
- assert (ginfo->n_ctxs > ctx_idx);
-
- return (ginfo->ctxs [ctx_idx]);
-}
-
-/*
- Get the pseudo-ctx of 'main'
-*/
-ctx_info_t *get_main_ctx ()
-{
- return (main_ctx);
-}
-
-/*
- Set the pseudo-ctx of 'main'
-*/
-void set_main_ctx (ctx_info_t *ctx)
-{
- main_ctx = ctx;
-}
-
-
-/* ====================
- ECG stuff
- ==================== */
-
-/* ====================
- Iterator stuff
- ==================== */
-/*
- Iterate over all graphs
-*/
-void ecg_iterate_graphs (graph_hnd_t *hnd, void *env)
-{
- graph_info_t *ginfo = graph_infos_list;
-
- while (NULL != ginfo) {
- /* do not visit graphs that have 0 == ginfo->n_ctxs, since they
- are not called */
- if (0 != ginfo->n_ctxs) {
- hnd (ginfo, env);
- }
-
- ginfo = ginfo->prev;
- }
-}
-
-
-/*
- Iterate of all allocs of a given graph info
-*/
-void ecg_iterate_allocs (graph_info_t *ginfo, alloc_hnd_t *hnd, void *env)
-{
- alloc_info_t *ainfo = ginfo->allocs;
-
- while (NULL != ainfo) {
- hnd (ainfo, env);
-
- ainfo = ainfo->prev;
- }
-}
-
-
-/*
- Iterate over all calls of the given graph info
-*/
-void ecg_iterate_calls (graph_info_t *ginfo, call_hnd_t *hnd, void *env)
-{
- call_info_t *cinfo = ginfo->calls;
-
- while (NULL != cinfo) {
- hnd (cinfo, env);
-
- cinfo = cinfo->prev;
- }
-}
-
-
-/*
- Iterate over all callEds of the given call info
-*/
-void ecg_iterate_callEds (call_info_t *cinfo, callEd_hnd_t *hnd, void *env)
-{
- callEd_info_t *ced = cinfo->callEds;
-
- while (NULL != ced) {
- hnd (ced, env);
-
- ced = ced->prev;
- }
-}
-
-
-/*
- get the call infos for the given graph
-*/
-graph_info_t *ecg_get_info (ir_graph *graph)
-{
- graph_info_t *ginfo = (graph_info_t*) pmap_get (graph_infos, graph);
-
- assert (ginfo && "no info for graph");
-
- return (ginfo);
-}
-
-/*
- Get the Alloc Infos for the given graph
-*/
-alloc_info_t *ecg_get_alloc_info (ir_graph *graph)
-{
- graph_info_t *ginfo = ecg_get_info (graph);
-
- return (ginfo->allocs);
-}
-
-/*
- Get the Call Info for the given call
-*/
-callEd_info_t *ecg_get_callEd_info (ir_node *call)
-{
- ir_graph *graph = get_irn_irg (call);
- graph_info_t *ginfo = ecg_get_info (graph);
-
- call_info_t *call_info = ginfo->calls;
-
- while (NULL != call_info) {
- if (call == call_info->call) {
- return (call_info->callEds);
- }
-
- call_info = call_info->prev;
- }
-
- return (NULL);
-}
-
-
-/**
- Dump the given graph and it's calls and it's calls callEds to the given file.
-*/
-static int ecg_ecg_graph (FILE *dot, ir_graph *graph)
-{
- int graph_no;
- call_info_t *cinfo;
- alloc_info_t *ainfo;
- const char *name = get_irg_entity (graph) ?
- get_entity_name (get_irg_entity (graph)) : "noEntity";
- const char *color =
- (get_entity_stickyness
- (get_irg_entity (graph)) == stickyness_sticky) ?
- "red" : "lightyellow";
-
- /* graph_info_t *ginfo = (graph_info_t*) pmap_get (graph_infos, graph); */
- graph_info_t *ginfo = ecg_get_info (graph);
-
- if (0 != ginfo->ecg_seen) {
- fprintf (dot, "\t/* recursive call to \"%s\" (%d) */\n",
- name, (int) ginfo->ecg_seen);
-# if 0
- fprintf (dot, "\t/* recursive call to \"%s\" (0x%08x) */\n",
- name, (int) graph);
-# endif /* 0 */
- return (ginfo->ecg_seen);
- }
-
- assert (0L <= _graphs);
-
- graph_no = _graphs ++;
- ginfo->ecg_seen = graph_no;
-
- fprintf (dot, "\t/* Graph of \"%s.%s\" */\n",
- get_type_name (get_entity_owner (get_irg_entity (graph))),
- name);
- fprintf (dot, "\tgraph_%i [label=\"<HEAD>%s\\l%s\\l|<CTX>n_ctx = %i\\l\", color=\"%s\"];\n",
- graph_no,
- get_type_name (get_entity_owner (get_irg_entity (graph))),
- name,
- ginfo->n_ctxs,
- color);
- fprintf (dot, "\n");
-
- if (visibility_external_allocated ==
- get_entity_visibility (get_irg_entity (graph))) {
- fprintf (dot, "\t/* graph \"%s\" is external */\n", name);
-
- return (graph_no);
- }
-
- cinfo = ginfo->calls;
- while (NULL != cinfo) {
- ir_node *call = cinfo->call;
- callEd_info_t *ced = cinfo->callEds;
- const int call_no = _calls ++;
- const char *call_color = (NULL == ced) ? "blue" :
- (NULL == ced->prev) ? "lightblue" : "blue3";
-
- fprintf (dot, "\t/* Call %li */\n", get_irn_node_nr (call));
- fprintf (dot, "\tcall_%i [label=\"call\\[%li\\]\", color=\"%s\", shape=\"ellipse\"];\n",
- call_no, get_irn_node_nr (call), call_color);
- fprintf (dot, "\tgraph_%i -> call_%i [color=\"black\"];\n", graph_no, call_no);
-
- while (NULL != ced) {
- ir_graph *callEd_graph = ced->callEd;
- const int callEd_no = ecg_ecg_graph (dot, callEd_graph);
- const char *callEd_name = get_irg_entity (callEd_graph) ?
- get_entity_name (get_irg_entity (callEd_graph)) : "noEntity";
- const char *direction = (callEd_no <= graph_no) ? "forward" : "forward";
- const char *callEd_color = (callEd_no <= graph_no) ? "red" : "black";
-
- fprintf (dot, "\t/* Call from graph \"%s\" to graph \"%s\" */\n",
- name,
- callEd_name);
- /* Check for recursive calls */
- /* if (callEd_no > graph_no) */ { /* do recursive calls (for now) */
- fprintf (dot, "\tcall_%i -> graph_%i:HEAD [color=\"%s\", dir=\"%s\"];\n",
- call_no, callEd_no, callEd_color, direction);
- }
-
- ced = ced->prev;
- /* ced = NULL; */
- } /* done all calEds (call) */
-
- cinfo = cinfo->prev;
- } /* done all calls (graph) */
-
- /* now the allocs */
- ainfo = ecg_get_alloc_info (graph);
- if (ainfo) {
- fprintf (dot, "\t/* now the allocs */\n");
- } else {
- fprintf (dot, "\t/* no allocs */\n");
- }
-
- while (NULL != ainfo) {
- ir_node *alloc = ainfo->alloc;
- const char *name = get_type_name (ainfo->tp);
- const char *color = "red1";
-
- _allocs ++;
- fprintf (dot, "\talloc_0x%08x_%i [label=\"%s\", color=\"%s\"];\n",
- (int) alloc, graph_no, name, color);
-
- fprintf (dot, "\tgraph_%i -> alloc_0x%08x_%i;\n",
- graph_no, (int) alloc, graph_no);
-
- ainfo = ainfo->prev;
- }
-
- if (0 == ginfo->allocs_seen) {
- ginfo->allocs_seen = 1;
- }
-
- /* write table of ctxs */
- {
- int i;
- const int max_ctxs = 30;
- const int n_ctxs = (ginfo->n_ctxs > max_ctxs) ? max_ctxs : ginfo->n_ctxs;
-
- fprintf (dot, "\tctx_%i [label=\"<HEAD>", graph_no);
-
- assert (ginfo->ctxs && "no ctx");
- for (i = 0; i < n_ctxs; i ++) {
- ctx_info_t *ctx_info = ginfo->ctxs [i];
-
- if (NULL != ctx_info->enc) {
- fprintf (dot, "ctx_info \\[%i\\] = ctx\\[%i\\-\\>%i\\]\\l",
- i,
- ctx_info->id,
- ctx_info->enc->id);
- } else {
- fprintf (dot, "ctx_info \\[%i\\] = ctx\\[%i\\]\\l",
- i, ctx_info->id);
- }
-
- if (i+1 != n_ctxs) {
- fprintf (dot, "|");
- }
- }
-
- if (0 < ginfo->n_ctxs - max_ctxs) {
- fprintf (dot, "(%i more)\\l", ginfo->n_ctxs - max_ctxs);
- }
-
- fprintf (dot, "\", color=\"green3\"];\n");
-
- fprintf (dot,
- "\tgraph_%i:CTX -> ctx_%i:HEAD [label=\"ctx\", dir=\"none\", style=\"dotted\"];\n",
- graph_no, graph_no);
- }
-
- fprintf (dot, "\t/* done with graph of \"%s\" */\n\n", name);
-
- fflush (dot);
- ginfo->ecg_seen = 0;
-
- return (graph_no);
-}
-
-/**
- Count how many nodes the ECG will have
-*/
-static char spaces [BUF_SIZE];
-
-static void ecg_ecg_count (ir_graph *graph)
-{
- int graph_no;
- call_info_t *cinfo;
- graph_info_t *ginfo = (graph_info_t*) pmap_get (graph_infos, graph);
-
- if (0 != ginfo->ecg_seen) {
- return;
- }
-
- _depth ++;
- if (_depth > _max_depth) {
- _max_depth = _depth;
-
- /*
- fprintf (stdout, "_max_depth = %i\n", _max_depth);
- fprintf (stdout, "\tn_graphs: %i\n", _graphs);
- */
- }
-
- assert (0L <= _graphs);
-
- /*
- if (0 == (_graphs % 1000000)) {
- fprintf (stdout, "\tn_graphs: %i\n", _graphs);
- fprintf (stdout, "_depth = %i\n", _depth);
- }
- */
-
- graph_no = _graphs ++;
- ginfo->ecg_seen = graph_no;
-
- fprintf (stdout, "%sMethod \"%s.%s\"\n",
- spaces + BUF_SIZE - _depth,
- get_type_name (get_entity_owner (get_irg_entity (graph))),
- get_entity_name (get_irg_entity (graph)));
-
- cinfo = ginfo->calls;
- while (NULL != cinfo) {
-
- callEd_info_t *ced = cinfo->callEds;
-
- fprintf (stdout, "%sCall \"0x%08x\"\n",
- spaces + BUF_SIZE - _depth,
- (int) cinfo->call);
-
- while (NULL != ced) {
- ir_graph *callEd_graph = ced->callEd;
-
- fprintf (stdout, "%sCall Target \"%s.%s\"\n",
- spaces + BUF_SIZE - _depth,
- get_type_name (get_entity_owner (get_irg_entity (callEd_graph))),
- get_entity_name (get_irg_entity (callEd_graph)));
-
- ecg_ecg_count (callEd_graph);
-
- ced = ced->prev;
- } /* done all calEds (call) */
- cinfo = cinfo->prev;
- } /* done all calls (graph) */
-
- ginfo->ecg_seen = 0;
- _depth --;
-}
-
-/* ====================
- Public Interface
- ==================== */
-
-/**
- Initialise our data structures.
-*/
-void ecg_init (int typalise)
-{
- do_typalise = typalise;
-
- if (typalise) {
- typalise_init ();
- }
-
- graph_infos = pmap_create ();
-
- ecg_fill_calls ();
- ecg_fill_ctxs ();
- ecg_ecg ();
-}
-
-/**
- Clean up our mess.
-*/
-void ecg_cleanup (void)
-{
- int i;
-
- return;
-
- for (i = 0; i < get_irp_n_irgs (); i++) {
- ir_graph *graph = get_irp_irg (i);
-
- graph_info_t *info = pmap_get (graph_infos, graph);
- call_info_t *cinfo = info->calls;
-
- while (NULL != cinfo) {
- callEd_info_t *ced = cinfo->callEds;
-
- cinfo->call = NULL;
-
- while (NULL != ced) {
- callEd_info_t *nced = ced->prev;
- free (ced);
- ced->prev = NULL;
- ced->callEd = NULL;
- ced = nced;
- }
-
- cinfo->callEds = NULL;
-
- free (cinfo);
- cinfo = cinfo->prev;
- }
-
- free (info);
- pmap_insert (graph_infos, graph, NULL);
- }
-
-
- pmap_destroy (graph_infos);
-
- /* paranoia mode */
- graph_infos = NULL;
-}
-
-/**
- Show what we have found.
-*/
-void ecg_report ()
-{
- int i;
-
- FILE *dot = fopen ("calls.dot", "w");
-
- fprintf (dot, "digraph \"calls\" {\n");
- fprintf (dot, "\tgraph [rankdir=\"LR\", ordering=\"out\", size=\"11, 7\", rotate=\"90\", ratio=\"fill\"];\n");
- fprintf (dot, "\tnode [shape=\"record\", style=\"filled\"];\n");
- fprintf (dot, "\tedge [color=\"black\"];\n");
- fprintf (dot, "\n");
-
- for (i = 0; i < get_irp_n_irgs (); i++) {
- ir_graph *graph = get_irp_irg (i);
- graph_info_t *ginfo = (graph_info_t*) pmap_get (graph_infos, graph);
-
- if (0 != ginfo->n_ctxs) {
- call_info_t *cinfo;
- alloc_info_t *ainfo;
-
- const char *name = get_irg_entity (graph) ?
- get_entity_name (get_irg_entity (graph)) : "noEntity";
-
- const char *oname = get_type_name
- (get_entity_owner (get_irg_entity (graph)));
-
- const char *color =
- (get_entity_stickyness
- (get_irg_entity (graph)) == stickyness_sticky) ?
- "red3" : "lightyellow";
-
- fprintf (dot, "\t/* graph_0x%08x (\"%s\") */\n", (int) graph, name);
- fprintf (dot,
- "\tgraph_0x%08x [label=\"%s\\l%s\", color=\"%s\"];\n",
- (int) graph, oname, name, color);
- fprintf (dot, "\n");
-
- cinfo = ginfo->calls;
- if (cinfo) {
- fprintf (dot, "\t/* now the calls */\n");
- } else {
- fprintf (dot, "\t/* no calls, nothing to see, move along! */\n");
- }
-
- while (NULL != cinfo) {
- callEd_info_t *ced;
- ir_node *call = cinfo->call;
-
- fprintf (dot, "\t/* call_0x%08x */\n", (int) call);
- fprintf (dot, "\tcall_0x%08x [label=\"call\\[%li\\]\", shape=\"ellipse\", color=\"lightblue\"];\n",
- (int) call, get_irn_node_nr (call));
- fprintf (dot, "\tgraph_0x%08x -> call_0x%08x;\n",
- (int) graph, (int) call);
-
- ced = cinfo->callEds;
- while (NULL != ced) {
- fprintf (dot, "\tcall_0x%08x -> graph_0x%08x;\n",
- (int) call, (int) ced->callEd);
- ced = ced->prev;
- }
- fprintf (dot, "\n");
-
- cinfo = cinfo->prev;
- }
- fprintf (dot, "\n");
-
- ainfo = ginfo->allocs;
- if (ainfo) {
- fprintf (dot, "\t/* now the allocs */\n");
- } else {
- fprintf (dot, "\t/* no allocs */\n");
- }
-
- /* allocs */
- while (NULL != ainfo) {
- ir_node *alloc = ainfo->alloc;
- const char *name = get_type_name (ainfo->tp);
- const char *color = "red1";
-
- fprintf (dot, "\talloc_0x%08x [label=\"%s\", color=\"%s\"];\n",
- (int) alloc, name, color);
- fprintf (dot, "\tgraph_0x%08x -> alloc_0x%08x;\n",
- (int) graph, (int) alloc);
-
- ainfo = ainfo->prev;
- }
-
- /* ctxs */
- {
- int i;
- const int max_ctxs = 30;
- const int n_ctxs = (ginfo->n_ctxs > max_ctxs) ? max_ctxs : ginfo->n_ctxs;
-
- fprintf (dot, "\t/* now the ctxs */\n");
- fprintf (dot, "\tctx_0x%08x [label=\"<HEAD>", (int) graph);
-
- assert (ginfo->ctxs && "no ctx");
- for (i = 0; i < n_ctxs; i ++) {
- ctx_info_t *ctx_info = ginfo->ctxs [i];
-
- if (NULL != ctx_info->enc) {
- fprintf (dot, "ctx_info \\[%i\\] = ctx\\[%i\\-\\>%i\\]\\l",
- i,
- ctx_info->id,
- ctx_info->enc->id);
- } else {
- fprintf (dot, "ctx_info \\[%i\\] = ctx\\[%i\\]\\l",
- i, ctx_info->id);
- }
-
- if (i+1 != n_ctxs) {
- fprintf (dot, "|");
- }
- }
-
- if (0 < ginfo->n_ctxs - max_ctxs) {
- fprintf (dot, "(%i more)\\l", ginfo->n_ctxs - max_ctxs);
- }
-
- fprintf (dot, "\", color=\"green3\"];\n");
-
- fprintf (dot,
- "\tgraph_0x%p -> ctx_0x%p:HEAD [label=\"ctx\", dir=\"none\", style=\"dotted\"];\n",
- graph, graph);
- }
- } else {
- fprintf (dot, "\t/* graph is not called */\n");
- } /* end all graphs */
- }
- fprintf (dot, "}\n");
-
- /*
- fprintf (stdout, " max_callEds: %i\n", _max_callEds);
- fprintf (stdout, " max_callEds_callR: \"%s\"\n",
- get_entity_name (_max_callEds_callR));
- */
- fclose (dot);
-}
-
-/**
- Experimental: Print the ecg
-*/
-void ecg_ecg (void)
-{
- FILE *dot;
- ir_graph *main_graph = get_irp_main_irg ();
-
- _graphs = 0;
- _calls = 0;
-
- /*
- memset (spaces, '.', BUF_SIZE);
- spaces [BUF_SIZE-1] = '\0';
-
- ecg_ecg_count (main_graph);
- fprintf (stdout, "n_graphs: %i\n", _graphs);
- fprintf (stdout, "max_depth = %i\n", _max_depth);
- */
-
- /* return; */
-
- _graphs = 0;
- _calls = 0;
-
- dot = fopen ("ecg.dot", "w");
-
- fprintf (dot, "digraph \"ecg\" {\n");
- fprintf (dot, "\tgraph [rankdir=\"LR\", ordering=\"out\", size=\"11, 7\", rotate=\"90\", ratio=\"fill\"];\n");
- fprintf (dot, "\tnode [shape=\"record\", style=\"filled\"];\n");
- fprintf (dot, "\tedge [color=\"black\"];\n");
- fprintf (dot, "\n");
- fprintf (dot, "\n");
-
- /* ir_graph *main_graph = get_irp_main_irg (); */
- ecg_ecg_graph (dot, main_graph);
-
- fprintf (dot, "\t/* Grand Total: */\n");
- fprintf (dot, "\t/* calls: %i */\n", (int) _calls);
- fprintf (dot, "\t/* graphs: %i */\n", (int) _graphs);
- fprintf (dot, "\t/* allocs: %i */\n", (int) _allocs);
- fprintf (dot, "\t/* (sales tax not included) */\n");
-
- fprintf (dot, "}\n");
-
- fclose (dot);
-}
-
-\f
-
-/*
- $Log: ecg.c,v $
- Revision 1.23 2006/12/13 19:46:47 beck
- rename type entity into ir_entity
-
- Revision 1.22 2006/01/13 22:55:03 beck
- renamed all types 'type' to 'ir_type'
-
- Revision 1.21 2005/12/31 15:58:57 beck
- added missing includes
-
- Revision 1.20 2005/12/05 12:01:06 beck
- needed include added
-
- Revision 1.19 2005/03/22 13:55:51 liekweg
- Need to initialise typalise now
-
- Revision 1.18 2005/01/14 14:14:43 liekweg
- fix gnu extension
-
- Revision 1.17 2005/01/14 13:34:25 liekweg
- Factor out call_info_t ctor; fix mallocs; fix initialisation
-
- Revision 1.16 2005/01/10 17:26:34 liekweg
- fixup printfs, don't put environments on the stack
-
- Revision 1.15 2004/12/23 15:40:03 beck
- used new xcalloc
-
- Revision 1.14 2004/12/22 14:43:14 beck
- made allocations C-like
-
- Revision 1.13 2004/12/21 14:21:16 beck
- removed C99 constructs
-
- Revision 1.12 2004/12/20 17:34:34 liekweg
- fix recursion handling
-
- Revision 1.11 2004/12/15 09:18:18 liekweg
- pto_name.c
-
- Revision 1.10 2004/12/06 12:55:06 liekweg
- actually iterate
-
- Revision 1.9 2004/12/02 16:17:50 beck
- fixed config.h include
-
- Revision 1.8 2004/11/30 14:45:44 liekweg
- fix graph dumping, remove 'HERE's
-
- Revision 1.7 2004/11/26 16:01:56 liekweg
- debugging annotations
-
- Revision 1.6 2004/11/24 14:53:55 liekweg
- Bugfixes
-
- Revision 1.5 2004/11/20 21:20:29 liekweg
- Added iterator functions
-
- Revision 1.4 2004/11/18 16:36:37 liekweg
- Added unique ids for debugging, added access functions
-
- Revision 1.3 2004/11/04 14:54:44 liekweg
- Nicer Colors
-
- Revision 1.2 2004/10/21 11:09:37 liekweg
- Moved memwalk stuf into irmemwalk
- Moved lset stuff into lset
- Moved typalise stuff into typalise
-
- Revision 1.1 2004/10/20 14:59:41 liekweg
- Added ana2, added ecg and pto
-
- Revision 1.6 2004/10/18 12:47:19 liekweg
- minor fix
-
- Revision 1.5 2004/10/14 11:31:28 liekweg
- SHUTUP_GCC
-
- Revision 1.4 2004/10/12 11:02:01 liekweg
- wtf?
-
-*/
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Extended Call Graph
- * @author Florian
- * @version $Id$
- */
-#ifndef FIRM_ANA2_EGC_H
-#define FIRM_ANA2_EGC_H
-
-# include "irgraph.h"
-# include "irnode.h"
-
-/*
- data
-*/
-
-typedef struct ctx_info
-{
- ir_graph *graph; /* The graph of the callR who created this ctx */
- /* (which is redundant, since it's always == get_irn_graph (call) */
- ir_node *call; /* The call through which this graph was called */
- struct ctx_info *enc; /* The ctx in which our callR was called */
- int id;
-} ctx_info_t;
-
-typedef struct alloc_info
-{
- ir_graph *graph;
- ir_node *alloc;
- ir_type *tp;
- struct alloc_info *prev;
-} alloc_info_t;
-
-typedef struct callEd_info
-{
- ir_graph *callEd;
- struct callEd_info *prev;
-} callEd_info_t;
-
-typedef struct call_info
-{
- ir_node *call;
- callEd_info_t *callEds;
- struct call_info *prev;
-} call_info_t;
-
-typedef struct graph_info
-{
- ir_graph *graph;
- call_info_t *calls;
- alloc_info_t *allocs;
- ctx_info_t **ctxs;
- int n_ctxs;
- int ecg_seen;
- int allocs_seen;
- struct graph_info *prev;
-} graph_info_t;
-
-typedef void graph_hnd_t (graph_info_t*, void*);
-typedef void alloc_hnd_t (alloc_info_t*, void*);
-typedef void call_hnd_t (call_info_t*, void*);
-typedef void callEd_hnd_t (callEd_info_t*, void*);
-
-/* protos */
-void ecg_print_ctx (ctx_info_t*, FILE *stream);
-
-ctx_info_t *get_ctx (graph_info_t*, int);
-ctx_info_t *get_main_ctx (void);
-
-void ecg_iterate_graphs (graph_hnd_t*, void*);
-void ecg_iterate_allocs (graph_info_t*, alloc_hnd_t*, void*);
-void ecg_iterate_calls (graph_info_t*, call_hnd_t*, void*);
-void ecg_iterate_callEds (call_info_t*, callEd_hnd_t*, void*);
-
-graph_info_t *ecg_get_info (ir_graph*);
-alloc_info_t *ecg_get_alloc_info (ir_graph*);
-callEd_info_t *ecg_get_callEd_info (ir_node*);
-
-void ecg_init (int);
-void ecg_cleanup (void);
-void ecg_report (void);
-void ecg_ecg (void);
-
-#endif /* defined _EGC_H_ */
-
-\f
-/*
-$Log$
-Revision 1.4 2006/01/13 22:00:15 beck
-renamed all types 'type' to 'ir_type'
-
-Revision 1.3 2004/11/20 21:20:29 liekweg
-Added iterator functions
-
-Revision 1.2 2004/11/18 16:36:37 liekweg
-Added unique ids for debugging, added access functions
-
-Revision 1.1 2004/10/20 14:59:42 liekweg
-Added ana2, added ecg and pto
-
-Revision 1.3 2004/10/14 11:31:29 liekweg
-SHUTUP_GCC
-
-Revision 1.2 2004/10/12 11:02:03 liekweg
-wtf?
-
-Revision 1.1 2004/09/29 12:03:39 liekweg
-Added ecg mod
- */
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Provide some GNU CC extensions to the rest of the world
- * @author Florian
- * @date Sat Nov 13 19:35:27 CET 2004
- * @version $Id$
- */
-# ifdef HAVE_CONFIG_H
-# include "config.h"
-# endif
-
-/*
- gnu_ext: Provide some GNU CC extensions to the rest of the world
-*/
-
-/* Includes */
-
-/* Local Defines: */
-# if !defined (__GNUC__)
-# if !defined(__FUNCTION__)
-# define __FUNCTION__ "::"
-# endif
-# if !defined(__PRETTY_FUNCTION__)
-# define __PRETTY_FUNCTION__ ":::"
-# endif
-# endif /* !define __GNUC__ */
-
-/* Local Data Types: */
-
-/* Local Variables: */
-
-/* Local Prototypes: */
-
-/* ===================================================
- Local Implementation:
- =================================================== */
-
-/* ===================================================
- Exported Implementation:
- =================================================== */
-
-\f
-/*
- $Log$
- Revision 1.2 2006/07/02 16:30:17 beck
- Fixed warnings on newer VC
-
- Revision 1.1 2005/01/14 14:15:19 liekweg
- Support GNU extensions on non-GNU platforms
-
-
-*/
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief walk along memory edges
- * @author Florian
- * @date Mon 18 Oct 2004
- * @version $Id$
- * @summary
- * Walk over a firm graph along its memory edges.
- *
- * Any number of graphs can be visited at the same time, but no graph
- * can be traversed more than once at any time.
- */
-# ifdef HAVE_CONFIG_H
-# include "config.h"
-# endif
-
-# include "irnode_t.h"
-# include "irgwalk.h" /* for irg_walk_func */
-# include "irprog.h" /* for get_irp_main_irg */
-# include "xmalloc.h"
-# include "gnu_ext.h"
-
-# ifndef TRUE
-# define TRUE 1
-# define FALSE 0
-# endif /* not defined TRUE */
-
-/*
- Data
-*/
-
-/** environment for a single memory walker */
-typedef struct walk_mem_env_str {
- ir_graph *graph; /**< the graph we're visiting */
- unsigned long visited; /**< 'visited' marker
- (unsigned long in case we walk more than 2^32 graphs) */
- irg_walk_func *pre; /**< pre action */
- irg_walk_func *post; /**< post action */
- void *env; /**< user-defined environment */
-
- struct walk_mem_env_str *prev; /**< link up walking instances */
- /* what else? */
-} walk_mem_env_t;
-
-/*
- Globals
-*/
-
-/* Link up walking instances */
-static walk_mem_env_t *walk_envs = NULL;
-
-/*
- Walk over the firm nodes of a graph via the memory edges (only)
- starting from a node that has a memory input.
-*/
-static void irg_walk_mem_node (ir_node *node,
- walk_mem_env_t *walk_env)
-{
- const ir_opcode op = get_irn_opcode (node);
- ir_node *in = NULL;
-
- if (get_irn_visited (node) >= walk_env->visited) {
- return;
- } else {
- set_irn_visited (node, walk_env->visited);
- }
-
- if (op_NoMem == get_irn_op (node)) {
- /* We don't want to see it it if it's not memory */
- return;
- }
-
- if (iro_Proj == op) {
- /* We don't want to see proj nodes at all --- skip over them */
- in = get_Proj_pred (node);
-
- irg_walk_mem_node (in, walk_env);
-
- return;
- }
-
- /* execute the 'pre' function */
- if (NULL != walk_env->pre) {
- walk_env->pre (node, walk_env->env);
- }
-
- switch (op) {
- case (iro_Start): {
- } break;
- case (iro_Load): {
- in = get_Load_mem (node);
-
- irg_walk_mem_node (in, walk_env);
- } break;
- case (iro_Store): {
- in = get_Store_mem (node);
-
- irg_walk_mem_node (in, walk_env);
- } break;
- case (iro_Alloc): {
- in = get_Alloc_mem (node);
-
- irg_walk_mem_node (in, walk_env);
- } break;
- case (iro_Free): {
- in = get_Free_mem (node);
- /* WTF? */
- irg_walk_mem_node (in, walk_env);
- } break;
- case (iro_Raise): {
- in = get_Raise_mem (node);
-
- irg_walk_mem_node (in, walk_env);
- } break;
- case (iro_Sel): {
- in = get_Sel_mem (node);
-
- irg_walk_mem_node (in, walk_env);
- } break;
- case (iro_Call): {
- in = get_Call_mem (node);
-
- irg_walk_mem_node (in, walk_env);
- } break;
- case (iro_Return): {
- in = get_Return_mem (node);
-
- irg_walk_mem_node (in, walk_env);
- } break;
- case (iro_Phi): {
- int i;
- int n_ins = get_irn_arity (node);
-
- for (i = 0; i < n_ins; i ++) {
- in = get_irn_n (node, i);
-
- irg_walk_mem_node (in, walk_env);
- }
- } break;
- case (iro_Div): {
- in = get_Div_mem (node);
-
- irg_walk_mem_node (in, walk_env);
- } break;
- case (iro_Quot): {
- in = get_Quot_mem (node);
-
- irg_walk_mem_node (in, walk_env);
- } break;
- case (iro_Mod): {
- in = get_Mod_mem (node);
-
- irg_walk_mem_node (in, walk_env);
- } break;
- case (iro_DivMod): {
- in = get_DivMod_mem (node);
-
- irg_walk_mem_node (in, walk_env);
- } break;
- case (iro_Block): {
- /* End Block ONLY */
- int i;
- int n_ins = get_irn_arity (node);
-
- for (i = 0; i < n_ins; i ++) {
- ir_node *ret = get_irn_n (node, i);
-
- irg_walk_mem_node (ret, walk_env);
- }
- } break;
- default: {
- fprintf (stderr, "%s: not handled: node[%li].op = %s\n",
- __FUNCTION__,
- get_irn_node_nr (node),
- get_op_name (get_irn_op (node)));
-
- assert (0 && "something not handled");
- }
- }
-
- /* execute the 'post' function */
- if (NULL != walk_env->post) {
- walk_env->post (node, walk_env->env);
- }
-}
-
-/*
- See whether the given graph is being visited right now.
- We can't be visiting a graph multiple times.
-*/
-int get_irg_is_mem_visited (ir_graph *graph)
-{
- walk_mem_env_t *walk_env = walk_envs;
-
- while (NULL != walk_env) {
- if (graph == walk_env->graph) {
- return (TRUE);
- }
-
- walk_env = walk_env->prev;
- }
-
- return (FALSE);
-}
-
-/*
- Walk over the nodes of the given graph via the memory edges (only).
- Each graph can only be subject to this walk once at any given time.
-*/
-void irg_walk_mem (ir_graph *graph,
- irg_walk_func *pre, irg_walk_func *post,
- void *env)
-{
- ir_node *end_block = get_irg_end_block (graph);
- walk_mem_env_t *walk_env = xmalloc (sizeof (walk_mem_env_t));
-
- assert (! get_irg_is_mem_visited (graph));
-
- walk_env->graph = graph;
- inc_irg_visited (walk_env->graph);
- walk_env->visited = get_irg_visited (graph);
-
- walk_env->prev = walk_envs;
- walk_envs = walk_env;
-
- walk_env->pre = pre;
- walk_env->post = post;
- walk_env->env = env;
-
- /* 'graph' is not actually being visited right now, so make sure it is reported that way */
- assert (get_irg_is_mem_visited (graph));
-
- /*
- The ins of the end BLOCK are either 'return's (regular exits) or
- 'ProjX'/'Raise's (exception exits). We only walk over the
- 'return' nodes, assuming that all memory-changing nodes are found
- from there on.
- */
- irg_walk_mem_node (end_block, walk_env);
- /*
- The end NODE sometimes has some more ins. not sure whether we need to walk them.
- */
-
- /* allow only properly nested calls right now */
- assert (walk_envs == walk_env);
- walk_envs = walk_envs->prev;
-
- free (walk_env);
-
- assert (! get_irg_is_mem_visited (graph));
-}
-
-\f
-
-/*
- $Log$
- Revision 1.12 2007/01/16 15:45:42 beck
- renamed type opcode to ir_opcode
-
- Revision 1.11 2005/01/26 12:20:20 beck
- gnu_ext.h included
-
- Revision 1.10 2005/01/14 13:34:48 liekweg
- Don't cast malloc
-
- Revision 1.9 2005/01/10 17:26:34 liekweg
- fixup printfs, don't put environments on the stack
-
- Revision 1.8 2004/12/22 14:43:14 beck
- made allocations C-like
-
- Revision 1.7 2004/12/21 14:25:35 beck
- removed C99 constructs
- make visit counter of same type as irn visit counter
-
- Revision 1.6 2004/12/02 16:17:51 beck
- fixed config.h include
-
- Revision 1.5 2004/11/19 10:35:20 liekweg
- also test for NoMem
-
- Revision 1.4 2004/11/18 16:35:11 liekweg
- Do not touch Proj nodes at all
-
- Revision 1.3 2004/11/04 14:57:12 liekweg
- fixed end block handling
-
- Revision 1.2 2004/10/22 14:41:12 liekweg
- execute 'pre' for a change. Also, add CVS log
-
-
-*/
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief walk along memory edges
- * @author Florian
- * @date Mon 18 Oct 2004
- * @version $Id$
- */
-# ifndef FIRM_ANA2_IRMEMWALK_H
-# define FIRM_ANA2_IRMEMWALK_H
-
-# include "irgraph.h"
-# include "irgwalk.h"
-
-void irg_walk_mem (ir_graph*, irg_walk_func*, irg_walk_func*, void*);
-int get_irg_is_mem_visited (ir_graph*);
-
-# endif
-
-\f
-/*
- $Log$
- Revision 1.1 2004/10/21 11:09:37 liekweg
- Moved memwalk stuf into irmemwalk
- Moved lset stuff into lset
- Moved typalise stuff into typalise
-
-
- */
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Lists, err, Sets
- * @author Florian
- * @date Mon 18 Oct 2004
- * @version $Id$
- */
-# ifdef HAVE_CONFIG_H
-# include "config.h"
-# endif
-
-# include "lset.h"
-# include "xmalloc.h"
-
-# ifndef TRUE
-# define TRUE 1
-# define FALSE 0
-# endif /* not defined TRUE */
-
-# include <assert.h>
-
-#ifdef HAVE_STRING_H
-# include <string.h> /* need memset */
-#endif
-
-/*
- Lists, err, Sets
- */
-
-/* create a new lset */
-lset_t *lset_create (void)
-{
- lset_t *lset = xmalloc (sizeof (lset_t));
- memset (lset, 0x00, sizeof (lset_t));
-
- return (lset);
-}
-
-/* check whether the lset contains an entry for the given data */
-int lset_contains (lset_t *lset, void *data)
-{
- lset_entry_t *entry = lset->first;
-
- while (NULL != entry) {
- if (data == entry->data) {
- return (TRUE);
- }
-
- entry = entry->next;
- }
-
- return (FALSE);
-}
-
-/* check whether the given lset is empty */
-int lset_empty (lset_t *lset)
-{
- return (NULL == lset->first);
-}
-
-
-/* insert the data into the lset (unless there's an entry for it
- already) */
-void lset_insert (lset_t *lset, void *data)
-{
- if (! lset_contains (lset, data)) {
- lset_entry_t *entry = xmalloc (sizeof (lset_entry_t));
-
- entry->data = data;
- entry->next = lset->first;
- lset->first = entry;
-
- if (NULL == lset->last) {
- lset->last = entry;
- }
-
- lset->n_entries ++;
- }
-}
-
-/* insert all entries from src into tgt */
-void lset_insert_all (lset_t *tgt, lset_t *src)
-{
- lset_entry_t *curs = src->first;
-
- while (NULL != curs) {
- lset_insert (tgt, curs->data);
-
- curs = curs->next;
- }
-}
-
-/* append src to tgt. src is deallocated. */
-void lset_append (lset_t *tgt, lset_t *src)
-{
- assert (! tgt->last->next);
-
- tgt->last->next = src->first;
- tgt->last = src->last;
- tgt->n_entries += src->n_entries;
-
- memset (src, 0x00, sizeof (lset_t));
- free (src);
-}
-
-/* remove the entry for the given data element from the lset. return
- TRUE iff it was on the list in the first place, FALSE else */
-int lset_remove (lset_t *lset, void *data)
-{
- lset_entry_t *entry = lset->first;
- lset_entry_t *prev = NULL;
-
- while (NULL != entry) {
- if (data == entry->data) {
- /* ok, dike it out */
-
- if (NULL == prev) { /* ok, it's lset->first that needs diking */
- lset->first = entry->next;
- } else {
- prev->next = entry->next;
- }
-
- memset (entry, 0x00, sizeof (lset_entry_t));
- free (entry);
-
- lset->n_entries --;
-
- return (TRUE);
- }
-
- prev = entry;
- entry = entry->next;
- }
-
- return (FALSE);
-}
-
-/* prepare the given lset for an iteration. return the first element. */
-void *lset_first (lset_t *lset)
-{
- lset->curs = lset->first;
-
- if (lset->first) {
- return (lset->first->data);
- } else {
- return (NULL);
- }
-}
-
-/* after calling lset_first, get the next element, if applicable, or
- NULL */
-void *lset_next (lset_t *lset)
-{
- lset->curs = lset->curs->next;
-
- if (lset->curs) {
- return (lset->curs->data);
- } else {
- return (NULL);
- }
-}
-
-/* say how many entries there are in the given lset */
-int lset_n_entries (lset_t *lset)
-{
- return (lset->n_entries);
-}
-
-/* deallocate the lset and all of its entries */
-void lset_destroy (lset_t *lset)
-{
- lset_entry_t *curs = lset->first;
-
- while (NULL != curs) {
- lset_entry_t *tmp = curs->next;
-
- memset (curs, 0x00, sizeof (lset_entry_t));
- free (curs);
-
- curs = tmp;
- }
-
- memset (lset, 0x00, sizeof (lset_t));
- free (lset);
-}
-
-
-\f
-/*
- $Log$
- Revision 1.4 2005/01/14 13:36:10 liekweg
- fix malloc, fix "initialisation"
-
- Revision 1.3 2004/12/22 14:43:14 beck
- made allocations C-like
-
- Revision 1.2 2004/12/02 16:17:51 beck
- fixed config.h include
-
- Revision 1.1 2004/10/21 11:09:37 liekweg
- Moved memwalk stuf into irmemwalk
- Moved lset stuff into lset
- Moved typalise stuff into typalise
-
-
- */
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Lists, err, Sets
- * @author Florian
- * @date Mon 18 Oct 2004
- * @version $Id$
- */
-# ifndef FIRM_ANA2_LSET_H
-# define FIRM_ANA2_LSET_H
-
-/*
- Data Types and Structures
-*/
-/* Lists, err, Sets */
-typedef struct lset_entry
-{
- void *data;
- struct lset_entry *next;
-} lset_entry_t;
-
-typedef struct lset
-{
- lset_entry_t *first;
- lset_entry_t *last; /* useful for lset_append */
- lset_entry_t *curs; /* for lset_first/lset_next */
- int n_entries;
-} lset_t;
-
-/* create a new lset */
-lset_t *lset_create (void);
-/* check whether the lset contains an entry for the given data */
-int lset_contains (lset_t*, void*);
-/* check whether the given lset is empty */
-int lset_empty (lset_t*);
-/* insert the data into the lset (unless there's an entry for it
- already) */
-void lset_insert (lset_t*, void*);
-/* insert all entries from src into tgt */
-void lset_insert_all (lset_t*, lset_t*);
-/* append src to tgt. src is deallocated. */
-void lset_append (lset_t*, lset_t*);
-
-/* remove the entry for the given data element from the lset. return
- TRUE iff it was on the list in the first place, FALSE else */
-int lset_remove (lset_t*, void*);
-/* prepare the given lset for an iteration. return the first element. */
-void *lset_first (lset_t*);
-/* after calling lset_first, get the next element, if applicable, or
- NULL */
-void *lset_next (lset_t*);
-/* say how many entries there are in the given lset */
-int lset_n_entries (lset_t*);
-/* deallocate the lset and all of its entries */
-void lset_destroy (lset_t*);
-
-
-
-# endif
-
-\f
-/*
- $Log$
- Revision 1.1 2004/10/21 11:09:37 liekweg
- Moved memwalk stuf into irmemwalk
- Moved lset stuff into lset
- Moved typalise stuff into typalise
-
-
- */
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Entry to PTO
- * @author Florian
- * @date Tue Nov 23 18:37:09 CET 2004
- * @version $Id$
- */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-/*
- pto: Entry to PTO
-*/
-
-#ifdef HAVE_STRING_H
-# include <string.h>
-#endif
-
-# include "pto.h"
-
-# include "irnode_t.h"
-# include "irprog.h"
-# include "xmalloc.h"
-
-# include "pto_debug.h"
-# include "pto_init.h"
-# include "pto_name.h"
-# include "pto_ctx.h"
-# include "ecg.h"
-
-/* Local Defines: */
-
-/* Local Data Types: */
-
-/* Local Variables: */
-extern char *spaces;
-
-/* Local Prototypes: */
-
-/* ===================================================
- Local Implementation:
- =================================================== */
-
-/* Helper to pto_init */
-static void pto_init_graph_wrapper (graph_info_t *ginfo, void *_unused)
-{
- ir_graph *graph = ginfo->graph;
-
- pto_init_graph (graph);
-}
-
-/* ===================================================
- Exported Implementation:
- =================================================== */
-/* Initialise the module (not in pto_init.c because it's the entry to pto) */
-void pto_init (int lvl)
-{
- set_dbg_lvl (lvl);
-
- ecg_init (1);
-
- /* Initialise the name module */
- pto_name_init ();
-
- /* Initialise the init module */
- pto_init_init ();
-
- /* allocate ctx-sens names for allocs and set ... etc etc */
- pto_init_type_names ();
-
- /* initialise all graphs with the static names */
- ecg_iterate_graphs (pto_init_graph_wrapper, NULL);
-
- /* debugging only */
- spaces = xmalloc (512 * sizeof (char));
- memset (spaces, ' ', 512);
- spaces += 511;
- *spaces = '\0';
-
- /* initialise for the CTX-sensitive ecg-traversal */
- set_curr_ctx (get_main_ctx ());
-}
-
-void pto_run (void)
-{
- ir_graph *save;
- ir_graph *graph = get_irp_main_irg ();
-
- pto_reset_graph_pto (graph, 0);
- fake_main_args (graph);
-
- DBGPRINT (1, (stdout, "START PTO\n"));
- DBGPRINT (1, (stdout, "START GRAPH (0x%08x) of \"%s.%s\"\n",
- (int) graph,
- get_type_name (get_entity_owner (get_irg_entity (graph))),
- get_entity_name (get_irg_entity (graph))));
-
- /* we need some kind of environment here: NULL */
- save = get_current_ir_graph ();
- pto_graph (graph, 0, NULL);
- set_current_ir_graph (save);
-
- DBGPRINT (1, (stdout, "END PTO\n"));
-}
-
-/* Dump all interesting stuff to a bunch of files */
-void pto_dump (void)
-{
- pto_dump_names ("names.dot");
-}
-
-void pto_cleanup (void)
-{
- /* todo: clean up our own mess */
- spaces -= 511; /* hope that all changes to spaces are
- properly nested */
- memset (spaces, 0x00, 512);
- free (spaces);
-
- /* Cleanup the name module */
- pto_name_cleanup ();
- /* Cleanup the Init module */
- pto_init_cleanup ();
-
- /* clean up ecg infos */
- ecg_cleanup ();
-}
-
-\f
-/*
- $Log$
- Revision 1.17 2005/01/10 17:26:34 liekweg
- fixup printfs, don't put environments on the stack
-
- Revision 1.16 2004/12/22 14:43:14 beck
- made allocations C-like
-
- Revision 1.15 2004/12/21 14:26:53 beck
- removed C99 constructs
-
- Revision 1.14 2004/12/20 17:41:14 liekweg
- __unused -> _unused
-
- Revision 1.13 2004/12/20 17:34:34 liekweg
- fix recursion handling
-
- Revision 1.12 2004/12/02 16:17:51 beck
- fixed config.h include
-
- Revision 1.11 2004/11/30 15:49:27 liekweg
- include 'dump'
-
- Revision 1.10 2004/11/30 14:46:41 liekweg
- Correctly reset main graph; remove dbugging stuff
-
- Revision 1.9 2004/11/26 16:01:56 liekweg
- debugging annotations
-
- Revision 1.8 2004/11/24 14:54:21 liekweg
- Added pto.c as main entry point
-
-
-*/
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Import all includes needed for PTO/Entry to PTO
- * @author Florian
- * @date Sat Nov 13 19:35:27 CET 2004
- * @version $Id$
- */
-# ifndef FIRM_ANA2_PTO_H
-# define FIRM_ANA2_PTO_H
-
-# include "pto_comp.h"
-
-/* ===================================================
- Global Defines:
- =================================================== */
-# define N_INITIAL_OJBS 10
-
-/* ===================================================
- Global Data Types:
- =================================================== */
-
-/* ===================================================
- Global Prototypes:
- =================================================== */
-/* Perform PTO on all visible graphs. */
-void pto_init (int);
-void pto_run (void);
-/* Dump all interesting stuff to a bunch of files */
-void pto_dump (void);
-/* Clean up our mess */
-void pto_cleanup (void);
-
-/* ===================================================
- Global Variables:
- =================================================== */
-
-
-# endif
-
-
-\f
-/*
- $Log$
- Revision 1.7 2004/11/30 15:49:27 liekweg
- include 'dump'
-
- Revision 1.6 2004/11/24 14:53:55 liekweg
- Bugfixes
-
- Revision 1.5 2004/11/18 16:37:07 liekweg
- rewrite
-
-
-*/
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Main Implementation of PTO
- * @author Florian
- * @date Sat Nov 13 19:35:27 CET 2004
- * @version $Id$
- */
-# ifdef HAVE_CONFIG_H
-# include "config.h"
-# endif
-
-/*
- pto_comp: Main Implementation of PTO
-*/
-
-# include <string.h> /* for memset */
-
-# include "pto_comp.h"
-# include "pto_util.h"
-# include "pto_name.h"
-# include "pto_ctx.h"
-# include "pto_mod.h"
-
-# include "irnode_t.h"
-# include "irprog_t.h"
-# include "xmalloc.h"
-# include "irmemwalk.h"
-
-# include "pto_debug.h"
-# include "pto_init.h"
-
-# include "ecg.h"
-
-# include "gnu_ext.h"
-
-/* Local Defines: */
-
-/* Local Data Types: */
-typedef struct pto_env_str {
- struct pto_env_str *enc_env;
- ir_graph *graph;
- int ctx_idx;
- int change;
-} pto_env_t;
-
-
-/* Local Variables: */
-
-/* Debug only: */
-char *spaces = NULL;
-
-/* Local Prototypes: */
-static pto_t *get_pto (ir_node*, pto_env_t*);
-static void pto_call (ir_graph*, ir_node*, pto_env_t*);
-static void pto_raise (ir_node*, pto_env_t*);
-static void pto_load (ir_node*, pto_env_t*);
-static void pto_store (ir_node*, pto_env_t*);
-static void pto_method (ir_node*, pto_env_t*);
-static void pto_end_block (ir_node*, pto_env_t*);
-
-/* ===================================================
- Local Implementation:
- =================================================== */
-/* Add values of the actual arguments to the formal arguments */
-static int add_graph_args (ir_graph *graph, ir_node *call, pto_env_t *env)
-{
- int change = FALSE;
- ir_type *meth = get_entity_type (get_irg_entity (graph));
- ir_node **args = get_irg_proj_args (graph);
- int i, n_args;
-
- assert(op_Call == get_irn_op(call));
-
- n_args = get_Call_n_params (call);
-
- DBGPRINT (1, (stdout, "%s: args of %s[%li] -> 0x%08x\n",
- __FUNCTION__,
- OPNAME (call), OPNUM (call), (int) graph));
-
- for (i = 0; i < n_args; i ++) {
- if (NULL != args [i]) {
- if (mode_P == get_type_mode (get_method_param_type (meth, i))) {
- ir_node *call_arg = get_Call_param (call, i);
- pto_t *arg_pto = get_pto (call_arg, env);
- pto_t *frm_pto = get_node_pto (args [i]);
-
- assert (arg_pto);
- assert (frm_pto);
-
- change |= qset_insert_all (frm_pto->values, arg_pto->values);
-
- DBGPRINT (2, (stdout, "%s: arg [%i]: -> %s[%li] (%i) -> %s[%li] (%i)\n",
- __FUNCTION__,
- i,
- OPNAME (call_arg), OPNUM (call_arg),
- arg_pto->values->id,
- OPNAME (args [i]), OPNUM (args [i]),
- frm_pto->values->id));
- }
- }
- }
-
- return (change);
-}
-
-/* Transfer the actual arguments to the formal arguments */
-static void set_graph_args (ir_graph *graph, ir_node *call, pto_env_t *env)
-{
- ir_type *meth = get_entity_type (get_irg_entity (graph));
- ir_node **args = get_irg_proj_args (graph);
- int i, n_args;
-
- assert (op_Call == get_irn_op(call));
-
- n_args = get_Call_n_params (call);
-
- for (i = 0; i < n_args; i ++) {
- if (NULL != args [i]) {
- if (mode_P == get_type_mode (get_method_param_type (meth, i))) {
- ir_node *call_arg = get_Call_param (call, i);
- pto_t *pto = get_pto (call_arg, env);
- assert (pto);
- set_node_pto (args [i], pto);
-
- DBGPRINT (1, (stdout, "%s: arg [%i]: %s[%li] -> %s[%li] (%i)\n",
- __FUNCTION__,
- i,
- OPNAME (call_arg), OPNUM (call_arg),
- OPNAME (args [i]), OPNUM (args [i]),
- pto->values->id));
- }
- }
- }
-}
-
-/* Transfer the graph's result to the call */
-static int set_graph_result (ir_graph *graph, ir_node *call)
-{
- ir_type *tp = get_entity_type (get_irg_entity (graph));
- ir_node *end_block;
- pto_t *ret_pto, *call_pto;
- int change;
-
- if (0 == get_method_n_ress (tp)) {
- return (FALSE);
- }
-
- tp = get_method_res_type (tp, 0);
-
- if (mode_P != get_type_mode (tp)) {
- set_node_pto (call, NULL);
-
- return (FALSE);
- }
-
- end_block = get_irg_end_block (graph);
- ret_pto = get_node_pto (end_block);
-
- call_pto = get_node_pto (call);
-
- assert (call_pto);
-
- DBGPRINT (1, (stdout, "%s: before change args\n", __FUNCTION__));
- DBGEXE (1, pto_print_pto (end_block));
- DBGEXE (1, pto_print_pto (call));
-
- change = qset_insert_all (call_pto->values, ret_pto->values);
-
- if (change) {
- DBGPRINT (1, (stdout, "%s: after change args\n", __FUNCTION__));
- DBGEXE (1, pto_print_pto (end_block));
- DBGEXE (1, pto_print_pto (call));
- /* assert (0); */
- }
-
- return (change);
-}
-
-/* Propagation of PTO values */
-static pto_t *get_pto_proj (ir_node *proj, pto_env_t *env)
-{
- ir_node *proj_in = get_Proj_pred (proj);
- const ir_opcode in_op = get_irn_opcode (proj_in);
- pto_t *in_pto = NULL;
- pto_t *proj_pto = NULL; /* get_node_pto (proj); */
-
- ir_node *proj_in_in = NULL;
-
- switch (in_op) {
- case (iro_Start): /* ProjT (Start) */
- assert (0 && "pto from ProjT(Start) requested");
-
- return (NULL);
- case (iro_Proj): { /* ProjT (Start), ProjT (Call) */
- ir_opcode in_in_op;
- long proj_in_proj;
-
- proj_in_in = get_Proj_pred (proj_in);
- in_in_op = get_irn_opcode (proj_in_in);
- proj_in_proj = get_Proj_proj (proj_in);
-
- assert ((pn_Start_T_args == proj_in_proj) ||
- (pn_Call_T_result == proj_in_proj));
-
- switch (in_in_op) {
- case (iro_Start): /* ProjArg (ProjT (Start)) */
- /* then the pto value must have been set to the node */
- proj_pto = get_node_pto (proj);
- assert (proj_pto);
-
- return (proj_pto);
- case (iro_Call): /* ProjV (ProjT (Call)) */
- if (NULL != proj_pto) {
- return (proj_pto);
- } else {
- in_pto = get_pto (proj_in, env);
- set_node_pto (proj, in_pto);
-
- assert (in_pto);
-
- return (in_pto);
- }
- default: assert (0 && "Proj(Proj(?))");
- }
- /* done with case (in_op == iro_Proj) */
- }
-
- case (iro_Load): /* ProjV (Load) */
- assert (pn_Load_res == get_Proj_proj(proj));
- /* FALLTHROUGH */
- case (iro_Call): /* ProjT (Call) */
- /* FALLTHROUGH */
- case (iro_Alloc): /* ProjV (Alloc) */
- if (NULL != proj_pto) {
- return (proj_pto);
- } else {
- in_pto = get_pto (proj_in, env);
- assert (in_pto);
-
- set_node_pto (proj, in_pto);
- return (in_pto);
- }
- default:
- fprintf (stderr, "get_pto_proj(/*todo*/): not handled: proj (%s[%li])\n",
- get_op_name (get_irn_op (proj_in)),
- get_irn_node_nr (proj_in));
- assert (0 && "Proj(?)");
- return NULL;
- }
-
-}
-
-static pto_t *get_pto_phi (ir_node *phi, pto_env_t *env)
-{
- pto_t *pto;
- int change = FALSE;
- int i, n_ins;
-
- assert (mode_P == get_irn_mode (phi));
-
- pto = get_node_pto (phi);
- assert (pto); /* must be initialised */
-
- n_ins = get_irn_arity (phi);
- for (i = 0; i < n_ins; i ++) {
- ir_node *in = get_irn_n (phi, i);
- pto_t *in_pto = get_pto (in, env);
-
- assert (in_pto);
-
- change |= qset_insert_all (pto->values, in_pto->values);
- }
-
- env->change |= change;
-
- return (pto);
-}
-
-static pto_t *get_pto_sel (ir_node *sel, pto_env_t *env)
-{
- pto_t *pto = NULL; /* get_node_pto (sel); */
-
- if (NULL == pto) {
- ir_node *in = get_Sel_ptr (sel);
-
- pto = get_pto (in, env);
- set_node_pto (sel, pto);
- }
-
- return (pto);
-}
-
-static pto_t *get_pto_ret (ir_node *ret, pto_env_t *env)
-{
- pto_t *pto = NULL; /* get_node_pto (ret); */
-
- if (NULL == pto) {
- ir_node *in = get_Return_res (ret, 0);
-
- pto = get_pto (in, env);
- set_node_pto (ret, pto);
- }
-
- assert (pto);
-
- DBGPRINT (9, (stdout, "%s: ", __FUNCTION__));
- DBGEXE (9, pto_print_pto (ret));
-
- return (pto);
-}
-
-
-/* Dispatch to propagate PTO values */
-static pto_t *get_pto (ir_node *node, pto_env_t *env)
-{
- const ir_opcode op = get_irn_opcode (node);
-
- DBGPRINT (2, (stdout, "%s (%s[%li])\n",
- __FUNCTION__,
- OPNAME (node), OPNUM (node)));
-
- switch (op) {
- case (iro_Cast): return (get_pto (get_Cast_op (node), env));
- case (iro_Proj): return (get_pto_proj (node, env));
- case (iro_Phi): return (get_pto_phi (node, env));
- case (iro_Sel): return (get_pto_sel (node, env));
- case (iro_Alloc): return (get_alloc_pto (node));
- case (iro_Return): return (get_pto_ret (node, env));
-
- case (iro_Call): /* FALLTHROUGH */
- case (iro_Load): /* FALLTHROUGH */
- case (iro_Const): /* FALLTHROUGH */
- case (iro_SymConst):{
- pto_t *pto = get_node_pto (node);
-
- assert (pto);
- return (pto);
- }
- default:
- /* stopgap measure */
- fprintf (stderr, "%s: not handled: node[%li].op = %s\n",
- __FUNCTION__,
- get_irn_node_nr (node),
- get_op_name (get_irn_op (node)));
- assert (0 && "something not handled");
- return NULL;
- }
-}
-
-
-/* Actions for the nodes: */
-static void pto_load (ir_node *load, pto_env_t *pto_env)
-{
- ir_node *ptr;
- ir_entity *ent;
-
- /* perform load */
- DBGPRINT (2, (stdout, "%s (%s[%li]): pto = 0x%08x\n",
- __FUNCTION__,
- OPNAME (load), OPNUM (load), (int) get_node_pto (load)));
-
- ptr = get_Load_ptr (load);
-
- if (is_dummy_load_ptr (ptr)) {
- return;
- }
-
- ent = get_ptr_ent (ptr);
-
- if (mode_P == get_type_mode (get_entity_type (ent))) {
- pto_t *ptr_pto = get_pto (ptr, pto_env);
-
- assert (ptr_pto);
-
- DBGPRINT (1, (stdout, "%s (%s[%li]): ptr = 0x%08x\n",
- __FUNCTION__,
- OPNAME (ptr), OPNUM (ptr), (int) ptr_pto));
-
- pto_env->change |= mod_load (load, ent, ptr_pto);
- }
-}
-
-static void pto_store (ir_node *store, pto_env_t *pto_env)
-{
- ir_node *ptr, *val;
- ir_entity *ent;
- pto_t *ptr_pto, *val_pto;
-
- /* perform store */
- DBGPRINT (2, (stdout, "%s (%s[%li]) (no pto)\n",
- __FUNCTION__,
- OPNAME (store), OPNUM (store)));
-
- ptr = get_Store_ptr (store);
- val = get_Store_value (store);
-
- if (mode_P != get_irn_mode (val)) {
- return;
- }
-
- ent = get_ptr_ent (ptr);
-
- ptr_pto = get_pto (ptr, pto_env);
- val_pto = get_pto (val, pto_env);
-
- assert (ptr_pto);
- assert (val_pto);
-
- DBGPRINT (2, (stdout, "%s (%s[%li]): ptr_pto = 0x%08x\n",
- __FUNCTION__,
- OPNAME (ptr), OPNUM (ptr), (int) ptr_pto));
- DBGPRINT (2, (stdout, "%s (%s[%li]): val_pto = 0x%08x\n",
- __FUNCTION__,
- OPNAME (val), OPNUM (val), (int) val_pto));
-
- pto_env->change |= mod_store (store, ent, ptr_pto, val_pto);
-}
-
-static void pto_method (ir_node *call, pto_env_t *pto_env)
-{
- int i;
- callEd_info_t *callEd_info;
-
- DBGPRINT (2, (stdout, "%s:%i (%s[%li]): pto = 0x%08x\n",
- __FUNCTION__, __LINE__, OPNAME (call), OPNUM (call),
- (int) get_node_pto (call)));
-
- callEd_info = ecg_get_callEd_info (call);
-
- if (NULL == callEd_info) {
- DBGPRINT (2, (stdout, "%s:%i (%s[%li]), no graph\n",
- __FUNCTION__, __LINE__, OPNAME (call), OPNUM (call)));
- }
-
- i = 0;
- while (NULL != callEd_info) {
- DBGPRINT (2, (stdout, "%s:%i (%s[%li]), graph %i\n",
- __FUNCTION__, __LINE__, OPNAME (call), OPNUM (call), i ++));
-
- pto_call (callEd_info->callEd, call, pto_env);
-
- callEd_info = callEd_info->prev;
- }
-}
-
-/* Perform the appropriate action on the given node */
-static void pto_node_node(ir_node *node, pto_env_t *pto_env)
-{
- ir_opcode op = get_irn_opcode (node);
-
- DBGPRINT (1, (stdout, "%s (%s[%li])\n",
- __FUNCTION__, OPNAME (node), OPNUM (node)));
-
- switch (op) {
- case (iro_Start): /* nothing */ break;
- case (iro_Load):
- pto_load (node, pto_env);
- break;
-
- case (iro_Store):
- pto_store (node, pto_env);
- break;
-
- case (iro_Call):
- pto_method (node, pto_env);
- break;
-
- case (iro_Raise):
- pto_raise (node, pto_env);
- break;
-
- case (iro_Return):
- /* nothing to do */
- break;
-
- case (iro_Alloc):
- /* nothing to do */
- break;
-
- case (iro_Block):
- pto_end_block (node, pto_env);
- break;
-
- case (iro_Phi):
- /* must be a PhiM */
- assert (mode_M == get_irn_mode (node));
- /* nothing to do */
- break;
-
- /* uninteresting stuff: */
- case (iro_Div):
- case (iro_Quot):
- case (iro_Mod):
- case (iro_DivMod): /* nothing to do */ break;
-
- default:
- /* stopgap measure */
- fprintf (stderr, "%s: not handled: node[%li].op = %s\n",
- __FUNCTION__,
- get_irn_node_nr (node),
- get_op_name (get_irn_op (node)));
- assert (0 && "something not handled");
- }
-}
-
-
-/* Callback function to execute in pre-order */
-static void pto_node_pre (ir_node *node, void *env)
-{
- /* nothing */
-}
-
-/* Callback function to execute in post-order */
-static void pto_node_post (ir_node *node, void *env)
-{
- pto_env_t *pto_env = (pto_env_t*) env;
-
- DBGPRINT (999, (stdout, "%s (%s[%li])\n",
- __FUNCTION__,
- OPNAME (node), OPNUM (node)));
-
- pto_node_node (node, pto_env);
-}
-
-/* Perform a single pass over the given graph */
-static void pto_graph_pass (ir_graph *graph, void *pto_env)
-{
- irg_walk_mem (graph, pto_node_pre, pto_node_post, pto_env);
-}
-
-/* Continue PTO for one of the graphs called at a Call */
-static void pto_call (ir_graph *graph, ir_node *call, pto_env_t *pto_env)
-{
- int change = FALSE;
-
- /* only for debugging stuff: */
- ir_entity *ent = get_irg_entity (graph);
- const char *ent_name = (char*) get_entity_name (ent);
- const char *own_name = (char*) get_type_name (get_entity_owner (ent));
-
- /* perform call */
- DBGPRINT (2, (stdout, "%s (%s[%li]) to \"%s.%s\"\n",
- __FUNCTION__,
- OPNAME (call), OPNUM (call),
- own_name, ent_name));
-
- if (! get_irg_is_mem_visited (graph)) {
- /* handle direct call */
- graph_info_t *ginfo = ecg_get_info (graph);
-
- /* Save CTX */
- int ctx_idx = find_ctx_idx (call, ginfo, get_curr_ctx ());
- ctx_info_t *call_ctx = get_ctx (ginfo, ctx_idx);
- ctx_info_t *old_ctx = set_curr_ctx (call_ctx);
-
- DBGPRINT (1, (stdout, "%s>CTX: ", -- spaces));
- DBGEXE (1, ecg_print_ctx (call_ctx, stdout));
-
- /* Initialise Alloc Names and Node values */
- pto_reset_graph_pto (graph, ctx_idx);
-
- /* Compute Arguments */
- set_graph_args (graph, call, pto_env);
-
- /* Visit/Iterate Graph */
- pto_graph (graph, ctx_idx, pto_env);
-
- /* Restore CTX */
- set_curr_ctx (old_ctx);
-
- /* Get Return Value from Graph */
- change |= set_graph_result (graph, call);
-
- DBGPRINT (1, (stdout, "%s<CTX: ", spaces ++));
- DBGEXE (1, ecg_print_ctx (call_ctx, stdout));
-
- /* Don't need to reset alloc names unless we handle recursion here */
- } else {
- pto_env_t *enc_env;
- int rec_change;
-
- /* handle recursion */
- DBGPRINT (0, (stdout, "%s: recursion into \"%s.%s\"\n",
- __FUNCTION__,
- own_name, ent_name));
- /* Find 'right' enclosing pto_env */
- enc_env = pto_env;
- while (graph != enc_env->graph) {
- enc_env = enc_env->enc_env; /* talk about naming issues here */
-
- /* since we're in a recursion loop, we *must* find an env for the callEd here: */
- assert (NULL != enc_env->enc_env);
- }
-
- /* Re-Set arguments */
- rec_change = add_graph_args (graph, call, pto_env);
-
- DBGPRINT (1, (stdout, "%s: return in:", __FUNCTION__));
- DBGEXE (1, pto_print_pto (get_irg_end_block (graph)));
-
- if (rec_change) {
- DBGPRINT (0, (stdout, "%s: change args\n", __FUNCTION__));
- }
-
- rec_change |= set_graph_result (graph, call);
-
- if (rec_change) {
- DBGPRINT (1, (stdout, "%s: return out:", __FUNCTION__));
- DBGEXE (1, pto_print_pto (get_irg_end_block (graph)));
- }
-
-# if 0
- /* appears that we don't need this: */
- enc_env->change |= rec_change;
-# endif /* 0 */
- }
-
- /* Todo: Set 'Unknown' Value as Return Value when the graph is not
- known */
-
- pto_env->change |= change;
-}
-
-static void pto_raise (ir_node *raise, pto_env_t *pto_env)
-{
- /* perform raise */
- DBGPRINT (2, (stdout, "%s (%s[%li]): pto = 0x%08x\n",
- __FUNCTION__,
- OPNAME (raise), OPNUM (raise), (int) get_node_pto (raise)));
-}
-
-static void pto_end_block (ir_node *end_block, pto_env_t *pto_env)
-{
- /* perform end block */
- ir_type *tp = get_entity_type (get_irg_entity (get_irn_irg (end_block)));
- pto_t *end_pto;
- int i, n_ins;
-
- if (0 == get_method_n_ress (tp)) {
- return;
- }
-
- tp = get_method_res_type (tp, 0);
-
- if (! mode_is_reference(get_type_mode (tp))) {
- return;
- }
-
- DBGPRINT (2, (stdout, "%s (%s[%li]): pto = 0x%08x\n",
- __FUNCTION__,
- OPNAME (end_block), OPNUM (end_block),
- (int) get_node_pto (end_block)));
-
- end_pto = get_node_pto (end_block);
-
- assert (end_pto);
-
- n_ins = get_irn_arity (end_block);
- for (i = 0; i < n_ins; i ++) {
- ir_node *in = get_irn_n (end_block, i);
-
- if (iro_Return == get_irn_opcode (in)) {
- pto_t *in_pto = get_pto (in, pto_env);
-
- pto_env->change |= qset_insert_all (end_pto->values, in_pto->values);
- }
- }
-}
-
-/* ===================================================
- Exported Implementation:
- =================================================== */
-/* Main loop: Initialise and iterate over the given graph */
-void pto_graph (ir_graph *graph, int ctx_idx, pto_env_t *enc_env)
-{
- int run;
- pto_env_t *pto_env;
-
- /* Also exported, since we need it in 'pto.c' */
- pto_env = xmalloc (sizeof (pto_env_t));
- pto_env->enc_env = enc_env;
- pto_env->graph = graph;
- pto_env->ctx_idx = ctx_idx;
- pto_env->change = TRUE;
-
- /* HERE ("start"); */
-
- DBGPRINT (2, (stdout, "%s: start for ctx %i\n",
- __FUNCTION__,
- ctx_idx));
-
- /* todo (here): iterate, obey 'changed' attribute */
- run = 0;
- while (0 != pto_env->change) {
- run ++;
- pto_env->change = FALSE;
- pto_graph_pass (graph, pto_env);
- }
-
- DBGPRINT (1, (stdout, "%s: %i runs on \"%s.%s\"\n",
- __FUNCTION__,
- run,
- get_type_name (get_entity_owner (get_irg_entity (graph))),
- get_entity_name (get_irg_entity (graph))));
- memset (pto_env, 0, sizeof (pto_env_t));
- free (pto_env);
- /* HERE ("end"); */
-}
-
-/* Set the PTO value for the given non-alloc node */
-void set_node_pto (ir_node *node, pto_t *pto)
-{
- assert (op_Alloc != get_irn_op(node));
-
- set_irn_link (node, (void*) pto);
-}
-
-/*Get the PTO value for the given non-alloc node */
-pto_t *get_node_pto (ir_node *node)
-{
- assert (op_Alloc != get_irn_op(node));
-
- return ((pto_t*) get_irn_link (node));
-}
-
-/* Set the PTO value for the given alloc node */
-void set_alloc_pto (ir_node *alloc, alloc_pto_t *alloc_pto)
-{
- assert (op_Alloc == get_irn_op(alloc));
-
- assert (alloc_pto);
-
- set_irn_link (alloc, (void*) alloc_pto);
-}
-
-/*Get the current PTO value for the given alloc node */
-pto_t *get_alloc_pto (ir_node *alloc)
-{
- alloc_pto_t *alloc_pto = get_irn_link (alloc);
-
- assert (op_Alloc == get_irn_op(alloc));
-
- assert (alloc_pto -> curr_pto);
-
- return (alloc_pto -> curr_pto);
-}
-
-\f
-/*
- $Log$
- Revision 1.21 2007/03/22 10:39:33 matze
- a bunch of fixes to make firm work with NDEBUG and without DEBUG_libfirm
-
- Revision 1.20 2007/01/16 15:45:42 beck
- renamed type opcode to ir_opcode
-
- Revision 1.19 2006/12/13 19:46:47 beck
- rename type entity into ir_entity
-
- Revision 1.18 2006/01/13 22:57:41 beck
- renamed all types 'type' to 'ir_type'
- used mode_is_reference instead of != mode_P test
-
- Revision 1.17 2005/02/25 16:48:21 liekweg
- fix typo
-
- Revision 1.16 2005/01/27 15:51:19 liekweg
- whitespace change
-
- Revision 1.15 2005/01/14 14:14:26 liekweg
- fix gnu extension, fix fprintf's
-
- Revision 1.14 2005/01/14 13:37:26 liekweg
- fix allocation (size); don't cast malloc
-
- Revision 1.13 2005/01/10 17:26:34 liekweg
- fixup printfs, don't put environments on the stack
-
- Revision 1.12 2004/12/23 15:46:19 beck
- removed unneeded allocations
-
- Revision 1.11 2004/12/21 14:50:59 beck
- removed C)) and GNUC constructs, add default returns
-
- Revision 1.10 2004/12/20 17:34:35 liekweg
- fix recursion handling
-
- Revision 1.9 2004/12/15 13:31:18 liekweg
- remove debugging stuff
-
- Revision 1.8 2004/12/15 09:18:18 liekweg
- pto_name.c
-
- Revision 1.7 2004/12/06 12:55:06 liekweg
- actually iterate
-
- Revision 1.6 2004/12/02 16:17:51 beck
- fixed config.h include
-
- Revision 1.5 2004/11/30 14:47:54 liekweg
- fix initialisation; do correct iteration
-
- Revision 1.4 2004/11/26 15:59:40 liekweg
- verify pto_{load,store}
-
- Revision 1.3 2004/11/24 14:53:55 liekweg
- Bugfixes
-
- Revision 1.2 2004/11/20 21:21:56 liekweg
- Finalise initialisation
-
- Revision 1.1 2004/11/18 16:37:34 liekweg
- rewritten
-
-
-*/
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Main Implementation of PTO
- * @author Florian
- * @date Sat Nov 13 19:35:27 CET 2004
- * @version $Id$
- */
-# ifndef FIRM_ANA2_PTO_COMP_H
-# define FIRM_ANA2_PTO_COMP_H
-
-# include "pto.h"
-# include "irnode.h"
-# include "qset.h"
-
-/* ===================================================
- Global Defines:
- =================================================== */
-
-/* ===================================================
- Global Data Types:
- =================================================== */
-typedef struct pto_str {
- qset_t *values;
-} pto_t;
-
-typedef struct alloc_pto_str {
- int dummy;
- pto_t **ptos; /* all names */
- pto_t *curr_pto; /* name for current ctx */
-} alloc_pto_t;
-
-struct pto_env_str; /* forward decl only */
-
-/* ===================================================
- Global Prototypes:
- =================================================== */
-/* Main loop: Initialise the graph for the given ctx_idx and iterate over it */
-void pto_graph (ir_graph*, int, struct pto_env_str*);
-
-/* Set the PTO value for the given node */
-void set_node_pto (ir_node*, pto_t*);
-/*Get the PTO value for the given non-alloc node */
-pto_t *get_node_pto (ir_node*);
-
-/* Set the PTO value for the given alloc node */
-void set_alloc_pto (ir_node*, alloc_pto_t*);
-
-/*Get the current PTO value for the given alloc node */
-pto_t *get_alloc_pto (ir_node*);
-
-
-/* ===================================================
- Global Variables:
- =================================================== */
-
-
-# endif
-
-
-\f
-/*
- $Log$
- Revision 1.3 2004/12/20 17:34:35 liekweg
- fix recursion handling
-
- Revision 1.2 2004/11/24 14:53:55 liekweg
- Bugfixes
-
- Revision 1.1 2004/11/18 16:37:34 liekweg
- rewritten
-
-
-*/
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Manage context-sensitivity markers
- * @author Florian
- * @date Sat Nov 13 19:35:27 CET 2004
- * @version $Id$
- */
-# ifdef HAVE_CONFIG_H
-# include "config.h"
-# endif
-
-#include <assert.h>
-
-/*
- pto_ctx: Manage context-sensitivity markers
-*/
-
-# include "pto_ctx.h"
-# include "pto_debug.h"
-# include "pto_comp.h"
-# include "ecg.h"
-
-# include "irnode.h"
-/* # include "xmalloc.h" */
-
-/* Local Defines: */
-
-/* Local Data Types: */
-
-/* Local Variables: */
-static ctx_info_t *curr_ctx = NULL;
-
-/* Local Prototypes: */
-
-/* ===================================================
- Local Implementation:
- =================================================== */
-
-
-/* ===================================================
- Exported Implementation:
- =================================================== */
-/* Find the appropriate ctx for the given call and the given graph */
-/* ctx_info_t *find_ctx (ir_node *call, graph_info_t *ginfo, ctx_info_t *curr_ctx) */
-int find_ctx_idx (ir_node *call, graph_info_t *ginfo, ctx_info_t *curr_ctx)
-{
- int i;
- const int n_ctxs = ginfo->n_ctxs;
-
- for (i = 0; i < n_ctxs; i ++) {
- ctx_info_t *ctx = ginfo->ctxs [i];
-
- if ((ctx->enc == curr_ctx) && (ctx->call == call)) {
- return (i);
- }
- }
-
- fflush (stdout);
- assert (0 && "CTX not found");
-
- return (-1);
-}
-
-/* Get the current ctx */
-ctx_info_t *get_curr_ctx (void)
-{
- return (curr_ctx);
-}
-
-/* Set the current ctx to the given ctx. Return the old value */
-ctx_info_t *set_curr_ctx (ctx_info_t *ctx)
-{
- ctx_info_t *old_ctx = curr_ctx;
-
- curr_ctx = ctx;
-
- return (old_ctx);
-}
-
-\f
-/*
- $Log$
- Revision 1.6 2005/12/05 12:19:54 beck
- added missing include <assert.h> (not anymore included in libFirm)
-
- Revision 1.5 2005/01/14 13:37:55 liekweg
- Insert purpose descr
-
- Revision 1.4 2004/12/02 16:17:51 beck
- fixed config.h include
-
- Revision 1.3 2004/11/24 14:53:55 liekweg
- Bugfixes
-
- Revision 1.2 2004/11/20 21:21:35 liekweg
- Add pto_ctx_allocs
-
- Revision 1.1 2004/11/18 16:37:34 liekweg
- rewritten
-
-
-*/
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Manage context-sensitivity markers
- * @author Florian
- * @date Sat Nov 13 19:35:27 CET 2004
- * @version $Id$
- */
-# ifndef FIRM_ANA2_PTO_CTX_H
-# define FIRM_ANA2_PTO_CTX_H
-
-# include "ecg.h"
-
-/* ===================================================
- Global Defines:
- =================================================== */
-
-/* ===================================================
- Global Data Types:
- =================================================== */
-
-/* ===================================================
- Global Prototypes:
- =================================================== */
-/* Find the appropriate ctx for the given call and the given graph */
-/* ctx_info_t *find_ctx (ir_node*, graph_info_t*, ctx_info_t*); */
-int find_ctx_idx (ir_node*, graph_info_t*, ctx_info_t*);
-
-/* Get the current ctx */
-ctx_info_t *get_curr_ctx (void);
-
-/* Set the current ctx to the given ctx. Return the old value */
-ctx_info_t *set_curr_ctx (ctx_info_t*);
-
-/* Set all alloc names to the right ptos */
-void pto_ctx_allocs (graph_info_t*, int);
-
-/* ===================================================
- Global Variables:
- =================================================== */
-
-
-# endif
-
-
-\f
-/*
- $Log$
- Revision 1.3 2005/01/14 13:37:55 liekweg
- Insert purpose descr
-
- Revision 1.2 2004/11/20 21:21:35 liekweg
- Add pto_ctx_allocs
-
- Revision 1.1 2004/11/18 16:37:34 liekweg
- rewritten
-
-
-*/
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Useful Macros for Debugging
- * @author Florian
- * @date Sat Nov 13 19:30:21 CET 2004
- * @version $Id$
- */
-# ifdef HAVE_CONFIG_H
-# include "config.h"
-# endif
-
-/*
- pto_debug: Useful Macros for Debugging
-*/
-
-# include "pto_debug.h"
-# include "pto_comp.h"
-# include "gnu_ext.h"
-# include "qset.h"
-
-/* # include "xmalloc.h" */
-
-/* Local Defines: */
-
-/* Local Data Types: */
-
-/* Local Variables: */
-static int dbg_lvl = 0;
-
-/* Local Prototypes: */
-
-/* ===================================================
- Local Implementation:
- =================================================== */
-
-
-/* ===================================================
- Exported Implementation:
- =================================================== */
-int get_dbg_lvl ()
-{
- return (dbg_lvl);
-}
-
-void set_dbg_lvl (int lvl)
-{
- /* fprintf (stdout, "%s:%s (): dbg_lvl: %i -> %i\n", */
-/* __FILE__, __FUNCTION__, dbg_lvl, lvl); */
- dbg_lvl = lvl;
-}
-
-void pto_print_pto (ir_node *node)
-{
- pto_t *pto = get_node_pto (node);
-
- fprintf (stdout, "pto (%s[%li]) = ", OPNAME (node), OPNUM (node));
- if (NULL != pto) {
- qset_print (pto->values, stdout);
- } else {
- fprintf (stdout, "NULL");
- }
-}
-
-
-\f
-/*
- $Log$
- Revision 1.5 2005/02/25 16:47:51 liekweg
- fix GNU stuff
-
- Revision 1.4 2004/12/20 17:34:35 liekweg
- fix recursion handling
-
- Revision 1.3 2004/12/02 16:17:51 beck
- fixed config.h include
-
- Revision 1.2 2004/11/24 14:53:56 liekweg
- Bugfixes
-
- Revision 1.1 2004/11/18 16:37:34 liekweg
- rewritten
-
-
-*/
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Useful Macros for Debugging
- * @author Florian
- * @date Sat Nov 13 19:30:21 CET 2004
- * @version $Id$
- */
-# ifndef FIRM_ANA2_PTO_DEBUG_H
-# define FIRM_ANA2_PTO_DEBUG_H
-
-# include "irnode.h"
-
-/* ===================================================
- Global Defines:
- =================================================== */
-# define DBGPRINT(lvl, args) if (get_dbg_lvl () > lvl) { fprintf args; }
-# define DBGEXE(lvl, cmd) if (get_dbg_lvl () > lvl) {cmd;}
-# define OPNAME(node) get_irn_opname(node)
-# define OPNUM(node) get_irn_node_nr(node)
-# define HERE(msg) fprintf (stdout, "%s:%i %s\n", __FUNCTION__, __LINE__, msg)
-# define HERE2(msg1, msg2) fprintf (stdout, "%s:%i: %s %s\n", __FUNCTION__, __LINE__, msg1, msg2)
-# define HERE3(msg1, msg2, msg3) fprintf (stdout, "%s:%i: %s %s %s\n", __FUNCTION__, __LINE__, msg1, msg2, msg3)
-
-/* ===================================================
- Global Data Types:
- =================================================== */
-
-/* ===================================================
- Global Prototypes:
- =================================================== */
-int get_dbg_lvl (void);
-void set_dbg_lvl (int);
-
-void pto_print_pto (ir_node*);
-
-/* ===================================================
- Global Variables:
- =================================================== */
-
-# endif
-
-
-\f
-/*
- $Log$
- Revision 1.5 2005/01/14 13:33:10 liekweg
- Use only public irnode interface
-
- Revision 1.4 2004/12/21 15:51:07 beck
- simplifyed
-
- Revision 1.3 2004/12/20 17:34:35 liekweg
- fix recursion handling
-
- Revision 1.2 2004/11/24 14:53:56 liekweg
- Bugfixes
-
- Revision 1.1 2004/11/18 16:37:34 liekweg
- rewritten
-
-
-*/
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Initialisation Functions
- * @author Florian
- * @date Sat Nov 13 19:35:27 CET 2004
- * @version $Id$
- */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-/*
- pto_init: Initialisation Functions
-*/
-
-# include <assert.h>
-#ifdef HAVE_STRING_H
-# include <string.h>
-#endif
-#ifdef HAVE_STRINGS_H
-# include <strings.h>
-#endif
-
-# include "obst.h"
-# include "pto.h"
-# include "pto_init.h"
-# include "pto_debug.h"
-# include "pto_comp.h"
-# include "pto_name.h"
-# include "pto_util.h"
-
-# include "typewalk.h"
-# include "irgwalk.h"
-# include "tv.h"
-# include "xmalloc.h"
-
-# include "gnu_ext.h"
-
-/* Local Defines: */
-# define obstack_chunk_alloc xmalloc
-# define obstack_chunk_free free
-
-/* Local Data Types: */
-typedef struct init_env_str
-{
- int n_ctxs;
-} init_env_t;
-
-typedef struct reset_env_str
-{
- int ctx_idx;
-} reset_env_t;
-
-/* Local Variables: */
-extern struct obstack *qset_obst; /* from pto_name */
-
-static struct obstack *pto_obst = NULL; /* all pto_t's go onto this one */
-
-/* Local Prototypes: */
-
-/* ===================================================
- Local Implementation:
- =================================================== */
-/** Allocate a new pto */
-static pto_t *new_pto (ir_node *node)
-{
- pto_t *pto = obstack_alloc (pto_obst, sizeof (pto_t));
- pto->values = qset_new (N_INITIAL_OJBS, qset_obst);
-
- return (pto);
-}
-
-/** Allocate a new alloc_pto */
-static alloc_pto_t *new_alloc_pto (ir_node *alloc, int n_ctxs)
-{
- int i;
- alloc_pto_t *alloc_pto = obstack_alloc (pto_obst, sizeof (alloc_pto_t));
- ir_type *tp;
-
- assert (op_Alloc == get_irn_op(alloc));
-
- tp = get_Alloc_type (alloc);
-
- alloc_pto->ptos = (pto_t**) obstack_alloc (pto_obst, n_ctxs * sizeof (pto_t*));
-
- for (i = 0; i < n_ctxs; i ++) {
- desc_t *desc = new_name (tp, alloc, i);
- alloc_pto->ptos [i] = new_pto (alloc);
- qset_insert (alloc_pto->ptos [i]->values, desc);
- }
-
- return (alloc_pto);
-}
-
-/** Allocate a new pto for a symconst */
-static pto_t* new_symconst_pto (ir_node *symconst)
-{
- pto_t *pto;
- ir_entity *ent;
- desc_t *desc = NULL;
-
- assert (op_SymConst == get_irn_op(symconst));
-
- pto = new_pto (symconst);
- ent = get_SymConst_entity (symconst);
-
- /*
- const char *ent_name = (char*) get_entity_name (ent);
- const char *own_name = (char*) get_type_name (get_entity_owner (ent));
- HERE3 ("start", own_name, ent_name);
- */
- /* Ok, so if the symconst has a pointer-to-mumble, it's some address
- calculation, but if it's the mumble itself, it's just the same,
- except it's presumably a constant of mumble. In any case, we need to
- branch on this. "How's that for object fucking oriented? --jwz" */
- if (is_Pointer_type (get_entity_type (ent))) {
- desc = new_ent_name (ent);
- } else if (is_Class_type (get_entity_type (ent))) {
- desc = new_name (get_entity_type (ent), symconst, -1);
- } else {
- fprintf (stderr, "%s: not handled: %s[%li] (\"%s\")\n",
- __FUNCTION__,
- get_op_name (get_irn_op (symconst)),
- get_irn_node_nr (symconst),
- get_entity_name (ent));
- assert (0 && "something not handled");
- }
-
- qset_insert (pto->values, desc);
-
- /* HERE3 ("end", own_name, ent_name); */
-
- return (pto);
-}
-
-/* Helper to pto_init --- clear the link fields of class types */
-static void clear_type_link (type_or_ent *thing, void *_unused)
-{
- if (is_type (thing)) {
- ir_type *tp = (ir_type*) thing;
-
- if (is_Class_type (tp)) {
- DBGPRINT (1, (stdout, "%s (\"%s\")\n",
- __FUNCTION__,
- get_type_name (tp)));
-
- set_type_link (tp, NULL);
- }
- } else if (is_entity (thing)) {
- ir_entity *ent = (ir_entity*) thing;
-
- DBGPRINT (1, (stdout, "%s (\"%s\")\n",
- __FUNCTION__,
- get_entity_name (ent)));
-
- set_entity_link (ent, NULL);
- }
-}
-
-/** Helper to pto_init_graph --- clear the links of the given node */
-static void clear_node_link (ir_node *node, void *_unused)
-{
- set_irn_link (node, NULL);
-}
-
-/** Helper to pto_init_graph --- clear the links of all nodes */
-static void clear_graph_links (ir_graph *graph)
-{
- irg_walk_graph (graph, clear_node_link, NULL, NULL);
-}
-
-/** Reset ALL the pto values for a new pass */
-static void reset_node_pto (ir_node *node, void *env)
-{
- reset_env_t *reset_env = (reset_env_t*) env;
- int ctx_idx = reset_env->ctx_idx;
- ir_opcode op = get_irn_opcode (node);
-
- /* HERE ("start"); */
-
- switch (op) {
- case (iro_Load):
- case (iro_Call):
- case (iro_Block): /* END BLOCK only */
- case (iro_Phi): {
- /* allocate 'empty' pto values */
- pto_t *pto = new_pto (node);
- set_node_pto (node, pto);
- } break;
-
- case (iro_Alloc): {
- /* set alloc to 'right' current pto */
- alloc_pto_t *alloc_pto = (alloc_pto_t*) get_irn_link (node);
- alloc_pto->curr_pto = alloc_pto->ptos [ctx_idx];
-
- DBGPRINT (1, (stdout, "%s: setting pto of \"%s[%li]\" for ctx %i\n",
- __FUNCTION__,
- OPNAME (node),
- OPNUM (node),
- ctx_idx));
-
- assert (alloc_pto->curr_pto);
- } break;
- case (iro_Const):
- case (iro_SymConst): {
- /* nothing, leave as-is */
- } break;
-
- default: {
- /* basically, nothing */
- DBGPRINT (2, (stdout, "%s: resetting pto of \"%s[%li]\"\n",
- __FUNCTION__,
- OPNAME (node),
- OPNUM (node)));
- set_node_pto (node, NULL);
- } break;
- }
-
- /* HERE ("end"); */
-}
-
-/** Initialise primary name sources */
-static void init_pto (ir_node *node, void *env)
-{
- init_env_t *init_env = (init_env_t*) env;
- int n_ctxs = init_env->n_ctxs;
-
- ir_opcode op = get_irn_opcode (node);
-
- switch (op) {
- case (iro_SymConst): {
- if (mode_is_reference (get_irn_mode (node))) {
- ir_entity *ent = get_SymConst_entity (node);
- ir_type *tp = get_entity_type (ent);
- if (is_Class_type (tp) || is_Pointer_type (tp)) {
- pto_t *symconst_pto = new_symconst_pto (node);
- set_node_pto (node, symconst_pto);
-
- /* debugging only */
- DBGPRINT (1, (stdout, "%s: new name \"%s\" for \"%s[%li]\"\n",
- __FUNCTION__,
- get_entity_name (ent),
- OPNAME (node),
- OPNUM (node)));
- }
- }
- } break;
-
- case (iro_Alloc): {
- alloc_pto_t *alloc_pto = new_alloc_pto (node, n_ctxs);
- ir_type *tp;
-
- set_alloc_pto (node, alloc_pto);
-
- tp = get_Alloc_type (node); /* debugging only */
- DBGPRINT (1, (stdout, "%s: %i names \"%s\" for \"%s[%li]\"\n",
- __FUNCTION__,
- n_ctxs,
- get_type_name (tp),
- OPNAME (node),
- OPNUM (node)));
- } break;
-
- case (iro_Const): {
- tarval *tv = get_Const_tarval (node);
-
- /* only need 'NULL' pointer constants */
- if (mode_P == get_tarval_mode (tv)) {
- if (get_tarval_null (mode_P) == tv) {
- pto_t *pto = new_pto (node);
- set_node_pto (node, pto);
- }
- }
- } break;
- case (iro_Load):
- case (iro_Call):
- case (iro_Phi):
- /* nothing --- handled by reset_node_pto on each pass */
- break;
- default: {
- /* nothing */
- } break;
- }
-}
-
-
-/** Initialise the given graph for a new pass run */
-static void pto_init_graph_allocs (ir_graph *graph)
-{
- graph_info_t *ginfo = ecg_get_info (graph);
- init_env_t *init_env;
-
- init_env = xmalloc (sizeof (init_env_t));
- init_env->n_ctxs = ginfo->n_ctxs;
-
- /* HERE ("start"); */
-
- irg_walk_graph (graph, init_pto, NULL, init_env);
-
- /* HERE ("end"); */
- memset (init_env, 0x00, sizeof (init_env_t));
- free (init_env);
-}
-
-/* ===================================================
- Exported Implementation:
- =================================================== */
-/* "Fake" the arguments to the main method */
-void fake_main_args (ir_graph *graph)
-{
- /* HERE ("start"); */
-
- ir_entity *ent = get_irg_entity (graph);
- ir_type *mtp = get_entity_type (ent);
- ir_node **args = find_irg_args (graph);
- ir_type *ctp = get_method_param_type (mtp, 1); /* ctp == char[]*[]* */
- desc_t *arg_desc;
- pto_t *arg_pto;
-
- /* 'main' has signature 'void(int, char[]*[]*)' */
- assert (NULL == args [2]);
-
- assert (is_Pointer_type (ctp));
-
- ctp = get_pointer_points_to_type (ctp); /* ctp == char[]*[] */
-
- assert (is_Array_type (ctp));
-
- arg_desc = new_name (ctp, args [1], -1);
- arg_pto = new_pto (args [1]);
- /* todo: simulate 'store' to arg1[] ?!? */
- qset_insert (arg_pto->values, arg_desc);
-
- set_node_pto (args [1], arg_pto);
-
- DBGPRINT (1, (stdout, "%s:%i (%s[%li])\n",
- __FUNCTION__, __LINE__,
- OPNAME (args [1]), OPNUM (args [1])));
-
-# ifdef TEST_MAIN_TYPE
- ctp = get_array_element_type (ctp); /* ctp == char[]* */
-
- assert (is_Pointer_type (ctp));
-
- ctp = get_pointer_points_to_type (ctp); /* ctp == char[] */
-
- assert (is_Array_type (ctp));
-
- ctp = get_array_element_type (ctp); /* ctp == char */
-
- assert (is_primitive_type (ctp));
-# endif /* defined TEST_MAIN_TYPE */
-
- /* HERE ("end"); */
-}
-
-/* Initialise the Init module */
-void pto_init_init (void)
-{
- pto_obst = (struct obstack*) xmalloc (sizeof (struct obstack));
-
- obstack_init (pto_obst);
-}
-
-/* Cleanup the Init module */
-void pto_init_cleanup (void)
-{
- obstack_free (pto_obst, NULL);
- memset (pto_obst, 0x00, sizeof (struct obstack));
- free (pto_obst);
- pto_obst = NULL;
-}
-
-
-/* Initialise the Names of the Types/Entities */
-void pto_init_type_names (void)
-{
- /* HERE ("start"); */
- type_walk (clear_type_link, NULL, NULL);
- /* HERE ("end"); */
-}
-
-/* Initialise the given graph for a new pass run */
-void pto_init_graph (ir_graph *graph)
-{
- ir_node **proj_args;
- graph_info_t *ginfo = ecg_get_info (graph);
- const int n_ctxs = ginfo->n_ctxs;
-
- /* only for debugging stuff: */
- ir_entity *ent = get_irg_entity (graph);
- const char *ent_name = (char*) get_entity_name (ent);
- const char *own_name = (char*) get_type_name (get_entity_owner (ent));
-
- DBGPRINT (2, (stdout, "%s: init \"%s.%s\" for %i ctxs\n",
- __FUNCTION__,
- own_name, ent_name, n_ctxs));
-
- /* HERE ("start"); */
-
- clear_graph_links (graph);
- pto_init_graph_allocs (graph);
-
- /* HERE ("end"); */
-
- assert (NULL == get_irg_proj_args (graph));
- proj_args = find_irg_args (graph);
- set_irg_proj_args (graph, proj_args);
- assert (proj_args == get_irg_proj_args (graph));
-}
-
-/* Reset the given graph for a new pass run */
-void pto_reset_graph_pto (ir_graph *graph, int ctx_idx)
-{
- reset_env_t *reset_env;
-
- reset_env = (reset_env_t*) xmalloc (sizeof (reset_env_t));
- reset_env->ctx_idx = ctx_idx;
-
- /* HERE ("start"); */
-
- irg_walk_graph (graph, reset_node_pto, NULL, reset_env);
-
- /* HERE ("end"); */
- memset (reset_env, 0x00, sizeof (reset_env_t));
- free (reset_env);
-}
-
-\f
-/*
- $Log$
- Revision 1.23 2007/01/16 15:45:42 beck
- renamed type opcode to ir_opcode
-
- Revision 1.22 2006/12/13 19:46:47 beck
- rename type entity into ir_entity
-
- Revision 1.21 2006/06/08 10:49:07 beck
- renamed type to ir_type
-
- Revision 1.20 2005/12/05 12:19:54 beck
- added missing include <assert.h> (not anymore included in libFirm)
-
- Revision 1.19 2005/06/17 17:42:32 beck
- added doxygen docu
- fixed (void) function headers
-
- Revision 1.18 2005/02/16 13:27:52 beck
- added needed tv.h include
-
- Revision 1.17 2005/01/14 14:12:51 liekweg
- prepare gnu extension fix
-
- Revision 1.16 2005/01/14 13:36:50 liekweg
- don't put environments on the stack; handle consts
-
- Revision 1.15 2005/01/10 17:26:34 liekweg
- fixup printfs, don't put environments on the stack
-
- Revision 1.14 2005/01/05 14:25:54 beck
- renames all is_x*_type() functions to is_X*_type() to prevent name clash with EDG fronten
-
- Revision 1.13 2004/12/21 15:07:55 beck
- removed C99 contructs
- removed unnecessary allocation
- removed use of mode_P, use mode_is_reference() instead
- removed handling of Const with pointer tarvals, these constructs are removed
-
- Revision 1.12 2004/12/20 17:41:14 liekweg
- __unused -> _unused
-
- Revision 1.11 2004/12/20 17:34:35 liekweg
- fix recursion handling
-
- Revision 1.10 2004/12/15 13:31:00 liekweg
- store ctx idx in names
-
- Revision 1.9 2004/12/15 09:18:18 liekweg
- pto_name.c
-
- Revision 1.8 2004/12/02 16:17:51 beck
- fixed config.h include
-
- Revision 1.7 2004/11/30 14:47:54 liekweg
- fix initialisation; do correct iteration
-
- Revision 1.6 2004/11/26 16:00:41 liekweg
- recognize class consts vs. ptr-to-class consts
-
- Revision 1.5 2004/11/24 14:53:56 liekweg
- Bugfixes
-
- Revision 1.4 2004/11/20 21:21:56 liekweg
- Finalise initialisation
-
- Revision 1.3 2004/11/18 16:37:07 liekweg
- rewrite
-
-
-*/
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief ...
- * @author Florian
- * @date Sat Nov 13 19:35:27 CET 2004
- * @version $Id$
- */
-# ifndef FIRM_ANA2_PTO_INIT_H
-# define FIRM_ANA2_PTO_INIT_H
-
-# include "irgraph.h"
-# include "ecg.h"
-
-/* ===================================================
- Global Defines:
- =================================================== */
-
-/* ===================================================
- Global Data Types:
- =================================================== */
-
-/* ===================================================
- Global Prototypes:
- =================================================== */
-/* "Fake" the arguments to the main method */
-void fake_main_args (ir_graph*);
-
-/* Initialise the Init module */
-void pto_init_init (void);
-
-/* Cleanup the Init module */
-void pto_init_cleanup (void);
-
-/* Initialise the Names of the Types/Entities */
-void pto_init_type_names (void);
-
-/* Initialise the given graph */
-void pto_init_graph (ir_graph*);
-
-/* Reset the given graph for a new pass run */
-void pto_reset_graph_pto (ir_graph*, int);
-
-/* ===================================================
- Global Variables:
- =================================================== */
-
-
-# endif
-
-
-\f
-/*
- $Log$
- Revision 1.4 2004/11/24 14:53:56 liekweg
- Bugfixes
-
- Revision 1.3 2004/11/20 21:21:56 liekweg
- Finalise initialisation
-
- Revision 1.2 2004/11/18 16:37:07 liekweg
- rewrite
-
-
-*/
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Load/Store Transfer Functions
- * @author Florian
- * @date Fri Nov 26 17:29:49 CET 2004
- * @version $Id$
- */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-/*
- pto_mod: Load/Store Transfer Functions
-*/
-
-# include "pto_mod.h"
-
-# include "xmalloc.h"
-
-# include "pto_debug.h"
-# include "pto_name.h"
-
-/* Local Defines: */
-
-/* Local Data Types: */
-
-/* Local Variables: */
-
-/* Local Prototypes: */
-
-/* ===================================================
- Local Implementation:
- =================================================== */
-
-
-/* ===================================================
- Exported Implementation:
- =================================================== */
-/* Perform the given store; return nonzero iff any involved values change */
-int mod_store (ir_node *store, ir_entity *ent,
- pto_t *ptr_pto, pto_t *val_pto)
-{
- int change = 0;
-
- /* foreach descr in ptr_pto, add val_pto->values to descr.ent */
-
- qset_t *ptos = ptr_pto->values;
-
- desc_t *desc = (desc_t*) qset_start (ptos);
-
- while (NULL != desc) {
- qset_t *entry = get_entry (desc, ent);
-
- change |= qset_insert_all (entry, val_pto->values);
-
- desc = (desc_t*) qset_next (ptos);
- }
-
- return (change);
-}
-
-/* Perform the given load; return nonzero iff any involved values change */
-int mod_load (ir_node *load, ir_entity *ent,
- pto_t *ptr_pto)
-{
- int change = 0;
- pto_t *res = get_node_pto (load);
- /* todo: for each descr in ptr_pto, add descr.ent to res */
-
- qset_t *ptos = ptr_pto->values;
- desc_t *desc = (desc_t*) qset_start (ptos);
-
- while (NULL != desc) {
- qset_t *entry = get_entry (desc, ent);
-
- change |= qset_insert_all (res->values, entry);
-
- desc = (desc_t*) qset_next (ptos);
- }
-
- return (change);
-}
-
-
-\f
-/*
- $Log$
- Revision 1.3 2006/12/13 19:46:47 beck
- rename type entity into ir_entity
-
- Revision 1.2 2004/12/02 16:17:51 beck
- fixed config.h include
-
- Revision 1.1 2004/11/30 14:47:54 liekweg
- fix initialisation; do correct iteration
-
-
-*/
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Load/Store Transfer Functions
- * @author Florian
- * @date Fri Nov 26 17:29:49 CET 2004
- * @version $Id$
- */
-#ifndef FIRM_ANA2_PTO_MOD_H
-#define FIRM_ANA2_PTO_MOD_H
-
-#include "irnode.h"
-#include "entity.h"
-#include "pto_comp.h"
-
-/* ===================================================
- Global Defines:
- =================================================== */
-
-/* ===================================================
- Global Data Types:
- =================================================== */
-
-/* ===================================================
- Global Prototypes:
- =================================================== */
-/* Perform the given store; return nonzero iff any involved values change */
-int mod_store (ir_node*, ir_entity*, pto_t*, pto_t*);
-
-/* Perform the given load; return nonzero iff any involved values change */
-int mod_load (ir_node*, ir_entity*, pto_t*);
-
-/* ===================================================
- Global Variables:
- =================================================== */
-
-
-#endif /* not defined _PTO_MOD_ */
-
-
-\f
-/*
- $Log$
- Revision 1.2 2006/12/13 19:46:47 beck
- rename type entity into ir_entity
-
- Revision 1.1 2004/11/30 14:47:54 liekweg
- fix initialisation; do correct iteration
-
-
-*/
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Names for abstract objects
- * @author Florian
- * @date Sat Nov 13 19:35:27 CET 2004
- * @version $Id$
- */
-# ifdef HAVE_CONFIG_H
-# include "config.h"
-# endif
-
-/*
- pto_name: Names for abstract objects
-*/
-
-# include "pto.h"
-# include "pto_name.h"
-# include "pto_util.h"
-
-#include <assert.h>
-
-#ifdef HAVE_STRING_H
-# include <string.h> /* for memcpy */
-#endif
-# include <errno.h>
-
-# include "obst.h"
-# include "irnode.h"
-# include "irprog.h"
-# include "xmalloc.h"
-
-# include "pto_debug.h"
-# include "gnu_ext.h"
-
-/* Local Defines: */
-# define obstack_chunk_alloc xmalloc
-# define obstack_chunk_free free
-
-# define NALLOC(size) obstack_alloc (name_obst, size)
-
-/* Local Data Types: */
-
-/* Local Variables: */
-struct obstack *qset_obst = NULL;
-struct obstack *name_obst = NULL;
-
-static desc_t *all_descs = NULL;
-
-static int name_id = 0;
-
-# define PTO_COLOR
-
-# ifdef PTO_COLOR
-static int last_col_idx = 0;
-
-/* Local Prototypes: */
-static int pto_name_alloc_color (desc_t*);
-static void pto_name_set_color (desc_t*, int);
-# endif /* defined PTO_COLOR */
-
-/* ===================================================
- Local Implementation:
- =================================================== */
-# ifdef PTO_COLOR
-/* set a nice color to an object descriptor */
-static void pto_name_set_obj_color (obj_desc_t *obj_desc, int col_idx)
-{
- int i;
-
- for (i = 0; i < obj_desc->n_fields; i ++) {
- qset_t *ptos = obj_desc->values [i];
-
- desc_t *tgt = (desc_t*) qset_start (ptos);
-
- while (NULL != tgt) {
- pto_name_set_color (tgt, col_idx);
-
- tgt = (desc_t*) qset_next (ptos);
- }
- }
-}
-
-/* set a nice color to an array descriptor */
-static void pto_name_set_arr_color (arr_desc_t *arr_desc, int col_idx)
-{
- qset_t *ptos = arr_desc->value;
-
- desc_t *tgt = (desc_t*) qset_start (ptos);
-
- while (NULL != tgt) {
- pto_name_set_color (tgt, col_idx);
-
- tgt = (desc_t*) qset_next (ptos);
- }
-}
-
-/* set a nice color to a descriptor */
-static void pto_name_set_color (desc_t *desc, int col_idx)
-{
- /* assert (0 == desc->col_idx); */
-
- desc->col_idx = col_idx;
-
- if (FALSE == desc->visit) {
- desc->visit = TRUE;
- if (object == desc->kind) {
- pto_name_set_obj_color ((obj_desc_t*) desc, col_idx);
- } else if (array == desc->kind) {
- pto_name_set_arr_color ((arr_desc_t*) desc, col_idx);
- }
-
- desc->visit = FALSE;
- }
-}
-
-
-/* allocate nice colors for an object descriptor */
-static int pto_name_alloc_obj_color (obj_desc_t *obj_desc)
-{
- int i;
- int col_idx = 0;
-
- for (i = 0; (0 == col_idx) && (i < obj_desc->n_fields); i ++) {
- qset_t *ptos = obj_desc->values [i];
- desc_t *tgt = (desc_t*) qset_start (ptos);
-
- while ((0 == col_idx) && (NULL != tgt)) {
- col_idx = pto_name_alloc_color (tgt);
-
- tgt = (desc_t*) qset_next (ptos);
- }
- }
-
- return (col_idx);
-}
-
-/* allocate nice colors for an array descriptor */
-static int pto_name_alloc_arr_color (arr_desc_t *arr_desc)
-{
- int col_idx = 0;
-
- qset_t *ptos = arr_desc->value;
-
- desc_t *tgt = (desc_t*) qset_start (ptos);
-
- while ((NULL != tgt) && (0 == col_idx)) {
- col_idx = pto_name_alloc_color (tgt);
- tgt = (desc_t*) qset_next (ptos);
- }
-
- return (col_idx);
-}
-
-/* allocate nice colors for the given descriptor */
-static int pto_name_alloc_color (desc_t *desc)
-{
- int col_idx = 0;
-
- if (0 != desc->col_idx) {
- return (desc->col_idx);
- }
-
- if (FALSE == desc->visit) {
- desc->visit = TRUE;
- if (object == desc->kind) {
- col_idx = pto_name_alloc_obj_color ((obj_desc_t*) desc);
- } else if (array == desc->kind) {
- col_idx = pto_name_alloc_arr_color ((arr_desc_t*) desc);
- }
- desc->visit = FALSE;
- }
-
- if (0 == col_idx) {
- col_idx = ++ last_col_idx;
- }
-
- pto_name_set_color (desc, col_idx);
-
- return (col_idx);
-}
-
-/* allocate nice colors */
-static void pto_name_alloc_colors (void)
-{
- desc_t *desc = all_descs;
-
- while (NULL != desc) {
- pto_name_alloc_color (desc);
-
- desc = desc->prev;
- }
-}
-# endif /* defined PTO_COLOR */
-
-/* See whether the given entity is a field. */
-static int is_field (ir_entity *ent)
-{
- ir_type *tp = get_entity_type (ent);
-
- if (is_Primitive_type (tp) || is_Pointer_type (tp)) {
- /* actually, we don't get by by restricting ourselves to pointer types */
- return (TRUE);
- } else {
- return (FALSE);
- }
-}
-
-/* Helper to collect_fields(ir_type*): collect all fields of the given
- clazz and its super classes into the given obstack. */
-static void _collect_fields (ir_type *clazz, struct obstack *obst)
-{
- int n_members = get_class_n_members (clazz);
- int n_supers = get_class_n_supertypes (clazz);
- int i;
-
- for (i = 0; i < n_members; i ++) {
- ir_entity *ent = get_class_member (clazz, i);
-
- if (is_field (ent)) {
- if (allocation_static != get_entity_allocation (ent)) {
- obstack_ptr_grow (obst, ent);
- }
- }
- }
-
- for (i = 0; i < n_supers; i ++) {
- ir_type *s_clazz = get_class_supertype (clazz, i);
-
- _collect_fields (s_clazz, obst);
- }
-}
-
-/* Collect the fields of the given class and its super classes into an array.
- The last entry of the array is written NULL. */
-static ir_entity **collect_fields (ir_type *clazz)
-{
- struct obstack obst;
- int n_fields;
- ir_entity ** fields;
- void *tmp;
-
- if (NULL != get_type_link (clazz)) {
- DBGPRINT (3, (stdout, "%s: reusing field list for \"%s\"\n",
- __FUNCTION__,
- get_type_name (clazz)));
-
- return ((ir_entity **) get_type_link (clazz));
- } else {
- DBGPRINT (2, (stdout, "%s: new field list for \"%s\"\n",
- __FUNCTION__,
- get_type_name (clazz)));
- }
-
- obstack_init (&obst);
-
- _collect_fields (clazz, &obst);
-
- /* append terminating NULL */
- obstack_ptr_grow (&obst, NULL);
-
- n_fields = obstack_object_size (&obst) / sizeof (void*);
-
- fields = NALLOC (n_fields * sizeof (ir_entity*));
- tmp = obstack_finish(&obst);
-
- memcpy (fields, tmp, n_fields * sizeof (ir_entity*));
-
- obstack_free (&obst, NULL);
-
- set_type_link (clazz, fields);
-
- return (fields);
-}
-
-/* Write the intro text for a name dump into the given stream */
-static void pto_name_dump_start (FILE *stream)
-{
-# ifdef PTO_COLOR
- pto_name_alloc_colors ();
-# endif /* defined PTO_COLOR */
-
- fprintf (stream, "digraph \"Names\" {\n");
- fprintf (stream, "\tgraph [rankdir=\"LR\", ordering=\"out\", size=\"11,7\", rotate=\"90\"];\n");
- fprintf (stream, "\tnode [shape=\"record\", style=\"filled\"];\n");
- fprintf (stream, "\tedge [color=\"black\"];\n");
- fprintf (stream, "\n");
-}
-
-/* Write the extro text for a name dump into the given stream */
-static void pto_name_dump_finish (FILE *stream)
-{
- fprintf (stream, "}\n");
-}
-
-/* Write a node for the given descriptor into the given stream */
-static void pto_name_dump_desc (desc_t *desc, FILE *stream)
-{
- ir_type *tp = desc->tp;
- const char *tp_name = get_type_name (tp);
- ir_node *nd;
-
- fprintf (stream, "\t/* %s \"%s\" */\n",
- object == desc->kind ? "Object" : "Array",
- tp_name);
-
- fprintf (stream, "\tdesc_%i [label=\"<HEAD>type \\[%i\\]",
- desc->id, desc->id);
-
- if (-1 != desc->ctx) {
- fprintf (stream, ", ctx = %i", desc->ctx);
- } else {
- fprintf (stream, " (global)");
- }
-
- fprintf (stream, "\\lname=\\\"%s\\\"",
- tp_name);
-
- nd = desc->node;
-
- if (NULL != nd) {
- ir_graph *graph = get_irn_irg (nd);
- ir_entity *method = get_irg_entity (graph);
- const char *ent_name = get_entity_name (method);
- const char *own_name = get_type_name (get_entity_owner (method));
-
- fprintf (stream, "\\lnode=%s\\[%li\\]",
- get_op_name (get_irn_op (nd)),
- get_irn_node_nr (nd));
- fprintf (stream, "\\lgraph=\\\"%s.%s\\\"",
- own_name,
- ent_name);
- }
-
- if (desc->kind == object) {
- obj_desc_t *obj_desc = (obj_desc_t*) desc;
-
- int i;
- for (i = 0; i < obj_desc->n_fields; i ++) {
- ir_entity *field = obj_desc->fields [i];
-
- if (is_Pointer_type (get_entity_type (field))) {
- const char *ent_name = get_entity_name (field);
-
- fprintf (stream, "|<%i>%s", i, ent_name);
- }
- }
- } else if (array == desc->kind) {
- fprintf (stream, "|<arr>[]");
- } else {
- assert (0 && "invalid descriptor");
- }
-
- /* end label string */
- fprintf (stream, "\"");
-
-# ifdef PTO_COLOR
- {
- const char *fontcolor;
- int col_idx = desc->col_idx;
- float hue = (float) col_idx / (float) last_col_idx;
- float sat = 1.000f; /* 0.300 .. 1.000 */
- float val = 0.800f; /* 0.300 .. 1.000 */
-
- # define MAX_COLORS 12
- if (last_col_idx > MAX_COLORS) {
- /* too many colors ... vary value too */
- float div = (float) MAX_COLORS / (float) last_col_idx;
-
- sat = (div * ((col_idx / MAX_COLORS)));
- val = (div * ((col_idx / MAX_COLORS)));
-
- col_idx = col_idx % MAX_COLORS;
- hue = (float) col_idx / (float) MAX_COLORS;
-
- // re-adjust sat and val
- {
- const float sat_min = 0.200f; /* 0.200 .. 0.400 */
- const float val_min = 0.300f; /* 0.300 .. 0.400 */
-
- sat = sat_min + ((1.0f - sat_min) * sat);
- val = val_min + ((1.0f - val_min) * val);
- }
- }
- # undef MAX_COLORS
-
- fprintf (stream, ", color=\"%01.3f, %01.3f, %01.3f\"", hue, sat, val);
-
- if ((hue > 0.3) && (sat < 0.5)) {
- fontcolor = "white";
- } else if (sat < 0.4) {
- fontcolor = "white";
- } else {
- fontcolor = "black";
- }
-
- fprintf (stream, ", fontcolor=\"%s\"", fontcolor);
- }
-# else /* if defined PTO_COLOR */
- fprintf (stream, ", color=\"lightgrey\"");
-# endif /* defined PTO_COLOR */
-
- /* end attributes */
- fprintf (stream, "];\n");
- fprintf (stream, "\n");
-
- /* now the edges */
- if (desc->kind == object) {
- obj_desc_t *obj_desc = (obj_desc_t*) desc;
-
- int i;
- for (i = 0; i < obj_desc->n_fields; i ++) {
- desc_t *tgt = (desc_t*) qset_start (obj_desc->values [i]);
-
- while (NULL != tgt) {
- fprintf (stream, "\tdesc_%i:%i -> desc_%i:HEAD;\n",
- desc->id, i, tgt->id);
-
- tgt = (desc_t*) qset_next (obj_desc->values [i]);
- }
- }
- } else if (array == desc->kind) {
- arr_desc_t *arr_desc = (arr_desc_t*) desc;
-
- desc_t *tgt = (desc_t*) qset_start (arr_desc->value);
-
- while (NULL != tgt) {
- fprintf (stream, "\tdesc_%i:arr -> desc_%i:HEAD;\n",
- desc->id, tgt->id);
-
- tgt = (desc_t*) qset_next (arr_desc->value);
- }
- }
-
- fprintf (stream, "\n");
-}
-
-
-/* ===================================================
- Exported Implementation:
- =================================================== */
-/* Find the given descriptor's entry for the given entity */
-qset_t *get_entry (desc_t *desc, ir_entity *ent)
-{
-
- if (desc->kind == object) {
- obj_desc_t *obj_desc = (obj_desc_t*) desc;
- int i;
- const int n_fields = obj_desc->n_fields;
-
- for (i = 0; i < n_fields; i ++) {
- if (ent == obj_desc->fields [i]) {
- return (obj_desc->values [i]);
- }
- }
-
- assert (0 && "entry not found");
- } else if (desc->kind == array) {
- arr_desc_t *arr_desc = (arr_desc_t*) desc;
-
- return (arr_desc->value);
- } else {
- assert (0 && "invalid descriptor");
- }
- return NULL;
-}
-
-
-/* get a new descriptor for the given type at the given node */
-desc_t *new_name (ir_type *tp, ir_node *node, int ctx)
-{
- desc_t *desc = NULL;
-
- assert ((is_Class_type (tp) || is_Array_type (tp)) && "unsuitable type");
-
- DBGPRINT (2, (stdout, "%s: new name for type \"%s\"\n",
- __FUNCTION__,
- get_type_name (tp)));
- fflush (stdout);
-
- if (is_Class_type (tp)) {
- obj_desc_t *obj_desc = NALLOC (sizeof (obj_desc_t));
- int i;
- int n_fields;
-
- obj_desc->kind = object;
- obj_desc->fields = collect_fields (tp);
-
- for (n_fields = 0; (NULL != obj_desc->fields [n_fields]); n_fields ++) {
- /* nothing, just count ... */
- }
-
- obj_desc->n_fields = n_fields;
- obj_desc->values = (qset_t**) NALLOC (n_fields * sizeof (qset_t*));
-
- for (i = 0; i < n_fields; i ++) {
- obj_desc->values [i] = qset_new (N_INITIAL_OJBS, qset_obst);
- }
-
- desc = (desc_t*) obj_desc;
- } else if (is_Array_type (tp)) {
- arr_desc_t *arr_desc = (arr_desc_t*) NALLOC (sizeof (arr_desc_t));
-
- arr_desc->kind = array;
- arr_desc->value = qset_new (N_INITIAL_OJBS, qset_obst);
-
- desc = (desc_t*) arr_desc;
- }
-
- desc->id = name_id ++;
- desc->col_idx = 0;
- desc->tp = tp;
- desc->visit = FALSE;
- desc->ctx = ctx;
- desc->node = node;
-
- desc->prev = all_descs;
- all_descs = desc;
-
- return (desc);
-}
-
-# define N_GLOB_INITIAL_FIELDS 20
-static obj_desc_t *obj_glob = NULL;
-static int n_glob_fields = N_GLOB_INITIAL_FIELDS;
-
-/* get a new descriptor for the given (presumably static) entity */
-desc_t *new_ent_name (ir_entity *ent)
-{
- int i;
- int missing = TRUE;
- ir_type *tp = get_entity_type (ent);
-
- assert (is_Pointer_type (tp));
- tp = get_pointer_points_to_type (tp);
- assert (is_Class_type (tp));
-
- DBGPRINT (2, (stdout, "%s: new name for entity \"%s\"\n",
- __FUNCTION__,
- get_entity_name (ent)));
- DBGEXE (2, (fflush (stdout)));
-
- assert (((allocation_static == get_entity_allocation (ent)) ||
- (allocation_automatic == get_entity_allocation (ent))) &&
- "not a static/automatic field");
-
- if (NULL == obj_glob) {
- obj_glob = (obj_desc_t*) NALLOC (sizeof (obj_desc_t));
-
- obj_glob->id = name_id ++;
- obj_glob->ctx = -1;
- obj_glob->col_idx = 0;
- obj_glob->visit = FALSE;
- obj_glob->kind = object;
- obj_glob->tp = get_glob_type ();
- obj_glob->node = NULL;
-
- obj_glob->n_fields = 0;
- obj_glob->fields = (ir_entity**) NALLOC (N_GLOB_INITIAL_FIELDS * sizeof (ir_entity*));
- obj_glob->values = (qset_t**) NALLOC (N_GLOB_INITIAL_FIELDS * sizeof (qset_t*));
-
- obj_glob->prev = all_descs;
- all_descs = (desc_t*) obj_glob;
- }
-
- for (i = 0; missing && (i < obj_glob->n_fields); i ++) {
- if (ent == obj_glob->fields [i]) {
- missing = FALSE;
- }
- }
-
- if (missing) {
- if (obj_glob->n_fields == n_glob_fields) {
- ir_entity **fields = obj_glob->fields;
- qset_t **values = obj_glob->values;
-
- n_glob_fields *= 2;
- obj_glob->fields = (ir_entity**) NALLOC (n_glob_fields * sizeof (ir_entity*));
- obj_glob->values = (qset_t**) NALLOC (n_glob_fields * sizeof (qset_t*));
-
- memcpy (obj_glob->fields, fields, obj_glob->n_fields * sizeof (ir_entity*));
- memcpy (obj_glob->values, values, obj_glob->n_fields * sizeof (qset_t*));
-
- /* free (fields); */
- /* free (values); */
- }
-
- obj_glob->fields [obj_glob->n_fields ] = ent;
- obj_glob->values [obj_glob->n_fields ++] = qset_new (N_INITIAL_OJBS, qset_obst);
- }
-
- return ((desc_t*) obj_glob);
-}
-# undef N_GLOB_INITIAL_FIELDS
-
-/* Dump all names to a file of the given name */
-void pto_dump_names (const char *name)
-{
- desc_t *desc = all_descs;
- FILE *stream = fopen (name, "w");
-
- errno = 0;
- if (NULL == stream) {
- fprintf (stderr, "%s: unable to open %s (%s)\n",
- __FUNCTION__, name, strerror (errno));
- return;
- }
-
- pto_name_dump_start (stream);
-
- while (NULL != desc) {
- pto_name_dump_desc (desc, stream);
-
- desc = desc->prev;
- }
-
- pto_name_dump_finish (stream);
- fclose (stream);
-}
-
-/* Initialise the name module */
-void pto_name_init (void)
-{
- DBGPRINT (3, (stdout, "%s\n", __FUNCTION__));
- assert (NULL == name_obst);
- assert (NULL == qset_obst);
-
- name_obst = xmalloc (sizeof (struct obstack));
- qset_obst = xmalloc (sizeof (struct obstack));
-
- obstack_init (name_obst);
- obstack_init (qset_obst);
-}
-
-/* Cleanup the name module */
-void pto_name_cleanup (void)
-{
- DBGPRINT (3, (stdout, "%s\n", __FUNCTION__));
- obstack_free (name_obst, NULL);
- obstack_free (qset_obst, NULL);
-
- memset (name_obst, 0x00, sizeof (struct obstack));
- memset (qset_obst, 0x00, sizeof (struct obstack));
-
- free (name_obst);
- free (qset_obst);
-
- name_obst = NULL;
- qset_obst = NULL;
-}
-
-\f
-/*
- $Log$
- Revision 1.19 2006/12/13 19:46:47 beck
- rename type entity into ir_entity
-
- Revision 1.18 2006/01/13 22:56:21 beck
- renamed all types 'type' to 'ir_type'
-
- Revision 1.17 2005/12/16 16:59:54 grund
- *** empty log message ***
-
- Revision 1.16 2005/12/05 12:19:54 beck
- added missing include <assert.h> (not anymore included in libFirm)
-
- Revision 1.15 2005/03/02 10:14:38 beck
- placed a return on all execution pathes
-
- Revision 1.14 2005/02/17 08:45:38 liekweg
- Don't return a value for an invalid descriptor
-
- Revision 1.13 2005/02/11 10:21:28 beck
- get_entry now always returns a value
-
- Revision 1.12 2005/01/14 14:13:56 liekweg
- fix gnu extension, fix fprintf's, fix allocs
-
- Revision 1.11 2005/01/05 14:25:54 beck
- renames all is_x*_type() functions to is_X*_type() to prevent name clash with EDG fronten
-
- Revision 1.10 2004/12/22 14:43:14 beck
- made allocations C-like
-
- Revision 1.9 2004/12/21 15:34:09 beck
- removed C99 constructs
- make const float
- add default return
-
- Revision 1.8 2004/12/15 13:30:30 liekweg
- use DBGEXE correctly; print yet nicer names
-
- Revision 1.7 2004/12/15 09:18:18 liekweg
- pto_name.c
-
- Revision 1.6 2004/12/06 12:52:09 liekweg
- colorize name dump
-
- Revision 1.4 2004/11/30 15:49:27 liekweg
- include 'dump'
-
- Revision 1.3 2004/11/30 14:47:54 liekweg
- fix initialisation; do correct iteration
-
- Revision 1.2 2004/11/24 14:53:56 liekweg
- Bugfixes
-
- Revision 1.1 2004/11/18 16:37:34 liekweg
- rewritten
-
-
-*/
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Names for abstract objects
- * @author Florian
- * @date Sat Nov 13 19:35:27 CET 2004
- * @version $Id$
- */
-# ifndef FIRM_ANA2_PTO_NAME_H
-# define FIRM_ANA2_PTO_NAME_H
-
-# include "pto_comp.h" /* for pto_t */
-# include "irnode.h"
-# include "type.h"
-# include "qset.h"
-
-/* ===================================================
- Global Defines:
- =================================================== */
-
-/* ===================================================
- Global Data Types:
- =================================================== */
-typedef enum desc_kind_enum {
- none,
- object,
- array
-} desc_kind_t;
-
-/* abstract super class for all descriptors */
-typedef struct desc_str
-{
- int id;
- int visit;
- int ctx;
- int col_idx;
- desc_kind_t kind;
- ir_type *tp;
- ir_node *node; /* allocation node */
- struct desc_str *prev; /* linked list */
-} desc_t;
-
-/* object descriptor */
-typedef struct obj_desc_str
-{
- int id;
- int visit;
- int ctx;
- int col_idx;
- desc_kind_t kind;
- ir_type *tp;
- ir_node *node; /* allocation node */
- struct desc_str *prev; /* linked list */
-
- int n_fields;
- ir_entity **fields;
- qset_t **values;
-} obj_desc_t;
-
-/* array descriptor */
-typedef struct arr_desc_str
-{
- int id;
- int visit;
- int ctx;
- int col_idx;
- desc_kind_t kind;
- ir_type *tp;
- ir_node *node; /* allocation node */
- struct desc_str *prev; /* linked list */
-
- qset_t *value;
-} arr_desc_t;
-
-/* ===================================================
- Global Prototypes:
- =================================================== */
-/* Dump all names to a file of the given name */
-void pto_dump_names (const char*);
-
-/* Find the given descriptor's entry for the given entity */
-qset_t *get_entry (desc_t*, ir_entity*);
-
-/* get a new descriptor for the given type at the given node */
-desc_t *new_name (ir_type*, ir_node*, int);
-
-/* get a new descriptor for the given (presumably static) entity */
-desc_t *new_ent_name (ir_entity*);
-
-/* Initialise the name module */
-void pto_name_init (void);
-
-/* Cleanup the name module */
-void pto_name_cleanup (void);
-
-/* ===================================================
- Global Variables:
- =================================================== */
-
-
-# endif
-
-
-\f
-/*
- $Log$
- Revision 1.8 2006/12/13 19:46:47 beck
- rename type entity into ir_entity
-
- Revision 1.7 2006/01/13 22:00:15 beck
- renamed all types 'type' to 'ir_type'
-
- Revision 1.6 2004/12/15 13:30:41 liekweg
- print yet nicer names
-
- Revision 1.5 2004/12/06 12:52:09 liekweg
- colorize name dump
-
- Revision 1.4 2004/11/30 15:49:27 liekweg
- include 'dump'
-
- Revision 1.3 2004/11/30 14:47:54 liekweg
- fix initialisation; do correct iteration
-
- Revision 1.2 2004/11/24 14:53:56 liekweg
- Bugfixes
-
- Revision 1.1 2004/11/18 16:37:34 liekweg
- rewritten
-
-
-*/
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Utilitites for PTO
- * @author Florian
- * @date Sat Nov 13 19:35:27 CET 2004
- * @version $Id$
- */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-/*
- pto_util: Utilitites for PTO
-*/
-
-# include "pto_util.h"
-
-# include "irnode_t.h"
-# include "irgwalk.h"
-# include "xmalloc.h"
-
-# include "pto_debug.h"
-# include "gnu_ext.h"
-
-/* Local Defines: */
-# ifndef TRUE
-# define TRUE 1
-# define FALSE 0
-# endif /* not defined TRUE */
-
-/* Local Data Types: */
-/* Environment for find_irg_args */
-typedef struct find_irg_args_env {
- ir_node **args;
- ir_node *arg;
-} find_irg_args_env_t;
-
-
-/* Local Variables: */
-
-/* Local Prototypes: */
-
-/* ===================================================
- Local Implementation:
- =================================================== */
-/* Helper for find_irg_args */
-static void find_irg_arg (ir_node *node, void *env)
-{
- find_irg_args_env_t *arg_env = (find_irg_args_env_t*) env;
-
- if (iro_Proj == get_irn_opcode (node)) {
- if (arg_env->arg == get_Proj_pred (node)) {
- long n = get_Proj_proj (node);
-
- assert (! arg_env->args [n]);
-
- arg_env->args [n] = node;
- }
- }
-}
-
-/* ===================================================
- Exported Implementation:
- =================================================== */
-/* Find the arguments of a graph. For a method that has n args, the
- result array has 'n+1' entries, the last of which is written NULL.
- Note that not all entries in [0..n-1] will be populated all the time.
-*/
-ir_node **find_irg_args (ir_graph *graph)
-{
- ir_type *tp = get_entity_type (get_irg_entity (graph));
- const int n_args = get_method_n_params (tp);
- ir_node **args = xcalloc (n_args + 1, sizeof (ir_node*));
- ir_node *arg = get_irg_args (graph);
- find_irg_args_env_t *arg_env;
-
- arg_env = (find_irg_args_env_t*) xmalloc (sizeof (find_irg_args_env_t));
-
- arg_env->args = args;
- arg_env->arg = arg;
-
- {
- ir_graph *save = get_current_ir_graph ();
-
- set_current_ir_graph (graph);
- irg_walk (get_irg_end (graph), find_irg_arg, NULL, arg_env);
- set_current_ir_graph (save);
- }
-
- memset (arg_env, 0x00, sizeof (find_irg_args_env_t));
- free (arg_env);
-
- args [n_args] = NULL;
-
- return (args);
-}
-
-/* Get the entity of a ptr */
-ir_entity *get_ptr_ent (ir_node *ptr)
-{
- ir_entity *ent = NULL;
- const ir_opcode ptr_op = get_irn_opcode (ptr);
- switch (ptr_op) {
- case (iro_Cast): {
- ent = get_ptr_ent (get_Cast_op (ptr));
- } break;
- case (iro_Sel): {
- ent = get_Sel_entity (ptr);
- } break;
-
- case (iro_SymConst): {
- ent = get_SymConst_entity (ptr);
- } break;
-
- default: {
- fprintf (stderr, "%s: no ent for ptr=%s[%ld]\n",
- __FUNCTION__,
- get_op_name (get_irn_op (ptr)),
- get_irn_node_nr (ptr));
- assert (0);
- }
- }
-
- return (ent);
-}
-
-/* Check whether the load of the given ptr is a dummy */
-int is_dummy_load_ptr (ir_node *ptr)
-{
- const ir_opcode ptr_op = get_irn_opcode (ptr);
-
- switch (ptr_op) {
- case (iro_Cast): {
- return (is_dummy_load_ptr (get_Cast_op (ptr)));
- } break;
- case (iro_Sel):
- case (iro_SymConst): {
- return (FALSE);
- } break;
-
- default: {
- return (TRUE);
- }
- }
-}
-
-\f
-/*
- $Log$
- Revision 1.19 2007/01/16 15:45:42 beck
- renamed type opcode to ir_opcode
-
- Revision 1.18 2006/12/13 19:46:47 beck
- rename type entity into ir_entity
-
- Revision 1.17 2006/06/08 10:49:07 beck
- renamed type to ir_type
-
- Revision 1.16 2005/01/14 14:13:32 liekweg
- fix gnu extension
-
- Revision 1.15 2005/01/10 17:26:34 liekweg
- fixup printfs, don't put environments on the stack
-
- Revision 1.14 2004/12/23 15:47:09 beck
- removed uneeded allocations
- used new xcalloc
-
- Revision 1.13 2004/12/22 14:43:14 beck
- made allocations C-like
-
- Revision 1.12 2004/12/21 15:53:12 beck
- removed GNUC constructs
-
- Revision 1.11 2004/12/20 17:34:35 liekweg
- fix recursion handling
-
- Revision 1.10 2004/12/06 12:55:06 liekweg
- actually iterate
-
- Revision 1.9 2004/12/02 16:17:51 beck
- fixed config.h include
-
- Revision 1.8 2004/11/26 15:59:14 liekweg
- recognize dummy loads
-
- Revision 1.7 2004/11/24 14:53:56 liekweg
- Bugfixes
-
- Revision 1.6 2004/11/18 16:37:07 liekweg
- rewrite
-
-
-*/
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Utilitites for PTO
- * @author Florian
- * @date Sat Nov 13 19:35:27 CET 2004
- * @version $Id$
- */
-# ifndef FIRM_ANA2_PTO_UTIL_H
-# define FIRM_ANA2_PTO_UTIL_H
-
-# include "irnode.h"
-# include "entity.h"
-
-/* ===================================================
- Global Defines:
- =================================================== */
-
-/* ===================================================
- Global Data Types:
- =================================================== */
-
-/* ===================================================
- Global Prototypes:
- =================================================== */
-/** Get the entity of a ptr. */
-ir_entity *get_ptr_ent (ir_node *ptr);
-
-/**
- * Find the arguments of a graph. For a method that has n args, the
- * result array has 'n+1' entries, the last of which is written NULL.
- *
- * @param irg The IR graph
- */
-ir_node **find_irg_args (ir_graph *irg);
-
-/* Check whether the load of the given ptr is a dummy */
-int is_dummy_load_ptr (ir_node*);
-
-/* ===================================================
- Global Variables:
- =================================================== */
-
-
-# endif /* not defined _PTO_UTIL_ */
-
-
-\f
-/*
- $Log$
- Revision 1.8 2006/12/13 19:46:47 beck
- rename type entity into ir_entity
-
- Revision 1.7 2005/06/17 17:43:52 beck
- added doxygen docu
-
- Revision 1.6 2004/11/26 15:59:14 liekweg
- recognize dummy loads
-
- Revision 1.5 2004/11/24 14:53:56 liekweg
- Bugfixes
-
- Revision 1.4 2004/11/18 16:37:07 liekweg
- rewrite
-
-
-*/
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief yet another set implementation
- * @author Florian
- * @date Mon 18 Oct 2004
- * @version $Id$
- */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-# include <stdio.h>
-# include <stdlib.h>
-# include <assert.h>
-# include <string.h>
-
-# include "obst.h"
-# include "timing.h"
-# include "qset.h"
-
-/* local globals */
-int qset_id = 0;
-
-/* local protos */
-
-# ifdef UNSINN
-/* Check whether the given list of sortables is sorted. */
-static void q_check (sortable_t*, const int);
-# endif /* defined UNSINN */
-
-/* Test whether the given val is among values. Return the index of
- val in values, or -1. */
-static int q_test (sortable_t*, const sortable_t, const int);
-
-/* Sort n_elems entries in 'values' */
-static void q_sort (sortable_t*, const int);
-
-/* Compare funktion, meant to be qsort(3)-compatible */
-static INLINE int sortable_compare (const void *pa, const void *pb)
-{
- const int a = * (unsigned int*) pa;
- const int b = * (unsigned int*) pb;
-
- if (a==b) {
- return (0);
- }
-
- return ((a < b) ? -1 : +1);
-}
-
-/*
- Wrapper for mixed allocation
-*/
-static void *mix_malloc (struct obstack *obst, size_t size)
-{
- if (NULL != obst) {
- return (obstack_alloc (obst, size));
- } else {
- return (xmalloc (size));
- }
-}
-
-/*
- Allocate a list of sortables of the given length.
-*/
-static sortable_t *alloc_list (const int len, struct obstack *obst)
-{
- sortable_t *values = (sortable_t*) mix_malloc (obst, len * sizeof (sortable_t));
-
- memset (values, 0x00, len * sizeof (sortable_t));
-
- return (values);
-}
-
-# ifdef UNSINN
-/*
- Create a list of sortables of the given length.
-*/
-static sortable_t *gen_list (const int len, struct obstack *obst)
-{
- int i;
- sortable_t *values = alloc_list (len, obst);
-
- for (i = 0; i < len; i ++) {
- values [i] = rand () >> 16;
- }
-
- return (values);
-}
-# endif /* defined UNSINN */
-
-/*
- Helper to q_test --- return the index of val in values, or -1
-*/
-static int _q_test (sortable_t *values,
- const sortable_t val,
- const int lo, const int hi)
-{
- int mid;
-
- /* fprintf (stdout, "%s for %d [%i:%i]\n", __FUNCTION__, val, lo, hi); */
-
- if (lo == hi) {
- if (EQUAL (val, values [lo])) {
- return (lo);
- } else {
- return (-1);
- }
- }
-
- if (COMPARE (val, values [lo])) {
- /* too low */
- return (-1);
- }
-
- if (COMPARE (values [hi], val)) {
- /* too high */
- return (-1);
- }
-
- mid = (hi + lo) / 2;
-
- if (EQUAL (val, values [mid])) {
- return (mid);
- }
-
- if (COMPARE (val, values [mid])) {
- return (_q_test (values, val, lo, mid));
- } else {
- return (_q_test (values, val, mid+1, hi));
- }
-}
-
-/*
- Helper to q_sort
-*/
-static void _q_sort (sortable_t *values, const int lo, const int hi)
-{
- sortable_t pivot;
- int p_lo;
- int p_hi;
-
- /* handle base case: */
- if (lo >= hi) {
- return;
- }
-
- if (1 == hi - lo) {
- if (COMPARE (values [hi], values [lo])) {
- sortable_t tmp = values [lo];
- values [lo] = values [hi];
- values [hi] = tmp;
- }
-
- return;
- }
-
- pivot = values [lo];
-
- p_lo = lo+1;
- p_hi = hi;
-
- while (p_lo <= p_hi) {
- if (COMPARE (values [p_lo], pivot)) {
- values [p_lo-1] = values [p_lo];
-
- p_lo ++;
- } else {
- sortable_t tmp = values [p_lo];
-
- values [p_lo] = values [p_hi];
- values [p_hi] = tmp;
-
- p_hi --;
- }
- }
-
- values [p_lo-1] = pivot;
-
- _q_sort (values, lo, p_lo-1);
- _q_sort (values, p_lo, hi);
-}
-
-# ifdef UNSINN
-/*
- Little test harness for q_sort and friends.
-*/
-static void test_qsort (const int n_runs, const int max_elems, const int incr)
-{
- int n_elems = 0;
- int i;
-
- fprintf (stdout, "# n_elems: q_sort time : libc qsort time\n");
-
- while (n_elems <= max_elems) {
- int total = 0;
- int qtotal = 0;
-
- for (i = 0; i < n_runs; i ++) {
- sortable_t *list = gen_list (n_elems, NULL);
-
- timing_t *timing = start_timing ();
- q_sort (list, n_elems);
- total += end_timing (timing);
-
- q_check (list, n_elems);
-
- free (list);
- }
-
- for (i = 0; i < n_runs; i ++) {
- sortable_t *list = gen_list (n_elems, NULL);
-
- timing_t *timing = start_timing ();
- qsort (list, n_elems, sizeof (sortable_t), sortable_compare);
- qtotal += end_timing (timing);
-
- q_check (list, n_elems);
-
- free (list);
- }
-
- fprintf (stdout, "%d %d %d\n", n_elems, total/n_runs, qtotal/n_runs);
- fflush (stdout);
- n_elems += incr;
- }
-
-
- fprintf (stdout, "\n");
-}
-
-/*
- Little test harness for the qset implementation
-*/
-static void test_qset (const int n_entries)
-{
- int i;
- int n1, n2, n;
-
- qset_t *q1 = qset_new (n_entries, NULL);
- qset_t *q2 = qset_new (n_entries, NULL);
- qset_t *q = NULL;
-
- sortable_t *values = gen_list (n_entries, NULL);
-
- for (i = 0; i < n_entries; i ++) {
- qset_insert (q1, values [i]);
- qset_insert (q2, values [i]);
- }
-
- fprintf (stdout, "q1: \t\t");
- qset_print (q1, stdout);
- qset_sort (q1);
- qset_sort (q2);
-
- /* TEST */
- q2->is_sorted = FALSE;
- qset_sort (q2);
-
- fprintf (stdout, "q1 (sorted):\t");
- qset_print (q1, stdout);
-
- assert (qset_compare (q1, q2));
-
- q = qset_union (q1, q2);
- fprintf (stdout, "qq (union):\t");
- qset_print (q, stdout);
-
- n1 = qset_size (q1);
- n2 = qset_size (q2);
- n = qset_size (q);
-
- fprintf (stdout, "q1.size = %i\n", n1);
- fprintf (stdout, "q1.slots = %i\n", q1->n_slots);
- fprintf (stdout, "q2.size = %i\n", n2);
- fprintf (stdout, "q2.slots = %i\n", q2->n_slots);
- fprintf (stdout, "q.size = %i\n", n);
- fprintf (stdout, "q.slots = %i\n", q->n_slots);
-
- assert (n1 == n2);
- assert (n2 == n);
-
- assert (qset_compare (q1, q2));
- assert (qset_compare (q2, q));
- assert (qset_compare (q, q1));
-
- for (i = 0; i < n_entries; i ++) {
- assert (qset_contains (q1, values [i]));
- assert (qset_contains (q2, values [i]));
- assert (qset_contains (q, values [i]));
- }
-
- qset_compact (q1);
- qset_compact (q);
-
- fprintf (stdout, "q1.size = %i\n", n1);
- fprintf (stdout, "q1.slots = %i\n", q1->n_slots);
- fprintf (stdout, "q2.size = %i\n", n2);
- fprintf (stdout, "q2.slots = %i\n", q2->n_slots);
- fprintf (stdout, "q.size = %i\n", n);
- fprintf (stdout, "q.slots = %i\n", q->n_slots);
-
- assert (qset_compare (q1, q2));
- assert (qset_compare (q2, q));
- assert (qset_compare (q, q1));
-
- for (i = 0; i < n_entries; i ++) {
- assert (qset_contains (q1, values [i]));
- assert (qset_contains (q2, values [i]));
- assert (qset_contains (q, values [i]));
- }
-
- qset_delete (q);
- qset_delete (q1);
- qset_delete (q2);
-}
-# endif /* defned UNSINN */
-
-/* PRIVATE QSET IMPLEMENTATION */
-/*
- Resize a qset to (at least) the given size.
-*/
-static void qset_resize (qset_t *qset, const int n_slots)
-{
- int new_size;
- sortable_t *values = NULL;
-
- if (qset->n_slots >= n_slots) {
- return;
- }
-
- new_size = qset->n_slots;
-
- while (new_size < n_slots) {
- new_size *= 2;
- }
-
- values = alloc_list (new_size, qset->obst);
-
- memcpy (values, qset->values, qset->n_elems * sizeof (sortable_t));
- memset (qset->values, 0x00, qset->n_elems * sizeof (sortable_t)); /* debug only */
-
- if (NULL == qset->obst) {
- free (qset->values);
- }
-
- qset->values = values;
- qset->n_slots = new_size;
-}
-
-/*
- Print a list of sortables.
-*/
-static void q_print (sortable_t *values, const int n_values, FILE *stream)
-{
- int i;
-
- fprintf (stream, "{");
-
- for (i = 0; i < n_values; i ++) {
- if (0 == values [i]) {
- fprintf (stream, "_");
- } else {
- fprintf (stream, "0x08%x", (int) values [i]);
- }
-
- if (i + 1 != n_values) {
- fprintf (stream, ", ");
- }
- }
-
- fprintf (stream, "}\n");
-}
-
-# ifdef UNSINN
-/*
- Check whether the given list of sortables is sorted.
-*/
-static void q_check (sortable_t *values, const int n_values)
-{
- int i;
-
- for (i = 1; i < n_values; i ++) {
- assert (COMPARE (values [i-1], values [i]) ||
- EQUAL (values [i-1], values [i]));
- }
-
- for (i = 1; i < n_values; i ++) {
- assert (-1 != q_test (values, values [i], n_values));
- }
-}
-# endif /* defined UNSINN */
-
-/*
- Test whether the given val is among values. Return the lowest index of val
- in values, or -1.
-*/
-static int q_test (sortable_t *values, const sortable_t val, const int n_elems)
-{
- int idx = _q_test (values, val, 0, n_elems-1);
-
- while ((0 <= idx-1) && EQUAL (values [idx], val)) {
- idx --;
- }
-
- return (idx);
-}
-
-/*
- Sort entries in 'values' from index 'lo' to 'hi' (inclusive)
-*/
-static void q_sort (sortable_t *values, const int n_elems)
-{
- _q_sort (values, 0, n_elems-1);
-}
-
-/* PUBLIC INTERFACE */
-
-/*
- Allocate a new qset with initial space for up to n_elems.
- If a non-NULL obstack is given, it is used for all allocations of this qset
- and must be initialised and deleted by the user of the qset.
-*/
-qset_t *qset_new (const int n_elems, struct obstack *obst)
-{
- qset_t *qset = (qset_t*) mix_malloc (obst, sizeof (qset_t));
-
- qset->obst = obst;
- qset->values = alloc_list (n_elems, obst);
- memset (qset->values, 0x00, n_elems * sizeof (sortable_t));
-
- qset->n_slots = n_elems;
- qset->n_elems = 0;
- qset->is_sorted = FALSE;
- qset->id = qset_id ++;
-
- return (qset);
-}
-
-/*
- Sort the entries of the given qset.
-*/
-void qset_sort (qset_t *qset)
-{
- int occ = 0;
- int i;
-
- if (qset->is_sorted) {
- return;
- }
-
- q_sort (qset->values, qset->n_elems);
-
- for (i = 1; i < qset->n_elems; i ++) {
- if (! EQUAL (qset->values [i], qset->values [occ])) {
- qset->values [++ occ] = qset->values [i];
- }
- }
-
- occ ++;
-
- /*
- if (qset->n_elems != occ) {
- fprintf (stdout, "removed %i duplicates\n", qset->n_elems - occ);
- }*/
-
- qset->n_elems = occ;
-
- qset->is_sorted = TRUE;
-}
-
-/*
- Compact a qset to take up no more space than required.
-*/
-void qset_compact (qset_t *qset)
-{
- if (NULL == qset->obst) {
- sortable_t *values = (sortable_t*) mix_malloc (qset->obst,
- qset->n_elems * sizeof (sortable_t));
- memcpy (values, qset->values, qset->n_elems * sizeof (sortable_t));
-
- memset (qset->values, 0x00, qset->n_elems * sizeof (sortable_t));
-
- free (qset->values);
-
- qset->values = values;
- qset->n_slots = qset->n_elems;
- }
-}
-
-/*
- Free the memory associated with the given qset
-*/
-void qset_delete (qset_t *qset)
-{
- memset (qset->values, 0x00, qset->n_elems * sizeof (sortable_t));
-
- if (NULL == qset->obst) {
- free (qset->values);
- }
-
- memset (qset, 0x00, sizeof (qset_t));
-
- if (NULL == qset->obst) {
- free (qset);
- }
-}
-
-/*
- Test whether the given qset contains the given value.
-*/
-int qset_contains (qset_t *qset, sortable_t val)
-{
- qset_sort (qset);
-
- return (-1 != q_test (qset->values, val, qset->n_elems));
-}
-
-/*
- Delete the given value from the given qset (if it exists)
-*/
-void qset_remove (qset_t *qset, sortable_t val)
-{
- int idx;
- int occ = 0;
- int i;
-
- qset_sort (qset);
-
- idx = q_test (qset->values, val, qset->n_elems);
-
- if (-1 == idx) {
- return;
- }
-
- while (EQUAL (qset->values [idx + occ], val)) {
- occ ++;
- }
-
- for (i = idx; i < qset->n_elems - occ; i ++) {
- qset->values [i] = qset->values [i+occ];
- }
-
- qset->n_elems -= occ;
-}
-
-/*
- Insert the given elem into the given qset; return nonzero iff any
- involved values change.
-*/
-int qset_insert (qset_t *qset, sortable_t val)
-{
- int i;
- const int n_elems = qset->n_elems;
-
- /* todo: sort, find */
- assert (0 != val);
-
- for (i = 0; i < n_elems; i ++) {
- if (EQUAL (val, qset->values [i])) {
- return (FALSE);
- }
- }
-
- qset_resize (qset, qset->n_elems+1);
-
- /* qset_print (qset, stdout); */
- /* fprintf (stdout, "%s: must insert 0x%08x\n", __FUNCTION__, (void*) val); */
-
- qset->values [qset->n_elems++] = val;
- qset->is_sorted = FALSE;
-
- return (TRUE);
-}
-
-/*
- Insert all elems of qset2 into qset1; return nonzero iff any
- involved values change. qset2 is *not* deleted.
-*/
-int qset_insert_all (qset_t *qset1, qset_t *qset2)
-{
- int change = FALSE;
- sortable_t val = qset_start (qset2);
-
- while (0 != val) {
- change |= qset_insert (qset1, val);
-
- val = qset_next (qset2);
- }
-
- qset_sort (qset1);
-
- return (change);
-}
-
-/*
- Compare two qsets.
-*/
-int qset_compare (qset_t *qset1, qset_t *qset2)
-{
- int i;
- const int n_elems = qset1->n_elems;
-
- qset_sort (qset1);
- qset_sort (qset2);
-
- if (qset1->n_elems != qset2->n_elems) {
- return (FALSE);
- }
-
- for (i = 0; i < n_elems; i ++) {
- if (qset1->values [i] != qset2->values [i]) {
- return (FALSE);
- }
- }
-
- return (TRUE);
-}
-
-/*
- Returns the union of two qsets.
-*/
-qset_t *qset_union (qset_t *qset1, qset_t *qset2)
-{
- qset_t *qset = (qset_t*) mix_malloc (qset1->obst, sizeof (qset_t));
- const int n_elems = qset1->n_elems + qset2->n_elems;
-
- qset->values = alloc_list (n_elems, qset1->obst);
-
- memcpy (qset->values, qset1->values,
- qset1->n_elems * sizeof (sortable_t));
-
- memcpy (qset->values+qset1->n_elems,
- qset2->values, qset2->n_elems * sizeof (sortable_t));
-
- qset->obst = qset1->obst;
- qset->n_elems = n_elems;
- qset->n_slots = qset->n_elems;
-
- qset_sort (qset);
-
- return (qset);
-}
-
-/*
- Report the size of the given qset.
-*/
-int qset_size (qset_t *qset)
-{
- return (qset->n_elems);
-}
-
-/*
- Print the given qset to the given stream.
-*/
-void qset_print (qset_t *qset, FILE *stream)
-{
- q_print (qset->values, qset->n_elems, stream);
-}
-
-/*
- Check wether the given qset is empty
-*/
-int qset_is_empty (qset_t *qset)
-{
- return (0 == qset->n_elems);
-}
-
-/*
- Initialise a new iteration over a qset
-*/
-sortable_t *qset_start (qset_t *qset)
-{
- sortable_t *start;
-
- qset->cursor = 0;
-
- start = qset_next (qset);
-
- return (start); /* works for empty sets, too */
-}
-
-/*
- Step to the next element
-*/
-sortable_t *qset_next (qset_t *qset)
-{
- if (qset->n_elems == qset->cursor) {
- return (NULL);
- }
-
- /* quick fix to skip NULL entries */
- while ((qset->cursor < qset->n_elems) &&
- (NULL == qset->values [qset->cursor])) {
- qset->cursor ++;
- }
-
- return (qset->values [qset->cursor++]);
-}
-
-
-# ifdef UNSINN
-int qset_test_main (int argc, char **argv)
-{
- struct timeval tp;
- unsigned int seed;
-
- if (-1 == gettimeofday (&tp, NULL)) {
- perror ("gettimeofday");
- exit (EXIT_FAILURE);
- }
-
- seed = (unsigned int) tp.tv_usec;
- srand (seed);
-
- /* test_qsort (20, 1000000, 100000); */
-
- test_qset (atoi (argv [1]));
-
- exit (EXIT_SUCCESS);
-}
-# endif /* defined UNSINN */
-
-/*
- $Log$
- Revision 1.12 2006/06/06 12:06:27 beck
- use xmalloc instead of malloc
-
- Revision 1.11 2005/06/22 09:34:11 beck
- typo fixed
-
- Revision 1.10 2004/12/21 15:37:31 beck
- added config.h include
- removed unused sys/times.h
- removed C99 constructs
-
- Revision 1.9 2004/12/20 17:34:35 liekweg
- fix recursion handling
-
- Revision 1.8 2004/12/06 12:49:26 liekweg
- virtually no change
-
- Revision 1.7 2004/11/30 14:47:11 liekweg
- insert report changes
-
- Revision 1.6 2004/11/26 15:58:30 liekweg
- don't free inside obstacks (thx, michael)
-
- Revision 1.5 2004/11/24 14:53:56 liekweg
- Bugfixes
-
- Revision 1.4 2004/11/18 16:35:45 liekweg
- Added unique ids for debugging
-
- Revision 1.3 2004/11/09 16:45:36 liekweg
- print pointers
-
- Revision 1.2 2004/11/08 12:32:00 liekweg
- Moved q_* methods into private section
-
- Revision 1.1 2004/11/04 14:55:13 liekweg
- added qset
-
-
- */
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief yet another set implementation
- * @author Florian
- * @date Mon 18 Oct 2004
- * @version $Id$
- */
-#ifndef FIRM_ANA2_QSET_H
-#define FIRM_ANA2_QSET_H
-
-# ifndef TRUE
-# define TRUE 1
-# define FALSE 0
-# endif /* nof defined TRUE */
-
-/* define this as needed */
-# define COMPARE(A,B) (A<B)
-# define EQUAL(A,B) (A==B)
-/* typedef unsigned int sortable_t; */
-typedef void* sortable_t;
-
-struct obstack; /* forward decl */
-
-typedef struct qset_str
-{
- struct obstack *obst;
- sortable_t *values;
- int n_slots;
- int n_elems;
- int is_sorted;
- int cursor; /* for qset_start/qset_next */
- int id;
-} qset_t;
-
-
-/* QSET INTERFACE */
-
-/* Allocate a new qset with initial space for up to n_elems.
- If a non-NULL obstack is given, it is used for all allocations of this qset
- and must be initialised and deleted by the user of the qset. */
-qset_t *qset_new (const int, struct obstack*);
-
-/* Sort the entries of the given qset. */
-void qset_sort (qset_t*);
-
-/* Compact a qset to take up no more space than required. */
-void qset_compact (qset_t*);
-
-/* Free the memory associated with the given qset */
-void qset_delete (qset_t*);
-
-/* Test whether the given qset contains the given value. */
-int qset_contains (qset_t*, sortable_t);
-
-/* Delete the given value from the given qset (if it exists) */
-void qset_remove (qset_t*, sortable_t);
-
-/* Insert the given elem into the given qset; return nonzero iff any involved values change. */
-int qset_insert (qset_t*, sortable_t);
-
-/* Insert all elems of qset2 into qset1. qset2 is deleted; return
- nonzero iff any involved values change. */
-int qset_insert_all (qset_t*, qset_t*);
-
-/* Compare two qsets. */
-int qset_compare (qset_t*, qset_t*);
-
-/* Returns the union of two qsets. */
-qset_t *qset_union (qset_t *qset1, qset_t *qset2);
-
-/* Report the size of the given qset. */
-int qset_size (qset_t *qset);
-
-/* Print the given qset to the given stream. */
-void qset_print (qset_t*, FILE*);
-
-/* Check wether the given qset is empty */
-int qset_is_empty (qset_t*);
-
-/*
- Iterate over a qset
-*/
-/* initialise the iteration, return the first element */
-sortable_t *qset_start (qset_t*);
-/* step to the next element, return NULL iff no more elems are available */
-sortable_t *qset_next (qset_t*);
-
-#endif
-
-/*
- $Log$
- Revision 1.5 2004/11/30 14:47:11 liekweg
- insert report changes
-
- Revision 1.4 2004/11/24 14:53:56 liekweg
- Bugfixes
-
- Revision 1.3 2004/11/18 16:35:46 liekweg
- Added unique ids for debugging
-
- Revision 1.2 2004/11/08 12:32:00 liekweg
- Moved q_* methods into private section
-
- Revision 1.1 2004/11/04 14:55:13 liekweg
- added qset
-
-
-*/
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief generic timing routines
- * @author Florian
- * @date Mon 18 Oct 2004
- * @version $Id$
- * @note
- * Timing stuff. Not really part of ana2, but where else should it go.
- */
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "timing.h"
-#include "xmalloc.h"
-
-struct timing_env
-{
- struct timeval *start;
- struct timeval *end;
-};
-
-#ifdef _WIN32
-/* no support yet */
-timing_t *start_timing (void) {}
-int end_timing (timing_t *t) {}
-
-#else
-#include <sys/time.h>
-
-
-/*
-Helpers
-*/
-static int
-timeval_subtract (struct timeval *x, struct timeval *y)
-{
- /* Perform the carry for the later subtraction by updating Y. */
- if (x->tv_usec < y->tv_usec) {
- int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1;
- y->tv_usec -= 1000000 * nsec;
- y->tv_sec += nsec;
- }
-
- if (x->tv_usec - y->tv_usec > 1000000) {
- int nsec = (x->tv_usec - y->tv_usec) / 1000000;
- y->tv_usec += 1000000 * nsec;
- y->tv_sec -= nsec;
- }
-
- return ((x->tv_sec - y->tv_sec) * 1000000 + (x->tv_usec - y->tv_usec));
-}
-
-
-/*
- Public Interface
-*/
-timing_t *
-start_timing (void)
-{
- timing_t *t = (timing_t*) xmalloc (sizeof (timing_t));
-
- t->start = (struct timeval*) xmalloc (sizeof (struct timeval));
- t->end = (struct timeval*) xmalloc (sizeof (struct timeval));
-
- gettimeofday (t->start, NULL);
-
- return (t);
-}
-
-int
-end_timing (timing_t *t)
-{
- int time;
-
- gettimeofday (t->end, NULL);
-
- time = timeval_subtract (t->end, t->start);
-
- memset (t->start, 0x0, sizeof (struct timeval));
- free (t->start);
-
- memset (t->end, 0x0, sizeof (struct timeval));
- free (t->end);
-
- memset (t, 0x00, sizeof (timing_t));
- free (t);
-
- return (time);
-}
-#endif /* _WIN32 */
-
-
-/*
- $Log$
- Revision 1.5 2006/09/12 12:17:37 matze
- more warning fixes
-
- Revision 1.4 2006/06/06 12:06:27 beck
- use xmalloc instead of malloc
-
- Revision 1.3 2005/01/05 14:25:38 beck
- added Win32 "support"
-
- Revision 1.2 2004/12/21 15:52:23 beck
- moved struct timing_env to .c file, added config.h
-
- Revision 1.1 2004/10/29 18:55:52 liekweg
- (mostly) generic timimg
-*/
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief generic timing routines
- * @author Florian
- * @date Mon 18 Oct 2004
- * @version $Id$
- */
-#ifndef FIRM_ANA2_TIMING_H
-#define FIRM_ANA2_TIMING_H
-
-/*
- Data structures
- */
-typedef struct timing_env timing_t;
-
-/*
- Protos
-*/
-timing_t *start_timing (void);
-int end_timing (timing_t*);
-
-#endif
-
-\f
-/*
- $Log$
- Revision 1.2 2004/12/21 15:52:23 beck
- moved struct timing_env to .c file, added config.h
-
- Revision 1.1 2004/10/29 18:55:52 liekweg
- (mostly) generic timimg
-
-
-*/
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Pto
- * @author Florian
- * @date Mon 18 Oct 2004
- * @version $Id$
- */
-# ifdef HAVE_CONFIG_H
-# include "config.h"
-# endif
-
-# include "typalise.h"
-
-# ifndef TRUE
-# define TRUE 1
-# define FALSE 0
-# endif /* not defined TRUE */
-
-# include <assert.h>
-
-#ifdef HAVE_STRING_H
-# include <string.h>
-#endif
-
-# include "irnode_t.h"
-# include "irgwalk.h"
-# include "xmalloc.h"
-# include "gnu_ext.h"
-# include "irdump.h"
-# include "typewalk.h"
-
-
-/*
- Local Globals
-*/
-
-static long ta_id = 0;
-
-/*
- Local Protos
-*/
-static typalise_t *typalise_proj (ir_node*);
-
-/* DEBUGGING only */
-static void cough_and_die (ir_node *node)
-{
- ir_graph *graph = get_irn_irg (node);
-
- fprintf (stdout, "%s: %s[%li]\n",
- __FUNCTION__,
- get_op_name (get_irn_op (node)),
- get_irn_node_nr (node));
- dump_ir_block_graph (graph, "-typealise");
- assert (0);
-}
-
-/*
- Exception b/d
-*/
-static ir_type *java_lang_Throwable_tp = NULL;
-
-static ir_type *get_java_lang_Throwable (void)
-{
- assert (NULL != java_lang_Throwable_tp);
-
- return (java_lang_Throwable_tp);
-}
-
-static void find_java_lang_Throwable (ir_type *tp, void *_unused)
-{
- const char *name = get_type_name (tp);
-
- if (0 == strcmp (name, "java/lang/Throwable")) {
- assert (NULL == java_lang_Throwable_tp);
-
- java_lang_Throwable_tp = tp;
- }
-}
-
-
-/*
- Ctors, Dtors for typalise_t-s
-*/
-static typalise_t *ta_exact (ir_type *tp)
-{
- typalise_t *ta = xmalloc (sizeof (typalise_t));
- ta->kind = type_exact;
- ta->res.type = tp;
- ta->id = ta_id ++;
-
- assert (is_Class_type (tp));
-
- return (ta);
-}
-
-static typalise_t *ta_types (lset_t *set)
-{
- typalise_t *ta = xmalloc (sizeof (typalise_t));
- ta->kind = type_types;
- ta->res.types = set;
- ta->id = ta_id ++;
-
- return (ta);
-}
-
-static typalise_t *ta_type (ir_type *tp)
-{
- typalise_t *ta = xmalloc (sizeof (typalise_t));
- ta->kind = type_type;
- ta->res.type = tp;
- ta->id = ta_id ++;
-
- assert (is_Class_type (tp));
-
- return (ta);
-}
-
-static void ta_delete (typalise_t *ta)
-{
- if (type_types == ta->kind) {
- lset_destroy (ta->res.types);
- ta->res.types = NULL;
- } else {
- ta->res.type = NULL;
- }
-
- ta->kind = type_invalid;
-
- free (ta);
-}
-
-/*
- Helpers for inheritance, overwriting and stuff
-*/
-/**
- Find out whether otype is a subtype of stype.
- Return non-zero iff otype is a subtype of stype.
-*/
-static int is_subtype (ir_type *otype, ir_type *stype)
-{
- int n_sub = get_class_n_subtypes (stype);
- int is_sub = FALSE;
- int i;
-
- if (otype == stype) {
- return (TRUE);
- }
-
- for (i = 0; (!is_sub) && (i < n_sub); i ++) {
- ir_type *sub = get_class_subtype (stype, i);
-
- is_sub |= is_subtype (otype, sub);
- }
-
-
- return (is_sub);
-}
-
-
-/**
- Compute the closure of all subtypes of otype (including otype
- itself)
-*/
-static void _collect_subtypes (ir_type *otype, lset_t *set)
-{
- int i, n_sub;
-
- lset_insert (set, otype);
-
- n_sub = get_class_n_subtypes (otype);
- for (i = 0; i < n_sub; i ++) {
- ir_type *sub = get_class_subtype (otype, i);
-
- _collect_subtypes (sub, set);
- }
-}
-
-static lset_t *subtype_closure (ir_type *otype)
-{
- lset_t *set = lset_create ();
-
- _collect_subtypes (otype, set);
-
- return (set);
-}
-
-/**
- Helper method for get_owner_types
-*/
-static void _collect_owner_types (ir_entity *method, ir_graph *graph, lset_t *tps)
-{
- int i, n_over;
-
- /* search DOWNwards in clazz hierarchy */
-
- if ((peculiarity_description == get_entity_peculiarity (method)) ||
- (peculiarity_inherited == get_entity_peculiarity (method))) {
- lset_insert (tps, get_entity_owner (method));
- } else if (peculiarity_existent == get_entity_peculiarity (method)) {
- ir_graph *ex_graph = get_entity_irg (method);
-
- if ((NULL == ex_graph) || (ex_graph == graph)) {
- /* wtf? they define the same graph again? well, whatever: */
- lset_insert (tps, get_entity_owner (method));
- } else {
- /* aha: they define a new graph. can't have that, so bail out */
- return;
- }
- }
-
- n_over = get_entity_n_overwrittenby (method);
- for (i = 0; i < n_over; i ++) {
- ir_entity *ometh = get_entity_overwrittenby (method, i);
-
- _collect_owner_types (ometh, graph, tps);
- }
-}
-
-
-/**
- Collect all classes that use the given implementation of a method.
-*/
-static lset_t *get_owner_types (ir_graph *graph)
-{
- lset_t *tps = lset_create ();
- ir_entity *meth = get_irg_entity (graph);
-
- _collect_owner_types (meth, graph, tps);
-
- return (tps);
-}
-
-/**
- Return a list containing all types of 'set' which are a subtype of 'type'.
-*/
-static lset_t *filter_for_type (lset_t *set, ir_type *stype)
-{
- ir_type *curs = (ir_type*) lset_first (set);
- lset_t *lset = lset_create ();
-
- while (NULL != curs) {
- if (is_subtype (curs, stype)) {
- lset_insert (lset, curs);
- }
-
- curs = lset_next (set);
- }
-
- return (lset);
-}
-
-/*
- Handle typalise_t-s
-*/
-/**
- Join 'one' and 'two'; both args are deallocated, result is freshly
- allocated.
-*/
-static typalise_t *ta_join (typalise_t *one, typalise_t *two)
-{
- typalise_t *res = NULL;
-
- /* now, one==NULL or two==NULL cannot happen legitimately (if we hit a NULL pointer constant)
- if (NULL == one) {
- return (two);
- }
-
- if (NULL == two) {
- return (one);
- }
- */
- switch (one->kind) {
- case (type_invalid): { /* shut up, gcc */ }
- case (type_exact): {
- switch (two->kind) {
- case (type_invalid): { /* shut up, gcc */ }
- case (type_exact): {
- if (one->res.type == two->res.type) {
- res = one;
- } else {
- lset_t *set = lset_create ();
- lset_insert (set, one->res.type);
- lset_insert (set, two->res.type);
- res = ta_types (set);
-
- ta_delete (one);
- }
-
- ta_delete (two);
- } break;
- case (type_types): {
- lset_insert (two->res.types, one->res.type);
- ta_delete (one);
-
- res = two;
- } break;
- case (type_type): {
- if (is_subtype (one->res.type, two->res.type)) {
- ta_delete (one);
- res = two;
- } else {
- lset_t *closure = subtype_closure (two->res.type);
- lset_insert (closure, one->res.type);
-
- ta_delete (two);
-
- res = one;
- }
- } break;
- }
- } break;
- case (type_types): {
- switch (two->kind) {
- case (type_invalid): { /* shut up, gcc */ }
- case (type_exact): {
- res = ta_join (two, one);
- } break;
- case (type_types): {
- lset_insert_all (one->res.types, two->res.types);
- ta_delete (two);
-
- res = one;
- } break;
- case (type_type): {
- lset_t *closure = subtype_closure (two->res.type);
- lset_append (one->res.types, closure);
-
- ta_delete (two);
-
- res = one;
- } break;
- }
- } break;
- case (type_type): {
- switch (two->kind) {
- case (type_invalid): { /* shut up, gcc */ }
- case (type_exact): {
- res = ta_join (two, one);
- } break;
- case (type_types): {
- res = ta_join (two, one);
- } break;
- case (type_type): {
- ir_type *one_type = one->res.type;
- ir_type *two_type = two->res.type;
-
- if (is_subtype (one_type, two_type)) {
- ta_delete (one);
- res = two;
- } else if (is_subtype (two_type, one_type)) {
- ta_delete (two);
- res = one;
- } else {
- lset_t *one_closure = subtype_closure (one->res.type);
- lset_t *two_closure = subtype_closure (two->res.type);
-
- lset_append (one_closure, two_closure);
-
- ta_delete (two);
- ta_delete (one);
-
- res = ta_types (one_closure);
- }
- } break;
- }
- } break;
- }
-
- assert (res && "no result");
-
- return (res);
-}
-
-
-# ifdef SHUT_UP_GCC
-static const char *ta_name (typalise_t *ta)
-{
-# define BUF_SIZE 1024
- static char buf [BUF_SIZE];
-
- int len = sprintf (buf, "[%d] ", ta->id);
-
- switch (ta->kind) {
- case (type_invalid): { /* shut up, gcc */ }
- case (type_exact): {
- len += sprintf (buf+len, "only ");
- strncat (buf, get_type_name (ta->res.type), BUF_SIZE);
- } break;
- case (type_types): {
- len += sprintf (buf+len, "one_of ");
-
- ir_type *iter = lset_first (ta->res.types);
-
- int size = BUF_SIZE - len - 1;
- while ((NULL != iter) && (0 < size)) {
- char *dest = strncat (buf, get_type_name (iter), size);
- size = (dest - buf);
-
- iter = lset_next (ta->res.types);
- }
- } break;
- case (type_type): {
- len += sprintf (buf+len, "poly ");
- strncat (buf, get_type_name (ta->res.type), BUF_SIZE);
- } break;
- }
-
- return (buf);
- /* # undef BUF_SIZE */
-}
-# endif /* SHUT_UP_GCC */
-
-/**
- Find out whether the given clazz uses the given implementation of a
- method. Presumably, this is because clazz inherits the graph as
- the implementation for a method.
-*/
-static int uses_graph (ir_type *clazz, ir_entity *meth, ir_graph *graph)
-{
- ir_type *g_clazz = get_entity_owner (meth);
- int i, n_over, use = FALSE;
-
- if (g_clazz == clazz) {
- return (TRUE);
- }
-
- if (peculiarity_existent == get_entity_peculiarity (meth)) {
- ir_graph *g_graph = get_entity_irg (meth);
-
- if (g_graph != graph) {
- return (FALSE);
- }
- }
-
- /* else inherited or description */
- n_over = get_entity_n_overwrittenby (meth); /* DOWN-wards */
- for (i = 0; (i < n_over) && (!use); i ++) {
- ir_entity *over = get_entity_overwrittenby (meth, i);
-
- use |= uses_graph (clazz, over, graph);
- }
-
- return (use);
-}
-
-/**
- Check whether the given typalise_t includes the given type.
-*/
-static int ta_supports (typalise_t *ta, ir_graph *graph)
-{
- switch (ta->kind) {
- case (type_invalid): { /* shut up, gcc */ }
- case (type_exact): {
- int res = FALSE;
- lset_t *tps = get_owner_types (graph);
-
- if (lset_contains (tps, ta->res.type)) {
- res = TRUE;
- }
-
- lset_destroy (tps);
-
- return (res);
- }
- case (type_type): {
- ir_entity *meth = get_irg_entity (graph);
- ir_type *tp = get_entity_owner (meth);
- int res = is_subtype (tp, ta->res.type);
-
- if (res) {
- return (TRUE);
- } else {
- res = uses_graph (ta->res.type, meth, graph);
- }
-
- return (res);
- }
- case (type_types): {
- ir_type *tp = get_entity_owner (get_irg_entity (graph));
-
- return (lset_contains (ta->res.types, tp));
- }
- }
-
- assert (0 && "invalid ta");
- return FALSE;
-}
-
-
-/* =========== WHAT ELSE ? =========== */
-
-/*
- Helpers to typalise (ir_node*)
-*/
-/**
- Find an approximation to the given load node's value's types
-*/
-static typalise_t *typalise_call (ir_node *call)
-{
- ir_entity *ent = NULL;
- ir_type *tp = NULL;
- typalise_t *res = NULL;
- ir_node *call_ptr = get_Call_ptr (call);
-
- if (iro_Sel == get_irn_opcode (call_ptr)) {
- ent = get_Sel_entity (call_ptr);
- } else if (iro_SymConst == get_irn_opcode (call_ptr)) {
- if (get_SymConst_kind (call_ptr) == symconst_addr_ent) {
- ent = get_SymConst_entity (call_ptr);
- } else if (get_SymConst_kind (call_ptr) == symconst_addr_name) {
- ident *id = get_SymConst_name (call_ptr);
- const char *name = get_id_str (id);
- if (0 == strcmp (name, "iro_Catch")) {
- res = ta_type (java_lang_Throwable_tp);
-
- return (res);
- }
-
- fprintf (stdout, "%s: cannot handle Call[%li] (symconst_addr_name=\"%s\")\n",
- __FUNCTION__, get_irn_node_nr (call),
- name);
- cough_and_die (call_ptr);
- } else if (get_SymConst_kind (call_ptr) == symconst_type_tag) {
- fprintf (stdout, "%s: cannot handle Call[%li] (symconst_type_tag)\n",
- __FUNCTION__, get_irn_node_nr (call));
- cough_and_die (call_ptr);
- } else {
- fprintf (stdout, "%s: cannot handle Call[%li] (%i)\n",
- __FUNCTION__, get_irn_node_nr (call),
- get_SymConst_kind (call_ptr));
- cough_and_die (call_ptr);
- }
- }
-
- tp = get_entity_type (ent);
- assert (is_Method_type (tp));
-
- tp = get_method_res_type (tp, 0);
-
- while (is_Pointer_type (tp)) {
- tp = get_pointer_points_to_type (tp);
- }
-
- res = ta_type (tp);
-
- return (res);
-}
-
-
-/**
- Find an approximation to the given load node's value's types
-*/
-static typalise_t *typalise_load (ir_node *load)
-{
- ir_entity *ent = NULL;
- ir_type *tp = NULL;
- typalise_t *res = NULL;
- ir_node *load_ptr = get_Load_ptr (load);
-
- if (iro_Sel == get_irn_opcode (load_ptr)) {
- ent = get_Sel_entity (load_ptr);
- } else if (iro_SymConst == get_irn_opcode (load_ptr)) {
- if (get_SymConst_kind (load_ptr) == symconst_addr_ent) {
- ent = get_SymConst_entity (load_ptr);
- } else if (get_SymConst_kind (load_ptr) == symconst_type_tag) {
- tp = get_SymConst_type (load_ptr);
- } else {
- fprintf (stdout, "%s: cannot handle load (%s)\n",
- __FUNCTION__, get_op_name (get_irn_op (load_ptr)));
-
- cough_and_die (load_ptr);
- }
- } else {
- fprintf (stdout, "%s: cannot handle load (%s)\n",
- __FUNCTION__, get_op_name (get_irn_op (load_ptr)));
- cough_and_die (load_ptr);
- }
-
- tp = get_entity_type (ent);
-
- while (is_Pointer_type (tp)) {
- tp = get_pointer_points_to_type (tp);
- }
-
- res = ta_type (tp);
-
- return (res);
-}
-
-
-/**
- Find an approximation to the given proj node's value's types
-*/
-static typalise_t *typalise_proj (ir_node *proj)
-{
- typalise_t *res = NULL;
- ir_node *proj_in = get_Proj_pred (proj);
-
- if (iro_Proj == get_irn_opcode (proj_in)) {
- /* fprintf (stdout, "\tProj (Proj)\n"); */
-
- proj_in = get_Proj_pred (proj_in);
- if (iro_Start == get_irn_opcode (proj_in)) {
- /* aha, proj arg */
- ir_graph *graph = get_irn_irg (proj);
- ir_entity *meth = get_irg_entity (graph);
-
- long n = get_Proj_proj (proj);
- ir_type *tp = get_method_param_type (get_entity_type (meth), n);
- if (is_Pointer_type (tp)) {
- tp = get_pointer_points_to_type (tp);
- }
-
- res = ta_type (tp);
-
- } else if (iro_Call == get_irn_opcode (proj_in)) {
- /* call result ... 'whatever' */
- res = typalise_call (proj_in);
- } else {
- fprintf (stdout, "\n Proj (Proj (%s)) not handled\n",
- get_op_name (get_irn_op (proj_in)));
- cough_and_die (proj_in);
- }
- } else {
- ir_opcode op = get_irn_opcode (proj_in);
- if ((iro_Load != op) && (iro_Alloc != op) && (iro_Call != op)) {
- fprintf (stdout, "\n Proj (%s) not handled\n",
- get_op_name (get_irn_op (proj_in)));
- cough_and_die (proj_in);
- }
- res = typalise (proj_in); /* everything else */
- /* Proj (Load), Proj (New), Proj (Call) */
- }
-
- return (res);
-}
-
-
-
-/*
- Public Interface
-*/
-/**
- Given a set of graphs and a typalise_t, return the method (s) in
- the set that are supported by the typalise_t. Also, deallocates
- the given set.
-*/
-lset_t *filter_for_ta (lset_t *set, typalise_t *ta)
-{
- lset_t *res = lset_create ();
- ir_graph *curs = (ir_graph*) lset_first (set);
-
- while (NULL != curs) {
- if (ta_supports (ta, curs)) {
- lset_insert (res, curs);
- }
-
- curs = lset_next (set);
- }
-
- lset_destroy (set);
-
- return (res);
-}
-
-/**
- For the given ptr, do a quick check about what (class) types may be
- brought along on it.
-*/
-typalise_t *typalise (ir_node *node)
-{
- ir_opcode op = get_irn_opcode (node);
- typalise_t *res = NULL;
-
- switch (op) {
- case (iro_Cast): {
- /* casts always succeed */
- typalise_t *ta = NULL;
- ir_type *tp = get_Cast_type (node);
-
- if (is_Pointer_type (tp)) {
- tp = get_pointer_points_to_type (tp);
- }
- assert (is_Class_type (tp));
-
- ta = typalise (get_Cast_op (node));
-
- if (NULL == ta) { /* no type found */
- ta = ta_type (tp);
- } else if (type_exact == ta->kind) { /* one type found */
- /* nothing (maybe check cast? */
- } else if (type_type == ta->kind) { /* some types found */
- if (is_subtype (tp, ta->res.type)) {
- ta->res.type = tp; /* assume cast is correct */
- } else {
- /* should assert (is_subtype (ta->res.type, tp)) */
- }
- } else if (type_types == ta->kind) {
- lset_t *ftp = filter_for_type (ta->res.types, tp);
- lset_destroy (ta->res.types);
- ta->res.types = ftp;
- }
-
- res = ta;
- } break;
-
- case (iro_Proj): {
- res = typalise_proj (node);
- } break;
-
- case (iro_Load): {
- res = typalise_load (node);
- } break;
-
- case (iro_Sel): {
- /* FILTER */
- /* it's call (sel (ptr)) or load (sel (ptr)) */
- ir_entity *ent = get_Sel_entity (node);
- ir_type *tp = get_entity_type (ent);
-
- if (is_Method_type (tp)) {
- /* obsoleted by typalise_call */
- assert (0);
- tp = get_entity_type (ent);
- tp = get_method_res_type (tp, 0);
-
- if (is_Pointer_type (tp)) {
- tp = get_pointer_points_to_type (tp);
- }
-
- res = ta_type (tp);
- } else if (is_Class_type (tp)) {
- tp = get_entity_type (ent);
-
- if (is_Pointer_type (tp)) {
- tp = get_pointer_points_to_type (tp);
- }
-
- res = ta_type (tp);
- } else if (is_Pointer_type (tp)) {
- tp = get_pointer_points_to_type (tp);
- res = ta_type (tp);
- } else {
- assert (0 && "select not handled");
- }
- } break;
-
- case (iro_Phi): {
- int n_ins = get_irn_arity (node);
- int i;
- ir_node *phi_in = NULL;
- typalise_t *ta = NULL;
-
- for (i = 0; i < n_ins; i ++) {
- typalise_t *ta_in;
-
- phi_in = get_irn_n (node, i);
- ta_in = typalise (phi_in);
-
- if (NULL != ta_in) {
- ta = (NULL == ta) ? ta_in : ta_join (ta, ta_in);
- }
- }
-
- res = ta;
- } break;
-
- case (iro_Alloc): {
- ir_type *type = get_Alloc_type (node);
- res = ta_exact (type);
- } break;
-
- case (iro_Call): {
- /* presumably call (sel (proj (call))) */
- ir_node *ptr = get_Call_ptr (node);
- ir_entity *meth = NULL;
- if (iro_Sel == get_irn_opcode (ptr)) {
- meth = get_Sel_entity (ptr);
- } else if (iro_SymConst == get_irn_opcode (ptr)) {
- if (get_SymConst_kind (ptr) == symconst_addr_ent) {
- meth = get_SymConst_entity (ptr);
- } else {
- meth = NULL; /* WTF? */
- }
- }
-
- if (NULL != meth) {
- ir_type *tp = get_method_res_type ((ir_type*) meth, 0);
- res = ta_type (tp);
- } else {
- /* could be anything */
- /* fprintf (stdout, "meth= (null)"); */
- res = NULL;
- }
-
- /* fprintf (stdout, "]\n"); */
-
- } break;
-
- case (iro_SymConst): {
- if (get_SymConst_kind (node) == symconst_type_tag) {
- ir_type *tp = get_SymConst_type (node);
-
- res = ta_type (tp);
- } else if (get_SymConst_kind (node) == symconst_addr_ent) {
- ir_entity *ent = get_SymConst_entity (node);
- ir_type *tp = get_entity_owner (ent);
-
- while (is_Pointer_type (tp)) {
- tp = get_pointer_points_to_type (tp);
- }
-
- assert (is_Class_type (tp));
-
- res = ta_type (tp); /* can't use ta_exact */
- } else if (get_SymConst_kind (node) == symconst_addr_name) {
- /* oh, this is not a real call but a placeholder (exception stuff) */
- fprintf (stdout, "%s (%s:%i): can't handle pseudo-call %s\n",
- __FUNCTION__, __FILE__, __LINE__,
- get_op_name (get_irn_op (node)));
-
- res = NULL;
- } else {
- fprintf (stdout, "%s (%s:%i): can't handle SymConst %s\n",
- __FUNCTION__, __FILE__, __LINE__,
- get_op_name (get_irn_op (node)));
-
- res = NULL;
- }
- } break;
- case (iro_Const): {
- /* presumably a NULL constant */
- /* this also means we cannot handle calls against a NULL pointer. */
- res = NULL;
- } break;
-
- /* template:
- case (iro_Cast): {}
- break;
- */
-
- default: {
- fprintf (stdout, "what's with %s?\n", get_op_name (get_irn_op (node)));
- cough_and_die (node);
- } break;
- }
-
- return (res);
-}
-
-/*
- Initialise the Typalise module
-*/
-void typalise_init (void)
-{
- if (NULL == java_lang_Throwable_tp) {
- class_walk_super2sub (find_java_lang_Throwable, NULL, NULL);
-
- /* make sure we have found it */
- get_java_lang_Throwable ();
- }
-}
-
-
-
-\f
-/*
- $Log$
- Revision 1.14 2007/01/16 15:45:42 beck
- renamed type opcode to ir_opcode
-
- Revision 1.13 2006/12/13 19:46:47 beck
- rename type entity into ir_entity
-
- Revision 1.12 2006/01/13 21:54:02 beck
- renamed all types 'type' to 'ir_type'
-
- Revision 1.11 2005/05/13 16:35:14 beck
- made (void) prototypes
- removed unused fprintf arguments
-
- Revision 1.10 2005/05/06 12:02:34 beck
- added missing includes
- removed C99 features
-
- Revision 1.9 2005/03/22 13:56:09 liekweg
- "small" fix for exception b/d
-
- Revision 1.8 2005/01/14 14:13:24 liekweg
- fix gnu extension
-
- Revision 1.7 2005/01/10 17:26:34 liekweg
- fixup printfs, don't put environments on the stack
-
- Revision 1.6 2005/01/05 14:25:54 beck
- renames all is_x*_type() functions to is_X*_type() to prevent name clash with EDG fronten
-
- Revision 1.5 2004/12/22 14:43:14 beck
- made allocations C-like
-
- Revision 1.4 2004/12/21 15:50:18 beck
- removed C99 constructs
-
- Revision 1.3 2004/12/02 16:17:51 beck
- fixed config.h include
-
- Revision 1.2 2004/10/22 09:53:10 liekweg
- Correctly handle proj_args
-
- Revision 1.1 2004/10/21 11:09:37 liekweg
- Moved memwalk stuf into irmemwalk
- Moved lset stuff into lset
- Moved typalise stuff into typalise
-
-
- */
+++ /dev/null
-/* -*- c -*- */
-
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Compute rough approximations of pointer types
- * @author Florian
- * @date Mon 18 Oct 2004
- * @version $Id$
- */
-# ifndef FIRM_ANA2_TYPALISE_H
-# define FIRM_ANA2_TYPALISE_H
-
-# include "lset.h"
-
-# include "type.h"
-# include "irnode.h"
-
-/*
- Data Types and Structures
-*/
-typedef enum typalise_kind_enum {
- type_invalid = 0, /* invalid (only set at deletion time) */
- type_exact = 1, /* this and only this type (res.type) */
- type_types = 2, /* these types (res.types) */
- type_type = 3 /* this type and sub types (res.type) */
-} typalise_kind;
-
-typedef struct typalise
-{
- typalise_kind kind;
- union {
- ir_type *type; /* for kind == kind_exact and kind == kind_type */
- lset_t *types; /* for kind == kind_types */
- } res;
- int id;
-} typalise_t;
-
-/*
- Protos
-*/
-/**
- Given a set of graphs and a typalise_t, return the method (s) in
- the set that are supported by the typalise_t. Also, deallocates
- the given set.
-*/
-lset_t *filter_for_ta (lset_t*, typalise_t*);
-
-/**
- For the given ptr, do a quick check about what (class) types may be
- brought along on it.
-*/
-typalise_t *typalise (ir_node*);
-
-/*
- Initialise the Typalise module
-*/
-void typalise_init (void);
-
-# endif
-
-\f
-/*
- $Log$
- Revision 1.4 2006/01/13 21:54:03 beck
- renamed all types 'type' to 'ir_type'
-
- Revision 1.3 2005/03/22 13:56:09 liekweg
- "small" fix for exception b/d
-
- Revision 1.2 2004/10/21 11:11:21 liekweg
- whitespace fix
-
- Revision 1.1 2004/10/21 11:09:37 liekweg
- Moved memwalk stuf into irmemwalk
- Moved lset stuff into lset
- Moved typalise stuff into typalise
-
-
- */
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Architecture dependand IR operations
- * @version $Id$
- */
-#ifndef FIRM_ARCH_ARCHOP_H
-#define FIRM_ARCH_ARCHOP_H
-
-#include "firm_types.h"
-#include "dbginfo.h"
-
-/**
- * Mask defining which architecture depend
- * operations are supported.
- */
-typedef enum _arch_ops_mask {
- ARCH_OPS_NONE = 0, /**< no additional Operations */
- ARCH_OPS_MINMAX = 1 /**< use the Min/Max Operation */
-} arch_ops_mask;
-
-typedef struct _arch_ops_info {
- arch_ops_mask enabled_ops; /**< a mask of enabled IR-opcodes */
- unsigned minmax_handle_NaN:1; /**< if set, Min(a,a) == a, else unknown */
-} arch_ops_info;
-
-extern ir_op *op_Min, *op_Max;
-
-ir_op *get_op_Min(void);
-ir_op *get_op_Max(void);
-
-/** construct a Min: Min(a,b) = a < b ? a : b */
-ir_node *
-new_rd_Min(dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** construct a Max: Max(a,b) = a > b ? a : b */
-ir_node *
-new_rd_Max(dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *op1, ir_node *op2, ir_mode *mode);
-
-ir_node *
-new_r_Min(ir_graph *irg, ir_node *block,
- ir_node *op1, ir_node *op2, ir_mode *mode);
-
-ir_node *
-new_r_Max(ir_graph *irg, ir_node *block,
- ir_node *op1, ir_node *op2, ir_mode *mode);
-
-ir_node *
-new_Min(ir_node *op1, ir_node *op2, ir_mode *mode);
-
-ir_node *
-new_Max(ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/**
- * Create Min and Mux from Mux nodes
- */
-ir_node *arch_transform_node_Mux(ir_node *mux);
-
-/**
- * initialize the ops.
- */
-void firm_archops_init(const arch_ops_info *info);
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief integer mode conversion
- * @author Michael Beck
- * @version $Id$
- * @summary
- * Contains the mode conversion for architectures that did not support lesser
- * integer modes. Converts all Op(mode_l) into Op(mode) operations by adding
- * conversions were needed. These Conv operations must be implemented in the
- * backend as bit-reducing ops.
- */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-# include "irnode_t.h"
-# include "irgraph_t.h"
-# include "irmode_t.h"
-# include "iropt_t.h"
-# include "ircons_t.h"
-# include "irgmod.h"
-# include "dbginfo.h"
-# include "iropt_dbg.h"
-# include "irflag_t.h"
-# include "irgwalk.h"
-# include "modeconv.h"
-# include "firmstat.h"
-
-typedef struct _walker_t {
- int bits; /**< number of bits in the destination mode */
- ir_mode *s_mode; /**< signed destination mode */
- ir_mode *u_mode; /**< unsigned destination mode */
- int changes; /**< non-zero if the graph was changed */
-} walker_t;
-
-/**
- * Add a Conv node where needed on output
- */
-static ir_node *fix_irn_output(ir_node *node, ir_mode *mode)
-{
- switch (get_irn_opcode(node)) {
- case iro_Proj:
- /* Args, Load, Div, Mod */
- case iro_Conv:
- /* Hmm, maybe the Conv should be replaced */
- case iro_Rot: {
- ir_node *block = get_nodes_block(node);
-
- if (get_irn_mode(node) != mode)
- return new_r_Conv(current_ir_graph, block, node, mode);
- else
- return node;
- }
- default:
- return node;
- }
-}
-
-/**
- * Add a Conv node where needed on input
- */
-static ir_node *fix_irn_input(ir_opcode code, ir_node *block, ir_node *pred, ir_mode *mode)
-{
- switch (code) {
- case iro_DivMod:
- case iro_Div:
- case iro_Mod:
- case iro_Shr:
- case iro_Shrs:
- case iro_Rot:
- case iro_Call:
- case iro_Return: {
- ir_mode *p_mode = get_irn_mode(pred);
-
- if (p_mode != mode && mode_is_int(p_mode))
- return new_r_Conv(current_ir_graph, block, pred, mode);
- return pred;
- }
- default:
- return pred;
- }
-}
-
-/**
- * fix the mode of the operations if possible
- */
-static void fix_mode(ir_node *n, ir_mode *mode)
-{
- ir_opcode code = get_irn_opcode(n);
-
- if (code == iro_Proj) {
- code = get_irn_opcode(get_Proj_pred(n));
- }
-
- switch (code) {
- case iro_Return:
- case iro_Load:
- case iro_Proj:
- case iro_Call:
- case iro_Conv:
- return;
- default:
- set_irn_mode(n, mode);
- }
-}
-
-/**
- * walker for the mode conversion
- */
-static void do_mode_conv(ir_node *n, void *env)
-{
- walker_t *wenv = env;
- ir_mode *mode = get_irn_mode(n);
- ir_node *block;
- ir_opcode code;
-
- /* save the old mode, we need this info later */
- set_irn_link(n, mode);
-
- /* special case: fix the Return */
- if (is_Return(n)) {
- ir_entity *ent = get_irg_entity(current_ir_graph);
- ir_type *mt = get_entity_type(ent);
- int i, n_ress = get_method_n_ress(mt);
-
- mode = mode_is_signed(mode) ? wenv->s_mode : wenv->u_mode;
- block = get_nodes_block(n);
- for (i = 0; i < n_ress; ++i) {
- ir_node *pred = get_irn_n(n, i + 1);
- ir_type *rt = get_method_res_type(mt, i);
-
- if (is_atomic_type(rt)) {
- mode = get_type_mode(rt);
-
- if (mode != get_irn_mode(pred)) {
- pred = fix_irn_input(iro_Return, block, pred, mode);
-
- set_irn_n(n, i + 1, pred);
- }
- }
- }
-
- return;
- }
-
- /* convert only integer modes with less than 'bits' bits */
- if (mode_is_int(mode) && get_mode_size_bits(mode) < wenv->bits && get_irn_op(n) != op_Conv) {
- mode = mode_is_signed(mode) ? wenv->s_mode : wenv->u_mode;
-
- code = get_irn_opcode(n);
-
- if (code == iro_Conv) {
- /* formally, the was a convert from modeA to modeB here.
- * So, the expression before the conv must have modeA. */
- ir_node *pred = get_Conv_op(n);
- ir_mode *modeA = get_irn_link(pred);
-
- if (modeA != get_irn_mode(pred)) {
- pred = new_r_Conv(current_ir_graph, get_nodes_block(pred), pred, modeA);
- set_Conv_op(n, pred);
- }
- }
- else if (code == iro_Proj) {
- /* special case for Proj: we must fix it's pred */
- ir_node *oper = get_Proj_pred(n);
- int i, arity = get_irn_arity(oper);
-
- code = get_irn_opcode(oper);
- block = get_nodes_block(oper);
-
- for (i = 0; i < arity; ++i) {
- ir_node *pred = get_irn_n(oper, i);
-
- pred = fix_irn_input(code, block, pred, mode);
-
- set_irn_n(oper, i, pred);
- }
-
- }
- else {
- int i, arity = get_irn_arity(n);
-
- block = get_nodes_block(n);
- for (i = 0; i < arity; ++i) {
- ir_node *pred = get_irn_n(n, i);
-
- pred = fix_irn_output(pred, mode);
- pred = fix_irn_input(code, block, pred, mode);
-
- set_irn_n(n, i, pred);
- }
- }
-
- fix_mode(n, mode);
- wenv->changes = 1;
- }
-
- if (get_irn_op(n) == op_Conv) {
- /* formally, the was a convert from modeA to modeB here.
- * So, the expression before the conv must have modeA. */
- ir_node *pred = get_Conv_op(n);
- ir_mode *modeA = get_irn_link(pred);
-
- if (modeA != get_irn_mode(pred)) {
- pred = new_r_Conv(current_ir_graph, get_nodes_block(pred), pred, modeA);
- set_Conv_op(n, pred);
- }
-
- /* old conv may now get useless */
- if (get_irn_mode(n) == get_irn_mode(pred)) {
- exchange(n, get_Conv_op(n));
- wenv->changes = 1;
- }
- }
-}
-
-/*
- * do the integer mode conversion
- */
-void arch_mode_conversion(ir_graph *irg, ir_mode *mode)
-{
- walker_t env;
-
- assert(get_irg_phase_state(irg) != phase_building);
-
- assert(mode_is_int(mode));
-
- env.s_mode = mode_is_signed(mode) ? mode: find_signed_mode(mode) ;
- env.u_mode = mode_is_signed(mode) ? find_unsigned_mode(mode) : mode;
- env.bits = get_mode_size_bits(mode);
- env.changes = 0;
-
- assert(env.s_mode && env.u_mode && "Could not find modes");
-
- irg_walk_graph(irg, NULL, do_mode_conv, &env);
-
- /* Handle graph state. We never change control flow. */
- if (env.changes) {
- set_irg_outs_inconsistent(current_ir_graph);
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief integer mode conversion
- * @author Michael Beck
- * @version $Id$
- * @summary
- * Contains the mode conversion for architectures that did not support lesser
- * integer modes. Converts all Op(mode_l) into Op(mode) operations by adding
- * conversions were needed. These Conv operations must be implemented in the
- * backend as bit-reducing ops.
- */
-#ifndef FIRM_ARCH_MODECONV_H
-#define FIRM_ARCH_MODECONV_H
-
-#include "irgraph.h"
-
-/** Mode conversion..
- *
- * Converts all operations with a integer mode lesser than mode into
- * operations of type mode. Adds Conv() operations only were strictly
- * needed.
- */
-void arch_mode_conversion(ir_graph *irg, ir_mode *mode);
-
-#endif
#include "bearch_TEMPLATE_t.h"
#include "TEMPLATE_nodes_attr.h"
-#include "../arch/archop.h" /* we need this for Min and Max nodes */
+#include "archop.h"
#include "TEMPLATE_transform.h"
#include "TEMPLATE_new_nodes.h"
#include "TEMPLATE_map_regs.h"
#include "../benode_t.h"
#include "../belower.h"
#include "../besched_t.h"
-#include "../be.h"
+#include "be.h"
#include "../beabi.h"
#include "../bemodule.h"
#include "../begnuas.h"
0, /* no Mulh */
};
static backend_params p = {
+ 0, /* no dword lowering */
+ 0, /* no inline assembly */
NULL, /* no additional opcodes */
NULL, /* will be set later */
- 0, /* no dword lowering */
NULL, /* no creator function */
NULL, /* context for create_intrinsic_fkt */
+ NULL,
+ NULL,
};
p.dep_param = &ad;
#include "debug.h"
#include "bearch_TEMPLATE.h"
#include "TEMPLATE_nodes_attr.h"
-#include "../be.h"
+#include "be.h"
#include "../beemitter.h"
#include "set.h"
#define FIRM_BE_ARM_ARM_NODES_ATTR_H
#include "../bearch_t.h"
-#include "../../common/firm_types.h"
+#include "firm_types.h"
/**
* Possible ARM register shift types.
#include "bearch_arm_t.h"
#include "arm_nodes_attr.h"
-#include "../arch/archop.h" /* we need this for Min and Max nodes */
+#include "archop.h"
#include "arm_transform.h"
#include "arm_new_nodes.h"
#include "arm_map_regs.h"
#include "../benode_t.h"
#include "../belower.h"
#include "../besched_t.h"
-#include "../be.h"
+#include "be.h"
#include "../beabi.h"
#include "../bemachine.h"
#include "../beilpsched.h"
#include "debug.h"
#include "bearch_arm.h"
#include "arm_nodes_attr.h"
-#include "../be.h"
+#include "be.h"
#include "../beemitter.h"
#include "set.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Generic backend types and interfaces.
- * @author Sebastian Hack
- * @version $Id$
- */
-#ifndef FIRM_BE_MAIN_H
-#define FIRM_BE_MAIN_H
-
-#include <stdio.h>
-#include "irarch.h"
-#include "archop.h"
-#include "lower_dw.h"
-#include "dbginfo.h"
-#include "ifconv.h"
-
-#include <libcore/lc_timing.h>
-
-#define LC_STOP_AND_RESET_TIMER(timer) do { lc_timer_stop(timer); lc_timer_reset(timer); } while(0)
-
-/** For inline assembler: get a register from a name and encode it into a backend specific value. */
-typedef unsigned (get_register_fkt)(const char *reg);
-
-/**
- * This structure contains parameters that should be
- * propagated to the libFirm parameter set.
- */
-typedef struct backend_params {
- /** if set, the backend cannot handle DWORD access */
- unsigned do_dw_lowering:1;
- /** if set, the backend supports inline assembly */
- unsigned support_inline_asm:1;
-
- /** Additional opcodes settings. */
- const arch_ops_info *arch_op_settings;
-
- /** Settings for architecture dependent optimizations */
- const arch_dep_params_t *dep_param;
-
- /** the architecture specific intrinsic function creator */
- create_intrinsic_fkt *arch_create_intrinsic_fkt;
-
- /** the context parameter for the create intrinsic function */
- void *create_intrinsic_ctx;
-
- /** backend settings for if-conversion */
- const opt_if_conv_info_t *if_conv_info;
-
- /** get the backend specific register encoding for a register name */
- get_register_fkt *get_register_from_name;
-} backend_params;
-
-/**
- * Register the Firm backend command line options.
- */
-void be_opt_register(void);
-
-/**
- * Parse one backend argument.
- */
-int be_parse_arg(const char *arg);
-
-/**
- * Initialize the Firm backend. Must be run BEFORE init_firm()!
- *
- * @return libFirm configuration parameters for the selected
- * backend
- */
-const backend_params *be_init(void);
-
-/**
- * Main interface to the frontend.
- */
-void be_main(FILE *file_handle, const char *cup_name);
-
-/** The type of the debug info retriever function. */
-typedef const char *(*retrieve_dbg_func)(const dbg_info *dbg, unsigned *line);
-
-/**
- * Sets a debug info retriever.
- *
- * @param func the debug retriever function.
- */
-void be_set_debug_retrieve(retrieve_dbg_func func);
-
-/**
- * Retrieve the debug info.
- */
-const char *be_retrieve_dbg_info(const dbg_info *dbg, unsigned *line);
-
-typedef struct be_main_env_t be_main_env_t;
-typedef struct be_options_t be_options_t;
-
-#endif /* FIRM_BE_MAIN_H */
#include "obst.h"
#include "offset.h"
-#include "type.h"
#include "irgopt.h"
#include "irgraph_t.h"
#include "bitset.h"
#include "pset.h"
-#include "entity.h"
#include "raw_bitset.h"
#include "irprintf.h"
#include "obst.h"
#include "tv.h"
#include "irnode.h"
-#include "entity.h"
#include "irprog.h"
#include "pdeq.h"
#include "error.h"
#include "irtools.h"
#include "irvrfy.h"
#include "irprintf.h"
-#include "return.h"
#include "firmstat.h"
-#include "cfopt.h"
#include "execfreq.h"
#include "bearch_t.h"
#include <limits.h>
-#include "irmode.h"
+#include "firm_types.h"
#include "irnode.h"
-#include "irgraph.h"
-#include "entity.h"
-
#include "bearch.h"
#define BE_OUT_POS(p) (-((p) + 1))
#include "list.h"
#include "pmap.h"
-#include "entity.h"
#include "irprintf.h"
#include "irgwalk.h"
#include "irdump_t.h"
#include "iredges.h"
#include "execfreq.h"
#include "irvrfy.h"
-#include "type.h"
+#include "typerep.h"
#include "be_t.h"
#include "belive_t.h"
#include "irprintf.h"
#include "execfreq.h"
#include "unionfind.h"
-#include "type.h"
#include "irdump_t.h"
#include "benode_t.h"
#include "obst.h"
#include "irprog.h"
-#include "entity.h"
#include "irgraph.h"
-#include "typewalk.h"
#include "tv.h"
#include "xmalloc.h"
#include "pmap.h"
return result;
}
-static void collect(be_verify_spillslots_env_t *env, ir_node *node, ir_node *reload, ir_entity* ent);
+static
+void collect(be_verify_spillslots_env_t *env, ir_node *node, ir_node *reload, ir_entity* ent);
-static void check_entity(be_verify_spillslots_env_t *env, ir_node *node, ir_entity *ent) {
+static
+void be_check_entity(be_verify_spillslots_env_t *env, ir_node *node, ir_entity *ent) {
if(ent == NULL) {
ir_fprintf(stderr, "Verify warning: Node %+F in block %+F(%s) should have an entity assigned\n",
node, get_nodes_block(node), get_irg_dump_name(env->irg));
}
}
-static void collect_spill(be_verify_spillslots_env_t *env, ir_node *node, ir_node *reload, ir_entity* ent) {
+static
+void collect_spill(be_verify_spillslots_env_t *env, ir_node *node, ir_node *reload, ir_entity* ent) {
ir_entity *spillent = arch_get_frame_entity(env->arch_env, node);
- check_entity(env, node, spillent);
+ be_check_entity(env, node, spillent);
get_spill(env, node, ent);
if(spillent != ent) {
out = get_Proj_proj(node);
spillent = be_get_MemPerm_out_entity(memperm, out);
- check_entity(env, memperm, spillent);
+ be_check_entity(env, memperm, spillent);
if(spillent != ent) {
ir_fprintf(stderr, "Verify warning: MemPerm %+F has different entity than reload %+F in block %+F(%s)\n",
node, reload, get_nodes_block(node), get_irg_dump_name(env->irg));
return;
}
ent = arch_get_frame_entity(env->arch_env, node);
- check_entity(env, node, ent);
+ be_check_entity(env, node, ent);
collect(env, spill, node, ent);
ARR_APP1(ir_node*, env->reloads, node);
spill_t *spill = find_spill(env, node);
if(be_is_Spill(node)) {
ir_entity *ent = arch_get_frame_entity(env->arch_env, node);
- check_entity(env, node, ent);
+ be_check_entity(env, node, ent);
}
if(spill == NULL) {
#include "irgmod.h"
#include "ircons_t.h"
#include "irgwalk.h"
-#include "type.h"
#include "irtools.h"
#include "../be_t.h"
#include "../benode_t.h"
#include "../belower.h"
#include "../besched_t.h"
-#include "../be.h"
+#include "be.h"
#include "../be_t.h"
#include "../beirgmod.h"
#include "../be_dbgout.h"
#include "set.h"
#include "pdeq.h"
-#include "../be.h"
+#include "be.h"
#include "../bemachine.h"
#include "../beemitter.h"
#include "irprog_t.h"
#include "lower_intrinsics.h"
#include "lower_dw.h"
-#include "mangle.h"
#include "array.h"
#include "ia32_new_nodes.h"
#include "irprintf.h"
#include "debug.h"
#include "irdom.h"
-#include "type.h"
-#include "entity.h"
#include "archop.h" /* we need this for Min and Max nodes */
#include "error.h"
#include "cgana.h"
#include "../benode_t.h"
#include "../belower.h"
#include "../besched_t.h"
-#include "../be.h"
+#include "be.h"
#include "../beabi.h"
#include "../bemachine.h"
#include "../bemodule.h"
#include "irgopt.h"
#include "bearch_mips.h"
#include "mips_nodes_attr.h"
-#include "../be.h"
+#include "be.h"
#include "../beemitter.h"
#include "set.h"
#include "mips_scheduler.h"
#include "../besched_t.h"
-#include "../be.h"
+#include "be.h"
#include "../beabi.h"
#include "iredges.h"
#include "ircons.h"
#include "bearch_mips_t.h"
#include "mips_nodes_attr.h"
-#include "../arch/archop.h" /* we need this for Min and Max nodes */
+#include "archop.h"
#include "mips_transform.h"
#include "mips_new_nodes.h"
#include "mips_map_regs.h"
#include "../benode_t.h"
#include "../belower.h"
#include "../besched_t.h"
-#include "../be.h"
+#include "be.h"
#include "../beabi.h"
#include "../bemachine.h"
#include "../bemodule.h"
#include "debug.h"
#include "bearch_ppc32.h"
#include "ppc32_nodes_attr.h"
-#include "../be.h"
+#include "be.h"
#include "../beemitter.h"
#include "pset.h"
#include "set.h"
#include "bearch_ppc32_t.h"
#include "ppc32_nodes_attr.h"
-#include "../arch/archop.h" /* we need this for Min and Max nodes */
+#include "archop.h"
#include "ppc32_transform.h"
#include "ppc32_new_nodes.h"
#include "ppc32_map_regs.h"
#include "ident_t.h"
#include "firm.h"
#include "irflag_t.h"
-#include "mangle.h"
/* init functions are not public */
#include "tv_t.h"
#include "tpop_t.h"
#include "irgraph_t.h"
#include "type_t.h"
#include "entity_t.h"
-#include "type_identify.h"
#include "firmstat.h"
-#include "irreflect_t.h"
#include "irarch.h"
#include "reassoc_t.h"
#include "irhooks.h"
firm_init_entity();
/* allocate a hash table. */
init_type_identify(def_params.ti_if);
- /* Init reflection facility. */
- firm_init_rflct();
/* Init architecture dependent optimizations. */
arch_dep_init(arch_dep_default_factory);
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Central firm header.
- * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier
- * @version $Id$
- * @summary
- * Central FIRM header.
- *
- * FIRM is a full graph based intermediate representation in SSA Form
- * with a novel concept to model side effects. It allows fast, aggressive
- * optimizations.
- *
- * This header is the central header of the library implementation of this
- * IR.
- *
- * The internal representation of a program in firm is separated into five
- * different modules:
- * - Firm Graphs representing the code of a program. (Subdirectory ir.)
- * Firm Graphs are assembled out of several data structures:
- * irprog: represents a program. Allows access to all types and all
- * FIRM graphs for procedures and other global things.
- * irgraph: represents a procedure. Allows access to the code of the
- * procedure, the actual FIRM graph.
- * irnode: A node of a FIRM graph. Nodes are typed with an opcode and a mode
- * and represent instructions in a program.
- * irop: The opcode of FIRM nodes.
- * irmode: The mode of FIRM nodes. Most modes correspond to machine known
- * data types (int, float, pointer).
- * - Entities representing program known objects. (Subdirectory tr.)
- * All variables and procedures are entities.
- * - Types describing the type system for the program. (Subdirectory tr.)
- * - Target Values representing program known constants. (Subdirectory tv.)
- * - Identifiers representing any Strings used in the program. (Subdirectory ident.)
- *
- * Further this library supplies functionality to build and optimize FIRM graphs
- * and further functionality needed in a compiler. Finally there is more
- * generic functionality to support implementations using firm. (Code generation,
- * further optimizations).
- */
-#ifndef FIRM_COMMON_FIRM_H
-#define FIRM_COMMON_FIRM_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* The representations */
-#include "firm_common.h" /* common type tags. */
-#include "irprog.h" /* control flow and data of a program */
-#include "irgraph.h" /* graphs */
-#include "type.h" /* type representation */
-#include "entity.h" /* entity representation */
-#include "tv.h" /* target values */
-#include "ident.h" /* source code identificators */
-
-/* Functionality */
-#include "ircons.h" /* construct ir */
-#include "ircgcons.h" /* construct interprocedural graph */
-
-/* Optimizations */
-#include "irflag.h" /* optimization flags */
-#include "irgopt.h" /* optimize ir */
-#include "reassoc.h" /* optimize ir by reassociation */
-#include "ldstopt.h" /* optimize Load/Store */
-#include "cfopt.h" /* optimize control flow */
-#include "tailrec.h" /* optimize tail-recursion calls */
-#include "ircgopt.h" /* Optimizations based on interprocedural graph */
-#include "opt_osr.h" /* Operator Strength Reduction */
-#include "strength_red.h" /* Old (and buggy) Strength reduction */
-#include "loop_unrolling.h" /* Do loop unrolling */
-#include "ifconv.h" /* if conversion */
-#include "funccall.h" /* real function call optimization */
-#include "return.h" /* Return node normalizations */
-#include "scalar_replace.h" /* Scalar replacement */
-#include "proc_cloning.h" /* procedure cloning */
-#include "opt_confirms.h" /* Confirm based optimizations */
-#include "gvn_pre.h" /* global value numbering and partial redundancy elimination */
-#include "opt_frame.h" /* frame type optimization */
-#include "tropt.h" /* optimize the type representation */
-#include "condeval.h" /* control flow optimization by conditional evaluation */
-
-/* Lowering */
-#include "lower_calls.h" /* lowering of different calls */
-#include "lower_intrinsics.h" /* lowering of intrinsic calls */
-#include "lower_dw.h" /* double word types lowering */
-#include "lower_hl.h" /* lowering of high-level constructs */
-
-/* Analyses */
-#include "irouts.h" /* Graph reversal / out edges. */
-#include "trouts.h" /* Graph reversal / out edges for types. */
-#include "irdom.h" /* Dominator analysis */
-#include "cgana.h" /* Analysis to construct interprocedural graph */
- /* including some optimizations */
-#include "irloop.h" /* loop and backedge analysis */
-#include "callgraph.h" /* Callgraph construction */
-#include "irconsconfirm.h" /* Confirm nodes */
-#include "analyze_irg_args.h" /* Simple pointer parameter analysis */
-#include "irtypeinfo.h" /* type information for nodes */
-#include "irmemory.h" /* memory disambiguation */
-#include "interval_analysis.h"
-#include "field_temperature.h"
-#include "execution_frequency.h"
-
-/* Support */
-#include "irgmod.h" /* Support to modify ir */
-#include "irgwalk.h" /* Support to walk ir */
-#include "typewalk.h" /* Support to walk type information */
-#include "typegmod.h" /* Support to modify type graph */
-#include "type_identify.h" /* Support for type identification */
-#include "mangle.h" /* Support for mangling ident names. */
-#include "tr_inheritance.h" /* Support to handle inheritance. */
-
-#include "irarch.h" /* architecture dependent optimizations */
-#include "archop.h" /* architecture dependent opcodes */
-//#include "modeconv.h" /* architecture dependent mode conversion */
-
-#include "firmstat.h" /* statistics */
-
-#include "irreflect.h" /* reflection */
-
-#include "seqnumbers.h" /* debug support */
-#include "firm_ycomp.h" /* ycomp debugging support */
-
-
-/* @@@ temporarily for jni builder until preprocessor works.
- Then it should be sufficient to include <file.h> instead
- of firm.h as not all enums are needed in the implementation
- files. */
-#include "irdump.h"
-#include "irprintf.h"
-#include "irvrfy.h"
-#include "trvrfy.h"
-
-#include "irarch.h"
-
-#include "iredges.h"
-
-/* Macros that define the old function names we decided to rename.
- Use for compatibility with old implementations. */
-/*#include "old_fctnames.h"*/
-
-/**
- * libFirm initialization parameters.
- */
-struct _firm_parameter_t {
- /**
- * The size of this structure. init_firm() will only initialize
- * this amount of data. This allows to add more fields to this structure
- * without breaking compatibility to older source.
- */
- unsigned int size;
-
- /**
- * Statistic options. If statistic function where enabled, these
- * flags configure it, see enum firmstat_options_t.
- */
- unsigned enable_statistics;
-
- /**
- * This function is called, whenever a local variable is
- * used before definition. The function should insert a default value,
- * and/or raise a compiler error/warning. Note that returning
- * an Unknown is allowed here.
- */
- uninitialized_local_variable_func_t *initialize_local_func;
-
- /**
- * The interface functions for the type identification module.
- * If not set, the default implementation with compare_strict() and
- * firm_hash_name() will be used.
- */
- type_identify_if_t *ti_if;
-
- /**
- * The interface for the ident module.
- * If not set, the default libFirm ident module (using hash sets).
- */
- ident_if_t *id_if;
-
- /**
- * The architecture dependent opcode settings.
- * If not set, no architecture dependent operations will be used.
- */
- const arch_ops_info *arch_op_settings;
-
- /**
- * The default calling convention.
- */
- unsigned cc_mask;
-
- /**
- * The debug info that should be used for "builtin" objects.
- */
- dbg_info *builtin_dbg;
-};
-
-typedef struct _firm_parameter_t firm_parameter_t;
-
-#define libFirm_VERSION_MAJOR 1
-#define libFirm_VERSION_MINOR 4
-
-/**
- * The Firm version number.
- */
-typedef struct _firm_version_t {
- unsigned major;
- unsigned minor;
-} firm_version_t;
-
-/**
- * Initialize the firm library.
- *
- * Initializes the firm library. Allocates default data structures.
- * Initializes configurable behavior of the library.
- *
- * @param params A structure containing the parameters of the libFirm.
- *
- * The parameter struct may be NULL. In that case, the original FIRM behavior
- * is conserved.
- */
-void init_firm(const firm_parameter_t *params);
-
-/**
- * Frees all memory occupied by the firm library.
- */
-void free_firm(void);
-
-/**
- * Returns the libFirm version number.
- * If statically linked, always libFirm_VERSION_MAJOR, libFirm_VERSION_MINOR
- */
-void firm_get_version(firm_version_t *version);
-
-#ifdef WITH_LIBCORE
-/**
- * Read initializations arguments from the .init file.
- */
-void firm_init_options(const char *arg_prefix, int argc, const char **argv);
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief common firm declarations
- * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier
- * @version $Id$
- */
-#ifndef FIRM_COMMON_FIRM_COMMON_H
-#define FIRM_COMMON_FIRM_COMMON_H
-
-/** a list of firm kinds
- @@@ not all datatypes are tagged yet. */
-typedef enum {
- k_BAD = 0, /**< An invalid firm node. */
- k_entity, /**< An entity. */
- k_type, /**< A type. */
- k_ir_graph, /**< An IR graph. */
- k_ir_node, /**< An IR node. */
- k_ir_mode, /**< An IR mode. */
- k_ir_op, /**< An IR opcode. */
- k_tarval, /**< A tarval. */
- k_ir_loop, /**< A loop. */
- k_ir_compound_graph_path, /**< A compound graph path, see entity.h. */
- k_ir_extblk, /**< An extended basic block. */
- k_ir_prog, /**< A program representation (irp). */
- k_ir_region, /**< A region. */
- k_ir_max /**< maximum value -- illegal for firm nodes. */
-} firm_kind;
-
-/**
- * Returns the kind of a thing.
- *
- * @param firm_thing pointer representing a firm object
- */
-firm_kind get_kind(const void *firm_thing);
-
-/** Returns the kind of a thing as a string. */
-const char *print_firm_kind(void *firm_thing);
-
-/** Print an identification of a firm thing. */
-void firm_identify_thing(void *X);
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Definition of opaque firm types
- * @author Michael Beck
- * @version $Id$
- */
-#ifndef FIRM_COMMON_FIRM_TYPES_H
-#define FIRM_COMMON_FIRM_TYPES_H
-
-#ifdef _MSC_VER
-typedef __int64 long64;
-typedef unsigned __int64 ulong64;
-
-#define LL_FMT "i64"
-#define ULL_FMT "ui64"
-
-#else
-typedef long long long64;
-typedef unsigned long long ulong64;
-
-#define LL_FMT "ll"
-#define ULL_FMT "llu"
-
-#endif /* _MSC_VER */
-
-#ifndef _IDENT_TYPEDEF_
-#define _IDENT_TYPEDEF_
-typedef const struct _ident ident, *ir_ident_ptr;
-#endif
-
-#ifndef _IR_NODE_TYPEDEF_
-#define _IR_NODE_TYPEDEF_
-typedef struct ir_node ir_node, *ir_node_ptr;
-#endif
-
-#ifndef _IR_OP_TYPEDEF_
-#define _IR_OP_TYPEDEF_
-typedef struct ir_op ir_op, *ir_op_ptr;
-#endif
-
-#ifndef _IR_MODE_TYPEDEF_
-#define _IR_MODE_TYPEDEF_
-typedef struct ir_mode ir_mode, *ir_mode_ptr;
-#endif
-
-#ifndef _IR_EDGE_TYPEDEF_
-#define _IR_EDGE_TYPEDEF_
-typedef struct _ir_edge_t ir_edge_t, *ir_edge_ptr;
-#endif
-
-#ifndef _TARVAL_TYPEDEF_
-#define _TARVAL_TYPEDEF_
-typedef struct tarval tarval, *ir_tarval_ptr;
-#endif
-
-#ifndef _IR_ENUM_CONST_TYPEDEF_
-#define _IR_ENUM_CONST_TYPEDEF_
-typedef struct ir_enum_const ir_enum_const, *ir_enum_const_ptr;
-#endif
-
-#ifndef _IR_TYPE_TYPEDEF_
-#define _IR_TYPE_TYPEDEF_
-typedef struct ir_type ir_type, *ir_type_ptr;
-#endif
-
-#ifndef _IR_GRAPH_TYPEDEF_
-#define _IR_GRAPH_TYPEDEF_
-typedef struct ir_graph ir_graph, *ir_graph_ptr;
-#endif
-
-#ifndef _IR_LOOP_TYPEDEF_
-#define _IR_LOOP_TYPEDEF_
-typedef struct ir_loop ir_loop, *ir_loop_ptr;
-#endif
-
-#ifndef _IR_REGION_TYPEDEF_
-#define _IR_REGION_TYPEDEF_
-typedef struct ir_region ir_region, *ir_region_ptr;
-#endif
-
-#ifndef _IR_REG_TREE_TYPEDEF_
-#define _IR_REG_TREE_TYPEDEF_
-typedef struct ir_reg_tree ir_reg_tree, *ir_reg_tree_ptr;
-#endif
-
-#ifndef _ENTITY_TYPEDEF_
-#define _ENTITY_TYPEDEF_
-typedef struct ir_entity ir_entity, *ir_entity_ptr;
-#endif
-
-#ifndef _COMPOUND_GRAPH_PATH_TYPEDEF_
-#define _COMPOUND_GRAPH_PATH_TYPEDEF_
-typedef struct compound_graph_path compound_graph_path, *ir_compound_graph_path_ptr;
-#endif
-
-#ifndef _IR_PHASE_TYPEDEF_
-#define _IR_PHASE_TYPEDEF_
-typedef struct _ir_phase ir_phase, *ir_phase_ptr;
-#endif
-
-#ifndef _IR_EXTBB_TYPEDEF_
-#define _IR_EXTBB_TYPEDEF_
-typedef struct _ir_extblk ir_extblk, *ir_extblk_ptr;
-#endif
-
-#ifndef _IRG_WALK_FUNC_TYPEDEF_
-#define _IRG_WALK_FUNC_TYPEDEF_
-typedef void irg_walk_func(ir_node *, void *);
-#endif
-
-#ifndef _IRG_REG_WALK_FUNC_TYPEDEF_
-#define _IRG_REG_WALK_FUNC_TYPEDEF_
-typedef void irg_reg_walk_func(ir_region *, void *);
-#endif
-
-#ifndef _SEQNO_T_TYPEDEF_
-#define _SEQNO_T_TYPEDEF_
-typedef struct sn_entry *seqno_t;
-#endif
-
-#ifndef _EXECFREQ_TYPEDEF
-#define _EXECFREQ_TYPEDEF
-typedef struct ir_exec_freq ir_exec_freq, *ir_exec_freq_ptr;
-#endif
-
-#endif
#include "irnode_t.h"
#include "irprog_t.h"
#include "irgwalk.h"
-#include "typewalk.h"
#include "irtools.h"
#include "array.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Some makros supporting old function names.
- * @author Goetz Lindenmaier
- * @version $Id$
- */
-#ifndef FIRM_COMMON_OLD_FCTNAMES_H
-#define FIRM_COMMON_OLD_FCTNAMES_H
-
-/* firmstat */
-#define stat_init init_stat
-
-/* ircons */
-#define add_in_edge(X, Y) add_immBlock_pred(X, Y)
-#define mature_block(X) mature_immBlock(X)
-#define switch_block(X) set_cur_block(X)
-#define finalize_cons(X) irg_finalize_cons(X)
-
-/* irgraph */
-#define get_irg_ent(X) get_irg_entity(X)
-#define get_irg_params get_irg_n_locs
-#define get_irg_n_loc get_irg_n_locs
-#define set_irg_ent(X, Y) set_irg_entity(X, Y)
-#define set_irg_params set_irg_n_loc
-#define no_dom dom_none
-#define no_outs outs_none
-
-/* irnode.h */
-#define get_Return_n_res get_Return_n_ress
-#define get_Sel_n_index get_Sel_n_indexs
-#define get_SymConst_ptrinfo get_SymConst_name
-#define set_SymConst_ptrinfo set_SymConst_name
-#define type_tag symconst_type_tag
-#define size symconst_type_size
-#define symconst_size symconst_type_size
-#define linkage_ptr_info symconst_addr_name
-
-#define get_nodes_Block(X) get_nodes_block(X)
-#define set_nodes_Block(X, Y) set_nodes_block(X, Y)
-#define get_Start_irg(X) get_irn_irg(X)
-#define get_EndReg_irg(X) get_irn_irg(X)
-#define get_EndExcept_irg(X) get_irn_irg(X)
-#define get_CallBegin_irg(X) get_irn_irg(X)
-#define get_ip_cfop_irg(X) get_irn_irg(X)
-#define skip_nop(X) skip_Id(X)
-
-#define pns_initial_exec pn_Start_X_initial_exec
-#define pns_global_store pn_Start_M
-#define pns_frame_base pn_Start_P_frame_base
-#define pns_args pn_Start_T_args
-#define pns_value_arg_base pn_Start_P_value_arg_base
-
-#define pnc_number pn_Cmp
-#define False pn_Cmp_False
-#define Eq pn_Cmp_Eq
-#define Lt pn_Cmp_Lt
-#define Le pn_Cmp_Le
-#define Gt pn_Cmp_Gt
-#define Ge pn_Cmp_Ge
-#define Lg pn_Cmp_Lg
-#define Leg pn_Cmp_Leg
-#define Uo pn_Cmp_Uo
-#define Ue pn_Cmp_Ue
-#define Ul pn_Cmp_Ul
-#define Ule pn_Cmp_Ule
-#define Ug pn_Cmp_Ug
-#define Uge pn_Cmp_Uge
-#define Ne pn_Cmp_Ne
-#define True pn_Cmp_True
-
-/* irmode.h */
-#define get_ident_of_mode get_mode_ident
-#define get_size_of_mode get_mode_size
-#define get_ld_align_of_mode get_mode_ld_align
-#define get_min_of_mode get_mode_min
-#define get_max_of_mode get_mode_max
-#define get_mode_vector_elems(X) get_mode_n_vector_elems(X)
-#define get_null_of_mode get_mode_null
-#define get_fsigned_of_mode get_mode_fsigned
-#define get_ffloat_of_mode get_mode_ffloat
-#define get_mode_size(X) (assert(get_mode_size_bytes(X) != -1), get_mode_size_bytes(X))
-
-
-/* irop */
-#define floats op_pin_state_floats
-#define pinned op_pin_state_pinned
-#define op_pinned op_pin_state
-
-/* irdump */
-#define dump_cg_graph dump_ir_graph
-#define dump_cg_block_graph dump_ir_block_graph
-#define dont_dump_loop_information() dump_loop_information(0)
-
-/* type.h */
-typedef ir_type type;
-#define get_type_nameid(_t_) get_type_ident(_t_)
-#define set_type_nameid(_t_,_i_) set_type_ident(_t_,_i_)
-#define get_class_n_member get_class_n_members
-#define get_class_n_subtype get_class_n_subtypes
-#define get_class_n_supertype get_class_n_supertypes
-#define get_struct_n_member get_struct_n_members
-
-#define get_method_n_res(X) get_method_n_ress(X)
-
-/* entity.h */
-#define ent_visibility ir_visibility
-#define ent_allocation ir_allocation
-#define ent_stickyness ir_stickyness
-#define ent_volatility ir_volatility
-#define peculiarity ir_peculiarity
-#define entity ir_entity
-#define get_entity_offset_bytes(ent) get_entity_offset(ent)
-#define set_entity_offset_bytes(ent, ofs) set_entity_offset(ent, ofs)
-
-/* tv.h */
-#define tarval_from_long(X, Y) new_tarval_from_long(Y, X)
-#define tarval_P_from_entity(X) new_tarval_from_entity(X, mode_P_mach)
-#define tarval_to_entity(X) get_tarval_entity(X)
-#define tarval_to_long(X) get_tarval_long(X)
-#define tarval_to_double(X) get_tarval_double(X)
-#define tarval_set_mode_output_option(X, Y) set_tarval_mode_output_option(X, Y)
-#define tarval_get_mode_output_option(X) get_tarval_mode_output_option(X)
-#define tarval_bitpattern(X) get_tarval_bitpattern(X)
-#define tarval_sub_bits(X, Y) get_tarval_sub_bits(X, Y)
-#define tarval_classify(X) classify_tarval(X)
-#define get_tarval_P_void() get_tarval_null(mode_P)
-#define tarval_P_void get_tarval_null(mode_P)
-
-#define tarval_is_entity(X) 0
-#define get_tarval_entity(X) ((ir_entity *)NULL)
-
-/* ident.h */
-#define id_to_strlen(X) get_id_strlen(X)
-#define id_to_str(X) get_id_str(X)
-#define id_from_str(X, Y) new_id_from_chars(X, Y)
-
-/* irouts.h */
-#define compute_outs(X) compute_irg_outs(X)
-
-/* tr_inheritance.h */
-#define is_subclass_of(low, high) is_SubClass_of(low, high)
-#define is_subclass_ptr_of(low, high) is_SubClass_ptr_of(low, high)
-#define is_superclass_of(high, low) is_SuperClass_of(high, low)
-#define is_superclass_ptr_of(low, high) is_SuperClass_ptr_of(low, high)
-
-/* previously in irvrfy.h, now in irflag.h */
-#define NODE_VERIFICATION_OFF FIRM_VERIFICATION_OFF
-#define NODE_VERIFICATION_ON FIRM_VERIFICATION_ON
-#define NODE_VERIFICATION_REPORT FIRM_VERIFICATION_REPORT
-#define NODE_VERIFICATION_ERROR_ONLY FIRM_VERIFICATION_ERROR_ONLY
-
-/* execfreq.h */
-#define exec_freq_t ir_exec_freq
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Implements the Firm interface to debug information.
- * @author Goetz Lindenmaier, Michael Beck
- * @date 2001
- * @version $Id$
- * @summary
- * Firm requires a debugging module fulfilling this interface, else no
- * debugging information is passed to the backend.
- * The interface requires a datatype representing the debugging
- * information. Firm supports administrating a reference to the debug
- * information in every Firm node. Further Firm optimizations call
- * routines to propagate debug information from old nodes to new nodes
- * if the optimization replaces the old ones by the new ones.
- */
-#ifndef FIRM_DEBUG_DBGINFO_H
-#define FIRM_DEBUG_DBGINFO_H
-
-#include "firm_types.h"
-#include "ident.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @defgroup debug The Firm interface to debugging support.
- *
- * @{
- */
-
-/**
- * An abstract data type containing information for
- * debugging support.
- *
- * This opaque data type is not defined anywhere in the Firm library,
- * but pointers to this type can be stored in Firm nodes.
- */
-typedef struct dbg_info dbg_info;
-
-/**
- * Sets the debug information of a node.
- *
- * @param n The node.
- * @param db The debug info.
- */
-void set_irn_dbg_info(ir_node *n, dbg_info *db);
-
-/**
- * Returns the debug information of an node.
- *
- * @param n The node.
- */
-dbg_info *get_irn_dbg_info(const ir_node *n);
-
-/**
- * Sets the debug information of an entity.
- *
- * @param ent The entity.
- * @param db The debug info.
- */
-void set_entity_dbg_info(ir_entity *ent, dbg_info *db);
-
-/**
- * Returns the debug information of an entity.
- *
- * @param ent The entity.
- */
-dbg_info *get_entity_dbg_info(const ir_entity *ent);
-
-/**
- * Sets the debug information of a type.
- *
- * @param tp The type.
- * @param db The debug info.
- */
-void set_type_dbg_info(ir_type *tp, dbg_info *db);
-
-/**
- * Returns the debug information of a type.
- *
- * @param tp The type.
- */
-dbg_info *get_type_dbg_info(const ir_type *tp);
-
-/**
- * An enumeration indicating the action performed by a transformation.
- */
-typedef enum {
- dbg_error = 0,
- dbg_opt_ssa, /**< Optimization of the SSA representation, e.g. removal of superfluent Phi nodes. */
- dbg_opt_auxnode, /**< Removal of unnecessary auxiliary nodes. */
- dbg_const_eval, /**< A Firm subgraph was evaluated to a single constant. */
- dbg_opt_cse, /**< A Firm node was replaced due to common subexpression elimination. */
- dbg_straightening, /**< A Firm subgraph was replaced by a single, existing block. */
- dbg_if_simplification, /**< The control flow of an if is changed as either the
- else, the then or both blocks are empty. */
- dbg_algebraic_simplification, /**< A Firm subgraph was replaced because of an algebraic
- simplification. */
- dbg_write_after_write, /**< A Firm subgraph was replaced because of a write
- after write optimization. */
- dbg_write_after_read, /**< A Firm subgraph was replaced because of a write
- after read optimization. */
- dbg_read_after_write, /**< A Firm subgraph was replaced because of a read
- after write optimization. */
- dbg_read_after_read, /**< A Firm subgraph was replaced because of a read
- after read optimization. */
- dbg_read_a_const, /**< A Firm subgraph was replaced because of a read
- a constant optimization. */
- dbg_rem_poly_call, /**< Remove polymorphic call. */
- dbg_dead_code, /**< Removing unreachable code, I.e. blocks that are never executed. */
- dbg_opt_confirm, /**< A Firm subgraph was replace because of a Confirmation. */
- dbg_backend, /**< A Firm subgraph was replaced because of a Backend transformation */
- dbg_max /**< Maximum value. */
-} dbg_action;
-
-/**
- * Converts a debug_action into a string.
- *
- * @param a the debug action
- */
-const char *dbg_action_2_str(dbg_action a);
-
-/**
- * The type of the debug info merge function.
- *
- * @param new_node the new ir node
- * @param old_node the old ir node
- * @param action the action that triggers the merge
- *
- * @see dbg_init()
- */
-typedef void merge_pair_func(ir_node *new_node, ir_node *old_node, dbg_action action);
-
-/**
- * The type of the debug info merge sets function.
- *
- * @param new_node_array array of new nodes
- * @param new_num_entries number of entries in new_node_array
- * @param old_node_array array of old nodes
- * @param old_num_entries number of entries in old_node_array
- * @param action the action that triggers the merge
- *
- * @see dbg_init()
- */
-typedef void merge_sets_func(ir_node **new_node_array, int new_num_entries, ir_node **old_node_array, int old_num_entries, dbg_action action);
-
-/**
- * The type of the debug info to human readable string function.
- *
- * @param buf pointer to a buffer that will hold the info
- * @param len length of the buffer
- * @param dbg the debug info
- *
- * @return Number of written characters to the buffer.
- *
- * @see dbg_init()
- */
-typedef unsigned snprint_dbg_func(char *buf, unsigned len, const dbg_info *dbg);
-
-/**
- * Initializes the debug support.
- *
- * @param dbg_info_merge_pair see function description
- * @param dbg_info_merge_sets see function description
- * @param snprint_dbg see function description
- *
- * This function takes pointers to two functions that merge the
- * debug information when a
- * transformation of a Firm graph is performed.
- * Firm transformations call one of these functions.
- *
- * - dbg_info_merge_pair() is called in the following situation:
- * The optimization replaced the old node by the new one. The new node
- * might be a recent allocated node not containing any debug information,
- * or just another node from somewhere in the graph with the same
- * semantics.
- * - dbg_info_merge_sets() is called in the following situation:
- * The optimization replaced a subgraph by another subgraph. There is no
- * obviously mapping between single nodes in both subgraphs. The optimization
- * simply passes two lists to the debug module, one containing the nodes in
- * the old subgraph, the other containing the nodes in the new subgraph.
- * The same node can be in both lists.
- *
- * Further both functions pass an enumeration indicating the action
- * performed by the transformation, e.g. the kind of optimization performed.
- *
- * The third argument snprint_dbg is called to convert a debug info into a human readable string.
- * This string is the dumped in the dumper functions.
- *
- * Note that if NULL is passed for dbg_info_merge_pair or dbg_info_merge_sets, the default
- * implementations default_dbg_info_merge_pair() and default_dbg_info_merge_sets() are used.
- * NULL passed for snprint_dbg means no output.
- */
-void dbg_init(merge_pair_func *dbg_info_merge_pair, merge_sets_func *dbg_info_merge_sets, snprint_dbg_func *snprint_dbg);
-
-/**
- * The default merge_pair_func implementation, simply copies the debug info
- * from the old Firm node to the new one if the new one does not have debug info yet.
- *
- * @param nw The new Firm node.
- * @param old The old Firm node.
- * @param info The action that cause old node to be replaced by new one.
- */
-void default_dbg_info_merge_pair(ir_node *nw, ir_node *old, dbg_action info);
-
-/**
- * The default merge_sets_func implementation. If n_old_nodes is equal 1, copies
- * the debug info from the old node to all new ones (if they do not have one), else does nothing.
- *
- * @param new_nodes An array of new Firm nodes.
- * @param n_new_nodes The length of the new_nodes array.
- * @param old_nodes An array of old (replaced) Firm nodes.
- * @param n_old_nodes The length of the old_nodes array.
- * @param info The action that cause old node to be replaced by new one.
- */
-void default_dbg_info_merge_sets(ir_node **new_nodes, int n_new_nodes,
- ir_node **old_nodes, int n_old_nodes,
- dbg_action info);
-
-/** @} */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
#include "irgraph_t.h"
#include "entity_t.h"
#include "irprintf.h"
-#include "typewalk.h"
#include "irdump.h"
#include "debug.h"
#define FIRM_DBG_MINOR 0
/** for automatic detection of the debug extension */
-static const char *firm_debug_info_string =
+static const char firm_debug_info_string[] =
API_VERSION(FIRM_DBG_MAJOR, FIRM_DBG_MINOR);
/**
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Connect firm to ycomp
- * @author Christian Wuerdig
- * @date 16.11.2006
- * @version $Id$
- */
-#ifndef FIRM_DEBUG_FIRM_YCOMP_H
-#define FIRM_DEBUG_FIRM_YCOMP_H
-
-#define FIRM_YCOMP_DEFAULT_HOST "localhost"
-#define FIRM_YCOMP_DEFAULT_PORT 4242
-
-/**
- * Establish connection to yComp and register debugger hooks.
- * @param host Hostname where yComp is running
- * @param port Port on which yComp is listening
- */
-void firm_init_ycomp_debugger(const char *host, unsigned port);
-
-/**
- * Close connection to yComp and unregister debugger hooks.
- */
-void firm_finish_ycomp_debugger(void);
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Implements simple sequence numbers for Firm debug info.
- * @author Michael Beck
- * @date 2005
- * @version $Id$
- * @summary
- * Sequence numbers for Firm.
- *
- * A sequence number is an unique number representing a filename
- * and a line number. The number 0 represents empty information.
- * This module is an optional "snap-in" for the Firm debug info.
- * In simple cases it should be possible to use sequence numbers
- * as dbg_info.
- */
-#ifndef FIRM_DEBUG_SEQNUMBERS_H
-#define FIRM_DEBUG_SEQNUMBERS_H
-
-#include "ident.h"
-
-/**
- * An opaque type for a sequence number.
- */
-#ifndef _SEQNO_T_TYPEDEF_
-#define _SEQNO_T_TYPEDEF_
-typedef struct sn_entry *seqno_t;
-#endif
-
-/**
- * Create a new sequence number from a filename and a line number.
- *
- * @param filename a file name
- * @param lineno a line number
- *
- * @return a sequence number for this position.
- */
-seqno_t firm_seqno_enter(const char *filename, unsigned lineno);
-
-/**
- * Create a new sequence number from a filename ident and a line number.
- *
- * @param filename an ident
- * @param lineno a line number
- *
- * @return a sequence number for this position.
- */
-seqno_t firm_seqno_enter_id(ident *filename, unsigned lineno);
-
-/**
- * Retrieve filename and line number from a sequence number.
- *
- * @param seqno a sequence number
- * @param lineno after return contains the line number of this position
- *
- * @return the file name of this position.
- */
-const char *firm_seqno_retrieve(seqno_t seqno, unsigned *lineno);
-
-/**
- * Creates the sequence number pool.
- * Is not called by init_firm(), because the sequence number
- * support is optional. Call firm_seqno_init() after init_firm()
- * if sequence numbers should be used.
- */
-void firm_seqno_init(void);
-
-/**
- * Terminates the sequence number pool.
- * Sequence numbers cannot be resolved anymore.
- * Call this function to terminate the sequence
- * pool.
- */
-void firm_seqno_term(void);
-
-#endif
# include "config.h"
#endif
-#ifdef HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
-# include <string.h>
-#endif
-
+#include <stdlib.h>
+#include <string.h>
#include <assert.h>
#include <libxml/xmlmemory.h>
#include "irmode.h"
#include "irdump.h"
#include "irvrfy.h"
-#include "type.h"
+#include "typerep.h"
#include "tv.h"
#include "xmalloc.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Data type for unique names.
- * @author Goetz Lindenmaier
- * @version $Id$
- * @summary
- * Declarations for identifiers in the firm library
- *
- * Identifiers are used in the firm library. This is the interface to it.
- */
-#ifndef FIRM_IDENT_IDENT_H
-#define FIRM_IDENT_IDENT_H
-
-#include "firm_config.h"
-
-#ifdef FIRM_ENABLE_WCHAR
-#include <wchar.h>
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Identifiers */
-
-/**
- * The abstract data type ident.
- *
- * An ident represents an unique string. The == operator
- * is sufficient to compare two idents.
- */
-#ifndef _IDENT_TYPEDEF_
-#define _IDENT_TYPEDEF_
-typedef const struct _ident ident;
-#endif
-
-/**
- * The ident module interface.
- */
-typedef struct _ident_if_t {
- /** The handle. */
- void *handle;
-
- /**
- * Store a string and create an ident.
- * This function may be NULL, new_id_from_chars()
- * is then used to emulate it's behavior.
- *
- * @param str - the string which shall be stored
- */
- ident *(*new_id_from_str)(void *handle, const char *str);
-
- /**
- * Store a string and create an ident.
- *
- * @param str - the string (or whatever) which shall be stored
- * @param len - the length of the data in bytes
- */
- ident *(*new_id_from_chars)(void *handle, const char *str, int len);
-
- /**
- * Returns a string represented by an ident.
- */
- const char *(*get_id_str)(void *handle, ident *id);
-
- /**
- * Returns the length of the string represented by an ident.
- * This function may be NULL, get_id_str() is then used
- * to emulate it's behavior.
- *
- * @param id - the ident
- */
- int (*get_id_strlen)(void *handle, ident *id);
-
- /**
- * Finish the ident module and frees all idents, may be NULL.
- */
- void (*finish_ident)(void *handle);
-
-#ifdef FIRM_ENABLE_WCHAR
- /**
- * Store a wide character string and create an ident.
- * This function may be NULL, new_id_from_wchars()
- * is then used to emulate it's behavior.
- *
- * @param wstr - the string which shall be stored
- */
- ident *(*new_id_from_wcs)(void *handle, const wchar_t *wstr);
-
- /**
- * Store a wide character string and create an ident.
- * This function may be NULL, new_id_from_chars() is then used appropriate.
- * Beware: the string might not be stored at a right alignment!
- *
- * @param wstr - the wide character string which shall be stored
- * @param len - the length of the string
- */
- ident *(*new_id_from_wchars)(void *handle, const wchar_t *wstr, int len);
-
- /**
- * Returns a wide character string represented by an ident.
- * This function may be NULL, get_id_str() is then used.
- * This assume that the strings are stored at an address aligned
- * for wchar_t, so beware!
- */
- const wchar_t *(*get_id_wcs)(void *handle, ident *id);
-
- /**
- * Returns the length of the string represented by an ident.
- * This function may be NULL, get_id_wcs() is then used
- * to emulate it's behavior.
- *
- * @param id - the ident
- */
- int (*get_id_wcslen)(void *handle, ident *id);
-#endif
-} ident_if_t;
-
-/**
- * Store a string and create an ident.
- *
- * Stores a string in the ident module and returns a handle for the string.
- *
- * Copies the string. @p str must be zero terminated
- *
- * @param str - the string which shall be stored
- *
- * @return id - a handle for the generated ident
- *
- * @see get_id_str(), get_id_strlen()
- */
-ident *new_id_from_str (const char *str);
-
-/** Store a string and create an ident.
- *
- * Stores a string in the ident module and returns a handle for the string.
- * Copies the string. This version takes non-zero-terminated strings.
- *
- * @param str - the string (or whatever) which shall be stored
- * @param len - the length of the data in bytes
- *
- * @return id - a handle for the generated ident
- *
- * @see new_id_from_str(), get_id_strlen()
- */
-ident *new_id_from_chars (const char *str, int len);
-
-/**
- * Returns a string represented by an ident.
- *
- * Returns the string represented by id. This string is
- * NULL terminated. The string may not be changed.
- *
- * @param id - the ident
- *
- * @return cp - a string
- *
- * @see new_id_from_str(), new_id_from_chars(), get_id_strlen()
- */
-const char *get_id_str (ident *id);
-
-/**
- * Returns the length of the string represented by an ident.
- *
- * @param id - the ident
- *
- * @return len - the length of the string
- *
- * @see new_id_from_str(), new_id_from_chars(), get_id_str()
- */
-int get_id_strlen(ident *id);
-
-/**
- * Returns true if prefix is a prefix of an ident.
- *
- * @param prefix - the prefix
- * @param id - the ident
- *
- * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix()
- */
-int id_is_prefix (ident *prefix, ident *id);
-
-/**
- * Returns true if suffix is a suffix of an ident.
- *
- * @param suffix - the suffix
- * @param id - the ident
- *
- * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix()
- */
-int id_is_suffix (ident *suffix, ident *id);
-
-/**
- * Returns true if infix is contained in id. (Can be suffix or prefix)
- *
- * @param infix - the infix
- * @param id - the ident to search in
- *
- * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix()
- */
-/* int id_contains(ident *infix, ident *id); */
-
-/**
- * Return true if an ident contains a given character.
- *
- * @param id - the ident
- * @param c - the character
- *
- * @see new_id_from_str(), new_id_from_chars(), get_id_str()
- */
-int id_contains_char (ident *id, char c);
-
-#ifdef FIRM_ENABLE_WCHAR
-/**
- * Store a wide character string and create an ident.
- *
- * Stores a string in the ident module and returns a handle for the string.
- *
- * Copies the string. @p str must be zero terminated
- *
- * @param str - the wide character string which shall be stored
- *
- * @return id - a handle for the generated ident
- *
- * @see get_id_wcs(), get_id_wcs()
- */
-ident *new_id_from_wcs (const wchar_t *str);
-
-/** Store a wide character string and create an ident.
- *
- * Stores a string in the ident module and returns a handle for the string.
- * Copies the string. This version takes non-zero-terminated strings.
- *
- * @param wstr - the wide character string (or whatever) which shall be stored
- * @param len - the length of string
- *
- * @return id - a handle for the generated ident
- *
- * @see new_id_from_str(), get_id_strlen()
- */
-ident *new_id_from_wchars (const wchar_t *str, int len);
-
-/**
- * Returns a wide character string represented by an ident.
- *
- * Returns the string represented by id. This string is
- * NULL terminated. The string may not be changed.
- *
- * @param id - the ident
- *
- * @return cp - a string
- *
- * @see new_id_from_wcs(), new_id_from_wchars(), get_id_wcslen()
- */
-const wchar_t *get_id_wcs(ident *id);
-
-/**
- * Returns the length of the wide character string represented by an ident.
- *
- * @param id - the ident
- *
- * @return len - the length of the string
- *
- * @see new_id_from_wcs(), new_id_from_wchars(), get_id_wcs()
- */
-int get_id_wcslen(ident *id);
-
-/**
- * Return true if an ident contains a given character.
- *
- * @param id - the ident
- * @param c - the character
- *
- * @see new_id_from_wcs(), new_id_from_chars(), get_id_str()
- */
-int id_contains_wchar (ident *id, wchar_t c);
-
-#endif /* FIRM_ENABLE_WCHAR */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
--- /dev/null
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Methods to manipulate names.
+ * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Michael Beck
+ * @version $Id$
+ */
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+# include <stdio.h>
+
+#include "ident.h"
+#include "obst.h"
+
+/* Make types visible to allow most efficient access */
+#include "entity_t.h"
+#include "type_t.h"
+#include "tpop_t.h"
+
+/** An obstack used for temporary space */
+static struct obstack mangle_obst;
+
+/** returned a mangled type name, currently no mangling */
+static INLINE ident *mangle_type(ir_type *tp) {
+ assert(tp->kind == k_type);
+ return tp->name;
+}
+
+ident *mangle_entity(ir_entity *ent) {
+ ident *type_id;
+ char *cp;
+ int len;
+ ident *res;
+
+ type_id = mangle_type(ent->owner);
+ obstack_grow(&mangle_obst, get_id_str(type_id), get_id_strlen(type_id));
+ obstack_1grow(&mangle_obst,'_');
+ obstack_grow(&mangle_obst,get_id_str(ent->name),get_id_strlen(ent->name));
+ len = obstack_object_size (&mangle_obst);
+ cp = obstack_finish (&mangle_obst);
+ res = new_id_from_chars(cp, len);
+ obstack_free (&mangle_obst, cp);
+ return res;
+}
+
+
+/* Returns a new ident that represents 'firstscnd'. */
+ident *mangle(ident *first, ident *scnd) {
+ char *cp;
+ int len;
+ ident *res;
+
+ obstack_grow(&mangle_obst, get_id_str(first), get_id_strlen(first));
+ obstack_grow(&mangle_obst, get_id_str(scnd), get_id_strlen(scnd));
+ len = obstack_object_size (&mangle_obst);
+ cp = obstack_finish (&mangle_obst);
+ res = new_id_from_chars (cp, len);
+ obstack_free (&mangle_obst, cp);
+ return res;
+}
+
+/** Returns a new ident that represents 'prefixscndsuffix'. */
+static ident *mangle3(const char *prefix, ident *scnd, const char *suffix) {
+ char *cp;
+ int len;
+ ident *res;
+
+ obstack_grow(&mangle_obst, prefix, strlen(prefix));
+ obstack_grow(&mangle_obst, get_id_str(scnd), get_id_strlen(scnd));
+ obstack_grow(&mangle_obst, suffix, strlen(suffix));
+ len = obstack_object_size (&mangle_obst);
+ cp = obstack_finish (&mangle_obst);
+ res = new_id_from_chars (cp, len);
+ obstack_free (&mangle_obst, cp);
+ return res;
+}
+
+/** Returns a new ident that represents first<c>scnd. */
+static ident *mangle_3(ident *first, char c, ident* scnd) {
+ char *cp;
+ int len;
+ ident *res;
+
+ obstack_grow(&mangle_obst, get_id_str(first), get_id_strlen(first));
+ obstack_1grow(&mangle_obst, c);
+ obstack_grow(&mangle_obst,get_id_str(scnd),get_id_strlen(scnd));
+ len = obstack_object_size (&mangle_obst);
+ cp = obstack_finish (&mangle_obst);
+ res = new_id_from_chars (cp, len);
+ obstack_free (&mangle_obst, cp);
+ return res;
+}
+
+/* Returns a new ident that represents first_scnd. */
+ident *mangle_u(ident *first, ident* scnd) {
+ return mangle_3(first, '_', scnd);
+}
+
+/* Returns a new ident that represents first.scnd. */
+ident *mangle_dot(ident *first, ident* scnd) {
+ return mangle_3(first, '.', scnd);
+}
+
+/* returns a mangled name for a Win32 function using it's calling convention */
+ident *decorate_win32_c_fkt(ir_entity *ent, ident *id) {
+ ir_type *tp = get_entity_type(ent);
+ unsigned cc_mask = get_method_calling_convention(tp);
+ char buf[16];
+ int size, i;
+
+ if (IS_CDECL(cc_mask))
+ return mangle3("_", id, "");
+ else if (IS_STDCALL(cc_mask)) {
+ size = 0;
+ for (i = get_method_n_params(tp) - 1; i >= 0; --i) {
+ size += get_type_size_bytes(get_method_param_type(tp, i));
+ }
+
+ snprintf(buf, sizeof(buf), "@%d", size);
+
+ if (cc_mask & cc_reg_param)
+ return mangle3("@", id, buf);
+ else
+ return mangle3("_", id, buf);
+ }
+ return id;
+}
+
+void firm_init_mangle(void) {
+ obstack_init(&mangle_obst);
+}
#include "irhooks.h"
#include "ircons.h"
#include "irarch.h"
-#include "irreflect.h"
#undef DEB
params = factory();
if (! op_Mulh) {
- rflct_sig_t *sig;
int mulh_opc = get_next_ir_opcode();
/* create the Mulh operation */
op_Mulh = new_ir_op(mulh_opc, "Mulh", op_pin_state_floats, irop_flag_commutative, oparity_binary, 0, 0, NULL);
- sig = rflct_signature_allocate(1, 3);
- rflct_signature_set_arg(sig, 0, 0, "Res", RFLCT_MC(Int), 0, 0);
- rflct_signature_set_arg(sig, 1, 0, "Block", RFLCT_MC(BB), 0, 0);
- rflct_signature_set_arg(sig, 1, 1, "Op 0", RFLCT_MC(Int), 0, 0);
- rflct_signature_set_arg(sig, 1, 2, "Op 1", RFLCT_MC(Int), 0, 0);
-
- rflct_new_opcode(mulh_opc, "Mulh", 0);
- rflct_opcode_add_signature(mulh_opc, sig);
}
}
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Some machine dependent optimizations.
- * @date 1.10.2004
- * @author Sebastian Hack
- * @version $Id$
- */
-#ifndef FIRM_IR_IRARCH_H
-#define FIRM_IR_IRARCH_H
-
-#include "firm_types.h"
-
-/**
- * A parameter structure that drives the machine dependent Firm
- * optimizations.
- */
-typedef struct {
- /* Mul optimization */
- unsigned also_use_subs : 1; /**< Use also Subs when resolving Muls to shifts */
- int maximum_shifts; /**< The maximum number of shifts that shall be inserted for a mul. */
- unsigned highest_shift_amount; /**< The highest shift amount you want to
- tolerate. Muls which would require a higher
- shift constant are left. */
-
- /* Div/Mod optimization */
- unsigned allow_mulhs : 1; /**< Use the Mulhs operation for division by constant */
- unsigned allow_mulhu : 1; /**< Use the Mulhu operation for division by constant */
- int max_bits_for_mulh; /**< Maximum number of bits the Mulh operation can take.
- Modes with higher amount of bits will use Mulh */
-} arch_dep_params_t;
-
-/**
- * A factory function, that provides architecture parameters for
- * machine dependent optimizations.
- */
-typedef const arch_dep_params_t *(*arch_dep_params_factory_t)(void);
-
-/**
- * A default parameter factory for testing purposes.
- */
-const arch_dep_params_t *arch_dep_default_factory(void);
-
-/**
- * Optimization flags.
- */
-typedef enum {
- arch_dep_none = 0,
- arch_dep_mul_to_shift = 1, /**< optimize Mul into Shift/Add/Sub */
- arch_dep_div_by_const = 2, /**< optimize Div into Shift/Add/Mulh */
- arch_dep_mod_by_const = 4 /**< optimize Mod into Shift/Add/Mulh */
-} arch_dep_opts_t;
-
-/**
- * Initialize the machine dependent optimizations.
- * @param factory A factory that delivers parameters for these
- * optimizations. If NULL is passed, or this method
- * is not called, the machine dependent optimizations
- * are not enabled at all.
- */
-void arch_dep_init(arch_dep_params_factory_t factory);
-
-/**
- * Set the optimizations that shall be applied.
- * @param opts An optimization bit mask.
- */
-void arch_dep_set_opts(arch_dep_opts_t opts);
-
-/**
- * Replace Muls with Shifts and Add/Subs.
- * This function is driven by the 3 parameters:
- * - also_use_subs
- * - maximum_shifts
- * - highest_shift_amount
- *
- * If irn is a Mul with a Const, the constant is inspected if it meets the
- * requirements of the three variables stated above. If a Shl/Add/Sub
- * sequence can be generated that meets these requirements, this expression
- * is returned. In each other case irn is returned unmodified.
- *
- * @param irn The Firm node to inspect.
- * @return A replacement expression for irn.
- */
-ir_node *arch_dep_replace_mul_with_shifts(ir_node *irn);
-
-/**
- * Replace Divs with Shifts and Add/Subs and Mulh.
- * This function is driven by the 3 parameters:
- * - allow_mulhu
- * - allow_mulhs
- * - max_bits_for_mulh
- *
- * If irn is a Div with a Const, the constant is inspected if it meets the
- * requirements of the variables stated above. If a Shl/Add/Sub/Mulh
- * sequence can be generated that meets these requirements, this expression
- * is returned. In each other case irn is returned unmodified.
- *
- * @param irn The Firm node to inspect.
- * @return A replacement expression for irn.
- */
-ir_node *arch_dep_replace_div_by_const(ir_node *irn);
-
-/**
- * Replace Mods with Shifts and Add/Subs and Mulh.
- * This function is driven by the 3 parameters:
- * - allow_mulhu
- * - allow_mulhs
- * - max_bits_for_mulh
- *
- * If irn is a Mod with a Const, the constant is inspected if it meets the
- * requirements of the variables stated above. If a Shl/Add/Sub/Mulh
- * sequence can be generated that meets these requirements, this expression
- * is returned. In each other case irn is returned unmodified.
- *
- * @param irn The Firm node to inspect.
- * @return A replacement expression for irn.
- */
-ir_node *arch_dep_replace_mod_by_const(ir_node *irn);
-
-/**
- * Replace DivMods with Shifts and Add/Subs and Mulh.
- * This function is driven by the 3 parameters:
- * - allow_mulhu
- * - allow_mulhs
- * - max_bits_for_mulh
- *
- * If irn is a DivMod with a Const, the constant is inspected if it meets the
- * requirements of the variables stated above. If a Shl/Add/Sub/Mulh
- * sequence can be generated that meets these requirements, this expression
- * is returned. In each other case irn is returned unmodified.
- *
- * @param div After call contains the Firm node div result or NULL.
- * @param mod After call contains the Firm node mod result or NULL.
- * @param irn The Firm node to inspect.
- */
-void arch_dep_replace_divmod_by_const(ir_node **div, ir_node **mod, ir_node *irn);
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Construction and removal of interprocedural representation
- * (explicit interprocedural dependencies).
- * @author Hubert Schmid
- * @date 09.06.2002
- * @version $Id$
- */
-#ifndef FIRM_IR_IRCGCONS_H
-#define FIRM_IR_IRCGCONS_H
-
-#include "firm_types.h"
-
-/** The state of the interprocedural view.
- *
- * This value indicates the state of the interprocedural view.
- */
-typedef enum {
- ip_view_no, /**< The interprocedural view is not constructed. There are no
- view specific nodes (EndReg, Filter, Break ...) in any graph. */
- ip_view_valid, /**< The interprocedural view is valid. */
- ip_view_invalid /**< The interprocedural view is invalid. Specific nodes are
- all still in the representation, but the graph is no more complete. */
-} ip_view_state;
-
-/** Return the current state of the interprocedural view. */
-ip_view_state get_irp_ip_view_state(void);
-/** Set the state of the interprocedural view to invalid. */
-void set_irp_ip_view_invalid(void);
-
-/** Construction of the interprocedural view.
- *
- * Construction of the interprocedural view. A prior analysis must have set
- * all possible callees in the corresponding fields of Call nodes. Sets
- * ip_view_valid in irp.
- *
- * @arg free_methods_arr: An array of all free methods, i.e., methods that
- * are external visible. These methods get an 'Unknown'
- * caller.
- * @arg arr_len The number of free methods. */
-void cg_construct(int arr_len, ir_entity *free_methods_arr[]);
-
-
-/** Deconstruction of the interprocedural view. Reduces memory consumption of
- the ir. Sets ip_view_no in irp. */
-void cg_destruct(void);
-
-#endif
#include "irloop_t.h"
#include "irflag_t.h"
#include "ircons.h"
-#include "typewalk.h"
#include "irtools.h"
/**
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Removal of unreachable methods.
- * @author Hubert Schmid
- * @date 09.06.2002
- * @version $Id$
- * @summary
- * (TODO: translate to english)
- * Entfernen von nicht erreichbaren (aufrufbaren) Methoden. Die Menge
- * der nicht erreichbaren Methoden wird aus der Abschätzung der
- * Aufrufrelation bestimmt.
- */
-#ifndef FIRM_IR_ICGOPT_H
-#define FIRM_IR_ICGOPT_H
-
-#include "firm_types.h"
-
-/* Entfernt alle Methoden, die von den Methoden aus "keep_arr"
- * (bezgl. der Abschaetzung get_Call_callee) nicht erreichbar sind. Die
- * Abschaetzung der Aufrufrelation muss entsprechend an den
- * Call-Operationen gespeichert sein. Die "entity->link"s werden dabei
- * ueberschrieben.
- *
- * Frees all interprocedural loop information. */
-void gc_irgs(int n_keep, ir_entity *keep_arr[]);
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Various irnode constructors. Automatic construction of SSA
- * representation.
- * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Boris Boesler,
- * Michael Beck
- * @version $Id$
- */
-
-/**@todo
- Ideas for improvement:
- -# Handle construction of exceptions more comfortable:
- Add new constructors that pass the exception region (or better the
- Phi for the memories, the ex. region can be found from there) as parameter,
- constructor then adds all Proj nodes and returns the pointer
- to the Proj node that selects the result of the arithmetic operation.
- -# Maybe hide the exception region in a global variable, especially if
- it is always unambiguous.
-*/
-
-/**
- * @file
- *
- * documentation no more supported since 2001
- *
- * ir node construction.
- *
- * This file documents all datatypes and constructors needed to
- * build a FIRM representation of a procedure. The constructors are
- * also implemented in this file.
- *
- * The documentation also gives a short manual how to use the library.
- *
- * For extensive documentation of FIRM see UKA Techreport 1999-14.
- *
- *
- * Three kinds of nodes
- * --------------------
- *
- * There are three kinds of nodes known to the ir: entities,
- * types, and ir_nodes
- *
- * + ir_nodes are the actual nodes of the FIRM intermediate representation.
- * They represent operations on the data of the program and control flow
- * operations.
- *
- * + entity ==> implemented in entity.h
- * Refers to a single entity of the compiled program, e.g. a field of a
- * class or a method. If a method or variable can not be assigned to
- * a method or class or the like, it is a global object.
- *
- * + types ==> implemented in type.h
- * With types type information is represented. There are several type
- * nodes.
- *
- * Implementation of the FIRM operations: ir_node
- * ----------------------------------------------
- *
- * Ir_nodes represent operations on the data of the program and control flow
- * operations. Examples of ir_nodes: Add, Jmp, Cmp
- *
- * FIRM is a dataflow graph. A dataflow graph is a directed graph,
- * so that every node has incoming and outgoing edges. A node is
- * executable if every input at it's incoming edges is available.
- * Execution of the dataflow graph is started at the Start node which
- * has no incoming edges and ends when the End node executes, even if
- * there are still executable or not executed nodes. (Is this true,
- * or must all executable nodes be executed?) (There are exceptions
- * to the dataflow paradigma that all inputs have to be available
- * before a node can execute: Phi, Block. See UKA Techreport
- * 1999-14.)
- *
- * The implementation of FIRM differs from the view as a dataflow
- * graph. To allow fast traversion of the graph edges are
- * implemented as C-pointers. Inputs to nodes are not ambiguous, the
- * results can be used by several other nodes. Each input can be
- * implemented as a single pointer to a predecessor node, outputs
- * need to be lists of pointers to successors. Therefore a node
- * contains pointers to it's predecessor so that the implementation is a
- * dataflow graph with reversed edges. It has to be traversed bottom
- * up.
- *
- * All nodes of the ir have the same basic structure. They are
- * distinguished by a field containing the opcode.
- *
- * The fields of an ir_node:
- *
- * kind A firm_kind tag containing k_ir_node. This is useful for
- * dynamically checking the type of a node.
- *
- * *op This ir_op gives the opcode as a tag and a string
- * and the number of attributes of an ir_node. There is
- * one statically allocated struct ir_op for each opcode.
- *
- * *mode The ir_mode of the operation represented by this firm
- * node. The mode of the operation is the mode of it's
- * result. A Firm mode is a datatype as known to the target,
- * not a type of the source language.
- *
- * visit A flag for traversing the ir.
- *
- * **in An array with pointers to the node's predecessors.
- *
- * *link A pointer to an ir_node. With this pointer all Phi nodes
- * are attached to a Block, i.e., a Block points to it's
- * first Phi node, this node points to the second Phi node
- * in the Block and so fourth. Used in mature_immBlock
- * to find all Phi nodes to be matured. It's also used to
- * annotate a node with a better, optimized version of it.
- *
- * attr An attr struct containing the attributes of the nodes. The
- * attributes depend on the opcode of the node. The number
- * of these attributes is given in op.
- *
- * The struct ir_op
- * ----------------
- * Not yet documented. See irop.h.
- *
- * The struct ir_mode
- * ------------------
- * Not yet documented. See irmode.h.
- *
- * GLOBAL VARIABLES -- now also fields of ir_graph.
- * ================
- *
- * current_ir_graph Points to the current ir_graph. All constructors for
- * nodes add nodes to this graph.
- *
- * ir_visited An int used as flag to traverse the ir_graph.
- *
- * block_visited An int used as a flag to traverse block nodes in the
- * graph.
- *
- * Others not yet documented.
- *
- *
- *
- * CONSTRUCTOR FOR IR_GRAPH --> see irgraph.h
- * ========================
- *
- *
- * PROCEDURE TO CONSTRUCT AN IR GRAPH --> see also Firm tutorial
- * ==================================
- *
- * This library supplies several interfaces to construct a FIRM graph for
- * a program:
- * - A "comfortable" interface generating SSA automatically. Automatically
- * computed predecessors of nodes need not be specified in the constructors.
- * (new_<Node> constructurs and a set of additional routines.)
- * - A less comfortable interface where all predecessors except the block
- * an operation belongs to need to be specified. SSA must be constructed
- * by hand. (new_<Node> constructors and set_cur_block()). This interface
- * is called "block oriented". It automatically calles the local optimizations
- * for each new node.
- * - An even less comfortable interface where the block needs to be specified
- * explicitly. This is called the "raw" interface. (new_r_<Node>
- * constructors). These nodes are not optimized.
- *
- * To use the functionality of the comfortable interface correctly the Front
- * End needs to follow certain protocols. This is explained in the following.
- * To build a correct IR with the other interfaces study the semantics of
- * the firm node (See tech-reprot UKA 1999-14). For the construction of
- * types and entities see the documentation in those modules.
- *
- * First the Frontend needs to decide which variables and values used in
- * a procedure can be represented by dataflow edges. These are variables
- * that need not be saved to memory as they cause no side effects visible
- * out of the procedure. Often these are all compiler generated
- * variables and simple local variables of the procedure as integers,
- * reals and pointers. The frontend has to count and number these variables.
- *
- * First an ir_graph needs to be constructed with new_ir_graph. The
- * constructor gets the number of local variables. The graph is hold in the
- * global variable irg.
- *
- * Now the construction of the procedure can start. Several basic blocks can
- * be constructed in parallel, but the code within each block needs to
- * be constructed (almost) in program order.
- *
- * A global variable holds the current basic block. All (non block) nodes
- * generated are added to this block. The current block can be set with
- * set_cur_block(block). If several blocks are constructed in parallel block
- * switches need to be performed constantly.
- *
- * To generate a Block node (with the comfortable interface) it's predecessor
- * control flow nodes need not be known. In case of cyclic control flow these
- * can not be known when the block is constructed. With add_immBlock_pred(block,
- * cfnode) predecessors can be added to the block. If all predecessors are
- * added to the block mature_immBlock(b) needs to be called. Calling mature_immBlock
- * early improves the efficiency of the Phi node construction algorithm.
- * But if several blocks are constructed at once, mature_immBlock must only
- * be called after performing all set_values and set_stores in the block!
- * (See documentation of new_immBlock constructor.)
- *
- * The constructors of arithmetic nodes require that their predecessors
- * are mentioned. Sometimes these are available in the Frontend as the
- * predecessors have just been generated by the frontend. If they are local
- * values the predecessors can be obtained from the library with a call to
- * get_value(local_val_nr). (local_val_nr needs to be administered by
- * the Frontend.) A call to get_value triggers the generation of Phi nodes.
- * If an arithmetic operation produces a local value this value needs to be
- * passed to the library by set_value(node, local_val_nr).
- * In straight line code these two operations just remember and return the
- * pointer to nodes producing the value. If the value passes block boundaries
- * Phi nodes can be inserted.
- * Similar routines exist to manage the Memory operands: set_store and
- * get_store.
- *
- * Several nodes produce more than one result. An example is the Div node.
- * Such nodes return tuples of values. From these individual values can be
- * extracted by proj nodes.
- *
- * The following example illustrates the construction of a simple basic block
- * with two predecessors stored in variables cf_pred1 and cf_pred2, containing
- * the code
- * a = a div a;
- * and finally jumping to an other block. The variable a got the local_val_nr
- * 42 by the frontend.
- *
- * ir_node *this_block, *cf_pred1, *cf_pred2, *a_val, *mem, *div, *res, *cf_op;
- *
- * this_block = new_immBlock();
- * add_immBlock_pred(this_block, cf_pred1);
- * add_immBlock_pred(this_block, cf_pred2);
- * mature_immBlock(this_block);
- * a_val = get_value(42, mode_Iu);
- * mem = get_store();
- * div = new_Div(mem, a_val, a_val, mode_Iu);
- * mem = new_Proj(div, mode_M, pn_Div_M); * for the numbers for Proj see docu *
- * res = new_Proj(div, mode_Iu, pn_Div_res);
- * set_store(mem);
- * set_value(res, 42);
- * cf_op = new_Jmp();
- *
- * For further information look at the documentation of the nodes and
- * constructors and at the paragraph COPING WITH DATA OBJECTS at the
- * end of this documentation.
- *
- * The comfortable interface contains the following routines further explained
- * below:
- *
- * ir_node *new_immBlock (void);
- * ir_node *new_Start (void);
- * ir_node *new_End (void);
- * ir_node *new_Jmp (void);
- * ir_node *new_IJmp (ir_node *tgt);
- * ir_node *new_Cond (ir_node *c);
- * ir_node *new_Return (ir_node *store, int arity, ir_node **in);
- * ir_node *new_Const (ir_mode *mode, tarval *con);
- * ir_node *new_SymConst (symconst_symbol value, symconst_kind kind);
- * ir_node *new_simpleSel (ir_node *store, ir_node *objptr, ir_entity *ent);
- * ir_node *new_Sel (ir_node *store, ir_node *objptr, int arity,
- * ir_node **in, ir_entity *ent);
- * ir_node *new_Call (ir_node *store, ir_node *callee, int arity,
- * ir_node **in, type_method *type);
- * ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode);
- * ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode);
- * ir_node *new_Minus (ir_node *op, ir_mode *mode);
- * ir_node *new_Mul (ir_node *op1, ir_node *op2, ir_mode *mode);
- * ir_node *new_Quot (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
- * ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
- * ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
- * ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
- * ir_node *new_Abs (ir_node *op, ir_mode *mode);
- * ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode);
- * ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode);
- * ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode);
- * ir_node *new_Not (ir_node *op, ir_mode *mode);
- * ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode);
- * ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode);
- * ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode);
- * ir_node *new_Rot (ir_node *op, ir_node *k, ir_mode *mode);
- * ir_node *new_Cmp (ir_node *op1, ir_node *op2);
- * ir_node *new_Conv (ir_node *op, ir_mode *mode);
- * ir_node *new_Cast (ir_node *op, ir_type *to_tp);
- * ir_node *new_Carry (ir_node *op1, ir_node *op2, ir_mode *mode);
- * ir_node *new_Borrow (ir_node *op1, ir_node *op2, ir_mode *mode);
- * ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode);
- * ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val);
- * ir_node *new_Alloc (ir_node *store, ir_node *size, ir_type *alloc_type,
- * where_alloc where);
- * ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size,
- * ir_type *free_type, where_alloc where);
- * ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj);
- * ir_node *new_NoMem (void);
- * ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
- * ir_node *new_Psi (int arity, ir_node *conds[], ir_node *vals[], ir_mode *mode);
- * ir_node *new_CopyB (ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
- * ir_node *new_InstOf (ir_node *store, ir_node obj, ir_type *ent);
- * ir_node *new_Raise (ir_node *store, ir_node *obj);
- * ir_node *new_Bound (ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
- * ir_node *new_Pin (ir_node *node);
- *
- * void add_immBlock_pred (ir_node *block, ir_node *jmp);
- * void mature_immBlock (ir_node *block);
- * void set_cur_block (ir_node *target);
- * ir_node *get_value (int pos, ir_mode *mode);
- * void set_value (int pos, ir_node *value);
- * ir_node *get_store (void);
- * void set_store (ir_node *store);
- * keep_alive (ir_node ka)
- *
- * IR_NODES AND CONSTRUCTORS FOR IR_NODES
- * =======================================
- *
- * All ir_nodes are defined by a common data structure. They are distinguished
- * by their opcode and differ in the number of their attributes.
- *
- * The constructor for the block node sets current_block to itself.
- * Const nodes are always added to the start block.
- * All other constructors add the created node to the current_block.
- * swich_block(block) allows to set the current block to block.
- *
- * Watch for my inconsistent use of input and predecessor (dataflow view)
- * and `the node points to' (implementation view).
- *
- * The following description of the nodes lists four properties them if these
- * are of interest:
- * - the parameters to the constructor
- * - the inputs of the Firm node
- * - the outputs of the Firm node
- * - attributes to the node
- *
- * ------------
- *
- * ir_node *new_immBlock (void)
- * ----------------------------
- *
- * Creates a new block. Sets current_block to itself. When a new block is
- * created it cannot be known how many predecessors this block will have in the
- * control flow graph. Therefore the list of inputs can not be fixed at
- * creation. Predecessors can be added with add_immBlock_pred (block, control flow
- * operation). With every added predecessor the number of inputs to Phi nodes
- * also changes.
- *
- * The block can be completed by mature_immBlock(block) if all predecessors are
- * known. If several blocks are built at once, mature_immBlock can only be called
- * after set_value has been called for all values that are life at the end
- * of the block. This is necessary so that Phi nodes created mature_immBlock
- * get the right predecessors in case of cyclic dependencies. If all set_values
- * of this block are called after maturing it and before calling get_value
- * in some block that is control flow dependent on this block, the construction
- * is correct.
- *
- * Example for faulty ir construction: (draw the graph on a paper and you'll
- * get it ;-)
- *
- * block_before_loop = new_block();
- * set_value(x);
- * mature_immBlock(block_before_loop);
- * before2header = new_Jmp;
- *
- * loop_header = new_block ();
- * header2body - new_Jmp();
- *
- * loop_body = new_block ();
- * body2header = new_Jmp();
- *
- * add_immBlock_pred(loop_header, before2header);
- * add_immBlock_pred(loop_header, body2header);
- * add_immBlock_pred(loop_body, header2body);
- *
- * mature_immBlock(loop_header);
- * mature_immBlock(loop_body);
- *
- * get_value(loop_body, x); // gets the Phi in loop_header
- * set_value(loop_header, x); // sets the value the above get_value should
- * // have returned!!!
- *
- * Mature_immBlock also fixes the number of inputs to the Phi nodes. Mature_immBlock
- * should be called as early as possible, as afterwards the generation of Phi
- * nodes is more efficient.
- *
- * Inputs:
- * There is an input for each control flow predecessor of the block.
- * The input points to an instruction producing an output of type X.
- * Possible predecessors: Start, Jmp, Cond, Raise or Return or any node
- * possibly causing an exception. (Often the real predecessors are Projs.)
- * Output:
- * Mode BB (R), all nodes belonging to this block should consume this output.
- * As they are strict (except Block and Phi node) it is a necessary condition
- * that the block node executed before any other node in this block executes.
- * Attributes:
- * block.matured Indicates whether the block is mature.
- * block.**graph_arr
- * This attribute contains all local values valid in this
- * block. This is needed to build the Phi nodes and removed
- * if the graph is complete. This field is used by the
- * internal construction algorithm and should not be accessed
- * from outside.
- *
- *
- * ir_node *new_Block (int arity, ir_node **in)
- * --------------------------------------------
- *
- * Creates a new Block with the given list of predecessors. This block
- * is mature. As other constructors calls optimization and vrfy for the
- * block. If one of the predecessors is Unknown (as it has to be filled in
- * later) optimizations are skipped. This is necessary to
- * construct Blocks in loops. Leaving Unknown in the Block after finishing
- * the construction may have strange effects, especially for interprocedural
- * representation and analysis.
- *
- *
- * CONTROL FLOW OPERATIONS
- * -----------------------
- *
- * In each block there must be exactly one of the control flow
- * operations Start, End, Jmp, Cond, Return or Raise. The output of a
- * control flow operation points to the block to be executed next.
- *
- * ir_node *new_Start (void)
- * -------------------------
- *
- * Creates a start node. Not actually needed public. There is only one such
- * node in each procedure which is automatically created by new_ir_graph.
- *
- * Inputs:
- * No inputs except the block it belogns to.
- * Output:
- * A tuple of 4 (5, 6) distinct values. These are labeled by the following
- * projection numbers (pn_Start):
- * * pn_Start_X_initial_exec mode X, points to the first block to be exe * cuted.
- * * pn_Start_M mode M, the global store
- * * pn_Start_P_frame_base mode P, a pointer to the base of the proce * dures stack frame.
- * * pn_Start_P_globals mode P, a pointer to the part of the memory * containing_all_ global things.
- * * pn_Start_T_args mode T, a tuple containing all arguments of * the procedure.
- *
- *
- * ir_node *new_End (void)
- * -----------------------
- *
- * Creates an end node. Not actually needed public. There is only one such
- * node in each procedure which is automatically created by new_ir_graph.
- *
- * Inputs:
- * No inputs except the block it belongs to.
- * Output:
- * No output.
- *
- * ir_node *new_Jmp (void)
- * -----------------------
- *
- * Creates a Jmp node.
- *
- * Inputs:
- * The block the node belongs to
- * Output:
- * Control flow to the next block.
- *
- * ir_node *new_IJmp (ir_node *tgt)
- * -----------------------
- *
- * Creates an IJmp node.
- *
- * Inputs:
- * The node that represents the target jump address
- * Output:
- * Control flow to an unknown target, must be pinned by
- * the End node.
- *
- * ir_node *new_Cond (ir_node *c)
- * ------------------------------
- *
- * Creates a Cond node. There are two versions of this node.
- *
- * The Boolean Cond:
- * Input:
- * A value of mode b.
- * Output:
- * A tuple of two control flows. The first is taken if the input is
- * false, the second if it is true.
- *
- * The Switch Cond:
- * Input:
- * A value of mode I_u. (i)
- * Output:
- * A tuple of n control flows. If the Cond's input is i, control
- * flow will procede along output i. If the input is >= n control
- * flow proceeds along output n.
- *
- * ir_node *new_Return (ir_node *store, int arity, ir_node **in)
- * -------------------------------------------------------------
- *
- * The return node has as inputs the results of the procedure. It
- * passes the control flow to the end_block.
- *
- * Inputs:
- * The memory state.
- * All results.
- * Output
- * Control flow to the end block.
- *
- * ---------
- *
- * ir_node *new_Const (ir_mode *mode, tarval *con)
- * -----------------------------------------------
- *
- * Creates a constant in the constant table and adds a Const node
- * returning this value to the start block.
- *
- * Parameters:
- * *mode The mode of the constant.
- * *con Points to an entry in the constant table.
- * This pointer is added to the attributes of
- * the node (self->attr.con)
- * Inputs:
- * No inputs except the block it belogns to.
- * Output:
- * The constant value.
- * Attribute:
- * attr.con A tarval* pointer to the proper entry in the constant
- * table.
- *
- * ir_node *new_SymConst (union symconst_symbol value, symconst_addr_ent kind)
- * ---------------------------------------------------------------------------
- *
- * There are three kinds of symbolic constants:
- * symconst_type_tag The symbolic constant represents a type tag.
- * symconst_type_size The symbolic constant represents the size of a type.
- * symconst_type_align The symbolic constant represents the alignment of a type.
- * symconst_addr_name Information for the linker, e.g. the name of a global
- * variable.
- * symconst_addr_name The symbolic constant represents the address of an entity.
- *
- * To represent a pointer to an entity that is represented by an entity
- * datastructure don't use
- * new_SymConst((type_or_id*)get_entity_ld_ident(ent), symconst_addr_name);.
- * Use a real const instead:
- * new_SymConst(ent, symconst_addr_ent);
- * This makes the Constant independent of name changes of the entity due to
- * mangling.
- *
- * Parameters
- * kind The kind of the symbolic constant: type_tag, size or link_info.
- * *type_or_id Points to the type the tag stands for or to the type
- * whose size is represented by the constant or to an ident
- * representing the linkage info.
- *
- * Inputs:
- * No inputs except the block it belogns to.
- * Output:
- * An unsigned integer (I_u) or a pointer (P).
- *
- * Attributes:
- * attr.i.num The symconst_addr_ent, i.e. one of
- * -symconst_type_tag
- * -symconst_type_size
- * -symconst_type_align
- * -symconst_addr_name
- *
- * If the attr.i.num is symconst_type_tag, symconst_type_size or symconst_type_align,
- * the node contains an attribute:
- *
- * attr.i.*type, a pointer to a type_class. The mode of the node is mode_Is.
- * if it is linkage_ptr_info it contains
- * attr.i.*ptrinfo, an ident holding information for the linker. The mode
- * of the node is mode_P_mach.
- *
- * ---------------
- *
- * ir_node *new_simpleSel (ir_node *store, ir_node *frame, ir_entity *sel)
- * -----------------------------------------------------------------------
- *
- *
- * Selects an entity from a compound type. This entity can be a field or
- * a method.
- *
- * Parameters:
- * *store The memory in which the object the entity should be selected
- * from is allocated.
- * *frame The pointer to the object.
- * *sel The entity to select.
- *
- * Inputs:
- * The memory containing the object.
- * A pointer to the object.
- * An unsigned integer.
- * Output:
- * A pointer to the selected entity.
- * Attributes:
- * attr.sel Pointer to the entity
- *
- *
- * ir_node *new_Sel (ir_node *store, ir_node *frame, int arity, ir_node **in,
- * --------------------------------------------------------------------------
- * ir_entity *sel)
- * ---------------
- *
- * Selects a field from an array type. The entity has as owner the array, as
- * type the arrays element type. The indices to access an array element are
- * given also.
- *
- * Parameters:
- * *store The memory in which the object the entity should be selected from
- * is allocated.
- * *frame The pointer to the object.
- * *arity number of array indices.
- * *in array with index inputs to the node.
- * *sel The entity to select.
- *
- * Inputs:
- * The memory containing the object.
- * A pointer to the object.
- * As much unsigned integer as there are array expressions.
- * Output:
- * A pointer to the selected entity.
- * Attributes:
- * attr.sel Pointer to the entity
- *
- * The constructors new_Sel and new_simpleSel generate the same ir nodes.
- * simpleSel just sets the arity of the index inputs to zero.
- *
- *
- * ARITHMETIC OPERATIONS
- * ---------------------
- *
- * ir_node *new_Call (ir_node *store, ir_node *callee, int arity, ir_node **in,
- * ----------------------------------------------------------------------------
- * type_method *type)
- * ------------------
- *
- * Creates a procedure call.
- *
- * Parameters
- * *store The actual store.
- * *callee A pointer to the called procedure.
- * arity The number of procedure parameters.
- * **in An array with the pointers to the parameters.
- * The constructor copies this array.
- * *type Type information of the procedure called.
- *
- * Inputs:
- * The store, the callee and the parameters.
- * Output:
- * A tuple containing the eventually changed store and the procedure
- * results.
- * Attributes:
- * attr.call Contains the type information for the procedure.
- *
- *
- * ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode)
- * ------------------------------------------------------------
- *
- * Trivial.
- *
- * ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode)
- * ------------------------------------------------------------
- *
- * Trivial.
- *
- * ir_node *new_Minus (ir_node *op, ir_mode *mode)
- * -----------------------------------------------
- *
- * Unary Minus operations on integer and floating point values.
- *
- * ir_node *new_Mul (ir_node *op1, ir_node *op2, ir_mode *mode)
- * ------------------------------------------------------------
- *
- * Trivial.
- *
- * ir_node *new_Quot (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode)
- * -----------------------------------------------------------------------------
- *
- * Quot performs exact division of floating point numbers. It's mode
- * is Tuple, the mode of the result must match the Proj mode
- * that extracts the result of the arithmetic operations.
- *
- * Inputs:
- * The store needed to model exceptions and the two operands.
- * Output:
- * A tuple containing a memory and a execution for modeling exceptions
- * and the result of the arithmetic operation.
- *
- * ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode)
- * -------------------------------------------------------------------------------
- *
- * Performs Div and Mod on integer values.
- *
- * Output:
- * A tuple containing a memory and a execution for modeling exceptions
- * and the two result of the arithmetic operations.
- *
- * ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode)
- * ----------------------------------------------------------------------------
- *
- * Trivial.
- *
- * ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode)
- * ----------------------------------------------------------------------------
- *
- * Trivial.
- *
- * ir_node *new_Abs (ir_node *op, ir_mode *mode)
- * ---------------------------------------------
- *
- * Trivial.
- *
- * ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode)
- * ------------------------------------------------------------
- *
- * Trivial.
- *
- * ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode)
- * -----------------------------------------------------------
- *
- * Trivial.
- *
- * ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode)
- * ------------------------------------------------------------
- *
- * Trivial.
- *
- * ir_node *new_Not (ir_node *op, ir_mode *mode)
- * ---------------------------------------------
- *
- * This node constructs a constant where all bits are set to one
- * and a Eor of this constant and the operator. This simulates a
- * Not operation.
- *
- * ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode)
- * ---------------------------------------------------------
- *
- * Trivial.
- *
- * ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode)
- * ---------------------------------------------------------
- *
- * Logic shift right, i.e., zero extended.
- *
- *
- * ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode)
- * ----------------------------------------------------------
- *
- * Arithmetic shift right, i.e., sign extended.
- *
- * ir_node *new_Rot (ir_node *op, ir_node *k, ir_mode *mode)
- * ---------------------------------------------------------
- *
- * Rotates the operand to the (right??) by k bits.
- *
- * ir_node *new_Carry (ir_node *op1, ir_node *op2, ir_mode *mode)
- * ------------------------------------------------------------
- *
- * Calculates the Carry value for integer addition. Used only
- * in lowering code.
- *
- * ir_node *new_Borrow (ir_node *op1, ir_node *op2, ir_mode *mode)
- * ------------------------------------------------------------
- *
- * Calculates the Borrow value for integer substraction. Used only
- * in lowering code.
- *
- * ir_node *new_Conv (ir_node *op, ir_mode *mode)
- * ---------------------------------------------
- *
- * Mode conversion. For allowed conversions see UKA Tech Report
- * 1999-14.
- *
- * ir_node *new_Cmp (ir_node *op1, ir_node *op2)
- * ---------------------------------------------
- *
- * Input:
- * The two values to be compared.
- * Output:
- * A 16-tuple containing the results of the 16 different comparisons.
- * The following is a list giving the comparisons and a projection
- * number (pn_Cmp) to use in Proj nodes to extract the proper result.
- * pn_Cmp_False false
- * pn_Cmp_Eq equal
- * pn_Cmp_Lt less
- * pn_Cmp_Le less or equal
- * pn_Cmp_Gt greater
- * pn_Cmp_Ge greater of equal
- * pn_Cmp_Lg less or greater
- * pn_Cmp_Leg less, equal or greater = ordered
- * pn_Cmp_Uo unordered
- * pn_Cmp_Ue unordered or equal
- * pn_Cmp_Ul unordered or less
- * pn_Cmp_Ule unordered, less or equal
- * pn_Cmp_Ug unordered or greater
- * pn_Cmp_Uge unordered, greater or equal
- * pn_Cmp_Ne unordered, less or greater = not equal
- * pn_Cmp_True true
- *
- *
- *
- * ------------
- *
- * In general, Phi nodes are automaitcally inserted. In some cases, if
- * all predecessors of a block are known, an explicit Phi node constructor
- * is needed. E.g., to construct a FIRM graph for a statement as
- * a = (b==c) ? 2 : 5;
- *
- * ir_node *new_Phi (int arity, ir_node **in, ir_mode *mode)
- * ---------------------------------------------------------
- *
- * Creates a Phi node. The in's order has to correspond to the order
- * of in's of current_block. This is not checked by the library!
- * If one of the predecessors is Unknown (as it has to be filled in
- * later) optimizations are skipped. This is necessary to
- * construct Phi nodes in loops. Leaving Unknown in the Phi after finishing
- * the construction may have strange effects, especially for interprocedural
- * representation and analysis.
- *
- * Parameter
- * arity number of predecessors
- * **in array with predecessors
- * *mode The mode of it's inputs and output.
- * Inputs:
- * A Phi node has as many inputs as the block it belongs to.
- * Each input points to a definition of the same value on a
- * different path in the control flow.
- * Output
- * The definition valid in this block.
- *
- * ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode)
- * -----------------------------------------------------------------------------
- *
- * Creates a Mux node. This node implements the following semantic:
- * If the sel node (which must be of mode_b) evaluates to true, its value is
- * ir_true, else ir_false;
- *
- *
- * ir_node *new_Psi (int arity, ir_node *conds[], ir_node *vals[], ir_mode *mode)
- * -----------------------------------------------------------------------------
- *
- * Creates a Psi node. This node implements the following semantic:
- * Enter it here!!!
- *
- *
- * OPERATIONS TO MANAGE MEMORY EXPLICITLY
- * --------------------------------------
- *
- * ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode)
- * ----------------------------------------------------------------
- *
- * The Load operation reads a value from memory.
- *
- * Parameters:
- * *store The current memory.
- * *addr A pointer to the variable to be read in this memory.
- * *mode The mode of the value to be loaded.
- *
- * Inputs:
- * The memory and a pointer to a variable in this memory.
- * Output:
- * A tuple of the memory, a control flow to be taken in case of
- * an exception and the loaded value.
- *
- * ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val)
- * ----------------------------------------------------------------
- *
- * The Store operation writes a value to a variable in memory.
- *
- * Inputs:
- * The memory, a pointer to a variable in this memory and the value
- * to write to this variable.
- * Output:
- * A tuple of the changed memory and a control flow to be taken in
- * case of an exception.
- *
- * ir_node *new_Alloc (ir_node *store, ir_node *size, ir_type *alloc_type,
- * -----------------------------------------------------------------------
- * where_alloc where)
- * ------------------
- *
- * The Alloc node allocates a new variable. It can be specified whether the
- * variable should be allocated to the stack or to the heap.
- *
- * Parameters:
- * *store The memory which shall contain the new variable.
- * ** *size The number of bytes to allocate. Old. **
- * *size We decided that the size easily can be derived from the type.
- * This field is for allocating arrays, i.e., it gives the multiple
- * of the size of alloc_type to allocate memory for.
- * *alloc_type The type of the allocated variable.
- * where Where to allocate the variable, either heap_alloc or stack_alloc.
- *
- * Inputs:
- * A memory and an unsigned integer.
- * Output:
- * A tuple of the changed memory, a control flow to be taken in
- * case of an exception and the pointer to the new variable.
- * Attributes:
- * a.where Indicates where the variable is allocated.
- * a.*type A pointer to the class the allocated data object
- * belongs to.
- *
- * ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size, ir_type *free_type,
- * -----------------------------------------------------------------------------------
- * where_alloc where)
- * ------------------
- *
- * The Free node frees memory of the given variable.
- *
- * Parameters:
- * *store The memory which shall contain the new variable.
- * *ptr The pointer to the object to free.
- * *size The number of objects of type free_type to free in a sequence.
- * *free_type The type of the freed variable.
- * where Where the variable was allocated, either heap_alloc or stack_alloc.
- *
- * Inputs:
- * A memory, a pointer and an unsigned integer.
- * Output:
- * The changed memory.
- * Attributes:
- * f.*type A pointer to the type information of the freed data object.
- *
- * Not Implemented!
- *
- * ir_node *new_Sync (int arity, ir_node **in)
- * -------------------------------------------
- *
- * The Sync operation unifies several partial memory blocks. These blocks
- * have to be pairwise disjunct or the values in common locations have to
- * be identical. This operation allows to specify all operations that eventually
- * need several partial memory blocks as input with a single entrance by
- * unifying the memories with a preceding Sync operation.
- *
- * Parameters
- * arity The number of memories to synchronize.
- * **in An array of pointers to nodes that produce an output of
- * type memory.
- * Inputs
- * Several memories.
- * Output
- * The unified memory.
- *
- *
- * SPECIAL OPERATIONS
- * ------------------
- *
- * ir_node *new_Bad (void)
- * -----------------------
- *
- * Returns the unique Bad node current_ir_graph->bad.
- * This node is used to express results of dead code elimination.
- *
- * ir_node *new_NoMem (void)
- * -----------------------------------------------------------------------------------
- *
- * Returns the unique NoMem node current_ir_graph->no_mem.
- * This node is used as input for operations that need a Memory, but do not
- * change it like Div by const != 0, analyzed calls etc.
- *
- * ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj)
- * ----------------------------------------------------------
- *
- * Selects one entry of a tuple. This is a hidden edge with attributes.
- *
- * Parameters
- * *arg A node producing a tuple.
- * *mode The mode of the value to project.
- * proj The position of the value in the tuple.
- * Input:
- * The tuple.
- * Output:
- * The value.
- *
- * ir_node *new_Tuple (int arity, ir_node **in)
- * --------------------------------------------
- *
- * Builds a Tuple from single values. This is needed to implement
- * optimizations that remove a node that produced a tuple. The node can be
- * replaced by the Tuple operation so that the following Proj nodes have not to
- * be changed. (They are hard to find due to the implementation with pointers
- * in only one direction.) The Tuple node is smaller than any other
- * node, so that a node can be changed into a Tuple by just changing it's
- * opcode and giving it a new in array.
- *
- * Parameters
- * arity The number of tuple elements.
- * **in An array containing pointers to the nodes producing the
- * tuple elements.
- *
- * ir_node *new_Id (ir_node *val, ir_mode *mode)
- * ---------------------------------------------
- *
- * The single output of the Id operation is it's input. Also needed
- * for optimizations.
- *
- *
- * HIGH LEVEL OPERATIONS
- * ---------------------
- *
- * ir_node *new_CopyB (ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type)
- * -----------------------------------------------------------------------------------
- *
- * Describes a high level block copy of a compound type from address src to
- * address dst. Must be lowered to a Call to a runtime memory copy function.
- *
- *
- * HIGH LEVEL OPERATIONS: Exception Support
- * ----------------------------------------
- * See TechReport 1999-14, chapter Exceptions.
- *
- * ir_node *new_InstOf(ir_node *store, ir_node *ptr, ir_type *type);
- * -----------------------------------------------------------------------------------
- *
- * Describes a high level type check. Must be lowered to a Call to a runtime check
- * function.
- *
- * ir_node *new_Raise (ir_node *store, ir_node *obj)
- * -------------------------------------------------
- *
- * Raises an exception. Unconditional change of control flow. Writes
- * an explicit Except variable to memory to pass it to the exception
- * handler. Must be lowered to a Call to a runtime check
- * function.
- *
- * Inputs:
- * The memory state.
- * A pointer to the Except variable.
- * Output:
- * A tuple of control flow and the changed memory state. The control flow
- * points to the exception handler if it is definied in this procedure,
- * else it points to the end_block.
- *
- * ir_node *new_Bound (ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
- * -----------------------------------------------------------------------------------
- *
- * Describes a high level bounds check. Must be lowered to a Call to a runtime check
- * function.
- *
- * ir_node *new_Pin (ir_node *node);
- * -----------------------------------------------------------------------------------
- *
- * Pin the value of the node node in the current block No users of the Pin node can
- * float above the Block of the Pin. The node cannot float behind this block. Often
- * used to Pin the NoMem node.
- *
- *
- * COPING WITH DATA OBJECTS
- * ========================
- *
- * Two kinds of data objects have to be distinguished for generating
- * FIRM. First there are local variables other than arrays that are
- * known to be alias free. Second there are all other data objects.
- * For the first a common SSA representation is built, the second
- * are modeled by saving them to memory. The memory is treated as
- * a single local variable, the alias problem is hidden in the
- * content of this variable.
- *
- * All values known in a Block are listed in the block's attribute,
- * block.**graph_arr which is used to automatically insert Phi nodes.
- * The following two functions can be used to add a newly computed value
- * to the array, or to get the producer of a value, i.e., the current
- * live value.
- *
- * inline void set_value (int pos, ir_node *value)
- * -----------------------------------------------
- *
- * Has to be called for every assignment to a local variable. It
- * adds the value to the array of used values at position pos. Pos
- * has to be a unique identifier for an entry in the procedure's
- * definition table. It can be used to access the value again.
- * Requires current_block to be set correctly.
- *
- * ir_node *get_value (int pos, ir_mode *mode)
- * -------------------------------------------
- *
- * Returns the node defining the value referred to by pos. If the
- * value is not defined in this block a Phi node is generated and
- * all definitions reaching this Phi node are collected. It can
- * happen that the algorithm allocates an unnecessary Phi node,
- * e.g. if there is only one definition of this value, but this
- * definition reaches the currend block on several different
- * paths. This Phi node will be eliminated if optimizations are
- * turned on right after it's creation.
- * Requires current_block to be set correctly.
- *
- * There are two special routines for the global store:
- *
- * void set_store (ir_node *store)
- * -------------------------------
- *
- * Adds the store to the array of known values at a reserved
- * position.
- * Requires current_block to be set correctly.
- *
- * ir_node *get_store (void)
- * -------------------------
- *
- * Returns the node defining the actual store.
- * Requires current_block to be set correctly.
- *
- *
- * inline void keep_alive (ir_node *ka)
- * ------------------------------------
- *
- * Keep this node alive because it is (might be) not in the control
- * flow from Start to End. Adds the node to the list in the end
- * node.
- *
- */
-#ifndef FIRM_IR_IRCONS_H
-#define FIRM_IR_IRCONS_H
-
-#include "firm_common.h"
-#include "irnode.h"
-#include "irgraph.h"
-#include "dbginfo.h"
-
-/*-------------------------------------------------------------------------*/
-/* The raw interface */
-/*-------------------------------------------------------------------------*/
-
-/** Constructor for a Block node.
- *
- * Constructs a mature block with the given predecessors. Use Unknown
- * nodes as predecessors to construct a block if the number of
- * predecessors is known, but not the predecessors themselves. This
- * constructor does not set current_block. It not be used with
- * automatic Phi node construction.
- *
- * @param *db A Pointer for debug information.
- * @param irg The ir graph the block belongs to.
- * @param arity The number of control predecessors.
- * @param in[] An array of control predecessors. The length of
- * the array must be 'arity'. The constructor copies this array.
- */
-ir_node *new_rd_Block (dbg_info *db, ir_graph *irg, int arity, ir_node *in[]);
-
-/** Constructor for a Start node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- */
-ir_node *new_rd_Start (dbg_info *db, ir_graph *irg, ir_node *block);
-
-/** Constructor for a End node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- */
-ir_node *new_rd_End (dbg_info *db, ir_graph *irg, ir_node *block);
-
-/** Constructor for a Jmp node.
- *
- * Jmp represents control flow to a single control successor.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- */
-ir_node *new_rd_Jmp (dbg_info *db, ir_graph *irg, ir_node *block);
-
-/** Constructor for an IJmp node.
- *
- * IJmp represents control flow to a single control successor not
- * statically known i.e. an indirect Jmp.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *tgt The ir node representing the target address.
- */
-ir_node *new_rd_IJmp (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *tgt);
-
-/** Constructor for a Break node.
- *
- * Break represents control flow to a single control successor just as Jmp.
- * The blocks separated by a break may not be concatenated by an optimization.
- * It is used for the interprocedural representation where blocks are parted
- * behind Call nodes to represent the control flow to called procedures.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belong to.
- * @param *block The block the node belong to.
- */
-ir_node *new_rd_Break (dbg_info *db, ir_graph *irg, ir_node *block);
-
-/** Constructor for a Cond node.
- *
- * If c is mode_b represents a conditional branch (if/else). If c is
- * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
- * node, default Proj is 0.)
- *
- * This is not consistent: Input to Cond is Is, Proj has as proj number
- * longs.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *c The conditions parameter. Can be of mode b or I_u.
- */
-ir_node *new_rd_Cond (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *c);
-
-/** Constructor for a Return node.
- *
- * Returns the memory an zero or more return values. Only node that
- * can end regular control flow.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *store The state of memory.
- * @param arity Number of return values.
- * @param *in Array of length arity with return values. The constructor copies this array.
- */
-ir_node *new_rd_Return (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *store, int arity, ir_node *in[]);
-
-/** Constructor for a Const_type node.
- *
- * The constant represents a target value. This constructor sets high
- * level type information for the constant value.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *mode The mode of the operands and results.
- * @param *con Points to an entry in the constant table.
- * @param *tp The type of the constant.
- */
-ir_node *new_rd_Const_type (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_mode *mode, tarval *con, ir_type *tp);
-
-/** Constructor for a Const node.
- *
- * Constructor for a Const node. The constant represents a target
- * value. Sets the type information to type_unknown. (No more
- * supported: If tv is entity derives a somehow useful type.)
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *mode The mode of the operands and results.
- * @param *con Points to an entry in the constant table.
- */
-ir_node *new_rd_Const (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_mode *mode, tarval *con);
-
-/** Constructor for a SymConst_type node.
- *
- * This is the constructor for a symbolic constant.
- * There are four kinds of symbolic constants:
- * - type_tag The symbolic constant represents a type tag. The type the
- * tag stands for is given explicitly.
- * - type_size The symbolic constant represents the size of a type. The
- * type of which the constant represents the size is given
- * explicitly.
- * - type_align The symbolic constant represents the alignment of a type. The
- * type of which the constant represents the size is given
- * explicitly.
- * - addr_name The symbolic constant represents the address of an entity
- * (variable or method). The variable is indicated by a name
- * that is valid for linking.
- * - addr_ent The symbolic constant represents the address of an entity
- * (variable or method). The variable is given explicitly by
- * a firm entity.
- *
- * Inputs to the node:
- * No inputs except the block it belongs to.
- * Outputs of the node.
- * An unsigned integer (I_u) or a pointer (P).
- *
- * Mention union in declaration so that the firmjni generator recognizes that
- * it can not cast the argument to an int.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param symkind The kind of the symbolic constant: type_tag, size, addr_name or addr_ent.
- * @param value A type, entity or a ident depending on the SymConst kind.
- * @param tp The source type of the constant.
- */
-ir_node *new_rd_SymConst_type (dbg_info *db, ir_graph *irg, ir_node *block, union symconst_symbol value,
- symconst_kind symkind, ir_type *tp);
-
-/** Constructor for a SymConst node.
- *
- * Same as new_rd_SymConst_type, except that it sets the type to type_unknown. */
-ir_node *new_rd_SymConst (dbg_info *db, ir_graph *irg, ir_node *block,
- union symconst_symbol value, symconst_kind symkind);
-
-/** Constructor for a SymConst addr_ent node.
- *
- * Same as new_rd_SymConst_type, except that the constructor is tailored for
- * symconst_addr_ent.
- * Adds the SymConst to the start block of irg. */
-ir_node *new_rd_SymConst_addr_ent (dbg_info *db, ir_graph *irg, ir_entity *symbol, ir_type *tp);
-
-/** Constructor for a SymConst ofs_ent node.
- *
- * Same as new_rd_SymConst_type, except that the constructor is tailored for
- * symconst_ofs_ent.
- * Adds the SymConst to the start block of irg. */
-ir_node *new_rd_SymConst_ofs_ent (dbg_info *db, ir_graph *irg, ir_entity *symbol, ir_type *tp);
-
-/** Constructor for a SymConst addr_name node.
- *
- * Same as new_rd_SymConst_type, except that the constructor is tailored for
- * symconst_addr_ent.
- * Adds the SymConst to the start block of irg. */
-ir_node *new_rd_SymConst_addr_name (dbg_info *db, ir_graph *irg, ident *symbol, ir_type *tp);
-
-/** Constructor for a SymConst type_tag node.
- *
- * Same as new_rd_SymConst_type, except that the constructor is tailored for
- * symconst_addr_ent.
- * Adds the SymConst to the start block of irg. */
-ir_node *new_rd_SymConst_type_tag (dbg_info *db, ir_graph *irg, ir_type *symbol, ir_type *tp);
-
-/** Constructor for a SymConst size node.
- *
- * Same as new_rd_SymConst_type, except that the constructor is tailored for
- * symconst_type_size.
- * Adds the SymConst to the start block of irg. */
-ir_node *new_rd_SymConst_size (dbg_info *db, ir_graph *irg, ir_type *symbol, ir_type *tp);
-
-/** Constructor for a SymConst size node.
- *
- * Same as new_rd_SymConst_type, except that the constructor is tailored for
- * symconst_type_align.
- * Adds the SymConst to the start block of irg. */
-ir_node *new_rd_SymConst_align (dbg_info *db, ir_graph *irg, ir_type *symbol, ir_type *tp);
-
-/** Constructor for a simpleSel node.
- *
- * This is a shortcut for the new_rd_Sel() constructor. To be used for
- * Sel nodes that do not select from an array, i.e., have no index
- * inputs. It adds the two parameters 0, NULL.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *store The memory in which the object the entity should be
- * selected from is allocated.
- * @param *objptr The object from that the Sel operation selects a
- * single attribute out.
- * @param *ent The entity to select.
- */
-ir_node *new_rd_simpleSel (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *store, ir_node *objptr, ir_entity *ent);
-
-/** Constructor for a Sel node.
- *
- * The select node selects an entity (field or method) from an entity
- * with a compound type. It explicitly specifies the entity selected.
- * Dynamically the node may select entities that overwrite the given
- * entity. If the selected entity is an array element entity the Sel
- * node takes the required array indices as inputs.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *store The memory in which the object the entity should be selected
- * from is allocated.
- * @param *objptr A pointer to a compound entity the Sel operation selects a
- * single attribute from.
- * @param *n_index The number of array indices needed to select an array element entity.
- * @param *index[] If the compound entity is an array the indices of the selected
- * element entity. The constructor copies this array.
- * @param *ent The entity to select.
- */
-ir_node *new_rd_Sel (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
- ir_node *objptr, int n_index, ir_node *index[], ir_entity *ent);
-
-/** Constructor for a Call node.
- *
- * Represents all kinds of method and function calls.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *store The current memory state.
- * @param *callee A pointer to the called procedure.
- * @param arity The number of procedure parameters.
- * @param *in[] An array with the procedure parameters. The constructor copies this array.
- * @param *tp Type information of the procedure called.
- */
-ir_node *new_rd_Call (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
- ir_node *callee, int arity, ir_node *in[], ir_type *tp);
-
-/** Constructor for a Add node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_rd_Add (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Sub node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_rd_Sub (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Minus node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op The operand .
- * @param *mode The mode of the operand and the result.
- */
-ir_node *new_rd_Minus (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *op, ir_mode *mode);
-
-/** Constructor for a Mul node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_rd_Mul (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Quot node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *memop The store needed to model exceptions
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the result.
- */
-ir_node *new_rd_Quot (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a DivMod node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *memop The store needed to model exceptions
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the results.
- */
-ir_node *new_rd_DivMod (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Div node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *memop The store needed to model exceptions
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the result.
- */
-ir_node *new_rd_Div (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Mod node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *memop The store needed to model exceptions
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the result.
- */
-ir_node *new_rd_Mod (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Abs node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op The operand
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_rd_Abs (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *op, ir_mode *mode);
-
-/** Constructor for a And node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_rd_And (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Or node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_rd_Or (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Eor node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the results.
- */
-ir_node *new_rd_Eor (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Not node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op The operand.
- * @param *mode The mode of the operand and the result.
- */
-ir_node *new_rd_Not (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *op, ir_mode *mode);
-
-/** Constructor for a Cmp node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- */
-ir_node *new_rd_Cmp (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *op1, ir_node *op2);
-
-/** Constructor for a Shl node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op The operand.
- * @param *k The number of bits to shift the operand .
- * @param *mode The mode of the operand and the result.
- */
-ir_node *new_rd_Shl (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *op, ir_node *k, ir_mode *mode);
-
-/** Constructor for a Shr node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op The operand.
- * @param *k The number of bits to shift the operand .
- * @param *mode The mode of the operand and the result.
- */
-ir_node *new_rd_Shr (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *op, ir_node *k, ir_mode *mode);
-
-/** Constructor for a Shrs node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op The operand.
- * @param *k The number of bits to shift the operand.
- * @param *mode The mode of the operand and the result.
- */
-ir_node *new_rd_Shrs (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *op, ir_node *k, ir_mode *mode);
-
-/** Constructor for a Rot node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op The operand.
- * @param *k The number of bits to rotate the operand.
- * @param *mode The mode of the operand.
- */
-ir_node *new_rd_Rot (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *op, ir_node *k, ir_mode *mode);
-
-
-/** Constructor for a Conv node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op The operand.
- * @param *mode The mode of this the operand muss be converted .
- */
-ir_node *new_rd_Conv (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *op, ir_mode *mode);
-
-/** Constructor for a Cast node.
- *
- * High level type cast.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op The operand.
- * @param *to_tp The type of this the operand muss be casted .
- */
-ir_node *new_rd_Cast (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *op, ir_type *to_tp);
-
-/** Constructor for a Carry node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_rd_Carry (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Borrow node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_rd_Borrow (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Phi node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param arity The number of predecessors
- * @param *in[] Array with predecessors. The constructor copies this array.
- * @param *mode The mode of it's inputs and output.
- */
-ir_node *new_rd_Phi (dbg_info *db, ir_graph *irg, ir_node *block, int arity,
- ir_node *in[], ir_mode *mode);
-
-/** Constructor for a Load node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *store The current memory
- * @param *adr A pointer to the variable to be read in this memory.
- * @param *mode The mode of the value to be loaded.
- */
-ir_node *new_rd_Load (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *store, ir_node *adr, ir_mode *mode);
-
-/** Constructor for a Store node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *store The current memory
- * @param *adr A pointer to the variable to be read in this memory.
- * @param *val The value to write to this variable.
- */
-ir_node *new_rd_Store (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *store, ir_node *adr, ir_node *val);
-
-/** Constructor for a Alloc node.
- *
- * The Alloc node extends the memory by space for an entity of type alloc_type.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *store The memory which shall contain the new variable.
- * @param *size The number of bytes to allocate.
- * @param *alloc_type The type of the allocated variable.
- * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
- */
-ir_node *new_rd_Alloc (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
- ir_node *size, ir_type *alloc_type, where_alloc where);
-
-/** Constructor for a Free node.
- *
- * Frees the memory occupied by the entity pointed to by the pointer
- * arg. Type indicates the type of the entity the argument points to.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *store The memory which shall contain the new variable.
- * @param *ptr The pointer to the object to free.
- * @param *size The number of objects of type free_type to free in a sequence.
- * @param *free_type The type of the freed variable.
- * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
- */
-ir_node *new_rd_Free (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
- ir_node *ptr, ir_node *size, ir_type *free_type, where_alloc where);
-
-/** Constructor for a Sync node.
- *
- * Merges several memory values. The node assumes that a variable
- * either occurs only in one of the memories, or it contains the same
- * value in all memories where it occurs.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param arity The number of memories to synchronize.
- * @param *in[] An array of pointers to nodes that produce an output of type
- * memory. The constructor copies this array.
- */
-ir_node *new_rd_Sync (dbg_info *db, ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
-
-/** Constructor for a Proj node.
- *
- * Projects a single value out of a tuple. The parameter proj gives the
- * position of the value within the tuple.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param arg A node producing a tuple. The node must have mode_T.
- * @param *mode The mode of the value to project.
- * @param proj The position of the value in the tuple.
- */
-ir_node *new_rd_Proj (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
- ir_mode *mode, long proj);
-
-/** Constructor for a defaultProj node.
- *
- * Represents the default control flow of a Switch-Cond node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param arg A node producing a tuple.
- * @param max_proj The end position of the value in the tuple.
- */
-ir_node *new_rd_defaultProj (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
- long max_proj);
-
-/** Constructor for a Tuple node.
- *
- * This is an auxiliary node to replace a node that returns a tuple
- * without changing the corresponding Proj nodes.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param arity The number of tuple elements.
- * @param *in[] An array containing pointers to the nodes producing the tuple
- * elements. The constructor copies this array.
- */
-ir_node *new_rd_Tuple (dbg_info *db, ir_graph *irg, ir_node *block,
- int arity, ir_node *in[]);
-
-/** Constructor for a Id node.
- *
- * This is an auxiliary node to replace a node that returns a single
- * value.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *val The value
- * @param *mode The mode of *val.
- */
-ir_node *new_rd_Id (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *val, ir_mode *mode);
-
-/** Constructor for a Bad node.
- *
- * Returns the unique Bad node of the graph. The same as
- * get_irg_bad().
- *
- * @param *irg The ir graph the node belongs to.
- */
-ir_node *new_rd_Bad (ir_graph *irg);
-
-/** Constructor for a Confirm node.
- *
- * Specifies constraints for a value. To support dataflow analyses.
- *
- * Example: If the value never exceeds '100' this is expressed by placing a
- * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
- *
- * @param *irg The ir graph the node belong to.
- * @param *block The ir block the node belong to.
- * @param *db A pointer for debug information.
- * @param *val The value we express a constraint for
- * @param *bound The value to compare against. Must be a firm node, typically a constant.
- * @param cmp The compare operation.
- */
-ir_node *new_rd_Confirm (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *val, ir_node *bound, pn_Cmp cmp);
-
-/** Constructor for an Unknown node.
- *
- * Represents an arbitrary value. Places the node in the start block.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *m The mode of the unknown value.
- */
-ir_node *new_rd_Unknown(ir_graph *irg, ir_mode *m);
-
-/** Constructor for a CallBegin node.
- *
- * CallBegin represents control flow depending of the pointer value
- * representing the called method to the called methods. The
- * constructor copies the method pointer input from the passed Call
- * node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belong to.
- * @param *block The block the node belong to.
- * @param *callee The call node visible in the intra procedural view.
- */
-ir_node *new_rd_CallBegin(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *callee);
-
-/** Constructor for a EndReg node.
- *
- * Used to represent regular procedure end in interprocedual view.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belong to.
- * @param *block The block the node belong to.
- */
-ir_node *new_rd_EndReg (dbg_info *db, ir_graph *irg, ir_node *block);
-
-/** Constructor for a EndExcept node.
- *
- * Used to represent exceptional procedure end in interprocedural view.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belong to.
- * @param *block The block the node belong to.
- */
-ir_node *new_rd_EndExcept(dbg_info *db, ir_graph *irg, ir_node *block);
-
-/** Constructor for a Filter node.
- *
- * Adds the node to the block in current_ir_block. Filter is a node
- * with two views used to construct the interprocedural view. In
- * intraprocedural view its semantics are identical to the Proj node.
- * In interprocedural view the Filter performs the Phi operation on
- * method parameters or results. Other than a Phi a Filter node may
- * not be removed if it has only a single input.
- *
- * The constructor builds the Filter in intraprocedural view.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belong to.
- * @param *block The block the node belong to.
- * @param *arg The tuple value to project from.
- * @param *mode The mode of the projected value.
- * @param proj The position in the tuple to project from.
- */
-ir_node *new_rd_Filter (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
- ir_mode *mode, long proj);
-
-/** Constructor for a NoMem node.
- *
- * Returns the unique NoMem node of the graph. The same as
- * get_irg_no_mem().
- *
- * @param *irg The ir graph the node belongs to.
- */
-ir_node *new_rd_NoMem (ir_graph *irg);
-
-/** Constructor for a Mux node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belong to.
- * @param *block The block the node belong to.
- * @param *sel The ir_node that calculates the boolean select.
- * @param *ir_true The ir_node that calculates the true result.
- * @param *ir_false The ir_node that calculates the false result.
- * @param *mode The mode of the node (and it_true and ir_false).
- */
-ir_node *new_rd_Mux (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
-
-/** Constructor for a Psi node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belong to.
- * @param *block The block the node belong to.
- * @param *arity The arity of the conditions
- * @param *conds The array of mode_b conditions, length must be equal arity
- * @param *vals The array of mode values, length must be equal arity + 1
- * @param *mode The mode of the node (must be the mode of all vals).
- */
-ir_node *new_rd_Psi (dbg_info *db, ir_graph *irg, ir_node *block,
- int arity, ir_node *conds[], ir_node *vals[], ir_mode *mode);
-
-/** Constructor for a CopyB node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belong to.
- * @param *block The block the node belong to.
- * @param *store The current memory
- * @param *dst The ir_node that represents the destination address.
- * @param *src The ir_node that represents the source address.
- * @param *data_type The type of the copied data
- */
-ir_node *new_rd_CopyB(dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
-
-/** Constructor for a InstOf node.
- *
- * A High-Level Type check.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *store The memory in which the object the entity should be selected
- * from is allocated.
- * @param *objptr A pointer to a object of a class type.
- * @param *type The type of which objptr must be.
- */
-ir_node *new_rd_InstOf (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
- ir_node *objptr, ir_type *type);
-
-/** Constructor for a Raise node.
- *
- * A High-Level Exception throw.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *store The current memory.
- * @param *obj A pointer to the Except variable.
- */
-ir_node *new_rd_Raise (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *store, ir_node *obj);
-
-/** Constructor for a Bound node.
- *
- * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belong to.
- * @param *block The block the node belong to.
- * @param *store The current memory.
- * @param *idx The ir_node that represents an index.
- * @param *lower The ir_node that represents the lower bound for the index.
- * @param *upper The ir_node that represents the upper bound for the index.
- */
-ir_node *new_rd_Bound(dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
-
-/** Constructor for a Pin node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belong to.
- * @param *block The block the node belong to.
- * @param *node The node which value should be pinned.
- */
-ir_node *new_rd_Pin(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *node);
-
-/** Constructor for an ASM pseudo node.
- *
- * @param *db A pointer for debug information.
- * @param *irg The ir graph the node belong to.
- * @param *block The block the node belong to.
- * @param arity The number of data inputs to the node.
- * @param *in The array of length arity of data inputs.
- * @param *inputs The array of length arity of input constraints.
- * @param n_outs The number of data outputs to the node.
- * @param *outputs The array of length n_outs of output constraints.
- * @param n_clobber The number of clobbered registers.
- * @param *clobber The array of length n_clobber of clobbered registers.
- * @param *asm_text The assembler text.
- */
-ir_node *new_rd_ASM(dbg_info *db, ir_graph *irg, ir_node *block,
- int arity, ir_node *in[], ir_asm_constraint *inputs,
- int n_outs, ir_asm_constraint *outputs,
- int n_clobber, ident *clobber[], ident *asm_text);
-
-/*-------------------------------------------------------------------------*/
-/* The raw interface without debug support */
-/*-------------------------------------------------------------------------*/
-
-/** Constructor for a Block node.
- *
- * Constructs a mature block with the given predecessors. Use Unknown
- * nodes as predecessors to construct a block if the number of
- * predecessors is known, but not the predecessors themselves. This
- * constructor does not set current_block. It not be used with
- * automatic Phi node construction.
- *
- *
- * @param irg The ir graph the block belongs to.
- * @param arity The number of control predecessors.
- * @param in[] An array of control predecessors. The length of
- * the array must be 'arity'. The constructor copies this array.
- */
-ir_node *new_r_Block (ir_graph *irg, int arity, ir_node *in[]);
-
-/** Constructor for a Start node.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- */
-ir_node *new_r_Start (ir_graph *irg, ir_node *block);
-
-/** Constructor for a End node.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- */
-ir_node *new_r_End (ir_graph *irg, ir_node *block);
-
-/** Constructor for a Jmp node.
- *
- * Jmp represents control flow to a single control successor.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- */
-ir_node *new_r_Jmp (ir_graph *irg, ir_node *block);
-
-/** Constructor for an IJmp node.
- *
- * IJmp represents control flow to a single control successor not
- * statically known i.e. an indirect Jmp.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *tgt The ir node representing the target address.
- */
-ir_node *new_r_IJmp (ir_graph *irg, ir_node *block, ir_node *tgt);
-
-/** Constructor for a Cond node.
- *
- * If c is mode_b represents a conditional branch (if/else). If c is
- * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
- * node, default Proj is 0.)
- *
- * This is not consistent: Input to Cond is Is, Proj has as proj number
- * longs.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *c The conditions parameter.Can be of mode b or I_u.
- */
-ir_node *new_r_Cond (ir_graph *irg, ir_node *block, ir_node *c);
-
-/** Constructor for a Return node.
- *
- * Returns the memory an zero or more return values. Only node that
- * can end regular control flow.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *store The state of memory.
- * @param arity Number of array indices.
- * @param *in[] Array with index inputs to the node. The constructor copies this array.
- */
-ir_node *new_r_Return (ir_graph *irg, ir_node *block,
- ir_node *store, int arity, ir_node *in[]);
-
-/** Constructor for a Const node.
- *
- * Constructor for a Const node. The constant represents a target
- * value. Sets the type information to type_unknown. (No more
- * supported: If tv is entity derives a somehow useful type.)
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *mode The mode of the operands and the results.
- * @param *con Points to an entry in the constant table.
- */
-ir_node *new_r_Const (ir_graph *irg, ir_node *block,
- ir_mode *mode, tarval *con);
-
-/** Constructor for a Const node.
- *
- * Constructor for a Const node. The constant represents a target
- * value. Sets the type information to type_unknown. (No more
- * supported: If tv is entity derives a somehow useful type.)
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *mode The mode of the operands and the results.
- * @param value A value from which the tarval is made.
- */
-ir_node *new_r_Const_long(ir_graph *irg, ir_node *block,
- ir_mode *mode, long value);
-
-/** Constructor for a Const_type node.
- *
- * The constant represents a target value. This constructor sets high
- * level type information for the constant value.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *mode The mode of the operands and results.
- * @param *con Points to an entry in the constant table.
- * @param *tp The type of the constant.
- */
-ir_node *new_r_Const_type(ir_graph *irg, ir_node *block,
- ir_mode *mode, tarval *con, ir_type *tp);
-
-/** Constructor for a SymConst node.
- *
- * This is the constructor for a symbolic constant.
- * There are four kinds of symbolic constants:
- * - type_tag The symbolic constant represents a type tag. The type the
- * tag stands for is given explicitly.
- * - size The symbolic constant represents the size of a type. The
- * type of which the constant represents the size is given
- * explicitly.
- * - addr_name The symbolic constant represents the address of an entity
- * (variable or method). The variable is indicated by a name
- * that is valid for linking.
- * - addr_ent The symbolic constant represents the address of an entity
- * (variable or method). The variable is given explicitly by
- * a firm entity.
- *
- * Inputs to the node:
- * No inputs except the block it belongs to.
- * Outputs of the node.
- * An unsigned integer (I_u) or a pointer (P).
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param value A type, entity or a ident depending on the SymConst kind.
- * @param symkind The kind of the symbolic constant: type_tag, size or link_info.
- */
-ir_node *new_r_SymConst (ir_graph *irg, ir_node *block,
- union symconst_symbol value, symconst_kind symkind);
-
-/** Constructor for a simpleSel node.
- *
- * This is a shortcut for the new_d_Sel() constructor. To be used for
- * Sel nodes that do not select from an array, i.e., have no index
- * inputs. It adds the two parameters 0, NULL.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *store The memory in which the object the entity should be selected
- * from is allocated.
- * @param *objptr The object from that the Sel operation selects a
- * single attribute out.
- * @param *ent The entity to select.
- */
-ir_node *new_r_simpleSel(ir_graph *irg, ir_node *block, ir_node *store,
- ir_node *objptr, ir_entity *ent);
-
-/** Constructor for a Sel node.
- *
- * The select node selects an entity (field or method) from an entity
- * with a compound type. It explicitly specifies the entity selected.
- * Dynamically the node may select entities that overwrite the given
- * entity. If the selected entity is an array element entity the Sel
- * node takes the required array indices as inputs.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *store The memory in which the object the entity should be selected
- * from is allocated.
- * @param *objptr A pointer to a compound entity the Sel operation selects a
- * single attribute from.
- * @param *n_index The number of array indices needed to select an array element entity.
- * @param *index[] If the compound entity is an array the indices of the selected
- * element entity. The constructor copies this array.
- * @param *ent The entity to select.
- */
-ir_node *new_r_Sel (ir_graph *irg, ir_node *block, ir_node *store,
- ir_node *objptr, int n_index, ir_node *index[],
- ir_entity *ent);
-
-/** Constructor for a Call node.
- *
- * Represents all kinds of method and function calls.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *store The actual store.
- * @param *callee A pointer to the called procedure.
- * @param arity The number of procedure parameters.
- * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
- * @param *tp Type information of the procedure called.
- */
-ir_node *new_r_Call (ir_graph *irg, ir_node *block, ir_node *store,
- ir_node *callee, int arity, ir_node *in[],
- ir_type *tp);
-
-/** Constructor for a Add node.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_r_Add (ir_graph *irg, ir_node *block,
- ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/**
- * Constructor for a Sub node.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the results.
- */
-ir_node *new_r_Sub (ir_graph *irg, ir_node *block,
- ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Minus node.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op The operand.
- * @param *mode The mode of the operand and the result.
- */
-ir_node *new_r_Minus (ir_graph *irg, ir_node *block,
- ir_node *op, ir_mode *mode);
-/** Constructor for a Mul node.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_r_Mul (ir_graph *irg, ir_node *block,
- ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Quot node.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *memop The store needed to model exceptions
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the result.
- */
-ir_node *new_r_Quot (ir_graph *irg, ir_node *block,
- ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a DivMod node.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *memop The store needed to model exceptions
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the results.
- */
-ir_node *new_r_DivMod (ir_graph *irg, ir_node *block,
- ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Div node.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *memop The store needed to model exceptions
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the result.
- */
-ir_node *new_r_Div (ir_graph *irg, ir_node *block,
- ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Mod node.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *memop The store needed to model exceptions
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the result.
- */
-ir_node *new_r_Mod (ir_graph *irg, ir_node *block,
- ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Abs node.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op The operand
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_r_Abs (ir_graph *irg, ir_node *block,
- ir_node *op, ir_mode *mode);
-
-/** Constructor for a And node.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_r_And (ir_graph *irg, ir_node *block,
- ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Or node.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_r_Or (ir_graph *irg, ir_node *block,
- ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Eor node.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the results.
- */
-ir_node *new_r_Eor (ir_graph *irg, ir_node *block,
- ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Not node.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op The operand.
- * @param *mode The mode of the operand and the result.
- */
-ir_node *new_r_Not (ir_graph *irg, ir_node *block,
- ir_node *op, ir_mode *mode);
-
-/** Constructor for a Cmp node.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- */
-ir_node *new_r_Cmp (ir_graph *irg, ir_node *block,
- ir_node *op1, ir_node *op2);
-
-/** Constructor for a Shl node.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op The operand.
- * @param *k The number of bits to shift the operand .
- * @param *mode The mode of the operand and the result.
- */
-ir_node *new_r_Shl (ir_graph *irg, ir_node *block,
- ir_node *op, ir_node *k, ir_mode *mode);
-
-/** Constructor for a Shr node.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op The operand.
- * @param *k The number of bits to shift the operand .
- * @param *mode The mode of the operand and the result.
- */
-ir_node *new_r_Shr (ir_graph *irg, ir_node *block,
- ir_node *op, ir_node *k, ir_mode *mode);
-
-/**
- * Constructor for a Shrs node.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op The operand.
- * @param *k The number of bits to shift the operand.
- * @param *mode The mode of the operand and the result.
- */
-ir_node *new_r_Shrs (ir_graph *irg, ir_node *block,
- ir_node *op, ir_node *k, ir_mode *mode);
-
-/** Constructor for a Rot node.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op The operand.
- * @param *k The number of bits to rotate the operand.
- * @param *mode The mode of the operand.
- */
-ir_node *new_r_Rot (ir_graph *irg, ir_node *block,
- ir_node *op, ir_node *k, ir_mode *mode);
-
-/** Constructor for a Conv node.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op The operand.
- * @param *mode The mode of this the operand muss be converted .
- */
-ir_node *new_r_Conv (ir_graph *irg, ir_node *block,
- ir_node *op, ir_mode *mode);
-
-/** Constructor for a Cast node.
- *
- * High level type cast
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op The operand.
- * @param *to_tp The type of this the operand muss be casted .
- */
-ir_node *new_r_Cast (ir_graph *irg, ir_node *block,
- ir_node *op, ir_type *to_tp);
-
-/** Constructor for a Carry node.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_r_Carry (ir_graph *irg, ir_node *block,
- ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/**
- * Constructor for a Borrow node.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the results.
- */
-ir_node *new_r_Borrow (ir_graph *irg, ir_node *block,
- ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Phi node.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param arity The number of predecessors
- * @param *in[] Array with predecessors. The constructor copies this array.
- * @param *mode The mode of it's inputs and output.
- */
-ir_node *new_r_Phi (ir_graph *irg, ir_node *block, int arity,
- ir_node *in[], ir_mode *mode);
-
-/** Constructor for a Load node.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *store The current memory
- * @param *adr A pointer to the variable to be read in this memory.
- * @param *mode The mode of the value to be loaded.
- */
-ir_node *new_r_Load (ir_graph *irg, ir_node *block,
- ir_node *store, ir_node *adr, ir_mode *mode);
-
-/** Constructor for a Store node.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *store The current memory
- * @param *adr A pointer to the variable to be read in this memory.
- * @param *val The value to write to this variable.
- */
-ir_node *new_r_Store (ir_graph *irg, ir_node *block,
- ir_node *store, ir_node *adr, ir_node *val);
-
-/** Constructor for a Alloc node.
- *
- * The Alloc node extends the memory by space for an entity of type alloc_type.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *store The memory which shall contain the new variable.
- * @param *size The number of bytes to allocate.
- * @param *alloc_type The type of the allocated variable.
- * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
- */
-ir_node *new_r_Alloc (ir_graph *irg, ir_node *block, ir_node *store,
- ir_node *size, ir_type *alloc_type, where_alloc where);
-
-/** Constructor for a Free node.
- *
- * Frees the memory occupied by the entity pointed to by the pointer
- * arg. Type indicates the type of the entity the argument points to.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *store The memory which shall contain the new variable.
- * @param *ptr The pointer to the object to free.
- * @param *size The number of objects of type free_type to free in a sequence.
- * @param *free_type The type of the freed variable.
- * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
- */
-ir_node *new_r_Free (ir_graph *irg, ir_node *block, ir_node *store,
- ir_node *ptr, ir_node *size, ir_type *free_type, where_alloc where);
-
-/** Constructor for a Sync node.
- *
- * Merges several memory values. The node assumes that a variable
- * either occurs only in one of the memories, or it contains the same
- * value in all memories where it occurs.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param arity The number of memories to synchronize.
- * @param *in[] An array of pointers to nodes that produce an output of type memory.
- * The constructor copies this array.
- */
-ir_node *new_r_Sync (ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
-
-/** Constructor for a Proj node.
- *
- * Projects a single value out of a tuple. The parameter proj gives the
- * position of the value within the tuple.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param arg A node producing a tuple.
- * @param *mode The mode of the value to project.
- * @param proj The position of the value in the tuple.
- */
-ir_node *new_r_Proj (ir_graph *irg, ir_node *block, ir_node *arg,
- ir_mode *mode, long proj);
-
-/** Constructor for a defaultProj node.
- *
- * Represents the default control flow of a Switch-Cond node.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param arg A node producing a tuple.
- * @param max_proj The end position of the value in the tuple.
- */
-ir_node *new_r_defaultProj (ir_graph *irg, ir_node *block, ir_node *arg, long max_proj);
-
-
-/** Constructor for a Tuple node.
- *
- * This is an auxiliary node to replace a node that returns a tuple
- * without changing the corresponding Proj nodes.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param arity The number of tuple elements.
- * @param *in[] An array containing pointers to the nodes producing the tuple elements.
- * The constructor copies this array.
- */
-ir_node *new_r_Tuple (ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
-
-/** Constructor for a Id node.
- *
- * This is an auxiliary node to replace a node that returns a single
- * value.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *val The operand to Id.
- * @param *mode The mode of *val.
- */
-ir_node *new_r_Id (ir_graph *irg, ir_node *block,
- ir_node *val, ir_mode *mode);
-
-/** Constructor for a Bad node.
- *
- * Returns the unique Bad node of the graph. The same as
- * get_irg_bad().
- *
- * @param *irg The ir graph the node belongs to.
- *
- */
-ir_node *new_r_Bad (ir_graph *irg);
-
-/** Constructor for a Confirm node.
- *
- * Specifies constraints for a value. To support dataflow analyses.
- *
- * Example: If the value never exceeds '100' this is expressed by placing a
- * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
- *
- * @param *irg The ir graph the node belong to.
- * @param *block The ir block the node belong to.
- * @param *val The value we express a constraint for
- * @param *bound The value to compare against. Must be a firm node, typically a constant.
- * @param cmp The compare operation.
- */
-ir_node *new_r_Confirm (ir_graph *irg, ir_node *block,
- ir_node *val, ir_node *bound, pn_Cmp cmp);
-
-/** Constructor for a Unknown node.
- *
- * Represents an arbitrary value. Places the node in
- * the start block.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *m The mode of the unknown value.
- */
-ir_node *new_r_Unknown(ir_graph *irg, ir_mode *m);
-
-/** Constructor for a CallBegin node.
- *
- * CallBegin represents control flow depending of the pointer value
- * representing the called method to the called methods. The
- * constructor copies the method pointer input from the passed Call
- * node.
- *
- * @param *irg The ir graph the node belong to.
- * @param *block The block the node belong to.
- * @param *callee The call node visible in the intra procedural view.
- */
-ir_node *new_r_CallBegin(ir_graph *irg, ir_node *block, ir_node *callee);
-
-/** Constructor for a EndReg node.
- *
- * Used to represent regular procedure end in interprocedual view.
- *
- * @param *irg The ir graph the node belong to.
- * @param *block The block the node belong to.
- */
-ir_node *new_r_EndReg (ir_graph *irg, ir_node *block);
-
-/** Constructor for a EndExcept node.
- *
- * Used to represent exceptional procedure end in interprocedural view.
- *
- * @param *irg The ir graph the node belong to.
- * @param *block The block the node belong to.
- */
-ir_node *new_r_EndExcept(ir_graph *irg, ir_node *block);
-
-/** Constructor for a Break node.
- *
- * Break represents control flow to a single control successor just as Jmp.
- * The blocks separated by a break may not be concatenated by an optimization.
- * It is used for the interprocedural representation where blocks are parted
- * behind Call nodes to represent the control flow to called procedures.
- *
- * @param *irg The ir graph the node belong to.
- * @param *block The block the node belong to.
- */
-ir_node *new_r_Break (ir_graph *irg, ir_node *block);
-
-/** Constructor for a Filter node.
- *
- * Constructor for a Filter node. Adds the node to the block in current_ir_block.
- * Filter is a node with two views used to construct the interprocedural view.
- * In intraprocedural view its semantics are identical to the Proj node.
- * In interprocedural view the Filter performs the Phi operation on method
- * parameters or results. Other than a Phi a Filter node may not be removed
- * if it has only a single input.
- *
- * The constructor builds the Filter in intraprocedural view.
- *
- * @param *irg The ir graph the node belong to.
- * @param *block The block the node belong to.
- * @param *arg The tuple value to project from.
- * @param *mode The mode of the projected value.
- * @param proj The position in the tuple to project from.
- */
-ir_node *new_r_Filter (ir_graph *irg, ir_node *block, ir_node *arg,
- ir_mode *mode, long proj);
-
-/** Constructor for a NoMem node.
- *
- * Returns the unique NoMem node of the graph. The same as
- * get_irg_no_mem().
- *
- * @param *irg The ir graph the node belongs to.
- */
-ir_node *new_r_NoMem (ir_graph *irg);
-
-/** Constructor for a Mux node.
- *
- * @param *irg The ir graph the node belong to.
- * @param *block The block the node belong to.
- * @param *sel The ir_node that calculates the boolean select.
- * @param *ir_true The ir_node that calculates the true result.
- * @param *ir_false The ir_node that calculates the false result.
- * @param *mode The mode of the node (and it_true and ir_false).
- */
-ir_node *new_r_Mux (ir_graph *irg, ir_node *block,
- ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
-
-/** Constructor for a Psi node.
- *
- * @param *irg The ir graph the node belong to.
- * @param *block The block the node belong to.
- * @param *arity The arity of the conditions
- * @param *conds The array of mode_b conditions, length must be equal arity
- * @param *vals The array of mode values, length must be equal arity + 1
- * @param *mode The mode of the node (must be the mode of all vals).
- */
-ir_node *new_r_Psi (ir_graph *irg, ir_node *block,
- int arity, ir_node *conds[], ir_node *vals[], ir_mode *mode);
-
-/** Constructor for a CopyB node.
- *
- * @param *irg The ir graph the node belong to.
- * @param *block The block the node belong to.
- * @param *store The current memory
- * @param *dst The ir_node that represents the destination address.
- * @param *src The ir_node that represents the source address.
- * @param *data_type The type of the copied data
- */
-ir_node *new_r_CopyB(ir_graph *irg, ir_node *block,
- ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
-
-/** Constructor for a InstOf node.
- *
- * A High-Level Type check.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *store The memory in which the object the entity should be selected
- * from is allocated.
- * @param *objptr A pointer to a object of a class type.
- * @param *type The type of which objptr must be.
- */
-ir_node *new_r_InstOf(ir_graph *irg, ir_node *block, ir_node *store,
- ir_node *objptr, ir_type *type);
-
-/** Constructor for a Raise node.
- *
- * A High-Level Exception throw.
- *
- * @param *irg The ir graph the node belongs to.
- * @param *block The ir block the node belongs to.
- * @param *store The current memory.
- * @param *obj A pointer to the Except variable.
- */
-ir_node *new_r_Raise(ir_graph *irg, ir_node *block,
- ir_node *store, ir_node *obj);
-
-/** Constructor for a Bound node.
- *
- * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
- *
- * @param *irg The ir graph the node belong to.
- * @param *block The block the node belong to.
- * @param *store The current memory.
- * @param *idx The ir_node that represents an index.
- * @param *lower The ir_node that represents the lower bound for the index.
- * @param *upper The ir_node that represents the upper bound for the index.
- */
-ir_node *new_r_Bound(ir_graph *irg, ir_node *block,
- ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
-
-/** Constructor for a Pin node.
- *
- * @param *irg The ir graph the node belong to.
- * @param *block The block the node belong to.
- * @param *node The node which value should be pinned.
- */
-ir_node *new_r_Pin(ir_graph *irg, ir_node *block, ir_node *node);
-
-/** Constructor for an ASM pseudo node.
- *
- * @param *irg The ir graph the node belong to.
- * @param *block The block the node belong to.
- * @param arity The number of data inputs to the node.
- * @param *in The array of length arity of data inputs.
- * @param *inputs The array of length arity of input constraints.
- * @param n_outs The number of data outputs to the node.
- * @param *outputs The array of length n_outs of output constraints.
- * @param n_clobber The number of clobbered registers.
- * @param *clobber The array of length n_clobber of clobbered registers.
- * @param *asm_text The assembler text.
- */
-ir_node *new_r_ASM(ir_graph *irg, ir_node *block,
- int arity, ir_node *in[], ir_asm_constraint *inputs,
- int n_outs, ir_asm_constraint *outputs,
- int n_clobber, ident *clobber[], ident *asm_text);
-
-/*-----------------------------------------------------------------------*/
-/* The block oriented interface */
-/*-----------------------------------------------------------------------*/
-
-/** Sets the current block in which the following constructors place the
- * nodes they construct.
- *
- * @param target The new current block.
- */
-void set_cur_block (ir_node *target);
-
-/** Returns the current block of the current graph. */
-ir_node *get_cur_block(void);
-
-/** Returns the fixed nodes of the current graph. */
-#define get_cur_end_block() get_irg_end_block(current_ir_graph)
-#define get_cur_end() get_irg_end(current_ir_graph)
-#define get_cur_start_block() get_irg_start_block(current_ir_graph)
-#define get_cur_start() get_irg_start(current_ir_graph)
-
-/** Constructor for a Block node.
- *
- * Adds the block to the graph in current_ir_graph. Constructs a Block
- * with a fixed number of predecessors. Does set current_block. Can
- * be used with automatic Phi node construction.
- *
- * @param *db A Pointer for debug information.
- * @param arity The number of control predecessors.
- * @param in[] An array of control predecessors. The length of
- * the array must be 'arity'.
- */
-ir_node *new_d_Block(dbg_info *db, int arity, ir_node *in[]);
-
-/** Constructor for a Start node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- */
-ir_node *new_d_Start (dbg_info *db);
-
-/** Constructor for a End node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- */
-ir_node *new_d_End (dbg_info *db);
-
-/** Constructor for a Jmp node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * Jmp represents control flow to a single control successor.
- *
- * @param *db A pointer for debug information.
- */
-ir_node *new_d_Jmp (dbg_info *db);
-
-/** Constructor for an IJmp node.
- *
- * IJmp represents control flow to a single control successor not
- * statically known i.e. an indirect Jmp.
- *
- * @param *db A pointer for debug information.
- * @param *tgt The ir node representing the target address.
- */
-ir_node *new_d_IJmp (dbg_info *db, ir_node *tgt);
-
-/** Constructor for a Cond node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * If c is mode_b represents a conditional branch (if/else). If c is
- * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
- * node, default Proj is 0.)
- *
- * This is not consistent: Input to Cond is Is, Proj has as proj number
- * longs.
- *
- * @param *db A pointer for debug information.
- * @param *c The conditions parameter.Can be of mode b or I_u.
- */
-ir_node *new_d_Cond (dbg_info *db, ir_node *c);
-
-/** Constructor for a Return node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * Returns the memory an zero or more return values. Only node that
- * can end regular control flow.
- *
- * @param *db A pointer for debug information.
- * @param *store The state of memory.
- * @param arity Number of array indices.
- * @param *in Array with index inputs to the node.
- */
-ir_node *new_d_Return (dbg_info *db, ir_node *store, int arity, ir_node *in[]);
-
-/** Constructor for a Const_type node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * The constant represents a target value. This constructor sets high
- * level type information for the constant value.
- *
- * @param *db A pointer for debug information.
- * @param *mode The mode of the operands and results.
- * @param *con Points to an entry in the constant table. This pointer is
- added to the attributes of the node.
- * @param *tp The type of the constant.
- */
-ir_node *new_d_Const_type (dbg_info *db, ir_mode *mode, tarval *con, ir_type *tp);
-
-/** Constructor for a Const node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * Constructor for a Const node. The constant represents a target
- * value. Sets the type information to type_unknown. (No more
- * supported: If tv is entity derives a somehow useful type.)
- *
- * @param *db A pointer for debug information.
- * @param *mode The mode of the operands and results.
- * @param *con Points to an entry in the constant table. This pointer is added
- * to the attributes of the node.
- */
-ir_node *new_d_Const (dbg_info *db, ir_mode *mode, tarval *con);
-
-/** Constructor for a SymConst_type node.
- *
- * Adds the node to the block in current_ir_block.
- * This is the constructor for a symbolic constant.
- * There are four kinds of symbolic constants:
- * - type_tag The symbolic constant represents a type tag. The type the
- * tag stands for is given explicitly.
- * - size The symbolic constant represents the size of a type. The
- * type of which the constant represents the size is given
- * explicitly.
- * - addr_name The symbolic constant represents the address of an entity
- * (variable or method). The variable is indicated by a name
- * that is valid for linking.
- * - addr_ent The symbolic constant represents the address of an entity
- * (variable or method). The variable is given explicitly by
- * a firm entity.
- *
- * Inputs to the node:
- * No inputs except the block it belongs to.
- * Outputs of the node.
- * An unsigned integer (I_u) or a pointer (P).
- *
- * @param *db A pointer for debug information.
- * @param value A type, entity or ident depending on the SymConst kind.
- * @param kind The kind of the symbolic constant: symconst_type_tag, symconst_type_size,
- * symconst_type_align, symconst_addr_name or symconst_addr_ent.
- * @param tp The source type of the constant.
- */
-ir_node *new_d_SymConst_type (dbg_info *db, union symconst_symbol value, symconst_kind kind, ir_type *tp);
-
-/** Constructor for a SymConst node.
- *
- * Same as new_d_SymConst_type, except that it sets the type to type_unknown. */
-ir_node *new_d_SymConst (dbg_info *db, union symconst_symbol value, symconst_kind kind);
-
-/** Constructor for a simpleSel node.
- *
- * This is a shortcut for the new_d_Sel() constructor. To be used for
- * Sel nodes that do not select from an array, i.e., have no index
- * inputs. It adds the two parameters 0, NULL.
- *
- * @param *db A pointer for debug information.
- * @param *store The memory in which the object the entity should be
- * selected from is allocated.
- * @param *objptr The object from that the Sel operation selects a
- * single attribute out.
- * @param *ent The entity to select.
- */
-ir_node *new_d_simpleSel(dbg_info *db, ir_node *store, ir_node *objptr, ir_entity *ent);
-
-/** Constructor for a Sel node.
- *
- * The select node selects an entity (field or method) from an entity
- * with a compound type. It explicitly specifies the entity selected.
- * Dynamically the node may select entities that overwrite the given
- * entity. If the selected entity is an array element entity the Sel
- * node takes the required array indices as inputs.
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *store The memory in which the object the entity should be selected
- * from is allocated.
- * @param *objptr A pointer to a compound entity the Sel operation selects a
- * single attribute from.
- * @param arity The number of array indices needed to select an array element entity.
- * @param *in[] If the compound entity is an array the indices of the selected
- * element entity. The constructor copies this array.
- * @param *ent The entity to select.
- */
-ir_node *new_d_Sel (dbg_info *db, ir_node *store, ir_node *objptr, int arity, ir_node *in[],
- ir_entity *ent);
-
-/** Constructor for a Call node.
- *
- * Represents all kinds of method and function calls.
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *store The actual store.
- * @param *callee A pointer to the called procedure.
- * @param arity The number of procedure parameters.
- * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
- * @param *tp Type information of the procedure called.
- */
-ir_node *new_d_Call (dbg_info *db, ir_node *store, ir_node *callee, int arity, ir_node *in[],
- ir_type *tp);
-
-/** Constructor for a Add node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_d_Add (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Sub node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_d_Sub (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Minus node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *op The operand .
- * @param *mode The mode of the operand and the result.
- */
-ir_node *new_d_Minus (dbg_info *db, ir_node *op, ir_mode *mode);
-
-/** Constructor for a Mul node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_d_Mul (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Quot node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *memop The store needed to model exceptions
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the result.
- */
-ir_node *new_d_Quot (dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a DivMod node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *memop The store needed to model exceptions
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the results.
- */
-ir_node *new_d_DivMod (dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Div node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *memop The store needed to model exceptions
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the result.
- */
-ir_node *new_d_Div (dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Mod node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *memop The store needed to model exceptions
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the result.
- */
-ir_node *new_d_Mod (dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Abs node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *op The operand
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_d_Abs (dbg_info *db, ir_node *op, ir_mode *mode);
-
-/** Constructor for a And node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_d_And (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Or node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_d_Or (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Eor node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the results.
- */
-ir_node *new_d_Eor (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Not node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *op The operand.
- * @param *mode The mode of the operand and the result.
- */
-ir_node *new_d_Not (dbg_info *db, ir_node *op, ir_mode *mode);
-
-/** Constructor for a Shl node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *op The operand.
- * @param *k The number of bits to shift the operand .
- * @param *mode The mode of the operand and the result.
- */
-ir_node *new_d_Shl (dbg_info *db, ir_node *op, ir_node *k, ir_mode *mode);
-
-/** Constructor for a Shr node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *op The operand.
- * @param *k The number of bits to shift the operand .
- * @param *mode The mode of the operand and the result.
- */
-ir_node *new_d_Shr (dbg_info *db, ir_node *op, ir_node *k, ir_mode *mode);
-
-/** Constructor for a Shrs node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *op The operand.
- * @param *k The number of bits to shift the operand .
- * @param *mode The mode of the operand and the result.
- */
-ir_node *new_d_Shrs (dbg_info *db, ir_node *op, ir_node *k, ir_mode *mode);
-
-/** Constructor for a Rot node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *op The operand.
- * @param *k The number of bits to rotate the operand.
- * @param *mode The mode of the operand.
- */
-ir_node *new_d_Rot (dbg_info *db, ir_node *op, ir_node *k, ir_mode *mode);
-
-/** Constructor for a Cmp node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- */
-ir_node *new_d_Cmp (dbg_info *db, ir_node *op1, ir_node *op2);
-
-/** Constructor for a Conv node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *op The operand.
- * @param *mode The mode of this the operand muss be converted .
- */
-ir_node *new_d_Conv (dbg_info *db, ir_node *op, ir_mode *mode);
-
-/** Constructor for a strict Conv node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *op The operand.
- * @param *mode The mode of this the operand muss be converted .
- */
-ir_node *new_d_strictConv (dbg_info *db, ir_node *op, ir_mode *mode);
-
-/** Constructor for a Cast node.
- *
- * High level type cast
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *op The operand.
- * @param *to_tp The type of this the operand muss be casted .
- */
-ir_node *new_d_Cast (dbg_info *db, ir_node *op, ir_type *to_tp);
-
-/** Constructor for a Carry node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_d_Carry (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Borrow node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_d_Borrow (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Phi node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param arity The number of predecessors
- * @param *in Array with predecessors
- * @param *mode The mode of it's inputs and output.
- */
-ir_node *new_d_Phi (dbg_info *db, int arity, ir_node *in[], ir_mode *mode);
-
-/** Constructor for a Load node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *store The current memory
- * @param *addr A pointer to the variable to be read in this memory.
- * @param *mode The mode of the value to be loaded.
- */
-ir_node *new_d_Load (dbg_info *db, ir_node *store, ir_node *addr, ir_mode *mode);
-
-/** Constructor for a Store node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *store The current memory
- * @param *addr A pointer to the variable to be read in this memory.
- * @param *val The value to write to this variable.
- */
-ir_node *new_d_Store (dbg_info *db, ir_node *store, ir_node *addr, ir_node *val);
-
-/** Constructor for a Alloc node.
- *
- * The Alloc node extends the memory by space for an entity of type alloc_type.
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *store The memory which shall contain the new variable.
- * @param *size The number of bytes to allocate.
- * @param *alloc_type The type of the allocated variable.
- * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
- */
-ir_node *new_d_Alloc (dbg_info *db, ir_node *store, ir_node *size, ir_type *alloc_type,
- where_alloc where);
-
- /** Constructor for a Free node.
- *
- * Frees the memory occupied by the entity pointed to by the pointer
- * arg. Type indicates the type of the entity the argument points to.
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *store The memory which shall contain the new variable.
- * @param *ptr The pointer to the object to free.
- * @param *size The number of objects of type free_type to free in a sequence.
- * @param *free_type The type of the freed variable.
- * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
- */
-ir_node *new_d_Free (dbg_info *db, ir_node *store, ir_node *ptr, ir_node *size,
- ir_type *free_type, where_alloc where);
-
-/** Constructor for a Sync node.
- *
- * Merges several memory values. The node assumes that a variable
- * either occurs only in one of the memories, or it contains the same
- * value in all memories where it occurs.
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param arity The number of memories to synchronize.
- * @param **in An array of pointers to nodes that produce an output of type
- * memory. The constructor copies this array.
- */
-ir_node *new_d_Sync (dbg_info *db, int arity, ir_node *in[]);
-
-/** Constructor for a Proj node.
- *
- * Projects a single value out of a tuple. The parameter proj gives the
- * position of the value within the tuple.
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for deubug information.
- * @param arg A node producing a tuple.
- * @param *mode The mode of the value to project.
- * @param proj The position of the value in the tuple.
- */
-ir_node *new_d_Proj (dbg_info *db, ir_node *arg, ir_mode *mode, long proj);
-
-/** Constructor for a defaultProj node.
- *
- * Represents the default control flow of a Switch-Cond node.
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param arg A node producing a tuple.
- * @param max_proj The end position of the value in the tuple.
- */
-ir_node *new_d_defaultProj (dbg_info *db, ir_node *arg, long max_proj);
-
-/** Constructor for a Tuple node.
- *
- * This is an auxiliary node to replace a node that returns a tuple
- * without changing the corresponding Proj nodes.
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param arity The number of tuple elements.
- * @param **in An array containing pointers to the nodes producing the tuple elements.
- */
-ir_node *new_d_Tuple (dbg_info *db, int arity, ir_node *in[]);
-
-/** Constructor for a Id node.
- *
- * This is an auxiliary node to replace a node that returns a single
- * value. Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *val The operand to Id.
- * @param *mode The mode of *val.
- */
-ir_node *new_d_Id (dbg_info *db, ir_node *val, ir_mode *mode);
-
-/** Constructor for a Bad node.
- *
- * Returns the unique Bad node of the graph. The same as
- * get_irg_bad().
- */
-ir_node *new_d_Bad (void);
-
-/** Constructor for a Confirm node.
- *
- * Constructor for a Confirm node. Adds the node to the block in current_ir_block.
- * Specifies constraints for a value. To support dataflow analyses.
- *
- * Example: If the value never exceeds '100' this is expressed by placing a
- * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
- *
- * @param *db A pointer for debug information.
- * @param *val The value we express a constraint for
- * @param *bound The value to compare against. Must be a firm node, typically a constant.
- * @param cmp The compare operation.
- */
-ir_node *new_d_Confirm (dbg_info *db, ir_node *val, ir_node *bound, pn_Cmp cmp);
-
-/** Constructor for an Unknown node.
- *
- * Represents an arbitrary value. Places the node in
- * the start block.
- *
- * @param *m The mode of the unknown value.
- */
-ir_node *new_d_Unknown(ir_mode *m);
-
-/** Constructor for a CallBegin node.
- *
- * CallBegin represents control flow depending of the pointer value
- * representing the called method to the called methods. The
- * constructor copies the method pointer input from the passed Call
- * node.Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- * @param *callee The call node visible in the intra procedural view.
- */
-ir_node *new_d_CallBegin(dbg_info *db, ir_node *callee);
-
-/** Constructor for an EndReg node.
- *
- *Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- */
-ir_node *new_d_EndReg (dbg_info *db);
-
-/** Constructor for an EndExcept node.
- *
- * Used to represent regular procedure end in interprocedual view.
- * Adds the node to the block in current_ir_block.
- *
- * @param *db A pointer for debug information.
- */
-ir_node *new_d_EndExcept(dbg_info *db);
-
-/** Constructor for a Break node.
- *
- * Used to represent exceptional procedure end in interprocedural view.
- * Adds the node to the block in current_ir_block.
- *
- * Break represents control flow to a single control successor just as Jmp.
- * The blocks separated by a break may not be concatenated by an optimization.
- * It is used for the interprocedural representation where blocks are parted
- * behind Call nodes to represent the control flow to called procedures.
- *
- * @param *db A pointer for debug information.
- */
-ir_node *new_d_Break (dbg_info *db);
-
-/** Constructor for a Filter node.
- *
- * Constructor for a Filter node. Adds the node to the block in
- * current_ir_block. Filter is a node with two views used to
- * construct the interprocedural view. In intraprocedural view its
- * semantics are identical to the Proj node. In interprocedural view
- * the Filter performs the Phi operation on method parameters or
- * results. Other than a Phi a Filter node may not be removed if it
- * has only a single input.
- *
- * The constructor builds the Filter in intraprocedural view.
- *
- * @param *db A pointer for debug information.
- * @param *arg The tuple value to project from.
- * @param *mode The mode of the projected value.
- * @param proj The position in the tuple to project from.
- */
-ir_node *new_d_Filter (dbg_info *db, ir_node *arg, ir_mode *mode, long proj);
-
-
-/** Constructor for a NoMem node.
- *
- * Returns the unique NoMem node of the graph. The same as
- * get_irg_no_mem().
- */
-ir_node *new_d_NoMem (void);
-
-/** Constructor for a Mux node.
- *
- * @param *db A pointer for debug information.
- * @param *sel The ir_node that calculates the boolean select.
- * @param *ir_true The ir_node that calculates the true result.
- * @param *ir_false The ir_node that calculates the false result.
- * @param *mode The mode of the node (and it_true and ir_false).
- */
-ir_node *new_d_Mux (dbg_info *db, ir_node *sel,
- ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
-
-/** Constructor for a Psi node.
- *
- * @param *db A pointer for debug information.
- * @param *arity The arity of the conditions
- * @param *conds The array of mode_b conditions, length must be equal arity
- * @param *vals The array of mode values, length must be equal arity + 1
- * @param *mode The mode of the node (must be the mode of all vals).
- */
-ir_node *new_d_Psi (dbg_info *db,
- int arity, ir_node *conds[], ir_node *vals[], ir_mode *mode);
-
-/** Constructor for a CopyB node.
- *
- * @param *db A pointer for debug information.
- * @param *store The current memory
- * @param *dst The ir_node that represents the destination address.
- * @param *src The ir_node that represents the source address.
- * @param *data_type The type of the copied data
- */
-ir_node *new_d_CopyB(dbg_info *db, ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
-
-/** Constructor for a InstOf node.
- *
- * A High-Level Type check.
- *
- * @param *db A pointer for debug information.
- * @param *store The memory in which the object the entity should be selected
- * from is allocated.
- * @param *objptr A pointer to a object of a class type.
- * @param *type The type of which objptr must be.
- */
-ir_node *new_d_InstOf (dbg_info *db, ir_node *store, ir_node *objptr, ir_type *type);
-
-/** Constructor for a Raise node.
- *
- * A High-Level Exception throw.
- *
- * @param *db A pointer for debug information.
- * @param *store The current memory.
- * @param *obj A pointer to the Except variable.
- */
-ir_node *new_d_Raise (dbg_info *db, ir_node *store, ir_node *obj);
-
-/** Constructor for a Bound node.
- *
- * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
- *
- * @param *db A pointer for debug information.
- * @param *store The current memory
- * @param *idx The ir_node that represents an index.
- * @param *lower The ir_node that represents the lower bound for the index.
- * @param *upper The ir_node that represents the upper bound for the index.
- */
-ir_node *new_d_Bound(dbg_info *db, ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
-
-/** Constructor for a Pin node.
- *
- * @param *db A pointer for debug information.
- * @param *node The node which value should be pinned.
- */
-ir_node *new_d_Pin(dbg_info *db, ir_node *node);
-
-/** Constructor for an ASM pseudo node.
- *
- * @param *db A pointer for debug information.
- * @param arity The number of data inputs to the node.
- * @param *in The array of length arity of data inputs.
- * @param *inputs The array of length arity of input constraints.
- * @param n_outs The number of data outputs to the node.
- * @param *outputs The array of length n_outs of output constraints.
- * @param n_clobber The number of clobbered registers.
- * @param *clobber The array of length n_clobber of clobbered registers.
- * @param *asm_text The assembler text.
- */
-ir_node *new_d_ASM(dbg_info *db, int arity, ir_node *in[], ir_asm_constraint *inputs,
- int n_outs, ir_asm_constraint *outputs,
- int n_clobber, ident *clobber[], ident *asm_text);
-
-/*-----------------------------------------------------------------------*/
-/* The block oriented interface without debug support */
-/*-----------------------------------------------------------------------*/
-
-/* Needed from the interface with debug support:
-void set_cur_block (ir_node *target); */
-
-/** Constructor for a Block node.
- *
- * Constructor for a Block node. Adds the block to the graph in
- * current_ir_graph. Constructs a Block with a fixed number of
- * predecessors. Does set current_block. Can be used with automatic
- * Phi node construction.
- *
- * @param arity The number of control predecessors.
- * @param in An array of control predecessors. The length of
- * the array must be 'arity'.
- */
-ir_node *new_Block(int arity, ir_node *in[]);
-
-/** Constructor for a Start node.
- *
- * Adds the node to the block in current_ir_block.
- *
- */
-ir_node *new_Start (void);
-
-/** Constructor for an End node.
- *
- * Adds the node to the block in current_ir_block.
- */
-ir_node *new_End (void);
-
-/** Constructor for an EndReg node.
- *
- * Used to represent regular procedure end in interprocedual view.
- * Adds the node to the block in current_ir_block.
- */
-ir_node *new_EndReg (void);
-
-/** Constructor for an EndExpcept node.
- *
- * Used to represent exceptional procedure end in interprocedural view.
- * Adds the node to the block in current_ir_block.
- */
-ir_node *new_EndExcept(void);
-
-/** Constructor for a Jump node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * Jmp represents control flow to a single control successor.
- */
-ir_node *new_Jmp (void);
-
-/** Constructor for an IJmp node.
- *
- * IJmp represents control flow to a single control successor not
- * statically known i.e. an indirect Jmp.
- *
- * @param *tgt The ir node representing the target address.
- */
-ir_node *new_IJmp (ir_node *tgt);
-
-/** Constructor for a Break node.
- * Break represents control flow to a single control successor just as Jmp.
- * The blocks separated by a break may not be concatenated by an optimization.
- * It is used for the interprocedural representation where blocks are parted
- * behind Call nodes to represent the control flow to called procedures.
- * Adds the node to the block in current_ir_block.
- */
-ir_node *new_Break (void);
-
-/** Constructor for a Cond node.
- *
- * If c is mode_b represents a conditional branch (if/else). If c is
- * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
- * node, default Proj is 0.). Adds the node to the block in current_ir_block.
- *
- * This is not consistent: Input to Cond is Is, Proj has as proj number
- * longs.
- *
- *
- * @param *c The conditions parameter.Can be of mode b or I_u.
- */
-ir_node *new_Cond (ir_node *c);
-
-/** Constructor for a Return node.
- *
- * Returns the memory an zero or more return values. Only node that
- * can end regular control flow. Adds the node to the block in current_ir_block.
- *
- * @param *store The state of memory.
- * @param arity Number of array indices.
- * @param *in Array with index inputs to the node.
- */
-ir_node *new_Return (ir_node *store, int arity, ir_node *in[]);
-
-/** Constructor for a Const node.
- *
- * Constructor for a Const node. The constant represents a target
- * value. Sets the type information to type_unknown. (No more
- * supported: If tv is entity derives a somehow useful type.)
- * Adds the node to the block in current_ir_block.
- *
- * @param *mode The mode of the operands and results.
- * @param *con Points to an entry in the constant table. This pointer is
- * added to the attributes of the node.
- */
-ir_node *new_Const (ir_mode *mode, tarval *con);
-
-/**
- * Make a const from a long.
- * This is just convenience for the usual
- * <code>
- * new_Const(mode, tarval_from_long(mode, ...))
- * </code>
- * pain.
- * @param mode The mode for the const.
- * @param value The value of the constant.
- * @return A new const node.
- */
-ir_node *new_Const_long(ir_mode *mode, long value);
-
-/** Constructor for a Const node.
- *
- * Derives mode from passed type. */
-ir_node *new_Const_type(tarval *con, ir_type *tp);
-
-/** Constructor for a SymConst node.
- *
- * Adds the node to the block in current_ir_block.
- * This is the constructor for a symbolic constant.
- * There are four kinds of symbolic constants:
- * -# type_tag The symbolic constant represents a type tag. The type the
- * tag stands for is given explicitly.
- * -# size The symbolic constant represents the size of a type. The
- * type of which the constant represents the size is given
- * explicitly.
- * -# align The symbolic constant represents the alignment of a type. The
- * type of which the constant represents the size is given
- * explicitly.
- * -# addr_name The symbolic constant represents the address of an entity
- * (variable or method). The variable is indicated by a name
- * that is valid for linking.
- * -# addr_ent The symbolic constant represents the address of an entity
- * (variable or method). The variable is given explicitly by
- * a firm entity.
- *
- * Inputs to the node:
- * No inputs except the block it belongs to.
- * Outputs of the node.
- * An unsigned integer (I_u) or a pointer (P).
- *
- * @param value A type or a ident depending on the SymConst kind.
- * @param kind The kind of the symbolic constant: symconst_type_tag, symconst_type_size
- * symconst_type_align, symconst_addr_name or symconst_addr_ent.
- * @param tp The source type of the constant.
- */
-ir_node *new_SymConst_type (union symconst_symbol value, symconst_kind kind, ir_type *tp);
-
-/** Constructor for a SymConst node.
- *
- * Adds the node to the block in current_ir_block.
- * This is the constructor for a symbolic constant.
- * There are four kinds of symbolic constants:
- * -# type_tag The symbolic constant represents a type tag. The type the
- * tag stands for is given explicitly.
- * -# size The symbolic constant represents the size of a type. The
- * type of which the constant represents the size is given
- * explicitly.
- * -# align The symbolic constant represents the alignment of a type. The
- * type of which the constant represents the size is given
- * explicitly.
- * -# addr_name The symbolic constant represents the address of an entity
- * (variable or method). The variable is indicated by a name
- * that is valid for linking.
- * -# addr_ent The symbolic constant represents the address of an entity
- * (variable or method). The variable is given explicitly by
- * a firm entity.
- *
- * Inputs to the node:
- * No inputs except the block it belongs to.
- * Outputs of the node.
- * An unsigned integer (I_u) or a pointer (P).
- *
- * @param value A type or a ident depending on the SymConst kind.
- * @param kind The kind of the symbolic constant: symconst_type_tag, symconst_type_size
- * symconst_type_align, symconst_addr_name or symconst_addr_ent.
- */
-ir_node *new_SymConst (union symconst_symbol value, symconst_kind kind);
-
-/** Constructor for a simpelSel node.
- *
- * This is a shortcut for the new_Sel() constructor. To be used for
- * Sel nodes that do not select from an array, i.e., have no index
- * inputs. It adds the two parameters 0, NULL.
- *
- * @param *store The memory in which the object the entity should be selected from is allocated.
- * @param *objptr The object from that the Sel operation selects a single attribute out.
- * @param *ent The entity to select.
- */
-ir_node *new_simpleSel(ir_node *store, ir_node *objptr, ir_entity *ent);
-
-/** Constructor for a Sel node.
- *
- * The select node selects an entity (field or method) from an entity
- * with a compound type. It explicitly specifies the entity selected.
- * Dynamically the node may select entities that overwrite the given
- * entity. If the selected entity is an array element entity the Sel
- * node takes the required array indices as inputs.
- * Adds the node to the block in current_ir_block.
- *
- * @param *store The memory in which the object the entity should be selected
- * from is allocated.
- * @param *objptr A pointer to a compound entity the Sel operation selects a
- * single attribute from.
- * @param arity The number of array indices needed to select an array element entity.
- * @param *in[] If the compound entity is an array the indices of the selected
- * element entity. The constructor copies this array.
- * @param *ent The entity to select.
- */
-ir_node *new_Sel (ir_node *store, ir_node *objptr, int arity, ir_node *in[],
- ir_entity *ent);
-
-/** Constructor for a Call node.
- *
- * Adds the node to the block in current_ir_block.
- * Represents all kinds of method and function calls.
- *
- * @param *store The actual store.
- * @param *callee A pointer to the called procedure.
- * @param arity The number of procedure parameters.
- * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
- * @param *tp Type information of the procedure called.
- */
-ir_node *new_Call (ir_node *store, ir_node *callee, int arity, ir_node *in[],
- ir_type *tp);
-
-/** Constructor for a CallBegin node.
- *
- * CallBegin represents control flow depending of the pointer value
- * representing the called method to the called methods. The
- * constructor copies the method pointer input from the passed Call
- * node. Adds the node to the block in current_ir_block.
- *
- * @param *callee A pointer to the called procedure.
- */
-ir_node *new_CallBegin(ir_node *callee);
-
-/** Constructor for a Add node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Sub node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Minus node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *op The operand .
- * @param *mode The mode of the operand and the result.
- */
-ir_node *new_Minus (ir_node *op, ir_mode *mode);
-
-/**
- * Constructor for a Mul node. Adds the node to the block in current_ir_block.
- *
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_Mul (ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Quot node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *memop The store needed to model exceptions
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the result.
- */
-ir_node *new_Quot (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a DivMod node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *memop The store needed to model exceptions
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the results.
- */
-ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Div node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *memop The store needed to model exceptions
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the result.
- */
-ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Mod node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *memop The store needed to model exceptions
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the result.
- */
-ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Abs node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *op The operand
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_Abs (ir_node *op, ir_mode *mode);
-
-/** Constructor for a And node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/**
- * Constructor for a Or node. Adds the node to the block in current_ir_block.
- *
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/**
- * Constructor for a Eor node. Adds the node to the block in current_ir_block.
- *
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the results.
- */
-ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Not node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *op The operand.
- * @param *mode The mode of the operand and the result.
- */
-ir_node *new_Not (ir_node *op, ir_mode *mode);
-
-/** Constructor for a Shl node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *op The operand.
- * @param *k The number of bits to shift the operand .
- * @param *mode The mode of the operand and the result.
- */
-ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode);
-
-/**
- * Constructor for a Shr node. Adds the node to the block in current_ir_block.
- *
- * @param *op The operand.
- * @param *k The number of bits to shift the operand .
- * @param *mode The mode of the operand and the result.
- */
-ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode);
-
-/** Constructor for a Shrs node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *op The operand.
- * @param *k The number of bits to shift the operand .
- * @param *mode The mode of the operand and the result.
- */
-ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode);
-
-/** Constructor for a Rot node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *op The operand.
- * @param *k The number of bits to rotate the operand.
- * @param *mode The mode of the operand.
- */
-ir_node *new_Rot (ir_node *op, ir_node *k, ir_mode *mode);
-
-/** Constructor for a Cmp node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- */
-ir_node *new_Cmp (ir_node *op1, ir_node *op2);
-
-/** Constructor for a Conv node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *op The operand.
- * @param *mode The mode of this the operand muss be converted.
- */
-ir_node *new_Conv (ir_node *op, ir_mode *mode);
-
-/** Constructor for a strict Conv node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *op The operand.
- * @param *mode The mode of this the operand muss be converted.
- */
-ir_node *new_strictConv (ir_node *op, ir_mode *mode);
-
-/** Constructor for a Cast node.
- *
- * Adds the node to the block in current_ir_block.
- * High level type cast
- *
- * @param *op The operand.
- * @param *to_tp The type of this the operand muss be casted .
- */
-ir_node *new_Cast (ir_node *op, ir_type *to_tp);
-
-/** Constructor for a Carry node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_Carry (ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Borrow node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *op1 The first operand.
- * @param *op2 The second operand.
- * @param *mode The mode of the operands and the result.
- */
-ir_node *new_Borrow (ir_node *op1, ir_node *op2, ir_mode *mode);
-
-/** Constructor for a Phi node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param arity The number of predecessors.
- * @param *in Array with predecessors.
- * @param *mode The mode of it's inputs and output.
- */
-ir_node *new_Phi (int arity, ir_node *in[], ir_mode *mode);
-
-/** Constructor for a Load node.
- *
- * @param *store The current memory.
- * @param *addr A pointer to the variable to be read in this memory.
- * @param *mode The mode of the value to be loaded.
- */
-ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode);
-
-/** Constructor for a Store node.
- *
- * @param *store The current memory.
- * @param *addr A pointer to the variable to be read in this memory.
- * @param *val The value to write to this variable.
- */
-ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val);
-
-/** Constructor for a Alloc node.
- *
- * The Alloc node extends the memory by space for an entity of type alloc_type.
- * Adds the node to the block in current_ir_block.
- *
- * @param *store The memory which shall contain the new variable.
- * @param *size The number of bytes to allocate.
- * @param *alloc_type The type of the allocated variable.
- * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
- */
-ir_node *new_Alloc (ir_node *store, ir_node *size, ir_type *alloc_type,
- where_alloc where);
-
-/** Constructor for a Free node.
- *
- * Frees the memory occupied by the entity pointed to by the pointer
- * arg. Type indicates the type of the entity the argument points to.
- * Adds the node to the block in current_ir_block.
- *
- * @param *store The memory which shall contain the new variable.
- * @param *ptr The pointer to the object to free.
- * @param *size The number of objects of type free_type to free in a sequence.
- * @param *free_type The type of the freed variable.
- * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
- */
-ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size,
- ir_type *free_type, where_alloc where);
-
-/** Constructor for a Sync node.
- *
- * Merges several memory values. The node assumes that a variable
- * either occurs only in one of the memories, or it contains the same
- * value in all memories where it occurs.
- * Adds the node to the block in current_ir_block.
- *
- * @param arity The number of memories to synchronize.
- * @param **in An array of pointers to nodes that produce an output of type
- * memory. The constructor copies this array.
- */
-ir_node *new_Sync (int arity, ir_node *in[]);
-
-/** Constructor for a Proj node.
- *
- * Projects a single value out of a tuple. The parameter proj gives the
- * position of the value within the tuple.
- * Adds the node to the block in current_ir_block.
- *
- * @param arg A node producing a tuple.
- * @param *mode The mode of the value to project.
- * @param proj The position of the value in the tuple.
- */
-ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj);
-
-/** Constructor for a Filter node.
- *
- * Constructor for a Filter node. Adds the node to the block in current_ir_block.
- * Filter is a node with two views used to construct the interprocedural view.
- * In intraprocedural view its semantics are identical to the Proj node.
- * In interprocedural view the Filter performs the Phi operation on method
- * parameters or results. Other than a Phi a Filter node may not be removed
- * if it has only a single input.
- *
- * The constructor builds the Filter in intraprocedural view.
- *
- * @param *arg The tuple value to project from.
- * @param *mode The mode of the projected value.
- * @param proj The position in the tuple to project from.
- */
-ir_node *new_Filter (ir_node *arg, ir_mode *mode, long proj);
-
-/** Constructor for a defaultProj node.
- *
- * Represents the default control flow of a Switch-Cond node.
- * Adds the node to the block in current_ir_block.
- *
- * @param arg A node producing a tuple.
- * @param max_proj The end position of the value in the tuple.
- */
-ir_node *new_defaultProj (ir_node *arg, long max_proj);
-
-/** Constructor for a Tuple node.
- *
- * This is an auxiliary node to replace a node that returns a tuple
- * without changing the corresponding Proj nodes.
- * Adds the node to the block in current_ir_block.
- *
- * @param arity The number of tuple elements.
- * @param **in An array containing pointers to the nodes producing the tuple elements.
- */
-ir_node *new_Tuple (int arity, ir_node *in[]);
-
-/** Constructor for an Id node.
- *
- * This is an auxiliary node to replace a node that returns a single
- * value. Adds the node to the block in current_ir_block.
- *
- * @param *val The operand to Id.
- * @param *mode The mode of *val.
- */
-ir_node *new_Id (ir_node *val, ir_mode *mode);
-
-/** Constructor for a Bad node.
- *
- * Returns the unique Bad node of the graph. The same as
- * get_irg_bad().
- */
-ir_node *new_Bad (void);
-
-/** Constructor for a Confirm node.
- *
- * Specifies constraints for a value. To support dataflow analyses.
- * Adds the node to the block in current_ir_block.
- *
- * Example: If the value never exceeds '100' this is expressed by placing a
- * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
- *
- * @param *val The value we express a constraint for
- * @param *bound The value to compare against. Must be a firm node, typically a constant.
- * @param cmp The compare operation.
- */
-ir_node *new_Confirm (ir_node *val, ir_node *bound, pn_Cmp cmp);
-
-/** Constructor for an Unknown node.
- *
- * Represents an arbitrary value. Places the node in
- * the start block.
- *
- * @param *m The mode of the unknown value.
- */
-ir_node *new_Unknown(ir_mode *m);
-
-/** Constructor for a NoMem node.
- *
- * Returns the unique NoMem node of the graph. The same as
- * get_irg_no_mem().
- */
-ir_node *new_NoMem (void);
-
-/** Constructor for a Mux node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *sel The ir_node that calculates the boolean select.
- * @param *ir_true The ir_node that calculates the true result.
- * @param *ir_false The ir_node that calculates the false result.
- * @param *mode The mode of the node (and it_true and ir_false).
- */
-ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
-
-/** Constructor for a Psi node.
- *
- * @param *arity The arity of the conditions
- * @param *conds The array of mode_b conditions, length must be equal arity
- * @param *vals The array of mode values, length must be equal arity + 1
- * @param *mode The mode of the node (must be the mode of all vals).
- */
-ir_node *new_Psi (int arity, ir_node *conds[], ir_node *vals[], ir_mode *mode);
-
-/** Constructor for a CopyB node.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *store The current memory
- * @param *dst The ir_node that represents the destination address.
- * @param *src The ir_node that represents the source address.
- * @param *data_type The type of the copied data
- */
-ir_node *new_CopyB(ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
-
-/** Constructor for a InstOf node.
- *
- * A High-Level Type check.
- *
- * @param *store The memory in which the object the entity should be selected
- * from is allocated.
- * @param *objptr A pointer to a object of a class type.
- * @param *type The type of which objptr must be.
- */
-ir_node *new_InstOf (ir_node *store, ir_node *objptr, ir_type *type);
-
-/**Constructor for a Raise node.
- *
- * A High-Level Exception throw.
- *
- * @param *store The current memory.
- * @param *obj A pointer to the Except variable.
- */
-ir_node *new_Raise (ir_node *store, ir_node *obj);
-
-/** Constructor for a Bound node.
- *
- * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
- *
- * Adds the node to the block in current_ir_block.
- *
- * @param *store The current memory
- * @param *idx The ir_node that represents an index.
- * @param *lower The ir_node that represents the lower bound for the index.
- * @param *upper The ir_node that represents the upper bound for the index.
- */
-ir_node *new_Bound (ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
-
-/** Constructor for a Pin node.
- *
- * @param *node The node which value should be pinned.
- */
-ir_node *new_Pin (ir_node *node);
-
-/** Constructor for an ASM pseudo node.
- *
- * @param arity The number of data inputs to the node.
- * @param *in The array of length arity of data inputs.
- * @param *inputs The array of length arity of input constraints.
- * @param n_outs The number of data outputs to the node.
- * @param *outputs The array of length n_outs of output constraints.
- * @param n_clobber The number of clobbered registers.
- * @param *clobber The array of length n_clobber of clobbered registers.
- * @param *asm_text The assembler text.
- */
-ir_node *new_ASM(int arity, ir_node *in[], ir_asm_constraint *inputs,
- int n_outs, ir_asm_constraint *outputs,
- int n_clobber, ident *clobber[], ident *asm_text);
-
-/*---------------------------------------------------------------------*/
-/* The comfortable interface. */
-/* Supports automatic Phi node construction. */
-/* All routines of the block oriented interface except new_Block are */
-/* needed also. */
-/*---------------------------------------------------------------------*/
-
-/** Create an immature Block.
- *
- * An immature Block has an unknown number of predecessors. Predecessors
- * can be added with add_immBlock_pred(). Once all predecessors are
- * added the block must be matured.
- *
- * Adds the block to the graph in current_ir_graph. Does set
- * current_block. Can be used with automatic Phi node construction.
- * This constructor can only be used if the graph is in
- * state_building.
- */
-ir_node *new_d_immBlock(dbg_info *db);
-ir_node *new_immBlock(void);
-
-/** Create an immature PartBlock.
- *
- * An immature block has only one Block or PartBlock predecessor.
- * A PartBlock forms together with one BLock and possibly other
- * PartBlocks a MacroBlock.
- *
- * Adds the PartBlock to the graph in current_ir_graph. Does set
- * current_block. Can be used with automatic Phi node construction.
- * This constructor can only be used if the graph is in
- * state_building.
- */
-ir_node *new_d_immPartBlock(dbg_info *db, ir_node *pred_jmp);
-ir_node *new_immPartBlock(ir_node *pred_jmp);
-
-/** Add a control flow edge to an immature block. */
-void add_immBlock_pred(ir_node *immblock, ir_node *jmp);
-
-/** Finalize a Block node, when all control flows are known. */
-void mature_immBlock(ir_node *block);
-#define mature_cur_block() mature_immBlock(get_cur_block());
-
-
-/** Get the current value of a local variable.
- *
- * Use this function to obtain the last definition of the local variable
- * associated with pos. Pos may not exceed the value passed as n_loc
- * to new_ir_graph. This call automatically inserts Phi nodes.
- *
- * @param *db A pointer for debug information.
- * @param pos The position/id of the local variable.
- * @param *mode The mode of the value to get.
- */
-ir_node *get_d_value(dbg_info *db, int pos, ir_mode *mode);
-ir_node *get_value(int pos, ir_mode *mode);
-
-/** Remark a new definition of a variable.
- *
- * Use this function to remember a new definition of the value
- * associated with pos. Pos may not exceed the value passed as n_loc
- * to new_ir_graph. This call is needed to automatically inserts Phi
- * nodes.
- *
- * @param pos The position/id of the local variable.
- * @param *value The new value written to the local variable.
- */
-void set_value(int pos, ir_node *value);
-
-/** Find the value number for a node in the current block.
- *
- * This function searches all values in the current block for
- * a given value and returns its value number if it was found, else
- * -1.
- * Note that this does not mean that the value does not exists,
- * it's just not equal the node (for instance behind a Phi/Confirm ...)
- *
- * @param *value The value to find.
- */
-int find_value(ir_node *value);
-
-/** Get the current memory state.
- *
- * Use this function to obtain the last definition of the memory
- * state. This call automatically inserts Phi nodes for the memory
- * state value.
- */
-ir_node *get_store(void);
-
-/** Remark a new definition of the memory state.
- *
- * Use this function to remember a new definition of the memory state.
- * This call is needed to automatically inserts Phi nodes.
- *
- * @param *store The new memory state.
- */
-void set_store(ir_node *store);
-
-/** keep this node alive even if End is not control-reachable from it
- *
- * @param ka The node to keep alive.
- */
-void keep_alive(ir_node *ka);
-
-/** Returns the frame type of the current graph */
-ir_type *get_cur_frame_type(void);
-
-
-/* --- initialize and finalize ir construction --- */
-
-/** Puts the graph into state "phase_high" */
-#define irg_finalize_cons(irg) set_irg_phase_state(irg, phase_high)
-
-/** Puts the program and all graphs into state phase_high.
- *
- * This also remarks, the construction of types is finished,
- * e.g., that no more subtypes will be added. */
-void irp_finalize_cons(void);
-
-/* --- Initialization --- */
-
-/**
- * This function is called, whenever a local variable is used before definition
- *
- * @param irg the IR graph on which this happens
- * @param mode the mode of the local var
- * @param pos position chosen be the frontend for this variable (n_loc)
- *
- * @return a firm node of mode @p mode that initializes the var at position pos
- *
- * @note
- * Do not return NULL!
- * If this function is not set, FIRM will create a const node with tarval BAD.
- * Use set_irg_loc_description()/get_irg_loc_description() to assign additional
- * informations to local variables.
- */
-typedef ir_node *uninitialized_local_variable_func_t(ir_graph *irg, ir_mode *mode, int pos);
-
-#endif
#include "irdump_t.h"
#include "irgwalk.h"
-#include "typewalk.h"
#include "tv_t.h"
-#include "type_or_entity.h"
#include "irouts.h"
#include "irdom.h"
#include "irloop_t.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Write vcg representation of firm to file.
- * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Hubert Schmidt
- * @version $Id$
- * @summary
- * Dump routines for the ir graph and all type information.
- *
- * The dump format of most functions is vcg. This is a text based graph
- * representation. Some use the original format,
- * but most generate an extended format that is only read by some special
- * versions of xvcg or by the comercialized version now calles aiSee.
- * A test version of aiSee is available at
- * http://www.absint.de/aisee/download/index.htm.
- *
- * We have developed an own advanced viewer called ycomp:
- * http://www.info.uni-karlsruhe.de/software.php/id=6&lang=en
- *
- * Most routines use the name of the passed entity as the name of the
- * file dumped to.
- */
-#ifndef FIRM_IR_IRDUMP_H
-#define FIRM_IR_IRDUMP_H
-
-#include "irnode.h"
-#include "irgraph.h"
-#include "irloop.h"
-
-/**
- * Names of the 32 supported colors
- */
-typedef enum {
- ird_color_default = -1,
- ird_color_white = 0,
- ird_color_blue = 1,
- ird_color_red = 2,
- ird_color_green = 3,
- ird_color_yellow = 4,
- ird_color_magenta = 5,
- ird_color_cyan = 6,
- ird_color_darkgray = 7,
- ird_color_darkblue = 8,
- ird_color_darkred = 9,
- ird_color_darkgreen = 10,
- ird_color_darkyellow = 11,
- ird_color_darkmagenta = 12,
- ird_color_darkcyan = 13,
- ird_color_gold = 14,
- ird_color_lightgray = 15,
- ird_color_lightblue = 16,
- ird_color_lightred = 17,
- ird_color_lightgreen = 18,
- ird_color_lightyellow = 19,
- ird_color_lightmagenta = 20,
- ird_color_lightcyan = 21,
- ird_color_lilac = 22,
- ird_color_turquoise = 23,
- ird_color_aquamarine = 24,
- ird_color_khaki = 25,
- ird_color_purple = 26,
- ird_color_yellowgreen = 27,
- ird_color_pink = 28,
- ird_color_orange = 29,
- ird_color_orchid = 30,
- ird_color_black = 31
-} dumper_colors;
-
-/**
- * Edge kinds
- */
-typedef enum {
- data_edge = 0x01, /**< a data edge between two basic blocks */
- block_edge = 0x02, /**< an edge from a node to its basic block */
- cf_edge = 0x03, /**< regularly control flow edge */
- exc_cf_edge = 0x04, /**< exceptional control flow edge */
- mem_edge = 0x05, /**< memory edge */
- dominator_edge = 0x06, /**< dominator edge */
- node2type_edge = 0x07, /**< an edge from an IR node to a type */
-
- ent_type_edge = 0x11, /**< an edge from an entity to its type */
- ent_own_edge = 0x12, /**< an edge from an entity to its owner type */
- ent_overwrites_edge = 0x13, /**< an edge from an entity to the entity it overwrites */
- ent_value_edge = 0x14, /**< an edge from an entity to its value entity */
- ent_corr_edge = 0x15, /**< an edge from an entity to the member entity its initializes */
-
- meth_par_edge = 0x21, /**< an edge from a method type to one of its parameter types */
- meth_res_edge = 0x22, /**< an edge from a method type to one of its result types */
- type_super_edge = 0x23, /**< an edge from a class type to its super/basis type */
- union_edge = 0x24, /**< an edge from a union type to its member types */
- ptr_pts_to_edge = 0x25, /**< an edge from a pointer type to its points-to type */
- arr_elt_type_edge = 0x26, /**< an edge from an array type to its element type */
- arr_ent_edge = 0x27, /**< an edge from a array type to its element entity */
- type_member_edge = 0x28, /**< an edge from a compound type to its member entities */
-
- /* additional flags */
- intra_edge = 0, /**< intra edge flag: edge do not cross basic block boundaries */
- inter_edge = 0x40, /**< inter edge flag: edge cross basic block boundaries */
- back_edge = 0x80 /**< backwards edge flag */
-} edge_kind;
-
-/* **************************************************************************** */
-/* GRAPH DUMPERS */
-/* **************************************************************************** */
-
-/**
- * This hook is called to insert some special nodes into dumped graph
- */
-typedef int (*DUMP_IR_GRAPH_FUNC)(FILE *F, ir_graph *irg);
-/**
- * This hook is called to dump the vcg attributes of a node to a file.
- * If this function returns zero, the default attributes are added, else
- * removed.
- */
-typedef int (*DUMP_NODE_VCGATTR_FUNC)(FILE *F, ir_node *node, ir_node *local);
-/**
- * This hook is called to dump the vcg attributes of an edge to a file.
- * If this function returns zero, the default attributes are added, else
- * removed.
- */
-typedef int (*DUMP_EDGE_VCGATTR_FUNC)(FILE *F, ir_node *node, int to);
-
-/** Set the ir graph dump hook. */
-void set_dump_ir_graph_hook(DUMP_IR_GRAPH_FUNC hook);
-/** Set the node_vcgattr hook. */
-void set_dump_node_vcgattr_hook(DUMP_NODE_VCGATTR_FUNC hook);
-/** Set the edge_vcgattr hook. */
-void set_dump_edge_vcgattr_hook(DUMP_EDGE_VCGATTR_FUNC hook);
-
-typedef int (*DUMP_NODE_EDGE_FUNC)(FILE *f, ir_node *node);
-
-/**
- * Set the hook to be called to dump additional edges to a node.
- * @param func The hook to be called.
- */
-void set_dump_node_edge_hook(DUMP_NODE_EDGE_FUNC func);
-
-/**
- * Get the additional edge dump hook.
- * @return The current additional edge dump hook.]
- */
-DUMP_NODE_EDGE_FUNC get_dump_node_edge_hook(void);
-
-/**
- * Set the hook to be called to dump additional edges to a block.
- * @param func The hook to be called.
- */
-void set_dump_block_edge_hook(DUMP_NODE_EDGE_FUNC func);
-
-/**
- * Get the additional block edge dump hook.
- * @return The current additional block edge dump hook.
- */
-DUMP_NODE_EDGE_FUNC get_dump_block_edge_hook(void);
-
-/** Dump a firm graph.
- *
- * @param irg The firm graph to be dumped.
- * @param suffix A suffix for the file name.
- *
- * @return
- * A file containing the firm graph in vcg format.
- *
- * Dumps all Firm nodes of a single graph for a single procedure in
- * standard xvcg format. Dumps the graph to a file. The file name
- * is constructed from the name of the entity describing the
- * procedure (irg->entity) and the ending -pure<-ip>.vcg. Eventually
- * overwrites existing files. Visits all nodes in
- * interprocedural_view.
- *
- * @see turn_off_edge_labels()
- */
-void dump_ir_graph (ir_graph *irg, const char *suffix);
-
-/** Dump a firm graph without explicit block nodes.
- *
- * @param irg The firm graph to be dumped.
- * @param suffix A suffix for the file name.
- *
- * @return
- * A file containing the firm graph in vcg format.
- *
- * Dumps all Firm nodes of a single graph for a single procedure in
- * extended xvcg format.
- * Dumps the graph to a file. The file name is constructed from the
- * name of the entity describing the procedure (irg->entity) and the
- * ending <-ip>.vcg. Eventually overwrites existing files. Dumps several
- * procedures in boxes if interprocedural_view.
- *
- * @see turn_off_edge_labels()
- */
-void dump_ir_block_graph (ir_graph *irg, const char *suffix);
-
-/** Dump a firm graph without explicit block nodes but grouped in extended blocks.
- *
- * @param irg The firm graph to be dumped.
- *
- * @return
- * A file containing the firm graph in vcg format.
- *
- * Dumps all Firm nodes of a single graph for a single procedure in
- * extended xvcg format.
- * Dumps the graph to a file. The file name is constructed from the
- * name of the entity describing the procedure (irg->entity) and the
- * ending <-ip>.vcg. Eventually overwrites existing files. Dumps several
- * procedures in boxes if interprocedural_view.
- *
- * @see turn_off_edge_labels()
- */
-void dump_ir_extblock_graph (ir_graph *irg, const char *suffix);
-
-/** Dumps all graphs in interprocedural view to a file named All_graphs<suffix>.vcg.
- *
- * @param suffix A suffix for the file name.
- */
-void dump_all_cg_block_graph(const char *suffix);
-
-/** Dumps a firm graph and all the type information needed for Calls,
- * Sels, ... in this graph.
- *
- * @param irg The firm graph to be dumped with its type information.
- * @param suffix A suffix for the file name.
- *
- * @return
- * A file containing the firm graph and the type information of the firm graph in vcg format.
- *
- * Dumps the graph to a file. The file name is constructed from the
- * name of the entity describing the procedure (irg->entity) and the
- * ending -all.vcg. Eventually overwrites existing files.
- *
- * @see turn_off_edge_labels()
- */
-void dump_ir_graph_w_types (ir_graph *irg, const char *suffix);
-
-/** Dumps a firm graph and all the type information needed for Calls,
- * Sels, ... in this graph.
- *
- * @param irg The firm graph to be dumped with its type information.
- * @param suffix A suffix for the file name.
- *
- * @return
- * A file containing the firm graph and the type information of the firm graph in vcg format.
- *
- * The graph is in blocked format.
- * Dumps the graph to a file. The file name is constructed from the
- * name of the entity describing the procedure (irg->entity) and the
- * ending -all.vcg. Eventually overwrites existing files.
- *
- * @see turn_off_edge_labels()
- */
-void dump_ir_block_graph_w_types (ir_graph *irg, const char *suffix);
-
-/** The type of a dump function that is called for each graph.
- *
- * @param irg current visited graph
- * @param suffix A suffix for the file name.
- */
-typedef void dump_graph_func(ir_graph *irg, const char *suffix);
-
-/**
- * A walker that calls a dumper for each graph.
- *
- * @param dump_graph The dumper to be used for dumping.
- * @param suffix A suffix for the file name.
- *
- * @return
- * Whatever the dumper creates.
- *
- * Walks over all firm graphs and calls a dumper for each graph.
- * The following dumpers can be passed as arguments:
- * - dump_ir_graph()
- * - dump_ir_block_graph()
- * - dump_cfg()
- * - dump_type_graph()
- * - dump_ir_graph_w_types()
- *
- * @see turn_off_edge_labels()
- */
-void dump_all_ir_graphs (dump_graph_func *dump_graph, const char *suffix);
-
-
-/**
- * Dump the control flow graph of a procedure.
- *
- * @param irg The firm graph whose CFG shall be dumped.
- * @param suffix A suffix for the file name.
- *
- * @return
- * A file containing the CFG in vcg format.
- *
- * Dumps the control flow graph of a procedure in standard xvcg format.
- * Dumps the graph to a file. The file name is constructed from the
- * name of the entity describing the procedure (irg->entity) and the
- * ending -cfg.vcg. Eventually overwrites existing files.
- *
- * @see turn_off_edge_labels()
- */
-void dump_cfg (ir_graph *irg, const char *suffix);
-
-/**
- * Dump a node and its predecessors forming a subgraph to a vcg file.
- *
- * @param root The node serving as root for the subgraph.
- * @param depth Dump nodes on paths starting at root with length depth.
- * @param suffix A suffix for the file name.
- *
- * Dumps the graph to a file. The file name is constructed from the
- * name of the entity describing the procedure the passed node is
- * in, suffix and the ending -subg_<nr>.vcg. nr is a unique number
- * for each graph dumped. Eventually overwrites existing files.
- *
- * @return
- * A file containing the subgraph in vcg format.
- */
-void dump_subgraph (ir_node *root, int depth, const char *suffix);
-
-/* **************************************************************************** */
-/* CALLGRAPH DUMPERS */
-/* **************************************************************************** */
-
-
-/** Dump the call graph.
- *
- * Dumps the callgraph to a file "Callgraph"<suffix>".vcg".
- *
- * @param suffix A suffix for the file name.
- *
- * @see dump_callgraph_loop_tree(const char *suffix)
- */
-void dump_callgraph(const char *suffix);
-
-/* **************************************************************************** */
-/* TYPEGRAPH DUMPERS */
-/* **************************************************************************** */
-
-/**
- * Dumps all the type information needed for Calls, Sels, ... in this graph.
- * Does not dump the graph!
- *
- * @param irg The firm graph whose type information is to be dumped.
- * @param suffix A suffix for the file name.
- *
- * @return
- * A file containing the type information of the firm graph in vcg format.
- *
- * Dumps this graph to a file. The file name is constructed from the
- * name of the entity describing the procedure (irg->entity) and the
- * ending -type.vcg. Eventually overwrites existing files.
- *
- * @see turn_off_edge_labels()
- */
-void dump_type_graph (ir_graph *irg, const char *suffix);
-
-/**
- * Dumps all type information.
- *
- * @param suffix A suffix for the file name.
- *
- * @return
- * A file containing all type information for the program in standard
- * vcg format.
- *
- * Dumps all type information that is somehow reachable in standard vcg
- * format.
- * Dumps the graph to a file named All_types.vcg.
- *
- * @see turn_off_edge_labels()
- */
-void dump_all_types (const char *suffix);
-
-/**
- * Dumps the class hierarchy with or without entities.
- *
- * @param entities Flag whether to dump the entities.
- * @param suffix A suffix for the file name.
- *
- * @return
- * A file containing the class hierarchy tree for the program in standard
- * vcg format.
- *
- * Does not dump the global type.
- * Dumps a node for all classes and the sub/supertype relations. If
- * entities is set to true also dumps the entities of classes, but without
- * any additional information as the entities type. The overwrites relation
- * is dumped along with the entities.
- * Dumps to a file class_hierarchy.vcg
- */
-void dump_class_hierarchy (int entities, const char *suffix);
-
-/* **************************************************************************** */
-/* LOOPTREE DUMPERS */
-/* **************************************************************************** */
-
-/**
- * Dump a standalone loop tree, which contains the loop nodes and the firm nodes
- * belonging to one loop packed together in one subgraph. Dumps to file
- * <name of irg><suffix>-looptree.vcg
- * Turns on edge labels by default.
- *
- * Implementing this dumper was stimulated by Florian Liekwegs similar dumper.
- *
- * @param irg Dump the loop tree for this graph.
- * @param suffix A suffix for the file name.
- */
-void dump_loop_tree(ir_graph *irg, const char *suffix);
-
-/** Dumps the firm nodes in the sub-loop-tree of loop to a graph.
- *
- * Dumps the loop nodes if dump_loop_information() is set.
- * The name of the file is loop_<loop_nr><suffix>.vcg.
- *
- * @param l Dump the loop tree for this loop.
- * @param suffix A suffix for the file name.
- */
-void dump_loop (ir_loop *l, const char *suffix);
-
-/** Dumps the loop tree over the call graph.
- *
- * See for yourself what you can use this for.
- * The filename is "Callgraph_looptree<suffix>.vcg".
- *
- * @param suffix A suffix for the file name.
- */
-void dump_callgraph_loop_tree(const char *suffix);
-
-
-/* **************************************************************************** */
-/* TEXT DUMPERS */
-/* **************************************************************************** */
-
-
-/** Write the irnode and all its attributes to the file passed.
- * */
-int dump_irnode_to_file (FILE *f, ir_node *n);
-
-/** Write the irnode and all its attributes to stdout.
- * */
-void dump_irnode (ir_node *n);
-
-/** Write the graph and all its attributes to the file passed.
- * Does not write the nodes.
- * */
-void dump_graph_to_file(FILE *F, ir_graph *irg);
-
-/** Write the graph and all its attributes to stdout.
- * Does not write the nodes.
- * */
-void dump_graph(ir_graph *g);
-
-
-/** Dump graph information as text.
- *
- * Often graphs are unhandy in their vcg representation. The text
- * dumper represents the information for the firm nodes more compact,
- * but the relations between the nodes only implicitly.
- *
- * The file name is the graph name (get_entity_name()), appended by
- * <suffix>.txt.
- */
-void dump_graph_as_text(ir_graph *irg, const char *suffix);
-
-
-/** Verbosity for text dumpers */
-typedef enum {
- dump_verbosity_onlynames = 0x00000001, /**< only dump names. turns off all other
- flags up to 0x00010000. */
- dump_verbosity_fields = 0x00000002, /**< dump types and fields (like a type declaration) */
- dump_verbosity_methods = 0x00000004, /**< dump types and methods (like a type declaration) */
- dump_verbosity_nostatic = 0x00000040, /**< dump types and dynamic allocated fields (like a
- type declaration). This excludes methods and
- static, polymorphic fields. */
- dump_verbosity_typeattrs = 0x00000008, /**< dump all type attributes */
- dump_verbosity_entattrs = 0x00000010, /**< dump all entity attributes */
- dump_verbosity_entconsts = 0x00000020, /**< dump entity constants */
-
- dump_verbosity_accessStats = 0x00000100, /**< dump entity access statistics */
- dump_verbosity_csv = 0x00000200, /**< dump access statistics as comma separated list */
-
- dump_verbosity_noClassTypes = 0x00001000, /**< dump no class types */
- dump_verbosity_noStructTypes = 0x00002000, /**< dump no struct types */
- dump_verbosity_noUnionTypes = 0x00004000, /**< dump no union types */
- dump_verbosity_noArrayTypes = 0x00008000, /**< dump no array types */
- dump_verbosity_noPointerTypes = 0x00010000, /**< dump no pointer types */
- dump_verbosity_noMethodTypes = 0x00020000, /**< dump no method types */
- dump_verbosity_noPrimitiveTypes = 0x00040000, /**< dump no primitive types */
- dump_verbosity_noEnumerationTypes= 0x00080000, /**< dump no enumeration types */
-
- dump_verbosity_onlyClassTypes = 0x000FE000, /**< dump only class types */
- dump_verbosity_onlyStructTypes = 0x000FD000, /**< dump only struct types */
- dump_verbosity_onlyUnionTypes = 0x000FB000, /**< dump only union types */
- dump_verbosity_onlyArrayTypes = 0x000F7000, /**< dump only array types */
- dump_verbosity_onlyPointerTypes = 0x000EF000, /**< dump only pointer types */
- dump_verbosity_onlyMethodTypes = 0x000DF000, /**< dump only method types */
- dump_verbosity_onlyPrimitiveTypes = 0x000BF000, /**< dump only primitive types */
- dump_verbosity_onlyEnumerationTypes=0x0007F000, /**< dump only enumeration types */
-
- dump_verbosity_max = 0x4FF00FBE /**< turn on all verbosity.
- Do not turn on negative flags!
- @@@ Because of a bug in gcc 3.2 we can not set the
- first two bits. */
-} dump_verbosity;
-
-
-/** Write the entity and all its attributes to the passed file.
- * */
-void dump_entity_to_file (FILE *F, ir_entity *ent, unsigned verbosity);
-
-/** Write the entity and all its attributes to the stdout.
- *
- * Calls dump_entity_to_file(). */
-void dump_entity (ir_entity *ent);
-
-/** Write the type and all its attributes to the file passed.
- * */
-void dump_type_to_file (FILE *f, ir_type *tp, dump_verbosity verbosity);
-
-/** Write the type and all its attributes to stdout.
- * */
-void dump_type (ir_type *tp);
-
-
-/** Dump type information as text.
- *
- * Often type graphs are unhandy in their vcg representation. The text
- * dumper represents the information for a single type more compact, but
- * the relations between the types only implicitly.
- * Dumps only 'real' types, i.e., those in the type list. Does not dump
- * the global type nor frame types or the like.
- *
- * The file name is the program name (get_irp_name()), or 'TextTypes'
- * if the program name is not set, appended by <suffix>-types.txt.
- * For verbosity see the documentation of the verbosity flags above.
- */
-void dump_types_as_text(unsigned verbosity, const char *suffix);
-
-/** Dumps all global variables as text.
- *
- * @param suffix A suffix for the file name.
- *
- * Dumps a text representation of the entities in the global type.
- *
- * The file name is the program name (get_irp_name()), or 'TextTypes'
- * if the program name is not set, appended by <suffix>-globals.txt.
- * For verbosity see the documentation of the verbosity flags above.
- */
-void dump_globals_as_text(unsigned verbosity, const char *suffix);
-
-/* **************************************************************************** */
-/* FLAGS */
-/* **************************************************************************** */
-
-/** Set a prefix filter for output functions.
- *
- * All graph dumpers check this name. If the name is != "" and
- * not a prefix of the graph to be dumped, the dumper does not
- * dump the graph.
- *
- * @param name The prefix of the name (not the ld_name) of the method
- * entity to be dumped.
- */
-void only_dump_method_with_name(ident *name);
-
-/** Returns the prefix filter set with only_dump_method_with_name(). */
-ident *get_dump_file_filter_ident(void);
-
-/** Returns true if dump file filter is not set, or if it is a
- * prefix of name. */
-int is_filtered_dump_name(ident *name);
-
-/** Sets the vcg flag "display_edge_labels" to no.
- *
- * This is necessary as xvcg and aisee both fail to display graphs
- * with self-edges if these edges have labels.
- */
-void turn_off_edge_labels(void);
-
-/**
- * If set to non-zero constants will be replicated for every use. In non
- * blocked view edges from constant to block are skipped. Vcg then
- * layouts the graphs more compact, this makes them better readable.
- * The flag is automatically and temporarily set to false if other
- * edges are dumped, as outs, loop, ...
- * Default setting: false.
- */
-void dump_consts_local(int flag);
-
-/**
- * Returns 0 if dump_out_edge_flag or dump_loop_information_flag
- * are set, else returns dump_const_local_flag.
- */
-int get_opt_dump_const_local(void);
-
-/** Turns off dumping the values of constant entities. Makes type graphs
- * better readable.
- */
-void dump_constant_entity_values(int flag);
-
-/** Turns on dumping the edges from the End node to nodes to be kept
- * alive.
- */
-void dump_keepalive_edges(int flag);
-int get_opt_dump_keepalive_edges(void);
-
-/** Turns on dumping the out edges starting from the Start block in
- * dump_ir_graph.
- *
- * To test the consistency of the out data structure.
- */
-void dump_out_edges(int flag);
-
-/** If this flag is set the dumper dumps edges to immediate dominator in cfg.
- */
-void dump_dominator_information(int flag);
-
-/** If this flag is set the dumper dumps loop nodes and edges from
- * these nodes to the contained ir nodes.
- *
- * If the loops are interprocedural nodes can be missing.
- */
-void dump_loop_information(int flag);
-
-/** If set and backedge info is computed, backedges are dumped dashed
- * and as vcg 'backedge' construct.
- *
- * Default: set.
- */
-void dump_backedge_information(int flag);
-
-/** Dump the information of type field specified in ana/irtypeinfo.h.
- *
- * If the flag is set, the type name is output in [] in the node label,
- * else it is output as info.
- */
-void set_opt_dump_analysed_type_info(int flag);
-
-/** Write the address of a node into the vcg info.
- *
- * This is off per default for automatic comparisons of
- * vcg graphs -- these will differ in the pointer values!
- */
-void dump_pointer_values_to_info(int flag);
-
-/** Dumps ld_names of entities instead of there names.
- *
- * This option is on per default.
- */
-void dump_ld_names(int flag);
-
-/** Dumps all graph anchor nodes, even if they
- * are dead.
- *
- * This option is off per default.
- */
-void dump_all_anchors(int flag);
-
-/** A node info dumper callback. */
-typedef void (dump_node_info_cb_t)(void *data, FILE *f, const ir_node *n);
-
-/**
- * Adds a new node info dumper callback. It is possible to add an unlimited
- * number of callbacks. The callbacks are called at the end of the default
- * info dumper.
- *
- * @param cb the callback function to be called
- * @param data a context parameter
- *
- * @return A callback handle.
- *
- * @note This functionality is only available, if Firm hooks are enabled (default).
- */
-void *dump_add_node_info_callback(dump_node_info_cb_t *cb, void *data);
-
-/**
- * Remove a previously added info dumper callback.
- *
- * @param handle the callback handle returned from dump_add_node_info_callback()
- */
-void dump_remv_node_info_callback(void *handle);
-
-#endif
fclose (F);
}
+#ifdef EXTENDED_ACCESS_STATS
static int addr_is_alloc(ir_node *acc) {
ir_node *addr = NULL;
ir_opcode addr_op;
/* In addition, the alloc must be in the same loop. */
return 1;
}
+#endif
/** dumps something like:
*
}
if (verbosity & dump_verbosity_accessStats) {
-#if 0
+#ifdef EXTENDED_ACCESS_STATS
int n_acc = get_entity_n_accesses(ent);
int max_depth = 0;
int max_L_freq = -1;
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @breif Declares different kind of edges between nodes
- * @date 29.08.2006
- * @author Sebastian Hack
- */
-#ifndef FIRM_IR_IREDGEKINDS_H
-#define FIRM_IR_IREDGEKINDS_H
-
-/** Supported Edge kinds. */
-enum _ir_edge_kind_t {
- EDGE_KIND_NORMAL, /**< Normal data flow edges. */
- EDGE_KIND_BLOCK, /**< Block to Block control flow edges. */
- EDGE_KIND_DEP, /**< Dependency edges. */
- EDGE_KIND_LAST
-};
-
-typedef enum _ir_edge_kind_t ir_edge_kind_t;
-
-/*
- * It's ugly but we need this forward ref.
- */
-
-void edges_notify_edge_kind(ir_node *src, int pos, ir_node *tgt, ir_node *old_tgt, ir_edge_kind_t kind, ir_graph *irg);
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Public header for the automatically updating outs.
- * @author Sebastian Hack
- * @date 3.2.2005
- * @version $Id$
- */
-#ifndef FIRM_IR_IREDGES_H
-#define FIRM_IR_IREDGES_H
-
-#include "firm_types.h"
-#include "iredgekinds.h"
-
-#ifndef _IR_EDGE_TYPEDEF_
-#define _IR_EDGE_TYPEDEF_
-typedef struct _ir_edge_t ir_edge_t;
-#endif
-
-/**
- * Get the first edge pointing to some node.
- * @note There is no order on out edges. First in this context only
- * means, that you get some starting point into the list of edges.
- * @param irn The node.
- * @param kind The kind of the edge.
- * @return The first out edge that points to this node.
- */
-const ir_edge_t *get_irn_out_edge_first_kind(const ir_node *irn, ir_edge_kind_t kind);
-
-/**
- * Get the next edge in the out list of some node.
- * @param irn The node.
- * @param last The last out edge you have seen.
- * @return The next out edge in @p irn 's out list after @p last.
- */
-const ir_edge_t *get_irn_out_edge_next(const ir_node *irn, const ir_edge_t *last);
-
-/**
- * A convenience iteration macro over all out edges of a node.
- * @param irn The node.
- * @param kind The edge's kind.
- * @param edge An ir_edge_t pointer which shall be set to the current
- * edge.
- */
-#define foreach_out_edge_kind(irn, edge, kind) \
- for(edge = get_irn_out_edge_first_kind(irn, kind); edge; edge = get_irn_out_edge_next(irn, edge))
-
-/**
- * A convenience iteration macro over all out edges of a node, which is safe
- * against alteration of the current edge.
- *
- * @param irn The node.
- * @param edge An ir_edge_t pointer which shall be set to the current edge.
- * @param ne The next edge, enables alteration safe edge processing.
- */
-#define foreach_out_edge_kind_safe(irn, edge, ne, kind) \
- for((edge) = (get_irn_out_edge_first_kind(irn, kind)), (ne) = ((edge) ? (get_irn_out_edge_next(irn, edge)) : NULL); \
- edge; (edge) = (ne), (ne) = ((edge) ? (get_irn_out_edge_next(irn, edge)) : NULL))
-
-/**
- * Convenience macro for normal out edges.
- */
-#define foreach_out_edge(irn, edge) foreach_out_edge_kind(irn, edge, EDGE_KIND_NORMAL)
-
-/**
- * Convenience macro for normal out edges.
- */
-#define foreach_out_edge_safe(irn, edge, tmp) foreach_out_edge_kind_safe(irn, edge, tmp, EDGE_KIND_NORMAL)
-
-/**
- * A convenience iteration macro for all control flow edges.
- */
-#define foreach_block_succ(bl, edge) foreach_out_edge_kind(bl, edge, EDGE_KIND_BLOCK)
-
-/*
- * Get the source node of an edge.
- * @param edge The edge.
- * @return The source node of that edge.
- */
-ir_node *get_edge_src_irn(const ir_edge_t *edge);
-
-/**
- * Get the number of edges pointing to a node.
- * @param irn The node.
- * @return The number of edges pointing to this node.
- */
-int get_irn_n_edges(const ir_node *irn);
-
-/**
- * Get the position of an edge.
- * @param edge The edge.
- * @return The position in the in array of that edges source.
- */
-extern int get_edge_src_pos(const ir_edge_t *edge);
-
-/**
- * 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.
- * @return The corresponding edge object or NULL,
- * if no such edge exists.
- */
-const ir_edge_t *get_irn_edge_kind(ir_graph *irg, const ir_node *irn, int pos, ir_edge_kind_t kind);
-
-/**
- * Get the number of registered out edges for a specific kind.
- * @param irn The node.
- * @param kind The kind.
- */
-extern int get_irn_n_edges_kind(const ir_node *irn, ir_edge_kind_t kind);
-
-
-/**
- * Check, if the out edges are activated.
- * @param irg The graph.
- * @param kind The edge kind.
- * @return 1, if the edges are present for the given irg, 0 if not.
- */
-extern int edges_activated_kind(const ir_graph *irg, ir_edge_kind_t kind);
-
-/**
- * Activate the edges for an irg.
- * @param irg The graph to activate the edges for.
- * @param kind The edge kind.
- */
-extern void edges_activate_kind(ir_graph *irg, ir_edge_kind_t kind);
-
-/**
- * Deactivate the edges for an irg.
- * @param irg The graph.
- * @param kind The edge kind.
- */
-extern void edges_deactivate_kind(ir_graph *irg, ir_edge_kind_t kind);
-
-extern void edges_reroute_kind(ir_node *old, ir_node *nw, ir_edge_kind_t kind, ir_graph *irg);
-
-/**
- * Verifies the out edges of graph @p irg.
- * @return 1 if a problem was found, 0 otherwise
- */
-int edges_verify(ir_graph *irg);
-
-/**
-
- * Set edge verification flag.
-
- */
-void edges_init_dbg(int do_dbg);
-
-/************************************************************************/
-/* Begin Old Interface */
-/************************************************************************/
-
-const ir_edge_t *get_irn_edge(ir_graph *irg, const ir_node *src, int pos);
-
-#define edges_reroute(old, nw, irg) edges_reroute_kind(old, nw, EDGE_KIND_NORMAL, irg)
-#define edges_activated(irg) (edges_activated_kind(irg, EDGE_KIND_NORMAL) && edges_activated_kind(irg, EDGE_KIND_BLOCK))
-
-#ifndef get_irn_n_edges
-#define get_irn_n_edges(irn) get_irn_n_edges_kind(irn, EDGE_KIND_NORMAL)
-#endif
-
-#ifndef get_irn_out_edge_first
-#define get_irn_out_edge_first(irn) get_irn_out_edge_first_kind(irn, EDGE_KIND_NORMAL)
-#endif
-
-#ifndef get_block_succ_first
-#define get_block_succ_first(irn) get_irn_out_edge_first_kind(irn, EDGE_KIND_BLOCK)
-#endif
-
-#ifndef get_block_succ_next
-#define get_block_succ_next(irn, last) get_irn_out_edge_next(irn, last)
-#endif
-
-/**
-* Activate all the edges for an irg.
-* @param irg The graph to activate the edges for.
-*/
-extern void edges_activate(ir_graph *irg);
-
-/**
-* Deactivate all the edges for an irg.
-* @param irg The graph.
-*/
-extern void edges_deactivate(ir_graph *irg);
-
-extern int edges_assure(ir_graph *irg);
-
-extern void edges_node_deleted(ir_node *irn, ir_graph *irg);
-
-/**
-* Notify normal and block edges.
-*/
-extern void edges_notify_edge(ir_node *src, int pos, ir_node *tgt, ir_node *old_tgt, ir_graph *irg);
-
-void edges_reset_private_data(ir_graph *irg, int offset, size_t size);
-
-/************************************************************************/
-/* End Old Interface */
-/************************************************************************/
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Flags to control optimizations.
- * @author Christian Schaefer, Goetz Lindenmaier, Michael Beck
- * @version $Id$
- * @summary
- * Flags to customize the behavior of libfirm.
- *
- * There are the following groups of flags:
- * 1. Optimization flags.
- * a) There is a flag, 'optimize' to turn on/off all optimizations.
- * b) There are flags for each individual optimization. Some flags turns
- * transformations in several algorithms on/off.
- * 2. Normalization flags.
- * These flags steer transformations of the ir that improve it, as removing
- * dump Phi nodes (one predecessor, all predecessors are equal ...), Ids, Tuples ...
- * 3. Verbosity flags.
- * a) Flags to steer the level of the information.
- * b) Flags to steer in which phase information should be dumped.
- * 4. Verification flag
- * This one controls the behavior of node and type verifications
- */
-#ifndef FIRM_IR_IRFLAG_H
-#define FIRM_IR_IRFLAG_H
-
-#include "firm_types.h"
-
-/**
- * A container type to load/restore all optimizations
- */
-typedef unsigned optimization_state_t;
-
-/**
- * This function enables/disables optimizations globally.
- *
- * If optimize == 0 no optimizations are performed at all.
- * Default: optimize == 1.
- */
-void set_optimize (int value);
-int get_optimize(void);
-
-/** This function enables/disables output of information about phases and
- * controls the verbosity level.
- *
- * 0: no output at all.
- * 1: very short output
- * >>1: very verbose output.
- */
-void set_firm_verbosity (int value);
-int get_firm_verbosity (void);
-
-/** Enables/Disables constant folding optimization.
- *
- * If opt_constant_folding == 1 perform
- * - constant expression evaluation (2 + 5 ==> 7, 3 < 2 ==> false)
- * - algebraic simplification (a * 0 ==> 0, a or a ==> a)
- * - simplification of tests ( !(a < b) ==> (a >= b))
- * Default: opt_constant_folding == 1.
- */
-void set_opt_constant_folding (int value);
-
-/** Enables/Disables loop unrolling.
- *
- * If opt_loop_unrolling == 1 perform loop_unrolling.
- * See loop_unrolling.h.
- *
- * Default: opt_loop_unrolling = 1;
- */
-void set_opt_loop_unrolling (int value);
-
-/** Enables/Disables output of information about loop unrolling.
- */
-void set_opt_loop_unrolling_verbose (int value);
-
-/** Enables/Disables removal of redundant Loads and Stores.
- *
- * - Remove Store that overwrites a just stored value (WAW).
- * - Remove Store if it stores a value just loaded (WAR with the same value).
- * - Remove Load that loads a value just saved (RAW with the same value).
- * - remove Load that loads a value already loaded (RAR)
- * - replace Load of constant values with constants (RC)
- */
-void set_opt_redundant_loadstore(int value);
-
-/** Enables/Disables common subexpression elimination.
- *
- * If opt_cse == 1 perform common subexpression elimination.
- * Default: opt_cse == 1.
- */
-void set_opt_cse (int value);
-
-/** Returns constant folding optimization setting. */
-int get_opt_cse(void);
-
-/** Enables/Disables global constant subexpression elimination.
- *
- * If opt_global_cse == 1 and opt_cse == 1 perform intra procedure
- * constant subexpression elimination for floating nodes. Intra
- * procedure cse gets the graph into state "floating". It is necessary
- * to run pre/code motion to get the graph back into state "op_pin_state_pinned".
- * right after a call to local_optimize with global cse turned on.
- * Default: opt_global_cse == 0.
- */
-void set_opt_global_cse (int value);
-
-/** Enables/Disables strength reduction.
- *
- * If opt_strength_red == 1 perform strength reduction.
- * See strenth_red.h.
- *
- * Default: opt_strength_red = 1;
- */
-void set_opt_strength_red (int value);
-
-/** Enables/Disables output of information about strength reduction.
- */
-void set_opt_strength_red_verbose (int value);
-
-/** Enables/Disables unreachable code elimination.
- *
- * If set, evaluate conditions of conditional branch and replace the
- * branch with a Jmp/Bad Tuple.
- *
- * If opt_unreachable_code == 1 replace nodes (except Block,
- * Phi and Tuple) with a Bad predecessor by the Bad node.
- * Default: opt_unreachable_code == 1.
- */
-void set_opt_unreachable_code(int value);
-
-/** Enables/Disables control flow optimizations.
- *
- * Performs Straightening, if simplifications and loop simplifications.
- * Sets all separate control flow flags (control_flow_straightening,
- * weak_simplification, strong_simplification and critical_edges).
- */
-void set_opt_control_flow(int value);
-
-/** Enables/Disables Straightening. */
-void set_opt_control_flow_straightening(int value);
-
-/** Enables/Disables if simplifications in local optimizations. */
-void set_opt_control_flow_weak_simplification(int value);
-
-/** Enables/Disables strong if and loop simplification (in optimize_cf). */
-void set_opt_control_flow_strong_simplification(int value);
-
-/** Enables/Disables reassociation.
- *
- * If opt_reassociation == 1 reassociation is performed.
- * Default: opt_reassociation == 1.
- */
-void set_opt_reassociation(int value);
-
-/** Enables/Disables dead node elimination.
- *
- * If opt_dead_node_elimination == 1 deallocate all dead nodes
- * by copying the firm graph.
- * Default: opt_dead_node_elimination == 1. */
-void set_opt_dead_node_elimination (int value);
-
-/** Enables/Disables dead method elimination.
- *
- * If opt_dead_method_elimination == 1 methods never called are
- * removed.
- * Default: opt_dead_method_elimination == 1.
- */
-void set_opt_dead_method_elimination (int value);
-void set_opt_dead_method_elimination_verbose (int value);
-
-/** Enable/Disables method inlining.
- *
- * If opt_inline == 1 the inlining transformation is performed.
- */
-void set_opt_inline (int value);
-
-/** Enable/Disable optimization of dynamic method dispatch.
- *
- * This flag enables/disables the optimization of dynamic method dispatch.
- * If the flag is turned on Sel nodes can be replaced by Const nodes representing
- * the address of a function.
- */
-void set_opt_dyn_meth_dispatch (int value);
-int get_opt_dyn_meth_dispatch (void);
-
-/** Enable/Disable type optimization of cast nodes.
- *
- * Controls the optimizations in tropt.h. Default: on.
- */
-void set_opt_optimize_class_casts (int value);
-void set_opt_optimize_class_casts_verbose (int value);
-
-/** Restricts the behavior of cast optimization.
- *
- * If set, downcast are not optimized if they might be
- * illegal as in (Super)(Sub) (new Super()). Default:
- * 0 == not suppressed.
- */
-void set_opt_suppress_downcast_optimization(int value);
-int get_opt_suppress_downcast_optimization(void);
-
-/** Enable/Disable optimization of tail-recursion calls.
- *
- * This flag enables/disables the optimization tail-recursion call.
- * If the flag is turned on tail-recursion calls are optimized into loops.
- */
-void set_opt_tail_recursion(int value);
-void set_opt_tail_recursion_verbose(int value);
-
-/** Enable/Disable floating of fragile ops.
- *
- * This flags enables/disables the floating of fragile operations.
- * If this flag is on, fragile operations which are known to NOT raise
- * an exception can be place to other basic blocks.
- * Otherwise they remain in the block they were created.
- */
-void set_opt_fragile_ops(int value);
-
-/**
- * Enable/Disable if conversion.
- *
- * If conversion tries to turn Conds into Mux nodes to eliminate
- * control flow.
- */
-void set_opt_if_conversion(int value);
-
-/**
- * Enable/Disable function call optimization.
- *
- * Function call optimization detects const and pure functions and
- * allows the CSE of Call nodes. A const function is one that
- * do only evaluate it's parameters and did not read or write memory
- * to compute its results. Pure functions are allowed to read global memory.
- */
-void set_opt_function_call(int value);
-
-/**
- * Enable/Disable Confirm node removal during local optimization.
- */
-void set_opt_remove_confirm(int value);
-
-/**
- * Enable/Disable scalar replacement optimization.
- */
-void set_opt_scalar_replacement(int value);
-void set_opt_scalar_replacement_verbose(int value);
-
-/**
- * Enable/Disable Null exception in Load and Store nodes only.
- *
- * If enabled, only Null pointer exception can occur at Load and
- * store nodes. If it can be proved that the address input of these
- * nodes is non-null, the exception edge can safely be removed.
- * If disabled, other exceptions (like unaligned access, read-only memory,
- * etc.) can occur.
- *
- * This flag is enabled by default.
- */
-void set_opt_ldst_only_null_ptr_exceptions(int value);
-
-/**
- * Enable/Disable Selection based Null pointer check elimination.
- *
- * In languages, where all addresses are always Sel nodes, Null
- * pointers can only occur as input to Sel nodes.
- * If Null pointers are the only source for exceptions in Load and
- * Store nodes (as typical in high level languages), we can eliminate
- * exception edges from Load and Store when can prove that the Sel
- * nodes representing the Load/Store address have non-null inputs.
- * Enabling this flag enables this elimination.
- *
- * Enabling this flag is meaningless if ldst_non_null_exceptions is
- * enabled.
- *
- * This flags should be set for Java style languages.
- */
-void set_opt_sel_based_null_check_elim(int value);
-
-/**
- * Enable/Disable Automatic construction of Sync nodes during
- * Firm construction.
- *
- * If this flags is set, sequential non-volatile Loads are automatically
- * rearranged so that they can be executed in parallel by creating Sync nodes.
- *
- * This flags should be set for Java style languages.
- */
-void set_opt_auto_create_sync(int value);
-
-/** Enable/Disable normalizations of the firm representation.
- *
- * This flag guards transformations that normalize the Firm representation
- * as removing Ids and Tuples, useless Phis, replacing SymConst(id) by
- * Const(entity) and others.
- * The transformations guarded by this flag are not guarded by flag
- * "optimize".
- * Many algorithms operating on Firm can not deal with constructs in
- * the non-normalized representation.
- * default: ON
- *
- * @note ATTENTION: not all such transformations are guarded by a flag.
- */
-void set_opt_normalize (int value);
-
-/** Enable/Disable precise exception context.
- *
- * If enabled, all exceptions form a barrier for values, as in the
- * following example:
- *
- * @code
- * a = 1;
- * b = 3 / 0;
- * a = 2;
- * @endcode
- *
- * If precise exception handling is enabled, an exception handler see a == 1,
- * else it might see a == 2.
- * Enable this for languages with strict exception order like Java.
- */
-void set_opt_precise_exc_context(int value);
-
-/** Enable/Disable Alias analysis.
- *
- * If enabled, memory disambiguation by alias analysis is used.
- */
-void set_opt_alias_analysis(int value);
-
-/** Enable/Disable closed world assumption.
- *
- * If enabled, optimizations expect to know the "whole world", i.e. no
- * external types or callers exist.
- * This enables some powerful optimizations.
- */
-void set_opt_closed_world(int value);
-
-/**
- * Save the current optimization state.
- */
-void save_optimization_state(optimization_state_t *state);
-
-/**
- * Restore the current optimization state.
- */
-void restore_optimization_state(const optimization_state_t *state);
-
-/**
- * Switches ALL optimizations off.
- */
-void all_optimizations_off(void);
-
-/**
- * Possible verification modes.
- */
-typedef enum _firm_verification_t {
- FIRM_VERIFICATION_OFF = 0, /**< do not verify nodes at all */
- FIRM_VERIFICATION_ON = 1, /**< do node verification and assert on error in debug version */
- FIRM_VERIFICATION_REPORT = 2, /**< do node verification, but report to stderr only */
- FIRM_VERIFICATION_ERROR_ONLY = 3 /**< do node verification, but NEVER do assert nor report */
-} firm_verification_t;
-
-/** 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.
- */
-void do_node_verification(firm_verification_t mode);
-
-#endif
#include "irhooks.h"
#include "iredges_t.h"
#include "irtools.h"
+#include "error.h"
/**
* Turns a node into a "useless" Tuple. The Tuple just forms a tuple
block = is_Block(nw) ? nw : get_nodes_block(nw);
if (! block) {
- DDMN(old);
- DDMN(nw);
- assert(0 && "cannot find legal block for id");
+ panic("cannot find legal block for id");
}
}
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Support for ir graph modification.
- * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier
- * @version $Id$
- */
-#ifndef FIRM_IR_IRGMOD_H
-#define FIRM_IR_IRGMOD_H
-
-#include "firm_types.h"
-
-/** Exchanges two nodes by conserving edges leaving old (i.e.,
- pointers pointing to old). Turns the old node into an Id. */
-void exchange(ir_node *old, ir_node *nw);
-
-/** Turns a node into a "useless" Tuple.
- *
- * Turns a node into a "useless" Tuple. The Tuple node just forms a tuple
- * from several inputs. The predecessors of the tuple have to be
- * set by hand. The block predecessor automatically remains the same.
- * This is useful if a node returning a tuple is removed, but the Projs
- * extracting values from the tuple are not available.
- *
- * @param node The node to be turned into a tuple.
- * @param arity The number of values formed into a Tuple.
- */
-void turn_into_tuple(ir_node *node, int arity);
-
-/** Walks over the passed ir graph and collects all Phi nodes as a
- * list built with the link field in their corresponding block.
- * Further it collects all Proj nodes in a list of the node producing
- * the tuple. In case of nested tuples the Projs are collected in the
- * node producing the outermost Tuple.
- * All other link fields are cleared afterwards.
- */
-void collect_phiprojs(ir_graph *irg);
-
-/** Parts a block into two. This is useful to insert other blocks within a
- * given block.
- *
- * Adds a new block (new_block) in the control flow before the block
- * (old_block) of node. Moves node and its predecessors from old_block to
- * new_block. Moves all Projs that depend on moved nodes and are in old_block
- * to new_block. Moves all Phi nodes from old_block to new_block. To achieve
- * this the routine assumes that all Phi nodes are in a list (using the link
- * field) in the link field of old_block. Further it assumes that all Proj nodes
- * are accessible by the link field of the nodes producing the Tuple. This
- * can be established by collect_phiprojs(). part_block conserves this property.
- * Adds a Jmp node to new_block that jumps to old_block.
- * Assumes that node is contained in current_ir_graph. Sets current_block in
- * this ir_graph to new_block.
- *
- * @param node The node were to break the block
- */
-void part_block(ir_node *node);
-
-#endif /* FIRM_IR_IRGMOD_H */
#include "irgraph_t.h"
#include "irprog_t.h"
+#include "iroptimize.h"
#include "ircons.h"
#include "iropt_t.h"
-#include "cfopt.h"
#include "irgopt.h"
#include "irgmod.h"
#include "irgwalk.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Optimizations for a whole ir graph, i.e., a procedure.
- * @author Christian Schaefer, Goetz Lindenmaier, Sebastian Felis
- * @version $Id$
- */
-#ifndef FIRM_IR_IRGOPT_H
-#define FIRM_IR_IRGOPT_H
-
-#include "firm_types.h"
-
-/** Applies local optimizations (see iropt.h) to all nodes reachable from node n.
- *
- * @param n The node to be optimized.
- */
-void local_optimize_node(ir_node *n);
-
-/** Applies local optimizations (see iropt.h) to all nodes in the graph.
- *
- * @param irg The graph to be optimized.
- *
- * After applying local_optimize_graph() to a IR-graph, Bad nodes
- * only occure as predecessor of Block and Phi nodes.
- */
-void local_optimize_graph (ir_graph *irg);
-
-/** Applies local optimizations (see iropt.h) to all nodes in the graph.
- *
- * @param irg The graph to be optimized.
- *
- * After applying local_optimize_graph() to a IR-graph, Bad nodes
- * only occure as predecessor of Block and Phi nodes.
- *
- * This version used a fixpoint iteration.
- */
-void optimize_graph_df(ir_graph *irg);
-
-/** Performs dead node elimination by copying the ir graph to a new obstack.
- *
- * The major intention of this pass is to free memory occupied by
- * dead nodes and outdated analyzes information. Further this
- * function removes Bad predecessors from Blocks and the corresponding
- * inputs to Phi nodes. This opens optimization potential for other
- * optimizations. Further this phase reduces dead Block<->Jmp
- * self-cycles to Bad nodes.
- *
- * Dead_node_elimination is only performed if options `optimize' and
- * `opt_dead_node_elimination' are set. The graph may
- * not be in state phase_building. The outs datasturcture is freed,
- * the outs state set to outs_none. Backedge information is conserved.
- * Removes old attributes of nodes. Sets link field to NULL.
- * Callee information must be freed (irg_callee_info_none).
- *
- * @param irg The graph to be optimized.
- */
-void dead_node_elimination(ir_graph *irg);
-
-typedef struct _survive_dce_t survive_dce_t;
-
-/**
- * Make a new Survive DCE environment.
- */
-survive_dce_t *new_survive_dce(void);
-
-/**
- * Free a Survive DCE environment.
- */
-void free_survive_dce(survive_dce_t *sd);
-
-/**
- * Register a node pointer to be patched upon DCE.
- * When DCE occurs, the node pointer specified by @p place will be
- * patched to the new address of the node it is pointing to.
- *
- * @param sd The Survive DCE environment.
- * @param place The address of the node pointer.
- */
-void survive_dce_register_irn(survive_dce_t *sd, ir_node **place);
-
-/** Cleans the control flow from Bad predecessors.
- *
- * Removes Bad predecessors from Blocks and the corresponding
- * inputs to Phi nodes as in dead_node_elimination but without
- * copying the graph.
- *
- * Conserves loop information.
- *
- * @param irg The graph to be optimized.
- */
-void remove_bad_predecessors(ir_graph *irg);
-
-/** Inlines a method at the given call site.
- *
- * Removes the call node and splits the basic block the call node
- * belongs to. Inserts a copy of the called graph between these nodes.
- * Assumes that call is a Call node in current_ir_graph and that
- * the type in the Call nodes type attribute is the same as the
- * type of the called graph.
- * Further it assumes that all Phi nodes in a block of current_ir_graph
- * are assembled in a "link" list in the link field of the corresponding
- * block nodes. Further assumes that all Proj nodes are in a "link" list
- * in the nodes producing the tuple. (This is only an optical feature
- * for the graph.) Conserves this feature for the old
- * nodes of the graph. This precondition can be established by a call to
- * collect_phisprojs(), see irgmod.h.
- * As dead_node_elimination this function reduces dead Block<->Jmp
- * self-cycles to Bad nodes.
- *
- * Called_graph must be unequal to current_ir_graph. Will not inline
- * if they are equal.
- * Sets visited masterflag in current_ir_graph to the max of the flag in
- * current and called graph.
- * Assumes that both, the called and the calling graph are in state
- * "op_pin_state_pinned".
- * It is recommended to call local_optimize_graph() after inlining as this
- * function leaves a set of obscure Tuple nodes, e.g. a Proj-Tuple-Jmp
- * combination as control flow operation.
- *
- * @param call the call node that should be inlined
- * @param called_graph the IR-graph that is called at call
- *
- * @return zero if method could not be inlined (recursion for instance),
- * non-zero if all went ok
- */
-int inline_method(ir_node *call, ir_graph *called_graph);
-
-/** Inlines all small methods at call sites where the called address comes
- * from a SymConst node that references the entity representing the called
- * method.
- *
- * The size argument is a rough measure for the code size of the method:
- * Methods where the obstack containing the firm graph is smaller than
- * size are inlined. Further only a limited number of calls are inlined.
- * If the method contains more than 1024 inlineable calls none will be
- * inlined.
- * Inlining is only performed if flags `optimize' and `inlineing' are set.
- * The graph may not be in state phase_building.
- * It is recommended to call local_optimize_graph() after inlining as this
- * function leaves a set of obscure Tuple nodes, e.g. a Proj-Tuple-Jmp
- * combination as control flow operation.
- */
-void inline_small_irgs(ir_graph *irg, int size);
-
-
-/** Inlineing with a different heuristic than inline_small_irgs().
- *
- * Inlines leave functions. If inlinening creates new leave
- * function inlines these, too. (If g calls f, and f calls leave h,
- * h is first inlined in f and then f in g.)
- *
- * Then inlines all small functions (this is not recursive).
- *
- * For a heuristic this inlineing uses firm node counts. It does
- * not count auxiliary nodes as Proj, Tuple, End, Start, Id, Sync.
- * If the ignore_runtime flag is set, calls to functions marked with the
- * mtp_property_runtime property are ignored.
- *
- * @param maxsize Do not inline any calls if a method has more than
- * maxsize firm nodes. It may reach this limit by
- * inlineing.
- * @param leavesize Inline leave functions if they have less than leavesize
- * nodes.
- * @param size Inline all function smaller than size.
- * @param ignore_runtime count a function only calling runtime functions as
- * leave
- */
-void inline_leave_functions(int maxsize, int leavesize, int size, int ignore_runtime);
-
-/** Code Placement.
- *
- * Pins all floating nodes to a block where they
- * will be executed only if needed. Depends on the flag opt_global_cse.
- * Graph may not be in phase_building. Does not schedule control dead
- * code. Uses dominator information which it computes if the irg is not
- * in state dom_consistent. Destroys the out information as it moves nodes
- * to other blocks. Optimizes Tuples in Control edges.
- * @todo This is not tested!
- *
- * Call remove_critical_cf_edges() before place_code(). This normalizes
- * the control flow graph so that for all operations a basic block exists
- * where they can be optimally placed.
- *
- * @todo A more powerful code placement would move operations past Phi nodes
- * out of loops.
- */
-void place_code(ir_graph *irg);
-
-/** Places an empty basic block on critical control flow edges thereby
- * removing them.
- *
- * A critical control flow edge is an edge from a block with several
- * control exits to a block with several control entries (See Muchnic
- * p. 407).
- *
- * @param irg IR Graph
- */
-void remove_critical_cf_edges(ir_graph *irg);
-
-#endif
#include "irflag_t.h"
#include "array.h"
#include "irgmod.h"
-#include "mangle.h"
#include "irouts.h"
#include "irhooks.h"
#include "irtools.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Entry point to the representation of procedure code.
- * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier
- * @version $Id$
- */
-#ifndef FIRM_IR_IRGRAPH_H
-#define FIRM_IR_IRGRAPH_H
-
-#include <stddef.h>
-
-#include "firm_types.h"
-#include "irop.h"
-#include "iropt.h"
-#include "irextbb.h"
-#include "type.h"
-
-/**
- * @page ir_graph The struct ir_graph
- *
- * This struct contains all information about a procedure.
- * It's allocated directly to memory.
- *
- * The fields of ir_graph:
- *
- * - ent The entity describing this procedure.
- *
- * The beginning and end of a graph:
- *
- * - start_block This ir_node is the block that contains the unique
- * start node of the procedure. With it it contains
- * the Proj's on starts results.
- * Further all Const nodes are placed in the start block.
- * - start This ir_node is the unique start node of the procedure.
- *
- * - end_block This ir_node is the block that contains the unique
- * end node of the procedure. This block contains no
- * further nodes.
- * - end This ir_node is the unique end node of the procedure.
- *
- * The following nodes are Projs from the Start node, held in ir_graph for
- * simple access:
- *
- * - frame The ir_node producing the pointer to the stack frame of
- * the procedure as output. This is the Proj node on the
- * third output of the start node. This output of the start
- * node is tagged as pns_frame_base. In FIRM most local
- * variables are modeled as data flow edges. Static
- * allocated arrays can not be represented as data flow
- * edges. Therefore FIRM has to represent them in the stack
- * frame.
- *
- * - globals This models a pointer to a space in the memory where
- * _all_ global things are held. Select from this pointer
- * with a Sel node the pointer to a global variable /
- * procedure / compiler known function... .
- *
- * - tls This models a pointer to a space in the memory where
- * thread local things are held. Select from this pointer
- * with a Sel node the pointer to a thread local variable.
- *
- * - args The ir_node that produces the arguments of the method as
- * it's result. This is a Proj node on the fourth output of
- * the start node. This output is tagged as pn_Start_T_args.
- *
- * - proj_args The proj nodes of the args node.
- *
- * - bad The Bad node is an auxiliary node. It is needed only once,
- * so there is this globally reachable node.
- *
- * - no_mem The NoMem node is an auxiliary node. It is needed only once,
- * so there is this globally reachable node.
- *
- * Data structures that are private to a graph:
- *
- * - obst An obstack that contains all nodes.
- *
- * - current_block A pointer to the current block. Any node created with
- * one of the node constructors (new_<opcode>) are assigned
- * to this block. It can be set with set_cur_block(block).
- * Only needed for ir construction.
- *
- * - params/n_loc An int giving the number of local variables in this
- * procedure. This is needed for ir construction. Name will
- * be changed.
- *
- * - value_table This hash table (pset) is used for global value numbering
- * for optimizing use in iropt.c.
- *
- * - Phi_in_stack; a stack needed for automatic Phi construction, needed only
- * during ir construction.
- *
- * - visited A int used as flag to traverse the ir_graph.
- *
- * - block_visited A int used as a flag to traverse block nodes in the graph.
- */
-
-/** Global variable holding the current ir graph.
- *
- * This global variable is used by the ir construction
- * interface in ircons and by the optimizations.
- * Further it is set by all walker functions.
- */
-extern ir_graph *current_ir_graph;
-
-ir_graph *get_current_ir_graph(void);
-void set_current_ir_graph(ir_graph *graph);
-
-/** This flag indicate the current view. The behavior of some methods
- * (get_irn_*, set_irn_*) is influenced by this flag. */
-int get_interprocedural_view(void);
-void set_interprocedural_view(int state);
-
-/**
- * Create a new ir graph to build ir for a procedure.
- *
- * @param ent A pointer to an entity representing the procedure,
- * i.e., the type of the entity must be of a method type.
- *
- * @param n_loc The number of local variables in this procedure including
- * the procedure parameters.
- *
- * This constructor generates the basic infrastructure needed to
- * represent a procedure in FIRM.
- *
- * It allocates an ir_graph and sets the field irg of the entity ent
- * as well as current_ir_graph to point to this graph.
- * Further it allocates the following nodes needed for every
- * procedure:
- *
- * - The start block containing a start node and Proj nodes for it's
- * seven results (X, M, P, P, P, T, P).
- * - The end block containing an end node. This block is not matured
- * after executing new_ir_graph() as predecessors need to be added to it.
- * (Maturing a block means fixing it's number of predecessors.)
- * - The current block, which is empty and also not matured.
- *
- * Further it enters the global store into the data structure of the start
- * block that contains all valid values in this block (set_store()). This
- * data structure is used to build the Phi nodes and removed after
- * completion of the graph. There is no path from end to start in the
- * graph after calling ir_graph.
- *
- * The op_pin_state of the graph is set to "op_pin_state_pinned"
- * if no global cse was performed on the graph.
- * It is set to "op_pin_state_floats" if global cse was performed
- * (and during construction: did actually change something).
- * Code placement is necessary.
- *
- * @see new_pseudo_ir_graph()
- */
-ir_graph *new_ir_graph (ir_entity *ent, int n_loc);
-
-/** Frees the passed irgraph.
- * Deallocates all nodes in this graph and the ir_graph structure.
- * Sets the field irgraph in the corresponding entity to NULL.
- * Does not remove the irgraph from the list in irprog (requires
- * inefficient search, call remove_irp_irg by hand).
- * Does not free types, entities or modes that are used only by this
- * graph, nor the entity standing for this graph.
- */
-void free_ir_graph (ir_graph *irg);
-
-/* --- access routines for all ir_graph attributes --- */
-
-/**
- * Checks whether a pointer points to a ir graph.
- *
- * @param thing an arbitrary pointer
- *
- * @return
- * true if the thing is a ir graph, else false
- */
-int is_ir_graph(const void *thing);
-
-/* #define get_irg_entity get_irg_ent */
-/* #define set_irg_entity set_irg_ent */
-ir_entity *get_irg_entity (const ir_graph *irg);
-void set_irg_entity (ir_graph *irg, ir_entity *ent);
-
-ir_type *get_irg_frame_type (ir_graph *irg);
-void set_irg_frame_type (ir_graph *irg, ir_type *ftp);
-
-ir_node *get_irg_start_block (const ir_graph *irg);
-void set_irg_start_block (ir_graph *irg, ir_node *node);
-
-ir_node *get_irg_start (const ir_graph *irg);
-void set_irg_start (ir_graph *irg, ir_node *node);
-
-ir_node *get_irg_end_block (const ir_graph *irg);
-void set_irg_end_block (ir_graph *irg, ir_node *node);
-
-ir_node *get_irg_end (const ir_graph *irg);
-void set_irg_end (ir_graph *irg, ir_node *node);
-
-/* The fields end_reg and end_except contain the end nodes of the
- interprocedural view. If the view is not constructed they contain
- the normal end node. */
-ir_node *get_irg_end_reg (const ir_graph *irg);
-void set_irg_end_reg (ir_graph *irg, ir_node *node);
-
-ir_node *get_irg_end_except (const ir_graph *irg);
-void set_irg_end_except (ir_graph *irg, ir_node *node);
-
-/** Returns the node that represents the frame pointer. */
-ir_node *get_irg_frame (const ir_graph *irg);
-/** Sets the node that represents the frame pointer. */
-void set_irg_frame (ir_graph *irg, ir_node *node);
-
-/** Returns the node that represents the global pointer. */
-ir_node *get_irg_globals (const ir_graph *irg);
-/** Sets the node that represents the global pointer. */
-void set_irg_globals (ir_graph *irg, ir_node *node);
-
-/** Returns the node that represents the tls pointer. */
-ir_node *get_irg_tls (const ir_graph *irg);
-/** Sets the node that represents the tls pointer. */
-void set_irg_tls (ir_graph *irg, ir_node *node);
-
-/** Returns the node that represents the initial memory. */
-ir_node *get_irg_initial_mem (const ir_graph *irg);
-/** Sets the node that represents the initial memory. */
-void set_irg_initial_mem (ir_graph *irg, ir_node *node);
-
-/** Returns the node that represents the argument pointer. */
-ir_node *get_irg_args (const ir_graph *irg);
-/** Sets the node that represents the argument pointer. */
-void set_irg_args (ir_graph *irg, ir_node *node);
-
-/** Returns the node that represents the value parameter base pointer. */
-ir_node *get_irg_value_param_base (const ir_graph *irg);
-/** Sets the node that represents the value parameter base pointer. */
-void set_irg_value_param_base (ir_graph *irg, ir_node *node);
-
-/** Returns an array of the nodes of the argument pointer. */
-ir_node **get_irg_proj_args (const ir_graph *irg);
-/** Sets the array of the nodes of the argument pointer. */
-void set_irg_proj_args (ir_graph *irg, ir_node **nodes);
-
-/** Returns the current block of a graph. */
-ir_node *get_irg_current_block (const ir_graph *irg);
-/** Sets the current block of a graph. */
-void set_irg_current_block (ir_graph *irg, ir_node *node);
-
-/** Returns the Bad node. Use new_Bad() instead!! */
-ir_node *get_irg_bad (const ir_graph *irg);
-void set_irg_bad (ir_graph *irg, ir_node *node);
-
-/** Returns the NoMem node. Use new_NoMem() instead!! */
-ir_node *get_irg_no_mem (const ir_graph *irg);
-void set_irg_no_mem (ir_graph *irg, ir_node *node);
-
-/** Returns the number of value numbers of a graph. */
-int get_irg_n_locs (ir_graph *irg);
-
-/** Returns the graph number. */
-long get_irg_graph_nr(ir_graph *irg);
-
-/********************************************************************************/
-/* 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.
- *
- * The graph is in phase_building during construction of the irgraph.
- * The construction is finished by a call to finalize_cons().
- *
- * Finalize_cons() sets the state to phase_high. All standard Firm nodes are
- * allowed.
- *
- * To get the irgraph into phase_low all Sel nodes must be removed and
- * replaced by explicit address computations. SymConst size and
- * type tag nodes must be removed (@@@ really?). Initialization of
- * memory allocated by Alloc must be explicit. @@@ More conditions?
- *
- * phase_backend is set if architecture specific machine nodes are inserted
- * (and probably most standard Firm are removed).
- */
-typedef enum {
- phase_building,
- phase_high,
- phase_low,
- phase_backend
-} irg_phase_state;
-
-/** returns the phase_state of an IR graph. */
-irg_phase_state get_irg_phase_state (const ir_graph *irg);
-
-/** sets the phase state of an IR graph. */
-void set_irg_phase_state(ir_graph *irg, irg_phase_state state);
-
-#define set_irg_phase_low(irg) set_irg_phase_state(irg, phase_low)
-
-/** state: op_pin_state_pinned
- The graph is "op_pin_state_pinned" if all nodes are associated with a basic block.
- It is in state "op_pin_state_floats" if nodes are in arbitrary blocks. In state
- "op_pin_state_floats" the block predecessor is set in all nodes, but this can be an
- invalid block, i.e., the block is not a dominator of all the uses of
- the node.
- The enum op_pin_state is defined in irop.h. */
-op_pin_state get_irg_pinned (const ir_graph *irg);
-
-/** state: outs_state
- * Outs are the back edges or def-use edges of ir nodes.
- * Values: outs_none, outs_consistent, outs_inconsistent */
-typedef enum {
- outs_none, /**< Outs are not computed, no memory is allocated. */
- outs_consistent, /**< Outs are computed and correct. */
- outs_inconsistent /**< Outs have been computed, memory is still allocated,
- but the graph has been changed since. */
-} irg_outs_state;
-irg_outs_state get_irg_outs_state(const ir_graph *irg);
-void set_irg_outs_inconsistent(ir_graph *irg);
-
-/** state: extended basic block state. */
-typedef enum {
- extblk_none = 0, /**< No extended basic block information is constructed. Default. */
- extblk_valid = 1, /**< Extended basic block information is valid. */
- extblk_invalid = 2 /**< Extended basic block information is constructed but invalid. */
-} irg_extblk_state;
-irg_extblk_state get_irg_extblk_state(const ir_graph *irg);
-void set_irg_extblk_inconsistent(ir_graph *irg);
-
-/** state: dom_state
- * Signals the state of the dominator / post dominator information.
- */
-typedef enum {
- dom_none, /**< dominator are not computed, no memory is allocated */
- dom_consistent, /**< dominator information is computed and correct */
- dom_inconsistent /**< dominator information is computed but the graph has been changed since */
-} irg_dom_state;
-
-/** returns the dominator state of an IR graph. */
-irg_dom_state get_irg_dom_state(const ir_graph *irg);
-
-/** returns the post dominator state of an IR graph. */
-irg_dom_state get_irg_postdom_state(const ir_graph *irg);
-
-/** sets the dominator and post dominator state of an IR graph to inconsistent. */
-void set_irg_doms_inconsistent(ir_graph *irg);
-
-/** state: loopinfo_state
- * Loop information describes the loops within the control and
- * data flow of the procedure.
- */
-typedef enum {
- loopinfo_none = 0, /**< No loop information is constructed. Default. */
- loopinfo_constructed = 1, /**< Some kind of loop information is constructed. */
- loopinfo_valid = 2, /**< Loop information is valid. */
- loopinfo_cf = 4, /**< Loop information constructed for control flow only. */
- loopinfo_inter = 8, /**< Loop information for interprocedural view. */
-
- loopinfo_for_firmjni = 16, /**< A hack for firmjni: all enums must differ as they
- are used in a switch. */
-
- /** IntRAprocedural loop information constructed and valid. */
- loopinfo_consistent = loopinfo_constructed | loopinfo_for_firmjni | loopinfo_valid,
- /** IntRAprocedural loop information constructed and invalid. */
- loopinfo_inconsistent = loopinfo_constructed | loopinfo_for_firmjni,
-
- /** IntERprocedural loop information constructed and valid. */
- loopinfo_ip_consistent = loopinfo_constructed | loopinfo_inter | loopinfo_valid,
- /** IntERprocedural loop information constructed and invalid. */
- loopinfo_ip_inconsistent = loopinfo_constructed | loopinfo_inter,
-
- /** IntRAprocedural control loop information constructed and valid. */
- loopinfo_cf_consistent = loopinfo_constructed | loopinfo_cf | loopinfo_valid,
- /** IntRAprocedural control loop information constructed and invalid. */
- loopinfo_cf_inconsistent = loopinfo_constructed | loopinfo_cf,
-
- /** IntERprocedural control loop information constructed and valid. */
- loopinfo_cf_ip_consistent = loopinfo_constructed | loopinfo_cf | loopinfo_inter | loopinfo_valid,
- /** IntERprocedural control loop information constructed and invalid. */
- loopinfo_cf_ip_inconsistent = loopinfo_constructed | loopinfo_cf | loopinfo_inter
-} irg_loopinfo_state;
-
-/** Return the current loop information state. */
-irg_loopinfo_state get_irg_loopinfo_state(const ir_graph *irg);
-
-/** Sets the current loop information state. */
-void set_irg_loopinfo_state(ir_graph *irg, irg_loopinfo_state s);
-
-/** Sets the loop information state to the appropriate inconsistent state.
- * If state is 'none' does not change. */
-void set_irg_loopinfo_inconsistent(ir_graph *irg);
-/** Sets the loop information state to the appropriate inconsistent state.
- * If state is 'none' does not change.
- * Does this for all irgs. */
-void set_irp_loopinfo_inconsistent(void);
-
-/** state: callee_information_state
- * Call nodes contain a list of possible callees. This list must be
- * computed by an analysis.
- *
- * It's strange that this state is administered on irg basis, as the
- * information must be computed for the whole program, or not?
- */
-typedef enum {
- irg_callee_info_none,
- irg_callee_info_consistent,
- irg_callee_info_inconsistent
-} irg_callee_info_state;
-
-/** returns the callee_info_state of an IR graph. */
-irg_callee_info_state get_irg_callee_info_state(const ir_graph *irg);
-
-/** sets the callee_info_state of an IR graph. */
-void set_irg_callee_info_state(ir_graph *irg, irg_callee_info_state s);
-
-/** property:
- * Tells how to handle an ir graph in inlineing.
- */
-typedef enum {
- irg_inline_any, /**< No restriction on inlineing. Default. */
- irg_inline_forbidden, /**< The graph may not be inlined. */
- irg_inline_recomended, /**< The graph should be inlined. */
- irg_inline_forced, /**< The graph must be inlined. */
- irg_inline_forced_no_body /**< The graph must be inlined. No body is allowed
- to be emitted. */
-} irg_inline_property;
-
-/** Returns the inline property of a graph. */
-irg_inline_property get_irg_inline_property(const ir_graph *irg);
-/** Sets the inline property of a graph. */
-void set_irg_inline_property(ir_graph *irg, irg_inline_property s);
-
-/**
- * Returns the mask of the additional graph properties.
- * The properties are automatically inherited from the method type
- * if they were not set using set_irg_additional_properties() or
- * set_irg_additional_property().
- */
-unsigned get_irg_additional_properties(const ir_graph *irg);
-
-/** Sets the mask of the additional graph properties. */
-void set_irg_additional_properties(ir_graph *irg, unsigned property_mask);
-
-/** Sets one additional graph property. */
-void set_irg_additional_property(ir_graph *irg, mtp_additional_property flag);
-
-/** A void * field to link arbitrary information to the node. */
-void set_irg_link (ir_graph *irg, void *thing);
-void *get_irg_link (const ir_graph *irg);
-
-/** Increments visited flag by one.
- * @see also: get_irn_visited() get_irg_block_visited(). */
-void inc_irg_visited (ir_graph *irg);
-unsigned long get_irg_visited (const ir_graph *irg);
-void set_irg_visited (ir_graph *irg, unsigned long i);
-/** An interprocedural flag valid for all irgs.
- * @see also: get_irn_visited() get_irg_block_visited(). */
-unsigned long get_max_irg_visited (void);
-void set_max_irg_visited (int val);
-unsigned long inc_max_irg_visited (void);
-
-/** Increments block_visited by one.
- * @see also: get_irn_visited() get_irg_block_visited(). */
-void inc_irg_block_visited (ir_graph *irg);
-unsigned long get_irg_block_visited (const ir_graph *irg);
-void set_irg_block_visited (ir_graph *irg, unsigned long i);
-
-/**
- * Debug helpers: You can indicate wether you are currently using visited or
- * block_visited flags. If NDEBUG is not defined, then the compiler will abort
- * if 2 parties try to use the flags.
- */
-#ifndef NDEBUG
-void set_using_block_visited(ir_graph *irg);
-void clear_using_block_visited(ir_graph *irg);
-int using_block_visited(const ir_graph *irg);
-void set_using_visited(ir_graph *irg);
-void clear_using_visited(ir_graph *irg);
-int using_visited(const ir_graph *irg);
-void set_using_irn_link(ir_graph *irg);
-void clear_using_irn_link(ir_graph *irg);
-int using_irn_link(const ir_graph *irg);
-#else
-static INLINE void set_using_block_visited(ir_graph *irg) { (void) irg; }
-static INLINE void clear_using_block_visited(ir_graph *irg) { (void) irg; }
-static INLINE int using_block_visited(const ir_graph *irg) { (void) irg; return 0; }
-static INLINE void set_using_visited(ir_graph *irg) { (void) irg; }
-static INLINE void clear_using_visited(ir_graph *irg) { (void) irg; }
-static INLINE int using_visited(const ir_graph *irg) { (void) irg; return 0; }
-static INLINE void set_using_irn_link(ir_graph *irg) { (void) irg; }
-static INLINE void clear_using_irn_link(ir_graph *irg) { (void) irg; }
-static INLINE int using_irn_link(const ir_graph *irg) { (void) irg; return 0; }
-#endif
-
-/** move Proj nodes into the same block as its predecessors */
-void normalize_proj_nodes(ir_graph *irg);
-
-/** set a description for local value n */
-void set_irg_loc_description(ir_graph *irg, int n, void *description);
-
-/** get the description for local value n */
-void *get_irg_loc_description(ir_graph *irg, int n);
-
-/** Returns a estimated node count of the irg. This count is updated
- * after every irg_walk_graph().
- */
-unsigned get_irg_estimated_node_cnt(const ir_graph *irg);
-
-/** Returns the last irn index for this graph. */
-unsigned get_irg_last_idx(const ir_graph *irg);
-
-/** Returns the floating point model of this graph. */
-unsigned get_irg_fp_model(const ir_graph *irg);
-
-/** Sets a floating point model for this graph. */
-void set_irg_fp_model(ir_graph *irg, unsigned model);
-
-/**
- * Access custom graph data.
- * The data must have been registered with
- * register_additional_graph_data() before.
- * @param graph The graph to get the data from.
- * @param type The type of the data you registered.
- * @param off The value returned by register_additional_graph_data().
- * @return A pointer of type @p type.
- */
-#define get_irg_data(graph,type,off) \
- (assert(off > 0 && "Invalid graph data offset"), (type *) ((char *) (graph) - (off)))
-
-/**
- * Get the pointer to the node some custom data belongs to.
- * @param data The pointer to the custom data.
- * @param off The number as returned by register_additional_graph_data().
- * @return A pointer to the ir node the custom data belongs to.
- */
-#define get_irg_data_base(data,off) \
- (assert(off > 0 && "Invalid graph data offset"), (ir_graph *) ((char *) (data) + (off)))
-
-/**
- * Request additional data to be allocated with an ir graph.
- * @param size The size of the additional data required.
- * @return A positive number, if the operation was successful, which
- * must be passed to the access macro get_irg_data(), 0 if the
- * registration failed.
- */
-size_t register_additional_graph_data(size_t size);
-
-#endif
#include "pseudo_irg.h"
#include "type_t.h"
#include "entity_t.h"
-#include "typegmod.h"
-#include "tr_inheritance.h"
#include "iredgekinds.h"
#include "irmemory.h"
#include "irgraph_t.h" /* visited flag */
#include "irprog.h"
#include "irgwalk.h"
-#include "typewalk.h"
#include "irhooks.h"
#include "ircgcons.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Traverse an ir graph
- * @author Boris Boesler, Goetz Lindenmaier
- * @version $Id$
- * @summary
- * Traverse an ir graph:
- * - execute the pre function before recursion
- * - execute the post function after recursion
- *
- * Uses current_ir_graph (from irgraph.h)!!! Set it to the proper
- * graph before starting the walker.
- */
-#ifndef FIRM_IR_IRGWALK_H
-#define FIRM_IR_IRGWALK_H
-
-#include "firm_types.h"
-
-/* type of callback function for ir_graph walk */
-#ifndef _IRG_WALK_FUNC_TYPEDEF_
-#define _IRG_WALK_FUNC_TYPEDEF_
-/**
- * The type of a walk function. Does not use the link field.
- *
- * @param node - the node that is just visited
- * @param env - an environment pointer passed by the walk functions
- */
-typedef void irg_walk_func(ir_node *node, void *env);
-#endif
-
-/**
- * Walks over the ir graph.
- *
- * Walks over the ir graph, starting at the node given as first argument.
- * Executes pre before visiting the predecessor of a node, post after.
- * irg_walk uses the visited flag in irg and the nodes to determine visited
- * nodes. It executes inc_irg_visited(current_ir_graph) to generate a new
- * flag. Therefore current_ir_graph must be set before calling the walker.
- * It marks the node as visited before executing pre.
- * The void* env can be used to pass status information between the
- * pre and post functions. Does not use the link fields.
- *
- * @param node - the start node
- * @param pre - walker function, executed before the predecessor of a node are visited
- * @param post - walker function, executed after the predecessor of a node are visited
- * @param env - environment, passed to pre and post
- *
- */
-void irg_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env);
-
-/**
- * Walks over all reachable nodes in the ir graph.
- *
- * @param irg - the irg graph
- * @param pre - walker function, executed before the predecessor of a node are visited
- * @param post - walker function, executed after the predecessor of a node are visited
- * @param env - environment, passed to pre and post
- *
- * Like irg_walk(), but walks over all reachable nodes in the ir
- * graph, starting at the end operation. During the walk current_ir_graph
- * is set to irg. Does not use the link field. If interprocedural_view
- * is set, visits all reachable irgs.
- */
-void irg_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
-
-/**
- * Walks over the ir graph.
- *
- * Walks over the ir graph, starting at the node given as first argument.
- * Executes pre before visiting the predecessor of a node, post after.
- * irg_walk uses the visited flag in irg and the nodes to determine visited
- * nodes. It executes inc_irg_visited(current_ir_graph) to generate a new
- * flag. Therefore current_ir_graph must be set before calling the walker.
- * It marks the node as visited before executing pre.
- * The void* env can be used to pass status information between the
- * pre and post functions. Does not use the link fields.
- * This walker also follows additional dependency egdes.
- *
- * @param node - the start node
- * @param pre - walker function, executed before the predecessor of a node are visited
- * @param post - walker function, executed after the predecessor of a node are visited
- * @param env - environment, passed to pre and post
- *
- */
-void irg_walk_in_or_dep(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env);
-
-/**
- * Walks over all reachable nodes in the ir graph.
- *
- * @param irg - the irg graph
- * @param pre - walker function, executed before the predecessor of a node are visited
- * @param post - walker function, executed after the predecessor of a node are visited
- * @param env - environment, passed to pre and post
- *
- * Like irg_walk(), but walks over all reachable nodes in the ir
- * graph, starting at the end operation. During the walk current_ir_graph
- * is set to irg. Does not use the link field.
- * This walker also follows additional dependency egdes.
- * interprocedural_view is not yet supported.
- */
-void irg_walk_in_or_dep_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
-
-/**
- * Executes irg_walk(end, pre, post, env) for all irgraphs in irprog.
- *
- * @param pre - walker function, executed before the predecessor of a node are visited
- * @param post - walker function, executed after the predecessor of a node are visited
- * @param env - environment, passed to pre and post
- *
- * This function executes irg_walk(end, pre, post, env) for all irgraphs in irprog.
- * Sets current_ir_graph properly for each walk. Conserves current
- * current_ir_graph. In interprocedural view nodes can be visited several
- * times. Does not use the link field.
- */
-void all_irg_walk(irg_walk_func *pre, irg_walk_func *post, void *env);
-
-/**
- * Walks all irgs in interprocedural view.
- *
- * @param pre - walker function, executed before the predecessor of a node are visited
- * @param post - walker function, executed after the predecessor of a node are visited
- * @param env - environment, passed to pre and post
- *
- * This function walks all irgs in interprocedural view.
- * Visits each node only once. Sets current_ir_graph properly. Does not use the link field.
- */
-void cg_walk(irg_walk_func *pre, irg_walk_func *post, void *env);
-
-/** Walks only over Block nodes in the graph.
- *
- * @param node - the start node
- * @param pre - walker function, executed before the predecessor of a node are visited
- * @param post - walker function, executed after the predecessor of a node are visited
- * @param env - environment, passed to pre and post
- *
- * This function Walks only over Block nodes in the graph. Has it's own visited
- * flag, so that it can be interleaved with the other walker.
- * If a none block is passed, starts at the block this node belongs to.
- * If end is passed also visits kept alive blocks. Does not use the link field.
- */
-void irg_block_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env);
-
-/**
- * Walks only over reachable Block nodes in the graph.
- *
- * @param irg - the irg graph
- * @param pre - walker function, executed before the predecessor of a node are visited
- * @param post - walker function, executed after the predecessor of a node are visited
- * @param env - environment, passed to pre and post
- *
- * Like irg_block_walk(), but walks over all reachable blocks in the
- * ir graph, starting at the end block. Does not use the link field.
- */
-void irg_block_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
-
-/**
- * Walks over all code in const_code_irg.
- *
- * @param pre - walker function, executed before the predecessor of a node are visited
- * @param post - walker function, executed after the predecessor of a node are visited
- * @param env - environment, passed to pre and post
- *
- * This function walks over all code in const_code_irg.
- * Uses visited flag in const_code_irg. Does not use the link field.
- */
-void walk_const_code(irg_walk_func *pre, irg_walk_func *post, void *env);
-
-/**
- * Walks over reachable nodes in block-wise order, i.e. visit all nodes in a block
- * before going to another block, starting at the end operation.
- * Executes pre before visiting the predecessor of a node, post after.
- * irg_walk_blkwise_graph() uses the visited flag in irg and the nodes to
- * determine visited nodes.
- * It executes inc_irg_visited(current_ir_graph) to generate a new
- * flag. It marks the node as visited before executing pre.
- * The void *env can be used to pass status information between the
- * pre and post functions. Does not use the link fields.
- * Walks only intraprocedural, even in interprocedural view.
- *
- * @param irg - the irg graph
- * @param pre - walker function, executed before the predecessor of a node are visited
- * @param post - walker function, executed after the predecessor of a node are visited
- * @param env - environment, passed to pre and post
- */
-void irg_walk_blkwise_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
-
-/**
- * Walks over reachable nodes in block-wise order, i.e. visit all nodes in a block
- * before going to another block, starting at the end operation.
- * Executes pre before visiting the predecessor of a node, post after.
- * irg_walk_blkwise_graph() uses the visited flag in irg and the nodes to
- * determine visited nodes.
- * It executes inc_irg_visited(current_ir_graph) to generate a new
- * flag. It marks the node as visited before executing pre.
- * The void *env can be used to pass status information between the
- * pre and post functions. Does not use the link fields.
- * Walks only intraprocedural, even in interprocedural view.
- * This walker also follows dependency edges.
- *
- * @param irg - the irg graph
- * @param pre - walker function, executed before the predecessor of a node are visited
- * @param post - walker function, executed after the predecessor of a node are visited
- * @param env - environment, passed to pre and post
- */
-void irg_walk_in_or_dep_blkwise_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
-
-/**
- * Additionally walk over all anchors. Do NOT increase the visit flag.
- * This function visits all anchor nodes that otherwise might not been visited in a
- * walk, for instance the Bad() node.
- *
- * @param irg - the irg graph
- * @param pre - walker function, executed before the predecessor of a node are visited
- * @param post - walker function, executed after the predecessor of a node are visited
- * @param env - environment, passed to pre and post
- */
-void irg_walk_anchors(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Generic hooks for various libFirm functions.
- * @author Michael Beck
- * @version $Id$
- */
-#ifndef FIRM_IR_IRHOOKS_H
-#define FIRM_IR_IRHOOKS_H
-
-#include "firm_config.h"
-#include "irop.h"
-#include "irnode.h"
-#include "irgraph.h"
-
-/**
- * options for the hook_merge_nodes hook
- */
-typedef enum {
- HOOK_OPT_DEAD_BLOCK, /**< a block was removed because it's dead */
- HOOK_OPT_STG, /**< straightening optimization */
- HOOK_OPT_IFSIM, /**< if simplification */
- HOOK_OPT_CONST_EVAL, /**< constant evaluation */
- HOOK_OPT_ALGSIM, /**< algebraic simplification */
- HOOK_OPT_PHI, /**< Phi optmization */
- HOOK_OPT_SYNC, /**< Sync optmization */
- HOOK_OPT_WAW, /**< Write-After-Write optimization */
- HOOK_OPT_WAR, /**< Write-After-Read optimization */
- HOOK_OPT_RAW, /**< Read-After-Write optimization */
- HOOK_OPT_RAR, /**< Read-After-Read optimization */
- HOOK_OPT_RC, /**< Read-a-Const optimization */
- HOOK_OPT_TUPLE, /**< Tuple optimization */
- HOOK_OPT_ID, /**< ID optimization */
- HOOK_OPT_CSE, /**< common subexpression elimination */
- HOOK_OPT_STRENGTH_RED,/**< strength reduction */
- HOOK_OPT_ARCH_DEP, /**< architecture dependent optimization */
- HOOK_OPT_REASSOC, /**< reassociation */
- HOOK_OPT_POLY_CALL, /**< polymorphic call optimization */
- HOOK_OPT_IF_CONV, /**< an if conversion was tried */
- HOOK_OPT_FUNC_CALL, /**< a real function call was removed */
- HOOK_OPT_CONFIRM, /**< a value was substituted by another due to a Confirm */
- HOOK_OPT_CONFIRM_C, /**< a value was substituted by a const due to a Confirm */
- HOOK_OPT_CONFIRM_E, /**< a value was evaluated due to a Confirm */
- HOOK_OPT_EXC_REM, /**< a exception edge was removed due to a Confirmation prove */
- HOOK_LOWERED, /**< lowered */
- HOOK_BACKEND, /**< a backend transformation */
- HOOK_OPT_LAST
-} hook_opt_kind;
-
-typedef enum _if_result_t {
- IF_RESULT_SUCCESS = 0, /**< if conversion could be done */
- IF_RESULT_SIDE_EFFECT = 1, /**< if conversion failed because of side effect */
- IF_RESULT_SIDE_EFFECT_PHI = 2, /**< if conversion failed because of Phi node found */
- IF_RESULT_TOO_DEEP = 3, /**< if conversion failed because of to deep DAG's */
- IF_RESULT_BAD_CF = 4, /**< if conversion failed because of bad control flow */
- IF_RESULT_DENIED = 5, /**< if conversion failed because of architecture deny */
- IF_RESULT_LAST
-} if_result_t;
-
-/**
- * A generic function type.
- */
-typedef void (generic_func)(void);
-
-/**
- * a hook entry
- */
-typedef struct hook_entry {
- /** A union of all possible hook types. */
- union {
- /** This hook is called, after a new ir_op was created. */
- void (*_hook_new_ir_op)(void *context, ir_op *op);
-
- /** This hook is called, before am ir_op is destroyed. */
- void (*_hook_free_ir_op)(void *context, ir_op *op);
-
- /** This hook is called, after a new IR-node was created and before it is optimized. */
- void (*_hook_new_node)(void *context, ir_graph *graph, ir_node *node);
-
- /** This hook is called, before a node input was changed. */
- void (*_hook_set_irn_n)(void *context, ir_node *src,
- int pos, ir_node *tgt, ir_node *old_tgt);
-
- /** This hook is called, before a node is replaced (exchange()) by another. */
- void (*_hook_replace)(void *context, ir_node *old_node, ir_node *new_node);
-
- /** This hook is called, before a node is changed into an Id node. */
- void (*_hook_turn_into_id)(void *context, ir_node *node);
-
- /** This hook is called, after a new graph was created and before the first block
- * on this graph is build. */
- void (*_hook_new_graph)(void *context, ir_graph *irg, ir_entity *ent);
-
- /** This hook is called before a graph is freed. */
- void (*_hook_free_graph)(void *context, ir_graph *irg);
-
- /** This hook is called before an irg walk is started. */
- void (*_hook_irg_walk)(void *context, ir_graph *irg, generic_func *pre, generic_func *post);
-
- /** This hook is called before an block wise irg walk is started. */
- void (*_hook_irg_walk_blkwise)(void *context, ir_graph *irg, generic_func *pre, generic_func *post);
-
- /** This hook is called before an block walk is started. */
- void (*_hook_irg_block_walk)(void *context, ir_graph *irg, ir_node *node, generic_func *pre, generic_func *post);
-
- /** This hook is called, when debug info must be merged. */
- void (*_hook_merge_nodes)(void *context, ir_node **new_node_array, int new_num_entries,
- ir_node **old_node_array, int old_num_entries, hook_opt_kind opt);
-
- /** This hook is called, when reassociation is started/stopped. */
- void (*_hook_reassociate)(void *context, int start);
-
- /** This hook is called, before a node is lowered. */
- void (*_hook_lower)(void *context, ir_node *node);
-
- /** This hook is called, before a graph is inlined. */
- void (*_hook_inline)(void *context, ir_node *call, ir_graph *irg);
-
- /** This hook is called, before tail recursion is applied to a graph. */
- void (*_hook_tail_rec)(void *context, ir_graph *irg, int n_calls);
-
- /** This hook is called, before a node is replaced due to strength reduction */
- void (*_hook_strength_red)(void *context, ir_graph *irg, ir_node *node);
-
- /** This hook is called, when dead node elimination is started/stopped. */
- void (*_hook_dead_node_elim)(void *context, ir_graph *irg, int start);
-
- /** This hook is called, when a node is substituted during dead node elimination. */
- void (*_hook_dead_node_elim_subst)(void *context, ir_graph *irg, ir_node *old, ir_node *nw);
-
- /** This hook is called after if conversion has run. */
- void (*_hook_if_conversion)(void *context, ir_graph *irg, ir_node *phi, int pos, ir_node *mux, if_result_t reason);
-
- /** This hook is called after a call was detected as const call */
- void (*_hook_func_call)(void *context, ir_graph *irg, ir_node *call);
-
- /** This hook is called after a Mul was replaced by a series of Shift and Add/Sub operations. */
- void (*_hook_arch_dep_replace_mul_with_shifts)(void *context, ir_node *irn);
-
- /** This hook is called after a Div/Mod/DivMod by a constant value was replaced. */
- void (*_hook_arch_dep_replace_division_by_const)(void *context, ir_node *irn);
-
- /** This hook is called after a new mode was registered. */
- void (*_hook_new_mode)(void *context, const ir_mode *tmpl, ir_mode *mode);
-
- /** This hook is called after a new entity was created. */
- void (*_hook_new_entity)(void *context, ir_entity *ent);
-
- /** This hook is called after a new type was created. */
- void (*_hook_new_type)(void *context, ir_type *tp);
-
- /** This hook is called at the end of the node info dumper to dump additional node info. */
- void (*_hook_node_info)(void *context, FILE *f, const ir_node *n);
- } hook;
-
- /** the context for every hook */
- void *context;
-
- /** needed for chaining */
- struct hook_entry *next;
-} hook_entry_t;
-
-/**
- * possible hooks
- */
-typedef enum {
- hook_new_ir_op,
- hook_free_ir_op,
- hook_new_node,
- hook_set_irn_n,
- hook_replace,
- hook_turn_into_id,
- hook_new_graph,
- hook_free_graph,
- hook_irg_walk,
- hook_irg_walk_blkwise,
- hook_irg_block_walk,
- hook_merge_nodes,
- hook_reassociate,
- hook_lower,
- hook_inline,
- hook_tail_rec,
- hook_strength_red,
- hook_dead_node_elim,
- hook_dead_node_elim_subst,
- hook_if_conversion,
- hook_func_call,
- hook_arch_dep_replace_mul_with_shifts,
- hook_arch_dep_replace_division_by_const,
- hook_new_mode,
- hook_new_entity,
- hook_new_type,
- hook_node_info,
- hook_last
-} hook_type_t;
-
-/**
- * register a hook entry.
- *
- * @param hook the hook type
- * @param entry the hook entry
- */
-void register_hook(hook_type_t hook, hook_entry_t *entry);
-
-/**
- * unregister a hook entry.
- *
- * @param hook the hook type
- * @param entry the hook entry
- */
-void unregister_hook(hook_type_t hook, hook_entry_t *entry);
-
-#ifdef FIRM_ENABLE_HOOKS
-
-extern hook_entry_t *hooks[hook_last];
-
-/**
- * execute the hook what with the args args
- * Do not use this macro directly.
- */
-#define hook_exec(what, args) do { \
- hook_entry_t *p; \
- for (p = hooks[what]; p; p = p->next){ \
- void *ctx = p->context; \
- p->hook._##what args; \
- } \
-} while (0)
-
-#else
-
-#define hook_exec(what, args)
-
-#endif /* FIRM_ENABLE_HOOKS */
-
-#define hook_new_ir_op(op) hook_exec(hook_new_ir_op, (ctx, op))
-#define hook_free_ir_op(op) hook_exec(hook_free_ir_op, (ctx, op))
-#define hook_new_node(graph, node) hook_exec(hook_new_node, (ctx, graph, node))
-#define hook_set_irn_n(src, pos, tgt, old_tgt) \
- hook_exec(hook_set_irn_n, (ctx, src, pos, tgt, old_tgt))
-#define hook_replace(old, nw) hook_exec(hook_replace, (ctx, old, nw))
-#define hook_turn_into_id(node) hook_exec(hook_turn_into_id, (ctx, node))
-#define hook_new_graph(irg, ent) hook_exec(hook_new_graph, (ctx, irg, ent))
-#define hook_free_graph(irg) hook_exec(hook_free_graph, (ctx, irg))
-#define hook_irg_walk(irg, pre, post) hook_exec(hook_irg_walk, (ctx, irg, pre, post))
-#define hook_irg_walk_blkwise(irg, pre, post) \
- hook_exec(hook_irg_walk_blkwise, (ctx, irg, pre, post))
-#define hook_irg_block_walk(irg, node, pre, post) \
- hook_exec(hook_irg_block_walk, (ctx, irg, node, pre, post))
-#define hook_merge_nodes(new_node_array, new_num_entries, old_node_array, old_num_entries, opt) \
- hook_exec(hook_merge_nodes, (ctx, new_node_array, new_num_entries, old_node_array, old_num_entries, opt))
-#define hook_reassociate(start) hook_exec(hook_reassociate, (ctx, start))
-#define hook_lower(node) hook_exec(hook_lower, (ctx, node))
-#define hook_inline(call, irg) hook_exec(hook_inline, (ctx, call, irg))
-#define hook_tail_rec(irg, n_calls) hook_exec(hook_tail_rec, (ctx, irg, n_calls))
-#define hook_strength_red(irg, node) \
- hook_exec(hook_strength_red, (ctx, irg, node))
-#define hook_dead_node_elim(irg, start) hook_exec(hook_dead_node_elim, (ctx, irg, start))
-#define hook_dead_node_elim_subst(irg, old, nw) \
- hook_exec(hook_dead_node_elim_subst, (ctx, irg, old, nw))
-#define hook_if_conversion(irg, phi, pos, mux, reason) \
- hook_exec(hook_if_conversion, (ctx, irg, phi, pos, mux, reason))
-#define hook_func_call(irg, call) \
- hook_exec(hook_func_call, (ctx, irg, call))
-#define hook_arch_dep_replace_mul_with_shifts(irn) \
- hook_exec(hook_arch_dep_replace_mul_with_shifts, (ctx, irn))
-#define hook_arch_dep_replace_division_by_const(irn) \
- hook_exec(hook_arch_dep_replace_division_by_const, (ctx, irn))
-#define hook_new_mode(tmpl, mode) hook_exec(hook_new_mode, (ctx, tmpl, mode))
-#define hook_new_entity(ent) hook_exec(hook_new_entity, (ctx, ent))
-#define hook_new_type(tp) hook_exec(hook_new_type, (ctx, tp))
-#define hook_node_info(F, node) hook_exec(hook_node_info, (ctx, F, node))
-
-/* the initializer, move to hooks_t.h some day */
-int firm_init_hooks(void);
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Data modes of operations.
- * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Mathias Heil,
- * Michael Beck
- * @version $Id$
- * @summary
- * This module specifies the modes that type the firm nodes. It defines
- * a datasturcture that describes a mode and implements constructors and
- * access routines to this datastructure. Further it defines a set of
- * predefined modes.
- *
- * SEE ALSO:
- * UKA tech report 1999-44 for more information about modes.
- */
-#ifndef FIRM_IR_IRMODE_H
-#define FIRM_IR_IRMODE_H
-
-#include "firm_types.h"
-#include "ident.h"
-
-/**
- * Contains relevant information about a mode.
- *
- * Necessary information about a mode is stored in this struct
- * which is used by the tarval module to perform calculations
- * and comparisons of values of a such described mode.
- *
- * ATTRIBUTES:
- * - modecode code: An unambiguous int (enum) for the mode
- * - ident *name: Name of this mode. Two modes are different if the name is different.
- * - mode_sort sort: sort of mode specifying possible usage categories
- * - int size: size of the mode in Bits.
- * - unsigned sign:1: signedness of this mode
- * - ... more to come
- * - modulo_shift specifies for modes of kind irms_int_number
- * whether shift applies modulo to value of bits to shift
- *
- * SEE ALSO:
- * The tech report 1999-44 describing FIRM and predefined modes
- * tarval.h
- */
-#ifndef _IR_MODE_TYPEDEF_
-#define _IR_MODE_TYPEDEF_
-typedef struct ir_mode ir_mode;
-#endif
-
-/* ********** Predefined modes ********** */
-
-/**
- * Predefined mode according to tech report 1999-14.
- */
-typedef enum { /* irm is short for `ir mode' */
- irm_BB, /**< basic block */
- irm_X, /**< execution */
- irm_F, /**< float(32) */
- irm_D, /**< double(64) */
- irm_E, /**< extended(80) */
- irm_Bs, /**< signed byte(8) */
- irm_Bu, /**< unsigned byte(8) */
- irm_Hs, /**< signed short(16) */
- irm_Hu, /**< unsigned short(16) */
- irm_Is, /**< signed int(32) */
- irm_Iu, /**< unsigned int(32) */
- irm_Ls, /**< signed long(64) */
- irm_Lu, /**< unsigned long(64) */
- irm_LLs, /**< signed long long(128) */
- irm_LLu, /**< unsigned long long(128) */
- irm_C, /**< character */
- irm_P, /**< pointer */
- irm_b, /**< internal boolean */
- irm_M, /**< memory */
- irm_T, /**< tuple */
- irm_U, /**< unicode character */
- irm_ANY, /**< undefined mode */
- irm_BAD, /**< bad mode */
- irm_max /**< maximum value for modecode */
-} modecode;
-
-/** These values represent the different mode classes of value representations.
- */
-typedef enum {
- /* Predefined sorts of modes */
- irms_auxiliary, /**< Only for Firm use. Not extensible. (irm_T) */
- irms_control_flow, /**< Marks all control flow modes. Not extensible. (irm_BB, irm_X) */
- irms_memory, /**< Marks the memory mode. Not extensible. (irm_M) */
- irms_internal_boolean, /**< Internal boolean representation.
- Storing to memory impossible, convert first. (irm_b) */
- /* user-extensible sorts of modes */
- irms_int_number, /**< A mode to represent int numbers.
- Integer computations can be performed. */
- irms_float_number, /**< A mode to represent float numbers.
- Floating point computations can be performed. */
- irms_reference, /**< A mode to represent entities.
- Restricted int computations can be performed */
- irms_character /**< A mode to represent characters/symbols
- ?? Are computations allowed? as int?? */
-} mode_sort;
-
-/** These values represent the different arithmetic operations possible with a mode.
- Further arithmetics can be defined, e.g., for @@@ modes.
- */
-typedef enum {
- 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
- floatingpoint 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
-} mode_arithmetic;
-
-
-/* ********** Constructor for user defined modes **************** */
-/**
- * Creates a new mode.
- *
- * @param name the name of the mode to be created
- * @param sort the mode_sort of the mode to be created
- * @param bit_size number of bits this mode allocate
- * @param sign non-zero if this is a signed mode
- * @param arithmetic arithmetic operations possible with a mode
- * @param modulo_shift Is ignored for modes other than integer.
- *
- * This function constructs a new mode given by the parameters.
- * If the parameters match an already defined mode, this mode is returned
- * (including the default modes).
- * If the mode is newly allocated, a new unique mode_code is chosen.
- * Also, special value tarvals will be calculated such as null,
- * min, max and can be retrieved using the get_mode_* functions
- *
- * @return
- * The new mode or NULL on error.
- *
- * @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.
- */
-ir_mode *new_ir_mode(const char *name, mode_sort sort, int bit_size, int sign, mode_arithmetic arithmetic, unsigned int modulo_shift);
-
-/**
- * Creates a new vector mode.
- *
- * @param name the name of the mode to be created
- * @param sort the mode_sort of the mode to be created
- * @param bit_size number of bits for one element of this mode
- * @param num_of_elem number of elements in this vector mode
- * @param sign non-zero if this is a signed mode
- * @param arithmetic arithmetic operations possible with a mode
- * @param modulo_shift Is ignored for modes other than integer.
- *
- * This function constructs a new vector mode given by the parameters.
- * If the parameters match an already defined mode, this mode is returned.
- * If the mode is newly allocated, a new unique mode_code is chosen.
- * Also, special value tarvals will be calculated such as null,
- * min, max and can be retrieved using the get_mode_* functions
- *
- * @return
- * The new mode or NULL on error.
- */
-ir_mode *new_ir_vector_mode(const char *name, mode_sort sort, int bit_size, unsigned num_of_elem, int sign,
- mode_arithmetic arithmetic, unsigned int modulo_shift);
-
-/**
- * Checks whether a pointer points to a mode.
- *
- * @param thing an arbitrary pointer
- *
- * @return
- * true if the thing is a mode, else false
- */
-int is_mode(void *thing);
-
-/* ********** Access methods to read mode information *********** */
-
-/** Returns the classification of the mode */
-modecode get_mode_modecode(const ir_mode *mode);
-
-/** Returns the ident* of the mode */
-ident *get_mode_ident(const ir_mode *mode);
-
-/** Returns the null-terminated name of this mode. */
-const char *get_mode_name(const ir_mode *mode);
-
-/** Returns a coarse classification of the mode. */
-mode_sort get_mode_sort(const ir_mode *mode);
-
-/** Returns the size of values of the mode in bits. */
-int get_mode_size_bits(const ir_mode *mode);
-
-/** Returns the size of values of the mode in bytes.
- * If the size is not dividable by 8 returns -1. */
-int get_mode_size_bytes(const ir_mode *mode);
-
-/** Returns the signess of a mode.
- *
- * Returns the signess of a mode: 1 if mode is signed. */
-int get_mode_sign(const ir_mode *mode);
-
-/** Returns the arithmetic of a mode */
-int get_mode_arithmetic(const ir_mode *mode);
-
-/** Get the modulo shift attribute.
- *
- * Attribute modulo shift specifies for modes of kind irms_int_number
- * whether shift applies modulo to value of bits to shift. Zero for
- * modes that are not integer.
- */
-unsigned int get_mode_modulo_shift(const ir_mode *mode);
-
-/** Return the number of vector elements.
- *
- * Attribute vector_elem specifies the number of vector elements of
- * a vector mode. For non-vector modes it returns 1 for data and 0
- * for all other modes
- */
-unsigned int get_mode_n_vector_elems(const ir_mode *mode);
-
-/** Returns the stored intermediate information. */
-void *get_mode_link(const ir_mode *mode);
-
-/** Stores new intermediate information. */
-void set_mode_link(ir_mode *mode, void *l);
-
-/**
- * Returns the smallest representable value of a given mode.
- *
- * For modes of the sort float_number this is the most negative value
- * bigger than -infinite.
- */
-tarval *get_mode_min(ir_mode *mode);
-
-/**
- * Returns the biggest representable value o f a given mode.
- *
- * For modes of the sort float_number this is the largest value lower
- * than infinite.
- */
-tarval *get_mode_max(ir_mode *mode);
-
-/**
- * Returns the value Zero represented in this mode.
- *
- * Zero is the additive neutral element and as such
- * is defined only for modes allowing addition, i.e.
- * op_pin_state_floats and ints, and references (NULL-Pointer)
- * else returns tarval_bad.
- */
-tarval *get_mode_null(ir_mode *mode);
-
-/**
- * Returns the value One, represented in this mode.
- *
- * One, being the multiplicative neutral element,
- * is defined only for modes allowing multiplication,
- * i.e. ints and floats.
- */
-tarval *get_mode_one(ir_mode *mode);
-
-/**
- * Returns the value Minus One, represented in this mode.
- *
- * Minus One is defined only for modes allowing
- * multiplication with signed values, i.e. signed ints and floats.
- */
-tarval *get_mode_minus_one(ir_mode *mode);
-
-/**
- * Returns the positive infinite value of a mode.
- *
- * This is only valid for float_numbers, other modes
- * will result in tarval_bad.
- */
-tarval *get_mode_infinite(ir_mode *mode);
-
-/**
- * Returns the NAN value of a given mode.
- *
- * This is only valid for float_numbers, other modes
- * will result in tarval_bad.
- */
-tarval *get_mode_NAN(ir_mode *mode);
-
-extern ir_mode *mode_M; /**< memory */
-
-/* -- A set of predefined, numerical modes according to Techreport 1999-44 -- */
-extern ir_mode *mode_F; /**< signed float(32) */
-extern ir_mode *mode_D; /**< signed double(64) */
-extern ir_mode *mode_E; /**< signed extended(80) */
-extern ir_mode *mode_Bs; /**< signed byte (former char) */
-extern ir_mode *mode_Bu; /**< unsigned byte (former char) */
-extern ir_mode *mode_Hs; /**< signed short integer */
-extern ir_mode *mode_Hu; /**< unsigned short integer */
-extern ir_mode *mode_Is; /**< signed integer */
-extern ir_mode *mode_Iu; /**< unsigned integer */
-extern ir_mode *mode_Ls; /**< signed long integer */
-extern ir_mode *mode_Lu; /**< unsigned long integer */
-extern ir_mode *mode_LLs; /**< signed long long integer */
-extern ir_mode *mode_LLu; /**< unsigned long long integer */
-
-extern ir_mode *mode_C; /**< 8 bit char */
-extern ir_mode *mode_U; /**< 16 bit unicode char */
-
-extern ir_mode *mode_P; /**< pointer */
-extern ir_mode *mode_P_code; /**< A pointer mode that is set by the client of libfirm. This mode
- represents the pointer size of the target machine code addresses. Is initialized
- to mode_P. */
-extern ir_mode *mode_P_data; /**< A pointer mode that is set by the client of libfirm. This mode
- represents the pointer size of the target machine data addresses. Is initialized
- to mode_P. */
-
-/* -- Auxiliary modes necessary for the Firm representation -- */
-extern ir_mode *mode_b; /**< internal boolean */
-
-extern ir_mode *mode_X; /**< execution */
-extern ir_mode *mode_BB; /**< block */
-
-extern ir_mode *mode_T; /**< tuple (none) */
-extern ir_mode *mode_ANY;/**< undefined mode */
-extern ir_mode *mode_BAD;/**< bad mode */
-
-/*@{*/
-/** Access routines for JNI Interface */
-ir_mode *get_modeF(void);
-ir_mode *get_modeD(void);
-ir_mode *get_modeE(void);
-ir_mode *get_modeBs(void);
-ir_mode *get_modeBu(void);
-ir_mode *get_modeHs(void);
-ir_mode *get_modeHu(void);
-ir_mode *get_modeIs(void);
-ir_mode *get_modeIu(void);
-ir_mode *get_modeLs(void);
-ir_mode *get_modeLu(void);
-ir_mode *get_modeLLs(void);
-ir_mode *get_modeLLu(void);
-ir_mode *get_modeC(void);
-ir_mode *get_modeU(void);
-ir_mode *get_modeP(void);
-ir_mode *get_modeb(void);
-ir_mode *get_modeX(void);
-ir_mode *get_modeBB(void);
-ir_mode *get_modeM(void);
-ir_mode *get_modeT(void);
-ir_mode *get_modeANY(void);
-ir_mode *get_modeBAD(void);
-
-/** Returns the machine specific pointer mode for code addresses. */
-ir_mode *get_modeP_code(void);
-
-/** Returns the machine specific pointer mode for data addresses. */
-ir_mode *get_modeP_data(void);
-
-/**
- * Sets the machine specific pointer mode for code addresses.
- * If not set, the predefined mode mode_P will be used.
- */
-void set_modeP_code(ir_mode *p);
-
-/**
- * Sets the machine specific pointer mode for data addresses.
- * If not set, the predefined mode mode_P will be used.
- */
-void set_modeP_data(ir_mode *p);
-
-/**
- Functions to check, whether a modecode is signed, float, int, character,
- reference, num, numP, data, datab or dataM.
-
- For more exact definitions read the corresponding pages
- in the firm documentation or the following enumeration
-
- The set of "float" is defined as:
- float = {irm_F, irm_D, irm_E}
-
- The set of "int" is defined as:
- int = {irm_Bs, irm_Bu, irm_Hs, irm_Hu, irm_Is, irm_Iu, irm_Ls, irm_Lu}
-
- The set of "character" is defined as:
- character = {irm_C, irm_U}
-
- The set of "reference" is defined as:
- reference = {irm_P}
-
- The set of "num" is defined as:
- num = {float || int}
-
- The set of "numP" is defined as:
- numP = {float || int || reference}
-
- The set of "data" is defined as:
- data = {num || character || reference}
-
- The set of "datab" is defined as:
- datab = {data || irm_b }
-
- The set of "dataM" is defined as:
- dataM = {data || irm_M}
-
- Vector "int" and "float" are defined by the arithmetic and vector_elem > 1.
-*/
-/*@}*/
-/* Test for a certain class of modes. */
-int mode_is_signed (const ir_mode *mode);
-int mode_is_float (const ir_mode *mode);
-int mode_is_int (const ir_mode *mode);
-int mode_is_character (const ir_mode *mode);
-int mode_is_reference (const ir_mode *mode);
-int mode_is_num (const ir_mode *mode);
-int mode_is_numP (const ir_mode *mode);
-int mode_is_data (const ir_mode *mode);
-int mode_is_datab (const ir_mode *mode);
-int mode_is_dataM (const ir_mode *mode);
-int mode_is_float_vector (const ir_mode *mode);
-int mode_is_int_vector (const ir_mode *mode);
-
-/** Returns true if sm can be converted to lm without loss
- according to firm definiton */
-int smaller_mode(const ir_mode *sm, const ir_mode *lm);
-
-/**
- * Returns a matching unsigned mode for a given integer signed mode.
- * Returns NULL if no matching mode exists.
- */
-ir_mode *find_unsigned_mode(const ir_mode *mode);
-
-/**
- * Returns a matching signed mode for a given integer unsigned mode.
- * Returns NULL if no matching mode exists.
- */
-ir_mode *find_signed_mode(const ir_mode *mode);
-
-/**
- * Returns an integer mode with 2*n bits for a given integer mode with n bits.
- * Returns NULL if no matching mode exists.
- */
-ir_mode *find_double_bits_int_mode(const ir_mode *mode);
-
-/**
- * Returns non-zero if the given mode honors signed zero's, i.e.,
- * a +0 and a -0 exists and handled differently.
- */
-int mode_honor_signed_zeros(const ir_mode *mode);
-
-/**
- * Returns non-zero if the given mode might overflow on unary Minus.
- */
-int mode_overflow_on_unary_Minus(const ir_mode *mode);
-
-/**
- * Returns non-zero if the mode has a reversed wrap-around
- * logic, especially (a + x) - x == a.
- * This is normally true for integer modes, not for floating
- * point modes.
- */
-int mode_wrap_around(const ir_mode *mode);
-
-/**
- * Return the signed integer equivalent mode for an reference mode.
- */
-ir_mode *get_reference_mode_signed_eq(ir_mode *mode);
-
-/**
- * Sets the signed integer equivalent mode for an reference mode.
- */
-void set_reference_mode_signed_eq(ir_mode *ref_mode, ir_mode *int_mode);
-
-/**
- * Return the unsigned integer equivalent mode for an reference mode.
- */
-ir_mode *get_reference_mode_unsigned_eq(ir_mode *mode);
-
-/**
- * Sets the unsigned integer equivalent mode for an reference mode.
- */
-void set_reference_mode_unsigned_eq(ir_mode *ref_mode, ir_mode *int_mode);
-
-#endif
#include "irmode.h"
#include "tv.h"
-/** This struct is supposed to completely define a mode. **/
+/**
+ * Contains relevant information about a mode.
+ *
+ * Necessary information about a mode is stored in this struct
+ * which is used by the tarval module to perform calculations
+ * and comparisons of values of a such described mode.
+ *
+ * ATTRIBUTES:
+ * - modecode code: An unambiguous int (enum) for the mode
+ * - ident *name: Name of this mode. Two modes are different if the name is different.
+ * - mode_sort sort: sort of mode specifying possible usage categories
+ * - int size: size of the mode in Bits.
+ * - unsigned sign:1: signedness of this mode
+ * - ... more to come
+ * - modulo_shift specifies for modes of kind irms_int_number
+ * whether shift applies modulo to value of bits to shift
+ *
+ * SEE ALSO:
+ * The tech report 1999-44 describing FIRM and predefined modes
+ * tarval.h
+ */
struct ir_mode {
firm_kind kind; /**< distinguishes this node from others */
modecode code; /**< unambiguous identifier of a mode */
#include "irnode_t.h"
#include "irgraph_t.h"
#include "irmode_t.h"
-#include "typegmod.h"
#include "irbackedge_t.h"
#include "irdump.h"
#include "irop_t.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Representation of an intermediate operation.
- * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Michael Beck
- * @version $Id$
- */
-#ifndef FIRM_IR_IRNODE_H
-#define FIRM_IR_IRNODE_H
-
-#include <stddef.h>
-
-#include "firm_common.h"
-#include "entity.h"
-#include "irop.h"
-#include "irmode.h"
-#include "dbginfo.h"
-
-/**
- * @file irnode.h
- *
- * @author Martin Trapp, Christian Schaefer
- *
- * Declarations of an ir node.
- */
-
-/**
- * @defgroup ir_node Declarations of an ir node.
- *
- * The type definition of ir_node is also in irgraph.h to resolve
- * recursion between irnode.h and irgraph.h
- *
- * ir_node - a datatype representing a Firm node
- *
- * The common fields are:
- *
- * - firm_kind - A firm_kind tag containing k_type. This is useful
- * for dynamically checking whether a node is a ir_node.
- * - 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.
- * @{
- */
-
-#ifndef _IR_NODE_TYPEDEF_
-#define _IR_NODE_TYPEDEF_
-typedef struct ir_node ir_node;
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * you can work on the graph without considering the different types
- * of nodes, it's just a big graph.
- */
-
-/**
- * Checks whether a pointer points to a ir node.
- *
- * @param thing an arbitrary pointer
- * @return non-zero if the thing is a ir mode, else zero
- */
-int is_ir_node (const void *thing);
-
-/**
- * Returns the number of predecessors without the block predecessor.
- *
- * @param node the IR-node
- */
-int get_irn_arity (const ir_node *node);
-int get_irn_intra_arity(const ir_node *node);
-int get_irn_inter_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. */
-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 */
-
-/**
- * Get the n-th predecessor of a node.
- * This function removes Id predecessors.
- * This function automatically handles intra- and interprocedural views.
- */
-ir_node *get_irn_n(const ir_node *node, int n);
-
-/**
-* Add a artificial dependency to the node.
-* The dependency is only inserted if it is not there already.
-* @param node The node.
-* @param dep The dependency target.
-* @return The index in the array (get_irn_dep() with that index returns @p dep).
-*/
-int add_irn_dep(ir_node *node, ir_node *dep);
-
-/**
- * Copy all dependencies from a node to another.
- * @param tgt The node which should be enriched.
- * @param src The node whose dependencies shall be copied.
- */
-void add_irn_deps(ir_node *tgt, ir_node *src);
-
-/**
-* Get the length of the dependency array.
-* @param node The node.
-* @return The length of the dependency array or 0 if it has not yet been allocated.
-*/
-int get_irn_deps(const ir_node *node);
-
-/**
-* Get an entry of the dependency array.
-* @param node The node.
-* @param pos The position.
-* @return The node at that position.
-*/
-ir_node *get_irn_dep(const ir_node *node, int pos);
-
-/**
-* Set an entry of the dependency array.
-* @param node The node.
-* @param pos The position.
-* @param dep The dependency target.
-*/
-void set_irn_dep(ir_node *node, int pos, ir_node *dep);
-
-
-/**
- * Get the n-th predecessor of a node in intraprocedural view.
- * Can be used always if it's know that node is not a split one.
- */
-ir_node *get_irn_intra_n(const ir_node *node, int n);
-
-/**
- * Get the n-th predecessor of a node in interprocedural view.
- */
-ir_node *get_irn_inter_n(const ir_node *node, int n);
-
-/** Replace the n-th predecessor of a node with a new one. */
-void set_irn_n(ir_node *node, int n, ir_node *in);
-/**
- * Appends a new predecessor to a node. This only works for nodes with
- * variable arity!
- * @returns the number of the new input
- */
-int add_irn_n(ir_node *node, ir_node *in);
-/* Sets the mode struct of node. */
-void set_irn_mode(ir_node *node, ir_mode *mode);
-/** Gets the mode struct of a node. */
-ir_mode *get_irn_mode(const ir_node *node);
-/** Gets the mode-enum modecode. */
-modecode get_irn_modecode(const ir_node *node);
-/** Gets the ident for a string representation of the mode .*/
-ident *get_irn_modeident(const ir_node *node);
-/** Gets the string representation of the mode .*/
-const char *get_irn_modename(const ir_node *node);
-/** Gets the opcode struct of the node. */
-ir_op *get_irn_op(const ir_node *node);
-/** Sets the opcode struct of the node. */
-void set_irn_op(ir_node *node, ir_op *op);
-/** Gets the opcode-enum of the node. */
-ir_opcode get_irn_opcode(const ir_node *node);
-/** Get the string representation of the opcode. */
-const char *get_irn_opname(const ir_node *node);
-/** Get the ident for a string representation of the opcode. */
-ident *get_irn_opident(const ir_node *node);
-/** If arg is an argument of the node, returns it's position, -1 otherwise */
-int get_irn_pred_pos(ir_node *node, ir_node *arg);
-/** Gets the visited counter of a node. */
-unsigned long get_irn_visited(const ir_node *node);
-/** Sets the visited counter of a node. */
-void set_irn_visited(ir_node *node, unsigned long visited);
-/** Sets visited to get_irg_visited(current_ir_graph). */
-void mark_irn_visited(ir_node *node);
-/** Returns 1 if visited < get_irg_visited(current_ir_graph). */
-int irn_not_visited(const ir_node *node);
-/** Returns 1 if visited >= get_irg_visited(current_ir_graph). */
-int irn_visited(const ir_node *node);
-
-/**
- * Sets the link of a node.
- * Only allowed if the graph is NOT in phase_building.
- */
-void set_irn_link(ir_node *node, void *link);
-
-/** Returns the link of a node. */
-void *get_irn_link(const ir_node *node);
-
-/** Returns the ir_graph this node belongs to. Only valid if irg
- * is in state op_pin_state_pinned (irg is only stored in the block. */
-ir_graph *get_irn_irg(const ir_node *node);
-
-/** Outputs a unique number for this node if libFIRM is compiled for
- debugging, (configure with --enable-debug) else returns address
- of node cast to long. */
-long get_irn_node_nr(const ir_node *node);
-
-/** 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.
- */
-op_pin_state get_irn_pinned(const ir_node *node);
-
-/** Set pin state for nodes with op pin state op_pin_state_exc_pinned */
-void set_irn_pinned(ir_node *node, op_pin_state state);
-
-/** Returns whether the node is currently pinned.
- *
- * If get_irn_pinned returns op_pin_state_floats and the graph the
- * node belongs to is in state op_poin_state_floats then this function
- * returns 'floats', else 'pinned'.
- */
-op_pin_state is_irn_pinned_in_irg(const ir_node *node);
-
-/**
- * IR node constructor.
- * Create a new IR node in irg, with an op, mode, arity and
- * some incoming IR nodes.
- * This constructor is used in every specific IR node constructor.
- *
- * @param db Debug info.
- * @param irg IR-graph on with this new node should be constructed.
- * @param block The block the new node belongs to
- * @param op The opcode of the new node.
- * @param mode The mode of the new node.
- * @param arity The arity of the new node, <0 if can be changed dynamically.
- * @param in An array of arity predecessor nodes.
- */
-ir_node *
-new_ir_node(dbg_info *db,
- ir_graph *irg,
- ir_node *block,
- ir_op *op,
- ir_mode *mode,
- int arity,
- ir_node *in[]);
-
-/**
- * Return the block the node belongs to. This is only
- * 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.
- *
- * 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
- * get_irn_block(). */
-ir_node *get_nodes_block (const ir_node *node);
-
-/** Sets the Block of a node. */
-void set_nodes_block (ir_node *node, ir_node *block);
-
-/**
- * @function get_irn_block()
- * @see get_nodes_block()
- */
-
-/**
- * Projection numbers for result of Start node: use for Proj nodes!
- */
-typedef enum {
- pn_Start_X_initial_exec, /**< Projection on the initial control flow. */
- pn_Start_M, /**< Projection on the initial memory. */
- pn_Start_P_frame_base, /**< Projection on the frame base pointer. */
- pn_Start_P_globals, /**< Projection on the pointer to the data segment
- containing _all_ global entities. Use for
- position independent data/code access. */
- pn_Start_P_tls, /**< Projection on the pointer to the thread local store
- segment containing _all_thread local variables. */
- pn_Start_T_args, /**< Projection on all arguments. */
- pn_Start_P_value_arg_base, /**< Pointer to region of compound value arguments as defined by
- type of this method. */
- pn_Start_max /**< number of projections from a Start */
-} pn_Start; /* Projection numbers for Start. */
-
-/** Test whether arbitrary node is frame pointer.
- *
- * Test whether arbitrary node is frame pointer, i.e. Proj(pn_Start_P_frame_base)
- * from Start. If so returns frame type, else Null. */
-ir_type *is_frame_pointer(ir_node *n);
-
-/** Test whether arbitrary node is globals pointer.
- *
- * Test whether arbitrary node is globals pointer, i.e. Proj(pn_Start_P_globals)
- * from Start. If so returns global type, else Null. */
-ir_type *is_globals_pointer(ir_node *n);
-
-/** Test whether arbitrary node is tls pointer.
- *
- * Test whether arbitrary node is tls pointer, i.e. Proj(pn_Start_P_tls)
- * from Start. If so returns tls type, else Null. */
-ir_type *is_tls_pointer(ir_node *n);
-
-/** Test whether arbitrary node is value arg base.
- *
- * Test whether arbitrary node is value arg base, i.e. Proj(pn_Start_P_value_arg_base)
- * from Start. If so returns 1, else 0. */
-int is_value_arg_pointer(ir_node *n);
-
-
-/* @@@ no more supported */
-ir_node **get_Block_cfgpred_arr(ir_node *node);
-int get_Block_n_cfgpreds(const ir_node *node);
-ir_node *get_Block_cfgpred(ir_node *node, int pos);
-void set_Block_cfgpred(ir_node *node, int pos, ir_node *pred);
-/** Get the predecessor block.
- *
- * Returns the block corresponding to the predecessor pos of block.
- *
- * There are several ambiguities we resolve with this function:
- * - The direct predecessor can be a Proj, which is not pinned.
- * We walk from the predecessor to the next pinned node
- * (skip_Proj) and return the block that node is in.
- * - If we encounter the Bad node, this function does not return
- * Start, but the Bad node.
- */
-ir_node *get_Block_cfgpred_block(ir_node *node, int pos);
-int get_Block_matured(ir_node *node);
-void set_Block_matured(ir_node *node, int matured);
-
-/** A visited flag only for block nodes.
- * @see also: get_irn_visited() inc_irg_visited() inc_irg_block_visited()*/
-unsigned long get_Block_block_visited(const ir_node *node);
-void set_Block_block_visited(ir_node *node, unsigned long visit);
-
-/**
- * Marks a block as dead but do not replace it with a Bad node.
- * Dead blocks are removed in the con
- */
-ir_node *set_Block_dead(ir_node *block);
-int is_Block_dead(const ir_node *block);
-
-/* For this current_ir_graph must be set. */
-void mark_Block_block_visited(ir_node *node);
-int Block_not_block_visited(const ir_node *node);
-int Block_block_visited(const ir_node *node);
-
-/* Set and remove interprocedural predecessors. If the interprocedural
- * predecessors are removed, the node has the same predecessors in
- * both views.
- * @@@ Maybe better: arity is zero if no cg preds. */
-void set_Block_cg_cfgpred_arr(ir_node *node, int arity, ir_node *in[]);
-void set_Block_cg_cfgpred(ir_node *node, int pos, ir_node *pred);
-/* @@@ not supported */
-ir_node **get_Block_cg_cfgpred_arr(ir_node *node);
-/** Returns the number of interprocedural predecessors. 0 if none. */
-int get_Block_cg_n_cfgpreds(ir_node *node);
-/** Return the interprocedural predecessor at position pos. */
-ir_node *get_Block_cg_cfgpred(ir_node *node, int pos);
-/** Frees the memory allocated for interprocedural predecessors. */
-void remove_Block_cg_cfgpred_arr(ir_node *node);
-
-/** Returns the extended basic block a block belongs to. */
-ir_extblk *get_Block_extbb(const ir_node *block);
-/** Sets the extended basic block a block belongs to. */
-void set_Block_extbb(ir_node *block, ir_extblk *extblk);
-
-/** Get the Macro Block header of a (sub-) block. */
-ir_node *get_Block_MacroBlock(const ir_node *block);
-
-/** Return the number of Keep alive node. */
-int get_End_n_keepalives(ir_node *end);
-
-/** Return the Keep alive node a position pos. */
-ir_node *get_End_keepalive(ir_node *end, int pos);
-
-/** Keep alive dedicated nodes. These must be either PhiM or Block nodes. */
-void add_End_keepalive (ir_node *end, ir_node *ka);
-
-/** Set the Keep alive node at position pos. */
-void set_End_keepalive(ir_node *end, int pos, ir_node *ka);
-
-/** Set new keep-alives */
-void set_End_keepalives(ir_node *end, int n, ir_node *in[]);
-
-/* Set new keep-alives from old keep-alives, skipping irn */
-void remove_End_keepalive(ir_node *end, ir_node *irn);
-
-/** Some parts of the End node are allocated separately -- their memory
- is not recovered by dead_node_elimination if a End node is dead.
- free_End() frees these data structures. */
-void free_End(ir_node *end);
-
-/** Return the target address of an IJmp */
-ir_node *get_IJmp_target(ir_node *ijmp);
-
-/** Sets the target address of an IJmp */
-void set_IJmp_target(ir_node *ijmp, ir_node *tgt);
-
-/* We distinguish three kinds of Cond nodes. These can be distinguished
- by the mode of the selector operand and an internal flag of type cond_kind.
- First we distinguish binary Conds and switch Conds.
- A binary Cond has as selector a boolean value. Proj(0) projects the control
- flow for case "False", Proj(1) the control flow for "True". A binary Cond
- is recognized by the boolean selector.
- The switch Cond has as selector an unsigned integer. It produces as result
- an n+1 Tuple (cf0, ... , cfn) of control flows.
- We differ two flavors of this Cond. The first, the dense Cond, passes
- control along output i if the selector value is i, 0 <= i <= n. If the
- selector value is >n it passes control along output n.
- The second Cond flavor differences in the treatment of cases not specified in
- the source program. It magically knows about the existence of Proj nodes.
- It only passes control along output i, 0 <= i <= n, if a node Proj(Cond, i)
- exists. Else it passes control along output n (even if this Proj does not
- exist.) This Cond we call "fragmentary". There is a special constructor
- new_defaultProj that automatically sets the flavor.
- The two switch flavors are distinguished by a flag of type cond_kind.
- Default flavor is "dense"
-*/
-typedef enum {
- dense, /**< Default. Missing Proj nodes are dead control flow. */
- fragmentary /**< Special. No control flow optimizations allowed. Missing
- Proj nodes mean default control flow, i.e., Proj(n). */
-} cond_kind;
-
-ir_node *get_Cond_selector(ir_node *node);
-void set_Cond_selector(ir_node *node, ir_node *selector);
-cond_kind get_Cond_kind(ir_node *node);
-void set_Cond_kind(ir_node *node, cond_kind kind);
-long get_Cond_defaultProj(ir_node *node);
-
-/**
- * Projection numbers for conditions.
- */
-typedef enum {
- pn_Cond_false, /**< Control flow if operand is "false". */
- pn_Cond_true, /**< Control flow if operand is "true". */
- pn_Cond_max /**< number of projections from a Cond */
-} pn_Cond; /* Projection numbers for Cond. */
-
-ir_node *get_Return_mem(ir_node *node);
-void set_Return_mem(ir_node *node, ir_node *mem);
-ir_node **get_Return_res_arr(ir_node *node);
-int get_Return_n_ress(ir_node *node);
-ir_node *get_Return_res(ir_node *node, int pos);
-void set_Return_res(ir_node *node, int pos, ir_node *res);
-
-/**
- * Possible classes for constant classification.
- */
-typedef enum {
- CNST_NULL = 0, /**< The node is a const(0). */
- CNST_ONE = +1, /**< The node is a const(1). */
- CNST_ALL_ONE = -1, /**< The node is a const(11111...). */
- CNST_OTHER = 2, /**< The tarval of the const has another value. */
- CNST_SYMCONST = 3, /**< The node is symconst. */
- CNST_NO_CONST = 4 /**< The node is no const at all. */
-} cnst_classify_t;
-
-tarval *get_Const_tarval(const ir_node *node);
-void set_Const_tarval(ir_node *node, tarval *con);
-
-/**
- * Classify a node concerning constant properties.
- * @param irn A node to check for.
- * @return Constant properties of that node.
- */
-cnst_classify_t classify_Const(ir_node *irn);
-
-/** Returns the source language type of a Const node.
- * Must be an atomic type. Mode of type must be mode of node.
- */
-ir_type *get_Const_type(ir_node *node);
-
-/** Sets the source language type of a Const node. */
-void set_Const_type(ir_node *node, ir_type *tp);
-
-/** This enum names the three different kinds of symbolic Constants
- represented by SymConst. The content of the attribute type_or_id
- depends on this tag. Use the proper access routine after testing
- this flag. */
-typedef enum {
- symconst_type_tag, /**< The SymConst is a type tag for the given type.
- symconst_symbol is type *. */
- symconst_type_size, /**< The SymConst is the size of the given type.
- symconst_symbol is type *. */
- symconst_type_align, /**< The SymConst is the alignment of the given type.
- symconst_symbol is type *. */
- symconst_addr_name, /**< The SymConst is a symbolic pointer to be filled in
- by the linker. The pointer is represented by a string.
- symconst_symbol is ident *. */
- symconst_addr_ent, /**< The SymConst is a symbolic pointer to be filled in
- by the linker. The pointer is represented by an entity.
- symconst_symbol is entity *. */
- symconst_ofs_ent, /**< The SymConst is the offset of its entity in the entities
- owner type. */
- symconst_enum_const /**< The SymConst is a enumeration constant of an
- enumeration type. */
-} symconst_kind;
-
-/** Returns non-zero if s symconst kind has a type attribute */
-#define SYMCONST_HAS_TYPE(kind) ((kind) <= symconst_type_align)
-
-/** Returns non-zero if s symconst kind has an ident attribute */
-#define SYMCONST_HAS_ID(kind) ((kind) == symconst_addr_name)
-
-/** Returns non-zero if s symconst kind has an entity attribute */
-#define SYMCONST_HAS_ENT(kind) ((kind) == symconst_addr_ent || (kind) == symconst_ofs_ent)
-
-/** Returns non-zero if s symconst kind has an enum_const attribute */
-#define SYMCONST_HAS_ENUM(kind) ((kind) == symconst_enum_const)
-
-/** SymConst attribute.
- *
- * This union contains the symbolic information represented by the node.
- */
-typedef union symconst_symbol {
- ir_type *type_p; /**< the type of a symconst */
- ident *ident_p; /**< the ident of a symconst */
- ir_entity *entity_p; /**< the entity of a symconst */
- ir_enum_const *enum_p; /**< the enumeration constant of a symconst */
-} symconst_symbol;
-
-/** Get the kind of the SymConst. */
-symconst_kind get_SymConst_kind(const ir_node *node);
-/** Set the kind of the SymConst. */
-void set_SymConst_kind(ir_node *node, symconst_kind num);
-
-/** Only to access SymConst of kind type_tag or size. Else assertion: */
-ir_type *get_SymConst_type(ir_node *node);
-void set_SymConst_type(ir_node *node, ir_type *tp);
-
-/** Only to access SymConst of kind addr_name. Else assertion: */
-ident *get_SymConst_name(const ir_node *node);
-void set_SymConst_name(ir_node *node, ident *name);
-
-/** Only to access SymConst of kind addr_ent. Else assertion: */
-ir_entity *get_SymConst_entity(const ir_node *node);
-void set_SymConst_entity(ir_node *node, ir_entity *ent);
-
-/** Only to access SymConst of kind symconst_enum_const. Else assertion: */
-ir_enum_const *get_SymConst_enum(const ir_node *node);
-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... */
-union symconst_symbol get_SymConst_symbol(const ir_node *node);
-void set_SymConst_symbol(ir_node *node,
- union symconst_symbol sym);
-
-/** Access the type of the value represented by the SymConst.
- *
- * Example: primitive type int for SymConst size. */
-ir_type *get_SymConst_value_type(ir_node *node);
-void set_SymConst_value_type(ir_node *node, ir_type *tp);
-
-ir_node *get_Sel_mem(ir_node *node);
-void set_Sel_mem(ir_node *node, ir_node *mem);
-ir_node *get_Sel_ptr(ir_node *node); /* ptr to the object to select from */
-void set_Sel_ptr(ir_node *node, ir_node *ptr);
-ir_node **get_Sel_index_arr(ir_node *node);
-int get_Sel_n_indexs(ir_node *node);
-ir_node *get_Sel_index(ir_node *node, int pos);
-void set_Sel_index(ir_node *node, int pos, ir_node *index);
-ir_entity *get_Sel_entity(ir_node *node); /* entity to select */
-void set_Sel_entity (ir_node *node, ir_entity *ent);
-
-/**
- * Projection numbers for result of Call node: use for Proj nodes!
- */
-typedef enum {
- pn_Call_M_regular = 0, /**< The memory result. */
- pn_Call_X_regular = 1, /**< The control flow result when no exception occurs. */
- pn_Call_X_except = 2, /**< The control flow result branching to the exception handler. */
- pn_Call_T_result = 3, /**< The tuple containing all (0, 1, 2, ...) results. */
- pn_Call_M_except = 4, /**< The memory result in case the called method terminated with
- an exception. */
- pn_Call_P_value_res_base = 5,/**< A pointer to the memory region containing copied results
- passed by value (for compound result types). */
- pn_Call_max = 6 /**< number of projections from a Call */
-} pn_Call; /* Projection numbers for Call. */
-#define pn_Call_M pn_Call_M_regular
-
-ir_node *get_Call_mem(ir_node *node);
-void set_Call_mem(ir_node *node, ir_node *mem);
-ir_node *get_Call_ptr(ir_node *node);
-void set_Call_ptr(ir_node *node, ir_node *ptr);
-ir_node **get_Call_param_arr(ir_node *node);
-/** Gets the number of parameters of a call. */
-int get_Call_n_params(ir_node *node);
-/** Gets the call parameter at position pos. */
-ir_node *get_Call_param(ir_node *node, int pos);
-/** Sets the call parameter at position pos. */
-void set_Call_param(ir_node *node, int pos, ir_node *param);
-/** Gets the type of a call. */
-ir_type *get_Call_type(ir_node *node);
-/** Sets the type of a call. */
-void set_Call_type(ir_node *node, ir_type *tp);
-/** Gets the arity of a call. Identical to get_Call_n_params(). */
-int get_Call_arity(ir_node *node);
-
-/** Set, get and remove the callee information for a Call node.
- *
- * The callee information lists all method entities that can be called
- * from this node. If the address expression can not be analyzed fully,
- * e.g., as entities can be called that are not in the compilation unit,
- * the array contains the unknown_entity. The array contains only entities
- * with peculiarity_existent, but with all kinds of visibility. The entities
- * not necessarily contain an irg.
- *
- * The array is only accessible if callee information is valid. See flag
- * in graph.
- *
- * The memory allocated for the array is managed automatically, i.e., it must
- * not be freed if the Call node is removed from the graph.
- *
- * @param node A Call node.
- */
-int Call_has_callees(ir_node *node);
-int get_Call_n_callees(ir_node *node);
-ir_entity *get_Call_callee(ir_node *node, int pos);
-
-/** Set the full callee array.
- *
- * The passed array is copied. Assumes current_ir_graph set properly! */
-void set_Call_callee_arr(ir_node *node, const int n, ir_entity **arr);
-void remove_Call_callee_arr(ir_node *node);
-
-ir_node *get_CallBegin_ptr(ir_node *node);
-void set_CallBegin_ptr(ir_node *node, ir_node *ptr);
-ir_node *get_CallBegin_call(ir_node *node);
-void set_CallBegin_call(ir_node *node, ir_node *call);
-
-/* 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, Quot, DivMod, Div, Mod, And, Or, Eor, Shl,
- Shr, Shrs, Rot, Cmp */
-int is_unop(const ir_node *node);
-ir_node *get_unop_op(const ir_node *node);
-void set_unop_op(ir_node *node, ir_node *op);
-int is_binop(const ir_node *node);
-ir_node *get_binop_left(const ir_node *node);
-void set_binop_left(ir_node *node, ir_node *left);
-ir_node *get_binop_right(const ir_node *node);
-void set_binop_right(ir_node *node, ir_node *right);
-
-ir_node *get_Add_left(const ir_node *node);
-void set_Add_left(ir_node *node, ir_node *left);
-ir_node *get_Add_right(const ir_node *node);
-void set_Add_right(ir_node *node, ir_node *right);
-
-ir_node *get_Sub_left(const ir_node *node);
-void set_Sub_left(ir_node *node, ir_node *left);
-ir_node *get_Sub_right(const ir_node *node);
-void set_Sub_right(ir_node *node, ir_node *right);
-
-ir_node *get_Minus_op(const ir_node *node);
-void set_Minus_op(ir_node *node, ir_node *op);
-
-ir_node *get_Mul_left(const ir_node *node);
-void set_Mul_left(ir_node *node, ir_node *left);
-ir_node *get_Mul_right(const ir_node *node);
-void set_Mul_right(ir_node *node, ir_node *right);
-
-ir_node *get_Quot_left(const ir_node *node);
-void set_Quot_left(ir_node *node, ir_node *left);
-ir_node *get_Quot_right(const ir_node *node);
-void set_Quot_right(ir_node *node, ir_node *right);
-ir_node *get_Quot_mem(ir_node *node);
-void set_Quot_mem(ir_node *node, ir_node *mem);
-ir_mode *get_Quot_resmode(const ir_node *node);
-void set_Quot_resmode(ir_node *node, ir_mode *mode);
-
-/**
- * Projection numbers for Quot: use for Proj nodes!
- */
-typedef enum {
- pn_Quot_M, /**< Memory result. */
- pn_Quot_X_regular, /**< Execution result if no exception occurred. */
- pn_Quot_X_except, /**< Execution result if exception occurred. */
- pn_Quot_res, /**< Result of computation. */
- pn_Quot_max /**< number of projections from a Quot */
-} pn_Quot; /* Projection numbers for Quot. */
-
-ir_node *get_DivMod_left(const ir_node *node);
-void set_DivMod_left(ir_node *node, ir_node *left);
-ir_node *get_DivMod_right(const ir_node *node);
-void set_DivMod_right(ir_node *node, ir_node *right);
-ir_node *get_DivMod_mem(ir_node *node);
-void set_DivMod_mem(ir_node *node, ir_node *mem);
-ir_mode *get_DivMod_resmode(const ir_node *node);
-void set_DivMod_resmode(ir_node *node, ir_mode *mode);
-
-/**
- * Projection numbers for DivMod: use for Proj nodes!
- */
-typedef enum {
- pn_DivMod_M, /**< Memory result. */
- pn_DivMod_X_regular, /**< Execution result if no exception occurred. */
- pn_DivMod_X_except, /**< Execution result if exception occurred. */
- pn_DivMod_res_div, /**< Result of computation a / b. */
- pn_DivMod_res_mod, /**< Result of computation a % b. */
- pn_DivMod_max /**< number of projections from a DivMod */
-} pn_DivMod; /* Projection numbers for DivMod. */
-
-ir_node *get_Div_left(const ir_node *node);
-void set_Div_left(ir_node *node, ir_node *left);
-ir_node *get_Div_right(const ir_node *node);
-void set_Div_right(ir_node *node, ir_node *right);
-ir_node *get_Div_mem(ir_node *node);
-void set_Div_mem(ir_node *node, ir_node *mem);
-ir_mode *get_Div_resmode(const ir_node *node);
-void set_Div_resmode(ir_node *node, ir_mode *mode);
-
-/**
- * Projection numbers for Div: use for Proj nodes!
- */
-typedef enum {
- pn_Div_M, /**< Memory result. */
- pn_Div_X_regular, /**< Execution result if no exception occurred. */
- pn_Div_X_except, /**< Execution result if exception occurred. */
- pn_Div_res, /**< Result of computation. */
- pn_Div_max /**< number of projections from a Div */
-} pn_Div; /* Projection numbers for Div. */
-
-ir_node *get_Mod_left(const ir_node *node);
-void set_Mod_left(ir_node *node, ir_node *left);
-ir_node *get_Mod_right(const ir_node *node);
-void set_Mod_right(ir_node *node, ir_node *right);
-ir_node *get_Mod_mem(ir_node *node);
-void set_Mod_mem(ir_node *node, ir_node *mem);
-ir_mode *get_Mod_resmode(const ir_node *node);
-void set_Mod_resmode(ir_node *node, ir_mode *mode);
-
-/**
- * Projection numbers for Mod: use for Proj nodes!
- */
-typedef enum {
- pn_Mod_M, /**< Memory result. */
- pn_Mod_X_regular, /**< Execution result if no exception occurred. */
- pn_Mod_X_except, /**< Execution result if exception occurred. */
- pn_Mod_res, /**< Result of computation. */
- pn_Mod_max /**< number of projections from a Mod */
-} pn_Mod; /* Projection numbers for Mod. */
-
-ir_node *get_Abs_op(const ir_node *node);
-void set_Abs_op(ir_node *node, ir_node *op);
-
-ir_node *get_And_left(const ir_node *node);
-void set_And_left(ir_node *node, ir_node *left);
-ir_node *get_And_right(const ir_node *node);
-void set_And_right(ir_node *node, ir_node *right);
-
-ir_node *get_Or_left(const ir_node *node);
-void set_Or_left(ir_node *node, ir_node *left);
-ir_node *get_Or_right(const ir_node *node);
-void set_Or_right(ir_node *node, ir_node *right);
-
-ir_node *get_Eor_left(const ir_node *node);
-void set_Eor_left(ir_node *node, ir_node *left);
-ir_node *get_Eor_right(const ir_node *node);
-void set_Eor_right(ir_node *node, ir_node *right);
-
-ir_node *get_Not_op(const ir_node *node);
-void set_Not_op(ir_node *node, ir_node *op);
-
-/**
- * Projection numbers for Cmp are defined several times.
- * The bit patterns are used for various tests, so don't change.
- * The "unordered" values are possible results of comparing
- * floating point numbers.
- * Note that the encoding is imported, so do NOT change the order.
- */
-typedef enum {
- pn_Cmp_False = 0, /**< false */
- pn_Cmp_Eq = 1, /**< equal */
- pn_Cmp_Lt = 2, /**< less */
- pn_Cmp_Le = pn_Cmp_Eq|pn_Cmp_Lt, /**< less or equal */
- pn_Cmp_Gt = 4, /**< greater */
- pn_Cmp_Ge = pn_Cmp_Eq|pn_Cmp_Gt, /**< greater or equal */
- pn_Cmp_Lg = pn_Cmp_Lt|pn_Cmp_Gt, /**< less or greater */
- pn_Cmp_Leg = pn_Cmp_Lt|pn_Cmp_Eq|pn_Cmp_Gt, /**< less, equal or greater = ordered */
- pn_Cmp_Uo = 8, /**< unordered */
- pn_Cmp_Ue = pn_Cmp_Uo|pn_Cmp_Eq, /**< unordered or equal */
- pn_Cmp_Ul = pn_Cmp_Uo|pn_Cmp_Lt, /**< unordered or less */
- pn_Cmp_Ule = pn_Cmp_Uo|pn_Cmp_Eq|pn_Cmp_Lt, /**< unordered, less or equal */
- pn_Cmp_Ug = pn_Cmp_Uo|pn_Cmp_Gt, /**< unordered or greater */
- pn_Cmp_Uge = pn_Cmp_Uo|pn_Cmp_Eq|pn_Cmp_Gt, /**< unordered, greater or equal */
- pn_Cmp_Ne = pn_Cmp_Uo|pn_Cmp_Lt|pn_Cmp_Gt, /**< unordered, less or greater = not equal */
- pn_Cmp_True = 15 /**< true */
- /* not_mask = Leg*/ /* bits to flip to negate comparison * @@ hack for JNI interface */
-} pn_Cmp; /* Projection numbers for Cmp */
-/* #define not_mask pn_Cmp_Leg */
-
-/** returns the pnc name from an pnc constant */
-const char *get_pnc_string(int pnc);
-
-/** Calculates the negated (Complement(R)) pnc condition. */
-int get_negated_pnc(int pnc, ir_mode *mode);
-
-/** Calculates the inversed (R^-1) pnc condition, i.e., "<" --> ">" */
-int get_inversed_pnc(int pnc);
-
-ir_node *get_Cmp_left(const ir_node *node);
-void set_Cmp_left(ir_node *node, ir_node *left);
-ir_node *get_Cmp_right(const ir_node *node);
-void set_Cmp_right(ir_node *node, ir_node *right);
-
-ir_node *get_Shl_left(const ir_node *node);
-void set_Shl_left(ir_node *node, ir_node *left);
-ir_node *get_Shl_right(const ir_node *node);
-void set_Shl_right(ir_node *node, ir_node *right);
-
-ir_node *get_Shr_left(const ir_node *node);
-void set_Shr_left(ir_node *node, ir_node *left);
-ir_node *get_Shr_right(const ir_node *node);
-void set_Shr_right(ir_node *node, ir_node *right);
-
-ir_node *get_Shrs_left(const ir_node *node);
-void set_Shrs_left(ir_node *node, ir_node *left);
-ir_node *get_Shrs_right(const ir_node *node);
-void set_Shrs_right(ir_node *node, ir_node *right);
-
-ir_node *get_Rot_left(const ir_node *node);
-void set_Rot_left(ir_node *node, ir_node *left);
-ir_node *get_Rot_right(const ir_node *node);
-void set_Rot_right(ir_node *node, ir_node *right);
-
-ir_node *get_Conv_op(const ir_node *node);
-void set_Conv_op(ir_node *node, ir_node *op);
-int get_Conv_strict(ir_node *node);
-void set_Conv_strict(ir_node *node, int flag);
-
-/* Does Cast need a mem operator?
- * Cast should only depend on the type, not on the state of an
- * entity. But: we initialize various fields after Alloc, that
- * are accessed in the cast. This required some precaution, to
- * get the right memory into the Loads generated from the cast.
- */
-ir_node *get_Cast_op(const ir_node *node);
-void set_Cast_op(ir_node *node, ir_node *op);
-ir_type *get_Cast_type(ir_node *node);
-void set_Cast_type(ir_node *node, ir_type *to_tp);
-
-/** Checks for upcast.
- *
- * Returns true if the Cast node casts a class type to a super type.
- * Works also for pointers to classes (recursively).
- *
- * Needs typeinfo calculated.
- */
-int is_Cast_upcast(ir_node *node);
-
-/** Checks for downcast.
- *
- * Returns true if the Cast node casts a class type to a sub type.
- * Works also for pointers to classes (recursively).
- *
- * Needs typeinfo calculated.
- */
-int is_Cast_downcast(ir_node *node);
-
-
-/** Returns true if n is Phi or Filter in interprocedural_view.
- Returns false if irg in phase building and the Phi has zero
- predecessors: it's a Phi0. */
-int is_Phi(const ir_node *n);
-/** Returns true if irg in phase building and the Phi has zero
- predecessors: it's a Phi0. */
-int is_Phi0(const ir_node *n);
-/* These routines also work for Filter nodes in interprocedural view. */
-ir_node **get_Phi_preds_arr(ir_node *node);
-int get_Phi_n_preds(const ir_node *node);
-ir_node *get_Phi_pred(const ir_node *node, int pos);
-void set_Phi_pred(ir_node *node, int pos, ir_node *pred);
-
-ir_node *get_Filter_pred(ir_node *node);
-void set_Filter_pred(ir_node *node, ir_node *pred);
-long get_Filter_proj(ir_node *node);
-void set_Filter_proj(ir_node *node, long proj);
-/* set the interprocedural predecessors, ...d_arr uses current_ir_graph.
- * @@@ Maybe better: arity is zero if no cg preds. */
-void set_Filter_cg_pred_arr(ir_node * node, int arity, ir_node ** in);
-void set_Filter_cg_pred(ir_node * node, int pos, ir_node * pred);
-int get_Filter_n_cg_preds(ir_node *node);
-ir_node *get_Filter_cg_pred(ir_node *node, int pos);
-
-/** Return true if parameter is a memory operation.
- *
- * A memory operation is an operation that changes the
- * memory. I.e., a Load or a Store operation.
- */
-int is_memop(ir_node *node);
-ir_node *get_memop_mem(ir_node *node);
-void set_memop_mem(ir_node *node, ir_node *mem);
-ir_node *get_memop_ptr(ir_node *node);
-void set_memop_ptr(ir_node *node, ir_node *ptr);
-
-/**
- * Projection numbers for Load: use for Proj nodes!
- */
-typedef enum {
- pn_Load_M, /**< Memory result. */
- pn_Load_X_regular, /**< Execution result if no exception occurred. */
- pn_Load_X_except, /**< Execution result if exception occurred. */
- pn_Load_res, /**< Result of load operation. */
- pn_Load_max /**< number of projections from a Load */
-} pn_Load; /* Projection numbers for Load. */
-
-ir_node *get_Load_mem(ir_node *node);
-void set_Load_mem(ir_node *node, ir_node *mem);
-ir_node *get_Load_ptr(ir_node *node);
-void set_Load_ptr(ir_node *node, ir_node *ptr);
-ir_mode *get_Load_mode(ir_node *node);
-void set_Load_mode(ir_node *node, ir_mode *mode);
-ir_volatility get_Load_volatility(ir_node *node);
-void set_Load_volatility(ir_node *node, ir_volatility volatility);
-
-/**
- * Projection numbers for Store: use for Proj nodes!
- */
-typedef enum {
- pn_Store_M, /**< Memory result. */
- pn_Store_X_regular, /**< Execution result if no exception occurred. */
- pn_Store_X_except, /**< Execution result if exception occurred. */
- pn_Store_max /**< number of projections from a Store */
-} pn_Store; /* Projection numbers for Store. */
-
-ir_node *get_Store_mem(ir_node *node);
-void set_Store_mem(ir_node *node, ir_node *mem);
-ir_node *get_Store_ptr(ir_node *node);
-void set_Store_ptr(ir_node *node, ir_node *ptr);
-ir_node *get_Store_value(ir_node *node);
-void set_Store_value(ir_node *node, ir_node *value);
-ir_volatility get_Store_volatility(ir_node *node);
-void set_Store_volatility(ir_node *node, ir_volatility volatility);
-
-/**
- * Projection numbers for Alloc: use for Proj nodes!
- */
-typedef enum {
- pn_Alloc_M, /**< Memory result. */
- pn_Alloc_X_regular, /**< Execution result if no exception occurred. */
- pn_Alloc_X_except, /**< Execution result if exception occurred. */
- pn_Alloc_res, /**< Result of allocation. */
- pn_Alloc_max /**< number of projections from an Alloc */
-} pn_Alloc; /* Projection numbers for Alloc. */
-
-ir_node *get_Alloc_mem(ir_node *node);
-void set_Alloc_mem(ir_node *node, ir_node *mem);
-ir_node *get_Alloc_size(ir_node *node);
-void set_Alloc_size(ir_node *node, ir_node *size);
-ir_type *get_Alloc_type(ir_node *node);
-void set_Alloc_type(ir_node *node, ir_type *tp);
-
-/** The allocation place. */
-typedef enum {
- stack_alloc, /**< Alloc allocates the object on the stack. */
- heap_alloc /**< Alloc allocates the object on the heap. */
-} where_alloc;
-
-where_alloc get_Alloc_where(ir_node *node);
-void set_Alloc_where(ir_node *node, where_alloc where);
-
-ir_node *get_Free_mem(ir_node *node);
-void set_Free_mem(ir_node *node, ir_node *mem);
-ir_node *get_Free_ptr(ir_node *node);
-void set_Free_ptr(ir_node *node, ir_node *ptr);
-ir_node *get_Free_size(ir_node *node);
-void set_Free_size(ir_node *node, ir_node *size);
-ir_type *get_Free_type(ir_node *node);
-void set_Free_type(ir_node *node, ir_type *tp);
-
-where_alloc get_Free_where(ir_node *node);
-void set_Free_where(ir_node *node, where_alloc where);
-
-ir_node **get_Sync_preds_arr(ir_node *node);
-int get_Sync_n_preds(ir_node *node);
-ir_node *get_Sync_pred(ir_node *node, int pos);
-void set_Sync_pred(ir_node *node, int pos, ir_node *pred);
-void add_Sync_pred(ir_node *node, ir_node *pred);
-
-/** Returns the source language type of a Proj node.
- * Must be an atomic type. Mode of type must be mode of node.
- */
-ir_type *get_Proj_type(ir_node *node);
-
-/** Return the predecessor of a Proj node. */
-ir_node *get_Proj_pred(const ir_node *node);
-void set_Proj_pred(ir_node *node, ir_node *pred);
-/** Return the projection number of a Proj node. */
-long get_Proj_proj(const ir_node *node);
-void set_Proj_proj(ir_node *node, long proj);
-long get_VProj_proj(const ir_node *node);
-void set_VProj_proj(ir_node *node, long value);
-
-
-ir_node **get_Tuple_preds_arr(ir_node *node);
-int get_Tuple_n_preds(ir_node *node);
-ir_node *get_Tuple_pred(ir_node *node, int pos);
-void set_Tuple_pred(ir_node *node, int pos, ir_node *pred);
-
-ir_node *get_Id_pred(ir_node *node);
-void set_Id_pred(ir_node *node, ir_node *pred);
-
-/** Confirm has a single result and returns 'value' unchanged.
- * The node expresses a restriction on 'value':
- * 'value' 'cmp' 'bound' == true. */
-ir_node *get_Confirm_value(ir_node *node);
-void set_Confirm_value(ir_node *node, ir_node *value);
-ir_node *get_Confirm_bound(ir_node *node);
-void set_Confirm_bound(ir_node *node, ir_node *bound);
-pn_Cmp get_Confirm_cmp(ir_node *node);
-void set_Confirm_cmp(ir_node *node, pn_Cmp cmp);
-
-/*
- * Mux Support: Note that Psi nodes with one condition can be handled
- * like Mux nodes, and the access functions work as expected.
- */
-ir_node *get_Mux_sel(ir_node *node);
-void set_Mux_sel(ir_node *node, ir_node *sel);
-ir_node *get_Mux_false(ir_node *node);
-void set_Mux_false(ir_node *node, ir_node *ir_false);
-ir_node *get_Mux_true (ir_node *node);
-void set_Mux_true (ir_node *node, ir_node *ir_true);
-
-ir_node *get_Psi_cond(ir_node *node, int pos);
-void set_Psi_cond(ir_node *node, int pos, ir_node *cond);
-ir_node *get_Psi_val(ir_node *node, int pos);
-void set_Psi_val(ir_node *node, int pos, ir_node *val);
-ir_node *get_Psi_default(ir_node *node);
-void set_Psi_default(ir_node *node, ir_node *val);
-int get_Psi_n_conds(ir_node *node);
-
-/**
- * Projection numbers for result of CopyB node: use for Proj nodes!
- */
-typedef enum {
- pn_CopyB_M_regular = 0, /**< The memory result. */
- pn_CopyB_X_regular = 1, /**< Execution result if no exception occurred. */
- pn_CopyB_X_except = 2, /**< The control flow result branching to the exception handler */
- pn_CopyB_M_except = 3, /**< The memory result in case the runtime function terminated with
- an exception */
- pn_CopyB_max = 4 /**< number of projections from a CopyB */
-} pn_CopyB; /* Projection numbers for CopyB. */
-#define pn_CopyB_M pn_CopyB_M_regular
-
-ir_node *get_CopyB_mem(ir_node *node);
-void set_CopyB_mem(ir_node *node, ir_node *mem);
-ir_node *get_CopyB_dst(ir_node *node);
-void set_CopyB_dst(ir_node *node, ir_node *dst);
-ir_node *get_CopyB_src(ir_node *node);
-void set_CopyB_src(ir_node *node, ir_node *src);
-ir_type *get_CopyB_type(ir_node *node);
-void set_CopyB_type(ir_node *node, ir_type *data_type);
-
-/**
- * Projection numbers for result of InstOf node: use for Proj nodes!
- */
-typedef enum {
- pn_InstOf_M_regular = 0, /**< The memory result. */
- pn_InstOf_X_regular = 1, /**< Execution result if no exception occurred. */
- pn_InstOf_X_except = 2, /**< The control flow result branching to the exception handler */
- pn_InstOf_res = 3, /**< The checked object pointer. */
- pn_InstOf_M_except = 4, /**< The memory result in case the runtime function terminated with
- an exception */
- pn_InstOf_max = 5 /**< number of projections from an InstOf */
-} pn_InstOf;
-#define pn_InstOf_M pn_InstOf_M_regular
-
-/** InstOf access */
-ir_type *get_InstOf_type(ir_node *node);
-void set_InstOf_type(ir_node *node, ir_type *type);
-ir_node *get_InstOf_store(ir_node *node);
-void set_InstOf_store(ir_node *node, ir_node *obj);
-ir_node *get_InstOf_obj(ir_node *node);
-void set_InstOf_obj(ir_node *node, ir_node *obj);
-
-/**
- * Projection numbers for Raise.
- */
-typedef enum {
- pn_Raise_X = 0, /**< The control flow to the exception handler. */
- pn_Raise_M = 1, /**< The Memory result. */
- pn_Raise_max /**< number of projections from a Raise */
-} pn_Raise; /* Projection numbers for Raise. */
-
-ir_node *get_Raise_mem(ir_node *node);
-void set_Raise_mem(ir_node *node, ir_node *mem);
-ir_node *get_Raise_exo_ptr(ir_node *node); /* PoinTeR to EXception Object */
-void set_Raise_exo_ptr(ir_node *node, ir_node *exoptr);
-
-/**
- * Projection numbers for result of Bound node: use for Proj nodes!
- */
-typedef enum {
- pn_Bound_M = 0, /**< The memory result. */
- pn_Bound_X_regular = 1, /**< Execution result if no exception occurred. */
- pn_Bound_X_except = 2, /**< The control flow result branching to the exception handler */
- pn_Bound_res = 3, /**< The checked index. */
- pn_Bound_max = 4 /**< number of projections from a Bound */
-} pn_Bound;
-
-/** Returns the memory input of a Bound operation. */
-ir_node *get_Bound_mem(ir_node *bound);
-void set_Bound_mem(ir_node *bound, ir_node *mem);
-
-/** Returns the index input of a Bound operation. */
-ir_node *get_Bound_index(ir_node *bound);
-void set_Bound_index(ir_node *bound, ir_node *idx);
-
-/** Returns the lower bound input of a Bound operation. */
-ir_node *get_Bound_lower(ir_node *bound);
-void set_Bound_lower(ir_node *bound, ir_node *lower);
-
-/** Returns the upper bound input of a Bound operation. */
-ir_node *get_Bound_upper(ir_node *bound);
-void set_Bound_upper(ir_node *bound, ir_node *upper);
-
-/** Return the operand of a Pin node. */
-ir_node *get_Pin_op(const ir_node *pin);
-void set_Pin_op(ir_node *pin, ir_node *node);
-
-/** A input/output constraint attribute */
-typedef struct {
- unsigned pos; /**< The inputs/output position for this constraint. */
- ident *constraint; /**< The constraint for this input/output. */
-} ir_asm_constraint;
-
-/** Return the assembler text of an ASM pseudo node. */
-const char *get_ASM_text(const ir_node *node);
-/** Return the number of input constraints for an ASM node. */
-int get_ASM_n_input_constraints(const ir_node *node);
-/** Return the input constraints for an ASM node. */
-const ir_asm_constraint *get_ASM_input_constraints(const ir_node *node);
-/** Return the number of output constraints for an ASM node. */
-int get_ASM_n_output_constraints(const ir_node *node);
-/** Return the output constraints for an ASM node. */
-const ir_asm_constraint *get_ASM_output_constraints(const ir_node *node);
-/** Return the number of clobbered registers for an ASM node. */
-int get_ASM_n_clobbers(const ir_node *node);
-/** Return the list of clobbered registers for an ASM node. */
-ident **get_ASM_clobbers(const ir_node *node);
-
-/*
- *
- * NAME Auxiliary routines
- *
- */
-
-/** Returns operand of node if node is a Proj. */
-ir_node *skip_Proj(ir_node *node);
-/** Returns operand of node if node is a Proj. */
-const ir_node *skip_Proj_const(const ir_node *node);
-/** Returns operand of node if node is a Id. */
-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. */
-ir_node *skip_Tuple(ir_node *node);
-/** returns operand of node if node is a Cast. */
-ir_node *skip_Cast(ir_node *node);
-/** Returns operand of node if node is a Confirm */
-ir_node *skip_Confirm(ir_node *node);
-/** Skip all high-level Operations. */
-ir_node *skip_HighLevel(ir_node *node);
-/** Returns true if irn is a Const node. */
-int is_Const(const ir_node *node);
-/** Returns true if a node is a Conv node. */
-int is_Conv(const ir_node *node);
-/** Returns true if node is a Bad node. */
-int is_Bad(const ir_node *node);
-/** Returns true if node is a NoMem node. */
-int is_NoMem(const ir_node *node);
-/** Returns true if node is a Start node. */
-int is_Start(const ir_node *node);
-/** Returns true if node is a Mod node. */
-int is_Mod(const ir_node *node);
-/** Returns true if node is a Div node. */
-int is_Div(const ir_node *node);
-/** Returns true if node is a DivMod node. */
-int is_DivMod(const ir_node *node);
-/** Returns true if node is a Quot node. */
-int is_Quot(const ir_node *node);
-/** Returns true if node is an Add node. */
-int is_Add(const ir_node *node);
-/** Returns true if node is a Sub node. */
-int is_Sub(const ir_node *node);
-/** Returns true if the node is not a Block */
-int is_no_Block(const ir_node *node);
-/** Returns true if the node is a Block */
-int is_Block(const ir_node *node);
-/** Returns true if node is an Unknown node. */
-int is_Unknown(const ir_node *node);
-/** Returns true if node is a Return node. */
-int is_Return(const ir_node *node);
-/** Returns true if node is a Call node. */
-int is_Call(const ir_node *node);
-/** Returns true if node is a Sel node. */
-int is_Sel(const ir_node *node);
-/** Returns true if node is a Mul node. */
-int is_Mul(const ir_node *node);
-/** Returns true if node is a Mux node or a Psi with only one condition. */
-int is_Mux(const ir_node *node);
-/** Returns true if node is a Load node. */
-int is_Load(const ir_node *node);
-/** Returns true if node is a Store node. */
-int is_Store(const ir_node *node);
-/** Returns true if node is a Sync node. */
-int is_Sync(const ir_node *node);
-/** Returns true if node is a Confirm node. */
-int is_Confirm(const ir_node *node);
-/** Returns true if node is a Pin node. */
-int is_Pin(const ir_node *node);
-/** Returns true if node is a SymConst node. */
-int is_SymConst(const ir_node *node);
-/** Returns true if node is a Cond node. */
-int is_Cond(const ir_node *node);
-/** Returns true of node is a CopyB node */
-int is_CopyB(const ir_node *node);
-/** Returns true if node is a Cmp node. */
-int is_Cmp(const ir_node *node);
-/** Returns true if node is an Alloc node */
-int is_Alloc(const ir_node *node);
-/** Returns true if a node is a Jmp node */
-int is_Jmp(const ir_node *node);
-/** Returns true if a node is a Raise node */
-int is_Raise(const ir_node *node);
-/** Returns true if a node is an ASM node */
-int is_ASM(const ir_node *node);
-/** Returns true if node is a Proj node or a Filter node in
- * intraprocedural view */
-int is_Proj(const ir_node *node);
-/** Returns true if the operation manipulates control flow:
- Start, End, Jmp, Cond, Return, Raise, Bad, CallBegin, EndReg, EndExcept */
-int is_cfop(const ir_node *node);
-
-/** Returns true if the operation manipulates interprocedural control flow:
- CallBegin, EndReg, EndExcept */
-int is_ip_cfop(const ir_node *node);
-/** Returns true if the operation can change the control flow because
- of an exception: Call, Quot, DivMod, Div, Mod, Load, Store, Alloc,
- Bad. Raise is not fragile, but a unconditional jump. */
-int is_fragile_op(const ir_node *node);
-/** Returns the memory operand of fragile operations. */
-ir_node *get_fragile_op_mem(ir_node *node);
-/** Returns the result mode of a Div operation. */
-ir_mode *get_divop_resmod(const ir_node *node);
-
-/** Returns true if the operation is a forking control flow
- * operation: Cond. */
-int is_irn_forking(const ir_node *node);
-
-/** Return the type associated with the value produced by n
- * if the node remarks this type as it is the case for
- * Cast, Const, SymConst and some Proj nodes or unknown_type. */
-ir_type *get_irn_type(ir_node *n);
-
-/** Return the type attribute of a node n (SymConst, Call, Alloc, Free,
- Cast) or NULL.*/
-ir_type *get_irn_type_attr(ir_node *n);
-
-/** Return the entity attribute of a node n (SymConst, Sel) or NULL. */
-ir_entity *get_irn_entity_attr(ir_node *n);
-
-/** Returns non-zero for constant-like nodes. */
-int is_irn_constlike(const ir_node *node);
-
-/**
- * Returns non-zero for nodes that must be always optimized
- * (Phi, Id. Proj, Cond, Block, Confirm ...).
- */
-int is_irn_always_opt(const ir_node *node);
-
-/**
- * Returns non-zero for nodes that are allowed to have keep-alives and
- * are neither Block nor PhiM.
- */
-int is_irn_keep(const ir_node *node);
-
-/**
- * Returns non-zero for nodes that are always placed in the start block.
- */
-int is_irn_start_block_placed(const ir_node *node);
-
-/**
- * Returns non-zero for nodes that are machine operations.
- */
-int is_irn_machine_op(const ir_node *node);
-
-/**
- * Returns non-zero for nodes that are machine operands.
- */
-int is_irn_machine_operand(const ir_node *node);
-
-/**
- * Returns non-zero for nodes that have the n'th user machine flag set.
- */
-int is_irn_machine_user(const ir_node *node, unsigned n);
-
-/**
- * A type to express conditional jump predictions.
- */
-typedef enum {
- COND_JMP_PRED_NONE, /**< No jump prediction. Default. */
- COND_JMP_PRED_TRUE, /**< The True case is predicted. */
- COND_JMP_PRED_FALSE /**< The False case is predicted. */
-} cond_jmp_predicate;
-
-/** Gets the string representation of the jump prediction .*/
-const char *get_cond_jmp_predicate_name(cond_jmp_predicate pred);
-
-/** Returns the conditional jump prediction of a Cond node. */
-cond_jmp_predicate get_Cond_jmp_pred(const ir_node *cond);
-
-/** Sets a new conditional jump prediction. */
-void set_Cond_jmp_pred(ir_node *cond, cond_jmp_predicate pred);
-
-/**
- * Access custom node data.
- * The data must have been registered with
- * register_additional_node_data() before.
- * @param node The ir node to get the data from.
- * @param type The type of the data you registered.
- * @param off The value returned by register_additional_node_data().
- * @return A pointer of type @p type.
- */
-#define get_irn_data(node,type,off) \
- (assert(off > 0 && "Invalid node data offset"), (type *) ((char *) (node) - (off)))
-
-/**
- * Get the pointer to the node some custom data belongs to.
- * @param data The pointer to the custom data.
- * @param off The number as returned by register_additional_node_data().
- * @return A pointer to the ir node the custom data belongs to.
- */
-#define get_irn_data_base(data,off) \
- (assert(off > 0 && "Invalid node data offset"), (ir_node *) ((char *) (data) + (off)))
-
-/**
- * Request additional data to be allocated with an ir node.
- * @param size The size of the additional data required.
- * @return A positive number, if the operation was successful, which
- * must be passed to the access macro get_irn_data(), 0 if the
- * registration failed.
- */
-unsigned register_additional_node_data(unsigned size);
-
-/**
- * Return a pointer to the node attributes.
- * Needed for user-defined nodes.
- */
-void *get_irn_generic_attr(ir_node *node);
-const void *get_irn_generic_attr_const(const ir_node *node);
-
-/**
- * Returns the unique node index for the node in its graph.
- * This index is used to access phase information for this node.
- */
-unsigned get_irn_idx(const ir_node *node);
-
-/*-----------------------------------------------------------------*/
-/** Debug aides **/
-/*-----------------------------------------------------------------*/
-
-
-/** Debug print the node.
- *
- * Writes the node, all its attributes and the predecessors to stdout if DEBUG_libfirm
- * is set. Else does nothing. */
-void dump_irn(ir_node *n);
-
-#include "ident.h"
-#include <stdio.h>
-
-#ifdef __GNUC__
-/* GNU C has the __FUNCTION__ extension */
-#define __MYFUNC__ __FUNCTION__
-#else
-/* use Filename instead */
-#define __MYFUNC__ __FILE__
-#endif
-
-/* !!!!!!!!! @@@
- Don't format with "\", firmjni gets problems */
-/** Output location */
-#define DDM printf("%s(l.%i).\n", __MYFUNC__, __LINE__);
-/** Output the firm kind of the node */
-#define DDMK(X) printf("%s(l.%i) %s: %p\n", __MYFUNC__, __LINE__, print_firm_kind(X), (void *)(X));
-/** Output information about a node */
-
-/*#define DDMN(X) printf("%s(l.%i) %s%s: %ld (%p)\n", __MYFUNC__, __LINE__, get_irn_opname(X), get_mode_name(get_irn_mode(X)), get_irn_node_nr(X), (void *)(X))*/
-int dump_node_opcode(FILE *F, ir_node *n);
-#define DDMN(X) do { printf("%s(l.%i) ", __MYFUNC__, __LINE__); dump_node_opcode(stdout, X); printf(": %ld (%p)\n", get_irn_node_nr(X), (void *)(X)); } while (0)
-
-/** Output information about a node and its block */
-#define DDMNB(X) printf("%s%s: %ld (in block %ld)\n", get_irn_opname(X), get_mode_name(get_irn_mode(X)), get_irn_node_nr(X), get_irn_node_nr(get_nodes_block(X)))
-/** Output information about a type */
-#define DDMT(X) printf("%s(l.%i) %s %s: %ld (%p)\n", __MYFUNC__, __LINE__, get_type_tpop_name(X), get_type_name(X), get_type_nr(X), (void *)(X))
-/** Output information about an entity */
-#define DDME(X) printf("%s(l.%i) %s: %ld (%p)\n", __MYFUNC__, __LINE__, get_entity_name(X), get_entity_nr(X), (void *)(X))
-/** Output information about an entity and its type */
-#define DDMET(X) printf("%s(l.%i) %s (typ: %s): %ld (%p)\n", __MYFUNC__, __LINE__, get_entity_name(X), get_type_name(get_entity_type(X)), get_entity_nr(X), (void *)(X))
-/** Output information about an entity and its owner */
-#define DDMEO(X) printf("%s(l.%i) %s (own: %s): %ld (%p)\n", __MYFUNC__, __LINE__, get_entity_name(X), get_type_name(get_entity_owner(X)), get_entity_nr(X), (void *)(X))
-/** Output information about a graph */
-#define DDMG(X) printf("%s(l.%i) graph %s: %ld (%p) in %s %s.\n", __MYFUNC__, __LINE__, get_entity_name(get_irg_entity(X)), get_irg_graph_nr(X), (void *)(X), get_type_tpop_name(get_entity_owner(get_irg_entity(X))), get_type_name(get_entity_owner(get_irg_entity(X))))
-/** Output information about an ident */
-#define DDMI(X) printf("%s(l.%i) %s: %p\n", __MYFUNC__, __LINE__, get_id_str(X), (void *)(X))
-/** Output information about a mode */
-#define DDMM(X) printf("%s(l.%i) %s: %p\n", __MYFUNC__, __LINE__, get_mode_name(X), (void *)(X))
-/** Output information about a loop */
-#define DDML(X) printf("%s(l.%i) loop with depth %d: %d\n", __MYFUNC__, __LINE__, get_loop_depth(X), get_loop_loop_nr(X))
-/** Output information about a tarVal */
-#define DDMV(X) printf("%s(l.%i) tarval: ",__MYFUNC__, __LINE__); tarval_printf(X); printf(" (%p)\n", (void *)(X));
-
-/*@}*/ /* end of ir_node group definition */
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Representation of opcode of intermediate operation.
- * @author Christian Schaefer, Goetz Lindenmaier, Michael Beck
- * @version $Id$
- * @summary
- * Operators of firm nodes.
- *
- * This module specifies the opcodes possible for ir nodes. Their
- * definition is close to the operations specified in UKA Tech-Report
- * 1999-14
- */
-#ifndef FIRM_IR_IROP_H
-#define FIRM_IR_IROP_H
-
-#include "firm_types.h"
-
-#include <stdio.h>
-#include "ident.h"
-
-/** The allowed parities */
-typedef enum {
- oparity_invalid = 0,
- oparity_unary, /**< an unary operator -- considering 'numeric' arguments. */
- oparity_binary, /**< an binary operator -- considering 'numeric' arguments.*/
- oparity_trinary, /**< an trinary operator -- considering 'numeric' arguments.*/
- oparity_zero, /**< no operators, as e.g. Const. */
- oparity_variable, /**< arity not fixed by opcode, but statically
- known. E.g., number of arguments to call. */
- oparity_dynamic, /**< arity depends on state of firm representation.
- Can change by optimizations...
- We must allocate a dynamic in array for the node! */
- oparity_any /**< other arity */
-} op_arity;
-
-
-/** The irop flags */
-typedef enum {
- irop_flag_none = 0x00000000, /**< Nothing. */
- irop_flag_labeled = 0x00000001, /**< If set, output edge labels on in-edges in vcg graph. */
- irop_flag_commutative = 0x00000002, /**< This operation is commutative. */
- irop_flag_cfopcode = 0x00000004, /**< This operation is a control flow operation. */
- irop_flag_ip_cfopcode = 0x00000008, /**< This operation manipulates the interprocedural control flow. */
- irop_flag_fragile = 0x00000010, /**< Set if the operation can change the control flow because
- of an exception. */
- irop_flag_forking = 0x00000020, /**< Forking control flow at this operation. */
- irop_flag_highlevel = 0x00000040, /**< This operation is a pure high-level one and can be
- skipped in low-level optimizations. */
- irop_flag_constlike = 0x00000080, /**< This operation has no arguments and is some
- kind of a constant. */
- irop_flag_always_opt = 0x00000100, /**< This operation must always be optimized .*/
- irop_flag_keep = 0x00000200, /**< This operation can be kept in End's keep-alive list. */
- irop_flag_start_block = 0x00000400, /**< This operation is always placed in the Start block. */
- irop_flag_machine = 0x00000800, /**< This operation is a machine operation. */
- irop_flag_machine_op = 0x00001000, /**< This operation is a machine operand. */
- irop_flag_user = 0x00002000 /**< This flag and all higher ones are free for machine user. */
-} irop_flags;
-
-/** The opcodes of the libFirm predefined operations. */
-typedef enum {
- iro_Block,
- iro_Start, iro_End, iro_Jmp, iro_IJmp, iro_Cond, iro_Return,
- iro_Const, iro_SymConst,
- iro_Sel,
- iro_Call, iro_Add, iro_Sub, iro_Minus, iro_Mul, iro_Quot, iro_DivMod,
- iro_Div, iro_Mod, iro_Abs, iro_And, iro_Or, iro_Eor, iro_Not,
- iro_Cmp, iro_Shl, iro_Shr, iro_Shrs, iro_Rot, iro_Conv, iro_Cast,
- iro_Carry, iro_Borrow,
- iro_Phi,
- iro_Load, iro_Store, iro_Alloc, iro_Free, iro_Sync,
- iro_Proj, iro_Tuple, iro_Id, iro_Bad, iro_Confirm,
- iro_Unknown, iro_Filter, iro_Break, iro_CallBegin, iro_EndReg, iro_EndExcept,
- iro_NoMem, iro_Mux, iro_Psi, iro_CopyB,
- iro_InstOf, iro_Raise, iro_Bound,
- iro_Pin,
- iro_ASM,
- iro_MaxOpcode
-} ir_opcode;
-
-#ifndef _IR_OP_TYPEDEF_
-#define _IR_OP_TYPEDEF_
-typedef struct ir_op ir_op;
-#endif
-
-extern ir_op *op_Block; ir_op *get_op_Block (void);
-
-extern ir_op *op_Start; ir_op *get_op_Start (void);
-extern ir_op *op_End; ir_op *get_op_End (void);
-extern ir_op *op_Jmp; ir_op *get_op_Jmp (void);
-extern ir_op *op_IJmp; ir_op *get_op_IJmp (void);
-extern ir_op *op_Cond; ir_op *get_op_Cond (void);
-extern ir_op *op_Return; ir_op *get_op_Return (void);
-extern ir_op *op_Sel; ir_op *get_op_Sel (void);
-
-extern ir_op *op_Const; ir_op *get_op_Const (void);
-extern ir_op *op_SymConst; ir_op *get_op_SymConst (void);
-
-extern ir_op *op_Call; ir_op *get_op_Call (void);
-extern ir_op *op_Add; ir_op *get_op_Add (void);
-extern ir_op *op_Sub; ir_op *get_op_Sub (void);
-extern ir_op *op_Minus; ir_op *get_op_Minus (void);
-extern ir_op *op_Mul; ir_op *get_op_Mul (void);
-extern ir_op *op_Quot; ir_op *get_op_Quot (void);
-extern ir_op *op_DivMod; ir_op *get_op_DivMod (void);
-extern ir_op *op_Div; ir_op *get_op_Div (void);
-extern ir_op *op_Mod; ir_op *get_op_Mod (void);
-extern ir_op *op_Abs; ir_op *get_op_Abs (void);
-extern ir_op *op_And; ir_op *get_op_And (void);
-extern ir_op *op_Or; ir_op *get_op_Or (void);
-extern ir_op *op_Eor; ir_op *get_op_Eor (void);
-extern ir_op *op_Not; ir_op *get_op_Not (void);
-extern ir_op *op_Cmp; ir_op *get_op_Cmp (void);
-extern ir_op *op_Shl; ir_op *get_op_Shl (void);
-extern ir_op *op_Shr; ir_op *get_op_Shr (void);
-extern ir_op *op_Shrs; ir_op *get_op_Shrs (void);
-extern ir_op *op_Rot; ir_op *get_op_Rot (void);
-extern ir_op *op_Conv; ir_op *get_op_Conv (void);
-extern ir_op *op_Cast; ir_op *get_op_Cast (void);
-extern ir_op *op_Carry; ir_op *get_op_Carry (void);
-extern ir_op *op_Borrow; ir_op *get_op_Borrow (void);
-
-extern ir_op *op_Phi; ir_op *get_op_Phi (void);
-
-extern ir_op *op_Load; ir_op *get_op_Load (void);
-extern ir_op *op_Store; ir_op *get_op_Store (void);
-extern ir_op *op_Alloc; ir_op *get_op_Alloc (void);
-extern ir_op *op_Free; ir_op *get_op_Free (void);
-
-extern ir_op *op_Sync; ir_op *get_op_Sync (void);
-
-extern ir_op *op_Tuple; ir_op *get_op_Tuple (void);
-extern ir_op *op_Proj; ir_op *get_op_Proj (void);
-extern ir_op *op_Id; ir_op *get_op_Id (void);
-extern ir_op *op_Bad; ir_op *get_op_Bad (void);
-extern ir_op *op_Confirm; ir_op *get_op_Confirm (void);
-
-extern ir_op *op_Unknown; ir_op *get_op_Unknown (void);
-extern ir_op *op_Filter; ir_op *get_op_Filter (void);
-extern ir_op *op_Break; ir_op *get_op_Break (void);
-extern ir_op *op_CallBegin; ir_op *get_op_CallBegin (void);
-extern ir_op *op_EndReg; ir_op *get_op_EndReg (void);
-extern ir_op *op_EndExcept; ir_op *get_op_EndExcept (void);
-
-extern ir_op *op_NoMem; ir_op *get_op_NoMem (void);
-extern ir_op *op_Mux; ir_op *get_op_Mux (void);
-extern ir_op *op_Psi; ir_op *get_op_Psi (void);
-extern ir_op *op_CopyB; ir_op *get_op_CopyB (void);
-
-extern ir_op *op_InstOf; ir_op *get_op_InstOf (void);
-extern ir_op *op_Raise; ir_op *get_op_Raise (void);
-extern ir_op *op_Bound; ir_op *get_op_Bound (void);
-
-extern ir_op *op_Pin; ir_op *get_op_Pin (void);
-
-extern ir_op *op_ASM; ir_op *get_op_ASM (void);
-
-/** Returns the ident for the opcode name */
-ident *get_op_ident(const ir_op *op);
-
-/** Returns the string for the opcode. */
-const char *get_op_name(const ir_op *op);
-
-/** Returns the enum for the opcode */
-ir_opcode get_op_code(const ir_op *op);
-
-/** op_pin_state_pinned states */
-typedef enum {
- op_pin_state_floats = 0, /**< Nodes of this opcode can be placed in any basic block. */
- op_pin_state_pinned = 1, /**< Nodes must remain in this basic block. */
- op_pin_state_exc_pinned, /**< Node must be remain in this basic block if it can throw an
- exception, else can float. Used internally. */
- op_pin_state_mem_pinned /**< Node must be remain in this basic block if it can throw an
- exception or uses memory, else can float. Used internally. */
-} op_pin_state;
-
-const char *get_op_pin_state_name(op_pin_state s);
-
-/** gets pinned state of an opcode */
-op_pin_state get_op_pinned(const ir_op *op);
-
-/** Sets pinned in the opcode. Setting it to floating has no effect
- for Block, Phi and control flow nodes. */
-void set_op_pinned(ir_op *op, op_pin_state pinned);
-
-/** Returns the next free IR opcode number, allows to register user ops */
-unsigned get_next_ir_opcode(void);
-
-/** Returns the next free n IR opcode number, allows to register a bunch of user ops */
-unsigned get_next_ir_opcodes(unsigned num);
-
-/**
- * A generic function pointer.
- */
-typedef void (*op_func)(void);
-
-/** The NULL-function. */
-#define NULL_FUNC ((generic_func)(NULL))
-
-/**
- * Returns the generic function pointer from an ir operation.
- */
-op_func get_generic_function_ptr(const ir_op *op);
-
-/**
- * Store a generic function pointer into an ir operation.
- */
-void set_generic_function_ptr(ir_op *op, op_func func);
-
-/**
- * The compute value operation.
- * This operation evaluates an IR node into a tarval if possible,
- * returning tarval_bad otherwise.
- */
-typedef tarval *(*computed_value_func)(ir_node *self);
-
-/**
- * The equivalent node operation.
- * This operation returns an equivalent node for the input node.
- * It does not create new nodes. It is therefore safe to free self
- * if the node returned is not self.
- * If a node returns a Tuple we can not just skip it. If the size of the
- * in array fits, we transform n into a tuple (e.g., possible for Div).
- */
-typedef ir_node *(*equivalent_node_func)(ir_node *self);
-
-/**
- * The transform node operation.
- * This operation tries several [inplace] [optimizing] transformations
- * and returns an equivalent node.
- * The difference to equivalent_node() is that these
- * transformations _do_ generate new nodes, and thus the old node must
- * not be freed even if the equivalent node isn't the old one.
- */
-typedef ir_node *(*transform_node_func)(ir_node *self);
-
-/**
- * The node attribute compare operation.
- * Compares the nodes attributes of two nodes of identical opcode
- * and returns 0 if the attributes are identical, 1 if they differ.
- */
-typedef int (*node_cmp_attr_func)(ir_node *a, ir_node *b);
-
-/**
- * The reassociation operation.
- * Called from a walker. Returns non-zero if
- * a reassociation rule was applied.
- * The pointer n is set to the newly created node, if some reassociation
- * was applied.
- */
-typedef int (*reassociate_func)(ir_node **n);
-
-/**
- * The copy attribute operation.
- * Copy the node attributes from a 'old' node to a 'new' one.
- */
-typedef void (*copy_attr_func)(const ir_node *old_node, ir_node *new_node);
-
-/**
- * The get_type operation.
- * Return the type of the node self.
- */
-typedef ir_type *(*get_type_func)(ir_node *self);
-
-/**
- * The get_type_attr operation. Used to traverse all types that can be
- * accessed from an ir_graph.
- * Return the type attribute of the node self.
- */
-typedef ir_type *(*get_type_attr_func)(ir_node *self);
-
-/**
- * The get_entity_attr operation. Used to traverse all entities that can be
- * accessed from an ir_graph.
- * Return the entity attribute of the node self.
- */
-typedef ir_entity *(*get_entity_attr_func)(ir_node *self);
-
-/**
- * The verify_node operation.
- * Return non-zero if the node verification is ok, else 0.
- * Depending on the node verification settings, may even assert.
- *
- * @see do_node_verification()
- */
-typedef int (*verify_node_func)(ir_node *self, ir_graph *irg);
-
-/**
- * The verify_node operation for Proj(X).
- * Return non-zero if the node verification is ok, else 0.
- * Depending on the node verification settings, may even assert.
- *
- * @see do_node_verification()
- */
-typedef int (*verify_proj_node_func)(ir_node *self, ir_node *proj);
-
-/**
- * Reasons to call the dump_node operation:
- */
-typedef enum {
- dump_node_opcode_txt, /**< dump the opcode */
- dump_node_mode_txt, /**< dump the mode */
- dump_node_nodeattr_txt, /**< dump node attributes to be shown in the label */
- dump_node_info_txt /**< dump node attributes into info1 */
-} dump_reason_t;
-
-/**
- * The dump_node operation.
- * Writes several informations requested by reason to
- * an output file
- */
-typedef int (*dump_node_func)(ir_node *self, FILE *F, dump_reason_t reason);
-
-/**
- * io_op Operations.
- */
-typedef struct {
- computed_value_func computed_value; /**< evaluates a node into a tarval if possible. */
- equivalent_node_func equivalent_node; /**< optimizes the node by returning an equivalent one. */
- transform_node_func transform_node; /**< optimizes the node by transforming it. */
- node_cmp_attr_func node_cmp_attr; /**< compares two node attributes. */
- reassociate_func reassociate; /**< reassociate a tree */
- copy_attr_func copy_attr; /**< copy node attributes */
- get_type_func get_type; /**< return the type of a node */
- get_type_attr_func get_type_attr; /**< return the type attribute of a node */
- get_entity_attr_func get_entity_attr; /**< return the entity attribute of a node */
- verify_node_func verify_node; /**< verify the node */
- verify_proj_node_func verify_proj_node; /**< verify the Proj node */
- dump_node_func dump_node; /**< dump a node */
- op_func generic; /**< a generic function */
-} ir_op_ops;
-
-/**
- * Creates a new ir operation.
- *
- * @param code the opcode, one of type \c opcode
- * @param name the printable name of this opcode
- * @param p whether operations of this opcode are op_pin_state_pinned or floating
- * @param flags a bitmask of irop_flags describing the behavior of the ir operation
- * @param opar the parity of this ir operation
- * @param op_index if the parity is oparity_unary, oparity_binary or oparity_trinary the index
- * of the left operand
- * @param ops operations for this opcode, iff NULL default operations are used
- * @param attr_size attribute size for this ir operation
- *
- * @return The generated ir operation.
- *
- * This function can create all standard Firm opcode as well as new ones.
- * The behavior of new opcode depends on the operations \c ops and the \c flags.
- */
-ir_op *new_ir_op(ir_opcode code, const char *name, op_pin_state p,
- unsigned flags, op_arity opar, int op_index, size_t attr_size,
- const ir_op_ops *ops);
-
-/** Returns the ir_op_ops of an ir_op. */
-const ir_op_ops *get_op_ops(const ir_op *op);
-
-#endif
# include "config.h"
#endif
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
#include "irnode_t.h"
#include "irgraph_t.h"
#include "irarch.h"
#include "hashptr.h"
#include "archop.h"
-#include "opt_polymorphy.h"
#include "opt_confirms.h"
+#include "opt_polymorphy.h"
#include "irtools.h"
#include "xmalloc.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief iropt --- optimizations of an ir node.
- * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Michael Beck
- * @version $Id$
- */
-#ifndef FIRM_IR_IROPT_H
-#define FIRM_IR_IROPT_H
-
-#include "firm_types.h"
-
-/**
- * The Floating point model.
- *
- * Several basic properties are defined:
- * - fp_explicit_rounding
- * - fp_strict_algebraic
- * - fp_contradictions
- * - fp_strict_eval_order
- * - fp_exceptions
- * - fp_environment_access
- *
- * From those basic properties three general models are defined,
- * compatible to the VC8 compiler:
- * - fp_model_precise:
- * Default mode. Associative and distributive law forbidden unless a transformation
- * is guaranteed to produce the same result.
- * No FPU environment access. No FP exception semantics.
- * - fp_model_strict:
- * Slowest mode. Additionally to fp_model_precise allows correct handling of
- * FP exceptions and FPU environment access.
- * - fp_model_fast:
- * Fastest mode. Associative and distributive law allowed at the expense
- * of floating point accuracy and correctness. Explicit rounding is disabled.
- */
-typedef enum _fp_model_t {
- fp_explicit_rounding = 1, /**< Explicit rounding at assignments, typecasts, return
- and function calls. Conv nodes may NOT be removed, even
- if they look useless. */
- fp_strict_algebraic = 2, /**< Strict adherence to non-associative and non-distributive
- algebra unless the same result is guaranteed. */
- fp_contradictions = 4, /**< FP contradictions are enabled. Only for backend. */
- fp_strict_eval_order = 8, /**< FP instructions must be strict evaluated in given order. */
- fp_exceptions = 16, /**< FP exceptions are supported. No reordering that changes
- the exception flow are allowed. Backends must generate
- synchronized exception code. */
- fp_environment_access = 32, /**< FPU environment can be accessed. Even Constant folding
- cannot be done. */
-
- /** Precise floating point model. Default. */
- fp_model_precise = fp_explicit_rounding|fp_strict_algebraic|fp_contradictions,
- /** Strict floating point model. */
- fp_model_strict = fp_explicit_rounding|fp_strict_algebraic|fp_strict_eval_order|
- fp_exceptions|fp_environment_access,
- /** Fast floating point model. */
- fp_model_fast = fp_contradictions,
-} fp_model_t;
-
-/** If the expression referenced can be evaluated statically
- * computed_value returns a tarval representing the result.
- * Else returns tarval_bad. */
-tarval *computed_value(ir_node *n);
-
-/** Applies all optimizations to n that are expressible as a pattern
- * in Firm, i.e., they need not a walk of the graph.
- * Returns a better node for n. Does not free n -- other nodes could
- * reference n.
- *
- * An equivalent optimization is applied in the constructors defined in
- * ircons.ch. There n is freed if a better node could be found.
- */
-ir_node *optimize_in_place(ir_node *n);
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Debug makros used in iropt.
- * @author Goetz Lindenmaier
- * @version $Id$
- */
-#ifndef FIRM_IR_IROPT_DBG_H
-#define FIRM_IR_IROPT_DBG_H
-
-#include "dbginfo_t.h"
-#include "irhooks.h"
-#include "firmstat.h"
-
-/* This file contains makros that generate the calls to
- update the debug information after a transformation. */
-
-#define SIZ(x) sizeof(x)/sizeof((x)[0])
-
-
-/**
- * Merge the debug info due to dead block elimination.
- *
- * @param oldn the block that it is eliminated
- * @param n the new node for this block, may be equal to oldn
- */
-#define DBG_OPT_DEAD_BLOCK(oldn, n) \
- do { \
- hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_DEAD_BLOCK); \
- __dbg_info_merge_pair(n, oldn, dbg_dead_code); \
- } while(0)
-
-
-/**
- * Merge the debug info due to a straightening optimization.
- * Block oldn is merged with n.
- *
- * @param oldn the old block
- * @param n the new block the merges with oldn
- */
-#define DBG_OPT_STG(oldn, n) \
- do { \
- ir_node *ons[2]; \
- ons[0] = oldn; \
- ons[1] = get_Block_cfgpred(oldn, 0); \
- hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_STG); \
- __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_straightening); \
- } while(0)
-
-/**
- * Merge the debug info due to an if simplification.
- *
- * @param oldn the old Block
- * @param proj1 the first ProjX predecessor
- * @param proj2 the second ProjX predecessor
- * @param n the new Block
- */
-#define DBG_OPT_IFSIM1(oldn, proj1, proj2, n) \
- do { \
- ir_node *ons[4]; \
- ons[0] = oldn; \
- ons[1] = proj1; \
- ons[2] = proj2; \
- ons[3] = get_Proj_pred(proj1); \
- hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_IFSIM); \
- __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_if_simplification); \
- } while(0)
-
-/**
- * Merge the debug info due to an if simplification.
- * @param oldn the old Cond
- * @param n the new Jmp
- */
-#define DBG_OPT_IFSIM2(oldn, n) \
- do { \
- hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_IFSIM); \
- __dbg_info_merge_pair(n, oldn, dbg_if_simplification); \
- } while(0)
-
-/**
- * Merge the debug info due to an algebraic_simplification.
- * A node could be avaluated into a Constant.
- *
- * @param oldn the node
- * @param n the new constant holding the value
- */
-#define DBG_OPT_CSTEVAL(oldn, n) \
- do { \
- hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_CONST_EVAL); \
- __dbg_info_merge_pair(n, oldn, dbg_const_eval); \
- } while(0)
-
-/**
- * Merge the debug info due to an algebraic_simplification.
- *
- * @param oldn the old node
- * @param n the new node replacing oldn
- * @param flag firm statistics option
- */
-#define DBG_OPT_ALGSIM0(oldn, n, flag) \
- do { \
- hook_merge_nodes(&n, 1, &oldn, 1, flag); \
- __dbg_info_merge_pair(n, oldn, dbg_algebraic_simplification); \
- } while(0)
-
-/**
- * Merge the debug info due to an algebraic_simplification.
- *
- * @param oldn the old node
- * @param a a predecessor of oldn
- * @param b a predecessor of oldn
- * @param n the new node replacing oldn
- * @param flag firm statistics option
- */
-#define DBG_OPT_ALGSIM1(oldn, a, b, n, flag) \
- do { \
- ir_node *ons[3]; \
- ons[0] = oldn; \
- ons[1] = a; \
- ons[2] = b; \
- hook_merge_nodes(&n, 1, ons, SIZ(ons), flag); \
- __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
- } while(0)
-
-/**
- * Merge the debug info due to an algebraic_simplification.
- */
-#define DBG_OPT_ALGSIM2(oldn, pred, n) \
- do { \
- ir_node *ons[3]; \
- ons[0] = oldn; \
- ons[1] = pred; \
- ons[2] = n; \
- hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_ALGSIM); \
- __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
- } while(0)
-
-/**
- * Merge the debug info due to an algebraic_simplification.
- */
-#define DBG_OPT_ALGSIM3(oldn, a, n) \
- do { \
- ir_node *ons[2]; \
- ons[0] = oldn; \
- ons[1] = a; \
- hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_ALGSIM); \
- __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_algebraic_simplification); \
- } while(0)
-
-/**
- * Merge the debug info due to a Phi optimization.
- * A Phi node was replaced by one of its input (the only meaningful)
- *
- * @param phi the Phi node that will be replaced
- * @param n in Phi Input that will replace Phi
- */
-#define DBG_OPT_PHI(phi, n) \
- do { \
- hook_merge_nodes(&n, 1, &phi, 1, HOOK_OPT_PHI); \
- __dbg_info_merge_sets(&n, 1, &phi, 1, dbg_opt_ssa); \
- } while(0)
-
-
-/**
- * Merge the debug info due to a Sync optimization.
- * A Sync node was replaced by one of its input (the only meaningful)
- *
- * @param sync the Sync node that will be replaced
- * @param n in Sync Input that will replace Sync
- */
-#define DBG_OPT_SYNC(sync, n) \
- do { \
- hook_merge_nodes(&n, 1, &sync, 1, HOOK_OPT_SYNC); \
- __dbg_info_merge_sets(&n, 1, &sync, 1, dbg_opt_ssa); \
- } while(0)
-
-
-/**
- * Merge the debug info due to Write-after-Write optimization:
- * Store oldst will be removed, because Store st overwrites it.
- *
- * @param oldst the old store that will be removed
- * @param st the other store that overwrites oldst
- */
-#define DBG_OPT_WAW(oldst, st) \
- do { \
- ir_node *ons[2]; \
- ons[0] = oldst; \
- ons[1] = st; \
- hook_merge_nodes(&st, 1, ons, SIZ(ons), HOOK_OPT_WAW); \
- __dbg_info_merge_sets(&st, 1, ons, SIZ(ons), dbg_write_after_write); \
- } while(0)
-
-/**
- * Merge the debug info due to Write-after-Read optimization:
- * A store will be removed because it rite a value just read back.
- *
- * @param store the store that will be removed
- * @param load the load that produces the value that store will write back
- */
-#define DBG_OPT_WAR(store, load) \
- do { \
- ir_node *ons[2]; \
- ons[0] = store; \
- ons[1] = load; \
- hook_merge_nodes(&load, 1, ons, SIZ(ons), HOOK_OPT_WAR); \
- __dbg_info_merge_sets(&load, 1, ons, SIZ(ons), dbg_write_after_read); \
- } while(0)
-
-/**
- * Merge the debug info due to Read-after-Write optimization:
- * A load will be replaced by a value that was just stored.
- *
- * @param load the load that will be replaced
- * @param value the value that will replace the load
- */
-#define DBG_OPT_RAW(load, value) \
- do { \
- ir_node *ons[2]; \
- ons[0] = load; \
- ons[1] = value; \
- hook_merge_nodes(&value, 1, ons, SIZ(ons), HOOK_OPT_RAW); \
- __dbg_info_merge_sets(&value, 1, ons, SIZ(ons), dbg_read_after_write); \
- } while(0)
-
-/**
- * Merge the debug info due to Read-after-Read optimization:
- * Load oldld will be replace by a reference to Load ld.
- *
- * @param oldld the old load that can be replaced
- * @param ld the load that produces the same values
- */
-#define DBG_OPT_RAR(oldld, ld) \
- do { \
- ir_node *ons[2]; \
- ons[0] = oldld; \
- ons[1] = ld; \
- hook_merge_nodes(&ld, 1, ons, SIZ(ons), HOOK_OPT_RAR); \
- __dbg_info_merge_sets(&ld, 1, ons, SIZ(ons), dbg_read_after_read); \
- } while(0)
-
-/**
- * Merge the debug info due to Read-a-Const optimization:
- * Load ld will be replace by a Constant if the value that
- * will be loaded is known and immutable.
- *
- * @param ld the load
- * @param c the constant value that will replace the load's result
- */
-#define DBG_OPT_RC(ld, c) \
- do { \
- ir_node *ons[2]; \
- ons[0] = ld; \
- ons[1] = c; \
- hook_merge_nodes(&c, 1, ons, SIZ(ons), HOOK_OPT_RC); \
- __dbg_info_merge_sets(&ld, 1, ons, SIZ(ons), dbg_read_a_const); \
- } while(0)
-
-/**
- * Merge the debug info after a tuple optimization.
- * a Proj(Tuple) is replaced by the associated tuple value.
- *
- * @param proj the Proj node
- * @param tuple the Tuple node
- * @param n the Proj(Tuple) value
- */
-#define DBG_OPT_TUPLE(proj, tuple, n) \
- do { \
- ir_node *ons[3]; \
- ons[0] = proj; \
- ons[1] = tuple; \
- ons[2] = n; \
- hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_TUPLE); \
- __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_auxnode); \
- } while(0)
-
-/**
- * Merge the debug info after an Id optimization.
- * An Id node was replaced by its non-Id predecessor.
- *
- * @param id the Id node
- * @param n the predecessor
- */
-#define DBG_OPT_ID(id, n) \
- do { \
- ir_node *ons[2]; \
- ons[0] = id; \
- ons[1] = n; \
- hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_ID); \
- __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_auxnode); \
- } while(0)
-
-/**
- * Merge the debug info due to common-subexpression elimination.
- *
- * @param oldn the old node
- * @param n the node that replaces oldn
- */
-#define DBG_OPT_CSE(oldn, n) \
- do { \
- ir_node *ons[2]; \
- ons[0] = oldn; \
- ons[1] = n; \
- hook_merge_nodes(&n, 1, ons, SIZ(ons), HOOK_OPT_CSE); \
- __dbg_info_merge_sets(&n, 1, ons, SIZ(ons), dbg_opt_cse); \
- } while(0)
-
-/**
- * Merge the debug info due to polymorphic call optimization.
- * A Sel node was replaced by a constant.
- *
- * @param sel the Sel node that will be replaced.
- * @param c the constant node that replaces sel
- */
-#define DBG_OPT_POLY(sel, c) \
- do { \
- ir_node *ons[3]; \
- ons[0] = sel; \
- ons[1] = skip_Proj(get_Sel_ptr(sel)); \
- ons[2] = c; \
- hook_merge_nodes(&c, 1, ons, SIZ(ons), HOOK_OPT_POLY_CALL); \
- __dbg_info_merge_sets(&c, 1, ons, SIZ(ons), dbg_rem_poly_call); \
- } while(0)
-
-/**
- * A node was replaced by another node due to a Confirmation.
- *
- * @param oldn the old node
- * @param n the new node
- */
-#define DBG_OPT_CONFIRM(oldn, n) \
- do { \
- hook_merge_nodes(&n, 1, &oldn, 1, HOOK_OPT_CONFIRM); \
- __dbg_info_merge_pair(n, oldn, dbg_opt_confirm); \
- } while(0)
-
-/**
- * A node was replaced by a constant due to a Confimation.
- *
- * @param oldn the old node
- * @param c the new constant node
- */
-#define DBG_OPT_CONFIRM_C(oldn, c) \
- do { \
- hook_merge_nodes(&c, 1, &oldn, 1, HOOK_OPT_CONFIRM_C); \
- __dbg_info_merge_pair(c, oldn, dbg_opt_confirm); \
- } while(0)
-
-/**
- * A exception exdge was removed due to a Confirmation prove.
- *
- * @param oldn the old node
- */
-#define DBG_OPT_EXC_REM(oldn) \
- do { \
- hook_merge_nodes(NULL, 0, &oldn, 1, HOOK_OPT_EXC_REM); \
- } while(0)
-
-/**
- * A node could be evaluated to a value due to a Confirm.
- * This will lead to a constant evaluation.
- *
- * @param n the node that could be evaluated
- */
-#define DBG_EVAL_CONFIRM(n) \
- do { \
- hook_merge_nodes(NULL, 0, &n, 1, HOOK_OPT_CONFIRM_E); \
- } while(0)
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief A little printf understanding some firm types.
- * @author Sebastian Hack
- * @date 29.11.2004
- * @version $Id$
- */
-#ifndef FIRM_IR_IRPRINTF_H
-#define FIRM_IR_IRPRINTF_H
-
-#include "firm_config.h"
-
-#include <stddef.h>
-#include <stdarg.h>
-#include <stdio.h>
-
-/* forward definition */
-struct obstack;
-
-/**
- * Something that can append strings and chars to something.
- */
-typedef struct _appender_t {
- void (*init)(void *object, size_t n);
- void (*append_char)(void *object, size_t n, char ch);
- void (*append_str)(void *object, size_t n, const char *str);
-} appender_t;
-
-/**
- * A callback function type to add something to an appender.
- *
- * @param app The appender.
- * @param object The object for the appender.
- * @param limit The limit for the appender.
- * @param arg The thing to append.
- */
-typedef void (ir_printf_cb_t)(const appender_t *app, void *object, size_t limit, const void *arg);
-
-/**
- * A string formatting routine for ir objects.
- *
- * @param fmt The format string.
- *
- * This function rudimentary implements a kind of printf(3) for ir
- * nodes. Following conversion specifiers. No length, special or field
- * width specifiers are accepted.
- * - @%% Print a '%' character.
- * - @%> Print as many white spaces as given in the parameter.
- * - @%c Print a character
- * - @%s A string.
- * - @%p A pointer.
- * - @%d A decimal integer.
- * - @%x A hexadecimal integer.
- * - @%o An octal integer.
- * - @%I An ident.
- * - @%t A type name.
- * - @%e An entity name.
- * - @%E An entity ld name.
- * - @%T A tarval.
- * - @%n A full description of a node.
- * - @%O The opcode name of an ir node.
- * - @%N The node number of an ir node.
- * - @%m The mode name of an ir mode.
- * - @%B The block node number of the nodes block.
- * - @%b A bitset.
- * - @%= A pnc value
- * - @%G A debug info (if available)
- * - @%P A compound graph path
- *
- * Each of these can be prepend by a '+' which means, that the given
- * pointer is a collection of items specified by the format. In this
- * case you also have to pass an iterator interface to ir_printf()
- * suitable for the instance of the collection. So, imagine you have a
- * @c pset of ir_nodes and want to dump it, you write:
- * @code
- * pset *nodes;
- * ...
- * ir_printf("Some nodes: %*n\n", it_pset, nodes);
- * @endcode
- * The @c it_pset is an iterator interface (of type
- * @c iterator_t that allows the dumper to traverse the set.
- *
- * As special case when working with collections, you can also give a
- * callback function which will be invoked on each element in the
- * collection. It gets the appender (the thing where the textual
- * representation of the element is written to) and its parameters
- * passed by the dumping function. Suppose you have your own data type
- * @c xyz_t and want to dump a pset of it, you have:
- * @code
- * void xyz_dump(const appender_t *app, void *object, size_t limit,
- * const void *arg)
- * {
- * const xyz_t *xyz = arg;
- * app->append_str(object, limit, xyz->name);
- * }
- * ...
- * pset *xyzs;
- *
- * ir_printf("A set of xyz\'s: %*C\n", it_pset, xyzs, xyz_dump);
- * @endcode
- */
-void ir_printf(const char *fmt, ...);
-
-/**
- * @see irn_printf.
- */
-void ir_fprintf(FILE *f, const char *fmt, ...);
-
-/**
- * @see irn_printf.
- */
-void ir_snprintf(char *buf, size_t n, const char *fmt, ...);
-
-/**
- * @see irn_printf.
- */
-void ir_vprintf(const char *fmt, va_list args);
-
-/**
- * @see irn_printf.
- */
-void ir_vfprintf(FILE *f, const char *fmt, va_list args);
-
-/**
- * @see irn_printf.
- */
-void ir_vsnprintf(char *buf, size_t len, const char *fmt, va_list args);
-
-/**
- * @see irn_printf.
- */
-void ir_obst_vprintf(struct obstack *obst, const char *fmt, va_list args);
-
-#ifdef WITH_LIBCORE
-#include <libcore/lc_printf.h>
-#endif /* WITH_LIBCORE */
-
-#endif
#include "pseudo_irg.h"
#include "array.h"
#include "obst.h"
-#include "typegmod.h"
#include "irop_t.h"
#include "irmemory.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Entry point to the representation of a whole program.
- * @author Goetz Lindenmaier
- * @date 2000
- * @version $Id$
- * @summary
- * ir representation of a program.
- *
- * This file defines a construct that keeps all information about a
- * program:
- * - A reference point to the method to be executed on program start.
- * - A list of all procedures.
- * - A list of all types.
- * - A global type that contais all global variables and procedures that do
- * not belong to a class. This type represents the data segment of the
- * program. It is not the base class of
- * all classes in a class hierarchy (as, e.g., "object" in java).
- * - A degenerated graph that contains constant expressions.
- * - interprocedural outs state.
- * - a flag indicating validity of the interprocedural representation.
- * - the output file name
- */
-#ifndef FIRM_IR_IRPROG_H
-#define FIRM_IR_IRPROG_H
-
-#include "firm_types.h"
-#include "irgraph.h"
-
-
-/**
- * Datastructure that holds central information about a program
- *
- * Preliminary documentation ;-)
- *
- * - main_irg: The ir graph that is the entry point to the program.
- * (Anything not reachable from here may be optimized away.
- * If we want to translate libraries or the like correctly
- * we must replace this by a list.)
- * - irg: List of all ir graphs in the program.
- * - type: A list containing all types known to the translated program.
- * Some types can have several entries in this list (as a result of
- * using exchange_types()).
- * - glob_type: The unique global type that is owner of all global entities.
- *
- */
-typedef struct ir_prog ir_prog;
-
-/**
- * A variable from where everything in the ir can be accessed.
- * This variable contains the irp, the "immediate representation program".
- * This variable should be considered constant. Moreover, one should use get_irp()
- * to get access the the irp.
- *
- * @note
- * Think of the irp as the "handle" of libFirm.
- */
-extern ir_prog *irp;
-
-/**
- * Returns the access points from where everything in the ir can be accessed.
- *
- * @see irp
- */
-ir_prog *get_irp(void);
-
-/** Creates a new ir_prog, returns it and sets irp with it.
- * Automatically called by init_firm() through init_irprog. */
-ir_prog *new_ir_prog (void);
-
-/** frees all memory used by irp. Types in type list and irgs in irg
- * list must be freed by hand before. */
-void free_ir_prog(void);
-
-/** Sets the file name / executable name or the like. Initially the
- ident 'no_name_set'. */
-void set_irp_prog_name (ident *name);
-
-/** Returns true if the user ever set a program name */
-int irp_prog_name_is_set(void);
-
-/** Gets the file name / executable name or the like.
- */
-ident *get_irp_prog_ident(void);
-
-/** Gets the file name / executable name or the like.
- */
-const char *get_irp_prog_name (void);
-
-/** Gets the main routine of the compiled program. */
-ir_graph *get_irp_main_irg(void);
-
-/** Sets the main routine of the compiled program. */
-void set_irp_main_irg(ir_graph *main_irg);
-
-/** Adds irg to the list of ir graphs in irp. */
-void add_irp_irg(ir_graph *irg);
-
-/** Removes irg from the list of irgs and
- shrinks the list by one. */
-void remove_irp_irg_from_list(ir_graph *irg);
-/** Removes irg from the list of irgs, deallocates it and
- shrinks the list by one. */
-void remove_irp_irg(ir_graph *irg);
-
-/** Returns the number of ir graphs in the irp. */
-int get_irp_n_irgs(void);
-
-/** Returns the ir graph at position pos in the irp. */
-ir_graph *get_irp_irg(int pos);
-
-/** Sets the ir graph at position pos. */
-void set_irp_irg(int pos, ir_graph *irg);
-
-/** Gets the number of graphs _and_ pseudo graphs. */
-int get_irp_n_allirgs(void);
-
-/** Returns the ir graph at position pos of all graphs (including
- pseudo graphs). Visits first graphs, then pseudo graphs. */
-ir_graph *get_irp_allirg(int pos);
-
-/**
- * Returns the "global" type of the irp.
- * Upon creation this is an empty class type.
- */
-ir_type *get_glob_type(void);
-
-/**
- * Returns the "thread local storage" type of the irp.
- * Upon creation this is an empty struct type.
- */
-ir_type *get_tls_type(void);
-
-/** Adds type to the list of types in irp. */
-void add_irp_type(ir_type *typ);
-
-/** Removes type from the list of types, deallocates it and
- shrinks the list by one. */
-void remove_irp_type(ir_type *typ);
-
-/** Returns the number of all types in the irp. */
-int get_irp_n_types(void);
-
-/** Returns the type at position pos in the irp. */
-ir_type *get_irp_type(int pos);
-
-/** Overwrites the type at position pos with another type. */
-void set_irp_type(int pos, ir_type *typ);
-
-/** Returns the number of all modes in the irp. */
-int get_irp_n_modes(void);
-
-/** Returns the mode at position pos in the irp. */
-ir_mode *get_irp_mode(int pos);
-
-/** Adds opcode to the list of opcodes in irp. */
-void add_irp_opcode(ir_op *opcode);
-
-/** Removes opcode from the list of opcodes, deallocates it and
- shrinks the list by one. */
-void remove_irp_opcode(ir_op *opcode);
-
-/** Returns the number of all opcodes in the irp. */
-int get_irp_n_opcodes(void);
-
-/** Returns the opcode at position pos in the irp. */
-ir_op *get_irp_opcode(int pos);
-
-/** Sets the generic function pointer of all opcodes to NULL */
-void clear_irp_opcodes_generic_func(void);
-
-
-/** Return the graph for global constants.
- *
- * Returns an irgraph that only contains constant expressions for
- * constant entities. Do not use any access function for this
- * graph, do not generate code for this graph. This graph contains
- * only one block. The constant expressions may not contain control
- * flow.
- * Walking the graph starting from any node will not reach the block
- * or any controlflow.
- * See also copy_const_code() in entity.h.
- */
-ir_graph *get_const_code_irg(void);
-
-
-/** The phase state for the program.
- *
- * The phase state of the whole program is
- * building: if at least one graph is state_building
- * or one type is incomplete.
- * high: all graphs are in state high or low, all types are constructed.
- * low: all graphs are in state low, all types are in state layout fixed.
- */
-irg_phase_state get_irp_phase_state(void);
-void set_irp_phase_state(irg_phase_state s);
-
-irg_outs_state get_irp_ip_outs_state(void);
-void set_irp_ip_outs_inconsistent(void);
-
-
-irg_callee_info_state get_irp_callee_info_state(void);
-void set_irp_callee_info_state(irg_callee_info_state s);
-
-#endif
#include "pseudo_irg.h"
#include "ircgcons.h"
#include "firm_common_t.h"
-#include "typegmod.h"
#include "irtypeinfo.h"
-#include "tr_inheritance.h"
#include "irmemory.h"
#include "callgraph.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Reflection for Firm operands.
- * @author Sebastian Hack
- * @date 9.9.2004
- * @version $Id$
- */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <assert.h>
-
-#ifdef HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
-# include <string.h>
-#endif
-#ifdef HAVE_STRINGS_H
-# include <strings.h>
-#endif
-
-#include "obst.h"
-
-#include "irnode_t.h"
-#include "irmode.h"
-#include "irreflect.h"
-
-#define obstack_grow_str(obst,s) obstack_grow((obst), (s), strlen((s)))
-#define obstack_grow_str_const(obst,s) obstack_grow((obst), (s), sizeof((s)))
-
-/**
- * Get the number of bits set in a word.
- */
-static INLINE int pop(int i) {
- unsigned x = (unsigned) i;
- x = ((x >> 1) & 0x55555555);
- x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
- x = (x + (x >> 4)) & 0x0f0f0f0f;
- x = x + (x >> 8);
- x = x + (x >> 16);
- return (int) (x & 0x3f);
-}
-
-/**
- * Get the number of bits differing in two variables.
- */
-static INLINE int dist(int x, int y) {
- return pop(x ^ y);
-}
-
-
-#define MAX_SIG_COUNT 8
-#define MAX_ARG_COUNT 10
-
-typedef struct {
- int num; /**< A sequential number (one opcode can have multiple signatures. */
- rflct_arg_t args[]; /**< The signature. */
-} rflct_args_t;
-
-typedef struct {
- ir_opcode opc;
- const char *name;
- int commutative;
- int sig_count;
- rflct_arg_t *sigs[MAX_SIG_COUNT];
-} rflct_opcode_t;
-
-static struct obstack obst;
-
-static rflct_opcode_t **opcodes = NULL;
-
-static int opcodes_size = 0;
-
-static INLINE void assure_opcode_capacity(int opcode)
-{
- if(opcode >= opcodes_size) {
- int new_size = 2 * opcode;
- rflct_opcode_t **new_opcodes = xcalloc(new_size, sizeof(new_opcodes[0]));
-
- if(opcodes != NULL) {
- memcpy(new_opcodes, opcodes, sizeof(*opcodes) * opcodes_size);
- free(opcodes);
- }
-
- opcodes = new_opcodes;
- opcodes_size = new_size;
- }
-}
-
-
-#if 0
-#define OPCODES_COUNT (sizeof(opcodes) / sizeof(opcodes[0]))
-#endif
-#define OPCODES_COUNT opcodes_size
-
-
-rflct_mode_class_t rflct_get_mode_class(const ir_mode *mode) {
- mode_sort sort = get_mode_sort(mode);
-
- switch(sort) {
- case irms_auxiliary:
- case irms_control_flow:
- if(mode == mode_BB)
- return RFLCT_MC(BB);
- else if(mode == mode_X)
- return RFLCT_MC(X);
- case irms_memory:
- return RFLCT_MC(Mem);
- case irms_internal_boolean:
- return RFLCT_MC(Bool);
- case irms_int_number:
- return mode_is_signed(mode) ? RFLCT_MC(IntS) : RFLCT_MC(IntU);
- case irms_float_number:
- return RFLCT_MC(Float);
- case irms_reference:
- return RFLCT_MC(Ref);
- case irms_character:
- return RFLCT_MC(Char);
- }
-
- return RFLCT_MC(None);
-}
-
-static INLINE const rflct_opcode_t *get_opcode(ir_opcode opc) {
- assert(opc >= 0 && opc < OPCODES_COUNT && "Invalid opcode");
- return opcodes[opc];
-}
-
-static INLINE const rflct_arg_t *get_args(ir_opcode opc, int sig) {
- const rflct_opcode_t *opcode = get_opcode(opc);
- assert(sig >= 0 && sig < opcode->sig_count
- && "Invalid signature");
- return opcode->sigs[sig];
-}
-
-#define GET_OPCODE(opc) get_opcode(opc)
-#define GET_ARGS(opc,args) get_args(opc, args)
-
-int rflct_get_signature_count(ir_opcode opc) {
- const rflct_opcode_t *opcode = GET_OPCODE(opc);
- return opcode->sig_count;
-}
-
-int rflct_get_in_args_count(ir_opcode opc, int sig) {
- const rflct_arg_t *args = GET_ARGS(opc, sig);
- int res = 0, i = 0;
-
- for(i = 0; args[i].name != NULL; i++);
- for(res = 0, i += 1; args[i].name != NULL; res++, i++);
- return res;
-}
-
-int rflct_get_out_args_count(ir_opcode opc, int sig) {
- const rflct_arg_t *args = GET_ARGS(opc, sig);
- int i = 0;
- for(i = 0; args[i].name != NULL; i++);
- return i;
-}
-
-
-const rflct_arg_t *rflct_get_in_args(ir_opcode opc, int sig) {
- const rflct_arg_t *args = GET_ARGS(opc, sig);
- int i;
-
- for(i = 0; args[i].name != NULL; i++);
- return &args[i + 1];
-}
-
-const rflct_arg_t *rflct_get_out_args(ir_opcode opc, int sig) {
- return GET_ARGS(opc, sig);
-}
-
-int rflct_signature_match(const ir_node *irn, int sig) {
- ir_opcode op = get_irn_opcode(irn);
- const rflct_arg_t *args = rflct_get_in_args(op, sig);
- int dst = 0;
- int i, j;
-
- for(i = 0, j = -1; RFLCT_ARG_VALID(&args[i])
- && j < get_irn_arity(irn); j++) {
-
- ir_node *child = get_irn_n(irn, j);
- const rflct_arg_t *arg = &args[i];
- rflct_mode_class_t mc = rflct_get_mode_class(get_irn_mode(child));
-
- if(arg->accepted_modes & mc)
- dst += dist(arg->accepted_modes, mc);
- else
- return INT_MAX;
-
- if(!arg->is_variadic)
- i++;
- }
-
- return dst;
-}
-
-int rflct_get_signature(const ir_node *irn) {
- const rflct_opcode_t *opc = GET_OPCODE(get_irn_opcode(irn));
- int min_dist = INT_MAX;
- int min_sig = INT_MAX;
- int i;
-
- for(i = 0; i < opc->sig_count; i++) {
- int dist = rflct_signature_match(irn, i);
- if(dist < min_dist) {
- min_dist = dist;
- min_sig = i;
- }
- }
-
- return min_sig;
-}
-
-static const char *rflct_mode_class_atomic_name(rflct_mode_class_t mc) {
-#define XXX(_mc) case RFLCT_MC(_mc): return #_mc
- switch(mc) {
- XXX(None);
- XXX(Mem);
- XXX(Bool);
- XXX(IntS);
- XXX(IntU);
- XXX(Float);
- XXX(Ref);
- XXX(Char);
- XXX(X);
- XXX(BB);
- XXX(Int);
- XXX(Intb);
- XXX(Num);
- XXX(NumP);
- XXX(Data);
- XXX(Datab);
- XXX(DataM);
- XXX(DataMX);
- XXX(Lh);
- default:
- return "";
- }
-#undef XXX
-}
-
-static void rflct_mode_class_comb_name_obst(struct obstack *obst,
- rflct_mode_class_t mc) {
- const char *res = rflct_mode_class_atomic_name(mc);
-
- if(strlen(res) == 0) {
- const char *prefix = "";
- int mask;
-
- obstack_1grow(obst, '{');
- for(mask = 1; mask != 0; mask <<= 1) {
- if(mask & mc) {
- const char *s = rflct_mode_class_atomic_name(mask);
- obstack_grow_str(obst, s);
- obstack_grow_str(obst, prefix);
- prefix = "|";
- }
- }
- obstack_1grow(obst, '}');
-
- } else
- obstack_grow(obst, res, strlen(res));
-}
-
-char *rflct_mode_class_name(char *str, int n, rflct_mode_class_t mc) {
- struct obstack obst;
- const char *res;
-
- obstack_init(&obst);
-
- rflct_mode_class_comb_name_obst(&obst, mc);
- obstack_1grow(&obst, 0);
- res = obstack_finish(&obst);
-
- strncpy(str, res, n);
-
- obstack_free(&obst, NULL);
-
- return str;
-}
-
-static void rflct_obstack_grow_args(struct obstack *obst,
- const rflct_arg_t *args) {
- const rflct_arg_t *arg;
- const char *prefix = "";
-
- for(arg = args; RFLCT_ARG_VALID(arg); arg++) {
- obstack_grow_str(obst, prefix);
- obstack_grow_str(obst, arg->name);
- if(arg->is_variadic)
- obstack_1grow(obst, '*');
- obstack_1grow(obst, ':');
- rflct_mode_class_comb_name_obst(obst, arg->accepted_modes);
- prefix = ", ";
- }
-
-}
-
-char *rflct_to_string(char *buf, int n, ir_opcode opc, int sig) {
- struct obstack obst;
- char *s;
- const rflct_opcode_t *opcode = GET_OPCODE(opc);
-
- obstack_init(&obst);
-
- obstack_1grow(&obst, '(');
- rflct_obstack_grow_args(&obst, rflct_get_out_args(opc, sig));
-
- obstack_grow_str(&obst, ") = ");
- obstack_grow_str(&obst, opcode->name);
- obstack_1grow(&obst, '(');
-
- rflct_obstack_grow_args(&obst, rflct_get_in_args(opc, sig));
-
- obstack_1grow(&obst, ')');
- obstack_1grow(&obst, 0);
- s = obstack_finish(&obst);
- strncpy(buf, s, n);
- obstack_free(&obst, NULL);
-
- return buf;
-}
-
-#define NON_VARIADIC 0
-#define VARIADIC 1
-
-#define ARG(name,modes) \
-_ARG(name, modes, NON_VARIADIC, -1)
-
-#define ARG_SAME(name,modes,mode_same) \
-_ARG(name, modes, NON_VARIADIC, mode_same)
-
-#define VARG(name,modes) \
-_ARG(name, modes, VARIADIC, 0)
-
-#define VARG_SAME(name,modes) \
-_ARG(name, modes, VARIADIC, 1)
-
-#define MARK \
-_ARG(NULL, None, NON_VARIADIC, -1)
-
-#define FINISH \
-_ARG(NULL, None, NON_VARIADIC, 0)
-
-#define BLOCK ARG("Block", BB)
-
- static void init_ops(void) {
-
- int curr_sig;
- rflct_opcode_t *opcode;
-
- obstack_init(&obst);
-
- assure_opcode_capacity(iro_MaxOpcode);
-
-
-#define BEGIN_OP(op) \
- curr_sig = 0; \
- opcode = obstack_alloc(&obst, sizeof(*opcode)); \
- opcode->opc = iro_ ## op; \
- opcode->name = #op; \
- opcodes[opcode->opc] = opcode;
-
-
-#define BEGIN_ARGS
-
-#define _ARG(_name,_modes,_variadic,_mode_equals) \
- { \
- rflct_arg_t args; \
- args.name = _name; \
- args.accepted_modes = RFLCT_MC(_modes); \
- args.is_variadic = _variadic; \
- args.mode_equals = _mode_equals; \
- obstack_grow(&obst, &args, sizeof(args)); \
- }
-
-#define END_ARGS \
- { \
- FINISH; \
- assert(curr_sig < MAX_SIG_COUNT && "Mind the maximum number of signatures"); \
- opcode->sigs[curr_sig++] = obstack_finish(&obst); \
- opcode->sig_count = curr_sig; \
- }
-
-#define END_OP
-
-#include "irreflect.def"
-
-#undef BEGIN_ARGS
-#undef END_ARGS
-#undef BEGIN_OP
-#undef END_OP
- }
-
-#undef _ARG
-#define _ARG(_name,_modes,_var,_me) \
-arg->name = _name; \
- arg->accepted_modes = RFLCT_MC(_modes); \
- arg->is_variadic = _var; \
- arg->mode_equals = _me;
-
-void rflct_new_opcode(ir_opcode opc, const char *name, int commutative)
-{
- rflct_opcode_t *ropc = obstack_alloc(&obst, sizeof(*ropc));
-
- ropc->opc = opc;
- ropc->name = name;
- ropc->sig_count = 0;
- memset(ropc->sigs, 0, sizeof(ropc->sigs));
-
- assure_opcode_capacity(opc);
- opcodes[opc] = ropc;
-}
-
-int rflct_opcode_add_signature(ir_opcode opc, rflct_sig_t *sig)
-{
- rflct_arg_t *args = sig->args;
- rflct_opcode_t *op = opcodes[opc];
- int i;
-
- assert(op && "Illegal opcode");
-
- for(i = 0; i < MAX_SIG_COUNT && op->sigs[i] != NULL; i++);
-
- if(i >= MAX_SIG_COUNT)
- return 0;
-
- op->sigs[op->sig_count++] = args;
-
- free(sig);
- return 1;
-}
-
-
-rflct_sig_t *rflct_signature_allocate(int defs, int uses)
-{
- rflct_sig_t *sig = xmalloc(sizeof(*sig));
-
- rflct_arg_t *args =
- obstack_alloc(&obst, sizeof(*args) * (defs + uses + 2));
-
- rflct_arg_t *arg = args + defs;
- MARK;
-
- arg = args + defs + uses + 1;
- FINISH;
-
- sig->defs = defs;
- sig->uses = uses;
- sig->args = args;
-
- return sig;
-}
-
-int rflct_signature_get_index(const rflct_sig_t *sig, int is_use, int num)
-{
- return is_use ? num + sig->defs + 1 : num;
-}
-
-#undef _ARG
-#define _ARG(_name,_modes,_var,_me) \
-arg->name = _name; \
- arg->accepted_modes = _modes; \
- arg->is_variadic = _var; \
- arg->mode_equals = _me;
-
-int rflct_signature_set_arg(rflct_sig_t *sig, int is_use, int num,
- const char *name, rflct_mode_class_t mc, int is_variadic, int mode_equals)
-{
- int index = rflct_signature_get_index(sig, is_use, num);
- rflct_arg_t *arg = sig->args + index;
- _ARG(name, mc, is_variadic, mode_equals);
- return index;
-}
-
-
-void firm_init_rflct(void) {
- init_ops();
-}
-
-#undef VARIADIC
-#undef NON_VARIADIC
+++ /dev/null
-
-BEGIN_OP(Block)
- BEGIN_ARGS
- ARG("Block", BB)
- MARK
- ARG("predecessors", X)
- END_ARGS
-END_OP
-
-BEGIN_OP(Start)
- BEGIN_ARGS
- ARG("Execution", X)
- ARG("Memory", Mem)
- ARG("Stack", Ref)
- ARG("Global", Ref)
- VARG("Arguments", Data)
- ARG("Call By Value", Ref)
- MARK
- BLOCK
- END_ARGS
-END_OP
-
-BEGIN_OP(End)
- BEGIN_ARGS
- MARK
- BLOCK
- VARG("Memory & Preds", Lh)
- END_ARGS
-END_OP
-
-/*
- * EndReg
- */
-
-/*
- * EndExcept
- */
-
-/*
- * Jmp
- */
-
-BEGIN_OP(Jmp)
- BEGIN_ARGS
- ARG("Target", X)
- MARK
- BLOCK
- END_ARGS
-END_OP
-
-BEGIN_OP(Break)
- BEGIN_ARGS
- ARG("Target", X)
- MARK
- BLOCK
- END_ARGS
-END_ARGS
-
-BEGIN_OP(Cond)
- BEGIN_ARGS
- ARG("False Branch", X)
- ARG("True Branch", X)
- MARK
- BLOCK
- ARG("Condition", Bool)
- END_ARGS
-
- BEGIN_ARGS
- VARG("Cases", X)
- MARK
- BLOCK
- ARG("Switch", Int)
- END_ARGS
-END_OP
-
-BEGIN_OP(Return)
- BEGIN_ARGS
- ARG("CF", X)
- MARK
- BLOCK
- ARG("Memory", Mem)
- VARG("Args", Data)
- END_ARGS
-END_OP
-
-BEGIN_OP(CallBegin)
- BEGIN_ARGS
- VARG("CF", X)
- MARK
- BLOCK
- ARG("Addr", Ref)
- END_ARGS
-END_OP
-
-BEGIN_OP(Const)
- BEGIN_ARGS
- ARG("Value", Data)
- MARK
- BLOCK
- END_ARGS
-END_OP
-
-BEGIN_OP(SymConst)
- BEGIN_ARGS
- ARG("Value", Int)
- MARK
- BLOCK
- END_ARGS
-
- BEGIN_ARGS
- ARG("Value", Ref)
- MARK
- BLOCK
- END_ARGS
-END_OP
-
-BEGIN_OP(Unknown)
- BEGIN_ARGS
- ARG("Value", Any)
- MARK
- BLOCK
- END_ARGS
-END_OP
-
-BEGIN_OP(Sel)
- BEGIN_ARGS
- ARG("Addr", Ref)
- MARK
- BLOCK
- ARG("Memory", Mem)
- ARG("Base", Ref)
- VARG_SAME("Indices", Int)
- END_ARGS
-END_OP
-
-BEGIN_OP(Call)
- BEGIN_ARGS
- ARG("Memory", Mem)
- ARG("CF", X)
- VARG("Results", Data)
- ARG("Exception Memory", Mem)
- ARG("Stack", Ref)
- MARK
- BLOCK
- ARG("Memory", Mem)
- ARG("Addr", Ref)
- VARG("Parameters", Data)
- END_ARGS
-END_OP
-
-BEGIN_OP(Add)
- BEGIN_ARGS
- ARG("Result", NumP)
- MARK
- BLOCK
- ARG_SAME("Op 1", NumP, 0)
- ARG_SAME("Op 2", NumP, 0)
- END_ARGS
-
- BEGIN_ARGS
- ARG("Result", Ref)
- MARK
- BLOCK
- ARG("Op 1", Ref)
- ARG("Op 2", Num)
- END_ARGS
-
- BEGIN_ARGS
- ARG("Result", Ref)
- MARK
- BLOCK
- ARG("Op 1", Num)
- ARG("Op 2", Ref)
- END_ARGS
-END_OP
-
-BEGIN_OP(Sub)
- BEGIN_ARGS
- ARG("Result", NumP)
- MARK
- BLOCK
- ARG_SAME("Op 1", NumP, 0)
- ARG_SAME("Op 2", NumP, 0)
- END_ARGS
-
- BEGIN_ARGS
- ARG("Result", Ref)
- MARK
- BLOCK
- ARG("Op 1", NumP)
- ARG("Op 2", Ref)
- END_ARGS
-
- BEGIN_ARGS
- ARG("Result", Ref)
- MARK
- BLOCK
- ARG("Op 1", Ref)
- ARG("Op 2", NumP)
- END_ARGS
-
- BEGIN_ARGS
- ARG("Result", Num)
- MARK
- BLOCK
- ARG("Op 1", Ref)
- ARG("Op 2", Ref)
- END_ARGS
-END_OP
-
-BEGIN_OP(Minus)
- BEGIN_ARGS
- ARG("Result", Num)
- MARK
- BLOCK
- ARG_SAME("Op 0", Num, 0)
- END_ARGS
-END_OP
-
-BEGIN_OP(Mul)
- BEGIN_ARGS
- ARG("Result", Int)
- MARK
- BLOCK
- ARG("Op 0", Int)
- ARG_SAME("Op 1", Int, 3)
- END_ARGS
-
- BEGIN_ARGS
- ARG("Result", Float)
- MARK
- BLOCK
- ARG_SAME("Op 0", Float, 0)
- ARG_SAME("Op 1", Float, 0)
- END_ARGS
-END_OP
-
-BEGIN_OP(Quot)
- BEGIN_ARGS
- ARG("Memory", Mem)
- ARG("CF", X)
- ARG("Op 0", Float)
- MARK
- BLOCK
- ARG("Memory", Mem)
- ARG_SAME("Op 0", Float, 2)
- ARG_SAME("Op 1", Float, 2)
- END_ARGS
-END_OP
-
-BEGIN_OP(DivMod)
- BEGIN_ARGS
- ARG("Memory", Mem)
- ARG("CF", X)
- ARG("Res 0", Int)
- ARG_SAME("Res 1", Int, 2)
- MARK
- BLOCK
- ARG("Memory", Mem)
- ARG_SAME("Op 0", Int, 2)
- ARG_SAME("Op 1", Int, 2)
- END_ARGS
-END_OP
-
-BEGIN_OP(Div)
-BEGIN_ARGS
- ARG("Memory", Mem)
- ARG("CF", X)
- ARG("Result", Int)
- MARK
- BLOCK
- ARG("Memory", Mem)
- ARG_SAME("Op 0", Int, 2)
- ARG_SAME("Op 1", Int, 2)
-END_ARGS
-END_OP
-
-BEGIN_OP(Mod)
-BEGIN_ARGS
- ARG("Memory", Mem)
- ARG("CF", X)
- ARG("Result", Int)
- MARK
- BLOCK
- ARG("Memory", Mem)
- ARG_SAME("Op 0", Int, 2)
- ARG_SAME("Op 1", Int, 2)
-END_ARGS
-END_OP
-
-BEGIN_OP(Abs)
-BEGIN_ARGS
- ARG("Res", Num)
- MARK
- BLOCK
- ARG_SAME("Op", Num, 0)
-END_ARGS
-END_OP
-
-BEGIN_OP(Mux)
-BEGIN_ARGS
- ARG("Res", NumP)
- MARK
- BLOCK
- ARG("Switch", Bool)
- ARG_SAME("Op 0", NumP, 0)
- ARG_SAME("Op 1", NumP, 0)
-END_ARGS
-END_OP
-
-
-BEGIN_OP(And)
-BEGIN_ARGS
- ARG("Res", Int)
- MARK
- BLOCK
- ARG_SAME("Op 0", Int, 0)
- ARG_SAME("Op 1", Int, 0)
-END_ARGS
-END_OP
-
-BEGIN_OP(Or)
-BEGIN_ARGS
- ARG("Res", Int)
- MARK
- BLOCK
- ARG_SAME("Op 0", Int, 0)
- ARG_SAME("Op 1", Int, 0)
-END_ARGS
-END_OP
-
-BEGIN_OP(Eor)
-BEGIN_ARGS
- ARG("Res", Int)
- MARK
- BLOCK
- ARG_SAME("Op 0", Int, 0)
- ARG_SAME("Op 1", Int, 0)
-END_ARGS
-END_OP
-
-BEGIN_OP(Not)
-BEGIN_ARGS
- ARG("Res", Int)
- MARK
- BLOCK
- ARG_SAME("Op", Int, 0)
-END_ARGS
-END_OP
-
-BEGIN_OP(Shl)
-BEGIN_ARGS
- ARG("Res", Int)
- MARK
- BLOCK
- ARG_SAME("Op 0", Int, 0)
- ARG("Op 1", IntU)
-END_ARGS
-END_OP
-
-BEGIN_OP(Shr)
-BEGIN_ARGS
- ARG("Res", Int)
- MARK
- BLOCK
- ARG_SAME("Op 0", Int, 0)
- ARG("Op 1", IntU)
-END_ARGS
-END_OP
-
-BEGIN_OP(Shrs)
-BEGIN_ARGS
- ARG("Res", Int)
- MARK
- BLOCK
- ARG_SAME("Op 0", Int, 0)
- ARG("Op 1", IntU)
-END_ARGS
-END_OP
-
-BEGIN_OP(Rot)
-BEGIN_ARGS
- ARG("Res", Int)
- MARK
- BLOCK
- ARG_SAME("Op 0", Int, 0)
- ARG("Op 1", Int)
-END_ARGS
-END_OP
-
-BEGIN_OP(Cmp)
-BEGIN_ARGS
- VARG("Res", Bool)
- MARK
- BLOCK
- ARG("Op 0", Datab)
- ARG_SAME("Op 1", Datab, 3)
-END_ARGS
-END_OP
-
-BEGIN_OP(Conv)
-BEGIN_ARGS
- VARG("Res", Datab)
- MARK
- BLOCK
- ARG("Op 0", Datab)
-END_ARGS
-END_OP
-
-BEGIN_OP(Phi)
-BEGIN_ARGS
- ARG_SAME("Res", DataM, 3)
- MARK
- BLOCK
- VARG("Op 0", DataM)
-END_ARGS
-END_OP
-
-BEGIN_OP(Filter)
-BEGIN_ARGS
- ARG_SAME("Res", DataM, 3)
- MARK
- BLOCK
- VARG("Op 0", DataM)
-END_ARGS
-END_OP
-
-BEGIN_OP(Load)
-BEGIN_ARGS
- ARG("Memory", Mem)
- ARG("CF", X)
- ARG("Data", Data)
- MARK
- BLOCK
- ARG("Memory", Mem)
- ARG("Addr", Ref)
-END_ARGS
-END_OP
-
-BEGIN_OP(Store)
-BEGIN_ARGS
- ARG("Memory", Mem)
- ARG("CF", X)
- MARK
- BLOCK
- ARG("Memory", Mem)
- ARG("Addr", Ref)
- ARG("Data", Data)
-END_ARGS
-END_OP
-
-BEGIN_OP(Alloc)
-BEGIN_ARGS
- ARG("Memory", Mem)
- ARG("CF", X)
- ARG("Addr", Ref)
- MARK
- BLOCK
- ARG("Memory", Mem)
- ARG("Size", IntU)
-END_ARGS
-END_OP
-
-BEGIN_OP(Free)
-BEGIN_ARGS
- ARG("Memory", Mem)
- MARK
- BLOCK
- ARG("Memory", Mem)
- ARG("Addr", Ref)
-END_ARGS
-END_OP
-
-BEGIN_OP(Sync)
-BEGIN_ARGS
- ARG("Memory", Mem)
- MARK
- BLOCK
- VARG_SAME("Memory", Mem)
-END_ARGS
-END_OP
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Reflection for Firm operations.
- * @author Sebastian Hack
- * @date 9.9.2004
- * @version $Id$
- */
-#ifndef FIRM_IR_REFLECT_H
-#define FIRM_IR_REFLECT_H
-
-#include <limits.h>
-
-#include "firm_types.h"
-#include "irop.h"
-
-#define RFLCT_MC(m) rflct_ms_ ## m
-typedef enum {
- RFLCT_MC(None) = 0,
- RFLCT_MC(Mem) = 2,
- RFLCT_MC(Bool) = 4,
- RFLCT_MC(IntS) = 8,
- RFLCT_MC(IntU) = 16,
- RFLCT_MC(Float) = 32,
- RFLCT_MC(Ref) = 64,
- RFLCT_MC(Char) = 128,
- RFLCT_MC(X) = 256,
- RFLCT_MC(BB) = 512,
- RFLCT_MC(Cf) = RFLCT_MC(X) | RFLCT_MC(BB),
-
- RFLCT_MC(Int) = RFLCT_MC(IntS) | RFLCT_MC(IntU),
- RFLCT_MC(Intb) = RFLCT_MC(Int) | RFLCT_MC(Bool),
- RFLCT_MC(Num) = RFLCT_MC(Int) | RFLCT_MC(Float),
- RFLCT_MC(NumP) = RFLCT_MC(Num) | RFLCT_MC(Ref),
- RFLCT_MC(Data) = RFLCT_MC(NumP) | RFLCT_MC(Char),
- RFLCT_MC(Datab) = RFLCT_MC(Data) | RFLCT_MC(Bool),
- RFLCT_MC(DataM) = RFLCT_MC(Data) | RFLCT_MC(Mem),
- RFLCT_MC(DataMX) = RFLCT_MC(Data) | RFLCT_MC(Mem) | RFLCT_MC(X),
- RFLCT_MC(Lh) = RFLCT_MC(Mem) | RFLCT_MC(BB),
-
- RFLCT_MC(Any) = -1
-
-} rflct_mode_class_t;
-
-typedef struct _rflct_arg_t {
- const char *name; /**< The name of the argument (just a description). */
-
- int is_variadic; /**< non-zero, if this argument can have multiple parameters. */
- rflct_mode_class_t accepted_modes; /**< The set of accepted modes. */
-
- int mode_equals; /**< If not variadic: You can specify the index of
- another argument meaning, that the mode of the
- operand binding at this argument must be the same
- as the mode of the operand binding to the argument
- at index. If you don't want to express such a
- dependency, just give -1 here.
-
- If variadic: If true, the modes of all
- variadic operands binding to this argument
- must be the same. If false, they can differ. */
-} rflct_arg_t;
-
-typedef struct _rflct_sig_t {
- int defs; /**< The number of defined arguments in the signature. */
- int uses; /**< The number of used arguments in the signature. */
-
- rflct_arg_t *args; /**< The arguments array. */
-} rflct_sig_t;
-
-#define RFLCT_ARG_IS_A(arg,modes) (((arg)->accepted_modes & modes) != 0)
-#define RFLCT_ARG_VALID(arg) ((arg)->name != NULL)
-#define RFLCT_SIG_VALID(sig) ((sig) != INT_MAX)
-
-/**
- * Get the mode class for an IR mode.
- * @param mode An IR mode.
- * @return The corresponding smallest reflection mode class.
- */
-rflct_mode_class_t rflct_get_mode_class(const ir_mode *mode);
-
-/**
- * Get the number of signatures for a Firm opcode.
- * @param opc The opcode.
- * @return The number of signatures for this opcode.
- */
-int rflct_get_signature_count(ir_opcode opc);
-
-/**
- * Try to get the signature, that matches to a given instance
- * of a Firm node.
- * @param irn The node.
- * @return The first matching signature or -1, if no signature matches.
- */
-int rflct_get_signature(const ir_node *irn);
-
-/**
- * Get the number of in arguments.
- * An in argument is a use of a value.
- * @param opc The opcode.
- * @param sig The signature you are refering to.
- * @return The number of arguments.
- */
-int rflct_get_in_args_count(ir_opcode opc, int sig);
-
-/**
- * Get the number of out arguments.
- * An out argument is a def of a value.
- * @param opc The opcode.
- * @param sig The signature you are refering to.
- * @return The number of arguments.
- */
-int rflct_get_out_args_count(ir_opcode opc, int sig);
-
-#define rflct_get_args_count(opc, sig, use) \
- ((use) ? rflct_get_in_args_count(opc, sig) : rflct_get_out_args_count(opc, sig))
-
-/**
- * Get the array of use args.
- * The array is terminated with an entry for which
- * <code>RFLCT_ARG_VALID</code> is 0.
- * @param opc The opcode.
- * @param sig The signature you are referring to (Must be between
- * 0 and the signature count).
- * @return The array.
- */
-const rflct_arg_t *rflct_get_in_args(ir_opcode opc, int sig);
-
-/**
- * Get the array of def args.
- * The array is terminated with an entry for which
- * <code>RFLCT_ARG_VALID</code> is 0.
- * @param opc The opcode.
- * @param sig The signature you are referring to (Must be between
- * 0 and the signature count).
- * @return The array.
- */
-const rflct_arg_t *rflct_get_out_args(ir_opcode opc, int sig);
-
-#define rflct_get_args(opc, sig, use) \
- ((use) ? rflct_get_in_args(opc, sig) : rflct_get_out_args(opc, sig))
-
-/**
- * Make a string representation of a signature of an opcode.
- * @param buf The buffer to put the string to.
- * @param n The size of buf.
- * @param opc The opcode.
- * @param sig The signature.
- * @return buf.
- */
-char *rflct_to_string(char *buf, int n, ir_opcode opc, int sig);
-
-/**
- * Get a string representation of a mode class.
- * @param str The buffer to put the string to.
- * @param n The size of the buffer.
- * @param mc The mode class.
- * @return str.
- */
-char *rflct_mode_class_name(char *str, int n, rflct_mode_class_t mc);
-
-/**
- * Create a new opcode.
- * @param opc The Firm opcode.
- * @param name A name.
- * @param commutative non-zero, if the opcode is commutative.
- */
-void rflct_new_opcode(ir_opcode opc, const char *name, int commutative);
-
-/**
- * Add a signature to the opcode.
- * @param opc The opcode.
- * @param sig The signature.
- * @return non-zero, if the signature was added successfully, false if no
- * more signatures can be added to the opcode.
- */
-int rflct_opcode_add_signature(ir_opcode opc, rflct_sig_t *sig);
-
-/**
- * Allocate a new signature.
- * @param defs Number of def arguments.
- * @param uses Number of use arguments.
- * @return An allocated signature.
- */
-rflct_sig_t *rflct_signature_allocate(int defs, int uses);
-
-/**
- * Set an argument in a signature.
- *
- * @param sig The signature.
- * @param is_use non-zero, if the argument is a use, else it is
- * considered a def.
- * @param num The index of the argument.
- * @param name The name of the argument.
- * @param mc The mode class of the argument.
- * @param is_variadic non-zero, if the argument is variadic.
- * @param mode_equals This variable has following meaning: If the
- * argument is variadic, a 1 indicates that all operands binding to this
- * argument must have the same mode. A 0 indicates, that their mode must
- * be of the specified mode class but can differ. If the argument is non
- * variadic, a positive number indicates, that the mode of the operand
- * binding to this argument must be the same as the one binding to
- * argument indexed by mode_equals. If the mode should not be dependent
- * to another mode, set -1 here.
- * @return The index of the argument. Only use this index in mode_equals
- * parameters of other arguments.
- */
-int rflct_signature_set_arg(rflct_sig_t *sig, int is_use, int num,
- const char *name, rflct_mode_class_t mc, int is_variadic, int mode_equals);
-
-/**
- * Get the arguments array index for an argument.
- * @param sig The signature.
- * @param is_use non-zero, if the argument indicates a use or def argument.
- * @param num The number of the argument.
- * @return The index into the arguments array.
- */
-int rflct_signature_get_index(const rflct_sig_t *sig, int is_use, int num);
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Basic (private) data structures for reflection.
- * @author Sebastian Hack
- * @date 10.9.2004
- * @version $Id$
- */
-#ifndef FIRM_IR_REFLECT_T_H
-#define FIRM_IR_REFLECT_T_H
-
-void firm_init_rflct(void);
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Check irnodes for correctness.
- * @author Christian Schaefer, Goetz Lindenmaier, Till Riedel
- * @version $Id$
- */
-#ifndef FIRM_IR_IRVRFY_H
-#define FIRM_IR_IRVRFY_H
-
-#include "firm_types.h"
-
-/**
- * Tests the modes of checknode and its predecessors.
- * checknode must be in current_ir_graph.
- *
- * @return
- * NON-zero on success
- */
-int irn_vrfy(ir_node *checknode);
-
-/**
- * Tests the modes of checknode and its predecessors.
- * checknode must be in given ir_graph.
- *
- * @return
- * NON-zero on success
- */
-int irn_vrfy_irg(ir_node *checknode, ir_graph *irg);
-
-/**
- * Same as irn_vrfy_irg, but temporary sets verification mode to
- * NODE_VERIFICATION_ERROR_ONLY.
- * @return
- * NON-zero on success
- */
-int irn_vrfy_irg_dump(ir_node *checknode, ir_graph *irg, const char **bad_string);
-
-/**
- * Flags for irg_verify().
- */
-typedef enum _irg_verify_flags_t {
- VRFY_NORMAL = 0, /**< check SSA property only if dominance information is available */
- VRFY_ENFORCE_SSA = 1 /**< check SSA property by enforcing the dominance information recalculation */
-} irg_verify_flags_t;
-
-/**
- * Calls irn_vrfy() for each node in irg.
- * Graph must be in state "op_pin_state_pinned".
- *
- * @return
- * NON-zero on success.
- */
-int irg_verify(ir_graph *irg, unsigned flags);
-
-/**
- * Compatibility macro. Deprecated soon.
- */
-#define irg_vrfy(irg) irg_verify(irg, 0)
-
-/**
- * Possible flags for irg_vrfy_bads().
- */
-enum verify_bad_flags_t {
- BAD_CF = 1, /**< Bad nodes are allowed as predecessors of Blocks and Phis. */
- BAD_DF = 2, /**< Bad nodes are allowed as dataflow predecessors. */
- BAD_BLOCK = 4, /**< Bad nodes are allowed as Block input. */
- TUPLE = 8 /**< Tuple nodes are allowed. */
-};
-
-/**
- * Verify occurrence of bad nodes in a graph.
- *
- * @param irg The graph to verify
- * @param flags combination of verify_bad_flags_t flags describing
- * which Bads are allowed
- * @returns a value combined of verify_bad_flags_t indicating the problems found.
- */
-int irg_vrfy_bads(ir_graph *irg, int flags);
-
-/**
- * Enable/disable verification of Load/Store nodes with
- * its entities. If disabled, Store(SymConst(array)) will be allowed
- * (C-frontend builds this :-)
- */
-void vrfy_enable_entity_tests(int enable);
-
-#endif
#include "ircons.h"
#include "irgmod.h"
#include "irgwalk.h"
-#include "typewalk.h"
#include "lower_calls.h"
-#include "return.h"
#include "irtools.h"
+#include "iroptimize.h"
#include "array.h"
#include "pmap.h"
#include "xmalloc.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Lowering of Calls with compound parameters and return types.
- * @author Michael Beck
- * @version $Id$
- */
-#ifndef FIRM_LOWER_LOWER_CALLS_H
-#define FIRM_LOWER_LOWER_CALLS_H
-
-/**
- * A type telling where to add hidden parameters.
- */
-typedef enum add_hidden_params {
- ADD_HIDDEN_ALWAYS_IN_FRONT = 0, /**< always add hidden parameters in front (default). */
- ADD_HIDDEN_ALWAYS_LAST = 1, /**< always add hidden parameters last, did not work for variadic functions. */
- ADD_HIDDEN_SMART = 2 /**< add hidden parameters last for non-variadic and first for variadic functions. */
-} add_hidden;
-
-/**
- * Additional flags for the lowering.
- */
-enum lowering_flags {
- LF_NONE = 0, /**< no additional flags */
- LF_COMPOUND_PARAM = 1, /**< lower calls with compound parameters */
- LF_COMPOUND_RETURN = 2, /**< lower calls with compound returns */
- LF_RETURN_HIDDEN = 4, /**< return the hidden address instead of void */
- LF_SMALL_CMP_IN_REGS = 8 /**< return small compound values in registers */
-};
-
-/** Maximum number of registers that can be used to return compound values. */
-#define MAX_REGISTER_RET_VAL 2
-
-/**
- * A struct containing all control parameters for
- * lower_compound_ret_calls().
- */
-typedef struct {
- int def_ptr_alignment; /**< Default alignment for data pointer. */
- unsigned flags; /**< A bitmask of enum lowering_flags. */
- add_hidden hidden_params; /**< Where to add hidden parameters. */
-
- /**
- * A function returning a pointer type for a given type.
- * If this pointer is NULL, a new pointer type is always created.
- */
- ir_type *(*find_pointer_type)(ir_type *e_type, ir_mode *mode, int alignment);
-
- /**
- * If the LF_SMALL_CMP_IN_REGS flag is set, this function will be called
- * to decide, whether a compound value should be returned in registers.
- * This function must return the number of used registers and fill in the modes
- * of the registers to use. Up to MAX_REGISTER_RET_VAL registers can be used.
- */
- int (*ret_compound_in_regs)(ir_type *compound_tp, ir_mode **modes);
-} lower_params_t;
-
-/**
- * Lower calls with compound parameter and return types.
- * This function does the following transformations:
- *
- * If LF_COMPOUND_PARAM is set:
- *
- * - Copy compound parameters to a new location on the callers
- * stack and transmit the address of this new location
- *
- * If LF_COMPOUND_RETURN is set:
- *
- * - Adds a new (hidden) pointer parameter for
- * any return compound type. The return type is replaced by void
- * or if LOWERING_FLAGS_RETURN_HIDDEN is set by the address.
- *
- * - Use of the hidden parameters in the function code.
- *
- * - Change all calls to functions with compound return
- * by providing space for the hidden parameter on the callers
- * stack.
- *
- * - Replace a possible block copy after the function call.
- *
- * General:
- *
- * - Changes the types of methods and calls to the lowered ones
- *
- * - lower all method types of existing entities
- *
- * In pseudo-code, the following transformation is done:
- *
- @code
- struct x ret = func(a, b);
- @endcode
- *
- * is translated into
- @code
- struct x ret;
- func(&ret, a, b);
- @endcode
- *
- * If the function returns only one possible result, the copy-on-return
- * optimization is done, ie.
- @code
- struct x func(a) {
- struct x ret;
- ret.a = a;
- return ret;
- }
- @endcode
- *
- * is transformed into
- *
- @code
- void func(struct x *ret, a) {
- ret->a = a;
- }
- @endcode
- *
- * @param params A structure containing the control parameter for this
- * transformation.
- *
- * During the transformation, pointer types must be created or reused.
- * The caller can provide params->find_pointer_type for this task to
- * reduce the number of created pointer types.
- * If params->find_pointer_type is NULL, new pointer types
- * are always created automatically.
- */
-void lower_calls_with_compounds(const lower_params_t *params);
-
-#endif /* FIRM_LOWER_LOWER_CALLS_H */
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Lower Double word operations, ie 64bit -> 32bit, 32bit -> 16bit etc.
- * @date 8.10.2004
- * @author Michael Beck
- * @version $Id$
- */
-#ifndef FIRM_LOWER_LOWER_DW_H
-#define FIRM_LOWER_LOWER_DW_H
-
-#include "firm_types.h"
-
-/**
- * A callback type for creating an intrinsic entity for a given opcode.
- *
- * @param method the method type of the emulation function entity
- * @param op the emulated ir_op
- * @param imode the input mode of the emulated opcode
- * @param omode the output mode of the emulated opcode
- * @param context the context parameter
- */
-typedef ir_entity *(create_intrinsic_fkt)(ir_type *method, const ir_op *op,
- const ir_mode *imode, const ir_mode *omode,
- void *context);
-
-/**
- * The lowering parameter description.
- */
-typedef struct _lwrdw_param_t {
- int enable; /**< if true lowering is enabled */
- int little_endian; /**< if true should be lowered for little endian, else big endian */
- ir_mode *high_signed; /**< the double word signed mode to be lowered, typically Ls */
- ir_mode *high_unsigned; /**< the double word unsigned mode to be lowered, typically Lu */
- ir_mode *low_signed; /**< the word signed mode to be used, typically Is */
- ir_mode *low_unsigned; /**< the word unsigned mode to be used, typically Iu */
-
- /** callback that creates the intrinsic entity */
- create_intrinsic_fkt *create_intrinsic;
- void *ctx; /**< context parameter for the creator function */
-} lwrdw_param_t;
-
-/**
- * Lower all double word operations.
- */
-void lower_dw_ops(const lwrdw_param_t *param);
-
-/**
- * Default implementation. Context is unused.
- */
-ir_entity *def_create_intrinsic_fkt(ir_type *method, const ir_op *op,
- const ir_mode *imode, const ir_mode *omode,
- void *context);
-
-#endif /* FIRM_LOWER_LOWER_DW_H */
#include "irmode_t.h"
#include "irnode_t.h"
#include "entity_t.h"
-#include "type.h"
+#include "typerep.h"
#include "irprog_t.h"
#include "ircons.h"
#include "lower_hl.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Lower some High-level constructs, moved from the firmlower.
- * @author Boris Boesler, Goetz Lindenmaier, Michael Beck
- * @version $Id$
- */
-#ifndef FIRM_LOWER_LOWER_HL_H
-#define FIRM_LOWER_LOWER_HL_H
-
-/**
- * Replaces SymConsts by a real constant if possible.
- * Replace Sel nodes by address computation. Also resolves array access.
- * Handle Bitfields by added And/Or calculations.
- *
- * @Note: There is NO lowering ob objects oriented types. This is highly compiler
- * and ABI specific and should be placed directly in the compiler.
- */
-void lower_highlevel(void);
-
-#endif /* FIRM_LOWER_LOWER_HL_H */
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief lowering of Calls of intrinsic functions
- * @author Michael Beck
- * @version $Id$
- */
-#ifndef FIRM_LOWER_LOWER_INTRINSICS_H
-#define FIRM_LOWER_LOWER_INTRINSICS_H
-
-#include "firm_types.h"
-
-/**
- * An intrinsic mapper function.
- *
- * @param node the IR-node that will be mapped
- * @param ctx a context
- *
- * @return non-zero if the call was mapped
- */
-typedef int (*i_mapper_func)(ir_node *node, void *ctx);
-
-enum ikind {
- INTRINSIC_CALL = 0, /**< the record represents an intrinsic call */
- INTRINSIC_INSTR /**< the record represents an intrinsic instruction */
-};
-
-/**
- * An intrinsic call record.
- */
-typedef struct _i_call_record {
- enum ikind kind; /**< must be INTRINSIC_CALL */
- ir_entity *i_ent; /**< the entity representing an intrinsic call */
- i_mapper_func i_mapper; /**< the mapper function to call */
- void *ctx; /**< mapper context */
- void *link; /**< used in the construction algorithm, must be NULL */
-} i_call_record;
-
-/**
- * An intrinsic instruction record.
- */
-typedef struct _i_instr_record {
- enum ikind kind; /**< must be INTRINSIC_INSTR */
- ir_op *op; /**< the opcode that must be mapped. */
- i_mapper_func i_mapper; /**< the mapper function to call */
- void *ctx; /**< mapper context */
- void *link; /**< used in the construction algorithm, must be NULL */
-} i_instr_record;
-
-/**
- * An intrinsic record.
- */
-typedef union _i_record {
- i_call_record i_call;
- i_instr_record i_instr;
-} i_record;
-
-/**
- * Go through all graphs and map calls to intrinsic functions and instructions.
- *
- * Every call or instruction is reported to its mapper function,
- * which is responsible for rebuilding the graph.
- *
- * current_ir_graph is always set.
- *
- * @param list an array of intrinsic map records
- * @param length the length of the array
- *
- * @return number of found intrinsics.
- */
-unsigned lower_intrinsics(i_record *list, int length);
-
-/**
- * A mapper for the integer absolute value: inttype abs(inttype v).
- * Replaces the call by a Abs node.
- *
- * @return always 1
- */
-int i_mapper_Abs(ir_node *call, void *ctx);
-
-/**
- * A mapper for the alloca() function: pointer alloca(inttype size)
- * Replaces the call by a Alloca(stack_alloc) node.
- *
- * @return always 1
- */
-int i_mapper_Alloca(ir_node *call, void *ctx);
-
-/**
- * A runtime routine description.
- */
-typedef struct _runtime_rt {
- ir_entity *ent; /**< The entity representing the runtime routine. */
- ir_mode *mode; /**< The operation mode of the mapped instruction. */
- ir_mode *res_mode; /**< The result mode of the mapped instruction or NULL. */
- long mem_proj_nr; /**< if >= 0, create a memory ProjM() */
- long regular_proj_nr; /**< if >= 0, create a regular ProjX() */
- long exc_proj_nr; /**< if >= 0, create a exception ProjX() */
- long exc_mem_proj_nr; /**< if >= 0, create a exception memory ProjM() */
- long res_proj_nr; /**< if >= 0, first result projection number */
-} runtime_rt;
-
-/**
- * A mapper for mapping unsupported instructions to runtime calls.
- * Maps a op(arg_0, ..., arg_n) into a call to a runtime function
- * rt(arg_0, ..., arg_n).
- *
- * The mapping is only done, if the modes of all arguments matches the
- * modes of rt's argument.
- * Further, if op has a memory input, the generated Call uses it, else
- * it gets a NoMem.
- * The pinned state of the Call will be set to the pinned state of op.
- *
- * Note that i_mapper_RuntimeCall() must be used with a i_instr_record.
- *
- * @return 1 if an op was mapped, 0 else
- *
- * Some examples:
- *
- * - Maps signed Div nodes to calls to rt_Div():
- @code
- runtime_rt rt_Div = {
- ent("int rt_Div(int, int)"),
- mode_T,
- mode_Is,
- pn_Div_M,
- pn_Div_X_regular,
- pn_Div_X_except,
- pn_Div_M,
- pn_Div_res
- };
- i_instr_record map_Div = {
- INTRINSIC_INSTR,
- op_Div,
- i_mapper_RuntimeCall,
- &rt_Div,
- NULL
- };
- @endcode
- *
- * - Maps ConvD(F) to calls to rt_Float2Div():
- @code
- runtime_rt rt_Float2Double = {
- ent("double rt_Float2Div(float)"),
- get_type_mode("double"),
- NULL,
- -1,
- -1,
- -1,
- -1,
- -1
- };
- i_instr_record map_Float2Double = {
- INTRINSIC_INSTR,
- op_Conv,
- i_mapper_RuntimeCall,
- &rt_Float2Double,
- NULL
- };
- @endcode
- */
-int i_mapper_RuntimeCall(ir_node *node, runtime_rt *rt);
-
-#endif /* FIRM_LOWER_LOWER_INTRINSICS_H */
# include "config.h"
#endif
+#include "iroptimize.h"
+
#include <assert.h>
#include "plist.h"
#include "irflag_t.h"
#include "firmstat.h"
-#include "cfopt.h"
#include "iropt_dbg.h"
/*------------------------------------------------------------------*/
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Control flow optimizations.
- * @author Goetz Lindenmaier, Michael Beck, Sebastian Hack
- * @version $Id$
- */
-#ifndef FIRM_OPT_CFOPT_H
-#define FIRM_OPT_CFOPT_H
-
-#include "irgraph.h"
-
-/** Control flow optimization.
- *
- * Removes empty blocks doing if simplifications and loop simplifications.
- * A block is empty if it contains only a Jmp node and Phi nodes.
- * Merges single entry single exit blocks with their predecessor
- * and propagates dead control flow by calling equivalent_node().
- * Independent of compiler flag it removes Tuples from cf edges,
- * Bad predecessors from Blocks and Phis, and unnecessary predecessors of End.
- *
- * @bug So far destroys backedge information.
- * @bug Chokes on Id nodes if called in a certain order with other
- * optimizations. Call local_optimize_graph() before to remove
- * Ids.
- */
-void optimize_cf(ir_graph *irg);
-
-#endif /* FIRM_OPT_CFOPT_H */
#include "config.h"
#endif
+#include "iroptimize.h"
+
#include <assert.h>
#include "array.h"
-#include "condeval.h"
#include "debug.h"
#include "ircons.h"
#include "irgmod.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Partial condition evaluation
- * @author Christoph Mallon, Matthias Braun
- * @version $Id$
- */
-#ifndef FIRM_OPT_CONDEVAL_H
-#define FIRM_OPT_CONDEVAL_H
-
-#include "firm_types.h"
-
-/**
- * Perform partial conditionla evaluation on the given graph.
- *
- * @param irg the graph
- */
-void opt_cond_eval(ir_graph* irg);
-
-#endif /* FIRM_OPT_CONDEVAL_H */
#include "config.h"
#endif
+#include "iroptimize.h"
+
#include <assert.h>
-#include "convopt.h"
#include "debug.h"
#include "ircons.h"
#include "irgmod.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief conv node optimisation
- * @author Matthias Braun, Christoph Mallon
- * @version $Id:$
- */
-#ifndef FIRM_OPT_CONVOPT_H
-#define FIRM_OPT_CONVOPT_H
-
-#include "firm_types.h"
-
-/**
- * Try to reduce the number of conv nodes in the given ir graph.
- *
- * @param irg the graph
- */
-void conv_opt(ir_graph *irg);
-
-#endif /* FIRM_OPT_CONVOPT_H */
#include "config.h"
#endif
-#ifdef HAVE_STRING_H
+#include "iroptimize.h"
+
#include <string.h>
-#endif
-#include "data_flow_scalar_replace.h"
#include "irflag_t.h"
#include "irouts.h"
#include "pset.h"
* Returns non-zero, if the address of an entity
* represented by a Sel node (or it's successor Sels) is taken.
*/
-static int is_address_taken(ir_node *sel)
+static int is_address_taken_2(ir_node *sel)
{
int i;
case iro_Sel: {
/* Check the Sel successor of Sel */
- int res = is_address_taken(succ);
+ int res = is_address_taken_2(succ);
if (res)
return 1;
/* we can handle arrays, structs and atomic types yet */
if (is_Array_type(ent_type) || is_Struct_type(ent_type) || is_atomic_type(ent_type)) {
- if (is_address_taken(succ)) {
+ if (is_address_taken_2(succ)) {
if (get_entity_link(ent)) /* killing one */
--res;
set_entity_link(ent, ADDRESS_TAKEN);
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief scalar replacement of compounds
- * @author Beyhan Veliev
- * @version $Id$
- */
-#ifndef FIRM_OPT_DATA_FLOW_SCALAR_REPLACE_H
-#define FIRM_OPT_DATA_FLOW_SCALAR_REPLACE_H
-
-#include "irgraph.h"
-
-/**
- * Do the scalar replacement optimization.
- * Make a date flow analyze and split the
- * data flow edges.
- *
- * @param irg the graph which should be optimized
- */
-void data_flow_scalar_replacement_opt(ir_graph *irg);
-
-#endif
*
* A fast and simple Escape analysis.
*/
-
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#include "iroptimize.h"
+
#include "irgraph_t.h"
#include "irnode_t.h"
#include "type_t.h"
#include "analyze_irg_args.h"
#include "irgmod.h"
#include "ircons.h"
-#include "escape_ana.h"
#include "debug.h"
/**
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief escape analysis and optimization
- * @author Michael Beck
- * @date 03.11.2005
- * @version $Id$
- */
-#ifndef FIRM_OPT_IR_OPT_ESCAPE_ANA_H
-#define FIRM_OPT_IR_OPT_ESCAPE_ANA_H
-
-#include "firm_types.h"
-
-/**
- * A callback that checks whether a entity is an allocation
- * routine.
- */
-typedef int (*check_alloc_entity_func)(ir_entity *ent);
-
-/**
- * Do simple and fast escape analysis for one graph.
- *
- * @param irg the graph
- * @param callback a callback function to check whether a
- * given entity is a allocation call
- */
-void escape_enalysis_irg(ir_graph *irg, check_alloc_entity_func callback);
-
-/**
- * Do simple and fast escape analysis for all graphs.
- *
- * This optimization implements a simple and fast but inexact
- * escape analysis. Some addresses might be marked as 'escaped' even
- * if they are not.
- * The advantage is a low memory footprint and fast speed.
- *
- * @param run_scalar_replace if this flag in non-zero, scalar
- * replacement optimization is run on graphs with removed
- * allocation
- * @param callback a callback function to check whether a
- * given entity is a allocation call
- *
- * This optimization removes allocation which are not used (rare) and replace
- * allocation that can be proved dead at the end of the graph which stack variables.
- *
- * The creation of stack variable allows scalar replacement to be run only
- * on those graphs that have been changed.
- *
- * This is most effective on Java where no other stack variables exists.
- */
-void escape_analysis(int run_scalar_replace, check_alloc_entity_func callback);
-
-#endif
#include "config.h"
#endif
+#include "iroptimize.h"
+
#include "irnode_t.h"
#include "irgraph_t.h"
#include "irgmod.h"
#include "dbginfo_t.h"
#include "irflag_t.h"
#include "ircons.h"
-#include "funccall.h"
#include "irhooks.h"
/**
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Optimization of function calls.
- * @author Michael Beck
- * @version $Id$
- */
-#ifndef FIRM_OPT_FUNCCALL_H
-#define FIRM_OPT_FUNCCALL_H
-
-/**
- * Optimize function calls by handling const functions.
- *
- * This optimization first detects all "const functions", i.e.,
- * IR graphs that neither read nor write memory (and hence did
- * not create exceptions, as these use memory in Firm).
- *
- * The result of calls to such functions depends only on its
- * arguments, hence those calls are no more pinned.
- *
- * This is a rather strong criteria, so do not expect that a
- * lot of functions will be found. Moreover, all of them might
- * already be inlined if inlining is activated.
- * Anyway, it might be good for handling builtin's or pseudo-graphs,
- * even if the later read/write memory (but we know how).
- *
- * This optimizations read the irg_const_function property of
- * entities and and sets the irg_const_function property of
- * graphs.
- *
- * If callee information is valid, we also optimize polymorphic Calls.
- *
- * @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.
- *
- * If the fontend created external entities with the irg_const_function
- * property set, the force_run parameter should be set, else
- * should be unset.
- *
- * @note This optimization destroys the link fields of nodes.
- */
-void optimize_funccalls(int force_run);
-
-#endif /* FIRM_OPT_FUNCCALL_H */
* @version $Id$
* @summary
*
- * Currently completely broken because our stes so NOT preserve
+ * Currently completely broken because our sets do NOT preserve
* the topological sort!
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#include "iroptimize.h"
+
#include <assert.h>
#include "irgraph_t.h"
#include "ircons.h"
#include "irgmod.h"
#include "debug.h"
-#include "gvn_pre.h"
#include "xmalloc.h"
/** The debug module handle. */
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Global Value Numbering Partial Redundancy Elimination
- * (VanDrunen Hosking 2004)
- * @author Michael Beck, Rubino Geiss
- * @version $Id$
- */
-#ifndef FIRM_OPT_GVN_PRE_H
-#define FIRM_OPT_GVN_PRE_H
-
-#include "firm_types.h"
-
-/**
- * Does Partial Redundancy Elimination combined with
- * Global Value Numbering.
- * Can be used to replace place_code() completely.
- *
- * Based on VanDrunen and Hosking 2004.
- *
- * @param irg the graph
- *
- * @note
- * Currently completely broken because the used sets do NOT
- * preserve the topological sort of its elements.
- */
-void do_gvn_pre(ir_graph *irg);
-
-#endif /* FIRM_OPT_GVN_PRE_H */
#include <assert.h>
+#include "iroptimize.h"
#include "obst.h"
#include "irnode_t.h"
#include "cdep.h"
#include "ircons.h"
-#include "ifconv.h"
#include "irdom.h"
#include "irgmod.h"
#include "irgopt.h"
#include "irgwalk.h"
#include "irtools.h"
-#include "return.h"
#include "array.h"
#include "xmalloc.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/*
- * Project: libFIRM
- * File name: ir/opt/ifconv.h
- * Purpose: If conversion.
- * Author: Sebastian Hack.
- * Created:
- * CVS-ID: $Id$
- * Copyright: (c) 1998-2005 Universität Karlsruhe
- */
-#ifndef _FIRM_IF_CONV_H
-#define _FIRM_IF_CONV_H
-
-/**
- * @file ifconv.h
- *
- * If conversion.
- * @author Sebastian Hack
- * @date 10.2.2005
- */
-#include "irnode.h"
-
-/**
- * This function is called to evaluate, if a mux can build
- * of the current architecture.
- * If it returns non-zero, a mux is created, else the code
- * is not modified.
- * @param sel A selector of a Cond.
- * @param phi_list List of Phi nodes about to be converted (linked via link field)
- * @param i First data predecessor involved in if conversion
- * @param j Second data predecessor involved in if conversion
- */
-typedef int (*arch_allow_ifconv_func)(ir_node *sel, ir_node* phi_list, int i, int j);
-
-/**
- * The parameters structure.
- */
-typedef struct _opt_if_conv_info_t {
- int max_depth; /**< The maximum depth up to which expressions
- are examined when it has to be decided if they
- can be placed into another block. */
- arch_allow_ifconv_func allow_ifconv; /**< Evaluator function, if not set all possible Psi
- nodes will be created. */
-} opt_if_conv_info_t;
-
-/**
- * Perform If conversion on a graph.
- *
- * @param irg The graph.
- * @param params The parameters for the if conversion.
- *
- * Cannot handle blocks with Bad control predecessors, so call it after control
- * flow optimization.
- */
-void opt_if_conv(ir_graph *irg, const opt_if_conv_info_t *params);
-
-#endif /* _FIRM_IF_CONV_H */
#include "config.h"
#endif
+#include "iroptimize.h"
+
#include "array.h"
#include "debug.h"
#include "ircons.h"
#include "irmemory.h"
#include "irnode.h"
#include "irnodeset.h"
-#include "ldst2.h"
#include "obst.h"
-#include "return.h"
#include "irdump.h"
#include "irflag_t.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief parallelizing Load/Store optimisation
- * @author Christoph Mallon
- * @version $Id$
- */
-#ifndef LDST2_H
-#define LDST2_H
-
-#include "firm_types.h"
-
-void opt_ldst2(ir_graph *irg);
-
-#endif
# include "config.h"
#endif
-#ifdef HAVE_STRING_H
-# include <string.h>
-#endif
+#include <string.h>
+#include "iroptimize.h"
#include "irnode_t.h"
#include "irgraph_t.h"
#include "irmode_t.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Load/Store optimizations.
- * @author Michael Beck
- * @version $Id$
- */
-#ifndef FIRM_OPT_LDSTOPT_H
-#define FIRM_OPT_LDSTOPT_H
-
-#include "firm_types.h"
-
-/** Load/Store optimization.
- *
- * Removes redundant non-volatile Loads and Stores.
- * May introduce Bad nodes if exceptional control flow
- * is removed. The following cases are optimized:
- *
- * Load without result: A Load which has only a memory use
- * is removed.
- *
- * Load after Store: A Load after a Store is removed, if
- * the Load doesn't have an exception handler OR is in
- * the same block as the Store.
- *
- * Load after Load: A Load after a Load is removed, if the
- * Load doesn't have an exception handler OR is in the
- * same block as the previous Load.
- *
- * Store before Store: A Store immediately before another
- * Store in the same block is removed, if the Store doesn't
- * have an exception handler.
- *
- * Store after Load: A Store after a Load is removed, if the
- * Store doesn't have an exception handler.
- */
-void optimize_load_store(ir_graph *irg);
-
-#endif /* FIRM_OPT_LDSTOPT_H */
#include "config.h"
#endif
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
-
-#include "loop_unrolling.h"
+#include "iroptimize.h"
#include "irnode_t.h"
#include "irgwalk.h"
#include "ircons.h"
#include "trouts.h"
#include "hashptr.h"
#include "pset.h"
-#include "strength_red.h"
+#include "strength_red_t.h"
#include "compute_loop_info.h"
#include "irdump.h"
#include "irtools.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/*
- * Project: libFIRM
- * File name: ir/opt/loop_unrolling.h
- * Purpose: Loop unrolling.
- * Author: Beyhan Veliev
- * Modified by:
- * Created: 16.11.2004
- * CVS-ID: $Id$
- * Copyright: (c) 2004 Universität Karlsruhe
- */
-
-/**
- * @file loop_unrolling.h
- *
- * Loop unrolling.
- *
- * @author Beyhan Veliev
- */
-#ifndef _LOOP_UNROLLING_H_
-#define _LOOP_UNROLLING_H_
-
-#include "irgraph.h"
-
-/**
- * Do Loop unrolling in the given graph.
- */
-void optimize_loop_unrolling(ir_graph *irg);
-
-#endif /* _LOOP_UNROLLING_H_ */
#include "config.h"
#endif
+#include "iroptimize.h"
#include "irgraph_t.h"
#include "type_t.h"
#include "irouts.h"
#include "iredges.h"
-#include "opt_frame.h"
/*
* Optimize the frame type of an irg by removing
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Optimize the frame type.
- * @date 15.03.2006
- * @author Michael Beck
- * @version $Id$
- * @summary
- * Optimize the frame type by removing unused type members.
- */
-#ifndef FIRM_OPT_FRAME_H
-#define FIRM_OPT_FRAME_H
-
-/**
- * @file opt_frame.h
- *
- * Optimize the frame type by removing unused type members.
- */
-
-#include "firm_types.h"
-
-/**
- * Optimize the frame type of an irg by removing
- * never touched entities.
- *
- * @param irg The graph whose frame type will be optimized
- *
- * This function did not change the graph, only it's frame type.
- * The layout state of the frame type will be set to layout_undefined
- * if entities were removed.
- */
-void opt_frame_irg(ir_graph *irg);
-
-#endif /* FIRM_OPT_FRAME_H */
#include "config.h"
#endif
-#include "opt_osr.h"
+#include "iroptimize.h"
#include "irgraph.h"
#include "ircons.h"
#include "irop_t.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Operator Strength Reduction.
- * @date 12.5.2006
- * @author Michael Beck
- * @version $Id$
- * @summary
- * Implementation of the Operator Strength Reduction algorithm
- * by Keith D. Cooper, L. Taylor Simpson, Christopher A. Vick.
- */
-#ifndef FIRM_OPT_OPT_OSR_H
-#define FIRM_OPT_OPT_OSR_H
-
-#include "firm_types.h"
-
-/** Possible flags for the Operator Scalar Replacement. */
-typedef enum osr_flags {
- osr_flag_none = 0, /**< no additional flags */
- osr_flag_lftr_with_ov_check = 1, /**< do linear function test replacement
- only if no overflow can occur. */
- osr_flag_ignore_x86_shift = 2 /**< ignore Multiplications by 2, 4, 8 */
-} osr_flags;
-
-/* FirmJNI cannot handle identical enum values... */
-
-/** default setting */
-#define osr_flag_default osr_flag_lftr_with_ov_check
-
-/**
- * Do the Operator Scalar Replacement optimization and linear
- * function test replacement for loop control.
- * Can be switched off using the set_opt_strength_red() flag.
- * In that case, only remove_phi_cycles() is executed.
- *
- * @param irg the graph which should be optimized
- * @param flags set of osr_flags
- *
- * The linear function replacement test is controlled by the flags.
- * If the osr_flag_lftr_with_ov_check is set, the replacement is only
- * done if do overflow can occur.
- * Otherwise it is ALWAYS done which might be insecure.
- *
- * For instance:
- *
- * for (i = 0; i < 100; ++i)
- *
- * might be replaced by
- *
- * for (i = 0; i < 400; i += 4)
- *
- * But
- *
- * for (i = 0; i < 0x7FFFFFFF; ++i)
- *
- * will not be replaced by
- *
- * for (i = 0; i < 0xFFFFFFFC; i += 4)
- *
- * because of overflow.
- *
- * More bad cases:
- *
- * for (i = 0; i <= 0xF; ++i)
- *
- * will NOT be transformed into
- *
- * for (i = 0xFFFFFFF0; i <= 0xFFFFFFFF; ++i)
- *
- * although here is no direct overflow. The OV occurs when the ++i
- * is executed (and would created an endless loop here!).
- *
- * For the same reason, a loop
- *
- * for (i = 0; i <= 9; i += x)
- *
- * will NOT be transformed because we cannot estimate whether an overflow
- * might happen adding x.
- *
- * Note that i < a + 400 is also not possible with the current implementation
- * although this might be allowed by other compilers...
- *
- * Note further that tests for equality can be handled some simpler (but are not
- * implemented yet).
- *
- * This algorithm destroys the link field of nodes.
- */
-void opt_osr(ir_graph *irg, unsigned flags);
-
-/**
- * Removes useless Phi cycles, i.e cycles of Phi nodes with only one
- * non-Phi node.
- * This is automatically done in opt_osr(), so there is no need to call it
- * additionally.
- *
- * @param irg the graph which should be optimized
- *
- * This algorithm destroys the link field of nodes.
- */
-void remove_phi_cycles(ir_graph *irg);
-
-#endif /* FIRM_OPT_OPT_OSR_H */
#include "config.h"
#endif
+#include "iroptimize.h"
#include "irprog_t.h"
#include "entity_t.h"
#include "type_t.h"
#include "firm_types.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/**
* Transform Sel(Alloc)[method]
* to SymC[method] under the following conditions:
*/
ir_node *transform_node_Load(ir_node *n);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* FIRM_OPT_OPT_POLYMORPHY_H */
#include "config.h"
#endif
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
+#include "iroptimize.h"
#include "tv.h"
#include "set.h"
-#include "entity.h"
#include "irprog_t.h"
#include "hashptr.h"
#include "irgwalk.h"
-#include "proc_cloning.h"
#include "analyze_irg_args.h"
#include "irprintf.h"
#include "ircons.h"
#include "irouts.h"
-#include "mangle.h"
#include "irnode_t.h"
#include "irtools.h"
#include "irgmod.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief procedure cloning
- * @author Beyhan Veliev
- * @version $Id$
- */
-#ifndef FIRM_OPT_PROC_CLONING_H
-#define FIRM_OPT_PROC_CLONING_H
-
-#include "firm_types.h"
-
-/** A default threshold. */
-#define DEFAULT_CLONE_THRESHOLD 300
-
-/**
- * Do procedure cloning. Evaluate a heuristic weight for every
- * Call(..., Const, ...). If the weight is bigger than threshold,
- * clone the entity and fix the calls.
- *
- * @param threshold the threshold for cloning
- *
- * The threshold is an estimation of how many instructions are saved
- * when executing a cloned method. If threshold is 0.0, every possible
- * call is cloned.
- */
-void proc_cloning(float threshold);
-
-#endif
#include "config.h"
#endif
+#include "iropt_t.h"
#include "irnode_t.h"
#include "irgraph_t.h"
#include "irmode_t.h"
-#include "iropt_t.h"
#include "ircons_t.h"
#include "irgmod.h"
#include "dbginfo.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/*
- * Project: libFIRM
- * File name: ir/opt/reassoc.h
- * Purpose: Reassociation
- * Author: Michael Beck
- * Created:
- * CVS-ID: $Id$
- * Copyright: (c) 1998-2004 Universität Karlsruhe
- */
-
-/**
- * @file reassoc.h
- *
- * Reassociation optimization.
- * Uses the "firm.opt.reassoc" debug space
- *
- * @author Michael Beck
- */
-#ifndef _REASSOC_H_
-#define _REASSOC_H_
-
-#include "irgraph.h"
-
-/** Reassociation.
- *
- * Applies Reassociation rules to integer expressions.
- * Beware: Works only if integer overflow might be ignored, as for C, Java
- * and for address expression.
- * Works only if Constant folding is activated.
- *
- * Uses loop information to detect loop-invariant (ie contant
- * inside the loop) values.
- *
- * See Muchnik 12.3.1 Algebraic Simplification and Reassociation of
- * Addressing Expressions.
- *
- *
- */
-void optimize_reassociation(ir_graph *irg);
-
-#endif /* _REASSOC_H_ */
*
* @author Michael Beck
*/
-#ifndef _REASSOC_T_H_
-#define _REASSOC_T_H_
+#ifndef REASSOC_T_H
+#define REASSOC_T_H
-#include "reassoc.h"
+#include "iroptimize.h"
/**
* Sets the default reassociation operation for an ir_op_ops.
#include "config.h"
#endif
+#include "iroptimize.h"
#include "irgraph_t.h"
#include "ircons_t.h"
#include "irnode_t.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Normalize returns.
- * @author Michael Beck
- * @version $Id$
- */
-#ifndef FIRM_OPT_RETURN_H
-#define FIRM_OPT_RETURN_H
-
-#include "firm_types.h"
-
-/**
- * Normalize the Returns of a graph by creating a new End block
- * with One Return(Phi).
- * This is the preferred input for the if-conversion.
- *
- * In pseudocode, it means:
- *
- * if (a)
- * return b;
- * else
- * return c;
- *
- * is transformed into
- *
- * if (a)
- * res = b;
- * else
- * res = c;
- * return res;
- */
-void normalize_one_return(ir_graph *irg);
-
-/**
- * Normalize the Returns of a graph by moving
- * the Returns upwards as much as possible.
- * This might be preferred for code generation.
- *
- * In pseudocode, it means:
- *
- * if (a)
- * res = b;
- * else
- * res = c;
- * return res;
- *
- * is transformed into
- *
- * if (a)
- * return b;
- * else
- * return c;
- */
-void normalize_n_returns(ir_graph *irg);
-
-#endif /* FIRM_OPT_RETURN_H */
#include "config.h"
#endif
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
+#include "iroptimize.h"
#include "scalar_replace.h"
#include "irflag_t.h"
#include "irouts.h"
*/
int is_address_taken(ir_node *sel);
-/**
- * Do the scalar replacement optimization.
- * Replace local compound entities (like structures and arrays)
- * with atomic values if possible. Does not handle classes yet.
- *
- * @param irg the graph which should be optimized
- */
-void scalar_replacement_opt(ir_graph *irg);
-
#endif /* FIRM_OPT_SCALAR_REPLACE_H */
#include "config.h"
#endif
-# include "strength_red.h"
-
-# include "irouts.h"
-# include "irnode_t.h"
-# include "irgwalk.h"
-# include "irloop_t.h"
-# include "ircons.h"
-# include "irgmod.h"
-# include "irdump_t.h"
-# include "firmstat.h"
+#include "strength_red_t.h"
+#include "iroptimize.h"
+#include "irouts.h"
+#include "irnode_t.h"
+#include "irgwalk.h"
+#include "irloop_t.h"
+#include "ircons.h"
+#include "irgmod.h"
+#include "irdump_t.h"
+#include "irprintf.h"
+#include "firmstat.h"
/** Counter for verbose information about optimization. */
n_made_new_phis++;
if (get_opt_strength_red_verbose() && get_firm_verbosity() > 1) {
- printf("The new Phi node is : "); DDMN(ivi->itervar_phi);
- printf("reducing operation is : "); DDMN(reduce_var);
- printf("in graph : "); DDMG(current_ir_graph);
+ ir_printf("The new Phi node is : %+F\n", ivi->itervar_phi);
+ ir_printf("reducing operation is : %+F\n", reduce_var);
+ ir_printf("in graph : %+F\n", current_ir_graph);
}
ivi->new_increment = new_r_Mul (current_ir_graph, block_inc, ivi->increment, mul_const,
get_irn_mode(mul_const));
}
if (get_opt_strength_red_verbose() && get_firm_verbosity() > 1) {
- printf("\nReducing operation is : "); DDMN(reduce_var);
- printf("in graph : "); DDMG(current_ir_graph);
+ ir_printf("\nReducing operation is : %+F\n", reduce_var);
+ ir_printf("in graph : %+F\n", current_ir_graph);
}
return 1;
}
add_const, ivi->new_init);
}
if (get_opt_strength_red_verbose() && get_firm_verbosity() > 1) {
- printf("\nReducing operation is : "); DDMN(reduce_var);
- printf("in graph : "); DDMG(current_ir_graph);
+ ir_printf("\nReducing operation is : %+F\n", reduce_var);
+ ir_printf("in graph : %+F\n", current_ir_graph);
}
return 1;
}
ivi->new_init = my_new_r_Sub (current_ir_graph, block_init,
ivi->new_init, sub_const);
if (get_opt_strength_red_verbose() && get_firm_verbosity() > 1) {
- printf("\nReducing operation is : "); DDMN(reduce_var);
- printf("in graph : "); DDMG(current_ir_graph);
+ ir_printf("\nReducing operation is : %+F", reduce_var);
+ ir_printf("in graph : %+F", current_ir_graph);
}
return 1;
}
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- *
- * @file strength_red.h
- *
- * Project: libFIRM
- * File name: ir/opt/strenth_red.h
- * Purpose: Strength reduction.
- * Author: Beyhan Veliev
- * Modified by:
- * Created: 22.8.2004
- * CVS-ID: $Id$
- * Copyright: (c) 2004 Universität Karlsruhe
- *
- *
- *
- *
- */
-
-
-# ifndef _STRENGTH_RED_H_
-# define _STRENGTH_RED_H_
-
-#include "irnode.h"
-#include "irgraph.h"
-#include "irloop.h"
-
-/** Performs strength reduction for the passed graph. */
-void reduce_strength(ir_graph *irg);
-
-/* The information needed for an induction variable */
-# ifndef _STRENGTH_RED_TYP_
-# define _STRENGTH_RED_TYP_
-typedef struct _induct_var_info {
- ir_op *operation_code; /**< The opcode of "op" */
- ir_node *increment; /**< The value which increase or decrease the iteration variable. */
- ir_node *init; /**< The start value of the iteration variable. */
- ir_node *op; /**< The operation which increase or decrease the iteration variable. */
- ir_node *itervar_phi; /**< The iteration variable. */
- ir_node *new_phi; /**< The new iteration variable. */
- ir_node *new_increment; /**< The new increment which replace the old one. */
- ir_node *new_init; /**< The new init value of the iteration variable. */
- ir_node *new_op; /**< The new operation that we need after replace. */
- ir_node *new_cmp; /**< The new Cmp which replaces the old one. */
- ir_node *cmp; /**< The Cmp which breaks the loop and compares the iteration variable with a constant. */
- ir_node *cmp_const; /**< The other operand of Cmp. */
- ir_node *cmp_init_block; /**< The initial block of the Cmp. */
- ir_node *reducible_node; /**< The reducible nodes are save here. */
- int is_reducible; /**< To save information if anything is reducible. */
- int phi_pred; /**< To save the value of iteration variable predecessors. */
- int init_pred_pos; /**< To save the position of iteration variable start value. */
- int op_pred_pos; /**< To save the backedge of iteration variable. */
- ir_loop *l_itervar_phi; /**< The loop of the induction variable */
-} induct_var_info;
-#endif
-
-/** If an ir_node is an induction variable return info else return NULL. */
-induct_var_info *is_induction_variable(induct_var_info *info);
-
-#endif /* _STRENGTH_RED_H_ */
# include "config.h"
#endif
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
-
#include <assert.h>
-#include "tailrec.h"
+
+#include "iroptimize.h"
+#include "scalar_replace.h"
#include "array.h"
#include "irprog_t.h"
#include "irgwalk.h"
#include "ircons.h"
#include "irflag.h"
#include "trouts.h"
-#include "return.h"
-#include "scalar_replace.h"
#include "irouts.h"
#include "irhooks.h"
#include "xmalloc.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Tail-recursion call optimization.
- * @date 08.06.2004
- * @author Michael Beck
- * @version $Id$
- */
-#ifndef FIRM_OPT_TAILREC_H
-#define FIRM_OPT_TAILREC_H
-
-#include "firm_types.h"
-
-/**
- * Optimizes simple tail-recursion calls by
- * converting them into loops. Depends on the flag opt_tail_recursion.
- *
- * Does not work for Calls that use the exception stuff.
- *
- * @param irg the graph to be optimized
- *
- * @return non-zero if the optimization could be applied, 0 else
- */
-int opt_tail_rec_irg(ir_graph *irg);
-
-/*
- * Optimize tail-recursion calls for all IR-Graphs.
- * Depends on the flag opt_tail_recursion.
- */
-void opt_tail_recursion(void);
-
-# endif /* FIRM_OPT_TAILREC_H */
#include <assert.h>
-#include "tropt.h"
-
+#include "iroptimize.h"
#include "irprog.h"
-#include "mangle.h"
-
-#include "tr_inheritance.h"
#include "irtypeinfo.h"
#include "irgwalk.h"
#include "irsimpletype.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Perform optimizations of the type representation.
- * @date 20.4.2005
- * @author Goetz Lindenmaier
- * @version $Id$
- */
-#ifndef FIRM_OPT_TROPT_H
-#define FIRM_OPT_TROPT_H
-
-#include "firm_types.h"
-
-/** This is the type for a method, that returns a pointer type to
- * tp. This is needed in the normalization. */
-typedef ir_type *(*gen_pointer_type_to_func)(ir_type *tp);
-
-/** Insert Casts so that class type casts conform exactly with the type hierarchy.
- *
- * Formulated in Java, this achieves the following:
- *
- * For a class hierarchy
- * class A {}
- * class B extends A {}
- * class C extends B {}
- * we transforms a cast
- * (A)new C()
- * to
- * (A)((B)new C()).
- *
- * The algorithm works for Casts with class types, but also for Casts
- * with all pointer types that point (over several indirections,
- * i.e. ***A) to a class type. Normalizes all graphs. Computes type
- * information (@see irtypeinfo.h) if not available.
- * Invalidates trout information as new casts are generated.
- *
- * @param gppt_fct A function that returns a pointer type that points
- * to the type given as argument. If this parameter is NULL, a default
- * function is used that either uses trout information or performs a O(n)
- * search to find an existing pointer type. If it can not find a type,
- * generates a pointer type with mode_P_mach and suffix "cc_ptr_tp".
- */
-void normalize_irp_class_casts(gen_pointer_type_to_func gppt_fct);
-
-
-/** Insert Casts so that class type casts conform exactly with the type hierarchy
- * in given graph.
- *
- * For more details see normalize_irp_class_casts().
- *
- * This transformation requires that type information is computed. @see irtypeinfo.h.
- */
-void normalize_irg_class_casts(ir_graph *irg, gen_pointer_type_to_func gppt_fct);
-
-
-/** Optimize casting between class types.
- *
- * class A { m(); }
- * class B extends A { }
- * class C extends B {}
- * Performs the following transformations:
- * C c = (C)(B)(A)(B)new C() --> C c = (C)(B)newC() --> C c = new C()
- * (Optimizing downcasts as A a = (A)(B)(new A()) --> A a = new A() can
- * be suppressed by setting the flag opt_suppress_downcast_optimization.
- * Downcasting A to B might cause an exception. It is not clear
- * whether this is modeled by the Firm Cast node, as it has no exception
- * outputs.);
- * If there is inh_m() that overwrites m() in B:
- * ((A) new B()).m() --> (new B()).inh_m()
- * Phi((A)x, (A)y) --> (A) Phi (x, y) if (A) is an upcast.
- *
- * Computes type information if not available. @see irtypeinfo.h.
- * Typeinformation is valid after optimization.
- * Invalidates trout information.
- */
-void optimize_class_casts(void);
-
-#endif /* FIRM_OPT_TROPT_H */
+++ /dev/null
-#
-# Project: libFIRM
-# File name: ir/st/Makefile.in
-# Purpose:
-# Author: Florian Liekweg, Till Riedel
-# Modified by:
-# Created:
-# CVS-ID: $Id$
-# Copyright: (c) 2001-2003 Universität Karlsruhe
-# Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
-#
-
-top_srcdir := @top_srcdir@
-srcdir = @srcdir@
-topdir = ../..
-subdir := ir/st
-
-INSTALL_HEADERS =
-
-SOURCES = $(INSTALL_HEADERS)
-
-SOURCES += Makefile.in st.c exc.c st.h exc.h bs.h
-
-
-include $(topdir)/MakeRules
-
-CPPFLAGS += -I$(top_srcdir)/ir/common -I$(top_srcdir)/ir/tr \
- -I$(top_srcdir)/ir/ident -I$(top_srcdir)/ir/adt \
- -I$(top_srcdir)/ir/ir -I$(top_srcdir)/ir/tv \
- -I$(top_srcdir)/ir/ana -I$(top_srcdir)/ir/debug
-
-include $(top_srcdir)/MakeTargets
-
-all: subdir.o
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Provides a simple bit set.
- * @author Florian Liekweg
- * @date 4.3.2002
- * @version $Id$
- * @note Not quite complete
- */
-#ifndef FIRM_ST_BS_H
-#define FIRM_ST_BS_H
-
-/**
- * the type of a bit set
- */
-typedef long int bs_t;
-
-/** set bit in a bit set */
-# define bs_set(bs, i) (bs) |= (0x00000001 << i)
-
-/** get bit in a bit set */
-# define bs_get(bs, i) (bs) & (0x00000001 << i)
-
-/** logical AND of two bit sets */
-# define bs_and(bsa, bsb) (bsa) &= (bsb)
-
-/** logical OR of two bit sets */
-# define bs_or(bsa, bsb) (bsa) |= (bsb)
-
-/** logical XOR of two bit sets */
-# define bs_xor(bsa, bsb) (bsa) ^= (bsb)
-
-/** returns TRUE if at least one bit is set */
-# define bs_zro(bs) (0x00000000 != bs)
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Helper functions for jack exceptions.
- * @author Florian Liekweg
- * @date 4.3.2002
- * @version $Id$
- */
-
-/**
- NAME
- exc
- PURPOSE
- Helper functions for exceptions
- S
- not quite complete
-***/
-
-#include <assert.h>
-#include "exc.h"
-
-static char* exc_strings [] = {
- "Invalid", /* invalid */
- "Normal", /* normal */
- "Entry", /* entry to region */
- "Exit", /* exit of region */
- "Handler", /* entry to handler */
- "Cont"
-};
-
-
-/*
- Return true iff (block b is a handler entry AND a dominates b) OR
- (b has a CFG successor that is both a handler entry AND is dominated
- by a)
-*/
-static bool has_handler (ir_graph *graph, ir_node *b, ir_node *a)
-{
- int i = 0;
- int n = get_irn_n_outs (b);
- ir_node *succ = 0;
-
- assert (0 && "Wrongly implemented");
- /* must check for _immediate_ dominance !!! */
-
- if (is_handler_entry (graph, b) && dominates (graph, a, b))
- return (true);
-
- for (i = 0; i < n; i ++)
- {
- succ = get_irn_out (b, i);
-
- if (has_handler (graph, succ, a))
- return (true);
- }
-
- return (false);
-}
-
-/*
- Return true iff the given node represents an exception jump
-*/
-static bool is_exc_jmp (ir_node *node)
-{
- ir_op *op = get_irn_op (node);
-
- /* Proj_X (Load), Proj_X (Sto), Proj_X (Div_Int),
- Proj_X (Raise), Proj_X (Call), Proj_X (Alloc) */
- if (op == op_Proj)
- {
- op = get_irn_op (get_Proj_pred (node));
-
- assert ((is_fragile_op(get_Proj_pred(node))) &&
- (op != op_Bad) /*&& (op != op_Unknown)*/ &&
- (get_irn_mode(node) == mode_X));/* Check for proper Proj attr */
- return (true);
- }
- else
- {
- return (false);
- }
-}
-
-/*
-Return true iff the given node represents a normal cfg jump
-*/
-#if 0
-static bool is_cfg_jmp (ir_node *node)
-{
- ir_op *op = get_irn_op (node);
-
- if (op == op_Proj)
- {
- op = get_irn_op (get_Proj_pred (node));
-
- /* Proj_X (Proj_Cmp (Cond)) */
- if (op_Proj == op)
- return (true); /* check for op == op_Cmp and op == op_Cond */
- }
-
- return (false);
-}
-#endif
-
-void set_Block_exc(ir_node *n, exc_t exc) {
-}
-
-exc_t get_Block_exc(ir_node *n) {
- return 0;
-}
-
-
-/* handler handling for Blocks */
-void
-set_Block_handler (ir_node *block, ir_node *handler) {
- assert (is_Block(block));
- assert (is_Block(handler));
-}
-
-ir_node *
-get_Block_handler (ir_node *block) {
- assert (is_Block(block));
- return (NULL);
-}
-
-/* handler handling for Nodes */
-void
-set_Node_handler (ir_node *node, ir_node *handler) {
-
-}
-
-ir_node *
-get_Node_handler (ir_node *node) {
- return (NULL);
-}
-
-
-/*
- Return true iff a new exception region must be left upon entry of this block.
-
- If all CFG preds of this block are exception jumps, then we must
- return true.
-*/
-bool is_handler_entry (ir_graph *graph, ir_node *block)
-{
- bool is_entry = true;
- int i = 0;
- int n = get_irn_arity (block);
-
- if (exc_invalid == get_Block_exc (block))
- {
- for (i = 0; (i < n) && (is_entry == true); i ++)
- if (is_exc_jmp (get_irn_n (block, i)))
- continue;
- else
- is_entry = false;
-
- if (true == is_entry)
- set_Block_exc (block, exc_handler);
- }
-
- return (exc_handler == get_Block_exc (block));
-}
-
-/*
- Return true iff a new exception region must be started upon entry of this block.
-
- If this block immediately dominates a handler entry, we must return true.
-*/
-bool is_region_entry (ir_graph *graph, ir_node *block)
-{
- assert (0 && "Not implemented");
-
- if (exc_invalid == get_Block_exc (block))
- {
- int i = 0;
- int n = get_irn_n_outs (block);
- ir_node *succ = 0;
-
- bool no_handler = true;
-
- for (i = 0; (i < n) && (no_handler == true); i ++)
- {
- succ = get_irn_out (block, i);
-
- if (has_handler (graph, succ, block))
- no_handler = false;
- }
-
- if (false == no_handler)
- set_Block_exc (block, exc_region);
- }
-
- return (exc_region == get_Block_exc (block));
-
- return (true);
-}
-
-/*
- Return true iff this block is part of handler code.
-
- If this block is dominated by a block for which {@link
- is_handler_entry} is true, then this block is part of the handler.
-*/
-bool is_handler_block (ir_graph *graph, ir_node *block)
-{
- assert (0 && "Not implemented");
-
- if (exc_invalid == get_Block_exc (block))
- {
- bool no_handler = true;
- dom_env_t *env = get_dom_env (graph, block);
- int block_index = env->index_a;
- bs_t block_mask = 0x00000001 << block_index;
- int n_blocks = env->dt->n_blocks;
- int i = 0;
-
- for (i = 0; (i < n_blocks) && (no_handler == true); i ++)
- if (0 != (env->dt->masks [i] & block_mask)) /* if dominator */
- if (is_handler_entry (graph, env->dt->blocks [i])) /* is handler entry */
- no_handler = false;
-
- delete_dom_env (env);
-
- if (false == no_handler)
- set_Block_exc (block, exc_handler);
- }
-
- return (exc_handler == get_Block_exc (block));
-}
-
-/*
- Convert a value of type exc_t to a descriptive string.
- Returns a reference to a statically allocated, constant string.
-*/
-
-const char *exc_to_string (exc_t exc)
-{
- int exc_val = (int) exc;
-
- assert ((0 <= (int) exc_val) && (exc_val < (int) exc_max));
-
- return (exc_strings [exc_val]);
-}
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Helper functions for jack exceptions.
- * @author Florian Liekweg
- * @date 4.3.2002
- * @version $Id$
- */
-
-/**
- NAME
- exc
- PURPOSE
- Helper functions for exceptions
- S
- not quite complete
-***/
-
-# include "irnode.h"
-
-# ifndef _EXC_H_
-# define _EXC_H_
-
-# include "st.h"
-# include "irop.h"
-# include "irouts.h"
-
-#include <stdbool.h>
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-typedef enum {
- exc_invalid = 0, /* not yet computed */
- exc_normal, /* normal CF */
-
- /* must push a new exc context at entry of block: */
- exc_region, /* region entry */
-
- /* must pop current exc context at EXIT of block */
- exc_exit, /* region exit */
-
- /* must pop current exc context at entry of block */
- exc_handler, /* handler entry */
-
- exc_max /* maximum value of enum for 'bounds checking' */
-} exc_t;
-
-
-
-const char *exc_to_string (exc_t);
-
-bool is_handler_entry (ir_graph*, ir_node*);
-bool is_region_entry (ir_graph*, ir_node*);
-bool is_handler_block (ir_graph*, ir_node*);
-bool is_cont_entry (ir_graph*, ir_node*);
-
-void set_Block_exc (ir_node*, exc_t);
-exc_t get_Block_exc (ir_node*);
-
-void set_Node_exc (ir_node*, exc_t);
-exc_t get_Node_exc (ir_node*);
-
-/* handler handling @@@ ajacs specific -- not supported */
-void set_Block_handler (ir_node*, ir_node*);
-ir_node* get_Block_handler (ir_node*);
-
-void set_Node_handler (ir_node*, ir_node*);
-ir_node* get_Node_handler (ir_node*);
-
-#ifdef __cplusplus
-}
-#endif
-
-# endif /* def _EXC_H_ */
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Provide some auxilliary structures for firm graphs.
- * @author Florian Liekweg
- * @date 26.2.2002
- * @version $Id$
- */
-
-/**
- NAME
- st.h
- PURPOSE
- provide some auxilliary structures for firm graphs.
- S
- not quite complete
-***/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <assert.h>
-
-#ifdef HAVE_STDIO_H
-# include <stdio.h>
-#endif
-#ifdef HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-
-# include "st.h"
-# include "irgwalk.h"
-# include "xmalloc.h"
-
-/* init globals: */
-/*static*/ dtree_t *trees = 0;
-/*
-static dtree_t *last = 0;
-*/
-
-/* --------------------------------------------------------------------
-* Helper Functions
-* -------------------------------------------------------------------- */
-/*
- Helper function for get_n_blocks
-*/
-static void count_block (ir_node *block, void *env)
-{
- int *n = (int*) env;
-
-# ifdef DEBUG_libfirm
- assert (block && "no block");
- assert (env && "no env");
-# endif /* def DEBUG_libfirm */
-
- fprintf (stdout, "%s: Block(%p) has # (%i)\n",
- __FILE__ ":count_block", (void *)block, *n);
-
- (*n) ++;
-}
-
-/*
- Count the number of blocks in the given graph
-*/
-static int get_n_blocks (ir_graph *graph)
-{
- int n = 0;
-
- ir_node *end_block = get_irg_end (graph);
-
-# ifdef DEBUG_libfirm
- assert (graph && "no graph");
- assert (end_block && "no end block");
-# endif /* def DEBUG_libfirm */
-
- irg_block_walk (end_block, count_block, NULL, &n);
-
- fprintf (stdout, "%s: Graph(%p) has (%i) blocks\n",
- __FILE__ ":get_n_blocks", (void *)graph, n);
-
- return (n);
-}
-
-/*
- Build an empty dominator relation entry
-*/
-static dtree_t *new_dtree (dt_t *tree, ir_graph *graph)
-{
- dtree_t *res = (dtree_t*) malloc (sizeof (dtree_t));
-
-# ifdef DEBUG_libfirm
- assert (res && "no memory for dtree");
-# endif /* def DEBUG_libfirm */
-
- res->tree = tree;
- res->graph = graph;
- res->next = 0;
-
- return (res);
-}
-
-/*
- Build an empty dominator relation
-*/
-static dt_t *new_dt (ir_graph *graph)
-{
- int n_blocks = get_n_blocks (graph);
-
- dt_t *res = (dt_t*) malloc (sizeof (dt_t));
-
-# ifdef DEBUG_libfirm
- assert (n_blocks && "no blocks for dt");
- assert (res && "no memory for dt");
-# endif /* def DEBUG_libfirm */
-
- res->n_blocks = n_blocks;
- res->graph = graph;
- res->blocks = xcalloc(n_blocks, sizeof(res->blocks[0]));
- res->idoms = xcalloc(n_blocks, sizeof(res->idoms[0]));
- res->masks = xcalloc(n_blocks, sizeof(res->masks[0]));
-
- assert (res && "no dt");
-
- return (res);
-}
-/*
-static void free_dt (dt_t *dt)
-{
- free (dt->blocks); dt->blocks = 0;
- free (dt->masks); dt->masks = 0;
- free (dt);
-}
-*/
-
-/* --------------------------------------------------------------------
-* Private Functions
-* -------------------------------------------------------------------- */
-
-/*
- Given a graph, find its dominator tree in the global list:
-
- @return The tree, if it exists, and 0 else
-*/
-static dt_t *get_dominator_tree (ir_graph *graph)
-{
- dtree_t *iter = trees;
-
-# ifdef DEBUG_libfirm
- assert (graph && "no graph");
-# endif /* def DEBUG_libfirm */
-
- while ((0 != iter) && (graph != iter->graph))
- iter = iter->next;
-
- if (0 != iter)
- {
-# ifdef DEBUG_libfirm
- assert ((graph == iter->tree->graph) && "wrong graph");
-# endif /* def DEBUG_libfirm */
-
- return (iter->tree);
- }
- else
- {
- return (0);
- }
-}
-
-/*
- Given a dominator tree and a graph, enter the tree into the global list.
-*/
-static void add_dominator_tree (dt_t *tree)
-{
- dtree_t *dtree = 0;
- ir_graph *graph = tree->graph;
-
-# ifdef DEBUG_libfirm
- assert (tree && "no tree" );
- assert (graph && "no graph");
-# endif /* def DEBUG_libfirm */
-
- dtree = new_dtree (tree, graph);
-
-# ifdef VERBOSE_libfirm
- fprintf (stdout, "%s: Adding dtree(%p) into trees(%p)\n",
- __FILE__ ":" __PRETTY_FUNCTION__, dtree, trees);
-# endif /* def VERBOSE_libfirm */
-
- /* enter in global list: */
- dtree->next = trees;
- trees = dtree;
-}
-
-/*
- Get (or create) the index for a given block
-*/
-static int get_index (dt_t *dt, ir_node *block)
-{
- int i;
-
-# ifdef DEBUG_libfirm
- assert (dt && "no dt");
- assert (block && "no block");
-# endif /* def DEBUG_libfirm */
-
- for (i = 0; (i < dt->n_blocks) && (0 != dt->blocks [i]); i ++)
- if (block == dt->blocks [i])
- return (i);
-
- /* not found . . . enter new one: */
- dt->blocks [i] = block;
- if (block == get_irg_start_block (dt->graph))
- {
- dt->masks [i] = 0x00000001 << i;
-
-# ifdef VERBOSE_libfirm
- fprintf (stdout, "%s: Adding block(%p)[%i] with [%#010lx]\n",
- __FILE__ ":" __PRETTY_FUNCTION__, block, i, dt->masks [i]);
-# endif /* def VERBOSE_libfirm */
- }
- else
- {
- dt->masks [i] = ~0x00000000;
-
-# ifdef VERBOSE_libfirm
- fprintf (stdout, "%s: Adding block(%p)[%i] with [%#010lx]\n",
- __FILE__ ":" __PRETTY_FUNCTION__, block, i, dt->masks [i]);
-# endif /* def VERBOSE_libfirm */
- }
-
- return (i);
-}
-
-/*
- Get the bit mask for a block
-*/
-static bs_t _get_mask (dt_t*, int);
-static bs_t get_mask (dt_t *dt, ir_node *block)
-{
- int index = get_index (dt, block);
-
-# ifdef DEBUG_libfirm
- assert (dt && "no dt");
- assert (block && "no block");
-# endif /* def DEBUG_libfirm */
-
- return (_get_mask (dt, index));
-}
-
-/*
- Get the bit mask for a block index
-*/
-static bs_t _get_mask (dt_t *dt, int index)
-{
-# ifdef DEBUG_libfirm
- assert (dt && "no dt");
-# endif /* def DEBUG_libfirm */
-
- return (dt->masks [index]);
-}
-
-/*
- Set the bit mask for a block
-*/
-#if 0
-static void _set_mask (dt_t*, int, bs_t);
-static void set_mask (dt_t *dt, ir_node *block, bs_t mask)
-{
- int index = get_index (dt, block);
-
-# ifdef DEBUG_libfirm
- assert (dt && "no dt");
- assert (block && "no block");
- # endif /* def DEBUG_libfirm */
-
- _set_mask (dt, index, mask);
-}
-#endif
-/*
- Set the bit mask for a block index
-*/
-static void _set_mask (dt_t *dt, int index, bs_t mask)
-{
-# ifdef DEBUG_libfirm
- assert (dt && "no dt");
-# endif /* def DEBUG_libfirm */
-
- dt->masks [index] = mask;
-}
-
-/*
- Update the list of dominators of a given block
-*/
-typedef struct dt_walk_env_t
-{
- dt_t *dt; /* the dominator relation we're building */
- ir_node *start_block; /* need to know the start block of this graph */
- bool changed; /* wether the relation has changed recently */
-}
-dt_walk_env_t;
-
-/*
- Helper function for build_dominator_tree
-*/
-static void update_dominators (ir_node *block, void *env)
-{
- int i;
- dt_walk_env_t *w = (dt_walk_env_t*) env;
- dt_t *dt = w->dt;
-
- int block_index = get_index (dt, block);
- int n_ins = get_irn_arity (block);
-
- bs_t old_mask = _get_mask (dt, block_index);
- bs_t new_mask = ~0x00000000;
-
- /* Special handling of Start Block: */
- if (block == w->start_block)
- return;
-
- /* check preds: */
- for (i = 0; i < n_ins; i ++)
- {
- ir_node *in = get_nodes_block (get_irn_n (block, i));
- bs_t in_mask = get_mask (dt, in);
-
- new_mask &= in_mask;
- }
-
- /* and remember ourselves: */
- new_mask |= (0x00000001 << block_index);
-
- if (new_mask != old_mask)
- {
- w->changed = true;
- _set_mask (dt, block_index, new_mask);
-
-# ifdef VERBOSE_libfirm
- fprintf (stdout, "%s: Updating block(%p)[%i] from [%#010lx] to [%#010lx]\n",
- __FILE__ ":" __PRETTY_FUNCTION__,
- block, block_index, old_mask, new_mask);
-# endif /* def VERBOSE_libfirm */
- }
-}
-
-/*
- Say wether a dominates b
-*/
-
-static bool _dominates (dt_t *dt, ir_node *a, ir_node *b)
-{
- int index_a = get_index (dt, a);
- bs_t b_mask = get_mask (dt, b);
-
- return (0 != (b_mask & (0x00000001 << index_a)));
-}
-
-/*
- Return the immediate dominator of block a
-*/
-static ir_node *_get_idom (dt_t *dt, ir_node *block)
-{
- ir_node *idom = 0;
- int block_index = get_index (dt, block);
-
- if (0 != (idom = dt->idoms [block_index]))
- return (idom);
-
- /* check all CFG preds:
- Question: Shouldn't it be good enough to just ask our first CFG
- predecessor? */
- {
- int i = 0;
- int n = get_irn_arity (block);
- ir_node *pred = 0;
-
- idom = block; /* prime the loop: */
-
- for (i = 0; i < n; i ++)
- {
- ir_node *ndom = 0;
-
- pred = get_nodes_block (get_irn_n (block, i));
- ndom = _get_idom (dt, pred);
-
- if (ndom != idom)
- if (_dominates (dt, idom, ndom))
- idom = ndom;
- }
- }
-
- assert (idom && "Something terribly wrong in _get_idom");
-
-# ifdef VERBOSE_libfirm
- fprintf (stdout, "%s: idom(%p) = %p\n",
- __FILE__ ":" __PRETTY_FUNCTION__,
- block, idom);
-# endif /* def VERBOSE_libfirm */
-
- /* remember it: */
- dt->idoms [block_index] = idom;
-
- return (idom);
-}
-
-/* --------------------------------------------------------------------
-* Public Functions
-* -------------------------------------------------------------------- */
-
-/*
- Say wether a dominates b
-*/
-bool dominates (ir_graph *g, ir_node *a, ir_node *b)
-{
- dt_t *dt = get_dominator_tree (g);
-
- return (_dominates (dt, a, b));
-}
-
-/*
- Return the immediate dominator of block a
-*/
-ir_node *get_idom (ir_graph *g, ir_node *a)
-{
- dt_t *dt = get_dominator_tree (g);
-
- return (_get_idom (dt, a));
-}
-
-/*
- Allow for precomputation of necessary data
- This will allow for a slightly faster lookup of the dominator
- relation if one node is checked for dominance against many other nodes.
-*/
-dom_env_t *get_dom_env (ir_graph *graph, ir_node *a)
-{
- dom_env_t *env = xcalloc(1, sizeof(*env));
-
- env->graph = graph;
- env->dt = get_dominator_tree (graph);
- env->a = a;
- env->index_a = get_index (env->dt, a);
- return env;
-}
-
-/*
- Dispose a dominator environment
-*/
-void delete_dom_env (dom_env_t *env)
-{
- env->dt = 0;
- env->a = 0;
- env->graph = 0;
- env->index_a = -1;
-
- free (env);
-}
-
-/*
- Say wether the node in env dominates b
-
- see get_dom_env
-*/
-bool dominates_l (dom_env_t *env, ir_node *b)
-{
- int index_a = env->index_a;
- dt_t *dt = env->dt;
- bs_t b_mask = get_mask (dt, b);
-
- return (0 != (b_mask & (0x00000001 << index_a)));
-}
-
-/*
- Build a new dominator tree for the given graph
-*/
-void build_dominator_tree (ir_graph *graph)
-{
- /*
- dt_walk_env_t *w = (dt_walk_env_t*) alloca (sizeof (dt_walk_env_t));
-
- ir_node *end_block = get_irg_end_block (graph);
- ir_node *start_block = get_irg_start_block (graph);
- int n_blocks = get_n_blocks (graph);
- dt_t *dt = get_dominator_tree (graph);
- */
-
- dt_walk_env_t *w = 0;
- ir_node *end_block = 0;
- ir_node *start_block = 0;
- int n_blocks = 0;
- dt_t *dt = 0;
-
- w = (dt_walk_env_t*) alloca (sizeof (dt_walk_env_t));
- end_block = get_irg_end_block (graph);
- start_block = get_irg_start_block (graph);
- n_blocks = get_n_blocks (graph);
- dt = get_dominator_tree (graph);
-
-# ifdef DEBUG_libfirm
- assert (graph && "no graph");
-# endif /* def DEBUG_libfirm */
-
-# ifdef VERBOSE_libfirm
- fprintf (stdout, "%s: for graph(%p)\n", __FILE__ ":" __PRETTY_FUNCTION__, graph);
-# endif /* def VERBOSE_libfirm */
-
- /*if (0 != dt)
- free_dt (dt); */
-
- dt = new_dt (graph);
-
- w->dt = dt;
- w->start_block = start_block;
- w->changed = true; /* at least one walk */
-
- /* do the walk: */
- {
- int walks = 0;
-
- while (w->changed)
- {
- w->changed = false;
- irg_block_walk (end_block, update_dominators, update_dominators, (void*) w);
- walks ++;
- }
-
-# ifdef VERBOSE_libfirm
- fprintf (stdout, "%s: for graph(%p): %i passes\n",
- __FILE__ ":" __PRETTY_FUNCTION__, graph, walks);
-# endif /* def VERBOSE_libfirm */
- }
-
- /* ok, now remember it: */
- add_dominator_tree (dt);
-}
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Provide some auxilliary structures for firm graphs.
- * @author Florian Liekweg
- * @date 26.2.2002
- * @version $Id$
- * @note not quite complete
- */
-#ifndef FIRM_ST_ST_H
-#define FIRM_ST_ST_H
-
-/* Includes: */
-#include "irgraph.h"
-#include "irnode.h"
-
-#include "bs.h"
-
-#include <stdbool.h>
-
-
-/* Data Types: */
-
-/** One dominator tree */
-typedef struct
-{
- int n_blocks;
- ir_graph *graph; /**< PRE */
- ir_node **blocks;
- ir_node **idoms; /**< idom [n] == immediate dominator of blocks [n] */
- bs_t *masks;
-}
-dt_t;
-
-/** List entry. */
-typedef struct dtree_t
-{
- dt_t *tree;
- ir_graph *graph;
-
- struct dtree_t *next;
-}
-dtree_t;
-
-/** dominator environment for a node dom_env_t::a in graph dom_env_t::graph */
-typedef struct dom_env_t
-{
- dt_t *dt;
- ir_graph *graph;
- ir_node *a;
- int index_a;
- bs_t mask;
-} dom_env_t;
-
-/* Forwards for Globals: */
-extern dtree_t *trees;
-extern dtree_t *last;
-
-/* Prototypes: */
-void st_build_dominator_tree (ir_graph*);
-bool dominates (ir_graph*, ir_node*, ir_node*);
-ir_node *get_idom (ir_graph*, ir_node*);
-
-dom_env_t *get_dom_env (ir_graph*, ir_node*);
-void delete_dom_env (dom_env_t*);
-bool dominates_l (dom_env_t*, ir_node*);
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Statistics for Firm.
- * @author Michael Beck
- * @version $Id$
- */
-#ifndef FIRM_STAT_FIRMSTAT_H
-#define FIRM_STAT_FIRMSTAT_H
-
-#include "irhooks.h"
-
-/**
- * Statistic options, can be or'ed.
- */
-enum firmstat_options_t {
- FIRMSTAT_ENABLED = 0x00000001, /**< enable statistics */
- FIRMSTAT_PATTERN_ENABLED = 0x00000002, /**< enable pattern calculation */
- FIRMSTAT_COUNT_STRONG_OP = 0x00000004, /**< if set, count Mul/Div/Mod/DivMod by constant */
- FIRMSTAT_COUNT_DAG = 0x00000008, /**< if set, count DAG statistics */
- FIRMSTAT_COUNT_DELETED = 0x00000010, /**< if set, count deleted graphs */
- FIRMSTAT_COUNT_SELS = 0x00000020, /**< if set, count Sel(Sel(..)) differently */
- FIRMSTAT_COUNT_CONSTS = 0x00000040, /**< if set, count Const statistics */
- FIRMSTAT_COUNT_EXTBB = 0x00000080, /**< if set, count extended Basic Block statistics */
- FIRMSTAT_CSV_OUTPUT = 0x10000000 /**< CSV output of some mini-statistic */
-};
-
-/**
- * Additional flags for statistics.
- */
-enum firmstat_optimizations_t {
- FS_OPT_NEUTRAL_0 = HOOK_OPT_LAST, /**< a op 0 = 0 op a = a */
- FS_OPT_NEUTRAL_1, /**< a op 1 = 1 op a = a */
- FS_OPT_ADD_A_A, /**< a + a = a * 2 */
- FS_OPT_ADD_A_MINUS_B, /**< a + -b = a - b */
- FS_OPT_ADD_SUB, /**< (a + x) - x = (a - x) + x */
- FS_OPT_ADD_MUL_A_X_A, /**< a * x + a = a * (x + 1) */
- FS_OPT_SUB_0_A, /**< 0 - a = -a */
- FS_OPT_SUB_MUL_A_X_A, /**< a * x - a = a * (x - 1) */
- FS_OPT_SUB_SUB_X_Y_Z, /**< (x - y) - z = x - (y + z) */
- FS_OPT_MUL_MINUS_1, /**< a * -1 = -a */
- FS_OPT_OR, /**< a | a = a | 0 = 0 | a = a */
- FS_OPT_AND, /**< a & 0b1...1 = 0b1...1 & a = a & a = a */
- FS_OPT_EOR_A_A, /**< a ^ a = 0 */
- FS_OPT_EOR_TO_NOT_BOOL, /**< bool ^ 1 = !bool */
- FS_OPT_EOR_TO_NOT, /**< x ^ 0b1..1 = ~x */
- FS_OPT_NOT_CMP, /**< !(a cmp b) = a !cmp b */
- FS_OPT_OR_SHFT_TO_ROT, /**< (x << c) | (x >> (bits - c)) == Rot(x, c) */
- FS_OPT_REASSOC_SHIFT, /**< (x SHF c1) SHF c2 = x SHF (c1+c2) */
- FS_OPT_CONV, /**< a Conv could be removed */
- FS_OPT_CAST, /**< a Cast could be removed */
- FS_OPT_MIN_MAX_EQ, /**< Min(a,a) = Max(a,a) = a */
- FS_OPT_MUX_C, /**< Mux(C, f, t) = C ? t : f */
- FS_OPT_MUX_EQ, /**< Mux(v, x, x) = x */
- FS_OPT_MUX_TRANSFORM, /**< Mux(a, b, c) = b OR Mux(a,b, c) = c */
- FS_OPT_MUX_TO_MIN, /**< Mux(a < b, a, b) = Min(a,b) */
- FS_OPT_MUX_TO_MAX, /**< Mux(a > b, a, b) = Max(a,b) */
- FS_OPT_MUX_TO_ABS, /**< Mux(a > b, a, b) = Abs(a,b) */
- FS_OPT_MUX_TO_SHR, /**< Mux(a > b, a, b) = a >> b */
- FS_OPT_CONST_PHI, /**< Constant evaluation on Phi */
- FS_BE_IA32_LEA, /**< Lea was created */
- FS_BE_IA32_LOAD_LEA, /**< Load merged with a Lea */
- FS_BE_IA32_STORE_LEA, /**< Store merged with a Lea */
- FS_BE_IA32_AM_S, /**< Source address mode node created */
- FS_BE_IA32_AM_D, /**< Destination address mode node created */
- FS_BE_IA32_CJMP, /**< CJmp created to save a cmp/test */
- FS_BE_IA32_2ADDRCPY, /**< Copy created due to 2-Addresscode constraints */
- FS_BE_IA32_SPILL2ST, /**< Created Store for a Spill */
- FS_BE_IA32_RELOAD2LD, /**< Created Load for a Reload */
- FS_BE_IA32_SUB2NEGADD, /**< Created Neg-Add for a Sub due to 2-Addresscode constraints */
- FS_BE_IA32_LEA2ADD, /**< Transformed Lea back into Add */
- FS_OPT_MAX
-};
-
-/**
- * Dump a snapshot of the statistic values.
- * Never called from libFirm should be called from user.
- *
- * @param name base name of the statistic output file
- * @param phase a phase name. Prefix will be firmstat-<phase>-
- */
-void stat_dump_snapshot(const char *name, const char *phase);
-
-/**
- * initialize the statistics module.
- *
- * @param enable_options a bitmask containing the statistic options
- */
-void firm_init_stat(unsigned enable_options);
-
-/**
- * terminates the statistics module, frees all memory
- */
-void stat_term(void);
-
-/**
- * returns 1 if statistic module is active, 0 otherwise
- */
-int stat_is_active(void);
-
-#endif /* FIRM_STAT_FIRMSTAT_H */
# include "config.h"
#endif
-#ifdef HAVE_STRING_H
-# include <string.h>
-#endif
-#ifdef HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-#ifdef HAVE_STDDEF_H
-# include <stddef.h>
-#endif
+#include <string.h>
+#include <stdlib.h>
+#include <stddef.h>
#include "firm_common_t.h"
#include "xmalloc.h"
#include "entity_t.h"
-#include "mangle.h"
-#include "typegmod.h"
#include "array.h"
#include "irtools.h"
#include "irhooks.h"
case iro_Unknown:
nn = new_d_Unknown(m); break;
default:
- DDMN(n);
assert(0 && "opcode invalid or not implemented");
nn = NULL;
break;
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/*
- * Project: libFIRM
- * File name: ir/tr/entity.h
- * Purpose: Representation of all program known entities.
- * Author: Martin Trapp, Christian Schaefer
- * Modified by: Goetz Lindenmaier, Michael Beck
- * Created:
- * CVS-ID: $Id$
- * Copyright: (c) 1998-2006 Universität Karlsruhe
- */
-
-/**
- * @file entity.h
- * @brief Representation of all program known entities.
- * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Michael Beck
- * @version $Id$
- * @summary
- *
- * An entity is the representation of program known objects in Firm.
- * The primary concept of entities is to represent members of complex
- * types, i.e., fields and methods of classes. As not all programming
- * language model all variables and methods as members of some class,
- * the concept of entities is extended to cover also local and global
- * variables, and arbitrary procedures.
- *
- * An entity always specifies the type of the object it represents and
- * the type of the object it is a part of, the owner of the entity.
- * Originally this is the type of the class of which the entity is a
- * member.
- * The owner of local variables is the procedure they are defined in.
- * The owner of global variables and procedures visible in the whole
- * program is a universally defined class type "GlobalType". The owner
- * of procedures defined in the scope of an other procedure is the
- * enclosing procedure.
- *
- * @link ir_entity
- */
-#ifndef FIRM_TR_ENTITY_H
-#define FIRM_TR_ENTITY_H
-
-#include "firm_types.h"
-#include "dbginfo.h"
-
-#include "tr_inheritance.h"
-
-/*-----------------------------------------------------------------*/
-/* ENTITY */
-/*-----------------------------------------------------------------*/
-
-/**
- * @page ir_entity Representation of an program entity.
- *
- * The type ir_entity is an abstract data type to represent program entities.
- * If contains the following attributes:
- *
- * - owner: A compound type this entity is a part of.
- * - type: The type of this entity.
- * - name: The string that represents this entity in the source program.
- * - allocation: A flag saying whether the entity is dynamically or statically
- * allocated (values: dynamic_allocated, static_allocated,
- * automatic_allocated).
- * - visibility: A flag indicating the visibility of this entity (values: local,
- * external_visible, external_allocated)
- * - variability: A flag indicating the variability of this entity (values:
- * uninitialized, initialized, part_constant, constant)
- * - volatility: @@@
- * - offset: The offset of the entity within the compound object in bytes. Only set
- * if the owner in the state "layout_fixed".
- * - offset_bits_remainder: The offset bit remainder of a bitfield entity (in a compound)
- * in bits. Only set if the owner in the state "layout_fixed".
- * - overwrites: A list of entities overwritten by this entity. This list is only
- * existent if the owner of this entity is a class. The members in
- * this list must be entities of super classes.
- * - overwrittenby: A list of entities that overwrite this entity. This list is only
- * existent if the owner of this entity is a class. The members in
- * this list must be entities of sub classes.
- * - link: A void* to associate some additional information with the entity.
- * - irg: If the entity is a method this is the ir graph that represents the
- * code of the method.
- * - peculiarity: The peculiarity of the entity. If the entity is a method this
- * indicates whether the entity represents
- * a real method or whether it only exists to describe an interface.
- * In that case there nowhere exists code for this entity and this entity
- * is never dynamically used in the code.
- * Values: description, existent. Default: existent.
- * - visited: visited flag. Master flag is type_visited.
- *
- * These fields can only be accessed via access functions.
- *
- * @see ir_type
- */
-
-/* to resolve recursion between entity.h and type.h */
-/** the type of an entity */
-#ifndef _ENTITY_TYPEDEF_
-#define _ENTITY_TYPEDEF_
-typedef struct ir_entity ir_entity, entity;
-#endif
-
-/**
- * Creates a new entity.
- *
- * Automatically inserts the entity as a member of owner.
- * Entity is automatic_allocated and uninitialized except if the type
- * is type_method, then it is static_allocated and constant. The constant
- * value is a pointer to the method.
- * Visibility is local, offset -1, and it is not volatile.
- */
-ir_entity *new_entity(ir_type *owner, ident *name, ir_type *tp);
-
-/**
- * Creates a new entity.
- *
- * Automatically inserts the entity as a member of owner.
- * The entity is automatic allocated and uninitialized except if the type
- * is type_method, then it is static allocated and constant. The constant
- * value is a pointer to the method.
- * Visibility is local, offset -1, and it is not volatile.
- */
-ir_entity *new_d_entity(ir_type *owner, ident *name, ir_type *tp, dbg_info *db);
-
-/**
- * Copies the entity if the new_owner is different from the
- * owner of the old entity, else returns the old entity.
- *
- * Automatically inserts the new entity as a member of owner.
- * Resets the overwrites/overwritten_by fields.
- * Keeps the old atomic value.
- * @@@ Maybe we should change this. If peculiarity of a method
- * is existent, we should add a new SymConst that points to
- * itself and not to the origin. Right now we have to change
- * the peculiarity and then set a new atomic value by hand.
- */
-ir_entity *copy_entity_own(ir_entity *old, ir_type *new_owner);
-
-/**
- * Copies the entity if the new_name is different from the
- * name of the old entity, else returns the old entity.
- *
- * Automatically inserts the new entity as a member of owner.
- * The mangled name ld_name is set to NULL.
- * Overwrites relation is copied from old.
- */
-ir_entity *copy_entity_name(ir_entity *old, ident *new_name);
-
-/**
- * Frees the entity.
- *
- * The owner will still contain the pointer to this
- * entity, as well as all other references!
- */
-void free_entity(ir_entity *ent);
-
-/** Returns the name of an entity. */
-const char *get_entity_name(const ir_entity *ent);
-
-/** Returns the ident of an entity. */
-ident *get_entity_ident(const ir_entity *ent);
-
-/** Sets the ident of the entity. */
-void set_entity_ident(ir_entity *ent, ident *id);
-
-/** Returns the mangled name of the entity.
- *
- * If the mangled name is set it returns the existing name.
- * Else it generates a name with mangle_entity()
- * and remembers this new name internally.
- */
-ident *get_entity_ld_ident(ir_entity *ent);
-
-/** Sets the mangled name of the entity. */
-void set_entity_ld_ident(ir_entity *ent, ident *ld_ident);
-
-/** Returns the mangled name of the entity as a string. */
-const char *get_entity_ld_name(ir_entity *ent);
-
-/** Returns the owner of the entity. */
-ir_type *get_entity_owner(ir_entity *ent);
-
-/** Sets the owner field in entity to owner. Don't forget to add
- ent to owner!! */
-void set_entity_owner(ir_entity *ent, ir_type *owner);
-
-/** Returns the type of an entity. */
-ir_type *get_entity_type(ir_entity *ent);
-
-/** Sets the type of an entity. */
-void set_entity_type(ir_entity *ent, ir_type *tp);
-
-/** The allocation type. */
-typedef enum {
- allocation_automatic, /**< The entity is allocated during runtime, implicitly
- as component of a compound type. This is the default. */
- allocation_parameter, /**< The entity is a parameter. It is also automatic allocated.
- We distinguish the allocation of parameters from the allocation
- of local variables as their placement depends on the calling
- conventions. */
- allocation_dynamic, /**< The entity is allocated during runtime, explicitly
- by an Alloc node. */
- allocation_static /**< The entity is allocated statically. We can use a
- Const as address of the entity. This is the default for methods. */
-} ir_allocation;
-
-/** Returns the allocation type of an entity. */
-ir_allocation get_entity_allocation(const ir_entity *ent);
-
-/** Sets the allocation type of an entity. */
-void set_entity_allocation(ir_entity *ent, ir_allocation al);
-
-/** Return the name of the allocation type. */
-const char *get_allocation_name(ir_allocation vis);
-
-/** Returns the visibility of an entity. */
-ir_visibility get_entity_visibility(const ir_entity *ent);
-
-/** Sets the visibility of an entity. */
-void set_entity_visibility(ir_entity *ent, ir_visibility vis);
-
-/** Return the name of the visibility */
-const char *get_visibility_name(ir_visibility vis);
-
-/** This enumeration flags the variability of entities. */
-typedef enum {
- variability_uninitialized, /**< The content of the entity is completely unknown. Default. */
- variability_initialized, /**< After allocation the entity is initialized with the
- value given somewhere in the entity. */
- variability_part_constant, /**< For entities of compound types.
- The members of the entity are mixed constant,
- initialized or uninitialized. */
- variability_constant /**< The entity is constant. */
-} ir_variability;
-
-/** Returns the variability of an entity. */
-ir_variability get_entity_variability(const ir_entity *ent);
-
-/** Sets the variability of an entity. */
-void set_entity_variability(ir_entity *ent, ir_variability var);
-
-/** Return the name of the variability. */
-const char *get_variability_name(ir_variability var);
-
-/** This enumeration flags the volatility of entities. */
-typedef enum {
- volatility_non_volatile, /**< The entity is not volatile. Default. */
- volatility_is_volatile /**< The entity is volatile */
-} ir_volatility;
-
-/** Returns the volatility of an entity. */
-ir_volatility get_entity_volatility(const ir_entity *ent);
-
-/** Sets the volatility of an entity. */
-void set_entity_volatility(ir_entity *ent, ir_volatility vol);
-
-/** Return the name of the volatility. */
-const char *get_volatility_name(ir_volatility var);
-
-/** This enumeration flags the stickyness of an entity. */
-typedef enum {
- stickyness_unsticky, /**< The entity can be removed from
- the program, unless contraindicated
- by other attributes. Default. */
- stickyness_sticky /**< The entity must remain in the
- program in any case. */
-} ir_stickyness;
-
-/** Get the entity's stickyness. */
-ir_stickyness get_entity_stickyness(const ir_entity *ent);
-
-/** Set the entity's stickyness. */
-void set_entity_stickyness(ir_entity *ent, ir_stickyness stickyness);
-
-/** Returns the offset of an entity (in a compound) in bytes. Only set if layout = fixed. */
-int get_entity_offset(const ir_entity *ent);
-
-/** Sets the offset of an entity (in a compound) in bytes. */
-void set_entity_offset(ir_entity *ent, int offset);
-
-/** Returns the offset bit remainder of a bitfield entity (in a compound) in bits. Only set if layout = fixed. */
-unsigned char get_entity_offset_bits_remainder(const ir_entity *ent);
-
-/** Sets the offset bit remainder of a bitfield entity (in a compound) in bits. */
-void set_entity_offset_bits_remainder(ir_entity *ent, unsigned char offset);
-
-/** Returns the stored intermediate information. */
-void *get_entity_link(const ir_entity *ent);
-
-/** Stores new intermediate information. */
-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.
- Only entities of peculiarity "existent" can have a corresponding irg,
- else the field is fixed to NULL. (Get returns NULL, set asserts.) */
-ir_graph *get_entity_irg(const ir_entity *ent);
-void set_entity_irg(ir_entity *ent, ir_graph *irg);
-
-/** Gets the entity vtable number. */
-unsigned get_entity_vtable_number(const ir_entity *ent);
-
-/** Sets the entity vtable number. */
-void set_entity_vtable_number(ir_entity *ent, unsigned vtable_number);
-
-/** Return the peculiarity of an entity. */
-ir_peculiarity get_entity_peculiarity(const ir_entity *ent);
-
-/** Sets the peculiarity of an entity. */
-void set_entity_peculiarity(ir_entity *ent, ir_peculiarity pec);
-
-/** Checks if an entity cannot be overridden anymore. */
-int is_entity_final(const ir_entity *ent);
-
-/** Sets/resets the final flag of an entity. */
-void set_entity_final(ir_entity *ent, int final);
-
-/** Checks if an entity is compiler generated. */
-int is_entity_compiler_generated(const ir_entity *ent);
-
-/** Sets/resets the compiler generated flag. */
-void set_entity_compiler_generated(ir_entity *ent, int flag);
-
-/**
- * The state of the address_taken flag.
- */
-typedef enum {
- ir_address_not_taken = 0, /**< The address is NOT taken. */
- ir_address_taken_unknown = 1, /**< The state of the address taken flag is unknown. */
- ir_address_taken = 2 /**< The address IS taken. */
-} ir_address_taken_state;
-
-/** Return the state of the address taken flag of an entity. */
-ir_address_taken_state get_entity_address_taken(const ir_entity *ent);
-
-/** Sets/resets the state of the address taken flag of an entity. */
-void set_entity_address_taken(ir_entity *ent, ir_address_taken_state flag);
-
-/** Return the name of the address_taken state. */
-const char *get_address_taken_state_name(ir_address_taken_state state);
-
-/* -- Representation of constant values of entities -- */
-/**
- * Returns true if the the node is representable as code on
- * const_code_irg.
- *
- * @deprecated This function is not used by libFirm and stays here
- * only as a helper for the old Jack frontend.
- */
-int is_irn_const_expression(ir_node *n);
-
-/**
- * Copies a Firm subgraph that complies to the restrictions for
- * constant expressions to current_block in current_ir_graph.
- *
- * @param dbg debug info for all newly created nodes
- * @param n the node
- *
- * Set current_ir_graph to get_const_code_irg() to generate a constant
- * expression.
- */
-ir_node *copy_const_value(dbg_info *dbg, ir_node *n);
-
-/* Set has no effect for existent entities of type method. */
-ir_node *get_atomic_ent_value(ir_entity *ent);
-void set_atomic_ent_value(ir_entity *ent, ir_node *val);
-
-/**
- * The following type describes a path to a leave in the compound graph.
- * Node 0 in the path must be an entity of type tp given in the constructor. If
- * the type of this element is compound, the path node 1 is an element of the type
- * of node 0 an so forth, until an entity of atomic type is reached.
- */
-#ifndef _COMPOUND_GRAPH_PATH_TYPEDEF_
-#define _COMPOUND_GRAPH_PATH_TYPEDEF_
-typedef struct compound_graph_path compound_graph_path;
-#endif /* _COMPOUND_GRAPH_PATH_TYPEDEF_ */
-
-/** Creates a new compound graph path. */
-compound_graph_path *new_compound_graph_path(ir_type *tp, int length);
-
-/** Returns non-zero if an object is a compound graph path */
-int is_compound_graph_path(const void *thing);
-
-/** Frees a graph path object */
-void free_compound_graph_path (compound_graph_path *gr);
-
-/** Returns the length of a graph path */
-int get_compound_graph_path_length(const compound_graph_path *gr);
-
-ir_entity *get_compound_graph_path_node(const compound_graph_path *gr, int pos);
-void set_compound_graph_path_node(compound_graph_path *gr, int pos, ir_entity *node);
-int get_compound_graph_path_array_index(const compound_graph_path *gr, int pos);
-void set_compound_graph_path_array_index(compound_graph_path *gr, int pos, int index);
-
-/** Checks whether the path up to pos is correct. If the path contains a NULL,
- * assumes the path is not complete and returns non-zero. */
-int is_proper_compound_graph_path(compound_graph_path *gr, int pos);
-
-/* A value of a compound entity is a pair of a value and the description of the
- corresponding access path to the member of the compound. */
-void add_compound_ent_value_w_path(ir_entity *ent, ir_node *val, compound_graph_path *path);
-void set_compound_ent_value_w_path(ir_entity *ent, ir_node *val, compound_graph_path *path, int pos);
-/** Returns the number of constant values needed to initialize the entity.
- *
- * Asserts if the entity has variability_uninitialized.
- * */
-int get_compound_ent_n_values(ir_entity *ent);
-/** Returns a constant value given the position. */
-ir_node *get_compound_ent_value(ir_entity *ent, int pos);
-/** Returns the access path for value at position pos. */
-compound_graph_path *get_compound_ent_value_path(ir_entity *ent, int pos);
-/** Returns a constant value given the access path.
- * The path must contain array indices for all array element entities. */
-ir_node *get_compound_ent_value_by_path(ir_entity *ent, compound_graph_path *path);
-
-/** Removes all constant entries where the path ends at value_ent. Does not
- free the memory of the paths. (The same path might be used for several
- constant entities. */
-void remove_compound_ent_value(ir_entity *ent, ir_entity *value_ent);
-
-/* Some languages support only trivial access paths, i.e., the member is a
- direct, atomic member of the constant entities type. In this case the
- corresponding entity can be accessed directly. The following functions
- allow direct access. */
-
-/** Generates a Path with length 1.
- Beware: Has a bad runtime for array elements (O(|array|) and should be
- avoided there. Use add_compound_ent_value_w_path() instead and create
- the path manually. */
-void add_compound_ent_value(ir_entity *ent, ir_node *val, ir_entity *member);
-
-/** Returns the last member in the path */
-ir_entity *get_compound_ent_value_member(ir_entity *ent, int pos);
-
-/** Sets the path at pos 0 */
-void set_compound_ent_value(ir_entity *ent, ir_node *val, ir_entity *member, int pos);
-
-/** Initializes the entity ent which must be of a one dimensional
- array type with the values given in the values array.
- The array must have a lower and an upper bound. Keeps the
- order of values. Does not test whether the number of values
- fits into the given array size. Does not test whether the
- values have the proper mode for the array. */
-void set_array_entity_values(ir_entity *ent, tarval **values, int num_vals);
-
-/**
- * Return the offset in bits from the last byte address.
- *
- * This requires that the layout of all concerned types is fixed.
- *
- * @param ent Any entity of compound type with at least pos initialization values.
- * @param pos The position of the value for which the offset is requested.
- */
-int get_compound_ent_value_offset_bit_remainder(ir_entity *ent, int pos);
-
-/** Return the overall offset of value at position pos in bytes.
- *
- * This requires that the layout of all concerned types is fixed.
- * Asserts if bit offset is not byte aligned.
- *
- * @param ent Any entity of compound type with at least pos initialization values.
- * @param pos The position of the value for which the offset is requested.
- */
-int get_compound_ent_value_offset_bytes(ir_entity *ent, int pos);
-
-/* --- 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. */
-void add_entity_overwrites (ir_entity *ent, ir_entity *overwritten);
-int get_entity_n_overwrites (ir_entity *ent);
-int get_entity_overwrites_index(ir_entity *ent, ir_entity *overwritten);
-ir_entity *get_entity_overwrites (ir_entity *ent, int pos);
-void set_entity_overwrites (ir_entity *ent, int pos, ir_entity *overwritten);
-void remove_entity_overwrites(ir_entity *ent, ir_entity *overwritten);
-
-void add_entity_overwrittenby (ir_entity *ent, ir_entity *overwrites);
-int get_entity_n_overwrittenby (ir_entity *ent);
-int get_entity_overwrittenby_index(ir_entity *ent, ir_entity *overwrites);
-ir_entity *get_entity_overwrittenby (ir_entity *ent, int pos);
-void set_entity_overwrittenby (ir_entity *ent, int pos, ir_entity *overwrites);
-void remove_entity_overwrittenby(ir_entity *ent, ir_entity *overwrites);
-
-/**
- * Checks whether a pointer points to an entity.
- *
- * @param thing an arbitrary pointer
- *
- * @return
- * true if the thing is an entity, else false
- */
-int is_entity (const void *thing);
-
-/** Returns true if the type of the entity is a primitive, pointer
- * enumeration or method type.
- *
- * @Note This is a different classification than from is_primitive_type().
- */
-int is_atomic_entity(ir_entity *ent);
-/** Returns true if the type of the entity is a class, structure,
- array or union type. */
-int is_compound_entity(ir_entity *ent);
-/** Returns true if the type of the entity is a Method type. */
-int is_method_entity(ir_entity *ent);
-
-/** Returns non-zero if ent1 and ent2 have are equal except for their owner.
- Two entities are equal if
- - they have the same type (the same C-struct)
- - ...?
-*/
-int equal_entity(ir_entity *ent1, ir_entity *ent2);
-
-/** Outputs a unique number for this entity if libfirm is compiled for
- * debugging, (configure with --enable-debug) else returns the address
- * of the type cast to long.
- */
-long get_entity_nr(const ir_entity *ent);
-
-/** Returns the entities visited count. */
-unsigned long get_entity_visited(ir_entity *ent);
-
-/** Sets the entities visited count. */
-void set_entity_visited(ir_entity *ent, unsigned long num);
-
-/** Sets visited field in entity to entity_visited. */
-void mark_entity_visited(ir_entity *ent);
-
-/** Returns true if this entity was visited. */
-int entity_visited(ir_entity *ent);
-
-/** Returns true if this entity was not visited. */
-int entity_not_visited(ir_entity *ent);
-
-/**
- * Returns the mask of the additional entity properties.
- * The properties are automatically inherited from the irg if available
- * or from the method type if they were not set using
- * set_entity_additional_properties() or
- * set_entity_additional_property().
- */
-unsigned get_entity_additional_properties(ir_entity *ent);
-
-/** Sets the mask of the additional graph properties. */
-void set_entity_additional_properties(ir_entity *ent, unsigned property_mask);
-
-/** Sets one additional graph property. */
-void set_entity_additional_property(ir_entity *ent, mtp_additional_property flag);
-
-/** Returns the class type that this type info entity represents or NULL
- if ent is no type info entity. */
-ir_type *get_entity_repr_class(const ir_entity *ent);
-
-/**
- * @page unknown_entity The Unknown entity
- *
- * This entity is an auxiliary entity dedicated to support analyses.
- *
- * The unknown entity represents that there could be an entity, but it is not
- * known. This entity can be used to initialize fields before an analysis (not known
- * yet) or to represent the top of a lattice (could not be determined). There exists
- * exactly one entity unknown. This entity has as owner and as type the unknown type. It is
- * allocated when initializing the entity module.
- *
- * The entity can take the role of any entity, also methods. It returns default
- * values in these cases.
- *
- * The following values are set:
- *
- * - name = "unknown_entity"
- * - ld_name = "unknown_entity"
- * - owner = unknown_type
- * - type = unknown_type
- * - allocation = allocation_automatic
- * - visibility = visibility_external_allocated
- * - offset = -1
- * - variability = variability_uninitialized
- * - value = SymConst(unknown_entity)
- * - values = NULL
- * - val_paths = NULL
- * - peculiarity = peculiarity_existent
- * - volatility = volatility_non_volatile
- * - stickyness = stickyness_unsticky
- * - ld_name = NULL
- * - overwrites = NULL
- * - overwrittenby = NULL
- * - irg = NULL
- * - link = NULL
- */
-/* A variable that contains the only unknown entity. */
-extern ir_entity *unknown_entity;
-
-/** Returns the @link unknown_entity unknown entity @endlink. */
-ir_entity *get_unknown_entity(void);
-
-/** Encodes how a pointer parameter is accessed. */
-typedef enum acc_bits {
- ptr_access_none = 0, /**< no access */
- ptr_access_read = 1, /**< read access */
- ptr_access_write = 2, /**< write access */
- ptr_access_rw = ptr_access_read|ptr_access_write, /**< read AND write access */
- ptr_access_store = 4, /**< the pointer is stored */
- ptr_access_all = ptr_access_rw|ptr_access_store /**< all possible access */
-} ptr_access_kind;
-
-#define IS_READ(a) ((a) & ptr_access_read)
-#define IS_WRITTEN(a) ((a) & ptr_access_write)
-#define IS_STORED(a) ((a) & ptr_access_store)
-
-/**
- * Supported image sections.
- * Currently only methods can be placed in different sections.
- */
-typedef enum {
- section_text, /**< The code segment. This is the default for methods. */
- section_constructors /**< The constructor section. */
-} ir_img_section;
-
-/** Returns the section of a method. */
-ir_img_section get_method_img_section(const ir_entity *method);
-
-/** Sets the section of a method. */
-void set_method_img_section(ir_entity *method, ir_img_section section);
-
-#endif /* FIRM_TR_ENTITY_H */
#ifndef FIRM_TR_ENTITY_T_H
#define FIRM_TR_ENTITY_T_H
+#include <assert.h>
+
#include "firm_common_t.h"
#include "firm_config.h"
+#include "typerep.h"
#include "type_t.h"
-#include "entity.h"
-#include "typegmod.h"
-#include "mangle.h"
+#include "ident.h"
#include "pseudo_irg.h"
/** A path in a compound graph. */
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Methods to manipulate names.
- * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Michael Beck
- * @version $Id$
- */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#ifdef HAVE_STDIO_H
-# include <stdio.h>
-#endif
-
-#include "mangle.h"
-#include "obst.h"
-
-/* Make types visible to allow most efficient access */
-#include "entity_t.h"
-#include "type_t.h"
-#include "tpop_t.h"
-
-/** An obstack used for temporary space */
-static struct obstack mangle_obst;
-
-/** returned a mangled type name, currently no mangling */
-static INLINE ident *mangle_type(ir_type *tp) {
- assert(tp->kind == k_type);
- return tp->name;
-}
-
-ident *mangle_entity(ir_entity *ent) {
- ident *type_id;
- char *cp;
- int len;
- ident *res;
-
- type_id = mangle_type(ent->owner);
- obstack_grow(&mangle_obst, get_id_str(type_id), get_id_strlen(type_id));
- obstack_1grow(&mangle_obst,'_');
- obstack_grow(&mangle_obst,get_id_str(ent->name),get_id_strlen(ent->name));
- len = obstack_object_size (&mangle_obst);
- cp = obstack_finish (&mangle_obst);
- res = new_id_from_chars(cp, len);
- obstack_free (&mangle_obst, cp);
- return res;
-}
-
-
-/* Returns a new ident that represents 'firstscnd'. */
-ident *mangle(ident *first, ident *scnd) {
- char *cp;
- int len;
- ident *res;
-
- obstack_grow(&mangle_obst, get_id_str(first), get_id_strlen(first));
- obstack_grow(&mangle_obst, get_id_str(scnd), get_id_strlen(scnd));
- len = obstack_object_size (&mangle_obst);
- cp = obstack_finish (&mangle_obst);
- res = new_id_from_chars (cp, len);
- obstack_free (&mangle_obst, cp);
- return res;
-}
-
-/** Returns a new ident that represents 'prefixscndsuffix'. */
-static ident *mangle3(const char *prefix, ident *scnd, const char *suffix) {
- char *cp;
- int len;
- ident *res;
-
- obstack_grow(&mangle_obst, prefix, strlen(prefix));
- obstack_grow(&mangle_obst, get_id_str(scnd), get_id_strlen(scnd));
- obstack_grow(&mangle_obst, suffix, strlen(suffix));
- len = obstack_object_size (&mangle_obst);
- cp = obstack_finish (&mangle_obst);
- res = new_id_from_chars (cp, len);
- obstack_free (&mangle_obst, cp);
- return res;
-}
-
-/** Returns a new ident that represents first<c>scnd. */
-static ident *mangle_3(ident *first, char c, ident* scnd) {
- char *cp;
- int len;
- ident *res;
-
- obstack_grow(&mangle_obst, get_id_str(first), get_id_strlen(first));
- obstack_1grow(&mangle_obst, c);
- obstack_grow(&mangle_obst,get_id_str(scnd),get_id_strlen(scnd));
- len = obstack_object_size (&mangle_obst);
- cp = obstack_finish (&mangle_obst);
- res = new_id_from_chars (cp, len);
- obstack_free (&mangle_obst, cp);
- return res;
-}
-
-/* Returns a new ident that represents first_scnd. */
-ident *mangle_u(ident *first, ident* scnd) {
- return mangle_3(first, '_', scnd);
-}
-
-/* Returns a new ident that represents first.scnd. */
-ident *mangle_dot(ident *first, ident* scnd) {
- return mangle_3(first, '.', scnd);
-}
-
-/* returns a mangled name for a Win32 function using it's calling convention */
-ident *decorate_win32_c_fkt(ir_entity *ent, ident *id) {
- ir_type *tp = get_entity_type(ent);
- unsigned cc_mask = get_method_calling_convention(tp);
- char buf[16];
- int size, i;
-
- if (IS_CDECL(cc_mask))
- return mangle3("_", id, "");
- else if (IS_STDCALL(cc_mask)) {
- size = 0;
- for (i = get_method_n_params(tp) - 1; i >= 0; --i) {
- size += get_type_size_bytes(get_method_param_type(tp, i));
- }
-
- snprintf(buf, sizeof(buf), "@%d", size);
-
- if (cc_mask & cc_reg_param)
- return mangle3("@", id, buf);
- else
- return mangle3("_", id, buf);
- }
- return id;
-}
-
-void firm_init_mangle(void) {
- obstack_init(&mangle_obst);
-}
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file mangle.h
- * @brief Methods to manipulate names.
- * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Michael Beck
- * @version $Id$
- */
-#ifndef FIRM_TR_MANGLE_H
-#define FIRM_TR_MANGLE_H
-
-#include "ident.h"
-#include "entity.h"
-
-/** initializes the name mangling code */
-void firm_init_mangle (void);
-
-/** Computes a definite name for this entity by concatenating
- the name of the owner type and the name of the entity with
- a separating "_". */
-ident *mangle_entity (ir_entity *ent);
-
-/** mangle underscore: Returns a new ident that represents first_scnd. */
-ident *mangle_u (ident *first, ident* scnd);
-
-/** mangle dot: Returns a new ident that represents first.scnd. */
-ident *mangle_dot (ident *first, ident* scnd);
-
-/** mangle: Returns a new ident that represents firstscnd. */
-ident *mangle (ident *first, ident* scnd);
-
-/** returns a mangled name for a Win32 function using it's calling convention */
-ident *decorate_win32_c_fkt(ir_entity *ent, ident *id);
-
-#endif /* FIRM_TR_MANGLE_H */
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Opcode of types.
- * @author Goetz Lindenmaier, Michael Beck
- * @version $Id$
- * @summary
- *
- * This module specifies the kinds of types available in firm.
- *
- * They are called type opcodes. These include classes, structs, methods, unions,
- * arrays, enumerations, pointers and primitive types.
- * Special types with own opcodes are the id type, a type representing an unknown
- * type and a type used to specify that something has no type.
- *
- * @see type.h
- */
-#ifndef FIRM_TR_TPOP_H
-#define FIRM_TR_TPOP_H
-
-#include "ident.h"
-
-/**
- * An enum for the type kinds.
- * For each type kind exists a typecode to identify it.
- */
-typedef enum {
- tpo_uninitialized = 0, /* not a type opcode */
- tpo_class, /**< A class type. */
- tpo_struct, /**< A struct type. */
- tpo_method, /**< A method type. */
- tpo_union, /**< An union type. */
- tpo_array, /**< An array type. */
- tpo_enumeration, /**< An enumeration type. */
- tpo_pointer, /**< A pointer type. */
- tpo_primitive, /**< A primitive type. */
- tpo_id, /**< Special Id tag used for type replacement. */
- tpo_none, /**< Special type for the None type. */
- tpo_unknown, /**< Special code for the Unknown type. */
- tpo_max /* not a type opcode */
-} tp_opcode;
-
-/**
- * A structure containing information about a kind of type.
- * A structure containing information about a kind of type. So far
- * this is only the kind name, an enum for case-switching and some
- * internal values.
- *
- * @see get_tpop_name(), get_tpop_code(), get_tpop_ident()
- */
-typedef struct tp_op tp_op;
-
-
-/**
- * Returns the string for the type opcode.
- *
- * @param op The type opcode to get the string from.
- * @return a string. (@todo Null terminated???)
- */
-const char *get_tpop_name (const tp_op *op);
-
-/**
- * Returns an enum for the type opcode.
- *
- * @param op The type opcode to get the enum from.
- * @return the enum.
- */
-tp_opcode get_tpop_code (const tp_op *op);
-
-/**
- * Returns the ident for the type opcode.
- *
- * @param op The type opcode to get the ident from.
- * @return The ident.
- */
-ident *get_tpop_ident (const tp_op *op);
-
-/**
- * This type opcode marks that the corresponding type is a class type.
- *
- * Consequently the type refers to supertypes, subtypes and entities.
- * Entities can be any fields, but also methods.
- * @@@ value class or not???
- * This struct is dynamically allocated but constant for the lifetime
- * of the library.
- */
-extern tp_op *type_class;
-tp_op *get_tpop_class(void);
-
-/**
- * This type opcode marks that the corresponding type is a compound type
- * as a struct in C.
- *
- * Consequently the type refers to a list of entities
- * which may not be methods (but pointers to methods).
- * This struct is dynamically allocated but constant for the lifetime
- * of the library.
- */
-extern tp_op *type_struct;
-tp_op *get_tpop_struct(void);
-
-/**
- * This type opcode marks that the corresponding type is a method type.
- *
- * Consequently it refers to a list of arguments and results.
- * This struct is dynamically allocated but constant for the lifetime
- * of the library.
- */
-extern tp_op *type_method;
-tp_op *get_tpop_method(void);
-
-/**
- * This type opcode marks that the corresponding type is a union type.
- *
- * Consequently it refers to a list of unioned types.
- * This struct is dynamically allocated but constant for the lifetime
- * of the library.
- */
-extern tp_op *type_union;
-tp_op *get_tpop_union(void);
-
-/**
- * This type opcode marks that the corresponding type is an array type.
- *
- * Consequently it contains a list of dimensions (lower and upper bounds)
- * and an element type.
- * This struct is dynamically allocated but constant for the lifetime
- * of the library.
- */
-extern tp_op *type_array;
-tp_op *get_tpop_array(void);
-
-/**
- * This type opcode marks that the corresponding type is an enumeration type.
- *
- * Consequently it contains a list of idents for the enumeration identifiers
- * and a list of target values that are the constants used to implement
- * the enumerators.
- * This struct is dynamically allocated but constant for the lifetime
- * of the library.
- */
-extern tp_op *type_enumeration;
-tp_op *get_tpop_enumeration(void);
-
-/**
- * This type opcode marks that the corresponding type is a pointer type.
- *
- * It contains a reference to the type the pointer points to.
- * This struct is dynamically allocated but constant for the lifetime
- * of the library.
- */
-extern tp_op *type_pointer;
-tp_op *get_tpop_pointer(void);
-
-/**
- * This type opcode marks that the corresponding type is a primitive type.
- *
- * Primitive types are types that are directly mapped to target machine
- * modes.
- * This struct is dynamically allocated but constant for the lifetime
- * of the library.
- */
-extern tp_op *type_primitive;
-tp_op *get_tpop_primitive(void);
-
-/**
- * This type opcode is an auxiliary opcode dedicated to support transformations
- * of the type structure.
- *
- * If a type is changed to another type with another
- * opcode the new type will be allocated with new memory. All nodes refering
- * to the old type need to be changed to refer to the new one. This is simplified
- * by turning the old type into an id type that merely forwards to the new type
- * that now replaces the old one.
- * type_ids should never be visible out of the type module. All access routines
- * should automatically check for type_id and eventually follow the forward in
- * type_id. Two types are exchanged by a call to exchange_types.
- * If a type_id is visible externally report this as bug. If it is assured that
- * this never happens this extern variable can be moved to tpop_t.h.
- * This struct is dynamically allocated but constant for the lifetime
- * of the library.
- */
-extern tp_op *type_id;
-tp_op *get_tpop_id(void);
-
-/**
- * This type opcode is an auxiliary opcode dedicated to support type analyses.
- *
- * Types with this opcode represents that there is no type.
- * The type can be used to initialize fields of the type* that actually can not
- * contain a type or that are initialized for an analysis. There exists exactly
- * one type with this opcode.
- */
-extern tp_op *tpop_none;
-tp_op *get_tpop_none(void);
-
-/**
- * This type opcode is an auxiliary opcode dedicated to support type analyses.
- *
- * Types with this opcode represents that there could be a type, but it is not
- * known. This type can be used to initialize fields before an analysis (not known
- * yet) or to represent the top of a lattice (could not be determined). There exists
- * exactly one type with this opcode.
- */
-extern tp_op *tpop_unknown;
-tp_op *get_tpop_unknown(void);
-
-#endif /* FIRM_TR_TPOP_H */
#include <stdlib.h>
#include "firm_types.h"
-#include "tpop.h"
+#include "typerep.h"
#include "irmode.h"
/** A function called to free attributes of a type. */
# include "config.h"
#endif
-#include "type.h"
-#include "entity.h"
-#include "typewalk.h"
+#include "typerep.h"
#include "irgraph_t.h"
#include "irprog_t.h"
+#include "irprintf.h"
#include "pset.h"
#include "set.h"
-#include "mangle.h"
#include "irgwalk.h"
#include "irflag.h"
}
if (!(this_state >= ccs->expected_state)) {
- printf(" Node is "); DDMN(n);
- printf(" totype "); DDMT(totype);
- printf(" fromtype "); DDMT(fromtype);
- printf(" this_state: %s, exp. state: %s\n",
+ ir_printf(" Node is %+F\n", n);
+ ir_printf(" totype %+F\n", totype);
+ ir_printf(" fromtype %+F\n", fromtype);
+ ir_printf(" this_state: %s, exp. state: %s\n",
get_class_cast_state_string(this_state),
get_class_cast_state_string(ccs->expected_state));
assert(this_state >= ccs->expected_state &&
irg_walk_graph(irg, NULL, verify_irn_class_cast_state, &env);
if ((env.worst_situation > env.expected_state) && get_firm_verbosity()) {
- printf("Note: class cast state is set lower than reqired in graph\n ");
- DDMG(irg);
+ ir_printf("Note: class cast state is set lower than reqired in graph \n\t%+F\n", irg);
printf(" state is %s, reqired is %s\n",
get_class_cast_state_string(env.expected_state),
get_class_cast_state_string(env.worst_situation));
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file tr_inheritance.h
- * @brief Utility routines for inheritance representation
- * @author Goetz Lindenmaier
- * @version $Id$
- * @summary
- *
- * This file supplies a set of utility routines for the inheritance
- * representation.
- *
- * Inheritance is represented in Firm by two relations: sub/supertype
- * between class types, overwrites/ovwerwrittenby between entities.
- *
- * - Classify pairs of types/entities in the inheritance relations.
- * - Resolve implicit inheritance.
- * - Compute the transitive closure of the subclass/superclass and
- * overwrites/overwrittenby relation.
- *
- * @see type.h entity.h
- */
-#ifndef FIRM_TR_INHERITANCE_H
-#define FIRM_TR_INHERITANCE_H
-
-#include "firm_types.h"
-#include "type.h"
-#include "ident.h"
-
-/* ----------------------------------------------------------------------- */
-/* 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
- * a subclass of high. I.e, we search in all subtypes of high for low.
- * @@@ this can be implemented more efficient if we know the set of all
- * subclasses of high. */
-int is_SubClass_of(ir_type *low, ir_type *high);
-
-/** Subclass check for pointers to classes.
- *
- * Dereferences at both types the same amount of pointer types (as
- * many as possible). If the remaining types are both class types
- * and subclasses, returns true, else false. Can also be called with
- * two class types. */
-int is_SubClass_ptr_of(ir_type *low, ir_type *high);
-
-/** Returns true if high is superclass of low.
- *
- * Low is a subclass of high if low == high or if low is a subclass of
- * a subclass of high. I.e, we search in all subtypes of high for low.
- * @@@ this can be implemented more efficient if we know the set of all
- * subclasses of high. */
-#define is_SuperClass_of(high, low) is_SubClass_of(low, high)
-
-/** Superclass check for pointers to classes.
- *
- * Dereferences at both types the same amount of pointer types (as
- * many as possible). If the remaining types are both class types
- * and superclasses, returns true, else false. Can also be called with
- * two class types. */
-#define is_SuperClass_ptr_of(low, high) is_SubClass_ptr_of(high, low)
-
-/** Returns true if high is (transitive) overwritten by low.
- *
- * Returns false if high == low. */
-int is_overwritten_by(ir_entity *high, ir_entity *low);
-
-/** Resolve polymorphism in the inheritance relation.
- *
- * Returns the dynamically referenced entity if the static entity and the
- * dynamic type are given.
- * Searches downwards in overwritten tree. */
-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
- * underscore and the name (not ld_name) of the entity. */
-ident *default_mangle_inherited_name(ir_entity *ent, ir_type *clss);
-
-/** Type of argument functions for inheritance resolver.
- *
- * @param ent The entity in the super type that will be overwritten
- * by the newly generated entity, for which this name is
- * used.
- * @param clss The class type in which the new entity will be placed.
- */
-typedef ident *mangle_inherited_name_func(ir_entity *ent, ir_type *clss);
-
-/** Resolve implicit inheritance.
- *
- * Resolves the implicit inheritance supplied by firm. Firm defines,
- * that each entity that is not overwritten in a subclass is
- * inherited to this subclass without change implicitly. This
- * function generates entities that explicitly represent this
- * inheritance. It generates for each entity overwriting entities in
- * all subclasses of the owner of the entity, if the entity is not
- * overwritten in that subclass.
- *
- * The name of the new entity is generated with the function passed.
- * If the function is NULL, the default_mangle_inherited_name() is
- * used.
- *
- * This function was moved here from firmlower 3/2005.
- */
-void resolve_inheritance(mangle_inherited_name_func *mfunc);
-
-
-/* ----------------------------------------------------------------------- */
-/* The transitive closure of the subclass/superclass and */
-/* overwrites/overwrittenby relation. */
-/* */
-/* A walk over the ir (O(#types+#entities)) computes the transitive */
-/* closure. Adding a new type/entity or changing the basic relations in */
-/* some other way invalidates the transitive closure, i.e., it is not */
-/* updated by the basic functions. */
-/* */
-/* The transitive edges are held in a set, not in an array as the */
-/* underlying relation. */
-/* */
-/* Do the sets contain the node itself? I assume NOT! */
-/* ----------------------------------------------------------------------- */
-
-/** The state of the transitive closure.
- *
- * @todo: we could manage the state for each relation separately. Invalidating
- * the entity relations does not mean invalidating the class relation. */
-typedef enum {
- inh_transitive_closure_none, /**< Closure is not computed, can not be accessed. */
- inh_transitive_closure_valid, /**< Closure computed and valid. */
- inh_transitive_closure_invalid, /**< Closure invalid, but can be accessed. */
- inh_transitive_closure_max /**< Invalid value. */
-} inh_transitive_closure_state;
-
-void set_irp_inh_transitive_closure_state(inh_transitive_closure_state s);
-void invalidate_irp_inh_transitive_closure_state(void);
-inh_transitive_closure_state get_irp_inh_transitive_closure_state(void);
-
-
-/** Compute transitive closure of the subclass/superclass and
- * overwrites/overwrittenby relation.
- *
- * This function walks over the ir (O(#types+#entities)) to compute the
- * transitive closure. */
-void compute_inh_transitive_closure(void);
-
-/** Free memory occupied by the transitive closure information. */
-void free_inh_transitive_closure(void);
-
-
-/* - subtype ------------------------------------------------------------- */
-
-/** Iterate over all transitive subtypes. */
-ir_type *get_class_trans_subtype_first(ir_type *tp);
-ir_type *get_class_trans_subtype_next (ir_type *tp);
-int is_class_trans_subtype (ir_type *tp, ir_type *subtp);
-
-/* - supertype ----------------------------------------------------------- */
-
-/** Iterate over all transitive supertypes. */
-ir_type *get_class_trans_supertype_first(ir_type *tp);
-ir_type *get_class_trans_supertype_next (ir_type *tp);
-
-/* - overwrittenby ------------------------------------------------------- */
-
-/** Iterate over all entities that transitive overwrite this entities. */
-ir_entity *get_entity_trans_overwrittenby_first(ir_entity *ent);
-ir_entity *get_entity_trans_overwrittenby_next (ir_entity *ent);
-
-/* - overwrites ---------------------------------------------------------- */
-
-/** Iterate over all transitive overwritten entities. */
-ir_entity *get_entity_trans_overwrites_first(ir_entity *ent);
-ir_entity *get_entity_trans_overwrites_next (ir_entity *ent);
-
-
-/* ----------------------------------------------------------------------- */
-/** The state of Cast operations that cast class types or pointers to class
- * types.
- *
- * The state expresses, how far Cast operations conform with the class
- * hierarchy.
- *
- * class A {}
- * class B1 extends A {}
- * class B2 extends A {}
- * class C extends B1 {}
- * normalized: Cast operations conform with the inheritance relation.
- * I.e., the type of the operand of a Cast is either a super= or a sub-
- * type of the type casted to. Example: (A)((B2) (new C())).
- * transitive: Cast operations conform with the transitive inheritance
- * relation. Example: (A)(new C()).
- * any: Cast operations do not conform with the transitive inheritance
- * relation. Example: (B2)(new B1())
- *
- * @see: tropt.h
- */
-/* ----------------------------------------------------------------------- */
-
-/** Flags for class cast state.
- *
- * The state in irp is always smaller or equal to the state of any
- * irg.
- *
- * We rely on the ordering of the enum. */
-typedef enum {
- ir_class_casts_any = 0, /**< There are class casts that do not cast in conformance with
- the class hierarchy. @@@ So far this does not happen in Firm. */
- ir_class_casts_transitive = 1, /**< Class casts conform to transitive inheritance edges. Default. */
- ir_class_casts_normalized = 2, /**< Class casts conform to inheritance edges. */
- ir_class_casts_state_max
-} ir_class_cast_state;
-char *get_class_cast_state_string(ir_class_cast_state s);
-
-void set_irg_class_cast_state(ir_graph *irg, ir_class_cast_state s);
-ir_class_cast_state get_irg_class_cast_state(ir_graph *irg);
-void set_irp_class_cast_state(ir_class_cast_state s);
-ir_class_cast_state get_irp_class_cast_state(void);
-
-/** Verify the class cast state of an irg.
- *
- * Asserts if state is to high, outputs warning if state is to low
- * and firm verbosity is set.
- */
-void verify_irg_class_cast_state(ir_graph *irg);
-#endif /* FIRM_TR_INHERITANCE_H */
#include "config.h"
#endif
-#include "trvrfy.h"
#include "irgraph_t.h" /* for checking whether constant code is allocated
on proper obstack */
#include "irflag_t.h"
#include "irprintf.h"
#include "irgwalk.h"
-#include "typewalk.h"
static const char *firm_vrfy_failure_msg;
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file trvrfy.h
- * @brief Check types and entities for correctness.
- * @date 29.1.2003
- * @author Michael Beck, Goetz Lindenmaier
- * @version $Id$
- */
-#ifndef FIRM_TR_TRVRFY_H
-#define FIRM_TR_TRVRFY_H
-
-#include "firm_types.h"
-
-/**
- * possible trvrfy() error codes
- */
-enum trvrfy_error_codes {
- no_error = 0, /**< no error */
- error_ent_not_cont, /**< overwritten entity not in superclass */
- error_null_mem, /**< compound contains NULL member */
- error_const_on_wrong_irg, /**< constant placed on wrong IRG */
- error_existent_entity_without_irg, /**< Method entities with pecularity_exist must have an irg */
- error_wrong_ent_overwrites, /**< number of entity overwrites exceeds number of class overwrites */
- error_inherited_ent_without_const, /**< inherited method entity not pointing to existent entity */
- error_glob_ent_allocation, /**< wrong allocation of a global entity */
- error_ent_const_mode, /**< Mode of constant in entity did not match entities type. */
- error_ent_wrong_owner /**< Mode of constant in entity did not match entities type. */
-};
-
-/**
- * Checks a type.
- *
- * @return
- * 0 if no error encountered
- */
-int check_type(ir_type *tp);
-
-/**
- * Check an entity. Currently, we check only if initialized constants
- * are build on the const irg graph.
- *
- * @return
- * 0 if no error encountered
- * != 0 a trvrfy_error_codes code
- */
-int check_entity(ir_entity *ent);
-
-/**
- * Walks the type information and performs a set of sanity checks.
- *
- * Currently, the following checks are executed:
- * - values of initialized entities must be allocated on the constant IRG
- * - class types: doesn't have NULL members
- * - class types: all overwrites are existent in the super type
- *
- * @return
- * 0 if graph is correct
- * else error code.
- */
-int tr_vrfy(void);
-
-/**
- * If NDEBUG is defined performs nothing, else calls the tr_vrfy() function.
- */
-#ifdef NDEBUG
-#define TR_VRFY() 0
-#else
-#define TR_VRFY() tr_vrfy()
-#endif
-
-#endif /* FIRM_TR_TRVRFY_H */
#include "irprog_t.h"
#include "ircons.h"
#include "tpop_t.h"
-#include "typegmod.h"
-#include "mangle.h"
#include "tv_t.h"
#include "irhooks.h"
#include "irtools.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file type.h
- * @brief Representation of types.
- * @author Goetz Lindenmaier, Michael Beck
- * @version $Id$
- * @summary
- *
- * Datastructure to hold type information.
- *
- * This module supplies a datastructure to represent all types
- * known in the compiled program. This includes types specified
- * in the program as well as types defined by the language. In the
- * view of the intermediate representation there is no difference
- * between these types. Finally it specifies some auxiliary types.
- *
- * There exist several kinds of types, arranged by the structure of
- * the type. A type is described by a set of attributes. Some of
- * these attributes are common to all types, others depend on the
- * kind of the type.
- *
- * Types are different from the modes defined in irmode: Types are
- * on the level of the programming language, modes at the level of
- * the target processor.
- *
- * @see tpop.h
- */
-#ifndef FIRM_TR_TYPE_H
-#define FIRM_TR_TYPE_H
-
-#include "firm_types.h"
-#include "tpop.h"
-#include "firm_common.h"
-#include "dbginfo.h"
-
-/**
- * An abstract data type to represent types.
- *
- * This is the abstract data type with which any type known in the
- * compiled program can be represented. This includes types specified
- * in the program as well as types defined by the language. In the
- * view of the intermediate representation there is no difference
- * between these types.
- *
- * There exist several kinds of types, arranged by the structure of
- * the type. These are distinguished by a type opcode.
- * A type is described by a set of attributes. Some of these attributes
- * are common to all types, others depend on the kind of the type.
- *
- * The following describes the common attributes. They can only be
- * accessed by the functions given below.
- *
- * The common fields are:
- *
- * - firm_kind: A firm_kind tag containing k_type. This is useful
- * for dynamically checking whether a node is a type node.
- * - type_op: A tp_op specifying the kind of the type.
- * - name: An identifier specifying the name of the type. To be
- * set by the frontend.
- * - visibility: The visibility of this type.
- * - size: The size of the type, i.e. an entity of this type will
- * occupy size bits in memory. In several cases this is
- * determined when fixing the layout of this type (class,
- * struct, union, array, enumeration).
- * - alignment The alignment of the type, i.e. an entity of this type will
- * be allocated an an address in memory with this alignment.
- * In several cases this is determined when fixing the layout
- * of this type (class, struct, union, array)
- * - mode: The mode to be used to represent the type on a machine.
- * - state: The state of the type. The state represents whether the
- * layout of the type is undefined or fixed (values: layout_undefined
- * or layout_fixed). Compound types can have an undefined
- * layout. The layout of the basic types primitive and pointer
- * is always layout_fixed. If the layout of
- * compound types is fixed all entities must have an offset
- * and the size of the type must be set.
- * A fixed layout for enumeration types means that each enumeration
- * is associated with an implementation value.
- * - assoc_type: The associated lowered/upper type.
- * - visit: A counter for walks of the type information.
- * - link: A void* to associate some additional information with the type.
- *
- * These fields can only be accessed via access functions.
- *
- * Depending on the value of @c type_op, i.e., depending on the kind of the
- * type the adt contains further attributes. These are documented below.
- *
- * @see
- *
- * @link class_type class @endlink, @link struct_type struct @endlink,
- * @link method_type method @endlink, @link union_type union @endlink,
- * @link array_type array @endlink, @link enumeration_type enumeration @endlink,
- * @link pointer_type pointer @endlink, @link primitive_type primitive @endlink
- *
- * @todo
- * mode maybe not global field??
- */
-#ifndef _IR_TYPE_TYPEDEF_
-#define _IR_TYPE_TYPEDEF_
-typedef struct ir_type ir_type;
-#endif
-
-# include "type_or_entity.h"
-
-/** Frees all entities associated with a type.
- * Does not free the array entity.
- * Warning: ensure these entities are not referenced anywhere else.
- */
-void free_type_entities(ir_type *tp);
-
-/** Frees the memory used by the type.
- *
- * Removes the type from the type list. Does not free the entities
- * belonging to the type, except for the array element entity. Does
- * not free if tp is "none" or "unknown". Frees entities in value
- * param subtypes of method types!!! Make sure these are not
- * referenced any more. Further make sure there is no pointer type
- * that refers to this type. */
-void free_type(ir_type *tp);
-
-const tp_op*get_type_tpop(const ir_type *tp);
-ident* get_type_tpop_nameid(const ir_type *tp);
-const char* get_type_tpop_name(const ir_type *tp);
-tp_opcode get_type_tpop_code(const ir_type *tp);
-
-ident* get_type_ident(const ir_type *tp);
-void set_type_ident(ir_type *tp, ident* id);
-const char* get_type_name(const ir_type *tp);
-
-/** This enumeration flags the visibility of entities and types.
- *
- * This is necessary for partial compilation.
- * We rely on the ordering of the flags.
- */
-typedef enum {
- visibility_local, /**< The entity is only visible locally. This is the default for
- entities.
- The type is only visible locally. All instances are allocated
- locally, and no pointer to entities of this type are passed
- out of this compilation unit. */
- visibility_external_visible, /**< The entity is visible to other external program parts, but
- it is defined here. It may not be optimized away. The entity must
- be static_allocated.
- For types: entities of this type can be accessed externally. No
- instances of this type are allocated externally. */
- visibility_external_allocated /**< The entity is defined and allocated externally. This compilation
- must not allocate memory for this entity. The entity must
- be static_allocated. This can also be an external defined
- method.
- For types: entities of this type are allocated and accessed from
- external code. Default for types. */
-} ir_visibility;
-
-/** The visibility of a type.
- *
- * The visibility of a type indicates, whether entities of this type
- * are accessed or allocated in external code.
- *
- * An entity of a type is allocated in external code, if the external
- * code declares a variable of this type, or dynamically allocates
- * an entity of this type. If the external code declares a (compound)
- * type, that contains entities of this type, the visibility also
- * must be external_allocated.
- *
- * The visibility must be higher than that of all entities, if the
- * type is a compound. Here it is questionable, what happens with
- * static entities. If these are accessed external by direct reference,
- * (a static call to a method, that is also in the dispatch table)
- * it should not affect the visibility of the type.
- *
- *
- * @@@ Do we need a visibility for types?
- * I change the layout of types radically when doing type splitting.
- * I need to know, which fields of classes are accessed in the RTS,
- * e.g., [_length. I may not move [_length to the split part.
- * The layout though, is a property of the type.
- *
- * One could also think of changing the mode of a type ...
- *
- * But, we could also output macros to access the fields, e.g.,
- * ACCESS_[_length (X) X->length // conventional
- * ACCESS_[_length (X) X->_split_ref->length // with type splitting
- *
- * For now I implement this function, that returns the visibility
- * based on the visibility of the entities of a compound ...
- *
- * This function returns visibility_external_visible if one or more
- * entities of a compound type have visibility_external_visible.
- * Entities of types are never visibility_external_allocated (right?).
- * Else returns visibility_local.
- */
-ir_visibility get_type_visibility(const ir_type *tp);
-void set_type_visibility(ir_type *tp, ir_visibility v);
-
-
-
-/** The state of the type layout. */
-typedef enum {
- layout_undefined, /**< The layout of this type is not defined.
- Address computation to access fields is not
- possible, fields must be accessed by Sel
- nodes. Enumeration constants might be undefined.
- This is the default value except for
- pointer, primitive and method types. */
- layout_fixed /**< The layout is fixed, all component/member entities
- have an offset assigned. Size of the type is known.
- Arrays can be accessed by explicit address
- computation. Enumeration constants must be defined.
- Default for pointer, primitive and method types. */
-} type_state;
-
-/** Returns a human readable string for the enum entry. */
-const char *get_type_state_name(type_state s);
-
-/** Returns the type layout state of a type. */
-type_state get_type_state(const ir_type *tp);
-
-/** Sets the type layout state of a type.
- *
- * For primitives, pointer and method types the layout is always fixed.
- * This call is legal but has no effect.
- */
-void set_type_state(ir_type *tp, type_state state);
-
-/** Returns the mode of a type.
- *
- * Returns NULL for all non atomic types.
- */
-ir_mode* get_type_mode(const ir_type *tp);
-
-/** Sets the mode of a type.
- *
- * Only has an effect on primitive, enumeration and pointer types.
- */
-void set_type_mode(ir_type *tp, ir_mode* m);
-
-/** Returns the size of a type in bytes, returns -1 if the size is NOT
- * a byte size, i.e. not dividable by 8. */
-int get_type_size_bytes(const ir_type *tp);
-
-/** Returns the size of a type in bits. */
-int get_type_size_bits(const ir_type *tp);
-
-/** Sets the size of a type in bytes.
- *
- * For primitive, enumeration, pointer and method types the size
- * is always fixed. This call is legal but has no effect.
- */
-void set_type_size_bytes(ir_type *tp, int size);
-
-/** Sets the size of a type in bits.
- *
- * For primitive, enumeration, pointer and method types the size
- * is always fixed. This call is legal but has no effect.
- */
-void set_type_size_bits(ir_type *tp, int size);
-
-/** Returns the alignment of a type in bytes.
- *
- * Returns -1 if the alignment is NOT
- * a byte size, i.e. not dividable by 8. Calls get_type_alignment_bits(). */
-int get_type_alignment_bytes(ir_type *tp);
-
-/** Returns the alignment of a type in bits.
- *
- * If the alignment of a type is
- * not set, it is calculated here according to the following rules:
- * -#.) if a type has a mode, the alignment is the mode size.
- * -#.) compound types have the alignment of there biggest member.
- * -#.) array types have the alignment of there element type.
- * -#.) method types return 0 here.
- * -#.) all other types return 8 here (i.e. aligned at byte).
- */
-int get_type_alignment_bits(ir_type *tp);
-
-/** Sets the alignment of a type in bytes. */
-void set_type_alignment_bytes(ir_type *tp, int size);
-
-/** Sets the alignment of a type in bits.
- *
- * For method types the alignment is always fixed.
- * This call is legal but has no effect.
- */
-void set_type_alignment_bits(ir_type *tp, int size);
-
-/** Returns the visited count of a type. */
-unsigned long get_type_visited(const ir_type *tp);
-/** Sets the visited count of a type to num. */
-void set_type_visited(ir_type *tp, unsigned long num);
-/** Sets visited field in type to type_visited. */
-void mark_type_visited(ir_type *tp);
-/** Returns non-zero if the type is already visited */
-int type_visited(const ir_type *tp);
-/** Returns non-zero if the type is not yet visited */
-int type_not_visited(const ir_type *tp);
-
-/** Returns the associated link field of a type. */
-void* get_type_link(const ir_type *tp);
-/** Sets the associated link field of a type. */
-void set_type_link(ir_type *tp, void *l);
-
-/**
- * Visited flag to traverse the type information.
- *
- * Increase this flag by one before traversing the type information
- * using inc_master_type_visited().
- * Mark type nodes as visited by mark_type_visited(ir_type).
- * Check whether node was already visited by type_visited(ir_type)
- * and type_not_visited(ir_type).
- * Or use the function to walk all types.
- *
- * @see typewalk
- */
-void set_master_type_visited(unsigned long val);
-unsigned long get_master_type_visited(void);
-void inc_master_type_visited(void);
-
-/**
- * Checks whether a pointer points to a type.
- *
- * @param thing an arbitrary pointer
- *
- * @return
- * true if the thing is a type, else false
- */
-int is_type(const void *thing);
-
-/**
- * Checks whether two types are structurally equal.
- *
- * @param typ1 the first type
- * @param typ2 the second type
- *
- * @return
- * true if the types are equal, else false.
- *
- * Types are equal if :
- * - they are the same type kind
- * - they have the same name
- * - they have the same mode (if applicable)
- * - they have the same type_state and, ev., the same size
- * - they are class types and have:
- * - the same members (see same_entity in entity.h)
- * - the same supertypes -- the C-pointers are compared --> no recursive call.
- * - the same number of subtypes. Subtypes are not compared,
- * as this could cause a cyclic test.
- * - the same peculiarity
- * - they are structure types and have the same members
- * - they are method types and have
- * - the same parameter types
- * - the same result types
- * - they are union types and have the same members
- * - they are array types and have
- * - the same number of dimensions
- * - the same dimension bounds
- * - the same dimension order
- * - the same element type
- * - they are enumeration types and have the same enumerator names
- * - they are pointer types and have the identical points_to type
- * (i.e., the same C-struct to represent the type, type_id is skipped.
- * This is to avoid endless recursions; with pointer types cyclic
- * type graphs are possible.)
- */
-int equal_type(ir_type *typ1, ir_type *typ2);
-
-/**
- * Checks whether two types are structural comparable.
- *
- * @param st pointer type
- * @param lt pointer type
- *
- * @return
- * true if type st is smaller than type lt, i.e. whenever
- * lt is expected a st can be used.
- * This is true if
- * - they are the same type kind
- * - mode(st) < mode (lt) (if applicable)
- * - they are class types and st is (transitive) subtype of lt,
- * - they are structure types and
- * - the members of st have exactly one counterpart in lt with the same name,
- * - the counterpart has a bigger type.
- * - they are method types and have
- * - the same number of parameter and result types,
- * - the parameter types of st are smaller than those of lt,
- * - the result types of st are smaller than those of lt
- * - they are union types and have the members of st have exactly one
- * @return counterpart in lt and the type is smaller
- * - they are array types and have
- * - the same number of dimensions
- * - all bounds of lt are bound of st
- * - the same dimension order
- * - the same element type
- * @return or
- * - the element type of st is smaller than that of lt
- * - the element types have the same size and fixed layout.
- * - they are enumeration types and have the same enumerator names
- * - they are pointer types and have the points_to type of st is
- * @return smaller than the points_to type of lt.
- *
- */
-int smaller_type(ir_type *st, ir_type *lt);
-
-/**
- * @page class_type Representation of a class type
- *
- * If the type opcode is set to type_class the type represents class
- * types. A list of fields and methods is associated with a class.
- * Further a class can inherit from and bequest to other classes.
- *
- * The following attributes are private to this type kind:
- * - member: All entities belonging to this class. This are method entities
- * which have type_method or fields that can have any of the
- * following type kinds: type_class, type_struct, type_union,
- * type_array, type_enumeration, type_pointer, type_primitive.
- *
- * The following two are dynamic lists that can be grown with an "add_" function,
- * but not shrinked:
- *
- * - subtypes: A list of direct subclasses.
- *
- * - supertypes: A list of direct superclasses.
- *
- * - peculiarity: The peculiarity of this class. If the class is of peculiarity
- * "description" it only is a description of requirements to a class,
- * as, e.g., a Java interface. The class will never be allocated.
- * Peculiarity inherited is only possible for entities. An entity
- * is of peculiarity inherited if the compiler generated the entity
- * to explicitly resolve inheritance. An inherited method entity has
- * no value for irg.
- * Values: description, existent, inherited. Default: existent.
- *
- * - type_info: An entity representing the type information of this class.
- * This entity can be of arbitrari type, Firm did not use it yet.
- * It allows to express the coupling of a type with an entity
- * representing this type. This information is useful for lowering
- * of InstOf and TypeChk nodes. Default: NULL
- *
- * - vtable_size: The size of this class virtual function table.
- * Default: 0
- *
- * - final: A final class is always a leaf in the class hierarchy. Final
- * classes cannot be super classes of other ones. As this information
- * can only be computed in whole world compilations, we allow to
- * set this flag. It is used in optimizations if get_opt_closed_world()
- * is false. Default: false
- *
- * - interface: The class represents an interface. This flag can be set to distinguish
- * between interfaces, abstract classes and other classes that all may
- * have the peculiarity peculiarity_description. Depending on this flag
- * the lowering might do different actions. Default: false
- *
- * - abstract : The class represents an abstract class. This flag can be set to distinguish
- * between interfaces, abstract classes and other classes that all may
- * have the peculiarity peculiarity_description. Depending on this flag
- * the lowering might do different actions. Default: false
- */
-
-/** Creates a new class type. */
-ir_type *new_type_class (ident *name);
-
-/** Creates a new class type with debug information. */
-ir_type *new_d_type_class (ident *name, dbg_info *db);
-
-/* --- manipulate private fields of class type --- */
-
-/** Adds the entity as member of the class. */
-void add_class_member (ir_type *clss, ir_entity *member);
-
-/** Returns the number of members of this class. */
-int get_class_n_members (const ir_type *clss);
-
-/** Returns the member at position pos, 0 <= pos < n_member */
-ir_entity *get_class_member (const ir_type *clss, int pos);
-
-/** Returns index of mem in clss, -1 if not contained. */
-int get_class_member_index(const ir_type *clss, ir_entity *mem);
-
-/** Finds the member with name 'name'. If several members with the same
- * name returns one of them. Returns NULL if no member found. */
-ir_entity *get_class_member_by_name(ir_type *clss, ident *name);
-
-/** Overwrites the member at position pos, 0 <= pos < n_member with
- * the passed entity. */
-void set_class_member (ir_type *clss, ir_entity *member, int pos);
-
-/** Replaces complete member list in class type by the list passed.
- *
- * Copies the list passed. This function is necessary to reduce the number of members.
- * members is an array of entities, num the size of this array. Sets all
- * owners of the members passed to clss. */
-void set_class_members (ir_type *clss, ir_entity *members[], int arity);
-
-/** Finds member in the list of members and removes it.
- *
- * Shrinks the member list, so iterate from the end!!!
- * Does not deallocate the entity. */
-void remove_class_member(ir_type *clss, ir_entity *member);
-
-
-/** Adds subtype as subtype to clss.
- *
- * Checks whether clss is a supertype of subtype. If not
- * adds also clss as supertype to subtype. */
-void add_class_subtype (ir_type *clss, ir_type *subtype);
-
-/** Returns the number of subtypes */
-int get_class_n_subtypes (const ir_type *clss);
-
-/** Gets the subtype at position pos, 0 <= pos < n_subtype. */
-ir_type *get_class_subtype (ir_type *clss, int pos);
-
-/** Returns the index to access subclass as subtype of class.
- *
- * If subclass is no direct subtype of class returns -1.
- */
-int get_class_subtype_index(ir_type *clss, const ir_type *subclass);
-
-/** Sets the subtype at position pos, 0 <= pos < n_subtype.
- *
- * Does not set the corresponding supertype relation for subtype: this might
- * be a different position! */
-void set_class_subtype (ir_type *clss, ir_type *subtype, int pos);
-
-/** Finds subtype in the list of subtypes and removes it */
-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)
-#define get_class_derived_type_index(clss, drvtype) get_class_subtype_index(clss, drvtype)
-#define set_class_derived_type(clss, drvtype, pos) set_class_subtype(clss, drvtype, pos)
-#define remove_class_derived_type(clss, drvtype) remove_class_subtype(clss, drvtype)
-
-/** Adds supertype as supertype to class.
- *
- * Checks whether clss is a subtype of supertype. If not
- * adds also clss as subtype to supertype. */
-void add_class_supertype (ir_type *clss, ir_type *supertype);
-
-/** Returns the number of supertypes */
-int get_class_n_supertypes (const ir_type *clss);
-
-/** Returns the index to access superclass as supertype of class.
- *
- * If superclass is no direct supertype of class returns -1.
- */
-int get_class_supertype_index(ir_type *clss, ir_type *super_clss);
-
-/** Gets the supertype at position pos, 0 <= pos < n_supertype. */
-ir_type *get_class_supertype (ir_type *clss, int pos);
-
-/** Sets the supertype at position pos, 0 <= pos < n_supertype.
- *
- * Does not set the corresponding subtype relation for supertype: this might
- * be at a different position! */
-void set_class_supertype (ir_type *clss, ir_type *supertype, int pos);
-
-/** Finds supertype in the list of supertypes and removes it */
-void remove_class_supertype(ir_type *clss, ir_type *supertype);
-
-/** Convenience macro */
-#define add_class_base_type(clss, basetype) add_class_supertype(clss, basetype)
-#define get_class_n_base_types(clss) get_class_n_supertypes(clss)
-#define get_class_base_type_index(clss, base_clss) get_class_supertype_index(clss, base_clss)
-#define get_class_base_type(clss, pos) get_class_supertype(clss, pos)
-#define set_class_base_type(clss, basetype, pos) set_class_supertype(clss, basetype, pos)
-#define remove_class_base_type(clss, basetype) remove_class_supertype(clss, basetype)
-
-/** Convenience macro */
-#define add_class_base_type(clss, basetype) add_class_supertype(clss, basetype)
-#define get_class_n_base_types(clss) get_class_n_supertypes(clss)
-#define get_class_base_type_index(clss, base_clss) get_class_supertype_index(clss, base_clss)
-#define get_class_base_type(clss, pos) get_class_supertype(clss, pos)
-#define set_class_base_type(clss, basetype, pos) set_class_supertype(clss, basetype, pos)
-#define remove_class_base_type(clss, basetype) remove_class_supertype(clss, basetype)
-
-/** This enumeration flags the peculiarity of entities and types. */
-typedef enum {
- peculiarity_description, /**< Represents only a description. The entity/type is never
- allocated, no code/data exists for this entity/type.
- @@@ eventually rename to descriptive (adjective as the others!)*/
- peculiarity_inherited, /**< Describes explicitly that other entities are
- inherited to the owner of this entity.
- Overwrites must refer to at least one other
- entity. If this is a method entity there exists
- no irg for this entity, only for one of the
- overwritten ones.
- Only for entity. */
- peculiarity_existent /**< The entity/type (can) exist.
- @@@ eventually rename to 'real' i.e., 'echt'
- This serves better as opposition to description _and_ inherited.*/
-} ir_peculiarity;
-
-/** Returns a human readable string for a peculiarity. */
-const char *get_peculiarity_name(ir_peculiarity p);
-
-/** Returns the peculiarity of the class. */
-ir_peculiarity get_class_peculiarity (const ir_type *clss);
-/** Sets the peculiarity of the class. */
-void set_class_peculiarity (ir_type *clss, ir_peculiarity pec);
-
-/** Returns the type info entity of a class. */
-ir_entity *get_class_type_info(const ir_type *clss);
-
-/** Set a type info entity for the class. */
-void set_class_type_info(ir_type *clss, ir_entity *ent);
-
-/** Returns the size of the virtual function table. */
-unsigned get_class_vtable_size(const ir_type *clss);
-
-/** Sets a new size of the virtual function table. */
-void set_class_vtable_size(ir_type *clss, unsigned size);
-
-/** Returns non-zero if a class is final. */
-int is_class_final(const ir_type *clss);
-
-/** Sets the class final flag. */
-void set_class_final(ir_type *clss, int flag);
-
-/** Return non-zero if a class is an interface */
-int is_class_interface(const ir_type *clss);
-
-/** Sets the class interface flag. */
-void set_class_interface(ir_type *clss, int flag);
-
-/** Return non-zero if a class is an abstract class. */
-int is_class_abstract(const ir_type *clss);
-
-/** Sets the class abstract flag. */
-void set_class_abstract(ir_type *clss, int flag);
-
-/** Set and get a class' dfn --
- @todo This is an undocumented field, subject to change! */
-void set_class_dfn (ir_type *clss, int dfn);
-int get_class_dfn (const ir_type *clss);
-
-/** Returns true if a type is a class type. */
-int is_Class_type(const ir_type *clss);
-
-/**
- * @page struct_type Representation of a struct type
- *
- * A struct type represents aggregate types that consist of a list
- * of fields.
- *
- * The following attributes are private to this type kind:
- * - member: All entities belonging to this class. This are the fields
- * that can have any of the following types: type_class,
- * type_struct, type_union, type_array, type_enumeration,
- * type_pointer, type_primitive.
- * This is a dynamic list that can be grown with an "add_" function,
- * but not shrinked.
- * This is a dynamic list that can be grown with an "add_" function,
- * but not shrinked.
- */
-/** Creates a new type struct */
-ir_type *new_type_struct (ident *name);
-/** Creates a new type struct with debug information. */
-ir_type *new_d_type_struct (ident *name, dbg_info* db);
-
-/* --- manipulate private fields of struct --- */
-
-/** Adds the entity as member of the struct. */
-void add_struct_member (ir_type *strct, ir_entity *member);
-
-/** Returns the number of members of this struct. */
-int get_struct_n_members (const ir_type *strct);
-
-/** Returns the member at position pos, 0 <= pos < n_member */
-ir_entity *get_struct_member (const ir_type *strct, int pos);
-
-/** Returns index of member in strct, -1 if not contained. */
-int get_struct_member_index(const ir_type *strct, ir_entity *member);
-
-/** Overwrites the member at position pos, 0 <= pos < n_member with
- the passed entity. */
-void set_struct_member (ir_type *strct, int pos, ir_entity *member);
-
-/** Finds member in the list of members and removes it. */
-void remove_struct_member (ir_type *strct, ir_entity *member);
-
-/** Returns true if a type is a struct type. */
-int is_Struct_type(const ir_type *strct);
-
-/**
- * @page method_type Representation of a method type
- *
- * A method type represents a method, function or procedure type.
- * It contains a list of the parameter and result types, as these
- * are part of the type description. These lists should not
- * be changed by a optimization, as a change creates a new method
- * type. Therefore optimizations should allocated new method types.
- * The set_ routines are only for construction by a frontend.
- *
- * - n_params: Number of parameters to the procedure.
- * A procedure in FIRM has only call by value parameters.
- *
- * - param_type: A list with the types of parameters. This list is ordered.
- * The nth type in this list corresponds to the nth element
- * in the parameter tuple that is a result of the start node.
- * (See ircons.h for more information.)
- *
- * - value_param_ents
- * A list of entities (whose owner is a struct private to the
- * method type) that represent parameters passed by value.
- *
- * - n_res: The number of results of the method. In general, procedures
- * have zero results, functions one.
- *
- * - res_type: A list with the types of parameters. This list is ordered.
- * The nth type in this list corresponds to the nth input to
- * Return nodes. (See ircons.h for more information.)
- *
- * - value_res_ents
- * A list of entities (whose owner is a struct private to the
- * method type) that represent results passed by value.
- */
-
-/* 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 name the name (ident) of this type
- * @param n_param the number of parameters
- * @param n_res the number of results
- *
- * The arrays for the parameter and result types are not initialized by
- * the constructor.
- */
-ir_type *new_type_method (ident *name, int n_param, int n_res);
-
-/** Create a new method type with debug information.
- *
- * @param name the name (ident) of this type
- * @param n_param the number of parameters
- * @param n_res the number of results
- * @param db user defined debug information
- *
- * The arrays for the parameter and result types are not initialized by
- * the constructor.
- */
-ir_type *new_d_type_method (ident *name, int n_param, int n_res, dbg_info* db);
-
-/* -- manipulate private fields of method. -- */
-
-/** Returns the number of parameters of this method. */
-int get_method_n_params (const ir_type *method);
-
-/** Returns the type of the parameter at position pos of a method. */
-ir_type *get_method_param_type(ir_type *method, int pos);
-/** Sets the type of the parameter at position pos of a method.
- Also changes the type in the pass-by-value representation by just
- changing the type of the corresponding entity if the representation is constructed. */
-void set_method_param_type(ir_type *method, int pos, ir_type *tp);
-/** Returns an entity that represents the copied value argument. Only necessary
- for compounds passed by value. This information is constructed only on demand. */
-ir_entity *get_method_value_param_ent(ir_type *method, int pos);
-/**
- * Returns a type that represents the copied value arguments if one
- * was allocated, else NULL.
- */
-ir_type *get_method_value_param_type(const ir_type *method);
-/** Returns an ident representing the parameters name. Returns NULL if not set.
- For debug support only. */
-ident *get_method_param_ident(ir_type *method, int pos);
-/** Returns a string representing the parameters name. Returns NULL if not set.
- For debug support only. */
-const char *get_method_param_name(ir_type *method, int pos);
-/** Sets an ident representing the parameters name. For debug support only. */
-void set_method_param_ident(ir_type *method, int pos, ident *id);
-
-/** Returns the number of results of a method type. */
-int get_method_n_ress (const ir_type *method);
-/** Returns the return type of a method type at position pos. */
-ir_type *get_method_res_type(ir_type *method, int pos);
-/** Sets the type of the result at position pos of a method.
- Also changes the type in the pass-by-value representation by just
- changing the type of the corresponding entity if the representation is constructed. */
-void set_method_res_type(ir_type *method, int pos, ir_type *tp);
-/** Returns an entity that represents the copied value result. Only necessary
- for compounds passed by value. This information is constructed only on demand. */
-ir_entity *get_method_value_res_ent(ir_type *method, int pos);
-
-/**
- * Returns a type that represents the copied value results.
- */
-ir_type *get_method_value_res_type(const ir_type *method);
-
-/**
- * This enum flags the variadicity of methods (methods with a
- * variable amount of arguments (e.g. C's printf). Default is
- * non_variadic.
- */
-typedef enum variadicity {
- variadicity_non_variadic, /**< non variadic */
- variadicity_variadic /**< variadic */
-} variadicity;
-
-/** Returns the null-terminated name of this variadicity. */
-const char *get_variadicity_name(variadicity vari);
-
-/** Returns the variadicity of a method. */
-variadicity get_method_variadicity(const ir_type *method);
-
-/** Sets the variadicity of a method. */
-void set_method_variadicity(ir_type *method, variadicity vari);
-
-/**
- * Returns the first variadic parameter index of a type.
- * If this index was NOT set, the index of the last parameter
- * of the method type plus one is returned for variadic functions.
- * Non-variadic function types always return -1 here.
- */
-int get_method_first_variadic_param_index(const ir_type *method);
-
-/**
- * Sets the first variadic parameter index. This allows to specify
- * a complete call type (containing the type of all parameters)
- * but still have the knowledge, which parameter must be passed as
- * variadic one.
- */
-void set_method_first_variadic_param_index(ir_type *method, int index);
-
-/**
- * Additional method type properties:
- * Tell about special properties of a method type. Some
- * of these may be discovered by analyses.
- */
-typedef enum {
- mtp_no_property = 0x00000000, /**< no additional properties, default */
- mtp_property_const = 0x00000001, /**< This method did not access memory and calculates
- its return values solely from its parameters.
- GCC: __attribute__((const)). */
- mtp_property_pure = 0x00000002, /**< This method did NOT write to memory and calculates
- its return values solely from its parameters and
- the memory they points to (or global vars).
- GCC: __attribute__((pure)). */
- mtp_property_noreturn = 0x00000004, /**< This method did not return due to an aborting system
- call.
- GCC: __attribute__((noreturn)). */
- mtp_property_nothrow = 0x00000008, /**< This method cannot throw an exception.
- GCC: __attribute__((nothrow)). */
- mtp_property_naked = 0x00000010, /**< This method is naked.
- GCC: __attribute__((naked)). */
- mtp_property_malloc = 0x00000020, /**< This method returns newly allocate memory.
- GCC: __attribute__((malloc)). */
- mtp_property_intrinsic = 0x00000040, /**< This method is intrinsic. It is expected that
- a lowering phase will remove all calls to it. */
- mtp_property_runtime = 0x00000080, /**< This method represents a runtime routine. */
- mtp_property_inherited = (1<<31) /**< Internal. Used only in irg's, means property is
- inherited from type. */
-} mtp_additional_property;
-
-/** Returns the mask of the additional graph properties. */
-unsigned get_method_additional_properties(const ir_type *method);
-
-/** Sets the mask of the additional graph properties. */
-void set_method_additional_properties(ir_type *method, unsigned property_mask);
-
-/** Sets one additional graph property. */
-void set_method_additional_property(ir_type *method, mtp_additional_property flag);
-
-/**
- * Calling conventions: lower 24 bits are the number of register parameters,
- * upper 8 encode the calling conventions.
- */
-typedef enum {
- cc_reg_param = 0x01000000, /**< Transmit parameters in registers, else the stack is used.
- This flag may be set as default on some architectures. */
- cc_last_on_top = 0x02000000, /**< The last non-register parameter is transmitted on top of
- the stack. This is equivalent to the pascal
- calling convention. If this flag is not set, the first
- non-register parameter is used (stdcall or cdecl
- calling convention) */
- cc_callee_clear_stk = 0x04000000, /**< The callee clears the stack. This forbids variadic
- function calls (stdcall). */
- cc_this_call = 0x08000000, /**< The first parameter is a this pointer and is transmitted
- in a special way. */
-
- 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 */
-#define cc_stdcall_set cc_callee_clear_stk
-/** fastcall calling convention */
-#define cc_fastcall_set (cc_reg_param|cc_callee_clear_stk)
-
-/** Returns the default calling convention for method types. */
-unsigned get_default_cc_mask(void);
-
-/**
- * check for the CDECL calling convention
- */
-#define IS_CDECL(cc_mask) (((cc_mask) & cc_bits) == cc_cdecl_set)
-
-/**
- * check for the STDCALL calling convention
- */
-#define IS_STDCALL(cc_mask) (((cc_mask) & cc_bits) == cc_stdcall_set)
-
-/**
- * check for the FASTCALL calling convention
- */
-#define IS_FASTCALL(cc_mask) (((cc_mask) & cc_bits) == cc_fastcall_set)
-
-/**
- * Sets the CDECL convention bits.
- */
-#define SET_CDECL(cc_mask) (((cc_mask) & ~cc_bits) | cc_cdecl_set)
-
-/**
- * Set. the STDCALL convention bits.
- */
-#define SET_STDCALL(cc_mask) (((cc_mask) & ~cc_bits) | cc_stdcall_set)
-
-/**
- * Sets the FASTCALL convention bits.
- */
-#define SET_FASTCALL(cc_mask) (((cc_mask) & ~cc_bits) | cc_fastcall_set)
-
-/** Returns the calling convention of an entities graph. */
-unsigned get_method_calling_convention(const ir_type *method);
-
-/** Sets the calling convention of an entities graph. */
-void set_method_calling_convention(ir_type *method, unsigned cc_mask);
-
-/** Returns the number of registers parameters, 0 means default. */
-unsigned get_method_n_regparams(ir_type *method);
-
-/** Sets the number of registers parameters, 0 means default. */
-void set_method_n_regparams(ir_type *method, unsigned n_regs);
-
-/** Returns true if a type is a method type. */
-int is_Method_type (const ir_type *method);
-
-/**
- * @page union_type Representation of a union (variant) type.
- *
- * The union type represents union types. Note that this representation
- * resembles the C union type. For tagged variant types like in Pascal or Modula
- * a combination of a struct and a union type must be used.
- *
- * - n_types: Number of unioned types.
- * - members: Entities for unioned types. Fixed length array.
- * This is a dynamic list that can be grown with an "add_" function,
- * but not shrinked.
- */
-/** Creates a new type union. */
-ir_type *new_type_union (ident *name);
-
-/** Creates a new type union with debug information. */
-ir_type *new_d_type_union (ident *name, dbg_info* db);
-
-/* --- manipulate private fields of struct --- */
-
-/** Returns the number of unioned types of this union */
-int get_union_n_members (const ir_type *uni);
-
-/** Adds a new entity to a union type */
-void add_union_member (ir_type *uni, ir_entity *member);
-
-/** Returns the entity at position pos of a union */
-ir_entity *get_union_member (const ir_type *uni, int pos);
-
-/** Returns index of member in uni, -1 if not contained. */
-int get_union_member_index(const ir_type *uni, ir_entity *member);
-
-/** Overwrites a entity at position pos in a union type. */
-void set_union_member (ir_type *uni, int pos, ir_entity *member);
-
-/** Finds member in the list of members and removes it. */
-void remove_union_member (ir_type *uni, ir_entity *member);
-
-/** Returns true if a type is a union type. */
-int is_Union_type (const ir_type *uni);
-
-/**
- * @page array_type Representation of an array type
- *
- * The array type represents rectangular multi dimensional arrays.
- * The constants representing the bounds must be allocated to
- * get_const_code_irg() by setting current_ir_graph accordingly.
- *
- * - n_dimensions: Number of array dimensions.
- * - *lower_bound: Lower bounds of dimensions. Usually all 0.
- * - *upper_bound: Upper bounds or dimensions.
- * - *element_type: The type of the array elements.
- * - *element_ent: An entity for the array elements to be used for
- * element selection with Sel.
- * @todo
- * Do we need several entities? One might want
- * to select a dimension and not a single element in case of multi
- * dimensional arrays.
- */
-
-/** Create a new type array.
- *
- * Sets n_dimension to dimension and all dimension entries to NULL.
- * Initializes order to the order of the dimensions.
- * The entity for array elements is built automatically.
- * Set dimension sizes after call to constructor with set_* routines.
- */
-ir_type *new_type_array (ident *name, int n_dimensions,
- ir_type *element_type);
-
-/** Create a new type array with debug information.
- *
- * Sets n_dimension to dimension and all dimension entries to NULL.
- * Initializes order to the order of the dimensions.
- * The entity for array elements is built automatically.
- * Set dimension sizes after call to constructor with set_* routines.
- * A legal array type must have at least one dimension set.
- */
-ir_type *new_d_type_array (ident *name, int n_dimensions,
- ir_type *element_type, dbg_info* db);
-
-/* --- manipulate private fields of array type --- */
-
-/** Returns the number of array dimensions of this type. */
-int get_array_n_dimensions (const ir_type *array);
-
-/**
- * Allocates Const nodes of mode_Is for one array dimension.
- * Upper bound in Firm is the element next to the last, i.e. [lower,upper[
- */
-void set_array_bounds_int (ir_type *array, int dimension, int lower_bound,
- int upper_bound);
-/**
- * Sets the bounds for one array dimension.
- * Upper bound in Firm is the element next to the last, i.e. [lower,upper[
- */
-void set_array_bounds (ir_type *array, int dimension, ir_node *lower_bound,
- ir_node *upper_bound);
-/** Sets the lower bound for one array dimension, i.e. [lower,upper[ */
-void set_array_lower_bound (ir_type *array, int dimension, ir_node *lower_bound);
-
-/** Allocates Const nodes of mode_Is for the lower bound of an array
- dimension, i.e. [lower,upper[ */
-void set_array_lower_bound_int (ir_type *array, int dimension, int lower_bound);
-
-/** Sets the upper bound for one array dimension, i.e. [lower,upper[ */
-void set_array_upper_bound (ir_type *array, int dimension, ir_node *upper_bound);
-
-/** Allocates Const nodes of mode_Is for the upper bound of an array
- dimension, i.e. [lower,upper[. */
-void set_array_upper_bound_int (ir_type *array, int dimension, int upper_bound);
-
-/** Returns true if lower bound != Unknown. */
-int has_array_lower_bound (const ir_type *array, int dimension);
-/** Returns the lower bound of an array. */
-ir_node * get_array_lower_bound (const ir_type *array, int dimension);
-/** Works only if bound is Const node with tarval that can be converted to long. */
-long get_array_lower_bound_int (const ir_type *array, int dimension);
-/** returns true if lower bound != Unknown */
-int has_array_upper_bound (const ir_type *array, int dimension);
-/** Returns the upper bound of an array. */
-ir_node * get_array_upper_bound (const ir_type *array, int dimension);
-/** Works only if bound is Const node with tarval that can be converted to long. */
-long get_array_upper_bound_int (const ir_type *array, int dimension);
-
-/** Sets an array dimension to a specific order. */
-void set_array_order (ir_type *array, int dimension, int order);
-
-/** Returns the order of an array dimension. */
-int get_array_order (const ir_type *array, int dimension);
-
-/** Find the array dimension that is placed at order order. */
-int find_array_dimension(const ir_type *array, int order);
-
-/** Sets the array element type. */
-void set_array_element_type (ir_type *array, ir_type* tp);
-
-/** Gets the array element type. */
-ir_type *get_array_element_type (ir_type *array);
-
-/** Sets the array element entity. */
-void set_array_element_entity (ir_type *array, ir_entity *ent);
-
-/** Get the array element entity. */
-ir_entity *get_array_element_entity (const ir_type *array);
-
-/** Returns true if a type is an array type. */
-int is_Array_type(const ir_type *array);
-
-/**
- * @page enumeration_type Representation of an enumeration type
- *
- * Enumeration types need not necessarily be represented explicitly
- * by Firm types, as the frontend can lower them to integer constants as
- * well. For debugging purposes or similar tasks this information is useful.
- * The type state layout_fixed is set, if all enumeration constant have
- * there tarvals assigned. Until then
- *
- * - *const: The target values representing the constants used to
- * represent individual enumerations.
- */
-
-#ifndef _IR_ENUM_CONST_TYPEDEF_
-#define _IR_ENUM_CONST_TYPEDEF_
-typedef struct ir_enum_const ir_enum_const;
-#endif
-
-/** Create a new type enumeration -- set the enumerators independently. */
-ir_type *new_type_enumeration(ident *name, int n_enums);
-
-/** Create a new type enumeration with debug information -- set the enumerators independently. */
-ir_type *new_d_type_enumeration(ident *name, int n_enums, dbg_info *db);
-
-/* --- manipulate fields of enumeration type. --- */
-
-/** Set an enumeration constant to a enumeration type at a given position. */
-void set_enumeration_const(ir_type *enumeration, int pos, ident *nameid, tarval *con);
-
-/** Returns the number of enumeration values of this enumeration */
-int get_enumeration_n_enums(const ir_type *enumeration);
-
-/** Returns the enumeration constant at a given position. */
-ir_enum_const *get_enumeration_const(const ir_type *enumeration, int pos);
-
-/** Returns the enumeration type owner of an enumeration constant. */
-ir_type *get_enumeration_owner(const ir_enum_const *enum_cnst);
-
-/** Sets the enumeration constant value. */
-void set_enumeration_value(ir_enum_const *enum_cnst, tarval *con);
-
-/** Returns the enumeration constant value. */
-tarval *get_enumeration_value(const ir_enum_const *enum_cnst);
-
-/** Assign an ident to an enumeration constant. */
-void set_enumeration_nameid(ir_enum_const *enum_cnst, ident *id);
-
-/** Returns the assigned ident of an enumeration constant. */
-ident *get_enumeration_nameid(const ir_enum_const *enum_cnst);
-
-/** Returns the assigned name of an enumeration constant. */
-const char *get_enumeration_name(const ir_enum_const *enum_cnst);
-
-/** Returns true if a type is a enumeration type. */
-int is_Enumeration_type(const ir_type *enumeration);
-
-/**
- * @page pointer_type Representation of a pointer type
- *
- * The mode of the pointer type must be a reference mode.
- *
- * Pointer types:
- * - points_to: The type of the entity this pointer points to.
- */
-
-/** Creates a new type pointer. */
-ir_type *new_type_pointer (ident *name, ir_type *points_to, ir_mode *ptr_mode);
-
-/** Creates a new type pointer with debug information. */
-ir_type *new_d_type_pointer (ident *name, ir_type *points_to, ir_mode *ptr_mode, dbg_info* db);
-
-/* --- manipulate fields of type_pointer --- */
-
-/** Sets the type to which a pointer points to. */
-void set_pointer_points_to_type (ir_type *pointer, ir_type *tp);
-
-/** Returns the type to which a pointer points to. */
-ir_type *get_pointer_points_to_type (ir_type *pointer);
-
-/** Returns true if a type is a pointer type. */
-int is_Pointer_type (const ir_type *pointer);
-
-/** Returns the first pointer type that has as points_to tp.
- * Not efficient: O(#types).
- * If not found returns firm_unknown_type. */
-ir_type *find_pointer_type_to_type (ir_type *tp);
-
-/**
- * @page primitive_type Representation of a primitive type
- *
- * Primitive types are types that represent atomic data values that
- * map directly to modes. They don't have private attributes. The
- * important information they carry is held in the common mode field.
- */
-/** Creates a new primitive type. */
-ir_type *new_type_primitive(ident *name, ir_mode *mode);
-
-/** Creates a new primitive type with debug information. */
-ir_type *new_d_type_primitive(ident *name, ir_mode *mode, dbg_info* db);
-
-/** Returns true if a type is a primitive type. */
-int is_Primitive_type(const ir_type *primitive);
-
-
-/**
- * @page none_type The None type
- *
- * This type is an auxiliary type dedicated to support type analyses.
- *
- * The none type represents that there is no type. The type can be used to
- * initialize fields of type* that actually can not contain a type or that
- * are initialized for an analysis. There exists exactly one type none.
- * This type is not on the type list in ir_prog. It is
- * allocated when initializing the type module.
- *
- * The following values are set:
- * - mode: mode_BAD
- * - name: "type_none"
- * - state: layout_fixed
- * - size: 0
- */
-/** A variable that contains the only none type. */
-extern ir_type *firm_none_type;
-
-/** Returns the none type. */
-ir_type *get_none_type(void);
-
-/**
- * @page unknown_type The Unknown type
- *
- * This type is an auxiliary type dedicated to support type analyses.
- *
- * The unknown type represents that there could be a type, but it is not
- * known. This type can be used to initialize fields before an analysis (not known
- * yet) or to represent the top of a lattice (could not be determined). There exists
- * exactly one type unknown. This type is not on the type list in ir_prog. It is
- * allocated when initializing the type module.
- *
- * The following values are set:
- * - mode: mode_ANY
- * - name: "type_unknown"
- * - state: layout_fixed
- * - size: 0
- */
-/** A variable that contains the only unknown type. */
-extern ir_type *firm_unknown_type;
-
-/** Returns the unknown type. */
-ir_type *get_unknown_type(void);
-
-
-/**
- * Checks whether a type is atomic.
- * @param tp any type
- * @return true if type is primitive, pointer or enumeration
- */
-int is_atomic_type(const ir_type *tp);
-
-/* --- Support for compound types --- */
-
-/**
- * Gets the number of elements in a Firm compound type.
- *
- * This is just a comfortability function, because structs and
- * classes can often be treated be the same code, but they have
- * different access functions to their members.
- *
- * @param tp The type (must be struct, union or class).
- *
- * @return Number of members in the compound type.
- */
-int get_compound_n_members(const ir_type *tp);
-
-/**
- * Gets the member of a Firm compound type at position pos.
- *
- * @param tp The type (must be struct, union or class).
- * @param pos The number of the member.
- *
- * @return The member entity at position pos.
- *
- * @see get_compound_n_members() for justification of existence.
- */
-ir_entity *get_compound_member(const ir_type *tp, int pos);
-
-/** Returns index of member in tp, -1 if not contained. */
-int get_compound_member_index(const ir_type *tp, ir_entity *member);
-
-/**
- * Checks whether a type is a compound type.
- *
- * @param tp - any type
- *
- * @return true if the type is class, structure, union or array type.
- */
-int is_compound_type(const ir_type *tp);
-
-/**
- * Checks, whether a type is a frame type.
- */
-int is_frame_type(const ir_type *tp);
-
-/**
- * Checks, whether a type is a value parameter type.
- */
-int is_value_param_type(const ir_type *tp);
-
-/**
- * Checks, whether a type is a lowered type.
- */
-int is_lowered_type(const ir_type *tp);
-
-/**
- * Makes a new frame type. Frame types are class types,
- * so all class access functions work.
- * Frame types are not in the global list of types.
- */
-ir_type *new_type_frame(ident *name);
-
-/**
- * Sets a lowered type for a type. This sets both associations
- * and marks lowered_type as a "lowered" one.
- */
-void set_lowered_type(ir_type *tp, ir_type *lowered_type);
-
-/**
- * Gets the lowered/unlowered type of a type or NULL if this type
- * has no lowered/unlowered one.
- */
-ir_type *get_associated_type(const ir_type *tp);
-
-/**
- * Allocate an area of size bytes aligned at alignment
- * at the start or the end of a frame type.
- * The frame type must already have a fixed layout.
- *
- * @param frame_type a frame type
- * @param size the size of the entity
- * @param alignment the alignment of the entity
- * @param at_start if true, put the area at the frame type's start, else at end
- *
- * @return the entity representing the area
- */
-ir_entity *frame_alloc_area(ir_type *frame_type, int size, int 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
- * of the type cast to long.
- */
-long get_type_nr(const ir_type *tp);
-
-#endif /* FIRM_TR_TYPE_H */
# include "config.h"
#endif
-#include "type_identify.h"
+#include "typerep.h"
#include <stdlib.h>
#include <stddef.h>
#include "type_t.h"
#include "tpop_t.h"
#include "irprog_t.h"
-#include "typegmod.h"
#include "array.h"
#include "irprog_t.h"
-#include "mangle.h"
#include "pset.h"
#include "irtools.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file type_identify.h
- * @brief Representation of types.
- * @author Goetz Lindenmaier
- * @version $Id$
- */
-#ifndef FIRM_TR_TYPE_IDENTIFY_H
-#define FIRM_TR_TYPE_IDENTIFY_H
-
-#include "firm_types.h"
-
-/* ------------------------------------------------------------------------ */
-
-/** Type for a function that compares two types.
- *
- * @param tp1 The first type to compare.
- * @param tp2 The second type to compare.
- */
-typedef int (compare_types_func_t)(const void *tp1, const void *tp2);
-
-/** Compares two types by their name.
- *
- * Compares the opcode and the name of the types. If these are
- * equal returns 0, else non-zero.
- */
-int compare_names (const void *tp1, const void *tp2);
-
-/** Compares two types strict.
- *
- * returns 0 if tp1 == tp2, else non-zero
- */
-int compare_strict (const void *tp1, const void *tp2);
-
-/* ------------------------------------------------------------------------ */
-
-/** Type for a function that computes a hash value for a type.
- *
- * @param tp The type to compute a hash for.
- */
-typedef int (hash_types_func_t)(ir_type *tp);
-
-/** Computes a hash value by the type name.
- *
- * Uses the name of the type and the type opcode to compute the hash.
- */
-int firm_hash_name (ir_type *tp);
-
-/* ------------------------------------------------------------------------ */
-
-/** Finalize type construction.
- *
- * Indicate that a type is so far completed that it can be
- * distinguished from other types. Mature_type hashes the type into a
- * table. It uses the function in compare_types_func to compare the
- * types.
- *
- * If it finds a type identical to tp it returns this type. It turns
- * tp into the Id type. All places formerly pointing to tp will now
- * point to the found type. All entities of tp now refer to the found
- * type as their owner, but they are not a member of this type. This
- * is invalid firm -- the entities must be replaced by entities of the
- * found type. The Id type will be removed from the representation
- * automatically, but within an unknown time span. It occupies memory
- * for this time.
- *
- * @param tp The type to mature.
- */
-ir_type * mature_type(ir_type *tp);
-
-/** Finalize type construction.
- *
- * Indicate that a type is so far completed that it can be
- * distinguished from other types. Mature_type hashes the type into a
- * table. It uses the function in compare_types_func to compare the
- * types.
- *
- * If it finds a type identical to tp it returns this type. It frees
- * type tp and all its entities.
- *
- * @param tp The type to mature.
- */
-ir_type * mature_type_free(ir_type *tp);
-
-/** Finalize type construction.
- *
- * Indicate that a type is so far completed that it can be
- * distinguished from other types. Mature_type hashes the type into a
- * table. It uses the function in compare_types_func to compare the
- * types.
- *
- * If it find a type identical to tp it returns this type. It frees
- * the entities and turns the type into an Id type. All places
- * formerly pointing to tp will now point to the found type. The Id
- * type will be removed from the representation automatically, but
- * within an unknown time span. It occupies memory for this time.
- *
- * @param tp The type to mature.
- */
-ir_type * mature_type_free_entities(ir_type *tp);
-
-/**
- * The interface type for the type identify module;
- */
-typedef struct _type_identify_if_t {
- compare_types_func_t *cmp; /**< The function that should be used to compare two types.
- If NULL, compare_strict() will be used. */
- hash_types_func_t *hash; /**< The function that should be used to calculate a hash
- value of a type. If NULL, hash_name() will be used. */
-} type_identify_if_t;
-
-/**
- * Initialise the type identifier module.
- *
- * @param ti_if The interface functions for this module.
- *
- * If the parameter ti_if is NULL, the default functions compare_strict() and
- * firm_hash_name() will be used.
- */
-void init_type_identify(type_identify_if_t *ti_if);
-
-#endif /* FIRM_TR_TYPE_IDENTIFY_H */
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Provides a datatype to treat types and entities as the same.
- * @author Goetz Lindenmaier
- * @version $Id$
- */
-#ifndef FIRM_TR_TYPE_OR_ENTITY_H
-#define FIRM_TR_TYPE_OR_ENTITY_H
-
-#include "firm_types.h"
-
-/** A data type to treat types and entities as the same. */
-typedef union {
- ir_type *typ; /**< points to a type */
- ir_entity *ent; /**< points to an entity */
-} type_or_ent;
-
-
-# endif /* FIRM_TR_TYPE_OR_ENTITY_H */
#define FIRM_TR_TYPE_T_H
#include "firm_config.h"
-#include "type.h"
+#include "typerep.h"
#include "tpop_t.h"
#include "irgraph.h"
+#include "firm_common.h"
#include "array.h"
tf_tls_type = 32, /**< Set only for the tls type */
};
-/** The structure of a type. */
+/**
+ * An abstract data type to represent types.
+ *
+ * This is the abstract data type with which any type known in the
+ * compiled program can be represented. This includes types specified
+ * in the program as well as types defined by the language. In the
+ * view of the intermediate representation there is no difference
+ * between these types.
+ *
+ * There exist several kinds of types, arranged by the structure of
+ * the type. These are distinguished by a type opcode.
+ * A type is described by a set of attributes. Some of these attributes
+ * are common to all types, others depend on the kind of the type.
+ *
+ * The following describes the common attributes. They can only be
+ * accessed by the functions given below.
+ *
+ * The common fields are:
+ *
+ * - firm_kind: A firm_kind tag containing k_type. This is useful
+ * for dynamically checking whether a node is a type node.
+ * - type_op: A tp_op specifying the kind of the type.
+ * - name: An identifier specifying the name of the type. To be
+ * set by the frontend.
+ * - visibility: The visibility of this type.
+ * - size: The size of the type, i.e. an entity of this type will
+ * occupy size bits in memory. In several cases this is
+ * determined when fixing the layout of this type (class,
+ * struct, union, array, enumeration).
+ * - alignment The alignment of the type, i.e. an entity of this type will
+ * be allocated an an address in memory with this alignment.
+ * In several cases this is determined when fixing the layout
+ * of this type (class, struct, union, array)
+ * - mode: The mode to be used to represent the type on a machine.
+ * - state: The state of the type. The state represents whether the
+ * layout of the type is undefined or fixed (values: layout_undefined
+ * or layout_fixed). Compound types can have an undefined
+ * layout. The layout of the basic types primitive and pointer
+ * is always layout_fixed. If the layout of
+ * compound types is fixed all entities must have an offset
+ * and the size of the type must be set.
+ * A fixed layout for enumeration types means that each enumeration
+ * is associated with an implementation value.
+ * - assoc_type: The associated lowered/upper type.
+ * - visit: A counter for walks of the type information.
+ * - link: A void* to associate some additional information with the type.
+ *
+ * These fields can only be accessed via access functions.
+ *
+ * Depending on the value of @c type_op, i.e., depending on the kind of the
+ * type the adt contains further attributes. These are documented below.
+ *
+ * @see
+ *
+ * @link class_type class @endlink, @link struct_type struct @endlink,
+ * @link method_type method @endlink, @link union_type union @endlink,
+ * @link array_type array @endlink, @link enumeration_type enumeration @endlink,
+ * @link pointer_type pointer @endlink, @link primitive_type primitive @endlink
+ *
+ * @todo
+ * mode maybe not global field??
+ */
struct ir_type {
firm_kind kind; /**< the firm kind, must be k_type */
const tp_op *type_op; /**< the type operation of the type */
#include "config.h"
#endif
-#include "typegmod.h"
#include "type_t.h"
#include "tpop_t.h"
#include "irmode.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file typegmod.h
- * @brief Functionality to modify the type graph.
- * @author Goetz Lindenmaier, Michael Beck
- * @version $Id$
- */
-#ifndef FIRM_TR_TYPEGMOD_H
-#define FIRM_TR_TYPEGMOD_H
-
-#include "firm_types.h"
-
-/**
- *
- * @file typegmod.h
- * This module supplies routines that support changing the type graph.
- */
-
-/** Replaces one type by the other.
- *
- * Old type is replaced by new_type. All references to old_type
- * now point to new_type. The memory for the old type is destroyed,
- * but still used. Therefore it is not freed.
- * All referenced to this memory will be lost after a certain while.
- * An exception is the list of types in irp (irprog.h).
- * In the future there might be a routine to recover the memory, but
- * this will be at considerable runtime cost.
- *
- * @param old_type - The old type that shall be replaced by the new type.
- * @param new_type - The new type that will replace old_type.
- *
- */
-void exchange_types(ir_type *old_type, ir_type *new_type);
-
-/** Skip id types until a useful type is reached.
- *
- * @param tp - A type of arbitrary kind.
- *
- * @return
- * tp if it is not an id type.
- * If tp is an id type returns the real type it stands for.
- */
-ir_type *skip_tid(ir_type *tp);
-
-#endif /*FIRM_TR_TYPEGMOD_H */
#include <stdio.h>
-#include "typewalk.h"
#include "entity_t.h"
#include "type_t.h"
-#include "type_or_entity.h"
-#include "typegmod.h"
#include "irprog_t.h"
#include "irgraph_t.h"
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file typewalk.h
- * @brief Functionality to modify the type graph.
- * @author Goetz Lindenmaier
- * @version $Id$
- * @summary
- *
- * Traverse the type information.
- *
- * The walker walks the whole ir graph
- * to find the distinct type trees in the type graph forest.
- * - execute the pre() function before recursion
- * - execute the post() function after recursion
- */
-#ifndef FIRM_TR_TYPEWALK_H
-#define FIRM_TR_TYPEWALK_H
-
-#include "type.h"
-#include "type_or_entity.h"
-
-#include "irgraph.h"
-
-/** Type of argument functions for type walkers.
- *
- * @param tore points to the visited type or entity
- * @param env free environment pointer
- */
-typedef void type_walk_func(type_or_ent *tore, void *env);
-
-/** The class walk function
- *
- * @param clss points to the visited class
- * @param env free environment pointer
- */
-typedef void class_walk_func(ir_type *clss, void *env);
-
-/** Touches every type and entity in unspecified order. If new
- * types/entities are created during the traversal these will
- * be visited, too.
- * Does not touch frame types or types for value params ... */
-void type_walk(type_walk_func *pre, type_walk_func *post, void *env);
-
-/** Walks over all type information reachable from an ir graph.
- *
- * Walks over all type information reachable from irg, i.e., starts a
- * type walk at the irgs entity, the irgs frame type and all types and
- * entities that are attributes to firm nodes. */
-void type_walk_irg(ir_graph *irg,
- type_walk_func *pre,
- type_walk_func *post,
- void *env);
-
-/**
- Touches every class in specified order:
- - first the super class
- - second the class itself
- - third the sub classes. If new classes are created
- during the traversal these will be visited, too.
-
- @todo should be named class-walk
-
- @deprecated will be removed?
-*/
-void type_walk_super2sub(type_walk_func *pre,
- type_walk_func *post,
- void *env);
-
-/** Walker for class types in inheritance order.
- *
- * Touches every class in specified order:
- * - first the super class
- * - second the class itself
- * If new classes are created during the traversal these
- * will be visited, too.
- * Starts the walk at arbitrary classes.
- * Executes pre when first visiting a class. Executes post after
- * visiting all superclasses.
- *
- * The arguments pre, post, env may be NULL. */
-void type_walk_super(type_walk_func *pre,
- type_walk_func *post,
- void *env);
-
-/** Same as type_walk_super2sub, but visits only class types.
- Executes pre for a class if all superclasses have been visited.
- Then iterates to subclasses. Executes post after return from
- subclass.
- Does not visit global type, frame types.
-
- @bug ?? something is wrong with this.
-*/
-void class_walk_super2sub(class_walk_func *pre,
- class_walk_func *post,
- void *env);
-
-/**
- * the entity walk function. A function type for entity walkers.
- *
- * @param ent points to the visited entity
- * @param env free environment pointer
- */
-typedef void entity_walk_func(ir_entity *ent, void *env);
-
-/**
- * Walks over all entities in the type.
- *
- * @param tp the type
- * @param doit the entity walker function
- * @param env environment, will be passed to the walker function
- */
-void walk_types_entities(ir_type *tp,
- entity_walk_func *doit,
- void *env);
-
-#endif /* FIRM_TR_TYPEWALK_H */
+++ /dev/null
-/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- */
-
-/**
- * @file
- * @brief Representation of and static computations on target machine
- * values.
- * @date 2003
- * @author Mathias Heil
- * @version $Id$
- * @summary
- * Tarvals represent target machine values. They are typed by modes.
- * Tarvals only represent values of mode_sort:
- * - int_number,
- * - float_number,
- * - boolean,
- * - reference,
- * - character
- *
- * In case of references the module accepts an entity to represent the
- * value.
- * Furthermore, computations and conversions of these values can
- * be performed.
- *
- * HISTORY
- * The original tv module originated in the fiasco compiler written ...
- * This is the new version, described in the tech report 1999-14 by ...
- *
- * @sa
- * Techreport 1999-14
- * irmode.h for the modes definitions
- * irnode.h for the pn_Cmp table
- */
-#ifndef FIRM_TV_TV_H
-#define FIRM_TV_TV_H
-
-#include "firm_types.h"
-#include "irnode.h"
-
-#ifndef _TARVAL_TYPEDEF_
-#define _TARVAL_TYPEDEF_
- typedef struct tarval tarval;
-#endif
-
-/* ************************ Constructors for tarvals ************************ */
-
-/**
- * Constructor function for new tarvals.
- *
- * @param str The string representing the target value
- * @param len The length of the string
- * @param mode The mode requested for the result tarval
- *
- * This function creates a new tarval representing the value represented
- * by a CString, aka char array. If a tarval representing this value already
- * exists, this tarval is returned instead of a new one. So tarvals are
- * directly comparable since their representation is unique.
- *
- * This function accepts the following strings:
- *
- * if mode is int_number:
- * - 0(x|X)[0-9a-fA-F]+ (hexadecimal representation)
- * - 0[0-7]* (octal representation)
- * - (+|-)?[1-9][0-9]* (decimal representation)
- *
- * if mode if float_number:
- * - (+|-)?(decimal int) (. (decimal int))? ((e|E)(+|-)?(decimal int))?
- *
- * if mode is boolean: true, True, TRUE ... False... 0, 1,
- *
- * if mode is reference: hexadecimal of decimal number as int
- *
- * if mode is character: hex or dec
- *
- * Leading and/or trailing spaces are ignored
- *
- * @return
- * A tarval of proper type representing the requested value is returned.
- * Tarvals are unique, so for any value/mode pair at most one tarval will
- * exist, which will be returned upon further requests with an identical
- * value/mode pair.
- *
- * @note
- * If the string is not representable in the given mode an assertion is
- * thrown in assert build.
- *
- * @sa
- * irmode.h for predefined modes
- * new_tarval_from_long()
- * new_tarval_from_double()
- */
-tarval *new_tarval_from_str(const char *str, size_t len, ir_mode *mode);
-
-/**
- * Constructor function for new tarvals
- *
- * @param l The long representing the value
- * @param mode The mode requested for the result tarval
- *
- * This function creates a new tarval representing the value represented
- * by a long integer. If a tarval representing this value already exists,
- * this tarval is returned instead of a new one. So tarvals are directly
- * comparable since their representation is unique.
- *
- * @return
- * A tarval of proper type representing the requested value is returned.
- * Tarvals are unique, so for any value/mode pair at most one tarval will
- * exist, which will be returned upon further requests with an identical
- * value/mode pair.
- *
- * @note
- * If the long is not representable in the given mode an assertion is
- * thrown in assert build.
- *
- * @sa
- * irmode.h for predefined modes
- * new_tarval_from_str()
- * new_tarval_from_double()
- *
- */
-tarval *new_tarval_from_long(long l, ir_mode *mode);
-
-/** Return value as long if possible.
- *
- * This returns a long int with the value represented value, or
- * gibberish, depending on the size of long int and the size of the
- * stored value. It works for e.g. 1 as mode_Ls, but might not work for
- * get_mode_max(mode_Ls).
- * This will overflow silently, so use only if you know what
- * you are doing! (better check with tarval_is_long()...)
- * Works only for int modes, even not for character modes!
- */
-long get_tarval_long(tarval *tv);
-
-/**
- * This validates if get_tarval_long() will return a satisfying
- * result. I.e. if tv is an int_number and between min, max
- * of long int (signed!)
- */
-int tarval_is_long(tarval *tv);
-
-/**
- * Constructor function for new tarvals.
- *
- * @param d The (long) double representing the value
- * @param mode The mode requested for the result tarval
- *
- * This function creates a new tarval representing the value represented
- * by a (long) double. If a tarval representing this value already exists,
- * this tarval is returned instead of a new one. So tarvals are directly
- * comparable since their representation is unique.
- * Only modes of sort float_number can be constructed this way.
- *
- * @return
- * A tarval of proper type representing the requested value is returned.
- * Tarvals are unique, so for any value/mode pair at most one tarval will
- * exist, which will be returned upon further requests with an identical
- * value/mode pair.
- *
- * @note
- * If the (long) double is not representable in the given mode an assertion
- * is thrown. This will happen for any mode not of sort float_number.
- *
- * @sa
- * irmode.h for predefined values
- * new_tarval_from_str()
- * new_tarval_from_long()
- */
-tarval *new_tarval_from_double(long double d, ir_mode *mode);
-
-/**
- * This returns a double with the value represented value, or
- * gibberish, depending on the size of double and the size of the
- * stored value.
- * This will overflow silently, so use only if you know what
- * you are doing! (better check with tarval_is_long...)
- */
-long double get_tarval_double(tarval *tv);
-
-/**
- * This validates if tarval_to_double() will return a satisfying
- * result. I.e. if tv is an float_number and between min, max
- * of double
- */
-int tarval_is_double(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. */
-ir_mode *get_tarval_mode (const tarval *tv);
-
-/** Returns the contents of the 'link' field of the tarval */
-/* void *get_tarval_link (tarval*); */
-
-/* Testing properties of the represented values */
-
-/**
- * Returns 1 if tv is negative
- *
- * @param a the tarval
- */
-int tarval_is_negative(tarval *a);
-
-/**
- * Returns 1 if tv is null
- *
- * @param a the tarval
- */
-int tarval_is_null(tarval *a);
-
-/**
- * Returns 1 if tv is the "one"
- *
- * @param a the tarval
- */
-int tarval_is_one(tarval *a);
-
-/** The 'bad' tarval. */
-extern tarval *tarval_bad;
-/** Returns the 'bad tarval. */
-tarval *get_tarval_bad(void);
-
-/** The 'undefined' tarval. */
-extern tarval *tarval_undefined;
-/** Returns the 'undefined' tarval. */
-tarval *get_tarval_undefined(void);
-
-/** The mode_b tarval 'false'. */
-extern tarval *tarval_b_false;
-
-/** Returns the mode_b tarval 'false'. */
-tarval *get_tarval_b_false(void);
-
-/** The mode_b tarval 'true'. */
-extern tarval *tarval_b_true;
-/** Returns the mode_b tarval 'true'. */
-tarval *get_tarval_b_true(void);
-
-/* 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. */
-tarval *get_tarval_max(ir_mode *mode);
-
-/** Returns the minimum value of a given mode. */
-tarval *get_tarval_min(ir_mode *mode);
-
-/** Returns the 0 value (additive neutral) of a given mode.
- For reference modes, the NULL value is returned (old tarval_P_void) */
-tarval *get_tarval_null(ir_mode *mode);
-
-/** Returns the 1 value (multiplicative neutral) of a given mode. */
-tarval *get_tarval_one(ir_mode *mode);
-
-/** Returns the -1 value (multiplicative neutral) of a given mode.
- * Returns tarval bad for unsigned modes */
-tarval *get_tarval_minus_one(ir_mode *mode);
-
-/** Return quite nan for float_number modes. */
-tarval *get_tarval_nan(ir_mode *mode);
-
-/** Return +inf for float_number modes. */
-tarval *get_tarval_plus_inf(ir_mode *mode);
-
-/** Return -inf for float_number modes. */
-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 */
- TV_OVERFLOW_SATURATE /**< tarval module will saturate the overflow */
-} tarval_int_overflow_mode_t;
-
-/**
- * Sets the overflow mode for integer operations.
- */
-void tarval_set_integer_overflow_mode(tarval_int_overflow_mode_t ov_mode);
-
-/**
- * Get the overflow mode for integer operations.
- */
-tarval_int_overflow_mode_t tarval_get_integer_overflow_mode(void);
-
-/**
- * Compares two tarvals
- *
- * Compare a with b and return a pn_Cmp describing the relation
- * between a and b. This is either pn_Cmp_Uo, pn_Cmp_Lt, pn_Cmp_Eq, pn_Cmp_Gt,
- * or pn_Cmp_False if a or b are symbolic pointers which can not be compared at all.
- *
- * @param a A tarval to be compared
- * @param b A tarval to be compared
- *
- * @return
- * The pn_Cmp best describing the relation between a and b is returned.
- * This means the mode with the least bits set is returned, e.g. if the
- * tarvals are equal the pn_Cmp 'pn_Cmp_Eq' is returned, not 'pn_Cmp_Ge' which
- * indicates 'greater or equal'
- *
- * @sa
- * irnode.h for the definition of pn_Cmp
- */
-pn_Cmp tarval_cmp(tarval *a, tarval *b);
-
-/**
- * Converts a tarval to another mode.
- *
- * Convert tarval 'src' to mode 'mode', this will succeed if and only if mode
- * 'mode' is wider than the mode of src, as defined in the firm documentation
- * and as returned by the function mode_is_smaller defined in irmode.h.
- *
- * @param src The tarval to convert
- * @param mode Tho mode to convert to
- *
- * @return
- * If a tarval of mode 'mode' with the result of the conversion of the 'src'
- * tarvals value already exists, it will be returned, else a new tarval is
- * constructed and returned
- *
- * @note
- * Illegal conversations will trigger an assertion
- *
- * @sa
- * FIRM documentation for conversion rules
- * mode_is_smaller defined in irmode.h
- */
-tarval *tarval_convert_to(tarval *src, ir_mode *mode);
-
-/*
- * These function implement basic computations representable as opcodes
- * in FIRM nodes.
- *
- * PARAMETERS
- * tarval_neg:
- * traval_abs:
- * a - the tarval to operate on
- *
- * all others:
- * a - the first operand tarval
- * b - the second operand tarval
- *
- * RESULT
- * If necessary a new tarval is constructed for the resulting value,
- * or the one already carrying the computation result is retrieved and
- * returned as result.
- *
- * NOTES
- * The order the arguments are given in is important, imagine postfix
- * notation.
- * Illegal operations will trigger an assertion.
- * The sort member of the struct mode defines which operations are valid
- */
-
-/** bitwise Negation of a tarval. */
-tarval *tarval_not(tarval *a);
-
-/** arithmetic Negation of a tarval. */
-tarval *tarval_neg(tarval *a);
-
-/** Addition of two tarvals. */
-tarval *tarval_add(tarval *a, tarval *b);
-
-/** Subtraction from a tarval. */
-tarval *tarval_sub(tarval *a, tarval *b);
-
-/** Multiplication of tarvals. */
-tarval *tarval_mul(tarval *a, tarval *b);
-
-/** 'Exact' division. */
-tarval *tarval_quo(tarval *a, tarval *b);
-
-/** Integer division. */
-tarval *tarval_div(tarval *a, tarval *b);
-
-/** Remainder of integer division. */
-tarval *tarval_mod(tarval *a, tarval *b);
-
-/** Absolute value. */
-tarval *tarval_abs(tarval *a);
-
-/** Bitwise and. */
-tarval *tarval_and(tarval *a, tarval *b);
-
-/** Bitwise or. */
-tarval *tarval_or(tarval *a, tarval *b);
-
-/** Bitwise exclusive or. */
-tarval *tarval_eor(tarval *a, tarval *b);
-
-/** Left shift. */
-tarval *tarval_shl(tarval *a, tarval *b);
-
-/** Unsigned (logical) right shift. */
-tarval *tarval_shr(tarval *a, tarval *b);
-
-/** Signed (arithmetic) right shift. */
-tarval *tarval_shrs(tarval *a, tarval *b);
-
-/** Rotation. */
-tarval *tarval_rot(tarval *a, tarval *b);
-
-/** Carry flag of the last operation */
-int tarval_carry(void);
-
-/* *********** Output of tarvals *********** */
-
-/**
- * The output mode for tarval values.
- *
- * Some modes allow more that one representation, for instance integers
- * can be represented hex or decimal. Of course it would be enough to have
- * one and let every backend convert it into the 'right' one.
- * 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)*/
-} tv_output_mode;
-
-/**
- * This structure contains helper information to format the output
- * of a tarval of a mode.
- */
-typedef struct tarval_mode_info {
- tv_output_mode mode_output; /**< if != TVO_NATIVE select a special mode */
- const char *mode_prefix; /**< if set, this prefix will be printed
- before a value of this mode */
- const char *mode_suffix; /**< if set, this suffix will be printed
- after a value of this mode */
-} tarval_mode_info;
-
-/**
- * Specify the output options of one mode.
- *
- * This functions stores the mode info, so DO NOT DESTROY it.
- *
- * @param mode a ir_mode that should be associated
- * @param modeinfo the output format info
- *
- * @return zero on success.
- */
-int set_tarval_mode_output_option(ir_mode *mode, const tarval_mode_info *modeinfo);
-
-/**
- * Returns the output options of one mode.
- *
- * This functions returns the mode info of a given mode.
- *
- * @param mode a ir_mode that should be associated
- *
- * @return the output option
- */
-const tarval_mode_info *get_tarval_mode_output_option(ir_mode *mode);
-
-/**
- * Returns Bit representation of a tarval value, as string of '0' and '1'
- *
- * @param tv The tarval
- *
- * This function returns a printable bit representation of any value
- * stored as tarval. This representation is a null terminated C string.
- *
- * @return
- * As usual in C a pointer to a char is returned. The length of the
- * returned string if fixed, just read as many chars as the mode defines
- * as size.
- *
- * @note
- * The string is allocated using malloc() and is free()ed on the next call
- * of this function.
- * The string consists of the ASCII characters '0' and '1' and is
- * null terminated
- *
- * @sa
- * irmode.h for the definition of the ir_mode struct
- * the size member of aforementioned struct
- */
-char *get_tarval_bitpattern(tarval *tv);
-
-/**
- * Returns the bitpattern of the bytes_ofs byte.
- *
- * This function succeeds even if the mode of the tarval uses lesser bits
- * than requested, in that case the bitpattern is filled with zero bits.
- *
- * To query a 32bit value the following code can be used:
- *
- * val0 = tarval_sub_bits(tv, 0);
- * val1 = tarval_sub_bits(tv, 1);
- * val2 = tarval_sub_bits(tv, 2);
- * val3 = tarval_sub_bits(tv, 3);
- *
- * 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 tv the tarval
- * @param byte_ofs the byte offset
- *
- * @note
- * The result of this function is undefined if the mode is neither integer nor float.
- */
-unsigned char get_tarval_sub_bits(tarval *tv, unsigned byte_ofs);
-
-/**
- * Return values of tarval classify
- */
-typedef enum _tarval_classification_t {
- TV_CLASSIFY_NULL = 0, /**< the tarval represents the additive neutral element */
- TV_CLASSIFY_ONE = +1, /**< the tarval represents the multiplicative neutral element */
- TV_CLASSIFY_ALL_ONE = -1, /**< the tarval represents the bitwise-and neutral element */
- TV_CLASSIFY_OTHER = 2 /**< all other tarvals */
-} tarval_classification_t;
-
-/**
- * Identifying tarvals values for algebraic simplifications.
- *
- * @param tv the tarval
- *
- * @return
- * - TV_CLASSIFY_NULL for additive neutral or the NULL tarval for reference modes,
- * - TV_CLASSIFY_ONE for multiplicative neutral,
- * - TV_CLASSIFY_ALL_ONE for bitwise-and neutral
- * - TV_CLASSIFY_OTHER else
- */
-tarval_classification_t classify_tarval(tarval *tv);
-
-/**
- * Returns non-zero if a given (integer) tarval has only one single bit
- * set.
- */
-int is_single_bit_tarval(tarval *tv);
-
-/**
- * Output of tarvals to a buffer.
- */
-int tarval_snprintf(char *buf, size_t buflen, tarval *tv);
-
-/**
- * Output of tarvals to stdio.
- */
-int tarval_printf(tarval *tv);
-
-#endif /* FIRM_TV_TV_H */