mirror of
https://github.com/MacosPorters/betterxen.git
synced 2026-11-26 07:39:52 +00:00
Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7113e4c8ec | ||
|
|
93b12b28c0 | ||
|
|
195f4306ed | ||
|
|
2c711213bc | ||
|
|
2d9f83fabc | ||
|
|
bb90e7a156 | ||
|
|
a332ee60b4 | ||
|
|
b489d0d7b7 | ||
|
|
5ffb9d58a1 | ||
|
|
3221f0e333 |
No files matched your search
@@ -17,6 +17,7 @@ remains unsupported.
|
||||
- Extended the read-only RDNA2 planning CLI (`python3 -m qa rdna2`) with family/status filters, compact summaries, Codex-ready manifests under `artifacts/`, active-claim exclusion (family claims exclude those families; path-only claims block overlapping permitted files), coverage reconcile against `semantic_coverage` without inflating counts, and inventory diffs. Covered by `tests/qa/test_rdna2_plan.py`; planning only, no GPU production edits.
|
||||
|
||||
### Added
|
||||
- Added eight gfx1030 SOP2 64-bit logical forms with even scalar register pairs, inline integers and one zero-extended literal. The compiler resolves both result words and sets SCC from the full result. Local CPU oracle and LLVM fixture checks passed. Native Metal readback and independent acceptance are pending (part of #215).
|
||||
- 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.
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
use std::fmt;
|
||||
|
||||
pub use xenora_isa::{
|
||||
Architecture, CompareRelation, ExportTarget, Instruction, InterpolationPhase, ScalarAluOp,
|
||||
ScalarCompareOp, ScalarImmediateCompareOp, ScalarImmediateOp, ScalarSource, ScalarUnaryOp,
|
||||
SoppControlOp, VectorAluOp, VectorAluVop3Op, VectorCompareOp, VectorSource, VectorSwapOp,
|
||||
VectorUnaryOp,
|
||||
Architecture, CompareRelation, ExportTarget, Instruction, InterpolationPhase, ScalarAlu64Op,
|
||||
ScalarAluOp, ScalarCompareOp, ScalarImmediateCompareOp, ScalarImmediateOp, ScalarSource,
|
||||
ScalarSource64, ScalarUnaryOp, SoppControlOp, VectorAluOp, VectorAluVop3Op, VectorCompareOp,
|
||||
VectorSource, VectorSwapOp, VectorUnaryOp,
|
||||
};
|
||||
use xenora_isa::{
|
||||
BUFFER_LOAD_DWORD, BUFFER_STORE_DWORD, EXP, IMAGE_SAMPLE_LZ, S_WAITCNT_VSCNT, V_ADD_F32,
|
||||
@@ -406,6 +406,9 @@ fn decode_gfx1030(bytes: &[u8], offset: usize) -> Result<(Instruction, u8), Deco
|
||||
let instruction = op.decode(|| branch_target(immediate, offset, op.mnemonic()))?;
|
||||
return Ok((instruction, 4));
|
||||
}
|
||||
if let Some(op) = ScalarAlu64Op::from_word(first) {
|
||||
return scalar_alu64(op, first, bytes);
|
||||
}
|
||||
if let Some(op) = ScalarAluOp::from_word(first) {
|
||||
return scalar_alu(op, first, bytes);
|
||||
}
|
||||
@@ -494,6 +497,57 @@ fn scalar_alu(
|
||||
))
|
||||
}
|
||||
|
||||
// RDNA 2 ISA guide 3.6.3 and 5.2: normal 64-bit SGPR operands use even pairs.
|
||||
// The XML declares U64 literal operands; apply the guide's unsigned expansion (6.2.1).
|
||||
fn scalar_alu64(
|
||||
op: ScalarAlu64Op,
|
||||
first: u32,
|
||||
bytes: &[u8],
|
||||
) -> Result<(Instruction, u8), DecodeErrorKind> {
|
||||
let mnemonic = op.mnemonic();
|
||||
let dst = ((first >> 16) & 0x7f) as u8;
|
||||
if dst > 104 || !dst.is_multiple_of(2) {
|
||||
return Err(unsupported(
|
||||
mnemonic,
|
||||
"expected an even normal SGPR destination pair",
|
||||
));
|
||||
}
|
||||
let (left, right) = (first as u8, (first >> 8) as u8);
|
||||
if (left, right) == (255, 255) {
|
||||
return Err(unsupported(
|
||||
mnemonic,
|
||||
"only one source may select a literal",
|
||||
));
|
||||
}
|
||||
let read = |selector| {
|
||||
let (source, len) = scalar_source(selector, bytes, mnemonic)?;
|
||||
let source = match source {
|
||||
ScalarSource::Register(base) if base.is_multiple_of(2) => {
|
||||
ScalarSource64::RegisterPair(base)
|
||||
}
|
||||
ScalarSource::Register(_) => {
|
||||
return Err(unsupported(mnemonic, "expected an even SGPR source pair"));
|
||||
}
|
||||
ScalarSource::Immediate(value) if selector == 255 => {
|
||||
ScalarSource64::Immediate(u64::from(value))
|
||||
}
|
||||
ScalarSource::Immediate(value) => ScalarSource64::Immediate((value as i32) as u64),
|
||||
};
|
||||
Ok((source, len))
|
||||
};
|
||||
let (src0, len0) = read(left)?;
|
||||
let (src1, len1) = read(right)?;
|
||||
Ok((
|
||||
Instruction::ScalarAlu64 {
|
||||
op,
|
||||
dst,
|
||||
src0,
|
||||
src1,
|
||||
},
|
||||
len0.max(len1),
|
||||
))
|
||||
}
|
||||
|
||||
fn scalar_source(
|
||||
bits: u8,
|
||||
bytes: &[u8],
|
||||
|
||||
@@ -4,8 +4,8 @@ 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,
|
||||
ScalarAlu64Op, ScalarAluOp, ScalarImmediateOp, ScalarSource, ScalarSource64, ScalarUnaryOp,
|
||||
VectorAluOp, VectorAluVop3Op, VectorSource, VectorUnaryOp, decode, decode_at,
|
||||
};
|
||||
use xenora_isa::semantics::Signedness;
|
||||
use xenora_ref::{
|
||||
@@ -330,6 +330,33 @@ fn reference_op(instruction: Instruction) -> Op {
|
||||
src: VectorSource::Scalar(src),
|
||||
} => Op::MoveScalar(dst, src),
|
||||
Instruction::MoveB32 { dst, src } => Op::Move(dst, reference_source(src)),
|
||||
Instruction::ScalarAlu64 {
|
||||
op,
|
||||
dst,
|
||||
src0,
|
||||
src1,
|
||||
} => {
|
||||
let pair = |src| match src {
|
||||
ScalarSource64::RegisterPair(base) => {
|
||||
[Source::Register(base), Source::Register(base + 1)]
|
||||
}
|
||||
ScalarSource64::Immediate(bits) => [
|
||||
Source::Immediate(bits as u32),
|
||||
Source::Immediate((bits >> 32) as u32),
|
||||
],
|
||||
};
|
||||
let kind = match op {
|
||||
ScalarAlu64Op::AndB64 => ScalarAlu::And,
|
||||
ScalarAlu64Op::OrB64 => ScalarAlu::Or,
|
||||
ScalarAlu64Op::XorB64 => ScalarAlu::Xor,
|
||||
ScalarAlu64Op::Andn2B64 => ScalarAlu::AndNot,
|
||||
ScalarAlu64Op::Orn2B64 => ScalarAlu::OrNot,
|
||||
ScalarAlu64Op::NandB64 => ScalarAlu::Nand,
|
||||
ScalarAlu64Op::NorB64 => ScalarAlu::Nor,
|
||||
ScalarAlu64Op::XnorB64 => ScalarAlu::Xnor,
|
||||
};
|
||||
Op::ScalarLogicPair(kind, dst, pair(src0), pair(src1))
|
||||
}
|
||||
Instruction::VectorUnary { op, dst, src } => Op::VectorUnary(
|
||||
match op {
|
||||
VectorUnaryOp::NotB32 => VectorUnary::Not,
|
||||
@@ -586,6 +613,7 @@ fn compares_fixture_instructions_against_llvm() {
|
||||
include_bytes!("../../../fixtures/rdna2/ashr.bin"),
|
||||
include_bytes!("../../../fixtures/rdna2/scalar-alu.bin"),
|
||||
include_bytes!("../../../fixtures/rdna2/scalar-logic.bin"),
|
||||
include_bytes!("../../../fixtures/rdna2/scalar-logic-b64.bin"),
|
||||
include_bytes!("../../../fixtures/rdna2/scalar-compare.bin"),
|
||||
include_bytes!("../../../fixtures/rdna2/scalar-unary.bin"),
|
||||
include_bytes!("../../../fixtures/rdna2/scalar-arith.bin"),
|
||||
@@ -601,7 +629,7 @@ fn compares_fixture_instructions_against_llvm() {
|
||||
] {
|
||||
count += compare_against_llvm(fixture, &mut forms);
|
||||
}
|
||||
assert_eq!(forms.len(), 142, "forms compared: {forms:?}");
|
||||
assert_eq!(forms.len(), 150, "forms compared: {forms:?}");
|
||||
eprintln!(
|
||||
"{count} three-way instruction comparisons across {} forms",
|
||||
forms.len()
|
||||
|
||||
@@ -156,7 +156,7 @@ MASK = {"unchanged": "Unchanged", "lane_mask": "LaneMask"}
|
||||
WAVE = {"any": "Any", "wave32": "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"}
|
||||
WAVE_BY_KIND = {"alu64": "any", "control": "wave32", "vector_compare": "wave32", "vector_unary": "wave32", "vector_swap": "wave32"}
|
||||
VCC_VECTOR_PRIMITIVES = {
|
||||
("cselect", "bitwise"): "Select",
|
||||
("add", "unsigned"): "AddCarry",
|
||||
@@ -182,6 +182,10 @@ PINNED_DOCUMENTS = {
|
||||
"file": "amdgpu_isa_rdna2.xml",
|
||||
},
|
||||
}
|
||||
WIDE_LOGICAL_PRIMITIVES = {
|
||||
operation: ("nonzero", f"{operation}_nonzero_b64", False)
|
||||
for operation in ("and", "or", "xor", "andn2", "orn2", "nand", "nor", "xnor")
|
||||
}
|
||||
|
||||
# (operation, signedness) -> (required SCC effect, primitive, takes carry-in).
|
||||
# A form whose declaration is not a row here has no primitive and is rejected.
|
||||
@@ -275,7 +279,7 @@ 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"} | VOP3_COMBOS | {"dst_odd_pair", "src_odd_pair"}
|
||||
VECTOR_UNARY_PRIMITIVES = {
|
||||
("not", "bitwise"): "Not",
|
||||
("brev", "bitwise"): "ReverseBits",
|
||||
@@ -353,6 +357,21 @@ OPERAND_RULES = {
|
||||
"unsupported": UNSUPPORTED_COMBOS,
|
||||
"kind": "alu",
|
||||
},
|
||||
"sop2_sgpr_pair": {
|
||||
"rust": "Sop2SgprPair",
|
||||
"enum": "ScalarAlu64Op",
|
||||
"shape": {
|
||||
"family": "SOP2",
|
||||
"dst": {"field": "SDST", "class": "sgpr_pair", "min": 0, "max": 104},
|
||||
"src": [
|
||||
{"field": "SSRC0", "class": "scalar_source64"},
|
||||
{"field": "SSRC1", "class": "scalar_source64"},
|
||||
],
|
||||
"max_literals": 1,
|
||||
},
|
||||
"unsupported": UNSUPPORTED_COMBOS | {"dst_odd_pair", "src_odd_pair"},
|
||||
"kind": "alu64",
|
||||
},
|
||||
"sopc_scalar": {
|
||||
"rust": "SopcScalar",
|
||||
"enum": "ScalarCompareOp",
|
||||
@@ -815,6 +834,9 @@ 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 _rule_kind(form) == "alu64":
|
||||
if data_format != "FMT_NUM_U64":
|
||||
errors.append(f"{label}: {field} requires XML format FMT_NUM_U64, got {data_format}")
|
||||
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")
|
||||
@@ -903,7 +925,7 @@ def validate(registry, snapshot):
|
||||
)
|
||||
if form["exec"] != "unchanged":
|
||||
errors.append(f"{label}: exec {form['exec']} has no contract (requires unchanged)")
|
||||
expected_width = (_implemented_rule(form) or {}).get("width", 32)
|
||||
expected_width = 64 if _rule_kind(form) == "alu64" else (_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 (
|
||||
@@ -1003,6 +1025,10 @@ def validate(registry, snapshot):
|
||||
}[_rule_kind(form)]
|
||||
lowering = table.get(key)
|
||||
primitive = None if lowering is None else ("unchanged", lowering, False)
|
||||
elif _rule_kind(form) == "alu64":
|
||||
if RELATION_KEY in form:
|
||||
errors.append(f"{label}: {RELATION_KEY} on a non-compare operation")
|
||||
primitive = WIDE_LOGICAL_PRIMITIVES.get(form["operation"])
|
||||
else:
|
||||
if RELATION_KEY in form:
|
||||
errors.append(f"{label}: {RELATION_KEY} on a non-compare operation")
|
||||
@@ -1037,6 +1063,7 @@ def validate(registry, snapshot):
|
||||
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 "alu64" if _rule_kind(form) == "alu64"
|
||||
else "alu"
|
||||
):
|
||||
errors.append(f"{label}: operation {form['operation']} does not fit rule {form['operands']}")
|
||||
@@ -1776,6 +1803,18 @@ def _render_enum(rule_name, forms, snapshot, positions):
|
||||
out.append(f" Self::{form['variant']} => {expression},")
|
||||
out += [" }", " }", "}"]
|
||||
return out
|
||||
if kind == "alu64":
|
||||
out += [
|
||||
"",
|
||||
" /// The full-width result and new SCC.",
|
||||
" pub const fn evaluate(self, src0: u64, src1: u64) -> (u64, bool) {",
|
||||
" match self {",
|
||||
]
|
||||
for form in forms:
|
||||
_, function, _ = WIDE_LOGICAL_PRIMITIVES[form["operation"]]
|
||||
out.append(f" Self::{form['variant']} => primitive::{function}(src0, src1),")
|
||||
out += [" }", " }", "}"]
|
||||
return out
|
||||
out += [
|
||||
"",
|
||||
" /// Whether the operation reads SCC (carry-in, borrow-in or select condition).",
|
||||
|
||||
@@ -22,6 +22,23 @@ unsupported = [
|
||||
]
|
||||
|
||||
|
||||
[operand_rules.sop2_sgpr_pair]
|
||||
family = "SOP2"
|
||||
dst = { field = "SDST", class = "sgpr_pair", min = 0, max = 104 }
|
||||
src = [
|
||||
{ field = "SSRC0", class = "scalar_source64" },
|
||||
{ field = "SSRC1", class = "scalar_source64" },
|
||||
]
|
||||
# Even SGPR pairs, inline integers -16..64, or one zero-extended literal word.
|
||||
max_literals = 1
|
||||
# Encodings this rule rejects, so they stay unsupported rather than guessed.
|
||||
unsupported = [
|
||||
"dst_vcc", "dst_exec", "dst_ttmp", "dst_m0", "dst_null",
|
||||
"src_vcc", "src_exec", "src_m0", "src_ttmp", "src_float_inline",
|
||||
"src_special", "two_literals", "dst_odd_pair", "src_odd_pair",
|
||||
]
|
||||
|
||||
|
||||
[[form]]
|
||||
name = "S_ADD_U32"
|
||||
family = "SOP2"
|
||||
@@ -159,6 +176,27 @@ operands = "sop2_sgpr"
|
||||
spec = [{ document = "guide", section = "12.1", page = 102 }]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "S_AND_B64"
|
||||
family = "SOP2"
|
||||
opcode = 15
|
||||
variant = "AndB64"
|
||||
operation = "and"
|
||||
signedness = "bitwise"
|
||||
carry_in = "none"
|
||||
width = 64
|
||||
scc = "nonzero"
|
||||
vcc = "unchanged"
|
||||
exec = "unchanged"
|
||||
wave = "any"
|
||||
operands = "sop2_sgpr_pair"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.1", page = 103 },
|
||||
{ document = "guide", section = "5.2", page = 33 },
|
||||
{ document = "guide", section = "6.2.1", page = 43 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "S_OR_B32"
|
||||
family = "SOP2"
|
||||
@@ -176,6 +214,27 @@ operands = "sop2_sgpr"
|
||||
spec = [{ document = "guide", section = "12.1", page = 102 }]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "S_OR_B64"
|
||||
family = "SOP2"
|
||||
opcode = 17
|
||||
variant = "OrB64"
|
||||
operation = "or"
|
||||
signedness = "bitwise"
|
||||
carry_in = "none"
|
||||
width = 64
|
||||
scc = "nonzero"
|
||||
vcc = "unchanged"
|
||||
exec = "unchanged"
|
||||
wave = "any"
|
||||
operands = "sop2_sgpr_pair"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.1", page = 103 },
|
||||
{ document = "guide", section = "5.2", page = 33 },
|
||||
{ document = "guide", section = "6.2.1", page = 43 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "S_XOR_B32"
|
||||
family = "SOP2"
|
||||
@@ -193,6 +252,27 @@ operands = "sop2_sgpr"
|
||||
spec = [{ document = "guide", section = "12.1", page = 102 }]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "S_XOR_B64"
|
||||
family = "SOP2"
|
||||
opcode = 19
|
||||
variant = "XorB64"
|
||||
operation = "xor"
|
||||
signedness = "bitwise"
|
||||
carry_in = "none"
|
||||
width = 64
|
||||
scc = "nonzero"
|
||||
vcc = "unchanged"
|
||||
exec = "unchanged"
|
||||
wave = "any"
|
||||
operands = "sop2_sgpr_pair"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.1", page = 103 },
|
||||
{ document = "guide", section = "5.2", page = 33 },
|
||||
{ document = "guide", section = "6.2.1", page = 43 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
# ---- Stage C: further SOP2 logical and shift forms (#215) ----
|
||||
# Shifts use the low shift_count_bits of S1 as the count (guide 12.1 pseudocode).
|
||||
|
||||
@@ -213,6 +293,27 @@ operands = "sop2_sgpr"
|
||||
spec = [{ document = "guide", section = "12.1", page = 103 }]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "S_ANDN2_B64"
|
||||
family = "SOP2"
|
||||
opcode = 21
|
||||
variant = "Andn2B64"
|
||||
operation = "andn2"
|
||||
signedness = "bitwise"
|
||||
carry_in = "none"
|
||||
width = 64
|
||||
scc = "nonzero"
|
||||
vcc = "unchanged"
|
||||
exec = "unchanged"
|
||||
wave = "any"
|
||||
operands = "sop2_sgpr_pair"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.1", page = 103 },
|
||||
{ document = "guide", section = "5.2", page = 33 },
|
||||
{ document = "guide", section = "6.2.1", page = 43 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "S_ORN2_B32"
|
||||
family = "SOP2"
|
||||
@@ -230,6 +331,27 @@ operands = "sop2_sgpr"
|
||||
spec = [{ document = "guide", section = "12.1", page = 103 }]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "S_ORN2_B64"
|
||||
family = "SOP2"
|
||||
opcode = 23
|
||||
variant = "Orn2B64"
|
||||
operation = "orn2"
|
||||
signedness = "bitwise"
|
||||
carry_in = "none"
|
||||
width = 64
|
||||
scc = "nonzero"
|
||||
vcc = "unchanged"
|
||||
exec = "unchanged"
|
||||
wave = "any"
|
||||
operands = "sop2_sgpr_pair"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.1", page = 103 },
|
||||
{ document = "guide", section = "5.2", page = 33 },
|
||||
{ document = "guide", section = "6.2.1", page = 43 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "S_NAND_B32"
|
||||
family = "SOP2"
|
||||
@@ -247,6 +369,27 @@ operands = "sop2_sgpr"
|
||||
spec = [{ document = "guide", section = "12.1", page = 104 }]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "S_NAND_B64"
|
||||
family = "SOP2"
|
||||
opcode = 25
|
||||
variant = "NandB64"
|
||||
operation = "nand"
|
||||
signedness = "bitwise"
|
||||
carry_in = "none"
|
||||
width = 64
|
||||
scc = "nonzero"
|
||||
vcc = "unchanged"
|
||||
exec = "unchanged"
|
||||
wave = "any"
|
||||
operands = "sop2_sgpr_pair"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.1", page = 104 },
|
||||
{ document = "guide", section = "5.2", page = 33 },
|
||||
{ document = "guide", section = "6.2.1", page = 43 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "S_NOR_B32"
|
||||
family = "SOP2"
|
||||
@@ -264,6 +407,27 @@ operands = "sop2_sgpr"
|
||||
spec = [{ document = "guide", section = "12.1", page = 104 }]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "S_NOR_B64"
|
||||
family = "SOP2"
|
||||
opcode = 27
|
||||
variant = "NorB64"
|
||||
operation = "nor"
|
||||
signedness = "bitwise"
|
||||
carry_in = "none"
|
||||
width = 64
|
||||
scc = "nonzero"
|
||||
vcc = "unchanged"
|
||||
exec = "unchanged"
|
||||
wave = "any"
|
||||
operands = "sop2_sgpr_pair"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.1", page = 104 },
|
||||
{ document = "guide", section = "5.2", page = 33 },
|
||||
{ document = "guide", section = "6.2.1", page = 43 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "S_XNOR_B32"
|
||||
family = "SOP2"
|
||||
@@ -281,6 +445,27 @@ operands = "sop2_sgpr"
|
||||
spec = [{ document = "guide", section = "12.1", page = 104 }]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "S_XNOR_B64"
|
||||
family = "SOP2"
|
||||
opcode = 29
|
||||
variant = "XnorB64"
|
||||
operation = "xnor"
|
||||
signedness = "bitwise"
|
||||
carry_in = "none"
|
||||
width = 64
|
||||
scc = "nonzero"
|
||||
vcc = "unchanged"
|
||||
exec = "unchanged"
|
||||
wave = "any"
|
||||
operands = "sop2_sgpr_pair"
|
||||
spec = [
|
||||
{ document = "guide", section = "12.1", page = 104 },
|
||||
{ document = "guide", section = "5.2", page = 33 },
|
||||
{ document = "guide", section = "6.2.1", page = 43 },
|
||||
]
|
||||
verify = ["reference", "independent", "metal", "llvm_encoding"]
|
||||
|
||||
[[form]]
|
||||
name = "S_LSHL_B32"
|
||||
family = "SOP2"
|
||||
|
||||
+37
-2
@@ -19,8 +19,9 @@ pub use rdna2::{
|
||||
V_MOV_B32, V_MUL_F32, V_OR_B32, V_XOR_B32,
|
||||
};
|
||||
pub use semantics_gen::{
|
||||
ScalarAluOp, ScalarCompareOp, ScalarImmediateCompareOp, ScalarImmediateOp, ScalarUnaryOp,
|
||||
SoppControlOp, VectorAluOp, VectorAluVop3Op, VectorCompareOp, VectorSwapOp, VectorUnaryOp,
|
||||
ScalarAlu64Op, ScalarAluOp, ScalarCompareOp, ScalarImmediateCompareOp, ScalarImmediateOp,
|
||||
ScalarUnaryOp, SoppControlOp, VectorAluOp, VectorAluVop3Op, VectorCompareOp, VectorSwapOp,
|
||||
VectorUnaryOp,
|
||||
};
|
||||
|
||||
impl VectorAluOp {
|
||||
@@ -108,6 +109,27 @@ impl fmt::Display for ScalarSource {
|
||||
}
|
||||
}
|
||||
|
||||
/// A scalar 64-bit source.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum ScalarSource64 {
|
||||
/// The even base of an SGPR pair, low word first.
|
||||
RegisterPair(u8),
|
||||
/// Inline integer or expanded literal bits.
|
||||
Immediate(u64),
|
||||
}
|
||||
|
||||
impl fmt::Display for ScalarSource64 {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match *self {
|
||||
Self::RegisterPair(base) => write!(formatter, "s[{base}:{}]", base + 1),
|
||||
Self::Immediate(value) => match value as i64 {
|
||||
integer @ -16..=64 => write!(formatter, "{integer}"),
|
||||
_ => write!(formatter, "0x{value:x}"),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Relation tested by a SOPC or VOPC integer compare; S0 (SSRC0 or SRC0) is on
|
||||
/// the left.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
@@ -190,6 +212,13 @@ pub enum Instruction {
|
||||
dst: u8,
|
||||
src: ScalarSource,
|
||||
},
|
||||
/// SOP2 64-bit logic writing an even SGPR pair and setting SCC.
|
||||
ScalarAlu64 {
|
||||
op: ScalarAlu64Op,
|
||||
dst: u8,
|
||||
src0: ScalarSource64,
|
||||
src1: ScalarSource64,
|
||||
},
|
||||
/// SOP2 32-bit integer operation writing a normal SGPR (s0-s105) and, for
|
||||
/// most operations, SCC; `s_cselect_b32` also reads SCC.
|
||||
ScalarAlu {
|
||||
@@ -304,6 +333,7 @@ impl Instruction {
|
||||
Self::VectorSwap { op, .. } => op.assembly_name(),
|
||||
Self::VectorAluVop3 { op, .. } => op.assembly_name(),
|
||||
Self::ScalarUnary { op, .. } => op.mnemonic(),
|
||||
Self::ScalarAlu64 { op, .. } => op.mnemonic(),
|
||||
Self::ScalarAlu { op, .. } => op.mnemonic(),
|
||||
Self::ScalarCompare { op, .. } => op.mnemonic(),
|
||||
Self::ScalarImmediate { op, .. } => op.mnemonic(),
|
||||
@@ -367,6 +397,11 @@ impl fmt::Display for Instruction {
|
||||
Self::ScalarUnary { dst, src, .. } => {
|
||||
write!(formatter, " {}, {src}", ScalarDestination(dst))
|
||||
}
|
||||
Self::ScalarAlu64 {
|
||||
dst, src0, src1, ..
|
||||
} => {
|
||||
write!(formatter, " s[{dst}:{}], {src0}, {src1}", dst + 1)
|
||||
}
|
||||
Self::ScalarAlu {
|
||||
dst, src0, src1, ..
|
||||
} => write!(formatter, " {}, {src0}, {src1}", ScalarDestination(dst)),
|
||||
|
||||
@@ -332,6 +332,54 @@ pub const fn lshl_add_carry_u32(a: u32, b: u32, shift: u32) -> (u32, bool) {
|
||||
(sum as u32, sum >> 32 != 0)
|
||||
}
|
||||
|
||||
/// SOP2 AND over 64 bits, with SCC set for a nonzero result.
|
||||
pub const fn and_nonzero_b64(a: u64, b: u64) -> (u64, bool) {
|
||||
let value = a & b;
|
||||
(value, value != 0)
|
||||
}
|
||||
|
||||
/// SOP2 OR over 64 bits, with SCC set for a nonzero result.
|
||||
pub const fn or_nonzero_b64(a: u64, b: u64) -> (u64, bool) {
|
||||
let value = a | b;
|
||||
(value, value != 0)
|
||||
}
|
||||
|
||||
/// SOP2 XOR over 64 bits, with SCC set for a nonzero result.
|
||||
pub const fn xor_nonzero_b64(a: u64, b: u64) -> (u64, bool) {
|
||||
let value = a ^ b;
|
||||
(value, value != 0)
|
||||
}
|
||||
|
||||
/// SOP2 ANDN2 over 64 bits, with SCC set for a nonzero result.
|
||||
pub const fn andn2_nonzero_b64(a: u64, b: u64) -> (u64, bool) {
|
||||
let value = a & !b;
|
||||
(value, value != 0)
|
||||
}
|
||||
|
||||
/// SOP2 ORN2 over 64 bits, with SCC set for a nonzero result.
|
||||
pub const fn orn2_nonzero_b64(a: u64, b: u64) -> (u64, bool) {
|
||||
let value = a | !b;
|
||||
(value, value != 0)
|
||||
}
|
||||
|
||||
/// SOP2 NAND over 64 bits, with SCC set for a nonzero result.
|
||||
pub const fn nand_nonzero_b64(a: u64, b: u64) -> (u64, bool) {
|
||||
let value = !(a & b);
|
||||
(value, value != 0)
|
||||
}
|
||||
|
||||
/// SOP2 NOR over 64 bits, with SCC set for a nonzero result.
|
||||
pub const fn nor_nonzero_b64(a: u64, b: u64) -> (u64, bool) {
|
||||
let value = !(a | b);
|
||||
(value, value != 0)
|
||||
}
|
||||
|
||||
/// SOP2 XNOR over 64 bits, with SCC set for a nonzero result.
|
||||
pub const fn xnor_nonzero_b64(a: u64, b: u64) -> (u64, bool) {
|
||||
let value = !(a ^ b);
|
||||
(value, value != 0)
|
||||
}
|
||||
|
||||
/// A bitwise copy of the source (RDNA 2 guide section 12.3).
|
||||
pub(crate) const fn mov_b32(src: u32) -> u32 {
|
||||
src
|
||||
|
||||
@@ -253,6 +253,8 @@ pub enum OperandRule {
|
||||
/// SOP2: SDST is s0-s105; SSRC0/SSRC1 are s0-s105, inline integers -16..64
|
||||
/// or one literal word. Everything else is rejected as unsupported.
|
||||
Sop2Sgpr,
|
||||
/// SOP2: even normal SGPR pairs, inline integers or one zero-extended literal word.
|
||||
Sop2SgprPair,
|
||||
/// SOPC: no destination; SSRC0/SSRC1 as for SOP2 sources (s0-s105, inline
|
||||
/// integers -16..64 or one literal word). Everything else is rejected.
|
||||
SopcScalar,
|
||||
|
||||
+541
-147
@@ -348,18 +348,18 @@ impl ScalarUnaryOp {
|
||||
/// The validated registry row.
|
||||
pub fn semantics(self) -> &'static FormSemantics {
|
||||
&FORMS[match self {
|
||||
Self::MovB32 => 61,
|
||||
Self::NotB32 => 62,
|
||||
Self::BrevB32 => 63,
|
||||
Self::Bcnt0I32B32 => 64,
|
||||
Self::Bcnt1I32B32 => 65,
|
||||
Self::Ff0I32B32 => 66,
|
||||
Self::Ff1I32B32 => 67,
|
||||
Self::FlbitI32B32 => 68,
|
||||
Self::FlbitI32 => 69,
|
||||
Self::SextI32I8 => 70,
|
||||
Self::SextI32I16 => 71,
|
||||
Self::AbsI32 => 72,
|
||||
Self::MovB32 => 69,
|
||||
Self::NotB32 => 70,
|
||||
Self::BrevB32 => 71,
|
||||
Self::Bcnt0I32B32 => 72,
|
||||
Self::Bcnt1I32B32 => 73,
|
||||
Self::Ff0I32B32 => 74,
|
||||
Self::Ff1I32B32 => 75,
|
||||
Self::FlbitI32B32 => 76,
|
||||
Self::FlbitI32 => 77,
|
||||
Self::SextI32I8 => 78,
|
||||
Self::SextI32I16 => 79,
|
||||
Self::AbsI32 => 80,
|
||||
}]
|
||||
}
|
||||
|
||||
@@ -712,32 +712,32 @@ impl ScalarAluOp {
|
||||
Self::AddcU32 => 4,
|
||||
Self::SubbU32 => 5,
|
||||
Self::AndB32 => 6,
|
||||
Self::OrB32 => 7,
|
||||
Self::XorB32 => 8,
|
||||
Self::Andn2B32 => 9,
|
||||
Self::Orn2B32 => 10,
|
||||
Self::NandB32 => 11,
|
||||
Self::NorB32 => 12,
|
||||
Self::XnorB32 => 13,
|
||||
Self::LshlB32 => 14,
|
||||
Self::LshrB32 => 15,
|
||||
Self::AshrI32 => 16,
|
||||
Self::MinI32 => 17,
|
||||
Self::MinU32 => 18,
|
||||
Self::MaxI32 => 19,
|
||||
Self::MaxU32 => 20,
|
||||
Self::CselectB32 => 21,
|
||||
Self::BfmB32 => 22,
|
||||
Self::MulI32 => 23,
|
||||
Self::BfeU32 => 24,
|
||||
Self::BfeI32 => 25,
|
||||
Self::AbsdiffI32 => 26,
|
||||
Self::Lshl1AddU32 => 27,
|
||||
Self::Lshl2AddU32 => 28,
|
||||
Self::Lshl3AddU32 => 29,
|
||||
Self::Lshl4AddU32 => 30,
|
||||
Self::MulHiU32 => 31,
|
||||
Self::MulHiI32 => 32,
|
||||
Self::OrB32 => 8,
|
||||
Self::XorB32 => 10,
|
||||
Self::Andn2B32 => 12,
|
||||
Self::Orn2B32 => 14,
|
||||
Self::NandB32 => 16,
|
||||
Self::NorB32 => 18,
|
||||
Self::XnorB32 => 20,
|
||||
Self::LshlB32 => 22,
|
||||
Self::LshrB32 => 23,
|
||||
Self::AshrI32 => 24,
|
||||
Self::MinI32 => 25,
|
||||
Self::MinU32 => 26,
|
||||
Self::MaxI32 => 27,
|
||||
Self::MaxU32 => 28,
|
||||
Self::CselectB32 => 29,
|
||||
Self::BfmB32 => 30,
|
||||
Self::MulI32 => 31,
|
||||
Self::BfeU32 => 32,
|
||||
Self::BfeI32 => 33,
|
||||
Self::AbsdiffI32 => 34,
|
||||
Self::Lshl1AddU32 => 35,
|
||||
Self::Lshl2AddU32 => 36,
|
||||
Self::Lshl3AddU32 => 37,
|
||||
Self::Lshl4AddU32 => 38,
|
||||
Self::MulHiU32 => 39,
|
||||
Self::MulHiI32 => 40,
|
||||
}]
|
||||
}
|
||||
|
||||
@@ -945,6 +945,224 @@ impl ScalarAluOp {
|
||||
}
|
||||
}
|
||||
|
||||
/// SOP2 operations declared in the semantic registry (operand rule `sop2_sgpr_pair`).
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum ScalarAlu64Op {
|
||||
/// `s_and_b64` (SOP2 opcode 15): bitwise and, SCC = nonzero.
|
||||
AndB64,
|
||||
/// `s_or_b64` (SOP2 opcode 17): bitwise or, SCC = nonzero.
|
||||
OrB64,
|
||||
/// `s_xor_b64` (SOP2 opcode 19): bitwise xor, SCC = nonzero.
|
||||
XorB64,
|
||||
/// `s_andn2_b64` (SOP2 opcode 21): bitwise andn2, SCC = nonzero.
|
||||
Andn2B64,
|
||||
/// `s_orn2_b64` (SOP2 opcode 23): bitwise orn2, SCC = nonzero.
|
||||
Orn2B64,
|
||||
/// `s_nand_b64` (SOP2 opcode 25): bitwise nand, SCC = nonzero.
|
||||
NandB64,
|
||||
/// `s_nor_b64` (SOP2 opcode 27): bitwise nor, SCC = nonzero.
|
||||
NorB64,
|
||||
/// `s_xnor_b64` (SOP2 opcode 29): bitwise xnor, SCC = nonzero.
|
||||
XnorB64,
|
||||
}
|
||||
|
||||
/// ScalarAlu64Op by SOP2 OP field value; `None` for undeclared opcodes.
|
||||
const SCALAR_ALU64_OP_BY_OPCODE: [Option<ScalarAlu64Op>; 128] = [
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
Some(ScalarAlu64Op::AndB64),
|
||||
None,
|
||||
Some(ScalarAlu64Op::OrB64),
|
||||
None,
|
||||
Some(ScalarAlu64Op::XorB64),
|
||||
None,
|
||||
Some(ScalarAlu64Op::Andn2B64),
|
||||
None,
|
||||
Some(ScalarAlu64Op::Orn2B64),
|
||||
None,
|
||||
Some(ScalarAlu64Op::NandB64),
|
||||
None,
|
||||
Some(ScalarAlu64Op::NorB64),
|
||||
None,
|
||||
Some(ScalarAlu64Op::XnorB64),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
];
|
||||
|
||||
impl ScalarAlu64Op {
|
||||
/// Every operation, in registry order.
|
||||
pub const ALL: [Self; 8] = [
|
||||
Self::AndB64,
|
||||
Self::OrB64,
|
||||
Self::XorB64,
|
||||
Self::Andn2B64,
|
||||
Self::Orn2B64,
|
||||
Self::NandB64,
|
||||
Self::NorB64,
|
||||
Self::XnorB64,
|
||||
];
|
||||
|
||||
/// Selects the operation from a first instruction word: the SOP2 encoding
|
||||
/// bits (mask 0xc000_0000) and then the OP field (bits 23-29).
|
||||
pub const fn from_word(word: u32) -> Option<Self> {
|
||||
if word & 0xc000_0000 != 0x8000_0000 {
|
||||
return None;
|
||||
}
|
||||
SCALAR_ALU64_OP_BY_OPCODE[((word >> 23) & 0x7f) as usize]
|
||||
}
|
||||
|
||||
/// Lower-case mnemonic.
|
||||
pub const fn mnemonic(self) -> &'static str {
|
||||
match self {
|
||||
Self::AndB64 => "s_and_b64",
|
||||
Self::OrB64 => "s_or_b64",
|
||||
Self::XorB64 => "s_xor_b64",
|
||||
Self::Andn2B64 => "s_andn2_b64",
|
||||
Self::Orn2B64 => "s_orn2_b64",
|
||||
Self::NandB64 => "s_nand_b64",
|
||||
Self::NorB64 => "s_nor_b64",
|
||||
Self::XnorB64 => "s_xnor_b64",
|
||||
}
|
||||
}
|
||||
|
||||
/// The validated registry row.
|
||||
pub fn semantics(self) -> &'static FormSemantics {
|
||||
&FORMS[match self {
|
||||
Self::AndB64 => 7,
|
||||
Self::OrB64 => 9,
|
||||
Self::XorB64 => 11,
|
||||
Self::Andn2B64 => 13,
|
||||
Self::Orn2B64 => 15,
|
||||
Self::NandB64 => 17,
|
||||
Self::NorB64 => 19,
|
||||
Self::XnorB64 => 21,
|
||||
}]
|
||||
}
|
||||
|
||||
/// The full-width result and new SCC.
|
||||
pub const fn evaluate(self, src0: u64, src1: u64) -> (u64, bool) {
|
||||
match self {
|
||||
Self::AndB64 => primitive::and_nonzero_b64(src0, src1),
|
||||
Self::OrB64 => primitive::or_nonzero_b64(src0, src1),
|
||||
Self::XorB64 => primitive::xor_nonzero_b64(src0, src1),
|
||||
Self::Andn2B64 => primitive::andn2_nonzero_b64(src0, src1),
|
||||
Self::Orn2B64 => primitive::orn2_nonzero_b64(src0, src1),
|
||||
Self::NandB64 => primitive::nand_nonzero_b64(src0, src1),
|
||||
Self::NorB64 => primitive::nor_nonzero_b64(src0, src1),
|
||||
Self::XnorB64 => primitive::xnor_nonzero_b64(src0, src1),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// SOPC operations declared in the semantic registry (operand rule `sopc_scalar`).
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum ScalarCompareOp {
|
||||
@@ -1153,18 +1371,18 @@ impl ScalarCompareOp {
|
||||
/// The validated registry row.
|
||||
pub fn semantics(self) -> &'static FormSemantics {
|
||||
&FORMS[match self {
|
||||
Self::CmpEqI32 => 33,
|
||||
Self::CmpLgI32 => 34,
|
||||
Self::CmpGtI32 => 35,
|
||||
Self::CmpGeI32 => 36,
|
||||
Self::CmpLtI32 => 37,
|
||||
Self::CmpLeI32 => 38,
|
||||
Self::CmpEqU32 => 39,
|
||||
Self::CmpLgU32 => 40,
|
||||
Self::CmpGtU32 => 41,
|
||||
Self::CmpGeU32 => 42,
|
||||
Self::CmpLtU32 => 43,
|
||||
Self::CmpLeU32 => 44,
|
||||
Self::CmpEqI32 => 41,
|
||||
Self::CmpLgI32 => 42,
|
||||
Self::CmpGtI32 => 43,
|
||||
Self::CmpGeI32 => 44,
|
||||
Self::CmpLtI32 => 45,
|
||||
Self::CmpLeI32 => 46,
|
||||
Self::CmpEqU32 => 47,
|
||||
Self::CmpLgU32 => 48,
|
||||
Self::CmpGtU32 => 49,
|
||||
Self::CmpGeU32 => 50,
|
||||
Self::CmpLtU32 => 51,
|
||||
Self::CmpLeU32 => 52,
|
||||
}]
|
||||
}
|
||||
|
||||
@@ -1317,18 +1535,18 @@ impl ScalarImmediateCompareOp {
|
||||
/// The validated registry row.
|
||||
pub fn semantics(self) -> &'static FormSemantics {
|
||||
&FORMS[match self {
|
||||
Self::CmpkEqI32 => 47,
|
||||
Self::CmpkLgI32 => 48,
|
||||
Self::CmpkGtI32 => 49,
|
||||
Self::CmpkGeI32 => 50,
|
||||
Self::CmpkLtI32 => 51,
|
||||
Self::CmpkLeI32 => 52,
|
||||
Self::CmpkEqU32 => 53,
|
||||
Self::CmpkLgU32 => 54,
|
||||
Self::CmpkGtU32 => 55,
|
||||
Self::CmpkGeU32 => 56,
|
||||
Self::CmpkLtU32 => 57,
|
||||
Self::CmpkLeU32 => 58,
|
||||
Self::CmpkEqI32 => 55,
|
||||
Self::CmpkLgI32 => 56,
|
||||
Self::CmpkGtI32 => 57,
|
||||
Self::CmpkGeI32 => 58,
|
||||
Self::CmpkLtI32 => 59,
|
||||
Self::CmpkLeI32 => 60,
|
||||
Self::CmpkEqU32 => 61,
|
||||
Self::CmpkLgU32 => 62,
|
||||
Self::CmpkGtU32 => 63,
|
||||
Self::CmpkGeU32 => 64,
|
||||
Self::CmpkLtU32 => 65,
|
||||
Self::CmpkLeU32 => 66,
|
||||
}]
|
||||
}
|
||||
|
||||
@@ -1450,10 +1668,10 @@ impl ScalarImmediateOp {
|
||||
/// The validated registry row.
|
||||
pub fn semantics(self) -> &'static FormSemantics {
|
||||
&FORMS[match self {
|
||||
Self::MovkI32 => 45,
|
||||
Self::CmovkI32 => 46,
|
||||
Self::AddkI32 => 59,
|
||||
Self::MulkI32 => 60,
|
||||
Self::MovkI32 => 53,
|
||||
Self::CmovkI32 => 54,
|
||||
Self::AddkI32 => 67,
|
||||
Self::MulkI32 => 68,
|
||||
}]
|
||||
}
|
||||
|
||||
@@ -1687,12 +1905,12 @@ impl SoppControlOp {
|
||||
/// The validated registry row.
|
||||
pub fn semantics(self) -> &'static FormSemantics {
|
||||
&FORMS[match self {
|
||||
Self::EndProgram => 145,
|
||||
Self::Branch => 146,
|
||||
Self::BranchSccZero => 147,
|
||||
Self::BranchVccZero => 148,
|
||||
Self::BranchExecZero => 149,
|
||||
Self::WaitLoad => 150,
|
||||
Self::EndProgram => 153,
|
||||
Self::Branch => 154,
|
||||
Self::BranchSccZero => 155,
|
||||
Self::BranchVccZero => 156,
|
||||
Self::BranchExecZero => 157,
|
||||
Self::WaitLoad => 158,
|
||||
}]
|
||||
}
|
||||
|
||||
@@ -2031,7 +2249,7 @@ impl VectorSwapOp {
|
||||
/// The validated registry row.
|
||||
pub fn semantics(self) -> &'static FormSemantics {
|
||||
&FORMS[match self {
|
||||
Self::SwapB32 => 78,
|
||||
Self::SwapB32 => 86,
|
||||
}]
|
||||
}
|
||||
|
||||
@@ -2351,11 +2569,11 @@ impl VectorUnaryOp {
|
||||
/// The validated registry row.
|
||||
pub fn semantics(self) -> &'static FormSemantics {
|
||||
&FORMS[match self {
|
||||
Self::NotB32 => 73,
|
||||
Self::BfrevB32 => 74,
|
||||
Self::FfbhU32 => 75,
|
||||
Self::FfblB32 => 76,
|
||||
Self::FfbhI32 => 77,
|
||||
Self::NotB32 => 81,
|
||||
Self::BfrevB32 => 82,
|
||||
Self::FfbhU32 => 83,
|
||||
Self::FfblB32 => 84,
|
||||
Self::FfbhI32 => 85,
|
||||
}]
|
||||
}
|
||||
|
||||
@@ -2566,28 +2784,28 @@ impl VectorAluOp {
|
||||
/// The validated registry row.
|
||||
pub fn semantics(self) -> &'static FormSemantics {
|
||||
&FORMS[match self {
|
||||
Self::MulI32I24 => 79,
|
||||
Self::MulHiI32I24 => 80,
|
||||
Self::MulU32U24 => 81,
|
||||
Self::MulHiU32U24 => 82,
|
||||
Self::MinI32 => 83,
|
||||
Self::MaxI32 => 84,
|
||||
Self::MinU32 => 85,
|
||||
Self::MaxU32 => 86,
|
||||
Self::XnorB32 => 87,
|
||||
Self::AddNcU32 => 88,
|
||||
Self::SubNcU32 => 89,
|
||||
Self::SubrevNcU32 => 90,
|
||||
Self::LshrrevB32 => 91,
|
||||
Self::AshrrevI32 => 92,
|
||||
Self::LshlrevB32 => 93,
|
||||
Self::AndB32 => 94,
|
||||
Self::OrB32 => 95,
|
||||
Self::XorB32 => 96,
|
||||
Self::CndmaskB32 => 97,
|
||||
Self::AddCoCiU32 => 98,
|
||||
Self::SubCoCiU32 => 99,
|
||||
Self::SubrevCoCiU32 => 100,
|
||||
Self::MulI32I24 => 87,
|
||||
Self::MulHiI32I24 => 88,
|
||||
Self::MulU32U24 => 89,
|
||||
Self::MulHiU32U24 => 90,
|
||||
Self::MinI32 => 91,
|
||||
Self::MaxI32 => 92,
|
||||
Self::MinU32 => 93,
|
||||
Self::MaxU32 => 94,
|
||||
Self::XnorB32 => 95,
|
||||
Self::AddNcU32 => 96,
|
||||
Self::SubNcU32 => 97,
|
||||
Self::SubrevNcU32 => 98,
|
||||
Self::LshrrevB32 => 99,
|
||||
Self::AshrrevI32 => 100,
|
||||
Self::LshlrevB32 => 101,
|
||||
Self::AndB32 => 102,
|
||||
Self::OrB32 => 103,
|
||||
Self::XorB32 => 104,
|
||||
Self::CndmaskB32 => 105,
|
||||
Self::AddCoCiU32 => 106,
|
||||
Self::SubCoCiU32 => 107,
|
||||
Self::SubrevCoCiU32 => 108,
|
||||
}]
|
||||
}
|
||||
|
||||
@@ -3168,50 +3386,50 @@ impl VectorCompareOp {
|
||||
/// The validated registry row.
|
||||
pub fn semantics(self) -> &'static FormSemantics {
|
||||
&FORMS[match self {
|
||||
Self::CmpLtI32 => 101,
|
||||
Self::CmpEqI32 => 102,
|
||||
Self::CmpLeI32 => 103,
|
||||
Self::CmpGtI32 => 104,
|
||||
Self::CmpNeI32 => 105,
|
||||
Self::CmpGeI32 => 106,
|
||||
Self::CmpLtU32 => 107,
|
||||
Self::CmpEqU32 => 108,
|
||||
Self::CmpLeU32 => 109,
|
||||
Self::CmpGtU32 => 110,
|
||||
Self::CmpNeU32 => 111,
|
||||
Self::CmpGeU32 => 112,
|
||||
Self::CmpFI32 => 113,
|
||||
Self::CmpTI32 => 114,
|
||||
Self::CmpFU32 => 115,
|
||||
Self::CmpTU32 => 116,
|
||||
Self::CmpLtI64 => 117,
|
||||
Self::CmpEqI64 => 118,
|
||||
Self::CmpLeI64 => 119,
|
||||
Self::CmpGtI64 => 120,
|
||||
Self::CmpNeI64 => 121,
|
||||
Self::CmpGeI64 => 122,
|
||||
Self::CmpLtU64 => 123,
|
||||
Self::CmpEqU64 => 124,
|
||||
Self::CmpLeU64 => 125,
|
||||
Self::CmpGtU64 => 126,
|
||||
Self::CmpNeU64 => 127,
|
||||
Self::CmpGeU64 => 128,
|
||||
Self::CmpFI64 => 129,
|
||||
Self::CmpTI64 => 130,
|
||||
Self::CmpFU64 => 131,
|
||||
Self::CmpTU64 => 132,
|
||||
Self::CmpLtI16 => 133,
|
||||
Self::CmpEqI16 => 134,
|
||||
Self::CmpLeI16 => 135,
|
||||
Self::CmpGtI16 => 136,
|
||||
Self::CmpNeI16 => 137,
|
||||
Self::CmpGeI16 => 138,
|
||||
Self::CmpLtU16 => 139,
|
||||
Self::CmpEqU16 => 140,
|
||||
Self::CmpLeU16 => 141,
|
||||
Self::CmpGtU16 => 142,
|
||||
Self::CmpNeU16 => 143,
|
||||
Self::CmpGeU16 => 144,
|
||||
Self::CmpLtI32 => 109,
|
||||
Self::CmpEqI32 => 110,
|
||||
Self::CmpLeI32 => 111,
|
||||
Self::CmpGtI32 => 112,
|
||||
Self::CmpNeI32 => 113,
|
||||
Self::CmpGeI32 => 114,
|
||||
Self::CmpLtU32 => 115,
|
||||
Self::CmpEqU32 => 116,
|
||||
Self::CmpLeU32 => 117,
|
||||
Self::CmpGtU32 => 118,
|
||||
Self::CmpNeU32 => 119,
|
||||
Self::CmpGeU32 => 120,
|
||||
Self::CmpFI32 => 121,
|
||||
Self::CmpTI32 => 122,
|
||||
Self::CmpFU32 => 123,
|
||||
Self::CmpTU32 => 124,
|
||||
Self::CmpLtI64 => 125,
|
||||
Self::CmpEqI64 => 126,
|
||||
Self::CmpLeI64 => 127,
|
||||
Self::CmpGtI64 => 128,
|
||||
Self::CmpNeI64 => 129,
|
||||
Self::CmpGeI64 => 130,
|
||||
Self::CmpLtU64 => 131,
|
||||
Self::CmpEqU64 => 132,
|
||||
Self::CmpLeU64 => 133,
|
||||
Self::CmpGtU64 => 134,
|
||||
Self::CmpNeU64 => 135,
|
||||
Self::CmpGeU64 => 136,
|
||||
Self::CmpFI64 => 137,
|
||||
Self::CmpTI64 => 138,
|
||||
Self::CmpFU64 => 139,
|
||||
Self::CmpTU64 => 140,
|
||||
Self::CmpLtI16 => 141,
|
||||
Self::CmpEqI16 => 142,
|
||||
Self::CmpLeI16 => 143,
|
||||
Self::CmpGtI16 => 144,
|
||||
Self::CmpNeI16 => 145,
|
||||
Self::CmpGeI16 => 146,
|
||||
Self::CmpLtU16 => 147,
|
||||
Self::CmpEqU16 => 148,
|
||||
Self::CmpLeU16 => 149,
|
||||
Self::CmpGtU16 => 150,
|
||||
Self::CmpNeU16 => 151,
|
||||
Self::CmpGeU16 => 152,
|
||||
}]
|
||||
}
|
||||
|
||||
@@ -3464,13 +3682,13 @@ impl VectorAluVop3Op {
|
||||
/// The validated registry row of this encoding.
|
||||
pub fn semantics(self) -> &'static FormSemantics {
|
||||
&FORMS[match self {
|
||||
Self::AddNcU32 => 151,
|
||||
Self::AddNcU32 => 159,
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
/// Identity of every registry form and encoding variant, in registry order.
|
||||
pub const FORM_IDS: [(&str, EncodingFamily); 152] = [
|
||||
pub const FORM_IDS: [(&str, EncodingFamily); 160] = [
|
||||
("S_ADD_U32", EncodingFamily::Sop2),
|
||||
("S_SUB_U32", EncodingFamily::Sop2),
|
||||
("S_ADD_I32", EncodingFamily::Sop2),
|
||||
@@ -3478,13 +3696,21 @@ pub const FORM_IDS: [(&str, EncodingFamily); 152] = [
|
||||
("S_ADDC_U32", EncodingFamily::Sop2),
|
||||
("S_SUBB_U32", EncodingFamily::Sop2),
|
||||
("S_AND_B32", EncodingFamily::Sop2),
|
||||
("S_AND_B64", EncodingFamily::Sop2),
|
||||
("S_OR_B32", EncodingFamily::Sop2),
|
||||
("S_OR_B64", EncodingFamily::Sop2),
|
||||
("S_XOR_B32", EncodingFamily::Sop2),
|
||||
("S_XOR_B64", EncodingFamily::Sop2),
|
||||
("S_ANDN2_B32", EncodingFamily::Sop2),
|
||||
("S_ANDN2_B64", EncodingFamily::Sop2),
|
||||
("S_ORN2_B32", EncodingFamily::Sop2),
|
||||
("S_ORN2_B64", EncodingFamily::Sop2),
|
||||
("S_NAND_B32", EncodingFamily::Sop2),
|
||||
("S_NAND_B64", EncodingFamily::Sop2),
|
||||
("S_NOR_B32", EncodingFamily::Sop2),
|
||||
("S_NOR_B64", EncodingFamily::Sop2),
|
||||
("S_XNOR_B32", EncodingFamily::Sop2),
|
||||
("S_XNOR_B64", EncodingFamily::Sop2),
|
||||
("S_LSHL_B32", EncodingFamily::Sop2),
|
||||
("S_LSHR_B32", EncodingFamily::Sop2),
|
||||
("S_ASHR_I32", EncodingFamily::Sop2),
|
||||
@@ -3626,7 +3852,7 @@ pub const FORM_IDS: [(&str, EncodingFamily); 152] = [
|
||||
];
|
||||
|
||||
/// One validated row per registry form, in registry order.
|
||||
pub static FORMS: [FormSemantics; 152] = [
|
||||
pub static FORMS: [FormSemantics; 160] = [
|
||||
FormSemantics {
|
||||
name: "S_ADD_U32",
|
||||
family: EncodingFamily::Sop2,
|
||||
@@ -3774,6 +4000,27 @@ pub static FORMS: [FormSemantics; 152] = [
|
||||
spec: &[SpecRef { document: Document::Guide, section: "12.1", page: 102 }],
|
||||
verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal, Evidence::LlvmEncoding],
|
||||
},
|
||||
FormSemantics {
|
||||
name: "S_AND_B64",
|
||||
family: EncodingFamily::Sop2,
|
||||
opcode: 15,
|
||||
operation: Operation::And,
|
||||
signedness: Signedness::Bitwise,
|
||||
carry_in: CarryIn::None,
|
||||
width: 64,
|
||||
shift_count_bits: 0,
|
||||
shift_amount: 0,
|
||||
swap_sources: false,
|
||||
source_bits: 64,
|
||||
relation: None,
|
||||
scc: SccEffect::Nonzero,
|
||||
vcc: MaskEffect::Unchanged,
|
||||
exec: MaskEffect::Unchanged,
|
||||
wave: Wave::Any,
|
||||
operands: OperandRule::Sop2SgprPair,
|
||||
spec: &[SpecRef { document: Document::Guide, section: "12.1", page: 103 }, SpecRef { document: Document::Guide, section: "5.2", page: 33 }, SpecRef { document: Document::Guide, section: "6.2.1", page: 43 }],
|
||||
verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal, Evidence::LlvmEncoding],
|
||||
},
|
||||
FormSemantics {
|
||||
name: "S_OR_B32",
|
||||
family: EncodingFamily::Sop2,
|
||||
@@ -3795,6 +4042,27 @@ pub static FORMS: [FormSemantics; 152] = [
|
||||
spec: &[SpecRef { document: Document::Guide, section: "12.1", page: 102 }],
|
||||
verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal, Evidence::LlvmEncoding],
|
||||
},
|
||||
FormSemantics {
|
||||
name: "S_OR_B64",
|
||||
family: EncodingFamily::Sop2,
|
||||
opcode: 17,
|
||||
operation: Operation::Or,
|
||||
signedness: Signedness::Bitwise,
|
||||
carry_in: CarryIn::None,
|
||||
width: 64,
|
||||
shift_count_bits: 0,
|
||||
shift_amount: 0,
|
||||
swap_sources: false,
|
||||
source_bits: 64,
|
||||
relation: None,
|
||||
scc: SccEffect::Nonzero,
|
||||
vcc: MaskEffect::Unchanged,
|
||||
exec: MaskEffect::Unchanged,
|
||||
wave: Wave::Any,
|
||||
operands: OperandRule::Sop2SgprPair,
|
||||
spec: &[SpecRef { document: Document::Guide, section: "12.1", page: 103 }, SpecRef { document: Document::Guide, section: "5.2", page: 33 }, SpecRef { document: Document::Guide, section: "6.2.1", page: 43 }],
|
||||
verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal, Evidence::LlvmEncoding],
|
||||
},
|
||||
FormSemantics {
|
||||
name: "S_XOR_B32",
|
||||
family: EncodingFamily::Sop2,
|
||||
@@ -3816,6 +4084,27 @@ pub static FORMS: [FormSemantics; 152] = [
|
||||
spec: &[SpecRef { document: Document::Guide, section: "12.1", page: 102 }],
|
||||
verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal, Evidence::LlvmEncoding],
|
||||
},
|
||||
FormSemantics {
|
||||
name: "S_XOR_B64",
|
||||
family: EncodingFamily::Sop2,
|
||||
opcode: 19,
|
||||
operation: Operation::Xor,
|
||||
signedness: Signedness::Bitwise,
|
||||
carry_in: CarryIn::None,
|
||||
width: 64,
|
||||
shift_count_bits: 0,
|
||||
shift_amount: 0,
|
||||
swap_sources: false,
|
||||
source_bits: 64,
|
||||
relation: None,
|
||||
scc: SccEffect::Nonzero,
|
||||
vcc: MaskEffect::Unchanged,
|
||||
exec: MaskEffect::Unchanged,
|
||||
wave: Wave::Any,
|
||||
operands: OperandRule::Sop2SgprPair,
|
||||
spec: &[SpecRef { document: Document::Guide, section: "12.1", page: 103 }, SpecRef { document: Document::Guide, section: "5.2", page: 33 }, SpecRef { document: Document::Guide, section: "6.2.1", page: 43 }],
|
||||
verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal, Evidence::LlvmEncoding],
|
||||
},
|
||||
FormSemantics {
|
||||
name: "S_ANDN2_B32",
|
||||
family: EncodingFamily::Sop2,
|
||||
@@ -3837,6 +4126,27 @@ pub static FORMS: [FormSemantics; 152] = [
|
||||
spec: &[SpecRef { document: Document::Guide, section: "12.1", page: 103 }],
|
||||
verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal, Evidence::LlvmEncoding],
|
||||
},
|
||||
FormSemantics {
|
||||
name: "S_ANDN2_B64",
|
||||
family: EncodingFamily::Sop2,
|
||||
opcode: 21,
|
||||
operation: Operation::AndNot,
|
||||
signedness: Signedness::Bitwise,
|
||||
carry_in: CarryIn::None,
|
||||
width: 64,
|
||||
shift_count_bits: 0,
|
||||
shift_amount: 0,
|
||||
swap_sources: false,
|
||||
source_bits: 64,
|
||||
relation: None,
|
||||
scc: SccEffect::Nonzero,
|
||||
vcc: MaskEffect::Unchanged,
|
||||
exec: MaskEffect::Unchanged,
|
||||
wave: Wave::Any,
|
||||
operands: OperandRule::Sop2SgprPair,
|
||||
spec: &[SpecRef { document: Document::Guide, section: "12.1", page: 103 }, SpecRef { document: Document::Guide, section: "5.2", page: 33 }, SpecRef { document: Document::Guide, section: "6.2.1", page: 43 }],
|
||||
verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal, Evidence::LlvmEncoding],
|
||||
},
|
||||
FormSemantics {
|
||||
name: "S_ORN2_B32",
|
||||
family: EncodingFamily::Sop2,
|
||||
@@ -3858,6 +4168,27 @@ pub static FORMS: [FormSemantics; 152] = [
|
||||
spec: &[SpecRef { document: Document::Guide, section: "12.1", page: 103 }],
|
||||
verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal, Evidence::LlvmEncoding],
|
||||
},
|
||||
FormSemantics {
|
||||
name: "S_ORN2_B64",
|
||||
family: EncodingFamily::Sop2,
|
||||
opcode: 23,
|
||||
operation: Operation::OrNot,
|
||||
signedness: Signedness::Bitwise,
|
||||
carry_in: CarryIn::None,
|
||||
width: 64,
|
||||
shift_count_bits: 0,
|
||||
shift_amount: 0,
|
||||
swap_sources: false,
|
||||
source_bits: 64,
|
||||
relation: None,
|
||||
scc: SccEffect::Nonzero,
|
||||
vcc: MaskEffect::Unchanged,
|
||||
exec: MaskEffect::Unchanged,
|
||||
wave: Wave::Any,
|
||||
operands: OperandRule::Sop2SgprPair,
|
||||
spec: &[SpecRef { document: Document::Guide, section: "12.1", page: 103 }, SpecRef { document: Document::Guide, section: "5.2", page: 33 }, SpecRef { document: Document::Guide, section: "6.2.1", page: 43 }],
|
||||
verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal, Evidence::LlvmEncoding],
|
||||
},
|
||||
FormSemantics {
|
||||
name: "S_NAND_B32",
|
||||
family: EncodingFamily::Sop2,
|
||||
@@ -3879,6 +4210,27 @@ pub static FORMS: [FormSemantics; 152] = [
|
||||
spec: &[SpecRef { document: Document::Guide, section: "12.1", page: 104 }],
|
||||
verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal, Evidence::LlvmEncoding],
|
||||
},
|
||||
FormSemantics {
|
||||
name: "S_NAND_B64",
|
||||
family: EncodingFamily::Sop2,
|
||||
opcode: 25,
|
||||
operation: Operation::Nand,
|
||||
signedness: Signedness::Bitwise,
|
||||
carry_in: CarryIn::None,
|
||||
width: 64,
|
||||
shift_count_bits: 0,
|
||||
shift_amount: 0,
|
||||
swap_sources: false,
|
||||
source_bits: 64,
|
||||
relation: None,
|
||||
scc: SccEffect::Nonzero,
|
||||
vcc: MaskEffect::Unchanged,
|
||||
exec: MaskEffect::Unchanged,
|
||||
wave: Wave::Any,
|
||||
operands: OperandRule::Sop2SgprPair,
|
||||
spec: &[SpecRef { document: Document::Guide, section: "12.1", page: 104 }, SpecRef { document: Document::Guide, section: "5.2", page: 33 }, SpecRef { document: Document::Guide, section: "6.2.1", page: 43 }],
|
||||
verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal, Evidence::LlvmEncoding],
|
||||
},
|
||||
FormSemantics {
|
||||
name: "S_NOR_B32",
|
||||
family: EncodingFamily::Sop2,
|
||||
@@ -3900,6 +4252,27 @@ pub static FORMS: [FormSemantics; 152] = [
|
||||
spec: &[SpecRef { document: Document::Guide, section: "12.1", page: 104 }],
|
||||
verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal, Evidence::LlvmEncoding],
|
||||
},
|
||||
FormSemantics {
|
||||
name: "S_NOR_B64",
|
||||
family: EncodingFamily::Sop2,
|
||||
opcode: 27,
|
||||
operation: Operation::Nor,
|
||||
signedness: Signedness::Bitwise,
|
||||
carry_in: CarryIn::None,
|
||||
width: 64,
|
||||
shift_count_bits: 0,
|
||||
shift_amount: 0,
|
||||
swap_sources: false,
|
||||
source_bits: 64,
|
||||
relation: None,
|
||||
scc: SccEffect::Nonzero,
|
||||
vcc: MaskEffect::Unchanged,
|
||||
exec: MaskEffect::Unchanged,
|
||||
wave: Wave::Any,
|
||||
operands: OperandRule::Sop2SgprPair,
|
||||
spec: &[SpecRef { document: Document::Guide, section: "12.1", page: 104 }, SpecRef { document: Document::Guide, section: "5.2", page: 33 }, SpecRef { document: Document::Guide, section: "6.2.1", page: 43 }],
|
||||
verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal, Evidence::LlvmEncoding],
|
||||
},
|
||||
FormSemantics {
|
||||
name: "S_XNOR_B32",
|
||||
family: EncodingFamily::Sop2,
|
||||
@@ -3921,6 +4294,27 @@ pub static FORMS: [FormSemantics; 152] = [
|
||||
spec: &[SpecRef { document: Document::Guide, section: "12.1", page: 104 }],
|
||||
verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal, Evidence::LlvmEncoding],
|
||||
},
|
||||
FormSemantics {
|
||||
name: "S_XNOR_B64",
|
||||
family: EncodingFamily::Sop2,
|
||||
opcode: 29,
|
||||
operation: Operation::Xnor,
|
||||
signedness: Signedness::Bitwise,
|
||||
carry_in: CarryIn::None,
|
||||
width: 64,
|
||||
shift_count_bits: 0,
|
||||
shift_amount: 0,
|
||||
swap_sources: false,
|
||||
source_bits: 64,
|
||||
relation: None,
|
||||
scc: SccEffect::Nonzero,
|
||||
vcc: MaskEffect::Unchanged,
|
||||
exec: MaskEffect::Unchanged,
|
||||
wave: Wave::Any,
|
||||
operands: OperandRule::Sop2SgprPair,
|
||||
spec: &[SpecRef { document: Document::Guide, section: "12.1", page: 104 }, SpecRef { document: Document::Guide, section: "5.2", page: 33 }, SpecRef { document: Document::Guide, section: "6.2.1", page: 43 }],
|
||||
verify: &[Evidence::Reference, Evidence::Independent, Evidence::Metal, Evidence::LlvmEncoding],
|
||||
},
|
||||
FormSemantics {
|
||||
name: "S_LSHL_B32",
|
||||
family: EncodingFamily::Sop2,
|
||||
|
||||
@@ -5,8 +5,8 @@ use xenora_isa::semantics::{
|
||||
CarryIn, FORM_IDS, FORMS, GENERATED_SCHEMA, MaskEffect, SCHEMA, SccEffect, Signedness, Wave,
|
||||
};
|
||||
use xenora_isa::{
|
||||
CompareRelation, ScalarAluOp, ScalarCompareOp, ScalarImmediateCompareOp, ScalarImmediateOp,
|
||||
ScalarUnaryOp, VectorAluOp, VectorAluVop3Op, VectorCompareOp,
|
||||
CompareRelation, ScalarAlu64Op, ScalarAluOp, ScalarCompareOp, ScalarImmediateCompareOp,
|
||||
ScalarImmediateOp, ScalarUnaryOp, VectorAluOp, VectorAluVop3Op, VectorCompareOp,
|
||||
};
|
||||
|
||||
#[test]
|
||||
@@ -60,8 +60,21 @@ fn scalar_alu_dispatch_selects_exactly_the_registry_sop2_forms() {
|
||||
assert_eq!(op.reads_scc(), row.carry_in == CarryIn::Scc);
|
||||
assert_eq!(op.writes_scc(), row.scc != SccEffect::Unchanged);
|
||||
}
|
||||
for op in ScalarAlu64Op::ALL {
|
||||
let row = op.semantics();
|
||||
assert_eq!(row.family, EncodingFamily::Sop2);
|
||||
assert_eq!(row.width, 64);
|
||||
assert_eq!(row.name.to_ascii_lowercase(), op.mnemonic());
|
||||
assert_eq!(row.carry_in, CarryIn::None);
|
||||
assert_eq!(row.scc, SccEffect::Nonzero);
|
||||
}
|
||||
dispatch_selects_exactly(EncodingFamily::Sop2, |word| {
|
||||
ScalarAluOp::from_word(word).map(|op| op.semantics().name)
|
||||
let narrow = ScalarAluOp::from_word(word);
|
||||
let wide = ScalarAlu64Op::from_word(word);
|
||||
assert!(narrow.is_none() || wide.is_none());
|
||||
narrow
|
||||
.map(|op| op.semantics().name)
|
||||
.or_else(|| wide.map(|op| op.semantics().name))
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+66
-16
@@ -63,6 +63,8 @@ pub enum Op {
|
||||
WideCompare(Comparison, CompareWidth, CompareSource, u8),
|
||||
/// SOP2 operation writing an SGPR and SCC.
|
||||
Scalar(ScalarAlu, u8, Source, Source),
|
||||
/// SOP2 logical operation writing two scalar words and SCC.
|
||||
ScalarLogicPair(ScalarAlu, u8, [Source; 2], [Source; 2]),
|
||||
/// SOPC `s_cmp_eq_{i32,u32}` (opcodes 0 and 6, identical per guide 12.4).
|
||||
CompareEqual(Source, Source),
|
||||
/// The other SOPC 32-bit integer compares (opcodes 1-5 and 7-11), writing
|
||||
@@ -676,11 +678,13 @@ pub fn decode(code: &[u8]) -> Result<Vec<DecodedInstruction>, ReferenceError> {
|
||||
&& low & 0x7f <= 105
|
||||
&& matches!(
|
||||
(high & 0x3f) << 1 | low >> 7,
|
||||
0..=10 | 14 | 16 | 18 | 20 | 22 | 24 | 26 | 28 | 30 | 32 | 34
|
||||
0..=10 | 14..=30 | 32 | 34
|
||||
| 36 | 38..=40 | 44 | 46..=49 | 53 | 54
|
||||
) =>
|
||||
{
|
||||
let kind = match (high & 0x3f) << 1 | low >> 7 {
|
||||
let opcode = (high & 0x3f) << 1 | low >> 7;
|
||||
let wide = (15..=29).contains(&opcode) && opcode % 2 == 1;
|
||||
let kind = match opcode {
|
||||
0 => ScalarAlu::Add,
|
||||
1 => ScalarAlu::Subtract,
|
||||
2 => ScalarAlu::AddSigned,
|
||||
@@ -692,14 +696,14 @@ pub fn decode(code: &[u8]) -> Result<Vec<DecodedInstruction>, ReferenceError> {
|
||||
8 => ScalarAlu::Maximum { signed: true },
|
||||
9 => ScalarAlu::Maximum { signed: false },
|
||||
10 => ScalarAlu::Select,
|
||||
14 => ScalarAlu::And,
|
||||
16 => ScalarAlu::Or,
|
||||
18 => ScalarAlu::Xor,
|
||||
20 => ScalarAlu::AndNot,
|
||||
22 => ScalarAlu::OrNot,
|
||||
24 => ScalarAlu::Nand,
|
||||
26 => ScalarAlu::Nor,
|
||||
28 => ScalarAlu::Xnor,
|
||||
14 | 15 => ScalarAlu::And,
|
||||
16 | 17 => ScalarAlu::Or,
|
||||
18 | 19 => ScalarAlu::Xor,
|
||||
20 | 21 => ScalarAlu::AndNot,
|
||||
22 | 23 => ScalarAlu::OrNot,
|
||||
24 | 25 => ScalarAlu::Nand,
|
||||
26 | 27 => ScalarAlu::Nor,
|
||||
28 | 29 => ScalarAlu::Xnor,
|
||||
30 => ScalarAlu::ShiftLeft,
|
||||
32 => ScalarAlu::ShiftRight,
|
||||
34 => ScalarAlu::ArithmeticShiftRight,
|
||||
@@ -712,12 +716,23 @@ pub fn decode(code: &[u8]) -> Result<Vec<DecodedInstruction>, ReferenceError> {
|
||||
53 => ScalarAlu::MultiplyHigh { signed: false },
|
||||
_ => ScalarAlu::MultiplyHigh { signed: true },
|
||||
};
|
||||
let (left, left_length) = decode_scalar(*left, tail, offset)?;
|
||||
let (right, right_length) = decode_scalar(*right, tail, offset)?;
|
||||
(
|
||||
Op::Scalar(kind, low & 0x7f, left, right),
|
||||
left_length.max(right_length),
|
||||
)
|
||||
let dst = low & 0x7f;
|
||||
let (lhs, left_length) = decode_scalar(*left, tail, offset)?;
|
||||
let (rhs, right_length) = decode_scalar(*right, tail, offset)?;
|
||||
let op = if wide {
|
||||
if !dst.is_multiple_of(2) {
|
||||
return Err(error(offset, "unaligned scalar destination pair"));
|
||||
}
|
||||
Op::ScalarLogicPair(
|
||||
kind,
|
||||
dst,
|
||||
scalar_pair(lhs, *left, offset)?,
|
||||
scalar_pair(rhs, *right, offset)?,
|
||||
)
|
||||
} else {
|
||||
Op::Scalar(kind, dst, lhs, rhs)
|
||||
};
|
||||
(op, left_length.max(right_length))
|
||||
}
|
||||
[lo, hi, opcode @ (0x82 | 0x84 | 0x86 | 0x88), 0xbf, ..] => {
|
||||
let words = i16::from_le_bytes([*lo, *hi]);
|
||||
@@ -888,6 +903,18 @@ pub fn decode(code: &[u8]) -> Result<Vec<DecodedInstruction>, ReferenceError> {
|
||||
Ok(program)
|
||||
}
|
||||
|
||||
// Guide 3.6.3 and 5.2: low SGPR first. U64 literal fields in the XML
|
||||
// use unsigned expansion (guide 6.2.1); negative inline values retain their sign.
|
||||
fn scalar_pair(low: Source, selector: u8, offset: usize) -> Result<[Source; 2], ReferenceError> {
|
||||
let high = match low {
|
||||
Source::Register(base) if base.is_multiple_of(2) => Source::Register(base + 1),
|
||||
Source::Register(_) => return Err(error(offset, "unaligned scalar source pair")),
|
||||
Source::Immediate(_) if (193..=208).contains(&selector) => Source::Immediate(u32::MAX),
|
||||
Source::Immediate(_) => Source::Immediate(0),
|
||||
};
|
||||
Ok([low, high])
|
||||
}
|
||||
|
||||
fn decode_scalar(
|
||||
selector: u8,
|
||||
tail: &[u8],
|
||||
@@ -1301,6 +1328,29 @@ fn execute_wave(program: &[DecodedInstruction], input: &[u32]) -> Result<Vec<u32
|
||||
}
|
||||
}
|
||||
}
|
||||
Op::ScalarLogicPair(kind, dst, lhs, rhs) => {
|
||||
if dst < 8 {
|
||||
return Err(error(offset, "write to a reserved resource SGPR"));
|
||||
}
|
||||
// Each dword uses the same boolean equation (guide 12.1).
|
||||
// Evaluate both before writing, since either pair may alias SDST.
|
||||
let logic = |a: u32, b: u32| match kind {
|
||||
ScalarAlu::And => a & b,
|
||||
ScalarAlu::Or => a | b,
|
||||
ScalarAlu::Xor => a ^ b,
|
||||
ScalarAlu::AndNot => a & !b,
|
||||
ScalarAlu::OrNot => a | !b,
|
||||
ScalarAlu::Nand => !(a & b),
|
||||
ScalarAlu::Nor => !(a | b),
|
||||
ScalarAlu::Xnor => !(a ^ b),
|
||||
_ => unreachable!("only SOP2 logical opcodes decode as pairs"),
|
||||
};
|
||||
let low = logic(read_scalar(lhs[0])?, read_scalar(rhs[0])?);
|
||||
let high = logic(read_scalar(lhs[1])?, read_scalar(rhs[1])?);
|
||||
scalars[usize::from(dst)] = Some(low);
|
||||
scalars[usize::from(dst) + 1] = Some(high);
|
||||
scc = Some(low != 0 || high != 0);
|
||||
}
|
||||
Op::Scalar(kind, dst, lhs, rhs) => {
|
||||
if dst < 8 {
|
||||
return Err(error(offset, "write to a reserved resource SGPR"));
|
||||
|
||||
@@ -10,9 +10,9 @@ 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, VectorLowering, VectorSource, VectorUnary,
|
||||
VectorVcc,
|
||||
DecodeError, DecodedInstruction, Instruction, ScalarSource, ScalarSource64, ScalarUnaryOp,
|
||||
VectorAluOp, VectorAluVop3Op, VectorBinary, VectorCompareOp, VectorLowering, VectorSource,
|
||||
VectorUnary, VectorVcc,
|
||||
};
|
||||
|
||||
/// SGPR index of `vcc_lo`.
|
||||
@@ -1051,6 +1051,29 @@ fn lift(decoded: &[DecodedInstruction], code_len: usize) -> Result<Vec<(usize, O
|
||||
}
|
||||
continue;
|
||||
}
|
||||
Instruction::ScalarAlu64 {
|
||||
op,
|
||||
dst,
|
||||
src0,
|
||||
src1,
|
||||
} => {
|
||||
if dst < 8 {
|
||||
return Err(error("scalar ALU would modify a resource descriptor"));
|
||||
}
|
||||
let read_pair = |source| match source {
|
||||
ScalarSource64::Immediate(value) => Ok(value),
|
||||
ScalarSource64::RegisterPair(base) => {
|
||||
let low = read_scalar(ScalarSource::Register(base))?;
|
||||
let high = read_scalar(ScalarSource::Register(base + 1))?;
|
||||
Ok(u64::from(low) | (u64::from(high) << 32))
|
||||
}
|
||||
};
|
||||
let (value, flag) = op.evaluate(read_pair(src0)?, read_pair(src1)?);
|
||||
scalars[usize::from(dst)] = Some(value as u32);
|
||||
scalars[usize::from(dst) + 1] = Some((value >> 32) as u32);
|
||||
scc = Some(flag);
|
||||
continue;
|
||||
}
|
||||
Instruction::ScalarAlu {
|
||||
op,
|
||||
dst,
|
||||
|
||||
@@ -392,6 +392,20 @@ fn vector_compares_lower_to_per_thread_wave_masks_and_selects() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn scalar_logic_b64_fixture_matches_goldens() {
|
||||
let code = include_bytes!("../../../fixtures/rdna2/scalar-logic-b64.bin");
|
||||
let compiled = compile(Architecture::Gfx1030, code).unwrap();
|
||||
assert_eq!(
|
||||
compiled.ir,
|
||||
include_str!("../../../fixtures/golden/scalar-logic-b64.ir")
|
||||
);
|
||||
assert_eq!(
|
||||
compiled.msl,
|
||||
include_str!("../../../fixtures/golden/scalar-logic-b64.metal")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vector_vcc_fixture_matches_ir_and_msl_goldens() {
|
||||
let code = include_bytes!("../../../fixtures/rdna2/vector-vcc.bin");
|
||||
|
||||
@@ -24,6 +24,7 @@ either path. The [changelog](../CHANGELOG.md) records notable changes.
|
||||
- [Instruction coverage](shaders/instruction-coverage.md) — Desktop gfx1030 instruction forms, operand limits, and CPU and GPU results.
|
||||
- [Semantic coverage](shaders/semantic-coverage.md) — Generated per-family counts of identified, declared, decoded, lowered and verified gfx1030 forms.
|
||||
- [SOP2 scalar ALU](shaders/scalar-alu.md) — Supported scalar add, subtract and bitwise forms, their SCC rules and sources.
|
||||
- [SOP2 64-bit logic](shaders/scalar-logic-b64.md) — Register pairs, literal expansion, SCC and local verification.
|
||||
- [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.
|
||||
|
||||
@@ -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: 158 of 158. Accepted Metal forms · Apple M5: 18 of 158. Accepted guest milestones · X1–X4: 4 of 4</desc>
|
||||
<desc id="description">Decoded gfx1030 forms: 166 of 166. Accepted Metal forms · Apple M5: 18 of 166. 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">158 / 158</text>
|
||||
<text x="510" y="58" font-size="13" text-anchor="end">166 / 166</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 / 158</text>
|
||||
<text x="510" y="96" font-size="13" text-anchor="end">18 / 166</text>
|
||||
<rect x="20" y="103" width="490" height="4" rx="2" fill="#3c4a58"/>
|
||||
<rect x="20" y="103" width="55.82" height="4" rx="2" fill="#88c6bd"/>
|
||||
<rect x="20" y="103" width="53.13" 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 |
@@ -67,13 +67,21 @@ The wider LLVM operand matrix exercises decoding only. ABI means application bin
|
||||
| `s_addc_u32` | SOP2, normal SGPR destination; normal SGPR, inline integer or literal sources with at most one literal; adds SCC; SCC = carry-out | `820980FF 7FFFFFFF` | yes | yes | three-way passed | resolved scalar state and SCC | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `s_subb_u32` | SOP2, normal SGPR destination; normal SGPR, inline integer or literal sources with at most one literal; subtracts SCC; SCC = borrow | `828B0809` | yes | yes | three-way passed | resolved scalar state and SCC | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `s_and_b32` | SOP2, normal SGPR destination; normal SGPR, inline integer or literal sources with at most one literal; SCC = result != 0 | `870D090C` | yes | yes | three-way passed | resolved scalar state and SCC | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `s_and_b64` | SOP2, even SGPR pairs, inline integers or one zero-extended literal, SCC = full result != 0 | 4 B, 8 B with literal | yes | yes | three-way passed | resolved scalar pairs and SCC | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `s_or_b32` | SOP2, normal SGPR destination; normal SGPR, inline integer or literal sources with at most one literal; SCC = result != 0 | `880ED00D` | yes | yes | three-way passed | resolved scalar state and SCC | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `s_or_b64` | SOP2, even SGPR pairs, inline integers or one zero-extended literal, SCC = full result != 0 | 4 B, 8 B with literal | yes | yes | three-way passed | resolved scalar pairs and SCC | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `s_xor_b32` | SOP2, normal SGPR destination; normal SGPR, inline integer or literal sources with at most one literal; SCC = result != 0 | `890C0A0B` | yes | yes | three-way passed | resolved scalar state and SCC | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `s_xor_b64` | SOP2, even SGPR pairs, inline integers or one zero-extended literal, SCC = full result != 0 | 4 B, 8 B with literal | yes | yes | three-way passed | resolved scalar pairs and SCC | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `s_andn2_b32` | SOP2, normal SGPR destination; normal SGPR, inline integer or literal sources with at most one literal; D = S0 & ~S1; SCC = result != 0 | `8A09FF08 FF00FF00` | yes | yes | three-way passed | resolved scalar state and SCC | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `s_andn2_b64` | SOP2, even SGPR pairs, inline integers or one zero-extended literal, SCC = full result != 0 | 4 B, 8 B with literal | yes | yes | three-way passed | resolved scalar pairs and SCC | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `s_orn2_b32` | SOP2, normal SGPR destination; normal SGPR, inline integer or literal sources with at most one literal; D = S0 \| ~S1; SCC = result != 0 | `8B0AC109` | yes | yes | three-way passed | resolved scalar state and SCC | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `s_orn2_b64` | SOP2, even SGPR pairs, inline integers or one zero-extended literal, SCC = full result != 0 | 4 B, 8 B with literal | yes | yes | three-way passed | resolved scalar pairs and SCC | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `s_nand_b32` | SOP2, normal SGPR destination; normal SGPR, inline integer or literal sources with at most one literal; D = ~(S0 & S1); SCC = result != 0 | `8C0B0808` | yes | yes | three-way passed | resolved scalar state and SCC | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `s_nand_b64` | SOP2, even SGPR pairs, inline integers or one zero-extended literal, SCC = full result != 0 | 4 B, 8 B with literal | yes | yes | three-way passed | resolved scalar pairs and SCC | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `s_nor_b32` | SOP2, normal SGPR destination; normal SGPR, inline integer or literal sources with at most one literal; D = ~(S0 \| S1); SCC = result != 0 | `8D0C090B` | yes | yes | three-way passed | resolved scalar state and SCC | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `s_nor_b64` | SOP2, even SGPR pairs, inline integers or one zero-extended literal, SCC = full result != 0 | 4 B, 8 B with literal | yes | yes | three-way passed | resolved scalar pairs and SCC | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `s_xnor_b32` | SOP2, normal SGPR destination; normal SGPR, inline integer or literal sources with at most one literal; D = ~(S0 ^ S1); SCC = result != 0 | `8E0D080C` | yes | yes | three-way passed | resolved scalar state and SCC | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `s_xnor_b64` | SOP2, even SGPR pairs, inline integers or one zero-extended literal, SCC = full result != 0 | 4 B, 8 B with literal | yes | yes | three-way passed | resolved scalar pairs and SCC | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `s_lshl_b32` | SOP2, normal SGPR destination; normal SGPR, inline integer or literal sources with at most one literal; D = S0 << S1[4:0]; SCC = result != 0 | `8F0EA40D` | yes | yes | three-way passed | resolved scalar state and SCC | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `s_lshr_b32` | SOP2, normal SGPR destination; normal SGPR, inline integer or literal sources with at most one literal; D = S0 >> S1[4:0], zero fill; SCC = result != 0 | `900FFF0E FFFFFFE1` | yes | yes | three-way passed | resolved scalar state and SCC | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
| `s_ashr_i32` | SOP2, normal SGPR destination; normal SGPR, inline integer or literal sources with at most one literal; D = S0 >> S1[4:0], sign fill; SCC = result != 0 | `91109F0E` | yes | yes | three-way passed | resolved scalar state and SCC | implemented | local known-answer test passed | local Apple M5 readback passed; acceptance pending |
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
# SOP2 64-bit scalar logic
|
||||
|
||||
The gfx1030 decoder and synthetic compute compiler support eight two-source
|
||||
scalar logical instructions. S0 and S1 are the first and second sources.
|
||||
Every instruction sets the scalar condition code (SCC) if any of the 64
|
||||
result bits is set, and clears SCC otherwise.
|
||||
|
||||
| Instruction | SOP2 opcode | Result |
|
||||
| --- | --- | --- |
|
||||
| `s_and_b64` | 15 | `S0 & S1` |
|
||||
| `s_or_b64` | 17 | `S0 \| S1` |
|
||||
| `s_xor_b64` | 19 | `S0 ^ S1` |
|
||||
| `s_andn2_b64` | 21 | `S0 & ~S1` |
|
||||
| `s_orn2_b64` | 23 | `S0 \| ~S1` |
|
||||
| `s_nand_b64` | 25 | `~(S0 & S1)` |
|
||||
| `s_nor_b64` | 27 | `~(S0 \| S1)` |
|
||||
| `s_xnor_b64` | 29 | `~(S0 ^ S1)` |
|
||||
|
||||
The AMD RDNA 2 ISA reference guide gives the equations in §12.1 and the SOP2
|
||||
fields in §13.1.1. Each scalar general-purpose register (SGPR) pair starts at
|
||||
an even register from s0 to s104. The low word is in s[n] and the high word
|
||||
in s[n+1] (§3.6.3 and §5.2). The operands are read before either result word
|
||||
is written, so either source pair may alias the destination.
|
||||
|
||||
Inline selectors 128–208 supply integers from −16 to 64 (§5.2), with negative
|
||||
values represented in 64-bit two's complement. One source may use selector
|
||||
255 and consume a following literal dword. The pinned XML also defines a
|
||||
`has_lit_0_has_lit_1` form, where both sources name the same literal; Xenora
|
||||
does not accept it yet and rejects a second 255 selector (a subset restriction,
|
||||
not a guide rule). The pinned AMD XML declares the
|
||||
SOP2 logical literal operands as unsigned 64-bit values (`FMT_NUM_U64`). The
|
||||
unsigned expansion rule in §6.2.1 gives them a zero high word even when bit
|
||||
31 of the literal is set.
|
||||
|
||||
Odd pair bases, two literal selectors, floating-point inline constants and
|
||||
special operands are unsupported. The special operands include the vector
|
||||
condition code (VCC), execution mask (EXEC), M0, trap temporaries (TTMP),
|
||||
NULL, SCC as a source, and other non-SGPR selectors. The synthetic compute
|
||||
compiler also rejects writes to resource registers s0–s7 and reads from
|
||||
either half of an uninitialized pair. Other 64-bit SOP2 operations, including
|
||||
shifts and bit-field extraction, remain outside this subset.
|
||||
|
||||
The compiler resolves pairs and SCC at translation time and emits Metal
|
||||
Shading Language for the resulting vector operations. The original
|
||||
`scalar-logic-b64.s` fixture uses all eight instructions and folds their
|
||||
results into an XOR key. Local CPU checks cover 4,432 oracle cases and 2,608
|
||||
operand rejections (on both interpreters and the compiler), and the LLVM
|
||||
three-way check covers fixture disassembly and instruction boundaries. Through
|
||||
the translator, the 4,432 cases also pass on native Metal (Apple M5, API and
|
||||
shader validation on: 185 programs). These are local checks against the guide,
|
||||
XML and LLVM; independent acceptance is pending.
|
||||
|
||||
```sh
|
||||
cargo test --locked -p xenora-semantic-review --test sop2_b64
|
||||
MTL_DEBUG_LAYER=1 MTL_SHADER_VALIDATION=1 cargo test --locked -p xenora-semantic-review --test sop2_b64 sop2_b64_oracle_matches_native_metal -- --ignored
|
||||
```
|
||||
@@ -25,7 +25,7 @@ acceptance remain outside the verified count. All results concern synthetic fixt
|
||||
| SCRATCH | 22 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
|
||||
| SMEM | 14 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
|
||||
| SOP1 | 65 | 12 | 12 | 12 | 12 | 12 | 1 | 1 | 11 |
|
||||
| SOP2 | 51 | 33 | 33 | 33 | 33 | 33 | 0 | 0 | 12 |
|
||||
| SOP2 | 51 | 41 | 41 | 41 | 41 | 41 | 0 | 0 | 14 |
|
||||
| SOPC | 18 | 12 | 12 | 12 | 12 | 12 | 1 | 1 | 7 |
|
||||
| SOPK | 27 | 17 | 16 | 17 | 17 | 17 | 1 | 1 | 5 |
|
||||
| SOPP | 36 | 6 | 6 | 6 | 6 | 6 | 4 | 4 | 0 |
|
||||
@@ -36,7 +36,7 @@ acceptance remain outside the verified count. All results concern synthetic fixt
|
||||
| VOP3P | 29 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
|
||||
| VOP3SDST | 10 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
|
||||
| VOPC | 190 | 28 | 44 | 44 | 44 | 44 | 0 | 0 | 9 |
|
||||
| **Total** | 1465 | 142 | 152 | 162 | 158 | 158 | 18 | 18 | 78 |
|
||||
| **Total** | 1465 | 150 | 160 | 170 | 166 | 166 | 18 | 18 | 80 |
|
||||
|
||||
## Unsupported operand variants
|
||||
|
||||
@@ -47,6 +47,7 @@ The table counts distinct variant names per family across registry operand rules
|
||||
| SOP1 | `sop1_move` | `dst_m0`, `dst_null`, `dst_ttmp`, `src_exec`, `src_float_inline`, `src_m0`, `src_special`, `src_ttmp`, `src_vcc` |
|
||||
| SOP1 | `sop1_sgpr` | `dst_exec`, `dst_m0`, `dst_null`, `dst_ttmp`, `dst_vcc`, `src_exec`, `src_float_inline`, `src_m0`, `src_special`, `src_ttmp`, `src_vcc` |
|
||||
| SOP2 | `sop2_sgpr` | `dst_exec`, `dst_m0`, `dst_null`, `dst_ttmp`, `dst_vcc`, `src_exec`, `src_float_inline`, `src_m0`, `src_special`, `src_ttmp`, `src_vcc`, `two_literals` |
|
||||
| SOP2 | `sop2_sgpr_pair` | `dst_exec`, `dst_m0`, `dst_null`, `dst_odd_pair`, `dst_ttmp`, `dst_vcc`, `src_exec`, `src_float_inline`, `src_m0`, `src_odd_pair`, `src_special`, `src_ttmp`, `src_vcc`, `two_literals` |
|
||||
| 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` |
|
||||
|
||||
@@ -6,7 +6,8 @@ the decoder uses. This page explains where entries live, what each field means,
|
||||
how to check and regenerate the tables, and what the generator does not do for
|
||||
you.
|
||||
|
||||
The registry covers the nine SOP2 forms listed in [SOP2 scalar ALU](scalar-alu.md).
|
||||
The registry covers the forms counted in [semantic coverage](semantic-coverage.md); the SOP2
|
||||
forms are listed in [SOP2 scalar ALU](scalar-alu.md) and [64-bit scalar logic](scalar-logic-b64.md).
|
||||
|
||||
## Files
|
||||
|
||||
@@ -98,7 +99,9 @@ The root file holds:
|
||||
(an SGPR, an inline integer -16 to 64, or a literal word) and at most one
|
||||
literal. A rule's `unsupported` list names the encodings it rejects, which
|
||||
stay unsupported instead of being guessed. The list must name exactly the
|
||||
encodings the decoder rejects.
|
||||
encodings the decoder rejects. For SOP2 64-bit logic, `sop2_sgpr_pair`
|
||||
requires even SGPR pair bases and accepts one zero-extended literal word.
|
||||
See [SOP2 64-bit logic](scalar-logic-b64.md) for the operand contract.
|
||||
|
||||
Each `[[form]]` entry has exactly these fields. A missing or unknown field is an
|
||||
error.
|
||||
@@ -112,7 +115,7 @@ error.
|
||||
| `operation` | The primitive the form uses | `add`, `sub`, `and`, `or`, `xor`, `andn2`, `orn2`, `nand`, `nor`, `xnor`, `lshl`, `lshr`, `ashr`, `min`, `max`, `cselect`, `bfm`, `mul`, `mul_hi`, `bfe`, `absdiff`, `lshl_add`, `mul24`, `mul_hi24` (vector only), `mov` (SOP1 and SOPK), `cmov` (SOPK only), `compare` and the SOP1 unaries |
|
||||
| `signedness` | How operands are read | `unsigned`, `signed`, `bitwise` (always `bitwise` for the logical operations, `cselect` and `bfm`; never for the arithmetic ones, `add`, `sub`, `min`, `max`, `mul`, `mul_hi`, `bfe`, `absdiff` and `lshl_add`; shifts take their primitive's signedness) |
|
||||
| `carry_in` | 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` |
|
||||
| `width` | Operand and result width in bits (operand width for compares) | `32`, `16` with `vopc_vcc_half`, or `64` with `sop2_sgpr_pair` or `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` |
|
||||
|
||||
@@ -687,6 +687,18 @@ recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "s_and_b64"
|
||||
encoding = "SOP2, even SGPR pairs, inline integers or one zero-extended literal, SCC = full result != 0"
|
||||
representation = "4 B, 8 B with literal"
|
||||
lowering = "resolved scalar pairs and SCC"
|
||||
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 = "s_or_b32"
|
||||
encoding = "SOP2, normal SGPR destination; normal SGPR, inline integer or literal sources with at most one literal; SCC = result != 0"
|
||||
@@ -699,6 +711,18 @@ recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "s_or_b64"
|
||||
encoding = "SOP2, even SGPR pairs, inline integers or one zero-extended literal, SCC = full result != 0"
|
||||
representation = "4 B, 8 B with literal"
|
||||
lowering = "resolved scalar pairs and SCC"
|
||||
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 = "s_xor_b32"
|
||||
encoding = "SOP2, normal SGPR destination; normal SGPR, inline integer or literal sources with at most one literal; SCC = result != 0"
|
||||
@@ -711,6 +735,18 @@ recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "s_xor_b64"
|
||||
encoding = "SOP2, even SGPR pairs, inline integers or one zero-extended literal, SCC = full result != 0"
|
||||
representation = "4 B, 8 B with literal"
|
||||
lowering = "resolved scalar pairs and SCC"
|
||||
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 = "s_andn2_b32"
|
||||
encoding = "SOP2, normal SGPR destination; normal SGPR, inline integer or literal sources with at most one literal; D = S0 & ~S1; SCC = result != 0"
|
||||
@@ -723,6 +759,18 @@ recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "s_andn2_b64"
|
||||
encoding = "SOP2, even SGPR pairs, inline integers or one zero-extended literal, SCC = full result != 0"
|
||||
representation = "4 B, 8 B with literal"
|
||||
lowering = "resolved scalar pairs and SCC"
|
||||
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 = "s_orn2_b32"
|
||||
encoding = "SOP2, normal SGPR destination; normal SGPR, inline integer or literal sources with at most one literal; D = S0 | ~S1; SCC = result != 0"
|
||||
@@ -735,6 +783,18 @@ recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "s_orn2_b64"
|
||||
encoding = "SOP2, even SGPR pairs, inline integers or one zero-extended literal, SCC = full result != 0"
|
||||
representation = "4 B, 8 B with literal"
|
||||
lowering = "resolved scalar pairs and SCC"
|
||||
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 = "s_nand_b32"
|
||||
encoding = "SOP2, normal SGPR destination; normal SGPR, inline integer or literal sources with at most one literal; D = ~(S0 & S1); SCC = result != 0"
|
||||
@@ -747,6 +807,18 @@ recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "s_nand_b64"
|
||||
encoding = "SOP2, even SGPR pairs, inline integers or one zero-extended literal, SCC = full result != 0"
|
||||
representation = "4 B, 8 B with literal"
|
||||
lowering = "resolved scalar pairs and SCC"
|
||||
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 = "s_nor_b32"
|
||||
encoding = "SOP2, normal SGPR destination; normal SGPR, inline integer or literal sources with at most one literal; D = ~(S0 | S1); SCC = result != 0"
|
||||
@@ -759,6 +831,18 @@ recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "s_nor_b64"
|
||||
encoding = "SOP2, even SGPR pairs, inline integers or one zero-extended literal, SCC = full result != 0"
|
||||
representation = "4 B, 8 B with literal"
|
||||
lowering = "resolved scalar pairs and SCC"
|
||||
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 = "s_xnor_b32"
|
||||
encoding = "SOP2, normal SGPR destination; normal SGPR, inline integer or literal sources with at most one literal; D = ~(S0 ^ S1); SCC = result != 0"
|
||||
@@ -771,6 +855,18 @@ recognized = true
|
||||
decoded = true
|
||||
llvm = "three-way passed"
|
||||
|
||||
[[instruction]]
|
||||
form = "s_xnor_b64"
|
||||
encoding = "SOP2, even SGPR pairs, inline integers or one zero-extended literal, SCC = full result != 0"
|
||||
representation = "4 B, 8 B with literal"
|
||||
lowering = "resolved scalar pairs and SCC"
|
||||
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 = "s_lshl_b32"
|
||||
encoding = "SOP2, normal SGPR destination; normal SGPR, inline integer or literal sources with at most one literal; D = S0 << S1[4:0]; SCC = result != 0"
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
0000: t0 = load.u32 input[index]
|
||||
0034: branch.uniform 0x0040 taken=false
|
||||
009c: t2 = const.u32 0xedcba986
|
||||
00a0: t3 = xor.b32 t0, t2
|
||||
00a4: store.u32 output[index], t3
|
||||
@@ -0,0 +1,11 @@
|
||||
#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 t2 = 0xedcba986u;
|
||||
uint t3 = t0 ^ t2;
|
||||
output[index] = t3;
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,42 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// Fold both SGPR halves of each logical result into a lane-wise XOR key.
|
||||
// The first AND has a zero low dword and nonzero high dword, so SCC is set.
|
||||
.text
|
||||
buffer_load_dword v1, v0, s[0:3], 0 idxen
|
||||
s_waitcnt vmcnt(0)
|
||||
s_mov_b32 s8, 0x55555555
|
||||
s_mov_b32 s9, 0x80000001
|
||||
s_mov_b32 s10, 0xaaaaaaaa
|
||||
s_mov_b32 s11, 0x80000000
|
||||
s_mov_b32 s20, 0
|
||||
s_and_b64 s[12:13], s[8:9], s[10:11]
|
||||
s_cbranch_scc0 .Lskip
|
||||
s_mov_b32 s20, 0x12345678
|
||||
.Lskip:
|
||||
s_xor_b32 s20, s20, s13
|
||||
s_or_b64 s[12:13], s[8:9], 0x80000000
|
||||
s_xor_b32 s20, s20, s12
|
||||
s_xor_b32 s20, s20, s13
|
||||
s_xor_b64 s[12:13], -1, s[10:11]
|
||||
s_xor_b32 s20, s20, s12
|
||||
s_xor_b32 s20, s20, s13
|
||||
s_andn2_b64 s[12:13], s[8:9], s[10:11]
|
||||
s_xor_b32 s20, s20, s12
|
||||
s_xor_b32 s20, s20, s13
|
||||
s_orn2_b64 s[12:13], s[10:11], s[8:9]
|
||||
s_xor_b32 s20, s20, s12
|
||||
s_xor_b32 s20, s20, s13
|
||||
s_nand_b64 s[12:13], s[8:9], s[10:11]
|
||||
s_xor_b32 s20, s20, s12
|
||||
s_xor_b32 s20, s20, s13
|
||||
s_nor_b64 s[12:13], s[8:9], s[10:11]
|
||||
s_xor_b32 s20, s20, s12
|
||||
s_xor_b32 s20, s20, s13
|
||||
s_xnor_b64 s[12:13], s[8:9], s[10:11]
|
||||
s_xor_b32 s20, s20, s12
|
||||
s_xor_b32 s20, s20, s13
|
||||
v_mov_b32_e32 v2, s20
|
||||
v_xor_b32_e32 v2, v1, v2
|
||||
buffer_store_dword v2, v0, s[4:7], 0 idxen
|
||||
s_waitcnt_vscnt null, 0
|
||||
s_endpgm
|
||||
@@ -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-vcc vector-unary vector-compare-64 vector-compare-16; do
|
||||
x9-constant-vs x9-constant-ps x9-varying-vs x9-varying-ps x9-transform-vs scalar-alu vector-compare scalar-logic scalar-logic-b64 scalar-compare scalar-unary scalar-arith scalar-immediate vector-integer vector-compare-ft vector-vcc 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"
|
||||
|
||||
@@ -67,6 +67,7 @@ enum Insn {
|
||||
/// SOP2 opcode 0-10, 14, 16, 18, an even opcode 20-36, 38-40, 44, 46-49,
|
||||
/// 53 or 54.
|
||||
SAlu(u32, u8, Src, Src),
|
||||
SLogic64(u32, u8, (Src, bool), (Src, bool)),
|
||||
/// SOPC opcode 0-11: `s_cmp_{eq,lg,gt,ge,lt,le}_i32` then `_u32`.
|
||||
SCmp(u32, Src, Src),
|
||||
/// SOPK opcode 0 or 2-16 on SGPR `SDST` (s0-s105) with the raw SIMM16.
|
||||
@@ -289,6 +290,9 @@ fn run_wave(program: &[(usize, Insn)], wave: &[u32]) -> Result<Vec<u32>, String>
|
||||
Insn::SImm(opcode, dst, simm16) => {
|
||||
scalar_immediate(&mut sgpr, &mut scc, (opcode, dst, simm16), offset).map(|()| None)
|
||||
}
|
||||
Insn::SLogic64(opcode, dst, a, b) => {
|
||||
scalar_logic64(&mut sgpr, &mut scc, (opcode, dst, a, b), offset).map(|()| None)
|
||||
}
|
||||
Insn::SAlu(opcode, dst, a, b) => {
|
||||
scalar_alu(&mut sgpr, &mut scc, (opcode, dst, a, b), offset).map(|()| None)
|
||||
}
|
||||
@@ -459,6 +463,52 @@ fn scalar_immediate(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Guide 12.1: the eight logical equations apply independently to each bit.
|
||||
fn scalar_logic64(
|
||||
sgpr: &mut [Option<u32>; 128],
|
||||
scc: &mut Option<bool>,
|
||||
(opcode, dst, a, b): (u32, u8, (Src, bool), (Src, bool)),
|
||||
offset: usize,
|
||||
) -> Result<(), String> {
|
||||
if dst < 8 {
|
||||
return Err(format!("{offset:#x}: write to a resource SGPR"));
|
||||
}
|
||||
let read = |(src, negative_inline)| -> Result<u64, String> {
|
||||
match src {
|
||||
Src::Imm(bits) if negative_inline => Ok(bits as i32 as u64),
|
||||
Src::Imm(bits) => Ok(u64::from(bits)),
|
||||
Src::Reg(reg) => {
|
||||
let word = |r: u8| {
|
||||
sgpr[usize::from(r)].ok_or_else(|| format!("{offset:#x}: uninitialized s{r}"))
|
||||
};
|
||||
let (low, high) = (word(reg)?, word(reg + 1)?);
|
||||
Ok(u64::from(high) * (1 << 32) + u64::from(low))
|
||||
}
|
||||
}
|
||||
};
|
||||
let (a, b) = (read(a)?, read(b)?);
|
||||
let value = (0..64).fold(0, |result, bit| {
|
||||
let x = (a >> bit) & 1 == 1;
|
||||
let y = (b >> bit) & 1 == 1;
|
||||
let set = match opcode {
|
||||
15 => x && y,
|
||||
17 => x || y,
|
||||
19 => x != y,
|
||||
21 => x && !y,
|
||||
23 => x || !y,
|
||||
25 => !x || !y,
|
||||
27 => !x && !y,
|
||||
29 => x == y,
|
||||
_ => unreachable!("only SOP2 logical opcodes decode as pairs"),
|
||||
};
|
||||
result | u64::from(set) << bit
|
||||
});
|
||||
sgpr[usize::from(dst)] = Some(value as u32);
|
||||
sgpr[usize::from(dst) + 1] = Some((value >> 32) as u32);
|
||||
*scc = Some(value != 0);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn scalar_alu(
|
||||
sgpr: &mut [Option<u32>; 128],
|
||||
scc: &mut Option<bool>,
|
||||
@@ -1380,15 +1430,7 @@ fn decode_one(code: &[u8], offset: usize) -> Result<(Insn, usize), String> {
|
||||
&& matches!(
|
||||
(first >> 23) & 0x7f,
|
||||
0..=10
|
||||
| 14
|
||||
| 16
|
||||
| 18
|
||||
| 20
|
||||
| 22
|
||||
| 24
|
||||
| 26
|
||||
| 28
|
||||
| 30
|
||||
| 14..=30
|
||||
| 32
|
||||
| 34
|
||||
| 36
|
||||
@@ -1409,7 +1451,23 @@ fn decode_one(code: &[u8], offset: usize) -> Result<(Insn, usize), String> {
|
||||
}
|
||||
let (sa, la) = scalar_source(code, offset, a)?;
|
||||
let (sb, lb) = scalar_source(code, offset, b)?;
|
||||
return Ok((Insn::SAlu((first >> 23) & 0x7f, dst, sa, sb), la.max(lb)));
|
||||
let opcode = (first >> 23) & 0x7f;
|
||||
let instruction = if matches!(opcode, 15 | 17 | 19 | 21 | 23 | 25 | 27 | 29) {
|
||||
// Guide 3.6.3: any 64-bit SGPR operand must start at an even index.
|
||||
let unaligned = |src| matches!(src, Src::Reg(reg) if !reg.is_multiple_of(2));
|
||||
if !dst.is_multiple_of(2) || unaligned(sa) || unaligned(sb) {
|
||||
return Err(fail("unaligned SOP2 register pair"));
|
||||
}
|
||||
Insn::SLogic64(
|
||||
opcode,
|
||||
dst,
|
||||
(sa, (193..=208).contains(&a)),
|
||||
(sb, (193..=208).contains(&b)),
|
||||
)
|
||||
} else {
|
||||
Insn::SAlu(opcode, dst, sa, sb)
|
||||
};
|
||||
return Ok((instruction, la.max(lb)));
|
||||
}
|
||||
// SOPC: ENCODING 0b10_1111110 in bits 23-31, OP in 16-22.
|
||||
if first >> 23 == 0b1_0111_1110 && (first >> 16) & 0x7f <= 11 {
|
||||
|
||||
@@ -989,6 +989,14 @@ mod review {
|
||||
assert!(compiled.disassembly.contains("s_cmp_le_u32 s9, 64"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn scalar_logic_b64_fixture_folds_both_halves() {
|
||||
let input = [0, 1, u32::MAX, 0x1234_5678];
|
||||
let expected = input.map(|word| word ^ 0xedcb_a986);
|
||||
let code = include_bytes!("../../fixtures/rdna2/scalar-logic-b64.bin");
|
||||
verify(code, &input, Some(&expected));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn scalar_immediate_fixture_records_every_registry_sopk_form() {
|
||||
let input = [0, 1, u32::MAX, SCALAR_IMMEDIATE_KEY, 0x1234_5678];
|
||||
|
||||
@@ -548,10 +548,10 @@ fn unsupported_sop2_arith_operands_are_rejected() {
|
||||
#[test]
|
||||
fn other_sop2_opcodes_stay_unsupported() {
|
||||
// Every SOP2 opcode (0-95; 96 and up are other encodings) except the
|
||||
// earlier stages' forms (0-5 and the even opcodes 14-34) and these
|
||||
// earlier stages' forms (0-5, 14-30, 32, 34) and these
|
||||
// sixteen. Sources and destination are aligned pairs, all initialized, so
|
||||
// a 64-bit form would read and write only set registers.
|
||||
let earlier = (0..=5).chain((14..=34).step_by(2));
|
||||
let earlier = (0..=5).chain(14..=30).chain([32, 34]);
|
||||
let supported: Vec<u32> = FORMS
|
||||
.iter()
|
||||
.map(|&(form, _)| form as u32)
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
//! Guide-derived truth tables for SOP2 pair logic (AMD RDNA 2 ISA guide 12.1).
|
||||
//! Encodings use sections 5.2 and 13.1.1. The pinned XML marks literal sources
|
||||
//! U64, so unsigned expansion in section 6.2.1 gives a zero upper dword.
|
||||
|
||||
#[path = "operand_domains/harness.rs"]
|
||||
#[allow(dead_code)]
|
||||
mod harness;
|
||||
#[path = "../independent_ref.rs"]
|
||||
mod independent_ref;
|
||||
|
||||
use harness::{Case, Rejection, words};
|
||||
use xenora_shader::{Architecture, compile};
|
||||
|
||||
// Each mask encodes the answers for input bits (00, 01, 10, 11), low bit first.
|
||||
const FORMS: [(u32, &str, u64); 8] = [
|
||||
(15, "s_and_b64", 0b1000),
|
||||
(17, "s_or_b64", 0b1110),
|
||||
(19, "s_xor_b64", 0b0110),
|
||||
(21, "s_andn2_b64", 0b0100),
|
||||
(23, "s_orn2_b64", 0b1101),
|
||||
(25, "s_nand_b64", 0b0111),
|
||||
(27, "s_nor_b64", 0b0001),
|
||||
(29, "s_xnor_b64", 0b1001),
|
||||
];
|
||||
const VALUES: [u64; 6] = [0, 1, 1 << 32, 1 << 63, 0x1234_5678_a5a5_a5a5, u64::MAX];
|
||||
const PREFIX: [u32; 3] = [0xe030_2000, 0x8000_0100, 0xbf8c_3f70];
|
||||
|
||||
fn sop2(op: u32, dst: u32, left: u32, right: u32) -> u32 {
|
||||
0x8000_0000 | op << 23 | dst << 16 | right << 8 | left
|
||||
}
|
||||
|
||||
fn program(a: u64, b: u64, alu: &[u32], result: u32) -> Vec<u8> {
|
||||
let mut code = PREFIX.to_vec();
|
||||
for (base, value) in [(8u32, a), (104, b)] {
|
||||
code.extend([
|
||||
0xbe80_03ff | base << 16,
|
||||
value as u32,
|
||||
0xbe80_03ff | (base + 1) << 16,
|
||||
(value >> 32) as u32,
|
||||
]);
|
||||
}
|
||||
code.extend(alu);
|
||||
// On input [0, !0], SCC controls whether the second lane is complemented.
|
||||
code.extend([0x7e04_0200 | result, 0xbf84_0001, 0x3a04_0501]);
|
||||
code.extend([0xe070_2000, 0x8001_0200, 0xbbfd_0000, 0xbf81_0000]);
|
||||
words(&code)
|
||||
}
|
||||
|
||||
fn cases() -> Vec<Case> {
|
||||
let mut cases = Vec::new();
|
||||
for (op, form, mask) in FORMS {
|
||||
let mut add = |dst, src0, src1, literal, a, b, x: u64, y: u64| {
|
||||
let value = (0..64).rev().fold(0, |result, i| {
|
||||
let index = ((x >> i) % 2) * 2 + (y >> i) % 2;
|
||||
result * 2 + (mask >> index) % 2
|
||||
});
|
||||
let mut alu = vec![sop2(op, dst, src0, src1)];
|
||||
alu.extend(literal);
|
||||
for half in 0..2 {
|
||||
let word = (value >> (half * 32)) as u32;
|
||||
cases.push(Case {
|
||||
form,
|
||||
family: "SOP2 pair logic",
|
||||
label: format!(
|
||||
"{form} {dst}, {src0}, {src1}, {x:#018x}, {y:#018x}, half {half}"
|
||||
),
|
||||
code: program(a, b, &alu, dst + half),
|
||||
input: vec![0, u32::MAX],
|
||||
expected: vec![word, if value != 0 { !word } else { word }],
|
||||
});
|
||||
}
|
||||
};
|
||||
for a in VALUES {
|
||||
for b in VALUES {
|
||||
for dst in [8, 10, 104] {
|
||||
add(dst, 8, 104, None, a, b, a, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
add(8, 8, 8, None, VALUES[4], 0, VALUES[4], VALUES[4]);
|
||||
for (selector, immediate, literal) in (128..=208)
|
||||
.map(|selector| {
|
||||
let value = if selector <= 192 {
|
||||
selector - 128
|
||||
} else {
|
||||
192 - selector
|
||||
};
|
||||
(selector as u32, value as u64, None)
|
||||
})
|
||||
.chain(
|
||||
[0x8000_0000, 0xffff_ffff, 0x1234_5678]
|
||||
.map(|word| (255, u64::from(word), Some(word))),
|
||||
)
|
||||
{
|
||||
let a = VALUES[4];
|
||||
add(10, selector, 8, literal, a, 0, immediate, a);
|
||||
add(10, 8, selector, literal, a, 0, a, immediate);
|
||||
}
|
||||
}
|
||||
cases
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sop2_b64_oracle_matches_cpu_and_translation() {
|
||||
let cases = cases();
|
||||
assert_eq!(cases.len(), 4432);
|
||||
for case in &cases {
|
||||
let reference = xenora_ref::execute(&case.code, &case.input).unwrap();
|
||||
let independent = independent_ref::execute(&case.code, &case.input).unwrap();
|
||||
assert_eq!(reference, case.expected, "reference: {}", case.label);
|
||||
assert_eq!(
|
||||
independent, case.expected,
|
||||
"second interpreter: {}",
|
||||
case.label
|
||||
);
|
||||
let compiled = compile(Architecture::Gfx1030, &case.code).unwrap();
|
||||
let constant = format!("const.u32 0x{:08x}", case.expected[0]);
|
||||
let branch = format!("taken={}", case.expected[0] == case.expected[1]);
|
||||
assert!(
|
||||
compiled.ir.contains(&constant),
|
||||
"{}: {constant}\n{}",
|
||||
case.label,
|
||||
compiled.ir
|
||||
);
|
||||
assert!(
|
||||
compiled.ir.contains(&branch),
|
||||
"{}: {branch}\n{}",
|
||||
case.label,
|
||||
compiled.ir
|
||||
);
|
||||
}
|
||||
eprintln!(
|
||||
"{} SOP2 pair cases on both interpreters and translated IR",
|
||||
cases.len()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sop2_b64_rejects_operands_outside_the_pair_contract() {
|
||||
let mut rejections = Vec::new();
|
||||
for (op, form, _) in FORMS {
|
||||
let mut reject = |dst, a, b, truncated: bool| {
|
||||
let mut code = PREFIX.to_vec();
|
||||
code.extend([0xbe88_0380, sop2(op, dst, a, b)]);
|
||||
if !truncated {
|
||||
code.extend([0xe070_2000, 0x8001_0100, 0xbbfd_0000, 0xbf81_0000]);
|
||||
}
|
||||
rejections.push(Rejection {
|
||||
family: form,
|
||||
truncated,
|
||||
label: format!("{form} {dst}, {a}, {b}"),
|
||||
code: words(&code),
|
||||
offset: 16,
|
||||
});
|
||||
};
|
||||
for dst in (1..=105).step_by(2).chain(106..=127).chain([0, 2, 4, 6]) {
|
||||
reject(dst, 128, 128, false);
|
||||
}
|
||||
for src in (1..=105).step_by(2).chain(106..=127).chain(209..=254) {
|
||||
reject(10, src, 128, false);
|
||||
reject(10, 128, src, false);
|
||||
}
|
||||
reject(10, 8, 128, false); // s8 initialized, s9 missing.
|
||||
reject(10, 128, 8, false);
|
||||
reject(10, 255, 255, false);
|
||||
reject(10, 255, 128, true);
|
||||
reject(10, 128, 255, true);
|
||||
}
|
||||
assert_eq!(rejections.len(), 2608);
|
||||
harness::check_rejected(&rejections).assert_none("SOP2 pair rejections");
|
||||
for rejection in &rejections {
|
||||
let error = independent_ref::execute(&rejection.code, &[0, 1]).unwrap_err();
|
||||
if rejection.truncated {
|
||||
assert_eq!(error, "0x14: truncated instruction", "{}", rejection.label);
|
||||
} else {
|
||||
assert!(error.starts_with("0x10:"), "{}: {error}", rejection.label);
|
||||
}
|
||||
}
|
||||
eprintln!("{} SOP2 pair rejections", rejections.len());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "requires a native Metal device with API and shader validation"]
|
||||
fn sop2_b64_oracle_matches_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 SOP2 pair oracle");
|
||||
eprintln!(
|
||||
"{} SOP2 pair cases in {programs} native Metal programs",
|
||||
cases.len()
|
||||
);
|
||||
}
|
||||
@@ -294,11 +294,10 @@ fn stage_c_forms_match_the_guide_on_the_independent_interpreter() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn odd_opcodes_beside_the_stage_c_forms_stay_unsupported() {
|
||||
// The 64-bit neighbours (opcodes 21-35 odd) read aligned SGPR pairs
|
||||
// (s[10:11] = s[8:9] op s[12:13], all initialized); neither interpreter
|
||||
// supports them, so each must refuse the SOP2 word.
|
||||
for op in (21..=35).step_by(2) {
|
||||
fn sop2_64_bit_shifts_stay_unsupported() {
|
||||
// Aligned, initialized pairs distinguish rejection of each shift opcode
|
||||
// from rejection of an operand.
|
||||
for op in [31, 33, 35] {
|
||||
let alu = [0x8000_0000 | op << 23 | 10 << 16 | 12 << 8 | 8];
|
||||
let init = [(8, 1), (9, 2), (12, 3), (13, 4)];
|
||||
let code = program(&init, false, &alu, 10);
|
||||
|
||||
Reference in new issue
Block a user