-/* CYGNUS LOCAL dependency analysis */
-
/* Analyze loop dependencies
Copyright (C) 2000 Free Software Foundation, Inc.
#include "system.h"
#include "rtl.h"
+#include "expr.h"
#include "tree.h"
#include "c-common.h"
#include "flags.h"
dependence to the dep_chain
*/
-enum dependence_type {flow, anti, output, none};
+enum dependence_type {dt_flow, dt_anti, dt_output, dt_none};
+#if 0
static const char * dependence_string [] = {"flow", "anti", "output", "none"};
-
+#endif
enum direction_type {lt, le, eq, gt, ge, star, independent, undef};
+#if 0
static const char * direction_string [] = {"<", "<=", "=", ">", ">=", "*",
"INDEPENDENT", "UNDEFINED"};
-
+#endif
enum def_use_type {def, use, init_def_use};
enum du_status_type {seen, unseen};
/* this expression */
tree expression;
/* our name */
- char *variable;
+ const char *variable;
/* def or use */
enum def_use_type type;
/* status flags */
typedef struct induction
{
/* our name */
- char *variable;
+ const char *variable;
/* increment. Currently only +1 or -1 */
int increment;
/* lower bound */
/* Y in X * i + Y */
int offset;
/* our name */
- char *variable;
+ const char *variable;
/* next subscript term. Currently null. */
struct subscript *next;
} subscript;
static void build_def_use PARAMS ((tree, enum def_use_type));
static loop* add_loop PARAMS ((tree, tree, int));
static int find_induction_variable PARAMS ((tree, tree, tree, loop*));
-static int get_low_bound PARAMS ((tree, char*));
-static int have_induction_variable PARAMS ((tree, char*));
+static int get_low_bound PARAMS ((tree, const char*));
+static int have_induction_variable PARAMS ((tree, const char*));
static void link_loops PARAMS ((void));
static void get_node_dependence PARAMS ((void));
static void check_node_dependence PARAMS ((def_use*));
static void normalize_coefficients PARAMS ((subscript[], loop*, int));
static void classify_dependence PARAMS ((subscript[], subscript[],
enum complexity_type[], int*, int));
-static void ziv_test PARAMS ((subscript[], subscript[], enum direction_type[][],
- int[][], loop*, int));
-static void siv_test PARAMS ((subscript[], subscript[], enum direction_type[][],
- int[][], loop*, int));
+static void ziv_test PARAMS ((subscript[], subscript[],
+ enum direction_type[][MAX_SUBSCRIPTS],
+ int[][MAX_SUBSCRIPTS], loop*, int));
+static void siv_test PARAMS ((subscript[], subscript[],
+ enum direction_type[][MAX_SUBSCRIPTS],
+ int[][MAX_SUBSCRIPTS], loop*, int));
static int check_subscript_induction PARAMS ((subscript*, subscript*, loop*));
-static void gcd_test PARAMS ((subscript[], subscript[], enum direction_type[][],
- int[][], loop*, int));
+static void gcd_test PARAMS ((subscript[], subscript[], enum
+ direction_type[][MAX_SUBSCRIPTS],
+ int[][MAX_SUBSCRIPTS], loop*, int));
static int find_gcd PARAMS ((int, int));
-static void merge_dependencies PARAMS ((enum direction_type[][], int[][], int, int));
+static void merge_dependencies PARAMS ((enum direction_type[][MAX_SUBSCRIPTS],
+ int[][MAX_SUBSCRIPTS], int, int));
static void dump_array_ref PARAMS ((tree));
+#if 0
static void dump_one_node PARAMS ((def_use*, varray_type*));
static void dump_node_dependence PARAMS ((void));
+#endif
int search_dependence PARAMS ((tree));
void remember_dest_for_dependence PARAMS ((tree));
int have_dependence_p PARAMS ((rtx, rtx, enum direction_type[], int[]));
if (TREE_CODE (TREE_OPERAND (cond_node, 0)) == VAR_DECL
&& IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (cond_node, 0)))
== ind_ptr->variable)
- if (TREE_CODE (TREE_OPERAND (cond_node, 1)) == INTEGER_CST)
- ind_ptr->high_bound = TREE_INT_CST_LOW (TREE_OPERAND (cond_node, 1));
- else
- ind_ptr->high_bound = ind_ptr->increment < 0 ? INT_MIN : INT_MAX;
+ {
+ if (TREE_CODE (TREE_OPERAND (cond_node, 1)) == INTEGER_CST)
+ ind_ptr->high_bound =
+ TREE_INT_CST_LOW (TREE_OPERAND (cond_node, 1));
+ else
+ ind_ptr->high_bound = ind_ptr->increment < 0 ? INT_MIN : INT_MAX;
+ }
else if (TREE_CODE (TREE_OPERAND (cond_node, 1)) == VAR_DECL
&& IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (cond_node, 1)))
== ind_ptr->variable)
- if (TREE_CODE (TREE_OPERAND (cond_node, 0)) == INTEGER_CST)
- ind_ptr->high_bound = TREE_INT_CST_LOW (TREE_OPERAND (cond_node, 0));
- else
- ind_ptr->high_bound = ind_ptr->increment < 0 ? INT_MIN : INT_MAX;
+ {
+ if (TREE_CODE (TREE_OPERAND (cond_node, 0)) == INTEGER_CST)
+ ind_ptr->high_bound =
+ TREE_INT_CST_LOW (TREE_OPERAND (cond_node, 0));
+ else
+ ind_ptr->high_bound = ind_ptr->increment < 0 ? INT_MIN : INT_MAX;
+ }
ind_ptr->next = 0;
return 1;
}
/* Return the low bound for induction VARIABLE in NODE */
-int
+static int
get_low_bound (node, variable)
tree node;
- char *variable;
+ const char *variable;
{
if (TREE_CODE (node) == SCOPE_STMT)
static int
have_induction_variable (outer_loop, ind_var)
tree outer_loop;
- char *ind_var;
+ const char *ind_var;
{
induction *ind_ptr;
loop *loop_ptr;
dep_ptr->next = 0;
if (def_ptr < use_ptr && use_ptr->type == use)
- dep_ptr->dependence = flow;
+ dep_ptr->dependence = dt_flow;
else if (def_ptr > use_ptr && use_ptr->type == use)
- dep_ptr->dependence = anti;
- else dep_ptr->dependence = output;
+ dep_ptr->dependence = dt_anti;
+ else dep_ptr->dependence = dt_output;
for (j = 1 ; j <= i - 1 ; j++)
{
if (direction[j][0] == gt)
{
- dep_ptr->dependence = anti;
+ dep_ptr->dependence = dt_anti;
direction[j][0] = lt;
distance[j][0] = -distance[j][0];
break;
}
else if (direction[j][0] == lt)
{
- dep_ptr->dependence = flow;
+ dep_ptr->dependence = dt_flow;
break;
}
}
dep_root_ptr = VARRAY_TOP (dep_chain, generic);
dep_root_ptr->source = 0;
dep_root_ptr->destination = def_ptr->expression;
- dep_root_ptr->dependence = none;
+ dep_root_ptr->dependence = dt_none;
dep_root_ptr->next = dep_ptr;
def_ptr->dep = dep_ptr;
}
}
else if (tree_op == MULT_EXPR)
{
- int value0, value1, value0_is_idx, value1_is_idx;
+ int value0, value1, value0_is_idx = 0, value1_is_idx = 0;
value0 = get_one_coefficient (TREE_OPERAND (node, 0), coefficients, du,
&tree_op_code);
/* Adjust the COEFFICIENTS as if loop LOOP_PTR were normalized to start at 0. */
-void
+static void
normalize_coefficients (coefficients, loop_ptr, count)
subscript coefficients [MAX_SUBSCRIPTS];
loop *loop_ptr;
int *separability;
int count;
{
- char *iiv_used [MAX_SUBSCRIPTS];
- char *oiv_used [MAX_SUBSCRIPTS];
+ const char *iiv_used [MAX_SUBSCRIPTS];
+ const char *oiv_used [MAX_SUBSCRIPTS];
int ocoeff [MAX_SUBSCRIPTS];
int icoeff [MAX_SUBSCRIPTS];
int idx, cidx;
subscript icoefficients [MAX_SUBSCRIPTS];
subscript ocoefficients [MAX_SUBSCRIPTS];
enum direction_type direction[MAX_SUBSCRIPTS][MAX_SUBSCRIPTS];
- int distance[MAX_SUBSCRIPTS][MAX_SUBSCRIPTS];
+ int distance[MAX_SUBSCRIPTS][MAX_SUBSCRIPTS] ATTRIBUTE_UNUSED;
loop *loop_ptr;
int sub;
{
- int idx;
-
if (ocoefficients[sub].offset !=
icoefficients[sub].offset)
- direction[loop_ptr->depth][idx] = independent;
+ direction[loop_ptr->depth][sub] = independent;
}
/* Determine the DIRECTION and DISTANCE dependency for subscript SUB of
subscript icoefficients [MAX_SUBSCRIPTS];
subscript ocoefficients [MAX_SUBSCRIPTS];
enum direction_type direction[MAX_SUBSCRIPTS][MAX_SUBSCRIPTS];
- int distance[MAX_SUBSCRIPTS][MAX_SUBSCRIPTS];
+ int distance[MAX_SUBSCRIPTS][MAX_SUBSCRIPTS] ATTRIBUTE_UNUSED;
loop *loop_ptr;
int sub;
{
int i, j;
int sign;
- enum direction_type direction_merge [8][8] =
+ static const enum direction_type direction_merge [8][8] =
{{lt, le, le, star, star, lt, independent, lt},
{le, le, le, star, star, le, independent, le},
{le, le, eq, ge, ge, eq, independent, eq},
/* Dump def/use DU. */
+#if 0
static void
dump_one_node (du, seen)
def_use *du;
}
VARRAY_FREE (seen);
}
+#endif
/* Return the index into 'dep_chain' if there is a dependency for destination
dest_to_remember (set by remember_dest_for_dependence) and source node.
enum direction_type direction[MAX_SUBSCRIPTS];
int distance[MAX_SUBSCRIPTS];
{
- int dest_idx, src_idx;
+ int dest_idx = 0, src_idx = 0;
rtx dest, src;
dependence *dep_ptr;
if (GET_CODE (SET_SRC (PATTERN (src_rtx))) == MEM)
{
src = SET_SRC (PATTERN (src_rtx));
- src_idx = MEM_DEPENDENCY (dest) - 1;
+ src_idx = MEM_DEPENDENCY (src) - 1;
}
if (dest_idx >= 0 || src_idx >= 0)
return 0;
/* Cleanup when dependency analysis is complete. */
void
-end_dependence_analysis (void)
+end_dependence_analysis ()
{
VARRAY_FREE (dep_chain);
}