Merge remote-tracking branch 'origin/main' into task/215-vop1-xlate

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>

# Conflicts:
#	crates/isa/generate_semantics.py
#	crates/isa/src/semantics_gen.rs
#	crates/shader/src/lib.rs
#	docs/shaders/semantic-coverage.md
#	docs/shaders/semantic-registry.md
This commit is contained in:
elforeign committed 2026-11-24 09:45:44 -06:00
commit 989bb79d6c
14 files changed
+196 -101

No files matched your search

+13 -16
View File
@@ -9,7 +9,7 @@ pub use xenora_isa::{
};
use xenora_isa::{
BUFFER_LOAD_DWORD, BUFFER_STORE_DWORD, EXP, IMAGE_SAMPLE_LZ, S_BRANCH, S_CBRANCH_EXECZ,
S_CBRANCH_SCC0, S_CBRANCH_VCCZ, S_ENDPGM, S_MOV_B32, S_WAITCNT, S_WAITCNT_VSCNT, V_ADD_F32,
S_CBRANCH_SCC0, S_CBRANCH_VCCZ, S_ENDPGM, S_WAITCNT, S_WAITCNT_VSCNT, V_ADD_F32,
V_INTERP_P1_F32, V_INTERP_P2_F32, V_MOV_B32, V_MUL_F32, VCC_LO,
};
@@ -40,7 +40,7 @@ const fn concat_forms<const N: usize>() -> [(&'static str, EncodingFamily); N] {
}
/// Decoded forms not yet described by the semantic registry.
const HANDWRITTEN_FORMS: [(&str, EncodingFamily); 17] = [
const HANDWRITTEN_FORMS: [(&str, EncodingFamily); 16] = [
("BUFFER_LOAD_DWORD", EncodingFamily::Mubuf),
("BUFFER_STORE_DWORD", EncodingFamily::Mubuf),
("EXP", EncodingFamily::Exp),
@@ -50,7 +50,6 @@ const HANDWRITTEN_FORMS: [(&str, EncodingFamily); 17] = [
("S_CBRANCH_SCC0", EncodingFamily::Sopp),
("S_CBRANCH_VCCZ", EncodingFamily::Sopp),
("S_ENDPGM", EncodingFamily::Sopp),
("S_MOV_B32", EncodingFamily::Sop1),
("S_WAITCNT", EncodingFamily::Sopp),
("S_WAITCNT_VSCNT", EncodingFamily::Sopk),
("V_ADD_F32", EncodingFamily::Vop2),
@@ -341,23 +340,21 @@ fn decode_gfx1030(bytes: &[u8], offset: usize) -> Result<(Instruction, u8), Deco
let second = word(bytes, 8)?;
return Ok((vop3_vgpr2(op, first, second)?, 8));
}
if S_MOV_B32.matches(first) {
let dst = ((first >> 16) & 0x7f) as u8;
if !matches!(dst, 0..=107 | 126..=127) {
return Err(unsupported(
"s_mov_b32",
"expected a normal SGPR or EXEC/VCC destination",
));
}
let (src, len) = scalar_source(first as u8, bytes, "s_mov_b32")?;
return Ok((Instruction::ScalarMoveB32 { dst, src }, len));
}
if let Some(op) = ScalarUnaryOp::from_word(first) {
// SOP1: SSRC0 in bits 0-7, SDST in bits 16-22.
let mnemonic = op.mnemonic();
let dst = ((first >> 16) & 0x7f) as u8;
if dst > 105 {
return Err(unsupported(mnemonic, "expected a normal SGPR destination"));
match op.semantics().operands {
OperandRule::Sop1Move if !matches!(dst, 0..=107 | 126..=127) => {
return Err(unsupported(
mnemonic,
"expected a normal SGPR or EXEC/VCC destination",
));
}
OperandRule::Sop1Sgpr if dst > 105 => {
return Err(unsupported(mnemonic, "expected a normal SGPR destination"));
}
_ => {}
}
let (src, len) = scalar_source(first as u8, bytes, mnemonic)?;
return Ok((Instruction::ScalarUnary { op, dst, src }, len));
+13 -10
View File
@@ -398,9 +398,10 @@ fn reference_op(instruction: Instruction) -> Op {
src0,
src1,
} => Op::Add(dst, src0, src1),
Instruction::ScalarMoveB32 { dst, src } => Op::ScalarMove(dst, reference_scalar(src)),
Instruction::ScalarUnary { op, dst, src } => Op::ScalarUnary(
match op {
Instruction::ScalarUnary { op, dst, src } => {
let src = reference_scalar(src);
let unary = match op {
ScalarUnaryOp::MovB32 => return Op::ScalarMove(dst, src),
ScalarUnaryOp::NotB32 => ScalarUnary::Not,
ScalarUnaryOp::BrevB32 => ScalarUnary::ReverseBits,
ScalarUnaryOp::Bcnt0I32B32 => ScalarUnary::CountZeros,
@@ -412,10 +413,9 @@ fn reference_op(instruction: Instruction) -> Op {
ScalarUnaryOp::SextI32I8 => ScalarUnary::SignExtendByte,
ScalarUnaryOp::SextI32I16 => ScalarUnary::SignExtendShort,
ScalarUnaryOp::AbsI32 => ScalarUnary::Absolute,
},
dst,
reference_scalar(src),
),
};
Op::ScalarUnary(unary, dst, src)
}
Instruction::ScalarCompare { op, src0, src1 } => {
let (src0, src1) = (reference_scalar(src0), reference_scalar(src1));
// The reference keeps CompareEqual for EQ and uses its VOPC relation
@@ -1008,14 +1008,16 @@ fn decodes_inline_negative_and_register_sources() {
let decoded = decode(Architecture::Gfx1030, &bytes).unwrap();
assert_eq!(
decoded[0].instruction,
Instruction::ScalarMoveB32 {
Instruction::ScalarUnary {
op: ScalarUnaryOp::MovB32,
dst: 10,
src: ScalarSource::Immediate(5)
}
);
assert_eq!(
decoded[1].instruction,
Instruction::ScalarMoveB32 {
Instruction::ScalarUnary {
op: ScalarUnaryOp::MovB32,
dst: 11,
src: ScalarSource::Immediate(0xffff_fffd)
}
@@ -1049,7 +1051,8 @@ fn accepts_scalar_destination_105_and_vgpr_zero_add_sources() {
let valid = 0xbee9_0380u32.to_le_bytes();
assert_eq!(
decode(Architecture::Gfx1030, &valid).unwrap()[0].instruction,
Instruction::ScalarMoveB32 {
Instruction::ScalarUnary {
op: ScalarUnaryOp::MovB32,
dst: 105,
src: ScalarSource::Immediate(0)
}