diff --git a/.crumb b/.crumb index 81f377ee2..5617cb83b 100644 --- a/.crumb +++ b/.crumb @@ -47,8 +47,8 @@ "purpose": "Directory calibration. Purpose not yet described by a human." }, { - "digest": "d2eb8967a939ebdb0b54e15fe5d849dd5af71c23b812941e4ba86ad2b0f21d39", - "last_commit": "4870b0a4", + "digest": "50e0cefb33d5d571a34c7f4aa7a3bacac299b002e882224e77b147fa83abe040", + "last_commit": "cde3c1d5", "name": "docs", "purpose": "Directory docs. Purpose not yet described by a human." }, @@ -59,8 +59,8 @@ "purpose": "Directory doctrine. Purpose not yet described by a human." }, { - "digest": "e7d38c87a51c3c0ee6e3b18419ef4a01d95029de12ac9bf69eb672654f0ace55", - "last_commit": "ae4ad9c0", + "digest": "35bcb5dc840dd7eb87431ed8727e066ebf88f474ce2fbae35af7468ddfcb82fc", + "last_commit": "af683338", "name": "mk", "purpose": "Directory mk. Purpose not yet described by a human." }, @@ -71,20 +71,20 @@ "purpose": "Directory research. Purpose not yet described by a human." }, { - "digest": "6327473d41e10acbf43be0918d3557509322bfd7d6e075e114c79c2600a47305", - "last_commit": "43d8d20d", + "digest": "c3c03a68714e648f7fc27dad18a77e23eea0cf624c49b98c34e79c38f1fd8518", + "last_commit": "4a839339", "name": "spec", "purpose": "Directory spec. Purpose not yet described by a human." }, { - "digest": "dfa36de2ac8649f66f80587abea51a7f166285ee0b92e0e09774c98689055250", - "last_commit": "333091a6", + "digest": "f165c505608480659b2696a46a0ccd85fd2190f696674cfaf8ca41c2ce89d1e8", + "last_commit": "6e164a12", "name": "src", "purpose": "Directory src. Purpose not yet described by a human." }, { - "digest": "4eb9d4d76234448c0ed691f0aeb9c90d785f8a47b1b1291d728bbe3e1509dc10", - "last_commit": "88e24bdd", + "digest": "df3654dac6fb2ef9f4584ff3fe24687c007e0c2decd005392bf90f78780f5022", + "last_commit": "d32f4fd0", "name": "tests", "purpose": "Directory tests. Purpose not yet described by a human." }, @@ -95,15 +95,15 @@ "purpose": "Directory tools. Purpose not yet described by a human." } ], - "children_root": "sha256:e1a8c008214ad5dbc33a3e184d7e882dc56d1d50f9bd14c58f8773992961557e", - "compiled_at": "2026-10-16T19:04:20Z", + "children_root": "sha256:3dd59d2d32307956f1b8971e276485c49f5e08a5eed390e36a57ffee429d5b84", + "compiled_at": "2026-10-18T14:43:09Z", "compiler": "crumb-compile/1", - "digest": "sha256:32086cfe6b319e0c0229bec39553d1b32f7460aa660ad888d5eb5990522e705a", + "digest": "sha256:ecf4877bcb57c22cfaa45270d8df4612d216d523faffb999deef7d8bcda5a542", "evidence_files": 11127, "evidence_root": "sha256:4528085ec1661c442b64fb5dc8def65067ea2620ff88e42bcf52d58b7642ea6e", - "files": 14109, - "generated_at_commit": "88e24bdd57b27817d030d0ad95f62c3f3eacf426", - "source_tree": "sha256:e01c9caa38757306582443fe69f52cb061c3d27250f8ad0b9f4b4f43b009dc14" + "files": 14138, + "generated_at_commit": "d32f4fd023910235289557e065bb47afa78ed4f1", + "source_tree": "sha256:f93b8cb6c1c292bd98c214ae57b22edc1fba6153c00b3989001984d444d2464e" }, "owner_lane": "", "provenance": { diff --git a/docs/.crumb b/docs/.crumb index ca5d5ec00..52a23209e 100644 --- a/docs/.crumb +++ b/docs/.crumb @@ -45,8 +45,8 @@ "generated": { "children": [ { - "digest": "640f6b7b818c769ab0dcd91437d58dd3251044084d2ae3785f000d30d2bb768a", - "last_commit": "a927bd6c", + "digest": "0667672cca1893b2332636a96fe69eac2773694913ebd47f42d25a2d55452d42", + "last_commit": "4a839339", "name": "adr", "purpose": "Directory docs/adr. Purpose not yet described by a human." }, @@ -87,8 +87,8 @@ "purpose": "Directory docs/numeric. Purpose not yet described by a human." }, { - "digest": "6bdfbc843114954144a288eb6bc0f8c84a3be256547a8db98b2bd3ee949e95be", - "last_commit": "f37bf0fd", + "digest": "d423a1d18e044af982d883d843b613888e554f6e9159f96b8985866348ce9f51", + "last_commit": "cde3c1d5", "name": "osc", "purpose": "Directory docs/osc. Purpose not yet described by a human." }, @@ -123,15 +123,15 @@ "purpose": "Directory docs/turing. Purpose not yet described by a human." } ], - "children_root": "sha256:ac7f7ea4b00d4620a993c6dd88a0267f2d49008d415162976e45fa4341e43407", - "compiled_at": "2026-10-16T09:04:56Z", + "children_root": "sha256:51a862f5452a7b37934dbd6186ed67fbe7bf529e3d2c6994824e7bb6ec805b89", + "compiled_at": "2026-10-16T20:35:19Z", "compiler": "crumb-compile/1", - "digest": "sha256:d2eb8967a939ebdb0b54e15fe5d849dd5af71c23b812941e4ba86ad2b0f21d39", + "digest": "sha256:50e0cefb33d5d571a34c7f4aa7a3bacac299b002e882224e77b147fa83abe040", "evidence_files": 34, "evidence_root": "sha256:589d8b3706e6d7a202ab20b278dac5fc5bafc973f1c2a867b2668aa7210b65cc", "files": 127, - "generated_at_commit": "9d368679f13ea58c46bf7580899aee92e39f5885", - "source_tree": "sha256:29d159b6950500f96de859834fd2c5a9e9ba037f9bc88fd97a8ed47a1688233b" + "generated_at_commit": "cde3c1d51cc2106f965ed34c6ae82d311d1b490a", + "source_tree": "sha256:5173bc8db05a033e9f2519e4644c9645a78aa739253abe9de8941c5a7ebf3e13" }, "owner_lane": "", "provenance": { diff --git a/docs/adr/.crumb b/docs/adr/.crumb index e143e99a1..f680571cf 100644 --- a/docs/adr/.crumb +++ b/docs/adr/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-04T13:47:05Z", + "compiled_at": "2026-10-16T03:04:32Z", "compiler": "crumb-compile/1", - "digest": "sha256:640f6b7b818c769ab0dcd91437d58dd3251044084d2ae3785f000d30d2bb768a", + "digest": "sha256:0667672cca1893b2332636a96fe69eac2773694913ebd47f42d25a2d55452d42", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 1, - "generated_at_commit": "834ee93e4314a42c1127a2fcda8b29cf3b511245", - "source_tree": "sha256:0ece06312221d01c1b9b1b35fc9533d661fa5bed21636dac5cb1a30061185435" + "generated_at_commit": "7be842c8a82a3dafc59a6aacee84ccad571dde84", + "source_tree": "sha256:08215fe61a4d82575877a23bbfa8779143d3e95ac342f4854840c6a1c0e6642b" }, "owner_lane": "", "provenance": { diff --git a/docs/adr/OMEGA-SYSTEMS-CORE-0000.md b/docs/adr/OMEGA-SYSTEMS-CORE-0000.md index e1c8a8642..1dd598f55 100644 --- a/docs/adr/OMEGA-SYSTEMS-CORE-0000.md +++ b/docs/adr/OMEGA-SYSTEMS-CORE-0000.md @@ -17,6 +17,7 @@ Omega, PHYSICS, and AIENOS rely on about 98k lines of C and assembly whose safet 4. **Ordering.** Omega owns its ordering vocabulary, with explicit AArch64 lowerings. `volatile` is banned from safe code (II.2). 5. **Four layouts: Semantic, Runtime, Wire, Device.** Raw struct hashing is forbidden, and every hashed byte comes from a declared encoder (II.3). 6. **Failures.** Typed `Result` for expected failures; deterministic traps for invariant violations; no unwinding. A per-context table covers OOM, bounds, stale generations, device loss, failed construction, and cleanup (II.4). + - *Clarification note, 2026-10-16 (OSC-4 Slice A, reviewer condition 2; the decision text above is unchanged).* For `f32` and `f64`, infinity and NaN are **values**, not invariant violations. Float division by zero, overflow and invalid operations never trap; the IEEE result flows on and the program reads it (`x != x`, `x as u64 bits`). This is a permanent language rule (docs/osc/OSC-4-DESIGN.md 1.3 items 7 and 13), distinct from integer `/` by a constant zero, which stays a compile-time refusal, and from integer overflow, which stays a trap. 7. **Ownership is a forest.** Graphs are owned by pools, and their edges are handles, weak references, or ids. Reference counting is never the default (II.5). 8. **Movable by default.** `pin` is rare and physical (II.7). MMIO, DMA, and cache visibility go through typed primitives inside declared `unsafe physical` blocks. The `ctx(irq)` / `ctx(trap)` contexts forbid allocation and blocking (II.8). 9. **Reproducible compiler.** Build twice and compare, and bootstrap equivalence is checked on a fixed corpus. The M6 self-copy is never evidence (II.9). diff --git a/docs/osc/.crumb b/docs/osc/.crumb index 93ece87ce..424ba8b60 100644 --- a/docs/osc/.crumb +++ b/docs/osc/.crumb @@ -20,14 +20,14 @@ } ], "children_root": "sha256:fe7b526366c92c41e77d831ed9fddc2c3c278df36af61c755bf788f12d38c5e7", - "compiled_at": "2026-10-16T01:32:55Z", + "compiled_at": "2026-10-16T20:35:19Z", "compiler": "crumb-compile/1", - "digest": "sha256:6bdfbc843114954144a288eb6bc0f8c84a3be256547a8db98b2bd3ee949e95be", + "digest": "sha256:d423a1d18e044af982d883d843b613888e554f6e9159f96b8985866348ce9f51", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 15, - "generated_at_commit": "06d994df9cb00eb5267a6c613552c70109a2aaa4", - "source_tree": "sha256:4d1c984a8fd4a3e5b30557b23ba1f073be816e090ede232f31284906723acb2b" + "generated_at_commit": "cde3c1d51cc2106f965ed34c6ae82d311d1b490a", + "source_tree": "sha256:c51286918bff25ab959a61cea775602618d9cded240bd9f9744b9578da8b973a" }, "owner_lane": "research-0c", "provenance": { diff --git a/docs/osc/OSC-4-DESIGN.md b/docs/osc/OSC-4-DESIGN.md index 0b775f976..9dbb7023f 100644 --- a/docs/osc/OSC-4-DESIGN.md +++ b/docs/osc/OSC-4-DESIGN.md @@ -241,13 +241,84 @@ F64 keeps all 64 bits, so the argument check at osc_interp.c:221 refuses only di 3. Fuzz: the dual-run generator gains float ops and constants, and `gen_arg` (tests/compiler/test_osc_compiler.c:143) emits f32/f64 argument patterns including quiet and signalling NaN, both infinities, -0.0 and subnormals; `mismatches=0` over 100k programs plus - the ASan/UBSan leg (mk/compiler.mk:23). + the ASan/UBSan leg (mk/compiler.mk:23). `make test-compiler` runs 250 units; the 100k run is + `make test-compiler-float-fuzz-full` and the oracle check is `make test-compiler-float-oracle`. 4. Backend: 25 `enc_expect` goldens, round trips, mutants. determinism.sh passes on version 6 units. ### 1.9 Limits No fused ops, no FRINT, no transcendental intrinsics, no f16/bf16, no SIMD, no float `%`, no float array constants. These omissions buy bit-exact agreement. +## Slice A implementation notes + +Written while building Slice A (branch osc4/slice-a, 2026-10-16). Each note is a place where the +text above left a choice open, or where the code deviates from a line above; the reading chosen is +the one that keeps the interpreter and the native code bit-identical. The code is the truth. + +1. **Names.** The scalar tags are `OSC_T_F32` / `OSC_T_F64` (the existing `OSC_T_` prefix, + src/compiler/osc_ir.h), not the `OSC_S_` spelling in 1.5. Tags 13 and 14; opcodes FBIN 30 .. + FBITS 36; sub-op enums `OscFBin` (ADD 1 .. MAX 6), `OscFUn` (NEG 1, ABS 2, SQRT 3), `OscFInt` + (SIGNED 1, UNSIGNED 2). spec/one-layer-format.md carries the wire layout. +2. **Canonical f32 value.** `canon` for F32 reuses the width-32 unsigned path: low 32 bits kept, + upper 32 zero, payload untouched. A dirty upper half in an F32 argument is refused exactly like a + dirty u32. +3. **Constant folding.** The only compile-time float evaluation is a literal (strtof / strtod, per + 1.3 item 12) and its negation (sign-bit flip, which is what FNEG does). `1.0 + 2.0` is NOT folded: + it is emitted as a run-time FBIN, so every rounding step has exactly one implementation (the + machine's). `ceval` returns "unknown" for every float-typed node, so a contract that mentions a + float is decided at run time, never folded. +4. **Literal typing.** An unsuffixed literal takes its type from the context (`let x: f32 = 1.0`, + `a * 2.0`); a suffixed literal must match the context or it is TYPE_MISMATCH. A float literal + where an integer is required, or an integer literal where a float is required (`x * 2` with + `x: f64`), is TYPE_MISMATCH with a message saying to write the `.`. FLOAT_MIXED (1.4) fires when + a float meets a float of the other width or an integer-typed expression; `bool` against a float + stays TYPE_MISMATCH. +5. **`as`.** Same float to same float lowers to MOV. `as ... bits` requires exactly one float side + and one integer side of equal width (f32 with u32/i32, f64 with u64/i64), else + FLOAT_BITS_WIDTH; `bool` to or from a float is TYPE_MISMATCH. ITOF `sub` is the signedness of + the source, FTOI `sub` the signedness of the destination; the validator checks both. +6. **FLOAT_BITOP** covers `% & | ^ << >>` and unary `~` on a float operand. `x / 0.0` with a + constant zero divisor is allowed (inf is a value, 1.3 item 7); the integer constant-zero-divisor + refusal does not apply to floats. +7. **FLOAT_INDEX** object: the array or slice name when a float indexes it (also for a float + literal index); the word `for` for a float loop-range end and `bound` for a float `while`/arena + bound (those two are decided in the parser, since ranges and bounds take integer literals only). +8. **min/max** (interpreter, mirrors FMINNM/FMAXNM): a signalling NaN in `a` returns quiet(`a`); a + signalling NaN in `b` returns quiet(`b`); both quiet NaN returns `a`; exactly one quiet NaN + returns the other operand; equal values (including +0.0 and -0.0) return the negative-signed one + for `min` and the positive-signed one for `max`; otherwise `<`. +9. **FTOI.** Interpreter: saturate in `double` (`half = (double)(1ULL << (w-1))`), NaN -> 0, then + canon to the destination width. Native: FCVTZS/FCVTZU to an X register (64-bit saturation, NaN + -> 0), then for destinations narrower than 64 bits a clamp: materialise the bound in x10, CMP, + skip over an `ORR x9, xzr, x10` with B.cond (LE for the upper signed bound, GE for the lower + signed bound, LS for the unsigned bound). The two agree bit for bit on every pattern the fuzz + draws (signalling/quiet NaN, both infinities, -0.0, subnormals, values past both bounds). +10. **f32 slot traffic.** Store: `FMOV w9, sN` (zero-extends) then the existing 64-bit STR, so the + upper half of an f32 slot is always zero. Load: `LDR sN, [sp, #off]`. FBITS to i32 sign-extends + (SBFM); to u32 or f32 it zero-extends. +11. **Fixed-form encodings.** FMOV_XD/DX/WS/SW and FCVT_SD/DS have one form each and refuse + `imm2 != 0`; the type bit is in the opcode name. All other float ops take `imm2` 0 (S) or 1 (D) + and refuse anything else. The 25 ops each have one golden word from + tests/compiler/aarch64_fp_golden.h (1365 header samples re-encoded with 0 mismatches), one + decoder round trip and field-flip mutants. +12. **Harness change (the one existing check that moved).** test_osc_compiler.c used to assert that + IR version byte 6 is refused as unknown. Version 6 is now the float version, so that check + asserts instead: `osc_ir_encoding_version` recognises 6, a float unit encodes as version 6, and + version 7 is the first unknown one. test_osc_ir_decode.c adds the strict-reader side: version 6 + on a unit without floats is VERSION_MISMATCH, version 7 is UNKNOWN_VERSION, tag 15 and opcode 37 + are RANGE. No other existing test changed. +13. **Build flags.** `-ffp-contract=off -fno-fast-math -fno-math-errno` are on OSC_CFLAGS for every + compiler-path C file and on the determinism.sh fallback build; `-lm` is linked for `sqrt`. +14. **Float literal length.** A float literal is at most OSC_LEX_NAME_MAX (63) characters, the + identifier limit; a longer spelling is CAPACITY in the lexer (and, as a belt, in the checker), + never truncated: a cut spelling would parse to a different value (review of PR 489 found a + 163-character 1e-161 compiling to 0.0 through a 128-byte buffer). Every other fixed-size text + buffer on the float path only shapes a diagnostic message or object name, never a value. +15. **Evidence targets.** `make test-compiler` runs the float dual run at 250 units (smoke); + `make test-compiler-float-fuzz-full` runs 100,000 (receipt); `make test-compiler-float-oracle` + rebuilds every expect-run value of the f_*.osc goldens with tests/compiler/float_oracle.c and + diffs them. + ## 2. Slice B: large buffers and typed slices ### 2.1 Subset statement @@ -513,6 +584,8 @@ For aien-dev-ba (GPU engine and compiler dispatcher): For the advisor: 1. Accept "floats as bit patterns in X registers" for the OSC-internal ABI (no V-register ABI until a real need)? 2. Accept no float traps (inf/NaN flow) as a permanent language rule or only for OSC-4? + SETTLED 2026-10-16: permanent (1.3 items 7 and 13; the dated note under decision 6 of + docs/adr/OMEGA-SYSTEMS-CORE-0000.md). Not open. 3. Gate `extern` and `syscall` behind oscc flags now, or wait for OSC-3 item 4 capabilities? 4. Is a host-specific code SHA-256 for units with externs acceptable, given the IR SHA-256 stays reproducible? 5. Should Slice B's `&[T]` replace `bytes`/`cells` names outright instead of aliasing them? diff --git a/mk/.crumb b/mk/.crumb index cd51a1c73..92d55bb6c 100644 --- a/mk/.crumb +++ b/mk/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-16T02:24:36Z", + "compiled_at": "2026-10-16T20:35:19Z", "compiler": "crumb-compile/1", - "digest": "sha256:e7d38c87a51c3c0ee6e3b18419ef4a01d95029de12ac9bf69eb672654f0ace55", + "digest": "sha256:35bcb5dc840dd7eb87431ed8727e066ebf88f474ce2fbae35af7468ddfcb82fc", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 71, - "generated_at_commit": "ccf021b944b0128a537dfd3dd301e6d83eefa311", - "source_tree": "sha256:e7a2b37daa8149cb73da719737df82c74a61685b4076bf2c5b4e0c26bee61dc7" + "generated_at_commit": "cde3c1d51cc2106f965ed34c6ae82d311d1b490a", + "source_tree": "sha256:2897551410a96f72dbaa94f240f60e763535c958601b6fc737e060c9b9020832" }, "owner_lane": "", "provenance": { diff --git a/mk/compiler.mk b/mk/compiler.mk index 701957663..659a59939 100644 --- a/mk/compiler.mk +++ b/mk/compiler.mk @@ -19,7 +19,8 @@ ifndef COMPILER_MK COMPILER_MK := 1 .PHONY: test-compiler test-compiler-full test-compiler-quick oscc compiler-receipt osc0b-model-receipt osc2-receipt osc3-receipt OSC_DIR = $(OUT_DIR)/compiler -OSC_CFLAGS = -std=gnu11 -Wall -Wextra -Werror -D_GNU_SOURCE -O2 -Isrc -Isrc/compiler -Isrc/compiler/model +OSC_CFLAGS = -std=gnu11 -Wall -Wextra -Werror -D_GNU_SOURCE -O2 -ffp-contract=off -fno-fast-math -fno-math-errno -Isrc -Isrc/compiler -Isrc/compiler/model +OSC_LDLIBS = -lm OSC_ASAN = -O1 -g -fsanitize=address,undefined -fno-sanitize-recover=all OSC_LIB = $(filter-out src/compiler/oscc_main.c,$(wildcard src/compiler/*.c)) src/sha256.c OSC_MODEL = src/compiler/model/osc_model.c @@ -36,31 +37,31 @@ $(OSC_DIR)/test_osc_model_asan: tests/compiler/test_osc_model.c $(OSC_MODEL) $(O $(OSC_DIR)/test_osc_backend: tests/compiler/test_osc_backend.c $(OSC_LIB) $(OSC_HDRS) @mkdir -p $(OSC_DIR) - $(CC) $(OSC_CFLAGS) -o $@ tests/compiler/test_osc_backend.c $(OSC_LIB) + $(CC) $(OSC_CFLAGS) -o $@ tests/compiler/test_osc_backend.c $(OSC_LIB) $(OSC_LDLIBS) $(OSC_DIR)/test_osc_backend_asan: tests/compiler/test_osc_backend.c $(OSC_LIB) $(OSC_HDRS) @mkdir -p $(OSC_DIR) - $(CC) $(OSC_CFLAGS) $(OSC_ASAN) -o $@ tests/compiler/test_osc_backend.c $(OSC_LIB) + $(CC) $(OSC_CFLAGS) $(OSC_ASAN) -o $@ tests/compiler/test_osc_backend.c $(OSC_LIB) $(OSC_LDLIBS) $(OSC_DIR)/test_osc_alloc: tests/compiler/test_osc_alloc.c $(OSC_LIB) $(OSC_HDRS) @mkdir -p $(OSC_DIR) - $(CC) $(OSC_CFLAGS) -o $@ tests/compiler/test_osc_alloc.c $(OSC_LIB) + $(CC) $(OSC_CFLAGS) -o $@ tests/compiler/test_osc_alloc.c $(OSC_LIB) $(OSC_LDLIBS) $(OSC_DIR)/test_osc_alloc_asan: tests/compiler/test_osc_alloc.c $(OSC_LIB) $(OSC_HDRS) @mkdir -p $(OSC_DIR) - $(CC) $(OSC_CFLAGS) $(OSC_ASAN) -o $@ tests/compiler/test_osc_alloc.c $(OSC_LIB) + $(CC) $(OSC_CFLAGS) $(OSC_ASAN) -o $@ tests/compiler/test_osc_alloc.c $(OSC_LIB) $(OSC_LDLIBS) $(OSC_DIR)/test_osc_compiler: tests/compiler/test_osc_compiler.c $(OSC_LIB) $(OSC_MODEL) $(OSC_HDRS) @mkdir -p $(OSC_DIR) - $(CC) $(OSC_CFLAGS) -o $@ tests/compiler/test_osc_compiler.c $(OSC_LIB) $(OSC_MODEL) + $(CC) $(OSC_CFLAGS) -o $@ tests/compiler/test_osc_compiler.c $(OSC_LIB) $(OSC_MODEL) $(OSC_LDLIBS) $(OSC_DIR)/test_osc_compiler_asan: tests/compiler/test_osc_compiler.c $(OSC_LIB) $(OSC_MODEL) $(OSC_HDRS) @mkdir -p $(OSC_DIR) - $(CC) $(OSC_CFLAGS) $(OSC_ASAN) -o $@ tests/compiler/test_osc_compiler.c $(OSC_LIB) $(OSC_MODEL) + $(CC) $(OSC_CFLAGS) $(OSC_ASAN) -o $@ tests/compiler/test_osc_compiler.c $(OSC_LIB) $(OSC_MODEL) $(OSC_LDLIBS) $(OSC_DIR)/oscc: src/compiler/oscc_main.c $(OSC_LIB) $(OSC_HDRS) @mkdir -p $(OSC_DIR) - $(CC) $(OSC_CFLAGS) -o $@ src/compiler/oscc_main.c $(OSC_LIB) + $(CC) $(OSC_CFLAGS) -o $@ src/compiler/oscc_main.c $(OSC_LIB) $(OSC_LDLIBS) oscc: $(OSC_DIR)/oscc @@ -90,15 +91,15 @@ OSC_DEC_ASAN_ENV = ASAN_OPTIONS=detect_stack_use_after_return=0 $(OSC_DIR)/test_osc_ir_decode: tests/compiler/test_osc_ir_decode.c $(OSC_LIB) $(OSC_HDRS) @mkdir -p $(OSC_DIR) - $(CC) $(OSC_CFLAGS) -o $@ tests/compiler/test_osc_ir_decode.c $(OSC_LIB) + $(CC) $(OSC_CFLAGS) -o $@ tests/compiler/test_osc_ir_decode.c $(OSC_LIB) $(OSC_LDLIBS) $(OSC_DIR)/test_osc_ir_decode_asan: tests/compiler/test_osc_ir_decode.c $(OSC_LIB) $(OSC_HDRS) @mkdir -p $(OSC_DIR) - $(CC) $(OSC_CFLAGS) $(OSC_ASAN) -o $@ tests/compiler/test_osc_ir_decode.c $(OSC_LIB) + $(CC) $(OSC_CFLAGS) $(OSC_ASAN) -o $@ tests/compiler/test_osc_ir_decode.c $(OSC_LIB) $(OSC_LDLIBS) $(OSC_DIR)/test_osc_ir_decode_mutant%: tests/compiler/test_osc_ir_decode.c $(OSC_LIB) $(OSC_HDRS) @mkdir -p $(OSC_DIR) - $(CC) $(OSC_CFLAGS) -DOSC_IR_DECODE_MUTANT=$* -o $@ tests/compiler/test_osc_ir_decode.c $(OSC_LIB) + $(CC) $(OSC_CFLAGS) -DOSC_IR_DECODE_MUTANT=$* -o $@ tests/compiler/test_osc_ir_decode.c $(OSC_LIB) $(OSC_LDLIBS) test-osc-ir-decode-mutants: $(foreach k,$(OSC_DEC_MUTANTS),$(OSC_DIR)/test_osc_ir_decode_mutant$(k)) @for k in $(OSC_DEC_MUTANTS); do \ @@ -158,6 +159,8 @@ test-compiler: $(OSC_DIR)/test_osc_model $(OSC_DIR)/test_osc_model_asan \ @grep "^struct fuzz: .* mismatches=0$$" $(OSC_DIR)/compiler_asan.out @grep "^arena fuzz: .* mismatches=0$$" $(OSC_DIR)/compiler.out @grep "^arena fuzz: .* mismatches=0$$" $(OSC_DIR)/compiler_asan.out + @grep "^float fuzz: .* mismatches=0$$" $(OSC_DIR)/compiler.out + @grep "^float fuzz: .* mismatches=0$$" $(OSC_DIR)/compiler_asan.out @grep "^arena destruction order: " $(OSC_DIR)/compiler.out @grep "^runtime model replay: .* rejected=0$$" $(OSC_DIR)/compiler.out @grep "^runtime model replay: .* rejected=0$$" $(OSC_DIR)/compiler_asan.out @@ -216,6 +219,27 @@ test-compiler-quick: $(OSC_DIR)/test_osc_model $(OSC_DIR)/test_osc_backend $(OSC @tail -1 $(OSC_QDIR)/legacy_callers.out; grep -q '^OSC2_LEGACY_CALLERS_PASS ' $(OSC_QDIR)/legacy_callers.out @echo "test-compiler-quick: PASS (smoke counts; not receipt evidence; full = make test-compiler-full. OSC-3 slice; not a general Omega compiler; no self-hosting.)" +# OSC-4 Slice A evidence targets (docs/osc/OSC-4-DESIGN.md 1.8). test-compiler runs the float dual run at +# 250 units; the 100k receipt run and the C oracle check are reached by name. +$(OSC_DIR)/float_oracle: tests/compiler/float_oracle.c + @mkdir -p $(OSC_DIR) + $(CC) $(OSC_CFLAGS) -o $@ tests/compiler/float_oracle.c $(OSC_LDLIBS) + +# Rebuild every expect-run value of tests/compiler/progs/f_*.osc with the C oracle and diff. +test-compiler-float-oracle: $(OSC_DIR)/float_oracle + $(abspath $(OSC_DIR)/float_oracle) | sort > $(OSC_DIR)/float_oracle.out + grep -h '^// expect-run: ' tests/compiler/progs/f_*.osc | sed 's#^// expect-run: ##' | sort > $(OSC_DIR)/float_expect.out + diff -u $(OSC_DIR)/float_expect.out $(OSC_DIR)/float_oracle.out + @echo "test-compiler-float-oracle: PASS ($$(wc -l < $(OSC_DIR)/float_oracle.out) expect-run values reproduced by the C oracle)" + +# The 100k-unit interpreter-vs-native float dual run (receipt evidence; test-compiler runs 250 units). +OSC_FLOAT_FUZZ_FULL ?= 100000 +test-compiler-float-fuzz-full: $(OSC_DIR)/test_osc_compiler + OSC_FLOAT_FUZZ_UNITS=$(OSC_FLOAT_FUZZ_FULL) $(abspath $(OSC_DIR)/test_osc_compiler) > $(OSC_DIR)/float_fuzz_full.out + @tail -1 $(OSC_DIR)/float_fuzz_full.out; grep -Eq '^OSC1_COMPILER_PASS( |$$)' $(OSC_DIR)/float_fuzz_full.out + @grep "^float fuzz: units=$(OSC_FLOAT_FUZZ_FULL) .* mismatches=0$$" $(OSC_DIR)/float_fuzz_full.out + @echo "test-compiler-float-fuzz-full: PASS" + osc0b-model-receipt: sh tests/compiler/osc0b_model_receipt.sh diff --git a/spec/.crumb b/spec/.crumb index e63063df8..06652f663 100644 --- a/spec/.crumb +++ b/spec/.crumb @@ -20,14 +20,14 @@ } ], "children_root": "sha256:6834a3241647d3a098283d4eafedbdb1428dfa4d834f9ed5f22025b6d2303093", - "compiled_at": "2026-10-16T07:53:23Z", + "compiled_at": "2026-10-16T20:35:19Z", "compiler": "crumb-compile/1", - "digest": "sha256:6327473d41e10acbf43be0918d3557509322bfd7d6e075e114c79c2600a47305", + "digest": "sha256:c3c03a68714e648f7fc27dad18a77e23eea0cf624c49b98c34e79c38f1fd8518", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 58, - "generated_at_commit": "4197e0bb49ad1e67d9dac37f259246470ffecedc", - "source_tree": "sha256:2130510e8275fd1ae1fdf6078a82521c7ac2fe0ea6ada8a9d1156f0f2ba191fd" + "generated_at_commit": "cde3c1d51cc2106f965ed34c6ae82d311d1b490a", + "source_tree": "sha256:512c73d0501241530565f42bb0b70485649770c301d6050c618fb37c48a4d9c9" }, "owner_lane": "", "provenance": { diff --git a/spec/one-layer-format.md b/spec/one-layer-format.md index 6946161ee..098ab72fc 100644 --- a/spec/one-layer-format.md +++ b/spec/one-layer-format.md @@ -3,7 +3,7 @@ ```text Document ID: SPEC-ONE-LAYER-FORMAT Issue: aien-spark/omega#444 (one-layer plan, stage 2 "Open the binary front door") -Status: IMPLEMENTED for format versions 1..5 (reader + writer); version 6 items OPEN (section 9) +Status: IMPLEMENTED for format versions 1..6 (reader + writer); numeric-identifier version OPEN (section 9) Code: src/compiler/osc_ir.h (osc_ir_encode, osc_ir_decode, OscIrRefusal) src/compiler/osc_ir.c (encode_unit, unit_version, decode_unit) Tests: tests/compiler/test_osc_ir_decode.c; make test-osc-ir-decode(-quick) @@ -42,13 +42,13 @@ All integers little-endian, no padding, no alignment, no pointers. | bytes | field | |---|---| | 7 | magic `4F 53 43 31 49 52 00` ("OSC1IR\0") | -| 1 | version, 1..5 (section 4) | -| versions 2..5 only: 1 | `nstructs` 0..16, then `nstructs` struct records (3.2) | +| 1 | version, 1..6 (section 4) | +| versions 2..6 only: 1 | `nstructs` 0..16, then `nstructs` struct records (3.2) | | 2 | `nfuncs` 0..32, then `nfuncs` function records (3.3) | Nothing may follow the last function record. -### 3.2 Struct record (versions 2..5) +### 3.2 Struct record (versions 2..6) | bytes | field | |---|---| @@ -76,7 +76,8 @@ Nothing may follow the last function record. ### 3.4 Type One byte scalar tag: 0 void, 1 bool, 2 u8, 3 u16, 4 u32, 5 u64, 6 i8, 7 i16, 8 i32, 9 i64, -10 ref, 11 bytes, 12 cells. Tags above 12 are refused. For every tag except 10 that byte is the +10 ref, 11 bytes, 12 cells, 13 f32, 14 f64 (version 6, OSC-4 Slice A). Tags above 14 are refused. +For every tag except 10 that byte is the whole type (the decoded `ref`, `elem`, `len`, `sid` are 0). Tag 10 (ref) continues: | bytes | field | @@ -126,8 +127,17 @@ field: 0x0000..0x7FFF, or 0xFFFF for "none" (-1); 0x8000..0xFFFE are refused (RA | 27 | HSTORE | r a, r b, r c, r args[0] | | 28 | SLOAD | r dst, r a, r b | | 29 | SSTORE | r a, r b, r c | - -Opcode 0 and opcodes above 29 are refused (RANGE): their length is unknown. The numbers are pinned +| 30 | FBIN | 1 sub (1 ADD, 2 SUB, 3 MUL, 4 DIV, 5 MIN, 6 MAX), r dst, r a, r b | +| 31 | FUN | 1 sub (1 NEG, 2 ABS, 3 SQRT), r dst, r a | +| 32 | FCMP | 1 sub (condition, as CMP), r dst, r a, r b | +| 33 | FCVT | r dst, r a | +| 34 | ITOF | 1 sub (1 signed, 2 unsigned: the source), r dst, r a | +| 35 | FTOI | 1 sub (1 signed, 2 unsigned: the destination), r dst, r a | +| 36 | FBITS | r dst, r a | + +Opcode 0 and opcodes above 36 are refused (RANGE): their length is unknown. Opcodes 30..36 are the +OSC-4 Slice A float instructions (docs/osc/OSC-4-DESIGN.md 1.5); a CONST whose register is f32 or f64 +carries the IEEE bit pattern in `imm` (f32: low 32 bits, upper 32 zero). The numbers are pinned by `_Static_assert`s in the test. The meaning of every field and every value range that `osc_ir_validate` enforces (types agree, registers in range, blocks partition the instructions, calls only to earlier functions, trap codes 1..14, and the rest) is in `osc_ir.h` and @@ -143,11 +153,12 @@ each decoded unit with the unit the compiler produced on every carried field. ## 4. Versions and historical readers -The version byte is a function of the content (`unit_version`, `src/compiler/osc_ir.c`): 5 if any +The version byte is a function of the content (`unit_version`, `src/compiler/osc_ir.c`): 6 if any +register, return, struct field or pool element is f32 or f64 or any opcode 30..36 occurs, else 5 if any register is a byte slice (bytes/cells), else 4 if any pool instruction (POPEN..HSTORE) occurs, else 3 if any arena instruction (AOPEN, AALLOC, ADESTROY) occurs, else 2 if the unit has structs, -else 1. Versions 2..5 share one layout (struct table present, possibly empty); version 1 has no -struct table. Every version 1..5 is read. A version byte that is not the one the content requires +else 1. Versions 2..6 share one layout (struct table present, possibly empty); version 1 has no +struct table. Every version 1..6 is read. A version byte that is not the one the content requires is refused (VERSION_MISMATCH), so one unit never has two encodings. Versions are only ever added; an existing version's bytes are never reinterpreted. @@ -179,14 +190,14 @@ run in the order listed. `osc_ir_refusal_name` gives the names. |---|---|---|---| | -1 | ARG | NULL input or output pointer | `osc_ir_decode(NULL, 8, u)` | | -2 | MAGIC | first 7 bytes are not the magic | "OSC2IR..." | -| -3 | UNKNOWN_VERSION | version byte 0 or above 5 | versions 0 and 6 | +| -3 | UNKNOWN_VERSION | version byte 0 or above 6 | versions 0 and 7 | | -4 | TRUNCATED | input ends inside a field | empty input; last byte missing; magic only | | -5 | OVERSIZED | input over `OSC_IR_ENCODED_MAX`, or a count or length over section 5 | 64-byte name; 481 registers; 256-byte requires text; 2,620,252-byte input | | -6 | TRAILING | bytes after the last function | one extra byte | -| -7 | RANGE | unknown opcode, scalar tag or ref kind; a register/block/callee field 0x8000..0xFFFE | opcodes 0 and 30; tag 13; register 0x8000 | +| -7 | RANGE | unknown opcode, scalar tag or ref kind; a register/block/callee field 0x8000..0xFFFE | opcodes 0 and 37; tag 15; register 0x8000 | | -8 | TEXT | a NUL byte inside a name or contract text (it would read back shorter: ambiguous) | name "f\0g" | | -9 | INVALID | well-formed, but `osc_ir_validate` refuses the unit | u8 constant 256; register out of range | -| -10 | VERSION_MISMATCH | version byte differs from the one the content requires (section 4) | version 2 or 5 for a plain unit | +| -10 | VERSION_MISMATCH | version byte differs from the one the content requires (section 4) | version 2, 5 or 6 for a plain unit | | -11 | NONCANONICAL | the unit re-encodes to different bytes | none: unreachable (below) | NONCANONICAL is a backstop. Given the checks above it, every field read back writes back to the @@ -218,11 +229,20 @@ build `tests/compiler/test_osc_ir_decode.c` plain and with ASan/UBSan. Measured 4 no validation, 5 no NUL check, 6 no register range check, 7 no total size check, 8 truncation read as zeros) each make the test fail. +Measured again on the Spark, 2026-10-16, full mode, after version 6 (OSC-4 Slice A floats) was added: +64 corpus units round-trip (32 v1, 7 v2, 6 v3, 3 v4, 11 v5, 5 v6); 10,000 distinct valid objects +round-trip byte-exactly (2,000 under ASan); 223,489 malformed inputs: 195,293 refused with a named +class, 28,196 admitted as another canonical unit, NONCANONICAL 0, no crash (ASan/UBSan leg: 223,496 +cases, 195,299 refused, 28,197 admitted, no sanitizer report); all 23 counterexample cases as +expected, including version 7 (UNKNOWN_VERSION), version 6 on a unit without floats +(VERSION_MISMATCH), tag 15 and opcode 37 (RANGE); 8 of 8 decoder mutants caught. + ## 9. Open (asked by #444, not in this change) - **Numeric identifiers.** Versions 1..5 still carry function, struct and field names as text, and - names are part of identity. A version 6 that identifies functions, structs and fields by index - only (calls and field accesses already do) is not specified here. + names are part of identity. A later version that identifies functions, structs and fields by index + only (calls and field accesses already do) is not specified here. (Version 6 was taken by the + OSC-4 Slice A floats, 2026-10-16: same layout as 2..5 plus tags 13 and 14 and opcodes 30..36.) - **Structured requirement objects.** `requires` / `ensures` are carried as source text; their checks are lowered into the instruction stream by the front end. A structured, machine-readable requirement object (and its place in identity) needs a design decision first. diff --git a/src/.crumb b/src/.crumb index 4fe5298a4..72d3f31a4 100644 --- a/src/.crumb +++ b/src/.crumb @@ -79,8 +79,8 @@ "purpose": "M21 OMEGA_AUTODIFF: reverse-mode tape over M20 tensor CPU ops, caller-owned nodes and scratch, p" }, { - "digest": "bdc017bf3baddb9034478651fb3f170f045ce8aa27187481d15ac5da7fbfd18c", - "last_commit": "1edf41a5", + "digest": "d103f98eeba56e622844ee6981e2e062e1013e6ff3a940bbed77e62fb335944e", + "last_commit": "6e164a12", "name": "compiler", "purpose": "Directory src/compiler. Purpose not yet described by a human." }, @@ -181,15 +181,15 @@ "purpose": "Directory src/visor. Purpose not yet described by a human." } ], - "children_root": "sha256:15012a017b26a269feb256b64875ece2912f5f82c57804baafa3777c4fcb80b9", - "compiled_at": "2026-10-16T07:33:43Z", + "children_root": "sha256:0ef3fae0e131abc502d2ef379eb5d1ba20cc574ed6aeaaf51b05bcbf0dd62d6e", + "compiled_at": "2026-10-16T20:35:19Z", "compiler": "crumb-compile/1", - "digest": "sha256:dfa36de2ac8649f66f80587abea51a7f166285ee0b92e0e09774c98689055250", + "digest": "sha256:f165c505608480659b2696a46a0ccd85fd2190f696674cfaf8ca41c2ce89d1e8", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 537, - "generated_at_commit": "1d481ab853a14d3c11eff926ce1e25993085f76a", - "source_tree": "sha256:200c9243151691313acb5f86d3e9cb3058f1a1b92ece2a255b3340b691dfb894" + "generated_at_commit": "cde3c1d51cc2106f965ed34c6ae82d311d1b490a", + "source_tree": "sha256:92dc5b797dac1e3d4b31a9b3a8b70b607c7fd6fbdd6b67858fcace612d4fbec6" }, "owner_lane": "", "provenance": { diff --git a/src/compiler/.crumb b/src/compiler/.crumb index 9f069fc78..70b243b30 100644 --- a/src/compiler/.crumb +++ b/src/compiler/.crumb @@ -20,14 +20,14 @@ } ], "children_root": "sha256:4067665ff5aaacc482c82c65d5074409c044890a046868d11fdb4faa38bbb95c", - "compiled_at": "2026-10-14T17:37:01Z", + "compiled_at": "2026-10-16T20:35:19Z", "compiler": "crumb-compile/1", - "digest": "sha256:bdc017bf3baddb9034478651fb3f170f045ce8aa27187481d15ac5da7fbfd18c", + "digest": "sha256:d103f98eeba56e622844ee6981e2e062e1013e6ff3a940bbed77e62fb335944e", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 31, - "generated_at_commit": "e9943ed23f0712a7dd1f7248a7d6bb00eabf5ea5", - "source_tree": "sha256:cf6e1630b5ccc657c6356142356038413cf7ec5420d675667111b7e366d3f4e7" + "generated_at_commit": "cde3c1d51cc2106f965ed34c6ae82d311d1b490a", + "source_tree": "sha256:d32931d762ea8f2f0e0bce335bdab6b3bc34df6d018507db8f4ae11025e48cfd" }, "owner_lane": "", "provenance": { diff --git a/src/compiler/osc_a64.c b/src/compiler/osc_a64.c index 9c2da62b8..f233b3512 100644 --- a/src/compiler/osc_a64.c +++ b/src/compiler/osc_a64.c @@ -12,11 +12,13 @@ typedef enum { CLS_NONE = 0, CLS_RRR_SH, CLS_RI, CLS_R4, CLS_MULH, CLS_R3, CLS_BFM, CLS_CSINC, - CLS_MOV16, CLS_MEM, CLS_PAIR, CLS_B26, CLS_BCOND, CLS_CB, CLS_BREG, CLS_BRK + CLS_MOV16, CLS_MEM, CLS_PAIR, CLS_B26, CLS_BCOND, CLS_CB, CLS_BREG, CLS_BRK, + /* OSC-4 scalar FP: type (S/D) in imm2 -> bit 22 (data processing) or bit 30 (loads/stores) */ + CLS_FP3, CLS_FP2, CLS_FCMP, CLS_FMOV_GP, CLS_FCVT_FF, CLS_CVT, CLS_FMEM_UOFF, CLS_FMEM_REG } Cls; -/* operand kinds for rd / rn / rm / ra positions */ -enum { K_NONE = 0, K_ZR, K_SP, K_X }; +/* operand kinds for rd / rn / rm / ra positions; K_V (OSC-4) is a V register 0..31 */ +enum { K_NONE = 0, K_ZR, K_SP, K_X, K_V }; typedef struct { const char *name; @@ -70,6 +72,32 @@ static const OpInfo OPS[OSC_A64_NOPS] = { [OSC_A64_RET] = {"ret", 0xD65F0000u, CLS_BREG, K_NONE, K_X, K_NONE, K_NONE}, [OSC_A64_BRK] = {"brk", 0xD4200000u, CLS_BRK, K_NONE, K_NONE, K_NONE, K_NONE}, [OSC_A64_LDRB_REG] = {"ldrb", 0x38606800u, CLS_R3, K_ZR, K_SP, K_ZR, K_NONE}, + /* OSC-4 Slice A (docs/osc/OSC-4-DESIGN.md 1.6 table; S-form bases, D adds bit 22 or bit 30) */ + [OSC_A64_FMOV_RR] = {"fmov", 0x1E204000u, CLS_FP2, K_V, K_V, K_NONE, K_NONE}, + [OSC_A64_FMOV_XD] = {"fmov", 0x9E670000u, CLS_FMOV_GP, K_V, K_ZR, K_NONE, K_NONE}, + [OSC_A64_FMOV_DX] = {"fmov", 0x9E660000u, CLS_FMOV_GP, K_ZR, K_V, K_NONE, K_NONE}, + [OSC_A64_FMOV_WS] = {"fmov", 0x1E270000u, CLS_FMOV_GP, K_V, K_ZR, K_NONE, K_NONE}, + [OSC_A64_FMOV_SW] = {"fmov", 0x1E260000u, CLS_FMOV_GP, K_ZR, K_V, K_NONE, K_NONE}, + [OSC_A64_FADD] = {"fadd", 0x1E202800u, CLS_FP3, K_V, K_V, K_V, K_NONE}, + [OSC_A64_FSUB] = {"fsub", 0x1E203800u, CLS_FP3, K_V, K_V, K_V, K_NONE}, + [OSC_A64_FMUL] = {"fmul", 0x1E200800u, CLS_FP3, K_V, K_V, K_V, K_NONE}, + [OSC_A64_FDIV] = {"fdiv", 0x1E201800u, CLS_FP3, K_V, K_V, K_V, K_NONE}, + [OSC_A64_FMAXNM] = {"fmaxnm",0x1E206800u, CLS_FP3, K_V, K_V, K_V, K_NONE}, + [OSC_A64_FMINNM] = {"fminnm",0x1E207800u, CLS_FP3, K_V, K_V, K_V, K_NONE}, + [OSC_A64_FSQRT] = {"fsqrt", 0x1E21C000u, CLS_FP2, K_V, K_V, K_NONE, K_NONE}, + [OSC_A64_FNEG] = {"fneg", 0x1E214000u, CLS_FP2, K_V, K_V, K_NONE, K_NONE}, + [OSC_A64_FABS] = {"fabs", 0x1E20C000u, CLS_FP2, K_V, K_V, K_NONE, K_NONE}, + [OSC_A64_FCMP] = {"fcmp", 0x1E202000u, CLS_FCMP, K_NONE, K_V, K_V, K_NONE}, + [OSC_A64_FCVT_SD] = {"fcvt", 0x1E624000u, CLS_FCVT_FF, K_V, K_V, K_NONE, K_NONE}, + [OSC_A64_FCVT_DS] = {"fcvt", 0x1E22C000u, CLS_FCVT_FF, K_V, K_V, K_NONE, K_NONE}, + [OSC_A64_SCVTF_X] = {"scvtf", 0x9E220000u, CLS_CVT, K_V, K_ZR, K_NONE, K_NONE}, + [OSC_A64_UCVTF_X] = {"ucvtf", 0x9E230000u, CLS_CVT, K_V, K_ZR, K_NONE, K_NONE}, + [OSC_A64_FCVTZS_X] = {"fcvtzs",0x9E380000u, CLS_CVT, K_ZR, K_V, K_NONE, K_NONE}, + [OSC_A64_FCVTZU_X] = {"fcvtzu",0x9E390000u, CLS_CVT, K_ZR, K_V, K_NONE, K_NONE}, + [OSC_A64_LDR_F_UOFF] = {"ldr", 0xBD400000u, CLS_FMEM_UOFF, K_V, K_SP, K_NONE, K_NONE}, + [OSC_A64_STR_F_UOFF] = {"str", 0xBD000000u, CLS_FMEM_UOFF, K_V, K_SP, K_NONE, K_NONE}, + [OSC_A64_LDR_F_REG] = {"ldr", 0xBC607800u, CLS_FMEM_REG, K_V, K_SP, K_ZR, K_NONE}, + [OSC_A64_STR_F_REG] = {"str", 0xBC207800u, CLS_FMEM_REG, K_V, K_SP, K_ZR, K_NONE}, }; /* variable-field mask per class (bits not fixed by the opcode) */ @@ -90,6 +118,15 @@ static uint32_t cls_varmask(int cls) { case CLS_CB: return 0x00FFFFFFu; case CLS_BREG: return 0x000003E0u; case CLS_BRK: return 0x001FFFE0u; + /* OSC-4 scalar FP */ + case CLS_FP3: return 0x005F03FFu; /* type 22, Rm 20:16, Rn, Rd */ + case CLS_FP2: return 0x004003FFu; /* type 22, Rn, Rd */ + case CLS_FCMP: return 0x005F03E0u; /* type 22, Rm, Rn (Rd field fixed 00000, E bit 4 fixed 0) */ + case CLS_FMOV_GP: return 0x000003FFu; /* Rn, Rd (one fixed width each) */ + case CLS_FCVT_FF: return 0x000003FFu; + case CLS_CVT: return 0x004003FFu; /* type 22, Rn, Rd */ + case CLS_FMEM_UOFF: return 0x403FFFFFu; /* size bit 30, imm12 21:10, Rn, Rt */ + case CLS_FMEM_REG: return 0x401F03FFu; /* size bit 30, Rm 20:16, Rn, Rt */ default: return 0; } } @@ -106,6 +143,12 @@ static int fail(char *err, size_t n, const char *fmt, ...) { /* map typed operand -> 5-bit field, refusing the wrong kind */ static int regfield(int kind, int r, uint32_t *f, const char *pos, const char *op, char *err, size_t n) { + if (kind == K_V) { /* OSC-4: V0..V31; the XZR / SP spellings are not V registers */ + if (r >= 0 && r <= 31) { *f = (uint32_t)r; return 0; } + if (r == OSC_A64_SP) return fail(err, n, "%s: %s cannot be SP (V register expected)", op, pos); + if (r == OSC_A64_XZR) return fail(err, n, "%s: %s cannot be XZR (V register expected)", op, pos); + return fail(err, n, "%s: %s V register %d out of range", op, pos, r); + } if (r >= 0 && r <= 30) { *f = (uint32_t)r; return 0; } if (kind == K_ZR && r == OSC_A64_XZR) { *f = 31; return 0; } if (kind == K_SP && r == OSC_A64_SP) { *f = 31; return 0; } @@ -115,7 +158,7 @@ static int regfield(int kind, int r, uint32_t *f, const char *pos, const char *o } static int unreg(int kind, uint32_t f) { - if (f < 31) return (int)f; + if (f < 31 || kind == K_V) return (int)f; if (kind == K_ZR) return OSC_A64_XZR; if (kind == K_SP) return OSC_A64_SP; return 255; /* not encodable: re-encode check refuses */ @@ -142,9 +185,13 @@ int osc_a64_encode(const OscA64Insn *in, uint32_t *word, char *err, size_t n) { if (oi->ka != K_NONE && regfield(oi->ka, in->ra, &ra, "ra", nm, err, n)) return -1; int uses_shift = oi->cls == CLS_RRR_SH; int uses_cond = oi->cls == CLS_CSINC || oi->cls == CLS_BCOND; - int uses_imm2 = oi->cls == CLS_RI || oi->cls == CLS_BFM || oi->cls == CLS_MOV16; + int fp_typed = oi->cls == CLS_FP3 || oi->cls == CLS_FP2 || oi->cls == CLS_FCMP || oi->cls == CLS_CVT || + oi->cls == CLS_FMEM_UOFF || oi->cls == CLS_FMEM_REG; + int uses_imm2 = oi->cls == CLS_RI || oi->cls == CLS_BFM || oi->cls == CLS_MOV16 || fp_typed; int uses_imm = !(oi->cls == CLS_R4 || oi->cls == CLS_MULH || oi->cls == CLS_R3 || - oi->cls == CLS_CSINC || oi->cls == CLS_BREG); + oi->cls == CLS_CSINC || oi->cls == CLS_BREG || oi->cls == CLS_FP3 || oi->cls == CLS_FP2 || + oi->cls == CLS_FCMP || oi->cls == CLS_FMOV_GP || oi->cls == CLS_FCVT_FF || oi->cls == CLS_CVT || + oi->cls == CLS_FMEM_REG); if (!uses_shift && in->shift) return fail(err, n, "%s: shift unused but set", nm); if (!uses_cond && in->cond) return fail(err, n, "%s: cond unused but set", nm); if (!uses_imm2 && in->imm2) return fail(err, n, "%s: imm2 unused but set", nm); @@ -225,6 +272,37 @@ int osc_a64_encode(const OscA64Insn *in, uint32_t *word, char *err, size_t n) { if (imm < 0 || imm > 0xFFFF) return fail(err, n, "%s: imm16 %lld out of range", nm, (long long)imm); w |= (uint32_t)imm << 5; break; + /* OSC-4 scalar FP: imm2 is the type, 0 = S, 1 = D */ + case CLS_FP3: + if (imm2 != 0 && imm2 != 1) return fail(err, n, "%s: type %lld refused (0 = S, 1 = D)", nm, (long long)imm2); + w |= ((uint32_t)imm2 << 22) | (rm << 16) | (rn << 5) | rd; + break; + case CLS_FP2: + case CLS_CVT: + if (imm2 != 0 && imm2 != 1) return fail(err, n, "%s: type %lld refused (0 = S, 1 = D)", nm, (long long)imm2); + w |= ((uint32_t)imm2 << 22) | (rn << 5) | rd; + break; + case CLS_FCMP: + if (imm2 != 0 && imm2 != 1) return fail(err, n, "%s: type %lld refused (0 = S, 1 = D)", nm, (long long)imm2); + w |= ((uint32_t)imm2 << 22) | (rm << 16) | (rn << 5); + break; + case CLS_FMOV_GP: + case CLS_FCVT_FF: + w |= (rn << 5) | rd; /* one fixed form each; imm2 was refused above if set */ + break; + case CLS_FMEM_UOFF: { + if (imm2 != 0 && imm2 != 1) return fail(err, n, "%s: type %lld refused (0 = S, 1 = D)", nm, (long long)imm2); + int64_t sc = imm2 ? 8 : 4; + if (imm < 0 || imm > 4095 * sc || (imm % sc)) + return fail(err, n, "%s: offset %lld not a multiple of %lld in 0..%lld", nm, (long long)imm, (long long)sc, + (long long)(4095 * sc)); + w |= ((uint32_t)imm2 << 30) | ((uint32_t)(imm / sc) << 10) | (rn << 5) | rd; + break; + } + case CLS_FMEM_REG: + if (imm2 != 0 && imm2 != 1) return fail(err, n, "%s: type %lld refused (0 = S, 1 = D)", nm, (long long)imm2); + w |= ((uint32_t)imm2 << 30) | (rm << 16) | (rn << 5) | rd; + break; default: return fail(err, n, "bad class"); } @@ -266,6 +344,13 @@ int osc_a64_decode(uint32_t w, OscA64Insn *out) { case CLS_BCOND: d.imm = sext((w >> 5) & 0x7FFFF, 19) * 4; d.cond = (uint8_t)(w & 15); break; case CLS_CB: d.imm = sext((w >> 5) & 0x7FFFF, 19) * 4; break; case CLS_BRK: d.imm = (w >> 5) & 0xFFFF; break; + /* OSC-4 scalar FP */ + case CLS_FP3: case CLS_FP2: case CLS_FCMP: case CLS_CVT: d.imm2 = (w >> 22) & 1; break; + case CLS_FMEM_UOFF: + d.imm2 = (w >> 30) & 1; + d.imm = (int64_t)((w >> 10) & 0xFFF) * (d.imm2 ? 8 : 4); + break; + case CLS_FMEM_REG: d.imm2 = (w >> 30) & 1; break; default: break; } uint32_t re; @@ -332,3 +417,20 @@ OscA64Insn osc_a64_bcond(OscA64Cond c, int64_t off) { OscA64Insn osc_a64_cb(OscA64Op op, int rt, int64_t off) { OscA64Insn i = mk(op); i.rd = r8(rt); i.imm = off; return i; } OscA64Insn osc_a64_breg(OscA64Op op, int rn) { OscA64Insn i = mk(op); i.rn = r8(rn); return i; } OscA64Insn osc_a64_brk(int64_t imm16) { OscA64Insn i = mk(OSC_A64_BRK); i.imm = imm16; return i; } + +/* OSC-4 floats: dbl lands in imm2 unchanged so the encoder sees and refuses anything but 0 / 1 */ +OscA64Insn osc_a64_f3(OscA64Op op, int vd, int vn, int vm, int dbl) { + OscA64Insn i = osc_a64_r3(op, vd, vn, vm); i.imm2 = dbl; return i; +} +OscA64Insn osc_a64_f2(OscA64Op op, int rd, int rn, int dbl) { + OscA64Insn i = mk(op); i.rd = r8(rd); i.rn = r8(rn); i.imm2 = dbl; return i; +} +OscA64Insn osc_a64_fcmp(int vn, int vm, int dbl) { + OscA64Insn i = mk(OSC_A64_FCMP); i.rn = r8(vn); i.rm = r8(vm); i.imm2 = dbl; return i; +} +OscA64Insn osc_a64_fmem(OscA64Op op, int vt, int rn, int64_t off, int dbl) { + OscA64Insn i = osc_a64_mem(op, vt, rn, off); i.imm2 = dbl; return i; +} +OscA64Insn osc_a64_fmem_reg(OscA64Op op, int vt, int rn, int rm, int dbl) { + OscA64Insn i = osc_a64_r3(op, vt, rn, rm); i.imm2 = dbl; return i; +} diff --git a/src/compiler/osc_a64.h b/src/compiler/osc_a64.h index 710451a4b..37ba060dd 100644 --- a/src/compiler/osc_a64.h +++ b/src/compiler/osc_a64.h @@ -60,6 +60,22 @@ typedef enum { OSC_A64_BRK, /* external byte slices: rd = Rt (zero-extended byte), rn = base (SP kind), rm = index (LDRB Wt, [Xn, Xm]) */ OSC_A64_LDRB_REG, + /* OSC-4 Slice A scalar floating point (docs/osc/OSC-4-DESIGN.md 1.6; goldens in + * tests/compiler/aarch64_fp_golden.h). A V operand is numbered 0..31 and never + * takes XZR / SP. imm2 is the type: 0 = S (f32), 1 = D (f64); the GP <-> V moves + * and the f32 <-> f64 converts have one fixed form and require imm2 = 0. + * No fused multiply-add, no FMIN/FMAX (non-NM), no FCMPE, no FCMP #0.0. */ + OSC_A64_FMOV_RR, /* vd = vn */ + OSC_A64_FMOV_XD, OSC_A64_FMOV_DX, /* dd = xn (rd V, rn X/ZR) ; xd = dn (rd X/ZR, rn V) */ + OSC_A64_FMOV_WS, OSC_A64_FMOV_SW, /* sd = wn ; wd = sn (zero-extends into Xd) */ + OSC_A64_FADD, OSC_A64_FSUB, OSC_A64_FMUL, OSC_A64_FDIV, OSC_A64_FMAXNM, OSC_A64_FMINNM, /* vd vn vm */ + OSC_A64_FSQRT, OSC_A64_FNEG, OSC_A64_FABS, /* vd vn */ + OSC_A64_FCMP, /* vn vm (rd unused) */ + OSC_A64_FCVT_SD, OSC_A64_FCVT_DS, /* sd = dn ; dd = sn */ + OSC_A64_SCVTF_X, OSC_A64_UCVTF_X, /* vd = xn (rd V, rn X/ZR) */ + OSC_A64_FCVTZS_X, OSC_A64_FCVTZU_X, /* xd = vn (rd X/ZR, rn V): truncate, saturate, NaN -> 0 */ + OSC_A64_LDR_F_UOFF, OSC_A64_STR_F_UOFF, /* rd = Vt, rn = base (SP kind), imm = byte offset, multiple of 4 (S) / 8 (D) */ + OSC_A64_LDR_F_REG, OSC_A64_STR_F_REG, /* rd = Vt, rn = base (SP kind), rm = index (ZR kind), LSL #2 (S) / #3 (D) */ OSC_A64_NOPS } OscA64Op; @@ -105,5 +121,11 @@ OscA64Insn osc_a64_bcond(OscA64Cond c, int64_t off); OscA64Insn osc_a64_cb(OscA64Op op, int rt, int64_t off); OscA64Insn osc_a64_breg(OscA64Op op, int rn); OscA64Insn osc_a64_brk(int64_t imm16); +/* OSC-4 floats: dbl = 0 for S (f32), 1 for D (f64); anything else is refused by the encoder */ +OscA64Insn osc_a64_f3(OscA64Op op, int vd, int vn, int vm, int dbl); +OscA64Insn osc_a64_f2(OscA64Op op, int rd, int rn, int dbl); +OscA64Insn osc_a64_fcmp(int vn, int vm, int dbl); +OscA64Insn osc_a64_fmem(OscA64Op op, int vt, int rn, int64_t off, int dbl); +OscA64Insn osc_a64_fmem_reg(OscA64Op op, int vt, int rn, int rm, int dbl); #endif /* OSC_A64_H */ diff --git a/src/compiler/osc_cg.c b/src/compiler/osc_cg.c index 5d6145122..cc5ceaf1d 100644 --- a/src/compiler/osc_cg.c +++ b/src/compiler/osc_cg.c @@ -318,6 +318,133 @@ static void gen_cast(Cg *g, const OscFunc *f, const OscInsn *in) { st(g, 9, in->dst); } +/* ---- OSC-4 Slice A floats (docs/osc/OSC-4-DESIGN.md 1.6) ----------------- + * Scratch V registers d16..d20 mirror x9..x13. An f64 fills its 8-byte slot; an + * f32 sits in the low 4 bytes with the upper 4 always zero: it is loaded with + * LDR S from the slot and stored through FMOV Wd, Sn (zero-extends) + STR X, + * so the slot never carries a dirty upper half. */ +static bool is_dbl(const OscFunc *f, int v) { return f->vtype[v].s == OSC_T_F64; } + +static void fld(Cg *g, int vr, int v, bool dbl) { E(g, osc_a64_fmem(OSC_A64_LDR_F_UOFF, vr, SP, slot(v), dbl)); } +static void fst(Cg *g, int vr, int v, bool dbl) { + if (dbl) { E(g, osc_a64_fmem(OSC_A64_STR_F_UOFF, vr, SP, slot(v), 1)); return; } + E(g, osc_a64_f2(OSC_A64_FMOV_SW, 9, vr, 0)); + st(g, 9, v); +} + +/* forward conditional branch over a short in-line sequence: emit placeholder, land later */ +static size_t skip_if(Cg *g) { size_t at = here(g); put(g, 0); return at; } +static void skip_land(Cg *g, size_t at, OscA64Cond c) { patch(g, at, osc_a64_bcond(c, 0), here(g)); } + +static void gen_fbin(Cg *g, const OscFunc *f, const OscInsn *in) { + bool dbl = is_dbl(f, in->a); + OscA64Op op; + switch (in->sub) { + case OSC_FB_ADD: op = OSC_A64_FADD; break; + case OSC_FB_SUB: op = OSC_A64_FSUB; break; + case OSC_FB_MUL: op = OSC_A64_FMUL; break; + case OSC_FB_DIV: op = OSC_A64_FDIV; break; + case OSC_FB_MIN: op = OSC_A64_FMINNM; break; + case OSC_FB_MAX: op = OSC_A64_FMAXNM; break; + default: cg_fail(g, "bad FBIN sub-op"); return; + } + fld(g, 16, in->a, dbl); + fld(g, 17, in->b, dbl); + E(g, osc_a64_f3(op, 16, 16, 17, dbl)); + fst(g, 16, in->dst, dbl); +} + +static void gen_fun(Cg *g, const OscFunc *f, const OscInsn *in) { + bool dbl = is_dbl(f, in->a); + OscA64Op op; + switch (in->sub) { + case OSC_FU_NEG: op = OSC_A64_FNEG; break; + case OSC_FU_ABS: op = OSC_A64_FABS; break; + case OSC_FU_SQRT: op = OSC_A64_FSQRT; break; + default: cg_fail(g, "bad FUN sub-op"); return; + } + fld(g, 16, in->a, dbl); + E(g, osc_a64_f2(op, 16, 16, dbl)); + fst(g, 16, in->dst, dbl); +} + +/* FCMP then CSET: LT -> MI, LE -> LS, GT, GE, EQ, NE read false on an unordered compare (NZCV 0011) */ +static void gen_fcmp(Cg *g, const OscFunc *f, const OscInsn *in) { + bool dbl = is_dbl(f, in->a); + OscA64Cond c; + switch (in->sub) { + case OSC_C_EQ: c = OSC_A64_EQ; break; + case OSC_C_NE: c = OSC_A64_NE; break; + case OSC_C_LT: c = OSC_A64_MI; break; + case OSC_C_LE: c = OSC_A64_LS; break; + case OSC_C_GT: c = OSC_A64_GT; break; + case OSC_C_GE: c = OSC_A64_GE; break; + default: cg_fail(g, "bad FCMP sub-op"); return; + } + fld(g, 16, in->a, dbl); + fld(g, 17, in->b, dbl); + E(g, osc_a64_fcmp(16, 17, dbl)); + E(g, osc_a64_csinc(11, ZR, ZR, (OscA64Cond)(c ^ 1))); /* cset x11, c */ + st(g, 11, in->dst); +} + +static void gen_fcvt(Cg *g, const OscFunc *f, const OscInsn *in) { + bool to_dbl = is_dbl(f, in->dst); + fld(g, 16, in->a, !to_dbl); + E(g, osc_a64_f2(to_dbl ? OSC_A64_FCVT_DS : OSC_A64_FCVT_SD, 16, 16, 0)); + fst(g, 16, in->dst, to_dbl); +} + +/* the integer slot is already canonical (sign- or zero-extended to 64 bits), so the X-form convert is exact */ +static void gen_itof(Cg *g, const OscFunc *f, const OscInsn *in) { + bool dbl = is_dbl(f, in->dst); + ld(g, 9, in->a); + E(g, osc_a64_f2(in->sub == OSC_FI_SIGNED ? OSC_A64_SCVTF_X : OSC_A64_UCVTF_X, 16, 9, dbl)); + fst(g, 16, in->dst, dbl); +} + +/* FCVTZS / FCVTZU to X saturate at 64 bits and give 0 for NaN; a narrower + * destination is clamped to its own range afterwards (compare + skip + move). */ +static void gen_ftoi(Cg *g, const OscFunc *f, const OscInsn *in) { + bool dbl = is_dbl(f, in->a); + OscScalar to = f->vtype[in->dst].s; + unsigned wt = osc_scalar_width(to); + bool s = osc_scalar_signed(to); + fld(g, 16, in->a, dbl); + E(g, osc_a64_f2(s ? OSC_A64_FCVTZS_X : OSC_A64_FCVTZU_X, 9, 16, dbl)); + if (wt < 64) { + if (s) { + mat(g, 10, (uint64_t)((1LL << (wt - 1)) - 1)); + cmp_rr(g, 9, 10); + size_t at = skip_if(g); + E(g, osc_a64_r3s(OSC_A64_ORR_REG, 9, ZR, 10, OSC_A64_LSL, 0)); + skip_land(g, at, OSC_A64_LE); + mat(g, 10, (uint64_t)(-(1LL << (wt - 1)))); + cmp_rr(g, 9, 10); + at = skip_if(g); + E(g, osc_a64_r3s(OSC_A64_ORR_REG, 9, ZR, 10, OSC_A64_LSL, 0)); + skip_land(g, at, OSC_A64_GE); + } else { + mat(g, 10, (1ULL << wt) - 1); + cmp_rr(g, 9, 10); + size_t at = skip_if(g); + E(g, osc_a64_r3s(OSC_A64_ORR_REG, 9, ZR, 10, OSC_A64_LSL, 0)); + skip_land(g, at, OSC_A64_LS); + } + } + st(g, 9, in->dst); +} + +/* bit cast: the cell already holds the pattern; only the 32-bit forms need the + * destination's canonical upper half (sign-extended for i32, zero for u32 / f32) */ +static void gen_fbits(Cg *g, const OscFunc *f, const OscInsn *in) { + OscScalar to = f->vtype[in->dst].s; + ld(g, 9, in->a); + if (to == OSC_T_I32) E(g, osc_a64_bfm(OSC_A64_SBFM, 9, 9, 0, 31)); + else if (osc_scalar_width(to) == 32) zext(g, 9, 32); + st(g, 9, in->dst); +} + static void epilogue(Cg *g) { E(g, osc_a64_ri(OSC_A64_ADD_IMM, SP, SP, g->frame, 0)); E(g, osc_a64_pair(OSC_A64_LDP_POST, 29, 30, SP, 16)); @@ -362,6 +489,14 @@ static void gen_func(Cg *g, const OscUnit *u, int fi) { break; } case OSC_I_CAST: gen_cast(g, f, in); break; + /* OSC-4 Slice A */ + case OSC_I_FBIN: gen_fbin(g, f, in); break; + case OSC_I_FUN: gen_fun(g, f, in); break; + case OSC_I_FCMP: gen_fcmp(g, f, in); break; + case OSC_I_FCVT: gen_fcvt(g, f, in); break; + case OSC_I_ITOF: gen_itof(g, f, in); break; + case OSC_I_FTOI: gen_ftoi(g, f, in); break; + case OSC_I_FBITS: gen_fbits(g, f, in); break; case OSC_I_ALLOC: load_rt(g, 0); mat(g, 1, T[in->dst].len); diff --git a/src/compiler/osc_check.c b/src/compiler/osc_check.c index fbbf9d806..76532f8ba 100644 --- a/src/compiler/osc_check.c +++ b/src/compiler/osc_check.c @@ -591,28 +591,52 @@ static int is_arith(int op) } static int is_cmpop(int op) { return op == OT_EQ || op == OT_NE || op == OT_LT || op == OT_LE || op == OT_GT || op == OT_GE; } +/* OSC-4: the expression contains a float literal (its leaves decide the fold path) */ +static int has_float(C *c, int i) +{ + const OscNode *n = NODE(i); + switch (n->kind) { + case ON_FLOAT: return 1; + case ON_UN: return has_float(c, n->a); + case ON_BIN: return has_float(c, n->a) || has_float(c, n->b); + case ON_INTRIN: return has_float(c, n->a) || (n->b >= 0 && has_float(c, n->b)); + default: return 0; + } +} + /* type comes only from context */ static int ctxfree(C *c, int i) { const OscNode *n = NODE(i); switch (n->kind) { case ON_INT: return 1; + case ON_FLOAT: return n->ival == 0; /* OSC-4: a suffixed literal carries its own type */ case ON_UN: return n->op != OT_BANG && ctxfree(c, n->a); case ON_BIN: if (is_shift(n->op)) return ctxfree(c, n->a); if (is_arith(n->op)) return ctxfree(c, n->a) && ctxfree(c, n->b); return 0; + case ON_INTRIN: return ctxfree(c, n->a) && (n->b < 0 || ctxfree(c, n->b)); default: return 0; } } -/* all leaves literal */ +/* all leaves literal. OSC-4: float constants fold only as a literal or its + * negation (sign flip, the FNEG bit pattern); float arithmetic on literals is + * emitted as run-time IR so the interpreter and the native code share one + * implementation of every rounding step. */ static int constexpr_(C *c, int i) { const OscNode *n = NODE(i); switch (n->kind) { case ON_INT: return 1; - case ON_UN: return n->op != OT_BANG && constexpr_(c, n->a); - case ON_BIN: return (is_shift(n->op) || is_arith(n->op)) && constexpr_(c, n->a) && constexpr_(c, n->b); + case ON_FLOAT: return 1; + case ON_UN: + if (n->op == OT_BANG) return 0; + if (n->op == OT_TILDE && has_float(c, n->a)) return 0; + return constexpr_(c, n->a); + case ON_BIN: + if (has_float(c, i)) return 0; + return (is_shift(n->op) || is_arith(n->op)) && constexpr_(c, n->a) && constexpr_(c, n->b); default: return 0; } } @@ -713,6 +737,9 @@ static int fold(C *c, int i, OscScalar t, i128 *out) v = wrapu(t, v); } break; + case ON_FLOAT: + snprintf(msg, sizeof msg, "float literal where %s is required", tname(t)); + return tmismatch(c, n, tname(t), msg); default: return tmismatch(c, n, NULL, "not a constant"); } @@ -723,6 +750,82 @@ static int fold(C *c, int i, OscScalar t, i128 *out) return 0; } +/* OSC-4 Slice A: fold a float constant (a literal or its negation) at float + * type t; *bits is the IEEE pattern (f32 in the low 32 bits, upper 32 zero). + * f32 spellings go through strtof and f64 through strtod (design 1.3 item 12, + * never strtod then a cast: that would round twice). A literal that rounds to + * inf is FLOAT_CONST_RANGE; one that underflows to zero or a subnormal is a + * value. Negation flips the sign bit, which is exactly what FNEG does. */ +static int ffold(C *c, int i, OscScalar t, uint64_t *bits) +{ + OscNode *n = NODE(i); + char msg[320]; + if (!osc_scalar_is_float(t)) { + snprintf(msg, sizeof msg, "float literal where %s is required", tname(t)); + return tmismatch(c, n, tname(t), msg); + } + uint64_t v; + switch (n->kind) { + case ON_FLOAT: { + OscScalar lit = n->ival == 1 ? OSC_T_F32 : n->ival == 2 ? OSC_T_F64 : t; + if (lit != t) { + snprintf(msg, sizeof msg, "%s literal where %s is required", tname(lit), tname(t)); + return tmismatch(c, n, tname(lit), msg); + } + const OscToken *tk = &c->ast->toks[n->tok]; + char buf[OSC_LEX_NAME_MAX + 1]; + if (tk->len > OSC_LEX_NAME_MAX) { /* the lexer refuses these first; never parse a cut spelling */ + osc_tok_text(c->ast->src, tk, buf, sizeof buf); + osc_diag_set(c->d, OSC_DIAG_CAPACITY, n->line, n->col, buf, 0, NULL, "float literal length", + "float literal longer than %d characters", OSC_LEX_NAME_MAX); + return -1; + } + osc_tok_text(c->ast->src, tk, buf, sizeof buf); + size_t len = strlen(buf); + if (n->ival && len > 3) buf[len - 3] = 0; /* drop the f32 / f64 suffix */ + if (t == OSC_T_F32) { + float f = strtof(buf, NULL); + uint32_t w; + memcpy(&w, &f, 4); + v = w; + if ((w & 0x7f800000u) == 0x7f800000u) { + osc_diag_set(c->d, OSC_DIAG_FLOAT_CONST_RANGE, n->line, n->col, c->sobj, 0, NULL, + "literal rounds to inf", "float literal '%s' does not round to a finite f32", buf); + return -1; + } + } else { + double d = strtod(buf, NULL); + memcpy(&v, &d, 8); + if ((v & 0x7ff0000000000000ull) == 0x7ff0000000000000ull) { + osc_diag_set(c->d, OSC_DIAG_FLOAT_CONST_RANGE, n->line, n->col, c->sobj, 0, NULL, + "literal rounds to inf", "float literal '%s' does not round to a finite f64", buf); + return -1; + } + } + break; + } + case ON_UN: + if (n->op == OT_TILDE) { + osc_diag_set(c->d, OSC_DIAG_FLOAT_BITOP, n->line, n->col, c->sobj, 0, NULL, "bit operator on a float", + "'~' is a bit operator and has no %s form (use 'as ... bits' first)", tname(t)); + return -1; + } + if (ffold(c, n->a, t, &v)) return -1; + v ^= t == OSC_T_F32 ? 0x80000000ull : 0x8000000000000000ull; + break; + case ON_INT: + snprintf(msg, sizeof msg, "integer literal where %s is required (write it with a '.')", tname(t)); + return tmismatch(c, n, tname(t), msg); + default: + return tmismatch(c, n, NULL, "not a constant"); + } + n->ty.s = t; + n->is_const = 1; + n->cval = v; + *bits = v; + return 0; +} + /* ------------------------------------------------------------ contracts (OSC-2) */ /* Static evaluation of a checked contract clause (docs/osc/OSC-2-DESIGN.md @@ -769,6 +872,7 @@ static int ceval(C *c, int i, const CEnv *env, uint64_t *out) if (n->sym >= 0 && n->sym == env->res_sym && env->res_known) { *out = env->res_val; return 1; } return 0; case ON_UN: { + if (osc_scalar_is_float(n->ty.s)) return 0; /* OSC-4: float clauses are decided at run time */ if (!ceval(c, n->a, env, &a)) return 0; OscScalar t = n->ty.s; if (n->op == OT_BANG) { *out = a ^ 1; return 1; } @@ -783,8 +887,9 @@ static int ceval(C *c, int i, const CEnv *env, uint64_t *out) return 1; } case ON_CAST: { - if (!ceval(c, n->a, env, &a)) return 0; OscScalar from = NODE(n->a)->ty.s, to = n->ty.s; + if (osc_scalar_is_float(from) || osc_scalar_is_float(to)) return 0; /* OSC-4 */ + if (!ceval(c, n->a, env, &a)) return 0; i128 v = osc_scalar_signed(from) ? (i128)(int64_t)a : (i128)a; unsigned w = osc_scalar_width(to); i128 lo = osc_scalar_signed(to) ? -((i128)1 << (w - 1)) : 0; @@ -803,6 +908,7 @@ static int ceval(C *c, int i, const CEnv *env, uint64_t *out) *out = b; return 1; } + if (osc_scalar_is_float(n->ty.s) || (is_cmpop(op) && osc_scalar_is_float((OscScalar)n->flag))) return 0; /* OSC-4 */ if (!ceval(c, n->a, env, &a) || !ceval(c, n->b, env, &b)) return 0; if (is_cmpop(op)) { OscScalar T = (OscScalar)n->flag; @@ -914,6 +1020,16 @@ static int want_ok(C *c, const OscNode *n, OscScalar got, OscScalar want) { if (want && got != want) { char msg[320]; + /* OSC-4: a float meeting a different float or an integer is FLOAT_MIXED (design 1.4); + * there is no implicit widening, the program writes the `as`. */ + if ((osc_scalar_is_float(got) || osc_scalar_is_float(want)) && + (osc_scalar_is_float(got) || osc_scalar_is_int(got)) && + (osc_scalar_is_float(want) || osc_scalar_is_int(want))) { + osc_diag_set(c->d, OSC_DIAG_FLOAT_MIXED, n->line, n->col, c->sobj, 0, tname(got), "mixed float types", + "%s used where %s is required; floats never mix with another type without 'as'", + tname(got), tname(want)); + return -1; + } snprintf(msg, sizeof msg, "expression of type %s where %s is required", tname(got), tname(want)); return tmismatch(c, n, tname(got), msg); } @@ -1108,6 +1224,15 @@ static const char *rty(C *c, const OscType *t, char *buf, size_t cap) static int chk_index_len(C *c, const char *name, uint32_t dline, unsigned len, int ix, const OscNode *at); +/* OSC-4 Slice A, design 1.4: a float is never an index (object = the array or slice name) */ +static int float_index(C *c, const char *name, int ix) +{ + const OscNode *x = NODE(ix); + osc_diag_set(c->d, OSC_DIAG_FLOAT_INDEX, x->line, x->col, name, 0, NULL, "float as index", + "the index of '%s' is a float; an index is an integer (convert with 'as')", name); + return -1; +} + /* index expression + static bounds; arr symbol s */ static int chk_index(C *c, int s, int ix, const OscNode *at) { @@ -1117,9 +1242,11 @@ static int chk_index(C *c, int s, int ix, const OscNode *at) static int chk_index_len(C *c, const char *name, uint32_t dline, unsigned len, int ix, const OscNode *at) { OscScalar it; + if (has_float(c, ix)) return float_index(c, name, ix); /* OSC-4: a float literal is never an index */ if (ctxfree(c, ix)) it = (OscScalar)chk(c, ix, OSC_T_I64); else it = (OscScalar)chk(c, ix, 0); if ((int)it < 0) return -1; + if (osc_scalar_is_float(it)) return float_index(c, name, ix); if (!osc_scalar_is_int(it)) return tmismatch(c, NODE(ix), tname(it), "array index must be an integer"); const OscNode *x = NODE(ix); if (x->is_const) { @@ -1194,6 +1321,11 @@ static int chk(C *c, int i, OscScalar want) return -1; } if (want && constexpr_(c, i)) { + if (osc_scalar_is_float(want) || has_float(c, i)) { /* OSC-4 */ + uint64_t bits; + if (ffold(c, i, want, &bits)) return -1; + return (int)want; + } i128 v; if (fold(c, i, want, &v)) return -1; return (int)want; @@ -1201,6 +1333,36 @@ static int chk(C *c, int i, OscScalar want) OscScalar t; switch (n->kind) { case ON_INT: { i128 v; if (fold(c, i, want, &v)) return -1; return (int)want; } /* unreachable: constexpr */ + case ON_FLOAT: { /* OSC-4: reached only without context, so the literal carries a suffix */ + uint64_t bits; + t = n->ival == 2 ? OSC_T_F64 : OSC_T_F32; + if (ffold(c, i, t, &bits)) return -1; + break; + } + case ON_INTRIN: { /* OSC-4: sqrt(x) abs(x) min(a, b) max(a, b) on one float type */ + OscScalar T; + if (n->b < 0) { + int r = chk(c, n->a, ctxfree(c, n->a) ? want : 0); + if (r < 0) return -1; + T = (OscScalar)r; + } else if (ctxfree(c, n->a)) { + int r = chk(c, n->b, ctxfree(c, n->b) ? want : 0); + if (r < 0) return -1; + T = (OscScalar)r; + if (chk(c, n->a, T) < 0) return -1; + } else { + int r = chk(c, n->a, 0); + if (r < 0) return -1; + T = (OscScalar)r; + if (chk(c, n->b, T) < 0) return -1; + } + if (!osc_scalar_is_float(T)) { + snprintf(msg, sizeof msg, "'%s' takes one float type (f32 or f64), not %s", osc_tok_kind_name(n->op), tname(T)); + return tmismatch(c, n, tname(T), msg); + } + t = T; + break; + } case ON_BOOL: t = OSC_T_BOOL; break; @@ -1244,8 +1406,10 @@ static int chk(C *c, int i, OscScalar want) "cells read in ensures", "an ensures clause may not read the written slice '%s'", c->sym[s].name); return -1; } + if (has_float(c, n->a)) return float_index(c, c->sym[s].name, n->a); /* OSC-4 */ int r = chk(c, n->a, ctxfree(c, n->a) ? OSC_T_I64 : 0); if (r < 0) return -1; + if (osc_scalar_is_float((OscScalar)r)) return float_index(c, c->sym[s].name, n->a); if (!osc_scalar_is_int((OscScalar)r)) return tmismatch(c, NODE(n->a), tname((OscScalar)r), "slice index must be an integer"); t = OSC_T_U64; break; @@ -1318,6 +1482,14 @@ static int chk(C *c, int i, OscScalar want) int r = chk(c, n->a, ctxfree(c, n->a) ? want : 0); if (r < 0) return -1; t = (OscScalar)r; + if (osc_scalar_is_float(t)) { /* OSC-4: '-' is FNEG; '~' has no float form */ + if (n->op == OT_TILDE) { + osc_diag_set(c->d, OSC_DIAG_FLOAT_BITOP, n->line, n->col, c->sobj, 0, NULL, "bit operator on a float", + "'~' is a bit operator and has no %s form (use 'as ... bits' first)", tname(t)); + return -1; + } + break; + } if (!osc_scalar_is_int(t)) return tmismatch(c, n, tname(t), "'-' and '~' need an integer operand"); break; } @@ -1329,12 +1501,33 @@ static int chk(C *c, int i, OscScalar want) } int r = chk(c, n->a, 0); if (r < 0) return -1; - if (!osc_scalar_is_int((OscScalar)r) || !osc_scalar_is_int(n->ty.s)) { - snprintf(msg, sizeof msg, "'as' converts between integer types only (%s as %s)", tname((OscScalar)r), - tname(n->ty.s)); - return tmismatch(c, n, tname((OscScalar)r), msg); + OscScalar from = (OscScalar)r, to = n->ty.s; + if (n->flag) { /* OSC-4: `as T bits` reinterprets; exactly one float side, equal widths */ + int nf = (int)osc_scalar_is_float(from) + (int)osc_scalar_is_float(to); + int ok = nf == 1 && (osc_scalar_is_float(from) ? osc_scalar_is_int(to) : osc_scalar_is_int(from)) && + osc_scalar_width(from) == osc_scalar_width(to); + if (!ok) { + osc_diag_set(c->d, OSC_DIAG_FLOAT_BITS_WIDTH, n->line, n->col, c->sobj, 0, tname(from), "bit cast shape", + "'%s as %s bits' is not a bit cast: 'bits' needs one float side and one integer side of the " + "same width (f32 with u32/i32, f64 with u64/i64)", tname(from), tname(to)); + return -1; + } + t = to; + break; } - t = n->ty.s; + if (osc_scalar_is_float(from) || osc_scalar_is_float(to)) { /* OSC-4: int <-> float, float <-> float */ + if (!(osc_scalar_is_float(from) || osc_scalar_is_int(from)) || !(osc_scalar_is_float(to) || osc_scalar_is_int(to))) { + snprintf(msg, sizeof msg, "'as' converts between integer and float types only (%s as %s)", tname(from), tname(to)); + return tmismatch(c, n, tname(from), msg); + } + t = to; + break; + } + if (!osc_scalar_is_int(from) || !osc_scalar_is_int(to)) { + snprintf(msg, sizeof msg, "'as' converts between integer types only (%s as %s)", tname(from), tname(to)); + return tmismatch(c, n, tname(from), msg); + } + t = to; break; } case ON_BIN: { @@ -1373,6 +1566,11 @@ static int chk(C *c, int i, OscScalar want) int r = chk(c, n->a, ctxfree(c, n->a) ? want : 0); if (r < 0) return -1; OscScalar T = (OscScalar)r; + if (osc_scalar_is_float(T)) { /* OSC-4 */ + osc_diag_set(c->d, OSC_DIAG_FLOAT_BITOP, n->line, n->col, c->sobj, 0, NULL, "bit operator on a float", + "shifts have no %s form (use 'as ... bits' first)", tname(T)); + return -1; + } if (!osc_scalar_is_int(T)) return tmismatch(c, n, tname(T), "shift of a non-integer"); int ra; if (ctxfree(c, n->b)) ra = chk(c, n->b, T); @@ -1412,6 +1610,16 @@ static int chk(C *c, int i, OscScalar want) if (T == OSC_T_BOOL) return tmismatch(c, NODE(n->a), "bool", "arithmetic on bool"); if (chk(c, n->b, T) < 0) return -1; } + if (osc_scalar_is_float(T)) { /* OSC-4: + - * / only; x / 0.0 is inf, a value, not a trap */ + if (op != OT_PLUS && op != OT_MINUS && op != OT_STAR && op != OT_SLASH) { + osc_diag_set(c->d, OSC_DIAG_FLOAT_BITOP, n->line, n->col, c->sobj, 0, NULL, "bit operator on a float", + "'%s' has no %s form (floats have + - * / only; use 'as ... bits' for bit work)", + osc_tok_kind_name(op), tname(T)); + return -1; + } + t = T; + break; + } if (!osc_scalar_is_int(T)) return tmismatch(c, n, tname(T), "arithmetic needs integer operands"); if ((op == OT_SLASH || op == OT_PERCENT) && NODE(n->b)->is_const && NODE(n->b)->cval == 0) return ovf(c, NODE(n->b), "literal zero divisor", "division by a constant zero"); @@ -2084,8 +2292,10 @@ static int chk_stmt(C *c, int i) return slice_diag(c, n, OSC_DIAG_SLICE_WRITE, y, "write to a bytes slice", "a 'bytes' slice is read-only: there is no way to write an element of it"); if (slice_noescape(c, n->b)) return -1; + if (has_float(c, n->a)) return float_index(c, y->name, n->a); /* OSC-4 */ int r = chk(c, n->a, ctxfree(c, n->a) ? OSC_T_I64 : 0); if (r < 0) return -1; + if (osc_scalar_is_float((OscScalar)r)) return float_index(c, y->name, n->a); if (!osc_scalar_is_int((OscScalar)r)) return tmismatch(c, NODE(n->a), tname((OscScalar)r), "slice index must be an integer"); return chk(c, n->b, OSC_T_U64) < 0 ? -1 : 0; } diff --git a/src/compiler/osc_diag.c b/src/compiler/osc_diag.c index 6c1a3d8b2..2abe2335f 100644 --- a/src/compiler/osc_diag.c +++ b/src/compiler/osc_diag.c @@ -15,7 +15,8 @@ static const char *const kind_names[OSC_DIAG__COUNT] = { "READ_ONLY_BORROW", "CONTRACT_INVALID", "CONTRACT_VIOLATION", "UNKNOWN_FIELD", "DUPLICATE_FIELD", "MISSING_FIELD", "UNDEFINED_TYPE", "RECURSIVE_STRUCT", "ARENA_ESCAPE", "ARENA_MOVE", "ARENA_CAPACITY", "STALE_HANDLE", "WRONG_POOL", "POOL_CAPACITY", "GENERATION_EXHAUSTED", "IMPORT_REFUSED", - "SLICE_ESCAPE", "SLICE_VALUE", "SLICE_WRITE", "SLICE_PARAMS", "SLICE_ALIAS"}; + "SLICE_ESCAPE", "SLICE_VALUE", "SLICE_WRITE", "SLICE_PARAMS", "SLICE_ALIAS", + "FLOAT_MIXED", "FLOAT_BITOP", "FLOAT_INDEX", "FLOAT_BITS_WIDTH", "FLOAT_CONST_RANGE"}; const char *osc_diag_kind_name(int kind) { diff --git a/src/compiler/osc_diag.h b/src/compiler/osc_diag.h index 708567822..0f1a070de 100644 --- a/src/compiler/osc_diag.h +++ b/src/compiler/osc_diag.h @@ -53,6 +53,12 @@ typedef enum { OSC_DIAG_SLICE_WRITE, /* an assignment to an element of a bytes slice */ OSC_DIAG_SLICE_PARAMS, /* slice parameters need more than six registers (a slice counts two) */ OSC_DIAG_SLICE_ALIAS, /* one cells slice is passed twice in one call (the callee would see two aliasing params) */ + /* OSC-4 Slice A floats (docs/osc/OSC-4-DESIGN.md 1.4), appended */ + OSC_DIAG_FLOAT_MIXED, /* arithmetic or compare between f32 and f64, or float and int, without `as` */ + OSC_DIAG_FLOAT_BITOP, /* % & | ^ << >> or ~ applied to a float */ + OSC_DIAG_FLOAT_INDEX, /* float used as an array index, loop bound or `bound` */ + OSC_DIAG_FLOAT_BITS_WIDTH, /* `as ... bits` between sizes that differ, or without exactly one float side */ + OSC_DIAG_FLOAT_CONST_RANGE, /* float literal that does not round to a finite value of its type */ OSC_DIAG__COUNT } OscDiagKind; diff --git a/src/compiler/osc_interp.c b/src/compiler/osc_interp.c index 999a1d014..faa1bf582 100644 --- a/src/compiler/osc_interp.c +++ b/src/compiler/osc_interp.c @@ -8,6 +8,7 @@ */ #include "osc_interp.h" +#include #include typedef struct { @@ -106,6 +107,144 @@ static uint64_t do_cast(Ctx *c, OscScalar to, OscScalar from, uint64_t a) { return (uint64_t)v; } +/* ---- OSC-4 Slice A floats (docs/osc/OSC-4-DESIGN.md 1.3) ---------------- + * Plain C float / double on volatile locals, one C expression per IR op, built + * with -ffp-contract=off -fno-fast-math -fno-math-errno (mk/compiler.mk), so + * every op is one hardware instruction with one RNE rounding, the same the + * native code performs. f32 values live in the low 32 bits of a cell. */ +static float f32_of(uint64_t x) { uint32_t w = (uint32_t)x; float f; memcpy(&f, &w, 4); return f; } +static double f64_of(uint64_t x) { double d; memcpy(&d, &x, 8); return d; } +static uint64_t bits_f32(float f) { uint32_t w; memcpy(&w, &f, 4); return w; } +static uint64_t bits_f64(double d) { uint64_t w; memcpy(&w, &d, 8); return w; } + +static bool fnan(bool dbl, uint64_t a) { + return dbl ? (a & 0x7fffffffffffffffull) > 0x7ff0000000000000ull : (a & 0x7fffffffu) > 0x7f800000u; +} +static bool fsnan(bool dbl, uint64_t a) { + return fnan(dbl, a) && !(a & (dbl ? 0x0008000000000000ull : 0x00400000ull)); +} +static uint64_t fquiet(bool dbl, uint64_t a) { return a | (dbl ? 0x0008000000000000ull : 0x00400000ull); } +static bool fsign(bool dbl, uint64_t a) { return (a >> (dbl ? 63 : 31)) & 1; } + +/* FMINNM / FMAXNM (IEEE minNum / maxNum, design 1.1 item 6 and 1.3 item 11): a + * signalling NaN propagates quieted (first operand first), one quiet NaN yields + * the other operand, two quiet NaNs yield the first, and -0.0 orders below +0.0. + * C fmin / fmax are never called. */ +static uint64_t do_fminmax(bool dbl, bool is_max, uint64_t a, uint64_t b) { + bool an = fnan(dbl, a), bn = fnan(dbl, b); + if (an || bn) { + if (fsnan(dbl, a)) return fquiet(dbl, a); + if (fsnan(dbl, b)) return fquiet(dbl, b); + if (an && bn) return a; + return an ? b : a; + } + bool lt, eq; + if (dbl) { volatile double x = f64_of(a), y = f64_of(b); lt = x < y; eq = x == y; } + else { volatile float x = f32_of(a), y = f32_of(b); lt = x < y; eq = x == y; } + if (eq) { /* equal values: only the zeros can differ in bits, by sign */ + bool neg_a = fsign(dbl, a); + return is_max ? (neg_a ? b : a) : (neg_a ? a : b); + } + return is_max ? (lt ? b : a) : (lt ? a : b); +} + +static uint64_t do_fbin(Ctx *c, unsigned sub, bool dbl, uint64_t a, uint64_t b) { + if (sub == OSC_FB_MIN || sub == OSC_FB_MAX) return do_fminmax(dbl, sub == OSC_FB_MAX, a, b); + if (dbl) { + volatile double x = f64_of(a), y = f64_of(b), r; + switch (sub) { + case OSC_FB_ADD: r = x + y; break; + case OSC_FB_SUB: r = x - y; break; + case OSC_FB_MUL: r = x * y; break; + case OSC_FB_DIV: r = x / y; break; + default: trap(c, OSC_TRAP_RUNTIME); return 0; + } + return bits_f64(r); + } + volatile float x = f32_of(a), y = f32_of(b), r; + switch (sub) { + case OSC_FB_ADD: r = x + y; break; + case OSC_FB_SUB: r = x - y; break; + case OSC_FB_MUL: r = x * y; break; + case OSC_FB_DIV: r = x / y; break; + default: trap(c, OSC_TRAP_RUNTIME); return 0; + } + return bits_f32(r); +} + +/* NEG is `-x` (FNEG: sign flip, so -(+0.0) is -0.0), ABS clears the sign, SQRT + * is the correctly rounded sqrt / sqrtf (the only libm calls, inlined to FSQRT). */ +static uint64_t do_fun(Ctx *c, unsigned sub, bool dbl, uint64_t a) { + if (dbl) { + volatile double x = f64_of(a), r; + switch (sub) { + case OSC_FU_NEG: r = -x; break; + case OSC_FU_ABS: return a & 0x7fffffffffffffffull; + case OSC_FU_SQRT: r = sqrt(x); break; + default: trap(c, OSC_TRAP_RUNTIME); return 0; + } + return bits_f64(r); + } + volatile float x = f32_of(a), r; + switch (sub) { + case OSC_FU_NEG: r = -x; break; + case OSC_FU_ABS: return a & 0x7fffffffu; + case OSC_FU_SQRT: r = sqrtf(x); break; + default: trap(c, OSC_TRAP_RUNTIME); return 0; + } + return bits_f32(r); +} + +/* C comparison operators: every ordered relation and == read false on NaN, != true (FCMP + cond) */ +static uint64_t do_fcmp(unsigned cc, bool dbl, uint64_t a, uint64_t b) { + bool lt, eq, gt; + if (dbl) { volatile double x = f64_of(a), y = f64_of(b); lt = x < y; eq = x == y; gt = x > y; } + else { volatile float x = f32_of(a), y = f32_of(b); lt = x < y; eq = x == y; gt = x > y; } + switch (cc) { + case OSC_C_EQ: return eq; + case OSC_C_NE: return !eq; + case OSC_C_LT: return lt; + case OSC_C_LE: return lt || eq; + case OSC_C_GT: return gt; + case OSC_C_GE: return gt || eq; + default: return 0; + } +} + +static uint64_t do_fcvt(bool to_dbl, uint64_t a) { + if (to_dbl) { volatile float x = f32_of(a); volatile double r = (double)x; return bits_f64(r); } + volatile double x = f64_of(a); volatile float r = (float)x; return bits_f32(r); +} + +static uint64_t do_itof(unsigned sub, bool dbl, uint64_t a) { + if (dbl) { + volatile double r = sub == OSC_FI_SIGNED ? (double)(int64_t)a : (double)a; + return bits_f64(r); + } + volatile float r = sub == OSC_FI_SIGNED ? (float)(int64_t)a : (float)a; + return bits_f32(r); +} + +/* FCVTZS / FCVTZU semantics spelled out: truncate toward zero, saturate at the + * destination's range, NaN -> 0. C's out-of-range conversion is undefined, so + * the range test happens first, in double (an f32 widens to double exactly). */ +static uint64_t do_ftoi(bool dbl, uint64_t a, OscScalar to) { + if (fnan(dbl, a)) return 0; + volatile double x = dbl ? f64_of(a) : (double)f32_of(a); + unsigned w = osc_scalar_width(to); + double half = (double)(1ULL << (w - 1)); /* 2^(w-1), exact */ + if (osc_scalar_signed(to)) { + if (x >= half) return canon(to, (uint64_t)smax(w)); + if (x <= -half) return canon(to, (uint64_t)smin(w)); + volatile int64_t v = (int64_t)x; + return canon(to, (uint64_t)v); + } + if (x <= 0.0) return 0; /* also every negative value and -0.0 */ + if (x >= half * 2.0) return w >= 64 ? UINT64_MAX : (1ULL << w) - 1; + volatile uint64_t v = (uint64_t)x; + return v; +} + /* element pointer with the bounds rule of section 5 */ static uint64_t *elem(Ctx *c, const OscType *rt_, uint64_t base, OscScalar ti, uint64_t idx) { if (osc_scalar_signed(ti) && (int64_t)idx < 0) trap(c, OSC_TRAP_BOUNDS); @@ -166,6 +305,14 @@ static uint64_t run_func(Ctx *c, int fi, const uint64_t *args) { case OSC_I_UN: v[in->dst] = do_un(c, in->sub, T[in->a].s, v[in->a]); break; case OSC_I_CMP: v[in->dst] = do_cmp(in->sub, T[in->a].s, v[in->a], v[in->b]); break; case OSC_I_CAST: v[in->dst] = do_cast(c, T[in->dst].s, T[in->a].s, v[in->a]); break; + /* OSC-4 Slice A */ + case OSC_I_FBIN: v[in->dst] = do_fbin(c, in->sub, T[in->a].s == OSC_T_F64, v[in->a], v[in->b]); break; + case OSC_I_FUN: v[in->dst] = do_fun(c, in->sub, T[in->a].s == OSC_T_F64, v[in->a]); break; + case OSC_I_FCMP: v[in->dst] = do_fcmp(in->sub, T[in->a].s == OSC_T_F64, v[in->a], v[in->b]); break; + case OSC_I_FCVT: v[in->dst] = do_fcvt(T[in->dst].s == OSC_T_F64, v[in->a]); break; + case OSC_I_ITOF: v[in->dst] = do_itof(in->sub, T[in->dst].s == OSC_T_F64, v[in->a]); break; + case OSC_I_FTOI: v[in->dst] = do_ftoi(T[in->a].s == OSC_T_F64, v[in->a], T[in->dst].s); break; + case OSC_I_FBITS: v[in->dst] = canon(T[in->dst].s, v[in->a]); break; case OSC_I_ALLOC: v[in->dst] = osc_rt_alloc(c->rt, T[in->dst].len, v[in->a]); break; case OSC_I_RELEASE: osc_rt_release(c->rt, v[in->a], T[in->a].len); break; case OSC_I_AOPEN: v[in->dst] = osc_rt_arena_open(c->rt, in->imm); break; diff --git a/src/compiler/osc_ir.c b/src/compiler/osc_ir.c index da7dcf82c..eafe61f8d 100644 --- a/src/compiler/osc_ir.c +++ b/src/compiler/osc_ir.c @@ -19,14 +19,17 @@ unsigned osc_scalar_width(OscScalar s) { case OSC_T_U16: case OSC_T_I16: return 16; case OSC_T_U32: case OSC_T_I32: return 32; case OSC_T_U64: case OSC_T_I64: return 64; + case OSC_T_F32: return 32; /* OSC-4: bit pattern in the low 32 bits, upper 32 zero */ + case OSC_T_F64: return 64; default: return 0; } } bool osc_scalar_signed(OscScalar s) { return s >= OSC_T_I8 && s <= OSC_T_I64; } bool osc_scalar_is_int(OscScalar s) { return s >= OSC_T_U8 && s <= OSC_T_I64; } +bool osc_scalar_is_float(OscScalar s) { return s == OSC_T_F32 || s == OSC_T_F64; } const char *osc_scalar_name(OscScalar s) { - static const char *n[] = {"void", "bool", "u8", "u16", "u32", "u64", "i8", "i16", "i32", "i64", "ref", "bytes", "cells"}; - return ((unsigned)s <= OSC_T_CELLS) ? n[s] : "?"; + static const char *n[] = {"void", "bool", "u8", "u16", "u32", "u64", "i8", "i16", "i32", "i64", "ref", "bytes", "cells", "f32", "f64"}; + return ((unsigned)s <= OSC_T_F64) ? n[s] : "?"; } /* ---- validation ------------------------------------------------------- */ @@ -40,7 +43,7 @@ static int vfail(char *err, size_t n, const char *fmt, ...) { return -1; } -static bool is_value_scalar(OscScalar s) { return s >= OSC_T_BOOL && s <= OSC_T_I64; } +static bool is_value_scalar(OscScalar s) { return (s >= OSC_T_BOOL && s <= OSC_T_I64) || osc_scalar_is_float(s); } static bool type_is_scalar(const OscType *t) { return is_value_scalar(t->s) && t->ref == OSC_REF_NONE && t->elem == OSC_T_VOID && t->len == 0 && t->sid == 0; @@ -101,6 +104,8 @@ static int insn_uses(const OscInsn *in, int16_t *u) { case OSC_I_HFREE: case OSC_I_HLOAD: u[k++] = in->a; u[k++] = in->b; u[k++] = in->c; break; case OSC_I_HSTORE: u[k++] = in->a; u[k++] = in->b; u[k++] = in->c; u[k++] = in->args[0]; break; case OSC_I_BIN: case OSC_I_CMP: case OSC_I_LOAD: u[k++] = in->a; u[k++] = in->b; break; + case OSC_I_FBIN: case OSC_I_FCMP: u[k++] = in->a; u[k++] = in->b; break; + case OSC_I_FUN: case OSC_I_FCVT: case OSC_I_ITOF: case OSC_I_FTOI: case OSC_I_FBITS: u[k++] = in->a; break; case OSC_I_STORE: u[k++] = in->a; u[k++] = in->b; u[k++] = in->c; break; case OSC_I_SLOAD: u[k++] = in->a; u[k++] = in->a + 1; u[k++] = in->b; break; case OSC_I_SSTORE: u[k++] = in->a; u[k++] = in->a + 1; u[k++] = in->b; u[k++] = in->c; break; @@ -118,6 +123,7 @@ static int insn_def(const OscInsn *in) { case OSC_I_CAST: case OSC_I_ALLOC: case OSC_I_LOAD: case OSC_I_FLOAD: case OSC_I_SLOAD: return in->dst; case OSC_I_AOPEN: case OSC_I_AALLOC: return in->dst; case OSC_I_POPEN: case OSC_I_HALLOC: case OSC_I_HGEN: case OSC_I_HLOAD: return in->dst; + case OSC_I_FBIN: case OSC_I_FUN: case OSC_I_FCMP: case OSC_I_FCVT: case OSC_I_ITOF: case OSC_I_FTOI: case OSC_I_FBITS: return in->dst; case OSC_I_CALL: return in->dst; /* may be -1 */ default: return -1; } @@ -149,6 +155,7 @@ static int validate_insn(const OscUnit *u, int fi, const OscFunc *f, uint32_t ii NEED(in->sub >= OSC_B_ADD && in->sub <= OSC_B_SHR, "BIN bad sub-op %u", fi, ii, in->sub); const OscType *d = &T[in->dst], *a = &T[in->a], *b = &T[in->b]; NEED(type_is_scalar(d) && type_eq(d, a), "BIN dst/a type mismatch", fi, ii); + NEED(!osc_scalar_is_float(a->s), "BIN on a float (use FBIN)", fi, ii); if (in->sub == OSC_B_SHL || in->sub == OSC_B_SHR) { NEED(osc_scalar_is_int(a->s), "shift of non-integer", fi, ii); NEED(type_is_scalar(b) && osc_scalar_is_int(b->s), "shift amount not integer", fi, ii); @@ -173,6 +180,7 @@ static int validate_insn(const OscUnit *u, int fi, const OscFunc *f, uint32_t ii NEED(in->sub >= OSC_C_EQ && in->sub <= OSC_C_GE, "CMP bad cc %u", fi, ii, in->sub); NEED(type_is_scalar(&T[in->dst]) && T[in->dst].s == OSC_T_BOOL, "CMP dst not bool", fi, ii); NEED(type_is_scalar(&T[in->a]) && type_eq(&T[in->a], &T[in->b]), "CMP operand type mismatch", fi, ii); + NEED(!osc_scalar_is_float(T[in->a].s), "CMP on a float (use FCMP)", fi, ii); break; case OSC_I_CAST: NEED(VR(in->dst) && VR(in->a), "CAST bad vreg", fi, ii); @@ -249,6 +257,56 @@ static int validate_insn(const OscUnit *u, int fi, const OscFunc *f, uint32_t ii NEED(type_is_scalar(&T[in->b]) && osc_scalar_is_int(T[in->b].s), "STORE index not integer", fi, ii); NEED(type_is_scalar(&T[in->c]) && T[in->c].s == T[in->a].elem, "STORE value type != elem", fi, ii); break; + /* OSC-4 Slice A floats (docs/osc/OSC-4-DESIGN.md 1.5 item 3) */ + case OSC_I_FBIN: { + NEED(VR(in->dst) && VR(in->a) && VR(in->b), "FBIN bad vreg", fi, ii); + NEED(in->sub >= OSC_FB_ADD && in->sub <= OSC_FB_MAX, "FBIN bad sub-op %u", fi, ii, in->sub); + const OscType *d = &T[in->dst], *a = &T[in->a], *b = &T[in->b]; + NEED(type_is_scalar(d) && osc_scalar_is_float(d->s) && type_eq(d, a) && type_eq(a, b), + "FBIN needs identical float types", fi, ii); + break; + } + case OSC_I_FUN: { + NEED(VR(in->dst) && VR(in->a), "FUN bad vreg", fi, ii); + NEED(in->sub >= OSC_FU_NEG && in->sub <= OSC_FU_SQRT, "FUN bad sub-op %u", fi, ii, in->sub); + const OscType *d = &T[in->dst], *a = &T[in->a]; + NEED(type_is_scalar(d) && osc_scalar_is_float(d->s) && type_eq(d, a), "FUN needs one float type", fi, ii); + break; + } + case OSC_I_FCMP: + NEED(VR(in->dst) && VR(in->a) && VR(in->b), "FCMP bad vreg", fi, ii); + NEED(in->sub >= OSC_C_EQ && in->sub <= OSC_C_GE, "FCMP bad cc %u", fi, ii, in->sub); + NEED(type_is_scalar(&T[in->dst]) && T[in->dst].s == OSC_T_BOOL, "FCMP dst not bool", fi, ii); + NEED(type_is_scalar(&T[in->a]) && osc_scalar_is_float(T[in->a].s) && type_eq(&T[in->a], &T[in->b]), + "FCMP needs identical float types", fi, ii); + break; + case OSC_I_FCVT: + NEED(VR(in->dst) && VR(in->a), "FCVT bad vreg", fi, ii); + NEED(type_is_scalar(&T[in->dst]) && osc_scalar_is_float(T[in->dst].s) && type_is_scalar(&T[in->a]) && + osc_scalar_is_float(T[in->a].s) && T[in->dst].s != T[in->a].s, "FCVT needs two distinct float types", fi, ii); + NEED(in->sub == 0, "FCVT sub must be 0", fi, ii); + break; + case OSC_I_ITOF: + NEED(VR(in->dst) && VR(in->a), "ITOF bad vreg", fi, ii); + NEED(type_is_scalar(&T[in->dst]) && osc_scalar_is_float(T[in->dst].s) && type_is_scalar(&T[in->a]) && + osc_scalar_is_int(T[in->a].s), "ITOF needs int -> float", fi, ii); + NEED(in->sub == (osc_scalar_signed(T[in->a].s) ? OSC_FI_SIGNED : OSC_FI_UNSIGNED), "ITOF sub does not match source signedness", fi, ii); + break; + case OSC_I_FTOI: + NEED(VR(in->dst) && VR(in->a), "FTOI bad vreg", fi, ii); + NEED(type_is_scalar(&T[in->dst]) && osc_scalar_is_int(T[in->dst].s) && type_is_scalar(&T[in->a]) && + osc_scalar_is_float(T[in->a].s), "FTOI needs float -> int", fi, ii); + NEED(in->sub == (osc_scalar_signed(T[in->dst].s) ? OSC_FI_SIGNED : OSC_FI_UNSIGNED), "FTOI sub does not match destination signedness", fi, ii); + break; + case OSC_I_FBITS: { + NEED(VR(in->dst) && VR(in->a), "FBITS bad vreg", fi, ii); + const OscType *d = &T[in->dst], *a = &T[in->a]; + NEED(type_is_scalar(d) && type_is_scalar(a) && (osc_scalar_is_float(d->s) != osc_scalar_is_float(a->s)) && + (osc_scalar_is_int(d->s) || osc_scalar_is_int(a->s)) && osc_scalar_width(d->s) == osc_scalar_width(a->s), + "FBITS needs a float and an integer of the same width", fi, ii); + NEED(in->sub == 0, "FBITS sub must be 0", fi, ii); + break; + } case OSC_I_SLOAD: case OSC_I_SSTORE: { bool ld = in->op == OSC_I_SLOAD; @@ -606,10 +664,30 @@ static bool unit_has_slice(const OscUnit *u) { return false; } +/* 1 if any function uses a float type or a float instruction (OSC-4 Slice A) */ +static bool unit_has_float(const OscUnit *u) { + for (int fi = 0; fi < u->nfuncs; fi++) { + const OscFunc *f = &u->funcs[fi]; + if (osc_scalar_is_float(f->ret.s) || osc_scalar_is_float(f->ret.elem)) return true; + for (int v = 0; v < f->nvregs; v++) + if (osc_scalar_is_float(f->vtype[v].s) || osc_scalar_is_float(f->vtype[v].elem)) return true; + for (uint32_t i = 0; i < f->ninsns; i++) { + uint8_t op = f->insns[i].op; + if (op >= OSC_I_FBIN && op <= OSC_I_FBITS) return true; + if (op == OSC_I_POPEN && osc_scalar_is_float((OscScalar)f->insns[i].sub)) return true; + } + } + for (int s = 0; s < u->nstructs; s++) + for (int k = 0; k < u->structs[s].nfields; k++) + if (osc_scalar_is_float(u->structs[s].fields[k].s)) return true; + return false; +} + /* The format version a unit encodes as: the highest feature it uses decides. - * 5 = external byte slices, 4 = pools (OSC-3 item 2), 3 = arenas, 2 = structs, - * 1 = none of these. Versions 2..5 share one layout (struct table after the magic). */ + * 6 = floats (OSC-4 Slice A), 5 = external byte slices, 4 = pools (OSC-3 item 2), 3 = arenas, 2 = structs, + * 1 = none of these. Versions 2..6 share one layout (struct table after the magic). */ static uint8_t unit_version(const OscUnit *u) { + if (unit_has_float(u)) return 6; if (unit_has_slice(u)) return 5; if (unit_has_pool(u)) return 4; if (unit_has_arena(u)) return 3; @@ -675,6 +753,9 @@ static void encode_unit(const OscUnit *u, W *w) { case OSC_I_STORE: wvr(w, in->a); wvr(w, in->b); wvr(w, in->c); break; case OSC_I_SLOAD: wvr(w, in->dst); wvr(w, in->a); wvr(w, in->b); break; case OSC_I_SSTORE: wvr(w, in->a); wvr(w, in->b); wvr(w, in->c); break; + case OSC_I_FBIN: case OSC_I_FCMP: w8(w, in->sub); wvr(w, in->dst); wvr(w, in->a); wvr(w, in->b); break; + case OSC_I_FUN: case OSC_I_ITOF: case OSC_I_FTOI: w8(w, in->sub); wvr(w, in->dst); wvr(w, in->a); break; + case OSC_I_FCVT: case OSC_I_FBITS: wvr(w, in->dst); wvr(w, in->a); break; case OSC_I_FLOAD: wvr(w, in->dst); wvr(w, in->a); wvr(w, in->b); w8(w, in->imm); break; case OSC_I_FSTORE: wvr(w, in->a); wvr(w, in->b); wvr(w, in->c); w8(w, in->imm); break; case OSC_I_CALL: @@ -785,7 +866,7 @@ static int16_t rvr(R *r) { } static OscScalar rscalar(R *r) { uint64_t v = rle(r, 1); - if (!r->rc && v > OSC_T_CELLS) rfail(r, OSC_IR_REFUSE_RANGE); + if (!r->rc && v > OSC_T_F64) rfail(r, OSC_IR_REFUSE_RANGE); return r->rc ? OSC_T_VOID : (OscScalar)v; } /* text of at most max bytes into dst (dst has room for max + 1); a NUL inside is ambiguous */ @@ -830,6 +911,9 @@ static void decode_insn(R *r, OscInsn *in) { case OSC_I_HSTORE: in->a = rvr(r); in->b = rvr(r); in->c = rvr(r); in->args[0] = rvr(r); in->nargs = 1; break; case OSC_I_LOAD: case OSC_I_SLOAD: in->dst = rvr(r); in->a = rvr(r); in->b = rvr(r); break; case OSC_I_STORE: case OSC_I_SSTORE: in->a = rvr(r); in->b = rvr(r); in->c = rvr(r); break; + case OSC_I_FBIN: case OSC_I_FCMP: in->sub = (uint8_t)rle(r, 1); in->dst = rvr(r); in->a = rvr(r); in->b = rvr(r); break; + case OSC_I_FUN: case OSC_I_ITOF: case OSC_I_FTOI: in->sub = (uint8_t)rle(r, 1); in->dst = rvr(r); in->a = rvr(r); break; + case OSC_I_FCVT: case OSC_I_FBITS: in->dst = rvr(r); in->a = rvr(r); break; case OSC_I_FLOAD: in->dst = rvr(r); in->a = rvr(r); in->b = rvr(r); in->imm = rle(r, 1); break; case OSC_I_FSTORE: in->a = rvr(r); in->b = rvr(r); in->c = rvr(r); in->imm = rle(r, 1); break; case OSC_I_CALL: diff --git a/src/compiler/osc_ir.h b/src/compiler/osc_ir.h index 33c23f490..3bc221e10 100644 --- a/src/compiler/osc_ir.h +++ b/src/compiler/osc_ir.h @@ -50,7 +50,11 @@ typedef enum { /* external byte slices (docs/osc/OSC-EXT-BYTES-DESIGN.md): the type of the POINTER * register of a slice parameter; its length is the next register (u64) */ OSC_T_BYTES, /* read-only borrowed bytes */ - OSC_T_CELLS /* caller-supplied writable u64 cells */ + OSC_T_CELLS, /* caller-supplied writable u64 cells */ + /* appended for OSC-4 Slice A (docs/osc/OSC-4-DESIGN.md section 1): IEEE-754 binary32 / + * binary64 held as bit patterns; f32 occupies the low 32 bits, upper 32 zero */ + OSC_T_F32, + OSC_T_F64 } OscScalar; typedef enum { @@ -123,9 +127,28 @@ typedef enum { OSC_I_SLOAD, /* dst(u64) = a[b] ; a is a slice pointer vreg (BYTES: u8 zero- */ /* extended; CELLS: u64), its length is vreg a+1 (u64); b any */ /* integer type; unsigned b >= len: TRAP_BOUNDS (len 0 always) */ - OSC_I_SSTORE /* a[b] = c(u64) ; same bounds rule; a is a CELLS pointer vreg */ + OSC_I_SSTORE, /* a[b] = c(u64) ; same bounds rule; a is a CELLS pointer vreg */ + /* appended for OSC-4 Slice A floats (docs/osc/OSC-4-DESIGN.md 1.5). None of these + * traps: inf and NaN are values. Rounding is round-to-nearest-even throughout. */ + OSC_I_FBIN, /* dst = a b ; a, b, dst the same float type (OscFBin) */ + OSC_I_FUN, /* dst = a ; same float type (OscFUn) */ + OSC_I_FCMP, /* dst(bool) = a b ; same float type; NaN: only NE true */ + OSC_I_FCVT, /* dst(float) = (T)a ; a the other float type (FCVT, RNE) */ + OSC_I_ITOF, /* dst(float) = a ; a an integer; sub 1 signed, 2 unsigned (RNE) */ + OSC_I_FTOI, /* dst(int) = a ; a a float; sub 1 signed, 2 unsigned: truncate */ + /* toward zero, saturate to dst width, NaN -> 0 (FCVTZS/FCVTZU) */ + OSC_I_FBITS /* dst = same bits as a ; float <-> integer of the same width */ } OscOp; +/* OSC-4 float binary / unary sub-operations */ +typedef enum { + OSC_FB_ADD = 1, OSC_FB_SUB, OSC_FB_MUL, OSC_FB_DIV, + OSC_FB_MIN, /* FMINNM: IEEE minNum (one quiet NaN -> the other operand), -0.0 < +0.0 */ + OSC_FB_MAX /* FMAXNM: IEEE maxNum */ +} OscFBin; +typedef enum { OSC_FU_NEG = 1, OSC_FU_ABS, OSC_FU_SQRT } OscFUn; +typedef enum { OSC_FI_SIGNED = 1, OSC_FI_UNSIGNED } OscFInt; /* ITOF / FTOI sub */ + typedef enum { OSC_B_ADD = 1, OSC_B_SUB, OSC_B_MUL, OSC_B_DIV, /* b == 0 -> TRAP_DIV0; signed MIN/-1 -> TRAP_OVERFLOW (truncating) */ @@ -254,7 +277,7 @@ int osc_ir_digest(const OscUnit *u, uint8_t out[32]); * if the magic is wrong or the version is unknown (never reinterpreted). * Version 5 = the unit uses external byte slices; units without slices keep * versions 1..4 and their bytes. */ -#define OSC_IR_VERSION_MAX 5 +#define OSC_IR_VERSION_MAX 6 /* 6: OSC-4 Slice A floats */ int osc_ir_encoding_version(const uint8_t *buf, size_t len); /* Strict decoder (omega#444; format and refusal classes: spec/one-layer-format.md). @@ -305,6 +328,7 @@ int osc_ir_slice_args_ok(const OscFunc *f, const uint64_t *args, unsigned nargs) unsigned osc_scalar_width(OscScalar s); bool osc_scalar_signed(OscScalar s); bool osc_scalar_is_int(OscScalar s); +bool osc_scalar_is_float(OscScalar s); /* OSC-4: F32 or F64 */ const char *osc_scalar_name(OscScalar s); #endif /* OSC_IR_H */ diff --git a/src/compiler/osc_lex.c b/src/compiler/osc_lex.c index 97ba414e0..bae7e74bb 100644 --- a/src/compiler/osc_lex.c +++ b/src/compiler/osc_lex.c @@ -15,6 +15,8 @@ static const struct { const char *w; int k; } keywords[] = { {"i64", OT_I64}, {"bool", OT_BOOL}, {"struct", OT_STRUCT}, {"arena", OT_ARENA}, {"pool", OT_POOL}, {"handle", OT_HANDLE}, {"import", OT_IMPORT}, {"bytes", OT_BYTES}, {"cells", OT_CELLS}, + {"f32", OT_F32}, {"f64", OT_F64}, {"sqrt", OT_SQRT}, {"abs", OT_ABS}, {"min", OT_MIN}, {"max", OT_MAX}, + {"bits", OT_BITS}, }; /* Reserved: destruction words (destruction has no surface syntax, III.8) and @@ -34,6 +36,7 @@ static const char *const kind_names[OT__COUNT] = { "+", "-", "*", "/", "%", "&", "|", "^", "~", "!", "&&", "||", "<<", ">>", "==", "!=", "<", "<=", ">", ">=", "struct", ".", "arena", "pool", "handle", "import", "bytes", "cells", + "f32", "f64", "sqrt", "abs", "min", "max", "bits", "FLOAT", }; const char *osc_tok_kind_name(int kind) @@ -121,6 +124,51 @@ int osc_lex(const char *src, size_t len, OscToken *toks, uint32_t cap, uint32_t continue; } if (is_digit(c)) { + /* OSC-4 float literal: digits "." digits [("e"|"E") ["+"|"-"] digits] ["f32"|"f64"]. + * Only when a digit precedes the dot and a digit follows it, so `..` ranges and a + * future `a.b` member syntax stay free. The value is parsed by the checker + * (strtof for f32, strtod for f64: never strtod then cast). */ + size_t j = i; + while (j < len && is_digit(src[j])) j++; + if (j + 1 < len && src[j] == '.' && is_digit(src[j + 1])) { + size_t s = i; + while (i < len && is_digit(src[i])) ADV(); + ADV(); /* '.' */ + while (i < len && is_digit(src[i])) ADV(); + if (i < len && (src[i] == 'e' || src[i] == 'E')) { + size_t k = i + 1; + if (k < len && (src[k] == '+' || src[k] == '-')) k++; + if (k < len && is_digit(src[k])) { + while (i < k) ADV(); + while (i < len && is_digit(src[i])) ADV(); + } + } + uint64_t suffix = 0; + if (i + 3 <= len && src[i] == 'f' && src[i + 1] == '3' && src[i + 2] == '2') suffix = 1; + if (i + 3 <= len && src[i] == 'f' && src[i + 1] == '6' && src[i + 2] == '4') suffix = 2; + if (suffix) { ADV(); ADV(); ADV(); } + t->len = (uint32_t)(i - s); + if (i < len && (is_alpha(src[i]) || is_digit(src[i]) || src[i] == '.')) { + char buf[64]; + while (i < len && (is_alpha(src[i]) || is_digit(src[i]) || src[i] == '.')) ADV(); + t->len = (uint32_t)(i - s); + osc_tok_text(src, t, buf, sizeof buf); + osc_diag_set(d, OSC_DIAG_SYNTAX, t->line, t->col, buf, 0, NULL, "malformed literal", + "malformed float literal '%s'", buf); + return -1; + } + if (t->len > OSC_LEX_NAME_MAX) { /* refused, never truncated: a cut literal would parse to another value */ + char lb[OSC_LEX_NAME_MAX + 1]; + osc_tok_text(src, t, lb, sizeof lb); + osc_diag_set(d, OSC_DIAG_CAPACITY, t->line, t->col, lb, 0, NULL, "float literal length", + "float literal longer than %d characters", OSC_LEX_NAME_MAX); + return -1; + } + t->kind = OT_FLOAT; + t->ival = suffix; + n++; + continue; + } size_t s = i; unsigned base = 10; if (c == '0' && i + 1 < len && (src[i + 1] == 'x' || src[i + 1] == 'b')) { diff --git a/src/compiler/osc_lex.h b/src/compiler/osc_lex.h index a136bf2da..2e9f44cdb 100644 --- a/src/compiler/osc_lex.h +++ b/src/compiler/osc_lex.h @@ -35,6 +35,9 @@ typedef enum { OT_IMPORT, /* external byte slices (docs/osc/OSC-EXT-BYTES-DESIGN.md): parameter types, appended */ OT_BYTES, OT_CELLS, + /* OSC-4 Slice A floats (docs/osc/OSC-4-DESIGN.md 1.2), appended: types, intrinsics, `bits`, + * and the FLOAT literal token (ival = suffix: 0 none, 1 f32, 2 f64; spelling via off/len) */ + OT_F32, OT_F64, OT_SQRT, OT_ABS, OT_MIN, OT_MAX, OT_BITS, OT_FLOAT, OT__COUNT } OscTokKind; @@ -42,7 +45,7 @@ typedef struct { uint16_t kind; /* OscTokKind */ uint32_t line, col; /* 1-based */ uint32_t off, len; /* spelling in the source */ - uint64_t ival; /* OT_INT value */ + uint64_t ival; /* OT_INT value; OT_FLOAT: suffix code 0/1/2 (value is parsed by the checker) */ } OscToken; /* Tokenise src[0..len). 0 ok (toks ends with OT_EOF), -1 with *d filled: diff --git a/src/compiler/osc_lower.c b/src/compiler/osc_lower.c index 8ce948772..46f07c9c3 100644 --- a/src/compiler/osc_lower.c +++ b/src/compiler/osc_lower.c @@ -162,6 +162,18 @@ static int bop(int tok) default: return 0; } } +/* OSC-4: float arithmetic sub-ops (the checker refused everything else) */ +static int fbop(int tok) +{ + switch (tok) { + case OT_PLUS: return OSC_FB_ADD; + case OT_MINUS: return OSC_FB_SUB; + case OT_STAR: return OSC_FB_MUL; + case OT_SLASH: return OSC_FB_DIV; + default: return 0; + } +} + static int cop(int tok) { switch (tok) { @@ -260,8 +272,16 @@ static int expr(L *l, int i) case ON_CALL: return call(l, i, 1); case ON_CAST: { int a = expr(l, n->a); - int r = newvs(l, n->ty.s, n->line); - OscInsn *x = emit(l, OSC_I_CAST, n->line); + OscScalar from = NODE(n->a)->ty.s, to = n->ty.s; + int r = newvs(l, to, n->line); + /* OSC-4 Slice A: one IR op per conversion kind (design 1.5 item 2) */ + uint8_t op = OSC_I_CAST, sub = 0; + if (n->flag) op = OSC_I_FBITS; /* `as T bits` */ + else if (osc_scalar_is_float(from) && osc_scalar_is_float(to)) op = from == to ? OSC_I_MOV : OSC_I_FCVT; + else if (osc_scalar_is_float(to)) { op = OSC_I_ITOF; sub = osc_scalar_signed(from) ? OSC_FI_SIGNED : OSC_FI_UNSIGNED; } + else if (osc_scalar_is_float(from)) { op = OSC_I_FTOI; sub = osc_scalar_signed(to) ? OSC_FI_SIGNED : OSC_FI_UNSIGNED; } + OscInsn *x = emit(l, op, n->line); + x->sub = sub; x->dst = (int16_t)r; x->a = (int16_t)a; return r; @@ -269,12 +289,30 @@ static int expr(L *l, int i) case ON_UN: { int a = expr(l, n->a); int r = newvs(l, n->ty.s, n->line); + if (osc_scalar_is_float(n->ty.s)) { /* OSC-4: the checker allows only '-' here */ + OscInsn *x = emit(l, OSC_I_FUN, n->line); + x->sub = OSC_FU_NEG; + x->dst = (int16_t)r; + x->a = (int16_t)a; + return r; + } OscInsn *x = emit(l, OSC_I_UN, n->line); x->sub = n->op == OT_MINUS ? OSC_U_NEG : n->op == OT_TILDE ? OSC_U_BNOT : OSC_U_LNOT; x->dst = (int16_t)r; x->a = (int16_t)a; return r; } + case ON_INTRIN: { /* OSC-4: sqrt / abs -> FUN, min / max -> FBIN */ + int a = expr(l, n->a); + int b = n->b >= 0 ? expr(l, n->b) : -1; + int r = newvs(l, n->ty.s, n->line); + OscInsn *x = emit(l, n->b >= 0 ? OSC_I_FBIN : OSC_I_FUN, n->line); + x->sub = (uint8_t)(n->op == OT_SQRT ? OSC_FU_SQRT : n->op == OT_ABS ? OSC_FU_ABS : n->op == OT_MIN ? OSC_FB_MIN : OSC_FB_MAX); + x->dst = (int16_t)r; + x->a = (int16_t)a; + x->b = (int16_t)b; + return r; + } case ON_BIN: { if (n->op == OT_ANDAND || n->op == OT_OROR) { int res = newvs(l, OSC_T_BOOL, n->line); @@ -298,8 +336,10 @@ static int expr(L *l, int i) int b = expr(l, n->b); int r = newvs(l, n->ty.s, n->line); int cc = cop(n->op); - OscInsn *x = emit(l, cc ? OSC_I_CMP : OSC_I_BIN, n->line); - x->sub = (uint8_t)(cc ? cc : bop(n->op)); + /* OSC-4: float operands take the float ops (compare operand type is in n->flag) */ + bool fl = osc_scalar_is_float(cc ? (OscScalar)n->flag : n->ty.s); + OscInsn *x = emit(l, cc ? (fl ? OSC_I_FCMP : OSC_I_CMP) : (fl ? OSC_I_FBIN : OSC_I_BIN), n->line); + x->sub = (uint8_t)(cc ? cc : fl ? fbop(n->op) : bop(n->op)); x->dst = (int16_t)r; x->a = (int16_t)a; x->b = (int16_t)b; diff --git a/src/compiler/osc_parse.c b/src/compiler/osc_parse.c index 67c18127b..5f73834bf 100644 --- a/src/compiler/osc_parse.c +++ b/src/compiler/osc_parse.c @@ -87,6 +87,7 @@ static int scalar_of(int k) case OT_U8: return OSC_T_U8; case OT_U16: return OSC_T_U16; case OT_U32: return OSC_T_U32; case OT_U64: return OSC_T_U64; case OT_I8: return OSC_T_I8; case OT_I16: return OSC_T_I16; case OT_I32: return OSC_T_I32; case OT_I64: return OSC_T_I64; case OT_BOOL: return OSC_T_BOOL; + case OT_F32: return OSC_T_F32; case OT_F64: return OSC_T_F64; /* OSC-4 Slice A */ default: return 0; } } @@ -101,7 +102,7 @@ static int parse_scalar(P *p, OscType *ty) at(p, OT_BYTES) ? "bytes" : "cells"); return -1; } - if (!s) return syntax(p, "a type (u8 u16 u32 u64 i8 i16 i32 i64 bool)"); + if (!s) return syntax(p, "a type (u8 u16 u32 u64 i8 i16 i32 i64 bool f32 f64)"); memset(ty, 0, sizeof *ty); ty->s = (OscScalar)s; adv(p); @@ -498,6 +499,33 @@ static int parse_primary(P *p) N(n)->ival = t->ival; adv(p); return n; + case OT_FLOAT: /* OSC-4: the checker parses the spelling once the type is known */ + n = new_node(p, ON_FLOAT, t); + if (n < 0) return -1; + N(n)->tok = p->pos; + N(n)->ival = t->ival; + adv(p); + return n; + case OT_SQRT: case OT_ABS: case OT_MIN: case OT_MAX: { /* OSC-4 intrinsics */ + n = new_node(p, ON_INTRIN, t); + if (n < 0) return -1; + N(n)->op = t->kind; + adv(p); + if (expect(p, OT_LPAREN)) return -1; + if (enter(p)) return -1; + int a = parse_expr(p); + if (a < 0) return -1; + N(n)->a = a; + if (t->kind == OT_MIN || t->kind == OT_MAX) { + if (expect(p, OT_COMMA)) return -1; + int b = parse_expr(p); + if (b < 0) return -1; + N(n)->b = b; + } + leave(p); + if (expect(p, OT_RPAREN)) return -1; + return n; + } case OT_TRUE: case OT_FALSE: n = new_node(p, ON_BOOL, t); if (n < 0) return -1; @@ -561,6 +589,7 @@ static int parse_postfix(P *p) if (n < 0) return -1; adv(p); if (parse_scalar(p, &N(n)->ty)) return -1; + if (at(p, OT_BITS)) { N(n)->flag = 1; adv(p); } /* OSC-4 bit cast */ N(n)->a = e; N(n)->line = N(e)->line; N(n)->col = N(e)->col; @@ -644,10 +673,23 @@ static int parse_name_tok(P *p, int n) return 0; } +/* OSC-4 FLOAT_INDEX: a float literal where a loop bound, range end or arena bound INT belongs */ +static int float_index_lit(P *p, const char *object) +{ + const OscToken *t = cur(p); + if (t->kind != OT_FLOAT) return 0; + char buf[64]; + osc_tok_text(p->ast->src, t, buf, sizeof buf); + osc_diag_set(p->d, OSC_DIAG_FLOAT_INDEX, t->line, t->col, object, 0, NULL, "float as a bound", + "'%s' is a float; loop bounds, range ends and arena bounds are integers", buf); + return -1; +} + static int parse_int_signed(P *p, int64_t *out) { int neg = 0; if (at(p, OT_MINUS)) { neg = 1; adv(p); } + if (float_index_lit(p, "for")) return -1; if (!at(p, OT_INT)) return syntax(p, "an integer literal"); const OscToken *t = cur(p); if (t->ival > (uint64_t)INT64_MAX + (uint64_t)neg) { @@ -873,6 +915,7 @@ static int parse_stmt(P *p) if (parse_name_tok(p, n)) return -1; if (!at(p, OT_BOUND)) return syntax(p, "'bound K' after the arena name"); adv(p); + if (float_index_lit(p, "bound")) return -1; if (!at(p, OT_INT)) return syntax(p, "bound INT"); const OscToken *bt = cur(p); if (bt->ival == 0 || bt->ival > OSC_ARENA_MAX_CELLS) { @@ -905,6 +948,7 @@ static int parse_stmt(P *p) return -1; } adv(p); + if (float_index_lit(p, "bound")) return -1; if (!at(p, OT_INT)) return syntax(p, "bound INT"); const OscToken *bt = cur(p); if (bt->ival == 0 || bt->ival > LOOP_BOUND_MAX) { diff --git a/src/compiler/osc_parse.h b/src/compiler/osc_parse.h index f9301c7ef..651a2729a 100644 --- a/src/compiler/osc_parse.h +++ b/src/compiler/osc_parse.h @@ -54,7 +54,7 @@ typedef enum { ON_BORROW, /* tok = name; mut */ ON_BIN, /* op = OscTokKind of the operator (incl. && ||); a, b */ ON_UN, /* op = OT_MINUS / OT_TILDE / OT_BANG; a */ - ON_CAST, /* a; ty = target scalar */ + ON_CAST, /* a; ty = target scalar; flag = 1 for `as T bits` (OSC-4 bit cast) */ /* OSC-2 structs (docs/osc/OSC-2-DESIGN.md section 2). A struct literal is an * ON_LET_ALLOC whose ty is a struct ref (ty.sid != 0) and whose a is the * first ON_FINIT (linked by next, source order). */ @@ -82,8 +82,12 @@ typedef enum { ON_PFREE, /* tok = pool name; a = handle expr ("p.free(h);") */ ON_HLOAD, /* checker rewrite of ON_INDEX on a pool: tok = pool; a = handle; * sym = pool symbol, sym2 = handle symbol */ - ON_HSTORE /* checker rewrite of ON_STORE on a pool: tok = pool; a = handle; + ON_HSTORE, /* checker rewrite of ON_STORE on a pool: tok = pool; a = handle; * b = value; sym = pool symbol, sym2 = handle symbol */ + /* OSC-4 Slice A floats (docs/osc/OSC-4-DESIGN.md 1.2), appended */ + ON_FLOAT, /* tok = FLOAT literal token (spelling); ival = suffix 0 none / 1 f32 / 2 f64; + * checker: cval = IEEE bits (is_const = 1) */ + ON_INTRIN /* op = OT_SQRT / OT_ABS / OT_MIN / OT_MAX; a, b (b = -1 for the unary two) */ } OscNodeKind; typedef struct { diff --git a/src/compiler/oscc_main.c b/src/compiler/oscc_main.c index 14e938fd4..17c6bf1ed 100644 --- a/src/compiler/oscc_main.c +++ b/src/compiler/oscc_main.c @@ -59,8 +59,9 @@ static int write_tmp(const char *pre, int i, const void *p, size_t n, const char return (fclose(f) != 0 || bad) ? -1 : 0; } -/* 1..9 scalars, 11 bytes, 12 cells (OSC_UNIT_ARTIFACT.md section 6.1); 0 and 10 are refused. */ -static int kind_ok(unsigned k) { return (k >= 1 && k <= 9) || k == 11 || k == 12; } +/* 1..9 scalars, 11 bytes, 12 cells, 13 f32, 14 f64 (OSC-4 Slice A; OSC_UNIT_ARTIFACT.md section 6.1); + * 0 and 10 are refused. Float values travel as IEEE bit patterns. */ +static int kind_ok(unsigned k) { return (k >= 1 && k <= 9) || k == 11 || k == 12 || k == 13 || k == 14; } /* 0 written; 1 refused (message in err); -1 cannot write. */ static int emit_files(const char *pre, const OscUnit *u, const OscCode *code, char *err, size_t errn) diff --git a/tests/.crumb b/tests/.crumb index bd5535a8b..3860a1716 100644 --- a/tests/.crumb +++ b/tests/.crumb @@ -133,8 +133,8 @@ "purpose": "Directory tests/canonicalization. Purpose not yet described by a human." }, { - "digest": "f041b7daf38c51e8db72834bb764cef7741637981223039d89731a30aa91e224", - "last_commit": "1edf41a5", + "digest": "6b96f09ec01f52e6fed8218382bb3413ec2dc0e6b3e23a5abb866b0f98d8f84d", + "last_commit": "af683338", "name": "compiler", "purpose": "Directory tests/compiler. Purpose not yet described by a human." }, @@ -295,15 +295,15 @@ "purpose": "Directory tests/visor. Purpose not yet described by a human." } ], - "children_root": "sha256:ddc3618190458bc5073e3bee67ffccc68a2ee9f065f2cb0d86545386a29fddf8", - "compiled_at": "2026-10-16T19:04:20Z", + "children_root": "sha256:6a6c3cdfa23b6913ae138f7dc7b20dc8637da700f07c4a3e478ced8de1521d38", + "compiled_at": "2026-10-18T14:43:09Z", "compiler": "crumb-compile/1", - "digest": "sha256:4eb9d4d76234448c0ed691f0aeb9c90d785f8a47b1b1291d728bbe3e1509dc10", + "digest": "sha256:df3654dac6fb2ef9f4584ff3fe24687c007e0c2decd005392bf90f78780f5022", "evidence_files": 16, "evidence_root": "sha256:96d08097822ad95f4e562c19e0ba5df5a035774c48632f1832912c40a27bd27a", - "files": 1270, - "generated_at_commit": "88e24bdd57b27817d030d0ad95f62c3f3eacf426", - "source_tree": "sha256:e6c4f0021d383ba2e59da0d85d06a0b98170f6d188289c891b5745200548e6fc" + "files": 1299, + "generated_at_commit": "d32f4fd023910235289557e065bb47afa78ed4f1", + "source_tree": "sha256:47afdbfff36fd5bb0346280319f0359adb1bb6cb585b275ccb16b88c45a26694" }, "owner_lane": "", "provenance": { diff --git a/tests/compiler/.crumb b/tests/compiler/.crumb index f010bfce4..11ccffc76 100644 --- a/tests/compiler/.crumb +++ b/tests/compiler/.crumb @@ -17,27 +17,27 @@ "generated": { "children": [ { - "digest": "52f60db8cad897bd1ad36a41cff28e90ad3ccd0e734555a8325701f1a9e9ba7b", - "last_commit": "eb8dedf7", + "digest": "7544331758567b00eef6404ec6694a271941193a664f062f80c7b5c3b1e1d947", + "last_commit": "848cfd99", "name": "neg", "purpose": "Directory tests/compiler/neg. Purpose not yet described by a human." }, { - "digest": "44128e1034bd4f570667a4a57f5d058b09b127f6e203e2173e2b07c533c45b57", - "last_commit": "334117d1", + "digest": "548842e38f88f2fcee6d1e3694f5a50ae56c0cc9ffca989659ca3415ae0745eb", + "last_commit": "848cfd99", "name": "progs", "purpose": "Directory tests/compiler/progs. Purpose not yet described by a human." } ], - "children_root": "sha256:8e71869afa3e9efae551dc468dfd9fae972bd9a404fc7f2cbdabc1684e98fb8e", - "compiled_at": "2026-10-14T17:37:01Z", + "children_root": "sha256:7e157ab353bfb6a3995754e5ad807308e2eab3c58a395c01eee13691e95d1c99", + "compiled_at": "2026-10-16T20:35:19Z", "compiler": "crumb-compile/1", - "digest": "sha256:f041b7daf38c51e8db72834bb764cef7741637981223039d89731a30aa91e224", + "digest": "sha256:6b96f09ec01f52e6fed8218382bb3413ec2dc0e6b3e23a5abb866b0f98d8f84d", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 206, - "generated_at_commit": "e9943ed23f0712a7dd1f7248a7d6bb00eabf5ea5", - "source_tree": "sha256:8d2b44ba348917da5af698886fa1226e8562684fbb069d7af91a0d64d158067b" + "files": 235, + "generated_at_commit": "cde3c1d51cc2106f965ed34c6ae82d311d1b490a", + "source_tree": "sha256:71dd58ee057d2549c7204c984e9358d15bf2e14a37946a7b72759366e0794694" }, "owner_lane": "", "provenance": { diff --git a/tests/compiler/aarch64_fp_golden.h b/tests/compiler/aarch64_fp_golden.h new file mode 100644 index 000000000..b634f4c01 --- /dev/null +++ b/tests/compiler/aarch64_fp_golden.h @@ -0,0 +1,2621 @@ +/* PROVENANCE: verbatim copy of /home/drakestapleton/workspace/osc4/golden/aarch64_fp_golden.h (research lane research-0c, + * generated 2026-10-16 from GNU as 2.42 + objdump 2.42 samples on the Spark; 87 forms, 1365 samples, 0 mismatches; + * see golden/aarch64_fp_golden.md). Copied unchanged for the OSC-4 Slice A encoder goldens (docs/osc/OSC-4-DESIGN.md 1.6). + * sha256 of the original: 5a1754791dd5073c074d66cc5c0e21599f8facb269ed8a70ab198378492e0818 */ +/* aarch64_fp_golden.h: AArch64 scalar FP instruction encoders. + * GENERATED by derive.c from GNU as 2.42 samples on this box (aarch64, Ubuntu 24.04). + * Every base word and field below was derived from assembler output and + * re-checked against all 1365 samples (0 mismatches at generation time). + * Encoders mask each operand to its field width; they do NOT range-check. + * Fused multiply-add forms are intentionally absent. */ +#ifndef AARCH64_FP_GOLDEN_H +#define AARCH64_FP_GOLDEN_H +#include + +/* fmov {rd}, {rn} + * rd bits 4.. 0: S register 0-31 + * rn bits 9.. 5: S register 0-31 + */ +#define A64_FMOV_S_BASE 0x1e204000u +static inline uint32_t a64_fmov_s(uint32_t rd, uint32_t rn) +{ + return A64_FMOV_S_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* fmov {rd}, {rn} + * rd bits 4.. 0: D register 0-31 + * rn bits 9.. 5: D register 0-31 + */ +#define A64_FMOV_D_BASE 0x1e604000u +static inline uint32_t a64_fmov_d(uint32_t rd, uint32_t rn) +{ + return A64_FMOV_D_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* fmov {rd}, {imm8} + * rd bits 4.. 0: S register 0-31 + * imm8 bits 20..13: 8-bit FP immediate abcdefgh (1.0=0x70, 2.0=0x00, 0.5=0x60, -1.0=0xF0) + */ +#define A64_FMOV_S_IMM_BASE 0x1e201000u +static inline uint32_t a64_fmov_s_imm(uint32_t rd, uint32_t imm8) +{ + return A64_FMOV_S_IMM_BASE + | (((rd) & 0x1fu) << 0) + | (((imm8) & 0xffu) << 13); +} + +/* fmov {rd}, {imm8} + * rd bits 4.. 0: D register 0-31 + * imm8 bits 20..13: 8-bit FP immediate abcdefgh (1.0=0x70, 2.0=0x00, 0.5=0x60, -1.0=0xF0) + */ +#define A64_FMOV_D_IMM_BASE 0x1e601000u +static inline uint32_t a64_fmov_d_imm(uint32_t rd, uint32_t imm8) +{ + return A64_FMOV_D_IMM_BASE + | (((rd) & 0x1fu) << 0) + | (((imm8) & 0xffu) << 13); +} + +/* fmov {rd}, {rn} + * rd bits 4.. 0: S register 0-31 + * rn bits 9.. 5: W register 0-30, 31 = WZR + */ +#define A64_FMOV_S_FROM_W_BASE 0x1e270000u +static inline uint32_t a64_fmov_s_from_w(uint32_t rd, uint32_t rn) +{ + return A64_FMOV_S_FROM_W_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* fmov {rd}, {rn} + * rd bits 4.. 0: W register 0-30, 31 = WZR + * rn bits 9.. 5: S register 0-31 + */ +#define A64_FMOV_S_TO_W_BASE 0x1e260000u +static inline uint32_t a64_fmov_s_to_w(uint32_t rd, uint32_t rn) +{ + return A64_FMOV_S_TO_W_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* fmov {rd}, {rn} + * rd bits 4.. 0: D register 0-31 + * rn bits 9.. 5: X register 0-30, 31 = XZR + */ +#define A64_FMOV_D_FROM_X_BASE 0x9e670000u +static inline uint32_t a64_fmov_d_from_x(uint32_t rd, uint32_t rn) +{ + return A64_FMOV_D_FROM_X_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* fmov {rd}, {rn} + * rd bits 4.. 0: X register 0-30, 31 = XZR + * rn bits 9.. 5: D register 0-31 + */ +#define A64_FMOV_D_TO_X_BASE 0x9e660000u +static inline uint32_t a64_fmov_d_to_x(uint32_t rd, uint32_t rn) +{ + return A64_FMOV_D_TO_X_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* fadd {rd}, {rn}, {rm} + * rd bits 4.. 0: S register 0-31 + * rn bits 9.. 5: S register 0-31 + * rm bits 20..16: S register 0-31 + */ +#define A64_FADD_S_BASE 0x1e202800u +static inline uint32_t a64_fadd_s(uint32_t rd, uint32_t rn, uint32_t rm) +{ + return A64_FADD_S_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16); +} + +/* fadd {rd}, {rn}, {rm} + * rd bits 4.. 0: D register 0-31 + * rn bits 9.. 5: D register 0-31 + * rm bits 20..16: D register 0-31 + */ +#define A64_FADD_D_BASE 0x1e602800u +static inline uint32_t a64_fadd_d(uint32_t rd, uint32_t rn, uint32_t rm) +{ + return A64_FADD_D_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16); +} + +/* fsub {rd}, {rn}, {rm} + * rd bits 4.. 0: S register 0-31 + * rn bits 9.. 5: S register 0-31 + * rm bits 20..16: S register 0-31 + */ +#define A64_FSUB_S_BASE 0x1e203800u +static inline uint32_t a64_fsub_s(uint32_t rd, uint32_t rn, uint32_t rm) +{ + return A64_FSUB_S_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16); +} + +/* fsub {rd}, {rn}, {rm} + * rd bits 4.. 0: D register 0-31 + * rn bits 9.. 5: D register 0-31 + * rm bits 20..16: D register 0-31 + */ +#define A64_FSUB_D_BASE 0x1e603800u +static inline uint32_t a64_fsub_d(uint32_t rd, uint32_t rn, uint32_t rm) +{ + return A64_FSUB_D_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16); +} + +/* fmul {rd}, {rn}, {rm} + * rd bits 4.. 0: S register 0-31 + * rn bits 9.. 5: S register 0-31 + * rm bits 20..16: S register 0-31 + */ +#define A64_FMUL_S_BASE 0x1e200800u +static inline uint32_t a64_fmul_s(uint32_t rd, uint32_t rn, uint32_t rm) +{ + return A64_FMUL_S_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16); +} + +/* fmul {rd}, {rn}, {rm} + * rd bits 4.. 0: D register 0-31 + * rn bits 9.. 5: D register 0-31 + * rm bits 20..16: D register 0-31 + */ +#define A64_FMUL_D_BASE 0x1e600800u +static inline uint32_t a64_fmul_d(uint32_t rd, uint32_t rn, uint32_t rm) +{ + return A64_FMUL_D_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16); +} + +/* fdiv {rd}, {rn}, {rm} + * rd bits 4.. 0: S register 0-31 + * rn bits 9.. 5: S register 0-31 + * rm bits 20..16: S register 0-31 + */ +#define A64_FDIV_S_BASE 0x1e201800u +static inline uint32_t a64_fdiv_s(uint32_t rd, uint32_t rn, uint32_t rm) +{ + return A64_FDIV_S_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16); +} + +/* fdiv {rd}, {rn}, {rm} + * rd bits 4.. 0: D register 0-31 + * rn bits 9.. 5: D register 0-31 + * rm bits 20..16: D register 0-31 + */ +#define A64_FDIV_D_BASE 0x1e601800u +static inline uint32_t a64_fdiv_d(uint32_t rd, uint32_t rn, uint32_t rm) +{ + return A64_FDIV_D_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16); +} + +/* fmin {rd}, {rn}, {rm} + * rd bits 4.. 0: S register 0-31 + * rn bits 9.. 5: S register 0-31 + * rm bits 20..16: S register 0-31 + */ +#define A64_FMIN_S_BASE 0x1e205800u +static inline uint32_t a64_fmin_s(uint32_t rd, uint32_t rn, uint32_t rm) +{ + return A64_FMIN_S_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16); +} + +/* fmin {rd}, {rn}, {rm} + * rd bits 4.. 0: D register 0-31 + * rn bits 9.. 5: D register 0-31 + * rm bits 20..16: D register 0-31 + */ +#define A64_FMIN_D_BASE 0x1e605800u +static inline uint32_t a64_fmin_d(uint32_t rd, uint32_t rn, uint32_t rm) +{ + return A64_FMIN_D_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16); +} + +/* fmax {rd}, {rn}, {rm} + * rd bits 4.. 0: S register 0-31 + * rn bits 9.. 5: S register 0-31 + * rm bits 20..16: S register 0-31 + */ +#define A64_FMAX_S_BASE 0x1e204800u +static inline uint32_t a64_fmax_s(uint32_t rd, uint32_t rn, uint32_t rm) +{ + return A64_FMAX_S_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16); +} + +/* fmax {rd}, {rn}, {rm} + * rd bits 4.. 0: D register 0-31 + * rn bits 9.. 5: D register 0-31 + * rm bits 20..16: D register 0-31 + */ +#define A64_FMAX_D_BASE 0x1e604800u +static inline uint32_t a64_fmax_d(uint32_t rd, uint32_t rn, uint32_t rm) +{ + return A64_FMAX_D_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16); +} + +/* fminnm {rd}, {rn}, {rm} + * rd bits 4.. 0: S register 0-31 + * rn bits 9.. 5: S register 0-31 + * rm bits 20..16: S register 0-31 + */ +#define A64_FMINNM_S_BASE 0x1e207800u +static inline uint32_t a64_fminnm_s(uint32_t rd, uint32_t rn, uint32_t rm) +{ + return A64_FMINNM_S_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16); +} + +/* fminnm {rd}, {rn}, {rm} + * rd bits 4.. 0: D register 0-31 + * rn bits 9.. 5: D register 0-31 + * rm bits 20..16: D register 0-31 + */ +#define A64_FMINNM_D_BASE 0x1e607800u +static inline uint32_t a64_fminnm_d(uint32_t rd, uint32_t rn, uint32_t rm) +{ + return A64_FMINNM_D_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16); +} + +/* fmaxnm {rd}, {rn}, {rm} + * rd bits 4.. 0: S register 0-31 + * rn bits 9.. 5: S register 0-31 + * rm bits 20..16: S register 0-31 + */ +#define A64_FMAXNM_S_BASE 0x1e206800u +static inline uint32_t a64_fmaxnm_s(uint32_t rd, uint32_t rn, uint32_t rm) +{ + return A64_FMAXNM_S_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16); +} + +/* fmaxnm {rd}, {rn}, {rm} + * rd bits 4.. 0: D register 0-31 + * rn bits 9.. 5: D register 0-31 + * rm bits 20..16: D register 0-31 + */ +#define A64_FMAXNM_D_BASE 0x1e606800u +static inline uint32_t a64_fmaxnm_d(uint32_t rd, uint32_t rn, uint32_t rm) +{ + return A64_FMAXNM_D_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16); +} + +/* fsqrt {rd}, {rn} + * rd bits 4.. 0: S register 0-31 + * rn bits 9.. 5: S register 0-31 + */ +#define A64_FSQRT_S_BASE 0x1e21c000u +static inline uint32_t a64_fsqrt_s(uint32_t rd, uint32_t rn) +{ + return A64_FSQRT_S_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* fsqrt {rd}, {rn} + * rd bits 4.. 0: D register 0-31 + * rn bits 9.. 5: D register 0-31 + */ +#define A64_FSQRT_D_BASE 0x1e61c000u +static inline uint32_t a64_fsqrt_d(uint32_t rd, uint32_t rn) +{ + return A64_FSQRT_D_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* fneg {rd}, {rn} + * rd bits 4.. 0: S register 0-31 + * rn bits 9.. 5: S register 0-31 + */ +#define A64_FNEG_S_BASE 0x1e214000u +static inline uint32_t a64_fneg_s(uint32_t rd, uint32_t rn) +{ + return A64_FNEG_S_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* fneg {rd}, {rn} + * rd bits 4.. 0: D register 0-31 + * rn bits 9.. 5: D register 0-31 + */ +#define A64_FNEG_D_BASE 0x1e614000u +static inline uint32_t a64_fneg_d(uint32_t rd, uint32_t rn) +{ + return A64_FNEG_D_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* fabs {rd}, {rn} + * rd bits 4.. 0: S register 0-31 + * rn bits 9.. 5: S register 0-31 + */ +#define A64_FABS_S_BASE 0x1e20c000u +static inline uint32_t a64_fabs_s(uint32_t rd, uint32_t rn) +{ + return A64_FABS_S_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* fabs {rd}, {rn} + * rd bits 4.. 0: D register 0-31 + * rn bits 9.. 5: D register 0-31 + */ +#define A64_FABS_D_BASE 0x1e60c000u +static inline uint32_t a64_fabs_d(uint32_t rd, uint32_t rn) +{ + return A64_FABS_D_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* frintn {rd}, {rn} + * rd bits 4.. 0: S register 0-31 + * rn bits 9.. 5: S register 0-31 + */ +#define A64_FRINTN_S_BASE 0x1e244000u +static inline uint32_t a64_frintn_s(uint32_t rd, uint32_t rn) +{ + return A64_FRINTN_S_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* frintn {rd}, {rn} + * rd bits 4.. 0: D register 0-31 + * rn bits 9.. 5: D register 0-31 + */ +#define A64_FRINTN_D_BASE 0x1e644000u +static inline uint32_t a64_frintn_d(uint32_t rd, uint32_t rn) +{ + return A64_FRINTN_D_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* frintm {rd}, {rn} + * rd bits 4.. 0: S register 0-31 + * rn bits 9.. 5: S register 0-31 + */ +#define A64_FRINTM_S_BASE 0x1e254000u +static inline uint32_t a64_frintm_s(uint32_t rd, uint32_t rn) +{ + return A64_FRINTM_S_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* frintm {rd}, {rn} + * rd bits 4.. 0: D register 0-31 + * rn bits 9.. 5: D register 0-31 + */ +#define A64_FRINTM_D_BASE 0x1e654000u +static inline uint32_t a64_frintm_d(uint32_t rd, uint32_t rn) +{ + return A64_FRINTM_D_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* frintp {rd}, {rn} + * rd bits 4.. 0: S register 0-31 + * rn bits 9.. 5: S register 0-31 + */ +#define A64_FRINTP_S_BASE 0x1e24c000u +static inline uint32_t a64_frintp_s(uint32_t rd, uint32_t rn) +{ + return A64_FRINTP_S_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* frintp {rd}, {rn} + * rd bits 4.. 0: D register 0-31 + * rn bits 9.. 5: D register 0-31 + */ +#define A64_FRINTP_D_BASE 0x1e64c000u +static inline uint32_t a64_frintp_d(uint32_t rd, uint32_t rn) +{ + return A64_FRINTP_D_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* frintz {rd}, {rn} + * rd bits 4.. 0: S register 0-31 + * rn bits 9.. 5: S register 0-31 + */ +#define A64_FRINTZ_S_BASE 0x1e25c000u +static inline uint32_t a64_frintz_s(uint32_t rd, uint32_t rn) +{ + return A64_FRINTZ_S_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* frintz {rd}, {rn} + * rd bits 4.. 0: D register 0-31 + * rn bits 9.. 5: D register 0-31 + */ +#define A64_FRINTZ_D_BASE 0x1e65c000u +static inline uint32_t a64_frintz_d(uint32_t rd, uint32_t rn) +{ + return A64_FRINTZ_D_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* fcmp {rn}, {rm} + * rn bits 9.. 5: S register 0-31 + * rm bits 20..16: S register 0-31 + */ +#define A64_FCMP_S_BASE 0x1e202000u +static inline uint32_t a64_fcmp_s(uint32_t rn, uint32_t rm) +{ + return A64_FCMP_S_BASE + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16); +} + +/* fcmp {rn}, {rm} + * rn bits 9.. 5: D register 0-31 + * rm bits 20..16: D register 0-31 + */ +#define A64_FCMP_D_BASE 0x1e602000u +static inline uint32_t a64_fcmp_d(uint32_t rn, uint32_t rm) +{ + return A64_FCMP_D_BASE + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16); +} + +/* fcmp {rn}, #0.0 + * rn bits 9.. 5: S register 0-31 + */ +#define A64_FCMP_S_ZERO_BASE 0x1e202008u +static inline uint32_t a64_fcmp_s_zero(uint32_t rn) +{ + return A64_FCMP_S_ZERO_BASE + | (((rn) & 0x1fu) << 5); +} + +/* fcmp {rn}, #0.0 + * rn bits 9.. 5: D register 0-31 + */ +#define A64_FCMP_D_ZERO_BASE 0x1e602008u +static inline uint32_t a64_fcmp_d_zero(uint32_t rn) +{ + return A64_FCMP_D_ZERO_BASE + | (((rn) & 0x1fu) << 5); +} + +/* fcvt {rd}, {rn} + * rd bits 4.. 0: D register 0-31 + * rn bits 9.. 5: S register 0-31 + */ +#define A64_FCVT_S_TO_D_BASE 0x1e22c000u +static inline uint32_t a64_fcvt_s_to_d(uint32_t rd, uint32_t rn) +{ + return A64_FCVT_S_TO_D_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* fcvt {rd}, {rn} + * rd bits 4.. 0: S register 0-31 + * rn bits 9.. 5: D register 0-31 + */ +#define A64_FCVT_D_TO_S_BASE 0x1e624000u +static inline uint32_t a64_fcvt_d_to_s(uint32_t rd, uint32_t rn) +{ + return A64_FCVT_D_TO_S_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* scvtf {rd}, {rn} + * rd bits 4.. 0: S register 0-31 + * rn bits 9.. 5: W register 0-30, 31 = WZR + */ +#define A64_SCVTF_S_FROM_W_BASE 0x1e220000u +static inline uint32_t a64_scvtf_s_from_w(uint32_t rd, uint32_t rn) +{ + return A64_SCVTF_S_FROM_W_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* scvtf {rd}, {rn} + * rd bits 4.. 0: S register 0-31 + * rn bits 9.. 5: X register 0-30, 31 = XZR + */ +#define A64_SCVTF_S_FROM_X_BASE 0x9e220000u +static inline uint32_t a64_scvtf_s_from_x(uint32_t rd, uint32_t rn) +{ + return A64_SCVTF_S_FROM_X_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* scvtf {rd}, {rn} + * rd bits 4.. 0: D register 0-31 + * rn bits 9.. 5: W register 0-30, 31 = WZR + */ +#define A64_SCVTF_D_FROM_W_BASE 0x1e620000u +static inline uint32_t a64_scvtf_d_from_w(uint32_t rd, uint32_t rn) +{ + return A64_SCVTF_D_FROM_W_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* scvtf {rd}, {rn} + * rd bits 4.. 0: D register 0-31 + * rn bits 9.. 5: X register 0-30, 31 = XZR + */ +#define A64_SCVTF_D_FROM_X_BASE 0x9e620000u +static inline uint32_t a64_scvtf_d_from_x(uint32_t rd, uint32_t rn) +{ + return A64_SCVTF_D_FROM_X_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* ucvtf {rd}, {rn} + * rd bits 4.. 0: S register 0-31 + * rn bits 9.. 5: W register 0-30, 31 = WZR + */ +#define A64_UCVTF_S_FROM_W_BASE 0x1e230000u +static inline uint32_t a64_ucvtf_s_from_w(uint32_t rd, uint32_t rn) +{ + return A64_UCVTF_S_FROM_W_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* ucvtf {rd}, {rn} + * rd bits 4.. 0: S register 0-31 + * rn bits 9.. 5: X register 0-30, 31 = XZR + */ +#define A64_UCVTF_S_FROM_X_BASE 0x9e230000u +static inline uint32_t a64_ucvtf_s_from_x(uint32_t rd, uint32_t rn) +{ + return A64_UCVTF_S_FROM_X_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* ucvtf {rd}, {rn} + * rd bits 4.. 0: D register 0-31 + * rn bits 9.. 5: W register 0-30, 31 = WZR + */ +#define A64_UCVTF_D_FROM_W_BASE 0x1e630000u +static inline uint32_t a64_ucvtf_d_from_w(uint32_t rd, uint32_t rn) +{ + return A64_UCVTF_D_FROM_W_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* ucvtf {rd}, {rn} + * rd bits 4.. 0: D register 0-31 + * rn bits 9.. 5: X register 0-30, 31 = XZR + */ +#define A64_UCVTF_D_FROM_X_BASE 0x9e630000u +static inline uint32_t a64_ucvtf_d_from_x(uint32_t rd, uint32_t rn) +{ + return A64_UCVTF_D_FROM_X_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* fcvtzs {rd}, {rn} + * rd bits 4.. 0: W register 0-30, 31 = WZR + * rn bits 9.. 5: S register 0-31 + */ +#define A64_FCVTZS_S_TO_W_BASE 0x1e380000u +static inline uint32_t a64_fcvtzs_s_to_w(uint32_t rd, uint32_t rn) +{ + return A64_FCVTZS_S_TO_W_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* fcvtzs {rd}, {rn} + * rd bits 4.. 0: X register 0-30, 31 = XZR + * rn bits 9.. 5: S register 0-31 + */ +#define A64_FCVTZS_S_TO_X_BASE 0x9e380000u +static inline uint32_t a64_fcvtzs_s_to_x(uint32_t rd, uint32_t rn) +{ + return A64_FCVTZS_S_TO_X_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* fcvtzs {rd}, {rn} + * rd bits 4.. 0: W register 0-30, 31 = WZR + * rn bits 9.. 5: D register 0-31 + */ +#define A64_FCVTZS_D_TO_W_BASE 0x1e780000u +static inline uint32_t a64_fcvtzs_d_to_w(uint32_t rd, uint32_t rn) +{ + return A64_FCVTZS_D_TO_W_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* fcvtzs {rd}, {rn} + * rd bits 4.. 0: X register 0-30, 31 = XZR + * rn bits 9.. 5: D register 0-31 + */ +#define A64_FCVTZS_D_TO_X_BASE 0x9e780000u +static inline uint32_t a64_fcvtzs_d_to_x(uint32_t rd, uint32_t rn) +{ + return A64_FCVTZS_D_TO_X_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* fcvtzu {rd}, {rn} + * rd bits 4.. 0: W register 0-30, 31 = WZR + * rn bits 9.. 5: S register 0-31 + */ +#define A64_FCVTZU_S_TO_W_BASE 0x1e390000u +static inline uint32_t a64_fcvtzu_s_to_w(uint32_t rd, uint32_t rn) +{ + return A64_FCVTZU_S_TO_W_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* fcvtzu {rd}, {rn} + * rd bits 4.. 0: X register 0-30, 31 = XZR + * rn bits 9.. 5: S register 0-31 + */ +#define A64_FCVTZU_S_TO_X_BASE 0x9e390000u +static inline uint32_t a64_fcvtzu_s_to_x(uint32_t rd, uint32_t rn) +{ + return A64_FCVTZU_S_TO_X_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* fcvtzu {rd}, {rn} + * rd bits 4.. 0: W register 0-30, 31 = WZR + * rn bits 9.. 5: D register 0-31 + */ +#define A64_FCVTZU_D_TO_W_BASE 0x1e790000u +static inline uint32_t a64_fcvtzu_d_to_w(uint32_t rd, uint32_t rn) +{ + return A64_FCVTZU_D_TO_W_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* fcvtzu {rd}, {rn} + * rd bits 4.. 0: X register 0-30, 31 = XZR + * rn bits 9.. 5: D register 0-31 + */ +#define A64_FCVTZU_D_TO_X_BASE 0x9e790000u +static inline uint32_t a64_fcvtzu_d_to_x(uint32_t rd, uint32_t rn) +{ + return A64_FCVTZU_D_TO_X_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5); +} + +/* fcsel {rd}, {rn}, {rm}, {cond} + * rd bits 4.. 0: S register 0-31 + * rn bits 9.. 5: S register 0-31 + * rm bits 20..16: S register 0-31 + * cond bits 15..12: condition code 0-15 (EQ=0 NE=1 CS=2 CC=3 MI=4 PL=5 VS=6 VC=7 HI=8 LS=9 GE=10 LT=11 GT=12 LE=13 AL=14) + */ +#define A64_FCSEL_S_BASE 0x1e200c00u +static inline uint32_t a64_fcsel_s(uint32_t rd, uint32_t rn, uint32_t rm, uint32_t cond) +{ + return A64_FCSEL_S_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16) + | (((cond) & 0xfu) << 12); +} + +/* fcsel {rd}, {rn}, {rm}, {cond} + * rd bits 4.. 0: D register 0-31 + * rn bits 9.. 5: D register 0-31 + * rm bits 20..16: D register 0-31 + * cond bits 15..12: condition code 0-15 (EQ=0 NE=1 CS=2 CC=3 MI=4 PL=5 VS=6 VC=7 HI=8 LS=9 GE=10 LT=11 GT=12 LE=13 AL=14) + */ +#define A64_FCSEL_D_BASE 0x1e600c00u +static inline uint32_t a64_fcsel_d(uint32_t rd, uint32_t rn, uint32_t rm, uint32_t cond) +{ + return A64_FCSEL_D_BASE + | (((rd) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16) + | (((cond) & 0xfu) << 12); +} + +/* ldr {rt}, [{rn}, {imm12}] + * rt bits 4.. 0: S register 0-31 + * rn bits 9.. 5: X base register 0-30, 31 = SP + * imm12 bits 21..10: unsigned scaled offset: byte offset / 4 (0-4095 => 0-16380 bytes) + */ +#define A64_LDR_S_UIMM_BASE 0xbd400000u +static inline uint32_t a64_ldr_s_uimm(uint32_t rt, uint32_t rn, uint32_t imm12) +{ + return A64_LDR_S_UIMM_BASE + | (((rt) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((imm12) & 0xfffu) << 10); +} + +/* ldr {rt}, [{rn}, {imm12}] + * rt bits 4.. 0: D register 0-31 + * rn bits 9.. 5: X base register 0-30, 31 = SP + * imm12 bits 21..10: unsigned scaled offset: byte offset / 8 (0-4095 => 0-32760 bytes) + */ +#define A64_LDR_D_UIMM_BASE 0xfd400000u +static inline uint32_t a64_ldr_d_uimm(uint32_t rt, uint32_t rn, uint32_t imm12) +{ + return A64_LDR_D_UIMM_BASE + | (((rt) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((imm12) & 0xfffu) << 10); +} + +/* str {rt}, [{rn}, {imm12}] + * rt bits 4.. 0: S register 0-31 + * rn bits 9.. 5: X base register 0-30, 31 = SP + * imm12 bits 21..10: unsigned scaled offset: byte offset / 4 (0-4095 => 0-16380 bytes) + */ +#define A64_STR_S_UIMM_BASE 0xbd000000u +static inline uint32_t a64_str_s_uimm(uint32_t rt, uint32_t rn, uint32_t imm12) +{ + return A64_STR_S_UIMM_BASE + | (((rt) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((imm12) & 0xfffu) << 10); +} + +/* str {rt}, [{rn}, {imm12}] + * rt bits 4.. 0: D register 0-31 + * rn bits 9.. 5: X base register 0-30, 31 = SP + * imm12 bits 21..10: unsigned scaled offset: byte offset / 8 (0-4095 => 0-32760 bytes) + */ +#define A64_STR_D_UIMM_BASE 0xfd000000u +static inline uint32_t a64_str_d_uimm(uint32_t rt, uint32_t rn, uint32_t imm12) +{ + return A64_STR_D_UIMM_BASE + | (((rt) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((imm12) & 0xfffu) << 10); +} + +/* ldr {rt}, [{rn}, {rm}] + * rt bits 4.. 0: S register 0-31 + * rn bits 9.. 5: X base register 0-30, 31 = SP + * rm bits 20..16: X register 0-30, 31 = XZR + */ +#define A64_LDR_S_REG_BASE 0xbc606800u +static inline uint32_t a64_ldr_s_reg(uint32_t rt, uint32_t rn, uint32_t rm) +{ + return A64_LDR_S_REG_BASE + | (((rt) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16); +} + +/* ldr {rt}, [{rn}, {rm}] + * rt bits 4.. 0: D register 0-31 + * rn bits 9.. 5: X base register 0-30, 31 = SP + * rm bits 20..16: X register 0-30, 31 = XZR + */ +#define A64_LDR_D_REG_BASE 0xfc606800u +static inline uint32_t a64_ldr_d_reg(uint32_t rt, uint32_t rn, uint32_t rm) +{ + return A64_LDR_D_REG_BASE + | (((rt) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16); +} + +/* str {rt}, [{rn}, {rm}] + * rt bits 4.. 0: S register 0-31 + * rn bits 9.. 5: X base register 0-30, 31 = SP + * rm bits 20..16: X register 0-30, 31 = XZR + */ +#define A64_STR_S_REG_BASE 0xbc206800u +static inline uint32_t a64_str_s_reg(uint32_t rt, uint32_t rn, uint32_t rm) +{ + return A64_STR_S_REG_BASE + | (((rt) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16); +} + +/* str {rt}, [{rn}, {rm}] + * rt bits 4.. 0: D register 0-31 + * rn bits 9.. 5: X base register 0-30, 31 = SP + * rm bits 20..16: X register 0-30, 31 = XZR + */ +#define A64_STR_D_REG_BASE 0xfc206800u +static inline uint32_t a64_str_d_reg(uint32_t rt, uint32_t rn, uint32_t rm) +{ + return A64_STR_D_REG_BASE + | (((rt) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16); +} + +/* ldr {rt}, [{rn}, {rm}, lsl #2] + * rt bits 4.. 0: S register 0-31 + * rn bits 9.. 5: X base register 0-30, 31 = SP + * rm bits 20..16: X register 0-30, 31 = XZR + */ +#define A64_LDR_S_REG_LSL_BASE 0xbc607800u +static inline uint32_t a64_ldr_s_reg_lsl(uint32_t rt, uint32_t rn, uint32_t rm) +{ + return A64_LDR_S_REG_LSL_BASE + | (((rt) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16); +} + +/* ldr {rt}, [{rn}, {rm}, lsl #3] + * rt bits 4.. 0: D register 0-31 + * rn bits 9.. 5: X base register 0-30, 31 = SP + * rm bits 20..16: X register 0-30, 31 = XZR + */ +#define A64_LDR_D_REG_LSL_BASE 0xfc607800u +static inline uint32_t a64_ldr_d_reg_lsl(uint32_t rt, uint32_t rn, uint32_t rm) +{ + return A64_LDR_D_REG_LSL_BASE + | (((rt) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16); +} + +/* str {rt}, [{rn}, {rm}, lsl #2] + * rt bits 4.. 0: S register 0-31 + * rn bits 9.. 5: X base register 0-30, 31 = SP + * rm bits 20..16: X register 0-30, 31 = XZR + */ +#define A64_STR_S_REG_LSL_BASE 0xbc207800u +static inline uint32_t a64_str_s_reg_lsl(uint32_t rt, uint32_t rn, uint32_t rm) +{ + return A64_STR_S_REG_LSL_BASE + | (((rt) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16); +} + +/* str {rt}, [{rn}, {rm}, lsl #3] + * rt bits 4.. 0: D register 0-31 + * rn bits 9.. 5: X base register 0-30, 31 = SP + * rm bits 20..16: X register 0-30, 31 = XZR + */ +#define A64_STR_D_REG_LSL_BASE 0xfc207800u +static inline uint32_t a64_str_d_reg_lsl(uint32_t rt, uint32_t rn, uint32_t rm) +{ + return A64_STR_D_REG_LSL_BASE + | (((rt) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((rm) & 0x1fu) << 16); +} + +/* ldr {rt}, [{rn}, {imm9}]! + * rt bits 4.. 0: S register 0-31 + * rn bits 9.. 5: X base register 0-30, 31 = SP + * imm9 bits 20..12: signed byte offset -256..255 (unscaled) + */ +#define A64_LDR_S_PRE_BASE 0xbc400c00u +static inline uint32_t a64_ldr_s_pre(uint32_t rt, uint32_t rn, int32_t imm9) +{ + return A64_LDR_S_PRE_BASE + | (((rt) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((uint32_t)(imm9) & 0x1ffu) << 12); +} + +/* ldr {rt}, [{rn}, {imm9}]! + * rt bits 4.. 0: D register 0-31 + * rn bits 9.. 5: X base register 0-30, 31 = SP + * imm9 bits 20..12: signed byte offset -256..255 (unscaled) + */ +#define A64_LDR_D_PRE_BASE 0xfc400c00u +static inline uint32_t a64_ldr_d_pre(uint32_t rt, uint32_t rn, int32_t imm9) +{ + return A64_LDR_D_PRE_BASE + | (((rt) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((uint32_t)(imm9) & 0x1ffu) << 12); +} + +/* str {rt}, [{rn}, {imm9}]! + * rt bits 4.. 0: S register 0-31 + * rn bits 9.. 5: X base register 0-30, 31 = SP + * imm9 bits 20..12: signed byte offset -256..255 (unscaled) + */ +#define A64_STR_S_PRE_BASE 0xbc000c00u +static inline uint32_t a64_str_s_pre(uint32_t rt, uint32_t rn, int32_t imm9) +{ + return A64_STR_S_PRE_BASE + | (((rt) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((uint32_t)(imm9) & 0x1ffu) << 12); +} + +/* str {rt}, [{rn}, {imm9}]! + * rt bits 4.. 0: D register 0-31 + * rn bits 9.. 5: X base register 0-30, 31 = SP + * imm9 bits 20..12: signed byte offset -256..255 (unscaled) + */ +#define A64_STR_D_PRE_BASE 0xfc000c00u +static inline uint32_t a64_str_d_pre(uint32_t rt, uint32_t rn, int32_t imm9) +{ + return A64_STR_D_PRE_BASE + | (((rt) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((uint32_t)(imm9) & 0x1ffu) << 12); +} + +/* ldr {rt}, [{rn}], {imm9} + * rt bits 4.. 0: S register 0-31 + * rn bits 9.. 5: X base register 0-30, 31 = SP + * imm9 bits 20..12: signed byte offset -256..255 (unscaled) + */ +#define A64_LDR_S_POST_BASE 0xbc400400u +static inline uint32_t a64_ldr_s_post(uint32_t rt, uint32_t rn, int32_t imm9) +{ + return A64_LDR_S_POST_BASE + | (((rt) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((uint32_t)(imm9) & 0x1ffu) << 12); +} + +/* ldr {rt}, [{rn}], {imm9} + * rt bits 4.. 0: D register 0-31 + * rn bits 9.. 5: X base register 0-30, 31 = SP + * imm9 bits 20..12: signed byte offset -256..255 (unscaled) + */ +#define A64_LDR_D_POST_BASE 0xfc400400u +static inline uint32_t a64_ldr_d_post(uint32_t rt, uint32_t rn, int32_t imm9) +{ + return A64_LDR_D_POST_BASE + | (((rt) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((uint32_t)(imm9) & 0x1ffu) << 12); +} + +/* str {rt}, [{rn}], {imm9} + * rt bits 4.. 0: S register 0-31 + * rn bits 9.. 5: X base register 0-30, 31 = SP + * imm9 bits 20..12: signed byte offset -256..255 (unscaled) + */ +#define A64_STR_S_POST_BASE 0xbc000400u +static inline uint32_t a64_str_s_post(uint32_t rt, uint32_t rn, int32_t imm9) +{ + return A64_STR_S_POST_BASE + | (((rt) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((uint32_t)(imm9) & 0x1ffu) << 12); +} + +/* str {rt}, [{rn}], {imm9} + * rt bits 4.. 0: D register 0-31 + * rn bits 9.. 5: X base register 0-30, 31 = SP + * imm9 bits 20..12: signed byte offset -256..255 (unscaled) + */ +#define A64_STR_D_POST_BASE 0xfc000400u +static inline uint32_t a64_str_d_post(uint32_t rt, uint32_t rn, int32_t imm9) +{ + return A64_STR_D_POST_BASE + | (((rt) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((uint32_t)(imm9) & 0x1ffu) << 12); +} + +/* ldur {rt}, [{rn}, {imm9}] + * rt bits 4.. 0: S register 0-31 + * rn bits 9.. 5: X base register 0-30, 31 = SP + * imm9 bits 20..12: signed byte offset -256..255 (unscaled) + */ +#define A64_LDUR_S_BASE 0xbc400000u +static inline uint32_t a64_ldur_s(uint32_t rt, uint32_t rn, int32_t imm9) +{ + return A64_LDUR_S_BASE + | (((rt) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((uint32_t)(imm9) & 0x1ffu) << 12); +} + +/* ldur {rt}, [{rn}, {imm9}] + * rt bits 4.. 0: D register 0-31 + * rn bits 9.. 5: X base register 0-30, 31 = SP + * imm9 bits 20..12: signed byte offset -256..255 (unscaled) + */ +#define A64_LDUR_D_BASE 0xfc400000u +static inline uint32_t a64_ldur_d(uint32_t rt, uint32_t rn, int32_t imm9) +{ + return A64_LDUR_D_BASE + | (((rt) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((uint32_t)(imm9) & 0x1ffu) << 12); +} + +/* stur {rt}, [{rn}, {imm9}] + * rt bits 4.. 0: S register 0-31 + * rn bits 9.. 5: X base register 0-30, 31 = SP + * imm9 bits 20..12: signed byte offset -256..255 (unscaled) + */ +#define A64_STUR_S_BASE 0xbc000000u +static inline uint32_t a64_stur_s(uint32_t rt, uint32_t rn, int32_t imm9) +{ + return A64_STUR_S_BASE + | (((rt) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((uint32_t)(imm9) & 0x1ffu) << 12); +} + +/* stur {rt}, [{rn}, {imm9}] + * rt bits 4.. 0: D register 0-31 + * rn bits 9.. 5: X base register 0-30, 31 = SP + * imm9 bits 20..12: signed byte offset -256..255 (unscaled) + */ +#define A64_STUR_D_BASE 0xfc000000u +static inline uint32_t a64_stur_d(uint32_t rt, uint32_t rn, int32_t imm9) +{ + return A64_STUR_D_BASE + | (((rt) & 0x1fu) << 0) + | (((rn) & 0x1fu) << 5) + | (((uint32_t)(imm9) & 0x1ffu) << 12); +} + +/* b.{cond} {imm19} + * cond bits 3.. 0: condition code (EQ=0 NE=1 MI=4 VS=6 HI=8 LS=9 GE=10 LT=11 GT=12 LE=13) + * imm19 bits 23.. 5: signed offset in instructions (byte offset / 4) from this instruction, -262144..262143 + */ +#define A64_B_COND_BASE 0x54000000u +static inline uint32_t a64_b_cond(uint32_t cond, int32_t imm19) +{ + return A64_B_COND_BASE + | (((cond) & 0xfu) << 0) + | (((uint32_t)(imm19) & 0x7ffffu) << 5); +} + +/* Self-test: re-encode every assembler sample through the named encoders. */ +static inline uint32_t a64_golden_encode(int form, const int32_t *a) +{ + switch (form) { + case 0: return a64_fmov_s((uint32_t)a[0], (uint32_t)a[1]); + case 1: return a64_fmov_d((uint32_t)a[0], (uint32_t)a[1]); + case 2: return a64_fmov_s_imm((uint32_t)a[0], (uint32_t)a[1]); + case 3: return a64_fmov_d_imm((uint32_t)a[0], (uint32_t)a[1]); + case 4: return a64_fmov_s_from_w((uint32_t)a[0], (uint32_t)a[1]); + case 5: return a64_fmov_s_to_w((uint32_t)a[0], (uint32_t)a[1]); + case 6: return a64_fmov_d_from_x((uint32_t)a[0], (uint32_t)a[1]); + case 7: return a64_fmov_d_to_x((uint32_t)a[0], (uint32_t)a[1]); + case 8: return a64_fadd_s((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 9: return a64_fadd_d((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 10: return a64_fsub_s((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 11: return a64_fsub_d((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 12: return a64_fmul_s((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 13: return a64_fmul_d((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 14: return a64_fdiv_s((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 15: return a64_fdiv_d((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 16: return a64_fmin_s((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 17: return a64_fmin_d((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 18: return a64_fmax_s((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 19: return a64_fmax_d((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 20: return a64_fminnm_s((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 21: return a64_fminnm_d((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 22: return a64_fmaxnm_s((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 23: return a64_fmaxnm_d((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 24: return a64_fsqrt_s((uint32_t)a[0], (uint32_t)a[1]); + case 25: return a64_fsqrt_d((uint32_t)a[0], (uint32_t)a[1]); + case 26: return a64_fneg_s((uint32_t)a[0], (uint32_t)a[1]); + case 27: return a64_fneg_d((uint32_t)a[0], (uint32_t)a[1]); + case 28: return a64_fabs_s((uint32_t)a[0], (uint32_t)a[1]); + case 29: return a64_fabs_d((uint32_t)a[0], (uint32_t)a[1]); + case 30: return a64_frintn_s((uint32_t)a[0], (uint32_t)a[1]); + case 31: return a64_frintn_d((uint32_t)a[0], (uint32_t)a[1]); + case 32: return a64_frintm_s((uint32_t)a[0], (uint32_t)a[1]); + case 33: return a64_frintm_d((uint32_t)a[0], (uint32_t)a[1]); + case 34: return a64_frintp_s((uint32_t)a[0], (uint32_t)a[1]); + case 35: return a64_frintp_d((uint32_t)a[0], (uint32_t)a[1]); + case 36: return a64_frintz_s((uint32_t)a[0], (uint32_t)a[1]); + case 37: return a64_frintz_d((uint32_t)a[0], (uint32_t)a[1]); + case 38: return a64_fcmp_s((uint32_t)a[0], (uint32_t)a[1]); + case 39: return a64_fcmp_d((uint32_t)a[0], (uint32_t)a[1]); + case 40: return a64_fcmp_s_zero((uint32_t)a[0]); + case 41: return a64_fcmp_d_zero((uint32_t)a[0]); + case 42: return a64_fcvt_s_to_d((uint32_t)a[0], (uint32_t)a[1]); + case 43: return a64_fcvt_d_to_s((uint32_t)a[0], (uint32_t)a[1]); + case 44: return a64_scvtf_s_from_w((uint32_t)a[0], (uint32_t)a[1]); + case 45: return a64_scvtf_s_from_x((uint32_t)a[0], (uint32_t)a[1]); + case 46: return a64_scvtf_d_from_w((uint32_t)a[0], (uint32_t)a[1]); + case 47: return a64_scvtf_d_from_x((uint32_t)a[0], (uint32_t)a[1]); + case 48: return a64_ucvtf_s_from_w((uint32_t)a[0], (uint32_t)a[1]); + case 49: return a64_ucvtf_s_from_x((uint32_t)a[0], (uint32_t)a[1]); + case 50: return a64_ucvtf_d_from_w((uint32_t)a[0], (uint32_t)a[1]); + case 51: return a64_ucvtf_d_from_x((uint32_t)a[0], (uint32_t)a[1]); + case 52: return a64_fcvtzs_s_to_w((uint32_t)a[0], (uint32_t)a[1]); + case 53: return a64_fcvtzs_s_to_x((uint32_t)a[0], (uint32_t)a[1]); + case 54: return a64_fcvtzs_d_to_w((uint32_t)a[0], (uint32_t)a[1]); + case 55: return a64_fcvtzs_d_to_x((uint32_t)a[0], (uint32_t)a[1]); + case 56: return a64_fcvtzu_s_to_w((uint32_t)a[0], (uint32_t)a[1]); + case 57: return a64_fcvtzu_s_to_x((uint32_t)a[0], (uint32_t)a[1]); + case 58: return a64_fcvtzu_d_to_w((uint32_t)a[0], (uint32_t)a[1]); + case 59: return a64_fcvtzu_d_to_x((uint32_t)a[0], (uint32_t)a[1]); + case 60: return a64_fcsel_s((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2], (uint32_t)a[3]); + case 61: return a64_fcsel_d((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2], (uint32_t)a[3]); + case 62: return a64_ldr_s_uimm((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 63: return a64_ldr_d_uimm((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 64: return a64_str_s_uimm((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 65: return a64_str_d_uimm((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 66: return a64_ldr_s_reg((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 67: return a64_ldr_d_reg((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 68: return a64_str_s_reg((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 69: return a64_str_d_reg((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 70: return a64_ldr_s_reg_lsl((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 71: return a64_ldr_d_reg_lsl((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 72: return a64_str_s_reg_lsl((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 73: return a64_str_d_reg_lsl((uint32_t)a[0], (uint32_t)a[1], (uint32_t)a[2]); + case 74: return a64_ldr_s_pre((uint32_t)a[0], (uint32_t)a[1], a[2]); + case 75: return a64_ldr_d_pre((uint32_t)a[0], (uint32_t)a[1], a[2]); + case 76: return a64_str_s_pre((uint32_t)a[0], (uint32_t)a[1], a[2]); + case 77: return a64_str_d_pre((uint32_t)a[0], (uint32_t)a[1], a[2]); + case 78: return a64_ldr_s_post((uint32_t)a[0], (uint32_t)a[1], a[2]); + case 79: return a64_ldr_d_post((uint32_t)a[0], (uint32_t)a[1], a[2]); + case 80: return a64_str_s_post((uint32_t)a[0], (uint32_t)a[1], a[2]); + case 81: return a64_str_d_post((uint32_t)a[0], (uint32_t)a[1], a[2]); + case 82: return a64_ldur_s((uint32_t)a[0], (uint32_t)a[1], a[2]); + case 83: return a64_ldur_d((uint32_t)a[0], (uint32_t)a[1], a[2]); + case 84: return a64_stur_s((uint32_t)a[0], (uint32_t)a[1], a[2]); + case 85: return a64_stur_d((uint32_t)a[0], (uint32_t)a[1], a[2]); + case 86: return a64_b_cond((uint32_t)a[0], a[1]); + default: return 0; + } +} + +struct a64_golden_sample { int form; int32_t a[4]; uint32_t want; const char *asm_text; }; + +/* Returns the number of mismatches; stores the sample count in *nsamples if non-NULL. + * If bad_out is non-NULL it is called for each mismatch. */ +static inline unsigned a64_golden_selftest(unsigned *nsamples, + void (*bad_out)(const char *asm_text, uint32_t want, uint32_t got)) +{ + static const struct a64_golden_sample t[] = { + {0, {0, 0, 0, 0}, 0x1e204000u, "fmov s0, s0"}, + {0, {1, 0, 0, 0}, 0x1e204001u, "fmov s1, s0"}, + {0, {7, 0, 0, 0}, 0x1e204007u, "fmov s7, s0"}, + {0, {15, 0, 0, 0}, 0x1e20400fu, "fmov s15, s0"}, + {0, {31, 0, 0, 0}, 0x1e20401fu, "fmov s31, s0"}, + {0, {0, 1, 0, 0}, 0x1e204020u, "fmov s0, s1"}, + {0, {0, 7, 0, 0}, 0x1e2040e0u, "fmov s0, s7"}, + {0, {0, 15, 0, 0}, 0x1e2041e0u, "fmov s0, s15"}, + {0, {0, 31, 0, 0}, 0x1e2043e0u, "fmov s0, s31"}, + {0, {15, 0, 0, 0}, 0x1e20400fu, "fmov s15, s0"}, + {0, {0, 15, 0, 0}, 0x1e2041e0u, "fmov s0, s15"}, + {0, {7, 1, 0, 0}, 0x1e204027u, "fmov s7, s1"}, + {0, {31, 31, 0, 0}, 0x1e2043ffu, "fmov s31, s31"}, + {1, {0, 0, 0, 0}, 0x1e604000u, "fmov d0, d0"}, + {1, {1, 0, 0, 0}, 0x1e604001u, "fmov d1, d0"}, + {1, {7, 0, 0, 0}, 0x1e604007u, "fmov d7, d0"}, + {1, {15, 0, 0, 0}, 0x1e60400fu, "fmov d15, d0"}, + {1, {31, 0, 0, 0}, 0x1e60401fu, "fmov d31, d0"}, + {1, {0, 1, 0, 0}, 0x1e604020u, "fmov d0, d1"}, + {1, {0, 7, 0, 0}, 0x1e6040e0u, "fmov d0, d7"}, + {1, {0, 15, 0, 0}, 0x1e6041e0u, "fmov d0, d15"}, + {1, {0, 31, 0, 0}, 0x1e6043e0u, "fmov d0, d31"}, + {1, {15, 0, 0, 0}, 0x1e60400fu, "fmov d15, d0"}, + {1, {0, 15, 0, 0}, 0x1e6041e0u, "fmov d0, d15"}, + {1, {7, 1, 0, 0}, 0x1e604027u, "fmov d7, d1"}, + {1, {31, 31, 0, 0}, 0x1e6043ffu, "fmov d31, d31"}, + {2, {0, 0, 0, 0}, 0x1e201000u, "fmov s0, #2.0"}, + {2, {1, 0, 0, 0}, 0x1e201001u, "fmov s1, #2.0"}, + {2, {7, 0, 0, 0}, 0x1e201007u, "fmov s7, #2.0"}, + {2, {15, 0, 0, 0}, 0x1e20100fu, "fmov s15, #2.0"}, + {2, {31, 0, 0, 0}, 0x1e20101fu, "fmov s31, #2.0"}, + {2, {0, 112, 0, 0}, 0x1e2e1000u, "fmov s0, #1.0"}, + {2, {0, 96, 0, 0}, 0x1e2c1000u, "fmov s0, #0.5"}, + {2, {0, 240, 0, 0}, 0x1e3e1000u, "fmov s0, #-1.0"}, + {2, {0, 127, 0, 0}, 0x1e2ff000u, "fmov s0, #1.9375"}, + {2, {0, 63, 0, 0}, 0x1e27f000u, "fmov s0, #31.0"}, + {2, {0, 128, 0, 0}, 0x1e301000u, "fmov s0, #-2.0"}, + {2, {0, 64, 0, 0}, 0x1e281000u, "fmov s0, #0.125"}, + {2, {15, 63, 0, 0}, 0x1e27f00fu, "fmov s15, #31.0"}, + {2, {0, 0, 0, 0}, 0x1e201000u, "fmov s0, #2.0"}, + {2, {7, 240, 0, 0}, 0x1e3e1007u, "fmov s7, #-1.0"}, + {2, {31, 128, 0, 0}, 0x1e30101fu, "fmov s31, #-2.0"}, + {3, {0, 0, 0, 0}, 0x1e601000u, "fmov d0, #2.0"}, + {3, {1, 0, 0, 0}, 0x1e601001u, "fmov d1, #2.0"}, + {3, {7, 0, 0, 0}, 0x1e601007u, "fmov d7, #2.0"}, + {3, {15, 0, 0, 0}, 0x1e60100fu, "fmov d15, #2.0"}, + {3, {31, 0, 0, 0}, 0x1e60101fu, "fmov d31, #2.0"}, + {3, {0, 112, 0, 0}, 0x1e6e1000u, "fmov d0, #1.0"}, + {3, {0, 96, 0, 0}, 0x1e6c1000u, "fmov d0, #0.5"}, + {3, {0, 240, 0, 0}, 0x1e7e1000u, "fmov d0, #-1.0"}, + {3, {0, 127, 0, 0}, 0x1e6ff000u, "fmov d0, #1.9375"}, + {3, {0, 63, 0, 0}, 0x1e67f000u, "fmov d0, #31.0"}, + {3, {0, 128, 0, 0}, 0x1e701000u, "fmov d0, #-2.0"}, + {3, {0, 64, 0, 0}, 0x1e681000u, "fmov d0, #0.125"}, + {3, {15, 63, 0, 0}, 0x1e67f00fu, "fmov d15, #31.0"}, + {3, {0, 0, 0, 0}, 0x1e601000u, "fmov d0, #2.0"}, + {3, {7, 240, 0, 0}, 0x1e7e1007u, "fmov d7, #-1.0"}, + {3, {31, 128, 0, 0}, 0x1e70101fu, "fmov d31, #-2.0"}, + {4, {0, 0, 0, 0}, 0x1e270000u, "fmov s0, w0"}, + {4, {1, 0, 0, 0}, 0x1e270001u, "fmov s1, w0"}, + {4, {7, 0, 0, 0}, 0x1e270007u, "fmov s7, w0"}, + {4, {15, 0, 0, 0}, 0x1e27000fu, "fmov s15, w0"}, + {4, {31, 0, 0, 0}, 0x1e27001fu, "fmov s31, w0"}, + {4, {0, 1, 0, 0}, 0x1e270020u, "fmov s0, w1"}, + {4, {0, 7, 0, 0}, 0x1e2700e0u, "fmov s0, w7"}, + {4, {0, 15, 0, 0}, 0x1e2701e0u, "fmov s0, w15"}, + {4, {0, 31, 0, 0}, 0x1e2703e0u, "fmov s0, wzr"}, + {4, {15, 0, 0, 0}, 0x1e27000fu, "fmov s15, w0"}, + {4, {0, 15, 0, 0}, 0x1e2701e0u, "fmov s0, w15"}, + {4, {7, 1, 0, 0}, 0x1e270027u, "fmov s7, w1"}, + {4, {31, 31, 0, 0}, 0x1e2703ffu, "fmov s31, wzr"}, + {5, {0, 0, 0, 0}, 0x1e260000u, "fmov w0, s0"}, + {5, {1, 0, 0, 0}, 0x1e260001u, "fmov w1, s0"}, + {5, {7, 0, 0, 0}, 0x1e260007u, "fmov w7, s0"}, + {5, {15, 0, 0, 0}, 0x1e26000fu, "fmov w15, s0"}, + {5, {31, 0, 0, 0}, 0x1e26001fu, "fmov wzr, s0"}, + {5, {0, 1, 0, 0}, 0x1e260020u, "fmov w0, s1"}, + {5, {0, 7, 0, 0}, 0x1e2600e0u, "fmov w0, s7"}, + {5, {0, 15, 0, 0}, 0x1e2601e0u, "fmov w0, s15"}, + {5, {0, 31, 0, 0}, 0x1e2603e0u, "fmov w0, s31"}, + {5, {15, 0, 0, 0}, 0x1e26000fu, "fmov w15, s0"}, + {5, {0, 15, 0, 0}, 0x1e2601e0u, "fmov w0, s15"}, + {5, {7, 1, 0, 0}, 0x1e260027u, "fmov w7, s1"}, + {5, {31, 31, 0, 0}, 0x1e2603ffu, "fmov wzr, s31"}, + {6, {0, 0, 0, 0}, 0x9e670000u, "fmov d0, x0"}, + {6, {1, 0, 0, 0}, 0x9e670001u, "fmov d1, x0"}, + {6, {7, 0, 0, 0}, 0x9e670007u, "fmov d7, x0"}, + {6, {15, 0, 0, 0}, 0x9e67000fu, "fmov d15, x0"}, + {6, {31, 0, 0, 0}, 0x9e67001fu, "fmov d31, x0"}, + {6, {0, 1, 0, 0}, 0x9e670020u, "fmov d0, x1"}, + {6, {0, 7, 0, 0}, 0x9e6700e0u, "fmov d0, x7"}, + {6, {0, 15, 0, 0}, 0x9e6701e0u, "fmov d0, x15"}, + {6, {0, 31, 0, 0}, 0x9e6703e0u, "fmov d0, xzr"}, + {6, {15, 0, 0, 0}, 0x9e67000fu, "fmov d15, x0"}, + {6, {0, 15, 0, 0}, 0x9e6701e0u, "fmov d0, x15"}, + {6, {7, 1, 0, 0}, 0x9e670027u, "fmov d7, x1"}, + {6, {31, 31, 0, 0}, 0x9e6703ffu, "fmov d31, xzr"}, + {7, {0, 0, 0, 0}, 0x9e660000u, "fmov x0, d0"}, + {7, {1, 0, 0, 0}, 0x9e660001u, "fmov x1, d0"}, + {7, {7, 0, 0, 0}, 0x9e660007u, "fmov x7, d0"}, + {7, {15, 0, 0, 0}, 0x9e66000fu, "fmov x15, d0"}, + {7, {31, 0, 0, 0}, 0x9e66001fu, "fmov xzr, d0"}, + {7, {0, 1, 0, 0}, 0x9e660020u, "fmov x0, d1"}, + {7, {0, 7, 0, 0}, 0x9e6600e0u, "fmov x0, d7"}, + {7, {0, 15, 0, 0}, 0x9e6601e0u, "fmov x0, d15"}, + {7, {0, 31, 0, 0}, 0x9e6603e0u, "fmov x0, d31"}, + {7, {15, 0, 0, 0}, 0x9e66000fu, "fmov x15, d0"}, + {7, {0, 15, 0, 0}, 0x9e6601e0u, "fmov x0, d15"}, + {7, {7, 1, 0, 0}, 0x9e660027u, "fmov x7, d1"}, + {7, {31, 31, 0, 0}, 0x9e6603ffu, "fmov xzr, d31"}, + {8, {0, 0, 0, 0}, 0x1e202800u, "fadd s0, s0, s0"}, + {8, {1, 0, 0, 0}, 0x1e202801u, "fadd s1, s0, s0"}, + {8, {7, 0, 0, 0}, 0x1e202807u, "fadd s7, s0, s0"}, + {8, {15, 0, 0, 0}, 0x1e20280fu, "fadd s15, s0, s0"}, + {8, {31, 0, 0, 0}, 0x1e20281fu, "fadd s31, s0, s0"}, + {8, {0, 1, 0, 0}, 0x1e202820u, "fadd s0, s1, s0"}, + {8, {0, 7, 0, 0}, 0x1e2028e0u, "fadd s0, s7, s0"}, + {8, {0, 15, 0, 0}, 0x1e2029e0u, "fadd s0, s15, s0"}, + {8, {0, 31, 0, 0}, 0x1e202be0u, "fadd s0, s31, s0"}, + {8, {0, 0, 1, 0}, 0x1e212800u, "fadd s0, s0, s1"}, + {8, {0, 0, 7, 0}, 0x1e272800u, "fadd s0, s0, s7"}, + {8, {0, 0, 15, 0}, 0x1e2f2800u, "fadd s0, s0, s15"}, + {8, {0, 0, 31, 0}, 0x1e3f2800u, "fadd s0, s0, s31"}, + {8, {15, 0, 7, 0}, 0x1e27280fu, "fadd s15, s0, s7"}, + {8, {0, 15, 1, 0}, 0x1e2129e0u, "fadd s0, s15, s1"}, + {8, {7, 1, 0, 0}, 0x1e202827u, "fadd s7, s1, s0"}, + {8, {31, 31, 31, 0}, 0x1e3f2bffu, "fadd s31, s31, s31"}, + {9, {0, 0, 0, 0}, 0x1e602800u, "fadd d0, d0, d0"}, + {9, {1, 0, 0, 0}, 0x1e602801u, "fadd d1, d0, d0"}, + {9, {7, 0, 0, 0}, 0x1e602807u, "fadd d7, d0, d0"}, + {9, {15, 0, 0, 0}, 0x1e60280fu, "fadd d15, d0, d0"}, + {9, {31, 0, 0, 0}, 0x1e60281fu, "fadd d31, d0, d0"}, + {9, {0, 1, 0, 0}, 0x1e602820u, "fadd d0, d1, d0"}, + {9, {0, 7, 0, 0}, 0x1e6028e0u, "fadd d0, d7, d0"}, + {9, {0, 15, 0, 0}, 0x1e6029e0u, "fadd d0, d15, d0"}, + {9, {0, 31, 0, 0}, 0x1e602be0u, "fadd d0, d31, d0"}, + {9, {0, 0, 1, 0}, 0x1e612800u, "fadd d0, d0, d1"}, + {9, {0, 0, 7, 0}, 0x1e672800u, "fadd d0, d0, d7"}, + {9, {0, 0, 15, 0}, 0x1e6f2800u, "fadd d0, d0, d15"}, + {9, {0, 0, 31, 0}, 0x1e7f2800u, "fadd d0, d0, d31"}, + {9, {15, 0, 7, 0}, 0x1e67280fu, "fadd d15, d0, d7"}, + {9, {0, 15, 1, 0}, 0x1e6129e0u, "fadd d0, d15, d1"}, + {9, {7, 1, 0, 0}, 0x1e602827u, "fadd d7, d1, d0"}, + {9, {31, 31, 31, 0}, 0x1e7f2bffu, "fadd d31, d31, d31"}, + {10, {0, 0, 0, 0}, 0x1e203800u, "fsub s0, s0, s0"}, + {10, {1, 0, 0, 0}, 0x1e203801u, "fsub s1, s0, s0"}, + {10, {7, 0, 0, 0}, 0x1e203807u, "fsub s7, s0, s0"}, + {10, {15, 0, 0, 0}, 0x1e20380fu, "fsub s15, s0, s0"}, + {10, {31, 0, 0, 0}, 0x1e20381fu, "fsub s31, s0, s0"}, + {10, {0, 1, 0, 0}, 0x1e203820u, "fsub s0, s1, s0"}, + {10, {0, 7, 0, 0}, 0x1e2038e0u, "fsub s0, s7, s0"}, + {10, {0, 15, 0, 0}, 0x1e2039e0u, "fsub s0, s15, s0"}, + {10, {0, 31, 0, 0}, 0x1e203be0u, "fsub s0, s31, s0"}, + {10, {0, 0, 1, 0}, 0x1e213800u, "fsub s0, s0, s1"}, + {10, {0, 0, 7, 0}, 0x1e273800u, "fsub s0, s0, s7"}, + {10, {0, 0, 15, 0}, 0x1e2f3800u, "fsub s0, s0, s15"}, + {10, {0, 0, 31, 0}, 0x1e3f3800u, "fsub s0, s0, s31"}, + {10, {15, 0, 7, 0}, 0x1e27380fu, "fsub s15, s0, s7"}, + {10, {0, 15, 1, 0}, 0x1e2139e0u, "fsub s0, s15, s1"}, + {10, {7, 1, 0, 0}, 0x1e203827u, "fsub s7, s1, s0"}, + {10, {31, 31, 31, 0}, 0x1e3f3bffu, "fsub s31, s31, s31"}, + {11, {0, 0, 0, 0}, 0x1e603800u, "fsub d0, d0, d0"}, + {11, {1, 0, 0, 0}, 0x1e603801u, "fsub d1, d0, d0"}, + {11, {7, 0, 0, 0}, 0x1e603807u, "fsub d7, d0, d0"}, + {11, {15, 0, 0, 0}, 0x1e60380fu, "fsub d15, d0, d0"}, + {11, {31, 0, 0, 0}, 0x1e60381fu, "fsub d31, d0, d0"}, + {11, {0, 1, 0, 0}, 0x1e603820u, "fsub d0, d1, d0"}, + {11, {0, 7, 0, 0}, 0x1e6038e0u, "fsub d0, d7, d0"}, + {11, {0, 15, 0, 0}, 0x1e6039e0u, "fsub d0, d15, d0"}, + {11, {0, 31, 0, 0}, 0x1e603be0u, "fsub d0, d31, d0"}, + {11, {0, 0, 1, 0}, 0x1e613800u, "fsub d0, d0, d1"}, + {11, {0, 0, 7, 0}, 0x1e673800u, "fsub d0, d0, d7"}, + {11, {0, 0, 15, 0}, 0x1e6f3800u, "fsub d0, d0, d15"}, + {11, {0, 0, 31, 0}, 0x1e7f3800u, "fsub d0, d0, d31"}, + {11, {15, 0, 7, 0}, 0x1e67380fu, "fsub d15, d0, d7"}, + {11, {0, 15, 1, 0}, 0x1e6139e0u, "fsub d0, d15, d1"}, + {11, {7, 1, 0, 0}, 0x1e603827u, "fsub d7, d1, d0"}, + {11, {31, 31, 31, 0}, 0x1e7f3bffu, "fsub d31, d31, d31"}, + {12, {0, 0, 0, 0}, 0x1e200800u, "fmul s0, s0, s0"}, + {12, {1, 0, 0, 0}, 0x1e200801u, "fmul s1, s0, s0"}, + {12, {7, 0, 0, 0}, 0x1e200807u, "fmul s7, s0, s0"}, + {12, {15, 0, 0, 0}, 0x1e20080fu, "fmul s15, s0, s0"}, + {12, {31, 0, 0, 0}, 0x1e20081fu, "fmul s31, s0, s0"}, + {12, {0, 1, 0, 0}, 0x1e200820u, "fmul s0, s1, s0"}, + {12, {0, 7, 0, 0}, 0x1e2008e0u, "fmul s0, s7, s0"}, + {12, {0, 15, 0, 0}, 0x1e2009e0u, "fmul s0, s15, s0"}, + {12, {0, 31, 0, 0}, 0x1e200be0u, "fmul s0, s31, s0"}, + {12, {0, 0, 1, 0}, 0x1e210800u, "fmul s0, s0, s1"}, + {12, {0, 0, 7, 0}, 0x1e270800u, "fmul s0, s0, s7"}, + {12, {0, 0, 15, 0}, 0x1e2f0800u, "fmul s0, s0, s15"}, + {12, {0, 0, 31, 0}, 0x1e3f0800u, "fmul s0, s0, s31"}, + {12, {15, 0, 7, 0}, 0x1e27080fu, "fmul s15, s0, s7"}, + {12, {0, 15, 1, 0}, 0x1e2109e0u, "fmul s0, s15, s1"}, + {12, {7, 1, 0, 0}, 0x1e200827u, "fmul s7, s1, s0"}, + {12, {31, 31, 31, 0}, 0x1e3f0bffu, "fmul s31, s31, s31"}, + {13, {0, 0, 0, 0}, 0x1e600800u, "fmul d0, d0, d0"}, + {13, {1, 0, 0, 0}, 0x1e600801u, "fmul d1, d0, d0"}, + {13, {7, 0, 0, 0}, 0x1e600807u, "fmul d7, d0, d0"}, + {13, {15, 0, 0, 0}, 0x1e60080fu, "fmul d15, d0, d0"}, + {13, {31, 0, 0, 0}, 0x1e60081fu, "fmul d31, d0, d0"}, + {13, {0, 1, 0, 0}, 0x1e600820u, "fmul d0, d1, d0"}, + {13, {0, 7, 0, 0}, 0x1e6008e0u, "fmul d0, d7, d0"}, + {13, {0, 15, 0, 0}, 0x1e6009e0u, "fmul d0, d15, d0"}, + {13, {0, 31, 0, 0}, 0x1e600be0u, "fmul d0, d31, d0"}, + {13, {0, 0, 1, 0}, 0x1e610800u, "fmul d0, d0, d1"}, + {13, {0, 0, 7, 0}, 0x1e670800u, "fmul d0, d0, d7"}, + {13, {0, 0, 15, 0}, 0x1e6f0800u, "fmul d0, d0, d15"}, + {13, {0, 0, 31, 0}, 0x1e7f0800u, "fmul d0, d0, d31"}, + {13, {15, 0, 7, 0}, 0x1e67080fu, "fmul d15, d0, d7"}, + {13, {0, 15, 1, 0}, 0x1e6109e0u, "fmul d0, d15, d1"}, + {13, {7, 1, 0, 0}, 0x1e600827u, "fmul d7, d1, d0"}, + {13, {31, 31, 31, 0}, 0x1e7f0bffu, "fmul d31, d31, d31"}, + {14, {0, 0, 0, 0}, 0x1e201800u, "fdiv s0, s0, s0"}, + {14, {1, 0, 0, 0}, 0x1e201801u, "fdiv s1, s0, s0"}, + {14, {7, 0, 0, 0}, 0x1e201807u, "fdiv s7, s0, s0"}, + {14, {15, 0, 0, 0}, 0x1e20180fu, "fdiv s15, s0, s0"}, + {14, {31, 0, 0, 0}, 0x1e20181fu, "fdiv s31, s0, s0"}, + {14, {0, 1, 0, 0}, 0x1e201820u, "fdiv s0, s1, s0"}, + {14, {0, 7, 0, 0}, 0x1e2018e0u, "fdiv s0, s7, s0"}, + {14, {0, 15, 0, 0}, 0x1e2019e0u, "fdiv s0, s15, s0"}, + {14, {0, 31, 0, 0}, 0x1e201be0u, "fdiv s0, s31, s0"}, + {14, {0, 0, 1, 0}, 0x1e211800u, "fdiv s0, s0, s1"}, + {14, {0, 0, 7, 0}, 0x1e271800u, "fdiv s0, s0, s7"}, + {14, {0, 0, 15, 0}, 0x1e2f1800u, "fdiv s0, s0, s15"}, + {14, {0, 0, 31, 0}, 0x1e3f1800u, "fdiv s0, s0, s31"}, + {14, {15, 0, 7, 0}, 0x1e27180fu, "fdiv s15, s0, s7"}, + {14, {0, 15, 1, 0}, 0x1e2119e0u, "fdiv s0, s15, s1"}, + {14, {7, 1, 0, 0}, 0x1e201827u, "fdiv s7, s1, s0"}, + {14, {31, 31, 31, 0}, 0x1e3f1bffu, "fdiv s31, s31, s31"}, + {15, {0, 0, 0, 0}, 0x1e601800u, "fdiv d0, d0, d0"}, + {15, {1, 0, 0, 0}, 0x1e601801u, "fdiv d1, d0, d0"}, + {15, {7, 0, 0, 0}, 0x1e601807u, "fdiv d7, d0, d0"}, + {15, {15, 0, 0, 0}, 0x1e60180fu, "fdiv d15, d0, d0"}, + {15, {31, 0, 0, 0}, 0x1e60181fu, "fdiv d31, d0, d0"}, + {15, {0, 1, 0, 0}, 0x1e601820u, "fdiv d0, d1, d0"}, + {15, {0, 7, 0, 0}, 0x1e6018e0u, "fdiv d0, d7, d0"}, + {15, {0, 15, 0, 0}, 0x1e6019e0u, "fdiv d0, d15, d0"}, + {15, {0, 31, 0, 0}, 0x1e601be0u, "fdiv d0, d31, d0"}, + {15, {0, 0, 1, 0}, 0x1e611800u, "fdiv d0, d0, d1"}, + {15, {0, 0, 7, 0}, 0x1e671800u, "fdiv d0, d0, d7"}, + {15, {0, 0, 15, 0}, 0x1e6f1800u, "fdiv d0, d0, d15"}, + {15, {0, 0, 31, 0}, 0x1e7f1800u, "fdiv d0, d0, d31"}, + {15, {15, 0, 7, 0}, 0x1e67180fu, "fdiv d15, d0, d7"}, + {15, {0, 15, 1, 0}, 0x1e6119e0u, "fdiv d0, d15, d1"}, + {15, {7, 1, 0, 0}, 0x1e601827u, "fdiv d7, d1, d0"}, + {15, {31, 31, 31, 0}, 0x1e7f1bffu, "fdiv d31, d31, d31"}, + {16, {0, 0, 0, 0}, 0x1e205800u, "fmin s0, s0, s0"}, + {16, {1, 0, 0, 0}, 0x1e205801u, "fmin s1, s0, s0"}, + {16, {7, 0, 0, 0}, 0x1e205807u, "fmin s7, s0, s0"}, + {16, {15, 0, 0, 0}, 0x1e20580fu, "fmin s15, s0, s0"}, + {16, {31, 0, 0, 0}, 0x1e20581fu, "fmin s31, s0, s0"}, + {16, {0, 1, 0, 0}, 0x1e205820u, "fmin s0, s1, s0"}, + {16, {0, 7, 0, 0}, 0x1e2058e0u, "fmin s0, s7, s0"}, + {16, {0, 15, 0, 0}, 0x1e2059e0u, "fmin s0, s15, s0"}, + {16, {0, 31, 0, 0}, 0x1e205be0u, "fmin s0, s31, s0"}, + {16, {0, 0, 1, 0}, 0x1e215800u, "fmin s0, s0, s1"}, + {16, {0, 0, 7, 0}, 0x1e275800u, "fmin s0, s0, s7"}, + {16, {0, 0, 15, 0}, 0x1e2f5800u, "fmin s0, s0, s15"}, + {16, {0, 0, 31, 0}, 0x1e3f5800u, "fmin s0, s0, s31"}, + {16, {15, 0, 7, 0}, 0x1e27580fu, "fmin s15, s0, s7"}, + {16, {0, 15, 1, 0}, 0x1e2159e0u, "fmin s0, s15, s1"}, + {16, {7, 1, 0, 0}, 0x1e205827u, "fmin s7, s1, s0"}, + {16, {31, 31, 31, 0}, 0x1e3f5bffu, "fmin s31, s31, s31"}, + {17, {0, 0, 0, 0}, 0x1e605800u, "fmin d0, d0, d0"}, + {17, {1, 0, 0, 0}, 0x1e605801u, "fmin d1, d0, d0"}, + {17, {7, 0, 0, 0}, 0x1e605807u, "fmin d7, d0, d0"}, + {17, {15, 0, 0, 0}, 0x1e60580fu, "fmin d15, d0, d0"}, + {17, {31, 0, 0, 0}, 0x1e60581fu, "fmin d31, d0, d0"}, + {17, {0, 1, 0, 0}, 0x1e605820u, "fmin d0, d1, d0"}, + {17, {0, 7, 0, 0}, 0x1e6058e0u, "fmin d0, d7, d0"}, + {17, {0, 15, 0, 0}, 0x1e6059e0u, "fmin d0, d15, d0"}, + {17, {0, 31, 0, 0}, 0x1e605be0u, "fmin d0, d31, d0"}, + {17, {0, 0, 1, 0}, 0x1e615800u, "fmin d0, d0, d1"}, + {17, {0, 0, 7, 0}, 0x1e675800u, "fmin d0, d0, d7"}, + {17, {0, 0, 15, 0}, 0x1e6f5800u, "fmin d0, d0, d15"}, + {17, {0, 0, 31, 0}, 0x1e7f5800u, "fmin d0, d0, d31"}, + {17, {15, 0, 7, 0}, 0x1e67580fu, "fmin d15, d0, d7"}, + {17, {0, 15, 1, 0}, 0x1e6159e0u, "fmin d0, d15, d1"}, + {17, {7, 1, 0, 0}, 0x1e605827u, "fmin d7, d1, d0"}, + {17, {31, 31, 31, 0}, 0x1e7f5bffu, "fmin d31, d31, d31"}, + {18, {0, 0, 0, 0}, 0x1e204800u, "fmax s0, s0, s0"}, + {18, {1, 0, 0, 0}, 0x1e204801u, "fmax s1, s0, s0"}, + {18, {7, 0, 0, 0}, 0x1e204807u, "fmax s7, s0, s0"}, + {18, {15, 0, 0, 0}, 0x1e20480fu, "fmax s15, s0, s0"}, + {18, {31, 0, 0, 0}, 0x1e20481fu, "fmax s31, s0, s0"}, + {18, {0, 1, 0, 0}, 0x1e204820u, "fmax s0, s1, s0"}, + {18, {0, 7, 0, 0}, 0x1e2048e0u, "fmax s0, s7, s0"}, + {18, {0, 15, 0, 0}, 0x1e2049e0u, "fmax s0, s15, s0"}, + {18, {0, 31, 0, 0}, 0x1e204be0u, "fmax s0, s31, s0"}, + {18, {0, 0, 1, 0}, 0x1e214800u, "fmax s0, s0, s1"}, + {18, {0, 0, 7, 0}, 0x1e274800u, "fmax s0, s0, s7"}, + {18, {0, 0, 15, 0}, 0x1e2f4800u, "fmax s0, s0, s15"}, + {18, {0, 0, 31, 0}, 0x1e3f4800u, "fmax s0, s0, s31"}, + {18, {15, 0, 7, 0}, 0x1e27480fu, "fmax s15, s0, s7"}, + {18, {0, 15, 1, 0}, 0x1e2149e0u, "fmax s0, s15, s1"}, + {18, {7, 1, 0, 0}, 0x1e204827u, "fmax s7, s1, s0"}, + {18, {31, 31, 31, 0}, 0x1e3f4bffu, "fmax s31, s31, s31"}, + {19, {0, 0, 0, 0}, 0x1e604800u, "fmax d0, d0, d0"}, + {19, {1, 0, 0, 0}, 0x1e604801u, "fmax d1, d0, d0"}, + {19, {7, 0, 0, 0}, 0x1e604807u, "fmax d7, d0, d0"}, + {19, {15, 0, 0, 0}, 0x1e60480fu, "fmax d15, d0, d0"}, + {19, {31, 0, 0, 0}, 0x1e60481fu, "fmax d31, d0, d0"}, + {19, {0, 1, 0, 0}, 0x1e604820u, "fmax d0, d1, d0"}, + {19, {0, 7, 0, 0}, 0x1e6048e0u, "fmax d0, d7, d0"}, + {19, {0, 15, 0, 0}, 0x1e6049e0u, "fmax d0, d15, d0"}, + {19, {0, 31, 0, 0}, 0x1e604be0u, "fmax d0, d31, d0"}, + {19, {0, 0, 1, 0}, 0x1e614800u, "fmax d0, d0, d1"}, + {19, {0, 0, 7, 0}, 0x1e674800u, "fmax d0, d0, d7"}, + {19, {0, 0, 15, 0}, 0x1e6f4800u, "fmax d0, d0, d15"}, + {19, {0, 0, 31, 0}, 0x1e7f4800u, "fmax d0, d0, d31"}, + {19, {15, 0, 7, 0}, 0x1e67480fu, "fmax d15, d0, d7"}, + {19, {0, 15, 1, 0}, 0x1e6149e0u, "fmax d0, d15, d1"}, + {19, {7, 1, 0, 0}, 0x1e604827u, "fmax d7, d1, d0"}, + {19, {31, 31, 31, 0}, 0x1e7f4bffu, "fmax d31, d31, d31"}, + {20, {0, 0, 0, 0}, 0x1e207800u, "fminnm s0, s0, s0"}, + {20, {1, 0, 0, 0}, 0x1e207801u, "fminnm s1, s0, s0"}, + {20, {7, 0, 0, 0}, 0x1e207807u, "fminnm s7, s0, s0"}, + {20, {15, 0, 0, 0}, 0x1e20780fu, "fminnm s15, s0, s0"}, + {20, {31, 0, 0, 0}, 0x1e20781fu, "fminnm s31, s0, s0"}, + {20, {0, 1, 0, 0}, 0x1e207820u, "fminnm s0, s1, s0"}, + {20, {0, 7, 0, 0}, 0x1e2078e0u, "fminnm s0, s7, s0"}, + {20, {0, 15, 0, 0}, 0x1e2079e0u, "fminnm s0, s15, s0"}, + {20, {0, 31, 0, 0}, 0x1e207be0u, "fminnm s0, s31, s0"}, + {20, {0, 0, 1, 0}, 0x1e217800u, "fminnm s0, s0, s1"}, + {20, {0, 0, 7, 0}, 0x1e277800u, "fminnm s0, s0, s7"}, + {20, {0, 0, 15, 0}, 0x1e2f7800u, "fminnm s0, s0, s15"}, + {20, {0, 0, 31, 0}, 0x1e3f7800u, "fminnm s0, s0, s31"}, + {20, {15, 0, 7, 0}, 0x1e27780fu, "fminnm s15, s0, s7"}, + {20, {0, 15, 1, 0}, 0x1e2179e0u, "fminnm s0, s15, s1"}, + {20, {7, 1, 0, 0}, 0x1e207827u, "fminnm s7, s1, s0"}, + {20, {31, 31, 31, 0}, 0x1e3f7bffu, "fminnm s31, s31, s31"}, + {21, {0, 0, 0, 0}, 0x1e607800u, "fminnm d0, d0, d0"}, + {21, {1, 0, 0, 0}, 0x1e607801u, "fminnm d1, d0, d0"}, + {21, {7, 0, 0, 0}, 0x1e607807u, "fminnm d7, d0, d0"}, + {21, {15, 0, 0, 0}, 0x1e60780fu, "fminnm d15, d0, d0"}, + {21, {31, 0, 0, 0}, 0x1e60781fu, "fminnm d31, d0, d0"}, + {21, {0, 1, 0, 0}, 0x1e607820u, "fminnm d0, d1, d0"}, + {21, {0, 7, 0, 0}, 0x1e6078e0u, "fminnm d0, d7, d0"}, + {21, {0, 15, 0, 0}, 0x1e6079e0u, "fminnm d0, d15, d0"}, + {21, {0, 31, 0, 0}, 0x1e607be0u, "fminnm d0, d31, d0"}, + {21, {0, 0, 1, 0}, 0x1e617800u, "fminnm d0, d0, d1"}, + {21, {0, 0, 7, 0}, 0x1e677800u, "fminnm d0, d0, d7"}, + {21, {0, 0, 15, 0}, 0x1e6f7800u, "fminnm d0, d0, d15"}, + {21, {0, 0, 31, 0}, 0x1e7f7800u, "fminnm d0, d0, d31"}, + {21, {15, 0, 7, 0}, 0x1e67780fu, "fminnm d15, d0, d7"}, + {21, {0, 15, 1, 0}, 0x1e6179e0u, "fminnm d0, d15, d1"}, + {21, {7, 1, 0, 0}, 0x1e607827u, "fminnm d7, d1, d0"}, + {21, {31, 31, 31, 0}, 0x1e7f7bffu, "fminnm d31, d31, d31"}, + {22, {0, 0, 0, 0}, 0x1e206800u, "fmaxnm s0, s0, s0"}, + {22, {1, 0, 0, 0}, 0x1e206801u, "fmaxnm s1, s0, s0"}, + {22, {7, 0, 0, 0}, 0x1e206807u, "fmaxnm s7, s0, s0"}, + {22, {15, 0, 0, 0}, 0x1e20680fu, "fmaxnm s15, s0, s0"}, + {22, {31, 0, 0, 0}, 0x1e20681fu, "fmaxnm s31, s0, s0"}, + {22, {0, 1, 0, 0}, 0x1e206820u, "fmaxnm s0, s1, s0"}, + {22, {0, 7, 0, 0}, 0x1e2068e0u, "fmaxnm s0, s7, s0"}, + {22, {0, 15, 0, 0}, 0x1e2069e0u, "fmaxnm s0, s15, s0"}, + {22, {0, 31, 0, 0}, 0x1e206be0u, "fmaxnm s0, s31, s0"}, + {22, {0, 0, 1, 0}, 0x1e216800u, "fmaxnm s0, s0, s1"}, + {22, {0, 0, 7, 0}, 0x1e276800u, "fmaxnm s0, s0, s7"}, + {22, {0, 0, 15, 0}, 0x1e2f6800u, "fmaxnm s0, s0, s15"}, + {22, {0, 0, 31, 0}, 0x1e3f6800u, "fmaxnm s0, s0, s31"}, + {22, {15, 0, 7, 0}, 0x1e27680fu, "fmaxnm s15, s0, s7"}, + {22, {0, 15, 1, 0}, 0x1e2169e0u, "fmaxnm s0, s15, s1"}, + {22, {7, 1, 0, 0}, 0x1e206827u, "fmaxnm s7, s1, s0"}, + {22, {31, 31, 31, 0}, 0x1e3f6bffu, "fmaxnm s31, s31, s31"}, + {23, {0, 0, 0, 0}, 0x1e606800u, "fmaxnm d0, d0, d0"}, + {23, {1, 0, 0, 0}, 0x1e606801u, "fmaxnm d1, d0, d0"}, + {23, {7, 0, 0, 0}, 0x1e606807u, "fmaxnm d7, d0, d0"}, + {23, {15, 0, 0, 0}, 0x1e60680fu, "fmaxnm d15, d0, d0"}, + {23, {31, 0, 0, 0}, 0x1e60681fu, "fmaxnm d31, d0, d0"}, + {23, {0, 1, 0, 0}, 0x1e606820u, "fmaxnm d0, d1, d0"}, + {23, {0, 7, 0, 0}, 0x1e6068e0u, "fmaxnm d0, d7, d0"}, + {23, {0, 15, 0, 0}, 0x1e6069e0u, "fmaxnm d0, d15, d0"}, + {23, {0, 31, 0, 0}, 0x1e606be0u, "fmaxnm d0, d31, d0"}, + {23, {0, 0, 1, 0}, 0x1e616800u, "fmaxnm d0, d0, d1"}, + {23, {0, 0, 7, 0}, 0x1e676800u, "fmaxnm d0, d0, d7"}, + {23, {0, 0, 15, 0}, 0x1e6f6800u, "fmaxnm d0, d0, d15"}, + {23, {0, 0, 31, 0}, 0x1e7f6800u, "fmaxnm d0, d0, d31"}, + {23, {15, 0, 7, 0}, 0x1e67680fu, "fmaxnm d15, d0, d7"}, + {23, {0, 15, 1, 0}, 0x1e6169e0u, "fmaxnm d0, d15, d1"}, + {23, {7, 1, 0, 0}, 0x1e606827u, "fmaxnm d7, d1, d0"}, + {23, {31, 31, 31, 0}, 0x1e7f6bffu, "fmaxnm d31, d31, d31"}, + {24, {0, 0, 0, 0}, 0x1e21c000u, "fsqrt s0, s0"}, + {24, {1, 0, 0, 0}, 0x1e21c001u, "fsqrt s1, s0"}, + {24, {7, 0, 0, 0}, 0x1e21c007u, "fsqrt s7, s0"}, + {24, {15, 0, 0, 0}, 0x1e21c00fu, "fsqrt s15, s0"}, + {24, {31, 0, 0, 0}, 0x1e21c01fu, "fsqrt s31, s0"}, + {24, {0, 1, 0, 0}, 0x1e21c020u, "fsqrt s0, s1"}, + {24, {0, 7, 0, 0}, 0x1e21c0e0u, "fsqrt s0, s7"}, + {24, {0, 15, 0, 0}, 0x1e21c1e0u, "fsqrt s0, s15"}, + {24, {0, 31, 0, 0}, 0x1e21c3e0u, "fsqrt s0, s31"}, + {24, {15, 0, 0, 0}, 0x1e21c00fu, "fsqrt s15, s0"}, + {24, {0, 15, 0, 0}, 0x1e21c1e0u, "fsqrt s0, s15"}, + {24, {7, 1, 0, 0}, 0x1e21c027u, "fsqrt s7, s1"}, + {24, {31, 31, 0, 0}, 0x1e21c3ffu, "fsqrt s31, s31"}, + {25, {0, 0, 0, 0}, 0x1e61c000u, "fsqrt d0, d0"}, + {25, {1, 0, 0, 0}, 0x1e61c001u, "fsqrt d1, d0"}, + {25, {7, 0, 0, 0}, 0x1e61c007u, "fsqrt d7, d0"}, + {25, {15, 0, 0, 0}, 0x1e61c00fu, "fsqrt d15, d0"}, + {25, {31, 0, 0, 0}, 0x1e61c01fu, "fsqrt d31, d0"}, + {25, {0, 1, 0, 0}, 0x1e61c020u, "fsqrt d0, d1"}, + {25, {0, 7, 0, 0}, 0x1e61c0e0u, "fsqrt d0, d7"}, + {25, {0, 15, 0, 0}, 0x1e61c1e0u, "fsqrt d0, d15"}, + {25, {0, 31, 0, 0}, 0x1e61c3e0u, "fsqrt d0, d31"}, + {25, {15, 0, 0, 0}, 0x1e61c00fu, "fsqrt d15, d0"}, + {25, {0, 15, 0, 0}, 0x1e61c1e0u, "fsqrt d0, d15"}, + {25, {7, 1, 0, 0}, 0x1e61c027u, "fsqrt d7, d1"}, + {25, {31, 31, 0, 0}, 0x1e61c3ffu, "fsqrt d31, d31"}, + {26, {0, 0, 0, 0}, 0x1e214000u, "fneg s0, s0"}, + {26, {1, 0, 0, 0}, 0x1e214001u, "fneg s1, s0"}, + {26, {7, 0, 0, 0}, 0x1e214007u, "fneg s7, s0"}, + {26, {15, 0, 0, 0}, 0x1e21400fu, "fneg s15, s0"}, + {26, {31, 0, 0, 0}, 0x1e21401fu, "fneg s31, s0"}, + {26, {0, 1, 0, 0}, 0x1e214020u, "fneg s0, s1"}, + {26, {0, 7, 0, 0}, 0x1e2140e0u, "fneg s0, s7"}, + {26, {0, 15, 0, 0}, 0x1e2141e0u, "fneg s0, s15"}, + {26, {0, 31, 0, 0}, 0x1e2143e0u, "fneg s0, s31"}, + {26, {15, 0, 0, 0}, 0x1e21400fu, "fneg s15, s0"}, + {26, {0, 15, 0, 0}, 0x1e2141e0u, "fneg s0, s15"}, + {26, {7, 1, 0, 0}, 0x1e214027u, "fneg s7, s1"}, + {26, {31, 31, 0, 0}, 0x1e2143ffu, "fneg s31, s31"}, + {27, {0, 0, 0, 0}, 0x1e614000u, "fneg d0, d0"}, + {27, {1, 0, 0, 0}, 0x1e614001u, "fneg d1, d0"}, + {27, {7, 0, 0, 0}, 0x1e614007u, "fneg d7, d0"}, + {27, {15, 0, 0, 0}, 0x1e61400fu, "fneg d15, d0"}, + {27, {31, 0, 0, 0}, 0x1e61401fu, "fneg d31, d0"}, + {27, {0, 1, 0, 0}, 0x1e614020u, "fneg d0, d1"}, + {27, {0, 7, 0, 0}, 0x1e6140e0u, "fneg d0, d7"}, + {27, {0, 15, 0, 0}, 0x1e6141e0u, "fneg d0, d15"}, + {27, {0, 31, 0, 0}, 0x1e6143e0u, "fneg d0, d31"}, + {27, {15, 0, 0, 0}, 0x1e61400fu, "fneg d15, d0"}, + {27, {0, 15, 0, 0}, 0x1e6141e0u, "fneg d0, d15"}, + {27, {7, 1, 0, 0}, 0x1e614027u, "fneg d7, d1"}, + {27, {31, 31, 0, 0}, 0x1e6143ffu, "fneg d31, d31"}, + {28, {0, 0, 0, 0}, 0x1e20c000u, "fabs s0, s0"}, + {28, {1, 0, 0, 0}, 0x1e20c001u, "fabs s1, s0"}, + {28, {7, 0, 0, 0}, 0x1e20c007u, "fabs s7, s0"}, + {28, {15, 0, 0, 0}, 0x1e20c00fu, "fabs s15, s0"}, + {28, {31, 0, 0, 0}, 0x1e20c01fu, "fabs s31, s0"}, + {28, {0, 1, 0, 0}, 0x1e20c020u, "fabs s0, s1"}, + {28, {0, 7, 0, 0}, 0x1e20c0e0u, "fabs s0, s7"}, + {28, {0, 15, 0, 0}, 0x1e20c1e0u, "fabs s0, s15"}, + {28, {0, 31, 0, 0}, 0x1e20c3e0u, "fabs s0, s31"}, + {28, {15, 0, 0, 0}, 0x1e20c00fu, "fabs s15, s0"}, + {28, {0, 15, 0, 0}, 0x1e20c1e0u, "fabs s0, s15"}, + {28, {7, 1, 0, 0}, 0x1e20c027u, "fabs s7, s1"}, + {28, {31, 31, 0, 0}, 0x1e20c3ffu, "fabs s31, s31"}, + {29, {0, 0, 0, 0}, 0x1e60c000u, "fabs d0, d0"}, + {29, {1, 0, 0, 0}, 0x1e60c001u, "fabs d1, d0"}, + {29, {7, 0, 0, 0}, 0x1e60c007u, "fabs d7, d0"}, + {29, {15, 0, 0, 0}, 0x1e60c00fu, "fabs d15, d0"}, + {29, {31, 0, 0, 0}, 0x1e60c01fu, "fabs d31, d0"}, + {29, {0, 1, 0, 0}, 0x1e60c020u, "fabs d0, d1"}, + {29, {0, 7, 0, 0}, 0x1e60c0e0u, "fabs d0, d7"}, + {29, {0, 15, 0, 0}, 0x1e60c1e0u, "fabs d0, d15"}, + {29, {0, 31, 0, 0}, 0x1e60c3e0u, "fabs d0, d31"}, + {29, {15, 0, 0, 0}, 0x1e60c00fu, "fabs d15, d0"}, + {29, {0, 15, 0, 0}, 0x1e60c1e0u, "fabs d0, d15"}, + {29, {7, 1, 0, 0}, 0x1e60c027u, "fabs d7, d1"}, + {29, {31, 31, 0, 0}, 0x1e60c3ffu, "fabs d31, d31"}, + {30, {0, 0, 0, 0}, 0x1e244000u, "frintn s0, s0"}, + {30, {1, 0, 0, 0}, 0x1e244001u, "frintn s1, s0"}, + {30, {7, 0, 0, 0}, 0x1e244007u, "frintn s7, s0"}, + {30, {15, 0, 0, 0}, 0x1e24400fu, "frintn s15, s0"}, + {30, {31, 0, 0, 0}, 0x1e24401fu, "frintn s31, s0"}, + {30, {0, 1, 0, 0}, 0x1e244020u, "frintn s0, s1"}, + {30, {0, 7, 0, 0}, 0x1e2440e0u, "frintn s0, s7"}, + {30, {0, 15, 0, 0}, 0x1e2441e0u, "frintn s0, s15"}, + {30, {0, 31, 0, 0}, 0x1e2443e0u, "frintn s0, s31"}, + {30, {15, 0, 0, 0}, 0x1e24400fu, "frintn s15, s0"}, + {30, {0, 15, 0, 0}, 0x1e2441e0u, "frintn s0, s15"}, + {30, {7, 1, 0, 0}, 0x1e244027u, "frintn s7, s1"}, + {30, {31, 31, 0, 0}, 0x1e2443ffu, "frintn s31, s31"}, + {31, {0, 0, 0, 0}, 0x1e644000u, "frintn d0, d0"}, + {31, {1, 0, 0, 0}, 0x1e644001u, "frintn d1, d0"}, + {31, {7, 0, 0, 0}, 0x1e644007u, "frintn d7, d0"}, + {31, {15, 0, 0, 0}, 0x1e64400fu, "frintn d15, d0"}, + {31, {31, 0, 0, 0}, 0x1e64401fu, "frintn d31, d0"}, + {31, {0, 1, 0, 0}, 0x1e644020u, "frintn d0, d1"}, + {31, {0, 7, 0, 0}, 0x1e6440e0u, "frintn d0, d7"}, + {31, {0, 15, 0, 0}, 0x1e6441e0u, "frintn d0, d15"}, + {31, {0, 31, 0, 0}, 0x1e6443e0u, "frintn d0, d31"}, + {31, {15, 0, 0, 0}, 0x1e64400fu, "frintn d15, d0"}, + {31, {0, 15, 0, 0}, 0x1e6441e0u, "frintn d0, d15"}, + {31, {7, 1, 0, 0}, 0x1e644027u, "frintn d7, d1"}, + {31, {31, 31, 0, 0}, 0x1e6443ffu, "frintn d31, d31"}, + {32, {0, 0, 0, 0}, 0x1e254000u, "frintm s0, s0"}, + {32, {1, 0, 0, 0}, 0x1e254001u, "frintm s1, s0"}, + {32, {7, 0, 0, 0}, 0x1e254007u, "frintm s7, s0"}, + {32, {15, 0, 0, 0}, 0x1e25400fu, "frintm s15, s0"}, + {32, {31, 0, 0, 0}, 0x1e25401fu, "frintm s31, s0"}, + {32, {0, 1, 0, 0}, 0x1e254020u, "frintm s0, s1"}, + {32, {0, 7, 0, 0}, 0x1e2540e0u, "frintm s0, s7"}, + {32, {0, 15, 0, 0}, 0x1e2541e0u, "frintm s0, s15"}, + {32, {0, 31, 0, 0}, 0x1e2543e0u, "frintm s0, s31"}, + {32, {15, 0, 0, 0}, 0x1e25400fu, "frintm s15, s0"}, + {32, {0, 15, 0, 0}, 0x1e2541e0u, "frintm s0, s15"}, + {32, {7, 1, 0, 0}, 0x1e254027u, "frintm s7, s1"}, + {32, {31, 31, 0, 0}, 0x1e2543ffu, "frintm s31, s31"}, + {33, {0, 0, 0, 0}, 0x1e654000u, "frintm d0, d0"}, + {33, {1, 0, 0, 0}, 0x1e654001u, "frintm d1, d0"}, + {33, {7, 0, 0, 0}, 0x1e654007u, "frintm d7, d0"}, + {33, {15, 0, 0, 0}, 0x1e65400fu, "frintm d15, d0"}, + {33, {31, 0, 0, 0}, 0x1e65401fu, "frintm d31, d0"}, + {33, {0, 1, 0, 0}, 0x1e654020u, "frintm d0, d1"}, + {33, {0, 7, 0, 0}, 0x1e6540e0u, "frintm d0, d7"}, + {33, {0, 15, 0, 0}, 0x1e6541e0u, "frintm d0, d15"}, + {33, {0, 31, 0, 0}, 0x1e6543e0u, "frintm d0, d31"}, + {33, {15, 0, 0, 0}, 0x1e65400fu, "frintm d15, d0"}, + {33, {0, 15, 0, 0}, 0x1e6541e0u, "frintm d0, d15"}, + {33, {7, 1, 0, 0}, 0x1e654027u, "frintm d7, d1"}, + {33, {31, 31, 0, 0}, 0x1e6543ffu, "frintm d31, d31"}, + {34, {0, 0, 0, 0}, 0x1e24c000u, "frintp s0, s0"}, + {34, {1, 0, 0, 0}, 0x1e24c001u, "frintp s1, s0"}, + {34, {7, 0, 0, 0}, 0x1e24c007u, "frintp s7, s0"}, + {34, {15, 0, 0, 0}, 0x1e24c00fu, "frintp s15, s0"}, + {34, {31, 0, 0, 0}, 0x1e24c01fu, "frintp s31, s0"}, + {34, {0, 1, 0, 0}, 0x1e24c020u, "frintp s0, s1"}, + {34, {0, 7, 0, 0}, 0x1e24c0e0u, "frintp s0, s7"}, + {34, {0, 15, 0, 0}, 0x1e24c1e0u, "frintp s0, s15"}, + {34, {0, 31, 0, 0}, 0x1e24c3e0u, "frintp s0, s31"}, + {34, {15, 0, 0, 0}, 0x1e24c00fu, "frintp s15, s0"}, + {34, {0, 15, 0, 0}, 0x1e24c1e0u, "frintp s0, s15"}, + {34, {7, 1, 0, 0}, 0x1e24c027u, "frintp s7, s1"}, + {34, {31, 31, 0, 0}, 0x1e24c3ffu, "frintp s31, s31"}, + {35, {0, 0, 0, 0}, 0x1e64c000u, "frintp d0, d0"}, + {35, {1, 0, 0, 0}, 0x1e64c001u, "frintp d1, d0"}, + {35, {7, 0, 0, 0}, 0x1e64c007u, "frintp d7, d0"}, + {35, {15, 0, 0, 0}, 0x1e64c00fu, "frintp d15, d0"}, + {35, {31, 0, 0, 0}, 0x1e64c01fu, "frintp d31, d0"}, + {35, {0, 1, 0, 0}, 0x1e64c020u, "frintp d0, d1"}, + {35, {0, 7, 0, 0}, 0x1e64c0e0u, "frintp d0, d7"}, + {35, {0, 15, 0, 0}, 0x1e64c1e0u, "frintp d0, d15"}, + {35, {0, 31, 0, 0}, 0x1e64c3e0u, "frintp d0, d31"}, + {35, {15, 0, 0, 0}, 0x1e64c00fu, "frintp d15, d0"}, + {35, {0, 15, 0, 0}, 0x1e64c1e0u, "frintp d0, d15"}, + {35, {7, 1, 0, 0}, 0x1e64c027u, "frintp d7, d1"}, + {35, {31, 31, 0, 0}, 0x1e64c3ffu, "frintp d31, d31"}, + {36, {0, 0, 0, 0}, 0x1e25c000u, "frintz s0, s0"}, + {36, {1, 0, 0, 0}, 0x1e25c001u, "frintz s1, s0"}, + {36, {7, 0, 0, 0}, 0x1e25c007u, "frintz s7, s0"}, + {36, {15, 0, 0, 0}, 0x1e25c00fu, "frintz s15, s0"}, + {36, {31, 0, 0, 0}, 0x1e25c01fu, "frintz s31, s0"}, + {36, {0, 1, 0, 0}, 0x1e25c020u, "frintz s0, s1"}, + {36, {0, 7, 0, 0}, 0x1e25c0e0u, "frintz s0, s7"}, + {36, {0, 15, 0, 0}, 0x1e25c1e0u, "frintz s0, s15"}, + {36, {0, 31, 0, 0}, 0x1e25c3e0u, "frintz s0, s31"}, + {36, {15, 0, 0, 0}, 0x1e25c00fu, "frintz s15, s0"}, + {36, {0, 15, 0, 0}, 0x1e25c1e0u, "frintz s0, s15"}, + {36, {7, 1, 0, 0}, 0x1e25c027u, "frintz s7, s1"}, + {36, {31, 31, 0, 0}, 0x1e25c3ffu, "frintz s31, s31"}, + {37, {0, 0, 0, 0}, 0x1e65c000u, "frintz d0, d0"}, + {37, {1, 0, 0, 0}, 0x1e65c001u, "frintz d1, d0"}, + {37, {7, 0, 0, 0}, 0x1e65c007u, "frintz d7, d0"}, + {37, {15, 0, 0, 0}, 0x1e65c00fu, "frintz d15, d0"}, + {37, {31, 0, 0, 0}, 0x1e65c01fu, "frintz d31, d0"}, + {37, {0, 1, 0, 0}, 0x1e65c020u, "frintz d0, d1"}, + {37, {0, 7, 0, 0}, 0x1e65c0e0u, "frintz d0, d7"}, + {37, {0, 15, 0, 0}, 0x1e65c1e0u, "frintz d0, d15"}, + {37, {0, 31, 0, 0}, 0x1e65c3e0u, "frintz d0, d31"}, + {37, {15, 0, 0, 0}, 0x1e65c00fu, "frintz d15, d0"}, + {37, {0, 15, 0, 0}, 0x1e65c1e0u, "frintz d0, d15"}, + {37, {7, 1, 0, 0}, 0x1e65c027u, "frintz d7, d1"}, + {37, {31, 31, 0, 0}, 0x1e65c3ffu, "frintz d31, d31"}, + {38, {0, 0, 0, 0}, 0x1e202000u, "fcmp s0, s0"}, + {38, {1, 0, 0, 0}, 0x1e202020u, "fcmp s1, s0"}, + {38, {7, 0, 0, 0}, 0x1e2020e0u, "fcmp s7, s0"}, + {38, {15, 0, 0, 0}, 0x1e2021e0u, "fcmp s15, s0"}, + {38, {31, 0, 0, 0}, 0x1e2023e0u, "fcmp s31, s0"}, + {38, {0, 1, 0, 0}, 0x1e212000u, "fcmp s0, s1"}, + {38, {0, 7, 0, 0}, 0x1e272000u, "fcmp s0, s7"}, + {38, {0, 15, 0, 0}, 0x1e2f2000u, "fcmp s0, s15"}, + {38, {0, 31, 0, 0}, 0x1e3f2000u, "fcmp s0, s31"}, + {38, {15, 0, 0, 0}, 0x1e2021e0u, "fcmp s15, s0"}, + {38, {0, 15, 0, 0}, 0x1e2f2000u, "fcmp s0, s15"}, + {38, {7, 1, 0, 0}, 0x1e2120e0u, "fcmp s7, s1"}, + {38, {31, 31, 0, 0}, 0x1e3f23e0u, "fcmp s31, s31"}, + {39, {0, 0, 0, 0}, 0x1e602000u, "fcmp d0, d0"}, + {39, {1, 0, 0, 0}, 0x1e602020u, "fcmp d1, d0"}, + {39, {7, 0, 0, 0}, 0x1e6020e0u, "fcmp d7, d0"}, + {39, {15, 0, 0, 0}, 0x1e6021e0u, "fcmp d15, d0"}, + {39, {31, 0, 0, 0}, 0x1e6023e0u, "fcmp d31, d0"}, + {39, {0, 1, 0, 0}, 0x1e612000u, "fcmp d0, d1"}, + {39, {0, 7, 0, 0}, 0x1e672000u, "fcmp d0, d7"}, + {39, {0, 15, 0, 0}, 0x1e6f2000u, "fcmp d0, d15"}, + {39, {0, 31, 0, 0}, 0x1e7f2000u, "fcmp d0, d31"}, + {39, {15, 0, 0, 0}, 0x1e6021e0u, "fcmp d15, d0"}, + {39, {0, 15, 0, 0}, 0x1e6f2000u, "fcmp d0, d15"}, + {39, {7, 1, 0, 0}, 0x1e6120e0u, "fcmp d7, d1"}, + {39, {31, 31, 0, 0}, 0x1e7f23e0u, "fcmp d31, d31"}, + {40, {0, 0, 0, 0}, 0x1e202008u, "fcmp s0, #0.0"}, + {40, {1, 0, 0, 0}, 0x1e202028u, "fcmp s1, #0.0"}, + {40, {7, 0, 0, 0}, 0x1e2020e8u, "fcmp s7, #0.0"}, + {40, {15, 0, 0, 0}, 0x1e2021e8u, "fcmp s15, #0.0"}, + {40, {31, 0, 0, 0}, 0x1e2023e8u, "fcmp s31, #0.0"}, + {41, {0, 0, 0, 0}, 0x1e602008u, "fcmp d0, #0.0"}, + {41, {1, 0, 0, 0}, 0x1e602028u, "fcmp d1, #0.0"}, + {41, {7, 0, 0, 0}, 0x1e6020e8u, "fcmp d7, #0.0"}, + {41, {15, 0, 0, 0}, 0x1e6021e8u, "fcmp d15, #0.0"}, + {41, {31, 0, 0, 0}, 0x1e6023e8u, "fcmp d31, #0.0"}, + {42, {0, 0, 0, 0}, 0x1e22c000u, "fcvt d0, s0"}, + {42, {1, 0, 0, 0}, 0x1e22c001u, "fcvt d1, s0"}, + {42, {7, 0, 0, 0}, 0x1e22c007u, "fcvt d7, s0"}, + {42, {15, 0, 0, 0}, 0x1e22c00fu, "fcvt d15, s0"}, + {42, {31, 0, 0, 0}, 0x1e22c01fu, "fcvt d31, s0"}, + {42, {0, 1, 0, 0}, 0x1e22c020u, "fcvt d0, s1"}, + {42, {0, 7, 0, 0}, 0x1e22c0e0u, "fcvt d0, s7"}, + {42, {0, 15, 0, 0}, 0x1e22c1e0u, "fcvt d0, s15"}, + {42, {0, 31, 0, 0}, 0x1e22c3e0u, "fcvt d0, s31"}, + {42, {15, 0, 0, 0}, 0x1e22c00fu, "fcvt d15, s0"}, + {42, {0, 15, 0, 0}, 0x1e22c1e0u, "fcvt d0, s15"}, + {42, {7, 1, 0, 0}, 0x1e22c027u, "fcvt d7, s1"}, + {42, {31, 31, 0, 0}, 0x1e22c3ffu, "fcvt d31, s31"}, + {43, {0, 0, 0, 0}, 0x1e624000u, "fcvt s0, d0"}, + {43, {1, 0, 0, 0}, 0x1e624001u, "fcvt s1, d0"}, + {43, {7, 0, 0, 0}, 0x1e624007u, "fcvt s7, d0"}, + {43, {15, 0, 0, 0}, 0x1e62400fu, "fcvt s15, d0"}, + {43, {31, 0, 0, 0}, 0x1e62401fu, "fcvt s31, d0"}, + {43, {0, 1, 0, 0}, 0x1e624020u, "fcvt s0, d1"}, + {43, {0, 7, 0, 0}, 0x1e6240e0u, "fcvt s0, d7"}, + {43, {0, 15, 0, 0}, 0x1e6241e0u, "fcvt s0, d15"}, + {43, {0, 31, 0, 0}, 0x1e6243e0u, "fcvt s0, d31"}, + {43, {15, 0, 0, 0}, 0x1e62400fu, "fcvt s15, d0"}, + {43, {0, 15, 0, 0}, 0x1e6241e0u, "fcvt s0, d15"}, + {43, {7, 1, 0, 0}, 0x1e624027u, "fcvt s7, d1"}, + {43, {31, 31, 0, 0}, 0x1e6243ffu, "fcvt s31, d31"}, + {44, {0, 0, 0, 0}, 0x1e220000u, "scvtf s0, w0"}, + {44, {1, 0, 0, 0}, 0x1e220001u, "scvtf s1, w0"}, + {44, {7, 0, 0, 0}, 0x1e220007u, "scvtf s7, w0"}, + {44, {15, 0, 0, 0}, 0x1e22000fu, "scvtf s15, w0"}, + {44, {31, 0, 0, 0}, 0x1e22001fu, "scvtf s31, w0"}, + {44, {0, 1, 0, 0}, 0x1e220020u, "scvtf s0, w1"}, + {44, {0, 7, 0, 0}, 0x1e2200e0u, "scvtf s0, w7"}, + {44, {0, 15, 0, 0}, 0x1e2201e0u, "scvtf s0, w15"}, + {44, {0, 31, 0, 0}, 0x1e2203e0u, "scvtf s0, wzr"}, + {44, {15, 0, 0, 0}, 0x1e22000fu, "scvtf s15, w0"}, + {44, {0, 15, 0, 0}, 0x1e2201e0u, "scvtf s0, w15"}, + {44, {7, 1, 0, 0}, 0x1e220027u, "scvtf s7, w1"}, + {44, {31, 31, 0, 0}, 0x1e2203ffu, "scvtf s31, wzr"}, + {45, {0, 0, 0, 0}, 0x9e220000u, "scvtf s0, x0"}, + {45, {1, 0, 0, 0}, 0x9e220001u, "scvtf s1, x0"}, + {45, {7, 0, 0, 0}, 0x9e220007u, "scvtf s7, x0"}, + {45, {15, 0, 0, 0}, 0x9e22000fu, "scvtf s15, x0"}, + {45, {31, 0, 0, 0}, 0x9e22001fu, "scvtf s31, x0"}, + {45, {0, 1, 0, 0}, 0x9e220020u, "scvtf s0, x1"}, + {45, {0, 7, 0, 0}, 0x9e2200e0u, "scvtf s0, x7"}, + {45, {0, 15, 0, 0}, 0x9e2201e0u, "scvtf s0, x15"}, + {45, {0, 31, 0, 0}, 0x9e2203e0u, "scvtf s0, xzr"}, + {45, {15, 0, 0, 0}, 0x9e22000fu, "scvtf s15, x0"}, + {45, {0, 15, 0, 0}, 0x9e2201e0u, "scvtf s0, x15"}, + {45, {7, 1, 0, 0}, 0x9e220027u, "scvtf s7, x1"}, + {45, {31, 31, 0, 0}, 0x9e2203ffu, "scvtf s31, xzr"}, + {46, {0, 0, 0, 0}, 0x1e620000u, "scvtf d0, w0"}, + {46, {1, 0, 0, 0}, 0x1e620001u, "scvtf d1, w0"}, + {46, {7, 0, 0, 0}, 0x1e620007u, "scvtf d7, w0"}, + {46, {15, 0, 0, 0}, 0x1e62000fu, "scvtf d15, w0"}, + {46, {31, 0, 0, 0}, 0x1e62001fu, "scvtf d31, w0"}, + {46, {0, 1, 0, 0}, 0x1e620020u, "scvtf d0, w1"}, + {46, {0, 7, 0, 0}, 0x1e6200e0u, "scvtf d0, w7"}, + {46, {0, 15, 0, 0}, 0x1e6201e0u, "scvtf d0, w15"}, + {46, {0, 31, 0, 0}, 0x1e6203e0u, "scvtf d0, wzr"}, + {46, {15, 0, 0, 0}, 0x1e62000fu, "scvtf d15, w0"}, + {46, {0, 15, 0, 0}, 0x1e6201e0u, "scvtf d0, w15"}, + {46, {7, 1, 0, 0}, 0x1e620027u, "scvtf d7, w1"}, + {46, {31, 31, 0, 0}, 0x1e6203ffu, "scvtf d31, wzr"}, + {47, {0, 0, 0, 0}, 0x9e620000u, "scvtf d0, x0"}, + {47, {1, 0, 0, 0}, 0x9e620001u, "scvtf d1, x0"}, + {47, {7, 0, 0, 0}, 0x9e620007u, "scvtf d7, x0"}, + {47, {15, 0, 0, 0}, 0x9e62000fu, "scvtf d15, x0"}, + {47, {31, 0, 0, 0}, 0x9e62001fu, "scvtf d31, x0"}, + {47, {0, 1, 0, 0}, 0x9e620020u, "scvtf d0, x1"}, + {47, {0, 7, 0, 0}, 0x9e6200e0u, "scvtf d0, x7"}, + {47, {0, 15, 0, 0}, 0x9e6201e0u, "scvtf d0, x15"}, + {47, {0, 31, 0, 0}, 0x9e6203e0u, "scvtf d0, xzr"}, + {47, {15, 0, 0, 0}, 0x9e62000fu, "scvtf d15, x0"}, + {47, {0, 15, 0, 0}, 0x9e6201e0u, "scvtf d0, x15"}, + {47, {7, 1, 0, 0}, 0x9e620027u, "scvtf d7, x1"}, + {47, {31, 31, 0, 0}, 0x9e6203ffu, "scvtf d31, xzr"}, + {48, {0, 0, 0, 0}, 0x1e230000u, "ucvtf s0, w0"}, + {48, {1, 0, 0, 0}, 0x1e230001u, "ucvtf s1, w0"}, + {48, {7, 0, 0, 0}, 0x1e230007u, "ucvtf s7, w0"}, + {48, {15, 0, 0, 0}, 0x1e23000fu, "ucvtf s15, w0"}, + {48, {31, 0, 0, 0}, 0x1e23001fu, "ucvtf s31, w0"}, + {48, {0, 1, 0, 0}, 0x1e230020u, "ucvtf s0, w1"}, + {48, {0, 7, 0, 0}, 0x1e2300e0u, "ucvtf s0, w7"}, + {48, {0, 15, 0, 0}, 0x1e2301e0u, "ucvtf s0, w15"}, + {48, {0, 31, 0, 0}, 0x1e2303e0u, "ucvtf s0, wzr"}, + {48, {15, 0, 0, 0}, 0x1e23000fu, "ucvtf s15, w0"}, + {48, {0, 15, 0, 0}, 0x1e2301e0u, "ucvtf s0, w15"}, + {48, {7, 1, 0, 0}, 0x1e230027u, "ucvtf s7, w1"}, + {48, {31, 31, 0, 0}, 0x1e2303ffu, "ucvtf s31, wzr"}, + {49, {0, 0, 0, 0}, 0x9e230000u, "ucvtf s0, x0"}, + {49, {1, 0, 0, 0}, 0x9e230001u, "ucvtf s1, x0"}, + {49, {7, 0, 0, 0}, 0x9e230007u, "ucvtf s7, x0"}, + {49, {15, 0, 0, 0}, 0x9e23000fu, "ucvtf s15, x0"}, + {49, {31, 0, 0, 0}, 0x9e23001fu, "ucvtf s31, x0"}, + {49, {0, 1, 0, 0}, 0x9e230020u, "ucvtf s0, x1"}, + {49, {0, 7, 0, 0}, 0x9e2300e0u, "ucvtf s0, x7"}, + {49, {0, 15, 0, 0}, 0x9e2301e0u, "ucvtf s0, x15"}, + {49, {0, 31, 0, 0}, 0x9e2303e0u, "ucvtf s0, xzr"}, + {49, {15, 0, 0, 0}, 0x9e23000fu, "ucvtf s15, x0"}, + {49, {0, 15, 0, 0}, 0x9e2301e0u, "ucvtf s0, x15"}, + {49, {7, 1, 0, 0}, 0x9e230027u, "ucvtf s7, x1"}, + {49, {31, 31, 0, 0}, 0x9e2303ffu, "ucvtf s31, xzr"}, + {50, {0, 0, 0, 0}, 0x1e630000u, "ucvtf d0, w0"}, + {50, {1, 0, 0, 0}, 0x1e630001u, "ucvtf d1, w0"}, + {50, {7, 0, 0, 0}, 0x1e630007u, "ucvtf d7, w0"}, + {50, {15, 0, 0, 0}, 0x1e63000fu, "ucvtf d15, w0"}, + {50, {31, 0, 0, 0}, 0x1e63001fu, "ucvtf d31, w0"}, + {50, {0, 1, 0, 0}, 0x1e630020u, "ucvtf d0, w1"}, + {50, {0, 7, 0, 0}, 0x1e6300e0u, "ucvtf d0, w7"}, + {50, {0, 15, 0, 0}, 0x1e6301e0u, "ucvtf d0, w15"}, + {50, {0, 31, 0, 0}, 0x1e6303e0u, "ucvtf d0, wzr"}, + {50, {15, 0, 0, 0}, 0x1e63000fu, "ucvtf d15, w0"}, + {50, {0, 15, 0, 0}, 0x1e6301e0u, "ucvtf d0, w15"}, + {50, {7, 1, 0, 0}, 0x1e630027u, "ucvtf d7, w1"}, + {50, {31, 31, 0, 0}, 0x1e6303ffu, "ucvtf d31, wzr"}, + {51, {0, 0, 0, 0}, 0x9e630000u, "ucvtf d0, x0"}, + {51, {1, 0, 0, 0}, 0x9e630001u, "ucvtf d1, x0"}, + {51, {7, 0, 0, 0}, 0x9e630007u, "ucvtf d7, x0"}, + {51, {15, 0, 0, 0}, 0x9e63000fu, "ucvtf d15, x0"}, + {51, {31, 0, 0, 0}, 0x9e63001fu, "ucvtf d31, x0"}, + {51, {0, 1, 0, 0}, 0x9e630020u, "ucvtf d0, x1"}, + {51, {0, 7, 0, 0}, 0x9e6300e0u, "ucvtf d0, x7"}, + {51, {0, 15, 0, 0}, 0x9e6301e0u, "ucvtf d0, x15"}, + {51, {0, 31, 0, 0}, 0x9e6303e0u, "ucvtf d0, xzr"}, + {51, {15, 0, 0, 0}, 0x9e63000fu, "ucvtf d15, x0"}, + {51, {0, 15, 0, 0}, 0x9e6301e0u, "ucvtf d0, x15"}, + {51, {7, 1, 0, 0}, 0x9e630027u, "ucvtf d7, x1"}, + {51, {31, 31, 0, 0}, 0x9e6303ffu, "ucvtf d31, xzr"}, + {52, {0, 0, 0, 0}, 0x1e380000u, "fcvtzs w0, s0"}, + {52, {1, 0, 0, 0}, 0x1e380001u, "fcvtzs w1, s0"}, + {52, {7, 0, 0, 0}, 0x1e380007u, "fcvtzs w7, s0"}, + {52, {15, 0, 0, 0}, 0x1e38000fu, "fcvtzs w15, s0"}, + {52, {31, 0, 0, 0}, 0x1e38001fu, "fcvtzs wzr, s0"}, + {52, {0, 1, 0, 0}, 0x1e380020u, "fcvtzs w0, s1"}, + {52, {0, 7, 0, 0}, 0x1e3800e0u, "fcvtzs w0, s7"}, + {52, {0, 15, 0, 0}, 0x1e3801e0u, "fcvtzs w0, s15"}, + {52, {0, 31, 0, 0}, 0x1e3803e0u, "fcvtzs w0, s31"}, + {52, {15, 0, 0, 0}, 0x1e38000fu, "fcvtzs w15, s0"}, + {52, {0, 15, 0, 0}, 0x1e3801e0u, "fcvtzs w0, s15"}, + {52, {7, 1, 0, 0}, 0x1e380027u, "fcvtzs w7, s1"}, + {52, {31, 31, 0, 0}, 0x1e3803ffu, "fcvtzs wzr, s31"}, + {53, {0, 0, 0, 0}, 0x9e380000u, "fcvtzs x0, s0"}, + {53, {1, 0, 0, 0}, 0x9e380001u, "fcvtzs x1, s0"}, + {53, {7, 0, 0, 0}, 0x9e380007u, "fcvtzs x7, s0"}, + {53, {15, 0, 0, 0}, 0x9e38000fu, "fcvtzs x15, s0"}, + {53, {31, 0, 0, 0}, 0x9e38001fu, "fcvtzs xzr, s0"}, + {53, {0, 1, 0, 0}, 0x9e380020u, "fcvtzs x0, s1"}, + {53, {0, 7, 0, 0}, 0x9e3800e0u, "fcvtzs x0, s7"}, + {53, {0, 15, 0, 0}, 0x9e3801e0u, "fcvtzs x0, s15"}, + {53, {0, 31, 0, 0}, 0x9e3803e0u, "fcvtzs x0, s31"}, + {53, {15, 0, 0, 0}, 0x9e38000fu, "fcvtzs x15, s0"}, + {53, {0, 15, 0, 0}, 0x9e3801e0u, "fcvtzs x0, s15"}, + {53, {7, 1, 0, 0}, 0x9e380027u, "fcvtzs x7, s1"}, + {53, {31, 31, 0, 0}, 0x9e3803ffu, "fcvtzs xzr, s31"}, + {54, {0, 0, 0, 0}, 0x1e780000u, "fcvtzs w0, d0"}, + {54, {1, 0, 0, 0}, 0x1e780001u, "fcvtzs w1, d0"}, + {54, {7, 0, 0, 0}, 0x1e780007u, "fcvtzs w7, d0"}, + {54, {15, 0, 0, 0}, 0x1e78000fu, "fcvtzs w15, d0"}, + {54, {31, 0, 0, 0}, 0x1e78001fu, "fcvtzs wzr, d0"}, + {54, {0, 1, 0, 0}, 0x1e780020u, "fcvtzs w0, d1"}, + {54, {0, 7, 0, 0}, 0x1e7800e0u, "fcvtzs w0, d7"}, + {54, {0, 15, 0, 0}, 0x1e7801e0u, "fcvtzs w0, d15"}, + {54, {0, 31, 0, 0}, 0x1e7803e0u, "fcvtzs w0, d31"}, + {54, {15, 0, 0, 0}, 0x1e78000fu, "fcvtzs w15, d0"}, + {54, {0, 15, 0, 0}, 0x1e7801e0u, "fcvtzs w0, d15"}, + {54, {7, 1, 0, 0}, 0x1e780027u, "fcvtzs w7, d1"}, + {54, {31, 31, 0, 0}, 0x1e7803ffu, "fcvtzs wzr, d31"}, + {55, {0, 0, 0, 0}, 0x9e780000u, "fcvtzs x0, d0"}, + {55, {1, 0, 0, 0}, 0x9e780001u, "fcvtzs x1, d0"}, + {55, {7, 0, 0, 0}, 0x9e780007u, "fcvtzs x7, d0"}, + {55, {15, 0, 0, 0}, 0x9e78000fu, "fcvtzs x15, d0"}, + {55, {31, 0, 0, 0}, 0x9e78001fu, "fcvtzs xzr, d0"}, + {55, {0, 1, 0, 0}, 0x9e780020u, "fcvtzs x0, d1"}, + {55, {0, 7, 0, 0}, 0x9e7800e0u, "fcvtzs x0, d7"}, + {55, {0, 15, 0, 0}, 0x9e7801e0u, "fcvtzs x0, d15"}, + {55, {0, 31, 0, 0}, 0x9e7803e0u, "fcvtzs x0, d31"}, + {55, {15, 0, 0, 0}, 0x9e78000fu, "fcvtzs x15, d0"}, + {55, {0, 15, 0, 0}, 0x9e7801e0u, "fcvtzs x0, d15"}, + {55, {7, 1, 0, 0}, 0x9e780027u, "fcvtzs x7, d1"}, + {55, {31, 31, 0, 0}, 0x9e7803ffu, "fcvtzs xzr, d31"}, + {56, {0, 0, 0, 0}, 0x1e390000u, "fcvtzu w0, s0"}, + {56, {1, 0, 0, 0}, 0x1e390001u, "fcvtzu w1, s0"}, + {56, {7, 0, 0, 0}, 0x1e390007u, "fcvtzu w7, s0"}, + {56, {15, 0, 0, 0}, 0x1e39000fu, "fcvtzu w15, s0"}, + {56, {31, 0, 0, 0}, 0x1e39001fu, "fcvtzu wzr, s0"}, + {56, {0, 1, 0, 0}, 0x1e390020u, "fcvtzu w0, s1"}, + {56, {0, 7, 0, 0}, 0x1e3900e0u, "fcvtzu w0, s7"}, + {56, {0, 15, 0, 0}, 0x1e3901e0u, "fcvtzu w0, s15"}, + {56, {0, 31, 0, 0}, 0x1e3903e0u, "fcvtzu w0, s31"}, + {56, {15, 0, 0, 0}, 0x1e39000fu, "fcvtzu w15, s0"}, + {56, {0, 15, 0, 0}, 0x1e3901e0u, "fcvtzu w0, s15"}, + {56, {7, 1, 0, 0}, 0x1e390027u, "fcvtzu w7, s1"}, + {56, {31, 31, 0, 0}, 0x1e3903ffu, "fcvtzu wzr, s31"}, + {57, {0, 0, 0, 0}, 0x9e390000u, "fcvtzu x0, s0"}, + {57, {1, 0, 0, 0}, 0x9e390001u, "fcvtzu x1, s0"}, + {57, {7, 0, 0, 0}, 0x9e390007u, "fcvtzu x7, s0"}, + {57, {15, 0, 0, 0}, 0x9e39000fu, "fcvtzu x15, s0"}, + {57, {31, 0, 0, 0}, 0x9e39001fu, "fcvtzu xzr, s0"}, + {57, {0, 1, 0, 0}, 0x9e390020u, "fcvtzu x0, s1"}, + {57, {0, 7, 0, 0}, 0x9e3900e0u, "fcvtzu x0, s7"}, + {57, {0, 15, 0, 0}, 0x9e3901e0u, "fcvtzu x0, s15"}, + {57, {0, 31, 0, 0}, 0x9e3903e0u, "fcvtzu x0, s31"}, + {57, {15, 0, 0, 0}, 0x9e39000fu, "fcvtzu x15, s0"}, + {57, {0, 15, 0, 0}, 0x9e3901e0u, "fcvtzu x0, s15"}, + {57, {7, 1, 0, 0}, 0x9e390027u, "fcvtzu x7, s1"}, + {57, {31, 31, 0, 0}, 0x9e3903ffu, "fcvtzu xzr, s31"}, + {58, {0, 0, 0, 0}, 0x1e790000u, "fcvtzu w0, d0"}, + {58, {1, 0, 0, 0}, 0x1e790001u, "fcvtzu w1, d0"}, + {58, {7, 0, 0, 0}, 0x1e790007u, "fcvtzu w7, d0"}, + {58, {15, 0, 0, 0}, 0x1e79000fu, "fcvtzu w15, d0"}, + {58, {31, 0, 0, 0}, 0x1e79001fu, "fcvtzu wzr, d0"}, + {58, {0, 1, 0, 0}, 0x1e790020u, "fcvtzu w0, d1"}, + {58, {0, 7, 0, 0}, 0x1e7900e0u, "fcvtzu w0, d7"}, + {58, {0, 15, 0, 0}, 0x1e7901e0u, "fcvtzu w0, d15"}, + {58, {0, 31, 0, 0}, 0x1e7903e0u, "fcvtzu w0, d31"}, + {58, {15, 0, 0, 0}, 0x1e79000fu, "fcvtzu w15, d0"}, + {58, {0, 15, 0, 0}, 0x1e7901e0u, "fcvtzu w0, d15"}, + {58, {7, 1, 0, 0}, 0x1e790027u, "fcvtzu w7, d1"}, + {58, {31, 31, 0, 0}, 0x1e7903ffu, "fcvtzu wzr, d31"}, + {59, {0, 0, 0, 0}, 0x9e790000u, "fcvtzu x0, d0"}, + {59, {1, 0, 0, 0}, 0x9e790001u, "fcvtzu x1, d0"}, + {59, {7, 0, 0, 0}, 0x9e790007u, "fcvtzu x7, d0"}, + {59, {15, 0, 0, 0}, 0x9e79000fu, "fcvtzu x15, d0"}, + {59, {31, 0, 0, 0}, 0x9e79001fu, "fcvtzu xzr, d0"}, + {59, {0, 1, 0, 0}, 0x9e790020u, "fcvtzu x0, d1"}, + {59, {0, 7, 0, 0}, 0x9e7900e0u, "fcvtzu x0, d7"}, + {59, {0, 15, 0, 0}, 0x9e7901e0u, "fcvtzu x0, d15"}, + {59, {0, 31, 0, 0}, 0x9e7903e0u, "fcvtzu x0, d31"}, + {59, {15, 0, 0, 0}, 0x9e79000fu, "fcvtzu x15, d0"}, + {59, {0, 15, 0, 0}, 0x9e7901e0u, "fcvtzu x0, d15"}, + {59, {7, 1, 0, 0}, 0x9e790027u, "fcvtzu x7, d1"}, + {59, {31, 31, 0, 0}, 0x9e7903ffu, "fcvtzu xzr, d31"}, + {60, {0, 0, 0, 0}, 0x1e200c00u, "fcsel s0, s0, s0, eq"}, + {60, {1, 0, 0, 0}, 0x1e200c01u, "fcsel s1, s0, s0, eq"}, + {60, {7, 0, 0, 0}, 0x1e200c07u, "fcsel s7, s0, s0, eq"}, + {60, {15, 0, 0, 0}, 0x1e200c0fu, "fcsel s15, s0, s0, eq"}, + {60, {31, 0, 0, 0}, 0x1e200c1fu, "fcsel s31, s0, s0, eq"}, + {60, {0, 1, 0, 0}, 0x1e200c20u, "fcsel s0, s1, s0, eq"}, + {60, {0, 7, 0, 0}, 0x1e200ce0u, "fcsel s0, s7, s0, eq"}, + {60, {0, 15, 0, 0}, 0x1e200de0u, "fcsel s0, s15, s0, eq"}, + {60, {0, 31, 0, 0}, 0x1e200fe0u, "fcsel s0, s31, s0, eq"}, + {60, {0, 0, 1, 0}, 0x1e210c00u, "fcsel s0, s0, s1, eq"}, + {60, {0, 0, 7, 0}, 0x1e270c00u, "fcsel s0, s0, s7, eq"}, + {60, {0, 0, 15, 0}, 0x1e2f0c00u, "fcsel s0, s0, s15, eq"}, + {60, {0, 0, 31, 0}, 0x1e3f0c00u, "fcsel s0, s0, s31, eq"}, + {60, {0, 0, 0, 1}, 0x1e201c00u, "fcsel s0, s0, s0, ne"}, + {60, {0, 0, 0, 2}, 0x1e202c00u, "fcsel s0, s0, s0, cs"}, + {60, {0, 0, 0, 3}, 0x1e203c00u, "fcsel s0, s0, s0, cc"}, + {60, {0, 0, 0, 4}, 0x1e204c00u, "fcsel s0, s0, s0, mi"}, + {60, {0, 0, 0, 5}, 0x1e205c00u, "fcsel s0, s0, s0, pl"}, + {60, {0, 0, 0, 6}, 0x1e206c00u, "fcsel s0, s0, s0, vs"}, + {60, {0, 0, 0, 7}, 0x1e207c00u, "fcsel s0, s0, s0, vc"}, + {60, {0, 0, 0, 8}, 0x1e208c00u, "fcsel s0, s0, s0, hi"}, + {60, {0, 0, 0, 9}, 0x1e209c00u, "fcsel s0, s0, s0, ls"}, + {60, {0, 0, 0, 10}, 0x1e20ac00u, "fcsel s0, s0, s0, ge"}, + {60, {0, 0, 0, 11}, 0x1e20bc00u, "fcsel s0, s0, s0, lt"}, + {60, {0, 0, 0, 12}, 0x1e20cc00u, "fcsel s0, s0, s0, gt"}, + {60, {0, 0, 0, 13}, 0x1e20dc00u, "fcsel s0, s0, s0, le"}, + {60, {0, 0, 0, 14}, 0x1e20ec00u, "fcsel s0, s0, s0, al"}, + {60, {15, 0, 7, 9}, 0x1e279c0fu, "fcsel s15, s0, s7, ls"}, + {60, {0, 15, 1, 14}, 0x1e21ede0u, "fcsel s0, s15, s1, al"}, + {60, {7, 1, 0, 4}, 0x1e204c27u, "fcsel s7, s1, s0, mi"}, + {60, {31, 31, 31, 9}, 0x1e3f9fffu, "fcsel s31, s31, s31, ls"}, + {61, {0, 0, 0, 0}, 0x1e600c00u, "fcsel d0, d0, d0, eq"}, + {61, {1, 0, 0, 0}, 0x1e600c01u, "fcsel d1, d0, d0, eq"}, + {61, {7, 0, 0, 0}, 0x1e600c07u, "fcsel d7, d0, d0, eq"}, + {61, {15, 0, 0, 0}, 0x1e600c0fu, "fcsel d15, d0, d0, eq"}, + {61, {31, 0, 0, 0}, 0x1e600c1fu, "fcsel d31, d0, d0, eq"}, + {61, {0, 1, 0, 0}, 0x1e600c20u, "fcsel d0, d1, d0, eq"}, + {61, {0, 7, 0, 0}, 0x1e600ce0u, "fcsel d0, d7, d0, eq"}, + {61, {0, 15, 0, 0}, 0x1e600de0u, "fcsel d0, d15, d0, eq"}, + {61, {0, 31, 0, 0}, 0x1e600fe0u, "fcsel d0, d31, d0, eq"}, + {61, {0, 0, 1, 0}, 0x1e610c00u, "fcsel d0, d0, d1, eq"}, + {61, {0, 0, 7, 0}, 0x1e670c00u, "fcsel d0, d0, d7, eq"}, + {61, {0, 0, 15, 0}, 0x1e6f0c00u, "fcsel d0, d0, d15, eq"}, + {61, {0, 0, 31, 0}, 0x1e7f0c00u, "fcsel d0, d0, d31, eq"}, + {61, {0, 0, 0, 1}, 0x1e601c00u, "fcsel d0, d0, d0, ne"}, + {61, {0, 0, 0, 2}, 0x1e602c00u, "fcsel d0, d0, d0, cs"}, + {61, {0, 0, 0, 3}, 0x1e603c00u, "fcsel d0, d0, d0, cc"}, + {61, {0, 0, 0, 4}, 0x1e604c00u, "fcsel d0, d0, d0, mi"}, + {61, {0, 0, 0, 5}, 0x1e605c00u, "fcsel d0, d0, d0, pl"}, + {61, {0, 0, 0, 6}, 0x1e606c00u, "fcsel d0, d0, d0, vs"}, + {61, {0, 0, 0, 7}, 0x1e607c00u, "fcsel d0, d0, d0, vc"}, + {61, {0, 0, 0, 8}, 0x1e608c00u, "fcsel d0, d0, d0, hi"}, + {61, {0, 0, 0, 9}, 0x1e609c00u, "fcsel d0, d0, d0, ls"}, + {61, {0, 0, 0, 10}, 0x1e60ac00u, "fcsel d0, d0, d0, ge"}, + {61, {0, 0, 0, 11}, 0x1e60bc00u, "fcsel d0, d0, d0, lt"}, + {61, {0, 0, 0, 12}, 0x1e60cc00u, "fcsel d0, d0, d0, gt"}, + {61, {0, 0, 0, 13}, 0x1e60dc00u, "fcsel d0, d0, d0, le"}, + {61, {0, 0, 0, 14}, 0x1e60ec00u, "fcsel d0, d0, d0, al"}, + {61, {15, 0, 7, 9}, 0x1e679c0fu, "fcsel d15, d0, d7, ls"}, + {61, {0, 15, 1, 14}, 0x1e61ede0u, "fcsel d0, d15, d1, al"}, + {61, {7, 1, 0, 4}, 0x1e604c27u, "fcsel d7, d1, d0, mi"}, + {61, {31, 31, 31, 9}, 0x1e7f9fffu, "fcsel d31, d31, d31, ls"}, + {62, {0, 0, 0, 0}, 0xbd400000u, "ldr s0, [x0, #0]"}, + {62, {1, 0, 0, 0}, 0xbd400001u, "ldr s1, [x0, #0]"}, + {62, {7, 0, 0, 0}, 0xbd400007u, "ldr s7, [x0, #0]"}, + {62, {15, 0, 0, 0}, 0xbd40000fu, "ldr s15, [x0, #0]"}, + {62, {31, 0, 0, 0}, 0xbd40001fu, "ldr s31, [x0, #0]"}, + {62, {0, 1, 0, 0}, 0xbd400020u, "ldr s0, [x1, #0]"}, + {62, {0, 7, 0, 0}, 0xbd4000e0u, "ldr s0, [x7, #0]"}, + {62, {0, 15, 0, 0}, 0xbd4001e0u, "ldr s0, [x15, #0]"}, + {62, {0, 31, 0, 0}, 0xbd4003e0u, "ldr s0, [sp, #0]"}, + {62, {0, 0, 1, 0}, 0xbd400400u, "ldr s0, [x0, #4]"}, + {62, {0, 0, 7, 0}, 0xbd401c00u, "ldr s0, [x0, #28]"}, + {62, {0, 0, 15, 0}, 0xbd403c00u, "ldr s0, [x0, #60]"}, + {62, {0, 0, 31, 0}, 0xbd407c00u, "ldr s0, [x0, #124]"}, + {62, {0, 0, 4095, 0}, 0xbd7ffc00u, "ldr s0, [x0, #16380]"}, + {62, {15, 0, 1, 0}, 0xbd40040fu, "ldr s15, [x0, #4]"}, + {62, {0, 15, 4095, 0}, 0xbd7ffde0u, "ldr s0, [x15, #16380]"}, + {62, {7, 1, 15, 0}, 0xbd403c27u, "ldr s7, [x1, #60]"}, + {62, {31, 31, 1, 0}, 0xbd4007ffu, "ldr s31, [sp, #4]"}, + {63, {0, 0, 0, 0}, 0xfd400000u, "ldr d0, [x0, #0]"}, + {63, {1, 0, 0, 0}, 0xfd400001u, "ldr d1, [x0, #0]"}, + {63, {7, 0, 0, 0}, 0xfd400007u, "ldr d7, [x0, #0]"}, + {63, {15, 0, 0, 0}, 0xfd40000fu, "ldr d15, [x0, #0]"}, + {63, {31, 0, 0, 0}, 0xfd40001fu, "ldr d31, [x0, #0]"}, + {63, {0, 1, 0, 0}, 0xfd400020u, "ldr d0, [x1, #0]"}, + {63, {0, 7, 0, 0}, 0xfd4000e0u, "ldr d0, [x7, #0]"}, + {63, {0, 15, 0, 0}, 0xfd4001e0u, "ldr d0, [x15, #0]"}, + {63, {0, 31, 0, 0}, 0xfd4003e0u, "ldr d0, [sp, #0]"}, + {63, {0, 0, 1, 0}, 0xfd400400u, "ldr d0, [x0, #8]"}, + {63, {0, 0, 7, 0}, 0xfd401c00u, "ldr d0, [x0, #56]"}, + {63, {0, 0, 15, 0}, 0xfd403c00u, "ldr d0, [x0, #120]"}, + {63, {0, 0, 31, 0}, 0xfd407c00u, "ldr d0, [x0, #248]"}, + {63, {0, 0, 4095, 0}, 0xfd7ffc00u, "ldr d0, [x0, #32760]"}, + {63, {15, 0, 1, 0}, 0xfd40040fu, "ldr d15, [x0, #8]"}, + {63, {0, 15, 4095, 0}, 0xfd7ffde0u, "ldr d0, [x15, #32760]"}, + {63, {7, 1, 15, 0}, 0xfd403c27u, "ldr d7, [x1, #120]"}, + {63, {31, 31, 1, 0}, 0xfd4007ffu, "ldr d31, [sp, #8]"}, + {64, {0, 0, 0, 0}, 0xbd000000u, "str s0, [x0, #0]"}, + {64, {1, 0, 0, 0}, 0xbd000001u, "str s1, [x0, #0]"}, + {64, {7, 0, 0, 0}, 0xbd000007u, "str s7, [x0, #0]"}, + {64, {15, 0, 0, 0}, 0xbd00000fu, "str s15, [x0, #0]"}, + {64, {31, 0, 0, 0}, 0xbd00001fu, "str s31, [x0, #0]"}, + {64, {0, 1, 0, 0}, 0xbd000020u, "str s0, [x1, #0]"}, + {64, {0, 7, 0, 0}, 0xbd0000e0u, "str s0, [x7, #0]"}, + {64, {0, 15, 0, 0}, 0xbd0001e0u, "str s0, [x15, #0]"}, + {64, {0, 31, 0, 0}, 0xbd0003e0u, "str s0, [sp, #0]"}, + {64, {0, 0, 1, 0}, 0xbd000400u, "str s0, [x0, #4]"}, + {64, {0, 0, 7, 0}, 0xbd001c00u, "str s0, [x0, #28]"}, + {64, {0, 0, 15, 0}, 0xbd003c00u, "str s0, [x0, #60]"}, + {64, {0, 0, 31, 0}, 0xbd007c00u, "str s0, [x0, #124]"}, + {64, {0, 0, 4095, 0}, 0xbd3ffc00u, "str s0, [x0, #16380]"}, + {64, {15, 0, 1, 0}, 0xbd00040fu, "str s15, [x0, #4]"}, + {64, {0, 15, 4095, 0}, 0xbd3ffde0u, "str s0, [x15, #16380]"}, + {64, {7, 1, 15, 0}, 0xbd003c27u, "str s7, [x1, #60]"}, + {64, {31, 31, 1, 0}, 0xbd0007ffu, "str s31, [sp, #4]"}, + {65, {0, 0, 0, 0}, 0xfd000000u, "str d0, [x0, #0]"}, + {65, {1, 0, 0, 0}, 0xfd000001u, "str d1, [x0, #0]"}, + {65, {7, 0, 0, 0}, 0xfd000007u, "str d7, [x0, #0]"}, + {65, {15, 0, 0, 0}, 0xfd00000fu, "str d15, [x0, #0]"}, + {65, {31, 0, 0, 0}, 0xfd00001fu, "str d31, [x0, #0]"}, + {65, {0, 1, 0, 0}, 0xfd000020u, "str d0, [x1, #0]"}, + {65, {0, 7, 0, 0}, 0xfd0000e0u, "str d0, [x7, #0]"}, + {65, {0, 15, 0, 0}, 0xfd0001e0u, "str d0, [x15, #0]"}, + {65, {0, 31, 0, 0}, 0xfd0003e0u, "str d0, [sp, #0]"}, + {65, {0, 0, 1, 0}, 0xfd000400u, "str d0, [x0, #8]"}, + {65, {0, 0, 7, 0}, 0xfd001c00u, "str d0, [x0, #56]"}, + {65, {0, 0, 15, 0}, 0xfd003c00u, "str d0, [x0, #120]"}, + {65, {0, 0, 31, 0}, 0xfd007c00u, "str d0, [x0, #248]"}, + {65, {0, 0, 4095, 0}, 0xfd3ffc00u, "str d0, [x0, #32760]"}, + {65, {15, 0, 1, 0}, 0xfd00040fu, "str d15, [x0, #8]"}, + {65, {0, 15, 4095, 0}, 0xfd3ffde0u, "str d0, [x15, #32760]"}, + {65, {7, 1, 15, 0}, 0xfd003c27u, "str d7, [x1, #120]"}, + {65, {31, 31, 1, 0}, 0xfd0007ffu, "str d31, [sp, #8]"}, + {66, {0, 0, 0, 0}, 0xbc606800u, "ldr s0, [x0, x0]"}, + {66, {1, 0, 0, 0}, 0xbc606801u, "ldr s1, [x0, x0]"}, + {66, {7, 0, 0, 0}, 0xbc606807u, "ldr s7, [x0, x0]"}, + {66, {15, 0, 0, 0}, 0xbc60680fu, "ldr s15, [x0, x0]"}, + {66, {31, 0, 0, 0}, 0xbc60681fu, "ldr s31, [x0, x0]"}, + {66, {0, 1, 0, 0}, 0xbc606820u, "ldr s0, [x1, x0]"}, + {66, {0, 7, 0, 0}, 0xbc6068e0u, "ldr s0, [x7, x0]"}, + {66, {0, 15, 0, 0}, 0xbc6069e0u, "ldr s0, [x15, x0]"}, + {66, {0, 31, 0, 0}, 0xbc606be0u, "ldr s0, [sp, x0]"}, + {66, {0, 0, 1, 0}, 0xbc616800u, "ldr s0, [x0, x1]"}, + {66, {0, 0, 7, 0}, 0xbc676800u, "ldr s0, [x0, x7]"}, + {66, {0, 0, 15, 0}, 0xbc6f6800u, "ldr s0, [x0, x15]"}, + {66, {0, 0, 31, 0}, 0xbc7f6800u, "ldr s0, [x0, xzr]"}, + {66, {15, 0, 7, 0}, 0xbc67680fu, "ldr s15, [x0, x7]"}, + {66, {0, 15, 1, 0}, 0xbc6169e0u, "ldr s0, [x15, x1]"}, + {66, {7, 1, 0, 0}, 0xbc606827u, "ldr s7, [x1, x0]"}, + {66, {31, 31, 31, 0}, 0xbc7f6bffu, "ldr s31, [sp, xzr]"}, + {67, {0, 0, 0, 0}, 0xfc606800u, "ldr d0, [x0, x0]"}, + {67, {1, 0, 0, 0}, 0xfc606801u, "ldr d1, [x0, x0]"}, + {67, {7, 0, 0, 0}, 0xfc606807u, "ldr d7, [x0, x0]"}, + {67, {15, 0, 0, 0}, 0xfc60680fu, "ldr d15, [x0, x0]"}, + {67, {31, 0, 0, 0}, 0xfc60681fu, "ldr d31, [x0, x0]"}, + {67, {0, 1, 0, 0}, 0xfc606820u, "ldr d0, [x1, x0]"}, + {67, {0, 7, 0, 0}, 0xfc6068e0u, "ldr d0, [x7, x0]"}, + {67, {0, 15, 0, 0}, 0xfc6069e0u, "ldr d0, [x15, x0]"}, + {67, {0, 31, 0, 0}, 0xfc606be0u, "ldr d0, [sp, x0]"}, + {67, {0, 0, 1, 0}, 0xfc616800u, "ldr d0, [x0, x1]"}, + {67, {0, 0, 7, 0}, 0xfc676800u, "ldr d0, [x0, x7]"}, + {67, {0, 0, 15, 0}, 0xfc6f6800u, "ldr d0, [x0, x15]"}, + {67, {0, 0, 31, 0}, 0xfc7f6800u, "ldr d0, [x0, xzr]"}, + {67, {15, 0, 7, 0}, 0xfc67680fu, "ldr d15, [x0, x7]"}, + {67, {0, 15, 1, 0}, 0xfc6169e0u, "ldr d0, [x15, x1]"}, + {67, {7, 1, 0, 0}, 0xfc606827u, "ldr d7, [x1, x0]"}, + {67, {31, 31, 31, 0}, 0xfc7f6bffu, "ldr d31, [sp, xzr]"}, + {68, {0, 0, 0, 0}, 0xbc206800u, "str s0, [x0, x0]"}, + {68, {1, 0, 0, 0}, 0xbc206801u, "str s1, [x0, x0]"}, + {68, {7, 0, 0, 0}, 0xbc206807u, "str s7, [x0, x0]"}, + {68, {15, 0, 0, 0}, 0xbc20680fu, "str s15, [x0, x0]"}, + {68, {31, 0, 0, 0}, 0xbc20681fu, "str s31, [x0, x0]"}, + {68, {0, 1, 0, 0}, 0xbc206820u, "str s0, [x1, x0]"}, + {68, {0, 7, 0, 0}, 0xbc2068e0u, "str s0, [x7, x0]"}, + {68, {0, 15, 0, 0}, 0xbc2069e0u, "str s0, [x15, x0]"}, + {68, {0, 31, 0, 0}, 0xbc206be0u, "str s0, [sp, x0]"}, + {68, {0, 0, 1, 0}, 0xbc216800u, "str s0, [x0, x1]"}, + {68, {0, 0, 7, 0}, 0xbc276800u, "str s0, [x0, x7]"}, + {68, {0, 0, 15, 0}, 0xbc2f6800u, "str s0, [x0, x15]"}, + {68, {0, 0, 31, 0}, 0xbc3f6800u, "str s0, [x0, xzr]"}, + {68, {15, 0, 7, 0}, 0xbc27680fu, "str s15, [x0, x7]"}, + {68, {0, 15, 1, 0}, 0xbc2169e0u, "str s0, [x15, x1]"}, + {68, {7, 1, 0, 0}, 0xbc206827u, "str s7, [x1, x0]"}, + {68, {31, 31, 31, 0}, 0xbc3f6bffu, "str s31, [sp, xzr]"}, + {69, {0, 0, 0, 0}, 0xfc206800u, "str d0, [x0, x0]"}, + {69, {1, 0, 0, 0}, 0xfc206801u, "str d1, [x0, x0]"}, + {69, {7, 0, 0, 0}, 0xfc206807u, "str d7, [x0, x0]"}, + {69, {15, 0, 0, 0}, 0xfc20680fu, "str d15, [x0, x0]"}, + {69, {31, 0, 0, 0}, 0xfc20681fu, "str d31, [x0, x0]"}, + {69, {0, 1, 0, 0}, 0xfc206820u, "str d0, [x1, x0]"}, + {69, {0, 7, 0, 0}, 0xfc2068e0u, "str d0, [x7, x0]"}, + {69, {0, 15, 0, 0}, 0xfc2069e0u, "str d0, [x15, x0]"}, + {69, {0, 31, 0, 0}, 0xfc206be0u, "str d0, [sp, x0]"}, + {69, {0, 0, 1, 0}, 0xfc216800u, "str d0, [x0, x1]"}, + {69, {0, 0, 7, 0}, 0xfc276800u, "str d0, [x0, x7]"}, + {69, {0, 0, 15, 0}, 0xfc2f6800u, "str d0, [x0, x15]"}, + {69, {0, 0, 31, 0}, 0xfc3f6800u, "str d0, [x0, xzr]"}, + {69, {15, 0, 7, 0}, 0xfc27680fu, "str d15, [x0, x7]"}, + {69, {0, 15, 1, 0}, 0xfc2169e0u, "str d0, [x15, x1]"}, + {69, {7, 1, 0, 0}, 0xfc206827u, "str d7, [x1, x0]"}, + {69, {31, 31, 31, 0}, 0xfc3f6bffu, "str d31, [sp, xzr]"}, + {70, {0, 0, 0, 0}, 0xbc607800u, "ldr s0, [x0, x0, lsl #2]"}, + {70, {1, 0, 0, 0}, 0xbc607801u, "ldr s1, [x0, x0, lsl #2]"}, + {70, {7, 0, 0, 0}, 0xbc607807u, "ldr s7, [x0, x0, lsl #2]"}, + {70, {15, 0, 0, 0}, 0xbc60780fu, "ldr s15, [x0, x0, lsl #2]"}, + {70, {31, 0, 0, 0}, 0xbc60781fu, "ldr s31, [x0, x0, lsl #2]"}, + {70, {0, 1, 0, 0}, 0xbc607820u, "ldr s0, [x1, x0, lsl #2]"}, + {70, {0, 7, 0, 0}, 0xbc6078e0u, "ldr s0, [x7, x0, lsl #2]"}, + {70, {0, 15, 0, 0}, 0xbc6079e0u, "ldr s0, [x15, x0, lsl #2]"}, + {70, {0, 31, 0, 0}, 0xbc607be0u, "ldr s0, [sp, x0, lsl #2]"}, + {70, {0, 0, 1, 0}, 0xbc617800u, "ldr s0, [x0, x1, lsl #2]"}, + {70, {0, 0, 7, 0}, 0xbc677800u, "ldr s0, [x0, x7, lsl #2]"}, + {70, {0, 0, 15, 0}, 0xbc6f7800u, "ldr s0, [x0, x15, lsl #2]"}, + {70, {0, 0, 31, 0}, 0xbc7f7800u, "ldr s0, [x0, xzr, lsl #2]"}, + {70, {15, 0, 7, 0}, 0xbc67780fu, "ldr s15, [x0, x7, lsl #2]"}, + {70, {0, 15, 1, 0}, 0xbc6179e0u, "ldr s0, [x15, x1, lsl #2]"}, + {70, {7, 1, 0, 0}, 0xbc607827u, "ldr s7, [x1, x0, lsl #2]"}, + {70, {31, 31, 31, 0}, 0xbc7f7bffu, "ldr s31, [sp, xzr, lsl #2]"}, + {71, {0, 0, 0, 0}, 0xfc607800u, "ldr d0, [x0, x0, lsl #3]"}, + {71, {1, 0, 0, 0}, 0xfc607801u, "ldr d1, [x0, x0, lsl #3]"}, + {71, {7, 0, 0, 0}, 0xfc607807u, "ldr d7, [x0, x0, lsl #3]"}, + {71, {15, 0, 0, 0}, 0xfc60780fu, "ldr d15, [x0, x0, lsl #3]"}, + {71, {31, 0, 0, 0}, 0xfc60781fu, "ldr d31, [x0, x0, lsl #3]"}, + {71, {0, 1, 0, 0}, 0xfc607820u, "ldr d0, [x1, x0, lsl #3]"}, + {71, {0, 7, 0, 0}, 0xfc6078e0u, "ldr d0, [x7, x0, lsl #3]"}, + {71, {0, 15, 0, 0}, 0xfc6079e0u, "ldr d0, [x15, x0, lsl #3]"}, + {71, {0, 31, 0, 0}, 0xfc607be0u, "ldr d0, [sp, x0, lsl #3]"}, + {71, {0, 0, 1, 0}, 0xfc617800u, "ldr d0, [x0, x1, lsl #3]"}, + {71, {0, 0, 7, 0}, 0xfc677800u, "ldr d0, [x0, x7, lsl #3]"}, + {71, {0, 0, 15, 0}, 0xfc6f7800u, "ldr d0, [x0, x15, lsl #3]"}, + {71, {0, 0, 31, 0}, 0xfc7f7800u, "ldr d0, [x0, xzr, lsl #3]"}, + {71, {15, 0, 7, 0}, 0xfc67780fu, "ldr d15, [x0, x7, lsl #3]"}, + {71, {0, 15, 1, 0}, 0xfc6179e0u, "ldr d0, [x15, x1, lsl #3]"}, + {71, {7, 1, 0, 0}, 0xfc607827u, "ldr d7, [x1, x0, lsl #3]"}, + {71, {31, 31, 31, 0}, 0xfc7f7bffu, "ldr d31, [sp, xzr, lsl #3]"}, + {72, {0, 0, 0, 0}, 0xbc207800u, "str s0, [x0, x0, lsl #2]"}, + {72, {1, 0, 0, 0}, 0xbc207801u, "str s1, [x0, x0, lsl #2]"}, + {72, {7, 0, 0, 0}, 0xbc207807u, "str s7, [x0, x0, lsl #2]"}, + {72, {15, 0, 0, 0}, 0xbc20780fu, "str s15, [x0, x0, lsl #2]"}, + {72, {31, 0, 0, 0}, 0xbc20781fu, "str s31, [x0, x0, lsl #2]"}, + {72, {0, 1, 0, 0}, 0xbc207820u, "str s0, [x1, x0, lsl #2]"}, + {72, {0, 7, 0, 0}, 0xbc2078e0u, "str s0, [x7, x0, lsl #2]"}, + {72, {0, 15, 0, 0}, 0xbc2079e0u, "str s0, [x15, x0, lsl #2]"}, + {72, {0, 31, 0, 0}, 0xbc207be0u, "str s0, [sp, x0, lsl #2]"}, + {72, {0, 0, 1, 0}, 0xbc217800u, "str s0, [x0, x1, lsl #2]"}, + {72, {0, 0, 7, 0}, 0xbc277800u, "str s0, [x0, x7, lsl #2]"}, + {72, {0, 0, 15, 0}, 0xbc2f7800u, "str s0, [x0, x15, lsl #2]"}, + {72, {0, 0, 31, 0}, 0xbc3f7800u, "str s0, [x0, xzr, lsl #2]"}, + {72, {15, 0, 7, 0}, 0xbc27780fu, "str s15, [x0, x7, lsl #2]"}, + {72, {0, 15, 1, 0}, 0xbc2179e0u, "str s0, [x15, x1, lsl #2]"}, + {72, {7, 1, 0, 0}, 0xbc207827u, "str s7, [x1, x0, lsl #2]"}, + {72, {31, 31, 31, 0}, 0xbc3f7bffu, "str s31, [sp, xzr, lsl #2]"}, + {73, {0, 0, 0, 0}, 0xfc207800u, "str d0, [x0, x0, lsl #3]"}, + {73, {1, 0, 0, 0}, 0xfc207801u, "str d1, [x0, x0, lsl #3]"}, + {73, {7, 0, 0, 0}, 0xfc207807u, "str d7, [x0, x0, lsl #3]"}, + {73, {15, 0, 0, 0}, 0xfc20780fu, "str d15, [x0, x0, lsl #3]"}, + {73, {31, 0, 0, 0}, 0xfc20781fu, "str d31, [x0, x0, lsl #3]"}, + {73, {0, 1, 0, 0}, 0xfc207820u, "str d0, [x1, x0, lsl #3]"}, + {73, {0, 7, 0, 0}, 0xfc2078e0u, "str d0, [x7, x0, lsl #3]"}, + {73, {0, 15, 0, 0}, 0xfc2079e0u, "str d0, [x15, x0, lsl #3]"}, + {73, {0, 31, 0, 0}, 0xfc207be0u, "str d0, [sp, x0, lsl #3]"}, + {73, {0, 0, 1, 0}, 0xfc217800u, "str d0, [x0, x1, lsl #3]"}, + {73, {0, 0, 7, 0}, 0xfc277800u, "str d0, [x0, x7, lsl #3]"}, + {73, {0, 0, 15, 0}, 0xfc2f7800u, "str d0, [x0, x15, lsl #3]"}, + {73, {0, 0, 31, 0}, 0xfc3f7800u, "str d0, [x0, xzr, lsl #3]"}, + {73, {15, 0, 7, 0}, 0xfc27780fu, "str d15, [x0, x7, lsl #3]"}, + {73, {0, 15, 1, 0}, 0xfc2179e0u, "str d0, [x15, x1, lsl #3]"}, + {73, {7, 1, 0, 0}, 0xfc207827u, "str d7, [x1, x0, lsl #3]"}, + {73, {31, 31, 31, 0}, 0xfc3f7bffu, "str d31, [sp, xzr, lsl #3]"}, + {74, {0, 0, 0, 0}, 0xbc400c00u, "ldr s0, [x0, #0]!"}, + {74, {1, 0, 0, 0}, 0xbc400c01u, "ldr s1, [x0, #0]!"}, + {74, {7, 0, 0, 0}, 0xbc400c07u, "ldr s7, [x0, #0]!"}, + {74, {15, 0, 0, 0}, 0xbc400c0fu, "ldr s15, [x0, #0]!"}, + {74, {31, 0, 0, 0}, 0xbc400c1fu, "ldr s31, [x0, #0]!"}, + {74, {0, 1, 0, 0}, 0xbc400c20u, "ldr s0, [x1, #0]!"}, + {74, {0, 7, 0, 0}, 0xbc400ce0u, "ldr s0, [x7, #0]!"}, + {74, {0, 15, 0, 0}, 0xbc400de0u, "ldr s0, [x15, #0]!"}, + {74, {0, 31, 0, 0}, 0xbc400fe0u, "ldr s0, [sp, #0]!"}, + {74, {0, 0, 1, 0}, 0xbc401c00u, "ldr s0, [x0, #1]!"}, + {74, {0, 0, 7, 0}, 0xbc407c00u, "ldr s0, [x0, #7]!"}, + {74, {0, 0, 15, 0}, 0xbc40fc00u, "ldr s0, [x0, #15]!"}, + {74, {0, 0, 255, 0}, 0xbc4ffc00u, "ldr s0, [x0, #255]!"}, + {74, {0, 0, -1, 0}, 0xbc5ffc00u, "ldr s0, [x0, #-1]!"}, + {74, {0, 0, -256, 0}, 0xbc500c00u, "ldr s0, [x0, #-256]!"}, + {74, {0, 0, -7, 0}, 0xbc5f9c00u, "ldr s0, [x0, #-7]!"}, + {74, {15, 0, -7, 0}, 0xbc5f9c0fu, "ldr s15, [x0, #-7]!"}, + {74, {0, 15, 15, 0}, 0xbc40fde0u, "ldr s0, [x15, #15]!"}, + {74, {7, 1, -7, 0}, 0xbc5f9c27u, "ldr s7, [x1, #-7]!"}, + {74, {31, 31, 15, 0}, 0xbc40ffffu, "ldr s31, [sp, #15]!"}, + {75, {0, 0, 0, 0}, 0xfc400c00u, "ldr d0, [x0, #0]!"}, + {75, {1, 0, 0, 0}, 0xfc400c01u, "ldr d1, [x0, #0]!"}, + {75, {7, 0, 0, 0}, 0xfc400c07u, "ldr d7, [x0, #0]!"}, + {75, {15, 0, 0, 0}, 0xfc400c0fu, "ldr d15, [x0, #0]!"}, + {75, {31, 0, 0, 0}, 0xfc400c1fu, "ldr d31, [x0, #0]!"}, + {75, {0, 1, 0, 0}, 0xfc400c20u, "ldr d0, [x1, #0]!"}, + {75, {0, 7, 0, 0}, 0xfc400ce0u, "ldr d0, [x7, #0]!"}, + {75, {0, 15, 0, 0}, 0xfc400de0u, "ldr d0, [x15, #0]!"}, + {75, {0, 31, 0, 0}, 0xfc400fe0u, "ldr d0, [sp, #0]!"}, + {75, {0, 0, 1, 0}, 0xfc401c00u, "ldr d0, [x0, #1]!"}, + {75, {0, 0, 7, 0}, 0xfc407c00u, "ldr d0, [x0, #7]!"}, + {75, {0, 0, 15, 0}, 0xfc40fc00u, "ldr d0, [x0, #15]!"}, + {75, {0, 0, 255, 0}, 0xfc4ffc00u, "ldr d0, [x0, #255]!"}, + {75, {0, 0, -1, 0}, 0xfc5ffc00u, "ldr d0, [x0, #-1]!"}, + {75, {0, 0, -256, 0}, 0xfc500c00u, "ldr d0, [x0, #-256]!"}, + {75, {0, 0, -7, 0}, 0xfc5f9c00u, "ldr d0, [x0, #-7]!"}, + {75, {15, 0, -7, 0}, 0xfc5f9c0fu, "ldr d15, [x0, #-7]!"}, + {75, {0, 15, 15, 0}, 0xfc40fde0u, "ldr d0, [x15, #15]!"}, + {75, {7, 1, -7, 0}, 0xfc5f9c27u, "ldr d7, [x1, #-7]!"}, + {75, {31, 31, 15, 0}, 0xfc40ffffu, "ldr d31, [sp, #15]!"}, + {76, {0, 0, 0, 0}, 0xbc000c00u, "str s0, [x0, #0]!"}, + {76, {1, 0, 0, 0}, 0xbc000c01u, "str s1, [x0, #0]!"}, + {76, {7, 0, 0, 0}, 0xbc000c07u, "str s7, [x0, #0]!"}, + {76, {15, 0, 0, 0}, 0xbc000c0fu, "str s15, [x0, #0]!"}, + {76, {31, 0, 0, 0}, 0xbc000c1fu, "str s31, [x0, #0]!"}, + {76, {0, 1, 0, 0}, 0xbc000c20u, "str s0, [x1, #0]!"}, + {76, {0, 7, 0, 0}, 0xbc000ce0u, "str s0, [x7, #0]!"}, + {76, {0, 15, 0, 0}, 0xbc000de0u, "str s0, [x15, #0]!"}, + {76, {0, 31, 0, 0}, 0xbc000fe0u, "str s0, [sp, #0]!"}, + {76, {0, 0, 1, 0}, 0xbc001c00u, "str s0, [x0, #1]!"}, + {76, {0, 0, 7, 0}, 0xbc007c00u, "str s0, [x0, #7]!"}, + {76, {0, 0, 15, 0}, 0xbc00fc00u, "str s0, [x0, #15]!"}, + {76, {0, 0, 255, 0}, 0xbc0ffc00u, "str s0, [x0, #255]!"}, + {76, {0, 0, -1, 0}, 0xbc1ffc00u, "str s0, [x0, #-1]!"}, + {76, {0, 0, -256, 0}, 0xbc100c00u, "str s0, [x0, #-256]!"}, + {76, {0, 0, -7, 0}, 0xbc1f9c00u, "str s0, [x0, #-7]!"}, + {76, {15, 0, -7, 0}, 0xbc1f9c0fu, "str s15, [x0, #-7]!"}, + {76, {0, 15, 15, 0}, 0xbc00fde0u, "str s0, [x15, #15]!"}, + {76, {7, 1, -7, 0}, 0xbc1f9c27u, "str s7, [x1, #-7]!"}, + {76, {31, 31, 15, 0}, 0xbc00ffffu, "str s31, [sp, #15]!"}, + {77, {0, 0, 0, 0}, 0xfc000c00u, "str d0, [x0, #0]!"}, + {77, {1, 0, 0, 0}, 0xfc000c01u, "str d1, [x0, #0]!"}, + {77, {7, 0, 0, 0}, 0xfc000c07u, "str d7, [x0, #0]!"}, + {77, {15, 0, 0, 0}, 0xfc000c0fu, "str d15, [x0, #0]!"}, + {77, {31, 0, 0, 0}, 0xfc000c1fu, "str d31, [x0, #0]!"}, + {77, {0, 1, 0, 0}, 0xfc000c20u, "str d0, [x1, #0]!"}, + {77, {0, 7, 0, 0}, 0xfc000ce0u, "str d0, [x7, #0]!"}, + {77, {0, 15, 0, 0}, 0xfc000de0u, "str d0, [x15, #0]!"}, + {77, {0, 31, 0, 0}, 0xfc000fe0u, "str d0, [sp, #0]!"}, + {77, {0, 0, 1, 0}, 0xfc001c00u, "str d0, [x0, #1]!"}, + {77, {0, 0, 7, 0}, 0xfc007c00u, "str d0, [x0, #7]!"}, + {77, {0, 0, 15, 0}, 0xfc00fc00u, "str d0, [x0, #15]!"}, + {77, {0, 0, 255, 0}, 0xfc0ffc00u, "str d0, [x0, #255]!"}, + {77, {0, 0, -1, 0}, 0xfc1ffc00u, "str d0, [x0, #-1]!"}, + {77, {0, 0, -256, 0}, 0xfc100c00u, "str d0, [x0, #-256]!"}, + {77, {0, 0, -7, 0}, 0xfc1f9c00u, "str d0, [x0, #-7]!"}, + {77, {15, 0, -7, 0}, 0xfc1f9c0fu, "str d15, [x0, #-7]!"}, + {77, {0, 15, 15, 0}, 0xfc00fde0u, "str d0, [x15, #15]!"}, + {77, {7, 1, -7, 0}, 0xfc1f9c27u, "str d7, [x1, #-7]!"}, + {77, {31, 31, 15, 0}, 0xfc00ffffu, "str d31, [sp, #15]!"}, + {78, {0, 0, 0, 0}, 0xbc400400u, "ldr s0, [x0], #0"}, + {78, {1, 0, 0, 0}, 0xbc400401u, "ldr s1, [x0], #0"}, + {78, {7, 0, 0, 0}, 0xbc400407u, "ldr s7, [x0], #0"}, + {78, {15, 0, 0, 0}, 0xbc40040fu, "ldr s15, [x0], #0"}, + {78, {31, 0, 0, 0}, 0xbc40041fu, "ldr s31, [x0], #0"}, + {78, {0, 1, 0, 0}, 0xbc400420u, "ldr s0, [x1], #0"}, + {78, {0, 7, 0, 0}, 0xbc4004e0u, "ldr s0, [x7], #0"}, + {78, {0, 15, 0, 0}, 0xbc4005e0u, "ldr s0, [x15], #0"}, + {78, {0, 31, 0, 0}, 0xbc4007e0u, "ldr s0, [sp], #0"}, + {78, {0, 0, 1, 0}, 0xbc401400u, "ldr s0, [x0], #1"}, + {78, {0, 0, 7, 0}, 0xbc407400u, "ldr s0, [x0], #7"}, + {78, {0, 0, 15, 0}, 0xbc40f400u, "ldr s0, [x0], #15"}, + {78, {0, 0, 255, 0}, 0xbc4ff400u, "ldr s0, [x0], #255"}, + {78, {0, 0, -1, 0}, 0xbc5ff400u, "ldr s0, [x0], #-1"}, + {78, {0, 0, -256, 0}, 0xbc500400u, "ldr s0, [x0], #-256"}, + {78, {0, 0, -7, 0}, 0xbc5f9400u, "ldr s0, [x0], #-7"}, + {78, {15, 0, -7, 0}, 0xbc5f940fu, "ldr s15, [x0], #-7"}, + {78, {0, 15, 15, 0}, 0xbc40f5e0u, "ldr s0, [x15], #15"}, + {78, {7, 1, -7, 0}, 0xbc5f9427u, "ldr s7, [x1], #-7"}, + {78, {31, 31, 15, 0}, 0xbc40f7ffu, "ldr s31, [sp], #15"}, + {79, {0, 0, 0, 0}, 0xfc400400u, "ldr d0, [x0], #0"}, + {79, {1, 0, 0, 0}, 0xfc400401u, "ldr d1, [x0], #0"}, + {79, {7, 0, 0, 0}, 0xfc400407u, "ldr d7, [x0], #0"}, + {79, {15, 0, 0, 0}, 0xfc40040fu, "ldr d15, [x0], #0"}, + {79, {31, 0, 0, 0}, 0xfc40041fu, "ldr d31, [x0], #0"}, + {79, {0, 1, 0, 0}, 0xfc400420u, "ldr d0, [x1], #0"}, + {79, {0, 7, 0, 0}, 0xfc4004e0u, "ldr d0, [x7], #0"}, + {79, {0, 15, 0, 0}, 0xfc4005e0u, "ldr d0, [x15], #0"}, + {79, {0, 31, 0, 0}, 0xfc4007e0u, "ldr d0, [sp], #0"}, + {79, {0, 0, 1, 0}, 0xfc401400u, "ldr d0, [x0], #1"}, + {79, {0, 0, 7, 0}, 0xfc407400u, "ldr d0, [x0], #7"}, + {79, {0, 0, 15, 0}, 0xfc40f400u, "ldr d0, [x0], #15"}, + {79, {0, 0, 255, 0}, 0xfc4ff400u, "ldr d0, [x0], #255"}, + {79, {0, 0, -1, 0}, 0xfc5ff400u, "ldr d0, [x0], #-1"}, + {79, {0, 0, -256, 0}, 0xfc500400u, "ldr d0, [x0], #-256"}, + {79, {0, 0, -7, 0}, 0xfc5f9400u, "ldr d0, [x0], #-7"}, + {79, {15, 0, -7, 0}, 0xfc5f940fu, "ldr d15, [x0], #-7"}, + {79, {0, 15, 15, 0}, 0xfc40f5e0u, "ldr d0, [x15], #15"}, + {79, {7, 1, -7, 0}, 0xfc5f9427u, "ldr d7, [x1], #-7"}, + {79, {31, 31, 15, 0}, 0xfc40f7ffu, "ldr d31, [sp], #15"}, + {80, {0, 0, 0, 0}, 0xbc000400u, "str s0, [x0], #0"}, + {80, {1, 0, 0, 0}, 0xbc000401u, "str s1, [x0], #0"}, + {80, {7, 0, 0, 0}, 0xbc000407u, "str s7, [x0], #0"}, + {80, {15, 0, 0, 0}, 0xbc00040fu, "str s15, [x0], #0"}, + {80, {31, 0, 0, 0}, 0xbc00041fu, "str s31, [x0], #0"}, + {80, {0, 1, 0, 0}, 0xbc000420u, "str s0, [x1], #0"}, + {80, {0, 7, 0, 0}, 0xbc0004e0u, "str s0, [x7], #0"}, + {80, {0, 15, 0, 0}, 0xbc0005e0u, "str s0, [x15], #0"}, + {80, {0, 31, 0, 0}, 0xbc0007e0u, "str s0, [sp], #0"}, + {80, {0, 0, 1, 0}, 0xbc001400u, "str s0, [x0], #1"}, + {80, {0, 0, 7, 0}, 0xbc007400u, "str s0, [x0], #7"}, + {80, {0, 0, 15, 0}, 0xbc00f400u, "str s0, [x0], #15"}, + {80, {0, 0, 255, 0}, 0xbc0ff400u, "str s0, [x0], #255"}, + {80, {0, 0, -1, 0}, 0xbc1ff400u, "str s0, [x0], #-1"}, + {80, {0, 0, -256, 0}, 0xbc100400u, "str s0, [x0], #-256"}, + {80, {0, 0, -7, 0}, 0xbc1f9400u, "str s0, [x0], #-7"}, + {80, {15, 0, -7, 0}, 0xbc1f940fu, "str s15, [x0], #-7"}, + {80, {0, 15, 15, 0}, 0xbc00f5e0u, "str s0, [x15], #15"}, + {80, {7, 1, -7, 0}, 0xbc1f9427u, "str s7, [x1], #-7"}, + {80, {31, 31, 15, 0}, 0xbc00f7ffu, "str s31, [sp], #15"}, + {81, {0, 0, 0, 0}, 0xfc000400u, "str d0, [x0], #0"}, + {81, {1, 0, 0, 0}, 0xfc000401u, "str d1, [x0], #0"}, + {81, {7, 0, 0, 0}, 0xfc000407u, "str d7, [x0], #0"}, + {81, {15, 0, 0, 0}, 0xfc00040fu, "str d15, [x0], #0"}, + {81, {31, 0, 0, 0}, 0xfc00041fu, "str d31, [x0], #0"}, + {81, {0, 1, 0, 0}, 0xfc000420u, "str d0, [x1], #0"}, + {81, {0, 7, 0, 0}, 0xfc0004e0u, "str d0, [x7], #0"}, + {81, {0, 15, 0, 0}, 0xfc0005e0u, "str d0, [x15], #0"}, + {81, {0, 31, 0, 0}, 0xfc0007e0u, "str d0, [sp], #0"}, + {81, {0, 0, 1, 0}, 0xfc001400u, "str d0, [x0], #1"}, + {81, {0, 0, 7, 0}, 0xfc007400u, "str d0, [x0], #7"}, + {81, {0, 0, 15, 0}, 0xfc00f400u, "str d0, [x0], #15"}, + {81, {0, 0, 255, 0}, 0xfc0ff400u, "str d0, [x0], #255"}, + {81, {0, 0, -1, 0}, 0xfc1ff400u, "str d0, [x0], #-1"}, + {81, {0, 0, -256, 0}, 0xfc100400u, "str d0, [x0], #-256"}, + {81, {0, 0, -7, 0}, 0xfc1f9400u, "str d0, [x0], #-7"}, + {81, {15, 0, -7, 0}, 0xfc1f940fu, "str d15, [x0], #-7"}, + {81, {0, 15, 15, 0}, 0xfc00f5e0u, "str d0, [x15], #15"}, + {81, {7, 1, -7, 0}, 0xfc1f9427u, "str d7, [x1], #-7"}, + {81, {31, 31, 15, 0}, 0xfc00f7ffu, "str d31, [sp], #15"}, + {82, {0, 0, 0, 0}, 0xbc400000u, "ldur s0, [x0, #0]"}, + {82, {1, 0, 0, 0}, 0xbc400001u, "ldur s1, [x0, #0]"}, + {82, {7, 0, 0, 0}, 0xbc400007u, "ldur s7, [x0, #0]"}, + {82, {15, 0, 0, 0}, 0xbc40000fu, "ldur s15, [x0, #0]"}, + {82, {31, 0, 0, 0}, 0xbc40001fu, "ldur s31, [x0, #0]"}, + {82, {0, 1, 0, 0}, 0xbc400020u, "ldur s0, [x1, #0]"}, + {82, {0, 7, 0, 0}, 0xbc4000e0u, "ldur s0, [x7, #0]"}, + {82, {0, 15, 0, 0}, 0xbc4001e0u, "ldur s0, [x15, #0]"}, + {82, {0, 31, 0, 0}, 0xbc4003e0u, "ldur s0, [sp, #0]"}, + {82, {0, 0, 1, 0}, 0xbc401000u, "ldur s0, [x0, #1]"}, + {82, {0, 0, 7, 0}, 0xbc407000u, "ldur s0, [x0, #7]"}, + {82, {0, 0, 15, 0}, 0xbc40f000u, "ldur s0, [x0, #15]"}, + {82, {0, 0, 255, 0}, 0xbc4ff000u, "ldur s0, [x0, #255]"}, + {82, {0, 0, -1, 0}, 0xbc5ff000u, "ldur s0, [x0, #-1]"}, + {82, {0, 0, -256, 0}, 0xbc500000u, "ldur s0, [x0, #-256]"}, + {82, {0, 0, -7, 0}, 0xbc5f9000u, "ldur s0, [x0, #-7]"}, + {82, {15, 0, -7, 0}, 0xbc5f900fu, "ldur s15, [x0, #-7]"}, + {82, {0, 15, 15, 0}, 0xbc40f1e0u, "ldur s0, [x15, #15]"}, + {82, {7, 1, -7, 0}, 0xbc5f9027u, "ldur s7, [x1, #-7]"}, + {82, {31, 31, 15, 0}, 0xbc40f3ffu, "ldur s31, [sp, #15]"}, + {83, {0, 0, 0, 0}, 0xfc400000u, "ldur d0, [x0, #0]"}, + {83, {1, 0, 0, 0}, 0xfc400001u, "ldur d1, [x0, #0]"}, + {83, {7, 0, 0, 0}, 0xfc400007u, "ldur d7, [x0, #0]"}, + {83, {15, 0, 0, 0}, 0xfc40000fu, "ldur d15, [x0, #0]"}, + {83, {31, 0, 0, 0}, 0xfc40001fu, "ldur d31, [x0, #0]"}, + {83, {0, 1, 0, 0}, 0xfc400020u, "ldur d0, [x1, #0]"}, + {83, {0, 7, 0, 0}, 0xfc4000e0u, "ldur d0, [x7, #0]"}, + {83, {0, 15, 0, 0}, 0xfc4001e0u, "ldur d0, [x15, #0]"}, + {83, {0, 31, 0, 0}, 0xfc4003e0u, "ldur d0, [sp, #0]"}, + {83, {0, 0, 1, 0}, 0xfc401000u, "ldur d0, [x0, #1]"}, + {83, {0, 0, 7, 0}, 0xfc407000u, "ldur d0, [x0, #7]"}, + {83, {0, 0, 15, 0}, 0xfc40f000u, "ldur d0, [x0, #15]"}, + {83, {0, 0, 255, 0}, 0xfc4ff000u, "ldur d0, [x0, #255]"}, + {83, {0, 0, -1, 0}, 0xfc5ff000u, "ldur d0, [x0, #-1]"}, + {83, {0, 0, -256, 0}, 0xfc500000u, "ldur d0, [x0, #-256]"}, + {83, {0, 0, -7, 0}, 0xfc5f9000u, "ldur d0, [x0, #-7]"}, + {83, {15, 0, -7, 0}, 0xfc5f900fu, "ldur d15, [x0, #-7]"}, + {83, {0, 15, 15, 0}, 0xfc40f1e0u, "ldur d0, [x15, #15]"}, + {83, {7, 1, -7, 0}, 0xfc5f9027u, "ldur d7, [x1, #-7]"}, + {83, {31, 31, 15, 0}, 0xfc40f3ffu, "ldur d31, [sp, #15]"}, + {84, {0, 0, 0, 0}, 0xbc000000u, "stur s0, [x0, #0]"}, + {84, {1, 0, 0, 0}, 0xbc000001u, "stur s1, [x0, #0]"}, + {84, {7, 0, 0, 0}, 0xbc000007u, "stur s7, [x0, #0]"}, + {84, {15, 0, 0, 0}, 0xbc00000fu, "stur s15, [x0, #0]"}, + {84, {31, 0, 0, 0}, 0xbc00001fu, "stur s31, [x0, #0]"}, + {84, {0, 1, 0, 0}, 0xbc000020u, "stur s0, [x1, #0]"}, + {84, {0, 7, 0, 0}, 0xbc0000e0u, "stur s0, [x7, #0]"}, + {84, {0, 15, 0, 0}, 0xbc0001e0u, "stur s0, [x15, #0]"}, + {84, {0, 31, 0, 0}, 0xbc0003e0u, "stur s0, [sp, #0]"}, + {84, {0, 0, 1, 0}, 0xbc001000u, "stur s0, [x0, #1]"}, + {84, {0, 0, 7, 0}, 0xbc007000u, "stur s0, [x0, #7]"}, + {84, {0, 0, 15, 0}, 0xbc00f000u, "stur s0, [x0, #15]"}, + {84, {0, 0, 255, 0}, 0xbc0ff000u, "stur s0, [x0, #255]"}, + {84, {0, 0, -1, 0}, 0xbc1ff000u, "stur s0, [x0, #-1]"}, + {84, {0, 0, -256, 0}, 0xbc100000u, "stur s0, [x0, #-256]"}, + {84, {0, 0, -7, 0}, 0xbc1f9000u, "stur s0, [x0, #-7]"}, + {84, {15, 0, -7, 0}, 0xbc1f900fu, "stur s15, [x0, #-7]"}, + {84, {0, 15, 15, 0}, 0xbc00f1e0u, "stur s0, [x15, #15]"}, + {84, {7, 1, -7, 0}, 0xbc1f9027u, "stur s7, [x1, #-7]"}, + {84, {31, 31, 15, 0}, 0xbc00f3ffu, "stur s31, [sp, #15]"}, + {85, {0, 0, 0, 0}, 0xfc000000u, "stur d0, [x0, #0]"}, + {85, {1, 0, 0, 0}, 0xfc000001u, "stur d1, [x0, #0]"}, + {85, {7, 0, 0, 0}, 0xfc000007u, "stur d7, [x0, #0]"}, + {85, {15, 0, 0, 0}, 0xfc00000fu, "stur d15, [x0, #0]"}, + {85, {31, 0, 0, 0}, 0xfc00001fu, "stur d31, [x0, #0]"}, + {85, {0, 1, 0, 0}, 0xfc000020u, "stur d0, [x1, #0]"}, + {85, {0, 7, 0, 0}, 0xfc0000e0u, "stur d0, [x7, #0]"}, + {85, {0, 15, 0, 0}, 0xfc0001e0u, "stur d0, [x15, #0]"}, + {85, {0, 31, 0, 0}, 0xfc0003e0u, "stur d0, [sp, #0]"}, + {85, {0, 0, 1, 0}, 0xfc001000u, "stur d0, [x0, #1]"}, + {85, {0, 0, 7, 0}, 0xfc007000u, "stur d0, [x0, #7]"}, + {85, {0, 0, 15, 0}, 0xfc00f000u, "stur d0, [x0, #15]"}, + {85, {0, 0, 255, 0}, 0xfc0ff000u, "stur d0, [x0, #255]"}, + {85, {0, 0, -1, 0}, 0xfc1ff000u, "stur d0, [x0, #-1]"}, + {85, {0, 0, -256, 0}, 0xfc100000u, "stur d0, [x0, #-256]"}, + {85, {0, 0, -7, 0}, 0xfc1f9000u, "stur d0, [x0, #-7]"}, + {85, {15, 0, -7, 0}, 0xfc1f900fu, "stur d15, [x0, #-7]"}, + {85, {0, 15, 15, 0}, 0xfc00f1e0u, "stur d0, [x15, #15]"}, + {85, {7, 1, -7, 0}, 0xfc1f9027u, "stur d7, [x1, #-7]"}, + {85, {31, 31, 15, 0}, 0xfc00f3ffu, "stur d31, [sp, #15]"}, + {86, {0, 0, 0, 0}, 0x54000000u, "b.eq .+0"}, + {86, {1, 0, 0, 0}, 0x54000001u, "b.ne .+0"}, + {86, {4, 0, 0, 0}, 0x54000004u, "b.mi .+0"}, + {86, {6, 0, 0, 0}, 0x54000006u, "b.vs .+0"}, + {86, {8, 0, 0, 0}, 0x54000008u, "b.hi .+0"}, + {86, {9, 0, 0, 0}, 0x54000009u, "b.ls .+0"}, + {86, {10, 0, 0, 0}, 0x5400000au, "b.ge .+0"}, + {86, {11, 0, 0, 0}, 0x5400000bu, "b.lt .+0"}, + {86, {12, 0, 0, 0}, 0x5400000cu, "b.gt .+0"}, + {86, {13, 0, 0, 0}, 0x5400000du, "b.le .+0"}, + {86, {0, 1, 0, 0}, 0x54000020u, "b.eq .+4"}, + {86, {0, 7, 0, 0}, 0x540000e0u, "b.eq .+28"}, + {86, {0, 15, 0, 0}, 0x540001e0u, "b.eq .+60"}, + {86, {0, -1, 0, 0}, 0x54ffffe0u, "b.eq .-4"}, + {86, {0, -4, 0, 0}, 0x54ffff80u, "b.eq .-16"}, + {86, {0, 262143, 0, 0}, 0x547fffe0u, "b.eq .+1048572"}, + {86, {0, -262144, 0, 0}, 0x54800000u, "b.eq .-1048576"}, + {86, {6, -4, 0, 0}, 0x54ffff86u, "b.vs .-16"}, + {86, {9, 0, 0, 0}, 0x54000009u, "b.ls .+0"}, + {86, {11, 15, 0, 0}, 0x540001ebu, "b.lt .+60"}, + {86, {13, 262143, 0, 0}, 0x547fffedu, "b.le .+1048572"}, + }; + unsigned bad = 0, n = (unsigned)(sizeof t / sizeof t[0]); + for (unsigned i = 0; i < n; i++) { + uint32_t got = a64_golden_encode(t[i].form, t[i].a); + if (got != t[i].want) { bad++; if (bad_out) bad_out(t[i].asm_text, t[i].want, got); } + } + if (nsamples) *nsamples = n; + return bad; +} + +#endif /* AARCH64_FP_GOLDEN_H */ diff --git a/tests/compiler/determinism.sh b/tests/compiler/determinism.sh index 241006960..473dda62e 100755 --- a/tests/compiler/determinism.sh +++ b/tests/compiler/determinism.sh @@ -23,9 +23,9 @@ else esac done # shellcheck disable=SC2086 - nice cc -std=gnu11 -Wall -Wextra -Werror -D_GNU_SOURCE -O2 \ + nice cc -std=gnu11 -Wall -Wextra -Werror -D_GNU_SOURCE -O2 -ffp-contract=off -fno-fast-math -fno-math-errno \ -I"$root/src" -I"$root/src/compiler" -I"$root/src/compiler/model" \ - -o "$oscc" "$root/src/compiler/oscc_main.c" $srcs "$root/src/sha256.c" || { + -o "$oscc" "$root/src/compiler/oscc_main.c" $srcs "$root/src/sha256.c" -lm || { echo "OSC1_DETERMINISM_FAIL build" exit 1 } diff --git a/tests/compiler/float_oracle.c b/tests/compiler/float_oracle.c new file mode 100644 index 000000000..91ea8ee8a --- /dev/null +++ b/tests/compiler/float_oracle.c @@ -0,0 +1,291 @@ +/* + * float_oracle.c -- the C reference that produced every `// expect-run:` value of the + * OSC-4 Slice A float golden programs (tests/compiler/progs/f_*.osc). + * + * Each OSC function is re-spelled in C one operation per source operation, with the + * inputs in volatile locals so nothing is folded at compile time and every rounding + * step happens on this CPU, under the same flags as the compiler + * (-O2 -ffp-contract=off -fno-fast-math -fno-math-errno, mk/compiler.mk OSC_CFLAGS). + * It prints one line per expect-run, in the exact text of the program headers, so + * `make test-compiler-float-oracle` can diff the two: a changed expectation that the + * oracle does not reproduce fails the target. + * + * Where C leaves a conversion undefined (float -> int out of range, NaN -> int) the + * oracle spells the FCVTZS/FCVTZU rule out (truncate, saturate, NaN -> 0); min/max + * spell out the FMINNM/FMAXNM rule (docs/osc/OSC-4-DESIGN.md 1.1 item 6). Those two + * rules are the design's own and are stated here independently of src/compiler/osc_interp.c. + * No Python, no libm beyond sqrt/sqrtf/fabs/fabsf (all inlined to one instruction). + */ +#include +#include +#include +#include +#include + +static uint64_t b32(float f) { uint32_t w; memcpy(&w, &f, 4); return w; } +static uint64_t b64(double d) { uint64_t w; memcpy(&w, &d, 8); return w; } +static float f32(uint64_t w) { uint32_t x = (uint32_t)w; float f; memcpy(&f, &x, 4); return f; } +static double f64(uint64_t w) { double d; memcpy(&d, &w, 8); return d; } + +/* one expect-run line: NAME, the argument text exactly as the program header spells it, the value */ +static void hexline(const char *name, const char *args, uint64_t v) { printf("%s%s%s -> %#llx\n", name, *args ? " " : "", args, (unsigned long long)v); } +static void sline(const char *name, const char *args, int64_t v) { printf("%s%s%s -> %lld\n", name, *args ? " " : "", args, (long long)v); } +static void uline(const char *name, const char *args, uint64_t v) { printf("%s%s%s -> %llu\n", name, *args ? " " : "", args, (unsigned long long)v); } + +/* FCVTZS / FCVTZU: truncate toward zero, saturate to the destination, NaN -> 0 */ +static int64_t ftoi_s(double x, unsigned w) { + if (x != x) return 0; + double half = (double)(1ULL << (w - 1)); + int64_t mx = (int64_t)((1ULL << (w - 1)) - 1), mn = -mx - 1; + if (x >= half) return mx; + if (x <= -half) return mn; + return (int64_t)x; +} +static uint64_t ftoi_u(double x, unsigned w) { + if (x != x || x <= 0.0) return 0; + double top = (double)(1ULL << (w - 1)) * 2.0; + if (x >= top) return w == 64 ? UINT64_MAX : (1ULL << w) - 1; + return (uint64_t)x; +} +/* FMINNM / FMAXNM on f64 bit patterns */ +static int isnan64(uint64_t a) { return (a & 0x7ff0000000000000ull) == 0x7ff0000000000000ull && (a & 0x000fffffffffffffull); } +static int issnan64(uint64_t a) { return isnan64(a) && !(a & 0x0008000000000000ull); } +static uint64_t minmax64(uint64_t a, uint64_t b, int is_max) { + if (isnan64(a) || isnan64(b)) { + if (issnan64(a)) return a | 0x0008000000000000ull; + if (issnan64(b)) return b | 0x0008000000000000ull; + if (isnan64(a) && isnan64(b)) return a; + return isnan64(a) ? b : a; + } + volatile double x = f64(a), y = f64(b); + if (x == y) { int neg_a = (a >> 63) != 0; return is_max ? (neg_a ? b : a) : (neg_a ? a : b); } + return is_max ? (x < y ? b : a) : (x < y ? a : b); +} + +/* ---------------------------------------------------------------- f_adam_step.osc */ +static float adam32(uint64_t P, uint64_t G, uint64_t M, uint64_t V) { + volatile float p = f32(P), g = f32(G), m = f32(M), v = f32(V); + volatile float b1 = 0.9f, b2 = 0.999f, lr = 0.001f, eps = 1.0e-8f; + float m1 = b1 * m + (1.0f - b1) * g; + float v1 = b2 * v + (1.0f - b2) * (g * g); + float mh = m1 / (1.0f - b1); + float vh = v1 / (1.0f - b2); + return p - lr * mh / (sqrtf(vh) + eps); +} +static double adam64(uint64_t P, uint64_t G, uint64_t M, uint64_t V) { + volatile double p = f64(P), g = f64(G), m = f64(M), v = f64(V); + volatile double b1 = 0.9, b2 = 0.999, lr = 0.001, eps = 1.0e-8; + double m1 = b1 * m + (1.0 - b1) * g; + double v1 = b2 * v + (1.0 - b2) * (g * g); + double mh = m1 / (1.0 - b1); + double vh = v1 / (1.0 - b2); + return p - lr * mh / (sqrt(vh) + eps); +} +static float lerp(uint64_t A, uint64_t B, uint64_t T) { volatile float a = f32(A), b = f32(B), t = f32(T); return a + (b - a) * t; } +static float sumsq(uint64_t X) { + volatile float x = f32(X), s = 0.0f; + for (int i = 0; i < 4; i++) s = s + x * x; + return s; +} +static void f_adam_step(void) { + hexline("adam32", "0x3f800000 0x3f000000 0 0", b32(adam32(0x3f800000, 0x3f000000, 0, 0))); + hexline("adam32", "0xc0200000 0x3dcccccd 0x3e4ccccd 0x3e99999a", b32(adam32(0xc0200000, 0x3dcccccd, 0x3e4ccccd, 0x3e99999a))); + hexline("adam64", "0x3ff0000000000000 0x3fe0000000000000 0 0", b64(adam64(0x3ff0000000000000ull, 0x3fe0000000000000ull, 0, 0))); + hexline("adam64", "0xc004000000000000 0x3fb999999999999a 0x3fc999999999999a 0x3fd3333333333333", + b64(adam64(0xc004000000000000ull, 0x3fb999999999999aull, 0x3fc999999999999aull, 0x3fd3333333333333ull))); + hexline("lerp", "0x3f800000 0x40400000 0x3e800000", b32(lerp(0x3f800000, 0x40400000, 0x3e800000))); + hexline("sumsq", "0x3dcccccd", b32(sumsq(0x3dcccccd))); +} + +/* ---------------------------------------------------------------- f_cast_sat.osc */ +static void f_cast_sat(void) { + sline("f2i32", "0x4f000000", ftoi_s(f32(0x4f000000), 32)); + sline("f2i32", "0xcf000001", ftoi_s(f32(0xcf000001), 32)); + sline("f2i32", "0xc0490fd0", ftoi_s(f32(0xc0490fd0), 32)); + sline("f2i32", "0x7fc00000", ftoi_s(f32(0x7fc00000), 32)); + sline("f2i32", "0xff800000", ftoi_s(f32(0xff800000), 32)); + uline("f2u32", "0xbf800000", ftoi_u(f32(0xbf800000), 32)); + uline("f2u32", "0x4f000000", ftoi_u(f32(0x4f000000), 32)); + uline("f2u32", "0x7f800000", ftoi_u(f32(0x7f800000), 32)); + uline("f2u32", "0x40490fd0", ftoi_u(f32(0x40490fd0), 32)); + sline("f2i64", "0x7ff0000000000000", ftoi_s(f64(0x7ff0000000000000ull), 64)); + sline("f2i64", "0xfff0000000000000", ftoi_s(f64(0xfff0000000000000ull), 64)); + sline("f2i64", "0xc004000000000000", ftoi_s(f64(0xc004000000000000ull), 64)); + sline("f2i64", "0x7ff8000000000000", ftoi_s(f64(0x7ff8000000000000ull), 64)); + uline("f2u64", "0x43f0000000000000", ftoi_u(f64(0x43f0000000000000ull), 64)); + uline("f2u64", "0xbff8000000000000", ftoi_u(f64(0xbff8000000000000ull), 64)); + uline("f2u64", "0x40f0000000000000", ftoi_u(f64(0x40f0000000000000ull), 64)); + { volatile int64_t x = 16777217; hexline("i2f", "16777217", b32((float)x)); } + { volatile int64_t x = 16777219; hexline("i2f", "16777219", b32((float)x)); } + { volatile int64_t x = -1; hexline("i2f", "-1", b32((float)x)); } + { volatile uint64_t x = 18446744073709551615ull; hexline("u2d", "18446744073709551615", b64((double)x)); } + { volatile uint64_t x = 9007199254740993ull; hexline("u2d", "9007199254740993", b64((double)x)); } + { volatile double x = f64(0x3ff0000010000000ull); hexline("d2f", "0x3ff0000010000000", b32((float)x)); } + { volatile double x = f64(0x7e37e43c8800759cull); hexline("d2f", "0x7e37e43c8800759c", b32((float)x)); } + { volatile double x = f64(0xbff8000000000000ull); hexline("d2f", "0xbff8000000000000", b32((float)x)); } + { volatile float x = f32(0x3f800000); hexline("f2d", "0x3f800000", b64((double)x)); } + { volatile float x = f32(0xffc00000); hexline("f2d", "0xffc00000", b64((double)x)); } + { volatile uint8_t x = 200; hexline("i2f_small", "200", b32((float)x)); } +} + +/* ---------------------------------------------------------------- f_nan_cmp.osc */ +static uint64_t cmp64(uint64_t A, uint64_t B) { + volatile double a = f64(A), b = f64(B); + uint64_t r = 0; + if (a == b) r |= 1; + if (a != b) r |= 2; + if (a < b) r |= 4; + if (a <= b) r |= 8; + if (a > b) r |= 16; + if (a >= b) r |= 32; + return r; +} +static uint64_t cmp32(uint64_t A, uint64_t B) { + volatile float a = f32(A), b = f32(B); + uint64_t r = 0; + if (a == b) r |= 1; + if (a != b) r |= 2; + if (a < b) r |= 4; + if (a <= b) r |= 8; + if (a > b) r |= 16; + if (a >= b) r |= 32; + return r; +} +static void f_nan_cmp(void) { + uline("cmp64", "0x3ff0000000000000 0x4000000000000000", cmp64(0x3ff0000000000000ull, 0x4000000000000000ull)); + uline("cmp64", "0x4000000000000000 0x4000000000000000", cmp64(0x4000000000000000ull, 0x4000000000000000ull)); + uline("cmp64", "0x4000000000000000 0x3ff0000000000000", cmp64(0x4000000000000000ull, 0x3ff0000000000000ull)); + uline("cmp64", "0x7ff8000000000000 0x3ff0000000000000", cmp64(0x7ff8000000000000ull, 0x3ff0000000000000ull)); + uline("cmp64", "0x3ff0000000000000 0x7ff0000000000001", cmp64(0x3ff0000000000000ull, 0x7ff0000000000001ull)); + uline("cmp64", "0x7ff8000000000000 0x7ff8000000000000", cmp64(0x7ff8000000000000ull, 0x7ff8000000000000ull)); + uline("cmp64", "0x8000000000000000 0", cmp64(0x8000000000000000ull, 0)); + uline("cmp32", "0x7fc00000 0x7fc00000", cmp32(0x7fc00000, 0x7fc00000)); + uline("cmp32", "0x80000000 0", cmp32(0x80000000, 0)); + uline("cmp32", "0xff800000 0x7f800000", cmp32(0xff800000, 0x7f800000)); + static const uint64_t props[6][2] = { + {0x7ff0000000000001ull, 0x3ff0000000000000ull}, {0x3ff0000000000000ull, 0x7ff0000000000001ull}, + {0x7ff80000000000abull, 0x4000000000000000ull}, {0x7ff0000000000000ull, 0x7ff0000000000000ull}, + {0x7ff0000000000001ull, 0x7ff80000000000abull}, {0x7ff80000000000abull, 0x7ff0000000000001ull}}; + for (int i = 0; i < 6; i++) { + char args[64]; + snprintf(args, sizeof args, "%#llx %#llx", (unsigned long long)props[i][0], (unsigned long long)props[i][1]); + volatile double a = f64(props[i][0]), b = f64(props[i][1]); + hexline("prop", args, b64(a - b)); + } + static const uint64_t negs[3] = {0x7ff80000000000abull, 0xfff80000000000abull, 0x3ff0000000000000ull}; + for (int i = 0; i < 3; i++) { + char args[32]; + snprintf(args, sizeof args, "%#llx", (unsigned long long)negs[i]); + volatile double a = f64(negs[i]); + hexline("neg_abs", args, b64(fabs(-a))); + } + static const struct { uint64_t a, b; int which; const char *txt; } mm[] = { + {0x7ff0000000000001ull, 0x3ff0000000000000ull, 0, "0x7ff0000000000001 0x3ff0000000000000 0"}, + {0x7ff8000000000000ull, 0x3ff0000000000000ull, 0, "0x7ff8000000000000 0x3ff0000000000000 0"}, + {0x3ff0000000000000ull, 0x7ff8000000000000ull, 1, "0x3ff0000000000000 0x7ff8000000000000 1"}, + {0x7ff80000000000abull, 0x7ff8000000000000ull, 1, "0x7ff80000000000ab 0x7ff8000000000000 1"}, + {0x7ff8000000000000ull, 0x7ff0000000000001ull, 1, "0x7ff8000000000000 0x7ff0000000000001 1"}, + {0x8000000000000000ull, 0, 0, "0x8000000000000000 0 0"}, + {0, 0x8000000000000000ull, 0, "0 0x8000000000000000 0"}, + {0x8000000000000000ull, 0, 1, "0x8000000000000000 0 1"}, + {0, 0x8000000000000000ull, 1, "0 0x8000000000000000 1"}, + {0x3ff0000000000000ull, 0x4000000000000000ull, 0, "0x3ff0000000000000 0x4000000000000000 0"}, + {0x3ff0000000000000ull, 0x4000000000000000ull, 1, "0x3ff0000000000000 0x4000000000000000 1"}, + }; + for (size_t i = 0; i < sizeof mm / sizeof mm[0]; i++) hexline("minmax", mm[i].txt, minmax64(mm[i].a, mm[i].b, mm[i].which)); + { volatile double a = f64(0xbff0000000000000ull); hexline("sqrt64", "0xbff0000000000000", b64(sqrt(a))); } + { volatile double a = f64(0x4000000000000000ull); hexline("sqrt64", "0x4000000000000000", b64(sqrt(a))); } + hexline("bits_rt", "0x7ff0000000000001", 0x7ff0000000000001ull); /* bit casts move no value */ + hexline("bits_rt", "0x8000000000000000", 0x8000000000000000ull); +} + +/* ---------------------------------------------------------------- f_neg_zero.osc */ +static void f_neg_zero(void) { + { volatile float x = f32(0); hexline("neg", "0", b32(-x)); } + { volatile float x = f32(0x80000000); hexline("neg", "0x80000000", b32(-x)); } + { volatile float x = f32(0x3f800000); hexline("neg", "0x3f800000", b32(-x)); } + { volatile float x = f32(0); hexline("zero_minus", "0", b32(0.0f - x)); } + { volatile float x = f32(0x80000000); hexline("zero_minus", "0x80000000", b32(0.0f - x)); } + hexline("neg_lit", "0", b32(-0.0f)); + hexline("neg_lit", "1", b32(-1.5f)); + { volatile float x = f32(0x80000000); uline("eq_zero", "0x80000000", x == 0.0f); } + { volatile float x = f32(0); uline("eq_zero", "0", x == 0.0f); } + { volatile float x = f32(0x3f800000); uline("eq_zero", "0x3f800000", x == 0.0f); } + { volatile float x = f32(0x3f800000), nz = -0.0f; hexline("div_nz", "0x3f800000", b32(x / nz)); } + { volatile float x = f32(0xbf800000), nz = -0.0f; hexline("div_nz", "0xbf800000", b32(x / nz)); } + { volatile float x = f32(0x80000000); hexline("abs_nz", "0x80000000", b32(fabsf(x))); } + { volatile float x = f32(0x80000000); hexline("sqrt_nz", "0x80000000", b32(sqrtf(x))); } + uline("sign_bit", "0x80000000", 0x80000000u >> 31); + uline("sign_bit", "0", 0u >> 31); + hexline("from_bits", "2147483648", 2147483648ull); + hexline("from_bits", "1065353216", 1065353216ull); + hexline("lit_bits", "0", b32(-0.0f)); + hexline("lit_bits", "1", b64(-0.0)); + { volatile double nz = -0.0; hexline("sub_mul", "0", b64(nz + 0.0)); } + { volatile double nz = -0.0; hexline("sub_mul", "1", b64(nz * 1.0)); } +} + +/* ---------------------------------------------------------------- f_array_dot.osc */ +static double dot(uint32_t seed) { + volatile double a[8], b[8], s = 0.0; + for (int i = 0; i < 8; i++) { b[i] = 1.5; volatile int64_t k = (int64_t)seed + i; a[i] = (double)k * 0.5; } + for (int i = 0; i < 8; i++) s = s + a[i] * b[i]; + return s; +} +static float fill_sum(uint64_t X) { + volatile float a[4], s = 0.0f; + for (int i = 0; i < 4; i++) a[i] = f32(X); + for (int i = 0; i < 4; i++) s = s + a[i]; + return s; +} +static double scale_ref(uint64_t X) { + volatile double a[5]; + for (int i = 0; i < 5; i++) a[i] = f64(X); + for (int i = 0; i < 5; i++) a[i] = a[i] * 5.0; + return a[4] * 2.0; +} +static double ret_arr(uint8_t k) { + volatile double a[2] = {0.0, 0.0}; + volatile double v = (double)k - 1.0; + a[0] = v; + a[1] = a[0] + 1.0; + return a[1]; +} +static double widen_sum(uint64_t X) { + volatile float a[4]; + volatile double s = 0.0; + for (int i = 0; i < 4; i++) a[i] = f32(X); + for (int i = 0; i < 4; i++) s = s + (double)a[i]; + return s; +} +static void f_array_dot(void) { + hexline("dot", "0", b64(dot(0))); + hexline("dot", "4", b64(dot(4))); + hexline("fill_sum", "0x3dcccccd", b32(fill_sum(0x3dcccccd))); + hexline("fill_sum", "0x7fc00000", b32(fill_sum(0x7fc00000))); + hexline("scale_ref", "0x4000000000000000", b64(scale_ref(0x4000000000000000ull))); + hexline("ret_arr", "3", b64(ret_arr(3))); + hexline("widen_sum", "0x3dcccccd", b64(widen_sum(0x3dcccccd))); +} + +/* ---------------------------------------------------------------- f_literals.osc */ +static void f_literals(void) { + char s[80] = "0."; + memset(s + 2, '0', 60); + s[62] = '1'; + s[63] = 0; /* 63 characters: the longest literal the lexer accepts */ + hexline("tiny63", "", b64(strtod(s, NULL))); + hexline("tiny_e", "", b64(strtod("1.0e-161", NULL))); + hexline("tiny32", "", b32(strtof("0.0000000000000000000000000000001", NULL))); + hexline("one_e", "", b64(strtod("10.0e-1", NULL))); +} + +int main(void) { + f_adam_step(); + f_cast_sat(); + f_nan_cmp(); + f_neg_zero(); + f_array_dot(); + f_literals(); + return 0; +} diff --git a/tests/compiler/neg/.crumb b/tests/compiler/neg/.crumb index 32e2bc448..313f1681b 100644 --- a/tests/compiler/neg/.crumb +++ b/tests/compiler/neg/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-08T00:52:33Z", + "compiled_at": "2026-10-16T20:35:19Z", "compiler": "crumb-compile/1", - "digest": "sha256:52f60db8cad897bd1ad36a41cff28e90ad3ccd0e734555a8325701f1a9e9ba7b", + "digest": "sha256:7544331758567b00eef6404ec6694a271941193a664f062f80c7b5c3b1e1d947", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 138, - "generated_at_commit": "eb8dedf75dfdf6cdeaee122ac8c7db90539c28e4", - "source_tree": "sha256:4ac509c1ae1b346d06ad7be106ae2dffeef4e537879f780b56c8dd7721bb62bf" + "files": 159, + "generated_at_commit": "cde3c1d51cc2106f965ed34c6ae82d311d1b490a", + "source_tree": "sha256:d4782f77bc72827d4600d301500ecef9124b43b52c306a7595dc06e404f7eac3" }, "owner_lane": "", "provenance": { diff --git a/tests/compiler/neg/float_ambiguous.osc b/tests/compiler/neg/float_ambiguous.osc new file mode 100644 index 000000000..ae5a85d5e --- /dev/null +++ b/tests/compiler/neg/float_ambiguous.osc @@ -0,0 +1,6 @@ +// expect: AMBIGUOUS_WIDTH object=y line=4 +// a bare float literal as the source of `as` has no width. +fn f() -> f64 { + let y: f64 = 1.5 as f64; + return y; +} diff --git a/tests/compiler/neg/float_bitop.osc b/tests/compiler/neg/float_bitop.osc new file mode 100644 index 000000000..d250ed182 --- /dev/null +++ b/tests/compiler/neg/float_bitop.osc @@ -0,0 +1,6 @@ +// expect: FLOAT_BITOP object=y line=4 +// `%` has no float form (no FMOD, no rounding intrinsics). +fn f(a: f32, b: f32) -> f32 { + let y: f32 = a % b; + return y; +} diff --git a/tests/compiler/neg/float_bitop_and.osc b/tests/compiler/neg/float_bitop_and.osc new file mode 100644 index 000000000..457667e0d --- /dev/null +++ b/tests/compiler/neg/float_bitop_and.osc @@ -0,0 +1,5 @@ +// expect: FLOAT_BITOP object=y line=3 +fn f(a: f64, b: f64) -> f64 { + let y: f64 = a & b; + return y; +} diff --git a/tests/compiler/neg/float_bitop_shift.osc b/tests/compiler/neg/float_bitop_shift.osc new file mode 100644 index 000000000..379c8a844 --- /dev/null +++ b/tests/compiler/neg/float_bitop_shift.osc @@ -0,0 +1,5 @@ +// expect: FLOAT_BITOP object=return line=4 +// shifts and bit operators are refused on floats; use `as u64 bits` first. +fn f(a: f64) -> f64 { + return a << 1; +} diff --git a/tests/compiler/neg/float_bitop_tilde.osc b/tests/compiler/neg/float_bitop_tilde.osc new file mode 100644 index 000000000..bca0ab1c4 --- /dev/null +++ b/tests/compiler/neg/float_bitop_tilde.osc @@ -0,0 +1,6 @@ +// expect: FLOAT_BITOP object=y line=4 +// unary `~` is a bit operator and is refused on floats. +fn f(a: f32) -> f32 { + let y: f32 = ~a; + return y; +} diff --git a/tests/compiler/neg/float_bits_not_float.osc b/tests/compiler/neg/float_bits_not_float.osc new file mode 100644 index 000000000..3dbe5bb53 --- /dev/null +++ b/tests/compiler/neg/float_bits_not_float.osc @@ -0,0 +1,3 @@ +// expect: FLOAT_BITS_WIDTH object=return line=3 +// `bits` needs exactly one float side. +fn f(x: u32) -> i32 { return x as i32 bits; } diff --git a/tests/compiler/neg/float_bits_width.osc b/tests/compiler/neg/float_bits_width.osc new file mode 100644 index 000000000..6f8b2f564 --- /dev/null +++ b/tests/compiler/neg/float_bits_width.osc @@ -0,0 +1,3 @@ +// expect: FLOAT_BITS_WIDTH object=return line=3 +// bit casts keep the width: f32 only to/from u32/i32, f64 only to/from u64/i64. +fn f(x: f32) -> u64 { return x as u64 bits; } diff --git a/tests/compiler/neg/float_bits_width_from.osc b/tests/compiler/neg/float_bits_width_from.osc new file mode 100644 index 000000000..4663fac92 --- /dev/null +++ b/tests/compiler/neg/float_bits_width_from.osc @@ -0,0 +1,2 @@ +// expect: FLOAT_BITS_WIDTH object=return line=2 +fn f(x: u64) -> f32 { return x as f32 bits; } diff --git a/tests/compiler/neg/float_cast_bool.osc b/tests/compiler/neg/float_cast_bool.osc new file mode 100644 index 000000000..bea89c732 --- /dev/null +++ b/tests/compiler/neg/float_cast_bool.osc @@ -0,0 +1,3 @@ +// expect: TYPE_MISMATCH object=return line=3 +// `as` to a float needs an int or float source; bool is neither. +fn f(b: bool) -> f32 { return b as f32; } diff --git a/tests/compiler/neg/float_const_range.osc b/tests/compiler/neg/float_const_range.osc new file mode 100644 index 000000000..d7a64f846 --- /dev/null +++ b/tests/compiler/neg/float_const_range.osc @@ -0,0 +1,6 @@ +// expect: FLOAT_CONST_RANGE object=y line=4 +// a literal that rounds to inf in its type is refused at compile time. +fn f() -> f32 { + let y: f32 = 1.0e39; + return y; +} diff --git a/tests/compiler/neg/float_const_range_f64.osc b/tests/compiler/neg/float_const_range_f64.osc new file mode 100644 index 000000000..fe95201d9 --- /dev/null +++ b/tests/compiler/neg/float_const_range_f64.osc @@ -0,0 +1,2 @@ +// expect: FLOAT_CONST_RANGE object=return line=2 +fn f() -> f64 { return 1.0e400; } diff --git a/tests/compiler/neg/float_index.osc b/tests/compiler/neg/float_index.osc new file mode 100644 index 000000000..43b96ae91 --- /dev/null +++ b/tests/compiler/neg/float_index.osc @@ -0,0 +1,3 @@ +// expect: FLOAT_INDEX object=a line=3 +// a float is never an array index. +fn f(a: &[u32; 8], x: f32) -> u32 { return a[x]; } diff --git a/tests/compiler/neg/float_index_bound.osc b/tests/compiler/neg/float_index_bound.osc new file mode 100644 index 000000000..208f5e31d --- /dev/null +++ b/tests/compiler/neg/float_index_bound.osc @@ -0,0 +1,7 @@ +// expect: FLOAT_INDEX object=for line=5 +// a float is never a loop bound or range end. +fn f() -> u32 { + let mut s: u32 = 0; + for i in 0 .. 2.5 { s = s + 1; } + return s; +} diff --git a/tests/compiler/neg/float_index_while.osc b/tests/compiler/neg/float_index_while.osc new file mode 100644 index 000000000..a3b4baf7a --- /dev/null +++ b/tests/compiler/neg/float_index_while.osc @@ -0,0 +1,6 @@ +// expect: FLOAT_INDEX object=bound line=4 +fn f() -> u32 { + let mut s: u32 = 0; + while s < 10 bound 4.0 { s = s + 1; } + return s; +} diff --git a/tests/compiler/neg/float_int_literal.osc b/tests/compiler/neg/float_int_literal.osc new file mode 100644 index 000000000..eab71a17d --- /dev/null +++ b/tests/compiler/neg/float_int_literal.osc @@ -0,0 +1,6 @@ +// expect: TYPE_MISMATCH object=y line=4 +// integer literals are not float literals: write 3.0. +fn f() -> f32 { + let y: f32 = 3; + return y; +} diff --git a/tests/compiler/neg/float_intrin_int.osc b/tests/compiler/neg/float_intrin_int.osc new file mode 100644 index 000000000..12ac1f18e --- /dev/null +++ b/tests/compiler/neg/float_intrin_int.osc @@ -0,0 +1,3 @@ +// expect: TYPE_MISMATCH object=return line=3 +// sqrt/abs/min/max take one float type only. +fn f(x: u32) -> u32 { return sqrt(x); } diff --git a/tests/compiler/neg/float_literal_int.osc b/tests/compiler/neg/float_literal_int.osc new file mode 100644 index 000000000..8b277fbb5 --- /dev/null +++ b/tests/compiler/neg/float_literal_int.osc @@ -0,0 +1,6 @@ +// expect: TYPE_MISMATCH object=y line=4 +// a float literal where an integer is required. +fn f() -> u32 { + let y: u32 = 3.0; + return y; +} diff --git a/tests/compiler/neg/float_literal_too_long.osc b/tests/compiler/neg/float_literal_too_long.osc new file mode 100644 index 000000000..e7be67445 --- /dev/null +++ b/tests/compiler/neg/float_literal_too_long.osc @@ -0,0 +1,2 @@ +// expect: CAPACITY object=0.0000000000000000000000000000000000000000000000000000000000000 line=2 +fn tiny() -> f64 { return 0.00000000000000000000000000000000000000000000000000000000000001; } diff --git a/tests/compiler/neg/float_mixed.osc b/tests/compiler/neg/float_mixed.osc new file mode 100644 index 000000000..4587f922a --- /dev/null +++ b/tests/compiler/neg/float_mixed.osc @@ -0,0 +1,6 @@ +// expect: FLOAT_MIXED object=y line=4 +// f32 and f64 never meet without `as`. +fn f(a: f32, b: f64) -> f64 { + let y: f64 = a + b; + return y; +} diff --git a/tests/compiler/neg/float_mixed_cmp.osc b/tests/compiler/neg/float_mixed_cmp.osc new file mode 100644 index 000000000..09f26fc75 --- /dev/null +++ b/tests/compiler/neg/float_mixed_cmp.osc @@ -0,0 +1,6 @@ +// expect: FLOAT_MIXED object=c line=4 +// comparing f64 with f32 is refused like arithmetic. +fn f(a: f64, b: f32) -> bool { + let c: bool = a < b; + return c; +} diff --git a/tests/compiler/neg/float_mixed_int.osc b/tests/compiler/neg/float_mixed_int.osc new file mode 100644 index 000000000..0d8af93a3 --- /dev/null +++ b/tests/compiler/neg/float_mixed_int.osc @@ -0,0 +1,6 @@ +// expect: FLOAT_MIXED object=y line=4 +// a float and an integer never meet without `as`. +fn f(a: f32, k: u32) -> f32 { + let y: f32 = a * k; + return y; +} diff --git a/tests/compiler/progs/.crumb b/tests/compiler/progs/.crumb index a3b027f07..9a12ff2db 100644 --- a/tests/compiler/progs/.crumb +++ b/tests/compiler/progs/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-04T13:47:05Z", + "compiled_at": "2026-10-16T20:35:19Z", "compiler": "crumb-compile/1", - "digest": "sha256:44128e1034bd4f570667a4a57f5d058b09b127f6e203e2173e2b07c533c45b57", + "digest": "sha256:548842e38f88f2fcee6d1e3694f5a50ae56c0cc9ffca989659ca3415ae0745eb", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 47, - "generated_at_commit": "834ee93e4314a42c1127a2fcda8b29cf3b511245", - "source_tree": "sha256:87862690dad770356b5d66d8d7b794c231c8b2d35823f04720fe81757fe2d1ff" + "files": 53, + "generated_at_commit": "cde3c1d51cc2106f965ed34c6ae82d311d1b490a", + "source_tree": "sha256:069b780bf8b661789e9a2039ddd658d969460f770d5c498453699fe49bc48450" }, "owner_lane": "", "provenance": { diff --git a/tests/compiler/progs/f_adam_step.osc b/tests/compiler/progs/f_adam_step.osc new file mode 100644 index 000000000..b7bfc388a --- /dev/null +++ b/tests/compiler/progs/f_adam_step.osc @@ -0,0 +1,42 @@ +// entry: adam32 adam64 lerp sumsq +// OSC-4 Slice A: one Adam optimizer step in f32 and f64, a lerp, and a +// running sum of squares. Arguments and results are IEEE bit patterns. +// Expected values come from a C oracle built with -O2 -ffp-contract=off +// -fno-fast-math -fno-math-errno (volatile intermediates, one round per op). +// expect-run: adam32 0x3f800000 0x3f000000 0 0 -> 0x3f7fbe77 +// expect-run: adam32 0xc0200000 0x3dcccccd 0x3e4ccccd 0x3e99999a -> 0xc02001cc +// expect-run: adam64 0x3ff0000000000000 0x3fe0000000000000 0 0 -> 0x3feff7ced91946db +// expect-run: adam64 0xc004000000000000 0x3fb999999999999a 0x3fc999999999999a 0x3fd3333333333333 -> 0xc00400398a57dec7 +// expect-run: lerp 0x3f800000 0x40400000 0x3e800000 -> 0x3fc00000 +// expect-run: sumsq 0x3dcccccd -> 0x3d23d70b +fn adam32(p: f32, g: f32, m: f32, v: f32) -> f32 { + let b1: f32 = 0.9; + let b2: f32 = 0.999; + let lr: f32 = 0.001; + let eps: f32 = 1.0e-8; + let m1: f32 = b1 * m + (1.0 - b1) * g; + let v1: f32 = b2 * v + (1.0 - b2) * (g * g); + let mh: f32 = m1 / (1.0 - b1); + let vh: f32 = v1 / (1.0 - b2); + return p - lr * mh / (sqrt(vh) + eps); +} + +fn adam64(p: f64, g: f64, m: f64, v: f64) -> f64 { + let b1: f64 = 0.9; + let b2: f64 = 0.999; + let lr: f64 = 0.001; + let eps: f64 = 1.0e-8; + let m1: f64 = b1 * m + (1.0 - b1) * g; + let v1: f64 = b2 * v + (1.0 - b2) * (g * g); + let mh: f64 = m1 / (1.0 - b1); + let vh: f64 = v1 / (1.0 - b2); + return p - lr * mh / (sqrt(vh) + eps); +} + +fn lerp(a: f32, b: f32, t: f32) -> f32 { return a + (b - a) * t; } + +fn sumsq(x: f32) -> f32 { + let mut s: f32 = 0.0; + for i in 0 .. 4 { s = s + x * x; } + return s; +} diff --git a/tests/compiler/progs/f_array_dot.osc b/tests/compiler/progs/f_array_dot.osc new file mode 100644 index 000000000..fe08839d9 --- /dev/null +++ b/tests/compiler/progs/f_array_dot.osc @@ -0,0 +1,54 @@ +// entry: dot fill_sum scale_ref ret_arr widen_sum +// OSC-4 Slice A: fixed arrays of f64 and f32. Cells hold the bit pattern; +// alloc(x) fills every cell. dot(seed) = sum_{i<8} ((seed+i)*0.5) * 1.5. +// expect-run: dot 0 -> 0x4035000000000000 +// expect-run: dot 4 -> 0x4046800000000000 +// expect-run: fill_sum 0x3dcccccd -> 0x3ecccccd +// expect-run: fill_sum 0x7fc00000 -> 0x7fc00000 +// expect-run: scale_ref 0x4000000000000000 -> 0x4034000000000000 +// expect-run: ret_arr 3 -> 0x4008000000000000 +// expect-run: widen_sum 0x3dcccccd -> 0x3fd99999a0000000 +fn dot(seed: u32) -> f64 { + let a: own [f64; 8] = alloc(0.0); + let b: own [f64; 8] = alloc(1.5); + for i in 0 .. 8 { a[i] = ((seed as i64) + i) as f64 * 0.5; } + let mut s: f64 = 0.0; + for i in 0 .. 8 { s = s + a[i] * b[i]; } + return s; +} + +fn fill_sum(x: f32) -> f32 { + let a: own [f32; 4] = alloc(x); + let mut s: f32 = 0.0; + for i in 0 .. 4 { s = s + a[i]; } + return s; +} + +fn scale(a: &mut [f64; 5], k: f64) { + for i in 0 .. 5 { a[i] = a[i] * k; } +} + +fn scale_ref(x: f64) -> f64 { + let a: own [f64; 5] = alloc(x); + scale(&mut a, 5.0); + let r: &[f64; 5] = &a; + return r[4] * 2.0; +} + +fn mk(a: &mut [f64; 2], v: f64) { + a[0] = v; + a[1] = a[0] + 1.0; +} + +fn ret_arr(k: u8) -> f64 { + let a: own [f64; 2] = alloc(0.0); + mk(&mut a, k as f64 - 1.0); + return a[1]; +} + +fn widen_sum(x: f32) -> f64 { + let a: own [f32; 4] = alloc(x); + let mut s: f64 = 0.0; + for i in 0 .. 4 { s = s + a[i] as f64; } + return s; +} diff --git a/tests/compiler/progs/f_cast_sat.osc b/tests/compiler/progs/f_cast_sat.osc new file mode 100644 index 000000000..0873070ff --- /dev/null +++ b/tests/compiler/progs/f_cast_sat.osc @@ -0,0 +1,41 @@ +// entry: f2i32 f2u32 f2i64 f2u64 i2f u2d d2f f2d i2f_small +// OSC-4 Slice A: float <-> int conversions. Float to int truncates toward +// zero and saturates (FCVTZS/FCVTZU), NaN gives 0, never a CAST trap. +// Int to float rounds to nearest even (SCVTF/UCVTF); f64 -> f32 is FCVT (RNE), +// overflow gives inf without a trap. Oracle: C with the Slice A flags. +// expect-run: f2i32 0x4f000000 -> 2147483647 +// expect-run: f2i32 0xcf000001 -> -2147483648 +// expect-run: f2i32 0xc0490fd0 -> -3 +// expect-run: f2i32 0x7fc00000 -> 0 +// expect-run: f2i32 0xff800000 -> -2147483648 +// expect-run: f2u32 0xbf800000 -> 0 +// expect-run: f2u32 0x4f000000 -> 2147483648 +// expect-run: f2u32 0x7f800000 -> 4294967295 +// expect-run: f2u32 0x40490fd0 -> 3 +// expect-run: f2i64 0x7ff0000000000000 -> 9223372036854775807 +// expect-run: f2i64 0xfff0000000000000 -> -9223372036854775808 +// expect-run: f2i64 0xc004000000000000 -> -2 +// expect-run: f2i64 0x7ff8000000000000 -> 0 +// expect-run: f2u64 0x43f0000000000000 -> 18446744073709551615 +// expect-run: f2u64 0xbff8000000000000 -> 0 +// expect-run: f2u64 0x40f0000000000000 -> 65536 +// expect-run: i2f 16777217 -> 0x4b800000 +// expect-run: i2f 16777219 -> 0x4b800002 +// expect-run: i2f -1 -> 0xbf800000 +// expect-run: u2d 18446744073709551615 -> 0x43f0000000000000 +// expect-run: u2d 9007199254740993 -> 0x4340000000000000 +// expect-run: d2f 0x3ff0000010000000 -> 0x3f800000 +// expect-run: d2f 0x7e37e43c8800759c -> 0x7f800000 +// expect-run: d2f 0xbff8000000000000 -> 0xbfc00000 +// expect-run: f2d 0x3f800000 -> 0x3ff0000000000000 +// expect-run: f2d 0xffc00000 -> 0xfff8000000000000 +// expect-run: i2f_small 200 -> 0x43480000 +fn f2i32(x: f32) -> i32 { return x as i32; } +fn f2u32(x: f32) -> u32 { return x as u32; } +fn f2i64(x: f64) -> i64 { return x as i64; } +fn f2u64(x: f64) -> u64 { return x as u64; } +fn i2f(x: i64) -> f32 { return x as f32; } +fn u2d(x: u64) -> f64 { return x as f64; } +fn d2f(x: f64) -> f32 { return x as f32; } +fn f2d(x: f32) -> f64 { return x as f64; } +fn i2f_small(x: u8) -> f32 { return x as f32; } diff --git a/tests/compiler/progs/f_literals.osc b/tests/compiler/progs/f_literals.osc new file mode 100644 index 000000000..efae429fe --- /dev/null +++ b/tests/compiler/progs/f_literals.osc @@ -0,0 +1,13 @@ +// entry: tiny63 tiny_e tiny32 one_e +// OSC-4 Slice A: float literal spellings. A literal may be up to OSC_LEX_NAME_MAX (63) +// characters; tiny63 is exactly 63 and parses with strtod to 1e-61. Longer spellings are +// refused (CAPACITY, tests/compiler/neg/float_literal_too_long.osc), never truncated. +// Oracle: strtod / strtof in C with the Slice A flags. +// expect-run: tiny63 -> 0x3344919d5556eb52 +// expect-run: tiny_e -> 0x1e81fee341fc585d +// expect-run: tiny32 -> 0xc01ceb3 +// expect-run: one_e -> 0x3ff0000000000000 +fn tiny63() -> f64 { return 0.0000000000000000000000000000000000000000000000000000000000001; } +fn tiny_e() -> f64 { return 1.0e-161; } +fn tiny32() -> f32 { return 0.0000000000000000000000000000001; } +fn one_e() -> f64 { return 10.0e-1; } diff --git a/tests/compiler/progs/f_nan_cmp.osc b/tests/compiler/progs/f_nan_cmp.osc new file mode 100644 index 000000000..30729f1cb --- /dev/null +++ b/tests/compiler/progs/f_nan_cmp.osc @@ -0,0 +1,78 @@ +// entry: cmp64 cmp32 prop neg_abs minmax sqrt64 bits_rt +// OSC-4 Slice A: comparisons read false on NaN except !=; NaN payloads +// propagate as the hardware does (first signalling NaN quieted, else first +// quiet NaN); min/max follow FMINNM/FMAXNM (one quiet NaN: the other operand). +// cmp* return a mask: bit0 ==, bit1 !=, bit2 <, bit3 <=, bit4 >, bit5 >=. +// expect-run: cmp64 0x3ff0000000000000 0x4000000000000000 -> 14 +// expect-run: cmp64 0x4000000000000000 0x4000000000000000 -> 41 +// expect-run: cmp64 0x4000000000000000 0x3ff0000000000000 -> 50 +// expect-run: cmp64 0x7ff8000000000000 0x3ff0000000000000 -> 2 +// expect-run: cmp64 0x3ff0000000000000 0x7ff0000000000001 -> 2 +// expect-run: cmp64 0x7ff8000000000000 0x7ff8000000000000 -> 2 +// expect-run: cmp64 0x8000000000000000 0 -> 41 +// expect-run: cmp32 0x7fc00000 0x7fc00000 -> 2 +// expect-run: cmp32 0x80000000 0 -> 41 +// expect-run: cmp32 0xff800000 0x7f800000 -> 14 +// expect-run: prop 0x7ff0000000000001 0x3ff0000000000000 -> 0x7ff8000000000001 +// expect-run: prop 0x3ff0000000000000 0x7ff0000000000001 -> 0x7ff8000000000001 +// expect-run: prop 0x7ff80000000000ab 0x4000000000000000 -> 0x7ff80000000000ab +// expect-run: prop 0x7ff0000000000000 0x7ff0000000000000 -> 0x7ff8000000000000 +// expect-run: prop 0x7ff0000000000001 0x7ff80000000000ab -> 0x7ff8000000000001 +// expect-run: prop 0x7ff80000000000ab 0x7ff0000000000001 -> 0x7ff8000000000001 +// expect-run: neg_abs 0x7ff80000000000ab -> 0x7ff80000000000ab +// expect-run: neg_abs 0xfff80000000000ab -> 0x7ff80000000000ab +// expect-run: neg_abs 0x3ff0000000000000 -> 0x3ff0000000000000 +// expect-run: minmax 0x7ff0000000000001 0x3ff0000000000000 0 -> 0x7ff8000000000001 +// expect-run: minmax 0x7ff8000000000000 0x3ff0000000000000 0 -> 0x3ff0000000000000 +// expect-run: minmax 0x3ff0000000000000 0x7ff8000000000000 1 -> 0x3ff0000000000000 +// expect-run: minmax 0x7ff80000000000ab 0x7ff8000000000000 1 -> 0x7ff80000000000ab +// expect-run: minmax 0x7ff8000000000000 0x7ff0000000000001 1 -> 0x7ff8000000000001 +// expect-run: minmax 0x8000000000000000 0 0 -> 0x8000000000000000 +// expect-run: minmax 0 0x8000000000000000 0 -> 0x8000000000000000 +// expect-run: minmax 0x8000000000000000 0 1 -> 0 +// expect-run: minmax 0 0x8000000000000000 1 -> 0 +// expect-run: minmax 0x3ff0000000000000 0x4000000000000000 0 -> 0x3ff0000000000000 +// expect-run: minmax 0x3ff0000000000000 0x4000000000000000 1 -> 0x4000000000000000 +// expect-run: sqrt64 0xbff0000000000000 -> 0x7ff8000000000000 +// expect-run: sqrt64 0x4000000000000000 -> 0x3ff6a09e667f3bcd +// expect-run: bits_rt 0x7ff0000000000001 -> 0x7ff0000000000001 +// expect-run: bits_rt 0x8000000000000000 -> 0x8000000000000000 +fn cmp64(a: f64, b: f64) -> u32 { + let mut r: u32 = 0; + if a == b { r = r | 1; } + if a != b { r = r | 2; } + if a < b { r = r | 4; } + if a <= b { r = r | 8; } + if a > b { r = r | 16; } + if a >= b { r = r | 32; } + return r; +} + +fn cmp32(a: f32, b: f32) -> u32 { + let mut r: u32 = 0; + if a == b { r = r | 1; } + if a != b { r = r | 2; } + if a < b { r = r | 4; } + if a <= b { r = r | 8; } + if a > b { r = r | 16; } + if a >= b { r = r | 32; } + return r; +} + +fn prop(a: f64, b: f64) -> f64 { return a - b; } + +fn neg_abs(a: f64) -> f64 { return abs(-a); } + +fn minmax(a: f64, b: f64, which: u32) -> f64 { + if which == 0 { return min(a, b); } + return max(a, b); +} + +fn sqrt64(a: f64) -> f64 { return sqrt(a); } + +// a bit cast round trip keeps a signalling NaN signalling (no arithmetic happens) +fn bits_rt(a: f64) -> u64 { + let u: u64 = a as u64 bits; + let f: f64 = u as f64 bits; + return f as u64 bits; +} diff --git a/tests/compiler/progs/f_neg_zero.osc b/tests/compiler/progs/f_neg_zero.osc new file mode 100644 index 000000000..49ba99ccb --- /dev/null +++ b/tests/compiler/progs/f_neg_zero.osc @@ -0,0 +1,55 @@ +// entry: neg zero_minus neg_lit eq_zero div_nz abs_nz sqrt_nz sign_bit from_bits lit_bits sub_mul +// OSC-4 Slice A: the sign of zero. `-x` is FNEG (gives -0.0 from +0.0); +// `0.0 - x` is FSUB (gives +0.0). -0.0 == +0.0 is true; only `bits` sees the +// sign. 1.0 / -0.0 is -inf with no trap. sqrt(-0.0) is -0.0 (IEEE). +// expect-run: neg 0 -> 0x80000000 +// expect-run: neg 0x80000000 -> 0 +// expect-run: neg 0x3f800000 -> 0xbf800000 +// expect-run: zero_minus 0 -> 0 +// expect-run: zero_minus 0x80000000 -> 0 +// expect-run: neg_lit 0 -> 0x80000000 +// expect-run: neg_lit 1 -> 0xbfc00000 +// expect-run: eq_zero 0x80000000 -> 1 +// expect-run: eq_zero 0 -> 1 +// expect-run: eq_zero 0x3f800000 -> 0 +// expect-run: div_nz 0x3f800000 -> 0xff800000 +// expect-run: div_nz 0xbf800000 -> 0x7f800000 +// expect-run: abs_nz 0x80000000 -> 0 +// expect-run: sqrt_nz 0x80000000 -> 0x80000000 +// expect-run: sign_bit 0x80000000 -> 1 +// expect-run: sign_bit 0 -> 0 +// expect-run: from_bits 2147483648 -> 0x80000000 +// expect-run: from_bits 1065353216 -> 0x3f800000 +// expect-run: lit_bits 0 -> 0x80000000 +// expect-run: lit_bits 1 -> 0x8000000000000000 +// expect-run: sub_mul 0 -> 0 +// expect-run: sub_mul 1 -> 0x8000000000000000 +fn neg(x: f32) -> f32 { return -x; } +fn zero_minus(x: f32) -> f32 { return 0.0 - x; } +fn neg_lit(k: u8) -> f32 { + if k == 0 { return -0.0; } + return -1.5; +} +fn eq_zero(x: f32) -> bool { return x == 0.0; } +fn div_nz(x: f32) -> f32 { + let nz: f32 = -0.0; + return x / nz; +} +fn abs_nz(x: f32) -> f32 { return abs(x); } +fn sqrt_nz(x: f32) -> f32 { return sqrt(x); } +fn sign_bit(x: f32) -> u32 { return (x as u32 bits) >> 31; } +fn from_bits(u: u32) -> f32 { return u as f32 bits; } +fn lit_bits(k: u8) -> u64 { + if k == 0 { + let z: f32 = -0.0; + return (z as u32 bits) as u64; + } + let d: f64 = -0.0; + return d as u64 bits; +} +// -0.0 + 0.0 is +0.0 and -0.0 * 1.0 is -0.0 (both RNE, both FADD/FMUL) +fn sub_mul(k: u8) -> u64 { + let nz: f64 = -0.0; + if k == 0 { return (nz + 0.0) as u64 bits; } + return (nz * 1.0) as u64 bits; +} diff --git a/tests/compiler/test_osc_backend.c b/tests/compiler/test_osc_backend.c index 7020a445c..7a634ccc9 100644 --- a/tests/compiler/test_osc_backend.c +++ b/tests/compiler/test_osc_backend.c @@ -26,6 +26,8 @@ #include "osc_native.h" #include "osc_rt.h" +#include "aarch64_fp_golden.h" /* OSC-4 Slice A: GNU as 2.42 reference encodings (see its provenance line) */ + #define NVEC 2000 static unsigned long n_checks, n_fail; @@ -160,6 +162,17 @@ static const uint64_t EDGE[] = { #define NEDGE (sizeof EDGE / sizeof EDGE[0]) static uint64_t gen_val(OscScalar t) { + if (t == OSC_T_F32 || t == OSC_T_F64) { /* OSC-4: float bit patterns, edges included */ + static const uint64_t f32e[] = {0, 0x80000000u, 0x3f800000u, 0xbf800000u, 0x7f800000u, 0xff800000u, 0x7fc00000u, 0x7f800001u, + 0x7fc00123u, 0x00000001u, 0x007fffffu, 0x7f7fffffu, 0x4b800001u, 0x4f000000u, 0xcf000000u, 0x5f000000u}; + static const uint64_t f64e[] = {0, 0x8000000000000000ull, 0x3ff0000000000000ull, 0xbff0000000000000ull, 0x7ff0000000000000ull, + 0xfff0000000000000ull, 0x7ff8000000000000ull, 0x7ff0000000000001ull, 0x7ff80000000000abull, 1, + 0x000fffffffffffffull, 0x7fefffffffffffffull, 0x4340000000000001ull, 0x43e0000000000000ull, + 0xc3e0000000000000ull, 0x43f0000000000000ull}; + uint64_t r = sm(); + if (r % 2) return t == OSC_T_F64 ? f64e[(r >> 8) % 16] : f32e[(r >> 8) % 16]; + return canon(t, sm()); + } uint64_t r = sm(), x; switch (r % 5) { case 0: case 1: x = EDGE[sm() % NEDGE]; break; @@ -346,6 +359,128 @@ static void gen_ops(void) { } /* arrays: alloc / store / load / release, loops, bounds traps */ +/* ---- OSC-4 Slice A: float units for the differential run ------------------- */ +static int k_fbin(B *b, int sub, int x, int y) { + int d = V(b, b->f->vtype[x]); OscInsn i = I0(OSC_I_FBIN); i.sub = (uint8_t)sub; i.dst = (int16_t)d; i.a = (int16_t)x; i.b = (int16_t)y; put(b, i); return d; +} +static int k_fun(B *b, int sub, int x) { + int d = V(b, b->f->vtype[x]); OscInsn i = I0(OSC_I_FUN); i.sub = (uint8_t)sub; i.dst = (int16_t)d; i.a = (int16_t)x; put(b, i); return d; +} +static int k_fcmp(B *b, int cc, int x, int y) { + int d = V(b, TS(OSC_T_BOOL)); OscInsn i = I0(OSC_I_FCMP); i.sub = (uint8_t)cc; i.dst = (int16_t)d; i.a = (int16_t)x; i.b = (int16_t)y; put(b, i); return d; +} +/* FCVT / ITOF / FTOI / FBITS: dst of type `to`, one source */ +static int k_f1(B *b, OscOp op, int sub, OscScalar to, int x) { + int d = V(b, TS(to)); OscInsn i = I0(op); i.sub = (uint8_t)sub; i.dst = (int16_t)d; i.a = (int16_t)x; put(b, i); return d; +} +static const OscScalar FLTS[2] = {OSC_T_F32, OSC_T_F64}; +static const char *fbname(int s) { + static const char *n[] = {"?", "fadd", "fsub", "fmul", "fdiv", "fmin", "fmax"}; + return n[s]; +} +static void gen_float_ops(void) { + Pack p = {0}; + B b; + char nm[64]; + for (int ti = 0; ti < 2; ti++) { + OscScalar t = FLTS[ti]; + for (int sub = OSC_FB_ADD; sub <= OSC_FB_MAX; sub++) { + OscType pt[2] = {TS(t), TS(t)}; + snprintf(nm, sizeof nm, "%s_%s", fbname(sub), osc_scalar_name(t)); + fn(&b, pack_get(&p, "fbin"), nm, pt[0], 2, pt); + k_ret(&b, k_fbin(&b, sub, 0, 1)); + } + /* a * b + c: two rounds, never fused */ + { + OscType pt[3] = {TS(t), TS(t), TS(t)}; + snprintf(nm, sizeof nm, "muladd_%s", osc_scalar_name(t)); + fn(&b, pack_get(&p, "fbin"), nm, pt[0], 3, pt); + k_ret(&b, k_fbin(&b, OSC_FB_ADD, k_fbin(&b, OSC_FB_MUL, 0, 1), 2)); + } + for (int sub = OSC_FU_NEG; sub <= OSC_FU_SQRT; sub++) { + OscType pt[1] = {TS(t)}; + snprintf(nm, sizeof nm, "fun%d_%s", sub, osc_scalar_name(t)); + fn(&b, pack_get(&p, "fun"), nm, pt[0], 1, pt); + k_ret(&b, k_fun(&b, sub, 0)); + } + for (int cc = OSC_C_EQ; cc <= OSC_C_GE; cc++) { + OscType pt[2] = {TS(t), TS(t)}; + snprintf(nm, sizeof nm, "fcmp%d_%s", cc, osc_scalar_name(t)); + fn(&b, pack_get(&p, "fcmp"), nm, TS(OSC_T_BOOL), 2, pt); + k_ret(&b, k_fcmp(&b, cc, 0, 1)); + } + { + OscScalar o = FLTS[1 - ti]; + OscType pt[1] = {TS(t)}; + snprintf(nm, sizeof nm, "fcvt_%s_%s", osc_scalar_name(t), osc_scalar_name(o)); + fn(&b, pack_get(&p, "fcvt"), nm, TS(o), 1, pt); + k_ret(&b, k_f1(&b, OSC_I_FCVT, 0, o, 0)); + } + for (int ii = 0; ii < 8; ii++) { + OscScalar it = INTS[ii]; + int sg = osc_scalar_signed(it) ? 1 : 2; + OscType pt[1] = {TS(it)}; + snprintf(nm, sizeof nm, "itof_%s_%s", osc_scalar_name(it), osc_scalar_name(t)); + fn(&b, pack_get(&p, "itof"), nm, TS(t), 1, pt); + k_ret(&b, k_f1(&b, OSC_I_ITOF, sg, t, 0)); + OscType pf[1] = {TS(t)}; + snprintf(nm, sizeof nm, "ftoi_%s_%s", osc_scalar_name(t), osc_scalar_name(it)); + fn(&b, pack_get(&p, "ftoi"), nm, TS(it), 1, pf); + k_ret(&b, k_f1(&b, OSC_I_FTOI, sg, it, 0)); + } + /* bit casts both ways, to the unsigned and the signed integer of the same width */ + for (int sg = 0; sg < 2; sg++) { + OscScalar it = ti ? (sg ? OSC_T_I64 : OSC_T_U64) : (sg ? OSC_T_I32 : OSC_T_U32); + OscType pf[1] = {TS(t)}, pi[1] = {TS(it)}; + snprintf(nm, sizeof nm, "fbits_%s_%s", osc_scalar_name(t), osc_scalar_name(it)); + fn(&b, pack_get(&p, "fbits"), nm, TS(it), 1, pf); + k_ret(&b, k_f1(&b, OSC_I_FBITS, 0, it, 0)); + snprintf(nm, sizeof nm, "fbits_%s_%s", osc_scalar_name(it), osc_scalar_name(t)); + fn(&b, pack_get(&p, "fbits"), nm, TS(t), 1, pi); + k_ret(&b, k_f1(&b, OSC_I_FBITS, 0, t, 0)); + } + /* constants: select a float constant by a u8 (MOVZ/MOVK materialisation of float bits) */ + { + static const uint64_t c32[] = {0, 0x80000000u, 0x3f800000u, 0x7fc00000u, 0x7f800001u, 0x3dcccccdu, 0xff800000u, 0x00000001u}; + static const uint64_t c64[] = {0, 0x8000000000000000ull, 0x3ff0000000000000ull, 0x7ff8000000000000ull, + 0x7ff0000000000001ull, 0x3fb999999999999aull, 0xfff0000000000000ull, 1}; + OscType pt[1] = {TS(OSC_T_U8)}; + snprintf(nm, sizeof nm, "fconst_%s", osc_scalar_name(t)); + fn(&b, pack_get(&p, "fconst"), nm, TS(t), 1, pt); + int res = V(&b, TS(t)); + k_mov(&b, res, k_const(&b, TS(t), ti ? c64[0] : c32[0])); + int blocks[8], exit_ = -1; + for (int i = 0; i < 8; i++) blocks[i] = blk(&b); + exit_ = blk(&b); + k_br(&b, blocks[0]); + for (int i = 0; i < 8; i++) { + at(&b, blocks[i]); + int hit = blk(&b); + int c = k_cmp(&b, OSC_C_EQ, 0, k_const(&b, TS(OSC_T_U8), (uint64_t)i)); + k_cbr(&b, c, hit, i + 1 < 8 ? blocks[i + 1] : exit_); + at(&b, hit); + k_mov(&b, res, k_const(&b, TS(t), ti ? c64[i] : c32[i])); + k_br(&b, exit_); + } + at(&b, exit_); + k_ret(&b, k_fbin(&b, OSC_FB_ADD, res, res)); + } + /* arrays of floats: cells hold the bits; LOAD/STORE unchanged */ + { + OscType pt[2] = {TS(t), TS(OSC_T_U8)}; + snprintf(nm, sizeof nm, "farray_%s", osc_scalar_name(t)); + fn(&b, pack_get(&p, "farray"), nm, TS(t), 2, pt); + int arr = k_alloc(&b, t, 4, 0); + int i1 = k_const(&b, TS(OSC_T_U8), 1); + k_store(&b, arr, i1, k_fbin(&b, OSC_FB_MUL, 0, 0)); + int v = k_fbin(&b, OSC_FB_SUB, k_load(&b, arr, i1), k_load(&b, arr, 1)); /* index 1 may trap BOUNDS */ + k_release(&b, arr); + k_ret(&b, v); + } + } + pack_flush(&p); +} + static void gen_arrays(void) { OscUnit *u = unit_new(); B b; @@ -836,6 +971,140 @@ static void expect_invalid(OscUnit *u, const char *what) { check(osc_ir_digest(u, dg) != 0 && osc_ir_encode(u, NULL, 0, &len) != 0, "digest/encode accepted: %s", what); } +/* ---- (d2) OSC-4 Slice A: scalar FP encoder goldens ------------------------ + * Reference words come from tests/compiler/aarch64_fp_golden.h (GNU as 2.42 + * samples, see its provenance line) and from the table in + * docs/osc/OSC-4-DESIGN.md 1.6. Every new op: one golden word, one decoder + * round trip (enc_expect) and a field-flip mutant sweep. */ +static unsigned long n_fp_goldens, n_fp_mutants; +static void fp_golden_bad(const char *asm_text, uint32_t want, uint32_t got) { + check(0, "golden header self-test: %s want 0x%08x got 0x%08x", asm_text, want, got); +} +/* every single-bit flip of a golden word either fails to decode or decodes to a + * different instruction that re-encodes to exactly the flipped word (mirror) */ +static void fp_mutants(OscA64Insn i, uint32_t w) { + for (int b = 0; b < 32; b++) { + uint32_t m = w ^ (1u << b), re = 0; + OscA64Insn d; + if (osc_a64_decode(m, &d) != 0) continue; + check(!osc_a64_equal(&d, &i), "mutant bit %d of 0x%08x decodes to the same fields", b, w); + check(osc_a64_reencode(&d, &re) == 0 && re == m, "mutant bit %d of 0x%08x: decode/re-encode 0x%08x", b, w, re); + n_fp_mutants++; + } +} +static void fp_expect(OscA64Insn i, uint32_t header_word, uint32_t design_word, const char *what) { + check(header_word == design_word, "%s: golden header 0x%08x disagrees with design table 0x%08x", what, header_word, design_word); + enc_expect(i, header_word, what); + fp_mutants(i, header_word); + n_fp_goldens++; +} + +static void test_fp_encoder(void) { + const int SP = OSC_A64_SP, ZR = OSC_A64_XZR, S = 0, D = 1; + unsigned nsamples = 0; + unsigned bad = a64_golden_selftest(&nsamples, fp_golden_bad); + check(bad == 0 && nsamples >= 1365, "golden header self-test: %u mismatches over %u samples", bad, nsamples); + /* the 25 ops of design table 1.6, D form where the table shows one */ + fp_expect(osc_a64_f2(OSC_A64_FMOV_RR, 0, 1, D), a64_fmov_d(0, 1), 0x1E604020u, "fmov d0,d1"); + fp_expect(osc_a64_f2(OSC_A64_FMOV_XD, 0, 1, 0), a64_fmov_d_from_x(0, 1), 0x9E670020u, "fmov d0,x1"); + fp_expect(osc_a64_f2(OSC_A64_FMOV_DX, 0, 1, 0), a64_fmov_d_to_x(0, 1), 0x9E660020u, "fmov x0,d1"); + fp_expect(osc_a64_f2(OSC_A64_FMOV_WS, 0, 1, 0), a64_fmov_s_from_w(0, 1), 0x1E270020u, "fmov s0,w1"); + fp_expect(osc_a64_f2(OSC_A64_FMOV_SW, 0, 1, 0), a64_fmov_s_to_w(0, 1), 0x1E260020u, "fmov w0,s1"); + fp_expect(osc_a64_f3(OSC_A64_FADD, 0, 1, 2, D), a64_fadd_d(0, 1, 2), 0x1E622820u, "fadd d0,d1,d2"); + fp_expect(osc_a64_f3(OSC_A64_FSUB, 0, 1, 2, D), a64_fsub_d(0, 1, 2), 0x1E623820u, "fsub d0,d1,d2"); + fp_expect(osc_a64_f3(OSC_A64_FMUL, 0, 1, 2, D), a64_fmul_d(0, 1, 2), 0x1E620820u, "fmul d0,d1,d2"); + fp_expect(osc_a64_f3(OSC_A64_FDIV, 0, 1, 2, D), a64_fdiv_d(0, 1, 2), 0x1E621820u, "fdiv d0,d1,d2"); + fp_expect(osc_a64_f3(OSC_A64_FMAXNM, 0, 1, 2, D), a64_fmaxnm_d(0, 1, 2), 0x1E626820u, "fmaxnm d0,d1,d2"); + fp_expect(osc_a64_f3(OSC_A64_FMINNM, 0, 1, 2, D), a64_fminnm_d(0, 1, 2), 0x1E627820u, "fminnm d0,d1,d2"); + fp_expect(osc_a64_f2(OSC_A64_FSQRT, 0, 1, D), a64_fsqrt_d(0, 1), 0x1E61C020u, "fsqrt d0,d1"); + fp_expect(osc_a64_f2(OSC_A64_FNEG, 0, 1, D), a64_fneg_d(0, 1), 0x1E614020u, "fneg d0,d1"); + fp_expect(osc_a64_f2(OSC_A64_FABS, 0, 1, D), a64_fabs_d(0, 1), 0x1E60C020u, "fabs d0,d1"); + fp_expect(osc_a64_fcmp(0, 1, D), a64_fcmp_d(0, 1), 0x1E612000u, "fcmp d0,d1"); + fp_expect(osc_a64_f2(OSC_A64_FCVT_SD, 0, 1, 0), a64_fcvt_d_to_s(0, 1), 0x1E624020u, "fcvt s0,d1"); + fp_expect(osc_a64_f2(OSC_A64_FCVT_DS, 0, 1, 0), a64_fcvt_s_to_d(0, 1), 0x1E22C020u, "fcvt d0,s1"); + fp_expect(osc_a64_f2(OSC_A64_SCVTF_X, 0, 1, D), a64_scvtf_d_from_x(0, 1), 0x9E620020u, "scvtf d0,x1"); + fp_expect(osc_a64_f2(OSC_A64_UCVTF_X, 0, 1, D), a64_ucvtf_d_from_x(0, 1), 0x9E630020u, "ucvtf d0,x1"); + fp_expect(osc_a64_f2(OSC_A64_FCVTZS_X, 0, 1, D), a64_fcvtzs_d_to_x(0, 1), 0x9E780020u, "fcvtzs x0,d1"); + fp_expect(osc_a64_f2(OSC_A64_FCVTZU_X, 0, 1, D), a64_fcvtzu_d_to_x(0, 1), 0x9E790020u, "fcvtzu x0,d1"); + fp_expect(osc_a64_fmem(OSC_A64_LDR_F_UOFF, 0, SP, 8, D), a64_ldr_d_uimm(0, 31, 1), 0xFD4007E0u, "ldr d0,[sp,#8]"); + fp_expect(osc_a64_fmem(OSC_A64_STR_F_UOFF, 0, SP, 8, D), a64_str_d_uimm(0, 31, 1), 0xFD0007E0u, "str d0,[sp,#8]"); + fp_expect(osc_a64_fmem_reg(OSC_A64_LDR_F_REG, 0, 1, 2, D), a64_ldr_d_reg_lsl(0, 1, 2), 0xFC627820u, "ldr d0,[x1,x2,lsl#3]"); + fp_expect(osc_a64_fmem_reg(OSC_A64_STR_F_REG, 0, 1, 2, D), a64_str_d_reg_lsl(0, 1, 2), 0xFC227820u, "str d0,[x1,x2,lsl#3]"); + check(n_fp_goldens == 25, "expected 25 FP goldens, ran %lu", n_fp_goldens); + /* S forms and the registers the code generator actually uses (d16..d20, x9..x13) */ + enc_expect(osc_a64_f2(OSC_A64_FMOV_RR, 16, 17, S), a64_fmov_s(16, 17), "fmov s16,s17"); + enc_expect(osc_a64_f3(OSC_A64_FADD, 16, 16, 17, S), a64_fadd_s(16, 16, 17), "fadd s16,s16,s17"); + enc_expect(osc_a64_f3(OSC_A64_FSUB, 16, 16, 17, S), a64_fsub_s(16, 16, 17), "fsub s16,s16,s17"); + enc_expect(osc_a64_f3(OSC_A64_FMUL, 18, 16, 17, S), a64_fmul_s(18, 16, 17), "fmul s18,s16,s17"); + enc_expect(osc_a64_f3(OSC_A64_FDIV, 20, 19, 18, S), a64_fdiv_s(20, 19, 18), "fdiv s20,s19,s18"); + enc_expect(osc_a64_f3(OSC_A64_FMAXNM, 16, 16, 17, S), a64_fmaxnm_s(16, 16, 17), "fmaxnm s16,s16,s17"); + enc_expect(osc_a64_f3(OSC_A64_FMINNM, 16, 16, 17, S), a64_fminnm_s(16, 16, 17), "fminnm s16,s16,s17"); + enc_expect(osc_a64_f2(OSC_A64_FSQRT, 16, 16, S), a64_fsqrt_s(16, 16), "fsqrt s16,s16"); + enc_expect(osc_a64_f2(OSC_A64_FNEG, 16, 16, S), a64_fneg_s(16, 16), "fneg s16,s16"); + enc_expect(osc_a64_f2(OSC_A64_FABS, 16, 16, S), a64_fabs_s(16, 16), "fabs s16,s16"); + enc_expect(osc_a64_fcmp(16, 17, S), a64_fcmp_s(16, 17), "fcmp s16,s17"); + enc_expect(osc_a64_f2(OSC_A64_SCVTF_X, 16, 9, S), a64_scvtf_s_from_x(16, 9), "scvtf s16,x9"); + enc_expect(osc_a64_f2(OSC_A64_UCVTF_X, 16, 9, S), a64_ucvtf_s_from_x(16, 9), "ucvtf s16,x9"); + enc_expect(osc_a64_f2(OSC_A64_FCVTZS_X, 9, 16, S), a64_fcvtzs_s_to_x(9, 16), "fcvtzs x9,s16"); + enc_expect(osc_a64_f2(OSC_A64_FCVTZU_X, 9, 16, S), a64_fcvtzu_s_to_x(9, 16), "fcvtzu x9,s16"); + enc_expect(osc_a64_f2(OSC_A64_FMOV_XD, 16, 9, 0), a64_fmov_d_from_x(16, 9), "fmov d16,x9"); + enc_expect(osc_a64_f2(OSC_A64_FMOV_XD, 16, ZR, 0), a64_fmov_d_from_x(16, 31), "fmov d16,xzr"); + enc_expect(osc_a64_f2(OSC_A64_FMOV_DX, 9, 16, 0), a64_fmov_d_to_x(9, 16), "fmov x9,d16"); + enc_expect(osc_a64_f2(OSC_A64_FMOV_WS, 16, 9, 0), a64_fmov_s_from_w(16, 9), "fmov s16,w9"); + enc_expect(osc_a64_f2(OSC_A64_FMOV_WS, 16, ZR, 0), a64_fmov_s_from_w(16, 31), "fmov s16,wzr"); + enc_expect(osc_a64_f2(OSC_A64_FMOV_SW, 9, 16, 0), a64_fmov_s_to_w(9, 16), "fmov w9,s16"); + enc_expect(osc_a64_f2(OSC_A64_FCVT_SD, 16, 17, 0), a64_fcvt_d_to_s(16, 17), "fcvt s16,d17"); + enc_expect(osc_a64_f2(OSC_A64_FCVT_DS, 16, 17, 0), a64_fcvt_s_to_d(16, 17), "fcvt d16,s17"); + enc_expect(osc_a64_fmem(OSC_A64_LDR_F_UOFF, 16, SP, 4, S), a64_ldr_s_uimm(16, 31, 1), "ldr s16,[sp,#4]"); + enc_expect(osc_a64_fmem(OSC_A64_LDR_F_UOFF, 16, SP, 16380, S), a64_ldr_s_uimm(16, 31, 4095), "ldr s16,[sp,#16380]"); + enc_expect(osc_a64_fmem(OSC_A64_STR_F_UOFF, 16, SP, 0, S), a64_str_s_uimm(16, 31, 0), "str s16,[sp]"); + enc_expect(osc_a64_fmem(OSC_A64_LDR_F_UOFF, 16, SP, 32760, D), a64_ldr_d_uimm(16, 31, 4095), "ldr d16,[sp,#32760]"); + enc_expect(osc_a64_fmem(OSC_A64_STR_F_UOFF, 20, 9, 0, D), a64_str_d_uimm(20, 9, 0), "str d20,[x9]"); + enc_expect(osc_a64_fmem_reg(OSC_A64_LDR_F_REG, 16, 9, 10, S), a64_ldr_s_reg_lsl(16, 9, 10), "ldr s16,[x9,x10,lsl#2]"); + enc_expect(osc_a64_fmem_reg(OSC_A64_STR_F_REG, 16, 9, 10, S), a64_str_s_reg_lsl(16, 9, 10), "str s16,[x9,x10,lsl#2]"); + enc_expect(osc_a64_fmem_reg(OSC_A64_LDR_F_REG, 16, SP, 10, D), a64_ldr_d_reg_lsl(16, 31, 10), "ldr d16,[sp,x10,lsl#3]"); + enc_expect(osc_a64_fmem_reg(OSC_A64_STR_F_REG, 31, 9, ZR, D), a64_str_d_reg_lsl(31, 9, 31), "str d31,[x9,xzr,lsl#3]"); + /* refusals */ + enc_refuse(osc_a64_f3(OSC_A64_FADD, 0, 1, 2, 2), "fadd type 2"); + enc_refuse(osc_a64_f3(OSC_A64_FADD, 0, 1, 2, -1), "fadd type -1"); + enc_refuse(osc_a64_f3(OSC_A64_FADD, 32, 1, 2, D), "fadd vd=32"); + enc_refuse(osc_a64_f3(OSC_A64_FADD, 0, SP, 2, D), "fadd vn=SP"); + enc_refuse(osc_a64_f3(OSC_A64_FADD, 0, 1, ZR, D), "fadd vm=XZR"); + enc_refuse(osc_a64_f2(OSC_A64_FMOV_XD, 0, 1, D), "fmov d0,x1 with type flag"); + enc_refuse(osc_a64_f2(OSC_A64_FMOV_XD, 0, SP, 0), "fmov d0,sp"); + enc_refuse(osc_a64_f2(OSC_A64_FMOV_DX, SP, 1, 0), "fmov sp,d1"); + enc_refuse(osc_a64_f2(OSC_A64_FMOV_SW, 0, 32, 0), "fmov w0,v32"); + enc_refuse(osc_a64_f2(OSC_A64_FCVT_SD, 0, 1, D), "fcvt s0,d1 with type flag"); + enc_refuse(osc_a64_f2(OSC_A64_FSQRT, 0, 1, 3), "fsqrt type 3"); + enc_refuse(osc_a64_f2(OSC_A64_SCVTF_X, 0, SP, D), "scvtf d0,sp"); + enc_refuse(osc_a64_f2(OSC_A64_FCVTZS_X, SP, 1, D), "fcvtzs sp,d1"); + { OscA64Insn i = osc_a64_fcmp(0, 1, D); i.rd = 1; enc_refuse(i, "fcmp with rd set"); } + { OscA64Insn i = osc_a64_f3(OSC_A64_FADD, 0, 1, 2, D); i.imm = 8; enc_refuse(i, "fadd with imm set"); } + { OscA64Insn i = osc_a64_f3(OSC_A64_FADD, 0, 1, 2, D); i.shift = 1; enc_refuse(i, "fadd with shift set"); } + { OscA64Insn i = osc_a64_f2(OSC_A64_FNEG, 0, 1, D); i.rm = 2; enc_refuse(i, "fneg with rm set"); } + enc_refuse(osc_a64_fmem(OSC_A64_LDR_F_UOFF, 0, SP, 2, S), "ldr s0 offset 2 (unaligned)"); + enc_refuse(osc_a64_fmem(OSC_A64_LDR_F_UOFF, 0, SP, 4, D), "ldr d0 offset 4 (unaligned)"); + enc_refuse(osc_a64_fmem(OSC_A64_LDR_F_UOFF, 0, SP, 16384, S), "ldr s0 offset 16384"); + enc_refuse(osc_a64_fmem(OSC_A64_LDR_F_UOFF, 0, SP, 32768, D), "ldr d0 offset 32768"); + enc_refuse(osc_a64_fmem(OSC_A64_LDR_F_UOFF, 0, SP, -8, D), "ldr d0 offset -8"); + enc_refuse(osc_a64_fmem(OSC_A64_LDR_F_UOFF, 0, ZR, 0, D), "ldr d0 base=XZR"); + enc_refuse(osc_a64_fmem(OSC_A64_STR_F_UOFF, 32, SP, 0, D), "str v32"); + enc_refuse(osc_a64_fmem(OSC_A64_STR_F_UOFF, 0, SP, 0, 2), "str type 2"); + enc_refuse(osc_a64_fmem_reg(OSC_A64_LDR_F_REG, 0, ZR, 1, D), "ldr d0 reg base=XZR"); + enc_refuse(osc_a64_fmem_reg(OSC_A64_LDR_F_REG, 0, 1, SP, D), "ldr d0 reg index=SP"); + enc_refuse(osc_a64_fmem_reg(OSC_A64_LDR_F_REG, 0, 1, 2, 2), "ldr reg type 2"); + { OscA64Insn i = osc_a64_fmem_reg(OSC_A64_LDR_F_REG, 0, 1, 2, D); i.imm = 8; enc_refuse(i, "ldr reg with imm set"); } + /* no fused multiply-add is encodable (design 1.3 item 2): decoder refuses FMADD/FMSUB/FNMADD/FNMSUB words */ + check(osc_a64_decode(0x1F420020u, NULL) != 0, "decoder accepted fmadd d0,d1,d2,d0"); + check(osc_a64_decode(0x1F428020u, NULL) != 0, "decoder accepted fmsub d0,d1,d2,d0"); + check(osc_a64_decode(0x1F620020u, NULL) != 0, "decoder accepted fnmadd d0,d1,d2,d0"); + check(osc_a64_decode(0x1E625820u, NULL) != 0, "decoder accepted fmin d0,d1,d2 (non-NM)"); + check(osc_a64_decode(0x1E624820u, NULL) != 0, "decoder accepted fmax d0,d1,d2 (non-NM)"); + check(osc_a64_decode(0x1E612010u, NULL) != 0, "decoder accepted fcmpe d0,d1 (E bit)"); + check(osc_a64_decode(0x1E602008u, NULL) != 0, "decoder accepted fcmp d0,#0.0"); + printf("fp encoder: goldens=%lu header_samples=%u mutant_words=%lu\n", n_fp_goldens, nsamples, n_fp_mutants); +} + static void test_validator(void) { OscUnit *u = base_unit(); char err[256]; @@ -1034,9 +1303,11 @@ int main(void) { osc_rt_init(rtN); test_encoder(); + test_fp_encoder(); test_validator(); sm_state = 0x05C1B4C4ULL; gen_ops(); + gen_float_ops(); gen_arrays(); gen_calls(); diff --git a/tests/compiler/test_osc_compiler.c b/tests/compiler/test_osc_compiler.c index efbb0a8fd..aabb63614 100644 --- a/tests/compiler/test_osc_compiler.c +++ b/tests/compiler/test_osc_compiler.c @@ -140,8 +140,35 @@ static uint64_t canon(OscScalar t, uint64_t v) if (osc_scalar_signed(t) && (v >> (w - 1))) v |= ~m; return v; } +/* OSC-4 Slice A: f32/f64 argument patterns travel as bit patterns (design 1.7). + * Edges: +-0, +-1, +-inf, quiet NaN, signalling NaN with payload, subnormals, + * max finite, 2^24+1 (RNE), 2^31 / 2^63 (saturation edges), plus random bits. */ +static uint64_t gen_arg_float(OscScalar t, uint64_t r) +{ + static const uint64_t p32[] = {0, 0x80000000u, 0x3f800000u, 0xbf800000u, 0x7f800000u, 0xff800000u, 0x7fc00000u, + 0x7f800001u, 0x7fc00123u, 0xffc00000u, 0x00000001u, 0x007fffffu, 0x7f7fffffu, + 0x3f000000u, 0x4b800001u, 0x4f000000u, 0xcf000000u, 0x5f000000u, 0x3dcccccdu}; + static const uint64_t p64[] = {0, 0x8000000000000000ull, 0x3ff0000000000000ull, 0xbff0000000000000ull, + 0x7ff0000000000000ull, 0xfff0000000000000ull, 0x7ff8000000000000ull, + 0x7ff0000000000001ull, 0x7ff80000000000abull, 0xfff8000000000000ull, 1, + 0x000fffffffffffffull, 0x7fefffffffffffffull, 0x3fe0000000000000ull, + 0x4340000000000001ull, 0x43e0000000000000ull, 0xc3e0000000000000ull, + 0x43f0000000000000ull, 0x3fb999999999999aull}; + int d = t == OSC_T_F64; + switch (r % 4) { + case 0: case 1: return d ? p64[(r >> 8) % 19] : p32[(r >> 8) % 19]; + case 2: { /* a small value with a short binary expansion: k/8 for k in -1000..1000 */ + int64_t k = (int64_t)((r >> 8) % 2001) - 1000; + if (d) { double v = (double)k / 8.0; uint64_t u; memcpy(&u, &v, 8); return u; } + float v = (float)k / 8.0f; uint32_t u; memcpy(&u, &v, 4); return u; + } + default: return canon(t, sm()); + } +} + static uint64_t gen_arg(OscScalar t) { + if (t == OSC_T_F32 || t == OSC_T_F64) return gen_arg_float(t, sm()); unsigned w = osc_scalar_width(t); int sg = osc_scalar_signed(t); uint64_t r = sm(); @@ -480,6 +507,7 @@ static const char *trap_names[OSC_TRAP_MAX + 1] = {"none", "OVERFLOW", "DIV0", " static uint64_t parse_val(const char *s) { if (*s == '-') return (uint64_t)strtoll(s, NULL, 10); + if (s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) return strtoull(s, NULL, 16); /* float bit patterns (OSC-4) */ return strtoull(s, NULL, 10); } @@ -1783,6 +1811,146 @@ typedef struct { unsigned nargs; /* source arguments */ } SliceCase; +/* ------------------------------------------------------------ OSC-4 Slice A: float fuzz */ +/* Random f32 / f64 expression trees over three parameters, constants, the four + * operators, unary minus, the intrinsics, float<->float and float<->int casts and + * bit casts; the entry returns one of several views selected by k so every result + * (bits of x, bits of y, the six comparisons, a saturating f->int, a float<->float + * conversion) is compared bit for bit between the interpreter and native code. + * Arguments come from gen_arg_float: NaNs with payloads, infinities, -0.0, + * subnormals. Design: docs/osc/OSC-4-DESIGN.md 1.3 and 1.8 item 3. */ +static unsigned long ff_units, ff_runs, ff_mismatch, ff_nan, ff_inf, ff_finite; + +/* typed = 1: the result must carry its own type (it is the source of an 'as'), so the + * leaf on the type-determining path is a parameter, never a bare literal (design 1.1 item 2) */ +static void ff_expr(char *dst, size_t cap, int depth, int dbl, int typed) +{ + uint64_t r = sm(); + const char *T = dbl ? "f64" : "f32", *U = dbl ? "u64" : "u32"; + if (depth <= 0 || r % 7 == 0) { + static const char *lits[] = {"0.0", "1.0", "0.5", "2.0", "3.0e2", "1.0e-3", "0.1", "1.0e38", "1.0e-40", "-0.0", "-2.5"}; + switch ((r >> 8) % 6) { + case 0: cf_cat(dst, cap, "a"); return; + case 1: cf_cat(dst, cap, "b"); return; + case 2: cf_cat(dst, cap, "c"); return; + case 3: cf_cat(dst, cap, "%s", typed ? "b" : lits[(r >> 16) % 11]); return; + case 4: cf_cat(dst, cap, "(%s)", typed ? "c" : lits[(r >> 16) % 11]); return; + default: cf_cat(dst, cap, "-a"); return; + } + } + static const char *ops[] = {"+", "-", "*", "/"}; + switch ((r >> 8) % 14) { + case 0: case 1: case 2: case 3: case 4: case 5: /* the left operand fixes the type; the right may be a literal */ + cf_cat(dst, cap, "("); + ff_expr(dst, cap, depth - 1, dbl, typed); + cf_cat(dst, cap, " %s ", ops[(r >> 16) % 4]); + ff_expr(dst, cap, depth - 1, dbl, 0); + cf_cat(dst, cap, ")"); + return; + case 6: cf_cat(dst, cap, "sqrt("); ff_expr(dst, cap, depth - 1, dbl, typed); cf_cat(dst, cap, ")"); return; + case 7: cf_cat(dst, cap, "abs("); ff_expr(dst, cap, depth - 1, dbl, typed); cf_cat(dst, cap, ")"); return; + case 8: case 9: + cf_cat(dst, cap, (r >> 16) & 1 ? "min(" : "max("); + ff_expr(dst, cap, depth - 1, dbl, typed); + cf_cat(dst, cap, ", "); + ff_expr(dst, cap, depth - 1, dbl, 0); + cf_cat(dst, cap, ")"); + return; + case 10: cf_cat(dst, cap, "-("); ff_expr(dst, cap, depth - 1, dbl, typed); cf_cat(dst, cap, ")"); return; + /* every 'as' source below is typed: a bare literal there is AMBIGUOUS_WIDTH by design */ + case 11: /* through the other float type and back (FCVT both ways) */ + cf_cat(dst, cap, "(("); ff_expr(dst, cap, depth - 1, dbl, 1); cf_cat(dst, cap, ") as %s) as %s", dbl ? "f32" : "f64", T); + return; + case 12: { /* through an integer type (saturating FTOI, then ITOF) */ + static const char *ints[] = {"i64", "u64", "i32", "u32", "i8", "u16"}; + cf_cat(dst, cap, "(("); ff_expr(dst, cap, depth - 1, dbl, 1); cf_cat(dst, cap, ") as %s) as %s", ints[(r >> 16) % 6], T); + return; + } + default: /* bit cast round trip (payload preserving) */ + cf_cat(dst, cap, "(("); ff_expr(dst, cap, depth - 1, dbl, 1); cf_cat(dst, cap, ") as %s bits) as %s bits", U, T); + return; + } +} + +static void float_fuzz(unsigned n) +{ + static char src[16384], ex[4096], ey[4096]; + sm_state = 0x0F10A7E4Aull; + for (unsigned u = 0; u < n; u++) { + int dbl = (int)(u & 1); + const char *T = dbl ? "f64" : "f32", *U = dbl ? "u64" : "u32", *O = dbl ? "f32" : "f64", *OU = dbl ? "u32" : "u64"; + ex[0] = ey[0] = src[0] = 0; + ff_expr(ex, sizeof ex, 2 + (int)(sm() % 3), dbl, 0); + ff_expr(ey, sizeof ey, 2 + (int)(sm() % 3), dbl, 0); + cf_cat(src, sizeof src, + "fn entry(a: %s, b: %s, c: %s, k: u32) -> u64 {\n" + " let x: %s = %s;\n" + " let y: %s = %s;\n" + " let mut m: u64 = 0;\n" + " if x == y { m = m | 1; }\n" + " if x != y { m = m | 2; }\n" + " if x < y { m = m | 4; }\n" + " if x <= y { m = m | 8; }\n" + " if x > y { m = m | 16; }\n" + " if x >= y { m = m | 32; }\n" + " if k == 0 { return (x as %s bits) as u64; }\n" + " if k == 1 { return (y as %s bits) as u64; }\n" + " if k == 2 { return m; }\n" + " if k == 3 { return x as u64; }\n" + " if k == 4 { return ((x as %s) as %s bits) as u64; }\n" + " return (((x as i64) as f64) as u64 bits) ^ ((min(x, y) as %s bits) as u64);\n" + "}\n", + T, T, T, T, ex, T, ey, U, U, O, OU, U); + ff_units++; + OscDiag d; + int rc = osc_compile(src, strlen(src), U1, &d, NULL); + CHECK(rc == 0, "float fuzz unit %u refused %s line %u object=%s: %s\n%s", u, osc_diag_kind_name(d.kind), d.line, + d.object, d.message, src); + if (rc) continue; + OscCode c; + char err[160]; + memset(&c, 0, sizeof c); + int cg = osc_cg_compile(U1, &c, err, sizeof err); + CHECK(cg == 0, "float fuzz unit %u codegen refused: %s", u, err); + if (cg) continue; + OscNative nm2; + int mr = osc_native_map(&nm2, c.code, c.len); + CHECK(mr == 0, "float fuzz unit %u native map failed (%d)", u, mr); + if (mr) { osc_cg_free(&c); continue; } + int fi = U1->nfuncs - 1; + void *entry = osc_native_at(&nm2, c.entry[fi]); + OscScalar ft = dbl ? OSC_T_F64 : OSC_T_F32; + for (unsigned it = 0; it < 36; it++) { + uint64_t args[OSC_MAX_PARAMS] = {0}, ri = 0, rn = 0; + args[0] = gen_arg(ft); + args[1] = gen_arg(ft); + args[2] = gen_arg(ft); + args[3] = it % 6; + osc_rt_reset(RI); + osc_rt_reset(RN); + int t1 = osc_interp_run_prevalidated(U1, fi, args, 4, RI, &ri); + int t2 = osc_rt_call_native(RN, entry, args, 4, &rn); + ff_runs++; + diff_runs++; + int same = t1 == t2 && t1 >= 0 && (t1 != 0 || ri == rn) && osc_rt_same_outcome(RI, RN); + CHECK(same, "float fuzz unit %u args %#llx %#llx %#llx k=%llu: interp trap %d ret %#llx vs native trap %d ret %#llx\n%s", + u, (unsigned long long)args[0], (unsigned long long)args[1], (unsigned long long)args[2], + (unsigned long long)args[3], t1, (unsigned long long)ri, t2, (unsigned long long)rn, src); + if (!same) { ff_mismatch++; break; } + CHECK(t1 == 0, "float fuzz unit %u trapped (%d): floats never trap\n%s", u, t1, src); + if (t1 == 0 && args[3] == 0) { /* classify the x result */ + uint64_t e = dbl ? (ri >> 52) & 0x7ff : (ri >> 23) & 0xff, mant = dbl ? ri & 0xfffffffffffffull : ri & 0x7fffffu; + if (e == (dbl ? 0x7ffu : 0xffu)) { if (mant) ff_nan++; else ff_inf++; } else ff_finite++; + } + } + osc_native_unmap(&nm2); + osc_cg_free(&c); + } + printf("float fuzz: units=%lu runs=%lu x_finite=%lu x_inf=%lu x_nan=%lu mismatches=%lu\n", ff_units, ff_runs, ff_finite, + ff_inf, ff_nan, ff_mismatch); + CHECK(ff_nan > 0 && ff_inf > 0 && ff_finite > 0, "float fuzz never produced a NaN, an inf and a finite result"); +} + static unsigned long slice_ok, slice_runs, slice_expect, slice_fuzz_runs, slice_neg_overlap; static void slice_free(SliceCase *s) @@ -2095,8 +2263,16 @@ static void slice_host_checks(void) const char *plain = "fn g(a: u64) -> u64 { return a + 1; }\n"; CHECK(osc_compile(plain, strlen(plain), u, &d, NULL) == 0, "plain unit refused"); CHECK(osc_ir_encode(u, enc, sizeof enc, &el) == 0 && osc_ir_encoding_version(enc, el) == 1, "plain unit not version 1"); + /* OSC-4 Slice A: 6 is the float version (OSC_IR_VERSION_MAX), so the first unknown one is 7 */ enc[7] = 6; - CHECK(osc_ir_encoding_version(enc, el) == -1, "unknown version 6 accepted"); + CHECK(osc_ir_encoding_version(enc, el) == 6, "version 6 (floats) not recognised"); + enc[7] = OSC_IR_VERSION_MAX + 1; + CHECK(osc_ir_encoding_version(enc, el) == -1, "unknown version 7 accepted"); + const char *fl = "fn h(a: f32) -> f32 { return a * 2.0; }\n"; + CHECK(osc_compile(fl, strlen(fl), u, &d, NULL) == 0, "float unit refused"); + CHECK(osc_ir_encode(u, enc, sizeof enc, &el) == 0 && osc_ir_encoding_version(enc, el) == 6, "float unit not version 6"); + CHECK(osc_compile(plain, strlen(plain), u, &d, NULL) == 0 && osc_ir_encode(u, enc, sizeof enc, &el) == 0, + "plain unit refused (second time)"); enc[7] = 0; CHECK(osc_ir_encoding_version(enc, el) == -1, "version 0 accepted"); enc[7] = 1; @@ -2143,6 +2319,12 @@ int main(int argc, char **argv) handle_fuzz(fuzz / 8 ? fuzz / 8 : 16); df_dtor_order(pdir); dropflags_fuzz(fuzz / 8 ? fuzz / 8 : 16); + { /* OSC_FLOAT_FUZZ_UNITS=N runs the float dual run alone at N units (receipt evidence, + * docs/osc/OSC-4-DESIGN.md 1.8 item 3) without scaling every other sweep with it */ + const char *ffu = getenv("OSC_FLOAT_FUZZ_UNITS"); + unsigned nf = ffu ? (unsigned)strtoul(ffu, NULL, 10) : 0; + float_fuzz(nf ? nf : (fuzz / 4 ? fuzz / 4 : 30)); + } { char sdir[512]; char **sv; diff --git a/tests/compiler/test_osc_ir_decode.c b/tests/compiler/test_osc_ir_decode.c index 9a1145509..abd7d668c 100644 --- a/tests/compiler/test_osc_ir_decode.c +++ b/tests/compiler/test_osc_ir_decode.c @@ -6,7 +6,7 @@ * 1. corpus every .osc unit under tests/compiler/{progs,slices}, src/osh and * tests/physics0/osc that the front end compiles: encode -> decode * -> encode is byte-identical, the decoded unit equals the compiled - * one in every encoded field, digests agree, all five versions seen. + * one in every encoded field, digests agree, all six versions seen. * 2. valid unit-level variants of the corpus (constants, names, contract * text, operators, trap codes) that pass osc_ir_validate: at least * VALID_MIN distinct encodings round-trip byte-exactly. @@ -38,8 +38,10 @@ /* spec/one-layer-format.md section 3 states these numbers; a renumbering must fail here. */ _Static_assert(OSC_I_CONST == 1 && OSC_I_CALL == 11 && OSC_I_RET == 15 && OSC_I_FLOAD == 16 && OSC_I_AOPEN == 18 && - OSC_I_POPEN == 21 && OSC_I_HSTORE == 27 && OSC_I_SSTORE == 29, "opcode numbers in the spec"); -_Static_assert(OSC_T_BOOL == 1 && OSC_T_U64 == 5 && OSC_T_I64 == 9 && OSC_T_REF == 10 && OSC_T_CELLS == 12, "scalar tags in the spec"); + OSC_I_POPEN == 21 && OSC_I_HSTORE == 27 && OSC_I_SSTORE == 29 && OSC_I_FBIN == 30 && + OSC_I_FBITS == 36, "opcode numbers in the spec"); +_Static_assert(OSC_T_BOOL == 1 && OSC_T_U64 == 5 && OSC_T_I64 == 9 && OSC_T_REF == 10 && OSC_T_CELLS == 12 && OSC_T_F32 == 13 && OSC_T_F64 == 14, + "scalar tags in the spec"); _Static_assert(OSC_REF_OWN == 1 && OSC_REF_MUT == 3, "ref kinds in the spec"); static int g_fail; @@ -227,8 +229,8 @@ static void test_corpus(void) { if (v >= 1 && v <= OSC_IR_VERSION_MAX) seen[v]++; if (round_trip(c->u, c->name) == 0) ok++; } - printf("corpus: units=%d round_trip_ok=%d compile_refused=%d versions v1=%d v2=%d v3=%d v4=%d v5=%d\n", g_ncorpus, ok, - g_compile_refused, seen[1], seen[2], seen[3], seen[4], seen[5]); + printf("corpus: units=%d round_trip_ok=%d compile_refused=%d versions v1=%d v2=%d v3=%d v4=%d v5=%d v6=%d\n", g_ncorpus, ok, + g_compile_refused, seen[1], seen[2], seen[3], seen[4], seen[5], seen[6]); CHECK(g_ncorpus >= 40, "corpus too small: %d units", g_ncorpus); CHECK(ok == g_ncorpus, "corpus round trip: %d of %d", ok, g_ncorpus); for (int v = 1; v <= OSC_IR_VERSION_MAX; v++) CHECK(seen[v] > 0, "corpus has no version %d unit", v); @@ -425,7 +427,7 @@ static void test_classes(void) { k = knobs_default(); k.version = 0; build(&m, &k); EXPECT(m.b, m.n, OSC_IR_REFUSE_UNKNOWN_VERSION, "version 0"); k.version = OSC_IR_VERSION_MAX + 1; build(&m, &k); - EXPECT(m.b, m.n, OSC_IR_REFUSE_UNKNOWN_VERSION, "version 6"); + EXPECT(m.b, m.n, OSC_IR_REFUSE_UNKNOWN_VERSION, "version 7"); EXPECT(b.b, b.n - 1, OSC_IR_REFUSE_TRUNCATED, "last byte missing"); EXPECT(b.b, 7, OSC_IR_REFUSE_TRUNCATED, "magic without version"); k = knobs_default(); k.name_len = 64; k.name = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl"; build(&m, &k); @@ -445,10 +447,10 @@ static void test_classes(void) { EXPECT(m.b, m.n, OSC_IR_REFUSE_TRAILING, "one trailing byte"); k = knobs_default(); k.op0 = 0; build(&m, &k); EXPECT(m.b, m.n, OSC_IR_REFUSE_RANGE, "opcode 0"); - k.op0 = OSC_I_SSTORE + 1; build(&m, &k); - EXPECT(m.b, m.n, OSC_IR_REFUSE_RANGE, "opcode past SSTORE"); - k = knobs_default(); k.ret_tag = OSC_T_CELLS + 1; build(&m, &k); - EXPECT(m.b, m.n, OSC_IR_REFUSE_RANGE, "scalar tag 13"); + k.op0 = OSC_I_FBITS + 1; build(&m, &k); + EXPECT(m.b, m.n, OSC_IR_REFUSE_RANGE, "opcode past FBITS"); + k = knobs_default(); k.ret_tag = OSC_T_F64 + 1; build(&m, &k); + EXPECT(m.b, m.n, OSC_IR_REFUSE_RANGE, "scalar tag 15"); k = knobs_default(); k.dst = 0x8000; build(&m, &k); EXPECT(m.b, m.n, OSC_IR_REFUSE_RANGE, "register 0x8000"); k = knobs_default(); k.name_len = 3; k.name = "f\0g"; build(&m, &k); @@ -461,6 +463,8 @@ static void test_classes(void) { EXPECT(m.b, m.n, OSC_IR_REFUSE_VERSION_MISMATCH, "version 2 with no structs"); k.version = 5; build(&m, &k); EXPECT(m.b, m.n, OSC_IR_REFUSE_VERSION_MISMATCH, "version 5 with no slices"); + k.version = 6; build(&m, &k); + EXPECT(m.b, m.n, OSC_IR_REFUSE_VERSION_MISMATCH, "version 6 with no floats (OSC-4 Slice A)"); #undef EXPECT int classes = 0; for (int c = 1; c <= OSC_IR_REFUSAL_COUNT; c++) classes += refused[c];