Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
f90_intrinsic.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 #include <cray/portdefs.h> 
00037 #include <cray/dopevec.h> 
00038 #include <liberrno.h>
00039 #include <float.h>
00040 #include <inttypes.h>
00041 #include <fmath.h>
00042 #include <fortran.h>
00043 #include <stdlib.h>            /* for malloc prototype */
00044 #include <string.h>
00045 
00046 #define MAX_NARY_DIMS MAXDIM   
00047 #define BIGDEFAULTSZ 64
00048 
00049 #define ERROR _lerror
00050 #define FALSE 0
00051 #define TRUE  1
00052 
00053 
00054 /* descriptor accessors */
00055 
00056 #define GET_RANK_FROM_DESC(array)       (array->n_dim) 
00057 #define GET_EXTENT_FROM_DESC(array,dim) (array->dimension[dim].extent)
00058 #define GET_ASSOCIATED_FROM_DESC(array) (array->assoc)
00059 #define GET_ALEN_FROM_DESC(array)       (array->base_addr.a.el_len)
00060 #define GET_DV_ASCII_FROM_DESC(array)   (array->type_lens.type == DVTYPE_ASCII)
00061 #define GET_DV_LOGICAL_FROM_DESC(array) (array->type_lens.type == DVTYPE_LOGICAL)
00062 
00063 #define GET_ADDRESS_FROM_DESC(array)   \
00064          ((array->type_lens.type == DVTYPE_ASCII) ?  \
00065           ((char *) _fcdtocp (array->base_addr.charptr))    :  \
00066           ((char *) array->base_addr.a.ptr)) 
00067 
00068 #define GET_BYTEALIGNED_FROM_DESC(array) \
00069          ((array->type_lens.type == DVTYPE_ASCII) ||  \
00070           (array->type_lens.type == DVTYPE_DERIVEDBYTE)) 
00071 
00072 #define GET_ELEMENT_SZ_FROM_DESC(array) \
00073                ((array->type_lens.type == DVTYPE_ASCII)?  \
00074                 (_fcdlen(array->base_addr.charptr))    :  \
00075                 ((array->base_addr.a.el_len)>>3))    
00076 
00077 static size_t GET_STRIDE_FROM_DESC(DopeVectorType * array, int32_t dim)
00078 {
00079    size_t rval;
00080    rval = array->dimension[dim].stride_mult;
00081    switch (array->type_lens.type) {
00082    case DVTYPE_ASCII:
00083    case DVTYPE_DERIVEDBYTE:
00084       return (rval);
00085 
00086    case DVTYPE_DERIVEDWORD:
00087      return (rval << 2 );
00088 
00089     default:
00090       switch (array->type_lens.int_len) {
00091       case 8: 
00092         return (rval);
00093 
00094       case 16:
00095         return (rval << 1);
00096 
00097       default:
00098         return ( rval <<2 );
00099       }
00100    }
00101 }
00102 
00103 #define MK_STRIDE(byte_aligned,typ_sz)  \
00104      ((byte_aligned || typ_sz == 1) ?   \
00105          (typ_sz)                   :   \
00106            ((typ_sz == 2)           ?   \
00107            (typ_sz/(BYTES_PER_WORD/2)) :\
00108               (typ_sz/BYTES_PER_WORD)))
00109 
00110 
00111 #define SET_RANK_IN_DESC(array,r)       (array->n_dim = r) 
00112 #define SET_ADDRESS_IN_DESC(array,d)    (array->base_addr.a.ptr = d) 
00113 #define SET_CHARPTR_IN_DESC(array,cr,sz) (array->base_addr.charptr = _cptofcd (cr, sz)) 
00114 #define SET_LBOUND_IN_DESC(array,dim,b) (array->dimension[dim].low_bound = b)
00115 #define SET_EXTENT_IN_DESC(array,dim,e) (array->dimension[dim].extent = e)
00116 #define SET_STRMULT_IN_DESC(array,dim,e)(array->dimension[dim].stride_mult = e)
00117 #define SET_ASSOCIATED_IN_DESC(array)   (array->assoc = TRUE)
00118 #define SET_CONTIG_IN_DESC(array)       (array->a_contig = TRUE)
00119 #define SET_ORIG_BS_IN_DESC(array,a)    (array->orig_base = a) 
00120 #define SET_ORIG_SZ_IN_DESC(array,s)    (array->orig_size = s) 
00121 #define SET_ALEN_IN_DESC(array,l)       (array->base_addr.a.el_len = l)
00122 
00123 
00124 /* assume 1/0 for TRUE is set in byte for mask arguments. offset to correct byte */
00125 
00126 #if defined(_LITTLE_ENDIAN)
00127 #define OFFSET_TO_TF_BYTE(by) 0
00128 #else
00129 #define OFFSET_TO_TF_BYTE(by) (by-1)
00130 #endif
00131 
00132 
00133 /* definitions of types to match usage in generated files */
00134 
00135 #define i8 int64_t 
00136 #define i4 int32_t 
00137 #define i2 int16_t 
00138 #define i1 int8_t  
00139 
00140 #define ui8 uint64_t 
00141 #define ui4 uint32_t 
00142 #define ui2 uint16_t 
00143 #define ui1 uint8_t  
00144 
00145 #define l8 uint64_t 
00146 #define l4 uint32_t 
00147 #define l2 uint16_t 
00148 #define l1 uint8_t  
00149 
00150 #define r16 long double
00151 #define r8  double 
00152 #define r4  float  
00153 
00154 typedef struct { float r, i; } complex;
00155 typedef struct { double r, i; } dcomplex;
00156 typedef struct { long double r, i ; } qcomplex;
00157 
00158 #define c32 qcomplex  
00159 #define c16 dcomplex  
00160 #define c8  complex  
00161 
00162 #define ALIGNED_r16(address) (((size_t)address & 0x7) == 0)
00163 #define ALIGNED_r8(address)  (((size_t)address & 0x7) == 0)
00164 #define ALIGNED_i8(address)  (((size_t)address & 0x7) == 0)
00165 #define ALIGNED_i4(address)  (((size_t)address & 0x3) == 0)
00166 #define ALIGNED_r4(address)  (((size_t)address & 0x3) == 0)
00167 #define ALIGNED_i2(address)  (((size_t)address & 0x1) == 0)
00168 #define ALIGNED_i1(address)  (TRUE)
00169                              
00170 
00171 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines