/* Lambda matrix and vector interface.
- Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
+ Free Software Foundation, Inc.
Contributed by Daniel Berlin <dberlin@dberlin.org>
This file is part of GCC.
and scalar multiplication. In this vector space, an element is a list of
integers. */
typedef int *lambda_vector;
-
DEF_VEC_P(lambda_vector);
DEF_VEC_ALLOC_P(lambda_vector,heap);
+DEF_VEC_ALLOC_P(lambda_vector,gc);
+
+typedef VEC(lambda_vector, heap) *lambda_vector_vec_p;
+DEF_VEC_P (lambda_vector_vec_p);
+DEF_VEC_ALLOC_P (lambda_vector_vec_p, 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;
+DEF_VEC_P (lambda_matrix);
+DEF_VEC_ALLOC_P (lambda_matrix, heap);
+
/* A transformation matrix, which is a self-contained ROWSIZE x COLSIZE
matrix. Rather than use floats, we simply keep a single DENOMINATOR that
represents the denominator for every element in the matrix. */
#define LBV_SIZE(T) ((T)->size)
#define LBV_DENOMINATOR(T) ((T)->denominator)
-/* Piecewise linear expression.
+/* Piecewise linear expression.
This structure represents a linear expression with terms for the invariants
- and induction variables of a loop.
+ and induction variables of a loop.
COEFFICIENTS is a vector of coefficients for the induction variables, one
per loop in the loop nest.
CONSTANT is the constant portion of the linear expression
INVARIANT_COEFFICIENTS is a vector of coefficients for the loop invariants,
one per invariant.
DENOMINATOR is the denominator for all of the coefficients and constants in
- the expression.
+ the expression.
The linear expressions can be linked together using the NEXT field, in
order to represent MAX or MIN of a group of linear expressions. */
typedef struct lambda_linear_expression_s
#define LL_LINEAR_OFFSET(T) ((T)->linear_offset)
#define LL_STEP(T) ((T)->step)
-/* Loop nest structure.
+/* Loop nest structure.
The loop nest structure consists of a set of loop structures (defined
above) in LOOPS, along with an integer representing the DEPTH of the loop,
and an integer representing the number of INVARIANTS in the loop. Both of
void lambda_matrix_left_hermite (lambda_matrix, int, int, lambda_matrix, lambda_matrix);
void lambda_matrix_right_hermite (lambda_matrix, int, int, lambda_matrix, lambda_matrix);
int lambda_matrix_first_nz_vec (lambda_matrix, int, int, int);
-void lambda_matrix_project_to_null (lambda_matrix, int, int, int,
+void lambda_matrix_project_to_null (lambda_matrix, int, int, int,
lambda_vector);
void print_lambda_matrix (FILE *, lambda_matrix, int, int);
lambda_trans_matrix lambda_trans_matrix_padding (lambda_trans_matrix);
lambda_trans_matrix lambda_trans_matrix_inverse (lambda_trans_matrix);
void print_lambda_trans_matrix (FILE *, lambda_trans_matrix);
-void lambda_matrix_vector_mult (lambda_matrix, int, int, lambda_vector,
+void lambda_matrix_vector_mult (lambda_matrix, int, int, lambda_vector,
lambda_vector);
bool lambda_trans_matrix_id_p (lambda_trans_matrix);
struct obstack *);
void lambda_loopnest_to_gcc_loopnest (struct loop *,
VEC(tree,heap) *, VEC(tree,heap) *,
- VEC(tree,heap) **,
+ VEC(gimple,heap) **,
lambda_loopnest, lambda_trans_matrix,
struct obstack *);
-void remove_iv (tree);
+void remove_iv (gimple);
+tree find_induction_var_from_exit_cond (struct loop *);
static inline void lambda_vector_negate (lambda_vector, lambda_vector, int);
static inline void lambda_vector_mult_const (lambda_vector, lambda_vector, int, int);
/* Negate vector VEC1 with length SIZE and store it in VEC2. */
-static inline void
+static inline void
lambda_vector_negate (lambda_vector vec1, lambda_vector vec2,
int size)
{
/* Return true if vector VEC1 of length SIZE is the zero vector. */
-static inline bool
+static inline bool
lambda_vector_zerop (lambda_vector vec1, int size)
{
int i;
}
/* Return true if two vectors are equal. */
-
+
static inline bool
lambda_vector_equal (lambda_vector vec1, lambda_vector vec2, int size)
{
/* Multiply a vector by a matrix. */
static inline void
-lambda_vector_matrix_mult (lambda_vector vect, int m, lambda_matrix mat,
+lambda_vector_matrix_mult (lambda_vector vect, int m, lambda_matrix mat,
int n, lambda_vector dest)
{
int i, j;
dest[i] += mat[j][i] * vect[j];
}
+/* Compare two vectors returning an integer less than, equal to, or
+ greater than zero if the first argument is considered to be respectively
+ less than, equal to, or greater than the second.
+ We use the lexicographic order. */
+
+static inline int
+lambda_vector_compare (lambda_vector vec1, int length1, lambda_vector vec2,
+ int length2)
+{
+ int min_length;
+ int i;
+
+ if (length1 < length2)
+ min_length = length1;
+ else
+ min_length = length2;
+
+ for (i = 0; i < min_length; i++)
+ if (vec1[i] < vec2[i])
+ return -1;
+ else if (vec1[i] > vec2[i])
+ return 1;
+ else
+ continue;
+
+ return length1 - length2;
+}
/* Print out a vector VEC of length N to OUTFILE. */
/* Compute the greatest common divisor of two numbers using
Euclid's algorithm. */
-static inline int
+static inline int
gcd (int a, int b)
{
int x, y, z;
other words, when the first nonzero element is positive. */
static inline bool
-lambda_vector_lexico_pos (lambda_vector v,
+lambda_vector_lexico_pos (lambda_vector v,
unsigned n)
{
unsigned i;
}
#endif /* LAMBDA_H */
-