GCC Middle and Back End API Reference
symbolic-scalars.h
Go to the documentation of this file.
1/* Unit-safe symbolic scalar values (e.g. "n * 32 bytes")
2 Copyright (C) 2026 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it
8under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 3, or (at your option)
10any later version.
11
12GCC is distributed in the hope that it will be useful, but
13WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
20
21#ifndef GCC_ANALYZER_SYMBOLIC_SCALARS_H
22#define GCC_ANALYZER_SYMBOLIC_SCALARS_H
23
24#include "analyzer/units.h"
27
28namespace ana {
29namespace symbolic {
30
31template<typename ConcreteValueType>
32class scalar_manager;
33
34template<typename ConcreteValueType>
35class concrete_scalar;
36
37template<typename ConcreteValueType>
38class sum;
39
40template<typename ConcreteValueType>
41class product;
42
43template<typename ConcreteValueType>
45
46template<typename ConcreteValueType>
48
50
51/* symbolic::scalar
52
53 The class hierarchy looks like this (using indentation to show
54 inheritance):
55
56 scalar: abstract base class
57 concrete: a value of ConcreteValueType
58 sum: the sum of two of more scalars
59 product: the product of a scalar and a dimensionless scalar
60 scalar_from_svalue: a scalar derived from an svalue
61 named_test: a placeholder for use in selftests
62 bits_from_bytes_scalar: converting a scalar measured in bits
63 into one measured in bytes. */
64
65template<typename ConcreteValueType>
67{
68public:
69 enum class kind
70 {
74 from_svalue,
75 named_test,
77 };
78
79 virtual ~scalar () = default;
80
82 get_mgr () const { return m_mgr; }
83
84 enum kind get_kind () const { return m_kind; }
85
87 dyn_cast_concrete_scalar () const { return nullptr; }
88 virtual const sum<ConcreteValueType> *
89 dyn_cast_sum () const { return nullptr; }
90 virtual const product<ConcreteValueType> *
91 dyn_cast_product () const { return nullptr; }
93 dyn_cast_scalar_from_svalue () const { return nullptr; }
94 virtual const bits_from_bytes_scalar *
95 dyn_cast_bits_from_bytes_scalar () const { return nullptr; }
96
97 virtual void
99
102 void *user_data),
103 void *) const final override
104 {
106 }
107
108 const char *
109 get_any_dump_color () const override { return "scalar"; }
110
111 bool
112 is_zero_p () const;
113
114 bool
115 is_one_p () const;
116
117 bool
118 is_unknown_p () const;
119
120 // FIXME: unit test these
121 static bool
123 enum tree_code op,
125 const region_model *model);
126 static tristate
128 enum tree_code op,
130 const region_model *model);
131 // FIXME: unit test these
132 // FIXME: add notes on the semantics of these comparisons
133 bool
135 {
136 return get_total_ordering (*this, EQ_EXPR, other, nullptr);
137 }
138 bool
140 {
141 return get_total_ordering (*this, NE_EXPR, other, nullptr);
142 }
143 bool
144 operator< (const scalar<ConcreteValueType> &other) const
145 {
146 return get_total_ordering (*this, LT_EXPR, other, nullptr);
147 }
148 bool
149 operator<= (const scalar<ConcreteValueType> &other) const
150 {
151 return get_total_ordering (*this, LE_EXPR, other, nullptr);
152 }
153 bool
155 {
156 return get_total_ordering (*this, GT_EXPR, other, nullptr);
157 }
158 bool
160 {
161 return get_total_ordering (*this, GE_EXPR, other, nullptr);
162 }
163
164protected:
166 enum kind kind)
167 : value_node (c, id),
168 m_mgr (mgr),
169 m_kind (kind)
170 {
171 }
172
173 std::unique_ptr<json::object>
174 make_json_obj (const char *type_name) const;
175
176private:
177 void
178 print_dump_widget_label (pretty_printer *pp) const final override;
179
180 virtual void
182
185};
186
187} // namespace symbolic
188
189/* Abbreviations for various useful symbolic::scalar types. */
190
192
195
198
199namespace symbolic {
200
201/* Symbolic value wrapping a concrete scalar. */
202
203template<typename ConcreteValueType>
204class concrete_scalar : public scalar<ConcreteValueType>
205{
206public:
208 dyn_cast_concrete_scalar () const final override { return this; }
209
210 concrete_scalar (unsigned id,
212 const ConcreteValueType &value);
213
214 const ConcreteValueType &
215 get_concrete () const { return m_value; }
216
217 const integer &
218 get_integer () const;
219
220 void
221 accept_node_visitor (node_visitor &v) const final override;
222
223 std::unique_ptr<json::object>
224 to_json () const final override;
225
226 void
227 dump_inline_to_pp (pretty_printer *pp, enum units::role) const final override;
228
229 std::unique_ptr<diagnostics::markup::node>
230 make_markup_node (markup_context &markup_ctxt) const final override;
231
232private:
233 void
235
236 void
238 node_dump_state &nds) const final override;
239
240 ConcreteValueType m_value;
241};
242
243/* Symbolic value for the sum of two of more scalars.
244
245 Consolidation/canonicalization:
246 - we never have a sum as an addend of another sum
247 (we flatten sums of sums)
248 - a sum is expressed as a sum of one or more non-concrete_scalars,
249 plus an optional concrete_scalar; the latter is the null pointer iff
250 the concrete addends sum to zero.
251 - we must have at least two addends (two or more symbolic, or a concrete
252 and one or more symbolic). */
253
254template<typename ConcreteValueType>
255class sum : public scalar<ConcreteValueType>
256{
257public:
259 {
260 std::vector<const scalar<ConcreteValueType> *> m_addends;
261
262 bool operator< (const memoization_key &other) const;
263 };
264
265 /* A helper class for canonicalizing sums in the form:
266 (v1 * f1) + (v2 * f2) + .... (vN * fN) + CST
267 i.e. as a pair of maps from:
268 key: v1 ... vN
269 to
270 value: f1 ... fN
271 (one map for where the coefficients have units, and another
272 for where they are unitless), plus a constant of CVT.
273
274 For example, given
275 | 3x + 4y + 5 - (2x + 5y + 6)
276 | => (x * 3) + (y * 4) + 5 - ((x * 2) + (y * 5) + 6)
277 | => (x * 3) + (y * 4) + 5 + ((x * -2) + (y * -5) + -6)
278 | => (x * 3) + (y * 4) + 5 + ((x * -2) + (y * -5) + -6)
279 we canonicalize/fold the addends thus:
280 | => ({} + 0) + (x * 3) + (y * 4) + 5 + ((x * -2) + (y * -5) + -6)
281 | => ({x: 3} + 0}) + (y * 4) + 5 + ((x * -2) + (y * -5) + -6)
282 | => ({x: 3, y: 4} + 0) + 5 + ((x * -2) + (y * -5) + -6)
283 | => ({x: 3, y: 4} + 5) + ((x * -2) + (y * -5) + -6)
284 | => ({x: 1, y: 4} + 5) + (y * -5) + -6)
285 | => ({x: 1, y: -1} + 5) + -6)
286 | => ({x: 1, y: -1} + -1)
287 from which we can get this:
288 | => x + (y * -1) + -1
289 i.e. sum(x, product(y, -1), -1). */
291 {
293
294 void
296 scalar_manager<integer> &unitless_mgr);
297
298 /* Add (FACTOR_WITH_UNIT * UNITLESS_FACTOR) to the sum. */
299 void
301 (const scalar<ConcreteValueType> *factor_with_unit,
302 const scalar<integer> *unitless_factor);
303
304 void
305 dump () const;
306
307 std::unique_ptr<text_art::tree_widget>
309
310 /* Maps from unfoldable symbolic addend to symbolic factor for that
311 addend. This is the "(v1 * f1) + (v2 * f2) + .... (vN * fN)"
312 from above, i.e "{v1: f1, v2: f2, ..., vN: fN}".
313 Note that the coefficient can be zero for cases such as "X + (-X)".
314 We'll discard these when we build the creation_key.
315
316 We have two maps:
317
318 (a) a map in which the terms have units and the
319 coefficients are unitless, e.g.
320 (N bytes * 16) + (N bytes * -4), and
321
322 (b) a map in which the coefficents have units and the
323 terms are unitless, e.g.
324 (16 bytes * N) + (-4 bytes * N)
325
326 We try to use concrete factors as coefficients, and
327 purely symbolic factors as "terms". */
328
329 std::map<const scalar<ConcreteValueType> *,
330 const scalar<integer> *>
332 /* e.g. {'N bytes': 12}. */
333
334 std::map<const scalar<integer> *,
337 /* e.g. {'N': 12 bytes}. */
338
339 /* This is the " + CST" from above. */
340 ConcreteValueType m_sum_of_concrete_values;
341 };
342
343 /* The second phase of canonicalization: arrange these into a vector
344 of terms, dropping any terms with a factor == 0. */
346 {
347 struct term
348 {
351
352 bool operator< (const term &other) const;
353 bool operator== (const term &other) const;
354
357
358 std::unique_ptr<text_art::tree_widget>
360 };
361
363
364 bool operator< (const creation_key &other) const;
365
368
371
374
375 void
376 dump () const;
377
378 std::unique_ptr<text_art::tree_widget>
380
381 std::vector<term> m_symbolic_terms;
382 ConcreteValueType m_concrete_term;
383 };
384
385 sum (unsigned id,
387 const creation_key &k);
388
390 dyn_cast_sum () const final override { return this; }
391
392 size_t
394 {
395 return m_symbolic_addends.size ();
396 }
397
399 get_symbolic_addend (size_t idx) const { return *m_symbolic_addends[idx]; }
400
403 {
404 return m_concrete_addend;
405 }
406
407 const ConcreteValueType *
409 {
411 return &m_concrete_addend->get_concrete ();
412 else
413 return nullptr;
414 }
415
416 void
417 accept_node_visitor (node_visitor &v) const final override;
418
419 std::unique_ptr<json::object>
420 to_json () const final override;
421
422 void
423 dump_inline_to_pp (pretty_printer *pp, enum units::role) const final override;
424
425 std::unique_ptr<diagnostics::markup::node>
426 make_markup_node (markup_context &markup_ctxt) const final override;
427
428private:
429 void
431
432 void
434 node_dump_state &nds) const final override;
435
436 std::vector<const scalar<ConcreteValueType> *> m_symbolic_addends;
437
438 // non-null if nonzero; null if zero:
439 const concrete_scalar<ConcreteValueType> *m_concrete_addend;
440};
441
442/* Symbolic value for a scalar (perhaps with a unit, perhaps dimensionless)
443 scaled by a dimensionless factor.
444
445 Consolidation/canonicalization:
446 - X units * 0 --> 0 units
447 - 0 units * Y --> 0 units
448 - X units * 1 --> X units
449 - we never have a product of two concrete_scalar (we fold this). */
450
451template<typename ConcreteValueType>
452class product : public scalar<ConcreteValueType>
453{
454public:
455 struct key
456 {
457 bool operator< (const key &other) const;
458
461
463
466 };
467
468 product (unsigned id,
470 const key &k);
471
473 dyn_cast_product () const final override { return this; }
474
476 get_lhs () const { return m_lhs; }
477
478 const scalar<integer> &
479 get_rhs () const { return m_rhs; }
480
481 void
482 accept_node_visitor (node_visitor &v) const final override;
483
484 std::unique_ptr<json::object>
485 to_json () const final override;
486
487 void
488 dump_inline_to_pp (pretty_printer *pp, enum units::role) const final override;
489
490 std::unique_ptr<diagnostics::markup::node>
491 make_markup_node (markup_context &markup_ctxt) const final override;
492
493private:
494 void
496
497 void
499 node_dump_state &nds) const final override;
500
501 const scalar<ConcreteValueType> &m_lhs;
503};
504
505/* Concrete subclass of symbolic::scalar for a scalar derived from an svalue
506 for when folding isn't possible.
507
508 Consolidation/canonicalization:
509 - if the svalue is a constant_svalue, it is not an INTEGER_CST (we
510 fold such scalars to concrete_scalar). */
511
512template<typename ConcreteValueType>
513class scalar_from_svalue : public scalar<ConcreteValueType>
514{
515public:
516 struct key
517 {
518 bool operator< (const key &other) const;
519
522
524 };
525
526 scalar_from_svalue (unsigned id,
528 const key &k);
529
531 dyn_cast_scalar_from_svalue () const final override { return this; }
532
533 const svalue &
534 get_svalue () const { return m_sval; }
535
536 void
537 accept_node_visitor (node_visitor &v) const final override;
538
539 std::unique_ptr<json::object>
540 to_json () const final override;
541
542 void
543 dump_inline_to_pp (pretty_printer *pp, enum units::role) const final override;
544
545 std::unique_ptr<diagnostics::markup::node>
546 make_markup_node (markup_context &markup_ctxt) const final override;
547
548private:
549 void
551
552 void
554 node_dump_state &nds) const final override;
555
557};
558
559/* A named scalar for use in unit tests: cannot be folded. */
560
561#if CHECKING_P
562
563template<typename ConcreteValueType>
564class named_test_scalar : public scalar<ConcreteValueType>
565{
566public:
567 named_test_scalar (scalar_manager<ConcreteValueType> &mgr,
568 std::string name)
570 mgr.alloc_node_id (),
571 mgr,
573 m_name (std::move (name))
574 {
575 }
576
577 void
578 accept_node_visitor (node_visitor &v) const final override;
579
580 std::unique_ptr<json::object>
581 to_json () const final override;
582
583 void
584 dump_inline_to_pp (pretty_printer *pp, enum units::role) const final override;
585
586 std::unique_ptr<diagnostics::markup::node>
587 make_markup_node (markup_context &markup_ctxt) const final override;
588
589private:
590 void
591 print_dump_widget_label_for_scalar (pretty_printer *pp) const final override;
592
593 void
595 node_dump_state &nds) const final override;
596
597 std::string m_name;
598};
599
600#endif /* #if CHECKING_P */
601
602/* Concrete subclass of symbolic::scalar for when we can't fold
603 a conversion from bytes to bits.
604
605 Consolidation/canonicalization:
606 - m_bytes is not a concrete_scalar.
607 - m_bytes is not is_unknown_p (). */
608
610{
611public:
612 struct key
613 {
614 bool operator< (const key &other) const;
615
618
620 };
621
624 const key &k);
625
627 dyn_cast_bits_from_bytes_scalar () const final override { return this; }
628
629 void
630 accept_node_visitor (node_visitor &v) const final override;
631
632 std::unique_ptr<json::object>
633 to_json () const final override;
634
635 void
636 dump_inline_to_pp (pretty_printer *pp, enum units::role) const final override;
637
638 std::unique_ptr<diagnostics::markup::node>
639 make_markup_node (markup_context &markup_ctxt) const final override;
640
641 const symbolic_byte_size &
642 get_bytes () const { return m_bytes; }
643
644private:
645 void
647
648 void
650 node_dump_state &nds) const final override;
651
653};
654
655/* A class with responsibility for allocating/consolidating
656 scalar<ConcreteValueType> instances. */
657
658template<typename ConcreteValueType>
660{
661public:
663 : m_node_mgr (node_mgr)
664 {
665 }
666
667 /* Make sure we don't accidentally copy these. */
668 scalar_manager (const scalar_manager &) = delete;
669
671 get_concrete (const ConcreteValueType &value);
672
674 get_sum (std::vector<const scalar<ConcreteValueType> *> addends);
675
678 const scalar<ConcreteValueType> &rhs);
679
682
685 const scalar<integer> &factor);
686
689
690 const symbolic_bit_size &
692
695
696#if CHECKING_P
698 get_named_test_scalar (std::string name);
699#endif
700
701 unsigned
702 alloc_node_id () { return m_node_mgr.alloc_node_id (); }
703
706
709
710private:
711 /* Explicitly adding units to a unitless value. */
713 maybe_from_unitless (const ConcreteValueType &concrete_lhs,
714 const scalar<integer> &unitless_rhs);
715
717 maybe_from_unitless_for_unit (const ConcreteValueType &concrete_lhs,
718 const scalar<integer> &unitless_rhs);
719
723
726
729
730 const symbolic_bit_size *
732
734
735 std::map<ConcreteValueType,
736 std::unique_ptr<const concrete_scalar<ConcreteValueType>>> m_concrete_map;
737
738 std::map<typename sum<ConcreteValueType>::memoization_key,
740 std::map<typename sum<ConcreteValueType>::creation_key,
741 std::unique_ptr<scalar<ConcreteValueType>>> m_sum_map;
742 std::map<typename product<ConcreteValueType>::key,
743 std::unique_ptr<const product<ConcreteValueType>>> m_product_map;
744 std::map<typename scalar_from_svalue<ConcreteValueType>::key,
745 std::unique_ptr<const scalar_from_svalue<ConcreteValueType>>> m_scalar_from_svalue_map;
746 std::map<typename bits_from_bytes_scalar::key,
747 std::unique_ptr<bits_from_bytes_scalar>> m_bits_from_bytes_map;
748
749#if CHECKING_P
750 std::vector<std::unique_ptr<named_test_scalar<ConcreteValueType>>>
751 m_named_test_scalars;
752#endif
753};
754
755/* A bundle of scalar_manager<CVT> singletons for each of the various
756 concrete value types we care about. */
757
795
796template<>
797const symbolic_bit_size &
800
801} // namespace ana::symbolic
802
803/* Overloaded operators. */
804
805/* Addition. */
806
807/* symbolic + symbolic -> symbolic. */
808
809template<typename ConcreteValueType>
813{
814 return lhs.get_mgr ().get_sum ({&lhs, &rhs});
815}
816
817/* symbolic + concrete -> symbolic. */
818
819template<typename ConcreteValueType>
820const symbolic::scalar<ConcreteValueType> &
822 const ConcreteValueType &rhs)
823{
824 auto &mgr = lhs.get_mgr ();
825 return mgr.get_sum ({&lhs, &mgr.get_concrete (rhs)});
826}
827
828/* Negation. */
829
830template<typename ConcreteValueType>
831const symbolic::scalar<ConcreteValueType> &
833{
834 auto &mgr = i.get_mgr ();
835 return mgr.get_negation (i);
836}
837
838/* Subtraction. */
839
840/* symbolic - symbolic -> symbolic. */
841
842template<typename ConcreteValueType>
843const symbolic::scalar<ConcreteValueType> &
846{
847 return lhs.get_mgr ().get_difference (lhs, rhs);
848}
849
850/* symbolic - concrete -> symbolic. */
851
852template<typename ConcreteValueType>
853const symbolic::scalar<ConcreteValueType> &
855 const ConcreteValueType &rhs)
856{
857 auto &mgr = lhs.get_mgr ();
858 return mgr.get_difference (lhs, mgr.get_concrete (rhs));
859}
860
861/* symbolic * symbolic_integer -> symbolic. */
862
863template<typename ConcreteValueType>
864const symbolic::scalar<ConcreteValueType> &
866 const symbolic::scalar<integer> &rhs)
867{
868 return lhs.get_mgr ().get_product (lhs, rhs);
869}
870
871inline const symbolic_bit_size &
873{
874 auto &bit_mgr
875 = bytes.get_mgr ().get_node_manager ().get_scalars ().get_bits ();
876 return bit_mgr.get_bits_from_bytes (bytes);
877}
878
879const symbolic_byte_size *
881
882template <typename ConcreteValueType>
883inline bool
885 ConcreteValueType *out)
886{
887 if (auto *concrete = in.dyn_cast_concrete_scalar ())
888 {
889 *out = concrete->get_concrete ();
890 return true;
891 }
892 return false;
893}
894
895template <typename ConcreteValueType>
896inline const symbolic::scalar<ConcreteValueType> &
897symbolic_from_concrete (const ConcreteValueType &in,
899{
900 return mgr.get_concrete (in);
901}
902
903} // namespace ana
904
905#endif /* GCC_ANALYZER_SYMBOLIC_SCALARS_H */
Definition integer.h:36
Definition region-model.h:289
Definition svalue.h:82
Definition symbolic-scalars.h:610
std::unique_ptr< json::object > to_json() const final override
void print_dump_widget_label_for_scalar(pretty_printer *pp) const final override
void dump_inline_to_pp(pretty_printer *pp, enum units::role) const final override
const symbolic_byte_size & m_bytes
Definition symbolic-scalars.h:652
bits_from_bytes_scalar(unsigned id, scalar_manager< concrete_bit_size > &mgr, const key &k)
const bits_from_bytes_scalar * dyn_cast_bits_from_bytes_scalar() const final override
Definition symbolic-scalars.h:627
void add_dump_widget_children(text_art::tree_widget &, node_dump_state &nds) const final override
const symbolic_byte_size & get_bytes() const
Definition symbolic-scalars.h:642
std::unique_ptr< diagnostics::markup::node > make_markup_node(markup_context &markup_ctxt) const final override
void accept_node_visitor(node_visitor &v) const final override
Definition symbolic-scalars.h:205
std::unique_ptr< json::object > to_json() const final override
concrete_scalar(unsigned id, scalar_manager< ConcreteValueType > &mgr, const ConcreteValueType &value)
const ConcreteValueType & get_concrete() const
Definition symbolic-scalars.h:215
const integer & get_integer() const
const concrete_scalar< ConcreteValueType > * dyn_cast_concrete_scalar() const final override
Definition symbolic-scalars.h:208
ConcreteValueType m_value
Definition symbolic-scalars.h:240
std::unique_ptr< diagnostics::markup::node > make_markup_node(markup_context &markup_ctxt) const final override
void add_dump_widget_children(text_art::tree_widget &, node_dump_state &nds) const final override
void accept_node_visitor(node_visitor &v) const final override
void print_dump_widget_label_for_scalar(pretty_printer *pp) const final override
void dump_inline_to_pp(pretty_printer *pp, enum units::role) const final override
Definition symbolic-nodes.h:48
Definition symbolic-nodes.h:502
Definition symbolic-scalars.h:47
Definition symbolic-scalars.h:453
const scalar< integer > & m_rhs
Definition symbolic-scalars.h:502
const scalar< ConcreteValueType > & get_lhs() const
Definition symbolic-scalars.h:476
const scalar< ConcreteValueType > & m_lhs
Definition symbolic-scalars.h:501
const product< ConcreteValueType > * dyn_cast_product() const final override
Definition symbolic-scalars.h:473
product(unsigned id, scalar_manager< ConcreteValueType > &mgr, const key &k)
const scalar< integer > & get_rhs() const
Definition symbolic-scalars.h:479
void accept_node_visitor(node_visitor &v) const final override
std::unique_ptr< json::object > to_json() const final override
void add_dump_widget_children(text_art::tree_widget &, node_dump_state &nds) const final override
void dump_inline_to_pp(pretty_printer *pp, enum units::role) const final override
std::unique_ptr< diagnostics::markup::node > make_markup_node(markup_context &markup_ctxt) const final override
void print_dump_widget_label_for_scalar(pretty_printer *pp) const final override
Definition symbolic-scalars.h:514
std::unique_ptr< diagnostics::markup::node > make_markup_node(markup_context &markup_ctxt) const final override
const svalue & get_svalue() const
Definition symbolic-scalars.h:534
void add_dump_widget_children(text_art::tree_widget &, node_dump_state &nds) const final override
void dump_inline_to_pp(pretty_printer *pp, enum units::role) const final override
std::unique_ptr< json::object > to_json() const final override
const svalue & m_sval
Definition symbolic-scalars.h:556
const scalar_from_svalue< ConcreteValueType > * dyn_cast_scalar_from_svalue() const final override
Definition symbolic-scalars.h:531
void print_dump_widget_label_for_scalar(pretty_printer *pp) const final override
void accept_node_visitor(node_visitor &v) const final override
scalar_from_svalue(unsigned id, scalar_manager< ConcreteValueType > &mgr, const key &k)
Definition symbolic-scalars.h:660
const scalar< ConcreteValueType > & get_sum_unmemoized(const sum_memoization_key &memo_key)
const scalar< ConcreteValueType > * maybe_fold_scalar_from_svalue(const typename scalar_from_svalue< ConcreteValueType >::key &k)
const scalar< ConcreteValueType > & get_difference(const scalar< ConcreteValueType > &lhs, const scalar< ConcreteValueType > &rhs)
std::map< typename sum< ConcreteValueType >::memoization_key, const scalar< ConcreteValueType > * > m_memoized_sums
Definition symbolic-scalars.h:739
const scalar< ConcreteValueType > & get_negation(const scalar< ConcreteValueType > &s)
const scalar< ConcreteValueType > & get_scalar_from_svalue(const svalue &sval)
node_manager & m_node_mgr
Definition symbolic-scalars.h:733
const scalar< ConcreteValueType > * maybe_from_unitless(const ConcreteValueType &concrete_lhs, const scalar< integer > &unitless_rhs)
unsigned alloc_node_id()
Definition symbolic-scalars.h:702
std::map< typename sum< ConcreteValueType >::creation_key, std::unique_ptr< scalar< ConcreteValueType > > > m_sum_map
Definition symbolic-scalars.h:741
const scalar< ConcreteValueType > & get_unknown()
const symbolic_bit_size & get_bits_from_bytes(const symbolic_byte_size &bytes)
const scalar< ConcreteValueType > & get_sum(std::vector< const scalar< ConcreteValueType > * > addends)
const concrete_scalar< ConcreteValueType > & get_concrete(const ConcreteValueType &value)
std::map< typename product< ConcreteValueType >::key, std::unique_ptr< const product< ConcreteValueType > > > m_product_map
Definition symbolic-scalars.h:743
scalar_manager(const scalar_manager &)=delete
const symbolic_bit_size * maybe_fold_bits_from_bytes(const symbolic_byte_size &bytes)
typename sum< ConcreteValueType >::memoization_key sum_memoization_key
Definition symbolic-scalars.h:720
std::map< typename scalar_from_svalue< ConcreteValueType >::key, std::unique_ptr< const scalar_from_svalue< ConcreteValueType > > > m_scalar_from_svalue_map
Definition symbolic-scalars.h:745
scalar_manager(node_manager &node_mgr)
Definition symbolic-scalars.h:662
const scalar< ConcreteValueType > * maybe_from_unitless_for_unit(const ConcreteValueType &concrete_lhs, const scalar< integer > &unitless_rhs)
std::map< ConcreteValueType, std::unique_ptr< const concrete_scalar< ConcreteValueType > > > m_concrete_map
Definition symbolic-scalars.h:736
scalar_manager< integer > & get_unitless_manager()
const scalar< ConcreteValueType > & get_product(const scalar< ConcreteValueType > &lhs, const scalar< integer > &factor)
std::map< typename bits_from_bytes_scalar::key, std::unique_ptr< bits_from_bytes_scalar > > m_bits_from_bytes_map
Definition symbolic-scalars.h:747
const scalar< ConcreteValueType > * maybe_fold_product(const typename product< ConcreteValueType >::key &k)
node_manager & get_node_manager()
Definition symbolic-scalars.h:705
scalar_manager< integer > m_unitless_mgr
Definition symbolic-scalars.h:793
scalar_managers(node_manager &node_mgr)
Definition symbolic-scalars.h:761
scalar_manager< integer_with_unit< units::byte > > m_byte_mgr
Definition symbolic-scalars.h:792
scalar_manager< integer > & get_unitless()
Definition symbolic-scalars.h:781
scalar_manager< ConcreteValueType > & get_manager()
scalar_manager< integer_with_unit< units::byte > > & get_bytes()
Definition symbolic-scalars.h:775
scalar_manager< integer_with_unit< units::bit > > m_bit_mgr
Definition symbolic-scalars.h:791
scalar_manager< integer_with_unit< units::bit > > & get_bits()
Definition symbolic-scalars.h:769
Definition symbolic-scalars.h:67
void print_dump_widget_label(pretty_printer *pp) const final override
bool operator>=(const scalar< ConcreteValueType > &other) const
Definition symbolic-scalars.h:159
virtual void print_dump_widget_label_for_scalar(pretty_printer *pp) const =0
bool operator<(const scalar< ConcreteValueType > &other) const
Definition symbolic-scalars.h:144
bool is_zero_p() const
bool operator==(const scalar< ConcreteValueType > &other) const
Definition symbolic-scalars.h:134
virtual void dump_inline_to_pp(pretty_printer *pp, enum units::role) const =0
scalar(complexity c, unsigned id, scalar_manager< ConcreteValueType > &mgr, enum kind kind)
Definition symbolic-scalars.h:165
enum kind get_kind() const
Definition symbolic-scalars.h:84
enum kind m_kind
Definition symbolic-scalars.h:184
bool operator<=(const scalar< ConcreteValueType > &other) const
Definition symbolic-scalars.h:149
bool is_unknown_p() const
virtual const bits_from_bytes_scalar * dyn_cast_bits_from_bytes_scalar() const
Definition symbolic-scalars.h:95
virtual ~scalar()=default
virtual const scalar_from_svalue< ConcreteValueType > * dyn_cast_scalar_from_svalue() const
Definition symbolic-scalars.h:93
const char * get_any_dump_color() const override
Definition symbolic-scalars.h:109
scalar_manager< integer_with_unit< units::bit > > & m_mgr
Definition symbolic-scalars.h:183
virtual const product< ConcreteValueType > * dyn_cast_product() const
Definition symbolic-scalars.h:91
std::unique_ptr< json::object > make_json_obj(const char *type_name) const
bool operator!=(const scalar< ConcreteValueType > &other) const
Definition symbolic-scalars.h:139
kind
Definition symbolic-scalars.h:70
@ named_test
Definition symbolic-scalars.h:75
bool is_one_p() const
static bool get_total_ordering(const scalar< ConcreteValueType > &a, enum tree_code op, const scalar< ConcreteValueType > &b, const region_model *model)
iter_result for_each_svalue(iter_result(*)(const svalue &sval, void *user_data), void *) const final override
Definition symbolic-scalars.h:101
virtual const concrete_scalar< ConcreteValueType > * dyn_cast_concrete_scalar() const
Definition symbolic-scalars.h:87
static tristate get_partial_ordering(const scalar< ConcreteValueType > &a, enum tree_code op, const scalar< ConcreteValueType > &b, const region_model *model)
virtual const sum< ConcreteValueType > * dyn_cast_sum() const
Definition symbolic-scalars.h:89
scalar_manager< ConcreteValueType > & get_mgr() const
Definition symbolic-scalars.h:82
bool operator>(const scalar< ConcreteValueType > &other) const
Definition symbolic-scalars.h:154
Definition symbolic-scalars.h:256
const concrete_scalar< ConcreteValueType > * get_any_concrete_addend() const
Definition symbolic-scalars.h:402
std::unique_ptr< diagnostics::markup::node > make_markup_node(markup_context &markup_ctxt) const final override
std::vector< const scalar< ConcreteValueType > * > m_symbolic_addends
Definition symbolic-scalars.h:436
const sum< ConcreteValueType > * dyn_cast_sum() const final override
Definition symbolic-scalars.h:390
sum(unsigned id, scalar_manager< ConcreteValueType > &mgr, const creation_key &k)
size_t get_num_symbolic_addends() const
Definition symbolic-scalars.h:393
void dump_inline_to_pp(pretty_printer *pp, enum units::role) const final override
std::unique_ptr< json::object > to_json() const final override
void add_dump_widget_children(text_art::tree_widget &, node_dump_state &nds) const final override
void accept_node_visitor(node_visitor &v) const final override
const scalar< ConcreteValueType > & get_symbolic_addend(size_t idx) const
Definition symbolic-scalars.h:399
void print_dump_widget_label_for_scalar(pretty_printer *pp) const final override
const concrete_scalar< ConcreteValueType > * m_concrete_addend
Definition symbolic-scalars.h:439
const ConcreteValueType * get_any_concrete_addend_value() const
Definition symbolic-scalars.h:408
Definition symbolic-nodes.h:468
value_node(complexity c, unsigned id)
Definition symbolic-nodes.h:484
Definition pretty-print.h:241
Definition tree-widget.h:32
Definition tristate.h:26
void final(rtx_insn *first, FILE *file, int optimize_p)
Definition final.cc:2004
bool operator==(const nowarn_spec_t &lhs, const nowarn_spec_t &rhs)
Definition gcc-diagnostic-spec.h:131
tree_code
Definition genmatch.cc:1011
bool operator<(const pattern_pos &e1, const pattern_pos &e2)
Definition genrecog.cc:3942
Definition concrete-ranges.h:27
Definition common.h:74
Definition common.h:68
role
Definition units.h:60
Definition access-diagram.h:30
integer_with_unit< Unit > operator-(const integer_with_unit< Unit > &i)
Definition integer-with-unit.h:276
symbolic::scalar< integer_with_unit< units::bit > > symbolic_bit_size
Definition symbolic-scalars.h:194
integer_with_unit< Unit > operator+(const integer_with_unit< Unit > &lhs, const integer_with_unit< Unit > &rhs)
Definition integer-with-unit.h:250
symbolic::scalar< integer_with_unit< units::byte > > symbolic_byte_size
Definition symbolic-scalars.h:197
symbolic::scalar< integer > symbolic_integer
Definition symbolic-scalars.h:191
bool maybe_bytes_from_bits(concrete_bit_range bits, concrete_byte_range *out)
integer_with_unit< Unit > operator*(const integer_with_unit< Unit > &lhs, const integer &rhs)
Definition integer-with-unit.h:312
@ other
Definition common.h:535
iter_result
Definition common.h:563
@ keep_going
Definition common.h:564
concrete_bit_range bits_from_bytes(concrete_byte_range bytes)
Definition concrete-ranges.h:121
symbolic::scalar< integer_with_unit< units::byte > > symbolic_byte_offset
Definition symbolic-scalars.h:196
bool concrete_from_symbolic(const symbolic::scalar< ConcreteValueType > &in, ConcreteValueType *out)
Definition symbolic-scalars.h:884
const symbolic::scalar< ConcreteValueType > & symbolic_from_concrete(const ConcreteValueType &in, symbolic::scalar_manager< ConcreteValueType > &mgr)
Definition symbolic-scalars.h:897
symbolic::scalar< integer_with_unit< units::bit > > symbolic_bit_offset
Definition symbolic-scalars.h:193
Definition custom-sarif-properties/state-graphs.h:33
Definition cfghooks.h:26
Definition analyzer-logging.h:28
i
Definition poly-int.h:776
Ca const poly_int< N, Cb > & b
Definition poly-int.h:771
Ca & a
Definition poly-int.h:770
Definition complexity.h:31
Definition symbolic-scalars.h:613
const symbolic_byte_size * m_bytes
Definition symbolic-scalars.h:619
Definition symbolic-nodes.h:88
Definition symbolic-nodes.h:276
Definition symbolic-scalars.h:456
complexity get_complexity() const
const scalar< ConcreteValueType > * m_lhs
Definition symbolic-scalars.h:464
const scalar< integer > * m_rhs
Definition symbolic-scalars.h:465
Definition symbolic-scalars.h:517
const svalue * m_sval
Definition symbolic-scalars.h:523
Definition symbolic-scalars.h:348
const scalar< ConcreteValueType > * m_with_unit
Definition symbolic-scalars.h:349
const scalar< integer > * m_unitless
Definition symbolic-scalars.h:350
std::unique_ptr< text_art::tree_widget > make_dump_widget(symbolic::node_dump_state &nds) const
Definition symbolic-scalars.h:346
std::vector< term > m_symbolic_terms
Definition symbolic-scalars.h:381
creation_key(folding_helper &&fh)
std::unique_ptr< text_art::tree_widget > make_dump_widget(symbolic::node_dump_state &nds) const
const scalar< ConcreteValueType > * maybe_fold_for_cvt(scalar_manager< ConcreteValueType > &mgr) const
ConcreteValueType m_concrete_term
Definition symbolic-scalars.h:382
complexity get_complexity() const
const scalar< ConcreteValueType > * maybe_fold(scalar_manager< ConcreteValueType > &mgr) const
Definition symbolic-scalars.h:291
std::map< const scalar< integer > *, const scalar< ConcreteValueType > * > m_map_unitless_term_to_coefficient_with_unit
Definition symbolic-scalars.h:336
void add_addend(const scalar< ConcreteValueType > &addend, scalar_manager< integer > &unitless_mgr)
std::map< const scalar< ConcreteValueType > *, const scalar< integer > * > m_map_term_with_unit_to_unitless_coefficient
Definition symbolic-scalars.h:331
ConcreteValueType m_sum_of_concrete_values
Definition symbolic-scalars.h:340
std::unique_ptr< text_art::tree_widget > make_dump_widget(symbolic::node_dump_state &nds) const
void add_to_coefficient_for_addend(const scalar< ConcreteValueType > *factor_with_unit, const scalar< integer > *unitless_factor)
folding_helper()
Definition symbolic-scalars.h:292
Definition symbolic-scalars.h:259
std::vector< const scalar< ConcreteValueType > * > m_addends
Definition symbolic-scalars.h:260
Definition collect2.cc:168