Skip to content

Commit a6d2c91

Browse files
committed
Normalize [us]shll.* ..., #0 aarch64 disassembly to the preferred [us]xtl.* ...
1 parent b9717b9 commit a6d2c91

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

crates/stdarch-test/src/disassembly.rs

+24-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ fn parse(output: &str) -> HashSet<Function> {
125125
cached_header = None;
126126
break;
127127
}
128-
let parts = if cfg!(target_env = "msvc") {
128+
let mut parts = if cfg!(target_env = "msvc") {
129129
// Each line looks like:
130130
//
131131
// > $addr: ab cd ef $instr..
@@ -152,6 +152,29 @@ fn parse(output: &str) -> HashSet<Function> {
152152
.map(std::string::ToString::to_string)
153153
.collect::<Vec<String>>()
154154
};
155+
156+
if cfg!(target_arch = "aarch64") {
157+
// Normalize [us]shll.* ..., #0 instructions to the preferred form: [us]xtl.* ...
158+
// as LLVM objdump does not do that.
159+
// See https://developer.arm.com/documentation/ddi0602/latest/SIMD-FP-Instructions/UXTL--UXTL2--Unsigned-extend-Long--an-alias-of-USHLL--USHLL2-
160+
// and https://developer.arm.com/documentation/ddi0602/latest/SIMD-FP-Instructions/SXTL--SXTL2--Signed-extend-Long--an-alias-of-SSHLL--SSHLL2-
161+
// for details.
162+
match (parts.first(), parts.last()) {
163+
(Some(instr), Some(last_arg))
164+
if (instr.starts_with("ushll.") || instr.starts_with("sshll."))
165+
&& last_arg == "#0" =>
166+
{
167+
assert_eq!(parts.len(), 4);
168+
let mut new_parts = Vec::with_capacity(3);
169+
let new_instr = format!("{}{}{}", &instr[..1], "xtl", &instr[5..]);
170+
new_parts.push(new_instr);
171+
new_parts.push(parts[1].clone());
172+
new_parts.push(parts[2][0..parts[2].len() - 1].to_owned()); // strip trailing comma
173+
parts = new_parts;
174+
}
175+
_ => {}
176+
};
177+
}
155178
instructions.push(parts.join(" "));
156179
}
157180
let function = Function {

0 commit comments

Comments
 (0)