Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
region_util.h
Go to the documentation of this file.
00001 /*
00002 
00003   Copyright (C) 2000, 2001 Silicon Graphics, Inc.  All Rights Reserved.
00004 
00005   This program is free software; you can redistribute it and/or modify it
00006   under the terms of version 2 of the GNU General Public License as
00007   published by the Free Software Foundation.
00008 
00009   This program is distributed in the hope that it would be useful, but
00010   WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00012 
00013   Further, this software is distributed without any warranty that it is
00014   free of the rightful claim of any third person regarding infringement 
00015   or the like.  Any license provided herein, whether implied or 
00016   otherwise, applies only to this software file.  Patent licenses, if 
00017   any, provided herein do not apply to combinations of this program with 
00018   other software, or any other product whatsoever.  
00019 
00020   You should have received a copy of the GNU General Public License along
00021   with this program; if not, write the Free Software Foundation, Inc., 59
00022   Temple Place - Suite 330, Boston MA 02111-1307, USA.
00023 
00024   Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pky,
00025   Mountain View, CA 94043, or:
00026 
00027   http://www.sgi.com
00028 
00029   For further information regarding this notice, see:
00030 
00031   http://oss.sgi.com/projects/GenInfo/NoticeExplan
00032 
00033 */
00034 
00035 
00036 /*-*-c++-*-*/
00037 /* ====================================================================
00038  *
00039  *
00040  * Revision history:
00041  *  31-MAY-95 wdl - Original Version
00042  *
00043  * Description:
00044  *      Definitions for region stuff in back-end.
00045  * ====================================================================*/
00046 
00047 #ifndef region_util_INCLUDED
00048 #define region_util_INCLUDED
00049 
00050 #include "defs.h"                /* for wn_core.h */
00051 #include "mempool.h"             /* for MEM_POOL  */
00052 #include "opcode.h"              /* for wn_core.h */
00053 #include "opcode_core.h"         /* for wn_core.h */
00054 #include "opcode_gen_core.h"     /* for wn_core.h */
00055 #include "srcpos.h"
00056 #include "wn_core.h"             /* for wn_map.h  */
00057 #include "wn_map.h"              /* for WN_MAP    */
00058 #include "preg_list.h"           /* for PREG_LIST */
00059 #include "stab.h"                /* for ST        */
00060 #include "wn_lower.h"            /* for LOWER_ACTIONS */
00061 #ifdef __cplusplus
00062 class POINTS_TO;
00063 #else
00064 #define POINTS_TO void           /* Evil Hack because POINTS_TO is in C++ */
00065 #endif
00066 
00067 #ifdef __cplusplus
00068 extern "C" {
00069 #endif
00070 
00071 /* structures defined elsewhere */
00072 struct cgrin;
00073 
00074 /* warning: the order of this type must correspond to phase order */
00075 /* any changes here should also be made to region_util.c, RID_level_str() */
00076 typedef enum {
00077   RL_UNKNOWN,   /* unknown REGION level                         */
00078   RL_SRC,       /* processed to source level (source to source) */
00079   RL_MP,        /* processed by MPC (source level)              */
00080   RL_RGN_INIT,  /* processed by REGION_initialize in driver     */
00081   RL_IPA_PREOPT,/* processed by IPA controlled Preopt           */
00082   RL_LNO_PREOPT,/* processed by LNO controlled Preopt           */
00083   RL_LNO,       /* processed by LNO                             */
00084   RL_DU_PREOPT, /* processed by LNO DU checking                 */
00085   RL_RAIL,      /* processed by RAIL                            */
00086   RL_RBI,       /* processed by RBI                             */
00087   RL_PREOPT,    /* processed by Mainopt's Preopt emitter        */
00088   RL_MAINOPT,   /* processed by Mainopt emitter                 */
00089   RL_RVI1,      /* processed by RVI emitter (phase 1)           */
00090   RL_RVI2,      /* processed by RVI emitter (phase 2)           */
00091   RL_CG,        /* processed to the beginning of CG             */
00092   RL_CGSCHED,   /* processed past CG scheduling                 */
00093   RL_LAST       /* > last legal value                           */
00094 } REGION_LEVEL;
00095 
00096 struct region_flags_struct {
00097   mUINT16 level : 4;           /* how far the region has been processed*/
00098   mUINT16 gra_flags : 4;
00099   mUINT16 return_flag : 1;     /* region contains a return             */
00100   mUINT16 glue_code_flag : 1;  /* glue code region created by cg       */
00101   mUINT16 contains_black : 1;  /* TRUE if PU can contain a black region*/
00102   mUINT16 contains_bounds : 1; /* TRUE if PU has regions w/ bounds     */
00103   mUINT16 bounds_exist : 1;    /* region boundaries have been created  */
00104   mUINT16 aliased_to_globals : 1; /* bound sets aliased to globals     */
00105   mUINT16 aliased_to_indirects : 1; /* bound sets aliased to indirects */
00106   mUINT16 contains_uplevel : 1; /* region contains uplevel references  */
00107   mUINT16 contains_barrier : 1; /* region contains barrier w/ no STs   */
00108   mUINT16 unused : 3;
00109 };
00110 
00111 typedef enum {
00112   RID_FLAGS_has_reg_alloc = 0x1, /* register allocation exists          */
00113   RID_FLAGS_was_gra       = 0x2  /* GRA did it (else must be SWP)       */
00114 } REGION_FLAGS;
00115 
00116 /* Here's how these types work:
00117 
00118    loop: a region inserted around a loop by RAIL
00119    pragma: a region inserted by user pragmas
00120    olimit: a region inserted by the olimit heuristic
00121    func_entry: always refers to the enclosing func_entry
00122 
00123    The BE driver iterator can be taught to look for loop/func_entries
00124    or normal/func_entries. Func_entry is always recognized. No type can
00125    be zero - it messes up the logic.
00126 */
00127 typedef enum {
00128   RID_TYPE_undefined  = 0x00,  /* initialized value                          */
00129   RID_TYPE_func_entry = 0x01,  /* root RID for PU associated w/func_entry    */
00130   RID_TYPE_loop       = 0x02,  /* it's a loop (RAIL)                         */
00131   RID_TYPE_pragma     = 0x04,  /* it's an arbitrary region                   */
00132   RID_TYPE_olimit     = 0x08,  /* it's an arbitrary region                   */
00133   RID_TYPE_mp         = 0x10,  /* it's a MP region (transparent)             */
00134   RID_TYPE_rpi        = 0x20,  /* it's a RPI region                          */
00135   RID_TYPE_cold       = 0x40,  /* it's a cold region (transparent)           */
00136   RID_TYPE_swp        = 0x80,  /* it's a SWP loop (transparent)              */
00137 
00138   RID_TYPE_eh           = 0x3f000, /* EH region mask (all EH are transparent)*/
00139   RID_TYPE_try          = 0x01000, /* it's a try-block                       */
00140   RID_TYPE_cleanup      = 0x02000, /* it's a cleanup region                  */
00141   RID_TYPE_exc_spec     = 0x04000, /* it's an exception specification region */
00142   RID_TYPE_mask         = 0x08000, /* it's an EH mask region                 */
00143   RID_TYPE_guard        = 0x10000, /* it's an EH guard region                */
00144   RID_TYPE_null_cleanup = 0x20000  /* it's a cleanup region to be deleted    */
00145 } RID_TYPE;
00146 
00147 /* debug flags for regions */
00148 typedef enum {
00149   TT_REGION_USER_DEBUG =        0x0001,
00150   TT_REGION_LARGE_PU_DEBUG =    0x0002,
00151   TT_REGION_LARGE_PU_OFF =      0x0004,
00152   TT_REGION_RGN_INIT_DEBUG =    0x0008,
00153   TT_REGION_LNO_DEBUG =         0x0010,
00154   TT_REGION_RAIL_DEBUG =        0x0020,
00155   TT_REGION_RBI_DEBUG =         0x0040,
00156   TT_REGION_WOPT_DEBUG =        0x0080,
00157   TT_REGION_CG_DEBUG =          0x0100,
00158   TT_REGION_BOUND_DEBUG =       0x0200,
00159   TT_REGION_ALL =               0xffffffff
00160 } REGION_DEBUG_FLAGS;
00161 
00162 /* Flag to tell us whether the boundary info is just NULL or really
00163    doesn't exist. This is used by Preopt to tell if it should be
00164    conservative or not in it's analysis. */
00165 typedef enum {
00166   REGION_BOUND_UNKNOWN = FALSE,
00167   REGION_BOUND_EXISTS = TRUE
00168 } REGION_BOUND_EXIST;
00169 
00170 /* Flag to tell us whether region has any return statements in it.
00171    This is useful once the region is black for building CFGs - you
00172    need to know if this region can exit the PU. */
00173 typedef enum {
00174   REGION_NO_RETURN = FALSE,
00175   REGION_RETURN = TRUE
00176 } REGION_RETURN_ENUM;
00177 
00178 typedef union region_flags_union {
00179   UINT32 flags;
00180   struct region_flags_struct rfs;
00181 } URFLAG;
00182 
00183 /* RID_Create should assign a new id, this has to be an invalid RID id */
00184 #define RID_CREATE_NEW_ID       -1
00185 
00186 #define URFLAG_flags(r)          ((r).flags)
00187 #define URFLAG_clear(r)         ( (r).flags = 0 )
00188 #define URFLAG_rfs(r)            ((r).rfs)
00189 #define URFLAG_level(r)          ((r).rfs.level)
00190 #define URFLAG_type(r)           ((r).rfs.type)
00191 #define URFLAG_gra_flags(r)      ((r).rfs.gra_flags)
00192 #define URFLAG_return_flag(r)    ((r).rfs.return_flag)
00193 #define URFLAG_glue_code_flag(r) ((r).rfs.glue_code_flag)
00194 #define URFLAG_contains_black(r) ((r).rfs.contains_black)
00195 #define URFLAG_contains_bounds(r) ((r).rfs.contains_bounds)
00196 #define URFLAG_bounds_exist(r)   ((r).rfs.bounds_exist)
00197 #define URFLAG_aliased_to_globals(r) ((r).rfs.aliased_to_globals)
00198 #define URFLAG_aliased_to_indirects(r) ((r).rfs.aliased_to_indirects)
00199 #define URFLAG_contains_uplevel(r) ((r).rfs.contains_uplevel)
00200 #define URFLAG_contains_barrier(r) ((r).rfs.contains_barrier)
00201 
00202 typedef struct points_to_ref {
00203   POINTS_TO            *Pt;
00204   struct points_to_ref *Next;
00205 } POINTS_TO_SET;
00206 
00207 struct EH_RANGE;
00208 
00209 /* RID */
00210 typedef struct region_id {
00211   INT id;               /* unique identifier, first in struct so that   */
00212                         /* refs don't require offsets                   */
00213   RID_TYPE rid_type;    /* type, 1:1 mapping to WHIRL region kind       */
00214   INT depth;            /* region nesting depth                         */
00215                         /* right now this is used for the loop level    */
00216   SRCPOS srcpos;        /* linenum for start of the original SCF,       */
00217                         /* may be NULL                                  */
00218   UINT32 flags;         /* includes WHIRL level                         */
00219   struct cgrin *cginfo; /* points to info for CG                        */
00220   INT32 num_exits;      /* number of exits from the region;             */
00221                         /* this is WN_num_entries                       */
00222   /* boundary sets                                                      */
00223   PREG_LIST *pregs_in;
00224   PREG_LIST **pregs_out;/* those pregs which are live and defreach      */
00225                         /* at each exit. If num_exits > 1, these lists  */
00226                         /* are in 1-1 correspondence with the exits in  */
00227                         /* kid1 of the rwn, i.e. the first list         */
00228                         /* corresponds to the first goto target, etc.   */
00229   PREG_LIST *pregs_quad; /* tells which pregs are quads (FQ)            */
00230   PREG_LIST *pregs_complex_quad; /* tells which pregs are complex quads (CQ) */
00231   POINTS_TO_SET *used_in;
00232   POINTS_TO_SET *def_in_live_out;
00233 
00234   char *options;        /* options to compile this region with          */
00235 
00236   WN *rwn;              /* The WHIRL node.  This field should be        */
00237                         /* cleared if the WN is deleted                 */
00238 
00239   WN *parent_block;     /* The WHIRL parent block that contains this    */
00240                         /* region, used by the driver to replace a      */
00241                         /* region once it has been processed.           */
00242 
00243   struct region_id *parent;     /* Parent, first_kid, and next          */
00244   struct region_id *first_kid;  /* allow traversal of the tree of       */
00245   struct region_id *next;       /* RIDs                                 */
00246 
00247   LOWER_ACTIONS lowered; /* lowerer actions already applied to region   */
00248   struct EH_RANGE  *eh_range_ptr; /* pointer to current EH range        */
00249 
00250 } RID;
00251 
00252 /* RID access macros */
00253 #define RID_id(r)               ((r)->id)
00254 #define RID_depth(r)            ((r)->depth)
00255 #define RID_srcpos(r)           ((r)->srcpos)
00256 #define RID_flags(r)            ((r)->flags)
00257 #define RID_cginfo(r)           ((r)->cginfo)
00258 #define RID_num_exits(r)        ((r)->num_exits)
00259 #define RID_options(r)          ((r)->options)
00260 #define RID_rwn(r)              ((r)->rwn)
00261 #define RID_parent(r)           ((r)->parent)
00262 #define RID_parent_block(r)     ((r)->parent_block)
00263 #define RID_first_kid(r)        ((r)->first_kid)
00264 #define RID_next(r)             ((r)->next)
00265 #define RID_rloop(r)            ((r)->rloop)
00266 #define RID_lowered(r)          ((r)->lowered)
00267 #define RID_eh_range_ptr(r)     ((r)->eh_range_ptr)
00268 #define RID_type(r)             ((r)->rid_type)
00269 
00270 /* flag macros */
00271 #define RID_level(r)         (URFLAG_level(*((URFLAG *)(&RID_flags(r)))))
00272 #define RID_gra_flags(r)     (URFLAG_gra_flags(*((URFLAG *)(&RID_flags(r)))))
00273 #define RID_has_return(r)    (URFLAG_return_flag(*((URFLAG *)(&RID_flags(r)))))
00274 #define RID_is_glue_code(r)  (URFLAG_glue_code_flag(*((URFLAG *)(&RID_flags(r)))))
00275 #define RID_contains_black(r)  (URFLAG_contains_black(*((URFLAG *)(&RID_flags(r)))))
00276 #define RID_contains_bounds(r)  (URFLAG_contains_bounds(*((URFLAG *)(&RID_flags(r)))))
00277 #define RID_bounds_exist(r)  (URFLAG_bounds_exist(*((URFLAG *)(&RID_flags(r)))))
00278 #define RID_aliased_to_globals(r)  (URFLAG_aliased_to_globals(*((URFLAG *)(&RID_flags(r)))))
00279 #define RID_aliased_to_indirects(r)  (URFLAG_aliased_to_indirects(*((URFLAG *)(&RID_flags(r)))))
00280 #define RID_contains_uplevel(r)  (URFLAG_contains_uplevel(*((URFLAG *)(&RID_flags(r)))))
00281 #define RID_contains_barrier(r)  (URFLAG_contains_barrier(*((URFLAG *)(&RID_flags(r)))))
00282 
00283 /* boundary set macros */
00284 #define RID_pregs_in(r)      ((r)->pregs_in)
00285 #define RID_pregs_quad(r)    ((r)->pregs_quad)
00286 #define RID_pregs_complex_quad(r)    ((r)->pregs_complex_quad)
00287 #define RID_pregs_out(r)     ((r)->pregs_out)
00288 #define RID_pregs_out_i(r,i) (((r)->pregs_out)?(((r)->pregs_out)[(i)]):((PREG_LIST *)NULL))
00289 #define RID_pregs_set_out_i(r,i) (((r)->pregs_out)[(i)])
00290 #define RID_used_in(r)       ((r)->used_in)
00291 #define RID_def_in_live_out(r)       ((r)->def_in_live_out)
00292 
00293 /* CG macros */
00294 #define RID_has_reg_alloc(r)        (RID_gra_flags(r) & RID_FLAGS_has_reg_alloc)
00295 #define RID_has_reg_alloc_Set(r)    (RID_gra_flags(r) |= RID_FLAGS_has_reg_alloc) 
00296 #define RID_has_reg_alloc_Reset(r)  (RID_gra_flags(r) &= ~RID_FLAGS_has_reg_alloc) 
00297 #define RID_was_gra(r)              (RID_gra_flags(r) & RID_FLAGS_was_gra)
00298 #define RID_was_gra_Set(r)          (RID_gra_flags(r) |= RID_FLAGS_was_gra) 
00299 #define RID_was_gra__Reset(r)       (RID_gra_flags(r) &= ~RID_FLAGS_was_gra) 
00300 
00301 /* RID type macros */
00302 #define RID_TYPE_func_entry(r)       (RID_type(r) & RID_TYPE_func_entry)
00303 #define RID_TYPE_func_entry_Set(r)   (RID_type(r) = \
00304                                      (RID_TYPE)(RID_type(r) | RID_TYPE_func_entry)) 
00305 #define RID_TYPE_func_entry_Reset(r) (RID_type(r) = \
00306                                      (RID_TYPE)(RID_type(r) & ~RID_TYPE_func_entry))
00307 
00308 #define RID_TYPE_loop(r)             (RID_type(r) & RID_TYPE_loop)
00309 #define RID_TYPE_loop_Set(r)         (RID_type(r) = \
00310                                      (RID_TYPE)(RID_type(r) | RID_TYPE_loop))
00311 #define RID_TYPE_loop_Reset(r)       (RID_type(r) = \
00312                                      (RID_TYPE)(RID_type(r) & ~RID_TYPE_loop))
00313 
00314 #define RID_TYPE_pragma(r)           (RID_type(r) & RID_TYPE_pragma)
00315 #define RID_TYPE_pragma_Set(r)       (RID_type(r) = \
00316                                      (RID_TYPE)(RID_type(r) | RID_TYPE_pragma))
00317 #define RID_TYPE_pragma_Reset(r)     (RID_type(r) = \
00318                                      (RID_TYPE)(RID_type(r) & ~RID_TYPE_pragma))
00319 
00320 #define RID_TYPE_olimit(r)           (RID_type(r) & RID_TYPE_olimit)
00321 #define RID_TYPE_olimit_Set(r)       (RID_type(r) = \
00322                                      (RID_TYPE)(RID_type(r) | RID_TYPE_olimit))
00323 #define RID_TYPE_olimit_Reset(r)     (RID_type(r) = \
00324                                      (RID_TYPE)(RID_type(r) & ~RID_TYPE_olimit))
00325 
00326 #define RID_TYPE_mp(r)               (RID_type(r) & RID_TYPE_mp)
00327 #define RID_TYPE_mp_Set(r)           (RID_type(r) = \
00328                                      (RID_TYPE)(RID_type(r) | RID_TYPE_mp))
00329 #define RID_TYPE_mp_Reset(r)         (RID_type(r) = \
00330                                      (RID_TYPE)(RID_type(r) & ~RID_TYPE_mp))
00331 
00332 #define RID_TYPE_rpi(r)              (RID_type(r) & RID_TYPE_rpi)
00333 #define RID_TYPE_rpi_Set(r)          (RID_type(r) = \
00334                                      (RID_TYPE)(RID_type(r) | RID_TYPE_rpi))
00335 #define RID_TYPE_rpi_Reset(r)        (RID_type(r) = \
00336                                      (RID_TYPE)(RID_type(r) & ~RID_TYPE_rpi))
00337 
00338 #define RID_TYPE_cold(r)             (RID_type(r) & RID_TYPE_cold)
00339 #define RID_TYPE_cold_Set(r)         (RID_type(r) = \
00340                                      (RID_TYPE)(RID_type(r) | RID_TYPE_cold))
00341 #define RID_TYPE_cold_Reset(r)       (RID_type(r) = \
00342                                      (RID_TYPE)(RID_type(r) & ~RID_TYPE_cold))
00343 
00344 #define RID_TYPE_swp(r)              (RID_type(r) & RID_TYPE_swp)
00345 #define RID_TYPE_swp_Set(r)          (RID_type(r) = \
00346                                      (RID_TYPE)(RID_type(r) | RID_TYPE_swp))
00347 #define RID_TYPE_swp_Reset(r)        (RID_type(r) = \
00348                                      (RID_TYPE)(RID_type(r) & ~RID_TYPE_swp))
00349 
00350 #define RID_TYPE_eh(r)               (RID_type(r) & RID_TYPE_eh)
00351 /* makes no sense to have set for EH, it is a mask */
00352 
00353 #define RID_TYPE_try(r)              (RID_type(r) & RID_TYPE_try)
00354 #define RID_TYPE_try_Set(r)          (RID_type(r) = \
00355                                      (RID_TYPE)(RID_type(r) | RID_TYPE_try))
00356 #define RID_TYPE_try_Reset(r)        (RID_type(r) = \
00357                                      (RID_TYPE)(RID_type(r) & ~RID_TYPE_try))
00358 
00359 #define RID_TYPE_cleanup(r)          (RID_type(r) & RID_TYPE_cleanup)
00360 #define RID_TYPE_cleanup_Set(r)      (RID_type(r) = \
00361                                      (RID_TYPE)(RID_type(r) | RID_TYPE_cleanup))
00362 #define RID_TYPE_cleanup_Reset(r)    (RID_type(r) = \
00363                                      (RID_TYPE)(RID_type(r) & ~RID_TYPE_cleanup))
00364 
00365 #define RID_TYPE_exc_spec(r)         (RID_type(r) & RID_TYPE_exc_spec)
00366 #define RID_TYPE_exc_spec_Set(r)     (RID_type(r) = \
00367                                      (RID_TYPE)(RID_type(r) | RID_TYPE_exc_spec))
00368 #define RID_TYPE_exc_spec_Reset(r)   (RID_type(r) = \
00369                                      (RID_TYPE)(RID_type(r) & ~RID_TYPE_exc_spec))
00370 
00371 #define RID_TYPE_mask(r)             (RID_type(r) & RID_TYPE_mask)
00372 #define RID_TYPE_mask_Set(r)         (RID_type(r) = \
00373                                      (RID_TYPE)(RID_type(r) | RID_TYPE_mask))
00374 #define RID_TYPE_mask_Reset(r)       (RID_type(r) = \
00375                                      (RID_TYPE)(RID_type(r) & ~RID_TYPE_mask))
00376 
00377 #define RID_TYPE_guard(r)             (RID_type(r) & RID_TYPE_guard)
00378 #define RID_TYPE_guard_Set(r)         (RID_type(r) = \
00379                                      (RID_TYPE)(RID_type(r) | RID_TYPE_guard))
00380 #define RID_TYPE_guard_Reset(r)       (RID_type(r) = \
00381                                      (RID_TYPE)(RID_type(r) & ~RID_TYPE_guard))
00382 
00383 #define RID_TYPE_null_cleanup(r)             (RID_type(r) & RID_TYPE_null_cleanup)
00384 #define RID_TYPE_null_cleanup_Set(r)         (RID_type(r) = \
00385                                      (RID_TYPE)(RID_type(r) | RID_TYPE_null_cleanup))
00386 #define RID_TYPE_null_cleanup_Reset(r)       (RID_type(r) = \
00387                                      (RID_TYPE)(RID_type(r) & ~RID_TYPE_guard))
00388 
00389 /* transparent regions (no boundary): PU, EH, MP, SWP, cold */
00390 #define RID_TYPE_transparent(r) (   RID_TYPE_func_entry(r) \
00391                                  || RID_TYPE_mp(r) \
00392                                  || RID_TYPE_eh(r) \
00393                                  || RID_TYPE_swp(r) \
00394                                  || RID_TYPE_cold(r))
00395 
00396 
00397 /* RID tree iterator */
00398 /* the type tells what loop we are doing:
00399    loop/func_entry: regions introduced by RAIL, loop around MainOpt/CG
00400    pragma/olimit/func_entry: regions introduced by user pragmas or Olimit
00401                         heuristic, loop around LNO/MainOpt/CG
00402  */
00403 #define REGION_STACK_SIZE 10
00404 typedef struct region_cs_iter {
00405   RID    *me;
00406   RID    *kid;
00407   RID_TYPE type;        /* type of region to loop through with iterator    */
00408   WN *parent_block;     /* block enclosing the region */
00409   WN *region_marker[REGION_STACK_SIZE]; /* mark where code was */
00410   INT32 region_marker_sp;
00411   BOOL   is_pu;         /* region is an actual PU */
00412   BOOL   is_not_stacked;/* region is not stacked (PU or same as outer loop) */
00413 } REGION_CS_ITER;
00414 
00415 #define REGION_CS_ITER_me(i)                    ((i)->me)
00416 #define REGION_CS_ITER_kid(i)                   ((i)->kid)
00417 #define REGION_CS_ITER_type(i)                  ((i)->type)
00418 #define REGION_CS_ITER_parent_block(i)          ((i)->parent_block)
00419 #define REGION_CS_ITER_sp(i)                    ((i)->region_marker_sp)
00420 #define REGION_CS_ITER_marker(i,j)              ((i)->region_marker[j])
00421 #define REGION_CS_ITER_is_pu(i)                 ((i)->is_pu)
00422 #define REGION_CS_ITER_is_not_stacked(i)        ((i)->is_not_stacked)
00423 #define REGION_CS_ITER_wn(i)                    (RID_rwn((i)->kid))
00424 
00425 /*--------------------------------------------------------------------------*/
00426 /* These variables are live across entire back end      */
00427 extern WN_MAP RID_map;
00428 extern MEM_POOL REGION_mem_pool;
00429 
00430 /* latest region id, defined in common/com/wn.c */
00431 extern INT32 New_Region_Id(void);
00432 extern INT32 Last_Region_Id(void);
00433 
00434 /* Replace the old WN tree with a new one and update the RID pointers */
00435 extern void REGION_new_wn(WN *, WN *);
00436 
00437 /* Make sure RID and WN map are consistent */
00438 extern BOOL REGION_consistency_check(WN *);
00439 
00440 /* Update alias information for glue code */
00441 extern void REGION_update_alias_info(WN *, struct ALIAS_MANAGER *);
00442 
00443 /* Get the RID from the WN map */
00444 extern RID *REGION_get_rid(const WN *);
00445 
00446 /* Given a WN *, find the RID tree root WN which is the PU */
00447 extern WN *REGION_find_pu(WN *);
00448 
00449 /* Given a RID that will be processed to black, mark the root RID */
00450 extern BOOL REGION_has_black_regions(RID *);
00451 
00452 /* Set the region_level for this RID and all its children */
00453 extern void REGION_set_level(RID *, REGION_LEVEL);
00454 
00455 /* count the exits in the exit block of a region */
00456 extern BOOL REGION_count_exits(WN *);
00457 
00458 /* recount exits, fix up any boundary sets that have changed */
00459 extern void REGION_fix_up_exits(RID *, WN *);
00460 
00461 /* look at all exit block between two rids and find a given label number */
00462 extern BOOL REGION_scan_exits(WN *, INT32);
00463 
00464 /* Allocate a RID from the REGION_mem_pool and fill in the fields with
00465    the id (or RID_CREATE_NEW_ID) and appropriate map values from the wn.
00466    If wn is NULL, fill in reasonable default values. */
00467 extern RID *RID_Create(INT, INT, WN *);
00468 
00469 /* Given two RIDs make the first the kid of the second */
00470 extern void RID_Add_kid(RID *, RID *);
00471 
00472 /* Remove a RID from the RID tree */
00473 extern void RID_unlink(RID *);
00474 
00475 /* Replace old_rid with new_rid */
00476 extern void RID_replace(RID *old_rid, RID *new_rid);
00477 
00478 /* delete a RID from the tree */
00479 extern void RID_Delete(WN_MAP_TAB *, WN *);
00480 extern void RID_Delete2(RID *);
00481 
00482 /* clone a RID and connect into tree */
00483 extern void REGION_clone(WN *, WN *, WN *);
00484 
00485 /* reattach a RID and WN, update the level and last preg */
00486 extern void REGION_emit(RID *, WN *, INT32, INT32, INT64);
00487 
00488 /* copy in and out sets from one rid to another */
00489 extern void RID_copy_sets(RID *, RID *);
00490 
00491 /* find the RID level for Preopt (it's called so many places) */
00492 extern REGION_LEVEL RID_preopt_level(INT);
00493 
00494 /* search a boundary set for a given PREG */
00495 extern BOOL REGION_search_preg_set(PREG_LIST *, PREG_NUM);
00496 
00497 /* create a POINTS_TO for the wn given and add it to the list given */
00498 extern void REGION_add_wn_points_to(POINTS_TO_SET **, WN *,
00499                                  struct ALIAS_MANAGER *);
00500 
00501 /* add a POINTS_TO to the list given, similar to REGION_add_wn_points_to */
00502 extern void REGION_add_points_to(POINTS_TO_SET **, POINTS_TO *,
00503                                  struct ALIAS_MANAGER *);
00504 
00505 /* allocate from a specific pool and copy a points_to into it */
00506 extern POINTS_TO *Points_to_copy(POINTS_TO *, MEM_POOL *);
00507 
00508 extern void Get_symbol_info_for_cvt_io(POINTS_TO *, WN *);
00509                         /* in opt_sym.cxx */
00510 extern POINTS_TO *Points_to(struct ALIAS_MANAGER *, WN *);
00511                         /* in opt_alias_mgr.cxx */
00512 
00513 /* add a PREG to either the pregs_in or pregs_out lists (pregs_quad also) */
00514 extern BOOL REGION_add_preg_in(RID *rid, PREG_NUM pr, TYPE_ID quad);
00515 extern BOOL REGION_add_preg_out(RID *rid, INT32 which_set, PREG_NUM pr,
00516                                 TYPE_ID quad);
00517 
00518 /* remove a PREG from either the pregs_in or ALL the pregs_out sets */
00519 /* does quad also */
00520 extern BOOL REGION_remove_preg(RID *rid, PREG_NUM pr, BOOL outset);
00521 
00522 /* add a label after the region and the OPC_REGION_EXIT at the end */
00523 extern WN *REGION_add_exit(WN *, WN *, WN *);
00524 
00525 /* delete a region exit from the exit block and decrement RID_num_exits */
00526 extern void REGION_delete_exit(RID *, INT32, WN *, BOOL);
00527 
00528 /* Find the options pragma for the PU or region */
00529 extern char *REGION_get_options_string(WN *);
00530 
00531 /* tell if a region is an EH region based on WHIRL kind */
00532 extern BOOL REGION_is_EH(WN *);
00533 
00534 /* tell if a region is an MP region based on WHIRL pragmas */
00535 extern BOOL REGION_is_mp(WN *);
00536 
00537 /* tell if a region is an EH region based on WHIRL kind */
00538 extern BOOL REGION_is_EH(WN *);
00539 
00540 /* tell if a call is a fake call (inside the pragma part of an EH region) */
00541 extern BOOL WN_Fake_Call_EH_Region(WN *,WN_MAP);
00542 
00543 
00544 /* convert from RID_TYPE_* to REGION_KIND_* (common/com/wn_core.h) */
00545 extern REGION_KIND REGION_type_to_kind(RID *);
00546 
00547 /* convert from REGION_KIND_* to RID_TYPE_* */
00548 extern void REGION_kind_to_type(WN *, RID *);
00549 
00550 /* set REGION_RETURN bit on current RID and propagate up to parent */
00551 extern void REGION_propagate_return(RID *);
00552 
00553 /* return the text for the level this RID is compiled to */
00554 extern char *RID_level_str(RID *rid);
00555 
00556 /* return text for RID type */
00557 extern char *RID_type_str(RID_TYPE type);
00558 
00559 /* Print: pregs_in, pregs_out, pregs_quad,      */
00560 /* used_in, def_in_live_out */
00561 extern void RID_set_print(FILE *, RID *);
00562 /* this is defined in opt_alias_analysis.cxx and exported from wopt.so */
00563 extern void Print_points_to(FILE *, POINTS_TO *);
00564 
00565 /* Print the given region_id to file */
00566 extern void RID_Fprint(FILE *, RID *);
00567 
00568 /* Print the tree of RIDs rooted at rid to TFile */
00569 extern void RID_Tree_Print(FILE *, RID *);
00570 
00571 /* Print the tree of RIDs rooted at the RID of the given WN to TFile */
00572 extern void RID_WN_Tree_Print(FILE *, WN *);
00573 
00574 #ifdef __cplusplus
00575 }
00576 #endif
00577 
00578 #endif /* region_util_INCLUDED */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines