rpg_source.zig: read the other SORTA and %LOOKUP forms (starts, counts, search values, element types, %LOOKUPGT, GE, LT and LE) #800
Loading…
Reference in a new issue
No description provided.
Delete branch "lsrt2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
rpg_source.zig: read the other SORTA and %LOOKUP forms (starts, counts, search values, element types, %LOOKUPGT, GE, LT and LE)
Round two of lane lsrt, stacked on round one (
docs/changes/lsrt.md). The 24 captures of the requestrequests/lsrt/sorta2(all public) measure what round one refused. The units ofrpg_sorta.zigandrpg_lookup.zigread them with a red test each, and the ordered lookups have a module of their own,rpg_lookup_ordered.zig. A shape that differs in any operation or operand still reads nothing and the statementkeeps its failure.
What changed in the reader
rpg_unit_pattern.zig: a family has a gap,X NAME: one to twelve operations of a value expression that leaveone value (the measured loads, decimal add and subtract, conversions). The unit keeps them before its
operation, so the statement reader writes
s + 1andn - 1itself. The unit proves its own temporaries(every
35 T) and labels (every15 L) by the pattern, not by a list, and no gap names a temporary of the unit.rpg_sorta.zig:%SUBARR(a: s: n)(two range checks), a literal start of 2 (the start is 1 to thedimension, no longer only 1), a count that the statement computed (
n - 1), the helper of a zoned array(
84 D 1after each load), the integer, character (descending) and packed(7:2) arrays, and the whole-arraytag
113 TG 2as a slot (6 packed(5), 7 character, 9 integer, 11 packed(7:2), 12 zoned).rpg_lookup.zig: the start is a field or an expression (the gap) or a literal (27 KS; 75 8; 75 4; 35 TS, nocheck), the count a field or a literal (
27 KC; 76 8; 35 TX, checked 0 to the elements left), the search value aconstant, a field (
29 SV 0 TT2; 35 TV) or an element, and the array a packed, character (only thetwo-argument form with a field search value is measured), zoned (
84 D 1after the load, two arguments anda constant) or integer one (
75 8, the same). An element of a variable index (the elementunit of
rpg_array_element.zigleft.element_address) may be of another array; one of a constant index is ofthe array that is searched. Twelve combinations are measured, written in
variants; the others do not read.rpg_lookup_ordered.zig:%LOOKUPGT,GE,LTandLEof an array that the program declares ascending, with aconstant search value, as four texts of about a hundred operations that differ in six places (below).
rpg_sort_value.zigreads the new operands, writes%LOOKUPGT(...)and the others, and tells the emitter thatthe array is ascending.
Emitter edits (the only edits of
rpg_source*.zig):rpg_source.ziglists%LOOKUPGT,GE,LTandLEasbuilt-in functions (one line);
rpg_facts.ziggivesarray_element_v1the flagascending, andrpg_source_decl_emit.zigkeeps it when two facts name one array and writesascendafterdim(n)(
dcl-s d packed(5:0) dim(10) ascend;; ten lines). Without the keyword the program that the emit writes doesnot compile:
%LOOKUPGTneeds a sequenced array.Measured (SC-ILE/EXPERIMENTS lsrt-*, statement 13 or 14; a packed(5) dim(10))
29 S ...; start check; 27 ONE; 52; 75 4; 35 S0;then the count check of%SUBARR(a:1:n)sorta %SUBARR(a: s: n);27 ST; 75 8; 27 ONE; 52), the rest as the count field and the constants%SUBARR(a: 2: n),(a: 2: 3)29 N 0 T; 27 K; 60 6 0 0first, then27 ST; 75 8; 5; 5; 27 ONE; 52; 75 4; 35 S0; 61 6 0 0; 87 8;and the count check%SUBARR(a: 1: n - 1)10sorta(d) c;84 5 1after each of its two loads (91 operations); the element type is zoned(5), tag 12sorta z;int(10)(32 A 0 2) and packed(7) (32 A 0 13); tags 9 and 11sorta(d) k;sorta q;29 SV 0 TT2; 35 TV(no rescale, TT2 is the element type)%LOOKUP(n: a),(n: a: s)27 KS; 75 8; 75 4; 35 TS; 27 DIM; 35 TE;(no check)%LOOKUP(4: a: 3)27 DIM; 27 TS; 52; 27 ONE; 78 4; 47; 35 TE; 27 KC; 76 8; 35 TX;checked 0 to TE andTE = TS + KC - 1%LOOKUP(4: a: 2: 3)29 S 0 TT; 27 K; 54 6 0 0before35 TQ: the start temporary has six digits (86 6) and is not the search temporary%LOOKUP(4: a: s + 1)a(2)addressed before the unit (34 A 0; 27 OFF; 62), two and four arguments%LOOKUP(a(2): a),(a(2): a: s: n)34 A 0; 29 N 0 T; 87 4; 75 4; 77 4; 27 ONE; 52; 27 K; 138; 78 4; 65 Wbefore the unit (one operation fewer than the bounds-checked form ofrpg_array_element.zig)%LOOKUP(a(i): a: s),(a(i): b: s)c char(5) dim(10), the compare is7%LOOKUP(key: c)84 5 1after the load, constant27 KV; 61 5 0 0; integer:75 8after the load, constant27 KV; 75 8; 35 TV%LOOKUP(4: z),(4: k)%LOOKUPGT(4: d)and the othersThe ordered lookups search LO to HI (the middle
(LO + HI [+ 1]) / 2is27 K1; 69, a shift by one), then scanfrom the element found. The four texts differ in three places: GT and GE add one to LO + HI (
27 ONE; 47), LT andLE do not; the first scan after the search compares
11 ... 12and steps up (47) for GT and GE, and compares9 ... 10and steps down (52) for LT and LE; the second scan ends with27 Z2; 35 MID(not found) for GTand LT, and with
27 MID; 27 ONE; 47; 35 MID(the equal element) for GE and LE. Each is proved by its own text;the function of a read is the text that matched, and the four captures are the four sources.
Effect
All 24 captures read their statement 13 or 14 (before,
? unresolved statement); none of the 24 emits is free offailure lines, because the probes' other statements are other work. Development programs (reported as fit, no rule or test holds
their text): p3 0 failure lines before and after; p4 1 to 0 (its
%LOOKUPof an element of another array at avariable index, the one line round one left, is lookup-elemvar-other).
Fix of the declaration of an array (
rpg_source_decl_emit.zig,rpg_source.zig): an array of packed or zonedelements has the digits of its elements from its statements and its decimal positions only when a statement proves
them. The declaration of sorta-dec2 was
packed(7:0) dim(10)forpacked(7:2), with no marker. It now carries// SOURCERER-TODO decimal_positions: not proved, 0 assumed, as a field does (the same condition: no scaleproved, no literal scale). The array is marked but not counted in
assumedand does not make the unused fieldsundeclared: the one literal that proves the positions of a field still proves those of an array (
lr1-lv:packed(15:2) dim(50), unmarked, as before). Arrays of integer, character and float elements are not marked.The emits of p3 and p4 change by this (the two arrays
dim(2000)carry the marker; placeholders 2 to 4 and 1 to 3,failure lines and emitted statements unchanged), and so do 31 of the 36 captures that I emitted (the 34 of the
two batteries and p3 and p4; the five that stay are the arrays of integer and character elements: lookup-char, lookup-int,
sorta-char, sorta-char-desc and sorta-int);
emit-diff.shbetween the two builds over the 888 public twins: worse [], failures1014 to 1014, emitted 8602 to 8602, clean 593 to 593. Eight tests of other lanes asserted
;and a newline afteran array declaration (
rpg_decimal_for_test,rpg_array_inz_test,rpg_long_value_test,rpg_num_elem_test):they now stop at the
;.The request
requests/lsrt/sorta3holds 12 more shapes (the ordered lookups with a start, a field search value anda DESCEND array; a field search value with a start and a count; an expression count; a character constant; a zoned
field; an element of an integer array; SORTA(D) with
%SUBARR(a:s:n);%SUBARR(a:2:n - 1); float and unsignedarrays). docs/OPERATIONS.md is regenerated (
ops-legend.sh --write).Probes adopted (matrix rows, none host-matching yet; each keeps the failure lines of statements 9, 10 and 14 or
15 of the probe): lsrt-sorta-subarr-sn, -2n, -2lit, -expr, lsrt-sorta-char-desc, -zoned, -int, -dec2, lsrt-lookup-var-2,
-var-3, -lit-start, -lit-count, -expr-start, -elem-2, -elem-4, -elemvar-same, -elemvar-other, -char, -zoned, -int,
lsrt-lookupgt, -lookupge, -lookuplt, -lookuple.
Gate
Host round trips on the build before the scale-marker commit: dev5 p3 and p4 compile (different; the round trip lacks the capture LICOPT until loop #118).
48c84fe9d3to97f7ff31cb