Lines Matching full:range

215  * GENERIC RANGE STRUCT AND OPERATIONS
218 struct range { struct
222 static void snprintf_range(enum num_t t, struct strbuf *sb, struct range x) in snprintf_range() argument
234 static void print_range(enum num_t t, struct range x, const char *sfx) in print_range()
242 static const struct range unkn[] = {
249 static struct range unkn_subreg(enum num_t t) in unkn_subreg()
260 static struct range range(enum num_t t, u64 a, u64 b) in range() function
263 case U64: return (struct range){ (u64)a, (u64)b }; in range()
264 case U32: return (struct range){ (u32)a, (u32)b }; in range()
265 case S64: return (struct range){ (s64)a, (s64)b }; in range()
266 case S32: return (struct range){ (u32)(s32)a, (u32)(s32)b }; in range()
267 default: printf("range!\n"); exit(1); in range()
276 static bool range_eq(struct range x, struct range y) in range_eq()
281 static struct range range_cast_to_s32(struct range x) in range_cast_to_s32()
286 * s32 range to be correct in range_cast_to_s32()
289 return range(S32, a, b); in range_cast_to_s32()
293 * 0x00000000 is also valid), while lower bits form a proper s32 range in range_cast_to_s32()
297 * over full 64-bit numbers range will form a proper [-16, 16] in range_cast_to_s32()
298 * ([0xffffff00; 0x00000010]) range in its lower 32 bits. in range_cast_to_s32()
301 return range(S32, a, b); in range_cast_to_s32()
307 static struct range range_cast_u64(enum num_t to_t, struct range x) in range_cast_u64()
317 return range(U32, a, b); in range_cast_u64()
321 return range(S64, a, b); in range_cast_u64()
328 static struct range range_cast_s64(enum num_t to_t, struct range x) in range_cast_s64()
337 return range(U64, a, b); in range_cast_s64()
341 return range(U32, a, b); in range_cast_s64()
350 static struct range range_cast_u32(enum num_t to_t, struct range x) in range_cast_u32()
358 return range(to_t, a, b); in range_cast_u32()
362 return range_cast_to_s32(range(U32, a, b)); in range_cast_u32()
367 static struct range range_cast_s32(enum num_t to_t, struct range x) in range_cast_s32()
377 return range(to_t, a, b); in range_cast_s32()
384 /* Reinterpret range in *from_t* domain as a range in *to_t* domain preserving
385 * all possible information. Worst case, it will be unknown range within
389 static struct range range_cast(enum num_t from_t, enum num_t to_t, struct range from) in range_cast()
411 static bool is_valid_range(enum num_t t, struct range x) in is_valid_range()
425 static struct range range_improve(enum num_t t, struct range old, struct range new) in range_improve()
427 return range(t, max_t(t, old.a, new.a), min_t(t, old.b, new.b)); in range_improve()
430 static struct range range_refine(enum num_t x_t, struct range x, enum num_t y_t, struct range y) in range_refine()
432 struct range y_cast; in range_refine()
437 * - *x* is in the range of signed 32bit value, and in range_refine()
438 * - *y_cast* range is 32-bit signed non-negative in range_refine()
439 * then *x* range can be improved with *y_cast* such that *x* range in range_refine()
440 * is 32-bit signed non-negative. Otherwise, if the new range for *x* in range_refine()
441 * allows upper 32-bit * 0xffffffff then the eventual new range for in range_refine()
442 * *x* will be out of signed 32-bit range which violates the origin in range_refine()
443 * *x* range. in range_refine()
449 /* the case when new range knowledge, *y*, is a 32-bit subregister in range_refine()
450 * range, while previous range knowledge, *x*, is a full register in range_refine()
451 * 64-bit range, needs special treatment to take into account upper 32 in range_refine()
452 * bits of full register range in range_refine()
455 struct range x_swap; in range_refine()
462 x_swap = range(x_t, swap_low32(x.a, y_cast.a), swap_low32(x.b, y_cast.b)); in range_refine()
468 /* otherwise, plain range cast and intersection works */ in range_refine()
504 /* Can register with range [x.a, x.b] *EVER* satisfy
506 * a register with range [y.a, y.b]
509 static bool range_canbe_op(enum num_t t, struct range x, struct range y, enum op op) in range_canbe_op()
533 /* Does register with range [x.a, x.b] *ALWAYS* satisfy
535 * a register with range [y.a, y.b]
538 static bool range_always_op(enum num_t t, struct range x, struct range y, enum op op) in range_always_op()
544 /* Does register with range [x.a, x.b] *NEVER* satisfy
546 * a register with range [y.a, y.b]
549 static bool range_never_op(enum num_t t, struct range x, struct range y, enum op op) in range_never_op()
559 static int range_branch_taken_op(enum num_t t, struct range x, struct range y, enum op op) in range_branch_taken_op()
575 static void range_cond(enum num_t t, struct range x, struct range y, in range_cond()
576 enum op op, struct range *newx, struct range *newy) in range_cond()
586 *newx = range(t, x.a, min_t(t, x.b, y.b - 1)); in range_cond()
587 *newy = range(t, max_t(t, x.a + 1, y.a), y.b); in range_cond()
590 *newx = range(t, x.a, min_t(t, x.b, y.b)); in range_cond()
591 *newy = range(t, max_t(t, x.a, y.a), y.b); in range_cond()
594 *newx = range(t, max_t(t, x.a, y.a + 1), x.b); in range_cond()
595 *newy = range(t, y.a, min_t(t, x.b - 1, y.b)); in range_cond()
598 *newx = range(t, max_t(t, x.a, y.a), x.b); in range_cond()
599 *newy = range(t, y.a, min_t(t, x.b, y.b)); in range_cond()
602 *newx = range(t, max_t(t, x.a, y.a), min_t(t, x.b, y.b)); in range_cond()
603 *newy = range(t, max_t(t, x.a, y.a), min_t(t, x.b, y.b)); in range_cond()
609 *newx = range(t, x.a, x.b); in range_cond()
610 *newy = range(t, y.a + 1, y.b); in range_cond()
613 *newx = range(t, x.a, x.b); in range_cond()
614 *newy = range(t, y.a, y.b - 1); in range_cond()
617 *newx = range(t, x.a + 1, x.b); in range_cond()
618 *newy = range(t, y.a, y.b); in range_cond()
621 *newx = range(t, x.a, x.b - 1); in range_cond()
622 *newy = range(t, y.a, y.b); in range_cond()
625 *newx = range(t, x.a, x.b); in range_cond()
626 *newy = range(t, y.a, y.b); in range_cond()
640 struct range r[4]; /* indexed by enum num_t: U64, U32, S64, S32 */
665 static void print_refinement(enum num_t s_t, struct range src, in print_refinement()
666 enum num_t d_t, struct range old, struct range new, in print_refinement()
677 static void reg_state_refine(struct reg_state *r, enum num_t t, struct range x, const char *ctx) in reg_state_refine()
680 struct range old; in reg_state_refine()
684 /* try to derive new knowledge from just learned range x of type t */ in reg_state_refine()
721 rs->r[tt] = tt == t ? range(t, val, val) : unkn[tt]; in reg_state_set_const()
733 struct range z1, z2; in reg_state_cond()
820 /* whether to establish initial value range on full register (r1) or
824 /* whether to establish initial value range using signed or unsigned
837 static int load_range_cmp_prog(struct range x, struct range y, enum op op, in load_range_cmp_prog()
888 /* ; setup initial r6/w6 possible value range ([x.a, x.b]) in load_range_cmp_prog()
909 /* ; setup initial r7/w7 possible value range ([y.a, y.b]) in load_range_cmp_prog()
930 /* ; range test instruction in load_range_cmp_prog()
1016 * - range: R6_rwD=scalar(id=1,...), where "..." is a comma-separated in parse_reg_state()
1017 * list of optional range specifiers: in parse_reg_state()
1077 reg->r[t] = range(t, sval, sval); in parse_reg_state()
1182 static bool assert_range_eq(enum num_t t, struct range x, struct range y, in assert_range_eq()
1243 /* Simulate provided test case purely with our own range-based logic.
1248 struct range x, struct range y, enum op op, in sim_case()
1267 struct range z = t_is_32(init_t) ? unkn_subreg(t) : unkn[t]; in sim_case()
1346 struct range *uranges, *sranges;
1347 struct range *usubranges, *ssubranges;
1367 struct range x;
1368 struct range y;
1386 struct range x, struct range y, enum op op) in verify_case_op()
1452 struct range x, struct range y, bool is_subtest) in verify_case_opt()
1506 struct range x, struct range y) in verify_case()
1628 snprintf_range(U64, sb1, range(U64, ctx->uvals[i], ctx->uvals[j])); in gen_ranges()
1629 snprintf_range(S64, sb2, range(S64, ctx->svals[i], ctx->svals[j])); in gen_ranges()
1630 printf("RANGE #%d: u64=%-40s s64=%-40s\n", cnt, sb1->buf, sb2->buf); in gen_ranges()
1647 ctx->uranges[cnt] = range(U64, ctx->uvals[i], ctx->uvals[j]); in gen_ranges()
1648 ctx->sranges[cnt] = range(S64, ctx->svals[i], ctx->svals[j]); in gen_ranges()
1661 snprintf_range(U32, sb1, range(U32, ctx->usubvals[i], ctx->usubvals[j])); in gen_ranges()
1662 snprintf_range(S32, sb2, range(S32, ctx->ssubvals[i], ctx->ssubvals[j])); in gen_ranges()
1680 ctx->usubranges[cnt] = range(U32, ctx->usubvals[i], ctx->usubvals[j]); in gen_ranges()
1681 ctx->ssubranges[cnt] = range(S32, ctx->ssubvals[i], ctx->ssubvals[j]); in gen_ranges()
1753 struct range rconst; in validate_gen_range_vs_const_64()
1754 const struct range *ranges; in validate_gen_range_vs_const_64()
1769 "RANGE x CONST, %s -> %s", in validate_gen_range_vs_const_64()
1774 rconst = range(init_t, vals[i], vals[i]); in validate_gen_range_vs_const_64()
1776 /* (u64|s64)(<range> x <const>) */ in validate_gen_range_vs_const_64()
1779 /* (u64|s64)(<const> x <range>) */ in validate_gen_range_vs_const_64()
1792 struct range rconst; in validate_gen_range_vs_const_32()
1793 const struct range *ranges; in validate_gen_range_vs_const_32()
1808 "RANGE x CONST, %s -> %s", in validate_gen_range_vs_const_32()
1813 rconst = range(init_t, vals[i], vals[i]); in validate_gen_range_vs_const_32()
1815 /* (u32|s32)(<range> x <const>) */ in validate_gen_range_vs_const_32()
1818 /* (u32|s32)(<const> x <range>) */ in validate_gen_range_vs_const_32()
1831 const struct range *ranges; in validate_gen_range_vs_range()
1865 "RANGE x RANGE, %s -> %s", in validate_gen_range_vs_range()
1870 /* (<range> x <range>) */ in validate_gen_range_vs_range()
1891 /* RANGE x CONST, U64 initial range */
1896 /* RANGE x CONST, S64 initial range */
1901 /* RANGE x CONST, U32 initial range */
1906 /* RANGE x CONST, S32 initial range */
1912 /* RANGE x RANGE, U64 initial range */
1917 /* RANGE x RANGE, S64 initial range */
1922 /* RANGE x RANGE, U32 initial range */
1927 /* RANGE x RANGE, S32 initial range */
1953 static struct range rand_range(enum num_t t) in rand_range()
1957 return range(t, min_t(t, x, y), max_t(t, x, y)); in rand_range()
1963 struct range range1, range2; in validate_rand_ranges()
1985 "[RANDOM SEED %u] RANGE x %s, %s -> %s", in validate_rand_ranges()
1986 ctx.rand_seed, const_range ? "CONST" : "RANGE", in validate_rand_ranges()
1993 range2 = range(init_t, t, t); in validate_rand_ranges()
2012 /* [RANDOM] RANGE x CONST, U64 initial range */
2017 /* [RANDOM] RANGE x CONST, S64 initial range */
2022 /* [RANDOM] RANGE x CONST, U32 initial range */
2027 /* [RANDOM] RANGE x CONST, S32 initial range */
2033 /* [RANDOM] RANGE x RANGE, U64 initial range */
2034 void test_reg_bounds_rand_ranges_u64_u64(void) { validate_rand_ranges(U64, U64, false /* range */);… in test_reg_bounds_rand_ranges_u64_u64()
2035 void test_reg_bounds_rand_ranges_u64_s64(void) { validate_rand_ranges(U64, S64, false /* range */);… in test_reg_bounds_rand_ranges_u64_s64()
2036 void test_reg_bounds_rand_ranges_u64_u32(void) { validate_rand_ranges(U64, U32, false /* range */);… in test_reg_bounds_rand_ranges_u64_u32()
2037 void test_reg_bounds_rand_ranges_u64_s32(void) { validate_rand_ranges(U64, S32, false /* range */);… in test_reg_bounds_rand_ranges_u64_s32()
2038 /* [RANDOM] RANGE x RANGE, S64 initial range */
2039 void test_reg_bounds_rand_ranges_s64_u64(void) { validate_rand_ranges(S64, U64, false /* range */);… in test_reg_bounds_rand_ranges_s64_u64()
2040 void test_reg_bounds_rand_ranges_s64_s64(void) { validate_rand_ranges(S64, S64, false /* range */);… in test_reg_bounds_rand_ranges_s64_s64()
2041 void test_reg_bounds_rand_ranges_s64_u32(void) { validate_rand_ranges(S64, U32, false /* range */);… in test_reg_bounds_rand_ranges_s64_u32()
2042 void test_reg_bounds_rand_ranges_s64_s32(void) { validate_rand_ranges(S64, S32, false /* range */);… in test_reg_bounds_rand_ranges_s64_s32()
2043 /* [RANDOM] RANGE x RANGE, U32 initial range */
2044 void test_reg_bounds_rand_ranges_u32_u64(void) { validate_rand_ranges(U32, U64, false /* range */);… in test_reg_bounds_rand_ranges_u32_u64()
2045 void test_reg_bounds_rand_ranges_u32_s64(void) { validate_rand_ranges(U32, S64, false /* range */);… in test_reg_bounds_rand_ranges_u32_s64()
2046 void test_reg_bounds_rand_ranges_u32_u32(void) { validate_rand_ranges(U32, U32, false /* range */);… in test_reg_bounds_rand_ranges_u32_u32()
2047 void test_reg_bounds_rand_ranges_u32_s32(void) { validate_rand_ranges(U32, S32, false /* range */);… in test_reg_bounds_rand_ranges_u32_s32()
2048 /* [RANDOM] RANGE x RANGE, S32 initial range */
2049 void test_reg_bounds_rand_ranges_s32_u64(void) { validate_rand_ranges(S32, U64, false /* range */);… in test_reg_bounds_rand_ranges_s32_u64()
2050 void test_reg_bounds_rand_ranges_s32_s64(void) { validate_rand_ranges(S32, S64, false /* range */);… in test_reg_bounds_rand_ranges_s32_s64()
2051 void test_reg_bounds_rand_ranges_s32_u32(void) { validate_rand_ranges(S32, U32, false /* range */);… in test_reg_bounds_rand_ranges_s32_u32()
2052 void test_reg_bounds_rand_ranges_s32_s32(void) { validate_rand_ranges(S32, S32, false /* range */);… in test_reg_bounds_rand_ranges_s32_s32()
2093 /* verifier knows about [-1, 0] range for s32 for this case already */