relations
[openscop.git] / include / scoplib / macros.h
blobb446d90f845db38015d3096c7efedefcbb44c6bb
2 /*+------- <| --------------------------------------------------------**
3 ** A Clan/Scop **
4 **--- /.\ -----------------------------------------------------**
5 ** <| [""M# macros.h **
6 **- A | # -----------------------------------------------------**
7 ** /.\ [""M# First version: 30/04/2008 **
8 **- [""M# | # U"U#U -----------------------------------------------**
9 | # | # \ .:/
10 | # | #___| #
11 ****** | "--' .-" ******************************************************
12 * |"-"-"-"-"-#-#-## Clan : the Chunky Loop Analyzer (experimental) *
13 **** | # ## ###### *****************************************************
14 * \ .::::'/ *
15 * \ ::::'/ Copyright (C) 2008 Cedric Bastoul *
16 * :8a| # # ## *
17 * ::88a ### This is free software; you can redistribute it *
18 * ::::888a 8a ##::. and/or modify it under the terms of the GNU Lesser *
19 * ::::::::888a88a[]::: General Public License as published by the Free *
20 *::8:::::::::SUNDOGa8a::. Software Foundation, either version 2.1 of the *
21 *::::::::8::::888:Y8888:: License, or (at your option) any later version. *
22 *::::':::88::::888::Y88a::::::::::::... *
23 *::'::.. . ..... .. ... . *
24 * This software is distributed in the hope that it will be useful, but *
25 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
26 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
27 * for more details. *
28 * *
29 * You should have received a copy of the GNU Lesser General Public License *
30 * along with software; if not, write to the Free Software Foundation, Inc., *
31 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
32 * *
33 * Clan, the Chunky Loop Analyzer *
34 * Written by Cedric Bastoul, Cedric.Bastoul@inria.fr *
35 * *
36 ******************************************************************************/
38 #ifndef SCOPLIB_MACROS_H
39 # define SCOPLIB_MACROS_H
42 # if defined(SCOPLIB_INT_T_IS_LONGLONG)
43 # define SCOPLIB_FMT "%4lld"
44 # define SCOPLIB_FMT_TXT "%lld"
45 # define scoplib_int_t long long
47 # elif defined(SCOPLIB_INT_T_IS_LONG)
48 # define SCOPLIB_FMT "%4ld"
49 # define SCOPLIB_FMT_TXT "%ld"
50 # define scoplib_int_t long int
52 # elif defined(SCOPLIB_INT_T_IS_MP) /* GNUMP */
53 #include <gmp.h>
54 # define SCOPLIB_FMT "%4s"
55 # define SCOPLIB_FMT_TXT "%s"
56 # define scoplib_int_t mpz_t
58 # else
59 # error Define SCOPLIB_INT_T_IS_xxx to use this file.
61 # endif
63 # define SCOPLIB_DEBUG 0 /* Set to 1 for debug mode,
64 0 otherwise */
65 # define SCOPLIB_MAX_STRING 2048
66 # define SCOPLIB_TYPE_ITERATOR 1
67 # define SCOPLIB_TYPE_PARAMETER 2
68 # define SCOPLIB_TYPE_ARRAY 3
69 # define SCOPLIB_TYPE_FUNCTION 4
70 # define SCOPLIB_TYPE_DOMAIN 6
71 # define SCOPLIB_TYPE_SCATTERING 7
72 # define SCOPLIB_TYPE_ACCESS 8
73 # define SCOPLIB_TYPE_UNKNOWN 9
74 # define SCOPLIB_FAKE_ARRAY "fakearray"
76 # define SCOPLIB_SCOP_PRINT_CASTLE 1
77 # define SCOPLIB_SCOP_PRINT_ARRAYSTAG 2
80 /*+****************************************************************************
81 * SCOP GMP MACROS *
82 ******************************************************************************/
83 # ifdef SCOPLIB_INT_T_IS_MP
84 /* Basic Macros */
85 # define SCOPVAL_init(val) (mpz_init((val)))
86 # define SCOPVAL_assign(v1,v2) (mpz_set((v1),(v2)))
87 # define SCOPVAL_set_si(val,i) (mpz_set_si((val),(i)))
88 # define SCOPVAL_get_si(val) (mpz_get_si((val)))
89 # define SCOPVAL_init_set_si(val,i) (mpz_init_set_si((val),(i)))
90 # define SCOPVAL_clear(val) (mpz_clear((val)))
91 # define SCOPVAL_print(Dst,fmt,val) { char *str; \
92 str = mpz_get_str(0,10,(val)); \
93 fprintf((Dst),(fmt),str); free(str); \
95 # define SCOPVAL_sprint(Dst,fmt,val) { char * str; \
96 str = mpz_get_str(0,10,(val)); \
97 sprintf((Dst),(fmt),str); free(str); \
100 /* Boolean operators on 'scoplib_int_t' */
101 # define SCOPVAL_eq(v1,v2) (mpz_cmp((v1),(v2)) == 0)
102 # define SCOPVAL_ne(v1,v2) (mpz_cmp((v1),(v2)) != 0)
104 /* Binary operators on 'scoplib_int_t' */
105 # define SCOPVAL_increment(ref,val) (mpz_add_ui((ref),(val),1))
106 # define SCOPVAL_addto(ref,val1,val2) (mpz_add((ref),(val1),(val2)))
107 # define SCOPVAL_multo(ref,val1,val2) (mpz_mul((ref),(val1),(val2)))
108 # define SCOPVAL_add_int(ref,val,vint) (mpz_add_ui((ref),(val),(long)(vint)))
109 # define SCOPVAL_subtract(ref,val1,val2) (mpz_sub((ref),(val1),(val2)))
110 # define SCOPVAL_oppose(ref,val) (mpz_neg((ref),(val)))
112 /* Conditional operations on 'scoplib_int_t' */
113 # define SCOPVAL_pos_p(val) (mpz_sgn(val) > 0)
114 # define SCOPVAL_neg_p(val) (mpz_sgn(val) < 0)
115 # define SCOPVAL_zero_p(val) (mpz_sgn(val) == 0)
116 # define SCOPVAL_notzero_p(val) (mpz_sgn(val) != 0)
117 # define SCOPVAL_one_p(val) (mpz_cmp_si(val,1) == 0)
118 # define SCOPVAL_mone_p(val) (mpz_cmp_si(val,-1) == 0)
120 /*+****************************************************************************
121 * SCOPVAL BASIC TYPES MACROS *
122 ******************************************************************************/
123 # else
124 /* Basic Macros */
125 # define SCOPVAL_init(val) ((val) = 0)
126 # define SCOPVAL_assign(v1,v2) ((v1) = (v2))
127 # define SCOPVAL_set_si(val,i) ((val) = (scoplib_int_t)(i))
128 # define SCOPVAL_get_si(val) ((val))
129 # define SCOPVAL_init_set_si(val,i) ((val) = (scoplib_int_t)(i))
130 # define SCOPVAL_clear(val) ((val) = 0)
131 # define SCOPVAL_print(Dst,fmt,val) (fprintf((Dst),(fmt),(val)))
132 # define SCOPVAL_sprint(Dst,fmt,val) (sprintf((Dst),(fmt),(val)))
134 /* Boolean operators on 'scoplib_int_t' */
135 # define SCOPVAL_eq(v1,v2) ((v1)==(v2))
136 # define SCOPVAL_ne(v1,v2) ((v1)!=(v2))
137 # define SCOPVAL_lt(v1,v2) ((v1)<(v2))
138 # define SCOPVAL_gt(v1,v2) ((v1)>(v2))
140 /* Binary operators on 'scoplib_int_t' */
141 # define SCOPVAL_increment(ref,val) ((ref) = (val)+(scoplib_int_t)(1))
142 # define SCOPVAL_addto(ref,val1,val2) ((ref) = (val1)+(val2))
143 # define SCOPVAL_multo(ref,val1,val2) ((ref) = (val1)*(val2))
144 # define SCOPVAL_add_int(ref,val,vint) ((ref) = (val)+(scoplib_int_t)(vint))
145 # define SCOPVAL_subtract(ref,val1,val2) ((ref) = (val1)-(val2))
146 # define SCOPVAL_oppose(ref,val) ((ref) = (-(val)))
148 /* Conditional operations on 'scoplib_int_t' */
149 # define SCOPVAL_pos_p(val) SCOPVAL_gt(val,0)
150 # define SCOPVAL_neg_p(val) SCOPVAL_lt(val,0)
151 # define SCOPVAL_zero_p(val) SCOPVAL_eq(val,0)
152 # define SCOPVAL_notzero_p(val) SCOPVAL_ne(val,0)
153 # define SCOPVAL_one_p(val) SCOPVAL_eq(val,1)
154 # define SCOPVAL_mone_p(val) SCOPVAL_eq(val,-1)
156 # endif
158 #endif /* define SCOPLIB_MACROS_H */