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 / bridge / babel / src / 50-diff.om
| 1 | note babel 50-diff: toolchains, target builds and the differential test. |
| 2 | note For every exported unit babel runs the same vectors through three legs: the ORIGINAL C function |
| 3 | note (cc, verbatim text), the lowered Omega unit (pinned omc) and the generated target. A unit is |
| 4 | note TRANSLATED only when all three outputs are byte-identical on every vector. |
| 5 | global Bv ulong 9 |
| 6 | global Sm ulong 1 |
| 7 | global Tok ulong 8 |
| 8 | global Brc ulong 1 |
| 9 | global Trc ulong 1 |
| 10 | global Tsr ulong 1 |
| 11 | global Ubd ulong 1024 |
| 12 | note leg results of unit u at Ulg[3u + k], k 0 original C, 1 Omega, 2 target: |
| 13 | note 0 not required (the unit never reached the differential), 1 PASS, 2 FAIL, 3 NOT_RUN |
| 14 | global Ulg ulong 3072 |
| 15 | text TnCc "cc" |
| 16 | text TnCargo "cargo" |
| 17 | text TnPy "python3" |
| 18 | text TnCpp "g++" |
| 19 | text TnCpp2 "c++" |
| 20 | text TnZig "zig" |
| 21 | text TnGo "go" |
| 22 | text EvZig "ZIG=" |
| 23 | text EvGo "GO=" |
| 24 | text AVer "--version" |
| 25 | text AVer2 "version" |
| 26 | text ABuild "build" |
| 27 | text ATest "test" |
| 28 | text AOff "--offline" |
| 29 | text AQuiet "--quiet" |
| 30 | text AMan "--manifest-path" |
| 31 | text AStd17 "-std=c17" |
| 32 | text AStdx "-std=c++17" |
| 33 | text AO0 "-O0" |
| 34 | text Aw "-w" |
| 35 | text Ao "-o" |
| 36 | text AB "-B" |
| 37 | text AExe "build-exe" |
| 38 | text AOd "-O" |
| 39 | text ADbg "Debug" |
| 40 | text Alc "-lc" |
| 41 | text AEmit "-femit-bin=" |
| 42 | text ADot "." |
| 43 | text EvZg1 "ZIG_GLOBAL_CACHE_DIR=" |
| 44 | text EvZg2 "ZIG_LOCAL_CACHE_DIR=" |
| 45 | text EvGoc "GOCACHE=" |
| 46 | text WZg1 "zig-global" |
| 47 | text WZg2 "zig-local" |
| 48 | text WGoc "go-build" |
| 49 | text WOrc "oracle" |
| 50 | text WOmd "omega-driver" |
| 51 | text PRsMan "rust/Cargo.toml" |
| 52 | text PRsExe "rust/target/debug/babel_diff" |
| 53 | text PCExe "c/.build/babel_diff" |
| 54 | text PCBld "c/.build" |
| 55 | text PCpBld "cpp/.build/" |
| 56 | text PZExe "zig/.build/babel_diff" |
| 57 | text PZBld "zig/.build" |
| 58 | text PGoBld "go/.build/" |
| 59 | text PVec "/vectors.txt" |
| 60 | text POut1 "/c-original.out" |
| 61 | text POut2 "/omega.out" |
| 62 | text POut3 "/target.out" |
| 63 | text PBlog "diff/build.log" |
| 64 | text PBlogU "/build.log" |
| 65 | text PTlog "diff/test.log" |
| 66 | text RsOrc "differential oracle failed: the original C function did not build or run with cc (see diff/" |
| 67 | text RsOrc2 "/oracle.c): " |
| 68 | text RsOmd "Omega leg failed: the lowered unit plus the babel driver did not compile or run with the pinned omc (see diff/" |
| 69 | text RsOmd2 "/driver.om): " |
| 70 | text RsPrep "could not write the differential files under diff/" |
| 71 | text RsTbd "target build failed (see diff/build.log): " |
| 72 | text RsTbdU "target build failed (see diff/" |
| 73 | text RsTbdU2 "/build.log): " |
| 74 | text RsTrn "target driver failed on the vectors (see diff/" |
| 75 | text RsTrn2 "/target.out): " |
| 76 | text RsMo "Omega leg differs from the original C on " |
| 77 | text RsMt "target output differs from the original C on " |
| 78 | text RsOf " of " |
| 79 | text RsVec " vectors (see diff/" |
| 80 | text RsVe "/)" |
| 81 | text RsNoCc "no C compiler (cc) on PATH: the differential oracle cannot run, so nothing can be called TRANSLATED" |
| 82 | |
| 83 | fn vinit to void |
| 84 | put Bv 0 0 |
| 85 | put Bv 1 1 |
| 86 | put Bv 2 2 |
| 87 | put Bv 3 sub shl ulong 1 32 1 |
| 88 | put Bv 4 shl ulong 1 32 |
| 89 | put Bv 5 sub shl ulong 1 63 1 |
| 90 | put Bv 6 shl ulong 1 63 |
| 91 | put Bv 7 sub ulong 0 2 |
| 92 | put Bv 8 sub ulong 0 1 |
| 93 | end |
| 94 | |
| 95 | fn hilo h ulong l ulong to ulong |
| 96 | ret or shl h 32 l |
| 97 | end |
| 98 | |
| 99 | note splitmix64; seed fixed so every run uses the same vectors |
| 100 | fn smx to ulong |
| 101 | s = add get Sm 0 hilo 2654435769 2135587861 |
| 102 | put Sm 0 s |
| 103 | z = mul xor s shr s 30 hilo 3210233709 484763065 |
| 104 | z = mul xor z shr z 27 hilo 2496678331 321982955 |
| 105 | ret xor z shr z 31 |
| 106 | end |
| 107 | |
| 108 | note systematic vector count for arity k: product of the 9 boundary values up to k = 3, 81 rows after |
| 109 | fn nsys k ulong to ulong |
| 110 | if eq k 0 |
| 111 | ret 1 |
| 112 | end |
| 113 | if eq k 1 |
| 114 | ret 9 |
| 115 | end |
| 116 | if eq k 2 |
| 117 | ret 81 |
| 118 | end |
| 119 | if eq k 3 |
| 120 | ret 729 |
| 121 | end |
| 122 | ret 81 |
| 123 | end |
| 124 | |
| 125 | fn sysval k ulong j ulong i ulong to ulong |
| 126 | if le k 3 |
| 127 | d = ulong 1 |
| 128 | for t ulong sub sub k 1 i |
| 129 | d = mul d 9 |
| 130 | end |
| 131 | ret get Bv rem div j d 9 |
| 132 | end |
| 133 | ret get Bv rem add j mul i add 1 div j 9 9 |
| 134 | end |
| 135 | |
| 136 | note vectors.txt for unit u: "id n" then one vector per line; stored in the pool (Uv0/Uvn, Unv) |
| 137 | fn genvec u ulong to void |
| 138 | k = get Uar u |
| 139 | ns = nsys k |
| 140 | nr = ulong 64 |
| 141 | if eq k 0 |
| 142 | nr = 0 |
| 143 | end |
| 144 | put Sm 0 20261026 |
| 145 | m = mark |
| 146 | bu get Uid u |
| 147 | bc 32 |
| 148 | bu add ns nr |
| 149 | bc 10 |
| 150 | for j ulong ns |
| 151 | for i ulong k |
| 152 | if gt i 0 |
| 153 | bc 32 |
| 154 | end |
| 155 | bu sysval k j i |
| 156 | end |
| 157 | bc 10 |
| 158 | end |
| 159 | for j ulong nr |
| 160 | for i ulong k |
| 161 | if gt i 0 |
| 162 | bc 32 |
| 163 | end |
| 164 | bu smx |
| 165 | end |
| 166 | bc 10 |
| 167 | end |
| 168 | n = sub mark m |
| 169 | put Uv0 u psave m n |
| 170 | put Uvn u n |
| 171 | put Unv u add ns nr |
| 172 | reset m |
| 173 | end |
| 174 | |
| 175 | note tool slot s: 0 cc, 1 cargo, 2 python3, 3 g++, 4 zig, 5 go (env ZIG / GO override PATH) |
| 176 | fn tfind s ulong nm view uchar * to void |
| 177 | if which nm |
| 178 | put Tok s 1 |
| 179 | put Tl0 s get Gv0 0 |
| 180 | put Tln s get Gvn 0 |
| 181 | end |
| 182 | end |
| 183 | |
| 184 | fn tools to void |
| 185 | tfind 0 TnCc |
| 186 | tfind 1 TnCargo |
| 187 | tfind 2 TnPy |
| 188 | tfind 3 TnCpp |
| 189 | if eq get Tok 3 0 |
| 190 | tfind 3 TnCpp2 |
| 191 | end |
| 192 | if getenv EvZig |
| 193 | tenv 4 |
| 194 | else |
| 195 | tfind 4 TnZig |
| 196 | end |
| 197 | if getenv EvGo |
| 198 | tenv 5 |
| 199 | else |
| 200 | tfind 5 TnGo |
| 201 | end |
| 202 | for s ulong 6 |
| 203 | if eq get Tok s 1 |
| 204 | tver s |
| 205 | end |
| 206 | end |
| 207 | end |
| 208 | |
| 209 | note tool slot s from an environment override (Gv0/Gvn): found only when the path is executable |
| 210 | fn tenv s ulong to void |
| 211 | m = mark |
| 212 | bpl get Gv0 0 get Gvn 0 |
| 213 | r = faccess Ob m sub mark m 1 |
| 214 | reset m |
| 215 | if ne r 0 |
| 216 | ret |
| 217 | end |
| 218 | put Tok s 1 |
| 219 | put Tl0 s get Gv0 0 |
| 220 | put Tln s get Gvn 0 |
| 221 | end |
| 222 | |
| 223 | note first line of "<tool> --version" (zig/go: "version") into Tv0/Tvn |
| 224 | fn tver s ulong to void |
| 225 | m = mark |
| 226 | rclr |
| 227 | kenv |
| 228 | kpl get Tl0 s get Tln s |
| 229 | if ge s 4 |
| 230 | ktx AVer2 |
| 231 | else |
| 232 | ktx AVer |
| 233 | end |
| 234 | a = mark |
| 235 | bwk WkOut |
| 236 | b = mark |
| 237 | rset 2 a b |
| 238 | put Rmg 0 1 |
| 239 | r = spawn |
| 240 | reset m |
| 241 | if ne r 0 |
| 242 | ret |
| 243 | end |
| 244 | a = mark |
| 245 | bwk WkOut |
| 246 | b = mark |
| 247 | q = rfile a b |
| 248 | reset m |
| 249 | if le q 0 |
| 250 | ret |
| 251 | end |
| 252 | j = ulong 0 |
| 253 | while lt j ulong q bound 999999 |
| 254 | if eq get Fb j 10 |
| 255 | break |
| 256 | end |
| 257 | j = add j 1 |
| 258 | end |
| 259 | if gt j 200 |
| 260 | j = 200 |
| 261 | end |
| 262 | bfb 0 j |
| 263 | put Tv0 s psave m j |
| 264 | put Tvn s j |
| 265 | reset m |
| 266 | end |
| 267 | |
| 268 | note tool slot of the selected target |
| 269 | fn tslot to ulong |
| 270 | g = get Lg 0 |
| 271 | if eq g 1 |
| 272 | ret 0 |
| 273 | end |
| 274 | if eq g 2 |
| 275 | ret 1 |
| 276 | end |
| 277 | if eq g 3 |
| 278 | ret 2 |
| 279 | end |
| 280 | if eq g 6 |
| 281 | ret 3 |
| 282 | end |
| 283 | if eq g 5 |
| 284 | ret 4 |
| 285 | end |
| 286 | ret 5 |
| 287 | end |
| 288 | |
| 289 | note argv helpers: <out>/<s>, <out>/<s><name><t> |
| 290 | fn kout s view uchar * to void |
| 291 | m = mark |
| 292 | bouts s |
| 293 | kob m sub mark m |
| 294 | reset m |
| 295 | end |
| 296 | |
| 297 | note <out>/<s><name> onto argv |
| 298 | fn kouto s view uchar * u ulong to void |
| 299 | m = mark |
| 300 | bouts s |
| 301 | bname u |
| 302 | kob m sub mark m |
| 303 | reset m |
| 304 | end |
| 305 | |
| 306 | fn koutn s view uchar * u ulong t view uchar * to void |
| 307 | m = mark |
| 308 | bouts s |
| 309 | bname u |
| 310 | bs t |
| 311 | kob m sub mark m |
| 312 | reset m |
| 313 | end |
| 314 | |
| 315 | fn ktool s ulong to void |
| 316 | kpl get Tl0 s get Tln s |
| 317 | end |
| 318 | |
| 319 | note stdin /dev/null, stdout and stderr merged into <out>/<s> |
| 320 | fn rlog s view uchar * to void |
| 321 | a = mark |
| 322 | bouts s |
| 323 | b = mark |
| 324 | rset 2 a b |
| 325 | put Rmg 0 1 |
| 326 | end |
| 327 | |
| 328 | note env-style NAME=<out>/.work/<s> argument |
| 329 | fn kenvwk e view uchar * s view uchar * to void |
| 330 | m = mark |
| 331 | bs e |
| 332 | bwk s |
| 333 | kob m sub mark m |
| 334 | reset m |
| 335 | end |
| 336 | |
| 337 | fn mkout s view uchar * to void |
| 338 | m = mark |
| 339 | bouts s |
| 340 | e = mark |
| 341 | q = mkdirs m e |
| 342 | reset m |
| 343 | end |
| 344 | |
| 345 | note build the selected target project once (per unit for cpp and go, into Ubd); log diff/build.log |
| 346 | fn tbuild to void |
| 347 | g = get Lg 0 |
| 348 | s = tslot |
| 349 | put Brc 0 0 |
| 350 | if eq get Tok s 0 |
| 351 | put Brc 0 255 |
| 352 | ret |
| 353 | end |
| 354 | m = mark |
| 355 | rclr |
| 356 | kenv |
| 357 | if eq g 2 |
| 358 | ktool 1 |
| 359 | ktx ABuild |
| 360 | ktx AOff |
| 361 | ktx AQuiet |
| 362 | ktx AMan |
| 363 | kout PRsMan |
| 364 | end |
| 365 | if eq g 3 |
| 366 | ktool 2 |
| 367 | ktx AB |
| 368 | kout PPyMain |
| 369 | end |
| 370 | if eq g 1 |
| 371 | mkout PCBld |
| 372 | cbuild |
| 373 | end |
| 374 | if eq g 5 |
| 375 | mkout PZBld |
| 376 | zbuild |
| 377 | end |
| 378 | if eq g 6 |
| 379 | reset m |
| 380 | ubuild |
| 381 | ret |
| 382 | end |
| 383 | if eq g 4 |
| 384 | reset m |
| 385 | ubuild |
| 386 | ret |
| 387 | end |
| 388 | rlog PBlog |
| 389 | put Brc 0 spawn |
| 390 | reset m |
| 391 | end |
| 392 | |
| 393 | fn cbuild to void |
| 394 | ktool 0 |
| 395 | ktx AStd17 |
| 396 | ktx AO0 |
| 397 | ktx Aw |
| 398 | ktx Ao |
| 399 | kout PCExe |
| 400 | kout PCMain |
| 401 | for u ulong get Nu 0 |
| 402 | if exported u |
| 403 | koutn UCc u Ext_c |
| 404 | end |
| 405 | end |
| 406 | end |
| 407 | |
| 408 | fn zbuild to void |
| 409 | kenvwk EvZg1 WZg1 |
| 410 | kenvwk EvZg2 WZg2 |
| 411 | ktool 4 |
| 412 | ktx AExe |
| 413 | ktx AOd |
| 414 | ktx ADbg |
| 415 | ktx Alc |
| 416 | m = mark |
| 417 | bs AEmit |
| 418 | bouts PZExe |
| 419 | kob m sub mark m |
| 420 | reset m |
| 421 | kout PZMain |
| 422 | end |
| 423 | |
| 424 | note per-unit builds: cpp/diff/<name>.cpp with g++, go/<name> with go build |
| 425 | fn ubuild to void |
| 426 | g = get Lg 0 |
| 427 | if eq g 6 |
| 428 | mkout PCpBld |
| 429 | else |
| 430 | mkout PGoBld |
| 431 | end |
| 432 | for u ulong get Nu 0 |
| 433 | if exported u |
| 434 | put Ubd u ubuild1 u |
| 435 | end |
| 436 | end |
| 437 | end |
| 438 | |
| 439 | fn ubuild1 u ulong to ulong |
| 440 | m = mark |
| 441 | rclr |
| 442 | kenv |
| 443 | if eq get Lg 0 6 |
| 444 | ktool 3 |
| 445 | ktx AStdx |
| 446 | ktx AO0 |
| 447 | ktx Aw |
| 448 | ktx Ao |
| 449 | kouto PCpBld u |
| 450 | koutn PCpD u Ext_cp |
| 451 | else |
| 452 | kenvwk EvGoc WGoc |
| 453 | ktool 5 |
| 454 | ktx ABuild |
| 455 | ktx Ao |
| 456 | kouto PGoBld u |
| 457 | ktx ADot |
| 458 | a = mark |
| 459 | bouts UGo |
| 460 | bname u |
| 461 | b = mark |
| 462 | rset 6 a b |
| 463 | end |
| 464 | a = mark |
| 465 | bouts PDiff |
| 466 | bname u |
| 467 | b = mark |
| 468 | q = mkdirs a b |
| 469 | bs PBlogU |
| 470 | b = mark |
| 471 | rset 2 a b |
| 472 | put Rmg 0 1 |
| 473 | r = spawn |
| 474 | reset m |
| 475 | ret r |
| 476 | end |
| 477 | |
| 478 | note the target executable (and interpreter) for unit u onto argv |
| 479 | fn ktarget u ulong to void |
| 480 | g = get Lg 0 |
| 481 | if eq g 2 |
| 482 | kout PRsExe |
| 483 | end |
| 484 | if eq g 3 |
| 485 | kenv |
| 486 | ktool 2 |
| 487 | ktx AB |
| 488 | kout PPyMain |
| 489 | end |
| 490 | if eq g 1 |
| 491 | kout PCExe |
| 492 | end |
| 493 | if eq g 5 |
| 494 | kout PZExe |
| 495 | end |
| 496 | if eq g 6 |
| 497 | kouto PCpBld u |
| 498 | end |
| 499 | if eq g 4 |
| 500 | kouto PGoBld u |
| 501 | end |
| 502 | end |
| 503 | |
| 504 | note run argv with stdin diff/<name>/vectors.txt and stdout diff/<name><t> |
| 505 | fn runvec u ulong t view uchar * to ulong |
| 506 | a = mark |
| 507 | bouts PDiff |
| 508 | bname u |
| 509 | bs PVec |
| 510 | b = mark |
| 511 | bouts PDiff |
| 512 | bname u |
| 513 | bs t |
| 514 | c = mark |
| 515 | bwk WkErr |
| 516 | d = mark |
| 517 | rset 0 a b |
| 518 | rset 2 b c |
| 519 | rset 4 c d |
| 520 | r = spawn |
| 521 | reset a |
| 522 | ret r |
| 523 | end |
| 524 | |
| 525 | note diff/<name>/ with vectors.txt, oracle.c and driver.om |
| 526 | fn dprep u ulong to bool |
| 527 | m = mark |
| 528 | bouts PDiff |
| 529 | bname u |
| 530 | e = mark |
| 531 | q = mkdirs m e |
| 532 | reset m |
| 533 | genvec u |
| 534 | m = mark |
| 535 | bpl get Uv0 u get Uvn u |
| 536 | c = mark |
| 537 | bouts PDiff |
| 538 | bname u |
| 539 | bs PVec |
| 540 | p = mark |
| 541 | w = wfile m c c p |
| 542 | reset m |
| 543 | genoracle u |
| 544 | ret genomdrv u |
| 545 | end |
| 546 | |
| 547 | note the original C leg; on success the oracle output is kept in the pool (Uo0/Uon) |
| 548 | fn leg1 u ulong to ulong |
| 549 | m = mark |
| 550 | rclr |
| 551 | kenv |
| 552 | ktool 0 |
| 553 | ktx AStd17 |
| 554 | ktx AO0 |
| 555 | ktx Aw |
| 556 | ktx Ao |
| 557 | a = mark |
| 558 | bwk WOrc |
| 559 | kob a sub mark a |
| 560 | reset a |
| 561 | koutn PDiff u POrc |
| 562 | put Rmg 0 1 |
| 563 | a = mark |
| 564 | bwk WkErr |
| 565 | b = mark |
| 566 | rset 2 a b |
| 567 | r = spawn |
| 568 | reset m |
| 569 | if ne r 0 |
| 570 | ret r |
| 571 | end |
| 572 | rclr |
| 573 | krst |
| 574 | a = mark |
| 575 | bwk WOrc |
| 576 | kob a sub mark a |
| 577 | reset a |
| 578 | r = runvec u POut1 |
| 579 | reset m |
| 580 | if ne r 0 |
| 581 | ret r |
| 582 | end |
| 583 | a = mark |
| 584 | bouts PDiff |
| 585 | bname u |
| 586 | bs POut1 |
| 587 | b = mark |
| 588 | q = rfile a b |
| 589 | reset m |
| 590 | if lt q 0 |
| 591 | ret 254 |
| 592 | end |
| 593 | if ne nlines ulong q get Unv u |
| 594 | ret 253 |
| 595 | end |
| 596 | bfb 0 ulong q |
| 597 | put Uo0 u psave m ulong q |
| 598 | put Uon u ulong q |
| 599 | reset m |
| 600 | ret 0 |
| 601 | end |
| 602 | |
| 603 | fn nlines n ulong to ulong |
| 604 | c = ulong 0 |
| 605 | for i ulong n |
| 606 | if eq get Fb i 10 |
| 607 | c = add c 1 |
| 608 | end |
| 609 | end |
| 610 | ret c |
| 611 | end |
| 612 | |
| 613 | note the Omega leg: driver.om through the pinned omc, then run |
| 614 | fn leg2 u ulong to ulong |
| 615 | m = mark |
| 616 | rclr |
| 617 | krst |
| 618 | k = mark |
| 619 | bomc |
| 620 | kob k sub mark k |
| 621 | reset k |
| 622 | a = mark |
| 623 | bouts PDiff |
| 624 | bname u |
| 625 | bs POmd |
| 626 | b = mark |
| 627 | bwk WOmd |
| 628 | c = mark |
| 629 | bwk WkErr |
| 630 | d = mark |
| 631 | rset 0 a b |
| 632 | rset 2 b c |
| 633 | rset 4 c d |
| 634 | r = spawn |
| 635 | if ne r 0 |
| 636 | reset m |
| 637 | ret r |
| 638 | end |
| 639 | q = chmod Ob b sub c b 493 |
| 640 | rclr |
| 641 | krst |
| 642 | kob b sub c b |
| 643 | reset m |
| 644 | r = runvec u POut2 |
| 645 | reset m |
| 646 | ret r |
| 647 | end |
| 648 | |
| 649 | note lines of the file <out>/diff/<name><t> that differ from the oracle output |
| 650 | fn mism u ulong t view uchar * to ulong |
| 651 | m = mark |
| 652 | bouts PDiff |
| 653 | bname u |
| 654 | bs t |
| 655 | b = mark |
| 656 | q = rfile m b |
| 657 | reset m |
| 658 | n = get Unv u |
| 659 | if lt q 0 |
| 660 | ret n |
| 661 | end |
| 662 | ret mcount u ulong q |
| 663 | end |
| 664 | |
| 665 | note compare Fb[0, fe) line by line with the oracle output of unit u |
| 666 | fn mcount u ulong fe ulong to ulong |
| 667 | put Cv 0 get Uo0 u |
| 668 | oe = add get Uo0 u get Uon u |
| 669 | f = ulong 0 |
| 670 | nb = ulong 0 |
| 671 | for j ulong get Unv u |
| 672 | o = get Cv 0 |
| 673 | e = lnend o oe |
| 674 | g = fend f fe |
| 675 | if not fbpl f sub g f o sub e o |
| 676 | nb = add nb 1 |
| 677 | end |
| 678 | put Cv 0 add e 1 |
| 679 | f = add g 1 |
| 680 | if gt f fe |
| 681 | f = fe |
| 682 | end |
| 683 | end |
| 684 | if lt f fe |
| 685 | nb = add nb 1 |
| 686 | end |
| 687 | ret nb |
| 688 | end |
| 689 | |
| 690 | fn fend f ulong e ulong to ulong |
| 691 | i = f |
| 692 | while lt i e bound 999999 |
| 693 | if eq get Fb i 10 |
| 694 | ret i |
| 695 | end |
| 696 | i = add i 1 |
| 697 | end |
| 698 | ret e |
| 699 | end |
| 700 | |
| 701 | fn fbpl a ulong an ulong b ulong bn ulong to bool |
| 702 | if ne an bn |
| 703 | ret false |
| 704 | end |
| 705 | for i ulong an |
| 706 | if ne get Fb add a i get Pl add b i |
| 707 | ret false |
| 708 | end |
| 709 | end |
| 710 | ret true |
| 711 | end |
| 712 | |
| 713 | note "<s><k> of <n> vectors (see diff/<name>/)" as the unit reason |
| 714 | fn whymis u ulong s view uchar * k ulong to void |
| 715 | m = mark |
| 716 | bs s |
| 717 | bu k |
| 718 | bs RsOf |
| 719 | bu get Unv u |
| 720 | bs RsVec |
| 721 | bname u |
| 722 | bs RsVe |
| 723 | ureasob u m |
| 724 | end |
| 725 | |
| 726 | fn whyrc u ulong s view uchar * rc ulong to void |
| 727 | m = mark |
| 728 | bs s |
| 729 | bs RsExit |
| 730 | bu rc |
| 731 | ureasob u m |
| 732 | end |
| 733 | |
| 734 | note s <name> t "exit rc" |
| 735 | fn whyrcn u ulong s view uchar * t view uchar * rc ulong to void |
| 736 | m = mark |
| 737 | bs s |
| 738 | bname u |
| 739 | bs t |
| 740 | bs RsExit |
| 741 | bu rc |
| 742 | ureasob u m |
| 743 | end |
| 744 | |
| 745 | fn legset u ulong k ulong v ulong to void |
| 746 | put Ulg add mul u 3 k v |
| 747 | end |
| 748 | |
| 749 | note one exported unit through all three legs |
| 750 | fn diffunit u ulong to void |
| 751 | progress u |
| 752 | if not dprep u |
| 753 | setst u 4 7 0 |
| 754 | ureason u RsPrep |
| 755 | ret |
| 756 | end |
| 757 | r = leg1 u |
| 758 | if ne r 0 |
| 759 | legset u 0 2 |
| 760 | setst u 4 8 r |
| 761 | whyrcn u RsOrc RsOrc2 r |
| 762 | ret |
| 763 | end |
| 764 | legset u 0 1 |
| 765 | r = leg2 u |
| 766 | if ne r 0 |
| 767 | legset u 1 2 |
| 768 | setst u 4 7 r |
| 769 | whyrcn u RsOmd RsOmd2 r |
| 770 | ret |
| 771 | end |
| 772 | k = mism u POut2 |
| 773 | put Umo u k |
| 774 | if gt k 0 |
| 775 | legset u 1 2 |
| 776 | setst u 4 7 0 |
| 777 | whymis u RsMo k |
| 778 | ret |
| 779 | end |
| 780 | legset u 1 1 |
| 781 | legt u |
| 782 | end |
| 783 | |
| 784 | fn legt u ulong to void |
| 785 | if eq get Tok tslot 0 |
| 786 | setst u 5 6 0 |
| 787 | ureason u RsNoTl |
| 788 | ret |
| 789 | end |
| 790 | b = get Brc 0 |
| 791 | if ne b 0 |
| 792 | legset u 2 2 |
| 793 | setst u 4 6 b |
| 794 | whyrc u RsTbd b |
| 795 | ret |
| 796 | end |
| 797 | b = get Ubd u |
| 798 | if ne b 0 |
| 799 | legset u 2 2 |
| 800 | setst u 4 6 b |
| 801 | whyrcn u RsTbdU RsTbdU2 b |
| 802 | ret |
| 803 | end |
| 804 | rclr |
| 805 | kenv |
| 806 | ktarget u |
| 807 | r = runvec u POut3 |
| 808 | if ne r 0 |
| 809 | legset u 2 2 |
| 810 | setst u 4 7 r |
| 811 | whyrcn u RsTrn RsTrn2 r |
| 812 | ret |
| 813 | end |
| 814 | k = mism u POut3 |
| 815 | put Umt u k |
| 816 | if gt k 0 |
| 817 | legset u 2 2 |
| 818 | setst u 4 7 0 |
| 819 | whymis u RsMt k |
| 820 | ret |
| 821 | end |
| 822 | legset u 2 1 |
| 823 | setst u 1 7 0 |
| 824 | end |
| 825 | |
| 826 | note generated tests (rust, python): cargo test / unittest over the oracle outputs; Tsr 999 = not run |
| 827 | fn ttests to void |
| 828 | put Tsr 0 999 |
| 829 | g = get Lg 0 |
| 830 | if eq get Tok tslot 0 |
| 831 | ret |
| 832 | end |
| 833 | if not anycase |
| 834 | ret |
| 835 | end |
| 836 | m = mark |
| 837 | rclr |
| 838 | kenv |
| 839 | if eq g 2 |
| 840 | genrstest |
| 841 | ktool 1 |
| 842 | ktx ATest |
| 843 | ktx AOff |
| 844 | ktx AQuiet |
| 845 | ktx AMan |
| 846 | kout PRsMan |
| 847 | end |
| 848 | if eq g 3 |
| 849 | genpytest |
| 850 | ktool 2 |
| 851 | ktx AB |
| 852 | kout PPyTst |
| 853 | end |
| 854 | if lt g 2 |
| 855 | reset m |
| 856 | ret |
| 857 | end |
| 858 | if gt g 3 |
| 859 | reset m |
| 860 | ret |
| 861 | end |
| 862 | rlog PTlog |
| 863 | put Tsr 0 spawn |
| 864 | reset m |
| 865 | end |
| 866 | |
| 867 | note whole differential stage: units still EXPORTED become TRANSLATED, FAIL or NOT_RUN |
| 868 | fn difftest to void |
| 869 | vinit |
| 870 | tbuild |
| 871 | for u ulong get Nu 0 |
| 872 | if not exported u |
| 873 | continue |
| 874 | end |
| 875 | legset u 0 3 |
| 876 | legset u 1 3 |
| 877 | legset u 2 3 |
| 878 | if eq get Tok 0 0 |
| 879 | setst u 5 8 0 |
| 880 | ureason u RsNoCc |
| 881 | continue |
| 882 | end |
| 883 | diffunit u |
| 884 | end |
| 885 | ttests |
| 886 | end |