diff options
| author | Veera <sveera.2001@gmail.com> | 2024-03-03 09:34:26 -0500 |
|---|---|---|
| committer | Veera <sveera.2001@gmail.com> | 2024-03-03 09:34:26 -0500 |
| commit | 9aac0c9ae39de7046af35788d19e5f9310e4cbb7 (patch) | |
| tree | 16d2ec7e507f479bb593151d8c9360f38d302831 /compiler/rustc_target/src/asm/mod.rs | |
| parent | d561a84d48b64dc0f23e0f0a152b72e5a8f62161 (diff) | |
| download | rust-9aac0c9ae39de7046af35788d19e5f9310e4cbb7.tar.gz rust-9aac0c9ae39de7046af35788d19e5f9310e4cbb7.zip | |
Mention Register Size in `#[warn(asm_sub_register)]`
Fixes #121593
Diffstat (limited to 'compiler/rustc_target/src/asm/mod.rs')
| -rw-r--r-- | compiler/rustc_target/src/asm/mod.rs | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/compiler/rustc_target/src/asm/mod.rs b/compiler/rustc_target/src/asm/mod.rs index a11884bea26..bfb6ae0b2d9 100644 --- a/compiler/rustc_target/src/asm/mod.rs +++ b/compiler/rustc_target/src/asm/mod.rs @@ -6,6 +6,18 @@ use rustc_span::Symbol; use std::fmt; use std::str::FromStr; +pub struct ModifierInfo { + pub modifier: char, + pub result: &'static str, + pub size: u64, +} + +impl From<(char, &'static str, u64)> for ModifierInfo { + fn from(value: (char, &'static str, u64)) -> Self { + Self { modifier: value.0, result: value.1, size: value.2 } + } +} + macro_rules! def_reg_class { ($arch:ident $arch_regclass:ident { $( @@ -512,11 +524,7 @@ impl InlineAsmRegClass { /// Such suggestions are useful if a type smaller than the full register /// size is used and a modifier can be used to point to the subregister of /// the correct size. - pub fn suggest_modifier( - self, - arch: InlineAsmArch, - ty: InlineAsmType, - ) -> Option<(char, &'static str)> { + pub fn suggest_modifier(self, arch: InlineAsmArch, ty: InlineAsmType) -> Option<ModifierInfo> { match self { Self::X86(r) => r.suggest_modifier(arch, ty), Self::Arm(r) => r.suggest_modifier(arch, ty), @@ -545,7 +553,7 @@ impl InlineAsmRegClass { /// This is only needed when the register class can suggest a modifier, so /// that the user can be shown how to get the default behavior without a /// warning. - pub fn default_modifier(self, arch: InlineAsmArch) -> Option<(char, &'static str)> { + pub fn default_modifier(self, arch: InlineAsmArch) -> Option<ModifierInfo> { match self { Self::X86(r) => r.default_modifier(arch), Self::Arm(r) => r.default_modifier(arch), |
