Open64 (mfef90, whirl2f, and IR tools)
TAG: version-openad; SVN changeset: 916
|
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.1 of the GNU Lesser General Public License 00007 as 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 Lesser General Public 00021 License along with this program; if not, write the Free Software 00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, 00023 USA. 00024 00025 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00026 Mountain View, CA 94043, or: 00027 00028 http://www.sgi.com 00029 00030 For further information regarding this notice, see: 00031 00032 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00033 00034 */ 00035 00036 00037 #pragma ident "@(#) libfi/element/associated.c 92.1 06/16/99 15:47:23" 00038 #include <fortran.h> 00039 #include <stdlib.h> 00040 #include <liberrno.h> 00041 #include <cray/dopevec.h> 00042 00043 #define TRUE 1 00044 #define FALSE 0 00045 00046 /* 00047 * ASSOCIATED Returns the association status of its pointer argument 00048 * or indicates the pointer is associated with the target. 00049 * If TARGET argument is NULL, return TRUE if POINTER is 00050 * currently associated. Otherwise return FALSE. 00051 * If TARGET argument is present and is a TARGET, return TRUE 00052 * if POINTER is currently associated with TARGET. 00053 * Otherwise, return FALSE. 00054 * If TARGET argument is present and is a pointer, return TRUE 00055 * if POINTER and TARGET are currently associated with the 00056 * same target. Otherwise, return FALSE. If either TARGET 00057 * or POINTER are disassociated, return FALSE. 00058 */ 00059 00060 _f_log 00061 _ASSOCIATED (DopeVectorType * pointer, 00062 DopeVectorType * target) 00063 { 00064 int iresult; 00065 int loopj; 00066 int rank; 00067 long ptrlen; 00068 long tarlen; 00069 iresult = FALSE; 00070 00071 /* if pointer is not associated, return FALSE */ 00072 if (!pointer->assoc) 00073 return(_btol(iresult)); 00074 00075 /* if target is not present and pointer is associated, 00076 * return TRUE 00077 */ 00078 if (target == NULL) { 00079 iresult = TRUE; 00080 return(_btol(iresult)); 00081 } 00082 00083 /* if target is a disassociated pointer, 00084 * return FALSE 00085 */ 00086 if ((target->p_or_a == POINTTR) && (!target->assoc)) 00087 return(_btol(iresult)); 00088 00089 rank = pointer->n_dim; 00090 #if defined(_CRAY1) && !defined(_ADDR64) && !defined(_WORD32) 00091 ptrlen = pointer->base_addr.a.el_len; 00092 tarlen = target->base_addr.a.el_len; 00093 #else 00094 ptrlen = _fcdlen(pointer->base_addr.charptr); 00095 tarlen = _fcdlen(target->base_addr.charptr); 00096 #endif 00097 00098 /* compare pointer and target fields */ 00099 if ((pointer->base_addr.a.ptr == target->base_addr.a.ptr) && 00100 (ptrlen == tarlen) && 00101 (pointer->n_dim == target->n_dim) && 00102 (pointer->type_lens.type == target->type_lens.type)) { 00103 00104 /* interp 000027, different low bounds are okay */ 00105 for (loopj = 0; loopj < rank; loopj++) { 00106 if((pointer->dimension[loopj].extent != 00107 target->dimension[loopj].extent) || 00108 (pointer->dimension[loopj].stride_mult != 00109 target->dimension[loopj].stride_mult)) 00110 return(_btol(iresult)); 00111 } 00112 iresult = TRUE; 00113 } 00114 return(_btol(iresult)); 00115 } 00116 00117 #ifdef _F_LOG4 00118 /* 00119 * ASSOCIATED_4 Returns the association status of its pointer argument 00120 * or indicates the pointer is associated with the target. 00121 * If TARGET argument is NULL, return TRUE if POINTER is 00122 * currently associated. Otherwise return FALSE. 00123 * If TARGET argument is present and is a TARGET, return TRUE 00124 * if POINTER is currently associated with TARGET. 00125 * Otherwise, return FALSE. 00126 * If TARGET argument is present and is a pointer, return TRUE 00127 * if POINTER and TARGET are currently associated with the 00128 * same target. Otherwise, return FALSE. If either TARGET 00129 * or POINTER are disassociated, return FALSE. 00130 */ 00131 00132 _f_log4 00133 _ASSOCIATED_4 (DopeVectorType * pointer, 00134 DopeVectorType * target) 00135 { 00136 _f_int4 iresult; 00137 int loopj; 00138 int rank; 00139 long ptrlen; 00140 long tarlen; 00141 iresult = FALSE; 00142 00143 /* if pointer is not associated, return FALSE */ 00144 if (!pointer->assoc) 00145 return(_btol(iresult)); 00146 00147 /* if target is not present and pointer is associated, 00148 * return TRUE 00149 */ 00150 if (target == NULL) { 00151 iresult = TRUE; 00152 return(_btol(iresult)); 00153 } 00154 00155 /* if target is a disassociated pointer, 00156 * return FALSE 00157 */ 00158 if ((target->p_or_a == POINTTR) && (!target->assoc)) 00159 return(_btol(iresult)); 00160 00161 rank = pointer->n_dim; 00162 #if defined(_CRAY1) && !defined(_ADDR64) && !defined(_WORD32) 00163 ptrlen = pointer->base_addr.a.el_len; 00164 tarlen = target->base_addr.a.el_len; 00165 #else 00166 ptrlen = _fcdlen(pointer->base_addr.charptr); 00167 tarlen = _fcdlen(target->base_addr.charptr); 00168 #endif 00169 00170 /* compare pointer and target fields */ 00171 if ((pointer->base_addr.a.ptr == target->base_addr.a.ptr) && 00172 (ptrlen == tarlen) && 00173 (pointer->n_dim == target->n_dim) && 00174 (pointer->type_lens.type == target->type_lens.type)) { 00175 00176 /* interp 000027, different low bounds are okay */ 00177 for (loopj = 0; loopj < rank; loopj++) { 00178 if((pointer->dimension[loopj].extent != 00179 target->dimension[loopj].extent) || 00180 (pointer->dimension[loopj].stride_mult != 00181 target->dimension[loopj].stride_mult)) 00182 return(_btol(iresult)); 00183 } 00184 iresult = TRUE; 00185 } 00186 return(_btol(iresult)); 00187 } 00188 00189 #endif 00190 00191 00192 #ifdef _F_LOG8 00193 /* 00194 * ASSOCIATED_8 Returns the association status of its pointer argument 00195 * or indicates the pointer is associated with the target. 00196 * If TARGET argument is NULL, return TRUE if POINTER is 00197 * currently associated. Otherwise return FALSE. 00198 * If TARGET argument is present and is a TARGET, return TRUE 00199 * if POINTER is currently associated with TARGET. 00200 * Otherwise, return FALSE. 00201 * If TARGET argument is present and is a pointer, return TRUE 00202 * if POINTER and TARGET are currently associated with the 00203 * same target. Otherwise, return FALSE. If either TARGET 00204 * or POINTER are disassociated, return FALSE. 00205 */ 00206 00207 _f_log8 00208 _ASSOCIATED_8 (DopeVectorType * pointer, 00209 DopeVectorType * target) 00210 { 00211 _f_int8 iresult; 00212 int loopj; 00213 int rank; 00214 long ptrlen; 00215 long tarlen; 00216 iresult = FALSE; 00217 00218 /* if pointer is not associated, return FALSE */ 00219 if (!pointer->assoc) 00220 return(_btol(iresult)); 00221 00222 /* if target is not present and pointer is associated, 00223 * return TRUE 00224 */ 00225 if (target == NULL) { 00226 iresult = TRUE; 00227 return(_btol(iresult)); 00228 } 00229 00230 /* if target is a disassociated pointer, 00231 * return FALSE 00232 */ 00233 if ((target->p_or_a == POINTTR) && (!target->assoc)) 00234 return(_btol(iresult)); 00235 00236 rank = pointer->n_dim; 00237 #if defined(_CRAY1) && !defined(_ADDR64) && !defined(_WORD32) 00238 ptrlen = pointer->base_addr.a.el_len; 00239 tarlen = target->base_addr.a.el_len; 00240 #else 00241 ptrlen = _fcdlen(pointer->base_addr.charptr); 00242 tarlen = _fcdlen(target->base_addr.charptr); 00243 #endif 00244 00245 /* compare pointer and target fields */ 00246 if ((pointer->base_addr.a.ptr == target->base_addr.a.ptr) && 00247 (ptrlen == tarlen) && 00248 (pointer->n_dim == target->n_dim) && 00249 (pointer->type_lens.type == target->type_lens.type)) { 00250 00251 /* interp 000027, different low bounds are okay */ 00252 for (loopj = 0; loopj < rank; loopj++) { 00253 if((pointer->dimension[loopj].extent != 00254 target->dimension[loopj].extent) || 00255 (pointer->dimension[loopj].stride_mult != 00256 target->dimension[loopj].stride_mult)) 00257 return(_btol(iresult)); 00258 } 00259 iresult = TRUE; 00260 } 00261 return(_btol(iresult)); 00262 } 00263 00264 #endif