Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8fee3f6

Browse files
committedMar 24, 2024
Auto merge of #121940 - veera-sivarajan:bugfix-121593, r=fmease
Mention Register Size in `#[warn(asm_sub_register)]` Fixes #121593 Displays the register size information obtained from `suggest_modifier()` and `default_modifier()`.
2 parents 548e14b + afc99cc commit 8fee3f6

File tree

23 files changed

+132
-124
lines changed

23 files changed

+132
-124
lines changed
 

‎compiler/rustc_hir_analysis/src/check/intrinsicck.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ use rustc_session::lint;
66
use rustc_span::def_id::LocalDefId;
77
use rustc_span::Symbol;
88
use rustc_target::abi::FieldIdx;
9-
use rustc_target::asm::{InlineAsmReg, InlineAsmRegClass, InlineAsmRegOrRegClass, InlineAsmType};
9+
use rustc_target::asm::{
10+
InlineAsmReg, InlineAsmRegClass, InlineAsmRegOrRegClass, InlineAsmType, ModifierInfo,
11+
};
1012

1113
pub struct InlineAsmCtxt<'a, 'tcx> {
1214
tcx: TyCtxt<'tcx>,
@@ -251,8 +253,11 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
251253
}
252254

253255
// Check whether a modifier is suggested for using this type.
254-
if let Some((suggested_modifier, suggested_result)) =
255-
reg_class.suggest_modifier(asm_arch, asm_ty)
256+
if let Some(ModifierInfo {
257+
modifier: suggested_modifier,
258+
result: suggested_result,
259+
size: suggested_size,
260+
}) = reg_class.suggest_modifier(asm_arch, asm_ty)
256261
{
257262
// Search for any use of this operand without a modifier and emit
258263
// the suggestion for them.
@@ -266,8 +271,11 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
266271
}
267272
}
268273
if !spans.is_empty() {
269-
let (default_modifier, default_result) =
270-
reg_class.default_modifier(asm_arch).unwrap();
274+
let ModifierInfo {
275+
modifier: default_modifier,
276+
result: default_result,
277+
size: default_size,
278+
} = reg_class.default_modifier(asm_arch).unwrap();
271279
self.tcx.node_span_lint(
272280
lint::builtin::ASM_SUB_REGISTER,
273281
expr.hir_id,
@@ -276,10 +284,10 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
276284
|lint| {
277285
lint.span_label(expr.span, "for this argument");
278286
lint.help(format!(
279-
"use `{{{idx}:{suggested_modifier}}}` to have the register formatted as `{suggested_result}`",
287+
"use `{{{idx}:{suggested_modifier}}}` to have the register formatted as `{suggested_result}` (for {suggested_size}-bit values)",
280288
));
281289
lint.help(format!(
282-
"or use `{{{idx}:{default_modifier}}}` to keep the default formatting of `{default_result}`",
290+
"or use `{{{idx}:{default_modifier}}}` to keep the default formatting of `{default_result}` (for {default_size}-bit values)",
283291
));
284292
},
285293
);

‎compiler/rustc_target/src/asm/aarch64.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{InlineAsmArch, InlineAsmType};
1+
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
22
use crate::spec::{RelocModel, Target};
33
use rustc_data_structures::fx::FxIndexSet;
44
use rustc_macros::HashStable_Generic;
@@ -27,32 +27,28 @@ impl AArch64InlineAsmRegClass {
2727
None
2828
}
2929

30-
pub fn suggest_modifier(
31-
self,
32-
_arch: InlineAsmArch,
33-
ty: InlineAsmType,
34-
) -> Option<(char, &'static str)> {
30+
pub fn suggest_modifier(self, _arch: InlineAsmArch, ty: InlineAsmType) -> Option<ModifierInfo> {
3531
match self {
3632
Self::reg => match ty.size().bits() {
3733
64 => None,
38-
_ => Some(('w', "w0")),
34+
_ => Some(('w', "w0", 32).into()),
3935
},
4036
Self::vreg | Self::vreg_low16 => match ty.size().bits() {
41-
8 => Some(('b', "b0")),
42-
16 => Some(('h', "h0")),
43-
32 => Some(('s', "s0")),
44-
64 => Some(('d', "d0")),
45-
128 => Some(('q', "q0")),
37+
8 => Some(('b', "b0", 8).into()),
38+
16 => Some(('h', "h0", 16).into()),
39+
32 => Some(('s', "s0", 32).into()),
40+
64 => Some(('d', "d0", 64).into()),
41+
128 => Some(('q', "q0", 128).into()),
4642
_ => None,
4743
},
4844
Self::preg => None,
4945
}
5046
}
5147

52-
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
48+
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
5349
match self {
54-
Self::reg => Some(('x', "x0")),
55-
Self::vreg | Self::vreg_low16 => Some(('v', "v0")),
50+
Self::reg => Some(('x', "x0", 64).into()),
51+
Self::vreg | Self::vreg_low16 => Some(('v', "v0", 128).into()),
5652
Self::preg => None,
5753
}
5854
}

‎compiler/rustc_target/src/asm/arm.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{InlineAsmArch, InlineAsmType};
1+
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
22
use crate::spec::{RelocModel, Target};
33
use rustc_data_structures::fx::FxIndexSet;
44
use rustc_macros::HashStable_Generic;
@@ -35,11 +35,11 @@ impl ArmInlineAsmRegClass {
3535
self,
3636
_arch: InlineAsmArch,
3737
_ty: InlineAsmType,
38-
) -> Option<(char, &'static str)> {
38+
) -> Option<ModifierInfo> {
3939
None
4040
}
4141

42-
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
42+
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
4343
None
4444
}
4545

‎compiler/rustc_target/src/asm/avr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{InlineAsmArch, InlineAsmType};
1+
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
22
use rustc_macros::HashStable_Generic;
33
use rustc_span::Symbol;
44
use std::fmt;
@@ -29,11 +29,11 @@ impl AvrInlineAsmRegClass {
2929
self,
3030
_arch: InlineAsmArch,
3131
_ty: InlineAsmType,
32-
) -> Option<(char, &'static str)> {
32+
) -> Option<ModifierInfo> {
3333
None
3434
}
3535

36-
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
36+
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
3737
None
3838
}
3939

‎compiler/rustc_target/src/asm/bpf.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{InlineAsmArch, InlineAsmType};
1+
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
22
use rustc_macros::HashStable_Generic;
33
use rustc_span::Symbol;
44
use std::fmt;
@@ -23,11 +23,11 @@ impl BpfInlineAsmRegClass {
2323
self,
2424
_arch: InlineAsmArch,
2525
_ty: InlineAsmType,
26-
) -> Option<(char, &'static str)> {
26+
) -> Option<ModifierInfo> {
2727
None
2828
}
2929

30-
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
30+
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
3131
None
3232
}
3333

‎compiler/rustc_target/src/asm/csky.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{InlineAsmArch, InlineAsmType};
1+
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
22
use rustc_macros::HashStable_Generic;
33
use rustc_span::Symbol;
44
use std::fmt;
@@ -23,11 +23,11 @@ impl CSKYInlineAsmRegClass {
2323
self,
2424
_arch: InlineAsmArch,
2525
_ty: InlineAsmType,
26-
) -> Option<(char, &'static str)> {
26+
) -> Option<ModifierInfo> {
2727
None
2828
}
2929

30-
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
30+
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
3131
None
3232
}
3333

‎compiler/rustc_target/src/asm/hexagon.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{InlineAsmArch, InlineAsmType};
1+
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
22
use rustc_macros::HashStable_Generic;
33
use rustc_span::Symbol;
44
use std::fmt;
@@ -22,11 +22,11 @@ impl HexagonInlineAsmRegClass {
2222
self,
2323
_arch: InlineAsmArch,
2424
_ty: InlineAsmType,
25-
) -> Option<(char, &'static str)> {
25+
) -> Option<ModifierInfo> {
2626
None
2727
}
2828

29-
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
29+
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
3030
None
3131
}
3232

‎compiler/rustc_target/src/asm/loongarch.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{InlineAsmArch, InlineAsmType};
1+
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
22
use rustc_macros::HashStable_Generic;
33
use rustc_span::Symbol;
44
use std::fmt;
@@ -23,11 +23,11 @@ impl LoongArchInlineAsmRegClass {
2323
self,
2424
_arch: InlineAsmArch,
2525
_ty: InlineAsmType,
26-
) -> Option<(char, &'static str)> {
26+
) -> Option<ModifierInfo> {
2727
None
2828
}
2929

30-
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
30+
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
3131
None
3232
}
3333

‎compiler/rustc_target/src/asm/m68k.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{InlineAsmArch, InlineAsmType};
1+
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
22
use rustc_macros::HashStable_Generic;
33
use rustc_span::Symbol;
44
use std::fmt;
@@ -24,11 +24,11 @@ impl M68kInlineAsmRegClass {
2424
self,
2525
_arch: InlineAsmArch,
2626
_ty: InlineAsmType,
27-
) -> Option<(char, &'static str)> {
27+
) -> Option<ModifierInfo> {
2828
None
2929
}
3030

31-
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
31+
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
3232
None
3333
}
3434

‎compiler/rustc_target/src/asm/mips.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{InlineAsmArch, InlineAsmType};
1+
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
22
use rustc_macros::HashStable_Generic;
33
use rustc_span::Symbol;
44
use std::fmt;
@@ -23,11 +23,11 @@ impl MipsInlineAsmRegClass {
2323
self,
2424
_arch: InlineAsmArch,
2525
_ty: InlineAsmType,
26-
) -> Option<(char, &'static str)> {
26+
) -> Option<ModifierInfo> {
2727
None
2828
}
2929

30-
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
30+
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
3131
None
3232
}
3333

‎compiler/rustc_target/src/asm/mod.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ use rustc_span::Symbol;
66
use std::fmt;
77
use std::str::FromStr;
88

9+
pub struct ModifierInfo {
10+
pub modifier: char,
11+
pub result: &'static str,
12+
pub size: u64,
13+
}
14+
15+
impl From<(char, &'static str, u64)> for ModifierInfo {
16+
fn from((modifier, result, size): (char, &'static str, u64)) -> Self {
17+
Self { modifier, result, size }
18+
}
19+
}
20+
921
macro_rules! def_reg_class {
1022
($arch:ident $arch_regclass:ident {
1123
$(
@@ -512,11 +524,7 @@ impl InlineAsmRegClass {
512524
/// Such suggestions are useful if a type smaller than the full register
513525
/// size is used and a modifier can be used to point to the subregister of
514526
/// the correct size.
515-
pub fn suggest_modifier(
516-
self,
517-
arch: InlineAsmArch,
518-
ty: InlineAsmType,
519-
) -> Option<(char, &'static str)> {
527+
pub fn suggest_modifier(self, arch: InlineAsmArch, ty: InlineAsmType) -> Option<ModifierInfo> {
520528
match self {
521529
Self::X86(r) => r.suggest_modifier(arch, ty),
522530
Self::Arm(r) => r.suggest_modifier(arch, ty),
@@ -545,7 +553,7 @@ impl InlineAsmRegClass {
545553
/// This is only needed when the register class can suggest a modifier, so
546554
/// that the user can be shown how to get the default behavior without a
547555
/// warning.
548-
pub fn default_modifier(self, arch: InlineAsmArch) -> Option<(char, &'static str)> {
556+
pub fn default_modifier(self, arch: InlineAsmArch) -> Option<ModifierInfo> {
549557
match self {
550558
Self::X86(r) => r.default_modifier(arch),
551559
Self::Arm(r) => r.default_modifier(arch),

‎compiler/rustc_target/src/asm/msp430.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{InlineAsmArch, InlineAsmType};
1+
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
22
use rustc_macros::HashStable_Generic;
33
use rustc_span::Symbol;
44
use std::fmt;
@@ -22,11 +22,11 @@ impl Msp430InlineAsmRegClass {
2222
self,
2323
_arch: InlineAsmArch,
2424
_ty: InlineAsmType,
25-
) -> Option<(char, &'static str)> {
25+
) -> Option<ModifierInfo> {
2626
None
2727
}
2828

29-
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
29+
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
3030
None
3131
}
3232

‎compiler/rustc_target/src/asm/nvptx.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{InlineAsmArch, InlineAsmType};
1+
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
22
use rustc_macros::HashStable_Generic;
33
use rustc_span::Symbol;
44

@@ -23,11 +23,11 @@ impl NvptxInlineAsmRegClass {
2323
self,
2424
_arch: InlineAsmArch,
2525
_ty: InlineAsmType,
26-
) -> Option<(char, &'static str)> {
26+
) -> Option<ModifierInfo> {
2727
None
2828
}
2929

30-
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
30+
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
3131
None
3232
}
3333

‎compiler/rustc_target/src/asm/powerpc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{InlineAsmArch, InlineAsmType};
1+
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
22
use rustc_macros::HashStable_Generic;
33
use rustc_span::Symbol;
44
use std::fmt;
@@ -26,11 +26,11 @@ impl PowerPCInlineAsmRegClass {
2626
self,
2727
_arch: InlineAsmArch,
2828
_ty: InlineAsmType,
29-
) -> Option<(char, &'static str)> {
29+
) -> Option<ModifierInfo> {
3030
None
3131
}
3232

33-
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
33+
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
3434
None
3535
}
3636

‎compiler/rustc_target/src/asm/riscv.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{InlineAsmArch, InlineAsmType};
1+
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
22
use crate::spec::{RelocModel, Target};
33
use rustc_data_structures::fx::FxIndexSet;
44
use rustc_macros::HashStable_Generic;
@@ -26,11 +26,11 @@ impl RiscVInlineAsmRegClass {
2626
self,
2727
_arch: InlineAsmArch,
2828
_ty: InlineAsmType,
29-
) -> Option<(char, &'static str)> {
29+
) -> Option<ModifierInfo> {
3030
None
3131
}
3232

33-
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
33+
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
3434
None
3535
}
3636

‎compiler/rustc_target/src/asm/s390x.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{InlineAsmArch, InlineAsmType};
1+
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
22
use rustc_macros::HashStable_Generic;
33
use rustc_span::Symbol;
44
use std::fmt;
@@ -24,11 +24,11 @@ impl S390xInlineAsmRegClass {
2424
self,
2525
_arch: InlineAsmArch,
2626
_ty: InlineAsmType,
27-
) -> Option<(char, &'static str)> {
27+
) -> Option<ModifierInfo> {
2828
None
2929
}
3030

31-
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
31+
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
3232
None
3333
}
3434

‎compiler/rustc_target/src/asm/spirv.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{InlineAsmArch, InlineAsmType};
1+
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
22
use rustc_macros::HashStable_Generic;
33
use rustc_span::Symbol;
44

@@ -21,11 +21,11 @@ impl SpirVInlineAsmRegClass {
2121
self,
2222
_arch: InlineAsmArch,
2323
_ty: InlineAsmType,
24-
) -> Option<(char, &'static str)> {
24+
) -> Option<ModifierInfo> {
2525
None
2626
}
2727

28-
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
28+
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
2929
None
3030
}
3131

‎compiler/rustc_target/src/asm/wasm.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{InlineAsmArch, InlineAsmType};
1+
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
22
use rustc_macros::HashStable_Generic;
33
use rustc_span::Symbol;
44

@@ -21,11 +21,11 @@ impl WasmInlineAsmRegClass {
2121
self,
2222
_arch: InlineAsmArch,
2323
_ty: InlineAsmType,
24-
) -> Option<(char, &'static str)> {
24+
) -> Option<ModifierInfo> {
2525
None
2626
}
2727

28-
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
28+
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
2929
None
3030
}
3131

‎compiler/rustc_target/src/asm/x86.rs

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{InlineAsmArch, InlineAsmType};
1+
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
22
use crate::spec::{RelocModel, Target};
33
use rustc_data_structures::fx::FxIndexSet;
44
use rustc_macros::HashStable_Generic;
@@ -53,52 +53,48 @@ impl X86InlineAsmRegClass {
5353
}
5454
}
5555

56-
pub fn suggest_modifier(
57-
self,
58-
arch: InlineAsmArch,
59-
ty: InlineAsmType,
60-
) -> Option<(char, &'static str)> {
56+
pub fn suggest_modifier(self, arch: InlineAsmArch, ty: InlineAsmType) -> Option<ModifierInfo> {
6157
match self {
6258
Self::reg => match ty.size().bits() {
63-
16 => Some(('x', "ax")),
64-
32 if arch == InlineAsmArch::X86_64 => Some(('e', "eax")),
59+
16 => Some(('x', "ax", 16).into()),
60+
32 if arch == InlineAsmArch::X86_64 => Some(('e', "eax", 32).into()),
6561
_ => None,
6662
},
6763
Self::reg_abcd => match ty.size().bits() {
68-
16 => Some(('x', "ax")),
69-
32 if arch == InlineAsmArch::X86_64 => Some(('e', "eax")),
64+
16 => Some(('x', "ax", 16).into()),
65+
32 if arch == InlineAsmArch::X86_64 => Some(('e', "eax", 32).into()),
7066
_ => None,
7167
},
7268
Self::reg_byte => None,
7369
Self::xmm_reg => None,
7470
Self::ymm_reg => match ty.size().bits() {
7571
256 => None,
76-
_ => Some(('x', "xmm0")),
72+
_ => Some(('x', "xmm0", 128).into()),
7773
},
7874
Self::zmm_reg => match ty.size().bits() {
7975
512 => None,
80-
256 => Some(('y', "ymm0")),
81-
_ => Some(('x', "xmm0")),
76+
256 => Some(('y', "ymm0", 256).into()),
77+
_ => Some(('x', "xmm0", 128).into()),
8278
},
8379
Self::kreg | Self::kreg0 => None,
8480
Self::mmx_reg | Self::x87_reg => None,
8581
Self::tmm_reg => None,
8682
}
8783
}
8884

89-
pub fn default_modifier(self, arch: InlineAsmArch) -> Option<(char, &'static str)> {
85+
pub fn default_modifier(self, arch: InlineAsmArch) -> Option<ModifierInfo> {
9086
match self {
9187
Self::reg | Self::reg_abcd => {
9288
if arch == InlineAsmArch::X86_64 {
93-
Some(('r', "rax"))
89+
Some(('r', "rax", 64).into())
9490
} else {
95-
Some(('e', "eax"))
91+
Some(('e', "eax", 32).into())
9692
}
9793
}
9894
Self::reg_byte => None,
99-
Self::xmm_reg => Some(('x', "xmm0")),
100-
Self::ymm_reg => Some(('y', "ymm0")),
101-
Self::zmm_reg => Some(('z', "zmm0")),
95+
Self::xmm_reg => Some(('x', "xmm0", 128).into()),
96+
Self::ymm_reg => Some(('y', "ymm0", 256).into()),
97+
Self::zmm_reg => Some(('z', "zmm0", 512).into()),
10298
Self::kreg | Self::kreg0 => None,
10399
Self::mmx_reg | Self::x87_reg => None,
104100
Self::tmm_reg => None,

‎tests/ui/asm/aarch64/type-check-3.stderr

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ warning: formatting may not be suitable for sub-register argument
44
LL | asm!("{}", in(reg) 0u8);
55
| ^^ --- for this argument
66
|
7-
= help: use `{0:w}` to have the register formatted as `w0`
8-
= help: or use `{0:x}` to keep the default formatting of `x0`
7+
= help: use `{0:w}` to have the register formatted as `w0` (for 32-bit values)
8+
= help: or use `{0:x}` to keep the default formatting of `x0` (for 64-bit values)
99
= note: `#[warn(asm_sub_register)]` on by default
1010

1111
warning: formatting may not be suitable for sub-register argument
@@ -14,80 +14,80 @@ warning: formatting may not be suitable for sub-register argument
1414
LL | asm!("{}", in(reg) 0u16);
1515
| ^^ ---- for this argument
1616
|
17-
= help: use `{0:w}` to have the register formatted as `w0`
18-
= help: or use `{0:x}` to keep the default formatting of `x0`
17+
= help: use `{0:w}` to have the register formatted as `w0` (for 32-bit values)
18+
= help: or use `{0:x}` to keep the default formatting of `x0` (for 64-bit values)
1919

2020
warning: formatting may not be suitable for sub-register argument
2121
--> $DIR/type-check-3.rs:52:15
2222
|
2323
LL | asm!("{}", in(reg) 0i32);
2424
| ^^ ---- for this argument
2525
|
26-
= help: use `{0:w}` to have the register formatted as `w0`
27-
= help: or use `{0:x}` to keep the default formatting of `x0`
26+
= help: use `{0:w}` to have the register formatted as `w0` (for 32-bit values)
27+
= help: or use `{0:x}` to keep the default formatting of `x0` (for 64-bit values)
2828

2929
warning: formatting may not be suitable for sub-register argument
3030
--> $DIR/type-check-3.rs:54:15
3131
|
3232
LL | asm!("{}", in(reg) 0f32);
3333
| ^^ ---- for this argument
3434
|
35-
= help: use `{0:w}` to have the register formatted as `w0`
36-
= help: or use `{0:x}` to keep the default formatting of `x0`
35+
= help: use `{0:w}` to have the register formatted as `w0` (for 32-bit values)
36+
= help: or use `{0:x}` to keep the default formatting of `x0` (for 64-bit values)
3737

3838
warning: formatting may not be suitable for sub-register argument
3939
--> $DIR/type-check-3.rs:57:15
4040
|
4141
LL | asm!("{}", in(vreg) 0i16);
4242
| ^^ ---- for this argument
4343
|
44-
= help: use `{0:h}` to have the register formatted as `h0`
45-
= help: or use `{0:v}` to keep the default formatting of `v0`
44+
= help: use `{0:h}` to have the register formatted as `h0` (for 16-bit values)
45+
= help: or use `{0:v}` to keep the default formatting of `v0` (for 128-bit values)
4646

4747
warning: formatting may not be suitable for sub-register argument
4848
--> $DIR/type-check-3.rs:59:15
4949
|
5050
LL | asm!("{}", in(vreg) 0f32);
5151
| ^^ ---- for this argument
5252
|
53-
= help: use `{0:s}` to have the register formatted as `s0`
54-
= help: or use `{0:v}` to keep the default formatting of `v0`
53+
= help: use `{0:s}` to have the register formatted as `s0` (for 32-bit values)
54+
= help: or use `{0:v}` to keep the default formatting of `v0` (for 128-bit values)
5555

5656
warning: formatting may not be suitable for sub-register argument
5757
--> $DIR/type-check-3.rs:61:15
5858
|
5959
LL | asm!("{}", in(vreg) 0f64);
6060
| ^^ ---- for this argument
6161
|
62-
= help: use `{0:d}` to have the register formatted as `d0`
63-
= help: or use `{0:v}` to keep the default formatting of `v0`
62+
= help: use `{0:d}` to have the register formatted as `d0` (for 64-bit values)
63+
= help: or use `{0:v}` to keep the default formatting of `v0` (for 128-bit values)
6464

6565
warning: formatting may not be suitable for sub-register argument
6666
--> $DIR/type-check-3.rs:63:15
6767
|
6868
LL | asm!("{}", in(vreg_low16) 0f64);
6969
| ^^ ---- for this argument
7070
|
71-
= help: use `{0:d}` to have the register formatted as `d0`
72-
= help: or use `{0:v}` to keep the default formatting of `v0`
71+
= help: use `{0:d}` to have the register formatted as `d0` (for 64-bit values)
72+
= help: or use `{0:v}` to keep the default formatting of `v0` (for 128-bit values)
7373

7474
warning: formatting may not be suitable for sub-register argument
7575
--> $DIR/type-check-3.rs:66:15
7676
|
7777
LL | asm!("{0} {0}", in(reg) 0i16);
7878
| ^^^ ^^^ ---- for this argument
7979
|
80-
= help: use `{0:w}` to have the register formatted as `w0`
81-
= help: or use `{0:x}` to keep the default formatting of `x0`
80+
= help: use `{0:w}` to have the register formatted as `w0` (for 32-bit values)
81+
= help: or use `{0:x}` to keep the default formatting of `x0` (for 64-bit values)
8282

8383
warning: formatting may not be suitable for sub-register argument
8484
--> $DIR/type-check-3.rs:68:15
8585
|
8686
LL | asm!("{0} {0:x}", in(reg) 0i16);
8787
| ^^^ ---- for this argument
8888
|
89-
= help: use `{0:w}` to have the register formatted as `w0`
90-
= help: or use `{0:x}` to keep the default formatting of `x0`
89+
= help: use `{0:w}` to have the register formatted as `w0` (for 32-bit values)
90+
= help: or use `{0:x}` to keep the default formatting of `x0` (for 64-bit values)
9191

9292
error: type `i128` cannot be used with this register class
9393
--> $DIR/type-check-3.rs:73:28

‎tests/ui/asm/bad-template.aarch64.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ warning: formatting may not be suitable for sub-register argument
194194
LL | asm!("{:foo}", in(reg) foo);
195195
| ^^^^^^ --- for this argument
196196
|
197-
= help: use `{0:w}` to have the register formatted as `w0`
198-
= help: or use `{0:x}` to keep the default formatting of `x0`
197+
= help: use `{0:w}` to have the register formatted as `w0` (for 32-bit values)
198+
= help: or use `{0:x}` to keep the default formatting of `x0` (for 64-bit values)
199199
= note: `#[warn(asm_sub_register)]` on by default
200200

201201
error: aborting due to 21 previous errors; 1 warning emitted

‎tests/ui/asm/bad-template.x86_64.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ warning: formatting may not be suitable for sub-register argument
194194
LL | asm!("{:foo}", in(reg) foo);
195195
| ^^^^^^ --- for this argument
196196
|
197-
= help: use `{0:e}` to have the register formatted as `eax`
198-
= help: or use `{0:r}` to keep the default formatting of `rax`
197+
= help: use `{0:e}` to have the register formatted as `eax` (for 32-bit values)
198+
= help: or use `{0:r}` to keep the default formatting of `rax` (for 64-bit values)
199199
= note: `#[warn(asm_sub_register)]` on by default
200200

201201
error: aborting due to 21 previous errors; 1 warning emitted

‎tests/ui/asm/x86_64/type-check-3.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ warning: formatting may not be suitable for sub-register argument
4444
LL | asm!("{0} {0}", in(reg) 0i16);
4545
| ^^^ ^^^ ---- for this argument
4646
|
47-
= help: use `{0:x}` to have the register formatted as `ax`
48-
= help: or use `{0:r}` to keep the default formatting of `rax`
47+
= help: use `{0:x}` to have the register formatted as `ax` (for 16-bit values)
48+
= help: or use `{0:r}` to keep the default formatting of `rax` (for 64-bit values)
4949
= note: `#[warn(asm_sub_register)]` on by default
5050

5151
warning: formatting may not be suitable for sub-register argument
@@ -54,26 +54,26 @@ warning: formatting may not be suitable for sub-register argument
5454
LL | asm!("{0} {0:x}", in(reg) 0i16);
5555
| ^^^ ---- for this argument
5656
|
57-
= help: use `{0:x}` to have the register formatted as `ax`
58-
= help: or use `{0:r}` to keep the default formatting of `rax`
57+
= help: use `{0:x}` to have the register formatted as `ax` (for 16-bit values)
58+
= help: or use `{0:r}` to keep the default formatting of `rax` (for 64-bit values)
5959

6060
warning: formatting may not be suitable for sub-register argument
6161
--> $DIR/type-check-3.rs:38:15
6262
|
6363
LL | asm!("{}", in(reg) 0i32);
6464
| ^^ ---- for this argument
6565
|
66-
= help: use `{0:e}` to have the register formatted as `eax`
67-
= help: or use `{0:r}` to keep the default formatting of `rax`
66+
= help: use `{0:e}` to have the register formatted as `eax` (for 32-bit values)
67+
= help: or use `{0:r}` to keep the default formatting of `rax` (for 64-bit values)
6868

6969
warning: formatting may not be suitable for sub-register argument
7070
--> $DIR/type-check-3.rs:41:15
7171
|
7272
LL | asm!("{}", in(ymm_reg) 0i64);
7373
| ^^ ---- for this argument
7474
|
75-
= help: use `{0:x}` to have the register formatted as `xmm0`
76-
= help: or use `{0:y}` to keep the default formatting of `ymm0`
75+
= help: use `{0:x}` to have the register formatted as `xmm0` (for 128-bit values)
76+
= help: or use `{0:y}` to keep the default formatting of `ymm0` (for 256-bit values)
7777

7878
error: type `i8` cannot be used with this register class
7979
--> $DIR/type-check-3.rs:52:28

0 commit comments

Comments
 (0)
Please sign in to comment.