mirror of
https://github.com/MacosPorters/betterxen.git
synced 2026-11-27 19:40:28 +00:00
Compare commits
30
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8049c36f51 | ||
|
|
c91036f879 | ||
|
|
0fdb995892 | ||
|
|
d7f7d586d3 | ||
|
|
d01627b3de | ||
|
|
1d363c3c34 | ||
|
|
e74ebbe30b | ||
|
|
26eba92b87 | ||
|
|
05143d6295 | ||
|
|
d6a65b2940 | ||
|
|
1cc7f01fec | ||
|
|
6a4fc7cce1 | ||
|
|
b5b24347e9 | ||
|
|
f8eb976102 | ||
|
|
bbb59324c0 | ||
|
|
34b16ca65c | ||
|
|
fd0e427c7b | ||
|
|
314d1f5874 | ||
|
|
7adb978683 | ||
|
|
9d5de05055 | ||
|
|
3348d34e6f | ||
|
|
8e9ec8b9d1 | ||
|
|
b54f5ef0aa | ||
|
|
4d5207afd8 | ||
|
|
27daa701c1 | ||
|
|
c985c3fa17 | ||
|
|
6ad1602a3d | ||
|
|
3521dca45b | ||
|
|
131c8669cf | ||
|
|
2c8c63cf65 |
No files matched your search
@@ -41,6 +41,8 @@ jobs:
|
||||
python3 crates/isa/generate_semantics.py --check
|
||||
python3 scripts/audit/semantic_coverage.py --check
|
||||
python3 scripts/audit/status.py --check
|
||||
# The generated status check must not depend on the host locale encoding.
|
||||
LC_ALL=C PYTHONCOERCECLOCALE=0 PYTHONUTF8=0 python3 scripts/audit/status.py --check
|
||||
for fixture in x2 x3 x4; do
|
||||
python3 "experiments/x1/fixtures/$fixture.py" --check || exit 1
|
||||
done
|
||||
@@ -65,7 +67,7 @@ jobs:
|
||||
cargo test --locked --workspace
|
||||
cargo test --locked --manifest-path experiments/x1/Cargo.toml
|
||||
scripts/audit/dependencies.sh
|
||||
scripts/audit/claims.sh
|
||||
LC_ALL=C PYTHONCOERCECLOCALE=0 PYTHONUTF8=0 scripts/audit/claims.sh
|
||||
- name: Inspect native CLI
|
||||
run: |
|
||||
cargo build --locked -p xenora
|
||||
|
||||
+9
-1
@@ -10,18 +10,25 @@ Guest execution uses original, purpose-built test programs. Commercial Xbox game
|
||||
remains unsupported.
|
||||
|
||||
### Changed
|
||||
- Moved the six supported gfx1030 SOPP compute control forms into the semantic registry, preserving instruction decoding and shader lowering. Part of #215.
|
||||
- Moved gfx1030 `s_mov_b32` (SOP1) into the semantic registry, preserving its existing decode domain and shader output. The move operand rule retains explicit VCC and EXEC half destinations. Part of #215.
|
||||
- Moved the six hand-written gfx1030 VOP2 logical and shift forms (`v_and_b32`, `v_or_b32`, `v_xor_b32`, `v_lshlrev_b32`, `v_lshrrev_b32`, `v_ashrrev_i32`, AMD guide section 12.7) into the semantic registry under a new VGPR-only operand rule `vop2_vgpr2`, with no behaviour change: a sweep of 132,608 VOP2, VOP1 and SOP1 words decodes to the same text, length and error before and after, the MSL goldens are unchanged, and the runtime-region allowlist admits exactly the same six forms. The per-lane `VectorBinary` gained `And`, `Or`, `Xor` and the three shifts (count masked to S0[4:0]); 6 hand-written instruction variants and their decoder and lowering arms are gone (17 hand-written forms remain). Part of #215.
|
||||
- Added non-blocking Metal compute submission through `submit_words` and `wait`, with completion-aware resource retirement and a sixteen-dispatch in-flight limit. Synchronous calls keep their existing behavior. The benchmark reports the host submission split and compares synchronous and pipelined batches.
|
||||
- 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 the VOP3A (`_e64`) encodings of eleven gfx1030 VOP2 integer forms (`v_mul_{i32_i24,hi_i32_i24,u32_u24,hi_u32_u24}`, `v_{min,max}_{i32,u32}`, `v_xnor_b32`, `v_sub_nc_u32`, `v_subrev_nc_u32`) and of the sixteen Wave32 integer compares (explicit SGPR mask destination, `s_cbranch_vccz` through `vcc_lo`, a translation error for reads of runtime-only SGPR results) as semantic-registry encoding variants, with VGPR sources only. New fixtures `vop3-integer` and `vop3-compare` with IR and MSL goldens, and an independent guide-derived oracle (`tests/validation/tests/vop3_{integer,compare}.rs`) that agrees on both reference interpreters and on native Metal. Part of #215.
|
||||
- Added guest texture binding through D3D12-style descriptor tables (#303): shader-visible CBV_SRV_UAV and sampler heaps, `CreateShaderResourceView` for one-level RGBA8 and BC1 2D textures, a point/clamp `CreateSampler`, a root signature with one pixel-stage SRV table and one sampler table, and `SetDescriptorHeaps`/`SetGraphicsRootDescriptorTable` in `crates/loader/src/graphics.rs`, plus `NativeCompute::render_rgba8_sampled_bc1`. Verified locally on an Apple M5 Pro under Metal validation: a guest draw with the translated `image_sample_lz` pixel stage matches the software reference and hand-derived images on 16 of 16 pixels for two RGBA8 textures and 64 of 64 for an 8×8 BC1 texture. A wrong descriptor slot changes the image, off-centre and out-of-range coordinates point-sample with clamping, and a rejected binding, draw shape or resource state never reaches the backend. The software reference samples BC1 with the spec-exact decoder, while Apple's hardware rounds BC1's interpolated palette entries differently (171/84 against 170/85), so the BC1 fixtures use only endpoint colours. Not yet reachable from guest imports. Not yet independently accepted.
|
||||
- Added four Wave32 gfx1030 VOP2 select and carry forms through the semantic registry. Conditional select, add with carry and both subtract orders with borrow use a per-lane VCC bit and have a guide-derived oracle that passes on both CPU interpreters and on native Metal (local Apple M5, API and shader validation); independent acceptance is pending. Part of #215.
|
||||
- Added decoding and Metal shader translation for twelve Wave32 VOPC 16-bit integer compares (#215). The signed and unsigned forms compare the low 16 bits of each source and write the Wave32 VCC mask. CPU verification covers 1,572 compiler acceptance cases and 408 rejections from the guide-derived oracle, which also passes on native Metal (1,572 cases in 1,420 programs on a local Apple M5 under API and shader validation); acceptance is pending.
|
||||
- Added MOVS and STOS for 8- to 64-bit elements, with and without REP, and the direction flag with CLD and STD (#129). A REP form runs one element per step and stays on the instruction until RCX is zero, so every element counts against the step budget, a repeat can stop part-way and resume, a zero count touches nothing, and a fault keeps the elements already done with RSI, RDI and RCX at the one that faulted. An FS or GS override applies to the MOVS source only. Both engines run these on the shared semantics with no bulk-copy path, so large copies are slow. LODS, CMPS, SCAS, REPE, REPNE and the address-size override stay rejected. Fourteen SDM-derived cases already in `cpu_known_answers.rs` moved from refused to verified, and `tests/cpu_rep.rs` adds a byte-array model over every form, direction and count; not compared with x86 hardware and awaiting independent review.
|
||||
- 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. The guide-derived oracle passes on native Metal (4,640 cases in 3,818 programs on a local Apple M5 under API and shader validation); acceptance is pending.
|
||||
- Added XADD and CMPXCHG for 8- to 64-bit register and memory destinations, and the LOCK prefix on their memory forms (#198). LOCK anywhere else, CMPXCHG8B and CMPXCHG16B stay rejected. Both engines run the new forms on the shared semantics, one instruction at a time, so a locked instruction is indivisible today and LOCK changes no result; `docs/cpu/instruction-registry.md` states the ordering, alignment, compare-failure and fault rules a guest scheduler must preserve. A failed compare still writes the destination, so it faults on memory that cannot be written. Nothing is lowered to ARM64 atomic instructions, and no multi-thread behaviour is established. Fourteen SDM-derived cases already in `cpu_known_answers.rs` moved from refused to verified, with 62 LLVM-assembled fixtures and five new tests in `x86_atomic.rs`; not compared with x86 hardware and awaiting independent review.
|
||||
- Added CPUID with a fixed, host-independent guest contract (#130). It reports a synthetic processor with the vendor string `Xenora guest` and sets a feature bit only when every instruction of that feature is implemented: CMOV, POPCNT, LZCNT and long mode today. SSE and SSE2 are not reported while parts of them, such as RSQRTPS and MFENCE, are still rejected, so the table is truthful about Xenora and not a plausible hardware model. Unlisted leaves return zeros. `tests/cpu_features.rs` pins every leaf in both engines, requires each reported feature's instructions among the executed fixtures, and holds a refused witness instruction for 31 unreported features. `docs/cpu/instruction-registry.md` gives the table and the rule for reporting a new feature. Not compared with a processor; awaiting independent review.
|
||||
- Added six Wave32 gfx1030 VOP1 integer forms through the semantic registry, including bit scans and a two-register swap under EXEC (AMD RDNA 2 ISA guide section 12.8, #215). The compiler accepts 752 guide-derived cases and rejects 610 programs at the oracle’s expected offsets. Native Metal verification and independent acceptance are 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`.
|
||||
@@ -189,6 +196,7 @@ remains unsupported.
|
||||
- Fixed 32-bit guest stores and loads in the native DBT (MOV 89/8B and C7 /0), which accessed eight bytes: stores overwrote the next four guest bytes and accesses at the end of a mapping faulted. RIP-relative operands of byte moves and extensions, which were read as RBP-relative, and LEA with a segment prefix, which added the segment base, are fixed too.
|
||||
- Fixed an x86 prefix-length test that read an untracked fuzz artifact and so failed on every fresh checkout; its input is now inline.
|
||||
- Fixed agent-queue `apply_actions` crashing on comment-only decisions (claim refusals) by skipping no-op `gh issue edit` calls; accept `summary --now` after the subcommand; grant the audit job `pull-requests: read` so live audits can list open PRs (issue #180).
|
||||
- Fixed `scripts/audit/status.py` and the Python embedded in `scripts/audit/claims.sh` reading and writing tracked files in the process locale encoding instead of UTF-8: under an ASCII or cp1252 locale the status check crashed on `docs/claims.toml` or reported a spurious `xenora-progress.svg` difference. Both scripts now pass `encoding="utf-8"`, as the rest of `scripts/` does, the two write sites also pin `newline="\n"` so a Windows host cannot turn tracked LF files into CRLF when it regenerates them, and CI runs the two checks again under a non-UTF-8 locale so the requirement stays enforced.
|
||||
|
||||
- Generated CRT adapters now report unsupported calls when the required guest ABI or runtime behavior is missing.
|
||||
|
||||
|
||||
Generated
+1
@@ -204,6 +204,7 @@ dependencies = [
|
||||
"sha2",
|
||||
"xenora-metal",
|
||||
"xenora-shader",
|
||||
"xenora-texture",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
+81
-68
@@ -5,17 +5,17 @@ use std::fmt;
|
||||
pub use xenora_isa::{
|
||||
Architecture, CompareRelation, ExportTarget, Instruction, InterpolationPhase, ScalarAluOp,
|
||||
ScalarCompareOp, ScalarImmediateCompareOp, ScalarImmediateOp, ScalarSource, ScalarUnaryOp,
|
||||
VectorAluOp, VectorAluVop3Op, VectorCompareOp, VectorSource, VectorSwapOp, VectorUnaryOp,
|
||||
SoppControlOp, VectorAluOp, VectorAluVop3Op, VectorCompareOp, VectorCompareVop3Op,
|
||||
VectorSource, VectorSwapOp, VectorUnaryOp,
|
||||
};
|
||||
use xenora_isa::{
|
||||
BUFFER_LOAD_DWORD, BUFFER_STORE_DWORD, EXP, IMAGE_SAMPLE_LZ, S_BRANCH, S_CBRANCH_EXECZ,
|
||||
S_CBRANCH_SCC0, S_CBRANCH_VCCZ, S_ENDPGM, S_WAITCNT, S_WAITCNT_VSCNT, V_ADD_F32,
|
||||
BUFFER_LOAD_DWORD, BUFFER_STORE_DWORD, EXP, IMAGE_SAMPLE_LZ, S_WAITCNT_VSCNT, V_ADD_F32,
|
||||
V_INTERP_P1_F32, V_INTERP_P2_F32, V_MOV_B32, V_MUL_F32, VCC_LO,
|
||||
};
|
||||
|
||||
use xenora_isa::meta::EncodingFamily;
|
||||
use xenora_isa::semantics::{FORM_IDS, OperandRule};
|
||||
pub use xenora_isa::semantics::{VectorBinary, VectorUnary};
|
||||
pub use xenora_isa::semantics::{VectorBinary, VectorLowering, VectorUnary, VectorVcc};
|
||||
|
||||
/// Metadata forms that [`decode`] turns into an [`Instruction`] for at least one
|
||||
/// operand combination: the hand-written forms below followed by every form of
|
||||
@@ -40,17 +40,11 @@ const fn concat_forms<const N: usize>() -> [(&'static str, EncodingFamily); N] {
|
||||
}
|
||||
|
||||
/// Decoded forms not yet described by the semantic registry.
|
||||
const HANDWRITTEN_FORMS: [(&str, EncodingFamily); 16] = [
|
||||
const HANDWRITTEN_FORMS: [(&str, EncodingFamily); 10] = [
|
||||
("BUFFER_LOAD_DWORD", EncodingFamily::Mubuf),
|
||||
("BUFFER_STORE_DWORD", EncodingFamily::Mubuf),
|
||||
("EXP", EncodingFamily::Exp),
|
||||
("IMAGE_SAMPLE_LZ", EncodingFamily::Mimg),
|
||||
("S_BRANCH", EncodingFamily::Sopp),
|
||||
("S_CBRANCH_EXECZ", EncodingFamily::Sopp),
|
||||
("S_CBRANCH_SCC0", EncodingFamily::Sopp),
|
||||
("S_CBRANCH_VCCZ", EncodingFamily::Sopp),
|
||||
("S_ENDPGM", EncodingFamily::Sopp),
|
||||
("S_WAITCNT", EncodingFamily::Sopp),
|
||||
("S_WAITCNT_VSCNT", EncodingFamily::Sopk),
|
||||
("V_ADD_F32", EncodingFamily::Vop2),
|
||||
("V_INTERP_P1_F32", EncodingFamily::Vintrp),
|
||||
@@ -336,6 +330,26 @@ fn decode_gfx1030(bytes: &[u8], offset: usize) -> Result<(Instruction, u8), Deco
|
||||
if let Some(op) = VectorCompareOp::from_word(first) {
|
||||
return vector_compare(op, first, bytes);
|
||||
}
|
||||
if let Some(op) = VectorCompareVop3Op::from_word(first) {
|
||||
let second = word(bytes, 8)?;
|
||||
let sdst = first as u8;
|
||||
if sdst > VCC_LO {
|
||||
return Err(unsupported(
|
||||
op.assembly_name(),
|
||||
"expected a destination of s0-s105 or vcc_lo",
|
||||
));
|
||||
}
|
||||
let (src0, src1) = vop3_vgpr2_sources(op.assembly_name(), first, second)?;
|
||||
return Ok((
|
||||
Instruction::VectorCompareVop3 {
|
||||
op,
|
||||
sdst,
|
||||
src0,
|
||||
src1,
|
||||
},
|
||||
8,
|
||||
));
|
||||
}
|
||||
if let Some(op) = VectorAluVop3Op::from_word(first) {
|
||||
let second = word(bytes, 8)?;
|
||||
return Ok((vop3_vgpr2(op, first, second)?, 8));
|
||||
@@ -396,34 +410,25 @@ fn decode_gfx1030(bytes: &[u8], offset: usize) -> Result<(Instruction, u8), Deco
|
||||
let simm16 = first as u16;
|
||||
return Ok((Instruction::ScalarImmediateCompare { op, src, simm16 }, 4));
|
||||
}
|
||||
if S_BRANCH.matches(first) {
|
||||
let target = branch_target(first, offset, "s_branch")?;
|
||||
return Ok((Instruction::Branch { target }, S_BRANCH.byte_len()));
|
||||
if let Some(op) = SoppControlOp::from_word(first) {
|
||||
let immediate = first as u16;
|
||||
if op
|
||||
.required_immediate()
|
||||
.is_some_and(|exact| immediate != exact)
|
||||
{
|
||||
let detail = if op == SoppControlOp::EndProgram {
|
||||
"expected zero immediate"
|
||||
} else {
|
||||
"expected vmcnt(0) alone"
|
||||
};
|
||||
return Err(unsupported(op.mnemonic(), detail));
|
||||
}
|
||||
let instruction = op.decode(|| branch_target(immediate, offset, op.mnemonic()))?;
|
||||
return Ok((instruction, 4));
|
||||
}
|
||||
if let Some(op) = ScalarAluOp::from_word(first) {
|
||||
return scalar_alu(op, first, bytes);
|
||||
}
|
||||
if S_CBRANCH_SCC0.matches(first) {
|
||||
let target = branch_target(first, offset, "s_cbranch_scc0")?;
|
||||
return Ok((
|
||||
Instruction::BranchSccZero { target },
|
||||
S_CBRANCH_SCC0.byte_len(),
|
||||
));
|
||||
}
|
||||
if S_CBRANCH_EXECZ.matches(first) {
|
||||
let target = branch_target(first, offset, "s_cbranch_execz")?;
|
||||
return Ok((
|
||||
Instruction::BranchExecZero { target },
|
||||
S_CBRANCH_EXECZ.byte_len(),
|
||||
));
|
||||
}
|
||||
if S_CBRANCH_VCCZ.matches(first) {
|
||||
let target = branch_target(first, offset, "s_cbranch_vccz")?;
|
||||
return Ok((
|
||||
Instruction::BranchVccZero { target },
|
||||
S_CBRANCH_VCCZ.byte_len(),
|
||||
));
|
||||
}
|
||||
if let Some(op) = VectorAluOp::from_word(first) {
|
||||
// VOP2: SRC0 in bits 0-8, VSRC1 in bits 9-16, VDST in bits 17-24.
|
||||
let dst = ((first >> 17) & 0xff) as u8;
|
||||
@@ -434,7 +439,10 @@ fn decode_gfx1030(bytes: &[u8], offset: usize) -> Result<(Instruction, u8), Deco
|
||||
let (_, src0, _) = vop2_registers(first, op.assembly_name())?;
|
||||
(VectorSource::Register(src0), 4)
|
||||
}
|
||||
_ => vector_src0(first, bytes, op.assembly_name())?,
|
||||
OperandRule::Vop2Vgpr | OperandRule::Vop2Vcc => {
|
||||
vector_src0(first, bytes, op.assembly_name())?
|
||||
}
|
||||
_ => unreachable!("non-VOP2 operand rule for VOP2 instruction"),
|
||||
};
|
||||
return Ok((
|
||||
Instruction::VectorAlu {
|
||||
@@ -460,15 +468,6 @@ fn decode_gfx1030(bytes: &[u8], offset: usize) -> Result<(Instruction, u8), Deco
|
||||
V_MUL_F32.byte_len(),
|
||||
));
|
||||
}
|
||||
if S_WAITCNT.matches(first) {
|
||||
return scalar_form(
|
||||
first,
|
||||
S_WAITCNT.byte_len(),
|
||||
0xbf8c_3f70,
|
||||
Instruction::WaitLoad,
|
||||
"expected vmcnt(0) alone",
|
||||
);
|
||||
}
|
||||
if S_WAITCNT_VSCNT.matches(first) {
|
||||
return scalar_form(
|
||||
first,
|
||||
@@ -478,15 +477,6 @@ fn decode_gfx1030(bytes: &[u8], offset: usize) -> Result<(Instruction, u8), Deco
|
||||
"expected null, 0",
|
||||
);
|
||||
}
|
||||
if S_ENDPGM.matches(first) {
|
||||
return scalar_form(
|
||||
first,
|
||||
S_ENDPGM.byte_len(),
|
||||
0xbf81_0000,
|
||||
Instruction::EndProgram,
|
||||
"expected zero immediate",
|
||||
);
|
||||
}
|
||||
|
||||
Err(DecodeErrorKind::UnsupportedOpcode { word: first })
|
||||
}
|
||||
@@ -543,11 +533,11 @@ fn scalar_source(
|
||||
}
|
||||
|
||||
fn branch_target(
|
||||
first: u32,
|
||||
immediate: u16,
|
||||
offset: usize,
|
||||
mnemonic: &'static str,
|
||||
) -> Result<usize, DecodeErrorKind> {
|
||||
let displacement = first as u16 as i16;
|
||||
let displacement = immediate as i16;
|
||||
let words = usize::try_from(displacement)
|
||||
.map_err(|_| unsupported(mnemonic, "expected a forward branch"))?;
|
||||
offset
|
||||
@@ -674,7 +664,22 @@ 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"));
|
||||
}
|
||||
}
|
||||
if op.semantics().width == 16 && first & 0x1ff == 255 {
|
||||
return Err(unsupported(mnemonic, "literal in 16-bit compare"));
|
||||
}
|
||||
let (src0, len) = vector_src0(first, bytes, mnemonic)?;
|
||||
Ok((Instruction::VectorCompare { op, src0, src1 }, len))
|
||||
}
|
||||
|
||||
@@ -738,29 +743,37 @@ fn move_b32(first: u32, bytes: &[u8]) -> Result<(Instruction, u8), DecodeErrorKi
|
||||
Ok((Instruction::MoveB32 { dst, src }, len))
|
||||
}
|
||||
|
||||
/// Operand rule `vop3_vgpr2`: VDST in bits 0-7 of the first word, SRC0 and SRC1
|
||||
/// in bits 0-8 and 9-17 of the second (RDNA 2 ISA section 13.3.4, VOP3A). Both sources
|
||||
/// are VGPRs, ABS, OP_SEL, CLAMP, OMOD and NEG are clear, and the unused SRC2 is
|
||||
/// the gfx1030 assembler's inline-zero operand encoding.
|
||||
fn vop3_vgpr2(
|
||||
op: VectorAluVop3Op,
|
||||
first: u32,
|
||||
second: u32,
|
||||
) -> Result<Instruction, DecodeErrorKind> {
|
||||
let (src0, src1) = vop3_vgpr2_sources(op.assembly_name(), first, second)?;
|
||||
Ok(Instruction::VectorAluVop3 {
|
||||
op,
|
||||
dst: first as u8,
|
||||
src0,
|
||||
src1,
|
||||
})
|
||||
}
|
||||
|
||||
/// Common VOP3A source and modifier checks (RDNA 2 ISA section 13.3.4).
|
||||
/// SRC0 and SRC1 are VGPRs, the unused SRC2 is inline zero, and ABS, OP_SEL,
|
||||
/// CLAMP, OMOD and NEG are clear.
|
||||
fn vop3_vgpr2_sources(
|
||||
mnemonic: &'static str,
|
||||
first: u32,
|
||||
second: u32,
|
||||
) -> Result<(u8, u8), DecodeErrorKind> {
|
||||
let src0 = second & 0x1ff;
|
||||
let src1 = (second >> 9) & 0x1ff;
|
||||
if first & 0xff00 != 0 || second >> 18 != 128 || src0 < 256 || src1 < 256 {
|
||||
return Err(unsupported(
|
||||
op.assembly_name(),
|
||||
mnemonic,
|
||||
"expected two VGPR sources and no modifiers",
|
||||
));
|
||||
}
|
||||
Ok(Instruction::VectorAluVop3 {
|
||||
op,
|
||||
dst: first as u8,
|
||||
src0: src0 as u8,
|
||||
src1: src1 as u8,
|
||||
})
|
||||
Ok((src0 as u8, src1 as u8))
|
||||
}
|
||||
|
||||
fn scalar_form(
|
||||
|
||||
+321
-41
@@ -5,12 +5,12 @@ use std::process::{Command, Stdio};
|
||||
use xenora_decoder::{
|
||||
Architecture, CompareRelation, DecodeError, DecodeErrorKind, DecodedInstruction, Instruction,
|
||||
ScalarAluOp, ScalarImmediateOp, ScalarSource, ScalarUnaryOp, VectorAluOp, VectorAluVop3Op,
|
||||
VectorSource, VectorUnaryOp, decode, decode_at,
|
||||
VectorCompareOp, VectorCompareVop3Op, VectorSource, VectorUnaryOp, decode, decode_at,
|
||||
};
|
||||
use xenora_isa::semantics::Signedness;
|
||||
use xenora_ref::{
|
||||
BranchCondition, CompareSource, Comparison, Op, ScalarAlu, ScalarImmediate, ScalarUnary,
|
||||
Source, VectorAlu, VectorInteger, VectorUnary,
|
||||
BranchCondition, CompareSource, CompareWidth, Comparison, Op, ScalarAlu, ScalarImmediate,
|
||||
ScalarUnary, Source, VectorAlu, VectorInteger, VectorUnary,
|
||||
};
|
||||
|
||||
const FIXTURE: &[u8] = include_bytes!("../../../fixtures/rdna2/add.bin");
|
||||
@@ -71,6 +71,127 @@ fn decodes_each_fixture_instruction_with_offset_and_length() {
|
||||
assert_eq!(instructions, wanted);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn decodes_wave32_vop3_compares_from_llvm_words() {
|
||||
use VectorCompareVop3Op::*;
|
||||
|
||||
// llvm-mc -triple=amdgcn -mcpu=gfx1030 -mattr=+wavefrontsize32 -show-encoding
|
||||
let cases: [(u32, VectorCompareVop3Op, u8); 19] = [
|
||||
// v_cmp_lt_i32_e64 s4, v1, v2 ; encoding: [0x04,0x00,0x81,0xd4,0x01,0x05,0x02,0x02]
|
||||
(0xd481_0004, CmpLtI32, 4),
|
||||
// v_cmp_eq_i32_e64 s4, v1, v2 ; encoding: [0x04,0x00,0x82,0xd4,0x01,0x05,0x02,0x02]
|
||||
(0xd482_0004, CmpEqI32, 4),
|
||||
// v_cmp_le_i32_e64 s4, v1, v2 ; encoding: [0x04,0x00,0x83,0xd4,0x01,0x05,0x02,0x02]
|
||||
(0xd483_0004, CmpLeI32, 4),
|
||||
// v_cmp_gt_i32_e64 s4, v1, v2 ; encoding: [0x04,0x00,0x84,0xd4,0x01,0x05,0x02,0x02]
|
||||
(0xd484_0004, CmpGtI32, 4),
|
||||
// v_cmp_ne_i32_e64 s4, v1, v2 ; encoding: [0x04,0x00,0x85,0xd4,0x01,0x05,0x02,0x02]
|
||||
(0xd485_0004, CmpNeI32, 4),
|
||||
// v_cmp_ge_i32_e64 s4, v1, v2 ; encoding: [0x04,0x00,0x86,0xd4,0x01,0x05,0x02,0x02]
|
||||
(0xd486_0004, CmpGeI32, 4),
|
||||
// v_cmp_lt_u32_e64 s4, v1, v2 ; encoding: [0x04,0x00,0xc1,0xd4,0x01,0x05,0x02,0x02]
|
||||
(0xd4c1_0004, CmpLtU32, 4),
|
||||
// v_cmp_eq_u32_e64 s4, v1, v2 ; encoding: [0x04,0x00,0xc2,0xd4,0x01,0x05,0x02,0x02]
|
||||
(0xd4c2_0004, CmpEqU32, 4),
|
||||
// v_cmp_le_u32_e64 s4, v1, v2 ; encoding: [0x04,0x00,0xc3,0xd4,0x01,0x05,0x02,0x02]
|
||||
(0xd4c3_0004, CmpLeU32, 4),
|
||||
// v_cmp_gt_u32_e64 s4, v1, v2 ; encoding: [0x04,0x00,0xc4,0xd4,0x01,0x05,0x02,0x02]
|
||||
(0xd4c4_0004, CmpGtU32, 4),
|
||||
// v_cmp_ne_u32_e64 s4, v1, v2 ; encoding: [0x04,0x00,0xc5,0xd4,0x01,0x05,0x02,0x02]
|
||||
(0xd4c5_0004, CmpNeU32, 4),
|
||||
// v_cmp_ge_u32_e64 s4, v1, v2 ; encoding: [0x04,0x00,0xc6,0xd4,0x01,0x05,0x02,0x02]
|
||||
(0xd4c6_0004, CmpGeU32, 4),
|
||||
// v_cmp_f_i32_e64 s4, v1, v2 ; encoding: [0x04,0x00,0x80,0xd4,0x01,0x05,0x02,0x02]
|
||||
(0xd480_0004, CmpFI32, 4),
|
||||
// v_cmp_t_i32_e64 s4, v1, v2 ; encoding: [0x04,0x00,0x87,0xd4,0x01,0x05,0x02,0x02]
|
||||
(0xd487_0004, CmpTI32, 4),
|
||||
// v_cmp_f_u32_e64 s4, v1, v2 ; encoding: [0x04,0x00,0xc0,0xd4,0x01,0x05,0x02,0x02]
|
||||
(0xd4c0_0004, CmpFU32, 4),
|
||||
// v_cmp_t_u32_e64 s4, v1, v2 ; encoding: [0x04,0x00,0xc7,0xd4,0x01,0x05,0x02,0x02]
|
||||
(0xd4c7_0004, CmpTU32, 4),
|
||||
// v_cmp_eq_u32_e64 s0, v1, v2 ; encoding: [0x00,0x00,0xc2,0xd4,0x01,0x05,0x02,0x02]
|
||||
(0xd4c2_0000, CmpEqU32, 0),
|
||||
// v_cmp_eq_u32_e64 s105, v1, v2 ; encoding: [0x69,0x00,0xc2,0xd4,0x01,0x05,0x02,0x02]
|
||||
(0xd4c2_0069, CmpEqU32, 105),
|
||||
// v_cmp_eq_u32_e64 vcc_lo, v1, v2 ; encoding: [0x6a,0x00,0xc2,0xd4,0x01,0x05,0x02,0x02]
|
||||
(0xd4c2_006a, CmpEqU32, 106),
|
||||
];
|
||||
for (first, op, sdst) in cases {
|
||||
let code: Vec<_> = [first, 0x0202_0501]
|
||||
.into_iter()
|
||||
.flat_map(u32::to_le_bytes)
|
||||
.collect();
|
||||
let decoded = decode(Architecture::Gfx1030, &code).unwrap();
|
||||
let dst = if sdst == 106 {
|
||||
"vcc_lo".to_owned()
|
||||
} else {
|
||||
format!("s{sdst}")
|
||||
};
|
||||
assert_eq!(
|
||||
decoded,
|
||||
[DecodedInstruction {
|
||||
offset: 0,
|
||||
byte_len: 8,
|
||||
instruction: Instruction::VectorCompareVop3 {
|
||||
op,
|
||||
sdst,
|
||||
src0: 1,
|
||||
src1: 2
|
||||
},
|
||||
}],
|
||||
);
|
||||
assert_eq!(
|
||||
decoded[0].instruction.to_string(),
|
||||
format!("{} {dst}, v1, v2", op.assembly_name())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_noncanonical_wave32_vop3_compare_operands() {
|
||||
// v_cmp_eq_u32_e64 s4, v1, v2
|
||||
let first = 0xd4c2_0004;
|
||||
let second = 0x0202_0501;
|
||||
let rejects = |first, second| {
|
||||
let code: Vec<_> = [first, second]
|
||||
.into_iter()
|
||||
.flat_map(u32::to_le_bytes)
|
||||
.collect();
|
||||
let error = decode(Architecture::Gfx1030, &code).unwrap_err();
|
||||
assert_eq!(error.offset, 0);
|
||||
assert!(
|
||||
matches!(
|
||||
error.kind,
|
||||
DecodeErrorKind::UnsupportedForm {
|
||||
mnemonic: "v_cmp_eq_u32_e64",
|
||||
..
|
||||
}
|
||||
),
|
||||
"{first:#010x} {second:#010x}: {error}"
|
||||
);
|
||||
};
|
||||
|
||||
// Includes vcc_hi (107), TTMPs (108-123), null (124), m0 (125) and EXEC (126-127).
|
||||
for sdst in 107..=255 {
|
||||
rejects((first & !0xff) | sdst, second);
|
||||
}
|
||||
for bit in 8..=15 {
|
||||
// ABS, OP_SEL and CLAMP.
|
||||
rejects(first | (1 << bit), second);
|
||||
}
|
||||
for bit in 27..=31 {
|
||||
// OMOD and NEG.
|
||||
rejects(first, second | (1 << bit));
|
||||
}
|
||||
rejects(first, second ^ (1 << 18)); // SRC2 = 129 instead of 128.
|
||||
for shift in [0, 9] {
|
||||
for selector in [4, 106, 128, 240, 255] {
|
||||
// SGPR, VCC_LO, inline integer/float, literal.
|
||||
rejects(first, (second & !(0x1ff << shift)) | (selector << shift));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_non_boundary_prefix_reports_the_incomplete_instruction() {
|
||||
let lengths = [8, 4, 8, 8, 8, 4, 4];
|
||||
@@ -303,6 +424,44 @@ fn reference_scalar(scalar: ScalarSource) -> Source {
|
||||
}
|
||||
}
|
||||
|
||||
fn reference_comparison(op: VectorCompareOp) -> Comparison {
|
||||
Comparison {
|
||||
offset: match op.relation() {
|
||||
CompareRelation::Less => 1,
|
||||
CompareRelation::Equal => 2,
|
||||
CompareRelation::LessOrEqual => 3,
|
||||
CompareRelation::Greater => 4,
|
||||
CompareRelation::NotEqual => 5,
|
||||
CompareRelation::GreaterOrEqual => 6,
|
||||
CompareRelation::False => 0,
|
||||
CompareRelation::True => 7,
|
||||
},
|
||||
signed: op.signed(),
|
||||
}
|
||||
}
|
||||
|
||||
fn reference_vector_integer(op: VectorAluOp) -> VectorInteger {
|
||||
match op {
|
||||
VectorAluOp::CndmaskB32 => VectorInteger::Select,
|
||||
VectorAluOp::AddCoCiU32 => VectorInteger::AddCarry,
|
||||
VectorAluOp::SubCoCiU32 => VectorInteger::SubtractBorrow { reversed: false },
|
||||
VectorAluOp::SubrevCoCiU32 => VectorInteger::SubtractBorrow { reversed: true },
|
||||
VectorAluOp::MulI32I24 => VectorInteger::Multiply24 { signed: true },
|
||||
VectorAluOp::MulHiI32I24 => VectorInteger::MultiplyHigh24 { signed: true },
|
||||
VectorAluOp::MulU32U24 => VectorInteger::Multiply24 { signed: false },
|
||||
VectorAluOp::MulHiU32U24 => VectorInteger::MultiplyHigh24 { signed: false },
|
||||
VectorAluOp::MinI32 => VectorInteger::Minimum { signed: true },
|
||||
VectorAluOp::MaxI32 => VectorInteger::Maximum { signed: true },
|
||||
VectorAluOp::MinU32 => VectorInteger::Minimum { signed: false },
|
||||
VectorAluOp::MaxU32 => VectorInteger::Maximum { signed: false },
|
||||
VectorAluOp::XnorB32 => VectorInteger::Xnor,
|
||||
VectorAluOp::AddNcU32 => VectorInteger::Add,
|
||||
VectorAluOp::SubNcU32 => VectorInteger::Subtract,
|
||||
VectorAluOp::SubrevNcU32 => VectorInteger::SubtractReverse,
|
||||
_ => panic!("{op:?} decodes only with a VGPR SRC0 (operand rule vop2_vgpr2)"),
|
||||
}
|
||||
}
|
||||
|
||||
fn reference_op(instruction: Instruction) -> Op {
|
||||
match instruction {
|
||||
Instruction::BufferLoadDword {
|
||||
@@ -391,13 +550,23 @@ fn reference_op(instruction: Instruction) -> Op {
|
||||
reference_scalar(src0),
|
||||
reference_scalar(src1),
|
||||
),
|
||||
// The reference's VOP3 add; it is the only VOP3 variant so far.
|
||||
Instruction::VectorAluVop3 {
|
||||
op: VectorAluVop3Op::AddNcU32,
|
||||
dst,
|
||||
src0,
|
||||
src1,
|
||||
} => Op::Add(dst, src0, src1),
|
||||
Instruction::VectorAluVop3 {
|
||||
op,
|
||||
dst,
|
||||
src0,
|
||||
src1,
|
||||
} => Op::VectorInteger(
|
||||
reference_vector_integer(op.base()),
|
||||
dst,
|
||||
CompareSource::Vector(src0),
|
||||
src1,
|
||||
),
|
||||
Instruction::ScalarUnary { op, dst, src } => {
|
||||
let src = reference_scalar(src);
|
||||
let unary = match op {
|
||||
@@ -505,25 +674,29 @@ fn reference_op(instruction: Instruction) -> Op {
|
||||
panic!("compute reference matrix received a graphics/image instruction")
|
||||
}
|
||||
|
||||
Instruction::VectorCompare { op, src0, src1 } => Op::Compare(
|
||||
Comparison {
|
||||
offset: match op.relation() {
|
||||
CompareRelation::Less => 1,
|
||||
CompareRelation::Equal => 2,
|
||||
CompareRelation::LessOrEqual => 3,
|
||||
CompareRelation::Greater => 4,
|
||||
CompareRelation::NotEqual => 5,
|
||||
CompareRelation::GreaterOrEqual => 6,
|
||||
CompareRelation::False => 0,
|
||||
CompareRelation::True => 7,
|
||||
},
|
||||
signed: op.signed(),
|
||||
},
|
||||
match src0 {
|
||||
Instruction::VectorCompare { op, src0, src1 } => {
|
||||
let comparison = reference_comparison(op);
|
||||
let src0 = match src0 {
|
||||
VectorSource::Register(reg) => CompareSource::Vector(reg),
|
||||
VectorSource::Scalar(reg) => CompareSource::Scalar(reg),
|
||||
VectorSource::Immediate(bits) => CompareSource::Immediate(bits),
|
||||
},
|
||||
};
|
||||
match op.semantics().width {
|
||||
16 => Op::WideCompare(comparison, CompareWidth::Half, src0, src1),
|
||||
32 => Op::Compare(comparison, src0, src1),
|
||||
64 => Op::WideCompare(comparison, CompareWidth::Double, src0, src1),
|
||||
width => panic!("unexpected VOPC operand width {width}"),
|
||||
}
|
||||
}
|
||||
Instruction::VectorCompareVop3 {
|
||||
op,
|
||||
sdst,
|
||||
src0,
|
||||
src1,
|
||||
} => Op::CompareVop3(
|
||||
sdst,
|
||||
reference_comparison(op.base()),
|
||||
CompareSource::Vector(src0),
|
||||
src1,
|
||||
),
|
||||
Instruction::VectorAlu {
|
||||
@@ -532,21 +705,7 @@ fn reference_op(instruction: Instruction) -> Op {
|
||||
src0,
|
||||
src1,
|
||||
} => Op::VectorInteger(
|
||||
match op {
|
||||
VectorAluOp::MulI32I24 => VectorInteger::Multiply24 { signed: true },
|
||||
VectorAluOp::MulHiI32I24 => VectorInteger::MultiplyHigh24 { signed: true },
|
||||
VectorAluOp::MulU32U24 => VectorInteger::Multiply24 { signed: false },
|
||||
VectorAluOp::MulHiU32U24 => VectorInteger::MultiplyHigh24 { signed: false },
|
||||
VectorAluOp::MinI32 => VectorInteger::Minimum { signed: true },
|
||||
VectorAluOp::MaxI32 => VectorInteger::Maximum { signed: true },
|
||||
VectorAluOp::MinU32 => VectorInteger::Minimum { signed: false },
|
||||
VectorAluOp::MaxU32 => VectorInteger::Maximum { signed: false },
|
||||
VectorAluOp::XnorB32 => VectorInteger::Xnor,
|
||||
VectorAluOp::AddNcU32 => VectorInteger::Add,
|
||||
VectorAluOp::SubNcU32 => VectorInteger::Subtract,
|
||||
VectorAluOp::SubrevNcU32 => VectorInteger::SubtractReverse,
|
||||
_ => panic!("{op:?} decodes only with a VGPR SRC0 (operand rule vop2_vgpr2)"),
|
||||
},
|
||||
reference_vector_integer(op),
|
||||
dst,
|
||||
match src0 {
|
||||
VectorSource::Register(reg) => CompareSource::Vector(reg),
|
||||
@@ -582,15 +741,19 @@ fn compares_fixture_instructions_against_llvm() {
|
||||
include_bytes!("../../../fixtures/rdna2/scalar-arith.bin"),
|
||||
include_bytes!("../../../fixtures/rdna2/scalar-immediate.bin"),
|
||||
include_bytes!("../../../fixtures/rdna2/vector-integer.bin"),
|
||||
include_bytes!("../../../fixtures/rdna2/vector-vcc.bin"),
|
||||
include_bytes!("../../../fixtures/rdna2/vector-compare.bin"),
|
||||
include_bytes!("../../../fixtures/rdna2/vector-compare-ft.bin"),
|
||||
include_bytes!("../../../fixtures/rdna2/vector-unary.bin"),
|
||||
include_bytes!("../../../fixtures/rdna2/vector-compare-16.bin"),
|
||||
include_bytes!("../../../fixtures/rdna2/vop3-integer.bin"),
|
||||
include_bytes!("../../../fixtures/rdna2/vop3-compare.bin"),
|
||||
high_registers,
|
||||
&matrix,
|
||||
] {
|
||||
count += compare_against_llvm(fixture, &mut forms);
|
||||
}
|
||||
assert_eq!(forms.len(), 126, "forms compared: {forms:?}");
|
||||
assert_eq!(forms.len(), 169, "forms compared: {forms:?}");
|
||||
eprintln!(
|
||||
"{count} three-way instruction comparisons across {} forms",
|
||||
forms.len()
|
||||
@@ -818,7 +981,7 @@ fn distinguishes_llvm_invalid_encodings_from_xenora_subset_rejections() {
|
||||
let outside_subset: &[&[u32]] = &[
|
||||
&[0x7e04_026b], // VOP1 VCC_HI source
|
||||
&[0x7da2_0501], // v_cmpx_eq_u32_e32
|
||||
&[0xd482_006a, 0x0002_0501], // v_cmp_lt_i32_e64
|
||||
&[0xd482_006a, 0x0002_0501], // v_cmp_eq_i32_e64 with SRC2 = 0
|
||||
&[0x8788_0908], // s_and_b64
|
||||
&[0x8008_ffff, 0x1234_5678], // SOP2 with two literal sources
|
||||
&[0x806c_0908], // SOP2 TTMP destination
|
||||
@@ -887,7 +1050,7 @@ fn normalize_llvm_assembly(assembly: &str, next_offset: usize) -> String {
|
||||
let target = next_offset + displacement * 4;
|
||||
format!("{mnemonic} -> 0x{target:04x}")
|
||||
}
|
||||
// VOPC and the registry VOP2 forms print SRC0 (the second operand) as bits.
|
||||
// VOPC and registry VOP2 forms print SRC0 as bits.
|
||||
mnemonic
|
||||
if mnemonic.starts_with("v_cmp_")
|
||||
|| VectorAluOp::ALL
|
||||
@@ -895,10 +1058,11 @@ fn normalize_llvm_assembly(assembly: &str, next_offset: usize) -> String {
|
||||
.any(|op| op.assembly_name() == mnemonic) =>
|
||||
{
|
||||
let mut parts: Vec<String> = operands.split(", ").map(str::to_owned).collect();
|
||||
parts[1] = match literal_bits(&parts[1]) {
|
||||
let src = if parts.len() == 5 { 2 } else { 1 };
|
||||
parts[src] = match literal_bits(&parts[src]) {
|
||||
Some(bits) => format!("0x{bits:x}"),
|
||||
None => parts[1].parse::<i32>().map_or_else(
|
||||
|_| parts[1].clone(),
|
||||
None => parts[src].parse::<i32>().map_or_else(
|
||||
|_| parts[src].clone(),
|
||||
|value| format!("0x{:x}", value as u32),
|
||||
),
|
||||
};
|
||||
@@ -1107,6 +1271,122 @@ fn decode_at_resolves_branch_targets_from_the_stream_offset() {
|
||||
);
|
||||
}
|
||||
|
||||
// llvm-mc -triple=amdgcn -mcpu=gfx1030 -show-encoding
|
||||
const VOP3_INTEGER_ENCODINGS: [(VectorAluVop3Op, u32); 11] = [
|
||||
// v_mul_i32_i24_e64 v255, v0, v127 ; encoding: [0xff,0x00,0x09,0xd5,0x00,0xff,0x02,0x02]
|
||||
(VectorAluVop3Op::MulI32I24, 0xd50900ff),
|
||||
// v_mul_hi_i32_i24_e64 v255, v0, v127 ; encoding: [0xff,0x00,0x0a,0xd5,0x00,0xff,0x02,0x02]
|
||||
(VectorAluVop3Op::MulHiI32I24, 0xd50a00ff),
|
||||
// v_mul_u32_u24_e64 v255, v0, v127 ; encoding: [0xff,0x00,0x0b,0xd5,0x00,0xff,0x02,0x02]
|
||||
(VectorAluVop3Op::MulU32U24, 0xd50b00ff),
|
||||
// v_mul_hi_u32_u24_e64 v255, v0, v127 ; encoding: [0xff,0x00,0x0c,0xd5,0x00,0xff,0x02,0x02]
|
||||
(VectorAluVop3Op::MulHiU32U24, 0xd50c00ff),
|
||||
// v_min_i32_e64 v255, v0, v127 ; encoding: [0xff,0x00,0x11,0xd5,0x00,0xff,0x02,0x02]
|
||||
(VectorAluVop3Op::MinI32, 0xd51100ff),
|
||||
// v_max_i32_e64 v255, v0, v127 ; encoding: [0xff,0x00,0x12,0xd5,0x00,0xff,0x02,0x02]
|
||||
(VectorAluVop3Op::MaxI32, 0xd51200ff),
|
||||
// v_min_u32_e64 v255, v0, v127 ; encoding: [0xff,0x00,0x13,0xd5,0x00,0xff,0x02,0x02]
|
||||
(VectorAluVop3Op::MinU32, 0xd51300ff),
|
||||
// v_max_u32_e64 v255, v0, v127 ; encoding: [0xff,0x00,0x14,0xd5,0x00,0xff,0x02,0x02]
|
||||
(VectorAluVop3Op::MaxU32, 0xd51400ff),
|
||||
// v_xnor_b32_e64 v255, v0, v127 ; encoding: [0xff,0x00,0x1e,0xd5,0x00,0xff,0x02,0x02]
|
||||
(VectorAluVop3Op::XnorB32, 0xd51e00ff),
|
||||
// v_sub_nc_u32_e64 v255, v0, v127 ; encoding: [0xff,0x00,0x26,0xd5,0x00,0xff,0x02,0x02]
|
||||
(VectorAluVop3Op::SubNcU32, 0xd52600ff),
|
||||
// v_subrev_nc_u32_e64 v255, v0, v127 ; encoding: [0xff,0x00,0x27,0xd5,0x00,0xff,0x02,0x02]
|
||||
(VectorAluVop3Op::SubrevNcU32, 0xd52700ff),
|
||||
];
|
||||
const VOP3_INTEGER_SOURCE_WORD: u32 = 0x0202_ff00;
|
||||
|
||||
#[test]
|
||||
fn decodes_registry_vop3_integer_encodings() {
|
||||
for (op, first) in VOP3_INTEGER_ENCODINGS {
|
||||
let bytes = [first.to_le_bytes(), VOP3_INTEGER_SOURCE_WORD.to_le_bytes()].concat();
|
||||
let decoded = decode(Architecture::Gfx1030, &bytes).unwrap();
|
||||
assert_eq!(decoded.len(), 1);
|
||||
assert_eq!(decoded[0].byte_len, 8);
|
||||
assert_eq!(
|
||||
decoded[0].instruction,
|
||||
Instruction::VectorAluVop3 {
|
||||
op,
|
||||
dst: 255,
|
||||
src0: 0,
|
||||
src1: 127,
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn decodes_vop3_integer_fixture() {
|
||||
use VectorAluVop3Op::*;
|
||||
|
||||
let code = include_bytes!("../../../fixtures/rdna2/vop3-integer.bin");
|
||||
let decoded = decode(Architecture::Gfx1030, code).unwrap();
|
||||
let expected = [
|
||||
(MulI32I24, 2, 1, 1),
|
||||
(MulHiI32I24, 3, 2, 1),
|
||||
(MulU32U24, 4, 2, 1),
|
||||
(MulHiU32U24, 255, 4, 1),
|
||||
(MinI32, 6, 1, 2),
|
||||
(MaxI32, 7, 1, 4),
|
||||
(MinU32, 8, 3, 1),
|
||||
(MaxU32, 9, 255, 2),
|
||||
(XnorB32, 10, 1, 255),
|
||||
(SubNcU32, 11, 6, 10),
|
||||
(SubrevNcU32, 1, 1, 9),
|
||||
];
|
||||
let actual: Vec<_> = decoded
|
||||
.iter()
|
||||
.filter_map(|decoded| match decoded.instruction {
|
||||
Instruction::VectorAluVop3 {
|
||||
op,
|
||||
dst,
|
||||
src0,
|
||||
src1,
|
||||
} => Some((decoded.offset, decoded.byte_len, op, dst, src0, src1)),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
let expected: Vec<_> = expected
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.map(|(index, (op, dst, src0, src1))| (12 + 8 * index, 8, op, dst, src0, src1))
|
||||
.collect();
|
||||
assert_eq!(actual, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_registry_vop3_integer_modifiers_and_other_sources() {
|
||||
for (op, first) in VOP3_INTEGER_ENCODINGS {
|
||||
let second = VOP3_INTEGER_SOURCE_WORD;
|
||||
let reject = |first: u32, second: u32| {
|
||||
let bytes = [first.to_le_bytes(), second.to_le_bytes()].concat();
|
||||
let error = decode(Architecture::Gfx1030, &bytes)
|
||||
.expect_err(&format!("{op:?} accepted {first:#010x} {second:#010x}"));
|
||||
assert_eq!(error.offset, 0);
|
||||
assert!(matches!(
|
||||
error.kind,
|
||||
DecodeErrorKind::UnsupportedForm { mnemonic, .. }
|
||||
if mnemonic == op.assembly_name()
|
||||
));
|
||||
};
|
||||
|
||||
// First word: ABS[10:8], OP_SEL[14:11], CLAMP[15].
|
||||
for bit in 8..=15 {
|
||||
reject(first | (1 << bit), second);
|
||||
}
|
||||
// Second word: OMOD[28:27], NEG[31:29].
|
||||
for bit in 27..=31 {
|
||||
reject(first, second | (1 << bit));
|
||||
}
|
||||
|
||||
reject(first, second & !0x1ff); // SRC0 = s0
|
||||
reject(first, (second & !(0x1ff << 9)) | (128 << 9)); // SRC1 = inline zero
|
||||
reject(first, second | (1 << 18)); // SRC2 = inline one
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn decodes_sopk_immediates_and_rejects_non_sgpr_operands() {
|
||||
use xenora_decoder::ScalarImmediateCompareOp;
|
||||
|
||||
@@ -44,12 +44,25 @@ TOP_KEYS = {
|
||||
# An encoding variant is another encoding of a form already in the registry (for
|
||||
# example the VOP3 `_e64` encoding of a VOP2 form): pure data that names the base
|
||||
# form, the encoding family, its opcode there and the operand rule of that
|
||||
# encoding. It inherits the base form's operation, signedness and effects.
|
||||
# encoding. The rule may redirect the base form's mask to an explicit destination.
|
||||
VARIANT_KEYS = {"of", "family", "opcode", "operands", "spec", "verify"}
|
||||
# The assembler suffix LLVM prints for a variant's encoding family.
|
||||
ASSEMBLY_SUFFIX = {"VOP3": "_e64"}
|
||||
|
||||
# Control effects select an existing typed instruction and its operand contract.
|
||||
# The XML records SCC as a separate implicit input. VCC and EXEC predicates
|
||||
# have fieldless mask inputs instead.
|
||||
CONTROL_OPERATIONS = {
|
||||
"end_program": ("EndProgram", "sopp_end", None),
|
||||
"branch": ("Branch", "sopp_branch", None),
|
||||
"branch_scc_zero": ("BranchSccZero", "sopp_branch", None),
|
||||
"branch_vcc_zero": ("BranchVccZero", "sopp_branch", "OPR_VCC"),
|
||||
"branch_exec_zero": ("BranchExecZero", "sopp_branch", "OPR_SDST_EXEC"),
|
||||
"wait_load": ("WaitLoad", "sopp_wait", None),
|
||||
}
|
||||
|
||||
OPERATIONS = {
|
||||
**{name: variant for name, (variant, _, _) in CONTROL_OPERATIONS.items()},
|
||||
"add": "Add", "sub": "Sub", "and": "And", "or": "Or", "xor": "Xor",
|
||||
"andn2": "AndNot", "orn2": "OrNot", "nand": "Nand", "nor": "Nor", "xnor": "Xnor",
|
||||
"lshl": "ShiftLeft", "lshr": "LogicalShiftRight", "ashr": "ArithmeticShiftRight",
|
||||
@@ -76,10 +89,13 @@ 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 = {
|
||||
16: {"signed": 136, "unsigned": 168},
|
||||
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.
|
||||
@@ -124,7 +140,7 @@ SHIFT_AMOUNTS = {1, 2, 3, 4}
|
||||
SOURCE_ORDER_KEY = "source_order"
|
||||
SOURCE_ORDERS = {"reversed"}
|
||||
SIGNEDNESS = {"unsigned": "Unsigned", "signed": "Signed", "bitwise": "Bitwise"}
|
||||
CARRY_IN = {"none": "None", "scc": "Scc"}
|
||||
CARRY_IN = {"none": "None", "scc": "Scc", "vcc": "Vcc"}
|
||||
SCC = {
|
||||
"unchanged": "Unchanged",
|
||||
"carry_out": "CarryOut",
|
||||
@@ -134,16 +150,19 @@ SCC = {
|
||||
"relation": "Relation",
|
||||
"selected_src0": "SelectedSrc0",
|
||||
}
|
||||
# lane_mask: the Wave32 VOPC result written to VCC_LO (vcc only; EXEC writes
|
||||
# such as v_cmpx have no contract yet, so exec must stay unchanged).
|
||||
MASK = {"unchanged": "Unchanged", "lane_mask": "LaneMask"}
|
||||
# lane_mask: the Wave32 compare or carry result written to VCC_LO.
|
||||
# sdst_lane_mask: the Wave32 compare result written to explicit VOP3A SDST.
|
||||
# EXEC writes such as v_cmpx have no contract, so exec must stay unchanged.
|
||||
MASK = {"unchanged": "Unchanged", "lane_mask": "LaneMask", "sdst_lane_mask": "SdstLaneMask"}
|
||||
WAVE = {"any": "Any", "wave32": "Wave32"}
|
||||
# Which wave declaration each operand-rule kind must make. The decoder has no
|
||||
# wave-size input, so "wave32" is only true where the caller's ABI fixes the
|
||||
# wave size: the lane-mask compares, whose one entry point is the Wave32
|
||||
# compute fixture ABI (docs/shaders/vector-compare.md section 2). Every other
|
||||
# kind must be "any".
|
||||
WAVE_BY_KIND = {"vector_compare": "wave32", "vector_unary": "wave32", "vector_swap": "wave32"}
|
||||
# The synthetic compute fixture ABI fixes the wave size for these operand-rule
|
||||
# kinds and for the VCC-reading VOP2 rule. Other forms declare "any".
|
||||
WAVE_BY_KIND = {"control": "wave32", "vector_compare": "wave32", "vector_unary": "wave32", "vector_swap": "wave32"}
|
||||
VCC_VECTOR_PRIMITIVES = {
|
||||
("cselect", "bitwise"): "Select",
|
||||
("add", "unsigned"): "AddCarry",
|
||||
("sub", "unsigned"): "SubtractBorrow",
|
||||
}
|
||||
EVIDENCE = {
|
||||
"reference": "Reference",
|
||||
"independent": "Independent",
|
||||
@@ -164,7 +183,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.
|
||||
@@ -258,7 +276,12 @@ UNSUPPORTED_COMBOS = {
|
||||
# which SOP2 groups under src_vcc and src_special).
|
||||
# VOP3 rules also name source classes and encoding fields they refuse.
|
||||
VOP3_COMBOS = {"src_sgpr", "src_inline", "src_literal", "modifiers", "src2"}
|
||||
ALL_COMBOS = UNSUPPORTED_COMBOS | {"src_vcc_hi", "src_null"} | VOP3_COMBOS
|
||||
ALL_COMBOS = UNSUPPORTED_COMBOS | {"src_vcc_hi", "src_null", "dst_vcc_hi"} | VOP3_COMBOS
|
||||
VOP3_VGPR2_UNSUPPORTED = {
|
||||
"src_sgpr", "src_vcc", "src_exec", "src_m0", "src_ttmp", "src_null", "src_inline",
|
||||
"src_float_inline", "src_special", "src_literal", "modifiers", "src2",
|
||||
}
|
||||
|
||||
VECTOR_UNARY_PRIMITIVES = {
|
||||
("not", "bitwise"): "Not",
|
||||
("brev", "bitwise"): "ReverseBits",
|
||||
@@ -268,6 +291,28 @@ VECTOR_UNARY_PRIMITIVES = {
|
||||
}
|
||||
|
||||
OPERAND_RULES = {
|
||||
"sopp_end": {
|
||||
"rust": "SoppEnd",
|
||||
"enum": "SoppControlOp",
|
||||
"shape": {"family": "SOPP", "src": [], "max_literals": 0, "immediate": 0},
|
||||
"unsupported": set(),
|
||||
"kind": "control",
|
||||
},
|
||||
"sopp_branch": {
|
||||
"rust": "SoppBranch",
|
||||
"enum": "SoppControlOp",
|
||||
"shape": {"family": "SOPP", "src": [{"field": "SIMM16", "class": "label"}], "max_literals": 0},
|
||||
"unsupported": set(),
|
||||
"kind": "control",
|
||||
},
|
||||
"sopp_wait": {
|
||||
"rust": "SoppWait",
|
||||
"enum": "SoppControlOp",
|
||||
"shape": {"family": "SOPP", "src": [{"field": "SIMM16", "class": "waitcnt"}],
|
||||
"max_literals": 0, "immediate": 0x3f70},
|
||||
"unsupported": set(),
|
||||
"kind": "control",
|
||||
},
|
||||
"vop1_vgpr": {
|
||||
"rust": "Vop1Vgpr",
|
||||
"enum": "VectorUnaryOp",
|
||||
@@ -401,6 +446,44 @@ OPERAND_RULES = {
|
||||
},
|
||||
"kind": "vector_compare",
|
||||
},
|
||||
"vopc_vcc_half": {
|
||||
"rust": "VopcVccHalf",
|
||||
"enum": "VectorCompareOp",
|
||||
"shape": {
|
||||
"family": "VOPC",
|
||||
"src": [
|
||||
{"field": "SRC0", "class": "vector_source"},
|
||||
{"field": "VSRC1", "class": "vgpr"},
|
||||
],
|
||||
"max_literals": 0,
|
||||
},
|
||||
# The destination is implicitly vcc_lo; the decoder rejects these SRC0
|
||||
# selectors (the same vector_source as VOP2).
|
||||
"unsupported": {
|
||||
"src_literal", "src_vcc_hi", "src_exec", "src_m0", "src_ttmp", "src_null", "src_float_inline",
|
||||
"src_special",
|
||||
},
|
||||
"kind": "vector_compare",
|
||||
"width": 16,
|
||||
},
|
||||
"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",
|
||||
@@ -418,16 +501,34 @@ OPERAND_RULES = {
|
||||
},
|
||||
# Two VGPR sources only, with ABS, OP_SEL, CLAMP, OMOD and NEG clear and
|
||||
# SRC2 the assembler's unused inline zero; the decoder rejects the rest.
|
||||
"unsupported": {
|
||||
"src_sgpr", "src_vcc", "src_exec", "src_m0", "src_ttmp", "src_null", "src_inline",
|
||||
"src_float_inline", "src_special", "src_literal", "modifiers", "src2",
|
||||
},
|
||||
"unsupported": VOP3_VGPR2_UNSUPPORTED,
|
||||
"kind": "vector_vop3",
|
||||
# Only encoding variants of forms whose rule has this kind may use it.
|
||||
"variant_of": "vector",
|
||||
# The generated enum of this rule's variants; base() maps to "enum".
|
||||
"variant_enum": "VectorAluVop3Op",
|
||||
},
|
||||
"vop3_cmp_vgpr2": {
|
||||
"rust": "Vop3CmpVgpr2",
|
||||
"enum": "VectorCompareOp",
|
||||
"shape": {
|
||||
"family": "VOP3",
|
||||
"dst": {"field": "VDST", "class": "sgpr", "min": 0, "max": 106},
|
||||
"src": [
|
||||
{"field": "SRC0", "class": "vgpr"},
|
||||
{"field": "SRC1", "class": "vgpr"},
|
||||
],
|
||||
"max_literals": 0,
|
||||
"variant_only": True,
|
||||
},
|
||||
"unsupported": VOP3_VGPR2_UNSUPPORTED | {
|
||||
"dst_vcc_hi", "dst_exec", "dst_ttmp", "dst_m0", "dst_null",
|
||||
},
|
||||
"kind": "vector_compare_vop3",
|
||||
"variant_of": "vector_compare",
|
||||
"variant_enum": "VectorCompareVop3Op",
|
||||
"vcc_transition": ("lane_mask", "sdst_lane_mask"),
|
||||
},
|
||||
"vop2_vgpr": {
|
||||
"rust": "Vop2Vgpr",
|
||||
"enum": "VectorAluOp",
|
||||
@@ -448,6 +549,24 @@ OPERAND_RULES = {
|
||||
},
|
||||
"kind": "vector",
|
||||
},
|
||||
"vop2_vcc": {
|
||||
"rust": "Vop2Vcc",
|
||||
"enum": "VectorAluOp",
|
||||
"shape": {
|
||||
"family": "VOP2",
|
||||
"dst": {"field": "VDST", "class": "vgpr", "min": 0, "max": 255},
|
||||
"src": [
|
||||
{"field": "SRC0", "class": "vector_source"},
|
||||
{"field": "VSRC1", "class": "vgpr"},
|
||||
],
|
||||
"max_literals": 1,
|
||||
},
|
||||
"unsupported": {
|
||||
"src_vcc_hi", "src_exec", "src_m0", "src_ttmp", "src_null", "src_float_inline",
|
||||
"src_special",
|
||||
},
|
||||
"kind": "vector",
|
||||
},
|
||||
"vop2_vgpr2": {
|
||||
"rust": "Vop2Vgpr2",
|
||||
"enum": "VectorAluOp",
|
||||
@@ -637,24 +756,35 @@ def _check_xml(form, rule, snapshot, errors):
|
||||
operands = {}
|
||||
scc_in = scc_out = False
|
||||
implicit = set()
|
||||
vcc_writes = []
|
||||
for field, data_format, kind, size, is_input, is_output, _implicit, _encoded in variant["operands"]:
|
||||
vcc_operands = []
|
||||
control_mask = CONTROL_OPERATIONS.get(form["operation"], (None, None, None))[2]
|
||||
mask_inputs = 0
|
||||
for field, data_format, kind, size, is_input, is_output, is_implicit, encoded in variant["operands"]:
|
||||
if kind == "OPR_SSRC_SPECIAL_SCC":
|
||||
scc_in |= is_input
|
||||
scc_out |= is_output
|
||||
elif control_mask and (field, kind, data_format, size, is_input, is_output, is_implicit, encoded) == (
|
||||
"", control_mask, "FMT_NUM_M64", 64, True, False, True, True
|
||||
):
|
||||
mask_inputs += 1
|
||||
elif field:
|
||||
operands[field] = (data_format, size, is_input, is_output)
|
||||
operands[field] = (data_format, kind, size, is_input, is_output)
|
||||
elif kind == "OPR_VCC":
|
||||
vcc_operands.append((data_format, size, is_input, is_output))
|
||||
else:
|
||||
implicit.add(kind)
|
||||
if kind == "OPR_VCC":
|
||||
vcc_writes.append((is_input, is_output))
|
||||
# The vocabulary states SCC effects and a lane-mask VCC write; any other
|
||||
# implicit XML operand (such as an EXEC write) is undeclared.
|
||||
if form["carry_in"] == "vcc":
|
||||
if vcc_operands.count(("FMT_NUM_M64", 64, True, False)) != 1:
|
||||
errors.append(f"{label}: carry_in vcc requires one implicit XML VCC input")
|
||||
if ("FMT_NUM_M64", 64, True, False) in vcc_operands:
|
||||
vcc_operands.remove(("FMT_NUM_M64", 64, True, False))
|
||||
if form["vcc"] == "lane_mask":
|
||||
# Exactly one fieldless VCC operand, written and not read.
|
||||
if vcc_writes != [(False, True)]:
|
||||
if vcc_operands != [("FMT_NUM_M64", 64, False, True)]:
|
||||
errors.append(f"{label}: vcc lane_mask but the XML has no implicit VCC output")
|
||||
implicit.discard("OPR_VCC")
|
||||
elif vcc_operands:
|
||||
implicit.add("OPR_VCC")
|
||||
if control_mask and mask_inputs != 1:
|
||||
errors.append(f"{label}: expected one implicit {control_mask} input in the XML")
|
||||
if implicit:
|
||||
errors.append(f"{label}: XML implicit operands {sorted(implicit)} are not declared")
|
||||
if scc_in != (form["carry_in"] == "scc"):
|
||||
@@ -674,7 +804,15 @@ def _check_xml(form, rule, snapshot, errors):
|
||||
if field not in operands:
|
||||
errors.append(f"{label}: XML has no operand {field}")
|
||||
continue
|
||||
data_format, size, is_input, is_output = operands[field]
|
||||
data_format, kind, size, is_input, is_output = operands[field]
|
||||
if field == "SIMM16" and _rule_kind(form) == "control":
|
||||
expected_kind, expected_format = (
|
||||
("OPR_LABEL", "FMT_NUM_I16") if form["operands"] == "sopp_branch"
|
||||
else ("OPR_WAITCNT", "FMT_NUM_B16")
|
||||
)
|
||||
if [field, expected_format, expected_kind, 16, True, False, False, True] not in variant["operands"]:
|
||||
errors.append(f"{label}: SIMM16 is not an encoded {expected_kind} input")
|
||||
continue
|
||||
if field == "SIMM16":
|
||||
# The 16-bit immediate: signed forms read it as FMT_NUM_I16 (sign
|
||||
# extended), unsigned compares as FMT_NUM_U16 (zero extended).
|
||||
@@ -686,6 +824,11 @@ def _check_xml(form, rule, snapshot, errors):
|
||||
continue
|
||||
bits = form.get(SOURCE_BITS_KEY) if is_source else None
|
||||
expected = bits if type(bits) is int else form["width"]
|
||||
if not is_source and form["vcc"] == "sdst_lane_mask":
|
||||
# The XML describes the Wave64 pair. The Wave32 ABI writes one SGPR.
|
||||
expected = 64
|
||||
if (kind, data_format) != ("OPR_SREG", "FMT_NUM_M64"):
|
||||
errors.append(f"{label}: {field} is not a scalar mask destination in the XML")
|
||||
if size != expected:
|
||||
errors.append(f"{label}: {field} is {size} bits in the XML, declared {expected}")
|
||||
# The XML marks both swap operands as outputs. Guide 12.8 also
|
||||
@@ -701,7 +844,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'}{form['width']}"}
|
||||
if form["operands"] in ("vopc_vcc_half", "vopc_vcc_pair")
|
||||
else SOURCE_FORMATS.get(form["signedness"], ())
|
||||
):
|
||||
errors.append(
|
||||
f"{label}: signedness {form['signedness']} contradicts XML format {data_format}"
|
||||
)
|
||||
@@ -771,18 +918,23 @@ def validate(registry, snapshot):
|
||||
errors.append(f"{label}: variant {form['variant']!r} is reserved")
|
||||
if type(form["opcode"]) is not int or not 0 <= form["opcode"] <= U16_MAX:
|
||||
errors.append(f"{label}: invalid opcode")
|
||||
wave = WAVE_BY_KIND.get(_rule_kind(form), "any")
|
||||
reads_vcc = form["operands"] == "vop2_vcc"
|
||||
wave = "wave32" if reads_vcc else WAVE_BY_KIND.get(_rule_kind(form), "any")
|
||||
if (form["carry_in"] == "vcc") != reads_vcc:
|
||||
errors.append(f"{label}: implicit VCC input requires the vop2_vcc rule")
|
||||
if form["wave"] in WAVE and form["wave"] != wave:
|
||||
errors.append(f"{label}: wave {form['wave']} is not enforced for this rule (requires {wave})")
|
||||
lane_mask = _rule_kind(form) == "vector_compare"
|
||||
if form["vcc"] in MASK and (form["vcc"] == "lane_mask") != lane_mask:
|
||||
lane_mask = _rule_kind(form) == "vector_compare" or (reads_vcc and form["operation"] != "cselect")
|
||||
vcc = "lane_mask" if lane_mask else "unchanged"
|
||||
if form["vcc"] in MASK and form["vcc"] != vcc:
|
||||
errors.append(
|
||||
f"{label}: vcc {form['vcc']} contradicts rule {form['operands']} "
|
||||
f"(requires {'lane_mask' if lane_mask else 'unchanged'})"
|
||||
f"(requires {vcc})"
|
||||
)
|
||||
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"]),
|
||||
@@ -822,7 +974,7 @@ def validate(registry, snapshot):
|
||||
errors.append(f"{label}: unknown {SOURCE_ORDER_KEY} {order!r}")
|
||||
elif _rule_kind(form) != "vector":
|
||||
errors.append(f"{label}: {SOURCE_ORDER_KEY} on a non-vector form")
|
||||
if form["operation"] in SCC_READERS and form["carry_in"] != "scc":
|
||||
if not reads_vcc and form["operation"] in SCC_READERS and form["carry_in"] != "scc":
|
||||
errors.append(f"{label}: operation {form['operation']} reads SCC (requires carry_in scc)")
|
||||
if form["operation"] == "sext":
|
||||
bits = form.get(SOURCE_BITS_KEY)
|
||||
@@ -848,7 +1000,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(
|
||||
@@ -862,12 +1014,20 @@ def validate(registry, snapshot):
|
||||
if form["carry_in"] != "none":
|
||||
errors.append(f"{label}: carry_in {form['carry_in']} contradicts compare")
|
||||
primitive = (scc, None, False)
|
||||
elif form["operation"] in CONTROL_OPERATIONS:
|
||||
variant, operand_rule, _ = CONTROL_OPERATIONS[form["operation"]]
|
||||
signedness = "signed" if operand_rule == "sopp_branch" else "bitwise"
|
||||
if (form["variant"], form["operands"], form["signedness"]) != (variant, operand_rule, signedness):
|
||||
errors.append(f"{label}: control operation requires {variant}, {operand_rule}, {signedness}")
|
||||
if RELATION_KEY in form or form["width"] != 32:
|
||||
errors.append(f"{label}: control operation requires width 32 and no relation")
|
||||
primitive = ("unchanged", None, form["operation"] == "branch_scc_zero")
|
||||
elif _rule_kind(form) in ("vector", "vector_unary", "vector_swap"):
|
||||
if RELATION_KEY in form:
|
||||
errors.append(f"{label}: {RELATION_KEY} on a non-compare operation")
|
||||
key = (form["operation"], form["signedness"])
|
||||
table = {
|
||||
"vector": VECTOR_PRIMITIVES,
|
||||
"vector": VCC_VECTOR_PRIMITIVES if reads_vcc else VECTOR_PRIMITIVES,
|
||||
"vector_unary": VECTOR_UNARY_PRIMITIVES,
|
||||
"vector_swap": {("swap", "bitwise"): "Swap"},
|
||||
}[_rule_kind(form)]
|
||||
@@ -905,6 +1065,7 @@ def validate(registry, snapshot):
|
||||
form["operation"] == "mov" and form["family"] == "SOP1"
|
||||
)
|
||||
else "vector" if _rule_kind(form) == "vector" and form["operation"] not in UNARY
|
||||
else "control" if form["operation"] in CONTROL_OPERATIONS
|
||||
else "immediate" if _rule_kind(form) == "immediate"
|
||||
else "alu"
|
||||
):
|
||||
@@ -939,9 +1100,10 @@ def variant_row(registry, variant, base=None):
|
||||
"""The base form re-encoded: its declaration with the variant's identity."""
|
||||
if base is None:
|
||||
base = next(form for form in registry["form"] if form.get("name") == variant["of"])
|
||||
_, vcc = OPERAND_RULES[variant["operands"]].get("vcc_transition", ("unchanged", "unchanged"))
|
||||
return dict(
|
||||
base, family=variant["family"], opcode=variant["opcode"], operands=variant["operands"],
|
||||
spec=variant["spec"], verify=variant["verify"],
|
||||
vcc=vcc, spec=variant["spec"], verify=variant["verify"],
|
||||
)
|
||||
|
||||
|
||||
@@ -1011,24 +1173,32 @@ def _check_variants(registry, rules, documents, snapshot, seen, errors):
|
||||
if FORM_KEYS - set(base):
|
||||
errors.append(f"{label}: not checked, its form {variant['of']} is incomplete")
|
||||
continue
|
||||
base_vcc, _ = implemented.get("vcc_transition", ("unchanged", "unchanged"))
|
||||
if base["vcc"] != base_vcc:
|
||||
errors.append(
|
||||
f"{label}: operand rule {variant['operands']} requires a base "
|
||||
f"destination contract of {base_vcc}, got {base['vcc']}"
|
||||
)
|
||||
# The same base row as the completeness check above (with duplicate
|
||||
# declarations, the dict keeps the last one).
|
||||
_check_xml(variant_row(registry, variant, base), rule, snapshot, errors)
|
||||
# Every explicit operand, destination included, has the base encoding's
|
||||
# data format, in the same order (VSRC1 of VOP2 is SRC1 of VOP3).
|
||||
# Explicit destinations and sources keep the base encoding's data format
|
||||
# in the same role. The implicit-to-explicit mask transition is checked
|
||||
# above and in _check_xml for each encoding.
|
||||
base_xml = snapshot["variants"].get((base["name"], _family_encoding(base["family"])))
|
||||
own_xml = snapshot["variants"].get((variant["of"], _family_encoding(variant["family"])))
|
||||
base_rule = rules.get(base.get("operands"))
|
||||
if base_xml and own_xml and _well_formed(base_rule) and _well_formed(rule):
|
||||
# Operands correspond by role, in rule order: the destination, then
|
||||
# each source (VSRC1 of VOP2 is SRC1 of VOP3).
|
||||
def roles(rule, record):
|
||||
def roles(rule, record, explicit_dst):
|
||||
by_field = {row[0]: row[1] for row in record["operands"] if row[0]}
|
||||
fields = ([rule["dst"]["field"]] if "dst" in rule else [])
|
||||
fields = [rule["dst"]["field"]] if explicit_dst else []
|
||||
fields += [src["field"] for src in rule.get("src", [])]
|
||||
return [(field, by_field.get(field)) for field in fields]
|
||||
|
||||
pairs = list(zip(roles(base_rule, base_xml), roles(rule, own_xml)))
|
||||
explicit_dst = "dst" in base_rule and "dst" in rule
|
||||
pairs = zip(roles(base_rule, base_xml, explicit_dst), roles(rule, own_xml, explicit_dst))
|
||||
for (base_field, base_format), (field, data_format) in pairs:
|
||||
if base_format != data_format:
|
||||
errors.append(
|
||||
@@ -1091,7 +1261,7 @@ def render(registry, snapshot):
|
||||
"use crate::primitive;",
|
||||
"use crate::semantics::{",
|
||||
" CarryIn, Document, Evidence, FormSemantics, MaskEffect, Operation, OperandRule, SccEffect,",
|
||||
" Signedness, SpecRef, VectorBinary, VectorUnary, Wave,",
|
||||
" Signedness, SpecRef, VectorBinary, VectorLowering, VectorUnary, VectorVcc, Wave,",
|
||||
"};",
|
||||
"use crate::CompareRelation;",
|
||||
"",
|
||||
@@ -1281,7 +1451,7 @@ def _render_enum(rule_name, forms, snapshot, positions):
|
||||
f"pub enum {enum} {{",
|
||||
]
|
||||
for form in forms:
|
||||
carry = " plus SCC" if form["carry_in"] == "scc" else ""
|
||||
carry = {"scc": " plus SCC", "vcc": " with VCC input"}.get(form["carry_in"], "")
|
||||
what = f"compare {form[RELATION_KEY]}" if RELATION_KEY in form else form["operation"]
|
||||
effect = f"VCC = {form['vcc']}" if form["vcc"] != "unchanged" else f"SCC = {form['scc']}"
|
||||
out += [
|
||||
@@ -1338,6 +1508,42 @@ def _render_enum(rule_name, forms, snapshot, positions):
|
||||
" }]",
|
||||
" }",
|
||||
]
|
||||
if kind == "control":
|
||||
out += [
|
||||
"",
|
||||
" /// Exact SIMM16 required by the fixture, or None for a displacement.",
|
||||
" pub const fn required_immediate(self) -> Option<u16> {",
|
||||
" match self {",
|
||||
]
|
||||
for form in forms:
|
||||
exact = OPERAND_RULES[form["operands"]]["shape"].get("immediate")
|
||||
value = "None" if exact is None else f"Some({exact:#x})"
|
||||
out.append(f" Self::{form['variant']} => {value},")
|
||||
out += [
|
||||
" }",
|
||||
" }",
|
||||
"",
|
||||
" /// Constructs the existing decoded instruction, resolving a target only for a branch.",
|
||||
" pub fn decode<E>(",
|
||||
" self,",
|
||||
" target: impl FnOnce() -> Result<usize, E>,",
|
||||
" ) -> Result<crate::Instruction, E> {",
|
||||
" Ok(match self {",
|
||||
]
|
||||
for form in forms:
|
||||
variant = form["variant"]
|
||||
fields = " { target: target()? }" if form["operands"] == "sopp_branch" else ""
|
||||
out.append(f" Self::{variant} => crate::Instruction::{variant}{fields},")
|
||||
out += [" })", " }", "}", "", "impl crate::Instruction {",
|
||||
" /// The registry operation corresponding to a decoded SOPP control.",
|
||||
f" pub const fn sopp_control(self) -> Option<{enum}> {{",
|
||||
" match self {"]
|
||||
for form in forms:
|
||||
variant = form["variant"]
|
||||
fields = " { .. }" if form["operands"] == "sopp_branch" else ""
|
||||
out.append(f" Self::{variant}{fields} => Some({enum}::{variant}),")
|
||||
out += [" _ => None,", " }", " }", "}"]
|
||||
return out
|
||||
if kind in ("vector_unary", "vector_swap"):
|
||||
out += [
|
||||
"",
|
||||
@@ -1505,14 +1711,16 @@ def _render_enum(rule_name, forms, snapshot, positions):
|
||||
" }",
|
||||
"",
|
||||
" /// The per-lane operation its MSL lowering uses.",
|
||||
" pub const fn lowering(self) -> VectorBinary {",
|
||||
" pub const fn lowering(self) -> VectorLowering {",
|
||||
" match self {",
|
||||
]
|
||||
out += [
|
||||
f" Self::{form['variant']} => "
|
||||
f"VectorBinary::{VECTOR_PRIMITIVES[(form['operation'], form['signedness'])]},"
|
||||
for form in forms
|
||||
]
|
||||
for form in forms:
|
||||
key = (form["operation"], form["signedness"])
|
||||
if form["operands"] == "vop2_vcc":
|
||||
lowering = f"Vcc(VectorVcc::{VCC_VECTOR_PRIMITIVES[key]})"
|
||||
else:
|
||||
lowering = f"Binary(VectorBinary::{VECTOR_PRIMITIVES[key]})"
|
||||
out.append(f" Self::{form['variant']} => VectorLowering::{lowering},")
|
||||
out += [
|
||||
" }",
|
||||
" }",
|
||||
@@ -1562,6 +1770,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.",
|
||||
@@ -1578,11 +1787,32 @@ 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"] in (16, 64) and relation not in VECTOR_ONLY_RELATIONS:
|
||||
symbol = {"lt": "<", "eq": "==", "le": "<=", "gt": ">", "lg": "!=", "ge": ">="}[relation]
|
||||
width = form["width"]
|
||||
if width == 64 and form["signedness"] == "unsigned":
|
||||
left, right = "src0", "src1"
|
||||
else:
|
||||
cast = f"{'i' if form['signedness'] == 'signed' else 'u'}{width}"
|
||||
left, right = f"(src0 as {cast})", f"(src1 as {cast})"
|
||||
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 += [
|
||||
|
||||
@@ -25,6 +25,7 @@ include = [
|
||||
"rdna2/vop2.toml",
|
||||
"rdna2/vopc.toml",
|
||||
"rdna2/vop3.toml",
|
||||
"rdna2/sopp.toml",
|
||||
]
|
||||
|
||||
# Named public documents that spec references point at.
|
||||
@@ -44,11 +45,12 @@ file = "amdgpu_isa_rdna2.xml"
|
||||
# variant Rust enum variant of the typed op
|
||||
# operation primitive (closed vocabulary in generate_semantics.py OPERATIONS)
|
||||
# signedness unsigned | signed | bitwise (bitwise iff a logical operation)
|
||||
# carry_in none | scc (scc for unsigned add/sub carry and the cselect condition)
|
||||
# carry_in none | scc | vcc (implicit scalar or per-lane condition or carry)
|
||||
# width operand and result width in bits
|
||||
# scc unchanged | carry_out | borrow | signed_overflow | nonzero | relation | selected_src0
|
||||
# vcc, exec unchanged (stated, not implied) | lane_mask (vcc of a Wave32 VOPC compare)
|
||||
# wave any | wave32 (wave32 for VOPC compares and VOP1 integer forms)
|
||||
# vcc, exec unchanged (stated, not implied) | lane_mask (Wave32 VOPC compare or VOP2 carry output)
|
||||
# VOP3A compare variant rows derive sdst_lane_mask from their operand rule.
|
||||
# wave any | wave32 (wave32 for VOPC compares, VOP1 integer forms and VCC-reading VOP2 forms)
|
||||
# operands a key of [operand_rules]
|
||||
# spec references; at least one guide section with a page
|
||||
# verify evidence required before the form counts as verified
|
||||
@@ -0,0 +1,123 @@
|
||||
# Existing gfx1030 compute controls, AMD RDNA 2 ISA guide §12.5.
|
||||
|
||||
[operand_rules.sopp_end]
|
||||
family = "SOPP"
|
||||
src = []
|
||||
max_literals = 0
|
||||
unsupported = []
|
||||
immediate = 0
|
||||
|
||||
[operand_rules.sopp_branch]
|
||||
family = "SOPP"
|
||||
src = [{ field = "SIMM16", class = "label" }]
|
||||
max_literals = 0
|
||||
unsupported = []
|
||||
|
||||
[operand_rules.sopp_wait]
|
||||
family = "SOPP"
|
||||
src = [{ field = "SIMM16", class = "waitcnt" }]
|
||||
max_literals = 0
|
||||
unsupported = []
|
||||
immediate = 0x3f70
|
||||
|
||||
[[form]]
|
||||
name = "S_ENDPGM"
|
||||
family = "SOPP"
|
||||
opcode = 1
|
||||
variant = "EndProgram"
|
||||
operation = "end_program"
|
||||
signedness = "bitwise"
|
||||
carry_in = "none"
|
||||
width = 32
|
||||
scc = "unchanged"
|
||||
vcc = "unchanged"
|
||||
exec = "unchanged"
|
||||
wave = "wave32"
|
||||
operands = "sopp_end"
|
||||
spec = [{ document = "guide", section = "12.5", page = 124 }, { document = "guide", section = "13.1.5", page = 245 }]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "S_BRANCH"
|
||||
family = "SOPP"
|
||||
opcode = 2
|
||||
variant = "Branch"
|
||||
operation = "branch"
|
||||
signedness = "signed"
|
||||
carry_in = "none"
|
||||
width = 32
|
||||
scc = "unchanged"
|
||||
vcc = "unchanged"
|
||||
exec = "unchanged"
|
||||
wave = "wave32"
|
||||
operands = "sopp_branch"
|
||||
spec = [{ document = "guide", section = "12.5", page = 124 }, { document = "guide", section = "13.1.5", page = 245 }]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "S_CBRANCH_SCC0"
|
||||
family = "SOPP"
|
||||
opcode = 4
|
||||
variant = "BranchSccZero"
|
||||
operation = "branch_scc_zero"
|
||||
signedness = "signed"
|
||||
carry_in = "scc"
|
||||
width = 32
|
||||
scc = "unchanged"
|
||||
vcc = "unchanged"
|
||||
exec = "unchanged"
|
||||
wave = "wave32"
|
||||
operands = "sopp_branch"
|
||||
spec = [{ document = "guide", section = "12.5", page = 124 }, { document = "guide", section = "13.1.5", page = 245 }]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "S_CBRANCH_VCCZ"
|
||||
family = "SOPP"
|
||||
opcode = 6
|
||||
variant = "BranchVccZero"
|
||||
operation = "branch_vcc_zero"
|
||||
signedness = "signed"
|
||||
carry_in = "none"
|
||||
width = 32
|
||||
scc = "unchanged"
|
||||
vcc = "unchanged"
|
||||
exec = "unchanged"
|
||||
wave = "wave32"
|
||||
operands = "sopp_branch"
|
||||
spec = [{ document = "guide", section = "12.5", page = 124 }, { document = "guide", section = "13.1.5", page = 245 }]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "S_CBRANCH_EXECZ"
|
||||
family = "SOPP"
|
||||
opcode = 8
|
||||
variant = "BranchExecZero"
|
||||
operation = "branch_exec_zero"
|
||||
signedness = "signed"
|
||||
carry_in = "none"
|
||||
width = 32
|
||||
scc = "unchanged"
|
||||
vcc = "unchanged"
|
||||
exec = "unchanged"
|
||||
wave = "wave32"
|
||||
operands = "sopp_branch"
|
||||
spec = [{ document = "guide", section = "12.5", page = 125 }, { document = "guide", section = "13.1.5", page = 245 }]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "S_WAITCNT"
|
||||
family = "SOPP"
|
||||
opcode = 12
|
||||
variant = "WaitLoad"
|
||||
operation = "wait_load"
|
||||
signedness = "bitwise"
|
||||
carry_in = "none"
|
||||
width = 32
|
||||
scc = "unchanged"
|
||||
vcc = "unchanged"
|
||||
exec = "unchanged"
|
||||
wave = "wave32"
|
||||
operands = "sopp_wait"
|
||||
spec = [{ document = "guide", section = "12.5", page = 125 }, { document = "guide", section = "13.1.5", page = 245 }]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
@@ -348,3 +348,85 @@ wave = "any"
|
||||
operands = "vop2_vgpr2"
|
||||
spec = [{ document = "guide", section = "12.7", page = 133 }]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[operand_rules.vop2_vcc]
|
||||
family = "VOP2"
|
||||
dst = { field = "VDST", class = "vgpr", min = 0, max = 255 }
|
||||
src = [
|
||||
{ field = "SRC0", class = "vector_source" },
|
||||
{ field = "VSRC1", class = "vgpr" },
|
||||
]
|
||||
# vector_source = VGPR, normal SGPR s0-s105, vcc_lo, inline integer -16..64, or a literal word.
|
||||
max_literals = 1
|
||||
unsupported = [
|
||||
"src_vcc_hi", "src_exec", "src_m0", "src_ttmp", "src_null", "src_float_inline", "src_special",
|
||||
]
|
||||
|
||||
[[form]]
|
||||
name = "V_CNDMASK_B32"
|
||||
family = "VOP2"
|
||||
opcode = 1
|
||||
variant = "CndmaskB32"
|
||||
operation = "cselect"
|
||||
signedness = "bitwise"
|
||||
carry_in = "vcc"
|
||||
width = 32
|
||||
scc = "unchanged"
|
||||
vcc = "unchanged"
|
||||
exec = "unchanged"
|
||||
wave = "wave32"
|
||||
operands = "vop2_vcc"
|
||||
spec = [{ document = "guide", section = "12.7", page = 131 }, { document = "guide", section = "3.9", page = 20 }]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "V_ADD_CO_CI_U32"
|
||||
family = "VOP2"
|
||||
opcode = 40
|
||||
variant = "AddCoCiU32"
|
||||
operation = "add"
|
||||
signedness = "unsigned"
|
||||
carry_in = "vcc"
|
||||
width = 32
|
||||
scc = "unchanged"
|
||||
vcc = "lane_mask"
|
||||
exec = "unchanged"
|
||||
wave = "wave32"
|
||||
operands = "vop2_vcc"
|
||||
spec = [{ document = "guide", section = "12.7", page = 134 }, { document = "guide", section = "3.9", page = 20 }]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "V_SUB_CO_CI_U32"
|
||||
family = "VOP2"
|
||||
opcode = 41
|
||||
variant = "SubCoCiU32"
|
||||
operation = "sub"
|
||||
signedness = "unsigned"
|
||||
carry_in = "vcc"
|
||||
width = 32
|
||||
scc = "unchanged"
|
||||
vcc = "lane_mask"
|
||||
exec = "unchanged"
|
||||
wave = "wave32"
|
||||
operands = "vop2_vcc"
|
||||
spec = [{ document = "guide", section = "12.7", page = 134 }, { document = "guide", section = "3.9", page = 20 }]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "V_SUBREV_CO_CI_U32"
|
||||
family = "VOP2"
|
||||
opcode = 42
|
||||
variant = "SubrevCoCiU32"
|
||||
operation = "sub"
|
||||
signedness = "unsigned"
|
||||
carry_in = "vcc"
|
||||
width = 32
|
||||
scc = "unchanged"
|
||||
vcc = "lane_mask"
|
||||
exec = "unchanged"
|
||||
wave = "wave32"
|
||||
operands = "vop2_vcc"
|
||||
source_order = "reversed"
|
||||
spec = [{ document = "guide", section = "12.7", page = 134 }, { document = "guide", section = "3.9", page = 20 }]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
@@ -1,6 +1,202 @@
|
||||
# VOP3 encodings of the gfx1030 semantic registry; included by ../rdna2.toml.
|
||||
# Data only; see the root file for the field meanings.
|
||||
|
||||
# ---- Wave32 VOPC compares in VOP3A (#215) ----
|
||||
|
||||
# VDST encodes the scalar lane-mask destination, including vcc_lo (selector 106).
|
||||
# The two sources are VGPRs. Modifiers are clear and SRC2 is inline zero.
|
||||
[operand_rules.vop3_cmp_vgpr2]
|
||||
family = "VOP3"
|
||||
dst = { field = "VDST", class = "sgpr", min = 0, max = 106 }
|
||||
src = [
|
||||
{ field = "SRC0", class = "vgpr" },
|
||||
{ field = "SRC1", class = "vgpr" },
|
||||
]
|
||||
max_literals = 0
|
||||
variant_only = true
|
||||
unsupported = [
|
||||
"dst_vcc_hi", "dst_exec", "dst_ttmp", "dst_m0", "dst_null",
|
||||
"src_sgpr", "src_vcc", "src_exec", "src_m0", "src_ttmp", "src_null", "src_inline",
|
||||
"src_float_inline", "src_special", "src_literal", "modifiers", "src2",
|
||||
]
|
||||
|
||||
# Opcodes come from the pinned XML's default ENC_VOP3 records.
|
||||
[[encoding_variant]]
|
||||
of = "V_CMP_LT_I32"
|
||||
family = "VOP3"
|
||||
opcode = 129
|
||||
operands = "vop3_cmp_vgpr2"
|
||||
spec = [
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
{ document = "guide", section = "13.3.4", page = 257 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[encoding_variant]]
|
||||
of = "V_CMP_EQ_I32"
|
||||
family = "VOP3"
|
||||
opcode = 130
|
||||
operands = "vop3_cmp_vgpr2"
|
||||
spec = [
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
{ document = "guide", section = "13.3.4", page = 257 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[encoding_variant]]
|
||||
of = "V_CMP_LE_I32"
|
||||
family = "VOP3"
|
||||
opcode = 131
|
||||
operands = "vop3_cmp_vgpr2"
|
||||
spec = [
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
{ document = "guide", section = "13.3.4", page = 257 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[encoding_variant]]
|
||||
of = "V_CMP_GT_I32"
|
||||
family = "VOP3"
|
||||
opcode = 132
|
||||
operands = "vop3_cmp_vgpr2"
|
||||
spec = [
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
{ document = "guide", section = "13.3.4", page = 257 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[encoding_variant]]
|
||||
of = "V_CMP_NE_I32"
|
||||
family = "VOP3"
|
||||
opcode = 133
|
||||
operands = "vop3_cmp_vgpr2"
|
||||
spec = [
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
{ document = "guide", section = "13.3.4", page = 257 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[encoding_variant]]
|
||||
of = "V_CMP_GE_I32"
|
||||
family = "VOP3"
|
||||
opcode = 134
|
||||
operands = "vop3_cmp_vgpr2"
|
||||
spec = [
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
{ document = "guide", section = "13.3.4", page = 257 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[encoding_variant]]
|
||||
of = "V_CMP_LT_U32"
|
||||
family = "VOP3"
|
||||
opcode = 193
|
||||
operands = "vop3_cmp_vgpr2"
|
||||
spec = [
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
{ document = "guide", section = "13.3.4", page = 257 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[encoding_variant]]
|
||||
of = "V_CMP_EQ_U32"
|
||||
family = "VOP3"
|
||||
opcode = 194
|
||||
operands = "vop3_cmp_vgpr2"
|
||||
spec = [
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
{ document = "guide", section = "13.3.4", page = 257 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[encoding_variant]]
|
||||
of = "V_CMP_LE_U32"
|
||||
family = "VOP3"
|
||||
opcode = 195
|
||||
operands = "vop3_cmp_vgpr2"
|
||||
spec = [
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
{ document = "guide", section = "13.3.4", page = 257 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[encoding_variant]]
|
||||
of = "V_CMP_GT_U32"
|
||||
family = "VOP3"
|
||||
opcode = 196
|
||||
operands = "vop3_cmp_vgpr2"
|
||||
spec = [
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
{ document = "guide", section = "13.3.4", page = 257 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[encoding_variant]]
|
||||
of = "V_CMP_NE_U32"
|
||||
family = "VOP3"
|
||||
opcode = 197
|
||||
operands = "vop3_cmp_vgpr2"
|
||||
spec = [
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
{ document = "guide", section = "13.3.4", page = 257 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[encoding_variant]]
|
||||
of = "V_CMP_GE_U32"
|
||||
family = "VOP3"
|
||||
opcode = 198
|
||||
operands = "vop3_cmp_vgpr2"
|
||||
spec = [
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
{ document = "guide", section = "13.3.4", page = 257 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[encoding_variant]]
|
||||
of = "V_CMP_F_I32"
|
||||
family = "VOP3"
|
||||
opcode = 128
|
||||
operands = "vop3_cmp_vgpr2"
|
||||
spec = [
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
{ document = "guide", section = "13.3.4", page = 257 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[encoding_variant]]
|
||||
of = "V_CMP_T_I32"
|
||||
family = "VOP3"
|
||||
opcode = 135
|
||||
operands = "vop3_cmp_vgpr2"
|
||||
spec = [
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
{ document = "guide", section = "13.3.4", page = 257 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[encoding_variant]]
|
||||
of = "V_CMP_F_U32"
|
||||
family = "VOP3"
|
||||
opcode = 192
|
||||
operands = "vop3_cmp_vgpr2"
|
||||
spec = [
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
{ document = "guide", section = "13.3.4", page = 257 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[encoding_variant]]
|
||||
of = "V_CMP_T_U32"
|
||||
family = "VOP3"
|
||||
opcode = 199
|
||||
operands = "vop3_cmp_vgpr2"
|
||||
spec = [
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
{ document = "guide", section = "13.3.4", page = 257 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
# ---- VOP3 encoding variants of registry forms (#215) ----
|
||||
# An [[encoding_variant]] re-encodes a form declared in another family file: it
|
||||
# names the form (`of`), this family, the XML opcode here and the operand rule
|
||||
@@ -37,3 +233,130 @@ spec = [
|
||||
{ document = "guide", section = "12.7", page = 134 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
# ABS and NEG apply to floating-point inputs (guide 6.2.1) and OMOD
|
||||
# applies to floating-point results (6.2.2). These integer forms use neither.
|
||||
# OP_SEL selects 16-bit halves (13.3.4). CLAMP saturates integer results
|
||||
# (6.5), which these registry forms do not declare. SGPR, inline and literal
|
||||
# sources remain outside this operand rule.
|
||||
|
||||
[[encoding_variant]]
|
||||
of = "V_MUL_I32_I24"
|
||||
family = "VOP3"
|
||||
opcode = 265
|
||||
operands = "vop3_vgpr2"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.12", page = 167 },
|
||||
{ document = "guide", section = "12.7", page = 131 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[encoding_variant]]
|
||||
of = "V_MUL_HI_I32_I24"
|
||||
family = "VOP3"
|
||||
opcode = 266
|
||||
operands = "vop3_vgpr2"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.12", page = 167 },
|
||||
{ document = "guide", section = "12.7", page = 132 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[encoding_variant]]
|
||||
of = "V_MUL_U32_U24"
|
||||
family = "VOP3"
|
||||
opcode = 267
|
||||
operands = "vop3_vgpr2"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.12", page = 167 },
|
||||
{ document = "guide", section = "12.7", page = 132 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[encoding_variant]]
|
||||
of = "V_MUL_HI_U32_U24"
|
||||
family = "VOP3"
|
||||
opcode = 268
|
||||
operands = "vop3_vgpr2"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.12", page = 167 },
|
||||
{ document = "guide", section = "12.7", page = 132 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[encoding_variant]]
|
||||
of = "V_MIN_I32"
|
||||
family = "VOP3"
|
||||
opcode = 273
|
||||
operands = "vop3_vgpr2"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.12", page = 167 },
|
||||
{ document = "guide", section = "12.7", page = 133 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[encoding_variant]]
|
||||
of = "V_MAX_I32"
|
||||
family = "VOP3"
|
||||
opcode = 274
|
||||
operands = "vop3_vgpr2"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.12", page = 167 },
|
||||
{ document = "guide", section = "12.7", page = 133 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[encoding_variant]]
|
||||
of = "V_MIN_U32"
|
||||
family = "VOP3"
|
||||
opcode = 275
|
||||
operands = "vop3_vgpr2"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.12", page = 167 },
|
||||
{ document = "guide", section = "12.7", page = 133 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[encoding_variant]]
|
||||
of = "V_MAX_U32"
|
||||
family = "VOP3"
|
||||
opcode = 276
|
||||
operands = "vop3_vgpr2"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.12", page = 167 },
|
||||
{ document = "guide", section = "12.7", page = 133 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[encoding_variant]]
|
||||
of = "V_XNOR_B32"
|
||||
family = "VOP3"
|
||||
opcode = 286
|
||||
operands = "vop3_vgpr2"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.12", page = 167 },
|
||||
{ document = "guide", section = "12.7", page = 134 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[encoding_variant]]
|
||||
of = "V_SUB_NC_U32"
|
||||
family = "VOP3"
|
||||
opcode = 294
|
||||
operands = "vop3_vgpr2"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.12", page = 167 },
|
||||
{ document = "guide", section = "12.7", page = 134 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[encoding_variant]]
|
||||
of = "V_SUBREV_NC_U32"
|
||||
family = "VOP3"
|
||||
opcode = 295
|
||||
operands = "vop3_vgpr2"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.12", page = 167 },
|
||||
{ document = "guide", section = "12.7", page = 134 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
@@ -358,3 +358,617 @@ 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"]
|
||||
|
||||
# Wave32 16-bit integer compares (guide 12.9, Tables 59 and 61).
|
||||
[operand_rules.vopc_vcc_half]
|
||||
family = "VOPC"
|
||||
src = [
|
||||
{ field = "SRC0", class = "vector_source" },
|
||||
{ field = "VSRC1", class = "vgpr" },
|
||||
]
|
||||
# Guide 6.2, 6.2.5 and 6.8: read the low half of each source.
|
||||
max_literals = 0
|
||||
unsupported = [
|
||||
"src_literal", "src_vcc_hi", "src_exec", "src_m0", "src_ttmp", "src_null", "src_float_inline", "src_special",
|
||||
]
|
||||
|
||||
[[form]]
|
||||
name = "V_CMP_LT_I16"
|
||||
family = "VOPC"
|
||||
opcode = 137
|
||||
variant = "CmpLtI16"
|
||||
operation = "compare"
|
||||
relation = "lt"
|
||||
signedness = "signed"
|
||||
carry_in = "none"
|
||||
width = 16
|
||||
scc = "unchanged"
|
||||
vcc = "lane_mask"
|
||||
exec = "unchanged"
|
||||
wave = "wave32"
|
||||
operands = "vopc_vcc_half"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.9", page = 150 },
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "V_CMP_EQ_I16"
|
||||
family = "VOPC"
|
||||
opcode = 138
|
||||
variant = "CmpEqI16"
|
||||
operation = "compare"
|
||||
relation = "eq"
|
||||
signedness = "signed"
|
||||
carry_in = "none"
|
||||
width = 16
|
||||
scc = "unchanged"
|
||||
vcc = "lane_mask"
|
||||
exec = "unchanged"
|
||||
wave = "wave32"
|
||||
operands = "vopc_vcc_half"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.9", page = 150 },
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "V_CMP_LE_I16"
|
||||
family = "VOPC"
|
||||
opcode = 139
|
||||
variant = "CmpLeI16"
|
||||
operation = "compare"
|
||||
relation = "le"
|
||||
signedness = "signed"
|
||||
carry_in = "none"
|
||||
width = 16
|
||||
scc = "unchanged"
|
||||
vcc = "lane_mask"
|
||||
exec = "unchanged"
|
||||
wave = "wave32"
|
||||
operands = "vopc_vcc_half"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.9", page = 150 },
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "V_CMP_GT_I16"
|
||||
family = "VOPC"
|
||||
opcode = 140
|
||||
variant = "CmpGtI16"
|
||||
operation = "compare"
|
||||
relation = "gt"
|
||||
signedness = "signed"
|
||||
carry_in = "none"
|
||||
width = 16
|
||||
scc = "unchanged"
|
||||
vcc = "lane_mask"
|
||||
exec = "unchanged"
|
||||
wave = "wave32"
|
||||
operands = "vopc_vcc_half"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.9", page = 150 },
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "V_CMP_NE_I16"
|
||||
family = "VOPC"
|
||||
opcode = 141
|
||||
variant = "CmpNeI16"
|
||||
operation = "compare"
|
||||
relation = "lg"
|
||||
signedness = "signed"
|
||||
carry_in = "none"
|
||||
width = 16
|
||||
scc = "unchanged"
|
||||
vcc = "lane_mask"
|
||||
exec = "unchanged"
|
||||
wave = "wave32"
|
||||
operands = "vopc_vcc_half"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.9", page = 150 },
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "V_CMP_GE_I16"
|
||||
family = "VOPC"
|
||||
opcode = 142
|
||||
variant = "CmpGeI16"
|
||||
operation = "compare"
|
||||
relation = "ge"
|
||||
signedness = "signed"
|
||||
carry_in = "none"
|
||||
width = 16
|
||||
scc = "unchanged"
|
||||
vcc = "lane_mask"
|
||||
exec = "unchanged"
|
||||
wave = "wave32"
|
||||
operands = "vopc_vcc_half"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.9", page = 150 },
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "V_CMP_LT_U16"
|
||||
family = "VOPC"
|
||||
opcode = 169
|
||||
variant = "CmpLtU16"
|
||||
operation = "compare"
|
||||
relation = "lt"
|
||||
signedness = "unsigned"
|
||||
carry_in = "none"
|
||||
width = 16
|
||||
scc = "unchanged"
|
||||
vcc = "lane_mask"
|
||||
exec = "unchanged"
|
||||
wave = "wave32"
|
||||
operands = "vopc_vcc_half"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.9", page = 150 },
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "V_CMP_EQ_U16"
|
||||
family = "VOPC"
|
||||
opcode = 170
|
||||
variant = "CmpEqU16"
|
||||
operation = "compare"
|
||||
relation = "eq"
|
||||
signedness = "unsigned"
|
||||
carry_in = "none"
|
||||
width = 16
|
||||
scc = "unchanged"
|
||||
vcc = "lane_mask"
|
||||
exec = "unchanged"
|
||||
wave = "wave32"
|
||||
operands = "vopc_vcc_half"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.9", page = 150 },
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "V_CMP_LE_U16"
|
||||
family = "VOPC"
|
||||
opcode = 171
|
||||
variant = "CmpLeU16"
|
||||
operation = "compare"
|
||||
relation = "le"
|
||||
signedness = "unsigned"
|
||||
carry_in = "none"
|
||||
width = 16
|
||||
scc = "unchanged"
|
||||
vcc = "lane_mask"
|
||||
exec = "unchanged"
|
||||
wave = "wave32"
|
||||
operands = "vopc_vcc_half"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.9", page = 150 },
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "V_CMP_GT_U16"
|
||||
family = "VOPC"
|
||||
opcode = 172
|
||||
variant = "CmpGtU16"
|
||||
operation = "compare"
|
||||
relation = "gt"
|
||||
signedness = "unsigned"
|
||||
carry_in = "none"
|
||||
width = 16
|
||||
scc = "unchanged"
|
||||
vcc = "lane_mask"
|
||||
exec = "unchanged"
|
||||
wave = "wave32"
|
||||
operands = "vopc_vcc_half"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.9", page = 150 },
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "V_CMP_NE_U16"
|
||||
family = "VOPC"
|
||||
opcode = 173
|
||||
variant = "CmpNeU16"
|
||||
operation = "compare"
|
||||
relation = "lg"
|
||||
signedness = "unsigned"
|
||||
carry_in = "none"
|
||||
width = 16
|
||||
scc = "unchanged"
|
||||
vcc = "lane_mask"
|
||||
exec = "unchanged"
|
||||
wave = "wave32"
|
||||
operands = "vopc_vcc_half"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.9", page = 150 },
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "V_CMP_GE_U16"
|
||||
family = "VOPC"
|
||||
opcode = 174
|
||||
variant = "CmpGeU16"
|
||||
operation = "compare"
|
||||
relation = "ge"
|
||||
signedness = "unsigned"
|
||||
carry_in = "none"
|
||||
width = 16
|
||||
scc = "unchanged"
|
||||
vcc = "lane_mask"
|
||||
exec = "unchanged"
|
||||
wave = "wave32"
|
||||
operands = "vopc_vcc_half"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.9", page = 150 },
|
||||
{ document = "guide", section = "3.9", page = 19 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
+55
-5
@@ -20,9 +20,22 @@ pub use rdna2::{
|
||||
};
|
||||
pub use semantics_gen::{
|
||||
ScalarAluOp, ScalarCompareOp, ScalarImmediateCompareOp, ScalarImmediateOp, ScalarUnaryOp,
|
||||
VectorAluOp, VectorAluVop3Op, VectorCompareOp, VectorSwapOp, VectorUnaryOp,
|
||||
SoppControlOp, VectorAluOp, VectorAluVop3Op, VectorCompareOp, VectorCompareVop3Op,
|
||||
VectorSwapOp, VectorUnaryOp,
|
||||
};
|
||||
|
||||
impl VectorAluOp {
|
||||
/// Whether this encoding takes a per-lane VCC_LO bit.
|
||||
pub fn reads_vcc(self) -> bool {
|
||||
self.semantics().carry_in == semantics::CarryIn::Vcc
|
||||
}
|
||||
|
||||
/// Whether this encoding replaces the Wave32 VCC_LO mask.
|
||||
pub fn writes_vcc(self) -> bool {
|
||||
self.semantics().vcc == semantics::MaskEffect::LaneMask
|
||||
}
|
||||
}
|
||||
|
||||
/// SGPR index of `vcc_lo`, the Wave32 vector condition code.
|
||||
pub const VCC_LO: u8 = 106;
|
||||
|
||||
@@ -207,13 +220,22 @@ 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,
|
||||
src1: u8,
|
||||
},
|
||||
/// VOP3A 32-bit integer compare writing a Wave32 mask to s0-s105 or `vcc_lo`.
|
||||
/// Both sources are VGPR indices.
|
||||
VectorCompareVop3 {
|
||||
op: VectorCompareVop3Op,
|
||||
sdst: u8,
|
||||
src0: u8,
|
||||
src1: u8,
|
||||
},
|
||||
/// VOP2 32-bit per-lane integer operation from the semantic registry.
|
||||
/// `src0` is a VGPR, `s0-s105`, `vcc_lo`, an inline integer or a literal;
|
||||
/// `src1` is a VGPR. Inactive lanes keep `dst`.
|
||||
@@ -296,6 +318,7 @@ impl Instruction {
|
||||
Self::ScalarImmediate { op, .. } => op.mnemonic(),
|
||||
Self::ScalarImmediateCompare { op, .. } => op.mnemonic(),
|
||||
Self::VectorCompare { op, .. } => op.assembly_name(),
|
||||
Self::VectorCompareVop3 { op, .. } => op.assembly_name(),
|
||||
Self::VectorAlu { op, .. } => op.assembly_name(),
|
||||
Self::BranchSccZero { .. } => "s_cbranch_scc0",
|
||||
Self::BranchExecZero { .. } => "s_cbranch_execz",
|
||||
@@ -364,13 +387,40 @@ 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}")
|
||||
}
|
||||
Self::VectorCompareVop3 {
|
||||
sdst, src0, src1, ..
|
||||
} => write!(formatter, " {}, v{src0}, v{src1}", ScalarDestination(sdst)),
|
||||
Self::VectorAlu {
|
||||
dst, src0, src1, ..
|
||||
op,
|
||||
dst,
|
||||
src0,
|
||||
src1,
|
||||
} => {
|
||||
write!(formatter, " v{dst}, {src0}, v{src1}")
|
||||
write!(formatter, " v{dst}, ")?;
|
||||
if op.writes_vcc() {
|
||||
write!(formatter, "vcc_lo, ")?;
|
||||
}
|
||||
write!(formatter, "{src0}, v{src1}")?;
|
||||
if op.reads_vcc() {
|
||||
write!(formatter, ", vcc_lo")?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
Self::Branch { target }
|
||||
| Self::BranchSccZero { target }
|
||||
|
||||
@@ -47,7 +47,7 @@ pub enum Operation {
|
||||
LogicalShiftRight,
|
||||
/// Shift S0 right by the masked count in S1, filling with its sign bit.
|
||||
ArithmeticShiftRight,
|
||||
/// Compare S0 with S1 under the form's relation; writes only SCC.
|
||||
/// Compare S0 with S1 under the form's relation, producing SCC or a lane mask.
|
||||
Compare,
|
||||
/// Bitwise complement of S0.
|
||||
Not,
|
||||
@@ -94,6 +94,18 @@ pub enum Operation {
|
||||
Move,
|
||||
/// SOPK: SDST receives the sign-extended SIMM16 when SCC is set.
|
||||
ConditionalMove,
|
||||
/// Terminate the program.
|
||||
EndProgram,
|
||||
/// Unconditional PC-relative branch.
|
||||
Branch,
|
||||
/// Branch when SCC is clear.
|
||||
BranchSccZero,
|
||||
/// Branch when VCC is zero.
|
||||
BranchVccZero,
|
||||
/// Branch when EXEC is zero.
|
||||
BranchExecZero,
|
||||
/// Complete an outstanding vector load.
|
||||
WaitLoad,
|
||||
/// Swap the two old per-lane VGPR values (guide 12.8).
|
||||
Swap,
|
||||
}
|
||||
@@ -165,13 +177,35 @@ pub enum Signedness {
|
||||
Bitwise,
|
||||
}
|
||||
|
||||
/// Whether the operation reads SCC.
|
||||
/// Per-lane VOP2 operation selected by the semantic registry.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum VectorLowering {
|
||||
/// Two explicit operands, with no implicit lane input.
|
||||
Binary(VectorBinary),
|
||||
/// Two explicit operands and the lane's VCC bit.
|
||||
Vcc(VectorVcc),
|
||||
}
|
||||
|
||||
/// VOP2 primitives with an implicit per-lane VCC input.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum VectorVcc {
|
||||
/// Choose S1 when the VCC bit is set, otherwise S0.
|
||||
Select,
|
||||
/// Unsigned addition with carry-in and carry-out.
|
||||
AddCarry,
|
||||
/// Unsigned subtraction with borrow-in and borrow-out.
|
||||
SubtractBorrow,
|
||||
}
|
||||
|
||||
/// Implicit condition or carry input.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum CarryIn {
|
||||
/// SCC is not read.
|
||||
/// No implicit condition or carry input.
|
||||
None,
|
||||
/// SCC as carry-in (add), borrow-in (sub) or the select condition (select).
|
||||
Scc,
|
||||
/// Per-lane Wave32 VCC_LO bit.
|
||||
Vcc,
|
||||
}
|
||||
|
||||
/// What a form writes to SCC.
|
||||
@@ -193,7 +227,7 @@ pub enum SccEffect {
|
||||
SelectedSrc0,
|
||||
}
|
||||
|
||||
/// What a form writes to VCC or EXEC.
|
||||
/// Where a form writes its lane mask, if any.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum MaskEffect {
|
||||
/// Not written.
|
||||
@@ -202,6 +236,8 @@ pub enum MaskEffect {
|
||||
/// exists) & test(lane n), fully written; `VCC_HI` has no known value after
|
||||
/// it (docs/shaders/vector-compare.md section 3).
|
||||
LaneMask,
|
||||
/// Wave32 VOP3A compare mask written to SDST, which may be `vcc_lo`.
|
||||
SdstLaneMask,
|
||||
}
|
||||
|
||||
/// Wave-size restriction.
|
||||
@@ -235,18 +271,34 @@ pub enum OperandRule {
|
||||
/// SOPK integer compare: SDST (s0-s105) is the left operand, SIMM16 the right
|
||||
/// (sign-extended for `_i32`, zero-extended for `_u32`); only SCC is written.
|
||||
SopkCompare,
|
||||
/// SOPP termination with zero in the reserved immediate field.
|
||||
SoppEnd,
|
||||
/// SOPP branch with a signed dword displacement from the next instruction.
|
||||
SoppBranch,
|
||||
/// SOPP wait with exactly vmcnt(0) and the other counters disabled.
|
||||
SoppWait,
|
||||
/// VOPC vector compare: the destination is `vcc_lo` (Wave32); SRC0 is a VGPR,
|
||||
/// 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,
|
||||
/// VOPC with low-half operands and no literal selector.
|
||||
VopcVccHalf,
|
||||
/// 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.
|
||||
Vop3Vgpr2,
|
||||
/// VOP3A compare: VDST encodes s0-s105 or `vcc_lo`; SRC0 and SRC1 are
|
||||
/// VGPRs, SRC2 is unused and all modifiers are clear.
|
||||
Vop3CmpVgpr2,
|
||||
/// VOP2 vector: VDST is v0-v255; SRC0 is a VGPR, s0-s105, `vcc_lo`, an inline
|
||||
/// integer -16..64 or a literal word; VSRC1 is a VGPR. Everything else is
|
||||
/// rejected as unsupported.
|
||||
Vop2Vgpr,
|
||||
/// VOP2 general SRC0 and VGPR VSRC1 with an implicit VCC_LO input.
|
||||
Vop2Vcc,
|
||||
/// VOP2 vector, VGPR sources only: VDST is v0-v255; SRC0 and VSRC1 are VGPRs.
|
||||
/// Everything else (SGPR, inline, literal SRC0) is rejected as unsupported.
|
||||
Vop2Vgpr2,
|
||||
@@ -318,7 +370,7 @@ pub struct FormSemantics {
|
||||
pub relation: Option<CompareRelation>,
|
||||
/// SCC write.
|
||||
pub scc: SccEffect,
|
||||
/// VCC write.
|
||||
/// Implicit VCC write or explicit scalar destination for a compare mask.
|
||||
pub vcc: MaskEffect,
|
||||
/// EXEC write.
|
||||
pub exec: MaskEffect,
|
||||
|
||||
+2287
-98
File diff suppressed because it is too large.
Load diff
@@ -2,11 +2,12 @@
|
||||
|
||||
use xenora_isa::meta::{EncodingFamily, FORMS as META_FORMS};
|
||||
use xenora_isa::semantics::{
|
||||
CarryIn, FORM_IDS, FORMS, GENERATED_SCHEMA, MaskEffect, SCHEMA, SccEffect, Signedness, Wave,
|
||||
CarryIn, FORM_IDS, FORMS, GENERATED_SCHEMA, MaskEffect, OperandRule, SCHEMA, SccEffect,
|
||||
Signedness, Wave,
|
||||
};
|
||||
use xenora_isa::{
|
||||
CompareRelation, ScalarAluOp, ScalarCompareOp, ScalarImmediateCompareOp, ScalarImmediateOp,
|
||||
ScalarUnaryOp, VectorAluOp, VectorAluVop3Op, VectorCompareOp,
|
||||
ScalarUnaryOp, VectorAluOp, VectorAluVop3Op, VectorCompareOp, VectorCompareVop3Op,
|
||||
};
|
||||
|
||||
#[test]
|
||||
@@ -168,7 +169,16 @@ 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 OPERANDS16: [u64; 6] = [
|
||||
0xaaaa_0000,
|
||||
0x5555_0001,
|
||||
0xdead_7fff,
|
||||
0x8000,
|
||||
0xfffe,
|
||||
0xffff,
|
||||
];
|
||||
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 +197,22 @@ 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 = match row.width {
|
||||
16 => OPERANDS16,
|
||||
64 => OPERANDS64,
|
||||
_ => OPERANDS32,
|
||||
};
|
||||
for src0 in operands {
|
||||
for src1 in operands {
|
||||
let ordering = if row.width == 16 {
|
||||
if op.signed() {
|
||||
(src0 as i16).cmp(&(src1 as i16))
|
||||
} else {
|
||||
(src0 as u16).cmp(&(src1 as u16))
|
||||
}
|
||||
} else 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 +228,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 +236,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 float compares must not be dispatched.
|
||||
dispatch_selects_exactly(EncodingFamily::Vopc, |word| {
|
||||
VectorCompareOp::from_word(word).map(|op| op.semantics().name)
|
||||
});
|
||||
@@ -239,8 +262,38 @@ fn vop3_variant_dispatch_selects_exactly_the_registry_vop3_rows() {
|
||||
assert_eq!(row.swap_sources, base.swap_sources);
|
||||
assert_eq!(op.assembly_name(), format!("{}_e64", op.base().mnemonic()));
|
||||
}
|
||||
for base_op in VectorCompareOp::ALL {
|
||||
let base = base_op.semantics();
|
||||
let mut variants = VectorCompareVop3Op::ALL
|
||||
.into_iter()
|
||||
.filter(|op| op.base() == base_op);
|
||||
if base.width != 32 {
|
||||
assert_eq!(variants.next(), None, "{}", base.name);
|
||||
continue;
|
||||
}
|
||||
let op = variants
|
||||
.next()
|
||||
.expect("32-bit VOPC form must have a VOP3A encoding");
|
||||
assert_eq!(variants.next(), None);
|
||||
let row = op.semantics();
|
||||
assert_eq!((row.name, row.family), (base.name, EncodingFamily::Vop3));
|
||||
assert_eq!(row.operation, base.operation);
|
||||
assert_eq!(row.signedness, base.signedness);
|
||||
assert_eq!(row.relation, base.relation);
|
||||
assert_eq!(row.scc, SccEffect::Unchanged);
|
||||
assert_eq!(row.exec, MaskEffect::Unchanged);
|
||||
assert_eq!(row.wave, Wave::Wave32);
|
||||
assert_eq!(row.width, 32);
|
||||
assert_eq!(row.vcc, MaskEffect::SdstLaneMask);
|
||||
assert_eq!(row.operands, OperandRule::Vop3CmpVgpr2);
|
||||
assert_eq!(op.assembly_name(), format!("{}_e64", base_op.mnemonic()));
|
||||
}
|
||||
dispatch_selects_exactly(EncodingFamily::Vop3, |word| {
|
||||
VectorAluVop3Op::from_word(word).map(|op| op.semantics().name)
|
||||
let alu = VectorAluVop3Op::from_word(word);
|
||||
let compare = VectorCompareVop3Op::from_word(word);
|
||||
assert!(alu.is_none() || compare.is_none(), "{word:#x}");
|
||||
alu.map(|op| op.semantics().name)
|
||||
.or_else(|| compare.map(|op| op.semantics().name))
|
||||
});
|
||||
// No first word of the other 64-bit families (VOP3B shares VOP3's
|
||||
// encoding bits) selects a variant.
|
||||
@@ -254,5 +307,11 @@ fn vop3_variant_dispatch_selects_exactly_the_registry_vop3_rows() {
|
||||
"{}",
|
||||
meta.name
|
||||
);
|
||||
assert_eq!(
|
||||
VectorCompareVop3Op::from_word(meta.bits as u32),
|
||||
None,
|
||||
"{}",
|
||||
meta.name
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ gpu-tests = []
|
||||
[dependencies]
|
||||
libc = "0.2"
|
||||
sha2 = "0.10"
|
||||
xenora-texture = { path = "../texture" }
|
||||
|
||||
[dev-dependencies]
|
||||
xenora-metal = { path = "../metal" }
|
||||
|
||||
@@ -40,6 +40,7 @@ SRCS = {"": 0, "b": 1, "w": 2, "d": 4, "q": 8, "x": 16}
|
||||
# encoding -> (Rust variant, has ModRM, required immediates)
|
||||
ENCS = {
|
||||
"none": ("None", False, {""}),
|
||||
"string": ("String", False, {""}),
|
||||
"rm_reg": ("RmReg", True, {""}),
|
||||
"reg_rm": ("RegRm", True, {""}),
|
||||
"reg_rm_imm": ("RegRmImm", True, {"ib", "iz"}),
|
||||
|
||||
@@ -97,6 +97,8 @@ pub struct CpuState {
|
||||
/// XMM0-XMM15, lane 0 in the low bits.
|
||||
pub xmm: [u128; 16],
|
||||
pub mxcsr: Mxcsr,
|
||||
/// Direction flag: string instructions step RSI and RDI down when set.
|
||||
pub df: bool,
|
||||
}
|
||||
|
||||
impl CpuState {
|
||||
@@ -111,6 +113,7 @@ impl CpuState {
|
||||
fs_base: 0,
|
||||
xmm: [0; 16],
|
||||
mxcsr: Mxcsr::default(),
|
||||
df: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1030
-2
File diff suppressed because it is too large.
Load diff
@@ -66,6 +66,8 @@ pub enum Entry {
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Encoding {
|
||||
None,
|
||||
/// A string instruction: source `[RSI]`, destination `[RDI]`, REP allowed.
|
||||
String,
|
||||
RmReg,
|
||||
RegRm,
|
||||
RegRmImm,
|
||||
@@ -172,6 +174,8 @@ pub struct Insn {
|
||||
/// Carries a LOCK prefix. Set only for a lockable form with a memory
|
||||
/// destination.
|
||||
pub lock: bool,
|
||||
/// A string instruction carrying a REP prefix.
|
||||
pub rep: bool,
|
||||
}
|
||||
|
||||
impl Insn {
|
||||
@@ -310,8 +314,12 @@ pub fn decode<E>(
|
||||
let opcode = if two_byte { cursor.u8()? } else { byte };
|
||||
let slot = usize::from(opcode);
|
||||
let table = if !two_byte {
|
||||
// Only PAUSE (F3 90) has a meaning here for F3 on a one-byte opcode.
|
||||
if repne || (rep && opcode != 0x90) {
|
||||
// On a one-byte opcode F3 is PAUSE (F3 90) or REP on a string form.
|
||||
let string = matches!(
|
||||
ONE_BYTE[slot],
|
||||
Entry::Form(index) if FORMS[usize::from(index)].encoding == Encoding::String
|
||||
);
|
||||
if repne || (rep && opcode != 0x90 && !string) {
|
||||
return Err(DecodeError::Unsupported(if rep { 0xF3 } else { 0xF2 }));
|
||||
}
|
||||
&ONE_BYTE
|
||||
@@ -424,6 +432,15 @@ pub fn decode<E>(
|
||||
}
|
||||
} else if matches!(form.encoding, Encoding::OpReg | Encoding::OpRegImm) {
|
||||
reg = register(opcode & 7, rex_b, size);
|
||||
} else if form.encoding == Encoding::String {
|
||||
// The source is DS:[RSI], which FS or GS may override. The destination
|
||||
// ES:[RDI] takes no override.
|
||||
rm = Some(RmOperand::Mem(MemOperand {
|
||||
base: Some(6),
|
||||
index: None,
|
||||
disp: 0,
|
||||
segment,
|
||||
}));
|
||||
}
|
||||
// LOCK is an invalid opcode unless the instruction is lockable and its
|
||||
// destination is memory (Intel SDM Vol. 2, "LOCK").
|
||||
@@ -467,6 +484,7 @@ pub fn decode<E>(
|
||||
imm,
|
||||
condition: opcode & 0xF,
|
||||
lock,
|
||||
rep: rep && form.encoding == Encoding::String,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ const RDX: usize = Register::Rdx as usize;
|
||||
const RBX: usize = Register::Rbx as usize;
|
||||
const RSP: usize = Register::Rsp as usize;
|
||||
const RBP: usize = Register::Rbp as usize;
|
||||
const RSI: usize = Register::Rsi as usize;
|
||||
const RDI: usize = Register::Rdi as usize;
|
||||
|
||||
/// Value mask of an operand of `size` bytes.
|
||||
fn mask(size: u8) -> u64 {
|
||||
@@ -582,6 +584,37 @@ pub fn execute(
|
||||
cpu.gpr[register] = u64::from(value);
|
||||
}
|
||||
}
|
||||
Op::Movs | Op::Stos => {
|
||||
// One element per execution. A REP form with elements left keeps
|
||||
// RIP on itself, so every element is a step of its own: it counts
|
||||
// against the step budget, and a fault keeps the elements already
|
||||
// done, with RSI, RDI and RCX at the element that faulted.
|
||||
if !(insn.rep && cpu.gpr[RCX] == 0) {
|
||||
let value = if insn.op == Op::Movs {
|
||||
read_rm(cpu, memory, insn)?
|
||||
} else {
|
||||
cpu.gpr[RAX] & mask(size)
|
||||
};
|
||||
write_mem(memory, cpu.gpr[RDI], size, value)?;
|
||||
let step = if cpu.df {
|
||||
u64::from(size).wrapping_neg()
|
||||
} else {
|
||||
u64::from(size)
|
||||
};
|
||||
if insn.op == Op::Movs {
|
||||
cpu.gpr[RSI] = cpu.gpr[RSI].wrapping_add(step);
|
||||
}
|
||||
cpu.gpr[RDI] = cpu.gpr[RDI].wrapping_add(step);
|
||||
if insn.rep {
|
||||
cpu.gpr[RCX] -= 1;
|
||||
if cpu.gpr[RCX] != 0 {
|
||||
next = insn.rip;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Op::Cld => cpu.df = false,
|
||||
Op::Std => cpu.df = true,
|
||||
Op::Clc => cpu.flags.cf = false,
|
||||
Op::Stc => cpu.flags.cf = true,
|
||||
Op::Cmc => cpu.flags.cf = !cpu.flags.cf,
|
||||
|
||||
+149
-107
@@ -67,6 +67,10 @@ pub enum Op {
|
||||
Stc,
|
||||
Cmc,
|
||||
Cpuid,
|
||||
Cld,
|
||||
Std,
|
||||
Movs,
|
||||
Stos,
|
||||
Movaps,
|
||||
Movups,
|
||||
Movdqa,
|
||||
@@ -205,7 +209,7 @@ pub enum Op {
|
||||
}
|
||||
|
||||
impl Op {
|
||||
pub const ALL: &[Op] = &[Op::Add, Op::Or, Op::Adc, Op::Sbb, Op::And, Op::Sub, Op::Xor, Op::Cmp, Op::Test, Op::Inc, Op::Dec, Op::Neg, Op::Not, Op::Mov, Op::Movzx, Op::Movsx, Op::Movsxd, Op::Lea, Op::Xchg, Op::Xadd, Op::Cmpxchg, Op::Bswap, Op::Cwde, Op::Cdq, Op::Rol, Op::Ror, Op::Shl, Op::Shr, Op::Sar, Op::Mul, Op::Imul, Op::Imul2, Op::Div, Op::Idiv, Op::Cmov, Op::Setcc, Op::Bt, Op::Bts, Op::Btr, Op::Btc, Op::Bsf, Op::Bsr, Op::Popcnt, Op::Tzcnt, Op::Lzcnt, Op::Push, Op::Pop, Op::Leave, Op::Call, Op::Jmp, Op::Jcc, Op::Ret, Op::Nop, Op::Hlt, Op::Syscall, Op::Clc, Op::Stc, Op::Cmc, Op::Cpuid, Op::Movaps, Op::Movups, Op::Movdqa, Op::Movdqu, Op::Movntdq, Op::Movntps, Op::Movss, Op::Movsd, Op::Movq, Op::Movd, Op::Movlps, Op::Movhps, Op::Movmskps, Op::Movmskpd, Op::Pmovmskb, Op::Pand, Op::Pandn, Op::Por, Op::Pxor, Op::Punpcklbw, Op::Punpcklwd, Op::Punpckldq, Op::Packsswb, Op::Pcmpgtb, Op::Pcmpgtw, Op::Pcmpgtd, Op::Packuswb, Op::Punpckhbw, Op::Punpckhwd, Op::Punpckhdq, Op::Packssdw, Op::Punpcklqdq, Op::Punpckhqdq, Op::Pcmpeqb, Op::Pcmpeqw, Op::Pcmpeqd, Op::Paddq, Op::Pmullw, Op::Psubusb, Op::Psubusw, Op::Pminub, Op::Paddusb, Op::Paddusw, Op::Pmaxub, Op::Pavgb, Op::Pavgw, Op::Pmulhuw, Op::Pmulhw, Op::Psubsb, Op::Psubsw, Op::Pminsw, Op::Paddsb, Op::Paddsw, Op::Pmaxsw, Op::Pmuludq, Op::Pmaddwd, Op::Psadbw, Op::Psubb, Op::Psubw, Op::Psubd, Op::Psubq, Op::Paddb, Op::Paddw, Op::Paddd, Op::Psrlw, Op::Psraw, Op::Psllw, Op::Psrld, Op::Psrad, Op::Pslld, Op::Psrlq, Op::Psllq, Op::Psrldq, Op::Pslldq, Op::Pshufd, Op::Pshufhw, Op::Pshuflw, Op::Shufps, Op::Shufpd, Op::Pinsrw, Op::Pextrw, Op::Ldmxcsr, Op::Stmxcsr, Op::Sqrtps, Op::Sqrtpd, Op::Sqrtss, Op::Sqrtsd, Op::Addps, Op::Addpd, Op::Addss, Op::Addsd, Op::Mulps, Op::Mulpd, Op::Mulss, Op::Mulsd, Op::Subps, Op::Subpd, Op::Subss, Op::Subsd, Op::Minps, Op::Minpd, Op::Minss, Op::Minsd, Op::Divps, Op::Divpd, Op::Divss, Op::Divsd, Op::Maxps, Op::Maxpd, Op::Maxss, Op::Maxsd, Op::Cmpps, Op::Cmppd, Op::Cmpss, Op::Cmpsd, Op::Ucomiss, Op::Comiss, Op::Ucomisd, Op::Comisd, Op::Cvtps2pd, Op::Cvtpd2ps, Op::Cvtss2sd, Op::Cvtsd2ss, Op::Cvtdq2ps, Op::Cvtps2dq, Op::Cvttps2dq, Op::Cvttpd2dq, Op::Cvtdq2pd, Op::Cvtpd2dq, Op::Cvtsi2ss, Op::Cvttss2si, Op::Cvtss2si, Op::Cvtsi2sd, Op::Cvttsd2si, Op::Cvtsd2si];
|
||||
pub const ALL: &[Op] = &[Op::Add, Op::Or, Op::Adc, Op::Sbb, Op::And, Op::Sub, Op::Xor, Op::Cmp, Op::Test, Op::Inc, Op::Dec, Op::Neg, Op::Not, Op::Mov, Op::Movzx, Op::Movsx, Op::Movsxd, Op::Lea, Op::Xchg, Op::Xadd, Op::Cmpxchg, Op::Bswap, Op::Cwde, Op::Cdq, Op::Rol, Op::Ror, Op::Shl, Op::Shr, Op::Sar, Op::Mul, Op::Imul, Op::Imul2, Op::Div, Op::Idiv, Op::Cmov, Op::Setcc, Op::Bt, Op::Bts, Op::Btr, Op::Btc, Op::Bsf, Op::Bsr, Op::Popcnt, Op::Tzcnt, Op::Lzcnt, Op::Push, Op::Pop, Op::Leave, Op::Call, Op::Jmp, Op::Jcc, Op::Ret, Op::Nop, Op::Hlt, Op::Syscall, Op::Clc, Op::Stc, Op::Cmc, Op::Cpuid, Op::Cld, Op::Std, Op::Movs, Op::Stos, Op::Movaps, Op::Movups, Op::Movdqa, Op::Movdqu, Op::Movntdq, Op::Movntps, Op::Movss, Op::Movsd, Op::Movq, Op::Movd, Op::Movlps, Op::Movhps, Op::Movmskps, Op::Movmskpd, Op::Pmovmskb, Op::Pand, Op::Pandn, Op::Por, Op::Pxor, Op::Punpcklbw, Op::Punpcklwd, Op::Punpckldq, Op::Packsswb, Op::Pcmpgtb, Op::Pcmpgtw, Op::Pcmpgtd, Op::Packuswb, Op::Punpckhbw, Op::Punpckhwd, Op::Punpckhdq, Op::Packssdw, Op::Punpcklqdq, Op::Punpckhqdq, Op::Pcmpeqb, Op::Pcmpeqw, Op::Pcmpeqd, Op::Paddq, Op::Pmullw, Op::Psubusb, Op::Psubusw, Op::Pminub, Op::Paddusb, Op::Paddusw, Op::Pmaxub, Op::Pavgb, Op::Pavgw, Op::Pmulhuw, Op::Pmulhw, Op::Psubsb, Op::Psubsw, Op::Pminsw, Op::Paddsb, Op::Paddsw, Op::Pmaxsw, Op::Pmuludq, Op::Pmaddwd, Op::Psadbw, Op::Psubb, Op::Psubw, Op::Psubd, Op::Psubq, Op::Paddb, Op::Paddw, Op::Paddd, Op::Psrlw, Op::Psraw, Op::Psllw, Op::Psrld, Op::Psrad, Op::Pslld, Op::Psrlq, Op::Psllq, Op::Psrldq, Op::Pslldq, Op::Pshufd, Op::Pshufhw, Op::Pshuflw, Op::Shufps, Op::Shufpd, Op::Pinsrw, Op::Pextrw, Op::Ldmxcsr, Op::Stmxcsr, Op::Sqrtps, Op::Sqrtpd, Op::Sqrtss, Op::Sqrtsd, Op::Addps, Op::Addpd, Op::Addss, Op::Addsd, Op::Mulps, Op::Mulpd, Op::Mulss, Op::Mulsd, Op::Subps, Op::Subpd, Op::Subss, Op::Subsd, Op::Minps, Op::Minpd, Op::Minss, Op::Minsd, Op::Divps, Op::Divpd, Op::Divss, Op::Divsd, Op::Maxps, Op::Maxpd, Op::Maxss, Op::Maxsd, Op::Cmpps, Op::Cmppd, Op::Cmpss, Op::Cmpsd, Op::Ucomiss, Op::Comiss, Op::Ucomisd, Op::Comisd, Op::Cvtps2pd, Op::Cvtpd2ps, Op::Cvtss2sd, Op::Cvtsd2ss, Op::Cvtdq2ps, Op::Cvtps2dq, Op::Cvttps2dq, Op::Cvttpd2dq, Op::Cvtdq2pd, Op::Cvtpd2dq, Op::Cvtsi2ss, Op::Cvttss2si, Op::Cvtss2si, Op::Cvtsi2sd, Op::Cvttsd2si, Op::Cvtsd2si];
|
||||
|
||||
/// Lower-case mnemonic stem.
|
||||
pub const fn name(self) -> &'static str {
|
||||
@@ -269,6 +273,10 @@ impl Op {
|
||||
Op::Stc => "stc",
|
||||
Op::Cmc => "cmc",
|
||||
Op::Cpuid => "cpuid",
|
||||
Op::Cld => "cld",
|
||||
Op::Std => "std",
|
||||
Op::Movs => "movs",
|
||||
Op::Stos => "stos",
|
||||
Op::Movaps => "movaps",
|
||||
Op::Movups => "movups",
|
||||
Op::Movdqa => "movdqa",
|
||||
@@ -469,6 +477,10 @@ impl Op {
|
||||
Op::Stc => 0,
|
||||
Op::Cmc => 1,
|
||||
Op::Cpuid => 0,
|
||||
Op::Cld => 0,
|
||||
Op::Std => 0,
|
||||
Op::Movs => 0,
|
||||
Op::Stos => 0,
|
||||
Op::Movaps => 0,
|
||||
Op::Movups => 0,
|
||||
Op::Movdqa => 0,
|
||||
@@ -669,6 +681,10 @@ impl Op {
|
||||
Op::Stc => 1,
|
||||
Op::Cmc => 1,
|
||||
Op::Cpuid => 0,
|
||||
Op::Cld => 0,
|
||||
Op::Std => 0,
|
||||
Op::Movs => 0,
|
||||
Op::Stos => 0,
|
||||
Op::Movaps => 0,
|
||||
Op::Movups => 0,
|
||||
Op::Movdqa => 0,
|
||||
@@ -869,6 +885,10 @@ impl Op {
|
||||
Op::Stc => 1,
|
||||
Op::Cmc => 1,
|
||||
Op::Cpuid => 0,
|
||||
Op::Cld => 0,
|
||||
Op::Std => 0,
|
||||
Op::Movs => 0,
|
||||
Op::Stos => 0,
|
||||
Op::Movaps => 0,
|
||||
Op::Movups => 0,
|
||||
Op::Movdqa => 0,
|
||||
@@ -1069,6 +1089,10 @@ impl Op {
|
||||
Op::Stc => 0,
|
||||
Op::Cmc => 0,
|
||||
Op::Cpuid => 0,
|
||||
Op::Cld => 0,
|
||||
Op::Std => 0,
|
||||
Op::Movs => 0,
|
||||
Op::Stos => 0,
|
||||
Op::Movaps => 0,
|
||||
Op::Movups => 0,
|
||||
Op::Movdqa => 0,
|
||||
@@ -1269,6 +1293,10 @@ impl Op {
|
||||
Op::Stc => false,
|
||||
Op::Cmc => false,
|
||||
Op::Cpuid => false,
|
||||
Op::Cld => false,
|
||||
Op::Std => false,
|
||||
Op::Movs => true,
|
||||
Op::Stos => true,
|
||||
Op::Movaps => false,
|
||||
Op::Movups => false,
|
||||
Op::Movdqa => false,
|
||||
@@ -1469,6 +1497,10 @@ impl Op {
|
||||
Op::Stc => false,
|
||||
Op::Cmc => false,
|
||||
Op::Cpuid => false,
|
||||
Op::Cld => false,
|
||||
Op::Std => false,
|
||||
Op::Movs => false,
|
||||
Op::Stos => false,
|
||||
Op::Movaps => false,
|
||||
Op::Movups => false,
|
||||
Op::Movdqa => false,
|
||||
@@ -1669,6 +1701,10 @@ impl Op {
|
||||
Op::Stc => false,
|
||||
Op::Cmc => false,
|
||||
Op::Cpuid => false,
|
||||
Op::Cld => false,
|
||||
Op::Std => false,
|
||||
Op::Movs => false,
|
||||
Op::Stos => false,
|
||||
Op::Movaps => true,
|
||||
Op::Movups => true,
|
||||
Op::Movdqa => true,
|
||||
@@ -1808,7 +1844,7 @@ impl Op {
|
||||
}
|
||||
}
|
||||
|
||||
pub static FORMS: [Form; 363] = [
|
||||
pub static FORMS: [Form; 369] = [
|
||||
Form { op: Op::Movsxd, encoding: Encoding::RegRm, size: OperandSize::Wide, immediate: Immediate::None, source: 4, has_modrm: true, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
|
||||
Form { op: Op::Push, encoding: Encoding::OpReg, size: OperandSize::Quad, immediate: Immediate::None, source: 0, has_modrm: false, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
|
||||
Form { op: Op::Pop, encoding: Encoding::OpReg, size: OperandSize::Quad, immediate: Immediate::None, source: 0, has_modrm: false, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
|
||||
@@ -1858,6 +1894,12 @@ pub static FORMS: [Form; 363] = [
|
||||
Form { op: Op::Stc, encoding: Encoding::None, size: OperandSize::None, immediate: Immediate::None, source: 0, has_modrm: false, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
|
||||
Form { op: Op::Syscall, encoding: Encoding::None, size: OperandSize::None, immediate: Immediate::None, source: 0, has_modrm: false, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
|
||||
Form { op: Op::Cpuid, encoding: Encoding::None, size: OperandSize::None, immediate: Immediate::None, source: 0, has_modrm: false, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
|
||||
Form { op: Op::Movs, encoding: Encoding::String, size: OperandSize::Byte, immediate: Immediate::None, source: 0, has_modrm: false, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
|
||||
Form { op: Op::Movs, encoding: Encoding::String, size: OperandSize::Variable, immediate: Immediate::None, source: 0, has_modrm: false, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
|
||||
Form { op: Op::Stos, encoding: Encoding::String, size: OperandSize::Byte, immediate: Immediate::None, source: 0, has_modrm: false, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
|
||||
Form { op: Op::Stos, encoding: Encoding::String, size: OperandSize::Variable, immediate: Immediate::None, source: 0, has_modrm: false, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
|
||||
Form { op: Op::Cld, encoding: Encoding::None, size: OperandSize::None, immediate: Immediate::None, source: 0, has_modrm: false, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
|
||||
Form { op: Op::Std, encoding: Encoding::None, size: OperandSize::None, immediate: Immediate::None, source: 0, has_modrm: false, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
|
||||
Form { op: Op::Movzx, encoding: Encoding::RegRm, size: OperandSize::Variable, immediate: Immediate::None, source: 1, has_modrm: true, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
|
||||
Form { op: Op::Movzx, encoding: Encoding::RegRm, size: OperandSize::Variable, immediate: Immediate::None, source: 2, has_modrm: true, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
|
||||
Form { op: Op::Movsx, encoding: Encoding::RegRm, size: OperandSize::Variable, immediate: Immediate::None, source: 1, has_modrm: true, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
|
||||
@@ -2176,47 +2218,47 @@ pub static FORMS: [Form; 363] = [
|
||||
|
||||
/// Form per ModRM digit; 65535 marks an unsupported digit.
|
||||
pub static GROUPS: [[u16; 8]; 22] = [
|
||||
[247, 256, 265, 274, 283, 292, 301, 310],
|
||||
[248, 257, 266, 275, 284, 293, 302, 311],
|
||||
[249, 258, 267, 276, 285, 294, 303, 312],
|
||||
[253, 262, 271, 280, 289, 298, 307, 316],
|
||||
[254, 263, 272, 281, 290, 299, 308, 317],
|
||||
[255, 264, 273, 282, 291, 300, 309, 318],
|
||||
[6, 65535, 65535, 65535, 65535, 65535, 65535, 65535],
|
||||
[333, 334, 65535, 65535, 335, 336, 65535, 337],
|
||||
[338, 339, 65535, 65535, 340, 341, 65535, 342],
|
||||
[339, 340, 65535, 65535, 341, 342, 65535, 343],
|
||||
[344, 345, 65535, 65535, 346, 347, 65535, 348],
|
||||
[33, 65535, 65535, 65535, 65535, 65535, 65535, 65535],
|
||||
[34, 65535, 65535, 65535, 65535, 65535, 65535, 65535],
|
||||
[343, 344, 65535, 65535, 345, 346, 65535, 347],
|
||||
[348, 349, 65535, 65535, 350, 351, 65535, 352],
|
||||
[353, 354, 65535, 65535, 355, 356, 65535, 357],
|
||||
[358, 359, 65535, 65535, 360, 361, 65535, 362],
|
||||
[18, 65535, 317, 318, 319, 320, 321, 322],
|
||||
[19, 65535, 323, 324, 325, 326, 327, 328],
|
||||
[329, 330, 65535, 65535, 65535, 65535, 65535, 65535],
|
||||
[331, 332, 41, 65535, 42, 65535, 5, 65535],
|
||||
[349, 350, 65535, 65535, 351, 352, 65535, 353],
|
||||
[354, 355, 65535, 65535, 356, 357, 65535, 358],
|
||||
[359, 360, 65535, 65535, 361, 362, 65535, 363],
|
||||
[364, 365, 65535, 65535, 366, 367, 65535, 368],
|
||||
[18, 65535, 323, 324, 325, 326, 327, 328],
|
||||
[19, 65535, 329, 330, 331, 332, 333, 334],
|
||||
[335, 336, 65535, 65535, 65535, 65535, 65535, 65535],
|
||||
[337, 338, 41, 65535, 42, 65535, 5, 65535],
|
||||
[28, 65535, 65535, 65535, 65535, 65535, 65535, 65535],
|
||||
[65535, 65535, 187, 188, 65535, 65535, 65535, 65535],
|
||||
[65535, 65535, 65535, 65535, 313, 314, 315, 316],
|
||||
[65535, 65535, 159, 65535, 161, 65535, 163, 65535],
|
||||
[65535, 65535, 193, 194, 65535, 65535, 65535, 65535],
|
||||
[65535, 65535, 65535, 65535, 319, 320, 321, 322],
|
||||
[65535, 65535, 165, 65535, 167, 65535, 169, 65535],
|
||||
[65535, 65535, 171, 174, 65535, 65535, 173, 175],
|
||||
[65535, 65535, 171, 65535, 173, 65535, 175, 65535],
|
||||
[65535, 65535, 177, 180, 65535, 65535, 179, 181],
|
||||
];
|
||||
|
||||
pub static ONE_BYTE: [Entry; 256] = [
|
||||
Entry::Form(241), Entry::Form(242), Entry::Form(243), Entry::Form(244),
|
||||
Entry::Form(245), Entry::Form(246), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(250), Entry::Form(251), Entry::Form(252), Entry::Form(253),
|
||||
Entry::Form(254), Entry::Form(255), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(259), Entry::Form(260), Entry::Form(261), Entry::Form(262),
|
||||
Entry::Form(263), Entry::Form(264), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(268), Entry::Form(269), Entry::Form(270), Entry::Form(271),
|
||||
Entry::Form(272), Entry::Form(273), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(277), Entry::Form(278), Entry::Form(279), Entry::Form(280),
|
||||
Entry::Form(281), Entry::Form(282), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(286), Entry::Form(287), Entry::Form(288), Entry::Form(289),
|
||||
Entry::Form(290), Entry::Form(291), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(295), Entry::Form(296), Entry::Form(297), Entry::Form(298),
|
||||
Entry::Form(299), Entry::Form(300), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(304), Entry::Form(305), Entry::Form(306), Entry::Form(307),
|
||||
Entry::Form(308), Entry::Form(309), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(247), Entry::Form(248), Entry::Form(249), Entry::Form(250),
|
||||
Entry::Form(251), Entry::Form(252), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(256), Entry::Form(257), Entry::Form(258), Entry::Form(259),
|
||||
Entry::Form(260), Entry::Form(261), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(265), Entry::Form(266), Entry::Form(267), Entry::Form(268),
|
||||
Entry::Form(269), Entry::Form(270), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(274), Entry::Form(275), Entry::Form(276), Entry::Form(277),
|
||||
Entry::Form(278), Entry::Form(279), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(283), Entry::Form(284), Entry::Form(285), Entry::Form(286),
|
||||
Entry::Form(287), Entry::Form(288), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(292), Entry::Form(293), Entry::Form(294), Entry::Form(295),
|
||||
Entry::Form(296), Entry::Form(297), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(301), Entry::Form(302), Entry::Form(303), Entry::Form(304),
|
||||
Entry::Form(305), Entry::Form(306), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(310), Entry::Form(311), Entry::Form(312), Entry::Form(313),
|
||||
Entry::Form(314), Entry::Form(315), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
@@ -2242,8 +2284,8 @@ pub static ONE_BYTE: [Entry; 256] = [
|
||||
Entry::Form(29), Entry::Form(30), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(16), Entry::Form(17), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(49), Entry::Form(50), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(16), Entry::Form(17), Entry::Form(51), Entry::Form(52),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(31), Entry::Form(31), Entry::Form(31), Entry::Form(31),
|
||||
Entry::Form(31), Entry::Form(31), Entry::Form(31), Entry::Form(31),
|
||||
@@ -2264,7 +2306,7 @@ pub static ONE_BYTE: [Entry; 256] = [
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(43), Entry::Form(44), Entry::Group(12), Entry::Group(13),
|
||||
Entry::Form(45), Entry::Form(46), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Group(14), Entry::Group(15),
|
||||
Entry::Form(53), Entry::Form(54), Entry::Group(14), Entry::Group(15),
|
||||
];
|
||||
|
||||
pub static TWO_BYTE: [Entry; 256] = [
|
||||
@@ -2272,14 +2314,14 @@ pub static TWO_BYTE: [Entry; 256] = [
|
||||
Entry::Unsupported, Entry::Form(47), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(71), Entry::Form(72), Entry::Form(90), Entry::Form(92),
|
||||
Entry::Form(181), Entry::Form(183), Entry::Form(94), Entry::Form(96),
|
||||
Entry::Form(77), Entry::Form(78), Entry::Form(96), Entry::Form(98),
|
||||
Entry::Form(187), Entry::Form(189), Entry::Form(100), Entry::Form(102),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Group(16),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(67), Entry::Form(68), Entry::Unsupported, Entry::Form(80),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(221), Entry::Form(222),
|
||||
Entry::Form(73), Entry::Form(74), Entry::Unsupported, Entry::Form(86),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(227), Entry::Form(228),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
@@ -2288,10 +2330,10 @@ pub static TWO_BYTE: [Entry; 256] = [
|
||||
Entry::Form(12), Entry::Form(12), Entry::Form(12), Entry::Form(12),
|
||||
Entry::Form(12), Entry::Form(12), Entry::Form(12), Entry::Form(12),
|
||||
Entry::Form(12), Entry::Form(12), Entry::Form(12), Entry::Form(12),
|
||||
Entry::Form(98), Entry::Form(189), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(102), Entry::Form(105), Entry::Form(108), Entry::Form(111),
|
||||
Entry::Form(193), Entry::Form(197), Entry::Form(225), Entry::Form(229),
|
||||
Entry::Form(201), Entry::Form(205), Entry::Form(209), Entry::Form(213),
|
||||
Entry::Form(104), Entry::Form(195), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(108), Entry::Form(111), Entry::Form(114), Entry::Form(117),
|
||||
Entry::Form(199), Entry::Form(203), Entry::Form(231), Entry::Form(235),
|
||||
Entry::Form(207), Entry::Form(211), Entry::Form(215), Entry::Form(219),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
@@ -2308,18 +2350,18 @@ pub static TWO_BYTE: [Entry; 256] = [
|
||||
Entry::Form(13), Entry::Form(13), Entry::Form(13), Entry::Form(13),
|
||||
Entry::Form(13), Entry::Form(13), Entry::Form(13), Entry::Form(13),
|
||||
Entry::Form(13), Entry::Form(13), Entry::Form(13), Entry::Form(13),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(48), Entry::Form(59),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(48), Entry::Form(65),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Form(60),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Form(66),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Group(17), Entry::Form(9),
|
||||
Entry::Form(63), Entry::Form(64), Entry::Unsupported, Entry::Form(61),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(49), Entry::Form(50),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Group(18), Entry::Form(62),
|
||||
Entry::Form(54), Entry::Form(55), Entry::Form(51), Entry::Form(52),
|
||||
Entry::Form(65), Entry::Form(66), Entry::Form(217), Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(179), Entry::Unsupported,
|
||||
Entry::Form(53), Entry::Form(53), Entry::Form(53), Entry::Form(53),
|
||||
Entry::Form(53), Entry::Form(53), Entry::Form(53), Entry::Form(53),
|
||||
Entry::Form(69), Entry::Form(70), Entry::Unsupported, Entry::Form(67),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(55), Entry::Form(56),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Group(18), Entry::Form(68),
|
||||
Entry::Form(60), Entry::Form(61), Entry::Form(57), Entry::Form(58),
|
||||
Entry::Form(71), Entry::Form(72), Entry::Form(223), Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(185), Entry::Unsupported,
|
||||
Entry::Form(59), Entry::Form(59), Entry::Form(59), Entry::Form(59),
|
||||
Entry::Form(59), Entry::Form(59), Entry::Form(59), Entry::Form(59),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
@@ -2339,14 +2381,14 @@ pub static TWO_BYTE_66: [Entry; 256] = [
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(73), Entry::Form(74), Entry::Form(91), Entry::Form(93),
|
||||
Entry::Form(182), Entry::Form(184), Entry::Form(95), Entry::Form(97),
|
||||
Entry::Form(79), Entry::Form(80), Entry::Form(97), Entry::Form(99),
|
||||
Entry::Form(188), Entry::Form(190), Entry::Form(101), Entry::Form(103),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(69), Entry::Form(70), Entry::Unsupported, Entry::Form(81),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(223), Entry::Form(224),
|
||||
Entry::Form(75), Entry::Form(76), Entry::Unsupported, Entry::Form(87),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(229), Entry::Form(230),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
@@ -2355,18 +2397,18 @@ pub static TWO_BYTE_66: [Entry; 256] = [
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(99), Entry::Form(190), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(103), Entry::Form(106), Entry::Form(109), Entry::Form(112),
|
||||
Entry::Form(194), Entry::Form(198), Entry::Form(226), Entry::Form(230),
|
||||
Entry::Form(202), Entry::Form(206), Entry::Form(210), Entry::Form(214),
|
||||
Entry::Form(113), Entry::Form(114), Entry::Form(115), Entry::Form(116),
|
||||
Entry::Form(117), Entry::Form(118), Entry::Form(119), Entry::Form(120),
|
||||
Entry::Form(121), Entry::Form(122), Entry::Form(123), Entry::Form(124),
|
||||
Entry::Form(125), Entry::Form(126), Entry::Form(88), Entry::Form(75),
|
||||
Entry::Form(176), Entry::Group(19), Entry::Group(20), Entry::Group(21),
|
||||
Entry::Form(127), Entry::Form(128), Entry::Form(129), Entry::Unsupported,
|
||||
Entry::Form(105), Entry::Form(196), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(109), Entry::Form(112), Entry::Form(115), Entry::Form(118),
|
||||
Entry::Form(200), Entry::Form(204), Entry::Form(232), Entry::Form(236),
|
||||
Entry::Form(208), Entry::Form(212), Entry::Form(216), Entry::Form(220),
|
||||
Entry::Form(119), Entry::Form(120), Entry::Form(121), Entry::Form(122),
|
||||
Entry::Form(123), Entry::Form(124), Entry::Form(125), Entry::Form(126),
|
||||
Entry::Form(127), Entry::Form(128), Entry::Form(129), Entry::Form(130),
|
||||
Entry::Form(131), Entry::Form(132), Entry::Form(94), Entry::Form(81),
|
||||
Entry::Form(182), Entry::Group(19), Entry::Group(20), Entry::Group(21),
|
||||
Entry::Form(133), Entry::Form(134), Entry::Form(135), Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(89), Entry::Form(76),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(95), Entry::Form(82),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
@@ -2383,22 +2425,22 @@ pub static TWO_BYTE_66: [Entry; 256] = [
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(218), Entry::Unsupported,
|
||||
Entry::Form(185), Entry::Form(186), Entry::Form(180), Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(224), Entry::Unsupported,
|
||||
Entry::Form(191), Entry::Form(192), Entry::Form(186), Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Form(158), Entry::Form(164), Entry::Form(170),
|
||||
Entry::Form(130), Entry::Form(131), Entry::Form(87), Entry::Form(100),
|
||||
Entry::Form(132), Entry::Form(133), Entry::Form(134), Entry::Form(101),
|
||||
Entry::Form(135), Entry::Form(136), Entry::Form(137), Entry::Form(104),
|
||||
Entry::Form(138), Entry::Form(160), Entry::Form(166), Entry::Form(139),
|
||||
Entry::Form(140), Entry::Form(141), Entry::Form(232), Entry::Form(79),
|
||||
Entry::Form(142), Entry::Form(143), Entry::Form(144), Entry::Form(107),
|
||||
Entry::Form(145), Entry::Form(146), Entry::Form(147), Entry::Form(110),
|
||||
Entry::Unsupported, Entry::Form(162), Entry::Form(168), Entry::Form(172),
|
||||
Entry::Form(148), Entry::Form(149), Entry::Form(150), Entry::Unsupported,
|
||||
Entry::Form(151), Entry::Form(152), Entry::Form(153), Entry::Form(154),
|
||||
Entry::Form(155), Entry::Form(156), Entry::Form(157), Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Form(164), Entry::Form(170), Entry::Form(176),
|
||||
Entry::Form(136), Entry::Form(137), Entry::Form(93), Entry::Form(106),
|
||||
Entry::Form(138), Entry::Form(139), Entry::Form(140), Entry::Form(107),
|
||||
Entry::Form(141), Entry::Form(142), Entry::Form(143), Entry::Form(110),
|
||||
Entry::Form(144), Entry::Form(166), Entry::Form(172), Entry::Form(145),
|
||||
Entry::Form(146), Entry::Form(147), Entry::Form(238), Entry::Form(85),
|
||||
Entry::Form(148), Entry::Form(149), Entry::Form(150), Entry::Form(113),
|
||||
Entry::Form(151), Entry::Form(152), Entry::Form(153), Entry::Form(116),
|
||||
Entry::Unsupported, Entry::Form(168), Entry::Form(174), Entry::Form(178),
|
||||
Entry::Form(154), Entry::Form(155), Entry::Form(156), Entry::Unsupported,
|
||||
Entry::Form(157), Entry::Form(158), Entry::Form(159), Entry::Form(160),
|
||||
Entry::Form(161), Entry::Form(162), Entry::Form(163), Entry::Unsupported,
|
||||
];
|
||||
|
||||
pub static TWO_BYTE_F3: [Entry; 256] = [
|
||||
@@ -2406,14 +2448,14 @@ pub static TWO_BYTE_F3: [Entry; 256] = [
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(82), Entry::Form(83), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(88), Entry::Form(89), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(235), Entry::Unsupported,
|
||||
Entry::Form(236), Entry::Form(237), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(241), Entry::Unsupported,
|
||||
Entry::Form(242), Entry::Form(243), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
@@ -2422,18 +2464,18 @@ pub static TWO_BYTE_F3: [Entry; 256] = [
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Form(191), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Form(197), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(195), Entry::Form(199), Entry::Form(227), Entry::Form(231),
|
||||
Entry::Form(203), Entry::Form(207), Entry::Form(211), Entry::Form(215),
|
||||
Entry::Form(201), Entry::Form(205), Entry::Form(233), Entry::Form(237),
|
||||
Entry::Form(209), Entry::Form(213), Entry::Form(217), Entry::Form(221),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Form(77),
|
||||
Entry::Form(177), Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Form(83),
|
||||
Entry::Form(183), Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(86), Entry::Form(78),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(92), Entry::Form(84),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
@@ -2448,9 +2490,9 @@ pub static TWO_BYTE_F3: [Entry; 256] = [
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(56), Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(57), Entry::Form(58), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(219), Entry::Unsupported,
|
||||
Entry::Form(62), Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(63), Entry::Form(64), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(225), Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
@@ -2459,7 +2501,7 @@ pub static TWO_BYTE_F3: [Entry; 256] = [
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(233), Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(239), Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
@@ -2473,14 +2515,14 @@ pub static TWO_BYTE_F2: [Entry; 256] = [
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(84), Entry::Form(85), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(90), Entry::Form(91), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(238), Entry::Unsupported,
|
||||
Entry::Form(239), Entry::Form(240), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(244), Entry::Unsupported,
|
||||
Entry::Form(245), Entry::Form(246), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
@@ -2489,15 +2531,15 @@ pub static TWO_BYTE_F2: [Entry; 256] = [
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Form(192), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Form(198), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(196), Entry::Form(200), Entry::Form(228), Entry::Unsupported,
|
||||
Entry::Form(204), Entry::Form(208), Entry::Form(212), Entry::Form(216),
|
||||
Entry::Form(202), Entry::Form(206), Entry::Form(234), Entry::Unsupported,
|
||||
Entry::Form(210), Entry::Form(214), Entry::Form(218), Entry::Form(222),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(178), Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(184), Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
@@ -2517,7 +2559,7 @@ pub static TWO_BYTE_F2: [Entry; 256] = [
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(220), Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(226), Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
@@ -2526,7 +2568,7 @@ pub static TWO_BYTE_F2: [Entry; 256] = [
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(234), Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(240), Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
|
||||
@@ -2666,7 +2666,7 @@ const UNSUPPORTED: &[(&str, usize)] = &[
|
||||
("bt_memory_register_offset_can_fault", 0),
|
||||
("btr16_memory_negative_16bit_offset", 0),
|
||||
("bts_memory_negative_offset", 0),
|
||||
("cmpsb_is_rsi_minus_rdi", 0),
|
||||
("cmpsb_is_rsi_minus_rdi", 1),
|
||||
("cmpxchg16b_equal", 0),
|
||||
("cmpxchg16b_equal_without_lock", 0),
|
||||
("cmpxchg16b_not_equal", 0),
|
||||
@@ -2681,8 +2681,6 @@ const UNSUPPORTED: &[(&str, usize)] = &[
|
||||
("enter_leave_round_trip", 0),
|
||||
("fifteen_byte_instruction_executes", 0),
|
||||
("fs_addr32_truncates_before_adding_base", 0),
|
||||
("fs_rep_movsb_overrides_source_only", 0),
|
||||
("fs_rep_movsb_overrides_source_only_df_clear", 0),
|
||||
("haddps_hsubpd_addsubps", 0),
|
||||
("insertps_zero_mask", 0),
|
||||
("jecxz_tests_low_32_bits", 1),
|
||||
@@ -2691,9 +2689,9 @@ const UNSUPPORTED: &[(&str, usize)] = &[
|
||||
("lahf_zero", 0),
|
||||
("lea64_addr32_truncates_effective_address", 0),
|
||||
("lock_btc_memory", 0),
|
||||
("lodsd_zero_extends", 0),
|
||||
("lodsd_zero_extends", 1),
|
||||
("lodsd_zero_extends_df_clear", 0),
|
||||
("lodsw_preserves_upper48", 0),
|
||||
("lodsw_preserves_upper48", 1),
|
||||
("loop_decrements_rcx_without_flags", 1),
|
||||
("loopne_stops_on_zero_flag", 1),
|
||||
("maskmovdqu_selects_bytes", 0),
|
||||
@@ -2701,7 +2699,6 @@ const UNSUPPORTED: &[(&str, usize)] = &[
|
||||
("mov_moffs8_store", 0),
|
||||
("movddup_movsldup_movshdup", 0),
|
||||
("movdqa_movaps_aligned_store_and_load", 3),
|
||||
("movsb_forward", 0),
|
||||
("mpsadbw", 0),
|
||||
("pabs_min_is_unchanged", 0),
|
||||
("packusdw", 0),
|
||||
@@ -2739,27 +2736,16 @@ const UNSUPPORTED: &[(&str, usize)] = &[
|
||||
("rcr8_by10_is_by_one_mod_9", 0),
|
||||
("rcr8_by1_clear_carry_in", 0),
|
||||
("rcr8_by1_set_carry_in", 0),
|
||||
("rep_lodsb_source_fault", 0),
|
||||
("rep_movs_zero_count_touches_nothing", 0),
|
||||
("rep_movsb_addr32_uses_32bit_registers", 0),
|
||||
("rep_movsb_fault_df_clear", 0),
|
||||
("rep_movsb_fault_stops_at_failing_iteration", 0),
|
||||
("rep_movsb_overlap_propagates_df_clear", 0),
|
||||
("rep_movsq_overlap_propagates", 0),
|
||||
("rep_movsq_zero_count_df_clear", 0),
|
||||
("rep_movsw_backward", 0),
|
||||
("rep_stosd_df_clear", 0),
|
||||
("rep_stosd_forward", 0),
|
||||
("rep_stosq_fault_df_clear", 0),
|
||||
("rep_stosq_fault_stops_at_failing_iteration", 0),
|
||||
("repe_cmpsb_fault_restores_flags", 0),
|
||||
("rep_lodsb_source_fault", 1),
|
||||
("rep_movsb_addr32_uses_32bit_registers", 1),
|
||||
("repe_cmpsb_fault_restores_flags", 1),
|
||||
("repe_cmpsb_fault_restores_flags_df_clear", 0),
|
||||
("repe_cmpsb_stops_at_difference", 0),
|
||||
("repe_cmpsb_stops_at_difference", 1),
|
||||
("repe_cmpsb_stops_at_difference_df_clear", 0),
|
||||
("repe_cmpsb_zero_count_keeps_flags", 0),
|
||||
("repne_scasb_finds_byte", 0),
|
||||
("repe_cmpsb_zero_count_keeps_flags", 1),
|
||||
("repne_scasb_finds_byte", 1),
|
||||
("repne_scasb_finds_byte_df_clear", 0),
|
||||
("repne_scasd_exhausts_count", 0),
|
||||
("repne_scasd_exhausts_count", 1),
|
||||
("rex_not_adjacent_to_opcode_is_ignored", 0),
|
||||
("roundps_uses_mxcsr_rc", 0),
|
||||
("roundsd_suppress_precision", 0),
|
||||
@@ -3613,6 +3599,7 @@ fn dbt_route_of_every_case_is_recorded() {
|
||||
let memory = start.image.load(&case.code);
|
||||
let text: Vec<&str> = case.asm.split(';').map(str::trim).collect();
|
||||
let mut routes = Vec::new();
|
||||
let mut repeats = false;
|
||||
for (index, &offset) in case.offsets.iter().enumerate() {
|
||||
let Ok(insn) = decode(CODE + offset as u64, |at| memory.fetch_instruction_byte(at))
|
||||
else {
|
||||
@@ -3620,6 +3607,7 @@ fn dbt_route_of_every_case_is_recorded() {
|
||||
};
|
||||
let name = text.get(index).copied().unwrap_or(case.asm);
|
||||
routes.push(is_native(&insn));
|
||||
repeats |= insn.rep;
|
||||
if is_native(&insn) {
|
||||
native.insert(name);
|
||||
} else {
|
||||
@@ -3634,13 +3622,13 @@ fn dbt_route_of_every_case_is_recorded() {
|
||||
};
|
||||
counts.entry(group).or_default()[kind] += 1;
|
||||
// Straight-line cases run each instruction once, so the counter must equal
|
||||
// the number of helper instructions.
|
||||
// the number of helper instructions. A REP form runs once per element.
|
||||
let labelled = text.iter().any(|piece| {
|
||||
piece
|
||||
.split_once(':')
|
||||
.is_some_and(|(label, _)| label.parse::<u8>().is_ok())
|
||||
});
|
||||
if !labelled && case.fault.is_empty() && routes.len() == case.offsets.len() {
|
||||
if !labelled && !repeats && case.fault.is_empty() && routes.len() == case.offsets.len() {
|
||||
let mut dbt = new_dbt();
|
||||
let mut memory = memory.clone();
|
||||
run_dbt(&mut dbt, &start.cpu, &mut memory, BUDGET);
|
||||
|
||||
@@ -0,0 +1,500 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
//! MOVS, STOS, REP and the direction flag (issue #129).
|
||||
//!
|
||||
//! Expected results come from a byte-array model written from the operation
|
||||
//! sections of the Intel SDM Vol. 2 for MOVS, STOS, REP, CLD and STD. The
|
||||
//! model never decodes or calls the production semantics. Encodings were
|
||||
//! assembled with `clang -target x86_64-apple-macos` and read with `objdump`.
|
||||
//! Nothing was compared with x86 hardware.
|
||||
//!
|
||||
//! A REP form runs one element per step and stays on the instruction until RCX
|
||||
//! is zero. The tests check that rule through the step counts, so a repeat can
|
||||
//! never outrun the step budget.
|
||||
|
||||
use std::collections::BTreeSet;
|
||||
use xenora_loader::cpu::{CpuState, ExecutionResult, ExitReason, Interpreter, RFlags};
|
||||
use xenora_loader::dbt::{DbtEngine, is_native};
|
||||
use xenora_loader::memory::{GuestMemory, MemoryPermissions};
|
||||
use xenora_loader::x86_decode::decode;
|
||||
use xenora_loader::x86_table::{FORMS, Op};
|
||||
|
||||
const ENTRY: u64 = 0x1000;
|
||||
/// One writable page with nothing mapped on either side.
|
||||
const DATA: u64 = 0x8000;
|
||||
const PAGE: usize = 0x1000;
|
||||
const END: u64 = DATA + PAGE as u64;
|
||||
|
||||
const RAX: usize = 0;
|
||||
const RCX: usize = 1;
|
||||
const RSI: usize = 6;
|
||||
const RDI: usize = 7;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
enum Kind {
|
||||
Movs,
|
||||
Stos,
|
||||
}
|
||||
|
||||
/// `[rep] movs/stos` for an element of `size` bytes, in the assembler's order.
|
||||
fn encode(kind: Kind, size: u64, rep: bool) -> Vec<u8> {
|
||||
let mut code = Vec::new();
|
||||
if rep {
|
||||
code.push(0xF3);
|
||||
}
|
||||
match size {
|
||||
2 => code.push(0x66),
|
||||
8 => code.push(0x48),
|
||||
_ => {}
|
||||
}
|
||||
code.push(match (kind, size) {
|
||||
(Kind::Movs, 1) => 0xA4,
|
||||
(Kind::Movs, _) => 0xA5,
|
||||
(Kind::Stos, 1) => 0xAA,
|
||||
(Kind::Stos, _) => 0xAB,
|
||||
});
|
||||
code
|
||||
}
|
||||
|
||||
fn image(code: &[u8], data: &[u8]) -> GuestMemory {
|
||||
let mut memory = GuestMemory::new();
|
||||
memory
|
||||
.map_region_with_data(ENTRY, code.len(), MemoryPermissions::READ_EXECUTE, code)
|
||||
.unwrap();
|
||||
memory
|
||||
.map_region_with_data(DATA, PAGE, MemoryPermissions::READ_WRITE, data)
|
||||
.unwrap();
|
||||
memory
|
||||
}
|
||||
|
||||
fn bytes(memory: &GuestMemory) -> Vec<u8> {
|
||||
let mut out = vec![0; PAGE];
|
||||
memory.read_bytes(DATA, &mut out).unwrap();
|
||||
out
|
||||
}
|
||||
|
||||
struct Run {
|
||||
name: &'static str,
|
||||
result: ExecutionResult,
|
||||
memory: GuestMemory,
|
||||
/// Instructions the DBT ran on the shared semantics.
|
||||
helpers: usize,
|
||||
}
|
||||
|
||||
/// The interpreter and the DBT, each from its own copy of the state.
|
||||
fn both(cpu: &CpuState, memory: &GuestMemory, budget: usize) -> [Run; 2] {
|
||||
let mut interpreted = memory.clone();
|
||||
let result = Interpreter::new(cpu.clone(), &mut interpreted, budget).run();
|
||||
let mut translated = memory.clone();
|
||||
let mut engine = DbtEngine::new(64 * 1024).unwrap();
|
||||
let mut state = cpu.clone();
|
||||
let native = engine.run(&mut state, &mut translated, budget);
|
||||
[
|
||||
Run {
|
||||
name: "interpreter",
|
||||
result,
|
||||
memory: interpreted,
|
||||
helpers: 0,
|
||||
},
|
||||
Run {
|
||||
name: "DBT",
|
||||
result: native,
|
||||
memory: translated,
|
||||
helpers: engine.metrics.interpreter_fallbacks,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
/// Deterministic generator (xorshift64*).
|
||||
struct Random(u64);
|
||||
|
||||
impl Random {
|
||||
fn next(&mut self) -> u64 {
|
||||
self.0 ^= self.0 >> 12;
|
||||
self.0 ^= self.0 << 25;
|
||||
self.0 ^= self.0 >> 27;
|
||||
self.0.wrapping_mul(0x2545_F491_4F6C_DD1D)
|
||||
}
|
||||
}
|
||||
|
||||
/// The architectural effect of `count` elements on a byte array: each element
|
||||
/// is read whole, then written, then the pointers move by its size.
|
||||
fn model(
|
||||
kind: Kind,
|
||||
size: u64,
|
||||
backward: bool,
|
||||
count: u64,
|
||||
data: &mut [u8],
|
||||
rax: u64,
|
||||
(mut rsi, mut rdi): (u64, u64),
|
||||
) -> (u64, u64) {
|
||||
let size_bytes = size as usize;
|
||||
for _ in 0..count {
|
||||
let element: Vec<u8> = match kind {
|
||||
Kind::Movs => {
|
||||
let from = (rsi - DATA) as usize;
|
||||
data[from..from + size_bytes].to_vec()
|
||||
}
|
||||
Kind::Stos => rax.to_le_bytes()[..size_bytes].to_vec(),
|
||||
};
|
||||
let to = (rdi - DATA) as usize;
|
||||
data[to..to + size_bytes].copy_from_slice(&element);
|
||||
if kind == Kind::Movs {
|
||||
rsi = if backward { rsi - size } else { rsi + size };
|
||||
}
|
||||
rdi = if backward { rdi - size } else { rdi + size };
|
||||
}
|
||||
(rsi, rdi)
|
||||
}
|
||||
|
||||
const FLAGS: RFlags = RFlags {
|
||||
cf: true,
|
||||
zf: false,
|
||||
sf: true,
|
||||
of: false,
|
||||
pf: true,
|
||||
af: false,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn every_form_matches_a_byte_array_model_and_counts_one_step_per_element() {
|
||||
let mut random = Random(0x1234_5678_9ABC_DEF1);
|
||||
for kind in [Kind::Movs, Kind::Stos] {
|
||||
for size in [1, 2, 4, 8] {
|
||||
for rep in [false, true] {
|
||||
for backward in [false, true] {
|
||||
for round in 0..40 {
|
||||
// Counts 0 to 9. Source and destination start within 24
|
||||
// bytes of each other, so the ranges often overlap.
|
||||
let count = round % 10;
|
||||
let rsi = DATA + 0x400 + random.next() % 0x100;
|
||||
let rdi = rsi + random.next() % 49 - 24;
|
||||
let rax = random.next();
|
||||
let data: Vec<u8> = (0..PAGE).map(|_| random.next() as u8).collect();
|
||||
|
||||
let mut code = encode(kind, size, rep);
|
||||
code.push(0xF4); // hlt
|
||||
let memory = image(&code, &data);
|
||||
let mut cpu = CpuState::new(ENTRY, 0);
|
||||
for register in &mut cpu.gpr {
|
||||
*register = random.next();
|
||||
}
|
||||
cpu.gpr[RAX] = rax;
|
||||
cpu.gpr[RCX] = count;
|
||||
cpu.gpr[RSI] = rsi;
|
||||
cpu.gpr[RDI] = rdi;
|
||||
cpu.df = backward;
|
||||
cpu.flags = FLAGS;
|
||||
|
||||
// Without REP exactly one element moves and RCX is not
|
||||
// read or written.
|
||||
let elements = if rep { count } else { 1 };
|
||||
let mut wanted_data = data.clone();
|
||||
let (wanted_rsi, wanted_rdi) = model(
|
||||
kind,
|
||||
size,
|
||||
backward,
|
||||
elements,
|
||||
&mut wanted_data,
|
||||
rax,
|
||||
(rsi, rdi),
|
||||
);
|
||||
let mut wanted = cpu.clone();
|
||||
wanted.rip = ENTRY + code.len() as u64;
|
||||
wanted.gpr[RSI] = wanted_rsi;
|
||||
wanted.gpr[RDI] = wanted_rdi;
|
||||
if rep {
|
||||
wanted.gpr[RCX] = 0;
|
||||
}
|
||||
// One step per element, one for a REP with a zero
|
||||
// count, and one for the HLT.
|
||||
let steps = elements.max(1) as usize + 1;
|
||||
|
||||
for run in both(&cpu, &memory, 64) {
|
||||
let what = format!(
|
||||
"{kind:?} size {size} rep={rep} backward={backward} count={count} \
|
||||
on the {}",
|
||||
run.name
|
||||
);
|
||||
assert_eq!(run.result.exit_reason, ExitReason::Halt, "{what}");
|
||||
assert_eq!(run.result.final_state, wanted, "{what}");
|
||||
assert!(bytes(&run.memory) == wanted_data, "{what}: memory");
|
||||
assert_eq!(run.result.instructions_executed, steps, "{what}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn step_budget_stops_a_repeat_part_way_and_it_resumes() {
|
||||
// rep stosb; hlt
|
||||
let code = [0xF3, 0xAA, 0xF4];
|
||||
let memory = image(&code, &[0; PAGE]);
|
||||
let mut cpu = CpuState::new(ENTRY, 0);
|
||||
cpu.gpr[RAX] = 0x5A;
|
||||
cpu.gpr[RCX] = 100;
|
||||
cpu.gpr[RDI] = DATA + 0x200;
|
||||
for run in both(&cpu, &memory, 10) {
|
||||
// Ten steps store ten bytes and leave RIP on the instruction.
|
||||
assert_eq!(
|
||||
run.result.exit_reason,
|
||||
ExitReason::StepLimitExceeded,
|
||||
"{}",
|
||||
run.name
|
||||
);
|
||||
assert_eq!(run.result.instructions_executed, 10, "{}", run.name);
|
||||
let state = &run.result.final_state;
|
||||
assert_eq!(
|
||||
(state.rip, state.gpr[RCX], state.gpr[RDI]),
|
||||
(ENTRY, 90, DATA + 0x20A),
|
||||
"{}",
|
||||
run.name
|
||||
);
|
||||
let written = bytes(&run.memory);
|
||||
assert_eq!(written[0x200..0x20A], [0x5A; 10], "{}", run.name);
|
||||
assert_eq!(written[0x20A..0x264], [0; 90], "{}", run.name);
|
||||
if run.name == "DBT" {
|
||||
assert_eq!(run.helpers, 10);
|
||||
}
|
||||
|
||||
// Resuming from that state finishes the remaining ninety and halts.
|
||||
let [rest, _] = both(state, &run.memory, 1000);
|
||||
assert_eq!(rest.result.exit_reason, ExitReason::Halt, "{}", run.name);
|
||||
assert_eq!(rest.result.instructions_executed, 91, "{}", run.name);
|
||||
assert_eq!(rest.result.final_state.gpr[RCX], 0, "{}", run.name);
|
||||
assert_eq!(
|
||||
bytes(&rest.memory)[0x200..0x264],
|
||||
[0x5A; 100],
|
||||
"{}",
|
||||
run.name
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_count_is_all_of_rcx() {
|
||||
// rep stosb with a count above 32 bits: two steps take exactly two off it.
|
||||
let memory = image(&[0xF3, 0xAA, 0xF4], &[0; PAGE]);
|
||||
let mut cpu = CpuState::new(ENTRY, 0);
|
||||
cpu.gpr[RCX] = 0x0000_0001_0000_0001;
|
||||
cpu.gpr[RDI] = DATA;
|
||||
for run in both(&cpu, &memory, 2) {
|
||||
assert_eq!(
|
||||
run.result.exit_reason,
|
||||
ExitReason::StepLimitExceeded,
|
||||
"{}",
|
||||
run.name
|
||||
);
|
||||
assert_eq!(
|
||||
run.result.final_state.gpr[RCX], 0x0000_0000_FFFF_FFFF,
|
||||
"{}",
|
||||
run.name
|
||||
);
|
||||
assert_eq!(run.result.final_state.rip, ENTRY, "{}", run.name);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_fault_keeps_the_elements_already_done() {
|
||||
// (code, RSI, RDI, backward, elements that complete before the fault)
|
||||
let cases: &[(&[u8], u64, u64, bool, u64)] = &[
|
||||
// rep movsq up to the end of the page: 19 bytes hold two elements, and
|
||||
// the third would end past the page.
|
||||
(&[0xF3, 0x48, 0xA5], DATA, END - 19, false, 2),
|
||||
// rep stosd down to the start of the page: elements at offsets 5 and 1
|
||||
// fit, the next would start before the page.
|
||||
(&[0xF3, 0xAB], 0, DATA + 5, true, 2),
|
||||
// rep movsw from a source that ends: three elements can be read.
|
||||
(&[0xF3, 0x66, 0xA5], END - 6, DATA + 0x100, false, 3),
|
||||
// rep movsb with no readable source at all.
|
||||
(&[0xF3, 0xA4], END, DATA + 0x100, false, 0),
|
||||
];
|
||||
let mut random = Random(77);
|
||||
for &(code, rsi, rdi, backward, done) in cases {
|
||||
let data: Vec<u8> = (0..PAGE).map(|_| random.next() as u8).collect();
|
||||
let memory = image(code, &data);
|
||||
let insn = decode(ENTRY, |at| {
|
||||
code.get((at - ENTRY) as usize).copied().ok_or(())
|
||||
})
|
||||
.unwrap();
|
||||
let (kind, size) = (
|
||||
if insn.op == Op::Movs {
|
||||
Kind::Movs
|
||||
} else {
|
||||
Kind::Stos
|
||||
},
|
||||
u64::from(insn.size),
|
||||
);
|
||||
let mut cpu = CpuState::new(ENTRY, 0);
|
||||
cpu.gpr[RAX] = 0x1122_3344_5566_7788;
|
||||
cpu.gpr[RCX] = 9;
|
||||
cpu.gpr[RSI] = rsi;
|
||||
cpu.gpr[RDI] = rdi;
|
||||
cpu.df = backward;
|
||||
cpu.flags = FLAGS;
|
||||
|
||||
// The completed elements took effect. The faulting one changed
|
||||
// nothing, and RIP stays on the instruction so it can be restarted.
|
||||
let mut wanted_data = data.clone();
|
||||
let (wanted_rsi, wanted_rdi) = model(
|
||||
kind,
|
||||
size,
|
||||
backward,
|
||||
done,
|
||||
&mut wanted_data,
|
||||
cpu.gpr[RAX],
|
||||
(rsi, rdi),
|
||||
);
|
||||
let mut wanted = cpu.clone();
|
||||
wanted.gpr[RCX] = 9 - done;
|
||||
wanted.gpr[RSI] = wanted_rsi;
|
||||
wanted.gpr[RDI] = wanted_rdi;
|
||||
|
||||
for run in both(&cpu, &memory, 64) {
|
||||
let what = format!("{code:02X?} on the {}", run.name);
|
||||
assert!(
|
||||
matches!(run.result.exit_reason, ExitReason::MemoryFault(_)),
|
||||
"{what}: {:?}",
|
||||
run.result.exit_reason
|
||||
);
|
||||
assert_eq!(run.result.final_state, wanted, "{what}");
|
||||
assert!(bytes(&run.memory) == wanted_data, "{what}: memory");
|
||||
assert_eq!(run.result.instructions_executed, done as usize, "{what}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn direction_flag_is_set_by_std_and_cleared_by_cld() {
|
||||
// std; stosb; cld; stosb; hlt
|
||||
let code = [0xFD, 0xAA, 0xFC, 0xAA, 0xF4];
|
||||
let memory = image(&code, &[0; PAGE]);
|
||||
let mut cpu = CpuState::new(ENTRY, 0);
|
||||
cpu.gpr[RAX] = 0xC3;
|
||||
cpu.gpr[RDI] = DATA + 0x80;
|
||||
cpu.flags = FLAGS;
|
||||
for run in both(&cpu, &memory, 16) {
|
||||
assert_eq!(run.result.exit_reason, ExitReason::Halt, "{}", run.name);
|
||||
// The first store steps down to 0x7F, the second back up to 0x80.
|
||||
assert_eq!(run.result.final_state.gpr[RDI], DATA + 0x80, "{}", run.name);
|
||||
let written = bytes(&run.memory);
|
||||
assert_eq!(written[0x7F..0x81], [0xC3, 0xC3], "{}", run.name);
|
||||
assert!(!run.result.final_state.df, "{}", run.name);
|
||||
// Neither instruction touches a status flag.
|
||||
assert_eq!(run.result.final_state.flags, FLAGS, "{}", run.name);
|
||||
}
|
||||
// The flag outlives the run that set it.
|
||||
for run in both(&cpu, &image(&[0xFD, 0xF4], &[0; PAGE]), 4) {
|
||||
assert!(run.result.final_state.df, "{}", run.name);
|
||||
assert_eq!(run.result.final_state.flags, FLAGS, "{}", run.name);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_segment_override_moves_the_source_only() {
|
||||
const BASE: u64 = 0x300;
|
||||
let mut data = vec![0u8; PAGE];
|
||||
data[0x10] = 0x11; // DATA + 0x10, what [RSI] names without a base
|
||||
data[0x310] = 0x22; // DATA + 0x10 + BASE, the same RSI under the FS or GS base
|
||||
for (code, uses_base) in [
|
||||
(&[0xA4][..], false), // movsb
|
||||
(&[0x64, 0xA4][..], true), // movsb with the source under FS
|
||||
(&[0x65, 0xA4][..], true), // movsb with the source under GS
|
||||
] {
|
||||
let memory = image(code, &data);
|
||||
let mut cpu = CpuState::new(ENTRY, 0);
|
||||
cpu.fs_base = BASE;
|
||||
cpu.gs_base = BASE;
|
||||
cpu.gpr[RSI] = DATA + 0x10;
|
||||
cpu.gpr[RDI] = DATA + 0x800;
|
||||
for run in both(&cpu, &memory, 1) {
|
||||
let what = format!("{code:02X?} on the {}", run.name);
|
||||
// The destination is [RDI] with no base either way.
|
||||
let wanted = if uses_base { 0x22 } else { 0x11 };
|
||||
assert_eq!(bytes(&run.memory)[0x800], wanted, "{what}");
|
||||
assert_eq!(
|
||||
run.result.final_state.gpr[RSI],
|
||||
DATA + 0x11,
|
||||
"{what}: RSI moves by the element, not by the base"
|
||||
);
|
||||
}
|
||||
}
|
||||
// STOS has no source, and its destination takes no override.
|
||||
let memory = image(&[0x64, 0xAA], &data);
|
||||
let mut cpu = CpuState::new(ENTRY, 0);
|
||||
cpu.fs_base = BASE;
|
||||
cpu.gpr[RAX] = 0x77;
|
||||
cpu.gpr[RDI] = DATA + 0x800;
|
||||
for run in both(&cpu, &memory, 1) {
|
||||
let written = bytes(&run.memory);
|
||||
assert_eq!((written[0x800], written[0xB00]), (0x77, 0), "{}", run.name);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn exactly_the_declared_string_forms_decode() {
|
||||
let decode_bytes = |code: &[u8]| {
|
||||
decode(ENTRY, |at| {
|
||||
code.get((at - ENTRY) as usize).copied().ok_or(())
|
||||
})
|
||||
};
|
||||
let mut seen = BTreeSet::new();
|
||||
for kind in [Kind::Movs, Kind::Stos] {
|
||||
for size in [1, 2, 4, 8] {
|
||||
for rep in [false, true] {
|
||||
let code = encode(kind, size, rep);
|
||||
let insn =
|
||||
decode_bytes(&code).unwrap_or_else(|error| panic!("{code:02X?}: {error:?}"));
|
||||
assert_eq!(usize::from(insn.len), code.len(), "{code:02X?}");
|
||||
assert_eq!((u64::from(insn.size), insn.rep), (size, rep), "{code:02X?}");
|
||||
assert!(!is_native(&insn), "{code:02X?}");
|
||||
seen.insert(usize::from(insn.form));
|
||||
}
|
||||
}
|
||||
}
|
||||
for code in [[0xFC], [0xFD]] {
|
||||
seen.insert(usize::from(decode_bytes(&code).unwrap().form));
|
||||
}
|
||||
// Every declared form of these operations was reached above.
|
||||
for (index, form) in FORMS.iter().enumerate() {
|
||||
if matches!(form.op, Op::Movs | Op::Stos | Op::Cld | Op::Std) {
|
||||
assert!(seen.contains(&index), "{:?} {:?}", form.op, form.size);
|
||||
}
|
||||
}
|
||||
|
||||
let rejected: &[&[u8]] = &[
|
||||
&[0xF2, 0xA4], // repne movsb
|
||||
&[0xF2, 0xAB], // repne stosd
|
||||
&[0xF3, 0xF2, 0xA4], // both repeat prefixes
|
||||
&[0x67, 0xF3, 0xA4], // rep movsb with 32-bit addresses
|
||||
&[0xF0, 0xF3, 0xAA], // lock rep stosb
|
||||
&[0xF3, 0xFC], // rep cld
|
||||
&[0xA6], // cmpsb
|
||||
&[0xF3, 0xA6], // repe cmpsb
|
||||
&[0xAC], // lodsb
|
||||
&[0xAE], // scasb
|
||||
&[0xF2, 0xAE], // repne scasb
|
||||
];
|
||||
for code in rejected {
|
||||
let mut padded = code.to_vec();
|
||||
padded.extend([0x90; 8]);
|
||||
let memory = image(&padded, &[0; PAGE]);
|
||||
let mut cpu = CpuState::new(ENTRY, 0);
|
||||
cpu.gpr[RCX] = 3;
|
||||
cpu.gpr[RSI] = DATA;
|
||||
cpu.gpr[RDI] = DATA + 0x100;
|
||||
for run in both(&cpu, &memory, 1) {
|
||||
assert!(
|
||||
matches!(run.result.exit_reason, ExitReason::IllegalInstruction(_)),
|
||||
"{code:02X?} on the {}: {:?}",
|
||||
run.name,
|
||||
run.result.exit_reason
|
||||
);
|
||||
assert_eq!(run.result.final_state, cpu, "{code:02X?}");
|
||||
assert!(bytes(&run.memory) == vec![0; PAGE], "{code:02X?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -977,7 +977,9 @@ fn every_declared_form_is_executed_by_a_fixture() {
|
||||
.unwrap_or_else(|error| panic!("{line}: {error:?}"));
|
||||
seen.insert(usize::from(insn.form));
|
||||
}
|
||||
// Control flow and exits are covered by the tests below.
|
||||
// Control flow and exits are covered by the tests below. String
|
||||
// instructions and the direction flag need their own memory layout and
|
||||
// are covered form by form in `tests/cpu_rep.rs`.
|
||||
let separate = [
|
||||
Op::Ldmxcsr,
|
||||
Op::Jcc,
|
||||
@@ -986,6 +988,10 @@ fn every_declared_form_is_executed_by_a_fixture() {
|
||||
Op::Ret,
|
||||
Op::Hlt,
|
||||
Op::Syscall,
|
||||
Op::Movs,
|
||||
Op::Stos,
|
||||
Op::Cld,
|
||||
Op::Std,
|
||||
];
|
||||
let mut missing: BTreeMap<&str, Vec<String>> = BTreeMap::new();
|
||||
for (index, form) in FORMS.iter().enumerate() {
|
||||
@@ -1208,7 +1214,8 @@ fn undeclared_and_ambiguous_encodings_are_rejected() {
|
||||
&[0xF0, 0x01, 0x0E], // lock add [rsi], ecx
|
||||
&[0xF2, 0x90], // repne nop
|
||||
&[0xF3, 0xC3], // rep ret
|
||||
&[0xF3, 0xA4], // rep movsb
|
||||
&[0xF2, 0xA4], // repne movsb
|
||||
&[0xF3, 0xA6], // repe cmpsb
|
||||
&[0x67, 0x8B, 0x06], // address-size override
|
||||
&[0x64, 0x2E, 0x8B, 0x06], // CS after FS
|
||||
&[0x66, 0x50], // push ax
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
# decodable; a form counts as implemented only once its operation has semantics
|
||||
# and independent tests. Forms not listed here are rejected.
|
||||
#
|
||||
# enc = "string" is a string instruction: its source is [RSI], which FS or GS
|
||||
# may override, its destination is [RDI], and it accepts the REP prefix (F3).
|
||||
#
|
||||
# lock = true accepts the LOCK prefix (F0) when the ModRM operand is memory.
|
||||
# Every other use of LOCK is rejected, as the architecture's #UD.
|
||||
#
|
||||
@@ -91,6 +94,11 @@ clc = { writes = "cf", ref = "sdm CLC" }
|
||||
stc = { writes = "cf", ref = "sdm STC" }
|
||||
cmc = { reads = "cf", writes = "cf", ref = "sdm CMC" }
|
||||
cpuid = { ref = "sdm CPUID" }
|
||||
cld = { ref = "sdm CLD" }
|
||||
std = { ref = "sdm STD" }
|
||||
# A REP form repeats by leaving RIP on itself, so these end a translated block.
|
||||
movs = { terminator = true, ref = "sdm MOVS/MOVSB/MOVSW/MOVSD/MOVSQ" }
|
||||
stos = { terminator = true, ref = "sdm STOS/STOSB/STOSW/STOSD/STOSQ" }
|
||||
|
||||
# SSE and SSE2 moves and packed integer operations. None reads or writes RFLAGS.
|
||||
movaps = { ref = "sdm MOVAPS" }
|
||||
@@ -575,6 +583,42 @@ opcode = 0xA2
|
||||
enc = "none"
|
||||
size = "n"
|
||||
|
||||
[[form]]
|
||||
op = "movs"
|
||||
opcode = 0xA4
|
||||
enc = "string"
|
||||
size = "b"
|
||||
|
||||
[[form]]
|
||||
op = "movs"
|
||||
opcode = 0xA5
|
||||
enc = "string"
|
||||
size = "v"
|
||||
|
||||
[[form]]
|
||||
op = "stos"
|
||||
opcode = 0xAA
|
||||
enc = "string"
|
||||
size = "b"
|
||||
|
||||
[[form]]
|
||||
op = "stos"
|
||||
opcode = 0xAB
|
||||
enc = "string"
|
||||
size = "v"
|
||||
|
||||
[[form]]
|
||||
op = "cld"
|
||||
opcode = 0xFC
|
||||
enc = "none"
|
||||
size = "n"
|
||||
|
||||
[[form]]
|
||||
op = "std"
|
||||
opcode = 0xFD
|
||||
enc = "none"
|
||||
size = "n"
|
||||
|
||||
[[form]]
|
||||
op = "movzx"
|
||||
map = "0f"
|
||||
|
||||
@@ -101,7 +101,43 @@ impl NativeCompute {
|
||||
colors,
|
||||
[width, height],
|
||||
clear,
|
||||
sampled,
|
||||
sampled.map(|(texture, sampler)| (texture.raw(), sampler)),
|
||||
)
|
||||
.map(|(pixels, _)| pixels)
|
||||
}
|
||||
|
||||
/// As [`Self::render_rgba8_sampled`], with level 0 of a BC1 upload bound
|
||||
/// natively as a `BC1_RGBA` texture to fragment texture slot 0 and the
|
||||
/// sampler to fragment sampler slot 0.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// As [`Self::render_rgba8_sampled`], and for an invalid BC1 level.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn render_rgba8_sampled_bc1(
|
||||
&self,
|
||||
source: &str,
|
||||
entries: [&str; 2],
|
||||
vertices: &[[f32; 4]; 3],
|
||||
colors: &[[f32; 4]; 3],
|
||||
extent: [usize; 2],
|
||||
clear: [u8; 4],
|
||||
texture: &Bc1Upload<'_>,
|
||||
sampler: &crate::sampler::MetalSampler,
|
||||
) -> Result<Vec<u8>, MetalError> {
|
||||
let level = texture
|
||||
.subresource(0, 0)
|
||||
.map_err(|error| MetalError::new("texture subresource", format!("{error:?}")))?;
|
||||
self.validate_bc_extent(level.width, level.height, "BC1")?;
|
||||
let bc1 = self.new_bc1_texture(&level)?;
|
||||
self.render_rgba8_internal(
|
||||
source,
|
||||
entries,
|
||||
vertices,
|
||||
colors,
|
||||
extent,
|
||||
clear,
|
||||
Some((&bc1, sampler)),
|
||||
)
|
||||
.map(|(pixels, _)| pixels)
|
||||
}
|
||||
@@ -116,7 +152,7 @@ impl NativeCompute {
|
||||
[width, height]: [usize; 2],
|
||||
clear: [u8; 4],
|
||||
sampled: Option<(
|
||||
&crate::texture_pipeline::MetalRgba8Texture,
|
||||
&ProtocolObject<dyn MTLTexture>,
|
||||
&crate::sampler::MetalSampler,
|
||||
)>,
|
||||
) -> Result<(Vec<u8>, Option<f64>), MetalError> {
|
||||
@@ -228,7 +264,7 @@ impl NativeCompute {
|
||||
encoder.setVertexBuffer_offset_atIndex(Some(&positions), 0, 0);
|
||||
encoder.setVertexBuffer_offset_atIndex(Some(&colors), 0, 1);
|
||||
if let Some((tex, samp)) = sampled {
|
||||
encoder.setFragmentTexture_atIndex(Some(tex.raw()), 0);
|
||||
encoder.setFragmentTexture_atIndex(Some(tex), 0);
|
||||
encoder.setFragmentSamplerState_atIndex(Some(samp.raw()), 0);
|
||||
}
|
||||
encoder.drawPrimitives_vertexStart_vertexCount(MTLPrimitiveType::Triangle, 0, 3);
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
use xenora_shader::{Architecture, PIXEL_ENTRY_POINT, VERTEX_ENTRY_POINT, compile_graphics};
|
||||
use xenora_texture::{Bc1Upload, Bc1UploadDesc, SamplerDesc, decode_bc1};
|
||||
|
||||
use super::{context, native};
|
||||
|
||||
/// The translated `image_sample_lz` pixel stage samples a native BC1
|
||||
/// texture bound by `render_rgba8_sampled_bc1`. Each of the 8×8 texture's
|
||||
/// four blocks selects only its two endpoints, which expand exactly to 0 or
|
||||
/// 255, so the image is known without a decoder: selector 1 (the second
|
||||
/// endpoint) where `x == 0 || y == 3` within a block, else selector 0.
|
||||
#[test]
|
||||
fn translated_image_sample_lz_reads_bound_bc1_texture() {
|
||||
let blocks: [[u8; 8]; 4] = [
|
||||
[0x00, 0xF8, 0x1F, 0x00, 0x01, 0x01, 0x01, 0x55], // red, blue
|
||||
[0xE0, 0x07, 0x00, 0x00, 0x01, 0x01, 0x01, 0x55], // green, black
|
||||
[0xFF, 0xFF, 0x1F, 0xF8, 0x01, 0x01, 0x01, 0x55], // white, magenta
|
||||
[0xE0, 0xFF, 0xFF, 0x07, 0x01, 0x01, 0x01, 0x55], // yellow, cyan
|
||||
];
|
||||
let endpoints: [[[u8; 4]; 2]; 4] = [
|
||||
[[255, 0, 0, 255], [0, 0, 255, 255]],
|
||||
[[0, 255, 0, 255], [0, 0, 0, 255]],
|
||||
[[255, 255, 255, 255], [255, 0, 255, 255]],
|
||||
[[255, 255, 0, 255], [0, 255, 255, 255]],
|
||||
];
|
||||
let mut expected = Vec::new();
|
||||
for y in 0..8 {
|
||||
for x in 0..8 {
|
||||
let selector = usize::from(x % 4 == 0 || y % 4 == 3);
|
||||
expected.extend(endpoints[(y / 4) * 2 + x / 4][selector]);
|
||||
}
|
||||
}
|
||||
for (index, block) in blocks.into_iter().enumerate() {
|
||||
let (bx, by) = (index % 2 * 4, index / 2 * 4);
|
||||
for (i, texel) in decode_bc1(block).iter().enumerate() {
|
||||
let at = ((by + i / 4) * 8 + bx + i % 4) * 4;
|
||||
assert_eq!(texel, &expected[at..at + 4], "decoder, block {index}");
|
||||
}
|
||||
}
|
||||
|
||||
let ps: Vec<u8> = [
|
||||
&[0x00, 0x00, 0x08, 0xc8][..], // v_interp_p1_f32 v2, v0, attr0.x
|
||||
&[0x01, 0x00, 0x09, 0xc8], // v_interp_p2_f32 v2, v1, attr0.x
|
||||
&[0x00, 0x01, 0x0c, 0xc8], // v_interp_p1_f32 v3, v0, attr0.y
|
||||
&[0x01, 0x01, 0x0d, 0xc8], // v_interp_p2_f32 v3, v1, attr0.y
|
||||
&[0x08, 0x0f, 0x9c, 0xf0, 0x02, 0x04, 0x40, 0x00], // image_sample_lz
|
||||
&[0x0f, 0x18, 0x00, 0xf8, 0x04, 0x05, 0x06, 0x07], // exp mrt0
|
||||
&[0x00, 0x00, 0x81, 0xbf], // s_endpgm
|
||||
]
|
||||
.concat();
|
||||
let compiled = compile_graphics(
|
||||
Architecture::Gfx1030,
|
||||
include_bytes!("../../../../fixtures/rdna2/x9-varying-vs.bin"),
|
||||
&ps,
|
||||
)
|
||||
.expect("compile translated image_sample_lz shader");
|
||||
let gpu = context();
|
||||
let upload = Bc1Upload::new(
|
||||
blocks.as_flattened(),
|
||||
Bc1UploadDesc {
|
||||
width: 8,
|
||||
height: 8,
|
||||
mips: 1,
|
||||
layers: 1,
|
||||
format: 1,
|
||||
usage: 1,
|
||||
row_pitch: 16,
|
||||
slice_pitch: 32,
|
||||
},
|
||||
)
|
||||
.expect("valid BC1 upload");
|
||||
let sampler = native(xenora_metal::sampler::MetalSampler::new(
|
||||
gpu.device(),
|
||||
SamplerDesc::nearest_clamp(),
|
||||
));
|
||||
// Pixel (x, y) of the 8×8 target samples uv ((x + 0.5) / 8, (y + 0.5) / 8).
|
||||
let positions = [
|
||||
[-1.0, -1.0, 0.5, 1.0],
|
||||
[3.0, -1.0, 0.5, 1.0],
|
||||
[-1.0, 3.0, 0.5, 1.0],
|
||||
];
|
||||
let uvs = [
|
||||
[0.0, 1.0, 0.0, 1.0],
|
||||
[2.0, 1.0, 0.0, 1.0],
|
||||
[0.0, -1.0, 0.0, 1.0],
|
||||
];
|
||||
let pixels = native(gpu.render_rgba8_sampled_bc1(
|
||||
&compiled.msl,
|
||||
[VERTEX_ENTRY_POINT, PIXEL_ENTRY_POINT],
|
||||
&positions,
|
||||
&uvs,
|
||||
[8, 8],
|
||||
[19, 43, 93, 251],
|
||||
&upload,
|
||||
&sampler,
|
||||
));
|
||||
assert_eq!(pixels, expected);
|
||||
}
|
||||
@@ -26,6 +26,8 @@ mod texture_bc_alpha;
|
||||
mod texture_bc_channel;
|
||||
#[path = "native/texture_sampling.rs"]
|
||||
mod texture_sampling;
|
||||
#[path = "native/translated_bc1.rs"]
|
||||
mod translated_bc1;
|
||||
#[path = "native/translated_render.rs"]
|
||||
mod translated_render;
|
||||
|
||||
|
||||
+138
-14
@@ -57,6 +57,8 @@ pub enum Op {
|
||||
MoveScalar(u8, u8),
|
||||
/// VOPC 32-bit integer compare writing the Wave32 mask to `vcc_lo`.
|
||||
Compare(Comparison, CompareSource, u8),
|
||||
/// VOP3A integer compare writing a Wave32 mask to SDST.
|
||||
CompareVop3(u8, Comparison, CompareSource, u8),
|
||||
/// VOPC 16- or 64-bit integer compare writing the Wave32 mask to
|
||||
/// `vcc_lo`. For 64-bit forms a `Vector` or `Scalar` source and VSRC1 name
|
||||
/// the low register of a pair.
|
||||
@@ -76,7 +78,7 @@ pub enum Op {
|
||||
},
|
||||
Vector(VectorAlu, u8, u8, u8),
|
||||
/// VOP2 32-bit integer form: VDST, SRC0 (VGPR, SGPR, `vcc_lo`, inline
|
||||
/// integer or literal) and VSRC1. Writes neither VCC nor SCC.
|
||||
/// integer or literal) and VSRC1, with implicit VCC for select/carry forms.
|
||||
VectorInteger(VectorInteger, u8, CompareSource, u8),
|
||||
/// VOP1 32-bit integer or bit form: VDST and SRC0 (VGPR, SGPR, `vcc_lo`,
|
||||
/// inline integer or literal). Writes neither VCC nor SCC.
|
||||
@@ -187,6 +189,8 @@ pub enum BranchCondition {
|
||||
SccZero,
|
||||
/// Take the branch when the low half of VCC is clear.
|
||||
VccZero,
|
||||
/// Take the branch when the low half of VCC is nonzero.
|
||||
VccNonzero,
|
||||
/// Take the branch when the low half of EXEC is clear.
|
||||
ExecZero,
|
||||
}
|
||||
@@ -317,6 +321,12 @@ pub enum VectorAlu {
|
||||
/// section 12.7). None has a carry-in or carry-out.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum VectorInteger {
|
||||
/// 1: select S1 when the lane's VCC bit is set.
|
||||
Select,
|
||||
/// 40: unsigned add with carry input and output.
|
||||
AddCarry,
|
||||
/// 41 / 42: unsigned subtract with borrow input and output.
|
||||
SubtractBorrow { reversed: bool },
|
||||
/// 9 / 11: D = low 32 bits of S0[23:0] * S1[23:0], sign-extended from
|
||||
/// bit 23 when `signed`.
|
||||
Multiply24 { signed: bool },
|
||||
@@ -340,6 +350,11 @@ impl VectorInteger {
|
||||
/// Opcode bits 30-25 of the VOP2 word.
|
||||
fn from_opcode(opcode: u8) -> Option<Self> {
|
||||
Some(match opcode {
|
||||
1 => Self::Select,
|
||||
40 => Self::AddCarry,
|
||||
41 | 42 => Self::SubtractBorrow {
|
||||
reversed: opcode == 42,
|
||||
},
|
||||
9 => Self::Multiply24 { signed: true },
|
||||
10 => Self::MultiplyHigh24 { signed: true },
|
||||
11 => Self::Multiply24 { signed: false },
|
||||
@@ -356,6 +371,34 @@ impl VectorInteger {
|
||||
})
|
||||
}
|
||||
|
||||
fn reads_vcc(self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
Self::Select | Self::AddCarry | Self::SubtractBorrow { .. }
|
||||
)
|
||||
}
|
||||
|
||||
fn writes_vcc(self) -> bool {
|
||||
matches!(self, Self::AddCarry | Self::SubtractBorrow { .. })
|
||||
}
|
||||
|
||||
// Guide 12.7: carry/borrow is determined from the exact mathematical result.
|
||||
fn apply_vcc(self, a: u32, b: u32, bit: u32) -> (u32, bool) {
|
||||
match self {
|
||||
Self::Select => (if bit == 0 { a } else { b }, false),
|
||||
Self::AddCarry => {
|
||||
let exact = u64::from(a) + u64::from(b) + u64::from(bit);
|
||||
(exact as u32, exact > u64::from(u32::MAX))
|
||||
}
|
||||
Self::SubtractBorrow { reversed } => {
|
||||
let (minuend, subtrahend) = if reversed { (b, a) } else { (a, b) };
|
||||
let exact = i64::from(minuend) - i64::from(subtrahend) - i64::from(bit);
|
||||
(exact as u32, exact < 0)
|
||||
}
|
||||
_ => unreachable!("VOP2 operation does not read VCC"),
|
||||
}
|
||||
}
|
||||
|
||||
/// D for S0 = `a`, S1 = `b`, from exact i64 arithmetic reduced modulo 2^32.
|
||||
fn apply(self, a: u32, b: u32) -> u32 {
|
||||
let field = |bits: u32, signed: bool| {
|
||||
@@ -393,6 +436,9 @@ impl VectorInteger {
|
||||
Self::Add => a.wrapping_add(b),
|
||||
Self::Subtract => a.wrapping_sub(b),
|
||||
Self::SubtractReverse => b.wrapping_sub(a),
|
||||
Self::Select | Self::AddCarry | Self::SubtractBorrow { .. } => {
|
||||
unreachable!("VOP2 operation requires VCC")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -677,7 +723,13 @@ pub fn decode(code: &[u8]) -> Result<Vec<DecodedInstruction>, ReferenceError> {
|
||||
left_length.max(right_length),
|
||||
)
|
||||
}
|
||||
[lo, hi, opcode @ (0x82 | 0x84 | 0x86 | 0x88), 0xbf, ..] => {
|
||||
[
|
||||
lo,
|
||||
hi,
|
||||
opcode @ (0x82 | 0x84 | 0x86 | 0x87 | 0x88),
|
||||
0xbf,
|
||||
..,
|
||||
] => {
|
||||
let words = i16::from_le_bytes([*lo, *hi]);
|
||||
let words = usize::try_from(words).map_err(|_| error(offset, "backward branch"))?;
|
||||
(
|
||||
@@ -686,6 +738,7 @@ pub fn decode(code: &[u8]) -> Result<Vec<DecodedInstruction>, ReferenceError> {
|
||||
condition: match opcode {
|
||||
0x84 => BranchCondition::SccZero,
|
||||
0x86 => BranchCondition::VccZero,
|
||||
0x87 => BranchCondition::VccNonzero,
|
||||
0x88 => BranchCondition::ExecZero,
|
||||
_ => BranchCondition::Always,
|
||||
},
|
||||
@@ -713,9 +766,50 @@ pub fn decode(code: &[u8]) -> Result<Vec<DecodedInstruction>, ReferenceError> {
|
||||
let src1 = (second >> 1) | ((third & 1) << 7);
|
||||
(Op::Vector(kind, dst, *first, src1), 4)
|
||||
}
|
||||
[dst, 0, 0x25, 0xd5, lo, middle, hi @ 2..=3, 0x02, ..] if middle & 1 == 1 => {
|
||||
// Guide §§12.7.1, 12.9.1, 12.12 and 13.3.4: VOP3A extends
|
||||
// VOP2 by 0x100 and preserves the VOPC opcode. This subset
|
||||
// fixes unused SRC2 to inline 0 and excludes FP ABS/NEG/OMOD,
|
||||
// halfword OP_SEL, and CLAMP (integer saturation or FP compare
|
||||
// exceptions, §6.5).
|
||||
[
|
||||
dst,
|
||||
0,
|
||||
op,
|
||||
tag @ (0xd4 | 0xd5),
|
||||
lo,
|
||||
middle,
|
||||
hi @ 2..=3,
|
||||
0x02,
|
||||
..,
|
||||
] if middle & 1 != 0 => {
|
||||
let src0 = CompareSource::Vector(*lo);
|
||||
let src1 = (middle >> 1) | ((hi & 1) << 7);
|
||||
(Op::Add(*dst, *lo, src1), 8)
|
||||
match tag {
|
||||
0xd4 if matches!(op, 128..=135 | 192..=199) && *dst <= 106 => (
|
||||
Op::CompareVop3(
|
||||
*dst,
|
||||
Comparison {
|
||||
offset: op & 7,
|
||||
signed: *op < 192,
|
||||
},
|
||||
src0,
|
||||
src1,
|
||||
),
|
||||
8,
|
||||
),
|
||||
0xd5 if *op == 37 => (Op::Add(*dst, *lo, src1), 8),
|
||||
0xd5 => (
|
||||
Op::VectorInteger(
|
||||
VectorInteger::from_opcode(*op)
|
||||
.ok_or_else(|| error(offset, "unsupported VOP3 opcode"))?,
|
||||
*dst,
|
||||
src0,
|
||||
src1,
|
||||
),
|
||||
8,
|
||||
),
|
||||
_ => return Err(error(offset, "unsupported VOP3 opcode or destination")),
|
||||
}
|
||||
}
|
||||
// VOPC (bits 31-25 = 0b0111110): SRC0 bits 0-8, VSRC1 bits 9-16, OP bits 17-24.
|
||||
[lo, packed, upper, tag @ 0x7c..=0x7d, tail @ ..]
|
||||
@@ -1087,13 +1181,33 @@ fn execute_wave(program: &[DecodedInstruction], input: &[u32]) -> Result<Vec<u32
|
||||
}
|
||||
check(src1)?;
|
||||
}
|
||||
let incoming = if exec != 0 && kind.reads_vcc() {
|
||||
read_scalar(Source::Register(VCC_LO as u8))?
|
||||
} else {
|
||||
0
|
||||
};
|
||||
let mut outgoing = 0;
|
||||
for lane in (0..lanes).filter(|&lane| executes(lane)) {
|
||||
let s0 = match src0 {
|
||||
CompareSource::Vector(register) => read(lane, register)?,
|
||||
CompareSource::Scalar(register) => read_scalar(Source::Register(register))?,
|
||||
CompareSource::Immediate(bits) => bits,
|
||||
};
|
||||
results[lane] = Some((dst, kind.apply(s0, read(lane, src1)?)));
|
||||
let s1 = read(lane, src1)?;
|
||||
let value = if kind.reads_vcc() {
|
||||
let (value, carry) = kind.apply_vcc(s0, s1, (incoming >> lane) & 1);
|
||||
outgoing |= u32::from(carry) << lane;
|
||||
value
|
||||
} else {
|
||||
kind.apply(s0, s1)
|
||||
};
|
||||
results[lane] = Some((dst, value));
|
||||
}
|
||||
// Guide 3.9: only executing lanes can contribute a carry.
|
||||
if kind.writes_vcc() {
|
||||
scalars[VCC_LO] = Some(outgoing);
|
||||
scalars[VCC_HI] = None;
|
||||
lane_derived_vcc = exec != 0;
|
||||
}
|
||||
}
|
||||
Op::VectorUnary(kind, dst, src0) => {
|
||||
@@ -1372,13 +1486,16 @@ fn execute_wave(program: &[DecodedInstruction], input: &[u32]) -> Result<Vec<u32
|
||||
}
|
||||
}
|
||||
// RDNA 2 ISA section 3.9: VCC[n] = EXEC[n] & test(n), fully written.
|
||||
Op::Compare(..) | Op::WideCompare(..) => {
|
||||
let (comparison, width, src0, src1) = match op {
|
||||
Op::Compare(..) | Op::WideCompare(..) | Op::CompareVop3(..) => {
|
||||
let (dst, comparison, width, src0, src1) = match op {
|
||||
Op::Compare(comparison, src0, src1) => {
|
||||
(comparison, CompareWidth::Word, src0, src1)
|
||||
(VCC_LO, comparison, CompareWidth::Word, src0, src1)
|
||||
}
|
||||
Op::CompareVop3(dst, comparison, src0, src1) => {
|
||||
(usize::from(dst), comparison, CompareWidth::Word, src0, src1)
|
||||
}
|
||||
Op::WideCompare(comparison, width, src0, src1) => {
|
||||
(comparison, width, src0, src1)
|
||||
(VCC_LO, comparison, width, src0, src1)
|
||||
}
|
||||
_ => unreachable!(),
|
||||
};
|
||||
@@ -1439,18 +1556,24 @@ fn execute_wave(program: &[DecodedInstruction], input: &[u32]) -> Result<Vec<u32
|
||||
}
|
||||
}
|
||||
}
|
||||
scalars[VCC_LO] = Some(mask);
|
||||
scalars[VCC_HI] = None;
|
||||
lane_derived_vcc = exec != 0;
|
||||
scalars[dst] = Some(mask);
|
||||
if dst == VCC_LO {
|
||||
scalars[VCC_HI] = None;
|
||||
lane_derived_vcc = exec != 0;
|
||||
}
|
||||
}
|
||||
Op::Branch {
|
||||
target: destination,
|
||||
condition,
|
||||
} => {
|
||||
if condition == BranchCondition::VccZero && scalars[VCC_LO].is_none() {
|
||||
let tests_vcc = matches!(
|
||||
condition,
|
||||
BranchCondition::VccZero | BranchCondition::VccNonzero
|
||||
);
|
||||
if tests_vcc && scalars[VCC_LO].is_none() {
|
||||
return Err(error(offset, "branch with uninitialized VCC_LO"));
|
||||
}
|
||||
if condition == BranchCondition::VccZero && lane_derived_vcc {
|
||||
if tests_vcc && lane_derived_vcc {
|
||||
check_runtime_region(
|
||||
&program[position + 1..],
|
||||
destination,
|
||||
@@ -1467,6 +1590,7 @@ fn execute_wave(program: &[DecodedInstruction], input: &[u32]) -> Result<Vec<u32
|
||||
!scc.ok_or_else(|| error(offset, "branch with uninitialized SCC"))?
|
||||
}
|
||||
BranchCondition::VccZero => scalars[VCC_LO] == Some(0),
|
||||
BranchCondition::VccNonzero => scalars[VCC_LO] != Some(0),
|
||||
BranchCondition::ExecZero => exec == 0,
|
||||
};
|
||||
if take_branch {
|
||||
|
||||
+392
-122
@@ -8,9 +8,11 @@ mod graphics;
|
||||
pub use graphics::{PIXEL_ENTRY_POINT, VERTEX_ENTRY_POINT, compile_graphics};
|
||||
|
||||
pub use xenora_decoder::Architecture;
|
||||
use xenora_decoder::SoppControlOp;
|
||||
use xenora_decoder::{
|
||||
DecodeError, DecodedInstruction, Instruction, ScalarSource, ScalarUnaryOp, VectorAluOp,
|
||||
VectorAluVop3Op, VectorBinary, VectorCompareOp, VectorSource, VectorUnary,
|
||||
VectorAluVop3Op, VectorBinary, VectorCompareOp, VectorLowering, VectorSource, VectorUnary,
|
||||
VectorVcc,
|
||||
};
|
||||
|
||||
/// SGPR index of `vcc_lo`.
|
||||
@@ -99,6 +101,17 @@ enum Op {
|
||||
inactive: Value,
|
||||
},
|
||||
Store(Value),
|
||||
VccArithmetic {
|
||||
primitive: VectorVcc,
|
||||
left: Value,
|
||||
right: Value,
|
||||
mask: Value,
|
||||
flag: bool,
|
||||
},
|
||||
CarryMask {
|
||||
flag: Value,
|
||||
exec: u32,
|
||||
},
|
||||
ScalarBranch {
|
||||
target: usize,
|
||||
taken: bool,
|
||||
@@ -107,8 +120,13 @@ enum Op {
|
||||
/// The value is wave-uniform; every thread computes it for its own wave.
|
||||
LaneMask {
|
||||
op: VectorCompareOp,
|
||||
/// Assembly name of the decoded encoding (`_e32` or `_e64`).
|
||||
name: &'static str,
|
||||
/// The explicit SGPR destination of the VOP3A encoding (IR text only).
|
||||
sdst: Option<usize>,
|
||||
src0: Value,
|
||||
src1: Value,
|
||||
high: Option<(Value, Value)>,
|
||||
exec: u32,
|
||||
},
|
||||
/// `s_cbranch_vccz` on a lane-derived VCC_LO (IR annotation only).
|
||||
@@ -135,8 +153,20 @@ 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::VccArithmetic {
|
||||
left, right, mask, ..
|
||||
} => vec![left, right, mask],
|
||||
Self::CarryMask { flag, .. } => vec![flag],
|
||||
Self::JoinVccz {
|
||||
mask,
|
||||
fallthrough,
|
||||
@@ -195,8 +225,32 @@ impl Op {
|
||||
name(fallthrough),
|
||||
name(taken)
|
||||
),
|
||||
Self::VccArithmetic {
|
||||
primitive,
|
||||
left,
|
||||
right,
|
||||
mask,
|
||||
flag,
|
||||
} => {
|
||||
let (left, right) = (name(left), name(right));
|
||||
let bit = format!("(({} >> {lane}) & 1u)", name(mask));
|
||||
// Guide 12.7: widen the carry/borrow check before adding the input bit.
|
||||
match (primitive, flag) {
|
||||
(VectorVcc::Select, false) => format!("{bit} != 0u ? {right} : {left}"),
|
||||
(VectorVcc::AddCarry, false) => format!("{left} + {right} + {bit}"),
|
||||
(VectorVcc::AddCarry, true) => {
|
||||
format!("uint((ulong({left}) + ulong({right}) + {bit}) >> 32u)")
|
||||
}
|
||||
(VectorVcc::SubtractBorrow, false) => format!("{left} - {right} - {bit}"),
|
||||
(VectorVcc::SubtractBorrow, true) => {
|
||||
format!("uint(ulong({right}) + {bit} > ulong({left}))")
|
||||
}
|
||||
_ => unreachable!("not a VCC arithmetic operation"),
|
||||
}
|
||||
}
|
||||
Self::Store(_)
|
||||
| Self::ScalarBranch { .. }
|
||||
| Self::CarryMask { .. }
|
||||
| Self::LaneMask { .. }
|
||||
| Self::RuntimeBranch { .. } => unreachable!("not a per-thread expression"),
|
||||
}
|
||||
@@ -216,7 +270,19 @@ 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.semantics().width == 16 {
|
||||
// Guide §§6.2, 6.2.5 and 6.8: the e32 form reads the low half.
|
||||
let half = |value| {
|
||||
if op.signed() {
|
||||
format!("as_type<short>(ushort({value}))")
|
||||
} else {
|
||||
format!("ushort({value})")
|
||||
}
|
||||
};
|
||||
format!("{} {symbol} {}", half(left), half(right))
|
||||
} else if op.signed() && op.semantics().width == 64 {
|
||||
format!("as_type<long>({left}) {symbol} as_type<long>({right})")
|
||||
} else if op.signed() {
|
||||
format!("as_type<int>({left}) {symbol} as_type<int>({right})")
|
||||
} else {
|
||||
format!("{left} {symbol} {right}")
|
||||
@@ -418,7 +484,7 @@ pub fn compile(architecture: Architecture, bytes: &[u8]) -> Result<CompiledShade
|
||||
let mut ir = String::new();
|
||||
let has_mask = operations
|
||||
.iter()
|
||||
.any(|(_, operation)| matches!(operation, Op::LaneMask { .. }));
|
||||
.any(|(_, operation)| matches!(operation, Op::LaneMask { .. } | Op::CarryMask { .. }));
|
||||
let grid = if has_mask {
|
||||
",\n uint grid [[threads_per_grid]]"
|
||||
} else {
|
||||
@@ -440,8 +506,8 @@ pub fn compile(architecture: Architecture, bytes: &[u8]) -> Result<CompiledShade
|
||||
for (index, &(offset, operation)) in operations.iter().enumerate() {
|
||||
let dest = Value(index);
|
||||
uniform.push(match operation {
|
||||
Op::Constant(_) | Op::LaneMask { .. } => true,
|
||||
Op::Load | Op::MergeLanes { .. } => false,
|
||||
Op::Constant(_) | Op::LaneMask { .. } | Op::CarryMask { .. } => true,
|
||||
Op::Load | Op::MergeLanes { .. } | Op::VccArithmetic { .. } => false,
|
||||
_ => operation.operands().iter().all(|value| uniform[value.0]),
|
||||
});
|
||||
let thread = |value: Value| value.to_string();
|
||||
@@ -504,18 +570,88 @@ pub fn compile(architecture: Architecture, bytes: &[u8]) -> Result<CompiledShade
|
||||
format!("{dest} = join.vccz {mask}, {fallthrough}, {taken}"),
|
||||
format!("uint {dest} = {};", operation.expression(&thread, "", "")),
|
||||
),
|
||||
Op::LaneMask {
|
||||
op,
|
||||
src0,
|
||||
src1,
|
||||
exec,
|
||||
} => {
|
||||
Op::VccArithmetic {
|
||||
primitive,
|
||||
left,
|
||||
right,
|
||||
mask,
|
||||
flag,
|
||||
} => (
|
||||
format!(
|
||||
"{dest} = vcc.{primitive:?}{suffix} {left}, {right}, {mask}",
|
||||
suffix = if flag { ".flag" } else { "" }
|
||||
),
|
||||
format!(
|
||||
"uint {dest} = {};",
|
||||
operation.expression(&thread, "", "(index & 31u)")
|
||||
),
|
||||
),
|
||||
Op::CarryMask { flag, exec } => {
|
||||
let _ = writeln!(
|
||||
ir,
|
||||
"{offset:04x}: {dest} = wave.mask {} {src0}, {src1} exec=0x{exec:08x}",
|
||||
op.assembly_name()
|
||||
"{offset:04x}: {dest} = wave.carry {flag} exec=0x{exec:08x}"
|
||||
);
|
||||
emit_lane_mask(
|
||||
&mut msl,
|
||||
&operations,
|
||||
&uniform,
|
||||
index,
|
||||
exec,
|
||||
vec![flag],
|
||||
|name| name(flag),
|
||||
);
|
||||
continue;
|
||||
}
|
||||
Op::LaneMask {
|
||||
op,
|
||||
name,
|
||||
sdst,
|
||||
src0,
|
||||
src1,
|
||||
high,
|
||||
exec,
|
||||
} => {
|
||||
let target = match sdst {
|
||||
None => String::new(),
|
||||
Some(VCC_LO) => " -> vcc_lo".to_string(),
|
||||
Some(register) => format!(" -> s{register}"),
|
||||
};
|
||||
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 {name} {left}, {right}{target} exec=0x{exec:08x}"
|
||||
);
|
||||
let inputs = if matches!(
|
||||
op.relation(),
|
||||
xenora_decoder::CompareRelation::False | xenora_decoder::CompareRelation::True
|
||||
) {
|
||||
Vec::new()
|
||||
} else {
|
||||
operation.operands()
|
||||
};
|
||||
emit_lane_mask(
|
||||
&mut msl,
|
||||
&operations,
|
||||
&uniform,
|
||||
index,
|
||||
exec,
|
||||
inputs,
|
||||
|name| {
|
||||
let (left, right) = if let Some((hi0, hi1)) = high {
|
||||
let pair = |lo, hi| {
|
||||
format!("((ulong({}) << 32u) | ulong({}))", name(hi), name(lo))
|
||||
};
|
||||
(pair(src0, hi0), pair(src1, hi1))
|
||||
} else {
|
||||
(name(src0), name(src1))
|
||||
};
|
||||
format!("({}) ? 1u : 0u", compare_expression(op, &left, &right))
|
||||
},
|
||||
);
|
||||
emit_lane_mask(&mut msl, &operations, &uniform, index, op, src0, src1, exec);
|
||||
continue;
|
||||
}
|
||||
Op::Store(value) => (
|
||||
@@ -535,31 +671,20 @@ pub fn compile(architecture: Architecture, bytes: &[u8]) -> Result<CompiledShade
|
||||
})
|
||||
}
|
||||
|
||||
/// Emit a Wave32 compare mask without any cross-thread operation: the thread
|
||||
/// Emit a Wave32 predicate mask without any cross-thread operation: the thread
|
||||
/// recomputes the lane-dependent operands of each lane of its own RDNA wave
|
||||
/// (dispatch indices `(index & ~31) + n`) from those lanes' input words.
|
||||
/// Absent lanes of a final partial wave contribute 0.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn emit_lane_mask(
|
||||
msl: &mut String,
|
||||
operations: &[(usize, Op)],
|
||||
uniform: &[bool],
|
||||
index: usize,
|
||||
op: VectorCompareOp,
|
||||
src0: Value,
|
||||
src1: Value,
|
||||
exec: u32,
|
||||
mut pending: Vec<Value>,
|
||||
predicate: impl FnOnce(&dyn Fn(Value) -> String) -> String,
|
||||
) {
|
||||
let mut cone = vec![false; index];
|
||||
// F and T do not depend on the operands, so their lanes compute none.
|
||||
let mut pending = if matches!(
|
||||
op.relation(),
|
||||
xenora_decoder::CompareRelation::False | xenora_decoder::CompareRelation::True
|
||||
) {
|
||||
Vec::new()
|
||||
} else {
|
||||
vec![src0, src1]
|
||||
};
|
||||
while let Some(value) = pending.pop() {
|
||||
if uniform[value.0] || cone[value.0] {
|
||||
continue;
|
||||
@@ -591,8 +716,8 @@ fn emit_lane_mask(
|
||||
}
|
||||
let _ = writeln!(
|
||||
msl,
|
||||
" uint pass = ({}) ? 1u : 0u;\n {dest} |= ((0x{exec:08x}u >> lane) & pass) << lane;\n }}",
|
||||
compare_expression(op, &name(src0), &name(src1))
|
||||
" uint pass = {};\n {dest} |= ((0x{exec:08x}u >> lane) & pass) << lane;\n }}",
|
||||
predicate(&name)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -606,6 +731,13 @@ fn decode_fixture(
|
||||
xenora_decoder::decode(architecture, bytes).map_err(CompileError::Decode)
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
enum ScalarValue {
|
||||
Uninitialized,
|
||||
Known(u32),
|
||||
RuntimeMask,
|
||||
}
|
||||
|
||||
fn lift(decoded: &[DecodedInstruction], code_len: usize) -> Result<Vec<(usize, Op)>, CompileError> {
|
||||
let mut operations = Vec::new();
|
||||
let mut registers = [None::<Value>; 256];
|
||||
@@ -613,12 +745,12 @@ fn lift(decoded: &[DecodedInstruction], code_len: usize) -> Result<Vec<(usize, O
|
||||
let mut pending_load = None;
|
||||
let mut stored = false;
|
||||
let mut store_pending = false;
|
||||
let mut scalars = [None; 128];
|
||||
let mut scalars = [ScalarValue::Uninitialized; 128];
|
||||
let mut exec = u32::MAX; // The fixture starts with full Wave32 EXEC.
|
||||
scalars[126] = Some(exec);
|
||||
scalars[126] = ScalarValue::Known(exec);
|
||||
let mut scc = None;
|
||||
let mut skip_before = 0;
|
||||
// Set while VCC_LO holds a lane-derived compare mask (scalars[VCC_LO] is then None).
|
||||
// VCC_LO can forward a lane-derived mask to its supported runtime consumers.
|
||||
let mut lane_vcc: Option<Value> = None;
|
||||
// An open runtime `s_cbranch_vccz` region: its end, mask and the VGPRs at the branch.
|
||||
let mut region: Option<(usize, Value, [Option<Value>; 256])> = None;
|
||||
@@ -627,18 +759,18 @@ fn lift(decoded: &[DecodedInstruction], code_len: usize) -> Result<Vec<(usize, O
|
||||
// contract, even when a known branch skips it.
|
||||
for (index, instruction) in decoded.iter().enumerate() {
|
||||
let offset = instruction.offset;
|
||||
if let Some(target) = instruction.branch_target()
|
||||
&& (target <= offset
|
||||
|| decoded
|
||||
.binary_search_by_key(&target, |instruction| instruction.offset)
|
||||
.is_err())
|
||||
{
|
||||
return Err(CompileError::Verify {
|
||||
offset,
|
||||
reason: "branch target must be a forward instruction boundary",
|
||||
});
|
||||
}
|
||||
let reason = match instruction.instruction {
|
||||
Instruction::Branch { target }
|
||||
| Instruction::BranchSccZero { target }
|
||||
| Instruction::BranchExecZero { target }
|
||||
| Instruction::BranchVccZero { target }
|
||||
if target <= offset
|
||||
|| decoded
|
||||
.binary_search_by_key(&target, |instruction| instruction.offset)
|
||||
.is_err() =>
|
||||
{
|
||||
"branch target must be a forward instruction boundary"
|
||||
}
|
||||
Instruction::BufferLoadDword {
|
||||
index, resource, ..
|
||||
} if (index, resource) != (0, 0) => "unsupported resource or buffer index",
|
||||
@@ -750,11 +882,15 @@ fn lift(decoded: &[DecodedInstruction], code_len: usize) -> Result<Vec<(usize, O
|
||||
}
|
||||
let read_scalar = |source| match source {
|
||||
ScalarSource::Immediate(value) => Ok(value),
|
||||
ScalarSource::Register(register) => scalars
|
||||
.get(usize::from(register))
|
||||
.copied()
|
||||
.flatten()
|
||||
.ok_or_else(|| error("scalar source has no known value")),
|
||||
ScalarSource::Register(register) => match scalars.get(usize::from(register)) {
|
||||
Some(ScalarValue::Known(value)) => Ok(*value),
|
||||
Some(ScalarValue::RuntimeMask) => Err(error(
|
||||
"scalar source reads a runtime-only SGPR compare mask",
|
||||
)),
|
||||
Some(ScalarValue::Uninitialized) | None => {
|
||||
Err(error("scalar source has no known value"))
|
||||
}
|
||||
},
|
||||
};
|
||||
let read_vector = |source, operations: &mut Vec<_>, facts: &mut Vec<_>| {
|
||||
Ok(match source {
|
||||
@@ -762,8 +898,10 @@ fn lift(decoded: &[DecodedInstruction], code_len: usize) -> Result<Vec<(usize, O
|
||||
VectorSource::Scalar(register) if usize::from(register) == VCC_LO => {
|
||||
match (lane_vcc, scalars[VCC_LO]) {
|
||||
(Some(mask), _) => mask,
|
||||
(None, Some(bits)) => constant(operations, facts, offset, bits),
|
||||
(None, None) => {
|
||||
(None, ScalarValue::Known(bits)) => {
|
||||
constant(operations, facts, offset, bits)
|
||||
}
|
||||
(None, _) => {
|
||||
return Err(error("vector ALU reads uninitialized VCC_LO"));
|
||||
}
|
||||
}
|
||||
@@ -778,6 +916,13 @@ fn lift(decoded: &[DecodedInstruction], code_len: usize) -> Result<Vec<(usize, O
|
||||
// Scalar instructions and waits still execute when all lanes are inactive.
|
||||
if exec == 0 {
|
||||
match instruction.instruction {
|
||||
Instruction::VectorAlu { op, .. } if op.writes_vcc() => {
|
||||
// Guide 3.9: inactive lanes contribute zero to carry-out.
|
||||
lane_vcc = None;
|
||||
scalars[VCC_LO] = ScalarValue::Known(0);
|
||||
scalars[VCC_HI] = ScalarValue::Uninitialized;
|
||||
continue;
|
||||
}
|
||||
Instruction::MoveB32 { .. }
|
||||
| Instruction::VectorAluVop3 { .. }
|
||||
| Instruction::VectorAddF32 { .. }
|
||||
@@ -796,6 +941,19 @@ fn lift(decoded: &[DecodedInstruction], code_len: usize) -> Result<Vec<(usize, O
|
||||
{
|
||||
return Err(error("vector memory requires full Wave32 EXEC"));
|
||||
}
|
||||
if let Instruction::BufferLoadDword { resource, .. }
|
||||
| Instruction::BufferStoreDword { resource, .. } = instruction.instruction
|
||||
{
|
||||
let start = usize::from(resource);
|
||||
if scalars[start..start + 4]
|
||||
.iter()
|
||||
.any(|value| matches!(value, ScalarValue::RuntimeMask))
|
||||
{
|
||||
return Err(error(
|
||||
"resource descriptor reads a runtime-only SGPR compare mask",
|
||||
));
|
||||
}
|
||||
}
|
||||
let next = Value(operations.len());
|
||||
let (dest, operation) = match instruction.instruction {
|
||||
Instruction::BufferLoadDword { data, .. } => {
|
||||
@@ -817,12 +975,6 @@ fn lift(decoded: &[DecodedInstruction], code_len: usize) -> Result<Vec<(usize, O
|
||||
store_pending = true;
|
||||
(None, Op::Store(read(data)?))
|
||||
}
|
||||
Instruction::WaitLoad => {
|
||||
if let Some((register, value)) = pending_load.take() {
|
||||
registers[register] = Some(value);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
Instruction::WaitStore => {
|
||||
store_pending = false;
|
||||
continue;
|
||||
@@ -894,10 +1046,10 @@ fn lift(decoded: &[DecodedInstruction], code_len: usize) -> Result<Vec<(usize, O
|
||||
} else {
|
||||
(read(src0)?, read(src1)?)
|
||||
};
|
||||
(
|
||||
Some(dst),
|
||||
Op::Binary(Binary::Vector(op.lowering()), left, right),
|
||||
)
|
||||
let VectorLowering::Binary(binary) = op.lowering() else {
|
||||
return Err(error("VOP3 with a lane condition is unsupported"));
|
||||
};
|
||||
(Some(dst), Op::Binary(Binary::Vector(binary), left, right))
|
||||
}
|
||||
Instruction::ScalarUnary {
|
||||
op: op @ ScalarUnaryOp::MovB32,
|
||||
@@ -917,7 +1069,7 @@ fn lift(decoded: &[DecodedInstruction], code_len: usize) -> Result<Vec<(usize, O
|
||||
let slot = scalars
|
||||
.get_mut(usize::from(dst))
|
||||
.ok_or_else(|| error("scalar destination exceeds the fixture register file"))?;
|
||||
*slot = Some(value);
|
||||
*slot = ScalarValue::Known(value);
|
||||
continue;
|
||||
}
|
||||
Instruction::ScalarUnary { op, dst, src } => {
|
||||
@@ -929,7 +1081,7 @@ fn lift(decoded: &[DecodedInstruction], code_len: usize) -> Result<Vec<(usize, O
|
||||
let slot = scalars
|
||||
.get_mut(usize::from(dst))
|
||||
.ok_or_else(|| error("scalar destination exceeds the fixture register file"))?;
|
||||
*slot = Some(value);
|
||||
*slot = ScalarValue::Known(value);
|
||||
if let Some(flag) = flag {
|
||||
scc = Some(flag);
|
||||
}
|
||||
@@ -954,7 +1106,7 @@ fn lift(decoded: &[DecodedInstruction], code_len: usize) -> Result<Vec<(usize, O
|
||||
let slot = scalars
|
||||
.get_mut(usize::from(dst))
|
||||
.ok_or_else(|| error("scalar destination exceeds the fixture register file"))?;
|
||||
*slot = Some(value);
|
||||
*slot = ScalarValue::Known(value);
|
||||
if let Some(flag) = flag {
|
||||
scc = Some(flag);
|
||||
}
|
||||
@@ -978,13 +1130,21 @@ fn lift(decoded: &[DecodedInstruction], code_len: usize) -> Result<Vec<(usize, O
|
||||
.get_mut(usize::from(dst))
|
||||
.ok_or_else(|| error("scalar destination exceeds the fixture register file"))?;
|
||||
let old = if op.reads_dst() {
|
||||
slot.ok_or_else(|| error("SOPK reads an uninitialized SGPR"))?
|
||||
match *slot {
|
||||
ScalarValue::Known(value) => value,
|
||||
ScalarValue::RuntimeMask => {
|
||||
return Err(error("SOPK reads a runtime-only SGPR compare mask"));
|
||||
}
|
||||
ScalarValue::Uninitialized => {
|
||||
return Err(error("SOPK reads an uninitialized SGPR"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
0
|
||||
};
|
||||
let (value, flag) = op.evaluate(old, simm16, scc_in);
|
||||
if let Some(value) = value {
|
||||
*slot = Some(value);
|
||||
*slot = ScalarValue::Known(value);
|
||||
}
|
||||
if let Some(flag) = flag {
|
||||
scc = Some(flag);
|
||||
@@ -996,11 +1156,36 @@ fn lift(decoded: &[DecodedInstruction], code_len: usize) -> Result<Vec<(usize, O
|
||||
continue;
|
||||
}
|
||||
// docs/shaders/vector-compare.md sections 3 and 5.
|
||||
Instruction::VectorCompare { op, src0, src1 } => {
|
||||
// Both encodings share the Wave32 lane mask implementation.
|
||||
compare @ (Instruction::VectorCompare { .. }
|
||||
| Instruction::VectorCompareVop3 { .. }) => {
|
||||
let (op, name, explicit, sdst, src0, src1) = match compare {
|
||||
Instruction::VectorCompare { op, src0, src1 } => {
|
||||
(op, op.assembly_name(), false, VCC_LO, src0, src1)
|
||||
}
|
||||
Instruction::VectorCompareVop3 {
|
||||
op,
|
||||
sdst,
|
||||
src0,
|
||||
src1,
|
||||
} => (
|
||||
op.base(),
|
||||
op.assembly_name(),
|
||||
true,
|
||||
usize::from(sdst),
|
||||
VectorSource::Register(src0),
|
||||
src1,
|
||||
),
|
||||
_ => unreachable!("only vector compares reach this arm"),
|
||||
};
|
||||
if exec == 0 {
|
||||
scalars[VCC_HI] = None;
|
||||
scalars[VCC_LO] = Some(0);
|
||||
lane_vcc = None;
|
||||
if sdst == VCC_LO {
|
||||
scalars[VCC_HI] = ScalarValue::Uninitialized;
|
||||
scalars[VCC_LO] = ScalarValue::Known(0);
|
||||
lane_vcc = None;
|
||||
} else {
|
||||
scalars[sdst] = ScalarValue::RuntimeMask;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let constant =
|
||||
@@ -1010,13 +1195,32 @@ fn lift(decoded: &[DecodedInstruction], code_len: usize) -> Result<Vec<(usize, O
|
||||
facts.push(KnownBits::constant(bits));
|
||||
value
|
||||
};
|
||||
let high = if op.semantics().width == 64 {
|
||||
// Guide §3.6.3 and contract §2a put the high word at base + 1.
|
||||
let left = match src0 {
|
||||
VectorSource::Register(base) => 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 => {
|
||||
match (lane_vcc, scalars[VCC_LO]) {
|
||||
(Some(mask), _) => mask,
|
||||
(None, Some(bits)) => constant(&mut operations, &mut facts, bits),
|
||||
(None, None) => {
|
||||
(None, ScalarValue::Known(bits)) => {
|
||||
constant(&mut operations, &mut facts, bits)
|
||||
}
|
||||
(None, _) => {
|
||||
return Err(error("compare reads uninitialized VCC_LO"));
|
||||
}
|
||||
}
|
||||
@@ -1033,54 +1237,87 @@ fn lift(decoded: &[DecodedInstruction], code_len: usize) -> Result<Vec<(usize, O
|
||||
offset,
|
||||
Op::LaneMask {
|
||||
op,
|
||||
name,
|
||||
sdst: explicit.then_some(sdst),
|
||||
src0,
|
||||
src1,
|
||||
high,
|
||||
exec,
|
||||
},
|
||||
));
|
||||
facts.push(KnownBits::UNKNOWN);
|
||||
scalars[VCC_LO] = None;
|
||||
scalars[VCC_HI] = None;
|
||||
lane_vcc = Some(mask);
|
||||
if sdst == VCC_LO {
|
||||
scalars[VCC_LO] = ScalarValue::Uninitialized;
|
||||
scalars[VCC_HI] = ScalarValue::Uninitialized;
|
||||
lane_vcc = Some(mask);
|
||||
} else {
|
||||
scalars[sdst] = ScalarValue::RuntimeMask;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
Instruction::BranchVccZero { target } if let Some(mask) = lane_vcc => {
|
||||
if pending_load.is_some() {
|
||||
return Err(error(
|
||||
"a runtime s_cbranch_vccz requires no outstanding vector load",
|
||||
));
|
||||
}
|
||||
region = Some((target, mask, registers));
|
||||
(None, Op::RuntimeBranch { mask, target })
|
||||
}
|
||||
Instruction::BranchSccZero { target }
|
||||
| Instruction::BranchExecZero { target }
|
||||
| Instruction::BranchVccZero { target } => {
|
||||
let taken = match instruction.instruction {
|
||||
Instruction::BranchSccZero { .. } => {
|
||||
!scc.ok_or_else(|| error("conditional branch reads uninitialized SCC"))?
|
||||
Instruction::Branch { .. }
|
||||
| Instruction::BranchSccZero { .. }
|
||||
| Instruction::BranchExecZero { .. }
|
||||
| Instruction::BranchVccZero { .. }
|
||||
| Instruction::WaitLoad
|
||||
| Instruction::EndProgram => {
|
||||
match instruction
|
||||
.instruction
|
||||
.sopp_control()
|
||||
.expect("decoded SOPP control")
|
||||
{
|
||||
SoppControlOp::WaitLoad => {
|
||||
if let Some((register, value)) = pending_load.take() {
|
||||
registers[register] = Some(value);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
Instruction::BranchVccZero { .. } => {
|
||||
scalars[106]
|
||||
.ok_or_else(|| error("conditional branch reads uninitialized VCC_LO"))?
|
||||
== 0
|
||||
SoppControlOp::EndProgram => {
|
||||
if !stored || store_pending || pending_load.is_some() {
|
||||
return Err(error(
|
||||
"termination requires one completed store and no pending loads",
|
||||
));
|
||||
}
|
||||
return Ok(operations);
|
||||
}
|
||||
op => {
|
||||
let target = instruction.branch_target().expect("decoded SOPP branch");
|
||||
if op == SoppControlOp::BranchVccZero
|
||||
&& let Some(mask) = lane_vcc
|
||||
{
|
||||
if pending_load.is_some() {
|
||||
return Err(error(
|
||||
"a runtime s_cbranch_vccz requires no outstanding vector load",
|
||||
));
|
||||
}
|
||||
region = Some((target, mask, registers));
|
||||
(None, Op::RuntimeBranch { mask, target })
|
||||
} else {
|
||||
let taken = match op {
|
||||
SoppControlOp::Branch => true,
|
||||
SoppControlOp::BranchSccZero => !scc.ok_or_else(|| {
|
||||
error("conditional branch reads uninitialized SCC")
|
||||
})?,
|
||||
SoppControlOp::BranchVccZero => {
|
||||
let ScalarValue::Known(bits) = scalars[VCC_LO] else {
|
||||
return Err(error(
|
||||
"conditional branch reads uninitialized VCC_LO",
|
||||
));
|
||||
};
|
||||
bits == 0
|
||||
}
|
||||
SoppControlOp::BranchExecZero => exec == 0,
|
||||
SoppControlOp::WaitLoad | SoppControlOp::EndProgram => {
|
||||
unreachable!()
|
||||
}
|
||||
};
|
||||
if taken {
|
||||
skip_before = target;
|
||||
}
|
||||
(None, Op::ScalarBranch { target, taken })
|
||||
}
|
||||
}
|
||||
_ => exec == 0,
|
||||
};
|
||||
if taken {
|
||||
skip_before = target;
|
||||
}
|
||||
(None, Op::ScalarBranch { target, taken })
|
||||
}
|
||||
Instruction::Branch { target } => {
|
||||
skip_before = target;
|
||||
(
|
||||
None,
|
||||
Op::ScalarBranch {
|
||||
target,
|
||||
taken: true,
|
||||
},
|
||||
)
|
||||
}
|
||||
Instruction::VectorAlu {
|
||||
op,
|
||||
@@ -1095,10 +1332,51 @@ fn lift(decoded: &[DecodedInstruction], code_len: usize) -> Result<Vec<(usize, O
|
||||
} else {
|
||||
(src0, src1)
|
||||
};
|
||||
(
|
||||
Some(dst),
|
||||
Op::Binary(Binary::Vector(op.lowering()), left, right),
|
||||
)
|
||||
match op.lowering() {
|
||||
VectorLowering::Binary(binary) => {
|
||||
(Some(dst), Op::Binary(Binary::Vector(binary), left, right))
|
||||
}
|
||||
VectorLowering::Vcc(primitive) => {
|
||||
let mask = match (lane_vcc, scalars[VCC_LO]) {
|
||||
(Some(mask), _) => mask,
|
||||
(None, ScalarValue::Known(bits)) => {
|
||||
constant(&mut operations, &mut facts, offset, bits)
|
||||
}
|
||||
(None, _) => {
|
||||
return Err(error("vector ALU reads uninitialized VCC_LO"));
|
||||
}
|
||||
};
|
||||
if op.writes_vcc() {
|
||||
let flag = Value(operations.len());
|
||||
operations.push((
|
||||
offset,
|
||||
Op::VccArithmetic {
|
||||
primitive,
|
||||
left,
|
||||
right,
|
||||
mask,
|
||||
flag: true,
|
||||
},
|
||||
));
|
||||
facts.push(KnownBits::UNKNOWN);
|
||||
lane_vcc = Some(Value(operations.len()));
|
||||
operations.push((offset, Op::CarryMask { flag, exec }));
|
||||
facts.push(KnownBits::UNKNOWN);
|
||||
scalars[VCC_LO] = ScalarValue::Uninitialized;
|
||||
scalars[VCC_HI] = ScalarValue::Uninitialized;
|
||||
}
|
||||
(
|
||||
Some(dst),
|
||||
Op::VccArithmetic {
|
||||
primitive,
|
||||
left,
|
||||
right,
|
||||
mask,
|
||||
flag: false,
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Instruction::VectorUnary { op, dst, src } => {
|
||||
let source = read_vector(src, &mut operations, &mut facts)?;
|
||||
@@ -1144,14 +1422,6 @@ fn lift(decoded: &[DecodedInstruction], code_len: usize) -> Result<Vec<(usize, O
|
||||
"graphics instruction is unsupported in a compute fixture",
|
||||
));
|
||||
}
|
||||
Instruction::EndProgram => {
|
||||
if !stored || store_pending || pending_load.is_some() {
|
||||
return Err(error(
|
||||
"termination requires one completed store and no pending loads",
|
||||
));
|
||||
}
|
||||
return Ok(operations);
|
||||
}
|
||||
};
|
||||
let value_bits = match operation {
|
||||
Op::Constant(bits) => KnownBits::constant(bits),
|
||||
|
||||
@@ -14,6 +14,110 @@ fn compiles_original_fixture() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vop3_compare_to_vcc_lo_drives_a_runtime_vccz_branch() {
|
||||
let code: Vec<_> = [
|
||||
0x7e02_0281u32, // v_mov_b32_e32 v1, 1
|
||||
0x7e04_0282, // v_mov_b32_e32 v2, 2
|
||||
0xd4c2_006a, // v_cmp_eq_u32_e64 vcc_lo, v1, v2
|
||||
0x0202_0501,
|
||||
0xbf86_0001, // s_cbranch_vccz 1
|
||||
0x7e02_0302, // v_mov_b32_e32 v1, v2
|
||||
]
|
||||
.into_iter()
|
||||
.flat_map(u32::to_le_bytes)
|
||||
.chain(FIXTURE[28..].iter().copied())
|
||||
.collect();
|
||||
let shader = compile(Architecture::Gfx1030, &code).unwrap();
|
||||
assert!(
|
||||
shader
|
||||
.disassembly
|
||||
.contains("v_cmp_eq_u32_e64 vcc_lo, v1, v2")
|
||||
);
|
||||
assert!(shader.ir.contains("0008: t2 = wave.mask"));
|
||||
assert!(shader.ir.contains("0010: branch.vccz t2 -> 0x0018"));
|
||||
assert!(shader.ir.contains("join.vccz t2"));
|
||||
assert!(shader.msl.contains("lane_index >= grid"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vop3_compare_to_s4_rejects_later_scalar_reads() {
|
||||
for (setup, offset) in [
|
||||
(&[0x7e02_0281u32, 0x7e04_0282][..], 16), // Initialize both VGPRs.
|
||||
(&[0xbefe_0380][..], 12), // Empty EXEC. The VGPRs need not be initialized.
|
||||
] {
|
||||
let code: Vec<_> = setup
|
||||
.iter()
|
||||
.copied()
|
||||
.chain([
|
||||
0xd4c2_0004, // v_cmp_eq_u32_e64 s4, v1, v2
|
||||
0x0202_0501,
|
||||
0xbf06_8004, // s_cmp_eq_u32 s4, 0
|
||||
0xbefe_03c1, // s_mov_b32 exec_lo, -1
|
||||
0x7e02_0281, // v_mov_b32_e32 v1, 1
|
||||
])
|
||||
.flat_map(u32::to_le_bytes)
|
||||
.chain(FIXTURE[28..].iter().copied())
|
||||
.collect();
|
||||
let error = compile(Architecture::Gfx1030, &code).unwrap_err();
|
||||
assert!(
|
||||
matches!(
|
||||
error,
|
||||
CompileError::Verify {
|
||||
offset: actual,
|
||||
reason: "scalar source reads a runtime-only SGPR compare mask",
|
||||
} if actual == offset
|
||||
),
|
||||
"{error}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vop3_compare_mask_cannot_be_read_as_a_buffer_descriptor() {
|
||||
let code: Vec<_> = [
|
||||
0x7e02_0281u32, // v_mov_b32_e32 v1, 1
|
||||
0x7e04_0282, // v_mov_b32_e32 v2, 2
|
||||
0xd4c2_0004, // v_cmp_eq_u32_e64 s4, v1, v2
|
||||
0x0202_0501,
|
||||
]
|
||||
.into_iter()
|
||||
.flat_map(u32::to_le_bytes)
|
||||
.chain(FIXTURE[28..].iter().copied())
|
||||
.collect();
|
||||
assert!(matches!(
|
||||
compile(Architecture::Gfx1030, &code),
|
||||
Err(CompileError::Verify {
|
||||
offset: 16,
|
||||
reason: "resource descriptor reads a runtime-only SGPR compare mask",
|
||||
})
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vop3_compare_to_normal_sgpr_preserves_vcc_and_can_be_overwritten() {
|
||||
let code: Vec<_> = [
|
||||
0x7e02_0281u32, // v_mov_b32_e32 v1, 1
|
||||
0x7e04_0282, // v_mov_b32_e32 v2, 2
|
||||
0xbeea_0381, // s_mov_b32 vcc_lo, 1
|
||||
0xd4c2_0008, // v_cmp_eq_u32_e64 s8, v1, v2
|
||||
0x0202_0501,
|
||||
0xbf86_0001, // s_cbranch_vccz 1
|
||||
0xbe88_0381, // s_mov_b32 s8, 1
|
||||
0xbf06_8008, // s_cmp_eq_u32 s8, 0
|
||||
]
|
||||
.into_iter()
|
||||
.flat_map(u32::to_le_bytes)
|
||||
.chain(FIXTURE[28..].iter().copied())
|
||||
.collect();
|
||||
let shader = compile(Architecture::Gfx1030, &code).unwrap();
|
||||
assert!(
|
||||
shader
|
||||
.ir
|
||||
.contains("0014: branch.uniform 0x001c taken=false")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn load_wait_is_required_before_using_loaded_data() {
|
||||
let mut code = FIXTURE.to_vec();
|
||||
@@ -364,6 +468,20 @@ fn vector_integer_forms_lower_to_per_lane_templates() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vop3_integer_forms_lower_to_per_lane_templates() {
|
||||
let code = include_bytes!("../../../fixtures/rdna2/vop3-integer.bin");
|
||||
let compiled = compile(Architecture::Gfx1030, code).unwrap();
|
||||
assert_eq!(
|
||||
compiled.ir,
|
||||
include_str!("../../../fixtures/golden/vop3-integer.ir")
|
||||
);
|
||||
assert_eq!(
|
||||
compiled.msl,
|
||||
include_str!("../../../fixtures/golden/vop3-integer.metal")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vector_f_and_t_compares_lower_to_operand_free_wave_masks() {
|
||||
let code = include_bytes!("../../../fixtures/rdna2/vector-compare-ft.bin");
|
||||
@@ -392,6 +510,34 @@ fn vector_compares_lower_to_per_thread_wave_masks_and_selects() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vop3_compare_forms_lower_to_wave_masks() {
|
||||
let code = include_bytes!("../../../fixtures/rdna2/vop3-compare.bin");
|
||||
let compiled = compile(Architecture::Gfx1030, code).unwrap();
|
||||
assert_eq!(
|
||||
compiled.ir,
|
||||
include_str!("../../../fixtures/golden/vop3-compare.ir")
|
||||
);
|
||||
assert_eq!(
|
||||
compiled.msl,
|
||||
include_str!("../../../fixtures/golden/vop3-compare.metal")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vector_vcc_fixture_matches_ir_and_msl_goldens() {
|
||||
let code = include_bytes!("../../../fixtures/rdna2/vector-vcc.bin");
|
||||
let result = compile(Architecture::Gfx1030, code).unwrap();
|
||||
assert_eq!(
|
||||
result.ir,
|
||||
include_str!("../../../fixtures/golden/vector-vcc.ir")
|
||||
);
|
||||
assert_eq!(
|
||||
result.msl,
|
||||
include_str!("../../../fixtures/golden/vector-vcc.metal")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vop1_integer_fixture_lowers_unary_and_masked_swap() {
|
||||
let code = include_bytes!("../../../fixtures/rdna2/vector-unary.bin");
|
||||
|
||||
@@ -26,6 +26,7 @@ either path. The [changelog](../CHANGELOG.md) records notable changes.
|
||||
- [SOP2 scalar ALU](shaders/scalar-alu.md) — Supported scalar add, subtract and bitwise forms, their SCC rules and sources.
|
||||
- [Semantic registry](shaders/semantic-registry.md) — How to add an instruction form: registry fields, validation, generation and the independence rule.
|
||||
- [VOP1 vector unary and swap](shaders/vector-unary.md) — Wave32 integer bit operations, register exchange, and operand limits.
|
||||
- [VOP2 select and carry](shaders/vector-vcc.md) — Wave32 lane selection, carry and borrow through the vector condition code.
|
||||
- [VOPC integer compares](shaders/vector-compare.md) — Wave32 compare forms, the VCC/EXEC contract, runtime `s_cbranch_vccz` and the Metal mapping.
|
||||
- [Metal Shading Language generation](shaders/msl.md) and [independent CPU reference](shaders/reference-interpreter.md) — Translation rules and separate CPU execution models.
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="530" height="185" viewBox="0 0 530 185" role="img" aria-labelledby="title description">
|
||||
<title id="title">Xenora · recorded progress</title>
|
||||
<desc id="description">Decoded gfx1030 forms: 126 of 126. Accepted Metal forms · Apple M5: 18 of 126. Accepted guest milestones · X1–X4: 4 of 4</desc>
|
||||
<desc id="description">Decoded gfx1030 forms: 185 of 185. Accepted Metal forms · Apple M5: 18 of 185. Accepted guest milestones · X1–X4: 4 of 4</desc>
|
||||
<rect x="1" y="1" width="528" height="183" rx="10" fill="#18212a" stroke="#516171"/>
|
||||
<g font-family="system-ui,sans-serif" fill="#eaf0f5">
|
||||
<text x="20" y="29" font-size="13" font-weight="700">RECORDED FIXTURE PROGRESS</text>
|
||||
<text x="20" y="58" font-size="13">Decoded gfx1030 forms</text>
|
||||
<text x="510" y="58" font-size="13" text-anchor="end">126 / 126</text>
|
||||
<text x="510" y="58" font-size="13" text-anchor="end">185 / 185</text>
|
||||
<rect x="20" y="65" width="490" height="4" rx="2" fill="#3c4a58"/>
|
||||
<rect x="20" y="65" width="490.00" height="4" rx="2" fill="#88c6bd"/>
|
||||
<text x="20" y="96" font-size="13">Accepted Metal forms · Apple M5</text>
|
||||
<text x="510" y="96" font-size="13" text-anchor="end">18 / 126</text>
|
||||
<text x="510" y="96" font-size="13" text-anchor="end">18 / 185</text>
|
||||
<rect x="20" y="103" width="490" height="4" rx="2" fill="#3c4a58"/>
|
||||
<rect x="20" y="103" width="70.00" height="4" rx="2" fill="#88c6bd"/>
|
||||
<rect x="20" y="103" width="47.68" height="4" rx="2" fill="#88c6bd"/>
|
||||
<text x="20" y="134" font-size="13">Accepted guest milestones · X1–X4</text>
|
||||
<text x="510" y="134" font-size="13" text-anchor="end">4 / 4</text>
|
||||
<rect x="20" y="141" width="490" height="4" rx="2" fill="#3c4a58"/>
|
||||
|
||||
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
@@ -59,6 +59,18 @@ These rules hold for both engines and are what a guest scheduler has to preserve
|
||||
|
||||
The SDM cases for these forms in `tests/cpu_known_answers.rs` were written before this implementation, by another contributor. `tests/x86_atomic.rs` adds the LOCK rules, both compare outcomes at every width, unaligned operands and faults. None of it has been compared with x86 hardware, and nothing here establishes multi-thread behaviour.
|
||||
|
||||
## String instructions
|
||||
|
||||
MOVS and STOS exist for 8-, 16-, 32- and 64-bit elements, alone and with REP (F3), together with the direction flag and CLD and STD. `CpuState::df` holds the flag. It is not one of the six status flags the registry tracks.
|
||||
|
||||
- **One element per step.** A REP form moves one element, decrements RCX and, while RCX is not zero, leaves RIP on the instruction. Each element is a step of its own in both engines and counts against the step budget, so a repeat cannot outrun the budget and can stop part-way and resume. A zero count touches no memory and no register. Without REP, RCX is not read. Step counts therefore count elements, not instructions, for a REP form.
|
||||
- **Direction.** RSI and RDI move up by the element size when the flag is clear and down when it is set. Each element is read whole and then written, so overlapping ranges behave as that order dictates.
|
||||
- **Faults.** An element completes or changes nothing. A fault keeps the elements already done, leaves RSI, RDI and RCX at the element that faulted, and leaves RIP on the instruction.
|
||||
- **Segments.** An FS or GS override applies to the MOVS source. The destination, and STOS as a whole, take no override.
|
||||
- **Lowering.** The DBT runs these forms on the shared semantics, one helper call per element, and a string instruction ends its translated block. There is no bulk-copy path, so large copies are slow.
|
||||
|
||||
The SDM cases for these forms in `tests/cpu_known_answers.rs` were written before this implementation, by another contributor. `tests/cpu_rep.rs` adds a byte-array model over every form, direction and count, the step accounting, faults and the segment rule. None of it has been compared with x86 hardware.
|
||||
|
||||
## Guest CPUID
|
||||
|
||||
CPUID (`0F A2`) returns a fixed table that never reads the host. It describes a synthetic processor: the vendor string is `Xenora guest`, not Intel's or AMD's, and leaf 1 reports no family, model or stepping.
|
||||
@@ -83,4 +95,4 @@ A feature bit is set only when every instruction of that feature is implemented.
|
||||
|
||||
## Rejected on purpose
|
||||
|
||||
LOCK except as described above, F2 or F3 where it is neither PAUSE nor part of a declared form, F2 combined with F3, address-size overrides, an ignored segment override after FS or GS, 16-bit stack and branch forms, 16-bit BSWAP and MOVSXD, bit tests of memory by a register index, RCL, RCR, SHLD, SHRD, string instructions, MMX, the RCP and RSQRT approximations, SSE3 and later, VEX, CMPXCHG8B, CMPXCHG16B and fences. The DBT also refuses raw SYSCALL.
|
||||
LOCK except as described above, F2 or F3 where it is neither PAUSE nor part of a declared form, F2 combined with F3, address-size overrides, an ignored segment override after FS or GS, 16-bit stack and branch forms, 16-bit BSWAP and MOVSXD, bit tests of memory by a register index, RCL, RCR, SHLD, SHRD, LODS, CMPS, SCAS, REPE and REPNE, MMX, the RCP and RSQRT approximations, SSE3 and later, VEX, CMPXCHG8B, CMPXCHG16B and fences. The DBT also refuses raw SYSCALL.
|
||||
@@ -498,3 +498,47 @@ compare function. Colour and the stored depth are both read back.
|
||||
|
||||
These passes are checked on the GPU with Metal validation against expectations
|
||||
derived independently from the public semantics; synthetic fixtures only.
|
||||
|
||||
### Guest texture binding (descriptor tables)
|
||||
|
||||
`GraphicsContext` lets a guest command list sample one texture in the pixel
|
||||
stage through a D3D12-shaped binding. A draw samples only if a root signature
|
||||
is bound. Draws without one keep the flat-colour path. The supported subset
|
||||
is fixed. Anything outside it fails with `GraphicsError::Unsupported` when the
|
||||
object is created, or with an error at execution. A rejected draw never
|
||||
reaches the backend. Draws recorded before it in the same list have already
|
||||
run.
|
||||
|
||||
| Object | Supported |
|
||||
| --- | --- |
|
||||
| `create_descriptor_heap` | Shader-visible `CBV_SRV_UAV` (0) or `SAMPLER` (1) heaps of 1–64 descriptors. RTV, DSV and CPU-only heaps are unsupported. |
|
||||
| `create_committed_texture2d` | One level of `R8G8B8A8_UNORM` (28) or `BC1_UNORM` (71), 1–64 texels per side. BC1 sizes must be multiples of four. Rows are linear: 4 bytes per texel, or 8 bytes per 4×4 block. Xbox tiling is not handled. |
|
||||
| `create_shader_resource_view` | A `Texture2D` view of mip 0 of a single-level, single-slice 2D texture, in the resource's own format. |
|
||||
| `create_sampler` | Point filtering (`MIN_MAG_MIP_POINT`), clamp addressing on U, V and W, no LOD bias and a minimum LOD of 0. |
|
||||
| `create_root_signature` | Exactly two pixel-visibility descriptor tables, in either order: one with a single SRV range for `t0`, and one with a single sampler range for `s0` (one descriptor each, space 0). Root constants, root descriptors, CBV and UAV ranges, extra tables or ranges and static samplers are unsupported. |
|
||||
| `cmd_set_descriptor_heaps` | At most one heap of each type. |
|
||||
| `cmd_set_graphics_root_descriptor_table` | The base must be a GPU handle to a slot of the bound heap of the table's type. The slot must hold a descriptor when a draw reads it. Changing the heaps or binding a different root signature clears every table. Setting the same heaps or the same root signature again keeps them. |
|
||||
|
||||
Descriptor handles follow D3D12 pointer arithmetic: the heap start plus
|
||||
`index × GetDescriptorHandleIncrementSize` (32 here; guests must query the
|
||||
value). `offset` returns `None` rather than carry into the next heap. CPU and
|
||||
GPU handles are separate spaces. A textured draw is a `DrawInstanced` of
|
||||
one instance of three vertices with start instance 0, starting at any vertex. Zero vertices or
|
||||
instances draw nothing. The sampled texture must be in `COMMON` or a read-only state that includes
|
||||
`PIXEL_SHADER_RESOURCE`. The software reference draws at most 4096 pixels. Each vertex record holds a float4 position
|
||||
at byte 0 and a float4 texture coordinate at byte 16, with a stride of at
|
||||
least 32. Textured indexed draws are unsupported.
|
||||
|
||||
The native backend receives a `TexturedDraw` with the bound level and must
|
||||
bind it to fragment texture 0 and sampler 0, which are the `tex0` and `samp0` arguments of
|
||||
the translated `image_sample_lz` pixel stage. `NativeCompute::render_rgba8_sampled_bc1`
|
||||
binds a BC1 level natively for that purpose. The software reference has no
|
||||
clipping or depth test. A pixel is covered when its centre lies inside or on
|
||||
an edge of the triangle. The texture coordinate is interpolated affinely, so
|
||||
`w = 1` is required, and point sampled with
|
||||
`min(floor(clamp(u, 0, 1) × width), width − 1)`. It decodes BC1 with the
|
||||
spec-exact `xenora_texture::decode_bc1`. Apple's hardware rounds BC1's two
|
||||
interpolated palette entries differently (171/84 against 170/85, measured
|
||||
on an M5 Pro), so the tests use endpoint colours only. Pipeline
|
||||
state objects do not exist yet, so the backend, not the guest, chooses the
|
||||
pixel shader. These entry points are not yet wired to guest imports.
|
||||
@@ -14,12 +14,39 @@ The wider LLVM operand matrix exercises decoding only. ABI means application bin
|
||||
| Form | Operands | Size or word | Recognized | Decoded | LLVM | Lowering | Reference | CPU | GPU |
|
||||
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
||||
| `buffer_load_dword` | MUBUF, VGPR data/index, four normal SGPRs, `idxen`, zero offsets and remaining flags | 8 B | yes | yes | three-way passed | MSL load | implemented | fixture verified | fixture verified |
|
||||
| `s_waitcnt vmcnt(0)` | SOPP, exact immediate `0x3f70`; other counters disabled by their maximum values | 4 B | yes | yes | three-way passed | verified load wait | implemented | fixture verified | fixture verified |
|
||||
| `s_waitcnt vmcnt(0)` | SOPP, exact immediate `0x3f70`; other counters disabled by their maximum values (semantic registry) | 4 B | yes | yes | three-way passed | verified load wait | implemented | fixture verified | fixture verified |
|
||||
| `v_mov_b32_e32` | VOP1, VGPR destination, VGPR, normal SGPR (wave-uniform, known during translation), vcc_lo (known or a compare mask) or inline integer or literal source, plus the inline bit pattern for +1.0f | 4 or 8 B | yes | yes | three-way passed | constant or register value | implemented | fixture verified | fixture verified |
|
||||
| `v_add_nc_u32_e64` | VOP3, VGPR destination and two VGPR inputs, modifier fields clear, third source field encoded as inline zero | 8 B | yes | yes | three-way passed | MSL unsigned add | implemented | fixture verified | fixture verified |
|
||||
| `v_mul_i32_i24_e64` | VOP3A, Wave32; VGPR destination and two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; inactive lanes keep VDST; the operation of `v_mul_i32_i24_e32` | 8 B | yes | yes | three-way passed | per-thread typed integer template of the VOP2 form | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_mul_hi_i32_i24_e64` | VOP3A, Wave32; VGPR destination and two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; inactive lanes keep VDST; the operation of `v_mul_hi_i32_i24_e32` | 8 B | yes | yes | three-way passed | per-thread typed integer template of the VOP2 form | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_mul_u32_u24_e64` | VOP3A, Wave32; VGPR destination and two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; inactive lanes keep VDST; the operation of `v_mul_u32_u24_e32` | 8 B | yes | yes | three-way passed | per-thread typed integer template of the VOP2 form | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_mul_hi_u32_u24_e64` | VOP3A, Wave32; VGPR destination and two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; inactive lanes keep VDST; the operation of `v_mul_hi_u32_u24_e32` | 8 B | yes | yes | three-way passed | per-thread typed integer template of the VOP2 form | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_min_i32_e64` | VOP3A, Wave32; VGPR destination and two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; inactive lanes keep VDST; the operation of `v_min_i32_e32` | 8 B | yes | yes | three-way passed | per-thread typed integer template of the VOP2 form | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_max_i32_e64` | VOP3A, Wave32; VGPR destination and two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; inactive lanes keep VDST; the operation of `v_max_i32_e32` | 8 B | yes | yes | three-way passed | per-thread typed integer template of the VOP2 form | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_min_u32_e64` | VOP3A, Wave32; VGPR destination and two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; inactive lanes keep VDST; the operation of `v_min_u32_e32` | 8 B | yes | yes | three-way passed | per-thread typed integer template of the VOP2 form | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_max_u32_e64` | VOP3A, Wave32; VGPR destination and two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; inactive lanes keep VDST; the operation of `v_max_u32_e32` | 8 B | yes | yes | three-way passed | per-thread typed integer template of the VOP2 form | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_xnor_b32_e64` | VOP3A, Wave32; VGPR destination and two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; inactive lanes keep VDST; the operation of `v_xnor_b32_e32` | 8 B | yes | yes | three-way passed | per-thread typed integer template of the VOP2 form | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_sub_nc_u32_e64` | VOP3A, Wave32; VGPR destination and two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; inactive lanes keep VDST; the operation of `v_sub_nc_u32_e32` | 8 B | yes | yes | three-way passed | per-thread typed integer template of the VOP2 form | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_subrev_nc_u32_e64` | VOP3A, Wave32; VGPR destination and two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; inactive lanes keep VDST; the operation of `v_subrev_nc_u32_e32` | 8 B | yes | yes | three-way passed | per-thread typed integer template of the VOP2 form | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cmp_lt_i32_e64` | VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_lt_i32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error | 8 B | yes | yes | three-way passed | per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cmp_eq_i32_e64` | VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_eq_i32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error | 8 B | yes | yes | three-way passed | per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cmp_le_i32_e64` | VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_le_i32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error | 8 B | yes | yes | three-way passed | per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cmp_gt_i32_e64` | VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_gt_i32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error | 8 B | yes | yes | three-way passed | per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cmp_ne_i32_e64` | VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_ne_i32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error | 8 B | yes | yes | three-way passed | per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cmp_ge_i32_e64` | VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_ge_i32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error | 8 B | yes | yes | three-way passed | per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cmp_f_i32_e64` | VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_f_i32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error | 8 B | yes | yes | three-way passed | per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cmp_t_i32_e64` | VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_t_i32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error | 8 B | yes | yes | three-way passed | per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cmp_lt_u32_e64` | VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_lt_u32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error | 8 B | yes | yes | three-way passed | per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cmp_eq_u32_e64` | VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_eq_u32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error | 8 B | yes | yes | three-way passed | per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cmp_le_u32_e64` | VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_le_u32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error | 8 B | yes | yes | three-way passed | per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cmp_gt_u32_e64` | VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_gt_u32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error | 8 B | yes | yes | three-way passed | per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cmp_ne_u32_e64` | VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_ne_u32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error | 8 B | yes | yes | three-way passed | per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cmp_ge_u32_e64` | VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_ge_u32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error | 8 B | yes | yes | three-way passed | per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cmp_f_u32_e64` | VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_f_u32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error | 8 B | yes | yes | three-way passed | per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cmp_t_u32_e64` | VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_t_u32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error | 8 B | yes | yes | three-way passed | per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `buffer_store_dword` | MUBUF, VGPR data/index, four normal SGPRs, `idxen`, zero offsets and remaining flags | 8 B | yes | yes | three-way passed | MSL store | implemented | fixture verified | fixture verified |
|
||||
| `s_waitcnt_vscnt null, 0` | SOPK, exact null source and zero immediate | 4 B | yes | yes | three-way passed | verified store wait | implemented | fixture verified | fixture verified |
|
||||
| `s_endpgm` | SOPP, zero immediate | 4 B | yes | yes | three-way passed | verified termination | implemented | fixture verified | fixture verified |
|
||||
| `s_endpgm` | SOPP, zero immediate (semantic registry) | 4 B | yes | yes | three-way passed | verified termination | implemented | fixture verified | fixture verified |
|
||||
| `s_mov_b32` | Normal SGPR or EXEC/VCC half destination and normal SGPR, inline integer or literal source | `BE880387` | yes | yes | three-way passed | resolved scalar state | implemented | fixture verified | fixture verified |
|
||||
| `s_not_b32` | SOP1, normal SGPR destination; normal SGPR, inline integer or literal source; D = ~S0; SCC = D != 0 | `BE890708` | yes | yes | three-way passed | resolved scalar state and SCC | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `s_brev_b32` | SOP1, normal SGPR destination; normal SGPR, inline integer or literal source; D = S0 bit-reversed; SCC unchanged | `BE8A0B08` | yes | yes | three-way passed | resolved scalar state and SCC | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
@@ -109,8 +136,36 @@ 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 |
|
||||
| `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_cmp_lt_i16_e32` | VOPC, Wave32; VGPR, known SGPR, VCC_LO or inline integer SRC0; VGPR VSRC1; signed low 16 bits; VCC_LO[n] = EXEC_LO[n] & (S0 < S1), fully written | `7D120702` | yes | yes | three-way passed | per-thread Wave32 mask with low-half operands | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cmp_eq_i16_e32` | VOPC, Wave32; VGPR, known SGPR, VCC_LO or inline integer SRC0; VGPR VSRC1; signed low 16 bits; VCC_LO[n] = EXEC_LO[n] & (S0 == S1), fully written | `7D140702` | yes | yes | three-way passed | per-thread Wave32 mask with low-half operands | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cmp_le_i16_e32` | VOPC, Wave32; VGPR, known SGPR, VCC_LO or inline integer SRC0; VGPR VSRC1; signed low 16 bits; VCC_LO[n] = EXEC_LO[n] & (S0 <= S1), fully written | `7D160702` | yes | yes | three-way passed | per-thread Wave32 mask with low-half operands | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cmp_gt_i16_e32` | VOPC, Wave32; VGPR, known SGPR, VCC_LO or inline integer SRC0; VGPR VSRC1; signed low 16 bits; VCC_LO[n] = EXEC_LO[n] & (S0 > S1), fully written | `7D180702` | yes | yes | three-way passed | per-thread Wave32 mask with low-half operands | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cmp_ne_i16_e32` | VOPC, Wave32; VGPR, known SGPR, VCC_LO or inline integer SRC0; VGPR VSRC1; signed low 16 bits; VCC_LO[n] = EXEC_LO[n] & (S0 != S1), fully written | `7D1A0702` | yes | yes | three-way passed | per-thread Wave32 mask with low-half operands | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cmp_ge_i16_e32` | VOPC, Wave32; VGPR, known SGPR, VCC_LO or inline integer SRC0; VGPR VSRC1; signed low 16 bits; VCC_LO[n] = EXEC_LO[n] & (S0 >= S1), fully written | `7D1C0702` | yes | yes | three-way passed | per-thread Wave32 mask with low-half operands | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cmp_lt_u16_e32` | VOPC, Wave32; VGPR, known SGPR, VCC_LO or inline integer SRC0; VGPR VSRC1; unsigned low 16 bits; VCC_LO[n] = EXEC_LO[n] & (S0 < S1), fully written | `7D520702` | yes | yes | three-way passed | per-thread Wave32 mask with low-half operands | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cmp_eq_u16_e32` | VOPC, Wave32; VGPR, known SGPR, VCC_LO or inline integer SRC0; VGPR VSRC1; unsigned low 16 bits; VCC_LO[n] = EXEC_LO[n] & (S0 == S1), fully written | `7D540702` | yes | yes | three-way passed | per-thread Wave32 mask with low-half operands | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cmp_le_u16_e32` | VOPC, Wave32; VGPR, known SGPR, VCC_LO or inline integer SRC0; VGPR VSRC1; unsigned low 16 bits; VCC_LO[n] = EXEC_LO[n] & (S0 <= S1), fully written | `7D560702` | yes | yes | three-way passed | per-thread Wave32 mask with low-half operands | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cmp_gt_u16_e32` | VOPC, Wave32; VGPR, known SGPR, VCC_LO or inline integer SRC0; VGPR VSRC1; unsigned low 16 bits; VCC_LO[n] = EXEC_LO[n] & (S0 > S1), fully written | `7D580702` | yes | yes | three-way passed | per-thread Wave32 mask with low-half operands | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cmp_ne_u16_e32` | VOPC, Wave32; VGPR, known SGPR, VCC_LO or inline integer SRC0; VGPR VSRC1; unsigned low 16 bits; VCC_LO[n] = EXEC_LO[n] & (S0 != S1), fully written | `7D5A0702` | yes | yes | three-way passed | per-thread Wave32 mask with low-half operands | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cmp_ge_u16_e32` | VOPC, Wave32; VGPR, known SGPR, VCC_LO or inline integer SRC0; VGPR VSRC1; unsigned low 16 bits; VCC_LO[n] = EXEC_LO[n] & (S0 >= S1), fully written | `7D5C0702` | yes | yes | three-way passed | per-thread Wave32 mask with low-half operands | 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 known-answer test passed | local Apple M5 readback 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 known-answer test passed | local Apple M5 readback 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 known-answer test passed | local Apple M5 readback 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 known-answer test passed | local Apple M5 readback 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 known-answer test passed | local Apple M5 readback 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 known-answer test passed | local Apple M5 readback 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 known-answer test passed | local Apple M5 readback 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 known-answer test passed | local Apple M5 readback 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 known-answer test passed | local Apple M5 readback 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 known-answer test passed | local Apple M5 readback 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 known-answer test passed | local Apple M5 readback 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 known-answer test passed | local Apple M5 readback 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 known-answer test passed | local Apple M5 readback 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 known-answer test passed | local Apple M5 readback 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 known-answer test passed | local Apple M5 readback 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 known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `s_cbranch_scc0` | Nonnegative signed dword displacement (semantic registry) | `BF840002` | yes | yes | three-way passed | resolved conditional branch | implemented | fixture verified | fixture verified |
|
||||
| `s_branch` | Nonnegative signed dword displacement (semantic registry) | `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 |
|
||||
| `v_xor_b32_e32` | Two VGPR sources and one VGPR destination | `3A020702` | yes | yes | three-way passed | MSL bitwise XOR | implemented | fixture verified | fixture verified |
|
||||
| `v_add_f32_e32` | Two VGPR sources and one VGPR destination | `06020702` | yes | yes | three-way passed | MSL FP32 add | implemented | fixture verified | fixture verified |
|
||||
@@ -119,8 +174,8 @@ The wider LLVM operand matrix exercises decoding only. ABI means application bin
|
||||
| `v_lshlrev_b32_e32` | Two VGPR sources and one VGPR destination | `34020501` | yes | yes | three-way passed | MSL logical left shift with a five-bit count | implemented | fixture verified | fixture verified on Apple M5 |
|
||||
| `v_lshrrev_b32_e32` | Two VGPR sources and one VGPR destination | `2DFFFF01` | yes | yes | three-way passed | MSL logical right shift with a five-bit count | implemented | fixture verified | fixture verified on Apple M5 |
|
||||
| `v_ashrrev_i32_e32` | Two VGPR sources and one VGPR destination | `31FFFF01` | yes | yes | three-way passed | MSL signed right shift with a five-bit count | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `s_cbranch_execz` | Nonnegative signed dword displacement | `BF880001` | yes | yes | three-way passed | resolved Wave32 EXEC_LO zero check | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `s_cbranch_vccz` | Nonnegative signed dword displacement | `BF860001` | yes | yes | three-way passed | resolved Wave32 VCC_LO zero check, or a wave-uniform join select after a vector compare | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `s_cbranch_execz` | Nonnegative signed dword displacement (semantic registry) | `BF880001` | yes | yes | three-way passed | resolved Wave32 EXEC_LO zero check | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `s_cbranch_vccz` | Nonnegative signed dword displacement (semantic registry) | `BF860001` | yes | yes | three-way passed | resolved Wave32 VCC_LO zero check, or a wave-uniform join select after a vector compare | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_not_b32_e32` | VOP1, Wave32; VGPR VDST with VGPR, normal SGPR, vcc_lo, inline integer or literal SRC0; bitwise complement | `7E046F01` | yes | yes | three-way passed | per-thread unary integer operation with a lane merge under partial EXEC | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_bfrev_b32_e32` | VOP1, Wave32; VGPR VDST with VGPR, normal SGPR, vcc_lo, inline integer or literal SRC0; reverse bit order | `7E067101` | yes | yes | three-way passed | per-thread unary integer operation with a lane merge under partial EXEC | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_ffbh_u32_e32` | VOP1, Wave32; VGPR VDST with VGPR, normal SGPR, vcc_lo, inline integer or literal SRC0; count leading zeros, or -1 for zero | `7E087302` | yes | yes | three-way passed | per-thread unary integer operation with a lane merge under partial EXEC | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
@@ -139,16 +194,20 @@ The wider LLVM operand matrix exercises decoding only. ABI means application bin
|
||||
| `v_add_nc_u32_e32` | VOP2, Wave32; VGPR, normal SGPR (known during translation), vcc_lo, inline integer or literal SRC0; VGPR VSRC1 and VDST; inactive lanes keep VDST; D = S0 + S1, no carry | `4A160F06` | yes | yes | three-way passed | per-thread typed integer template over the lane's own VGPRs; partial EXEC as a lane merge | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_sub_nc_u32_e32` | VOP2, Wave32; VGPR, normal SGPR (known during translation), vcc_lo, inline integer or literal SRC0; VGPR VSRC1 and VDST; inactive lanes keep VDST; D = S0 - S1, no carry | `4C181308` | yes | yes | three-way passed | per-thread typed integer template over the lane's own VGPRs; partial EXEC as a lane merge | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_subrev_nc_u32_e32` | VOP2, Wave32; VGPR, normal SGPR (known during translation), vcc_lo, inline integer or literal SRC0; VGPR VSRC1 and VDST; inactive lanes keep VDST; D = S1 - S0, no carry | `4E1A170A` | yes | yes | three-way passed | per-thread typed integer template over the lane's own VGPRs; partial EXEC as a lane merge | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_cndmask_b32_e32` | VOP2, Wave32; VCC_LO lane input; general SRC0, VGPR VSRC1 and VDST; select S1 when the VCC_LO lane bit is set, otherwise S0 | `020402C1` | yes | yes | three-way passed | per-thread integer expression with EXEC masking | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_add_co_ci_u32_e32` | VOP2, Wave32; VCC_LO lane input; general SRC0, VGPR VSRC1 and VDST; unsigned addition with carry input and output | `50040481` | yes | yes | three-way passed | per-thread integer expression with EXEC masking | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_sub_co_ci_u32_e32` | VOP2, Wave32; VCC_LO lane input; general SRC0, VGPR VSRC1 and VDST; unsigned S0 minus S1 with borrow input and output | `52060480` | yes | yes | three-way passed | per-thread integer expression with EXEC masking | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `v_subrev_co_ci_u32_e32` | VOP2, Wave32; VCC_LO lane input; general SRC0, VGPR VSRC1 and VDST; unsigned S1 minus S0 with borrow input and output | `540606C2` | yes | yes | three-way passed | per-thread integer expression with EXEC masking | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
<!-- status:instructions:end -->
|
||||
|
||||
## Automated three-way comparison
|
||||
|
||||
LLVM 23.1.6, the production decoder and the independent reference decoder
|
||||
matched 650 instructions across ten streams: the eight synthetic fixtures,
|
||||
matched 1,088 instructions across 18 streams: 16 synthetic fixtures,
|
||||
a high-register sequence and an operand matrix assembled by LLVM.
|
||||
The harness checks byte offsets, widths, encoded bytes from LLVM, mnemonic
|
||||
and operands, and the typed reference operation against the production
|
||||
operation. It covers all 42 compute forms in this document.
|
||||
operation. It covers 124 instruction forms.
|
||||
|
||||
The matrix checks the 81 inline integer selectors in VOP1, SOP1, SOPC and
|
||||
SOP2, forced literals that could otherwise be inline, literal selection in
|
||||
@@ -158,7 +217,7 @@ operands, and zero and nonzero forward branch displacements. The decoder
|
||||
trace exposes MUBUF operands independently of the synthetic execution ABI,
|
||||
which still requires the original index and resource bindings.
|
||||
|
||||
Five malformed LLVM probes produced diagnostics, and 25 valid encodings
|
||||
Five malformed LLVM probes produced diagnostics, and 27 valid encodings
|
||||
or disassemblable branch sequences were deliberately rejected by both Xenora
|
||||
decoders. Both Xenora decoders also reject all 37 interior truncation offsets
|
||||
in the add fixture and every case in the unsupported-encoding list.
|
||||
|
||||
@@ -28,15 +28,15 @@ acceptance remain outside the verified count. All results concern synthetic fixt
|
||||
| SOP2 | 51 | 33 | 33 | 33 | 33 | 33 | 0 | 0 | 12 |
|
||||
| SOPC | 18 | 12 | 12 | 12 | 12 | 12 | 1 | 1 | 7 |
|
||||
| SOPK | 27 | 17 | 16 | 17 | 17 | 17 | 1 | 1 | 5 |
|
||||
| SOPP | 36 | 6 | 0 | 6 | 6 | 6 | 4 | 4 | 0 |
|
||||
| SOPP | 36 | 6 | 6 | 6 | 6 | 6 | 4 | 4 | 0 |
|
||||
| VINTRP | 3 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 0 |
|
||||
| VOP1 | 81 | 7 | 6 | 7 | 7 | 7 | 1 | 1 | 11 |
|
||||
| VOP2 | 47 | 20 | 18 | 20 | 20 | 20 | 7 | 7 | 11 |
|
||||
| VOP3 | 416 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 12 |
|
||||
| VOP2 | 47 | 24 | 22 | 24 | 24 | 24 | 7 | 7 | 11 |
|
||||
| VOP3 | 416 | 28 | 28 | 28 | 28 | 28 | 1 | 1 | 17 |
|
||||
| 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 | 126 | 114 | 130 | 126 | 126 | 18 | 18 | 76 |
|
||||
| VOPC | 190 | 28 | 44 | 44 | 44 | 44 | 0 | 0 | 9 |
|
||||
| **Total** | 1465 | 169 | 179 | 189 | 185 | 185 | 18 | 18 | 83 |
|
||||
|
||||
## Unsupported operand variants
|
||||
|
||||
@@ -50,9 +50,16 @@ The table counts distinct variant names per family across registry operand rules
|
||||
| SOPC | `sopc_scalar` | `src_exec`, `src_float_inline`, `src_m0`, `src_special`, `src_ttmp`, `src_vcc`, `two_literals` |
|
||||
| SOPK | `sopk_compare` | `dst_exec`, `dst_m0`, `dst_null`, `dst_ttmp`, `dst_vcc` |
|
||||
| SOPK | `sopk_sgpr` | `dst_exec`, `dst_m0`, `dst_null`, `dst_ttmp`, `dst_vcc` |
|
||||
| SOPP | `sopp_branch` | None listed |
|
||||
| SOPP | `sopp_end` | None listed |
|
||||
| SOPP | `sopp_wait` | None listed |
|
||||
| VOP1 | `vop1_swap` | `src_exec`, `src_float_inline`, `src_inline`, `src_literal`, `src_m0`, `src_null`, `src_sgpr`, `src_special`, `src_ttmp`, `src_vcc` |
|
||||
| VOP1 | `vop1_vgpr` | `src_exec`, `src_float_inline`, `src_m0`, `src_null`, `src_special`, `src_ttmp`, `src_vcc_hi` |
|
||||
| VOP2 | `vop2_vcc` | `src_exec`, `src_float_inline`, `src_m0`, `src_null`, `src_special`, `src_ttmp`, `src_vcc_hi` |
|
||||
| VOP2 | `vop2_vgpr` | `src_exec`, `src_float_inline`, `src_m0`, `src_null`, `src_special`, `src_ttmp`, `src_vcc_hi` |
|
||||
| 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_cmp_vgpr2` | `dst_exec`, `dst_m0`, `dst_null`, `dst_ttmp`, `dst_vcc_hi`, `modifiers`, `src2`, `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_half` | `src_exec`, `src_float_inline`, `src_literal`, `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` |
|
||||
@@ -48,20 +48,19 @@ file of its encoding (`rdna2/vop3.toml`) and has exactly these fields:
|
||||
| `of` | The `name` of the declared base form |
|
||||
| `family` | The encoding family of this variant; must differ from the form's |
|
||||
| `opcode` | The XML opcode in that family |
|
||||
| `operands` | An operand rule of that family whose kind can encode the base form (today `vop3_vgpr2` for VOP2 vector forms) |
|
||||
| `operands` | An operand rule of that family that can encode the base form (`vop3_vgpr2` for VOP2 vector forms, `vop3_cmp_vgpr2` for VOPC integer compares) |
|
||||
| `spec`, `verify` | As for a form |
|
||||
|
||||
Everything else (operation, signedness, effects, source order) is inherited
|
||||
from the base form, and the XML check runs on that inherited declaration with
|
||||
the variant's family, opcode and operand rule, so the VOP3 operand widths and
|
||||
formats must agree with it. The generator emits one enum per variant rule (`VectorAluVop3Op` for
|
||||
`vop3_vgpr2`) holding exactly the declared variants, with `from_word` (encoding
|
||||
The variant inherits the operation, signedness, source order and SCC and EXEC
|
||||
effects. Its operand rule determines where the result is written. The XML
|
||||
check uses the variant's family, opcode and operand rule to validate the
|
||||
inherited declaration. The generator emits one enum per variant rule
|
||||
(`VectorAluVop3Op` or `VectorCompareVop3Op`) with `from_word` (encoding
|
||||
bits, then an explicit match on the OP field), `base()` (the inherited form),
|
||||
`assembly_name()` and `semantics()`, and one `FORMS` row per variant after the
|
||||
forms. Because the enum has no undeclared members, an instruction cannot name a
|
||||
VOP3 encoding that does not exist. Every explicit XML operand of the variant,
|
||||
destination included, must have the data format of the base operand in the same
|
||||
role (destination, then the sources in rule order). A variant-only rule says so
|
||||
VOP3 encoding that does not exist. Corresponding explicit XML operands must
|
||||
have the same data format by role. A variant-only rule says so
|
||||
in the data (`variant_only = true`), so the RDNA2 planner does not count it as a
|
||||
rule that can host new forms. A
|
||||
variant-only rule (one marked `variant_of` in the generator) cannot be used by a
|
||||
@@ -75,7 +74,15 @@ the registry: VGPR destination, two VGPR sources, ABS, OP_SEL, CLAMP, OMOD and
|
||||
NEG clear, and SRC2 the assembler's unused inline zero. `v_add_nc_u32_e64` is its
|
||||
first variant; adding the VOP3 encoding of another VOP2 form under this rule is
|
||||
one `[[encoding_variant]]` entry. Wider VOP3 operand rules (scalar and inline
|
||||
sources, legal modifiers) come with the VOP3 batch.
|
||||
sources, legal modifiers) need separate rules.
|
||||
|
||||
`vop3_cmp_vgpr2` uses the same VGPR source and modifier restrictions and
|
||||
specifies a scalar destination. It requires a base form with a `lane_mask`
|
||||
write to implicit VCC, and generates an `sdst_lane_mask` effect on the
|
||||
variant row. The generator checks the base VCC output and the variant's
|
||||
explicit scalar mask destination against the XML. An SDST of 106 selects
|
||||
`vcc_lo`. See [the compare contract](vector-compare.md#11-vop3a-encoding-_e64)
|
||||
for Wave32 lowering and allowed consumers.
|
||||
|
||||
## Fields
|
||||
|
||||
@@ -111,16 +118,16 @@ error.
|
||||
| `variant` | Rust enum variant of the typed operation | CamelCase, e.g. `AddU32` |
|
||||
| `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` |
|
||||
| `carry_in` | Implicit carry, borrow or select input | `none`, `scc` for unsigned scalar `add` and `sub` and required for scalar `cselect`, `vcc` for the Wave32 VOP2 select and carry forms |
|
||||
| `width` | Operand and result width in bits (operand width for compares) | `32`, `16` with `vopc_vcc_half`, 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` |
|
||||
| `shift_amount` | `lshl_add` only: the fixed left shift of S0 before the add | `1` to `4`; required for `lshl_add`, rejected elsewhere |
|
||||
| `shift_count_bits` | Shifts only: the low bits of the count source used as the count: S1, or S0 for a vector form with `source_order = "reversed"`. Scalar forms mask it in the generated evaluation, vector forms in their MSL template; the XML must list the count source as unsigned | `5` (log2 of `width`); required for shifts, rejected elsewhere |
|
||||
| `scc` | What the form writes to SCC | `carry_out`, `borrow`, `signed_overflow`, `nonzero`, `relation` (SOPC and SOPK compares only), `selected_src0` (min and max: S0 won the strict compare, so a tie gives 0), `unchanged` |
|
||||
| `vcc`, `exec` | Implicit effect on VCC and EXEC | `unchanged`; `vcc` is `lane_mask` exactly for the VOPC compares (VCC_LO bit n = EXEC[n] & test, fully written; VCC_HI unknown afterwards, see [vector-compare.md](vector-compare.md)); `exec` must be `unchanged` (explicit destinations are covered by the operand rule) |
|
||||
| `wave` | Wave sizes the form is valid in | `wave32` for VOPC compares and VOP1 integer forms in the Wave32 compute fixture ABI, `any` for other registry forms |
|
||||
| `vcc`, `exec` | Implicit effect on VCC and EXEC | `vcc` is `lane_mask` for [VOPC compares](vector-compare.md) and the three [VOP2 carry forms](vector-vcc.md). These write all of VCC_LO, zero inactive lane bits and leave VCC_HI unknown. Other forms declare `vcc` as `unchanged`. All forms declare `exec` as `unchanged`. Operand rules cover explicit destinations. |
|
||||
| `wave` | Wave sizes the form is valid in | `wave32` for SOPP controls, VOPC compares, VOP1 integer forms and VCC-reading VOP2 forms in the Wave32 compute fixture ABI, `any` for other registry forms |
|
||||
| `operands` | Name of an `[operand_rules]` entry for the same family | e.g. `sop2_sgpr` |
|
||||
| `spec` | References `{ document, section, page }` | at least one `guide` reference with a page above 0 |
|
||||
| `verify` | Evidence the form needs before it counts as verified | `reference`, `independent`, `metal`, `llvm_encoding` |
|
||||
@@ -162,11 +169,11 @@ and one literal dword. The move copies the source and leaves SCC unchanged.
|
||||
The destination vocabulary preserves the original decoder subset of the
|
||||
RDNA 2 guide sections 5.3 and 12.3.
|
||||
|
||||
Vector forms (operand rules `vop2_vgpr` and `vop2_vgpr2`, kind `vector`; both
|
||||
Binary vector forms (operand rules `vop2_vgpr` and `vop2_vgpr2`, kind `vector`; both
|
||||
generate the one `VectorAluOp` enum, whose `operand_rule()` tells the decoder
|
||||
which rule a form uses) use a separate table:
|
||||
the pair picks the per-lane `VectorBinary` the MSL lowering uses, and `scc`
|
||||
must be `unchanged` (VOP2 integer forms write no SCC, VCC or EXEC):
|
||||
must be `unchanged` (these binary forms write no SCC, VCC or EXEC):
|
||||
|
||||
| `operation` / `signedness` | `VectorBinary` |
|
||||
| --- | --- |
|
||||
@@ -177,6 +184,12 @@ must be `unchanged` (VOP2 integer forms write no SCC, VCC or EXEC):
|
||||
| `and`, `or`, `xor` / `bitwise` | `And`, `Or`, `Xor` |
|
||||
| `lshl`, `lshr` / `bitwise`, `ashr` / `signed` (with `shift_count_bits = 5`) | `ShiftLeft`, `ShiftRight`, `ArithmeticShiftRight` |
|
||||
|
||||
The [Wave32 VOP2 select and carry forms](vector-vcc.md) use `vop2_vcc` with
|
||||
the general SRC0 domain and an implicit VCC input. The generator checks the
|
||||
direction of each fieldless VCC operand in the pinned XML. The three arithmetic
|
||||
forms also declare a lane-mask output and use the same reverse-source mechanism
|
||||
as the no-carry subtraction.
|
||||
|
||||
`vop2_vgpr2` is the VGPR-only subset (SRC0 256-511) that the hand-written decoder
|
||||
accepted for `v_and_b32`, `v_or_b32`, `v_xor_b32`, `v_lshlrev_b32`, `v_lshrrev_b32`
|
||||
and `v_ashrrev_i32` before they moved into the registry (#215 M27); widening them
|
||||
@@ -184,13 +197,17 @@ 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 16-bit rule
|
||||
`vopc_vcc_half` reads the low half of the same source types and rejects
|
||||
literals (guide sections 6.2, 6.2.5 and 6.8). 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. All three 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.
|
||||
`v_cmpx_*` (EXEC writes), the VOP3 encoding and Wave64 stay unsupported.
|
||||
The VOP3A variants redirect the same Wave32 mask to SDST. EXEC-writing
|
||||
compares (`v_cmpx_*`) and Wave64 stay unsupported.
|
||||
|
||||
A SOPC compare must use an operand rule of the compare kind (`sopc_scalar`: two
|
||||
sources, no destination), a unary operation one of the unary kind (`sop1_sgpr`:
|
||||
@@ -210,6 +227,17 @@ The XML must give SIMM16 as 16-bit `FMT_NUM_I16` (`FMT_NUM_U16` for `unsigned`).
|
||||
The word never takes a literal dword. The details are in
|
||||
[scalar-immediate.md](scalar-immediate.md).
|
||||
|
||||
The SOPP control rules (AMD RDNA 2 ISA guide §§12.5 and 13.1.5) generate
|
||||
`SoppControlOp` for the existing Wave32 compute subset. `sopp_end` accepts
|
||||
`s_endpgm` with zero in SIMM16. `sopp_wait` accepts only `s_waitcnt vmcnt(0)`
|
||||
(`0x3f70`), completing a pending vector load. `sopp_branch` accepts
|
||||
`s_branch`, `s_cbranch_scc0`, `s_cbranch_vccz` and `s_cbranch_execz` with a
|
||||
nonnegative signed SIMM16 displacement in dwords from the next instruction.
|
||||
The decoder and compiler require a valid target boundary. The conditional
|
||||
branches read SCC, VCC_LO or EXEC_LO without writing those registers.
|
||||
Other SOPP forms, including `s_nop`, the nonzero branches, `s_sendmsg`,
|
||||
`s_trap`, `s_sethalt` and `s_setprio`, remain unsupported.
|
||||
|
||||
Behaviour is chosen only from these declared fields, never from the mnemonic.
|
||||
|
||||
## What the validator checks
|
||||
@@ -219,8 +247,9 @@ 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, 136 and 168 for 16-bit forms, 160 and 224 for 64-bit
|
||||
forms) 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
|
||||
|
||||
@@ -75,18 +75,18 @@ 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.
|
||||
The decoder, translator and both reference interpreters 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 registry
|
||||
uses `vopc_vcc_half` for the 16-bit forms and `vopc_vcc_pair` for the 64-bit
|
||||
forms.
|
||||
|
||||
- 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).
|
||||
There is no literal source.
|
||||
SRC0 accepts a VGPR, a known SGPR, `vcc_lo` or an inline integer
|
||||
(for example, −1 supplies `0xffff`). VSRC1 is a VGPR. Literals are rejected.
|
||||
- 64-bit forms read a pair: v[n:n+1] with n <= 254, an even-aligned
|
||||
s[2k:2k+1] with k <= 52 (3.6.3), or an inline integer, which is
|
||||
sign-extended to 64 bits (-1 is all ones, also for `_u64`; a reading of
|
||||
@@ -122,10 +122,10 @@ this wave (all 32 except in a final partial wave, see 7). As an unsigned
|
||||
## 4. Rejected (controlled translation/reference error, never a silent no-op)
|
||||
|
||||
- V_CMPX_* (writes EXEC: divergent execution; needs its own contract).
|
||||
- The VOP3 encoding of any compare (arbitrary SGPR destination, modifiers).
|
||||
- VOP3A compares outside the integer subset in section 11.
|
||||
- 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,15 @@ 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 1,572 16-bit and 4,640
|
||||
64-bit cases, plus compiler rejection of out-of-contract programs. LLVM
|
||||
assembled `vector-compare-16.s` and `vector-compare-64.s` cover all 28 opcodes
|
||||
in the decoder's fixture inventory. The native Metal gate runs both
|
||||
`vopc16_match_the_guide_on_native_metal` and
|
||||
`vopc64_match_the_guide_on_native_metal`. On a local Apple M5 with API and
|
||||
shader validation, all 4,640 64-bit cases (3,818 programs) agree with the
|
||||
oracle. On a local Apple M5 under API and shader validation, all 1,572 16-bit cases (1,420 programs) agree; independent acceptance 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 +274,12 @@ 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. 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`, SDWA, DPP or float compares. VOP3 encodings cover the 32-bit compares only.
|
||||
- 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
|
||||
@@ -284,3 +288,38 @@ locally on Apple M5 Pro. It is not agreement with RDNA 2 or Xbox hardware.
|
||||
- Each thread recomputes up to 32 lanes per compare. The cost grows with the
|
||||
compare's dependency chain. That is fine for fixtures, and no performance is
|
||||
claimed.
|
||||
|
||||
## 11. VOP3A encoding (`_e64`)
|
||||
|
||||
All sixteen 32-bit signed and unsigned compares in section 2 also have a 64-bit
|
||||
VOP3A encoding. The pinned AMD XML supplies each opcode. Bits 7:0 of the first
|
||||
word are the scalar destination selector (SDST), in the field named VDST.
|
||||
Selectors 0–105 name scalar general-purpose registers (SGPRs), and 106 names
|
||||
`vcc_lo`. All other destinations are rejected. Both SRC0 and SRC1 must name
|
||||
vector general-purpose registers (VGPRs), and the unused SRC2 must be the
|
||||
assembler's inline-zero selector (128). ABS, OP_SEL, CLAMP, OMOD and NEG must
|
||||
be clear. The guide describes CLAMP on compares as enabling floating-point
|
||||
exception signaling (§6.5, p. 48 and §12.9.1, p. 162).
|
||||
|
||||
The AMD guide's compare-specific text (§3.9, pp. 19–20 and §13.3.3, p. 252)
|
||||
specifies an SGPR destination for this encoding. The generic VDST label in
|
||||
§12.9.1 (p. 162) and §13.3.4 Table 82 (pp. 257–258) describes the VOP3A field
|
||||
as a VGPR destination. The pinned XML identifies VDST for these compares as
|
||||
`OPR_SREG`, with the Wave64 pair described by `FMT_NUM_M64`. The Wave32 write
|
||||
occupies one 32-bit SGPR. The guide defines 32 work-items in §2.1 (pp. 7–8),
|
||||
32-bit SGPRs in §3.1 Table 2 (p. 12) and one compare result bit per lane in
|
||||
§12.9 (p. 150). Wave64 stays unsupported.
|
||||
|
||||
LLVM 23 `llvm-mc` for gfx1030 with `+wavefrontsize32` assembles
|
||||
`v_cmp_eq_u32_e64 s4, v1, v2` as bytes `04 00 c2 d4 01 05 02 02`.
|
||||
Selecting `vcc_lo` changes the first byte to `6a`. The decoder tests cover
|
||||
the assembler's words for all sixteen forms. This is encoding evidence.
|
||||
|
||||
The compare replaces all 32 bits of SDST with the lane mask from section 3,
|
||||
including zero bits for inactive and absent lanes. It leaves SCC and EXEC
|
||||
unchanged. VCC is written only when SDST selects `vcc_lo`, which uses the
|
||||
same lowering and consumers as the VOPC form, including `s_cbranch_vccz`.
|
||||
Every other SDST is tracked as a runtime-only SGPR result, including under
|
||||
empty EXEC. Translation rejects later reads of that result, including reads
|
||||
through resource descriptors. The runtime branch region rules in section 6
|
||||
also apply here.
|
||||
@@ -0,0 +1,42 @@
|
||||
# Wave32 vector select, carry and borrow
|
||||
|
||||
The gfx1030 compute fixture ABI supports four 32-bit vector two-operand
|
||||
instruction (VOP2) forms that read the vector condition code (VCC).
|
||||
In Wave32, bit `n` of `VCC_LO` supplies lane `n`'s input `c`.
|
||||
The AMD RDNA 2 guide describes the operations in section 12.7, the VOP2 word
|
||||
in section 13.3.1, and the execution and condition masks in sections 3.3 and 3.9.
|
||||
|
||||
| Instruction | Active lane destination | Active lane VCC output |
|
||||
| --- | --- | --- |
|
||||
| `v_cndmask_b32_e32` | S1 if c is set, S0 otherwise | Preserved |
|
||||
| `v_add_co_ci_u32_e32` | Low 32 bits of S0 + S1 + c | Exact sum reaches 2³² |
|
||||
| `v_sub_co_ci_u32_e32` | Low 32 bits of S0 − S1 − c | S1 + c exceeds S0 |
|
||||
| `v_subrev_co_ci_u32_e32` | Low 32 bits of S1 − S0 − c | S0 + c exceeds S1 |
|
||||
|
||||
Section 12.7 prints a reverse-subtract flag expression that conflicts with its
|
||||
prose and destination equation. Xenora uses unsigned borrow from the stated
|
||||
reverse subtraction, consistent with section 12.12's `v_subrev_co_u32` when
|
||||
the incoming borrow is zero.
|
||||
|
||||
Inactive lanes retain the old vector destination (VDST). Section 3.9
|
||||
describes a fully written VCC mask and defines carry-out in terms of executing
|
||||
lanes. Under that reading, inactive lanes contribute zero to a carry or borrow
|
||||
output. Section 3.3 says scalar-register-writing vector ALU instructions
|
||||
still execute under empty EXEC, so the carry output is a zero mask.
|
||||
The synthetic ABI also zeros
|
||||
absent lanes in a final short wave when it constructs a new mask.
|
||||
The scalar condition code (SCC) and EXEC are preserved by these forms.
|
||||
|
||||
The general SRC0 subset includes vector general-purpose registers (VGPRs),
|
||||
scalar registers s0–s105, `vcc_lo`, inline integers and one literal word.
|
||||
VSRC1 and VDST are VGPRs. Translated scalar sources must be known or supplied
|
||||
by a translated VCC result. The pinned XML lists the VCC input on all four
|
||||
forms and an additional VCC output on the three arithmetic forms. VOP3
|
||||
encodings with explicit scalar conditions and VOP3B carry-out-only forms
|
||||
are outside this subset.
|
||||
|
||||
The Metal lowering reuses the compare mask's replay of the current wave's
|
||||
input lanes to form carry and borrow masks. The original `vector-vcc.s`
|
||||
fixture chains all four operations. LLVM checks encoding, and the guide-derived
|
||||
oracle checks both CPU interpreters. `vop2_vcc_matches_guide_on_native_metal` passes on a local
|
||||
Apple M5 under API and shader validation; independent acceptance is pending. The expectations are derived from the public AMD specification (class B).
|
||||
+714
-6
@@ -53,7 +53,7 @@ llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "s_waitcnt vmcnt(0)"
|
||||
encoding = "SOPP, exact immediate `0x3f70`; other counters disabled by their maximum values"
|
||||
encoding = "SOPP, exact immediate `0x3f70`; other counters disabled by their maximum values (semantic registry)"
|
||||
representation = "4 B"
|
||||
lowering = "verified load wait"
|
||||
reference = "implemented"
|
||||
@@ -87,6 +87,330 @@ recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_mul_i32_i24_e64"
|
||||
encoding = "VOP3A, Wave32; VGPR destination and two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; inactive lanes keep VDST; the operation of `v_mul_i32_i24_e32`"
|
||||
representation = "8 B"
|
||||
lowering = "per-thread typed integer template of the VOP2 form"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_mul_hi_i32_i24_e64"
|
||||
encoding = "VOP3A, Wave32; VGPR destination and two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; inactive lanes keep VDST; the operation of `v_mul_hi_i32_i24_e32`"
|
||||
representation = "8 B"
|
||||
lowering = "per-thread typed integer template of the VOP2 form"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_mul_u32_u24_e64"
|
||||
encoding = "VOP3A, Wave32; VGPR destination and two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; inactive lanes keep VDST; the operation of `v_mul_u32_u24_e32`"
|
||||
representation = "8 B"
|
||||
lowering = "per-thread typed integer template of the VOP2 form"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_mul_hi_u32_u24_e64"
|
||||
encoding = "VOP3A, Wave32; VGPR destination and two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; inactive lanes keep VDST; the operation of `v_mul_hi_u32_u24_e32`"
|
||||
representation = "8 B"
|
||||
lowering = "per-thread typed integer template of the VOP2 form"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_min_i32_e64"
|
||||
encoding = "VOP3A, Wave32; VGPR destination and two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; inactive lanes keep VDST; the operation of `v_min_i32_e32`"
|
||||
representation = "8 B"
|
||||
lowering = "per-thread typed integer template of the VOP2 form"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_max_i32_e64"
|
||||
encoding = "VOP3A, Wave32; VGPR destination and two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; inactive lanes keep VDST; the operation of `v_max_i32_e32`"
|
||||
representation = "8 B"
|
||||
lowering = "per-thread typed integer template of the VOP2 form"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_min_u32_e64"
|
||||
encoding = "VOP3A, Wave32; VGPR destination and two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; inactive lanes keep VDST; the operation of `v_min_u32_e32`"
|
||||
representation = "8 B"
|
||||
lowering = "per-thread typed integer template of the VOP2 form"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_max_u32_e64"
|
||||
encoding = "VOP3A, Wave32; VGPR destination and two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; inactive lanes keep VDST; the operation of `v_max_u32_e32`"
|
||||
representation = "8 B"
|
||||
lowering = "per-thread typed integer template of the VOP2 form"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_xnor_b32_e64"
|
||||
encoding = "VOP3A, Wave32; VGPR destination and two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; inactive lanes keep VDST; the operation of `v_xnor_b32_e32`"
|
||||
representation = "8 B"
|
||||
lowering = "per-thread typed integer template of the VOP2 form"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_sub_nc_u32_e64"
|
||||
encoding = "VOP3A, Wave32; VGPR destination and two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; inactive lanes keep VDST; the operation of `v_sub_nc_u32_e32`"
|
||||
representation = "8 B"
|
||||
lowering = "per-thread typed integer template of the VOP2 form"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_subrev_nc_u32_e64"
|
||||
encoding = "VOP3A, Wave32; VGPR destination and two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; inactive lanes keep VDST; the operation of `v_subrev_nc_u32_e32`"
|
||||
representation = "8 B"
|
||||
lowering = "per-thread typed integer template of the VOP2 form"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_lt_i32_e64"
|
||||
encoding = "VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_lt_i32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error"
|
||||
representation = "8 B"
|
||||
lowering = "per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_eq_i32_e64"
|
||||
encoding = "VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_eq_i32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error"
|
||||
representation = "8 B"
|
||||
lowering = "per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_le_i32_e64"
|
||||
encoding = "VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_le_i32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error"
|
||||
representation = "8 B"
|
||||
lowering = "per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_gt_i32_e64"
|
||||
encoding = "VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_gt_i32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error"
|
||||
representation = "8 B"
|
||||
lowering = "per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_ne_i32_e64"
|
||||
encoding = "VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_ne_i32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error"
|
||||
representation = "8 B"
|
||||
lowering = "per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_ge_i32_e64"
|
||||
encoding = "VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_ge_i32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error"
|
||||
representation = "8 B"
|
||||
lowering = "per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_f_i32_e64"
|
||||
encoding = "VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_f_i32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error"
|
||||
representation = "8 B"
|
||||
lowering = "per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_t_i32_e64"
|
||||
encoding = "VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_t_i32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error"
|
||||
representation = "8 B"
|
||||
lowering = "per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_lt_u32_e64"
|
||||
encoding = "VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_lt_u32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error"
|
||||
representation = "8 B"
|
||||
lowering = "per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_eq_u32_e64"
|
||||
encoding = "VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_eq_u32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error"
|
||||
representation = "8 B"
|
||||
lowering = "per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_le_u32_e64"
|
||||
encoding = "VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_le_u32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error"
|
||||
representation = "8 B"
|
||||
lowering = "per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_gt_u32_e64"
|
||||
encoding = "VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_gt_u32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error"
|
||||
representation = "8 B"
|
||||
lowering = "per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_ne_u32_e64"
|
||||
encoding = "VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_ne_u32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error"
|
||||
representation = "8 B"
|
||||
lowering = "per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_ge_u32_e64"
|
||||
encoding = "VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_ge_u32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error"
|
||||
representation = "8 B"
|
||||
lowering = "per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_f_u32_e64"
|
||||
encoding = "VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_f_u32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error"
|
||||
representation = "8 B"
|
||||
lowering = "per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_t_u32_e64"
|
||||
encoding = "VOP3A, Wave32; SGPR destination s0-s105 or vcc_lo, D[n] = EXEC_LO[n] & test, fully written; two VGPR inputs, modifier fields clear, SRC2 encoded as inline zero; the relation of `v_cmp_t_u32_e32`; reading a lane-derived mask from an SGPR other than vcc_lo is a translation error"
|
||||
representation = "8 B"
|
||||
lowering = "per-thread Wave32 mask, as the VOPC form; runtime s_cbranch_vccz through vcc_lo"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "buffer_store_dword"
|
||||
encoding = "MUBUF, VGPR data/index, four normal SGPRs, `idxen`, zero offsets and remaining flags"
|
||||
@@ -113,7 +437,7 @@ llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "s_endpgm"
|
||||
encoding = "SOPP, zero immediate"
|
||||
encoding = "SOPP, zero immediate (semantic registry)"
|
||||
representation = "4 B"
|
||||
lowering = "verified termination"
|
||||
reference = "implemented"
|
||||
@@ -1190,9 +1514,345 @@ recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_lt_i16_e32"
|
||||
encoding = "VOPC, Wave32; VGPR, known SGPR, VCC_LO or inline integer SRC0; VGPR VSRC1; signed low 16 bits; VCC_LO[n] = EXEC_LO[n] & (S0 < S1), fully written"
|
||||
representation = "`7D120702`"
|
||||
lowering = "per-thread Wave32 mask with low-half operands"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_eq_i16_e32"
|
||||
encoding = "VOPC, Wave32; VGPR, known SGPR, VCC_LO or inline integer SRC0; VGPR VSRC1; signed low 16 bits; VCC_LO[n] = EXEC_LO[n] & (S0 == S1), fully written"
|
||||
representation = "`7D140702`"
|
||||
lowering = "per-thread Wave32 mask with low-half operands"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_le_i16_e32"
|
||||
encoding = "VOPC, Wave32; VGPR, known SGPR, VCC_LO or inline integer SRC0; VGPR VSRC1; signed low 16 bits; VCC_LO[n] = EXEC_LO[n] & (S0 <= S1), fully written"
|
||||
representation = "`7D160702`"
|
||||
lowering = "per-thread Wave32 mask with low-half operands"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_gt_i16_e32"
|
||||
encoding = "VOPC, Wave32; VGPR, known SGPR, VCC_LO or inline integer SRC0; VGPR VSRC1; signed low 16 bits; VCC_LO[n] = EXEC_LO[n] & (S0 > S1), fully written"
|
||||
representation = "`7D180702`"
|
||||
lowering = "per-thread Wave32 mask with low-half operands"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_ne_i16_e32"
|
||||
encoding = "VOPC, Wave32; VGPR, known SGPR, VCC_LO or inline integer SRC0; VGPR VSRC1; signed low 16 bits; VCC_LO[n] = EXEC_LO[n] & (S0 != S1), fully written"
|
||||
representation = "`7D1A0702`"
|
||||
lowering = "per-thread Wave32 mask with low-half operands"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_ge_i16_e32"
|
||||
encoding = "VOPC, Wave32; VGPR, known SGPR, VCC_LO or inline integer SRC0; VGPR VSRC1; signed low 16 bits; VCC_LO[n] = EXEC_LO[n] & (S0 >= S1), fully written"
|
||||
representation = "`7D1C0702`"
|
||||
lowering = "per-thread Wave32 mask with low-half operands"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_lt_u16_e32"
|
||||
encoding = "VOPC, Wave32; VGPR, known SGPR, VCC_LO or inline integer SRC0; VGPR VSRC1; unsigned low 16 bits; VCC_LO[n] = EXEC_LO[n] & (S0 < S1), fully written"
|
||||
representation = "`7D520702`"
|
||||
lowering = "per-thread Wave32 mask with low-half operands"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_eq_u16_e32"
|
||||
encoding = "VOPC, Wave32; VGPR, known SGPR, VCC_LO or inline integer SRC0; VGPR VSRC1; unsigned low 16 bits; VCC_LO[n] = EXEC_LO[n] & (S0 == S1), fully written"
|
||||
representation = "`7D540702`"
|
||||
lowering = "per-thread Wave32 mask with low-half operands"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_le_u16_e32"
|
||||
encoding = "VOPC, Wave32; VGPR, known SGPR, VCC_LO or inline integer SRC0; VGPR VSRC1; unsigned low 16 bits; VCC_LO[n] = EXEC_LO[n] & (S0 <= S1), fully written"
|
||||
representation = "`7D560702`"
|
||||
lowering = "per-thread Wave32 mask with low-half operands"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_gt_u16_e32"
|
||||
encoding = "VOPC, Wave32; VGPR, known SGPR, VCC_LO or inline integer SRC0; VGPR VSRC1; unsigned low 16 bits; VCC_LO[n] = EXEC_LO[n] & (S0 > S1), fully written"
|
||||
representation = "`7D580702`"
|
||||
lowering = "per-thread Wave32 mask with low-half operands"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_ne_u16_e32"
|
||||
encoding = "VOPC, Wave32; VGPR, known SGPR, VCC_LO or inline integer SRC0; VGPR VSRC1; unsigned low 16 bits; VCC_LO[n] = EXEC_LO[n] & (S0 != S1), fully written"
|
||||
representation = "`7D5A0702`"
|
||||
lowering = "per-thread Wave32 mask with low-half operands"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cmp_ge_u16_e32"
|
||||
encoding = "VOPC, Wave32; VGPR, known SGPR, VCC_LO or inline integer SRC0; VGPR VSRC1; unsigned low 16 bits; VCC_LO[n] = EXEC_LO[n] & (S0 >= S1), fully written"
|
||||
representation = "`7D5C0702`"
|
||||
lowering = "per-thread Wave32 mask with low-half operands"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
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 known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; 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 known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; 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 known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; 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 known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; 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 known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; 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 known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; 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 known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; 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 known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; 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 known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; 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 known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; 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 known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; 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 known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; 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 known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; 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 known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; 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 known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; 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 known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "assembled fixture matched"
|
||||
|
||||
[[instruction]]
|
||||
form = "s_cbranch_scc0"
|
||||
encoding = "Nonnegative signed dword displacement"
|
||||
encoding = "Nonnegative signed dword displacement (semantic registry)"
|
||||
representation = "`BF840002`"
|
||||
lowering = "resolved conditional branch"
|
||||
reference = "implemented"
|
||||
@@ -1204,7 +1864,7 @@ llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "s_branch"
|
||||
encoding = "Nonnegative signed dword displacement"
|
||||
encoding = "Nonnegative signed dword displacement (semantic registry)"
|
||||
representation = "`BF820001`"
|
||||
lowering = "resolved branch"
|
||||
reference = "implemented"
|
||||
@@ -1312,7 +1972,7 @@ llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "s_cbranch_execz"
|
||||
encoding = "Nonnegative signed dword displacement"
|
||||
encoding = "Nonnegative signed dword displacement (semantic registry)"
|
||||
representation = "`BF880001`"
|
||||
lowering = "resolved Wave32 EXEC_LO zero check"
|
||||
reference = "implemented"
|
||||
@@ -1324,7 +1984,7 @@ llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "s_cbranch_vccz"
|
||||
encoding = "Nonnegative signed dword displacement"
|
||||
encoding = "Nonnegative signed dword displacement (semantic registry)"
|
||||
representation = "`BF860001`"
|
||||
lowering = "resolved Wave32 VCC_LO zero check, or a wave-uniform join select after a vector compare"
|
||||
reference = "implemented"
|
||||
@@ -1550,6 +2210,54 @@ recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_cndmask_b32_e32"
|
||||
encoding = "VOP2, Wave32; VCC_LO lane input; general SRC0, VGPR VSRC1 and VDST; select S1 when the VCC_LO lane bit is set, otherwise S0"
|
||||
representation = "`020402C1`"
|
||||
lowering = "per-thread integer expression with EXEC masking"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_add_co_ci_u32_e32"
|
||||
encoding = "VOP2, Wave32; VCC_LO lane input; general SRC0, VGPR VSRC1 and VDST; unsigned addition with carry input and output"
|
||||
representation = "`50040481`"
|
||||
lowering = "per-thread integer expression with EXEC masking"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_sub_co_ci_u32_e32"
|
||||
encoding = "VOP2, Wave32; VCC_LO lane input; general SRC0, VGPR VSRC1 and VDST; unsigned S0 minus S1 with borrow input and output"
|
||||
representation = "`52060480`"
|
||||
lowering = "per-thread integer expression with EXEC masking"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "v_subrev_co_ci_u32_e32"
|
||||
encoding = "VOP2, Wave32; VCC_LO lane input; general SRC0, VGPR VSRC1 and VDST; unsigned S1 minus S0 with borrow input and output"
|
||||
representation = "`540606C2`"
|
||||
lowering = "per-thread integer expression with EXEC masking"
|
||||
reference = "implemented"
|
||||
cpu = "local known-answer test passed"
|
||||
gpu = "local Apple M5 readback passed; acceptance pending"
|
||||
recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[guest_milestones]
|
||||
X1 = "accepted"
|
||||
X2 = "accepted"
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
0000: t0 = load.u32 input[index]
|
||||
000c: t1 = const.u32 0x00000000
|
||||
000c: t2 = wave.mask v_cmp_eq_u32_e32 t1, t0 exec=0xffffffff
|
||||
0010: t3 = const.u32 0xffffffff
|
||||
0010: t4 = vcc.Select t3, t0, t2
|
||||
0014: t5 = const.u32 0x00000001
|
||||
0014: t6 = vcc.AddCarry.flag t5, t4, t2
|
||||
0014: t7 = wave.carry t6 exec=0xffffffff
|
||||
0014: t8 = vcc.AddCarry t5, t4, t2
|
||||
0018: t9 = const.u32 0x00000000
|
||||
0018: t10 = vcc.SubtractBorrow.flag t9, t8, t7
|
||||
0018: t11 = wave.carry t10 exec=0xffffffff
|
||||
0018: t12 = vcc.SubtractBorrow t9, t8, t7
|
||||
001c: t13 = const.u32 0xfffffffe
|
||||
001c: t14 = vcc.SubtractBorrow.flag t12, t13, t11
|
||||
001c: t15 = wave.carry t14 exec=0xffffffff
|
||||
001c: t16 = vcc.SubtractBorrow t12, t13, t11
|
||||
0024: store.u32 output[index], t15
|
||||
@@ -0,0 +1,63 @@
|
||||
#include <metal_stdlib>
|
||||
using namespace metal;
|
||||
kernel void xenora_compute(
|
||||
device const uint* input [[buffer(0)]],
|
||||
device uint* output [[buffer(1)]],
|
||||
uint index [[thread_position_in_grid]],
|
||||
uint grid [[threads_per_grid]]) {
|
||||
uint t0 = input[index];
|
||||
uint t1 = 0x00000000u;
|
||||
uint t2 = 0u;
|
||||
for (uint lane = 0u; lane < 32u; ++lane) {
|
||||
uint lane_index = (index & ~31u) + lane;
|
||||
if (lane_index >= grid) { break; }
|
||||
uint l0 = input[lane_index];
|
||||
uint pass = (t1 == l0) ? 1u : 0u;
|
||||
t2 |= ((0xffffffffu >> lane) & pass) << lane;
|
||||
}
|
||||
uint t3 = 0xffffffffu;
|
||||
uint t4 = ((t2 >> (index & 31u)) & 1u) != 0u ? t0 : t3;
|
||||
uint t5 = 0x00000001u;
|
||||
uint t6 = uint((ulong(t5) + ulong(t4) + ((t2 >> (index & 31u)) & 1u)) >> 32u);
|
||||
uint t7 = 0u;
|
||||
for (uint lane = 0u; lane < 32u; ++lane) {
|
||||
uint lane_index = (index & ~31u) + lane;
|
||||
if (lane_index >= grid) { break; }
|
||||
uint l0 = input[lane_index];
|
||||
uint l4 = ((t2 >> lane) & 1u) != 0u ? l0 : t3;
|
||||
uint l6 = uint((ulong(t5) + ulong(l4) + ((t2 >> lane) & 1u)) >> 32u);
|
||||
uint pass = l6;
|
||||
t7 |= ((0xffffffffu >> lane) & pass) << lane;
|
||||
}
|
||||
uint t8 = t5 + t4 + ((t2 >> (index & 31u)) & 1u);
|
||||
uint t9 = 0x00000000u;
|
||||
uint t10 = uint(ulong(t8) + ((t7 >> (index & 31u)) & 1u) > ulong(t9));
|
||||
uint t11 = 0u;
|
||||
for (uint lane = 0u; lane < 32u; ++lane) {
|
||||
uint lane_index = (index & ~31u) + lane;
|
||||
if (lane_index >= grid) { break; }
|
||||
uint l0 = input[lane_index];
|
||||
uint l4 = ((t2 >> lane) & 1u) != 0u ? l0 : t3;
|
||||
uint l8 = t5 + l4 + ((t2 >> lane) & 1u);
|
||||
uint l10 = uint(ulong(l8) + ((t7 >> lane) & 1u) > ulong(t9));
|
||||
uint pass = l10;
|
||||
t11 |= ((0xffffffffu >> lane) & pass) << lane;
|
||||
}
|
||||
uint t12 = t9 - t8 - ((t7 >> (index & 31u)) & 1u);
|
||||
uint t13 = 0xfffffffeu;
|
||||
uint t14 = uint(ulong(t13) + ((t11 >> (index & 31u)) & 1u) > ulong(t12));
|
||||
uint t15 = 0u;
|
||||
for (uint lane = 0u; lane < 32u; ++lane) {
|
||||
uint lane_index = (index & ~31u) + lane;
|
||||
if (lane_index >= grid) { break; }
|
||||
uint l0 = input[lane_index];
|
||||
uint l4 = ((t2 >> lane) & 1u) != 0u ? l0 : t3;
|
||||
uint l8 = t5 + l4 + ((t2 >> lane) & 1u);
|
||||
uint l12 = t9 - l8 - ((t7 >> lane) & 1u);
|
||||
uint l14 = uint(ulong(t13) + ((t11 >> lane) & 1u) > ulong(l12));
|
||||
uint pass = l14;
|
||||
t15 |= ((0xffffffffu >> lane) & pass) << lane;
|
||||
}
|
||||
uint t16 = t12 - t13 - ((t11 >> (index & 31u)) & 1u);
|
||||
output[index] = t15;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
0000: t0 = load.u32 input[index]
|
||||
000c: t1 = const.u32 0x00000000
|
||||
0010: t2 = const.u32 0x00000001
|
||||
0014: t3 = const.u32 0x40000001
|
||||
001c: t4 = const.u32 0x00000001
|
||||
0020: t5 = wave.mask v_cmp_f_i32_e64 t0, t3 -> vcc_lo exec=0xffffffff
|
||||
002c: t6 = lshl.b32 t1, t2
|
||||
0030: t7 = xor.b32 t6, t5
|
||||
0034: t8 = wave.mask v_cmp_lt_i32_e64 t0, t3 -> vcc_lo exec=0xffffffff
|
||||
0040: t9 = lshl.b32 t7, t2
|
||||
0044: t10 = xor.b32 t9, t8
|
||||
0048: t11 = wave.mask v_cmp_eq_i32_e64 t0, t3 -> vcc_lo exec=0xffffffff
|
||||
0054: t12 = lshl.b32 t10, t2
|
||||
0058: t13 = xor.b32 t12, t11
|
||||
005c: t14 = wave.mask v_cmp_le_i32_e64 t0, t3 -> vcc_lo exec=0xffffffff
|
||||
0068: t15 = lshl.b32 t13, t2
|
||||
006c: t16 = xor.b32 t15, t14
|
||||
0070: t17 = wave.mask v_cmp_gt_i32_e64 t0, t3 -> vcc_lo exec=0xffffffff
|
||||
007c: t18 = lshl.b32 t16, t2
|
||||
0080: t19 = xor.b32 t18, t17
|
||||
0084: t20 = wave.mask v_cmp_ne_i32_e64 t0, t3 -> vcc_lo exec=0xffffffff
|
||||
0090: t21 = lshl.b32 t19, t2
|
||||
0094: t22 = xor.b32 t21, t20
|
||||
0098: t23 = wave.mask v_cmp_ge_i32_e64 t0, t3 -> vcc_lo exec=0xffffffff
|
||||
00a4: t24 = lshl.b32 t22, t2
|
||||
00a8: t25 = xor.b32 t24, t23
|
||||
00ac: t26 = wave.mask v_cmp_t_i32_e64 t0, t3 -> vcc_lo exec=0xffffffff
|
||||
00b8: t27 = lshl.b32 t25, t2
|
||||
00bc: t28 = xor.b32 t27, t26
|
||||
00c0: t29 = wave.mask v_cmp_f_u32_e64 t0, t3 -> vcc_lo exec=0xffffffff
|
||||
00cc: t30 = lshl.b32 t28, t2
|
||||
00d0: t31 = xor.b32 t30, t29
|
||||
00d4: t32 = wave.mask v_cmp_lt_u32_e64 t0, t3 -> vcc_lo exec=0xffffffff
|
||||
00e0: t33 = lshl.b32 t31, t2
|
||||
00e4: t34 = xor.b32 t33, t32
|
||||
00e8: t35 = wave.mask v_cmp_eq_u32_e64 t0, t3 -> vcc_lo exec=0xffffffff
|
||||
00f4: t36 = lshl.b32 t34, t2
|
||||
00f8: t37 = xor.b32 t36, t35
|
||||
00fc: t38 = wave.mask v_cmp_le_u32_e64 t0, t3 -> vcc_lo exec=0xffffffff
|
||||
0108: t39 = lshl.b32 t37, t2
|
||||
010c: t40 = xor.b32 t39, t38
|
||||
0110: t41 = wave.mask v_cmp_gt_u32_e64 t0, t3 -> vcc_lo exec=0xffffffff
|
||||
011c: t42 = lshl.b32 t40, t2
|
||||
0120: t43 = xor.b32 t42, t41
|
||||
0124: t44 = wave.mask v_cmp_ne_u32_e64 t0, t3 -> vcc_lo exec=0xffffffff
|
||||
0130: t45 = lshl.b32 t43, t2
|
||||
0134: t46 = xor.b32 t45, t44
|
||||
0138: t47 = wave.mask v_cmp_ge_u32_e64 t0, t3 -> vcc_lo exec=0xffffffff
|
||||
0144: t48 = lshl.b32 t46, t2
|
||||
0148: t49 = xor.b32 t48, t47
|
||||
014c: t50 = wave.mask v_cmp_t_u32_e64 t0, t3 -> vcc_lo exec=0xffffffff
|
||||
0158: t51 = lshl.b32 t49, t2
|
||||
015c: t52 = xor.b32 t51, t50
|
||||
0160: t53 = wave.mask v_cmp_eq_u32_e64 t0, t3 -> s8 exec=0xffffffff
|
||||
0168: t54 = wave.mask v_cmp_gt_u32_e64 t3, t0 -> vcc_lo exec=0xffffffff
|
||||
0170: branch.vccz t54 -> 0x0178
|
||||
0174: t56 = xor.b32 t4, t52
|
||||
0178: t57 = join.vccz t54, t56, t52
|
||||
0178: store.u32 output[index], t57
|
||||
@@ -0,0 +1,188 @@
|
||||
#include <metal_stdlib>
|
||||
using namespace metal;
|
||||
kernel void xenora_compute(
|
||||
device const uint* input [[buffer(0)]],
|
||||
device uint* output [[buffer(1)]],
|
||||
uint index [[thread_position_in_grid]],
|
||||
uint grid [[threads_per_grid]]) {
|
||||
uint t0 = input[index];
|
||||
uint t1 = 0x00000000u;
|
||||
uint t2 = 0x00000001u;
|
||||
uint t3 = 0x40000001u;
|
||||
uint t4 = 0x00000001u;
|
||||
uint t5 = 0u;
|
||||
for (uint lane = 0u; lane < 32u; ++lane) {
|
||||
uint lane_index = (index & ~31u) + lane;
|
||||
if (lane_index >= grid) { break; }
|
||||
uint pass = (false) ? 1u : 0u;
|
||||
t5 |= ((0xffffffffu >> lane) & pass) << lane;
|
||||
}
|
||||
uint t6 = t1 << (t2 & 31u);
|
||||
uint t7 = t6 ^ t5;
|
||||
uint t8 = 0u;
|
||||
for (uint lane = 0u; lane < 32u; ++lane) {
|
||||
uint lane_index = (index & ~31u) + lane;
|
||||
if (lane_index >= grid) { break; }
|
||||
uint l0 = input[lane_index];
|
||||
uint pass = (as_type<int>(l0) < as_type<int>(t3)) ? 1u : 0u;
|
||||
t8 |= ((0xffffffffu >> lane) & pass) << lane;
|
||||
}
|
||||
uint t9 = t7 << (t2 & 31u);
|
||||
uint t10 = t9 ^ t8;
|
||||
uint t11 = 0u;
|
||||
for (uint lane = 0u; lane < 32u; ++lane) {
|
||||
uint lane_index = (index & ~31u) + lane;
|
||||
if (lane_index >= grid) { break; }
|
||||
uint l0 = input[lane_index];
|
||||
uint pass = (as_type<int>(l0) == as_type<int>(t3)) ? 1u : 0u;
|
||||
t11 |= ((0xffffffffu >> lane) & pass) << lane;
|
||||
}
|
||||
uint t12 = t10 << (t2 & 31u);
|
||||
uint t13 = t12 ^ t11;
|
||||
uint t14 = 0u;
|
||||
for (uint lane = 0u; lane < 32u; ++lane) {
|
||||
uint lane_index = (index & ~31u) + lane;
|
||||
if (lane_index >= grid) { break; }
|
||||
uint l0 = input[lane_index];
|
||||
uint pass = (as_type<int>(l0) <= as_type<int>(t3)) ? 1u : 0u;
|
||||
t14 |= ((0xffffffffu >> lane) & pass) << lane;
|
||||
}
|
||||
uint t15 = t13 << (t2 & 31u);
|
||||
uint t16 = t15 ^ t14;
|
||||
uint t17 = 0u;
|
||||
for (uint lane = 0u; lane < 32u; ++lane) {
|
||||
uint lane_index = (index & ~31u) + lane;
|
||||
if (lane_index >= grid) { break; }
|
||||
uint l0 = input[lane_index];
|
||||
uint pass = (as_type<int>(l0) > as_type<int>(t3)) ? 1u : 0u;
|
||||
t17 |= ((0xffffffffu >> lane) & pass) << lane;
|
||||
}
|
||||
uint t18 = t16 << (t2 & 31u);
|
||||
uint t19 = t18 ^ t17;
|
||||
uint t20 = 0u;
|
||||
for (uint lane = 0u; lane < 32u; ++lane) {
|
||||
uint lane_index = (index & ~31u) + lane;
|
||||
if (lane_index >= grid) { break; }
|
||||
uint l0 = input[lane_index];
|
||||
uint pass = (as_type<int>(l0) != as_type<int>(t3)) ? 1u : 0u;
|
||||
t20 |= ((0xffffffffu >> lane) & pass) << lane;
|
||||
}
|
||||
uint t21 = t19 << (t2 & 31u);
|
||||
uint t22 = t21 ^ t20;
|
||||
uint t23 = 0u;
|
||||
for (uint lane = 0u; lane < 32u; ++lane) {
|
||||
uint lane_index = (index & ~31u) + lane;
|
||||
if (lane_index >= grid) { break; }
|
||||
uint l0 = input[lane_index];
|
||||
uint pass = (as_type<int>(l0) >= as_type<int>(t3)) ? 1u : 0u;
|
||||
t23 |= ((0xffffffffu >> lane) & pass) << lane;
|
||||
}
|
||||
uint t24 = t22 << (t2 & 31u);
|
||||
uint t25 = t24 ^ t23;
|
||||
uint t26 = 0u;
|
||||
for (uint lane = 0u; lane < 32u; ++lane) {
|
||||
uint lane_index = (index & ~31u) + lane;
|
||||
if (lane_index >= grid) { break; }
|
||||
uint pass = (true) ? 1u : 0u;
|
||||
t26 |= ((0xffffffffu >> lane) & pass) << lane;
|
||||
}
|
||||
uint t27 = t25 << (t2 & 31u);
|
||||
uint t28 = t27 ^ t26;
|
||||
uint t29 = 0u;
|
||||
for (uint lane = 0u; lane < 32u; ++lane) {
|
||||
uint lane_index = (index & ~31u) + lane;
|
||||
if (lane_index >= grid) { break; }
|
||||
uint pass = (false) ? 1u : 0u;
|
||||
t29 |= ((0xffffffffu >> lane) & pass) << lane;
|
||||
}
|
||||
uint t30 = t28 << (t2 & 31u);
|
||||
uint t31 = t30 ^ t29;
|
||||
uint t32 = 0u;
|
||||
for (uint lane = 0u; lane < 32u; ++lane) {
|
||||
uint lane_index = (index & ~31u) + lane;
|
||||
if (lane_index >= grid) { break; }
|
||||
uint l0 = input[lane_index];
|
||||
uint pass = (l0 < t3) ? 1u : 0u;
|
||||
t32 |= ((0xffffffffu >> lane) & pass) << lane;
|
||||
}
|
||||
uint t33 = t31 << (t2 & 31u);
|
||||
uint t34 = t33 ^ t32;
|
||||
uint t35 = 0u;
|
||||
for (uint lane = 0u; lane < 32u; ++lane) {
|
||||
uint lane_index = (index & ~31u) + lane;
|
||||
if (lane_index >= grid) { break; }
|
||||
uint l0 = input[lane_index];
|
||||
uint pass = (l0 == t3) ? 1u : 0u;
|
||||
t35 |= ((0xffffffffu >> lane) & pass) << lane;
|
||||
}
|
||||
uint t36 = t34 << (t2 & 31u);
|
||||
uint t37 = t36 ^ t35;
|
||||
uint t38 = 0u;
|
||||
for (uint lane = 0u; lane < 32u; ++lane) {
|
||||
uint lane_index = (index & ~31u) + lane;
|
||||
if (lane_index >= grid) { break; }
|
||||
uint l0 = input[lane_index];
|
||||
uint pass = (l0 <= t3) ? 1u : 0u;
|
||||
t38 |= ((0xffffffffu >> lane) & pass) << lane;
|
||||
}
|
||||
uint t39 = t37 << (t2 & 31u);
|
||||
uint t40 = t39 ^ t38;
|
||||
uint t41 = 0u;
|
||||
for (uint lane = 0u; lane < 32u; ++lane) {
|
||||
uint lane_index = (index & ~31u) + lane;
|
||||
if (lane_index >= grid) { break; }
|
||||
uint l0 = input[lane_index];
|
||||
uint pass = (l0 > t3) ? 1u : 0u;
|
||||
t41 |= ((0xffffffffu >> lane) & pass) << lane;
|
||||
}
|
||||
uint t42 = t40 << (t2 & 31u);
|
||||
uint t43 = t42 ^ t41;
|
||||
uint t44 = 0u;
|
||||
for (uint lane = 0u; lane < 32u; ++lane) {
|
||||
uint lane_index = (index & ~31u) + lane;
|
||||
if (lane_index >= grid) { break; }
|
||||
uint l0 = input[lane_index];
|
||||
uint pass = (l0 != t3) ? 1u : 0u;
|
||||
t44 |= ((0xffffffffu >> lane) & pass) << lane;
|
||||
}
|
||||
uint t45 = t43 << (t2 & 31u);
|
||||
uint t46 = t45 ^ t44;
|
||||
uint t47 = 0u;
|
||||
for (uint lane = 0u; lane < 32u; ++lane) {
|
||||
uint lane_index = (index & ~31u) + lane;
|
||||
if (lane_index >= grid) { break; }
|
||||
uint l0 = input[lane_index];
|
||||
uint pass = (l0 >= t3) ? 1u : 0u;
|
||||
t47 |= ((0xffffffffu >> lane) & pass) << lane;
|
||||
}
|
||||
uint t48 = t46 << (t2 & 31u);
|
||||
uint t49 = t48 ^ t47;
|
||||
uint t50 = 0u;
|
||||
for (uint lane = 0u; lane < 32u; ++lane) {
|
||||
uint lane_index = (index & ~31u) + lane;
|
||||
if (lane_index >= grid) { break; }
|
||||
uint pass = (true) ? 1u : 0u;
|
||||
t50 |= ((0xffffffffu >> lane) & pass) << lane;
|
||||
}
|
||||
uint t51 = t49 << (t2 & 31u);
|
||||
uint t52 = t51 ^ t50;
|
||||
uint t53 = 0u;
|
||||
for (uint lane = 0u; lane < 32u; ++lane) {
|
||||
uint lane_index = (index & ~31u) + lane;
|
||||
if (lane_index >= grid) { break; }
|
||||
uint l0 = input[lane_index];
|
||||
uint pass = (l0 == t3) ? 1u : 0u;
|
||||
t53 |= ((0xffffffffu >> lane) & pass) << lane;
|
||||
}
|
||||
uint t54 = 0u;
|
||||
for (uint lane = 0u; lane < 32u; ++lane) {
|
||||
uint lane_index = (index & ~31u) + lane;
|
||||
if (lane_index >= grid) { break; }
|
||||
uint l0 = input[lane_index];
|
||||
uint pass = (t3 > l0) ? 1u : 0u;
|
||||
t54 |= ((0xffffffffu >> lane) & pass) << lane;
|
||||
}
|
||||
uint t56 = t4 ^ t52;
|
||||
uint t57 = t54 != 0u ? t56 : t52;
|
||||
output[index] = t57;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
0000: t0 = load.u32 input[index]
|
||||
000c: t1 = mul24.i32 t0, t0
|
||||
0014: t2 = mulhi24.i32 t1, t0
|
||||
001c: t3 = mul24.u32 t1, t0
|
||||
0024: t4 = mulhi24.u32 t3, t0
|
||||
002c: t5 = min.i32 t0, t1
|
||||
0034: t6 = max.i32 t0, t3
|
||||
003c: t7 = min.u32 t2, t0
|
||||
0044: t8 = max.u32 t4, t1
|
||||
004c: t9 = xnor.b32 t0, t4
|
||||
0054: t10 = sub.u32 t5, t9
|
||||
005c: t11 = sub.u32 t8, t0
|
||||
0064: t12 = xor.b32 t1, t2
|
||||
0068: t13 = xor.b32 t3, t12
|
||||
006c: t14 = xor.b32 t4, t13
|
||||
0070: t15 = xor.b32 t5, t14
|
||||
0074: t16 = xor.b32 t6, t15
|
||||
0078: t17 = xor.b32 t7, t16
|
||||
007c: t18 = xor.b32 t8, t17
|
||||
0080: t19 = xor.b32 t9, t18
|
||||
0084: t20 = xor.b32 t10, t19
|
||||
0088: t21 = xor.b32 t11, t20
|
||||
008c: store.u32 output[index], t21
|
||||
@@ -0,0 +1,30 @@
|
||||
#include <metal_stdlib>
|
||||
using namespace metal;
|
||||
kernel void xenora_compute(
|
||||
device const uint* input [[buffer(0)]],
|
||||
device uint* output [[buffer(1)]],
|
||||
uint index [[thread_position_in_grid]]) {
|
||||
uint t0 = input[index];
|
||||
uint t1 = as_type<uint>((as_type<int>(t0 << 8u) >> 8)) * as_type<uint>((as_type<int>(t0 << 8u) >> 8));
|
||||
uint t2 = as_type<uint>(mulhi((as_type<int>(t1 << 8u) >> 8), (as_type<int>(t0 << 8u) >> 8)));
|
||||
uint t3 = (t1 & 0x00ffffffu) * (t0 & 0x00ffffffu);
|
||||
uint t4 = mulhi((t3 & 0x00ffffffu), (t0 & 0x00ffffffu));
|
||||
uint t5 = as_type<uint>(min(as_type<int>(t0), as_type<int>(t1)));
|
||||
uint t6 = as_type<uint>(max(as_type<int>(t0), as_type<int>(t3)));
|
||||
uint t7 = min(t2, t0);
|
||||
uint t8 = max(t4, t1);
|
||||
uint t9 = ~(t0 ^ t4);
|
||||
uint t10 = t5 - t9;
|
||||
uint t11 = t8 - t0;
|
||||
uint t12 = t1 ^ t2;
|
||||
uint t13 = t3 ^ t12;
|
||||
uint t14 = t4 ^ t13;
|
||||
uint t15 = t5 ^ t14;
|
||||
uint t16 = t6 ^ t15;
|
||||
uint t17 = t7 ^ t16;
|
||||
uint t18 = t8 ^ t17;
|
||||
uint t19 = t9 ^ t18;
|
||||
uint t20 = t10 ^ t19;
|
||||
uint t21 = t11 ^ t20;
|
||||
output[index] = t21;
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,23 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// Encoding inventory for Wave32 16-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, 7
|
||||
v_cmp_lt_i16_e32 vcc_lo, v2, v3
|
||||
v_cmp_eq_i16_e32 vcc_lo, v2, v3
|
||||
v_cmp_le_i16_e32 vcc_lo, v2, v3
|
||||
v_cmp_gt_i16_e32 vcc_lo, v2, v3
|
||||
v_cmp_ne_i16_e32 vcc_lo, v2, v3
|
||||
v_cmp_ge_i16_e32 vcc_lo, v2, v3
|
||||
v_cmp_lt_u16_e32 vcc_lo, v2, v3
|
||||
v_cmp_eq_u16_e32 vcc_lo, v2, v3
|
||||
v_cmp_le_u16_e32 vcc_lo, v2, v3
|
||||
v_cmp_gt_u16_e32 vcc_lo, v2, v3
|
||||
v_cmp_ne_u16_e32 vcc_lo, v2, v3
|
||||
v_cmp_ge_u16_e32 vcc_lo, v2, v3
|
||||
v_mov_b32_e32 v2, vcc_lo
|
||||
buffer_store_dword v2, v0, s[4:7], 0 idxen
|
||||
s_waitcnt_vscnt null, 0
|
||||
s_endpgm
|
||||
Binary file not shown.
@@ -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
|
||||
Binary file not shown.
@@ -0,0 +1,17 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// Original Wave32 example. The compare derives VCC from the input, then each
|
||||
// carry/borrow feeds the next operation. Before reverse subtract, v3 is
|
||||
// 0xfffffffe for a zero input and 0xffffffff otherwise, with borrow-in 1.
|
||||
// Subtracting 0xfffffffe and the borrow-in sets the final VCC bit for zero inputs.
|
||||
.text
|
||||
buffer_load_dword v1, v0, s[0:3], 0 idxen
|
||||
s_waitcnt vmcnt(0)
|
||||
v_cmp_eq_u32_e32 vcc_lo, 0, v1
|
||||
v_cndmask_b32_e32 v2, -1, v1, vcc_lo
|
||||
v_add_co_ci_u32_e32 v2, vcc_lo, 1, v2, vcc_lo
|
||||
v_sub_co_ci_u32_e32 v3, vcc_lo, 0, v2, vcc_lo
|
||||
v_subrev_co_ci_u32_e32 v3, vcc_lo, -2, v3, vcc_lo
|
||||
v_mov_b32_e32 v4, vcc_lo
|
||||
buffer_store_dword v4, v0, s[4:7], 0 idxen
|
||||
s_waitcnt_vscnt null, 0
|
||||
s_endpgm
|
||||
Binary file not shown.
@@ -0,0 +1,85 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// Original Wave32 VOP3A vectors for the sixteen integer compare encoding variants.
|
||||
// Each compare writes vcc_lo through the explicit 64-bit destination field
|
||||
// (one writes s8), and each wave folds the masks into v2 as
|
||||
// v2 = (v2 << 1) ^ mask. Sources are VGPRs. This fixture is checked through
|
||||
// its IR and MSL goldens; the per-lane expected values for these forms are in
|
||||
// tests/validation/tests/vop3_compare.rs.
|
||||
.text
|
||||
buffer_load_dword v1, v0, s[0:3], 0 idxen // Load the lane's input word.
|
||||
s_waitcnt vmcnt(0) // Wait for the load.
|
||||
v_mov_b32_e32 v2, 0 // Clear the accumulator.
|
||||
v_mov_b32_e32 v5, 1 // Shift count for the fold.
|
||||
v_mov_b32_e32 v3, 0x40000001 // Second source: inputs fall below, on and above it.
|
||||
v_mov_b32_e32 v6, 1 // Low bit for the branch fold.
|
||||
v_cmp_f_i32_e64 vcc_lo, v1, v3 // Compare the input with 0x40000001.
|
||||
v_mov_b32_e32 v4, vcc_lo // Move the mask into a VGPR.
|
||||
v_lshlrev_b32_e32 v2, v5, v2 // Shift the accumulator.
|
||||
v_xor_b32_e32 v2, v2, v4 // Fold the mask.
|
||||
v_cmp_lt_i32_e64 vcc_lo, v1, v3 // Compare the input with 0x40000001.
|
||||
v_mov_b32_e32 v4, vcc_lo // Move the mask into a VGPR.
|
||||
v_lshlrev_b32_e32 v2, v5, v2 // Shift the accumulator.
|
||||
v_xor_b32_e32 v2, v2, v4 // Fold the mask.
|
||||
v_cmp_eq_i32_e64 vcc_lo, v1, v3 // Compare the input with 0x40000001.
|
||||
v_mov_b32_e32 v4, vcc_lo // Move the mask into a VGPR.
|
||||
v_lshlrev_b32_e32 v2, v5, v2 // Shift the accumulator.
|
||||
v_xor_b32_e32 v2, v2, v4 // Fold the mask.
|
||||
v_cmp_le_i32_e64 vcc_lo, v1, v3 // Compare the input with 0x40000001.
|
||||
v_mov_b32_e32 v4, vcc_lo // Move the mask into a VGPR.
|
||||
v_lshlrev_b32_e32 v2, v5, v2 // Shift the accumulator.
|
||||
v_xor_b32_e32 v2, v2, v4 // Fold the mask.
|
||||
v_cmp_gt_i32_e64 vcc_lo, v1, v3 // Compare the input with 0x40000001.
|
||||
v_mov_b32_e32 v4, vcc_lo // Move the mask into a VGPR.
|
||||
v_lshlrev_b32_e32 v2, v5, v2 // Shift the accumulator.
|
||||
v_xor_b32_e32 v2, v2, v4 // Fold the mask.
|
||||
v_cmp_ne_i32_e64 vcc_lo, v1, v3 // Compare the input with 0x40000001.
|
||||
v_mov_b32_e32 v4, vcc_lo // Move the mask into a VGPR.
|
||||
v_lshlrev_b32_e32 v2, v5, v2 // Shift the accumulator.
|
||||
v_xor_b32_e32 v2, v2, v4 // Fold the mask.
|
||||
v_cmp_ge_i32_e64 vcc_lo, v1, v3 // Compare the input with 0x40000001.
|
||||
v_mov_b32_e32 v4, vcc_lo // Move the mask into a VGPR.
|
||||
v_lshlrev_b32_e32 v2, v5, v2 // Shift the accumulator.
|
||||
v_xor_b32_e32 v2, v2, v4 // Fold the mask.
|
||||
v_cmp_t_i32_e64 vcc_lo, v1, v3 // Compare the input with 0x40000001.
|
||||
v_mov_b32_e32 v4, vcc_lo // Move the mask into a VGPR.
|
||||
v_lshlrev_b32_e32 v2, v5, v2 // Shift the accumulator.
|
||||
v_xor_b32_e32 v2, v2, v4 // Fold the mask.
|
||||
v_cmp_f_u32_e64 vcc_lo, v1, v3 // Compare the input with 0x40000001.
|
||||
v_mov_b32_e32 v4, vcc_lo // Move the mask into a VGPR.
|
||||
v_lshlrev_b32_e32 v2, v5, v2 // Shift the accumulator.
|
||||
v_xor_b32_e32 v2, v2, v4 // Fold the mask.
|
||||
v_cmp_lt_u32_e64 vcc_lo, v1, v3 // Compare the input with 0x40000001.
|
||||
v_mov_b32_e32 v4, vcc_lo // Move the mask into a VGPR.
|
||||
v_lshlrev_b32_e32 v2, v5, v2 // Shift the accumulator.
|
||||
v_xor_b32_e32 v2, v2, v4 // Fold the mask.
|
||||
v_cmp_eq_u32_e64 vcc_lo, v1, v3 // Compare the input with 0x40000001.
|
||||
v_mov_b32_e32 v4, vcc_lo // Move the mask into a VGPR.
|
||||
v_lshlrev_b32_e32 v2, v5, v2 // Shift the accumulator.
|
||||
v_xor_b32_e32 v2, v2, v4 // Fold the mask.
|
||||
v_cmp_le_u32_e64 vcc_lo, v1, v3 // Compare the input with 0x40000001.
|
||||
v_mov_b32_e32 v4, vcc_lo // Move the mask into a VGPR.
|
||||
v_lshlrev_b32_e32 v2, v5, v2 // Shift the accumulator.
|
||||
v_xor_b32_e32 v2, v2, v4 // Fold the mask.
|
||||
v_cmp_gt_u32_e64 vcc_lo, v1, v3 // Compare the input with 0x40000001.
|
||||
v_mov_b32_e32 v4, vcc_lo // Move the mask into a VGPR.
|
||||
v_lshlrev_b32_e32 v2, v5, v2 // Shift the accumulator.
|
||||
v_xor_b32_e32 v2, v2, v4 // Fold the mask.
|
||||
v_cmp_ne_u32_e64 vcc_lo, v1, v3 // Compare the input with 0x40000001.
|
||||
v_mov_b32_e32 v4, vcc_lo // Move the mask into a VGPR.
|
||||
v_lshlrev_b32_e32 v2, v5, v2 // Shift the accumulator.
|
||||
v_xor_b32_e32 v2, v2, v4 // Fold the mask.
|
||||
v_cmp_ge_u32_e64 vcc_lo, v1, v3 // Compare the input with 0x40000001.
|
||||
v_mov_b32_e32 v4, vcc_lo // Move the mask into a VGPR.
|
||||
v_lshlrev_b32_e32 v2, v5, v2 // Shift the accumulator.
|
||||
v_xor_b32_e32 v2, v2, v4 // Fold the mask.
|
||||
v_cmp_t_u32_e64 vcc_lo, v1, v3 // Compare the input with 0x40000001.
|
||||
v_mov_b32_e32 v4, vcc_lo // Move the mask into a VGPR.
|
||||
v_lshlrev_b32_e32 v2, v5, v2 // Shift the accumulator.
|
||||
v_xor_b32_e32 v2, v2, v4 // Fold the mask.
|
||||
v_cmp_eq_u32_e64 s8, v1, v3 // A mask into a plain SGPR, never read.
|
||||
v_cmp_gt_u32_e64 vcc_lo, v3, v1 // Unsigned 0x40000001 > input.
|
||||
s_cbranch_vccz 1 // Skip the next fold when no lane passed.
|
||||
v_xor_b32_e32 v2, v6, v2 // Flip the low bit when some lane passed.
|
||||
buffer_store_dword v2, v0, s[4:7], 0 idxen // Store the folded word.
|
||||
s_waitcnt_vscnt null, 0 // Wait for the store.
|
||||
s_endpgm // End the program.
|
||||
Binary file not shown.
@@ -0,0 +1,31 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// Original VOP3A vectors for the eleven per-lane integer encoding variants.
|
||||
// All arithmetic operands are vector general-purpose registers (VGPRs) and every result
|
||||
// depends on the lane's own input word. XOR folds the results into one word.
|
||||
.text
|
||||
buffer_load_dword v1, v0, s[0:3], 0 idxen // Load the lane's input word.
|
||||
s_waitcnt vmcnt(0) // Wait for the load.
|
||||
v_mul_i32_i24_e64 v2, v1, v1 // Multiply signed 24-bit inputs and keep the low word.
|
||||
v_mul_hi_i32_i24_e64 v3, v2, v1 // Multiply signed 24-bit inputs and keep the high word.
|
||||
v_mul_u32_u24_e64 v4, v2, v1 // Multiply unsigned 24-bit inputs and keep the low word.
|
||||
v_mul_hi_u32_u24_e64 v255, v4, v1 // Multiply unsigned 24-bit inputs and keep the high word.
|
||||
v_min_i32_e64 v6, v1, v2 // Select the signed minimum.
|
||||
v_max_i32_e64 v7, v1, v4 // Select the signed maximum.
|
||||
v_min_u32_e64 v8, v3, v1 // Select the unsigned minimum.
|
||||
v_max_u32_e64 v9, v255, v2 // Select the unsigned maximum.
|
||||
v_xnor_b32_e64 v10, v1, v255 // Complement the XOR.
|
||||
v_sub_nc_u32_e64 v11, v6, v10 // Subtract the second source from the first.
|
||||
v_subrev_nc_u32_e64 v1, v1, v9 // Subtract the first source from the second, overwriting the first.
|
||||
v_xor_b32_e32 v13, v2, v3 // Start the XOR fold.
|
||||
v_xor_b32_e32 v13, v4, v13 // Fold the unsigned product low word.
|
||||
v_xor_b32_e32 v13, v255, v13 // Fold the unsigned product high word.
|
||||
v_xor_b32_e32 v13, v6, v13 // Fold the signed minimum.
|
||||
v_xor_b32_e32 v13, v7, v13 // Fold the signed maximum.
|
||||
v_xor_b32_e32 v13, v8, v13 // Fold the unsigned minimum.
|
||||
v_xor_b32_e32 v13, v9, v13 // Fold the unsigned maximum.
|
||||
v_xor_b32_e32 v13, v10, v13 // Fold the XNOR result.
|
||||
v_xor_b32_e32 v13, v11, v13 // Fold the subtraction result.
|
||||
v_xor_b32_e32 v13, v1, v13 // Fold the reverse subtraction result.
|
||||
buffer_store_dword v13, v0, s[4:7], 0 idxen // Store the folded word.
|
||||
s_waitcnt_vscnt null, 0 // Wait for the store.
|
||||
s_endpgm // End the program.
|
||||
@@ -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 vector-unary; 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-vcc vop3-integer vop3-compare vector-unary vector-compare-64 vector-compare-16; 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"
|
||||
|
||||
@@ -10,7 +10,7 @@ import sys
|
||||
import tomllib
|
||||
|
||||
registry = Path("docs/claims.toml")
|
||||
claims = tomllib.loads(registry.read_text())["claim"]
|
||||
claims = tomllib.loads(registry.read_text(encoding="utf-8"))["claim"]
|
||||
classes = {}
|
||||
errors = []
|
||||
claim_id = re.compile(r"\bCLAIM-[A-Z0-9]+(?:-[A-Z0-9]+)*\b")
|
||||
@@ -37,10 +37,10 @@ files = [Path("README.md"), Path("AGENTS.md"), *Path("docs").rglob("*"),
|
||||
for source in files:
|
||||
if source == registry or source.suffix not in {".md", ".toml", ".rs"}:
|
||||
continue
|
||||
for reference in set(claim_id.findall(source.read_text())) - classes.keys():
|
||||
for reference in set(claim_id.findall(source.read_text(encoding="utf-8"))) - classes.keys():
|
||||
errors.append(f"{source}: unregistered {reference}")
|
||||
|
||||
status = tomllib.loads(Path("docs/status.toml").read_text())
|
||||
status = tomllib.loads(Path("docs/status.toml").read_text(encoding="utf-8"))
|
||||
for feature in status["feature"]:
|
||||
verification = feature.get("hardware_verification", "")
|
||||
if verification.casefold() != "verified":
|
||||
|
||||
@@ -18,7 +18,7 @@ def table(headers, rows):
|
||||
|
||||
|
||||
def replace_block(path, name, body, check):
|
||||
original = path.read_text()
|
||||
original = path.read_text(encoding="utf-8")
|
||||
start = f"<!-- status:{name}:start -->\n"
|
||||
stop = f"\n<!-- status:{name}:end -->"
|
||||
head, _, tail = original.partition(start)
|
||||
@@ -30,7 +30,7 @@ def replace_block(path, name, body, check):
|
||||
if check:
|
||||
print(f"{path}: status table differs from docs/status.toml", file=sys.stderr)
|
||||
return False
|
||||
path.write_text(updated)
|
||||
path.write_text(updated, encoding="utf-8", newline="\n")
|
||||
return True
|
||||
|
||||
|
||||
@@ -90,12 +90,12 @@ def render_progress(status):
|
||||
|
||||
|
||||
def check_asset(path, svg, check):
|
||||
if path.exists() and path.read_text() == svg:
|
||||
if path.exists() and path.read_text(encoding="utf-8") == svg:
|
||||
return True
|
||||
if check:
|
||||
print(f"{path}: progress graphic differs from docs/status.toml", file=sys.stderr)
|
||||
return False
|
||||
path.write_text(svg)
|
||||
path.write_text(svg, encoding="utf-8", newline="\n")
|
||||
return True
|
||||
|
||||
|
||||
@@ -105,8 +105,8 @@ def main():
|
||||
check = parser.parse_args().check
|
||||
root = Path(__file__).resolve().parents[2]
|
||||
docs = root / "docs"
|
||||
status = tomllib.loads((docs / "status.toml").read_text())
|
||||
claims = tomllib.loads((docs / "claims.toml").read_text())
|
||||
status = tomllib.loads((docs / "status.toml").read_text(encoding="utf-8"))
|
||||
claims = tomllib.loads((docs / "claims.toml").read_text(encoding="utf-8"))
|
||||
classes = {claim["id"]: claim["class"] for claim in claims["claim"]}
|
||||
|
||||
features = table(
|
||||
|
||||
+6
-4
@@ -25,6 +25,11 @@ cargo test --locked -p xenora-loader --features gpu-tests --test graphics_d3d12
|
||||
timeout 30s cargo test --locked -p xenora-loader --features gpu-tests --test graphics_d3d12 -- \
|
||||
--nocapture --test-threads=1
|
||||
|
||||
# Guest draws sample textures bound through descriptor tables (#303).
|
||||
cargo test --locked -p xenora-loader --features gpu-tests --test graphics_textures --no-run
|
||||
timeout 30s cargo test --locked -p xenora-loader --features gpu-tests --test graphics_textures -- \
|
||||
--nocapture --test-threads=1
|
||||
|
||||
# The native app interface runs the trusted fixture's guest draw on Metal.
|
||||
cargo test --locked -p xenora-ffi --features gpu-tests --test native_frame --no-run
|
||||
timeout 30s cargo test --locked -p xenora-ffi --features gpu-tests --test native_frame -- \
|
||||
@@ -53,7 +58,4 @@ timeout 30s cargo test --locked -p xenora-ffi --features gpu-tests --test audio_
|
||||
# Native Metal known answers of the independent semantic review, including SOP2 scalar ALU
|
||||
# and VOPC compares.
|
||||
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
|
||||
timeout 120s cargo test --locked -p xenora-semantic-review -- --ignored --nocapture --test-threads=1
|
||||
@@ -177,7 +177,7 @@ def snapshot():
|
||||
["SRC2", [[50, 9]]], ["OMOD", [[59, 2]]], ["NEG", [[61, 3]]],
|
||||
],
|
||||
"identifier_mask": 0xFFFF0000,
|
||||
"identifiers": [0xD4000000 | (op << 16) for op in (265, 273, 295)],
|
||||
"identifiers": [0xD4000000 | (op << 16) for op in (129, 265, 273, 295)],
|
||||
}
|
||||
# Values copied from the AMD XML snapshot: VOP3 encodings of VOP2 forms.
|
||||
for name, opcode, data_format in (
|
||||
@@ -191,6 +191,14 @@ def snapshot():
|
||||
["SRC1", data_format, "OPR_SRC_NOLDS", 32, True, False, False, True],
|
||||
],
|
||||
}
|
||||
variants[("V_CMP_LT_I32", "ENC_VOP3")] = {
|
||||
"instruction": "V_CMP_LT_I32", "encoding": "ENC_VOP3", "opcode": 129,
|
||||
"operands": [
|
||||
["VDST", "FMT_NUM_M64", "OPR_SREG", 64, False, True, False, True],
|
||||
["SRC0", I32, "OPR_SRC", 32, True, False, False, True],
|
||||
["SRC1", I32, "OPR_SRC_NOLDS", 32, True, False, False, True],
|
||||
],
|
||||
}
|
||||
return {
|
||||
"source": {"sha256": SHA},
|
||||
"encodings": {
|
||||
@@ -309,6 +317,18 @@ def _variant(of, opcode):
|
||||
}
|
||||
|
||||
|
||||
def compare_variants():
|
||||
reg = vector_compares()
|
||||
rule = gen.OPERAND_RULES["vop3_cmp_vgpr2"]
|
||||
reg["operand_rules"]["vop3_cmp_vgpr2"] = dict(
|
||||
copy.deepcopy(rule["shape"]), unsupported=sorted(rule["unsupported"])
|
||||
)
|
||||
reg["encoding_variant"] = [
|
||||
dict(_variant("V_CMP_LT_I32", 129), operands="vop3_cmp_vgpr2")
|
||||
]
|
||||
return reg
|
||||
|
||||
|
||||
def compares():
|
||||
reg = registry()
|
||||
reg["form"] += [
|
||||
@@ -771,12 +791,21 @@ class Validate(unittest.TestCase):
|
||||
text = gen.render(vectors(), snapshot())
|
||||
self.assertIn("pub enum VectorAluOp {", text)
|
||||
self.assertIn("if word & 0x8000_0000 != 0x0000_0000 {", text)
|
||||
self.assertIn("Self::MulI32I24 => VectorBinary::Mul24Signed,", text)
|
||||
self.assertIn("Self::SubrevNcU32 => VectorBinary::Sub,", text)
|
||||
self.assertIn("Self::MulI32I24 => VectorLowering::Binary(VectorBinary::Mul24Signed),", text)
|
||||
self.assertIn("Self::SubrevNcU32 => VectorLowering::Binary(VectorBinary::Sub),", text)
|
||||
self.assertIn("Self::SubrevNcU32 => true,", text.split("fn swaps_sources", 1)[1])
|
||||
self.assertIn('Self::AddU32 => "v_min_i32_e32",', text)
|
||||
self.assertIn("swap_sources: true,", text)
|
||||
|
||||
def test_vop2_vcc_requires_the_xml_input_and_output(self):
|
||||
reg = gen.load_registry()
|
||||
snap = gen.load_snapshot()
|
||||
operands = snap["variants"][("V_ADD_CO_CI_U32", "ENC_VOP2")]["operands"]
|
||||
operands[:] = [op for op in operands if not (op[2] == "OPR_VCC" and op[4])]
|
||||
self.rejects(reg, "V_ADD_CO_CI_U32: carry_in vcc requires one implicit XML VCC input", snap)
|
||||
form(reg, "V_CNDMASK_B32")["vcc"] = "lane_mask"
|
||||
self.rejects(reg, "V_CNDMASK_B32: vcc lane_mask contradicts rule vop2_vcc", snap)
|
||||
|
||||
def test_accepts_compares(self):
|
||||
self.assertEqual(self.errors(compares()), [])
|
||||
|
||||
@@ -851,6 +880,25 @@ class Validate(unittest.TestCase):
|
||||
def test_accepts_encoding_variants(self):
|
||||
self.assertEqual(self.errors(variants()), [])
|
||||
|
||||
def test_compare_variant_routes_mask_to_sdst(self):
|
||||
reg = compare_variants()
|
||||
self.assertEqual(self.errors(reg), [])
|
||||
row = gen.variant_row(reg, reg["encoding_variant"][0])
|
||||
self.assertEqual((row["vcc"], row["width"], row["wave"]), ("sdst_lane_mask", 32, "wave32"))
|
||||
|
||||
def test_rejects_mismatched_compare_variant_destination(self):
|
||||
reg = compare_variants()
|
||||
form(reg, "V_CMP_LT_I32")["vcc"] = "unchanged"
|
||||
self.rejects(reg, "requires a base destination contract of lane_mask, got unchanged")
|
||||
|
||||
reg = compare_variants()
|
||||
reg["operand_rules"]["vop3_cmp_vgpr2"]["dst"]["class"] = "vgpr"
|
||||
self.rejects(reg, "operand rule vop3_cmp_vgpr2: declaration differs")
|
||||
|
||||
snap = snapshot()
|
||||
snap["variants"][("V_CMP_LT_I32", "ENC_VOP3")]["operands"][0][2] = "OPR_VGPR"
|
||||
self.rejects(compare_variants(), "VDST is not a scalar mask destination in the XML", snap)
|
||||
|
||||
def test_rejects_a_variant_of_an_undeclared_form(self):
|
||||
reg = variants()
|
||||
reg["encoding_variant"].append(_variant("V_MUL_HI_I32_I24", 266))
|
||||
@@ -1140,7 +1188,7 @@ class Validate(unittest.TestCase):
|
||||
|
||||
def test_rejects_unknown_signedness_carry_in_exec_and_wave(self):
|
||||
for key, value in (
|
||||
("signedness", "float"), ("carry_in", "vcc"), ("exec", "written"), ("wave", "wave64"),
|
||||
("signedness", "float"), ("carry_in", "exec"), ("exec", "written"), ("wave", "wave64"),
|
||||
):
|
||||
with self.subTest(key=key):
|
||||
reg = registry()
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//! MUL_I32_I24, MUL_HI_I32_I24, MUL_U32_U24, MUL_HI_U32_U24, MIN/MAX (I32,
|
||||
//! U32), XNOR and ADD/SUB/SUBREV_NC_U32 (any SRC0 a VOPC compare takes; a
|
||||
//! shift-and-add multiplier and floor division for the high half, the ripple
|
||||
//! adder for add and subtract), VOP3 add-no-carry, MUBUF
|
||||
//! adder for add and subtract), VOP3A integer arithmetic and compares, MUBUF
|
||||
//! load/store and the two waits plus `s_endpgm`. Anything else is a controlled
|
||||
//! error. The arithmetic shift is evaluated as a floor division by a power of
|
||||
//! two rather than with a host signed shift, so the oracle does not share the
|
||||
@@ -72,18 +72,20 @@ enum Insn {
|
||||
/// SOPK opcode 0 or 2-16 on SGPR `SDST` (s0-s105) with the raw SIMM16.
|
||||
SImm(u32, u8, u16),
|
||||
BranchScc0(usize),
|
||||
BranchMaskZero {
|
||||
BranchMask {
|
||||
target: usize,
|
||||
register: usize,
|
||||
nonzero: bool,
|
||||
},
|
||||
Branch(usize),
|
||||
VMov(u8, Src),
|
||||
VMovFromSgpr(u8, u8),
|
||||
/// `v_mov_b32_e32 vD, vcc_lo`.
|
||||
VMovFromVcc(u8),
|
||||
/// VOPC compare into VCC_LO: relation 0 f, 1 lt, 2 eq, 3 le, 4 gt, 5 ne, 6 ge, 7 t.
|
||||
/// Integer vector compare into `dst`: relation 0 f, 1 lt, 2 eq, 3 le, 4 gt, 5 ne, 6 ge, 7 t.
|
||||
/// `bits` is 16, 32 or 64; 64-bit register operands name the low register of a pair.
|
||||
VCmp {
|
||||
dst: u8,
|
||||
relation: u8,
|
||||
signed: bool,
|
||||
bits: u32,
|
||||
@@ -99,6 +101,7 @@ enum Insn {
|
||||
VXor(u8, u8, u8),
|
||||
/// VOP2 integer opcode 9-12, 17-20, 30 or 37-39: VDST, SRC0, VSRC1.
|
||||
VInt(u32, u8, CmpSrc, u8),
|
||||
VIntVcc(u32, u8, CmpSrc, u8),
|
||||
/// VOP1 integer opcode 55-59: VDST, SRC0.
|
||||
VUnary(u32, u8, CmpSrc),
|
||||
/// `v_swap_b32 vD, vS` (VOP1 opcode 101).
|
||||
@@ -206,6 +209,7 @@ fn run_wave(program: &[(usize, Insn)], wave: &[u32]) -> Result<Vec<u32>, String>
|
||||
return Ok(lanes.iter().map(|lane| lane.written.unwrap()).collect());
|
||||
}
|
||||
Insn::VCmp {
|
||||
dst,
|
||||
relation,
|
||||
signed,
|
||||
bits,
|
||||
@@ -225,10 +229,32 @@ fn run_wave(program: &[(usize, Insn)], wave: &[u32]) -> Result<Vec<u32>, String>
|
||||
offset,
|
||||
)
|
||||
.map(|mask| {
|
||||
sgpr[106] = Some(mask);
|
||||
// VCC_HI has no known value after a compare (contract 3).
|
||||
sgpr[107] = None;
|
||||
vcc_lane_derived = execution_mask != 0;
|
||||
sgpr[usize::from(dst)] = Some(mask);
|
||||
if dst == 106 {
|
||||
// VCC_HI has no known value after a VCC compare (contract 3).
|
||||
sgpr[107] = None;
|
||||
vcc_lane_derived = execution_mask != 0;
|
||||
}
|
||||
None
|
||||
})
|
||||
}
|
||||
Insn::VIntVcc(opcode, dst, src0, src1) => {
|
||||
if let Some(error) = first_error(&lanes) {
|
||||
return Err(error);
|
||||
}
|
||||
vector_vcc(
|
||||
&mut lanes,
|
||||
&sgpr,
|
||||
execution_mask,
|
||||
(opcode, dst, src0, src1),
|
||||
offset,
|
||||
)
|
||||
.map(|mask| {
|
||||
if opcode != 1 {
|
||||
sgpr[106] = Some(mask);
|
||||
sgpr[107] = None;
|
||||
vcc_lane_derived = execution_mask != 0;
|
||||
}
|
||||
None
|
||||
})
|
||||
}
|
||||
@@ -280,12 +306,17 @@ fn run_wave(program: &[(usize, Insn)], wave: &[u32]) -> Result<Vec<u32>, String>
|
||||
index_of(program, target, offset).map(Some)
|
||||
}
|
||||
}),
|
||||
Insn::BranchMaskZero { target, register } => {
|
||||
Insn::BranchMask {
|
||||
target,
|
||||
register,
|
||||
nonzero,
|
||||
} => {
|
||||
let takes = |mask| (mask != 0) == nonzero;
|
||||
if register == 106 && vcc_lane_derived {
|
||||
let live = lanes.iter().find(|lane| lane.error.is_none()).unwrap();
|
||||
check_runtime_region(program, pc, target, live, &sgpr, execution_mask, offset)
|
||||
.and_then(|()| {
|
||||
if sgpr[106] == Some(0) {
|
||||
if takes(sgpr[106].unwrap()) {
|
||||
index_of(program, target, offset).map(Some)
|
||||
} else {
|
||||
Ok(None)
|
||||
@@ -295,7 +326,7 @@ fn run_wave(program: &[(usize, Insn)], wave: &[u32]) -> Result<Vec<u32>, String>
|
||||
sgpr[register]
|
||||
.ok_or_else(|| format!("{offset:#x}: uninitialized mask"))
|
||||
.and_then(|mask| {
|
||||
if mask == 0 {
|
||||
if takes(mask) {
|
||||
index_of(program, target, offset).map(Some)
|
||||
} else {
|
||||
Ok(None)
|
||||
@@ -325,6 +356,60 @@ fn run_wave(program: &[(usize, Insn)], wave: &[u32]) -> Result<Vec<u32>, String>
|
||||
Err(first_error(&lanes).unwrap_or_else(|| "stream ended without s_endpgm".to_string()))
|
||||
}
|
||||
|
||||
/// Guide 12.7 vector select and carry/borrow, with the Wave32 mask from 3.9.
|
||||
fn vector_vcc(
|
||||
lanes: &mut [Lane],
|
||||
sgpr: &[Option<u32>; 128],
|
||||
exec: u32,
|
||||
(opcode, dst, src0, src1): (u32, u8, CmpSrc, u8),
|
||||
offset: usize,
|
||||
) -> Result<u32, String> {
|
||||
if exec == 0 {
|
||||
return Ok(0);
|
||||
}
|
||||
let incoming = sgpr[106].ok_or_else(|| format!("{offset:#x}: uninitialized vcc_lo"))?;
|
||||
let mut mask = 0;
|
||||
for (index, lane) in lanes.iter_mut().enumerate() {
|
||||
if exec != u32::MAX && lane.vgpr[usize::from(dst)].is_none() {
|
||||
return Err(format!("{offset:#x}: partial EXEC on uninitialized VGPR"));
|
||||
}
|
||||
let a = match src0 {
|
||||
CmpSrc::Sgpr(reg) => sgpr[usize::from(reg)]
|
||||
.ok_or_else(|| format!("{offset:#x}: uninitialized s{reg}"))?,
|
||||
CmpSrc::Vcc => incoming,
|
||||
CmpSrc::Imm(value) => value,
|
||||
CmpSrc::Vgpr(reg) => read_vgpr(lane, reg, offset)?,
|
||||
};
|
||||
let b = read_vgpr(lane, src1, offset)?;
|
||||
let lane_bit = 2_u32.pow(index as u32);
|
||||
if exec & lane_bit == 0 {
|
||||
continue;
|
||||
}
|
||||
check_destination(dst, lane.pending_read, offset)?;
|
||||
let bit = incoming / lane_bit % 2;
|
||||
let (value, flag) = match opcode {
|
||||
1 => (if bit == 1 { b } else { a }, false),
|
||||
40 => {
|
||||
let (sum, overflow) = a.overflowing_add(b);
|
||||
let (value, carry) = sum.overflowing_add(bit);
|
||||
(value, overflow || carry)
|
||||
}
|
||||
41 | 42 => {
|
||||
let (lhs, rhs) = if opcode == 42 { (b, a) } else { (a, b) };
|
||||
let (difference, underflow) = lhs.overflowing_sub(rhs);
|
||||
let (value, borrow) = difference.overflowing_sub(bit);
|
||||
(value, underflow || borrow)
|
||||
}
|
||||
_ => unreachable!("not a VCC-reading VOP2 opcode"),
|
||||
};
|
||||
lane.vgpr[usize::from(dst)] = Some(value);
|
||||
if flag {
|
||||
mask |= lane_bit;
|
||||
}
|
||||
}
|
||||
Ok(mask)
|
||||
}
|
||||
|
||||
/// One SOPK instruction, per the operation text of guide 12.2. SDST names
|
||||
/// the destination and, for every form but the two moves, the first source.
|
||||
fn scalar_immediate(
|
||||
@@ -615,7 +700,7 @@ fn read_vgpr(lane: &Lane, reg: u8, offset: usize) -> Result<u32, String> {
|
||||
lane.vgpr[reg as usize].ok_or_else(|| format!("{offset:#x}: uninitialized v{reg}"))
|
||||
}
|
||||
|
||||
/// Evaluate one VOPC compare for the whole wave and return the new VCC_LO.
|
||||
/// Evaluate one integer vector compare for the whole wave and return its mask.
|
||||
fn compare(
|
||||
lanes: &[Lane],
|
||||
sgpr: &[Option<u32>; 128],
|
||||
@@ -1139,7 +1224,7 @@ fn decode(code: &[u8]) -> Result<Vec<(usize, Insn)>, String> {
|
||||
offset += len;
|
||||
}
|
||||
for &(at, insn) in &program {
|
||||
if let Insn::Branch(target) | Insn::BranchScc0(target) | Insn::BranchMaskZero { target, .. } =
|
||||
if let Insn::Branch(target) | Insn::BranchScc0(target) | Insn::BranchMask { target, .. } =
|
||||
insn
|
||||
&& !program.iter().any(|(boundary, _)| *boundary == target)
|
||||
{
|
||||
@@ -1240,6 +1325,7 @@ fn decode_one(code: &[u8], offset: usize) -> Result<(Insn, usize), String> {
|
||||
return Err(fail("unsupported VOPC operand"));
|
||||
}
|
||||
let insn = Insn::VCmp {
|
||||
dst: 106,
|
||||
relation: relation as u8,
|
||||
signed,
|
||||
bits,
|
||||
@@ -1250,19 +1336,46 @@ fn decode_one(code: &[u8], offset: usize) -> Result<(Insn, usize), String> {
|
||||
}
|
||||
// VOP2 integer forms: bit 31 = 0, OP 30:25, VDST 24:17, VSRC1 16:9, SRC0 8:0.
|
||||
let vop2_op = (first >> 25) & 0x3f;
|
||||
if first >> 31 == 0 && matches!(vop2_op, 1 | 40..=42) {
|
||||
let (src0, len) = vector_src0(code, offset, first, "VOP2")?;
|
||||
return Ok((
|
||||
Insn::VIntVcc(vop2_op, (first >> 17) as u8, src0, (first >> 9) as u8),
|
||||
len,
|
||||
));
|
||||
}
|
||||
if first >> 31 == 0 && matches!(vop2_op, 9..=12 | 17..=20 | 30 | 37..=39) {
|
||||
let (src0, len) = vector_src0(code, offset, first, "VOP2")?;
|
||||
let insn = Insn::VInt(vop2_op, (first >> 17) as u8, src0, (first >> 9) as u8);
|
||||
return Ok((insn, len));
|
||||
}
|
||||
if first & 0xffff_0000 == 0xd525_0000 {
|
||||
let second = word(code, offset + 4)?;
|
||||
if first >> 26 == 0b110101 {
|
||||
let dst = first as u8;
|
||||
let opcode = (first >> 16) & 0x3ff;
|
||||
let second = word(code, offset + 4).map_err(|_| fail("truncated VOP3A"))?;
|
||||
let src0 = second & 0x1ff;
|
||||
let src1 = (second >> 9) & 0x1ff;
|
||||
if first & 0xff00 != 0 || second >> 18 != 128 || src0 < 256 || src1 < 256 {
|
||||
return Err(fail("bad VOP3 add form"));
|
||||
return Err(fail("unsupported VOP3A modifiers or sources"));
|
||||
}
|
||||
return Ok((Insn::VAddNc(first as u8, src0 as u8, src1 as u8), 8));
|
||||
// Guide §§3.9, 12.7.1 and 12.9.1: re-encoded VOP2 writes a VGPR,
|
||||
// while VOPC uses the destination field for the scalar mask.
|
||||
let (src0, src1) = (src0 as u8, src1 as u8);
|
||||
let insn = match opcode {
|
||||
128..=135 | 192..=199 if dst <= 106 => Insn::VCmp {
|
||||
dst,
|
||||
relation: (opcode % 8) as u8,
|
||||
signed: opcode < 192,
|
||||
bits: 32,
|
||||
src0: CmpSrc::Vgpr(src0),
|
||||
src1,
|
||||
},
|
||||
293 => Insn::VAddNc(dst, src0, src1),
|
||||
265..=268 | 273..=276 | 286 | 294..=295 => {
|
||||
Insn::VInt(opcode - 256, dst, CmpSrc::Vgpr(src0), src1)
|
||||
}
|
||||
_ => return Err(fail("unsupported VOP3A opcode or destination")),
|
||||
};
|
||||
return Ok((insn, 8));
|
||||
}
|
||||
// SOP1: ENCODING 0b10_1111101 in bits 23-31, SDST 16-22, OP 8-15.
|
||||
let sop1_op = (first >> 8) & 0xff;
|
||||
@@ -1347,15 +1460,16 @@ fn decode_one(code: &[u8], offset: usize) -> Result<(Insn, usize), String> {
|
||||
return Ok((Insn::BranchScc0(branch_target(first, offset)?), 4));
|
||||
}
|
||||
let tested_register = match first >> 16 {
|
||||
0xbf86 => Some(106),
|
||||
0xbf86 | 0xbf87 => Some(106),
|
||||
0xbf88 => Some(126),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(register) = tested_register {
|
||||
return Ok((
|
||||
Insn::BranchMaskZero {
|
||||
Insn::BranchMask {
|
||||
target: branch_target(first, offset)?,
|
||||
register,
|
||||
nonzero: first >> 16 == 0xbf87,
|
||||
},
|
||||
4,
|
||||
));
|
||||
|
||||
@@ -784,6 +784,27 @@ mod review {
|
||||
const SCALAR_ARITH_FIXTURE: &[u8] = include_bytes!("../../fixtures/rdna2/scalar-arith.bin");
|
||||
// Hand-derived in fixtures/rdna2/scalar-arith.s from the guide's 12.1 pseudocode.
|
||||
const SCALAR_ARITH_KEY: u32 = 0x8115_7dfe;
|
||||
#[test]
|
||||
fn vector_vcc_chain_returns_the_zero_input_mask() {
|
||||
let code = include_bytes!("../../fixtures/rdna2/vector-vcc.bin");
|
||||
let input: Vec<_> = [0, 1, u32::MAX, 5, 0, 7]
|
||||
.into_iter()
|
||||
.cycle()
|
||||
.take(67)
|
||||
.collect();
|
||||
let expected: Vec<_> = input
|
||||
.chunks(32)
|
||||
.flat_map(|wave| {
|
||||
let mask = wave
|
||||
.iter()
|
||||
.enumerate()
|
||||
.fold(0, |mask, (lane, &x)| mask | (u32::from(x == 0) << lane));
|
||||
std::iter::repeat_n(mask, wave.len())
|
||||
})
|
||||
.collect();
|
||||
verify(code, &input, Some(&expected));
|
||||
}
|
||||
|
||||
const VECTOR_INTEGER_FIXTURE: &[u8] = include_bytes!("../../fixtures/rdna2/vector-integer.bin");
|
||||
|
||||
/// fixtures/rdna2/vector-integer.s for one lane input `x`, written from the
|
||||
|
||||
@@ -745,9 +745,9 @@ fn unsupported_vop2_integer_encodings_are_rejected() {
|
||||
fn other_vop2_opcodes_stay_unsupported() {
|
||||
// Every VOP2 opcode (0-61; 62 and 63 are the VOPC and VOP1 encodings)
|
||||
// except the forms supported before this set (V_ADD_F32 3, V_MUL_F32 8,
|
||||
// the shifts 22, 24, 26 and AND, OR, XOR 27-29) and these twelve. VDST is
|
||||
// the shifts 22, 24, 26 and AND, OR, XOR 27-29) and the registered integer forms. VDST is
|
||||
// initialized, so a form that also reads it fails only on the opcode.
|
||||
let earlier = [3, 8, 22, 24, 26, 27, 28, 29];
|
||||
let earlier = [1, 3, 8, 22, 24, 26, 27, 28, 29, 40, 41, 42];
|
||||
let supported: Vec<u32> = FORMS
|
||||
.iter()
|
||||
.map(|&(form, _)| form as u32)
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
//! Wave32 VOP2 select and carry/borrow oracle from AMD RDNA 2 ISA guide
|
||||
//! sections 3.3, 3.9, 12.7 and 13.3.1.
|
||||
|
||||
#[path = "../independent_ref.rs"]
|
||||
mod independent_ref;
|
||||
|
||||
use xenora_shader::{Architecture, CompileError, compile};
|
||||
|
||||
const FORMS: [u32; 4] = [1, 40, 41, 42];
|
||||
const EXEC_PATTERNS: [u32; 3] = [u32::MAX, 0xaaaa_aaab, 0];
|
||||
const INITIAL_DST: u32 = 0x1234_5678;
|
||||
const SCALAR_VCC: u32 = 0x8000_0005;
|
||||
|
||||
fn words(code: &[u32]) -> Vec<u8> {
|
||||
code.iter().flat_map(|word| word.to_le_bytes()).collect()
|
||||
}
|
||||
|
||||
fn vop2(op: u32, dst: u32, src0: u32, src1: u32) -> u32 {
|
||||
op << 25 | dst << 17 | src1 << 9 | src0
|
||||
}
|
||||
|
||||
fn program(body: &[u32], output: u32) -> Vec<u8> {
|
||||
let mut code = vec![0xe030_2000, 0x8000_0100, 0xbf8c_3f70];
|
||||
code.extend(body);
|
||||
code.extend([
|
||||
0xe070_2000,
|
||||
0x8001_0000 | output << 8,
|
||||
0xbbfd_0000,
|
||||
0xbf81_0000,
|
||||
]);
|
||||
words(&code)
|
||||
}
|
||||
|
||||
fn input() -> Vec<u32> {
|
||||
[0, 1, 2, u32::MAX, u32::MAX - 1, 0x8000_0000, 0, 31]
|
||||
.into_iter()
|
||||
.cycle()
|
||||
.take(67)
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Guide 12.7 gives the unbounded result and the 32-bit destination.
|
||||
/// For SUBREV the prose and D equation reverse the operands. The printed
|
||||
/// borrow formula repeats SUB's order, inconsistent with that subtraction.
|
||||
fn expected(op: u32, a: u32, b: u32, bit: u32) -> (u32, bool) {
|
||||
let (a, b, bit) = (i128::from(a), i128::from(b), i128::from(bit));
|
||||
let exact = match op {
|
||||
1 => return (if bit == 0 { a } else { b } as u32, false),
|
||||
40 => a + b + bit,
|
||||
41 => a - b - bit,
|
||||
42 => b - a - bit,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let modulus = 1_i128 << 32;
|
||||
(
|
||||
exact.rem_euclid(modulus) as u32,
|
||||
!(0..modulus).contains(&exact),
|
||||
)
|
||||
}
|
||||
|
||||
fn cases() -> Vec<(Vec<u8>, Vec<u32>)> {
|
||||
let input = input();
|
||||
let mut cases = Vec::new();
|
||||
for op in FORMS {
|
||||
for exec in EXEC_PATTERNS {
|
||||
for (selector, extension, src0) in [
|
||||
(129, None, 1),
|
||||
(193, None, u32::MAX),
|
||||
(8, None, 0x8000_0000),
|
||||
(255, Some(u32::MAX - 1), u32::MAX - 1),
|
||||
(259, None, INITIAL_DST),
|
||||
(106, None, 0),
|
||||
] {
|
||||
for from_compare in [false, true] {
|
||||
let mut body = vec![0x7e06_02ff, INITIAL_DST, 0xbe88_03ff, 0x8000_0000];
|
||||
if from_compare {
|
||||
body.push(0x7d84_0280); // v_cmp_eq_u32_e32 vcc_lo, 0, v1
|
||||
} else {
|
||||
body.extend([0xbeea_03ff, SCALAR_VCC]); // s_mov_b32 vcc_lo, literal
|
||||
}
|
||||
body.extend([0xbefe_03ff, exec]);
|
||||
body.push(vop2(op, 3, selector, 1));
|
||||
body.extend(extension);
|
||||
body.push(0xbefe_03c1); // restore full EXEC for the store
|
||||
|
||||
let mut values = Vec::new();
|
||||
let mut masks = Vec::new();
|
||||
for wave in input.chunks(32) {
|
||||
let incoming = if from_compare {
|
||||
wave.iter()
|
||||
.enumerate()
|
||||
.fold(0, |mask, (lane, &x)| mask | (u32::from(x == 0) << lane))
|
||||
} else {
|
||||
SCALAR_VCC
|
||||
};
|
||||
let mut mask = if op == 1 { incoming } else { 0 };
|
||||
for (lane, &x) in wave.iter().enumerate() {
|
||||
if exec & (1 << lane) == 0 {
|
||||
values.push(INITIAL_DST);
|
||||
} else {
|
||||
let a = if selector == 106 { incoming } else { src0 };
|
||||
let (value, flag) = expected(op, a, x, (incoming >> lane) & 1);
|
||||
values.push(value);
|
||||
mask |= u32::from(flag) << lane;
|
||||
}
|
||||
}
|
||||
masks.extend(std::iter::repeat_n(mask, wave.len()));
|
||||
}
|
||||
cases.push((program(&body, 3), values));
|
||||
body.push(0x7e08_026a); // v_mov_b32_e32 v4, vcc_lo
|
||||
cases.push((program(&body, 4), masks));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cases
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vop2_vcc_matches_guide_on_both_interpreters() {
|
||||
let input = input();
|
||||
for (index, (code, expected)) in cases().into_iter().enumerate() {
|
||||
compile(Architecture::Gfx1030, &code).unwrap();
|
||||
assert_eq!(
|
||||
xenora_ref::execute(&code, &input).unwrap(),
|
||||
expected,
|
||||
"reference case {index}"
|
||||
);
|
||||
assert_eq!(
|
||||
independent_ref::execute(&code, &input).unwrap(),
|
||||
expected,
|
||||
"independent case {index}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vop2_vcc_rejects_unsupported_operands_and_uninitialized_state() {
|
||||
let mut cases = Vec::new();
|
||||
for op in FORMS {
|
||||
cases.push((program(&[vop2(op, 2, 129, 1)], 2), 12));
|
||||
for selector in [107, 124, 126, 128 + 112, 249, 250] {
|
||||
cases.push((program(&[vop2(op, 2, selector, 1), 0], 2), 12));
|
||||
}
|
||||
let fixture = words(&[vop2(op, 2, 255, 1)]);
|
||||
assert!(matches!(
|
||||
compile(Architecture::Gfx1030, &fixture),
|
||||
Err(CompileError::Decode(_))
|
||||
));
|
||||
assert!(xenora_ref::execute(&fixture, &[1]).is_err());
|
||||
assert!(independent_ref::execute(&fixture, &[1]).is_err());
|
||||
cases.push((
|
||||
program(&[0xbeea_03c1, 0xbefe_0381, vop2(op, 2, 129, 1)], 2),
|
||||
20,
|
||||
));
|
||||
}
|
||||
// LLVM-assembled e64 forms with an explicit scalar condition operand.
|
||||
for first in [0xd501_0002, 0xd528_0902, 0xd529_0902, 0xd52a_0902] {
|
||||
cases.push((program(&[first, 0x0022_0303], 2), 12));
|
||||
}
|
||||
for (code, offset) in cases {
|
||||
let result = compile(Architecture::Gfx1030, &code);
|
||||
let got = match result {
|
||||
Err(CompileError::Decode(error)) => error.offset,
|
||||
Err(CompileError::Verify { offset, .. }) => offset,
|
||||
other => panic!("expected rejection at {offset:#x}: {other:?}"),
|
||||
};
|
||||
assert_eq!(got, offset);
|
||||
assert_eq!(
|
||||
xenora_ref::execute(&code, &[1, 2]).unwrap_err().offset,
|
||||
offset
|
||||
);
|
||||
assert!(
|
||||
independent_ref::execute(&code, &[1, 2])
|
||||
.unwrap_err()
|
||||
.starts_with(&format!("{offset:#x}:"))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "requires a native Metal device with API and shader validation"]
|
||||
fn vop2_vcc_matches_guide_on_native_metal() {
|
||||
assert_eq!(std::env::var("MTL_DEBUG_LAYER").as_deref(), Ok("1"));
|
||||
assert_eq!(std::env::var("MTL_SHADER_VALIDATION").as_deref(), Ok("1"));
|
||||
let metal = xenora_metal::NativeCompute::new().unwrap();
|
||||
let input = input();
|
||||
let fixture = include_bytes!("../../../fixtures/rdna2/vector-vcc.bin");
|
||||
let fixture_expected = input
|
||||
.chunks(32)
|
||||
.flat_map(|wave| {
|
||||
let mask = wave
|
||||
.iter()
|
||||
.enumerate()
|
||||
.fold(0, |mask, (lane, &x)| mask | (u32::from(x == 0) << lane));
|
||||
std::iter::repeat_n(mask, wave.len())
|
||||
})
|
||||
.collect();
|
||||
for (index, (code, expected)) in cases()
|
||||
.into_iter()
|
||||
.chain([(fixture.to_vec(), fixture_expected)])
|
||||
.enumerate()
|
||||
{
|
||||
let shader = compile(Architecture::Gfx1030, &code).unwrap();
|
||||
assert_eq!(
|
||||
metal
|
||||
.run_words(&shader.msl, xenora_shader::ENTRY_POINT, &input)
|
||||
.unwrap(),
|
||||
expected,
|
||||
"Metal case {index}",
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,302 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
//! Wave32 VOP3A integer compares. Guide §3.9 permits an SGPR destination in
|
||||
//! the 64-bit encoding and describes the fully rewritten per-lane mask.
|
||||
//! A Wave32 mask has 32 bits (§2.1), so SDST consumes one 32-bit SGPR (§5.2).
|
||||
//! The opcode relations are in §12.9, the re-encoding in §12.9.1, and the
|
||||
//! VOP3A fields in §13.3.4. These are spec-derived expectations.
|
||||
|
||||
#[path = "operand_domains/harness.rs"]
|
||||
#[allow(dead_code)]
|
||||
mod harness;
|
||||
#[path = "../independent_ref.rs"]
|
||||
mod independent_ref;
|
||||
|
||||
use harness::{Case, words};
|
||||
|
||||
const FORMS: [(u32, &str); 16] = [
|
||||
(128, "v_cmp_f_i32"),
|
||||
(129, "v_cmp_lt_i32"),
|
||||
(130, "v_cmp_eq_i32"),
|
||||
(131, "v_cmp_le_i32"),
|
||||
(132, "v_cmp_gt_i32"),
|
||||
(133, "v_cmp_ne_i32"),
|
||||
(134, "v_cmp_ge_i32"),
|
||||
(135, "v_cmp_t_i32"),
|
||||
(192, "v_cmp_f_u32"),
|
||||
(193, "v_cmp_lt_u32"),
|
||||
(194, "v_cmp_eq_u32"),
|
||||
(195, "v_cmp_le_u32"),
|
||||
(196, "v_cmp_gt_u32"),
|
||||
(197, "v_cmp_ne_u32"),
|
||||
(198, "v_cmp_ge_u32"),
|
||||
(199, "v_cmp_t_u32"),
|
||||
];
|
||||
const VALUES: [u32; 10] = [
|
||||
0,
|
||||
1,
|
||||
0x7fff_ffff,
|
||||
0x8000_0000,
|
||||
u32::MAX,
|
||||
0x00ff_ffff,
|
||||
0x0080_0000,
|
||||
0xff80_0000,
|
||||
0x0100_0001,
|
||||
0xff00_0003,
|
||||
];
|
||||
const MASKS: [u32; 4] = [u32::MAX, 0x5555_5555, 0x8000_0001, 0];
|
||||
|
||||
fn passes(op: u32, a: u32, b: u32) -> bool {
|
||||
let operand = |value: u32| {
|
||||
if op < 192 {
|
||||
i64::from(value as i32)
|
||||
} else {
|
||||
i64::from(value)
|
||||
}
|
||||
};
|
||||
let (a, b) = (operand(a), operand(b));
|
||||
match op & 7 {
|
||||
// D[threadId] = 0.
|
||||
0 => false,
|
||||
// D[threadId] = (S0 < S1).
|
||||
1 => a < b,
|
||||
// D[threadId] = (S0 == S1).
|
||||
2 => a == b,
|
||||
// D[threadId] = (S0 <= S1).
|
||||
3 => a <= b,
|
||||
// D[threadId] = (S0 > S1).
|
||||
4 => a > b,
|
||||
// D[threadId] = (S0 <> S1).
|
||||
5 => a != b,
|
||||
// D[threadId] = (S0 >= S1).
|
||||
6 => a >= b,
|
||||
// D[threadId] = 1.
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
|
||||
fn expected_mask(op: u32, exec: u32, wave: &[u32], bound: u32, reverse: bool) -> u32 {
|
||||
// §3.9: VCC[n] = EXEC[n] & (test passed for thread[n]).
|
||||
// §3.9 uses the same result for the alternate scalar destination.
|
||||
wave.iter().enumerate().fold(0, |mask, (n, &x)| {
|
||||
let (a, b) = if reverse { (bound, x) } else { (x, bound) };
|
||||
mask | (exec & (u32::from(passes(op, a, b)) << n))
|
||||
})
|
||||
}
|
||||
|
||||
fn vop3(op: u32, dst: u32, reverse: bool) -> [u32; 2] {
|
||||
let (a, b) = if reverse { (511, 257) } else { (257, 511) };
|
||||
[0xd400_0000 | op << 16 | dst, a | b << 9 | 128 << 18]
|
||||
}
|
||||
|
||||
fn smov(dst: u32, value: u32) -> [u32; 2] {
|
||||
[0xbe80_03ff | dst << 16, value]
|
||||
}
|
||||
|
||||
fn setup(bound: u32, exec: u32) -> Vec<u32> {
|
||||
let mut code = vec![0xe030_2000, 0x8000_0100, 0xbf8c_3f70]; // load v1
|
||||
code.extend([0x7ffe_02ff, bound]); // v255 = literal
|
||||
code.extend(smov(126, exec));
|
||||
code
|
||||
}
|
||||
|
||||
fn store(mut code: Vec<u32>) -> Vec<u8> {
|
||||
code.extend([0xe070_2000, 0x8001_0200, 0xbbfd_0000, 0xbf81_0000]);
|
||||
words(&code)
|
||||
}
|
||||
|
||||
fn mask_cases() -> Vec<Case> {
|
||||
let mut cases = Vec::new();
|
||||
for (op, name) in FORMS {
|
||||
for bound in VALUES {
|
||||
for reverse in [false, true] {
|
||||
for exec in MASKS {
|
||||
for (lanes, dst) in [(7, 106), (32, 106), (45, 106), (45, 0), (45, 105)] {
|
||||
let mut code = setup(bound, exec);
|
||||
// Give the old VCC bits on both sides of EXEC.
|
||||
code.extend(smov(106, 0xa5a5_5a5a));
|
||||
code.extend(vop3(op, dst, reverse));
|
||||
code.extend([0xbefe_03c1, 0x7e04_0200 | dst]);
|
||||
let input: Vec<_> = VALUES.into_iter().cycle().take(lanes).collect();
|
||||
let expected = input
|
||||
.chunks(32)
|
||||
.flat_map(|wave| {
|
||||
let mask = expected_mask(op, exec, wave, bound, reverse);
|
||||
std::iter::repeat_n(mask, wave.len())
|
||||
})
|
||||
.collect();
|
||||
cases.push(Case {
|
||||
form: name,
|
||||
family: if dst == 106 { "vcc_lo" } else { "sgpr" },
|
||||
label: format!("{name} s{dst}, bound={bound:#x}, reverse={reverse}, EXEC={exec:#x}, {lanes} lanes"),
|
||||
code: store(code),
|
||||
input,
|
||||
expected,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cases
|
||||
}
|
||||
|
||||
fn branch_cases() -> Vec<Case> {
|
||||
let mut cases = Vec::new();
|
||||
for (op, name) in FORMS {
|
||||
for dst in [0, 105, 106] {
|
||||
for exec in MASKS {
|
||||
for old_vcc in [0, 0xa5a5_5a5a] {
|
||||
for nonzero in [false, true] {
|
||||
let scc = old_vcc != 0;
|
||||
let mut code = setup(0, u32::MAX);
|
||||
// Seed s1 to detect an accidental second SGPR write to s0:s1.
|
||||
code.extend(vop3(199, 1, false));
|
||||
code.extend(smov(106, old_vcc));
|
||||
code.push(if scc { 0xbf06_8080 } else { 0xbf06_8180 });
|
||||
code.extend([0x7e04_0280, 0x7e08_0280, 0x7e0c_0284]); // v2 = v4 = 0, v6 = 4
|
||||
code.extend(smov(126, exec));
|
||||
code.extend(vop3(op, dst, false));
|
||||
code.extend([
|
||||
0x7e08_0281, // v4 = 1 only where EXEC was set
|
||||
0xbefe_03c1,
|
||||
// Independent bits for the VCC edge, SCC, and EXEC.
|
||||
if nonzero { 0xbf87_0001 } else { 0xbf86_0001 },
|
||||
0x7e04_0282, // v2 = 2 on fallthrough
|
||||
0xbf84_0001,
|
||||
0x3a04_0d02, // v2 ^= 4 if SCC = 1
|
||||
0x3a04_0902, // v2 ^= v4
|
||||
0x7e06_0201,
|
||||
0x3a04_0702, // v2 ^= s1
|
||||
0x7e06_026a,
|
||||
0x3a04_0702, // v2 ^= VCC_LO
|
||||
]);
|
||||
// The two waves give opposite results for several relations.
|
||||
let input: Vec<_> = std::iter::repeat_n(1, 32)
|
||||
.chain(std::iter::repeat_n(u32::MAX, 13))
|
||||
.collect();
|
||||
let mut expected = Vec::new();
|
||||
for wave in input.chunks(32) {
|
||||
let mask = expected_mask(op, exec, wave, 0, false);
|
||||
let vcc = if dst == 106 { mask } else { old_vcc };
|
||||
// §12.5: if (VCC == 0) / if (VCC != 0), PC = PC + signext(SIMM16 * 4) + 4.
|
||||
let taken = (vcc != 0) == nonzero;
|
||||
let s1 = u32::MAX >> (32 - wave.len());
|
||||
let marker = (u32::from(scc) << 2) | (u32::from(!taken) << 1);
|
||||
expected.extend(
|
||||
wave.iter()
|
||||
.enumerate()
|
||||
.map(|(n, _)| marker ^ ((exec >> n) & 1) ^ s1 ^ vcc),
|
||||
);
|
||||
}
|
||||
cases.push(Case {
|
||||
form: name,
|
||||
family: "vcc branch and flags",
|
||||
label: format!(
|
||||
"{name} s{dst}, EXEC={exec:#x}, VCC={old_vcc:#x}, NZ={nonzero}"
|
||||
),
|
||||
code: store(code),
|
||||
input,
|
||||
expected,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cases
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vop3_compare_matches_the_guide() {
|
||||
let masks = mask_cases();
|
||||
let branches = branch_cases();
|
||||
assert_eq!(masks.len(), 16 * 10 * 2 * 4 * 5);
|
||||
assert_eq!(branches.len(), 16 * 3 * 4 * 2 * 2);
|
||||
for case in masks.iter().chain(&branches) {
|
||||
assert_eq!(
|
||||
xenora_ref::execute(&case.code, &case.input).unwrap(),
|
||||
case.expected,
|
||||
"reference: {}",
|
||||
case.label
|
||||
);
|
||||
assert_eq!(
|
||||
independent_ref::execute(&case.code, &case.input).unwrap(),
|
||||
case.expected,
|
||||
"independent: {}",
|
||||
case.label
|
||||
);
|
||||
}
|
||||
eprintln!(
|
||||
"vop3_compare: {} mask and {} branch/flag cases per CPU interpreter",
|
||||
masks.len(),
|
||||
branches.len()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vop3_compare_rejects_excluded_operands_and_modifiers() {
|
||||
let mut count = 0;
|
||||
for (op, name) in FORMS {
|
||||
let setup = setup(7, u32::MAX);
|
||||
let offset = setup.len() * 4;
|
||||
let [head, tail] = vop3(op, 106, false);
|
||||
let mut check = |alu: &[u32]| {
|
||||
let mut code = setup.clone();
|
||||
code.extend(alu);
|
||||
let code = if alu.len() == 1 {
|
||||
words(&code)
|
||||
} else {
|
||||
// A successful decode would read its mask here and complete.
|
||||
code.push(0x7e04_026a);
|
||||
store(code)
|
||||
};
|
||||
let input = [1, 2];
|
||||
let err = xenora_ref::execute(&code, &input).expect_err(name);
|
||||
assert_eq!(err.offset, offset, "{name}: {alu:08x?} {err:?}");
|
||||
let err = independent_ref::execute(&code, &input).expect_err(name);
|
||||
assert!(
|
||||
err.starts_with(&format!("{offset:#x}:")),
|
||||
"{name}: {alu:08x?} {err}"
|
||||
);
|
||||
count += 1;
|
||||
};
|
||||
// ABS, OP_SEL and CLAMP in word 0. OMOD and NEG in word 1.
|
||||
for bit in 8..16 {
|
||||
check(&[head | 1 << bit, tail]);
|
||||
}
|
||||
for bit in 27..32 {
|
||||
check(&[head, tail | 1 << bit]);
|
||||
}
|
||||
for selector in 0..256 {
|
||||
check(&[head, (tail & !511) | selector]);
|
||||
check(&[head, (tail & !(511 << 9)) | selector << 9]);
|
||||
}
|
||||
for selector in (0..512).filter(|&s| s != 128) {
|
||||
check(&[head, (tail & !(511 << 18)) | selector << 18]);
|
||||
}
|
||||
for dst in 107..=255 {
|
||||
check(&[(head & !255) | dst, tail]);
|
||||
}
|
||||
check(&[head]);
|
||||
}
|
||||
assert_eq!(count, 16 * (13 + 512 + 511 + 149 + 1));
|
||||
eprintln!("vop3_compare: {count} rejections per CPU interpreter");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "requires a native Metal device with API and shader validation"]
|
||||
fn vop3_vcc_compare_matches_the_guide_on_native_metal() {
|
||||
assert_eq!(std::env::var("MTL_DEBUG_LAYER").as_deref(), Ok("1"));
|
||||
assert_eq!(std::env::var("MTL_SHADER_VALIDATION").as_deref(), Ok("1"));
|
||||
let cases: Vec<_> = mask_cases()
|
||||
.into_iter()
|
||||
.filter(|case| case.family == "vcc_lo")
|
||||
.collect();
|
||||
let (failures, programs) = harness::check_metal(&cases);
|
||||
failures.assert_none("native Metal disagrees with the guide");
|
||||
eprintln!(
|
||||
"vop3_compare: {} Metal cases in {programs} programs",
|
||||
cases.len()
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
//! Wave32 VOP3A integer ALU forms. AMD RDNA 2 ISA guide §§12.7, 12.7.1,
|
||||
//! 12.12 and 13.3.4. The expectations use the guide's arithmetic per lane.
|
||||
|
||||
#[path = "operand_domains/harness.rs"]
|
||||
#[allow(dead_code)]
|
||||
mod harness;
|
||||
#[path = "../independent_ref.rs"]
|
||||
mod independent_ref;
|
||||
|
||||
use harness::{Case, words};
|
||||
|
||||
const FORMS: [(u32, &str); 11] = [
|
||||
(265, "v_mul_i32_i24"),
|
||||
(266, "v_mul_hi_i32_i24"),
|
||||
(267, "v_mul_u32_u24"),
|
||||
(268, "v_mul_hi_u32_u24"),
|
||||
(273, "v_min_i32"),
|
||||
(274, "v_max_i32"),
|
||||
(275, "v_min_u32"),
|
||||
(276, "v_max_u32"),
|
||||
(286, "v_xnor_b32"),
|
||||
(294, "v_sub_nc_u32"),
|
||||
(295, "v_subrev_nc_u32"),
|
||||
];
|
||||
const VALUES: [u32; 12] = [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
0x007f_ffff,
|
||||
0x0080_0000,
|
||||
0x0080_0001,
|
||||
0x00ff_ffff,
|
||||
0xff80_0000,
|
||||
0xff00_0003,
|
||||
0x7fff_ffff,
|
||||
0x8000_0000,
|
||||
u32::MAX,
|
||||
];
|
||||
const MASKS: [u32; 4] = [u32::MAX, 0x5555_5555, 0x8000_0001, 0];
|
||||
|
||||
fn expected(op: u32, a: u32, b: u32) -> u32 {
|
||||
// S.i24 is bits 23:0 sign-extended from bit 23; S.u24 is zero-extended.
|
||||
let i24 = |x: u32| (i64::from(x & 0x7f_ffff)) - i64::from(x & 0x80_0000);
|
||||
let u24 = |x: u32| i64::from(x & 0xff_ffff);
|
||||
match op {
|
||||
// D.i32 = S0.i24 * S1.i24.
|
||||
265 => (i24(a) * i24(b)) as u32,
|
||||
// D.i32 = (S0.i24 * S1.i24)>>32.
|
||||
266 => (i24(a) * i24(b)).div_euclid(1 << 32) as u32,
|
||||
// D.u32 = S0.u24 * S1.u24.
|
||||
267 => (u24(a) * u24(b)) as u32,
|
||||
// D.u32 = (S0.u24 * S1.u24)>>32.
|
||||
268 => (u24(a) * u24(b)).div_euclid(1 << 32) as u32,
|
||||
// D.i32 = (S0.i32 < S1.i32 ? S0.i32 : S1.i32).
|
||||
273 => (a as i32).min(b as i32) as u32,
|
||||
// D.i32 = (S0.i32 >= S1.i32 ? S0.i32 : S1.i32).
|
||||
274 => (a as i32).max(b as i32) as u32,
|
||||
// D.u32 = (S0.u32 < S1.u32 ? S0.u32 : S1.u32).
|
||||
275 => a.min(b),
|
||||
// D.u32 = (S0.u32 >= S1.u32 ? S0.u32 : S1.u32).
|
||||
276 => a.max(b),
|
||||
// D.u32 = ~(S0.u32 ^ S1.u32).
|
||||
286 => !(a ^ b),
|
||||
// D.u32 = S0.u32 - S1.u32.
|
||||
294 => (i64::from(a) - i64::from(b)) as u32,
|
||||
// D.u32 = S1.u32 - S0.u32.
|
||||
295 => (i64::from(b) - i64::from(a)) as u32,
|
||||
_ => unreachable!("test only uses the listed forms"),
|
||||
}
|
||||
}
|
||||
|
||||
/// VOP3A: OP 25:16, VDST 7:0, three 9-bit sources, inline zero at SRC2.
|
||||
fn vop3(op: u32, dst: u32, a: u32, b: u32) -> [u32; 2] {
|
||||
[
|
||||
0xd400_0000 | op << 16 | dst,
|
||||
(256 + a) | (256 + b) << 9 | 128 << 18,
|
||||
]
|
||||
}
|
||||
|
||||
fn vmov(dst: u32, value: u32) -> [u32; 2] {
|
||||
[0x7e00_02ff | dst << 17, value]
|
||||
}
|
||||
|
||||
fn smov(dst: u32, value: u32) -> [u32; 2] {
|
||||
[0xbe80_03ff | dst << 16, value]
|
||||
}
|
||||
|
||||
fn setup(b: u32, exec: u32, scc: bool) -> Vec<u32> {
|
||||
let mut code = vec![0xe030_2000, 0x8000_0100, 0xbf8c_3f70]; // load v1
|
||||
code.extend(vmov(255, b));
|
||||
code.extend(vmov(2, 0xabad_1dea));
|
||||
code.extend(smov(106, 0x1357_9bdf));
|
||||
code.push(if scc { 0xbf06_8080 } else { 0xbf06_8180 });
|
||||
code.extend(smov(126, exec));
|
||||
code
|
||||
}
|
||||
|
||||
fn finish(mut code: Vec<u32>, dst: u32) -> Vec<u8> {
|
||||
// Restore EXEC, read D and VCC_LO, and XOR in v1 when SCC is set.
|
||||
code.extend([
|
||||
0xbefe_03c1,
|
||||
0x7e04_0300 | dst,
|
||||
0x7e0c_026a,
|
||||
0x3a04_0506,
|
||||
0xbf84_0001,
|
||||
0x3a04_0501,
|
||||
0xe070_2000,
|
||||
0x8001_0200,
|
||||
0xbbfd_0000,
|
||||
0xbf81_0000,
|
||||
]);
|
||||
words(&code)
|
||||
}
|
||||
|
||||
fn cases() -> Vec<Case> {
|
||||
let mut cases = Vec::new();
|
||||
for (op, name) in FORMS {
|
||||
for b in VALUES {
|
||||
for (dst, src0, src1) in [
|
||||
(2, 1, 255),
|
||||
(2, 255, 1),
|
||||
(1, 1, 255),
|
||||
(255, 1, 255),
|
||||
(255, 255, 255),
|
||||
] {
|
||||
for exec in MASKS {
|
||||
for lanes in [7, 32, 45] {
|
||||
let scc = dst == 255;
|
||||
let mut code = setup(b, exec, scc);
|
||||
code.extend(vop3(op, dst, src0, src1));
|
||||
let input: Vec<_> = VALUES.into_iter().cycle().take(lanes).collect();
|
||||
let expected = input
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(lane, &x)| {
|
||||
let read = |reg| if reg == 1 { x } else { b };
|
||||
// Guide §3.3: a disabled lane retains its previous VGPR.
|
||||
let d = if exec & (1 << (lane % 32)) != 0 {
|
||||
expected(op, read(src0), read(src1))
|
||||
} else {
|
||||
match dst {
|
||||
1 => x,
|
||||
255 => b,
|
||||
_ => 0xabad_1dea,
|
||||
}
|
||||
};
|
||||
d ^ 0x1357_9bdf ^ if scc { x } else { 0 }
|
||||
})
|
||||
.collect();
|
||||
cases.push(Case {
|
||||
form: name,
|
||||
family: "vop3 integer",
|
||||
label: format!("{name} v{dst}, v{src0}, v{src1} ({b:#x}), EXEC={exec:#x}, {lanes} lanes"),
|
||||
code: finish(code, dst),
|
||||
input,
|
||||
expected,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cases
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vop3_integer_matches_the_guide() {
|
||||
let cases = cases();
|
||||
assert_eq!(cases.len(), 11 * 12 * 5 * 4 * 3);
|
||||
for case in &cases {
|
||||
assert_eq!(
|
||||
xenora_ref::execute(&case.code, &case.input).unwrap(),
|
||||
case.expected,
|
||||
"reference: {}",
|
||||
case.label
|
||||
);
|
||||
assert_eq!(
|
||||
independent_ref::execute(&case.code, &case.input).unwrap(),
|
||||
case.expected,
|
||||
"independent: {}",
|
||||
case.label
|
||||
);
|
||||
}
|
||||
eprintln!("vop3_integer: {} cases per CPU interpreter", cases.len());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vop3_integer_rejects_excluded_operands_and_modifiers() {
|
||||
let mut count = 0;
|
||||
for (op, name) in FORMS {
|
||||
let setup = setup(7, u32::MAX, false);
|
||||
let offset = setup.len() * 4;
|
||||
let [head, tail] = vop3(op, 2, 1, 255);
|
||||
let mut check = |alu: &[u32]| {
|
||||
let mut code = setup.clone();
|
||||
code.extend(alu);
|
||||
let code = if alu.len() == 1 {
|
||||
words(&code)
|
||||
} else {
|
||||
finish(code, 2)
|
||||
};
|
||||
let input = [1, 2];
|
||||
let err = xenora_ref::execute(&code, &input).expect_err(name);
|
||||
assert_eq!(err.offset, offset, "{name}: {alu:08x?} {err:?}");
|
||||
let err = independent_ref::execute(&code, &input).expect_err(name);
|
||||
assert!(
|
||||
err.starts_with(&format!("{offset:#x}:")),
|
||||
"{name}: {alu:08x?} {err}"
|
||||
);
|
||||
count += 1;
|
||||
};
|
||||
// ABS, OP_SEL and CLAMP in word 0. OMOD and NEG in word 1.
|
||||
for bit in 8..16 {
|
||||
check(&[head | 1 << bit, tail]);
|
||||
}
|
||||
for bit in 27..32 {
|
||||
check(&[head, tail | 1 << bit]);
|
||||
}
|
||||
for selector in 0..256 {
|
||||
check(&[head, (tail & !511) | selector]);
|
||||
check(&[head, (tail & !(511 << 9)) | selector << 9]);
|
||||
}
|
||||
for selector in (0..512).filter(|&s| s != 128) {
|
||||
check(&[head, (tail & !(511 << 18)) | selector << 18]);
|
||||
}
|
||||
check(&[head]);
|
||||
}
|
||||
assert_eq!(count, 11 * (13 + 512 + 511 + 1));
|
||||
eprintln!("vop3_integer: {count} rejections per CPU interpreter");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "requires a native Metal device with API and shader validation"]
|
||||
fn vop3_integer_matches_the_guide_on_native_metal() {
|
||||
assert_eq!(std::env::var("MTL_DEBUG_LAYER").as_deref(), Ok("1"));
|
||||
assert_eq!(std::env::var("MTL_SHADER_VALIDATION").as_deref(), Ok("1"));
|
||||
let cases = cases();
|
||||
let (failures, programs) = harness::check_metal(&cases);
|
||||
failures.assert_none("native Metal disagrees with the guide");
|
||||
eprintln!(
|
||||
"vop3_integer: {} Metal cases in {programs} programs",
|
||||
cases.len()
|
||||
);
|
||||
}
|
||||
@@ -11,9 +11,7 @@
|
||||
//! 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 both widths.
|
||||
//!
|
||||
//! 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 +1167,82 @@ 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)
|
||||
fn production_compiler_lowers_the_16_bit_compares() {
|
||||
let cases = cases_at_width(16);
|
||||
harness::check_reference(&cases).assert_none("16-bit compare compilation and reference");
|
||||
check_compiler_rejections(16);
|
||||
eprintln!("vopc16: {} compiler acceptance cases", cases.len());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn production_compiler_emits_signed_and_unsigned_low_half_relations() {
|
||||
for (name, signed) in [("v_cmp_lt_i16", true), ("v_cmp_lt_u16", false)] {
|
||||
let code = code(&vmov(3, 7), None, &[vopc(form(name).op, 193, 3)]);
|
||||
let shader = compile(Architecture::Gfx1030, &code).unwrap();
|
||||
let predicate = shader
|
||||
.msl
|
||||
.lines()
|
||||
.find(|line| line.contains("uint pass = ("))
|
||||
.unwrap();
|
||||
let cast = if signed {
|
||||
"as_type<short>(ushort("
|
||||
} else {
|
||||
(vmov(3, 7).to_vec(), 3)
|
||||
"ushort("
|
||||
};
|
||||
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);
|
||||
assert_eq!(predicate.matches(cast).count(), 2, "{name}: {predicate}");
|
||||
assert!(!predicate.contains(">>"), "{name}: {predicate}");
|
||||
assert_eq!(
|
||||
predicate.matches("as_type<short>(").count(),
|
||||
if signed { 2 } else { 0 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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<Case> {
|
||||
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<long>(").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 +1260,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 +1284,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 a native Metal device with API and shader 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()
|
||||
);
|
||||
}
|
||||
@@ -79,6 +79,12 @@ class GenerateX86(unittest.TestCase):
|
||||
_, forms = generate_x86.load(REGISTRY)
|
||||
self.assertEqual({form["op"] for form in forms if form.get("lock")}, {"cmpxchg", "xadd"})
|
||||
|
||||
def test_string_forms_are_movs_and_stos_without_operands(self):
|
||||
_, forms = generate_x86.load(REGISTRY)
|
||||
self.assertEqual({form["op"] for form in forms if form["enc"] == "string"}, {"movs", "stos"})
|
||||
self.rejects(self.form('op = "movs"\nopcode = 0xD7\nenc = "string"\nsize = "b"\nimm = "ib"'), "not valid for string")
|
||||
self.rejects(self.form('op = "movs"\nopcode = 0xD7\nenc = "string"\nsize = "b"\nlock = true'), "LOCK needs a memory destination")
|
||||
|
||||
def test_unknown_vocabulary_is_rejected(self):
|
||||
self.rejects(self.form('op = "frob"\nopcode = 0xD7\nenc = "none"\nsize = "n"'), "unknown op")
|
||||
self.rejects(self.form('op = "nop"\nopcode = 0xD7\nenc = "none"\nsize = "z"'), "unknown size")
|
||||
|
||||
Reference in new issue
Block a user