X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=gcc%2Flambda.h;h=fc5679a57634194e7b6b888cc3938257f8156a2e;hb=2934c6b590ded021f96a83dbb8b1100acedde68c;hp=6e145ad4ce7cc86ad4711aabb22fdeb1757e66a4;hpb=046bfc77364f8647fa26398c54a063d9d7f93022;p=pf3gnuchains%2Fgcc-fork.git diff --git a/gcc/lambda.h b/gcc/lambda.h index 6e145ad4ce7..fc5679a5763 100644 --- a/gcc/lambda.h +++ b/gcc/lambda.h @@ -1,5 +1,5 @@ /* Lambda matrix and vector interface. - Copyright (C) 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Contributed by Daniel Berlin This file is part of GCC. @@ -16,8 +16,8 @@ for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. */ +Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301, USA. */ #ifndef LAMBDA_H #define LAMBDA_H @@ -30,6 +30,9 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA integers. */ typedef int *lambda_vector; +DEF_VEC_P(lambda_vector); +DEF_VEC_ALLOC_P(lambda_vector,heap); + /* An integer matrix. A matrix consists of m vectors of length n (IE all vectors are the same length). */ typedef lambda_vector *lambda_matrix; @@ -140,7 +143,6 @@ lambda_loopnest lambda_loopnest_transform (lambda_loopnest, lambda_trans_matrix) struct loop; struct loops; bool perfect_nest_p (struct loop *); -bool lambda_transform_legal_p (lambda_trans_matrix, int, varray_type); void print_lambda_loopnest (FILE *, lambda_loopnest, char); #define lambda_loop_new() (lambda_loop) ggc_alloc_cleared (sizeof (struct lambda_loop_s)) @@ -196,13 +198,12 @@ lambda_body_vector lambda_body_vector_compute_new (lambda_trans_matrix, void print_lambda_body_vector (FILE *, lambda_body_vector); lambda_loopnest gcc_loopnest_to_lambda_loopnest (struct loops *, struct loop *, - VEC(tree,gc) **, - VEC(tree,gc) **, + VEC(tree,heap) **, + VEC(tree,heap) **, bool); -void lambda_loopnest_to_gcc_loopnest (struct loop *, VEC(tree,gc) *, - VEC(tree,gc) *, - lambda_loopnest, - lambda_trans_matrix); +void lambda_loopnest_to_gcc_loopnest (struct loop *, + VEC(tree,heap) *, VEC(tree,heap) *, + lambda_loopnest, lambda_trans_matrix); static inline void lambda_vector_negate (lambda_vector, lambda_vector, int); @@ -224,7 +225,7 @@ static inline void print_lambda_vector (FILE *, lambda_vector, int); static inline lambda_vector lambda_vector_new (int size) { - return ggc_alloc_cleared (size * sizeof(int)); + return GGC_CNEWVEC (int, size); } @@ -326,19 +327,15 @@ lambda_vector_min_nz (lambda_vector vec1, int n, int start) { int j; int min = -1; -#ifdef ENABLE_CHECKING - if (start > n) - abort (); -#endif + + gcc_assert (start <= n); for (j = start; j < n; j++) { if (vec1[j]) if (min < 0 || vec1[j] < vec1[min]) min = j; } - - if (min < 0) - abort (); + gcc_assert (min >= 0); return min; } @@ -381,5 +378,64 @@ print_lambda_vector (FILE * outfile, lambda_vector vector, int n) fprintf (outfile, "%3d ", vector[i]); fprintf (outfile, "\n"); } + +/* Compute the greatest common divisor of two numbers using + Euclid's algorithm. */ + +static inline int +gcd (int a, int b) +{ + int x, y, z; + + x = abs (a); + y = abs (b); + + while (x > 0) + { + z = y % x; + y = x; + x = z; + } + + return y; +} + +/* Compute the greatest common divisor of a VECTOR of SIZE numbers. */ + +static inline int +lambda_vector_gcd (lambda_vector vector, int size) +{ + int i; + int gcd1 = 0; + + if (size > 0) + { + gcd1 = vector[0]; + for (i = 1; i < size; i++) + gcd1 = gcd (gcd1, vector[i]); + } + return gcd1; +} + +/* Returns true when the vector V is lexicographically positive, in + other words, when the first nonzero element is positive. */ + +static inline bool +lambda_vector_lexico_pos (lambda_vector v, + unsigned n) +{ + unsigned i; + for (i = 0; i < n; i++) + { + if (v[i] == 0) + continue; + if (v[i] < 0) + return false; + if (v[i] > 0) + return true; + } + return true; +} + #endif /* LAMBDA_H */