1 /* Concrete_Expression class implementation (non-inline functions).
2 Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3 Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4
5 This file is part of the Parma Polyhedra Library (PPL).
6
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY 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 this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23
24 #include "ppl-config.h"
25 #include "Concrete_Expression_defs.hh"
26 #include <iostream>
27
28 namespace PPL = Parma_Polyhedra_Library;
29
30 bool
OK() const31 PPL::Concrete_Expression_Type::OK() const {
32 if (impl.bounded_integer) {
33 if (impl.bounded_integer_type_width != BITS_8
34 && impl.bounded_integer_type_width != BITS_16
35 && impl.bounded_integer_type_width != BITS_32
36 && impl.bounded_integer_type_width != BITS_64
37 && impl.bounded_integer_type_width != BITS_128) {
38 #ifndef NDEBUG
39 std::cerr << "bounded integer type has illegal width "
40 << impl.bounded_integer_type_width
41 << std::endl;
42 #endif
43 return false;
44 }
45
46 if (impl.bounded_integer_type_representation != UNSIGNED
47 && impl.bounded_integer_type_representation != SIGNED_2_COMPLEMENT) {
48 #ifndef NDEBUG
49 std::cerr << "bounded integer type has illegal representation "
50 << impl.bounded_integer_type_representation
51 << std::endl;
52 #endif
53 return false;
54 }
55
56 if (impl.bounded_integer_type_overflow != OVERFLOW_WRAPS
57 && impl.bounded_integer_type_overflow != OVERFLOW_UNDEFINED
58 && impl.bounded_integer_type_overflow != OVERFLOW_IMPOSSIBLE) {
59 #ifndef NDEBUG
60 std::cerr << "bounded integer type has illegal overflow "
61 << impl.bounded_integer_type_overflow
62 << std::endl;
63 #endif
64 return false;
65 }
66
67 if (impl.floating_point_format != IEEE754_HALF) {
68 #ifndef NDEBUG
69 std::cerr << "bounded integer type has illegal (unused) fp format "
70 << impl.floating_point_format
71 << std::endl;
72 #endif
73 return false;
74 }
75 }
76 else {
77 // Here we have impl.bounded_integer == false.
78 if (impl.floating_point_format != IEEE754_HALF
79 && impl.floating_point_format != IEEE754_SINGLE
80 && impl.floating_point_format != IEEE754_DOUBLE
81 && impl.floating_point_format != IBM_SINGLE
82 && impl.floating_point_format != IEEE754_QUAD
83 && impl.floating_point_format != INTEL_DOUBLE_EXTENDED) {
84 #ifndef NDEBUG
85 std::cerr << "floating point type has illegal format "
86 << impl.floating_point_format
87 << std::endl;
88 #endif
89 return false;
90 }
91
92 if (impl.bounded_integer_type_width != BITS_128) {
93 #ifdef NDEBUG
94 std::cerr << "floating point type has illegal (unused) bi width "
95 << impl.bounded_integer_type_width
96 << std::endl;
97 #endif
98 return false;
99 }
100
101 if (impl.bounded_integer_type_representation != SIGNED_2_COMPLEMENT) {
102 #ifndef NDEBUG
103 std::cerr << "floating point type has illegal (unused) bi representation "
104 << impl.bounded_integer_type_representation
105 << std::endl;
106 #endif
107 return false;
108 }
109
110 if (impl.bounded_integer_type_overflow != OVERFLOW_IMPOSSIBLE) {
111 #ifndef NDEBUG
112 std::cerr << "floating point type has illegal (unused) bi overflow "
113 << impl.bounded_integer_type_overflow
114 << std::endl;
115 #endif
116 return false;
117 }
118 }
119
120 // If we got here, everything is OK.
121 return true;
122 }
123