X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Fircons.h;h=94ecb7aa45102d5ca6a656174cb2fcc0fe3ed5ee;hb=e570f00fb465d212dde403160e97ab45d36d1d7e;hp=04af240301a751473d78a634ab0b24a701a37618;hpb=62526938a78e229e700fef9bd825e87d14ba549f;p=libfirm diff --git a/ir/ir/ircons.h b/ir/ir/ircons.h index 04af24030..94ecb7aa4 100644 --- a/ir/ir/ircons.h +++ b/ir/ir/ircons.h @@ -1,32 +1,37 @@ -/* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe -** All rights reserved. -** -** Authors: Martin Trapp, Christian Schaefer, -** Goetz Lindenmaier -** -** ircons.h ir node construction -*/ - - -/** !!! -*** 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. +/* + * Project: libFIRM + * File name: ir/ir/ircons.h + * Purpose: Various irnode constructors. Automatic construction + * of SSA representation. + * Author: Martin Trapp, Christian Schaefer + * Modified by: Goetz Lindenmaier, Boris Boesler + * Created: + * CVS-ID: $Id$ + * Copyright: (c) 1998-2003 Universität Karlsruhe + * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. + */ - 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 + * + * documentation no more supported since 2001 * - * NAME - * file ircons.h + * ir node construction. + * + * @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. @@ -35,7 +40,6 @@ * * For extensive documentation of FIRM see UKA Techreport 1999-14. * - * DATATYPES * ========= * * The struct ir_graph @@ -73,14 +77,14 @@ * 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... . + * *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... . * - * *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 pns_args. + * *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 pns_args. * * *bad The bad node is an auxiliary node. It is needed only once, * so there is this globally reachable node. @@ -95,14 +99,14 @@ * Only needed for ir construction. * * params/n_loc An int giving the number of local variables in this - * procedure. This is neede for ir construction. Name will - * be changed. + * procedure. This is neede 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. + * for optimizing use in iropt.c. * * *Phi_in_stack; a stack needed for automatic Phi construction, needed only - * during ir construction. + * during ir construction. * * visited A int used as flag to traverse the ir_graph. * @@ -169,7 +173,7 @@ * *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. + * not a type of the source language. * * visit A flag for traversing the ir. * @@ -180,11 +184,11 @@ * first Phi node, this node points to the second Phi node * in the Block and so fourth. Used in mature_block * to find all Phi nodes to be matured. It's also used to - * annotate a node with a better, optimized version of it. + * 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. + * of these attributes is given in op. * * The struct ir_op * ---------------- @@ -297,11 +301,11 @@ * 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(); @@ -313,20 +317,22 @@ * 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_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_immBlock (void); + * ir_node *new_Start (void); + * ir_node *new_End (void); + * ir_node *new_Jmp (void); + * 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); +<<<<<<< ircons.h * 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 obj, type *ent); * ir_node *new_Call (ir_node *store, ir_node *callee, int arity, - * ir_node **in, type_method *type); + * 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); @@ -346,22 +352,58 @@ * 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, type *to_tp); * 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); + * type *free_type); * ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj); +======= + * 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_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_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2); + * ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2); + * ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2); + * 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, type *to_tp); + * 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_Proj (ir_node *arg, ir_mode *mode, long proj); + * ir_node *new_FuncCall (ir_node *store, ir_node *callee, int arity, + * ir_node **in, type_method *type); * * void add_in_edge (ir_node *block, ir_node *jmp); - * void mature_block (ir_node *block); + * void mature_block (ir_node *block); * void switch_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 * ======================================= @@ -384,7 +426,6 @@ * - the outputs of the Firm node * - attributes to the node * - * BASIC BLOCKS * ------------ * * ir_node *new_immBlock (void) @@ -450,15 +491,20 @@ * 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. + * 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. + * 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 analyses. * * * CONTROL FLOW OPERATIONS @@ -484,7 +530,7 @@ * * pns_global_store * mode M, the global store * * pns_frame_base mode P, a pointer to the base of the procedures - * stack frame. + * stack frame. * * pns_globals mode P, a pointer to the part of the memory containing * _all_ global things. * * pns_args mode T, a tuple containing all arguments of the procedure. @@ -559,7 +605,6 @@ * else it points to the end_block. * * - * CONSTANTS * --------- * * ir_node *new_Const (ir_mode *mode, tarval *con) @@ -581,7 +626,7 @@ * 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: @@ -589,6 +634,13 @@ * size The symbolic constant represents the size of a class. * link_info Information for the linker, e.g. the name of a global * variable. + * 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), linkage_ptr_info);. + * Use a real const instead: + * new_Const(mode_P_mach, tarval_p_from_entity(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. @@ -605,14 +657,13 @@ * attr.i.num The symconst_kind, i.e. one of * - type_tag * - size - * - linkage_ptr_info + * - 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_mach. * - * THE SELECT NODE * --------------- * * ir_node *new_simpleSel (ir_node *store, ir_node *frame, entity *sel) @@ -694,6 +745,27 @@ * Attributes: * attr.call Contains the type information for the procedure. * + * ir_node *new_FuncCall (ir_node *callee, int arity, ir_node **in, type_method *type) + * ----------------------------------------------------------------------------------- + * + * Creates a procedure call to a function WITHOUT memory side effects. + * Nodes of this kind are floating in contrast to Call nodes. + * Further, a procedure call with FuncCall cannot raise an exception! + * + * Parameters + * *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 callee and the parameters. + * Output: + * A tuple containing 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) * ------------------------------------------------------------ * @@ -811,24 +883,23 @@ * number (pnc_number) to use in Proj nodes to extract the proper result. * False false * Eq equal - * Lt less - * Le less or equal - * Gt greater - * Ge greater of equal - * Lg less or greater - * Leg less, equal or greater = ordered - * Uo unordered - * Ue unordered or equal - * Ul unordered or less - * Ule unordered, less or equal - * Ug unordered or greater - * Uge unordered, greater or equal - * Ne unordered, less or greater = not equal - * True true - * - * - * - * THE PHI NODE + * Lt less + * Le less or equal + * Gt greater + * Ge greater of equal + * Lg less or greater + * Leg less, equal or greater = ordered + * Uo unordered + * Ue unordered or equal + * Ul unordered or less + * Ule unordered, less or equal + * Ug unordered or greater + * Uge unordered, greater or equal + * Ne unordered, less or greater = not equal + * True true + * + * + * * ------------ * * In general, Phi nodes are automaitcally inserted. In some cases, if @@ -841,6 +912,11 @@ * * 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 analyses. * * Parameter * arity number of predecessors @@ -897,7 +973,7 @@ * ** *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. + * 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. * @@ -1049,132 +1125,333 @@ * * 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 _IRCONS_H_ # define _IRCONS_H_ -# include "common.h" +# include "firm_common.h" # include "irgraph.h" # include "irnode.h" # include "irmode.h" # include "entity.h" # include "tv.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_r_Block (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 *new_rd_Raise (dbg_info *db, ir_graph *irg, ir_node *block, + ir_node *store, ir_node *obj); +ir_node *new_rd_Const_type (dbg_info* db, ir_graph *irg, ir_node *block, + ir_mode *mode, tarval *con, type *tp); +ir_node *new_rd_Const (dbg_info *db, ir_graph *irg, ir_node *block, + ir_mode *mode, tarval *con); +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[], + entity *ent); +ir_node *new_rd_InstOf (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store, ir_node *objptr, type *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 *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 *op1, ir_node *op2, ir_mode *mode); +ir_node *new_rd_Minus (dbg_info *db, ir_graph *irg, ir_node *block, + ir_node *op, ir_mode *mode); +ir_node *new_rd_Mul (dbg_info *db, ir_graph *irg, ir_node *block, + ir_node *op1, ir_node *op2, ir_mode *mode); +ir_node *new_rd_Quot (dbg_info *db, ir_graph *irg, ir_node *block, + ir_node *memop, ir_node *op1, ir_node *op2); +ir_node *new_rd_DivMod (dbg_info *db, ir_graph *irg, ir_node *block, + ir_node *memop, ir_node *op1, ir_node *op2); +ir_node *new_rd_Div (dbg_info *db, ir_graph *irg, ir_node *block, + ir_node *memop, ir_node *op1, ir_node *op2); +ir_node *new_rd_Mod (dbg_info *db, ir_graph *irg, ir_node *block, + ir_node *memop, ir_node *op1, ir_node *op2); +ir_node *new_rd_Abs (dbg_info *db, ir_graph *irg, ir_node *block, + ir_node *op, ir_mode *mode); +ir_node *new_rd_And (dbg_info *db, ir_graph *irg, ir_node *block, + ir_node *op1, ir_node *op2, ir_mode *mode); +ir_node *new_rd_Or (dbg_info *db, ir_graph *irg, ir_node *block, + ir_node *op1, ir_node *op2, ir_mode *mode); +ir_node *new_rd_Eor (dbg_info *db, ir_graph *irg, ir_node *block, + ir_node *op1, ir_node *op2, ir_mode *mode); +ir_node *new_rd_Not (dbg_info *db, ir_graph *irg, ir_node *block, + ir_node *op, ir_mode *mode); +ir_node *new_rd_Cmp (dbg_info *db, ir_graph *irg, ir_node *block, + ir_node *op1, ir_node *op2); +ir_node *new_rd_Shl (dbg_info *db, ir_graph *irg, ir_node *block, + ir_node *op, ir_node *k, ir_mode *mode); +ir_node *new_rd_Shr (dbg_info *db, ir_graph *irg, ir_node *block, + ir_node *op, ir_node *k, ir_mode *mode); +ir_node *new_rd_Shrs (dbg_info *db, ir_graph *irg, ir_node *block, + ir_node *op, ir_node *k, ir_mode *mode); +ir_node *new_rd_Rot (dbg_info *db, ir_graph *irg, ir_node *block, + ir_node *op, ir_node *k, ir_mode *mode); +ir_node *new_rd_Conv (dbg_info *db, ir_graph *irg, ir_node *block, + ir_node *op, ir_mode *mode); +ir_node *new_rd_Cast (dbg_info* db, ir_graph *irg, ir_node *block, + ir_node *op, type *to_tp); +ir_node *new_rd_Phi (dbg_info *db, ir_graph *irg, ir_node *block, int arity, + 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 *store, ir_node *adr, ir_node *val); +ir_node *new_rd_Alloc (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store, + 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_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[]); +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_graph *irg); +ir_node *new_rd_Confirm (dbg_info *db, ir_graph *irg, ir_node *block, + ir_node *val, ir_node *bound, pn_Cmp cmp); +ir_node *new_rd_Unknown(ir_graph *irg, ir_mode *m); +ir_node *new_rd_CallBegin(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *callee); +ir_node *new_rd_EndReg (dbg_info *db, ir_graph *irg, ir_node *block); +ir_node *new_rd_EndExcept(dbg_info *db, ir_graph *irg, ir_node *block); +ir_node *new_rd_Break (dbg_info *db, ir_graph *irg, ir_node *block); +ir_node *new_rd_Filter (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg, + ir_mode *mode, long proj); +ir_node *new_rd_FuncCall (dbg_info *db, ir_graph *irg, ir_node *block, + ir_node *callee, int arity, ir_node *in[], + type *tp); + +/*-------------------------------------------------------------------------*/ +/* 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_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 *store, ir_node *obj); ir_node *new_r_Const (ir_graph *irg, ir_node *block, - ir_mode *mode, tarval *con); + ir_mode *mode, tarval *con); 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, - entity *ent); + ir_node *objptr, int n_index, ir_node *index[], + entity *ent); +ir_node *new_r_InstOf (ir_graph *irg, ir_node *block, ir_node *x, ir_node *y, type *z); 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 *op1, ir_node *op2, ir_mode *mode); ir_node *new_r_Sub (ir_graph *irg, ir_node *block, - ir_node *op1, ir_node *op2, ir_mode *mode); + ir_node *op1, ir_node *op2, ir_mode *mode); ir_node *new_r_Minus (ir_graph *irg, ir_node *block, - ir_node *op, ir_mode *mode); + ir_node *op, ir_mode *mode); ir_node *new_r_Mul (ir_graph *irg, ir_node *block, - ir_node *op1, ir_node *op2, ir_mode *mode); + ir_node *op1, ir_node *op2, ir_mode *mode); ir_node *new_r_Quot (ir_graph *irg, ir_node *block, - ir_node *memop, ir_node *op1, ir_node *op2); + ir_node *memop, ir_node *op1, ir_node *op2); ir_node *new_r_DivMod (ir_graph *irg, ir_node *block, - ir_node *memop, ir_node *op1, ir_node *op2); + ir_node *memop, ir_node *op1, ir_node *op2); ir_node *new_r_Div (ir_graph *irg, ir_node *block, - ir_node *memop, ir_node *op1, ir_node *op2); + ir_node *memop, ir_node *op1, ir_node *op2); ir_node *new_r_Mod (ir_graph *irg, ir_node *block, - ir_node *memop, ir_node *op1, ir_node *op2); + ir_node *memop, ir_node *op1, ir_node *op2); ir_node *new_r_Abs (ir_graph *irg, ir_node *block, ir_node *op, ir_mode *mode); ir_node *new_r_And (ir_graph *irg, ir_node *block, - ir_node *op1, ir_node *op2, ir_mode *mode); + ir_node *op1, ir_node *op2, ir_mode *mode); ir_node *new_r_Or (ir_graph *irg, ir_node *block, - ir_node *op1, ir_node *op2, ir_mode *mode); + ir_node *op1, ir_node *op2, ir_mode *mode); ir_node *new_r_Eor (ir_graph *irg, ir_node *block, - ir_node *op1, ir_node *op2, ir_mode *mode); + ir_node *op1, ir_node *op2, ir_mode *mode); ir_node *new_r_Not (ir_graph *irg, ir_node *block, - ir_node *op, ir_mode *mode); + ir_node *op, ir_mode *mode); ir_node *new_r_Cmp (ir_graph *irg, ir_node *block, - ir_node *op1, ir_node *op2); + ir_node *op1, ir_node *op2); ir_node *new_r_Shl (ir_graph *irg, ir_node *block, - ir_node *op, ir_node *k, ir_mode *mode); + ir_node *op, ir_node *k, ir_mode *mode); ir_node *new_r_Shr (ir_graph *irg, ir_node *block, - ir_node *op, ir_node *k, ir_mode *mode); + ir_node *op, ir_node *k, ir_mode *mode); ir_node *new_r_Shrs (ir_graph *irg, ir_node *block, - ir_node *op, ir_node *k, ir_mode *mode); + ir_node *op, ir_node *k, ir_mode *mode); ir_node *new_r_Rot (ir_graph *irg, ir_node *block, - ir_node *op, ir_node *k, ir_mode *mode); + ir_node *op, ir_node *k, ir_mode *mode); ir_node *new_r_Conv (ir_graph *irg, ir_node *block, - ir_node *op, ir_mode *mode); + ir_node *op, ir_mode *mode); +ir_node *new_r_Cast (ir_graph *irg, ir_node *block, + ir_node *op, type *to_tp); 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 *store, ir_node *adr); ir_node *new_r_Store (ir_graph *irg, ir_node *block, - ir_node *store, ir_node *adr, ir_node *val); + ir_node *store, ir_node *adr, ir_node *val); ir_node *new_r_Alloc (ir_graph *irg, ir_node *block, ir_node *store, - ir_node *size, type *alloc_type, where_alloc where); + 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 *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_Proj (ir_graph *irg, ir_node *block, ir_node *arg, - ir_mode *mode, long proj); + ir_mode *mode, long proj); ir_node *new_r_defaultProj (ir_graph *irg, ir_node *block, ir_node *arg, - long max_proj); + 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 *val, ir_mode *mode); +ir_node *new_r_Bad (ir_graph *irg); +ir_node *new_r_Confirm (ir_graph *irg, ir_node *block, + ir_node *val, ir_node *bound, pn_Cmp cmp); +ir_node *new_r_Unknown(ir_graph *irg, ir_mode *m); +ir_node *new_r_CallBegin(ir_graph *irg, ir_node *block, ir_node *callee); +ir_node *new_r_EndReg (ir_graph *irg, ir_node *block); +ir_node *new_r_EndExcept(ir_graph *irg, ir_node *block); +ir_node *new_r_Break (ir_graph *irg, ir_node *block); +ir_node *new_r_Filter (ir_graph *irg, ir_node *block, ir_node *arg, + ir_mode *mode, long proj); +ir_node *new_r_FuncCall (ir_graph *irg, ir_node *block, + ir_node *callee, int arity, ir_node *in[], + type *tp); -/*************************************************************************/ +/*-----------------------------------------------------------------------*/ /* 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); /* 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_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_Raise (dbg_info* db, ir_node *store, ir_node *obj); +ir_node *new_d_Const_type (dbg_info* db, ir_mode *mode, tarval *con, type *tp); +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[], + entity *ent); +ir_node *new_d_InstOf (dbg_info* db, ir_node *store, ir_node *objptr, type *ent); +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_Mul (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode); +ir_node *new_d_Quot (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2); +ir_node *new_d_DivMod (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2); +ir_node *new_d_Div (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2); +ir_node *new_d_Mod (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2); +ir_node *new_d_Abs (dbg_info* db, ir_node *op, ir_mode *mode); +ir_node *new_d_And (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode); +ir_node *new_d_Or (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode); +ir_node *new_d_Eor (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode); +ir_node *new_d_Not (dbg_info* db, ir_node *op, ir_mode *mode); +ir_node *new_d_Shl (dbg_info* db, ir_node *op, ir_node *k, ir_mode *mode); +ir_node *new_d_Shr (dbg_info* db, ir_node *op, ir_node *k, ir_mode *mode); +ir_node *new_d_Shrs (dbg_info* db, ir_node *op, ir_node *k, 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_Cast (dbg_info* db, ir_node *op, type *to_tp); +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_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_Id (dbg_info* db, ir_node *val, ir_mode *mode); +ir_node *new_d_Bad (void); +ir_node *new_d_Confirm (dbg_info* db, ir_node *val, ir_node *bound, pn_Cmp cmp); +ir_node *new_d_Unknown(ir_mode *m); +ir_node *new_d_CallBegin(dbg_info *db, ir_node *callee); +ir_node *new_d_EndReg (dbg_info *db); +ir_node *new_d_EndExcept(dbg_info *db); +ir_node *new_d_Break (dbg_info *db); +ir_node *new_d_Filter (dbg_info *db, ir_node *arg, ir_mode *mode, long proj); +ir_node *new_d_FuncCall (dbg_info* db, ir_node *callee, int arity, ir_node *in[], + type *tp); + +/*-----------------------------------------------------------------------*/ +/* 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_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 *obj, 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); @@ -1194,60 +1471,102 @@ 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_Phi (int arity, ir_node **in, ir_mode *mode); +ir_node *new_Cast (ir_node *op, type *to_tp); +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); + type *free_type); +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_Confirm (ir_node *val, ir_node *bound, pn_Cmp cmp); +ir_node *new_Unknown(ir_mode *m); +ir_node *new_FuncCall (ir_node *callee, int arity, ir_node *in[], + type *tp); -/***********************************************************************/ +/*---------------------------------------------------------------------*/ /* 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); -/***********************************************************************/ -/* initialize ir construction */ -/***********************************************************************/ -void init_cons (void); +/** 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 + block use switch_block(). */ +ir_node *get_cur_block(void); + +/** Returns the frame type of the current graph */ +type *get_cur_frame_type(void); + + +/* --- initialize and finalize ir construction --- */ + +/** Puts the graph into state "phase_high" */ +void finalize_cons (ir_graph *irg); + +/* --- Initialization --- */ +/** + * This function is called, whenever a local variable is used before definition + * + * @parameter mode the mode of the local var + * @pos position choosen be the frontend for this var + * + * @return a firm node of mode @p mode that initialises 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 + */ +typedef ir_node *default_initialize_local_variable_func_t(ir_mode *mode, int pos); + +/** + * Initializes the graph construction. + * + * @param func @see default_initialize_local_variable_func_t + */ +void init_cons (default_initialize_local_variable_func_t *func); # endif /* _IRCONS_H_ */