Upstream instruction fixes: 64-bit literals, exact normalized ends, flat offsets, rare forms

Ports of 7d04943 (a signed 64-bit operand sign-extends its literal),
645391b (a normalized buffer format's ends load as exactly 1.0 and -1.0),
40f30be (FLAT offsets ignore bit 11), 3d71ad1, 344704e, 5d6889e, 78c1267,
c3a04e2, e3fe5bf and the tests 259ba31, 8610ffb, 41b2472, 45ed8e3, 8d67fa5.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
localandClaude Opus 5.5 committed 2026-11-24 23:24:50 -06:00
1 parent 25f78a079c
commit a780306f4c
5 files changed
+529 -14

No files matched your search

+79 -1
View File
@@ -137,6 +137,12 @@ fn operands(inst: &Instruction, name: &str, fields: &Fields) -> String {
cache,
} => {
if let Some(data) = data {
let data = match (name, data) {
("s_atc_probe" | "s_atc_probe_buffer", Operand::Literal(imm)) => {
atc_immediate(*imm)
}
_ => data.to_string(),
};
let off = match (soffset, offset) {
(Operand::Scalar { code: NULL, .. }, 0) => soffset.to_string(),
(Operand::Scalar { code: NULL, .. }, _) => {
@@ -335,6 +341,15 @@ fn operands(inst: &Instruction, name: &str, fields: &Fields) -> String {
out
}
/// `s_atc_probe` immediate: 0..=64 in decimal, larger values in hex.
fn atc_immediate(imm: u32) -> String {
if imm <= 64 {
imm.to_string()
} else {
format!("0x{imm:x}")
}
}
/// Cache flags; images write `dlc` first.
fn flags(out: &mut String, cache: &Cache, dlc_first: bool) {
let dlc = (cache.dlc, " dlc");
@@ -660,7 +675,7 @@ fn valu(name: &str, v: &Valu, encoding: Encoding) -> String {
#[cfg(test)]
mod tests {
use crate::gfx10::{Fields, Operand, decode};
use crate::gfx10::{Cache, Fields, Operand, decode};
/// Text of each instruction in `words` (a straight-line program).
fn texts(words: &[u32], wave64: bool) -> Vec<String> {
@@ -700,6 +715,69 @@ mod tests {
);
}
/// `s_atc_probe` / `s_atc_probe_buffer`: SDATA is a 7-bit immediate, the
/// buffer resource is 4 dwords, and GLC/DLC are not operands.
///
/// Words checked with `llvm-mc -arch=amdgcn -mcpu=gfx1030 --disassemble`.
/// The offset keeps this printer's 6-digit hex (`0x000064`, not `0x64`).
#[test]
fn atc_probe_immediate_is_not_a_register() {
let cases = [
(
[0xF498_01C2, 0xFA00_0064],
"s_atc_probe 7, s[4:5], 0x000064",
Operand::Literal(7),
Operand::Scalar { code: 4, dwords: 2 },
),
(
[0xF498_1FF4, 0x0A00_0001],
"s_atc_probe 0x7f, s[104:105], s5 offset:0x000001",
Operand::Literal(0x7f),
Operand::Scalar {
code: 104,
dwords: 2,
},
),
(
[0xF498_0000, 0xFA00_0000],
"s_atc_probe 0, s[0:1], null",
Operand::Literal(0),
Operand::Scalar { code: 0, dwords: 2 },
),
(
[0xF49C_01C4, 0xFA00_0020],
"s_atc_probe_buffer 7, s[8:11], 0x000020",
Operand::Literal(7),
Operand::Scalar { code: 8, dwords: 4 },
),
(
[0xF499_41C2, 0xFA00_0000],
"s_atc_probe 7, s[4:5], null",
Operand::Literal(7),
Operand::Scalar { code: 4, dwords: 2 },
),
];
for (words, text, data, base) in cases {
assert_eq!(one(&words, false), text, "{words:08x?}");
assert_eq!(one(&words, true), text, "{words:08x?}");
let mut code: Vec<u8> = words.iter().flat_map(|w| w.to_le_bytes()).collect();
code.extend(0xBF81_0000u32.to_le_bytes());
let inst = &decode(&code).unwrap()[0];
let Fields::Smem {
data: got,
base: got_base,
cache,
..
} = inst.fields(false)
else {
panic!("not an SMEM instruction");
};
assert_eq!(got, Some(data), "{words:08x?}");
assert_eq!(got_base, base, "{words:08x?}");
assert_eq!(cache, Cache::default(), "{words:08x?}");
}
}
#[test]
fn lane_masks_follow_the_wave_size() {
let cmp = [0x7C08_06F0]; // v_cmp_gt_f32 with 0.5 and v3