]>
Commit | Line | Data |
---|---|---|
38a73435 | 1 | /* Misc range functions. |
a945c346 | 2 | Copyright (C) 2017-2024 Free Software Foundation, Inc. |
38a73435 AH |
3 | Contributed by Aldy Hernandez <aldyh@redhat.com>. |
4 | ||
5 | This file is part of GCC. | |
6 | ||
7 | GCC is free software; you can redistribute it and/or modify it under | |
8 | the terms of the GNU General Public License as published by the Free | |
9 | Software Foundation; either version 3, or (at your option) any later | |
10 | version. | |
11 | ||
12 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
13 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 | for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with GCC; see the file COPYING3. If not see | |
19 | <http://www.gnu.org/licenses/>. */ | |
20 | ||
21 | #include "config.h" | |
22 | #include "system.h" | |
23 | #include "coretypes.h" | |
24 | #include "backend.h" | |
25 | #include "tree.h" | |
26 | #include "gimple.h" | |
27 | #include "gimple-pretty-print.h" | |
28 | #include "fold-const.h" | |
29 | #include "ssa.h" | |
30 | #include "range.h" | |
31 | ||
028d81b1 | 32 | value_range |
38a73435 AH |
33 | range_zero (tree type) |
34 | { | |
cb779afe AH |
35 | wide_int zero = wi::zero (TYPE_PRECISION (type)); |
36 | return value_range (type, zero, zero); | |
38a73435 AH |
37 | } |
38 | ||
028d81b1 | 39 | value_range |
38a73435 AH |
40 | range_nonzero (tree type) |
41 | { | |
cb779afe AH |
42 | wide_int zero = wi::zero (TYPE_PRECISION (type)); |
43 | return value_range (type, zero, zero, VR_ANTI_RANGE); | |
38a73435 AH |
44 | } |
45 | ||
028d81b1 | 46 | value_range |
38a73435 AH |
47 | range_positives (tree type) |
48 | { | |
49 | unsigned prec = TYPE_PRECISION (type); | |
50 | signop sign = TYPE_SIGN (type); | |
028d81b1 | 51 | return value_range (type, wi::zero (prec), wi::max_value (prec, sign)); |
38a73435 AH |
52 | } |
53 | ||
028d81b1 | 54 | value_range |
38a73435 AH |
55 | range_negatives (tree type) |
56 | { | |
57 | unsigned prec = TYPE_PRECISION (type); | |
58 | signop sign = TYPE_SIGN (type); | |
028d81b1 | 59 | value_range r; |
38a73435 AH |
60 | if (sign == UNSIGNED) |
61 | r.set_undefined (); | |
62 | else | |
028d81b1 | 63 | r = value_range (type, wi::min_value (prec, sign), wi::minus_one (prec)); |
38a73435 AH |
64 | return r; |
65 | } |