@@ -103,23 +103,23 @@ static std::vector<linear_constraint_t> assume_bit_cst_interval(const NumAbsDoma
103
103
104
104
auto dst_interval = inv.eval_interval (dst_uvalue);
105
105
std::optional<number_t > dst_n = dst_interval.singleton ();
106
- if (!dst_n || !dst_n.value ().fits_cast_to_int64 ()) {
106
+ if (!dst_n || !dst_n.value ().fits_cast_to < int64_t > ()) {
107
107
return {};
108
108
}
109
109
110
110
std::optional<number_t > src_n = src_interval.singleton ();
111
- if (!src_n || !src_n->fits_cast_to_int64 ()) {
111
+ if (!src_n || !src_n->fits_cast_to < int64_t > ()) {
112
112
return {};
113
113
}
114
- uint64_t src_int_value = src_n.value ().cast_to_uint64 ();
114
+ uint64_t src_int_value = src_n.value ().cast_to < uint64_t > ();
115
115
if (!is64) {
116
116
src_int_value = (uint32_t )src_int_value;
117
117
}
118
118
119
119
bool result;
120
120
switch (op) {
121
- case Op::SET: result = ((dst_n.value ().cast_to_uint64 () & src_int_value) != 0 ); break ;
122
- case Op::NSET: result = ((dst_n.value ().cast_to_uint64 () & src_int_value) == 0 ); break ;
121
+ case Op::SET: result = ((dst_n.value ().cast_to < uint64_t > () & src_int_value) != 0 ); break ;
122
+ case Op::NSET: result = ((dst_n.value ().cast_to < uint64_t > () & src_int_value) == 0 ); break ;
123
123
default : throw std::exception ();
124
124
}
125
125
@@ -148,11 +148,11 @@ static std::vector<linear_constraint_t> assume_signed_32bit_eq(const NumAbsDomai
148
148
// Find the lowest 64-bit svalue whose low 32 bits match the singleton.
149
149
150
150
// Get lower bound as a 64-bit value.
151
- int64_t lb = inv.eval_interval (left_svalue).lb ().number ()->cast_to_sint64 ();
151
+ int64_t lb = inv.eval_interval (left_svalue).lb ().number ()->cast_to < int64_t > ();
152
152
153
153
// Use the high 32-bits from the left lower bound and the low 32-bits from the right singleton.
154
154
// The result might be lower than the lower bound.
155
- int64_t lb_match = ((lb & 0xFFFFFFFF00000000 ) | (rn->cast_to_sint64 () & 0xFFFFFFFF ));
155
+ int64_t lb_match = ((lb & 0xFFFFFFFF00000000 ) | (rn->cast_to < int64_t > () & 0xFFFFFFFF ));
156
156
if (lb_match < lb) {
157
157
// The result is lower than the left interval, so try the next higher matching 64-bit value.
158
158
// It's ok if this goes higher than the left upper bound.
@@ -162,11 +162,11 @@ static std::vector<linear_constraint_t> assume_signed_32bit_eq(const NumAbsDomai
162
162
// Find the highest 64-bit svalue whose low 32 bits match the singleton.
163
163
164
164
// Get upper bound as a 64-bit value.
165
- int64_t ub = inv.eval_interval (left_svalue).ub ().number ()->cast_to_sint64 ();
165
+ int64_t ub = inv.eval_interval (left_svalue).ub ().number ()->cast_to < int64_t > ();
166
166
167
167
// Use the high 32-bits from the left upper bound and the low 32-bits from the right singleton.
168
168
// The result might be higher than the upper bound.
169
- int64_t ub_match = ((ub & 0xFFFFFFFF00000000 ) | (rn->cast_to_sint64 () & 0xFFFFFFFF ));
169
+ int64_t ub_match = ((ub & 0xFFFFFFFF00000000 ) | (rn->cast_to < int64_t > () & 0xFFFFFFFF ));
170
170
if (ub_match > ub) {
171
171
// The result is higher than the left interval, so try the next lower matching 64-bit value.
172
172
// It's ok if this goes lower than the left lower bound.
@@ -1514,8 +1514,8 @@ void ebpf_domain_t::operator()(const Un& stmt) {
1514
1514
if (m_inv.entail (type_is_number (stmt.dst ))) {
1515
1515
auto interval = m_inv.eval_interval (v);
1516
1516
if (std::optional<number_t > n = interval.singleton ()) {
1517
- if (n->fits_cast_to_int64 ()) {
1518
- input = (decltype (input))n.value ().cast_to_sint64 ();
1517
+ if (n->fits_cast_to < int64_t > ()) {
1518
+ input = (decltype (input))n.value ().cast_to < int64_t > ();
1519
1519
decltype (input) output = be_or_le (input);
1520
1520
m_inv.set (v, crab::interval_t (number_t (output), number_t (output)));
1521
1521
return ;
@@ -1663,9 +1663,9 @@ void ebpf_domain_t::operator()(const FuncConstraint& s) {
1663
1663
const reg_pack_t & reg = reg_pack (s.reg );
1664
1664
auto src_interval = m_inv.eval_interval (reg.svalue );
1665
1665
if (auto sn = src_interval.singleton ()) {
1666
- if (sn->fits_sint32 ()) {
1666
+ if (sn->fits < int32_t > ()) {
1667
1667
// We can now process it as if the id was immediate.
1668
- int32_t imm = sn->cast_to_sint32 ();
1668
+ int32_t imm = sn->cast_to < int32_t > ();
1669
1669
if (!global_program_info->platform ->is_helper_usable (imm)) {
1670
1670
require (m_inv, linear_constraint_t::false_const (), " invalid helper function id " + std::to_string (imm));
1671
1671
return ;
@@ -1693,7 +1693,7 @@ bool ebpf_domain_t::get_map_fd_range(const Reg& map_fd_reg, int32_t* start_fd, i
1693
1693
const crab::interval_t & map_fd_interval = m_inv[reg_pack (map_fd_reg).map_fd ];
1694
1694
auto lb = map_fd_interval.lb ().number ();
1695
1695
auto ub = map_fd_interval.ub ().number ();
1696
- if (!lb || !lb->fits_sint32 () || !ub || !ub->fits_sint32 ()) {
1696
+ if (!lb || !lb->fits < int32_t > () || !ub || !ub->fits < int32_t > ()) {
1697
1697
return false ;
1698
1698
}
1699
1699
*start_fd = (int32_t )lb.value ();
@@ -1841,9 +1841,9 @@ void ebpf_domain_t::operator()(const ValidMapKeyValue& s) {
1841
1841
linear_expression_t ub = lb + width;
1842
1842
if (!stack.all_num (inv, lb, ub)) {
1843
1843
auto lb_is = inv[lb].lb ().number ();
1844
- std::string lb_s = lb_is && lb_is->fits_sint32 () ? std::to_string ((int32_t )*lb_is) : " -oo" ;
1844
+ std::string lb_s = lb_is && lb_is->fits < int32_t > () ? std::to_string ((int32_t )*lb_is) : " -oo" ;
1845
1845
auto ub_is = inv.eval_interval (ub).ub ().number ();
1846
- std::string ub_s = ub_is && ub_is->fits_sint32 () ? std::to_string ((int32_t )*ub_is) : " oo" ;
1846
+ std::string ub_s = ub_is && ub_is->fits < int32_t > () ? std::to_string ((int32_t )*ub_is) : " oo" ;
1847
1847
require (inv, linear_constraint_t::false_const (),
1848
1848
" Illegal map update with a non-numerical value [" + lb_s + " -" + ub_s + " )" );
1849
1849
} else if (thread_local_options.strict && fd_type.has_value ()) {
@@ -2478,9 +2478,9 @@ void ebpf_domain_t::operator()(const Callx& callx) {
2478
2478
const reg_pack_t & reg = reg_pack (callx.func );
2479
2479
auto src_interval = m_inv.eval_interval (reg.svalue );
2480
2480
if (auto sn = src_interval.singleton ()) {
2481
- if (sn->fits_sint32 ()) {
2481
+ if (sn->fits < int32_t > ()) {
2482
2482
// We can now process it as if the id was immediate.
2483
- int32_t imm = sn->cast_to_sint32 ();
2483
+ int32_t imm = sn->cast_to < int32_t > ();
2484
2484
if (!global_program_info->platform ->is_helper_usable (imm)) {
2485
2485
return ;
2486
2486
}
@@ -2569,8 +2569,8 @@ void ebpf_domain_t::shl(const Reg& dst_reg, int imm, int finite_width) {
2569
2569
if (interval.finite_size ()) {
2570
2570
number_t lb = interval.lb ().number ().value ();
2571
2571
number_t ub = interval.ub ().number ().value ();
2572
- uint64_t lb_n = lb.cast_to_uint64 ();
2573
- uint64_t ub_n = ub.cast_to_uint64 ();
2572
+ uint64_t lb_n = lb.cast_to < uint64_t > ();
2573
+ uint64_t ub_n = ub.cast_to < uint64_t > ();
2574
2574
uint64_t uint_max = (finite_width == 64 ) ? UINT64_MAX : UINT32_MAX;
2575
2575
if ((lb_n >> (finite_width - imm)) != (ub_n >> (finite_width - imm))) {
2576
2576
// The bits that will be shifted out to the left are different,
@@ -2611,13 +2611,13 @@ void ebpf_domain_t::lshr(const Reg& dst_reg, int imm, int finite_width) {
2611
2611
number_t lb = interval.lb ().number ().value ();
2612
2612
number_t ub = interval.ub ().number ().value ();
2613
2613
if (finite_width == 64 ) {
2614
- lb_n = lb.cast_to_uint64 () >> imm;
2615
- ub_n = ub.cast_to_uint64 () >> imm;
2614
+ lb_n = lb.cast_to < uint64_t > () >> imm;
2615
+ ub_n = ub.cast_to < uint64_t > () >> imm;
2616
2616
} else {
2617
2617
number_t lb_w = lb.cast_to_signed_finite_width (finite_width);
2618
2618
number_t ub_w = ub.cast_to_signed_finite_width (finite_width);
2619
- lb_n = lb_w.cast_to_uint32 () >> imm;
2620
- ub_n = ub_w.cast_to_uint32 () >> imm;
2619
+ lb_n = lb_w.cast_to < uint32_t > () >> imm;
2620
+ ub_n = ub_w.cast_to < uint32_t > () >> imm;
2621
2621
2622
2622
// The interval must be valid since a signed range crossing 0
2623
2623
// was earlier converted to a full unsigned range.
@@ -2668,10 +2668,10 @@ void ebpf_domain_t::sign_extend(const Reg& dst_reg, const linear_expression_t& r
2668
2668
int64_t mask = 1ULL << (bits - 1 );
2669
2669
2670
2670
// Sign extend each bound.
2671
- int64_t lb = right_interval.lb ().number ().value ().cast_to_sint64 ();
2671
+ int64_t lb = right_interval.lb ().number ().value ().cast_to < int64_t > ();
2672
2672
lb &= (span - 1 );
2673
2673
lb = (lb ^ mask) - mask;
2674
- int64_t ub = right_interval.ub ().number ().value ().cast_to_sint64 ();
2674
+ int64_t ub = right_interval.ub ().number ().value ().cast_to < int64_t > ();
2675
2675
ub &= (span - 1 );
2676
2676
ub = (ub ^ mask) - mask;
2677
2677
m_inv.set (dst.svalue , crab::interval_t {number_t {lb}, number_t {ub}});
@@ -2696,22 +2696,22 @@ void ebpf_domain_t::ashr(const Reg& dst_reg, const linear_expression_t& right_sv
2696
2696
right_interval, left_interval_positive, left_interval_negative);
2697
2697
if (auto sn = right_interval.singleton ()) {
2698
2698
// The BPF ISA requires masking the imm.
2699
- int64_t imm = sn->cast_to_sint64 () & (finite_width - 1 );
2699
+ int64_t imm = sn->cast_to < int64_t > () & (finite_width - 1 );
2700
2700
2701
2701
int64_t lb_n = INT64_MIN >> imm;
2702
2702
int64_t ub_n = INT64_MAX >> imm;
2703
2703
if (left_interval.finite_size ()) {
2704
2704
number_t lb = left_interval.lb ().number ().value ();
2705
2705
number_t ub = left_interval.ub ().number ().value ();
2706
2706
if (finite_width == 64 ) {
2707
- lb_n = lb.cast_to_sint64 () >> imm;
2708
- ub_n = ub.cast_to_sint64 () >> imm;
2707
+ lb_n = lb.cast_to < int64_t > () >> imm;
2708
+ ub_n = ub.cast_to < int64_t > () >> imm;
2709
2709
} else {
2710
2710
number_t lb_w = lb.cast_to_signed_finite_width (finite_width) >> (int )imm;
2711
2711
number_t ub_w = ub.cast_to_signed_finite_width (finite_width) >> (int )imm;
2712
- if (lb_w.cast_to_uint32 () <= ub_w.cast_to_uint32 ()) {
2713
- lb_n = lb_w.cast_to_uint32 ();
2714
- ub_n = ub_w.cast_to_uint32 ();
2712
+ if (lb_w.cast_to < uint32_t > () <= ub_w.cast_to < uint32_t > ()) {
2713
+ lb_n = lb_w.cast_to < uint32_t > ();
2714
+ ub_n = ub_w.cast_to < uint32_t > ();
2715
2715
}
2716
2716
}
2717
2717
}
@@ -2957,7 +2957,7 @@ void ebpf_domain_t::operator()(const Bin& bin) {
2957
2957
auto src_interval = m_inv.eval_interval (src.uvalue );
2958
2958
if (std::optional<number_t > sn = src_interval.singleton ()) {
2959
2959
// truncate to uint64?
2960
- uint64_t imm = sn->cast_to_uint64 () & (bin.is64 ? 63 : 31 );
2960
+ uint64_t imm = sn->cast_to < uint64_t > () & (bin.is64 ? 63 : 31 );
2961
2961
if (imm <= INT32_MAX) {
2962
2962
if (!bin.is64 ) {
2963
2963
// Use only the low 32 bits of the value.
@@ -2975,7 +2975,7 @@ void ebpf_domain_t::operator()(const Bin& bin) {
2975
2975
if (m_inv.entail (type_is_number (src_reg))) {
2976
2976
auto src_interval = m_inv.eval_interval (src.uvalue );
2977
2977
if (std::optional<number_t > sn = src_interval.singleton ()) {
2978
- uint64_t imm = sn->cast_to_uint64 () & (bin.is64 ? 63 : 31 );
2978
+ uint64_t imm = sn->cast_to < uint64_t > () & (bin.is64 ? 63 : 31 );
2979
2979
if (imm <= INT32_MAX) {
2980
2980
if (!bin.is64 ) {
2981
2981
// Use only the low 32 bits of the value.
0 commit comments