end block can not be optimized away any more.
[libfirm] / ir / ir / ircons.h
index 2f4b26c..5409d0d 100644 (file)
  it is always unambiguous.
 **/
 
-/**
-***  IRCONS
+/****h* libfirm/ircons
+ *
+ * NAME
+ *   file ircons.h
+ *
+ * NOTES
 
   This file documents all datatypes and constructors needed to
   build a FIRM representation of a pocedure.  The constructors are
     *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.
 
   Three kinds of nodes
   --------------------
 
 
 
-
   CONSTRUCTOR FOR IR_GRAPH
   ========================
 
   * 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 switch_block()).  This interface
-    is called "block oriented".
+    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).
+    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.
               variable.
 
   Parameters
-    kind       The kind of the symbolic constant: type_tag, size or link_info.
-    *type      Points to the type the tag stands for or to the type
-               whose size is represented by the constant.
+    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.
                       - size
                      - linkage_ptr_info
       If the attr.i.num is type_tag or size, the node contains an attribute
-    attr.i.*type     A pointer to a type_class.
+    attr.i.*type,    a pointer to a type_class.  The mode of the node is mode_i.
       if it is linkage_ptr_info it contains
-    attr.i.*ptrinfo  A ident holding information for the linker.
+    attr.i.*ptrinfo,  an ident holding information for the linker.  The mode
+      of the node is mode_p.
 
   THE SELECT NODE
   ---------------
   Parameters:
   *store        The current memory.
   *addr         A pointer to the variable to be read in this memory.
-  *mode         The mode of the loaded value.
 
   Inputs:
     The memory and a pointer to a variable in this memory.
   --------------------------------
 
   Returns the node defining the actual store.
-
-**/
+  *****
+  */
 
 
 # ifndef _IRCONS_H_
 # define _IRCONS_H_
 
+# include "common.h"
 # include "irgraph.h"
 # include "irnode.h"
 # include "irmode.h"
 # include "entity.h"
 # include "tv.h"
 # include "type.h"
-# include "pdeq.h"
-
-#if USE_EXPICIT_PHI_IN_STACK
-/* A stack needed for the automatic Phi node construction in constructor
-   Phi_in. */
-typedef struct Phi_in_stack Phi_in_stack;
-#endif
 
 /***************************************************************************/
 /* The raw interface                                                       */
+/***************************************************************************/
 
+/* Constructs a Block with a fixed number of predecessors.
+   Does not set current_block.  Can not be used with automatic
+   Phi node construction. */
 ir_node *new_r_Block  (ir_graph *irg,  int arity, ir_node **in);
 ir_node *new_r_Start  (ir_graph *irg, ir_node *block);
 ir_node *new_r_End    (ir_graph *irg, ir_node *block);
@@ -1107,7 +1113,7 @@ ir_node *new_r_Raise  (ir_graph *irg, ir_node *block,
 ir_node *new_r_Const  (ir_graph *irg, ir_node *block,
                       ir_mode *mode, tarval *con);
 ir_node *new_r_SymConst (ir_graph *irg, ir_node *block,
-                       type_or_id *value, symconst_kind symkind);
+                       type_or_id_p value, symconst_kind symkind);
 ir_node *new_r_Sel    (ir_graph *irg, ir_node *block, ir_node *store,
                        ir_node *objptr, int n_index, ir_node **index,
                       entity *ent);
@@ -1169,25 +1175,21 @@ ir_node *new_r_Tuple  (ir_graph *irg, ir_node *block,
                       int arity, ir_node **in);
 ir_node *new_r_Id     (ir_graph *irg, ir_node *block,
                       ir_node *val, ir_mode *mode);
-ir_node *new_r_Bad    (ir_node *block);
+ir_node *new_r_Bad    ();
 
 
 /*************************************************************************/
 /* The block oriented interface                                          */
+/*************************************************************************/
 
 /* Sets the current block in which the following constructors place the
    nodes they construct. */
 void switch_block (ir_node *target);
 
-/* Chris: please rename the Block constructor:
-   new_Block to new_immBlock
-   and add a new one so dass das dann so aussieht:
-   passe die Beispeilprogramme an! */
-#if 0
-ir_node *new_Block(int arity, ir_node **in);     /* creates mature Block */
-#else
-ir_node *new_Block  (void);
-#endif
+/* Constructs a Block with a fixed number of predecessors.
+   Does set current_block.  Can be used with automatic Phi
+   node construction. */
+ir_node *new_Block(int arity, ir_node **in);
 ir_node *new_Start  (void);
 ir_node *new_End    (void);
 ir_node *new_Jmp    (void);
@@ -1195,7 +1197,7 @@ ir_node *new_Cond   (ir_node *c);
 ir_node *new_Return (ir_node *store, int arity, ir_node **in);
 ir_node *new_Raise  (ir_node *store, ir_node *obj);
 ir_node *new_Const  (ir_mode *mode, tarval *con);
-ir_node *new_SymConst (type_or_id *value, symconst_kind kind);
+ir_node *new_SymConst (type_or_id_p value, symconst_kind kind);
 ir_node *new_simpleSel (ir_node *store, ir_node *objptr, entity *ent);
 ir_node *new_Sel    (ir_node *store, ir_node *objptr, int arity, ir_node **in,
                      entity *ent);
@@ -1238,6 +1240,7 @@ ir_node *new_Bad    (void);
 /* Supports automatic Phi node construction.                           */
 /* All routines of the block oriented interface except new_Block are   */
 /* needed also.                                                        */
+/***********************************************************************/
 
 /** Block construction **/
 /* immature Block without predecessors */
@@ -1247,16 +1250,17 @@ ir_node *new_immBlock (void);
 void add_in_edge (ir_node *immblock, ir_node *jmp);
 
 /* fixes the number of predecessors of a block. */
-void     mature_block (ir_node *block);
+void mature_block (ir_node *block);
 
 /** Parameter administration **/
 /* Read a value from the array with the local variables.  Use this
    function to obtain the last definition of the value associated with
-   pos. */
+   pos.  Pos may not exceed the value passed as n_loc to new_ir_graph. */
 ir_node *get_value (int pos, ir_mode *mode);
 
 /* Write a value in the array with the local variables. Use this function
-   to remember a new definition of the value associated with pos. */
+   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. */
 void set_value (int pos, ir_node *value);
 
 /* Read a store.
@@ -1267,16 +1271,9 @@ ir_node *get_store (void);
 /* Write a store. */
 void set_store (ir_node *store);
 
-
-/* This function is for internal use only.  It is visible as it is needed
-   in irgraph.c to create the stack that is needed for automatic Phi
-   construction. */
-#if USE_EXPICIT_PHI_IN_STACK
-Phi_in_stack *new_Phi_in_stack();
-#endif
-
-/**************************************************************************/
-/* initialize ir construction                                             */
+/***********************************************************************/
+/* initialize ir construction                                          */
+/***********************************************************************/
 void init_cons (void);