/* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
-** All rights reserved.
-**
-** Authors: Martin Trapp, Christian Schaefer,
-** Goetz Lindenmaier
-**
-** ircons.h ir node construction
+* All rights reserved.
*/
/* $Id$ */
-/** !!!
-*** Ideas for imrovement:
-***
- 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.
-**/
+/**
+ @todo
+ Ideas for imrovement:
+ -# 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.
+*/
-/****h* libfirm/ircons
+/**
+ * @file ircons.h
+ *
+ * ir node construction.
*
- * NAME
- * file ircons.h
+ * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier
*
- * NOTES
* This file documents all datatypes and constructors needed to
* build a FIRM representation of a pocedure. The constructors are
* also implemented in this file.
*
* For extensive documentation of FIRM see UKA Techreport 1999-14.
*
- * DATATYPES
* =========
*
* The struct ir_graph
* add_in_edge(this_block, cf_pred1);
* add_in_edge(this_block, cf_pred2);
* mature_block(this_block);
- * a_val = get_value(42, mode_I);
+ * a_val = get_value(42, mode_Iu);
* mem = get_store();
* div = new_Div(mem, a_val, a_val);
* mem = new_Proj(div, mode_M, 0); * for the numbers for Proj see docu *
- * res = new_Proj(div, mode_I, 2);
+ * res = new_Proj(div, mode_Iu, 2);
* set_store(mem);
* set_value(res, 42);
* cf_op = new_Jmp();
* 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);
+ * ir_node *new_InstOf (ir_node *store, ir_node *objptr, type *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);
* - the outputs of the Firm node
* - attributes to the node
*
- * BASIC BLOCKS
* ------------
*
* ir_node *new_immBlock (void)
* else it points to the end_block.
*
*
- * CONSTANTS
* ---------
*
* ir_node *new_Const (ir_mode *mode, tarval *con)
* attr.con A tarval* pointer to the proper entry in the constant
* table.
*
- * ir_node *new_SymConst (type *type, symconst_kind kind)
+ * ir_node *new_SymConst (type *tp, symconst_kind kind)
* ------------------------------------------------------------
*
* There are three kinds of symbolic constants:
* datastructure don't use
* new_SymConst((type_or_id*)get_entity_ld_ident(ent), linkage_ptr_info);.
* Use a real const instead:
- * new_Const(mode_p, tarval_p_from_entity(ent));
+ * new_Const(mode_P, tarval_p_from_entity(ent));
* This makes the Constant independent of name changes of the entity due to
* mangling.
*
* - 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. The mode of the node is mode_i.
+ * 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.
+ * of the node is mode_P.
*
- * THE SELECT NODE
* ---------------
*
* ir_node *new_simpleSel (ir_node *store, ir_node *frame, entity *sel)
*
*
*
- * THE PHI NODE
* ------------
*
* In general, Phi nodes are automaitcally inserted. In some cases, if
* flow from Start to End. Adds the node to the list in the end
* node.
*
- *****
*/
# ifndef _IRCONS_H_
# define _IRCONS_H_
-# include "common.h"
+# include "firm_common.h"
# include "irgraph.h"
# include "irnode.h"
# include "irmode.h"
# include "type.h"
# include "dbginfo.h"
-/***************************************************************************/
+/*-------------------------------------------------------------------------*/
/* 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_rd_Block (dbg_info *db, ir_graph *irg, int arity, ir_node **in);
+ir_node *new_rd_Block (dbg_info *db, ir_graph *irg, int arity, ir_node *in[]);
ir_node *new_rd_Start (dbg_info *db, ir_graph *irg, ir_node *block);
ir_node *new_rd_End (dbg_info *db, ir_graph *irg, ir_node *block);
ir_node *new_rd_Jmp (dbg_info *db, ir_graph *irg, ir_node *block);
ir_node *new_rd_Cond (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *c);
ir_node *new_rd_Return (dbg_info *db, ir_graph *irg, ir_node *block,
- ir_node *store, int arity, ir_node **in);
+ ir_node *store, int arity, ir_node *in[]);
ir_node *new_rd_Raise (dbg_info *db, ir_graph *irg, ir_node *block,
ir_node *store, ir_node *obj);
ir_node *new_rd_Const (dbg_info *db, ir_graph *irg, ir_node *block,
ir_node *new_rd_SymConst (dbg_info *db, ir_graph *irg, ir_node *block,
type_or_id_p value, symconst_kind symkind);
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_node *objptr, int n_index, ir_node *index[],
entity *ent);
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,
- type *type);
+ ir_node *callee, int arity, ir_node *in[],
+ type *tp);
ir_node *new_rd_Add (dbg_info *db, ir_graph *irg, ir_node *block,
ir_node *op1, ir_node *op2, ir_mode *mode);
ir_node *new_rd_Sub (dbg_info *db, ir_graph *irg, ir_node *block,
ir_node *new_rd_Conv (dbg_info *db, ir_graph *irg, ir_node *block,
ir_node *op, ir_mode *mode);
ir_node *new_rd_Phi (dbg_info *db, ir_graph *irg, ir_node *block, int arity,
- ir_node **in, ir_mode *mode);
+ ir_node *in[], ir_mode *mode);
ir_node *new_rd_Load (dbg_info *db, ir_graph *irg, ir_node *block,
ir_node *store, ir_node *adr);
ir_node *new_rd_Store (dbg_info *db, ir_graph *irg, ir_node *block,
ir_node *size, type *alloc_type, where_alloc where);
ir_node *new_rd_Free (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
ir_node *ptr, ir_node *size, type *free_type);
-ir_node *new_rd_Sync (dbg_info *db, ir_graph *irg, ir_node *block, int arity, ir_node **in);
+ir_node *new_rd_Sync (dbg_info *db, ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
ir_node *new_rd_Proj (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
ir_mode *mode, long proj);
ir_node *new_rd_defaultProj (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
long max_proj);
ir_node *new_rd_Tuple (dbg_info *db, ir_graph *irg, ir_node *block,
- int arity, ir_node **in);
+ int arity, ir_node *in[]);
ir_node *new_rd_Id (dbg_info *db, ir_graph *irg, ir_node *block,
ir_node *val, ir_mode *mode);
ir_node *new_rd_Bad ();
ir_node *new_rd_Filter (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
ir_mode *mode, long proj);
-/***************************************************************************/
+/*-------------------------------------------------------------------------*/
/* The raw interface without debug support */
-/***************************************************************************/
+/*-------------------------------------------------------------------------*/
/* Constructs a Block with a fixed number of predecessors.
Does not set current_block. Can not be used with automatic
Phi node costruction. */
-ir_node *new_r_Block (ir_graph *irg, int arity, ir_node **in);
+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);
ir_node *new_r_Jmp (ir_graph *irg, ir_node *block);
ir_node *new_r_Cond (ir_graph *irg, ir_node *block, ir_node *c);
ir_node *new_r_Return (ir_graph *irg, ir_node *block,
- ir_node *store, int arity, ir_node **in);
+ ir_node *store, int arity, ir_node *in[]);
ir_node *new_r_Raise (ir_graph *irg, ir_node *block,
ir_node *store, ir_node *obj);
ir_node *new_r_Const (ir_graph *irg, ir_node *block,
ir_node *new_r_SymConst (ir_graph *irg, ir_node *block,
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,
+ ir_node *objptr, int n_index, ir_node *index[],
entity *ent);
ir_node *new_r_Call (ir_graph *irg, ir_node *block, ir_node *store,
- ir_node *callee, int arity, ir_node **in,
- type *type);
+ ir_node *callee, int arity, ir_node *in[],
+ type *tp);
ir_node *new_r_Add (ir_graph *irg, ir_node *block,
ir_node *op1, ir_node *op2, ir_mode *mode);
ir_node *new_r_Sub (ir_graph *irg, ir_node *block,
ir_node *new_r_Conv (ir_graph *irg, ir_node *block,
ir_node *op, ir_mode *mode);
ir_node *new_r_Phi (ir_graph *irg, ir_node *block, int arity,
- ir_node **in, ir_mode *mode);
+ ir_node *in[], ir_mode *mode);
ir_node *new_r_Load (ir_graph *irg, ir_node *block,
ir_node *store, ir_node *adr);
ir_node *new_r_Store (ir_graph *irg, ir_node *block,
ir_node *size, type *alloc_type, where_alloc where);
ir_node *new_r_Free (ir_graph *irg, ir_node *block, ir_node *store,
ir_node *ptr, ir_node *size, type *free_type);
-ir_node *new_r_Sync (ir_graph *irg, ir_node *block, int arity, ir_node **in);
+ir_node *new_r_Sync (ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
ir_node *new_r_Proj (ir_graph *irg, ir_node *block, ir_node *arg,
ir_mode *mode, long proj);
ir_node *new_r_defaultProj (ir_graph *irg, ir_node *block, ir_node *arg,
long max_proj);
ir_node *new_r_Tuple (ir_graph *irg, ir_node *block,
- int arity, ir_node **in);
+ 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 *new_r_Filter (ir_graph *irg, ir_node *block, ir_node *arg,
ir_mode *mode, long proj);
-/*************************************************************************/
+/*-----------------------------------------------------------------------*/
/* The block oriented interface */
-/*************************************************************************/
+/*-----------------------------------------------------------------------*/
-/* Sets the current block in which the following constructors place the
+/** Sets the current block in which the following constructors place the
nodes they construct. */
void switch_block (ir_node *target);
node construction. */
-ir_node *new_d_Block(dbg_info* db, int arity, ir_node **in);
+ir_node *new_d_Block(dbg_info* db, int arity, ir_node *in[]);
ir_node *new_d_Start (dbg_info* db);
ir_node *new_d_End (dbg_info* db);
ir_node *new_d_Jmp (dbg_info* db);
ir_node *new_d_Cond (dbg_info* db, ir_node *c);
-ir_node *new_d_Return (dbg_info* db, ir_node *store, int arity, ir_node **in);
+ir_node *new_d_Return (dbg_info* db, ir_node *store, int arity, ir_node *in[]);
ir_node *new_d_Raise (dbg_info* db, ir_node *store, ir_node *obj);
ir_node *new_d_Const (dbg_info* db, ir_mode *mode, tarval *con);
ir_node *new_d_SymConst (dbg_info* db, type_or_id_p value, symconst_kind kind);
ir_node *new_d_simpleSel(dbg_info* db, ir_node *store, ir_node *objptr, entity *ent);
-ir_node *new_d_Sel (dbg_info* db, ir_node *store, ir_node *objptr, int arity, ir_node **in,
+ir_node *new_d_Sel (dbg_info* db, ir_node *store, ir_node *objptr, int arity, ir_node *in[],
entity *ent);
-ir_node *new_d_Call (dbg_info* db, ir_node *store, ir_node *callee, int arity, ir_node **in,
- type *type);
+ir_node *new_d_Call (dbg_info* db, ir_node *store, ir_node *callee, int arity, ir_node *in[],
+ type *tp);
ir_node *new_d_Add (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode);
ir_node *new_d_Sub (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode);
ir_node *new_d_Minus (dbg_info* db, ir_node *op, ir_mode *mode);
ir_node *new_d_Rot (dbg_info* db, ir_node *op, ir_node *k, ir_mode *mode);
ir_node *new_d_Cmp (dbg_info* db, ir_node *op1, ir_node *op2);
ir_node *new_d_Conv (dbg_info* db, ir_node *op, ir_mode *mode);
-ir_node *new_d_Phi (dbg_info* db, int arity, ir_node **in, ir_mode *mode);
+ir_node *new_d_Phi (dbg_info* db, int arity, ir_node *in[], ir_mode *mode);
ir_node *new_d_Load (dbg_info* db, ir_node *store, ir_node *addr);
ir_node *new_d_Store (dbg_info* db, ir_node *store, ir_node *addr, ir_node *val);
ir_node *new_d_Alloc (dbg_info* db, ir_node *store, ir_node *size, type *alloc_type,
where_alloc where);
ir_node *new_d_Free (dbg_info* db, ir_node *store, ir_node *ptr, ir_node *size,
type *free_type);
-ir_node *new_d_Sync (dbg_info* db, int arity, ir_node **in);
+ir_node *new_d_Sync (dbg_info* db, int arity, ir_node *in[]);
ir_node *new_d_Proj (dbg_info* db, ir_node *arg, ir_mode *mode, long proj);
ir_node *new_d_defaultProj (dbg_info* db, ir_node *arg, long max_proj);
-ir_node *new_d_Tuple (dbg_info* db, int arity, ir_node **in);
+ir_node *new_d_Tuple (dbg_info* db, int arity, ir_node *in[]);
ir_node *new_d_Id (dbg_info* db, ir_node *val, ir_mode *mode);
ir_node *new_d_Bad (void);
ir_node *new_d_Unknown(void);
ir_node *new_d_Break (dbg_info *db);
ir_node *new_d_Filter (dbg_info *db, ir_node *arg, ir_mode *mode, long proj);
-/*************************************************************************/
+/*-----------------------------------------------------------------------*/
/* The block oriented interface without debug support */
-/*************************************************************************/
+/*-----------------------------------------------------------------------*/
/* Needed from the interfase with debug support:
void switch_block (ir_node *target); */
/* 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_Block(int arity, ir_node *in[]);
ir_node *new_Start (void);
ir_node *new_End (void);
+ir_node *new_EndReg (void);
+ir_node *new_EndExcept(void);
ir_node *new_Jmp (void);
+ir_node *new_Break (void);
ir_node *new_Cond (ir_node *c);
-ir_node *new_Return (ir_node *store, int arity, ir_node **in);
+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_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,
+ir_node *new_Sel (ir_node *store, ir_node *objptr, int arity, ir_node *in[],
entity *ent);
-ir_node *new_Call (ir_node *store, ir_node *callee, int arity, ir_node **in,
- type *type);
+ir_node *new_InstOf (ir_node *store, ir_node *objptr, type *ent);
+ir_node *new_Call (ir_node *store, ir_node *callee, int arity, ir_node *in[],
+ type *tp);
+ir_node *new_CallBegin(ir_node *callee);
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_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_Phi (int arity, ir_node **in, ir_mode *mode);
+ir_node *new_Phi (int arity, ir_node *in[], ir_mode *mode);
ir_node *new_Load (ir_node *store, ir_node *addr);
ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val);
ir_node *new_Alloc (ir_node *store, ir_node *size, type *alloc_type,
where_alloc where);
ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size,
type *free_type);
-ir_node *new_Sync (int arity, ir_node **in);
+ir_node *new_Sync (int arity, ir_node *in[]);
ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj);
+ir_node *new_Filter (ir_node *arg, ir_mode *mode, long proj);
ir_node *new_defaultProj (ir_node *arg, long max_proj);
-ir_node *new_Tuple (int arity, ir_node **in);
+ir_node *new_Tuple (int arity, ir_node *in[]);
ir_node *new_Id (ir_node *val, ir_mode *mode);
ir_node *new_Bad (void);
ir_node *new_Unknown(void);
-ir_node *new_CallBegin(ir_node *callee);
-ir_node *new_EndReg (void);
-ir_node *new_EndExcept(void);
-ir_node *new_Break (void);
-ir_node *new_Filter (ir_node *arg, ir_mode *mode, long proj);
-/***********************************************************************/
+/*---------------------------------------------------------------------*/
/* The comfortable interface. */
/* Supports automatic Phi node construction. */
/* All routines of the block oriented interface except new_Block are */
/* needed also. */
-/***********************************************************************/
+/*---------------------------------------------------------------------*/
-/** Block construction **/
+/* --- Block construction --- */
/* immature Block without predecessors */
ir_node *new_d_immBlock (dbg_info* db);
ir_node *new_immBlock (void);
-/* Add a control flow edge to an immature block. */
+/** Add a control flow edge to an immature block. */
void add_in_edge (ir_node *immblock, ir_node *jmp);
-/* fixes the number of predecessors of a block. */
+/** fixes the number of predecessors of a block. */
void mature_block (ir_node *block);
-/** Parameter administration **/
+/* --- 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 may not exceed the value passed as n_loc to new_ir_graph. */
ir_node *get_d_value (dbg_info* db, int pos, ir_mode *mode);
ir_node *get_value (int pos, ir_mode *mode);
-/* Write a value in the array with the local variables. Use this function
+/** Write a value in the array with the local variables. 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. */
void set_value (int pos, ir_node *value);
-/* Read a store.
+/** Read a store.
Use this function to get the most recent version of the store (type M).
Internally it does the same as get_value. */
ir_node *get_store (void);
-/* Write a store. */
+/** Write a store. */
void set_store (ir_node *store);
-/* keep this node alive even if End is not control-reachable from it */
-inline void keep_alive (ir_node *ka);
+/** keep this node alive even if End is not control-reachable from it */
+void keep_alive (ir_node *ka);
-/** Useful access routines **/
-/* Returns the current block of the current graph. To set the current
+/* --- Useful access routines --- */
+/** Returns the current block of the current graph. To set the current
block use switch_block(). */
ir_node *get_cur_block();
-/* Returns the frame type of the current graph */
+/** Returns the frame type of the current graph */
type *get_cur_frame_type();
-/***********************************************************************/
-/* initialize and finalize ir construction */
-/***********************************************************************/
+/* --- initialize and finalize ir construction --- */
-/* Puts the graph into state "phase_high" */
+/** Puts the graph into state "phase_high" */
void finalize_cons (ir_graph *irg);