Skip to content

Commit

Permalink
Simplify register name output for x86
Browse files Browse the repository at this point in the history
  • Loading branch information
Amanieu committed May 18, 2020
1 parent 5a20f39 commit 62ff543
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/librustc_target/asm/x86.rs
Expand Up @@ -297,7 +297,7 @@ impl X86InlineAsmReg {
_ => unreachable!(),
}
} else if self as u32 <= Self::di as u32 {
let root = ["si", "di"][self as usize - Self::si as usize];
let root = self.name();
match modifier.unwrap_or(reg_default_modifier) {
'l' => write!(out, "{}l", root),
'x' => write!(out, "{}", root),
Expand All @@ -306,12 +306,12 @@ impl X86InlineAsmReg {
_ => unreachable!(),
}
} else if self as u32 <= Self::r15 as u32 {
let index = self as u32 - Self::r8 as u32 + 8;
let root = self.name();
match modifier.unwrap_or(reg_default_modifier) {
'l' => write!(out, "r{}b", index),
'x' => write!(out, "r{}w", index),
'e' => write!(out, "r{}d", index),
'r' => write!(out, "r{}", index),
'l' => write!(out, "{}b", root),
'x' => write!(out, "{}w", root),
'e' => write!(out, "{}d", root),
'r' => out.write_str(root),
_ => unreachable!(),
}
} else if self as u32 <= Self::r15b as u32 {
Expand All @@ -329,8 +329,7 @@ impl X86InlineAsmReg {
let index = self as u32 - Self::zmm0 as u32;
write!(out, "{}{}", prefix, index)
} else {
let index = self as u32 - Self::k1 as u32 + 1;
write!(out, "k{}", index)
out.write_str(self.name())
}
}

Expand Down

0 comments on commit 62ff543

Please sign in to comment.