1*e4b17023SJohn Marino /* Operations with affine combinations of trees. 2*e4b17023SJohn Marino Copyright (C) 2005, 2007, 2008 Free Software Foundation, Inc. 3*e4b17023SJohn Marino 4*e4b17023SJohn Marino This file is part of GCC. 5*e4b17023SJohn Marino 6*e4b17023SJohn Marino GCC is free software; you can redistribute it and/or modify it 7*e4b17023SJohn Marino under the terms of the GNU General Public License as published by the 8*e4b17023SJohn Marino Free Software Foundation; either version 3, or (at your option) any 9*e4b17023SJohn Marino later version. 10*e4b17023SJohn Marino 11*e4b17023SJohn Marino GCC is distributed in the hope that it will be useful, but WITHOUT 12*e4b17023SJohn Marino ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13*e4b17023SJohn Marino FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14*e4b17023SJohn Marino for more details. 15*e4b17023SJohn Marino 16*e4b17023SJohn Marino You should have received a copy of the GNU General Public License 17*e4b17023SJohn Marino along with GCC; see the file COPYING3. If not see 18*e4b17023SJohn Marino <http://www.gnu.org/licenses/>. */ 19*e4b17023SJohn Marino 20*e4b17023SJohn Marino /* Affine combination of trees. We keep track of at most MAX_AFF_ELTS elements 21*e4b17023SJohn Marino to make things simpler; this is sufficient in most cases. */ 22*e4b17023SJohn Marino 23*e4b17023SJohn Marino #define MAX_AFF_ELTS 8 24*e4b17023SJohn Marino 25*e4b17023SJohn Marino /* Element of an affine combination. */ 26*e4b17023SJohn Marino 27*e4b17023SJohn Marino struct aff_comb_elt 28*e4b17023SJohn Marino { 29*e4b17023SJohn Marino /* The value of the element. */ 30*e4b17023SJohn Marino tree val; 31*e4b17023SJohn Marino 32*e4b17023SJohn Marino /* Its coefficient in the combination. */ 33*e4b17023SJohn Marino double_int coef; 34*e4b17023SJohn Marino }; 35*e4b17023SJohn Marino 36*e4b17023SJohn Marino typedef struct affine_tree_combination 37*e4b17023SJohn Marino { 38*e4b17023SJohn Marino /* Type of the result of the combination. */ 39*e4b17023SJohn Marino tree type; 40*e4b17023SJohn Marino 41*e4b17023SJohn Marino /* Constant offset. */ 42*e4b17023SJohn Marino double_int offset; 43*e4b17023SJohn Marino 44*e4b17023SJohn Marino /* Number of elements of the combination. */ 45*e4b17023SJohn Marino unsigned n; 46*e4b17023SJohn Marino 47*e4b17023SJohn Marino /* Elements and their coefficients. Type of elements may be different from 48*e4b17023SJohn Marino TYPE, but their sizes must be the same (STRIP_NOPS is applied to the 49*e4b17023SJohn Marino elements). 50*e4b17023SJohn Marino 51*e4b17023SJohn Marino The coefficients are always sign extended from the precision of TYPE 52*e4b17023SJohn Marino (regardless of signedness of TYPE). */ 53*e4b17023SJohn Marino struct aff_comb_elt elts[MAX_AFF_ELTS]; 54*e4b17023SJohn Marino 55*e4b17023SJohn Marino /* Remainder of the expression. Usually NULL, used only if there are more 56*e4b17023SJohn Marino than MAX_AFF_ELTS elements. Type of REST will be either sizetype for 57*e4b17023SJohn Marino TYPE of POINTER_TYPEs or TYPE. */ 58*e4b17023SJohn Marino tree rest; 59*e4b17023SJohn Marino } aff_tree; 60*e4b17023SJohn Marino 61*e4b17023SJohn Marino double_int double_int_ext_for_comb (double_int, aff_tree *); 62*e4b17023SJohn Marino void aff_combination_const (aff_tree *, tree, double_int); 63*e4b17023SJohn Marino void aff_combination_elt (aff_tree *, tree, tree); 64*e4b17023SJohn Marino void aff_combination_scale (aff_tree *, double_int); 65*e4b17023SJohn Marino void aff_combination_mult (aff_tree *, aff_tree *, aff_tree *); 66*e4b17023SJohn Marino void aff_combination_add (aff_tree *, aff_tree *); 67*e4b17023SJohn Marino void aff_combination_add_elt (aff_tree *, tree, double_int); 68*e4b17023SJohn Marino void aff_combination_remove_elt (aff_tree *, unsigned); 69*e4b17023SJohn Marino void aff_combination_convert (aff_tree *, tree); 70*e4b17023SJohn Marino void tree_to_aff_combination (tree, tree, aff_tree *); 71*e4b17023SJohn Marino tree aff_combination_to_tree (aff_tree *); 72*e4b17023SJohn Marino void unshare_aff_combination (aff_tree *); 73*e4b17023SJohn Marino bool aff_combination_constant_multiple_p (aff_tree *, aff_tree *, double_int *); 74*e4b17023SJohn Marino void aff_combination_expand (aff_tree *, struct pointer_map_t **); 75*e4b17023SJohn Marino void tree_to_aff_combination_expand (tree, tree, aff_tree *, 76*e4b17023SJohn Marino struct pointer_map_t **); 77*e4b17023SJohn Marino void get_inner_reference_aff (tree, aff_tree *, double_int *); 78*e4b17023SJohn Marino void free_affine_expand_cache (struct pointer_map_t **); 79*e4b17023SJohn Marino bool aff_comb_cannot_overlap_p (aff_tree *, double_int, double_int); 80*e4b17023SJohn Marino 81*e4b17023SJohn Marino /* Debugging functions. */ 82*e4b17023SJohn Marino void print_aff (FILE *, aff_tree *); 83*e4b17023SJohn Marino void debug_aff (aff_tree *); 84