ScopLib
0.2.1
|
00001 00002 /*+------- <| --------------------------------------------------------** 00003 ** A Clan/Scop ** 00004 **--- /.\ -----------------------------------------------------** 00005 ** <| [""M# macros.h ** 00006 **- A | # -----------------------------------------------------** 00007 ** /.\ [""M# First version: 30/04/2008 ** 00008 **- [""M# | # U"U#U -----------------------------------------------** 00009 | # | # \ .:/ 00010 | # | #___| # 00011 ****** | "--' .-" ****************************************************** 00012 * |"-"-"-"-"-#-#-## Clan : the Chunky Loop Analyzer (experimental) * 00013 **** | # ## ###### ***************************************************** 00014 * \ .::::'/ * 00015 * \ ::::'/ Copyright (C) 2008 Cedric Bastoul * 00016 * :8a| # # ## * 00017 * ::88a ### This is free software; you can redistribute it * 00018 * ::::888a 8a ##::. and/or modify it under the terms of the GNU Lesser * 00019 * ::::::::888a88a[]::: General Public License as published by the Free * 00020 *::8:::::::::SUNDOGa8a::. Software Foundation, either version 2.1 of the * 00021 *::::::::8::::888:Y8888:: License, or (at your option) any later version. * 00022 *::::':::88::::888::Y88a::::::::::::... * 00023 *::'::.. . ..... .. ... . * 00024 * This software is distributed in the hope that it will be useful, but * 00025 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * 00026 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * 00027 * for more details. * 00028 * * 00029 * You should have received a copy of the GNU Lesser General Public License * 00030 * along with software; if not, write to the Free Software Foundation, Inc., * 00031 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 00032 * * 00033 * Clan, the Chunky Loop Analyzer * 00034 * Written by Cedric Bastoul, Cedric.Bastoul@inria.fr * 00035 * * 00036 ******************************************************************************/ 00037 00038 #ifndef SCOPLIB_MACROS_H 00039 # define SCOPLIB_MACROS_H 00040 00041 00042 # if defined(SCOPLIB_INT_T_IS_LONGLONG) 00043 # define SCOPLIB_FMT "%4lld" 00044 # define SCOPLIB_FMT_TXT "%lld" 00045 # define scoplib_int_t long long 00046 00047 # elif defined(SCOPLIB_INT_T_IS_LONG) 00048 # define SCOPLIB_FMT "%4ld" 00049 # define SCOPLIB_FMT_TXT "%ld" 00050 # define scoplib_int_t long int 00051 00052 # elif defined(SCOPLIB_INT_T_IS_MP) /* GNUMP */ 00053 #include <gmp.h> 00054 # define SCOPLIB_FMT "%4s" 00055 # define SCOPLIB_FMT_TXT "%s" 00056 # define scoplib_int_t mpz_t 00057 00058 # else 00059 # error Define SCOPLIB_INT_T_IS_xxx to use this file. 00060 00061 # endif 00062 00063 # define SCOPLIB_DEBUG 0 /* Set to 1 for debug mode, 00064 0 otherwise */ 00065 # define SCOPLIB_MAX_STRING 2048 00066 # define SCOPLIB_TYPE_ITERATOR 1 00067 # define SCOPLIB_TYPE_PARAMETER 2 00068 # define SCOPLIB_TYPE_ARRAY 3 00069 # define SCOPLIB_TYPE_FUNCTION 4 00070 # define SCOPLIB_TYPE_DOMAIN 6 00071 # define SCOPLIB_TYPE_SCATTERING 7 00072 # define SCOPLIB_TYPE_ACCESS 8 00073 # define SCOPLIB_TYPE_UNKNOWN 9 00074 # define SCOPLIB_FAKE_ARRAY "fakearray" 00075 00076 # define SCOPLIB_SCOP_PRINT_CASTLE 1 00077 # define SCOPLIB_SCOP_PRINT_ARRAYSTAG 2 00078 00079 00080 /*+**************************************************************************** 00081 * SCOP GMP MACROS * 00082 ******************************************************************************/ 00083 # ifdef SCOPLIB_INT_T_IS_MP 00084 /* Basic Macros */ 00085 # define SCOPVAL_init(val) (mpz_init((val))) 00086 # define SCOPVAL_assign(v1,v2) (mpz_set((v1),(v2))) 00087 # define SCOPVAL_set_si(val,i) (mpz_set_si((val),(i))) 00088 # define SCOPVAL_get_si(val) (mpz_get_si((val))) 00089 # define SCOPVAL_init_set_si(val,i) (mpz_init_set_si((val),(i))) 00090 # define SCOPVAL_clear(val) (mpz_clear((val))) 00091 # define SCOPVAL_print(Dst,fmt,val) { char *str; \ 00092 str = mpz_get_str(0,10,(val)); \ 00093 fprintf((Dst),(fmt),str); free(str); \ 00094 } 00095 # define SCOPVAL_sprint(Dst,fmt,val) { char * str; \ 00096 str = mpz_get_str(0,10,(val)); \ 00097 sprintf((Dst),(fmt),str); free(str); \ 00098 } 00099 00100 /* Boolean operators on 'scoplib_int_t' */ 00101 # define SCOPVAL_eq(v1,v2) (mpz_cmp((v1),(v2)) == 0) 00102 # define SCOPVAL_ne(v1,v2) (mpz_cmp((v1),(v2)) != 0) 00103 00104 /* Binary operators on 'scoplib_int_t' */ 00105 # define SCOPVAL_increment(ref,val) (mpz_add_ui((ref),(val),1)) 00106 # define SCOPVAL_addto(ref,val1,val2) (mpz_add((ref),(val1),(val2))) 00107 # define SCOPVAL_multo(ref,val1,val2) (mpz_mul((ref),(val1),(val2))) 00108 # define SCOPVAL_divto(ref,val1,val2) (mpz_div((ref),(val1),(val2))) 00109 # define SCOPVAL_add_int(ref,val,vint) (mpz_add_ui((ref),(val),(long)(vint))) 00110 # define SCOPVAL_subtract(ref,val1,val2) (mpz_sub((ref),(val1),(val2))) 00111 # define SCOPVAL_oppose(ref,val) (mpz_neg((ref),(val))) 00112 00113 /* Conditional operations on 'scoplib_int_t' */ 00114 # define SCOPVAL_pos_p(val) (mpz_sgn(val) > 0) 00115 # define SCOPVAL_neg_p(val) (mpz_sgn(val) < 0) 00116 # define SCOPVAL_zero_p(val) (mpz_sgn(val) == 0) 00117 # define SCOPVAL_notzero_p(val) (mpz_sgn(val) != 0) 00118 # define SCOPVAL_one_p(val) (mpz_cmp_si(val,1) == 0) 00119 # define SCOPVAL_mone_p(val) (mpz_cmp_si(val,-1) == 0) 00120 00121 /*+**************************************************************************** 00122 * SCOPVAL BASIC TYPES MACROS * 00123 ******************************************************************************/ 00124 # else 00125 /* Basic Macros */ 00126 # define SCOPVAL_init(val) ((val) = 0) 00127 # define SCOPVAL_assign(v1,v2) ((v1) = (v2)) 00128 # define SCOPVAL_set_si(val,i) ((val) = (scoplib_int_t)(i)) 00129 # define SCOPVAL_get_si(val) ((val)) 00130 # define SCOPVAL_init_set_si(val,i) ((val) = (scoplib_int_t)(i)) 00131 # define SCOPVAL_clear(val) ((val) = 0) 00132 # define SCOPVAL_print(Dst,fmt,val) (fprintf((Dst),(fmt),(val))) 00133 # define SCOPVAL_sprint(Dst,fmt,val) (sprintf((Dst),(fmt),(val))) 00134 00135 /* Boolean operators on 'scoplib_int_t' */ 00136 # define SCOPVAL_eq(v1,v2) ((v1)==(v2)) 00137 # define SCOPVAL_ne(v1,v2) ((v1)!=(v2)) 00138 # define SCOPVAL_lt(v1,v2) ((v1)<(v2)) 00139 # define SCOPVAL_gt(v1,v2) ((v1)>(v2)) 00140 00141 /* Binary operators on 'scoplib_int_t' */ 00142 # define SCOPVAL_increment(ref,val) ((ref) = (val)+(scoplib_int_t)(1)) 00143 # define SCOPVAL_addto(ref,val1,val2) ((ref) = (val1)+(val2)) 00144 # define SCOPVAL_multo(ref,val1,val2) ((ref) = (val1)*(val2)) 00145 # define SCOPVAL_divto(ref,val1,val2) ((ref) = (val1)/(val2)) 00146 # define SCOPVAL_add_int(ref,val,vint) ((ref) = (val)+(scoplib_int_t)(vint)) 00147 # define SCOPVAL_subtract(ref,val1,val2) ((ref) = (val1)-(val2)) 00148 # define SCOPVAL_oppose(ref,val) ((ref) = (-(val))) 00149 00150 /* Conditional operations on 'scoplib_int_t' */ 00151 # define SCOPVAL_pos_p(val) SCOPVAL_gt(val,0) 00152 # define SCOPVAL_neg_p(val) SCOPVAL_lt(val,0) 00153 # define SCOPVAL_zero_p(val) SCOPVAL_eq(val,0) 00154 # define SCOPVAL_notzero_p(val) SCOPVAL_ne(val,0) 00155 # define SCOPVAL_one_p(val) SCOPVAL_eq(val,1) 00156 # define SCOPVAL_mone_p(val) SCOPVAL_eq(val,-1) 00157 00158 # endif 00159 00160 #endif /* define SCOPLIB_MACROS_H */