diff options
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index cd922e53c86..b1cbfac7f75 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -45,7 +45,17 @@ along with GCC; see the file COPYING3. If not see #include "coretypes.h" #include "tm.h" #include "flags.h" +#include "hash-set.h" +#include "machmode.h" +#include "vec.h" +#include "double-int.h" +#include "input.h" +#include "alias.h" +#include "symtab.h" +#include "wide-int.h" +#include "inchash.h" #include "tree.h" +#include "fold-const.h" #include "stor-layout.h" #include "calls.h" #include "tree-iterator.h" @@ -61,8 +71,6 @@ along with GCC; see the file COPYING3. If not see #include "predict.h" #include "vec.h" #include "hashtab.h" -#include "hash-set.h" -#include "machmode.h" #include "hard-reg-set.h" #include "input.h" #include "function.h" @@ -16214,3 +16222,27 @@ fold_strip_sign_ops (tree exp) } return NULL_TREE; } + +/* Return OFF converted to a pointer offset type suitable as offset for + POINTER_PLUS_EXPR. Use location LOC for this conversion. */ +tree +convert_to_ptrofftype_loc (location_t loc, tree off) +{ + return fold_convert_loc (loc, sizetype, off); +} + +/* Build and fold a POINTER_PLUS_EXPR at LOC offsetting PTR by OFF. */ +tree +fold_build_pointer_plus_loc (location_t loc, tree ptr, tree off) +{ + return fold_build2_loc (loc, POINTER_PLUS_EXPR, TREE_TYPE (ptr), + ptr, convert_to_ptrofftype_loc (loc, off)); +} + +/* Build and fold a POINTER_PLUS_EXPR at LOC offsetting PTR by OFF. */ +tree +fold_build_pointer_plus_hwi_loc (location_t loc, tree ptr, HOST_WIDE_INT off) +{ + return fold_build2_loc (loc, POINTER_PLUS_EXPR, TREE_TYPE (ptr), + ptr, size_int (off)); +} |