Files
mandy/docs/contracts/code_embedded_data.json

23 lines
2.2 KiB
JSON

{
"piece": "Code-embedded data",
"status": "cpu_only",
"rank": 8,
"sentences": [
"155 VS/PS had \"undecodable words\".",
"They're **constant tables inside the code range** (float values like 0x3EF7…, plus zeros), read through `s_getpc_b64` + `s_add_u32`/`s_addc_u32` + `s_load` (147 of 155).",
"The translator re-anchors each instruction to its true FSSM offset by matching encodings, translates only code reachable from entry (a branch into data is rejected), and turns `s_getpc_b64` into code base + next-instruction offset.",
"**The runtime uploads each shader's FSSM blob into the heap and passes that VA as the code base.** Re-anchoring compares bytes exactly, except that VOP3P `op_sel_hi[2]` (bit 14) is ignored on two-source packed ops: the compiler stores 0 there, and LLVM prints its default of 1.",
"Unused VOP3/VOP3P `SRC1` (bits 49:41) and `SRC2` (bits 58:50) fields are also ignored when stored as 0 and printed as `0x80`: LLVM 23 re-encodes a source it doesn't read as inline constant 0 (one-source `v_rcp`/`v_log`/`v_sqrt_f32_e64`, two-source `v_sub_f32_e64`/`v_cmp_*_e64`/`v_mul_lo_u32`/`v_pk_mul_f16`).",
"Both checks for clean listings and re-anchoring use the parsed operand count to apply this exception only to unused sources.",
"A used source encoded as 0 reads `s0` and is never treated as inline zero.",
"`tests/semantic/test_printed_encoding.py` checks used `SRC1`/`SRC2` and an unused field with synthetic listings.",
"Confirmed by a count over the corpus with LLVM 23.1.5: without it, 1,471 of the 1,473 shaders with embedded data are rejected (\"reachable instruction with normalized encoding\"); with it, all 1,473 translate and pass `spirv-val`.",
"Runs with LLVM 21 already translated all of them, so older LLVMs presumably print the stored 0 (not re-checked).",
"Data words that decode with ignored fields set are printed re-encoded (e.g.",
"`0xbe8d2242` as `s_rfe_b64` `0xbe802242`), so they can never match.",
"Since the decoder consumed the same length, they are anchored in sequence and marked.",
"A shader that can *reach* a marked word is rejected; none of the corpus does.",
"All 155 now translate."
]
}