omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / seed / omc / omc.om
| 1 | note omc: the Omega compiler written in Omega (the om4 subset). Reads Omegese on stdin, writes a runnable |
| 2 | note AArch64 Linux program (or bare function words) on stdout. Built first by om4; its codegen matches om4 |
| 3 | note byte for byte on the original subset (seed chain rung 5, ledger L408). Native host operations |
| 4 | note extend that subset; om4 still builds this compiler, and the compiler rebuilds itself identically. |
| 5 | note All compiler state lives in global pools (decision 24: no heap). Every working value is a ulong |
| 6 | note (raw 64 bits) so the language's checked conversions never fire on om4's untyped-register logic. |
| 7 | |
| 8 | note ---- the arena (decision 23 as amended 2026-11-11, OMEGESE 9.6; grown at run time since landing 2 of the |
| 9 | note run-time pools, decision 3 of 2026-11-11, docs/RUNTIME-POOLS.md s6). Every table whose size grows with the |
| 10 | note unit (the input, the output, names, long names, functions and their parameters, call sites, trap sites, |
| 11 | note blocks, breaks, value nesting, the x86 fixups, the om2 diag sites) is a region of the one pool a_ar. |
| 12 | note A region starts small and doubles when an index reaches its capacity (a_need), so no table fills. |
| 13 | note a_ar is a run-time pool (global a_ar ulong *, OMEGESE 9.15): its length is 0 when omc starts, and a_need |
| 14 | note enlarges it (a_grow) whenever a group's growth would not fit in the words left: to twice its length, or |
| 15 | note to what the tables need when that is more. So omc has no arena size of its own: the host is the bound. |
| 16 | note When the host refuses (enlarge's negative result, for example under prlimit --as), the arena is compacted |
| 17 | note and the group grows in place to the largest size that fits; when not even one more entry fits, the unit |
| 18 | note is error 14 with an omc-use record on stderr (full=1: the host refused) naming every group and the words |
| 19 | note it held (a_full, a_rec). The static 128 MiB arena this replaces was sized by omc's image under the |
| 20 | note smallest RLIMIT_AS omc runs under (the interplane-forge salvage compile, 268435456) and by the 16777216 |
| 21 | note elements of a sized pool (OMEGESE 9.4); a run-time pool is bounded by neither, and the image no longer |
| 22 | note holds the arena. |
| 23 | note a_rb / a_rw: a region's first word and the words it holds; a_rg its group; a_rm its elements per group |
| 24 | note index (0: a byte region, 8 bytes to a word); a_gc / a_gp a group's capacity and the highest index it |
| 25 | note was asked for, plus 1; a_top the words handed out; a_wst the words left behind by moves; a_fl 1 while |
| 26 | note error 14 is the arena's; a_nr the region count; a_wb the staging bytes of read and write. |
| 27 | global a_ar ulong * |
| 28 | note a_cel: the caller-stated memory ceiling C in bytes (OMC_MEMORY_MAX, a_env; 0: none). The arena's bytes A, the |
| 29 | note output's bytes O (written to stdout they are page cache of the same cgroup) and the margin 16 MiB + A / 128 |
| 30 | note stay within C (docs/RUNTIME-POOLS.md s6, "The memory ceiling"): a_capw at every growth, a_ceilo before the write |
| 31 | global a_cel ulong 1 |
| 32 | note a_rdy: 1 once a_init has given every region its first room (a_need compacts only then, or while region 0 is alone) |
| 33 | global a_rdy ulong 1 |
| 34 | note a_hw: the most words a_top ever held (a_hwset); a compaction lowers a_top, not the pages it touched |
| 35 | global a_hw ulong 1 |
| 36 | text a_envk "OMC_MEMORY_MAX=" |
| 37 | note a_eb: one environment entry (Linux keeps each below 131072 bytes, MAX_ARG_STRLEN) |
| 38 | global a_eb uchar 131072 |
| 39 | global a_rb ulong 96 |
| 40 | global a_rw ulong 96 |
| 41 | global a_rg ulong 96 |
| 42 | global a_rm ulong 96 |
| 43 | global a_gc ulong 32 |
| 44 | global a_gp ulong 32 |
| 45 | global a_top ulong 1 |
| 46 | global a_wst ulong 1 |
| 47 | global a_fl ulong 1 |
| 48 | global a_nr ulong 1 |
| 49 | note a_ord / a_np: the regions in order of base and their new places, for a_relayout |
| 50 | global a_ord ulong 96 |
| 51 | global a_np ulong 96 |
| 52 | global a_wb uchar 65536 |
| 53 | note nh_b / lh_b / fh_b: the bucket bits of the name, long-name and function hash tables (chained: the |
| 54 | note bucket holds index + 1 of the newest entry, nm_nx / ln_x / fn_nx the one before it in the chain) |
| 55 | global nh_b ulong 1 |
| 56 | global lh_b ulong 1 |
| 57 | global fh_b ulong 1 |
| 58 | note tpend: the first trap site of the function being compiled that no stub was patched to yet (island) |
| 59 | global tpend ulong 1 |
| 60 | |
| 61 | note ---- input, output, token ---- |
| 62 | global inlen ulong 1 |
| 63 | global irmode ulong 1 |
| 64 | global cur ulong 1 |
| 65 | global line ulong 1 |
| 66 | global tk ulong 1 |
| 67 | global tw ulong 1 |
| 68 | global tl ulong 1 |
| 69 | global ts ulong 1 |
| 70 | global tbig ulong 1 |
| 71 | global oc ulong 1 |
| 72 | |
| 73 | note ---- OM-2 profile (spec/omegese-om2.md, OMEGESE.md 9.13). om2 is 1 in an OM-2 unit (its first line |
| 74 | note that is not a note or blank is exactly om2, om2 diag or om2 fmt); om2m 0 compile, 1 diag, 2 fmt; |
| 75 | note om2ln/om2pos the line number and offset of that line; fmtm 1 while a unit is formatted; lbase and |
| 76 | note sbase shift reported lines and bytes back to the original input in fmt mode; tka/tkb the byte span of |
| 77 | note the last token; dexp what was being read (0 word 1 value 2 type 3 name 4 number 5 end 6 newline); |
| 78 | note dsev 0 derived, 2 unknown (an undeclared function or struct), 3 error ---- |
| 79 | global om2 ulong 1 |
| 80 | global om2m ulong 1 |
| 81 | global om2ln ulong 1 |
| 82 | global om2pos ulong 1 |
| 83 | global fmtm ulong 1 |
| 84 | global chkmode ulong 1 |
| 85 | global objmode ulong 1 |
| 86 | global objmeta ulong 1 |
| 87 | global chkln ulong 1 |
| 88 | global lbase ulong 1 |
| 89 | global sbase ulong 1 |
| 90 | global tka ulong 1 |
| 91 | global tkb ulong 1 |
| 92 | global dexp ulong 1 |
| 93 | global dsev ulong 1 |
| 94 | |
| 95 | note ---- executable contracts: OM-2 debug by default, release erases only validated pure predicates. |
| 96 | note Function prefixes are replayed at returns with their declaration scope, including inline frames. |
| 97 | global crel ulong 1 |
| 98 | global cpure ulong 1 |
| 99 | global cvalid ulong 1 |
| 100 | global clim ulong 1 |
| 101 | global crkind ulong 1 |
| 102 | global crval ulong 1 |
| 103 | global crtype ulong 1 |
| 104 | global cfpos ulong 8 |
| 105 | global cfline ulong 8 |
| 106 | global cflim ulong 8 |
| 107 | global cfhas ulong 8 |
| 108 | global csnap ulong 8 |
| 109 | global ckind ulong 1 |
| 110 | |
| 111 | note ---- OM-2 section 4 (unroll, inline, folding, bounds, sites). fn_inl/fn_body/fn_bln/fn_pn: a function's |
| 112 | note inline mark, its body offset and line, its parameter names. fstart: where the function being compiled |
| 113 | note starts (no longer a bound: OM-2 functions have no emitted-word budget). nmlo: names below it and at or above nglob are hidden while an |
| 114 | note inlined body is compiled (0 otherwise). fzone: open unrolled bodies and inline frames (folding is |
| 115 | note done only when it is above 0). inl and il_*: the inline frames (at most 4). ilp/nilp: the B words of |
| 116 | note an inlined ret, patched at its end. lastb/tgoc: the word after the last inlined ret's B and the last |
| 117 | note place a branch was patched to. u_*: the unrolled loop of each block. fok/fval/fty: a fold result. |
| 118 | note sitebuf/nsite: the omc-site records of om2 diag. |
| 119 | global fstart ulong 1 |
| 120 | global nmlo ulong 1 |
| 121 | global fzone ulong 1 |
| 122 | global inl ulong 1 |
| 123 | global il_cur ulong 8 |
| 124 | global il_line ulong 8 |
| 125 | global il_ret ulong 8 |
| 126 | global il_nn ulong 8 |
| 127 | global il_lo ulong 8 |
| 128 | global il_held ulong 8 |
| 129 | global il_ns ulong 8 |
| 130 | global il_res ulong 8 |
| 131 | global il_fn ulong 8 |
| 132 | global il_p0 ulong 8 |
| 133 | global nilp ulong 1 |
| 134 | global lastb ulong 1 |
| 135 | global tgoc ulong 1 |
| 136 | note fuel (E14, E16): the expansion fuel used by the function being compiled: an unrolled loop costs K when |
| 137 | note it starts, an inline expansion 1, at most 65536 in all (error 14) |
| 138 | global fuel ulong 1 |
| 139 | global fok ulong 1 |
| 140 | global fval ulong 1 |
| 141 | global fty ulong 1 |
| 142 | global nsite ulong 1 |
| 143 | global nie ulong 1 |
| 144 | |
| 145 | note ---- name table (arena group 3; names in scope bounded by the arena only): packed name, register, type, |
| 146 | note length, kind, address. Lookup is by the chained hash nm_h (group 4) with nm_nx; every change of nn goes |
| 147 | note through nm_set, so a chain holds exactly the names below nn, newest first ---- |
| 148 | global nn ulong 1 |
| 149 | note ---- long names: tok2 interns each word of 9..63 bytes that is not a number as the packed word |
| 150 | note 1 + 256 * index. Its low byte, 1, is below every byte a word can hold (33..255), so it never equals |
| 151 | note a name of 8 bytes or fewer or a keyword, and two words get the same packed word exactly when they |
| 152 | note are spelled the same: every table that compares packed words takes long names unchanged. |
| 153 | note ln_o: where the spelling starts in the input (it is read there, never copied); ln_l: its length; ln_h |
| 154 | note (group 6) the chained hash, bucket -> index + 1 of the newest, ln_x the one before it; ln_n: the |
| 155 | note count (arena group 5). tw8: the word's first 8 bytes before interning (cp_kind reads |
| 156 | note invariant there). Abstract, layout and layout-field names and IR-mode names stay at 8. |
| 157 | global ln_n ulong 1 |
| 158 | global tw8 ulong 1 |
| 159 | note ---- OM-2 pinned registers (AArch64 program mode only): X18..X26, which nothing else in a program names, |
| 160 | note hold for the whole run the base address of the first globals and the length of a global whose length |
| 161 | note is no CMP immediate. nm_pb / nm_pl: the base / length register of a global name (0: none); pinv the |
| 162 | note value of pin p (register 18 + p), npin how many are taken. eof_prog sets them before main; scrub sets |
| 163 | note them again after it clears X18..X26. pinshut: 1 once the body pass has begun a function; a global |
| 164 | note declared after that gets no pin, because a scrub compiled before it would clear its register and |
| 165 | note restore only the pins taken so far. ---- |
| 166 | global pinv ulong 9 |
| 167 | global npin ulong 1 |
| 168 | global pinshut ulong 1 |
| 169 | note ---- floats in v registers: kind 9 is a float held in v(16 + pool index of x register rv), the twin of |
| 170 | note pool register rv; vsl marks each pool slot whose value lives in its twin (an f32/f64 local name, a |
| 171 | note kind 9 value), saved and loaded as D around a call. fpw asks the next value read for kind 9 (1: a new |
| 172 | note twin, 2 + r: the twin of r); fpo hands that request to the part that makes the value. A float local |
| 173 | note name (nm_fv 1) lives in its twin; its x register holds a copy only while a reader needs one. ---- |
| 174 | global vsl uchar 16 |
| 175 | global fpw ulong 1 |
| 176 | global fpo ulong 1 |
| 177 | note fwv: rdval's fpw request at each nesting depth (kept here, not in a register of rdval) |
| 178 | |
| 179 | note ---- function table (arena group 7; chained hash fn_h, group 8, with fn_nx): name, address (byte offset |
| 180 | note in out), return type, parameter count, per-parameter type/length/kind (6 each), name length, name offset |
| 181 | note in the input ---- |
| 182 | note x86 Linux retains the parser's sixteen logical slots in each native frame. |
| 183 | note No A64 instruction may pass emit once the explicit target is selected (error 25). |
| 184 | global xtarget ulong 1 |
| 185 | note xefa: 1 under the first line `target a64efi` (docs/A64-EFI.md): the default AArch64 code generator, |
| 186 | note a PE32+ UEFI image, base-relative addresses (mataddr) and the efi and fw words; xtarget stays 0. |
| 187 | global xefa ulong 1 |
| 188 | global xnaddr ulong 1 |
| 189 | note x86efi (xtarget 2): exit-site jumps patched to the shared firmware return, the PE bss address, |
| 190 | note and the error/done branch lists of one efi operation (closed by xe 2). |
| 191 | global xnexit ulong 1 |
| 192 | global xbss ulong 1 |
| 193 | global xenerr ulong 1 |
| 194 | global xerrpos ulong 256 |
| 195 | global xerrcode ulong 256 |
| 196 | global xenend ulong 1 |
| 197 | global xendpos ulong 256 |
| 198 | global nf ulong 1 |
| 199 | global lastfn ulong 1 |
| 200 | global scanning ulong 1 |
| 201 | global ncalls ulong 1 |
| 202 | |
| 203 | |
| 204 | note ---- compiler state ---- |
| 205 | global npar ulong 1 |
| 206 | global held ulong 1 |
| 207 | global nslot ulong 1 |
| 208 | global curret ulong 1 |
| 209 | global progmode ulong 1 |
| 210 | global nglob ulong 1 |
| 211 | global hostargs ulong 1 |
| 212 | global maptab ulong 1 |
| 213 | global fdtab ulong 1 |
| 214 | global stkbytes ulong 1 |
| 215 | global osp ulong 1 |
| 216 | global osmax ulong 1 |
| 217 | global osbad ulong 1 |
| 218 | global dead ulong 1 |
| 219 | global poolb ulong 1 |
| 220 | note run-time pools (docs/RUNTIME-POOLS.md, OMEGESE 9.15): enl_at is the code offset of the unit's omc_enlarge |
| 221 | note helper plus 1, 0 until the unit's first enlarge. |
| 222 | global enl_at ulong 1 |
| 223 | |
| 224 | note ---- structs (16) and fields (256). R6. nm_type 16+index, kind 6 own, 7 edit, 8 view ---- |
| 225 | global st_name ulong 16 |
| 226 | global st_nf uchar 16 |
| 227 | global st_cells uchar 16 |
| 228 | global st_foff uchar 16 |
| 229 | global nst ulong 1 |
| 230 | global sf_name ulong 256 |
| 231 | global sf_type uchar 256 |
| 232 | global sf_len uchar 256 |
| 233 | global sf_off uchar 256 |
| 234 | global nsf ulong 1 |
| 235 | global svk ulong 16 |
| 236 | global svv ulong 16 |
| 237 | global svt ulong 16 |
| 238 | |
| 239 | note ---- OM-2 section 5 external layouts (16) and their fields (256): name, SIZE, first field, field count, |
| 240 | note the cursor and line after the block's end (the body pass jumps there). Field: name, type, COUNT (0 a |
| 241 | note scalar), byte offset, 1 big-endian. lymap marks the bytes taken while a layout is read. nm_lay / |
| 242 | note fn_play: the layout (index + 1) of a layout parameter name / parameter slot, else 0 ---- |
| 243 | global ly_name ulong 16 |
| 244 | global ly_size ulong 16 |
| 245 | global ly_fo ulong 16 |
| 246 | global ly_nf ulong 16 |
| 247 | global ly_ec ulong 16 |
| 248 | global ly_el ulong 16 |
| 249 | global nly ulong 1 |
| 250 | global lf_name ulong 256 |
| 251 | global lf_type uchar 256 |
| 252 | global lf_cnt ulong 256 |
| 253 | global lf_off ulong 256 |
| 254 | global lf_big uchar 256 |
| 255 | global nlf ulong 1 |
| 256 | global lymap uchar 4096 |
| 257 | |
| 258 | note ---- OM-2 section 5 fresh scratch (erratum E8). fn_pfr: 1 for a `fresh` parameter slot. nm_fr: the |
| 259 | note written-set slot (index + 1) a name's elements are tracked in, else 0. fz_n slots in use by the |
| 260 | note function being compiled (16), fz_len their N, fz_cur the elements definitely written on the path |
| 261 | note being compiled (bit i for element i); fz_ent / fz_thn (16 per block): the sets when the block opened |
| 262 | note and at its else. il_fz: fz_n when an inline frame opened. dobx 1: error 14 reports obligation=init ---- |
| 263 | global fz_n ulong 1 |
| 264 | global fz_len ulong 16 |
| 265 | global fz_cur ulong 16 |
| 266 | global il_fz ulong 8 |
| 267 | global dobx ulong 1 |
| 268 | |
| 269 | note ---- OM-2 section 5 abstract types (16; type 64 + index): name, its length, representation type (4 uint, |
| 270 | note 5 ulong), the preserving operations listed (1 rotr, 2 rotl, 4 and, 8 or, 16 xor), 1 when `holds NAME |
| 271 | note dup32` is declared. aw_*: the word reader of the exact-constructor test (place, packed word, length, |
| 272 | note newlines crossed before it) ---- |
| 273 | global ab_name ulong 16 |
| 274 | global ab_len ulong 16 |
| 275 | global ab_base uchar 16 |
| 276 | global ab_ops ulong 16 |
| 277 | global ab_holds uchar 16 |
| 278 | global nab ulong 1 |
| 279 | global aw_p ulong 1 |
| 280 | global aw_w ulong 1 |
| 281 | global aw_l ulong 1 |
| 282 | global aw_nl ulong 1 |
| 283 | |
| 284 | note ---- OM-2 section 6 unsized views (spec 4 slots, 6, erratum E2). An unsized `view T *` / `edit T *` |
| 285 | note name has length 0 in nm_len and its run-time element count in register nm_lr. Parameters take the |
| 286 | note registers x0..x5 by slots: an unsized array two (pointer, then count), every other parameter one |
| 287 | note (pwid, pslot); psl counts the slots of the fn line being read (6 at most, error 9). ul_k / ul_v: the |
| 288 | note count (kind 1 register / 3 number) of argument i of the call at value depth d, at d * 6 + i ---- |
| 289 | global psl ulong 1 |
| 290 | note ---- OM-2 section 6 multi-entry units: nexp `export fn` lines (32 at most, function mode only), fn_exp 1 |
| 291 | note for an exported function, expf 1 while an `export fn` line is read. With any export, words 0 .. E-1 |
| 292 | note of the code are B to each export in source order and the code starts at byte 176 + 4E ---- |
| 293 | global nexp ulong 1 |
| 294 | global expf ulong 1 |
| 295 | |
| 296 | note ======== leaf helpers ======== |
| 297 | |
| 298 | note poolc: the i-th register of the pool x0..x6, x8..x15, x17 (x7 is the runtime, x16 scratch) |
| 299 | fn poolc i ulong to ulong |
| 300 | if lt i 7 |
| 301 | ret i |
| 302 | end |
| 303 | if lt i 15 |
| 304 | ret add i 1 |
| 305 | end |
| 306 | ret 17 |
| 307 | end |
| 308 | |
| 309 | note pwid: the parameter slots of fn table entry p: 2 for an unsized array (pointer, count), else 1 |
| 310 | fn pwid p ulong to ulong |
| 311 | k = ulong uchar get a_ar add get a_rb 37 p |
| 312 | if and or eq k 2 eq k 3 eq get a_ar add get a_rb 36 p 0 |
| 313 | ret 2 |
| 314 | end |
| 315 | ret 1 |
| 316 | end |
| 317 | |
| 318 | note unsz: 1 when name entry i is an unsized array (nm_len 0, its count in register nm_lr), else 0. A text |
| 319 | note (kind 5) of length 0 (`text e ""`) is sized: its count is the number 0 and it has no count register. |
| 320 | fn unsz i ulong to ulong |
| 321 | if and eq a_g 6 i 0 ne a_gu 7 i 5 |
| 322 | if ne a_gu 7 i 10 |
| 323 | ret 1 |
| 324 | end |
| 325 | end |
| 326 | ret 0 |
| 327 | end |
| 328 | |
| 329 | note pslot: the first slot (register) of parameter i of function f (index) |
| 330 | fn pslot f ulong i ulong to ulong |
| 331 | s = ulong 0 |
| 332 | j = ulong 0 |
| 333 | while lt j i |
| 334 | s = add s pwid add mul f 6 j |
| 335 | j = add j 1 |
| 336 | end |
| 337 | ret s |
| 338 | end |
| 339 | |
| 340 | note ---- error reporting ---- |
| 341 | global msg uchar 65536 |
| 342 | global mc ulong 1 |
| 343 | note ======== the arena (notes at a_ar). Groups: 0 inp, 1 out, 2 site, 3 names, 4 name hash, 5 long names, |
| 344 | note 6 long-name hash, 7 functions, 8 function hash, 9 calls, 10 trap sites, 11 x86 addresses, 12 x86 exits, |
| 345 | note 13 blocks, 14 breaks, 15 continues, 16 inline rets, 17 inline edges, 18 value depth, 19 and 20 the |
| 346 | note settle order (ksettle). The regions of each group are listed at a_defs. ======== |
| 347 | |
| 348 | note a_def: region r is in group g with m elements per group index (0: a byte region) |
| 349 | fn a_def r ulong g ulong m ulong to void |
| 350 | put a_rg r g |
| 351 | put a_rm r m |
| 352 | end |
| 353 | |
| 354 | note a_words: the words region r takes at group capacity c |
| 355 | fn a_words r ulong c ulong to ulong |
| 356 | m = get a_rm r |
| 357 | if eq m 0 |
| 358 | ret shr add c 7 3 |
| 359 | end |
| 360 | ret mul c m |
| 361 | end |
| 362 | |
| 363 | note a_move: room in region r for group capacity c. The last region handed out grows in place; any other |
| 364 | note moves to the top with its words copied, and the words it leaves behind are counted in a_wst. Words |
| 365 | note past a_top were never handed out and are 0, so new elements start at 0 as a fresh pool's do. No |
| 366 | note room: error 14 (a_full). |
| 367 | fn a_move r ulong c ulong to void |
| 368 | w = a_words r c |
| 369 | o = get a_rw r |
| 370 | if le w o |
| 371 | ret |
| 372 | end |
| 373 | b = get a_rb r |
| 374 | t = get a_top 0 |
| 375 | if eq add b o t |
| 376 | if gt sub w o sub len a_ar t |
| 377 | a_full |
| 378 | end |
| 379 | put a_top 0 add b w |
| 380 | put a_rw r w |
| 381 | ret |
| 382 | end |
| 383 | if gt w sub len a_ar t |
| 384 | a_full |
| 385 | end |
| 386 | a_copy t b o |
| 387 | put a_wst 0 add get a_wst 0 o |
| 388 | put a_rb r t |
| 389 | put a_rw r w |
| 390 | put a_top 0 add t w |
| 391 | end |
| 392 | |
| 393 | note a_copy: words s .. s + n - 1 of the arena to d .. d + n - 1, in ascending order: d above s + n (no |
| 394 | note overlap, a move to the top) or d below s (a slide down, a_compact) |
| 395 | fn a_copy d ulong s ulong n ulong to void |
| 396 | i = ulong 0 |
| 397 | go = true |
| 398 | while go |
| 399 | m = ulong 0 |
| 400 | while and go lt m 999999 |
| 401 | if ge i n |
| 402 | go = false |
| 403 | else |
| 404 | put a_ar add d i get a_ar add s i |
| 405 | i = add i 1 |
| 406 | end |
| 407 | m = add m 1 |
| 408 | end |
| 409 | end |
| 410 | end |
| 411 | |
| 412 | note a_need: group g is about to use index n. Call sites outside this module test `if ge n get a_gp g` |
| 413 | note first: below the highest index asked so far the capacity already holds n, so no call is made. Below its capacity nothing happens; at or above it every |
| 414 | note region of the group grows to twice the capacity (at least n + 1, at least 64), moving to the top when |
| 415 | note it is not there already. When the moved copies do not fit in the free words, the arena is compacted |
| 416 | note (a_compact: the words moved regions left behind are reclaimed) and the group grows in place |
| 417 | note (a_relayout: everything above its first region slides up), to twice when that fits, else to the |
| 418 | note largest capacity that does (a_gfit). Before that the arena itself grows (a_grow); the compaction runs |
| 419 | note only when the host refused. So a table is refused (error 14) only when the host refuses the arena's |
| 420 | note growth and the live tables with its group grown by one entry no longer fit in the arena as it is. |
| 421 | note a_gp keeps the highest index asked for, plus 1, for the omc-use record. |
| 422 | fn a_need g ulong n ulong to void |
| 423 | if ge n get a_gp g |
| 424 | put a_gp g add n 1 |
| 425 | end |
| 426 | c = get a_gc g |
| 427 | if lt n c |
| 428 | ret |
| 429 | end |
| 430 | c = shl c 1 |
| 431 | if le c n |
| 432 | c = add n 1 |
| 433 | end |
| 434 | if lt c 64 |
| 435 | c = ulong 64 |
| 436 | end |
| 437 | if gt a_gneed g c sub len a_ar get a_top 0 |
| 438 | a_grow a_gneed g c |
| 439 | end |
| 440 | cm = ulong 0 |
| 441 | if gt a_gneed g c sub len a_ar get a_top 0 |
| 442 | cm = ulong 1 |
| 443 | end |
| 444 | if eq a_ok g c add get a_top 0 a_gneed g c 0 |
| 445 | cm = ulong 1 |
| 446 | end |
| 447 | note under a ceiling a move to the top never raises the high-water (the group grows in place after a compaction), |
| 448 | note and a group never grows to less than its doubling: then the words handed out follow the same course for |
| 449 | note every ceiling, and a unit refused at a ceiling is refused at every lower one |
| 450 | if ne get a_cel 0 0 |
| 451 | if ne get a_rdy 0 0 |
| 452 | if gt add get a_top 0 a_gneed g c get a_hw 0 |
| 453 | cm = ulong 1 |
| 454 | end |
| 455 | end |
| 456 | end |
| 457 | if ne cm 0 |
| 458 | if eq get a_rdy 0 0 |
| 459 | if ne get a_nr 0 1 |
| 460 | a_full |
| 461 | end |
| 462 | end |
| 463 | a_compact |
| 464 | if ne get a_cel 0 0 |
| 465 | if gt a_gextra g c sub len a_ar get a_top 0 |
| 466 | a_grow a_gextra g c |
| 467 | end |
| 468 | if ne get a_rdy 0 0 |
| 469 | if ne a_bad g c 0 |
| 470 | a_full |
| 471 | end |
| 472 | end |
| 473 | end |
| 474 | if ne a_bad g c 0 |
| 475 | c = a_gfit g n c |
| 476 | end |
| 477 | a_relayout g c |
| 478 | put a_gc g c |
| 479 | a_hwset |
| 480 | ret |
| 481 | end |
| 482 | r = ulong 0 |
| 483 | while lt r get a_nr 0 |
| 484 | if eq get a_rg r g |
| 485 | a_move r c |
| 486 | end |
| 487 | r = add r 1 |
| 488 | end |
| 489 | put a_gc g c |
| 490 | a_hwset |
| 491 | end |
| 492 | |
| 493 | note a_hwset: a_hw follows a_top up. While a_rdin reads the input, region 0 is the only region (a_nr 1): it grows |
| 494 | note in place, words past the input are handed out but never touched, and how far depends on how the reads were |
| 495 | note cut (a pipe or a file), so a_hw is not followed then; a_rdin sets it to the words the input holds |
| 496 | fn a_hwset to void |
| 497 | if eq get a_nr 0 1 |
| 498 | ret |
| 499 | end |
| 500 | if gt get a_top 0 get a_hw 0 |
| 501 | put a_hw 0 get a_top 0 |
| 502 | end |
| 503 | end |
| 504 | |
| 505 | note a_grow: the arena a_ar grows so that w more words are free above a_top: to twice its length, or to a_top |
| 506 | note + w when that is more (doubling, so the copies a_need makes are linear in the arena's final size). A |
| 507 | note refusal by the host (enlarge's negative result: -12 when mmap or mremap fails, -22 past 2^63 bytes) |
| 508 | note leaves a_ar as it was, and a_need goes on to compact. Words past the old length are 0 (a fresh pool's |
| 509 | note pages), as a_move expects of words above a_top. |
| 510 | fn a_grow w ulong to void |
| 511 | t = add get a_top 0 w |
| 512 | n = shl len a_ar 1 |
| 513 | if lt n t |
| 514 | n = t |
| 515 | end |
| 516 | note under a memory ceiling the arena grows at most to a_capw words; when that is less than the tables need, |
| 517 | note a_need goes on as after a host refusal (compaction, then error 14 full=1) |
| 518 | if ne get a_cel 0 0 |
| 519 | c = a_capw 0 |
| 520 | if gt n c |
| 521 | n = c |
| 522 | end |
| 523 | end |
| 524 | r = enlarge a_ar n |
| 525 | end |
| 526 | |
| 527 | note a_capw: the arena's largest length in words under the ceiling with the output so far: A + A / 128 + 16 MiB + O |
| 528 | note <= C, A = 8 words, so words <= (C - 16 MiB - O) / 129 * 16 (0 when C does not cover 16 MiB and O) |
| 529 | fn a_capw z ulong to ulong |
| 530 | f = add 16777216 a_resv 0 0 |
| 531 | if le get a_cel 0 f |
| 532 | ret 0 |
| 533 | end |
| 534 | ret mul div sub get a_cel 0 f 129 16 |
| 535 | end |
| 536 | |
| 537 | note a_marg: the margin added to b bytes of arena: b / 128 for the kernel's page tables, 16 MiB for omc's image |
| 538 | note (docs/RUNTIME-POOLS.md s6, "The margin") |
| 539 | fn a_marg b ulong to ulong |
| 540 | ret add add b shr b 7 16777216 |
| 541 | end |
| 542 | |
| 543 | note a_resv: the output reserve in bytes: the capacities of group 1 (the artifact) and group 2 (the om2 diag site |
| 544 | note records written after it), with group g at capacity c. Everything omc writes beyond them is small and |
| 545 | note inside the margin (diagnostics, the omc-use record) |
| 546 | fn a_resv g ulong c ulong to ulong |
| 547 | r = get a_gc 1 |
| 548 | if eq g 1 |
| 549 | r = c |
| 550 | end |
| 551 | t = get a_gc 2 |
| 552 | if eq g 2 |
| 553 | t = c |
| 554 | end |
| 555 | ret add r t |
| 556 | end |
| 557 | |
| 558 | note a_ok: 1 when group g at capacity c with the words handed out at t keeps the budget under the ceiling: the most |
| 559 | note words ever handed out (a_hw, or t when higher) in bytes, their margin and the output reserve within C; 1 |
| 560 | note without a ceiling. Every growth keeps it, so the artifact and the site records always fit when written |
| 561 | fn a_ok g ulong c ulong t ulong to ulong |
| 562 | if eq get a_cel 0 0 |
| 563 | ret 1 |
| 564 | end |
| 565 | h = get a_hw 0 |
| 566 | if gt t h |
| 567 | h = t |
| 568 | end |
| 569 | if gt add a_marg shl h 3 a_resv g c get a_cel 0 |
| 570 | ret 0 |
| 571 | end |
| 572 | ret 1 |
| 573 | end |
| 574 | |
| 575 | note a_bad: 1 when group g cannot grow in place to capacity c after a compaction: no room in the arena, or past |
| 576 | note the budget (a_ok) |
| 577 | fn a_bad g ulong c ulong to ulong |
| 578 | x = a_gextra g c |
| 579 | if gt x sub len a_ar get a_top 0 |
| 580 | ret 1 |
| 581 | end |
| 582 | if eq a_ok g c add get a_top 0 x 0 |
| 583 | ret 1 |
| 584 | end |
| 585 | ret 0 |
| 586 | end |
| 587 | |
| 588 | note a_ceilo: before the artifact (o bytes) is written: under a ceiling, the most arena words ever handed out |
| 589 | note (a_hw: the words above it were never handed out and their pages never touched), the margin and o must fit in |
| 590 | note it (the output grows inside its region without a growth to check), else error 14 full=1 and nothing is written |
| 591 | fn a_ceilo o ulong to void |
| 592 | if eq get a_cel 0 0 |
| 593 | ret |
| 594 | end |
| 595 | if gt add a_marg shl get a_hw 0 3 o get a_cel 0 |
| 596 | a_full |
| 597 | end |
| 598 | end |
| 599 | |
| 600 | note a_env: the memory ceiling from the environment (docs/RUNTIME-POOLS.md s6): the first entry named |
| 601 | note OMC_MEMORY_MAX, read with envcnt / envread into a_eb before the input; an entry that does not fit is error 26 |
| 602 | note D2-GENERATED-BEGIN |
| 603 | text d2pin "7c3278640c250cb51f0948440c03d4e4ae978311586b38f8c7966168de91eb7b" |
| 604 | text d2means "1|the compiler's standard input could not be read\n2|the compiler's standard output could not be written\n3|unknown name or field, or a word this mode does not provide\n4|the line ends where a word or value is needed\n5|extra words after a complete statement\n6|malformed number or token\n7|type mismatch\n8|number out of range for its type or place\n9|word or declaration in a place that does not allow it\n10|duplicate name\n11|bare number without a type from its context\n12|register pool exhausted\n13|name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode)\n14|capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound)\n15|missing end\n16|syntax: unknown or misplaced word\n17|line after ret, break, continue, trap or exit in the same block\n18|a function with a result can reach its end\n19|global passed as an argument, or one array twice in a call\n20|write to a view or a text\n21|constant index outside the array\n22|malformed text literal\n23|size capacity\n24|AArch64 branch displacement out of range\n25|unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14)\n26|the compiler's environment entry OMC_MEMORY_MAX is not empty, 0 or 1 to 19 decimal digits below 2^63, or an entry is too long to read whole\n27|fresh element read before it is definitely written, or fresh array passed on\n28|abstract type: seal outside its constructor, or an unsupported holds\n29|external layout out of bounds or misplaced\n30|contract syntax misplaced or not supported here (IR mode included)\n" |
| 605 | text d2sites "1|a_env: the compiler's environment entry OMC_MEMORY_MAX is not empty, 0 or 1 to 19 decimal digits below 2^63, or an entry is too long to read whole; condition if lt kl 0\n2|a_envv: the compiler's environment entry OMC_MEMORY_MAX is not empty, 0 or 1 to 19 decimal digits below 2^63, or an entry is too long to read whole; condition if gt sub k 15 19\n3|a_envv: the compiler's environment entry OMC_MEMORY_MAX is not empty, 0 or 1 to 19 decimal digits below 2^63, or an entry is too long to read whole; condition if or lt c 48 gt c 57\n4|a_envv: the compiler's environment entry OMC_MEMORY_MAX is not empty, 0 or 1 to 19 decimal digits below 2^63, or an entry is too long to read whole; condition if gt v 922337203685477580\n5|a_envv: the compiler's environment entry OMC_MEMORY_MAX is not empty, 0 or 1 to 19 decimal digits below 2^63, or an entry is too long to read whole; condition if ge v 9223372036854775808\n6|a_full: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound)\n7|a_rdin: the compiler's standard input could not be read; condition if lt n 0\n623|mflush: standard output refused a diagnostic or query chunk\n8|emit: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if ne get xtarget 0 0\n9|a_ogrow: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge o lim\n10|tok_num: malformed number or token; condition if eq ndig 0\n11|tok_num: malformed number or token; condition if gt ndig 20\n12|tok_num: malformed number or token; condition if gt d 9\n13|tok_num: number out of range for its type or place; condition if gt v lim\n14|tok_num: number out of range for its type or place; condition if and eq v lim gt d 5\n15|tok_num: number out of range for its type or place; condition if gt v half\n16|tok_text: malformed text literal; condition if ge get cur 0 get inlen 0\n17|tok_text: malformed text literal; condition if eq b 10\n18|tok_text: malformed text literal; condition if ge get cur 0 get inlen 0\n19|tok_text: malformed text literal; condition if eq a_ib get cur 0 10\n20|tok_text: malformed text literal; condition if gt a_ib get cur 0 32\n21|tok: syntax: unknown or misplaced word; condition if lt c 32\n22|fmttail: malformed number or token; condition if bad\n23|fmtprep: syntax: unknown or misplaced word; condition if ne get om2pos 0 0\n24|fmtprep: malformed number or token; condition if eq b 13\n25|fmtprep: syntax: unknown or misplaced word; condition if eq get om2m 0 2\n26|tok_hex: malformed number or token; condition if or eq c 120 eq c 88\n27|tok_hex: malformed number or token; condition if eq c 88\n28|tok_hex: malformed number or token; condition if eq n 0\n29|tok_hex: malformed number or token; condition if gt n 16\n30|tok_hex: malformed number or token; condition otherwise: if and ge d 97 le d 102\n31|fparse: number out of range for its type or place; condition if gt get fnd 0 922337203685477580\n32|fparse: number out of range for its type or place; condition if gt d 7\n33|fparse: malformed number or token; condition if and ne get fg_seen 0 0 eq get fg_fl 0 0\n34|fparse: malformed number or token; condition if ne p e\n35|fexp: number out of range for its type or place; condition if gt get fg_ex 0 999\n36|fexp: malformed number or token; condition if eq get fg_ed 0 0\n37|fsufx: malformed number or token; condition if ne r 3\n38|fsufx: malformed number or token; condition if ne uchar and shr get a_ar shr p 3 shl and p 7 3 255 102\n39|fsufx: malformed number or token; condition otherwise: if and eq a_ib add p 1 54 eq a_ib add p 2 52\n40|fpack: number out of range for its type or place; condition if ge E maxe\n41|fbits: number out of range for its type or place; condition if gt p 308\n42|fsizeof: type mismatch; condition if ge t 64\n43|foffset: syntax: unknown or misplaced word; condition if ne get tk 0 1\n44|foffset: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63\n45|foffset: unknown name or field, or a word this mode does not provide; condition if eq sid 0\n46|foffset: syntax: unknown or misplaced word; condition if ne get tk 0 1\n47|foffset: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63\n48|foffset: unknown name or field, or a word this mode does not provide; condition if eq f 0\n49|newname: syntax: unknown or misplaced word; condition if ne kwx w 0\n50|newname: duplicate name; condition if ne findstruct w 0\n51|newname: duplicate name; condition if ne findname w 0\n52|newname: duplicate name; condition if ne findlay w 0\n53|newname: duplicate name; condition if ne findab w 0\n54|newname: duplicate name; condition if ne findfn w l s 0\n55|addname: syntax: unknown or misplaced word; condition if ne kwx w 0\n56|alloc: register pool exhausted; condition if ge i 16\n57|bdisp: AArch64 branch displacement out of range; condition if ne and diff 3 0\n58|bdisp: AArch64 branch displacement out of range; condition if and gt diff sub span 4 lt diff sub ulong 0 span\n59|range: number out of range for its type or place; condition if ne big 0\n60|range: number out of range for its type or place; condition if ne shr v 63 0\n61|range: number out of range for its type or place; condition if ne big 0\n62|range: number out of range for its type or place; condition if ge v lim\n63|range: number out of range for its type or place; condition if ge add v half lim\n64|force: bare number without a type from its context\n65|elemtype: word or declaration in a place that does not allow it; condition if lt t 2\n66|elemtype: type mismatch; condition if ge t 64\n67|arrlen: size capacity; condition if ne get tbig 0 0\n68|arrlen: number out of range for its type or place; condition if or eq v 0 ne shr v 63 0\n69|arrlen: size capacity; condition if gt v 16777216\n70|lenval: line ended before the required array expression; condition if eq k 0\n71|lenval: syntax: unknown or misplaced word; condition if ge t 10\n72|lenval: syntax: unknown or misplaced word\n73|typeword: the line ends where a word or value is needed; condition if eq k 0\n74|typeword: syntax: unknown or misplaced word; condition if ne k 1\n75|typeword: syntax: unknown or misplaced word; condition if gt get tl 0 8\n76|typeword: syntax: unknown or misplaced word; condition if eq c 0\n77|typeword: word or declaration in a place that does not allow it; condition if eq c 76\n78|typeword: word or declaration in a place that does not allow it; condition if ne get irmode 0 0\n79|typeword: syntax: unknown or misplaced word; condition if gt sub c 1 8\n80|eol: extra words after a complete statement; condition if and ne k 0 ne k 3\n81|arrname: the line ends where a word or value is needed; condition if eq k 0\n82|arrname: the line ends where a word or value is needed; condition if eq k 3\n83|arrname: syntax: unknown or misplaced word; condition if ne k 1\n84|arrname: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63\n85|arrname: word or declaration in a place that does not allow it; condition if eq kw get tw 0 193\n86|arrname: unknown name or field, or a word this mode does not provide; condition if eq e 0\n87|arrname: type mismatch; condition if eq k 0\n88|arrname: type mismatch; condition if eq pk 0\n89|topname: syntax: unknown or misplaced word; condition if ne get tk 0 1\n90|topname: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63\n91|topname: syntax: unknown or misplaced word; condition if ne kw w 0\n92|xfconv: word or declaration in a place that does not allow it; condition if or eq ft 1 eq tt 1\n93|xfconv: type mismatch; condition if or eq ft 13 eq tt 13\n94|xfbinop: type mismatch; condition if or or lt op 33 gt op 36 ge op 41\n95|fintr: word or declaration in a place that does not allow it; condition if ne get irmode 0 0\n96|fintr: type mismatch; condition if eq get rk 0 2\n97|fintr: bare number without a type from its context; condition if eq get rk 0 6\n98|fintr: type mismatch; condition if eq isfloat t 0\n99|fminmax: word or declaration in a place that does not allow it; condition if ne get irmode 0 0\n100|fminmax: bare number without a type from its context; condition if or eq get rk 0 2 eq get rk 0 6\n101|fminmax: bare number without a type from its context; condition if or eq get rk 0 2 eq get rk 0 6\n102|fminmax: type mismatch; condition if or eq isfloat at 0 eq isfloat get rt 0 0\n103|fminmax: type mismatch; condition if ne at get rt 0\n104|ffma: bare number without a type from its context; condition if eq get rk 0 6\n105|ffma: type mismatch; condition if eq isfloat at 0\n106|ffma: bare number without a type from its context; condition if eq get rk 0 6\n107|ffma: type mismatch; condition if ne get rt 0 at\n108|ffma: bare number without a type from its context; condition if eq get rk 0 6\n109|ffma: type mismatch; condition if ne get rt 0 at\n110|ffma: word or declaration in a place that does not allow it; condition if or ne get irmode 0 0 ne get xtarget 0 0\n111|fp_conv: word or declaration in a place that does not allow it; condition if eq ft 1\n112|fp_conv: word or declaration in a place that does not allow it; condition if eq tt 1\n113|binrot: type mismatch; condition if or lt ty 2 gt ty 5\n114|binop: type mismatch; condition if or or lt op 33 gt op 36 ge op 41\n115|binop: type mismatch; condition if and ge op 38 le op 42\n116|binop: type mismatch; condition if gt sub op 38 2\n117|elemaddr: type mismatch; condition if or or eq t 1 eq t 10 eq t 11\n118|elemaddr: constant index outside the array; condition if ge v ln\n119|aa_word: the line ends where a word or value is needed; condition if eq k 0\n120|aa_word: syntax: unknown or misplaced word; condition if ne k 1\n121|aa_word: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63\n122|arrarg: syntax: unknown or misplaced word; condition if or lt c 57 gt c 58\n123|arrarg: unknown name or field, or a word this mode does not provide; condition if eq e 0\n124|arrarg: type mismatch; condition if eq k 0\n125|arrarg: global passed as an argument, or one array twice in a call; condition if eq k 10\n126|arrarg: type mismatch; condition if ge k 6\n127|arrarg: global passed as an argument, or one array twice in a call; condition if eq k 4\n128|arrarg: write to a view or a text; condition if eq md 57\n129|arrarg: write to a view or a text; condition if and ne k 1 ne k 3\n130|arrarg: type mismatch; condition if eq md 58\n131|arrarg: type mismatch; condition if ne a_gu 5 i a_gu 35 p\n132|arrarg: type mismatch; condition if ne a_g 6 i a_g 36 p\n133|arrpart: global passed as an argument, or one array twice in a call; condition if eq k 10\n134|arrpart: type mismatch; condition if ge k 6\n135|arrpart: global passed as an argument, or one array twice in a call; condition if eq k 4\n136|arrpart: write to a view or a text; condition if eq md 57\n137|arrpart: write to a view or a text; condition if and ne k 1 ne k 3\n138|arrpart: type mismatch; condition if eq md 58\n139|arrpart: type mismatch; condition if ne ulong a_gu 5 i ulong a_gu 35 p\n140|arrpart: type mismatch; condition if ne get a_ar add get a_rb 36 p 0\n141|arrpart: type mismatch; condition if and ne k 5 ne k 13\n142|arrpart: type mismatch; condition if and ne k 5 ne k 13\n143|vdec: contract syntax misplaced or not supported here (IR mode included); condition if and ne get cpure 0 0 ge get rt 0 10\n144|vt_un: type mismatch; condition if eq c 50\n145|vt_un: type mismatch; condition if eq ty 13\n146|vt_un: type mismatch; condition if or eq ty 1 eq ty 13\n147|vt_conv: type mismatch; condition if or eq ft 13 eq tt 13\n148|vt_conv: word or declaration in a place that does not allow it; condition if eq ft 1\n149|vt_conv: word or declaration in a place that does not allow it; condition if eq tt 1\n150|vt_conv: word or declaration in a place that does not allow it; condition if eq ft 1\n151|vt_conv: word or declaration in a place that does not allow it; condition if eq tt 1\n152|vs_chk: type mismatch; condition if ne uchar get a_ar add get a_rb 5 sub e 1 2\n153|vs_chk: type mismatch; condition if ne uchar get a_ar add get a_rb 5 sub e 1 2\n154|vs_call: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if ne get xefa 0 0\n155|ca_scal: type mismatch; condition if ne get rt 0 ulong uchar get a_ar add get a_rb 35 p\n156|ca_arr: global passed as an argument, or one array twice in a call; condition if eq a_g 77 add add cb mul j 3 2 get rt 0\n157|vs_fd: type mismatch; condition if ne get rt 0 8\n158|vs_arr: type mismatch; condition if ne uchar get a_ar add get a_rb 7 sub e 1 10\n159|vs_arr: write to a view or a text; condition if or eq k 2 eq k 5\n160|vs_off: type mismatch; condition if ne get rt 0 5\n161|vs_end: type mismatch; condition if ne get rt 0 5\n162|harg: type mismatch; condition if ne get rt 0 ty\n163|hscalar: size capacity; condition if gt fdpool 1073739776\n164|harray: type mismatch; condition if ne uchar get a_ar add get a_rb 5 sub e 1 2\n165|mtinit: size capacity; condition if gt p 1073737728\n166|mnew: word or declaration in a place that does not allow it; condition if or ne a_g 77 add x 14 3 ne a_g 77 add x 16 3\n167|mnew: word or declaration in a place that does not allow it; condition if and ne acc 1 ne acc 3\n168|mnew: word or declaration in a place that does not allow it; condition if and and and ne mode 1 ne mode 2 ne mode 33 ne mode 34\n169|mbind: word or declaration in a place that does not allow it; condition if ne get a_ar add get a_rb 77 add x 14 3\n170|mbind: word or declaration in a place that does not allow it; condition if and ne acc 1 ne acc 3\n171|hdevcall: global passed as an argument, or one array twice in a call; condition if eq e f\n172|mmapio: word or declaration in a place that does not allow it; condition if ne get a_ar add get a_rb 77 add x 12 3\n173|mmapio: word or declaration in a place that does not allow it; condition if and ne w 4 ne w 8\n624|ksize: KFD request is not in the checked request allowlist\n625|kctl: KFD request must be a literal\n626|kctl: literal KFD header length differs from the request ABI size\n627|kctl: KFD header and pointed-to span must be distinct arrays\n174|hostval: word or declaration in a place that does not allow it; condition if and ne get objmode 0 0 and ge c 166 le c 177\n175|hostval: word or declaration in a place that does not allow it; condition if eq get progmode 0 0\n176|hostval: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if and ge c 228 le c 232\n177|hostval: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if ne get xtarget 0 0\n178|hostval: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if ne get xefa 0 0\n179|hostval: word or declaration in a place that does not allow it; condition if eq get om2 0 0\n180|hostval: word or declaration in a place that does not allow it; condition if eq ok 0\n181|hostval: size capacity; condition if gt fdpool 1073739776\n182|hostval: word or declaration in a place that does not allow it; condition if ne get a_ar add get a_rb 77 add x 12 3\n183|hostval: word or declaration in a place that does not allow it; condition if eq n 99\n184|hostval: word or declaration in a place that does not allow it; condition if ne get a_ar add get a_rb 77 add x 12 3\n185|hostval: word or declaration in a place that does not allow it; condition if and ne q 15213 ne q 15214\n186|rdval: contract syntax misplaced or not supported here (IR mode included); condition if ne get cpure 0 0\n187|rdval: word or declaration in a place that does not allow it; condition if eq get curfn 0 fe\n188|rdval: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if gt get depth 0 32768\n189|rdval: the line ends where a word or value is needed; condition if or eq get tk 0 0 eq get tk 0 3\n190|rdval: syntax: unknown or misplaced word; condition if eq get tk 0 4\n191|rdval: word or declaration in a place that does not allow it; condition if ne get irmode 0 0\n192|rdval: type mismatch; condition if ge exp 64\n193|rdval: type mismatch; condition if eq isfloat exp 0\n194|rdval: type mismatch; condition if and ne exp 0 ne exp t\n195|rdval: type mismatch; condition if or ge exp 64 ne isfloat exp 0\n196|rdval: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63\n197|rdval: type mismatch; condition if eq uchar get a_ar add get a_rb 23 sub f 1 12\n198|rdval: contract syntax misplaced or not supported here (IR mode included); condition if eq get crkind 0 0\n199|rdval: type mismatch; condition if ne uchar get a_ar add get a_rb 7 sub e 1 0\n200|rdval: contract syntax misplaced or not supported here (IR mode included); condition if ge get rt 0 10\n201|rdval: unknown name or field, or a word this mode does not provide; condition if eq f 0\n202|rdval: type mismatch; condition if eq uchar get a_ar add get a_rb 23 sub f 1 12\n203|rdval: type mismatch; condition if ge get rt 0 64\n204|rdval: type mismatch; condition if eq get rt 0 1\n205|rdval: word or declaration in a place that does not allow it; condition if ne get irmode 0 0\n206|rdval: bare number without a type from its context; condition if or eq get rk 0 6 eq get rk 0 2\n207|rdval: type mismatch; condition if eq ft 1\n208|rdval: type mismatch; condition if or ge ft 64 ge tt 64\n209|rdval: type mismatch; condition if ne twid ft twid tt\n210|rdval: type mismatch; condition if ge get rt 0 64\n211|rdval: bare number without a type from its context; condition if eq get rk 0 2\n212|rdval: type mismatch; condition if eq get rk 0 6\n213|rdval: type mismatch; condition if ge get rt 0 64\n214|rdval: bare number without a type from its context; condition if eq get rk 0 2\n215|rdval: syntax: unknown or misplaced word; condition if ne get tk 0 1\n216|rdval: syntax: unknown or misplaced word; condition if gt get tl 0 8\n217|rdval: syntax: unknown or misplaced word; condition if ne kw get tw 0 75\n218|rdval: word or declaration in a place that does not allow it; condition if or eq c 77 eq c 193\n219|rdval: word or declaration in a place that does not allow it; condition if or eq get progmode 0 0 ne get irmode 0 0\n220|rdval: type mismatch; condition if ge uchar get a_ar add get a_rb 7 sub e 1 6\n222|rdval: word or declaration in a place that does not allow it; condition if eq c 244\n223|rdval: syntax: unknown or misplaced word; condition if and gt sub c 33 17 gt sub c 59 1\n224|rdval: type mismatch; condition if ge get rt 0 64\n225|rdval: bare number without a type from its context; condition if eq get rk 0 2\n226|rdval: bare number without a type from its context; condition if and eq ak 6 eq bk 6\n227|rdval: bare number without a type from its context; condition if eq bt 0\n228|rdval: type mismatch; condition if eq isfloat bt 0\n229|rdval: bare number without a type from its context; condition if eq at 0\n230|rdval: type mismatch; condition if eq isfloat at 0\n231|rdval: type mismatch; condition if or eq ak 2 eq ak 3\n232|rdval: type mismatch; condition if or eq bk 2 eq bk 3\n233|rdval: type mismatch; condition if or eq ak 6 eq bk 6\n234|rdval: bare number without a type from its context; condition if eq bk 2\n235|rdval: type mismatch; condition if ne at bt\n236|cond: type mismatch; condition if ne get rt 0 1\n237|cond: type mismatch; condition if ne get rt 0 1\n238|sa_arr: word or declaration in a place that does not allow it; condition if ne get nb 0 0\n239|sa_arr: size capacity; condition if gt s 4194304\n240|sa_arr: type mismatch; condition if ne get rt 0 t\n241|s_assign: type mismatch; condition if ne uchar get a_ar add get a_rb 7 i 0\n242|s_assign: type mismatch; condition if ne get rt 0 t\n243|s_assign: type mismatch; condition if ne get rt 0 t\n244|s_assign: duplicate name; condition if ne findfn w 0 0 0\n245|s_assign: bare number without a type from its context; condition if eq get rk 0 2\n246|s_enlarge: type mismatch; condition if ne uchar get a_ar add get a_rb 7 i 0\n247|s_enlarge: type mismatch; condition if ne uchar get a_ar add get a_rb 5 i 9\n248|s_enlarge: duplicate name; condition if ne findfn w 0 0 0\n249|s_enlarge: type mismatch; condition if ne uchar get a_ar add get a_rb 7 sub p 1 10\n250|s_enlarge: bare number without a type from its context; condition if eq get rk 0 2\n251|s_enlarge: type mismatch; condition if ne get rt 0 5\n252|s_name: type mismatch; condition if ne uchar get a_ar add get a_rb 23 sub f 1 12\n253|fn_p: syntax: unknown or misplaced word; condition if ne get tk 0 1\n254|fn_p: syntax: unknown or misplaced word; condition if gt get tl 0 8\n255|fn_to: the line ends where a word or value is needed; condition if eq get tk 0 0\n256|fn_to: syntax: unknown or misplaced word; condition if ne get tk 0 1\n257|fn_to: syntax: unknown or misplaced word; condition if gt get tl 0 8\n258|s_fn: missing end; condition if ne get curret 0 0\n259|s_fn: syntax: unknown or misplaced word; condition if ne get tk 0 1\n260|s_fn: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63\n261|s_fn: syntax: unknown or misplaced word; condition if eq get tl 0 6\n262|s_fn: syntax: unknown or misplaced word; condition if ne kw w 0\n263|s_fn: the line ends where a word or value is needed; condition if eq get tk 0 0\n264|s_fn: syntax: unknown or misplaced word; condition if ne get tk 0 1\n265|s_fn: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63\n266|s_fn: syntax: unknown or misplaced word; condition if ne c 0\n267|s_fn: word or declaration in a place that does not allow it; condition if ge get psl 0 6\n268|s_fn: word or declaration in a place that does not allow it; condition if gt get psl 0 6\n269|s_ret: type mismatch; condition if ne get rt 0 r\n270|s_break: word or declaration in a place that does not allow it; condition if eq found 0\n271|s_break: word or declaration in a place that does not allow it; condition if ge get a_ar add get a_rb 49 bi 5\n272|s_cont: word or declaration in a place that does not allow it; condition if eq found 0\n273|s_cont: word or declaration in a place that does not allow it; condition if ge get a_ar add get a_rb 49 bi 5\n274|s_put: write to a view or a text; condition if or eq k 2 eq k 5\n275|s_put: type mismatch; condition if ne get rt 0 t\n276|s_const: syntax: unknown or misplaced word; condition if ne get tk 0 1\n277|s_const: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63\n278|s_const: syntax: unknown or misplaced word; condition if ne kw w 0\n279|s_const: type mismatch; condition if ge t 64\n280|s_const: syntax: unknown or misplaced word; condition if ne get rk 0 6\n281|s_const: the line ends where a word or value is needed; condition if eq get tk 0 0\n282|s_const: type mismatch; condition if eq get tk 0 5\n283|s_const: syntax: unknown or misplaced word; condition if ne get tk 0 2\n284|s_global: size capacity; condition if gt s 1073741824\n285|sg_pool: word or declaration in a place that does not allow it; condition if eq get progmode 0 0\n286|sg_pool: word or declaration in a place that does not allow it; condition if ne get irmode 0 0\n287|sg_pool: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if gt get xtarget 0 1\n288|sg_pool: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if ne get xefa 0 0\n289|sg_pool: size capacity; condition if gt s 1073741824\n290|s_text: syntax: unknown or misplaced word; condition if ne get tk 0 4\n291|s_text: malformed text literal; condition if and ne b 92 ne b 34\n292|s_else: missing end; condition if eq n 0\n293|s_else: missing end; condition if ne get a_ar add get a_rb 49 i 1\n294|s_while: extra words after a complete statement; condition if ne k 1\n295|s_while: extra words after a complete statement; condition if gt get tl 0 8\n296|s_while: extra words after a complete statement; condition if ne kw get tw 0 70\n297|s_while: number out of range for its type or place; condition if ge sub v 1 9223372036854775807\n298|sf_num: number out of range for its type or place; condition if ge sub bn 1 9223372036854775807\n299|sf_val: number out of range for its type or place; condition if ge sub n 1 9223372036854775807\n300|s_for: the line ends where a word or value is needed; condition if eq get tk 0 0\n301|s_for: syntax: unknown or misplaced word; condition if ne get tk 0 1\n302|s_for: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63\n303|s_for: syntax: unknown or misplaced word; condition if ne kw w 0\n304|s_for: type mismatch; condition if or eq t 1 ge t 10\n305|s_for: the line ends where a word or value is needed; condition if eq get tk 0 0\n306|s_for: type mismatch; condition if ne get rt 0 t\n307|s_for: syntax: unknown or misplaced word; condition if eq peekw 181\n308|s_unroll: number out of range for its type or place; condition if or eq kk 0 gt kk 64\n309|fuelc: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if gt add get fuel 0 n 65536\n310|fn_tail: extra words after a complete statement; condition if and ne k 0 ne k 3\n311|inl_body: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge lv 4\n312|inl_body: word or declaration in a place that does not allow it; condition if eq get curfn 0 fe\n313|inl_body: word or declaration in a place that does not allow it; condition if eq get il_fn j fe\n314|inl_run: missing end; condition if ne stmt 0\n315|s_iret: type mismatch; condition if ne get rt 0 r\n316|s_iret: type mismatch; condition if ne get rt 0 r\n317|s_inlx: a function with a result can reach its end; condition if ne uchar get a_ar add get a_rb 23 sub fe 1 12\n318|finish: a function with a result can reach its end; condition if ne get curret 0 12\n628|finish: word or declaration in a place that does not allow it; condition if or ne get osbad 0 0 ne get osp 0 0\n319|writeout: the compiler's standard output could not be written; condition if eq a_out 1 1 st get oc 0 0\n320|eof_prog: syntax: unknown or misplaced word; condition if eq f 0\n321|eof_prog: word or declaration in a place that does not allow it; condition if ne uchar get a_ar add get a_rb 24 sub f 1 0\n322|kunset: word or declaration in a place that does not allow it; condition if eq uchar get a_ar add get a_rb 30 f 0\n323|s_eof: missing end; condition if ne get curret 0 0\n324|s_eof: syntax: unknown or misplaced word; condition if eq get nf 0 0\n325|s_eof: word or declaration in a place that does not allow it; condition if ne reachself f 0\n326|s_eof: word or declaration in a place that does not allow it; condition if ne uchar get a_ar add get a_rb 7 i 9\n327|stmt: syntax: unknown or misplaced word; condition if ne k 1\n328|stmt: contract syntax misplaced or not supported here (IR mode included); condition if ne cp_kind 0\n329|stmt: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if eq get curret 0 0\n330|stmt: line after ret, break, continue, trap or exit in the same block; condition if ne get dead 0 0\n331|stmt: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63\n332|stmt: type mismatch; condition if ne uchar get a_ar add get a_rb 23 sub f 1 12\n333|stmt: syntax: unknown or misplaced word; condition if eq get curret 0 0\n334|stmt: line after ret, break, continue, trap or exit in the same block; condition if ne get dead 0 0\n336|stmt: type mismatch; condition if ne get rt 0 8\n337|stmt: number out of range for its type or place; condition if or lt v 1 gt v 14\n338|stmt: word or declaration in a place that does not allow it; condition if ne get objmode 0 0\n339|stmt: word or declaration in a place that does not allow it; condition if ne get objmode 0 0\n340|stmt: word or declaration in a place that does not allow it; condition if or or or eq c 77 eq c 78 eq c 79 eq c 81\n341|stmt: word or declaration in a place that does not allow it; condition if or eq c 85 eq c 193\n342|stmt: syntax: unknown or misplaced word\n343|s_field: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63\n344|s_field: syntax: unknown or misplaced word; condition if ne kw get tw 0 0\n345|s_field: duplicate name; condition if eq fw w\n346|s_field: duplicate name; condition if ne findstruct fw 0\n347|s_field: duplicate name; condition if ne field_dup fo fw 0\n348|s_field: type mismatch; condition if ge t 64\n349|s_field: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ne get tbig 0 0\n350|s_field: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if or eq ln 0 gt ln 64\n351|s_field: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge ct 10\n352|s_field: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if or eq ln 0 gt ln 64\n353|s_field: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if gt add cells addc 64\n354|s_struct: word or declaration in a place that does not allow it; condition if ne get nf 0 0\n355|s_struct: syntax: unknown or misplaced word; condition if ne get tk 0 1\n356|s_struct: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63\n357|s_struct: syntax: unknown or misplaced word; condition if ne kw get tw 0 0\n358|s_struct: duplicate name; condition if ne findstruct w 0\n359|s_struct: duplicate name; condition if ne findfn w get tl 0 get ts 0 0\n360|s_struct: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge get nst 0 16\n361|s_struct: the line ends where a word or value is needed; condition if eq get tk 0 0\n362|s_struct: syntax: unknown or misplaced word; condition if ne get tk 0 1\n363|s_struct: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge nfld 16\n364|s_struct: syntax: unknown or misplaced word; condition if eq nfld 0\n365|sa_new: word or declaration in a place that does not allow it; condition if ne get inl 0 0\n366|sa_new: word or declaration in a place that does not allow it; condition if ne uchar get a_ar add get a_rb 27 sub get curfn 0 1 0\n367|st_read: type mismatch; condition if ne get rt 0 ft\n368|sa_st: word or declaration in a place that does not allow it; condition if ne get nb 0 0\n369|sa_st: size capacity; condition if gt s 4194304\n370|abty: syntax: unknown or misplaced word; condition if eq a 0\n371|s_abstract: word or declaration in a place that does not allow it; condition if ne get nf 0 0\n372|s_abstract: syntax: unknown or misplaced word; condition if ne get tk 0 1\n373|s_abstract: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 8\n374|s_abstract: syntax: unknown or misplaced word; condition if ne kw w 0\n375|s_abstract: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge n 16\n376|s_abstract: type mismatch; condition if and ne t 4 ne t 5\n377|s_abstract: extra words after a complete statement; condition if or gt get tl 0 8 ne kw get tw 0 196\n378|s_abstract: syntax: unknown or misplaced word; condition if or ne k 1 gt get tl 0 8\n379|s_abstract: syntax: unknown or misplaced word; condition if eq b 0\n380|s_abstract: extra words after a complete statement; condition if and ne get tk 0 0 ne get tk 0 3\n381|ab_entry: type mismatch; condition if ge uchar get a_ar add get a_rb 23 f 64\n382|ab_entry: type mismatch; condition if ge uchar get a_ar add get a_rb 35 add mul f 6 i 64\n383|ab_open: type mismatch; condition if lt t 64\n384|ab_seal: the line ends where a word or value is needed; condition if or eq get tk 0 0 eq get tk 0 3\n385|ab_seal: syntax: unknown or misplaced word; condition if eq a 0\n386|ab_seal: abstract type: seal outside its constructor, or an unsupported holds; condition if eq ab_ctor fe a 0\n387|ab_seal: type mismatch; condition if ne get rt 0 t\n388|ab_bin: type mismatch; condition if lt at 64\n389|ab_bin: type mismatch; condition if eq b 0\n390|ab_bin: type mismatch; condition if eq and get ab_ops a b 0\n391|ab_bin: type mismatch; condition if ne bt t\n392|ab_bin: type mismatch; condition if ne bt at\n393|fz_par: syntax: unknown or misplaced word; condition if ne k 3\n394|fz_par: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if gt ln 64\n395|fz_new: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge s 16\n396|fz_get: fresh element read before it is definitely written, or fresh array passed on; condition if eq and shr get fz_cur s v 1 0\n397|fz_get: fresh element read before it is definitely written, or fresh array passed on; condition if ne get fz_cur s fmask n\n398|fz_arg: fresh element read before it is definitely written, or fresh array passed on; condition if ne uchar get a_ar add get a_rb 13 sub e 1 0\n399|ns_om2: word or declaration in a place that does not allow it; condition if ne get nf 0 0\n400|ns_om2: syntax: unknown or misplaced word; condition if ne get tk 0 1\n401|ns_om2: syntax: unknown or misplaced word; condition if eq a 0\n402|ns_om2: the line ends where a word or value is needed; condition if or eq get tk 0 0 eq get tk 0 3\n403|ns_om2: abstract type: seal outside its constructor, or an unsupported holds; condition if ne get tk 0 1\n404|ns_om2: abstract type: seal outside its constructor, or an unsupported holds; condition if or ne get tl 0 5 ne get tw 0 215611372900\n405|ns_om2: abstract type: seal outside its constructor, or an unsupported holds; condition if ne get ab_base a 5\n406|ns_om2: duplicate name; condition if ne get ab_holds a 0\n407|s_export: syntax: unknown or misplaced word; condition if or ne get tk 0 1 ne get tw 0 28262\n408|s_export: word or declaration in a place that does not allow it; condition if ne get progmode 0 0\n409|s_export: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge get nexp 0 32\n410|ly_num: the line ends where a word or value is needed; condition if or eq get tk 0 0 eq get tk 0 3\n411|ly_num: syntax: unknown or misplaced word; condition if ne get tk 0 2\n412|ly_num: external layout out of bounds or misplaced; condition if ne get tbig 0 0\n413|s_layout: external layout out of bounds or misplaced; condition if ne get nf 0 0\n414|s_layout: syntax: unknown or misplaced word; condition if ne get tk 0 1\n415|s_layout: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 8\n416|s_layout: syntax: unknown or misplaced word; condition if ne kw w 0\n417|s_layout: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge get nly 0 16\n418|s_layout: external layout out of bounds or misplaced; condition if or eq sz 0 gt sz 4096\n419|s_layout: the line ends where a word or value is needed; condition if eq k 3\n420|s_layout: syntax: unknown or misplaced word; condition if ne c 189\n421|s_layout: syntax: unknown or misplaced word; condition if ne k 0\n422|ly_field: the line ends where a word or value is needed; condition if or eq get tk 0 0 eq get tk 0 3\n423|ly_field: syntax: unknown or misplaced word; condition if ne get tk 0 1\n424|ly_field: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 8\n425|ly_field: syntax: unknown or misplaced word; condition if ne kw fw 0\n426|ly_field: duplicate name; condition if eq get lf_name i fw\n427|ly_field: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge n 256\n428|ly_field: type mismatch; condition if or lt t 2 gt t 9\n429|ly_field: external layout out of bounds or misplaced; condition if ne get tbig 0 0\n430|ly_field: external layout out of bounds or misplaced; condition if or eq cnt 0 gt cnt 4096\n431|ly_field: the line ends where a word or value is needed; condition if or eq get tk 0 0 eq get tk 0 3\n432|ly_field: syntax: unknown or misplaced word; condition if ne get tk 0 1\n433|ly_field: syntax: unknown or misplaced word; condition if ne kw get tw 0 190\n434|ly_end: the line ends where a word or value is needed; condition if or eq get tk 0 0 eq get tk 0 3\n435|ly_end: syntax: unknown or misplaced word; condition if ne get tk 0 1\n436|ly_end: syntax: unknown or misplaced word\n437|ly_mark: external layout out of bounds or misplaced; condition if gt off sz\n438|ly_mark: external layout out of bounds or misplaced; condition if gt e sz\n439|ly_mark: external layout out of bounds or misplaced; condition if ne get lymap i 0\n440|ly_ix: type mismatch; condition if or eq t 1 ge t 10\n441|ly_ix: constant index outside the array; condition if ge v cnt\n442|ly_st: type mismatch; condition if ne get rt 0 ft\n443|vt_fget_go: type mismatch; condition if eq get rt 0 1\n444|vt_fget_go: constant index outside the array; condition if ge get rv 0 fl\n445|vt_fget_go: type mismatch; condition if ne get rk 0 1\n446|vt_fget: syntax: unknown or misplaced word; condition if ne get tk 0 1\n447|vt_fget: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63\n448|vt_fget: unknown name or field, or a word this mode does not provide; condition if eq fid 0\n449|s_putf_go: type mismatch; condition if eq get rt 0 1\n450|s_putf_go: type mismatch; condition if ne get rt 0 ft\n451|s_putf: write to a view or a text; condition if eq ulong uchar get a_ar add get a_rb 7 i 8\n452|s_putf: syntax: unknown or misplaced word; condition if ne get tk 0 1\n453|s_putf: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63\n454|s_putf: unknown name or field, or a word this mode does not provide; condition if eq fid 0\n455|s_putf_ix: type mismatch; condition if eq get svt 0 1\n456|s_putf_ix: constant index outside the array; condition if ge iv fl\n457|s_putf_ix: type mismatch; condition if ne ik 1\n458|ca_st_ok: syntax: unknown or misplaced word; condition if or lt c 57 gt c 58\n459|ca_st_ok: unknown name or field, or a word this mode does not provide; condition if eq e 0\n460|ca_st_ok: type mismatch; condition if eq k 10\n461|ca_st_ok: type mismatch; condition if lt k 6\n462|ca_st_ok: write to a view or a text; condition if eq md 57\n463|ca_st_ok: write to a view or a text; condition if eq k 8\n464|ca_st_ok: type mismatch; condition if eq md 58\n465|ca_st_ok: type mismatch; condition if ne ulong a_gu 5 ni ulong a_gu 35 p\n466|ca_st: global passed as an argument, or one array twice in a call; condition if eq a_g 77 add add cb mul j 3 2 e\n467|ir_newreg: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge r 64\n468|ir_block: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge b 32\n469|ir_op: line after ret, break, continue, trap or exit in the same block; condition if ne get ir_dead 0 0\n470|ir_op: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge n 256\n471|ir_lit: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge n 32\n472|ir_bind: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge n 32\n473|ir_newname: syntax: unknown or misplaced word; condition if ne kw w 0\n474|ir_newname: duplicate name; condition if ne findname w 0\n475|ir_newname: duplicate name; condition if ne ir_find w l 0\n476|ir_newname: duplicate name; condition if ne ir_nameeq j 0\n477|ir_newloc: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt l 8\n478|ir_type: the line ends where a word or value is needed; condition if or eq get tk 0 0 eq get tk 0 3\n479|ir_type: syntax: unknown or misplaced word; condition if ne get tk 0 1\n480|ir_type: word or declaration in a place that does not allow it; condition if or or eq c 76 eq c 88 eq c 89\n481|ir_type: word or declaration in a place that does not allow it; condition if or eq c 57 eq c 58\n482|ir_type: syntax: unknown or misplaced word\n483|ir_push: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge n 8\n484|ir_emit_record: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge get irnf 0 32\n485|ir_callop: line after ret, break, continue, trap or exit in the same block; condition if ne get ir_dead 0 0\n486|ir_callop: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge n 256\n487|ir_name: word or declaration in a place that does not allow it; condition if ge t 10\n488|ir_un: bare number without a type from its context; condition if ne get ir_isb 0 0\n489|ir_un: type mismatch; condition if and eq c 49 eq ty 1\n490|ir_bin_done: type mismatch; condition if or ge lty 10 eq lty 1\n491|ir_bin_done: type mismatch; condition if or ge ty2 10 eq ty2 1\n492|ir_bin_done: type mismatch; condition if ge lty 10\n493|ir_bin_done: type mismatch; condition if and eq isb2 0 ne ty2 lty\n494|ir_bin_done: type mismatch; condition if and and ge c 33 le c 37 eq lty 1\n495|ir_bin: bare number without a type from its context; condition if ne get ir_isb 0 0\n496|ir_cast: word or declaration in a place that does not allow it; condition if xor eq sty 1 eq c 1\n497|ir_val: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if gt get irdep 0 32768\n498|ir_valb: the line ends where a word or value is needed; condition if or eq get tk 0 0 eq get tk 0 3\n499|ir_valb: word or declaration in a place that does not allow it; condition if or eq get tk 0 4 eq get tk 0 5\n500|ir_valb: type mismatch; condition if and ne exp 0 ne get ir_vt 0 exp\n501|ir_valb: type mismatch; condition if and ne exp 0 ne get ir_vt 0 exp\n502|ir_valb: type mismatch; condition if and ne exp 0 ne exp 1\n503|ir_valb: type mismatch; condition if and ne exp 0 ne exp 1\n504|ir_valb: unknown name or field, or a word this mode does not provide; condition if eq f 0\n505|ir_valb: type mismatch; condition if eq rtv 76\n506|ir_valb: type mismatch; condition if ne get ir_vt 0 ty\n507|ir_end: a function with a result can reach its end; condition if ne get ir_ret 0 76\n508|ir_bound: extra words after a complete statement; condition if or ne get tk 0 1 ne ir_kwt 70\n509|ir_bound: number out of range for its type or place; condition if ge sub bnd 1 1000000\n510|ir_while: type mismatch; condition if ne get ir_vt 0 1\n511|ir_for: the line ends where a word or value is needed; condition if or eq get tk 0 0 eq get tk 0 3\n512|ir_for: syntax: unknown or misplaced word; condition if ne get tk 0 1\n513|ir_for: type mismatch; condition if eq ty 1\n514|ir_for: number out of range for its type or place; condition if eq a_ib get ts 0 45\n515|ir_for: number out of range for its type or place; condition if gt get tw 0 1000000\n516|ir_for: number out of range for its type or place; condition if gt a_g 8 sub e 1 1000000\n517|ir_for: type mismatch; condition if ne get ir_vt 0 ty\n518|ir_stmtcall: type mismatch; condition if ne get irf_ret j 76\n519|ir_stmtcall: type mismatch; condition if ne get ir_vt 0 ty\n520|ir_assign: type mismatch; condition if ne get ir_vt 0 ulong get ir_rty r\n521|ir_assign: type mismatch; condition if eqs\n522|ir_assign: type mismatch; condition if ne findname w 0\n523|ir_assign: bare number without a type from its context; condition if ne get ir_isb 0 0\n524|ir_stmt: missing end; condition if eq get tk 0 3\n525|ir_stmt: syntax: unknown or misplaced word; condition if ne get tk 0 1\n526|ir_stmt: line after ret, break, continue, trap or exit in the same block; condition if ne get ir_dead 0 0\n527|ir_stmt: word or declaration in a place that does not allow it; condition if eq c 77\n528|ir_stmt: number out of range for its type or place; condition if or lt code 1 gt code 14\n529|ir_stmt: the line ends where a word or value is needed; condition if not or eq get tk 0 0 eq get tk 0 3\n530|ir_stmt: word or declaration in a place that does not allow it; condition if eq ex 0\n531|ir_stmt: missing end; condition if or ne get ir_fk n 1 ne get ir_fc n 0\n532|ir_stmt: type mismatch; condition if ne get ir_vt 0 1\n533|ir_stmt: the line ends where a word or value is needed; condition if ne get ir_ret 0 76\n534|ir_stmt: extra words after a complete statement; condition if eq get ir_ret 0 76\n535|ir_stmt: type mismatch; condition if ne get ir_vt 0 get ir_ret 0\n536|ir_stmt: missing end; condition if eq c 64\n537|ir_stmt: unknown name or field, or a word this mode does not provide; condition if eq c 97\n538|ir_stmt: word or declaration in a place that does not allow it; condition if or eq c 80 eq c 82\n539|ir_stmt: word or declaration in a place that does not allow it; condition if or or or eq c 78 eq c 79 eq c 81 eq c 85\n540|ir_stmt: word or declaration in a place that does not allow it; condition if eq c 193\n541|ir_stmt: syntax: unknown or misplaced word; condition if ne c 0\n542|ir_stmt: contract syntax misplaced or not supported here (IR mode included); condition if not eqs\n543|ir_param: word or declaration in a place that does not allow it; condition if ge np 6\n544|ir_fn: syntax: unknown or misplaced word; condition if ne get tk 0 1\n545|ir_fn: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63\n546|ir_fn: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge fcur 32\n547|ir_fn: the line ends where a word or value is needed; condition if or eq get tk 0 0 eq get tk 0 3\n548|ir_fn: syntax: unknown or misplaced word; condition if ne get tk 0 1\n549|ir_run: syntax: unknown or misplaced word; condition if ne k 1\n550|ir_run: word or declaration in a place that does not allow it; condition if or or eq c 85 eq c 78 eq c 79\n551|ir_run: syntax: unknown or misplaced word; condition otherwise: if eq c 152\n552|cp_token: contract syntax misplaced or not supported here (IR mode included); condition if ne get tk 0 1\n553|cp_token: contract syntax misplaced or not supported here (IR mode included); condition if gt get tl 0 63\n554|cp_token: contract syntax misplaced or not supported here (IR mode included)\n555|cp_eval: type mismatch; condition if ne get rt 0 1\n556|cp_entry: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge n 64\n557|cp_entry: contract syntax misplaced or not supported here (IR mode included); condition if eq k 3\n558|cp_head: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge n 64\n559|main: syntax: unknown or misplaced word; condition if or eq get om2 0 0 ne get om2m 0 0\n560|main: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if or ne get xtarget 0 0 ne get xefa 0 0\n561|main: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if eq get progmode 0 0\n562|main: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if eq get progmode 0 0\n563|xhmnew: word or declaration in a place that does not allow it; condition if or ne a_g 77 add x 14 3 ne a_g 77 add x 16 3\n564|xhmnew: word or declaration in a place that does not allow it; condition if and ne acc 1 ne acc 3\n565|xhmnew: word or declaration in a place that does not allow it; condition if and and and ne mode 1 ne mode 2 ne mode 33 ne mode 34\n566|xhmbind: word or declaration in a place that does not allow it; condition if ne get a_ar add get a_rb 77 add x 14 3\n567|xhmbind: word or declaration in a place that does not allow it; condition if and ne acc 1 ne acc 3\n568|xhmmio: word or declaration in a place that does not allow it; condition if ne get a_ar add get a_rb 77 add x 12 3\n569|xhmmio: word or declaration in a place that does not allow it; condition if and ne w 4 ne w 8\n570|xhreq: word or declaration in a place that does not allow it; condition if ne get a_ar add get a_rb 77 add x 12 3\n571|xhreq: word or declaration in a place that does not allow it; condition if not ok\n572|xhreq: word or declaration in a place that does not allow it; condition if eq n 0\n573|xhreq: word or declaration in a place that does not allow it; condition if eq n 0\n574|xhreq: word or declaration in a place that does not allow it; condition if and ne q 3223340586 ne q 3223340587\n575|xhdev: global passed as an argument, or one array twice in a call; condition if eq e f\n576|xhost: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if ne get xtarget 0 1\n577|xhost: word or declaration in a place that does not allow it; condition if eq 0 get om2 0\n578|xhost: word or declaration in a place that does not allow it; condition if eq ok 0\n579|xhost: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if eq c 198\n580|xcc: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14)\n581|xarith: type mismatch; condition if or lt op 33 gt op 35\n582|xdiv: type mismatch; condition if ne op 36\n583|xunary: type mismatch; condition if eq ty 13\n584|xunary: type mismatch; condition if eq op 50\n585|xunary: type mismatch; condition if eq ty 1\n586|xconv: type mismatch; condition if or eq ft 13 eq tt 13\n587|xconv: word or declaration in a place that does not allow it; condition if or eq ft 1 eq tt 1\n588|xconv: word or declaration in a place that does not allow it; condition if or eq ft 1 eq tt 1\n589|xelem: type mismatch; condition if or or eq t 1 eq t 10 eq t 11\n590|xelem: constant index outside the array; condition if le ln v\n591|xio: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if ne get xtarget 0 1\n592|xarray: word or declaration in a place that does not allow it; condition if ne get nb 0 0\n593|xarray: size capacity; condition if gt add get stkbytes 0 by 4194304\n594|xarray: type mismatch; condition if ne get rt 0 t\n595|xfinish: a function with a result can reach its end; condition if ne get curret 0 12\n596|xlead: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition otherwise: if and eq get tw 0 115888505501281 eq get tl 0 6\n597|xeof: syntax: unknown or misplaced word; condition if eq f 0\n598|xeof: word or declaration in a place that does not allow it; condition if ne uchar get a_ar add get a_rb 24 sub f 1 0\n599|xer: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge n 256\n600|xer: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge m 256\n601|xefival: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if ne get xtarget 0 2\n602|xefival: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if gt op 14\n603|xdev: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if ne op 13\n604|aeof: syntax: unknown or misplaced word; condition if eq f 0\n605|aeof: word or declaration in a place that does not allow it; condition if ne uchar get a_ar add get a_rb 24 sub f 1 0\n606|aeof: word or declaration in a place that does not allow it; condition if ne ulong get a_ar add get a_rb 24 sub h 1 0\n607|aeof: word or declaration in a place that does not allow it; condition if ne ulong get a_ar add get a_rb 23 sub h 1 12\n608|aefival: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if gt op 14\n609|aefival: syntax: unknown or misplaced word; condition if eq f 0\n610|aefival: word or declaration in a place that does not allow it; condition if ne ulong get a_ar add get a_rb 24 sub f 1 4\n611|aefival: word or declaration in a place that does not allow it; condition if ne ulong get a_ar add get a_rb 23 sub f 1 5\n612|aefival: word or declaration in a place that does not allow it; condition if ne a_gu 37 pe 0\n613|aefival: word or declaration in a place that does not allow it; condition if ne ulong a_gu 35 pe 5\n614|s_extern: missing end; condition if ne get curret 0 0\n615|s_extern: syntax: unknown or misplaced word; condition if or ne get tk 0 1 ne get tw 0 28262\n616|obj_import: word or declaration in a place that does not allow it; condition if ne a_gu 27 f 0\n617|obj_signature: type mismatch; condition if gt a_gu 23 f 13\n618|obj_signature: type mismatch; condition if gt a_gu 35 p 13\n619|obj_signature: type mismatch; condition if and ne k 0 and ne k 2 ne k 3\n620|obj_signature: type mismatch; condition if ne a_gu 38 p 0\n621|obj_signature: fresh element read before it is definitely written, or fresh array passed on; condition if and eq a_gu 32 f 2 ne a_gu 39 p 0\n622|obj_write: the compiler's standard output could not be written; condition if eq a_out 1 1 0 get oc 0 0\n" |
| 606 | note Native diagnostic v2 + canonical program-identity & effect receipts. SHA core below is generated from seed/trace/sha256.om. |
| 607 | global d2mode ulong 1 |
| 608 | global d2site ulong 1 |
| 609 | global d2size ulong 1 |
| 610 | global d2full ulong 1 |
| 611 | global d2done ulong 1 |
| 612 | global d2hash uchar 32 |
| 613 | global rcmode ulong 1 |
| 614 | global rc_sz ulong 1 |
| 615 | global rc_cnt ulong 1 |
| 616 | global rc_cat ulong 1 |
| 617 | global rc_ccnt ulong 1 |
| 618 | global rc_w ulong 4 |
| 619 | global rc_tmp uchar 32 |
| 620 | global rc_body uchar 32 |
| 621 | global rc_sig uchar 32 |
| 622 | global rc_con uchar 32 |
| 623 | global rc_pid uchar 32 |
| 624 | global rc_out uchar 32 |
| 625 | global rc_rid uchar 32 |
| 626 | text d2flag "OMC_DIAGNOSTICS=2" |
| 627 | text rcflag "OMC_RECEIPT=1" |
| 628 | text rcdom_p "omega.program.v2" |
| 629 | text rcdom_c "omega.contract.v1" |
| 630 | text rcdom_r "omega.effect.receipt.v1" |
| 631 | text rct_hdr "omc-receipt 1 program_id=" |
| 632 | text rct_bid " body_id=" |
| 633 | text rct_sid " sig_id=" |
| 634 | text rct_cid " contract_id=" |
| 635 | text rct_ish " input_sha256=" |
| 636 | text rct_ib " input_bytes=" |
| 637 | text rct_osh " output_sha256=" |
| 638 | text rct_ob " output_bytes=" |
| 639 | text rct_cs " compiler_source_sha256=" |
| 640 | text rct_om2 " om2=" |
| 641 | text rct_obj " obj=" |
| 642 | text rct_ir " ir=" |
| 643 | text rct_tgt " target=" |
| 644 | text rct_efa " efa=" |
| 645 | text rct_eff " effects=" |
| 646 | text rct_es " effect_sites=" |
| 647 | text rct_ew " effect_words=" |
| 648 | text rct_rid " receipt_id=" |
| 649 | |
| 650 | note SPDX-License-Identifier: AGPL-3.0-only |
| 651 | note SHA-256, one-shot over a byte slice, in seeded .om. |
| 652 | note The digest is the standard FIPS 180-4 construction with 32-bit words held in ulong and |
| 653 | note masked after every addition. It has no host crypto dependency and no network path. |
| 654 | global ds_h ulong 8 |
| 655 | global ds_w ulong 64 |
| 656 | global ds_k ulong 64 |
| 657 | global ds_blk uchar 64 |
| 658 | global ds_kset ulong 1 |
| 659 | |
| 660 | fn ds_mask x ulong to ulong |
| 661 | ret and x 4294967295 |
| 662 | end |
| 663 | |
| 664 | fn ds_ror x ulong n ulong to ulong |
| 665 | ret ds_mask or shr x n shl x sub 32 n |
| 666 | end |
| 667 | |
| 668 | fn ds_ch e ulong f ulong g ulong to ulong |
| 669 | ret xor and e f and xor e 4294967295 g |
| 670 | end |
| 671 | |
| 672 | fn ds_maj a ulong b ulong c ulong to ulong |
| 673 | ret xor and a b xor and a c and b c |
| 674 | end |
| 675 | |
| 676 | fn ds_bs0 x ulong to ulong |
| 677 | ret xor ds_ror x 2 xor ds_ror x 13 ds_ror x 22 |
| 678 | end |
| 679 | |
| 680 | fn ds_bs1 x ulong to ulong |
| 681 | ret xor ds_ror x 6 xor ds_ror x 11 ds_ror x 25 |
| 682 | end |
| 683 | |
| 684 | fn ds_ss0 x ulong to ulong |
| 685 | ret xor ds_ror x 7 xor ds_ror x 18 shr x 3 |
| 686 | end |
| 687 | |
| 688 | fn ds_ss1 x ulong to ulong |
| 689 | ret xor ds_ror x 17 xor ds_ror x 19 shr x 10 |
| 690 | end |
| 691 | |
| 692 | fn ds_kinit to void |
| 693 | if ne get ds_kset 0 0 |
| 694 | ret |
| 695 | end |
| 696 | put ds_k 0 ulong 1116352408 |
| 697 | put ds_k 1 ulong 1899447441 |
| 698 | put ds_k 2 ulong 3049323471 |
| 699 | put ds_k 3 ulong 3921009573 |
| 700 | put ds_k 4 ulong 961987163 |
| 701 | put ds_k 5 ulong 1508970993 |
| 702 | put ds_k 6 ulong 2453635748 |
| 703 | put ds_k 7 ulong 2870763221 |
| 704 | put ds_k 8 ulong 3624381080 |
| 705 | put ds_k 9 ulong 310598401 |
| 706 | put ds_k 10 ulong 607225278 |
| 707 | put ds_k 11 ulong 1426881987 |
| 708 | put ds_k 12 ulong 1925078388 |
| 709 | put ds_k 13 ulong 2162078206 |
| 710 | put ds_k 14 ulong 2614888103 |
| 711 | put ds_k 15 ulong 3248222580 |
| 712 | put ds_k 16 ulong 3835390401 |
| 713 | put ds_k 17 ulong 4022224774 |
| 714 | put ds_k 18 ulong 264347078 |
| 715 | put ds_k 19 ulong 604807628 |
| 716 | put ds_k 20 ulong 770255983 |
| 717 | put ds_k 21 ulong 1249150122 |
| 718 | put ds_k 22 ulong 1555081692 |
| 719 | put ds_k 23 ulong 1996064986 |
| 720 | put ds_k 24 ulong 2554220882 |
| 721 | put ds_k 25 ulong 2821834349 |
| 722 | put ds_k 26 ulong 2952996808 |
| 723 | put ds_k 27 ulong 3210313671 |
| 724 | put ds_k 28 ulong 3336571891 |
| 725 | put ds_k 29 ulong 3584528711 |
| 726 | put ds_k 30 ulong 113926993 |
| 727 | put ds_k 31 ulong 338241895 |
| 728 | put ds_k 32 ulong 666307205 |
| 729 | put ds_k 33 ulong 773529912 |
| 730 | put ds_k 34 ulong 1294757372 |
| 731 | put ds_k 35 ulong 1396182291 |
| 732 | put ds_k 36 ulong 1695183700 |
| 733 | put ds_k 37 ulong 1986661051 |
| 734 | put ds_k 38 ulong 2177026350 |
| 735 | put ds_k 39 ulong 2456956037 |
| 736 | put ds_k 40 ulong 2730485921 |
| 737 | put ds_k 41 ulong 2820302411 |
| 738 | put ds_k 42 ulong 3259730800 |
| 739 | put ds_k 43 ulong 3345764771 |
| 740 | put ds_k 44 ulong 3516065817 |
| 741 | put ds_k 45 ulong 3600352804 |
| 742 | put ds_k 46 ulong 4094571909 |
| 743 | put ds_k 47 ulong 275423344 |
| 744 | put ds_k 48 ulong 430227734 |
| 745 | put ds_k 49 ulong 506948616 |
| 746 | put ds_k 50 ulong 659060556 |
| 747 | put ds_k 51 ulong 883997877 |
| 748 | put ds_k 52 ulong 958139571 |
| 749 | put ds_k 53 ulong 1322822218 |
| 750 | put ds_k 54 ulong 1537002063 |
| 751 | put ds_k 55 ulong 1747873779 |
| 752 | put ds_k 56 ulong 1955562222 |
| 753 | put ds_k 57 ulong 2024104815 |
| 754 | put ds_k 58 ulong 2227730452 |
| 755 | put ds_k 59 ulong 2361852424 |
| 756 | put ds_k 60 ulong 2428436474 |
| 757 | put ds_k 61 ulong 2756734187 |
| 758 | put ds_k 62 ulong 3204031479 |
| 759 | put ds_k 63 ulong 3329325298 |
| 760 | put ds_kset 0 1 |
| 761 | end |
| 762 | |
| 763 | fn ds_hinit to void |
| 764 | put ds_h 0 ulong 1779033703 |
| 765 | put ds_h 1 ulong 3144134277 |
| 766 | put ds_h 2 ulong 1013904242 |
| 767 | put ds_h 3 ulong 2773480762 |
| 768 | put ds_h 4 ulong 1359893119 |
| 769 | put ds_h 5 ulong 2600822924 |
| 770 | put ds_h 6 ulong 528734635 |
| 771 | put ds_h 7 ulong 1541459225 |
| 772 | end |
| 773 | |
| 774 | fn ds_compress to void |
| 775 | ds_kinit |
| 776 | for i ulong 16 |
| 777 | v = ulong 0 |
| 778 | for j ulong 4 |
| 779 | v = or shl v 8 ulong get ds_blk add mul i 4 j |
| 780 | end |
| 781 | put ds_w i v |
| 782 | end |
| 783 | for i ulong 48 |
| 784 | j = add i 16 |
| 785 | v = add ds_ss1 get ds_w sub j 2 add ds_ss0 get ds_w sub j 15 add get ds_w sub j 7 get ds_w sub j 16 |
| 786 | put ds_w j ds_mask v |
| 787 | end |
| 788 | a = ulong get ds_h 0 |
| 789 | b = ulong get ds_h 1 |
| 790 | c = ulong get ds_h 2 |
| 791 | d = ulong get ds_h 3 |
| 792 | e = ulong get ds_h 4 |
| 793 | f = ulong get ds_h 5 |
| 794 | g = ulong get ds_h 6 |
| 795 | hh = ulong get ds_h 7 |
| 796 | for i ulong 64 |
| 797 | x = ds_ch e f g |
| 798 | x = add x get ds_k i |
| 799 | x = add x get ds_w i |
| 800 | x = add x ds_bs1 e |
| 801 | x = add x hh |
| 802 | t1 = ds_mask x |
| 803 | x = ds_maj a b c |
| 804 | x = add ds_bs0 a x |
| 805 | hh = g |
| 806 | g = f |
| 807 | f = e |
| 808 | e = ds_mask add d t1 |
| 809 | d = c |
| 810 | c = b |
| 811 | b = a |
| 812 | a = ds_mask add t1 x |
| 813 | end |
| 814 | put ds_h 0 ds_mask add get ds_h 0 a |
| 815 | put ds_h 1 ds_mask add get ds_h 1 b |
| 816 | put ds_h 2 ds_mask add get ds_h 2 c |
| 817 | put ds_h 3 ds_mask add get ds_h 3 d |
| 818 | put ds_h 4 ds_mask add get ds_h 4 e |
| 819 | put ds_h 5 ds_mask add get ds_h 5 f |
| 820 | put ds_h 6 ds_mask add get ds_h 6 g |
| 821 | put ds_h 7 ds_mask add get ds_h 7 hh |
| 822 | end |
| 823 | |
| 824 | fn d2env to void |
| 825 | n = envcnt |
| 826 | i = ulong 0 |
| 827 | while lt i ulong n |
| 828 | k = envread i a_eb 0 131072 |
| 829 | if eq k long len d2flag |
| 830 | ok = true |
| 831 | for j ulong len d2flag |
| 832 | if ne get a_eb j get d2flag j |
| 833 | ok = false |
| 834 | end |
| 835 | end |
| 836 | if ok |
| 837 | put d2mode 0 1 |
| 838 | end |
| 839 | end |
| 840 | if eq k long len rcflag |
| 841 | ok = true |
| 842 | for j ulong len rcflag |
| 843 | if ne get a_eb j get rcflag j |
| 844 | ok = false |
| 845 | end |
| 846 | end |
| 847 | if ok |
| 848 | put rcmode 0 1 |
| 849 | end |
| 850 | end |
| 851 | i = add i 1 |
| 852 | end |
| 853 | if or ne get d2mode 0 0 ne get rcmode 0 0 |
| 854 | ds_hinit |
| 855 | end |
| 856 | end |
| 857 | |
| 858 | note Hash bytes as read, before a memory refusal or formatter can change the input arena. |
| 859 | fn d2feed n ulong to void |
| 860 | for i ulong n |
| 861 | j = rem get d2size 0 64 |
| 862 | put ds_blk j get a_wb i |
| 863 | put d2size 0 add get d2size 0 1 |
| 864 | if eq j 63 |
| 865 | ds_compress |
| 866 | end |
| 867 | end |
| 868 | end |
| 869 | |
| 870 | fn d2finish to void |
| 871 | if ne get d2done 0 0 |
| 872 | ret |
| 873 | end |
| 874 | j = rem get d2size 0 64 |
| 875 | put ds_blk j 128 |
| 876 | j = add j 1 |
| 877 | while lt j 64 |
| 878 | put ds_blk j 0 |
| 879 | j = add j 1 |
| 880 | end |
| 881 | if ge rem get d2size 0 64 56 |
| 882 | ds_compress |
| 883 | for i ulong 64 |
| 884 | put ds_blk i 0 |
| 885 | end |
| 886 | end |
| 887 | bits = mul get d2size 0 8 |
| 888 | for i ulong 8 |
| 889 | put ds_blk add 56 i uchar and shr bits mul sub 7 i 8 255 |
| 890 | end |
| 891 | ds_compress |
| 892 | for i ulong 32 |
| 893 | v = get ds_h div i 4 |
| 894 | shift = mul sub 3 rem i 4 8 |
| 895 | put d2hash i uchar and shr v shift 255 |
| 896 | end |
| 897 | put d2done 0 1 |
| 898 | end |
| 899 | |
| 900 | fn d2record code ulong to void |
| 901 | d2finish |
| 902 | put mc 0 0 |
| 903 | mputw 7449351137626647919 8 |
| 904 | mputw 4424052638528582176 8 |
| 905 | mputn code |
| 906 | mputw 19207804370383648 7 |
| 907 | mputn get d2site 0 |
| 908 | mputw 67505853393952 6 |
| 909 | mputn add get line 0 get lbase 0 |
| 910 | mputw 263812244256 5 |
| 911 | mputn dcol get tka 0 |
| 912 | mputw 67544290456352 6 |
| 913 | mputn add get tka 0 get sbase 0 |
| 914 | mputb 45 |
| 915 | mputn add get tkb 0 get sbase 0 |
| 916 | mputw 7088512386250729760 8 |
| 917 | mputw 263929033849 5 |
| 918 | mputn get d2size 0 |
| 919 | mputw 7160569980288657696 8 |
| 920 | mputw 4424070187921206639 8 |
| 921 | mputn get d2full 0 |
| 922 | mputw 8313491484895504672 8 |
| 923 | mputw 67303030022504 6 |
| 924 | for i ulong 32 |
| 925 | mputh ulong get d2hash i |
| 926 | end |
| 927 | mputw 7308332226908742432 8 |
| 928 | mputw 7305808869231648626 8 |
| 929 | mputw 4410771375554851679 8 |
| 930 | for i ulong len d2pin |
| 931 | mputb get d2pin i |
| 932 | end |
| 933 | mputw 262839037728 5 |
| 934 | mputn get om2 0 |
| 935 | mputw 67505686015264 6 |
| 936 | mputn get chkmode 0 |
| 937 | mputw 1030908192 4 |
| 938 | mputn get irmode 0 |
| 939 | mputw 4428275828587066400 8 |
| 940 | mputn get xtarget 0 |
| 941 | mputw 7237123381843029792 8 |
| 942 | mputw 15717 2 |
| 943 | mputn get om2m 0 |
| 944 | mputb 10 |
| 945 | w = write 2 msg 0 get mc 0 |
| 946 | end |
| 947 | |
| 948 | fn d2mean code ulong to void |
| 949 | i = ulong 0 |
| 950 | while lt i len d2means |
| 951 | id = ulong 0 |
| 952 | more = true |
| 953 | while and more lt i len d2means |
| 954 | c = get d2means i |
| 955 | i = add i 1 |
| 956 | if eq c 124 |
| 957 | more = false |
| 958 | else |
| 959 | id = add mul id 10 sub ulong c 48 |
| 960 | end |
| 961 | end |
| 962 | more = true |
| 963 | while and more lt i len d2means |
| 964 | c = get d2means i |
| 965 | i = add i 1 |
| 966 | if eq c 10 |
| 967 | more = false |
| 968 | else |
| 969 | if eq id code |
| 970 | mputb c |
| 971 | end |
| 972 | end |
| 973 | end |
| 974 | if eq id code |
| 975 | ret |
| 976 | end |
| 977 | end |
| 978 | end |
| 979 | |
| 980 | fn d2reason to void |
| 981 | i = ulong 0 |
| 982 | while lt i len d2sites |
| 983 | id = ulong 0 |
| 984 | more = true |
| 985 | while and more lt i len d2sites |
| 986 | c = get d2sites i |
| 987 | i = add i 1 |
| 988 | if eq c 124 |
| 989 | more = false |
| 990 | else |
| 991 | id = add mul id 10 sub ulong c 48 |
| 992 | end |
| 993 | end |
| 994 | more = true |
| 995 | while and more lt i len d2sites |
| 996 | c = get d2sites i |
| 997 | i = add i 1 |
| 998 | if eq c 10 |
| 999 | more = false |
| 1000 | else |
| 1001 | if eq id get d2site 0 |
| 1002 | mputb c |
| 1003 | end |
| 1004 | end |
| 1005 | end |
| 1006 | if eq id get d2site 0 |
| 1007 | ret |
| 1008 | end |
| 1009 | end |
| 1010 | end |
| 1011 | |
| 1012 | fn eff_cat1 c ulong to ulong |
| 1013 | if or eq c 53 eq c 54 |
| 1014 | ret 1 |
| 1015 | end |
| 1016 | if or eq c 108 eq c 128 |
| 1017 | ret 1 |
| 1018 | end |
| 1019 | if or eq c 161 eq c 162 |
| 1020 | ret 1 |
| 1021 | end |
| 1022 | if eq c 221 |
| 1023 | ret 1 |
| 1024 | end |
| 1025 | if or and ge c 100 le c 103 and ge c 110 le c 113 |
| 1026 | ret 2 |
| 1027 | end |
| 1028 | if or eq c 117 and ge c 125 le c 126 |
| 1029 | ret 2 |
| 1030 | end |
| 1031 | if or and ge c 132 le c 133 and ge c 138 le c 144 |
| 1032 | ret 2 |
| 1033 | end |
| 1034 | if or and ge c 149 le c 151 eq c 153 |
| 1035 | ret 2 |
| 1036 | end |
| 1037 | if or and ge c 155 le c 157 or eq c 164 eq c 197 |
| 1038 | ret 2 |
| 1039 | end |
| 1040 | ret 0 |
| 1041 | end |
| 1042 | |
| 1043 | fn eff_cat2 c ulong to ulong |
| 1044 | if or eq c 82 eq c 107 |
| 1045 | ret 4 |
| 1046 | end |
| 1047 | if or eq c 116 eq c 124 |
| 1048 | ret 4 |
| 1049 | end |
| 1050 | if or eq c 127 eq c 129 |
| 1051 | ret 4 |
| 1052 | end |
| 1053 | if or eq c 154 and ge c 158 le c 160 |
| 1054 | ret 4 |
| 1055 | end |
| 1056 | if or eq c 163 eq c 198 |
| 1057 | ret 4 |
| 1058 | end |
| 1059 | if or eq c 233 eq c 235 |
| 1060 | ret 4 |
| 1061 | end |
| 1062 | if or and ge c 104 le c 106 and ge c 114 le c 115 |
| 1063 | ret 8 |
| 1064 | end |
| 1065 | if or and ge c 118 le c 119 eq c 123 |
| 1066 | ret 8 |
| 1067 | end |
| 1068 | if or eq c 131 eq c 134 |
| 1069 | ret 8 |
| 1070 | end |
| 1071 | if or eq c 165 eq c 220 |
| 1072 | ret 8 |
| 1073 | end |
| 1074 | if or eq c 222 eq c 224 |
| 1075 | ret 8 |
| 1076 | end |
| 1077 | ret 0 |
| 1078 | end |
| 1079 | |
| 1080 | fn eff_cat3 c ulong to ulong |
| 1081 | if or eq c 109 eq c 120 |
| 1082 | ret 16 |
| 1083 | end |
| 1084 | if or eq c 130 eq c 135 |
| 1085 | ret 16 |
| 1086 | end |
| 1087 | if or and ge c 166 le c 177 and ge c 228 le c 232 |
| 1088 | ret 32 |
| 1089 | end |
| 1090 | if and ge c 241 le c 243 |
| 1091 | ret 32 |
| 1092 | end |
| 1093 | if eq c 244 |
| 1094 | ret 64 |
| 1095 | end |
| 1096 | if or eq c 178 ge c 251 |
| 1097 | ret 128 |
| 1098 | end |
| 1099 | if or and ge c 121 le c 122 and ge c 136 le c 137 |
| 1100 | ret 256 |
| 1101 | end |
| 1102 | if and ge c 145 le c 148 |
| 1103 | ret 256 |
| 1104 | end |
| 1105 | if or eq c 199 eq c 200 |
| 1106 | ret 512 |
| 1107 | end |
| 1108 | if and ge c 236 le c 240 |
| 1109 | ret 512 |
| 1110 | end |
| 1111 | ret 0 |
| 1112 | end |
| 1113 | |
| 1114 | fn eff_rec c ulong to void |
| 1115 | put rc_cnt 0 add get rc_cnt 0 1 |
| 1116 | if lt c 256 |
| 1117 | wi = shr c 6 |
| 1118 | wb = shl ulong 1 and c 63 |
| 1119 | put rc_w wi or get rc_w wi wb |
| 1120 | end |
| 1121 | cat = or or eff_cat1 c eff_cat2 c eff_cat3 c |
| 1122 | put rc_cat 0 or get rc_cat 0 cat |
| 1123 | end |
| 1124 | |
| 1125 | fn rc_sha_init to void |
| 1126 | ds_hinit |
| 1127 | put rc_sz 0 0 |
| 1128 | end |
| 1129 | |
| 1130 | fn rc_sha_b b uchar to void |
| 1131 | j = rem get rc_sz 0 64 |
| 1132 | put ds_blk j b |
| 1133 | put rc_sz 0 add get rc_sz 0 1 |
| 1134 | if eq j 63 |
| 1135 | ds_compress |
| 1136 | end |
| 1137 | end |
| 1138 | |
| 1139 | fn rc_sha_u64 v ulong to void |
| 1140 | for i ulong 8 |
| 1141 | rc_sha_b uchar and shr v mul sub 7 i 8 255 |
| 1142 | end |
| 1143 | end |
| 1144 | |
| 1145 | fn rc_sha_fin to void |
| 1146 | sz = get rc_sz 0 |
| 1147 | j = rem sz 64 |
| 1148 | put ds_blk j 128 |
| 1149 | j = add j 1 |
| 1150 | while lt j 64 |
| 1151 | put ds_blk j 0 |
| 1152 | j = add j 1 |
| 1153 | end |
| 1154 | if ge rem sz 64 56 |
| 1155 | ds_compress |
| 1156 | for i ulong 64 |
| 1157 | put ds_blk i 0 |
| 1158 | end |
| 1159 | end |
| 1160 | bits = mul sz 8 |
| 1161 | for i ulong 8 |
| 1162 | put ds_blk add 56 i uchar and shr bits mul sub 7 i 8 255 |
| 1163 | end |
| 1164 | ds_compress |
| 1165 | for i ulong 32 |
| 1166 | v = get ds_h div i 4 |
| 1167 | shift = mul sub 3 rem i 4 8 |
| 1168 | put rc_tmp i uchar and shr v shift 255 |
| 1169 | end |
| 1170 | end |
| 1171 | |
| 1172 | fn rc_body_str p ulong e ulong to ulong |
| 1173 | rc_sha_b 34 |
| 1174 | q = add p 1 |
| 1175 | sgo = true |
| 1176 | while and sgo lt q e |
| 1177 | sb = a_ib q |
| 1178 | rc_sha_b sb |
| 1179 | q = add q 1 |
| 1180 | if eq sb 92 |
| 1181 | if lt q e |
| 1182 | rc_sha_b a_ib q |
| 1183 | q = add q 1 |
| 1184 | end |
| 1185 | else |
| 1186 | if or eq sb 34 eq sb 10 |
| 1187 | sgo = false |
| 1188 | end |
| 1189 | end |
| 1190 | end |
| 1191 | ret q |
| 1192 | end |
| 1193 | |
| 1194 | fn rc_body_tok p ulong e ulong to ulong |
| 1195 | q = p |
| 1196 | tgo = true |
| 1197 | while and tgo lt q e |
| 1198 | tb = a_ib q |
| 1199 | st = ulong 0 |
| 1200 | if le ulong tb 32 |
| 1201 | st = 1 |
| 1202 | end |
| 1203 | if or eq ulong tb 40 eq ulong tb 41 |
| 1204 | st = 1 |
| 1205 | end |
| 1206 | if eq ulong tb 34 |
| 1207 | st = 1 |
| 1208 | end |
| 1209 | if ne st 0 |
| 1210 | tgo = false |
| 1211 | else |
| 1212 | rc_sha_b tb |
| 1213 | q = add q 1 |
| 1214 | end |
| 1215 | end |
| 1216 | ret q |
| 1217 | end |
| 1218 | |
| 1219 | fn rc_body_hash to void |
| 1220 | rc_sha_init |
| 1221 | e = get inlen 0 |
| 1222 | p = ulong 0 |
| 1223 | ht = ulong 0 |
| 1224 | go = true |
| 1225 | while go |
| 1226 | m = ulong 0 |
| 1227 | while and go lt m 999999 |
| 1228 | if ge p e |
| 1229 | go = false |
| 1230 | else |
| 1231 | b = a_ib p |
| 1232 | if or or eq b 32 eq b 9 eq b 13 |
| 1233 | p = add p 1 |
| 1234 | else |
| 1235 | if eq b 10 |
| 1236 | if ne ht 0 |
| 1237 | rc_sha_b 10 |
| 1238 | ht = ulong 0 |
| 1239 | end |
| 1240 | p = add p 1 |
| 1241 | else |
| 1242 | if and eq ht 0 ne isnote p 0 |
| 1243 | p = skipln p |
| 1244 | else |
| 1245 | if ne ht 0 |
| 1246 | rc_sha_b 32 |
| 1247 | end |
| 1248 | if eq b 34 |
| 1249 | p = rc_body_str p e |
| 1250 | else |
| 1251 | if or eq b 40 eq b 41 |
| 1252 | rc_sha_b b |
| 1253 | p = add p 1 |
| 1254 | else |
| 1255 | p = rc_body_tok p e |
| 1256 | end |
| 1257 | end |
| 1258 | ht = ulong 1 |
| 1259 | end |
| 1260 | end |
| 1261 | end |
| 1262 | end |
| 1263 | m = add m 1 |
| 1264 | end |
| 1265 | end |
| 1266 | if ne ht 0 |
| 1267 | rc_sha_b 10 |
| 1268 | end |
| 1269 | rc_sha_fin |
| 1270 | for i ulong 32 |
| 1271 | put rc_body i get rc_tmp i |
| 1272 | end |
| 1273 | end |
| 1274 | |
| 1275 | fn rc_sig_hash to void |
| 1276 | rc_sha_init |
| 1277 | nfv = get nf 0 |
| 1278 | rc_sha_u64 nfv |
| 1279 | f = ulong 0 |
| 1280 | go = true |
| 1281 | while go |
| 1282 | m = ulong 0 |
| 1283 | while and go lt m 999999 |
| 1284 | if ge f nfv |
| 1285 | go = false |
| 1286 | else |
| 1287 | rc_sha_b a_gu 32 f |
| 1288 | rc_sha_b a_gu 23 f |
| 1289 | np = ulong a_gu 24 f |
| 1290 | rc_sha_b uchar np |
| 1291 | j = ulong 0 |
| 1292 | while lt j np |
| 1293 | px = add mul f 6 j |
| 1294 | rc_sha_b a_gu 35 px |
| 1295 | rc_sha_b a_gu 37 px |
| 1296 | rc_sha_u64 a_g 36 px |
| 1297 | j = add j 1 |
| 1298 | end |
| 1299 | f = add f 1 |
| 1300 | end |
| 1301 | m = add m 1 |
| 1302 | end |
| 1303 | end |
| 1304 | rc_sha_fin |
| 1305 | for i ulong 32 |
| 1306 | put rc_sig i get rc_tmp i |
| 1307 | end |
| 1308 | end |
| 1309 | |
| 1310 | fn rc_con_hash to void |
| 1311 | if and eq get rc_ccnt 0 0 eq get crel 0 0 |
| 1312 | for i ulong 32 |
| 1313 | put rc_con i 0 |
| 1314 | end |
| 1315 | ret |
| 1316 | end |
| 1317 | rc_sha_init |
| 1318 | for i ulong len rcdom_c |
| 1319 | rc_sha_b get rcdom_c i |
| 1320 | end |
| 1321 | rc_sha_b 0 |
| 1322 | rc_sha_u64 get crel 0 |
| 1323 | rc_sha_u64 get rc_ccnt 0 |
| 1324 | rc_sha_fin |
| 1325 | for i ulong 32 |
| 1326 | put rc_con i get rc_tmp i |
| 1327 | end |
| 1328 | end |
| 1329 | |
| 1330 | fn rc_pid_hash to void |
| 1331 | rc_sha_init |
| 1332 | for i ulong len rcdom_p |
| 1333 | rc_sha_b get rcdom_p i |
| 1334 | end |
| 1335 | rc_sha_b 0 |
| 1336 | for i ulong 32 |
| 1337 | rc_sha_b get rc_body i |
| 1338 | end |
| 1339 | for i ulong 32 |
| 1340 | rc_sha_b get rc_sig i |
| 1341 | end |
| 1342 | for i ulong 32 |
| 1343 | rc_sha_b get rc_con i |
| 1344 | end |
| 1345 | rc_sha_fin |
| 1346 | for i ulong 32 |
| 1347 | put rc_pid i get rc_tmp i |
| 1348 | end |
| 1349 | end |
| 1350 | |
| 1351 | fn rc_out_hash st ulong to void |
| 1352 | rc_sha_init |
| 1353 | i = st |
| 1354 | e = get oc 0 |
| 1355 | go = true |
| 1356 | while go |
| 1357 | m = ulong 0 |
| 1358 | while and go lt m 999999 |
| 1359 | if ge i e |
| 1360 | go = false |
| 1361 | else |
| 1362 | rc_sha_b a_ob i |
| 1363 | i = add i 1 |
| 1364 | end |
| 1365 | m = add m 1 |
| 1366 | end |
| 1367 | end |
| 1368 | rc_sha_fin |
| 1369 | for j ulong 32 |
| 1370 | put rc_out j get rc_tmp j |
| 1371 | end |
| 1372 | end |
| 1373 | |
| 1374 | fn rc_putw64 v ulong to void |
| 1375 | for i ulong 8 |
| 1376 | mputh and shr v mul sub 7 i 8 255 |
| 1377 | end |
| 1378 | end |
| 1379 | |
| 1380 | fn rc_emit st ulong to void |
| 1381 | if eq get rcmode 0 0 |
| 1382 | ret |
| 1383 | end |
| 1384 | d2finish |
| 1385 | rc_body_hash |
| 1386 | rc_sig_hash |
| 1387 | rc_con_hash |
| 1388 | rc_pid_hash |
| 1389 | rc_out_hash st |
| 1390 | put mc 0 0 |
| 1391 | for i ulong len rct_hdr |
| 1392 | mputb get rct_hdr i |
| 1393 | end |
| 1394 | for i ulong 32 |
| 1395 | mputh ulong get rc_pid i |
| 1396 | end |
| 1397 | for i ulong len rct_bid |
| 1398 | mputb get rct_bid i |
| 1399 | end |
| 1400 | for i ulong 32 |
| 1401 | mputh ulong get rc_body i |
| 1402 | end |
| 1403 | for i ulong len rct_sid |
| 1404 | mputb get rct_sid i |
| 1405 | end |
| 1406 | for i ulong 32 |
| 1407 | mputh ulong get rc_sig i |
| 1408 | end |
| 1409 | for i ulong len rct_cid |
| 1410 | mputb get rct_cid i |
| 1411 | end |
| 1412 | for i ulong 32 |
| 1413 | mputh ulong get rc_con i |
| 1414 | end |
| 1415 | for i ulong len rct_ish |
| 1416 | mputb get rct_ish i |
| 1417 | end |
| 1418 | for i ulong 32 |
| 1419 | mputh ulong get d2hash i |
| 1420 | end |
| 1421 | for i ulong len rct_ib |
| 1422 | mputb get rct_ib i |
| 1423 | end |
| 1424 | mputn get d2size 0 |
| 1425 | for i ulong len rct_osh |
| 1426 | mputb get rct_osh i |
| 1427 | end |
| 1428 | for i ulong 32 |
| 1429 | mputh ulong get rc_out i |
| 1430 | end |
| 1431 | for i ulong len rct_ob |
| 1432 | mputb get rct_ob i |
| 1433 | end |
| 1434 | mputn sub get oc 0 st |
| 1435 | for i ulong len rct_cs |
| 1436 | mputb get rct_cs i |
| 1437 | end |
| 1438 | for i ulong len d2pin |
| 1439 | mputb get d2pin i |
| 1440 | end |
| 1441 | for i ulong len rct_om2 |
| 1442 | mputb get rct_om2 i |
| 1443 | end |
| 1444 | mputn get om2 0 |
| 1445 | for i ulong len rct_obj |
| 1446 | mputb get rct_obj i |
| 1447 | end |
| 1448 | mputn get objmode 0 |
| 1449 | for i ulong len rct_ir |
| 1450 | mputb get rct_ir i |
| 1451 | end |
| 1452 | mputn get irmode 0 |
| 1453 | for i ulong len rct_tgt |
| 1454 | mputb get rct_tgt i |
| 1455 | end |
| 1456 | mputn get xtarget 0 |
| 1457 | for i ulong len rct_efa |
| 1458 | mputb get rct_efa i |
| 1459 | end |
| 1460 | mputn get xefa 0 |
| 1461 | for i ulong len rct_eff |
| 1462 | mputb get rct_eff i |
| 1463 | end |
| 1464 | mputn get rc_cat 0 |
| 1465 | for i ulong len rct_es |
| 1466 | mputb get rct_es i |
| 1467 | end |
| 1468 | mputn get rc_cnt 0 |
| 1469 | for i ulong len rct_ew |
| 1470 | mputb get rct_ew i |
| 1471 | end |
| 1472 | rc_putw64 get rc_w 3 |
| 1473 | rc_putw64 get rc_w 2 |
| 1474 | rc_putw64 get rc_w 1 |
| 1475 | rc_putw64 get rc_w 0 |
| 1476 | plen = get mc 0 |
| 1477 | rc_sha_init |
| 1478 | for i ulong len rcdom_r |
| 1479 | rc_sha_b get rcdom_r i |
| 1480 | end |
| 1481 | rc_sha_b 0 |
| 1482 | for i ulong plen |
| 1483 | rc_sha_b get msg i |
| 1484 | end |
| 1485 | rc_sha_fin |
| 1486 | for i ulong 32 |
| 1487 | put rc_rid i get rc_tmp i |
| 1488 | end |
| 1489 | for i ulong len rct_rid |
| 1490 | mputb get rct_rid i |
| 1491 | end |
| 1492 | for i ulong 32 |
| 1493 | mputh ulong get rc_rid i |
| 1494 | end |
| 1495 | mputb 10 |
| 1496 | w = write 2 msg 0 get mc 0 |
| 1497 | end |
| 1498 | |
| 1499 | |
| 1500 | note D2-GENERATED-END |
| 1501 | |
| 1502 | fn a_env to void |
| 1503 | nl = envcnt |
| 1504 | n = ulong nl |
| 1505 | i = ulong 0 |
| 1506 | while lt i n |
| 1507 | kl = envread i a_eb 0 131072 |
| 1508 | if lt kl 0 |
| 1509 | note d2site 1|a_env: the compiler's environment entry OMC_MEMORY_MAX is not empty, 0 or 1 to 19 decimal digits below 2^63, or an entry is too long to read whole; condition if lt kl 0 |
| 1510 | put d2site 0 1 |
| 1511 | fail 26 |
| 1512 | end |
| 1513 | if ge kl 15 |
| 1514 | k = ulong kl |
| 1515 | if eq a_envp 0 1 |
| 1516 | a_envv k |
| 1517 | ret |
| 1518 | end |
| 1519 | end |
| 1520 | i = add i 1 |
| 1521 | end |
| 1522 | end |
| 1523 | |
| 1524 | note a_envp: 1 when a_eb starts with OMC_MEMORY_MAX= |
| 1525 | fn a_envp z ulong to ulong |
| 1526 | j = ulong 0 |
| 1527 | while lt j 15 |
| 1528 | if ne get a_eb j get a_envk j |
| 1529 | ret 0 |
| 1530 | end |
| 1531 | j = add j 1 |
| 1532 | end |
| 1533 | ret 1 |
| 1534 | end |
| 1535 | |
| 1536 | note a_envv: the value of OMC_MEMORY_MAX=, bytes 15 .. k - 1 of a_eb: empty or 0 is no ceiling; 1 to 19 decimal |
| 1537 | note digits below 2^63 a ceiling; anything else is a caller's mistake: error 26 on line 0, before any input is read |
| 1538 | fn a_envv k ulong to void |
| 1539 | if eq k 15 |
| 1540 | ret |
| 1541 | end |
| 1542 | if gt sub k 15 19 |
| 1543 | note d2site 2|a_envv: the compiler's environment entry OMC_MEMORY_MAX is not empty, 0 or 1 to 19 decimal digits below 2^63, or an entry is too long to read whole; condition if gt sub k 15 19 |
| 1544 | put d2site 0 2 |
| 1545 | fail 26 |
| 1546 | end |
| 1547 | v = ulong 0 |
| 1548 | j = ulong 15 |
| 1549 | while lt j k |
| 1550 | c = ulong get a_eb j |
| 1551 | if or lt c 48 gt c 57 |
| 1552 | note d2site 3|a_envv: the compiler's environment entry OMC_MEMORY_MAX is not empty, 0 or 1 to 19 decimal digits below 2^63, or an entry is too long to read whole; condition if or lt c 48 gt c 57 |
| 1553 | put d2site 0 3 |
| 1554 | fail 26 |
| 1555 | end |
| 1556 | if gt v 922337203685477580 |
| 1557 | note d2site 4|a_envv: the compiler's environment entry OMC_MEMORY_MAX is not empty, 0 or 1 to 19 decimal digits below 2^63, or an entry is too long to read whole; condition if gt v 922337203685477580 |
| 1558 | put d2site 0 4 |
| 1559 | fail 26 |
| 1560 | end |
| 1561 | v = add mul v 10 sub c 48 |
| 1562 | j = add j 1 |
| 1563 | end |
| 1564 | if ge v 9223372036854775808 |
| 1565 | note d2site 5|a_envv: the compiler's environment entry OMC_MEMORY_MAX is not empty, 0 or 1 to 19 decimal digits below 2^63, or an entry is too long to read whole; condition if ge v 9223372036854775808 |
| 1566 | put d2site 0 5 |
| 1567 | fail 26 |
| 1568 | end |
| 1569 | if eq v 0 |
| 1570 | ret |
| 1571 | end |
| 1572 | note CEILMUT |
| 1573 | put a_cel 0 v |
| 1574 | end |
| 1575 | |
| 1576 | note a_gextra: the words group g's regions need beyond the words they hold, at capacity c |
| 1577 | fn a_gextra g ulong c ulong to ulong |
| 1578 | s = ulong 0 |
| 1579 | r = ulong 0 |
| 1580 | while lt r get a_nr 0 |
| 1581 | if eq get a_rg r g |
| 1582 | w = a_words r c |
| 1583 | if gt w get a_rw r |
| 1584 | s = add s sub w get a_rw r |
| 1585 | end |
| 1586 | end |
| 1587 | r = add r 1 |
| 1588 | end |
| 1589 | ret s |
| 1590 | end |
| 1591 | |
| 1592 | note a_gfit: the largest capacity in n + 1 .. hi whose growth in place fits in the free words and the budget (a_bad) |
| 1593 | note (binary search; it grows with the capacity), or error 14 (a_full) when not even n + 1 does |
| 1594 | fn a_gfit g ulong n ulong hi ulong to ulong |
| 1595 | f = sub len a_ar get a_top 0 |
| 1596 | lo = add n 1 |
| 1597 | if ne a_bad g lo 0 |
| 1598 | a_full |
| 1599 | end |
| 1600 | go = true |
| 1601 | while go |
| 1602 | m = ulong 0 |
| 1603 | while and go lt m 999999 |
| 1604 | if le sub hi lo 1 |
| 1605 | go = false |
| 1606 | else |
| 1607 | mid = add lo shr sub hi lo 1 |
| 1608 | if ne a_bad g mid 0 |
| 1609 | hi = mid |
| 1610 | else |
| 1611 | lo = mid |
| 1612 | end |
| 1613 | end |
| 1614 | m = add m 1 |
| 1615 | end |
| 1616 | end |
| 1617 | ret lo |
| 1618 | end |
| 1619 | |
| 1620 | note a_relayout: after a_compact (regions contiguous from word 0 in order of base), give group g's |
| 1621 | note regions their words at capacity c in place: new places are laid out in the same order, every region |
| 1622 | note at or above its old place, and the regions are moved from the top down (a_copyd), each new tail |
| 1623 | note zeroed. Region 0, the input, is the first and never moves. |
| 1624 | fn a_relayout g ulong c ulong to void |
| 1625 | k = ulong 0 |
| 1626 | lb = ulong 0 |
| 1627 | any = false |
| 1628 | go = true |
| 1629 | while go |
| 1630 | best = a_lowest any lb |
| 1631 | if eq best 0 |
| 1632 | go = false |
| 1633 | else |
| 1634 | r = sub best 1 |
| 1635 | put a_ord k r |
| 1636 | k = add k 1 |
| 1637 | lb = get a_rb r |
| 1638 | any = true |
| 1639 | end |
| 1640 | end |
| 1641 | pos = ulong 0 |
| 1642 | i = ulong 0 |
| 1643 | while lt i k |
| 1644 | r = get a_ord i |
| 1645 | put a_np i pos |
| 1646 | w = get a_rw r |
| 1647 | if eq get a_rg r g |
| 1648 | w = a_words r c |
| 1649 | end |
| 1650 | pos = add pos w |
| 1651 | i = add i 1 |
| 1652 | end |
| 1653 | i = k |
| 1654 | while gt i 0 |
| 1655 | i = sub i 1 |
| 1656 | r = get a_ord i |
| 1657 | np = get a_np i |
| 1658 | b = get a_rb r |
| 1659 | w = get a_rw r |
| 1660 | if ne np b |
| 1661 | a_copyd np b w |
| 1662 | put a_rb r np |
| 1663 | end |
| 1664 | if eq get a_rg r g |
| 1665 | nw = a_words r c |
| 1666 | if gt nw w |
| 1667 | a_clear add np w add np nw |
| 1668 | put a_rw r nw |
| 1669 | end |
| 1670 | end |
| 1671 | end |
| 1672 | put a_top 0 pos |
| 1673 | end |
| 1674 | |
| 1675 | note a_copyd: words s .. s + n - 1 of the arena to d .. d + n - 1 in descending order (d above s: a slide up) |
| 1676 | fn a_copyd d ulong s ulong n ulong to void |
| 1677 | i = n |
| 1678 | go = true |
| 1679 | while go |
| 1680 | m = ulong 0 |
| 1681 | while and go lt m 999999 |
| 1682 | if eq i 0 |
| 1683 | go = false |
| 1684 | else |
| 1685 | i = sub i 1 |
| 1686 | put a_ar add d i get a_ar add s i |
| 1687 | end |
| 1688 | m = add m 1 |
| 1689 | end |
| 1690 | end |
| 1691 | end |
| 1692 | |
| 1693 | note a_compact: slide every region down over the words moved regions left behind, in order of base, so |
| 1694 | note the free words are one run at the top again; the words above the new top become 0 (a_move hands out |
| 1695 | note words past a_top as zero). Region 0, the input, has base 0 and stays there (a_ib reads it at 0). |
| 1696 | fn a_compact to void |
| 1697 | t = get a_top 0 |
| 1698 | pos = ulong 0 |
| 1699 | lb = ulong 0 |
| 1700 | any = false |
| 1701 | go = true |
| 1702 | while go |
| 1703 | best = a_lowest any lb |
| 1704 | if eq best 0 |
| 1705 | go = false |
| 1706 | else |
| 1707 | r = sub best 1 |
| 1708 | b = get a_rb r |
| 1709 | w = get a_rw r |
| 1710 | if ne b pos |
| 1711 | a_copy pos b w |
| 1712 | put a_rb r pos |
| 1713 | end |
| 1714 | pos = add pos w |
| 1715 | lb = b |
| 1716 | any = true |
| 1717 | end |
| 1718 | end |
| 1719 | a_clear pos t |
| 1720 | put a_top 0 pos |
| 1721 | put a_wst 0 0 |
| 1722 | end |
| 1723 | |
| 1724 | note a_lowest: index + 1 of the region holding words with the lowest base above lb (any base when any is |
| 1725 | note false), or 0 when none is left; regions slid already have bases at or below lb |
| 1726 | fn a_lowest any bool lb ulong to ulong |
| 1727 | best = ulong 0 |
| 1728 | bb = ulong 0 |
| 1729 | r = ulong 0 |
| 1730 | while lt r get a_nr 0 |
| 1731 | if ne get a_rw r 0 |
| 1732 | b = get a_rb r |
| 1733 | if or not any gt b lb |
| 1734 | if or eq best 0 lt b bb |
| 1735 | best = add r 1 |
| 1736 | bb = b |
| 1737 | end |
| 1738 | end |
| 1739 | end |
| 1740 | r = add r 1 |
| 1741 | end |
| 1742 | ret best |
| 1743 | end |
| 1744 | |
| 1745 | note a_clear: words a .. b - 1 of the arena become 0 |
| 1746 | fn a_clear a ulong b ulong to void |
| 1747 | i = a |
| 1748 | go = true |
| 1749 | while go |
| 1750 | m = ulong 0 |
| 1751 | while and go lt m 999999 |
| 1752 | if ge i b |
| 1753 | go = false |
| 1754 | else |
| 1755 | put a_ar i 0 |
| 1756 | i = add i 1 |
| 1757 | end |
| 1758 | m = add m 1 |
| 1759 | end |
| 1760 | end |
| 1761 | end |
| 1762 | |
| 1763 | note a_gneed: the words group g's regions take at capacity c, counted as if every one of them moved |
| 1764 | fn a_gneed g ulong c ulong to ulong |
| 1765 | s = ulong 0 |
| 1766 | r = ulong 0 |
| 1767 | while lt r get a_nr 0 |
| 1768 | if eq get a_rg r g |
| 1769 | s = add s a_words r c |
| 1770 | end |
| 1771 | r = add r 1 |
| 1772 | end |
| 1773 | ret s |
| 1774 | end |
| 1775 | |
| 1776 | note a_full: the arena has no room left and the host refused to grow it: error 14 (full=1), and fail writes the |
| 1777 | note omc-use record after its line |
| 1778 | fn a_full to void |
| 1779 | put a_fl 0 1 |
| 1780 | note d2site 6|a_full: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound) |
| 1781 | put d2site 0 6 |
| 1782 | fail 14 |
| 1783 | end |
| 1784 | |
| 1785 | note a_zero: the first k words of region r become 0 |
| 1786 | fn a_zero r ulong k ulong to void |
| 1787 | b = get a_rb r |
| 1788 | i = ulong 0 |
| 1789 | go = true |
| 1790 | while go |
| 1791 | m = ulong 0 |
| 1792 | while and go lt m 999999 |
| 1793 | if ge i k |
| 1794 | go = false |
| 1795 | else |
| 1796 | put a_ar add b i 0 |
| 1797 | i = add i 1 |
| 1798 | end |
| 1799 | m = add m 1 |
| 1800 | end |
| 1801 | end |
| 1802 | end |
| 1803 | |
| 1804 | note a_gzero: every word of every region of group g becomes 0 (a hash table about to be rebuilt) |
| 1805 | fn a_gzero g ulong to void |
| 1806 | r = ulong 0 |
| 1807 | while lt r get a_nr 0 |
| 1808 | if eq get a_rg r g |
| 1809 | a_zero r get a_rw r |
| 1810 | end |
| 1811 | r = add r 1 |
| 1812 | end |
| 1813 | end |
| 1814 | |
| 1815 | note a_ib: input byte i. The input is region 0, the first region handed out, so it starts at word 0. Past |
| 1816 | note its words the byte is 0, as the zero pool past the input was. |
| 1817 | fn a_ib i ulong to uchar |
| 1818 | x = shr i 3 |
| 1819 | if ge x get a_rw 0 |
| 1820 | ret 0 |
| 1821 | end |
| 1822 | y = get a_ar x |
| 1823 | ret uchar and shr y shl and i 7 3 255 |
| 1824 | end |
| 1825 | |
| 1826 | note a_ob: output byte i (0 past the output's words) |
| 1827 | fn a_ob i ulong to uchar |
| 1828 | x = shr i 3 |
| 1829 | if ge x get a_rw 1 |
| 1830 | ret 0 |
| 1831 | end |
| 1832 | y = get a_ar add get a_rb 1 x |
| 1833 | ret uchar and shr y shl and i 7 3 255 |
| 1834 | end |
| 1835 | |
| 1836 | note a_oob: an index past its region is a fault of omc itself, never an input's: trap 3, exactly as an |
| 1837 | note index past a fixed pool trapped (the runtime check on a_rb at index 96 + i, always past its 96) |
| 1838 | fn a_oob i ulong to void |
| 1839 | z = get a_rb add 96 i |
| 1840 | end |
| 1841 | |
| 1842 | note a_bput: byte i of byte region r becomes v (a_oob past the region's words) |
| 1843 | fn a_bput r ulong i ulong v uchar to void |
| 1844 | x = shr i 3 |
| 1845 | if ge x get a_rw r |
| 1846 | a_oob x |
| 1847 | end |
| 1848 | x = add get a_rb r x |
| 1849 | s = shl and i 7 3 |
| 1850 | y = get a_ar x |
| 1851 | y = and y not shl ulong 255 s |
| 1852 | y = or y shl ulong v s |
| 1853 | put a_ar x y |
| 1854 | end |
| 1855 | |
| 1856 | note a_pc: element i of a uchar table held one to a word (region r) becomes v (a_oob past the region) |
| 1857 | fn a_pc r ulong i ulong v uchar to void |
| 1858 | if ge i get a_rw r |
| 1859 | a_oob i |
| 1860 | end |
| 1861 | put a_ar add get a_rb r i ulong v |
| 1862 | end |
| 1863 | |
| 1864 | note a_stage: bytes p .. p + c - 1 of the byte region at word b into a_wb from 0 (c at most 65536) |
| 1865 | fn a_stage b ulong p ulong c ulong to void |
| 1866 | i = ulong 0 |
| 1867 | while and lt i c ne and add p i 7 0 |
| 1868 | x = add p i |
| 1869 | y = get a_ar add b shr x 3 |
| 1870 | put a_wb i uchar and shr y shl and x 7 3 255 |
| 1871 | i = add i 1 |
| 1872 | end |
| 1873 | note whole words: one load, eight bytes |
| 1874 | while le add i 8 c |
| 1875 | y = get a_ar add b shr add p i 3 |
| 1876 | for k ulong 8 |
| 1877 | put a_wb add i k uchar and shr y shl k 3 255 |
| 1878 | end |
| 1879 | i = add i 8 |
| 1880 | end |
| 1881 | while lt i c |
| 1882 | x = add p i |
| 1883 | y = get a_ar add b shr x 3 |
| 1884 | put a_wb i uchar and shr y shl and x 7 3 255 |
| 1885 | i = add i 1 |
| 1886 | end |
| 1887 | end |
| 1888 | |
| 1889 | note a_out: write bytes p .. e - 1 of byte region r to fd, 65536 at a time through a_wb: 1 when every |
| 1890 | note byte was written, 0 when a write returned 0 or less |
| 1891 | fn a_out fd ulong r ulong p ulong e ulong to ulong |
| 1892 | b = get a_rb r |
| 1893 | go = true |
| 1894 | while go |
| 1895 | m = ulong 0 |
| 1896 | while and go lt m 999999 |
| 1897 | if ge p e |
| 1898 | go = false |
| 1899 | else |
| 1900 | c = sub e p |
| 1901 | if gt c 65536 |
| 1902 | c = ulong 65536 |
| 1903 | end |
| 1904 | a_stage b p c |
| 1905 | q = ulong 0 |
| 1906 | while lt q c |
| 1907 | n = write int fd a_wb q sub c q |
| 1908 | if le n 0 |
| 1909 | ret 0 |
| 1910 | end |
| 1911 | q = add q ulong n |
| 1912 | end |
| 1913 | p = add p c |
| 1914 | end |
| 1915 | m = add m 1 |
| 1916 | end |
| 1917 | end |
| 1918 | ret 1 |
| 1919 | end |
| 1920 | |
| 1921 | note a_rdin: all of stdin into region 0, eight bytes to a word from word 0 (error 1 on a read error, |
| 1922 | note error 14 when the arena has no room); then the region keeps the words the input fills and 8 more, all |
| 1923 | note zero, so the next region starts after them. inlen: the input's bytes. Input bytes are read inline |
| 1924 | note from word 0 (the codemod's a_ib form) without a region check; the 64 zero bytes past the input are |
| 1925 | note what a lookahead past the end reads, as the zero pool past the input did. |
| 1926 | fn a_rdin to void |
| 1927 | off = ulong 0 |
| 1928 | go = true |
| 1929 | while go |
| 1930 | m = ulong 0 |
| 1931 | while and go lt m 999999 |
| 1932 | n = read 0 a_wb 0 65536 |
| 1933 | if eq n 0 |
| 1934 | if or ne get d2mode 0 0 ne get rcmode 0 0 |
| 1935 | d2finish |
| 1936 | put d2full 0 1 |
| 1937 | end |
| 1938 | go = false |
| 1939 | else |
| 1940 | if lt n 0 |
| 1941 | note d2site 7|a_rdin: the compiler's standard input could not be read; condition if lt n 0 |
| 1942 | put d2site 0 7 |
| 1943 | fail 1 |
| 1944 | end |
| 1945 | c = ulong n |
| 1946 | if or ne get d2mode 0 0 ne get rcmode 0 0 |
| 1947 | d2feed c |
| 1948 | end |
| 1949 | note inlen counts what was read so far, so an arena-full record shows it |
| 1950 | put inlen 0 add off c |
| 1951 | a_need 0 add off c |
| 1952 | a_pack off c |
| 1953 | off = add off c |
| 1954 | end |
| 1955 | m = add m 1 |
| 1956 | end |
| 1957 | end |
| 1958 | put inlen 0 off |
| 1959 | w = add shr off 3 9 |
| 1960 | a_need 0 shl w 3 |
| 1961 | put a_rw 0 w |
| 1962 | put a_top 0 w |
| 1963 | put a_hw 0 w |
| 1964 | put a_gc 0 shl w 3 |
| 1965 | end |
| 1966 | |
| 1967 | note a_pack: the c bytes of a_wb become input bytes off .. off + c - 1 (their words are 0 until now) |
| 1968 | fn a_pack off ulong c ulong to void |
| 1969 | i = ulong 0 |
| 1970 | while and lt i c ne and add off i 7 0 |
| 1971 | a_pack1 add off i ulong get a_wb i |
| 1972 | i = add i 1 |
| 1973 | end |
| 1974 | note whole words: eight bytes, one store (the word was 0) |
| 1975 | while le add i 8 c |
| 1976 | w = ulong 0 |
| 1977 | for k ulong 8 |
| 1978 | w = or w shl ulong get a_wb add i k shl k 3 |
| 1979 | end |
| 1980 | put a_ar shr add off i 3 w |
| 1981 | i = add i 8 |
| 1982 | end |
| 1983 | while lt i c |
| 1984 | a_pack1 add off i ulong get a_wb i |
| 1985 | i = add i 1 |
| 1986 | end |
| 1987 | end |
| 1988 | |
| 1989 | note a_pack1: input byte x becomes b (its word holds 0 at that byte until now) |
| 1990 | fn a_pack1 x ulong b ulong to void |
| 1991 | s = shl and x 7 3 |
| 1992 | y = get a_ar shr x 3 |
| 1993 | put a_ar shr x 3 or y shl b s |
| 1994 | end |
| 1995 | |
| 1996 | note a_init: every other region gets its first room after the input: the hash tables 1024 buckets, the |
| 1997 | note output last (it grows most, and the last region grows in place), the rest 64 entries each, except |
| 1998 | note the groups that grow with the input (names, long names, functions, calls, trap sites), which get |
| 1999 | note room for the entries an input of this size usually holds (a_isize). The arena is zero .bss: room |
| 2000 | note never written costs no page, while a region that outgrows its room moves and leaves touched pages |
| 2001 | note behind, so a first room that fits saves those pages (measured: 145 fewer page faults on omega-mcp). |
| 2002 | fn a_init to void |
| 2003 | a_defs |
| 2004 | g = ulong 2 |
| 2005 | while lt g 21 |
| 2006 | if or or eq g 4 eq g 6 eq g 8 |
| 2007 | a_need g 1023 |
| 2008 | else |
| 2009 | a_need g sub a_isize g 1 |
| 2010 | end |
| 2011 | g = add g 1 |
| 2012 | end |
| 2013 | put nh_b 0 10 |
| 2014 | put lh_b 0 10 |
| 2015 | put fh_b 0 10 |
| 2016 | a_need 1 65535 |
| 2017 | note the first room is not use: a_gp counts only what the unit asks for (the omc-use record) |
| 2018 | g = ulong 0 |
| 2019 | while lt g 21 |
| 2020 | put a_gp g 0 |
| 2021 | g = add g 1 |
| 2022 | end |
| 2023 | put a_rdy 0 1 |
| 2024 | end |
| 2025 | |
| 2026 | note a_isize: the first room of group g, in entries: the input's bytes over k for the groups that grow |
| 2027 | note with it (names k 16, long names 64, functions 64, calls 8, trap sites 8), between 64 and 8192; |
| 2028 | note 64 for the rest. A guess, never a bound: past it the group doubles as always. |
| 2029 | fn a_isize g ulong to ulong |
| 2030 | k = ulong 0 |
| 2031 | if or eq g 3 eq g 9 |
| 2032 | k = ulong 16 |
| 2033 | end |
| 2034 | if or eq g 5 eq g 7 |
| 2035 | k = ulong 64 |
| 2036 | end |
| 2037 | if eq g 10 |
| 2038 | k = ulong 8 |
| 2039 | end |
| 2040 | if eq g 9 |
| 2041 | k = ulong 8 |
| 2042 | end |
| 2043 | if eq k 0 |
| 2044 | ret 64 |
| 2045 | end |
| 2046 | c = div get inlen 0 k |
| 2047 | if lt c 64 |
| 2048 | ret 64 |
| 2049 | end |
| 2050 | if gt c 8192 |
| 2051 | ret 8192 |
| 2052 | end |
| 2053 | ret c |
| 2054 | end |
| 2055 | |
| 2056 | note a_hash: the b-bit multiplicative hash of w (2^64 divided by the golden ratio, odd) |
| 2057 | fn a_hash w ulong b ulong to ulong |
| 2058 | ret shr mul w 11400714819323198485 sub 64 b |
| 2059 | end |
| 2060 | |
| 2061 | note a_gcount: what group g was asked to hold: the bytes of the input, the output and the om2 diag sites, |
| 2062 | note else the highest index asked for, plus 1 |
| 2063 | fn a_gcount g ulong to ulong |
| 2064 | if eq g 0 |
| 2065 | ret get inlen 0 |
| 2066 | end |
| 2067 | if eq g 1 |
| 2068 | ret get oc 0 |
| 2069 | end |
| 2070 | if eq g 2 |
| 2071 | ret get nsite 0 |
| 2072 | end |
| 2073 | ret get a_gp g |
| 2074 | end |
| 2075 | |
| 2076 | note a_gwords: the words the regions of group g hold |
| 2077 | fn a_gwords g ulong to ulong |
| 2078 | s = ulong 0 |
| 2079 | r = ulong 0 |
| 2080 | while lt r get a_nr 0 |
| 2081 | if eq get a_rg r g |
| 2082 | s = add s get a_rw r |
| 2083 | end |
| 2084 | r = add r 1 |
| 2085 | end |
| 2086 | ret s |
| 2087 | end |
| 2088 | |
| 2089 | note a_rec: the omc-use record, one line to fd: omc-use 1 arena=A top=T waste=W full=F, then for each |
| 2090 | note group LABEL=N/H, N what it was asked to hold (a_gcount) and H the words it holds. A, T, W and H are |
| 2091 | note 8-byte words of the arena; F is 1 when the compile stopped because the arena was full. |
| 2092 | fn a_rec fd ulong to void |
| 2093 | put mc 0 0 |
| 2094 | mputw 2334398928971328879 8 |
| 2095 | mputw 4422937691044257841 8 |
| 2096 | mputn len a_ar |
| 2097 | mputw 263879357472 5 |
| 2098 | mputn get a_top 0 |
| 2099 | mputw 17281524405729056 7 |
| 2100 | mputn get a_wst 0 |
| 2101 | mputw 67535885395488 6 |
| 2102 | mputn get a_fl 0 |
| 2103 | g = ulong 0 |
| 2104 | limit = ulong 21 |
| 2105 | if ne get objmode 0 0 |
| 2106 | limit = ulong 23 |
| 2107 | end |
| 2108 | while lt g limit |
| 2109 | mputb 32 |
| 2110 | a_gname g |
| 2111 | mputb 61 |
| 2112 | mputn a_gcount g |
| 2113 | mputb 47 |
| 2114 | mputn a_gwords g |
| 2115 | g = add g 1 |
| 2116 | end |
| 2117 | mputb 32 |
| 2118 | mputw 4424626557984269667 8 |
| 2119 | mputn get a_cel 0 |
| 2120 | mputb 10 |
| 2121 | w = write int fd msg 0 get mc 0 |
| 2122 | end |
| 2123 | |
| 2124 | note ---- arena regions (generated by the one-off codemod; region: name, group, kind) ---- |
| 2125 | note 0 inp group 0 (INP) bytes |
| 2126 | note 1 out group 1 (OUT) bytes |
| 2127 | note 2 sitebuf group 2 (SITE) bytes |
| 2128 | note 3 nm_name group 3 (NM) ulong x1 |
| 2129 | note 4 nm_reg group 3 (NM) uchar in a word x1 |
| 2130 | note 5 nm_type group 3 (NM) uchar in a word x1 |
| 2131 | note 6 nm_len group 3 (NM) ulong x1 |
| 2132 | note 7 nm_kind group 3 (NM) uchar in a word x1 |
| 2133 | note 8 nm_addr group 3 (NM) ulong x1 |
| 2134 | note 9 nm_fv group 3 (NM) uchar in a word x1 |
| 2135 | note 10 nm_pb group 3 (NM) uchar in a word x1 |
| 2136 | note 11 nm_pl group 3 (NM) uchar in a word x1 |
| 2137 | note 12 nm_lay group 3 (NM) uchar in a word x1 |
| 2138 | note 13 nm_fr group 3 (NM) uchar in a word x1 |
| 2139 | note 14 nm_lr group 3 (NM) uchar in a word x1 |
| 2140 | note 15 nm_nx group 3 (NM) ulong x1 |
| 2141 | note 16 nm_h group 4 (NMH) ulong x1 |
| 2142 | note 17 ln_o group 5 (LN) ulong x1 |
| 2143 | note 18 ln_l group 5 (LN) uchar in a word x1 |
| 2144 | note 19 ln_x group 5 (LN) ulong x1 |
| 2145 | note 20 ln_h group 6 (LNH) ulong x1 |
| 2146 | note 21 fn_name group 7 (FN) ulong x1 |
| 2147 | note 22 fn_addr group 7 (FN) ulong x1 |
| 2148 | note 23 fn_ret group 7 (FN) uchar in a word x1 |
| 2149 | note 24 fn_np group 7 (FN) uchar in a word x1 |
| 2150 | note 25 fn_nmlen group 7 (FN) ulong x1 |
| 2151 | note 26 fn_off group 7 (FN) ulong x1 |
| 2152 | note 27 fn_inl group 7 (FN) uchar in a word x1 |
| 2153 | note 28 fn_body group 7 (FN) ulong x1 |
| 2154 | note 29 fn_bln group 7 (FN) ulong x1 |
| 2155 | note 30 settled group 7 (FN) uchar in a word x1 |
| 2156 | note 31 reach group 7 (FN) uchar in a word x1 |
| 2157 | note 32 fn_exp group 7 (FN) uchar in a word x1 |
| 2158 | note 33 fn_nx group 7 (FN) ulong x1 |
| 2159 | note 34 fn_pn group 7 (FN) ulong x6 |
| 2160 | note 35 fn_pt group 7 (FN) uchar in a word x6 |
| 2161 | note 36 fn_pl group 7 (FN) ulong x6 |
| 2162 | note 37 fn_pk group 7 (FN) uchar in a word x6 |
| 2163 | note 38 fn_play group 7 (FN) uchar in a word x6 |
| 2164 | note 39 fn_pfr group 7 (FN) uchar in a word x6 |
| 2165 | note 40 fn_h group 8 (FNH) ulong x1 |
| 2166 | note 41 callsite group 9 (CALL) ulong x1 |
| 2167 | note 42 callfrom group 9 (CALL) ulong x1 |
| 2168 | note 43 callto group 9 (CALL) ulong x1 |
| 2169 | note 44 tsite group 10 (TRAP) ulong x1 |
| 2170 | note 45 tcode group 10 (TRAP) ulong x1 |
| 2171 | note 46 xasite group 11 (XA) ulong x1 |
| 2172 | note 47 xavalue group 11 (XA) ulong x1 |
| 2173 | note 48 xexsite group 12 (XE) ulong x1 |
| 2174 | note 49 bkind group 13 (BLK) ulong x1 |
| 2175 | note 50 bbr group 13 (BLK) ulong x1 |
| 2176 | note 51 bhead group 13 (BLK) ulong x1 |
| 2177 | note 52 breg group 13 (BLK) ulong x1 |
| 2178 | note 53 btyp group 13 (BLK) ulong x1 |
| 2179 | note 54 bnames group 13 (BLK) ulong x1 |
| 2180 | note 55 bheld group 13 (BLK) ulong x1 |
| 2181 | note 56 bdead group 13 (BLK) ulong x1 |
| 2182 | note 57 brot group 13 (BLK) ulong x1 |
| 2183 | note 58 bkk group 13 (BLK) ulong x1 |
| 2184 | note 59 bkr group 13 (BLK) ulong x1 |
| 2185 | note 60 bk0 group 13 (BLK) ulong x1 |
| 2186 | note 61 bc0 group 13 (BLK) ulong x1 |
| 2187 | note 62 u_cur group 13 (BLK) ulong x1 |
| 2188 | note 63 u_line group 13 (BLK) ulong x1 |
| 2189 | note 64 u_it group 13 (BLK) ulong x1 |
| 2190 | note 65 u_k group 13 (BLK) ulong x1 |
| 2191 | note 66 u_nn group 13 (BLK) ulong x1 |
| 2192 | note 67 u_held group 13 (BLK) ulong x1 |
| 2193 | note 68 fz_ent group 13 (BLK) ulong x16 |
| 2194 | note 69 fz_thn group 13 (BLK) ulong x16 |
| 2195 | note 70 brkpos group 14 (BRK) ulong x1 |
| 2196 | note 71 brkblk group 14 (BRK) ulong x1 |
| 2197 | note 72 cpos group 15 (CONT) ulong x1 |
| 2198 | note 73 cblk group 15 (CONT) ulong x1 |
| 2199 | note 74 ilp group 16 (ILP) ulong x1 |
| 2200 | note 75 ie_from group 17 (IE) ulong x1 |
| 2201 | note 76 ie_to group 17 (IE) ulong x1 |
| 2202 | note 77 fr group 18 (DEP) ulong x32 |
| 2203 | note 78 fwv group 18 (DEP) ulong x1 |
| 2204 | note 79 ul_k group 18 (DEP) ulong x6 |
| 2205 | note 80 ul_v group 18 (DEP) ulong x6 |
| 2206 | note 81 k_deg group 19 (KF) ulong x1 |
| 2207 | note 82 k_st group 19 (KF) ulong x1 |
| 2208 | note 83 k_cu group 19 (KF) ulong x1 |
| 2209 | note 84 k_q group 19 (KF) ulong x1 |
| 2210 | note 85 k_ed group 20 (KC) ulong x1 |
| 2211 | fn a_defs to void |
| 2212 | a_def 0 0 0 |
| 2213 | a_def 1 1 0 |
| 2214 | a_def 2 2 0 |
| 2215 | a_def 3 3 1 |
| 2216 | a_def 4 3 1 |
| 2217 | a_def 5 3 1 |
| 2218 | a_def 6 3 1 |
| 2219 | a_def 7 3 1 |
| 2220 | a_def 8 3 1 |
| 2221 | a_def 9 3 1 |
| 2222 | a_def 10 3 1 |
| 2223 | a_def 11 3 1 |
| 2224 | a_def 12 3 1 |
| 2225 | a_def 13 3 1 |
| 2226 | a_def 14 3 1 |
| 2227 | a_def 15 3 1 |
| 2228 | a_def 16 4 1 |
| 2229 | a_def 17 5 1 |
| 2230 | a_def 18 5 1 |
| 2231 | a_def 19 5 1 |
| 2232 | a_def 20 6 1 |
| 2233 | a_def 21 7 1 |
| 2234 | a_def 22 7 1 |
| 2235 | a_def 23 7 1 |
| 2236 | a_def 24 7 1 |
| 2237 | a_def 25 7 1 |
| 2238 | a_def 26 7 1 |
| 2239 | a_def 27 7 1 |
| 2240 | a_def 28 7 1 |
| 2241 | a_def 29 7 1 |
| 2242 | a_def 30 7 1 |
| 2243 | a_def 31 7 1 |
| 2244 | a_def 32 7 1 |
| 2245 | a_def 33 7 1 |
| 2246 | a_def 34 7 6 |
| 2247 | a_def 35 7 6 |
| 2248 | a_def 36 7 6 |
| 2249 | a_def 37 7 6 |
| 2250 | a_def 38 7 6 |
| 2251 | a_def 39 7 6 |
| 2252 | a_def 40 8 1 |
| 2253 | a_def 41 9 1 |
| 2254 | a_def 42 9 1 |
| 2255 | a_def 43 9 1 |
| 2256 | a_def 44 10 1 |
| 2257 | a_def 45 10 1 |
| 2258 | a_def 46 11 1 |
| 2259 | a_def 47 11 1 |
| 2260 | a_def 48 12 1 |
| 2261 | a_def 49 13 1 |
| 2262 | a_def 50 13 1 |
| 2263 | a_def 51 13 1 |
| 2264 | a_def 52 13 1 |
| 2265 | a_def 53 13 1 |
| 2266 | a_def 54 13 1 |
| 2267 | a_def 55 13 1 |
| 2268 | a_def 56 13 1 |
| 2269 | a_def 57 13 1 |
| 2270 | a_def 58 13 1 |
| 2271 | a_def 59 13 1 |
| 2272 | a_def 60 13 1 |
| 2273 | a_def 61 13 1 |
| 2274 | a_def 62 13 1 |
| 2275 | a_def 63 13 1 |
| 2276 | a_def 64 13 1 |
| 2277 | a_def 65 13 1 |
| 2278 | a_def 66 13 1 |
| 2279 | a_def 67 13 1 |
| 2280 | a_def 68 13 16 |
| 2281 | a_def 69 13 16 |
| 2282 | a_def 70 14 1 |
| 2283 | a_def 71 14 1 |
| 2284 | a_def 72 15 1 |
| 2285 | a_def 73 15 1 |
| 2286 | a_def 74 16 1 |
| 2287 | a_def 75 17 1 |
| 2288 | a_def 76 17 1 |
| 2289 | a_def 77 18 32 |
| 2290 | a_def 78 18 1 |
| 2291 | a_def 79 18 6 |
| 2292 | a_def 80 18 6 |
| 2293 | a_def 81 19 1 |
| 2294 | a_def 82 19 1 |
| 2295 | a_def 83 19 1 |
| 2296 | a_def 84 19 1 |
| 2297 | a_def 85 20 1 |
| 2298 | note Object-only local stack and call-stack cost: lazy, charged arena groups. |
| 2299 | a_def 86 21 1 |
| 2300 | a_def 87 22 1 |
| 2301 | put a_nr 0 88 |
| 2302 | end |
| 2303 | |
| 2304 | note a_gname: the usage-record label of group g |
| 2305 | fn a_gname g ulong to void |
| 2306 | if eq g 21 |
| 2307 | mputw 474164650607 5 |
| 2308 | ret |
| 2309 | end |
| 2310 | if eq g 22 |
| 2311 | mputw 30518463020294767 7 |
| 2312 | ret |
| 2313 | end |
| 2314 | if eq g 0 |
| 2315 | mputw 7368297 3 |
| 2316 | ret |
| 2317 | end |
| 2318 | if eq g 1 |
| 2319 | mputw 7632239 3 |
| 2320 | ret |
| 2321 | end |
| 2322 | if eq g 2 |
| 2323 | mputw 1702127987 4 |
| 2324 | ret |
| 2325 | end |
| 2326 | if eq g 3 |
| 2327 | mputw 495622906222 5 |
| 2328 | ret |
| 2329 | end |
| 2330 | if eq g 4 |
| 2331 | mputw 7526466503272391022 8 |
| 2332 | ret |
| 2333 | end |
| 2334 | if eq g 5 |
| 2335 | mputw 1735290732 4 |
| 2336 | ret |
| 2337 | end |
| 2338 | if eq g 6 |
| 2339 | mputw 7526466503306014572 8 |
| 2340 | ret |
| 2341 | end |
| 2342 | if eq g 7 |
| 2343 | mputw 7564902 3 |
| 2344 | ret |
| 2345 | end |
| 2346 | if eq g 8 |
| 2347 | mputw 114844764761702 6 |
| 2348 | ret |
| 2349 | end |
| 2350 | if eq g 9 |
| 2351 | mputw 495740281187 5 |
| 2352 | ret |
| 2353 | end |
| 2354 | if eq g 10 |
| 2355 | mputw 495806673524 5 |
| 2356 | ret |
| 2357 | end |
| 2358 | if eq g 11 |
| 2359 | mputw 32198529635465336 7 |
| 2360 | ret |
| 2361 | end |
| 2362 | if eq g 12 |
| 2363 | mputw 32767063113480312 7 |
| 2364 | ret |
| 2365 | end |
| 2366 | if eq g 13 |
| 2367 | mputw 126905066941538 6 |
| 2368 | ret |
| 2369 | end |
| 2370 | if eq g 14 |
| 2371 | mputw 126905032733282 6 |
| 2372 | ret |
| 2373 | end |
| 2374 | if eq g 15 |
| 2375 | mputw 495874633571 5 |
| 2376 | ret |
| 2377 | end |
| 2378 | if eq g 16 |
| 2379 | mputw 127979060227689 6 |
| 2380 | ret |
| 2381 | end |
| 2382 | if eq g 17 |
| 2383 | mputw 28542653543771753 7 |
| 2384 | ret |
| 2385 | end |
| 2386 | if eq g 18 |
| 2387 | mputw 448630121828 5 |
| 2388 | ret |
| 2389 | end |
| 2390 | if eq g 19 |
| 2391 | mputw 121386218053995 6 |
| 2392 | ret |
| 2393 | end |
| 2394 | if eq g 20 |
| 2395 | mputw 7812726533262958955 8 |
| 2396 | ret |
| 2397 | end |
| 2398 | end |
| 2399 | |
| 2400 | note Table accesses are written inline, `get a_ar add get a_rb R i` / `put a_ar add get a_rb R i v`, |
| 2401 | note checked only by a_ar's own length: every index is in its region by construction. A count |
| 2402 | note grows only after a_need has given its group room for it, reads use indices below a count, links |
| 2403 | note omc stored (each below a count) or hash buckets below the bucket count, and input bytes are read |
| 2404 | note from region 0 at word 0, padded with 64 zero bytes (a_rdin). The lines whose registers did not |
| 2405 | note fit inline use the calls below; a_g / a_gu / a_p check the region (a_oob, trap 3), as a_pc, |
| 2406 | note a_bput and a_ib do. gate-nocaps, gate12 and gate-usage drive every group far past its first room. |
| 2407 | note The argument holds only when the count that bounds an index is the count of the region's own group: |
| 2408 | note rscan once read the calls (group 9) at an inline edge's index (group 17), past them once the edges |
| 2409 | note outnumbered the calls' room (trap 3, omc c52e986e and 1e628c80). gate-nocaps step 4 compiles a unit |
| 2410 | note past every group's first room with a checked twin of this file (each inline access the checked call). |
| 2411 | fn a_g r ulong i ulong to ulong |
| 2412 | if ge i get a_rw r |
| 2413 | a_oob i |
| 2414 | end |
| 2415 | ret get a_ar add get a_rb r i |
| 2416 | end |
| 2417 | |
| 2418 | fn a_gu r ulong i ulong to uchar |
| 2419 | if ge i get a_rw r |
| 2420 | a_oob i |
| 2421 | end |
| 2422 | ret uchar get a_ar add get a_rb r i |
| 2423 | end |
| 2424 | |
| 2425 | fn a_p r ulong i ulong v ulong to void |
| 2426 | if ge i get a_rw r |
| 2427 | a_oob i |
| 2428 | end |
| 2429 | put a_ar add get a_rb r i v |
| 2430 | end |
| 2431 | |
| 2432 | |
| 2433 | note mflush: complete a diagnostic/query stdout chunk or report compiler output error 2. |
| 2434 | fn mflush to void |
| 2435 | off = ulong 0 |
| 2436 | n = get mc 0 |
| 2437 | while lt off n |
| 2438 | w = write 1 msg off sub n off |
| 2439 | if le w 0 |
| 2440 | if ne get d2mode 0 0 |
| 2441 | note d2site 623|mflush: standard output refused a diagnostic or query chunk |
| 2442 | put d2site 0 623 |
| 2443 | fail 2 |
| 2444 | end |
| 2445 | exit int 2 |
| 2446 | end |
| 2447 | off = add off ulong w |
| 2448 | end |
| 2449 | put mc 0 0 |
| 2450 | end |
| 2451 | |
| 2452 | fn mputb b uchar to void |
| 2453 | m = get mc 0 |
| 2454 | put msg m b |
| 2455 | put mc 0 add m 1 |
| 2456 | end |
| 2457 | |
| 2458 | fn mputn v ulong to void |
| 2459 | d = new uchar 20 0 |
| 2460 | i = ulong 0 |
| 2461 | x = v |
| 2462 | put d 0 uchar add rem x 10 48 |
| 2463 | x = div x 10 |
| 2464 | i = add i 1 |
| 2465 | while gt x 0 |
| 2466 | put d i uchar add rem x 10 48 |
| 2467 | x = div x 10 |
| 2468 | i = add i 1 |
| 2469 | end |
| 2470 | j = i |
| 2471 | while gt j 0 |
| 2472 | j = sub j 1 |
| 2473 | mputb get d j |
| 2474 | end |
| 2475 | end |
| 2476 | |
| 2477 | note fail: write "omc: line N: error E" to stderr (fd 2) and exit with the code |
| 2478 | fn fail code ulong to void |
| 2479 | put mc 0 0 |
| 2480 | mputb 111 |
| 2481 | mputb 109 |
| 2482 | mputb 99 |
| 2483 | mputb 58 |
| 2484 | mputb 32 |
| 2485 | mputb 108 |
| 2486 | mputb 105 |
| 2487 | mputb 110 |
| 2488 | mputb 101 |
| 2489 | mputb 32 |
| 2490 | mputn add get line 0 get lbase 0 |
| 2491 | mputb 58 |
| 2492 | mputb 32 |
| 2493 | mputb 101 |
| 2494 | mputb 114 |
| 2495 | mputb 114 |
| 2496 | mputb 111 |
| 2497 | mputb 114 |
| 2498 | mputb 32 |
| 2499 | mputn code |
| 2500 | if ne get d2mode 0 0 |
| 2501 | mputb 58 |
| 2502 | mputb 32 |
| 2503 | d2mean code |
| 2504 | mputb 59 |
| 2505 | mputb 32 |
| 2506 | d2reason |
| 2507 | end |
| 2508 | mputb 10 |
| 2509 | w = write 2 msg 0 get mc 0 |
| 2510 | if ne get om2 0 0 |
| 2511 | if eq get om2m 0 1 |
| 2512 | drec code |
| 2513 | end |
| 2514 | end |
| 2515 | if and ge get chkmode 0 1 le get chkmode 0 2 |
| 2516 | note A stdout failure cannot report another record to stdout. |
| 2517 | if ne code 2 |
| 2518 | diagrec code |
| 2519 | end |
| 2520 | end |
| 2521 | if ne get d2mode 0 0 |
| 2522 | d2record code |
| 2523 | end |
| 2524 | note An arena-full error 14, and any error of a usage unit, ends with the omc-use record (a_rec). |
| 2525 | if or ne get a_fl 0 0 eq get chkmode 0 3 |
| 2526 | a_rec 2 |
| 2527 | end |
| 2528 | exit int code |
| 2529 | end |
| 2530 | |
| 2531 | note mputw: the first n bytes (at most 8) of the little-endian packed word w |
| 2532 | fn mputw w ulong n ulong to void |
| 2533 | i = ulong 0 |
| 2534 | x = w |
| 2535 | while lt i n |
| 2536 | mputb uchar and x 255 |
| 2537 | x = shr x 8 |
| 2538 | i = add i 1 |
| 2539 | end |
| 2540 | end |
| 2541 | |
| 2542 | note dcol: the 1-based column of byte a in its line |
| 2543 | fn dcol a ulong to ulong |
| 2544 | j = a |
| 2545 | go = true |
| 2546 | while go |
| 2547 | m = ulong 0 |
| 2548 | while and go lt m 999999 |
| 2549 | if eq j 0 |
| 2550 | go = false |
| 2551 | else |
| 2552 | if eq a_ib sub j 1 10 |
| 2553 | go = false |
| 2554 | else |
| 2555 | j = sub j 1 |
| 2556 | end |
| 2557 | end |
| 2558 | m = add m 1 |
| 2559 | end |
| 2560 | end |
| 2561 | ret add sub a j 1 |
| 2562 | end |
| 2563 | |
| 2564 | note dsev_w: sev= incomplete when the failure is on the end-of-input token (or inside a text literal cut by |
| 2565 | note the end), unknown for an undeclared function or struct, else error |
| 2566 | fn dsev_w code ulong to void |
| 2567 | s = get dsev 0 |
| 2568 | if eq s 0 |
| 2569 | if eq get tk 0 3 |
| 2570 | s = ulong 1 |
| 2571 | end |
| 2572 | if and eq code 22 ge get cur 0 get inlen 0 |
| 2573 | s = ulong 1 |
| 2574 | end |
| 2575 | end |
| 2576 | if eq s 1 |
| 2577 | mputw 7308339910638005865 8 |
| 2578 | mputw 25972 2 |
| 2579 | ret |
| 2580 | end |
| 2581 | if eq s 2 |
| 2582 | mputw 31093567915781749 7 |
| 2583 | ret |
| 2584 | end |
| 2585 | mputw 491496043109 5 |
| 2586 | end |
| 2587 | |
| 2588 | note dexp_w: expect= the class of token being read (end for an open function at the end of the input) |
| 2589 | fn dexp_w code ulong to void |
| 2590 | e = get dexp 0 |
| 2591 | if eq code 15 |
| 2592 | e = ulong 5 |
| 2593 | end |
| 2594 | if or eq code 6 eq code 8 |
| 2595 | e = ulong 4 |
| 2596 | end |
| 2597 | if eq e 1 |
| 2598 | mputw 435761734006 5 |
| 2599 | ret |
| 2600 | end |
| 2601 | if eq e 2 |
| 2602 | mputw 1701869940 4 |
| 2603 | ret |
| 2604 | end |
| 2605 | if eq e 3 |
| 2606 | mputw 1701667182 4 |
| 2607 | ret |
| 2608 | end |
| 2609 | if eq e 4 |
| 2610 | mputw 125779768604014 6 |
| 2611 | ret |
| 2612 | end |
| 2613 | if eq e 5 |
| 2614 | mputw 6581861 3 |
| 2615 | ret |
| 2616 | end |
| 2617 | if eq e 6 |
| 2618 | mputw 28550371718161774 7 |
| 2619 | ret |
| 2620 | end |
| 2621 | mputw 1685221239 4 |
| 2622 | end |
| 2623 | |
| 2624 | note dobl_w: obligation= from the code: 27 init, 28 ctor, 29 layout, 21 bounds, 14 growth, 12 regs, else - |
| 2625 | fn dobl_w code ulong to void |
| 2626 | if eq code 30 |
| 2627 | mputw 8386654075301556067 8 |
| 2628 | ret |
| 2629 | end |
| 2630 | if eq code 27 |
| 2631 | mputw 1953066601 4 |
| 2632 | ret |
| 2633 | end |
| 2634 | if eq code 28 |
| 2635 | mputw 1919906915 4 |
| 2636 | ret |
| 2637 | end |
| 2638 | if eq code 29 |
| 2639 | mputw 128047730221420 6 |
| 2640 | ret |
| 2641 | end |
| 2642 | if eq code 21 |
| 2643 | mputw 126875187113826 6 |
| 2644 | ret |
| 2645 | end |
| 2646 | if and eq code 14 ne get dobx 0 0 |
| 2647 | mputw 1953066601 4 |
| 2648 | ret |
| 2649 | end |
| 2650 | if eq code 14 |
| 2651 | mputw 114849429287527 6 |
| 2652 | ret |
| 2653 | end |
| 2654 | if eq code 12 |
| 2655 | mputw 1936156018 4 |
| 2656 | ret |
| 2657 | end |
| 2658 | mputb 45 |
| 2659 | end |
| 2660 | |
| 2661 | note mputh: one byte as two lowercase hex digits |
| 2662 | fn mputh b ulong to void |
| 2663 | hi = shr b 4 |
| 2664 | lo = and b 15 |
| 2665 | if lt hi 10 |
| 2666 | mputb uchar add hi 48 |
| 2667 | else |
| 2668 | mputb uchar add hi 87 |
| 2669 | end |
| 2670 | if lt lo 10 |
| 2671 | mputb uchar add lo 48 |
| 2672 | else |
| 2673 | mputb uchar add lo 87 |
| 2674 | end |
| 2675 | end |
| 2676 | |
| 2677 | note drec: the om2 diag machine record after the human line (spec 1): code, sev, line (the human line), |
| 2678 | note col, the half-open byte span of the token being read, expect, found (at most 32 bytes, hex), |
| 2679 | note obligation, profile |
| 2680 | fn drec code ulong to void |
| 2681 | put mc 0 0 |
| 2682 | mputw 7449351137626647919 8 |
| 2683 | mputw 4424052638528581920 8 |
| 2684 | mputn code |
| 2685 | mputw 263979365152 5 |
| 2686 | dsev_w code |
| 2687 | mputw 67505853393952 6 |
| 2688 | mputn add get line 0 get lbase 0 |
| 2689 | a = get tka 0 |
| 2690 | b = get tkb 0 |
| 2691 | if le b a |
| 2692 | b = a |
| 2693 | if gt get cur 0 a |
| 2694 | b = get cur 0 |
| 2695 | end |
| 2696 | end |
| 2697 | if gt b get inlen 0 |
| 2698 | b = get inlen 0 |
| 2699 | end |
| 2700 | mputw 263812244256 5 |
| 2701 | mputn dcol a |
| 2702 | mputw 67544290456352 6 |
| 2703 | mputn add a get sbase 0 |
| 2704 | mputb 45 |
| 2705 | mputn add b get sbase 0 |
| 2706 | mputw 4428273620941825312 8 |
| 2707 | dexp_w code |
| 2708 | mputw 17280399158765088 7 |
| 2709 | if eq a b |
| 2710 | mputb 45 |
| 2711 | end |
| 2712 | i = a |
| 2713 | while and lt i b lt sub i a 32 |
| 2714 | mputh ulong uchar and shr get a_ar shr i 3 shl and i 7 3 255 |
| 2715 | i = add i 1 |
| 2716 | end |
| 2717 | mputw 8386097683628191520 8 |
| 2718 | mputw 1030647657 4 |
| 2719 | dobl_w code |
| 2720 | mputw 7308332183992823840 8 |
| 2721 | mputw 11210624683837 6 |
| 2722 | w = write 2 msg 0 get mc 0 |
| 2723 | end |
| 2724 | |
| 2725 | note emitb / emit: one byte / one 32-bit word (little-endian) to the output (region 1, eight bytes to a |
| 2726 | note word). The output grows with the arena (a_ogrow); there is no per-function budget: the OM-2 65536-word |
| 2727 | note bound is gone, and a long function keeps its trap branches in reach through stub islands (island). |
| 2728 | fn emitb b uchar to void |
| 2729 | o = get oc 0 |
| 2730 | if ge o get a_gc 1 |
| 2731 | a_ogrow o |
| 2732 | end |
| 2733 | x = add get a_rb 1 shr o 3 |
| 2734 | s = shl and o 7 3 |
| 2735 | y = get a_ar x |
| 2736 | y = and y not shl ulong 255 s |
| 2737 | y = or y shl ulong b s |
| 2738 | put a_ar x y |
| 2739 | put oc 0 add o 1 |
| 2740 | end |
| 2741 | |
| 2742 | fn emit w ulong to void |
| 2743 | if ne get xtarget 0 0 |
| 2744 | note d2site 8|emit: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if ne get xtarget 0 0 |
| 2745 | put d2site 0 8 |
| 2746 | fail 25 |
| 2747 | end |
| 2748 | o = get oc 0 |
| 2749 | if ne and o 3 0 |
| 2750 | emitb uchar and w 255 |
| 2751 | emitb uchar and shr w 8 255 |
| 2752 | emitb uchar and shr w 16 255 |
| 2753 | emitb uchar and shr w 24 255 |
| 2754 | ret |
| 2755 | end |
| 2756 | if ge add o 3 get a_gc 1 |
| 2757 | a_ogrow add o 3 |
| 2758 | end |
| 2759 | x = add get a_rb 1 shr o 3 |
| 2760 | s = shl and o 4 3 |
| 2761 | y = get a_ar x |
| 2762 | y = and y not shl ulong 4294967295 s |
| 2763 | y = or y shl and w 4294967295 s |
| 2764 | put a_ar x y |
| 2765 | put oc 0 add o 4 |
| 2766 | end |
| 2767 | |
| 2768 | note a_ogrow: the output will hold byte o. Two machine boundaries, each error 14 at its first byte, never a |
| 2769 | note table's: AArch64 output stops at 134217728 bytes, the reach of B and BL (imm26, 2^27 bytes), so every |
| 2770 | note call and jump of a unit stays encodable and bdisp's error 24 for them stays a defence (security673 |
| 2771 | note gate669 probes 16 and 17); x86 code is mapped from 0x400000 below the pools at 0x10000000, so its |
| 2772 | note output ends at byte 264241152. |
| 2773 | fn a_ogrow o ulong to void |
| 2774 | lim = ulong 264241152 |
| 2775 | if eq get xtarget 0 0 |
| 2776 | lim = ulong 134217728 |
| 2777 | end |
| 2778 | note Non-executable object metadata has no instruction-displacement bound; allocation is checked. |
| 2779 | if ne get objmeta 0 0 |
| 2780 | lim = ulong 9223372036854775807 |
| 2781 | end |
| 2782 | if ge o lim |
| 2783 | note d2site 9|a_ogrow: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge o lim |
| 2784 | put d2site 0 9 |
| 2785 | fail 14 |
| 2786 | end |
| 2787 | if ge o get a_gp 1 |
| 2788 | a_need 1 o |
| 2789 | end |
| 2790 | end |
| 2791 | |
| 2792 | note tok_num: the word at [ts,cur) is [-]decimal, at most 20 digits, from -2^63 to 2^64 - 1 (error 6 |
| 2793 | note bad number, 8 out of range). tw = its raw 64 bits (a negative one as two's complement); tbig = 1 |
| 2794 | note when it is 2^63 or more (only a ulong holds it), else 0. As om4's TK_NUM. |
| 2795 | note The float-marker scan walks the word in chunks of at most 999999 bytes: a single loop's hidden |
| 2796 | note 1000000-pass guard trapped 4 on a decimal word of 1000001 digits, which must refuse with error 6 (#671). |
| 2797 | fn tok_num to void |
| 2798 | if ne get om2 0 0 |
| 2799 | if ne tok_hex 0 |
| 2800 | ret |
| 2801 | end |
| 2802 | end |
| 2803 | p = get ts 0 |
| 2804 | e = get cur 0 |
| 2805 | fl = false |
| 2806 | i = p |
| 2807 | while lt i e |
| 2808 | c = sub e i |
| 2809 | if gt c 999999 |
| 2810 | c = ulong 999999 |
| 2811 | end |
| 2812 | for k ulong c |
| 2813 | b = a_ib add i k |
| 2814 | if or or or eq b 46 eq b 101 eq b 69 eq b 102 |
| 2815 | fl = true |
| 2816 | end |
| 2817 | end |
| 2818 | i = add i c |
| 2819 | end |
| 2820 | if fl |
| 2821 | put tk 0 5 |
| 2822 | ret |
| 2823 | end |
| 2824 | minus = false |
| 2825 | if eq uchar and shr get a_ar shr p 3 shl and p 7 3 255 45 |
| 2826 | minus = true |
| 2827 | p = add p 1 |
| 2828 | end |
| 2829 | ndig = sub e p |
| 2830 | if eq ndig 0 |
| 2831 | note d2site 10|tok_num: malformed number or token; condition if eq ndig 0 |
| 2832 | put d2site 0 10 |
| 2833 | nfail 6 |
| 2834 | end |
| 2835 | if gt ndig 20 |
| 2836 | note d2site 11|tok_num: malformed number or token; condition if gt ndig 20 |
| 2837 | put d2site 0 11 |
| 2838 | nfail 6 |
| 2839 | end |
| 2840 | v = ulong 0 |
| 2841 | lim = ulong 1844674407370955161 |
| 2842 | i = p |
| 2843 | while lt i e |
| 2844 | d = sub ulong a_ib i 48 |
| 2845 | if gt d 9 |
| 2846 | note d2site 12|tok_num: malformed number or token; condition if gt d 9 |
| 2847 | put d2site 0 12 |
| 2848 | nfail 6 |
| 2849 | end |
| 2850 | if gt v lim |
| 2851 | note d2site 13|tok_num: number out of range for its type or place; condition if gt v lim |
| 2852 | put d2site 0 13 |
| 2853 | nfail 8 |
| 2854 | end |
| 2855 | if and eq v lim gt d 5 |
| 2856 | note d2site 14|tok_num: number out of range for its type or place; condition if and eq v lim gt d 5 |
| 2857 | put d2site 0 14 |
| 2858 | nfail 8 |
| 2859 | end |
| 2860 | v = add mul v 10 d |
| 2861 | i = add i 1 |
| 2862 | end |
| 2863 | half = shl ulong 1 63 |
| 2864 | put tbig 0 0 |
| 2865 | if minus |
| 2866 | if gt v half |
| 2867 | note d2site 15|tok_num: number out of range for its type or place; condition if gt v half |
| 2868 | put d2site 0 15 |
| 2869 | nfail 8 |
| 2870 | end |
| 2871 | put tw 0 sub ulong 0 v |
| 2872 | else |
| 2873 | if ge v half |
| 2874 | put tbig 0 1 |
| 2875 | end |
| 2876 | put tw 0 v |
| 2877 | end |
| 2878 | put tk 0 2 |
| 2879 | end |
| 2880 | |
| 2881 | note tok_text: a text literal starting at the opening quote. tw = first byte offset, tl = source length |
| 2882 | note (escapes not yet decoded). Ends at an unescaped '"' on the same line, followed by a blank/end. Err 22. |
| 2883 | note (Loops over the input are two loops, the inner under 1000000 passes: om4 has no pass limit.) |
| 2884 | fn tok_text to void |
| 2885 | put cur 0 add get cur 0 1 |
| 2886 | put tw 0 get cur 0 |
| 2887 | go = true |
| 2888 | while go |
| 2889 | n = ulong 0 |
| 2890 | while and go lt n 999999 |
| 2891 | if ge get cur 0 get inlen 0 |
| 2892 | note d2site 16|tok_text: malformed text literal; condition if ge get cur 0 get inlen 0 |
| 2893 | put d2site 0 16 |
| 2894 | fail 22 |
| 2895 | end |
| 2896 | b = a_ib get cur 0 |
| 2897 | if eq b 10 |
| 2898 | note d2site 17|tok_text: malformed text literal; condition if eq b 10 |
| 2899 | put d2site 0 17 |
| 2900 | fail 22 |
| 2901 | end |
| 2902 | if eq b 34 |
| 2903 | go = false |
| 2904 | else |
| 2905 | put cur 0 add get cur 0 1 |
| 2906 | if eq b 92 |
| 2907 | if ge get cur 0 get inlen 0 |
| 2908 | note d2site 18|tok_text: malformed text literal; condition if ge get cur 0 get inlen 0 |
| 2909 | put d2site 0 18 |
| 2910 | fail 22 |
| 2911 | end |
| 2912 | if eq a_ib get cur 0 10 |
| 2913 | note d2site 19|tok_text: malformed text literal; condition if eq a_ib get cur 0 10 |
| 2914 | put d2site 0 19 |
| 2915 | fail 22 |
| 2916 | end |
| 2917 | put cur 0 add get cur 0 1 |
| 2918 | end |
| 2919 | end |
| 2920 | n = add n 1 |
| 2921 | end |
| 2922 | end |
| 2923 | put tl 0 sub get cur 0 get tw 0 |
| 2924 | put cur 0 add get cur 0 1 |
| 2925 | put tk 0 4 |
| 2926 | if lt get cur 0 get inlen 0 |
| 2927 | if gt a_ib get cur 0 32 |
| 2928 | note d2site 20|tok_text: malformed text literal; condition if gt a_ib get cur 0 32 |
| 2929 | put d2site 0 20 |
| 2930 | fail 22 |
| 2931 | end |
| 2932 | end |
| 2933 | end |
| 2934 | |
| 2935 | note tok2: a word at cur with first byte c; packs 8 bytes into tw, sets tl and ts. A '"' is a text; a |
| 2936 | note first byte '-' or a digit is a number. |
| 2937 | fn tok2 c uchar to void |
| 2938 | if eq c 34 |
| 2939 | tok_text |
| 2940 | ret |
| 2941 | end |
| 2942 | put ts 0 get cur 0 |
| 2943 | if or eq c 40 eq c 41 |
| 2944 | put tw 0 ulong c |
| 2945 | put tl 0 1 |
| 2946 | put cur 0 add get cur 0 1 |
| 2947 | put tk 0 1 |
| 2948 | ret |
| 2949 | end |
| 2950 | w = ulong 0 |
| 2951 | sh = ulong 0 |
| 2952 | n = ulong 0 |
| 2953 | go = true |
| 2954 | while go |
| 2955 | m = ulong 0 |
| 2956 | while and go lt m 999999 |
| 2957 | if ge get cur 0 get inlen 0 |
| 2958 | go = false |
| 2959 | else |
| 2960 | b = a_ib get cur 0 |
| 2961 | if le b 32 |
| 2962 | go = false |
| 2963 | else |
| 2964 | if or eq b 40 eq b 41 |
| 2965 | go = false |
| 2966 | else |
| 2967 | if lt n 8 |
| 2968 | w = or w shl ulong b sh |
| 2969 | sh = add sh 8 |
| 2970 | end |
| 2971 | n = add n 1 |
| 2972 | put cur 0 add get cur 0 1 |
| 2973 | end |
| 2974 | end |
| 2975 | end |
| 2976 | m = add m 1 |
| 2977 | end |
| 2978 | end |
| 2979 | put tw 0 w |
| 2980 | put tl 0 n |
| 2981 | put tw8 0 w |
| 2982 | if and gt n 8 le n 63 |
| 2983 | if ne c 45 |
| 2984 | if or lt c 48 gt c 57 |
| 2985 | note intern the long name (the long-names notes above the name table): its index from ln_intern |
| 2986 | put tw 0 add 1 shl ln_intern get ts 0 n 8 |
| 2987 | end |
| 2988 | end |
| 2989 | end |
| 2990 | f = a_ib get ts 0 |
| 2991 | isnum = false |
| 2992 | if eq f 45 |
| 2993 | isnum = true |
| 2994 | end |
| 2995 | if and ge f 48 le f 57 |
| 2996 | isnum = true |
| 2997 | end |
| 2998 | if isnum |
| 2999 | tok_num |
| 3000 | else |
| 3001 | put tk 0 1 |
| 3002 | end |
| 3003 | end |
| 3004 | |
| 3005 | note tok: next word, skipping blanks (space, tab, carriage return); newline is end of line (kind 0) and |
| 3006 | note bumps the line number; another byte below 32 is error 16; the end of the input is kind 3. om4 TOK. |
| 3007 | fn tok to void |
| 3008 | go = true |
| 3009 | while go |
| 3010 | n = ulong 0 |
| 3011 | while and go lt n 999999 |
| 3012 | if ge get cur 0 get inlen 0 |
| 3013 | go = false |
| 3014 | else |
| 3015 | c = a_ib get cur 0 |
| 3016 | if or or eq c 32 eq c 9 eq c 13 |
| 3017 | put cur 0 add get cur 0 1 |
| 3018 | else |
| 3019 | if eq c 10 |
| 3020 | put tka 0 get cur 0 |
| 3021 | put tkb 0 add get cur 0 1 |
| 3022 | put cur 0 add get cur 0 1 |
| 3023 | put line 0 add get line 0 1 |
| 3024 | put tk 0 0 |
| 3025 | ret |
| 3026 | end |
| 3027 | put tka 0 get cur 0 |
| 3028 | put tkb 0 add get cur 0 1 |
| 3029 | if lt c 32 |
| 3030 | note d2site 21|tok: syntax: unknown or misplaced word; condition if lt c 32 |
| 3031 | put d2site 0 21 |
| 3032 | fail 16 |
| 3033 | end |
| 3034 | put tka 0 get cur 0 |
| 3035 | put tkb 0 get cur 0 |
| 3036 | tok2 c |
| 3037 | put tkb 0 get cur 0 |
| 3038 | ret |
| 3039 | end |
| 3040 | end |
| 3041 | n = add n 1 |
| 3042 | end |
| 3043 | end |
| 3044 | put tka 0 get inlen 0 |
| 3045 | put tkb 0 get inlen 0 |
| 3046 | put tk 0 3 |
| 3047 | end |
| 3048 | |
| 3049 | note ======== keyword lookup (original om4 KWTAB plus native host words 100..177, flock 197, execpure 198, execenv 233, prlimit 235 and cpuset..getprio 236..240) ======== |
| 3050 | note genkw.awk describes the original om4 table only; retain the native host extension on regeneration. |
| 3051 | note efi (178) is a keyword only under `target x86efi`; gate18 checks that scoped entry separately. |
| 3052 | note kwa: the words of target a64efi, 0 for any other word: efi (178) and the firmware words fwcall 250, |
| 3053 | note fwld 251, fwst 252, fwsys 253, fwadr 254. They are not in fn kw (the chain gate18 compares with |
| 3054 | note genkw.awk), so under every other target these stay ordinary names. Read where a value starts. |
| 3055 | fn kwa w ulong to ulong |
| 3056 | if eq w 6907493 |
| 3057 | ret 178 |
| 3058 | end |
| 3059 | if eq w 119212746176358 |
| 3060 | ret 250 |
| 3061 | end |
| 3062 | if eq w 1684830054 |
| 3063 | ret 251 |
| 3064 | end |
| 3065 | if eq w 1953724262 |
| 3066 | ret 252 |
| 3067 | end |
| 3068 | if eq w 495958849382 |
| 3069 | ret 253 |
| 3070 | end |
| 3071 | if eq w 491310380902 |
| 3072 | ret 254 |
| 3073 | end |
| 3074 | if eq w 1886353254 |
| 3075 | ret 255 |
| 3076 | end |
| 3077 | ret 0 |
| 3078 | end |
| 3079 | |
| 3080 | note kwx: w is reserved under the current target beyond fn kw's chain: under target a64efi the words of |
| 3081 | note fn kwa. A program may not define a variable, a global, a constant, a text or a function with such |
| 3082 | note a name (error 16, as for a keyword; checked where every name is entered, newname and addname): where |
| 3083 | note a value starts the word would win and the name be ignored. |
| 3084 | fn kwx w ulong to ulong |
| 3085 | if eq get xefa 0 0 |
| 3086 | ret 0 |
| 3087 | end |
| 3088 | ret kwa w |
| 3089 | end |
| 3090 | |
| 3091 | fn kw w ulong to ulong |
| 3092 | if and eq w 6907493 eq get xtarget 0 2 |
| 3093 | ret 178 |
| 3094 | end |
| 3095 | if eq w 7310034270740117605 |
| 3096 | ret 198 |
| 3097 | end |
| 3098 | if eq w 6584163 |
| 3099 | ret 132 |
| 3100 | end |
| 3101 | packed = or ulong 114 shl ulong 101 8 |
| 3102 | packed = or packed shl ulong 97 16 |
| 3103 | packed = or packed shl ulong 100 24 |
| 3104 | packed = or packed shl ulong 108 32 |
| 3105 | packed = or packed shl ulong 110 40 |
| 3106 | packed = or packed shl ulong 107 48 |
| 3107 | if eq w packed |
| 3108 | ret 133 |
| 3109 | end |
| 3110 | packed = or ulong 115 shl ulong 111 8 |
| 3111 | packed = or packed shl ulong 99 16 |
| 3112 | packed = or packed shl ulong 107 24 |
| 3113 | packed = or packed shl ulong 111 32 |
| 3114 | packed = or packed shl ulong 112 40 |
| 3115 | packed = or packed shl ulong 116 48 |
| 3116 | if eq w packed |
| 3117 | ret 134 |
| 3118 | end |
| 3119 | if eq w 120325193752946 |
| 3120 | ret 135 |
| 3121 | end |
| 3122 | if eq w 128017463930469 |
| 3123 | ret 136 |
| 3124 | end |
| 3125 | if eq w 28254586011020901 |
| 3126 | ret 137 |
| 3127 | end |
| 3128 | if eq w 491394459747 |
| 3129 | ret 138 |
| 3130 | end |
| 3131 | if eq w 109326067987558 |
| 3132 | ret 139 |
| 3133 | end |
| 3134 | if eq w 1952543859 |
| 3135 | ret 140 |
| 3136 | end |
| 3137 | if eq w 1802398060 |
| 3138 | ret 141 |
| 3139 | end |
| 3140 | if eq w 118122009688435 |
| 3141 | ret 142 |
| 3142 | end |
| 3143 | if eq w 431366170723 |
| 3144 | ret 143 |
| 3145 | end |
| 3146 | if eq w 32496501618073958 |
| 3147 | ret 144 |
| 3148 | end |
| 3149 | if eq w 110404104906087 |
| 3150 | ret 145 |
| 3151 | end |
| 3152 | if eq w 28263450605282663 |
| 3153 | ret 146 |
| 3154 | end |
| 3155 | if eq w 110403870025063 |
| 3156 | ret 147 |
| 3157 | end |
| 3158 | if eq w 28263390475740519 |
| 3159 | ret 148 |
| 3160 | end |
| 3161 | if eq w 499851228012 |
| 3162 | ret 149 |
| 3163 | end |
| 3164 | if eq w 7310575174812004980 |
| 3165 | ret 150 |
| 3166 | end |
| 3167 | if eq w 474450192483 |
| 3168 | ret 151 |
| 3169 | end |
| 3170 | if eq w 500152823651 |
| 3171 | ret 152 |
| 3172 | end |
| 3173 | if eq w 125796981695334 |
| 3174 | ret 153 |
| 3175 | end |
| 3176 | if eq w 28263429314995559 |
| 3177 | ret 154 |
| 3178 | end |
| 3179 | if eq w 461497265525 |
| 3180 | ret 155 |
| 3181 | end |
| 3182 | if eq w 109326135157862 |
| 3183 | ret 156 |
| 3184 | end |
| 3185 | if eq w 431215175021 |
| 3186 | ret 157 |
| 3187 | end |
| 3188 | if eq w 110404071351667 |
| 3189 | ret 158 |
| 3190 | end |
| 3191 | if eq w 28263390660289895 |
| 3192 | ret 159 |
| 3193 | end |
| 3194 | if eq w 28263390660289907 |
| 3195 | ret 160 |
| 3196 | end |
| 3197 | if eq w 431130767984 |
| 3198 | ret 161 |
| 3199 | end |
| 3200 | if eq w 111550659721072 |
| 3201 | ret 162 |
| 3202 | end |
| 3203 | if eq w 110404071351655 |
| 3204 | ret 163 |
| 3205 | end |
| 3206 | if eq w 126883592042867 |
| 3207 | ret 164 |
| 3208 | end |
| 3209 | if eq w 7959953343641905267 |
| 3210 | ret 165 |
| 3211 | end |
| 3212 | if eq w 119247140709732 |
| 3213 | ret 166 |
| 3214 | end |
| 3215 | if eq w 131277528260973 |
| 3216 | ret 167 |
| 3217 | end |
| 3218 | if eq w 31647734493634925 |
| 3219 | ret 168 |
| 3220 | end |
| 3221 | if eq w 28254586010624365 |
| 3222 | ret 169 |
| 3223 | end |
| 3224 | if eq w 7310584035480199533 |
| 3225 | ret 170 |
| 3226 | end |
| 3227 | if eq w 30518463021081956 |
| 3228 | ret 171 |
| 3229 | end |
| 3230 | if eq w 119247140124277 |
| 3231 | ret 172 |
| 3232 | end |
| 3233 | if eq w 32198529639276909 |
| 3234 | ret 173 |
| 3235 | end |
| 3236 | if eq w 127978875937133 |
| 3237 | ret 174 |
| 3238 | end |
| 3239 | if eq w 127979077263725 |
| 3240 | ret 175 |
| 3241 | end |
| 3242 | if eq w 28266723420430701 |
| 3243 | ret 176 |
| 3244 | end |
| 3245 | if eq w 28268896573219181 |
| 3246 | ret 177 |
| 3247 | end |
| 3248 | if eq w 30527267904513654 |
| 3249 | ret 228 |
| 3250 | end |
| 3251 | if eq w 31632320040101494 |
| 3252 | ret 229 |
| 3253 | end |
| 3254 | if eq w 8606486010553525878 |
| 3255 | ret 230 |
| 3256 | end |
| 3257 | if eq w 28260147925448293 |
| 3258 | ret 231 |
| 3259 | end |
| 3260 | if eq w 31932469534615158 |
| 3261 | ret 232 |
| 3262 | end |
| 3263 | if eq w 32767015939502704 |
| 3264 | ret 235 |
| 3265 | end |
| 3266 | if eq w 127979077595235 |
| 3267 | ret 236 |
| 3268 | end |
| 3269 | if eq w 127978876268643 |
| 3270 | ret 237 |
| 3271 | end |
| 3272 | if eq w 131320478265443 |
| 3273 | ret 238 |
| 3274 | end |
| 3275 | if eq w 31359662648747379 |
| 3276 | ret 239 |
| 3277 | end |
| 3278 | if eq w 31359662648747367 |
| 3279 | ret 240 |
| 3280 | end |
| 3281 | if eq w 119247139530347 |
| 3282 | ret 241 |
| 3283 | end |
| 3284 | if eq w 123563749434987 |
| 3285 | ret 242 |
| 3286 | end |
| 3287 | if eq w 126879548073579 |
| 3288 | ret 243 |
| 3289 | end |
| 3290 | if eq w 461229747302 |
| 3291 | ret 197 |
| 3292 | end |
| 3293 | if eq w 1819242338 |
| 3294 | ret 1 |
| 3295 | end |
| 3296 | if eq w 491260502901 |
| 3297 | ret 2 |
| 3298 | end |
| 3299 | if eq w 14453 |
| 3300 | ret 2 |
| 3301 | end |
| 3302 | if eq w 128034844210037 |
| 3303 | ret 3 |
| 3304 | end |
| 3305 | if eq w 3551605 |
| 3306 | ret 3 |
| 3307 | end |
| 3308 | if eq w 1953393013 |
| 3309 | ret 4 |
| 3310 | end |
| 3311 | if eq w 3289973 |
| 3312 | ret 4 |
| 3313 | end |
| 3314 | if eq w 444234427509 |
| 3315 | ret 5 |
| 3316 | end |
| 3317 | if eq w 3421813 |
| 3318 | ret 5 |
| 3319 | end |
| 3320 | if eq w 1702132066 |
| 3321 | ret 6 |
| 3322 | end |
| 3323 | if eq w 14441 |
| 3324 | ret 6 |
| 3325 | end |
| 3326 | if eq w 500136110195 |
| 3327 | ret 7 |
| 3328 | end |
| 3329 | if eq w 3551593 |
| 3330 | ret 7 |
| 3331 | end |
| 3332 | if eq w 7630441 |
| 3333 | ret 8 |
| 3334 | end |
| 3335 | if eq w 3289961 |
| 3336 | ret 8 |
| 3337 | end |
| 3338 | if eq w 1735290732 |
| 3339 | ret 9 |
| 3340 | end |
| 3341 | if eq w 3421801 |
| 3342 | ret 9 |
| 3343 | end |
| 3344 | if eq w 6579297 |
| 3345 | ret 33 |
| 3346 | end |
| 3347 | if eq w 6452595 |
| 3348 | ret 34 |
| 3349 | end |
| 3350 | if eq w 7107949 |
| 3351 | ret 35 |
| 3352 | end |
| 3353 | if eq w 7760228 |
| 3354 | ret 36 |
| 3355 | end |
| 3356 | if eq w 7169394 |
| 3357 | ret 37 |
| 3358 | end |
| 3359 | if eq w 6581857 |
| 3360 | ret 38 |
| 3361 | end |
| 3362 | if eq w 29295 |
| 3363 | ret 39 |
| 3364 | end |
| 3365 | if eq w 7499640 |
| 3366 | ret 40 |
| 3367 | end |
| 3368 | if eq w 7104627 |
| 3369 | ret 41 |
| 3370 | end |
| 3371 | if eq w 7497843 |
| 3372 | ret 42 |
| 3373 | end |
| 3374 | if eq w 29029 |
| 3375 | ret 43 |
| 3376 | end |
| 3377 | if eq w 25966 |
| 3378 | ret 44 |
| 3379 | end |
| 3380 | if eq w 29804 |
| 3381 | ret 45 |
| 3382 | end |
| 3383 | if eq w 25964 |
| 3384 | ret 46 |
| 3385 | end |
| 3386 | if eq w 29799 |
| 3387 | ret 47 |
| 3388 | end |
| 3389 | if eq w 25959 |
| 3390 | ret 48 |
| 3391 | end |
| 3392 | if eq w 6776174 |
| 3393 | ret 49 |
| 3394 | end |
| 3395 | if eq w 7630702 |
| 3396 | ret 50 |
| 3397 | end |
| 3398 | if eq w 7628135 |
| 3399 | ret 51 |
| 3400 | end |
| 3401 | if eq w 7234924 |
| 3402 | ret 52 |
| 3403 | end |
| 3404 | if eq w 1684104562 |
| 3405 | ret 53 |
| 3406 | end |
| 3407 | if eq w 435744764535 |
| 3408 | ret 54 |
| 3409 | end |
| 3410 | if eq w 1702195828 |
| 3411 | ret 55 |
| 3412 | end |
| 3413 | if eq w 435728179558 |
| 3414 | ret 56 |
| 3415 | end |
| 3416 | if eq w 2003134838 |
| 3417 | ret 57 |
| 3418 | end |
| 3419 | if eq w 1953064037 |
| 3420 | ret 58 |
| 3421 | end |
| 3422 | if eq w 28262 |
| 3423 | ret 64 |
| 3424 | end |
| 3425 | if eq w 28532 |
| 3426 | ret 65 |
| 3427 | end |
| 3428 | if eq w 6581861 |
| 3429 | ret 66 |
| 3430 | end |
| 3431 | if eq w 26217 |
| 3432 | ret 67 |
| 3433 | end |
| 3434 | if eq w 1702063205 |
| 3435 | ret 68 |
| 3436 | end |
| 3437 | if eq w 435610544247 |
| 3438 | ret 69 |
| 3439 | end |
| 3440 | if eq w 431349919586 |
| 3441 | ret 70 |
| 3442 | end |
| 3443 | if eq w 7499622 |
| 3444 | ret 71 |
| 3445 | end |
| 3446 | if eq w 7628146 |
| 3447 | ret 72 |
| 3448 | end |
| 3449 | if eq w 61 |
| 3450 | ret 73 |
| 3451 | end |
| 3452 | if eq w 40 |
| 3453 | ret 74 |
| 3454 | end |
| 3455 | if eq w 41 |
| 3456 | ret 75 |
| 3457 | end |
| 3458 | if eq w 1684631414 |
| 3459 | ret 76 |
| 3460 | end |
| 3461 | if eq w 119165519096935 |
| 3462 | ret 78 |
| 3463 | end |
| 3464 | if eq w 1954047348 |
| 3465 | ret 79 |
| 3466 | end |
| 3467 | if eq w 7632240 |
| 3468 | ret 80 |
| 3469 | end |
| 3470 | if eq w 1701147238 |
| 3471 | ret 81 |
| 3472 | end |
| 3473 | if eq w 1953069157 |
| 3474 | ret 82 |
| 3475 | end |
| 3476 | if eq w 1702129518 |
| 3477 | ret 83 |
| 3478 | end |
| 3479 | if eq w 7824750 |
| 3480 | ret 84 |
| 3481 | end |
| 3482 | if eq w 461195539042 |
| 3483 | ret 86 |
| 3484 | end |
| 3485 | if eq w 1885434484 |
| 3486 | ret 87 |
| 3487 | end |
| 3488 | if eq w 7239535 |
| 3489 | ret 77 |
| 3490 | end |
| 3491 | if eq w 7308604897168158579 |
| 3492 | ret 131 |
| 3493 | end |
| 3494 | if eq w 126918101919090 |
| 3495 | ret 130 |
| 3496 | end |
| 3497 | if eq w 7453301735350958181 |
| 3498 | ret 124 |
| 3499 | end |
| 3500 | if eq w 32481142782190962 |
| 3501 | ret 125 |
| 3502 | end |
| 3503 | if eq w 491394461042 |
| 3504 | ret 126 |
| 3505 | end |
| 3506 | if eq w 28263429247363435 |
| 3507 | ret 127 |
| 3508 | end |
| 3509 | if eq w 32480013273033072 |
| 3510 | ret 128 |
| 3511 | end |
| 3512 | if eq w 110404021020007 |
| 3513 | ret 129 |
| 3514 | end |
| 3515 | if eq w 122498715312503 |
| 3516 | ret 123 |
| 3517 | end |
| 3518 | if eq w 32497639802299751 |
| 3519 | ret 113 |
| 3520 | end |
| 3521 | if eq w 32760384594014051 |
| 3522 | ret 114 |
| 3523 | end |
| 3524 | if eq w 1684957538 |
| 3525 | ret 115 |
| 3526 | end |
| 3527 | if eq w 28263429381382519 |
| 3528 | ret 116 |
| 3529 | end |
| 3530 | if eq w 499851228006 |
| 3531 | ret 117 |
| 3532 | end |
| 3533 | if eq w 1986225522 |
| 3534 | ret 118 |
| 3535 | end |
| 3536 | if eq w 1684956531 |
| 3537 | ret 119 |
| 3538 | end |
| 3539 | if eq w 32491051338263667 |
| 3540 | ret 120 |
| 3541 | end |
| 3542 | if eq w 128017462948449 |
| 3543 | ret 121 |
| 3544 | end |
| 3545 | if eq w 28254586010038881 |
| 3546 | ret 122 |
| 3547 | end |
| 3548 | if eq w 111546465018726 |
| 3549 | ret 100 |
| 3550 | end |
| 3551 | if eq w 427055215462 |
| 3552 | ret 101 |
| 3553 | end |
| 3554 | if eq w 110429739705190 |
| 3555 | ret 102 |
| 3556 | end |
| 3557 | if eq w 461262648166 |
| 3558 | ret 103 |
| 3559 | end |
| 3560 | if eq w 33607047151054707 |
| 3561 | ret 104 |
| 3562 | end |
| 3563 | if eq w 121382024472940 |
| 3564 | ret 105 |
| 3565 | end |
| 3566 | if eq w 128026086171489 |
| 3567 | ret 106 |
| 3568 | end |
| 3569 | if eq w 1802661734 |
| 3570 | ret 107 |
| 3571 | end |
| 3572 | if eq w 431215375716 |
| 3573 | ret 108 |
| 3574 | end |
| 3575 | if eq w 126918153105261 |
| 3576 | ret 109 |
| 3577 | end |
| 3578 | if eq w 474148269926 |
| 3579 | ret 110 |
| 3580 | end |
| 3581 | if eq w 118121959288437 |
| 3582 | ret 111 |
| 3583 | end |
| 3584 | if eq w 32204027264196973 |
| 3585 | ret 112 |
| 3586 | end |
| 3587 | if eq w 127970521019507 |
| 3588 | ret 85 |
| 3589 | end |
| 3590 | if eq w 3289958 |
| 3591 | ret 88 |
| 3592 | end |
| 3593 | if eq w 3421798 |
| 3594 | ret 89 |
| 3595 | end |
| 3596 | if eq w 32777959416031586 |
| 3597 | ret 90 |
| 3598 | end |
| 3599 | if eq w 500136244070 |
| 3600 | ret 91 |
| 3601 | end |
| 3602 | if eq w 1935827302 |
| 3603 | ret 92 |
| 3604 | end |
| 3605 | if eq w 1852403046 |
| 3606 | ret 93 |
| 3607 | end |
| 3608 | if eq w 2019650918 |
| 3609 | ret 94 |
| 3610 | end |
| 3611 | if eq w 112628629924211 |
| 3612 | ret 95 |
| 3613 | end |
| 3614 | if eq w 7381246293360141935 |
| 3615 | ret 96 |
| 3616 | end |
| 3617 | if eq w 7310870969309884259 |
| 3618 | ret 97 |
| 3619 | end |
| 3620 | if eq w 7234314147887146352 |
| 3621 | ret 220 |
| 3622 | end |
| 3623 | if eq w 32480013390212976 |
| 3624 | ret 221 |
| 3625 | end |
| 3626 | if eq w 29118836274783603 |
| 3627 | ret 222 |
| 3628 | end |
| 3629 | if eq w 7959665 |
| 3630 | ret 223 |
| 3631 | end |
| 3632 | if eq w 7305804402314801251 |
| 3633 | ret 199 |
| 3634 | end |
| 3635 | if eq w 8674333540260081763 |
| 3636 | ret 200 |
| 3637 | end |
| 3638 | if eq w 7308604897285727600 |
| 3639 | ret 224 |
| 3640 | end |
| 3641 | if eq w 6384998 |
| 3642 | ret 227 |
| 3643 | end |
| 3644 | if eq w 33335428990204005 |
| 3645 | ret 233 |
| 3646 | end |
| 3647 | if eq w 28542713606205029 |
| 3648 | ret 244 |
| 3649 | end |
| 3650 | if eq get om2 0 0 |
| 3651 | ret 0 |
| 3652 | end |
| 3653 | ret kw2 w |
| 3654 | end |
| 3655 | |
| 3656 | note ======== OM-2 words (spec/omegese-om2.md): reserved only in an OM-2 unit. rotr 59, rotl 60 are |
| 3657 | note binary operators; dit 225 and scrub 226 are program-mode value words (OMEGESE 9.13.1); the rest are |
| 3658 | note statement and declaration words of later sections. ======== |
| 3659 | fn kw2 w ulong to ulong |
| 3660 | if eq w 1920233330 |
| 3661 | ret 59 |
| 3662 | end |
| 3663 | if eq w 1819570034 |
| 3664 | ret 60 |
| 3665 | end |
| 3666 | if eq w 119212982038133 |
| 3667 | ret 181 |
| 3668 | end |
| 3669 | if eq w 111524889521769 |
| 3670 | ret 182 |
| 3671 | end |
| 3672 | if eq w 448612627046 |
| 3673 | ret 183 |
| 3674 | end |
| 3675 | if eq w 8386654075301880417 |
| 3676 | ret 184 |
| 3677 | end |
| 3678 | if eq w 1818322291 |
| 3679 | ret 185 |
| 3680 | end |
| 3681 | if eq w 1852141679 |
| 3682 | ret 186 |
| 3683 | end |
| 3684 | if eq w 495606067048 |
| 3685 | ret 187 |
| 3686 | end |
| 3687 | if eq w 128047730221420 |
| 3688 | ret 188 |
| 3689 | end |
| 3690 | if eq w 431315315046 |
| 3691 | ret 189 |
| 3692 | end |
| 3693 | if eq w 29793 |
| 3694 | ret 190 |
| 3695 | end |
| 3696 | if eq w 111516484659564 |
| 3697 | ret 191 |
| 3698 | end |
| 3699 | if eq w 6777186 |
| 3700 | ret 192 |
| 3701 | end |
| 3702 | if eq w 1953653104 |
| 3703 | ret 193 |
| 3704 | end |
| 3705 | if eq w 7632239 |
| 3706 | ret 194 |
| 3707 | end |
| 3708 | if eq w 128034844735589 |
| 3709 | ret 195 |
| 3710 | end |
| 3711 | if eq w 7565423 |
| 3712 | ret 196 |
| 3713 | end |
| 3714 | if eq w 7629156 |
| 3715 | ret 225 |
| 3716 | end |
| 3717 | if eq w 422877225843 |
| 3718 | ret 226 |
| 3719 | end |
| 3720 | ret 0 |
| 3721 | end |
| 3722 | |
| 3723 | note nfail: a bad number (diag expect=number); unkfail: an undeclared function or struct (sev=unknown) |
| 3724 | fn nfail code ulong to void |
| 3725 | put dexp 0 4 |
| 3726 | fail code |
| 3727 | end |
| 3728 | |
| 3729 | fn unkfail code ulong to void |
| 3730 | put dsev 0 2 |
| 3731 | put dexp 0 3 |
| 3732 | fail code |
| 3733 | end |
| 3734 | |
| 3735 | note lineis: the n bytes at q are the packed word w and the line ends right after them |
| 3736 | fn lineis q ulong w ulong n ulong to ulong |
| 3737 | e = get inlen 0 |
| 3738 | if gt add q n e |
| 3739 | ret 0 |
| 3740 | end |
| 3741 | i = ulong 0 |
| 3742 | x = w |
| 3743 | while lt i n |
| 3744 | if ne ulong a_ib add q i and x 255 |
| 3745 | ret 0 |
| 3746 | end |
| 3747 | x = shr x 8 |
| 3748 | i = add i 1 |
| 3749 | end |
| 3750 | r = add q n |
| 3751 | if lt r e |
| 3752 | if ne a_ib r 10 |
| 3753 | ret 0 |
| 3754 | end |
| 3755 | end |
| 3756 | ret 1 |
| 3757 | end |
| 3758 | |
| 3759 | note isnote: the word at p is note (the lexer ends a word at a blank, a parenthesis or the end) |
| 3760 | fn isnote p ulong to ulong |
| 3761 | e = get inlen 0 |
| 3762 | if gt add p 4 e |
| 3763 | ret 0 |
| 3764 | end |
| 3765 | i = ulong 0 |
| 3766 | x = ulong 1702129518 |
| 3767 | while lt i 4 |
| 3768 | if ne ulong a_ib add p i and x 255 |
| 3769 | ret 0 |
| 3770 | end |
| 3771 | x = shr x 8 |
| 3772 | i = add i 1 |
| 3773 | end |
| 3774 | r = add p 4 |
| 3775 | if lt r e |
| 3776 | b = a_ib r |
| 3777 | if and gt b 32 and ne b 40 ne b 41 |
| 3778 | ret 0 |
| 3779 | end |
| 3780 | end |
| 3781 | ret 1 |
| 3782 | end |
| 3783 | |
| 3784 | note chk_mode: the lead line check (1), next (2) or usage (3). usage compiles the unit as usual and, in |
| 3785 | note place of the artifact, writes the omc-use record (a_rec) to stdout and exits 0; an error writes the |
| 3786 | note human line and then the record to stderr. It is how the usage gate reads what a unit asked of the |
| 3787 | note arena without changing the unit's profile. |
| 3788 | fn chk_mode q ulong to ulong |
| 3789 | if ne lineis q 127970252055151 6 0 |
| 3790 | ret 4 |
| 3791 | end |
| 3792 | if ne lineis q 461229090915 5 0 |
| 3793 | ret 1 |
| 3794 | end |
| 3795 | if ne lineis q 1954047342 4 0 |
| 3796 | ret 2 |
| 3797 | end |
| 3798 | if ne lineis q 435526136693 5 0 |
| 3799 | ret 3 |
| 3800 | end |
| 3801 | ret 0 |
| 3802 | end |
| 3803 | |
| 3804 | fn chk_lead to void |
| 3805 | e = get inlen 0 |
| 3806 | p = ulong 0 |
| 3807 | ln = ulong 1 |
| 3808 | go = true |
| 3809 | while go |
| 3810 | m = ulong 0 |
| 3811 | while and go lt m 999999 |
| 3812 | q = skipbl p |
| 3813 | if ge q e |
| 3814 | go = false |
| 3815 | else |
| 3816 | if eq a_ib q 10 |
| 3817 | p = add q 1 |
| 3818 | ln = add ln 1 |
| 3819 | else |
| 3820 | if ne isnote q 0 |
| 3821 | p = skipln q |
| 3822 | ln = add ln 1 |
| 3823 | else |
| 3824 | k = chk_mode q |
| 3825 | if ne k 0 |
| 3826 | put chkmode 0 k |
| 3827 | put chkln 0 ln |
| 3828 | put sbase 0 skipln q |
| 3829 | end |
| 3830 | go = false |
| 3831 | end |
| 3832 | end |
| 3833 | end |
| 3834 | m = add m 1 |
| 3835 | end |
| 3836 | end |
| 3837 | end |
| 3838 | |
| 3839 | note om2lead: skip blank lines and note lines; when the next line is exactly om2 (1), om2 diag (2) or |
| 3840 | note om2 fmt (3) the unit is OM-2: om2, om2m, om2ln, om2pos. Anything else leaves the unit OM-1. |
| 3841 | fn om2lead to void |
| 3842 | e = get inlen 0 |
| 3843 | p = ulong 0 |
| 3844 | ln = ulong 1 |
| 3845 | if ne get chkmode 0 0 |
| 3846 | p = get sbase 0 |
| 3847 | ln = add get chkln 0 1 |
| 3848 | end |
| 3849 | go = true |
| 3850 | while go |
| 3851 | m = ulong 0 |
| 3852 | while and go lt m 999999 |
| 3853 | q = skipbl p |
| 3854 | if ge q e |
| 3855 | go = false |
| 3856 | else |
| 3857 | if eq a_ib q 10 |
| 3858 | p = add q 1 |
| 3859 | ln = add ln 1 |
| 3860 | else |
| 3861 | if ne isnote q 0 |
| 3862 | p = skipln q |
| 3863 | ln = add ln 1 |
| 3864 | else |
| 3865 | r = ulong 0 |
| 3866 | if eq q p |
| 3867 | if ne lineis q 3304815 3 0 |
| 3868 | r = ulong 1 |
| 3869 | end |
| 3870 | if ne lineis q 7449351137405332847 8 0 |
| 3871 | r = ulong 2 |
| 3872 | end |
| 3873 | if ne lineis q 32771382692703599 7 0 |
| 3874 | r = ulong 3 |
| 3875 | end |
| 3876 | if eq r 0 |
| 3877 | r = cp_mode q |
| 3878 | end |
| 3879 | end |
| 3880 | if ne r 0 |
| 3881 | put om2 0 1 |
| 3882 | put om2m 0 sub r 1 |
| 3883 | put om2ln 0 ln |
| 3884 | put om2pos 0 q |
| 3885 | end |
| 3886 | go = false |
| 3887 | end |
| 3888 | end |
| 3889 | end |
| 3890 | m = add m 1 |
| 3891 | end |
| 3892 | end |
| 3893 | end |
| 3894 | |
| 3895 | note ---- om2 fmt (spec 2, errata E4, E6): only when the input's first line, at byte 0, is om2 fmt (an om2 |
| 3896 | note fmt line elsewhere is error 16). The rest (the bytes after the first LF) is compiled as a unit of |
| 3897 | note its own (OM-1 or OM-2 by its own first line) and, when it is accepted, its canonical text is written |
| 3898 | note instead of the artifact. A CR anywhere and blank lines at the end are error 6. Lines and spans are |
| 3899 | note reported against the whole input. |
| 3900 | global fst ulong 1 |
| 3901 | global fpend ulong 1 |
| 3902 | global fbo ulong 1 |
| 3903 | global fprp ulong 1 |
| 3904 | global flso ulong 1 |
| 3905 | |
| 3906 | note fmttail: blank lines at the end of the rest (n bytes) are error 6, at the first such line |
| 3907 | fn fmttail n ulong to void |
| 3908 | lnb = ulong 0 |
| 3909 | lnl = ulong 1 |
| 3910 | ln = ulong 1 |
| 3911 | i = ulong 0 |
| 3912 | go = true |
| 3913 | while go |
| 3914 | m = ulong 0 |
| 3915 | while and go lt m 999999 |
| 3916 | if ge i n |
| 3917 | go = false |
| 3918 | else |
| 3919 | b = a_ib i |
| 3920 | if eq b 10 |
| 3921 | ln = add ln 1 |
| 3922 | else |
| 3923 | if and ne b 32 ne b 9 |
| 3924 | lnb = add i 1 |
| 3925 | lnl = ln |
| 3926 | end |
| 3927 | end |
| 3928 | i = add i 1 |
| 3929 | end |
| 3930 | m = add m 1 |
| 3931 | end |
| 3932 | end |
| 3933 | bad = false |
| 3934 | if eq lnb 0 |
| 3935 | if gt n 0 |
| 3936 | bad = true |
| 3937 | lnl = ulong 0 |
| 3938 | end |
| 3939 | end |
| 3940 | k = lnb |
| 3941 | fl = n |
| 3942 | go = true |
| 3943 | while go |
| 3944 | m = ulong 0 |
| 3945 | while and go lt m 999999 |
| 3946 | if ge k n |
| 3947 | go = false |
| 3948 | else |
| 3949 | if eq a_ib k 10 |
| 3950 | fl = k |
| 3951 | go = false |
| 3952 | end |
| 3953 | k = add k 1 |
| 3954 | end |
| 3955 | m = add m 1 |
| 3956 | end |
| 3957 | end |
| 3958 | if lt add fl 1 n |
| 3959 | bad = true |
| 3960 | end |
| 3961 | if bad |
| 3962 | put line 0 add lnl 1 |
| 3963 | put tka 0 lnb |
| 3964 | put tkb 0 lnb |
| 3965 | note d2site 22|fmttail: malformed number or token; condition if bad |
| 3966 | put d2site 0 22 |
| 3967 | fail 6 |
| 3968 | end |
| 3969 | end |
| 3970 | |
| 3971 | fn fmtprep to void |
| 3972 | if ne get om2pos 0 0 |
| 3973 | put line 0 get om2ln 0 |
| 3974 | put tka 0 get om2pos 0 |
| 3975 | put tkb 0 get om2pos 0 |
| 3976 | note d2site 23|fmtprep: syntax: unknown or misplaced word; condition if ne get om2pos 0 0 |
| 3977 | put d2site 0 23 |
| 3978 | fail 16 |
| 3979 | end |
| 3980 | e = get inlen 0 |
| 3981 | ln = ulong 1 |
| 3982 | i = ulong 0 |
| 3983 | go = true |
| 3984 | while go |
| 3985 | m = ulong 0 |
| 3986 | while and go lt m 999999 |
| 3987 | if ge i e |
| 3988 | go = false |
| 3989 | else |
| 3990 | b = a_ib i |
| 3991 | if eq b 13 |
| 3992 | put line 0 ln |
| 3993 | put tka 0 i |
| 3994 | put tkb 0 add i 1 |
| 3995 | note d2site 24|fmtprep: malformed number or token; condition if eq b 13 |
| 3996 | put d2site 0 24 |
| 3997 | fail 6 |
| 3998 | end |
| 3999 | if eq b 10 |
| 4000 | ln = add ln 1 |
| 4001 | end |
| 4002 | i = add i 1 |
| 4003 | end |
| 4004 | m = add m 1 |
| 4005 | end |
| 4006 | end |
| 4007 | r = skipln get om2pos 0 |
| 4008 | put lbase 0 get om2ln 0 |
| 4009 | put sbase 0 r |
| 4010 | n = sub e r |
| 4011 | j = ulong 0 |
| 4012 | go = true |
| 4013 | while go |
| 4014 | m = ulong 0 |
| 4015 | while and go lt m 999999 |
| 4016 | if ge j n |
| 4017 | go = false |
| 4018 | else |
| 4019 | a_bput 0 j a_ib add r j |
| 4020 | j = add j 1 |
| 4021 | end |
| 4022 | m = add m 1 |
| 4023 | end |
| 4024 | end |
| 4025 | put inlen 0 n |
| 4026 | fmttail n |
| 4027 | put om2 0 0 |
| 4028 | put om2m 0 0 |
| 4029 | put om2ln 0 0 |
| 4030 | put fmtm 0 1 |
| 4031 | om2lead |
| 4032 | if eq get om2m 0 2 |
| 4033 | put line 0 get om2ln 0 |
| 4034 | put tka 0 get om2pos 0 |
| 4035 | put tkb 0 get om2pos 0 |
| 4036 | note d2site 25|fmtprep: syntax: unknown or misplaced word; condition if eq get om2m 0 2 |
| 4037 | put d2site 0 25 |
| 4038 | fail 16 |
| 4039 | end |
| 4040 | end |
| 4041 | |
| 4042 | note fmtbyte: one input byte of the canonical text. fst: 0 line start, 1 indentation (kept, dropped |
| 4043 | note again on a blank line), 2 note line (copied), 3 between words, 4 in a word, 5 in a text literal, 6 |
| 4044 | note after a backslash in a text literal. A run of blanks between words (fpend, starting at output byte |
| 4045 | note fbo) is written as it comes, then becomes one space unless a parenthesis is next to it (fprp: the |
| 4046 | note word before it was one); at the end of the line it is dropped. |
| 4047 | fn fmtbyte p ulong to void |
| 4048 | b = uchar and shr get a_ar shr p 3 shl and p 7 3 255 |
| 4049 | s = get fst 0 |
| 4050 | if eq b 10 |
| 4051 | if lt s 2 |
| 4052 | put oc 0 get flso 0 |
| 4053 | else |
| 4054 | if ne get fpend 0 0 |
| 4055 | put oc 0 get fbo 0 |
| 4056 | end |
| 4057 | end |
| 4058 | emitb 10 |
| 4059 | put fst 0 0 |
| 4060 | put fpend 0 0 |
| 4061 | put fprp 0 0 |
| 4062 | put flso 0 get oc 0 |
| 4063 | ret |
| 4064 | end |
| 4065 | if eq s 2 |
| 4066 | emitb b |
| 4067 | ret |
| 4068 | end |
| 4069 | if eq s 5 |
| 4070 | emitb b |
| 4071 | if eq b 92 |
| 4072 | put fst 0 6 |
| 4073 | end |
| 4074 | if eq b 34 |
| 4075 | put fst 0 3 |
| 4076 | put fprp 0 0 |
| 4077 | end |
| 4078 | ret |
| 4079 | end |
| 4080 | if eq s 6 |
| 4081 | emitb b |
| 4082 | put fst 0 5 |
| 4083 | ret |
| 4084 | end |
| 4085 | blank = or eq b 32 eq b 9 |
| 4086 | if lt s 2 |
| 4087 | if blank |
| 4088 | emitb b |
| 4089 | put fst 0 1 |
| 4090 | ret |
| 4091 | end |
| 4092 | if ne isnote p 0 |
| 4093 | emitb b |
| 4094 | put fst 0 2 |
| 4095 | ret |
| 4096 | end |
| 4097 | put fst 0 3 |
| 4098 | put fpend 0 0 |
| 4099 | end |
| 4100 | if blank |
| 4101 | if eq get fpend 0 0 |
| 4102 | put fbo 0 get oc 0 |
| 4103 | put fpend 0 1 |
| 4104 | end |
| 4105 | emitb b |
| 4106 | put fst 0 3 |
| 4107 | ret |
| 4108 | end |
| 4109 | paren = or eq b 40 eq b 41 |
| 4110 | if and eq get fst 0 4 not paren |
| 4111 | emitb b |
| 4112 | ret |
| 4113 | end |
| 4114 | if ne get fpend 0 0 |
| 4115 | if and eq get fprp 0 0 not paren |
| 4116 | put oc 0 get fbo 0 |
| 4117 | emitb 32 |
| 4118 | end |
| 4119 | end |
| 4120 | put fpend 0 0 |
| 4121 | emitb b |
| 4122 | if eq b 34 |
| 4123 | put fst 0 5 |
| 4124 | put fprp 0 0 |
| 4125 | ret |
| 4126 | end |
| 4127 | if paren |
| 4128 | put fst 0 3 |
| 4129 | put fprp 0 1 |
| 4130 | else |
| 4131 | put fst 0 4 |
| 4132 | put fprp 0 0 |
| 4133 | end |
| 4134 | end |
| 4135 | |
| 4136 | fn fmtout to void |
| 4137 | put oc 0 0 |
| 4138 | put fst 0 0 |
| 4139 | put fpend 0 0 |
| 4140 | put fprp 0 0 |
| 4141 | put flso 0 0 |
| 4142 | e = get inlen 0 |
| 4143 | p = ulong 0 |
| 4144 | go = true |
| 4145 | while go |
| 4146 | m = ulong 0 |
| 4147 | while and go lt m 999999 |
| 4148 | if ge p e |
| 4149 | go = false |
| 4150 | else |
| 4151 | fmtbyte p |
| 4152 | p = add p 1 |
| 4153 | end |
| 4154 | m = add m 1 |
| 4155 | end |
| 4156 | end |
| 4157 | if ge get fst 0 2 |
| 4158 | if ne get fpend 0 0 |
| 4159 | put oc 0 get fbo 0 |
| 4160 | end |
| 4161 | emitb 10 |
| 4162 | end |
| 4163 | put fmtm 0 0 |
| 4164 | put om2m 0 0 |
| 4165 | writeout 0 |
| 4166 | end |
| 4167 | |
| 4168 | note tok_hex (OM-2): 0x and 1..16 digits 0-9 a-f is the unsigned value (tk 2, tbig as tok_num). A - before |
| 4169 | note 0x, 0X, no digits, more than 16 digits, an uppercase or any other character is error 6. 0 when the |
| 4170 | note word is not a hex literal. |
| 4171 | fn tok_hex to ulong |
| 4172 | p = get ts 0 |
| 4173 | e = get cur 0 |
| 4174 | if eq uchar and shr get a_ar shr p 3 shl and p 7 3 255 45 |
| 4175 | q = add p 1 |
| 4176 | if lt add q 1 e |
| 4177 | if eq uchar and shr get a_ar shr q 3 shl and q 7 3 255 48 |
| 4178 | c = a_ib add q 1 |
| 4179 | if or eq c 120 eq c 88 |
| 4180 | note d2site 26|tok_hex: malformed number or token; condition if or eq c 120 eq c 88 |
| 4181 | put d2site 0 26 |
| 4182 | nfail 6 |
| 4183 | end |
| 4184 | end |
| 4185 | end |
| 4186 | ret 0 |
| 4187 | end |
| 4188 | if ge add p 1 e |
| 4189 | ret 0 |
| 4190 | end |
| 4191 | if ne uchar and shr get a_ar shr p 3 shl and p 7 3 255 48 |
| 4192 | ret 0 |
| 4193 | end |
| 4194 | c = uchar and shr get a_ar shr add p 1 3 shl and add p 1 7 3 255 |
| 4195 | if eq c 88 |
| 4196 | note d2site 27|tok_hex: malformed number or token; condition if eq c 88 |
| 4197 | put d2site 0 27 |
| 4198 | nfail 6 |
| 4199 | end |
| 4200 | if ne c 120 |
| 4201 | ret 0 |
| 4202 | end |
| 4203 | n = sub e add p 2 |
| 4204 | if eq n 0 |
| 4205 | note d2site 28|tok_hex: malformed number or token; condition if eq n 0 |
| 4206 | put d2site 0 28 |
| 4207 | nfail 6 |
| 4208 | end |
| 4209 | if gt n 16 |
| 4210 | note d2site 29|tok_hex: malformed number or token; condition if gt n 16 |
| 4211 | put d2site 0 29 |
| 4212 | nfail 6 |
| 4213 | end |
| 4214 | v = ulong 0 |
| 4215 | i = add p 2 |
| 4216 | while lt i e |
| 4217 | d = ulong a_ib i |
| 4218 | if and ge d 48 le d 57 |
| 4219 | v = or shl v 4 sub d 48 |
| 4220 | else |
| 4221 | if and ge d 97 le d 102 |
| 4222 | v = or shl v 4 sub d 87 |
| 4223 | else |
| 4224 | note d2site 30|tok_hex: malformed number or token; condition otherwise: if and ge d 97 le d 102 |
| 4225 | put d2site 0 30 |
| 4226 | nfail 6 |
| 4227 | end |
| 4228 | end |
| 4229 | i = add i 1 |
| 4230 | end |
| 4231 | put tbig 0 shr v 63 |
| 4232 | put tw 0 v |
| 4233 | put tk 0 2 |
| 4234 | ret 1 |
| 4235 | end |
| 4236 | |
| 4237 | note ---- float literals: a token is the decimal value fsgn * fnd * 10^fp10, fsuf 0 none / 1 f32 / 2 f64. |
| 4238 | note fg_* hold the working state of the one literal being converted (see fparse/fbits/fnorm/fgen). |
| 4239 | global fsgn ulong 1 |
| 4240 | global fnd ulong 1 |
| 4241 | global fp10 long 1 |
| 4242 | global fsuf ulong 1 |
| 4243 | global fg_fl ulong 1 |
| 4244 | global fg_seen ulong 1 |
| 4245 | global fg_ex long 1 |
| 4246 | global fg_esign long 1 |
| 4247 | global fg_ed ulong 1 |
| 4248 | global fg_ty ulong 1 |
| 4249 | global fg_e long 1 |
| 4250 | global fg_q ulong 1 |
| 4251 | global fg_m ulong 1 |
| 4252 | global fg_stk ulong 1 |
| 4253 | global fbn ulong 80 |
| 4254 | |
| 4255 | note ======== float literals: decimal text to IEEE-754 binary32/binary64 ======== |
| 4256 | note The literal is fnd * 10^fp10 = A / D with A = fnd * 10^max(fp10,0) and D = 10^max(-fp10,0), both |
| 4257 | note held exactly as 40 32-bit limbs in fbn (A at 0, D at 40). The smaller of the two is shifted to the |
| 4258 | note other's bit length, then restoring division yields the first 64 quotient bits (fg_m, leading bit |
| 4259 | note set) and a remainder whose nonzero-ness is the sticky flag (fg_stk); froundsh rounds that exact |
| 4260 | note truncation once to nearest even and fpack packs it, subnormals included (#1024: the old converter |
| 4261 | note scaled one factor of ten at a time and dropped bits at every step). fp10 < -343 means a value |
| 4262 | note below (2^63-1)*10^-344 < 2^-1075, signed zero; fp10 > 308 means at least 10^309, above the |
| 4263 | note binary64 maximum (error 8). So A and D never exceed 1141 bits. |
| 4264 | |
| 4265 | note blen: bits needed for x (0 for zero) |
| 4266 | fn blen x ulong to ulong |
| 4267 | n = ulong 0 |
| 4268 | while ne x 0 |
| 4269 | x = shr x 1 |
| 4270 | n = add n 1 |
| 4271 | end |
| 4272 | ret n |
| 4273 | end |
| 4274 | |
| 4275 | note fparse: read the literal text inp[pos, pos+len) into fsgn, fnd, fp10, fsuf (0 none, 1 f32, 2 f64). |
| 4276 | note Grammar: [-]digits[.digits][(e|E)[+|-]digits][f32|f64]. At most 2^63-1 significant digits |
| 4277 | note (error 8), a dot with no digit after it is error 6, |exponent| <= 999 (error 8). |
| 4278 | note The digit scans here and in fexp run as nested 999999-pass loops: a literal of more than 1000000 |
| 4279 | note zero digits trapped 4 in a single loop's hidden 1000000-pass guard (#965). |
| 4280 | fn fparse pos ulong ln ulong to void |
| 4281 | p = pos |
| 4282 | e = add pos ln |
| 4283 | put fsgn 0 0 |
| 4284 | put fsuf 0 0 |
| 4285 | put fnd 0 0 |
| 4286 | put fg_fl 0 0 |
| 4287 | put fg_seen 0 0 |
| 4288 | if eq uchar and shr get a_ar shr p 3 shl and p 7 3 255 45 |
| 4289 | put fsgn 0 1 |
| 4290 | p = add p 1 |
| 4291 | end |
| 4292 | go = true |
| 4293 | while go |
| 4294 | pos = ulong 0 |
| 4295 | while and go lt pos 999999 |
| 4296 | if ge p e |
| 4297 | go = false |
| 4298 | else |
| 4299 | d = sub ulong a_ib p 48 |
| 4300 | if le d 9 |
| 4301 | if gt get fnd 0 922337203685477580 |
| 4302 | note d2site 31|fparse: number out of range for its type or place; condition if gt get fnd 0 922337203685477580 |
| 4303 | put d2site 0 31 |
| 4304 | fail 8 |
| 4305 | end |
| 4306 | if eq get fnd 0 922337203685477580 |
| 4307 | if gt d 7 |
| 4308 | note d2site 32|fparse: number out of range for its type or place; condition if gt d 7 |
| 4309 | put d2site 0 32 |
| 4310 | fail 8 |
| 4311 | end |
| 4312 | end |
| 4313 | put fnd 0 add mul get fnd 0 10 d |
| 4314 | if ne get fg_seen 0 0 |
| 4315 | put fg_fl 0 add get fg_fl 0 1 |
| 4316 | end |
| 4317 | p = add p 1 |
| 4318 | else |
| 4319 | go = false |
| 4320 | if eq a_ib p 46 |
| 4321 | if eq get fg_seen 0 0 |
| 4322 | put fg_seen 0 1 |
| 4323 | p = add p 1 |
| 4324 | go = true |
| 4325 | end |
| 4326 | end |
| 4327 | end |
| 4328 | end |
| 4329 | pos = add pos 1 |
| 4330 | end |
| 4331 | end |
| 4332 | if and ne get fg_seen 0 0 eq get fg_fl 0 0 |
| 4333 | note d2site 33|fparse: malformed number or token; condition if and ne get fg_seen 0 0 eq get fg_fl 0 0 |
| 4334 | put d2site 0 33 |
| 4335 | fail 6 |
| 4336 | end |
| 4337 | p = fexp p e |
| 4338 | p = fsufx p e |
| 4339 | if ne p e |
| 4340 | note d2site 34|fparse: malformed number or token; condition if ne p e |
| 4341 | put d2site 0 34 |
| 4342 | fail 6 |
| 4343 | end |
| 4344 | x = mul get fg_esign 0 get fg_ex 0 |
| 4345 | put fp10 0 sub x long get fg_fl 0 |
| 4346 | end |
| 4347 | |
| 4348 | note fexp: the exponent of the literal, if present: fg_ex, fg_esign, fg_ed. Returns the new position. |
| 4349 | fn fexp p ulong e ulong to ulong |
| 4350 | put fg_ex 0 0 |
| 4351 | put fg_esign 0 1 |
| 4352 | if and lt p e or eq a_ib p 101 eq a_ib p 69 |
| 4353 | p = add p 1 |
| 4354 | if lt p e |
| 4355 | if or eq a_ib p 43 eq a_ib p 45 |
| 4356 | if eq uchar and shr get a_ar shr p 3 shl and p 7 3 255 45 |
| 4357 | put fg_esign 0 -1 |
| 4358 | end |
| 4359 | p = add p 1 |
| 4360 | end |
| 4361 | end |
| 4362 | put fg_ed 0 0 |
| 4363 | go = true |
| 4364 | while go |
| 4365 | m = ulong 0 |
| 4366 | while and go lt m 999999 |
| 4367 | if ge p e |
| 4368 | go = false |
| 4369 | else |
| 4370 | d = sub ulong a_ib p 48 |
| 4371 | if gt d 9 |
| 4372 | go = false |
| 4373 | else |
| 4374 | put fg_ex 0 mul get fg_ex 0 10 |
| 4375 | put fg_ex 0 add get fg_ex 0 long d |
| 4376 | if gt get fg_ex 0 999 |
| 4377 | note d2site 35|fexp: number out of range for its type or place; condition if gt get fg_ex 0 999 |
| 4378 | put d2site 0 35 |
| 4379 | fail 8 |
| 4380 | end |
| 4381 | put fg_ed 0 add get fg_ed 0 1 |
| 4382 | p = add p 1 |
| 4383 | end |
| 4384 | end |
| 4385 | m = add m 1 |
| 4386 | end |
| 4387 | end |
| 4388 | if eq get fg_ed 0 0 |
| 4389 | note d2site 36|fexp: malformed number or token; condition if eq get fg_ed 0 0 |
| 4390 | put d2site 0 36 |
| 4391 | fail 6 |
| 4392 | end |
| 4393 | end |
| 4394 | ret p |
| 4395 | end |
| 4396 | |
| 4397 | note fsufx: the optional f32/f64 suffix: fsuf 1 or 2. Returns the new position. |
| 4398 | fn fsufx p ulong e ulong to ulong |
| 4399 | if lt p e |
| 4400 | r = sub e p |
| 4401 | if ne r 3 |
| 4402 | note d2site 37|fsufx: malformed number or token; condition if ne r 3 |
| 4403 | put d2site 0 37 |
| 4404 | fail 6 |
| 4405 | end |
| 4406 | if ne uchar and shr get a_ar shr p 3 shl and p 7 3 255 102 |
| 4407 | note d2site 38|fsufx: malformed number or token; condition if ne uchar and shr get a_ar shr p 3 shl and p 7 3 255 102 |
| 4408 | put d2site 0 38 |
| 4409 | fail 6 |
| 4410 | end |
| 4411 | if and eq a_ib add p 1 51 eq a_ib add p 2 50 |
| 4412 | put fsuf 0 1 |
| 4413 | else |
| 4414 | if and eq a_ib add p 1 54 eq a_ib add p 2 52 |
| 4415 | put fsuf 0 2 |
| 4416 | else |
| 4417 | note d2site 39|fsufx: malformed number or token; condition otherwise: if and eq a_ib add p 1 54 eq a_ib add p 2 52 |
| 4418 | put d2site 0 39 |
| 4419 | fail 6 |
| 4420 | end |
| 4421 | end |
| 4422 | p = add p 3 |
| 4423 | end |
| 4424 | ret p |
| 4425 | end |
| 4426 | |
| 4427 | note fbmul: limbs fbn[o, o+40) times k (k < 2^32, so each limb step fits 64 bits); the product must fit |
| 4428 | note in 40 limbs. Returns its bit length, so fbmul o 1 only measures. |
| 4429 | fn fbmul o ulong k ulong to ulong |
| 4430 | c = ulong 0 |
| 4431 | t = ulong 0 |
| 4432 | i = ulong 0 |
| 4433 | while lt i 40 |
| 4434 | j = add o i |
| 4435 | v = add mul get fbn j k c |
| 4436 | put fbn j and v 4294967295 |
| 4437 | c = shr v 32 |
| 4438 | if ne and v 4294967295 0 |
| 4439 | t = add mul i 32 blen and v 4294967295 |
| 4440 | end |
| 4441 | i = add i 1 |
| 4442 | end |
| 4443 | ret t |
| 4444 | end |
| 4445 | |
| 4446 | note fbpow: fbn[o, o+40) times b^n (b 2 or 10), in factors that stay below 2^32. |
| 4447 | fn fbpow o ulong b ulong n ulong to void |
| 4448 | while gt n 0 |
| 4449 | m = ulong 1 |
| 4450 | c = ulong 0 |
| 4451 | while and lt c n le mul m b 4294967295 |
| 4452 | m = mul m b |
| 4453 | c = add c 1 |
| 4454 | end |
| 4455 | t = fbmul o m |
| 4456 | n = sub n c |
| 4457 | end |
| 4458 | end |
| 4459 | |
| 4460 | note fbsub: one restoring-division step. If A >= D then A = A - D and 1, else A is kept and 0. |
| 4461 | fn fbsub to ulong |
| 4462 | r = ulong 2 |
| 4463 | i = ulong 40 |
| 4464 | while and gt i 0 eq r 2 |
| 4465 | i = sub i 1 |
| 4466 | a = get fbn i |
| 4467 | d = get fbn add i 40 |
| 4468 | if lt a d |
| 4469 | r = ulong 0 |
| 4470 | end |
| 4471 | if gt a d |
| 4472 | r = ulong 1 |
| 4473 | end |
| 4474 | end |
| 4475 | if eq r 0 |
| 4476 | ret 0 |
| 4477 | end |
| 4478 | b = ulong 0 |
| 4479 | i = ulong 0 |
| 4480 | while lt i 40 |
| 4481 | v = sub sub get fbn i get fbn add i 40 b |
| 4482 | put fbn i and v 4294967295 |
| 4483 | b = shr v 63 |
| 4484 | i = add i 1 |
| 4485 | end |
| 4486 | ret 1 |
| 4487 | end |
| 4488 | |
| 4489 | note froundsh: round fg_m right by sh bits to fg_q, nearest even; the guard and every lower bit |
| 4490 | note (plus fg_stk) decide. sh may be 64 (then q is zero and bit 63 is the guard). |
| 4491 | fn froundsh sh ulong to void |
| 4492 | m = get fg_m 0 |
| 4493 | q = ulong 0 |
| 4494 | guard = ulong 0 |
| 4495 | lost = ulong 0 |
| 4496 | if eq sh 0 |
| 4497 | q = m |
| 4498 | else |
| 4499 | if ge sh 64 |
| 4500 | guard = shr m 63 |
| 4501 | lost = and m 9223372036854775807 |
| 4502 | else |
| 4503 | q = shr m sh |
| 4504 | guard = and shr m sub sh 1 1 |
| 4505 | if gt sub sh 1 0 |
| 4506 | lost = and m sub shl 1 sub sh 1 1 |
| 4507 | end |
| 4508 | end |
| 4509 | end |
| 4510 | sticky = or get fg_stk 0 lost |
| 4511 | if ne guard 0 |
| 4512 | if or ne sticky 0 eq and q 1 1 |
| 4513 | q = add q 1 |
| 4514 | end |
| 4515 | end |
| 4516 | put fg_q 0 q |
| 4517 | end |
| 4518 | |
| 4519 | note fpack: fg_m/fg_e to IEEE bits of fg_ty, including subnormals; a literal that rounds to infinity |
| 4520 | note is refused (error 8). |
| 4521 | fn fpack to ulong |
| 4522 | p = ulong 53 |
| 4523 | bias = long 1023 |
| 4524 | maxe = long 2047 |
| 4525 | emin = long -1022 |
| 4526 | mb = ulong 52 |
| 4527 | w = ulong 64 |
| 4528 | if eq get fg_ty 0 10 |
| 4529 | p = ulong 24 |
| 4530 | bias = long 127 |
| 4531 | maxe = long 255 |
| 4532 | emin = long -126 |
| 4533 | mb = ulong 23 |
| 4534 | w = ulong 32 |
| 4535 | end |
| 4536 | e = add get fg_e 0 63 |
| 4537 | if ge e emin |
| 4538 | sh = sub 64 p |
| 4539 | froundsh sh |
| 4540 | q = get fg_q 0 |
| 4541 | if eq q shl 1 p |
| 4542 | q = shr q 1 |
| 4543 | e = add e 1 |
| 4544 | end |
| 4545 | E = add e bias |
| 4546 | if ge E maxe |
| 4547 | note d2site 40|fpack: number out of range for its type or place; condition if ge E maxe |
| 4548 | put d2site 0 40 |
| 4549 | fail 8 |
| 4550 | end |
| 4551 | q = and q sub shl 1 sub p 1 1 |
| 4552 | q = or q shl ulong E mb |
| 4553 | q = or q shl get fsgn 0 sub w 1 |
| 4554 | ret q |
| 4555 | end |
| 4556 | k = ulong sub emin e |
| 4557 | sh = add sub 64 p k |
| 4558 | if gt sh 64 |
| 4559 | ret shl get fsgn 0 sub w 1 |
| 4560 | end |
| 4561 | froundsh sh |
| 4562 | q = get fg_q 0 |
| 4563 | q = or q shl get fsgn 0 sub w 1 |
| 4564 | ret q |
| 4565 | end |
| 4566 | |
| 4567 | note fbits: the parsed literal as IEEE bits of type ty (10 f32, 11 f64). Zero keeps the sign (-0.0). |
| 4568 | fn fbits ty ulong to ulong |
| 4569 | put fg_ty 0 ty |
| 4570 | p = get fp10 0 |
| 4571 | if or eq get fnd 0 0 lt p -343 |
| 4572 | w = ulong 64 |
| 4573 | if eq ty 10 |
| 4574 | w = ulong 32 |
| 4575 | end |
| 4576 | b = ulong 0 |
| 4577 | if ne get fsgn 0 0 |
| 4578 | b = shl ulong 1 sub w 1 |
| 4579 | end |
| 4580 | ret b |
| 4581 | end |
| 4582 | if gt p 308 |
| 4583 | note d2site 41|fbits: number out of range for its type or place; condition if gt p 308 |
| 4584 | put d2site 0 41 |
| 4585 | fail 8 |
| 4586 | end |
| 4587 | i = ulong 0 |
| 4588 | while lt i 80 |
| 4589 | put fbn i 0 |
| 4590 | i = add i 1 |
| 4591 | end |
| 4592 | put fbn 0 and get fnd 0 4294967295 |
| 4593 | put fbn 1 shr get fnd 0 32 |
| 4594 | put fbn 40 1 |
| 4595 | if gt p 0 |
| 4596 | fbpow 0 10 ulong p |
| 4597 | else |
| 4598 | fbpow 40 10 ulong sub 0 p |
| 4599 | end |
| 4600 | a = fbmul 0 1 |
| 4601 | d = fbmul 40 1 |
| 4602 | e = long 0 |
| 4603 | if lt a d |
| 4604 | fbpow 0 2 sub d a |
| 4605 | e = sub 0 long sub d a |
| 4606 | else |
| 4607 | fbpow 40 2 sub a d |
| 4608 | e = long sub a d |
| 4609 | end |
| 4610 | q = ulong 0 |
| 4611 | while lt q 9223372036854775808 |
| 4612 | q = or shl q 1 fbsub |
| 4613 | a = fbmul 0 2 |
| 4614 | e = sub e 1 |
| 4615 | end |
| 4616 | put fg_m 0 q |
| 4617 | put fg_e 0 add e 1 |
| 4618 | put fg_stk 0 fbmul 0 1 |
| 4619 | ret fpack |
| 4620 | end |
| 4621 | |
| 4622 | note fsizeof: sizeof T, or sizeof S for a struct: bytes. foffset: offsetof S f: the field's byte offset |
| 4623 | note in the struct's 8-byte-cell layout. Both are compile-time constants of type ulong. |
| 4624 | fn fsizeof dst ulong to void |
| 4625 | sid = peek_struct |
| 4626 | if ne sid 0 |
| 4627 | si = sub sid 1 |
| 4628 | n = ulong get st_cells si |
| 4629 | vdone 3 mul n 8 5 |
| 4630 | ret |
| 4631 | end |
| 4632 | t = typeword |
| 4633 | if ge t 64 |
| 4634 | note d2site 42|fsizeof: type mismatch; condition if ge t 64 |
| 4635 | put d2site 0 42 |
| 4636 | fail 7 |
| 4637 | end |
| 4638 | v = shl 1 tlog t |
| 4639 | vdone 3 v 5 |
| 4640 | end |
| 4641 | |
| 4642 | fn foffset dst ulong to void |
| 4643 | tok |
| 4644 | if ne get tk 0 1 |
| 4645 | note d2site 43|foffset: syntax: unknown or misplaced word; condition if ne get tk 0 1 |
| 4646 | put d2site 0 43 |
| 4647 | fail 16 |
| 4648 | end |
| 4649 | if gt get tl 0 63 |
| 4650 | note d2site 44|foffset: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63 |
| 4651 | put d2site 0 44 |
| 4652 | fail 13 |
| 4653 | end |
| 4654 | sid = findstruct get tw 0 |
| 4655 | if eq sid 0 |
| 4656 | note d2site 45|foffset: unknown name or field, or a word this mode does not provide; condition if eq sid 0 |
| 4657 | put d2site 0 45 |
| 4658 | unkfail 3 |
| 4659 | end |
| 4660 | tok |
| 4661 | if ne get tk 0 1 |
| 4662 | note d2site 46|foffset: syntax: unknown or misplaced word; condition if ne get tk 0 1 |
| 4663 | put d2site 0 46 |
| 4664 | fail 16 |
| 4665 | end |
| 4666 | if gt get tl 0 63 |
| 4667 | note d2site 47|foffset: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63 |
| 4668 | put d2site 0 47 |
| 4669 | fail 13 |
| 4670 | end |
| 4671 | f = findfield sub sid 1 get tw 0 |
| 4672 | if eq f 0 |
| 4673 | note d2site 48|foffset: unknown name or field, or a word this mode does not provide; condition if eq f 0 |
| 4674 | put d2site 0 48 |
| 4675 | fail 3 |
| 4676 | end |
| 4677 | off = ulong get sf_off sub f 1 |
| 4678 | vdone 3 mul off 8 5 |
| 4679 | end |
| 4680 | |
| 4681 | note fspan: a deferred literal stored as pos*4294967296+len. The input lives in the arena (2^27 bytes at |
| 4682 | note most), so pos fits the high 32 bits and len the low 32; the old pos*64+len read a literal of 64 or more |
| 4683 | note characters from the wrong span (#965), and pos*16777216+len assumed an input below 2^23 bytes. |
| 4684 | fn fspan ty ulong packed ulong to ulong |
| 4685 | fparse div packed 4294967296 rem packed 4294967296 |
| 4686 | ret fbits ty |
| 4687 | end |
| 4688 | |
| 4689 | fn isfloat t ulong to ulong |
| 4690 | if or eq t 10 eq t 11 |
| 4691 | ret 1 |
| 4692 | end |
| 4693 | ret 0 |
| 4694 | end |
| 4695 | |
| 4696 | note ======== om4's small tables, as functions ======== |
| 4697 | note twid: width in bits by type 0..9 (bool 1; uchar ushort uint ulong; byte short int long) |
| 4698 | fn twid t ulong to ulong |
| 4699 | if eq t 13 |
| 4700 | ret 64 |
| 4701 | end |
| 4702 | if eq t 10 |
| 4703 | ret 32 |
| 4704 | end |
| 4705 | if eq t 11 |
| 4706 | ret 64 |
| 4707 | end |
| 4708 | if eq t 1 |
| 4709 | ret 1 |
| 4710 | end |
| 4711 | if or eq t 2 eq t 6 |
| 4712 | ret 8 |
| 4713 | end |
| 4714 | if or eq t 3 eq t 7 |
| 4715 | ret 16 |
| 4716 | end |
| 4717 | if or eq t 4 eq t 8 |
| 4718 | ret 32 |
| 4719 | end |
| 4720 | if or eq t 5 eq t 9 |
| 4721 | ret 64 |
| 4722 | end |
| 4723 | ret 0 |
| 4724 | end |
| 4725 | |
| 4726 | note tlog: log2 of the element size by type |
| 4727 | fn tlog t ulong to ulong |
| 4728 | if eq t 13 |
| 4729 | ret 3 |
| 4730 | end |
| 4731 | if eq t 10 |
| 4732 | ret 2 |
| 4733 | end |
| 4734 | if eq t 11 |
| 4735 | ret 3 |
| 4736 | end |
| 4737 | if or eq t 3 eq t 7 |
| 4738 | ret 1 |
| 4739 | end |
| 4740 | if or eq t 4 eq t 8 |
| 4741 | ret 2 |
| 4742 | end |
| 4743 | if or eq t 5 eq t 9 |
| 4744 | ret 3 |
| 4745 | end |
| 4746 | ret 0 |
| 4747 | end |
| 4748 | |
| 4749 | note regidx: the pool index of register r (the inverse of poolc; 255 for x7 and x16) |
| 4750 | fn regidx r ulong to ulong |
| 4751 | if lt r 7 |
| 4752 | ret r |
| 4753 | end |
| 4754 | if eq r 7 |
| 4755 | ret 255 |
| 4756 | end |
| 4757 | if lt r 16 |
| 4758 | ret sub r 1 |
| 4759 | end |
| 4760 | if eq r 16 |
| 4761 | ret 255 |
| 4762 | end |
| 4763 | ret 15 |
| 4764 | end |
| 4765 | |
| 4766 | note conds: the condition for eq ne lt le gt ge (i = 2 (op - 43) + 1 when signed): EQ 0, NE 1, LO 3 / LT 11, |
| 4767 | note LS 9 / LE 13, HI 8 / GT 12, HS 2 / GE 10 (Arm ARM Table C1-1). The opposite condition is cond xor 1. |
| 4768 | fn conds i ulong to ulong |
| 4769 | if lt i 2 |
| 4770 | ret 0 |
| 4771 | end |
| 4772 | if lt i 4 |
| 4773 | ret 1 |
| 4774 | end |
| 4775 | if eq i 4 |
| 4776 | ret 3 |
| 4777 | end |
| 4778 | if eq i 5 |
| 4779 | ret 11 |
| 4780 | end |
| 4781 | if eq i 6 |
| 4782 | ret 9 |
| 4783 | end |
| 4784 | if eq i 7 |
| 4785 | ret 13 |
| 4786 | end |
| 4787 | if eq i 8 |
| 4788 | ret 8 |
| 4789 | end |
| 4790 | if eq i 9 |
| 4791 | ret 12 |
| 4792 | end |
| 4793 | if eq i 10 |
| 4794 | ret 2 |
| 4795 | end |
| 4796 | ret 10 |
| 4797 | end |
| 4798 | |
| 4799 | note ldop / stop: register-offset load / store by element type (om4 LDOP, STOP tables) |
| 4800 | fn ldop t ulong to ulong |
| 4801 | note LDRB 0x38606800, LDRH 0x78607800, LDR w 0xb8607800, LDR x 0xf8607800, LDRSB 0x38a06800, |
| 4802 | note LDRSH 0x78a07800, LDRSW 0xb8a07800 |
| 4803 | note Bool struct fields use a byte load/store, as their canonical values are zero or one. |
| 4804 | if or eq t 1 eq t 2 |
| 4805 | ret 945842176 |
| 4806 | end |
| 4807 | if eq t 3 |
| 4808 | ret 2019588096 |
| 4809 | end |
| 4810 | if eq t 4 |
| 4811 | ret 3093329920 |
| 4812 | end |
| 4813 | if or or eq t 5 eq t 9 eq t 13 |
| 4814 | ret 4167071744 |
| 4815 | end |
| 4816 | if eq t 10 |
| 4817 | ret 3093329920 |
| 4818 | end |
| 4819 | if eq t 11 |
| 4820 | ret 4167071744 |
| 4821 | end |
| 4822 | if eq t 6 |
| 4823 | ret 950036480 |
| 4824 | end |
| 4825 | if eq t 7 |
| 4826 | ret 2023782400 |
| 4827 | end |
| 4828 | if eq t 8 |
| 4829 | ret 3097524224 |
| 4830 | end |
| 4831 | ret 0 |
| 4832 | end |
| 4833 | |
| 4834 | fn stop t ulong to ulong |
| 4835 | note STRB 0x38206800, STRH 0x78207800, STR w 0xb8207800, STR x 0xf8207800 |
| 4836 | if or or eq t 1 eq t 2 eq t 6 |
| 4837 | ret 941647872 |
| 4838 | end |
| 4839 | if or eq t 3 eq t 7 |
| 4840 | ret 2015393792 |
| 4841 | end |
| 4842 | if or eq t 4 eq t 8 |
| 4843 | ret 3089135616 |
| 4844 | end |
| 4845 | if or or eq t 5 eq t 9 eq t 13 |
| 4846 | ret 4162877440 |
| 4847 | end |
| 4848 | if eq t 10 |
| 4849 | ret 3089135616 |
| 4850 | end |
| 4851 | if eq t 11 |
| 4852 | ret 4162877440 |
| 4853 | end |
| 4854 | ret 0 |
| 4855 | end |
| 4856 | |
| 4857 | note ---- trap list (arena group 10; no count of its own): output offset of the branch, trap code ---- |
| 4858 | global nt ulong 1 |
| 4859 | note ---- block stack (arena group 13; no depth of its own): kind (1 if, 2 else, 3 while, 4 for), branch to patch, loop head, loop |
| 4860 | note register, its type, names and held pool slots to restore at end, then-part ended (for else) ---- |
| 4861 | note brot / bkk / bkr: a for whose test moved to its latch (OM-2, lpmark / lpback): the place the latch |
| 4862 | note branches back to (0: not moved), its number K, and its K register + 1 (0 when K is the number). |
| 4863 | note cphn: the head clauses the last cp_head emitted (OM-2). |
| 4864 | global cphn ulong 1 |
| 4865 | global nb ulong 1 |
| 4866 | global curfn ulong 1 |
| 4867 | note ---- break and continue fixups (arena groups 14, 15; no count of their own): output offset of the branch, block index of the loop it leaves ---- |
| 4868 | global nbrk ulong 1 |
| 4869 | global ncont ulong 1 |
| 4870 | fn dcat_w code ulong to void |
| 4871 | if or or eq code 4 eq code 6 eq code 16 |
| 4872 | mputw 9104236865280339 7 |
| 4873 | ret |
| 4874 | end |
| 4875 | if or or eq code 7 eq code 11 eq code 19 |
| 4876 | mputw 138601847124 5 |
| 4877 | ret |
| 4878 | end |
| 4879 | if or eq code 17 eq code 18 |
| 4880 | mputw 138903768134 5 |
| 4881 | ret |
| 4882 | end |
| 4883 | if or or eq code 3 eq code 10 eq code 13 |
| 4884 | mputw 138601644366 5 |
| 4885 | ret |
| 4886 | end |
| 4887 | if or or or eq code 12 eq code 14 eq code 23 eq code 24 |
| 4888 | mputw 6436850320626696515 8 |
| 4889 | mputb 32 |
| 4890 | ret |
| 4891 | end |
| 4892 | if or eq code 8 eq code 21 |
| 4893 | mputw 35481921143122 6 |
| 4894 | ret |
| 4895 | end |
| 4896 | if or or or eq code 27 eq code 28 eq code 29 eq code 30 |
| 4897 | mputw 6071768544483102531 8 |
| 4898 | mputb 32 |
| 4899 | ret |
| 4900 | end |
| 4901 | mputw 9104236865280339 7 |
| 4902 | end |
| 4903 | |
| 4904 | fn dty_w t ulong to void |
| 4905 | if eq t 1 |
| 4906 | mputw 1819242338 4 |
| 4907 | ret |
| 4908 | end |
| 4909 | if eq t 2 |
| 4910 | mputw 491260502901 5 |
| 4911 | ret |
| 4912 | end |
| 4913 | if eq t 3 |
| 4914 | mputw 128034844210037 6 |
| 4915 | ret |
| 4916 | end |
| 4917 | if eq t 4 |
| 4918 | mputw 1953393013 4 |
| 4919 | ret |
| 4920 | end |
| 4921 | if eq t 5 |
| 4922 | mputw 444234427509 5 |
| 4923 | ret |
| 4924 | end |
| 4925 | if eq t 6 |
| 4926 | mputw 1702132066 4 |
| 4927 | ret |
| 4928 | end |
| 4929 | if eq t 7 |
| 4930 | mputw 500136110195 5 |
| 4931 | ret |
| 4932 | end |
| 4933 | if eq t 8 |
| 4934 | mputw 7630441 3 |
| 4935 | ret |
| 4936 | end |
| 4937 | if eq t 9 |
| 4938 | mputw 1735290732 4 |
| 4939 | ret |
| 4940 | end |
| 4941 | if eq t 10 |
| 4942 | mputw 3289958 3 |
| 4943 | ret |
| 4944 | end |
| 4945 | if eq t 11 |
| 4946 | mputw 3421798 3 |
| 4947 | ret |
| 4948 | end |
| 4949 | if eq t 12 |
| 4950 | mputw 1684631414 4 |
| 4951 | ret |
| 4952 | end |
| 4953 | if eq t 13 |
| 4954 | mputb 113 |
| 4955 | mputb 116 |
| 4956 | mputb 121 |
| 4957 | ret |
| 4958 | end |
| 4959 | mputw 2003134838 4 |
| 4960 | end |
| 4961 | |
| 4962 | fn dname_kind i ulong to void |
| 4963 | k = ulong uchar get a_ar add get a_rb 7 i |
| 4964 | if eq k 4 |
| 4965 | mputw 119165519096935 6 |
| 4966 | ret |
| 4967 | end |
| 4968 | if eq k 5 |
| 4969 | mputw 1954047348 4 |
| 4970 | ret |
| 4971 | end |
| 4972 | if eq k 10 |
| 4973 | mputw 1819242352 4 |
| 4974 | ret |
| 4975 | end |
| 4976 | if eq k 9 |
| 4977 | mputw 500152823651 5 |
| 4978 | ret |
| 4979 | end |
| 4980 | if or eq k 2 eq k 8 |
| 4981 | mputw 2003134838 4 |
| 4982 | ret |
| 4983 | end |
| 4984 | if or eq k 3 eq k 7 |
| 4985 | mputw 1953064037 4 |
| 4986 | ret |
| 4987 | end |
| 4988 | if ne get curfn 0 0 |
| 4989 | f = sub get curfn 0 1 |
| 4990 | np = ulong uchar get a_ar add get a_rb 24 f |
| 4991 | endp = add get nglob 0 np |
| 4992 | if and ge i get nglob 0 lt i endp |
| 4993 | mputw 469786321264 5 |
| 4994 | ret |
| 4995 | end |
| 4996 | end |
| 4997 | mputw 465490374508 5 |
| 4998 | end |
| 4999 | |
| 5000 | fn mput_name w ulong to void |
| 5001 | if eq and w 255 1 |
| 5002 | k = shr w 8 |
| 5003 | o = get a_ar add get a_rb 17 k |
| 5004 | i = ulong 0 |
| 5005 | while lt i ulong uchar get a_ar add get a_rb 18 k |
| 5006 | mputb a_ib add o i |
| 5007 | i = add i 1 |
| 5008 | end |
| 5009 | ret |
| 5010 | end |
| 5011 | x = w |
| 5012 | go = true |
| 5013 | while go |
| 5014 | if eq x 0 |
| 5015 | go = false |
| 5016 | else |
| 5017 | b = and x 255 |
| 5018 | if eq b 0 |
| 5019 | go = false |
| 5020 | else |
| 5021 | mputb uchar b |
| 5022 | x = shr x 8 |
| 5023 | end |
| 5024 | end |
| 5025 | end |
| 5026 | end |
| 5027 | |
| 5028 | |
| 5029 | fn mput_tok a ulong b ulong to void |
| 5030 | if eq a b |
| 5031 | if eq get tk 0 3 |
| 5032 | mputw 6713189 3 |
| 5033 | ret |
| 5034 | end |
| 5035 | mputb 45 |
| 5036 | ret |
| 5037 | end |
| 5038 | i = a |
| 5039 | while and lt i b lt sub i a 16 |
| 5040 | c = ulong uchar and shr get a_ar shr i 3 shl and i 7 3 255 |
| 5041 | if and gt c 32 lt c 127 |
| 5042 | mputb uchar c |
| 5043 | else |
| 5044 | mputh c |
| 5045 | end |
| 5046 | i = add i 1 |
| 5047 | end |
| 5048 | end |
| 5049 | |
| 5050 | fn diagrec code ulong to void |
| 5051 | put mc 0 0 |
| 5052 | mputw 7594244768023276911 8 |
| 5053 | mputw 11207551510369 6 |
| 5054 | if eq get om2 0 0 |
| 5055 | mputw 3239279 3 |
| 5056 | mputb 32 |
| 5057 | else |
| 5058 | mputw 3304815 3 |
| 5059 | mputb 32 |
| 5060 | end |
| 5061 | dcat_w code |
| 5062 | a = get tka 0 |
| 5063 | b = get tkb 0 |
| 5064 | if le b a |
| 5065 | b = a |
| 5066 | if gt get cur 0 a |
| 5067 | b = get cur 0 |
| 5068 | end |
| 5069 | end |
| 5070 | if gt b get inlen 0 |
| 5071 | b = get inlen 0 |
| 5072 | end |
| 5073 | sa = a |
| 5074 | sb = b |
| 5075 | if ge sa get sbase 0 |
| 5076 | sa = sub sa get sbase 0 |
| 5077 | else |
| 5078 | sa = ulong 0 |
| 5079 | end |
| 5080 | if ge sb get sbase 0 |
| 5081 | sb = sub sb get sbase 0 |
| 5082 | else |
| 5083 | sb = ulong 0 |
| 5084 | end |
| 5085 | mputw 263844884595 5 |
| 5086 | mputn sa |
| 5087 | mputb 45 |
| 5088 | mputn sb |
| 5089 | mputb 32 |
| 5090 | s = get dsev 0 |
| 5091 | if eq s 0 |
| 5092 | if eq get tk 0 3 |
| 5093 | s = ulong 1 |
| 5094 | end |
| 5095 | if and eq code 22 ge get cur 0 get inlen 0 |
| 5096 | s = ulong 1 |
| 5097 | end |
| 5098 | end |
| 5099 | if eq s 1 |
| 5100 | mputw 4993454379819552329 8 |
| 5101 | mputw 2114900 3 |
| 5102 | else |
| 5103 | if eq s 2 |
| 5104 | mputw 2327894055524716117 8 |
| 5105 | else |
| 5106 | mputw 35511885252934 6 |
| 5107 | end |
| 5108 | end |
| 5109 | note Repairability is independent of prefix finality; only capacity failures are unrepairable. |
| 5110 | if or or or eq code 12 eq code 14 eq code 23 eq code 24 |
| 5111 | mputw 5929342197426179669 8 |
| 5112 | mputw 138601579073 4 |
| 5113 | else |
| 5114 | mputw 4774187554571306322 8 |
| 5115 | mputw 2114892 2 |
| 5116 | end |
| 5117 | mputw 67505686012704 6 |
| 5118 | mputn code |
| 5119 | mputw 67505853393952 6 |
| 5120 | hl = get line 0 |
| 5121 | if ne get chkmode 0 0 |
| 5122 | if gt hl get chkln 0 |
| 5123 | hl = sub hl get chkln 0 |
| 5124 | else |
| 5125 | hl = ulong 1 |
| 5126 | end |
| 5127 | end |
| 5128 | mputn hl |
| 5129 | mputw 4428273620941825312 8 |
| 5130 | dexp_w code |
| 5131 | mputw 17280399158765088 7 |
| 5132 | mput_tok a b |
| 5133 | mputb 10 |
| 5134 | mflush |
| 5135 | end |
| 5136 | |
| 5137 | fn emit_query to void |
| 5138 | put mc 0 0 |
| 5139 | mputw 8462595071175650671 8 |
| 5140 | mputw 2869133187838565 7 |
| 5141 | mputw 9071406607197043 7 |
| 5142 | if eq get curfn 0 0 |
| 5143 | mputw 7810779306727075700 8 |
| 5144 | mputb 10 |
| 5145 | mputw 7166760226508402531 8 |
| 5146 | mputw 7142830393916027764 8 |
| 5147 | mputw 8028905624785088111 8 |
| 5148 | mputw 8392569455039504738 8 |
| 5149 | mputw 2338603462594687776 8 |
| 5150 | mputw 44651802478 5 |
| 5151 | else |
| 5152 | mputw 7957695015192261990 8 |
| 5153 | mputb 10 |
| 5154 | mputw 7166760226508402531 8 |
| 5155 | mputw 2338605647353508724 8 |
| 5156 | mputw 7308332192711599721 8 |
| 5157 | mputw 7021802451731703328 8 |
| 5158 | mputw 8079585727842951280 8 |
| 5159 | mputw 9117624560546933 7 |
| 5160 | mputw 1702129518 4 |
| 5161 | in_loop = ulong 0 |
| 5162 | j = get nb 0 |
| 5163 | while and eq in_loop 0 gt j 0 |
| 5164 | j = sub j 1 |
| 5165 | if and ge a_g 49 j 3 le a_g 49 j 4 |
| 5166 | in_loop = ulong 1 |
| 5167 | end |
| 5168 | end |
| 5169 | if ne in_loop 0 |
| 5170 | mputw 7142827075067601440 8 |
| 5171 | mputw 749134030103146095 8 |
| 5172 | else |
| 5173 | mputb 10 |
| 5174 | end |
| 5175 | end |
| 5176 | mputw 2879017064423790 7 |
| 5177 | mflush |
| 5178 | i = ulong 0 |
| 5179 | go = true |
| 5180 | while go |
| 5181 | m = ulong 0 |
| 5182 | while and go lt m 999999 |
| 5183 | if ge i get nn 0 |
| 5184 | go = false |
| 5185 | else |
| 5186 | if ne get a_ar add get a_rb 3 i 0 |
| 5187 | mput_name get a_ar add get a_rb 3 i |
| 5188 | mputb 32 |
| 5189 | dty_w ulong uchar get a_ar add get a_rb 5 i |
| 5190 | mputb 32 |
| 5191 | dname_kind i |
| 5192 | mputb 10 |
| 5193 | mflush |
| 5194 | end |
| 5195 | i = add i 1 |
| 5196 | end |
| 5197 | m = add m 1 |
| 5198 | end |
| 5199 | end |
| 5200 | mputw 7957695015192261990 8 |
| 5201 | mputw 670323 3 |
| 5202 | mflush |
| 5203 | f = ulong 0 |
| 5204 | while lt f get nf 0 |
| 5205 | mputw 2125414 3 |
| 5206 | note Single caller: spell the function name here rather than spend a bootstrap function slot. |
| 5207 | o = get a_ar add get a_rb 26 f |
| 5208 | l = get a_ar add get a_rb 25 f |
| 5209 | if and ne o 0 gt l 0 |
| 5210 | i = ulong 0 |
| 5211 | while lt i l |
| 5212 | mputb a_ib add o i |
| 5213 | i = add i 1 |
| 5214 | end |
| 5215 | else |
| 5216 | mput_name get a_ar add get a_rb 21 f |
| 5217 | end |
| 5218 | mputw 544175136 4 |
| 5219 | dty_w ulong uchar get a_ar add get a_rb 23 f |
| 5220 | np = ulong uchar get a_ar add get a_rb 24 f |
| 5221 | p = ulong 0 |
| 5222 | while lt p np |
| 5223 | mputb 32 |
| 5224 | dty_w ulong a_gu 35 add mul f 6 p |
| 5225 | p = add p 1 |
| 5226 | end |
| 5227 | mputb 10 |
| 5228 | mflush |
| 5229 | f = add f 1 |
| 5230 | end |
| 5231 | mflush |
| 5232 | exit int 0 |
| 5233 | end |
| 5234 | note ======== names and functions ======== |
| 5235 | note findname: packed name -> its index + 1 among the names in scope (0 none). om4 FINDNAME. The names in |
| 5236 | note scope are 0 .. nn - 1 (clim while a pure contract is read), without nglob .. nmlo - 1 while an inlined |
| 5237 | note body hides its caller's locals. The lowest such index whose packed name is w is the answer, as the |
| 5238 | note old front-to-back scan gave; the chain of w's bucket holds every name below nn, newest first. |
| 5239 | fn findname w ulong to ulong |
| 5240 | n = get nn 0 |
| 5241 | if ne get cpure 0 0 |
| 5242 | n = get clim 0 |
| 5243 | end |
| 5244 | g = get nglob 0 |
| 5245 | lo = get nmlo 0 |
| 5246 | k = get a_ar add get a_rb 16 a_hash w get nh_b 0 |
| 5247 | best = ulong 0 |
| 5248 | go = true |
| 5249 | while go |
| 5250 | m = ulong 0 |
| 5251 | while and go lt m 999999 |
| 5252 | if eq k 0 |
| 5253 | go = false |
| 5254 | else |
| 5255 | i = sub k 1 |
| 5256 | if and lt i n eq a_g 3 i w |
| 5257 | if or lt i g ge i lo |
| 5258 | best = k |
| 5259 | end |
| 5260 | end |
| 5261 | k = a_g 15 i |
| 5262 | end |
| 5263 | m = add m 1 |
| 5264 | end |
| 5265 | end |
| 5266 | ret best |
| 5267 | end |
| 5268 | |
| 5269 | note nm_link: name i becomes the newest of its bucket's chain |
| 5270 | fn nm_link i ulong to void |
| 5271 | h = a_hash get a_ar add get a_rb 3 i get nh_b 0 |
| 5272 | put a_ar add get a_rb 15 i get a_ar add get a_rb 16 h |
| 5273 | put a_ar add get a_rb 16 h add i 1 |
| 5274 | end |
| 5275 | |
| 5276 | note nm_unlk: name i, the newest name of its chain (every name above it has left), leaves it. Should a |
| 5277 | note chain ever not start with i, the buckets are rebuilt from names 0 .. i - 1 instead. |
| 5278 | fn nm_unlk i ulong to void |
| 5279 | h = a_hash get a_ar add get a_rb 3 i get nh_b 0 |
| 5280 | if eq get a_ar add get a_rb 16 h add i 1 |
| 5281 | put a_ar add get a_rb 16 h get a_ar add get a_rb 15 i |
| 5282 | else |
| 5283 | nm_build i |
| 5284 | end |
| 5285 | end |
| 5286 | |
| 5287 | note nm_build: empty buckets, then names 0 .. n - 1 linked in order |
| 5288 | fn nm_build n ulong to void |
| 5289 | a_gzero 4 |
| 5290 | i = ulong 0 |
| 5291 | go = true |
| 5292 | while go |
| 5293 | m = ulong 0 |
| 5294 | while and go lt m 999999 |
| 5295 | if ge i n |
| 5296 | go = false |
| 5297 | else |
| 5298 | nm_link i |
| 5299 | i = add i 1 |
| 5300 | end |
| 5301 | m = add m 1 |
| 5302 | end |
| 5303 | end |
| 5304 | end |
| 5305 | |
| 5306 | note nm_set: the names in scope become 0 .. v - 1 (every write of nn but addname's): names above v leave |
| 5307 | note their chains newest first; names between nn and v (a scope given back) join them again in order |
| 5308 | fn nm_set v ulong to void |
| 5309 | n = get nn 0 |
| 5310 | if gt v 0 |
| 5311 | if ge sub v 1 get a_gp 3 |
| 5312 | a_need 3 sub v 1 |
| 5313 | end |
| 5314 | end |
| 5315 | go = true |
| 5316 | while go |
| 5317 | m = ulong 0 |
| 5318 | while and go lt m 999999 |
| 5319 | if gt n v |
| 5320 | n = sub n 1 |
| 5321 | nm_unlk n |
| 5322 | else |
| 5323 | if lt n v |
| 5324 | nm_link n |
| 5325 | n = add n 1 |
| 5326 | else |
| 5327 | go = false |
| 5328 | end |
| 5329 | end |
| 5330 | m = add m 1 |
| 5331 | end |
| 5332 | end |
| 5333 | put nn 0 v |
| 5334 | end |
| 5335 | |
| 5336 | note fn_same: function j is the name w of length l starting at input byte s (the test of the old scan) |
| 5337 | fn fn_same j ulong w ulong l ulong s ulong to ulong |
| 5338 | if ne get a_ar add get a_rb 21 j w |
| 5339 | ret 0 |
| 5340 | end |
| 5341 | if eq and w 255 1 |
| 5342 | ret 1 |
| 5343 | end |
| 5344 | fl = get a_ar add get a_rb 25 j |
| 5345 | if le l 8 |
| 5346 | if le fl 8 |
| 5347 | ret 1 |
| 5348 | end |
| 5349 | ret 0 |
| 5350 | end |
| 5351 | if ne fl l |
| 5352 | ret 0 |
| 5353 | end |
| 5354 | o = get a_ar add get a_rb 26 j |
| 5355 | k = ulong 8 |
| 5356 | while lt k l |
| 5357 | if ne a_ib add o k a_ib add s k |
| 5358 | ret 0 |
| 5359 | end |
| 5360 | k = add k 1 |
| 5361 | end |
| 5362 | ret 1 |
| 5363 | end |
| 5364 | |
| 5365 | note findfn: packed name w (first 8 bytes, or an interned long name), length l (any value up to 8 for a |
| 5366 | note short name), start s in the input (read only for a name over 8 bytes that is not interned) -> |
| 5367 | note function index + 1 (0 none), the lowest that matches, as the old scan gave. om4 FINDFN. |
| 5368 | fn findfn w ulong l ulong s ulong to ulong |
| 5369 | k = get a_ar add get a_rb 40 a_hash w get fh_b 0 |
| 5370 | best = ulong 0 |
| 5371 | go = true |
| 5372 | while go |
| 5373 | m = ulong 0 |
| 5374 | while and go lt m 999999 |
| 5375 | if eq k 0 |
| 5376 | go = false |
| 5377 | else |
| 5378 | j = sub k 1 |
| 5379 | if ne fn_same j w l s 0 |
| 5380 | best = k |
| 5381 | end |
| 5382 | k = get a_ar add get a_rb 33 j |
| 5383 | end |
| 5384 | m = add m 1 |
| 5385 | end |
| 5386 | end |
| 5387 | ret best |
| 5388 | end |
| 5389 | |
| 5390 | note fn_link: function f becomes the newest of its bucket's chain; at twice as many functions as buckets |
| 5391 | note the buckets double and every function is linked again in order |
| 5392 | fn fn_link f ulong to void |
| 5393 | h = a_hash get a_ar add get a_rb 21 f get fh_b 0 |
| 5394 | put a_ar add get a_rb 33 f get a_ar add get a_rb 40 h |
| 5395 | put a_ar add get a_rb 40 h add f 1 |
| 5396 | if ge add f 1 shl ulong 2 get fh_b 0 |
| 5397 | b = add get fh_b 0 1 |
| 5398 | put fh_b 0 b |
| 5399 | if ge sub shl ulong 1 b 1 get a_gp 8 |
| 5400 | a_need 8 sub shl ulong 1 b 1 |
| 5401 | end |
| 5402 | a_gzero 8 |
| 5403 | j = ulong 0 |
| 5404 | go = true |
| 5405 | while go |
| 5406 | m = ulong 0 |
| 5407 | while and go lt m 999999 |
| 5408 | if gt j f |
| 5409 | go = false |
| 5410 | else |
| 5411 | h = a_hash get a_ar add get a_rb 21 j b |
| 5412 | a_p 33 j a_g 40 h |
| 5413 | put a_ar add get a_rb 40 h add j 1 |
| 5414 | j = add j 1 |
| 5415 | end |
| 5416 | m = add m 1 |
| 5417 | end |
| 5418 | end |
| 5419 | end |
| 5420 | end |
| 5421 | |
| 5422 | note ln_hw: the hash word of the n input bytes at s |
| 5423 | fn ln_hw s ulong n ulong to ulong |
| 5424 | w = ulong 0 |
| 5425 | i = ulong 0 |
| 5426 | while lt i n |
| 5427 | w = add mul w 31 ulong a_ib add s i |
| 5428 | i = add i 1 |
| 5429 | end |
| 5430 | ret w |
| 5431 | end |
| 5432 | |
| 5433 | note ln_same: long name j is spelled as the n input bytes at s |
| 5434 | fn ln_same j ulong s ulong n ulong to ulong |
| 5435 | if ne ulong uchar get a_ar add get a_rb 18 j n |
| 5436 | ret 0 |
| 5437 | end |
| 5438 | o = get a_ar add get a_rb 17 j |
| 5439 | i = ulong 0 |
| 5440 | while lt i n |
| 5441 | if ne a_ib add o i a_ib add s i |
| 5442 | ret 0 |
| 5443 | end |
| 5444 | i = add i 1 |
| 5445 | end |
| 5446 | ret 1 |
| 5447 | end |
| 5448 | |
| 5449 | note ln_intern: the index of the long name spelled by the n input bytes at s. A spelling met for the first |
| 5450 | note time is appended (indices in order of first appearance, as before) and linked into its chain; at |
| 5451 | note twice as many long names as buckets the buckets double and every name is linked again. |
| 5452 | fn ln_intern s ulong n ulong to ulong |
| 5453 | h = a_hash ln_hw s n get lh_b 0 |
| 5454 | k = get a_ar add get a_rb 20 h |
| 5455 | go = true |
| 5456 | while go |
| 5457 | m = ulong 0 |
| 5458 | while and go lt m 999999 |
| 5459 | if eq k 0 |
| 5460 | go = false |
| 5461 | else |
| 5462 | j = sub k 1 |
| 5463 | if ne ln_same j s n 0 |
| 5464 | ret j |
| 5465 | end |
| 5466 | k = get a_ar add get a_rb 19 j |
| 5467 | end |
| 5468 | m = add m 1 |
| 5469 | end |
| 5470 | end |
| 5471 | k = get ln_n 0 |
| 5472 | if ge k get a_gp 5 |
| 5473 | a_need 5 k |
| 5474 | end |
| 5475 | put a_ar add get a_rb 17 k s |
| 5476 | a_pc 18 k uchar n |
| 5477 | a_p 19 k a_g 20 h |
| 5478 | put a_ar add get a_rb 20 h add k 1 |
| 5479 | put ln_n 0 add k 1 |
| 5480 | if ge add k 1 shl ulong 2 get lh_b 0 |
| 5481 | ln_rehash add k 1 |
| 5482 | end |
| 5483 | ret k |
| 5484 | end |
| 5485 | |
| 5486 | note ln_rehash: double the long-name buckets and link long names 0 .. c - 1 again in order |
| 5487 | fn ln_rehash c ulong to void |
| 5488 | b = add get lh_b 0 1 |
| 5489 | put lh_b 0 b |
| 5490 | if ge sub shl ulong 1 b 1 get a_gp 6 |
| 5491 | a_need 6 sub shl ulong 1 b 1 |
| 5492 | end |
| 5493 | a_gzero 6 |
| 5494 | j = ulong 0 |
| 5495 | go = true |
| 5496 | while go |
| 5497 | m = ulong 0 |
| 5498 | while and go lt m 999999 |
| 5499 | if ge j c |
| 5500 | go = false |
| 5501 | else |
| 5502 | h = a_hash ln_hw a_g 17 j ulong a_gu 18 j b |
| 5503 | a_p 19 j a_g 20 h |
| 5504 | put a_ar add get a_rb 20 h add j 1 |
| 5505 | j = add j 1 |
| 5506 | end |
| 5507 | m = add m 1 |
| 5508 | end |
| 5509 | end |
| 5510 | end |
| 5511 | |
| 5512 | note newname: the name must not be in use (a name in scope, a struct, layout, abstract or function): error 10 |
| 5513 | fn newname w ulong l ulong s ulong to void |
| 5514 | if le l 8 |
| 5515 | if ne kwx w 0 |
| 5516 | note d2site 49|newname: syntax: unknown or misplaced word; condition if ne kwx w 0 |
| 5517 | put d2site 0 49 |
| 5518 | fail 16 |
| 5519 | end |
| 5520 | end |
| 5521 | if ne findstruct w 0 |
| 5522 | note d2site 50|newname: duplicate name; condition if ne findstruct w 0 |
| 5523 | put d2site 0 50 |
| 5524 | fail 10 |
| 5525 | end |
| 5526 | if ne findname w 0 |
| 5527 | note d2site 51|newname: duplicate name; condition if ne findname w 0 |
| 5528 | put d2site 0 51 |
| 5529 | fail 10 |
| 5530 | end |
| 5531 | if ne findlay w 0 |
| 5532 | note d2site 52|newname: duplicate name; condition if ne findlay w 0 |
| 5533 | put d2site 0 52 |
| 5534 | fail 10 |
| 5535 | end |
| 5536 | if ne findab w 0 |
| 5537 | note d2site 53|newname: duplicate name; condition if ne findab w 0 |
| 5538 | put d2site 0 53 |
| 5539 | fail 10 |
| 5540 | end |
| 5541 | if ne findfn w l s 0 |
| 5542 | note d2site 54|newname: duplicate name; condition if ne findfn w l s 0 |
| 5543 | put d2site 0 54 |
| 5544 | fail 10 |
| 5545 | end |
| 5546 | end |
| 5547 | |
| 5548 | note addname: packed name, register, type, length, kind, address. om4 ADDNAME. The table grows with the |
| 5549 | note arena (group 3); at twice as many names as buckets the buckets double (nm_build). |
| 5550 | fn addname w ulong r ulong t ulong ln ulong k ulong a ulong to void |
| 5551 | if ne kwx w 0 |
| 5552 | note d2site 55|addname: syntax: unknown or misplaced word; condition if ne kwx w 0 |
| 5553 | put d2site 0 55 |
| 5554 | fail 16 |
| 5555 | end |
| 5556 | n = get nn 0 |
| 5557 | if ge n get a_gp 3 |
| 5558 | a_need 3 n |
| 5559 | end |
| 5560 | put a_ar add get a_rb 3 n w |
| 5561 | a_pc 4 n uchar r |
| 5562 | a_pc 5 n uchar t |
| 5563 | put a_ar add get a_rb 6 n ln |
| 5564 | a_pc 7 n uchar k |
| 5565 | put a_ar add get a_rb 8 n a |
| 5566 | a_pc 9 n 0 |
| 5567 | a_pc 12 n 0 |
| 5568 | a_pc 13 n 0 |
| 5569 | a_pc 14 n 0 |
| 5570 | a_pc 10 n 0 |
| 5571 | a_pc 11 n 0 |
| 5572 | nm_link n |
| 5573 | put nn 0 add n 1 |
| 5574 | if ge add n 1 shl ulong 2 get nh_b 0 |
| 5575 | put nh_b 0 add get nh_b 0 1 |
| 5576 | if ge sub shl ulong 1 get nh_b 0 1 get a_gp 4 |
| 5577 | a_need 4 sub shl ulong 1 get nh_b 0 1 |
| 5578 | end |
| 5579 | nm_build add n 1 |
| 5580 | end |
| 5581 | end |
| 5582 | |
| 5583 | note ======== registers and words ======== |
| 5584 | note alloc: the next free register of the pool (after the parameters); error 12 when none is left |
| 5585 | fn alloc to ulong |
| 5586 | i = add get npar 0 get nslot 0 |
| 5587 | if ge i 16 |
| 5588 | note d2site 56|alloc: register pool exhausted; condition if ge i 16 |
| 5589 | put d2site 0 56 |
| 5590 | fail 12 |
| 5591 | end |
| 5592 | put vsl i 0 |
| 5593 | put nslot 0 add get nslot 0 1 |
| 5594 | ret poolc i |
| 5595 | end |
| 5596 | |
| 5597 | note destreg: d, or a new temporary when d is 255 |
| 5598 | fn destreg d ulong to ulong |
| 5599 | if eq d 255 |
| 5600 | ret alloc |
| 5601 | end |
| 5602 | ret d |
| 5603 | end |
| 5604 | |
| 5605 | note e3: emit op | d | n << 5 | m << 16 |
| 5606 | fn e3 op ulong d ulong n ulong m ulong to void |
| 5607 | emit or or or op d shl n 5 shl m 16 |
| 5608 | end |
| 5609 | |
| 5610 | note trapsite: note the place and code of a branch to the trap stub, then emit it. trapc: B.cond, as om4. |
| 5611 | note The trap list grows with the arena (group 10); island keeps every such branch within its reach. |
| 5612 | fn trapsite w ulong code ulong to void |
| 5613 | n = get nt 0 |
| 5614 | if ge n get a_gp 10 |
| 5615 | a_need 10 n |
| 5616 | end |
| 5617 | put a_ar add get a_rb 44 n get oc 0 |
| 5618 | put a_ar add get a_rb 45 n code |
| 5619 | put nt 0 add n 1 |
| 5620 | emit w |
| 5621 | if eq get om2m 0 1 |
| 5622 | siterec |
| 5623 | end |
| 5624 | end |
| 5625 | |
| 5626 | fn trapc cc ulong code ulong to void |
| 5627 | if ne get xtarget 0 0 |
| 5628 | xtrap cc code |
| 5629 | ret |
| 5630 | end |
| 5631 | trapsite or 1409286144 cc code |
| 5632 | end |
| 5633 | |
| 5634 | fn rdword at ulong to ulong |
| 5635 | a = ulong a_ob at |
| 5636 | b = shl ulong a_ob add at 1 8 |
| 5637 | c = shl ulong a_ob add at 2 16 |
| 5638 | d = shl ulong a_ob add at 3 24 |
| 5639 | ret or or or a b c d |
| 5640 | end |
| 5641 | |
| 5642 | fn wrword at ulong w ulong to void |
| 5643 | a_bput 1 at uchar and w 255 |
| 5644 | a_bput 1 add at 1 uchar and shr w 8 255 |
| 5645 | a_bput 1 add at 2 uchar and shr w 16 255 |
| 5646 | a_bput 1 add at 3 uchar and shr w 24 255 |
| 5647 | end |
| 5648 | |
| 5649 | note bdisp: the checked word distance from a branch at `at` to `target` for its signed w-bit word field: |
| 5650 | note w 19 for B.cond / CBZ / CBNZ (C6.2.34, C6.2.78, C6.2.77), w 26 for B (C6.2.35) and BL. The |
| 5651 | note target must be word aligned and at most 2^(w-1) - 1 words forward or 2^(w-1) words back (w 19: 1048572 |
| 5652 | note bytes forward, 1048576 back; w 26: 134217724 forward, 134217728 back), else error 24 before any |
| 5653 | note artifact is accepted. Returns the distance masked to w bits. |
| 5654 | fn bdisp at ulong target ulong w ulong to ulong |
| 5655 | diff = sub target at |
| 5656 | if ne and diff 3 0 |
| 5657 | note d2site 57|bdisp: AArch64 branch displacement out of range; condition if ne and diff 3 0 |
| 5658 | put d2site 0 57 |
| 5659 | fail 24 |
| 5660 | end |
| 5661 | span = shl ulong 1 add w 1 |
| 5662 | if and gt diff sub span 4 lt diff sub ulong 0 span |
| 5663 | note d2site 58|bdisp: AArch64 branch displacement out of range; condition if and gt diff sub span 4 lt diff sub ulong 0 span |
| 5664 | put d2site 0 58 |
| 5665 | fail 24 |
| 5666 | end |
| 5667 | ret and shr diff 2 sub shl ulong 1 w 1 |
| 5668 | end |
| 5669 | |
| 5670 | note patch19: the word distance from a B.cond / CBZ / CBNZ at `at` to `target`, into bits 5..23 |
| 5671 | fn patch19 at ulong target ulong to void |
| 5672 | if ne get xtarget 0 0 |
| 5673 | xpatch at target |
| 5674 | if eq target get oc 0 |
| 5675 | put tgoc 0 target |
| 5676 | end |
| 5677 | ret |
| 5678 | end |
| 5679 | d = bdisp at target 19 |
| 5680 | wrword at or rdword at shl d 5 |
| 5681 | if eq target get oc 0 |
| 5682 | put tgoc 0 target |
| 5683 | end |
| 5684 | end |
| 5685 | |
| 5686 | note patch26: the word distance from a B at `at` to `target`, into bits 0..25, checked by bdisp. The output |
| 5687 | note grows with the arena, whose 2^27 bytes equal the reach of B and BL, so a legal unit stays in reach; the |
| 5688 | note check keeps a wrong B from ever being written (error 24, the ISA's boundary) if the arena grows. |
| 5689 | fn patch26 at ulong target ulong to void |
| 5690 | if ne get xtarget 0 0 |
| 5691 | xpatch at target |
| 5692 | if eq target get oc 0 |
| 5693 | put tgoc 0 target |
| 5694 | end |
| 5695 | ret |
| 5696 | end |
| 5697 | d = bdisp at target 26 |
| 5698 | wrword at or rdword at d |
| 5699 | if eq target get oc 0 |
| 5700 | put tgoc 0 target |
| 5701 | end |
| 5702 | end |
| 5703 | |
| 5704 | note back: emit B to an earlier place (C6.2.35) |
| 5705 | fn back addr ulong to void |
| 5706 | if ne get xtarget 0 0 |
| 5707 | p = xbranch 14 |
| 5708 | xpatch p addr |
| 5709 | ret |
| 5710 | end |
| 5711 | emit or 335544320 bdisp get oc 0 addr 26 |
| 5712 | end |
| 5713 | |
| 5714 | note matconst: put a 64-bit value in register r: MOVZ (C6.2.285) or, for a value with the top bit set, |
| 5715 | note MOVN (C6.2.284) with the first halfword that differs from the fill, then MOVK (C6.2.283) for each |
| 5716 | note other such halfword. om4 MATCONST. |
| 5717 | fn matconst r ulong v ulong to void |
| 5718 | if ne get xtarget 0 0 |
| 5719 | ximm 0 v |
| 5720 | xstore 0 r |
| 5721 | ret |
| 5722 | end |
| 5723 | fill = ulong 0 |
| 5724 | mop = ulong 3531603968 |
| 5725 | if ne shr v 63 0 |
| 5726 | fill = ulong 65535 |
| 5727 | mop = ulong 2457862144 |
| 5728 | end |
| 5729 | started = false |
| 5730 | hw = ulong 0 |
| 5731 | while lt hw 4 |
| 5732 | h = and shr v shl hw 4 65535 |
| 5733 | if ne h fill |
| 5734 | if started |
| 5735 | emit or or or 4068474880 shl h 5 shl hw 21 r |
| 5736 | else |
| 5737 | emit or or or mop shl xor h fill 5 shl hw 21 r |
| 5738 | started = true |
| 5739 | end |
| 5740 | end |
| 5741 | hw = add hw 1 |
| 5742 | end |
| 5743 | if not started |
| 5744 | emit or mop r |
| 5745 | end |
| 5746 | end |
| 5747 | |
| 5748 | note canon: u8/u16/u32 UBFM Xr, Xr, #0, #w-1 (C6.2.487); i8/i16/i32 SBFM (C6.2.355); else nothing |
| 5749 | fn canon r ulong t ulong to void |
| 5750 | canonto r r t |
| 5751 | end |
| 5752 | |
| 5753 | note canonto: canon of Xn written to Xd (the same UBFM / SBFM with Rd = d, Rn = n) |
| 5754 | fn canonto d ulong n ulong t ulong to void |
| 5755 | if ne get xtarget 0 0 |
| 5756 | xload 0 n |
| 5757 | xcanrax t |
| 5758 | xstore 0 d |
| 5759 | ret |
| 5760 | end |
| 5761 | if lt t 2 |
| 5762 | ret |
| 5763 | end |
| 5764 | if eq t 5 |
| 5765 | ret |
| 5766 | end |
| 5767 | if eq t 9 |
| 5768 | ret |
| 5769 | end |
| 5770 | base = ulong 3544186880 |
| 5771 | if gt t 5 |
| 5772 | base = ulong 2470445056 |
| 5773 | end |
| 5774 | emit or or or base shl sub twid t 1 10 d shl n 5 |
| 5775 | end |
| 5776 | |
| 5777 | note chkext: CMP Xr, Wr, SXTB/SXTH/SXTW (SUBS extended, C6.2.463), then B.NE trap code |
| 5778 | fn chkext r ulong t ulong code ulong to void |
| 5779 | if ne get xtarget 0 0 |
| 5780 | xext r t code |
| 5781 | ret |
| 5782 | end |
| 5783 | emit or or or 3944742943 shl sub t 2 13 shl r 16 shl r 5 |
| 5784 | trapc 1 code |
| 5785 | end |
| 5786 | |
| 5787 | note range: error 8 unless v is a value of type t; big = the number was written as 2^63 or more |
| 5788 | fn range v ulong t ulong big ulong to void |
| 5789 | w = twid t |
| 5790 | if eq w 64 |
| 5791 | if eq t 9 |
| 5792 | if ne big 0 |
| 5793 | note d2site 59|range: number out of range for its type or place; condition if ne big 0 |
| 5794 | put d2site 0 59 |
| 5795 | fail 8 |
| 5796 | end |
| 5797 | ret |
| 5798 | end |
| 5799 | if ne big 0 |
| 5800 | ret |
| 5801 | end |
| 5802 | if ne shr v 63 0 |
| 5803 | note d2site 60|range: number out of range for its type or place; condition if ne shr v 63 0 |
| 5804 | put d2site 0 60 |
| 5805 | fail 8 |
| 5806 | end |
| 5807 | ret |
| 5808 | end |
| 5809 | if ne big 0 |
| 5810 | note d2site 61|range: number out of range for its type or place; condition if ne big 0 |
| 5811 | put d2site 0 61 |
| 5812 | fail 8 |
| 5813 | end |
| 5814 | lim = shl ulong 1 w |
| 5815 | if lt t 6 |
| 5816 | if ge v lim |
| 5817 | note d2site 62|range: number out of range for its type or place; condition if ge v lim |
| 5818 | put d2site 0 62 |
| 5819 | fail 8 |
| 5820 | end |
| 5821 | ret |
| 5822 | end |
| 5823 | half = shr lim 1 |
| 5824 | if ge add v half lim |
| 5825 | note d2site 63|range: number out of range for its type or place; condition if ge add v half lim |
| 5826 | put d2site 0 63 |
| 5827 | fail 8 |
| 5828 | end |
| 5829 | end |
| 5830 | |
| 5831 | note cset: CSET Xr, cond = CSINC Xr, XZR, XZR, opposite cond (C6.2.141) |
| 5832 | fn cset r ulong cc ulong to void |
| 5833 | if ne get xtarget 0 0 |
| 5834 | xb 15 add 144 xcc cc 192 |
| 5835 | xb 72 15 182 |
| 5836 | emitb 192 |
| 5837 | xstore 0 r |
| 5838 | ret |
| 5839 | end |
| 5840 | emit or or 2594113504 r shl xor cc 1 12 |
| 5841 | end |
| 5842 | |
| 5843 | note force: put a value (kind 1 register, 3 number, 4 flags, 9 float in a twin: FMOV Xr, Dn) in register |
| 5844 | note r; a bare number is error 11 |
| 5845 | fn force k ulong v ulong t ulong r ulong to void |
| 5846 | if ne get xtarget 0 0 |
| 5847 | if eq k 1 |
| 5848 | xload 0 v |
| 5849 | xstore 0 r |
| 5850 | ret |
| 5851 | end |
| 5852 | end |
| 5853 | if eq k 1 |
| 5854 | if ne v r |
| 5855 | emit or or 2852127712 r shl v 16 |
| 5856 | end |
| 5857 | ret |
| 5858 | end |
| 5859 | if or eq k 3 eq k 7 |
| 5860 | matconst r v |
| 5861 | ret |
| 5862 | end |
| 5863 | if eq k 4 |
| 5864 | cset r v |
| 5865 | ret |
| 5866 | end |
| 5867 | if eq k 9 |
| 5868 | fv2x t vtw v r |
| 5869 | ret |
| 5870 | end |
| 5871 | note d2site 64|force: bare number without a type from its context |
| 5872 | put d2site 0 64 |
| 5873 | fail 11 |
| 5874 | end |
| 5875 | |
| 5876 | note matreg: a register holding the value |
| 5877 | fn matreg k ulong v ulong t ulong to ulong |
| 5878 | if eq k 1 |
| 5879 | ret v |
| 5880 | end |
| 5881 | if eq k 9 |
| 5882 | fv2x t vtw v v |
| 5883 | ret v |
| 5884 | end |
| 5885 | r = alloc |
| 5886 | force k v t r |
| 5887 | ret r |
| 5888 | end |
| 5889 | |
| 5890 | note spop: ADD (C6.2.5) / SUB (C6.2.457) SP, SP by a multiple of 16 below 2^24: low 12 bits, then the |
| 5891 | note high 12 bits LSL 12; nothing for a zero part |
| 5892 | fn spop base ulong bytes ulong to void |
| 5893 | lo = and bytes 4095 |
| 5894 | if ne lo 0 |
| 5895 | emit or or base 1023 shl lo 10 |
| 5896 | end |
| 5897 | hi = and shr bytes 12 4095 |
| 5898 | if ne hi 0 |
| 5899 | emit or or base 4195327 shl hi 10 |
| 5900 | end |
| 5901 | end |
| 5902 | |
| 5903 | note spadd and spsub move SP for a transient push (a save area, a host word's private buffer) and keep |
| 5904 | note osp, the bytes of transient push live at this point of the emitted code, and osmax, its largest value |
| 5905 | note in the function. A native object records stkbytes + osmax as the function's own stack, so the |
| 5906 | note module linker's whole-program stack proof covers every push. A pop larger than osp sets osbad; |
| 5907 | note an object function with osbad set, or osp not 0 at its end, is refused (fnend), never under-reported. |
| 5908 | fn spadd bytes ulong to void |
| 5909 | if lt get osp 0 bytes |
| 5910 | put osbad 0 1 |
| 5911 | put osp 0 0 |
| 5912 | else |
| 5913 | put osp 0 sub get osp 0 bytes |
| 5914 | end |
| 5915 | if ne get xtarget 0 0 |
| 5916 | xsp 0 bytes |
| 5917 | ret |
| 5918 | end |
| 5919 | spop 2432696320 bytes |
| 5920 | end |
| 5921 | |
| 5922 | fn spsub bytes ulong to void |
| 5923 | put osp 0 add get osp 0 bytes |
| 5924 | if gt get osp 0 get osmax 0 |
| 5925 | put osmax 0 get osp 0 |
| 5926 | end |
| 5927 | if ne get xtarget 0 0 |
| 5928 | xsp 1 bytes |
| 5929 | ret |
| 5930 | end |
| 5931 | spop 3506438144 bytes |
| 5932 | end |
| 5933 | |
| 5934 | note spaddk and spsubk move SP for the frame (local arrays and structs), which stkbytes counts and epi |
| 5935 | note gives back; they leave osp alone. |
| 5936 | fn spaddk bytes ulong to void |
| 5937 | if ne get xtarget 0 0 |
| 5938 | xsp 0 bytes |
| 5939 | ret |
| 5940 | end |
| 5941 | spop 2432696320 bytes |
| 5942 | end |
| 5943 | |
| 5944 | fn spsubk bytes ulong to void |
| 5945 | if ne get xtarget 0 0 |
| 5946 | xsp 1 bytes |
| 5947 | ret |
| 5948 | end |
| 5949 | spop 3506438144 bytes |
| 5950 | end |
| 5951 | |
| 5952 | note stkchk: program mode only: CMP SP, X28 (C6.2.463); B.LO trap 6 |
| 5953 | fn stkchk to void |
| 5954 | if ne get xtarget 0 0 |
| 5955 | ret |
| 5956 | end |
| 5957 | if ne get progmode 0 0 |
| 5958 | emit 3946603519 |
| 5959 | trapc 3 6 |
| 5960 | end |
| 5961 | end |
| 5962 | |
| 5963 | note epi: give back the stack of the local arrays, then RET (C6.2.338) |
| 5964 | fn epi to void |
| 5965 | if ne get xtarget 0 0 |
| 5966 | xload 0 0 |
| 5967 | emitb 201 |
| 5968 | emitb 195 |
| 5969 | ret |
| 5970 | end |
| 5971 | spaddk get stkbytes 0 |
| 5972 | emit 3596551104 |
| 5973 | end |
| 5974 | |
| 5975 | fn dead1 to void |
| 5976 | put dead 0 1 |
| 5977 | end |
| 5978 | |
| 5979 | note pushb / pushnh: open a block (om4 PUSHB, split in two because a call takes at most 6 values). The |
| 5980 | note block stack grows with the arena (group 13). bk0 / bc0: the break and continue counts when it opened, |
| 5981 | note so a loop's end patches only its own (s_end) and gives their entries back. |
| 5982 | fn pushb br ulong k ulong head ulong reg ulong ty ulong to void |
| 5983 | n = get nb 0 |
| 5984 | if ge n get a_gp 13 |
| 5985 | a_need 13 n |
| 5986 | end |
| 5987 | put a_ar add get a_rb 60 n get nbrk 0 |
| 5988 | put a_ar add get a_rb 61 n get ncont 0 |
| 5989 | put a_ar add get a_rb 49 n k |
| 5990 | put a_ar add get a_rb 50 n br |
| 5991 | put a_ar add get a_rb 51 n head |
| 5992 | put a_ar add get a_rb 52 n reg |
| 5993 | put a_ar add get a_rb 53 n ty |
| 5994 | put a_ar add get a_rb 56 n 0 |
| 5995 | put a_ar add get a_rb 57 n 0 |
| 5996 | put nb 0 add n 1 |
| 5997 | note fz_push / fz_else / fz_join: the sets when block n opens; at its else (the then sets kept, the |
| 5998 | note opening sets back); at its end (kind k: 1 if, 2 else, 3 while, 4 for) |
| 5999 | j = ulong 0 |
| 6000 | while lt j get fz_n 0 |
| 6001 | a_p 68 add mul n 16 j get fz_cur j |
| 6002 | j = add j 1 |
| 6003 | end |
| 6004 | end |
| 6005 | |
| 6006 | fn pushnh names ulong hd ulong to void |
| 6007 | n = sub get nb 0 1 |
| 6008 | put a_ar add get a_rb 54 n names |
| 6009 | put a_ar add get a_rb 55 n hd |
| 6010 | end |
| 6011 | |
| 6012 | note ======== small readers ======== |
| 6013 | fn elemtype t ulong to void |
| 6014 | if lt t 2 |
| 6015 | note d2site 65|elemtype: word or declaration in a place that does not allow it; condition if lt t 2 |
| 6016 | put d2site 0 65 |
| 6017 | fail 9 |
| 6018 | end |
| 6019 | if ge t 64 |
| 6020 | note d2site 66|elemtype: type mismatch; condition if ge t 64 |
| 6021 | put d2site 0 66 |
| 6022 | fail 7 |
| 6023 | end |
| 6024 | end |
| 6025 | |
| 6026 | note arrlen: an array length 1 .. 16777216 (error 8 below, 23 above, 23 when written as 2^63 or more) |
| 6027 | fn arrlen v ulong to void |
| 6028 | if ne get tbig 0 0 |
| 6029 | note d2site 67|arrlen: size capacity; condition if ne get tbig 0 0 |
| 6030 | put d2site 0 67 |
| 6031 | fail 23 |
| 6032 | end |
| 6033 | if or eq v 0 ne shr v 63 0 |
| 6034 | note d2site 68|arrlen: number out of range for its type or place; condition if or eq v 0 ne shr v 63 0 |
| 6035 | put d2site 0 68 |
| 6036 | fail 8 |
| 6037 | end |
| 6038 | if gt v 16777216 |
| 6039 | note d2site 69|arrlen: size capacity; condition if gt v 16777216 |
| 6040 | put d2site 0 69 |
| 6041 | fail 23 |
| 6042 | end |
| 6043 | end |
| 6044 | |
| 6045 | note lenval: an array length, loop bound or trap code token: a number, or an integer constant name (kind 9). |
| 6046 | note A name that is not an integer constant is error 16. When the line ends it is error eolc: 16 for a pool, |
| 6047 | note a new array or a parameter written without its length (OMEGESE s.7, as om4), 4 for trap and bound. |
| 6048 | fn lenval eolc ulong to ulong |
| 6049 | tok |
| 6050 | k = get tk 0 |
| 6051 | if eq k 0 |
| 6052 | note d2site 70|lenval: line ended before the required array expression; condition if eq k 0 |
| 6053 | put d2site 0 70 |
| 6054 | fail eolc |
| 6055 | end |
| 6056 | if eq k 2 |
| 6057 | ret get tw 0 |
| 6058 | end |
| 6059 | if eq k 1 |
| 6060 | if le get tl 0 63 |
| 6061 | e = findname get tw 0 |
| 6062 | if ne e 0 |
| 6063 | if eq uchar get a_ar add get a_rb 7 sub e 1 9 |
| 6064 | t = ulong uchar get a_ar add get a_rb 5 sub e 1 |
| 6065 | if ge t 10 |
| 6066 | note d2site 71|lenval: syntax: unknown or misplaced word; condition if ge t 10 |
| 6067 | put d2site 0 71 |
| 6068 | fail 16 |
| 6069 | end |
| 6070 | put tbig 0 0 |
| 6071 | ret get a_ar add get a_rb 8 sub e 1 |
| 6072 | end |
| 6073 | end |
| 6074 | end |
| 6075 | end |
| 6076 | note d2site 72|lenval: syntax: unknown or misplaced word |
| 6077 | put d2site 0 72 |
| 6078 | fail 16 |
| 6079 | ret 0 |
| 6080 | end |
| 6081 | |
| 6082 | note typeword: read a type name -> 1..9 |
| 6083 | fn typeword to ulong |
| 6084 | put dexp 0 2 |
| 6085 | tok |
| 6086 | k = get tk 0 |
| 6087 | if eq k 0 |
| 6088 | note d2site 73|typeword: the line ends where a word or value is needed; condition if eq k 0 |
| 6089 | put d2site 0 73 |
| 6090 | fail 4 |
| 6091 | end |
| 6092 | if ne k 1 |
| 6093 | note d2site 74|typeword: syntax: unknown or misplaced word; condition if ne k 1 |
| 6094 | put d2site 0 74 |
| 6095 | fail 16 |
| 6096 | end |
| 6097 | if gt get tl 0 8 |
| 6098 | note d2site 75|typeword: syntax: unknown or misplaced word; condition if gt get tl 0 8 |
| 6099 | put d2site 0 75 |
| 6100 | fail 16 |
| 6101 | end |
| 6102 | c = kw get tw 0 |
| 6103 | if eq c 0 |
| 6104 | a = findab get tw 0 |
| 6105 | if ne a 0 |
| 6106 | ret add a 63 |
| 6107 | end |
| 6108 | note d2site 76|typeword: syntax: unknown or misplaced word; condition if eq c 0 |
| 6109 | put d2site 0 76 |
| 6110 | unkfail 16 |
| 6111 | end |
| 6112 | if eq c 76 |
| 6113 | note d2site 77|typeword: word or declaration in a place that does not allow it; condition if eq c 76 |
| 6114 | put d2site 0 77 |
| 6115 | fail 9 |
| 6116 | end |
| 6117 | if or eq c 88 eq c 89 |
| 6118 | if ne get irmode 0 0 |
| 6119 | note d2site 78|typeword: word or declaration in a place that does not allow it; condition if ne get irmode 0 0 |
| 6120 | put d2site 0 78 |
| 6121 | fail 9 |
| 6122 | end |
| 6123 | end |
| 6124 | if eq c 88 |
| 6125 | ret 10 |
| 6126 | end |
| 6127 | if eq c 89 |
| 6128 | ret 11 |
| 6129 | end |
| 6130 | if eq c 223 |
| 6131 | ret 13 |
| 6132 | end |
| 6133 | if gt sub c 1 8 |
| 6134 | note d2site 79|typeword: syntax: unknown or misplaced word; condition if gt sub c 1 8 |
| 6135 | put d2site 0 79 |
| 6136 | fail 16 |
| 6137 | end |
| 6138 | ret c |
| 6139 | end |
| 6140 | |
| 6141 | note eol: the line must end here |
| 6142 | fn eol to void |
| 6143 | put dexp 0 6 |
| 6144 | tok |
| 6145 | k = get tk 0 |
| 6146 | if and ne k 0 ne k 3 |
| 6147 | note d2site 80|eol: extra words after a complete statement; condition if and ne k 0 ne k 3 |
| 6148 | put d2site 0 80 |
| 6149 | fail 5 |
| 6150 | end |
| 6151 | end |
| 6152 | |
| 6153 | note arrname: read an array name -> its index + 1. pk 1 where a run-time pool may be named (get, put, len, |
| 6154 | note read, write, part (then error 19), enlarge); with pk 0 a pool is error 7 (every host word, mcopy, ...) |
| 6155 | fn arrname pk ulong to ulong |
| 6156 | put dexp 0 3 |
| 6157 | tok |
| 6158 | k = get tk 0 |
| 6159 | if eq k 0 |
| 6160 | note d2site 81|arrname: the line ends where a word or value is needed; condition if eq k 0 |
| 6161 | put d2site 0 81 |
| 6162 | fail 4 |
| 6163 | end |
| 6164 | if eq k 3 |
| 6165 | note d2site 82|arrname: the line ends where a word or value is needed; condition if eq k 3 |
| 6166 | put d2site 0 82 |
| 6167 | fail 4 |
| 6168 | end |
| 6169 | if ne k 1 |
| 6170 | note d2site 83|arrname: syntax: unknown or misplaced word; condition if ne k 1 |
| 6171 | put d2site 0 83 |
| 6172 | fail 16 |
| 6173 | end |
| 6174 | if gt get tl 0 63 |
| 6175 | note d2site 84|arrname: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63 |
| 6176 | put d2site 0 84 |
| 6177 | fail 13 |
| 6178 | end |
| 6179 | if eq kw get tw 0 193 |
| 6180 | note d2site 85|arrname: word or declaration in a place that does not allow it; condition if eq kw get tw 0 193 |
| 6181 | put d2site 0 85 |
| 6182 | fail 9 |
| 6183 | end |
| 6184 | e = findname get tw 0 |
| 6185 | if eq e 0 |
| 6186 | note d2site 86|arrname: unknown name or field, or a word this mode does not provide; condition if eq e 0 |
| 6187 | put d2site 0 86 |
| 6188 | fail 3 |
| 6189 | end |
| 6190 | k = ulong uchar get a_ar add get a_rb 7 sub e 1 |
| 6191 | if eq k 0 |
| 6192 | note d2site 87|arrname: type mismatch; condition if eq k 0 |
| 6193 | put d2site 0 87 |
| 6194 | fail 7 |
| 6195 | end |
| 6196 | if eq k 10 |
| 6197 | if eq pk 0 |
| 6198 | note d2site 88|arrname: type mismatch; condition if eq pk 0 |
| 6199 | put d2site 0 88 |
| 6200 | fail 7 |
| 6201 | end |
| 6202 | end |
| 6203 | ret e |
| 6204 | end |
| 6205 | |
| 6206 | note topname: read a new name for a global or a text -> its packed word |
| 6207 | fn topname to ulong |
| 6208 | tok |
| 6209 | if ne get tk 0 1 |
| 6210 | note d2site 89|topname: syntax: unknown or misplaced word; condition if ne get tk 0 1 |
| 6211 | put d2site 0 89 |
| 6212 | fail 16 |
| 6213 | end |
| 6214 | if gt get tl 0 63 |
| 6215 | note d2site 90|topname: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63 |
| 6216 | put d2site 0 90 |
| 6217 | fail 13 |
| 6218 | end |
| 6219 | w = get tw 0 |
| 6220 | if ne kw w 0 |
| 6221 | note d2site 91|topname: syntax: unknown or misplaced word; condition if ne kw w 0 |
| 6222 | put d2site 0 91 |
| 6223 | fail 16 |
| 6224 | end |
| 6225 | newname w get tl 0 get ts 0 |
| 6226 | ret w |
| 6227 | end |
| 6228 | |
| 6229 | note ---- value results (om4 x0 kind 1 register / 2 bare number / 3 typed number / 4 flags, x1 register, |
| 6230 | note number or condition, x2 type). fr: 32 cells per value nesting depth (arena group 18, 0..32768): 0..5 the two operands of |
| 6231 | note a binary op (kind, value, type each), 8..25 a call's arguments (kind, value, array name each) ---- |
| 6232 | global rk ulong 1 |
| 6233 | global rv ulong 1 |
| 6234 | global rt ulong 1 |
| 6235 | global depth ulong 1 |
| 6236 | |
| 6237 | note ======== BINOP (om4 BINOP and its BO_* parts): two values already read, types settled ======== |
| 6238 | note bo_w3: emit fx | rd | ra << 5 | (imm12 << 10, or rb << 16) |
| 6239 | fn bo_w3 fx ulong rd ulong ra ulong rb ulong imm ulong to void |
| 6240 | if ne imm 0 |
| 6241 | emit or or or fx rd shl ra 5 shl rb 10 |
| 6242 | else |
| 6243 | emit or or or fx rd shl ra 5 shl rb 16 |
| 6244 | end |
| 6245 | end |
| 6246 | |
| 6247 | note bo_fix: after a 64-bit op on rd: u8/u16/u32 wrap (canon), i8/i16/i32 overflow check (trap 1) |
| 6248 | fn bo_fix rd ulong ty ulong to void |
| 6249 | if lt ty 6 |
| 6250 | canon rd ty |
| 6251 | ret |
| 6252 | end |
| 6253 | if eq ty 9 |
| 6254 | ret |
| 6255 | end |
| 6256 | chkext rd ty 1 |
| 6257 | end |
| 6258 | |
| 6259 | note bo_schk: a shift amount in a register must be below the width: CMP Xb, #w; B.HS trap 7 |
| 6260 | fn bo_schk ty ulong rb ulong to void |
| 6261 | if ne get xtarget 0 0 |
| 6262 | xload 0 rb |
| 6263 | ximm 1 twid ty |
| 6264 | xrr 57 0 1 |
| 6265 | xtrap 2 7 |
| 6266 | ret |
| 6267 | end |
| 6268 | emit or or 4043309087 shl twid ty 10 shl rb 5 |
| 6269 | trapc 2 7 |
| 6270 | end |
| 6271 | |
| 6272 | note add, sub: u32 the 32-bit form; i64 ADDS/SUBS + B.VS trap 1; others 64-bit then bo_fix (om4 BO_ADD) |
| 6273 | fn bo_add op ulong ty ulong ra ulong rb ulong imm ulong rd ulong to void |
| 6274 | if ne get xtarget 0 0 |
| 6275 | xarith op ty ra rb imm rd |
| 6276 | ret |
| 6277 | end |
| 6278 | fx = ulong 2332033024 |
| 6279 | if eq op 34 |
| 6280 | fx = ulong 3405774848 |
| 6281 | end |
| 6282 | if ne imm 0 |
| 6283 | fx = ulong 2432696320 |
| 6284 | if eq op 34 |
| 6285 | fx = ulong 3506438144 |
| 6286 | end |
| 6287 | end |
| 6288 | if eq ty 4 |
| 6289 | bo_w3 xor fx 2147483648 rd ra rb imm |
| 6290 | ret |
| 6291 | end |
| 6292 | if eq ty 9 |
| 6293 | bo_w3 or fx 536870912 rd ra rb imm |
| 6294 | trapc 6 1 |
| 6295 | ret |
| 6296 | end |
| 6297 | if eq ty 13 |
| 6298 | bo_w3 or fx 536870912 rd ra rb imm |
| 6299 | if eq op 34 |
| 6300 | trapc 3 1 |
| 6301 | else |
| 6302 | trapc 2 1 |
| 6303 | end |
| 6304 | ret |
| 6305 | end |
| 6306 | bo_w3 fx rd ra rb imm |
| 6307 | bo_fix rd ty |
| 6308 | end |
| 6309 | |
| 6310 | note mul: i64 SMULH t, MUL, CMP t, rd, ASR #63, B.NE trap 1 (om4 BO_MUL) |
| 6311 | fn bo_mul ty ulong ra ulong rb ulong rd ulong to void |
| 6312 | if ne get xtarget 0 0 |
| 6313 | xarith 35 ty ra rb 0 rd |
| 6314 | ret |
| 6315 | end |
| 6316 | if eq ty 9 |
| 6317 | t = alloc |
| 6318 | e3 2604694528 t ra rb |
| 6319 | bo_w3 2600500224 rd ra rb 0 |
| 6320 | e3 3951098911 0 t rd |
| 6321 | trapc 1 1 |
| 6322 | ret |
| 6323 | end |
| 6324 | if eq ty 13 |
| 6325 | t = alloc |
| 6326 | e3 2613083136 t ra rb |
| 6327 | bo_w3 2600500224 rd ra rb 0 |
| 6328 | emit or 4043309087 shl t 5 |
| 6329 | trapc 1 1 |
| 6330 | ret |
| 6331 | end |
| 6332 | if eq ty 4 |
| 6333 | bo_w3 453016576 rd ra rb 0 |
| 6334 | ret |
| 6335 | end |
| 6336 | bo_w3 2600500224 rd ra rb 0 |
| 6337 | bo_fix rd ty |
| 6338 | end |
| 6339 | |
| 6340 | note div, rem (om4 BO_DIV, BO_SDIV): CBZ Xb trap 2 unless fl bit 1 (b a number other than 0); UDIV or |
| 6341 | note SDIV; rem: t = a / b, rd = a - t * b (MSUB); i64 div: CMN Xb, #1; B.NE +3; NEGS XZR, Xa; B.VS trap 1, |
| 6342 | note unless fl bit 2 (b a number other than -1) |
| 6343 | fn bo_div op ulong ty ulong ra ulong rb ulong rd ulong fl ulong to void |
| 6344 | if ne get xtarget 0 0 |
| 6345 | xdiv op ty ra rb rd fl |
| 6346 | ret |
| 6347 | end |
| 6348 | if eq and fl 1 0 |
| 6349 | trapsite or 3019898880 rb 2 |
| 6350 | end |
| 6351 | if eq op 37 |
| 6352 | t = alloc |
| 6353 | if and ge ty 6 le ty 9 |
| 6354 | e3 2596277248 t ra rb |
| 6355 | else |
| 6356 | e3 2596276224 t ra rb |
| 6357 | end |
| 6358 | e3 or 2600501248 shl ra 10 rd t rb |
| 6359 | ret |
| 6360 | end |
| 6361 | if or lt ty 6 eq ty 13 |
| 6362 | bo_w3 2596276224 rd ra rb 0 |
| 6363 | ret |
| 6364 | end |
| 6365 | if eq ty 9 |
| 6366 | if eq and fl 2 0 |
| 6367 | emit or 2969568287 shl rb 5 |
| 6368 | emit 1409286241 |
| 6369 | emit or 3942646783 shl ra 16 |
| 6370 | trapc 6 1 |
| 6371 | end |
| 6372 | end |
| 6373 | bo_w3 2596277248 rd ra rb 0 |
| 6374 | if ne ty 9 |
| 6375 | bo_fix rd ty |
| 6376 | end |
| 6377 | end |
| 6378 | |
| 6379 | note and, or, xor (om4 BO_LOG) |
| 6380 | fn bo_log op ulong ra ulong rb ulong rd ulong to void |
| 6381 | if ne get xtarget 0 0 |
| 6382 | xarith op 5 ra rb 0 rd |
| 6383 | ret |
| 6384 | end |
| 6385 | fx = ulong 2315255808 |
| 6386 | if eq op 39 |
| 6387 | fx = ulong 2852126720 |
| 6388 | end |
| 6389 | if eq op 40 |
| 6390 | fx = ulong 3388997632 |
| 6391 | end |
| 6392 | bo_w3 fx rd ra rb 0 |
| 6393 | end |
| 6394 | |
| 6395 | note bo_lsl: LSL Xd, Xn, #s as UBFM Xd, Xn, #(64-s) mod 64, #63-s |
| 6396 | fn bo_lsl ra ulong s ulong rd ulong to void |
| 6397 | if ne get xtarget 0 0 |
| 6398 | xshift 41 5 ra s 1 rd |
| 6399 | ret |
| 6400 | end |
| 6401 | r = shl and sub 64 s 63 16 |
| 6402 | r = or r shl sub 63 s 10 |
| 6403 | r = or r shl ra 5 |
| 6404 | emit or or 3544186880 r rd |
| 6405 | end |
| 6406 | |
| 6407 | note shl (om4 BO_SHL, BS_64): by a number s: UBFM Xd, Xn, #(64-s) mod 64, #63-s; by a register: the amount |
| 6408 | note check, LSLV; i64: t = a << s, X16 = t >> s arithmetic, CMP X16, Xa, B.NE trap 1, MOV Xd, Xt |
| 6409 | fn bo_shl ty ulong ra ulong rb ulong imm ulong rd ulong to void |
| 6410 | if ne get xtarget 0 0 |
| 6411 | xshift 41 ty ra rb imm rd |
| 6412 | ret |
| 6413 | end |
| 6414 | if eq ty 9 |
| 6415 | t = alloc |
| 6416 | if ne imm 0 |
| 6417 | bo_lsl ra rb t |
| 6418 | emit or or 2470509584 shl rb 16 shl t 5 |
| 6419 | else |
| 6420 | bo_schk ty rb |
| 6421 | e3 2596282368 t ra rb |
| 6422 | e3 2596284432 0 t rb |
| 6423 | end |
| 6424 | emit or 3942646303 shl ra 16 |
| 6425 | trapc 1 1 |
| 6426 | emit or or 2852127712 rd shl t 16 |
| 6427 | ret |
| 6428 | end |
| 6429 | if ne imm 0 |
| 6430 | bo_lsl ra rb rd |
| 6431 | bo_fix rd ty |
| 6432 | ret |
| 6433 | end |
| 6434 | bo_schk ty rb |
| 6435 | if eq ty 4 |
| 6436 | bo_w3 448798720 rd ra rb 0 |
| 6437 | ret |
| 6438 | end |
| 6439 | bo_w3 2596282368 rd ra rb 0 |
| 6440 | bo_fix rd ty |
| 6441 | end |
| 6442 | |
| 6443 | note shr: unsigned LSR, signed ASR; by a number UBFM / SBFM Xd, Xn, #s, #63; by a register the amount check |
| 6444 | note then LSRV / ASRV (om4 BO_SHR) |
| 6445 | fn bo_shr ty ulong ra ulong rb ulong imm ulong rd ulong to void |
| 6446 | if ne get xtarget 0 0 |
| 6447 | xshift 42 ty ra rb imm rd |
| 6448 | ret |
| 6449 | end |
| 6450 | if ne imm 0 |
| 6451 | fi = ulong 3544251392 |
| 6452 | if ge ty 6 |
| 6453 | fi = ulong 2470509568 |
| 6454 | end |
| 6455 | emit or or or fi shl rb 16 shl ra 5 rd |
| 6456 | ret |
| 6457 | end |
| 6458 | bo_schk ty rb |
| 6459 | fx = ulong 2596283392 |
| 6460 | if ge ty 6 |
| 6461 | fx = ulong 2596284416 |
| 6462 | end |
| 6463 | bo_w3 fx rd ra rb 0 |
| 6464 | end |
| 6465 | |
| 6466 | note comparisons: CMP Xa, #imm or CMP Xa, Xb; the result is the flags and a condition (om4 BO_CMP) |
| 6467 | fn bo_cmp op ulong ty ulong ra ulong rb ulong imm ulong to void |
| 6468 | if ne get xtarget 0 0 |
| 6469 | xcmp ra rb imm |
| 6470 | else |
| 6471 | if ne imm 0 |
| 6472 | emit or or 4043309087 shl rb 10 shl ra 5 |
| 6473 | else |
| 6474 | emit or or 3942645791 shl rb 16 shl ra 5 |
| 6475 | end |
| 6476 | end |
| 6477 | i = mul sub op 43 2 |
| 6478 | if and ge ty 6 le ty 9 |
| 6479 | i = add i 1 |
| 6480 | end |
| 6481 | put rk 0 4 |
| 6482 | put rv 0 conds i |
| 6483 | put rt 0 1 |
| 6484 | end |
| 6485 | |
| 6486 | note Baseline SSE2, Intel SDM MOVD/MOVQ, scalar SS/SD, UCOMIS, CVTSI and CVTT instructions. |
| 6487 | note WolframLanguageEvaluator: {2^31,2^63,2^22,2^51} -> {2147483648,9223372036854775808,4194304,2251799813685248}. |
| 6488 | note WolframLanguageEvaluator: FromDigits[#,16]& /@ {"7F800000","7FF0000000000000","7FC00000","7FF8000000000000"} |
| 6489 | note -> {2139095040,9218868437227405312,2143289344,9221120237041090560}. |
| 6490 | fn xfmask ty ulong kind ulong to ulong |
| 6491 | if eq ty 10 |
| 6492 | if eq kind 0 |
| 6493 | ret 2147483648 |
| 6494 | end |
| 6495 | if eq kind 1 |
| 6496 | ret 2147483647 |
| 6497 | end |
| 6498 | if eq kind 2 |
| 6499 | ret 4194304 |
| 6500 | end |
| 6501 | if eq kind 3 |
| 6502 | ret 2139095040 |
| 6503 | end |
| 6504 | ret 2143289344 |
| 6505 | end |
| 6506 | if eq kind 0 |
| 6507 | ret 9223372036854775808 |
| 6508 | end |
| 6509 | if eq kind 1 |
| 6510 | ret 9223372036854775807 |
| 6511 | end |
| 6512 | if eq kind 2 |
| 6513 | ret 2251799813685248 |
| 6514 | end |
| 6515 | if eq kind 3 |
| 6516 | ret 9218868437227405312 |
| 6517 | end |
| 6518 | ret 9221120237041090560 |
| 6519 | end |
| 6520 | |
| 6521 | note MOVD clears EAX's upper bits on extraction; no float sign extension. |
| 6522 | fn xfmov ty ulong op ulong vr ulong to void |
| 6523 | emitb 102 |
| 6524 | if eq ty 11 |
| 6525 | emitb 72 |
| 6526 | end |
| 6527 | xb 15 op add 192 shl vr 3 |
| 6528 | end |
| 6529 | |
| 6530 | fn xfsse ty ulong op ulong mr ulong to void |
| 6531 | if eq ty 10 |
| 6532 | emitb 243 |
| 6533 | else |
| 6534 | emitb 242 |
| 6535 | end |
| 6536 | xb 15 op mr |
| 6537 | end |
| 6538 | |
| 6539 | fn xfucom ty ulong mr ulong to void |
| 6540 | if eq ty 11 |
| 6541 | emitb 102 |
| 6542 | end |
| 6543 | xb 15 46 mr |
| 6544 | end |
| 6545 | |
| 6546 | note Raw Intel condition for parity: existing xbranch takes the A64 condition vocabulary. |
| 6547 | fn xfbranch cc ulong to ulong |
| 6548 | p = get oc 0 |
| 6549 | emitb 15 |
| 6550 | emitb uchar add 128 cc |
| 6551 | xword 0 |
| 6552 | ret p |
| 6553 | end |
| 6554 | |
| 6555 | note Leaves the raw value in RAX, magnitude in RCX, and unsigned magnitude-versus-infinity flags. |
| 6556 | fn xfclass ty ulong r ulong to void |
| 6557 | xload 0 r |
| 6558 | ximm 1 xfmask ty 1 |
| 6559 | xrr 33 1 0 |
| 6560 | ximm 2 xfmask ty 3 |
| 6561 | xrr 57 1 2 |
| 6562 | end |
| 6563 | |
| 6564 | note Arm FPProcessNaNs priority: first signaling NaN, second signaling NaN, then first quiet NaN. |
| 6565 | note minNum/maxNum additionally return the numeric argument when paired with one quiet NaN. |
| 6566 | note Return the selected-result jump for the caller to patch past its normal arithmetic. |
| 6567 | fn xfnans ty ulong a ulong b ulong num ulong d ulong to ulong |
| 6568 | note Emit shared result stubs first so each case patches immediately instead of retaining its own fixup. |
| 6569 | skip = xbranch 14 |
| 6570 | quiet = get oc 0 |
| 6571 | ximm 1 xfmask ty 2 |
| 6572 | xrr 9 0 1 |
| 6573 | store = get oc 0 |
| 6574 | xstore 0 d |
| 6575 | d = xbranch 14 |
| 6576 | xpatch skip get oc 0 |
| 6577 | xfclass ty a |
| 6578 | skip = xbranch 8 |
| 6579 | xfclass ty b |
| 6580 | bn = xbranch 8 |
| 6581 | none = xbranch 14 |
| 6582 | xpatch skip get oc 0 |
| 6583 | ximm 1 xfmask ty 2 |
| 6584 | xrr 133 0 1 |
| 6585 | p = xbranch 0 |
| 6586 | xpatch p quiet |
| 6587 | xfclass ty b |
| 6588 | skip = xbranch 9 |
| 6589 | ximm 1 xfmask ty 2 |
| 6590 | xrr 133 0 1 |
| 6591 | p = xbranch 0 |
| 6592 | xpatch p quiet |
| 6593 | xload 0 a |
| 6594 | p = xbranch 14 |
| 6595 | xpatch p store |
| 6596 | xpatch skip get oc 0 |
| 6597 | if ne num 0 |
| 6598 | xload 0 b |
| 6599 | else |
| 6600 | xload 0 a |
| 6601 | end |
| 6602 | p = xbranch 14 |
| 6603 | xpatch p store |
| 6604 | xpatch bn get oc 0 |
| 6605 | if ne num 0 |
| 6606 | ximm 1 xfmask ty 2 |
| 6607 | xrr 133 0 1 |
| 6608 | p = xbranch 0 |
| 6609 | xpatch p quiet |
| 6610 | xload 0 a |
| 6611 | p = xbranch 14 |
| 6612 | xpatch p store |
| 6613 | else |
| 6614 | p = xbranch 14 |
| 6615 | xpatch p quiet |
| 6616 | end |
| 6617 | xpatch none get oc 0 |
| 6618 | ret d |
| 6619 | end |
| 6620 | |
| 6621 | note SSE invalid arithmetic produces a negative indefinite NaN; Arm's default NaN is positive. |
| 6622 | note Operand NaNs have already bypassed arithmetic, retaining their sign and payload. |
| 6623 | fn xfdefnan ty ulong d ulong to void |
| 6624 | xfclass ty d |
| 6625 | ok = xbranch 9 |
| 6626 | ximm 0 xfmask ty 4 |
| 6627 | xstore 0 d |
| 6628 | xpatch ok get oc 0 |
| 6629 | end |
| 6630 | |
| 6631 | fn xfbin op ulong ty ulong a ulong b ulong d ulong to void |
| 6632 | nanend = xfnans ty a b 0 d |
| 6633 | f2v ty a 0 |
| 6634 | f2v ty b 1 |
| 6635 | code = ulong 89 |
| 6636 | if eq op 33 |
| 6637 | code = ulong 88 |
| 6638 | end |
| 6639 | if eq op 34 |
| 6640 | code = ulong 92 |
| 6641 | end |
| 6642 | if eq op 36 |
| 6643 | code = ulong 94 |
| 6644 | end |
| 6645 | xfsse ty code 193 |
| 6646 | fv2x ty 0 d |
| 6647 | xfdefnan ty d |
| 6648 | xpatch nanend get oc 0 |
| 6649 | end |
| 6650 | |
| 6651 | fn xfminmax c ulong ty ulong a ulong b ulong d ulong to void |
| 6652 | nanend = xfnans ty a b 1 d |
| 6653 | f2v ty a 0 |
| 6654 | f2v ty b 1 |
| 6655 | xfucom ty 193 |
| 6656 | cc = ulong 3 |
| 6657 | if eq c 94 |
| 6658 | cc = ulong 8 |
| 6659 | end |
| 6660 | takea = xbranch cc |
| 6661 | if eq c 94 |
| 6662 | cc = ulong 3 |
| 6663 | else |
| 6664 | cc = ulong 8 |
| 6665 | end |
| 6666 | takeb = xbranch cc |
| 6667 | note Equal finite operands have equal bits except signed zero: OR chooses -0, AND chooses +0. |
| 6668 | xload 0 a |
| 6669 | xload 1 b |
| 6670 | if eq c 94 |
| 6671 | xrr 33 0 1 |
| 6672 | else |
| 6673 | xrr 9 0 1 |
| 6674 | end |
| 6675 | xstore 0 d |
| 6676 | equalend = xbranch 14 |
| 6677 | xpatch takea get oc 0 |
| 6678 | xload 0 a |
| 6679 | xstore 0 d |
| 6680 | aend = xbranch 14 |
| 6681 | xpatch takeb get oc 0 |
| 6682 | xload 0 b |
| 6683 | xstore 0 d |
| 6684 | xpatch equalend get oc 0 |
| 6685 | xpatch aend get oc 0 |
| 6686 | xpatch nanend get oc 0 |
| 6687 | end |
| 6688 | |
| 6689 | note Normalize the predicate to TEST flags; callers retain the existing rk=4, rv=NE contract. |
| 6690 | fn xfcmp op ulong ty ulong a ulong b ulong to void |
| 6691 | f2v ty a 0 |
| 6692 | f2v ty b 1 |
| 6693 | xfucom ty 193 |
| 6694 | unord = xfbranch 10 |
| 6695 | cc = ulong 4 |
| 6696 | if eq op 44 |
| 6697 | cc = ulong 5 |
| 6698 | end |
| 6699 | if eq op 45 |
| 6700 | cc = ulong 2 |
| 6701 | end |
| 6702 | if eq op 46 |
| 6703 | cc = ulong 6 |
| 6704 | end |
| 6705 | if eq op 47 |
| 6706 | cc = ulong 7 |
| 6707 | end |
| 6708 | if eq op 48 |
| 6709 | cc = ulong 3 |
| 6710 | end |
| 6711 | xb 15 add 144 cc 192 |
| 6712 | done = xbranch 14 |
| 6713 | xpatch unord get oc 0 |
| 6714 | if eq op 44 |
| 6715 | ximm 0 1 |
| 6716 | else |
| 6717 | ximm 0 0 |
| 6718 | end |
| 6719 | xpatch done get oc 0 |
| 6720 | xb 72 15 182 |
| 6721 | emitb 192 |
| 6722 | xrr 133 0 0 |
| 6723 | put rk 0 4 |
| 6724 | put rv 0 1 |
| 6725 | put rt 0 1 |
| 6726 | end |
| 6727 | |
| 6728 | fn xfsito ty ulong to void |
| 6729 | if eq ty 10 |
| 6730 | emitb 243 |
| 6731 | else |
| 6732 | emitb 242 |
| 6733 | end |
| 6734 | emitb 72 |
| 6735 | xb 15 42 192 |
| 6736 | end |
| 6737 | |
| 6738 | fn xfint ft ulong tt ulong a ulong d ulong to void |
| 6739 | xload 0 a |
| 6740 | if eq ft 5 |
| 6741 | xrr 133 0 0 |
| 6742 | small = xbranch 10 |
| 6743 | note Sticky halve before signed conversion preserves nearest-even rounding for the unsigned high half. |
| 6744 | xrr 137 2 0 |
| 6745 | xb 72 209 234 |
| 6746 | ximm 1 1 |
| 6747 | xrr 33 0 1 |
| 6748 | xrr 9 0 2 |
| 6749 | xfsito tt |
| 6750 | xfsse tt 88 192 |
| 6751 | done = xbranch 14 |
| 6752 | xpatch small get oc 0 |
| 6753 | xfsito tt |
| 6754 | xpatch done get oc 0 |
| 6755 | else |
| 6756 | xfsito tt |
| 6757 | end |
| 6758 | fv2x tt 0 d |
| 6759 | end |
| 6760 | |
| 6761 | fn xfconst bits ulong to void |
| 6762 | ximm 0 bits |
| 6763 | xfmov 11 110 1 |
| 6764 | end |
| 6765 | |
| 6766 | fn xfcvtt to void |
| 6767 | emitb 242 |
| 6768 | emitb 72 |
| 6769 | xb 15 44 192 |
| 6770 | end |
| 6771 | |
| 6772 | |
| 6773 | note Widen f32 exactly, guard NaN and the destination's own bounds, then CVTT toward zero. |
| 6774 | note WolframLanguageEvaluator: Table[BitShiftLeft[1023+k,52],{k,{7,8,15,16,31,32,63,64}}] |
| 6775 | note -> {4638707616191610880,4643211215818981376,4674736413210574848,4679240012837945344,4746794007248502784,4751297606875873280,4890909195324358656,4895412794951729152}. |
| 6776 | fn xftoint ft ulong tt ulong d ulong to void |
| 6777 | n = twid tt |
| 6778 | sg = and ge tt 6 le tt 9 |
| 6779 | if eq ft 10 |
| 6780 | xfsse 10 90 192 |
| 6781 | end |
| 6782 | xfucom 11 192 |
| 6783 | nan = xfbranch 10 |
| 6784 | if sg |
| 6785 | n = sub n 1 |
| 6786 | end |
| 6787 | xfconst shl add ulong 1023 n 52 |
| 6788 | xfucom 11 193 |
| 6789 | above = xbranch 2 |
| 6790 | if sg |
| 6791 | xfconst or 9223372036854775808 shl add ulong 1023 n 52 |
| 6792 | else |
| 6793 | xfconst 0 |
| 6794 | end |
| 6795 | xfucom 11 193 |
| 6796 | below = xbranch 9 |
| 6797 | if and not sg eq n 64 |
| 6798 | xfconst 4890909195324358656 |
| 6799 | xfucom 11 193 |
| 6800 | small = xbranch 3 |
| 6801 | xfsse 11 92 193 |
| 6802 | xfcvtt |
| 6803 | ximm 1 9223372036854775808 |
| 6804 | xrr 9 0 1 |
| 6805 | done = xbranch 14 |
| 6806 | xpatch small get oc 0 |
| 6807 | xfcvtt |
| 6808 | xpatch done get oc 0 |
| 6809 | else |
| 6810 | xfcvtt |
| 6811 | end |
| 6812 | done = xbranch 14 |
| 6813 | xpatch nan get oc 0 |
| 6814 | ximm 0 0 |
| 6815 | nan = xbranch 14 |
| 6816 | xpatch above get oc 0 |
| 6817 | maxv = ulong 18446744073709551615 |
| 6818 | if sg |
| 6819 | maxv = sub shl ulong 1 n 1 |
| 6820 | else |
| 6821 | if lt n 64 |
| 6822 | maxv = sub shl ulong 1 n 1 |
| 6823 | end |
| 6824 | end |
| 6825 | ximm 0 maxv |
| 6826 | above = xbranch 14 |
| 6827 | xpatch below get oc 0 |
| 6828 | if sg |
| 6829 | ximm 0 sub ulong 0 shl ulong 1 n |
| 6830 | else |
| 6831 | ximm 0 0 |
| 6832 | end |
| 6833 | xpatch done get oc 0 |
| 6834 | xpatch nan get oc 0 |
| 6835 | xpatch above get oc 0 |
| 6836 | xstore 0 d |
| 6837 | end |
| 6838 | |
| 6839 | fn xfconv ft ulong tt ulong a ulong to ulong |
| 6840 | if or eq ft 1 eq tt 1 |
| 6841 | note d2site 92|xfconv: word or declaration in a place that does not allow it; condition if or eq ft 1 eq tt 1 |
| 6842 | put d2site 0 92 |
| 6843 | fail 9 |
| 6844 | end |
| 6845 | if or eq ft 13 eq tt 13 |
| 6846 | note d2site 93|xfconv: type mismatch; condition if or eq ft 13 eq tt 13 |
| 6847 | put d2site 0 93 |
| 6848 | fail 7 |
| 6849 | end |
| 6850 | if eq ft tt |
| 6851 | ret a |
| 6852 | end |
| 6853 | d = alloc |
| 6854 | if ge ft 10 |
| 6855 | f2v ft a 0 |
| 6856 | if ge tt 10 |
| 6857 | xfsse ft 90 192 |
| 6858 | fv2x tt 0 d |
| 6859 | else |
| 6860 | xftoint ft tt d |
| 6861 | end |
| 6862 | else |
| 6863 | xfint ft tt a d |
| 6864 | end |
| 6865 | ret d |
| 6866 | end |
| 6867 | |
| 6868 | note xfbinop: binop's float arm on x86: both operands in x registers, a compare or one SSE operation. |
| 6869 | fn xfbinop op ulong dst ulong ix ulong ty ulong to void |
| 6870 | ra = matreg a_g 77 ix a_g 77 add ix 1 ty |
| 6871 | rb = matreg a_g 77 add ix 3 a_g 77 add ix 4 ty |
| 6872 | if ge op 43 |
| 6873 | xfcmp op ty ra rb |
| 6874 | ret |
| 6875 | end |
| 6876 | if or or lt op 33 gt op 36 ge op 41 |
| 6877 | note d2site 94|xfbinop: type mismatch; condition if or or lt op 33 gt op 36 ge op 41 |
| 6878 | put d2site 0 94 |
| 6879 | fail 7 |
| 6880 | end |
| 6881 | rd = destreg dst |
| 6882 | xfbin op ty ra rb rd |
| 6883 | put rk 0 1 |
| 6884 | put rv 0 rd |
| 6885 | put rt 0 ty |
| 6886 | end |
| 6887 | |
| 6888 | note xfun1 / xfmm: fintr's and fminmax's x86 arms; the operand is in rk/rv (fminmax: the first in ak/av). |
| 6889 | fn xfun1 c ulong t ulong dst ulong to void |
| 6890 | ra = matreg get rk 0 get rv 0 t |
| 6891 | rd = destreg dst |
| 6892 | if eq c 91 |
| 6893 | nanend = xfnans t ra ra 0 rd |
| 6894 | f2v t ra 0 |
| 6895 | xfsse t 81 192 |
| 6896 | fv2x t 0 rd |
| 6897 | xfdefnan t rd |
| 6898 | xpatch nanend get oc 0 |
| 6899 | else |
| 6900 | xload 0 ra |
| 6901 | ximm 1 xfmask t 1 |
| 6902 | xrr 33 0 1 |
| 6903 | xstore 0 rd |
| 6904 | end |
| 6905 | put rk 0 1 |
| 6906 | put rv 0 rd |
| 6907 | put rt 0 t |
| 6908 | end |
| 6909 | |
| 6910 | fn xfmm c ulong at ulong ak ulong av ulong dst ulong to void |
| 6911 | ra = matreg ak av at |
| 6912 | rb = matreg get rk 0 get rv 0 at |
| 6913 | rd = destreg dst |
| 6914 | xfminmax c at ra rb rd |
| 6915 | put rk 0 1 |
| 6916 | put rv 0 rd |
| 6917 | put rt 0 at |
| 6918 | end |
| 6919 | |
| 6920 | note ---- floating point. A float value is its IEEE bit pattern: in an x register (kind 1, 7 a constant), |
| 6921 | note or in a v register (kind 9, the twin of a pool register; float local names live there). Arithmetic |
| 6922 | note runs one scalar FP instruction (round to nearest even, no fused op) on v registers: an x operand moves |
| 6923 | note to v0/v1 first; a result wanted in x moves back from v1/v2, one wanted as kind 9 stays in its twin. |
| 6924 | note f32 uses the S form (low 32 bits), f64 the D form. |
| 6925 | fn f2v ty ulong xr ulong vr ulong to void |
| 6926 | if ne get xtarget 0 0 |
| 6927 | xload 0 xr |
| 6928 | xfmov ty 110 vr |
| 6929 | ret |
| 6930 | end |
| 6931 | if eq ty 10 |
| 6932 | emit or or 505872384 shl xr 5 vr |
| 6933 | else |
| 6934 | emit or or 2657550336 shl xr 5 vr |
| 6935 | end |
| 6936 | end |
| 6937 | |
| 6938 | fn fv2x ty ulong vr ulong xr ulong to void |
| 6939 | if ne get xtarget 0 0 |
| 6940 | xfmov ty 126 vr |
| 6941 | xstore 0 xr |
| 6942 | ret |
| 6943 | end |
| 6944 | if eq ty 10 |
| 6945 | emit or or 505806848 shl vr 5 xr |
| 6946 | else |
| 6947 | emit or or 2657484800 shl vr 5 xr |
| 6948 | end |
| 6949 | end |
| 6950 | |
| 6951 | note vtw: the twin of pool register r, v(16 + its pool index): v16..v31, caller-saved in AAPCS64 |
| 6952 | fn vtw r ulong to ulong |
| 6953 | ret add 16 regidx r |
| 6954 | end |
| 6955 | |
| 6956 | note fv8d / fv8s: the FMOV (scalar, immediate) imm8 of f64 / f32 bits b, or 256 when there is none. imm8 is |
| 6957 | note the sign, then bits 54..48 (f64) / 25..19 (f32). Encodable only when the fraction bits below those are |
| 6958 | note zero and exponent bits 61..54 (f64) / 29..25 (f32) all equal NOT bit 62 / 30 (VFPExpandImm). |
| 6959 | fn fv8d b ulong to ulong |
| 6960 | if ne and b 281474976710655 0 |
| 6961 | ret 256 |
| 6962 | end |
| 6963 | e = and shr b 54 255 |
| 6964 | if and ne e 0 ne e 255 |
| 6965 | ret 256 |
| 6966 | end |
| 6967 | if eq and shr b 62 1 and e 1 |
| 6968 | ret 256 |
| 6969 | end |
| 6970 | s = shl shr b 63 7 |
| 6971 | s = or s shl and e 1 6 |
| 6972 | ret or s and shr b 48 63 |
| 6973 | end |
| 6974 | |
| 6975 | fn fv8s b ulong to ulong |
| 6976 | if ne and b 524287 0 |
| 6977 | ret 256 |
| 6978 | end |
| 6979 | e = and shr b 25 31 |
| 6980 | if and ne e 0 ne e 31 |
| 6981 | ret 256 |
| 6982 | end |
| 6983 | if eq and shr b 30 1 and e 1 |
| 6984 | ret 256 |
| 6985 | end |
| 6986 | s = shl and shr b 31 1 7 |
| 6987 | s = or s shl and e 1 6 |
| 6988 | ret or s and shr b 19 63 |
| 6989 | end |
| 6990 | |
| 6991 | note fvk: float bits b of type ty into v register vr: 0 FMOV from XZR (C7.2.131); a value with an 8-bit |
| 6992 | note form FMOV (scalar, immediate, C7.2.132); any other MOVZ/MOVK into X16, then FMOV from X16. |
| 6993 | fn fvk ty ulong b ulong vr ulong to void |
| 6994 | if eq b 0 |
| 6995 | f2v ty 31 vr |
| 6996 | ret |
| 6997 | end |
| 6998 | if eq ty 10 |
| 6999 | im = fv8s b |
| 7000 | if lt im 256 |
| 7001 | emit or or 505417728 shl im 13 vr |
| 7002 | ret |
| 7003 | end |
| 7004 | else |
| 7005 | im = fv8d b |
| 7006 | if lt im 256 |
| 7007 | emit or or 509612032 shl im 13 vr |
| 7008 | ret |
| 7009 | end |
| 7010 | end |
| 7011 | matconst 16 b |
| 7012 | f2v ty 16 vr |
| 7013 | end |
| 7014 | |
| 7015 | note fvop: the v register holding float operand (kind k, value v, type t): its twin for kind 9, else v |
| 7016 | note register s, filled from the constant or from the operand's x register. |
| 7017 | fn fvop k ulong v ulong t ulong s ulong to ulong |
| 7018 | if eq k 9 |
| 7019 | ret vtw v |
| 7020 | end |
| 7021 | if eq k 7 |
| 7022 | fvk t v s |
| 7023 | ret s |
| 7024 | end |
| 7025 | r = matreg k v t |
| 7026 | f2v t r s |
| 7027 | ret s |
| 7028 | end |
| 7029 | |
| 7030 | note fvdst: the pool register whose twin takes a kind 9 result for request o (fpw): 1 a new one, its slot |
| 7031 | note marked as living in v; 2 + r the twin of r (a float local name). |
| 7032 | fn fvdst o ulong to ulong |
| 7033 | if eq o 1 |
| 7034 | r = alloc |
| 7035 | put vsl regidx r uchar 1 |
| 7036 | ret r |
| 7037 | end |
| 7038 | ret sub o 2 |
| 7039 | end |
| 7040 | |
| 7041 | note fvset: float value (kind k, value v, type t) into the twin of r: FMOV Dd, Dn (C7.2.130), the constant, |
| 7042 | note or FMOV from its x register. Nothing when it is already there. |
| 7043 | fn fvset k ulong v ulong t ulong r ulong to void |
| 7044 | d = vtw r |
| 7045 | if eq k 9 |
| 7046 | if ne v r |
| 7047 | if eq t 10 |
| 7048 | emit or or 505430016 shl vtw v 5 d |
| 7049 | else |
| 7050 | emit or or 509624320 shl vtw v 5 d |
| 7051 | end |
| 7052 | end |
| 7053 | ret |
| 7054 | end |
| 7055 | if eq k 7 |
| 7056 | fvk t v d |
| 7057 | ret |
| 7058 | end |
| 7059 | x = matreg k v t |
| 7060 | f2v t x d |
| 7061 | end |
| 7062 | |
| 7063 | note fp_binop: one FP add / sub / mul / div of v registers va, vb into vd |
| 7064 | fn fp_binop op ulong ty ulong va ulong vb ulong vd ulong to void |
| 7065 | base = ulong 509609984 |
| 7066 | if eq ty 10 |
| 7067 | base = ulong 505415680 |
| 7068 | end |
| 7069 | if eq op 33 |
| 7070 | if eq ty 10 |
| 7071 | base = ulong 505423872 |
| 7072 | else |
| 7073 | base = ulong 509618176 |
| 7074 | end |
| 7075 | else |
| 7076 | if eq op 34 |
| 7077 | if eq ty 10 |
| 7078 | base = ulong 505427968 |
| 7079 | else |
| 7080 | base = ulong 509622272 |
| 7081 | end |
| 7082 | else |
| 7083 | if eq op 36 |
| 7084 | if eq ty 10 |
| 7085 | base = ulong 505419776 |
| 7086 | else |
| 7087 | base = ulong 509614080 |
| 7088 | end |
| 7089 | end |
| 7090 | end |
| 7091 | end |
| 7092 | emit or or or base shl vb 16 shl va 5 vd |
| 7093 | end |
| 7094 | |
| 7095 | fn fp_neg ty ulong va ulong vd ulong to void |
| 7096 | if eq ty 10 |
| 7097 | emit or or ulong 505495552 shl va 5 vd |
| 7098 | else |
| 7099 | emit or or ulong 509689856 shl va 5 vd |
| 7100 | end |
| 7101 | end |
| 7102 | |
| 7103 | note fp_un1: sqrt (c 91) or abs of v register va into vd |
| 7104 | fn fp_un1 c ulong ty ulong va ulong vd ulong to void |
| 7105 | if eq c 91 |
| 7106 | if eq ty 10 |
| 7107 | emit or or ulong 505528320 shl va 5 vd |
| 7108 | else |
| 7109 | emit or or ulong 509722624 shl va 5 vd |
| 7110 | end |
| 7111 | else |
| 7112 | if eq ty 10 |
| 7113 | emit or or ulong 505462784 shl va 5 vd |
| 7114 | else |
| 7115 | emit or or ulong 509657088 shl va 5 vd |
| 7116 | end |
| 7117 | end |
| 7118 | end |
| 7119 | |
| 7120 | note fp_minmax: FMINNM/FMAXNM, the IEEE minNum/maxNum rule: one quiet NaN returns the other operand, |
| 7121 | note and -0.0 orders below +0.0. |
| 7122 | fn fp_minmax c ulong ty ulong va ulong vb ulong vd ulong to void |
| 7123 | base = ulong 509638656 |
| 7124 | if eq c 94 |
| 7125 | base = ulong 509634560 |
| 7126 | end |
| 7127 | if eq ty 10 |
| 7128 | base = ulong 505444352 |
| 7129 | if eq c 94 |
| 7130 | base = ulong 505440256 |
| 7131 | end |
| 7132 | end |
| 7133 | emit or or or base shl vb 16 shl va 5 vd |
| 7134 | end |
| 7135 | |
| 7136 | note fintr: sqrt or abs of one float value; fminmax: min or max of two values of one float type. |
| 7137 | note Both refuse a bare integer operand and an unresolved literal, as everywhere else. A request o (fpo) |
| 7138 | note makes the result in a twin (kind 9); otherwise it moves to x register destreg dst (kind 1). |
| 7139 | fn fintr c ulong dst ulong to void |
| 7140 | o = get fpo 0 |
| 7141 | put fpo 0 0 |
| 7142 | if ne get irmode 0 0 |
| 7143 | note d2site 95|fintr: word or declaration in a place that does not allow it; condition if ne get irmode 0 0 |
| 7144 | put d2site 0 95 |
| 7145 | fail 9 |
| 7146 | end |
| 7147 | put fpw 0 1 |
| 7148 | rdval 0 0 255 0 |
| 7149 | if eq get rk 0 2 |
| 7150 | note d2site 96|fintr: type mismatch; condition if eq get rk 0 2 |
| 7151 | put d2site 0 96 |
| 7152 | fail 7 |
| 7153 | end |
| 7154 | if eq get rk 0 6 |
| 7155 | note d2site 97|fintr: bare number without a type from its context; condition if eq get rk 0 6 |
| 7156 | put d2site 0 97 |
| 7157 | fail 11 |
| 7158 | end |
| 7159 | t = get rt 0 |
| 7160 | if eq isfloat t 0 |
| 7161 | note d2site 98|fintr: type mismatch; condition if eq isfloat t 0 |
| 7162 | put d2site 0 98 |
| 7163 | fail 7 |
| 7164 | end |
| 7165 | if ne get xtarget 0 0 |
| 7166 | xfun1 c t dst |
| 7167 | vdec |
| 7168 | ret |
| 7169 | end |
| 7170 | va = fvop get rk 0 get rv 0 t 0 |
| 7171 | if eq o 0 |
| 7172 | rd = destreg dst |
| 7173 | fp_un1 c t va 1 |
| 7174 | fv2x t 1 rd |
| 7175 | put rk 0 1 |
| 7176 | put rv 0 rd |
| 7177 | else |
| 7178 | r = fvdst o |
| 7179 | fp_un1 c t va vtw r |
| 7180 | put rk 0 9 |
| 7181 | put rv 0 r |
| 7182 | end |
| 7183 | put rt 0 t |
| 7184 | vdec |
| 7185 | end |
| 7186 | |
| 7187 | fn fminmax c ulong dst ulong to void |
| 7188 | o = get fpo 0 |
| 7189 | put fpo 0 0 |
| 7190 | if ne get irmode 0 0 |
| 7191 | note d2site 99|fminmax: word or declaration in a place that does not allow it; condition if ne get irmode 0 0 |
| 7192 | put d2site 0 99 |
| 7193 | fail 9 |
| 7194 | end |
| 7195 | put fpw 0 1 |
| 7196 | rdval 0 0 255 0 |
| 7197 | if or eq get rk 0 2 eq get rk 0 6 |
| 7198 | note d2site 100|fminmax: bare number without a type from its context; condition if or eq get rk 0 2 eq get rk 0 6 |
| 7199 | put d2site 0 100 |
| 7200 | fail 11 |
| 7201 | end |
| 7202 | at = get rt 0 |
| 7203 | ak = get rk 0 |
| 7204 | av = get rv 0 |
| 7205 | put fpw 0 1 |
| 7206 | rdval 0 0 255 0 |
| 7207 | if or eq get rk 0 2 eq get rk 0 6 |
| 7208 | note d2site 101|fminmax: bare number without a type from its context; condition if or eq get rk 0 2 eq get rk 0 6 |
| 7209 | put d2site 0 101 |
| 7210 | fail 11 |
| 7211 | end |
| 7212 | if or eq isfloat at 0 eq isfloat get rt 0 0 |
| 7213 | note d2site 102|fminmax: type mismatch; condition if or eq isfloat at 0 eq isfloat get rt 0 0 |
| 7214 | put d2site 0 102 |
| 7215 | fail 7 |
| 7216 | end |
| 7217 | if ne at get rt 0 |
| 7218 | note d2site 103|fminmax: type mismatch; condition if ne at get rt 0 |
| 7219 | put d2site 0 103 |
| 7220 | fail 7 |
| 7221 | end |
| 7222 | if ne get xtarget 0 0 |
| 7223 | xfmm c at ak av dst |
| 7224 | vdec |
| 7225 | ret |
| 7226 | end |
| 7227 | va = fvop ak av at 0 |
| 7228 | vb = fvop get rk 0 get rv 0 at 1 |
| 7229 | if eq o 0 |
| 7230 | rd = destreg dst |
| 7231 | fp_minmax c at va vb 2 |
| 7232 | fv2x at 2 rd |
| 7233 | put rk 0 1 |
| 7234 | put rv 0 rd |
| 7235 | else |
| 7236 | r = fvdst o |
| 7237 | fp_minmax c at va vb vtw r |
| 7238 | put rk 0 9 |
| 7239 | put rv 0 r |
| 7240 | end |
| 7241 | put rt 0 at |
| 7242 | vdec |
| 7243 | end |
| 7244 | |
| 7245 | note FMADD (scalar), ARM C7: one rounded multiply-add, not FMUL followed by FADD. |
| 7246 | note The addend is Ra, bits 14..10; multiplicands Rn, Rm are bits 9..5, 20..16. |
| 7247 | fn ffma dst ulong to void |
| 7248 | o = get fpo 0 |
| 7249 | put fpo 0 0 |
| 7250 | put fpw 0 1 |
| 7251 | rdval 0 0 255 0 |
| 7252 | if eq get rk 0 6 |
| 7253 | note d2site 104|ffma: bare number without a type from its context; condition if eq get rk 0 6 |
| 7254 | put d2site 0 104 |
| 7255 | fail 11 |
| 7256 | end |
| 7257 | at = get rt 0 |
| 7258 | if eq isfloat at 0 |
| 7259 | note d2site 105|ffma: type mismatch; condition if eq isfloat at 0 |
| 7260 | put d2site 0 105 |
| 7261 | fail 7 |
| 7262 | end |
| 7263 | ak = get rk 0 |
| 7264 | av = get rv 0 |
| 7265 | put fpw 0 1 |
| 7266 | rdval 0 0 255 0 |
| 7267 | if eq get rk 0 6 |
| 7268 | note d2site 106|ffma: bare number without a type from its context; condition if eq get rk 0 6 |
| 7269 | put d2site 0 106 |
| 7270 | fail 11 |
| 7271 | end |
| 7272 | if ne get rt 0 at |
| 7273 | note d2site 107|ffma: type mismatch; condition if ne get rt 0 at |
| 7274 | put d2site 0 107 |
| 7275 | fail 7 |
| 7276 | end |
| 7277 | bk = get rk 0 |
| 7278 | bv = get rv 0 |
| 7279 | put fpw 0 1 |
| 7280 | rdval 0 0 255 0 |
| 7281 | if eq get rk 0 6 |
| 7282 | note d2site 108|ffma: bare number without a type from its context; condition if eq get rk 0 6 |
| 7283 | put d2site 0 108 |
| 7284 | fail 11 |
| 7285 | end |
| 7286 | if ne get rt 0 at |
| 7287 | note d2site 109|ffma: type mismatch; condition if ne get rt 0 at |
| 7288 | put d2site 0 109 |
| 7289 | fail 7 |
| 7290 | end |
| 7291 | note x86's baseline is SSE2, not FMA3. No unfused fallback is permitted. The operands are typed |
| 7292 | note first, so an ill-typed fma gets the same error 7 or 11 on every target; only a well-typed one |
| 7293 | note is refused here. |
| 7294 | if or ne get irmode 0 0 ne get xtarget 0 0 |
| 7295 | note d2site 110|ffma: word or declaration in a place that does not allow it; condition if or ne get irmode 0 0 ne get xtarget 0 0 |
| 7296 | put d2site 0 110 |
| 7297 | fail 9 |
| 7298 | end |
| 7299 | va = fvop ak av at 0 |
| 7300 | vb = fvop bk bv at 1 |
| 7301 | vc = fvop get rk 0 get rv 0 at 2 |
| 7302 | r = ulong 0 |
| 7303 | vd = ulong 3 |
| 7304 | if eq o 0 |
| 7305 | r = destreg dst |
| 7306 | else |
| 7307 | r = fvdst o |
| 7308 | vd = vtw r |
| 7309 | end |
| 7310 | b = ulong 520093696 |
| 7311 | if eq at 11 |
| 7312 | b = 524288000 |
| 7313 | end |
| 7314 | b = or b shl vb 16 |
| 7315 | b = or b shl vc 10 |
| 7316 | b = or b shl va 5 |
| 7317 | emit or b vd |
| 7318 | if eq o 0 |
| 7319 | fv2x at vd r |
| 7320 | put rk 0 1 |
| 7321 | else |
| 7322 | put rk 0 9 |
| 7323 | end |
| 7324 | put rv 0 r |
| 7325 | put rt 0 at |
| 7326 | vdec |
| 7327 | end |
| 7328 | |
| 7329 | note fcond: the condition for a float compare op: EQ, NE, MI (lt), LS (le), GT, GE. MI/LS/GT/GE are |
| 7330 | note false for NaN, so unordered comparisons come out as the IEEE rules require. |
| 7331 | fn fcond op ulong to ulong |
| 7332 | i = sub op 43 |
| 7333 | if eq i 0 |
| 7334 | ret 0 |
| 7335 | end |
| 7336 | if eq i 1 |
| 7337 | ret 1 |
| 7338 | end |
| 7339 | if eq i 2 |
| 7340 | ret 4 |
| 7341 | end |
| 7342 | if eq i 3 |
| 7343 | ret 9 |
| 7344 | end |
| 7345 | if eq i 4 |
| 7346 | ret 12 |
| 7347 | end |
| 7348 | ret 10 |
| 7349 | end |
| 7350 | |
| 7351 | note fp_cmp: FCMP Sn, Sm / Dn, Dm (scalar) of v registers va, vb: 0x1E202000 / 0x1E602000 with Rm and Rn |
| 7352 | note zero, so both fields come from va and vb alone (#861: the S word had Rm bit 0 set, and an even vb |
| 7353 | note read the next twin). |
| 7354 | fn fp_cmp op ulong ty ulong va ulong vb ulong to void |
| 7355 | if eq ty 10 |
| 7356 | emit or or 505421824 shl vb 16 shl va 5 |
| 7357 | else |
| 7358 | emit or or 509616128 shl vb 16 shl va 5 |
| 7359 | end |
| 7360 | put rk 0 4 |
| 7361 | put rv 0 fcond op |
| 7362 | put rt 0 1 |
| 7363 | end |
| 7364 | |
| 7365 | note fp_conv: one scalar conversion (int<->float, f32<->f64) into a new x register. Same type is a copy. |
| 7366 | note Returns the register. A float result is made in v(rd), or in v0 when rd is x17 (v17 is a twin). |
| 7367 | fn fp_conv ft ulong tt ulong ra ulong to ulong |
| 7368 | if ne get xtarget 0 0 |
| 7369 | ret xfconv ft tt ra |
| 7370 | end |
| 7371 | if eq ft tt |
| 7372 | ret ra |
| 7373 | end |
| 7374 | if eq ft 1 |
| 7375 | note d2site 111|fp_conv: word or declaration in a place that does not allow it; condition if eq ft 1 |
| 7376 | put d2site 0 111 |
| 7377 | fail 9 |
| 7378 | end |
| 7379 | if eq tt 1 |
| 7380 | note d2site 112|fp_conv: word or declaration in a place that does not allow it; condition if eq tt 1 |
| 7381 | put d2site 0 112 |
| 7382 | fail 9 |
| 7383 | end |
| 7384 | rd = alloc |
| 7385 | if eq isfloat tt 0 |
| 7386 | f2v ft ra 0 |
| 7387 | fp_toint ft tt rd |
| 7388 | ret rd |
| 7389 | end |
| 7390 | vs = rd |
| 7391 | if ge rd 16 |
| 7392 | vs = ulong 0 |
| 7393 | end |
| 7394 | fp_tov ft tt ra vs |
| 7395 | fv2x tt vs rd |
| 7396 | ret rd |
| 7397 | end |
| 7398 | |
| 7399 | note fp_tov: x register ra of type ft (an integer, or the other float type, moved to v0 first) converted |
| 7400 | note to float type tt in v register vd: SCVTF/UCVTF (C7.2.236/C7.2.355) by signedness, FCVT (C7.2.69). |
| 7401 | fn fp_tov ft ulong tt ulong ra ulong vd ulong to void |
| 7402 | if ne isfloat ft 0 |
| 7403 | f2v ft ra 0 |
| 7404 | if eq ft 10 |
| 7405 | emit or 505593856 vd |
| 7406 | else |
| 7407 | emit or 509755392 vd |
| 7408 | end |
| 7409 | ret |
| 7410 | end |
| 7411 | sgn = false |
| 7412 | if ge ft 6 |
| 7413 | sgn = true |
| 7414 | end |
| 7415 | if eq tt 10 |
| 7416 | if eq twid ft 32 |
| 7417 | if sgn |
| 7418 | emit or or 505544704 shl ra 5 vd |
| 7419 | else |
| 7420 | emit or or 505610240 shl ra 5 vd |
| 7421 | end |
| 7422 | else |
| 7423 | if sgn |
| 7424 | emit or or 2653028352 shl ra 5 vd |
| 7425 | else |
| 7426 | emit or or 2653093888 shl ra 5 vd |
| 7427 | end |
| 7428 | end |
| 7429 | else |
| 7430 | if eq twid ft 32 |
| 7431 | if sgn |
| 7432 | emit or or 509739008 shl ra 5 vd |
| 7433 | else |
| 7434 | emit or or 509804544 shl ra 5 vd |
| 7435 | end |
| 7436 | else |
| 7437 | if sgn |
| 7438 | emit or or 2657222656 shl ra 5 vd |
| 7439 | else |
| 7440 | emit or or 2657288192 shl ra 5 vd |
| 7441 | end |
| 7442 | end |
| 7443 | end |
| 7444 | end |
| 7445 | |
| 7446 | |
| 7447 | note fp_toint: float (v0) to integer rd: truncate toward zero, saturate to the destination's own range, NaN |
| 7448 | note to 0 (OMEGESE 9.9; spec/one-layer-format.md 10.3). 32/64-bit: FCVTZS/FCVTZU (C7.2.90/C7.2.94) by |
| 7449 | note signedness, int sign-extended (SXTW). 8/16-bit: the scalar SIMD FCVTZ[SU] in v0, then saturating |
| 7450 | note narrows (SQXTN/UQXTN, C7.2.311/C7.2.374) to the width, FMOV W (C7.2.130), then SXTB/SXTH for signed. |
| 7451 | fn fp_toint ft ulong tt ulong rd ulong to void |
| 7452 | if ne get xtarget 0 0 |
| 7453 | xftoint ft tt rd |
| 7454 | ret |
| 7455 | end |
| 7456 | w = twid tt |
| 7457 | sg = ge tt 6 |
| 7458 | if eq w 64 |
| 7459 | if sg |
| 7460 | if eq ft 10 |
| 7461 | emit or 2654470144 rd |
| 7462 | else |
| 7463 | emit or 2658664448 rd |
| 7464 | end |
| 7465 | else |
| 7466 | if eq ft 10 |
| 7467 | emit or 2654535680 rd |
| 7468 | else |
| 7469 | emit or 2658729984 rd |
| 7470 | end |
| 7471 | end |
| 7472 | ret |
| 7473 | end |
| 7474 | if eq w 32 |
| 7475 | if sg |
| 7476 | if eq ft 10 |
| 7477 | emit or 506986496 rd |
| 7478 | else |
| 7479 | emit or 511180800 rd |
| 7480 | end |
| 7481 | emit or or 2470476800 rd shl rd 5 |
| 7482 | else |
| 7483 | if eq ft 10 |
| 7484 | emit or 507052032 rd |
| 7485 | else |
| 7486 | emit or 511246336 rd |
| 7487 | end |
| 7488 | end |
| 7489 | ret |
| 7490 | end |
| 7491 | fp_narrow ft sg w |
| 7492 | emit or 505806848 rd |
| 7493 | if sg |
| 7494 | if eq w 8 |
| 7495 | emit or or 2470452224 rd shl rd 5 |
| 7496 | else |
| 7497 | emit or or 2470460416 rd shl rd 5 |
| 7498 | end |
| 7499 | end |
| 7500 | end |
| 7501 | |
| 7502 | note fp_narrow: convert v0 in place to a saturated integer of width w (8 or 16) in its low bits. |
| 7503 | fn fp_narrow ft ulong sg bool w ulong to void |
| 7504 | if eq ft 10 |
| 7505 | if sg |
| 7506 | emit 1587656704 |
| 7507 | emit 1583433728 |
| 7508 | else |
| 7509 | emit 2124527616 |
| 7510 | emit 2120304640 |
| 7511 | end |
| 7512 | else |
| 7513 | if sg |
| 7514 | emit 1591851008 |
| 7515 | emit 1587628032 |
| 7516 | emit 1583433728 |
| 7517 | else |
| 7518 | emit 2128721920 |
| 7519 | emit 2124498944 |
| 7520 | emit 2120304640 |
| 7521 | end |
| 7522 | end |
| 7523 | if eq w 8 |
| 7524 | if sg |
| 7525 | emit 1579239424 |
| 7526 | else |
| 7527 | emit 2116110336 |
| 7528 | end |
| 7529 | end |
| 7530 | end |
| 7531 | |
| 7532 | note ---- rotate (OM-2, spec 3): rotr 59 / rotl 60 of an unsigned uchar..ulong by the same type. uint and |
| 7533 | note ulong with a number below the width: ROR (immediate) = EXTR Rd, Rn, Rn, #s (C6.2.347, C6.2.160); |
| 7534 | note otherwise the shift amount check (trap 7) then RORV (C6.2.349); rotl by n is ror by w - n (a number) |
| 7535 | note or by NEG n (C6.2.295) since RORV takes the amount modulo the width. uchar/ushort first replicate the |
| 7536 | note value through W16 with ORR (shifted register, LSL, C6.2.302), rotate the 32-bit pattern, then canon. |
| 7537 | fn rotrep ty ulong ra ulong to void |
| 7538 | if eq ty 3 |
| 7539 | emit or or 704659472 shl ra 16 shl ra 5 |
| 7540 | ret |
| 7541 | end |
| 7542 | emit or or 704651280 shl ra 16 shl ra 5 |
| 7543 | emit 705708560 |
| 7544 | end |
| 7545 | |
| 7546 | fn rotimm ty ulong ra ulong s ulong rd ulong to void |
| 7547 | if ne get xtarget 0 0 |
| 7548 | xrot ty ra s 1 rd |
| 7549 | ret |
| 7550 | end |
| 7551 | if eq ty 5 |
| 7552 | emit or or or 2478833664 shl ra 16 shl s 10 or shl ra 5 rd |
| 7553 | ret |
| 7554 | end |
| 7555 | if eq ty 4 |
| 7556 | emit or or or 327155712 shl ra 16 shl s 10 or shl ra 5 rd |
| 7557 | ret |
| 7558 | end |
| 7559 | rotrep ty ra |
| 7560 | emit or or 328204800 shl s 10 rd |
| 7561 | canon rd ty |
| 7562 | end |
| 7563 | |
| 7564 | fn rotreg ty ulong ra ulong rr ulong rd ulong to void |
| 7565 | if ne get xtarget 0 0 |
| 7566 | xrot ty ra rr 0 rd |
| 7567 | ret |
| 7568 | end |
| 7569 | if eq ty 5 |
| 7570 | emit or or 2596285440 shl rr 16 or shl ra 5 rd |
| 7571 | ret |
| 7572 | end |
| 7573 | if eq ty 4 |
| 7574 | emit or or 448801792 shl rr 16 or shl ra 5 rd |
| 7575 | ret |
| 7576 | end |
| 7577 | rotrep ty ra |
| 7578 | emit or or 448802304 shl rr 16 rd |
| 7579 | canon rd ty |
| 7580 | end |
| 7581 | |
| 7582 | fn binrot op ulong dst ulong ix ulong to void |
| 7583 | ty = get a_ar add get a_rb 77 add ix 2 |
| 7584 | if or lt ty 2 gt ty 5 |
| 7585 | note d2site 113|binrot: type mismatch; condition if or lt ty 2 gt ty 5 |
| 7586 | put d2site 0 113 |
| 7587 | fail 7 |
| 7588 | end |
| 7589 | ra = matreg a_g 77 ix a_g 77 add ix 1 ty |
| 7590 | bk = get a_ar add get a_rb 77 add ix 3 |
| 7591 | bn = get a_ar add get a_rb 77 add ix 4 |
| 7592 | w = twid ty |
| 7593 | rb = ulong 0 |
| 7594 | useimm = false |
| 7595 | if and eq bk 3 lt bn w |
| 7596 | useimm = true |
| 7597 | rb = bn |
| 7598 | else |
| 7599 | rb = matreg bk bn a_g 77 add ix 5 |
| 7600 | bo_schk ty rb |
| 7601 | end |
| 7602 | rd = destreg dst |
| 7603 | if useimm |
| 7604 | s = rb |
| 7605 | if and eq op 60 ne s 0 |
| 7606 | s = sub w s |
| 7607 | end |
| 7608 | rotimm ty ra s rd |
| 7609 | else |
| 7610 | rr = rb |
| 7611 | if eq op 60 |
| 7612 | rr = alloc |
| 7613 | if ne get xtarget 0 0 |
| 7614 | xload 0 rb |
| 7615 | xb 72 247 216 |
| 7616 | xstore 0 rr |
| 7617 | else |
| 7618 | emit or or 3405775840 shl rb 16 rr |
| 7619 | end |
| 7620 | end |
| 7621 | rotreg ty ra rr rd |
| 7622 | end |
| 7623 | put rk 0 1 |
| 7624 | put rv 0 rd |
| 7625 | put rt 0 ty |
| 7626 | end |
| 7627 | |
| 7628 | note binop: op 33..48, destination (255 none), ix the fr slot of a (kind, number/register, type) then b. |
| 7629 | note Result in rk/rv/rt. om4 BINOP. A float op reads its operands as v registers; with a request (fpo) |
| 7630 | note the result stays in a twin (kind 9), else it moves to x (kind 1). |
| 7631 | fn binop op ulong dst ulong ix ulong to void |
| 7632 | if ne get fzone 0 0 |
| 7633 | if and eq a_g 77 ix 3 eq a_g 77 add ix 3 3 |
| 7634 | foldbin op a_g 77 add ix 2 a_g 77 add ix 1 a_g 77 add ix 4 |
| 7635 | if ne get fok 0 0 |
| 7636 | put rk 0 3 |
| 7637 | put rv 0 get fval 0 |
| 7638 | put rt 0 get fty 0 |
| 7639 | ret |
| 7640 | end |
| 7641 | end |
| 7642 | end |
| 7643 | if or eq op 59 eq op 60 |
| 7644 | binrot op dst ix |
| 7645 | ret |
| 7646 | end |
| 7647 | ty = get a_ar add get a_rb 77 add ix 2 |
| 7648 | if ne isfloat ty 0 |
| 7649 | if ne get xtarget 0 0 |
| 7650 | xfbinop op dst ix ty |
| 7651 | ret |
| 7652 | end |
| 7653 | o = get fpo 0 |
| 7654 | put fpo 0 0 |
| 7655 | va = fvop a_g 77 ix a_g 77 add ix 1 ty 0 |
| 7656 | vb = fvop a_g 77 add ix 3 a_g 77 add ix 4 ty 1 |
| 7657 | if ge op 43 |
| 7658 | fp_cmp op ty va vb |
| 7659 | ret |
| 7660 | end |
| 7661 | if or or lt op 33 gt op 36 ge op 41 |
| 7662 | note d2site 114|binop: type mismatch; condition if or or lt op 33 gt op 36 ge op 41 |
| 7663 | put d2site 0 114 |
| 7664 | fail 7 |
| 7665 | end |
| 7666 | if eq o 0 |
| 7667 | rd = destreg dst |
| 7668 | fp_binop op ty va vb 2 |
| 7669 | fv2x ty 2 rd |
| 7670 | put rk 0 1 |
| 7671 | put rv 0 rd |
| 7672 | else |
| 7673 | r = fvdst o |
| 7674 | fp_binop op ty va vb vtw r |
| 7675 | put rk 0 9 |
| 7676 | put rv 0 r |
| 7677 | end |
| 7678 | put rt 0 ty |
| 7679 | ret |
| 7680 | end |
| 7681 | ra = matreg a_g 77 ix a_g 77 add ix 1 ty |
| 7682 | if eq ty 13 |
| 7683 | if and ge op 38 le op 42 |
| 7684 | note d2site 115|binop: type mismatch; condition if and ge op 38 le op 42 |
| 7685 | put d2site 0 115 |
| 7686 | fail 7 |
| 7687 | end |
| 7688 | end |
| 7689 | imm = ulong 0 |
| 7690 | bk = get a_ar add get a_rb 77 add ix 3 |
| 7691 | bn = get a_ar add get a_rb 77 add ix 4 |
| 7692 | rb = ulong 0 |
| 7693 | useimm = false |
| 7694 | if eq bk 3 |
| 7695 | if or eq op 41 eq op 42 |
| 7696 | if lt bn twid ty |
| 7697 | useimm = true |
| 7698 | end |
| 7699 | else |
| 7700 | if or lt op 35 ge op 43 |
| 7701 | if le bn 4095 |
| 7702 | useimm = true |
| 7703 | end |
| 7704 | end |
| 7705 | end |
| 7706 | end |
| 7707 | if useimm |
| 7708 | rb = bn |
| 7709 | imm = ulong 1 |
| 7710 | else |
| 7711 | rb = matreg bk bn a_g 77 add ix 5 |
| 7712 | end |
| 7713 | if ge op 43 |
| 7714 | bo_cmp op ty ra rb imm |
| 7715 | ret |
| 7716 | end |
| 7717 | if eq ty 1 |
| 7718 | if gt sub op 38 2 |
| 7719 | note d2site 116|binop: type mismatch; condition if gt sub op 38 2 |
| 7720 | put d2site 0 116 |
| 7721 | fail 7 |
| 7722 | end |
| 7723 | end |
| 7724 | rd = destreg dst |
| 7725 | if lt op 35 |
| 7726 | bo_add op ty ra rb imm rd |
| 7727 | else |
| 7728 | if eq op 35 |
| 7729 | bo_mul ty ra rb rd |
| 7730 | else |
| 7731 | if lt op 38 |
| 7732 | fl = ulong 0 |
| 7733 | if and eq bk 3 ne bn 0 |
| 7734 | fl = or fl 1 |
| 7735 | end |
| 7736 | if and eq bk 3 ne bn 18446744073709551615 |
| 7737 | fl = or fl 2 |
| 7738 | end |
| 7739 | bo_div op ty ra rb rd fl |
| 7740 | else |
| 7741 | if lt op 41 |
| 7742 | bo_log op ra rb rd |
| 7743 | else |
| 7744 | if eq op 41 |
| 7745 | bo_shl ty ra rb imm rd |
| 7746 | else |
| 7747 | bo_shr ty ra rb imm rd |
| 7748 | end |
| 7749 | end |
| 7750 | end |
| 7751 | end |
| 7752 | end |
| 7753 | put rk 0 1 |
| 7754 | put rv 0 rd |
| 7755 | put rt 0 ty |
| 7756 | end |
| 7757 | |
| 7758 | note ======== calls: registers saved around a call and loaded back ======== |
| 7759 | global svn ulong 1 |
| 7760 | global sva ulong 1 |
| 7761 | note save: n = registers in use (parameters + pool slots), A = 8 (n + 1) rounded up to 16: SUB SP, SP, #A |
| 7762 | note (C6.2.457); the stack check; STR Xr, [SP, #8j] for each (C6.2.415), or STR Dj+16 (SIMD&FP, C7.2.331) |
| 7763 | note for a slot living in its twin (vsl); STR X30, [SP, #8n]. Out: svn n, sva A. om4 SAVE. |
| 7764 | fn save to void |
| 7765 | if ne get xtarget 0 0 |
| 7766 | put svn 0 add get npar 0 get nslot 0 |
| 7767 | put sva 0 256 |
| 7768 | xsp 1 256 |
| 7769 | j = ulong 0 |
| 7770 | while lt j 18 |
| 7771 | xload 0 j |
| 7772 | xmem 137 0 4 mul j 8 |
| 7773 | j = add j 1 |
| 7774 | end |
| 7775 | note Reserve the callee's return address, frame pointer and slot area before CALL. |
| 7776 | xcheck 272 |
| 7777 | ret |
| 7778 | end |
| 7779 | n = add get npar 0 get nslot 0 |
| 7780 | a = shl shr add n 2 1 4 |
| 7781 | put svn 0 n |
| 7782 | put sva 0 a |
| 7783 | spsub a |
| 7784 | stkchk |
| 7785 | j = ulong 0 |
| 7786 | while lt j n |
| 7787 | if ne get vsl j 0 |
| 7788 | emit or or 4244636640 add j 16 shl j 10 |
| 7789 | else |
| 7790 | emit or or 4177527776 poolc j shl j 10 |
| 7791 | end |
| 7792 | j = add j 1 |
| 7793 | end |
| 7794 | emit or 4177527806 shl n 10 |
| 7795 | end |
| 7796 | |
| 7797 | note loadarg: register t from an argument: kind 1, 5 or 9 a register v, read back from its save slot (LDR |
| 7798 | note Xt, [SP, #8 slot], C6.2.216; a kind 9 slot holds the twin's D bits, the same bit pattern); kind 3, 6 |
| 7799 | note or 7 the number, address or float bits v. om4 LOADARG. |
| 7800 | fn loadarg t ulong k ulong v ulong to void |
| 7801 | if ne get xtarget 0 0 |
| 7802 | xarg t k v |
| 7803 | ret |
| 7804 | end |
| 7805 | if eq k 6 |
| 7806 | mataddr t v |
| 7807 | ret |
| 7808 | end |
| 7809 | if or eq k 3 eq k 7 |
| 7810 | matconst t v |
| 7811 | ret |
| 7812 | end |
| 7813 | emit or or 4181722080 t shl regidx v 10 |
| 7814 | end |
| 7815 | |
| 7816 | note basearg: register t = the base of array name e (index + 1): its register from the save area, or its |
| 7817 | note address. om4 BASEARG. |
| 7818 | fn basearg t ulong e ulong to void |
| 7819 | i = sub e 1 |
| 7820 | if eq uchar get a_ar add get a_rb 7 i 10 |
| 7821 | mataddr t get a_ar add get a_rb 8 i |
| 7822 | emit or or 4181721088 shl t 5 t |
| 7823 | ret |
| 7824 | end |
| 7825 | if ge uchar get a_ar add get a_rb 7 i 4 |
| 7826 | mataddr t get a_ar add get a_rb 8 i |
| 7827 | ret |
| 7828 | end |
| 7829 | loadarg t 1 ulong uchar get a_ar add get a_rb 4 i |
| 7830 | end |
| 7831 | |
| 7832 | note restore: d destination (255: a new temporary at pool slot `slot`), slot the pool slot before the |
| 7833 | note arguments, n saved count, a save bytes, res 1 if there is a result in X0. MOV Xd, X0 (C6.2.282); LDR |
| 7834 | note each register in use before the arguments except Xd (C6.2.216), or LDR Dj+16 (C7.2.191) instead for a |
| 7835 | note slot living in its twin; LDR X30; ADD SP, SP, #A (C6.2.5). Returns Xd (255 when no result). om4 |
| 7836 | note RESTORE. |
| 7837 | fn restore d ulong slot ulong n ulong a ulong res ulong to ulong |
| 7838 | if ne get xtarget 0 0 |
| 7839 | ret xrestore d slot res |
| 7840 | end |
| 7841 | put nslot 0 slot |
| 7842 | rd = ulong 255 |
| 7843 | if ne res 0 |
| 7844 | rd = d |
| 7845 | if eq d 255 |
| 7846 | rd = alloc |
| 7847 | end |
| 7848 | if ne rd 0 |
| 7849 | emit or 2852127712 rd |
| 7850 | end |
| 7851 | end |
| 7852 | m = add get npar 0 slot |
| 7853 | j = ulong 0 |
| 7854 | while lt j m |
| 7855 | r = poolc j |
| 7856 | if ne get vsl j 0 |
| 7857 | emit or or 4248830944 add j 16 shl j 10 |
| 7858 | else |
| 7859 | if ne r rd |
| 7860 | emit or or 4181722080 r shl j 10 |
| 7861 | end |
| 7862 | end |
| 7863 | j = add j 1 |
| 7864 | end |
| 7865 | emit or 4181722110 shl n 10 |
| 7866 | spadd a |
| 7867 | ret rd |
| 7868 | end |
| 7869 | |
| 7870 | note ca_bl: BL to function f (index + 1), C6.2.43. The call records grow with the arena (group 9). |
| 7871 | fn ca_bl f ulong to void |
| 7872 | n = get ncalls 0 |
| 7873 | if ge n get a_gp 9 |
| 7874 | a_need 9 n |
| 7875 | end |
| 7876 | put a_ar add get a_rb 41 n get oc 0 |
| 7877 | put a_ar add get a_rb 42 n get curfn 0 |
| 7878 | put a_ar add get a_rb 43 n f |
| 7879 | if ne get objmode 0 0 |
| 7880 | a_need 22 n |
| 7881 | note At the BL, SP is stkbytes + osp below the frame base; osp holds this call's save area too. |
| 7882 | t = get osp 0 |
| 7883 | if lt t get sva 0 |
| 7884 | t = get sva 0 |
| 7885 | end |
| 7886 | a_p 87 n add get stkbytes 0 t |
| 7887 | end |
| 7888 | put ncalls 0 add n 1 |
| 7889 | |
| 7890 | if ne get xtarget 0 0 |
| 7891 | emitb 232 |
| 7892 | xword 0 |
| 7893 | else |
| 7894 | if and ne get objmode 0 0 eq a_gu 32 sub f 1 2 |
| 7895 | emit 2483027968 |
| 7896 | else |
| 7897 | emit or 2483027968 bdisp get oc 0 get a_ar add get a_rb 22 sub f 1 26 |
| 7898 | end |
| 7899 | end |
| 7900 | end |
| 7901 | |
| 7902 | note ======== element addresses and array arguments ======== |
| 7903 | global ea_b ulong 1 |
| 7904 | global ea_i ulong 1 |
| 7905 | global ea_k ulong 1 |
| 7906 | note xea_g: on x86 targets, the address of the global whose element access is pending (ea_b 254, xbase) |
| 7907 | global xea_g ulong 1 |
| 7908 | |
| 7909 | note eaem: the load or store word base (LDOP / STOP register-offset form) of register rt at ea_b / ea_i. |
| 7910 | note ea_i 255 (OM-2, a number index k = ea_k up to 4095): the unsigned-offset form instead, same size, V |
| 7911 | note (bit 26, the SIMD&FP forms) and opc bits, imm12 = k scaled by the element size (LDR/STR (immediate), |
| 7912 | note C6.2.216 and its family; C7.2.191/C7.2.331). |
| 7913 | fn eaem wd ulong rg ulong to void |
| 7914 | b = get ea_b 0 |
| 7915 | if eq get ea_i 0 255 |
| 7916 | emit or or or or and wd 3300917248 956301312 shl get ea_k 0 10 shl b 5 rg |
| 7917 | ret |
| 7918 | end |
| 7919 | emit or or or wd rg shl b 5 shl get ea_i 0 16 |
| 7920 | end |
| 7921 | note elemaddr: array name e (index + 1), index value (kind, number or register, type). A number index must |
| 7922 | note be inside the array (error 21) and needs no check; a register index: CMP Xi, #len (C6.2.96) or CMP Xi, |
| 7923 | note Xt (C6.2.97), B.HS trap 3 (unsigned, so a negative signed index traps too). Out: ea_b base register |
| 7924 | note (the array's register, or a new one holding its address), ea_i index register. om4 ELEMADDR. |
| 7925 | note OM-2 unsized array (unsz): every index, a number too, is checked against its count register nm_lr |
| 7926 | note (CMP Xi, Xn; B.HS trap 3); none is eliminated (spec 4, 6). |
| 7927 | note OM-2 global with a pinned register (pinset): the base is that register and a long length is compared |
| 7928 | note with its pinned register (CMP Xi, Xp), so neither is rebuilt with MOVZ/MOVK at each access. |
| 7929 | fn elemaddr e ulong k ulong v ulong t ulong to void |
| 7930 | if ne get xtarget 0 0 |
| 7931 | xelem e k v t |
| 7932 | ret |
| 7933 | end |
| 7934 | if or or eq t 1 eq t 10 eq t 11 |
| 7935 | note d2site 117|elemaddr: type mismatch; condition if or or eq t 1 eq t 10 eq t 11 |
| 7936 | put d2site 0 117 |
| 7937 | fail 7 |
| 7938 | end |
| 7939 | i = sub e 1 |
| 7940 | ln = get a_ar add get a_rb 6 i |
| 7941 | if eq ln 0 |
| 7942 | if eq uchar get a_ar add get a_rb 7 i 10 |
| 7943 | ea_pool i k v t |
| 7944 | ret |
| 7945 | end |
| 7946 | end |
| 7947 | x = v |
| 7948 | if ne unsz i 0 |
| 7949 | x = matreg k v t |
| 7950 | emit or or 3942645791 shl ulong a_gu 14 i 16 shl x 5 |
| 7951 | trapc 2 3 |
| 7952 | else |
| 7953 | if eq k 3 |
| 7954 | if ge v ln |
| 7955 | note d2site 118|elemaddr: constant index outside the array; condition if ge v ln |
| 7956 | put d2site 0 118 |
| 7957 | fail 21 |
| 7958 | end |
| 7959 | if and ne get om2 0 0 le v 4095 |
| 7960 | x = ulong 255 |
| 7961 | put ea_k 0 v |
| 7962 | else |
| 7963 | x = alloc |
| 7964 | matconst x v |
| 7965 | end |
| 7966 | else |
| 7967 | if le ln 4095 |
| 7968 | emit or or 4043309087 shl ln 10 shl v 5 |
| 7969 | else |
| 7970 | if ne uchar get a_ar add get a_rb 11 i 0 |
| 7971 | emit or or 3942645791 shl ulong a_gu 11 i 16 shl v 5 |
| 7972 | else |
| 7973 | y = alloc |
| 7974 | matconst y ln |
| 7975 | emit or or 3942645791 shl y 16 shl v 5 |
| 7976 | end |
| 7977 | end |
| 7978 | trapc 2 3 |
| 7979 | end |
| 7980 | end |
| 7981 | put ea_i 0 x |
| 7982 | if ge uchar get a_ar add get a_rb 7 i 4 |
| 7983 | if ne uchar get a_ar add get a_rb 10 i 0 |
| 7984 | put ea_b 0 ulong a_gu 10 i |
| 7985 | else |
| 7986 | b = alloc |
| 7987 | mataddr b get a_ar add get a_rb 8 i |
| 7988 | put ea_b 0 b |
| 7989 | end |
| 7990 | else |
| 7991 | put ea_b 0 ulong a_gu 4 i |
| 7992 | end |
| 7993 | end |
| 7994 | |
| 7995 | note ea_pool: the element address of run-time pool i (docs/RUNTIME-POOLS.md s4) for index (k, v, t): the index |
| 7996 | note in a register, the slot's base and length in two more (LDP, C6.2.163), CMP index, length (C6.2.97), B.HS |
| 7997 | note trap 3. The slot is loaded here, after every operand of the access has been read (the soundness rule |
| 7998 | note B1: an enlarge inside an operand may move the pool). A number index is checked at run time like any |
| 7999 | note other: no error 21 and no check elimination, since the length is known only at run time. |
| 8000 | fn ea_pool i ulong k ulong v ulong t ulong to void |
| 8001 | x = matreg k v t |
| 8002 | b = alloc |
| 8003 | l = alloc |
| 8004 | mataddr b get a_ar add get a_rb 8 i |
| 8005 | emit or or or 2839543808 shl l 10 shl b 5 b |
| 8006 | emit or or 3942645791 shl l 16 shl x 5 |
| 8007 | note POOLMUT-ALT cmpdrop note removed |
| 8008 | note POOLMUT cmpdrop |
| 8009 | trapc 2 3 |
| 8010 | put ea_i 0 x |
| 8011 | put ea_b 0 b |
| 8012 | end |
| 8013 | |
| 8014 | note aa_word: the next word of an array argument must be a name of at most 63 bytes |
| 8015 | fn aa_word to void |
| 8016 | tok |
| 8017 | k = get tk 0 |
| 8018 | if eq k 0 |
| 8019 | note d2site 119|aa_word: the line ends where a word or value is needed; condition if eq k 0 |
| 8020 | put d2site 0 119 |
| 8021 | fail 4 |
| 8022 | end |
| 8023 | if ne k 1 |
| 8024 | note d2site 120|aa_word: syntax: unknown or misplaced word; condition if ne k 1 |
| 8025 | put d2site 0 120 |
| 8026 | fail 16 |
| 8027 | end |
| 8028 | if gt get tl 0 63 |
| 8029 | note d2site 121|aa_word: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63 |
| 8030 | put d2site 0 121 |
| 8031 | fail 13 |
| 8032 | end |
| 8033 | end |
| 8034 | |
| 8035 | note arrarg: an array argument for parameter pi of function f (index + 1): [view | edit] NAME. Its type and |
| 8036 | note length must equal the parameter's; an edit parameter needs a writable array (local or edit, error 20; |
| 8037 | note a view passed to it is error 20, OMEGESE.md 9.4); a global is never passed (error 19). Out: rk 5 |
| 8038 | note (register rv) or 6 (address rv, a text), rt the name entry. om4 ARRARG. |
| 8039 | note OM-2: an unsized parameter (length 0) takes an array of any length (erratum E2), whose count goes to |
| 8040 | note ul_k / ul_v at depth * 6 + pi: its count register, or its length as a number. `part` is read by arrpart. |
| 8041 | fn arrarg f ulong pi ulong to void |
| 8042 | md = ulong 0 |
| 8043 | aa_word |
| 8044 | w = get tw 0 |
| 8045 | c = kw w |
| 8046 | if ne c 0 |
| 8047 | if eq c 193 |
| 8048 | arrpart f pi 0 |
| 8049 | ret |
| 8050 | end |
| 8051 | if or lt c 57 gt c 58 |
| 8052 | note d2site 122|arrarg: syntax: unknown or misplaced word; condition if or lt c 57 gt c 58 |
| 8053 | put d2site 0 122 |
| 8054 | fail 16 |
| 8055 | end |
| 8056 | md = c |
| 8057 | aa_word |
| 8058 | w = get tw 0 |
| 8059 | if eq kw w 193 |
| 8060 | arrpart f pi md |
| 8061 | ret |
| 8062 | end |
| 8063 | end |
| 8064 | e = findname w |
| 8065 | if eq e 0 |
| 8066 | note d2site 123|arrarg: unknown name or field, or a word this mode does not provide; condition if eq e 0 |
| 8067 | put d2site 0 123 |
| 8068 | fail 3 |
| 8069 | end |
| 8070 | i = sub e 1 |
| 8071 | k = ulong uchar get a_ar add get a_rb 7 i |
| 8072 | if eq k 0 |
| 8073 | note d2site 124|arrarg: type mismatch; condition if eq k 0 |
| 8074 | put d2site 0 124 |
| 8075 | fail 7 |
| 8076 | end |
| 8077 | if eq k 10 |
| 8078 | note d2site 125|arrarg: global passed as an argument, or one array twice in a call; condition if eq k 10 |
| 8079 | put d2site 0 125 |
| 8080 | fail 19 |
| 8081 | end |
| 8082 | if ge k 6 |
| 8083 | note d2site 126|arrarg: type mismatch; condition if ge k 6 |
| 8084 | put d2site 0 126 |
| 8085 | fail 7 |
| 8086 | end |
| 8087 | if eq k 4 |
| 8088 | note d2site 127|arrarg: global passed as an argument, or one array twice in a call; condition if eq k 4 |
| 8089 | put d2site 0 127 |
| 8090 | fail 19 |
| 8091 | end |
| 8092 | p = add mul sub f 1 6 pi |
| 8093 | if eq a_gu 37 p 3 |
| 8094 | if eq md 57 |
| 8095 | note d2site 128|arrarg: write to a view or a text; condition if eq md 57 |
| 8096 | put d2site 0 128 |
| 8097 | fail 20 |
| 8098 | end |
| 8099 | if and ne k 1 ne k 3 |
| 8100 | note d2site 129|arrarg: write to a view or a text; condition if and ne k 1 ne k 3 |
| 8101 | put d2site 0 129 |
| 8102 | fail 20 |
| 8103 | end |
| 8104 | else |
| 8105 | if eq md 58 |
| 8106 | note d2site 130|arrarg: type mismatch; condition if eq md 58 |
| 8107 | put d2site 0 130 |
| 8108 | fail 7 |
| 8109 | end |
| 8110 | end |
| 8111 | if ne a_gu 5 i a_gu 35 p |
| 8112 | note d2site 131|arrarg: type mismatch; condition if ne a_gu 5 i a_gu 35 p |
| 8113 | put d2site 0 131 |
| 8114 | fail 7 |
| 8115 | end |
| 8116 | ux = add mul get depth 0 6 pi |
| 8117 | if eq a_g 36 p 0 |
| 8118 | if ne unsz i 0 |
| 8119 | a_p 79 ux 1 |
| 8120 | a_p 80 ux ulong a_gu 14 i |
| 8121 | else |
| 8122 | a_p 79 ux 3 |
| 8123 | a_p 80 ux a_g 6 i |
| 8124 | end |
| 8125 | else |
| 8126 | if ne a_g 6 i a_g 36 p |
| 8127 | note d2site 132|arrarg: type mismatch; condition if ne a_g 6 i a_g 36 p |
| 8128 | put d2site 0 132 |
| 8129 | fail 7 |
| 8130 | end |
| 8131 | end |
| 8132 | put rt 0 e |
| 8133 | if eq k 5 |
| 8134 | put rk 0 6 |
| 8135 | put rv 0 a_g 8 i |
| 8136 | else |
| 8137 | put rk 0 5 |
| 8138 | put rv 0 ulong a_gu 4 i |
| 8139 | end |
| 8140 | end |
| 8141 | |
| 8142 | note arrpart (OM-2, spec 6): `part A o k` as argument pi of function f (index + 1); md 57 / 58 when `view` / |
| 8143 | note `edit` was written before it. A is a name (a global is error 19, a fresh array 27); o, then k, are |
| 8144 | note ulong values. Checks, in this order: o <= len A (CMP Xo, Xlen; B.HI trap 3), then k <= len A - o (SUB, |
| 8145 | note CMP, B.HI trap 3); the wrapped o + k is never formed. The part is a view of A + o * size with count k: |
| 8146 | note an edit when A is writable (local or edit) and no `view` was written, else a view. It goes only to an |
| 8147 | note unsized parameter (error 7). Out as arrarg; rt is A, so for error 19 the part counts as its base. |
| 8148 | fn arrpart f ulong pi ulong md ulong to void |
| 8149 | p = add mul sub f 1 6 pi |
| 8150 | e = arrname 1 |
| 8151 | i = sub e 1 |
| 8152 | k = ulong uchar get a_ar add get a_rb 7 i |
| 8153 | if eq k 10 |
| 8154 | note d2site 133|arrpart: global passed as an argument, or one array twice in a call; condition if eq k 10 |
| 8155 | put d2site 0 133 |
| 8156 | fail 19 |
| 8157 | end |
| 8158 | if ge k 6 |
| 8159 | note d2site 134|arrpart: type mismatch; condition if ge k 6 |
| 8160 | put d2site 0 134 |
| 8161 | fail 7 |
| 8162 | end |
| 8163 | if eq k 4 |
| 8164 | note d2site 135|arrpart: global passed as an argument, or one array twice in a call; condition if eq k 4 |
| 8165 | put d2site 0 135 |
| 8166 | fail 19 |
| 8167 | end |
| 8168 | fz_arg e |
| 8169 | if eq uchar get a_ar add get a_rb 37 p 3 |
| 8170 | if eq md 57 |
| 8171 | note d2site 136|arrpart: write to a view or a text; condition if eq md 57 |
| 8172 | put d2site 0 136 |
| 8173 | fail 20 |
| 8174 | end |
| 8175 | if and ne k 1 ne k 3 |
| 8176 | note d2site 137|arrpart: write to a view or a text; condition if and ne k 1 ne k 3 |
| 8177 | put d2site 0 137 |
| 8178 | fail 20 |
| 8179 | end |
| 8180 | else |
| 8181 | if eq md 58 |
| 8182 | note d2site 138|arrpart: type mismatch; condition if eq md 58 |
| 8183 | put d2site 0 138 |
| 8184 | fail 7 |
| 8185 | end |
| 8186 | end |
| 8187 | if ne ulong a_gu 5 i ulong a_gu 35 p |
| 8188 | note d2site 139|arrpart: type mismatch; condition if ne ulong a_gu 5 i ulong a_gu 35 p |
| 8189 | put d2site 0 139 |
| 8190 | fail 7 |
| 8191 | end |
| 8192 | if ne get a_ar add get a_rb 36 p 0 |
| 8193 | note d2site 140|arrpart: type mismatch; condition if ne get a_ar add get a_rb 36 p 0 |
| 8194 | put d2site 0 140 |
| 8195 | fail 7 |
| 8196 | end |
| 8197 | rdval 0 5 255 0 |
| 8198 | k = get rt 0 |
| 8199 | if and ne k 5 ne k 13 |
| 8200 | note d2site 141|arrpart: type mismatch; condition if and ne k 5 ne k 13 |
| 8201 | put d2site 0 141 |
| 8202 | fail 7 |
| 8203 | end |
| 8204 | ro = matreg get rk 0 get rv 0 k |
| 8205 | rdval 0 5 255 0 |
| 8206 | k = get rt 0 |
| 8207 | if and ne k 5 ne k 13 |
| 8208 | note d2site 142|arrpart: type mismatch; condition if and ne k 5 ne k 13 |
| 8209 | put d2site 0 142 |
| 8210 | fail 7 |
| 8211 | end |
| 8212 | rn = matreg get rk 0 get rv 0 k |
| 8213 | d = partck i ro rn |
| 8214 | ux = add mul get depth 0 6 pi |
| 8215 | a_p 79 ux 1 |
| 8216 | a_p 80 ux rn |
| 8217 | put rt 0 e |
| 8218 | put rk 0 5 |
| 8219 | put rv 0 d |
| 8220 | end |
| 8221 | |
| 8222 | note partck: the two checks of part (name index i, o in ro, k in rn), then the part's base register |
| 8223 | fn partck i ulong ro ulong rn ulong to ulong |
| 8224 | rl = ulong uchar get a_ar add get a_rb 14 i |
| 8225 | if eq unsz i 0 |
| 8226 | rl = alloc |
| 8227 | matconst rl get a_ar add get a_rb 6 i |
| 8228 | end |
| 8229 | if ne get xtarget 0 0 |
| 8230 | xcmp ro rl 0 |
| 8231 | xtrap 8 3 |
| 8232 | d = alloc |
| 8233 | xarith 34 5 rl ro 0 d |
| 8234 | xcmp rn d 0 |
| 8235 | xtrap 8 3 |
| 8236 | b = ulong uchar get a_ar add get a_rb 4 i |
| 8237 | if eq uchar get a_ar add get a_rb 7 i 5 |
| 8238 | b = alloc |
| 8239 | mataddr b get a_ar add get a_rb 8 i |
| 8240 | end |
| 8241 | xload 0 ro |
| 8242 | xb 72 193 224 |
| 8243 | emitb uchar tlog ulong uchar get a_ar add get a_rb 5 i |
| 8244 | xload 1 b |
| 8245 | xrr 1 0 1 |
| 8246 | xstore 0 d |
| 8247 | ret d |
| 8248 | end |
| 8249 | emit or or 3942645791 shl rl 16 shl ro 5 |
| 8250 | trapc 8 3 |
| 8251 | d = alloc |
| 8252 | e3 3405774848 d rl ro |
| 8253 | emit or or 3942645791 shl d 16 shl rn 5 |
| 8254 | trapc 8 3 |
| 8255 | b = ulong uchar get a_ar add get a_rb 4 i |
| 8256 | if eq uchar get a_ar add get a_rb 7 i 5 |
| 8257 | b = alloc |
| 8258 | mataddr b get a_ar add get a_rb 8 i |
| 8259 | end |
| 8260 | emit or or or or 2332033024 shl ro 16 shl tlog ulong a_gu 5 i 10 shl b 5 d |
| 8261 | ret d |
| 8262 | end |
| 8263 | |
| 8264 | note ======== the parts of the value reader that read no further value ======== |
| 8265 | fn vdec to void |
| 8266 | if and ne get cpure 0 0 ge get rt 0 10 |
| 8267 | note d2site 143|vdec: contract syntax misplaced or not supported here (IR mode included); condition if and ne get cpure 0 0 ge get rt 0 10 |
| 8268 | put d2site 0 143 |
| 8269 | fail 30 |
| 8270 | end |
| 8271 | put depth 0 sub get depth 0 1 |
| 8272 | end |
| 8273 | |
| 8274 | note vdone: a value's result, and one nesting level less (om4 VT_RET) |
| 8275 | fn vdone k ulong v ulong t ulong to void |
| 8276 | put rk 0 k |
| 8277 | put rv 0 v |
| 8278 | put rt 0 t |
| 8279 | vdec |
| 8280 | end |
| 8281 | |
| 8282 | note fwreq: hand this depth's fpw request to the part that makes the value (fpo) |
| 8283 | fn fwreq to void |
| 8284 | put fpo 0 get a_ar add get a_rb 78 get depth 0 |
| 8285 | end |
| 8286 | |
| 8287 | note vt_un: neg / not of the value in rk/rv/rt (a bare number already refused). neg: NEG Xd, Xm (SUB from |
| 8288 | note XZR, C6.2.458; the 32-bit form for u32), i64 NEGS + B.VS trap 1 (C6.2.465), then the wrap or the |
| 8289 | note sign check; not: bool EOR Xd, Xn, #1 (C6.2.155), else MVN (ORN from XZR, C6.2.300), then the wrap. |
| 8290 | note om4 VU1 .. VU_E. Float neg: FNEG (C7.2.144) of the operand's v register; with a request (fpo) the |
| 8291 | note result stays in a twin (kind 9). |
| 8292 | fn vt_un c ulong dst ulong to void |
| 8293 | o = get fpo 0 |
| 8294 | put fpo 0 0 |
| 8295 | if ne get fzone 0 0 |
| 8296 | if eq get rk 0 3 |
| 8297 | foldun c get rt 0 get rv 0 |
| 8298 | if ne get fok 0 0 |
| 8299 | put rv 0 get fval 0 |
| 8300 | ret |
| 8301 | end |
| 8302 | end |
| 8303 | end |
| 8304 | if ne get xtarget 0 0 |
| 8305 | xunary c dst |
| 8306 | ret |
| 8307 | end |
| 8308 | ty = get rt 0 |
| 8309 | if or eq ty 10 eq ty 11 |
| 8310 | if eq c 50 |
| 8311 | note d2site 144|vt_un: type mismatch; condition if eq c 50 |
| 8312 | put d2site 0 144 |
| 8313 | fail 7 |
| 8314 | end |
| 8315 | va = fvop get rk 0 get rv 0 ty 0 |
| 8316 | if eq o 0 |
| 8317 | rd = destreg dst |
| 8318 | fp_neg ty va 1 |
| 8319 | fv2x ty 1 rd |
| 8320 | put rk 0 1 |
| 8321 | put rv 0 rd |
| 8322 | else |
| 8323 | r = fvdst o |
| 8324 | fp_neg ty va vtw r |
| 8325 | put rk 0 9 |
| 8326 | put rv 0 r |
| 8327 | end |
| 8328 | put rt 0 ty |
| 8329 | ret |
| 8330 | end |
| 8331 | ra = matreg get rk 0 get rv 0 ty |
| 8332 | rd = destreg dst |
| 8333 | if eq c 50 |
| 8334 | if eq ty 13 |
| 8335 | note d2site 145|vt_un: type mismatch; condition if eq ty 13 |
| 8336 | put d2site 0 145 |
| 8337 | fail 7 |
| 8338 | end |
| 8339 | if eq ty 1 |
| 8340 | e3 3527409664 rd ra 0 |
| 8341 | else |
| 8342 | if eq ty 4 |
| 8343 | e3 706741216 rd 0 ra |
| 8344 | else |
| 8345 | e3 2854224864 rd 0 ra |
| 8346 | if lt ty 6 |
| 8347 | canon rd ty |
| 8348 | end |
| 8349 | end |
| 8350 | end |
| 8351 | else |
| 8352 | if or eq ty 1 eq ty 13 |
| 8353 | note d2site 146|vt_un: type mismatch; condition if or eq ty 1 eq ty 13 |
| 8354 | put d2site 0 146 |
| 8355 | fail 7 |
| 8356 | end |
| 8357 | if eq ty 9 |
| 8358 | e3 3942646752 rd 0 ra |
| 8359 | trapc 6 1 |
| 8360 | else |
| 8361 | if eq ty 4 |
| 8362 | e3 1258292192 rd 0 ra |
| 8363 | else |
| 8364 | e3 3405775840 rd 0 ra |
| 8365 | if lt ty 6 |
| 8366 | canon rd ty |
| 8367 | else |
| 8368 | chkext rd ty 1 |
| 8369 | end |
| 8370 | end |
| 8371 | end |
| 8372 | end |
| 8373 | put rk 0 1 |
| 8374 | put rv 0 rd |
| 8375 | put rt 0 ty |
| 8376 | end |
| 8377 | |
| 8378 | note vt_conv: the value in rk/rv/rt converted to type tt (neither bool, error 9). Out of range when any bit |
| 8379 | note at or above s is set: LSR Xt, Xa, #s (UBFM, C6.2.487); CBNZ Xt trap 5 (C6.2.77); signed to a narrower |
| 8380 | note signed type: the sign-extension check, trap 5. om4 VTT1 .. VC_OK. To a float with a request (fpo): the |
| 8381 | note conversion is made in a twin (kind 9); the same float type is left as it is. |
| 8382 | fn vt_conv tt ulong to void |
| 8383 | if ne get xtarget 0 0 |
| 8384 | xconv tt |
| 8385 | ret |
| 8386 | end |
| 8387 | o = get fpo 0 |
| 8388 | put fpo 0 0 |
| 8389 | ft = get rt 0 |
| 8390 | if or or or eq ft 10 eq ft 11 eq tt 10 eq tt 11 |
| 8391 | if or eq ft 13 eq tt 13 |
| 8392 | note d2site 147|vt_conv: type mismatch; condition if or eq ft 13 eq tt 13 |
| 8393 | put d2site 0 147 |
| 8394 | fail 7 |
| 8395 | end |
| 8396 | if eq ft 1 |
| 8397 | note d2site 148|vt_conv: word or declaration in a place that does not allow it; condition if eq ft 1 |
| 8398 | put d2site 0 148 |
| 8399 | fail 9 |
| 8400 | end |
| 8401 | if eq tt 1 |
| 8402 | note d2site 149|vt_conv: word or declaration in a place that does not allow it; condition if eq tt 1 |
| 8403 | put d2site 0 149 |
| 8404 | fail 9 |
| 8405 | end |
| 8406 | if and ne o 0 ne isfloat tt 0 |
| 8407 | if eq ft tt |
| 8408 | ret |
| 8409 | end |
| 8410 | ra = matreg get rk 0 get rv 0 ft |
| 8411 | r = fvdst o |
| 8412 | fp_tov ft tt ra vtw r |
| 8413 | put rk 0 9 |
| 8414 | put rv 0 r |
| 8415 | put rt 0 tt |
| 8416 | ret |
| 8417 | end |
| 8418 | ra = matreg get rk 0 get rv 0 ft |
| 8419 | rd = fp_conv ft tt ra |
| 8420 | put rk 0 1 |
| 8421 | put rv 0 rd |
| 8422 | put rt 0 tt |
| 8423 | ret |
| 8424 | end |
| 8425 | ra = matreg get rk 0 get rv 0 ft |
| 8426 | if eq ft 1 |
| 8427 | note d2site 150|vt_conv: word or declaration in a place that does not allow it; condition if eq ft 1 |
| 8428 | put d2site 0 150 |
| 8429 | fail 9 |
| 8430 | end |
| 8431 | if eq tt 1 |
| 8432 | note d2site 151|vt_conv: word or declaration in a place that does not allow it; condition if eq tt 1 |
| 8433 | put d2site 0 151 |
| 8434 | fail 9 |
| 8435 | end |
| 8436 | wf = twid ft |
| 8437 | wt = twid tt |
| 8438 | s = ulong 99 |
| 8439 | sgf = and ge ft 6 le ft 9 |
| 8440 | sgt = and ge tt 6 le tt 9 |
| 8441 | if eq sgf 0 |
| 8442 | if ne sgt 0 |
| 8443 | if ge wf wt |
| 8444 | s = sub wt 1 |
| 8445 | end |
| 8446 | else |
| 8447 | if gt wf wt |
| 8448 | s = wt |
| 8449 | end |
| 8450 | end |
| 8451 | else |
| 8452 | if eq sgt 0 |
| 8453 | s = wt |
| 8454 | if gt s 63 |
| 8455 | s = ulong 63 |
| 8456 | end |
| 8457 | else |
| 8458 | if gt wf wt |
| 8459 | chkext ra tt 5 |
| 8460 | end |
| 8461 | end |
| 8462 | end |
| 8463 | if ne s 99 |
| 8464 | t = alloc |
| 8465 | emit or or or 3544251392 t shl s 16 shl ra 5 |
| 8466 | trapsite or 3036676096 t 5 |
| 8467 | end |
| 8468 | put rk 0 1 |
| 8469 | put rv 0 ra |
| 8470 | put rt 0 tt |
| 8471 | end |
| 8472 | |
| 8473 | note vt_get: get A i with the index value in rk/rv/rt: the element address, then the load of the element |
| 8474 | note type, register offset (LDOP table). om4 VT_GET. A float element with a request (fpo) loads straight |
| 8475 | note into a twin: the same word with V (bit 26), LDR St/Dt (C7.2.192) (kind 9). |
| 8476 | fn vt_get e ulong dst ulong to void |
| 8477 | if ne get xtarget 0 0 |
| 8478 | elemaddr e get rk 0 get rv 0 get rt 0 |
| 8479 | st_ld get ea_b 0 get ea_i 0 ulong a_gu 5 sub e 1 dst |
| 8480 | ret |
| 8481 | end |
| 8482 | o = get fpo 0 |
| 8483 | put fpo 0 0 |
| 8484 | elemaddr e get rk 0 get rv 0 get rt 0 |
| 8485 | ty = ulong uchar get a_ar add get a_rb 5 sub e 1 |
| 8486 | if and ne o 0 ne isfloat ty 0 |
| 8487 | r = fvdst o |
| 8488 | eaem or ldop ty 67108864 vtw r |
| 8489 | put rk 0 9 |
| 8490 | put rv 0 r |
| 8491 | put rt 0 ty |
| 8492 | ret |
| 8493 | end |
| 8494 | rd = destreg dst |
| 8495 | eaem ldop ty rd |
| 8496 | put rk 0 1 |
| 8497 | put rv 0 rd |
| 8498 | put rt 0 ty |
| 8499 | end |
| 8500 | |
| 8501 | note pl_len: len P of run-time pool e (index + 1): a run-time load of the slot's length (LDR, C6.2.214), never |
| 8502 | note a constant, so a contract on it is checked at run time (docs/RUNTIME-POOLS.md s5). x86linux: LEA RAX, |
| 8503 | note [RIP + slot] (SDM vol 2 LEA), MOV RAX, [RAX + 8] (MOV 8B /r), stored to the destination slot. |
| 8504 | fn pl_len e ulong dst ulong to void |
| 8505 | rd = destreg dst |
| 8506 | if ne get xtarget 0 0 |
| 8507 | xaddr 0 get a_ar add get a_rb 8 sub e 1 |
| 8508 | xmem 139 0 0 8 |
| 8509 | xstore 0 rd |
| 8510 | vdone 1 rd 5 |
| 8511 | ret |
| 8512 | end |
| 8513 | mataddr rd get a_ar add get a_rb 8 sub e 1 |
| 8514 | emit or or 4181722112 shl rd 5 rd |
| 8515 | vdone 1 rd 5 |
| 8516 | end |
| 8517 | |
| 8518 | note vs_chk: read / write bounds: n <= len A and off <= len A - n, else trap 3 (CMP C6.2.97, B.HI C6.2.34, |
| 8519 | note SUB C6.2.458). om4 VT_SYS. |
| 8520 | fn vs_chk e ulong ro ulong rn ulong to void |
| 8521 | if ne get xtarget 0 0 |
| 8522 | if ne uchar get a_ar add get a_rb 5 sub e 1 2 |
| 8523 | note d2site 152|vs_chk: type mismatch; condition if ne uchar get a_ar add get a_rb 5 sub e 1 2 |
| 8524 | put d2site 0 152 |
| 8525 | fail 7 |
| 8526 | end |
| 8527 | xload 1 rn |
| 8528 | if eq uchar get a_ar add get a_rb 7 sub e 1 10 |
| 8529 | note x86linux pool: the length is loaded from the slot after every operand (soundness rule B1) |
| 8530 | xaddr 0 get a_ar add get a_rb 8 sub e 1 |
| 8531 | xmem 139 0 0 8 |
| 8532 | else |
| 8533 | if ne unsz sub e 1 0 |
| 8534 | xload 0 ulong uchar get a_ar add get a_rb 14 sub e 1 |
| 8535 | else |
| 8536 | ximm 0 get a_ar add get a_rb 6 sub e 1 |
| 8537 | end |
| 8538 | end |
| 8539 | xrr 57 1 0 |
| 8540 | xtrap 8 3 |
| 8541 | xrr 41 0 1 |
| 8542 | xload 1 ro |
| 8543 | xrr 57 1 0 |
| 8544 | xtrap 8 3 |
| 8545 | ret |
| 8546 | end |
| 8547 | if ne uchar get a_ar add get a_rb 5 sub e 1 2 |
| 8548 | note d2site 153|vs_chk: type mismatch; condition if ne uchar get a_ar add get a_rb 5 sub e 1 2 |
| 8549 | put d2site 0 153 |
| 8550 | fail 7 |
| 8551 | end |
| 8552 | t = alloc |
| 8553 | l = ulong uchar get a_ar add get a_rb 14 sub e 1 |
| 8554 | if eq uchar get a_ar add get a_rb 7 sub e 1 10 |
| 8555 | l = alloc |
| 8556 | mataddr l get a_ar add get a_rb 8 sub e 1 |
| 8557 | emit or or 4181722112 shl l 5 l |
| 8558 | else |
| 8559 | if eq unsz sub e 1 0 |
| 8560 | l = t |
| 8561 | matconst t get a_ar add get a_rb 6 sub e 1 |
| 8562 | end |
| 8563 | end |
| 8564 | emit or or 3942645791 shl rn 5 shl l 16 |
| 8565 | trapc 8 3 |
| 8566 | e3 3405774848 t l rn |
| 8567 | emit or or 3942645791 shl ro 5 shl t 16 |
| 8568 | trapc 8 3 |
| 8569 | end |
| 8570 | |
| 8571 | note vs_call: save the registers in use, X0 = fd, X1 = A + off (ADD through X16, C6.2.6), X2 = n, X8 = 63 |
| 8572 | note (read) or 64 (write) (MOVZ C6.2.285), SVC #0 (C6.2.466). om4 VT_SYS. |
| 8573 | fn vs_call c ulong fk ulong fv ulong e ulong ro ulong rn ulong to void |
| 8574 | if ne get xtarget 0 0 |
| 8575 | xio c fk fv e ro rn |
| 8576 | ret |
| 8577 | end |
| 8578 | note target a64efi: read and write are Linux system calls; there is no Linux beneath the image |
| 8579 | if ne get xefa 0 0 |
| 8580 | note d2site 154|vs_call: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if ne get xefa 0 0 |
| 8581 | put d2site 0 154 |
| 8582 | fail 25 |
| 8583 | end |
| 8584 | save |
| 8585 | loadarg 0 fk fv |
| 8586 | basearg 1 e |
| 8587 | loadarg 16 1 ro |
| 8588 | emit 2333081633 |
| 8589 | loadarg 2 1 rn |
| 8590 | emit or 3531603976 shl add c 10 5 |
| 8591 | emit 3556769793 |
| 8592 | end |
| 8593 | |
| 8594 | note ca_scal: a scalar argument just read (rk/rv/rt) for parameter p: flags into a register; its type |
| 8595 | note must be the parameter's; stored at fr[q..q+2]. om4 CA1 .. CA_PUT. |
| 8596 | fn ca_scal p ulong q ulong to void |
| 8597 | if eq get rk 0 4 |
| 8598 | put rv 0 matreg 4 get rv 0 get rt 0 |
| 8599 | put rk 0 1 |
| 8600 | put rt 0 1 |
| 8601 | end |
| 8602 | if ne get rt 0 ulong uchar get a_ar add get a_rb 35 p |
| 8603 | note d2site 155|ca_scal: type mismatch; condition if ne get rt 0 ulong uchar get a_ar add get a_rb 35 p |
| 8604 | put d2site 0 155 |
| 8605 | fail 7 |
| 8606 | end |
| 8607 | put a_ar add get a_rb 77 q get rk 0 |
| 8608 | put a_ar add get a_rb 77 add q 1 get rv 0 |
| 8609 | put a_ar add get a_rb 77 add q 2 0 |
| 8610 | end |
| 8611 | |
| 8612 | note ca_arr: an array argument i of function f, call frame cb: one array passed twice is error 19. |
| 8613 | note om4 CA_ARR .. CA_PUT. |
| 8614 | fn ca_arr f ulong i ulong cb ulong to void |
| 8615 | arrarg f i |
| 8616 | j = ulong 0 |
| 8617 | while lt j i |
| 8618 | if eq a_g 77 add add cb mul j 3 2 get rt 0 |
| 8619 | note d2site 156|ca_arr: global passed as an argument, or one array twice in a call; condition if eq a_g 77 add add cb mul j 3 2 get rt 0 |
| 8620 | put d2site 0 156 |
| 8621 | fail 19 |
| 8622 | end |
| 8623 | j = add j 1 |
| 8624 | end |
| 8625 | q = add cb mul i 3 |
| 8626 | put a_ar add get a_rb 77 q get rk 0 |
| 8627 | put a_ar add get a_rb 77 add q 1 get rv 0 |
| 8628 | put a_ar add get a_rb 77 add q 2 get rt 0 |
| 8629 | end |
| 8630 | |
| 8631 | note ca_end: all arguments read: save, the arguments into X0.., BL, restore. Frame cb: 3 per argument, |
| 8632 | note then cb+18 the parameter count, cb+19 the pool slot before the arguments. om4 CA_DONE .. CA5. |
| 8633 | fn ca_end f ulong dst ulong cb ulong to void |
| 8634 | save |
| 8635 | np = get a_ar add get a_rb 77 add cb 18 |
| 8636 | i = ulong 0 |
| 8637 | while lt i np |
| 8638 | q = add cb mul i 3 |
| 8639 | s = pslot sub f 1 i |
| 8640 | loadarg s a_g 77 q a_g 77 add q 1 |
| 8641 | if eq pwid add mul sub f 1 6 i 2 |
| 8642 | ux = add mul div cb 32 6 i |
| 8643 | loadarg add s 1 a_g 79 ux a_g 80 ux |
| 8644 | end |
| 8645 | i = add i 1 |
| 8646 | end |
| 8647 | ca_bl f |
| 8648 | hr = ulong 1 |
| 8649 | if eq uchar get a_ar add get a_rb 23 sub f 1 12 |
| 8650 | hr = ulong 0 |
| 8651 | end |
| 8652 | n = get svn 0 |
| 8653 | a = get sva 0 |
| 8654 | sl = get a_ar add get a_rb 77 add cb 19 |
| 8655 | r = restore dst sl n a hr |
| 8656 | put rk 0 1 |
| 8657 | put rv 0 r |
| 8658 | put rt 0 ulong a_gu 23 sub f 1 |
| 8659 | end |
| 8660 | |
| 8661 | note vs_fd, vs_arr, vs_off, vs_end: the steps of read / write between the values it reads, with the fd |
| 8662 | note (kind, value), the offset register and the pool slot before kept in fr[x+8..x+11] (om4's VT_SYS |
| 8663 | note frame slots 4, 5, 7 and 14) |
| 8664 | fn vs_fd x ulong to void |
| 8665 | if ne get rt 0 8 |
| 8666 | note d2site 157|vs_fd: type mismatch; condition if ne get rt 0 8 |
| 8667 | put d2site 0 157 |
| 8668 | fail 7 |
| 8669 | end |
| 8670 | put a_ar add get a_rb 77 add x 9 get rk 0 |
| 8671 | put a_ar add get a_rb 77 add x 10 get rv 0 |
| 8672 | end |
| 8673 | |
| 8674 | fn vs_arr c ulong e ulong to void |
| 8675 | fz_arg e |
| 8676 | if ge uchar get a_ar add get a_rb 7 sub e 1 6 |
| 8677 | if ne uchar get a_ar add get a_rb 7 sub e 1 10 |
| 8678 | note d2site 158|vs_arr: type mismatch; condition if ne uchar get a_ar add get a_rb 7 sub e 1 10 |
| 8679 | put d2site 0 158 |
| 8680 | fail 7 |
| 8681 | end |
| 8682 | end |
| 8683 | if eq c 53 |
| 8684 | k = uchar get a_ar add get a_rb 7 sub e 1 |
| 8685 | if or eq k 2 eq k 5 |
| 8686 | note d2site 159|vs_arr: write to a view or a text; condition if or eq k 2 eq k 5 |
| 8687 | put d2site 0 159 |
| 8688 | fail 20 |
| 8689 | end |
| 8690 | end |
| 8691 | end |
| 8692 | |
| 8693 | fn vs_off x ulong to void |
| 8694 | if ne get rt 0 5 |
| 8695 | note d2site 160|vs_off: type mismatch; condition if ne get rt 0 5 |
| 8696 | put d2site 0 160 |
| 8697 | fail 7 |
| 8698 | end |
| 8699 | put a_ar add get a_rb 77 add x 11 matreg get rk 0 get rv 0 get rt 0 |
| 8700 | end |
| 8701 | |
| 8702 | fn vs_end c ulong e ulong dst ulong x ulong to void |
| 8703 | if ne get rt 0 5 |
| 8704 | note d2site 161|vs_end: type mismatch; condition if ne get rt 0 5 |
| 8705 | put d2site 0 161 |
| 8706 | fail 7 |
| 8707 | end |
| 8708 | rn = matreg get rk 0 get rv 0 get rt 0 |
| 8709 | ro = get a_ar add get a_rb 77 add x 11 |
| 8710 | vs_chk e ro rn |
| 8711 | fk = get a_ar add get a_rb 77 add x 9 |
| 8712 | fv = get a_ar add get a_rb 77 add x 10 |
| 8713 | vs_call c fk fv e ro rn |
| 8714 | sl = get a_ar add get a_rb 77 add x 8 |
| 8715 | n = get svn 0 |
| 8716 | a = get sva 0 |
| 8717 | r = restore dst sl n a 1 |
| 8718 | vdone 1 r 9 |
| 8719 | end |
| 8720 | |
| 8721 | note Native Linux ARM64 host operations. Encoding forms are those in seed/rung2/table.s2. |
| 8722 | note Syscall numbers and layouts: Linux asm-generic/unistd.h, fcntl.h and time.h. |
| 8723 | note No raw address or arbitrary syscall is exposed to an Omega program. |
| 8724 | fn hargc c ulong to ulong |
| 8725 | if eq c 107 |
| 8726 | ret 0 |
| 8727 | end |
| 8728 | if eq c 109 |
| 8729 | ret 0 |
| 8730 | end |
| 8731 | if eq c 129 |
| 8732 | ret 0 |
| 8733 | end |
| 8734 | if eq c 145 |
| 8735 | ret 0 |
| 8736 | end |
| 8737 | if eq c 146 |
| 8738 | ret 0 |
| 8739 | end |
| 8740 | if eq c 147 |
| 8741 | ret 0 |
| 8742 | end |
| 8743 | if eq c 148 |
| 8744 | ret 0 |
| 8745 | end |
| 8746 | if eq c 154 |
| 8747 | ret 0 |
| 8748 | end |
| 8749 | if eq c 158 |
| 8750 | ret 0 |
| 8751 | end |
| 8752 | if eq c 100 |
| 8753 | ret 1 |
| 8754 | end |
| 8755 | if eq c 101 |
| 8756 | ret 1 |
| 8757 | end |
| 8758 | if eq c 153 |
| 8759 | ret 1 |
| 8760 | end |
| 8761 | if eq c 155 |
| 8762 | ret 1 |
| 8763 | end |
| 8764 | if eq c 156 |
| 8765 | ret 1 |
| 8766 | end |
| 8767 | if eq c 159 |
| 8768 | ret 1 |
| 8769 | end |
| 8770 | if eq c 163 |
| 8771 | ret 1 |
| 8772 | end |
| 8773 | if eq c 164 |
| 8774 | ret 1 |
| 8775 | end |
| 8776 | if eq c 102 |
| 8777 | ret 2 |
| 8778 | end |
| 8779 | if eq c 105 |
| 8780 | ret 2 |
| 8781 | end |
| 8782 | if eq c 106 |
| 8783 | ret 2 |
| 8784 | end |
| 8785 | if eq c 127 |
| 8786 | ret 2 |
| 8787 | end |
| 8788 | if eq c 139 |
| 8789 | ret 2 |
| 8790 | end |
| 8791 | if eq c 160 |
| 8792 | ret 2 |
| 8793 | end |
| 8794 | if eq c 165 |
| 8795 | ret 2 |
| 8796 | end |
| 8797 | if eq c 197 |
| 8798 | ret 2 |
| 8799 | end |
| 8800 | if eq c 240 |
| 8801 | ret 2 |
| 8802 | end |
| 8803 | ret 3 |
| 8804 | end |
| 8805 | fn hsysno c ulong to ulong |
| 8806 | if eq c 127 |
| 8807 | ret 129 |
| 8808 | end |
| 8809 | if eq c 129 |
| 8810 | ret 172 |
| 8811 | end |
| 8812 | if eq c 100 |
| 8813 | ret 57 |
| 8814 | end |
| 8815 | if eq c 101 |
| 8816 | ret 82 |
| 8817 | end |
| 8818 | if eq c 102 |
| 8819 | ret 52 |
| 8820 | end |
| 8821 | if eq c 103 |
| 8822 | ret 62 |
| 8823 | end |
| 8824 | if eq c 104 |
| 8825 | ret 198 |
| 8826 | end |
| 8827 | if eq c 139 |
| 8828 | ret 46 |
| 8829 | end |
| 8830 | if eq c 145 |
| 8831 | ret 174 |
| 8832 | end |
| 8833 | if eq c 146 |
| 8834 | ret 175 |
| 8835 | end |
| 8836 | if eq c 147 |
| 8837 | ret 176 |
| 8838 | end |
| 8839 | if eq c 148 |
| 8840 | ret 177 |
| 8841 | end |
| 8842 | if eq c 144 |
| 8843 | ret 48 |
| 8844 | end |
| 8845 | if eq c 153 |
| 8846 | ret 50 |
| 8847 | end |
| 8848 | if eq c 154 |
| 8849 | ret 173 |
| 8850 | end |
| 8851 | if eq c 155 |
| 8852 | ret 166 |
| 8853 | end |
| 8854 | if eq c 156 |
| 8855 | ret 83 |
| 8856 | end |
| 8857 | if eq c 157 |
| 8858 | ret 279 |
| 8859 | end |
| 8860 | if eq c 158 |
| 8861 | ret 157 |
| 8862 | end |
| 8863 | if eq c 159 |
| 8864 | ret 155 |
| 8865 | end |
| 8866 | if eq c 160 |
| 8867 | ret 154 |
| 8868 | end |
| 8869 | if eq c 163 |
| 8870 | ret 156 |
| 8871 | end |
| 8872 | if eq c 164 |
| 8873 | ret 267 |
| 8874 | end |
| 8875 | if eq c 165 |
| 8876 | ret 210 |
| 8877 | end |
| 8878 | if eq c 197 |
| 8879 | ret 32 |
| 8880 | end |
| 8881 | if eq c 105 |
| 8882 | ret 201 |
| 8883 | end |
| 8884 | if eq c 106 |
| 8885 | ret 242 |
| 8886 | end |
| 8887 | if eq c 107 |
| 8888 | ret 220 |
| 8889 | end |
| 8890 | if eq c 239 |
| 8891 | ret 140 |
| 8892 | end |
| 8893 | if eq c 240 |
| 8894 | ret 141 |
| 8895 | end |
| 8896 | ret 24 |
| 8897 | end |
| 8898 | fn harg x ulong i ulong ty ulong to void |
| 8899 | rdval 0 ty 255 0 |
| 8900 | if ne get rt 0 ty |
| 8901 | note d2site 162|harg: type mismatch; condition if ne get rt 0 ty |
| 8902 | put d2site 0 162 |
| 8903 | fail 7 |
| 8904 | end |
| 8905 | q = add add x 8 mul i 2 |
| 8906 | put a_ar add get a_rb 77 q get rk 0 |
| 8907 | put a_ar add get a_rb 77 add q 1 get rv 0 |
| 8908 | end |
| 8909 | fn hload x ulong i ulong reg ulong to void |
| 8910 | q = add add x 8 mul i 2 |
| 8911 | loadarg reg a_g 77 q a_g 77 add q 1 |
| 8912 | end |
| 8913 | fn hsys n ulong to void |
| 8914 | matconst 8 n |
| 8915 | emit 3556769793 |
| 8916 | end |
| 8917 | fn hreturn dst ulong x ulong to void |
| 8918 | sl = get a_ar add get a_rb 77 add x 7 |
| 8919 | n = get svn 0 |
| 8920 | a = get sva 0 |
| 8921 | r = restore dst sl n a 1 |
| 8922 | vdone 1 r 9 |
| 8923 | end |
| 8924 | fn hscalar c ulong dst ulong x ulong to void |
| 8925 | np = hargc c |
| 8926 | for i ulong np |
| 8927 | ty = ulong 8 |
| 8928 | if or and eq c 103 eq i 1 and eq c 139 eq i 1 |
| 8929 | ty = ulong 9 |
| 8930 | end |
| 8931 | harg x i ty |
| 8932 | end |
| 8933 | note VFIO descriptor-kind state exists only in standalone programs, never in OM-2 unit contexts. |
| 8934 | if and ne get progmode 0 0 or eq c 100 eq c 108 |
| 8935 | if eq get fdtab 0 0 |
| 8936 | fdpool = get poolb 0 |
| 8937 | if gt fdpool 1073739776 |
| 8938 | note d2site 163|hscalar: size capacity; condition if gt fdpool 1073739776 |
| 8939 | put d2site 0 163 |
| 8940 | fail 23 |
| 8941 | end |
| 8942 | put fdtab 0 add 276824064 fdpool |
| 8943 | put poolb 0 add fdpool 2048 |
| 8944 | end |
| 8945 | end |
| 8946 | save |
| 8947 | if and ne get progmode 0 0 eq c 100 |
| 8948 | hload x 0 10 |
| 8949 | fdforget |
| 8950 | end |
| 8951 | for i ulong np |
| 8952 | hload x i i |
| 8953 | end |
| 8954 | if eq c 106 |
| 8955 | hload x 1 3 |
| 8956 | matconst 1 0 |
| 8957 | matconst 2 0 |
| 8958 | end |
| 8959 | if eq c 107 |
| 8960 | matconst 0 17 |
| 8961 | for i ulong 5 |
| 8962 | matconst add i 1 0 |
| 8963 | end |
| 8964 | end |
| 8965 | hsys hsysno c |
| 8966 | if and ne get progmode 0 0 eq c 108 |
| 8967 | mimmed 4043309056 31 0 0 |
| 8968 | baddup = mbranch 11 |
| 8969 | hload x 1 10 |
| 8970 | fdforget |
| 8971 | patch19 baddup get oc 0 |
| 8972 | end |
| 8973 | hreturn dst x |
| 8974 | end |
| 8975 | fn hclock c ulong dst ulong x ulong to void |
| 8976 | save |
| 8977 | spsub 16 |
| 8978 | stkchk |
| 8979 | matconst 0 1 |
| 8980 | if eq c 130 |
| 8981 | matconst 0 0 |
| 8982 | end |
| 8983 | emit 2432697313 |
| 8984 | hsys 113 |
| 8985 | emit 4043309087 |
| 8986 | bad = get oc 0 |
| 8987 | emit 1409286155 |
| 8988 | emit 4181722081 |
| 8989 | emit 4181723106 |
| 8990 | note Reject overflow before seconds are multiplied; clock result is a signed nanosecond count. |
| 8991 | matconst 3 9223372036 |
| 8992 | e3 3942645760 31 1 3 |
| 8993 | trapc 8 1 |
| 8994 | matconst 3 1000000000 |
| 8995 | e3 2600500224 1 1 3 |
| 8996 | e3 2868903936 0 1 2 |
| 8997 | trapc 6 1 |
| 8998 | patch19 bad get oc 0 |
| 8999 | spadd 16 |
| 9000 | hreturn dst x |
| 9001 | end |
| 9002 | fn harray x ulong writable ulong to ulong |
| 9003 | e = arrname 0 |
| 9004 | if ne uchar get a_ar add get a_rb 5 sub e 1 2 |
| 9005 | note d2site 164|harray: type mismatch; condition if ne uchar get a_ar add get a_rb 5 sub e 1 2 |
| 9006 | put d2site 0 164 |
| 9007 | fail 7 |
| 9008 | end |
| 9009 | if ne writable 0 |
| 9010 | vs_arr 53 e |
| 9011 | end |
| 9012 | fz_arg e |
| 9013 | put a_ar add get a_rb 77 add x 20 e |
| 9014 | harg x 0 5 |
| 9015 | harg x 1 5 |
| 9016 | ro = matreg a_g 77 add x 8 a_g 77 add x 9 5 |
| 9017 | rn = matreg a_g 77 add x 10 a_g 77 add x 11 5 |
| 9018 | put a_ar add get a_rb 77 add x 21 ro |
| 9019 | put a_ar add get a_rb 77 add x 22 rn |
| 9020 | vs_chk e ro rn |
| 9021 | ret e |
| 9022 | end |
| 9023 | note Copy a checked path to a private 4096-byte stack buffer. Reject embedded zero bytes. |
| 9024 | note Public paths remain length-delimited; only the kernel-facing private copy has a terminator. |
| 9025 | fn hpathcp x ulong to void |
| 9026 | e = get a_ar add get a_rb 77 add x 20 |
| 9027 | save |
| 9028 | basearg 4 e |
| 9029 | loadarg 16 1 get a_ar add get a_rb 77 add x 21 |
| 9030 | e3 2332033024 4 4 16 |
| 9031 | loadarg 5 1 get a_ar add get a_rb 77 add x 22 |
| 9032 | matconst 6 4095 |
| 9033 | e3 3942645760 31 5 6 |
| 9034 | trapc 8 3 |
| 9035 | end |
| 9036 | fn hcopy to void |
| 9037 | spsub 4096 |
| 9038 | stkchk |
| 9039 | emit 2432697313 |
| 9040 | head = get oc 0 |
| 9041 | emit 4043309247 |
| 9042 | done = get oc 0 |
| 9043 | emit 1409286144 |
| 9044 | emit 960495750 |
| 9045 | emit 4043309279 |
| 9046 | trapc 0 3 |
| 9047 | emit 956301350 |
| 9048 | emit 2432697476 |
| 9049 | emit 2432697377 |
| 9050 | emit 3506439333 |
| 9051 | back head |
| 9052 | patch19 done get oc 0 |
| 9053 | emit 956301375 |
| 9054 | emit 2432697313 |
| 9055 | matconst 0 18446744073709551516 |
| 9056 | end |
| 9057 | fn hpath c ulong dst ulong x ulong to void |
| 9058 | e = harray x 0 |
| 9059 | if or eq c 110 eq c 151 |
| 9060 | harg x 2 8 |
| 9061 | harg x 3 8 |
| 9062 | end |
| 9063 | if or or or eq c 112 eq c 143 eq c 144 eq c 157 |
| 9064 | harg x 2 8 |
| 9065 | end |
| 9066 | if eq c 150 |
| 9067 | harg x 2 9 |
| 9068 | end |
| 9069 | hpathcp x |
| 9070 | if or eq c 110 eq c 151 |
| 9071 | hload x 2 2 |
| 9072 | hload x 3 3 |
| 9073 | end |
| 9074 | if eq c 111 |
| 9075 | matconst 2 0 |
| 9076 | end |
| 9077 | if eq c 126 |
| 9078 | matconst 2 512 |
| 9079 | end |
| 9080 | if eq c 112 |
| 9081 | hload x 2 2 |
| 9082 | end |
| 9083 | if or eq c 143 eq c 144 |
| 9084 | hload x 2 2 |
| 9085 | matconst 3 0 |
| 9086 | end |
| 9087 | if eq c 157 |
| 9088 | hload x 2 2 |
| 9089 | end |
| 9090 | if eq c 150 |
| 9091 | hload x 2 2 |
| 9092 | end |
| 9093 | hcopy |
| 9094 | nr = ulong 56 |
| 9095 | if or eq c 111 eq c 126 |
| 9096 | nr = ulong 35 |
| 9097 | end |
| 9098 | if eq c 112 |
| 9099 | nr = ulong 34 |
| 9100 | end |
| 9101 | if eq c 143 |
| 9102 | nr = ulong 53 |
| 9103 | end |
| 9104 | if eq c 144 |
| 9105 | nr = ulong 48 |
| 9106 | end |
| 9107 | if eq c 157 |
| 9108 | nr = ulong 279 |
| 9109 | end |
| 9110 | if eq c 150 |
| 9111 | nr = ulong 45 |
| 9112 | end |
| 9113 | if eq c 151 |
| 9114 | nr = ulong 54 |
| 9115 | end |
| 9116 | if eq c 138 |
| 9117 | nr = ulong 49 |
| 9118 | note hcopy leaves AT_FDCWD in X0 and the path in X1; chdir takes the path in X0. |
| 9119 | e3 2852126720 0 31 1 |
| 9120 | end |
| 9121 | if eq c 150 |
| 9122 | note truncate takes the path in X0 and the length in X1. |
| 9123 | e3 2852126720 0 31 1 |
| 9124 | e3 2852126720 1 31 2 |
| 9125 | end |
| 9126 | if eq c 151 |
| 9127 | note fchownat(dirfd, path, uid, gid, 0): X2/X3 are the ids, X4 is set after the copy. |
| 9128 | matconst 4 0 |
| 9129 | end |
| 9130 | if eq c 157 |
| 9131 | note memfd_create(name, flags): X0 = name, X1 = flags. |
| 9132 | e3 2852126720 0 31 1 |
| 9133 | e3 2852126720 1 31 2 |
| 9134 | end |
| 9135 | hsys nr |
| 9136 | spadd 4096 |
| 9137 | hreturn dst x |
| 9138 | end |
| 9139 | fn hbuffer c ulong dst ulong x ulong to void |
| 9140 | harg x 4 8 |
| 9141 | wr = ulong 0 |
| 9142 | if or or or or or eq c 113 eq c 116 eq c 117 eq c 118 eq c 131 eq c 224 |
| 9143 | wr = ulong 1 |
| 9144 | end |
| 9145 | e = harray x wr |
| 9146 | if or or eq c 116 eq c 118 eq c 119 |
| 9147 | harg x 2 8 |
| 9148 | end |
| 9149 | if or eq c 116 eq c 117 |
| 9150 | need = ulong 4 |
| 9151 | if eq c 117 |
| 9152 | need = ulong 128 |
| 9153 | end |
| 9154 | tmp = alloc |
| 9155 | matconst tmp need |
| 9156 | e3 3942645760 31 get a_ar add get a_rb 77 add x 22 tmp |
| 9157 | trapc 3 3 |
| 9158 | end |
| 9159 | save |
| 9160 | hload x 4 0 |
| 9161 | basearg 1 e |
| 9162 | loadarg 16 1 get a_ar add get a_rb 77 add x 21 |
| 9163 | e3 2332033024 1 1 16 |
| 9164 | loadarg 2 1 get a_ar add get a_rb 77 add x 22 |
| 9165 | nr = ulong 61 |
| 9166 | if eq c 114 |
| 9167 | nr = ulong 203 |
| 9168 | end |
| 9169 | if eq c 115 |
| 9170 | nr = ulong 200 |
| 9171 | end |
| 9172 | if eq c 116 |
| 9173 | nr = ulong 260 |
| 9174 | hload x 2 2 |
| 9175 | matconst 3 0 |
| 9176 | end |
| 9177 | if eq c 117 |
| 9178 | nr = ulong 80 |
| 9179 | end |
| 9180 | if or eq c 118 eq c 119 |
| 9181 | nr = ulong 207 |
| 9182 | hload x 2 3 |
| 9183 | matconst 4 0 |
| 9184 | matconst 5 0 |
| 9185 | if eq c 119 |
| 9186 | nr = ulong 206 |
| 9187 | matconst 16 16384 |
| 9188 | e3 2852126720 3 3 16 |
| 9189 | end |
| 9190 | end |
| 9191 | |
| 9192 | if or eq c 131 eq c 224 |
| 9193 | note Socket-name queries use a private 32-bit socklen and return the full length. |
| 9194 | spsub 16 |
| 9195 | stkchk |
| 9196 | emit 3103785954 |
| 9197 | emit 2432697314 |
| 9198 | if eq c 224 |
| 9199 | hsys 205 |
| 9200 | else |
| 9201 | hsys 204 |
| 9202 | end |
| 9203 | emit 4043309087 |
| 9204 | failed = get oc 0 |
| 9205 | emit 1409286155 |
| 9206 | emit 3107980256 |
| 9207 | patch19 failed get oc 0 |
| 9208 | spadd 16 |
| 9209 | else |
| 9210 | hsys nr |
| 9211 | end |
| 9212 | hreturn dst x |
| 9213 | end |
| 9214 | fn hargs c ulong dst ulong x ulong to void |
| 9215 | if eq c 121 |
| 9216 | save |
| 9217 | emit 4181721952 |
| 9218 | hreturn dst x |
| 9219 | ret |
| 9220 | end |
| 9221 | if eq c 136 |
| 9222 | note envcnt: walk the environment vector X27 + 8*(argc+2) (after argv's own null word) until the |
| 9223 | note terminating null. |
| 9224 | save |
| 9225 | emit 4181721953 |
| 9226 | emit 2432698401 |
| 9227 | bo_lsl 1 3 1 |
| 9228 | e3 2332033024 0 27 1 |
| 9229 | matconst 2 0 |
| 9230 | lb = get oc 0 |
| 9231 | emit 4181721091 |
| 9232 | brend = get oc 0 |
| 9233 | emit 3019898883 |
| 9234 | emit 2432697410 |
| 9235 | emit 2432704512 |
| 9236 | back lb |
| 9237 | patch19 brend get oc 0 |
| 9238 | emit 2852258784 |
| 9239 | hreturn dst x |
| 9240 | ret |
| 9241 | end |
| 9242 | harg x 4 5 |
| 9243 | e = harray x 1 |
| 9244 | save |
| 9245 | hload x 4 0 |
| 9246 | if eq c 137 |
| 9247 | note envread: envp[index] lives at X27 + 8*(argc+2+index); scan the entries before it so an |
| 9248 | note index at or past the count traps 3 even when the vector is sparse or empty. |
| 9249 | emit 2852127714 |
| 9250 | emit 4181721953 |
| 9251 | emit 2432698401 |
| 9252 | e3 2852126720 0 31 1 |
| 9253 | matconst 16 8 |
| 9254 | emit 2601548800 |
| 9255 | e3 2332033024 3 27 0 |
| 9256 | lb = get oc 0 |
| 9257 | brend = get oc 0 |
| 9258 | emit 3019898882 |
| 9259 | emit 4181721188 |
| 9260 | emit 4043309215 |
| 9261 | trapc 0 3 |
| 9262 | emit 2432704611 |
| 9263 | emit 3506439234 |
| 9264 | back lb |
| 9265 | patch19 brend get oc 0 |
| 9266 | emit 4181721187 |
| 9267 | emit 4043309183 |
| 9268 | trapc 0 3 |
| 9269 | else |
| 9270 | emit 4181721953 |
| 9271 | e3 3942645760 31 0 1 |
| 9272 | trapc 2 3 |
| 9273 | emit 2432697344 |
| 9274 | matconst 16 8 |
| 9275 | e3 2600500224 0 0 16 |
| 9276 | e3 2332033024 3 27 0 |
| 9277 | emit 4181721187 |
| 9278 | end |
| 9279 | e3 2852126720 4 31 3 |
| 9280 | matconst 5 0 |
| 9281 | scan = get oc 0 |
| 9282 | emit 960495750 |
| 9283 | emit 4043309279 |
| 9284 | done = get oc 0 |
| 9285 | emit 1409286144 |
| 9286 | emit 2432697476 |
| 9287 | emit 2432697509 |
| 9288 | matconst 16 1048576 |
| 9289 | e3 3942645760 31 5 16 |
| 9290 | trapc 2 3 |
| 9291 | back scan |
| 9292 | patch19 done get oc 0 |
| 9293 | loadarg 2 1 get a_ar add get a_rb 77 add x 22 |
| 9294 | e3 3942645760 31 5 2 |
| 9295 | small = get oc 0 |
| 9296 | emit 1409286152 |
| 9297 | basearg 0 e |
| 9298 | loadarg 16 1 get a_ar add get a_rb 77 add x 21 |
| 9299 | e3 2332033024 0 0 16 |
| 9300 | e3 2852126720 2 31 5 |
| 9301 | copy = get oc 0 |
| 9302 | emit 4043309247 |
| 9303 | endcp = get oc 0 |
| 9304 | emit 1409286144 |
| 9305 | emit 960495718 |
| 9306 | emit 956301318 |
| 9307 | emit 2432697443 |
| 9308 | emit 2432697344 |
| 9309 | emit 3506439333 |
| 9310 | back copy |
| 9311 | patch19 endcp get oc 0 |
| 9312 | e3 2852126720 0 31 2 |
| 9313 | endbr = get oc 0 |
| 9314 | emit 335544320 |
| 9315 | patch19 small get oc 0 |
| 9316 | matconst 0 18446744073709551511 |
| 9317 | patch26 endbr get oc 0 |
| 9318 | hreturn dst x |
| 9319 | end |
| 9320 | |
| 9321 | note waitio(fd int, events int, timeout_ns long): revents, 0 timeout, or negative errno. |
| 9322 | note ppoll uses one private pollfd and one private timespec. Negative timeout is infinite. |
| 9323 | fn hwaitio dst ulong x ulong to void |
| 9324 | harg x 0 8 |
| 9325 | harg x 1 8 |
| 9326 | harg x 2 9 |
| 9327 | save |
| 9328 | hload x 0 0 |
| 9329 | hload x 1 1 |
| 9330 | hload x 2 2 |
| 9331 | note pollfd.events is 16 bits; refuse truncation of the public int argument. |
| 9332 | emit 4043309119 |
| 9333 | trapc 11 3 |
| 9334 | matconst 16 65535 |
| 9335 | e3 3942645760 31 1 16 |
| 9336 | trapc 8 3 |
| 9337 | spsub 32 |
| 9338 | stkchk |
| 9339 | emit 4177527807 |
| 9340 | emit 3103785952 |
| 9341 | emit 2030046177 |
| 9342 | matconst 3 1000000000 |
| 9343 | emit 4043309151 |
| 9344 | forever = get oc 0 |
| 9345 | emit 1409286155 |
| 9346 | e3 2596276224 4 2 3 |
| 9347 | emit 2600700037 |
| 9348 | emit 4177528804 |
| 9349 | emit 4177529829 |
| 9350 | emit 2432705506 |
| 9351 | jump = get oc 0 |
| 9352 | emit 335544320 |
| 9353 | patch19 forever get oc 0 |
| 9354 | matconst 2 0 |
| 9355 | patch26 jump get oc 0 |
| 9356 | emit 2432697312 |
| 9357 | matconst 1 1 |
| 9358 | matconst 3 0 |
| 9359 | matconst 4 8 |
| 9360 | hsys 73 |
| 9361 | emit 4043309087 |
| 9362 | failed = get oc 0 |
| 9363 | emit 1409286157 |
| 9364 | emit 2034241504 |
| 9365 | patch19 failed get oc 0 |
| 9366 | spadd 32 |
| 9367 | hreturn dst x |
| 9368 | end |
| 9369 | |
| 9370 | note hexw: 1 for the exec words (execprog 124, execpure 198, execenv 233), whose argv packet may hold |
| 9371 | note 65536 bytes and 1024 records; 0 for renames, link and symlnk. |
| 9372 | fn hexw c ulong to ulong |
| 9373 | if or or eq c 124 eq c 198 eq c 233 |
| 9374 | ret 1 |
| 9375 | end |
| 9376 | ret 0 |
| 9377 | end |
| 9378 | note hnpass: packet passes of hpack/xhpack: 2 for execenv (argv, then environment), else 1. |
| 9379 | fn hnpass c ulong to ulong |
| 9380 | if eq c 233 |
| 9381 | ret 2 |
| 9382 | end |
| 9383 | ret 1 |
| 9384 | end |
| 9385 | note hplim: the record-count limit of packet pass p: 1024 for an exec argv packet, else 64. |
| 9386 | fn hplim c ulong p ulong to ulong |
| 9387 | if eq p 0 |
| 9388 | if ne hexw c 0 |
| 9389 | ret 1024 |
| 9390 | end |
| 9391 | end |
| 9392 | ret 64 |
| 9393 | end |
| 9394 | |
| 9395 | note A packed argument list is u16 count followed by count (u16 length, bytes) records. |
| 9396 | note Byte order is little-endian. An exec argv packet (execprog, execpure, execenv) is at most 65536 |
| 9397 | note bytes and 1024 records; renames, link and symlnk packets and the execenv environment packet are |
| 9398 | note at most 4096 bytes and 64 records. The decoder constructs kernel pointers only in private stack memory. |
| 9399 | note execenv 233 (execenv A off n B off m) decodes a second packet, the environment, with the same |
| 9400 | note rules except that every record must be nonempty. Its base and length are loaded into x14/x15 |
| 9401 | note before SPSUB (save-area reads are SP-relative) and both packets are checked before any fd closes. |
| 9402 | note Stack, exec words: argv strings SP, argv pointers SP+65536 (at most 1025 words), and for execenv |
| 9403 | note env strings SP+81920, env pointers SP+86016 (at most 65 words). Other words: strings SP, |
| 9404 | note pointers SP+4096, 8192 bytes. |
| 9405 | fn hpack c ulong dst ulong x ulong to void |
| 9406 | errs = new ulong 16 0 |
| 9407 | tbl = new ulong 27 0 |
| 9408 | e = harray x 0 |
| 9409 | if eq c 125 |
| 9410 | harg x 2 8 |
| 9411 | end |
| 9412 | if eq c 233 |
| 9413 | put a_ar add get a_rb 77 add x 23 e |
| 9414 | a_p 77 add x 24 a_g 77 add x 21 |
| 9415 | a_p 77 add x 25 a_g 77 add x 22 |
| 9416 | e = harray x 0 |
| 9417 | put a_ar add get a_rb 77 add x 26 e |
| 9418 | a_p 77 add x 27 a_g 77 add x 21 |
| 9419 | a_p 77 add x 28 a_g 77 add x 22 |
| 9420 | a_p 77 add x 20 a_g 77 add x 23 |
| 9421 | a_p 77 add x 21 a_g 77 add x 24 |
| 9422 | a_p 77 add x 22 a_g 77 add x 25 |
| 9423 | e = get a_ar add get a_rb 77 add x 23 |
| 9424 | end |
| 9425 | save |
| 9426 | basearg 4 e |
| 9427 | loadarg 16 1 get a_ar add get a_rb 77 add x 21 |
| 9428 | e3 2332033024 4 4 16 |
| 9429 | loadarg 5 1 get a_ar add get a_rb 77 add x 22 |
| 9430 | if ne hexw c 0 |
| 9431 | matconst 16 65536 |
| 9432 | else |
| 9433 | matconst 16 4096 |
| 9434 | end |
| 9435 | e3 3942645760 31 5 16 |
| 9436 | trapc 8 3 |
| 9437 | emit 4043311295 |
| 9438 | trapc 3 3 |
| 9439 | if eq c 125 |
| 9440 | hload x 2 14 |
| 9441 | end |
| 9442 | note stack: 8192 bytes for renames, link and symlnk; 81920 for execprog and execpure; 90112 for |
| 9443 | note execenv, whose second pass decodes the environment packet. |
| 9444 | stack = ulong 8192 |
| 9445 | if ne hexw c 0 |
| 9446 | stack = ulong 81920 |
| 9447 | end |
| 9448 | if eq c 233 |
| 9449 | note x14 = env base + off (ADD), x15 = env length; length 2..4096 (CMP x15,x16 B.HI; CMP x15,#2 B.LO). |
| 9450 | basearg 14 get a_ar add get a_rb 77 add x 26 |
| 9451 | loadarg 16 1 get a_ar add get a_rb 77 add x 27 |
| 9452 | e3 2332033024 14 14 16 |
| 9453 | loadarg 15 1 get a_ar add get a_rb 77 add x 28 |
| 9454 | matconst 16 4096 |
| 9455 | e3 3942645760 31 15 16 |
| 9456 | trapc 8 3 |
| 9457 | emit 4043311615 |
| 9458 | trapc 3 3 |
| 9459 | stack = ulong 90112 |
| 9460 | end |
| 9461 | spsub stack |
| 9462 | stkchk |
| 9463 | pass = ulong 0 |
| 9464 | while lt pass hnpass c |
| 9465 | if eq pass 1 |
| 9466 | note MOV x4,x14; MOV x5,x15 (ORR with XZR): the environment packet. |
| 9467 | e3 2852126720 4 31 14 |
| 9468 | e3 2852126720 5 31 15 |
| 9469 | end |
| 9470 | emit 2034237574 |
| 9471 | emit 2432698500 |
| 9472 | emit 3506440357 |
| 9473 | emit 4043309279 |
| 9474 | trapc 0 3 |
| 9475 | matconst 16 hplim c pass |
| 9476 | e3 3942645760 31 6 16 |
| 9477 | trapc 8 3 |
| 9478 | if or or eq c 125 eq c 141 eq c 142 |
| 9479 | emit 4043311327 |
| 9480 | trapc 1 3 |
| 9481 | end |
| 9482 | matconst 9 0 |
| 9483 | if eq pass 0 |
| 9484 | emit 2432697322 |
| 9485 | if ne hexw c 0 |
| 9486 | emit 2436908011 |
| 9487 | else |
| 9488 | emit 2436892651 |
| 9489 | end |
| 9490 | else |
| 9491 | note ADD x10,SP,#20,LSL12; ADD x11,SP,#21,LSL12: env strings and env pointers. |
| 9492 | emit 2436912106 |
| 9493 | emit 2436913131 |
| 9494 | end |
| 9495 | outer = get oc 0 |
| 9496 | e3 3942645760 31 9 6 |
| 9497 | done = get oc 0 |
| 9498 | emit 1409286146 |
| 9499 | emit 4043311295 |
| 9500 | trapc 3 3 |
| 9501 | emit 2034237580 |
| 9502 | emit 2432698500 |
| 9503 | emit 3506440357 |
| 9504 | e3 3942645760 31 12 5 |
| 9505 | trapc 8 3 |
| 9506 | note A program path and both rename paths must be nonempty; every environment record is nonempty. |
| 9507 | note (Nested conditions keep om4 within its 16 live registers.) |
| 9508 | if eq pass 0 |
| 9509 | if or or eq c 124 eq c 198 eq c 233 |
| 9510 | emit 4043309375 |
| 9511 | notfirst = get oc 0 |
| 9512 | emit 1409286145 |
| 9513 | emit 4043309471 |
| 9514 | trapc 0 3 |
| 9515 | patch19 notfirst get oc 0 |
| 9516 | else |
| 9517 | emit 4043309471 |
| 9518 | trapc 0 3 |
| 9519 | end |
| 9520 | else |
| 9521 | emit 4043309471 |
| 9522 | trapc 0 3 |
| 9523 | end |
| 9524 | emit 4177527146 |
| 9525 | emit 2432704875 |
| 9526 | inner = get oc 0 |
| 9527 | emit 4043309471 |
| 9528 | endstr = get oc 0 |
| 9529 | emit 1409286144 |
| 9530 | emit 960495757 |
| 9531 | emit 4043309503 |
| 9532 | trapc 0 3 |
| 9533 | emit 956301645 |
| 9534 | emit 2432697476 |
| 9535 | emit 2432697674 |
| 9536 | emit 3506439333 |
| 9537 | emit 3506439564 |
| 9538 | back inner |
| 9539 | patch19 endstr get oc 0 |
| 9540 | emit 956301663 |
| 9541 | emit 2432697674 |
| 9542 | emit 2432697641 |
| 9543 | back outer |
| 9544 | patch19 done get oc 0 |
| 9545 | emit 4043309247 |
| 9546 | trapc 1 3 |
| 9547 | emit 4177527167 |
| 9548 | pass = add pass 1 |
| 9549 | end |
| 9550 | if or or eq c 124 eq c 198 eq c 233 |
| 9551 | note Exec admits only the caller-assigned standard streams. Linux close_range with UNSHARE |
| 9552 | note closes every descriptor >=3 in a private table. Failure returns without executing a child; |
| 9553 | note no guessed descriptor ceiling or permissive fallback. This is not filesystem isolation. |
| 9554 | matconst 0 3 |
| 9555 | matconst 1 4294967295 |
| 9556 | matconst 2 2 |
| 9557 | hsys 436 |
| 9558 | emit 4043309087 |
| 9559 | note outer and done are dead after the packet scan; they are reused for the two branch sites here. |
| 9560 | done = get oc 0 |
| 9561 | emit 1409286145 |
| 9562 | if eq c 198 |
| 9563 | note execpure strict stdio profile: Linux UAPI layouts in 640 private guest stack bytes, never an |
| 9564 | note exposed native pointer. sock_filter is u16 code,u8 jt,u8 jf,u32 k; sock_fprog has its length at |
| 9565 | note 0 and its pointer at 8 on AArch64. A Landlock path rule is a packed u64 allowed_access plus an |
| 9566 | note s32 parent_fd; prlimit64 takes two u64s. Each step that returns a negative value branches (B.LT) |
| 9567 | note to the common restore with the kernel error in x0. ADD x16,SP,#k then STR x0,[x16] stores a word. |
| 9568 | n = ulong 0 |
| 9569 | spsub 640 |
| 9570 | stkchk |
| 9571 | mimmed 2432697312 16 0 632 |
| 9572 | e3 4177526784 11 16 0 |
| 9573 | note Extra descriptors are already closed in a private table. Pin the executable as descriptor 3. |
| 9574 | matconst 0 18446744073709551516 |
| 9575 | mimmed 2432697312 1 0 640 |
| 9576 | matconst 2 2621440 |
| 9577 | matconst 3 0 |
| 9578 | hsys 56 |
| 9579 | emit 4043309087 |
| 9580 | put errs n get oc 0 |
| 9581 | emit 1409286155 |
| 9582 | n = add n 1 |
| 9583 | note ABI3 rights through TRUNCATE are all handled, with only read/execute of that one inode allowed. |
| 9584 | matconst 0 32767 |
| 9585 | mimmed 2432697312 16 0 0 |
| 9586 | e3 4177526784 0 16 0 |
| 9587 | mimmed 2432697312 0 0 0 |
| 9588 | matconst 1 8 |
| 9589 | matconst 2 0 |
| 9590 | hsys 444 |
| 9591 | emit 4043309087 |
| 9592 | put errs n get oc 0 |
| 9593 | emit 1409286155 |
| 9594 | n = add n 1 |
| 9595 | matconst 0 5 |
| 9596 | mimmed 2432697312 16 0 16 |
| 9597 | e3 4177526784 0 16 0 |
| 9598 | matconst 0 3 |
| 9599 | mimmed 2432697312 16 0 24 |
| 9600 | e3 4177526784 0 16 0 |
| 9601 | matconst 0 4 |
| 9602 | matconst 1 1 |
| 9603 | mimmed 2432697312 2 0 16 |
| 9604 | matconst 3 0 |
| 9605 | hsys 445 |
| 9606 | emit 4043309087 |
| 9607 | put errs n get oc 0 |
| 9608 | emit 1409286155 |
| 9609 | n = add n 1 |
| 9610 | matconst 0 38 |
| 9611 | matconst 1 1 |
| 9612 | matconst 2 0 |
| 9613 | matconst 3 0 |
| 9614 | matconst 4 0 |
| 9615 | hsys 167 |
| 9616 | emit 4043309087 |
| 9617 | put errs n get oc 0 |
| 9618 | emit 1409286155 |
| 9619 | n = add n 1 |
| 9620 | matconst 0 4 |
| 9621 | matconst 1 0 |
| 9622 | hsys 446 |
| 9623 | emit 4043309087 |
| 9624 | put errs n get oc 0 |
| 9625 | emit 1409286155 |
| 9626 | n = add n 1 |
| 9627 | matconst 0 4 |
| 9628 | hsys 57 |
| 9629 | emit 4043309087 |
| 9630 | put errs n get oc 0 |
| 9631 | emit 1409286155 |
| 9632 | n = add n 1 |
| 9633 | note Per-process ceilings as (resource, soft, hard): CPU, FSIZE, STACK, CORE, NPROC, NOFILE, AS. |
| 9634 | note Pipe-output and wall budgets additionally require the trusted supervisor. |
| 9635 | put tbl 1 1 |
| 9636 | put tbl 2 2 |
| 9637 | put tbl 3 1 |
| 9638 | put tbl 4 1048576 |
| 9639 | put tbl 5 1048576 |
| 9640 | put tbl 6 3 |
| 9641 | put tbl 7 8388608 |
| 9642 | put tbl 8 8388608 |
| 9643 | put tbl 9 4 |
| 9644 | put tbl 12 6 |
| 9645 | put tbl 15 7 |
| 9646 | put tbl 16 4 |
| 9647 | put tbl 17 4 |
| 9648 | put tbl 18 9 |
| 9649 | put tbl 19 134217728 |
| 9650 | put tbl 20 134217728 |
| 9651 | for i ulong 7 |
| 9652 | matconst 0 get tbl add mul i 3 1 |
| 9653 | mimmed 2432697312 16 0 48 |
| 9654 | e3 4177526784 0 16 0 |
| 9655 | matconst 0 get tbl add mul i 3 2 |
| 9656 | mimmed 2432697312 16 0 56 |
| 9657 | e3 4177526784 0 16 0 |
| 9658 | matconst 0 0 |
| 9659 | matconst 1 get tbl mul i 3 |
| 9660 | mimmed 2432697312 2 0 48 |
| 9661 | matconst 3 0 |
| 9662 | hsys 261 |
| 9663 | emit 4043309087 |
| 9664 | put errs n get oc 0 |
| 9665 | emit 1409286155 |
| 9666 | n = add n 1 |
| 9667 | end |
| 9668 | note Validate architecture, then read only 0, write only 1/2, exit/exit_group. Everything else is EPERM. |
| 9669 | note execveat is restricted to descriptor 3 and AT_EMPTY_PATH; Landlock also binds execution to inode 3. |
| 9670 | note The inode rule is essential: an absolute execveat path otherwise ignores its dirfd argument. |
| 9671 | note Entry i = code | jt<<16 | jf<<24 | k<<32, stored at SP+128+8i. (code jt jf k) rows in order: |
| 9672 | note (32 0 0 4) (21 1 0 3221225655) (6 0 0 2147483648) (32 0 0 0) (21 0 3 63) (32 0 0 16) (21 0 1 0) (6 0 0 2147418112) (32 0 0 0) |
| 9673 | note (21 0 4 64) (32 0 0 16) (21 1 0 1) (21 0 1 2) (6 0 0 2147418112) (32 0 0 0) (21 0 1 93) (6 0 0 2147418112) (21 0 1 94) |
| 9674 | note (6 0 0 2147418112) (32 0 0 0) (21 0 5 281) (32 0 0 16) (21 0 3 3) (32 0 0 48) (21 0 1 4096) (6 0 0 2147418112) (6 0 0 327681) |
| 9675 | put tbl 0 ulong 17179869216 |
| 9676 | put tbl 1 ulong 13835058841261244437 |
| 9677 | put tbl 2 ulong 9223372036854775814 |
| 9678 | put tbl 3 ulong 32 |
| 9679 | put tbl 4 ulong 270633271317 |
| 9680 | put tbl 5 ulong 68719476768 |
| 9681 | put tbl 6 ulong 16777237 |
| 9682 | put tbl 7 ulong 9223090561878065158 |
| 9683 | put tbl 8 ulong 32 |
| 9684 | put tbl 9 ulong 274945015829 |
| 9685 | put tbl 10 ulong 68719476768 |
| 9686 | put tbl 11 ulong 4295032853 |
| 9687 | put tbl 12 ulong 8606711829 |
| 9688 | put tbl 13 ulong 9223090561878065158 |
| 9689 | put tbl 14 ulong 32 |
| 9690 | put tbl 15 ulong 399448735765 |
| 9691 | put tbl 16 ulong 9223090561878065158 |
| 9692 | put tbl 17 ulong 403743703061 |
| 9693 | put tbl 18 ulong 9223090561878065158 |
| 9694 | put tbl 19 ulong 32 |
| 9695 | put tbl 20 ulong 1206969696277 |
| 9696 | put tbl 21 ulong 68719476768 |
| 9697 | put tbl 22 ulong 12935233557 |
| 9698 | put tbl 23 ulong 206158430240 |
| 9699 | put tbl 24 ulong 17592202821653 |
| 9700 | put tbl 25 ulong 9223090561878065158 |
| 9701 | put tbl 26 ulong 1407379178520582 |
| 9702 | for i ulong 27 |
| 9703 | matconst 0 get tbl i |
| 9704 | mimmed 2432697312 16 0 add 128 mul i 8 |
| 9705 | e3 4177526784 0 16 0 |
| 9706 | end |
| 9707 | matconst 0 27 |
| 9708 | mimmed 2432697312 16 0 80 |
| 9709 | e3 4177526784 0 16 0 |
| 9710 | mimmed 2432697312 0 0 128 |
| 9711 | mimmed 2432697312 16 0 88 |
| 9712 | e3 4177526784 0 16 0 |
| 9713 | matconst 0 1 |
| 9714 | matconst 1 0 |
| 9715 | mimmed 2432697312 2 0 80 |
| 9716 | hsys 277 |
| 9717 | emit 4043309087 |
| 9718 | put errs n get oc 0 |
| 9719 | emit 1409286155 |
| 9720 | n = add n 1 |
| 9721 | note Restore the original packet stack before entering the pinned executable. Descriptor 3 is CLOEXEC. |
| 9722 | mimmed 2432697312 16 0 632 |
| 9723 | e3 4181721088 11 16 0 |
| 9724 | spadd 640 |
| 9725 | matconst 0 3 |
| 9726 | e3 2852126720 1 31 11 |
| 9727 | emit 2436908002 |
| 9728 | e3 2852126720 3 31 11 |
| 9729 | matconst 4 4096 |
| 9730 | hsys 281 |
| 9731 | outer = get oc 0 |
| 9732 | emit 335544320 |
| 9733 | while gt n 0 |
| 9734 | n = sub n 1 |
| 9735 | patch19 get errs n get oc 0 |
| 9736 | end |
| 9737 | mimmed 2432697312 16 0 632 |
| 9738 | e3 4181721088 11 16 0 |
| 9739 | spadd 640 |
| 9740 | patch26 outer get oc 0 |
| 9741 | else |
| 9742 | emit 2432697312 |
| 9743 | emit 2436908001 |
| 9744 | if eq c 233 |
| 9745 | note ADD x2,SP,#21,LSL12: envp is the private environment pointer list. |
| 9746 | emit 2436913122 |
| 9747 | else |
| 9748 | note MOV x2,x11: envp is the argv list's NULL terminator, an empty environment. |
| 9749 | e3 2852126720 2 31 11 |
| 9750 | end |
| 9751 | hsys 221 |
| 9752 | end |
| 9753 | patch19 done get oc 0 |
| 9754 | else |
| 9755 | if eq c 125 |
| 9756 | emit 2436892656 |
| 9757 | emit 4181721601 |
| 9758 | emit 4181722627 |
| 9759 | matconst 0 18446744073709551516 |
| 9760 | matconst 2 18446744073709551516 |
| 9761 | e3 2852126720 4 31 14 |
| 9762 | hsys 276 |
| 9763 | else |
| 9764 | note linkat/symlnk: the packed list's two records are pointer-list entries 0 and 1. |
| 9765 | emit 2436892656 |
| 9766 | emit 4181721601 |
| 9767 | emit 4181722627 |
| 9768 | if eq c 141 |
| 9769 | matconst 0 18446744073709551516 |
| 9770 | matconst 2 18446744073709551516 |
| 9771 | matconst 4 0 |
| 9772 | hsys 37 |
| 9773 | else |
| 9774 | e3 2852126720 2 31 3 |
| 9775 | e3 2852126720 0 31 1 |
| 9776 | matconst 1 18446744073709551516 |
| 9777 | hsys 36 |
| 9778 | end |
| 9779 | end |
| 9780 | end |
| 9781 | spadd stack |
| 9782 | hreturn dst x |
| 9783 | end |
| 9784 | |
| 9785 | fn hreadlnk dst ulong x ulong to void |
| 9786 | e = harray x 0 |
| 9787 | put a_ar add get a_rb 77 add x 23 e |
| 9788 | a_p 77 add x 24 a_g 77 add x 21 |
| 9789 | a_p 77 add x 25 a_g 77 add x 22 |
| 9790 | e = harray x 1 |
| 9791 | put a_ar add get a_rb 77 add x 26 e |
| 9792 | a_p 77 add x 27 a_g 77 add x 21 |
| 9793 | a_p 77 add x 28 a_g 77 add x 22 |
| 9794 | a_p 77 add x 20 a_g 77 add x 23 |
| 9795 | a_p 77 add x 21 a_g 77 add x 24 |
| 9796 | a_p 77 add x 22 a_g 77 add x 25 |
| 9797 | hpathcp x |
| 9798 | note readlnk refuses an empty path before the kernel call. |
| 9799 | emit 4043309247 |
| 9800 | trapc 0 3 |
| 9801 | basearg 2 get a_ar add get a_rb 77 add x 26 |
| 9802 | loadarg 16 1 get a_ar add get a_rb 77 add x 27 |
| 9803 | e3 2332033024 2 2 16 |
| 9804 | loadarg 3 1 get a_ar add get a_rb 77 add x 28 |
| 9805 | hcopy |
| 9806 | hsys 78 |
| 9807 | spadd 4096 |
| 9808 | hreturn dst x |
| 9809 | end |
| 9810 | note stat: path slice (readonly) + output slice, at least 128 bytes for the ARM64 stat structure. |
| 9811 | note Linux newfstatat(AT_FDCWD, path, out, 0); returns 0 or -errno. A short output traps 3. |
| 9812 | note pread/pwrite: fd, byte slice (off, n), position long. The file offset is not moved. |
| 9813 | note pread (161) writes A, so A must be writable (error 20); pwrite (162) only reads A, so a text is allowed. |
| 9814 | fn hpread c ulong dst ulong x ulong to void |
| 9815 | harg x 4 8 |
| 9816 | wr = ulong 0 |
| 9817 | if eq c 161 |
| 9818 | wr = ulong 1 |
| 9819 | end |
| 9820 | e = harray x wr |
| 9821 | harg x 3 9 |
| 9822 | save |
| 9823 | hload x 4 0 |
| 9824 | basearg 1 e |
| 9825 | loadarg 16 1 get a_ar add get a_rb 77 add x 21 |
| 9826 | e3 2332033024 1 1 16 |
| 9827 | loadarg 2 1 get a_ar add get a_rb 77 add x 22 |
| 9828 | hload x 3 3 |
| 9829 | nr = ulong 67 |
| 9830 | if eq c 162 |
| 9831 | nr = ulong 68 |
| 9832 | end |
| 9833 | hsys nr |
| 9834 | hreturn dst x |
| 9835 | end |
| 9836 | |
| 9837 | fn hstat c ulong dst ulong x ulong to void |
| 9838 | e = harray x 0 |
| 9839 | put a_ar add get a_rb 77 add x 23 e |
| 9840 | a_p 77 add x 24 a_g 77 add x 21 |
| 9841 | a_p 77 add x 25 a_g 77 add x 22 |
| 9842 | e = harray x 1 |
| 9843 | put a_ar add get a_rb 77 add x 26 e |
| 9844 | a_p 77 add x 27 a_g 77 add x 21 |
| 9845 | a_p 77 add x 28 a_g 77 add x 22 |
| 9846 | a_p 77 add x 20 a_g 77 add x 23 |
| 9847 | a_p 77 add x 21 a_g 77 add x 24 |
| 9848 | a_p 77 add x 22 a_g 77 add x 25 |
| 9849 | hpathcp x |
| 9850 | note stat refuses an empty path before the kernel call. |
| 9851 | emit 4043309247 |
| 9852 | trapc 0 3 |
| 9853 | basearg 2 get a_ar add get a_rb 77 add x 26 |
| 9854 | loadarg 16 1 get a_ar add get a_rb 77 add x 27 |
| 9855 | e3 2332033024 2 2 16 |
| 9856 | loadarg 3 1 get a_ar add get a_rb 77 add x 28 |
| 9857 | matconst 6 128 |
| 9858 | e3 3942645760 31 3 6 |
| 9859 | trapc 3 3 |
| 9860 | matconst 3 0 |
| 9861 | if eq c 149 |
| 9862 | matconst 3 256 |
| 9863 | end |
| 9864 | hcopy |
| 9865 | hsys 79 |
| 9866 | spadd 4096 |
| 9867 | hreturn dst x |
| 9868 | end |
| 9869 | fn hsockopt dst ulong x ulong to void |
| 9870 | harg x 2 8 |
| 9871 | harg x 3 8 |
| 9872 | harg x 4 8 |
| 9873 | e = harray x 0 |
| 9874 | save |
| 9875 | hload x 2 0 |
| 9876 | hload x 3 1 |
| 9877 | hload x 4 2 |
| 9878 | basearg 3 e |
| 9879 | loadarg 16 1 get a_ar add get a_rb 77 add x 21 |
| 9880 | e3 2332033024 3 3 16 |
| 9881 | loadarg 4 1 get a_ar add get a_rb 77 add x 22 |
| 9882 | note Only scalar transport options; no filters, devices, credentials or pointer-bearing options. |
| 9883 | hoptgate |
| 9884 | hreturn dst x |
| 9885 | end |
| 9886 | |
| 9887 | note Socket option allowlist. Linux asm-generic/socket.h and linux/tcp.h own these IDs. |
| 9888 | note Unknown options retain ENOPROTOOPT (-92); malformed scalar sizes return EINVAL (-22). |
| 9889 | fn hoptgate to void |
| 9890 | ok = new ulong 6 0 |
| 9891 | mimmed 4043309056 31 1 1 |
| 9892 | tcp = get oc 0 |
| 9893 | emit 1409286145 |
| 9894 | for j ulong 5 |
| 9895 | v = add j 5 |
| 9896 | if eq j 0 |
| 9897 | v = ulong 2 |
| 9898 | end |
| 9899 | if eq j 1 |
| 9900 | v = ulong 15 |
| 9901 | end |
| 9902 | mimmed 4043309056 31 2 v |
| 9903 | put ok j get oc 0 |
| 9904 | emit 1409286144 |
| 9905 | end |
| 9906 | badso = get oc 0 |
| 9907 | emit 335544320 |
| 9908 | patch19 tcp get oc 0 |
| 9909 | mimmed 4043309056 31 1 6 |
| 9910 | badtcp = get oc 0 |
| 9911 | emit 1409286145 |
| 9912 | mimmed 4043309056 31 2 1 |
| 9913 | put ok 5 get oc 0 |
| 9914 | emit 1409286144 |
| 9915 | patch26 badso get oc 0 |
| 9916 | patch19 badtcp get oc 0 |
| 9917 | matconst 0 sub ulong 0 92 |
| 9918 | done = get oc 0 |
| 9919 | emit 335544320 |
| 9920 | for j ulong 6 |
| 9921 | patch19 get ok j get oc 0 |
| 9922 | end |
| 9923 | mimmed 4043309056 31 4 4 |
| 9924 | sizeok = get oc 0 |
| 9925 | emit 1409286144 |
| 9926 | matconst 0 sub ulong 0 22 |
| 9927 | badsize = get oc 0 |
| 9928 | emit 335544320 |
| 9929 | patch19 sizeok get oc 0 |
| 9930 | hsys 208 |
| 9931 | patch26 done get oc 0 |
| 9932 | patch26 badsize get oc 0 |
| 9933 | end |
| 9934 | |
| 9935 | note prlimit pid res A off n (keyword 235): Linux prlimit64, ARM64 261. pid and res are int; A is a writable |
| 9936 | note byte slice checked like every host slice (trap 3). n 16 reads: new NULL, old {rlim_cur, rlim_max} as |
| 9937 | note little-endian u64 at A[off..off+16). n 32 sets from A[off..off+16) and writes the old pair to |
| 9938 | note A[off+16..off+32). Any other n returns -22 (EINVAL) without a kernel call. x4 = &A[off], x5 = n. |
| 9939 | fn hprlim dst ulong x ulong to void |
| 9940 | harg x 2 8 |
| 9941 | harg x 3 8 |
| 9942 | e = harray x 1 |
| 9943 | save |
| 9944 | hload x 2 0 |
| 9945 | hload x 3 1 |
| 9946 | basearg 4 e |
| 9947 | loadarg 16 1 get a_ar add get a_rb 77 add x 21 |
| 9948 | e3 2332033024 4 4 16 |
| 9949 | loadarg 5 1 get a_ar add get a_rb 77 add x 22 |
| 9950 | matconst 2 0 |
| 9951 | e3 2852126720 3 31 4 |
| 9952 | mimmed 4043309056 31 5 16 |
| 9953 | rd = mbranch 0 |
| 9954 | mimmed 4043309056 31 5 32 |
| 9955 | setp = mbranch 0 |
| 9956 | matconst 0 sub ulong 0 22 |
| 9957 | bad = get oc 0 |
| 9958 | emit 335544320 |
| 9959 | patch19 setp get oc 0 |
| 9960 | e3 2852126720 2 31 4 |
| 9961 | mimmed 2432696320 3 4 16 |
| 9962 | patch19 rd get oc 0 |
| 9963 | hsys 261 |
| 9964 | patch26 bad get oc 0 |
| 9965 | hreturn dst x |
| 9966 | end |
| 9967 | |
| 9968 | note cpuset 236 / cpuget 237 pid A off n: Linux sched_setaffinity 122 / sched_getaffinity 123 (ARM64), |
| 9969 | note X0 pid (int; 0 is the calling thread), X1 n, X2 &A[off]. The byte slice is checked like every host |
| 9970 | note slice (trap 3); cpuset only reads it, cpuget writes it (a text is error 20). cpuset gives 0 or minus |
| 9971 | note errno (a mask with no online permitted CPU is -22); cpuget gives the bytes the kernel wrote (its |
| 9972 | note cpumask size) or minus errno (n below that size or not a multiple of 8 is -22). cpunow 238, no |
| 9973 | note operands: getcpu 168 into a 16-byte stack slot, node NULL; the CPU the calling thread ran on at the |
| 9974 | note call (LDR W0 from the slot only when X0 is not negative), or minus errno. |
| 9975 | fn hsched c ulong dst ulong x ulong to void |
| 9976 | if eq c 238 |
| 9977 | save |
| 9978 | spsub 16 |
| 9979 | stkchk |
| 9980 | emit 2432697312 |
| 9981 | matconst 1 0 |
| 9982 | matconst 2 0 |
| 9983 | hsys 168 |
| 9984 | emit 4043309087 |
| 9985 | bad = get oc 0 |
| 9986 | emit 1409286155 |
| 9987 | mimmed 3107979264 0 31 0 |
| 9988 | patch19 bad get oc 0 |
| 9989 | spadd 16 |
| 9990 | hreturn dst x |
| 9991 | ret |
| 9992 | end |
| 9993 | harg x 2 8 |
| 9994 | w = ulong 0 |
| 9995 | if eq c 237 |
| 9996 | w = ulong 1 |
| 9997 | end |
| 9998 | e = harray x w |
| 9999 | save |
| 10000 | hload x 2 0 |
| 10001 | basearg 2 e |
| 10002 | loadarg 16 1 get a_ar add get a_rb 77 add x 21 |
| 10003 | e3 2332033024 2 2 16 |
| 10004 | loadarg 1 1 get a_ar add get a_rb 77 add x 22 |
| 10005 | hsys add 122 w |
| 10006 | hreturn dst x |
| 10007 | end |
| 10008 | |
| 10009 | note SO_PEERCRED: fixed 12-byte ucred result, never a caller-chosen getsockopt operation. |
| 10010 | fn hpeercr dst ulong x ulong to void |
| 10011 | harg x 4 8 |
| 10012 | e = harray x 1 |
| 10013 | save |
| 10014 | hload x 4 0 |
| 10015 | basearg 3 e |
| 10016 | loadarg 16 1 get a_ar add get a_rb 77 add x 21 |
| 10017 | e3 2332033024 3 3 16 |
| 10018 | loadarg 4 1 get a_ar add get a_rb 77 add x 22 |
| 10019 | matconst 16 12 |
| 10020 | e3 3942645760 31 4 16 |
| 10021 | trapc 3 3 |
| 10022 | matconst 1 1 |
| 10023 | matconst 2 17 |
| 10024 | spsub 16 |
| 10025 | stkchk |
| 10026 | matconst 4 12 |
| 10027 | emit or ulong 3103785952 4 |
| 10028 | emit or ulong 2432697312 4 |
| 10029 | hsys 209 |
| 10030 | spadd 16 |
| 10031 | hreturn dst x |
| 10032 | end |
| 10033 | |
| 10034 | note pollfds uses packed Linux pollfd records; length is bytes, each record is 8 bytes. |
| 10035 | note Maximum 1024 records, checked before ppoll. Kernel writes only revents in the checked slice. |
| 10036 | fn hpollfds dst ulong x ulong to void |
| 10037 | e = harray x 1 |
| 10038 | harg x 2 9 |
| 10039 | save |
| 10040 | basearg 0 e |
| 10041 | loadarg 16 1 get a_ar add get a_rb 77 add x 21 |
| 10042 | e3 2332033024 0 0 16 |
| 10043 | loadarg 1 1 get a_ar add get a_rb 77 add x 22 |
| 10044 | matconst 16 7 |
| 10045 | e3 2315255808 17 1 16 |
| 10046 | mimmed 4043309056 31 17 0 |
| 10047 | trapc 1 3 |
| 10048 | matconst 16 8192 |
| 10049 | e3 3942645760 31 1 16 |
| 10050 | trapc 8 3 |
| 10051 | matconst 16 8 |
| 10052 | e3 2596276224 1 1 16 |
| 10053 | hload x 2 2 |
| 10054 | spsub 16 |
| 10055 | stkchk |
| 10056 | matconst 3 1000000000 |
| 10057 | emit 4043309151 |
| 10058 | forever = get oc 0 |
| 10059 | emit 1409286155 |
| 10060 | e3 2596276224 4 2 3 |
| 10061 | emit 2600700037 |
| 10062 | emit 4177527780 |
| 10063 | emit 4177528805 |
| 10064 | emit or ulong 2432697312 2 |
| 10065 | jump = get oc 0 |
| 10066 | emit 335544320 |
| 10067 | patch19 forever get oc 0 |
| 10068 | matconst 2 0 |
| 10069 | patch26 jump get oc 0 |
| 10070 | matconst 3 0 |
| 10071 | matconst 4 8 |
| 10072 | hsys 73 |
| 10073 | spadd 16 |
| 10074 | hreturn dst x |
| 10075 | end |
| 10076 | |
| 10077 | note sendmsg has one checked iovec and no ancillary data or exposed kernel pointers. |
| 10078 | note Arm ARM STR unsigned offset: imm12 scaled by 8, Rn=SP; private msghdr then iovec. |
| 10079 | fn hsendmsg dst ulong x ulong to void |
| 10080 | harg x 4 8 |
| 10081 | e = harray x 0 |
| 10082 | harg x 2 8 |
| 10083 | save |
| 10084 | hload x 4 0 |
| 10085 | hload x 2 2 |
| 10086 | matconst 16 16384 |
| 10087 | e3 2852126720 2 2 16 |
| 10088 | basearg 3 e |
| 10089 | loadarg 16 1 get a_ar add get a_rb 77 add x 21 |
| 10090 | e3 2332033024 3 3 16 |
| 10091 | loadarg 4 1 get a_ar add get a_rb 77 add x 22 |
| 10092 | spsub 80 |
| 10093 | stkchk |
| 10094 | for j ulong 10 |
| 10095 | emit or or ulong 4177527776 31 shl j 10 |
| 10096 | end |
| 10097 | emit or or ulong 4177527776 3 shl ulong 8 10 |
| 10098 | emit or or ulong 4177527776 4 shl ulong 9 10 |
| 10099 | emit or or ulong 2432697312 3 shl ulong 64 10 |
| 10100 | emit or or ulong 4177527776 3 shl ulong 2 10 |
| 10101 | matconst 3 1 |
| 10102 | emit or or ulong 4177527776 3 shl ulong 3 10 |
| 10103 | emit or ulong 2432697312 1 |
| 10104 | hsys 211 |
| 10105 | spadd 80 |
| 10106 | hreturn dst x |
| 10107 | end |
| 10108 | |
| 10109 | note Bounded mapping table belongs to the emitted program, not the compiler process. |
| 10110 | note 128 slots of address, byte length, generation, access. Only owned spans are accessible. |
| 10111 | note Function mode has no program image: the caller's runtime table supplies the zero-initialised |
| 10112 | note 4096-byte table at entry 31 (mcheck and mnew load it from [x7, #248]); nothing is reserved here. |
| 10113 | fn mtinit to void |
| 10114 | if eq get progmode 0 0 |
| 10115 | ret |
| 10116 | end |
| 10117 | if eq get maptab 0 0 |
| 10118 | p = get poolb 0 |
| 10119 | if gt p 1073737728 |
| 10120 | note d2site 165|mtinit: size capacity; condition if gt p 1073737728 |
| 10121 | put d2site 0 165 |
| 10122 | fail 23 |
| 10123 | end |
| 10124 | put maptab 0 add 276824064 p |
| 10125 | put poolb 0 add p 4096 |
| 10126 | end |
| 10127 | end |
| 10128 | note Instruction forms in seed/rung2/table.s2. ldr/str offsets count eight-byte cells. |
| 10129 | fn mload d ulong n ulong off ulong to void |
| 10130 | emit or or or 4181721088 d shl n 5 shl off 10 |
| 10131 | end |
| 10132 | fn mstore d ulong n ulong off ulong to void |
| 10133 | emit or or or 4177526784 d shl n 5 shl off 10 |
| 10134 | end |
| 10135 | fn mimmed op ulong d ulong n ulong k ulong to void |
| 10136 | emit or or or op d shl n 5 shl k 10 |
| 10137 | end |
| 10138 | fn mbranch cc ulong to ulong |
| 10139 | p = get oc 0 |
| 10140 | emit or 1409286144 cc |
| 10141 | ret p |
| 10142 | end |
| 10143 | |
| 10144 | note Descriptor-kind table is process local, not a sandbox. Full fd keys avoid high-fd cleanup resets. |
| 10145 | note Tags certify the current descriptor, not a generation-bearing stale integer reference. |
| 10146 | note X10 fd, X11 entry or end, X12 remaining. X0..X8 and X15..X17 preserved. |
| 10147 | fn fdscan kind ulong to void |
| 10148 | matconst 11 get fdtab 0 |
| 10149 | matconst 12 128 |
| 10150 | head = get oc 0 |
| 10151 | mload 14 11 1 |
| 10152 | mimmed 4043309056 31 14 kind |
| 10153 | next = mbranch 1 |
| 10154 | found = ulong 0 |
| 10155 | if ne kind 0 |
| 10156 | mload 13 11 0 |
| 10157 | e3 3942645760 31 13 10 |
| 10158 | found = mbranch 0 |
| 10159 | else |
| 10160 | found = mbranch 0 |
| 10161 | end |
| 10162 | patch19 next get oc 0 |
| 10163 | mimmed 2432696320 11 11 16 |
| 10164 | mimmed 3506438144 12 12 1 |
| 10165 | mimmed 4043309056 31 12 0 |
| 10166 | again = mbranch 1 |
| 10167 | patch19 again head |
| 10168 | patch19 found get oc 0 |
| 10169 | end |
| 10170 | fn fdcheck kind ulong to void |
| 10171 | fdscan kind |
| 10172 | mimmed 4043309056 31 12 0 |
| 10173 | trapc 0 3 |
| 10174 | end |
| 10175 | fn fdforget to void |
| 10176 | note Match either kind, clearing every matching key. No propagation through dupfd. |
| 10177 | for kind ulong 2 |
| 10178 | fdscan add kind 1 |
| 10179 | mimmed 4043309056 31 12 0 |
| 10180 | none = mbranch 0 |
| 10181 | mstore 31 11 1 |
| 10182 | patch19 none get oc 0 |
| 10183 | end |
| 10184 | end |
| 10185 | fn fdrecord kind ulong to void |
| 10186 | mimmed 4043309056 31 0 0 |
| 10187 | bad = mbranch 11 |
| 10188 | mstore 0 11 0 |
| 10189 | matconst 12 kind |
| 10190 | mstore 12 11 1 |
| 10191 | patch19 bad get oc 0 |
| 10192 | end |
| 10193 | |
| 10194 | |
| 10195 | |
| 10196 | note Validate a long handle in X10; produce entry X11, base X13, length X12. |
| 10197 | note The slot's generation defeats a stale handle after close and slot reuse. |
| 10198 | fn mcheck to void |
| 10199 | if eq get progmode 0 0 |
| 10200 | matconst 15 8191 |
| 10201 | else |
| 10202 | matconst 15 255 |
| 10203 | end |
| 10204 | e3 2315255808 11 10 15 |
| 10205 | mimmed 4043309056 31 11 1 |
| 10206 | trapc 3 3 |
| 10207 | if eq get progmode 0 0 |
| 10208 | mload 14 7 31 |
| 10209 | mload 14 14 0 |
| 10210 | mimmed 4043309056 31 14 1 |
| 10211 | trapc 3 3 |
| 10212 | matconst 15 4098 |
| 10213 | e3 3942645760 31 14 15 |
| 10214 | trapc 8 3 |
| 10215 | e3 3942645760 31 11 14 |
| 10216 | trapc 8 3 |
| 10217 | else |
| 10218 | mimmed 4043309056 31 11 128 |
| 10219 | trapc 8 3 |
| 10220 | end |
| 10221 | mimmed 3506438144 11 11 1 |
| 10222 | matconst 15 32 |
| 10223 | e3 2600500224 11 11 15 |
| 10224 | if eq get progmode 0 0 |
| 10225 | mload 15 7 31 |
| 10226 | mimmed 2432696320 15 15 32 |
| 10227 | else |
| 10228 | matconst 15 get maptab 0 |
| 10229 | end |
| 10230 | e3 2332033024 11 11 15 |
| 10231 | mload 14 11 2 |
| 10232 | mimmed 4043309056 31 14 0 |
| 10233 | trapc 0 3 |
| 10234 | if eq get progmode 0 0 |
| 10235 | matconst 15 13 |
| 10236 | else |
| 10237 | matconst 15 8 |
| 10238 | end |
| 10239 | e3 2596283392 10 10 15 |
| 10240 | e3 3942645760 31 10 14 |
| 10241 | trapc 1 3 |
| 10242 | mload 13 11 0 |
| 10243 | mimmed 4043309056 31 13 0 |
| 10244 | trapc 0 3 |
| 10245 | mload 12 11 1 |
| 10246 | end |
| 10247 | |
| 10248 | note mapnew fd:int offset:ulong bytes:ulong access:int mode:int -> long handle/errno. |
| 10249 | note Access 1 or 3 and modes 1/2/33/34 must be literal. No fixed address or executable map. |
| 10250 | note vfiomap fd:int A off n -> long handle/errno: n must be 32, a struct vfio_region_info the kernel |
| 10251 | note filled. Its flags need READ|MMAP (1|4); size and offset come from the span. Always read-only shared. |
| 10252 | note vfiomapw is the same with flags READ|WRITE|MMAP (7) and a read/write shared map, so mapset can store |
| 10253 | note to device registers (BAR0 MMIO). Only a span the kernel reported writable maps writable. |
| 10254 | fn mnew c ulong dst ulong x ulong to void |
| 10255 | acc = ulong 0 |
| 10256 | mode = ulong 1048610 |
| 10257 | if eq c 242 |
| 10258 | harg x 0 8 |
| 10259 | harg x 1 5 |
| 10260 | harg x 2 5 |
| 10261 | acc = ulong 3 |
| 10262 | mode = ulong 1 |
| 10263 | end |
| 10264 | if eq c 243 |
| 10265 | harg x 2 5 |
| 10266 | mode = ulong 34 |
| 10267 | end |
| 10268 | if or eq c 229 eq c 230 |
| 10269 | harg x 4 8 |
| 10270 | put a_ar add get a_rb 77 add x 20 harray x 0 |
| 10271 | put a_ar add get a_rb 77 add x 23 alloc |
| 10272 | matconst get a_ar add get a_rb 77 add x 23 32 |
| 10273 | e3 3942645760 31 a_g 77 add x 22 a_g 77 add x 23 |
| 10274 | trapc 1 3 |
| 10275 | acc = ulong 1 |
| 10276 | if eq c 230 |
| 10277 | acc = ulong 3 |
| 10278 | end |
| 10279 | mode = ulong 1 |
| 10280 | end |
| 10281 | if eq c 167 |
| 10282 | harg x 0 8 |
| 10283 | harg x 1 5 |
| 10284 | harg x 2 5 |
| 10285 | harg x 3 8 |
| 10286 | harg x 4 8 |
| 10287 | if or ne a_g 77 add x 14 3 ne a_g 77 add x 16 3 |
| 10288 | note d2site 166|mnew: word or declaration in a place that does not allow it; condition if or ne a_g 77 add x 14 3 ne a_g 77 add x 16 3 |
| 10289 | put d2site 0 166 |
| 10290 | fail 9 |
| 10291 | end |
| 10292 | acc = get a_ar add get a_rb 77 add x 15 |
| 10293 | mode = get a_ar add get a_rb 77 add x 17 |
| 10294 | if and ne acc 1 ne acc 3 |
| 10295 | note d2site 167|mnew: word or declaration in a place that does not allow it; condition if and ne acc 1 ne acc 3 |
| 10296 | put d2site 0 167 |
| 10297 | fail 9 |
| 10298 | end |
| 10299 | if and and and ne mode 1 ne mode 2 ne mode 33 ne mode 34 |
| 10300 | note d2site 168|mnew: word or declaration in a place that does not allow it; condition if and and and ne mode 1 ne mode 2 ne mode 33 ne mode 34 |
| 10301 | put d2site 0 168 |
| 10302 | fail 9 |
| 10303 | end |
| 10304 | end |
| 10305 | if eq c 176 |
| 10306 | harg x 1 5 |
| 10307 | harg x 2 5 |
| 10308 | end |
| 10309 | save |
| 10310 | if eq c 242 |
| 10311 | hload x 0 0 |
| 10312 | kmapfd |
| 10313 | end |
| 10314 | if or eq c 229 eq c 230 |
| 10315 | basearg 6 get a_ar add get a_rb 77 add x 20 |
| 10316 | loadarg 16 1 get a_ar add get a_rb 77 add x 21 |
| 10317 | e3 2332033024 6 6 16 |
| 10318 | mimmed 3107979264 15 6 1 |
| 10319 | matconst 14 or 5 sub acc 1 |
| 10320 | e3 2315255808 15 15 14 |
| 10321 | mimmed 4043309056 31 15 or 5 sub acc 1 |
| 10322 | trapc 1 3 |
| 10323 | mload 1 6 2 |
| 10324 | hload x 4 4 |
| 10325 | mload 5 6 3 |
| 10326 | else |
| 10327 | hload x 2 1 |
| 10328 | end |
| 10329 | mimmed 4043309056 31 1 0 |
| 10330 | trapc 0 3 |
| 10331 | if lt c 242 |
| 10332 | matconst 15 68719476736 |
| 10333 | e3 3942645760 31 1 15 |
| 10334 | trapc 8 3 |
| 10335 | end |
| 10336 | if eq c 242 |
| 10337 | hload x 0 4 |
| 10338 | hload x 1 5 |
| 10339 | end |
| 10340 | if eq c 243 |
| 10341 | matconst 4 18446744073709551615 |
| 10342 | matconst 5 0 |
| 10343 | note Keep the exact requested length; over-reserve only to align the owned base to 2 MiB. |
| 10344 | matconst 15 4095 |
| 10345 | e3 2315255808 14 1 15 |
| 10346 | mimmed 4043309056 31 14 0 |
| 10347 | trapc 1 3 |
| 10348 | matconst 15 2097152 |
| 10349 | e3 2868903936 1 1 15 |
| 10350 | trapc 2 3 |
| 10351 | end |
| 10352 | if eq c 167 |
| 10353 | hload x 0 4 |
| 10354 | hload x 1 5 |
| 10355 | if ge mode 32 |
| 10356 | matconst 15 18446744073709551615 |
| 10357 | e3 3942645760 31 4 15 |
| 10358 | trapc 1 3 |
| 10359 | mimmed 4043309056 31 5 0 |
| 10360 | trapc 1 3 |
| 10361 | end |
| 10362 | end |
| 10363 | if eq c 176 |
| 10364 | hload x 1 0 |
| 10365 | note Reservations are page aligned and bounded below the 40-bit GPU command limit. |
| 10366 | matconst 15 65536 |
| 10367 | e3 3942645760 31 0 15 |
| 10368 | trapc 3 3 |
| 10369 | matconst 15 1099511627776 |
| 10370 | e3 3405774848 15 15 1 |
| 10371 | e3 3942645760 31 0 15 |
| 10372 | trapc 8 3 |
| 10373 | matconst 15 4095 |
| 10374 | e3 2315255808 14 0 15 |
| 10375 | mimmed 4043309056 31 14 0 |
| 10376 | trapc 1 3 |
| 10377 | e3 2315255808 14 1 15 |
| 10378 | mimmed 4043309056 31 14 0 |
| 10379 | trapc 1 3 |
| 10380 | matconst 4 18446744073709551615 |
| 10381 | matconst 5 0 |
| 10382 | end |
| 10383 | if eq get progmode 0 0 |
| 10384 | mload 9 7 31 |
| 10385 | mload 12 9 0 |
| 10386 | mimmed 4043309056 31 12 1 |
| 10387 | trapc 3 3 |
| 10388 | matconst 15 4098 |
| 10389 | e3 3942645760 31 12 15 |
| 10390 | trapc 8 3 |
| 10391 | mload 14 9 2 |
| 10392 | mimmed 4043309056 31 14 1 |
| 10393 | trapc 3 3 |
| 10394 | matconst 15 1125899906842623 |
| 10395 | e3 3942645760 31 14 15 |
| 10396 | trapc 8 3 |
| 10397 | mimmed 2432696320 9 9 32 |
| 10398 | else |
| 10399 | matconst 9 get maptab 0 |
| 10400 | end |
| 10401 | matconst 10 1 |
| 10402 | head = get oc 0 |
| 10403 | mload 11 9 0 |
| 10404 | mimmed 4043309056 31 11 0 |
| 10405 | used = mbranch 1 |
| 10406 | mload 11 9 2 |
| 10407 | if eq get progmode 0 0 |
| 10408 | e3 3942645760 31 11 14 |
| 10409 | else |
| 10410 | matconst 15 36028797018963967 |
| 10411 | e3 3942645760 31 11 15 |
| 10412 | end |
| 10413 | vacant = mbranch 3 |
| 10414 | patch19 used get oc 0 |
| 10415 | mimmed 2432696320 9 9 32 |
| 10416 | mimmed 2432696320 10 10 1 |
| 10417 | if eq get progmode 0 0 |
| 10418 | e3 3942645760 31 10 12 |
| 10419 | else |
| 10420 | mimmed 4043309056 31 10 128 |
| 10421 | end |
| 10422 | again = mbranch 9 |
| 10423 | patch19 again head |
| 10424 | matconst 0 18446744073709551592 |
| 10425 | full = get oc 0 |
| 10426 | emit 335544320 |
| 10427 | patch19 vacant get oc 0 |
| 10428 | if eq c 176 |
| 10429 | hload x 1 0 |
| 10430 | else |
| 10431 | matconst 0 0 |
| 10432 | end |
| 10433 | matconst 2 acc |
| 10434 | matconst 3 mode |
| 10435 | hsys 222 |
| 10436 | mimmed 4043309056 31 0 0 |
| 10437 | failed = mbranch 11 |
| 10438 | if eq c 243 |
| 10439 | note Trim only the prefix and suffix of this fresh anonymous mapping. |
| 10440 | matconst 15 2097152 |
| 10441 | e3 3405774848 1 1 15 |
| 10442 | matconst 15 2097151 |
| 10443 | e3 2332033024 2 0 15 |
| 10444 | matconst 15 18446744073707454464 |
| 10445 | e3 2315255808 2 2 15 |
| 10446 | e3 3405774848 3 2 0 |
| 10447 | spsub 32 |
| 10448 | mstore 1 31 0 |
| 10449 | mstore 2 31 1 |
| 10450 | mstore 3 31 2 |
| 10451 | mimmed 4043309056 31 3 0 |
| 10452 | aligned = mbranch 0 |
| 10453 | e3 2852126720 1 31 3 |
| 10454 | hsys 215 |
| 10455 | mimmed 4043309056 31 0 0 |
| 10456 | trapc 1 3 |
| 10457 | patch19 aligned get oc 0 |
| 10458 | mload 0 31 1 |
| 10459 | mload 1 31 0 |
| 10460 | e3 2332033024 0 0 1 |
| 10461 | mload 2 31 2 |
| 10462 | matconst 1 2097152 |
| 10463 | e3 3405774848 1 1 2 |
| 10464 | hsys 215 |
| 10465 | mimmed 4043309056 31 0 0 |
| 10466 | trapc 1 3 |
| 10467 | mload 0 31 1 |
| 10468 | mload 1 31 0 |
| 10469 | spadd 32 |
| 10470 | end |
| 10471 | if eq c 176 |
| 10472 | hload x 1 14 |
| 10473 | e3 3942645760 31 0 14 |
| 10474 | exact = mbranch 0 |
| 10475 | note Old kernels may ignore NOREPLACE; reject and unmap any displaced result. |
| 10476 | hsys 215 |
| 10477 | mimmed 4043309056 31 0 0 |
| 10478 | trapc 1 3 |
| 10479 | matconst 0 18446744073709551521 |
| 10480 | wrong = get oc 0 |
| 10481 | emit 335544320 |
| 10482 | patch19 exact get oc 0 |
| 10483 | a_p 77 add x 23 wrong |
| 10484 | end |
| 10485 | mstore 0 9 0 |
| 10486 | mstore 1 9 1 |
| 10487 | mimmed 2432696320 11 11 1 |
| 10488 | mstore 11 9 2 |
| 10489 | matconst 15 acc |
| 10490 | mstore 15 9 3 |
| 10491 | if eq get progmode 0 0 |
| 10492 | matconst 15 13 |
| 10493 | else |
| 10494 | matconst 15 8 |
| 10495 | end |
| 10496 | e3 2596282368 0 11 15 |
| 10497 | e3 2852126720 0 0 10 |
| 10498 | patch19 failed get oc 0 |
| 10499 | patch26 full get oc 0 |
| 10500 | if eq c 176 |
| 10501 | head = a_g 77 add x 23 |
| 10502 | patch26 head get oc 0 |
| 10503 | end |
| 10504 | hreturn dst x |
| 10505 | end |
| 10506 | |
| 10507 | note Replace only an entire owned PROT_NONE reservation. Failed binds retire the handle. |
| 10508 | fn mbind dst ulong x ulong to void |
| 10509 | harg x 0 9 |
| 10510 | harg x 1 8 |
| 10511 | harg x 2 5 |
| 10512 | harg x 3 8 |
| 10513 | if ne get a_ar add get a_rb 77 add x 14 3 |
| 10514 | note d2site 169|mbind: word or declaration in a place that does not allow it; condition if ne get a_ar add get a_rb 77 add x 14 3 |
| 10515 | put d2site 0 169 |
| 10516 | fail 9 |
| 10517 | end |
| 10518 | acc = get a_ar add get a_rb 77 add x 15 |
| 10519 | if and ne acc 1 ne acc 3 |
| 10520 | note d2site 170|mbind: word or declaration in a place that does not allow it; condition if and ne acc 1 ne acc 3 |
| 10521 | put d2site 0 170 |
| 10522 | fail 9 |
| 10523 | end |
| 10524 | save |
| 10525 | hload x 0 10 |
| 10526 | mcheck |
| 10527 | mload 15 11 3 |
| 10528 | mimmed 4043309056 31 15 0 |
| 10529 | trapc 1 3 |
| 10530 | e3 2852126720 0 31 13 |
| 10531 | e3 2852126720 1 31 12 |
| 10532 | matconst 2 acc |
| 10533 | matconst 3 17 |
| 10534 | hload x 1 4 |
| 10535 | hload x 2 5 |
| 10536 | hsys 222 |
| 10537 | mimmed 4043309056 31 0 0 |
| 10538 | failed = mbranch 11 |
| 10539 | e3 3942645760 31 0 13 |
| 10540 | trapc 1 3 |
| 10541 | matconst 15 acc |
| 10542 | mstore 15 11 3 |
| 10543 | matconst 0 0 |
| 10544 | done = get oc 0 |
| 10545 | emit 335544320 |
| 10546 | patch19 failed get oc 0 |
| 10547 | e3 2852126720 10 31 0 |
| 10548 | e3 2852126720 0 31 13 |
| 10549 | e3 2852126720 1 31 12 |
| 10550 | note Preserve a droppable owner but forbid a second bind if cleanup also fails. |
| 10551 | if eq get progmode 0 0 |
| 10552 | matconst 15 4 |
| 10553 | mstore 15 11 3 |
| 10554 | end |
| 10555 | hsys 215 |
| 10556 | mimmed 4043309056 31 0 0 |
| 10557 | trapc 1 3 |
| 10558 | mstore 31 11 0 |
| 10559 | mstore 31 11 1 |
| 10560 | mstore 31 11 3 |
| 10561 | e3 2852126720 0 31 10 |
| 10562 | patch26 done get oc 0 |
| 10563 | hreturn dst x |
| 10564 | end |
| 10565 | |
| 10566 | note Copies traverse only checked live mapped spans and normal bounded byte arrays. |
| 10567 | note mapread writes A; mapwrite reads A. Both return the count, with no pointer decay. |
| 10568 | fn mcopy c ulong dst ulong x ulong to void |
| 10569 | harg x 4 9 |
| 10570 | harg x 3 5 |
| 10571 | wr = ulong 0 |
| 10572 | if eq c 169 |
| 10573 | wr = ulong 1 |
| 10574 | end |
| 10575 | e = harray x wr |
| 10576 | save |
| 10577 | hload x 4 10 |
| 10578 | mcheck |
| 10579 | mload 15 11 3 |
| 10580 | mimmed 4043309056 31 15 0 |
| 10581 | trapc 0 3 |
| 10582 | if eq get progmode 0 0 |
| 10583 | mimmed 4043309056 31 15 3 |
| 10584 | trapc 8 3 |
| 10585 | end |
| 10586 | hload x 3 0 |
| 10587 | e3 3942645760 31 0 12 |
| 10588 | trapc 8 3 |
| 10589 | e3 3405774848 12 12 0 |
| 10590 | loadarg 2 1 get a_ar add get a_rb 77 add x 22 |
| 10591 | e3 3942645760 31 2 12 |
| 10592 | trapc 8 3 |
| 10593 | e3 2332033024 0 13 0 |
| 10594 | basearg 1 e |
| 10595 | loadarg 16 1 get a_ar add get a_rb 77 add x 21 |
| 10596 | e3 2332033024 1 1 16 |
| 10597 | if eq c 170 |
| 10598 | mload 15 11 3 |
| 10599 | mimmed 4043309056 31 15 3 |
| 10600 | trapc 1 3 |
| 10601 | e3 2852126720 15 31 0 |
| 10602 | e3 2852126720 0 31 1 |
| 10603 | e3 2852126720 1 31 15 |
| 10604 | end |
| 10605 | e3 2852126720 4 31 2 |
| 10606 | head = get oc 0 |
| 10607 | mimmed 4043309056 31 2 0 |
| 10608 | done = mbranch 0 |
| 10609 | emit 960495619 |
| 10610 | emit 956301347 |
| 10611 | mimmed 2432696320 0 0 1 |
| 10612 | mimmed 2432696320 1 1 1 |
| 10613 | mimmed 3506438144 2 2 1 |
| 10614 | back head |
| 10615 | patch19 done get oc 0 |
| 10616 | e3 2852126720 0 31 4 |
| 10617 | hreturn dst x |
| 10618 | end |
| 10619 | |
| 10620 | note NVRM NVOS21/NVOS54 parameter binding. The kernel sees one private header. |
| 10621 | note Pointer and length are derived from a checked byte span, never from user bytes. |
| 10622 | note Request is exactly the 32-byte RM_ALLOC or RM_CONTROL encoding. |
| 10623 | fn hdevcall dst ulong x ulong to void |
| 10624 | n = xhreq 171 x |
| 10625 | e = harray x 1 |
| 10626 | put a_ar add get a_rb 77 add x 23 e |
| 10627 | a_p 77 add x 24 a_g 77 add x 21 |
| 10628 | t = alloc |
| 10629 | matconst t 32 |
| 10630 | e3 3942645760 31 get a_ar add get a_rb 77 add x 22 t |
| 10631 | trapc 1 3 |
| 10632 | f = harray x 1 |
| 10633 | if eq e f |
| 10634 | note d2site 171|hdevcall: global passed as an argument, or one array twice in a call; condition if eq e f |
| 10635 | put d2site 0 171 |
| 10636 | fail 19 |
| 10637 | end |
| 10638 | t = alloc |
| 10639 | matconst t 1048576 |
| 10640 | e3 3942645760 31 get a_ar add get a_rb 77 add x 22 t |
| 10641 | trapc 8 3 |
| 10642 | save |
| 10643 | hload x 4 0 |
| 10644 | hload x 2 1 |
| 10645 | basearg 10 get a_ar add get a_rb 77 add x 23 |
| 10646 | loadarg 16 1 get a_ar add get a_rb 77 add x 24 |
| 10647 | e3 2332033024 10 10 16 |
| 10648 | basearg 11 f |
| 10649 | loadarg 16 1 get a_ar add get a_rb 77 add x 21 |
| 10650 | e3 2332033024 11 11 16 |
| 10651 | loadarg 12 1 get a_ar add get a_rb 77 add x 22 |
| 10652 | note Refuse overlapping parameter/header spans even through distinct edit parameters. |
| 10653 | mimmed 4043309056 31 12 0 |
| 10654 | empty = mbranch 0 |
| 10655 | e3 2332033024 14 11 12 |
| 10656 | e3 3942645760 31 14 10 |
| 10657 | before = mbranch 9 |
| 10658 | mimmed 2432696320 14 10 32 |
| 10659 | e3 3942645760 31 11 14 |
| 10660 | trapc 3 3 |
| 10661 | patch19 before get oc 0 |
| 10662 | patch19 empty get oc 0 |
| 10663 | mload 13 10 2 |
| 10664 | mimmed 4043309056 31 13 0 |
| 10665 | trapc 1 3 |
| 10666 | mimmed 4043309056 31 12 0 |
| 10667 | nonzero = mbranch 1 |
| 10668 | matconst 11 0 |
| 10669 | patch19 nonzero get oc 0 |
| 10670 | spsub 32 |
| 10671 | stkchk |
| 10672 | for i ulong 4 |
| 10673 | mload 13 10 i |
| 10674 | mstore 13 31 i |
| 10675 | end |
| 10676 | mstore 11 31 2 |
| 10677 | emit 3103792108 |
| 10678 | emit 2432697314 |
| 10679 | hsys 29 |
| 10680 | for i ulong 4 |
| 10681 | if ne i 2 |
| 10682 | mload 13 31 i |
| 10683 | mstore 13 10 i |
| 10684 | end |
| 10685 | end |
| 10686 | spadd 32 |
| 10687 | hreturn dst x |
| 10688 | end |
| 10689 | |
| 10690 | |
| 10691 | note Mapped-address export for driver GPU VA serialization; no arbitrary-address access. |
| 10692 | note Aligned word access uses exactly one 32/64-bit load/store bracketed by DSB SY. |
| 10693 | fn mmapio c ulong dst ulong x ulong to void |
| 10694 | harg x 0 9 |
| 10695 | if eq c 173 |
| 10696 | save |
| 10697 | hload x 0 10 |
| 10698 | mcheck |
| 10699 | e3 2852126720 0 31 13 |
| 10700 | hreturn dst x |
| 10701 | put rt 0 5 |
| 10702 | ret |
| 10703 | end |
| 10704 | harg x 1 5 |
| 10705 | harg x 2 8 |
| 10706 | if ne get a_ar add get a_rb 77 add x 12 3 |
| 10707 | note d2site 172|mmapio: word or declaration in a place that does not allow it; condition if ne get a_ar add get a_rb 77 add x 12 3 |
| 10708 | put d2site 0 172 |
| 10709 | fail 9 |
| 10710 | end |
| 10711 | w = get a_ar add get a_rb 77 add x 13 |
| 10712 | if and ne w 4 ne w 8 |
| 10713 | note d2site 173|mmapio: word or declaration in a place that does not allow it; condition if and ne w 4 ne w 8 |
| 10714 | put d2site 0 173 |
| 10715 | fail 9 |
| 10716 | end |
| 10717 | if eq c 175 |
| 10718 | harg x 3 5 |
| 10719 | end |
| 10720 | save |
| 10721 | hload x 0 10 |
| 10722 | mcheck |
| 10723 | hload x 1 0 |
| 10724 | mload 15 11 3 |
| 10725 | mimmed 4043309056 31 15 0 |
| 10726 | trapc 0 3 |
| 10727 | if eq get progmode 0 0 |
| 10728 | mimmed 4043309056 31 15 3 |
| 10729 | trapc 8 3 |
| 10730 | end |
| 10731 | e3 3942645760 31 0 12 |
| 10732 | trapc 8 3 |
| 10733 | e3 3405774848 12 12 0 |
| 10734 | mimmed 4043309056 31 12 w |
| 10735 | trapc 3 3 |
| 10736 | matconst 15 sub w 1 |
| 10737 | e3 2315255808 14 0 15 |
| 10738 | mimmed 4043309056 31 14 0 |
| 10739 | trapc 1 3 |
| 10740 | e3 2332033024 13 13 0 |
| 10741 | if eq c 175 |
| 10742 | mload 15 11 3 |
| 10743 | mimmed 4043309056 31 15 3 |
| 10744 | trapc 1 3 |
| 10745 | hload x 3 2 |
| 10746 | if eq w 4 |
| 10747 | matconst 15 4294967295 |
| 10748 | e3 3942645760 31 2 15 |
| 10749 | trapc 8 3 |
| 10750 | end |
| 10751 | emit 3573759903 |
| 10752 | if eq w 4 |
| 10753 | mimmed 3103784960 2 13 0 |
| 10754 | else |
| 10755 | mstore 2 13 0 |
| 10756 | end |
| 10757 | emit 3573759903 |
| 10758 | matconst 0 0 |
| 10759 | hreturn dst x |
| 10760 | else |
| 10761 | emit 3573759903 |
| 10762 | if eq w 4 |
| 10763 | mimmed 3107979264 0 13 0 |
| 10764 | else |
| 10765 | mload 0 13 0 |
| 10766 | end |
| 10767 | emit 3573759903 |
| 10768 | hreturn dst x |
| 10769 | put rt 0 5 |
| 10770 | end |
| 10771 | end |
| 10772 | |
| 10773 | note KFD private records: logical scratch 0..3 and 4 (SP), no language slot registers. |
| 10774 | fn kfdreg r ulong to ulong |
| 10775 | if eq get xtarget 0 0 |
| 10776 | if eq r 4 |
| 10777 | ret 31 |
| 10778 | end |
| 10779 | ret r |
| 10780 | end |
| 10781 | if eq r 1 |
| 10782 | ret 2 |
| 10783 | end |
| 10784 | if eq r 2 |
| 10785 | ret 6 |
| 10786 | end |
| 10787 | if eq r 3 |
| 10788 | ret 7 |
| 10789 | end |
| 10790 | ret r |
| 10791 | end |
| 10792 | fn kfdimm r ulong v ulong to void |
| 10793 | if eq get xtarget 0 0 |
| 10794 | matconst kfdreg r v |
| 10795 | else |
| 10796 | ximm kfdreg r v |
| 10797 | end |
| 10798 | end |
| 10799 | fn kfdload r ulong b ulong off ulong size ulong to void |
| 10800 | if eq get xtarget 0 0 |
| 10801 | op = ulong 4181721088 |
| 10802 | if eq size 4 |
| 10803 | op = ulong 3107979264 |
| 10804 | end |
| 10805 | mimmed op kfdreg r kfdreg b div off size |
| 10806 | else |
| 10807 | if eq size 8 |
| 10808 | xmem 139 kfdreg r kfdreg b off |
| 10809 | else |
| 10810 | xhraw kfdreg r kfdreg b off size |
| 10811 | end |
| 10812 | end |
| 10813 | end |
| 10814 | fn kfdstore r ulong b ulong off ulong to void |
| 10815 | if eq get xtarget 0 0 |
| 10816 | mstore kfdreg r kfdreg b div off 8 |
| 10817 | else |
| 10818 | xmem 137 kfdreg r kfdreg b off |
| 10819 | end |
| 10820 | end |
| 10821 | fn kfdcmp r ulong s ulong to void |
| 10822 | if eq get xtarget 0 0 |
| 10823 | e3 3942645760 31 kfdreg r kfdreg s |
| 10824 | else |
| 10825 | xrr 57 kfdreg r kfdreg s |
| 10826 | end |
| 10827 | end |
| 10828 | fn kfdcmpv r ulong v ulong to void |
| 10829 | if eq get xtarget 0 0 |
| 10830 | matconst 16 v |
| 10831 | e3 3942645760 31 kfdreg r 16 |
| 10832 | else |
| 10833 | xhcmp kfdreg r v |
| 10834 | end |
| 10835 | end |
| 10836 | fn kfdtrap c ulong to void |
| 10837 | if eq get xtarget 0 0 |
| 10838 | trapc c 3 |
| 10839 | else |
| 10840 | xtrap c 3 |
| 10841 | end |
| 10842 | end |
| 10843 | fn kfdjump c ulong to ulong |
| 10844 | if eq get xtarget 0 0 |
| 10845 | ret mbranch c |
| 10846 | end |
| 10847 | ret xbranch c |
| 10848 | end |
| 10849 | fn kfdpatch p ulong to void |
| 10850 | if eq get xtarget 0 0 |
| 10851 | patch19 p get oc 0 |
| 10852 | else |
| 10853 | xpatch p get oc 0 |
| 10854 | end |
| 10855 | end |
| 10856 | fn kfdadd r ulong v ulong to void |
| 10857 | if eq get xtarget 0 0 |
| 10858 | matconst 16 v |
| 10859 | e3 2332033024 kfdreg r kfdreg r 16 |
| 10860 | else |
| 10861 | xhadd kfdreg r v |
| 10862 | end |
| 10863 | end |
| 10864 | fn kfdzero off ulong to void |
| 10865 | kfdload 0 4 off 8 |
| 10866 | kfdcmpv 0 0 |
| 10867 | kfdtrap 1 |
| 10868 | end |
| 10869 | fn ksize q ulong to ulong |
| 10870 | if or or eq q 2148027137 eq q 1074285333 or eq q 3221768963 eq q 1074285335 |
| 10871 | ret 8 |
| 10872 | end |
| 10873 | if or eq q 1074285321 eq q 1074291721 |
| 10874 | ret 8 |
| 10875 | end |
| 10876 | if or eq q 3222293268 eq q 3222293265 |
| 10877 | ret 16 |
| 10878 | end |
| 10879 | if or or eq q 3222817560 eq q 3222817561 eq q 3222817548 |
| 10880 | ret 24 |
| 10881 | end |
| 10882 | if or eq q 1075340356 eq q 1075340359 |
| 10883 | ret 24 |
| 10884 | end |
| 10885 | if or eq q 3223341832 eq q 3223348291 |
| 10886 | ret 32 |
| 10887 | end |
| 10888 | if or or eq q 3223866134 eq q 3223872576 eq q 3223872578 |
| 10889 | ret 40 |
| 10890 | end |
| 10891 | if eq q 3224396870 |
| 10892 | ret 48 |
| 10893 | end |
| 10894 | if or eq q 3224921153 eq q 1077437513 |
| 10895 | ret 56 |
| 10896 | end |
| 10897 | if eq q 3225969738 |
| 10898 | ret 72 |
| 10899 | end |
| 10900 | if eq q 3227011842 |
| 10901 | ret 88 |
| 10902 | end |
| 10903 | if eq q 1082680389 |
| 10904 | ret 136 |
| 10905 | end |
| 10906 | note d2site 624|ksize: KFD request is not in the checked request allowlist |
| 10907 | put d2site 0 624 |
| 10908 | fail 9 |
| 10909 | ret 0 |
| 10910 | end |
| 10911 | fn kptr q ulong off ulong to bool |
| 10912 | if eq q 3227011842 |
| 10913 | ret or or le off 16 eq off 56 eq off 72 |
| 10914 | end |
| 10915 | if or eq q 3222817560 eq q 3222817561 |
| 10916 | ret eq off 8 |
| 10917 | end |
| 10918 | if or or eq q 3222293268 eq q 3222817548 or eq q 3223866134 eq q 3222293265 |
| 10919 | ret eq off 0 |
| 10920 | end |
| 10921 | if eq q 3223872576 |
| 10922 | ret eq off 16 |
| 10923 | end |
| 10924 | if eq q 3224396870 |
| 10925 | ret eq off 24 |
| 10926 | end |
| 10927 | ret false |
| 10928 | end |
| 10929 | note X6 anchors the original AArch64 save area while the private KFD record is on SP. |
| 10930 | fn karg x ulong i ulong r ulong to void |
| 10931 | j = add add x 8 mul i 2 |
| 10932 | k = a_g 77 j |
| 10933 | v = a_g 77 add j 1 |
| 10934 | if or or eq k 3 eq k 7 eq k 6 |
| 10935 | loadarg r k v |
| 10936 | else |
| 10937 | mload r 6 regidx v |
| 10938 | end |
| 10939 | end |
| 10940 | fn kbase e ulong to void |
| 10941 | if ge uchar get a_ar add get a_rb 7 sub e 1 4 |
| 10942 | basearg 3 e |
| 10943 | else |
| 10944 | mload 3 6 regidx ulong uchar get a_ar add get a_rb 4 sub e 1 |
| 10945 | end |
| 10946 | end |
| 10947 | note kind 0 reservation, kind 3 writable map. need is size-field offset or 255 for minimum sz. |
| 10948 | note Fixed-layout fields (shape bit 24) bind base plus a compiler constant (shape bits 32 to 47), never caller bytes; |
| 10949 | note their required remaining bytes are shape bits 48 to 63 (wider than the 8-bit literal size of other fields). |
| 10950 | fn kbind x ulong i ulong off ulong kind ulong shape ulong z ulong to void |
| 10951 | need = and shape 255 |
| 10952 | sz = and shr shape 8 255 |
| 10953 | optional = and shr shape 16 255 |
| 10954 | relative = ne and shape 16777216 0 |
| 10955 | kfdzero off |
| 10956 | if relative |
| 10957 | kfdimm 0 shr shape 48 |
| 10958 | else |
| 10959 | if eq need 255 |
| 10960 | kfdimm 0 sz |
| 10961 | else |
| 10962 | kfdload 0 4 need sz |
| 10963 | end |
| 10964 | end |
| 10965 | kfdstore 0 4 add z 8 |
| 10966 | if eq get xtarget 0 0 |
| 10967 | karg x i 10 |
| 10968 | mimmed 4043309056 31 10 0 |
| 10969 | else |
| 10970 | xha x i 10 |
| 10971 | xhcmp 10 0 |
| 10972 | end |
| 10973 | skip = ulong 0 |
| 10974 | if ne optional 0 |
| 10975 | skip = kfdjump 0 |
| 10976 | end |
| 10977 | if eq get xtarget 0 0 |
| 10978 | mcheck |
| 10979 | mload 0 11 3 |
| 10980 | else |
| 10981 | xhmcheck |
| 10982 | xmem 139 0 13 24 |
| 10983 | end |
| 10984 | kfdcmpv 0 kind |
| 10985 | kfdtrap 1 |
| 10986 | if relative |
| 10987 | note The offset is the compiler's ABI constant, never a caller-supplied byte. |
| 10988 | kfdimm 0 and shr shape 32 65535 |
| 10989 | if eq get xtarget 0 0 |
| 10990 | e3 3942645760 31 0 12 |
| 10991 | else |
| 10992 | xrr 57 0 9 |
| 10993 | end |
| 10994 | kfdtrap 8 |
| 10995 | note Subtract only after offset <= length; the existing extent check sees remaining bytes. |
| 10996 | if eq get xtarget 0 0 |
| 10997 | e3 3405774848 12 12 0 |
| 10998 | e3 2332033024 13 13 0 |
| 10999 | e3 3942645760 31 13 0 |
| 11000 | else |
| 11001 | xrr 41 9 0 |
| 11002 | xrr 1 8 0 |
| 11003 | xrr 57 8 0 |
| 11004 | end |
| 11005 | kfdtrap 3 |
| 11006 | end |
| 11007 | kfdload 0 4 add z 8 8 |
| 11008 | if eq get xtarget 0 0 |
| 11009 | e3 3942645760 31 0 12 |
| 11010 | else |
| 11011 | xrr 57 0 9 |
| 11012 | end |
| 11013 | kfdtrap 8 |
| 11014 | if eq get xtarget 0 0 |
| 11015 | mstore 13 31 div off 8 |
| 11016 | else |
| 11017 | xmem 137 8 4 off |
| 11018 | end |
| 11019 | if ne optional 0 |
| 11020 | kfdpatch skip |
| 11021 | if ne optional 2 |
| 11022 | kfdload 0 4 off 8 |
| 11023 | kfdcmpv 0 0 |
| 11024 | live = kfdjump 1 |
| 11025 | kfdload 0 4 add z 8 8 |
| 11026 | kfdcmpv 0 0 |
| 11027 | kfdtrap 1 |
| 11028 | kfdpatch live |
| 11029 | end |
| 11030 | end |
| 11031 | end |
| 11032 | note Aperture payload dispatch looks ahead without consuming the array or scalar expression. |
| 11033 | fn kapmap to bool |
| 11034 | c0 = get cur 0 |
| 11035 | l0 = get line 0 |
| 11036 | a0 = get tka 0 |
| 11037 | b0 = get tkb 0 |
| 11038 | tok |
| 11039 | e = findname get tw 0 |
| 11040 | r = true |
| 11041 | if ne e 0 |
| 11042 | k = ulong uchar get a_ar add get a_rb 7 sub e 1 |
| 11043 | r = or eq k 0 eq k 9 |
| 11044 | end |
| 11045 | put cur 0 c0 |
| 11046 | put line 0 l0 |
| 11047 | put tka 0 a0 |
| 11048 | put tkb 0 b0 |
| 11049 | ret r |
| 11050 | end |
| 11051 | note Checked mapping payload: logical 3 receives base+offset, logical 2 receives span length. |
| 11052 | fn kmspan x ulong to void |
| 11053 | if eq get xtarget 0 0 |
| 11054 | karg x 0 10 |
| 11055 | mcheck |
| 11056 | mload 0 11 3 |
| 11057 | else |
| 11058 | xha x 0 10 |
| 11059 | xhmcheck |
| 11060 | xmem 139 0 13 24 |
| 11061 | end |
| 11062 | kfdcmpv 0 3 |
| 11063 | kfdtrap 1 |
| 11064 | if eq get xtarget 0 0 |
| 11065 | karg x 1 0 |
| 11066 | karg x 3 2 |
| 11067 | e3 2332033024 3 0 2 |
| 11068 | else |
| 11069 | xha x 1 0 |
| 11070 | xha x 3 6 |
| 11071 | xrr 137 7 0 |
| 11072 | xrr 1 7 6 |
| 11073 | end |
| 11074 | note Reject wrapped offset+length before comparing the mapping extent. |
| 11075 | kfdcmp 3 0 |
| 11076 | kfdtrap 3 |
| 11077 | if eq get xtarget 0 0 |
| 11078 | e3 3942645760 31 3 12 |
| 11079 | else |
| 11080 | xrr 57 7 9 |
| 11081 | end |
| 11082 | kfdtrap 8 |
| 11083 | if eq get xtarget 0 0 |
| 11084 | e3 2332033024 3 13 0 |
| 11085 | else |
| 11086 | xrr 137 7 8 |
| 11087 | xrr 1 7 0 |
| 11088 | end |
| 11089 | end |
| 11090 | fn kspan q ulong x ulong e ulong n ulong z ulong to void |
| 11091 | off = ulong 0 |
| 11092 | co = ulong 8 |
| 11093 | stride = ulong 56 |
| 11094 | if or eq q 3222817560 eq q 3222817561 |
| 11095 | off = ulong 8 |
| 11096 | co = ulong 16 |
| 11097 | stride = ulong 4 |
| 11098 | end |
| 11099 | if eq q 3222817548 |
| 11100 | stride = ulong 48 |
| 11101 | end |
| 11102 | if eq q 3223872576 |
| 11103 | off = ulong 16 |
| 11104 | co = ulong 12 |
| 11105 | stride = ulong 1 |
| 11106 | end |
| 11107 | if eq q 3224396870 |
| 11108 | off = ulong 24 |
| 11109 | co = ulong 8 |
| 11110 | stride = ulong 8 |
| 11111 | end |
| 11112 | kfdzero off |
| 11113 | if eq e 0 |
| 11114 | kmspan x |
| 11115 | else |
| 11116 | if eq get xtarget 0 0 |
| 11117 | kbase e |
| 11118 | mload 16 6 regidx a_g 77 add x 21 |
| 11119 | e3 2332033024 3 3 16 |
| 11120 | mload 2 6 regidx a_g 77 add x 22 |
| 11121 | else |
| 11122 | xhb 7 e a_g 77 add x 21 |
| 11123 | xhs 6 a_g 77 add x 22 |
| 11124 | end |
| 11125 | end |
| 11126 | if eq q 3224396870 |
| 11127 | note XE_EXEC_QUEUE_CREATE: require width=1 and num_placements=1 (8-byte engine_class_instance). |
| 11128 | kfdload 0 4 8 4 |
| 11129 | kfdcmpv 0 65537 |
| 11130 | kfdtrap 1 |
| 11131 | kfdimm 0 8 |
| 11132 | else |
| 11133 | kfdload 0 4 co 4 |
| 11134 | if eq get xtarget 0 0 |
| 11135 | matconst 16 stride |
| 11136 | e3 2600500224 0 0 16 |
| 11137 | else |
| 11138 | ximm 11 stride |
| 11139 | xb 73 15 175 |
| 11140 | emitb 195 |
| 11141 | end |
| 11142 | end |
| 11143 | note A u32 count times a wire stride fits u64. |
| 11144 | kfdcmp 0 2 |
| 11145 | kfdtrap 8 |
| 11146 | kfdload 1 4 z 8 |
| 11147 | if eq get xtarget 0 0 |
| 11148 | e3 2332033024 2 3 2 |
| 11149 | else |
| 11150 | xrr 1 6 7 |
| 11151 | end |
| 11152 | kfdcmp 2 1 |
| 11153 | before = kfdjump 9 |
| 11154 | kfdadd 1 n |
| 11155 | kfdcmp 3 1 |
| 11156 | kfdtrap 3 |
| 11157 | kfdpatch before |
| 11158 | if eq q 3223872576 |
| 11159 | note XE_DEVICE_QUERY with size=0 queries required byte length and requires data=NULL. |
| 11160 | kfdcmpv 0 0 |
| 11161 | qzero = kfdjump 0 |
| 11162 | kfdstore 3 4 off |
| 11163 | kfdpatch qzero |
| 11164 | else |
| 11165 | kfdstore 3 4 off |
| 11166 | end |
| 11167 | if eq q 3222817548 |
| 11168 | note event_data.ext is an unsupported pointer extension and must remain NULL. |
| 11169 | kfdload 2 4 co 4 |
| 11170 | loop = get oc 0 |
| 11171 | kfdcmpv 2 0 |
| 11172 | done = kfdjump 0 |
| 11173 | kfdload 0 3 32 8 |
| 11174 | kfdcmpv 0 0 |
| 11175 | kfdtrap 1 |
| 11176 | kfdadd 3 48 |
| 11177 | if eq get xtarget 0 0 |
| 11178 | mimmed 3506438144 2 2 1 |
| 11179 | back loop |
| 11180 | else |
| 11181 | xhsub 6 1 |
| 11182 | p = xbranch 14 |
| 11183 | xpatch p loop |
| 11184 | end |
| 11185 | kfdpatch done |
| 11186 | end |
| 11187 | end |
| 11188 | note ACQUIRE_VM accepts only a DRM render character descriptor. Linux stat layouts |
| 11189 | note are asm-generic (AArch64) and arch/x86 UAPI; fstat never follows a supplied path. |
| 11190 | fn kdrm z ulong to void |
| 11191 | if eq get xtarget 0 0 |
| 11192 | kfdload 0 4 0 4 |
| 11193 | mimmed 2432696320 1 31 add z 32 |
| 11194 | hsys 80 |
| 11195 | else |
| 11196 | xhraw 7 4 0 4 |
| 11197 | xmem 141 6 4 add z 32 |
| 11198 | xhcall 5 |
| 11199 | end |
| 11200 | kfdcmpv 0 0 |
| 11201 | kfdtrap 1 |
| 11202 | mo = ulong 16 |
| 11203 | ro = ulong 32 |
| 11204 | if ne get xtarget 0 0 |
| 11205 | mo = ulong 24 |
| 11206 | ro = ulong 40 |
| 11207 | end |
| 11208 | kfdload 0 4 add add z 32 mo 4 |
| 11209 | if eq get xtarget 0 0 |
| 11210 | matconst 16 61440 |
| 11211 | e3 2315255808 0 0 16 |
| 11212 | else |
| 11213 | ximm 11 61440 |
| 11214 | xrr 33 0 11 |
| 11215 | end |
| 11216 | kfdcmpv 0 8192 |
| 11217 | kfdtrap 1 |
| 11218 | kfdload 0 4 add add z 32 ro 8 |
| 11219 | note Linux dev_t encodes minor bits 0..7 and 20..31; every other bit is major. |
| 11220 | if eq get xtarget 0 0 |
| 11221 | matconst 16 18446744069415632640 |
| 11222 | e3 2315255808 1 0 16 |
| 11223 | else |
| 11224 | xrr 137 2 0 |
| 11225 | ximm 11 18446744069415632640 |
| 11226 | xrr 33 2 11 |
| 11227 | end |
| 11228 | kfdcmpv 1 57856 |
| 11229 | kfdtrap 1 |
| 11230 | if eq get xtarget 0 0 |
| 11231 | matconst 16 4293918975 |
| 11232 | e3 2315255808 0 0 16 |
| 11233 | else |
| 11234 | ximm 11 4293918975 |
| 11235 | xrr 33 0 11 |
| 11236 | end |
| 11237 | kfdcmpv 0 128 |
| 11238 | kfdtrap 3 |
| 11239 | end |
| 11240 | |
| 11241 | note kfdmap admits DRM render character descriptors or the device named /dev/kfd. |
| 11242 | note The fd is already evaluated and saved. Compare st_rdev, not a caller path. |
| 11243 | note Python oracle int.from_bytes(b'/dev/kfd','little') = 7234587703011271727. |
| 11244 | fn kmapfd to void |
| 11245 | if eq get xtarget 0 0 |
| 11246 | spsub 352 |
| 11247 | stkchk |
| 11248 | mimmed 2432696320 1 31 0 |
| 11249 | hsys 80 |
| 11250 | else |
| 11251 | xsp 1 352 |
| 11252 | xrr 137 6 4 |
| 11253 | xhcall 5 |
| 11254 | end |
| 11255 | kfdcmpv 0 0 |
| 11256 | kfdtrap 1 |
| 11257 | mo = ulong 16 |
| 11258 | ro = ulong 32 |
| 11259 | if ne get xtarget 0 0 |
| 11260 | mo = ulong 24 |
| 11261 | ro = ulong 40 |
| 11262 | end |
| 11263 | kchar mo |
| 11264 | kfdload 0 4 ro 8 |
| 11265 | kfdstore 0 4 304 |
| 11266 | if eq get xtarget 0 0 |
| 11267 | matconst 16 18446744069415632640 |
| 11268 | e3 2315255808 1 0 16 |
| 11269 | else |
| 11270 | xrr 137 2 0 |
| 11271 | ximm 11 18446744069415632640 |
| 11272 | xrr 33 2 11 |
| 11273 | end |
| 11274 | kfdcmpv 1 57856 |
| 11275 | other = kfdjump 1 |
| 11276 | if eq get xtarget 0 0 |
| 11277 | matconst 16 4293918975 |
| 11278 | e3 2315255808 0 0 16 |
| 11279 | else |
| 11280 | ximm 11 4293918975 |
| 11281 | xrr 33 0 11 |
| 11282 | end |
| 11283 | kfdcmpv 0 128 |
| 11284 | render = kfdjump 2 |
| 11285 | kfdpatch other |
| 11286 | kfdimm 0 7234587703011271727 |
| 11287 | kfdstore 0 4 320 |
| 11288 | kfdimm 0 0 |
| 11289 | kfdstore 0 4 328 |
| 11290 | if eq get xtarget 0 0 |
| 11291 | matconst 0 18446744073709551516 |
| 11292 | mimmed 2432696320 1 31 320 |
| 11293 | mimmed 2432696320 2 31 144 |
| 11294 | matconst 3 0 |
| 11295 | hsys 79 |
| 11296 | else |
| 11297 | ximm 7 18446744073709551516 |
| 11298 | xmem 141 6 4 320 |
| 11299 | xmem 141 2 4 144 |
| 11300 | ximm 10 0 |
| 11301 | xhcall 262 |
| 11302 | end |
| 11303 | kfdcmpv 0 0 |
| 11304 | kfdtrap 1 |
| 11305 | kchar add 144 mo |
| 11306 | kfdload 0 4 add 144 ro 8 |
| 11307 | kfdload 1 4 304 8 |
| 11308 | kfdcmp 0 1 |
| 11309 | kfdtrap 1 |
| 11310 | kfdpatch render |
| 11311 | if eq get xtarget 0 0 |
| 11312 | spadd 352 |
| 11313 | else |
| 11314 | xsp 0 352 |
| 11315 | end |
| 11316 | end |
| 11317 | fn kchar off ulong to void |
| 11318 | kfdload 0 4 off 4 |
| 11319 | if eq get xtarget 0 0 |
| 11320 | matconst 16 61440 |
| 11321 | e3 2315255808 0 0 16 |
| 11322 | else |
| 11323 | ximm 11 61440 |
| 11324 | xrr 33 0 11 |
| 11325 | end |
| 11326 | kfdcmpv 0 8192 |
| 11327 | kfdtrap 1 |
| 11328 | end |
| 11329 | |
| 11330 | fn kring to void |
| 11331 | kfdload 0 4 32 4 |
| 11332 | kfdcmpv 0 1024 |
| 11333 | kfdtrap 3 |
| 11334 | if eq get xtarget 0 0 |
| 11335 | mimmed 3506438144 1 0 1 |
| 11336 | e3 2315255808 0 0 1 |
| 11337 | else |
| 11338 | xrr 137 2 0 |
| 11339 | xhsub 2 1 |
| 11340 | xrr 33 0 2 |
| 11341 | end |
| 11342 | kfdcmpv 0 0 |
| 11343 | kfdtrap 1 |
| 11344 | end |
| 11345 | fn kshape need ulong sz ulong optional ulong to ulong |
| 11346 | ret or or need shl sz 8 shl optional 16 |
| 11347 | end |
| 11348 | fn kxezero q ulong to void |
| 11349 | if or eq q 3223872576 eq q 3224396870 |
| 11350 | kfdzero 0 |
| 11351 | end |
| 11352 | if eq q 1082680389 |
| 11353 | kfdzero 0 |
| 11354 | kfdzero 24 |
| 11355 | kfdzero 112 |
| 11356 | end |
| 11357 | if eq q 1077437513 |
| 11358 | kfdzero 0 |
| 11359 | kfdzero 16 |
| 11360 | end |
| 11361 | end |
| 11362 | |
| 11363 | fn kctl dst ulong x ulong to void |
| 11364 | harg x 4 8 |
| 11365 | harg x 2 4 |
| 11366 | if ne a_g 77 add x 12 3 |
| 11367 | note d2site 625|kctl: KFD request must be a literal |
| 11368 | put d2site 0 625 |
| 11369 | fail 9 |
| 11370 | end |
| 11371 | q = a_g 77 add x 13 |
| 11372 | n = ksize q |
| 11373 | z = mul div add n 15 16 16 |
| 11374 | e = harray x 1 |
| 11375 | if eq a_g 77 add x 10 3 |
| 11376 | if ne a_g 77 add x 11 n |
| 11377 | note d2site 626|kctl: literal KFD header length differs from the request ABI size |
| 11378 | put d2site 0 626 |
| 11379 | fail 9 |
| 11380 | end |
| 11381 | end |
| 11382 | a_p 77 add x 23 e |
| 11383 | a_p 77 add x 24 a_g 77 add x 21 |
| 11384 | a_p 77 add x 25 a_g 77 add x 22 |
| 11385 | a_p 77 add x 26 a_g 77 add x 16 |
| 11386 | a_p 77 add x 27 a_g 77 add x 17 |
| 11387 | span = false |
| 11388 | if or eq q 3222293268 eq q 3222817548 |
| 11389 | span = true |
| 11390 | end |
| 11391 | if or eq q 3222817560 eq q 3222817561 |
| 11392 | span = true |
| 11393 | end |
| 11394 | if or eq q 3223872576 eq q 3224396870 |
| 11395 | span = true |
| 11396 | end |
| 11397 | f = ulong 0 |
| 11398 | if span |
| 11399 | if and eq q 3222293268 kapmap |
| 11400 | harg x 0 9 |
| 11401 | harg x 1 5 |
| 11402 | harg x 3 5 |
| 11403 | else |
| 11404 | f = harray x 1 |
| 11405 | if eq e f |
| 11406 | note d2site 627|kctl: KFD header and pointed-to span must be distinct arrays |
| 11407 | put d2site 0 627 |
| 11408 | fail 19 |
| 11409 | end |
| 11410 | end |
| 11411 | end |
| 11412 | if eq q 3227011842 |
| 11413 | for i ulong 5 |
| 11414 | harg x i 9 |
| 11415 | end |
| 11416 | end |
| 11417 | if or eq q 3223866134 eq q 3222293265 |
| 11418 | harg x 0 9 |
| 11419 | end |
| 11420 | if eq get xtarget 0 0 |
| 11421 | save |
| 11422 | loadarg 0 1 a_g 77 add x 25 |
| 11423 | else |
| 11424 | xhbegin |
| 11425 | xhs 0 a_g 77 add x 25 |
| 11426 | end |
| 11427 | kfdcmpv 0 n |
| 11428 | kfdtrap 1 |
| 11429 | if eq get xtarget 0 0 |
| 11430 | basearg 3 e |
| 11431 | loadarg 16 1 a_g 77 add x 24 |
| 11432 | e3 2332033024 3 3 16 |
| 11433 | mimmed 2432696320 6 31 0 |
| 11434 | spsub add z 176 |
| 11435 | stkchk |
| 11436 | else |
| 11437 | xhb 7 e a_g 77 add x 24 |
| 11438 | xsp 1 add z 176 |
| 11439 | end |
| 11440 | kfdstore 3 4 z |
| 11441 | for i ulong div n 8 |
| 11442 | kfdload 0 3 mul i 8 8 |
| 11443 | kfdstore 0 4 mul i 8 |
| 11444 | end |
| 11445 | if span |
| 11446 | kspan q x f n z |
| 11447 | end |
| 11448 | if eq q 1074285333 |
| 11449 | kdrm z |
| 11450 | end |
| 11451 | kxezero q |
| 11452 | if eq q 3227011842 |
| 11453 | kring |
| 11454 | kbind x 0 0 3 kshape 32 4 0 z |
| 11455 | note One writable handle named as both write and read pointer selects the AMD AQL queue object: |
| 11456 | note the compiler binds write_dispatch_id at 56 and read_dispatch_id at 128 and requires all |
| 11457 | note 2304 bytes of amd_queue_v2_t inside the mapping (CP firmware reads past the 256-byte v1 object |
| 11458 | note when the caller-owned caps word sets SW_ASYNC_RECLAIM; ROCm amd_hsa_queue.h, MAX_NUM_XCC 128). |
| 11459 | note Distinct handles keep base-only binding. Both address fields stay zero in the caller's header. |
| 11460 | if eq get xtarget 0 0 |
| 11461 | karg x 1 0 |
| 11462 | karg x 2 1 |
| 11463 | e3 3942645760 31 0 1 |
| 11464 | else |
| 11465 | xha x 1 0 |
| 11466 | xha x 2 2 |
| 11467 | xrr 57 0 2 |
| 11468 | end |
| 11469 | sep = kfdjump 1 |
| 11470 | kfdload 0 4 40 4 |
| 11471 | kfdcmpv 0 2 |
| 11472 | kfdtrap 1 |
| 11473 | wshape = or shl ulong 56 32 shl ulong 2248 48 |
| 11474 | kbind x 1 8 3 or kshape 255 0 0 or 16777216 wshape z |
| 11475 | rshape = or shl ulong 128 32 shl ulong 2176 48 |
| 11476 | kbind x 2 16 3 or kshape 255 0 0 or 16777216 rshape z |
| 11477 | kfdpatch sep |
| 11478 | if eq get xtarget 0 0 |
| 11479 | karg x 1 0 |
| 11480 | karg x 2 1 |
| 11481 | e3 3942645760 31 0 1 |
| 11482 | else |
| 11483 | xha x 1 0 |
| 11484 | xha x 2 2 |
| 11485 | xrr 57 0 2 |
| 11486 | end |
| 11487 | obj = kfdjump 0 |
| 11488 | kbind x 1 8 3 kshape 255 8 0 z |
| 11489 | kbind x 2 16 3 kshape 255 8 0 z |
| 11490 | kfdpatch obj |
| 11491 | kbind x 3 56 3 kshape 64 8 1 z |
| 11492 | kbind x 4 72 3 kshape 80 4 1 z |
| 11493 | end |
| 11494 | if eq q 3223866134 |
| 11495 | note USERPTR would smuggle an address through mmap_offset; never admit it. |
| 11496 | kfdload 0 4 36 4 |
| 11497 | if eq get xtarget 0 0 |
| 11498 | matconst 16 4 |
| 11499 | e3 2315255808 0 0 16 |
| 11500 | else |
| 11501 | ximm 11 4 |
| 11502 | xrr 33 0 11 |
| 11503 | end |
| 11504 | kfdcmpv 0 0 |
| 11505 | kfdtrap 1 |
| 11506 | kbind x 0 0 0 kshape 8 8 0 z |
| 11507 | end |
| 11508 | if eq q 3222293265 |
| 11509 | kbind x 0 0 0 kshape 255 1 0 z |
| 11510 | end |
| 11511 | if eq get xtarget 0 0 |
| 11512 | karg x 9 0 |
| 11513 | matconst 1 q |
| 11514 | mimmed 2432696320 2 31 0 |
| 11515 | hsys 29 |
| 11516 | else |
| 11517 | xha x 9 7 |
| 11518 | ximm 6 q |
| 11519 | xrr 137 2 4 |
| 11520 | xhcall 16 |
| 11521 | end |
| 11522 | kfdload 3 4 z 8 |
| 11523 | for i ulong div n 8 |
| 11524 | if not kptr q mul i 8 |
| 11525 | kfdload 1 4 mul i 8 8 |
| 11526 | kfdstore 1 3 mul i 8 |
| 11527 | end |
| 11528 | end |
| 11529 | if eq get xtarget 0 0 |
| 11530 | spadd add z 176 |
| 11531 | hreturn dst x |
| 11532 | else |
| 11533 | xhdone dst x add z 176 |
| 11534 | end |
| 11535 | end |
| 11536 | |
| 11537 | fn hostval c ulong dst ulong to void |
| 11538 | note A native object takes the OM-2 function-mode host subset below (files, identity, clocks), save, |
| 11539 | note inline svc, restore, its pushes charged to the object's stack record (spsub). The device words |
| 11540 | note 166..177 keep error 9: their table lives in the caller's runtime context, which the module linker's |
| 11541 | note program wrapper does not set up. |
| 11542 | if and ne get objmode 0 0 and ge c 166 le c 177 |
| 11543 | note d2site 174|hostval: word or declaration in a place that does not allow it; condition if and ne get objmode 0 0 and ge c 166 le c 177 |
| 11544 | put d2site 0 174 |
| 11545 | fail 9 |
| 11546 | end |
| 11547 | if eq get xtarget 0 1 |
| 11548 | if and ge c 228 le c 232 |
| 11549 | if eq get progmode 0 0 |
| 11550 | note d2site 175|hostval: word or declaration in a place that does not allow it; condition if eq get progmode 0 0 |
| 11551 | put d2site 0 175 |
| 11552 | fail 9 |
| 11553 | end |
| 11554 | note d2site 176|hostval: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if and ge c 228 le c 232 |
| 11555 | put d2site 0 176 |
| 11556 | fail 25 |
| 11557 | end |
| 11558 | xhost c dst |
| 11559 | ret |
| 11560 | end |
| 11561 | if ne get xtarget 0 0 |
| 11562 | note d2site 177|hostval: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if ne get xtarget 0 0 |
| 11563 | put d2site 0 177 |
| 11564 | fail 25 |
| 11565 | end |
| 11566 | note target a64efi has no Linux beneath it: every host word is error 25 (the fw words are not host words). |
| 11567 | if ne get xefa 0 0 |
| 11568 | note d2site 178|hostval: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if ne get xefa 0 0 |
| 11569 | put d2site 0 178 |
| 11570 | fail 25 |
| 11571 | end |
| 11572 | note Function mode (no program image: no argv in x27, no x28 stack floor, no globals) refuses host |
| 11573 | note words with error 9, except in an OM-2 unit the file and identity subset that needs none of the |
| 11574 | note image: fclose 100, fopen 110, fstat 117, stat 140, getuid 145, geteuid 146, getgid 147, getegid 148, |
| 11575 | note lstat 149 (OMEGESE.md 10, spec/omegese-om2.md); the clocks monons 109, realns 130 and sleepns 120; |
| 11576 | note and the device subset devctl 166, mapnew 167, mapdrop 168, mapread 169, mapwrite 170, devcall 171, |
| 11577 | note uvmctl 172, mapaddr 173, mapget 174, mapset 175, maphold 176 and mapbind 177. Fixed replacement |
| 11578 | note is only over a whole live PROT_NONE reservation owned by this table. Each is save, inline svc, |
| 11579 | note restore; x7 and x19..x28 are never written. Function-mode table entry31 points at a 32-byte |
| 11580 | note header (capacity1..4098, generation base, generation limit, reserved) then capacity32-byte slots. |
| 11581 | note Handles use13slot bits; program mode retains its raw128slots and8slot-bit handles. |
| 11582 | if eq get progmode 0 0 |
| 11583 | if eq get om2 0 0 |
| 11584 | note d2site 179|hostval: word or declaration in a place that does not allow it; condition if eq get om2 0 0 |
| 11585 | put d2site 0 179 |
| 11586 | fail 9 |
| 11587 | end |
| 11588 | ok = ulong 0 |
| 11589 | if or or eq c 100 eq c 110 or eq c 117 eq c 140 |
| 11590 | ok = ulong 1 |
| 11591 | end |
| 11592 | if and ge c 145 le c 149 |
| 11593 | ok = ulong 1 |
| 11594 | end |
| 11595 | if or or eq c 109 eq c 120 eq c 130 |
| 11596 | ok = ulong 1 |
| 11597 | end |
| 11598 | if and ge c 166 le c 177 |
| 11599 | ok = ulong 1 |
| 11600 | end |
| 11601 | if eq ok 0 |
| 11602 | note d2site 180|hostval: word or declaration in a place that does not allow it; condition if eq ok 0 |
| 11603 | put d2site 0 180 |
| 11604 | fail 9 |
| 11605 | end |
| 11606 | end |
| 11607 | eff_rec c |
| 11608 | x = mul get depth 0 32 |
| 11609 | put a_ar add get a_rb 77 add x 7 get nslot 0 |
| 11610 | if and ge c 241 le c 243 |
| 11611 | mtinit |
| 11612 | if eq c 241 |
| 11613 | kctl dst x |
| 11614 | else |
| 11615 | mnew c dst x |
| 11616 | end |
| 11617 | ret |
| 11618 | end |
| 11619 | note VFIO words are program-only. These IDs are disjoint from efi178, qty223 and peername224. |
| 11620 | if and ge c 228 le c 232 |
| 11621 | if eq get fdtab 0 0 |
| 11622 | fdpool = get poolb 0 |
| 11623 | if gt fdpool 1073739776 |
| 11624 | note d2site 181|hostval: size capacity; condition if gt fdpool 1073739776 |
| 11625 | put d2site 0 181 |
| 11626 | fail 23 |
| 11627 | end |
| 11628 | put fdtab 0 add 276824064 fdpool |
| 11629 | put poolb 0 add fdpool 2048 |
| 11630 | end |
| 11631 | if eq c 228 |
| 11632 | note VFIO container, group and device requests: _IO(';', 100 + k) from linux/vfio.h, exact allowlist and |
| 11633 | note shapes. GET_API_VERSION 15204 takes no argument (n 0). DEVICE_RESET 15215 is not allowed: W0 never |
| 11634 | note resets the device from Omega (Drake: W0a only, no FLR). CHECK_EXTENSION 15205 and |
| 11635 | note SET_IOMMU 15206 pass the 4-byte little-endian value in the span; SET_IOMMU accepts only TYPE1v2 (3). |
| 11636 | note GROUP_SET_CONTAINER 15208 points at a 4-byte fd. GROUP_GET_STATUS 15207 (8), DEVICE_GET_INFO 15211 |
| 11637 | note (24) and DEVICE_GET_REGION_INFO 15212 (32) point at the span after the compiler itself stores |
| 11638 | note argsz = n, so the kernel copies at most n bytes. GROUP_GET_DEVICE_FD 15210 passes a private zero- |
| 11639 | note terminated copy of a non-empty span (at most 4095 bytes, no embedded zero). |
| 11640 | note IOMMU_MAP_DMA 15217 (32) takes an Omega mapping handle in the vaddr field (bytes 8..15), never an |
| 11641 | note address: the compiler checks the handle like mapget, requires a read/write mapping and flags exactly |
| 11642 | note READ|WRITE (3), then stores the mapping's own base address and whole length into vaddr and size. |
| 11643 | note The caller chooses only the IOVA (bytes 16..23). IOMMU_UNMAP_DMA 15218 (24) requires flags 0 (no |
| 11644 | note dirty bitmap, no ALL, no VADDR) and unmaps only the caller's IOVA range in its own container. |
| 11645 | mtinit |
| 11646 | harg x 4 8 |
| 11647 | harg x 2 4 |
| 11648 | if ne get a_ar add get a_rb 77 add x 12 3 |
| 11649 | note d2site 182|hostval: word or declaration in a place that does not allow it; condition if ne get a_ar add get a_rb 77 add x 12 3 |
| 11650 | put d2site 0 182 |
| 11651 | fail 9 |
| 11652 | end |
| 11653 | q = get a_ar add get a_rb 77 add x 13 |
| 11654 | if eq q 15210 |
| 11655 | e = harray x 0 |
| 11656 | hpathcp x |
| 11657 | emit 4043309247 |
| 11658 | trapc 0 3 |
| 11659 | fdscan 0 |
| 11660 | mimmed 4043309056 31 12 0 |
| 11661 | fdfound = mbranch 1 |
| 11662 | matconst 0 18446744073709551592 |
| 11663 | full = get oc 0 |
| 11664 | emit 335544320 |
| 11665 | patch19 fdfound get oc 0 |
| 11666 | hload x 4 3 |
| 11667 | hcopy |
| 11668 | e3 2852126720 0 31 3 |
| 11669 | e3 2852126720 2 31 1 |
| 11670 | matconst 1 15210 |
| 11671 | hsys 29 |
| 11672 | fdrecord 1 |
| 11673 | spadd 4096 |
| 11674 | patch26 full get oc 0 |
| 11675 | hreturn dst x |
| 11676 | ret |
| 11677 | end |
| 11678 | n = ulong 99 |
| 11679 | if eq q 15204 |
| 11680 | n = ulong 0 |
| 11681 | end |
| 11682 | if or or eq q 15205 eq q 15206 eq q 15208 |
| 11683 | n = ulong 4 |
| 11684 | end |
| 11685 | if eq q 15207 |
| 11686 | n = ulong 8 |
| 11687 | end |
| 11688 | if eq q 15211 |
| 11689 | n = ulong 24 |
| 11690 | end |
| 11691 | if eq q 15212 |
| 11692 | n = ulong 32 |
| 11693 | end |
| 11694 | if eq q 15217 |
| 11695 | n = ulong 32 |
| 11696 | end |
| 11697 | if eq q 15218 |
| 11698 | n = ulong 24 |
| 11699 | end |
| 11700 | if eq n 99 |
| 11701 | note d2site 183|hostval: word or declaration in a place that does not allow it; condition if eq n 99 |
| 11702 | put d2site 0 183 |
| 11703 | fail 9 |
| 11704 | end |
| 11705 | put a_ar add get a_rb 77 add x 23 n |
| 11706 | e = harray x 1 |
| 11707 | t = alloc |
| 11708 | matconst t get a_ar add get a_rb 77 add x 23 |
| 11709 | e3 3942645760 31 get a_ar add get a_rb 77 add x 22 t |
| 11710 | trapc 1 3 |
| 11711 | save |
| 11712 | hload x 4 0 |
| 11713 | matconst 1 q |
| 11714 | basearg 2 e |
| 11715 | loadarg 16 1 get a_ar add get a_rb 77 add x 21 |
| 11716 | e3 2332033024 2 2 16 |
| 11717 | if ge n 8 |
| 11718 | matconst 16 n |
| 11719 | mimmed 3103784960 16 2 0 |
| 11720 | end |
| 11721 | if eq q 15217 |
| 11722 | mimmed 3107979264 15 2 1 |
| 11723 | mimmed 4043309056 31 15 3 |
| 11724 | trapc 1 3 |
| 11725 | mload 10 2 1 |
| 11726 | mcheck |
| 11727 | mload 15 11 3 |
| 11728 | mimmed 4043309056 31 15 3 |
| 11729 | trapc 1 3 |
| 11730 | mstore 13 2 1 |
| 11731 | mstore 12 2 3 |
| 11732 | end |
| 11733 | if eq q 15218 |
| 11734 | mimmed 3107979264 15 2 1 |
| 11735 | mimmed 4043309056 31 15 0 |
| 11736 | trapc 1 3 |
| 11737 | end |
| 11738 | if or eq q 15205 eq q 15206 |
| 11739 | mimmed 3107979264 2 2 0 |
| 11740 | end |
| 11741 | if eq q 15206 |
| 11742 | mimmed 4043309056 31 2 3 |
| 11743 | trapc 1 3 |
| 11744 | end |
| 11745 | if eq n 0 |
| 11746 | matconst 2 0 |
| 11747 | end |
| 11748 | hsys 29 |
| 11749 | hreturn dst x |
| 11750 | end |
| 11751 | if or eq c 229 eq c 230 |
| 11752 | mtinit |
| 11753 | mnew c dst x |
| 11754 | end |
| 11755 | if eq c 231 |
| 11756 | note Fixed eventfd flags: CLOEXEC prevents exec leakage; NONBLOCK makes drained reads safe. |
| 11757 | harg x 0 4 |
| 11758 | save |
| 11759 | fdscan 0 |
| 11760 | mimmed 4043309056 31 12 0 |
| 11761 | fdfound = mbranch 1 |
| 11762 | matconst 0 18446744073709551592 |
| 11763 | full = get oc 0 |
| 11764 | emit 335544320 |
| 11765 | patch19 fdfound get oc 0 |
| 11766 | hload x 0 0 |
| 11767 | matconst 1 526336 |
| 11768 | hsys 19 |
| 11769 | fdrecord 2 |
| 11770 | patch26 full get oc 0 |
| 11771 | hreturn dst x |
| 11772 | end |
| 11773 | if eq c 232 |
| 11774 | note GET_IRQ_INFO and SET_IRQS only; caller bytes cannot introduce pointers or arbitrary ioctls. |
| 11775 | harg x 4 8 |
| 11776 | harg x 2 4 |
| 11777 | if ne get a_ar add get a_rb 77 add x 12 3 |
| 11778 | note d2site 184|hostval: word or declaration in a place that does not allow it; condition if ne get a_ar add get a_rb 77 add x 12 3 |
| 11779 | put d2site 0 184 |
| 11780 | fail 9 |
| 11781 | end |
| 11782 | q = get a_ar add get a_rb 77 add x 13 |
| 11783 | if and ne q 15213 ne q 15214 |
| 11784 | note d2site 185|hostval: word or declaration in a place that does not allow it; condition if and ne q 15213 ne q 15214 |
| 11785 | put d2site 0 185 |
| 11786 | fail 9 |
| 11787 | end |
| 11788 | e = harray x 1 |
| 11789 | save |
| 11790 | hload x 4 10 |
| 11791 | fdcheck 1 |
| 11792 | basearg 2 e |
| 11793 | loadarg 16 1 get a_ar add get a_rb 77 add x 21 |
| 11794 | e3 2332033024 2 2 16 |
| 11795 | loadarg 3 1 get a_ar add get a_rb 77 add x 22 |
| 11796 | if eq q 15213 |
| 11797 | mimmed 4043309056 31 3 16 |
| 11798 | trapc 1 3 |
| 11799 | else |
| 11800 | mimmed 4043309056 31 3 20 |
| 11801 | trapc 3 3 |
| 11802 | mimmed 4043309056 31 3 276 |
| 11803 | trapc 8 3 |
| 11804 | end |
| 11805 | mimmed 3107979264 4 2 0 |
| 11806 | e3 3942645760 31 4 3 |
| 11807 | trapc 1 3 |
| 11808 | if eq q 15214 |
| 11809 | mimmed 3107979264 5 2 4 |
| 11810 | mimmed 4043309056 31 5 64 |
| 11811 | trapc 8 3 |
| 11812 | mimmed 3107979264 6 2 3 |
| 11813 | matconst 7 4294967295 |
| 11814 | e3 3405774848 7 7 5 |
| 11815 | e3 3942645760 31 6 7 |
| 11816 | trapc 8 3 |
| 11817 | mimmed 3107979264 4 2 1 |
| 11818 | mimmed 4043309056 31 4 36 |
| 11819 | event = mbranch 0 |
| 11820 | mimmed 4043309056 31 3 20 |
| 11821 | trapc 1 3 |
| 11822 | mimmed 4043309056 31 4 33 |
| 11823 | disable = mbranch 0 |
| 11824 | note DATA_NONE MASK or UNMASK. Linux checks the device's MASKABLE capability. |
| 11825 | mimmed 4043309056 31 4 9 |
| 11826 | mask = mbranch 0 |
| 11827 | mimmed 4043309056 31 4 17 |
| 11828 | trapc 1 3 |
| 11829 | patch19 mask get oc 0 |
| 11830 | mimmed 4043309056 31 5 0 |
| 11831 | trapc 0 3 |
| 11832 | done = get oc 0 |
| 11833 | emit 335544320 |
| 11834 | patch19 disable get oc 0 |
| 11835 | mimmed 4043309056 31 5 0 |
| 11836 | trapc 1 3 |
| 11837 | mimmed 4043309056 31 6 0 |
| 11838 | trapc 1 3 |
| 11839 | disdone = get oc 0 |
| 11840 | emit 335544320 |
| 11841 | patch19 event get oc 0 |
| 11842 | mimmed 4043309056 31 5 0 |
| 11843 | trapc 0 3 |
| 11844 | matconst 7 4 |
| 11845 | e3 2600500224 7 5 7 |
| 11846 | mimmed 2432696320 7 7 20 |
| 11847 | e3 3942645760 31 7 3 |
| 11848 | trapc 1 3 |
| 11849 | mimmed 2432696320 6 2 20 |
| 11850 | head = get oc 0 |
| 11851 | mimmed 3107979264 10 6 0 |
| 11852 | matconst 7 4294967295 |
| 11853 | e3 3942645760 31 10 7 |
| 11854 | skip = mbranch 0 |
| 11855 | fdcheck 2 |
| 11856 | patch19 skip get oc 0 |
| 11857 | mimmed 2432696320 6 6 4 |
| 11858 | mimmed 3506438144 5 5 1 |
| 11859 | mimmed 4043309056 31 5 0 |
| 11860 | again = mbranch 1 |
| 11861 | patch19 again head |
| 11862 | patch26 done get oc 0 |
| 11863 | patch26 disdone get oc 0 |
| 11864 | end |
| 11865 | hload x 4 0 |
| 11866 | matconst 1 q |
| 11867 | hsys 29 |
| 11868 | hreturn dst x |
| 11869 | end |
| 11870 | ret |
| 11871 | end |
| 11872 | if eq c 197 |
| 11873 | hscalar c dst x |
| 11874 | ret |
| 11875 | end |
| 11876 | note execpure 198 and execenv 233 are dispatched here, before the ge c 173 mapped-memory range below |
| 11877 | note would claim them. |
| 11878 | if or eq c 198 eq c 233 |
| 11879 | hpack c dst x |
| 11880 | ret |
| 11881 | end |
| 11882 | if eq c 220 |
| 11883 | hpeercr dst x |
| 11884 | ret |
| 11885 | end |
| 11886 | if eq c 235 |
| 11887 | hprlim dst x |
| 11888 | ret |
| 11889 | end |
| 11890 | if and ge c 236 le c 238 |
| 11891 | hsched c dst x |
| 11892 | ret |
| 11893 | end |
| 11894 | if or eq c 239 eq c 240 |
| 11895 | hscalar c dst x |
| 11896 | ret |
| 11897 | end |
| 11898 | if eq c 221 |
| 11899 | hpollfds dst x |
| 11900 | ret |
| 11901 | end |
| 11902 | if eq c 222 |
| 11903 | hsendmsg dst x |
| 11904 | ret |
| 11905 | end |
| 11906 | if eq c 224 |
| 11907 | hbuffer c dst x |
| 11908 | ret |
| 11909 | end |
| 11910 | if eq c 176 |
| 11911 | mtinit |
| 11912 | mnew c dst x |
| 11913 | ret |
| 11914 | end |
| 11915 | if eq c 177 |
| 11916 | mtinit |
| 11917 | mbind dst x |
| 11918 | ret |
| 11919 | end |
| 11920 | if ge c 173 |
| 11921 | mtinit |
| 11922 | mmapio c dst x |
| 11923 | ret |
| 11924 | end |
| 11925 | if eq c 172 |
| 11926 | note Linux UVM has unencoded commands. Exact allowlist and ABI580.173.02 byte sizes. |
| 11927 | put a_ar add get a_rb 77 add x 23 xhreq 172 x |
| 11928 | e = harray x 1 |
| 11929 | t = alloc |
| 11930 | matconst t get a_ar add get a_rb 77 add x 23 |
| 11931 | e3 3942645760 31 get a_ar add get a_rb 77 add x 22 t |
| 11932 | trapc 1 3 |
| 11933 | save |
| 11934 | hload x 4 0 |
| 11935 | hload x 2 1 |
| 11936 | basearg 2 e |
| 11937 | loadarg 16 1 get a_ar add get a_rb 77 add x 21 |
| 11938 | e3 2332033024 2 2 16 |
| 11939 | hsys 29 |
| 11940 | hreturn dst x |
| 11941 | ret |
| 11942 | end |
| 11943 | if eq c 171 |
| 11944 | hdevcall dst x |
| 11945 | ret |
| 11946 | end |
| 11947 | if ge c 167 |
| 11948 | mtinit |
| 11949 | if eq c 167 |
| 11950 | mnew c dst x |
| 11951 | ret |
| 11952 | end |
| 11953 | if eq c 168 |
| 11954 | harg x 0 9 |
| 11955 | save |
| 11956 | hload x 0 10 |
| 11957 | mcheck |
| 11958 | e3 2852126720 0 31 13 |
| 11959 | e3 2852126720 1 31 12 |
| 11960 | hsys 215 |
| 11961 | mimmed 4043309056 31 0 0 |
| 11962 | failed = mbranch 1 |
| 11963 | mstore 31 11 0 |
| 11964 | mstore 31 11 1 |
| 11965 | mstore 31 11 3 |
| 11966 | patch19 failed get oc 0 |
| 11967 | hreturn dst x |
| 11968 | ret |
| 11969 | end |
| 11970 | mcopy c dst x |
| 11971 | ret |
| 11972 | end |
| 11973 | if eq c 166 |
| 11974 | note Same bounded ioctl contract as L605 src/device/omc.om at 0dee699. |
| 11975 | note Compose with native host words instead of maintaining a second compiler. |
| 11976 | note Only literal FIONREAD, encoded read/write NVRM F, or five exact aien-gpu ABI1 A requests. |
| 11977 | put a_ar add get a_rb 77 add x 23 xhreq 166 x |
| 11978 | e = harray x 1 |
| 11979 | t = alloc |
| 11980 | matconst t get a_ar add get a_rb 77 add x 23 |
| 11981 | e3 3942645760 31 get a_ar add get a_rb 77 add x 22 t |
| 11982 | trapc 1 3 |
| 11983 | save |
| 11984 | hload x 4 0 |
| 11985 | hload x 2 1 |
| 11986 | basearg 2 e |
| 11987 | loadarg 16 1 get a_ar add get a_rb 77 add x 21 |
| 11988 | e3 2332033024 2 2 16 |
| 11989 | hsys 29 |
| 11990 | hreturn dst x |
| 11991 | ret |
| 11992 | end |
| 11993 | if eq c 132 |
| 11994 | e = harray x 1 |
| 11995 | save |
| 11996 | basearg 0 e |
| 11997 | loadarg 16 1 get a_ar add get a_rb 77 add x 21 |
| 11998 | e3 2332033024 0 0 16 |
| 11999 | loadarg 1 1 get a_ar add get a_rb 77 add x 22 |
| 12000 | hsys 17 |
| 12001 | hreturn dst x |
| 12002 | ret |
| 12003 | end |
| 12004 | if eq c 133 |
| 12005 | hreadlnk dst x |
| 12006 | ret |
| 12007 | end |
| 12008 | if eq c 134 |
| 12009 | hsockopt dst x |
| 12010 | ret |
| 12011 | end |
| 12012 | if eq c 135 |
| 12013 | note random A off n flags: Linux getrandom into a writable byte slice. Returns the bytes written or |
| 12014 | note minus the Linux error number. flags follows getrandom(2): 0 blocks until the pool is ready, |
| 12015 | note 1 (GRND_NONBLOCK) returns -EAGAIN instead, 2 (GRND_INSECURE) may return non-cryptographic bytes. |
| 12016 | e = harray x 1 |
| 12017 | harg x 2 8 |
| 12018 | save |
| 12019 | basearg 0 e |
| 12020 | loadarg 16 1 get a_ar add get a_rb 77 add x 21 |
| 12021 | e3 2332033024 0 0 16 |
| 12022 | loadarg 1 1 get a_ar add get a_rb 77 add x 22 |
| 12023 | hload x 2 2 |
| 12024 | hsys 278 |
| 12025 | hreturn dst x |
| 12026 | ret |
| 12027 | end |
| 12028 | if or eq c 109 eq c 130 |
| 12029 | hclock c dst x |
| 12030 | ret |
| 12031 | end |
| 12032 | if or and ge c 113 le c 119 eq c 131 |
| 12033 | hbuffer c dst x |
| 12034 | ret |
| 12035 | end |
| 12036 | if eq c 120 |
| 12037 | harg x 0 9 |
| 12038 | save |
| 12039 | hload x 0 2 |
| 12040 | emit 4043309151 |
| 12041 | trapc 11 3 |
| 12042 | spsub 16 |
| 12043 | stkchk |
| 12044 | matconst 3 1000000000 |
| 12045 | e3 2596276224 4 2 3 |
| 12046 | note MSUB x5,x4,x3,x2 gives the subsecond remainder. |
| 12047 | emit 2600700037 |
| 12048 | emit 4177527780 |
| 12049 | emit 4177528805 |
| 12050 | emit 2432697312 |
| 12051 | matconst 1 0 |
| 12052 | hsys 101 |
| 12053 | spadd 16 |
| 12054 | hreturn dst x |
| 12055 | ret |
| 12056 | end |
| 12057 | if eq c 123 |
| 12058 | hwaitio dst x |
| 12059 | ret |
| 12060 | end |
| 12061 | if or or or eq c 124 eq c 125 eq c 141 eq c 142 |
| 12062 | hpack c dst x |
| 12063 | ret |
| 12064 | end |
| 12065 | if or or or or or or eq c 126 eq c 138 eq c 143 eq c 144 eq c 150 eq c 151 eq c 157 |
| 12066 | hpath c dst x |
| 12067 | ret |
| 12068 | end |
| 12069 | if eq c 140 |
| 12070 | hstat 140 dst x |
| 12071 | ret |
| 12072 | end |
| 12073 | if eq c 149 |
| 12074 | hstat 149 dst x |
| 12075 | ret |
| 12076 | end |
| 12077 | if and ge c 145 le c 148 |
| 12078 | hscalar c dst x |
| 12079 | ret |
| 12080 | end |
| 12081 | if or or or eq c 153 eq c 154 eq c 155 eq c 156 |
| 12082 | hscalar c dst x |
| 12083 | ret |
| 12084 | end |
| 12085 | if and ge c 158 le c 160 |
| 12086 | hscalar c dst x |
| 12087 | ret |
| 12088 | end |
| 12089 | if or eq c 161 eq c 162 |
| 12090 | hpread c dst x |
| 12091 | ret |
| 12092 | end |
| 12093 | if and ge c 163 le c 165 |
| 12094 | hscalar c dst x |
| 12095 | ret |
| 12096 | end |
| 12097 | if or or eq c 127 eq c 129 eq c 139 |
| 12098 | hscalar c dst x |
| 12099 | ret |
| 12100 | end |
| 12101 | if eq c 128 |
| 12102 | e = harray x 1 |
| 12103 | harg x 2 8 |
| 12104 | tmp = alloc |
| 12105 | matconst tmp 8 |
| 12106 | e3 3942645760 31 get a_ar add get a_rb 77 add x 22 tmp |
| 12107 | trapc 3 3 |
| 12108 | save |
| 12109 | basearg 0 e |
| 12110 | loadarg 16 1 get a_ar add get a_rb 77 add x 21 |
| 12111 | e3 2332033024 0 0 16 |
| 12112 | hload x 2 1 |
| 12113 | hsys 59 |
| 12114 | hreturn dst x |
| 12115 | ret |
| 12116 | end |
| 12117 | if ge c 121 |
| 12118 | put hostargs 0 1 |
| 12119 | hargs c dst x |
| 12120 | ret |
| 12121 | end |
| 12122 | if ge c 110 |
| 12123 | hpath c dst x |
| 12124 | ret |
| 12125 | end |
| 12126 | hscalar c dst x |
| 12127 | end |
| 12128 | |
| 12129 | note ======== rdval: read one value (om4 VAL, VALTOK, CALL and the VT_ parts, one self-recursive |
| 12130 | note function because a function calls only earlier functions or itself) ======== |
| 12131 | note mode 0: read the first word; 1: the first word is the current token; 2: a call of function fe (index |
| 12132 | note + 1), its arguments still to read. exp the expected type (0 none), dst the destination register (255 |
| 12133 | note none). Out: rk kind (1 register, 2 bare number, 3 typed number, 4 flags, 9 a float in a twin, only when |
| 12134 | note asked for by fpw), rv register / number / condition, rt type (for a bare number: 1 when written as 2^63 |
| 12135 | note or more). Only the outermost op writes the destination. Every value nests one level deeper (at most |
| 12136 | note 32768, bounded by omc's own stack, error 14); a call does not. |
| 12137 | fn rdval mode ulong exp ulong dst ulong fe ulong to void |
| 12138 | note fwtake: rdval's entry: keep the caller's fpw request for this depth (none on x86, which has no twins) |
| 12139 | if eq get xtarget 0 0 |
| 12140 | a_p 78 add get depth 0 1 get fpw 0 |
| 12141 | else |
| 12142 | put a_ar add get a_rb 78 add get depth 0 1 0 |
| 12143 | end |
| 12144 | put fpw 0 0 |
| 12145 | put dexp 0 1 |
| 12146 | if eq mode 2 |
| 12147 | if ne get cpure 0 0 |
| 12148 | note d2site 186|rdval: contract syntax misplaced or not supported here (IR mode included); condition if ne get cpure 0 0 |
| 12149 | put d2site 0 186 |
| 12150 | fail 30 |
| 12151 | end |
| 12152 | if ne get om2 0 0 |
| 12153 | if ne uchar get a_ar add get a_rb 27 sub fe 1 0 |
| 12154 | inl_call fe dst |
| 12155 | ret |
| 12156 | end |
| 12157 | end |
| 12158 | cb = add mul get depth 0 32 8 |
| 12159 | a_p 77 add cb 18 ulong a_gu 24 sub fe 1 |
| 12160 | put a_ar add get a_rb 77 add cb 19 get nslot 0 |
| 12161 | if eq get progmode 0 0 |
| 12162 | if eq get curfn 0 fe |
| 12163 | note d2site 187|rdval: word or declaration in a place that does not allow it; condition if eq get curfn 0 fe |
| 12164 | put d2site 0 187 |
| 12165 | fail 9 |
| 12166 | end |
| 12167 | end |
| 12168 | i = ulong 0 |
| 12169 | while lt i get a_ar add get a_rb 77 add cb 18 |
| 12170 | p = add mul sub fe 1 6 i |
| 12171 | if eq uchar get a_ar add get a_rb 37 p 0 |
| 12172 | if ne isfloat ulong uchar get a_ar add get a_rb 35 p 0 |
| 12173 | put fpw 0 1 |
| 12174 | end |
| 12175 | rdval 0 ulong uchar get a_ar add get a_rb 35 p 255 0 |
| 12176 | ca_scal p add cb mul i 3 |
| 12177 | else |
| 12178 | if ge uchar get a_ar add get a_rb 37 p 6 |
| 12179 | ca_st fe i cb |
| 12180 | else |
| 12181 | ca_arr fe i cb |
| 12182 | fz_arg get rt 0 |
| 12183 | end |
| 12184 | end |
| 12185 | i = add i 1 |
| 12186 | end |
| 12187 | ca_end fe dst cb |
| 12188 | ret |
| 12189 | end |
| 12190 | if eq mode 0 |
| 12191 | tok |
| 12192 | end |
| 12193 | if ne get cpure 0 0 |
| 12194 | cp_token |
| 12195 | end |
| 12196 | put depth 0 add get depth 0 1 |
| 12197 | note value nesting: the per-depth cells (fr, fwv, ul_k, ul_v) are arena group 18 and grow. What bounds the |
| 12198 | note depth is omc's own stack: rdval recurses once per level, and omc, a program, has the fixed 8 MiB stack |
| 12199 | note pool of program mode (OMEGESE 9.6); past it omc would trap 6 with no line. Measured 2026-11-11 (omc |
| 12200 | note b985535d): the deepest frame per level is 144 bytes (nested calls; 64 for get, 80 for and, 96 in IR |
| 12201 | note mode), trap 6 from 58252 nested calls. Allowing 256 bytes per level, 8388608 / 256 = 32768 levels is |
| 12202 | note the deepest value omc reads; deeper is error 14 on its line, a clean refusal before the stack ends. |
| 12203 | note seed/omc/gate-nocaps.sh compiles every measured shape at 32768 deep, so a frame that grows is noticed. |
| 12204 | if gt get depth 0 32768 |
| 12205 | note d2site 188|rdval: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if gt get depth 0 32768 |
| 12206 | put d2site 0 188 |
| 12207 | fail 14 |
| 12208 | end |
| 12209 | if ge add get depth 0 1 get a_gp 18 |
| 12210 | a_need 18 add get depth 0 1 |
| 12211 | end |
| 12212 | if or eq get tk 0 0 eq get tk 0 3 |
| 12213 | note d2site 189|rdval: the line ends where a word or value is needed; condition if or eq get tk 0 0 eq get tk 0 3 |
| 12214 | put d2site 0 189 |
| 12215 | fail 4 |
| 12216 | end |
| 12217 | if eq get tk 0 4 |
| 12218 | note d2site 190|rdval: syntax: unknown or misplaced word; condition if eq get tk 0 4 |
| 12219 | put d2site 0 190 |
| 12220 | fail 16 |
| 12221 | end |
| 12222 | if eq get tk 0 5 |
| 12223 | if ne get irmode 0 0 |
| 12224 | note d2site 191|rdval: word or declaration in a place that does not allow it; condition if ne get irmode 0 0 |
| 12225 | put d2site 0 191 |
| 12226 | fail 9 |
| 12227 | end |
| 12228 | if ge exp 64 |
| 12229 | note d2site 192|rdval: type mismatch; condition if ge exp 64 |
| 12230 | put d2site 0 192 |
| 12231 | fail 7 |
| 12232 | end |
| 12233 | fparse get ts 0 get tl 0 |
| 12234 | t = ulong 0 |
| 12235 | if eq get fsuf 0 0 |
| 12236 | if eq exp 0 |
| 12237 | vdone 6 add mul get ts 0 4294967296 get tl 0 ulong 0 |
| 12238 | ret |
| 12239 | end |
| 12240 | if eq isfloat exp 0 |
| 12241 | note d2site 193|rdval: type mismatch; condition if eq isfloat exp 0 |
| 12242 | put d2site 0 193 |
| 12243 | fail 7 |
| 12244 | end |
| 12245 | t = exp |
| 12246 | else |
| 12247 | t = ulong 10 |
| 12248 | if eq get fsuf 0 2 |
| 12249 | t = ulong 11 |
| 12250 | end |
| 12251 | if and ne exp 0 ne exp t |
| 12252 | note d2site 194|rdval: type mismatch; condition if and ne exp 0 ne exp t |
| 12253 | put d2site 0 194 |
| 12254 | fail 7 |
| 12255 | end |
| 12256 | end |
| 12257 | v = fbits t |
| 12258 | vdone 7 v t |
| 12259 | ret |
| 12260 | end |
| 12261 | if eq get tk 0 2 |
| 12262 | if eq exp 0 |
| 12263 | vdone 2 get tw 0 get tbig 0 |
| 12264 | ret |
| 12265 | end |
| 12266 | note an integer literal where a float is expected is the mixing OMEGESE 9.9 refuses (error 7); before |
| 12267 | note this it was stored as raw bits (f64 x = 1 held 0x1). The conversion f64 1 reads it with exp 0. |
| 12268 | if or ge exp 64 ne isfloat exp 0 |
| 12269 | note d2site 195|rdval: type mismatch; condition if or ge exp 64 ne isfloat exp 0 |
| 12270 | put d2site 0 195 |
| 12271 | fail 7 |
| 12272 | end |
| 12273 | range get tw 0 exp get tbig 0 |
| 12274 | vdone 3 get tw 0 exp |
| 12275 | ret |
| 12276 | end |
| 12277 | if gt get tl 0 8 |
| 12278 | f = findfn get tw 0 get tl 0 get ts 0 |
| 12279 | if eq f 0 |
| 12280 | if gt get tl 0 63 |
| 12281 | note d2site 196|rdval: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63 |
| 12282 | put d2site 0 196 |
| 12283 | unkfail 13 |
| 12284 | end |
| 12285 | else |
| 12286 | if eq uchar get a_ar add get a_rb 23 sub f 1 12 |
| 12287 | note d2site 197|rdval: type mismatch; condition if eq uchar get a_ar add get a_rb 23 sub f 1 12 |
| 12288 | put d2site 0 197 |
| 12289 | fail 7 |
| 12290 | end |
| 12291 | rdval 2 0 dst f |
| 12292 | vdec |
| 12293 | ret |
| 12294 | end |
| 12295 | end |
| 12296 | c = kw get tw 0 |
| 12297 | if ne get xefa 0 0 |
| 12298 | ca = kwa get tw 0 |
| 12299 | if eq ca 178 |
| 12300 | eff_rec 178 |
| 12301 | aefival dst |
| 12302 | ret |
| 12303 | end |
| 12304 | if ne ca 0 |
| 12305 | eff_rec ca |
| 12306 | afw ca dst |
| 12307 | ret |
| 12308 | end |
| 12309 | end |
| 12310 | if eq c 178 |
| 12311 | eff_rec 178 |
| 12312 | xefival dst |
| 12313 | ret |
| 12314 | end |
| 12315 | if eq c 0 |
| 12316 | if ne get cpure 0 0 |
| 12317 | if eq get tw 0 128009175786866 |
| 12318 | if eq get crkind 0 0 |
| 12319 | note d2site 198|rdval: contract syntax misplaced or not supported here (IR mode included); condition if eq get crkind 0 0 |
| 12320 | put d2site 0 198 |
| 12321 | fail 30 |
| 12322 | end |
| 12323 | vdone get crkind 0 get crval 0 get crtype 0 |
| 12324 | ret |
| 12325 | end |
| 12326 | end |
| 12327 | e = findname get tw 0 |
| 12328 | if ne e 0 |
| 12329 | if eq uchar get a_ar add get a_rb 7 sub e 1 9 |
| 12330 | ct = ulong uchar get a_ar add get a_rb 5 sub e 1 |
| 12331 | cv = get a_ar add get a_rb 8 sub e 1 |
| 12332 | if ne isfloat ct 0 |
| 12333 | vdone 7 cv ct |
| 12334 | else |
| 12335 | vdone 3 cv ct |
| 12336 | end |
| 12337 | ret |
| 12338 | end |
| 12339 | if ne uchar get a_ar add get a_rb 7 sub e 1 0 |
| 12340 | note d2site 199|rdval: type mismatch; condition if ne uchar get a_ar add get a_rb 7 sub e 1 0 |
| 12341 | put d2site 0 199 |
| 12342 | fail 7 |
| 12343 | end |
| 12344 | e1 = sub e 1 |
| 12345 | if ne uchar get a_ar add get a_rb 9 e1 0 |
| 12346 | nr = ulong uchar get a_ar add get a_rb 4 e1 |
| 12347 | if ne a_g 78 get depth 0 0 |
| 12348 | vdone 9 nr ulong uchar get a_ar add get a_rb 5 e1 |
| 12349 | else |
| 12350 | fv2x ulong a_gu 5 e1 vtw nr nr |
| 12351 | vdone 1 nr ulong uchar get a_ar add get a_rb 5 e1 |
| 12352 | end |
| 12353 | else |
| 12354 | vdone 1 ulong a_gu 4 e1 ulong a_gu 5 e1 |
| 12355 | end |
| 12356 | if ne get cpure 0 0 |
| 12357 | if ge get rt 0 10 |
| 12358 | note d2site 200|rdval: contract syntax misplaced or not supported here (IR mode included); condition if ge get rt 0 10 |
| 12359 | put d2site 0 200 |
| 12360 | fail 30 |
| 12361 | end |
| 12362 | end |
| 12363 | ret |
| 12364 | end |
| 12365 | f = findfn get tw 0 0 0 |
| 12366 | if eq f 0 |
| 12367 | note d2site 201|rdval: unknown name or field, or a word this mode does not provide; condition if eq f 0 |
| 12368 | put d2site 0 201 |
| 12369 | unkfail 3 |
| 12370 | end |
| 12371 | if eq uchar get a_ar add get a_rb 23 sub f 1 12 |
| 12372 | note d2site 202|rdval: type mismatch; condition if eq uchar get a_ar add get a_rb 23 sub f 1 12 |
| 12373 | put d2site 0 202 |
| 12374 | fail 7 |
| 12375 | end |
| 12376 | rdval 2 0 dst f |
| 12377 | vdec |
| 12378 | ret |
| 12379 | end |
| 12380 | if or eq c 88 eq c 89 |
| 12381 | t = ulong 10 |
| 12382 | if eq c 89 |
| 12383 | t = ulong 11 |
| 12384 | end |
| 12385 | rdval 0 0 255 0 |
| 12386 | if ge get rt 0 64 |
| 12387 | note d2site 203|rdval: type mismatch; condition if ge get rt 0 64 |
| 12388 | put d2site 0 203 |
| 12389 | fail 7 |
| 12390 | end |
| 12391 | if eq get rk 0 6 |
| 12392 | v = fspan t get rv 0 |
| 12393 | put rk 0 7 |
| 12394 | put rv 0 v |
| 12395 | put rt 0 t |
| 12396 | end |
| 12397 | if eq get rk 0 2 |
| 12398 | range get rv 0 9 get tbig 0 |
| 12399 | put rk 0 3 |
| 12400 | put rt 0 9 |
| 12401 | end |
| 12402 | if eq get rt 0 1 |
| 12403 | note d2site 204|rdval: type mismatch; condition if eq get rt 0 1 |
| 12404 | put d2site 0 204 |
| 12405 | fail 7 |
| 12406 | end |
| 12407 | fwreq |
| 12408 | vt_conv t |
| 12409 | vdec |
| 12410 | ret |
| 12411 | end |
| 12412 | if eq c 90 |
| 12413 | if ne get irmode 0 0 |
| 12414 | note d2site 205|rdval: word or declaration in a place that does not allow it; condition if ne get irmode 0 0 |
| 12415 | put d2site 0 205 |
| 12416 | fail 9 |
| 12417 | end |
| 12418 | tt = typeword |
| 12419 | rdval 0 0 255 0 |
| 12420 | if or eq get rk 0 6 eq get rk 0 2 |
| 12421 | note d2site 206|rdval: bare number without a type from its context; condition if or eq get rk 0 6 eq get rk 0 2 |
| 12422 | put d2site 0 206 |
| 12423 | fail 11 |
| 12424 | end |
| 12425 | ft = get rt 0 |
| 12426 | if eq ft 1 |
| 12427 | note d2site 207|rdval: type mismatch; condition if eq ft 1 |
| 12428 | put d2site 0 207 |
| 12429 | fail 7 |
| 12430 | end |
| 12431 | if or ge ft 64 ge tt 64 |
| 12432 | note d2site 208|rdval: type mismatch; condition if or ge ft 64 ge tt 64 |
| 12433 | put d2site 0 208 |
| 12434 | fail 7 |
| 12435 | end |
| 12436 | if ne twid ft twid tt |
| 12437 | note d2site 209|rdval: type mismatch; condition if ne twid ft twid tt |
| 12438 | put d2site 0 209 |
| 12439 | fail 7 |
| 12440 | end |
| 12441 | r = matreg get rk 0 get rv 0 ft |
| 12442 | note A register holds an 8/16/32-bit unsigned value and an f32 zero-extended (canon, FMOV W) and a signed |
| 12443 | note one sign-extended, so a bitcast that changes the extension extends the bits again for tt, into a new |
| 12444 | note register (a name's register keeps its value). f32 takes the uint form. |
| 12445 | if ne twid tt 64 |
| 12446 | if ne and ge ft 6 le ft 8 and ge tt 6 le tt 8 |
| 12447 | ct = tt |
| 12448 | if eq tt 10 |
| 12449 | ct = ulong 4 |
| 12450 | end |
| 12451 | rd = destreg dst |
| 12452 | canonto rd r ct |
| 12453 | r = rd |
| 12454 | end |
| 12455 | end |
| 12456 | put rk 0 1 |
| 12457 | put rv 0 r |
| 12458 | put rt 0 tt |
| 12459 | vdec |
| 12460 | ret |
| 12461 | end |
| 12462 | if or or or eq c 91 eq c 92 eq c 93 eq c 94 |
| 12463 | fwreq |
| 12464 | if or eq c 91 eq c 92 |
| 12465 | fintr c dst |
| 12466 | else |
| 12467 | fminmax c dst |
| 12468 | end |
| 12469 | ret |
| 12470 | end |
| 12471 | if eq c 227 |
| 12472 | fwreq |
| 12473 | ffma dst |
| 12474 | ret |
| 12475 | end |
| 12476 | if eq c 95 |
| 12477 | fsizeof dst |
| 12478 | ret |
| 12479 | end |
| 12480 | if eq c 96 |
| 12481 | foffset dst |
| 12482 | ret |
| 12483 | end |
| 12484 | if le sub c 1 8 |
| 12485 | tok |
| 12486 | if eq get tk 0 2 |
| 12487 | range get tw 0 c get tbig 0 |
| 12488 | vdone 3 get tw 0 c |
| 12489 | ret |
| 12490 | end |
| 12491 | rdval 1 0 255 0 |
| 12492 | if ge get rt 0 64 |
| 12493 | note d2site 210|rdval: type mismatch; condition if ge get rt 0 64 |
| 12494 | put d2site 0 210 |
| 12495 | fail 7 |
| 12496 | end |
| 12497 | if eq get rk 0 2 |
| 12498 | note d2site 211|rdval: bare number without a type from its context; condition if eq get rk 0 2 |
| 12499 | put d2site 0 211 |
| 12500 | fail 11 |
| 12501 | end |
| 12502 | vt_conv c |
| 12503 | vdec |
| 12504 | ret |
| 12505 | end |
| 12506 | if eq c 223 |
| 12507 | tok |
| 12508 | if eq get tk 0 2 |
| 12509 | range get tw 0 13 get tbig 0 |
| 12510 | vdone 3 get tw 0 13 |
| 12511 | ret |
| 12512 | end |
| 12513 | rdval 1 0 255 0 |
| 12514 | if eq get rk 0 6 |
| 12515 | note d2site 212|rdval: type mismatch; condition if eq get rk 0 6 |
| 12516 | put d2site 0 212 |
| 12517 | fail 7 |
| 12518 | end |
| 12519 | if ge get rt 0 64 |
| 12520 | note d2site 213|rdval: type mismatch; condition if ge get rt 0 64 |
| 12521 | put d2site 0 213 |
| 12522 | fail 7 |
| 12523 | end |
| 12524 | if eq get rk 0 2 |
| 12525 | note d2site 214|rdval: bare number without a type from its context; condition if eq get rk 0 2 |
| 12526 | put d2site 0 214 |
| 12527 | fail 11 |
| 12528 | end |
| 12529 | vt_conv 13 |
| 12530 | vdec |
| 12531 | ret |
| 12532 | end |
| 12533 | if eq c 74 |
| 12534 | put fpw 0 a_g 78 get depth 0 |
| 12535 | rdval 0 exp dst 0 |
| 12536 | tok |
| 12537 | if ne get tk 0 1 |
| 12538 | note d2site 215|rdval: syntax: unknown or misplaced word; condition if ne get tk 0 1 |
| 12539 | put d2site 0 215 |
| 12540 | fail 16 |
| 12541 | end |
| 12542 | if gt get tl 0 8 |
| 12543 | note d2site 216|rdval: syntax: unknown or misplaced word; condition if gt get tl 0 8 |
| 12544 | put d2site 0 216 |
| 12545 | fail 16 |
| 12546 | end |
| 12547 | if ne kw get tw 0 75 |
| 12548 | note d2site 217|rdval: syntax: unknown or misplaced word; condition if ne kw get tw 0 75 |
| 12549 | put d2site 0 217 |
| 12550 | fail 16 |
| 12551 | end |
| 12552 | vdec |
| 12553 | ret |
| 12554 | end |
| 12555 | if or eq c 77 eq c 193 |
| 12556 | note d2site 218|rdval: word or declaration in a place that does not allow it; condition if or eq c 77 eq c 193 |
| 12557 | put d2site 0 218 |
| 12558 | fail 9 |
| 12559 | end |
| 12560 | if or eq c 225 eq c 226 |
| 12561 | if or eq get progmode 0 0 ne get irmode 0 0 |
| 12562 | note d2site 219|rdval: word or declaration in a place that does not allow it; condition if or eq get progmode 0 0 ne get irmode 0 0 |
| 12563 | put d2site 0 219 |
| 12564 | fail 9 |
| 12565 | end |
| 12566 | x = mul get depth 0 32 |
| 12567 | sl = get nslot 0 |
| 12568 | note dit and scrub are emitted inline here, not in helper functions: om4 holds 512 functions and omc.om |
| 12569 | note uses 511 of them (seed/omc/size-history.tsv). |
| 12570 | if eq c 225 |
| 12571 | note dit: OM-2 `dit v` (program mode): v is int, 0 or 1, else trap 3. Sets PSTATE.DIT (Arm ARM |
| 12572 | note C5.2.4: DIT is bit 24 of the special-purpose register; MRS/MSR <Xt>, DIT have op0 3, op1 3, CRn 4, |
| 12573 | note CRm 2, op2 5) and gives the previous bit as a long 0 or 1. CMP Xv, #1 = SUBS XZR (C6.2.464); B.HI |
| 12574 | note trap 3; LSL X16, Xv, #24 = UBFM X16, Xv, #40, #39 (C6.2.487), taken before the destination is |
| 12575 | note written because the destination may be v's own register; MRS Xd, DIT (C6.2.287); MSR DIT, X16 |
| 12576 | note (C6.2.289); UBFX Xd, Xd, #24, #1 = UBFM Xd, Xd, #24, #24. Writes to PSTATE are in program order |
| 12577 | note without further synchronization (C5.1), so the next instruction already runs under the new bit. |
| 12578 | harg x 0 8 |
| 12579 | r = matreg a_g 77 add x 8 a_g 77 add x 9 8 |
| 12580 | emit or 4043310111 shl r 5 |
| 12581 | trapc 8 3 |
| 12582 | emit or 3546848272 shl r 5 |
| 12583 | put nslot 0 sl |
| 12584 | d = destreg dst |
| 12585 | emit or 3577430688 d |
| 12586 | emit 3575333552 |
| 12587 | emit or or 3545784320 shl d 5 d |
| 12588 | vdone 1 d 9 |
| 12589 | ret |
| 12590 | end |
| 12591 | note scrub: OM-2 `scrub n` (program mode): n is ulong, a multiple of 16 and at most 1048576, else trap 3. |
| 12592 | note TST Xn, #15 = ANDS XZR (C6.2.16, N 1 immr 0 imms 3); B.NE trap 3; X16 = 1048576; CMP Xn, X16 = |
| 12593 | note SUBS XZR (C6.2.465); B.HI trap 3. X16 = SP - n: SUB X16, SP, Xn, UXTX (C6.2.456); CMP X16, X28 |
| 12594 | note (C6.2.465); B.LO trap 6, before any store. Loop: CMP SP, X16 = SUBS XZR, SP, X16, UXTX (C6.2.463); |
| 12595 | note B.LS out; STP XZR, XZR, [X16], #16 (C6.2.414, post-index); B back (C6.2.35). Then MOVZ Xr, #0 |
| 12596 | note (C6.2.319) for every pool register at index npar + nslot or above (no live value: parameters, |
| 12597 | note locals and the held parts of the expression sit below), X16, and X7, X18-X26, X29, which program |
| 12598 | note mode never names; then MOVI Vd.2D, #0 (C7.2.247) for V0-V15 and for every twin V16+j except those |
| 12599 | note of a live slot j (below npar + nslot) whose value lives in its twin (vsl: an f32/f64 local name or a |
| 12600 | note held kind 9 float, as save stores it); a twin of a free slot or of a slot whose value is in its x |
| 12601 | note register holds nothing live. V0-V15 carry a float only inside one operation. Never touched: SP, X27 |
| 12602 | note (the Linux initial stack under args), X28 (the stack floor), X30 (the return address), the live pool |
| 12603 | note registers and live twins, NZCV, FPCR, FPSR, and the SVE P registers and FFR. Gives long 0. Pinned |
| 12604 | note registers (OM-2 global bases and lengths among X18..X26, pinset) are cleared with the rest, then set |
| 12605 | note back to their public constant values (pinlo), since later element accesses read them. |
| 12606 | harg x 0 5 |
| 12607 | r = matreg a_g 77 add x 8 a_g 77 add x 9 5 |
| 12608 | emit or 4064283679 shl r 5 |
| 12609 | trapc 1 3 |
| 12610 | matconst 16 1048576 |
| 12611 | emit or 3943694367 shl r 5 |
| 12612 | trapc 8 3 |
| 12613 | emit or 3407897584 shl r 16 |
| 12614 | emit 3944481311 |
| 12615 | trapc 3 6 |
| 12616 | top = get oc 0 |
| 12617 | emit 3945817087 |
| 12618 | at = get oc 0 |
| 12619 | emit 1409286153 |
| 12620 | emit 2827058719 |
| 12621 | back top |
| 12622 | patch19 at get oc 0 |
| 12623 | i = add get npar 0 sl |
| 12624 | while lt i 16 |
| 12625 | emit or 3531603968 poolc i |
| 12626 | i = add i 1 |
| 12627 | end |
| 12628 | emit 3531603984 |
| 12629 | emit 3531603975 |
| 12630 | note under target a64efi X18 is the platform's (UEFI 2.10 2.3.6): scrub leaves it and clears X19..X26 |
| 12631 | i = add 18 get xefa 0 |
| 12632 | while le i 26 |
| 12633 | emit or 3531603968 i |
| 12634 | i = add i 1 |
| 12635 | end |
| 12636 | emit 3531603997 |
| 12637 | at = add get npar 0 sl |
| 12638 | i = ulong 0 |
| 12639 | while lt i 32 |
| 12640 | top = and i 15 |
| 12641 | r = ulong get vsl top |
| 12642 | if or lt i 16 ge top at |
| 12643 | r = ulong 0 |
| 12644 | end |
| 12645 | if eq r 0 |
| 12646 | emit or 1862329344 i |
| 12647 | end |
| 12648 | i = add i 1 |
| 12649 | end |
| 12650 | pinlo |
| 12651 | put nslot 0 sl |
| 12652 | d = destreg dst |
| 12653 | matconst d 0 |
| 12654 | vdone 1 d 9 |
| 12655 | ret |
| 12656 | end |
| 12657 | if or or and ge c 100 le c 177 and ge c 197 le c 198 and ge c 220 le c 222 |
| 12658 | hostval c dst |
| 12659 | ret |
| 12660 | end |
| 12661 | if eq c 224 |
| 12662 | hostval c dst |
| 12663 | ret |
| 12664 | end |
| 12665 | if or or and ge c 228 le c 232 or eq c 233 eq c 235 and ge c 236 le c 243 |
| 12666 | hostval c dst |
| 12667 | ret |
| 12668 | end |
| 12669 | if eq c 186 |
| 12670 | rdval 0 0 255 0 |
| 12671 | ab_open |
| 12672 | vdec |
| 12673 | ret |
| 12674 | end |
| 12675 | if eq c 185 |
| 12676 | ab_seal |
| 12677 | vdec |
| 12678 | ret |
| 12679 | end |
| 12680 | if eq c 51 |
| 12681 | e = arrname 1 |
| 12682 | if ge uchar get a_ar add get a_rb 7 sub e 1 6 |
| 12683 | if ne uchar get a_ar add get a_rb 7 sub e 1 10 |
| 12684 | vt_fget e dst |
| 12685 | vdec |
| 12686 | ret |
| 12687 | end |
| 12688 | end |
| 12689 | if ne ly_get e dst 0 |
| 12690 | vdec |
| 12691 | ret |
| 12692 | end |
| 12693 | rdval 0 5 255 0 |
| 12694 | fz_get e |
| 12695 | fwreq |
| 12696 | vt_get e dst |
| 12697 | vdec |
| 12698 | ret |
| 12699 | end |
| 12700 | if eq c 52 |
| 12701 | e = arrname 1 |
| 12702 | if eq uchar get a_ar add get a_rb 7 sub e 1 10 |
| 12703 | pl_len e dst |
| 12704 | ret |
| 12705 | end |
| 12706 | if ge uchar get a_ar add get a_rb 7 sub e 1 6 |
| 12707 | note d2site 220|rdval: type mismatch; condition if ge uchar get a_ar add get a_rb 7 sub e 1 6 |
| 12708 | put d2site 0 220 |
| 12709 | fail 7 |
| 12710 | end |
| 12711 | if ne unsz sub e 1 0 |
| 12712 | vdone 1 ulong uchar get a_ar add get a_rb 14 sub e 1 5 |
| 12713 | ret |
| 12714 | end |
| 12715 | vdone 3 get a_ar add get a_rb 6 sub e 1 5 |
| 12716 | ret |
| 12717 | end |
| 12718 | if or eq c 53 eq c 54 |
| 12719 | eff_rec c |
| 12720 | note read and write compile the same in a native object as in function mode (no image state). |
| 12721 | x = mul get depth 0 32 |
| 12722 | put a_ar add get a_rb 77 add x 8 get nslot 0 |
| 12723 | rdval 0 8 255 0 |
| 12724 | vs_fd x |
| 12725 | e = arrname 1 |
| 12726 | vs_arr c e |
| 12727 | rdval 0 5 255 0 |
| 12728 | vs_off x |
| 12729 | rdval 0 5 255 0 |
| 12730 | vs_end c e dst x |
| 12731 | ret |
| 12732 | end |
| 12733 | if eq c 55 |
| 12734 | vdone 3 1 1 |
| 12735 | ret |
| 12736 | end |
| 12737 | if eq c 56 |
| 12738 | vdone 3 0 1 |
| 12739 | ret |
| 12740 | end |
| 12741 | if and gt sub c 33 17 gt sub c 59 1 |
| 12742 | if eq c 244 |
| 12743 | note d2site 222|rdval: word or declaration in a place that does not allow it; condition if eq c 244 |
| 12744 | put d2site 0 222 |
| 12745 | fail 9 |
| 12746 | end |
| 12747 | note d2site 223|rdval: syntax: unknown or misplaced word; condition if and gt sub c 33 17 gt sub c 59 1 |
| 12748 | put d2site 0 223 |
| 12749 | fail 16 |
| 12750 | end |
| 12751 | if and ge c 49 le c 50 |
| 12752 | put fpw 0 1 |
| 12753 | rdval 0 exp 255 0 |
| 12754 | if ge get rt 0 64 |
| 12755 | note d2site 224|rdval: type mismatch; condition if ge get rt 0 64 |
| 12756 | put d2site 0 224 |
| 12757 | fail 7 |
| 12758 | end |
| 12759 | if and eq c 50 eq get rk 0 4 |
| 12760 | put rv 0 xor get rv 0 1 |
| 12761 | vdec |
| 12762 | ret |
| 12763 | end |
| 12764 | if eq get rk 0 2 |
| 12765 | note d2site 225|rdval: bare number without a type from its context; condition if eq get rk 0 2 |
| 12766 | put d2site 0 225 |
| 12767 | fail 11 |
| 12768 | end |
| 12769 | fwreq |
| 12770 | vt_un c dst |
| 12771 | vdec |
| 12772 | ret |
| 12773 | end |
| 12774 | put fpw 0 1 |
| 12775 | rdval 0 0 255 0 |
| 12776 | ak = get rk 0 |
| 12777 | av = get rv 0 |
| 12778 | at = get rt 0 |
| 12779 | if eq ak 4 |
| 12780 | av = matreg 4 av at |
| 12781 | ak = ulong 1 |
| 12782 | at = ulong 1 |
| 12783 | end |
| 12784 | put fpw 0 1 |
| 12785 | rdval 0 0 255 0 |
| 12786 | bk = get rk 0 |
| 12787 | bv = get rv 0 |
| 12788 | bt = get rt 0 |
| 12789 | if eq bk 4 |
| 12790 | bv = matreg 4 bv bt |
| 12791 | bk = ulong 1 |
| 12792 | bt = ulong 1 |
| 12793 | end |
| 12794 | if or ge at 64 ge bt 64 |
| 12795 | x = mul get depth 0 32 |
| 12796 | a_p 77 x ak |
| 12797 | a_p 77 add x 1 av |
| 12798 | a_p 77 add x 2 at |
| 12799 | a_p 77 add x 3 bk |
| 12800 | a_p 77 add x 4 bv |
| 12801 | a_p 77 add x 5 bt |
| 12802 | ab_bin c dst x |
| 12803 | vdec |
| 12804 | ret |
| 12805 | end |
| 12806 | if and eq ak 6 eq bk 6 |
| 12807 | note d2site 226|rdval: bare number without a type from its context; condition if and eq ak 6 eq bk 6 |
| 12808 | put d2site 0 226 |
| 12809 | fail 11 |
| 12810 | end |
| 12811 | if or ne isfloat at 0 ne isfloat bt 0 |
| 12812 | if eq ak 6 |
| 12813 | if eq bt 0 |
| 12814 | note d2site 227|rdval: bare number without a type from its context; condition if eq bt 0 |
| 12815 | put d2site 0 227 |
| 12816 | fail 11 |
| 12817 | end |
| 12818 | if eq isfloat bt 0 |
| 12819 | note d2site 228|rdval: type mismatch; condition if eq isfloat bt 0 |
| 12820 | put d2site 0 228 |
| 12821 | fail 7 |
| 12822 | end |
| 12823 | av = fspan bt av |
| 12824 | ak = ulong 7 |
| 12825 | at = bt |
| 12826 | end |
| 12827 | if eq bk 6 |
| 12828 | if eq at 0 |
| 12829 | note d2site 229|rdval: bare number without a type from its context; condition if eq at 0 |
| 12830 | put d2site 0 229 |
| 12831 | fail 11 |
| 12832 | end |
| 12833 | if eq isfloat at 0 |
| 12834 | note d2site 230|rdval: type mismatch; condition if eq isfloat at 0 |
| 12835 | put d2site 0 230 |
| 12836 | fail 7 |
| 12837 | end |
| 12838 | bv = fspan at bv |
| 12839 | bk = ulong 7 |
| 12840 | bt = at |
| 12841 | end |
| 12842 | if or eq ak 2 eq ak 3 |
| 12843 | note d2site 231|rdval: type mismatch; condition if or eq ak 2 eq ak 3 |
| 12844 | put d2site 0 231 |
| 12845 | fail 7 |
| 12846 | end |
| 12847 | if or eq bk 2 eq bk 3 |
| 12848 | note d2site 232|rdval: type mismatch; condition if or eq bk 2 eq bk 3 |
| 12849 | put d2site 0 232 |
| 12850 | fail 7 |
| 12851 | end |
| 12852 | end |
| 12853 | if or eq ak 6 eq bk 6 |
| 12854 | note d2site 233|rdval: type mismatch; condition if or eq ak 6 eq bk 6 |
| 12855 | put d2site 0 233 |
| 12856 | fail 7 |
| 12857 | end |
| 12858 | if eq ak 2 |
| 12859 | if eq bk 2 |
| 12860 | note d2site 234|rdval: bare number without a type from its context; condition if eq bk 2 |
| 12861 | put d2site 0 234 |
| 12862 | fail 11 |
| 12863 | end |
| 12864 | range av bt at |
| 12865 | at = bt |
| 12866 | ak = ulong 3 |
| 12867 | end |
| 12868 | if eq bk 2 |
| 12869 | range bv at bt |
| 12870 | bt = at |
| 12871 | bk = ulong 3 |
| 12872 | end |
| 12873 | if and ne c 41 ne c 42 |
| 12874 | if ne at bt |
| 12875 | note d2site 235|rdval: type mismatch; condition if ne at bt |
| 12876 | put d2site 0 235 |
| 12877 | fail 7 |
| 12878 | end |
| 12879 | end |
| 12880 | x = mul get depth 0 32 |
| 12881 | a_p 77 x ak |
| 12882 | a_p 77 add x 1 av |
| 12883 | a_p 77 add x 2 at |
| 12884 | a_p 77 add x 3 bk |
| 12885 | a_p 77 add x 4 bv |
| 12886 | a_p 77 add x 5 bt |
| 12887 | if ne isfloat at 0 |
| 12888 | fwreq |
| 12889 | end |
| 12890 | binop c dst x |
| 12891 | vdec |
| 12892 | end |
| 12893 | |
| 12894 | note cond: read a condition (a bool value); emit a branch taken when it is false: B.cond with the opposite |
| 12895 | note condition (C6.2.34), or CBZ Xr (C6.2.78). Returns that branch's place. om4 COND. |
| 12896 | fn cond to ulong |
| 12897 | if ne get xtarget 0 0 |
| 12898 | rdval 0 1 255 0 |
| 12899 | if ne get rt 0 1 |
| 12900 | note d2site 236|cond: type mismatch; condition if ne get rt 0 1 |
| 12901 | put d2site 0 236 |
| 12902 | fail 7 |
| 12903 | end |
| 12904 | if eq get rk 0 4 |
| 12905 | ret xbranch xor get rv 0 1 |
| 12906 | end |
| 12907 | r = matreg get rk 0 get rv 0 get rt 0 |
| 12908 | xcmp r 0 1 |
| 12909 | ret xbranch 0 |
| 12910 | end |
| 12911 | rdval 0 1 255 0 |
| 12912 | if ne get rt 0 1 |
| 12913 | note d2site 237|cond: type mismatch; condition if ne get rt 0 1 |
| 12914 | put d2site 0 237 |
| 12915 | fail 7 |
| 12916 | end |
| 12917 | if eq get rk 0 4 |
| 12918 | at = get oc 0 |
| 12919 | emit or 1409286144 xor get rv 0 1 |
| 12920 | ret at |
| 12921 | end |
| 12922 | r = matreg get rk 0 get rv 0 get rt 0 |
| 12923 | at = get oc 0 |
| 12924 | emit or 3019898880 r |
| 12925 | ret at |
| 12926 | end |
| 12927 | |
| 12928 | note ======== statements, one per line (om4 STMT and the S_ parts) ======== |
| 12929 | note skipnl: note ...: the rest of the line is not read (up to the newline, which tok reads). om4 S_NOTE. |
| 12930 | fn skipnl to void |
| 12931 | go = true |
| 12932 | while go |
| 12933 | n = ulong 0 |
| 12934 | while and go lt n 999999 |
| 12935 | if ge get cur 0 get inlen 0 |
| 12936 | go = false |
| 12937 | else |
| 12938 | if eq a_ib get cur 0 10 |
| 12939 | go = false |
| 12940 | else |
| 12941 | put cur 0 add get cur 0 1 |
| 12942 | end |
| 12943 | end |
| 12944 | n = add n 1 |
| 12945 | end |
| 12946 | end |
| 12947 | end |
| 12948 | |
| 12949 | note blo: B.LO back to an earlier place (C6.2.34) |
| 12950 | fn blo at ulong to void |
| 12951 | if ne get xtarget 0 0 |
| 12952 | p = xbranch 3 |
| 12953 | xpatch p at |
| 12954 | ret |
| 12955 | end |
| 12956 | d = bdisp get oc 0 at 19 |
| 12957 | emit or 1409286147 shl d 5 |
| 12958 | end |
| 12959 | |
| 12960 | note sa_arr: x = new T N v: N elements of type T on the stack, each set to v; only in the function's |
| 12961 | note outermost block, so the stack held by local arrays is known at every ret. SUB SP (C6.2.457); program |
| 12962 | note mode: the stack check; MOV Xb, SP (ADD immediate, C6.2.5); then the fill loop: STR v, [Xb, Xi, LSL]; |
| 12963 | note ADD Xi, Xi, #1; CMP Xi, #N or Xn; B.LO back (C6.2.34). om4 SA_ARR. |
| 12964 | fn sa_arr w ulong to void |
| 12965 | if ne get xtarget 0 0 |
| 12966 | xarray w |
| 12967 | ret |
| 12968 | end |
| 12969 | if ne get nb 0 0 |
| 12970 | note d2site 238|sa_arr: word or declaration in a place that does not allow it; condition if ne get nb 0 0 |
| 12971 | put d2site 0 238 |
| 12972 | fail 9 |
| 12973 | end |
| 12974 | t = typeword |
| 12975 | elemtype t |
| 12976 | n = lenval 16 |
| 12977 | arrlen n |
| 12978 | by = shl shr add shl n tlog t 15 4 4 |
| 12979 | s = add get stkbytes 0 by |
| 12980 | if gt s 4194304 |
| 12981 | note d2site 239|sa_arr: size capacity; condition if gt s 4194304 |
| 12982 | put d2site 0 239 |
| 12983 | fail 23 |
| 12984 | end |
| 12985 | put stkbytes 0 s |
| 12986 | r = alloc |
| 12987 | put held 0 get nslot 0 |
| 12988 | rdval 0 t 255 0 |
| 12989 | if ne get rt 0 t |
| 12990 | note d2site 240|sa_arr: type mismatch; condition if ne get rt 0 t |
| 12991 | put d2site 0 240 |
| 12992 | fail 7 |
| 12993 | end |
| 12994 | v = matreg get rk 0 get rv 0 get rt 0 |
| 12995 | spsubk by |
| 12996 | stkchk |
| 12997 | emit or 2432697312 r |
| 12998 | i = alloc |
| 12999 | emit or 3531603968 i |
| 13000 | m = ulong 0 |
| 13001 | if gt n 4095 |
| 13002 | m = alloc |
| 13003 | matconst m n |
| 13004 | end |
| 13005 | lp = get oc 0 |
| 13006 | emit or or or stop t v shl r 5 shl i 16 |
| 13007 | emit or or 2432697344 i shl i 5 |
| 13008 | if le n 4095 |
| 13009 | emit or or 4043309087 shl n 10 shl i 5 |
| 13010 | else |
| 13011 | emit or or 3942645791 shl m 16 shl i 5 |
| 13012 | end |
| 13013 | blo lp |
| 13014 | addname w r t n 1 0 |
| 13015 | end |
| 13016 | |
| 13017 | note s_assign: name [=] value (an existing scalar, or a new one), or name = new T N v. om4 S_ASSIGN. A new |
| 13018 | note f32/f64 name lives in the twin of its register (nm_fv, vsl): the value is made there when it can be. |
| 13019 | fn s_assign w ulong to void |
| 13020 | tok |
| 13021 | if eq get tk 0 1 |
| 13022 | if le get tl 0 8 |
| 13023 | if eq kw get tw 0 73 |
| 13024 | tok |
| 13025 | end |
| 13026 | end |
| 13027 | end |
| 13028 | if eq get tk 0 1 |
| 13029 | if eq get tl 0 7 |
| 13030 | if eq get tw 0 28542713606205029 |
| 13031 | s_enlarge w |
| 13032 | ret |
| 13033 | end |
| 13034 | end |
| 13035 | end |
| 13036 | e = findname w |
| 13037 | if ne e 0 |
| 13038 | i = sub e 1 |
| 13039 | if ne uchar get a_ar add get a_rb 7 i 0 |
| 13040 | note d2site 241|s_assign: type mismatch; condition if ne uchar get a_ar add get a_rb 7 i 0 |
| 13041 | put d2site 0 241 |
| 13042 | fail 7 |
| 13043 | end |
| 13044 | r = ulong uchar get a_ar add get a_rb 4 i |
| 13045 | t = ulong uchar get a_ar add get a_rb 5 i |
| 13046 | if ne uchar get a_ar add get a_rb 9 i 0 |
| 13047 | put fpw 0 add r 2 |
| 13048 | rdval 1 t 255 0 |
| 13049 | if ne get rt 0 t |
| 13050 | note d2site 242|s_assign: type mismatch; condition if ne get rt 0 t |
| 13051 | put d2site 0 242 |
| 13052 | fail 7 |
| 13053 | end |
| 13054 | fvset get rk 0 get rv 0 t r |
| 13055 | eol |
| 13056 | ret |
| 13057 | end |
| 13058 | rdval 1 t r 0 |
| 13059 | if ne get rt 0 t |
| 13060 | note d2site 243|s_assign: type mismatch; condition if ne get rt 0 t |
| 13061 | put d2site 0 243 |
| 13062 | fail 7 |
| 13063 | end |
| 13064 | force get rk 0 get rv 0 get rt 0 r |
| 13065 | eol |
| 13066 | ret |
| 13067 | end |
| 13068 | if ne findfn w 0 0 0 |
| 13069 | note d2site 244|s_assign: duplicate name; condition if ne findfn w 0 0 0 |
| 13070 | put d2site 0 244 |
| 13071 | fail 10 |
| 13072 | end |
| 13073 | if eq get tk 0 1 |
| 13074 | if le get tl 0 8 |
| 13075 | if eq kw get tw 0 84 |
| 13076 | sa_new w |
| 13077 | eol |
| 13078 | ret |
| 13079 | end |
| 13080 | end |
| 13081 | end |
| 13082 | r = alloc |
| 13083 | put held 0 get nslot 0 |
| 13084 | put fpw 0 add r 2 |
| 13085 | rdval 1 0 r 0 |
| 13086 | if eq get rk 0 2 |
| 13087 | note d2site 245|s_assign: bare number without a type from its context; condition if eq get rk 0 2 |
| 13088 | put d2site 0 245 |
| 13089 | fail 11 |
| 13090 | end |
| 13091 | t = get rt 0 |
| 13092 | if and ne isfloat t 0 eq get xtarget 0 0 |
| 13093 | fvset get rk 0 get rv 0 t r |
| 13094 | put vsl regidx r uchar 1 |
| 13095 | addname w r t 0 0 0 |
| 13096 | a_pc 9 sub get nn 0 1 uchar 1 |
| 13097 | else |
| 13098 | force get rk 0 get rv 0 t r |
| 13099 | addname w r t 0 0 0 |
| 13100 | end |
| 13101 | eol |
| 13102 | end |
| 13103 | |
| 13104 | note s_enlarge: NAME = enlarge P n (docs/RUNTIME-POOLS.md s3), only as the whole of an assignment (anywhere |
| 13105 | note else error 9). NAME is a long local or a new one (error 7 for any other type), P a run-time pool (error |
| 13106 | note 7 for any other name), n a ulong (error 7). n is read first; then the registers in use are saved, X0 = P's |
| 13107 | note slot, X1 = n, X2 = log2 of the element size, BL omc_enlarge (en_help), and the result moves to NAME's |
| 13108 | note register as the registers come back: 0, -22 when n times the element size reaches 2^63, or the host's |
| 13109 | note -errno (-12) when mmap or mremap refuses; on a refusal the pool is unchanged. |
| 13110 | fn s_enlarge w ulong to void |
| 13111 | eff_rec 244 |
| 13112 | e = findname w |
| 13113 | r = ulong 0 |
| 13114 | if ne e 0 |
| 13115 | i = sub e 1 |
| 13116 | if ne uchar get a_ar add get a_rb 7 i 0 |
| 13117 | note d2site 246|s_enlarge: type mismatch; condition if ne uchar get a_ar add get a_rb 7 i 0 |
| 13118 | put d2site 0 246 |
| 13119 | fail 7 |
| 13120 | end |
| 13121 | if ne uchar get a_ar add get a_rb 5 i 9 |
| 13122 | note d2site 247|s_enlarge: type mismatch; condition if ne uchar get a_ar add get a_rb 5 i 9 |
| 13123 | put d2site 0 247 |
| 13124 | fail 7 |
| 13125 | end |
| 13126 | r = ulong uchar get a_ar add get a_rb 4 i |
| 13127 | else |
| 13128 | if ne findfn w 0 0 0 |
| 13129 | note d2site 248|s_enlarge: duplicate name; condition if ne findfn w 0 0 0 |
| 13130 | put d2site 0 248 |
| 13131 | fail 10 |
| 13132 | end |
| 13133 | r = alloc |
| 13134 | put held 0 get nslot 0 |
| 13135 | end |
| 13136 | if eq get xtarget 0 0 |
| 13137 | en_help |
| 13138 | end |
| 13139 | p = arrname 1 |
| 13140 | if ne uchar get a_ar add get a_rb 7 sub p 1 10 |
| 13141 | note d2site 249|s_enlarge: type mismatch; condition if ne uchar get a_ar add get a_rb 7 sub p 1 10 |
| 13142 | put d2site 0 249 |
| 13143 | fail 7 |
| 13144 | end |
| 13145 | sl = get nslot 0 |
| 13146 | rdval 0 5 255 0 |
| 13147 | if eq get rk 0 2 |
| 13148 | note d2site 250|s_enlarge: bare number without a type from its context; condition if eq get rk 0 2 |
| 13149 | put d2site 0 250 |
| 13150 | fail 11 |
| 13151 | end |
| 13152 | if ne get rt 0 5 |
| 13153 | note d2site 251|s_enlarge: type mismatch; condition if ne get rt 0 5 |
| 13154 | put d2site 0 251 |
| 13155 | fail 7 |
| 13156 | end |
| 13157 | nv = matreg get rk 0 get rv 0 5 |
| 13158 | if ne get xtarget 0 0 |
| 13159 | xenlarge p nv |
| 13160 | put nslot 0 sl |
| 13161 | xstore 0 r |
| 13162 | if eq e 0 |
| 13163 | addname w r 9 0 0 0 |
| 13164 | end |
| 13165 | eol |
| 13166 | ret |
| 13167 | end |
| 13168 | save |
| 13169 | loadarg 1 1 nv |
| 13170 | mataddr 0 get a_ar add get a_rb 8 sub p 1 |
| 13171 | matconst 2 tlog ulong uchar get a_ar add get a_rb 5 sub p 1 |
| 13172 | en_bl |
| 13173 | n = get svn 0 |
| 13174 | a = get sva 0 |
| 13175 | r = restore r sl n a 1 |
| 13176 | if eq e 0 |
| 13177 | addname w r 9 0 0 0 |
| 13178 | end |
| 13179 | eol |
| 13180 | end |
| 13181 | |
| 13182 | note en_help: the unit's omc_enlarge helper (docs/RUNTIME-POOLS.md s4), emitted once, at the unit's first |
| 13183 | note enlarge, behind a B over it (C6.2.35); a unit without enlarge has neither it nor any pool slot. In: X0 the |
| 13184 | note slot (base, length), X1 the count n, X2 log2 of the element size; out X0. n <= length: 0. n << X2 past |
| 13185 | note 2^63 (LSR, CBNZ): -22. Bytes rounded up to the page (4096): a growth within the pages already mapped |
| 13186 | note only stores the length (they are still zero: nothing writes past the length and nothing shrinks); length |
| 13187 | note 0 maps (mmap 222, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS); else mremap (216, MREMAP_MAYMOVE), |
| 13188 | note which moves page tables, not data. A result in -4095..-1 (CMN, B.HS) returns as it is with the slot |
| 13189 | note untouched; else the new base and then the length are stored and the result is 0. It clobbers X0..X6, |
| 13190 | note X8..X10 only, all saved by the caller (save); X7, X16..X30 and SP are untouched. |
| 13191 | note en_bl: BL omc_enlarge (C6.2.43): the helper is behind, so the offset is negative, kept to imm26 |
| 13192 | fn en_bl to void |
| 13193 | d = sub sub get enl_at 0 1 get oc 0 |
| 13194 | emit or 2483027968 and shr d 2 67108863 |
| 13195 | end |
| 13196 | |
| 13197 | fn en_help to void |
| 13198 | if ne get enl_at 0 0 |
| 13199 | ret |
| 13200 | end |
| 13201 | emit 335544362 |
| 13202 | put enl_at 0 add get oc 0 1 |
| 13203 | emit 2852127721 |
| 13204 | emit 2852193258 |
| 13205 | emit 4181722403 |
| 13206 | emit 3942842719 |
| 13207 | note POOLMUT belowlen |
| 13208 | emit 1409287209 |
| 13209 | emit 3531605988 |
| 13210 | emit 3405906052 |
| 13211 | emit 2596545861 |
| 13212 | note POOLMUT ovf |
| 13213 | emit 3036677093 |
| 13214 | emit 2596413765 |
| 13215 | emit 2436889765 |
| 13216 | emit 2457128101 |
| 13217 | emit 2596413542 |
| 13218 | emit 2436889798 |
| 13219 | emit 2457128134 |
| 13220 | emit 3943039167 |
| 13221 | emit 1409286793 |
| 13222 | emit 3019899142 |
| 13223 | emit 4181721376 |
| 13224 | emit 2852520929 |
| 13225 | emit 2852455394 |
| 13226 | emit 3531604003 |
| 13227 | emit 3531610888 |
| 13228 | emit 3556769793 |
| 13229 | emit 335544329 |
| 13230 | emit 3531603968 |
| 13231 | emit 2852455393 |
| 13232 | emit 3531604066 |
| 13233 | emit 3531605059 |
| 13234 | emit 2457862148 |
| 13235 | emit 3531603973 |
| 13236 | emit 3531611080 |
| 13237 | emit 3556769793 |
| 13238 | emit 2973760543 |
| 13239 | note POOLMUT slotfail |
| 13240 | emit 1409286274 |
| 13241 | emit 4177527072 |
| 13242 | note POOLMUT caplen |
| 13243 | emit 4177528106 |
| 13244 | emit 3531603968 |
| 13245 | emit 3596551104 |
| 13246 | emit 2457862816 |
| 13247 | emit 3596551104 |
| 13248 | note POOLMUT-ALT belowlen emit 3573751839 |
| 13249 | note POOLMUT-ALT caplen emit 4177528101 |
| 13250 | note POOLMUT-ALT ovf emit 3573751839 |
| 13251 | note POOLMUT-ALT slotfail emit 3573751839 |
| 13252 | end |
| 13253 | |
| 13254 | note s_name: a name at the start of a line: a call of a void function, or name [=] value. om4 S_NAME. |
| 13255 | fn s_name w ulong to void |
| 13256 | if ne findname w 0 |
| 13257 | s_assign w |
| 13258 | ret |
| 13259 | end |
| 13260 | f = findfn w get tl 0 0 |
| 13261 | if eq f 0 |
| 13262 | s_assign w |
| 13263 | ret |
| 13264 | end |
| 13265 | if ne uchar get a_ar add get a_rb 23 sub f 1 12 |
| 13266 | note d2site 252|s_name: type mismatch; condition if ne uchar get a_ar add get a_rb 23 sub f 1 12 |
| 13267 | put d2site 0 252 |
| 13268 | fail 7 |
| 13269 | end |
| 13270 | rdval 2 0 255 f |
| 13271 | eol |
| 13272 | end |
| 13273 | |
| 13274 | note fn_p: the type of parameter np (name pw) of function f (index): T, or view / edit T N (an array: |
| 13275 | note kind 2 / 3, element type, length 1 .. 2^24). om4 FN_P .. FN_ADD. |
| 13276 | fn fn_p f ulong np ulong pw ulong to void |
| 13277 | tok |
| 13278 | if ne get tk 0 1 |
| 13279 | note d2site 253|fn_p: syntax: unknown or misplaced word; condition if ne get tk 0 1 |
| 13280 | put d2site 0 253 |
| 13281 | fail 16 |
| 13282 | end |
| 13283 | if gt get tl 0 8 |
| 13284 | note d2site 254|fn_p: syntax: unknown or misplaced word; condition if gt get tl 0 8 |
| 13285 | put d2site 0 254 |
| 13286 | fail 16 |
| 13287 | end |
| 13288 | c = kw get tw 0 |
| 13289 | t = ulong 0 |
| 13290 | ln = ulong 0 |
| 13291 | k = ulong 0 |
| 13292 | if eq c 194 |
| 13293 | fn_p_out f np pw |
| 13294 | ret |
| 13295 | end |
| 13296 | if or eq c 57 eq c 58 |
| 13297 | k = sub c 55 |
| 13298 | sid = peek_struct |
| 13299 | if ne sid 0 |
| 13300 | fn_p_st f np pw sid k |
| 13301 | ret |
| 13302 | end |
| 13303 | if ne get om2 0 0 |
| 13304 | lid = peek_lay |
| 13305 | if ne lid 0 |
| 13306 | fn_p_ly f np pw lid k |
| 13307 | ret |
| 13308 | end |
| 13309 | end |
| 13310 | t = typeword |
| 13311 | elemtype t |
| 13312 | if and ne get om2 0 0 ne peekstar 0 |
| 13313 | tok |
| 13314 | else |
| 13315 | ln = lenval 16 |
| 13316 | arrlen ln |
| 13317 | if ne get om2 0 0 |
| 13318 | if eq peekw 183 |
| 13319 | tok |
| 13320 | fz_par f np k ln |
| 13321 | end |
| 13322 | end |
| 13323 | end |
| 13324 | else |
| 13325 | if eq c 88 |
| 13326 | t = ulong 10 |
| 13327 | else |
| 13328 | if eq c 89 |
| 13329 | t = ulong 11 |
| 13330 | else |
| 13331 | if eq c 223 |
| 13332 | t = ulong 13 |
| 13333 | else |
| 13334 | if gt sub c 1 8 |
| 13335 | t = abty |
| 13336 | else |
| 13337 | t = c |
| 13338 | end |
| 13339 | end |
| 13340 | end |
| 13341 | end |
| 13342 | end |
| 13343 | addname pw poolc get psl 0 t ln k 0 |
| 13344 | if and ne k 0 eq ln 0 |
| 13345 | a_pc 14 sub get nn 0 1 uchar poolc add get psl 0 1 |
| 13346 | end |
| 13347 | fz_bind add mul f 6 np ln |
| 13348 | p = add mul f 6 np |
| 13349 | a_pc 35 p uchar t |
| 13350 | put a_ar add get a_rb 36 p ln |
| 13351 | a_pc 37 p uchar k |
| 13352 | end |
| 13353 | |
| 13354 | note fn_p_out (OM-2, spec 6, erratum E1): `NAME out T N`, a sized array the unit writes and the bridge owns |
| 13355 | note (copied out only after status 0). Inside the unit it is an edit of T N (kind 3) in one slot, its |
| 13356 | note pointer; a length `*` is error 16, and so is `fresh` after it. |
| 13357 | fn fn_p_out f ulong np ulong pw ulong to void |
| 13358 | t = typeword |
| 13359 | elemtype t |
| 13360 | ln = lenval 16 |
| 13361 | arrlen ln |
| 13362 | addname pw poolc get psl 0 t ln 3 0 |
| 13363 | p = add mul f 6 np |
| 13364 | a_pc 35 p uchar t |
| 13365 | put a_ar add get a_rb 36 p ln |
| 13366 | a_pc 37 p 3 |
| 13367 | end |
| 13368 | |
| 13369 | note fn_to: to T | to void at the end of a fn line; the function's state starts. om4 FN_TO .. FN_T2. |
| 13370 | fn fn_to f ulong np ulong to void |
| 13371 | tok |
| 13372 | if eq get tk 0 0 |
| 13373 | note d2site 255|fn_to: the line ends where a word or value is needed; condition if eq get tk 0 0 |
| 13374 | put d2site 0 255 |
| 13375 | fail 4 |
| 13376 | end |
| 13377 | if ne get tk 0 1 |
| 13378 | note d2site 256|fn_to: syntax: unknown or misplaced word; condition if ne get tk 0 1 |
| 13379 | put d2site 0 256 |
| 13380 | fail 16 |
| 13381 | end |
| 13382 | if gt get tl 0 8 |
| 13383 | note d2site 257|fn_to: syntax: unknown or misplaced word; condition if gt get tl 0 8 |
| 13384 | put d2site 0 257 |
| 13385 | fail 16 |
| 13386 | end |
| 13387 | c = kw get tw 0 |
| 13388 | r = c |
| 13389 | if eq c 76 |
| 13390 | r = ulong 12 |
| 13391 | else |
| 13392 | if eq c 88 |
| 13393 | r = ulong 10 |
| 13394 | else |
| 13395 | if eq c 89 |
| 13396 | r = ulong 11 |
| 13397 | else |
| 13398 | if eq c 223 |
| 13399 | r = ulong 13 |
| 13400 | else |
| 13401 | if gt sub c 1 8 |
| 13402 | r = abty |
| 13403 | else |
| 13404 | r = c |
| 13405 | end |
| 13406 | end |
| 13407 | end |
| 13408 | end |
| 13409 | end |
| 13410 | put curret 0 r |
| 13411 | a_pc 23 f uchar r |
| 13412 | a_pc 24 f uchar np |
| 13413 | put stkbytes 0 0 |
| 13414 | put osp 0 0 |
| 13415 | put osmax 0 0 |
| 13416 | put osbad 0 0 |
| 13417 | put dead 0 0 |
| 13418 | put npar 0 get psl 0 |
| 13419 | put nslot 0 0 |
| 13420 | for j ulong 16 |
| 13421 | put vsl j 0 |
| 13422 | end |
| 13423 | put held 0 0 |
| 13424 | put nb 0 0 |
| 13425 | put nt 0 0 |
| 13426 | put tpend 0 0 |
| 13427 | fn_tail f |
| 13428 | if and ne get xtarget 0 0 eq get scanning 0 0 |
| 13429 | xpro get psl 0 |
| 13430 | end |
| 13431 | end |
| 13432 | |
| 13433 | note s_fn: fn name (param type | param view T N | param edit T N)* to type | void. om4 S_FN. |
| 13434 | note A name of 9..63 bytes is never a keyword: tw packs only its first 8 bytes (continue_x is not continue). |
| 13435 | fn s_fn to void |
| 13436 | if ne get curret 0 0 |
| 13437 | note d2site 258|s_fn: missing end; condition if ne get curret 0 0 |
| 13438 | put d2site 0 258 |
| 13439 | fail 15 |
| 13440 | end |
| 13441 | tok |
| 13442 | if ne get tk 0 1 |
| 13443 | note d2site 259|s_fn: syntax: unknown or misplaced word; condition if ne get tk 0 1 |
| 13444 | put d2site 0 259 |
| 13445 | fail 16 |
| 13446 | end |
| 13447 | if gt get tl 0 63 |
| 13448 | note d2site 260|s_fn: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63 |
| 13449 | put d2site 0 260 |
| 13450 | fail 13 |
| 13451 | end |
| 13452 | w = get tw 0 |
| 13453 | if and ne get objmode 0 0 eq w 121437607458917 |
| 13454 | if eq get tl 0 6 |
| 13455 | note d2site 261|s_fn: syntax: unknown or misplaced word; condition if eq get tl 0 6 |
| 13456 | put d2site 0 261 |
| 13457 | fail 16 |
| 13458 | end |
| 13459 | end |
| 13460 | if le get tl 0 8 |
| 13461 | if ne kw w 0 |
| 13462 | note d2site 262|s_fn: syntax: unknown or misplaced word; condition if ne kw w 0 |
| 13463 | put d2site 0 262 |
| 13464 | fail 16 |
| 13465 | end |
| 13466 | end |
| 13467 | l = get tl 0 |
| 13468 | s = get ts 0 |
| 13469 | f = ulong 0 |
| 13470 | if eq get scanning 0 1 |
| 13471 | newname w l s |
| 13472 | f = get nf 0 |
| 13473 | if ge f get a_gp 7 |
| 13474 | a_need 7 f |
| 13475 | end |
| 13476 | if ne get objmode 0 0 |
| 13477 | a_need 21 f |
| 13478 | a_p 86 f 0 |
| 13479 | end |
| 13480 | put nf 0 add f 1 |
| 13481 | put curfn 0 add f 1 |
| 13482 | put lastfn 0 add f 1 |
| 13483 | put a_ar add get a_rb 21 f w |
| 13484 | fn_link f |
| 13485 | put a_ar add get a_rb 22 f get oc 0 |
| 13486 | a_pc 23 f 0 |
| 13487 | a_pc 24 f 0 |
| 13488 | put a_ar add get a_rb 25 f l |
| 13489 | put a_ar add get a_rb 26 f s |
| 13490 | a_pc 32 f uchar get expf 0 |
| 13491 | else |
| 13492 | f = sub findfn w l s 1 |
| 13493 | put curfn 0 add f 1 |
| 13494 | put lastfn 0 add f 1 |
| 13495 | put a_ar add get a_rb 22 f get oc 0 |
| 13496 | put fstart 0 get oc 0 |
| 13497 | put pinshut 0 1 |
| 13498 | put fuel 0 0 |
| 13499 | put fz_n 0 0 |
| 13500 | end |
| 13501 | nm_set get nglob 0 |
| 13502 | put psl 0 0 |
| 13503 | np = ulong 0 |
| 13504 | go = true |
| 13505 | while go |
| 13506 | tok |
| 13507 | if eq get tk 0 0 |
| 13508 | note d2site 263|s_fn: the line ends where a word or value is needed; condition if eq get tk 0 0 |
| 13509 | put d2site 0 263 |
| 13510 | fail 4 |
| 13511 | end |
| 13512 | if ne get tk 0 1 |
| 13513 | note d2site 264|s_fn: syntax: unknown or misplaced word; condition if ne get tk 0 1 |
| 13514 | put d2site 0 264 |
| 13515 | fail 16 |
| 13516 | end |
| 13517 | if gt get tl 0 63 |
| 13518 | note d2site 265|s_fn: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63 |
| 13519 | put d2site 0 265 |
| 13520 | fail 13 |
| 13521 | end |
| 13522 | pw = get tw 0 |
| 13523 | c = kw pw |
| 13524 | if eq c 65 |
| 13525 | go = false |
| 13526 | else |
| 13527 | if ne c 0 |
| 13528 | note d2site 266|s_fn: syntax: unknown or misplaced word; condition if ne c 0 |
| 13529 | put d2site 0 266 |
| 13530 | fail 16 |
| 13531 | end |
| 13532 | newname pw get tl 0 get ts 0 |
| 13533 | if ge get psl 0 6 |
| 13534 | note d2site 267|s_fn: word or declaration in a place that does not allow it; condition if ge get psl 0 6 |
| 13535 | put d2site 0 267 |
| 13536 | fail 9 |
| 13537 | end |
| 13538 | fn_p f np pw |
| 13539 | a_p 34 add mul f 6 np pw |
| 13540 | put psl 0 add get psl 0 pwid add mul f 6 np |
| 13541 | if gt get psl 0 6 |
| 13542 | note d2site 268|s_fn: word or declaration in a place that does not allow it; condition if gt get psl 0 6 |
| 13543 | put d2site 0 268 |
| 13544 | fail 9 |
| 13545 | end |
| 13546 | np = add np 1 |
| 13547 | end |
| 13548 | end |
| 13549 | fn_to f np |
| 13550 | if and ne get objmode 0 0 eq get expf 0 2 |
| 13551 | obj_import f |
| 13552 | ret |
| 13553 | end |
| 13554 | ab_entry f |
| 13555 | if eq get scanning 0 0 |
| 13556 | cp_entry |
| 13557 | end |
| 13558 | if eq get scanning 0 1 |
| 13559 | put curret 0 0 |
| 13560 | note keep the top-level consts read so far: a later const must not take an earlier one's slot. |
| 13561 | nm_set get nglob 0 |
| 13562 | end |
| 13563 | end |
| 13564 | |
| 13565 | note s_ret: ret [value]: the value into X0, give back the local arrays' stack, RET. om4 S_RET. |
| 13566 | fn s_ret to void |
| 13567 | if ne get inl 0 0 |
| 13568 | s_iret |
| 13569 | ret |
| 13570 | end |
| 13571 | r = get curret 0 |
| 13572 | if eq r 12 |
| 13573 | eol |
| 13574 | cp_post 0 0 r |
| 13575 | epi |
| 13576 | dead1 |
| 13577 | ret |
| 13578 | end |
| 13579 | dst = ulong 0 |
| 13580 | if and ne get cfhas 0 0 eq get crel 0 0 |
| 13581 | dst = ulong 255 |
| 13582 | end |
| 13583 | rdval 0 r dst 0 |
| 13584 | if ne get rt 0 r |
| 13585 | note d2site 269|s_ret: type mismatch; condition if ne get rt 0 r |
| 13586 | put d2site 0 269 |
| 13587 | fail 7 |
| 13588 | end |
| 13589 | if and ne get cfhas 0 0 eq get crel 0 0 |
| 13590 | rr = matreg get rk 0 get rv 0 r |
| 13591 | eol |
| 13592 | cp_post 1 rr r |
| 13593 | force 1 rr r 0 |
| 13594 | else |
| 13595 | force get rk 0 get rv 0 get rt 0 0 |
| 13596 | eol |
| 13597 | cp_post 1 0 r |
| 13598 | end |
| 13599 | epi |
| 13600 | dead1 |
| 13601 | end |
| 13602 | |
| 13603 | note s_break: leave the innermost loop: find the nearest block of kind 3 (while) or 4 (for), emit an |
| 13604 | note always-taken B.cond to the loop's exit and record the word for s_end to patch. Outside a loop the |
| 13605 | note line is error 9. Like ret, the line ends the path (a later line in the same block is error 17). |
| 13606 | fn s_break to void |
| 13607 | j = get nb 0 |
| 13608 | found = ulong 0 |
| 13609 | bi = ulong 0 |
| 13610 | while and eq found 0 gt j 0 |
| 13611 | j = sub j 1 |
| 13612 | if ge get a_ar add get a_rb 49 j 3 |
| 13613 | found = ulong 1 |
| 13614 | bi = j |
| 13615 | end |
| 13616 | end |
| 13617 | if eq found 0 |
| 13618 | note d2site 270|s_break: word or declaration in a place that does not allow it; condition if eq found 0 |
| 13619 | put d2site 0 270 |
| 13620 | fail 9 |
| 13621 | end |
| 13622 | if ge get a_ar add get a_rb 49 bi 5 |
| 13623 | note d2site 271|s_break: word or declaration in a place that does not allow it; condition if ge get a_ar add get a_rb 49 bi 5 |
| 13624 | put d2site 0 271 |
| 13625 | fail 9 |
| 13626 | end |
| 13627 | n = get nbrk 0 |
| 13628 | if ge n get a_gp 14 |
| 13629 | a_need 14 n |
| 13630 | end |
| 13631 | put a_ar add get a_rb 70 n get oc 0 |
| 13632 | put a_ar add get a_rb 71 n bi |
| 13633 | put nbrk 0 add n 1 |
| 13634 | if ne get xtarget 0 0 |
| 13635 | p = xbranch 14 |
| 13636 | else |
| 13637 | emit 1409286158 |
| 13638 | end |
| 13639 | dead1 |
| 13640 | eol |
| 13641 | end |
| 13642 | |
| 13643 | note s_cont: continue: like break it finds the innermost loop, but its exit is the latch: the head of a |
| 13644 | note while, the increment of a for (patched by s_end). Outside a loop it is error 9; the line ends the |
| 13645 | note path (error 17 for a later line in the same block). |
| 13646 | fn s_cont to void |
| 13647 | j = get nb 0 |
| 13648 | found = ulong 0 |
| 13649 | bi = ulong 0 |
| 13650 | while and eq found 0 gt j 0 |
| 13651 | j = sub j 1 |
| 13652 | if ge get a_ar add get a_rb 49 j 3 |
| 13653 | found = ulong 1 |
| 13654 | bi = j |
| 13655 | end |
| 13656 | end |
| 13657 | if eq found 0 |
| 13658 | note d2site 272|s_cont: word or declaration in a place that does not allow it; condition if eq found 0 |
| 13659 | put d2site 0 272 |
| 13660 | fail 9 |
| 13661 | end |
| 13662 | if ge get a_ar add get a_rb 49 bi 5 |
| 13663 | note d2site 273|s_cont: word or declaration in a place that does not allow it; condition if ge get a_ar add get a_rb 49 bi 5 |
| 13664 | put d2site 0 273 |
| 13665 | fail 9 |
| 13666 | end |
| 13667 | n = get ncont 0 |
| 13668 | if ge n get a_gp 15 |
| 13669 | a_need 15 n |
| 13670 | end |
| 13671 | put a_ar add get a_rb 72 n get oc 0 |
| 13672 | put a_ar add get a_rb 73 n bi |
| 13673 | put ncont 0 add n 1 |
| 13674 | if ne get xtarget 0 0 |
| 13675 | p = xbranch 14 |
| 13676 | else |
| 13677 | emit 1409286158 |
| 13678 | end |
| 13679 | dead1 |
| 13680 | eol |
| 13681 | end |
| 13682 | |
| 13683 | note stel: the checked store of v (type t) at ea_b / ea_i (the STOP table: register offset, scaled) |
| 13684 | fn stel t ulong v ulong to void |
| 13685 | if ne get xtarget 0 0 |
| 13686 | xmemval 1 get ea_b 0 get ea_i 0 t v |
| 13687 | ret |
| 13688 | end |
| 13689 | eaem stop t v |
| 13690 | end |
| 13691 | |
| 13692 | note s_put: put A i v: index, then value, then the checked store (STOP table). om4 S_PUT. |
| 13693 | fn s_put to void |
| 13694 | e = arrname 1 |
| 13695 | k = uchar get a_ar add get a_rb 7 sub e 1 |
| 13696 | if ge k 6 |
| 13697 | if ne k 10 |
| 13698 | s_putf e |
| 13699 | ret |
| 13700 | end |
| 13701 | end |
| 13702 | if or eq k 2 eq k 5 |
| 13703 | note d2site 274|s_put: write to a view or a text; condition if or eq k 2 eq k 5 |
| 13704 | put d2site 0 274 |
| 13705 | fail 20 |
| 13706 | end |
| 13707 | if ne ly_put e 0 |
| 13708 | ret |
| 13709 | end |
| 13710 | rdval 0 5 255 0 |
| 13711 | ik = get rk 0 |
| 13712 | iv = get rv 0 |
| 13713 | it = get rt 0 |
| 13714 | note POOLMUT-ALT slotearly.1 elemaddr e ik iv it |
| 13715 | note POOLMUT-ALT slotearly.2 note removed |
| 13716 | note POOLMUT slotearly.1 |
| 13717 | note the element address comes after the value (docs/RUNTIME-POOLS.md s4, rule B1) |
| 13718 | t = ulong uchar get a_ar add get a_rb 5 sub e 1 |
| 13719 | if ne isfloat t 0 |
| 13720 | put fpw 0 1 |
| 13721 | end |
| 13722 | rdval 0 t 255 0 |
| 13723 | if ne get rt 0 t |
| 13724 | note d2site 275|s_put: type mismatch; condition if ne get rt 0 t |
| 13725 | put d2site 0 275 |
| 13726 | fail 7 |
| 13727 | end |
| 13728 | if eq get rk 0 9 |
| 13729 | vv = vtw get rv 0 |
| 13730 | fz_put e ik iv |
| 13731 | elemaddr e ik iv it |
| 13732 | eaem or stop t 67108864 vv |
| 13733 | eol |
| 13734 | ret |
| 13735 | end |
| 13736 | v = matreg get rk 0 get rv 0 get rt 0 |
| 13737 | fz_put e ik iv |
| 13738 | note POOLMUT slotearly.2 |
| 13739 | elemaddr e ik iv it |
| 13740 | stel t v |
| 13741 | eol |
| 13742 | end |
| 13743 | |
| 13744 | note s_const: const NAME TYPE LITERAL at top level. The value is a typed number (integer or float) |
| 13745 | note read wherever a value goes; it may not be assigned and is refused in IR mode. |
| 13746 | fn s_const to void |
| 13747 | tok |
| 13748 | if ne get tk 0 1 |
| 13749 | note d2site 276|s_const: syntax: unknown or misplaced word; condition if ne get tk 0 1 |
| 13750 | put d2site 0 276 |
| 13751 | fail 16 |
| 13752 | end |
| 13753 | if gt get tl 0 63 |
| 13754 | note d2site 277|s_const: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63 |
| 13755 | put d2site 0 277 |
| 13756 | fail 13 |
| 13757 | end |
| 13758 | w = get tw 0 |
| 13759 | if ne kw w 0 |
| 13760 | note d2site 278|s_const: syntax: unknown or misplaced word; condition if ne kw w 0 |
| 13761 | put d2site 0 278 |
| 13762 | fail 16 |
| 13763 | end |
| 13764 | newname w get tl 0 get ts 0 |
| 13765 | t = typeword |
| 13766 | if ge t 64 |
| 13767 | note d2site 279|s_const: type mismatch; condition if ge t 64 |
| 13768 | put d2site 0 279 |
| 13769 | fail 7 |
| 13770 | end |
| 13771 | if ne isfloat t 0 |
| 13772 | note float constant: rdval reads the float token as a value (kind 6); fspan converts it to the |
| 13773 | note target type's bits and rdval has already balanced the nesting depth. |
| 13774 | rdval 0 0 255 0 |
| 13775 | if ne get rk 0 6 |
| 13776 | note d2site 280|s_const: syntax: unknown or misplaced word; condition if ne get rk 0 6 |
| 13777 | put d2site 0 280 |
| 13778 | fail 16 |
| 13779 | end |
| 13780 | v = fspan t get rv 0 |
| 13781 | addname w 0 t 0 9 v |
| 13782 | put nglob 0 get nn 0 |
| 13783 | eol |
| 13784 | ret |
| 13785 | end |
| 13786 | tok |
| 13787 | if eq get tk 0 0 |
| 13788 | note d2site 281|s_const: the line ends where a word or value is needed; condition if eq get tk 0 0 |
| 13789 | put d2site 0 281 |
| 13790 | fail 4 |
| 13791 | end |
| 13792 | if eq get tk 0 5 |
| 13793 | note d2site 282|s_const: type mismatch; condition if eq get tk 0 5 |
| 13794 | put d2site 0 282 |
| 13795 | fail 7 |
| 13796 | end |
| 13797 | if ne get tk 0 2 |
| 13798 | note d2site 283|s_const: syntax: unknown or misplaced word; condition if ne get tk 0 2 |
| 13799 | put d2site 0 283 |
| 13800 | fail 16 |
| 13801 | end |
| 13802 | v = get tw 0 |
| 13803 | range v t get tbig 0 |
| 13804 | addname w 0 t 0 9 v |
| 13805 | put nglob 0 get nn 0 |
| 13806 | eol |
| 13807 | end |
| 13808 | |
| 13809 | note s_global: global NAME T N: a fixed pool of N elements, zero at start, in the read/write part of the |
| 13810 | note program image after the 8 MiB stack pool (address 0x10800000 + pool bytes so far); at most 1 GiB of |
| 13811 | note pools (error 23). om4 S_GLOBAL. |
| 13812 | fn s_global to void |
| 13813 | w = topname |
| 13814 | t = typeword |
| 13815 | elemtype t |
| 13816 | pc = get cur 0 |
| 13817 | pl = get line 0 |
| 13818 | tok |
| 13819 | if eq get tk 0 1 |
| 13820 | if eq get tl 0 1 |
| 13821 | if eq get tw 0 42 |
| 13822 | sg_pool w t |
| 13823 | ret |
| 13824 | end |
| 13825 | end |
| 13826 | end |
| 13827 | put cur 0 pc |
| 13828 | put line 0 pl |
| 13829 | n = lenval 16 |
| 13830 | arrlen n |
| 13831 | by = shl shr add shl n tlog t 15 4 4 |
| 13832 | pb = get poolb 0 |
| 13833 | a = add 276824064 pb |
| 13834 | s = add pb by |
| 13835 | if gt s 1073741824 |
| 13836 | note d2site 284|s_global: size capacity; condition if gt s 1073741824 |
| 13837 | put d2site 0 284 |
| 13838 | fail 23 |
| 13839 | end |
| 13840 | put poolb 0 s |
| 13841 | addname w 0 t n 4 a |
| 13842 | put nglob 0 get nn 0 |
| 13843 | if ne om2cg 0 |
| 13844 | pinset sub get nn 0 1 a n |
| 13845 | end |
| 13846 | eol |
| 13847 | end |
| 13848 | |
| 13849 | note sg_pool: global NAME T * (docs/RUNTIME-POOLS.md s3, s4): a run-time pool of element type t, name kind |
| 13850 | note 10, length 0 when the program starts. Its 16-byte slot in the global pool area (zero at start) holds the |
| 13851 | note base address, then the length in elements. Program mode on AArch64 and x86linux: function mode and IR mode |
| 13852 | note are error 9, x86efi and a64efi error 25. Never pinned: no X18..X26 holds its base or length. |
| 13853 | fn sg_pool w ulong t ulong to void |
| 13854 | if eq get progmode 0 0 |
| 13855 | note d2site 285|sg_pool: word or declaration in a place that does not allow it; condition if eq get progmode 0 0 |
| 13856 | put d2site 0 285 |
| 13857 | fail 9 |
| 13858 | end |
| 13859 | if ne get irmode 0 0 |
| 13860 | note d2site 286|sg_pool: word or declaration in a place that does not allow it; condition if ne get irmode 0 0 |
| 13861 | put d2site 0 286 |
| 13862 | fail 9 |
| 13863 | end |
| 13864 | if gt get xtarget 0 1 |
| 13865 | note d2site 287|sg_pool: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if gt get xtarget 0 1 |
| 13866 | put d2site 0 287 |
| 13867 | fail 25 |
| 13868 | end |
| 13869 | if ne get xefa 0 0 |
| 13870 | note d2site 288|sg_pool: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if ne get xefa 0 0 |
| 13871 | put d2site 0 288 |
| 13872 | fail 25 |
| 13873 | end |
| 13874 | pb = get poolb 0 |
| 13875 | a = add 276824064 pb |
| 13876 | s = add pb 16 |
| 13877 | if gt s 1073741824 |
| 13878 | note d2site 289|sg_pool: size capacity; condition if gt s 1073741824 |
| 13879 | put d2site 0 289 |
| 13880 | fail 23 |
| 13881 | end |
| 13882 | put poolb 0 s |
| 13883 | addname w 0 t 0 10 a |
| 13884 | put nglob 0 get nn 0 |
| 13885 | note POOLMUT-ALT pinned pinset sub get nn 0 1 a 0 |
| 13886 | note POOLMUT pinned |
| 13887 | eol |
| 13888 | end |
| 13889 | |
| 13890 | note om2cg: 1 when the unit gets the OM-2 AArch64 code improvements (an OM-2 unit, AArch64, not IR mode), |
| 13891 | note else 0. An OM-1 unit keeps om4's machine words exactly (gate5 compares them word for word). |
| 13892 | note Not under target a64efi: the improvements pin globals in X18..X26, and X18 belongs to the platform |
| 13893 | note under UEFI (the entry never sets those registers either). `target a64efi` then `om2` is the OM-2 |
| 13894 | note language with the OM-1 addressing, as on the x86 targets. |
| 13895 | fn om2cg to ulong |
| 13896 | if ne get xefa 0 0 |
| 13897 | ret 0 |
| 13898 | end |
| 13899 | if and and ne get om2 0 0 eq get xtarget 0 0 eq get irmode 0 0 |
| 13900 | ret 1 |
| 13901 | end |
| 13902 | ret 0 |
| 13903 | end |
| 13904 | |
| 13905 | note pinset: give global name i (address a, n elements) the next free pinned register for its base, then |
| 13906 | note one for its length when n is above 4095 (no CMP immediate); nothing once X18..X26 are all taken, and |
| 13907 | note nothing for a global declared after the first function body (pinshut). |
| 13908 | fn pinset i ulong a ulong n ulong to void |
| 13909 | p = get npin 0 |
| 13910 | if or ge p 9 ne get pinshut 0 0 |
| 13911 | ret |
| 13912 | end |
| 13913 | a_pc 10 i uchar add 18 p |
| 13914 | put pinv p a |
| 13915 | p = add p 1 |
| 13916 | if and gt n 4095 lt p 9 |
| 13917 | a_pc 11 i uchar add 18 p |
| 13918 | put pinv p n |
| 13919 | p = add p 1 |
| 13920 | end |
| 13921 | put npin 0 p |
| 13922 | end |
| 13923 | |
| 13924 | note pinlo: MOVZ/MOVK (matconst) every pinned register X18 + p with its value pinv p |
| 13925 | fn pinlo to void |
| 13926 | p = ulong 0 |
| 13927 | while lt p get npin 0 |
| 13928 | matconst add 18 p get pinv p |
| 13929 | p = add p 1 |
| 13930 | end |
| 13931 | end |
| 13932 | |
| 13933 | note s_text: text NAME "...": read-only bytes in the program image (escapes \n \t \\ \", any other is error |
| 13934 | note 22), padded to a word, with their length; address 0x400000 + its place. om4 S_TEXT. |
| 13935 | fn s_text to void |
| 13936 | w = topname |
| 13937 | tok |
| 13938 | if ne get tk 0 4 |
| 13939 | note d2site 290|s_text: syntax: unknown or misplaced word; condition if ne get tk 0 4 |
| 13940 | put d2site 0 290 |
| 13941 | fail 16 |
| 13942 | end |
| 13943 | br = ulong 0 |
| 13944 | if and ne get xtarget 0 0 ne get tl 0 0 |
| 13945 | br = xbranch 14 |
| 13946 | end |
| 13947 | a = add get oc 0 4194304 |
| 13948 | p = get tw 0 |
| 13949 | e = add p get tl 0 |
| 13950 | n = ulong 0 |
| 13951 | go = true |
| 13952 | while go |
| 13953 | m = ulong 0 |
| 13954 | while and go lt m 999999 |
| 13955 | if ge p e |
| 13956 | go = false |
| 13957 | else |
| 13958 | b = a_ib p |
| 13959 | p = add p 1 |
| 13960 | if eq b 92 |
| 13961 | b = a_ib p |
| 13962 | p = add p 1 |
| 13963 | if eq b 110 |
| 13964 | b = uchar 10 |
| 13965 | else |
| 13966 | if eq b 116 |
| 13967 | b = uchar 9 |
| 13968 | else |
| 13969 | if and ne b 92 ne b 34 |
| 13970 | note d2site 291|s_text: malformed text literal; condition if and ne b 92 ne b 34 |
| 13971 | put d2site 0 291 |
| 13972 | fail 22 |
| 13973 | end |
| 13974 | end |
| 13975 | end |
| 13976 | end |
| 13977 | emitb b |
| 13978 | n = add n 1 |
| 13979 | end |
| 13980 | m = add m 1 |
| 13981 | end |
| 13982 | end |
| 13983 | note Empty text carries no data or padding; its zero count forbids every access. |
| 13984 | if ne n 0 |
| 13985 | while ne and get oc 0 3 0 |
| 13986 | emitb 0 |
| 13987 | end |
| 13988 | end |
| 13989 | if ne br 0 |
| 13990 | xpatch br get oc 0 |
| 13991 | end |
| 13992 | addname w 0 2 n 5 a |
| 13993 | put nglob 0 get nn 0 |
| 13994 | eol |
| 13995 | end |
| 13996 | |
| 13997 | note s_else: jump over the else part (B, C6.2.35); the if's false branch lands after that jump. om4 S_ELSE. |
| 13998 | fn s_else to void |
| 13999 | n = get nb 0 |
| 14000 | if eq n 0 |
| 14001 | note d2site 292|s_else: missing end; condition if eq n 0 |
| 14002 | put d2site 0 292 |
| 14003 | fail 15 |
| 14004 | end |
| 14005 | i = sub n 1 |
| 14006 | if ne get a_ar add get a_rb 49 i 1 |
| 14007 | note d2site 293|s_else: missing end; condition if ne get a_ar add get a_rb 49 i 1 |
| 14008 | put d2site 0 293 |
| 14009 | fail 15 |
| 14010 | end |
| 14011 | b = get oc 0 |
| 14012 | if ne get xtarget 0 0 |
| 14013 | note A terminated then-path needs no skip jump, particularly at a bare unit's final byte. |
| 14014 | if eq get dead 0 0 |
| 14015 | p = xbranch 14 |
| 14016 | end |
| 14017 | else |
| 14018 | emit 335544320 |
| 14019 | end |
| 14020 | patch19 get a_ar add get a_rb 50 i get oc 0 |
| 14021 | put a_ar add get a_rb 49 i 2 |
| 14022 | put a_ar add get a_rb 50 i b |
| 14023 | fz_else i |
| 14024 | nm_set get a_ar add get a_rb 54 i |
| 14025 | put held 0 get a_ar add get a_rb 55 i |
| 14026 | put a_ar add get a_rb 56 i get dead 0 |
| 14027 | put dead 0 0 |
| 14028 | eol |
| 14029 | end |
| 14030 | |
| 14031 | note lpcnt: the hidden counter check of a loop: CMP Xc, #N (C6.2.96) or CMP Xc, Xn (C6.2.97); B.HS trap |
| 14032 | note 4; ADD Xc, Xc, #1 (C6.2.5). om4 SW_NOB .. SW_G and the same in S_FOR. |
| 14033 | fn lpcnt c ulong n ulong to void |
| 14034 | if ne get xtarget 0 0 |
| 14035 | xcmp c n 1 |
| 14036 | trapc 2 4 |
| 14037 | xarith 33 5 c 1 1 c |
| 14038 | ret |
| 14039 | end |
| 14040 | if le n 4095 |
| 14041 | emit or or 4043309087 shl n 10 shl c 5 |
| 14042 | else |
| 14043 | m = alloc |
| 14044 | matconst m n |
| 14045 | emit or or 3942645791 shl c 5 shl m 16 |
| 14046 | end |
| 14047 | trapc 2 4 |
| 14048 | emit or or 2432697344 c shl c 5 |
| 14049 | end |
| 14050 | |
| 14051 | note lpmark: after pushb of a for in an OM-2 unit on AArch64 whose head ran no clause code (cphn 0): move its |
| 14052 | note test to the latch (lpback). br is the head's exit branch; the latch branches back to the word after it. |
| 14053 | note kk is K when K is a number, kr K's register + 1 when K is a value (0 for a number). |
| 14054 | fn lpmark br ulong kk ulong kr ulong to void |
| 14055 | if eq get om2 0 0 |
| 14056 | ret |
| 14057 | end |
| 14058 | if ne get cphn 0 0 |
| 14059 | ret |
| 14060 | end |
| 14061 | b = sub get nb 0 1 |
| 14062 | put a_ar add get a_rb 57 b add br 4 |
| 14063 | put a_ar add get a_rb 58 b kk |
| 14064 | put a_ar add get a_rb 59 b kr |
| 14065 | end |
| 14066 | |
| 14067 | note lpback: the latch test of a for whose test moved there (block b): CMP Xi, #K (C6.2.96), CMP Xi, Xk or |
| 14068 | note CMP Xi, X(matconst K) (C6.2.97), then B.LO (unsigned) or B.LT (signed) back to the first word after |
| 14069 | note the head's exit branch (C6.2.34). The head keeps its test for the first pass only; every later pass |
| 14070 | note is tested here, after the increment, so a pass runs one branch instead of two. When K needs a register |
| 14071 | note and none is free here (alloc would be error 12), the latch is B head (C6.2.35), as without the move. |
| 14072 | fn lpback b ulong to void |
| 14073 | r = get a_ar add get a_rb 52 b |
| 14074 | kr = get a_ar add get a_rb 59 b |
| 14075 | if ne kr 0 |
| 14076 | emit or or 3942645791 shl sub kr 1 16 shl r 5 |
| 14077 | else |
| 14078 | kk = get a_ar add get a_rb 58 b |
| 14079 | if le kk 4095 |
| 14080 | emit or or 4043309087 shl kk 10 shl r 5 |
| 14081 | else |
| 14082 | if ge add get npar 0 get nslot 0 16 |
| 14083 | back get a_ar add get a_rb 51 b |
| 14084 | ret |
| 14085 | end |
| 14086 | m = alloc |
| 14087 | matconst m kk |
| 14088 | emit or or 3942645791 shl r 5 shl m 16 |
| 14089 | end |
| 14090 | end |
| 14091 | cc = ulong 3 |
| 14092 | if ge get a_ar add get a_rb 53 b 6 |
| 14093 | cc = ulong 11 |
| 14094 | end |
| 14095 | emit or or 1409286144 shl bdisp get oc 0 get a_ar add get a_rb 57 b 19 5 cc |
| 14096 | end |
| 14097 | |
| 14098 | note s_while: while cond [bound N]: hidden counter = 0; head: cond false -> exit; counter >= N -> trap 4; |
| 14099 | note counter = counter + 1; body; B head. N is 1 .. 9223372036854775807 (error 8), 1000000 with no bound. om4 S_WHILE. |
| 14100 | fn s_while to void |
| 14101 | sn = get nn 0 |
| 14102 | sh = get held 0 |
| 14103 | c = alloc |
| 14104 | put held 0 get nslot 0 |
| 14105 | if ne get xtarget 0 0 |
| 14106 | matconst c 0 |
| 14107 | else |
| 14108 | emit or 3531603968 c |
| 14109 | end |
| 14110 | hd = get oc 0 |
| 14111 | cp_head skipln get cur 0 add get line 0 1 |
| 14112 | br = cond |
| 14113 | n = ulong 1000000 |
| 14114 | tok |
| 14115 | k = get tk 0 |
| 14116 | if and ne k 0 ne k 3 |
| 14117 | if ne k 1 |
| 14118 | note d2site 294|s_while: extra words after a complete statement; condition if ne k 1 |
| 14119 | put d2site 0 294 |
| 14120 | fail 5 |
| 14121 | end |
| 14122 | if gt get tl 0 8 |
| 14123 | note d2site 295|s_while: extra words after a complete statement; condition if gt get tl 0 8 |
| 14124 | put d2site 0 295 |
| 14125 | fail 5 |
| 14126 | end |
| 14127 | if ne kw get tw 0 70 |
| 14128 | note d2site 296|s_while: extra words after a complete statement; condition if ne kw get tw 0 70 |
| 14129 | put d2site 0 296 |
| 14130 | fail 5 |
| 14131 | end |
| 14132 | v = lenval 4 |
| 14133 | if ge sub v 1 9223372036854775807 |
| 14134 | note d2site 297|s_while: number out of range for its type or place; condition if ge sub v 1 9223372036854775807 |
| 14135 | put d2site 0 297 |
| 14136 | fail 8 |
| 14137 | end |
| 14138 | n = v |
| 14139 | eol |
| 14140 | end |
| 14141 | lpcnt c n |
| 14142 | pushb br 3 hd c 0 |
| 14143 | pushnh sn sh |
| 14144 | cp_skip |
| 14145 | end |
| 14146 | |
| 14147 | note sf_br: B.HS (unsigned) or B.GE (signed) to the loop exit, C6.2.34 (distance filled at end); returns |
| 14148 | note its place. om4 SF_BR. |
| 14149 | fn sf_br t ulong to ulong |
| 14150 | if ne get xtarget 0 0 |
| 14151 | if lt t 6 |
| 14152 | ret xbranch 2 |
| 14153 | end |
| 14154 | ret xbranch 10 |
| 14155 | end |
| 14156 | at = get oc 0 |
| 14157 | if lt t 6 |
| 14158 | emit 1409286146 |
| 14159 | else |
| 14160 | emit 1409286154 |
| 14161 | end |
| 14162 | ret at |
| 14163 | end |
| 14164 | |
| 14165 | note sf_num: for i T K with K a number: i = 0 (MOVZ, C6.2.285); head: CMP Xi, #K or Xk; B.HS/B.GE exit. |
| 14166 | note With `bound N` a hidden counter c = 0 is checked after the exit test, as in s_while. om4 SF_NUM .. SF_PUSH. |
| 14167 | note The optional `bound N` before the line's end: N a number or an integer constant, 1 .. |
| 14168 | note 9223372036854775807 (error 8, as s_while; 4 when N is missing); bn = 0 when no bound is written. |
| 14169 | fn sf_num w ulong t ulong kk ulong sn ulong sh ulong to void |
| 14170 | bn = ulong 0 |
| 14171 | if eq peekw 70 |
| 14172 | tok |
| 14173 | bn = lenval 4 |
| 14174 | if ge sub bn 1 9223372036854775807 |
| 14175 | note d2site 298|sf_num: number out of range for its type or place; condition if ge sub bn 1 9223372036854775807 |
| 14176 | put d2site 0 298 |
| 14177 | fail 8 |
| 14178 | end |
| 14179 | end |
| 14180 | if ne get xtarget 0 0 |
| 14181 | xfornum w t kk sn sh bn |
| 14182 | ret |
| 14183 | end |
| 14184 | eol |
| 14185 | i = alloc |
| 14186 | put held 0 get nslot 0 |
| 14187 | addname w i t 0 0 0 |
| 14188 | emit or 3531603968 i |
| 14189 | c = ulong 0 |
| 14190 | if ne bn 0 |
| 14191 | c = alloc |
| 14192 | put held 0 get nslot 0 |
| 14193 | emit or 3531603968 c |
| 14194 | end |
| 14195 | hd = get oc 0 |
| 14196 | cp_head get cur 0 get line 0 |
| 14197 | if le kk 4095 |
| 14198 | emit or or 4043309087 shl kk 10 shl i 5 |
| 14199 | else |
| 14200 | k = alloc |
| 14201 | matconst k kk |
| 14202 | emit or or 3942645791 shl i 5 shl k 16 |
| 14203 | end |
| 14204 | br = sf_br t |
| 14205 | if ne bn 0 |
| 14206 | lpcnt c bn |
| 14207 | end |
| 14208 | pushb br 4 hd i t |
| 14209 | lpmark br kk 0 |
| 14210 | pushnh sn sh |
| 14211 | cp_skip |
| 14212 | end |
| 14213 | |
| 14214 | note sf_val: for i T K with K a value of type T in register kr: i = 0; the hidden counter c = 0; head: CMP |
| 14215 | note Xi, Xk; B.HS/B.GE exit; the counter guard of a while: `bound N` (read as in sf_num), else 1000000. |
| 14216 | note om4 SF_VAL. |
| 14217 | fn sf_val w ulong t ulong kr ulong sn ulong sh ulong to void |
| 14218 | n = ulong 1000000 |
| 14219 | if eq peekw 70 |
| 14220 | tok |
| 14221 | n = lenval 4 |
| 14222 | if ge sub n 1 9223372036854775807 |
| 14223 | note d2site 299|sf_val: number out of range for its type or place; condition if ge sub n 1 9223372036854775807 |
| 14224 | put d2site 0 299 |
| 14225 | fail 8 |
| 14226 | end |
| 14227 | end |
| 14228 | if ne get xtarget 0 0 |
| 14229 | xforval w t kr sn sh n |
| 14230 | ret |
| 14231 | end |
| 14232 | eol |
| 14233 | i = alloc |
| 14234 | put held 0 get nslot 0 |
| 14235 | addname w i t 0 0 0 |
| 14236 | emit or 3531603968 i |
| 14237 | c = alloc |
| 14238 | put held 0 get nslot 0 |
| 14239 | emit or 3531603968 c |
| 14240 | hd = get oc 0 |
| 14241 | cp_head get cur 0 get line 0 |
| 14242 | emit or or 3942645791 shl kr 16 shl i 5 |
| 14243 | br = sf_br t |
| 14244 | lpcnt c n |
| 14245 | pushb br 4 hd i t |
| 14246 | lpmark br 0 add kr 1 |
| 14247 | pushnh sn sh |
| 14248 | cp_skip |
| 14249 | end |
| 14250 | |
| 14251 | note s_for: for i T K [bound N]: i = 0; head: not i < K -> exit; body; latch i = add i 1; B head. K a number, |
| 14252 | note or a value of type T: a name is read at every pass, another value once before the loop. More than N |
| 14253 | note passes (default 1000000 for a value K, no limit for a number K) trap 4. om4 S_FOR. |
| 14254 | fn s_for to void |
| 14255 | sn = get nn 0 |
| 14256 | sh = get held 0 |
| 14257 | tok |
| 14258 | if eq get tk 0 0 |
| 14259 | note d2site 300|s_for: the line ends where a word or value is needed; condition if eq get tk 0 0 |
| 14260 | put d2site 0 300 |
| 14261 | fail 4 |
| 14262 | end |
| 14263 | if ne get tk 0 1 |
| 14264 | note d2site 301|s_for: syntax: unknown or misplaced word; condition if ne get tk 0 1 |
| 14265 | put d2site 0 301 |
| 14266 | fail 16 |
| 14267 | end |
| 14268 | if gt get tl 0 63 |
| 14269 | note d2site 302|s_for: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63 |
| 14270 | put d2site 0 302 |
| 14271 | fail 13 |
| 14272 | end |
| 14273 | w = get tw 0 |
| 14274 | if ne kw w 0 |
| 14275 | note d2site 303|s_for: syntax: unknown or misplaced word; condition if ne kw w 0 |
| 14276 | put d2site 0 303 |
| 14277 | fail 16 |
| 14278 | end |
| 14279 | newname w get tl 0 get ts 0 |
| 14280 | t = typeword |
| 14281 | if or eq t 1 ge t 10 |
| 14282 | note d2site 304|s_for: type mismatch; condition if or eq t 1 ge t 10 |
| 14283 | put d2site 0 304 |
| 14284 | fail 7 |
| 14285 | end |
| 14286 | tok |
| 14287 | if eq get tk 0 0 |
| 14288 | note d2site 305|s_for: the line ends where a word or value is needed; condition if eq get tk 0 0 |
| 14289 | put d2site 0 305 |
| 14290 | fail 4 |
| 14291 | end |
| 14292 | if eq get tk 0 2 |
| 14293 | range get tw 0 t get tbig 0 |
| 14294 | if ne get om2 0 0 |
| 14295 | kk = get tw 0 |
| 14296 | if eq peekw 181 |
| 14297 | s_unroll w t kk sn sh |
| 14298 | ret |
| 14299 | end |
| 14300 | put tw 0 kk |
| 14301 | end |
| 14302 | sf_num w t get tw 0 sn sh |
| 14303 | ret |
| 14304 | end |
| 14305 | rdval 1 t 255 0 |
| 14306 | if ne get rt 0 t |
| 14307 | note d2site 306|s_for: type mismatch; condition if ne get rt 0 t |
| 14308 | put d2site 0 306 |
| 14309 | fail 7 |
| 14310 | end |
| 14311 | if ne get om2 0 0 |
| 14312 | if eq peekw 181 |
| 14313 | note d2site 307|s_for: syntax: unknown or misplaced word; condition if eq peekw 181 |
| 14314 | put d2site 0 307 |
| 14315 | fail 16 |
| 14316 | end |
| 14317 | end |
| 14318 | if eq get rk 0 3 |
| 14319 | sf_num w t get rv 0 sn sh |
| 14320 | ret |
| 14321 | end |
| 14322 | kr = matreg get rk 0 get rv 0 get rt 0 |
| 14323 | sf_val w t kr sn sh |
| 14324 | end |
| 14325 | |
| 14326 | note ======== OM-2 section 4: unroll, inline, folding, the growth bound and trap-site records ======== |
| 14327 | note peekstar: 1 when the next word is `*` (an unsized array, OM-2), without reading it |
| 14328 | fn peekstar to ulong |
| 14329 | c0 = get cur 0 |
| 14330 | l0 = get line 0 |
| 14331 | a0 = get tka 0 |
| 14332 | b0 = get tkb 0 |
| 14333 | tok |
| 14334 | r = ulong 0 |
| 14335 | if and eq get tk 0 1 eq get tl 0 1 |
| 14336 | if eq get tw 0 42 |
| 14337 | r = ulong 1 |
| 14338 | end |
| 14339 | end |
| 14340 | put cur 0 c0 |
| 14341 | put line 0 l0 |
| 14342 | put tka 0 a0 |
| 14343 | put tkb 0 b0 |
| 14344 | ret r |
| 14345 | end |
| 14346 | |
| 14347 | note peekw: the keyword code of the next word (0 for anything else) without reading it |
| 14348 | fn peekw to ulong |
| 14349 | c0 = get cur 0 |
| 14350 | l0 = get line 0 |
| 14351 | a0 = get tka 0 |
| 14352 | b0 = get tkb 0 |
| 14353 | tok |
| 14354 | r = ulong 0 |
| 14355 | if eq get tk 0 1 |
| 14356 | if le get tl 0 8 |
| 14357 | r = kw get tw 0 |
| 14358 | end |
| 14359 | end |
| 14360 | put cur 0 c0 |
| 14361 | put line 0 l0 |
| 14362 | put tka 0 a0 |
| 14363 | put tkb 0 b0 |
| 14364 | ret r |
| 14365 | end |
| 14366 | |
| 14367 | note s_unroll: for i T K unroll (K a number 1..64, error 8 outside). i is a constant name (kind 9) bound to |
| 14368 | note 0..K-1 in turn; the body is read K times from its first line (s_unr). No branch is emitted. |
| 14369 | fn s_unroll w ulong t ulong kk ulong sn ulong sh ulong to void |
| 14370 | if or eq kk 0 gt kk 64 |
| 14371 | note d2site 308|s_unroll: number out of range for its type or place; condition if or eq kk 0 gt kk 64 |
| 14372 | put d2site 0 308 |
| 14373 | fail 8 |
| 14374 | end |
| 14375 | fuelc get line 0 kk |
| 14376 | tok |
| 14377 | eol |
| 14378 | addname w 0 t 0 9 0 |
| 14379 | n = get nb 0 |
| 14380 | pushb 0 5 0 sub get nn 0 1 t |
| 14381 | pushnh sn sh |
| 14382 | put a_ar add get a_rb 62 n get cur 0 |
| 14383 | put a_ar add get a_rb 63 n get line 0 |
| 14384 | put a_ar add get a_rb 64 n 0 |
| 14385 | put a_ar add get a_rb 65 n kk |
| 14386 | put a_ar add get a_rb 66 n get nn 0 |
| 14387 | put a_ar add get a_rb 67 n get held 0 |
| 14388 | put fzone 0 add get fzone 0 1 |
| 14389 | cp_head get cur 0 get line 0 |
| 14390 | cp_skip |
| 14391 | end |
| 14392 | |
| 14393 | note fuelc: charge n to the function's fuel at the construct on line ln, before anything of it expands; a |
| 14394 | note total above 65536 is error 14 on line ln (E14, E16) |
| 14395 | fn fuelc ln ulong n ulong to void |
| 14396 | if gt add get fuel 0 n 65536 |
| 14397 | put line 0 ln |
| 14398 | note d2site 309|fuelc: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if gt add get fuel 0 n 65536 |
| 14399 | put d2site 0 309 |
| 14400 | fail 14 |
| 14401 | end |
| 14402 | put fuel 0 add get fuel 0 n |
| 14403 | end |
| 14404 | |
| 14405 | note s_unr: the end of an unrolled body: read it again with the next value of i, or close the block |
| 14406 | fn s_unr i ulong to void |
| 14407 | eol |
| 14408 | it = add get a_ar add get a_rb 64 i 1 |
| 14409 | if lt it get a_ar add get a_rb 65 i |
| 14410 | put a_ar add get a_rb 64 i it |
| 14411 | put a_ar add get a_rb 8 get a_ar add get a_rb 52 i it |
| 14412 | nm_set get a_ar add get a_rb 66 i |
| 14413 | put held 0 get a_ar add get a_rb 67 i |
| 14414 | put nslot 0 get a_ar add get a_rb 67 i |
| 14415 | put dead 0 0 |
| 14416 | put cur 0 get a_ar add get a_rb 62 i |
| 14417 | put line 0 get a_ar add get a_rb 63 i |
| 14418 | cp_head get cur 0 get line 0 |
| 14419 | cp_skip |
| 14420 | ret |
| 14421 | end |
| 14422 | put a_ar add get a_rb 64 i it |
| 14423 | put a_ar add get a_rb 8 get a_ar add get a_rb 52 i it |
| 14424 | nm_set get a_ar add get a_rb 66 i |
| 14425 | put nslot 0 get a_ar add get a_rb 67 i |
| 14426 | cp_head get a_ar add get a_rb 62 i get a_ar add get a_rb 63 i |
| 14427 | put nb 0 i |
| 14428 | nm_set get a_ar add get a_rb 54 i |
| 14429 | put held 0 get a_ar add get a_rb 55 i |
| 14430 | put dead 0 0 |
| 14431 | put fzone 0 sub get fzone 0 1 |
| 14432 | end |
| 14433 | |
| 14434 | note fn_tail: the end of a fn line: an optional inline (OM-2), then the line ends; records the body start |
| 14435 | fn fn_tail f ulong to void |
| 14436 | tok |
| 14437 | k = get tk 0 |
| 14438 | if eq k 1 |
| 14439 | if ne get om2 0 0 |
| 14440 | if le get tl 0 8 |
| 14441 | if eq kw get tw 0 182 |
| 14442 | a_pc 27 f 1 |
| 14443 | eol |
| 14444 | put a_ar add get a_rb 28 f get cur 0 |
| 14445 | put a_ar add get a_rb 29 f get line 0 |
| 14446 | ret |
| 14447 | end |
| 14448 | end |
| 14449 | end |
| 14450 | end |
| 14451 | if and ne k 0 ne k 3 |
| 14452 | put dexp 0 6 |
| 14453 | note d2site 310|fn_tail: extra words after a complete statement; condition if and ne k 0 ne k 3 |
| 14454 | put d2site 0 310 |
| 14455 | fail 5 |
| 14456 | end |
| 14457 | put a_ar add get a_rb 28 f get cur 0 |
| 14458 | put a_ar add get a_rb 29 f get line 0 |
| 14459 | end |
| 14460 | |
| 14461 | note inl_call: a call of an inline function fe (index + 1): the result register first (dst, or the next |
| 14462 | note pool slot), then the arguments left to right exactly as for a call, then the body in place. |
| 14463 | fn inl_call fe ulong dst ulong to void |
| 14464 | s0 = get nslot 0 |
| 14465 | rres = ulong 255 |
| 14466 | ns = s0 |
| 14467 | if ne uchar get a_ar add get a_rb 23 sub fe 1 12 |
| 14468 | if eq dst 255 |
| 14469 | rres = alloc |
| 14470 | ns = add s0 1 |
| 14471 | else |
| 14472 | rres = dst |
| 14473 | end |
| 14474 | end |
| 14475 | cb = add mul get depth 0 32 8 |
| 14476 | np = ulong uchar get a_ar add get a_rb 24 sub fe 1 |
| 14477 | put a_ar add get a_rb 77 add cb 18 np |
| 14478 | a_p 77 add cb 19 get nslot 0 |
| 14479 | i = ulong 0 |
| 14480 | while lt i np |
| 14481 | p = add mul sub fe 1 6 i |
| 14482 | if eq a_gu 37 p 0 |
| 14483 | rdval 0 ulong a_gu 35 p 255 0 |
| 14484 | ca_scal p add cb mul i 3 |
| 14485 | else |
| 14486 | if ge a_gu 37 p 6 |
| 14487 | ca_st fe i cb |
| 14488 | else |
| 14489 | ca_arr fe i cb |
| 14490 | end |
| 14491 | end |
| 14492 | i = add i 1 |
| 14493 | end |
| 14494 | inl_body fe cb ns rres |
| 14495 | end |
| 14496 | |
| 14497 | note inl_par: bind parameter i of inline function fe to its argument in frame cb. A scalar held in a |
| 14498 | note temporary register (pool index hb or above) is taken as it is; any other scalar is copied to a new |
| 14499 | note register. An array or struct takes its base register; a text's address is loaded into one. An |
| 14500 | note unsized array parameter also takes its count register, or a new one holding a number count. |
| 14501 | fn inl_par fe ulong cb ulong i ulong hb ulong to void |
| 14502 | p = add mul sub fe 1 6 i |
| 14503 | q = add cb mul i 3 |
| 14504 | k = get a_ar add get a_rb 77 q |
| 14505 | v = get a_ar add get a_rb 77 add q 1 |
| 14506 | r = ulong 0 |
| 14507 | if eq a_gu 37 p 0 |
| 14508 | if and eq k 1 ge regidx v hb |
| 14509 | r = v |
| 14510 | else |
| 14511 | r = alloc |
| 14512 | force k v ulong a_gu 35 p r |
| 14513 | end |
| 14514 | else |
| 14515 | if eq k 5 |
| 14516 | r = v |
| 14517 | else |
| 14518 | r = alloc |
| 14519 | matconst r v |
| 14520 | end |
| 14521 | end |
| 14522 | inl_add p r |
| 14523 | if eq pwid p 2 |
| 14524 | inl_lr add mul div cb 32 6 i |
| 14525 | end |
| 14526 | fz_inl p a_g 77 add q 2 |
| 14527 | end |
| 14528 | |
| 14529 | note inl_lr: the unsized parameter name just added gets the count of argument ux (ul_k / ul_v): its |
| 14530 | note register, or a new one holding the number |
| 14531 | fn inl_lr ux ulong to void |
| 14532 | lr = get a_ar add get a_rb 80 ux |
| 14533 | if ne get a_ar add get a_rb 79 ux 1 |
| 14534 | lr = alloc |
| 14535 | matconst lr get a_ar add get a_rb 80 ux |
| 14536 | end |
| 14537 | a_pc 14 sub get nn 0 1 uchar lr |
| 14538 | end |
| 14539 | |
| 14540 | note inl_add: the name of parameter slot p on register r (a view struct is name kind 8, an edit one 7) |
| 14541 | fn inl_add p ulong r ulong to void |
| 14542 | pk = ulong uchar get a_ar add get a_rb 37 p |
| 14543 | if eq pk 0 |
| 14544 | addname a_g 34 p r ulong a_gu 35 p 0 0 0 |
| 14545 | ret |
| 14546 | end |
| 14547 | nk = pk |
| 14548 | if eq pk 6 |
| 14549 | nk = ulong 8 |
| 14550 | end |
| 14551 | addname a_g 34 p r ulong a_gu 35 p a_g 36 p nk 0 |
| 14552 | a_pc 12 sub get nn 0 1 uchar get a_ar add get a_rb 38 p |
| 14553 | end |
| 14554 | |
| 14555 | note inl_edge: record the call-graph edge (expanding function -> inline function) once (arena group 17) |
| 14556 | fn inl_edge a ulong b ulong to void |
| 14557 | n = get nie 0 |
| 14558 | j = ulong 0 |
| 14559 | go = true |
| 14560 | while go |
| 14561 | m = ulong 0 |
| 14562 | while and go lt m 999999 |
| 14563 | if ge j n |
| 14564 | go = false |
| 14565 | else |
| 14566 | if and eq a_g 75 j a eq a_g 76 j b |
| 14567 | ret |
| 14568 | end |
| 14569 | j = add j 1 |
| 14570 | end |
| 14571 | m = add m 1 |
| 14572 | end |
| 14573 | end |
| 14574 | if ge n get a_gp 17 |
| 14575 | a_need 17 n |
| 14576 | end |
| 14577 | put a_ar add get a_rb 75 n a |
| 14578 | put a_ar add get a_rb 76 n b |
| 14579 | put nie 0 add n 1 |
| 14580 | end |
| 14581 | |
| 14582 | note inl_body: at most 4 nested inline frames (error 14); an inline function reached again while it is |
| 14583 | note being inlined, or from its own body, is error 9. The caller's local names are hidden, the parameters |
| 14584 | note bound, and the body's lines compiled here until its end (s_inlx) closes the frame. |
| 14585 | note Each expansion costs one unit of the function's fuel (E14). |
| 14586 | fn inl_body fe ulong cb ulong ns ulong rres ulong to void |
| 14587 | lv = get inl 0 |
| 14588 | fuelc get line 0 1 |
| 14589 | if ge lv 4 |
| 14590 | note d2site 311|inl_body: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge lv 4 |
| 14591 | put d2site 0 311 |
| 14592 | fail 14 |
| 14593 | end |
| 14594 | if eq get curfn 0 fe |
| 14595 | note d2site 312|inl_body: word or declaration in a place that does not allow it; condition if eq get curfn 0 fe |
| 14596 | put d2site 0 312 |
| 14597 | fail 9 |
| 14598 | end |
| 14599 | j = ulong 0 |
| 14600 | while lt j lv |
| 14601 | if eq get il_fn j fe |
| 14602 | note d2site 313|inl_body: word or declaration in a place that does not allow it; condition if eq get il_fn j fe |
| 14603 | put d2site 0 313 |
| 14604 | fail 9 |
| 14605 | end |
| 14606 | j = add j 1 |
| 14607 | end |
| 14608 | inl_edge get curfn 0 fe |
| 14609 | put il_cur lv get cur 0 |
| 14610 | put il_line lv get line 0 |
| 14611 | put il_ret lv get curret 0 |
| 14612 | put il_nn lv get nn 0 |
| 14613 | put il_lo lv get nmlo 0 |
| 14614 | put il_held lv get held 0 |
| 14615 | put il_ns lv ns |
| 14616 | put il_res lv rres |
| 14617 | put il_fn lv fe |
| 14618 | put il_p0 lv get nilp 0 |
| 14619 | put il_fz lv get fz_n 0 |
| 14620 | inl_bind fe cb |
| 14621 | pushb 0 6 0 fe 0 |
| 14622 | pushnh get il_nn lv get il_held lv |
| 14623 | put inl 0 add lv 1 |
| 14624 | put fzone 0 add get fzone 0 1 |
| 14625 | put curret 0 ulong a_gu 23 sub fe 1 |
| 14626 | put dead 0 0 |
| 14627 | put cur 0 get a_ar add get a_rb 28 sub fe 1 |
| 14628 | put line 0 get a_ar add get a_rb 29 sub fe 1 |
| 14629 | cp_entry |
| 14630 | inl_run lv |
| 14631 | end |
| 14632 | |
| 14633 | note inl_bind: hide the caller's local names, bind the parameters, protect every register in use |
| 14634 | fn inl_bind fe ulong cb ulong to void |
| 14635 | hb = add get npar 0 get held 0 |
| 14636 | put nmlo 0 get nn 0 |
| 14637 | np = ulong uchar get a_ar add get a_rb 24 sub fe 1 |
| 14638 | i = ulong 0 |
| 14639 | while lt i np |
| 14640 | inl_par fe cb i hb |
| 14641 | i = add i 1 |
| 14642 | end |
| 14643 | put held 0 get nslot 0 |
| 14644 | end |
| 14645 | |
| 14646 | note inl_run: compile the inlined body's lines until its frame (level lv) is closed |
| 14647 | fn inl_run lv ulong to void |
| 14648 | go = true |
| 14649 | while go |
| 14650 | m = ulong 0 |
| 14651 | while and go lt m 999999 |
| 14652 | if ne stmt 0 |
| 14653 | note d2site 314|inl_run: missing end; condition if ne stmt 0 |
| 14654 | put d2site 0 314 |
| 14655 | fail 15 |
| 14656 | end |
| 14657 | if le get inl 0 lv |
| 14658 | go = false |
| 14659 | end |
| 14660 | m = add m 1 |
| 14661 | end |
| 14662 | end |
| 14663 | end |
| 14664 | |
| 14665 | note inlb: the B of an inlined ret, patched to the frame's end (arena group 16) |
| 14666 | fn inlb to void |
| 14667 | n = get nilp 0 |
| 14668 | if ge n get a_gp 16 |
| 14669 | a_need 16 n |
| 14670 | end |
| 14671 | put a_ar add get a_rb 74 n get oc 0 |
| 14672 | put nilp 0 add n 1 |
| 14673 | if ne get xtarget 0 0 |
| 14674 | p = xbranch 14 |
| 14675 | put a_ar add get a_rb 74 n p |
| 14676 | else |
| 14677 | emit 335544320 |
| 14678 | end |
| 14679 | put lastb 0 get oc 0 |
| 14680 | end |
| 14681 | |
| 14682 | note s_iret: ret inside an inlined body: the value into the frame's result register, then B to its end |
| 14683 | fn s_iret to void |
| 14684 | lv = sub get inl 0 1 |
| 14685 | r = get curret 0 |
| 14686 | if eq r 12 |
| 14687 | eol |
| 14688 | cp_post 0 0 r |
| 14689 | inlb |
| 14690 | dead1 |
| 14691 | ret |
| 14692 | end |
| 14693 | if and ne get cfhas get inl 0 0 eq get crel 0 0 |
| 14694 | rdval 0 r 255 0 |
| 14695 | if ne get rt 0 r |
| 14696 | note d2site 315|s_iret: type mismatch; condition if ne get rt 0 r |
| 14697 | put d2site 0 315 |
| 14698 | fail 7 |
| 14699 | end |
| 14700 | rr = matreg get rk 0 get rv 0 r |
| 14701 | eol |
| 14702 | cp_post 1 rr r |
| 14703 | force 1 rr r get il_res lv |
| 14704 | else |
| 14705 | rdval 0 r get il_res lv 0 |
| 14706 | if ne get rt 0 r |
| 14707 | note d2site 316|s_iret: type mismatch; condition if ne get rt 0 r |
| 14708 | put d2site 0 316 |
| 14709 | fail 7 |
| 14710 | end |
| 14711 | force get rk 0 get rv 0 get rt 0 get il_res lv |
| 14712 | eol |
| 14713 | cp_post 1 get il_res lv r |
| 14714 | end |
| 14715 | inlb |
| 14716 | dead1 |
| 14717 | end |
| 14718 | |
| 14719 | note s_inlx: the end of an inlined body: a value function must not reach it (error 18). A last ret's B |
| 14720 | note that is the last word, with no branch patched to the place after it, is taken back; the other rets |
| 14721 | note branch here. The caller's line, names, registers and return type come back; the result is in rk/rv/rt. |
| 14722 | fn s_inlx i ulong to void |
| 14723 | eol |
| 14724 | lv = sub get inl 0 1 |
| 14725 | fe = get il_fn lv |
| 14726 | if eq get dead 0 0 |
| 14727 | if ne uchar get a_ar add get a_rb 23 sub fe 1 12 |
| 14728 | note d2site 317|s_inlx: a function with a result can reach its end; condition if ne uchar get a_ar add get a_rb 23 sub fe 1 12 |
| 14729 | put d2site 0 317 |
| 14730 | fail 18 |
| 14731 | end |
| 14732 | cp_post 0 0 12 |
| 14733 | end |
| 14734 | inl_pat get il_p0 lv |
| 14735 | put nb 0 i |
| 14736 | put cur 0 get il_cur lv |
| 14737 | put line 0 get il_line lv |
| 14738 | put curret 0 get il_ret lv |
| 14739 | nm_set get il_nn lv |
| 14740 | put nmlo 0 get il_lo lv |
| 14741 | put held 0 get il_held lv |
| 14742 | put nslot 0 get il_ns lv |
| 14743 | put dead 0 0 |
| 14744 | put inl 0 lv |
| 14745 | put fzone 0 sub get fzone 0 1 |
| 14746 | put fz_n 0 get il_fz lv |
| 14747 | put rk 0 1 |
| 14748 | put rv 0 get il_res lv |
| 14749 | put rt 0 ulong uchar get a_ar add get a_rb 23 sub fe 1 |
| 14750 | end |
| 14751 | |
| 14752 | note inl_pat: patch the frame's ret B words (from p0) to here, after taking back a last one that is the |
| 14753 | note last word and that no branch was patched past |
| 14754 | fn inl_pat p0 ulong to void |
| 14755 | n = get nilp 0 |
| 14756 | o = get oc 0 |
| 14757 | if and ne get dead 0 0 gt n p0 |
| 14758 | if eq get lastb 0 o |
| 14759 | if ne get tgoc 0 o |
| 14760 | if eq get a_ar add get a_rb 74 sub n 1 sub o 4 |
| 14761 | put oc 0 sub o 4 |
| 14762 | n = sub n 1 |
| 14763 | end |
| 14764 | end |
| 14765 | end |
| 14766 | end |
| 14767 | j = p0 |
| 14768 | go = true |
| 14769 | while go |
| 14770 | m = ulong 0 |
| 14771 | while and go lt m 999999 |
| 14772 | if ge j n |
| 14773 | go = false |
| 14774 | else |
| 14775 | patch26 a_g 74 j get oc 0 |
| 14776 | j = add j 1 |
| 14777 | end |
| 14778 | m = add m 1 |
| 14779 | end |
| 14780 | end |
| 14781 | put nilp 0 p0 |
| 14782 | end |
| 14783 | |
| 14784 | note ---- folding (only while fzone is above 0): an operation on two typed numbers is computed with OM-1 |
| 14785 | note arithmetic: unsigned wraps to its width, signed results are sign-extended; an operation that would |
| 14786 | note trap (signed overflow, divide by 0, a shift or rotate amount at or above the width) is not folded. |
| 14787 | fn fmask w ulong to ulong |
| 14788 | if ge w 64 |
| 14789 | ret not ulong 0 |
| 14790 | end |
| 14791 | ret sub shl ulong 1 w 1 |
| 14792 | end |
| 14793 | |
| 14794 | fn fasr x ulong s ulong to ulong |
| 14795 | if eq shr x 63 0 |
| 14796 | ret shr x s |
| 14797 | end |
| 14798 | ret not shr not x s |
| 14799 | end |
| 14800 | |
| 14801 | fn fsext r ulong w ulong to ulong |
| 14802 | if ge w 64 |
| 14803 | ret r |
| 14804 | end |
| 14805 | ret fasr shl r sub 64 w sub 64 w |
| 14806 | end |
| 14807 | |
| 14808 | fn fyes v ulong t ulong to void |
| 14809 | put fval 0 v |
| 14810 | put fty 0 t |
| 14811 | put fok 0 1 |
| 14812 | end |
| 14813 | |
| 14814 | fn fb_cmp op ulong sg ulong a ulong b ulong to void |
| 14815 | x = a |
| 14816 | y = b |
| 14817 | if ne sg 0 |
| 14818 | x = xor a shl ulong 1 63 |
| 14819 | y = xor b shl ulong 1 63 |
| 14820 | end |
| 14821 | r = false |
| 14822 | if eq op 43 |
| 14823 | r = eq x y |
| 14824 | end |
| 14825 | if eq op 44 |
| 14826 | r = ne x y |
| 14827 | end |
| 14828 | if eq op 45 |
| 14829 | r = lt x y |
| 14830 | end |
| 14831 | if eq op 46 |
| 14832 | r = le x y |
| 14833 | end |
| 14834 | if eq op 47 |
| 14835 | r = gt x y |
| 14836 | end |
| 14837 | if eq op 48 |
| 14838 | r = ge x y |
| 14839 | end |
| 14840 | v = ulong 0 |
| 14841 | if r |
| 14842 | v = ulong 1 |
| 14843 | end |
| 14844 | fyes v 1 |
| 14845 | end |
| 14846 | |
| 14847 | fn fb_arith op ulong ty ulong w ulong sg ulong a ulong b ulong to void |
| 14848 | r = ulong 0 |
| 14849 | if eq op 33 |
| 14850 | r = add a b |
| 14851 | end |
| 14852 | if eq op 34 |
| 14853 | r = sub a b |
| 14854 | end |
| 14855 | if eq op 35 |
| 14856 | if ne sg 0 |
| 14857 | if ge add a shl ulong 1 31 shl ulong 1 32 |
| 14858 | ret |
| 14859 | end |
| 14860 | if ge add b shl ulong 1 31 shl ulong 1 32 |
| 14861 | ret |
| 14862 | end |
| 14863 | end |
| 14864 | r = mul a b |
| 14865 | end |
| 14866 | if eq sg 0 |
| 14867 | fyes and r fmask w ty |
| 14868 | ret |
| 14869 | end |
| 14870 | if eq w 64 |
| 14871 | if eq op 33 |
| 14872 | if ne shr and xor a r xor b r 63 0 |
| 14873 | ret |
| 14874 | end |
| 14875 | end |
| 14876 | if eq op 34 |
| 14877 | if ne shr and xor a b xor a r 63 0 |
| 14878 | ret |
| 14879 | end |
| 14880 | end |
| 14881 | fyes r ty |
| 14882 | ret |
| 14883 | end |
| 14884 | if ne fsext r w r |
| 14885 | ret |
| 14886 | end |
| 14887 | fyes r ty |
| 14888 | end |
| 14889 | |
| 14890 | fn fb_div op ulong ty ulong w ulong sg ulong a ulong b ulong to void |
| 14891 | if eq b 0 |
| 14892 | ret |
| 14893 | end |
| 14894 | if eq sg 0 |
| 14895 | if eq op 36 |
| 14896 | fyes div a b ty |
| 14897 | else |
| 14898 | fyes rem a b ty |
| 14899 | end |
| 14900 | ret |
| 14901 | end |
| 14902 | na = shr a 63 |
| 14903 | sb = shr b 63 |
| 14904 | ma = a |
| 14905 | if ne na 0 |
| 14906 | ma = sub 0 a |
| 14907 | end |
| 14908 | mb = b |
| 14909 | if ne sb 0 |
| 14910 | mb = sub 0 b |
| 14911 | end |
| 14912 | if eq op 37 |
| 14913 | rr = rem ma mb |
| 14914 | if ne na 0 |
| 14915 | rr = sub 0 rr |
| 14916 | end |
| 14917 | fyes rr ty |
| 14918 | ret |
| 14919 | end |
| 14920 | if eq w 64 |
| 14921 | if eq a shl ulong 1 63 |
| 14922 | if eq b not ulong 0 |
| 14923 | ret |
| 14924 | end |
| 14925 | end |
| 14926 | end |
| 14927 | q = div ma mb |
| 14928 | if ne xor na sb 0 |
| 14929 | q = sub 0 q |
| 14930 | end |
| 14931 | if ne fsext q w q |
| 14932 | ret |
| 14933 | end |
| 14934 | fyes q ty |
| 14935 | end |
| 14936 | |
| 14937 | fn fb_shift op ulong ty ulong w ulong sg ulong a ulong b ulong to void |
| 14938 | if ge b w |
| 14939 | ret |
| 14940 | end |
| 14941 | if eq op 42 |
| 14942 | if eq sg 0 |
| 14943 | fyes shr a b ty |
| 14944 | else |
| 14945 | fyes fasr a b ty |
| 14946 | end |
| 14947 | ret |
| 14948 | end |
| 14949 | r = shl a b |
| 14950 | if eq sg 0 |
| 14951 | fyes and r fmask w ty |
| 14952 | ret |
| 14953 | end |
| 14954 | if eq w 64 |
| 14955 | if ne fasr r b a |
| 14956 | ret |
| 14957 | end |
| 14958 | fyes r ty |
| 14959 | ret |
| 14960 | end |
| 14961 | if ne fsext r w r |
| 14962 | ret |
| 14963 | end |
| 14964 | fyes r ty |
| 14965 | end |
| 14966 | |
| 14967 | fn fb_rot op ulong ty ulong w ulong a ulong b ulong to void |
| 14968 | if ge b w |
| 14969 | ret |
| 14970 | end |
| 14971 | s = b |
| 14972 | if and eq op 60 ne s 0 |
| 14973 | s = sub w s |
| 14974 | end |
| 14975 | if eq s 0 |
| 14976 | fyes a ty |
| 14977 | ret |
| 14978 | end |
| 14979 | fyes and or shr a s shl a sub w s fmask w ty |
| 14980 | end |
| 14981 | |
| 14982 | note foldbin: op on the typed numbers a, b of type ty (b's own type for a shift); fok 1 when folded |
| 14983 | fn foldbin op ulong ty ulong a ulong b ulong to void |
| 14984 | put fok 0 0 |
| 14985 | if or eq ty 0 ge ty 10 |
| 14986 | ret |
| 14987 | end |
| 14988 | sg = ulong 0 |
| 14989 | if ge ty 6 |
| 14990 | sg = ulong 1 |
| 14991 | end |
| 14992 | if and ge op 43 le op 48 |
| 14993 | fb_cmp op sg a b |
| 14994 | ret |
| 14995 | end |
| 14996 | if and ge op 38 le op 40 |
| 14997 | r = and a b |
| 14998 | if eq op 39 |
| 14999 | r = or a b |
| 15000 | end |
| 15001 | if eq op 40 |
| 15002 | r = xor a b |
| 15003 | end |
| 15004 | fyes r ty |
| 15005 | ret |
| 15006 | end |
| 15007 | if eq ty 1 |
| 15008 | ret |
| 15009 | end |
| 15010 | w = twid ty |
| 15011 | if le op 35 |
| 15012 | fb_arith op ty w sg a b |
| 15013 | ret |
| 15014 | end |
| 15015 | if le op 37 |
| 15016 | fb_div op ty w sg a b |
| 15017 | ret |
| 15018 | end |
| 15019 | if le op 42 |
| 15020 | fb_shift op ty w sg a b |
| 15021 | ret |
| 15022 | end |
| 15023 | if or eq op 59 eq op 60 |
| 15024 | if le ty 5 |
| 15025 | fb_rot op ty w a b |
| 15026 | end |
| 15027 | end |
| 15028 | end |
| 15029 | |
| 15030 | note foldun: neg (49) / not (50) of the typed number a |
| 15031 | fn foldun c ulong ty ulong a ulong to void |
| 15032 | put fok 0 0 |
| 15033 | if or eq ty 0 ge ty 10 |
| 15034 | ret |
| 15035 | end |
| 15036 | if eq c 50 |
| 15037 | if eq ty 1 |
| 15038 | fyes xor a 1 ty |
| 15039 | ret |
| 15040 | end |
| 15041 | if lt ty 6 |
| 15042 | fyes and not a fmask twid ty ty |
| 15043 | ret |
| 15044 | end |
| 15045 | fyes not a ty |
| 15046 | ret |
| 15047 | end |
| 15048 | if eq ty 1 |
| 15049 | ret |
| 15050 | end |
| 15051 | r = sub 0 a |
| 15052 | if lt ty 6 |
| 15053 | fyes and r fmask twid ty ty |
| 15054 | ret |
| 15055 | end |
| 15056 | w = twid ty |
| 15057 | if eq w 64 |
| 15058 | if eq a shl ulong 1 63 |
| 15059 | ret |
| 15060 | end |
| 15061 | fyes r ty |
| 15062 | ret |
| 15063 | end |
| 15064 | if ne fsext r w r |
| 15065 | ret |
| 15066 | end |
| 15067 | fyes r ty |
| 15068 | end |
| 15069 | |
| 15070 | note ---- omc-site records (om2 diag): one per runtime trap site, in emission order, after the artifact |
| 15071 | note on stderr: omc-site 1 line=N iter=k, k the counters of the open unrolled loops outer to inner |
| 15072 | note joined by '.', or '-'. |
| 15073 | fn siteb b ulong to void |
| 15074 | n = get nsite 0 |
| 15075 | if ge n get a_gp 2 |
| 15076 | a_need 2 n |
| 15077 | end |
| 15078 | a_bput 2 n uchar b |
| 15079 | put nsite 0 add n 1 |
| 15080 | end |
| 15081 | |
| 15082 | fn sitew w ulong n ulong to void |
| 15083 | i = ulong 0 |
| 15084 | x = w |
| 15085 | while lt i n |
| 15086 | siteb and x 255 |
| 15087 | x = shr x 8 |
| 15088 | i = add i 1 |
| 15089 | end |
| 15090 | end |
| 15091 | |
| 15092 | fn siten v ulong to void |
| 15093 | d = new uchar 20 0 |
| 15094 | i = ulong 0 |
| 15095 | x = v |
| 15096 | put d 0 uchar add rem x 10 48 |
| 15097 | x = div x 10 |
| 15098 | i = add i 1 |
| 15099 | while gt x 0 |
| 15100 | put d i uchar add rem x 10 48 |
| 15101 | x = div x 10 |
| 15102 | i = add i 1 |
| 15103 | end |
| 15104 | j = i |
| 15105 | while gt j 0 |
| 15106 | j = sub j 1 |
| 15107 | siteb ulong get d j |
| 15108 | end |
| 15109 | end |
| 15110 | |
| 15111 | fn siterec to void |
| 15112 | sitew 7310584038532803951 8 |
| 15113 | sitew 4424063608026050848 8 |
| 15114 | siten add get line 0 get lbase 0 |
| 15115 | sitew 67561537693984 6 |
| 15116 | any = false |
| 15117 | j = ulong 0 |
| 15118 | while lt j get nb 0 |
| 15119 | if eq get a_ar add get a_rb 49 j 5 |
| 15120 | if any |
| 15121 | siteb 46 |
| 15122 | end |
| 15123 | siten get a_ar add get a_rb 64 j |
| 15124 | any = true |
| 15125 | end |
| 15126 | j = add j 1 |
| 15127 | end |
| 15128 | if not any |
| 15129 | siteb 45 |
| 15130 | end |
| 15131 | siteb 10 |
| 15132 | end |
| 15133 | |
| 15134 | fn sitesout to void |
| 15135 | z = a_out 2 2 0 get nsite 0 |
| 15136 | end |
| 15137 | |
| 15138 | note finish: end of a function: a function that needs a value must not reach its end (error 18), a void |
| 15139 | note one returns; then the trap stubs of the sites no island took (stubs). om4 FINISH. |
| 15140 | fn finish to void |
| 15141 | if ne get xtarget 0 0 |
| 15142 | xfinish |
| 15143 | ret |
| 15144 | end |
| 15145 | eol |
| 15146 | if eq get dead 0 0 |
| 15147 | if ne get curret 0 12 |
| 15148 | note d2site 318|finish: a function with a result can reach its end; condition if ne get curret 0 12 |
| 15149 | put d2site 0 318 |
| 15150 | fail 18 |
| 15151 | end |
| 15152 | cp_post 0 0 12 |
| 15153 | epi |
| 15154 | end |
| 15155 | nt0 = get nt 0 |
| 15156 | p0 = get tpend 0 |
| 15157 | if lt p0 nt0 |
| 15158 | stubs p0 nt0 |
| 15159 | end |
| 15160 | put tpend 0 nt0 |
| 15161 | if ne get objmode 0 0 |
| 15162 | if or ne get osbad 0 0 ne get osp 0 0 |
| 15163 | note d2site 628|finish: word or declaration in a place that does not allow it; condition if or ne get osbad 0 0 ne get osp 0 0 |
| 15164 | put d2site 0 628 |
| 15165 | fail 9 |
| 15166 | end |
| 15167 | a_p 86 sub get curfn 0 1 add get stkbytes 0 get osmax 0 |
| 15168 | end |
| 15169 | put curret 0 0 |
| 15170 | nm_set get nglob 0 |
| 15171 | put curfn 0 0 |
| 15172 | put nbrk 0 0 |
| 15173 | put ncont 0 0 |
| 15174 | end |
| 15175 | |
| 15176 | note stubs: the trap stubs of trap sites p .. n - 1: shared tail, function mode MOV X0, X7; LDR X16, |
| 15177 | note [X7, #16]; BR X16 (C6.2.282, C6.2.216, C6.2.46: OscRt.trap); program mode ADD X0, X1, #100; MOVZ X8, |
| 15178 | note #93; SVC #0 (exit 100 + code). Per trap code used: MOVZ X1, #code (C6.2.285); B tail. Each site's |
| 15179 | note B.cond is patched to its code's stub. om4 FINISH, for the sites of a whole function. |
| 15180 | fn stubs p ulong n ulong to void |
| 15181 | tail = get oc 0 |
| 15182 | if eq get progmode 0 0 |
| 15183 | emit 2852586464 |
| 15184 | emit 4181723376 |
| 15185 | emit 3592356352 |
| 15186 | else |
| 15187 | if ne get xefa 0 0 |
| 15188 | note a64efi: ADD X0, X1, #100; ORR X0, X0, #2^63 (C6.2.240); B to the shared firmware return (aefx) |
| 15189 | emit 2432798752 |
| 15190 | emit 2990604288 |
| 15191 | emit or 335544320 bdisp get oc 0 520 26 |
| 15192 | else |
| 15193 | emit 2432798752 |
| 15194 | emit 3531606952 |
| 15195 | emit 3556769793 |
| 15196 | end |
| 15197 | end |
| 15198 | code = ulong 1 |
| 15199 | while le code 14 |
| 15200 | st = ulong 0 |
| 15201 | j = p |
| 15202 | go = true |
| 15203 | while go |
| 15204 | m = ulong 0 |
| 15205 | while and go lt m 999999 |
| 15206 | if ge j n |
| 15207 | go = false |
| 15208 | else |
| 15209 | if eq a_g 45 j code |
| 15210 | if eq st 0 |
| 15211 | st = get oc 0 |
| 15212 | emit or 3531603969 shl code 5 |
| 15213 | back tail |
| 15214 | end |
| 15215 | patch19 a_g 44 j st |
| 15216 | end |
| 15217 | j = add j 1 |
| 15218 | end |
| 15219 | m = add m 1 |
| 15220 | end |
| 15221 | end |
| 15222 | code = add code 1 |
| 15223 | end |
| 15224 | end |
| 15225 | |
| 15226 | note island: a B.cond reaches 1 MiB (19-bit word field), and a function's stubs used to sit only at its |
| 15227 | note end. When the oldest site no stub was patched to yet is 512 KiB back, B over a group of stubs here |
| 15228 | note and patch the waiting sites to it (stubs), so a function of any length keeps every trap branch in |
| 15229 | note reach. Only between lines of a function body (stmt: AArch64, not IR mode, no open inline frame, so |
| 15230 | note never inside a contract's evaluation, which may expand an inline function and then erase its code) |
| 15231 | note and outside every if, else, while and for (open unrolled bodies only, which no branch spans): an |
| 15232 | note island never lengthens a block, so every block keeps the branch spans it had (an if or loop body over |
| 15233 | note 1 MiB stays error 24, as before). A function whose sites never wait that long compiles as before. |
| 15234 | fn island to void |
| 15235 | p = get tpend 0 |
| 15236 | n = get nt 0 |
| 15237 | if ge p n |
| 15238 | ret |
| 15239 | end |
| 15240 | if lt sub get oc 0 get a_ar add get a_rb 44 p 524288 |
| 15241 | ret |
| 15242 | end |
| 15243 | i = ulong 0 |
| 15244 | go = true |
| 15245 | while go |
| 15246 | m = ulong 0 |
| 15247 | while and go lt m 999999 |
| 15248 | if ge i get nb 0 |
| 15249 | go = false |
| 15250 | else |
| 15251 | k = get a_ar add get a_rb 49 i |
| 15252 | if and ge k 1 le k 4 |
| 15253 | ret |
| 15254 | end |
| 15255 | i = add i 1 |
| 15256 | end |
| 15257 | m = add m 1 |
| 15258 | end |
| 15259 | end |
| 15260 | bo = get oc 0 |
| 15261 | emit 335544320 |
| 15262 | stubs p n |
| 15263 | patch26 bo get oc 0 |
| 15264 | put tpend 0 n |
| 15265 | end |
| 15266 | |
| 15267 | note patchl: patch to t every entry of loop i in the break (w 0) or continue (w 1) list, from the list's |
| 15268 | note count when loop i opened (bk0 / bc0) to its end |
| 15269 | fn patchl w ulong i ulong t ulong to void |
| 15270 | j = ulong 0 |
| 15271 | n = ulong 0 |
| 15272 | if eq w 0 |
| 15273 | j = get a_ar add get a_rb 60 i |
| 15274 | n = get nbrk 0 |
| 15275 | else |
| 15276 | j = get a_ar add get a_rb 61 i |
| 15277 | n = get ncont 0 |
| 15278 | end |
| 15279 | go = true |
| 15280 | while go |
| 15281 | m = ulong 0 |
| 15282 | while and go lt m 999999 |
| 15283 | if ge j n |
| 15284 | go = false |
| 15285 | else |
| 15286 | if eq w 0 |
| 15287 | if eq get a_ar add get a_rb 71 j i |
| 15288 | patch19 get a_ar add get a_rb 70 j t |
| 15289 | put a_ar add get a_rb 71 j 65535 |
| 15290 | end |
| 15291 | else |
| 15292 | if eq get a_ar add get a_rb 73 j i |
| 15293 | patch19 get a_ar add get a_rb 72 j t |
| 15294 | put a_ar add get a_rb 73 j 65535 |
| 15295 | end |
| 15296 | end |
| 15297 | j = add j 1 |
| 15298 | end |
| 15299 | m = add m 1 |
| 15300 | end |
| 15301 | end |
| 15302 | end |
| 15303 | |
| 15304 | note s_end: close the innermost block (if: patch its branch; else: patch its jump; while: B head; for: i = |
| 15305 | note add i 1, B head), or the function. om4 S_END. |
| 15306 | fn s_end to void |
| 15307 | n = get nb 0 |
| 15308 | if eq n 0 |
| 15309 | finish |
| 15310 | ret |
| 15311 | end |
| 15312 | i = sub n 1 |
| 15313 | if eq get a_ar add get a_rb 49 i 5 |
| 15314 | s_unr i |
| 15315 | ret |
| 15316 | end |
| 15317 | if eq get a_ar add get a_rb 49 i 6 |
| 15318 | s_inlx i |
| 15319 | ret |
| 15320 | end |
| 15321 | put nb 0 i |
| 15322 | k = get a_ar add get a_rb 49 i |
| 15323 | fz_join i k |
| 15324 | if eq k 2 |
| 15325 | put dead 0 and get dead 0 get a_ar add get a_rb 56 i |
| 15326 | else |
| 15327 | put dead 0 0 |
| 15328 | end |
| 15329 | if eq k 4 |
| 15330 | lat = get oc 0 |
| 15331 | patchl 1 i lat |
| 15332 | put a_ar add get a_rb 77 0 1 |
| 15333 | a_p 77 1 a_g 52 i |
| 15334 | a_p 77 2 a_g 53 i |
| 15335 | put a_ar add get a_rb 77 3 3 |
| 15336 | put a_ar add get a_rb 77 4 1 |
| 15337 | a_p 77 5 a_g 53 i |
| 15338 | binop 33 get a_ar add get a_rb 52 i 0 |
| 15339 | end |
| 15340 | if eq k 3 |
| 15341 | patchl 1 i get a_ar add get a_rb 51 i |
| 15342 | end |
| 15343 | if ge k 3 |
| 15344 | if ne get a_ar add get a_rb 57 i 0 |
| 15345 | lpback i |
| 15346 | else |
| 15347 | back get a_ar add get a_rb 51 i |
| 15348 | end |
| 15349 | ex = get oc 0 |
| 15350 | note the breaks and continues of loop i are the entries recorded since it opened (bk0, bc0): an inner |
| 15351 | note loop gave its own back when it closed, so this is linear in them, and they are given back below |
| 15352 | patchl 0 i ex |
| 15353 | put nbrk 0 get a_ar add get a_rb 60 i |
| 15354 | put ncont 0 get a_ar add get a_rb 61 i |
| 15355 | end |
| 15356 | if eq k 2 |
| 15357 | if or eq get xtarget 0 0 eq get a_ar add get a_rb 56 i 0 |
| 15358 | patch26 get a_ar add get a_rb 50 i get oc 0 |
| 15359 | end |
| 15360 | else |
| 15361 | patch19 get a_ar add get a_rb 50 i get oc 0 |
| 15362 | end |
| 15363 | nm_set get a_ar add get a_rb 54 i |
| 15364 | put held 0 get a_ar add get a_rb 55 i |
| 15365 | eol |
| 15366 | end |
| 15367 | |
| 15368 | note ======== the end of the input: the output ======== |
| 15369 | note writeout: the output from byte st to the end, to stdout (error 2), then exit 0. om4 WRITEOUT. |
| 15370 | fn writeout st ulong to void |
| 15371 | if eq get chkmode 0 1 |
| 15372 | put mc 0 0 |
| 15373 | mputw 7594244768023276911 8 |
| 15374 | mputw 11207551510369 6 |
| 15375 | mflush |
| 15376 | exit int 0 |
| 15377 | end |
| 15378 | if eq get chkmode 0 3 |
| 15379 | a_rec 1 |
| 15380 | exit int 0 |
| 15381 | end |
| 15382 | if ne get fmtm 0 0 |
| 15383 | fmtout |
| 15384 | end |
| 15385 | o = sub get oc 0 st |
| 15386 | if eq get om2m 0 1 |
| 15387 | o = add o get nsite 0 |
| 15388 | end |
| 15389 | a_ceilo o |
| 15390 | if eq a_out 1 1 st get oc 0 0 |
| 15391 | note d2site 319|writeout: the compiler's standard output could not be written; condition if eq a_out 1 1 st get oc 0 0 |
| 15392 | put d2site 0 319 |
| 15393 | fail 2 |
| 15394 | end |
| 15395 | if eq get om2m 0 1 |
| 15396 | sitesout |
| 15397 | end |
| 15398 | rc_emit st |
| 15399 | exit int 0 |
| 15400 | end |
| 15401 | |
| 15402 | note elfhdr: the 176-byte file header (om4 ELFHDR, 44 words): ELF64 little-endian, executable, AArch64, |
| 15403 | note entry 0x4000b0 (the word after the header), 2 program headers: code read+execute from 0x400000, and |
| 15404 | note the read/write pools from 0x10000000. Only the words that are not 0 (the output starts at 0). |
| 15405 | fn elfhdr to void |
| 15406 | wrword 0 1179403647 |
| 15407 | wrword 4 65794 |
| 15408 | wrword 16 11993090 |
| 15409 | wrword 20 1 |
| 15410 | wrword 24 4194480 |
| 15411 | wrword 32 64 |
| 15412 | wrword 52 3670080 |
| 15413 | wrword 56 2 |
| 15414 | wrword 64 1 |
| 15415 | wrword 68 5 |
| 15416 | wrword 80 4194304 |
| 15417 | wrword 88 4194304 |
| 15418 | wrword 112 4096 |
| 15419 | wrword 120 1 |
| 15420 | wrword 124 6 |
| 15421 | wrword 136 268435456 |
| 15422 | wrword 144 268435456 |
| 15423 | wrword 168 4096 |
| 15424 | end |
| 15425 | |
| 15426 | note eof_prog: program mode: start code = MOVZ X28, #0x1000, LSL 16 (stack pool floor); MOVZ X16, #0x1080, |
| 15427 | note LSL 16; MOV SP, X16 (ADD immediate, C6.2.5); BL main (C6.2.43); [MOVZ X0, #0 for a void main]; MOVZ X8, |
| 15428 | note #93; SVC #0. The entry word after the header is a B to it; the header gets the file and pool sizes. |
| 15429 | note om4 EOF_PROG. An OM-2 unit with pinned registers sets them (pinlo) just before the BL. |
| 15430 | fn eof_prog to void |
| 15431 | if ne get xtarget 0 0 |
| 15432 | xeof |
| 15433 | ret |
| 15434 | end |
| 15435 | if ne get xefa 0 0 |
| 15436 | aeof |
| 15437 | ret |
| 15438 | end |
| 15439 | f = findfn 1852399981 4 0 |
| 15440 | if eq f 0 |
| 15441 | note d2site 320|eof_prog: syntax: unknown or misplaced word; condition if eq f 0 |
| 15442 | put d2site 0 320 |
| 15443 | fail 16 |
| 15444 | end |
| 15445 | if ne uchar get a_ar add get a_rb 24 sub f 1 0 |
| 15446 | note d2site 321|eof_prog: word or declaration in a place that does not allow it; condition if ne uchar get a_ar add get a_rb 24 sub f 1 0 |
| 15447 | put d2site 0 321 |
| 15448 | fail 9 |
| 15449 | end |
| 15450 | wrword 176 or 335544320 bdisp 176 get oc 0 26 |
| 15451 | if ne get hostargs 0 0 |
| 15452 | note Preserve Linux's initial argument stack privately before installing Omega's bounded stack. |
| 15453 | emit 2432697339 |
| 15454 | end |
| 15455 | emit 3533832220 |
| 15456 | emit 3533836304 |
| 15457 | emit 2432696863 |
| 15458 | pinlo |
| 15459 | emit or 2483027968 bdisp get oc 0 get a_ar add get a_rb 22 sub f 1 26 |
| 15460 | if eq uchar get a_ar add get a_rb 23 sub f 1 12 |
| 15461 | emit 3531603968 |
| 15462 | end |
| 15463 | emit 3531606952 |
| 15464 | emit 3556769793 |
| 15465 | elfhdr |
| 15466 | wrword 96 get oc 0 |
| 15467 | wrword 104 get oc 0 |
| 15468 | wrword 160 add get poolb 0 8388608 |
| 15469 | writeout 0 |
| 15470 | end |
| 15471 | |
| 15472 | note s_eof: end of input: no open function (error 15), some function (16); function mode: no globals or |
| 15473 | note texts (9, fnstore; consts fold and are allowed); one function: its bare words; more: the entry word, a |
| 15474 | note B to the last function. om4 S_EOF. |
| 15475 | note Resolve every call after all addresses are known. In function mode a function is settled when every |
| 15476 | note function it calls is (leaves of the call graph first); any function left unsettled forms or reaches a |
| 15477 | note cycle (error 9). ksettle finds the same set as the old nf rounds over every call, in linear time. |
| 15478 | fn resolve to void |
| 15479 | n = get ncalls 0 |
| 15480 | i = ulong 0 |
| 15481 | go = true |
| 15482 | while go |
| 15483 | m = ulong 0 |
| 15484 | while and go lt m 999999 |
| 15485 | if ge i n |
| 15486 | go = false |
| 15487 | else |
| 15488 | s = get a_ar add get a_rb 41 i |
| 15489 | f = sub get a_ar add get a_rb 43 i 1 |
| 15490 | if ne get xtarget 0 0 |
| 15491 | wrword add s 1 sub a_g 22 f add s 5 |
| 15492 | else |
| 15493 | if and ne get objmode 0 0 eq a_gu 32 f 2 |
| 15494 | wrword s 2483027968 |
| 15495 | else |
| 15496 | wrword s or 2483027968 bdisp s get a_ar add get a_rb 22 f 26 |
| 15497 | end |
| 15498 | end |
| 15499 | i = add i 1 |
| 15500 | end |
| 15501 | m = add m 1 |
| 15502 | end |
| 15503 | end |
| 15504 | if eq get progmode 0 0 |
| 15505 | ksettle n |
| 15506 | kunset |
| 15507 | end |
| 15508 | end |
| 15509 | |
| 15510 | note ksettle: Kahn's order over the n call records (callfrom 0 is no function's call and is skipped). |
| 15511 | note k_deg: the calls function f makes to functions not yet settled; k_st / k_ed: the callers of each |
| 15512 | note callee, grouped by callee (k_st g .. k_st g + 1 - 1 in k_ed), k_cu the fill cursor; k_q: the |
| 15513 | note settled functions in order. A function is settled when its count reaches 0. Arena groups 19, 20. |
| 15514 | fn ksettle n ulong to void |
| 15515 | fc = get nf 0 |
| 15516 | if ge fc get a_gp 19 |
| 15517 | a_need 19 fc |
| 15518 | end |
| 15519 | if ge n get a_gp 20 |
| 15520 | a_need 20 n |
| 15521 | end |
| 15522 | kcount n fc |
| 15523 | kfill n fc |
| 15524 | t = ulong 0 |
| 15525 | f = ulong 0 |
| 15526 | while lt f fc |
| 15527 | if eq get a_ar add get a_rb 81 f 0 |
| 15528 | put a_ar add get a_rb 84 t f |
| 15529 | t = add t 1 |
| 15530 | end |
| 15531 | f = add f 1 |
| 15532 | end |
| 15533 | h = ulong 0 |
| 15534 | go = true |
| 15535 | while go |
| 15536 | m = ulong 0 |
| 15537 | while and go lt m 999999 |
| 15538 | if ge h t |
| 15539 | go = false |
| 15540 | else |
| 15541 | g = get a_ar add get a_rb 84 h |
| 15542 | h = add h 1 |
| 15543 | a_pc 30 g 1 |
| 15544 | t = kpop g t |
| 15545 | end |
| 15546 | m = add m 1 |
| 15547 | end |
| 15548 | end |
| 15549 | end |
| 15550 | |
| 15551 | note kcount: k_deg and the per-callee counts k_st g + 1 from the call records, then k_st as starts |
| 15552 | fn kcount n ulong fc ulong to void |
| 15553 | f = ulong 0 |
| 15554 | while le f fc |
| 15555 | put a_ar add get a_rb 81 f 0 |
| 15556 | put a_ar add get a_rb 82 f 0 |
| 15557 | f = add f 1 |
| 15558 | end |
| 15559 | i = ulong 0 |
| 15560 | go = true |
| 15561 | while go |
| 15562 | m = ulong 0 |
| 15563 | while and go lt m 999999 |
| 15564 | if ge i n |
| 15565 | go = false |
| 15566 | else |
| 15567 | a = get a_ar add get a_rb 42 i |
| 15568 | if ne a 0 |
| 15569 | b = get a_ar add get a_rb 43 i |
| 15570 | a_p 81 sub a 1 add a_g 81 sub a 1 1 |
| 15571 | a_p 82 b add a_g 82 b 1 |
| 15572 | end |
| 15573 | i = add i 1 |
| 15574 | end |
| 15575 | m = add m 1 |
| 15576 | end |
| 15577 | end |
| 15578 | f = ulong 1 |
| 15579 | while le f fc |
| 15580 | a_p 82 f add a_g 82 f a_g 82 sub f 1 |
| 15581 | f = add f 1 |
| 15582 | end |
| 15583 | end |
| 15584 | |
| 15585 | note kfill: each call record's caller into k_ed at its callee's place |
| 15586 | fn kfill n ulong fc ulong to void |
| 15587 | f = ulong 0 |
| 15588 | while lt f fc |
| 15589 | a_p 83 f a_g 82 f |
| 15590 | f = add f 1 |
| 15591 | end |
| 15592 | i = ulong 0 |
| 15593 | go = true |
| 15594 | while go |
| 15595 | m = ulong 0 |
| 15596 | while and go lt m 999999 |
| 15597 | if ge i n |
| 15598 | go = false |
| 15599 | else |
| 15600 | a = get a_ar add get a_rb 42 i |
| 15601 | if ne a 0 |
| 15602 | g = sub a_g 43 i 1 |
| 15603 | a_p 85 a_g 83 g sub a 1 |
| 15604 | a_p 83 g add a_g 83 g 1 |
| 15605 | end |
| 15606 | i = add i 1 |
| 15607 | end |
| 15608 | m = add m 1 |
| 15609 | end |
| 15610 | end |
| 15611 | end |
| 15612 | |
| 15613 | note kpop: function g is settled: each caller's count drops by one per call; a caller at 0 joins the |
| 15614 | note queue at t. Returns the new end of the queue. |
| 15615 | fn kpop g ulong t ulong to ulong |
| 15616 | e = get a_ar add get a_rb 82 add g 1 |
| 15617 | j = get a_ar add get a_rb 82 g |
| 15618 | q = t |
| 15619 | go = true |
| 15620 | while go |
| 15621 | m = ulong 0 |
| 15622 | while and go lt m 999999 |
| 15623 | if ge j e |
| 15624 | go = false |
| 15625 | else |
| 15626 | c = get a_ar add get a_rb 85 j |
| 15627 | d = sub a_g 81 c 1 |
| 15628 | a_p 81 c d |
| 15629 | if eq d 0 |
| 15630 | a_p 84 q c |
| 15631 | q = add q 1 |
| 15632 | end |
| 15633 | j = add j 1 |
| 15634 | end |
| 15635 | m = add m 1 |
| 15636 | end |
| 15637 | end |
| 15638 | ret q |
| 15639 | end |
| 15640 | |
| 15641 | note kunset: a function ksettle left unsettled is error 9 at the end of the input |
| 15642 | fn kunset to void |
| 15643 | f = ulong 0 |
| 15644 | while lt f get nf 0 |
| 15645 | if eq uchar get a_ar add get a_rb 30 f 0 |
| 15646 | put dsev 0 3 |
| 15647 | note d2site 322|kunset: word or declaration in a place that does not allow it; condition if eq uchar get a_ar add get a_rb 30 f 0 |
| 15648 | put d2site 0 322 |
| 15649 | fail 9 |
| 15650 | end |
| 15651 | f = add f 1 |
| 15652 | end |
| 15653 | end |
| 15654 | |
| 15655 | note reachself: 1 when function f (index + 1) reaches itself |
| 15656 | fn reachself f ulong to ulong |
| 15657 | i = ulong 0 |
| 15658 | while lt i get nf 0 |
| 15659 | a_pc 31 i 0 |
| 15660 | i = add i 1 |
| 15661 | end |
| 15662 | a_pc 31 sub f 1 1 |
| 15663 | go = true |
| 15664 | pass = ulong 0 |
| 15665 | while and go le pass get nf 0 |
| 15666 | r = rscan f 0 |
| 15667 | if eq r 2 |
| 15668 | ret 1 |
| 15669 | end |
| 15670 | s = rscan f 1 |
| 15671 | if eq s 2 |
| 15672 | ret 1 |
| 15673 | end |
| 15674 | go = or ne r 0 ne s 0 |
| 15675 | pass = add pass 1 |
| 15676 | end |
| 15677 | ret 0 |
| 15678 | end |
| 15679 | |
| 15680 | note rscan: one pass over the calls (w 0) or the inline edges (w 1): 2 when an edge from a reached |
| 15681 | note function leads to f, 1 when a function was newly reached, else 0. A pass reads only its own regions: the |
| 15682 | note calls (42/43) below ncalls or the inline edges (75/76) below nie. (Reading the call regions at an edge |
| 15683 | note index ran past them once the edges outnumbered their room: trap 3 in omc c52e986e and 1e628c80.) |
| 15684 | fn rscan f ulong w ulong to ulong |
| 15685 | n = get ncalls 0 |
| 15686 | ra = ulong 42 |
| 15687 | rb = ulong 43 |
| 15688 | if ne w 0 |
| 15689 | n = get nie 0 |
| 15690 | ra = ulong 75 |
| 15691 | rb = ulong 76 |
| 15692 | end |
| 15693 | ch = ulong 0 |
| 15694 | j = ulong 0 |
| 15695 | go = true |
| 15696 | while go |
| 15697 | m = ulong 0 |
| 15698 | while and go lt m 999999 |
| 15699 | if ge j n |
| 15700 | go = false |
| 15701 | else |
| 15702 | a = a_g ra j |
| 15703 | b = a_g rb j |
| 15704 | if ne a_gu 31 sub a 1 0 |
| 15705 | if eq b f |
| 15706 | ret 2 |
| 15707 | end |
| 15708 | if eq a_gu 31 sub b 1 0 |
| 15709 | a_pc 31 sub b 1 1 |
| 15710 | ch = ulong 1 |
| 15711 | end |
| 15712 | end |
| 15713 | j = add j 1 |
| 15714 | end |
| 15715 | m = add m 1 |
| 15716 | end |
| 15717 | end |
| 15718 | ret ch |
| 15719 | end |
| 15720 | |
| 15721 | fn s_eof to void |
| 15722 | if eq get chkmode 0 2 |
| 15723 | emit_query |
| 15724 | end |
| 15725 | if ne get curret 0 0 |
| 15726 | note d2site 323|s_eof: missing end; condition if ne get curret 0 0 |
| 15727 | put d2site 0 323 |
| 15728 | fail 15 |
| 15729 | end |
| 15730 | if eq get nf 0 0 |
| 15731 | note d2site 324|s_eof: syntax: unknown or misplaced word; condition if eq get nf 0 0 |
| 15732 | put d2site 0 324 |
| 15733 | fail 16 |
| 15734 | end |
| 15735 | if ne get om2 0 0 |
| 15736 | note inlcyc (OM-2): an inline function that reaches itself through the whole call graph (the calls made, |
| 15737 | note plus an edge from each function to every inline function expanded in it) is error 9 at the end. |
| 15738 | f = ulong 1 |
| 15739 | while le f get nf 0 |
| 15740 | if ne uchar get a_ar add get a_rb 27 sub f 1 0 |
| 15741 | if ne reachself f 0 |
| 15742 | put dsev 0 3 |
| 15743 | note d2site 325|s_eof: word or declaration in a place that does not allow it; condition if ne reachself f 0 |
| 15744 | put d2site 0 325 |
| 15745 | fail 9 |
| 15746 | end |
| 15747 | end |
| 15748 | f = add f 1 |
| 15749 | end |
| 15750 | end |
| 15751 | resolve |
| 15752 | if ne get progmode 0 0 |
| 15753 | eof_prog |
| 15754 | end |
| 15755 | if eq get progmode 0 0 |
| 15756 | note fnstore: function mode. A top-level global pool (kind 4) or text (kind 5) needs the program image and |
| 15757 | note is error 9; a const (kind 9) is folded to a typed number wherever it is read, so it composes here too. |
| 15758 | i = ulong 0 |
| 15759 | go = true |
| 15760 | while go |
| 15761 | m = ulong 0 |
| 15762 | while and go lt m 999999 |
| 15763 | if ge i get nglob 0 |
| 15764 | go = false |
| 15765 | else |
| 15766 | if ne uchar get a_ar add get a_rb 7 i 9 |
| 15767 | note d2site 326|s_eof: word or declaration in a place that does not allow it; condition if ne uchar get a_ar add get a_rb 7 i 9 |
| 15768 | put d2site 0 326 |
| 15769 | fail 9 |
| 15770 | end |
| 15771 | i = add i 1 |
| 15772 | end |
| 15773 | m = add m 1 |
| 15774 | end |
| 15775 | end |
| 15776 | end |
| 15777 | if ne get objmode 0 0 |
| 15778 | obj_write |
| 15779 | end |
| 15780 | if ne get xtarget 0 0 |
| 15781 | note Bare x86 units share the private frame ABI; exports have six-byte JMP/NOP slots. |
| 15782 | n = get nexp 0 |
| 15783 | p = ulong 512 |
| 15784 | f = ulong 0 |
| 15785 | while lt f get nf 0 |
| 15786 | take = ne uchar get a_ar add get a_rb 32 f 0 |
| 15787 | if eq n 0 |
| 15788 | take = eq f sub get lastfn 0 1 |
| 15789 | end |
| 15790 | if take |
| 15791 | a_bput 1 p 233 |
| 15792 | wrword add p 1 sub get a_ar add get a_rb 22 f add p 5 |
| 15793 | a_bput 1 add p 5 144 |
| 15794 | p = add p 6 |
| 15795 | end |
| 15796 | f = add f 1 |
| 15797 | end |
| 15798 | writeout 512 |
| 15799 | end |
| 15800 | if ne get nexp 0 0 |
| 15801 | note expwords (OM-2, spec 6): words 0 .. E-1 of a multi-entry unit, B to each export in source order |
| 15802 | at = ulong 176 |
| 15803 | f = ulong 0 |
| 15804 | while lt f get nf 0 |
| 15805 | if ne uchar get a_ar add get a_rb 32 f 0 |
| 15806 | wrword at or 335544320 bdisp at get a_ar add get a_rb 22 f 26 |
| 15807 | at = add at 4 |
| 15808 | end |
| 15809 | f = add f 1 |
| 15810 | end |
| 15811 | writeout 176 |
| 15812 | end |
| 15813 | if eq get nf 0 1 |
| 15814 | writeout 180 |
| 15815 | end |
| 15816 | a = get a_ar add get a_rb 22 sub get lastfn 0 1 |
| 15817 | wrword 176 or 335544320 bdisp 176 a 26 |
| 15818 | writeout 176 |
| 15819 | end |
| 15820 | |
| 15821 | note stmt: one line. Returns 1 at the end of the input. om4 STMT. |
| 15822 | fn stmt to ulong |
| 15823 | put dexp 0 0 |
| 15824 | put nslot 0 get held 0 |
| 15825 | if lt get tpend 0 get nt 0 |
| 15826 | if and ne get curret 0 0 eq get inl 0 0 |
| 15827 | if and eq get xtarget 0 0 eq get irmode 0 0 |
| 15828 | island |
| 15829 | end |
| 15830 | end |
| 15831 | end |
| 15832 | tok |
| 15833 | k = get tk 0 |
| 15834 | if eq k 0 |
| 15835 | ret 0 |
| 15836 | end |
| 15837 | if eq k 3 |
| 15838 | s_eof |
| 15839 | ret 1 |
| 15840 | end |
| 15841 | if ne k 1 |
| 15842 | note d2site 327|stmt: syntax: unknown or misplaced word; condition if ne k 1 |
| 15843 | put d2site 0 327 |
| 15844 | fail 16 |
| 15845 | end |
| 15846 | if and ne get chkmode 0 0 eq get line 0 get chkln 0 |
| 15847 | skipnl |
| 15848 | ret 0 |
| 15849 | end |
| 15850 | if and ne get om2 0 0 eq get line 0 get om2ln 0 |
| 15851 | skipnl |
| 15852 | ret 0 |
| 15853 | end |
| 15854 | if ne get objmode 0 0 |
| 15855 | if and eq get tl 0 6 eq get tw 0 121437607458917 |
| 15856 | s_extern |
| 15857 | ret 0 |
| 15858 | end |
| 15859 | end |
| 15860 | if ne cp_kind 0 |
| 15861 | note d2site 328|stmt: contract syntax misplaced or not supported here (IR mode included); condition if ne cp_kind 0 |
| 15862 | put d2site 0 328 |
| 15863 | fail 30 |
| 15864 | end |
| 15865 | if gt get tl 0 8 |
| 15866 | note s_long: a word over 8 characters at the start of a line: a call of a void function (om4 S_LONG), or |
| 15867 | note a long name of up to 63 bytes, which goes on below as a short name does. |
| 15868 | if eq get curret 0 0 |
| 15869 | note d2site 329|stmt: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if eq get curret 0 0 |
| 15870 | put d2site 0 329 |
| 15871 | fail 13 |
| 15872 | end |
| 15873 | if ne get dead 0 0 |
| 15874 | note d2site 330|stmt: line after ret, break, continue, trap or exit in the same block; condition if ne get dead 0 0 |
| 15875 | put d2site 0 330 |
| 15876 | fail 17 |
| 15877 | end |
| 15878 | f = findfn get tw 0 get tl 0 get ts 0 |
| 15879 | if eq f 0 |
| 15880 | if gt get tl 0 63 |
| 15881 | note d2site 331|stmt: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63 |
| 15882 | put d2site 0 331 |
| 15883 | unkfail 13 |
| 15884 | end |
| 15885 | else |
| 15886 | if ne uchar get a_ar add get a_rb 23 sub f 1 12 |
| 15887 | note d2site 332|stmt: type mismatch; condition if ne uchar get a_ar add get a_rb 23 sub f 1 12 |
| 15888 | put d2site 0 332 |
| 15889 | fail 7 |
| 15890 | end |
| 15891 | rdval 2 0 255 f |
| 15892 | eol |
| 15893 | ret 0 |
| 15894 | end |
| 15895 | end |
| 15896 | w = get tw 0 |
| 15897 | c = kw w |
| 15898 | if eq c 83 |
| 15899 | skipnl |
| 15900 | ret 0 |
| 15901 | end |
| 15902 | if eq c 64 |
| 15903 | s_fn |
| 15904 | ret 0 |
| 15905 | end |
| 15906 | if eq get curret 0 0 |
| 15907 | if eq c 78 |
| 15908 | s_global |
| 15909 | ret 0 |
| 15910 | end |
| 15911 | if eq c 79 |
| 15912 | s_text |
| 15913 | ret 0 |
| 15914 | end |
| 15915 | if eq c 152 |
| 15916 | s_const |
| 15917 | ret 0 |
| 15918 | end |
| 15919 | if eq c 85 |
| 15920 | skipnl |
| 15921 | ret 0 |
| 15922 | end |
| 15923 | if eq c 195 |
| 15924 | s_export |
| 15925 | ret 0 |
| 15926 | end |
| 15927 | if eq c 188 |
| 15928 | note s_lyskip: the body pass jumps to the place after the layout's end (read in the names pass) |
| 15929 | tok |
| 15930 | li = sub findlay get tw 0 1 |
| 15931 | put cur 0 get ly_ec li |
| 15932 | put line 0 get ly_el li |
| 15933 | ret 0 |
| 15934 | end |
| 15935 | if or eq c 184 eq c 187 |
| 15936 | skipnl |
| 15937 | ret 0 |
| 15938 | end |
| 15939 | note d2site 333|stmt: syntax: unknown or misplaced word; condition if eq get curret 0 0 |
| 15940 | put d2site 0 333 |
| 15941 | fail 16 |
| 15942 | end |
| 15943 | if eq c 66 |
| 15944 | s_end |
| 15945 | ret 0 |
| 15946 | end |
| 15947 | if eq c 68 |
| 15948 | s_else |
| 15949 | ret 0 |
| 15950 | end |
| 15951 | if ne get dead 0 0 |
| 15952 | note d2site 334|stmt: line after ret, break, continue, trap or exit in the same block; condition if ne get dead 0 0 |
| 15953 | put d2site 0 334 |
| 15954 | fail 17 |
| 15955 | end |
| 15956 | if eq c 0 |
| 15957 | s_name w |
| 15958 | ret 0 |
| 15959 | end |
| 15960 | if eq c 67 |
| 15961 | note s_if: if cond: the false branch is patched at else / end. om4 S_IF. |
| 15962 | at = cond |
| 15963 | pushb at 1 0 0 0 |
| 15964 | pushnh get nn 0 get held 0 |
| 15965 | eol |
| 15966 | ret 0 |
| 15967 | end |
| 15968 | if eq c 69 |
| 15969 | s_while |
| 15970 | ret 0 |
| 15971 | end |
| 15972 | if eq c 71 |
| 15973 | s_for |
| 15974 | ret 0 |
| 15975 | end |
| 15976 | if eq c 72 |
| 15977 | s_ret |
| 15978 | ret 0 |
| 15979 | end |
| 15980 | if eq c 80 |
| 15981 | s_put |
| 15982 | ret 0 |
| 15983 | end |
| 15984 | if eq c 82 |
| 15985 | eff_rec 82 |
| 15986 | note exit compiles the same in a native object as in function mode. |
| 15987 | note s_exit: exit value (int): Linux exit (system call 93: MOVZ X8, #93, C6.2.285; SVC #0, C6.2.466); the |
| 15988 | note path ends. om4 S_EXIT. |
| 15989 | rdval 0 8 255 0 |
| 15990 | if ne get rt 0 8 |
| 15991 | note d2site 336|stmt: type mismatch; condition if ne get rt 0 8 |
| 15992 | put d2site 0 336 |
| 15993 | fail 7 |
| 15994 | end |
| 15995 | force get rk 0 get rv 0 get rt 0 0 |
| 15996 | if ne get xtarget 0 0 |
| 15997 | xload 0 0 |
| 15998 | xleave |
| 15999 | else |
| 16000 | if ne get xefa 0 0 |
| 16001 | emit or 335544320 bdisp get oc 0 520 26 |
| 16002 | else |
| 16003 | emit 3531606952 |
| 16004 | emit 3556769793 |
| 16005 | end |
| 16006 | end |
| 16007 | dead1 |
| 16008 | eol |
| 16009 | ret 0 |
| 16010 | end |
| 16011 | if eq c 86 |
| 16012 | s_break |
| 16013 | ret 0 |
| 16014 | end |
| 16015 | if eq c 87 |
| 16016 | note s_trap: trap N (1 .. 14): an always-taken branch to the trap stub for code N, which finish makes. |
| 16017 | note Program mode exits 100 + N; function mode calls OscRt.trap (OMEGESE 9.1). The line ends the path. |
| 16018 | v = lenval 4 |
| 16019 | if or lt v 1 gt v 14 |
| 16020 | note d2site 337|stmt: number out of range for its type or place; condition if or lt v 1 gt v 14 |
| 16021 | put d2site 0 337 |
| 16022 | fail 8 |
| 16023 | end |
| 16024 | trapc 14 v |
| 16025 | dead1 |
| 16026 | eol |
| 16027 | ret 0 |
| 16028 | end |
| 16029 | note cpufence (keyword 199, a statement without operands): the host CPU publication barrier. AArch64: |
| 16030 | note DSB SY (d5033f9f, the full-system barrier mapget/mapset already bracket their access with). x86-64: |
| 16031 | note MFENCE (0F AE F0), the fence the x86 mapget/mapset use. Every earlier load and store completes before |
| 16032 | note any later one, so a GPU or another CPU that observes a later store also observes the earlier ones. |
| 16033 | note Inline here, not a function: om4 builds omc and holds at most 512 functions, 511 in use. |
| 16034 | if eq c 199 |
| 16035 | eff_rec 199 |
| 16036 | if ne get objmode 0 0 |
| 16037 | note d2site 338|stmt: word or declaration in a place that does not allow it; condition if ne get objmode 0 0 |
| 16038 | put d2site 0 338 |
| 16039 | fail 9 |
| 16040 | end |
| 16041 | eol |
| 16042 | if ne get xtarget 0 0 |
| 16043 | xb 15 174 240 |
| 16044 | else |
| 16045 | emit 3573759903 |
| 16046 | end |
| 16047 | ret 0 |
| 16048 | end |
| 16049 | note cpurelax (keyword 200, a statement without operands): spin-wait hint, no ordering. AArch64: YIELD |
| 16050 | note (d503203f). x86-64: PAUSE (F3 90). Use it in a bounded poll loop; pair it with cpufence for order. |
| 16051 | if eq c 200 |
| 16052 | eff_rec 200 |
| 16053 | if ne get objmode 0 0 |
| 16054 | note d2site 339|stmt: word or declaration in a place that does not allow it; condition if ne get objmode 0 0 |
| 16055 | put d2site 0 339 |
| 16056 | fail 9 |
| 16057 | end |
| 16058 | eol |
| 16059 | if ne get xtarget 0 0 |
| 16060 | emitb 243 |
| 16061 | emitb 144 |
| 16062 | else |
| 16063 | emit 3573751871 |
| 16064 | end |
| 16065 | ret 0 |
| 16066 | end |
| 16067 | if eq c 97 |
| 16068 | s_cont |
| 16069 | ret 0 |
| 16070 | end |
| 16071 | if or or or eq c 77 eq c 78 eq c 79 eq c 81 |
| 16072 | note d2site 340|stmt: word or declaration in a place that does not allow it; condition if or or or eq c 77 eq c 78 eq c 79 eq c 81 |
| 16073 | put d2site 0 340 |
| 16074 | fail 9 |
| 16075 | end |
| 16076 | if or eq c 85 eq c 193 |
| 16077 | note d2site 341|stmt: word or declaration in a place that does not allow it; condition if or eq c 85 eq c 193 |
| 16078 | put d2site 0 341 |
| 16079 | fail 9 |
| 16080 | end |
| 16081 | note d2site 342|stmt: syntax: unknown or misplaced word |
| 16082 | put d2site 0 342 |
| 16083 | fail 16 |
| 16084 | ret 0 |
| 16085 | end |
| 16086 | |
| 16087 | note ======== program mode: some line is `fn main` (blanks, fn, blanks, main, then a blank or the end) ======== |
| 16088 | note skipbl: the first place at or after q that is not a space or tab (or the end) |
| 16089 | fn skipbl q ulong to ulong |
| 16090 | e = get inlen 0 |
| 16091 | p = q |
| 16092 | go = true |
| 16093 | while go |
| 16094 | m = ulong 0 |
| 16095 | while and go lt m 999999 |
| 16096 | if ge p e |
| 16097 | go = false |
| 16098 | else |
| 16099 | b = a_ib p |
| 16100 | if or eq b 32 eq b 9 |
| 16101 | p = add p 1 |
| 16102 | else |
| 16103 | go = false |
| 16104 | end |
| 16105 | end |
| 16106 | m = add m 1 |
| 16107 | end |
| 16108 | end |
| 16109 | ret p |
| 16110 | end |
| 16111 | |
| 16112 | note skipln: the place after the next newline at or after q (or the end) |
| 16113 | fn skipln q ulong to ulong |
| 16114 | e = get inlen 0 |
| 16115 | p = q |
| 16116 | go = true |
| 16117 | while go |
| 16118 | m = ulong 0 |
| 16119 | while and go lt m 999999 |
| 16120 | if ge p e |
| 16121 | go = false |
| 16122 | else |
| 16123 | b = a_ib p |
| 16124 | p = add p 1 |
| 16125 | if eq b 10 |
| 16126 | go = false |
| 16127 | end |
| 16128 | end |
| 16129 | m = add m 1 |
| 16130 | end |
| 16131 | end |
| 16132 | ret p |
| 16133 | end |
| 16134 | |
| 16135 | note ps_at: the line's first byte that is not blank is at p: 1 when the line is `fn main`, 2 when the input |
| 16136 | note ends while deciding, else 0. om4 PS_LINE .. PS_YES. |
| 16137 | fn ps_at p ulong to ulong |
| 16138 | e = get inlen 0 |
| 16139 | if ne uchar and shr get a_ar shr p 3 shl and p 7 3 255 102 |
| 16140 | ret 0 |
| 16141 | end |
| 16142 | q = add p 1 |
| 16143 | if ge q e |
| 16144 | ret 2 |
| 16145 | end |
| 16146 | if ne uchar and shr get a_ar shr q 3 shl and q 7 3 255 110 |
| 16147 | ret 0 |
| 16148 | end |
| 16149 | r = add q 1 |
| 16150 | q = skipbl r |
| 16151 | if ge q e |
| 16152 | ret 2 |
| 16153 | end |
| 16154 | if eq q r |
| 16155 | ret 0 |
| 16156 | end |
| 16157 | if gt add q 4 e |
| 16158 | ret 0 |
| 16159 | end |
| 16160 | if ne uchar and shr get a_ar shr q 3 shl and q 7 3 255 109 |
| 16161 | ret 0 |
| 16162 | end |
| 16163 | if ne a_ib add q 1 97 |
| 16164 | ret 0 |
| 16165 | end |
| 16166 | if ne a_ib add q 2 105 |
| 16167 | ret 0 |
| 16168 | end |
| 16169 | if ne a_ib add q 3 110 |
| 16170 | ret 0 |
| 16171 | end |
| 16172 | if ge add q 4 e |
| 16173 | ret 1 |
| 16174 | end |
| 16175 | if gt a_ib add q 4 32 |
| 16176 | ret 0 |
| 16177 | end |
| 16178 | ret 1 |
| 16179 | end |
| 16180 | |
| 16181 | fn prescan to void |
| 16182 | e = get inlen 0 |
| 16183 | p = ulong 0 |
| 16184 | go = true |
| 16185 | while go |
| 16186 | m = ulong 0 |
| 16187 | while and go lt m 999999 |
| 16188 | p = skipbl p |
| 16189 | if ge p e |
| 16190 | go = false |
| 16191 | else |
| 16192 | r = ps_at p |
| 16193 | if eq r 1 |
| 16194 | put progmode 0 1 |
| 16195 | go = false |
| 16196 | end |
| 16197 | if eq r 2 |
| 16198 | go = false |
| 16199 | end |
| 16200 | if go |
| 16201 | p = skipln p |
| 16202 | if ge p e |
| 16203 | go = false |
| 16204 | end |
| 16205 | end |
| 16206 | end |
| 16207 | m = add m 1 |
| 16208 | end |
| 16209 | end |
| 16210 | end |
| 16211 | |
| 16212 | note First collect signatures. Only fn headers are parsed here; other lines are read in the body pass. |
| 16213 | fn namescan to void |
| 16214 | put scanning 0 1 |
| 16215 | put line 0 1 |
| 16216 | go = true |
| 16217 | while go |
| 16218 | n = ulong 0 |
| 16219 | while and go lt n 999999 |
| 16220 | tok |
| 16221 | if eq get tk 0 3 |
| 16222 | go = false |
| 16223 | else |
| 16224 | if ne get tk 0 0 |
| 16225 | if and eq get tk 0 1 eq get tw 0 28262 |
| 16226 | s_fn |
| 16227 | else |
| 16228 | if and eq get tk 0 1 eq get tw 0 127970521019507 |
| 16229 | s_struct |
| 16230 | else |
| 16231 | if and eq get tk 0 1 eq get tw 0 500152823651 |
| 16232 | s_const |
| 16233 | else |
| 16234 | if eq ns_om2 0 |
| 16235 | skipnl |
| 16236 | end |
| 16237 | end |
| 16238 | end |
| 16239 | end |
| 16240 | end |
| 16241 | end |
| 16242 | n = add n 1 |
| 16243 | end |
| 16244 | end |
| 16245 | put scanning 0 0 |
| 16246 | put cur 0 0 |
| 16247 | put line 0 1 |
| 16248 | nm_set 0 |
| 16249 | put nglob 0 0 |
| 16250 | put curfn 0 0 |
| 16251 | put curret 0 0 |
| 16252 | put npar 0 0 |
| 16253 | put nslot 0 0 |
| 16254 | for j ulong 16 |
| 16255 | put vsl j 0 |
| 16256 | end |
| 16257 | put held 0 0 |
| 16258 | end |
| 16259 | |
| 16260 | note ======== R6 structs (omc only; om4 stays the parent that rebuilds this file) ======== |
| 16261 | note A struct is 8-byte cells, declaration order, no padding (OSC-2). new is a stack slot, given |
| 16262 | note back at ret, like a local array. There is no free (decision 24). Field scale: cell << (3 - tlog) |
| 16263 | note so a typed store lands on cell * 8. Pack of struct is 127970521019507 (Wolfram, little-endian). |
| 16264 | |
| 16265 | note findstruct: packed name -> index + 1, or 0 |
| 16266 | fn findstruct w ulong to ulong |
| 16267 | i = ulong 0 |
| 16268 | n = get nst 0 |
| 16269 | while lt i n |
| 16270 | if eq get st_name i w |
| 16271 | ret add i 1 |
| 16272 | end |
| 16273 | i = add i 1 |
| 16274 | end |
| 16275 | ret 0 |
| 16276 | end |
| 16277 | |
| 16278 | note findfield: struct index, packed field name -> field-table index + 1, or 0 |
| 16279 | fn findfield si ulong w ulong to ulong |
| 16280 | fo = ulong get st_foff si |
| 16281 | nfd = ulong get st_nf si |
| 16282 | i = ulong 0 |
| 16283 | while lt i nfd |
| 16284 | j = add fo i |
| 16285 | if eq get sf_name j w |
| 16286 | ret add j 1 |
| 16287 | end |
| 16288 | i = add i 1 |
| 16289 | end |
| 16290 | ret 0 |
| 16291 | end |
| 16292 | |
| 16293 | note field_dup: 1 if w is already a field of the struct being read (fields fo .. nsf) |
| 16294 | fn field_dup fo ulong w ulong to ulong |
| 16295 | i = fo |
| 16296 | e = get nsf 0 |
| 16297 | while lt i e |
| 16298 | if eq get sf_name i w |
| 16299 | ret 1 |
| 16300 | end |
| 16301 | i = add i 1 |
| 16302 | end |
| 16303 | ret 0 |
| 16304 | end |
| 16305 | |
| 16306 | note s_field: the current word is a field name of struct w. Returns the cell count after this field. |
| 16307 | fn s_field w ulong fo ulong cells ulong to ulong |
| 16308 | if gt get tl 0 63 |
| 16309 | note d2site 343|s_field: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63 |
| 16310 | put d2site 0 343 |
| 16311 | fail 13 |
| 16312 | end |
| 16313 | if ne kw get tw 0 0 |
| 16314 | note d2site 344|s_field: syntax: unknown or misplaced word; condition if ne kw get tw 0 0 |
| 16315 | put d2site 0 344 |
| 16316 | fail 16 |
| 16317 | end |
| 16318 | fw = get tw 0 |
| 16319 | if eq fw w |
| 16320 | note d2site 345|s_field: duplicate name; condition if eq fw w |
| 16321 | put d2site 0 345 |
| 16322 | fail 10 |
| 16323 | end |
| 16324 | if ne findstruct fw 0 |
| 16325 | note d2site 346|s_field: duplicate name; condition if ne findstruct fw 0 |
| 16326 | put d2site 0 346 |
| 16327 | fail 10 |
| 16328 | end |
| 16329 | if ne field_dup fo fw 0 |
| 16330 | note d2site 347|s_field: duplicate name; condition if ne field_dup fo fw 0 |
| 16331 | put d2site 0 347 |
| 16332 | fail 10 |
| 16333 | end |
| 16334 | t = typeword |
| 16335 | if ge t 64 |
| 16336 | note d2site 348|s_field: type mismatch; condition if ge t 64 |
| 16337 | put d2site 0 348 |
| 16338 | fail 7 |
| 16339 | end |
| 16340 | ln = ulong 0 |
| 16341 | p = get cur 0 |
| 16342 | ln0 = get line 0 |
| 16343 | tok |
| 16344 | k = get tk 0 |
| 16345 | if eq k 2 |
| 16346 | ln = get tw 0 |
| 16347 | if ne get tbig 0 0 |
| 16348 | note d2site 349|s_field: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ne get tbig 0 0 |
| 16349 | put d2site 0 349 |
| 16350 | fail 14 |
| 16351 | end |
| 16352 | if or eq ln 0 gt ln 64 |
| 16353 | note d2site 350|s_field: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if or eq ln 0 gt ln 64 |
| 16354 | put d2site 0 350 |
| 16355 | fail 14 |
| 16356 | end |
| 16357 | else |
| 16358 | if eq k 1 |
| 16359 | e = findname get tw 0 |
| 16360 | if ne e 0 |
| 16361 | if eq a_gu 7 sub e 1 9 |
| 16362 | ct = ulong a_gu 5 sub e 1 |
| 16363 | if ge ct 10 |
| 16364 | note d2site 351|s_field: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge ct 10 |
| 16365 | put d2site 0 351 |
| 16366 | fail 14 |
| 16367 | end |
| 16368 | ln = a_g 8 sub e 1 |
| 16369 | if or eq ln 0 gt ln 64 |
| 16370 | note d2site 352|s_field: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if or eq ln 0 gt ln 64 |
| 16371 | put d2site 0 352 |
| 16372 | fail 14 |
| 16373 | end |
| 16374 | else |
| 16375 | put cur 0 p |
| 16376 | put line 0 ln0 |
| 16377 | end |
| 16378 | else |
| 16379 | put cur 0 p |
| 16380 | put line 0 ln0 |
| 16381 | end |
| 16382 | else |
| 16383 | put cur 0 p |
| 16384 | put line 0 ln0 |
| 16385 | end |
| 16386 | end |
| 16387 | addc = ulong 1 |
| 16388 | if ne ln 0 |
| 16389 | addc = ln |
| 16390 | end |
| 16391 | if gt add cells addc 64 |
| 16392 | note d2site 353|s_field: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if gt add cells addc 64 |
| 16393 | put d2site 0 353 |
| 16394 | fail 14 |
| 16395 | end |
| 16396 | put sf_name get nsf 0 fw |
| 16397 | put sf_type get nsf 0 uchar t |
| 16398 | put sf_len get nsf 0 uchar ln |
| 16399 | put sf_off get nsf 0 uchar cells |
| 16400 | put nsf 0 add get nsf 0 1 |
| 16401 | ret add cells addc |
| 16402 | end |
| 16403 | |
| 16404 | note s_struct: struct Name (field type [len])* end. Before any fn (namescan). 1..16 fields, <= 64 cells. |
| 16405 | fn s_struct to void |
| 16406 | if ne get nf 0 0 |
| 16407 | note d2site 354|s_struct: word or declaration in a place that does not allow it; condition if ne get nf 0 0 |
| 16408 | put d2site 0 354 |
| 16409 | fail 9 |
| 16410 | end |
| 16411 | tok |
| 16412 | if ne get tk 0 1 |
| 16413 | note d2site 355|s_struct: syntax: unknown or misplaced word; condition if ne get tk 0 1 |
| 16414 | put d2site 0 355 |
| 16415 | fail 16 |
| 16416 | end |
| 16417 | if gt get tl 0 63 |
| 16418 | note d2site 356|s_struct: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63 |
| 16419 | put d2site 0 356 |
| 16420 | fail 13 |
| 16421 | end |
| 16422 | if ne kw get tw 0 0 |
| 16423 | note d2site 357|s_struct: syntax: unknown or misplaced word; condition if ne kw get tw 0 0 |
| 16424 | put d2site 0 357 |
| 16425 | fail 16 |
| 16426 | end |
| 16427 | w = get tw 0 |
| 16428 | if ne findstruct w 0 |
| 16429 | note d2site 358|s_struct: duplicate name; condition if ne findstruct w 0 |
| 16430 | put d2site 0 358 |
| 16431 | fail 10 |
| 16432 | end |
| 16433 | if ne findfn w get tl 0 get ts 0 0 |
| 16434 | note d2site 359|s_struct: duplicate name; condition if ne findfn w get tl 0 get ts 0 0 |
| 16435 | put d2site 0 359 |
| 16436 | fail 10 |
| 16437 | end |
| 16438 | if ge get nst 0 16 |
| 16439 | note d2site 360|s_struct: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge get nst 0 16 |
| 16440 | put d2site 0 360 |
| 16441 | fail 14 |
| 16442 | end |
| 16443 | sid = get nst 0 |
| 16444 | fo = get nsf 0 |
| 16445 | cells = ulong 0 |
| 16446 | nfld = ulong 0 |
| 16447 | go = true |
| 16448 | while go |
| 16449 | tok |
| 16450 | if eq get tk 0 0 |
| 16451 | note d2site 361|s_struct: the line ends where a word or value is needed; condition if eq get tk 0 0 |
| 16452 | put d2site 0 361 |
| 16453 | fail 4 |
| 16454 | end |
| 16455 | if ne get tk 0 1 |
| 16456 | note d2site 362|s_struct: syntax: unknown or misplaced word; condition if ne get tk 0 1 |
| 16457 | put d2site 0 362 |
| 16458 | fail 16 |
| 16459 | end |
| 16460 | if eq kw get tw 0 66 |
| 16461 | go = false |
| 16462 | else |
| 16463 | if ge nfld 16 |
| 16464 | note d2site 363|s_struct: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge nfld 16 |
| 16465 | put d2site 0 363 |
| 16466 | fail 14 |
| 16467 | end |
| 16468 | cells = s_field w fo cells |
| 16469 | nfld = add nfld 1 |
| 16470 | end |
| 16471 | end |
| 16472 | if eq nfld 0 |
| 16473 | note d2site 364|s_struct: syntax: unknown or misplaced word; condition if eq nfld 0 |
| 16474 | put d2site 0 364 |
| 16475 | fail 16 |
| 16476 | end |
| 16477 | put st_name sid w |
| 16478 | put st_nf sid uchar nfld |
| 16479 | put st_cells sid uchar cells |
| 16480 | put st_foff sid uchar fo |
| 16481 | put nst 0 add sid 1 |
| 16482 | eol |
| 16483 | end |
| 16484 | |
| 16485 | note peek_struct: if the next word is a struct name, consume it and return index + 1; else rewind |
| 16486 | fn peek_struct to ulong |
| 16487 | p = get cur 0 |
| 16488 | ln = get line 0 |
| 16489 | tok |
| 16490 | if ne get tk 0 1 |
| 16491 | put cur 0 p |
| 16492 | put line 0 ln |
| 16493 | ret 0 |
| 16494 | end |
| 16495 | sid = findstruct get tw 0 |
| 16496 | if eq sid 0 |
| 16497 | put cur 0 p |
| 16498 | put line 0 ln |
| 16499 | ret 0 |
| 16500 | end |
| 16501 | ret sid |
| 16502 | end |
| 16503 | |
| 16504 | note fn_p_st: parameter pw is view (k 2, name kind 8) or edit (k 3, name kind 7). fn_pk is 6 or 7. |
| 16505 | fn fn_p_st f ulong np ulong pw ulong sid ulong k ulong to void |
| 16506 | si = sub sid 1 |
| 16507 | t = add si 16 |
| 16508 | ln = ulong get st_cells si |
| 16509 | sk = add k 4 |
| 16510 | if eq k 2 |
| 16511 | addname pw poolc get psl 0 t ln 8 0 |
| 16512 | else |
| 16513 | addname pw poolc get psl 0 t ln 7 0 |
| 16514 | end |
| 16515 | p = add mul f 6 np |
| 16516 | a_pc 35 p uchar t |
| 16517 | put a_ar add get a_rb 36 p ln |
| 16518 | a_pc 37 p uchar sk |
| 16519 | end |
| 16520 | |
| 16521 | note sa_new: name = new <type or struct>. Rewind unless the next word is a struct name. |
| 16522 | fn sa_new w ulong to void |
| 16523 | if ne get om2 0 0 |
| 16524 | if ne get inl 0 0 |
| 16525 | note d2site 365|sa_new: word or declaration in a place that does not allow it; condition if ne get inl 0 0 |
| 16526 | put d2site 0 365 |
| 16527 | fail 9 |
| 16528 | end |
| 16529 | if ne uchar get a_ar add get a_rb 27 sub get curfn 0 1 0 |
| 16530 | note d2site 366|sa_new: word or declaration in a place that does not allow it; condition if ne uchar get a_ar add get a_rb 27 sub get curfn 0 1 0 |
| 16531 | put d2site 0 366 |
| 16532 | fail 9 |
| 16533 | end |
| 16534 | end |
| 16535 | p = get cur 0 |
| 16536 | ln = get line 0 |
| 16537 | tok |
| 16538 | sid = ulong 0 |
| 16539 | if eq get tk 0 1 |
| 16540 | sid = findstruct get tw 0 |
| 16541 | end |
| 16542 | if ne sid 0 |
| 16543 | sa_st w sid |
| 16544 | ret |
| 16545 | end |
| 16546 | put cur 0 p |
| 16547 | put line 0 ln |
| 16548 | sa_arr w |
| 16549 | end |
| 16550 | |
| 16551 | note st_read: one value per field, saved in svk/svv/svt. An array field takes one value. |
| 16552 | fn st_read si ulong to void |
| 16553 | fo = ulong get st_foff si |
| 16554 | nfd = ulong get st_nf si |
| 16555 | i = ulong 0 |
| 16556 | while lt i nfd |
| 16557 | ft = ulong get sf_type add fo i |
| 16558 | rdval 0 ft 255 0 |
| 16559 | if ne get rt 0 ft |
| 16560 | note d2site 367|st_read: type mismatch; condition if ne get rt 0 ft |
| 16561 | put d2site 0 367 |
| 16562 | fail 7 |
| 16563 | end |
| 16564 | put svk i get rk 0 |
| 16565 | put svv i get rv 0 |
| 16566 | put svt i get rt 0 |
| 16567 | i = add i 1 |
| 16568 | end |
| 16569 | end |
| 16570 | |
| 16571 | note st_store: STR of v at cell, scaled so the typed store lands on cell * 8. ADD is not used; the |
| 16572 | note index register holds cell << (3 - tlog). STR register-offset is the STOP table (om4). |
| 16573 | fn st_store base ulong idx ulong cell ulong t ulong v ulong to void |
| 16574 | matconst idx shl cell sub 3 tlog t |
| 16575 | put ea_b 0 base |
| 16576 | put ea_i 0 idx |
| 16577 | stel t v |
| 16578 | end |
| 16579 | |
| 16580 | note st_ixreg: runtime element index iv, field length fl, cell offset off. CMP + B.HS trap 3 |
| 16581 | note (elemaddr, C6.2.96 / C6.2.34), then ADD Xidx, Xiv, #off (C6.2.5, base word 2432696320) and |
| 16582 | note LSL by 3 - tlog (bo_lsl) so the STOP store lands on (off + i) * 8. |
| 16583 | fn st_ixreg idx ulong iv ulong off ulong fl ulong t ulong to void |
| 16584 | if ne get xtarget 0 0 |
| 16585 | xcmp iv fl 1 |
| 16586 | trapc 2 3 |
| 16587 | xarith 33 5 iv off 1 idx |
| 16588 | sh = sub 3 tlog t |
| 16589 | if ne sh 0 |
| 16590 | bo_lsl idx sh idx |
| 16591 | end |
| 16592 | ret |
| 16593 | end |
| 16594 | emit or or 4043309087 shl fl 10 shl iv 5 |
| 16595 | trapc 2 3 |
| 16596 | emit or or or 2432696320 idx shl iv 5 shl off 10 |
| 16597 | sh = sub 3 tlog t |
| 16598 | if ne sh 0 |
| 16599 | bo_lsl idx sh idx |
| 16600 | end |
| 16601 | end |
| 16602 | |
| 16603 | note st_ld: LDR of type t from base + idx into dst (or a new register). LDOP table, as vt_get. |
| 16604 | fn st_ld base ulong idx ulong t ulong dst ulong to void |
| 16605 | rd = destreg dst |
| 16606 | if ne get xtarget 0 0 |
| 16607 | xmemval 0 base idx t rd |
| 16608 | else |
| 16609 | w = or ldop t rd |
| 16610 | emit or or w shl base 5 shl idx 16 |
| 16611 | end |
| 16612 | put rk 0 1 |
| 16613 | put rv 0 rd |
| 16614 | put rt 0 t |
| 16615 | end |
| 16616 | |
| 16617 | note st_write1: store field j (value saved at sv* i) into the struct at base. |
| 16618 | fn st_write1 base ulong tmp ulong idx ulong j ulong i ulong to void |
| 16619 | ft = ulong get sf_type j |
| 16620 | fl = ulong get sf_len j |
| 16621 | off = ulong get sf_off j |
| 16622 | force get svk i get svv i get svt i tmp |
| 16623 | if eq fl 0 |
| 16624 | st_store base idx off ft tmp |
| 16625 | else |
| 16626 | k = ulong 0 |
| 16627 | while lt k fl |
| 16628 | st_store base idx add off k ft tmp |
| 16629 | k = add k 1 |
| 16630 | end |
| 16631 | end |
| 16632 | end |
| 16633 | |
| 16634 | note st_write: store each field value. An array field is filled with its one value. |
| 16635 | fn st_write base ulong tmp ulong idx ulong si ulong to void |
| 16636 | fo = ulong get st_foff si |
| 16637 | nfd = ulong get st_nf si |
| 16638 | i = ulong 0 |
| 16639 | while lt i nfd |
| 16640 | st_write1 base tmp idx add fo i i |
| 16641 | i = add i 1 |
| 16642 | end |
| 16643 | end |
| 16644 | |
| 16645 | note sa_st: p = new S v1 .. vn. Stack slot of the cell count, 16-byte aligned, outermost block only. |
| 16646 | fn sa_st w ulong sid ulong to void |
| 16647 | if ne get nb 0 0 |
| 16648 | note d2site 368|sa_st: word or declaration in a place that does not allow it; condition if ne get nb 0 0 |
| 16649 | put d2site 0 368 |
| 16650 | fail 9 |
| 16651 | end |
| 16652 | si = sub sid 1 |
| 16653 | cells = ulong get st_cells si |
| 16654 | by = shl shr add shl cells 3 15 4 4 |
| 16655 | s = add get stkbytes 0 by |
| 16656 | if gt s 4194304 |
| 16657 | note d2site 369|sa_st: size capacity; condition if gt s 4194304 |
| 16658 | put d2site 0 369 |
| 16659 | fail 23 |
| 16660 | end |
| 16661 | put stkbytes 0 s |
| 16662 | r = alloc |
| 16663 | put held 0 get nslot 0 |
| 16664 | st_read si |
| 16665 | spsubk by |
| 16666 | stkchk |
| 16667 | if ne get xtarget 0 0 |
| 16668 | xmovsp r |
| 16669 | else |
| 16670 | emit or 2432697312 r |
| 16671 | end |
| 16672 | tmp = alloc |
| 16673 | idx = alloc |
| 16674 | st_write r tmp idx si |
| 16675 | addname w r add si 16 cells 6 0 |
| 16676 | end |
| 16677 | |
| 16678 | note ======== OM-2 section 5: abstract types (spec 5, errata E8, E9). `abstract NAME T [ops W..]` and |
| 16679 | note `holds NAME dup32` at top level before the first fn (names pass). NAME is type 64 + index: a value of |
| 16680 | note it comes only from `seal NAME v` inside the function NAMEmk returning NAME (else error 28), `open v` |
| 16681 | note gives the T value, and the listed operations (rotr/rotl with a T count, and/or/xor of two NAME |
| 16682 | note values) keep NAME; anything else on it, a T value or a number where NAME is needed, an array of it and |
| 16683 | note the entry function's parameters and result are error 7. With holds, seal checks high32 == low32 |
| 16684 | note (LSR, CMP ..., UXTW, B.NE trap 10) unless the constructor body is exactly `ret seal NAME or shl ulong |
| 16685 | note x 32 ulong x` with x a uint parameter (rule dup32: uint values are held zero-extended). om2 diag |
| 16686 | note reports each check as omc-check 1 kept|erased line=N rule=dup32|-. ======== |
| 16687 | fn findab w ulong to ulong |
| 16688 | i = ulong 0 |
| 16689 | while lt i get nab 0 |
| 16690 | if eq get ab_name i w |
| 16691 | ret add i 1 |
| 16692 | end |
| 16693 | i = add i 1 |
| 16694 | end |
| 16695 | ret 0 |
| 16696 | end |
| 16697 | |
| 16698 | note abty: the current word (not a type word) as an abstract type; anything else is error 16 |
| 16699 | fn abty to ulong |
| 16700 | a = findab get tw 0 |
| 16701 | if eq a 0 |
| 16702 | note d2site 370|abty: syntax: unknown or misplaced word; condition if eq a 0 |
| 16703 | put d2site 0 370 |
| 16704 | fail 16 |
| 16705 | end |
| 16706 | ret add a 63 |
| 16707 | end |
| 16708 | |
| 16709 | note opbit: the ops bit of a preserving operation (rotr rotl and or xor), else 0 |
| 16710 | fn opbit c ulong to ulong |
| 16711 | if eq c 59 |
| 16712 | ret 1 |
| 16713 | end |
| 16714 | if eq c 60 |
| 16715 | ret 2 |
| 16716 | end |
| 16717 | if eq c 38 |
| 16718 | ret 4 |
| 16719 | end |
| 16720 | if eq c 39 |
| 16721 | ret 8 |
| 16722 | end |
| 16723 | if eq c 40 |
| 16724 | ret 16 |
| 16725 | end |
| 16726 | ret 0 |
| 16727 | end |
| 16728 | |
| 16729 | note s_abstract: abstract NAME uint|ulong [ops W ..] (another type is error 7, another op word 16) |
| 16730 | fn s_abstract to void |
| 16731 | if ne get nf 0 0 |
| 16732 | note d2site 371|s_abstract: word or declaration in a place that does not allow it; condition if ne get nf 0 0 |
| 16733 | put d2site 0 371 |
| 16734 | fail 9 |
| 16735 | end |
| 16736 | tok |
| 16737 | if ne get tk 0 1 |
| 16738 | note d2site 372|s_abstract: syntax: unknown or misplaced word; condition if ne get tk 0 1 |
| 16739 | put d2site 0 372 |
| 16740 | fail 16 |
| 16741 | end |
| 16742 | if gt get tl 0 8 |
| 16743 | note d2site 373|s_abstract: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 8 |
| 16744 | put d2site 0 373 |
| 16745 | fail 13 |
| 16746 | end |
| 16747 | w = get tw 0 |
| 16748 | if ne kw w 0 |
| 16749 | note d2site 374|s_abstract: syntax: unknown or misplaced word; condition if ne kw w 0 |
| 16750 | put d2site 0 374 |
| 16751 | fail 16 |
| 16752 | end |
| 16753 | newname w get tl 0 get ts 0 |
| 16754 | n = get nab 0 |
| 16755 | if ge n 16 |
| 16756 | note d2site 375|s_abstract: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge n 16 |
| 16757 | put d2site 0 375 |
| 16758 | fail 14 |
| 16759 | end |
| 16760 | put ab_len n get tl 0 |
| 16761 | t = typeword |
| 16762 | if and ne t 4 ne t 5 |
| 16763 | note d2site 376|s_abstract: type mismatch; condition if and ne t 4 ne t 5 |
| 16764 | put d2site 0 376 |
| 16765 | fail 7 |
| 16766 | end |
| 16767 | ops = ulong 0 |
| 16768 | tok |
| 16769 | if eq get tk 0 1 |
| 16770 | if or gt get tl 0 8 ne kw get tw 0 196 |
| 16771 | note d2site 377|s_abstract: extra words after a complete statement; condition if or gt get tl 0 8 ne kw get tw 0 196 |
| 16772 | put d2site 0 377 |
| 16773 | fail 5 |
| 16774 | end |
| 16775 | go = true |
| 16776 | while go |
| 16777 | tok |
| 16778 | k = get tk 0 |
| 16779 | if or eq k 0 eq k 3 |
| 16780 | go = false |
| 16781 | else |
| 16782 | if or ne k 1 gt get tl 0 8 |
| 16783 | note d2site 378|s_abstract: syntax: unknown or misplaced word; condition if or ne k 1 gt get tl 0 8 |
| 16784 | put d2site 0 378 |
| 16785 | fail 16 |
| 16786 | end |
| 16787 | b = opbit kw get tw 0 |
| 16788 | if eq b 0 |
| 16789 | note d2site 379|s_abstract: syntax: unknown or misplaced word; condition if eq b 0 |
| 16790 | put d2site 0 379 |
| 16791 | fail 16 |
| 16792 | end |
| 16793 | ops = or ops b |
| 16794 | end |
| 16795 | end |
| 16796 | else |
| 16797 | if and ne get tk 0 0 ne get tk 0 3 |
| 16798 | note d2site 380|s_abstract: extra words after a complete statement; condition if and ne get tk 0 0 ne get tk 0 3 |
| 16799 | put d2site 0 380 |
| 16800 | fail 5 |
| 16801 | end |
| 16802 | end |
| 16803 | put ab_name n w |
| 16804 | put ab_base n uchar t |
| 16805 | put ab_ops n ops |
| 16806 | put nab 0 add n 1 |
| 16807 | end |
| 16808 | |
| 16809 | note ab_entry: function f (index) is the entry of a function-mode unit: no abstract parameter or result |
| 16810 | fn ab_entry f ulong to void |
| 16811 | if eq get om2 0 0 |
| 16812 | ret |
| 16813 | end |
| 16814 | if ne get scanning 0 0 |
| 16815 | ret |
| 16816 | end |
| 16817 | if ne get progmode 0 0 |
| 16818 | ret |
| 16819 | end |
| 16820 | if ne get nexp 0 0 |
| 16821 | if eq uchar get a_ar add get a_rb 32 f 0 |
| 16822 | ret |
| 16823 | end |
| 16824 | else |
| 16825 | if ne add f 1 get nf 0 |
| 16826 | ret |
| 16827 | end |
| 16828 | end |
| 16829 | if ge uchar get a_ar add get a_rb 23 f 64 |
| 16830 | note d2site 381|ab_entry: type mismatch; condition if ge uchar get a_ar add get a_rb 23 f 64 |
| 16831 | put d2site 0 381 |
| 16832 | fail 7 |
| 16833 | end |
| 16834 | i = ulong 0 |
| 16835 | while lt i ulong uchar get a_ar add get a_rb 24 f |
| 16836 | if ge uchar get a_ar add get a_rb 35 add mul f 6 i 64 |
| 16837 | note d2site 382|ab_entry: type mismatch; condition if ge uchar get a_ar add get a_rb 35 add mul f 6 i 64 |
| 16838 | put d2site 0 382 |
| 16839 | fail 7 |
| 16840 | end |
| 16841 | i = add i 1 |
| 16842 | end |
| 16843 | end |
| 16844 | |
| 16845 | note ab_open: open v (the value read): an abstract value becomes its representation type |
| 16846 | fn ab_open to void |
| 16847 | t = get rt 0 |
| 16848 | if lt t 64 |
| 16849 | note d2site 383|ab_open: type mismatch; condition if lt t 64 |
| 16850 | put d2site 0 383 |
| 16851 | fail 7 |
| 16852 | end |
| 16853 | put rt 0 ulong get ab_base sub t 64 |
| 16854 | end |
| 16855 | |
| 16856 | note ab_seal: seal NAME v, only in the function NAMEmk (inlined or not) returning NAME (else error 28) |
| 16857 | fn ab_seal to void |
| 16858 | tok |
| 16859 | if or eq get tk 0 0 eq get tk 0 3 |
| 16860 | note d2site 384|ab_seal: the line ends where a word or value is needed; condition if or eq get tk 0 0 eq get tk 0 3 |
| 16861 | put d2site 0 384 |
| 16862 | fail 4 |
| 16863 | end |
| 16864 | a = ulong 0 |
| 16865 | if and eq get tk 0 1 le get tl 0 8 |
| 16866 | a = findab get tw 0 |
| 16867 | end |
| 16868 | if eq a 0 |
| 16869 | note d2site 385|ab_seal: syntax: unknown or misplaced word; condition if eq a 0 |
| 16870 | put d2site 0 385 |
| 16871 | fail 16 |
| 16872 | end |
| 16873 | a = sub a 1 |
| 16874 | fe = get curfn 0 |
| 16875 | if ne get inl 0 0 |
| 16876 | fe = get il_fn sub get inl 0 1 |
| 16877 | end |
| 16878 | if eq ab_ctor fe a 0 |
| 16879 | note d2site 386|ab_seal: abstract type: seal outside its constructor, or an unsupported holds; condition if eq ab_ctor fe a 0 |
| 16880 | put d2site 0 386 |
| 16881 | fail 28 |
| 16882 | end |
| 16883 | t = ulong get ab_base a |
| 16884 | rdval 0 t 255 0 |
| 16885 | if ne get rt 0 t |
| 16886 | note d2site 387|ab_seal: type mismatch; condition if ne get rt 0 t |
| 16887 | put d2site 0 387 |
| 16888 | fail 7 |
| 16889 | end |
| 16890 | r = matreg get rk 0 get rv 0 get rt 0 |
| 16891 | if ne get ab_holds a 0 |
| 16892 | ab_check fe a r |
| 16893 | end |
| 16894 | put rk 0 1 |
| 16895 | put rv 0 r |
| 16896 | put rt 0 add a 64 |
| 16897 | end |
| 16898 | |
| 16899 | note ab_ctor: 1 when function fe (index + 1) is NAMEmk for abstract a and returns it |
| 16900 | fn ab_ctor fe ulong a ulong to ulong |
| 16901 | if eq fe 0 |
| 16902 | ret 0 |
| 16903 | end |
| 16904 | f = sub fe 1 |
| 16905 | if ne ulong uchar get a_ar add get a_rb 23 f add a 64 |
| 16906 | ret 0 |
| 16907 | end |
| 16908 | l = get ab_len a |
| 16909 | if ne get a_ar add get a_rb 25 f add l 2 |
| 16910 | ret 0 |
| 16911 | end |
| 16912 | o = get a_ar add get a_rb 26 f |
| 16913 | w = get ab_name a |
| 16914 | i = ulong 0 |
| 16915 | while lt i l |
| 16916 | if ne ulong a_ib add o i and shr w shl i 3 255 |
| 16917 | ret 0 |
| 16918 | end |
| 16919 | i = add i 1 |
| 16920 | end |
| 16921 | if ne a_ib add o l 109 |
| 16922 | ret 0 |
| 16923 | end |
| 16924 | if ne a_ib add add o l 1 107 |
| 16925 | ret 0 |
| 16926 | end |
| 16927 | ret 1 |
| 16928 | end |
| 16929 | |
| 16930 | note ab_check: the dup32 check of a seal (value in r): erased for the exact body, else LSR Xt, Xr, #32 |
| 16931 | note (UBFM, C6.2.487); CMP Xt, Wr, UXTW (SUBS extended, C6.2.463); B.NE trap 10 |
| 16932 | fn ab_check fe ulong a ulong r ulong to void |
| 16933 | ex = ab_exact fe a |
| 16934 | if eq get om2m 0 1 |
| 16935 | note ab_rec: omc-check 1 kept|erased line=N rule=dup32|- (om2 diag, with the omc-site records) |
| 16936 | sitew 7162245557575183727 8 |
| 16937 | sitew 540090475 4 |
| 16938 | if ne ex 0 |
| 16939 | sitew 110386890240613 6 |
| 16940 | else |
| 16941 | sitew 1953523051 4 |
| 16942 | end |
| 16943 | sitew 67505853393952 6 |
| 16944 | siten add get line 0 get lbase 0 |
| 16945 | sitew 67505820627488 6 |
| 16946 | if ne ex 0 |
| 16947 | sitew 215611372900 5 |
| 16948 | else |
| 16949 | siteb 45 |
| 16950 | end |
| 16951 | siteb 10 |
| 16952 | end |
| 16953 | if eq ex 0 |
| 16954 | t = alloc |
| 16955 | if ne get xtarget 0 0 |
| 16956 | xload 0 r |
| 16957 | xload 1 r |
| 16958 | emitb 137 |
| 16959 | emitb 192 |
| 16960 | xb 72 193 233 |
| 16961 | emitb 32 |
| 16962 | xrr 57 0 1 |
| 16963 | xtrap 1 10 |
| 16964 | else |
| 16965 | emit or or 3546348544 t shl r 5 |
| 16966 | emit or or 3944759327 shl r 16 shl t 5 |
| 16967 | trapc 1 10 |
| 16968 | end |
| 16969 | end |
| 16970 | end |
| 16971 | |
| 16972 | note aw_next: the next word of the input from aw_p (blanks skipped, newlines counted in aw_nl) |
| 16973 | fn aw_next to void |
| 16974 | p = get aw_p 0 |
| 16975 | e = get inlen 0 |
| 16976 | nl = ulong 0 |
| 16977 | go = true |
| 16978 | while and go lt p e |
| 16979 | b = a_ib p |
| 16980 | if or eq b 32 eq b 9 |
| 16981 | p = add p 1 |
| 16982 | else |
| 16983 | if eq b 10 |
| 16984 | nl = add nl 1 |
| 16985 | p = add p 1 |
| 16986 | else |
| 16987 | go = false |
| 16988 | end |
| 16989 | end |
| 16990 | end |
| 16991 | w = ulong 0 |
| 16992 | l = ulong 0 |
| 16993 | go2 = true |
| 16994 | while and go2 lt p e |
| 16995 | c = a_ib p |
| 16996 | if or or eq c 32 eq c 9 eq c 10 |
| 16997 | go2 = false |
| 16998 | else |
| 16999 | if lt l 8 |
| 17000 | w = or w shl ulong c shl l 3 |
| 17001 | end |
| 17002 | l = add l 1 |
| 17003 | p = add p 1 |
| 17004 | end |
| 17005 | end |
| 17006 | put aw_p 0 p |
| 17007 | put aw_w 0 w |
| 17008 | put aw_l 0 l |
| 17009 | put aw_nl 0 nl |
| 17010 | end |
| 17011 | |
| 17012 | note aw_is: the next word is w (length l) after exactly nl newlines |
| 17013 | fn aw_is w ulong l ulong nl ulong to ulong |
| 17014 | aw_next |
| 17015 | if ne get aw_w 0 w |
| 17016 | ret 0 |
| 17017 | end |
| 17018 | if ne get aw_l 0 l |
| 17019 | ret 0 |
| 17020 | end |
| 17021 | if ne get aw_nl 0 nl |
| 17022 | ret 0 |
| 17023 | end |
| 17024 | ret 1 |
| 17025 | end |
| 17026 | |
| 17027 | note ab_upar: x (length xl) is a uint scalar parameter of function f (index) |
| 17028 | fn ab_upar f ulong x ulong xl ulong to ulong |
| 17029 | if gt xl 8 |
| 17030 | ret 0 |
| 17031 | end |
| 17032 | i = ulong 0 |
| 17033 | while lt i ulong uchar get a_ar add get a_rb 24 f |
| 17034 | p = add mul f 6 i |
| 17035 | if eq get a_ar add get a_rb 34 p x |
| 17036 | if eq uchar get a_ar add get a_rb 37 p 0 |
| 17037 | if eq uchar get a_ar add get a_rb 35 p 4 |
| 17038 | ret 1 |
| 17039 | end |
| 17040 | end |
| 17041 | end |
| 17042 | i = add i 1 |
| 17043 | end |
| 17044 | ret 0 |
| 17045 | end |
| 17046 | |
| 17047 | note ab_exact: the body of constructor fe is exactly `ret seal NAME or shl ulong x 32 ulong x` then `end` |
| 17048 | fn ab_exact fe ulong a ulong to ulong |
| 17049 | f = sub fe 1 |
| 17050 | put aw_p 0 get a_ar add get a_rb 28 f |
| 17051 | if eq aw_is 7628146 3 0 0 |
| 17052 | ret 0 |
| 17053 | end |
| 17054 | if eq aw_is 1818322291 4 0 0 |
| 17055 | ret 0 |
| 17056 | end |
| 17057 | if eq aw_is get ab_name a get ab_len a 0 0 |
| 17058 | ret 0 |
| 17059 | end |
| 17060 | if eq aw_is 29295 2 0 0 |
| 17061 | ret 0 |
| 17062 | end |
| 17063 | if eq aw_is 7104627 3 0 0 |
| 17064 | ret 0 |
| 17065 | end |
| 17066 | if eq aw_is 444234427509 5 0 0 |
| 17067 | ret 0 |
| 17068 | end |
| 17069 | aw_next |
| 17070 | if ne get aw_nl 0 0 |
| 17071 | ret 0 |
| 17072 | end |
| 17073 | x = get aw_w 0 |
| 17074 | xl = get aw_l 0 |
| 17075 | if eq ab_upar f x xl 0 |
| 17076 | ret 0 |
| 17077 | end |
| 17078 | if eq aw_is 12851 2 0 0 |
| 17079 | ret 0 |
| 17080 | end |
| 17081 | if eq aw_is 444234427509 5 0 0 |
| 17082 | ret 0 |
| 17083 | end |
| 17084 | if eq aw_is x xl 0 0 |
| 17085 | ret 0 |
| 17086 | end |
| 17087 | if eq aw_is 6581861 3 1 0 |
| 17088 | ret 0 |
| 17089 | end |
| 17090 | aw_next |
| 17091 | if and ne get aw_l 0 0 eq get aw_nl 0 0 |
| 17092 | ret 0 |
| 17093 | end |
| 17094 | ret 1 |
| 17095 | end |
| 17096 | |
| 17097 | note ab_bin: a binary operation whose operand (fr[x..x+5]) is abstract: only a listed preserving one, run |
| 17098 | note on the representation type T and giving NAME; rotr/rotl take a T count (E9), and/or/xor two NAME values |
| 17099 | fn ab_bin c ulong dst ulong x ulong to void |
| 17100 | at = get a_ar add get a_rb 77 add x 2 |
| 17101 | if lt at 64 |
| 17102 | note d2site 388|ab_bin: type mismatch; condition if lt at 64 |
| 17103 | put d2site 0 388 |
| 17104 | fail 7 |
| 17105 | end |
| 17106 | a = sub at 64 |
| 17107 | b = opbit c |
| 17108 | if eq b 0 |
| 17109 | note d2site 389|ab_bin: type mismatch; condition if eq b 0 |
| 17110 | put d2site 0 389 |
| 17111 | fail 7 |
| 17112 | end |
| 17113 | if eq and get ab_ops a b 0 |
| 17114 | note d2site 390|ab_bin: type mismatch; condition if eq and get ab_ops a b 0 |
| 17115 | put d2site 0 390 |
| 17116 | fail 7 |
| 17117 | end |
| 17118 | t = ulong get ab_base a |
| 17119 | bk = get a_ar add get a_rb 77 add x 3 |
| 17120 | bt = get a_ar add get a_rb 77 add x 5 |
| 17121 | if or eq c 59 eq c 60 |
| 17122 | if eq bk 2 |
| 17123 | range a_g 77 add x 4 t bt |
| 17124 | a_p 77 add x 3 3 |
| 17125 | else |
| 17126 | if ne bt t |
| 17127 | note d2site 391|ab_bin: type mismatch; condition if ne bt t |
| 17128 | put d2site 0 391 |
| 17129 | fail 7 |
| 17130 | end |
| 17131 | end |
| 17132 | else |
| 17133 | if ne bt at |
| 17134 | note d2site 392|ab_bin: type mismatch; condition if ne bt at |
| 17135 | put d2site 0 392 |
| 17136 | fail 7 |
| 17137 | end |
| 17138 | end |
| 17139 | put a_ar add get a_rb 77 add x 2 t |
| 17140 | put a_ar add get a_rb 77 add x 5 t |
| 17141 | binop c dst x |
| 17142 | put rt 0 at |
| 17143 | end |
| 17144 | |
| 17145 | note ======== OM-2 section 5: fresh scratch (spec 5, erratum E8). `NAME edit T N fresh` (N <= 64): the |
| 17146 | note incoming elements are unspecified. Each such array has a written set (bit i: element i definitely |
| 17147 | note written on the path being compiled). A put with a number index (after unrolling and inlining) sets |
| 17148 | note its bit; a get with a number index needs its bit, any other get all N bits (else error 27, |
| 17149 | note obligation=init). Joins: an if without else, a while and a rolled for keep the set they opened with; |
| 17150 | note an if/else takes the intersection of its arms (or the arm that does not end in ret); an unrolled |
| 17151 | note body and an inlined body keep what they wrote. Passing the array to a non-inline call, read, write or |
| 17152 | note a host operation is error 27; an inline callee works on the same set. ======== |
| 17153 | note fz_par: parameter slot f*6+np of kind k with N = ln is fresh: an edit only (else 16), N <= 64 (else 14) |
| 17154 | fn fz_par f ulong np ulong k ulong ln ulong to void |
| 17155 | if ne k 3 |
| 17156 | note d2site 393|fz_par: syntax: unknown or misplaced word; condition if ne k 3 |
| 17157 | put d2site 0 393 |
| 17158 | fail 16 |
| 17159 | end |
| 17160 | if gt ln 64 |
| 17161 | put dobx 0 1 |
| 17162 | note d2site 394|fz_par: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if gt ln 64 |
| 17163 | put d2site 0 394 |
| 17164 | fail 14 |
| 17165 | end |
| 17166 | a_pc 39 add mul f 6 np 1 |
| 17167 | end |
| 17168 | |
| 17169 | note fz_bind: the parameter name just added for slot p gets a new written set in the body pass |
| 17170 | fn fz_bind p ulong ln ulong to void |
| 17171 | if eq uchar get a_ar add get a_rb 39 p 0 |
| 17172 | ret |
| 17173 | end |
| 17174 | if ne get scanning 0 0 |
| 17175 | ret |
| 17176 | end |
| 17177 | fz_new sub get nn 0 1 ln |
| 17178 | end |
| 17179 | |
| 17180 | note fz_new: a new, empty written set of N elements for name index n (16 per function, error 14) |
| 17181 | fn fz_new n ulong ln ulong to void |
| 17182 | s = get fz_n 0 |
| 17183 | if ge s 16 |
| 17184 | put dobx 0 1 |
| 17185 | note d2site 395|fz_new: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge s 16 |
| 17186 | put d2site 0 395 |
| 17187 | fail 14 |
| 17188 | end |
| 17189 | put fz_len s ln |
| 17190 | put fz_cur s 0 |
| 17191 | a_pc 13 n uchar add s 1 |
| 17192 | put fz_n 0 add s 1 |
| 17193 | end |
| 17194 | |
| 17195 | note fz_inl: an inline parameter slot p bound to array name e: its own fresh set, or e's set |
| 17196 | fn fz_inl p ulong e ulong to void |
| 17197 | pk = ulong uchar get a_ar add get a_rb 37 p |
| 17198 | if or eq pk 0 ge pk 6 |
| 17199 | ret |
| 17200 | end |
| 17201 | n = sub get nn 0 1 |
| 17202 | if ne uchar get a_ar add get a_rb 39 p 0 |
| 17203 | fz_new n get a_ar add get a_rb 36 p |
| 17204 | ret |
| 17205 | end |
| 17206 | a_pc 13 n uchar get a_ar add get a_rb 13 sub e 1 |
| 17207 | end |
| 17208 | |
| 17209 | fn fz_else i ulong to void |
| 17210 | j = ulong 0 |
| 17211 | while lt j get fz_n 0 |
| 17212 | x = add mul i 16 j |
| 17213 | put a_ar add get a_rb 69 x get fz_cur j |
| 17214 | put fz_cur j get a_ar add get a_rb 68 x |
| 17215 | j = add j 1 |
| 17216 | end |
| 17217 | end |
| 17218 | |
| 17219 | fn fz_join i ulong k ulong to void |
| 17220 | td = get a_ar add get a_rb 56 i |
| 17221 | ed = get dead 0 |
| 17222 | j = ulong 0 |
| 17223 | while lt j get fz_n 0 |
| 17224 | x = add mul i 16 j |
| 17225 | if eq k 2 |
| 17226 | v = and get fz_cur j a_g 69 x |
| 17227 | if and ne td 0 eq ed 0 |
| 17228 | v = get fz_cur j |
| 17229 | end |
| 17230 | if and ne ed 0 eq td 0 |
| 17231 | v = get a_ar add get a_rb 69 x |
| 17232 | end |
| 17233 | put fz_cur j v |
| 17234 | else |
| 17235 | put fz_cur j get a_ar add get a_rb 68 x |
| 17236 | end |
| 17237 | j = add j 1 |
| 17238 | end |
| 17239 | end |
| 17240 | |
| 17241 | note fz_get: get e i with the index in rk/rv/rt |
| 17242 | fn fz_get e ulong to void |
| 17243 | if ne get cvalid 0 0 |
| 17244 | ret |
| 17245 | end |
| 17246 | s = ulong uchar get a_ar add get a_rb 13 sub e 1 |
| 17247 | if eq s 0 |
| 17248 | ret |
| 17249 | end |
| 17250 | s = sub s 1 |
| 17251 | n = get fz_len s |
| 17252 | if eq get rk 0 3 |
| 17253 | v = get rv 0 |
| 17254 | if lt v n |
| 17255 | if eq and shr get fz_cur s v 1 0 |
| 17256 | note d2site 396|fz_get: fresh element read before it is definitely written, or fresh array passed on; condition if eq and shr get fz_cur s v 1 0 |
| 17257 | put d2site 0 396 |
| 17258 | fail 27 |
| 17259 | end |
| 17260 | end |
| 17261 | ret |
| 17262 | end |
| 17263 | if ne get fz_cur s fmask n |
| 17264 | note d2site 397|fz_get: fresh element read before it is definitely written, or fresh array passed on; condition if ne get fz_cur s fmask n |
| 17265 | put d2site 0 397 |
| 17266 | fail 27 |
| 17267 | end |
| 17268 | end |
| 17269 | |
| 17270 | note fz_put: put e i v with index (k, v): a number index sets its bit |
| 17271 | fn fz_put e ulong k ulong v ulong to void |
| 17272 | s = ulong uchar get a_ar add get a_rb 13 sub e 1 |
| 17273 | if eq s 0 |
| 17274 | ret |
| 17275 | end |
| 17276 | s = sub s 1 |
| 17277 | if eq k 3 |
| 17278 | if lt v get fz_len s |
| 17279 | put fz_cur s or get fz_cur s shl ulong 1 v |
| 17280 | end |
| 17281 | end |
| 17282 | end |
| 17283 | |
| 17284 | note fz_arg: array name e leaves the analysis (a non-inline call, read, write, a host operation): error 27 |
| 17285 | note when it is tracked |
| 17286 | fn fz_arg e ulong to void |
| 17287 | if ne uchar get a_ar add get a_rb 13 sub e 1 0 |
| 17288 | note d2site 398|fz_arg: fresh element read before it is definitely written, or fresh array passed on; condition if ne uchar get a_ar add get a_rb 13 sub e 1 0 |
| 17289 | put d2site 0 398 |
| 17290 | fail 27 |
| 17291 | end |
| 17292 | end |
| 17293 | |
| 17294 | note ======== OM-2 section 5: external layouts (spec 5, errata E5, E8, E9). `layout NAME SIZE`, then one |
| 17295 | note `field F T [COUNT] at OFF little|big` per line, then `end`, before the first fn. Read in the names pass; |
| 17296 | note the body pass jumps over the block. A parameter `c view|edit NAME` is a uchar array of SIZE bytes (one |
| 17297 | note pointer); `get c F [i]` / `put c F [i] v` load / store the field at its width and byte order: |
| 17298 | note LDR/STR (register, unscaled offset; C6.2.216 family) at base + OFF + i * width, REV16 / REV (C6.2.333, |
| 17299 | note C6.2.331) for big, a run-time index checked like an array's (CMP, B.HS trap 3) ======== |
| 17300 | note findlay: packed name -> layout index + 1, or 0 |
| 17301 | fn findlay w ulong to ulong |
| 17302 | i = ulong 0 |
| 17303 | while lt i get nly 0 |
| 17304 | if eq get ly_name i w |
| 17305 | ret add i 1 |
| 17306 | end |
| 17307 | i = add i 1 |
| 17308 | end |
| 17309 | ret 0 |
| 17310 | end |
| 17311 | |
| 17312 | note findlf: layout index li, packed field name -> field-table index + 1, or 0 |
| 17313 | fn findlf li ulong w ulong to ulong |
| 17314 | fo = get ly_fo li |
| 17315 | i = ulong 0 |
| 17316 | while lt i get ly_nf li |
| 17317 | if eq get lf_name add fo i w |
| 17318 | ret add add fo i 1 |
| 17319 | end |
| 17320 | i = add i 1 |
| 17321 | end |
| 17322 | ret 0 |
| 17323 | end |
| 17324 | |
| 17325 | note ns_om2: an OM-2 declaration line in the names pass (1 when it was read), else 0 |
| 17326 | fn ns_om2 to ulong |
| 17327 | if ne get objmode 0 0 |
| 17328 | if and eq get tl 0 6 eq get tw 0 121437607458917 |
| 17329 | s_extern |
| 17330 | ret 1 |
| 17331 | end |
| 17332 | end |
| 17333 | if eq get om2 0 0 |
| 17334 | ret 0 |
| 17335 | end |
| 17336 | if ne get tk 0 1 |
| 17337 | ret 0 |
| 17338 | end |
| 17339 | if gt get tl 0 8 |
| 17340 | ret 0 |
| 17341 | end |
| 17342 | if eq get tw 0 128047730221420 |
| 17343 | s_layout |
| 17344 | ret 1 |
| 17345 | end |
| 17346 | if eq get tw 0 8386654075301880417 |
| 17347 | s_abstract |
| 17348 | ret 1 |
| 17349 | end |
| 17350 | if eq get tw 0 495606067048 |
| 17351 | note s_holds: holds NAME dup32 (ulong representation only); any other predicate is error 28 on this line |
| 17352 | if ne get nf 0 0 |
| 17353 | note d2site 399|ns_om2: word or declaration in a place that does not allow it; condition if ne get nf 0 0 |
| 17354 | put d2site 0 399 |
| 17355 | fail 9 |
| 17356 | end |
| 17357 | tok |
| 17358 | if ne get tk 0 1 |
| 17359 | note d2site 400|ns_om2: syntax: unknown or misplaced word; condition if ne get tk 0 1 |
| 17360 | put d2site 0 400 |
| 17361 | fail 16 |
| 17362 | end |
| 17363 | a = ulong 0 |
| 17364 | if le get tl 0 8 |
| 17365 | a = findab get tw 0 |
| 17366 | end |
| 17367 | if eq a 0 |
| 17368 | note d2site 401|ns_om2: syntax: unknown or misplaced word; condition if eq a 0 |
| 17369 | put d2site 0 401 |
| 17370 | fail 16 |
| 17371 | end |
| 17372 | a = sub a 1 |
| 17373 | tok |
| 17374 | if or eq get tk 0 0 eq get tk 0 3 |
| 17375 | note d2site 402|ns_om2: the line ends where a word or value is needed; condition if or eq get tk 0 0 eq get tk 0 3 |
| 17376 | put d2site 0 402 |
| 17377 | fail 4 |
| 17378 | end |
| 17379 | if ne get tk 0 1 |
| 17380 | note d2site 403|ns_om2: abstract type: seal outside its constructor, or an unsupported holds; condition if ne get tk 0 1 |
| 17381 | put d2site 0 403 |
| 17382 | fail 28 |
| 17383 | end |
| 17384 | if or ne get tl 0 5 ne get tw 0 215611372900 |
| 17385 | note d2site 404|ns_om2: abstract type: seal outside its constructor, or an unsupported holds; condition if or ne get tl 0 5 ne get tw 0 215611372900 |
| 17386 | put d2site 0 404 |
| 17387 | fail 28 |
| 17388 | end |
| 17389 | if ne get ab_base a 5 |
| 17390 | note d2site 405|ns_om2: abstract type: seal outside its constructor, or an unsupported holds; condition if ne get ab_base a 5 |
| 17391 | put d2site 0 405 |
| 17392 | fail 28 |
| 17393 | end |
| 17394 | if ne get ab_holds a 0 |
| 17395 | note d2site 406|ns_om2: duplicate name; condition if ne get ab_holds a 0 |
| 17396 | put d2site 0 406 |
| 17397 | fail 10 |
| 17398 | end |
| 17399 | put ab_holds a 1 |
| 17400 | eol |
| 17401 | ret 1 |
| 17402 | end |
| 17403 | if eq get tw 0 128034844735589 |
| 17404 | s_export |
| 17405 | ret 1 |
| 17406 | end |
| 17407 | ret 0 |
| 17408 | end |
| 17409 | |
| 17410 | note s_export (OM-2, spec 6): `export fn ...` at top level: the fn line of an exported entry, in both |
| 17411 | note passes. Function mode only (error 9), at most 32 (error 14), counted and marked in the names pass. |
| 17412 | fn s_export to void |
| 17413 | tok |
| 17414 | if or ne get tk 0 1 ne get tw 0 28262 |
| 17415 | note d2site 407|s_export: syntax: unknown or misplaced word; condition if or ne get tk 0 1 ne get tw 0 28262 |
| 17416 | put d2site 0 407 |
| 17417 | fail 16 |
| 17418 | end |
| 17419 | if eq get scanning 0 1 |
| 17420 | if ne get progmode 0 0 |
| 17421 | note d2site 408|s_export: word or declaration in a place that does not allow it; condition if ne get progmode 0 0 |
| 17422 | put d2site 0 408 |
| 17423 | fail 9 |
| 17424 | end |
| 17425 | if eq get objmode 0 0 |
| 17426 | if ge get nexp 0 32 |
| 17427 | note d2site 409|s_export: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge get nexp 0 32 |
| 17428 | put d2site 0 409 |
| 17429 | fail 14 |
| 17430 | end |
| 17431 | end |
| 17432 | put nexp 0 add get nexp 0 1 |
| 17433 | end |
| 17434 | put expf 0 1 |
| 17435 | s_fn |
| 17436 | put expf 0 0 |
| 17437 | end |
| 17438 | |
| 17439 | note ly_num: the next token must be a number (error 4 at the line end, 16 for another token, 29 when it |
| 17440 | note was written as 2^63 or more) |
| 17441 | fn ly_num to ulong |
| 17442 | tok |
| 17443 | if or eq get tk 0 0 eq get tk 0 3 |
| 17444 | note d2site 410|ly_num: the line ends where a word or value is needed; condition if or eq get tk 0 0 eq get tk 0 3 |
| 17445 | put d2site 0 410 |
| 17446 | fail 4 |
| 17447 | end |
| 17448 | if ne get tk 0 2 |
| 17449 | note d2site 411|ly_num: syntax: unknown or misplaced word; condition if ne get tk 0 2 |
| 17450 | put d2site 0 411 |
| 17451 | fail 16 |
| 17452 | end |
| 17453 | if ne get tbig 0 0 |
| 17454 | note d2site 412|ly_num: external layout out of bounds or misplaced; condition if ne get tbig 0 0 |
| 17455 | put d2site 0 412 |
| 17456 | fail 29 |
| 17457 | end |
| 17458 | ret get tw 0 |
| 17459 | end |
| 17460 | |
| 17461 | note s_layout: SIZE 1..4096 and a layout after the first fn are error 29 on the layout line |
| 17462 | fn s_layout to void |
| 17463 | if ne get nf 0 0 |
| 17464 | note d2site 413|s_layout: external layout out of bounds or misplaced; condition if ne get nf 0 0 |
| 17465 | put d2site 0 413 |
| 17466 | fail 29 |
| 17467 | end |
| 17468 | tok |
| 17469 | if ne get tk 0 1 |
| 17470 | note d2site 414|s_layout: syntax: unknown or misplaced word; condition if ne get tk 0 1 |
| 17471 | put d2site 0 414 |
| 17472 | fail 16 |
| 17473 | end |
| 17474 | if gt get tl 0 8 |
| 17475 | note d2site 415|s_layout: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 8 |
| 17476 | put d2site 0 415 |
| 17477 | fail 13 |
| 17478 | end |
| 17479 | w = get tw 0 |
| 17480 | if ne kw w 0 |
| 17481 | note d2site 416|s_layout: syntax: unknown or misplaced word; condition if ne kw w 0 |
| 17482 | put d2site 0 416 |
| 17483 | fail 16 |
| 17484 | end |
| 17485 | newname w get tl 0 get ts 0 |
| 17486 | if ge get nly 0 16 |
| 17487 | note d2site 417|s_layout: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge get nly 0 16 |
| 17488 | put d2site 0 417 |
| 17489 | fail 14 |
| 17490 | end |
| 17491 | sz = ly_num |
| 17492 | if or eq sz 0 gt sz 4096 |
| 17493 | note d2site 418|s_layout: external layout out of bounds or misplaced; condition if or eq sz 0 gt sz 4096 |
| 17494 | put d2site 0 418 |
| 17495 | fail 29 |
| 17496 | end |
| 17497 | eol |
| 17498 | li = get nly 0 |
| 17499 | fo = get nlf 0 |
| 17500 | i = ulong 0 |
| 17501 | while lt i sz |
| 17502 | put lymap i 0 |
| 17503 | i = add i 1 |
| 17504 | end |
| 17505 | go = true |
| 17506 | while go |
| 17507 | tok |
| 17508 | k = get tk 0 |
| 17509 | if eq k 3 |
| 17510 | note d2site 419|s_layout: the line ends where a word or value is needed; condition if eq k 3 |
| 17511 | put d2site 0 419 |
| 17512 | fail 4 |
| 17513 | end |
| 17514 | if eq k 1 |
| 17515 | c = ulong 0 |
| 17516 | if le get tl 0 8 |
| 17517 | c = kw get tw 0 |
| 17518 | end |
| 17519 | if eq c 66 |
| 17520 | eol |
| 17521 | go = false |
| 17522 | else |
| 17523 | if eq c 83 |
| 17524 | skipnl |
| 17525 | else |
| 17526 | if ne c 189 |
| 17527 | note d2site 420|s_layout: syntax: unknown or misplaced word; condition if ne c 189 |
| 17528 | put d2site 0 420 |
| 17529 | fail 16 |
| 17530 | end |
| 17531 | ly_field fo sz |
| 17532 | end |
| 17533 | end |
| 17534 | else |
| 17535 | if ne k 0 |
| 17536 | note d2site 421|s_layout: syntax: unknown or misplaced word; condition if ne k 0 |
| 17537 | put d2site 0 421 |
| 17538 | fail 16 |
| 17539 | end |
| 17540 | end |
| 17541 | end |
| 17542 | put ly_name li w |
| 17543 | put ly_size li sz |
| 17544 | put ly_fo li fo |
| 17545 | put ly_nf li sub get nlf 0 fo |
| 17546 | put ly_ec li get cur 0 |
| 17547 | put ly_el li get line 0 |
| 17548 | put nly 0 add li 1 |
| 17549 | end |
| 17550 | |
| 17551 | note ly_field: F T [COUNT] at OFF little|big. A field over SIZE, a COUNT outside 1..4096, an OFF out of range |
| 17552 | note or two fields sharing a byte are error 29 on the field line. Field types are the integer types. |
| 17553 | fn ly_field fo ulong sz ulong to void |
| 17554 | tok |
| 17555 | if or eq get tk 0 0 eq get tk 0 3 |
| 17556 | note d2site 422|ly_field: the line ends where a word or value is needed; condition if or eq get tk 0 0 eq get tk 0 3 |
| 17557 | put d2site 0 422 |
| 17558 | fail 4 |
| 17559 | end |
| 17560 | if ne get tk 0 1 |
| 17561 | note d2site 423|ly_field: syntax: unknown or misplaced word; condition if ne get tk 0 1 |
| 17562 | put d2site 0 423 |
| 17563 | fail 16 |
| 17564 | end |
| 17565 | if gt get tl 0 8 |
| 17566 | note d2site 424|ly_field: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 8 |
| 17567 | put d2site 0 424 |
| 17568 | fail 13 |
| 17569 | end |
| 17570 | fw = get tw 0 |
| 17571 | if ne kw fw 0 |
| 17572 | note d2site 425|ly_field: syntax: unknown or misplaced word; condition if ne kw fw 0 |
| 17573 | put d2site 0 425 |
| 17574 | fail 16 |
| 17575 | end |
| 17576 | n = get nlf 0 |
| 17577 | i = fo |
| 17578 | while lt i n |
| 17579 | if eq get lf_name i fw |
| 17580 | note d2site 426|ly_field: duplicate name; condition if eq get lf_name i fw |
| 17581 | put d2site 0 426 |
| 17582 | fail 10 |
| 17583 | end |
| 17584 | i = add i 1 |
| 17585 | end |
| 17586 | if ge n 256 |
| 17587 | note d2site 427|ly_field: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge n 256 |
| 17588 | put d2site 0 427 |
| 17589 | fail 14 |
| 17590 | end |
| 17591 | t = typeword |
| 17592 | if or lt t 2 gt t 9 |
| 17593 | note d2site 428|ly_field: type mismatch; condition if or lt t 2 gt t 9 |
| 17594 | put d2site 0 428 |
| 17595 | fail 7 |
| 17596 | end |
| 17597 | cnt = ulong 0 |
| 17598 | tok |
| 17599 | if eq get tk 0 2 |
| 17600 | if ne get tbig 0 0 |
| 17601 | note d2site 429|ly_field: external layout out of bounds or misplaced; condition if ne get tbig 0 0 |
| 17602 | put d2site 0 429 |
| 17603 | fail 29 |
| 17604 | end |
| 17605 | cnt = get tw 0 |
| 17606 | if or eq cnt 0 gt cnt 4096 |
| 17607 | note d2site 430|ly_field: external layout out of bounds or misplaced; condition if or eq cnt 0 gt cnt 4096 |
| 17608 | put d2site 0 430 |
| 17609 | fail 29 |
| 17610 | end |
| 17611 | tok |
| 17612 | end |
| 17613 | if or eq get tk 0 0 eq get tk 0 3 |
| 17614 | note d2site 431|ly_field: the line ends where a word or value is needed; condition if or eq get tk 0 0 eq get tk 0 3 |
| 17615 | put d2site 0 431 |
| 17616 | fail 4 |
| 17617 | end |
| 17618 | if ne get tk 0 1 |
| 17619 | note d2site 432|ly_field: syntax: unknown or misplaced word; condition if ne get tk 0 1 |
| 17620 | put d2site 0 432 |
| 17621 | fail 16 |
| 17622 | end |
| 17623 | if ne kw get tw 0 190 |
| 17624 | note d2site 433|ly_field: syntax: unknown or misplaced word; condition if ne kw get tw 0 190 |
| 17625 | put d2site 0 433 |
| 17626 | fail 16 |
| 17627 | end |
| 17628 | off = ly_num |
| 17629 | big = ly_end |
| 17630 | ly_mark off cnt t sz |
| 17631 | eol |
| 17632 | put lf_name n fw |
| 17633 | put lf_type n uchar t |
| 17634 | put lf_cnt n cnt |
| 17635 | put lf_off n off |
| 17636 | put lf_big n uchar big |
| 17637 | put nlf 0 add n 1 |
| 17638 | end |
| 17639 | |
| 17640 | note ly_end: little (0) or big (1) |
| 17641 | fn ly_end to ulong |
| 17642 | tok |
| 17643 | if or eq get tk 0 0 eq get tk 0 3 |
| 17644 | note d2site 434|ly_end: the line ends where a word or value is needed; condition if or eq get tk 0 0 eq get tk 0 3 |
| 17645 | put d2site 0 434 |
| 17646 | fail 4 |
| 17647 | end |
| 17648 | if ne get tk 0 1 |
| 17649 | note d2site 435|ly_end: syntax: unknown or misplaced word; condition if ne get tk 0 1 |
| 17650 | put d2site 0 435 |
| 17651 | fail 16 |
| 17652 | end |
| 17653 | c = kw get tw 0 |
| 17654 | if eq c 191 |
| 17655 | ret 0 |
| 17656 | end |
| 17657 | if eq c 192 |
| 17658 | ret 1 |
| 17659 | end |
| 17660 | note d2site 436|ly_end: syntax: unknown or misplaced word |
| 17661 | put d2site 0 436 |
| 17662 | fail 16 |
| 17663 | ret 0 |
| 17664 | end |
| 17665 | |
| 17666 | note ly_mark: the bytes OFF .. OFF + max(COUNT, 1) * width must lie inside SIZE and be free (error 29) |
| 17667 | fn ly_mark off ulong cnt ulong t ulong sz ulong to void |
| 17668 | n = cnt |
| 17669 | if eq n 0 |
| 17670 | n = ulong 1 |
| 17671 | end |
| 17672 | by = shl n tlog t |
| 17673 | if gt off sz |
| 17674 | note d2site 437|ly_mark: external layout out of bounds or misplaced; condition if gt off sz |
| 17675 | put d2site 0 437 |
| 17676 | fail 29 |
| 17677 | end |
| 17678 | e = add off by |
| 17679 | if gt e sz |
| 17680 | note d2site 438|ly_mark: external layout out of bounds or misplaced; condition if gt e sz |
| 17681 | put d2site 0 438 |
| 17682 | fail 29 |
| 17683 | end |
| 17684 | i = off |
| 17685 | while lt i e |
| 17686 | if ne get lymap i 0 |
| 17687 | note d2site 439|ly_mark: external layout out of bounds or misplaced; condition if ne get lymap i 0 |
| 17688 | put d2site 0 439 |
| 17689 | fail 29 |
| 17690 | end |
| 17691 | put lymap i 1 |
| 17692 | i = add i 1 |
| 17693 | end |
| 17694 | end |
| 17695 | |
| 17696 | note peek_lay: if the next word is a layout name, consume it and return index + 1; else rewind |
| 17697 | fn peek_lay to ulong |
| 17698 | p = get cur 0 |
| 17699 | ln = get line 0 |
| 17700 | tok |
| 17701 | if eq get tk 0 1 |
| 17702 | if le get tl 0 8 |
| 17703 | lid = findlay get tw 0 |
| 17704 | if ne lid 0 |
| 17705 | ret lid |
| 17706 | end |
| 17707 | end |
| 17708 | end |
| 17709 | put cur 0 p |
| 17710 | put line 0 ln |
| 17711 | ret 0 |
| 17712 | end |
| 17713 | |
| 17714 | note fn_p_ly: parameter pw is a layout (view k 2 / edit k 3): a uchar array of SIZE bytes, name kind 2 / 3 |
| 17715 | fn fn_p_ly f ulong np ulong pw ulong lid ulong k ulong to void |
| 17716 | ln = get ly_size sub lid 1 |
| 17717 | addname pw poolc get psl 0 2 ln k 0 |
| 17718 | a_pc 12 sub get nn 0 1 uchar lid |
| 17719 | p = add mul f 6 np |
| 17720 | a_pc 35 p 2 |
| 17721 | put a_ar add get a_rb 36 p ln |
| 17722 | a_pc 37 p uchar k |
| 17723 | a_pc 38 p uchar lid |
| 17724 | end |
| 17725 | |
| 17726 | note ly_fld: for a layout name e, when the next word is one of its fields: consume it, return the field-table |
| 17727 | note index + 1; otherwise rewind and return 0 (the name is then an ordinary uchar array) |
| 17728 | fn ly_fld e ulong to ulong |
| 17729 | lid = ulong uchar get a_ar add get a_rb 12 sub e 1 |
| 17730 | if eq lid 0 |
| 17731 | ret 0 |
| 17732 | end |
| 17733 | p = get cur 0 |
| 17734 | ln = get line 0 |
| 17735 | tok |
| 17736 | if eq get tk 0 1 |
| 17737 | if le get tl 0 8 |
| 17738 | j = findlf sub lid 1 get tw 0 |
| 17739 | if ne j 0 |
| 17740 | ret j |
| 17741 | end |
| 17742 | end |
| 17743 | end |
| 17744 | put cur 0 p |
| 17745 | put line 0 ln |
| 17746 | ret 0 |
| 17747 | end |
| 17748 | |
| 17749 | note ldun / stun: LDRB / LDRH / LDR w / LDR x and the stores, register offset, LSL #0 (S = 0) |
| 17750 | fn ldun t ulong to ulong |
| 17751 | if or eq t 2 eq t 6 |
| 17752 | ret 945842176 |
| 17753 | end |
| 17754 | if or eq t 3 eq t 7 |
| 17755 | ret 2019584000 |
| 17756 | end |
| 17757 | if or eq t 4 eq t 8 |
| 17758 | ret 3093325824 |
| 17759 | end |
| 17760 | ret 4167067648 |
| 17761 | end |
| 17762 | |
| 17763 | fn stun t ulong to ulong |
| 17764 | if or eq t 2 eq t 6 |
| 17765 | ret 941647872 |
| 17766 | end |
| 17767 | if or eq t 3 eq t 7 |
| 17768 | ret 2015389696 |
| 17769 | end |
| 17770 | if or eq t 4 eq t 8 |
| 17771 | ret 3089131520 |
| 17772 | end |
| 17773 | ret 4162873344 |
| 17774 | end |
| 17775 | |
| 17776 | note ly_rev: Rd = the bytes of Rs reversed at width t: REV16 Wd (C6.2.333), REV Wd, REV Xd (C6.2.331) |
| 17777 | fn ly_rev t ulong s ulong d ulong to void |
| 17778 | if ne get xtarget 0 0 |
| 17779 | xload 0 s |
| 17780 | if or eq t 2 eq t 6 |
| 17781 | xstore 0 d |
| 17782 | ret |
| 17783 | end |
| 17784 | if or eq t 3 eq t 7 |
| 17785 | emitb 102 |
| 17786 | xb 193 200 8 |
| 17787 | else |
| 17788 | if or eq t 5 eq t 9 |
| 17789 | emitb 72 |
| 17790 | end |
| 17791 | emitb 15 |
| 17792 | emitb 200 |
| 17793 | end |
| 17794 | xstore 0 d |
| 17795 | ret |
| 17796 | end |
| 17797 | if or eq t 3 eq t 7 |
| 17798 | emit or or 1522533376 d shl s 5 |
| 17799 | end |
| 17800 | if or eq t 4 eq t 8 |
| 17801 | emit or or 1522534400 d shl s 5 |
| 17802 | end |
| 17803 | if or eq t 5 eq t 9 |
| 17804 | emit or or 3670019072 d shl s 5 |
| 17805 | end |
| 17806 | end |
| 17807 | |
| 17808 | note ly_ix: the byte-offset register of element (k, v, t) of array field j: a number index must be below |
| 17809 | note COUNT (error 21); a register index: CMP Xi, #COUNT or Xc (C6.2.96 / C6.2.97), B.HS trap 3, then |
| 17810 | note Xo = OFF; ADD Xo, Xo, Xi, LSL #log2 width (C6.2.6) |
| 17811 | fn ly_ix j ulong k ulong v ulong t ulong to ulong |
| 17812 | if or eq t 1 ge t 10 |
| 17813 | note d2site 440|ly_ix: type mismatch; condition if or eq t 1 ge t 10 |
| 17814 | put d2site 0 440 |
| 17815 | fail 7 |
| 17816 | end |
| 17817 | cnt = get lf_cnt j |
| 17818 | sh = tlog ulong get lf_type j |
| 17819 | x = alloc |
| 17820 | if eq k 3 |
| 17821 | if ge v cnt |
| 17822 | note d2site 441|ly_ix: constant index outside the array; condition if ge v cnt |
| 17823 | put d2site 0 441 |
| 17824 | fail 21 |
| 17825 | end |
| 17826 | matconst x add get lf_off j shl v sh |
| 17827 | ret x |
| 17828 | end |
| 17829 | r = matreg k v t |
| 17830 | if ne get xtarget 0 0 |
| 17831 | xcmp r cnt 1 |
| 17832 | xtrap 2 3 |
| 17833 | xload 0 r |
| 17834 | xb 72 193 224 |
| 17835 | emitb uchar sh |
| 17836 | ximm 1 get lf_off j |
| 17837 | xrr 1 0 1 |
| 17838 | xstore 0 x |
| 17839 | ret x |
| 17840 | end |
| 17841 | if le cnt 4095 |
| 17842 | emit or or 4043309087 shl cnt 10 shl r 5 |
| 17843 | else |
| 17844 | y = alloc |
| 17845 | matconst y cnt |
| 17846 | emit or or 3942645791 shl y 16 shl r 5 |
| 17847 | end |
| 17848 | trapc 2 3 |
| 17849 | matconst x get lf_off j |
| 17850 | emit or or or or 2332033024 x shl x 5 shl r 16 shl sh 10 |
| 17851 | ret x |
| 17852 | end |
| 17853 | |
| 17854 | note ly_get: get c F [i] on a layout name e (1 when it was a field, the value in rk/rv/rt), else 0 |
| 17855 | fn ly_get e ulong dst ulong to ulong |
| 17856 | j = ly_fld e |
| 17857 | if eq j 0 |
| 17858 | ret 0 |
| 17859 | end |
| 17860 | j = sub j 1 |
| 17861 | ft = ulong get lf_type j |
| 17862 | x = ulong 0 |
| 17863 | if eq get lf_cnt j 0 |
| 17864 | x = alloc |
| 17865 | matconst x get lf_off j |
| 17866 | else |
| 17867 | rdval 0 5 255 0 |
| 17868 | x = ly_ix j get rk 0 get rv 0 get rt 0 |
| 17869 | end |
| 17870 | rd = destreg dst |
| 17871 | if ne get xtarget 0 0 |
| 17872 | xlayout 0 ulong uchar get a_ar add get a_rb 4 sub e 1 x ft rd |
| 17873 | else |
| 17874 | emit or or or ldun ft rd shl ulong a_gu 4 sub e 1 5 shl x 16 |
| 17875 | end |
| 17876 | if ne get lf_big j 0 |
| 17877 | ly_rev ft rd rd |
| 17878 | end |
| 17879 | if gt ft 5 |
| 17880 | canon rd ft |
| 17881 | end |
| 17882 | put rk 0 1 |
| 17883 | put rv 0 rd |
| 17884 | put rt 0 ft |
| 17885 | ret 1 |
| 17886 | end |
| 17887 | |
| 17888 | note ly_put: put c F [i] v on a layout name e (an edit; a view was refused 20 before): index, value, then |
| 17889 | note the store; 1 when it was a field, else 0 |
| 17890 | fn ly_put e ulong to ulong |
| 17891 | j = ly_fld e |
| 17892 | if eq j 0 |
| 17893 | ret 0 |
| 17894 | end |
| 17895 | j = sub j 1 |
| 17896 | if ne get lf_cnt j 0 |
| 17897 | rdval 0 5 255 0 |
| 17898 | put svk 0 get rk 0 |
| 17899 | put svv 0 get rv 0 |
| 17900 | put svt 0 get rt 0 |
| 17901 | end |
| 17902 | ly_st e j |
| 17903 | eol |
| 17904 | ret 1 |
| 17905 | end |
| 17906 | |
| 17907 | note ly_st: the value of field j (index saved in svk/svv/svt), then the store through layout name e |
| 17908 | fn ly_st e ulong j ulong to void |
| 17909 | ft = ulong get lf_type j |
| 17910 | cnt = get lf_cnt j |
| 17911 | rdval 0 ft 255 0 |
| 17912 | if ne get rt 0 ft |
| 17913 | note d2site 442|ly_st: type mismatch; condition if ne get rt 0 ft |
| 17914 | put d2site 0 442 |
| 17915 | fail 7 |
| 17916 | end |
| 17917 | v = matreg get rk 0 get rv 0 get rt 0 |
| 17918 | x = ulong 0 |
| 17919 | if eq cnt 0 |
| 17920 | x = alloc |
| 17921 | matconst x get lf_off j |
| 17922 | else |
| 17923 | x = ly_ix j get svk 0 get svv 0 get svt 0 |
| 17924 | end |
| 17925 | if and ne get lf_big j 0 ne tlog ft 0 |
| 17926 | y = alloc |
| 17927 | ly_rev ft v y |
| 17928 | v = y |
| 17929 | end |
| 17930 | if ne get xtarget 0 0 |
| 17931 | xlayout 1 ulong uchar get a_ar add get a_rb 4 sub e 1 x ft v |
| 17932 | else |
| 17933 | emit or or or stun ft v shl ulong a_gu 4 sub e 1 5 shl x 16 |
| 17934 | end |
| 17935 | end |
| 17936 | |
| 17937 | note vt_fget_go: field j of struct name e. Scalar, or an index then the element. |
| 17938 | fn vt_fget_go e ulong dst ulong j ulong to void |
| 17939 | fl = ulong get sf_len j |
| 17940 | ft = ulong get sf_type j |
| 17941 | off = ulong get sf_off j |
| 17942 | base = ulong uchar get a_ar add get a_rb 4 sub e 1 |
| 17943 | idx = alloc |
| 17944 | if eq fl 0 |
| 17945 | st_store_ld base idx off ft dst |
| 17946 | else |
| 17947 | rdval 0 5 255 0 |
| 17948 | if eq get rt 0 1 |
| 17949 | note d2site 443|vt_fget_go: type mismatch; condition if eq get rt 0 1 |
| 17950 | put d2site 0 443 |
| 17951 | fail 7 |
| 17952 | end |
| 17953 | if eq get rk 0 3 |
| 17954 | if ge get rv 0 fl |
| 17955 | note d2site 444|vt_fget_go: constant index outside the array; condition if ge get rv 0 fl |
| 17956 | put d2site 0 444 |
| 17957 | fail 21 |
| 17958 | end |
| 17959 | st_store_ld base idx add off get rv 0 ft dst |
| 17960 | else |
| 17961 | if ne get rk 0 1 |
| 17962 | note d2site 445|vt_fget_go: type mismatch; condition if ne get rk 0 1 |
| 17963 | put d2site 0 445 |
| 17964 | fail 7 |
| 17965 | end |
| 17966 | st_ixreg idx get rv 0 off fl ft |
| 17967 | st_ld base idx ft dst |
| 17968 | end |
| 17969 | end |
| 17970 | end |
| 17971 | |
| 17972 | note vt_fget: get p f, or get p f i for an array field. Kind 6 own, 7 edit, 8 view; all may be read. |
| 17973 | fn vt_fget e ulong dst ulong to void |
| 17974 | i = sub e 1 |
| 17975 | tok |
| 17976 | if ne get tk 0 1 |
| 17977 | note d2site 446|vt_fget: syntax: unknown or misplaced word; condition if ne get tk 0 1 |
| 17978 | put d2site 0 446 |
| 17979 | fail 16 |
| 17980 | end |
| 17981 | if gt get tl 0 63 |
| 17982 | note d2site 447|vt_fget: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63 |
| 17983 | put d2site 0 447 |
| 17984 | fail 13 |
| 17985 | end |
| 17986 | si = sub ulong uchar get a_ar add get a_rb 5 i 16 |
| 17987 | fid = findfield si get tw 0 |
| 17988 | if eq fid 0 |
| 17989 | note d2site 448|vt_fget: unknown name or field, or a word this mode does not provide; condition if eq fid 0 |
| 17990 | put d2site 0 448 |
| 17991 | fail 3 |
| 17992 | end |
| 17993 | vt_fget_go e dst sub fid 1 |
| 17994 | end |
| 17995 | |
| 17996 | note st_store_ld: constant cell, then load. Split out so vt_fget stays under 16 registers. |
| 17997 | fn st_store_ld base ulong idx ulong cell ulong t ulong dst ulong to void |
| 17998 | matconst idx shl cell sub 3 tlog t |
| 17999 | st_ld base idx t dst |
| 18000 | end |
| 18001 | |
| 18002 | note s_putf_go: field j of struct name e. Read the value (and the index, if an array field) and store. |
| 18003 | fn s_putf_go e ulong j ulong to void |
| 18004 | fl = ulong get sf_len j |
| 18005 | ft = ulong get sf_type j |
| 18006 | off = ulong get sf_off j |
| 18007 | base = ulong uchar get a_ar add get a_rb 4 sub e 1 |
| 18008 | if ne fl 0 |
| 18009 | rdval 0 5 255 0 |
| 18010 | if eq get rt 0 1 |
| 18011 | note d2site 449|s_putf_go: type mismatch; condition if eq get rt 0 1 |
| 18012 | put d2site 0 449 |
| 18013 | fail 7 |
| 18014 | end |
| 18015 | put svk 0 get rk 0 |
| 18016 | put svv 0 get rv 0 |
| 18017 | put svt 0 get rt 0 |
| 18018 | end |
| 18019 | rdval 0 ft 255 0 |
| 18020 | if ne get rt 0 ft |
| 18021 | note d2site 450|s_putf_go: type mismatch; condition if ne get rt 0 ft |
| 18022 | put d2site 0 450 |
| 18023 | fail 7 |
| 18024 | end |
| 18025 | v = matreg get rk 0 get rv 0 get rt 0 |
| 18026 | idx = alloc |
| 18027 | if eq fl 0 |
| 18028 | st_store base idx off ft v |
| 18029 | else |
| 18030 | s_putf_ix base idx v off fl ft |
| 18031 | end |
| 18032 | eol |
| 18033 | end |
| 18034 | |
| 18035 | note s_putf: put p f v, or put p f i v. A view struct is error 20. |
| 18036 | fn s_putf e ulong to void |
| 18037 | i = sub e 1 |
| 18038 | if eq ulong uchar get a_ar add get a_rb 7 i 8 |
| 18039 | note d2site 451|s_putf: write to a view or a text; condition if eq ulong uchar get a_ar add get a_rb 7 i 8 |
| 18040 | put d2site 0 451 |
| 18041 | fail 20 |
| 18042 | end |
| 18043 | tok |
| 18044 | if ne get tk 0 1 |
| 18045 | note d2site 452|s_putf: syntax: unknown or misplaced word; condition if ne get tk 0 1 |
| 18046 | put d2site 0 452 |
| 18047 | fail 16 |
| 18048 | end |
| 18049 | if gt get tl 0 63 |
| 18050 | note d2site 453|s_putf: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63 |
| 18051 | put d2site 0 453 |
| 18052 | fail 13 |
| 18053 | end |
| 18054 | si = sub ulong uchar get a_ar add get a_rb 5 i 16 |
| 18055 | fid = findfield si get tw 0 |
| 18056 | if eq fid 0 |
| 18057 | note d2site 454|s_putf: unknown name or field, or a word this mode does not provide; condition if eq fid 0 |
| 18058 | put d2site 0 454 |
| 18059 | fail 3 |
| 18060 | end |
| 18061 | s_putf_go e sub fid 1 |
| 18062 | end |
| 18063 | |
| 18064 | note s_putf_ix: the index was saved in svk/svv/svt before the value was read |
| 18065 | fn s_putf_ix base ulong idx ulong v ulong off ulong fl ulong ft ulong to void |
| 18066 | ik = get svk 0 |
| 18067 | iv = get svv 0 |
| 18068 | if eq get svt 0 1 |
| 18069 | note d2site 455|s_putf_ix: type mismatch; condition if eq get svt 0 1 |
| 18070 | put d2site 0 455 |
| 18071 | fail 7 |
| 18072 | end |
| 18073 | if eq ik 3 |
| 18074 | if ge iv fl |
| 18075 | note d2site 456|s_putf_ix: constant index outside the array; condition if ge iv fl |
| 18076 | put d2site 0 456 |
| 18077 | fail 21 |
| 18078 | end |
| 18079 | st_store base idx add off iv ft v |
| 18080 | else |
| 18081 | if ne ik 1 |
| 18082 | note d2site 457|s_putf_ix: type mismatch; condition if ne ik 1 |
| 18083 | put d2site 0 457 |
| 18084 | fail 7 |
| 18085 | end |
| 18086 | st_ixreg idx iv off fl ft |
| 18087 | put ea_b 0 base |
| 18088 | put ea_i 0 idx |
| 18089 | stel ft v |
| 18090 | end |
| 18091 | end |
| 18092 | |
| 18093 | note ca_st_ok: read one struct argument of parameter i of function f. Returns the name entry. |
| 18094 | fn ca_st_ok f ulong i ulong to ulong |
| 18095 | md = ulong 0 |
| 18096 | aa_word |
| 18097 | w = get tw 0 |
| 18098 | c = kw w |
| 18099 | if ne c 0 |
| 18100 | if or lt c 57 gt c 58 |
| 18101 | note d2site 458|ca_st_ok: syntax: unknown or misplaced word; condition if or lt c 57 gt c 58 |
| 18102 | put d2site 0 458 |
| 18103 | fail 16 |
| 18104 | end |
| 18105 | md = c |
| 18106 | aa_word |
| 18107 | w = get tw 0 |
| 18108 | end |
| 18109 | e = findname w |
| 18110 | if eq e 0 |
| 18111 | note d2site 459|ca_st_ok: unknown name or field, or a word this mode does not provide; condition if eq e 0 |
| 18112 | put d2site 0 459 |
| 18113 | fail 3 |
| 18114 | end |
| 18115 | ni = sub e 1 |
| 18116 | k = ulong uchar get a_ar add get a_rb 7 ni |
| 18117 | if eq k 10 |
| 18118 | note d2site 460|ca_st_ok: type mismatch; condition if eq k 10 |
| 18119 | put d2site 0 460 |
| 18120 | fail 7 |
| 18121 | end |
| 18122 | if lt k 6 |
| 18123 | note d2site 461|ca_st_ok: type mismatch; condition if lt k 6 |
| 18124 | put d2site 0 461 |
| 18125 | fail 7 |
| 18126 | end |
| 18127 | p = add mul sub f 1 6 i |
| 18128 | pk = ulong a_gu 37 p |
| 18129 | if eq pk 7 |
| 18130 | if eq md 57 |
| 18131 | note d2site 462|ca_st_ok: write to a view or a text; condition if eq md 57 |
| 18132 | put d2site 0 462 |
| 18133 | fail 20 |
| 18134 | end |
| 18135 | if eq k 8 |
| 18136 | note d2site 463|ca_st_ok: write to a view or a text; condition if eq k 8 |
| 18137 | put d2site 0 463 |
| 18138 | fail 20 |
| 18139 | end |
| 18140 | else |
| 18141 | if eq md 58 |
| 18142 | note d2site 464|ca_st_ok: type mismatch; condition if eq md 58 |
| 18143 | put d2site 0 464 |
| 18144 | fail 7 |
| 18145 | end |
| 18146 | end |
| 18147 | if ne ulong a_gu 5 ni ulong a_gu 35 p |
| 18148 | note d2site 465|ca_st_ok: type mismatch; condition if ne ulong a_gu 5 ni ulong a_gu 35 p |
| 18149 | put d2site 0 465 |
| 18150 | fail 7 |
| 18151 | end |
| 18152 | ret e |
| 18153 | end |
| 18154 | |
| 18155 | note ca_st: a struct argument. edit (fn_pk 7) needs own or edit; view takes any. Same struct. |
| 18156 | fn ca_st f ulong i ulong cb ulong to void |
| 18157 | e = ca_st_ok f i |
| 18158 | note ca_dist: the same struct name passed twice in one call is error 19. |
| 18159 | j = ulong 0 |
| 18160 | while lt j i |
| 18161 | if eq a_g 77 add add cb mul j 3 2 e |
| 18162 | note d2site 466|ca_st: global passed as an argument, or one array twice in a call; condition if eq a_g 77 add add cb mul j 3 2 e |
| 18163 | put d2site 0 466 |
| 18164 | fail 19 |
| 18165 | end |
| 18166 | j = add j 1 |
| 18167 | end |
| 18168 | q = add cb mul i 3 |
| 18169 | put a_ar add get a_rb 77 q 5 |
| 18170 | a_p 77 add q 1 ulong a_gu 4 sub e 1 |
| 18171 | put a_ar add get a_rb 77 add q 2 e |
| 18172 | end |
| 18173 | note ---- R6 IR. A leading line `ir` writes OSC IR version 1. The AArch64 path is not taken. |
| 18174 | note Worksheet ir_match.py matched omega_emit on the 10 dev programs; this is that algorithm. |
| 18175 | |
| 18176 | global ir_rty uchar 64 |
| 18177 | global ir_nreg ulong 1 |
| 18178 | global ir_nm ulong 32 |
| 18179 | global ir_nrr uchar 32 |
| 18180 | global ir_nn ulong 1 |
| 18181 | global ir_cty uchar 32 |
| 18182 | global ir_cm ulong 32 |
| 18183 | global ir_cr uchar 32 |
| 18184 | global ir_nc ulong 1 |
| 18185 | global ir_bord ulong 32 |
| 18186 | global ir_nord ulong 1 |
| 18187 | global ir_cur ulong 1 |
| 18188 | global ir_dead ulong 1 |
| 18189 | global ir_nb ulong 1 |
| 18190 | global ir_ok uchar 256 |
| 18191 | global ir_oa ulong 256 |
| 18192 | global ir_ob ulong 256 |
| 18193 | global ir_oc ulong 256 |
| 18194 | global ir_od ulong 256 |
| 18195 | global ir_obl ulong 256 |
| 18196 | global ir_no ulong 1 |
| 18197 | global ir_bf ulong 32 |
| 18198 | global ir_bc ulong 32 |
| 18199 | global ir_fk uchar 8 |
| 18200 | global ir_fa ulong 8 |
| 18201 | global ir_fb ulong 8 |
| 18202 | global ir_fc ulong 8 |
| 18203 | global ir_fd ulong 8 |
| 18204 | global ir_nf ulong 1 |
| 18205 | global ir_ret ulong 1 |
| 18206 | global ir_npar ulong 1 |
| 18207 | global ir_rr ulong 1 |
| 18208 | global ir_vt ulong 1 |
| 18209 | global ir_bare ulong 1 |
| 18210 | global ir_isb ulong 1 |
| 18211 | global ir_ns ulong 1 |
| 18212 | global ir_nl ulong 1 |
| 18213 | global ir_have ulong 1 |
| 18214 | global irrec uchar 2620252 |
| 18215 | global irrlen ulong 1 |
| 18216 | global irnf ulong 1 |
| 18217 | global irf_nm ulong 32 |
| 18218 | global irf_ns ulong 32 |
| 18219 | global irf_nl ulong 32 |
| 18220 | global irf_np ulong 32 |
| 18221 | global irf_ret uchar 32 |
| 18222 | global irf_pt uchar 192 |
| 18223 | global irf_n ulong 1 |
| 18224 | global ir_args ulong 6 |
| 18225 | global ir_oarg ulong 1536 |
| 18226 | global ir_miss ulong 1 |
| 18227 | global ir_cl ulong 1 |
| 18228 | global ir_cs ulong 1 |
| 18229 | note per open block frame, the local count when it opened (names bound inside go out of scope at else / end) |
| 18230 | global ir_fnn ulong 8 |
| 18231 | note ir_bbig: tbig of the bare number in ir_bare, for the range check once its type is known (error 8). |
| 18232 | global ir_bbig ulong 1 |
| 18233 | |
| 18234 | note ir_lead: 1 when the first line is "ir" (after blanks). Both scans run as nested 999999-pass loops, |
| 18235 | note so more than 1000000 leading blanks or first-line bytes are read, not trapped 4 (#671). |
| 18236 | fn ir_lead to ulong |
| 18237 | p = ulong 0 |
| 18238 | go = true |
| 18239 | while go |
| 18240 | m = ulong 0 |
| 18241 | while and go lt m 999999 |
| 18242 | if ge p get inlen 0 |
| 18243 | go = false |
| 18244 | else |
| 18245 | c = a_ib p |
| 18246 | if gt c 32 |
| 18247 | go = false |
| 18248 | else |
| 18249 | if eq c 10 |
| 18250 | ret 0 |
| 18251 | end |
| 18252 | p = add p 1 |
| 18253 | end |
| 18254 | end |
| 18255 | m = add m 1 |
| 18256 | end |
| 18257 | end |
| 18258 | if ge add p 3 get inlen 0 |
| 18259 | ret 0 |
| 18260 | end |
| 18261 | if ne uchar and shr get a_ar shr p 3 shl and p 7 3 255 105 |
| 18262 | ret 0 |
| 18263 | end |
| 18264 | if ne uchar and shr get a_ar shr add p 1 3 shl and add p 1 7 3 255 114 |
| 18265 | ret 0 |
| 18266 | end |
| 18267 | if gt uchar and shr get a_ar shr add p 2 3 shl and add p 2 7 3 255 32 |
| 18268 | ret 0 |
| 18269 | end |
| 18270 | q = add p 2 |
| 18271 | go = true |
| 18272 | while go |
| 18273 | m = ulong 0 |
| 18274 | while and go lt m 999999 |
| 18275 | if ge q get inlen 0 |
| 18276 | go = false |
| 18277 | else |
| 18278 | if eq a_ib q 10 |
| 18279 | go = false |
| 18280 | else |
| 18281 | q = add q 1 |
| 18282 | end |
| 18283 | end |
| 18284 | m = add m 1 |
| 18285 | end |
| 18286 | end |
| 18287 | if lt q get inlen 0 |
| 18288 | q = add q 1 |
| 18289 | end |
| 18290 | put cur 0 q |
| 18291 | put line 0 2 |
| 18292 | ret 1 |
| 18293 | end |
| 18294 | |
| 18295 | fn ir_w16 v ulong to void |
| 18296 | emitb uchar and v 255 |
| 18297 | emitb uchar and shr v 8 255 |
| 18298 | end |
| 18299 | |
| 18300 | fn ir_w32 v ulong to void |
| 18301 | ir_w16 v |
| 18302 | ir_w16 shr v 16 |
| 18303 | end |
| 18304 | |
| 18305 | fn ir_w64 v ulong to void |
| 18306 | ir_w32 v |
| 18307 | ir_w32 shr v 32 |
| 18308 | end |
| 18309 | |
| 18310 | fn ir_newreg ty ulong to ulong |
| 18311 | r = get ir_nreg 0 |
| 18312 | if ge r 64 |
| 18313 | note d2site 467|ir_newreg: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge r 64 |
| 18314 | put d2site 0 467 |
| 18315 | fail 14 |
| 18316 | end |
| 18317 | put ir_rty r uchar ty |
| 18318 | put ir_nreg 0 add r 1 |
| 18319 | ret r |
| 18320 | end |
| 18321 | |
| 18322 | fn ir_block to ulong |
| 18323 | b = get ir_nb 0 |
| 18324 | if ge b 32 |
| 18325 | note d2site 468|ir_block: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge b 32 |
| 18326 | put d2site 0 468 |
| 18327 | fail 14 |
| 18328 | end |
| 18329 | put ir_bord b 65535 |
| 18330 | put ir_nb 0 add b 1 |
| 18331 | ret b |
| 18332 | end |
| 18333 | |
| 18334 | fn ir_start b ulong to void |
| 18335 | put ir_bord b get ir_nord 0 |
| 18336 | put ir_nord 0 add get ir_nord 0 1 |
| 18337 | put ir_cur 0 b |
| 18338 | put ir_dead 0 0 |
| 18339 | end |
| 18340 | |
| 18341 | fn ir_op k ulong a ulong b ulong c ulong d ulong to void |
| 18342 | if ne get ir_dead 0 0 |
| 18343 | note d2site 469|ir_op: line after ret, break, continue, trap or exit in the same block; condition if ne get ir_dead 0 0 |
| 18344 | put d2site 0 469 |
| 18345 | fail 17 |
| 18346 | end |
| 18347 | n = get ir_no 0 |
| 18348 | if ge n 256 |
| 18349 | note d2site 470|ir_op: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge n 256 |
| 18350 | put d2site 0 470 |
| 18351 | fail 14 |
| 18352 | end |
| 18353 | put ir_ok n uchar k |
| 18354 | put ir_oa n a |
| 18355 | put ir_ob n b |
| 18356 | put ir_oc n c |
| 18357 | put ir_od n d |
| 18358 | put ir_obl n get ir_cur 0 |
| 18359 | put ir_no 0 add n 1 |
| 18360 | end |
| 18361 | |
| 18362 | fn ir_lit mag ulong ty ulong to ulong |
| 18363 | i = ulong 0 |
| 18364 | n = get ir_nc 0 |
| 18365 | while lt i n |
| 18366 | if and eq ulong get ir_cty i ty eq get ir_cm i mag |
| 18367 | ret ulong get ir_cr i |
| 18368 | end |
| 18369 | i = add i 1 |
| 18370 | end |
| 18371 | if ge n 32 |
| 18372 | note d2site 471|ir_lit: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge n 32 |
| 18373 | put d2site 0 471 |
| 18374 | fail 14 |
| 18375 | end |
| 18376 | r = ir_newreg ty |
| 18377 | put ir_cty n uchar ty |
| 18378 | put ir_cm n mag |
| 18379 | put ir_cr n uchar r |
| 18380 | put ir_nc 0 add n 1 |
| 18381 | ret r |
| 18382 | end |
| 18383 | |
| 18384 | note ir_find: the local in scope named w (packed) -> its index + 1, or 0. Locals are at most 8 bytes, so a |
| 18385 | note word of length l over 8 is never one (its packed first 8 bytes may equal a local's name). |
| 18386 | fn ir_find w ulong l ulong to ulong |
| 18387 | if gt l 8 |
| 18388 | ret 0 |
| 18389 | end |
| 18390 | i = ulong 0 |
| 18391 | while lt i get ir_nn 0 |
| 18392 | if eq get ir_nm i w |
| 18393 | ret add i 1 |
| 18394 | end |
| 18395 | i = add i 1 |
| 18396 | end |
| 18397 | ret 0 |
| 18398 | end |
| 18399 | |
| 18400 | fn ir_bind w ulong r ulong to void |
| 18401 | n = get ir_nn 0 |
| 18402 | if ge n 32 |
| 18403 | note d2site 472|ir_bind: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge n 32 |
| 18404 | put d2site 0 472 |
| 18405 | fail 14 |
| 18406 | end |
| 18407 | put ir_nm n w |
| 18408 | put ir_nrr n uchar r |
| 18409 | put ir_nn 0 add n 1 |
| 18410 | end |
| 18411 | |
| 18412 | note ir_kwt: the keyword number of the current word, or 0 for a word over 8 bytes (only 8 are packed). |
| 18413 | fn ir_kwt to ulong |
| 18414 | if gt get tl 0 8 |
| 18415 | ret 0 |
| 18416 | end |
| 18417 | ret kw get tw 0 |
| 18418 | end |
| 18419 | |
| 18420 | note ir_newname: a new local, parameter or function name must not be a keyword (16), a local in scope, a |
| 18421 | note constant, or a function of the unit so far, the current one included (10, as newname). Function |
| 18422 | note names compare in full (up to 63 bytes). |
| 18423 | fn ir_newname w ulong s ulong l ulong to void |
| 18424 | if le l 8 |
| 18425 | if ne kw w 0 |
| 18426 | note d2site 473|ir_newname: syntax: unknown or misplaced word; condition if ne kw w 0 |
| 18427 | put d2site 0 473 |
| 18428 | fail 16 |
| 18429 | end |
| 18430 | if ne findname w 0 |
| 18431 | note d2site 474|ir_newname: duplicate name; condition if ne findname w 0 |
| 18432 | put d2site 0 474 |
| 18433 | fail 10 |
| 18434 | end |
| 18435 | end |
| 18436 | if ne ir_find w l 0 |
| 18437 | note d2site 475|ir_newname: duplicate name; condition if ne ir_find w l 0 |
| 18438 | put d2site 0 475 |
| 18439 | fail 10 |
| 18440 | end |
| 18441 | put ir_cl 0 l |
| 18442 | put ir_cs 0 s |
| 18443 | j = ulong 0 |
| 18444 | while lt j get irf_n 0 |
| 18445 | if eq get irf_nm j w |
| 18446 | if ne ir_nameeq j 0 |
| 18447 | note d2site 476|ir_newname: duplicate name; condition if ne ir_nameeq j 0 |
| 18448 | put d2site 0 476 |
| 18449 | fail 10 |
| 18450 | end |
| 18451 | end |
| 18452 | j = add j 1 |
| 18453 | end |
| 18454 | end |
| 18455 | |
| 18456 | note ir_newloc: a new local, parameter or for counter: at most 8 bytes (13, as native), then ir_newname. |
| 18457 | fn ir_newloc w ulong s ulong l ulong to void |
| 18458 | if gt l 8 |
| 18459 | note d2site 477|ir_newloc: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt l 8 |
| 18460 | put d2site 0 477 |
| 18461 | fail 13 |
| 18462 | end |
| 18463 | ir_newname w s l |
| 18464 | end |
| 18465 | |
| 18466 | note ir_type: a type word IR v1 lowers: 1 .. 9, or void (76) when isret is 1. A float, a view / edit array or |
| 18467 | note void elsewhere is error 9 (as typeword in IR mode); no word is 4; another word 16. |
| 18468 | fn ir_type isret ulong to ulong |
| 18469 | tok |
| 18470 | if or eq get tk 0 0 eq get tk 0 3 |
| 18471 | note d2site 478|ir_type: the line ends where a word or value is needed; condition if or eq get tk 0 0 eq get tk 0 3 |
| 18472 | put d2site 0 478 |
| 18473 | fail 4 |
| 18474 | end |
| 18475 | if ne get tk 0 1 |
| 18476 | note d2site 479|ir_type: syntax: unknown or misplaced word; condition if ne get tk 0 1 |
| 18477 | put d2site 0 479 |
| 18478 | fail 16 |
| 18479 | end |
| 18480 | c = ir_kwt |
| 18481 | if and ge c 1 le c 9 |
| 18482 | ret c |
| 18483 | end |
| 18484 | if and eq c 76 eq isret 1 |
| 18485 | ret c |
| 18486 | end |
| 18487 | if or or eq c 76 eq c 88 eq c 89 |
| 18488 | note d2site 480|ir_type: word or declaration in a place that does not allow it; condition if or or eq c 76 eq c 88 eq c 89 |
| 18489 | put d2site 0 480 |
| 18490 | fail 9 |
| 18491 | end |
| 18492 | if or eq c 57 eq c 58 |
| 18493 | note d2site 481|ir_type: word or declaration in a place that does not allow it; condition if or eq c 57 eq c 58 |
| 18494 | put d2site 0 481 |
| 18495 | fail 9 |
| 18496 | end |
| 18497 | note d2site 482|ir_type: syntax: unknown or misplaced word |
| 18498 | put d2site 0 482 |
| 18499 | fail 16 |
| 18500 | ret 0 |
| 18501 | end |
| 18502 | |
| 18503 | fn ir_push k ulong a ulong b ulong c ulong d ulong to void |
| 18504 | n = get ir_nf 0 |
| 18505 | if ge n 8 |
| 18506 | note d2site 483|ir_push: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge n 8 |
| 18507 | put d2site 0 483 |
| 18508 | fail 14 |
| 18509 | end |
| 18510 | put ir_fk n uchar k |
| 18511 | put ir_fa n a |
| 18512 | put ir_fb n b |
| 18513 | put ir_fc n c |
| 18514 | put ir_fd n d |
| 18515 | put ir_fnn n get ir_nn 0 |
| 18516 | put ir_nf 0 add n 1 |
| 18517 | end |
| 18518 | |
| 18519 | fn ir_set dst ulong r ulong ty ulong to void |
| 18520 | put ir_isb 0 0 |
| 18521 | if eq dst 65534 |
| 18522 | put ir_rr 0 r |
| 18523 | put ir_vt 0 ty |
| 18524 | ret |
| 18525 | end |
| 18526 | d = dst |
| 18527 | if eq dst 65535 |
| 18528 | d = ir_newreg ty |
| 18529 | end |
| 18530 | ir_op 2 d r 0 0 |
| 18531 | put ir_rr 0 d |
| 18532 | put ir_vt 0 ty |
| 18533 | end |
| 18534 | |
| 18535 | fn ir_ord id ulong to ulong |
| 18536 | ret get ir_bord id |
| 18537 | end |
| 18538 | |
| 18539 | |
| 18540 | |
| 18541 | |
| 18542 | fn ir_wins k ulong to void |
| 18543 | if eq k 0 |
| 18544 | i = ulong 0 |
| 18545 | while lt i get ir_nc 0 |
| 18546 | emitb 1 |
| 18547 | ir_w16 ulong get ir_cr i |
| 18548 | ir_w64 get ir_cm i |
| 18549 | i = add i 1 |
| 18550 | end |
| 18551 | end |
| 18552 | i = ulong 0 |
| 18553 | while lt i get ir_no 0 |
| 18554 | if eq ir_ord get ir_obl i k |
| 18555 | op = ulong get ir_ok i |
| 18556 | emitb uchar op |
| 18557 | if eq op 1 |
| 18558 | ir_w16 get ir_oa i |
| 18559 | ir_w64 get ir_ob i |
| 18560 | end |
| 18561 | if eq op 2 |
| 18562 | ir_w16 get ir_oa i |
| 18563 | ir_w16 get ir_ob i |
| 18564 | end |
| 18565 | if eq op 3 |
| 18566 | emitb uchar get ir_oa i |
| 18567 | ir_w16 get ir_ob i |
| 18568 | ir_w16 get ir_oc i |
| 18569 | ir_w16 get ir_od i |
| 18570 | end |
| 18571 | if eq op 4 |
| 18572 | emitb uchar get ir_oa i |
| 18573 | ir_w16 get ir_ob i |
| 18574 | ir_w16 get ir_oc i |
| 18575 | end |
| 18576 | if eq op 5 |
| 18577 | emitb uchar get ir_oa i |
| 18578 | ir_w16 get ir_ob i |
| 18579 | ir_w16 get ir_oc i |
| 18580 | ir_w16 get ir_od i |
| 18581 | end |
| 18582 | if eq op 6 |
| 18583 | ir_w16 get ir_oa i |
| 18584 | ir_w16 get ir_ob i |
| 18585 | end |
| 18586 | if eq op 11 |
| 18587 | ir_w16 get ir_oa i |
| 18588 | ir_w16 get ir_ob i |
| 18589 | emitb uchar get ir_oc i |
| 18590 | j = ulong 0 |
| 18591 | while lt j get ir_oc i |
| 18592 | ir_w16 get ir_oarg add mul i 6 j |
| 18593 | j = add j 1 |
| 18594 | end |
| 18595 | end |
| 18596 | if eq op 12 |
| 18597 | emitb uchar get ir_oa i |
| 18598 | end |
| 18599 | if eq op 13 |
| 18600 | ir_w16 ir_ord get ir_oa i |
| 18601 | end |
| 18602 | if eq op 14 |
| 18603 | ir_w16 get ir_oa i |
| 18604 | ir_w16 ir_ord get ir_ob i |
| 18605 | ir_w16 ir_ord get ir_oc i |
| 18606 | end |
| 18607 | if eq op 15 |
| 18608 | ir_w16 get ir_oa i |
| 18609 | end |
| 18610 | end |
| 18611 | i = add i 1 |
| 18612 | end |
| 18613 | end |
| 18614 | |
| 18615 | fn ir_record to void |
| 18616 | emitb uchar get ir_nl 0 |
| 18617 | p = get ir_ns 0 |
| 18618 | e = add p get ir_nl 0 |
| 18619 | while lt p e |
| 18620 | emitb uchar and shr get a_ar shr p 3 shl and p 7 3 255 |
| 18621 | p = add p 1 |
| 18622 | end |
| 18623 | emitb uchar get ir_npar 0 |
| 18624 | if eq get ir_ret 0 76 |
| 18625 | emitb 0 |
| 18626 | else |
| 18627 | emitb uchar get ir_ret 0 |
| 18628 | end |
| 18629 | ir_w16 get ir_nreg 0 |
| 18630 | i = ulong 0 |
| 18631 | while lt i get ir_nreg 0 |
| 18632 | emitb get ir_rty i |
| 18633 | i = add i 1 |
| 18634 | end |
| 18635 | note Lay out blocks and count their instructions here, preserving constant records in block zero. |
| 18636 | k = ulong 0 |
| 18637 | at = ulong 0 |
| 18638 | while lt k get ir_nord 0 |
| 18639 | put ir_bf k at |
| 18640 | c = ulong 0 |
| 18641 | if eq k 0 |
| 18642 | c = get ir_nc 0 |
| 18643 | end |
| 18644 | i = ulong 0 |
| 18645 | while lt i get ir_no 0 |
| 18646 | if eq ir_ord get ir_obl i k |
| 18647 | c = add c 1 |
| 18648 | end |
| 18649 | i = add i 1 |
| 18650 | end |
| 18651 | put ir_bc k c |
| 18652 | at = add at c |
| 18653 | k = add k 1 |
| 18654 | end |
| 18655 | put ir_no 0 get ir_no 0 |
| 18656 | ir_w16 get ir_nord 0 |
| 18657 | k = ulong 0 |
| 18658 | while lt k get ir_nord 0 |
| 18659 | ir_w32 get ir_bf k |
| 18660 | ir_w32 get ir_bc k |
| 18661 | k = add k 1 |
| 18662 | end |
| 18663 | tot = ulong 0 |
| 18664 | k = ulong 0 |
| 18665 | while lt k get ir_nord 0 |
| 18666 | tot = add tot get ir_bc k |
| 18667 | k = add k 1 |
| 18668 | end |
| 18669 | ir_w32 tot |
| 18670 | k = ulong 0 |
| 18671 | while lt k get ir_nord 0 |
| 18672 | ir_wins k |
| 18673 | k = add k 1 |
| 18674 | end |
| 18675 | ir_w16 0 |
| 18676 | ir_w16 0 |
| 18677 | end |
| 18678 | |
| 18679 | note ir_emit_record: encode the current function into irrec and count it. The per-function IR state is |
| 18680 | note reset by ir_fn, so this must run before the next fn line. |
| 18681 | fn ir_emit_record to void |
| 18682 | if ge get irnf 0 32 |
| 18683 | note d2site 484|ir_emit_record: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge get irnf 0 32 |
| 18684 | put d2site 0 484 |
| 18685 | fail 14 |
| 18686 | end |
| 18687 | put oc 0 0 |
| 18688 | ir_record |
| 18689 | n = get oc 0 |
| 18690 | base = get irrlen 0 |
| 18691 | i = ulong 0 |
| 18692 | while lt i n |
| 18693 | put irrec add base i a_ob i |
| 18694 | i = add i 1 |
| 18695 | end |
| 18696 | put irrlen 0 add base n |
| 18697 | put irnf 0 add get irnf 0 1 |
| 18698 | end |
| 18699 | |
| 18700 | |
| 18701 | note ir_nameeq: table entry j's name equals the current source name token (length and bytes past 8). |
| 18702 | fn ir_nameeq j ulong to ulong |
| 18703 | fl = get irf_nl j |
| 18704 | if ne fl get ir_cl 0 |
| 18705 | ret 0 |
| 18706 | end |
| 18707 | k = ulong 8 |
| 18708 | same = ulong 1 |
| 18709 | while and eq same 1 lt k get ir_cl 0 |
| 18710 | left = a_ib add get irf_ns j k |
| 18711 | right = a_ib add get ir_cs 0 k |
| 18712 | if ne left right |
| 18713 | same = 0 |
| 18714 | end |
| 18715 | k = add k 1 |
| 18716 | end |
| 18717 | ret same |
| 18718 | end |
| 18719 | |
| 18720 | note ir_findfn: packed name -> earlier function index + 1, or 0. The current function is the newest |
| 18721 | note table entry and is never returned, so self and forward calls fail. |
| 18722 | fn ir_findfn w ulong to ulong |
| 18723 | if le get irf_n 0 1 |
| 18724 | ret 0 |
| 18725 | end |
| 18726 | fc = sub get irf_n 0 1 |
| 18727 | j = ulong 0 |
| 18728 | while lt j fc |
| 18729 | if eq get irf_nm j w |
| 18730 | if ne ir_nameeq j 0 |
| 18731 | ret add j 1 |
| 18732 | end |
| 18733 | end |
| 18734 | j = add j 1 |
| 18735 | end |
| 18736 | ret 0 |
| 18737 | end |
| 18738 | |
| 18739 | note ir_callop: CALL in the IR's five-field form; the argument registers live in ir_args[0..nargs). |
| 18740 | fn ir_callop dst ulong callee ulong nargs ulong to void |
| 18741 | if ne get ir_dead 0 0 |
| 18742 | note d2site 485|ir_callop: line after ret, break, continue, trap or exit in the same block; condition if ne get ir_dead 0 0 |
| 18743 | put d2site 0 485 |
| 18744 | fail 17 |
| 18745 | end |
| 18746 | n = get ir_no 0 |
| 18747 | if ge n 256 |
| 18748 | note d2site 486|ir_callop: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge n 256 |
| 18749 | put d2site 0 486 |
| 18750 | fail 14 |
| 18751 | end |
| 18752 | put ir_ok n 11 |
| 18753 | put ir_oa n dst |
| 18754 | put ir_ob n callee |
| 18755 | put ir_oc n nargs |
| 18756 | put ir_od n 0 |
| 18757 | put ir_obl n get ir_cur 0 |
| 18758 | j = ulong 0 |
| 18759 | while lt j nargs |
| 18760 | put ir_oarg add mul n 6 j get ir_args j |
| 18761 | j = add j 1 |
| 18762 | end |
| 18763 | put ir_no 0 add n 1 |
| 18764 | end |
| 18765 | |
| 18766 | fn ir_name to void |
| 18767 | e = ir_find get tw 0 get tl 0 |
| 18768 | if eq e 0 |
| 18769 | if le get tl 0 8 |
| 18770 | e = findname get tw 0 |
| 18771 | end |
| 18772 | if ne e 0 |
| 18773 | if eq uchar get a_ar add get a_rb 7 sub e 1 9 |
| 18774 | t = ulong uchar get a_ar add get a_rb 5 sub e 1 |
| 18775 | if ge t 10 |
| 18776 | note d2site 487|ir_name: word or declaration in a place that does not allow it; condition if ge t 10 |
| 18777 | put d2site 0 487 |
| 18778 | fail 9 |
| 18779 | end |
| 18780 | r = ir_lit get a_ar add get a_rb 8 sub e 1 t |
| 18781 | ir_set 65534 r t |
| 18782 | ret |
| 18783 | end |
| 18784 | end |
| 18785 | put ir_miss 0 1 |
| 18786 | ret |
| 18787 | end |
| 18788 | r = ulong get ir_nrr sub e 1 |
| 18789 | ir_set 65534 r ulong get ir_rty r |
| 18790 | end |
| 18791 | |
| 18792 | fn ir_un c ulong dst ulong to void |
| 18793 | ir_val 65534 0 |
| 18794 | if ne get ir_isb 0 0 |
| 18795 | note d2site 488|ir_un: bare number without a type from its context; condition if ne get ir_isb 0 0 |
| 18796 | put d2site 0 488 |
| 18797 | fail 11 |
| 18798 | end |
| 18799 | ty = get ir_vt 0 |
| 18800 | if and eq c 49 eq ty 1 |
| 18801 | note d2site 489|ir_un: type mismatch; condition if and eq c 49 eq ty 1 |
| 18802 | put d2site 0 489 |
| 18803 | fail 7 |
| 18804 | end |
| 18805 | d = dst |
| 18806 | if or eq dst 65534 eq dst 65535 |
| 18807 | d = ir_newreg ty |
| 18808 | end |
| 18809 | su = ulong 1 |
| 18810 | if eq c 50 |
| 18811 | su = ulong 3 |
| 18812 | if ne ty 1 |
| 18813 | su = ulong 2 |
| 18814 | end |
| 18815 | end |
| 18816 | ir_op 4 su d get ir_rr 0 0 |
| 18817 | put ir_rr 0 d |
| 18818 | put ir_vt 0 ty |
| 18819 | put ir_isb 0 0 |
| 18820 | end |
| 18821 | |
| 18822 | fn ir_bin_r left ulong lty ulong c ulong dst ulong to void |
| 18823 | exp2 = lty |
| 18824 | if or eq c 41 eq c 42 |
| 18825 | exp2 = ulong 0 |
| 18826 | end |
| 18827 | ir_val 65534 exp2 |
| 18828 | ir_bin_done left lty c dst |
| 18829 | end |
| 18830 | |
| 18831 | fn ir_bin_done left ulong lty ulong c ulong dst ulong to void |
| 18832 | isb2 = get ir_isb 0 |
| 18833 | ty2 = get ir_vt 0 |
| 18834 | if or eq c 41 eq c 42 |
| 18835 | if or ge lty 10 eq lty 1 |
| 18836 | note d2site 490|ir_bin_done: type mismatch; condition if or ge lty 10 eq lty 1 |
| 18837 | put d2site 0 490 |
| 18838 | fail 7 |
| 18839 | end |
| 18840 | if eq isb2 0 |
| 18841 | if or ge ty2 10 eq ty2 1 |
| 18842 | note d2site 491|ir_bin_done: type mismatch; condition if or ge ty2 10 eq ty2 1 |
| 18843 | put d2site 0 491 |
| 18844 | fail 7 |
| 18845 | end |
| 18846 | end |
| 18847 | else |
| 18848 | if ge lty 10 |
| 18849 | note d2site 492|ir_bin_done: type mismatch; condition if ge lty 10 |
| 18850 | put d2site 0 492 |
| 18851 | fail 7 |
| 18852 | end |
| 18853 | if and eq isb2 0 ne ty2 lty |
| 18854 | note d2site 493|ir_bin_done: type mismatch; condition if and eq isb2 0 ne ty2 lty |
| 18855 | put d2site 0 493 |
| 18856 | fail 7 |
| 18857 | end |
| 18858 | if and and ge c 33 le c 37 eq lty 1 |
| 18859 | note d2site 494|ir_bin_done: type mismatch; condition if and and ge c 33 le c 37 eq lty 1 |
| 18860 | put d2site 0 494 |
| 18861 | fail 7 |
| 18862 | end |
| 18863 | end |
| 18864 | right = get ir_rr 0 |
| 18865 | if ne isb2 0 |
| 18866 | range get ir_bare 0 lty get ir_bbig 0 |
| 18867 | right = ir_lit get ir_bare 0 lty |
| 18868 | end |
| 18869 | if ge c 43 |
| 18870 | d = dst |
| 18871 | if or eq dst 65534 eq dst 65535 |
| 18872 | d = ir_newreg 1 |
| 18873 | end |
| 18874 | ir_op 5 sub c 42 d left right |
| 18875 | put ir_rr 0 d |
| 18876 | put ir_vt 0 1 |
| 18877 | ret |
| 18878 | end |
| 18879 | d = dst |
| 18880 | if or eq dst 65534 eq dst 65535 |
| 18881 | d = ir_newreg lty |
| 18882 | end |
| 18883 | ir_op 3 sub c 32 d left right |
| 18884 | put ir_rr 0 d |
| 18885 | put ir_vt 0 lty |
| 18886 | put ir_isb 0 0 |
| 18887 | end |
| 18888 | |
| 18889 | fn ir_bin c ulong dst ulong to void |
| 18890 | ir_val 65534 0 |
| 18891 | if ne get ir_isb 0 0 |
| 18892 | mag = get ir_bare 0 |
| 18893 | bg = get ir_bbig 0 |
| 18894 | ir_val 65534 0 |
| 18895 | if ne get ir_isb 0 0 |
| 18896 | note d2site 495|ir_bin: bare number without a type from its context; condition if ne get ir_isb 0 0 |
| 18897 | put d2site 0 495 |
| 18898 | fail 11 |
| 18899 | end |
| 18900 | ty = get ir_vt 0 |
| 18901 | range mag ty bg |
| 18902 | left = ir_lit mag ty |
| 18903 | ir_bin_done left ty c dst |
| 18904 | ret |
| 18905 | end |
| 18906 | left = get ir_rr 0 |
| 18907 | lty = get ir_vt 0 |
| 18908 | ir_bin_r left lty c dst |
| 18909 | end |
| 18910 | |
| 18911 | note ir_cast: TYPE v. The operand keeps its own type (as native rdval reads it, exp 0); a bare number is |
| 18912 | note checked against TYPE (8). bool converts to and from numbers only by comparison (9, as vt_conv). |
| 18913 | note Only a constant of TYPE is the value itself; any other same-type value is a mov, as the C oracle. |
| 18914 | fn ir_cast c ulong dst ulong to void |
| 18915 | ir_val 65534 0 |
| 18916 | if ne get ir_isb 0 0 |
| 18917 | range get ir_bare 0 c get ir_bbig 0 |
| 18918 | r = ir_lit get ir_bare 0 c |
| 18919 | ir_set dst r c |
| 18920 | ret |
| 18921 | end |
| 18922 | src = get ir_rr 0 |
| 18923 | sty = get ir_vt 0 |
| 18924 | if xor eq sty 1 eq c 1 |
| 18925 | note d2site 496|ir_cast: word or declaration in a place that does not allow it; condition if xor eq sty 1 eq c 1 |
| 18926 | put d2site 0 496 |
| 18927 | fail 9 |
| 18928 | end |
| 18929 | k = ulong 0 |
| 18930 | if and eq sty c eq dst 65534 |
| 18931 | i = ulong 0 |
| 18932 | while lt i get ir_nc 0 |
| 18933 | if eq ulong get ir_cr i src |
| 18934 | k = ulong 1 |
| 18935 | end |
| 18936 | i = add i 1 |
| 18937 | end |
| 18938 | end |
| 18939 | if ne k 0 |
| 18940 | put ir_rr 0 src |
| 18941 | put ir_vt 0 c |
| 18942 | put ir_isb 0 0 |
| 18943 | ret |
| 18944 | end |
| 18945 | d = dst |
| 18946 | if or eq dst 65534 eq dst 65535 |
| 18947 | d = ir_newreg c |
| 18948 | end |
| 18949 | if eq sty c |
| 18950 | ir_op 2 d src 0 0 |
| 18951 | else |
| 18952 | ir_op 6 d src 0 0 |
| 18953 | end |
| 18954 | put ir_rr 0 d |
| 18955 | put ir_vt 0 c |
| 18956 | put ir_isb 0 0 |
| 18957 | end |
| 18958 | |
| 18959 | note ir_val: one IR-mode value (ir_valb), counted in irdep. IR mode reads values by recursion as rdval does, |
| 18960 | note so it has the same stack-derived bound (rdval's notes): deeper than 32768 is error 14 on its line, |
| 18961 | note never a trap 6 in omc. Measured 2026-11-11: omc f4fa7951 trapped 6 at 140000 nested IR calls. |
| 18962 | global irdep ulong 1 |
| 18963 | fn ir_val dst ulong exp ulong to void |
| 18964 | put irdep 0 add get irdep 0 1 |
| 18965 | if gt get irdep 0 32768 |
| 18966 | note d2site 497|ir_val: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if gt get irdep 0 32768 |
| 18967 | put d2site 0 497 |
| 18968 | fail 14 |
| 18969 | end |
| 18970 | ir_valb dst exp |
| 18971 | put irdep 0 sub get irdep 0 1 |
| 18972 | end |
| 18973 | |
| 18974 | fn ir_valb dst ulong exp ulong to void |
| 18975 | put ir_isb 0 0 |
| 18976 | put ir_miss 0 0 |
| 18977 | tok |
| 18978 | if or eq get tk 0 0 eq get tk 0 3 |
| 18979 | note d2site 498|ir_valb: the line ends where a word or value is needed; condition if or eq get tk 0 0 eq get tk 0 3 |
| 18980 | put d2site 0 498 |
| 18981 | fail 4 |
| 18982 | end |
| 18983 | if or eq get tk 0 4 eq get tk 0 5 |
| 18984 | note d2site 499|ir_valb: word or declaration in a place that does not allow it; condition if or eq get tk 0 4 eq get tk 0 5 |
| 18985 | put d2site 0 499 |
| 18986 | fail 9 |
| 18987 | end |
| 18988 | if eq get tk 0 2 |
| 18989 | if eq exp 0 |
| 18990 | put ir_bare 0 get tw 0 |
| 18991 | put ir_bbig 0 get tbig 0 |
| 18992 | put ir_isb 0 1 |
| 18993 | ret |
| 18994 | end |
| 18995 | range get tw 0 exp get tbig 0 |
| 18996 | r = ir_lit get tw 0 exp |
| 18997 | ir_set dst r exp |
| 18998 | ret |
| 18999 | end |
| 19000 | c = ir_kwt |
| 19001 | if and ge c 1 le c 9 |
| 19002 | ir_cast c dst |
| 19003 | ret |
| 19004 | end |
| 19005 | if and ge c 33 le c 48 |
| 19006 | ir_bin c dst |
| 19007 | if and ne exp 0 ne get ir_vt 0 exp |
| 19008 | note d2site 500|ir_valb: type mismatch; condition if and ne exp 0 ne get ir_vt 0 exp |
| 19009 | put d2site 0 500 |
| 19010 | fail 7 |
| 19011 | end |
| 19012 | ret |
| 19013 | end |
| 19014 | if or eq c 49 eq c 50 |
| 19015 | ir_un c dst |
| 19016 | if and ne exp 0 ne get ir_vt 0 exp |
| 19017 | note d2site 501|ir_valb: type mismatch; condition if and ne exp 0 ne get ir_vt 0 exp |
| 19018 | put d2site 0 501 |
| 19019 | fail 7 |
| 19020 | end |
| 19021 | ret |
| 19022 | end |
| 19023 | if eq c 55 |
| 19024 | if and ne exp 0 ne exp 1 |
| 19025 | note d2site 502|ir_valb: type mismatch; condition if and ne exp 0 ne exp 1 |
| 19026 | put d2site 0 502 |
| 19027 | fail 7 |
| 19028 | end |
| 19029 | r = ir_lit 1 1 |
| 19030 | ir_set dst r 1 |
| 19031 | ret |
| 19032 | end |
| 19033 | if eq c 56 |
| 19034 | if and ne exp 0 ne exp 1 |
| 19035 | note d2site 503|ir_valb: type mismatch; condition if and ne exp 0 ne exp 1 |
| 19036 | put d2site 0 503 |
| 19037 | fail 7 |
| 19038 | end |
| 19039 | r = ir_lit 0 1 |
| 19040 | ir_set dst r 1 |
| 19041 | ret |
| 19042 | end |
| 19043 | ir_name |
| 19044 | if ne get ir_miss 0 0 |
| 19045 | put ir_cl 0 get tl 0 |
| 19046 | put ir_cs 0 get ts 0 |
| 19047 | f = ir_findfn get tw 0 |
| 19048 | if eq f 0 |
| 19049 | note d2site 504|ir_valb: unknown name or field, or a word this mode does not provide; condition if eq f 0 |
| 19050 | put d2site 0 504 |
| 19051 | fail 3 |
| 19052 | end |
| 19053 | j = sub f 1 |
| 19054 | rtv = ulong get irf_ret j |
| 19055 | if eq rtv 76 |
| 19056 | note d2site 505|ir_valb: type mismatch; condition if eq rtv 76 |
| 19057 | put d2site 0 505 |
| 19058 | fail 7 |
| 19059 | end |
| 19060 | np = get irf_np j |
| 19061 | i = ulong 0 |
| 19062 | while lt i np |
| 19063 | ty = ulong get irf_pt add mul j 6 i |
| 19064 | ir_val 65534 ty |
| 19065 | if ne get ir_vt 0 ty |
| 19066 | note d2site 506|ir_valb: type mismatch; condition if ne get ir_vt 0 ty |
| 19067 | put d2site 0 506 |
| 19068 | fail 7 |
| 19069 | end |
| 19070 | put ir_args i get ir_rr 0 |
| 19071 | i = add i 1 |
| 19072 | end |
| 19073 | r = dst |
| 19074 | if or eq dst 65534 eq dst 65535 |
| 19075 | r = ir_newreg rtv |
| 19076 | end |
| 19077 | ir_callop r j np |
| 19078 | put ir_rr 0 r |
| 19079 | put ir_vt 0 rtv |
| 19080 | ret |
| 19081 | end |
| 19082 | if ne dst 65534 |
| 19083 | ir_set dst get ir_rr 0 get ir_vt 0 |
| 19084 | end |
| 19085 | end |
| 19086 | |
| 19087 | fn ir_end to void |
| 19088 | n = sub get ir_nf 0 1 |
| 19089 | put ir_nf 0 n |
| 19090 | k = ulong get ir_fk n |
| 19091 | put ir_nn 0 get ir_fnn n |
| 19092 | if eq k 1 |
| 19093 | if eq get ir_fc n 0 |
| 19094 | if eq get ir_dead 0 0 |
| 19095 | ir_op 13 get ir_fb n 0 0 0 |
| 19096 | put ir_dead 0 1 |
| 19097 | end |
| 19098 | ir_start get ir_fb n |
| 19099 | else |
| 19100 | if eq get ir_dead 0 0 |
| 19101 | if eq get ir_fd n 65535 |
| 19102 | j = ir_block |
| 19103 | put ir_fd n j |
| 19104 | end |
| 19105 | ir_op 13 get ir_fd n 0 0 0 |
| 19106 | put ir_dead 0 1 |
| 19107 | end |
| 19108 | if ne get ir_fd n 65535 |
| 19109 | ir_start get ir_fd n |
| 19110 | end |
| 19111 | end |
| 19112 | end |
| 19113 | if eq k 2 |
| 19114 | if eq get ir_dead 0 0 |
| 19115 | ir_op 13 get ir_fa n 0 0 0 |
| 19116 | put ir_dead 0 1 |
| 19117 | end |
| 19118 | ir_start get ir_fb n |
| 19119 | end |
| 19120 | if eq k 3 |
| 19121 | if eq get ir_dead 0 0 |
| 19122 | one = ir_lit 1 ulong get ir_rty get ir_fc n |
| 19123 | ir_op 3 1 get ir_fc n get ir_fc n one |
| 19124 | ir_op 13 get ir_fa n 0 0 0 |
| 19125 | put ir_dead 0 1 |
| 19126 | end |
| 19127 | ir_start get ir_fb n |
| 19128 | end |
| 19129 | if eq k 4 |
| 19130 | if eq get ir_dead 0 0 |
| 19131 | if ne get ir_ret 0 76 |
| 19132 | note d2site 507|ir_end: a function with a result can reach its end; condition if ne get ir_ret 0 76 |
| 19133 | put d2site 0 507 |
| 19134 | fail 18 |
| 19135 | end |
| 19136 | ir_op 15 65535 0 0 0 |
| 19137 | put ir_dead 0 1 |
| 19138 | end |
| 19139 | put ir_have 0 1 |
| 19140 | end |
| 19141 | eol |
| 19142 | end |
| 19143 | |
| 19144 | note ir_bound: the rest of a while or for line: `bound N` (1 .. 1000000, error 8: the C oracle's range, |
| 19145 | note omegese.c, and the guard range checker2 proves) -> N, or 0 when the line ends there. |
| 19146 | fn ir_bound to ulong |
| 19147 | tok |
| 19148 | if or eq get tk 0 0 eq get tk 0 3 |
| 19149 | ret 0 |
| 19150 | end |
| 19151 | if or ne get tk 0 1 ne ir_kwt 70 |
| 19152 | note d2site 508|ir_bound: extra words after a complete statement; condition if or ne get tk 0 1 ne ir_kwt 70 |
| 19153 | put d2site 0 508 |
| 19154 | fail 5 |
| 19155 | end |
| 19156 | bnd = lenval 4 |
| 19157 | if ge sub bnd 1 1000000 |
| 19158 | note d2site 509|ir_bound: number out of range for its type or place; condition if ge sub bnd 1 1000000 |
| 19159 | put d2site 0 509 |
| 19160 | fail 8 |
| 19161 | end |
| 19162 | eol |
| 19163 | ret bnd |
| 19164 | end |
| 19165 | |
| 19166 | fn ir_while to void |
| 19167 | z = ir_lit 0 5 |
| 19168 | one = ir_lit 1 5 |
| 19169 | cnt = ir_newreg 5 |
| 19170 | ir_op 2 cnt z 0 0 |
| 19171 | h = ir_block |
| 19172 | g = ir_block |
| 19173 | tb = ir_block |
| 19174 | body = ir_block |
| 19175 | ex = ir_block |
| 19176 | ir_op 13 h 0 0 0 |
| 19177 | put ir_dead 0 1 |
| 19178 | ir_start h |
| 19179 | ir_val 65534 1 |
| 19180 | if ne get ir_vt 0 1 |
| 19181 | note d2site 510|ir_while: type mismatch; condition if ne get ir_vt 0 1 |
| 19182 | put d2site 0 510 |
| 19183 | fail 7 |
| 19184 | end |
| 19185 | lim = ir_bound |
| 19186 | if eq lim 0 |
| 19187 | lim = ulong 1000000 |
| 19188 | end |
| 19189 | lim = ir_lit lim 5 |
| 19190 | ir_op 14 get ir_rr 0 g ex 0 |
| 19191 | ir_start g |
| 19192 | ger = ir_newreg 1 |
| 19193 | ir_op 5 6 ger cnt lim |
| 19194 | ir_op 14 ger tb body 0 |
| 19195 | ir_start tb |
| 19196 | ir_op 12 4 0 0 0 |
| 19197 | ir_op 13 ex 0 0 0 |
| 19198 | put ir_dead 0 1 |
| 19199 | ir_start body |
| 19200 | ir_op 3 1 cnt cnt one |
| 19201 | ir_push 2 h ex cnt 0 |
| 19202 | end |
| 19203 | |
| 19204 | note ir_for: for name type count [bound N]. The counter is bound after the count is read, so the count cannot |
| 19205 | note name it. nc: 1 when the count is a number or an integer constant name (not a local), seen ahead without |
| 19206 | note reading it. Such a count must be 0..1000000 (error 8 otherwise, a minus sign included): the C oracle's |
| 19207 | note count range (omegese.c for_line), so a plain loop never counts past what checker2 proves. Such a count |
| 19208 | note with no bound opens the plain loop (ir_forg with N = 0); any other count, and any count with a bound, |
| 19209 | note opens the guarded loop with N, default 1000000. The counter leaves scope at its end. |
| 19210 | fn ir_for to void |
| 19211 | tok |
| 19212 | if or eq get tk 0 0 eq get tk 0 3 |
| 19213 | note d2site 511|ir_for: the line ends where a word or value is needed; condition if or eq get tk 0 0 eq get tk 0 3 |
| 19214 | put d2site 0 511 |
| 19215 | fail 4 |
| 19216 | end |
| 19217 | if ne get tk 0 1 |
| 19218 | note d2site 512|ir_for: syntax: unknown or misplaced word; condition if ne get tk 0 1 |
| 19219 | put d2site 0 512 |
| 19220 | fail 16 |
| 19221 | end |
| 19222 | w = get tw 0 |
| 19223 | ir_newloc w get ts 0 get tl 0 |
| 19224 | ty = ir_type 0 |
| 19225 | if eq ty 1 |
| 19226 | note d2site 513|ir_for: type mismatch; condition if eq ty 1 |
| 19227 | put d2site 0 513 |
| 19228 | fail 7 |
| 19229 | end |
| 19230 | c0 = get cur 0 |
| 19231 | l0 = get line 0 |
| 19232 | a0 = get tka 0 |
| 19233 | b0 = get tkb 0 |
| 19234 | tok |
| 19235 | nc = ulong 0 |
| 19236 | if eq get tk 0 2 |
| 19237 | nc = ulong 1 |
| 19238 | if eq a_ib get ts 0 45 |
| 19239 | note d2site 514|ir_for: number out of range for its type or place; condition if eq a_ib get ts 0 45 |
| 19240 | put d2site 0 514 |
| 19241 | fail 8 |
| 19242 | end |
| 19243 | if gt get tw 0 1000000 |
| 19244 | note d2site 515|ir_for: number out of range for its type or place; condition if gt get tw 0 1000000 |
| 19245 | put d2site 0 515 |
| 19246 | fail 8 |
| 19247 | end |
| 19248 | end |
| 19249 | if and eq get tk 0 1 le get tl 0 8 |
| 19250 | if eq ir_find get tw 0 get tl 0 0 |
| 19251 | e = findname get tw 0 |
| 19252 | if ne e 0 |
| 19253 | if eq a_gu 7 sub e 1 9 |
| 19254 | nc = ulong 1 |
| 19255 | if lt a_gu 5 sub e 1 10 |
| 19256 | if gt a_g 8 sub e 1 1000000 |
| 19257 | note d2site 516|ir_for: number out of range for its type or place; condition if gt a_g 8 sub e 1 1000000 |
| 19258 | put d2site 0 516 |
| 19259 | fail 8 |
| 19260 | end |
| 19261 | end |
| 19262 | end |
| 19263 | end |
| 19264 | end |
| 19265 | end |
| 19266 | put cur 0 c0 |
| 19267 | put line 0 l0 |
| 19268 | put tka 0 a0 |
| 19269 | put tkb 0 b0 |
| 19270 | if eq nc 1 |
| 19271 | z = ir_lit 0 ty |
| 19272 | end |
| 19273 | ir_val 65534 ty |
| 19274 | if ne get ir_vt 0 ty |
| 19275 | note d2site 517|ir_for: type mismatch; condition if ne get ir_vt 0 ty |
| 19276 | put d2site 0 517 |
| 19277 | fail 7 |
| 19278 | end |
| 19279 | kr = get ir_rr 0 |
| 19280 | bn = ir_bound |
| 19281 | if and eq bn 0 eq nc 0 |
| 19282 | bn = ulong 1000000 |
| 19283 | end |
| 19284 | ir_forg w ty kr bn |
| 19285 | end |
| 19286 | |
| 19287 | note ir_forg: the for loop over counter ctr = 0 below kr. N = 0: the plain loop, head: lt ctr kr -> body | exit. |
| 19288 | note Else the guarded loop, the C oracle's shape (omegese.c guarded_loop): a ulong counter cnt = 0 as well; head: |
| 19289 | note lt ctr kr -> guard | exit; guard: ge cnt N -> trap 4 | body; body starts with cnt = add cnt 1. Literals and |
| 19290 | note blocks are made in the oracle's order (literals are shared). The latch adds 1 to ctr (ir_end kind 3). The |
| 19291 | note for frame (kind 3: head h, exit ex, counter ctr): the counter, bound last, leaves scope at the end. |
| 19292 | note The literals 0 and 1 are made first (shared; ir_lit returns the same register again), then the counters. |
| 19293 | note om4 holds 16 registers per function, so the guard blocks reuse names already dead: ty is the guard block |
| 19294 | note and w the trap block (both after ir_bind); cnt is 0 only in the plain loop (two literals precede it). |
| 19295 | fn ir_forg w ulong ty ulong kr ulong bn ulong to void |
| 19296 | cnt = ulong 0 |
| 19297 | if ne bn 0 |
| 19298 | cnt = ir_lit 0 5 |
| 19299 | cnt = ir_lit 1 5 |
| 19300 | cnt = ir_newreg 5 |
| 19301 | end |
| 19302 | ctr = ir_lit 0 ty |
| 19303 | ctr = ir_lit 1 ty |
| 19304 | ctr = ir_newreg ty |
| 19305 | ir_op 2 ctr ir_lit 0 ty 0 0 |
| 19306 | ir_bind w ctr |
| 19307 | h = ir_block |
| 19308 | if ne bn 0 |
| 19309 | ir_op 2 cnt ir_lit 0 5 0 0 |
| 19310 | ty = ir_block |
| 19311 | w = ir_block |
| 19312 | end |
| 19313 | body = ir_block |
| 19314 | ex = ir_block |
| 19315 | ir_op 13 h 0 0 0 |
| 19316 | put ir_dead 0 1 |
| 19317 | ir_start h |
| 19318 | c = ir_newreg 1 |
| 19319 | ir_op 5 3 c ctr kr |
| 19320 | if eq bn 0 |
| 19321 | ir_op 14 c body ex 0 |
| 19322 | else |
| 19323 | bn = ir_lit bn 5 |
| 19324 | ir_op 14 c ty ex 0 |
| 19325 | ir_start ty |
| 19326 | c = ir_newreg 1 |
| 19327 | ir_op 5 6 c cnt bn |
| 19328 | ir_op 14 c w body 0 |
| 19329 | ir_start w |
| 19330 | ir_op 12 4 0 0 0 |
| 19331 | ir_op 13 ex 0 0 0 |
| 19332 | put ir_dead 0 1 |
| 19333 | end |
| 19334 | ir_start body |
| 19335 | if ne cnt 0 |
| 19336 | ir_op 3 1 cnt cnt ir_lit 1 5 |
| 19337 | end |
| 19338 | ir_push 3 h ex ctr 0 |
| 19339 | kr = sub get ir_nf 0 1 |
| 19340 | put ir_fnn kr sub get ir_nn 0 1 |
| 19341 | end |
| 19342 | |
| 19343 | note ir_stmtcall: a void call as a statement; f is the table index + 1. |
| 19344 | fn ir_stmtcall f ulong to void |
| 19345 | j = sub f 1 |
| 19346 | if ne get irf_ret j 76 |
| 19347 | note d2site 518|ir_stmtcall: type mismatch; condition if ne get irf_ret j 76 |
| 19348 | put d2site 0 518 |
| 19349 | fail 7 |
| 19350 | end |
| 19351 | np = get irf_np j |
| 19352 | i = ulong 0 |
| 19353 | while lt i np |
| 19354 | ty = ulong get irf_pt add mul j 6 i |
| 19355 | ir_val 65534 ty |
| 19356 | if ne get ir_vt 0 ty |
| 19357 | note d2site 519|ir_stmtcall: type mismatch; condition if ne get ir_vt 0 ty |
| 19358 | put d2site 0 519 |
| 19359 | fail 7 |
| 19360 | end |
| 19361 | put ir_args i get ir_rr 0 |
| 19362 | i = add i 1 |
| 19363 | end |
| 19364 | ir_callop 65535 j np |
| 19365 | eol |
| 19366 | end |
| 19367 | |
| 19368 | note ir_assign: name [=] value for a local in scope, a void call, or a new typed local (a new name that is |
| 19369 | note a keyword, constant, local or function is refused; a bare number has no type, error 11). |
| 19370 | fn ir_assign w ulong to void |
| 19371 | p = get ts 0 |
| 19372 | l = get tl 0 |
| 19373 | c0 = get cur 0 |
| 19374 | tok |
| 19375 | eqs = false |
| 19376 | if and eq get tk 0 1 eq ir_kwt 73 |
| 19377 | eqs = true |
| 19378 | else |
| 19379 | put cur 0 c0 |
| 19380 | if eq get tk 0 0 |
| 19381 | put line 0 sub get line 0 1 |
| 19382 | end |
| 19383 | end |
| 19384 | e = ir_find w l |
| 19385 | if ne e 0 |
| 19386 | r = ulong get ir_nrr sub e 1 |
| 19387 | ir_val r ulong get ir_rty r |
| 19388 | if ne get ir_vt 0 ulong get ir_rty r |
| 19389 | note d2site 520|ir_assign: type mismatch; condition if ne get ir_vt 0 ulong get ir_rty r |
| 19390 | put d2site 0 520 |
| 19391 | fail 7 |
| 19392 | end |
| 19393 | eol |
| 19394 | ret |
| 19395 | end |
| 19396 | put ir_cl 0 l |
| 19397 | put ir_cs 0 p |
| 19398 | f = ir_findfn w |
| 19399 | if ne f 0 |
| 19400 | if eqs |
| 19401 | note d2site 521|ir_assign: type mismatch; condition if eqs |
| 19402 | put d2site 0 521 |
| 19403 | fail 7 |
| 19404 | end |
| 19405 | ir_stmtcall f |
| 19406 | ret |
| 19407 | end |
| 19408 | if le l 8 |
| 19409 | if ne findname w 0 |
| 19410 | note d2site 522|ir_assign: type mismatch; condition if ne findname w 0 |
| 19411 | put d2site 0 522 |
| 19412 | fail 7 |
| 19413 | end |
| 19414 | end |
| 19415 | ir_newloc w p l |
| 19416 | ir_val 65535 0 |
| 19417 | if ne get ir_isb 0 0 |
| 19418 | note d2site 523|ir_assign: bare number without a type from its context; condition if ne get ir_isb 0 0 |
| 19419 | put d2site 0 523 |
| 19420 | fail 11 |
| 19421 | end |
| 19422 | eol |
| 19423 | ir_bind w get ir_rr 0 |
| 19424 | end |
| 19425 | |
| 19426 | note ir_loopexit: innermost loop block's exit + 1, or 0 outside a loop. |
| 19427 | fn ir_loopexit to ulong |
| 19428 | i = get ir_nf 0 |
| 19429 | while gt i 0 |
| 19430 | i = sub i 1 |
| 19431 | k = ulong get ir_fk i |
| 19432 | if or eq k 2 eq k 3 |
| 19433 | ret add get ir_fb i 1 |
| 19434 | end |
| 19435 | end |
| 19436 | ret 0 |
| 19437 | end |
| 19438 | |
| 19439 | note ir_stmt: one line. The end of the input inside a function is error 15; a line starting with a number |
| 19440 | note is 16; a note is skipped even after the path ended; a statement IR v1 does not lower is 9. |
| 19441 | fn ir_stmt to ulong |
| 19442 | tok |
| 19443 | if eq get tk 0 0 |
| 19444 | ret 0 |
| 19445 | end |
| 19446 | if eq get tk 0 3 |
| 19447 | note d2site 524|ir_stmt: missing end; condition if eq get tk 0 3 |
| 19448 | put d2site 0 524 |
| 19449 | fail 15 |
| 19450 | end |
| 19451 | if ne get tk 0 1 |
| 19452 | note d2site 525|ir_stmt: syntax: unknown or misplaced word; condition if ne get tk 0 1 |
| 19453 | put d2site 0 525 |
| 19454 | fail 16 |
| 19455 | end |
| 19456 | c = ir_kwt |
| 19457 | if eq c 83 |
| 19458 | skipnl |
| 19459 | ret 0 |
| 19460 | end |
| 19461 | if and ne c 66 ne c 68 |
| 19462 | if ne get ir_dead 0 0 |
| 19463 | note d2site 526|ir_stmt: line after ret, break, continue, trap or exit in the same block; condition if ne get ir_dead 0 0 |
| 19464 | put d2site 0 526 |
| 19465 | fail 17 |
| 19466 | end |
| 19467 | end |
| 19468 | if eq c 77 |
| 19469 | note d2site 527|ir_stmt: word or declaration in a place that does not allow it; condition if eq c 77 |
| 19470 | put d2site 0 527 |
| 19471 | fail 9 |
| 19472 | end |
| 19473 | if eq c 87 |
| 19474 | note ir_trap: OMEGESE section 4. A trap ends the path but the IR still |
| 19475 | note needs an unreachable ret terminator (zero of the return type, or void). |
| 19476 | note trap is packed little endian 1885434484; independently checked in Wolfram. |
| 19477 | code = lenval 4 |
| 19478 | if or lt code 1 gt code 14 |
| 19479 | note d2site 528|ir_stmt: number out of range for its type or place; condition if or lt code 1 gt code 14 |
| 19480 | put d2site 0 528 |
| 19481 | fail 8 |
| 19482 | end |
| 19483 | tok |
| 19484 | if not or eq get tk 0 0 eq get tk 0 3 |
| 19485 | note d2site 529|ir_stmt: the line ends where a word or value is needed; condition if not or eq get tk 0 0 eq get tk 0 3 |
| 19486 | put d2site 0 529 |
| 19487 | fail 4 |
| 19488 | end |
| 19489 | ir_op 12 code 0 0 0 |
| 19490 | z = ulong 65535 |
| 19491 | if ne get ir_ret 0 76 |
| 19492 | z = ir_lit 0 get ir_ret 0 |
| 19493 | end |
| 19494 | ir_op 15 z 0 0 0 |
| 19495 | put ir_dead 0 1 |
| 19496 | ret 0 |
| 19497 | end |
| 19498 | if eq c 86 |
| 19499 | note ir_break: BR to the innermost loop's exit, then the path is dead. The if/loop closes skip the |
| 19500 | note unreachable join exactly as they do after ret or trap. |
| 19501 | ex = ir_loopexit |
| 19502 | if eq ex 0 |
| 19503 | note d2site 530|ir_stmt: word or declaration in a place that does not allow it; condition if eq ex 0 |
| 19504 | put d2site 0 530 |
| 19505 | fail 9 |
| 19506 | end |
| 19507 | ir_op 13 sub ex 1 0 0 0 |
| 19508 | put ir_dead 0 1 |
| 19509 | eol |
| 19510 | ret 0 |
| 19511 | end |
| 19512 | if eq c 66 |
| 19513 | ir_end |
| 19514 | ret 0 |
| 19515 | end |
| 19516 | if eq c 68 |
| 19517 | n = sub get ir_nf 0 1 |
| 19518 | if or ne get ir_fk n 1 ne get ir_fc n 0 |
| 19519 | note d2site 531|ir_stmt: missing end; condition if or ne get ir_fk n 1 ne get ir_fc n 0 |
| 19520 | put d2site 0 531 |
| 19521 | fail 15 |
| 19522 | end |
| 19523 | eol |
| 19524 | put ir_nn 0 get ir_fnn n |
| 19525 | if eq get ir_dead 0 0 |
| 19526 | j = ir_block |
| 19527 | ir_op 13 j 0 0 0 |
| 19528 | put ir_dead 0 1 |
| 19529 | put ir_fd n j |
| 19530 | else |
| 19531 | put ir_fd n 65535 |
| 19532 | end |
| 19533 | put ir_fc n 1 |
| 19534 | ir_start get ir_fb n |
| 19535 | ret 0 |
| 19536 | end |
| 19537 | if eq c 67 |
| 19538 | ir_val 65534 1 |
| 19539 | if ne get ir_vt 0 1 |
| 19540 | note d2site 532|ir_stmt: type mismatch; condition if ne get ir_vt 0 1 |
| 19541 | put d2site 0 532 |
| 19542 | fail 7 |
| 19543 | end |
| 19544 | eol |
| 19545 | th = ir_block |
| 19546 | el = ir_block |
| 19547 | ir_op 14 get ir_rr 0 th el 0 |
| 19548 | ir_push 1 th el 0 65535 |
| 19549 | ir_start th |
| 19550 | ret 0 |
| 19551 | end |
| 19552 | if eq c 69 |
| 19553 | ir_while |
| 19554 | ret 0 |
| 19555 | end |
| 19556 | if eq c 71 |
| 19557 | ir_for |
| 19558 | ret 0 |
| 19559 | end |
| 19560 | if eq c 72 |
| 19561 | note ir_doret: ret alone in a void function, ret value otherwise (4 when the value is missing, 5 for a |
| 19562 | note value or any other word after it); the value is read from just after ret. |
| 19563 | c0 = get cur 0 |
| 19564 | tok |
| 19565 | if or eq get tk 0 0 eq get tk 0 3 |
| 19566 | if ne get ir_ret 0 76 |
| 19567 | note d2site 533|ir_stmt: the line ends where a word or value is needed; condition if ne get ir_ret 0 76 |
| 19568 | put d2site 0 533 |
| 19569 | fail 4 |
| 19570 | end |
| 19571 | ir_op 15 65535 0 0 0 |
| 19572 | else |
| 19573 | if eq get ir_ret 0 76 |
| 19574 | note d2site 534|ir_stmt: extra words after a complete statement; condition if eq get ir_ret 0 76 |
| 19575 | put d2site 0 534 |
| 19576 | fail 5 |
| 19577 | end |
| 19578 | put cur 0 c0 |
| 19579 | ir_val 65534 get ir_ret 0 |
| 19580 | if ne get ir_vt 0 get ir_ret 0 |
| 19581 | note d2site 535|ir_stmt: type mismatch; condition if ne get ir_vt 0 get ir_ret 0 |
| 19582 | put d2site 0 535 |
| 19583 | fail 7 |
| 19584 | end |
| 19585 | eol |
| 19586 | ir_op 15 get ir_rr 0 0 0 0 |
| 19587 | end |
| 19588 | put ir_dead 0 1 |
| 19589 | ret 0 |
| 19590 | end |
| 19591 | if eq c 64 |
| 19592 | note d2site 536|ir_stmt: missing end; condition if eq c 64 |
| 19593 | put d2site 0 536 |
| 19594 | fail 15 |
| 19595 | end |
| 19596 | if ne c 0 |
| 19597 | if eq c 97 |
| 19598 | note continue keeps its documented IR refusal, error 3 (gate-ir.sh continue_use) |
| 19599 | note d2site 537|ir_stmt: unknown name or field, or a word this mode does not provide; condition if eq c 97 |
| 19600 | put d2site 0 537 |
| 19601 | fail 3 |
| 19602 | end |
| 19603 | if or eq c 80 eq c 82 |
| 19604 | note d2site 538|ir_stmt: word or declaration in a place that does not allow it; condition if or eq c 80 eq c 82 |
| 19605 | put d2site 0 538 |
| 19606 | fail 9 |
| 19607 | end |
| 19608 | if or or or eq c 78 eq c 79 eq c 81 eq c 85 |
| 19609 | note d2site 539|ir_stmt: word or declaration in a place that does not allow it; condition if or or or eq c 78 eq c 79 eq c 81 eq c 85 |
| 19610 | put d2site 0 539 |
| 19611 | fail 9 |
| 19612 | end |
| 19613 | if eq c 193 |
| 19614 | note d2site 540|ir_stmt: word or declaration in a place that does not allow it; condition if eq c 193 |
| 19615 | put d2site 0 540 |
| 19616 | fail 9 |
| 19617 | end |
| 19618 | note d2site 541|ir_stmt: syntax: unknown or misplaced word; condition if ne c 0 |
| 19619 | put d2site 0 541 |
| 19620 | fail 16 |
| 19621 | end |
| 19622 | note a contract clause (requires, ensures, invariant not followed by =) is not an IR v1 statement: refuse it, never |
| 19623 | note read it as a local (#791). `ensures = v` assigns a local of that name, as the C oracle and native mode accept. |
| 19624 | if ne cp_kind 0 |
| 19625 | p = get ts 0 |
| 19626 | l = get line 0 |
| 19627 | tok |
| 19628 | eqs = and eq get tk 0 1 eq ir_kwt 73 |
| 19629 | put cur 0 p |
| 19630 | put line 0 l |
| 19631 | tok |
| 19632 | if not eqs |
| 19633 | note d2site 542|ir_stmt: contract syntax misplaced or not supported here (IR mode included); condition if not eqs |
| 19634 | put d2site 0 542 |
| 19635 | fail 30 |
| 19636 | end |
| 19637 | end |
| 19638 | ir_assign get tw 0 |
| 19639 | ret 0 |
| 19640 | end |
| 19641 | |
| 19642 | note ir_param: parameter np of function f, named by the current word: a new name and an IR v1 type. |
| 19643 | fn ir_param f ulong to void |
| 19644 | w = get tw 0 |
| 19645 | s = get ts 0 |
| 19646 | l = get tl 0 |
| 19647 | ir_newloc w s l |
| 19648 | np = get irf_np f |
| 19649 | if ge np 6 |
| 19650 | note d2site 543|ir_param: word or declaration in a place that does not allow it; condition if ge np 6 |
| 19651 | put d2site 0 543 |
| 19652 | fail 9 |
| 19653 | end |
| 19654 | ty = ir_type 0 |
| 19655 | put irf_pt add mul f 6 np uchar ty |
| 19656 | put irf_np f add np 1 |
| 19657 | r = ir_newreg ty |
| 19658 | ir_bind w r |
| 19659 | end |
| 19660 | |
| 19661 | note ir_fn: fn name (param type)* to type | void, then the body. The name is checked (16, 13 over 63 |
| 19662 | note bytes, 10 when in use) and entered before the parameters, so a parameter cannot reuse it. |
| 19663 | fn ir_fn to void |
| 19664 | tok |
| 19665 | if ne get tk 0 1 |
| 19666 | note d2site 544|ir_fn: syntax: unknown or misplaced word; condition if ne get tk 0 1 |
| 19667 | put d2site 0 544 |
| 19668 | fail 16 |
| 19669 | end |
| 19670 | if gt get tl 0 63 |
| 19671 | note d2site 545|ir_fn: name too long (63 bytes; 8 for an abstract, a layout, a layout field, or any name in IR mode); condition if gt get tl 0 63 |
| 19672 | put d2site 0 545 |
| 19673 | fail 13 |
| 19674 | end |
| 19675 | fcur = get irf_n 0 |
| 19676 | if ge fcur 32 |
| 19677 | note d2site 546|ir_fn: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge fcur 32 |
| 19678 | put d2site 0 546 |
| 19679 | fail 14 |
| 19680 | end |
| 19681 | put ir_nn 0 0 |
| 19682 | ir_newname get tw 0 get ts 0 get tl 0 |
| 19683 | put irf_nm fcur get tw 0 |
| 19684 | put irf_ns fcur get ts 0 |
| 19685 | put irf_nl fcur get tl 0 |
| 19686 | put irf_np fcur 0 |
| 19687 | put irf_n 0 add fcur 1 |
| 19688 | put ir_ns 0 get ts 0 |
| 19689 | put ir_nl 0 get tl 0 |
| 19690 | put ir_nreg 0 0 |
| 19691 | put ir_nc 0 0 |
| 19692 | put ir_nb 0 0 |
| 19693 | put ir_nord 0 0 |
| 19694 | put ir_no 0 0 |
| 19695 | put ir_nf 0 0 |
| 19696 | put ir_dead 0 0 |
| 19697 | go = true |
| 19698 | while go |
| 19699 | tok |
| 19700 | if or eq get tk 0 0 eq get tk 0 3 |
| 19701 | note d2site 547|ir_fn: the line ends where a word or value is needed; condition if or eq get tk 0 0 eq get tk 0 3 |
| 19702 | put d2site 0 547 |
| 19703 | fail 4 |
| 19704 | end |
| 19705 | if ne get tk 0 1 |
| 19706 | note d2site 548|ir_fn: syntax: unknown or misplaced word; condition if ne get tk 0 1 |
| 19707 | put d2site 0 548 |
| 19708 | fail 16 |
| 19709 | end |
| 19710 | if eq ir_kwt 65 |
| 19711 | go = false |
| 19712 | else |
| 19713 | ir_param fcur |
| 19714 | end |
| 19715 | end |
| 19716 | put ir_ret 0 ir_type 1 |
| 19717 | eol |
| 19718 | put irf_ret fcur uchar get ir_ret 0 |
| 19719 | put ir_npar 0 get ir_nreg 0 |
| 19720 | b = ir_block |
| 19721 | ir_start b |
| 19722 | ir_push 4 0 0 0 0 |
| 19723 | put ir_have 0 0 |
| 19724 | while eq get ir_have 0 0 |
| 19725 | ignored = ir_stmt |
| 19726 | end |
| 19727 | end |
| 19728 | |
| 19729 | fn ir_run to void |
| 19730 | go = true |
| 19731 | while go |
| 19732 | tok |
| 19733 | k = get tk 0 |
| 19734 | if eq k 3 |
| 19735 | go = false |
| 19736 | else |
| 19737 | if eq k 0 |
| 19738 | else |
| 19739 | if ne k 1 |
| 19740 | note d2site 549|ir_run: syntax: unknown or misplaced word; condition if ne k 1 |
| 19741 | put d2site 0 549 |
| 19742 | fail 16 |
| 19743 | end |
| 19744 | c = kw get tw 0 |
| 19745 | if eq c 64 |
| 19746 | ir_fn |
| 19747 | ir_emit_record |
| 19748 | else |
| 19749 | if eq c 83 |
| 19750 | skipnl |
| 19751 | else |
| 19752 | if eq c 152 |
| 19753 | s_const |
| 19754 | else |
| 19755 | if or or eq c 85 eq c 78 eq c 79 |
| 19756 | note d2site 550|ir_run: word or declaration in a place that does not allow it; condition if or or eq c 85 eq c 78 eq c 79 |
| 19757 | put d2site 0 550 |
| 19758 | fail 9 |
| 19759 | end |
| 19760 | note d2site 551|ir_run: syntax: unknown or misplaced word; condition otherwise: if eq c 152 |
| 19761 | put d2site 0 551 |
| 19762 | fail 16 |
| 19763 | end |
| 19764 | end |
| 19765 | end |
| 19766 | end |
| 19767 | end |
| 19768 | end |
| 19769 | note ir_encode: header (magic, version 1, nfuncs) followed by every collected function record. |
| 19770 | put oc 0 0 |
| 19771 | emitb 79 |
| 19772 | emitb 83 |
| 19773 | emitb 67 |
| 19774 | emitb 49 |
| 19775 | emitb 73 |
| 19776 | emitb 82 |
| 19777 | emitb 0 |
| 19778 | emitb 1 |
| 19779 | ir_w16 get irnf 0 |
| 19780 | i = ulong 0 |
| 19781 | while lt i get irrlen 0 |
| 19782 | emitb get irrec i |
| 19783 | i = add i 1 |
| 19784 | end |
| 19785 | if ne get fmtm 0 0 |
| 19786 | fmtout |
| 19787 | end |
| 19788 | a_ceilo get oc 0 |
| 19789 | n = a_out 1 1 0 get oc 0 |
| 19790 | exit 0 |
| 19791 | end |
| 19792 | |
| 19793 | note ======== executable contract predicates (OM-2, native targets) ======== |
| 19794 | note Token packs below: Wolfram FromDigits[Reverse[ToCharacterCode[word]],256]. |
| 19795 | note Contract words are contextual: OM-1 name meanings and keyword-table bytes do not change. |
| 19796 | note Explicit native build policy, with syntax and purity checked in both policies. |
| 19797 | note om2 debug / om2 release and om2 diag debug / om2 diag release; fmt stays canonical. |
| 19798 | fn cp_mode q ulong to ulong |
| 19799 | if gt add q 4 get inlen 0 |
| 19800 | ret 0 |
| 19801 | end |
| 19802 | if ne uchar and shr get a_ar shr q 3 shl and q 7 3 255 111 |
| 19803 | ret 0 |
| 19804 | end |
| 19805 | if ne uchar and shr get a_ar shr add q 1 3 shl and add q 1 7 3 255 109 |
| 19806 | ret 0 |
| 19807 | end |
| 19808 | if ne uchar and shr get a_ar shr add q 2 3 shl and add q 2 7 3 255 50 |
| 19809 | ret 0 |
| 19810 | end |
| 19811 | if ne uchar and shr get a_ar shr add q 3 3 shl and add q 3 7 3 255 32 |
| 19812 | ret 0 |
| 19813 | end |
| 19814 | p = add q 4 |
| 19815 | m = ulong 1 |
| 19816 | if le add p 5 get inlen 0 |
| 19817 | if and eq a_ib p 100 eq a_ib add p 1 105 |
| 19818 | if and eq a_ib add p 2 97 eq a_ib add p 3 103 |
| 19819 | if eq uchar and shr get a_ar shr add p 4 3 shl and add p 4 7 3 255 32 |
| 19820 | p = add p 5 |
| 19821 | m = ulong 2 |
| 19822 | end |
| 19823 | end |
| 19824 | end |
| 19825 | end |
| 19826 | if ne lineis p 28555834798400882 7 0 |
| 19827 | put crel 0 1 |
| 19828 | ret m |
| 19829 | end |
| 19830 | if ne lineis p 444351014244 5 0 |
| 19831 | ret m |
| 19832 | end |
| 19833 | ret 0 |
| 19834 | end |
| 19835 | |
| 19836 | fn cp_kind to ulong |
| 19837 | if and eq get om2 0 0 eq get irmode 0 0 |
| 19838 | ret 0 |
| 19839 | end |
| 19840 | if ne get tk 0 1 |
| 19841 | ret 0 |
| 19842 | end |
| 19843 | if and eq get tl 0 8 eq get tw 0 8315178084276987250 |
| 19844 | ret 1 |
| 19845 | end |
| 19846 | if and eq get tl 0 7 eq get tw 0 32481164592901733 |
| 19847 | ret 2 |
| 19848 | end |
| 19849 | if and eq get tl 0 9 eq get tw8 0 7953754356895346281 |
| 19850 | if eq a_ib add get ts 0 8 116 |
| 19851 | ret 3 |
| 19852 | end |
| 19853 | end |
| 19854 | ret 0 |
| 19855 | end |
| 19856 | |
| 19857 | note cp_next reads the next prefix clause, ignoring comments and blanks; a nonclause is unread. |
| 19858 | fn cp_next to ulong |
| 19859 | p = get cur 0 |
| 19860 | l = get line 0 |
| 19861 | go = true |
| 19862 | while go |
| 19863 | tok |
| 19864 | if eq get tk 0 1 |
| 19865 | if and eq get tl 0 4 eq get tw 0 1702129518 |
| 19866 | skipnl |
| 19867 | else |
| 19868 | go = false |
| 19869 | end |
| 19870 | else |
| 19871 | if ne get tk 0 0 |
| 19872 | go = false |
| 19873 | end |
| 19874 | end |
| 19875 | end |
| 19876 | k = cp_kind |
| 19877 | if eq k 0 |
| 19878 | put cur 0 p |
| 19879 | put line 0 l |
| 19880 | end |
| 19881 | ret k |
| 19882 | end |
| 19883 | |
| 19884 | note Recursive purity allowlist, before rdval dispatch. No calls, floats, host or mapped operations. |
| 19885 | fn cp_token to void |
| 19886 | if eq get tk 0 2 |
| 19887 | ret |
| 19888 | end |
| 19889 | if ne get tk 0 1 |
| 19890 | note d2site 552|cp_token: contract syntax misplaced or not supported here (IR mode included); condition if ne get tk 0 1 |
| 19891 | put d2site 0 552 |
| 19892 | fail 30 |
| 19893 | end |
| 19894 | if gt get tl 0 63 |
| 19895 | note d2site 553|cp_token: contract syntax misplaced or not supported here (IR mode included); condition if gt get tl 0 63 |
| 19896 | put d2site 0 553 |
| 19897 | fail 30 |
| 19898 | end |
| 19899 | c = kw get tw 0 |
| 19900 | if eq c 0 |
| 19901 | ret |
| 19902 | end |
| 19903 | if le sub c 1 8 |
| 19904 | ret |
| 19905 | end |
| 19906 | if le sub c 33 19 |
| 19907 | ret |
| 19908 | end |
| 19909 | if or eq c 55 eq c 56 |
| 19910 | ret |
| 19911 | end |
| 19912 | if or or eq c 59 eq c 60 eq c 74 |
| 19913 | ret |
| 19914 | end |
| 19915 | note d2site 554|cp_token: contract syntax misplaced or not supported here (IR mode included) |
| 19916 | put d2site 0 554 |
| 19917 | fail 30 |
| 19918 | end |
| 19919 | |
| 19920 | fn cp_erase to void |
| 19921 | put oc 0 get csnap 0 |
| 19922 | put nt 0 get csnap 1 |
| 19923 | put nsite 0 get csnap 2 |
| 19924 | put tgoc 0 get csnap 5 |
| 19925 | put lastb 0 get csnap 6 |
| 19926 | note no island is ever emitted inside an evaluation (island runs only between body lines, never inside an |
| 19927 | note inline frame); tpend is kept within the trap list all the same |
| 19928 | if gt get tpend 0 get nt 0 |
| 19929 | put tpend 0 get nt 0 |
| 19930 | end |
| 19931 | end |
| 19932 | |
| 19933 | fn cp_eval code ulong erase ulong to void |
| 19934 | ln = get line 0 |
| 19935 | rule = ulong 0 |
| 19936 | note Pure evaluation changes no names, calls, inline frames or writes. |
| 19937 | note Snapshot emission effects, including trap records, diagnostic sites and branch targets. |
| 19938 | put csnap 0 get oc 0 |
| 19939 | put csnap 1 get nt 0 |
| 19940 | put csnap 2 get nsite 0 |
| 19941 | put csnap 3 get nslot 0 |
| 19942 | put csnap 4 get fzone 0 |
| 19943 | put csnap 5 get tgoc 0 |
| 19944 | put csnap 6 get lastb 0 |
| 19945 | put cpure 0 1 |
| 19946 | put fzone 0 1 |
| 19947 | rdval 0 1 255 0 |
| 19948 | if ne get rt 0 1 |
| 19949 | note d2site 555|cp_eval: type mismatch; condition if ne get rt 0 1 |
| 19950 | put d2site 0 555 |
| 19951 | fail 7 |
| 19952 | end |
| 19953 | eol |
| 19954 | nextln = get line 0 |
| 19955 | put line 0 ln |
| 19956 | if and eq get rk 0 3 ne get rv 0 0 |
| 19957 | rule = ulong 1 |
| 19958 | cp_erase |
| 19959 | else |
| 19960 | if or ne erase 0 ne get crel 0 0 |
| 19961 | rule = ulong 2 |
| 19962 | cp_erase |
| 19963 | else |
| 19964 | if eq get rk 0 3 |
| 19965 | trapc 14 code |
| 19966 | else |
| 19967 | if eq get rk 0 4 |
| 19968 | trapc xor get rv 0 1 code |
| 19969 | else |
| 19970 | r = matreg get rk 0 get rv 0 get rt 0 |
| 19971 | trapsite or 3019898880 r code |
| 19972 | end |
| 19973 | end |
| 19974 | end |
| 19975 | end |
| 19976 | if and eq get om2m 0 1 eq erase 0 |
| 19977 | cp_rec rule |
| 19978 | end |
| 19979 | put line 0 nextln |
| 19980 | put cpure 0 0 |
| 19981 | put cvalid 0 0 |
| 19982 | put fzone 0 get csnap 4 |
| 19983 | put nslot 0 get csnap 3 |
| 19984 | end |
| 19985 | |
| 19986 | note omc-check distinguishes a proof from release policy; initial deferred validation is silent. |
| 19987 | fn cp_rec rule ulong to void |
| 19988 | put rc_ccnt 0 add get rc_ccnt 0 1 |
| 19989 | sitew 7162245557575183727 8 |
| 19990 | sitew 540090475 4 |
| 19991 | if eq rule 0 |
| 19992 | sitew 1953523051 4 |
| 19993 | else |
| 19994 | sitew 110386890240613 6 |
| 19995 | end |
| 19996 | sitew 67505853393952 6 |
| 19997 | siten add get line 0 get lbase 0 |
| 19998 | sitew 67505820627488 6 |
| 19999 | if eq rule 0 |
| 20000 | sitew 28549272340166002 7 |
| 20001 | end |
| 20002 | if eq rule 1 |
| 20003 | sitew 8389750308618530659 8 |
| 20004 | sitew 435762132013 5 |
| 20005 | end |
| 20006 | if eq rule 2 |
| 20007 | sitew 28555834798400882 7 |
| 20008 | end |
| 20009 | sitew 67501558426400 6 |
| 20010 | if eq get ckind 0 1 |
| 20011 | sitew 8315178084276987250 8 |
| 20012 | end |
| 20013 | if eq get ckind 0 2 |
| 20014 | sitew 32481164592901733 7 |
| 20015 | end |
| 20016 | if eq get ckind 0 3 |
| 20017 | sitew 7953754356895346281 8 |
| 20018 | siteb 116 |
| 20019 | end |
| 20020 | siteb 10 |
| 20021 | end |
| 20022 | |
| 20023 | note Function prefix predicates bind only globals and parameters visible on entry. |
| 20024 | fn cp_entry to void |
| 20025 | lv = get inl 0 |
| 20026 | put cfhas lv 0 |
| 20027 | if eq get om2 0 0 |
| 20028 | ret |
| 20029 | end |
| 20030 | put cfpos lv get cur 0 |
| 20031 | put cfline lv get line 0 |
| 20032 | put cflim lv get nn 0 |
| 20033 | put clim 0 get nn 0 |
| 20034 | k = cp_next |
| 20035 | n = ulong 0 |
| 20036 | while ne k 0 |
| 20037 | put ckind 0 k |
| 20038 | if ge n 64 |
| 20039 | note d2site 556|cp_entry: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge n 64 |
| 20040 | put d2site 0 556 |
| 20041 | fail 14 |
| 20042 | end |
| 20043 | if eq k 3 |
| 20044 | note d2site 557|cp_entry: contract syntax misplaced or not supported here (IR mode included); condition if eq k 3 |
| 20045 | put d2site 0 557 |
| 20046 | fail 30 |
| 20047 | end |
| 20048 | put crkind 0 0 |
| 20049 | if eq k 1 |
| 20050 | cp_eval 9 0 |
| 20051 | else |
| 20052 | put cfhas lv 1 |
| 20053 | ns = get nslot 0 |
| 20054 | put crtype 0 get curret 0 |
| 20055 | if ne get curret 0 12 |
| 20056 | put crkind 0 1 |
| 20057 | put crval 0 alloc |
| 20058 | end |
| 20059 | put cvalid 0 1 |
| 20060 | cp_eval 10 1 |
| 20061 | put nslot 0 ns |
| 20062 | end |
| 20063 | n = add n 1 |
| 20064 | k = cp_next |
| 20065 | end |
| 20066 | end |
| 20067 | |
| 20068 | note Return expressions are evaluated once, before postconditions, without overwriting argument X0. |
| 20069 | fn cp_post kind ulong value ulong ty ulong to void |
| 20070 | lv = get inl 0 |
| 20071 | if eq get cfhas lv 0 |
| 20072 | ret |
| 20073 | end |
| 20074 | p = get cur 0 |
| 20075 | l = get line 0 |
| 20076 | put cur 0 get cfpos lv |
| 20077 | put line 0 get cfline lv |
| 20078 | put clim 0 get cflim lv |
| 20079 | put crkind 0 kind |
| 20080 | put crval 0 value |
| 20081 | put crtype 0 ty |
| 20082 | k = cp_next |
| 20083 | while ne k 0 |
| 20084 | if eq k 2 |
| 20085 | put ckind 0 2 |
| 20086 | cp_eval 10 0 |
| 20087 | else |
| 20088 | skipnl |
| 20089 | end |
| 20090 | k = cp_next |
| 20091 | end |
| 20092 | put cur 0 p |
| 20093 | put line 0 l |
| 20094 | end |
| 20095 | |
| 20096 | note Loop invariants execute at the head, including zero trips and final false condition. |
| 20097 | note Continue reaches the checked head (for increments first); break bypasses it. |
| 20098 | fn cp_head pos ulong ln ulong to void |
| 20099 | if eq get om2 0 0 |
| 20100 | ret |
| 20101 | end |
| 20102 | p = get cur 0 |
| 20103 | l = get line 0 |
| 20104 | put cur 0 pos |
| 20105 | put line 0 ln |
| 20106 | put clim 0 get nn 0 |
| 20107 | put crkind 0 0 |
| 20108 | k = cp_next |
| 20109 | n = ulong 0 |
| 20110 | while eq k 3 |
| 20111 | put ckind 0 3 |
| 20112 | if ge n 64 |
| 20113 | note d2site 558|cp_head: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge n 64 |
| 20114 | put d2site 0 558 |
| 20115 | fail 14 |
| 20116 | end |
| 20117 | cp_eval 10 0 |
| 20118 | n = add n 1 |
| 20119 | k = cp_next |
| 20120 | end |
| 20121 | put cphn 0 n |
| 20122 | put cur 0 p |
| 20123 | put line 0 l |
| 20124 | end |
| 20125 | |
| 20126 | note Head clauses have already been checked and emitted before the condition, never at body entry. |
| 20127 | fn cp_skip to void |
| 20128 | if eq get om2 0 0 |
| 20129 | ret |
| 20130 | end |
| 20131 | p = get cur 0 |
| 20132 | l = get line 0 |
| 20133 | k = cp_next |
| 20134 | while eq k 3 |
| 20135 | skipnl |
| 20136 | p = get cur 0 |
| 20137 | l = get line 0 |
| 20138 | k = cp_next |
| 20139 | end |
| 20140 | put cur 0 p |
| 20141 | put line 0 l |
| 20142 | end |
| 20143 | |
| 20144 | note main: read all of stdin into the arena (a read error is 1, no room is 14), find the mode, then one |
| 20145 | note statement per line from output byte 180 (om4 START .. STMT) |
| 20146 | fn main to int |
| 20147 | note the input becomes region 0 of the arena (a_rdin), then every other region gets its first room |
| 20148 | d2env |
| 20149 | put a_nr 0 1 |
| 20150 | a_env |
| 20151 | a_rdin |
| 20152 | a_init |
| 20153 | xlead |
| 20154 | chk_lead |
| 20155 | om2lead |
| 20156 | if eq get chkmode 0 4 |
| 20157 | put objmode 0 1 |
| 20158 | if or eq get om2 0 0 ne get om2m 0 0 |
| 20159 | note d2site 559|main: syntax: unknown or misplaced word; condition if or eq get om2 0 0 ne get om2m 0 0 |
| 20160 | put d2site 0 559 |
| 20161 | fail 16 |
| 20162 | end |
| 20163 | if or ne get xtarget 0 0 ne get xefa 0 0 |
| 20164 | note d2site 560|main: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if or ne get xtarget 0 0 ne get xefa 0 0 |
| 20165 | put d2site 0 560 |
| 20166 | fail 25 |
| 20167 | end |
| 20168 | end |
| 20169 | if eq get om2m 0 2 |
| 20170 | fmtprep |
| 20171 | end |
| 20172 | if ne ir_lead 0 |
| 20173 | put irmode 0 1 |
| 20174 | ir_run |
| 20175 | end |
| 20176 | prescan |
| 20177 | if ne get objmode 0 0 |
| 20178 | put progmode 0 0 |
| 20179 | end |
| 20180 | namescan |
| 20181 | if eq get nexp 0 0 |
| 20182 | put oc 0 180 |
| 20183 | else |
| 20184 | put oc 0 add 176 shl get nexp 0 2 |
| 20185 | end |
| 20186 | if ne get xefa 0 0 |
| 20187 | if eq get progmode 0 0 |
| 20188 | note d2site 561|main: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if eq get progmode 0 0 |
| 20189 | put d2site 0 561 |
| 20190 | fail 25 |
| 20191 | end |
| 20192 | note PE headers and the 8-byte relocation block fill 520 bytes; the shared firmware return is first. |
| 20193 | put oc 0 520 |
| 20194 | aefx |
| 20195 | end |
| 20196 | if ne get xtarget 0 0 |
| 20197 | put oc 0 512 |
| 20198 | if eq get xtarget 0 2 |
| 20199 | if eq get progmode 0 0 |
| 20200 | note d2site 562|main: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if eq get progmode 0 0 |
| 20201 | put d2site 0 562 |
| 20202 | fail 25 |
| 20203 | end |
| 20204 | note The PE headers fill 520 bytes; code is mapped from file offset 512 at RVA 4096 (xefx 2). |
| 20205 | put oc 0 520 |
| 20206 | end |
| 20207 | if eq get progmode 0 0 |
| 20208 | m = get nexp 0 |
| 20209 | if eq m 0 |
| 20210 | m = ulong 1 |
| 20211 | end |
| 20212 | put oc 0 add 512 mul m 6 |
| 20213 | end |
| 20214 | end |
| 20215 | put line 0 1 |
| 20216 | done = false |
| 20217 | while not done |
| 20218 | m = ulong 0 |
| 20219 | while and not done lt m 999999 |
| 20220 | if ne stmt 0 |
| 20221 | done = true |
| 20222 | end |
| 20223 | m = add m 1 |
| 20224 | end |
| 20225 | end |
| 20226 | ret 0 |
| 20227 | end |
| 20228 | |
| 20229 | note Linux x86-64 host ABI: Linux v6.17 arch/x86/entry/syscalls/syscall_64.tbl. |
| 20230 | note RBX anchors the saved slot snapshot; preserve R13 (initial argument stack) in its spare tail. |
| 20231 | note R12 (nonlocal native return), R14 (runtime dispatch), R15 (stack floor) are never scratch. |
| 20232 | fn xhbegin to void |
| 20233 | save |
| 20234 | xmem 137 13 4 144 |
| 20235 | xrr 137 3 4 |
| 20236 | end |
| 20237 | fn xha x ulong i ulong r ulong to void |
| 20238 | q = add add x 8 mul i 2 |
| 20239 | k = get a_ar add get a_rb 77 q |
| 20240 | v = get a_ar add get a_rb 77 add q 1 |
| 20241 | if or eq k 3 eq k 7 |
| 20242 | ximm r v |
| 20243 | else |
| 20244 | if eq k 6 |
| 20245 | xaddr r v |
| 20246 | else |
| 20247 | xmem 139 r 3 mul v 8 |
| 20248 | end |
| 20249 | end |
| 20250 | end |
| 20251 | fn xhs r ulong s ulong to void |
| 20252 | xmem 139 r 3 mul s 8 |
| 20253 | end |
| 20254 | fn xhb r ulong e ulong off ulong to void |
| 20255 | if ge uchar get a_ar add get a_rb 7 sub e 1 4 |
| 20256 | xaddr r get a_ar add get a_rb 8 sub e 1 |
| 20257 | else |
| 20258 | xhs r ulong uchar get a_ar add get a_rb 4 sub e 1 |
| 20259 | end |
| 20260 | xhs 0 off |
| 20261 | xrr 1 r 0 |
| 20262 | end |
| 20263 | fn xhcall n ulong to void |
| 20264 | ximm 0 n |
| 20265 | emitb 15 |
| 20266 | emitb 5 |
| 20267 | end |
| 20268 | fn xhdone dst ulong x ulong bytes ulong to void |
| 20269 | xsp 0 bytes |
| 20270 | xmem 139 13 3 144 |
| 20271 | hreturn dst x |
| 20272 | end |
| 20273 | fn xhcmp r ulong v ulong to void |
| 20274 | ximm 11 v |
| 20275 | xrr 57 r 11 |
| 20276 | end |
| 20277 | fn xhadd r ulong v ulong to void |
| 20278 | ximm 11 v |
| 20279 | xrr 1 r 11 |
| 20280 | end |
| 20281 | fn xhsub r ulong v ulong to void |
| 20282 | ximm 11 v |
| 20283 | xrr 41 r 11 |
| 20284 | end |
| 20285 | fn xhraw r ulong b ulong off ulong size ulong to void |
| 20286 | emitb uchar add add 64 shl shr r 3 2 shr b 3 |
| 20287 | if lt size 4 |
| 20288 | emitb 15 |
| 20289 | if eq size 1 |
| 20290 | emitb 182 |
| 20291 | else |
| 20292 | emitb 183 |
| 20293 | end |
| 20294 | else |
| 20295 | emitb 139 |
| 20296 | end |
| 20297 | emitb uchar add add 128 shl and r 7 3 and b 7 |
| 20298 | if eq and b 7 4 |
| 20299 | emitb 36 |
| 20300 | end |
| 20301 | xword off |
| 20302 | end |
| 20303 | fn xhput r ulong b ulong off ulong size ulong to void |
| 20304 | if eq size 2 |
| 20305 | emitb 102 |
| 20306 | end |
| 20307 | emitb uchar add add 64 shl shr r 3 2 shr b 3 |
| 20308 | if eq size 1 |
| 20309 | emitb 136 |
| 20310 | else |
| 20311 | emitb 137 |
| 20312 | end |
| 20313 | emitb uchar add add 128 shl and r 7 3 and b 7 |
| 20314 | if eq and b 7 4 |
| 20315 | emitb 36 |
| 20316 | end |
| 20317 | xword off |
| 20318 | end |
| 20319 | fn xhpath x ulong to void |
| 20320 | xhb 6 a_g 77 add x 20 a_g 77 add x 21 |
| 20321 | xhs 2 get a_ar add get a_rb 77 add x 22 |
| 20322 | xhcmp 2 4095 |
| 20323 | xtrap 8 3 |
| 20324 | xsp 1 4096 |
| 20325 | xrr 137 7 4 |
| 20326 | loop = get oc 0 |
| 20327 | xrr 133 2 2 |
| 20328 | done = xbranch 0 |
| 20329 | xhraw 0 6 0 1 |
| 20330 | xrr 133 0 0 |
| 20331 | xtrap 0 3 |
| 20332 | xhput 0 7 0 1 |
| 20333 | xhadd 6 1 |
| 20334 | xhadd 7 1 |
| 20335 | xhsub 2 1 |
| 20336 | p = xbranch 14 |
| 20337 | xpatch p loop |
| 20338 | xpatch done get oc 0 |
| 20339 | ximm 0 0 |
| 20340 | xhput 0 7 0 1 |
| 20341 | end |
| 20342 | fn xhscalar c ulong dst ulong x ulong to void |
| 20343 | np = hargc c |
| 20344 | for i ulong np |
| 20345 | ty = ulong 8 |
| 20346 | if or and eq c 103 eq i 1 and eq c 139 eq i 1 |
| 20347 | ty = ulong 9 |
| 20348 | end |
| 20349 | harg x i ty |
| 20350 | end |
| 20351 | xhbegin |
| 20352 | for i ulong np |
| 20353 | r = ulong 7 |
| 20354 | if eq i 1 |
| 20355 | r = ulong 6 |
| 20356 | end |
| 20357 | if eq i 2 |
| 20358 | r = ulong 2 |
| 20359 | end |
| 20360 | xha x i r |
| 20361 | end |
| 20362 | nr = ulong 292 |
| 20363 | if eq c 100 |
| 20364 | nr = ulong 3 |
| 20365 | end |
| 20366 | if eq c 101 |
| 20367 | nr = ulong 74 |
| 20368 | end |
| 20369 | if eq c 102 |
| 20370 | nr = ulong 91 |
| 20371 | end |
| 20372 | if eq c 103 |
| 20373 | nr = ulong 8 |
| 20374 | end |
| 20375 | if eq c 104 |
| 20376 | nr = ulong 41 |
| 20377 | end |
| 20378 | if eq c 105 |
| 20379 | nr = ulong 50 |
| 20380 | end |
| 20381 | if eq c 106 |
| 20382 | nr = ulong 288 |
| 20383 | xha x 1 10 |
| 20384 | ximm 6 0 |
| 20385 | ximm 2 0 |
| 20386 | end |
| 20387 | if eq c 107 |
| 20388 | nr = ulong 57 |
| 20389 | end |
| 20390 | if eq c 127 |
| 20391 | nr = ulong 62 |
| 20392 | end |
| 20393 | if eq c 129 |
| 20394 | nr = ulong 39 |
| 20395 | end |
| 20396 | if eq c 139 |
| 20397 | nr = ulong 77 |
| 20398 | end |
| 20399 | if eq c 145 |
| 20400 | nr = ulong 102 |
| 20401 | end |
| 20402 | if eq c 146 |
| 20403 | nr = ulong 107 |
| 20404 | end |
| 20405 | if eq c 147 |
| 20406 | nr = ulong 104 |
| 20407 | end |
| 20408 | if eq c 148 |
| 20409 | nr = ulong 108 |
| 20410 | end |
| 20411 | if eq c 153 |
| 20412 | nr = ulong 81 |
| 20413 | end |
| 20414 | if eq c 154 |
| 20415 | nr = ulong 110 |
| 20416 | end |
| 20417 | if eq c 155 |
| 20418 | nr = ulong 95 |
| 20419 | end |
| 20420 | if eq c 156 |
| 20421 | nr = ulong 75 |
| 20422 | end |
| 20423 | if eq c 158 |
| 20424 | nr = ulong 112 |
| 20425 | end |
| 20426 | if eq c 159 |
| 20427 | nr = ulong 121 |
| 20428 | end |
| 20429 | if eq c 160 |
| 20430 | nr = ulong 109 |
| 20431 | end |
| 20432 | if eq c 163 |
| 20433 | nr = ulong 124 |
| 20434 | end |
| 20435 | if eq c 164 |
| 20436 | nr = ulong 306 |
| 20437 | end |
| 20438 | if eq c 165 |
| 20439 | nr = ulong 48 |
| 20440 | end |
| 20441 | if eq c 197 |
| 20442 | nr = ulong 73 |
| 20443 | end |
| 20444 | if eq c 239 |
| 20445 | nr = ulong 141 |
| 20446 | end |
| 20447 | if eq c 240 |
| 20448 | nr = ulong 140 |
| 20449 | end |
| 20450 | xhcall nr |
| 20451 | xhdone dst x 0 |
| 20452 | end |
| 20453 | note xoflags: RDX holds fopen's flags in the language's values, which are Linux asm-generic (AArch64). x86-64 |
| 20454 | note numbers four of them differently (asm/fcntl.h): O_DIRECTORY 040000 -> 0200000, O_NOFOLLOW 0100000 -> |
| 20455 | note 0400000, O_DIRECT 0200000 -> 040000, O_LARGEFILE 0400000 -> 0100000; every other O_ flag is the same. |
| 20456 | note So bits 14..15 move up 2 and bits 16..17 move down 2: MOV RAX, RDX (89 /r); AND RAX, 0xC000 (REX.W 25 |
| 20457 | note id); SHL RAX, 2 (C1 /4 ib); MOV RCX, RDX; AND RCX, 0x30000 (REX.W 81 /4 id); SHR RCX, 2 (C1 /5 ib); OR RAX, |
| 20458 | note RCX (09 /r); AND RDX, ~0x3C000 (REX.W 81 /4 id, sign-extended); OR RDX, RAX. RAX and RCX are scratch here: |
| 20459 | note xhcall sets RAX, and SYSCALL clobbers RCX. |
| 20460 | fn xoflags to void |
| 20461 | xrr 137 0 2 |
| 20462 | emitb 72 |
| 20463 | emitb 37 |
| 20464 | xword 49152 |
| 20465 | xb 72 193 224 |
| 20466 | emitb 2 |
| 20467 | xrr 137 1 2 |
| 20468 | xb 72 129 225 |
| 20469 | xword 196608 |
| 20470 | xb 72 193 233 |
| 20471 | emitb 2 |
| 20472 | xrr 9 0 1 |
| 20473 | xb 72 129 226 |
| 20474 | xword 4294721535 |
| 20475 | xrr 9 2 0 |
| 20476 | end |
| 20477 | |
| 20478 | fn xhpaths c ulong dst ulong x ulong to void |
| 20479 | e = harray x 0 |
| 20480 | if or eq c 110 eq c 151 |
| 20481 | harg x 2 8 |
| 20482 | harg x 3 8 |
| 20483 | end |
| 20484 | if or or or eq c 112 eq c 143 eq c 144 eq c 157 |
| 20485 | harg x 2 8 |
| 20486 | end |
| 20487 | if eq c 150 |
| 20488 | harg x 2 9 |
| 20489 | end |
| 20490 | xhbegin |
| 20491 | xhpath x |
| 20492 | ximm 7 18446744073709551516 |
| 20493 | xrr 137 6 4 |
| 20494 | nr = ulong 257 |
| 20495 | if eq c 110 |
| 20496 | xha x 2 2 |
| 20497 | xoflags |
| 20498 | xha x 3 10 |
| 20499 | end |
| 20500 | if or eq c 111 eq c 126 |
| 20501 | nr = ulong 263 |
| 20502 | ximm 2 0 |
| 20503 | if eq c 126 |
| 20504 | ximm 2 512 |
| 20505 | end |
| 20506 | end |
| 20507 | if eq c 112 |
| 20508 | nr = ulong 258 |
| 20509 | xha x 2 2 |
| 20510 | end |
| 20511 | if eq c 138 |
| 20512 | nr = ulong 80 |
| 20513 | xrr 137 7 6 |
| 20514 | end |
| 20515 | if or eq c 143 eq c 144 |
| 20516 | nr = ulong 268 |
| 20517 | if eq c 144 |
| 20518 | nr = ulong 269 |
| 20519 | end |
| 20520 | xha x 2 2 |
| 20521 | ximm 10 0 |
| 20522 | end |
| 20523 | if eq c 150 |
| 20524 | nr = ulong 76 |
| 20525 | xrr 137 7 6 |
| 20526 | xha x 2 6 |
| 20527 | end |
| 20528 | if eq c 151 |
| 20529 | nr = ulong 260 |
| 20530 | xha x 2 2 |
| 20531 | xha x 3 10 |
| 20532 | ximm 8 0 |
| 20533 | end |
| 20534 | if eq c 157 |
| 20535 | nr = ulong 319 |
| 20536 | xrr 137 7 6 |
| 20537 | xha x 2 6 |
| 20538 | end |
| 20539 | xhcall nr |
| 20540 | xhdone dst x 4096 |
| 20541 | end |
| 20542 | note Native x86 struct stat is private; output remains Omega's 128-byte asm-generic ABI. |
| 20543 | fn xhstatcv to void |
| 20544 | xrr 133 0 0 |
| 20545 | bad = xbranch 11 |
| 20546 | ximm 2 0 |
| 20547 | for j ulong 16 |
| 20548 | xmem 137 2 13 mul j 8 |
| 20549 | end |
| 20550 | for j ulong 2 |
| 20551 | xmem 139 2 4 mul j 8 |
| 20552 | xmem 137 2 13 mul j 8 |
| 20553 | end |
| 20554 | xhraw 2 4 24 4 |
| 20555 | xhput 2 13 16 4 |
| 20556 | xhraw 2 4 16 4 |
| 20557 | xhput 2 13 20 4 |
| 20558 | xmem 139 2 4 28 |
| 20559 | xmem 137 2 13 24 |
| 20560 | xmem 139 2 4 40 |
| 20561 | xmem 137 2 13 32 |
| 20562 | xmem 139 2 4 48 |
| 20563 | xmem 137 2 13 48 |
| 20564 | xhraw 2 4 56 4 |
| 20565 | xhput 2 13 56 4 |
| 20566 | for j ulong 7 |
| 20567 | xmem 139 2 4 add 64 mul j 8 |
| 20568 | xmem 137 2 13 add 64 mul j 8 |
| 20569 | end |
| 20570 | ximm 0 0 |
| 20571 | xpatch bad get oc 0 |
| 20572 | end |
| 20573 | fn xhbuffer c ulong dst ulong x ulong to void |
| 20574 | harg x 4 8 |
| 20575 | wr = ulong 0 |
| 20576 | if or or or or or eq c 113 eq c 116 eq c 117 eq c 118 eq c 131 eq c 161 |
| 20577 | wr = ulong 1 |
| 20578 | end |
| 20579 | if eq c 224 |
| 20580 | wr = ulong 1 |
| 20581 | end |
| 20582 | e = harray x wr |
| 20583 | if or or eq c 116 eq c 118 eq c 119 |
| 20584 | harg x 2 8 |
| 20585 | end |
| 20586 | if or eq c 161 eq c 162 |
| 20587 | harg x 3 9 |
| 20588 | end |
| 20589 | xhbegin |
| 20590 | xha x 4 7 |
| 20591 | xhb 6 e get a_ar add get a_rb 77 add x 21 |
| 20592 | xhs 2 get a_ar add get a_rb 77 add x 22 |
| 20593 | nr = ulong 217 |
| 20594 | if or eq c 114 eq c 115 |
| 20595 | nr = ulong 42 |
| 20596 | if eq c 115 |
| 20597 | nr = ulong 49 |
| 20598 | end |
| 20599 | end |
| 20600 | if eq c 116 |
| 20601 | xhcmp 2 4 |
| 20602 | xtrap 3 3 |
| 20603 | nr = ulong 61 |
| 20604 | xha x 2 2 |
| 20605 | ximm 10 0 |
| 20606 | end |
| 20607 | if eq c 117 |
| 20608 | xhcmp 2 128 |
| 20609 | xtrap 3 3 |
| 20610 | xrr 137 13 6 |
| 20611 | xsp 1 144 |
| 20612 | xrr 137 6 4 |
| 20613 | xhcall 5 |
| 20614 | xhstatcv |
| 20615 | xhdone dst x 144 |
| 20616 | ret |
| 20617 | end |
| 20618 | if or eq c 118 eq c 119 |
| 20619 | nr = ulong 45 |
| 20620 | xha x 2 10 |
| 20621 | ximm 8 0 |
| 20622 | ximm 9 0 |
| 20623 | if eq c 119 |
| 20624 | nr = ulong 44 |
| 20625 | ximm 0 16384 |
| 20626 | xrr 9 10 0 |
| 20627 | end |
| 20628 | end |
| 20629 | if or eq c 131 eq c 224 |
| 20630 | note peername shares the private 32-bit socklen; x86-64 getsockname 51, getpeername 52. |
| 20631 | xsp 1 16 |
| 20632 | xhput 2 4 0 4 |
| 20633 | xrr 137 2 4 |
| 20634 | if eq c 224 |
| 20635 | xhcall 52 |
| 20636 | else |
| 20637 | xhcall 51 |
| 20638 | end |
| 20639 | xrr 133 0 0 |
| 20640 | bad = xbranch 11 |
| 20641 | xhraw 0 4 0 4 |
| 20642 | xpatch bad get oc 0 |
| 20643 | xhdone dst x 16 |
| 20644 | ret |
| 20645 | end |
| 20646 | if or eq c 161 eq c 162 |
| 20647 | nr = ulong 17 |
| 20648 | if eq c 162 |
| 20649 | nr = ulong 18 |
| 20650 | end |
| 20651 | xha x 3 10 |
| 20652 | end |
| 20653 | xhcall nr |
| 20654 | xhdone dst x 0 |
| 20655 | end |
| 20656 | fn xhstats c ulong dst ulong x ulong to void |
| 20657 | e = harray x 0 |
| 20658 | put a_ar add get a_rb 77 add x 23 e |
| 20659 | a_p 77 add x 24 a_g 77 add x 21 |
| 20660 | a_p 77 add x 25 a_g 77 add x 22 |
| 20661 | e = harray x 1 |
| 20662 | put a_ar add get a_rb 77 add x 26 e |
| 20663 | a_p 77 add x 27 a_g 77 add x 21 |
| 20664 | a_p 77 add x 28 a_g 77 add x 22 |
| 20665 | a_p 77 add x 20 a_g 77 add x 23 |
| 20666 | a_p 77 add x 21 a_g 77 add x 24 |
| 20667 | a_p 77 add x 22 a_g 77 add x 25 |
| 20668 | xhbegin |
| 20669 | xhs 2 get a_ar add get a_rb 77 add x 22 |
| 20670 | xrr 133 2 2 |
| 20671 | xtrap 0 3 |
| 20672 | xhpath x |
| 20673 | xhb 13 e get a_ar add get a_rb 77 add x 27 |
| 20674 | xhs 2 get a_ar add get a_rb 77 add x 28 |
| 20675 | xhcmp 2 128 |
| 20676 | xtrap 3 3 |
| 20677 | ximm 7 18446744073709551516 |
| 20678 | xrr 137 6 4 |
| 20679 | xsp 1 144 |
| 20680 | xrr 137 2 4 |
| 20681 | ximm 10 0 |
| 20682 | if eq c 149 |
| 20683 | ximm 10 256 |
| 20684 | end |
| 20685 | xhcall 262 |
| 20686 | xhstatcv |
| 20687 | xhdone dst x 4240 |
| 20688 | end |
| 20689 | fn xhtime c ulong dst ulong x ulong to void |
| 20690 | if eq c 120 |
| 20691 | harg x 0 9 |
| 20692 | end |
| 20693 | xhbegin |
| 20694 | xsp 1 16 |
| 20695 | if eq c 120 |
| 20696 | xha x 0 0 |
| 20697 | xrr 133 0 0 |
| 20698 | xtrap 11 3 |
| 20699 | ximm 1 1000000000 |
| 20700 | ximm 2 0 |
| 20701 | xb 72 247 241 |
| 20702 | xmem 137 0 4 0 |
| 20703 | xmem 137 2 4 8 |
| 20704 | xrr 137 7 4 |
| 20705 | ximm 6 0 |
| 20706 | xhcall 35 |
| 20707 | else |
| 20708 | ximm 7 1 |
| 20709 | if eq c 130 |
| 20710 | ximm 7 0 |
| 20711 | end |
| 20712 | xrr 137 6 4 |
| 20713 | xhcall 228 |
| 20714 | xrr 133 0 0 |
| 20715 | bad = xbranch 11 |
| 20716 | xmem 139 2 4 0 |
| 20717 | xhcmp 2 9223372036 |
| 20718 | xtrap 8 1 |
| 20719 | ximm 0 1000000000 |
| 20720 | xb 72 15 175 |
| 20721 | emitb 194 |
| 20722 | xmem 139 2 4 8 |
| 20723 | xrr 1 0 2 |
| 20724 | xtrap 6 1 |
| 20725 | xpatch bad get oc 0 |
| 20726 | end |
| 20727 | xhdone dst x 16 |
| 20728 | end |
| 20729 | |
| 20730 | fn xrot ty ulong ra ulong b ulong imm ulong rd ulong to void |
| 20731 | xload 0 ra |
| 20732 | if ne imm 0 |
| 20733 | ximm 1 b |
| 20734 | else |
| 20735 | xload 1 b |
| 20736 | end |
| 20737 | if eq ty 3 |
| 20738 | emitb 102 |
| 20739 | end |
| 20740 | if eq ty 5 |
| 20741 | emitb 72 |
| 20742 | end |
| 20743 | if eq ty 2 |
| 20744 | emitb 210 |
| 20745 | else |
| 20746 | emitb 211 |
| 20747 | end |
| 20748 | emitb 200 |
| 20749 | xstore 0 rd |
| 20750 | canon rd ty |
| 20751 | end |
| 20752 | |
| 20753 | fn xhts off ulong to void |
| 20754 | xrr 133 2 2 |
| 20755 | forever = xbranch 11 |
| 20756 | xrr 137 0 2 |
| 20757 | ximm 1 1000000000 |
| 20758 | ximm 2 0 |
| 20759 | xb 72 247 241 |
| 20760 | xmem 137 0 4 off |
| 20761 | xmem 137 2 4 add off 8 |
| 20762 | xmem 141 2 4 off |
| 20763 | jump = xbranch 14 |
| 20764 | xpatch forever get oc 0 |
| 20765 | ximm 2 0 |
| 20766 | xpatch jump get oc 0 |
| 20767 | end |
| 20768 | fn xhpoll c ulong dst ulong x ulong to void |
| 20769 | if eq c 123 |
| 20770 | harg x 0 8 |
| 20771 | harg x 1 8 |
| 20772 | harg x 2 9 |
| 20773 | xhbegin |
| 20774 | xha x 0 7 |
| 20775 | xha x 1 6 |
| 20776 | xha x 2 2 |
| 20777 | xrr 133 6 6 |
| 20778 | xtrap 11 3 |
| 20779 | xhcmp 6 65535 |
| 20780 | xtrap 8 3 |
| 20781 | xsp 1 32 |
| 20782 | ximm 0 0 |
| 20783 | xmem 137 0 4 0 |
| 20784 | xhput 7 4 0 4 |
| 20785 | xhput 6 4 4 2 |
| 20786 | xhts 16 |
| 20787 | xrr 137 7 4 |
| 20788 | ximm 6 1 |
| 20789 | else |
| 20790 | e = harray x 1 |
| 20791 | harg x 2 9 |
| 20792 | xhbegin |
| 20793 | xhb 7 e get a_ar add get a_rb 77 add x 21 |
| 20794 | xhs 6 get a_ar add get a_rb 77 add x 22 |
| 20795 | xhcmp 6 8192 |
| 20796 | xtrap 8 3 |
| 20797 | xrr 137 0 6 |
| 20798 | ximm 1 7 |
| 20799 | xrr 33 0 1 |
| 20800 | xrr 133 0 0 |
| 20801 | xtrap 1 3 |
| 20802 | xb 72 193 238 |
| 20803 | emitb 3 |
| 20804 | xha x 2 2 |
| 20805 | xsp 1 32 |
| 20806 | xhts 16 |
| 20807 | end |
| 20808 | ximm 10 0 |
| 20809 | ximm 8 8 |
| 20810 | xhcall 271 |
| 20811 | if eq c 123 |
| 20812 | xrr 133 0 0 |
| 20813 | bad = xbranch 13 |
| 20814 | xhraw 0 4 6 2 |
| 20815 | xpatch bad get oc 0 |
| 20816 | end |
| 20817 | xhdone dst x 32 |
| 20818 | end |
| 20819 | fn xhargs c ulong dst ulong x ulong to void |
| 20820 | put hostargs 0 1 |
| 20821 | if or eq c 121 eq c 136 |
| 20822 | xhbegin |
| 20823 | xmem 139 0 13 0 |
| 20824 | if eq c 136 |
| 20825 | xmem 141 6 13 16 |
| 20826 | xb 72 193 224 |
| 20827 | emitb 3 |
| 20828 | xrr 1 6 0 |
| 20829 | ximm 0 0 |
| 20830 | loop = get oc 0 |
| 20831 | xmem 139 2 6 0 |
| 20832 | xrr 133 2 2 |
| 20833 | done = xbranch 0 |
| 20834 | xhadd 6 8 |
| 20835 | xhadd 0 1 |
| 20836 | p = xbranch 14 |
| 20837 | xpatch p loop |
| 20838 | xpatch done get oc 0 |
| 20839 | end |
| 20840 | xhdone dst x 0 |
| 20841 | ret |
| 20842 | end |
| 20843 | harg x 4 5 |
| 20844 | e = harray x 1 |
| 20845 | xhbegin |
| 20846 | xha x 4 2 |
| 20847 | xmem 139 1 13 0 |
| 20848 | xmem 141 6 13 8 |
| 20849 | if eq c 137 |
| 20850 | xhadd 1 1 |
| 20851 | xb 72 193 225 |
| 20852 | emitb 3 |
| 20853 | xrr 1 6 1 |
| 20854 | loop = get oc 0 |
| 20855 | xmem 139 0 6 0 |
| 20856 | xrr 133 0 0 |
| 20857 | xtrap 0 3 |
| 20858 | xrr 133 2 2 |
| 20859 | done = xbranch 0 |
| 20860 | xhsub 2 1 |
| 20861 | xhadd 6 8 |
| 20862 | p = xbranch 14 |
| 20863 | xpatch p loop |
| 20864 | xpatch done get oc 0 |
| 20865 | else |
| 20866 | xrr 57 2 1 |
| 20867 | xtrap 2 3 |
| 20868 | xb 72 193 226 |
| 20869 | emitb 3 |
| 20870 | xrr 1 6 2 |
| 20871 | end |
| 20872 | xmem 139 6 6 0 |
| 20873 | xrr 137 13 6 |
| 20874 | ximm 2 0 |
| 20875 | scan = get oc 0 |
| 20876 | xhraw 0 6 0 1 |
| 20877 | xrr 133 0 0 |
| 20878 | found = xbranch 0 |
| 20879 | xhadd 6 1 |
| 20880 | xhadd 2 1 |
| 20881 | xhcmp 2 1048576 |
| 20882 | xtrap 2 3 |
| 20883 | p = xbranch 14 |
| 20884 | xpatch p scan |
| 20885 | xpatch found get oc 0 |
| 20886 | xhs 1 get a_ar add get a_rb 77 add x 22 |
| 20887 | xrr 57 2 1 |
| 20888 | small = xbranch 8 |
| 20889 | xhb 7 e get a_ar add get a_rb 77 add x 21 |
| 20890 | xrr 137 6 13 |
| 20891 | xrr 137 1 2 |
| 20892 | emitb 243 |
| 20893 | emitb 164 |
| 20894 | xrr 137 0 2 |
| 20895 | tail = xbranch 14 |
| 20896 | xpatch small get oc 0 |
| 20897 | ximm 0 18446744073709551511 |
| 20898 | xpatch tail get oc 0 |
| 20899 | xhdone dst x 0 |
| 20900 | end |
| 20901 | fn xhsimple c ulong dst ulong x ulong to void |
| 20902 | e = harray x 1 |
| 20903 | if or eq c 128 eq c 135 |
| 20904 | harg x 2 8 |
| 20905 | end |
| 20906 | xhbegin |
| 20907 | xhb 7 e get a_ar add get a_rb 77 add x 21 |
| 20908 | xhs 6 get a_ar add get a_rb 77 add x 22 |
| 20909 | nr = ulong 79 |
| 20910 | if eq c 128 |
| 20911 | xhcmp 6 8 |
| 20912 | xtrap 3 3 |
| 20913 | xha x 2 6 |
| 20914 | nr = ulong 293 |
| 20915 | end |
| 20916 | if eq c 135 |
| 20917 | xha x 2 2 |
| 20918 | nr = ulong 318 |
| 20919 | end |
| 20920 | xhcall nr |
| 20921 | xhdone dst x 0 |
| 20922 | end |
| 20923 | fn xhreadln dst ulong x ulong to void |
| 20924 | e = harray x 0 |
| 20925 | put a_ar add get a_rb 77 add x 23 e |
| 20926 | a_p 77 add x 24 a_g 77 add x 21 |
| 20927 | a_p 77 add x 25 a_g 77 add x 22 |
| 20928 | e = harray x 1 |
| 20929 | put a_ar add get a_rb 77 add x 26 e |
| 20930 | a_p 77 add x 27 a_g 77 add x 21 |
| 20931 | a_p 77 add x 28 a_g 77 add x 22 |
| 20932 | a_p 77 add x 20 a_g 77 add x 23 |
| 20933 | a_p 77 add x 21 a_g 77 add x 24 |
| 20934 | a_p 77 add x 22 a_g 77 add x 25 |
| 20935 | xhbegin |
| 20936 | xhs 2 get a_ar add get a_rb 77 add x 22 |
| 20937 | xrr 133 2 2 |
| 20938 | xtrap 0 3 |
| 20939 | xhpath x |
| 20940 | xhb 2 e get a_ar add get a_rb 77 add x 27 |
| 20941 | xhs 10 get a_ar add get a_rb 77 add x 28 |
| 20942 | ximm 7 18446744073709551516 |
| 20943 | xrr 137 6 4 |
| 20944 | xhcall 267 |
| 20945 | xhdone dst x 4096 |
| 20946 | end |
| 20947 | note Scheduler host words 236..238 on x86linux. Linux syscall_64.tbl: affinity 203/204, getcpu 309. |
| 20948 | fn xhsched c ulong dst ulong x ulong to void |
| 20949 | if eq c 238 |
| 20950 | xhbegin |
| 20951 | xsp 1 16 |
| 20952 | xrr 137 7 4 |
| 20953 | ximm 6 0 |
| 20954 | ximm 2 0 |
| 20955 | xhcall 309 |
| 20956 | xrr 133 0 0 |
| 20957 | bad = xbranch 11 |
| 20958 | xhraw 0 4 0 4 |
| 20959 | xpatch bad get oc 0 |
| 20960 | xhdone dst x 16 |
| 20961 | ret |
| 20962 | end |
| 20963 | harg x 2 8 |
| 20964 | w = ulong 0 |
| 20965 | if eq c 237 |
| 20966 | w = ulong 1 |
| 20967 | end |
| 20968 | e = harray x w |
| 20969 | xhbegin |
| 20970 | xha x 2 7 |
| 20971 | xhb 2 e get a_ar add get a_rb 77 add x 21 |
| 20972 | xhs 6 get a_ar add get a_rb 77 add x 22 |
| 20973 | xhcall add 203 w |
| 20974 | xhdone dst x 0 |
| 20975 | end |
| 20976 | note prlimit (235) on x86-64: prlimit64 302, RDI pid, RSI res, RDX new, R10 old; n 16 reads (RDX 0, R10 |
| 20977 | note &A[off]), n 32 sets (RDX &A[off], R10 &A[off+16]), other n -22 without a kernel call. |
| 20978 | fn xhprlim dst ulong x ulong to void |
| 20979 | harg x 2 8 |
| 20980 | harg x 3 8 |
| 20981 | e = harray x 1 |
| 20982 | xhbegin |
| 20983 | xha x 2 7 |
| 20984 | xha x 3 6 |
| 20985 | xhb 10 e get a_ar add get a_rb 77 add x 21 |
| 20986 | xhs 8 get a_ar add get a_rb 77 add x 22 |
| 20987 | ximm 2 0 |
| 20988 | xhcmp 8 16 |
| 20989 | rd = xbranch 0 |
| 20990 | xhcmp 8 32 |
| 20991 | setp = xbranch 0 |
| 20992 | ximm 0 sub ulong 0 22 |
| 20993 | bad = xbranch 14 |
| 20994 | xpatch setp get oc 0 |
| 20995 | xrr 137 2 10 |
| 20996 | xhadd 10 16 |
| 20997 | xpatch rd get oc 0 |
| 20998 | xhcall 302 |
| 20999 | xpatch bad get oc 0 |
| 21000 | xhdone dst x 0 |
| 21001 | end |
| 21002 | fn xhsock c ulong dst ulong x ulong to void |
| 21003 | ok = new ulong 6 0 |
| 21004 | if eq c 134 |
| 21005 | harg x 2 8 |
| 21006 | harg x 3 8 |
| 21007 | harg x 4 8 |
| 21008 | e = harray x 0 |
| 21009 | xhbegin |
| 21010 | xha x 2 7 |
| 21011 | xha x 3 6 |
| 21012 | xha x 4 2 |
| 21013 | xhb 10 e get a_ar add get a_rb 77 add x 21 |
| 21014 | xhs 8 get a_ar add get a_rb 77 add x 22 |
| 21015 | xhcmp 6 1 |
| 21016 | tcp = xbranch 1 |
| 21017 | for j ulong 5 |
| 21018 | v = add j 5 |
| 21019 | if eq j 0 |
| 21020 | v = ulong 2 |
| 21021 | end |
| 21022 | if eq j 1 |
| 21023 | v = ulong 15 |
| 21024 | end |
| 21025 | xhcmp 2 v |
| 21026 | put ok j xbranch 0 |
| 21027 | end |
| 21028 | badso = xbranch 14 |
| 21029 | xpatch tcp get oc 0 |
| 21030 | xhcmp 6 6 |
| 21031 | badtcp = xbranch 1 |
| 21032 | xhcmp 2 1 |
| 21033 | put ok 5 xbranch 0 |
| 21034 | xpatch badso get oc 0 |
| 21035 | xpatch badtcp get oc 0 |
| 21036 | ximm 0 sub ulong 0 92 |
| 21037 | done = xbranch 14 |
| 21038 | for j ulong 6 |
| 21039 | xpatch get ok j get oc 0 |
| 21040 | end |
| 21041 | xhcmp 8 4 |
| 21042 | sizeok = xbranch 0 |
| 21043 | ximm 0 sub ulong 0 22 |
| 21044 | badsize = xbranch 14 |
| 21045 | xpatch sizeok get oc 0 |
| 21046 | xhcall 54 |
| 21047 | xpatch done get oc 0 |
| 21048 | xpatch badsize get oc 0 |
| 21049 | xhdone dst x 0 |
| 21050 | ret |
| 21051 | end |
| 21052 | harg x 4 8 |
| 21053 | if eq c 220 |
| 21054 | e = harray x 1 |
| 21055 | xhbegin |
| 21056 | xha x 4 7 |
| 21057 | xhb 10 e get a_ar add get a_rb 77 add x 21 |
| 21058 | xhs 8 get a_ar add get a_rb 77 add x 22 |
| 21059 | xhcmp 8 12 |
| 21060 | xtrap 3 3 |
| 21061 | ximm 6 1 |
| 21062 | ximm 2 17 |
| 21063 | xsp 1 16 |
| 21064 | ximm 8 12 |
| 21065 | xhput 8 4 0 4 |
| 21066 | xrr 137 8 4 |
| 21067 | xhcall 55 |
| 21068 | xhdone dst x 16 |
| 21069 | ret |
| 21070 | end |
| 21071 | e = harray x 0 |
| 21072 | harg x 2 8 |
| 21073 | xhbegin |
| 21074 | xha x 4 7 |
| 21075 | xha x 2 2 |
| 21076 | ximm 0 16384 |
| 21077 | xrr 9 2 0 |
| 21078 | xhb 6 e get a_ar add get a_rb 77 add x 21 |
| 21079 | xhs 8 get a_ar add get a_rb 77 add x 22 |
| 21080 | xsp 1 80 |
| 21081 | ximm 0 0 |
| 21082 | for j ulong 10 |
| 21083 | xmem 137 0 4 mul j 8 |
| 21084 | end |
| 21085 | xmem 137 6 4 64 |
| 21086 | xmem 137 8 4 72 |
| 21087 | xmem 141 6 4 64 |
| 21088 | xmem 137 6 4 16 |
| 21089 | ximm 6 1 |
| 21090 | xmem 137 6 4 24 |
| 21091 | xrr 137 6 4 |
| 21092 | xhcall 46 |
| 21093 | xhdone dst x 80 |
| 21094 | end |
| 21095 | note execenv 233 on x86-64: as on AArch64, a second pass decodes the environment packet (every record |
| 21096 | note nonempty) into env strings at RSP+81920 and env pointers at RSP+86016; both checks precede close_range. |
| 21097 | note Exec argv packets (execprog, execenv) allow 65536 bytes and 1024 records, pointers at RSP+65536; |
| 21098 | note renames, link, symlnk and the environment packet keep 4096 bytes and 64 records. |
| 21099 | fn xhpack c ulong dst ulong x ulong to void |
| 21100 | e = harray x 0 |
| 21101 | if eq c 125 |
| 21102 | harg x 2 8 |
| 21103 | end |
| 21104 | if eq c 233 |
| 21105 | put a_ar add get a_rb 77 add x 23 e |
| 21106 | a_p 77 add x 24 a_g 77 add x 21 |
| 21107 | a_p 77 add x 25 a_g 77 add x 22 |
| 21108 | e = harray x 0 |
| 21109 | put a_ar add get a_rb 77 add x 26 e |
| 21110 | a_p 77 add x 27 a_g 77 add x 21 |
| 21111 | a_p 77 add x 28 a_g 77 add x 22 |
| 21112 | a_p 77 add x 20 a_g 77 add x 23 |
| 21113 | a_p 77 add x 21 a_g 77 add x 24 |
| 21114 | a_p 77 add x 22 a_g 77 add x 25 |
| 21115 | e = get a_ar add get a_rb 77 add x 23 |
| 21116 | end |
| 21117 | xhbegin |
| 21118 | note stack: 8192 bytes for renames, link and symlnk; 81920 for execprog; 90112 for execenv (two passes). |
| 21119 | stack = ulong 8192 |
| 21120 | if ne hexw c 0 |
| 21121 | stack = ulong 81920 |
| 21122 | end |
| 21123 | if eq c 233 |
| 21124 | stack = ulong 90112 |
| 21125 | end |
| 21126 | pass = ulong 0 |
| 21127 | while lt pass hnpass c |
| 21128 | if eq pass 0 |
| 21129 | xhb 6 e get a_ar add get a_rb 77 add x 21 |
| 21130 | xhs 2 get a_ar add get a_rb 77 add x 22 |
| 21131 | else |
| 21132 | note The slot snapshot is RBX-relative, so the environment slice is read after the RSP move. |
| 21133 | xhb 6 a_g 77 add x 26 a_g 77 add x 27 |
| 21134 | xhs 2 get a_ar add get a_rb 77 add x 28 |
| 21135 | end |
| 21136 | if eq hplim c pass 1024 |
| 21137 | xhcmp 2 65536 |
| 21138 | else |
| 21139 | xhcmp 2 4096 |
| 21140 | end |
| 21141 | xtrap 8 3 |
| 21142 | xhcmp 2 2 |
| 21143 | xtrap 3 3 |
| 21144 | xhraw 8 6 0 2 |
| 21145 | xhadd 6 2 |
| 21146 | xhsub 2 2 |
| 21147 | xrr 133 8 8 |
| 21148 | xtrap 0 3 |
| 21149 | xhcmp 8 hplim c pass |
| 21150 | xtrap 8 3 |
| 21151 | if or or eq c 125 eq c 141 eq c 142 |
| 21152 | xhcmp 8 2 |
| 21153 | xtrap 1 3 |
| 21154 | end |
| 21155 | if eq pass 0 |
| 21156 | xsp 1 stack |
| 21157 | xrr 137 10 4 |
| 21158 | if ne hexw c 0 |
| 21159 | xmem 141 13 4 65536 |
| 21160 | else |
| 21161 | xmem 141 13 4 4096 |
| 21162 | end |
| 21163 | else |
| 21164 | xmem 141 10 4 81920 |
| 21165 | xmem 141 13 4 86016 |
| 21166 | end |
| 21167 | ximm 9 0 |
| 21168 | outer = get oc 0 |
| 21169 | xrr 57 9 8 |
| 21170 | done = xbranch 2 |
| 21171 | xhcmp 2 2 |
| 21172 | xtrap 3 3 |
| 21173 | xhraw 1 6 0 2 |
| 21174 | xhadd 6 2 |
| 21175 | xhsub 2 2 |
| 21176 | xrr 57 1 2 |
| 21177 | xtrap 8 3 |
| 21178 | if and eq pass 0 or eq c 124 eq c 233 |
| 21179 | xrr 133 9 9 |
| 21180 | notfirst = xbranch 1 |
| 21181 | xrr 133 1 1 |
| 21182 | xtrap 0 3 |
| 21183 | xpatch notfirst get oc 0 |
| 21184 | else |
| 21185 | xrr 133 1 1 |
| 21186 | xtrap 0 3 |
| 21187 | end |
| 21188 | xmem 137 10 13 0 |
| 21189 | xhadd 13 8 |
| 21190 | xrr 41 2 1 |
| 21191 | inner = get oc 0 |
| 21192 | xrr 133 1 1 |
| 21193 | endstr = xbranch 0 |
| 21194 | xhraw 0 6 0 1 |
| 21195 | xrr 133 0 0 |
| 21196 | xtrap 0 3 |
| 21197 | xhput 0 10 0 1 |
| 21198 | xhadd 6 1 |
| 21199 | xhadd 10 1 |
| 21200 | xhsub 1 1 |
| 21201 | p = xbranch 14 |
| 21202 | xpatch p inner |
| 21203 | xpatch endstr get oc 0 |
| 21204 | ximm 0 0 |
| 21205 | xhput 0 10 0 1 |
| 21206 | xhadd 10 1 |
| 21207 | xhadd 9 1 |
| 21208 | p = xbranch 14 |
| 21209 | xpatch p outer |
| 21210 | xpatch done get oc 0 |
| 21211 | xrr 133 2 2 |
| 21212 | xtrap 1 3 |
| 21213 | ximm 0 0 |
| 21214 | xmem 137 0 13 0 |
| 21215 | pass = add pass 1 |
| 21216 | end |
| 21217 | if or eq c 124 eq c 233 |
| 21218 | note As on AArch64: close_range(3, ~0U, CLOSE_RANGE_UNSHARE) first; a nonzero result skips execve |
| 21219 | note and returns that kernel error. RDI/RSI/RDX are reloaded after the call; R13 holds the argv end. |
| 21220 | ximm 7 3 |
| 21221 | ximm 6 4294967295 |
| 21222 | ximm 2 2 |
| 21223 | xhcall 436 |
| 21224 | xrr 133 0 0 |
| 21225 | p = xbranch 1 |
| 21226 | xmem 139 7 4 65536 |
| 21227 | xmem 141 6 4 65536 |
| 21228 | if eq c 233 |
| 21229 | xmem 141 2 4 86016 |
| 21230 | else |
| 21231 | xrr 137 2 13 |
| 21232 | end |
| 21233 | xhcall 59 |
| 21234 | xpatch p get oc 0 |
| 21235 | else |
| 21236 | xmem 139 6 4 4096 |
| 21237 | xmem 139 10 4 4104 |
| 21238 | ximm 7 18446744073709551516 |
| 21239 | ximm 2 18446744073709551516 |
| 21240 | ximm 8 0 |
| 21241 | if eq c 125 |
| 21242 | xha x 2 8 |
| 21243 | xhcall 316 |
| 21244 | else |
| 21245 | if eq c 141 |
| 21246 | xhcall 265 |
| 21247 | else |
| 21248 | xrr 137 7 6 |
| 21249 | ximm 6 18446744073709551516 |
| 21250 | xrr 137 2 10 |
| 21251 | xhcall 266 |
| 21252 | end |
| 21253 | end |
| 21254 | end |
| 21255 | xhdone dst x stack |
| 21256 | end |
| 21257 | note Hosted handles use the entry31 context header and 13 slot bits; programs retain raw128 slots. |
| 21258 | fn xhmcheck to void |
| 21259 | xrr 137 13 10 |
| 21260 | if eq get progmode 0 0 |
| 21261 | ximm 0 8191 |
| 21262 | else |
| 21263 | ximm 0 255 |
| 21264 | end |
| 21265 | xrr 33 13 0 |
| 21266 | xhcmp 13 1 |
| 21267 | xtrap 3 3 |
| 21268 | if eq get progmode 0 0 |
| 21269 | xmem 139 0 14 248 |
| 21270 | xmem 139 0 0 0 |
| 21271 | xhcmp 0 1 |
| 21272 | xtrap 3 3 |
| 21273 | xhcmp 0 4098 |
| 21274 | xtrap 8 3 |
| 21275 | xrr 57 13 0 |
| 21276 | xtrap 8 3 |
| 21277 | else |
| 21278 | xhcmp 13 128 |
| 21279 | xtrap 8 3 |
| 21280 | end |
| 21281 | xhsub 13 1 |
| 21282 | xb 73 193 229 |
| 21283 | emitb 5 |
| 21284 | if eq get progmode 0 0 |
| 21285 | xmem 139 0 14 248 |
| 21286 | xhadd 0 32 |
| 21287 | else |
| 21288 | xaddr 0 get maptab 0 |
| 21289 | end |
| 21290 | xrr 1 13 0 |
| 21291 | xmem 139 9 13 16 |
| 21292 | xrr 133 9 9 |
| 21293 | xtrap 0 3 |
| 21294 | xb 73 193 234 |
| 21295 | if eq get progmode 0 0 |
| 21296 | emitb 13 |
| 21297 | else |
| 21298 | emitb 8 |
| 21299 | end |
| 21300 | xrr 57 10 9 |
| 21301 | xtrap 1 3 |
| 21302 | xmem 139 8 13 0 |
| 21303 | xrr 133 8 8 |
| 21304 | xtrap 0 3 |
| 21305 | xmem 139 9 13 8 |
| 21306 | end |
| 21307 | fn xhmnew c ulong dst ulong x ulong to void |
| 21308 | acc = ulong 0 |
| 21309 | mode = ulong 1048610 |
| 21310 | if eq c 167 |
| 21311 | harg x 0 8 |
| 21312 | harg x 1 5 |
| 21313 | harg x 2 5 |
| 21314 | harg x 3 8 |
| 21315 | harg x 4 8 |
| 21316 | if or ne a_g 77 add x 14 3 ne a_g 77 add x 16 3 |
| 21317 | note d2site 563|xhmnew: word or declaration in a place that does not allow it; condition if or ne a_g 77 add x 14 3 ne a_g 77 add x 16 3 |
| 21318 | put d2site 0 563 |
| 21319 | fail 9 |
| 21320 | end |
| 21321 | acc = get a_ar add get a_rb 77 add x 15 |
| 21322 | mode = get a_ar add get a_rb 77 add x 17 |
| 21323 | if and ne acc 1 ne acc 3 |
| 21324 | note d2site 564|xhmnew: word or declaration in a place that does not allow it; condition if and ne acc 1 ne acc 3 |
| 21325 | put d2site 0 564 |
| 21326 | fail 9 |
| 21327 | end |
| 21328 | if and and and ne mode 1 ne mode 2 ne mode 33 ne mode 34 |
| 21329 | note d2site 565|xhmnew: word or declaration in a place that does not allow it; condition if and and and ne mode 1 ne mode 2 ne mode 33 ne mode 34 |
| 21330 | put d2site 0 565 |
| 21331 | fail 9 |
| 21332 | end |
| 21333 | end |
| 21334 | if eq c 176 |
| 21335 | harg x 1 5 |
| 21336 | harg x 2 5 |
| 21337 | end |
| 21338 | if eq c 242 |
| 21339 | harg x 0 8 |
| 21340 | harg x 1 5 |
| 21341 | harg x 2 5 |
| 21342 | acc = ulong 3 |
| 21343 | mode = ulong 1 |
| 21344 | end |
| 21345 | if eq c 243 |
| 21346 | harg x 2 5 |
| 21347 | mode = ulong 34 |
| 21348 | end |
| 21349 | xhbegin |
| 21350 | if eq c 242 |
| 21351 | xha x 0 7 |
| 21352 | kmapfd |
| 21353 | end |
| 21354 | xha x 2 6 |
| 21355 | xrr 133 6 6 |
| 21356 | xtrap 0 3 |
| 21357 | if lt c 242 |
| 21358 | xhcmp 6 68719476736 |
| 21359 | xtrap 8 3 |
| 21360 | end |
| 21361 | if or eq c 167 eq c 242 |
| 21362 | xha x 0 8 |
| 21363 | xha x 1 9 |
| 21364 | if ge mode 32 |
| 21365 | xhcmp 8 18446744073709551615 |
| 21366 | xtrap 1 3 |
| 21367 | xrr 133 9 9 |
| 21368 | xtrap 1 3 |
| 21369 | end |
| 21370 | end |
| 21371 | if eq c 243 |
| 21372 | ximm 8 18446744073709551615 |
| 21373 | ximm 9 0 |
| 21374 | end |
| 21375 | if eq c 176 |
| 21376 | xha x 1 7 |
| 21377 | xhcmp 7 65536 |
| 21378 | xtrap 3 3 |
| 21379 | ximm 0 1099511627776 |
| 21380 | xrr 41 0 6 |
| 21381 | xrr 57 7 0 |
| 21382 | xtrap 8 3 |
| 21383 | ximm 0 4095 |
| 21384 | xrr 137 1 7 |
| 21385 | xrr 33 1 0 |
| 21386 | xrr 133 1 1 |
| 21387 | xtrap 1 3 |
| 21388 | xrr 137 1 6 |
| 21389 | xrr 33 1 0 |
| 21390 | xrr 133 1 1 |
| 21391 | xtrap 1 3 |
| 21392 | ximm 8 18446744073709551615 |
| 21393 | ximm 9 0 |
| 21394 | end |
| 21395 | if eq get progmode 0 0 |
| 21396 | xmem 139 13 14 248 |
| 21397 | xmem 139 0 13 0 |
| 21398 | xhcmp 0 1 |
| 21399 | xtrap 3 3 |
| 21400 | xhcmp 0 4098 |
| 21401 | xtrap 8 3 |
| 21402 | xmem 139 0 13 16 |
| 21403 | xhcmp 0 1 |
| 21404 | xtrap 3 3 |
| 21405 | xhcmp 0 1125899906842623 |
| 21406 | xtrap 8 3 |
| 21407 | xhadd 13 32 |
| 21408 | else |
| 21409 | xaddr 13 get maptab 0 |
| 21410 | end |
| 21411 | ximm 2 1 |
| 21412 | head = get oc 0 |
| 21413 | xmem 139 0 13 0 |
| 21414 | xrr 133 0 0 |
| 21415 | used = xbranch 1 |
| 21416 | xmem 139 10 13 16 |
| 21417 | if eq get progmode 0 0 |
| 21418 | xmem 139 11 14 248 |
| 21419 | xmem 139 11 11 16 |
| 21420 | xrr 57 10 11 |
| 21421 | else |
| 21422 | xhcmp 10 36028797018963967 |
| 21423 | end |
| 21424 | vacant = xbranch 3 |
| 21425 | xpatch used get oc 0 |
| 21426 | xhadd 13 32 |
| 21427 | xhadd 2 1 |
| 21428 | if eq get progmode 0 0 |
| 21429 | xmem 139 11 14 248 |
| 21430 | xmem 139 11 11 0 |
| 21431 | xrr 57 2 11 |
| 21432 | else |
| 21433 | xhcmp 2 128 |
| 21434 | end |
| 21435 | again = xbranch 9 |
| 21436 | xpatch again head |
| 21437 | ximm 0 sub ulong 0 24 |
| 21438 | full = xbranch 14 |
| 21439 | xpatch vacant get oc 0 |
| 21440 | xsp 1 32 |
| 21441 | if eq c 243 |
| 21442 | xsp 1 16 |
| 21443 | end |
| 21444 | xmem 137 2 4 0 |
| 21445 | xmem 137 6 4 8 |
| 21446 | xmem 137 10 4 16 |
| 21447 | if eq c 176 |
| 21448 | xha x 1 7 |
| 21449 | else |
| 21450 | ximm 7 0 |
| 21451 | end |
| 21452 | ximm 2 acc |
| 21453 | if eq c 243 |
| 21454 | ximm 11 4095 |
| 21455 | xrr 137 0 6 |
| 21456 | xrr 33 0 11 |
| 21457 | xhcmp 0 0 |
| 21458 | xtrap 1 3 |
| 21459 | ximm 11 2097152 |
| 21460 | xrr 1 6 11 |
| 21461 | xtrap 3 3 |
| 21462 | end |
| 21463 | ximm 10 mode |
| 21464 | xhcall 9 |
| 21465 | xrr 133 0 0 |
| 21466 | failed = xbranch 11 |
| 21467 | if eq c 243 |
| 21468 | xrr 137 7 0 |
| 21469 | xhadd 0 2097151 |
| 21470 | ximm 11 18446744073707454464 |
| 21471 | xrr 33 0 11 |
| 21472 | xmem 137 0 4 24 |
| 21473 | xrr 137 6 0 |
| 21474 | xrr 41 6 7 |
| 21475 | xmem 137 6 4 32 |
| 21476 | xrr 133 6 6 |
| 21477 | aligned = xbranch 0 |
| 21478 | xhcall 11 |
| 21479 | xrr 133 0 0 |
| 21480 | xtrap 1 3 |
| 21481 | xpatch aligned get oc 0 |
| 21482 | xmem 139 7 4 24 |
| 21483 | xmem 139 6 4 8 |
| 21484 | xrr 1 7 6 |
| 21485 | note Suffix = 2MiB - prefix, both page aligned. |
| 21486 | xmem 139 0 4 32 |
| 21487 | ximm 6 2097152 |
| 21488 | xrr 41 6 0 |
| 21489 | xhcall 11 |
| 21490 | xrr 133 0 0 |
| 21491 | xtrap 1 3 |
| 21492 | xmem 139 0 4 24 |
| 21493 | end |
| 21494 | wrong = ulong 0 |
| 21495 | if eq c 176 |
| 21496 | xha x 1 2 |
| 21497 | xrr 57 0 2 |
| 21498 | exact = xbranch 0 |
| 21499 | xrr 137 7 0 |
| 21500 | xmem 139 6 4 8 |
| 21501 | xhcall 11 |
| 21502 | xrr 133 0 0 |
| 21503 | xtrap 1 3 |
| 21504 | ximm 0 sub ulong 0 95 |
| 21505 | wrong = xbranch 14 |
| 21506 | xpatch exact get oc 0 |
| 21507 | end |
| 21508 | xmem 137 0 13 0 |
| 21509 | xmem 139 2 4 8 |
| 21510 | xmem 137 2 13 8 |
| 21511 | xmem 139 2 4 16 |
| 21512 | xhadd 2 1 |
| 21513 | xmem 137 2 13 16 |
| 21514 | ximm 0 acc |
| 21515 | xmem 137 0 13 24 |
| 21516 | xrr 137 0 2 |
| 21517 | xb 72 193 224 |
| 21518 | if eq get progmode 0 0 |
| 21519 | emitb 13 |
| 21520 | else |
| 21521 | emitb 8 |
| 21522 | end |
| 21523 | xmem 139 2 4 0 |
| 21524 | xrr 9 0 2 |
| 21525 | xpatch failed get oc 0 |
| 21526 | if ne wrong 0 |
| 21527 | xpatch wrong get oc 0 |
| 21528 | end |
| 21529 | xsp 0 32 |
| 21530 | if eq c 243 |
| 21531 | xsp 0 16 |
| 21532 | end |
| 21533 | xpatch full get oc 0 |
| 21534 | xhdone dst x 0 |
| 21535 | end |
| 21536 | fn xhmbind dst ulong x ulong to void |
| 21537 | harg x 0 9 |
| 21538 | harg x 1 8 |
| 21539 | harg x 2 5 |
| 21540 | harg x 3 8 |
| 21541 | if ne get a_ar add get a_rb 77 add x 14 3 |
| 21542 | note d2site 566|xhmbind: word or declaration in a place that does not allow it; condition if ne get a_ar add get a_rb 77 add x 14 3 |
| 21543 | put d2site 0 566 |
| 21544 | fail 9 |
| 21545 | end |
| 21546 | acc = get a_ar add get a_rb 77 add x 15 |
| 21547 | if and ne acc 1 ne acc 3 |
| 21548 | note d2site 567|xhmbind: word or declaration in a place that does not allow it; condition if and ne acc 1 ne acc 3 |
| 21549 | put d2site 0 567 |
| 21550 | fail 9 |
| 21551 | end |
| 21552 | xhbegin |
| 21553 | xha x 0 10 |
| 21554 | xhmcheck |
| 21555 | xmem 139 0 13 24 |
| 21556 | xrr 133 0 0 |
| 21557 | xtrap 1 3 |
| 21558 | xsp 1 32 |
| 21559 | xmem 137 8 4 0 |
| 21560 | xmem 137 9 4 8 |
| 21561 | xrr 137 7 8 |
| 21562 | xrr 137 6 9 |
| 21563 | xha x 1 8 |
| 21564 | xha x 2 9 |
| 21565 | ximm 2 acc |
| 21566 | ximm 10 17 |
| 21567 | xhcall 9 |
| 21568 | xrr 133 0 0 |
| 21569 | failed = xbranch 11 |
| 21570 | xmem 139 2 4 0 |
| 21571 | xrr 57 0 2 |
| 21572 | xtrap 1 3 |
| 21573 | ximm 0 acc |
| 21574 | xmem 137 0 13 24 |
| 21575 | ximm 0 0 |
| 21576 | done = xbranch 14 |
| 21577 | xpatch failed get oc 0 |
| 21578 | xmem 137 0 4 16 |
| 21579 | ximm 0 4 |
| 21580 | xmem 137 0 13 24 |
| 21581 | xmem 139 7 4 0 |
| 21582 | xmem 139 6 4 8 |
| 21583 | xhcall 11 |
| 21584 | xrr 133 0 0 |
| 21585 | xtrap 1 3 |
| 21586 | ximm 0 0 |
| 21587 | xmem 137 0 13 0 |
| 21588 | xmem 137 0 13 8 |
| 21589 | xmem 137 0 13 24 |
| 21590 | xmem 139 0 4 16 |
| 21591 | xpatch done get oc 0 |
| 21592 | xhdone dst x 32 |
| 21593 | end |
| 21594 | fn xhmcopy c ulong dst ulong x ulong to void |
| 21595 | harg x 4 9 |
| 21596 | harg x 3 5 |
| 21597 | wr = ulong 0 |
| 21598 | if eq c 169 |
| 21599 | wr = ulong 1 |
| 21600 | end |
| 21601 | e = harray x wr |
| 21602 | xhbegin |
| 21603 | xha x 4 10 |
| 21604 | xhmcheck |
| 21605 | xmem 139 0 13 24 |
| 21606 | xrr 133 0 0 |
| 21607 | xtrap 0 3 |
| 21608 | xhcmp 0 3 |
| 21609 | xtrap 8 3 |
| 21610 | xha x 3 2 |
| 21611 | xrr 57 2 9 |
| 21612 | xtrap 8 3 |
| 21613 | xrr 41 9 2 |
| 21614 | xhs 1 get a_ar add get a_rb 77 add x 22 |
| 21615 | xrr 57 1 9 |
| 21616 | xtrap 8 3 |
| 21617 | xrr 1 8 2 |
| 21618 | xhb 7 e get a_ar add get a_rb 77 add x 21 |
| 21619 | xrr 137 6 8 |
| 21620 | if eq c 170 |
| 21621 | xmem 139 0 13 24 |
| 21622 | xhcmp 0 3 |
| 21623 | xtrap 1 3 |
| 21624 | xrr 137 6 7 |
| 21625 | xrr 137 7 8 |
| 21626 | end |
| 21627 | xrr 137 2 1 |
| 21628 | emitb 243 |
| 21629 | emitb 164 |
| 21630 | xrr 137 0 2 |
| 21631 | xhdone dst x 0 |
| 21632 | end |
| 21633 | fn xhmmio c ulong dst ulong x ulong to void |
| 21634 | harg x 0 9 |
| 21635 | if eq c 173 |
| 21636 | xhbegin |
| 21637 | xha x 0 10 |
| 21638 | xhmcheck |
| 21639 | xrr 137 0 8 |
| 21640 | xhdone dst x 0 |
| 21641 | put rt 0 5 |
| 21642 | ret |
| 21643 | end |
| 21644 | harg x 1 5 |
| 21645 | harg x 2 8 |
| 21646 | if ne get a_ar add get a_rb 77 add x 12 3 |
| 21647 | note d2site 568|xhmmio: word or declaration in a place that does not allow it; condition if ne get a_ar add get a_rb 77 add x 12 3 |
| 21648 | put d2site 0 568 |
| 21649 | fail 9 |
| 21650 | end |
| 21651 | w = get a_ar add get a_rb 77 add x 13 |
| 21652 | if and ne w 4 ne w 8 |
| 21653 | note d2site 569|xhmmio: word or declaration in a place that does not allow it; condition if and ne w 4 ne w 8 |
| 21654 | put d2site 0 569 |
| 21655 | fail 9 |
| 21656 | end |
| 21657 | if eq c 175 |
| 21658 | harg x 3 5 |
| 21659 | end |
| 21660 | xhbegin |
| 21661 | xha x 0 10 |
| 21662 | xhmcheck |
| 21663 | xha x 1 2 |
| 21664 | xmem 139 0 13 24 |
| 21665 | xrr 133 0 0 |
| 21666 | xtrap 0 3 |
| 21667 | xhcmp 0 3 |
| 21668 | xtrap 8 3 |
| 21669 | xrr 57 2 9 |
| 21670 | xtrap 8 3 |
| 21671 | xrr 41 9 2 |
| 21672 | xhcmp 9 w |
| 21673 | xtrap 3 3 |
| 21674 | xrr 137 0 2 |
| 21675 | ximm 1 sub w 1 |
| 21676 | xrr 33 0 1 |
| 21677 | xrr 133 0 0 |
| 21678 | xtrap 1 3 |
| 21679 | xrr 1 8 2 |
| 21680 | if eq c 175 |
| 21681 | xmem 139 0 13 24 |
| 21682 | xhcmp 0 3 |
| 21683 | xtrap 1 3 |
| 21684 | xha x 3 2 |
| 21685 | if eq w 4 |
| 21686 | xhcmp 2 4294967295 |
| 21687 | xtrap 8 3 |
| 21688 | end |
| 21689 | xb 15 174 240 |
| 21690 | if eq w 4 |
| 21691 | xhput 2 8 0 4 |
| 21692 | else |
| 21693 | xmem 137 2 8 0 |
| 21694 | end |
| 21695 | xb 15 174 240 |
| 21696 | ximm 0 0 |
| 21697 | xhdone dst x 0 |
| 21698 | else |
| 21699 | xb 15 174 240 |
| 21700 | if eq w 4 |
| 21701 | xhraw 0 8 0 4 |
| 21702 | else |
| 21703 | xmem 139 0 8 0 |
| 21704 | end |
| 21705 | xb 15 174 240 |
| 21706 | xhdone dst x 0 |
| 21707 | put rt 0 5 |
| 21708 | end |
| 21709 | end |
| 21710 | note One compile-time ioctl allowlist is shared by both native Linux backends. |
| 21711 | fn xhreq c ulong x ulong to ulong |
| 21712 | harg x 4 8 |
| 21713 | harg x 2 4 |
| 21714 | if ne get a_ar add get a_rb 77 add x 12 3 |
| 21715 | note d2site 570|xhreq: word or declaration in a place that does not allow it; condition if ne get a_ar add get a_rb 77 add x 12 3 |
| 21716 | put d2site 0 570 |
| 21717 | fail 9 |
| 21718 | end |
| 21719 | q = get a_ar add get a_rb 77 add x 13 |
| 21720 | n = ulong 4 |
| 21721 | if eq c 166 |
| 21722 | if ne q 21531 |
| 21723 | if ne and q 3221290752 3221243392 |
| 21724 | ok = eq q 2154840336 |
| 21725 | ok = or ok eq q 3224387873 |
| 21726 | ok = or ok eq q 3222815010 |
| 21727 | ok = or ok eq q 3225960739 |
| 21728 | ok = or ok eq q 3222815012 |
| 21729 | if not ok |
| 21730 | note d2site 571|xhreq: word or declaration in a place that does not allow it; condition if not ok |
| 21731 | put d2site 0 571 |
| 21732 | fail 9 |
| 21733 | end |
| 21734 | end |
| 21735 | n = and shr q 16 16383 |
| 21736 | if eq n 0 |
| 21737 | note d2site 572|xhreq: word or declaration in a place that does not allow it; condition if eq n 0 |
| 21738 | put d2site 0 572 |
| 21739 | fail 9 |
| 21740 | end |
| 21741 | end |
| 21742 | end |
| 21743 | if eq c 172 |
| 21744 | n = ulong 0 |
| 21745 | if eq q 805306369 |
| 21746 | n = ulong 16 |
| 21747 | end |
| 21748 | if eq q 75 |
| 21749 | n = ulong 8 |
| 21750 | end |
| 21751 | if eq q 37 |
| 21752 | n = ulong 40 |
| 21753 | end |
| 21754 | if or eq q 38 eq q 26 |
| 21755 | n = ulong 20 |
| 21756 | end |
| 21757 | if eq q 25 |
| 21758 | n = ulong 32 |
| 21759 | end |
| 21760 | if eq q 27 |
| 21761 | n = ulong 56 |
| 21762 | end |
| 21763 | if eq q 28 |
| 21764 | n = ulong 28 |
| 21765 | end |
| 21766 | if eq q 33 |
| 21767 | n = ulong 9264 |
| 21768 | end |
| 21769 | if or eq q 34 eq q 73 |
| 21770 | n = ulong 24 |
| 21771 | end |
| 21772 | if eq n 0 |
| 21773 | note d2site 573|xhreq: word or declaration in a place that does not allow it; condition if eq n 0 |
| 21774 | put d2site 0 573 |
| 21775 | fail 9 |
| 21776 | end |
| 21777 | end |
| 21778 | if eq c 171 |
| 21779 | if and ne q 3223340586 ne q 3223340587 |
| 21780 | note d2site 574|xhreq: word or declaration in a place that does not allow it; condition if and ne q 3223340586 ne q 3223340587 |
| 21781 | put d2site 0 574 |
| 21782 | fail 9 |
| 21783 | end |
| 21784 | n = ulong 32 |
| 21785 | end |
| 21786 | ret n |
| 21787 | end |
| 21788 | fn xhdev c ulong dst ulong x ulong to void |
| 21789 | n = xhreq c x |
| 21790 | put a_ar add get a_rb 77 add x 23 n |
| 21791 | e = harray x 1 |
| 21792 | if ne c 171 |
| 21793 | xhbegin |
| 21794 | xhs 2 get a_ar add get a_rb 77 add x 22 |
| 21795 | xhcmp 2 get a_ar add get a_rb 77 add x 23 |
| 21796 | xtrap 1 3 |
| 21797 | xha x 4 7 |
| 21798 | xha x 2 6 |
| 21799 | xhb 2 e get a_ar add get a_rb 77 add x 21 |
| 21800 | xhcall 16 |
| 21801 | xhdone dst x 0 |
| 21802 | ret |
| 21803 | end |
| 21804 | put a_ar add get a_rb 77 add x 23 e |
| 21805 | a_p 77 add x 24 a_g 77 add x 21 |
| 21806 | a_p 77 add x 25 a_g 77 add x 22 |
| 21807 | f = harray x 1 |
| 21808 | if eq e f |
| 21809 | note d2site 575|xhdev: global passed as an argument, or one array twice in a call; condition if eq e f |
| 21810 | put d2site 0 575 |
| 21811 | fail 19 |
| 21812 | end |
| 21813 | xhbegin |
| 21814 | xhs 2 get a_ar add get a_rb 77 add x 25 |
| 21815 | xhcmp 2 32 |
| 21816 | xtrap 1 3 |
| 21817 | xhs 9 get a_ar add get a_rb 77 add x 22 |
| 21818 | xhcmp 9 1048576 |
| 21819 | xtrap 8 3 |
| 21820 | xhb 13 e get a_ar add get a_rb 77 add x 24 |
| 21821 | xhb 8 f get a_ar add get a_rb 77 add x 21 |
| 21822 | xrr 133 9 9 |
| 21823 | empty = xbranch 0 |
| 21824 | xrr 137 2 8 |
| 21825 | xrr 1 2 9 |
| 21826 | xrr 57 2 13 |
| 21827 | before = xbranch 9 |
| 21828 | xmem 141 2 13 32 |
| 21829 | xrr 57 8 2 |
| 21830 | xtrap 3 3 |
| 21831 | xpatch before get oc 0 |
| 21832 | xpatch empty get oc 0 |
| 21833 | xmem 139 2 13 16 |
| 21834 | xrr 133 2 2 |
| 21835 | xtrap 1 3 |
| 21836 | xrr 133 9 9 |
| 21837 | nonzero = xbranch 1 |
| 21838 | ximm 8 0 |
| 21839 | xpatch nonzero get oc 0 |
| 21840 | xsp 1 32 |
| 21841 | for j ulong 4 |
| 21842 | xmem 139 0 13 mul j 8 |
| 21843 | xmem 137 0 4 mul j 8 |
| 21844 | end |
| 21845 | xmem 137 8 4 16 |
| 21846 | xhput 9 4 24 4 |
| 21847 | xha x 4 7 |
| 21848 | xha x 2 6 |
| 21849 | xrr 137 2 4 |
| 21850 | xhcall 16 |
| 21851 | for j ulong 4 |
| 21852 | if ne j 2 |
| 21853 | xmem 139 2 4 mul j 8 |
| 21854 | xmem 137 2 13 mul j 8 |
| 21855 | end |
| 21856 | end |
| 21857 | xhdone dst x 32 |
| 21858 | end |
| 21859 | fn xhost c ulong dst ulong to void |
| 21860 | if ne get xtarget 0 1 |
| 21861 | note d2site 576|xhost: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if ne get xtarget 0 1 |
| 21862 | put d2site 0 576 |
| 21863 | fail 25 |
| 21864 | end |
| 21865 | if eq 0 get progmode 0 |
| 21866 | if eq 0 get om2 0 |
| 21867 | note d2site 577|xhost: word or declaration in a place that does not allow it; condition if eq 0 get om2 0 |
| 21868 | put d2site 0 577 |
| 21869 | fail 9 |
| 21870 | end |
| 21871 | ok = ulong 0 |
| 21872 | if or or eq c 100 eq c 110 or eq c 117 eq c 140 |
| 21873 | ok = ulong 1 |
| 21874 | end |
| 21875 | if and le c 149 ge c 145 |
| 21876 | ok = ulong 1 |
| 21877 | end |
| 21878 | if or or eq c 130 eq c 109 eq c 120 |
| 21879 | ok = ulong 1 |
| 21880 | end |
| 21881 | if and le c 177 ge c 166 |
| 21882 | ok = ulong 1 |
| 21883 | end |
| 21884 | if eq ok 0 |
| 21885 | note d2site 578|xhost: word or declaration in a place that does not allow it; condition if eq ok 0 |
| 21886 | put d2site 0 578 |
| 21887 | fail 9 |
| 21888 | end |
| 21889 | end |
| 21890 | note execpure (198) has no x86 strict-profile lowering; refuse it rather than run an unconfined exec. |
| 21891 | if eq c 198 |
| 21892 | note d2site 579|xhost: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if eq c 198 |
| 21893 | put d2site 0 579 |
| 21894 | fail 25 |
| 21895 | end |
| 21896 | eff_rec c |
| 21897 | x = mul get depth 0 32 |
| 21898 | put a_ar add get a_rb 77 add x 7 get nslot 0 |
| 21899 | if and ge c 241 le c 243 |
| 21900 | mtinit |
| 21901 | if eq c 241 |
| 21902 | kctl dst x |
| 21903 | else |
| 21904 | xhmnew c dst x |
| 21905 | end |
| 21906 | ret |
| 21907 | end |
| 21908 | if and ge c 236 le c 238 |
| 21909 | xhsched c dst x |
| 21910 | ret |
| 21911 | end |
| 21912 | if eq c 235 |
| 21913 | xhprlim dst x |
| 21914 | ret |
| 21915 | end |
| 21916 | if or eq c 220 eq c 222 |
| 21917 | xhsock c dst x |
| 21918 | ret |
| 21919 | end |
| 21920 | if or eq c 123 eq c 221 |
| 21921 | xhpoll c dst x |
| 21922 | ret |
| 21923 | end |
| 21924 | if and ge c 167 le c 177 |
| 21925 | if or eq c 171 eq c 172 |
| 21926 | xhdev c dst x |
| 21927 | ret |
| 21928 | end |
| 21929 | mtinit |
| 21930 | if or eq c 167 eq c 176 |
| 21931 | xhmnew c dst x |
| 21932 | ret |
| 21933 | end |
| 21934 | if eq c 177 |
| 21935 | xhmbind dst x |
| 21936 | ret |
| 21937 | end |
| 21938 | if eq c 168 |
| 21939 | harg x 0 9 |
| 21940 | xhbegin |
| 21941 | xha x 0 10 |
| 21942 | xhmcheck |
| 21943 | xrr 137 7 8 |
| 21944 | xrr 137 6 9 |
| 21945 | xhcall 11 |
| 21946 | xrr 133 0 0 |
| 21947 | failed = xbranch 1 |
| 21948 | xmem 137 0 13 0 |
| 21949 | xmem 137 0 13 8 |
| 21950 | xmem 137 0 13 24 |
| 21951 | xpatch failed get oc 0 |
| 21952 | xhdone dst x 0 |
| 21953 | ret |
| 21954 | end |
| 21955 | if or eq c 169 eq c 170 |
| 21956 | xhmcopy c dst x |
| 21957 | ret |
| 21958 | end |
| 21959 | xhmmio c dst x |
| 21960 | ret |
| 21961 | end |
| 21962 | if eq c 166 |
| 21963 | xhdev c dst x |
| 21964 | ret |
| 21965 | end |
| 21966 | if or eq c 132 eq c 128 |
| 21967 | xhsimple c dst x |
| 21968 | ret |
| 21969 | end |
| 21970 | if eq c 135 |
| 21971 | xhsimple c dst x |
| 21972 | ret |
| 21973 | end |
| 21974 | if eq c 133 |
| 21975 | xhreadln dst x |
| 21976 | ret |
| 21977 | end |
| 21978 | if eq c 134 |
| 21979 | xhsock c dst x |
| 21980 | ret |
| 21981 | end |
| 21982 | if or or eq c 109 eq c 130 eq c 120 |
| 21983 | xhtime c dst x |
| 21984 | ret |
| 21985 | end |
| 21986 | if or or or and ge c 113 le c 119 eq c 131 or eq c 161 eq c 162 eq c 224 |
| 21987 | xhbuffer c dst x |
| 21988 | ret |
| 21989 | end |
| 21990 | if or or or eq c 121 eq c 122 eq c 136 eq c 137 |
| 21991 | xhargs c dst x |
| 21992 | ret |
| 21993 | end |
| 21994 | if or or or or eq c 124 eq c 125 eq c 141 eq c 142 eq c 233 |
| 21995 | xhpack c dst x |
| 21996 | ret |
| 21997 | end |
| 21998 | if or eq c 140 eq c 149 |
| 21999 | xhstats c dst x |
| 22000 | ret |
| 22001 | end |
| 22002 | if or or or or eq c 110 eq c 111 eq c 112 eq c 126 eq c 138 |
| 22003 | xhpaths c dst x |
| 22004 | ret |
| 22005 | end |
| 22006 | if or or or or eq c 143 eq c 144 eq c 150 eq c 151 eq c 157 |
| 22007 | xhpaths c dst x |
| 22008 | ret |
| 22009 | end |
| 22010 | xhscalar c dst x |
| 22011 | end |
| 22012 | |
| 22013 | note ======== Native x86-64 semantic backend ======== |
| 22014 | note Intel SDM volume 2 instruction entries MOV, LEA, CALL, RET, Jcc, SETcc, MOVSX, |
| 22015 | note MOVZX, ADD, SUB, IMUL, DIV, IDIV, SHL, SHR, SAR, SYSCALL; volume 2 chapter 2 |
| 22016 | note supplies REX, ModRM and SIB. No A64 word decoding occurs in this backend. |
| 22017 | fn xb a ulong b ulong c ulong to void |
| 22018 | emitb uchar a |
| 22019 | emitb uchar b |
| 22020 | emitb uchar c |
| 22021 | end |
| 22022 | |
| 22023 | fn xword v ulong to void |
| 22024 | emitb uchar and v 255 |
| 22025 | emitb uchar and shr v 8 255 |
| 22026 | emitb uchar and shr v 16 255 |
| 22027 | emitb uchar and shr v 24 255 |
| 22028 | end |
| 22029 | |
| 22030 | fn ximm r ulong v ulong to void |
| 22031 | emitb uchar add 72 shr r 3 |
| 22032 | emitb uchar add 184 and r 7 |
| 22033 | xword v |
| 22034 | xword shr v 32 |
| 22035 | end |
| 22036 | |
| 22037 | note Hardware registers are private emitter operands. Language values are RBP slots. |
| 22038 | fn xrr op ulong d ulong s ulong to void |
| 22039 | emitb uchar add add 72 shl shr s 3 2 shr d 3 |
| 22040 | emitb uchar op |
| 22041 | emitb uchar add add 192 shl and s 7 3 and d 7 |
| 22042 | end |
| 22043 | |
| 22044 | fn xmem op ulong r ulong b ulong off ulong to void |
| 22045 | emitb uchar add add 72 shl shr r 3 2 shr b 3 |
| 22046 | emitb uchar op |
| 22047 | emitb uchar add add 128 shl and r 7 3 and b 7 |
| 22048 | if eq and b 7 4 |
| 22049 | emitb 36 |
| 22050 | end |
| 22051 | xword off |
| 22052 | end |
| 22053 | |
| 22054 | fn xload r ulong s ulong to void |
| 22055 | xmem 139 r 5 sub ulong 0 mul add s 1 8 |
| 22056 | end |
| 22057 | |
| 22058 | fn xstore r ulong s ulong to void |
| 22059 | xmem 137 r 5 sub ulong 0 mul add s 1 8 |
| 22060 | end |
| 22061 | |
| 22062 | fn xcc cc ulong to ulong |
| 22063 | if eq cc 0 |
| 22064 | ret 4 |
| 22065 | end |
| 22066 | if eq cc 1 |
| 22067 | ret 5 |
| 22068 | end |
| 22069 | if eq cc 2 |
| 22070 | ret 3 |
| 22071 | end |
| 22072 | if eq cc 3 |
| 22073 | ret 2 |
| 22074 | end |
| 22075 | if eq cc 6 |
| 22076 | ret 0 |
| 22077 | end |
| 22078 | if eq cc 7 |
| 22079 | ret 1 |
| 22080 | end |
| 22081 | if eq cc 8 |
| 22082 | ret 7 |
| 22083 | end |
| 22084 | if eq cc 9 |
| 22085 | ret 6 |
| 22086 | end |
| 22087 | if eq cc 10 |
| 22088 | ret 13 |
| 22089 | end |
| 22090 | if eq cc 11 |
| 22091 | ret 12 |
| 22092 | end |
| 22093 | if eq cc 12 |
| 22094 | ret 15 |
| 22095 | end |
| 22096 | if eq cc 13 |
| 22097 | ret 14 |
| 22098 | end |
| 22099 | note d2site 580|xcc: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14) |
| 22100 | put d2site 0 580 |
| 22101 | fail 25 |
| 22102 | ret 0 |
| 22103 | end |
| 22104 | |
| 22105 | note Every branch reserves six bytes; all targets are byte offsets, not word offsets. |
| 22106 | fn xbranch cc ulong to ulong |
| 22107 | p = get oc 0 |
| 22108 | if eq cc 14 |
| 22109 | emitb 233 |
| 22110 | xword 0 |
| 22111 | emitb 144 |
| 22112 | else |
| 22113 | emitb 15 |
| 22114 | emitb uchar add 128 xcc cc |
| 22115 | xword 0 |
| 22116 | end |
| 22117 | ret p |
| 22118 | end |
| 22119 | |
| 22120 | fn xpatch p ulong dest ulong to void |
| 22121 | if eq a_ob p 233 |
| 22122 | wrword add p 1 sub dest add p 5 |
| 22123 | else |
| 22124 | wrword add p 2 sub dest add p 6 |
| 22125 | end |
| 22126 | end |
| 22127 | |
| 22128 | fn xtrap cc ulong code ulong to void |
| 22129 | n = get nt 0 |
| 22130 | if ge n get a_gp 10 |
| 22131 | a_need 10 n |
| 22132 | end |
| 22133 | put a_ar add get a_rb 45 n code |
| 22134 | put a_ar add get a_rb 44 n xbranch cc |
| 22135 | put nt 0 add n 1 |
| 22136 | if eq get om2m 0 1 |
| 22137 | siterec |
| 22138 | end |
| 22139 | end |
| 22140 | |
| 22141 | fn xcmp a ulong b ulong imm ulong to void |
| 22142 | xload 0 a |
| 22143 | if ne imm 0 |
| 22144 | ximm 1 b |
| 22145 | else |
| 22146 | xload 1 b |
| 22147 | end |
| 22148 | xrr 57 0 1 |
| 22149 | end |
| 22150 | |
| 22151 | note Canonicalization uses shifts, preserving the checked language's signed widths. |
| 22152 | fn xcanrax t ulong to void |
| 22153 | if eq t 10 |
| 22154 | emitb 137 |
| 22155 | emitb 192 |
| 22156 | ret |
| 22157 | end |
| 22158 | w = twid t |
| 22159 | if eq w 64 |
| 22160 | ret |
| 22161 | end |
| 22162 | xb 72 193 224 |
| 22163 | emitb uchar sub 64 w |
| 22164 | xb 72 193 232 |
| 22165 | if ge t 6 |
| 22166 | a_bput 1 sub get oc 0 1 248 |
| 22167 | end |
| 22168 | emitb uchar sub 64 w |
| 22169 | end |
| 22170 | |
| 22171 | fn xext r ulong t ulong code ulong to void |
| 22172 | xload 0 r |
| 22173 | xrr 137 2 0 |
| 22174 | xcanrax t |
| 22175 | xrr 57 0 2 |
| 22176 | xtrap 1 code |
| 22177 | end |
| 22178 | |
| 22179 | fn xarith op ulong ty ulong a ulong b ulong imm ulong d ulong to void |
| 22180 | if or eq ty 10 eq ty 11 |
| 22181 | if or lt op 33 gt op 35 |
| 22182 | note d2site 581|xarith: type mismatch; condition if or lt op 33 gt op 35 |
| 22183 | put d2site 0 581 |
| 22184 | fail 7 |
| 22185 | end |
| 22186 | if ne imm 0 |
| 22187 | matconst 16 b |
| 22188 | b = ulong 16 |
| 22189 | end |
| 22190 | xfbin op ty a b d |
| 22191 | ret |
| 22192 | end |
| 22193 | xload 0 a |
| 22194 | if ne imm 0 |
| 22195 | ximm 1 b |
| 22196 | else |
| 22197 | xload 1 b |
| 22198 | end |
| 22199 | if eq op 33 |
| 22200 | xrr 1 0 1 |
| 22201 | if eq ty 13 |
| 22202 | xtrap 3 1 |
| 22203 | end |
| 22204 | end |
| 22205 | if eq op 34 |
| 22206 | xrr 41 0 1 |
| 22207 | if eq ty 13 |
| 22208 | xtrap 3 1 |
| 22209 | end |
| 22210 | end |
| 22211 | if eq op 35 |
| 22212 | if eq ty 13 |
| 22213 | xb 72 247 225 |
| 22214 | xrr 133 2 2 |
| 22215 | xtrap 1 1 |
| 22216 | else |
| 22217 | xb 72 15 175 |
| 22218 | emitb 193 |
| 22219 | end |
| 22220 | end |
| 22221 | if eq op 38 |
| 22222 | xrr 33 0 1 |
| 22223 | end |
| 22224 | if eq op 39 |
| 22225 | xrr 9 0 1 |
| 22226 | end |
| 22227 | if eq op 40 |
| 22228 | xrr 49 0 1 |
| 22229 | end |
| 22230 | if and eq ty 9 le op 35 |
| 22231 | xtrap 6 1 |
| 22232 | end |
| 22233 | xstore 0 d |
| 22234 | if le op 35 |
| 22235 | bo_fix d ty |
| 22236 | end |
| 22237 | end |
| 22238 | |
| 22239 | fn xdiv op ulong ty ulong a ulong b ulong d ulong fl ulong to void |
| 22240 | if or eq ty 10 eq ty 11 |
| 22241 | if ne op 36 |
| 22242 | note d2site 582|xdiv: type mismatch; condition if ne op 36 |
| 22243 | put d2site 0 582 |
| 22244 | fail 7 |
| 22245 | end |
| 22246 | xfbin op ty a b d |
| 22247 | ret |
| 22248 | end |
| 22249 | xload 0 a |
| 22250 | xload 1 b |
| 22251 | note Match bo_div's constant-divisor proofs and source trap sites. |
| 22252 | if eq and fl 1 0 |
| 22253 | xrr 133 1 1 |
| 22254 | xtrap 0 2 |
| 22255 | end |
| 22256 | done = ulong 0 |
| 22257 | if and ge ty 6 le ty 9 |
| 22258 | if and eq ty 9 eq and fl 2 0 |
| 22259 | note Only 64-bit IDIV can fault on MIN/-1; remainder must bypass with zero. |
| 22260 | ximm 2 18446744073709551615 |
| 22261 | xrr 57 1 2 |
| 22262 | other = xbranch 1 |
| 22263 | if eq op 37 |
| 22264 | ximm 0 0 |
| 22265 | done = xbranch 14 |
| 22266 | else |
| 22267 | xb 72 247 216 |
| 22268 | xtrap 6 1 |
| 22269 | done = xbranch 14 |
| 22270 | end |
| 22271 | xpatch other get oc 0 |
| 22272 | end |
| 22273 | xb 72 153 144 |
| 22274 | xb 72 247 249 |
| 22275 | else |
| 22276 | xrr 49 2 2 |
| 22277 | xb 72 247 241 |
| 22278 | end |
| 22279 | if eq op 37 |
| 22280 | xrr 137 0 2 |
| 22281 | end |
| 22282 | if ne done 0 |
| 22283 | xpatch done get oc 0 |
| 22284 | end |
| 22285 | xstore 0 d |
| 22286 | note Narrow signed quotients can overflow; remainders and unsigned quotients cannot. |
| 22287 | if and eq op 36 and ge ty 6 lt ty 9 |
| 22288 | bo_fix d ty |
| 22289 | end |
| 22290 | end |
| 22291 | |
| 22292 | fn xshift op ulong ty ulong a ulong b ulong imm ulong d ulong to void |
| 22293 | xload 0 a |
| 22294 | if ne imm 0 |
| 22295 | ximm 1 b |
| 22296 | else |
| 22297 | xload 1 b |
| 22298 | end |
| 22299 | note imm is set only for a statically valid shift amount, as in bo_shl/bo_shr. |
| 22300 | if eq imm 0 |
| 22301 | ximm 2 twid ty |
| 22302 | xrr 57 1 2 |
| 22303 | xtrap 2 7 |
| 22304 | end |
| 22305 | xrr 137 2 0 |
| 22306 | if eq op 41 |
| 22307 | xb 72 211 224 |
| 22308 | if eq ty 9 |
| 22309 | xrr 137 8 0 |
| 22310 | xb 73 211 248 |
| 22311 | xrr 57 8 2 |
| 22312 | xtrap 1 1 |
| 22313 | end |
| 22314 | else |
| 22315 | if ge ty 6 |
| 22316 | xb 72 211 248 |
| 22317 | else |
| 22318 | xb 72 211 232 |
| 22319 | end |
| 22320 | end |
| 22321 | xstore 0 d |
| 22322 | if eq op 41 |
| 22323 | bo_fix d ty |
| 22324 | end |
| 22325 | end |
| 22326 | |
| 22327 | fn xunary op ulong dst ulong to void |
| 22328 | ty = get rt 0 |
| 22329 | if eq ty 13 |
| 22330 | note d2site 583|xunary: type mismatch; condition if eq ty 13 |
| 22331 | put d2site 0 583 |
| 22332 | fail 7 |
| 22333 | end |
| 22334 | if or eq ty 10 eq ty 11 |
| 22335 | if eq op 50 |
| 22336 | note d2site 584|xunary: type mismatch; condition if eq op 50 |
| 22337 | put d2site 0 584 |
| 22338 | fail 7 |
| 22339 | end |
| 22340 | fa = matreg get rk 0 get rv 0 ty |
| 22341 | fd = destreg dst |
| 22342 | note xfneg / xfsqrt / xfabs: the x86 forms of fp_neg / fp_un1 on x registers ra into rd (sign mask, SQRTS). |
| 22343 | xload 0 fa |
| 22344 | ximm 1 xfmask ty 0 |
| 22345 | xrr 49 0 1 |
| 22346 | xstore 0 fd |
| 22347 | put rk 0 1 |
| 22348 | put rv 0 fd |
| 22349 | put rt 0 ty |
| 22350 | ret |
| 22351 | end |
| 22352 | a = matreg get rk 0 get rv 0 ty |
| 22353 | d = destreg dst |
| 22354 | xload 0 a |
| 22355 | if eq op 50 |
| 22356 | if eq ty 1 |
| 22357 | ximm 1 1 |
| 22358 | xrr 49 0 1 |
| 22359 | else |
| 22360 | xb 72 247 208 |
| 22361 | end |
| 22362 | else |
| 22363 | if eq ty 1 |
| 22364 | note d2site 585|xunary: type mismatch; condition if eq ty 1 |
| 22365 | put d2site 0 585 |
| 22366 | fail 7 |
| 22367 | end |
| 22368 | xb 72 247 216 |
| 22369 | if eq ty 9 |
| 22370 | xtrap 6 1 |
| 22371 | end |
| 22372 | end |
| 22373 | xstore 0 d |
| 22374 | if eq op 50 |
| 22375 | canon d ty |
| 22376 | else |
| 22377 | bo_fix d ty |
| 22378 | end |
| 22379 | put rk 0 1 |
| 22380 | put rv 0 d |
| 22381 | put rt 0 ty |
| 22382 | end |
| 22383 | |
| 22384 | fn xconv tt ulong to void |
| 22385 | ft = get rt 0 |
| 22386 | if or or or eq ft 10 eq ft 11 eq tt 10 eq tt 11 |
| 22387 | if or eq ft 13 eq tt 13 |
| 22388 | note d2site 586|xconv: type mismatch; condition if or eq ft 13 eq tt 13 |
| 22389 | put d2site 0 586 |
| 22390 | fail 7 |
| 22391 | end |
| 22392 | if or eq ft 1 eq tt 1 |
| 22393 | note d2site 587|xconv: word or declaration in a place that does not allow it; condition if or eq ft 1 eq tt 1 |
| 22394 | put d2site 0 587 |
| 22395 | fail 9 |
| 22396 | end |
| 22397 | fa = matreg get rk 0 get rv 0 ft |
| 22398 | fd = fp_conv ft tt fa |
| 22399 | put rk 0 1 |
| 22400 | put rv 0 fd |
| 22401 | put rt 0 tt |
| 22402 | ret |
| 22403 | end |
| 22404 | if or eq ft 1 eq tt 1 |
| 22405 | note d2site 588|xconv: word or declaration in a place that does not allow it; condition if or eq ft 1 eq tt 1 |
| 22406 | put d2site 0 588 |
| 22407 | fail 9 |
| 22408 | end |
| 22409 | r = matreg get rk 0 get rv 0 ft |
| 22410 | wf = twid ft |
| 22411 | wt = twid tt |
| 22412 | s = ulong 99 |
| 22413 | if not and ge ft 6 le ft 9 |
| 22414 | if and ge tt 6 le tt 9 |
| 22415 | if ge wf wt |
| 22416 | s = sub wt 1 |
| 22417 | end |
| 22418 | else |
| 22419 | if gt wf wt |
| 22420 | s = wt |
| 22421 | end |
| 22422 | end |
| 22423 | else |
| 22424 | if not and ge tt 6 le tt 9 |
| 22425 | s = wt |
| 22426 | if gt s 63 |
| 22427 | s = ulong 63 |
| 22428 | end |
| 22429 | else |
| 22430 | if gt wf wt |
| 22431 | xext r tt 5 |
| 22432 | end |
| 22433 | end |
| 22434 | end |
| 22435 | if ne s 99 |
| 22436 | xload 0 r |
| 22437 | xb 72 193 232 |
| 22438 | emitb uchar s |
| 22439 | xrr 133 0 0 |
| 22440 | xtrap 1 5 |
| 22441 | end |
| 22442 | put rk 0 1 |
| 22443 | put rv 0 r |
| 22444 | put rt 0 tt |
| 22445 | end |
| 22446 | |
| 22447 | note Reserve checked stack BEFORE stores, CALL return addresses, or PUSH. |
| 22448 | fn xcheck bytes ulong to void |
| 22449 | xmem 141 0 4 sub ulong 0 bytes |
| 22450 | xrr 57 0 15 |
| 22451 | xtrap 3 6 |
| 22452 | end |
| 22453 | |
| 22454 | fn xsp down ulong bytes ulong to void |
| 22455 | if eq bytes 0 |
| 22456 | ret |
| 22457 | end |
| 22458 | if ne down 0 |
| 22459 | xcheck bytes |
| 22460 | xb 72 129 236 |
| 22461 | else |
| 22462 | xb 72 129 196 |
| 22463 | end |
| 22464 | xword bytes |
| 22465 | end |
| 22466 | |
| 22467 | fn xmovsp r ulong to void |
| 22468 | xrr 137 0 4 |
| 22469 | xstore 0 r |
| 22470 | end |
| 22471 | |
| 22472 | fn xpro np ulong to void |
| 22473 | xrr 137 11 5 |
| 22474 | emitb 85 |
| 22475 | xrr 137 5 4 |
| 22476 | xb 72 129 236 |
| 22477 | xword 256 |
| 22478 | j = ulong 0 |
| 22479 | while lt j np |
| 22480 | xmem 139 0 11 sub ulong 0 mul add j 1 8 |
| 22481 | xstore 0 j |
| 22482 | j = add j 1 |
| 22483 | end |
| 22484 | end |
| 22485 | |
| 22486 | |
| 22487 | fn xarg t ulong k ulong v ulong to void |
| 22488 | if eq k 6 |
| 22489 | mataddr t v |
| 22490 | ret |
| 22491 | end |
| 22492 | if or eq k 3 eq k 7 |
| 22493 | matconst t v |
| 22494 | ret |
| 22495 | end |
| 22496 | xmem 139 0 4 mul v 8 |
| 22497 | xstore 0 t |
| 22498 | end |
| 22499 | |
| 22500 | fn xrestore d ulong slot ulong res ulong to ulong |
| 22501 | put nslot 0 slot |
| 22502 | rd = ulong 255 |
| 22503 | if ne res 0 |
| 22504 | rd = destreg d |
| 22505 | xstore 0 rd |
| 22506 | end |
| 22507 | j = ulong 0 |
| 22508 | while lt j 18 |
| 22509 | if ne j rd |
| 22510 | xmem 139 0 4 mul j 8 |
| 22511 | xstore 0 j |
| 22512 | end |
| 22513 | j = add j 1 |
| 22514 | end |
| 22515 | xsp 0 256 |
| 22516 | ret rd |
| 22517 | end |
| 22518 | |
| 22519 | note Typed addresses carry origin through fixup records. Numeric constants never relocate. |
| 22520 | fn mataddr r ulong v ulong to void |
| 22521 | if eq get xtarget 0 0 |
| 22522 | if ne get xefa 0 0 |
| 22523 | note a64efi: the image loads anywhere. A pool address (0x10000000 up) is its offset plus X27, the base of |
| 22524 | note the .bss the entry found; a text address (0x400000 + file offset) is ADRP + ADD from this instruction |
| 22525 | note (C6.2.11, C6.2.5), both as RVAs = file offset + 3584. |
| 22526 | if ge v 268435456 |
| 22527 | matconst r sub v 268435456 |
| 22528 | e3 2332033024 r r 27 |
| 22529 | ret |
| 22530 | end |
| 22531 | t = add sub v 4194304 3584 |
| 22532 | d = and sub shr t 12 shr add get oc 0 3584 12 2097151 |
| 22533 | emit or or or 2415919104 shl and d 3 29 shl shr d 2 5 r |
| 22534 | emit or or or 2432696320 shl and t 4095 10 shl r 5 r |
| 22535 | ret |
| 22536 | end |
| 22537 | matconst r v |
| 22538 | ret |
| 22539 | end |
| 22540 | xaddr 0 v |
| 22541 | xstore 0 r |
| 22542 | end |
| 22543 | |
| 22544 | fn xaddr r ulong v ulong to void |
| 22545 | n = get xnaddr 0 |
| 22546 | if ge n get a_gp 11 |
| 22547 | a_need 11 n |
| 22548 | end |
| 22549 | emitb uchar add 72 shl shr r 3 2 |
| 22550 | emitb 141 |
| 22551 | emitb uchar add 5 shl and r 7 3 |
| 22552 | put a_ar add get a_rb 46 n get oc 0 |
| 22553 | put a_ar add get a_rb 47 n v |
| 22554 | put xnaddr 0 add n 1 |
| 22555 | xword 0 |
| 22556 | end |
| 22557 | |
| 22558 | fn xelem e ulong k ulong v ulong t ulong to void |
| 22559 | if or or eq t 1 eq t 10 eq t 11 |
| 22560 | note d2site 589|xelem: type mismatch; condition if or or eq t 1 eq t 10 eq t 11 |
| 22561 | put d2site 0 589 |
| 22562 | fail 7 |
| 22563 | end |
| 22564 | i = sub e 1 |
| 22565 | if eq get a_ar add get a_rb 6 i 0 |
| 22566 | if eq uchar get a_ar add get a_rb 7 i 10 |
| 22567 | xepool i k v t |
| 22568 | ret |
| 22569 | end |
| 22570 | end |
| 22571 | ln = get a_ar add get a_rb 6 i |
| 22572 | x = v |
| 22573 | if ne unsz i 0 |
| 22574 | x = matreg k v t |
| 22575 | xcmp x ulong uchar get a_ar add get a_rb 14 i 0 |
| 22576 | xtrap 2 3 |
| 22577 | else |
| 22578 | if eq k 3 |
| 22579 | if le ln v |
| 22580 | note d2site 590|xelem: constant index outside the array; condition if le ln v |
| 22581 | put d2site 0 590 |
| 22582 | fail 21 |
| 22583 | end |
| 22584 | if and ne get om2 0 0 le v 4095 |
| 22585 | x = ulong 255 |
| 22586 | put ea_k 0 v |
| 22587 | else |
| 22588 | x = alloc |
| 22589 | matconst x v |
| 22590 | end |
| 22591 | else |
| 22592 | xcmp v ln 1 |
| 22593 | xtrap 2 3 |
| 22594 | end |
| 22595 | end |
| 22596 | put ea_i 0 x |
| 22597 | note A global's base is not held in an operand slot: ea_b 254 tells xbase to LEA it into RDX at the access |
| 22598 | note itself (xaddr), which follows elemaddr directly in every x86 caller (vt_get, stel), so OM-2 units whose |
| 22599 | note AArch64 form pins globals keep their operand budget on x86 too. |
| 22600 | if ge uchar get a_ar add get a_rb 7 i 4 |
| 22601 | put xea_g 0 get a_ar add get a_rb 8 i |
| 22602 | put ea_b 0 254 |
| 22603 | else |
| 22604 | put ea_b 0 ulong a_gu 4 i |
| 22605 | end |
| 22606 | end |
| 22607 | |
| 22608 | note xepool: the element address of run-time pool i (docs/RUNTIME-POOLS.md s4) on x86linux for index (k, v, t). |
| 22609 | note The slot is read here, after every operand of the access (soundness rule B1): RCX = index, LEA RDX, |
| 22610 | note [RIP + slot], MOV RAX, [RDX + 8] (length), MOV RDX, [RDX] (base), CMP RCX, RAX (39 /r), JAE trap 3, so |
| 22611 | note a negative signed index traps as a large unsigned one. The base goes to a new operand slot; a number |
| 22612 | note index is checked at run time too (no error 21, no check elimination). |
| 22613 | fn xepool i ulong k ulong v ulong t ulong to void |
| 22614 | x = matreg k v t |
| 22615 | b = alloc |
| 22616 | xload 1 x |
| 22617 | xaddr 2 get a_ar add get a_rb 8 i |
| 22618 | xmem 139 0 2 8 |
| 22619 | xmem 139 2 2 0 |
| 22620 | xrr 57 1 0 |
| 22621 | note POOLMUT-ALT x86cmp note removed |
| 22622 | note POOLMUT x86cmp |
| 22623 | xtrap 2 3 |
| 22624 | xstore 2 b |
| 22625 | put ea_i 0 x |
| 22626 | put ea_b 0 b |
| 22627 | end |
| 22628 | |
| 22629 | note xenlarge: r = enlarge P n on x86linux (docs/RUNTIME-POOLS.md s3, s4), emitted inline at each site, so it |
| 22630 | note needs no call frame. In: p the pool's name (index + 1), whose slot address a holds (base, length) and |
| 22631 | note s log2 of its element size, nv n's operand |
| 22632 | note slot. Out: RAX = 0, -22 when n << s reaches 2^63, or the host's -errno; the slot changes only on success. |
| 22633 | note Intel SDM vol 2: MOV 8B/89 /r, LEA 8D /r, CMP 39 /r and REX.W 3D id, TEST 85 /r, SHL/SHR C1 /4 /5 ib, |
| 22634 | note ADD/AND 81 /0 /4 id, MOV B8+r io, Jcc 0F 8x cd, JMP E9 cd, SYSCALL 0F 05. Linux x86-64: mmap 9 (RDI 0, |
| 22635 | note RSI bytes, RDX PROT_READ|PROT_WRITE 3, R10 MAP_PRIVATE|MAP_ANONYMOUS 0x22, R8 -1, R9 0), mremap 25 |
| 22636 | note (RDI old base, RSI old bytes, RDX new bytes, R10 MREMAP_MAYMOVE 1). SYSCALL clobbers RCX and R11 only. |
| 22637 | note Language values live in RBP slots, so only RAX, RCX, RDX, RSI, RDI, R8..R11 change here. |
| 22638 | fn xenlarge p ulong nv ulong to void |
| 22639 | a = get a_ar add get a_rb 8 sub p 1 |
| 22640 | s = tlog ulong uchar get a_ar add get a_rb 5 sub p 1 |
| 22641 | note RSI = n, RDI = slot, RAX = length; n <= length: nothing changes (JBE) |
| 22642 | xload 6 nv |
| 22643 | xaddr 7 a |
| 22644 | xmem 139 0 7 8 |
| 22645 | xrr 57 6 0 |
| 22646 | note POOLMUT-ALT x86belowlen sm = xbranch 0 |
| 22647 | note POOLMUT x86belowlen |
| 22648 | sm = xbranch 9 |
| 22649 | note RDX = n >> (63 - s): nonzero means n << s reaches 2^63 (JNE to -22) |
| 22650 | xrr 137 2 6 |
| 22651 | xb 72 193 234 |
| 22652 | emitb uchar sub 63 s |
| 22653 | xrr 133 2 2 |
| 22654 | note POOLMUT-ALT x86ovf ov = xbranch 0 |
| 22655 | note POOLMUT x86ovf |
| 22656 | ov = xbranch 1 |
| 22657 | note RDX = new bytes, RSI = old bytes, each rounded up to the 4096-byte page |
| 22658 | xrr 137 2 6 |
| 22659 | xb 72 193 226 |
| 22660 | emitb uchar s |
| 22661 | xb 72 129 194 |
| 22662 | xword 4095 |
| 22663 | xb 72 129 226 |
| 22664 | xword 4294963200 |
| 22665 | xrr 137 6 0 |
| 22666 | xb 72 193 230 |
| 22667 | emitb uchar s |
| 22668 | xb 72 129 198 |
| 22669 | xword 4095 |
| 22670 | xb 72 129 230 |
| 22671 | xword 4294963200 |
| 22672 | note within the pages already mapped (JBE): store only the length; they are still zero |
| 22673 | xrr 57 2 6 |
| 22674 | ft = xbranch 9 |
| 22675 | note length 0: mmap; else mremap |
| 22676 | xrr 133 0 0 |
| 22677 | rm = xbranch 1 |
| 22678 | ximm 7 0 |
| 22679 | xrr 137 6 2 |
| 22680 | ximm 2 3 |
| 22681 | ximm 10 34 |
| 22682 | ximm 8 18446744073709551615 |
| 22683 | ximm 9 0 |
| 22684 | ximm 0 9 |
| 22685 | emitb 15 |
| 22686 | emitb 5 |
| 22687 | cl = xbranch 14 |
| 22688 | xpatch rm get oc 0 |
| 22689 | xmem 139 7 7 0 |
| 22690 | ximm 10 1 |
| 22691 | ximm 0 25 |
| 22692 | emitb 15 |
| 22693 | emitb 5 |
| 22694 | xpatch cl get oc 0 |
| 22695 | note RAX in -4095..-1 (CMP RAX, -4095; JAE): the host refused, RAX is the result, the slot is untouched |
| 22696 | emitb 72 |
| 22697 | emitb 61 |
| 22698 | xword 4294963201 |
| 22699 | note POOLMUT-ALT x86slotfail hf = xbranch 3 |
| 22700 | note POOLMUT x86slotfail |
| 22701 | hf = xbranch 2 |
| 22702 | xaddr 7 a |
| 22703 | note POOLMUT-ALT x86base note removed |
| 22704 | note POOLMUT x86base |
| 22705 | xmem 137 0 7 0 |
| 22706 | xpatch ft get oc 0 |
| 22707 | xload 0 nv |
| 22708 | xmem 137 0 7 8 |
| 22709 | xpatch sm get oc 0 |
| 22710 | ximm 0 0 |
| 22711 | dn = xbranch 14 |
| 22712 | xpatch ov get oc 0 |
| 22713 | ximm 0 18446744073709551594 |
| 22714 | xpatch dn get oc 0 |
| 22715 | xpatch hf get oc 0 |
| 22716 | end |
| 22717 | |
| 22718 | note xbase: RDX = the base of the element access: the global address xea_g when base is 254 (LEA RDX, |
| 22719 | note [RIP + disp32], SDM vol 2 LEA, with an xaddr fixup), else the operand slot base (MOV RDX, [RBP - ...]). |
| 22720 | fn xbase base ulong to void |
| 22721 | if eq base 254 |
| 22722 | xaddr 2 get xea_g 0 |
| 22723 | ret |
| 22724 | end |
| 22725 | xload 2 base |
| 22726 | end |
| 22727 | |
| 22728 | note Indexed load/store uses RDX=base+index*element-size; pointers never enter source scalars. |
| 22729 | fn xmemval store ulong base ulong idx ulong ty ulong val ulong to void |
| 22730 | xbase base |
| 22731 | if eq idx 255 |
| 22732 | ximm 1 get ea_k 0 |
| 22733 | else |
| 22734 | xload 1 idx |
| 22735 | end |
| 22736 | xb 72 193 225 |
| 22737 | emitb uchar tlog ty |
| 22738 | xrr 1 2 1 |
| 22739 | xmemraw store ty val |
| 22740 | end |
| 22741 | |
| 22742 | note RDX is a checked aggregate address; layout byte offsets do not scale by the field width. |
| 22743 | fn xlayout store ulong base ulong idx ulong ty ulong val ulong to void |
| 22744 | xbase base |
| 22745 | xload 1 idx |
| 22746 | xrr 1 2 1 |
| 22747 | xmemraw store ty val |
| 22748 | end |
| 22749 | |
| 22750 | fn xmemraw store ulong ty ulong val ulong to void |
| 22751 | if ne store 0 |
| 22752 | xload 0 val |
| 22753 | if eq twid ty 16 |
| 22754 | emitb 102 |
| 22755 | end |
| 22756 | if eq twid ty 64 |
| 22757 | emitb 72 |
| 22758 | end |
| 22759 | if le twid ty 8 |
| 22760 | emitb 136 |
| 22761 | else |
| 22762 | emitb 137 |
| 22763 | end |
| 22764 | emitb 2 |
| 22765 | else |
| 22766 | if eq twid ty 64 |
| 22767 | xb 72 139 2 |
| 22768 | else |
| 22769 | if eq twid ty 32 |
| 22770 | if and ge ty 6 le ty 9 |
| 22771 | xb 72 99 2 |
| 22772 | else |
| 22773 | emitb 139 |
| 22774 | emitb 2 |
| 22775 | end |
| 22776 | else |
| 22777 | emitb 72 |
| 22778 | emitb 15 |
| 22779 | op = ulong 182 |
| 22780 | if eq twid ty 16 |
| 22781 | op = ulong 183 |
| 22782 | end |
| 22783 | if and ge ty 6 le ty 9 |
| 22784 | op = add op 8 |
| 22785 | end |
| 22786 | emitb uchar op |
| 22787 | emitb 2 |
| 22788 | end |
| 22789 | end |
| 22790 | xstore 0 val |
| 22791 | end |
| 22792 | end |
| 22793 | |
| 22794 | fn xio c ulong fk ulong fv ulong e ulong ro ulong rn ulong to void |
| 22795 | if ne get xtarget 0 1 |
| 22796 | note d2site 591|xio: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if ne get xtarget 0 1 |
| 22797 | put d2site 0 591 |
| 22798 | fail 25 |
| 22799 | end |
| 22800 | save |
| 22801 | i = sub e 1 |
| 22802 | if eq uchar get a_ar add get a_rb 7 i 10 |
| 22803 | note pool: RSI = the base word of its slot, loaded after every operand (soundness rule B1) |
| 22804 | xaddr 6 get a_ar add get a_rb 8 i |
| 22805 | xmem 139 6 6 0 |
| 22806 | else |
| 22807 | if ge uchar get a_ar add get a_rb 7 i 4 |
| 22808 | xaddr 6 get a_ar add get a_rb 8 i |
| 22809 | else |
| 22810 | xload 6 ulong uchar get a_ar add get a_rb 4 i |
| 22811 | end |
| 22812 | end |
| 22813 | xmem 139 0 4 mul ro 8 |
| 22814 | xrr 1 6 0 |
| 22815 | if eq fk 3 |
| 22816 | ximm 7 fv |
| 22817 | else |
| 22818 | xmem 139 7 4 mul fv 8 |
| 22819 | end |
| 22820 | xmem 139 2 4 mul rn 8 |
| 22821 | ximm 0 sub c 53 |
| 22822 | emitb 15 |
| 22823 | emitb 5 |
| 22824 | end |
| 22825 | |
| 22826 | fn xarray w ulong to void |
| 22827 | if ne get nb 0 0 |
| 22828 | note d2site 592|xarray: word or declaration in a place that does not allow it; condition if ne get nb 0 0 |
| 22829 | put d2site 0 592 |
| 22830 | fail 9 |
| 22831 | end |
| 22832 | t = typeword |
| 22833 | elemtype t |
| 22834 | n = lenval 16 |
| 22835 | arrlen n |
| 22836 | by = shl shr add shl n tlog t 15 4 4 |
| 22837 | if gt add get stkbytes 0 by 4194304 |
| 22838 | note d2site 593|xarray: size capacity; condition if gt add get stkbytes 0 by 4194304 |
| 22839 | put d2site 0 593 |
| 22840 | fail 23 |
| 22841 | end |
| 22842 | put stkbytes 0 add get stkbytes 0 by |
| 22843 | r = alloc |
| 22844 | put held 0 get nslot 0 |
| 22845 | rdval 0 t 255 0 |
| 22846 | if ne get rt 0 t |
| 22847 | note d2site 594|xarray: type mismatch; condition if ne get rt 0 t |
| 22848 | put d2site 0 594 |
| 22849 | fail 7 |
| 22850 | end |
| 22851 | v = matreg get rk 0 get rv 0 t |
| 22852 | xsp 1 by |
| 22853 | xmovsp r |
| 22854 | i = alloc |
| 22855 | matconst i 0 |
| 22856 | lp = get oc 0 |
| 22857 | xmemval 1 r i t v |
| 22858 | xarith 33 5 i 1 1 i |
| 22859 | xcmp i n 1 |
| 22860 | blo lp |
| 22861 | addname w r t n 1 0 |
| 22862 | end |
| 22863 | |
| 22864 | note xfornum / xforval: the x86 sf_num / sf_val. bn and n come from sf_num / sf_val, which parse the bound |
| 22865 | note themselves (sf_val: 1000000 when no bound is written); bn = 0 leaves a number count unguarded, as on Arm. |
| 22866 | fn xfornum w ulong t ulong k ulong sn ulong sh ulong bn ulong to void |
| 22867 | eol |
| 22868 | i = alloc |
| 22869 | put held 0 get nslot 0 |
| 22870 | addname w i t 0 0 0 |
| 22871 | matconst i 0 |
| 22872 | c = ulong 0 |
| 22873 | if ne bn 0 |
| 22874 | c = alloc |
| 22875 | put held 0 get nslot 0 |
| 22876 | matconst c 0 |
| 22877 | end |
| 22878 | hd = get oc 0 |
| 22879 | cp_head get cur 0 get line 0 |
| 22880 | xcmp i k 1 |
| 22881 | br = sf_br t |
| 22882 | if ne bn 0 |
| 22883 | lpcnt c bn |
| 22884 | end |
| 22885 | pushb br 4 hd i t |
| 22886 | pushnh sn sh |
| 22887 | cp_skip |
| 22888 | end |
| 22889 | |
| 22890 | fn xforval w ulong t ulong kr ulong sn ulong sh ulong n ulong to void |
| 22891 | eol |
| 22892 | i = alloc |
| 22893 | put held 0 get nslot 0 |
| 22894 | addname w i t 0 0 0 |
| 22895 | matconst i 0 |
| 22896 | c = alloc |
| 22897 | put held 0 get nslot 0 |
| 22898 | matconst c 0 |
| 22899 | hd = get oc 0 |
| 22900 | cp_head get cur 0 get line 0 |
| 22901 | xcmp i kr 0 |
| 22902 | br = sf_br t |
| 22903 | lpcnt c n |
| 22904 | pushb br 4 hd i t |
| 22905 | pushnh sn sh |
| 22906 | cp_skip |
| 22907 | end |
| 22908 | |
| 22909 | fn xleave to void |
| 22910 | if eq get xtarget 0 2 |
| 22911 | note UEFI: every exit jumps to the shared firmware return emitted by xefx 1; RAX is the status. |
| 22912 | n = get xnexit 0 |
| 22913 | if ge n get a_gp 12 |
| 22914 | a_need 12 n |
| 22915 | end |
| 22916 | put a_ar add get a_rb 48 n xbranch 14 |
| 22917 | put xnexit 0 add n 1 |
| 22918 | ret |
| 22919 | end |
| 22920 | xrr 137 7 0 |
| 22921 | ximm 0 60 |
| 22922 | emitb 15 |
| 22923 | emitb 5 |
| 22924 | end |
| 22925 | |
| 22926 | fn xfinish to void |
| 22927 | eol |
| 22928 | if eq get dead 0 0 |
| 22929 | if ne get curret 0 12 |
| 22930 | note d2site 595|xfinish: a function with a result can reach its end; condition if ne get curret 0 12 |
| 22931 | put d2site 0 595 |
| 22932 | fail 18 |
| 22933 | end |
| 22934 | cp_post 0 0 12 |
| 22935 | epi |
| 22936 | end |
| 22937 | j = ulong 0 |
| 22938 | n = get nt 0 |
| 22939 | go = true |
| 22940 | while go |
| 22941 | m = ulong 0 |
| 22942 | while and go lt m 999999 |
| 22943 | if ge j n |
| 22944 | go = false |
| 22945 | else |
| 22946 | xpatch get a_ar add get a_rb 44 j get oc 0 |
| 22947 | if eq get progmode 0 0 |
| 22948 | note Bare units reserve physical R12/R14: recovery stack and immutable runtime table. |
| 22949 | note Host helpers clobber these registers and must remain forbidden in bare units. |
| 22950 | emitb 190 |
| 22951 | xword get a_ar add get a_rb 45 j |
| 22952 | xb 65 255 102 |
| 22953 | emitb 16 |
| 22954 | else |
| 22955 | if eq get xtarget 0 2 |
| 22956 | ximm 0 or 9223372036854775808 add 100 a_g 45 j |
| 22957 | else |
| 22958 | ximm 0 add 100 get a_ar add get a_rb 45 j |
| 22959 | end |
| 22960 | xleave |
| 22961 | end |
| 22962 | j = add j 1 |
| 22963 | end |
| 22964 | m = add m 1 |
| 22965 | end |
| 22966 | end |
| 22967 | put curret 0 0 |
| 22968 | nm_set get nglob 0 |
| 22969 | put curfn 0 0 |
| 22970 | put nbrk 0 0 |
| 22971 | put ncont 0 0 |
| 22972 | end |
| 22973 | |
| 22974 | fn xlead to void |
| 22975 | note Only the exact bytes "target " at offset zero select x86. Default parsing is untouched. |
| 22976 | if lt get inlen 0 8 |
| 22977 | ret |
| 22978 | end |
| 22979 | if or ne a_ib 0 116 ne a_ib 1 97 |
| 22980 | ret |
| 22981 | end |
| 22982 | if or ne a_ib 2 114 ne a_ib 3 103 |
| 22983 | ret |
| 22984 | end |
| 22985 | if or ne a_ib 4 101 ne a_ib 5 116 |
| 22986 | ret |
| 22987 | end |
| 22988 | if ne uchar and shr get a_ar 0 48 255 32 |
| 22989 | ret |
| 22990 | end |
| 22991 | put cur 0 0 |
| 22992 | put line 0 1 |
| 22993 | tok |
| 22994 | tok |
| 22995 | if and eq get tw 0 8679965255892613240 eq get tl 0 8 |
| 22996 | put xtarget 0 1 |
| 22997 | else |
| 22998 | if and eq get tw 0 115888505632888 eq get tl 0 6 |
| 22999 | put xtarget 0 2 |
| 23000 | else |
| 23001 | if and eq get tw 0 115888505501281 eq get tl 0 6 |
| 23002 | put xefa 0 1 |
| 23003 | else |
| 23004 | note d2site 596|xlead: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition otherwise: if and eq get tw 0 115888505501281 eq get tl 0 6 |
| 23005 | put d2site 0 596 |
| 23006 | fail 25 |
| 23007 | end |
| 23008 | end |
| 23009 | end |
| 23010 | eol |
| 23011 | p = ulong 0 |
| 23012 | while lt p get cur 0 |
| 23013 | if ne uchar and shr get a_ar shr p 3 shl and p 7 3 255 10 |
| 23014 | a_bput 0 p 32 |
| 23015 | end |
| 23016 | p = add p 1 |
| 23017 | end |
| 23018 | put cur 0 0 |
| 23019 | put line 0 1 |
| 23020 | end |
| 23021 | |
| 23022 | |
| 23023 | fn xeof to void |
| 23024 | f = findfn 1852399981 4 0 |
| 23025 | if eq f 0 |
| 23026 | note d2site 597|xeof: syntax: unknown or misplaced word; condition if eq f 0 |
| 23027 | put d2site 0 597 |
| 23028 | fail 16 |
| 23029 | end |
| 23030 | if ne uchar get a_ar add get a_rb 24 sub f 1 0 |
| 23031 | note d2site 598|xeof: word or declaration in a place that does not allow it; condition if ne uchar get a_ar add get a_rb 24 sub f 1 0 |
| 23032 | put d2site 0 598 |
| 23033 | fail 9 |
| 23034 | end |
| 23035 | entry = get oc 0 |
| 23036 | efi = eq get xtarget 0 2 |
| 23037 | if efi |
| 23038 | xefx 0 0 |
| 23039 | else |
| 23040 | xrr 137 13 4 |
| 23041 | ximm 15 268435456 |
| 23042 | ximm 4 276824064 |
| 23043 | ximm 5 0 |
| 23044 | end |
| 23045 | emitb 232 |
| 23046 | p = get oc 0 |
| 23047 | xword sub get a_ar add get a_rb 22 sub f 1 add p 4 |
| 23048 | if eq uchar get a_ar add get a_rb 23 sub f 1 12 |
| 23049 | ximm 0 0 |
| 23050 | end |
| 23051 | xleave |
| 23052 | if efi |
| 23053 | xefx 1 0 |
| 23054 | xefx 2 entry |
| 23055 | else |
| 23056 | elfhdr |
| 23057 | wrword 16 4063234 |
| 23058 | wrword 24 add 4194304 entry |
| 23059 | wrword 96 get oc 0 |
| 23060 | wrword 104 get oc 0 |
| 23061 | wrword 160 add get poolb 0 8388608 |
| 23062 | end |
| 23063 | i = ulong 0 |
| 23064 | go = true |
| 23065 | while go |
| 23066 | m = ulong 0 |
| 23067 | while and go lt m 999999 |
| 23068 | if ge i get xnaddr 0 |
| 23069 | go = false |
| 23070 | else |
| 23071 | p = get a_ar add get a_rb 46 i |
| 23072 | v = get a_ar add get a_rb 47 i |
| 23073 | if efi |
| 23074 | note PE: code RVA = file offset + 3584; static data lives in the bss section at xbss. |
| 23075 | if ge v 268435456 |
| 23076 | v = add get xbss 0 sub v 268435456 |
| 23077 | else |
| 23078 | v = add sub v 4194304 3584 |
| 23079 | end |
| 23080 | p = add p 3584 |
| 23081 | else |
| 23082 | v = sub v 4194304 |
| 23083 | end |
| 23084 | wrword a_g 46 i sub v add p 4 |
| 23085 | i = add i 1 |
| 23086 | end |
| 23087 | m = add m 1 |
| 23088 | end |
| 23089 | end |
| 23090 | writeout 0 |
| 23091 | end |
| 23092 | |
| 23093 | note ======== x86efi: UEFI 2.10 PE32+ application (docs/X86-EFI.md) ======== |
| 23094 | note efi OP ARG A OFF N -> ulong EFI_STATUS or result. OP is a literal 0..14; A is writable uchar |
| 23095 | note storage, bounds checked before any firmware call; ARG is never a pointer. Errors are 2^63|code. |
| 23096 | note Private state occupies the first 16 KiB of the PE .bss, below the owned 8 MiB stack. Firmware is |
| 23097 | note called per UEFI 2.3.4.2: RCX/RDX/R8/R9, 32-byte home area, an 80-byte 16-aligned reservation. |
| 23098 | note Language values stay in RBP slots, so integers and floats survive every firmware call. |
| 23099 | note Port of the Allen x86efi fork (operations 0..11) onto main's backend; 12, 13 and 14 are new. |
| 23100 | |
| 23101 | note xp k: 0 LEA r,private+off; 1 load r from private+off; 2 store r to private+off (via R10); |
| 23102 | note 3 call BootServices+off (R11); 4 call method off of the protocol held in private slot r (RCX = This). |
| 23103 | fn xp k ulong r ulong off ulong to void |
| 23104 | if eq k 0 |
| 23105 | xaddr r add 268435456 off |
| 23106 | ret |
| 23107 | end |
| 23108 | if eq k 1 |
| 23109 | xaddr r add 268435456 off |
| 23110 | xmem 139 r r 0 |
| 23111 | ret |
| 23112 | end |
| 23113 | if eq k 2 |
| 23114 | xaddr 10 add 268435456 off |
| 23115 | xmem 137 r 10 0 |
| 23116 | ret |
| 23117 | end |
| 23118 | if eq k 3 |
| 23119 | xaddr 11 268435456 |
| 23120 | xmem 139 11 11 0 |
| 23121 | xmem 139 11 11 96 |
| 23122 | xmem 139 11 11 off |
| 23123 | xb 65 255 211 |
| 23124 | ret |
| 23125 | end |
| 23126 | xaddr 1 add 268435456 r |
| 23127 | xmem 139 1 1 0 |
| 23128 | xmem 139 11 1 off |
| 23129 | xb 65 255 211 |
| 23130 | end |
| 23131 | |
| 23132 | note xer k: 0 branch on cc to an error tail that returns 2^63|code; 1 jump to the operation's end; |
| 23133 | note 2 RDTSC into RAX (Intel SDM: LFENCE before and after serializes local instruction execution). |
| 23134 | fn xer k ulong cc ulong code ulong to void |
| 23135 | if eq k 2 |
| 23136 | xb 15 174 232 |
| 23137 | emitb 15 |
| 23138 | emitb 49 |
| 23139 | xb 15 174 232 |
| 23140 | xb 72 193 226 |
| 23141 | emitb 32 |
| 23142 | xrr 9 0 2 |
| 23143 | ret |
| 23144 | end |
| 23145 | if eq k 0 |
| 23146 | n = get xenerr 0 |
| 23147 | if ge n 256 |
| 23148 | note d2site 599|xer: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge n 256 |
| 23149 | put d2site 0 599 |
| 23150 | fail 14 |
| 23151 | end |
| 23152 | put xerrpos n xbranch cc |
| 23153 | put xerrcode n code |
| 23154 | put xenerr 0 add n 1 |
| 23155 | ret |
| 23156 | end |
| 23157 | m = get xenend 0 |
| 23158 | if ge m 256 |
| 23159 | note d2site 600|xer: capacity exceeded (the host refused to grow the compiler's arena or its memory ceiling OMC_MEMORY_MAX was reached, value nesting past omc's own stack, the program image, or an OM-2 expansion bound); condition if ge m 256 |
| 23160 | put d2site 0 600 |
| 23161 | fail 14 |
| 23162 | end |
| 23163 | put xendpos m xbranch 14 |
| 23164 | put xenend 0 add m 1 |
| 23165 | end |
| 23166 | |
| 23167 | note xg k: inline constant data skipped by a jump; returns its address for xaddr. k 0..7 a UEFI GUID |
| 23168 | note packed Data1|Data2<<32|Data3<<48 then Data4 little-endian (0 GOP, 1 SNP, 2 RNG, 3 simple pointer, |
| 23169 | note 4 absolute pointer, 5 Simple File System, 6 LoadedImage, 7 FileInfo, 9 SMBIOS3 table, 10 SMBIOS |
| 23170 | note table); 8 UCS-2 \EFI\BOOT\BOOTX64.EFI. |
| 23171 | fn xg k ulong to ulong |
| 23172 | br = xbranch 14 |
| 23173 | p = get oc 0 |
| 23174 | if eq k 8 |
| 23175 | xb 92 0 69 |
| 23176 | xb 0 70 0 |
| 23177 | xb 73 0 92 |
| 23178 | xb 0 66 0 |
| 23179 | xb 79 0 79 |
| 23180 | xb 0 84 0 |
| 23181 | xb 92 0 66 |
| 23182 | xb 0 79 0 |
| 23183 | xb 79 0 84 |
| 23184 | xb 0 88 0 |
| 23185 | xb 54 0 52 |
| 23186 | xb 0 46 0 |
| 23187 | xb 69 0 70 |
| 23188 | xb 0 73 0 |
| 23189 | emitb 0 |
| 23190 | emitb 0 |
| 23191 | else |
| 23192 | a = ulong 5348063987722529246 |
| 23193 | b = ulong 7661046075708078998 |
| 23194 | if eq k 1 |
| 23195 | a = ulong 1284559596355596985 |
| 23196 | b = ulong 5602828850577812890 |
| 23197 | end |
| 23198 | if eq k 2 |
| 23199 | a = ulong 4845287014151666853 |
| 23200 | b = ulong 4908688144209030790 |
| 23201 | end |
| 23202 | if eq k 3 |
| 23203 | a = ulong 1284945866654190727 |
| 23204 | b = ulong 5602828850577821594 |
| 23205 | end |
| 23206 | if eq k 4 |
| 23207 | a = ulong 5398063699126244139 |
| 23208 | b = ulong 4839848993530975643 |
| 23209 | end |
| 23210 | if eq k 5 |
| 23211 | a = ulong 1284199179690597154 |
| 23212 | b = ulong 4283602510276475278 |
| 23213 | end |
| 23214 | if eq k 6 |
| 23215 | a = ulong 1284253093421855137 |
| 23216 | b = ulong 4283602510276476814 |
| 23217 | end |
| 23218 | if eq k 7 |
| 23219 | a = ulong 1284208961261104786 |
| 23220 | b = ulong 4283602510276475278 |
| 23221 | end |
| 23222 | if eq k 9 |
| 23223 | a = ulong 5344813523769562436 |
| 23224 | b = ulong 10728454813909331609 |
| 23225 | end |
| 23226 | if eq k 10 |
| 23227 | a = ulong 1284420384822471985 |
| 23228 | b = ulong 5602828850577807002 |
| 23229 | end |
| 23230 | xword a |
| 23231 | xword shr a 32 |
| 23232 | xword b |
| 23233 | xword shr b 32 |
| 23234 | end |
| 23235 | xpatch br get oc 0 |
| 23236 | ret add p 4194304 |
| 23237 | end |
| 23238 | |
| 23239 | note xe k: 2 close the operation (error tails, then the shared end); 3 need N >= a (5); 4 need the |
| 23240 | note protocol in private slot a (3); 5 leave on a firmware error; 7 OR a into the info flags at A+4; |
| 23241 | note 8 LocateProtocol GUID a into slot b; 9 calibrate TSC ticks/ms over a 100 ms Stall (176, base 168); |
| 23242 | note 10 settle the transmit buffer at exit (status 88); 12 elapsed milliseconds into A. |
| 23243 | fn xe k ulong a ulong b ulong to void |
| 23244 | if eq k 2 |
| 23245 | xer 1 0 0 |
| 23246 | j = ulong 0 |
| 23247 | while lt j get xenerr 0 |
| 23248 | xpatch get xerrpos j get oc 0 |
| 23249 | ximm 0 or 9223372036854775808 get xerrcode j |
| 23250 | xer 1 0 0 |
| 23251 | j = add j 1 |
| 23252 | end |
| 23253 | i = ulong 0 |
| 23254 | while lt i get xenend 0 |
| 23255 | xpatch get xendpos i get oc 0 |
| 23256 | i = add i 1 |
| 23257 | end |
| 23258 | ret |
| 23259 | end |
| 23260 | if eq k 3 |
| 23261 | ximm 0 a |
| 23262 | xrr 57 13 0 |
| 23263 | xer 0 3 5 |
| 23264 | ret |
| 23265 | end |
| 23266 | if eq k 4 |
| 23267 | xp 1 1 a |
| 23268 | xrr 133 1 1 |
| 23269 | xer 0 0 3 |
| 23270 | ret |
| 23271 | end |
| 23272 | if eq k 5 |
| 23273 | xrr 133 0 0 |
| 23274 | ok = xbranch 0 |
| 23275 | xleave |
| 23276 | xpatch ok get oc 0 |
| 23277 | ret |
| 23278 | end |
| 23279 | if eq k 7 |
| 23280 | xhraw 0 12 4 4 |
| 23281 | ximm 2 a |
| 23282 | xrr 9 0 2 |
| 23283 | xhput 0 12 4 4 |
| 23284 | ret |
| 23285 | end |
| 23286 | if eq k 8 |
| 23287 | g = xg a |
| 23288 | xaddr 1 g |
| 23289 | ximm 2 0 |
| 23290 | xp 0 8 b |
| 23291 | xp 3 0 320 |
| 23292 | note LocateProtocol is optional. Failed output is discarded, never dereferenced. |
| 23293 | xrr 133 0 0 |
| 23294 | ok8 = xbranch 0 |
| 23295 | ximm 0 0 |
| 23296 | xp 2 0 b |
| 23297 | xpatch ok8 get oc 0 |
| 23298 | ret |
| 23299 | end |
| 23300 | if eq k 9 |
| 23301 | xer 2 0 0 |
| 23302 | xp 2 0 160 |
| 23303 | ximm 1 100000 |
| 23304 | xp 3 0 248 |
| 23305 | xrr 133 0 0 |
| 23306 | ok9 = xbranch 0 |
| 23307 | xleave |
| 23308 | xpatch ok9 get oc 0 |
| 23309 | xer 2 0 0 |
| 23310 | xp 1 1 160 |
| 23311 | xrr 41 0 1 |
| 23312 | mono = xbranch 3 |
| 23313 | ximm 1 100 |
| 23314 | ximm 2 0 |
| 23315 | xb 72 247 241 |
| 23316 | xp 2 0 176 |
| 23317 | xer 2 0 0 |
| 23318 | xp 2 0 168 |
| 23319 | xpatch mono get oc 0 |
| 23320 | ret |
| 23321 | end |
| 23322 | if eq k 10 |
| 23323 | xp 1 1 96 |
| 23324 | xrr 133 1 1 |
| 23325 | none = xbranch 0 |
| 23326 | xp 1 0 72 |
| 23327 | xrr 133 0 0 |
| 23328 | idle = xbranch 0 |
| 23329 | ximm 0 0 |
| 23330 | xp 2 0 80 |
| 23331 | ximm 2 0 |
| 23332 | xp 0 8 80 |
| 23333 | xp 4 24 88 |
| 23334 | xp 1 0 80 |
| 23335 | xp 1 2 96 |
| 23336 | xrr 57 0 2 |
| 23337 | busy = xbranch 1 |
| 23338 | xpatch idle get oc 0 |
| 23339 | xp 1 1 96 |
| 23340 | xp 3 0 72 |
| 23341 | xrr 133 0 0 |
| 23342 | freed = xbranch 0 |
| 23343 | xp 2 0 88 |
| 23344 | xpatch freed get oc 0 |
| 23345 | fin = xbranch 14 |
| 23346 | xpatch busy get oc 0 |
| 23347 | note Do not free or reuse an unreturned DMA buffer. Expose NOT_READY on exit. |
| 23348 | ximm 0 9223372036854775814 |
| 23349 | xp 2 0 88 |
| 23350 | xpatch fin get oc 0 |
| 23351 | xpatch none get oc 0 |
| 23352 | ret |
| 23353 | end |
| 23354 | xp 1 1 176 |
| 23355 | xrr 133 1 1 |
| 23356 | xer 0 0 3 |
| 23357 | xer 2 0 0 |
| 23358 | xp 1 2 168 |
| 23359 | xrr 41 0 2 |
| 23360 | xer 0 3 3 |
| 23361 | ximm 2 0 |
| 23362 | xb 72 247 241 |
| 23363 | xmem 137 0 12 0 |
| 23364 | ximm 0 0 |
| 23365 | end |
| 23366 | |
| 23367 | note xefx k: 0 image entry, 1 the shared firmware return (every exit site lands here), 2 PE32+ headers. |
| 23368 | fn xefx k ulong a ulong to void |
| 23369 | if eq k 0 |
| 23370 | note Preserve the integer nonvolatiles, MXCSR and XMM6-15 (UEFI 2.3.4.2), then install the owned stack. |
| 23371 | emitb 83 |
| 23372 | emitb 85 |
| 23373 | emitb 86 |
| 23374 | emitb 87 |
| 23375 | xb 65 84 65 |
| 23376 | emitb 85 |
| 23377 | xb 65 86 65 |
| 23378 | emitb 87 |
| 23379 | xp 2 4 2048 |
| 23380 | xp 2 1 8 |
| 23381 | xp 2 2 0 |
| 23382 | xp 0 10 2056 |
| 23383 | xb 65 15 174 |
| 23384 | emitb 26 |
| 23385 | xp 0 10 2080 |
| 23386 | j = ulong 6 |
| 23387 | while lt j 16 |
| 23388 | emitb 243 |
| 23389 | emitb uchar add 65 mul shr j 3 4 |
| 23390 | xb 15 127 add 130 shl and j 7 3 |
| 23391 | xword mul sub j 6 16 |
| 23392 | j = add j 1 |
| 23393 | end |
| 23394 | note MXCSR 0x1F80: all exceptions masked, round to nearest, as on x86 Linux. |
| 23395 | ximm 0 8064 |
| 23396 | xp 2 0 2064 |
| 23397 | xp 0 10 2064 |
| 23398 | xb 65 15 174 |
| 23399 | emitb 18 |
| 23400 | xp 0 15 16384 |
| 23401 | xp 0 4 8388608 |
| 23402 | ximm 5 0 |
| 23403 | note Entry has its own 80-byte EFI home/argument reservation, not an Omega frame. |
| 23404 | xb 72 129 236 |
| 23405 | xword 80 |
| 23406 | ximm 1 0 |
| 23407 | ximm 2 0 |
| 23408 | ximm 8 0 |
| 23409 | ximm 9 0 |
| 23410 | xp 3 0 256 |
| 23411 | xe 5 0 0 |
| 23412 | note TX storage outlives the image if firmware fails to release an in-flight packet. |
| 23413 | ximm 1 2 |
| 23414 | ximm 2 2048 |
| 23415 | xp 0 8 96 |
| 23416 | xp 3 0 64 |
| 23417 | xe 5 0 0 |
| 23418 | xe 8 0 16 |
| 23419 | xe 8 2 32 |
| 23420 | xe 8 3 40 |
| 23421 | xe 8 4 48 |
| 23422 | note Intel SDM 20.17.1 invariant TSC, CPUID.80000007H:EDX[8]; otherwise calibrate lazily (op 10). |
| 23423 | ximm 0 1 |
| 23424 | emitb 15 |
| 23425 | emitb 162 |
| 23426 | ximm 0 16 |
| 23427 | xrr 33 2 0 |
| 23428 | xrr 133 2 2 |
| 23429 | no1 = xbranch 0 |
| 23430 | ximm 0 2147483648 |
| 23431 | emitb 15 |
| 23432 | emitb 162 |
| 23433 | ximm 2 2147483655 |
| 23434 | xrr 57 0 2 |
| 23435 | no2 = xbranch 3 |
| 23436 | ximm 0 2147483655 |
| 23437 | emitb 15 |
| 23438 | emitb 162 |
| 23439 | ximm 0 256 |
| 23440 | xrr 33 2 0 |
| 23441 | xrr 133 2 2 |
| 23442 | no3 = xbranch 0 |
| 23443 | xe 9 0 0 |
| 23444 | xpatch no1 get oc 0 |
| 23445 | xpatch no2 get oc 0 |
| 23446 | xpatch no3 get oc 0 |
| 23447 | xb 72 129 196 |
| 23448 | xword 80 |
| 23449 | ret |
| 23450 | end |
| 23451 | if eq k 1 |
| 23452 | i = ulong 0 |
| 23453 | go = true |
| 23454 | while go |
| 23455 | m = ulong 0 |
| 23456 | while and go lt m 999999 |
| 23457 | if ge i get xnexit 0 |
| 23458 | go = false |
| 23459 | else |
| 23460 | xpatch a_g 48 i get oc 0 |
| 23461 | i = add i 1 |
| 23462 | end |
| 23463 | m = add m 1 |
| 23464 | end |
| 23465 | end |
| 23466 | note Restore a known-good private stack even when an Omega stack check failed. |
| 23467 | xp 0 4 8388608 |
| 23468 | xb 72 129 236 |
| 23469 | xword 80 |
| 23470 | xp 2 0 88 |
| 23471 | note An efi 12 file still open at exit (return, exit or trap) is flushed when writable, then the file |
| 23472 | note and its volume root are closed and the slot cleared, as a process exit closes descriptors. |
| 23473 | xp 1 1 2304 |
| 23474 | xrr 133 1 1 |
| 23475 | p1 = xbranch 0 |
| 23476 | xp 1 0 2320 |
| 23477 | xrr 133 0 0 |
| 23478 | p2 = xbranch 0 |
| 23479 | xp 4 2304 80 |
| 23480 | xpatch p2 get oc 0 |
| 23481 | xp 4 2304 16 |
| 23482 | xpatch p1 get oc 0 |
| 23483 | xp 1 1 2312 |
| 23484 | xrr 133 1 1 |
| 23485 | p3 = xbranch 0 |
| 23486 | xp 4 2312 16 |
| 23487 | xpatch p3 get oc 0 |
| 23488 | ximm 0 0 |
| 23489 | xp 2 0 2304 |
| 23490 | xp 2 0 2312 |
| 23491 | xp 2 0 2320 |
| 23492 | xe 10 0 0 |
| 23493 | xp 0 10 2080 |
| 23494 | r = ulong 6 |
| 23495 | while lt r 16 |
| 23496 | emitb 243 |
| 23497 | emitb uchar add 65 mul shr r 3 4 |
| 23498 | xb 15 111 add 130 shl and r 7 3 |
| 23499 | xword mul sub r 6 16 |
| 23500 | r = add r 1 |
| 23501 | end |
| 23502 | xp 0 10 2056 |
| 23503 | xb 65 15 174 |
| 23504 | emitb 18 |
| 23505 | xp 1 0 88 |
| 23506 | xp 1 11 2048 |
| 23507 | xrr 137 4 11 |
| 23508 | xb 65 95 65 |
| 23509 | emitb 94 |
| 23510 | xb 65 93 65 |
| 23511 | emitb 92 |
| 23512 | emitb 95 |
| 23513 | emitb 94 |
| 23514 | emitb 93 |
| 23515 | emitb 91 |
| 23516 | emitb 195 |
| 23517 | ret |
| 23518 | end |
| 23519 | note PE32+ UEFI application. Section/file alignment 4096/512; every address is RIP-relative, so the |
| 23520 | note image is position independent. A valid empty relocation block keeps loader relocation support. |
| 23521 | while ne and get oc 0 511 0 |
| 23522 | emitb 0 |
| 23523 | end |
| 23524 | raw = sub get oc 0 512 |
| 23525 | bs = shl shr add add raw 4096 4095 12 12 |
| 23526 | put xbss 0 bs |
| 23527 | wrword 0 23117 |
| 23528 | wrword 60 64 |
| 23529 | wrword 64 17744 |
| 23530 | wrword 68 165476 |
| 23531 | wrword 84 2228464 |
| 23532 | wrword 88 523 |
| 23533 | wrword 92 raw |
| 23534 | wrword 100 add get poolb 0 8388608 |
| 23535 | wrword 104 add a 3584 |
| 23536 | wrword 108 4096 |
| 23537 | wrword 112 4194304 |
| 23538 | wrword 120 4096 |
| 23539 | wrword 124 512 |
| 23540 | wrword 128 6 |
| 23541 | wrword 136 6 |
| 23542 | wrword 144 shl shr add add bs add get poolb 0 8388608 4095 12 12 |
| 23543 | wrword 148 512 |
| 23544 | wrword 156 4194314 |
| 23545 | wrword 160 1048576 |
| 23546 | wrword 168 4096 |
| 23547 | wrword 176 1048576 |
| 23548 | wrword 184 4096 |
| 23549 | wrword 196 16 |
| 23550 | wrword 512 0 |
| 23551 | wrword 516 8 |
| 23552 | note Base relocation directory points to the first eight bytes of .text, reserved by the driver. |
| 23553 | wrword 240 4096 |
| 23554 | wrword 244 8 |
| 23555 | wrword 328 2019914798 |
| 23556 | wrword 332 116 |
| 23557 | wrword 336 raw |
| 23558 | wrword 340 4096 |
| 23559 | wrword 344 raw |
| 23560 | wrword 348 512 |
| 23561 | wrword 364 1610612768 |
| 23562 | wrword 368 1936941614 |
| 23563 | wrword 376 add get poolb 0 8388608 |
| 23564 | wrword 380 bs |
| 23565 | wrword 404 3221225600 |
| 23566 | end |
| 23567 | |
| 23568 | fn xefival dst ulong to void |
| 23569 | if ne get xtarget 0 2 |
| 23570 | note d2site 601|xefival: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if ne get xtarget 0 2 |
| 23571 | put d2site 0 601 |
| 23572 | fail 25 |
| 23573 | end |
| 23574 | x = mul get depth 0 32 |
| 23575 | put a_ar add get a_rb 77 add x 7 get nslot 0 |
| 23576 | op = lenval 4 |
| 23577 | if gt op 14 |
| 23578 | note d2site 602|xefival: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if gt op 14 |
| 23579 | put d2site 0 602 |
| 23580 | fail 25 |
| 23581 | end |
| 23582 | harg x 2 5 |
| 23583 | e = harray x 1 |
| 23584 | note RBX anchors the snapshot only until ARG is loaded; firmware-preserved R14 carries it across the call |
| 23585 | note (UEFI 2.3.4.2), and the caller's R14 waits in the snapshot tail beside R13. |
| 23586 | xhbegin |
| 23587 | xmem 137 14 3 152 |
| 23588 | xrr 137 14 3 |
| 23589 | xhb 12 e get a_ar add get a_rb 77 add x 21 |
| 23590 | xhs 13 get a_ar add get a_rb 77 add x 22 |
| 23591 | xha x 2 3 |
| 23592 | note Firmware runs on the owned stack: reserve 64 KiB (trap 6), then align RSP for UEFI 2.3.4.2. |
| 23593 | xcheck 65536 |
| 23594 | xb 72 131 228 |
| 23595 | emitb 240 |
| 23596 | xb 72 129 236 |
| 23597 | xword 80 |
| 23598 | put xenerr 0 0 |
| 23599 | put xenend 0 0 |
| 23600 | xeop op |
| 23601 | xe 2 0 0 |
| 23602 | xrr 137 4 14 |
| 23603 | xmem 139 13 4 144 |
| 23604 | xmem 139 14 4 152 |
| 23605 | r = restore dst a_g 77 add x 7 get svn 0 get sva 0 1 |
| 23606 | vdone 1 r 5 |
| 23607 | end |
| 23608 | |
| 23609 | note Operation registers: RBX = ARG, R12 = A+OFF, R13 = N; the result or error is RAX. |
| 23610 | fn xeop op ulong to void |
| 23611 | if eq op 1 |
| 23612 | xe 3 4 0 |
| 23613 | xp 1 1 0 |
| 23614 | xmem 139 1 1 48 |
| 23615 | xrr 133 1 1 |
| 23616 | xer 0 0 3 |
| 23617 | xrr 137 2 12 |
| 23618 | xmem 139 11 1 8 |
| 23619 | xb 65 255 211 |
| 23620 | ret |
| 23621 | end |
| 23622 | if eq op 2 |
| 23623 | xrr 137 1 3 |
| 23624 | xp 3 0 248 |
| 23625 | ret |
| 23626 | end |
| 23627 | if eq op 4 |
| 23628 | xe 3 16 0 |
| 23629 | xp 1 11 0 |
| 23630 | xmem 139 11 11 88 |
| 23631 | xmem 139 11 11 24 |
| 23632 | xrr 137 1 12 |
| 23633 | ximm 2 0 |
| 23634 | xb 65 255 211 |
| 23635 | ret |
| 23636 | end |
| 23637 | if eq op 8 |
| 23638 | xenet |
| 23639 | ret |
| 23640 | end |
| 23641 | if eq op 10 |
| 23642 | xe 3 8 0 |
| 23643 | xp 1 1 176 |
| 23644 | xrr 133 1 1 |
| 23645 | ok = xbranch 1 |
| 23646 | xe 9 0 0 |
| 23647 | xpatch ok get oc 0 |
| 23648 | xe 12 0 0 |
| 23649 | ret |
| 23650 | end |
| 23651 | if eq op 11 |
| 23652 | xefile |
| 23653 | ret |
| 23654 | end |
| 23655 | if eq op 12 |
| 23656 | xf12 |
| 23657 | ret |
| 23658 | end |
| 23659 | if eq op 14 |
| 23660 | xf14 |
| 23661 | ret |
| 23662 | end |
| 23663 | xdev op |
| 23664 | end |
| 23665 | |
| 23666 | note efi 14 machine identity; ARG bits 0..15 sub, 16..63 its parameter. Sub 0: CPUID leaf ARG>>16 |
| 23667 | note (below 2^32, else 32) with ECX 0, EAX EBX ECX EDX as four u32 at A+OFF (N >= 16, else 5), |
| 23668 | note result 16. ARG 1: the UCS-2 code units of SystemTable FirmwareVendor (+24) up to its NUL, at |
| 23669 | note most N bytes in whole units, result bytes copied (0 when the pointer is NULL). ARG 2: result |
| 23670 | note FirmwareRevision (+32). Sub 3: SMBIOS structure table bytes from position ARG>>16 into A |
| 23671 | note (at most N), result bytes copied, 0 at or past the end. The table comes from the configuration |
| 23672 | note table: the SMBIOS3 entry point (_SM3_, size u32 @12, address u64 @16) first, else SMBIOS 2.x |
| 23673 | note (_SM_, length u16 @22, address u32 @24); 44 when neither is there, an anchor is wrong or the |
| 23674 | note address is 0. Any other ARG is 32. Nothing is written past A+OFF+N. |
| 23675 | fn xf14 to void |
| 23676 | ximm 0 1 |
| 23677 | xrr 57 3 0 |
| 23678 | p = xbranch 1 |
| 23679 | xp 1 1 0 |
| 23680 | xmem 139 6 1 24 |
| 23681 | ximm 0 0 |
| 23682 | xrr 137 7 12 |
| 23683 | xrr 137 9 13 |
| 23684 | xrr 133 6 6 |
| 23685 | z = xbranch 0 |
| 23686 | loop = get oc 0 |
| 23687 | ximm 2 2 |
| 23688 | xrr 57 9 2 |
| 23689 | d1 = xbranch 3 |
| 23690 | xhraw 2 6 0 2 |
| 23691 | xrr 133 2 2 |
| 23692 | d2 = xbranch 0 |
| 23693 | xhput 2 7 0 2 |
| 23694 | xb 72 131 198 |
| 23695 | emitb 2 |
| 23696 | xb 72 131 199 |
| 23697 | emitb 2 |
| 23698 | xb 72 131 192 |
| 23699 | emitb 2 |
| 23700 | xb 73 131 233 |
| 23701 | emitb 2 |
| 23702 | q = xbranch 14 |
| 23703 | xpatch q loop |
| 23704 | xpatch z get oc 0 |
| 23705 | xpatch d1 get oc 0 |
| 23706 | xpatch d2 get oc 0 |
| 23707 | xer 1 0 0 |
| 23708 | xpatch p get oc 0 |
| 23709 | ximm 0 2 |
| 23710 | xrr 57 3 0 |
| 23711 | p = xbranch 1 |
| 23712 | xp 1 1 0 |
| 23713 | xhraw 0 1 32 4 |
| 23714 | xer 1 0 0 |
| 23715 | xpatch p get oc 0 |
| 23716 | xrr 137 6 3 |
| 23717 | ximm 0 65535 |
| 23718 | xrr 33 6 0 |
| 23719 | p = xbranch 1 |
| 23720 | xe 3 16 0 |
| 23721 | xrr 137 0 3 |
| 23722 | xb 72 193 232 |
| 23723 | emitb 16 |
| 23724 | xrr 137 2 0 |
| 23725 | xb 72 193 234 |
| 23726 | emitb 32 |
| 23727 | xrr 133 2 2 |
| 23728 | xer 0 1 32 |
| 23729 | ximm 1 0 |
| 23730 | emitb 15 |
| 23731 | emitb 162 |
| 23732 | xhput 0 12 0 4 |
| 23733 | xhput 3 12 4 4 |
| 23734 | xhput 1 12 8 4 |
| 23735 | xhput 2 12 12 4 |
| 23736 | ximm 0 16 |
| 23737 | xer 1 0 0 |
| 23738 | xpatch p get oc 0 |
| 23739 | ximm 0 3 |
| 23740 | xrr 57 6 0 |
| 23741 | xer 0 1 32 |
| 23742 | xp 1 1 0 |
| 23743 | xmem 139 8 1 104 |
| 23744 | xmem 139 9 1 112 |
| 23745 | f3 = ulong 0 |
| 23746 | f = ulong 0 |
| 23747 | g = ulong 9 |
| 23748 | while le g 10 |
| 23749 | xaddr 10 xg g |
| 23750 | xrr 137 11 9 |
| 23751 | xrr 137 1 8 |
| 23752 | loop = get oc 0 |
| 23753 | xrr 133 1 1 |
| 23754 | miss = xbranch 0 |
| 23755 | xmem 139 0 11 0 |
| 23756 | xmem 59 0 10 0 |
| 23757 | n1 = xbranch 1 |
| 23758 | xmem 139 0 11 8 |
| 23759 | xmem 59 0 10 8 |
| 23760 | n2 = xbranch 1 |
| 23761 | xmem 139 6 11 16 |
| 23762 | f = xbranch 14 |
| 23763 | xpatch n1 get oc 0 |
| 23764 | xpatch n2 get oc 0 |
| 23765 | xb 73 131 195 |
| 23766 | emitb 24 |
| 23767 | xb 72 131 233 |
| 23768 | emitb 1 |
| 23769 | q = xbranch 14 |
| 23770 | xpatch q loop |
| 23771 | xpatch miss get oc 0 |
| 23772 | if eq g 9 |
| 23773 | f3 = f |
| 23774 | end |
| 23775 | g = add g 1 |
| 23776 | end |
| 23777 | xer 0 14 44 |
| 23778 | xpatch f get oc 0 |
| 23779 | xrr 133 6 6 |
| 23780 | xer 0 0 44 |
| 23781 | xhraw 0 6 0 4 |
| 23782 | ximm 2 1598903135 |
| 23783 | xrr 57 0 2 |
| 23784 | xer 0 1 44 |
| 23785 | xhraw 8 6 22 2 |
| 23786 | xhraw 6 6 24 4 |
| 23787 | cp = xbranch 14 |
| 23788 | xpatch f3 get oc 0 |
| 23789 | xrr 133 6 6 |
| 23790 | xer 0 0 44 |
| 23791 | xhraw 0 6 0 4 |
| 23792 | ximm 2 860705631 |
| 23793 | xrr 57 0 2 |
| 23794 | xer 0 1 44 |
| 23795 | xhraw 8 6 12 4 |
| 23796 | xmem 139 6 6 16 |
| 23797 | xpatch cp get oc 0 |
| 23798 | xrr 133 6 6 |
| 23799 | xer 0 0 44 |
| 23800 | xrr 137 2 3 |
| 23801 | xb 72 193 234 |
| 23802 | emitb 16 |
| 23803 | ximm 0 0 |
| 23804 | xrr 57 2 8 |
| 23805 | done = xbranch 2 |
| 23806 | xrr 137 1 8 |
| 23807 | xrr 41 1 2 |
| 23808 | xrr 57 1 13 |
| 23809 | ok = xbranch 9 |
| 23810 | xrr 137 1 13 |
| 23811 | xpatch ok get oc 0 |
| 23812 | xrr 1 6 2 |
| 23813 | xrr 137 7 12 |
| 23814 | xrr 137 0 1 |
| 23815 | emitb 252 |
| 23816 | emitb 243 |
| 23817 | emitb 164 |
| 23818 | xpatch done get oc 0 |
| 23819 | end |
| 23820 | |
| 23821 | note Device operations: 0 info, 3 GOP Blt, 5 entropy, 6 receive, 7 transmit, 9 pointer, 13 console. |
| 23822 | note OP0 info, 64 bytes: u32 version=1, flags (1 GOP, 2 net, 4 RNG, 8 pointer), u32 width/height@8, |
| 23823 | note pixelFormat@16, stride@20, MAC[6]@24, maxPacket@32, hwAddrSize@36, media@40, state@44, txBusy@48. |
| 23824 | note OP3 ARG: width bits0..31, height bits32..47, destination row bits48..63 (UEFI 12.9.2 Blt). |
| 23825 | fn xdev op ulong to void |
| 23826 | if eq op 0 |
| 23827 | xe 3 64 0 |
| 23828 | ximm 0 0 |
| 23829 | j = ulong 0 |
| 23830 | while lt j 64 |
| 23831 | xmem 137 0 12 j |
| 23832 | j = add j 8 |
| 23833 | end |
| 23834 | ximm 0 1 |
| 23835 | xmem 137 0 12 0 |
| 23836 | xp 1 1 16 |
| 23837 | xrr 133 1 1 |
| 23838 | p = xbranch 0 |
| 23839 | xmem 139 1 1 24 |
| 23840 | xrr 133 1 1 |
| 23841 | z1 = xbranch 0 |
| 23842 | xmem 139 1 1 8 |
| 23843 | xrr 133 1 1 |
| 23844 | z2 = xbranch 0 |
| 23845 | xmem 139 0 1 4 |
| 23846 | xmem 137 0 12 8 |
| 23847 | xhraw 0 1 12 4 |
| 23848 | xhput 0 12 16 4 |
| 23849 | xhraw 0 1 32 4 |
| 23850 | xhput 0 12 20 4 |
| 23851 | ximm 0 1 |
| 23852 | xhput 0 12 4 4 |
| 23853 | xpatch p get oc 0 |
| 23854 | xp 1 1 24 |
| 23855 | xrr 133 1 1 |
| 23856 | p = xbranch 0 |
| 23857 | xmem 139 1 1 120 |
| 23858 | xrr 133 1 1 |
| 23859 | z3 = xbranch 0 |
| 23860 | xhraw 0 1 552 4 |
| 23861 | xhput 0 12 24 4 |
| 23862 | xhraw 0 1 556 2 |
| 23863 | xhput 0 12 28 4 |
| 23864 | xhraw 0 1 12 4 |
| 23865 | xhput 0 12 32 4 |
| 23866 | xhraw 0 1 4 4 |
| 23867 | xhput 0 12 36 4 |
| 23868 | xhraw 0 1 652 1 |
| 23869 | xhput 0 12 40 4 |
| 23870 | xhraw 0 1 0 4 |
| 23871 | xhput 0 12 44 4 |
| 23872 | xp 1 0 72 |
| 23873 | xhput 0 12 48 4 |
| 23874 | xe 7 2 0 |
| 23875 | xpatch p get oc 0 |
| 23876 | xp 1 1 32 |
| 23877 | xrr 133 1 1 |
| 23878 | p = xbranch 0 |
| 23879 | xe 7 4 0 |
| 23880 | xpatch p get oc 0 |
| 23881 | xp 1 1 40 |
| 23882 | xp 1 2 48 |
| 23883 | xrr 9 1 2 |
| 23884 | xrr 133 1 1 |
| 23885 | p = xbranch 0 |
| 23886 | xe 7 8 0 |
| 23887 | xpatch p get oc 0 |
| 23888 | xpatch z1 get oc 0 |
| 23889 | xpatch z2 get oc 0 |
| 23890 | xpatch z3 get oc 0 |
| 23891 | ximm 0 0 |
| 23892 | ret |
| 23893 | end |
| 23894 | if eq op 3 |
| 23895 | xe 4 16 0 |
| 23896 | xrr 137 8 3 |
| 23897 | xb 73 193 232 |
| 23898 | emitb 32 |
| 23899 | ximm 0 65535 |
| 23900 | xrr 33 8 0 |
| 23901 | xrr 137 10 3 |
| 23902 | xb 73 193 234 |
| 23903 | emitb 48 |
| 23904 | xrr 137 9 3 |
| 23905 | ximm 0 4294967295 |
| 23906 | xrr 33 9 0 |
| 23907 | xrr 133 8 8 |
| 23908 | xer 0 0 2 |
| 23909 | xrr 133 9 9 |
| 23910 | xer 0 0 2 |
| 23911 | xmem 139 2 1 24 |
| 23912 | xrr 133 2 2 |
| 23913 | xer 0 0 2 |
| 23914 | xmem 139 2 2 8 |
| 23915 | xrr 133 2 2 |
| 23916 | xer 0 0 2 |
| 23917 | xhraw 0 2 4 4 |
| 23918 | xrr 57 9 0 |
| 23919 | xer 0 8 2 |
| 23920 | xhraw 0 2 8 4 |
| 23921 | xrr 41 0 10 |
| 23922 | xer 0 3 2 |
| 23923 | xrr 57 8 0 |
| 23924 | xer 0 8 2 |
| 23925 | xrr 137 0 8 |
| 23926 | xb 73 15 175 |
| 23927 | emitb 193 |
| 23928 | xb 72 193 224 |
| 23929 | emitb 2 |
| 23930 | xrr 57 0 13 |
| 23931 | xer 0 1 2 |
| 23932 | xmem 137 9 4 56 |
| 23933 | xmem 137 8 4 64 |
| 23934 | ximm 0 0 |
| 23935 | xmem 137 0 4 32 |
| 23936 | xmem 137 0 4 40 |
| 23937 | xmem 137 10 4 48 |
| 23938 | xmem 137 0 4 72 |
| 23939 | xrr 137 2 12 |
| 23940 | ximm 8 2 |
| 23941 | ximm 9 0 |
| 23942 | xp 4 16 16 |
| 23943 | ret |
| 23944 | end |
| 23945 | if eq op 5 |
| 23946 | note RNG protocol when present; else Intel SDM RDRAND (CPUID.1:ECX[30], CF = valid), ten attempts |
| 23947 | note per byte, then EFI_NOT_READY, never fallback data. |
| 23948 | xp 1 1 32 |
| 23949 | xrr 133 1 1 |
| 23950 | p = xbranch 0 |
| 23951 | ximm 2 0 |
| 23952 | xrr 137 8 13 |
| 23953 | xrr 137 9 12 |
| 23954 | xp 4 32 8 |
| 23955 | xer 1 0 0 |
| 23956 | xpatch p get oc 0 |
| 23957 | ximm 0 0 |
| 23958 | emitb 15 |
| 23959 | emitb 162 |
| 23960 | ximm 2 1 |
| 23961 | xrr 57 0 2 |
| 23962 | xer 0 3 3 |
| 23963 | ximm 0 1 |
| 23964 | emitb 15 |
| 23965 | emitb 162 |
| 23966 | ximm 2 1073741824 |
| 23967 | xrr 33 1 2 |
| 23968 | xrr 133 1 1 |
| 23969 | xer 0 0 3 |
| 23970 | xrr 137 7 12 |
| 23971 | xrr 137 6 13 |
| 23972 | lp = get oc 0 |
| 23973 | xrr 133 6 6 |
| 23974 | q = xbranch 0 |
| 23975 | ximm 1 10 |
| 23976 | rw = get oc 0 |
| 23977 | xb 72 15 199 |
| 23978 | emitb 240 |
| 23979 | s = xbranch 3 |
| 23980 | xb 72 255 201 |
| 23981 | p = xbranch 1 |
| 23982 | xpatch p rw |
| 23983 | xer 0 14 6 |
| 23984 | xpatch s get oc 0 |
| 23985 | emitb 136 |
| 23986 | emitb 7 |
| 23987 | xb 72 255 199 |
| 23988 | xb 72 255 206 |
| 23989 | back lp |
| 23990 | xpatch q get oc 0 |
| 23991 | ximm 0 0 |
| 23992 | ret |
| 23993 | end |
| 23994 | if eq op 6 |
| 23995 | xe 3 9 0 |
| 23996 | xe 4 24 0 |
| 23997 | xrr 137 0 13 |
| 23998 | xb 72 131 232 |
| 23999 | emitb 8 |
| 24000 | xmem 137 0 12 0 |
| 24001 | ximm 2 0 |
| 24002 | xrr 137 8 12 |
| 24003 | xmem 141 9 12 8 |
| 24004 | ximm 0 0 |
| 24005 | xmem 137 0 4 32 |
| 24006 | xmem 137 0 4 40 |
| 24007 | xmem 137 0 4 48 |
| 24008 | xp 4 24 104 |
| 24009 | ret |
| 24010 | end |
| 24011 | if eq op 7 |
| 24012 | note Transmit always owns its private packet until GetStatus reclaims that exact address (UEFI 24.1.12). |
| 24013 | xe 4 24 0 |
| 24014 | xe 3 14 0 |
| 24015 | ximm 0 2048 |
| 24016 | xrr 57 13 0 |
| 24017 | xer 0 8 4 |
| 24018 | xp 1 0 72 |
| 24019 | xrr 133 0 0 |
| 24020 | p = xbranch 0 |
| 24021 | ximm 0 0 |
| 24022 | xp 2 0 80 |
| 24023 | ximm 2 0 |
| 24024 | xp 0 8 80 |
| 24025 | xp 4 24 88 |
| 24026 | xrr 133 0 0 |
| 24027 | xer 0 1 6 |
| 24028 | xp 1 0 80 |
| 24029 | xp 1 2 96 |
| 24030 | xrr 57 0 2 |
| 24031 | xer 0 1 6 |
| 24032 | ximm 0 0 |
| 24033 | xp 2 0 72 |
| 24034 | xpatch p get oc 0 |
| 24035 | xrr 137 6 12 |
| 24036 | xp 1 7 96 |
| 24037 | xrr 137 1 13 |
| 24038 | emitb 252 |
| 24039 | emitb 243 |
| 24040 | emitb 164 |
| 24041 | ximm 2 0 |
| 24042 | xrr 137 8 13 |
| 24043 | xp 1 9 96 |
| 24044 | ximm 0 0 |
| 24045 | xmem 137 0 4 32 |
| 24046 | xmem 137 0 4 40 |
| 24047 | xmem 137 0 4 48 |
| 24048 | xp 4 24 96 |
| 24049 | xrr 133 0 0 |
| 24050 | p = xbranch 1 |
| 24051 | ximm 2 1 |
| 24052 | xp 2 2 72 |
| 24053 | xpatch p get oc 0 |
| 24054 | ret |
| 24055 | end |
| 24056 | if eq op 9 |
| 24057 | xe 3 32 0 |
| 24058 | xp 1 1 40 |
| 24059 | xrr 133 1 1 |
| 24060 | q = xbranch 0 |
| 24061 | xp 0 2 256 |
| 24062 | xp 4 40 8 |
| 24063 | xrr 133 0 0 |
| 24064 | p = xbranch 1 |
| 24065 | xp 0 2 256 |
| 24066 | ximm 0 1 |
| 24067 | xmem 137 0 12 0 |
| 24068 | xhraw 0 2 12 1 |
| 24069 | xhraw 1 2 13 1 |
| 24070 | xb 72 193 225 |
| 24071 | emitb 1 |
| 24072 | xrr 9 0 1 |
| 24073 | xhput 0 12 4 4 |
| 24074 | i = ulong 0 |
| 24075 | while lt i 3 |
| 24076 | note MOVSXD rax,dword [rdx+disp32], Intel MOVSX/MOVSXD. |
| 24077 | xb 72 99 130 |
| 24078 | xword mul i 4 |
| 24079 | xmem 137 0 12 add 8 mul i 8 |
| 24080 | i = add i 1 |
| 24081 | end |
| 24082 | ximm 0 0 |
| 24083 | xpatch p get oc 0 |
| 24084 | xer 1 0 0 |
| 24085 | xpatch q get oc 0 |
| 24086 | xe 4 48 0 |
| 24087 | xp 0 2 256 |
| 24088 | xp 4 48 8 |
| 24089 | xrr 133 0 0 |
| 24090 | p = xbranch 1 |
| 24091 | xp 0 2 256 |
| 24092 | ximm 0 2 |
| 24093 | xmem 137 0 12 0 |
| 24094 | xhraw 0 2 24 4 |
| 24095 | xhput 0 12 4 4 |
| 24096 | i = ulong 0 |
| 24097 | while lt i 3 |
| 24098 | xmem 139 0 2 mul i 8 |
| 24099 | xmem 137 0 12 add 8 mul i 8 |
| 24100 | i = add i 1 |
| 24101 | end |
| 24102 | ximm 0 0 |
| 24103 | xpatch p get oc 0 |
| 24104 | ret |
| 24105 | end |
| 24106 | if ne op 13 |
| 24107 | note d2site 603|xdev: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if ne op 13 |
| 24108 | put d2site 0 603 |
| 24109 | fail 25 |
| 24110 | end |
| 24111 | note efi 13: write A[OFF..OFF+N) to ConOut (UEFI 12.4 OutputString). ARG must be 0; only bytes 9, 10, |
| 24112 | note 13 and 32..126, all checked before any output; LF becomes CR LF; UCS-2 chunks of at most 255 |
| 24113 | note characters in private 4096. Warnings (bit 63 clear) are not errors. Result N. |
| 24114 | xrr 133 3 3 |
| 24115 | xer 0 1 32 |
| 24116 | xrr 137 8 12 |
| 24117 | xrr 137 9 13 |
| 24118 | lp = get oc 0 |
| 24119 | xrr 133 9 9 |
| 24120 | p = xbranch 0 |
| 24121 | xhraw 0 8 0 1 |
| 24122 | ximm 2 9 |
| 24123 | xrr 57 0 2 |
| 24124 | q = xbranch 0 |
| 24125 | ximm 2 10 |
| 24126 | xrr 57 0 2 |
| 24127 | rw = xbranch 0 |
| 24128 | ximm 2 13 |
| 24129 | xrr 57 0 2 |
| 24130 | s = xbranch 0 |
| 24131 | ximm 2 32 |
| 24132 | xrr 57 0 2 |
| 24133 | xer 0 3 42 |
| 24134 | ximm 2 126 |
| 24135 | xrr 57 0 2 |
| 24136 | xer 0 8 42 |
| 24137 | xpatch q get oc 0 |
| 24138 | xpatch rw get oc 0 |
| 24139 | xpatch s get oc 0 |
| 24140 | xb 73 131 192 |
| 24141 | emitb 1 |
| 24142 | xb 73 131 233 |
| 24143 | emitb 1 |
| 24144 | back lp |
| 24145 | xpatch p get oc 0 |
| 24146 | note ConOut (SystemTable+64) may be NULL on headless firmware: refuse with 43 before any call. |
| 24147 | xp 1 1 0 |
| 24148 | xmem 139 1 1 64 |
| 24149 | xrr 133 1 1 |
| 24150 | xer 0 0 43 |
| 24151 | xrr 137 6 12 |
| 24152 | xrr 137 3 13 |
| 24153 | ximm 7 0 |
| 24154 | lp = get oc 0 |
| 24155 | xrr 133 3 3 |
| 24156 | p = xbranch 0 |
| 24157 | ximm 0 254 |
| 24158 | xrr 57 7 0 |
| 24159 | q = xbranch 3 |
| 24160 | xpatch p get oc 0 |
| 24161 | xrr 133 7 7 |
| 24162 | rw = xbranch 0 |
| 24163 | xp 0 10 4096 |
| 24164 | xrr 137 11 7 |
| 24165 | xrr 1 11 11 |
| 24166 | xrr 1 10 11 |
| 24167 | ximm 0 0 |
| 24168 | xhput 0 10 0 2 |
| 24169 | xp 1 1 0 |
| 24170 | xmem 139 1 1 64 |
| 24171 | xp 0 2 4096 |
| 24172 | xmem 139 11 1 8 |
| 24173 | xb 65 255 211 |
| 24174 | xrr 133 0 0 |
| 24175 | xer 0 11 43 |
| 24176 | ximm 7 0 |
| 24177 | xpatch rw get oc 0 |
| 24178 | xrr 133 3 3 |
| 24179 | s = xbranch 0 |
| 24180 | xpatch q get oc 0 |
| 24181 | xp 0 10 4096 |
| 24182 | xrr 137 11 7 |
| 24183 | xrr 1 11 11 |
| 24184 | xrr 1 10 11 |
| 24185 | xhraw 0 6 0 1 |
| 24186 | ximm 2 10 |
| 24187 | xrr 57 0 2 |
| 24188 | p = xbranch 1 |
| 24189 | ximm 0 13 |
| 24190 | xhput 0 10 0 2 |
| 24191 | ximm 0 10 |
| 24192 | xhput 0 10 2 2 |
| 24193 | xb 72 131 199 |
| 24194 | emitb 1 |
| 24195 | q = xbranch 14 |
| 24196 | xpatch p get oc 0 |
| 24197 | xhput 0 10 0 2 |
| 24198 | xpatch q get oc 0 |
| 24199 | xb 72 131 199 |
| 24200 | emitb 1 |
| 24201 | xb 72 131 198 |
| 24202 | emitb 1 |
| 24203 | xb 72 131 235 |
| 24204 | emitb 1 |
| 24205 | back lp |
| 24206 | xpatch s get oc 0 |
| 24207 | xrr 137 0 13 |
| 24208 | end |
| 24209 | |
| 24210 | note UEFI 24.1 SNP mode: MAC array capacity 16, 32-byte MAC cells, current@552, IfType@648, |
| 24211 | note MediaPresentSupported@651, MediaPresent@652. k 0 probe candidate 128 (own error scope); |
| 24212 | note k 1 reject it: shut down/stop only what this application initialized/started. |
| 24213 | fn xenpr k ulong to void |
| 24214 | if eq k 1 |
| 24215 | xp 1 0 144 |
| 24216 | xrr 133 0 0 |
| 24217 | p = xbranch 0 |
| 24218 | xp 4 128 40 |
| 24219 | xpatch p get oc 0 |
| 24220 | xp 1 0 136 |
| 24221 | xrr 133 0 0 |
| 24222 | p = xbranch 0 |
| 24223 | xp 4 128 16 |
| 24224 | xpatch p get oc 0 |
| 24225 | ret |
| 24226 | end |
| 24227 | put xenerr 0 0 |
| 24228 | put xenend 0 0 |
| 24229 | ximm 0 0 |
| 24230 | xp 2 0 136 |
| 24231 | xp 2 0 144 |
| 24232 | xp 1 1 128 |
| 24233 | xmem 139 2 1 120 |
| 24234 | xrr 133 2 2 |
| 24235 | xer 0 0 3 |
| 24236 | xhraw 0 2 4 4 |
| 24237 | ximm 8 6 |
| 24238 | xrr 57 0 8 |
| 24239 | xer 0 1 3 |
| 24240 | xhraw 0 2 648 1 |
| 24241 | ximm 8 1 |
| 24242 | xrr 57 0 8 |
| 24243 | xer 0 1 3 |
| 24244 | xhraw 0 2 0 4 |
| 24245 | xrr 133 0 0 |
| 24246 | q = xbranch 1 |
| 24247 | xp 4 128 8 |
| 24248 | xrr 133 0 0 |
| 24249 | xer 0 1 7 |
| 24250 | ximm 0 1 |
| 24251 | xp 2 0 136 |
| 24252 | xpatch q get oc 0 |
| 24253 | xp 1 1 128 |
| 24254 | xmem 139 2 1 120 |
| 24255 | xhraw 0 2 0 4 |
| 24256 | ximm 8 1 |
| 24257 | xrr 57 0 8 |
| 24258 | q = xbranch 1 |
| 24259 | ximm 2 0 |
| 24260 | ximm 8 0 |
| 24261 | xp 4 128 24 |
| 24262 | xrr 133 0 0 |
| 24263 | xer 0 1 7 |
| 24264 | ximm 0 1 |
| 24265 | xp 2 0 144 |
| 24266 | xpatch q get oc 0 |
| 24267 | ximm 2 0 |
| 24268 | ximm 8 0 |
| 24269 | xp 4 128 88 |
| 24270 | xrr 133 0 0 |
| 24271 | xer 0 1 7 |
| 24272 | xp 1 1 128 |
| 24273 | xmem 139 2 1 120 |
| 24274 | xhraw 0 2 0 4 |
| 24275 | ximm 8 2 |
| 24276 | xrr 57 0 8 |
| 24277 | xer 0 1 6 |
| 24278 | note MediaPresent is binding only when the driver says media detection is supported. |
| 24279 | xhraw 0 2 651 1 |
| 24280 | xrr 133 0 0 |
| 24281 | q = xbranch 0 |
| 24282 | xhraw 0 2 652 1 |
| 24283 | xrr 133 0 0 |
| 24284 | xer 0 0 12 |
| 24285 | xpatch q get oc 0 |
| 24286 | xhraw 0 2 24 4 |
| 24287 | ximm 8 5 |
| 24288 | xrr 33 0 8 |
| 24289 | xrr 57 0 8 |
| 24290 | xer 0 1 3 |
| 24291 | ximm 2 5 |
| 24292 | ximm 8 0 |
| 24293 | ximm 9 0 |
| 24294 | ximm 0 0 |
| 24295 | xmem 137 0 4 32 |
| 24296 | xmem 137 0 4 40 |
| 24297 | xp 4 128 48 |
| 24298 | xe 2 0 0 |
| 24299 | end |
| 24300 | |
| 24301 | note UEFI 2.4 7.3 OpenProtocol EXCLUSIVE (32) disconnects MNP and the IP stack above SNP; while they |
| 24302 | note stay bound, MNP's poll timer drains frames no child wants (aienux#454). Firmware that refuses |
| 24303 | note keeps the shared HandleProtocol path. All candidates are tried for a live link. |
| 24304 | fn xenscan g ulong to void |
| 24305 | ximm 3 0 |
| 24306 | lp = get oc 0 |
| 24307 | xrr 57 3 7 |
| 24308 | ex = xbranch 2 |
| 24309 | xrr 137 0 3 |
| 24310 | xb 72 193 224 |
| 24311 | emitb 3 |
| 24312 | xrr 1 0 6 |
| 24313 | xmem 139 1 0 0 |
| 24314 | xaddr 2 g |
| 24315 | xp 0 8 128 |
| 24316 | xp 1 9 8 |
| 24317 | ximm 0 0 |
| 24318 | xmem 137 0 4 32 |
| 24319 | ximm 0 32 |
| 24320 | xmem 137 0 4 40 |
| 24321 | xp 3 0 280 |
| 24322 | xrr 133 0 0 |
| 24323 | p = xbranch 0 |
| 24324 | xrr 137 0 3 |
| 24325 | xb 72 193 224 |
| 24326 | emitb 3 |
| 24327 | xrr 1 0 6 |
| 24328 | xmem 139 1 0 0 |
| 24329 | xaddr 2 g |
| 24330 | xp 0 8 128 |
| 24331 | xp 3 0 152 |
| 24332 | xpatch p get oc 0 |
| 24333 | xrr 133 0 0 |
| 24334 | sk = xbranch 1 |
| 24335 | xenpr 0 |
| 24336 | xrr 133 0 0 |
| 24337 | p = xbranch 1 |
| 24338 | xp 1 0 128 |
| 24339 | xp 2 0 24 |
| 24340 | sel = xbranch 14 |
| 24341 | xpatch p get oc 0 |
| 24342 | xenpr 1 |
| 24343 | xpatch sk get oc 0 |
| 24344 | xb 72 255 195 |
| 24345 | back lp |
| 24346 | xpatch ex get oc 0 |
| 24347 | ximm 0 9223372036854775822 |
| 24348 | p = xbranch 14 |
| 24349 | xpatch sel get oc 0 |
| 24350 | ximm 0 0 |
| 24351 | xpatch p get oc 0 |
| 24352 | end |
| 24353 | |
| 24354 | note OP8: select a live Simple Network Protocol interface once (result 0), or an EFI status. |
| 24355 | fn xenet to void |
| 24356 | xp 1 1 24 |
| 24357 | xrr 133 1 1 |
| 24358 | al = xbranch 1 |
| 24359 | g = xg 1 |
| 24360 | ximm 1 2 |
| 24361 | xaddr 2 g |
| 24362 | ximm 8 0 |
| 24363 | xp 0 9 104 |
| 24364 | xp 0 0 112 |
| 24365 | xmem 137 0 4 32 |
| 24366 | xp 3 0 312 |
| 24367 | xrr 133 0 0 |
| 24368 | lerr = xbranch 1 |
| 24369 | xp 1 6 112 |
| 24370 | xp 1 7 104 |
| 24371 | ximm 0 1024 |
| 24372 | xrr 57 7 0 |
| 24373 | lg = xbranch 8 |
| 24374 | xenscan g |
| 24375 | sv = xbranch 14 |
| 24376 | xpatch lg get oc 0 |
| 24377 | ximm 0 9223372036854775813 |
| 24378 | xpatch sv get oc 0 |
| 24379 | xp 2 0 152 |
| 24380 | xrr 137 1 6 |
| 24381 | xp 3 0 72 |
| 24382 | xrr 133 0 0 |
| 24383 | fe = xbranch 1 |
| 24384 | xp 1 0 152 |
| 24385 | dn = xbranch 14 |
| 24386 | xpatch al get oc 0 |
| 24387 | ximm 0 0 |
| 24388 | xpatch dn get oc 0 |
| 24389 | xpatch lerr get oc 0 |
| 24390 | xpatch fe get oc 0 |
| 24391 | put xenerr 0 0 |
| 24392 | put xenend 0 0 |
| 24393 | end |
| 24394 | |
| 24395 | note Volumes (UEFI 13.4 Simple File System, 9.1 LoadedImage). k 0: copy the handles (at most 64) to |
| 24396 | note private 1024 and free the firmware buffer (clobbers RSI/RDI/RCX); 1: result count | boot index<<8 |
| 24397 | note (255 none) and finish; 2: open the root of volume RDI into slot root (19 index, 21, 22); |
| 24398 | note 3: open the root of the volume this image was loaded from into slot root (18, 21, 22). |
| 24399 | fn xvol k ulong root ulong to void |
| 24400 | if eq k 0 |
| 24401 | g = xg 5 |
| 24402 | ximm 1 2 |
| 24403 | xaddr 2 g |
| 24404 | ximm 8 0 |
| 24405 | xp 0 9 512 |
| 24406 | xp 0 0 520 |
| 24407 | xmem 137 0 4 32 |
| 24408 | xp 3 0 312 |
| 24409 | xrr 133 0 0 |
| 24410 | xer 0 1 16 |
| 24411 | xp 1 1 512 |
| 24412 | ximm 0 64 |
| 24413 | xrr 57 1 0 |
| 24414 | p = xbranch 3 |
| 24415 | ximm 1 64 |
| 24416 | xpatch p get oc 0 |
| 24417 | xp 2 1 512 |
| 24418 | xp 1 6 520 |
| 24419 | xp 0 7 1024 |
| 24420 | emitb 252 |
| 24421 | emitb 243 |
| 24422 | emitb 72 |
| 24423 | emitb 165 |
| 24424 | xp 1 1 520 |
| 24425 | xp 3 0 72 |
| 24426 | xrr 133 0 0 |
| 24427 | xer 0 1 17 |
| 24428 | ret |
| 24429 | end |
| 24430 | if eq k 1 |
| 24431 | gl = xg 6 |
| 24432 | xp 1 1 8 |
| 24433 | xaddr 2 gl |
| 24434 | xp 0 8 528 |
| 24435 | xp 3 0 152 |
| 24436 | xrr 133 0 0 |
| 24437 | xer 0 1 18 |
| 24438 | xp 1 0 528 |
| 24439 | xmem 139 0 0 24 |
| 24440 | xp 1 6 512 |
| 24441 | xp 0 7 1024 |
| 24442 | ximm 2 0 |
| 24443 | lp = get oc 0 |
| 24444 | xrr 57 2 6 |
| 24445 | nm = xbranch 2 |
| 24446 | xmem 139 1 7 0 |
| 24447 | xrr 57 1 0 |
| 24448 | fd = xbranch 0 |
| 24449 | xb 72 131 199 |
| 24450 | emitb 8 |
| 24451 | xb 72 255 194 |
| 24452 | back lp |
| 24453 | xpatch nm get oc 0 |
| 24454 | ximm 2 255 |
| 24455 | xpatch fd get oc 0 |
| 24456 | xrr 137 0 6 |
| 24457 | xb 72 193 226 |
| 24458 | emitb 8 |
| 24459 | xrr 9 0 2 |
| 24460 | xer 1 0 0 |
| 24461 | ret |
| 24462 | end |
| 24463 | gs = xg 5 |
| 24464 | if eq k 3 |
| 24465 | gi = xg 6 |
| 24466 | xp 1 1 8 |
| 24467 | xaddr 2 gi |
| 24468 | xp 0 8 528 |
| 24469 | xp 3 0 152 |
| 24470 | xrr 133 0 0 |
| 24471 | xer 0 1 18 |
| 24472 | xp 1 1 528 |
| 24473 | xmem 139 1 1 24 |
| 24474 | else |
| 24475 | xp 1 0 512 |
| 24476 | xrr 57 7 0 |
| 24477 | xer 0 2 19 |
| 24478 | xp 0 1 1024 |
| 24479 | xrr 137 0 7 |
| 24480 | xb 72 193 224 |
| 24481 | emitb 3 |
| 24482 | xrr 1 1 0 |
| 24483 | xmem 139 1 1 0 |
| 24484 | end |
| 24485 | xaddr 2 gs |
| 24486 | xp 0 8 536 |
| 24487 | xp 3 0 152 |
| 24488 | xrr 133 0 0 |
| 24489 | xer 0 1 21 |
| 24490 | xp 0 2 root |
| 24491 | xp 4 536 8 |
| 24492 | xrr 133 0 0 |
| 24493 | xer 0 1 22 |
| 24494 | end |
| 24495 | |
| 24496 | note File I/O (UEFI 13.5). k 0: Open(root, path, mode) into slot file; the path is the fixed |
| 24497 | note \EFI\BOOT\BOOTX64.EFI for root 544 (efi 11), else the UCS-2 copy at private 3584 (efi 12). |
| 24498 | note k 1: efi 11 Read/Write (method mode) of N bytes at R12 via size slot 560. Failure: RDI = code, |
| 24499 | note jump to cleanup. |
| 24500 | fn xfio k ulong root ulong file ulong mode ulong code ulong cleanup ulong to void |
| 24501 | if eq k 0 |
| 24502 | if eq root 544 |
| 24503 | p = xg 8 |
| 24504 | xaddr 8 p |
| 24505 | else |
| 24506 | xp 0 8 3584 |
| 24507 | end |
| 24508 | xp 0 2 file |
| 24509 | ximm 9 mode |
| 24510 | ximm 0 0 |
| 24511 | xmem 137 0 4 32 |
| 24512 | xp 4 root 8 |
| 24513 | else |
| 24514 | xp 2 13 560 |
| 24515 | xp 0 2 560 |
| 24516 | xrr 137 8 12 |
| 24517 | xp 4 552 mode |
| 24518 | end |
| 24519 | xrr 133 0 0 |
| 24520 | ximm 7 code |
| 24521 | bad = xbranch 1 |
| 24522 | xpatch bad cleanup |
| 24523 | end |
| 24524 | |
| 24525 | note OP11 (Allen fork contract): ARG sub bits0..7, volume bits8..15. Sub 0 counts the volumes and |
| 24526 | note finds the boot one (count | index<<8); sub 1 reads \EFI\BOOT\BOOTX64.EFI of volume k into A |
| 24527 | note (result bytes); sub 2 writes A's N bytes as that file (deleted first; result bytes). File and |
| 24528 | note root handles are closed on every path. |
| 24529 | fn xefile to void |
| 24530 | xrr 137 0 3 |
| 24531 | ximm 2 255 |
| 24532 | xrr 33 0 2 |
| 24533 | ximm 2 2 |
| 24534 | xrr 57 0 2 |
| 24535 | xer 0 8 15 |
| 24536 | ximm 0 0 |
| 24537 | xp 2 0 544 |
| 24538 | xp 2 0 552 |
| 24539 | skip = xbranch 14 |
| 24540 | cleanup = get oc 0 |
| 24541 | xp 1 1 552 |
| 24542 | xrr 133 1 1 |
| 24543 | p = xbranch 0 |
| 24544 | xp 4 552 16 |
| 24545 | xpatch p get oc 0 |
| 24546 | xp 1 1 544 |
| 24547 | xrr 133 1 1 |
| 24548 | p = xbranch 0 |
| 24549 | xp 4 544 16 |
| 24550 | xpatch p get oc 0 |
| 24551 | xrr 133 7 7 |
| 24552 | p = xbranch 0 |
| 24553 | ximm 0 9223372036854775808 |
| 24554 | xrr 9 0 7 |
| 24555 | xer 1 0 0 |
| 24556 | xpatch p get oc 0 |
| 24557 | xp 1 0 568 |
| 24558 | xer 1 0 0 |
| 24559 | xpatch skip get oc 0 |
| 24560 | xvol 0 0 |
| 24561 | xrr 137 6 3 |
| 24562 | ximm 2 255 |
| 24563 | xrr 33 6 2 |
| 24564 | xrr 137 7 3 |
| 24565 | xb 72 193 239 |
| 24566 | emitb 8 |
| 24567 | xrr 33 7 2 |
| 24568 | xrr 133 6 6 |
| 24569 | p = xbranch 1 |
| 24570 | xvol 1 0 |
| 24571 | xpatch p get oc 0 |
| 24572 | xp 1 0 512 |
| 24573 | xrr 57 7 0 |
| 24574 | xer 0 2 19 |
| 24575 | xe 3 1 0 |
| 24576 | xvol 2 544 |
| 24577 | ximm 0 1 |
| 24578 | xrr 57 6 0 |
| 24579 | wr = xbranch 1 |
| 24580 | xfio 0 544 552 1 23 cleanup |
| 24581 | xfio 1 0 0 32 25 cleanup |
| 24582 | xp 1 0 560 |
| 24583 | xp 2 0 568 |
| 24584 | ximm 0 1 |
| 24585 | xp 2 0 560 |
| 24586 | xp 0 2 560 |
| 24587 | xp 0 8 576 |
| 24588 | xp 4 552 32 |
| 24589 | xrr 133 0 0 |
| 24590 | ximm 7 25 |
| 24591 | p = xbranch 1 |
| 24592 | xpatch p cleanup |
| 24593 | xp 1 0 560 |
| 24594 | xrr 133 0 0 |
| 24595 | ximm 7 24 |
| 24596 | p = xbranch 1 |
| 24597 | xpatch p cleanup |
| 24598 | ximm 7 0 |
| 24599 | p = xbranch 14 |
| 24600 | xpatch p cleanup |
| 24601 | xpatch wr get oc 0 |
| 24602 | xfio 0 544 552 3 26 cleanup |
| 24603 | xp 4 552 24 |
| 24604 | ximm 2 0 |
| 24605 | xp 2 2 552 |
| 24606 | xrr 133 0 0 |
| 24607 | ximm 7 27 |
| 24608 | p = xbranch 1 |
| 24609 | xpatch p cleanup |
| 24610 | xfio 0 544 552 9223372036854775811 28 cleanup |
| 24611 | xfio 1 0 0 40 29 cleanup |
| 24612 | xp 1 0 560 |
| 24613 | xrr 57 0 13 |
| 24614 | ximm 7 30 |
| 24615 | p = xbranch 1 |
| 24616 | xpatch p cleanup |
| 24617 | xp 4 552 80 |
| 24618 | xrr 133 0 0 |
| 24619 | ximm 7 31 |
| 24620 | p = xbranch 1 |
| 24621 | xpatch p cleanup |
| 24622 | xp 1 0 560 |
| 24623 | xp 2 0 568 |
| 24624 | ximm 7 0 |
| 24625 | p = xbranch 14 |
| 24626 | xpatch p cleanup |
| 24627 | end |
| 24628 | |
| 24629 | note OP12 general file (new): ARG sub bits0..7, volume bits8..15 (255 = the volume this image was |
| 24630 | note loaded from), position bits16..63. Open subs take the path A[OFF..OFF+N): 1..255 bytes, first |
| 24631 | note '\', each 32..126. Sub 0 open read-only, 5 open an existing file read/write (no truncate), both |
| 24632 | note result FileSize; 1 create empty, replacing any file (result 0). Sub 2 reads up to N bytes at |
| 24633 | note the position into A (result bytes read, 0 at end), 3 writes N bytes there (result N; needs sub |
| 24634 | note 1 or 5), 4 flushes and closes (result 0). One file at a time: its handle stays in private 2304 |
| 24635 | note and its volume root in 2312 between operations. Errors: 32 sub, 33 path, 34 busy, 35 nothing |
| 24636 | note open, 36 open/create/delete, 37 read, 38 write (or not writable), 39 short write, 40 flush, |
| 24637 | note 41 GetInfo; volume errors 16..22 as efi 11. Refusals 32..35 and 38 not-writable leave the slot |
| 24638 | note as it was (the caller still owns an open file); so do the firmware errors 37, 38 and 39 of subs |
| 24639 | note 2 and 3. Volume errors leave the slot empty. 36 and 41 close the file and root, slot empty; |
| 24640 | note sub 4 with a file open closes both and empties the slot on every path, returning 40 when Flush |
| 24641 | note failed. A file still open at exit is flushed and closed by the shared exit (xefx 1). |
| 24642 | fn xf12 to void |
| 24643 | skip = xbranch 14 |
| 24644 | cleanup = get oc 0 |
| 24645 | xp 1 1 2304 |
| 24646 | xrr 133 1 1 |
| 24647 | p = xbranch 0 |
| 24648 | xp 4 2304 16 |
| 24649 | xpatch p get oc 0 |
| 24650 | xp 1 1 2312 |
| 24651 | xrr 133 1 1 |
| 24652 | p = xbranch 0 |
| 24653 | xp 4 2312 16 |
| 24654 | xpatch p get oc 0 |
| 24655 | ximm 0 0 |
| 24656 | xp 2 0 2304 |
| 24657 | xp 2 0 2312 |
| 24658 | xp 2 0 2320 |
| 24659 | xrr 133 7 7 |
| 24660 | p = xbranch 0 |
| 24661 | ximm 0 9223372036854775808 |
| 24662 | xrr 9 0 7 |
| 24663 | xer 1 0 0 |
| 24664 | xpatch p get oc 0 |
| 24665 | xer 1 0 0 |
| 24666 | xpatch skip get oc 0 |
| 24667 | xrr 137 6 3 |
| 24668 | ximm 0 255 |
| 24669 | xrr 33 6 0 |
| 24670 | ximm 0 5 |
| 24671 | xrr 57 6 0 |
| 24672 | xer 0 8 32 |
| 24673 | ximm 0 2 |
| 24674 | xrr 57 6 0 |
| 24675 | opn = xbranch 3 |
| 24676 | ximm 0 5 |
| 24677 | xrr 57 6 0 |
| 24678 | op5 = xbranch 0 |
| 24679 | xp 1 1 2304 |
| 24680 | xrr 133 1 1 |
| 24681 | xer 0 0 35 |
| 24682 | ximm 0 4 |
| 24683 | xrr 57 6 0 |
| 24684 | p = xbranch 1 |
| 24685 | ximm 7 0 |
| 24686 | xp 1 0 2320 |
| 24687 | xrr 133 0 0 |
| 24688 | q = xbranch 0 |
| 24689 | xp 4 2304 80 |
| 24690 | xrr 133 0 0 |
| 24691 | rw = xbranch 0 |
| 24692 | ximm 7 40 |
| 24693 | xpatch rw get oc 0 |
| 24694 | xpatch q get oc 0 |
| 24695 | ximm 0 0 |
| 24696 | rw = xbranch 14 |
| 24697 | xpatch rw cleanup |
| 24698 | xpatch p get oc 0 |
| 24699 | xrr 137 2 3 |
| 24700 | xb 72 193 234 |
| 24701 | emitb 16 |
| 24702 | ximm 0 3 |
| 24703 | xrr 57 6 0 |
| 24704 | p = xbranch 0 |
| 24705 | xp 4 2304 56 |
| 24706 | xrr 133 0 0 |
| 24707 | xer 0 1 37 |
| 24708 | xp 2 13 2336 |
| 24709 | xp 0 2 2336 |
| 24710 | xrr 137 8 12 |
| 24711 | xp 4 2304 32 |
| 24712 | xrr 133 0 0 |
| 24713 | xer 0 1 37 |
| 24714 | xp 1 0 2336 |
| 24715 | xer 1 0 0 |
| 24716 | xpatch p get oc 0 |
| 24717 | xp 1 0 2320 |
| 24718 | xrr 133 0 0 |
| 24719 | xer 0 0 38 |
| 24720 | xp 4 2304 56 |
| 24721 | xrr 133 0 0 |
| 24722 | xer 0 1 38 |
| 24723 | xp 2 13 2336 |
| 24724 | xp 0 2 2336 |
| 24725 | xrr 137 8 12 |
| 24726 | xp 4 2304 40 |
| 24727 | xrr 133 0 0 |
| 24728 | xer 0 1 38 |
| 24729 | xp 1 0 2336 |
| 24730 | xrr 57 0 13 |
| 24731 | xer 0 1 39 |
| 24732 | xrr 137 0 13 |
| 24733 | xer 1 0 0 |
| 24734 | xpatch opn get oc 0 |
| 24735 | xpatch op5 get oc 0 |
| 24736 | xp 1 1 2304 |
| 24737 | xrr 133 1 1 |
| 24738 | xer 0 1 34 |
| 24739 | xrr 133 13 13 |
| 24740 | xer 0 0 33 |
| 24741 | ximm 0 255 |
| 24742 | xrr 57 13 0 |
| 24743 | xer 0 8 33 |
| 24744 | xhraw 0 12 0 1 |
| 24745 | ximm 2 92 |
| 24746 | xrr 57 0 2 |
| 24747 | xer 0 1 33 |
| 24748 | xrr 137 8 12 |
| 24749 | xrr 137 9 13 |
| 24750 | xp 0 10 3584 |
| 24751 | lp = get oc 0 |
| 24752 | xrr 133 9 9 |
| 24753 | p = xbranch 0 |
| 24754 | xhraw 0 8 0 1 |
| 24755 | ximm 2 32 |
| 24756 | xrr 57 0 2 |
| 24757 | xer 0 3 33 |
| 24758 | ximm 2 126 |
| 24759 | xrr 57 0 2 |
| 24760 | xer 0 8 33 |
| 24761 | xhput 0 10 0 2 |
| 24762 | xb 73 131 192 |
| 24763 | emitb 1 |
| 24764 | xb 73 131 194 |
| 24765 | emitb 2 |
| 24766 | xb 73 131 233 |
| 24767 | emitb 1 |
| 24768 | back lp |
| 24769 | xpatch p get oc 0 |
| 24770 | ximm 0 0 |
| 24771 | xhput 0 10 0 2 |
| 24772 | xrr 137 0 3 |
| 24773 | ximm 2 65280 |
| 24774 | xrr 33 0 2 |
| 24775 | xrr 57 0 2 |
| 24776 | p = xbranch 0 |
| 24777 | xvol 0 0 |
| 24778 | xrr 137 7 3 |
| 24779 | xb 72 193 239 |
| 24780 | emitb 8 |
| 24781 | ximm 2 255 |
| 24782 | xrr 33 7 2 |
| 24783 | xvol 2 2312 |
| 24784 | q = xbranch 14 |
| 24785 | xpatch p get oc 0 |
| 24786 | xvol 3 2312 |
| 24787 | xpatch q get oc 0 |
| 24788 | xrr 137 6 3 |
| 24789 | ximm 0 255 |
| 24790 | xrr 33 6 0 |
| 24791 | ximm 0 1 |
| 24792 | xrr 57 6 0 |
| 24793 | p = xbranch 1 |
| 24794 | note Sub 1: delete an existing file first (UEFI 13.5 Delete closes the handle), then create. |
| 24795 | xp 0 8 3584 |
| 24796 | xp 0 2 2304 |
| 24797 | ximm 9 3 |
| 24798 | ximm 0 0 |
| 24799 | xmem 137 0 4 32 |
| 24800 | xp 4 2312 8 |
| 24801 | xrr 133 0 0 |
| 24802 | q = xbranch 1 |
| 24803 | xp 4 2304 24 |
| 24804 | ximm 2 0 |
| 24805 | xp 2 2 2304 |
| 24806 | xrr 133 0 0 |
| 24807 | ximm 7 36 |
| 24808 | rw = xbranch 1 |
| 24809 | xpatch rw cleanup |
| 24810 | xpatch q get oc 0 |
| 24811 | ximm 2 0 |
| 24812 | xp 2 2 2304 |
| 24813 | xfio 0 2312 2304 9223372036854775811 36 cleanup |
| 24814 | ximm 0 1 |
| 24815 | xp 2 0 2320 |
| 24816 | ximm 0 0 |
| 24817 | xer 1 0 0 |
| 24818 | xpatch p get oc 0 |
| 24819 | ximm 0 5 |
| 24820 | xrr 57 6 0 |
| 24821 | p = xbranch 0 |
| 24822 | xfio 0 2312 2304 1 36 cleanup |
| 24823 | ximm 0 0 |
| 24824 | xp 2 0 2320 |
| 24825 | q = xbranch 14 |
| 24826 | xpatch p get oc 0 |
| 24827 | xfio 0 2312 2304 3 36 cleanup |
| 24828 | ximm 0 1 |
| 24829 | xp 2 0 2320 |
| 24830 | xpatch q get oc 0 |
| 24831 | ximm 0 1024 |
| 24832 | xp 2 0 2336 |
| 24833 | gi = xg 7 |
| 24834 | xaddr 2 gi |
| 24835 | xp 0 8 2336 |
| 24836 | xp 0 9 2560 |
| 24837 | xp 4 2304 64 |
| 24838 | xrr 133 0 0 |
| 24839 | ximm 7 41 |
| 24840 | p = xbranch 1 |
| 24841 | xpatch p cleanup |
| 24842 | xp 1 0 2568 |
| 24843 | xp 2 0 2328 |
| 24844 | end |
| 24845 | |
| 24846 | |
| 24847 | |
| 24848 | note ======== a64efi: UEFI AArch64 PE32+ application (docs/A64-EFI.md) ======== |
| 24849 | note The default AArch64 code generator with three differences: addresses are base-relative (mataddr), |
| 24850 | note every exit branches to the shared firmware return at file offset 520 (aefx), and there are no host |
| 24851 | note words. Private state is the first 16 KiB of the .bss, whose base stays in X27: 0 ImageHandle, |
| 24852 | note 8 SystemTable, 16..111 X19..X30, 112 the firmware SP, 120..183 D8..D15 (AAPCS64 callee-saved, UEFI |
| 24853 | note 2.10 2.3.6), 184 the address of fn efiexit when the program has one, 192 the status across it. |
| 24854 | note The Omega stack is the rest of the first 8 MiB (X28 = base + 16 KiB), the globals follow. |
| 24855 | |
| 24856 | note aefx: the shared return, X0 = EFI_STATUS. When slot 184 holds a function it is called once on a |
| 24857 | note fresh stack (the slot is cleared first, so a trap inside it returns), then the callee-saved |
| 24858 | note registers and the firmware stack come back and RET returns to the firmware. |
| 24859 | fn aefx to void |
| 24860 | emit 4181747561 |
| 24861 | emit 3036676841 |
| 24862 | emit 4181745520 |
| 24863 | emit 3019899152 |
| 24864 | emit 4177551231 |
| 24865 | emit 4177552224 |
| 24866 | emit 2438988649 |
| 24867 | emit 2432696639 |
| 24868 | emit 2436895612 |
| 24869 | emit 3594453504 |
| 24870 | emit 4181746528 |
| 24871 | emit 4181736297 |
| 24872 | emit 2432696639 |
| 24873 | emit 1833412456 |
| 24874 | emit 1833480042 |
| 24875 | emit 1833547628 |
| 24876 | emit 1833615214 |
| 24877 | emit 2839630707 |
| 24878 | emit 2839698293 |
| 24879 | emit 2839765879 |
| 24880 | emit 2839833465 |
| 24881 | emit 2839968637 |
| 24882 | emit 2839901051 |
| 24883 | emit 3596551104 |
| 24884 | emit 3573764063 |
| 24885 | emit 3577233993 |
| 24886 | emit 3544321321 |
| 24887 | emit 4043311423 |
| 24888 | emit 1409286304 |
| 24889 | emit 3577238017 |
| 24890 | emit 3577233442 |
| 24891 | emit 3577241603 |
| 24892 | emit 335544324 |
| 24893 | emit 3577500161 |
| 24894 | emit 3577495586 |
| 24895 | emit 3577503747 |
| 24896 | emit 3573764063 |
| 24897 | emit 2438988649 |
| 24898 | emit 2432696639 |
| 24899 | emit 2436895612 |
| 24900 | emit 4181754736 |
| 24901 | emit 3019898992 |
| 24902 | emit 4177560447 |
| 24903 | emit 3594453504 |
| 24904 | emit 4181749609 |
| 24905 | emit 4043310399 |
| 24906 | emit 1409286305 |
| 24907 | emit 3531604256 |
| 24908 | emit 4071653376 |
| 24909 | emit 3556769795 |
| 24910 | emit 335544326 |
| 24911 | emit 4043311423 |
| 24912 | emit 1409286273 |
| 24913 | emit 3531604256 |
| 24914 | emit 4071653376 |
| 24915 | emit 3556769794 |
| 24916 | emit 3573751903 |
| 24917 | emit 402653183 |
| 24918 | emit 4043309087 |
| 24919 | emit 1409286305 |
| 24920 | emit 3573759903 |
| 24921 | emit 3573759967 |
| 24922 | emit 3531603968 |
| 24923 | emit 3596551104 |
| 24924 | emit 4043310111 |
| 24925 | emit 1409286305 |
| 24926 | emit 3573758879 |
| 24927 | emit 3573759967 |
| 24928 | emit 3531603968 |
| 24929 | emit 3596551104 |
| 24930 | emit 4043311135 |
| 24931 | emit 1409286273 |
| 24932 | emit 3573759967 |
| 24933 | emit 3531603968 |
| 24934 | emit 3596551104 |
| 24935 | emit 4043312159 |
| 24936 | emit 1409286337 |
| 24937 | emit 3574104863 |
| 24938 | emit 3573758879 |
| 24939 | emit 3573759967 |
| 24940 | emit 3531603968 |
| 24941 | emit 3596551104 |
| 24942 | emit 4043313183 |
| 24943 | emit 1409286273 |
| 24944 | emit 3574300193 |
| 24945 | emit 3531603968 |
| 24946 | emit 3596551104 |
| 24947 | emit 4043314207 |
| 24948 | emit 1409286273 |
| 24949 | emit 3574299169 |
| 24950 | emit 3531603968 |
| 24951 | emit 3596551104 |
| 24952 | emit 4043315231 |
| 24953 | emit 1409286337 |
| 24954 | emit 3574101279 |
| 24955 | emit 3573758879 |
| 24956 | emit 3573759967 |
| 24957 | emit 3531603968 |
| 24958 | emit 3596551104 |
| 24959 | emit 4043316255 |
| 24960 | emit 1409286305 |
| 24961 | emit 3573764063 |
| 24962 | emit 3573759967 |
| 24963 | emit 3531603968 |
| 24964 | emit 3596551104 |
| 24965 | emit 4043317279 |
| 24966 | emit 1409286305 |
| 24967 | emit 3573760767 |
| 24968 | emit 3573759967 |
| 24969 | emit 3531603968 |
| 24970 | emit 3596551104 |
| 24971 | emit 4043318303 |
| 24972 | emit 1409286273 |
| 24973 | emit 3573751903 |
| 24974 | emit 3531603968 |
| 24975 | emit 3596551104 |
| 24976 | emit 4043319327 |
| 24977 | emit 1409286273 |
| 24978 | emit 3573751967 |
| 24979 | emit 3531603968 |
| 24980 | emit 3596551104 |
| 24981 | emit 4043320351 |
| 24982 | emit 1409286273 |
| 24983 | emit 3573751935 |
| 24984 | emit 3531603968 |
| 24985 | emit 3596551104 |
| 24986 | emit 4043325471 |
| 24987 | emit 1409288960 |
| 24988 | emit 4043326495 |
| 24989 | emit 1409292416 |
| 24990 | emit 4043327519 |
| 24991 | emit 1409286816 |
| 24992 | emit 4043328543 |
| 24993 | emit 1409286944 |
| 24994 | emit 4043329567 |
| 24995 | emit 1409294976 |
| 24996 | emit 4043330591 |
| 24997 | emit 1409296576 |
| 24998 | emit 4043331615 |
| 24999 | emit 1409287616 |
| 25000 | emit 4043332639 |
| 25001 | emit 1409287296 |
| 25002 | emit 4043335711 |
| 25003 | emit 1409286816 |
| 25004 | emit 4043336735 |
| 25005 | emit 1409286880 |
| 25006 | emit 4043337759 |
| 25007 | emit 1409286944 |
| 25008 | emit 4043338783 |
| 25009 | emit 1409286944 |
| 25010 | emit 2457862144 |
| 25011 | emit 3596551104 |
| 25012 | emit 2852193248 |
| 25013 | emit 2852258785 |
| 25014 | emit 2852324322 |
| 25015 | emit 3531603971 |
| 25016 | emit 3556769795 |
| 25017 | emit 3596551104 |
| 25018 | emit 2852193248 |
| 25019 | emit 2852258785 |
| 25020 | emit 2852324322 |
| 25021 | emit 3531603971 |
| 25022 | emit 3556769794 |
| 25023 | emit 3596551104 |
| 25024 | emit 3531604064 |
| 25025 | emit 4072177664 |
| 25026 | emit 3556769795 |
| 25027 | emit 3596551104 |
| 25028 | emit 3531604064 |
| 25029 | emit 4072177664 |
| 25030 | emit 3556769794 |
| 25031 | emit 3596551104 |
| 25032 | emit 3370122272 |
| 25033 | emit 3596551104 |
| 25034 | emit 3365927970 |
| 25035 | emit 3531603968 |
| 25036 | emit 3596551104 |
| 25037 | emit 3531604009 |
| 25038 | emit 4177553257 |
| 25039 | emit 4177554273 |
| 25040 | emit 4177555298 |
| 25041 | emit 3573759903 |
| 25042 | emit 3573759967 |
| 25043 | emit 3531603968 |
| 25044 | emit 3596551104 |
| 25045 | emit 4043309119 |
| 25046 | emit 1409286241 |
| 25047 | emit 4181756768 |
| 25048 | emit 3596551104 |
| 25049 | emit 4043310143 |
| 25050 | emit 1409286241 |
| 25051 | emit 2853897184 |
| 25052 | emit 3596551104 |
| 25053 | emit 4043311167 |
| 25054 | emit 1409286241 |
| 25055 | emit 4181757792 |
| 25056 | emit 3596551104 |
| 25057 | emit 4043313215 |
| 25058 | emit 1409286241 |
| 25059 | emit 4181751648 |
| 25060 | emit 3596551104 |
| 25061 | emit 4043314239 |
| 25062 | emit 1409286241 |
| 25063 | emit 4181752672 |
| 25064 | emit 3596551104 |
| 25065 | emit 4043315263 |
| 25066 | emit 1409286241 |
| 25067 | emit 4181759840 |
| 25068 | emit 3596551104 |
| 25069 | emit 4043316287 |
| 25070 | emit 1409286241 |
| 25071 | emit 4181755744 |
| 25072 | emit 3596551104 |
| 25073 | emit 3531603968 |
| 25074 | emit 3596551104 |
| 25075 | emit 4043309119 |
| 25076 | emit 1409286241 |
| 25077 | emit 3577233984 |
| 25078 | emit 3596551104 |
| 25079 | emit 4043310143 |
| 25080 | emit 1409286241 |
| 25081 | emit 3577217184 |
| 25082 | emit 3596551104 |
| 25083 | emit 4043311167 |
| 25084 | emit 1409286241 |
| 25085 | emit 3577413664 |
| 25086 | emit 3596551104 |
| 25087 | emit 4043312191 |
| 25088 | emit 1409286241 |
| 25089 | emit 3577218816 |
| 25090 | emit 3596551104 |
| 25091 | emit 4043313215 |
| 25092 | emit 1409286241 |
| 25093 | emit 3577218048 |
| 25094 | emit 3596551104 |
| 25095 | emit 4043314239 |
| 25096 | emit 1409286241 |
| 25097 | emit 3577221120 |
| 25098 | emit 3596551104 |
| 25099 | emit 4043315263 |
| 25100 | emit 1409286241 |
| 25101 | emit 3577225216 |
| 25102 | emit 3596551104 |
| 25103 | emit 4043316287 |
| 25104 | emit 1409286241 |
| 25105 | emit 3577225280 |
| 25106 | emit 3596551104 |
| 25107 | emit 4043317311 |
| 25108 | emit 1409286241 |
| 25109 | emit 3577258496 |
| 25110 | emit 3596551104 |
| 25111 | emit 4043318335 |
| 25112 | emit 1409286241 |
| 25113 | emit 3577266176 |
| 25114 | emit 3596551104 |
| 25115 | emit 4043319359 |
| 25116 | emit 1409286241 |
| 25117 | emit 3577269408 |
| 25118 | emit 3596551104 |
| 25119 | emit 4043320383 |
| 25120 | emit 1409286241 |
| 25121 | emit 3577269248 |
| 25122 | emit 3596551104 |
| 25123 | emit 4043321407 |
| 25124 | emit 1409286241 |
| 25125 | emit 3577234944 |
| 25126 | emit 3596551104 |
| 25127 | emit 4043322431 |
| 25128 | emit 1409286241 |
| 25129 | emit 3577269344 |
| 25130 | emit 3596551104 |
| 25131 | emit 4043323455 |
| 25132 | emit 1409286241 |
| 25133 | emit 3577269472 |
| 25134 | emit 3596551104 |
| 25135 | emit 4043324479 |
| 25136 | emit 1409286241 |
| 25137 | emit 3577269376 |
| 25138 | emit 3596551104 |
| 25139 | emit 4043325503 |
| 25140 | emit 1409286241 |
| 25141 | emit 3577483520 |
| 25142 | emit 3596551104 |
| 25143 | emit 4043326527 |
| 25144 | emit 1409286241 |
| 25145 | emit 3577483264 |
| 25146 | emit 3596551104 |
| 25147 | emit 4043327551 |
| 25148 | emit 1409286241 |
| 25149 | emit 3577487360 |
| 25150 | emit 3596551104 |
| 25151 | emit 4043328575 |
| 25152 | emit 1409286241 |
| 25153 | emit 3577530784 |
| 25154 | emit 3596551104 |
| 25155 | emit 4043329599 |
| 25156 | emit 1409286241 |
| 25157 | emit 3577238016 |
| 25158 | emit 3596551104 |
| 25159 | emit 4043330623 |
| 25160 | emit 1409286241 |
| 25161 | emit 3577233440 |
| 25162 | emit 3596551104 |
| 25163 | emit 4043331647 |
| 25164 | emit 1409286241 |
| 25165 | emit 3577241600 |
| 25166 | emit 3596551104 |
| 25167 | emit 4043332671 |
| 25168 | emit 1409286241 |
| 25169 | emit 3577430560 |
| 25170 | emit 3596551104 |
| 25171 | emit 4043333695 |
| 25172 | emit 1409286241 |
| 25173 | emit 2432697312 |
| 25174 | emit 3596551104 |
| 25175 | emit 4043334719 |
| 25176 | emit 1409286241 |
| 25177 | emit 3577471520 |
| 25178 | emit 3596551104 |
| 25179 | emit 4043335743 |
| 25180 | emit 1409286241 |
| 25181 | emit 3577471488 |
| 25182 | emit 3596551104 |
| 25183 | emit 3531603968 |
| 25184 | emit 3596551104 |
| 25185 | emit 4043314239 |
| 25186 | emit 1409286305 |
| 25187 | emit 3575123970 |
| 25188 | emit 3573759967 |
| 25189 | emit 3531603968 |
| 25190 | emit 3596551104 |
| 25191 | emit 4043315263 |
| 25192 | emit 1409286305 |
| 25193 | emit 3575128066 |
| 25194 | emit 3573759967 |
| 25195 | emit 3531603968 |
| 25196 | emit 3596551104 |
| 25197 | emit 4043316287 |
| 25198 | emit 1409286305 |
| 25199 | emit 3575128130 |
| 25200 | emit 3573759967 |
| 25201 | emit 3531603968 |
| 25202 | emit 3596551104 |
| 25203 | emit 4043317311 |
| 25204 | emit 1409286305 |
| 25205 | emit 3575161346 |
| 25206 | emit 3573759967 |
| 25207 | emit 3531603968 |
| 25208 | emit 3596551104 |
| 25209 | emit 4043318335 |
| 25210 | emit 1409286305 |
| 25211 | emit 3575169026 |
| 25212 | emit 3573759967 |
| 25213 | emit 3531603968 |
| 25214 | emit 3596551104 |
| 25215 | emit 4043319359 |
| 25216 | emit 1409286305 |
| 25217 | emit 3575172258 |
| 25218 | emit 3573759967 |
| 25219 | emit 3531603968 |
| 25220 | emit 3596551104 |
| 25221 | emit 4043320383 |
| 25222 | emit 1409286305 |
| 25223 | emit 3575172130 |
| 25224 | emit 3573759967 |
| 25225 | emit 3531603968 |
| 25226 | emit 3596551104 |
| 25227 | emit 4043321407 |
| 25228 | emit 1409286305 |
| 25229 | emit 3575137794 |
| 25230 | emit 3573759967 |
| 25231 | emit 3531603968 |
| 25232 | emit 3596551104 |
| 25233 | emit 4043322431 |
| 25234 | emit 1409286305 |
| 25235 | emit 3575172194 |
| 25236 | emit 3573759967 |
| 25237 | emit 3531603968 |
| 25238 | emit 3596551104 |
| 25239 | emit 4043323455 |
| 25240 | emit 1409286305 |
| 25241 | emit 3575172322 |
| 25242 | emit 3573759967 |
| 25243 | emit 3531603968 |
| 25244 | emit 3596551104 |
| 25245 | emit 4043324479 |
| 25246 | emit 1409286305 |
| 25247 | emit 3575172226 |
| 25248 | emit 3573759967 |
| 25249 | emit 3531603968 |
| 25250 | emit 3596551104 |
| 25251 | emit 4043325503 |
| 25252 | emit 1409286305 |
| 25253 | emit 3575386370 |
| 25254 | emit 3573759967 |
| 25255 | emit 3531603968 |
| 25256 | emit 3596551104 |
| 25257 | emit 4043334719 |
| 25258 | emit 1409286305 |
| 25259 | emit 3575374370 |
| 25260 | emit 3573759967 |
| 25261 | emit 3531603968 |
| 25262 | emit 3596551104 |
| 25263 | emit 4043335743 |
| 25264 | emit 1409286305 |
| 25265 | emit 3575374338 |
| 25266 | emit 3573759967 |
| 25267 | emit 3531603968 |
| 25268 | emit 3596551104 |
| 25269 | emit 2457862144 |
| 25270 | emit 3596551104 |
| 25271 | emit 3573764063 |
| 25272 | emit 3577217033 |
| 25273 | emit 3575382025 |
| 25274 | emit 3577217193 |
| 25275 | emit 3575382185 |
| 25276 | emit 3534749705 |
| 25277 | emit 3575386377 |
| 25278 | emit 3573759967 |
| 25279 | emit 3532021737 |
| 25280 | emit 3575386441 |
| 25281 | emit 3575386495 |
| 25282 | emit 3575390495 |
| 25283 | emit 3531604073 |
| 25284 | emit 3575439625 |
| 25285 | emit 3575439487 |
| 25286 | emit 3577218057 |
| 25287 | emit 3545787689 |
| 25288 | emit 3019899113 |
| 25289 | emit 3577530793 |
| 25290 | emit 3531604266 |
| 25291 | emit 2852782377 |
| 25292 | emit 3575433641 |
| 25293 | emit 3573759967 |
| 25294 | emit 3575434015 |
| 25295 | emit 3533702665 |
| 25296 | emit 3575124041 |
| 25297 | emit 2839555114 |
| 25298 | emit 2839622700 |
| 25299 | emit 2839690286 |
| 25300 | emit 2839769120 |
| 25301 | emit 3575161355 |
| 25302 | emit 3575128140 |
| 25303 | emit 3575128074 |
| 25304 | emit 3575128127 |
| 25305 | emit 3573758879 |
| 25306 | emit 3574104863 |
| 25307 | emit 3573758879 |
| 25308 | emit 3574101279 |
| 25309 | emit 3573758879 |
| 25310 | emit 3573759967 |
| 25311 | emit 3575123981 |
| 25312 | emit 3573759967 |
| 25313 | emit 3575398670 |
| 25314 | emit 4181755753 |
| 25315 | emit 3575169033 |
| 25316 | emit 3531634857 |
| 25317 | emit 3575398409 |
| 25318 | emit 3575398447 |
| 25319 | emit 2854159357 |
| 25320 | emit 285199390 |
| 25321 | emit 3573759967 |
| 25322 | emit 3600745440 |
| 25323 | emit 3573764063 |
| 25324 | emit 3577221129 |
| 25325 | emit 2457860393 |
| 25326 | emit 3575123977 |
| 25327 | emit 3573759967 |
| 25328 | emit 2839555114 |
| 25329 | emit 2839622700 |
| 25330 | emit 2839690286 |
| 25331 | emit 2839769120 |
| 25332 | emit 3575161355 |
| 25333 | emit 3575128140 |
| 25334 | emit 3575128074 |
| 25335 | emit 3575128127 |
| 25336 | emit 3573758879 |
| 25337 | emit 3574104863 |
| 25338 | emit 3573758879 |
| 25339 | emit 3574101279 |
| 25340 | emit 3573758879 |
| 25341 | emit 3573759967 |
| 25342 | emit 3575123981 |
| 25343 | emit 3573759967 |
| 25344 | emit 2432696799 |
| 25345 | emit 4181755753 |
| 25346 | emit 3575169033 |
| 25347 | emit 3573759967 |
| 25348 | emit 2854159357 |
| 25349 | emit 285198462 |
| 25350 | emit 3592356320 |
| 25351 | emit 3573764063 |
| 25352 | emit 4181729307 |
| 25353 | emit 2852127713 |
| 25354 | emit 3577233993 |
| 25355 | emit 3544321321 |
| 25356 | emit 4043311423 |
| 25357 | emit 1426060608 |
| 25358 | emit 4043310399 |
| 25359 | emit 1426062208 |
| 25360 | emit 3573751903 |
| 25361 | emit 402653183 |
| 25362 | for i ulong 8 |
| 25363 | emit 3573751839 |
| 25364 | end |
| 25365 | emit 3573764063 |
| 25366 | emit 3577238017 |
| 25367 | emit 3577233442 |
| 25368 | emit 3577241603 |
| 25369 | emit 3531612128 |
| 25370 | emit 2990604288 |
| 25371 | emit 402652704 |
| 25372 | for i ulong 25 |
| 25373 | emit 3573751839 |
| 25374 | end |
| 25375 | emit 3573764063 |
| 25376 | emit 3577238017 |
| 25377 | emit 3577233442 |
| 25378 | emit 3577241603 |
| 25379 | emit 3531612128 |
| 25380 | emit 2990604288 |
| 25381 | emit 402652672 |
| 25382 | for i ulong 25 |
| 25383 | emit 3573751839 |
| 25384 | end |
| 25385 | emit 3573764063 |
| 25386 | emit 3577238017 |
| 25387 | emit 3577233442 |
| 25388 | emit 3577241603 |
| 25389 | emit 3531612128 |
| 25390 | emit 2990604288 |
| 25391 | emit 402652640 |
| 25392 | for i ulong 25 |
| 25393 | emit 3573751839 |
| 25394 | end |
| 25395 | emit 3573764063 |
| 25396 | emit 3577238017 |
| 25397 | emit 3577233442 |
| 25398 | emit 3577241603 |
| 25399 | emit 3531612128 |
| 25400 | emit 2990604288 |
| 25401 | emit 402652608 |
| 25402 | for i ulong 25 |
| 25403 | emit 3573751839 |
| 25404 | end |
| 25405 | emit 3573764063 |
| 25406 | emit 3577238017 |
| 25407 | emit 3577233442 |
| 25408 | emit 3577241603 |
| 25409 | emit 3531612128 |
| 25410 | emit 2990604288 |
| 25411 | emit 402652576 |
| 25412 | for i ulong 25 |
| 25413 | emit 3573751839 |
| 25414 | end |
| 25415 | emit 335544672 |
| 25416 | for i ulong 31 |
| 25417 | emit 3573751839 |
| 25418 | end |
| 25419 | emit 3573764063 |
| 25420 | emit 3577238017 |
| 25421 | emit 3577233442 |
| 25422 | emit 3577241603 |
| 25423 | emit 3531612128 |
| 25424 | emit 2990604288 |
| 25425 | emit 402652512 |
| 25426 | for i ulong 25 |
| 25427 | emit 3573751839 |
| 25428 | end |
| 25429 | emit 3573764063 |
| 25430 | emit 3577238017 |
| 25431 | emit 3577233442 |
| 25432 | emit 3577241603 |
| 25433 | emit 3531612128 |
| 25434 | emit 2990604288 |
| 25435 | emit 402652480 |
| 25436 | for i ulong 25 |
| 25437 | emit 3573751839 |
| 25438 | end |
| 25439 | emit 3573764063 |
| 25440 | emit 3577238017 |
| 25441 | emit 3577233442 |
| 25442 | emit 3577241603 |
| 25443 | emit 3531612128 |
| 25444 | emit 2990604288 |
| 25445 | emit 402652448 |
| 25446 | for i ulong 25 |
| 25447 | emit 3573751839 |
| 25448 | end |
| 25449 | emit 3573764063 |
| 25450 | emit 3577238017 |
| 25451 | emit 3577233442 |
| 25452 | emit 3577241603 |
| 25453 | emit 3531612128 |
| 25454 | emit 2990604288 |
| 25455 | emit 402652416 |
| 25456 | for i ulong 25 |
| 25457 | emit 3573751839 |
| 25458 | end |
| 25459 | emit 3573764063 |
| 25460 | emit 3577238017 |
| 25461 | emit 3577233442 |
| 25462 | emit 3577241603 |
| 25463 | emit 3531612128 |
| 25464 | emit 2990604288 |
| 25465 | emit 402652384 |
| 25466 | for i ulong 25 |
| 25467 | emit 3573751839 |
| 25468 | end |
| 25469 | emit 3573764063 |
| 25470 | emit 3577238017 |
| 25471 | emit 3577233442 |
| 25472 | emit 3577241603 |
| 25473 | emit 3531612128 |
| 25474 | emit 2990604288 |
| 25475 | emit 402652352 |
| 25476 | for i ulong 25 |
| 25477 | emit 3573751839 |
| 25478 | end |
| 25479 | emit 3573764063 |
| 25480 | emit 3577238017 |
| 25481 | emit 3577233442 |
| 25482 | emit 3577241603 |
| 25483 | emit 3531612128 |
| 25484 | emit 2990604288 |
| 25485 | emit 402652320 |
| 25486 | for i ulong 25 |
| 25487 | emit 3573751839 |
| 25488 | end |
| 25489 | emit 3573764063 |
| 25490 | emit 3577238017 |
| 25491 | emit 3577233442 |
| 25492 | emit 3577241603 |
| 25493 | emit 3531612128 |
| 25494 | emit 2990604288 |
| 25495 | emit 402652288 |
| 25496 | for i ulong 25 |
| 25497 | emit 3573751839 |
| 25498 | end |
| 25499 | emit 3573764063 |
| 25500 | emit 3577238017 |
| 25501 | emit 3577233442 |
| 25502 | emit 3577241603 |
| 25503 | emit 3531612128 |
| 25504 | emit 2990604288 |
| 25505 | emit 402652256 |
| 25506 | for i ulong 25 |
| 25507 | emit 3573751839 |
| 25508 | end |
| 25509 | emit 3573764063 |
| 25510 | emit 3577238017 |
| 25511 | emit 3577233442 |
| 25512 | emit 3577241603 |
| 25513 | emit 3531612128 |
| 25514 | emit 2990604288 |
| 25515 | emit 402652224 |
| 25516 | for i ulong 25 |
| 25517 | emit 3573751839 |
| 25518 | end |
| 25519 | emit 2847213536 |
| 25520 | emit 2835419106 |
| 25521 | emit 2835486692 |
| 25522 | emit 2835554278 |
| 25523 | emit 2835621864 |
| 25524 | emit 2835689450 |
| 25525 | emit 2835757036 |
| 25526 | emit 2835824622 |
| 25527 | emit 2835892208 |
| 25528 | emit 2835959794 |
| 25529 | emit 2836036605 |
| 25530 | emit 3577269267 |
| 25531 | emit 2457794153 |
| 25532 | emit 4044353855 |
| 25533 | emit 1409286368 |
| 25534 | emit 4181753705 |
| 25535 | emit 3019898985 |
| 25536 | emit 2853372896 |
| 25537 | emit 3594453280 |
| 25538 | emit 3575172147 |
| 25539 | emit 3573759967 |
| 25540 | emit 2840230909 |
| 25541 | emit 2840154098 |
| 25542 | emit 2840086512 |
| 25543 | emit 2840018926 |
| 25544 | emit 2839951340 |
| 25545 | emit 2839883754 |
| 25546 | emit 2839816168 |
| 25547 | emit 2839748582 |
| 25548 | emit 2839680996 |
| 25549 | emit 2839613410 |
| 25550 | emit 2831878112 |
| 25551 | emit 3600745440 |
| 25552 | end |
| 25553 | |
| 25554 | note aadr: ADRP + ADD of register r to file offset t0 from the current instruction (RVA = offset + 3584) |
| 25555 | fn aadr r ulong t0 ulong to void |
| 25556 | t = add t0 3584 |
| 25557 | d = and sub shr t 12 shr add get oc 0 3584 12 2097151 |
| 25558 | emit or or or 2415919104 shl and d 3 29 shl shr d 2 5 r |
| 25559 | emit or or or 2432696320 shl and t 4095 10 shl r 5 r |
| 25560 | end |
| 25561 | |
| 25562 | note aeof: the entry (X0 ImageHandle, X1 SystemTable): X9 = the .bss page (ADRP, patched once the image |
| 25563 | note size is known), save the callee-saved state, X27 = X9, X28 = X27 + 16 KiB, SP = X27 + 8 MiB, store |
| 25564 | note efiexit's address when there is one, BL main, B to the shared return. Then the PE32+ headers, as |
| 25565 | note x86efi's (xefx 2) with machine 0xAA64 and NX_COMPAT: .text from file offset 512 at RVA 4096, its |
| 25566 | note first 8 bytes an empty base relocation block, .bss after it (zero filled by the loader). |
| 25567 | fn aeof to void |
| 25568 | f = findfn 1852399981 4 0 |
| 25569 | if eq f 0 |
| 25570 | note d2site 604|aeof: syntax: unknown or misplaced word; condition if eq f 0 |
| 25571 | put d2site 0 604 |
| 25572 | fail 16 |
| 25573 | end |
| 25574 | if ne uchar get a_ar add get a_rb 24 sub f 1 0 |
| 25575 | note d2site 605|aeof: word or declaration in a place that does not allow it; condition if ne uchar get a_ar add get a_rb 24 sub f 1 0 |
| 25576 | put d2site 0 605 |
| 25577 | fail 9 |
| 25578 | end |
| 25579 | entry = get oc 0 |
| 25580 | emit 2415919113 |
| 25581 | emit 2835435827 |
| 25582 | emit 2835503413 |
| 25583 | emit 2835570999 |
| 25584 | emit 2835638585 |
| 25585 | emit 2835706171 |
| 25586 | emit 2835773757 |
| 25587 | emit 2432697322 |
| 25588 | emit 4177541418 |
| 25589 | emit 1829217576 |
| 25590 | emit 1829285162 |
| 25591 | emit 1829352748 |
| 25592 | emit 1829420334 |
| 25593 | emit 2835350816 |
| 25594 | emit 2852717563 |
| 25595 | emit 2436895612 |
| 25596 | emit 2438988656 |
| 25597 | emit 2432696863 |
| 25598 | h = findfn 32767063116834405 7 0 |
| 25599 | if ne h 0 |
| 25600 | note the return sequence calls efiexit with no arguments and ignores a result: only `fn efiexit to void` |
| 25601 | note is that function (region 23: the result type, 12 void); anything else is error 9 |
| 25602 | if ne ulong get a_ar add get a_rb 24 sub h 1 0 |
| 25603 | note d2site 606|aeof: word or declaration in a place that does not allow it; condition if ne ulong get a_ar add get a_rb 24 sub h 1 0 |
| 25604 | put d2site 0 606 |
| 25605 | fail 9 |
| 25606 | end |
| 25607 | if ne ulong get a_ar add get a_rb 23 sub h 1 12 |
| 25608 | note d2site 607|aeof: word or declaration in a place that does not allow it; condition if ne ulong get a_ar add get a_rb 23 sub h 1 12 |
| 25609 | put d2site 0 607 |
| 25610 | fail 9 |
| 25611 | end |
| 25612 | aadr 10 get a_ar add get a_rb 22 sub h 1 |
| 25613 | emit 4177551210 |
| 25614 | end |
| 25615 | note bare-metal a64efi metadata and optional hooks: image_base [272], image_end [280], vbar_el1 [264], |
| 25616 | note smp_trampoline [296], el1main [232], smpmain [240], irqhook [248], panichk [256] |
| 25617 | aadr 10 512 |
| 25618 | emit 3510633802 |
| 25619 | emit 4177562474 |
| 25620 | matconst 10 shl shr add add get poolb 0 8388608 4095 12 12 |
| 25621 | emit 2332689258 |
| 25622 | emit 4177563498 |
| 25623 | aadr 10 2560 |
| 25624 | emit 4177561450 |
| 25625 | aadr 10 2484 |
| 25626 | emit 4177565546 |
| 25627 | h = findfn 31078114602871909 7 0 |
| 25628 | if ne h 0 |
| 25629 | aadr 10 get a_ar add get a_rb 22 sub h 1 |
| 25630 | emit 4177557354 |
| 25631 | end |
| 25632 | h = findfn 31078114607000947 7 0 |
| 25633 | if ne h 0 |
| 25634 | aadr 10 get a_ar add get a_rb 22 sub h 1 |
| 25635 | emit 4177558378 |
| 25636 | end |
| 25637 | h = findfn 30240346792358505 7 0 |
| 25638 | if ne h 0 |
| 25639 | aadr 10 get a_ar add get a_rb 22 sub h 1 |
| 25640 | emit 4177559402 |
| 25641 | end |
| 25642 | h = findfn 30232598687932784 7 0 |
| 25643 | if ne h 0 |
| 25644 | aadr 10 get a_ar add get a_rb 22 sub h 1 |
| 25645 | emit 4177560426 |
| 25646 | end |
| 25647 | emit or 2483027968 bdisp get oc 0 get a_ar add get a_rb 22 sub f 1 26 |
| 25648 | if eq uchar get a_ar add get a_rb 23 sub f 1 12 |
| 25649 | emit 3531603968 |
| 25650 | end |
| 25651 | emit or 335544320 bdisp get oc 0 520 26 |
| 25652 | while ne and get oc 0 511 0 |
| 25653 | emit 0 |
| 25654 | end |
| 25655 | raw = sub get oc 0 512 |
| 25656 | bs = shl shr add add raw 4096 4095 12 12 |
| 25657 | d = and sub shr bs 12 shr add entry 3584 12 2097151 |
| 25658 | wrword entry or or or 2415919104 shl and d 3 29 shl shr d 2 5 9 |
| 25659 | wrword 0 23117 |
| 25660 | wrword 60 64 |
| 25661 | wrword 64 17744 |
| 25662 | wrword 68 174692 |
| 25663 | wrword 84 2228464 |
| 25664 | wrword 88 523 |
| 25665 | wrword 92 raw |
| 25666 | wrword 100 add get poolb 0 8388608 |
| 25667 | wrword 104 add entry 3584 |
| 25668 | wrword 108 4096 |
| 25669 | wrword 112 4194304 |
| 25670 | wrword 120 4096 |
| 25671 | wrword 124 512 |
| 25672 | wrword 128 6 |
| 25673 | wrword 136 6 |
| 25674 | wrword 144 shl shr add add bs add get poolb 0 8388608 4095 12 12 |
| 25675 | wrword 148 512 |
| 25676 | wrword 156 20971530 |
| 25677 | wrword 160 1048576 |
| 25678 | wrword 168 4096 |
| 25679 | wrword 176 1048576 |
| 25680 | wrword 184 4096 |
| 25681 | wrword 196 16 |
| 25682 | wrword 512 0 |
| 25683 | wrword 516 8 |
| 25684 | wrword 240 4096 |
| 25685 | wrword 244 8 |
| 25686 | wrword 328 2019914798 |
| 25687 | wrword 332 116 |
| 25688 | wrword 336 raw |
| 25689 | wrword 340 4096 |
| 25690 | wrword 344 raw |
| 25691 | wrword 348 512 |
| 25692 | wrword 364 1610612768 |
| 25693 | wrword 368 1936941614 |
| 25694 | wrword 376 add get poolb 0 8388608 |
| 25695 | wrword 380 bs |
| 25696 | wrword 404 3221225600 |
| 25697 | writeout 0 |
| 25698 | end |
| 25699 | |
| 25700 | note aret: the result of a firmware word, X0 as a ulong, after the saved registers come back |
| 25701 | fn aret dst ulong x ulong to void |
| 25702 | sl = get a_ar add get a_rb 77 add x 7 |
| 25703 | r = restore dst sl get svn 0 get sva 0 1 |
| 25704 | vdone 1 r 5 |
| 25705 | end |
| 25706 | |
| 25707 | note aefival: efi OP ARG A OFF N -> ulong, the contract of x86efi's word. OP is a literal 0..14, A writable |
| 25708 | note uchar storage with OFF + N inside it (trap 3). Here the operation is Omega code: the word is a call of |
| 25709 | note the program's own fn efirt op arg addr n (four ulong, result ulong), which must be defined above its |
| 25710 | note first use (error 16) and reaches the firmware through the fw words. |
| 25711 | fn aefival dst ulong to void |
| 25712 | x = mul get depth 0 32 |
| 25713 | put a_ar add get a_rb 77 add x 7 get nslot 0 |
| 25714 | op = lenval 4 |
| 25715 | if gt op 14 |
| 25716 | note d2site 608|aefival: unknown target, an AArch64-only path on another target, or an x86efi refusal (bare unit, Linux host word, efi OP literal outside 0..14); condition if gt op 14 |
| 25717 | put d2site 0 608 |
| 25718 | fail 25 |
| 25719 | end |
| 25720 | harg x 2 5 |
| 25721 | e = harray x 1 |
| 25722 | f = findfn 500135716453 5 0 |
| 25723 | if eq f 0 |
| 25724 | note d2site 609|aefival: syntax: unknown or misplaced word; condition if eq f 0 |
| 25725 | put d2site 0 609 |
| 25726 | fail 16 |
| 25727 | end |
| 25728 | note efirt takes four ulong values and gives a ulong: anything else is error 9 here, not a wrong call at |
| 25729 | note run time (parameter i of function f is entry (f - 1) * 6 + i: region 37 its kind, 0 a scalar; region |
| 25730 | note 35 its type, 5 ulong) |
| 25731 | if ne ulong get a_ar add get a_rb 24 sub f 1 4 |
| 25732 | note d2site 610|aefival: word or declaration in a place that does not allow it; condition if ne ulong get a_ar add get a_rb 24 sub f 1 4 |
| 25733 | put d2site 0 610 |
| 25734 | fail 9 |
| 25735 | end |
| 25736 | if ne ulong get a_ar add get a_rb 23 sub f 1 5 |
| 25737 | note d2site 611|aefival: word or declaration in a place that does not allow it; condition if ne ulong get a_ar add get a_rb 23 sub f 1 5 |
| 25738 | put d2site 0 611 |
| 25739 | fail 9 |
| 25740 | end |
| 25741 | for i ulong 4 |
| 25742 | pe = add mul sub f 1 6 i |
| 25743 | if ne a_gu 37 pe 0 |
| 25744 | note d2site 612|aefival: word or declaration in a place that does not allow it; condition if ne a_gu 37 pe 0 |
| 25745 | put d2site 0 612 |
| 25746 | fail 9 |
| 25747 | end |
| 25748 | if ne ulong a_gu 35 pe 5 |
| 25749 | note d2site 613|aefival: word or declaration in a place that does not allow it; condition if ne ulong a_gu 35 pe 5 |
| 25750 | put d2site 0 613 |
| 25751 | fail 9 |
| 25752 | end |
| 25753 | end |
| 25754 | save |
| 25755 | hload x 2 1 |
| 25756 | basearg 2 e |
| 25757 | loadarg 16 1 get a_ar add get a_rb 77 add x 21 |
| 25758 | e3 2332033024 2 2 16 |
| 25759 | loadarg 3 1 get a_ar add get a_rb 77 add x 22 |
| 25760 | matconst 0 op |
| 25761 | emit or 2483027968 bdisp get oc 0 get a_ar add get a_rb 22 sub f 1 26 |
| 25762 | aret dst x |
| 25763 | end |
| 25764 | |
| 25765 | note afw: the firmware words, all ulong in and out. They carry raw addresses, which no other word does: |
| 25766 | note fwcall F A0 A1 A2 A3 A4 A5: BLR F with A0..A5 in X0..X5 (AAPCS64), result X0; 64 KiB of stack must |
| 25767 | note be free (trap 6). fwld ADDR W / fwst ADDR W V: load or store W = 1, 2, 4 or 8 bytes (another W is 1) at |
| 25768 | note ADDR; fwst gives 0. fwsys K: 0 ImageHandle, 1 SystemTable, 2 CNTVCT_EL0 after ISB, 3 CNTFRQ_EL0, else |
| 25769 | note MIDR_EL1. fwadr A OFF N: the address of A[OFF], with OFF + N inside A (trap 3). |
| 25770 | fn afw c ulong dst ulong to void |
| 25771 | x = mul get depth 0 32 |
| 25772 | put a_ar add get a_rb 77 add x 7 get nslot 0 |
| 25773 | if eq c 254 |
| 25774 | e = harray x 1 |
| 25775 | save |
| 25776 | basearg 0 e |
| 25777 | loadarg 16 1 get a_ar add get a_rb 77 add x 21 |
| 25778 | e3 2332033024 0 0 16 |
| 25779 | aret dst x |
| 25780 | ret |
| 25781 | end |
| 25782 | np = ulong 7 |
| 25783 | if eq c 251 |
| 25784 | np = ulong 2 |
| 25785 | end |
| 25786 | if eq c 252 |
| 25787 | np = ulong 3 |
| 25788 | end |
| 25789 | if eq c 253 |
| 25790 | np = ulong 1 |
| 25791 | end |
| 25792 | if eq c 255 |
| 25793 | np = ulong 4 |
| 25794 | end |
| 25795 | for i ulong np |
| 25796 | harg x i 5 |
| 25797 | end |
| 25798 | save |
| 25799 | for i ulong np |
| 25800 | hload x i i |
| 25801 | end |
| 25802 | if eq c 250 |
| 25803 | emit 3510649840 |
| 25804 | emit 3944481311 |
| 25805 | trapc 3 6 |
| 25806 | emit 2852127728 |
| 25807 | emit 2852193248 |
| 25808 | emit 2852258785 |
| 25809 | emit 2852324322 |
| 25810 | emit 2852389859 |
| 25811 | emit 2852455396 |
| 25812 | emit 2852520933 |
| 25813 | emit 3594453504 |
| 25814 | end |
| 25815 | if eq c 251 |
| 25816 | emit 4043317311 |
| 25817 | emit 1409286368 |
| 25818 | emit 4043313215 |
| 25819 | emit 1409286368 |
| 25820 | emit 4043311167 |
| 25821 | emit 1409286368 |
| 25822 | emit 960495616 |
| 25823 | emit 335544326 |
| 25824 | emit 4181721088 |
| 25825 | emit 335544324 |
| 25826 | emit 3107979264 |
| 25827 | emit 335544322 |
| 25828 | emit 2034237440 |
| 25829 | end |
| 25830 | if eq c 252 |
| 25831 | emit 4043317311 |
| 25832 | emit 1409286368 |
| 25833 | emit 4043313215 |
| 25834 | emit 1409286368 |
| 25835 | emit 4043311167 |
| 25836 | emit 1409286368 |
| 25837 | emit 956301314 |
| 25838 | emit 335544326 |
| 25839 | emit 4177526786 |
| 25840 | emit 335544324 |
| 25841 | emit 3103784962 |
| 25842 | emit 335544322 |
| 25843 | emit 2030043138 |
| 25844 | emit 3531603968 |
| 25845 | end |
| 25846 | if eq c 253 |
| 25847 | emit 4043311135 |
| 25848 | emit 1409286339 |
| 25849 | emit 1409286368 |
| 25850 | emit 4043312159 |
| 25851 | emit 1409286400 |
| 25852 | emit 3577217024 |
| 25853 | emit 335544327 |
| 25854 | emit 4167072608 |
| 25855 | emit 335544325 |
| 25856 | emit 3573759967 |
| 25857 | emit 3577471040 |
| 25858 | emit 335544322 |
| 25859 | emit 3577470976 |
| 25860 | end |
| 25861 | if eq c 255 |
| 25862 | emit or 2483027968 bdisp get oc 0 752 26 |
| 25863 | end |
| 25864 | aret dst x |
| 25865 | end |
| 25866 | |
| 25867 | note Native object mode is opt-in with object then om2. Existing profiles retain their artifacts. |
| 25868 | note An import has an ordinary compiler-checked signature but no body or address. |
| 25869 | fn s_extern to void |
| 25870 | if ne get curret 0 0 |
| 25871 | note d2site 614|s_extern: missing end; condition if ne get curret 0 0 |
| 25872 | put d2site 0 614 |
| 25873 | fail 15 |
| 25874 | end |
| 25875 | tok |
| 25876 | if or ne get tk 0 1 ne get tw 0 28262 |
| 25877 | note d2site 615|s_extern: syntax: unknown or misplaced word; condition if or ne get tk 0 1 ne get tw 0 28262 |
| 25878 | put d2site 0 615 |
| 25879 | fail 16 |
| 25880 | end |
| 25881 | put expf 0 2 |
| 25882 | s_fn |
| 25883 | put expf 0 0 |
| 25884 | end |
| 25885 | |
| 25886 | fn obj_import f ulong to void |
| 25887 | if ne a_gu 27 f 0 |
| 25888 | note d2site 616|obj_import: word or declaration in a place that does not allow it; condition if ne a_gu 27 f 0 |
| 25889 | put d2site 0 616 |
| 25890 | fail 9 |
| 25891 | end |
| 25892 | obj_signature f |
| 25893 | a_p 22 f 0 |
| 25894 | put curret 0 0 |
| 25895 | put curfn 0 0 |
| 25896 | nm_set get nglob 0 |
| 25897 | end |
| 25898 | |
| 25899 | note Version 1 external interfaces carry primitive scalars and arrays. Nominal layouts need |
| 25900 | note a separately versioned type identity; refusing them avoids equating unrelated definitions. |
| 25901 | fn obj_signature f ulong to void |
| 25902 | if gt a_gu 23 f 13 |
| 25903 | note d2site 617|obj_signature: type mismatch; condition if gt a_gu 23 f 13 |
| 25904 | put d2site 0 617 |
| 25905 | fail 7 |
| 25906 | end |
| 25907 | i = ulong 0 |
| 25908 | while lt i ulong a_gu 24 f |
| 25909 | p = add mul f 6 i |
| 25910 | if gt a_gu 35 p 13 |
| 25911 | note d2site 618|obj_signature: type mismatch; condition if gt a_gu 35 p 13 |
| 25912 | put d2site 0 618 |
| 25913 | fail 7 |
| 25914 | end |
| 25915 | k = ulong a_gu 37 p |
| 25916 | if and ne k 0 and ne k 2 ne k 3 |
| 25917 | note d2site 619|obj_signature: type mismatch; condition if and ne k 0 and ne k 2 ne k 3 |
| 25918 | put d2site 0 619 |
| 25919 | fail 7 |
| 25920 | end |
| 25921 | if ne a_gu 38 p 0 |
| 25922 | note d2site 620|obj_signature: type mismatch; condition if ne a_gu 38 p 0 |
| 25923 | put d2site 0 620 |
| 25924 | fail 7 |
| 25925 | end |
| 25926 | if and eq a_gu 32 f 2 ne a_gu 39 p 0 |
| 25927 | note d2site 621|obj_signature: fresh element read before it is definitely written, or fresh array passed on; condition if and eq a_gu 32 f 2 ne a_gu 39 p 0 |
| 25928 | put d2site 0 621 |
| 25929 | fail 27 |
| 25930 | end |
| 25931 | i = add i 1 |
| 25932 | end |
| 25933 | end |
| 25934 | |
| 25935 | fn obj64 v ulong to void |
| 25936 | emit and v 4294967295 |
| 25937 | emit shr v 32 |
| 25938 | end |
| 25939 | |
| 25940 | fn objhdr at ulong v ulong to void |
| 25941 | wrword at and v 4294967295 |
| 25942 | wrword add at 4 shr v 32 |
| 25943 | end |
| 25944 | |
| 25945 | fn obj_fn f ulong to void |
| 25946 | obj_signature f |
| 25947 | obj64 ulong a_gu 32 f |
| 25948 | obj64 a_g 22 f |
| 25949 | obj64 ulong a_gu 23 f |
| 25950 | obj64 ulong a_gu 24 f |
| 25951 | obj64 a_g 86 f |
| 25952 | n = a_g 25 f |
| 25953 | obj64 n |
| 25954 | p = a_g 26 f |
| 25955 | i = ulong 0 |
| 25956 | while lt i n |
| 25957 | emitb a_ib add p i |
| 25958 | i = add i 1 |
| 25959 | end |
| 25960 | while ne and get oc 0 7 0 |
| 25961 | emitb 0 |
| 25962 | end |
| 25963 | i = ulong 0 |
| 25964 | while lt i ulong a_gu 24 f |
| 25965 | p = add mul f 6 i |
| 25966 | obj64 ulong a_gu 35 p |
| 25967 | obj64 ulong a_gu 37 p |
| 25968 | obj64 a_g 36 p |
| 25969 | obj64 ulong a_gu 38 p |
| 25970 | obj64 ulong a_gu 39 p |
| 25971 | i = add i 1 |
| 25972 | end |
| 25973 | end |
| 25974 | |
| 25975 | note Object header, native payload and compiler-produced symbols/call relocations. No executable |
| 25976 | note header is emitted. The linker owns identity verification and cross-object graph/stack checks. |
| 25977 | fn obj_write to void |
| 25978 | ce = get oc 0 |
| 25979 | i = ulong 0 |
| 25980 | while lt i 176 |
| 25981 | wrword i 0 |
| 25982 | i = add i 4 |
| 25983 | end |
| 25984 | objhdr 0 3544386002238786895 |
| 25985 | objhdr 8 1 |
| 25986 | objhdr 16 1 |
| 25987 | objhdr 24 get crel 0 |
| 25988 | objhdr 32 176 |
| 25989 | objhdr 40 ce |
| 25990 | objhdr 48 get nf 0 |
| 25991 | objhdr 56 get ncalls 0 |
| 25992 | objhdr 64 get nexp 0 |
| 25993 | at = ulong 176 |
| 25994 | f = ulong 0 |
| 25995 | go = true |
| 25996 | while go |
| 25997 | chunk = ulong 0 |
| 25998 | while and go lt chunk 999999 |
| 25999 | if ge f get nf 0 |
| 26000 | go = false |
| 26001 | else |
| 26002 | if eq a_gu 32 f 1 |
| 26003 | wrword at or 335544320 bdisp at a_g 22 f 26 |
| 26004 | at = add at 4 |
| 26005 | end |
| 26006 | f = add f 1 |
| 26007 | end |
| 26008 | chunk = add chunk 1 |
| 26009 | end |
| 26010 | end |
| 26011 | put objmeta 0 1 |
| 26012 | f = ulong 0 |
| 26013 | go = true |
| 26014 | while go |
| 26015 | chunk = ulong 0 |
| 26016 | while and go lt chunk 999999 |
| 26017 | if ge f get nf 0 |
| 26018 | go = false |
| 26019 | else |
| 26020 | obj_fn f |
| 26021 | f = add f 1 |
| 26022 | end |
| 26023 | chunk = add chunk 1 |
| 26024 | end |
| 26025 | end |
| 26026 | i = ulong 0 |
| 26027 | go = true |
| 26028 | while go |
| 26029 | chunk = ulong 0 |
| 26030 | while and go lt chunk 999999 |
| 26031 | if ge i get ncalls 0 |
| 26032 | go = false |
| 26033 | else |
| 26034 | obj64 a_g 41 i |
| 26035 | obj64 sub a_g 42 i 1 |
| 26036 | obj64 sub a_g 43 i 1 |
| 26037 | obj64 a_g 87 i |
| 26038 | i = add i 1 |
| 26039 | end |
| 26040 | chunk = add chunk 1 |
| 26041 | end |
| 26042 | end |
| 26043 | a_ceilo get oc 0 |
| 26044 | if eq a_out 1 1 0 get oc 0 0 |
| 26045 | note d2site 622|obj_write: the compiler's standard output could not be written; condition if eq a_out 1 1 0 get oc 0 0 |
| 26046 | put d2site 0 622 |
| 26047 | fail 2 |
| 26048 | end |
| 26049 | rc_emit 0 |
| 26050 | exit int 0 |
| 26051 | end |