Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
cwh_addr.i
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 OPCODE opc_lda;
00036 OPCODE opc_call;
00037 OPCODE opc_array;
00038 OPCODE opc_section;
00039 OPCODE opc_triplet;
00040 OPCODE opc_src_triplet;  //April
00041 OPCODE opc_pint;
00042 OPCODE opc_sint;
00043 
00044 TYPE_ID   cwh_addr_char_len_typeid;
00045 TYPE_ID   cwh_bound_int_typeid;
00046 TYPE_ID   cwh_doloop_typeid;
00047 
00048 /*
00049 static OPCODE opc_ldid;
00050 static OPCODE opc_pldid;
00051 static OPCODE opc_padd;
00052 static OPCODE opc_pstid;
00053 static OPCODE opc_psub;
00054 static OPCODE  opc_pmpy;
00055 static OPCODE  opc_pdiv;
00056 static OPCODE  opc_psra;
00057 static OPCODE  opc_pload;
00058 static OPCODE  opc_pne;
00059 static OPCODE  opc_ptas;
00060 static OPCODE  opc_reg_sra;
00061 */
00062 
00063 
00064 OPCODE Ldid_Opcode [MTYPE_LAST + 1] = {
00065   OPCODE_UNKNOWN,    /* MTYPE_UNKNOWN */
00066   OPCODE_UNKNOWN,    /* MTYPE_UNKNOWN */
00067   OPC_I4I1LDID,   /* MTYPE_I1 */
00068   OPC_I4I2LDID,   /* MTYPE_I2 */
00069   OPC_I4I4LDID,   /* MTYPE_I4 */
00070   OPC_I8I8LDID,   /* MTYPE_I8 */
00071   OPC_U4U1LDID,   /* MTYPE_U1 */
00072   OPC_U4U2LDID,   /* MTYPE_U2 */
00073   OPC_U4U4LDID,   /* MTYPE_U4 */
00074   OPC_U8U8LDID,   /* MTYPE_U8 */
00075   OPC_F4F4LDID,   /* MTYPE_F4 */
00076   OPC_F8F8LDID,   /* MTYPE_F8 */
00077   OPCODE_UNKNOWN,    /* MTYPE_F10 */
00078   OPCODE_UNKNOWN,    /* MTYPE_F16 */
00079   OPCODE_UNKNOWN,    /* MTYPE_STR */
00080   OPC_FQFQLDID,   /* MTYPE_FQ */
00081   OPC_MMLDID,    /* MTYPE_M */
00082   OPC_C4C4LDID,   /* MTYPE_C4 */
00083   OPC_C8C8LDID,   /* MTYPE_C8 */
00084   OPC_CQCQLDID,   /* MTYPE_CQ */
00085   OPCODE_UNKNOWN     /* MTYPE_V */
00086 };
00087 
00088 OPCODE Stid_Opcode [MTYPE_LAST + 1] = {
00089   OPCODE_UNKNOWN,    /* MTYPE_UNKNOWN */
00090   OPCODE_UNKNOWN,    /* MTYPE_UNKNOWN */
00091   OPC_I1STID,     /* MTYPE_I1 */
00092   OPC_I2STID,     /* MTYPE_I2 */
00093   OPC_I4STID,     /* MTYPE_I4 */
00094   OPC_I8STID,     /* MTYPE_I8 */
00095   OPC_U1STID,     /* MTYPE_U1 */
00096   OPC_U2STID,     /* MTYPE_U2 */
00097   OPC_U4STID,     /* MTYPE_U4 */
00098   OPC_U8STID,     /* MTYPE_U8 */
00099   OPC_F4STID,     /* MTYPE_F4 */
00100   OPC_F8STID,     /* MTYPE_F8 */
00101   OPCODE_UNKNOWN,    /* MTYPE_F10 */
00102   OPCODE_UNKNOWN,    /* MTYPE_F16 */
00103   OPCODE_UNKNOWN,    /* MTYPE_STR */
00104   OPC_FQSTID,     /* MTYPE_FQ */
00105   OPC_MSTID,    /* MTYPE_M */
00106   OPC_C4STID,     /* MTYPE_C4 */
00107   OPC_C8STID,     /* MTYPE_C8 */
00108   OPC_CQSTID,     /* MTYPE_CQ */
00109   OPCODE_UNKNOWN     /* MTYPE_V */
00110 };
00111 
00112 
00113 OPCODE PStid_Opcode [MTYPE_LAST + 1] = {
00114   OPCODE_UNKNOWN,    /* MTYPE_UNKNOWN */
00115   OPCODE_UNKNOWN,    /* MTYPE_UNKNOWN */
00116   OPC_I1PSTID,     /* MTYPE_I1 */
00117   OPC_I2PSTID,     /* MTYPE_I2 */
00118   OPC_I4PSTID,     /* MTYPE_I4 */
00119   OPC_I8PSTID,     /* MTYPE_I8 */
00120   OPC_U1PSTID,     /* MTYPE_U1 */
00121   OPC_U2PSTID,     /* MTYPE_U2 */
00122   OPC_U4PSTID,     /* MTYPE_U4 */
00123   OPC_U8PSTID,     /* MTYPE_U8 */
00124   OPC_F4PSTID,     /* MTYPE_F4 */
00125   OPC_F8PSTID,     /* MTYPE_F8 */
00126   OPCODE_UNKNOWN,    /* MTYPE_F10 */
00127   OPCODE_UNKNOWN,    /* MTYPE_F16 */
00128   OPCODE_UNKNOWN,    /* MTYPE_STR */
00129   OPC_FQPSTID,     /* MTYPE_FQ */
00130   OPC_MPSTID,    /* MTYPE_M */
00131   OPC_C4PSTID,     /* MTYPE_C4 */
00132   OPC_C8PSTID,     /* MTYPE_C8 */
00133   OPC_CQPSTID,     /* MTYPE_CQ */
00134   OPCODE_UNKNOWN     /* MTYPE_V */
00135 };
00136 
00137 
00138 OPCODE Load_Opcode [MTYPE_LAST + 1] = {
00139   OPCODE_UNKNOWN,    /* MTYPE_UNKNOWN */
00140   OPCODE_UNKNOWN,    /* MTYPE_UNKNOWN */
00141   OPC_I4I1ILOAD,  /* MTYPE_I1 */
00142   OPC_I4I2ILOAD,  /* MTYPE_I2 */
00143   OPC_I4I4ILOAD,  /* MTYPE_I4 */
00144   OPC_I8I8ILOAD,  /* MTYPE_I8 */
00145   OPC_U4U1ILOAD,  /* MTYPE_U1 */
00146   OPC_U4U2ILOAD,  /* MTYPE_U2 */
00147   OPC_U4U4ILOAD,  /* MTYPE_U4 */
00148   OPC_U8U8ILOAD,  /* MTYPE_U8 */
00149   OPC_F4F4ILOAD,  /* MTYPE_F4 */
00150   OPC_F8F8ILOAD,  /* MTYPE_F8 */
00151   OPCODE_UNKNOWN,    /* MTYPE_F10 */
00152   OPCODE_UNKNOWN,    /* MTYPE_F16 */
00153   OPCODE_UNKNOWN,    /* MTYPE_STR */
00154   OPC_FQFQILOAD,  /* MTYPE_FQ */
00155   OPC_MMILOAD,    /* MTYPE_M */
00156   OPC_C4C4ILOAD,  /* MTYPE_C4 */
00157   OPC_C8C8ILOAD,  /* MTYPE_C8 */
00158   OPC_CQCQILOAD,  /* MTYPE_CQ */
00159   OPCODE_UNKNOWN     /* MTYPE_V */
00160 };
00161 
00162 
00163 
00164 OPCODE Store_Opcode [MTYPE_LAST + 1] = {
00165   OPCODE_UNKNOWN,    /* MTYPE_UNKNOWN */
00166   OPCODE_UNKNOWN,    /* MTYPE_UNKNOWN */
00167   OPC_I1ISTORE,    /* MTYPE_I1 */
00168   OPC_I2ISTORE,    /* MTYPE_I2 */
00169   OPC_I4ISTORE,    /* MTYPE_I4 */
00170   OPC_I8ISTORE,    /* MTYPE_I8 */
00171   OPC_U1ISTORE,    /* MTYPE_U1 */
00172   OPC_U2ISTORE,    /* MTYPE_U2 */
00173   OPC_U4ISTORE,    /* MTYPE_U4 */
00174   OPC_U8ISTORE,    /* MTYPE_U8 */
00175   OPC_F4ISTORE,    /* MTYPE_F4 */
00176   OPC_F8ISTORE,    /* MTYPE_F8 */
00177   OPCODE_UNKNOWN,    /* MTYPE_F10 */
00178   OPCODE_UNKNOWN,    /* MTYPE_F16 */
00179   OPCODE_UNKNOWN,    /* MTYPE_STR */
00180   OPC_FQISTORE,    /* MTYPE_FQ */
00181   OPC_MISTORE,    /* MTYPE_M */
00182   OPC_C4ISTORE,    /* MTYPE_C4 */
00183   OPC_C8ISTORE,    /* MTYPE_C8 */
00184   OPC_CQISTORE,    /* MTYPE_CQ */
00185   OPCODE_UNKNOWN     /* MTYPE_V */
00186 };
00187 
00188 
00189 
00190 OPCODE PStore_Opcode [MTYPE_LAST + 1] = {
00191   OPCODE_UNKNOWN,    /* MTYPE_UNKNOWN */
00192   OPCODE_UNKNOWN,    /* MTYPE_UNKNOWN */
00193   OPC_I1PSTORE,    /* MTYPE_I1 */
00194   OPC_I2PSTORE,    /* MTYPE_I2 */
00195   OPC_I4PSTORE,    /* MTYPE_I4 */
00196   OPC_I8PSTORE,    /* MTYPE_I8 */
00197   OPC_U1PSTORE,    /* MTYPE_U1 */
00198   OPC_U2PSTORE,    /* MTYPE_U2 */
00199   OPC_U4PSTORE,    /* MTYPE_U4 */
00200   OPC_U8PSTORE,    /* MTYPE_U8 */
00201   OPC_F4PSTORE,    /* MTYPE_F4 */
00202   OPC_F8PSTORE,    /* MTYPE_F8 */
00203   OPCODE_UNKNOWN,    /* MTYPE_F10 */
00204   OPCODE_UNKNOWN,    /* MTYPE_F16 */
00205   OPCODE_UNKNOWN,    /* MTYPE_STR */
00206   OPC_FQPSTORE,    /* MTYPE_FQ */
00207   OPC_MPSTORE,    /* MTYPE_M */
00208   OPC_C4PSTORE,    /* MTYPE_C4 */
00209   OPC_C8PSTORE,    /* MTYPE_C8 */
00210   OPC_CQPSTORE,    /* MTYPE_CQ */
00211   OPCODE_UNKNOWN     /* MTYPE_V */
00212 };
00213 
00214 
00215 /*
00216  * NONCONTIG_BY_DIVIDE determines if we should deal with element size scaling
00217  * by using division (if NONCONTIG_BY_DIVIDE is defined) or by altering the array
00218  * element_size field (if NONCONTIG_BY_DIVIDE is not defined).
00219  * 
00220  * NONCONTIG_BY_ARRAYNC means use the non-contiguous array method.
00221  */
00222 
00223 /* These are used by fei_nseq_subscr */ 
00224 static BOOL may_be_noncontig;
00225 
00226 /* This is used to turn on bounds checking for an access. It is set by 
00227  * fei_subscr_size
00228  */
00229 static BOOL check_bounds_this_access;
00230 
00231 /* test for an offset which doesn't fit in WN_OFFSET */
00232 
00233 #define BIG_OFFSET(off) (off > 0xffffffffLL)
00234 
00235 /* is ST reference in host symbol table? */
00236 #define HOST_ASSOCIATED(st) ((ST_level(st) < CURRENT_SYMTAB) &&   \
00237                              (ST_class(st) == CLASS_VAR)     &&   \
00238                              (ST_has_nested_ref(st)))
00239 
00240 /* is FORMAL passed by value? */
00241 
00242 #define BY_VALUE(t) ((TY_kind(t) == KIND_SCALAR) || \
00243                      ((TY_kind(t) == KIND_POINTER) && (TY_kind(TY_pointed(t)) == KIND_FUNCTION)))
00244 
00245 /* get rank of array section node */
00246 
00247 #define GET_ARRSECTION_RANK(a) ((WN_kid_count(a)-1)/2) ;
00248 
00249 /* loop over axes of OPC_ARRAY/ARRSECTION */
00250 
00251 #define FOREACH_AXIS(i,nk) for(i = 1 ; i <= nk/2 ; i++) 
00252 #define SZ_OFF(rk) 0
00253 #define SUB_OFF(rk) (rk/2)
00254 
00255 /* forward references */
00256 
00257 static WN * cwh_addr_add_bound(WN * ar, WN * sz, WN *sub);
00258 static WN * cwh_addr_array(OPCODE op, WN * ad,  TY_IDX  ty) ;
00259 static WN * cwh_addr_array1(OPCODE op, WN * ad,  TY_IDX  ty,INT32 kidsnum) ;
00260 static WN * cwh_addr_triplet(WN *lb,WN *ub,WN *str) ;
00261 static WN * cwh_addr_src_triplet(WN *lb,WN *ub,WN *str) ;
00262 static WN * cwh_addr_zero_based(WN *sub, WN * lb);
00263 static WN * cwh_addr_do_bounds_check(WN *sb, WN *lb, WN *ex);
00264 static void cwh_addr_insert_bounds_check(WN *assertion, WN *ar);
00265 
00266 static BOOL cwh_addr_is_triplet(WN * wn) ;
00267 
00268 static  WN * cwh_addr_iload(WN *wn, OFFSET_64 off, TY_IDX  ty) ;
00269 static  WN * cwh_addr_lda(ST * st, OFFSET_64 off, TY_IDX  ty)  ;
00270 static  WN * cwh_addr_adjust_array(WN *wn, TY_IDX  ty) ;
00271 static  WN * cwh_addr_nonc_recast(WN *wt, WN *wa) ;
00272 static  void cwh_addr_access_flags(ST *, INT fg) ;
00273 static  BOOL cwh_addr_f90_pointer_reference_ls(WN * ls);
00274 static  W_node cwh_addr_substr_util(OFFSET_64 off,  TY_IDX  dty ) ;
00275 
00276 
00277 /* Holds extra information about ARRAY nodes. Currently only 
00278  * an array name is stored there.
00279  */
00280 
00281 WN_MAP array_name_map;
00282 
00283 #define POINTER_TY (Be_Type_Tbl(Pointer_Mtype))
00284 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines