local_optimize() now kills unrteachable code if dominance info is available.
[libfirm] / ir / ir / irnode.h
index 6df3c1d..48d41bd 100644 (file)
@@ -189,6 +189,7 @@ op_pin_state is_irn_pinned_in_irg (const ir_node *node);
  *
  * @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, may be <0 if yet.
@@ -203,13 +204,17 @@ new_ir_node (dbg_info *db,
          int arity,
          ir_node *in[]);
 
-/** Return the block the node belongs to.
+/**
+ * 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. */
+ * get_irn_block(). */
 ir_node  *get_nodes_block (const ir_node *node);
 
 /** Sets the Block of a node. */
@@ -219,6 +224,7 @@ 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!
  */
@@ -259,6 +265,18 @@ ir_node **get_Block_cfgpred_arr (ir_node *node);
 int       get_Block_n_cfgpreds (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 corresonding 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);
 bool      get_Block_matured (ir_node *node);
 void      set_Block_matured (ir_node *node, bool matured);
 
@@ -315,6 +333,11 @@ void set_End_keepalive(ir_node *end, int pos, ir_node *ka);
    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.
@@ -324,10 +347,10 @@ void free_End (ir_node *end);
    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 flavours of this Cond.  The first, the dense Cond, passes
+   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 diffirences in the treatment of cases not specified in
+   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
@@ -382,7 +405,7 @@ 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 tarvel of the const has another value. */
+  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;
@@ -422,8 +445,9 @@ typedef enum {
                           Type_or_id_p is entity *. */
 } symconst_kind;
 
-/** SymConst attributes
-    This union contains the symbolic information represented by the node  */
+/** SymConst attribute.
+ *
+ *  This union contains the symbolic information represented by the node.  */
 union symconst_symbol {
   type   *type_p;
   ident  *ident_p;
@@ -628,7 +652,8 @@ void     set_Div_mem (ir_node *node, ir_node *mem);
 typedef enum {
   pn_Div_M,           /**< Memory result.    */
   pn_Div_X_except,    /**< Execution result if exception occurred. */
-  pn_Div_res          /**< Result of computation. */
+  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 (ir_node *node);
@@ -693,7 +718,7 @@ typedef enum {
   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 */
+  /* 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 */
 
@@ -836,7 +861,7 @@ void           set_Store_volatility (ir_node *node, ent_volatility volatility);
  * Projection numbers for Alloc: use for Proj nodes!
  */
 typedef enum {
-  pn_Alloc_M,          /**< Memory result. */
+  pn_Alloc_M,         /**< Memory result. */
   pn_Alloc_X_except,  /**< Execution result if exception occurred. */
   pn_Alloc_res,       /**< Result of allocation. */
   pn_Alloc_max        /**< number of projections from an Alloc */
@@ -925,7 +950,7 @@ void     set_Mux_true  (ir_node *node, ir_node *ir_true);
 ir_node *skip_Proj (ir_node *node);
 /** returns operand of node if node is a Id */
 ir_node *skip_Id  (ir_node *node);   /* Same as skip_nop. */
-/* returns corresponding operand of Tuple if node is a Proj from
+/** 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 */
@@ -963,13 +988,34 @@ ir_node *get_fragile_op_mem(ir_node *node);
 
 /** Returns true if the operation is a forking control flow
  *  operation: Cond. */
-int is_forking_op(const ir_node *node);
+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. */
 type *get_irn_type(ir_node *n);
 
+/** Returns non-zero for constant-like nodes. */
+int is_irn_constlike(const ir_node *node);
+
+/**
+ * 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(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
@@ -1000,6 +1046,11 @@ type *get_irn_type(ir_node *n);
  */
 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);
 
 /*-----------------------------------------------------------------*/
 /** Debug aides                                                   **/