Skip to content

Commit f820168

Browse files
committed
Fix cpuid replacement shim
1 parent 241eae7 commit f820168

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/inline_asm.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub(crate) fn codegen_inline_asm<'tcx>(
2727
}
2828

2929
// Used by stdarch
30-
if template[0] == InlineAsmTemplatePiece::String("movq %rbx, ".to_string())
30+
if template[0] == InlineAsmTemplatePiece::String("mov ".to_string())
3131
&& matches!(
3232
template[1],
3333
InlineAsmTemplatePiece::Placeholder {
@@ -36,24 +36,26 @@ pub(crate) fn codegen_inline_asm<'tcx>(
3636
span: _
3737
}
3838
)
39-
&& template[2] == InlineAsmTemplatePiece::String("\n".to_string())
40-
&& template[3] == InlineAsmTemplatePiece::String("cpuid".to_string())
41-
&& template[4] == InlineAsmTemplatePiece::String("\n".to_string())
42-
&& template[5] == InlineAsmTemplatePiece::String("xchgq %rbx, ".to_string())
39+
&& template[2] == InlineAsmTemplatePiece::String(", rbx".to_string())
40+
&& template[3] == InlineAsmTemplatePiece::String("\n".to_string())
41+
&& template[4] == InlineAsmTemplatePiece::String("cpuid".to_string())
42+
&& template[5] == InlineAsmTemplatePiece::String("\n".to_string())
43+
&& template[6] == InlineAsmTemplatePiece::String("xchg ".to_string())
4344
&& matches!(
44-
template[6],
45+
template[7],
4546
InlineAsmTemplatePiece::Placeholder {
4647
operand_idx: 0,
4748
modifier: Some('r'),
4849
span: _
4950
}
5051
)
52+
&& template[8] == InlineAsmTemplatePiece::String(", rbx".to_string())
5153
{
5254
assert_eq!(operands.len(), 4);
5355
let (leaf, eax_place) = match operands[1] {
5456
InlineAsmOperand::InOut {
5557
reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::X86(X86InlineAsmReg::ax)),
56-
late: true,
58+
late: _,
5759
ref in_value,
5860
out_place: Some(out_place),
5961
} => (
@@ -68,15 +70,15 @@ pub(crate) fn codegen_inline_asm<'tcx>(
6870
InlineAsmRegOrRegClass::RegClass(InlineAsmRegClass::X86(
6971
X86InlineAsmRegClass::reg,
7072
)),
71-
late: true,
73+
late: _,
7274
place: Some(place),
7375
} => crate::base::codegen_place(fx, place),
7476
_ => unreachable!(),
7577
};
7678
let (sub_leaf, ecx_place) = match operands[2] {
7779
InlineAsmOperand::InOut {
7880
reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::X86(X86InlineAsmReg::cx)),
79-
late: true,
81+
late: _,
8082
ref in_value,
8183
out_place: Some(out_place),
8284
} => (
@@ -88,7 +90,7 @@ pub(crate) fn codegen_inline_asm<'tcx>(
8890
let edx_place = match operands[3] {
8991
InlineAsmOperand::Out {
9092
reg: InlineAsmRegOrRegClass::Reg(InlineAsmReg::X86(X86InlineAsmReg::dx)),
91-
late: true,
93+
late: _,
9294
place: Some(place),
9395
} => crate::base::codegen_place(fx, place),
9496
_ => unreachable!(),

0 commit comments

Comments
 (0)