Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
util.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 util_INCLUDED
00037 #define util_INCLUDED
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif
00041 
00042 
00043 
00044 #ifdef _KEEP_RCS_ID
00045 #endif /* _KEEP_RCS_ID */
00046 
00047 /* Generate a call to an external command:
00048  * Returns 0 on success, an error code on failure.
00049  * An error code < 0400 is a Unix error code from errno.h.
00050  * An error code > 0400 is 0400 plus the signal which killed child.
00051  */
00052 extern INT Execute (
00053   char *cmd,            /* The command to execute */
00054   char **argv,          /* Argument list */
00055   char *stdoutfile,     /* stdout for new process to use or NULL */
00056   BOOL echo             /* Echo command line? */
00057 );
00058 
00059 /* Get the value of an environment variable: */
00060 extern char *Get_Environment_Value (
00061   char *name,   /* The name of the environment variable */
00062   char **envp,  /* Array of environment variables + NULL */
00063   char *def     /* Default to return if not found */
00064 );
00065 
00066 /* Check an integer value against bounds: */
00067 extern INT Check_Range (
00068   INT val,      /* Check this value */
00069   INT lbound,   /* ... against this lower bound */
00070   INT ubound,   /* ... and this upper bound, */
00071   INT def       /* ... with this default. */
00072 );              /* Returns val if in range, def if out of range. */
00073 
00074 /* Print tabs and spaces to indent given number of characters: */
00075 extern void Indent (
00076   FILE *f,      /* File to indent */
00077   INT16 indent  /* Number of spaces to indent */
00078 );
00079 
00080 /* Mathematically correct integer modulus function: */
00081 INT Mod(
00082   INT i,
00083   INT j
00084 );
00085 
00086 /* Min & Max functions.  These really have to be functions because
00087  * they evaluate their arguments an indeterminate number of times.  (1
00088  * or 2).
00089  */
00090 extern INT Min(
00091   INT i,
00092   INT j
00093 );
00094 
00095 extern INT Max(
00096   INT i,
00097   INT j
00098 );
00099 
00100 /* Count set bits */
00101 extern const mUINT8 UINT8_pop_count[256];
00102 extern TARG_INT
00103 TARG_INT_Pop_Count(
00104   TARG_INT x
00105 );
00106 
00107 /* Find leftmost set bit */
00108 /*      extern const mUINT8 UINT8_most_sig_one[256];    */
00109 extern TARG_INT
00110 TARG_INT_Most_Sig_One(
00111   TARG_INT x
00112 );
00113 
00114 /* Find rightmost set bit. */
00115 extern const mUINT8 UINT8_least_sig_one[256];
00116 extern TARG_INT
00117 TARG_INT_Least_Sig_One(
00118   TARG_INT x
00119 );
00120 
00121 extern INT32 nearest_power_of_two(INT32 n);
00122 
00123 /* Is there a string of ones from bit ub to lb ([63 .. 0])      */
00124 extern BOOL Immediate_Has_All_Ones(INT64 imm, INT32 ub, INT32 lb);
00125 
00126 
00127 #ifdef __cplusplus
00128 }
00129 #endif
00130 #endif /* util_INCLUDED */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines