diff --git a/CHANGELOG.md b/CHANGELOG.md index e92b822..c5ec5ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,9 +16,10 @@ remains unsupported. - Extended the read-only RDNA2 planning CLI (`python3 -m qa rdna2`) with family/status filters, compact summaries, Codex-ready manifests under `artifacts/`, active-claim exclusion (family claims exclude those families; path-only claims block overlapping permitted files), coverage reconcile against `semantic_coverage` without inflating counts, and inventory diffs. Covered by `tests/qa/test_rdna2_plan.py`; planning only, no GPU production edits. ### Added +- Added decoding and Metal shader translation for the sixteen Wave32 VOPC 64-bit integer compares (#215). They read VGPR pairs, known even-aligned SGPR pairs or sign-extended inline integers and write the Wave32 VCC mask. CPU checks cover compilation and operand rejection. Native Metal readback is pending. - Added delay-loaded imports to the static PE probe (#244). `xenora probe --mode static` now reads the PE32+ delay-load directory and lists each delay-loaded import in `imports.csv` with its DLL, symbol or ordinal, and delay import address table slot. A new `import_table` column, inserted after `iat_rva`, marks every row `ordinary` or `delayed`; `import_kind` stays the last column. The existing totals and `missing_imports.csv` still cover ordinary imports only, and the JSON report adds `delayed_imports`, `delayed_imported_dlls_count` and `delay_import_error`. The table is bounded by the directory's declared size, which must hold the empty descriptor that ends it, and each descriptor's DLL name, import address table and import name table must be present and start in section data. A table that breaks these rules, is truncated, sets a reserved attribute bit or uses the earlier virtual-address descriptor form is reported with the entries read before the problem. `xenora imports sync` leaves delayed rows out of its backlog. Inspection stays static: nothing is bound or executed. Covered by an original fixture (`fixtures/pe/delay-imports.exe`, generated by `fixtures/pe/delay-imports.py`) whose imports were cross-checked locally with `llvm-readobj --coff-imports` from LLVM 23.1.6; awaiting independent review. - Added the sixteen gfx1030 SOPK integer forms through the semantic registry: `s_movk_i32`, `s_cmovk_i32`, `s_cmpk_{eq,lg,gt,ge,lt,le}_{i32,u32}`, `s_addk_i32` and `s_mulk_i32` (AMD guide sections 12.2 and 13.1.2), with SDST s0-s105 only and SIMM16 sign-extended (zero-extended for the unsigned compares). The registry gained the operand rules `sopk_sgpr` and `sopk_compare` and the operations `mov` and `cmov`; the decoder and the scalar translation fold them like SOP2 and SOPC. An independent guide-derived oracle (`tests/validation/tests/sopk.rs`, 4,184 cases and 398 rejections on both CPU interpreters and native Metal), an LLVM-assembled fixture `scalar-immediate.s` with IR and MSL goldens, and the LLVM three-way decoder check cover them (part of #215). -- Added an independent guide-derived oracle for the Wave32 16-bit (`v_cmp_{lt..ge}_{i16,u16}_e32`) and 64-bit (`v_cmp_{f..t}_{i64,u64}_e32`) integer compares in the reference and the second interpreter (6,212 lane cases, 1,208 rejections; contract in `docs/shaders/vector-compare.md` section 2a). The decoder and translator still reject these forms, and native Metal agreement is not yet shown. Part of #215. +- Added an independent guide-derived oracle for the Wave32 16-bit (`v_cmp_{lt..ge}_{i16,u16}_e32`) and 64-bit (`v_cmp_{f..t}_{i64,u64}_e32`) integer compares in the reference and the second interpreter (6,212 lane cases, 1,208 rejections; contract in `docs/shaders/vector-compare.md` section 2a). Part of #215. - Added `python3 -m qa rdna2 rank` to the read-only RDNA2 planner: it groups undeclared gfx1030 forms by the piece of work that would unlock them (an encoding variant of a declared form, a new operand rule, or a new primitive, from XML identity and operand shape only) and ranks the groups by forms per estimated cost, excluding claimed scopes, with `--no-float` to leave out floating-point groups until the FP contract exists (part of #215). - Added authoritative read-only x86-64 CPU inventory CLI (`python3 -m qa cpu-inventory`) over `crates/loader/x86/instructions.toml` via `generate_x86.load`, with opcode-map/prefix/operand summaries, native vs shared-semantic operation partitions from `dbt.rs`, fixture mnemonic evidence and a separate unsupported catalog. Does not count candidates as implemented. Covered by `tests/qa/test_cpu_inventory.py`. - Added typed runtime inventory CLI (`python3 -m qa runtime-inventory`) over `crates/loader/runtime/services.txt`, reporting implemented/partial/stub services separately from API-set aliases and leaving independently-verified empty unless recorded. Covered by `tests/qa/test_runtime_inventory.py`. diff --git a/crates/decoder/src/lib.rs b/crates/decoder/src/lib.rs index cc16295..c52092d 100644 --- a/crates/decoder/src/lib.rs +++ b/crates/decoder/src/lib.rs @@ -657,7 +657,19 @@ fn vector_compare( bytes: &[u8], ) -> Result<(Instruction, u8), DecodeErrorKind> { let src1 = ((first >> 9) & 0xff) as u8; - let (src0, len) = vector_src0(first, bytes, op.assembly_name())?; + let mnemonic = op.assembly_name(); + if op.semantics().width == 64 { + // Guide §3.6.3 requires even SGPR bases. Reject invalid selectors + // before reading a literal word or considering the execution mask. + let source = first & 0x1ff; + if src1 == 255 + || !matches!(source, 0..=104 | 128..=208 | 256..=510) + || (source <= 104 && !source.is_multiple_of(2)) + { + return Err(unsupported(mnemonic, "invalid 64-bit compare source")); + } + } + let (src0, len) = vector_src0(first, bytes, mnemonic)?; Ok((Instruction::VectorCompare { op, src0, src1 }, len)) } diff --git a/crates/isa/generate_semantics.py b/crates/isa/generate_semantics.py index 926543c..bbb6e2c 100755 --- a/crates/isa/generate_semantics.py +++ b/crates/isa/generate_semantics.py @@ -76,10 +76,9 @@ RELATIONS = { } # F and T exist only as VOPC compares (guide Table 59 offsets 0 and 7). VECTOR_ONLY_RELATIONS = {"f", "t"} -# Guide 12.9 Table 59 and Table 61: a 32-bit integer VOPC compare's opcode is -# its group base (128 for _I32, 192 for _U32) plus its relation's offset. This -# is the guide's opcode layout, not a reading of the mnemonic. -VOPC_INTEGER_BASES = {"signed": 128, "unsigned": 192} +# Guide 12.9 Tables 59 and 61: integer VOPC opcodes are the group base +# for the operand width and signedness plus the relation offset. +VOPC_INTEGER_BASES = {32: {"signed": 128, "unsigned": 192}, 64: {"signed": 160, "unsigned": 224}} VOPC_RELATION_OFFSETS = {"f": 0, "lt": 1, "eq": 2, "le": 3, "gt": 4, "lg": 5, "ge": 6, "t": 7} # (relation, signedness) -> primitive. Equality does not depend on signedness, # so both declared signednesses of EQ and LG share one primitive. @@ -164,7 +163,6 @@ PINNED_DOCUMENTS = { "file": "amdgpu_isa_rdna2.xml", }, } -WIDTHS = {32} # (operation, signedness) -> (required SCC effect, primitive, takes carry-in). # A form whose declaration is not a row here has no primitive and is rejected. @@ -363,6 +361,24 @@ OPERAND_RULES = { }, "kind": "vector_compare", }, + "vopc_vcc_pair": { + "rust": "VopcVccPair", + "enum": "VectorCompareOp", + "shape": { + "family": "VOPC", + "src": [ + {"field": "SRC0", "class": "vector_pair_or_inline_integer"}, + {"field": "VSRC1", "class": "vgpr_pair"}, + ], + "max_literals": 0, + }, + "unsupported": { + "src_vcc", "src_literal", "src_exec", "src_m0", "src_ttmp", "src_null", + "src_float_inline", "src_special", + }, + "kind": "vector_compare", + "width": 64, + }, "vop3_vgpr2": { "rust": "Vop3Vgpr2", "enum": "VectorAluOp", @@ -660,7 +676,11 @@ def _check_xml(form, rule, snapshot, errors): elif type(bits) is int: if data_format != f"FMT_NUM_I{bits}": errors.append(f"{label}: {field} has XML format {data_format}, not FMT_NUM_I{bits}") - elif is_source and data_format not in SOURCE_FORMATS.get(form["signedness"], ()): + elif is_source and data_format not in ( + {f"FMT_NUM_{'I' if form['signedness'] == 'signed' else 'U'}64"} + if form["operands"] == "vopc_vcc_pair" + else SOURCE_FORMATS.get(form["signedness"], ()) + ): errors.append( f"{label}: signedness {form['signedness']} contradicts XML format {data_format}" ) @@ -741,7 +761,8 @@ def validate(registry, snapshot): ) if form["exec"] != "unchanged": errors.append(f"{label}: exec {form['exec']} has no contract (requires unchanged)") - if type(form["width"]) is not int or form["width"] not in WIDTHS: + expected_width = (_implemented_rule(form) or {}).get("width", 32) + if type(form["width"]) is not int or form["width"] != expected_width: errors.append(f"{label}: width {form['width']} is not supported") for key, value in ( ("name", form["name"]), @@ -807,7 +828,7 @@ def validate(registry, snapshot): f"{expected} (guide 13.1.2), not {form['opcode']}" ) elif _rule_kind(form) == "vector_compare": - base = VOPC_INTEGER_BASES.get(form["signedness"]) + base = VOPC_INTEGER_BASES.get(expected_width, {}).get(form["signedness"]) expected = None if base is None else base + VOPC_RELATION_OFFSETS[relation] if form["opcode"] != expected: errors.append( @@ -1488,6 +1509,7 @@ def _render_enum(rule_name, forms, snapshot, positions): out += [" }", " }"] if kind in ("compare", "vector_compare"): result = "SCC" if kind == "compare" else "per-lane result" + has_pairs = any(form["width"] == 64 for form in forms) out += [ "", " /// The relation tested, with S0 on the left.", @@ -1504,11 +1526,27 @@ def _render_enum(rule_name, forms, snapshot, positions): "", f" /// The {result}: whether the relation holds for S0 and S1.", " pub const fn test(self, src0: u32, src1: u32) -> bool {", - " match self {", ] + if has_pairs: + out += [ + " self.test_bits(src0 as u64, src1 as u64)", + " }", + "", + " /// Test raw operand bits at the width declared by this VOPC form.", + " pub const fn test_bits(self, src0: u64, src1: u64) -> bool {", + ] + out += [" match self {"] for form in forms: - function = COMPARE_PRIMITIVES[(form[RELATION_KEY], form["signedness"])] - out.append(f" Self::{form['variant']} => primitive::{function}(src0, src1),") + relation = form[RELATION_KEY] + if form["width"] == 64 and relation not in VECTOR_ONLY_RELATIONS: + symbol = {"lt": "<", "eq": "==", "le": "<=", "gt": ">", "lg": "!=", "ge": ">="}[relation] + left, right = ("(src0 as i64)", "(src1 as i64)") if form["signedness"] == "signed" else ("src0", "src1") + expression = f"{left} {symbol} {right}" + else: + function = COMPARE_PRIMITIVES[(relation, form["signedness"])] + args = "src0 as u32, src1 as u32" if has_pairs else "src0, src1" + expression = f"primitive::{function}({args})" + out.append(f" Self::{form['variant']} => {expression},") out += [" }", " }", "}"] return out out += [ diff --git a/crates/isa/semantics/rdna2/vopc.toml b/crates/isa/semantics/rdna2/vopc.toml index d3bfe8a..b028b74 100644 --- a/crates/isa/semantics/rdna2/vopc.toml +++ b/crates/isa/semantics/rdna2/vopc.toml @@ -358,3 +358,352 @@ spec = [ { document = "guide", section = "3.9", page = 19 }, ] verify = ["reference", "independent", "metal", "llvm_encoding"] + +# Wave32 64-bit integer compares (guide 3.6.3, 6.2 Table 20 and 12.9). +[operand_rules.vopc_vcc_pair] +family = "VOPC" +src = [ + { field = "SRC0", class = "vector_pair_or_inline_integer" }, + { field = "VSRC1", class = "vgpr_pair" }, +] +max_literals = 0 +unsupported = [ + "src_vcc", "src_literal", "src_exec", "src_m0", "src_ttmp", "src_null", + "src_float_inline", "src_special", +] + +[[form]] +name = "V_CMP_LT_I64" +family = "VOPC" +opcode = 161 +variant = "CmpLtI64" +operation = "compare" +relation = "lt" +signedness = "signed" +carry_in = "none" +width = 64 +scc = "unchanged" +vcc = "lane_mask" +exec = "unchanged" +wave = "wave32" +operands = "vopc_vcc_pair" +spec = [ + { document = "guide", section = "12.9", page = 150 }, + { document = "guide", section = "3.9", page = 19 }, +] +verify = ["reference", "independent", "metal"] + +[[form]] +name = "V_CMP_EQ_I64" +family = "VOPC" +opcode = 162 +variant = "CmpEqI64" +operation = "compare" +relation = "eq" +signedness = "signed" +carry_in = "none" +width = 64 +scc = "unchanged" +vcc = "lane_mask" +exec = "unchanged" +wave = "wave32" +operands = "vopc_vcc_pair" +spec = [ + { document = "guide", section = "12.9", page = 150 }, + { document = "guide", section = "3.9", page = 19 }, +] +verify = ["reference", "independent", "metal"] + +[[form]] +name = "V_CMP_LE_I64" +family = "VOPC" +opcode = 163 +variant = "CmpLeI64" +operation = "compare" +relation = "le" +signedness = "signed" +carry_in = "none" +width = 64 +scc = "unchanged" +vcc = "lane_mask" +exec = "unchanged" +wave = "wave32" +operands = "vopc_vcc_pair" +spec = [ + { document = "guide", section = "12.9", page = 150 }, + { document = "guide", section = "3.9", page = 19 }, +] +verify = ["reference", "independent", "metal"] + +[[form]] +name = "V_CMP_GT_I64" +family = "VOPC" +opcode = 164 +variant = "CmpGtI64" +operation = "compare" +relation = "gt" +signedness = "signed" +carry_in = "none" +width = 64 +scc = "unchanged" +vcc = "lane_mask" +exec = "unchanged" +wave = "wave32" +operands = "vopc_vcc_pair" +spec = [ + { document = "guide", section = "12.9", page = 150 }, + { document = "guide", section = "3.9", page = 19 }, +] +verify = ["reference", "independent", "metal"] + +[[form]] +name = "V_CMP_NE_I64" +family = "VOPC" +opcode = 165 +variant = "CmpNeI64" +operation = "compare" +relation = "lg" +signedness = "signed" +carry_in = "none" +width = 64 +scc = "unchanged" +vcc = "lane_mask" +exec = "unchanged" +wave = "wave32" +operands = "vopc_vcc_pair" +spec = [ + { document = "guide", section = "12.9", page = 150 }, + { document = "guide", section = "3.9", page = 19 }, +] +verify = ["reference", "independent", "metal"] + +[[form]] +name = "V_CMP_GE_I64" +family = "VOPC" +opcode = 166 +variant = "CmpGeI64" +operation = "compare" +relation = "ge" +signedness = "signed" +carry_in = "none" +width = 64 +scc = "unchanged" +vcc = "lane_mask" +exec = "unchanged" +wave = "wave32" +operands = "vopc_vcc_pair" +spec = [ + { document = "guide", section = "12.9", page = 150 }, + { document = "guide", section = "3.9", page = 19 }, +] +verify = ["reference", "independent", "metal"] + +[[form]] +name = "V_CMP_LT_U64" +family = "VOPC" +opcode = 225 +variant = "CmpLtU64" +operation = "compare" +relation = "lt" +signedness = "unsigned" +carry_in = "none" +width = 64 +scc = "unchanged" +vcc = "lane_mask" +exec = "unchanged" +wave = "wave32" +operands = "vopc_vcc_pair" +spec = [ + { document = "guide", section = "12.9", page = 150 }, + { document = "guide", section = "3.9", page = 19 }, +] +verify = ["reference", "independent", "metal"] + +[[form]] +name = "V_CMP_EQ_U64" +family = "VOPC" +opcode = 226 +variant = "CmpEqU64" +operation = "compare" +relation = "eq" +signedness = "unsigned" +carry_in = "none" +width = 64 +scc = "unchanged" +vcc = "lane_mask" +exec = "unchanged" +wave = "wave32" +operands = "vopc_vcc_pair" +spec = [ + { document = "guide", section = "12.9", page = 150 }, + { document = "guide", section = "3.9", page = 19 }, +] +verify = ["reference", "independent", "metal"] + +[[form]] +name = "V_CMP_LE_U64" +family = "VOPC" +opcode = 227 +variant = "CmpLeU64" +operation = "compare" +relation = "le" +signedness = "unsigned" +carry_in = "none" +width = 64 +scc = "unchanged" +vcc = "lane_mask" +exec = "unchanged" +wave = "wave32" +operands = "vopc_vcc_pair" +spec = [ + { document = "guide", section = "12.9", page = 150 }, + { document = "guide", section = "3.9", page = 19 }, +] +verify = ["reference", "independent", "metal"] + +[[form]] +name = "V_CMP_GT_U64" +family = "VOPC" +opcode = 228 +variant = "CmpGtU64" +operation = "compare" +relation = "gt" +signedness = "unsigned" +carry_in = "none" +width = 64 +scc = "unchanged" +vcc = "lane_mask" +exec = "unchanged" +wave = "wave32" +operands = "vopc_vcc_pair" +spec = [ + { document = "guide", section = "12.9", page = 150 }, + { document = "guide", section = "3.9", page = 19 }, +] +verify = ["reference", "independent", "metal"] + +[[form]] +name = "V_CMP_NE_U64" +family = "VOPC" +opcode = 229 +variant = "CmpNeU64" +operation = "compare" +relation = "lg" +signedness = "unsigned" +carry_in = "none" +width = 64 +scc = "unchanged" +vcc = "lane_mask" +exec = "unchanged" +wave = "wave32" +operands = "vopc_vcc_pair" +spec = [ + { document = "guide", section = "12.9", page = 150 }, + { document = "guide", section = "3.9", page = 19 }, +] +verify = ["reference", "independent", "metal"] + +[[form]] +name = "V_CMP_GE_U64" +family = "VOPC" +opcode = 230 +variant = "CmpGeU64" +operation = "compare" +relation = "ge" +signedness = "unsigned" +carry_in = "none" +width = 64 +scc = "unchanged" +vcc = "lane_mask" +exec = "unchanged" +wave = "wave32" +operands = "vopc_vcc_pair" +spec = [ + { document = "guide", section = "12.9", page = 150 }, + { document = "guide", section = "3.9", page = 19 }, +] +verify = ["reference", "independent", "metal"] + +[[form]] +name = "V_CMP_F_I64" +family = "VOPC" +opcode = 160 +variant = "CmpFI64" +operation = "compare" +relation = "f" +signedness = "signed" +carry_in = "none" +width = 64 +scc = "unchanged" +vcc = "lane_mask" +exec = "unchanged" +wave = "wave32" +operands = "vopc_vcc_pair" +spec = [ + { document = "guide", section = "12.9", page = 150 }, + { document = "guide", section = "3.9", page = 19 }, +] +verify = ["reference", "independent", "metal"] + +[[form]] +name = "V_CMP_T_I64" +family = "VOPC" +opcode = 167 +variant = "CmpTI64" +operation = "compare" +relation = "t" +signedness = "signed" +carry_in = "none" +width = 64 +scc = "unchanged" +vcc = "lane_mask" +exec = "unchanged" +wave = "wave32" +operands = "vopc_vcc_pair" +spec = [ + { document = "guide", section = "12.9", page = 150 }, + { document = "guide", section = "3.9", page = 19 }, +] +verify = ["reference", "independent", "metal"] + +[[form]] +name = "V_CMP_F_U64" +family = "VOPC" +opcode = 224 +variant = "CmpFU64" +operation = "compare" +relation = "f" +signedness = "unsigned" +carry_in = "none" +width = 64 +scc = "unchanged" +vcc = "lane_mask" +exec = "unchanged" +wave = "wave32" +operands = "vopc_vcc_pair" +spec = [ + { document = "guide", section = "12.9", page = 150 }, + { document = "guide", section = "3.9", page = 19 }, +] +verify = ["reference", "independent", "metal"] + +[[form]] +name = "V_CMP_T_U64" +family = "VOPC" +opcode = 231 +variant = "CmpTU64" +operation = "compare" +relation = "t" +signedness = "unsigned" +carry_in = "none" +width = 64 +scc = "unchanged" +vcc = "lane_mask" +exec = "unchanged" +wave = "wave32" +operands = "vopc_vcc_pair" +spec = [ + { document = "guide", section = "12.9", page = 150 }, + { document = "guide", section = "3.9", page = 19 }, +] +verify = ["reference", "independent", "metal"] diff --git a/crates/isa/src/lib.rs b/crates/isa/src/lib.rs index ccc26fa..cd0ffa8 100644 --- a/crates/isa/src/lib.rs +++ b/crates/isa/src/lib.rs @@ -199,8 +199,9 @@ pub enum Instruction { src: u8, simm16: u16, }, - /// VOPC 32-bit integer compare writing a Wave32 mask to `vcc_lo`. - /// `src0` is a VGPR, `s0-s105`, `vcc_lo`, an inline integer or a literal. + /// VOPC integer compare writing a Wave32 mask to `vcc_lo`. + /// For 64-bit forms register operands name pair bases and the immediate + /// contains the low word of a sign-extended inline integer. VectorCompare { op: VectorCompareOp, src0: VectorSource, @@ -351,6 +352,19 @@ impl fmt::Display for Instruction { Self::ScalarImmediateCompare { src, simm16, .. } => { write!(formatter, " s{src}, {simm16:#x}") } + Self::VectorCompare { op, src0, src1 } if op.semantics().width == 64 => { + formatter.write_str(" vcc_lo, ")?; + match src0 { + VectorSource::Register(base) => { + write!(formatter, "v[{base}:{}]", u16::from(base) + 1)?; + } + VectorSource::Scalar(base) => { + write!(formatter, "s[{base}:{}]", u16::from(base) + 1)?; + } + VectorSource::Immediate(bits) => write!(formatter, "{}", bits as i32)?, + } + write!(formatter, ", v[{src1}:{}]", u16::from(src1) + 1) + } Self::VectorCompare { src0, src1, .. } => { write!(formatter, " vcc_lo, {src0}, v{src1}") } diff --git a/crates/isa/src/semantics.rs b/crates/isa/src/semantics.rs index c588a91..f4b6d7f 100644 --- a/crates/isa/src/semantics.rs +++ b/crates/isa/src/semantics.rs @@ -222,6 +222,9 @@ pub enum OperandRule { /// s0-s105, `vcc_lo`, an inline integer -16..64 or a literal word; VSRC1 is a /// VGPR. Everything else is rejected as unsupported. VopcVcc, + /// Wave32 VOPC with a VGPR pair, even normal SGPR pair or inline integer + /// as SRC0 and a VGPR pair as VSRC1. The destination is `vcc_lo`. + VopcVccPair, /// VOP3 encoding of a VOP2 vector form: VDST is v0-v255, SRC0 and SRC1 are /// VGPRs, no input or output modifiers, SRC2 unused. Everything else is /// rejected as unsupported. diff --git a/crates/isa/src/semantics_gen.rs b/crates/isa/src/semantics_gen.rs index 8a72f6c..6349d0c 100644 --- a/crates/isa/src/semantics_gen.rs +++ b/crates/isa/src/semantics_gen.rs @@ -1789,7 +1789,7 @@ impl VectorAluOp { } } -/// VOPC operations declared in the semantic registry (operand rule `vopc_vcc`). +/// VOPC operations declared in the semantic registry (operand rules `vopc_vcc`, `vopc_vcc_pair`). #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum VectorCompareOp { /// `v_cmp_lt_i32` (VOPC opcode 129): signed compare lt, VCC = lane_mask. @@ -1824,6 +1824,38 @@ pub enum VectorCompareOp { CmpFU32, /// `v_cmp_t_u32` (VOPC opcode 199): unsigned compare t, VCC = lane_mask. CmpTU32, + /// `v_cmp_lt_i64` (VOPC opcode 161): signed compare lt, VCC = lane_mask. + CmpLtI64, + /// `v_cmp_eq_i64` (VOPC opcode 162): signed compare eq, VCC = lane_mask. + CmpEqI64, + /// `v_cmp_le_i64` (VOPC opcode 163): signed compare le, VCC = lane_mask. + CmpLeI64, + /// `v_cmp_gt_i64` (VOPC opcode 164): signed compare gt, VCC = lane_mask. + CmpGtI64, + /// `v_cmp_ne_i64` (VOPC opcode 165): signed compare lg, VCC = lane_mask. + CmpNeI64, + /// `v_cmp_ge_i64` (VOPC opcode 166): signed compare ge, VCC = lane_mask. + CmpGeI64, + /// `v_cmp_lt_u64` (VOPC opcode 225): unsigned compare lt, VCC = lane_mask. + CmpLtU64, + /// `v_cmp_eq_u64` (VOPC opcode 226): unsigned compare eq, VCC = lane_mask. + CmpEqU64, + /// `v_cmp_le_u64` (VOPC opcode 227): unsigned compare le, VCC = lane_mask. + CmpLeU64, + /// `v_cmp_gt_u64` (VOPC opcode 228): unsigned compare gt, VCC = lane_mask. + CmpGtU64, + /// `v_cmp_ne_u64` (VOPC opcode 229): unsigned compare lg, VCC = lane_mask. + CmpNeU64, + /// `v_cmp_ge_u64` (VOPC opcode 230): unsigned compare ge, VCC = lane_mask. + CmpGeU64, + /// `v_cmp_f_i64` (VOPC opcode 160): signed compare f, VCC = lane_mask. + CmpFI64, + /// `v_cmp_t_i64` (VOPC opcode 167): signed compare t, VCC = lane_mask. + CmpTI64, + /// `v_cmp_f_u64` (VOPC opcode 224): unsigned compare f, VCC = lane_mask. + CmpFU64, + /// `v_cmp_t_u64` (VOPC opcode 231): unsigned compare t, VCC = lane_mask. + CmpTU64, } /// VectorCompareOp by VOPC OP field value; `None` for undeclared opcodes. @@ -1988,14 +2020,14 @@ const VECTOR_COMPARE_OP_BY_OPCODE: [Option; 256] = [ None, None, None, - None, - None, - None, - None, - None, - None, - None, - None, + Some(VectorCompareOp::CmpFI64), + Some(VectorCompareOp::CmpLtI64), + Some(VectorCompareOp::CmpEqI64), + Some(VectorCompareOp::CmpLeI64), + Some(VectorCompareOp::CmpGtI64), + Some(VectorCompareOp::CmpNeI64), + Some(VectorCompareOp::CmpGeI64), + Some(VectorCompareOp::CmpTI64), None, None, None, @@ -2052,14 +2084,14 @@ const VECTOR_COMPARE_OP_BY_OPCODE: [Option; 256] = [ None, None, None, - None, - None, - None, - None, - None, - None, - None, - None, + Some(VectorCompareOp::CmpFU64), + Some(VectorCompareOp::CmpLtU64), + Some(VectorCompareOp::CmpEqU64), + Some(VectorCompareOp::CmpLeU64), + Some(VectorCompareOp::CmpGtU64), + Some(VectorCompareOp::CmpNeU64), + Some(VectorCompareOp::CmpGeU64), + Some(VectorCompareOp::CmpTU64), None, None, None, @@ -2088,7 +2120,7 @@ const VECTOR_COMPARE_OP_BY_OPCODE: [Option; 256] = [ impl VectorCompareOp { /// Every operation, in registry order. - pub const ALL: [Self; 16] = [ + pub const ALL: [Self; 32] = [ Self::CmpLtI32, Self::CmpEqI32, Self::CmpLeI32, @@ -2105,6 +2137,22 @@ impl VectorCompareOp { Self::CmpTI32, Self::CmpFU32, Self::CmpTU32, + Self::CmpLtI64, + Self::CmpEqI64, + Self::CmpLeI64, + Self::CmpGtI64, + Self::CmpNeI64, + Self::CmpGeI64, + Self::CmpLtU64, + Self::CmpEqU64, + Self::CmpLeU64, + Self::CmpGtU64, + Self::CmpNeU64, + Self::CmpGeU64, + Self::CmpFI64, + Self::CmpTI64, + Self::CmpFU64, + Self::CmpTU64, ]; /// Selects the operation from a first instruction word: the VOPC encoding @@ -2135,6 +2183,22 @@ impl VectorCompareOp { Self::CmpTI32 => "v_cmp_t_i32", Self::CmpFU32 => "v_cmp_f_u32", Self::CmpTU32 => "v_cmp_t_u32", + Self::CmpLtI64 => "v_cmp_lt_i64", + Self::CmpEqI64 => "v_cmp_eq_i64", + Self::CmpLeI64 => "v_cmp_le_i64", + Self::CmpGtI64 => "v_cmp_gt_i64", + Self::CmpNeI64 => "v_cmp_ne_i64", + Self::CmpGeI64 => "v_cmp_ge_i64", + Self::CmpLtU64 => "v_cmp_lt_u64", + Self::CmpEqU64 => "v_cmp_eq_u64", + Self::CmpLeU64 => "v_cmp_le_u64", + Self::CmpGtU64 => "v_cmp_gt_u64", + Self::CmpNeU64 => "v_cmp_ne_u64", + Self::CmpGeU64 => "v_cmp_ge_u64", + Self::CmpFI64 => "v_cmp_f_i64", + Self::CmpTI64 => "v_cmp_t_i64", + Self::CmpFU64 => "v_cmp_f_u64", + Self::CmpTU64 => "v_cmp_t_u64", } } @@ -2157,6 +2221,22 @@ impl VectorCompareOp { Self::CmpTI32 => 104, Self::CmpFU32 => 105, Self::CmpTU32 => 106, + Self::CmpLtI64 => 107, + Self::CmpEqI64 => 108, + Self::CmpLeI64 => 109, + Self::CmpGtI64 => 110, + Self::CmpNeI64 => 111, + Self::CmpGeI64 => 112, + Self::CmpLtU64 => 113, + Self::CmpEqU64 => 114, + Self::CmpLeU64 => 115, + Self::CmpGtU64 => 116, + Self::CmpNeU64 => 117, + Self::CmpGeU64 => 118, + Self::CmpFI64 => 119, + Self::CmpTI64 => 120, + Self::CmpFU64 => 121, + Self::CmpTU64 => 122, }] } @@ -2179,6 +2259,22 @@ impl VectorCompareOp { Self::CmpTI32 => "v_cmp_t_i32_e32", Self::CmpFU32 => "v_cmp_f_u32_e32", Self::CmpTU32 => "v_cmp_t_u32_e32", + Self::CmpLtI64 => "v_cmp_lt_i64_e32", + Self::CmpEqI64 => "v_cmp_eq_i64_e32", + Self::CmpLeI64 => "v_cmp_le_i64_e32", + Self::CmpGtI64 => "v_cmp_gt_i64_e32", + Self::CmpNeI64 => "v_cmp_ne_i64_e32", + Self::CmpGeI64 => "v_cmp_ge_i64_e32", + Self::CmpLtU64 => "v_cmp_lt_u64_e32", + Self::CmpEqU64 => "v_cmp_eq_u64_e32", + Self::CmpLeU64 => "v_cmp_le_u64_e32", + Self::CmpGtU64 => "v_cmp_gt_u64_e32", + Self::CmpNeU64 => "v_cmp_ne_u64_e32", + Self::CmpGeU64 => "v_cmp_ge_u64_e32", + Self::CmpFI64 => "v_cmp_f_i64_e32", + Self::CmpTI64 => "v_cmp_t_i64_e32", + Self::CmpFU64 => "v_cmp_f_u64_e32", + Self::CmpTU64 => "v_cmp_t_u64_e32", } } @@ -2201,6 +2297,22 @@ impl VectorCompareOp { Self::CmpTI32 => true, Self::CmpFU32 => false, Self::CmpTU32 => false, + Self::CmpLtI64 => true, + Self::CmpEqI64 => true, + Self::CmpLeI64 => true, + Self::CmpGtI64 => true, + Self::CmpNeI64 => true, + Self::CmpGeI64 => true, + Self::CmpLtU64 => false, + Self::CmpEqU64 => false, + Self::CmpLeU64 => false, + Self::CmpGtU64 => false, + Self::CmpNeU64 => false, + Self::CmpGeU64 => false, + Self::CmpFI64 => true, + Self::CmpTI64 => true, + Self::CmpFU64 => false, + Self::CmpTU64 => false, } } @@ -2223,28 +2335,65 @@ impl VectorCompareOp { Self::CmpTI32 => CompareRelation::True, Self::CmpFU32 => CompareRelation::False, Self::CmpTU32 => CompareRelation::True, + Self::CmpLtI64 => CompareRelation::Less, + Self::CmpEqI64 => CompareRelation::Equal, + Self::CmpLeI64 => CompareRelation::LessOrEqual, + Self::CmpGtI64 => CompareRelation::Greater, + Self::CmpNeI64 => CompareRelation::NotEqual, + Self::CmpGeI64 => CompareRelation::GreaterOrEqual, + Self::CmpLtU64 => CompareRelation::Less, + Self::CmpEqU64 => CompareRelation::Equal, + Self::CmpLeU64 => CompareRelation::LessOrEqual, + Self::CmpGtU64 => CompareRelation::Greater, + Self::CmpNeU64 => CompareRelation::NotEqual, + Self::CmpGeU64 => CompareRelation::GreaterOrEqual, + Self::CmpFI64 => CompareRelation::False, + Self::CmpTI64 => CompareRelation::True, + Self::CmpFU64 => CompareRelation::False, + Self::CmpTU64 => CompareRelation::True, } } /// The per-lane result: whether the relation holds for S0 and S1. pub const fn test(self, src0: u32, src1: u32) -> bool { + self.test_bits(src0 as u64, src1 as u64) + } + + /// Test raw operand bits at the width declared by this VOPC form. + pub const fn test_bits(self, src0: u64, src1: u64) -> bool { match self { - Self::CmpLtI32 => primitive::lt_i32(src0, src1), - Self::CmpEqI32 => primitive::eq_b32(src0, src1), - Self::CmpLeI32 => primitive::le_i32(src0, src1), - Self::CmpGtI32 => primitive::gt_i32(src0, src1), - Self::CmpNeI32 => primitive::ne_b32(src0, src1), - Self::CmpGeI32 => primitive::ge_i32(src0, src1), - Self::CmpLtU32 => primitive::lt_u32(src0, src1), - Self::CmpEqU32 => primitive::eq_b32(src0, src1), - Self::CmpLeU32 => primitive::le_u32(src0, src1), - Self::CmpGtU32 => primitive::gt_u32(src0, src1), - Self::CmpNeU32 => primitive::ne_b32(src0, src1), - Self::CmpGeU32 => primitive::ge_u32(src0, src1), - Self::CmpFI32 => primitive::false_b32(src0, src1), - Self::CmpTI32 => primitive::true_b32(src0, src1), - Self::CmpFU32 => primitive::false_b32(src0, src1), - Self::CmpTU32 => primitive::true_b32(src0, src1), + Self::CmpLtI32 => primitive::lt_i32(src0 as u32, src1 as u32), + Self::CmpEqI32 => primitive::eq_b32(src0 as u32, src1 as u32), + Self::CmpLeI32 => primitive::le_i32(src0 as u32, src1 as u32), + Self::CmpGtI32 => primitive::gt_i32(src0 as u32, src1 as u32), + Self::CmpNeI32 => primitive::ne_b32(src0 as u32, src1 as u32), + Self::CmpGeI32 => primitive::ge_i32(src0 as u32, src1 as u32), + Self::CmpLtU32 => primitive::lt_u32(src0 as u32, src1 as u32), + Self::CmpEqU32 => primitive::eq_b32(src0 as u32, src1 as u32), + Self::CmpLeU32 => primitive::le_u32(src0 as u32, src1 as u32), + Self::CmpGtU32 => primitive::gt_u32(src0 as u32, src1 as u32), + Self::CmpNeU32 => primitive::ne_b32(src0 as u32, src1 as u32), + Self::CmpGeU32 => primitive::ge_u32(src0 as u32, src1 as u32), + Self::CmpFI32 => primitive::false_b32(src0 as u32, src1 as u32), + Self::CmpTI32 => primitive::true_b32(src0 as u32, src1 as u32), + Self::CmpFU32 => primitive::false_b32(src0 as u32, src1 as u32), + Self::CmpTU32 => primitive::true_b32(src0 as u32, src1 as u32), + Self::CmpLtI64 => (src0 as i64) < (src1 as i64), + Self::CmpEqI64 => (src0 as i64) == (src1 as i64), + Self::CmpLeI64 => (src0 as i64) <= (src1 as i64), + Self::CmpGtI64 => (src0 as i64) > (src1 as i64), + Self::CmpNeI64 => (src0 as i64) != (src1 as i64), + Self::CmpGeI64 => (src0 as i64) >= (src1 as i64), + Self::CmpLtU64 => src0 < src1, + Self::CmpEqU64 => src0 == src1, + Self::CmpLeU64 => src0 <= src1, + Self::CmpGtU64 => src0 > src1, + Self::CmpNeU64 => src0 != src1, + Self::CmpGeU64 => src0 >= src1, + Self::CmpFI64 => primitive::false_b32(src0 as u32, src1 as u32), + Self::CmpTI64 => primitive::true_b32(src0 as u32, src1 as u32), + Self::CmpFU64 => primitive::false_b32(src0 as u32, src1 as u32), + Self::CmpTU64 => primitive::true_b32(src0 as u32, src1 as u32), } } } @@ -2292,13 +2441,13 @@ impl VectorAluVop3Op { /// The validated registry row of this encoding. pub fn semantics(self) -> &'static FormSemantics { &FORMS[match self { - Self::AddNcU32 => 107, + Self::AddNcU32 => 123, }] } } /// Identity of every registry form and encoding variant, in registry order. -pub const FORM_IDS: [(&str, EncodingFamily); 108] = [ +pub const FORM_IDS: [(&str, EncodingFamily); 124] = [ ("S_ADD_U32", EncodingFamily::Sop2), ("S_SUB_U32", EncodingFamily::Sop2), ("S_ADD_I32", EncodingFamily::Sop2), @@ -2406,11 +2555,27 @@ pub const FORM_IDS: [(&str, EncodingFamily); 108] = [ ("V_CMP_T_I32", EncodingFamily::Vopc), ("V_CMP_F_U32", EncodingFamily::Vopc), ("V_CMP_T_U32", EncodingFamily::Vopc), + ("V_CMP_LT_I64", EncodingFamily::Vopc), + ("V_CMP_EQ_I64", EncodingFamily::Vopc), + ("V_CMP_LE_I64", EncodingFamily::Vopc), + ("V_CMP_GT_I64", EncodingFamily::Vopc), + ("V_CMP_NE_I64", EncodingFamily::Vopc), + ("V_CMP_GE_I64", EncodingFamily::Vopc), + ("V_CMP_LT_U64", EncodingFamily::Vopc), + ("V_CMP_EQ_U64", EncodingFamily::Vopc), + ("V_CMP_LE_U64", EncodingFamily::Vopc), + ("V_CMP_GT_U64", EncodingFamily::Vopc), + ("V_CMP_NE_U64", EncodingFamily::Vopc), + ("V_CMP_GE_U64", EncodingFamily::Vopc), + ("V_CMP_F_I64", EncodingFamily::Vopc), + ("V_CMP_T_I64", EncodingFamily::Vopc), + ("V_CMP_F_U64", EncodingFamily::Vopc), + ("V_CMP_T_U64", EncodingFamily::Vopc), ("V_ADD_NC_U32", EncodingFamily::Vop3), ]; /// One validated row per registry form, in registry order. -pub static FORMS: [FormSemantics; 108] = [ +pub static FORMS: [FormSemantics; 124] = [ FormSemantics { name: "S_ADD_U32", family: EncodingFamily::Sop2, @@ -4658,6 +4823,342 @@ pub static FORMS: [FormSemantics; 108] = [ spec: &[SpecRef { document: Document::Guide, section: "12.9", page: 150 }, SpecRef { document: Document::Guide, section: "3.9", page: 19 }], verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal, Evidence::LlvmEncoding], }, + FormSemantics { + name: "V_CMP_LT_I64", + family: EncodingFamily::Vopc, + opcode: 161, + operation: Operation::Compare, + signedness: Signedness::Signed, + carry_in: CarryIn::None, + width: 64, + shift_count_bits: 0, + shift_amount: 0, + swap_sources: false, + source_bits: 64, + relation: Some(CompareRelation::Less), + scc: SccEffect::Unchanged, + vcc: MaskEffect::LaneMask, + exec: MaskEffect::Unchanged, + wave: Wave::Wave32, + operands: OperandRule::VopcVccPair, + spec: &[SpecRef { document: Document::Guide, section: "12.9", page: 150 }, SpecRef { document: Document::Guide, section: "3.9", page: 19 }], + verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal], + }, + FormSemantics { + name: "V_CMP_EQ_I64", + family: EncodingFamily::Vopc, + opcode: 162, + operation: Operation::Compare, + signedness: Signedness::Signed, + carry_in: CarryIn::None, + width: 64, + shift_count_bits: 0, + shift_amount: 0, + swap_sources: false, + source_bits: 64, + relation: Some(CompareRelation::Equal), + scc: SccEffect::Unchanged, + vcc: MaskEffect::LaneMask, + exec: MaskEffect::Unchanged, + wave: Wave::Wave32, + operands: OperandRule::VopcVccPair, + spec: &[SpecRef { document: Document::Guide, section: "12.9", page: 150 }, SpecRef { document: Document::Guide, section: "3.9", page: 19 }], + verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal], + }, + FormSemantics { + name: "V_CMP_LE_I64", + family: EncodingFamily::Vopc, + opcode: 163, + operation: Operation::Compare, + signedness: Signedness::Signed, + carry_in: CarryIn::None, + width: 64, + shift_count_bits: 0, + shift_amount: 0, + swap_sources: false, + source_bits: 64, + relation: Some(CompareRelation::LessOrEqual), + scc: SccEffect::Unchanged, + vcc: MaskEffect::LaneMask, + exec: MaskEffect::Unchanged, + wave: Wave::Wave32, + operands: OperandRule::VopcVccPair, + spec: &[SpecRef { document: Document::Guide, section: "12.9", page: 150 }, SpecRef { document: Document::Guide, section: "3.9", page: 19 }], + verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal], + }, + FormSemantics { + name: "V_CMP_GT_I64", + family: EncodingFamily::Vopc, + opcode: 164, + operation: Operation::Compare, + signedness: Signedness::Signed, + carry_in: CarryIn::None, + width: 64, + shift_count_bits: 0, + shift_amount: 0, + swap_sources: false, + source_bits: 64, + relation: Some(CompareRelation::Greater), + scc: SccEffect::Unchanged, + vcc: MaskEffect::LaneMask, + exec: MaskEffect::Unchanged, + wave: Wave::Wave32, + operands: OperandRule::VopcVccPair, + spec: &[SpecRef { document: Document::Guide, section: "12.9", page: 150 }, SpecRef { document: Document::Guide, section: "3.9", page: 19 }], + verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal], + }, + FormSemantics { + name: "V_CMP_NE_I64", + family: EncodingFamily::Vopc, + opcode: 165, + operation: Operation::Compare, + signedness: Signedness::Signed, + carry_in: CarryIn::None, + width: 64, + shift_count_bits: 0, + shift_amount: 0, + swap_sources: false, + source_bits: 64, + relation: Some(CompareRelation::NotEqual), + scc: SccEffect::Unchanged, + vcc: MaskEffect::LaneMask, + exec: MaskEffect::Unchanged, + wave: Wave::Wave32, + operands: OperandRule::VopcVccPair, + spec: &[SpecRef { document: Document::Guide, section: "12.9", page: 150 }, SpecRef { document: Document::Guide, section: "3.9", page: 19 }], + verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal], + }, + FormSemantics { + name: "V_CMP_GE_I64", + family: EncodingFamily::Vopc, + opcode: 166, + operation: Operation::Compare, + signedness: Signedness::Signed, + carry_in: CarryIn::None, + width: 64, + shift_count_bits: 0, + shift_amount: 0, + swap_sources: false, + source_bits: 64, + relation: Some(CompareRelation::GreaterOrEqual), + scc: SccEffect::Unchanged, + vcc: MaskEffect::LaneMask, + exec: MaskEffect::Unchanged, + wave: Wave::Wave32, + operands: OperandRule::VopcVccPair, + spec: &[SpecRef { document: Document::Guide, section: "12.9", page: 150 }, SpecRef { document: Document::Guide, section: "3.9", page: 19 }], + verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal], + }, + FormSemantics { + name: "V_CMP_LT_U64", + family: EncodingFamily::Vopc, + opcode: 225, + operation: Operation::Compare, + signedness: Signedness::Unsigned, + carry_in: CarryIn::None, + width: 64, + shift_count_bits: 0, + shift_amount: 0, + swap_sources: false, + source_bits: 64, + relation: Some(CompareRelation::Less), + scc: SccEffect::Unchanged, + vcc: MaskEffect::LaneMask, + exec: MaskEffect::Unchanged, + wave: Wave::Wave32, + operands: OperandRule::VopcVccPair, + spec: &[SpecRef { document: Document::Guide, section: "12.9", page: 150 }, SpecRef { document: Document::Guide, section: "3.9", page: 19 }], + verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal], + }, + FormSemantics { + name: "V_CMP_EQ_U64", + family: EncodingFamily::Vopc, + opcode: 226, + operation: Operation::Compare, + signedness: Signedness::Unsigned, + carry_in: CarryIn::None, + width: 64, + shift_count_bits: 0, + shift_amount: 0, + swap_sources: false, + source_bits: 64, + relation: Some(CompareRelation::Equal), + scc: SccEffect::Unchanged, + vcc: MaskEffect::LaneMask, + exec: MaskEffect::Unchanged, + wave: Wave::Wave32, + operands: OperandRule::VopcVccPair, + spec: &[SpecRef { document: Document::Guide, section: "12.9", page: 150 }, SpecRef { document: Document::Guide, section: "3.9", page: 19 }], + verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal], + }, + FormSemantics { + name: "V_CMP_LE_U64", + family: EncodingFamily::Vopc, + opcode: 227, + operation: Operation::Compare, + signedness: Signedness::Unsigned, + carry_in: CarryIn::None, + width: 64, + shift_count_bits: 0, + shift_amount: 0, + swap_sources: false, + source_bits: 64, + relation: Some(CompareRelation::LessOrEqual), + scc: SccEffect::Unchanged, + vcc: MaskEffect::LaneMask, + exec: MaskEffect::Unchanged, + wave: Wave::Wave32, + operands: OperandRule::VopcVccPair, + spec: &[SpecRef { document: Document::Guide, section: "12.9", page: 150 }, SpecRef { document: Document::Guide, section: "3.9", page: 19 }], + verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal], + }, + FormSemantics { + name: "V_CMP_GT_U64", + family: EncodingFamily::Vopc, + opcode: 228, + operation: Operation::Compare, + signedness: Signedness::Unsigned, + carry_in: CarryIn::None, + width: 64, + shift_count_bits: 0, + shift_amount: 0, + swap_sources: false, + source_bits: 64, + relation: Some(CompareRelation::Greater), + scc: SccEffect::Unchanged, + vcc: MaskEffect::LaneMask, + exec: MaskEffect::Unchanged, + wave: Wave::Wave32, + operands: OperandRule::VopcVccPair, + spec: &[SpecRef { document: Document::Guide, section: "12.9", page: 150 }, SpecRef { document: Document::Guide, section: "3.9", page: 19 }], + verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal], + }, + FormSemantics { + name: "V_CMP_NE_U64", + family: EncodingFamily::Vopc, + opcode: 229, + operation: Operation::Compare, + signedness: Signedness::Unsigned, + carry_in: CarryIn::None, + width: 64, + shift_count_bits: 0, + shift_amount: 0, + swap_sources: false, + source_bits: 64, + relation: Some(CompareRelation::NotEqual), + scc: SccEffect::Unchanged, + vcc: MaskEffect::LaneMask, + exec: MaskEffect::Unchanged, + wave: Wave::Wave32, + operands: OperandRule::VopcVccPair, + spec: &[SpecRef { document: Document::Guide, section: "12.9", page: 150 }, SpecRef { document: Document::Guide, section: "3.9", page: 19 }], + verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal], + }, + FormSemantics { + name: "V_CMP_GE_U64", + family: EncodingFamily::Vopc, + opcode: 230, + operation: Operation::Compare, + signedness: Signedness::Unsigned, + carry_in: CarryIn::None, + width: 64, + shift_count_bits: 0, + shift_amount: 0, + swap_sources: false, + source_bits: 64, + relation: Some(CompareRelation::GreaterOrEqual), + scc: SccEffect::Unchanged, + vcc: MaskEffect::LaneMask, + exec: MaskEffect::Unchanged, + wave: Wave::Wave32, + operands: OperandRule::VopcVccPair, + spec: &[SpecRef { document: Document::Guide, section: "12.9", page: 150 }, SpecRef { document: Document::Guide, section: "3.9", page: 19 }], + verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal], + }, + FormSemantics { + name: "V_CMP_F_I64", + family: EncodingFamily::Vopc, + opcode: 160, + operation: Operation::Compare, + signedness: Signedness::Signed, + carry_in: CarryIn::None, + width: 64, + shift_count_bits: 0, + shift_amount: 0, + swap_sources: false, + source_bits: 64, + relation: Some(CompareRelation::False), + scc: SccEffect::Unchanged, + vcc: MaskEffect::LaneMask, + exec: MaskEffect::Unchanged, + wave: Wave::Wave32, + operands: OperandRule::VopcVccPair, + spec: &[SpecRef { document: Document::Guide, section: "12.9", page: 150 }, SpecRef { document: Document::Guide, section: "3.9", page: 19 }], + verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal], + }, + FormSemantics { + name: "V_CMP_T_I64", + family: EncodingFamily::Vopc, + opcode: 167, + operation: Operation::Compare, + signedness: Signedness::Signed, + carry_in: CarryIn::None, + width: 64, + shift_count_bits: 0, + shift_amount: 0, + swap_sources: false, + source_bits: 64, + relation: Some(CompareRelation::True), + scc: SccEffect::Unchanged, + vcc: MaskEffect::LaneMask, + exec: MaskEffect::Unchanged, + wave: Wave::Wave32, + operands: OperandRule::VopcVccPair, + spec: &[SpecRef { document: Document::Guide, section: "12.9", page: 150 }, SpecRef { document: Document::Guide, section: "3.9", page: 19 }], + verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal], + }, + FormSemantics { + name: "V_CMP_F_U64", + family: EncodingFamily::Vopc, + opcode: 224, + operation: Operation::Compare, + signedness: Signedness::Unsigned, + carry_in: CarryIn::None, + width: 64, + shift_count_bits: 0, + shift_amount: 0, + swap_sources: false, + source_bits: 64, + relation: Some(CompareRelation::False), + scc: SccEffect::Unchanged, + vcc: MaskEffect::LaneMask, + exec: MaskEffect::Unchanged, + wave: Wave::Wave32, + operands: OperandRule::VopcVccPair, + spec: &[SpecRef { document: Document::Guide, section: "12.9", page: 150 }, SpecRef { document: Document::Guide, section: "3.9", page: 19 }], + verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal], + }, + FormSemantics { + name: "V_CMP_T_U64", + family: EncodingFamily::Vopc, + opcode: 231, + operation: Operation::Compare, + signedness: Signedness::Unsigned, + carry_in: CarryIn::None, + width: 64, + shift_count_bits: 0, + shift_amount: 0, + swap_sources: false, + source_bits: 64, + relation: Some(CompareRelation::True), + scc: SccEffect::Unchanged, + vcc: MaskEffect::LaneMask, + exec: MaskEffect::Unchanged, + wave: Wave::Wave32, + operands: OperandRule::VopcVccPair, + spec: &[SpecRef { document: Document::Guide, section: "12.9", page: 150 }, SpecRef { document: Document::Guide, section: "3.9", page: 19 }], + verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal], + }, FormSemantics { name: "V_ADD_NC_U32", family: EncodingFamily::Vop3, diff --git a/crates/isa/tests/semantics.rs b/crates/isa/tests/semantics.rs index 1bb721f..7d3057c 100644 --- a/crates/isa/tests/semantics.rs +++ b/crates/isa/tests/semantics.rs @@ -168,7 +168,8 @@ fn vector_alu_dispatch_selects_exactly_the_registry_vop2_forms() { #[test] fn vector_compare_dispatch_selects_exactly_the_registry_vopc_forms() { - const OPERANDS: [u32; 6] = [0, 1, 0x7fff_ffff, 0x8000_0000, 0xffff_fffe, 0xffff_ffff]; + const OPERANDS32: [u64; 6] = [0, 1, 0x7fff_ffff, 0x8000_0000, 0xffff_fffe, 0xffff_ffff]; + const OPERANDS64: [u64; 6] = [0, 1, u64::MAX >> 1, 1 << 63, u64::MAX - 1, u64::MAX]; for op in VectorCompareOp::ALL { let row = op.semantics(); assert_eq!(row.family, EncodingFamily::Vopc); @@ -187,9 +188,16 @@ fn vector_compare_dispatch_selects_exactly_the_registry_vopc_forms() { ); // The per-lane test is the declared relation over the declared // signedness, with SRC0 on the left. - for src0 in OPERANDS { - for src1 in OPERANDS { - let ordering = if op.signed() { + let operands = if row.width == 64 { + OPERANDS64 + } else { + OPERANDS32 + }; + for src0 in operands { + for src1 in operands { + let ordering = if op.signed() && row.width == 64 { + (src0 as i64).cmp(&(src1 as i64)) + } else if op.signed() { (src0 as i32).cmp(&(src1 as i32)) } else { src0.cmp(&src1) @@ -205,7 +213,7 @@ fn vector_compare_dispatch_selects_exactly_the_registry_vopc_forms() { CompareRelation::True => true, }; assert_eq!( - op.test(src0, src1), + op.test_bits(src0, src1), expected, "{} {src0:#x} {src1:#x}", row.name @@ -213,7 +221,7 @@ fn vector_compare_dispatch_selects_exactly_the_registry_vopc_forms() { } } } - // v_cmpx and the 16-, 64-bit and float compares must not be dispatched. + // v_cmpx and the 16-bit and float compares must not be dispatched. dispatch_selects_exactly(EncodingFamily::Vopc, |word| { VectorCompareOp::from_word(word).map(|op| op.semantics().name) }); diff --git a/crates/shader/src/lib.rs b/crates/shader/src/lib.rs index 9bd42a6..256b867 100644 --- a/crates/shader/src/lib.rs +++ b/crates/shader/src/lib.rs @@ -108,6 +108,7 @@ enum Op { op: VectorCompareOp, src0: Value, src1: Value, + high: Option<(Value, Value)>, exec: u32, }, /// `s_cbranch_vccz` on a lane-derived VCC_LO (IR annotation only). @@ -133,7 +134,15 @@ impl Op { active, inactive, .. } => vec![active, inactive], Self::Store(value) => vec![value], - Self::LaneMask { src0, src1, .. } => vec![src0, src1], + Self::LaneMask { + src0, src1, high, .. + } => { + let mut operands = vec![src0, src1]; + if let Some((left, right)) = high { + operands.extend([left, right]); + } + operands + } Self::RuntimeBranch { mask, .. } => vec![mask], Self::JoinVccz { mask, @@ -199,7 +208,9 @@ fn compare_expression(op: VectorCompareOp, left: &str, right: &str) -> String { CompareRelation::False => return "false".to_owned(), CompareRelation::True => return "true".to_owned(), }; - if op.signed() { + if op.signed() && op.semantics().width == 64 { + format!("as_type({left}) {symbol} as_type({right})") + } else if op.signed() { format!("as_type({left}) {symbol} as_type({right})") } else { format!("{left} {symbol} {right}") @@ -478,14 +489,20 @@ pub fn compile(architecture: Architecture, bytes: &[u8]) -> Result { + let (left, right) = if let Some((hi0, hi1)) = high { + (format!("{src0}:{hi0}"), format!("{src1}:{hi1}")) + } else { + (src0.to_string(), src1.to_string()) + }; let _ = writeln!( ir, - "{offset:04x}: {dest} = wave.mask {} {src0}, {src1} exec=0x{exec:08x}", + "{offset:04x}: {dest} = wave.mask {} {left}, {right} exec=0x{exec:08x}", op.assembly_name() ); - emit_lane_mask(&mut msl, &operations, &uniform, index, op, src0, src1, exec); + emit_lane_mask(&mut msl, &operations, &uniform, index, operation); continue; } Op::Store(value) => ( @@ -509,17 +526,23 @@ pub fn compile(architecture: Architecture, bytes: &[u8]) -> Result> lane) & pass) << lane;\n }}", - compare_expression(op, &name(src0), &name(src1)) + compare_expression(op, &left, &right) ); } @@ -959,6 +988,23 @@ fn lift(decoded: &[DecodedInstruction], code_len: usize) -> Result read(base + 1)?, + VectorSource::Scalar(base) => { + let bits = read_scalar(ScalarSource::Register(base + 1))?; + constant(&mut operations, &mut facts, bits) + } + VectorSource::Immediate(bits) => { + let high = ((bits as i32) >> 31) as u32; + constant(&mut operations, &mut facts, high) + } + }; + Some((left, read(src1 + 1)?)) + } else { + None + }; let src0 = match src0 { VectorSource::Register(register) => read(register)?, VectorSource::Scalar(register) if usize::from(register) == VCC_LO => { @@ -984,6 +1030,7 @@ fn lift(decoded: &[DecodedInstruction], code_len: usize) -> Result Xenora · recorded progress -Decoded gfx1030 forms: 120 of 120. Accepted Metal forms · Apple M5: 18 of 120. Accepted guest milestones · X1–X4: 4 of 4 +Decoded gfx1030 forms: 136 of 136. Accepted Metal forms · Apple M5: 18 of 136. Accepted guest milestones · X1–X4: 4 of 4 RECORDED FIXTURE PROGRESS Decoded gfx1030 forms -120 / 120 +136 / 136 Accepted Metal forms · Apple M5 -18 / 120 +18 / 136 - + Accepted guest milestones · X1–X4 4 / 4 diff --git a/docs/shaders/instruction-coverage.md b/docs/shaders/instruction-coverage.md index 75733c3..5f850ee 100644 --- a/docs/shaders/instruction-coverage.md +++ b/docs/shaders/instruction-coverage.md @@ -109,6 +109,22 @@ The wider LLVM operand matrix exercises decoding only. ABI means application bin | `v_cmp_t_i32_e32` | VOPC, Wave32; VGPR, normal SGPR (known during translation), vcc_lo, inline integer or literal SRC0 (signed); VGPR VSRC1; VCC_LO[n] = EXEC_LO[n] & true, fully written | `7D0E0501` | yes | yes | three-way passed | per-thread Wave32 mask over the dispatch's own 32 lanes, reading no operand bits; runtime s_cbranch_vccz as a join select | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending | | `v_cmp_f_u32_e32` | VOPC, Wave32; VGPR, normal SGPR (known during translation), vcc_lo, inline integer or literal SRC0 (unsigned); VGPR VSRC1; VCC_LO[n] = EXEC_LO[n] & false, fully written | `7D800501` | yes | yes | three-way passed | per-thread Wave32 mask over the dispatch's own 32 lanes, reading no operand bits; runtime s_cbranch_vccz as a join select | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending | | `v_cmp_t_u32_e32` | VOPC, Wave32; VGPR, normal SGPR (known during translation), vcc_lo, inline integer or literal SRC0 (unsigned); VGPR VSRC1; VCC_LO[n] = EXEC_LO[n] & true, fully written | `7D8E0501` | yes | yes | three-way passed | per-thread Wave32 mask over the dispatch's own 32 lanes, reading no operand bits; runtime s_cbranch_vccz as a join select | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending | +| `v_cmp_f_i64_e32` | VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; signed 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (false), fully written | `7D400902` | yes | yes | assembled fixture matched | per-thread Wave32 mask with 64-bit operands | implemented | local compiler and guide-derived reference tests passed | acceptance pending | +| `v_cmp_lt_i64_e32` | VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; signed 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (S0 < S1), fully written | `7D420902` | yes | yes | assembled fixture matched | per-thread Wave32 mask with 64-bit operands | implemented | local compiler and guide-derived reference tests passed | acceptance pending | +| `v_cmp_eq_i64_e32` | VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; signed 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (S0 == S1), fully written | `7D440902` | yes | yes | assembled fixture matched | per-thread Wave32 mask with 64-bit operands | implemented | local compiler and guide-derived reference tests passed | acceptance pending | +| `v_cmp_le_i64_e32` | VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; signed 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (S0 <= S1), fully written | `7D460902` | yes | yes | assembled fixture matched | per-thread Wave32 mask with 64-bit operands | implemented | local compiler and guide-derived reference tests passed | acceptance pending | +| `v_cmp_gt_i64_e32` | VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; signed 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (S0 > S1), fully written | `7D480902` | yes | yes | assembled fixture matched | per-thread Wave32 mask with 64-bit operands | implemented | local compiler and guide-derived reference tests passed | acceptance pending | +| `v_cmp_ne_i64_e32` | VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; signed 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (S0 != S1), fully written | `7D4A0902` | yes | yes | assembled fixture matched | per-thread Wave32 mask with 64-bit operands | implemented | local compiler and guide-derived reference tests passed | acceptance pending | +| `v_cmp_ge_i64_e32` | VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; signed 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (S0 >= S1), fully written | `7D4C0902` | yes | yes | assembled fixture matched | per-thread Wave32 mask with 64-bit operands | implemented | local compiler and guide-derived reference tests passed | acceptance pending | +| `v_cmp_t_i64_e32` | VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; signed 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (true), fully written | `7D4E0902` | yes | yes | assembled fixture matched | per-thread Wave32 mask with 64-bit operands | implemented | local compiler and guide-derived reference tests passed | acceptance pending | +| `v_cmp_f_u64_e32` | VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; unsigned 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (false), fully written | `7DC00902` | yes | yes | assembled fixture matched | per-thread Wave32 mask with 64-bit operands | implemented | local compiler and guide-derived reference tests passed | acceptance pending | +| `v_cmp_lt_u64_e32` | VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; unsigned 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (S0 < S1), fully written | `7DC20902` | yes | yes | assembled fixture matched | per-thread Wave32 mask with 64-bit operands | implemented | local compiler and guide-derived reference tests passed | acceptance pending | +| `v_cmp_eq_u64_e32` | VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; unsigned 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (S0 == S1), fully written | `7DC40902` | yes | yes | assembled fixture matched | per-thread Wave32 mask with 64-bit operands | implemented | local compiler and guide-derived reference tests passed | acceptance pending | +| `v_cmp_le_u64_e32` | VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; unsigned 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (S0 <= S1), fully written | `7DC60902` | yes | yes | assembled fixture matched | per-thread Wave32 mask with 64-bit operands | implemented | local compiler and guide-derived reference tests passed | acceptance pending | +| `v_cmp_gt_u64_e32` | VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; unsigned 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (S0 > S1), fully written | `7DC80902` | yes | yes | assembled fixture matched | per-thread Wave32 mask with 64-bit operands | implemented | local compiler and guide-derived reference tests passed | acceptance pending | +| `v_cmp_ne_u64_e32` | VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; unsigned 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (S0 != S1), fully written | `7DCA0902` | yes | yes | assembled fixture matched | per-thread Wave32 mask with 64-bit operands | implemented | local compiler and guide-derived reference tests passed | acceptance pending | +| `v_cmp_ge_u64_e32` | VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; unsigned 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (S0 >= S1), fully written | `7DCC0902` | yes | yes | assembled fixture matched | per-thread Wave32 mask with 64-bit operands | implemented | local compiler and guide-derived reference tests passed | acceptance pending | +| `v_cmp_t_u64_e32` | VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; unsigned 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (true), fully written | `7DCE0902` | yes | yes | assembled fixture matched | per-thread Wave32 mask with 64-bit operands | implemented | local compiler and guide-derived reference tests passed | acceptance pending | | `s_cbranch_scc0` | Nonnegative signed dword displacement | `BF840002` | yes | yes | three-way passed | resolved conditional branch | implemented | fixture verified | fixture verified | | `s_branch` | Nonnegative signed dword displacement | `BF820001` | yes | yes | three-way passed | resolved branch | implemented | fixture verified | fixture verified | | `v_and_b32_e32` | Two VGPR sources and one VGPR destination | `36020702` | yes | yes | three-way passed | MSL bitwise AND | implemented | fixture verified | fixture verified | diff --git a/docs/shaders/semantic-coverage.md b/docs/shaders/semantic-coverage.md index 10223f9..433a859 100644 --- a/docs/shaders/semantic-coverage.md +++ b/docs/shaders/semantic-coverage.md @@ -35,8 +35,8 @@ acceptance remain outside the verified count. All results concern synthetic fixt | VOP3 | 416 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 12 | | VOP3P | 29 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | | VOP3SDST | 10 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | -| VOPC | 190 | 16 | 16 | 16 | 16 | 16 | 0 | 0 | 7 | -| **Total** | 1465 | 120 | 108 | 124 | 120 | 120 | 18 | 18 | 65 | +| VOPC | 190 | 16 | 32 | 32 | 32 | 32 | 0 | 0 | 9 | +| **Total** | 1465 | 120 | 124 | 140 | 136 | 136 | 18 | 18 | 67 | ## Unsupported operand variants @@ -54,3 +54,4 @@ The table counts distinct variant names per family across registry operand rules | VOP2 | `vop2_vgpr2` | `src_exec`, `src_float_inline`, `src_inline`, `src_literal`, `src_m0`, `src_null`, `src_sgpr`, `src_special`, `src_ttmp`, `src_vcc` | | VOP3 | `vop3_vgpr2` | `modifiers`, `src2`, `src_exec`, `src_float_inline`, `src_inline`, `src_literal`, `src_m0`, `src_null`, `src_sgpr`, `src_special`, `src_ttmp`, `src_vcc` | | VOPC | `vopc_vcc` | `src_exec`, `src_float_inline`, `src_m0`, `src_null`, `src_special`, `src_ttmp`, `src_vcc_hi` | +| VOPC | `vopc_vcc_pair` | `src_exec`, `src_float_inline`, `src_literal`, `src_m0`, `src_null`, `src_special`, `src_ttmp`, `src_vcc` | diff --git a/docs/shaders/semantic-registry.md b/docs/shaders/semantic-registry.md index 238c76a..9a75522 100644 --- a/docs/shaders/semantic-registry.md +++ b/docs/shaders/semantic-registry.md @@ -112,7 +112,7 @@ error. | `operation` | The primitive the form uses | `add`, `sub`, `and`, `or`, `xor`, `andn2`, `orn2`, `nand`, `nor`, `xnor`, `lshl`, `lshr`, `ashr`, `min`, `max`, `cselect`, `bfm`, `mul`, `mul_hi`, `bfe`, `absdiff`, `lshl_add`, `mul24`, `mul_hi24` (vector only), `mov` (SOP1 and SOPK), `cmov` (SOPK only), `compare` and the SOP1 unaries | | `signedness` | How operands are read | `unsigned`, `signed`, `bitwise` (always `bitwise` for the logical operations, `cselect` and `bfm`; never for the arithmetic ones, `add`, `sub`, `min`, `max`, `mul`, `mul_hi`, `bfe`, `absdiff` and `lshl_add`; shifts take their primitive's signedness) | | `carry_in` | Whether the form reads SCC: carry-in, borrow-in or the select condition | `none`, `scc` (`scc` only for unsigned `add` and `sub`, and required for `cselect`) | -| `width` | Operand and result width in bits | `32` | +| `width` | Operand and result width in bits (operand width for compares) | `32`, or `64` with `vopc_vcc_pair` | | `source_bits` | Sign extension only: the low bits of S0 that are read. The XML must list S0 with that size and format (`FMT_NUM_I8` or `FMT_NUM_I16`) | `8`, `16`; required for `sext`, rejected elsewhere | | `relation` | Compares only: the relation tested with S0 on the left | `eq`, `lg` (not equal), `gt`, `ge`, `lt`, `le`; required for `compare`, rejected elsewhere | | `source_order` | Vector forms only: `reversed` when the guide computes `op(S1, S0)` (the XML records no operand order); absent otherwise | `reversed` | @@ -184,9 +184,10 @@ to `vop2_vgpr` would be a behaviour change and needs its own oracle. The three shifts declare `source_order = "reversed"` (D = S1 shifted by S0[4:0]), so the generator checks the XML's unsigned count format on SRC0, not VSRC1. -VOPC compares (operand rule `vopc_vcc`, kind `vector_compare`: SRC0 a -`vector_source` as for VOP2, VSRC1 a VGPR, destination implicitly `vcc_lo`) -take the same `relation` and primitive as SOPC compares, but declare +VOPC compares (kind `vector_compare`) write `vcc_lo`. The 32-bit rule +`vopc_vcc` accepts a `vector_source` as for VOP2 and a VGPR. The 64-bit rule +`vopc_vcc_pair` accepts a VGPR pair, an even normal SGPR pair or an inline +integer as SRC0 and a VGPR pair as VSRC1. Both declare a `relation`, `scc = "unchanged"`, `vcc = "lane_mask"` and `wave = "wave32"`. The XML's implicit 64-bit VCC output must be present and is accounted for by `lane_mask`. Signedness still matters for `eq` and `lg`, because the MSL lowering casts signed operands. @@ -219,8 +220,8 @@ vocabularies above, it rejects: - contradictions: a declared `scc` or `carry_in` that the primitive does not have, `bitwise` on an arithmetic operation or the reverse; -- VOPC compares whose opcode is not the group base (128 for `signed`, 192 - for `unsigned`) plus the relation's offset in guide Table 59 (F 0, LT 1, +- VOPC compares whose opcode is not the group base (128 and 192 for signed and + unsigned 32-bit forms, 160 and 224 for their 64-bit counterparts) plus the relation's offset in guide Table 59 (F 0, LT 1, EQ 2, LE 3, GT 4, LG/NE 5, GE 6, T 7), and a `lane_mask` form whose XML does not have exactly one implicit VCC operand that is written and not read; - duplicates: the same `name`, the same `(family, opcode)`, or the same diff --git a/docs/shaders/vector-compare.md b/docs/shaders/vector-compare.md index 486d221..a91aa57 100644 --- a/docs/shaders/vector-compare.md +++ b/docs/shaders/vector-compare.md @@ -75,14 +75,14 @@ stream carries no wave-size declaration (the VOPC word has no wave-size field), so every caller of the translator and the reference establishes Wave32 by using this ABI; there is no Wave64 entry point to reject. -### 2a. 16-bit and 64-bit compares (reference interpreters only) +### 2a. 16-bit and 64-bit compares The reference (`crates/ref`) and the second interpreter (`tests/validation/independent_ref.rs`) also accept the `_e32` forms `v_cmp_{lt,eq,le,gt,ne,ge}_{i16,u16}` (opcodes 137-142, 169-174) and `v_cmp_{f,lt,eq,le,gt,ne,ge,t}_{i64,u64}` (160-167, 224-231). The decoder and -the translator still reject them (section 4); these forms have an oracle -but no translation yet. +translator support the 64-bit forms through the `vopc_vcc_pair` operand rule. +The 16-bit forms are available only in the interpreters. - 16-bit forms read bits 15:0 of each 32-bit source and ignore bits 31:16 (an inference from guide 6.2, 6.2.5 and 6.8: only SDWA selects a half). @@ -124,8 +124,8 @@ this wave (all 32 except in a final partial wave, see 7). As an unsigned - V_CMPX_* (writes EXEC: divergent execution; needs its own contract). - The VOP3 encoding of any compare (arbitrary SGPR destination, modifiers). - SDWA and DPP forms; float compares; v_cmp_class. -- 16-bit and 64-bit compares in the decoder and translator (the reference - interpreters accept the subset in 2a). +- 16-bit compares in the decoder and translator (the reference interpreters + accept the subset in 2a). - SRC0 inline float constants (240-248), SGPRs other than s0-s106, TTMPs, M0, EXEC_LO/HI, VCC_HI, SCC/VCCZ/EXECZ selectors, LDS direct. - A normal-SGPR SRC0 without a known value, when EXEC_LO != 0. @@ -148,14 +148,15 @@ Acceptance rules for one compare: or VCC state), and VCC_LO becomes known 0. - EXEC_LO != 0: VSRC1 and a VGPR SRC0 must be initialized and not pending a load; a normal-SGPR SRC0 must be known; a `vcc_lo` SRC0 must be known or - lane-derived (uninitialized is rejected). VCC_LO becomes lane-derived. + lane-derived (uninitialized is rejected). The 64-bit forms check both words + of each register pair. VCC_LO becomes lane-derived. While VCC_LO is lane-derived it may be read only by: 1. `s_cbranch_vccz` (6); 2. `v_mov_b32_e32 vD, vcc_lo`, which writes the 32-bit mask into vD of active lanes (inactive lanes keep vD, as for any partial-EXEC move); -3. SRC0 of a supported compare (`v_cmp_* vcc_lo, vcc_lo, vN`), which reads the +3. SRC0 of a supported 32-bit compare (`v_cmp_* vcc_lo, vcc_lo, vN`), which reads the old VCC_LO in every active lane before the new value is written. 4. SRC0 of a registry VOP2 integer form (for example `v_add_nc_u32_e32 vD, vcc_lo, vN`), which reads the 32-bit mask in every @@ -252,10 +253,14 @@ programs, plus 2 mask-chain programs (252 in all), and the F/T fixture (253) mat run in `vopc_f_t_match_the_guide_on_native_metal`. The 16-bit and 64-bit oracle (`tests/validation/tests/vopc_wide.rs`) checks -6,212 lane cases on both reference interpreters, plus 1,208 rejections and the -13 neighbouring opcodes, and that the production compiler still rejects all 28 -forms. Its native Metal test stays ignored (and skipped by `scripts/test-gpu.sh`) -until the translator implements these forms. Deliberately broken copies of both +6,212 cases on both reference interpreters, plus 1,208 rejections and 13 +neighbouring opcodes. CPU tests check compilation of the 4,640 64-bit cases +and rejection of out-of-contract 64-bit operands and all 12 16-bit forms. +The LLVM-assembled `fixtures/rdna2/vector-compare-64.s` covers all sixteen +64-bit opcodes in the decoder's fixture inventory. +`scripts/test-gpu.sh` includes `vopc64_match_the_guide_on_native_metal` and +skips `vopc16_match_the_guide_on_native_metal`. Native Metal readback for the +64-bit forms is pending. Deliberately broken copies of both interpreters (16-bit reads of 32 bits, swapped pair halves, zero-extended inline integers, flipped signedness, reads under empty EXEC and others) each fail it. @@ -268,14 +273,14 @@ the translator with a stale VCC under empty EXEC (CPU), and, on Metal, with swapped signedness, without the EXEC mask, without the absent-lane bound (shader validation aborts on the out-of-range read) or with an inverted join. -Evidence class: agreement with a specification-derived reference, run -locally on Apple M5 Pro. It is not agreement with RDNA 2 or Xbox hardware. +The 32-bit readback evidence is local agreement with a specification-derived +reference on Apple M5 Pro. The 64-bit compiler evidence is CPU-only. +There is no RDNA 2 or Xbox hardware evidence. ## 10. Limitations -- Wave32 only. No `v_cmpx`, VOP3, SDWA, DPP or float compares. 16-bit and - 64-bit compares exist only in the reference interpreters (2a); native Metal - agreement for them is not shown. +- Wave32 only. No `v_cmpx`, VOP3, SDWA, DPP or float compares. The 16-bit + compares are available only in the reference interpreters (2a). - A lane-derived VCC_LO cannot reach EXEC or any scalar instruction, so there is no divergent execution. That needs its own contract. - The skipped region of a runtime `s_cbranch_vccz` holds only integer vector diff --git a/docs/status.toml b/docs/status.toml index 5f92851..c71e427 100644 --- a/docs/status.toml +++ b/docs/status.toml @@ -1190,6 +1190,198 @@ recognized = true decoded = true llvm = "three-way passed" +[[instruction]] +form = "v_cmp_f_i64_e32" +encoding = "VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; signed 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (false), fully written" +representation = "`7D400902`" +lowering = "per-thread Wave32 mask with 64-bit operands" +reference = "implemented" +cpu = "local compiler and guide-derived reference tests passed" +gpu = "acceptance pending" +recognized = true +decoded = true +llvm = "assembled fixture matched" + +[[instruction]] +form = "v_cmp_lt_i64_e32" +encoding = "VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; signed 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (S0 < S1), fully written" +representation = "`7D420902`" +lowering = "per-thread Wave32 mask with 64-bit operands" +reference = "implemented" +cpu = "local compiler and guide-derived reference tests passed" +gpu = "acceptance pending" +recognized = true +decoded = true +llvm = "assembled fixture matched" + +[[instruction]] +form = "v_cmp_eq_i64_e32" +encoding = "VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; signed 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (S0 == S1), fully written" +representation = "`7D440902`" +lowering = "per-thread Wave32 mask with 64-bit operands" +reference = "implemented" +cpu = "local compiler and guide-derived reference tests passed" +gpu = "acceptance pending" +recognized = true +decoded = true +llvm = "assembled fixture matched" + +[[instruction]] +form = "v_cmp_le_i64_e32" +encoding = "VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; signed 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (S0 <= S1), fully written" +representation = "`7D460902`" +lowering = "per-thread Wave32 mask with 64-bit operands" +reference = "implemented" +cpu = "local compiler and guide-derived reference tests passed" +gpu = "acceptance pending" +recognized = true +decoded = true +llvm = "assembled fixture matched" + +[[instruction]] +form = "v_cmp_gt_i64_e32" +encoding = "VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; signed 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (S0 > S1), fully written" +representation = "`7D480902`" +lowering = "per-thread Wave32 mask with 64-bit operands" +reference = "implemented" +cpu = "local compiler and guide-derived reference tests passed" +gpu = "acceptance pending" +recognized = true +decoded = true +llvm = "assembled fixture matched" + +[[instruction]] +form = "v_cmp_ne_i64_e32" +encoding = "VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; signed 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (S0 != S1), fully written" +representation = "`7D4A0902`" +lowering = "per-thread Wave32 mask with 64-bit operands" +reference = "implemented" +cpu = "local compiler and guide-derived reference tests passed" +gpu = "acceptance pending" +recognized = true +decoded = true +llvm = "assembled fixture matched" + +[[instruction]] +form = "v_cmp_ge_i64_e32" +encoding = "VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; signed 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (S0 >= S1), fully written" +representation = "`7D4C0902`" +lowering = "per-thread Wave32 mask with 64-bit operands" +reference = "implemented" +cpu = "local compiler and guide-derived reference tests passed" +gpu = "acceptance pending" +recognized = true +decoded = true +llvm = "assembled fixture matched" + +[[instruction]] +form = "v_cmp_t_i64_e32" +encoding = "VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; signed 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (true), fully written" +representation = "`7D4E0902`" +lowering = "per-thread Wave32 mask with 64-bit operands" +reference = "implemented" +cpu = "local compiler and guide-derived reference tests passed" +gpu = "acceptance pending" +recognized = true +decoded = true +llvm = "assembled fixture matched" + +[[instruction]] +form = "v_cmp_f_u64_e32" +encoding = "VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; unsigned 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (false), fully written" +representation = "`7DC00902`" +lowering = "per-thread Wave32 mask with 64-bit operands" +reference = "implemented" +cpu = "local compiler and guide-derived reference tests passed" +gpu = "acceptance pending" +recognized = true +decoded = true +llvm = "assembled fixture matched" + +[[instruction]] +form = "v_cmp_lt_u64_e32" +encoding = "VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; unsigned 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (S0 < S1), fully written" +representation = "`7DC20902`" +lowering = "per-thread Wave32 mask with 64-bit operands" +reference = "implemented" +cpu = "local compiler and guide-derived reference tests passed" +gpu = "acceptance pending" +recognized = true +decoded = true +llvm = "assembled fixture matched" + +[[instruction]] +form = "v_cmp_eq_u64_e32" +encoding = "VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; unsigned 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (S0 == S1), fully written" +representation = "`7DC40902`" +lowering = "per-thread Wave32 mask with 64-bit operands" +reference = "implemented" +cpu = "local compiler and guide-derived reference tests passed" +gpu = "acceptance pending" +recognized = true +decoded = true +llvm = "assembled fixture matched" + +[[instruction]] +form = "v_cmp_le_u64_e32" +encoding = "VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; unsigned 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (S0 <= S1), fully written" +representation = "`7DC60902`" +lowering = "per-thread Wave32 mask with 64-bit operands" +reference = "implemented" +cpu = "local compiler and guide-derived reference tests passed" +gpu = "acceptance pending" +recognized = true +decoded = true +llvm = "assembled fixture matched" + +[[instruction]] +form = "v_cmp_gt_u64_e32" +encoding = "VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; unsigned 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (S0 > S1), fully written" +representation = "`7DC80902`" +lowering = "per-thread Wave32 mask with 64-bit operands" +reference = "implemented" +cpu = "local compiler and guide-derived reference tests passed" +gpu = "acceptance pending" +recognized = true +decoded = true +llvm = "assembled fixture matched" + +[[instruction]] +form = "v_cmp_ne_u64_e32" +encoding = "VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; unsigned 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (S0 != S1), fully written" +representation = "`7DCA0902`" +lowering = "per-thread Wave32 mask with 64-bit operands" +reference = "implemented" +cpu = "local compiler and guide-derived reference tests passed" +gpu = "acceptance pending" +recognized = true +decoded = true +llvm = "assembled fixture matched" + +[[instruction]] +form = "v_cmp_ge_u64_e32" +encoding = "VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; unsigned 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (S0 >= S1), fully written" +representation = "`7DCC0902`" +lowering = "per-thread Wave32 mask with 64-bit operands" +reference = "implemented" +cpu = "local compiler and guide-derived reference tests passed" +gpu = "acceptance pending" +recognized = true +decoded = true +llvm = "assembled fixture matched" + +[[instruction]] +form = "v_cmp_t_u64_e32" +encoding = "VOPC, Wave32; VGPR pair, known even SGPR pair or sign-extended inline integer SRC0; VGPR pair VSRC1; unsigned 64-bit operands; VCC_LO[n] = EXEC_LO[n] & (true), fully written" +representation = "`7DCE0902`" +lowering = "per-thread Wave32 mask with 64-bit operands" +reference = "implemented" +cpu = "local compiler and guide-derived reference tests passed" +gpu = "acceptance pending" +recognized = true +decoded = true +llvm = "assembled fixture matched" + [[instruction]] form = "s_cbranch_scc0" encoding = "Nonnegative signed dword displacement" diff --git a/fixtures/rdna2/vector-compare-64.bin b/fixtures/rdna2/vector-compare-64.bin new file mode 100644 index 0000000..9702a74 Binary files /dev/null and b/fixtures/rdna2/vector-compare-64.bin differ diff --git a/fixtures/rdna2/vector-compare-64.s b/fixtures/rdna2/vector-compare-64.s new file mode 100644 index 0000000..ef60555 --- /dev/null +++ b/fixtures/rdna2/vector-compare-64.s @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Encoding inventory for Wave32 64-bit VOPC compares (guide Table 61). +// Operand and execution cases are in tests/validation/tests/vopc_wide.rs. +.text +buffer_load_dword v2, v0, s[0:3], 0 idxen +s_waitcnt vmcnt(0) +v_mov_b32_e32 v3, 0 +v_mov_b32_e32 v4, 7 +v_mov_b32_e32 v5, 0 +v_cmp_f_i64_e32 vcc_lo, v[2:3], v[4:5] +v_cmp_lt_i64_e32 vcc_lo, v[2:3], v[4:5] +v_cmp_eq_i64_e32 vcc_lo, v[2:3], v[4:5] +v_cmp_le_i64_e32 vcc_lo, v[2:3], v[4:5] +v_cmp_gt_i64_e32 vcc_lo, v[2:3], v[4:5] +v_cmp_ne_i64_e32 vcc_lo, v[2:3], v[4:5] +v_cmp_ge_i64_e32 vcc_lo, v[2:3], v[4:5] +v_cmp_t_i64_e32 vcc_lo, v[2:3], v[4:5] +v_cmp_f_u64_e32 vcc_lo, v[2:3], v[4:5] +v_cmp_lt_u64_e32 vcc_lo, v[2:3], v[4:5] +v_cmp_eq_u64_e32 vcc_lo, v[2:3], v[4:5] +v_cmp_le_u64_e32 vcc_lo, v[2:3], v[4:5] +v_cmp_gt_u64_e32 vcc_lo, v[2:3], v[4:5] +v_cmp_ne_u64_e32 vcc_lo, v[2:3], v[4:5] +v_cmp_ge_u64_e32 vcc_lo, v[2:3], v[4:5] +v_cmp_t_u64_e32 vcc_lo, v[2:3], v[4:5] +v_mov_b32_e32 v2, vcc_lo +buffer_store_dword v2, v0, s[4:7], 0 idxen +s_waitcnt_vscnt null, 0 +s_endpgm diff --git a/scripts/assemble-fixture.sh b/scripts/assemble-fixture.sh index 416a52a..18afc9f 100755 --- a/scripts/assemble-fixture.sh +++ b/scripts/assemble-fixture.sh @@ -12,7 +12,7 @@ case "${1:-}" in esac for name in add bitwise-branch float-exact or shifts ashr \ - x9-constant-vs x9-constant-ps x9-varying-vs x9-varying-ps x9-transform-vs scalar-alu vector-compare scalar-logic scalar-compare scalar-unary scalar-arith scalar-immediate vector-integer vector-compare-ft; do + x9-constant-vs x9-constant-ps x9-varying-vs x9-varying-ps x9-transform-vs scalar-alu vector-compare scalar-logic scalar-compare scalar-unary scalar-arith scalar-immediate vector-integer vector-compare-ft vector-compare-64; do "$llvm_bin/llvm-mc" -triple=amdgcn-amd-amdhsa -mcpu=gfx1030 -mattr=+wavefrontsize32 \ -filetype=obj "fixtures/rdna2/$name.s" -o "$scratch/$name.o" "$llvm_bin/llvm-objcopy" -O binary --only-section=.text "$scratch/$name.o" "$scratch/$name.bin" diff --git a/scripts/test-gpu.sh b/scripts/test-gpu.sh index 381aac1..f212698 100755 --- a/scripts/test-gpu.sh +++ b/scripts/test-gpu.sh @@ -56,5 +56,5 @@ cargo test --locked -p xenora-semantic-review --no-run # Oracles whose translator side has not landed are skipped by name until it does # (#215: the PR that translates the forms removes its skip). timeout 120s cargo test --locked -p xenora-semantic-review -- --ignored --nocapture --test-threads=1 \ - --skip vopc_wide_match_the_guide_on_native_metal \ + --skip vopc16_match_the_guide_on_native_metal \ --skip vop1_integer_forms_match_the_guide_on_native_metal diff --git a/tests/validation/tests/vopc_wide.rs b/tests/validation/tests/vopc_wide.rs index 0df572b..61ab83b 100644 --- a/tests/validation/tests/vopc_wide.rs +++ b/tests/validation/tests/vopc_wide.rs @@ -11,9 +11,9 @@ //! 6.2 (Table 20 and 6.2.1), 6.2.5, 6.8 and 9.1. Nothing here comes from the //! ISA crate, the semantic registry, the decoder or the shader compiler. Every //! case runs on the reference interpreter `xenora_ref` and on the second -//! interpreter `independent_ref`. The ignored native Metal test needs the -//! translator's 16- and 64-bit forms; until then a CPU test checks that the -//! production compiler rejects all 28. +//! interpreter `independent_ref`. The native Metal gate includes the 64-bit +//! cases. The 16-bit Metal cases remain skipped while the compiler rejects +//! those forms. //! //! Readings of the guide (not hardware evidence): //! - Table 59: offsets F 0, LT 1, EQ 2, LE 3, GT 4, LG/NE 5, GE 6, TRU 7 with @@ -1169,24 +1169,58 @@ fn vopc_wide_outside_the_contract_are_rejected() { } #[test] -fn production_compiler_still_rejects_the_wide_compares() { - // docs/shaders/vector-compare.md 2a: the oracle runs ahead of the - // translator, which rejects all 28 forms at the compare until it - // implements them. This test fails once it does; then the Metal test - // below takes over. - for form in forms() { - let (setup, other) = if form.bits == 64 { - (lane_pair(7), 4) - } else { - (vmov(3, 7).to_vec(), 3) - }; - let (code, offset) = program(&setup, None, &[vopc(form.op, vgpr(1), other)], &[]); - let at = match compile(Architecture::Gfx1030, &code) { - Err(CompileError::Decode(error)) => error.offset, - Err(CompileError::Verify { offset, .. }) => offset, - other => panic!("compiler accepted {}: {other:?}", form.name), - }; - assert_eq!(at, offset, "compiler rejected {} elsewhere", form.name); +fn production_compiler_still_rejects_the_16_bit_compares() { + for form in forms().into_iter().filter(|form| form.bits == 16) { + let (code, offset) = program(&vmov(3, 7), None, &[vopc(form.op, vgpr(1), 3)], &[]); + assert_compiler_rejected_at(form.name, &code, offset); + } +} + +fn assert_compiler_rejected_at(label: &str, code: &[u8], offset: usize) { + let at = match compile(Architecture::Gfx1030, code) { + Err(CompileError::Decode(error)) => error.offset, + Err(CompileError::Verify { offset, .. }) => offset, + other => panic!("compiler did not reject {label}: {other:?}"), + }; + assert_eq!(at, offset, "compiler rejected {label} elsewhere"); +} + +fn cases_at_width(bits: u32) -> Vec { + let suffix = bits.to_string(); + checked_cases() + .into_iter() + .filter(|case| case.form.ends_with(&suffix)) + .collect() +} + +fn check_compiler_rejections(bits: u32) { + let suffix = bits.to_string(); + for (label, code, offset) in rejections() { + if label.split_once(' ').unwrap().0.ends_with(&suffix) { + assert_compiler_rejected_at(&label, &code, offset); + } + } +} + +#[test] +fn production_compiler_lowers_the_64_bit_compares() { + let cases = cases_at_width(64); + harness::check_reference(&cases).assert_none("64-bit compare compilation and reference"); + check_compiler_rejections(64); + eprintln!("vopc64: {} compiler acceptance cases", cases.len()); +} + +#[test] +fn production_compiler_emits_signed_and_unsigned_64_bit_relations() { + for (name, signed) in [("v_cmp_lt_i64", true), ("v_cmp_lt_u64", false)] { + let code = code(&lane_pair(7), None, &[vopc(form(name).op, 193, 4)]); + let shader = compile(Architecture::Gfx1030, &code).unwrap(); + assert_eq!( + shader.msl.matches("as_type(").count(), + if signed { 2 } else { 0 } + ); + assert_eq!(shader.msl.matches("<< 32u").count(), 2); + assert!(shader.disassembly.contains("vcc_lo, -1, v[4:5]")); } } @@ -1204,6 +1238,7 @@ fn pair_halves_are_checked_without_active_lanes() { let (code, offset) = program(&lane_pair(7), Some(0xffff_ff80), &compare, &[]); let label = format!("{} v2 uninitialized in {slot}, no active lane", form.name); assert_rejected_at(&label, &code, offset, input); + assert_compiler_rejected_at(&label, &code, offset); n += 1; } } @@ -1227,23 +1262,26 @@ fn neighbouring_compares_stay_unsupported() { } #[test] -#[ignore = "requires a native Metal device with API and shader validation, and the translator's 16- and 64-bit forms (skipped by scripts/test-gpu.sh until then)"] -fn vopc_wide_match_the_guide_on_native_metal() { +#[ignore = "requires a native Metal device with API and shader validation"] +fn vopc64_match_the_guide_on_native_metal() { + check_native_metal(64); +} + +#[test] +#[ignore = "requires the translator's 16-bit forms and native Metal validation"] +fn vopc16_match_the_guide_on_native_metal() { + check_compiler_rejections(16); + check_native_metal(16); +} + +fn check_native_metal(bits: u32) { assert_eq!(std::env::var("MTL_DEBUG_LAYER").as_deref(), Ok("1")); assert_eq!(std::env::var("MTL_SHADER_VALIDATION").as_deref(), Ok("1")); - for (label, code, offset) in rejections() { - let at = match compile(Architecture::Gfx1030, &code) { - Err(CompileError::Decode(error)) => error.offset, - Err(CompileError::Verify { offset, .. }) => offset, - other => panic!("compiler did not reject {label}: {other:?}"), - }; - assert_eq!(at, offset, "compiler rejected {label} elsewhere"); - } - let cases = checked_cases(); + let cases = cases_at_width(bits); let (failures, programs) = harness::check_metal(&cases); failures.assert_none("native Metal disagrees with the guide"); eprintln!( - "vopc_wide: {} Metal cases in {programs} programs", + "vopc{bits}: {} Metal cases in {programs} programs", cases.len() ); }