Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
callutil.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 #ifndef callutil_INCLUDED
00037 #define callutil_INCLUDED
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif
00041 
00042 
00043 /* ====================================================================
00044  * ====================================================================
00045  *
00046  *
00047  * Revision history:
00048  *  07-Jun-92 - Original Version (extracted from stab.h)
00049  *
00050  * Description:
00051  *
00052  * This module contains the external interfaces (data structures and
00053  * prototypes) for routines which provide utility services related to
00054  * calls, entries, and returns.
00055  *
00056  * ====================================================================
00057  * ====================================================================
00058  */
00059 
00060 #ifdef _KEEP_RCS_ID
00061 #endif /* _KEEP_RCS_ID */
00062 
00063 /* Incomplete types to keep ANSI happy: */
00064 struct arg_copy_list;   /* see irbcall.c */
00065 struct bb;
00066 struct einfo;
00067 struct fld;
00068 struct insch;
00069 struct nd;
00070 struct st;
00071 struct stch;
00072 struct ty;
00073 #ifdef BACK_END
00074 struct op;
00075 #endif /* BACK_END */
00076 
00077 #ifdef OLDCODE
00078 /* Methods for returning a function result value: */
00079 typedef enum {
00080   RSTYLE_NONE,          /* no result */
00081   RSTYLE_REG,           /* in one TN */
00082   RSTYLE_REG_PAIR,      /* in two TNs */
00083   RSTYLE_VIA_FIRST_ARG, /* caller passes buffer address as first arg */
00084   RSTYLE_VIA_RETURN_ARG,
00085   RSTYLE_INT_REGS,
00086   RSTYLE_FLOAT_REGS,
00087   RSTYLE_VIA_COMMON_BUF, /* callee puts value in a common buffer */
00088   RSTYLE_VIA_LOCAL_BUF  /* callee returns address of local buf */
00089 } RSTYLE;
00090 
00091 /* How should a function result be returned?  These routines are
00092  * (potentially) language-specific, and therefore restricted to the
00093  * front ends.
00094  */
00095 #ifdef FRONT_END
00096   extern RSTYLE How_To_Return ( struct ty * );
00097 #ifdef OLDCODE
00098   /* In FEs' aux_misc.c: */
00099   extern RSTYLE How_To_Return_Type ( struct ty *, struct nd * );
00100 #endif /* OLDCODE */
00101 #endif
00102 #endif /* OLDCODE */
00103 
00104 /* Return the TN for the return address: */
00105 extern struct tn * Get_Return_Address_TN
00106                         ( struct bb *bb, BOOL gen_load );
00107 
00108 /* Find the adjustment of the given TN (usually SP_TN) in the entry
00109  * or exit code (bounded by BB_entry_sp_adj_.../BB_exit_sp_adj_...).
00110  */
00111 extern struct insch * Find_Entry_TN_Adjustment_INSCH
00112                         ( struct bb *bb, struct tn *mod_tn );
00113 extern struct insch * Find_Exit_TN_Adjustment_INSCH
00114                         ( struct bb *bb, struct tn *mod_tn );
00115 #ifdef BACK_END
00116 extern struct op * Find_Entry_TN_Adjustment_OP
00117                         ( struct bb *bb, struct tn *mod_tn );
00118 extern struct op * Find_Exit_TN_Adjustment_OP
00119                         ( struct bb *bb, struct tn *mod_tn );
00120 #endif /* BACK_END */
00121 
00122 /* Mark an ST as referenced by a nested subprogram: */
00123 extern void Mark_Nested_Reference ( struct st *st );
00124 
00125 /* ====================================================================
00126  *
00127  * ARG_TY_LIST
00128  *
00129  * This structure provides the interface to the function
00130  * Calc_Arg_Offsets which calculates offsets of arguments.
00131  *
00132  * It is used for finding offsets (TNs) both of formals and of actuals.
00133  *
00134  * ====================================================================
00135  */
00136 
00137 #ifdef FRONT_END_FORTRAN
00138 /* Various treatment styles for multiple-entry formal parameters: */
00139 typedef enum {
00140   FSTYLE_NONE,          /* Not yet determined */
00141   FSTYLE_NOMOVE,        /* No movement required */
00142   FSTYLE_RADICAL,       /* Move to radical copied formal */
00143   FSTYLE_MEMORY         /* Move to memory copied formal */
00144 } FSTYLE;
00145 #endif /* FRONT_END_FORTRAN */
00146 
00147 /* Each argument may consist of a number of components (normally one,
00148  * except for struct/class arguments):
00149  */
00150 typedef struct arg_ty_comp {
00151   struct arg_ty_comp * next;    /* Next in list */
00152   struct ty * ctype;    /* Component type */
00153   INTSC  csize;         /* Component size */
00154   struct nd * cnd;      /* Node for accessing component */
00155   struct tn * tn;       /* TN for component (i.e. parm register) */
00156   struct tn * tn_val;   /* TN where component is loaded (for call) */
00157   INTSC mem_ofst;       /* Memory offset for component if in memory */
00158   INT16 parm_reg;       /* Parameter register to use if in register */
00159   TOP op_store;         /* Store operation to use if in register */
00160   TOP op_copy;          /* Copy operation to use if in register */
00161 } ARG_TY_COMP;
00162 
00163 /* ATC field access macros: */
00164 #define ATC_next(a)     ((a)->next)
00165 #define ATC_ctype(a)    ((a)->ctype)
00166 #define ATC_csize(a)    ((a)->csize)
00167 #define ATC_cnd(a)      ((a)->cnd)
00168 #define ATC_cnd(a)      ((a)->cnd)
00169 #define ATC_tn(a)       ((a)->tn)
00170 #define ATC_tn_val(a)   ((a)->tn_val)
00171 #define ATC_mem_ofst(a) ((a)->mem_ofst)
00172 #define ATC_parm_reg(a) ((a)->parm_reg)
00173 #define ATC_op_store(a) ((a)->op_store)
00174 #define ATC_op_copy(a)  ((a)->op_copy )
00175 
00176 /* An argument type list contains information about the full parameter,
00177  * and the first element of a list of components.  We handle such lists
00178  * as an array, so there is no explicit list link.
00179  */
00180 typedef struct arg_ty_list {
00181   struct st *sym;       /* Formal parameter symbol (NULL for calls) */
00182   struct ty *type;      /* Parameter type */
00183   struct nd * pnd;      /* Parameter node */
00184   ARG_TY_COMP atc;      /* First (usually only) component */
00185   mINT8 flags;          /* Attributes */
00186   mINT8 fstyle;         /* Multiple-entry formal treatment style */
00187   struct st *cform;     /* Copied formal symtab entry */
00188   struct einfo *entry;  /* Entry this ATL belongs to */
00189   struct arg_copy_list *copies; /* Head of copies list */
00190   struct arg_ty_list *next_copy;        /* Next copy in list */
00191 } ARG_TY_LIST;
00192 
00193 /* Attribute flag masks: */
00194 #define ATL_IS_REF      0x01    /* Reference parameter */
00195 #define ATL_IS_IN_TN    0x02    /* Argument is in TN (register) */
00196 #define ATL_ON_COPIES   0x04    /* Argument is on copy list ... */
00197 #define ATL_IS_VARARGS  0x08    /* Argument is from varargs ... */
00198 #define ATL_DUP_FLOAT   0x10    /* Duplicate float varargs argument ... */
00199 
00200 /* ATL field access macros: */
00201 #define ATL_next(a)     ((a)+1)
00202 #define ATL_sym(a)      ((a)->sym)
00203 #define ATL_type(a)     ((a)->type)
00204 #define ATL_pnd(a)      ((a)->pnd)
00205 #define ATL_atc(a)      (&((a)->atc))
00206 # define ATL_ctype(a)    (ATC_ctype(ATL_atc(a)))
00207 # define ATL_csize(a)    (ATC_csize(ATL_atc(a)))
00208 # define ATL_cnd(a)      (ATC_cnd(ATL_atc(a)))
00209 # define ATL_tn(a)       (ATC_tn(ATL_atc(a)))
00210 # define ATL_tn_val(a)   (ATC_tn_val(ATL_atc(a)))
00211 # define ATL_mem_ofst(a) (ATC_mem_ofst(ATL_atc(a)))
00212 # define ATL_parm_reg(a) (ATC_parm_reg(ATL_atc(a)))
00213 # define ATL_op_store(a) (ATC_op_store(ATL_atc(a)))
00214 # define ATL_op_copy(a)  (ATC_op_copy(ATL_atc(a)))
00215 #define ATL_flags(a)    ((a)->flags)
00216 #define ATL_fstyle(a)   ((a)->fstyle)
00217 #define ATL_cform(a)    ((a)->cform)
00218 #define ATL_entry(a)    ((a)->entry)
00219 #define ATL_copies(a)   ((a)->copies)
00220 #define ATL_next_copy(a) ((a)->next_copy)
00221 
00222 #define ATL_is_ref(a)           (ATL_flags(a) & ATL_IS_REF)
00223 #define Set_ATL_is_ref(a)       (ATL_flags(a) |= ATL_IS_REF)
00224 #define Reset_ATL_is_ref(a)     (ATL_flags(a) &= ~ATL_IS_REF)
00225 #define ATL_is_in_tn(a)         (ATL_flags(a) & ATL_IS_IN_TN)
00226 #define Set_ATL_is_in_tn(a)     (ATL_flags(a) |= ATL_IS_IN_TN)
00227 #define Reset_ATL_is_in_tn(a)   (ATL_flags(a) &= ~ATL_IS_IN_TN)
00228 #define ATL_on_copies(a)        (ATL_flags(a) & ATL_ON_COPIES)
00229 #define Set_ATL_on_copies(a)    (ATL_flags(a) |= ATL_ON_COPIES)
00230 #define Reset_ATL_on_copies(a)  (ATL_flags(a) &= ~ATL_ON_COPIES)
00231 #define ATL_is_varargs(a)       (ATL_flags(a) & ATL_IS_VARARGS)
00232 #define Set_ATL_is_varargs(a)   (ATL_flags(a) |= ATL_IS_VARARGS)
00233 #define ATL_dup_float(a)        (ATL_flags(a) & ATL_DUP_FLOAT)
00234 #define Set_ATL_dup_float(a)    (ATL_flags(a) |= ATL_DUP_FLOAT)
00235 
00236 /* --------------------------------------------------------------------
00237  * Subprogram call utilities.
00238  * --------------------------------------------------------------------
00239  */
00240 
00241 /* Determine whether two fields in a KIND_STRUCT overlap. */
00242 BOOL No_Overlap ( struct fld *f1, struct fld *f2 );
00243 
00244 /* Given a node for a PU, identify the type of the routine: */
00245 extern struct ty * Identify_Callee_Type ( struct nd *pu );
00246 
00247 /* What is the actual type of a formal parameter?  Adjust for default
00248  * promotions or reference parameters:
00249  */
00250 extern struct ty * Formal_Parameter_Type ( struct st *parm );
00251 
00252 /* Given a reference formal, construct a symbol representing its base
00253  * address, and convert its addressing to reflect that:
00254  */
00255 extern struct st * Make_Formal_Base_Symbol ( struct st *formal_sym );
00256 
00257 /* The two functions below make an ARG_TY_LIST for the formals
00258  * of a function or for a call. The ARG_TY_LIST is terminated
00259  * by am ARG_TY_LIST record having ATL_ty() == NULL. ATL_is_ref
00260  * is set to TRUE if arg is reference arg.  In this case ATL_type()
00261  * is the dedicated type associated with Pointer_Mtype.  Otherwise
00262  * (for a value parameter), ATL_type gives the type of the value
00263  * parameter. 
00264  *
00265  * These two routines essentially allow use of the single routine
00266  * Calc_Arg_Offsets above to determine the offsets of both formals
00267  * and actuals.
00268  */
00269 extern ARG_TY_LIST *Prepare_Atl_Of_Call ( struct nd *t );
00270 extern ARG_TY_LIST *Prepare_Atl_Of_Formals ( struct nd *t,
00271                                              struct stch *args );
00272 
00273 extern void Trace_ATL ( ARG_TY_LIST *atl );
00274 extern void Trace_ATL_List ( struct nd *t, ARG_TY_LIST *atl );
00275 
00276 #ifdef __cplusplus
00277 }
00278 #endif
00279 #endif /* callutil_INCLUDED */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines