Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
dvector.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 dvector_INCLUDED
00037 #define dvector_INCLUDED
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif
00041 
00042 
00195 #ifndef ND_RCS_ID
00196 #define ND_RCS_ID
00197 #ifdef _KEEP_RCS_ID
00198 #endif /* _KEEP_RCS_ID */
00199 #endif
00200 
00201 #include "defs.h"
00202 #include "errors.h"
00203 #include "mempool.h"
00204 
00205 
00206 typedef enum {
00207   DIR_POS=1,
00208   DIR_NEG=2,
00209   DIR_EQ=4,
00210   DIR_POSNEG=3,
00211   DIR_POSEQ=5,
00212   DIR_NEGEQ=6,
00213   DIR_STAR=7
00214 } DIRECTION;
00215 
00216 /* DEP is implemented as a 16 bit quantity */
00217 /* Bit 15 is on if the distance is constant */
00218 /* Bits 12-14  give the direction */
00219 /* Bits 0-11 give the distance + offset (offset=2048) */
00220 typedef mINT16  DEP;
00221 
00222 #define DISTANCE_FLAG_PRIVATE 0x8000
00223 #define DISTANCE_MASK_PRIVATE 0x0FFF
00224 #define DISTANCE_OFFSET_PRIVATE 2048
00225 #define DIRECTION_MASK_PRIVATE 0x7000
00226 #define MAX_BOUND_PRIVATE 4095
00227 #define MAX_DISTANCE_PRIVATE 2047
00228 #define MIN_DISTANCE_PRIVATE -2048
00229 
00230 extern DEP DEP_SetDistance(INT32 distance);
00231 extern void DEP_Lex_Pos_Decompose(DEP dep,MEM_POOL *pool,DEP **pos, 
00232     DEP **neg, BOOL keep_pos_equals,BOOL keep_neg_equals) ;
00233 
00234 extern DEP DEP_Lex_Pos_Compose(DEP *pos, DEP *neg, BOOL *pos_has_eq,
00235         BOOL *neg_has_eq);
00236 
00237 inline BOOL DEP_IsDistance(DEP dep)
00238 {
00239   return(dep & DISTANCE_FLAG_PRIVATE);
00240 }
00241 
00242 inline INT32 DEP_Distance(DEP dep)
00243 {
00244   Is_True(DEP_IsDistance(dep),("DEP_Distance called on non-constant dist."));
00245   return(((INT32) (dep & DISTANCE_MASK_PRIVATE)) - DISTANCE_OFFSET_PRIVATE);
00246 }
00247 
00248 inline UINT32 DEP_DistanceBound(DEP dep)
00249 {
00250   return(((UINT32) (dep & DISTANCE_MASK_PRIVATE)) - DISTANCE_OFFSET_PRIVATE);
00251 }
00252 
00253 inline DIRECTION DEP_Direction(DEP dep)
00254 {
00255   return((DIRECTION) ((dep & DIRECTION_MASK_PRIVATE) >> 12)); 
00256 }
00257 
00258 inline DEP DEP_MAKE_DIST_CONST_PRIVATE(DEP dep)
00259 {
00260   return (dep | DISTANCE_FLAG_PRIVATE);
00261 }
00262 
00263 inline DEP DEP_MAKE_DIST_NON_CONST_PRIVATE(DEP dep)
00264 {
00265   return( dep & (~DISTANCE_FLAG_PRIVATE));
00266 }
00267 
00268 /* set the direction bits, don't fiddle with anything else */
00269 inline DEP DEP_SET_DIR_PRIVATE(DEP dep,DIRECTION direction)
00270 {
00271   dep &= (~DIRECTION_MASK_PRIVATE);
00272   dep  |= ((mINT16) direction) << 12;
00273   return (dep);
00274 }
00275 
00276 /* set the distance bits, don't fiddle with anything else */
00277 /* assumes distance is withing bounds */
00278 inline DEP DEP_SET_DIST_PRIVATE(DEP dep,INT32 distance)
00279 {
00280   dep &= (~DISTANCE_MASK_PRIVATE);
00281   dep = (mINT16) (dep | (distance + DISTANCE_OFFSET_PRIVATE));
00282   return (dep);
00283 }
00284 
00285 
00286 
00287 /* DEPV */
00288 
00289 /* DEPV is implemented as an array of DEP, which is assumed to be mINT16 */
00290 /* Element 0..num_dim give the individual deps */
00291 typedef DEP DEPV;  
00292 
00293 
00294 #define DEPV_Dep(depv,i) depv[i]
00295 
00296 
00297 inline void DEPV_Free(MEM_POOL *mem_pool,DEPV *depv)
00298 {
00299   MEM_POOL_FREE(mem_pool,depv);
00300 }
00301 
00302 extern DEP DEP_SetDirection(DIRECTION direction);
00303 extern DEP DEP_UnionDirection(DEP dep,DIRECTION direction);
00304 extern DEP DEP_Negate(DEP dep);
00305 extern void  DIRECTION_Print(DIRECTION dir,FILE *fp);
00306 extern void  DEP_Print(const DEP dep,FILE *fp);
00307 extern void  DEP_PrintBound(const DEP dep,FILE *fp);
00308 extern DEPV *DEPV_Create(MEM_POOL *mem_pool,UINT8 num_dim);
00309 extern DEPV *DEPV_CreateStar(MEM_POOL *mem_pool,UINT8 num_dim);
00310 extern DEPV *DEPV_CreateEqual(MEM_POOL *mem_pool,UINT8 num_dim);
00311 extern DEPV *DEPV_Copy(MEM_POOL *mem_pool, DEPV *depv, UINT8 num_dim);
00312 extern void DEPV_Print(const DEPV *depv,FILE *fp, UINT8 num_dim);
00313 extern void DEPV_PrintBound(const DEPV *depv,FILE *fp, UINT8 num_dim);
00314 
00315 #ifdef __cplusplus
00316 }
00317 #endif
00318 
00319 #endif /* dvector_INCLUDED */
00320 
00321 
00322 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines