- renamed init_cons() to firm_init_cons()
[libfirm] / ir / ir / irtypes.h
index e2c8620..585dd8d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
+ * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
  *
  * This file is part of libFirm.
  *
 #include "irmemory.h"
 #include "callgraph.h"
 #include "field_temperature.h"
+#include "irphases_t.h"
 
 #include "pset.h"
 #include "set.h"
 #include "list.h"
+#include "obst.h"
+
+struct ir_phase;
 
 /** The type of an ir_op. */
 struct ir_op {
        unsigned code;          /**< The unique opcode of the op. */
        ident *name;            /**< The name of the op. */
        size_t attr_size;       /**< Space needed in memory for private attributes. */
-       op_pin_state op_pin_state_pinned; /**< How to deal with the node in CSE, PRE. */
+       op_pin_state pin_state; /**< How to deal with the node in CSE, PRE. */
        op_arity opar;          /**< The arity of operator. */
        int op_index;           /**< The index of the first data operand, 0 for most cases, 1 for Div etc. */
        unsigned flags;         /**< Flags describing the behavior of the ir_op, a bitmasks of irop_flags. */
        void *tag;              /**< Some custom pointer the op's creator can attach stuff to. */
+       void *attr;             /**< custom pointer where op's creator can attach attribute stuff to. */
 
        ir_op_ops ops;          /**< The operations of the this op. */
 };
@@ -89,7 +94,7 @@ struct ir_mode {
                                           int, float, reference ...
                                           (see irmode.h) */
        mode_arithmetic   arithmetic;    /**< different arithmetic operations possible with a mode */
-       int               size;          /**< size of the mode in Bits. */
+       unsigned          size;          /**< size of the mode in Bits. */
        unsigned          sign:1;        /**< signedness of this mode */
        unsigned int      modulo_shift;  /**< number of bits a values of this mode will be shifted */
        unsigned          vector_elem;   /**< if this is not equal 1, this is a vector mode with
@@ -102,6 +107,7 @@ struct ir_mode {
        tarval            *null;        /**< the value 0 */
        tarval            *one;         /**< the value 1 */
        tarval            *minus_one;   /**< the value -1 */
+       tarval            *all_one;     /**< the value ~0 */
        ir_mode           *eq_signed;   /**< For pointer modes, the equivalent signed integer one. */
        ir_mode           *eq_unsigned; /**< For pointer modes, the equivalent unsigned integer one. */
        void              *link;        /**< To store some intermediate information */
@@ -119,6 +125,7 @@ typedef struct {
        unsigned is_matured:1;      /**< If set, all in-nodes of the block are fixed. */
        unsigned is_dead:1;         /**< If set, the block is dead (and could be replace by a Bad. */
        unsigned is_mb_head:1;      /**< Set if this block is a macroblock head. */
+       unsigned has_label:1;       /**< Set if this block has a label assigned. */
        ir_node **graph_arr;        /**< An array to store all parameters. */
        /* Attributes holding analyses information */
        ir_dom_info dom;            /**< Datastructure that holds information about dominators.
@@ -130,13 +137,13 @@ typedef struct {
        ir_node ** in_cg;           /**< array with predecessors in
                                     * interprocedural_view, if they differ
                                     * from intraprocedural predecessors */
-       int *backedge;              /**< Field n set to true if pred n is backedge.
-                                        @@@ @todo Ev. replace by bit field! */
-       int *cg_backedge;           /**< Field n set to true if pred n is interprocedural backedge.
-                                        @@@ @todo Ev. replace by bit field! */
+       unsigned *backedge;         /**< Raw Bitfield n set to true if pred n is backedge.*/
+       unsigned *cg_backedge;      /**< Raw Bitfield n set to true if pred n is interprocedural backedge. */
        ir_extblk *extblk;          /**< The extended basic block this block belongs to. */
        ir_region *region;          /**< The immediate structural region this block belongs to. */
        unsigned mb_depth;          /**< The macroblock depth: A distance from the macroblock header */
+       ir_label_t label;           /**< The block label if assigned. */
+       ir_node  *phis;             /**< The list of Phi nodes in this block. */
 
        struct list_head succ_head; /**< A list head for all successor edges of a block. */
 } block_attr;
@@ -187,13 +194,13 @@ typedef struct {
 typedef struct {
        except_attr    exc;           /**< the exception attribute. MUST be the first one. */
        ir_type *type;                /**< Type of the allocated object.  */
-       where_alloc where;            /**< stack, heap or other managed part of memory */
+       ir_where_alloc where;         /**< stack, heap or other managed part of memory */
 } alloc_attr;
 
 /** Free attributes. */
 typedef struct {
        ir_type *type;                /**< Type of the allocated object.  */
-       where_alloc where;            /**< stack, heap or other managed part of memory */
+       ir_where_alloc where;         /**< stack, heap or other managed part of memory */
 } free_attr;
 
 /** InstOf attributes. */
@@ -205,9 +212,8 @@ typedef struct {
 /** Filter attributes. */
 typedef struct {
        long proj;                 /**< contains the result position to project (Proj) */
-       ir_node ** in_cg;          /**< array with interprocedural predecessors (Phi) */
-       int *backedge;             /**< Field n set to true if pred n is backedge.
-                                       @todo Ev. replace by bitfield! */
+       ir_node **in_cg;           /**< array with interprocedural predecessors (Phi) */
+       unsigned *backedge;        /**< Raw Bitfield n set to true if pred n is backedge. */
 } filter_attr;
 
 /** CallBegin attributes. */
@@ -224,23 +230,30 @@ typedef struct {
 typedef struct {
        except_attr   exc;            /**< The exception attribute. MUST be the first one. */
        ir_mode       *load_mode;     /**< The mode of this Load operation. */
-       ir_volatility volatility;     /**< The volatility of a Load/Store operation. */
+       unsigned      volatility:1;   /**< The volatility of this Load operation. */
+       unsigned      aligned:1;      /**< The align attribute of this Load operation. */
 } load_attr;
 
 /** Store attributes. */
 typedef struct {
        except_attr   exc;            /**< the exception attribute. MUST be the first one. */
-       ir_volatility volatility;     /**< the volatility of a Store operation */
+       unsigned      volatility:1;   /**< The volatility of this Store operation. */
+       unsigned      aligned:1;      /**< The align attribute of this Store operation. */
 } store_attr;
 
 typedef struct {
-       int            pos;  /**< For Phi0. Used to remember the value defined by
-                                 this Phi node.  Needed when the Phi is completed
-                                 to call get_r_internal_value to find the
-                                 predecessors. If this attribute is set, the Phi
-                                 node takes the role of the obsolete Phi0 node,
-                                 therefore the name. */
-} phi0_attr;
+       ir_node        *next;         /**< Points to the next Phi in the Phi list of a block. */
+       union {
+               unsigned       *backedge;     /**< Raw Bitfield: bit n is set to true if pred n is backedge. */
+               int            pos;           /**< For Phi0. Used to remember the value defined by
+                                              this Phi node.  Needed when the Phi is completed
+                                              to call get_r_internal_value() to find the
+                                              predecessors. If this attribute is set, the Phi
+                                              node takes the role of the obsolete Phi0 node,
+                                              therefore the name. */
+       } u;
+} phi_attr;
+
 
 /**< Confirm attribute. */
 typedef struct {
@@ -267,6 +280,7 @@ typedef struct {
 typedef struct {
        except_attr    exc;           /**< The exception attribute. MUST be the first one. */
        ir_mode        *res_mode;     /**< Result mode for the division. */
+       char           no_remainder;  /**< Set, if known that a division can be done without a remainder. */
 } divmod_attr;
 
 /** Inline Assembler support attribute. */
@@ -294,10 +308,7 @@ typedef union {
        cast_attr      cast;          /**< For Cast. */
        load_attr      load;          /**< For Load. */
        store_attr     store;         /**< For Store. */
-       phi0_attr      phi0;          /**< for Phi0 nodes. */
-       int            *phi_backedge; /**< For Phi after construction.
-                                          Field n set to true if pred n is backedge.
-                                          @todo Ev. replace by bitfield! */
+       phi_attr       phi;           /**< For Phi. */
        long           proj;          /**< For Proj: contains the result position to project */
        confirm_attr   confirm;       /**< For Confirm: compare operation and region. */
        filter_attr    filter;        /**< For Filter */
@@ -340,7 +351,8 @@ struct ir_node {
        struct dbg_info *dbi;    /**< A pointer to information for debug support. */
        /* ------- For debugging ------- */
 #ifdef DEBUG_libfirm
-       int out_valid;
+       unsigned out_valid : 1;
+       unsigned flags     : 31;
        long node_nr;            /**< A unique node number for each node to make output
                                      readable. */
 #endif
@@ -357,12 +369,20 @@ struct ir_node {
                                      Must be last field of struct ir_node. */
 };
 
+#include "iredgeset.h"
+
 /**
  * Edge info to put into an irg.
  */
 typedef struct _irg_edge_info_t {
+#if 0
          set      *edges;         /**< a set containing all edges of a graph. */
-         unsigned activated : 1;  /**< set if edges are activated for the graph. */
+#else
+       ir_edgeset_t    edges;
+       struct obstack  edges_obst;
+       unsigned        allocated : 1;
+#endif
+       unsigned     activated : 1;  /**< set if edges are activated for the graph. */
 } irg_edge_info_t;
 
 typedef irg_edge_info_t irg_edges_info_t[EDGE_KIND_LAST];
@@ -409,8 +429,7 @@ struct ir_graph {
                                            class it belongs to. */
        ir_type *frame_type;           /**< A class type representing the stack frame.
                                            Can include "inner" methods. */
-       ir_node *anchor;               /**< The anchor node. */
-       ir_node **proj_args;           /**< Projs of the methods arguments. */
+       ir_node *anchor;               /**< Pointer to the anchor node of this graph. */
        struct obstack *obst;          /**< The obstack where all of the ir_nodes live. */
        ir_node *current_block;        /**< Current block for newly gen_*()-erated ir_nodes. */
        struct obstack *extbb_obst;    /**< The obstack for extended basic block info. */
@@ -455,9 +474,9 @@ struct ir_graph {
                                                the node. */
 
        ir_graph **callers;                /**< For callgraph analysis: list of caller graphs. */
-       unsigned char *caller_isbe;        /**< For callgraph analysis: set if backedge. */
+       unsigned *caller_isbe;             /**< For callgraph analysis: raw bitset if backedge info calculated. */
        cg_callee_entry **callees;         /**< For callgraph analysis: list of callee calls */
-       unsigned char *callee_isbe;        /**< For callgraph analysis: set if backedge. */
+       unsigned *callee_isbe;             /**< For callgraph analysis: raw bitset if backedge info calculated. */
        int        callgraph_loop_depth;         /**< For callgraph analysis */
        int        callgraph_recursion_depth;    /**< For callgraph analysis */
        double     method_execution_frequency;   /**< For callgraph analysis */
@@ -476,14 +495,16 @@ struct ir_graph {
        irg_edges_info_t edge_info;        /**< edge info for automatic outs */
        ir_node **idx_irn_map;             /**< Array mapping node indexes to nodes. */
 
+       int index;                         /**< a unique number for each graph */
+       ir_phase *phases[PHASE_LAST];      /**< Phase information. */
 #ifdef DEBUG_libfirm
-       int             n_outs;            /**< Size wasted for outs */
-       long graph_nr;                     /**< a unique graph number for each graph to make output
-                                               readable. */
+       int   n_outs;                      /**< Size wasted for outs */
+       long graph_nr;                     /**< a unique graph number for each
+                                               graph to make output readable. */
 #endif
 
 #ifndef NDEBUG
-       unsigned using_visited       : 1;  /**< set to 1 if we are currently using the visited flag */
+       unsigned using_irn_visited   : 1;  /**< set to 1 if we are currently using the visited flag */
        unsigned using_block_visited : 1;  /**< set to 1 if we are currently using the block_visited flag */
        unsigned using_irn_link      : 1;  /**< set to 1 if we are currently using the irn_link fields */
 #endif
@@ -538,10 +559,11 @@ struct ir_prog {
        ir_address_taken_computed_state globals_adr_taken_state;  /**< Address taken state of the globals. */
 
        ir_exc_region_t last_region_nr;      /**< The last exception region number that was assigned. */
+       ir_label_t last_label_nr;            /**< The highest label number for generating unique labels. */
+       int  max_irg_idx;                    /**< highest unused irg index */
 #ifdef DEBUG_libfirm
        long max_node_nr;                    /**< to generate unique numbers for nodes. */
 #endif
 };
 
-
 #endif