Rollup 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()`.
This commit is contained in:
commit
97fcfaa103
23 changed files with 132 additions and 124 deletions
|
@ -6,7 +6,9 @@ use rustc_session::lint;
|
||||||
use rustc_span::def_id::LocalDefId;
|
use rustc_span::def_id::LocalDefId;
|
||||||
use rustc_span::Symbol;
|
use rustc_span::Symbol;
|
||||||
use rustc_target::abi::FieldIdx;
|
use rustc_target::abi::FieldIdx;
|
||||||
use rustc_target::asm::{InlineAsmReg, InlineAsmRegClass, InlineAsmRegOrRegClass, InlineAsmType};
|
use rustc_target::asm::{
|
||||||
|
InlineAsmReg, InlineAsmRegClass, InlineAsmRegOrRegClass, InlineAsmType, ModifierInfo,
|
||||||
|
};
|
||||||
|
|
||||||
pub struct InlineAsmCtxt<'a, 'tcx> {
|
pub struct InlineAsmCtxt<'a, 'tcx> {
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
|
@ -251,8 +253,11 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check whether a modifier is suggested for using this type.
|
// Check whether a modifier is suggested for using this type.
|
||||||
if let Some((suggested_modifier, suggested_result)) =
|
if let Some(ModifierInfo {
|
||||||
reg_class.suggest_modifier(asm_arch, asm_ty)
|
modifier: suggested_modifier,
|
||||||
|
result: suggested_result,
|
||||||
|
size: suggested_size,
|
||||||
|
}) = reg_class.suggest_modifier(asm_arch, asm_ty)
|
||||||
{
|
{
|
||||||
// Search for any use of this operand without a modifier and emit
|
// Search for any use of this operand without a modifier and emit
|
||||||
// the suggestion for them.
|
// the suggestion for them.
|
||||||
|
@ -266,8 +271,11 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !spans.is_empty() {
|
if !spans.is_empty() {
|
||||||
let (default_modifier, default_result) =
|
let ModifierInfo {
|
||||||
reg_class.default_modifier(asm_arch).unwrap();
|
modifier: default_modifier,
|
||||||
|
result: default_result,
|
||||||
|
size: default_size,
|
||||||
|
} = reg_class.default_modifier(asm_arch).unwrap();
|
||||||
self.tcx.node_span_lint(
|
self.tcx.node_span_lint(
|
||||||
lint::builtin::ASM_SUB_REGISTER,
|
lint::builtin::ASM_SUB_REGISTER,
|
||||||
expr.hir_id,
|
expr.hir_id,
|
||||||
|
@ -276,10 +284,10 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
||||||
|lint| {
|
|lint| {
|
||||||
lint.span_label(expr.span, "for this argument");
|
lint.span_label(expr.span, "for this argument");
|
||||||
lint.help(format!(
|
lint.help(format!(
|
||||||
"use `{{{idx}:{suggested_modifier}}}` to have the register formatted as `{suggested_result}`",
|
"use `{{{idx}:{suggested_modifier}}}` to have the register formatted as `{suggested_result}` (for {suggested_size}-bit values)",
|
||||||
));
|
));
|
||||||
lint.help(format!(
|
lint.help(format!(
|
||||||
"or use `{{{idx}:{default_modifier}}}` to keep the default formatting of `{default_result}`",
|
"or use `{{{idx}:{default_modifier}}}` to keep the default formatting of `{default_result}` (for {default_size}-bit values)",
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use super::{InlineAsmArch, InlineAsmType};
|
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||||
use crate::spec::{RelocModel, Target};
|
use crate::spec::{RelocModel, Target};
|
||||||
use rustc_data_structures::fx::FxIndexSet;
|
use rustc_data_structures::fx::FxIndexSet;
|
||||||
use rustc_macros::HashStable_Generic;
|
use rustc_macros::HashStable_Generic;
|
||||||
|
@ -27,32 +27,28 @@ impl AArch64InlineAsmRegClass {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn suggest_modifier(
|
pub fn suggest_modifier(self, _arch: InlineAsmArch, ty: InlineAsmType) -> Option<ModifierInfo> {
|
||||||
self,
|
|
||||||
_arch: InlineAsmArch,
|
|
||||||
ty: InlineAsmType,
|
|
||||||
) -> Option<(char, &'static str)> {
|
|
||||||
match self {
|
match self {
|
||||||
Self::reg => match ty.size().bits() {
|
Self::reg => match ty.size().bits() {
|
||||||
64 => None,
|
64 => None,
|
||||||
_ => Some(('w', "w0")),
|
_ => Some(('w', "w0", 32).into()),
|
||||||
},
|
},
|
||||||
Self::vreg | Self::vreg_low16 => match ty.size().bits() {
|
Self::vreg | Self::vreg_low16 => match ty.size().bits() {
|
||||||
8 => Some(('b', "b0")),
|
8 => Some(('b', "b0", 8).into()),
|
||||||
16 => Some(('h', "h0")),
|
16 => Some(('h', "h0", 16).into()),
|
||||||
32 => Some(('s', "s0")),
|
32 => Some(('s', "s0", 32).into()),
|
||||||
64 => Some(('d', "d0")),
|
64 => Some(('d', "d0", 64).into()),
|
||||||
128 => Some(('q', "q0")),
|
128 => Some(('q', "q0", 128).into()),
|
||||||
_ => None,
|
_ => None,
|
||||||
},
|
},
|
||||||
Self::preg => None,
|
Self::preg => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||||
match self {
|
match self {
|
||||||
Self::reg => Some(('x', "x0")),
|
Self::reg => Some(('x', "x0", 64).into()),
|
||||||
Self::vreg | Self::vreg_low16 => Some(('v', "v0")),
|
Self::vreg | Self::vreg_low16 => Some(('v', "v0", 128).into()),
|
||||||
Self::preg => None,
|
Self::preg => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use super::{InlineAsmArch, InlineAsmType};
|
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||||
use crate::spec::{RelocModel, Target};
|
use crate::spec::{RelocModel, Target};
|
||||||
use rustc_data_structures::fx::FxIndexSet;
|
use rustc_data_structures::fx::FxIndexSet;
|
||||||
use rustc_macros::HashStable_Generic;
|
use rustc_macros::HashStable_Generic;
|
||||||
|
@ -35,11 +35,11 @@ impl ArmInlineAsmRegClass {
|
||||||
self,
|
self,
|
||||||
_arch: InlineAsmArch,
|
_arch: InlineAsmArch,
|
||||||
_ty: InlineAsmType,
|
_ty: InlineAsmType,
|
||||||
) -> Option<(char, &'static str)> {
|
) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use super::{InlineAsmArch, InlineAsmType};
|
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||||
use rustc_macros::HashStable_Generic;
|
use rustc_macros::HashStable_Generic;
|
||||||
use rustc_span::Symbol;
|
use rustc_span::Symbol;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
@ -29,11 +29,11 @@ impl AvrInlineAsmRegClass {
|
||||||
self,
|
self,
|
||||||
_arch: InlineAsmArch,
|
_arch: InlineAsmArch,
|
||||||
_ty: InlineAsmType,
|
_ty: InlineAsmType,
|
||||||
) -> Option<(char, &'static str)> {
|
) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use super::{InlineAsmArch, InlineAsmType};
|
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||||
use rustc_macros::HashStable_Generic;
|
use rustc_macros::HashStable_Generic;
|
||||||
use rustc_span::Symbol;
|
use rustc_span::Symbol;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
@ -23,11 +23,11 @@ impl BpfInlineAsmRegClass {
|
||||||
self,
|
self,
|
||||||
_arch: InlineAsmArch,
|
_arch: InlineAsmArch,
|
||||||
_ty: InlineAsmType,
|
_ty: InlineAsmType,
|
||||||
) -> Option<(char, &'static str)> {
|
) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use super::{InlineAsmArch, InlineAsmType};
|
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||||
use rustc_macros::HashStable_Generic;
|
use rustc_macros::HashStable_Generic;
|
||||||
use rustc_span::Symbol;
|
use rustc_span::Symbol;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
@ -23,11 +23,11 @@ impl CSKYInlineAsmRegClass {
|
||||||
self,
|
self,
|
||||||
_arch: InlineAsmArch,
|
_arch: InlineAsmArch,
|
||||||
_ty: InlineAsmType,
|
_ty: InlineAsmType,
|
||||||
) -> Option<(char, &'static str)> {
|
) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use super::{InlineAsmArch, InlineAsmType};
|
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||||
use rustc_macros::HashStable_Generic;
|
use rustc_macros::HashStable_Generic;
|
||||||
use rustc_span::Symbol;
|
use rustc_span::Symbol;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
@ -22,11 +22,11 @@ impl HexagonInlineAsmRegClass {
|
||||||
self,
|
self,
|
||||||
_arch: InlineAsmArch,
|
_arch: InlineAsmArch,
|
||||||
_ty: InlineAsmType,
|
_ty: InlineAsmType,
|
||||||
) -> Option<(char, &'static str)> {
|
) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use super::{InlineAsmArch, InlineAsmType};
|
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||||
use rustc_macros::HashStable_Generic;
|
use rustc_macros::HashStable_Generic;
|
||||||
use rustc_span::Symbol;
|
use rustc_span::Symbol;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
@ -23,11 +23,11 @@ impl LoongArchInlineAsmRegClass {
|
||||||
self,
|
self,
|
||||||
_arch: InlineAsmArch,
|
_arch: InlineAsmArch,
|
||||||
_ty: InlineAsmType,
|
_ty: InlineAsmType,
|
||||||
) -> Option<(char, &'static str)> {
|
) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use super::{InlineAsmArch, InlineAsmType};
|
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||||
use rustc_macros::HashStable_Generic;
|
use rustc_macros::HashStable_Generic;
|
||||||
use rustc_span::Symbol;
|
use rustc_span::Symbol;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
@ -24,11 +24,11 @@ impl M68kInlineAsmRegClass {
|
||||||
self,
|
self,
|
||||||
_arch: InlineAsmArch,
|
_arch: InlineAsmArch,
|
||||||
_ty: InlineAsmType,
|
_ty: InlineAsmType,
|
||||||
) -> Option<(char, &'static str)> {
|
) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use super::{InlineAsmArch, InlineAsmType};
|
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||||
use rustc_macros::HashStable_Generic;
|
use rustc_macros::HashStable_Generic;
|
||||||
use rustc_span::Symbol;
|
use rustc_span::Symbol;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
@ -23,11 +23,11 @@ impl MipsInlineAsmRegClass {
|
||||||
self,
|
self,
|
||||||
_arch: InlineAsmArch,
|
_arch: InlineAsmArch,
|
||||||
_ty: InlineAsmType,
|
_ty: InlineAsmType,
|
||||||
) -> Option<(char, &'static str)> {
|
) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,18 @@ use rustc_span::Symbol;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::str::FromStr;
|
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((modifier, result, size): (char, &'static str, u64)) -> Self {
|
||||||
|
Self { modifier, result, size }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
macro_rules! def_reg_class {
|
macro_rules! def_reg_class {
|
||||||
($arch:ident $arch_regclass:ident {
|
($arch:ident $arch_regclass:ident {
|
||||||
$(
|
$(
|
||||||
|
@ -512,11 +524,7 @@ impl InlineAsmRegClass {
|
||||||
/// Such suggestions are useful if a type smaller than the full register
|
/// 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
|
/// size is used and a modifier can be used to point to the subregister of
|
||||||
/// the correct size.
|
/// the correct size.
|
||||||
pub fn suggest_modifier(
|
pub fn suggest_modifier(self, arch: InlineAsmArch, ty: InlineAsmType) -> Option<ModifierInfo> {
|
||||||
self,
|
|
||||||
arch: InlineAsmArch,
|
|
||||||
ty: InlineAsmType,
|
|
||||||
) -> Option<(char, &'static str)> {
|
|
||||||
match self {
|
match self {
|
||||||
Self::X86(r) => r.suggest_modifier(arch, ty),
|
Self::X86(r) => r.suggest_modifier(arch, ty),
|
||||||
Self::Arm(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
|
/// 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
|
/// that the user can be shown how to get the default behavior without a
|
||||||
/// warning.
|
/// warning.
|
||||||
pub fn default_modifier(self, arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
pub fn default_modifier(self, arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||||
match self {
|
match self {
|
||||||
Self::X86(r) => r.default_modifier(arch),
|
Self::X86(r) => r.default_modifier(arch),
|
||||||
Self::Arm(r) => r.default_modifier(arch),
|
Self::Arm(r) => r.default_modifier(arch),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use super::{InlineAsmArch, InlineAsmType};
|
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||||
use rustc_macros::HashStable_Generic;
|
use rustc_macros::HashStable_Generic;
|
||||||
use rustc_span::Symbol;
|
use rustc_span::Symbol;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
@ -22,11 +22,11 @@ impl Msp430InlineAsmRegClass {
|
||||||
self,
|
self,
|
||||||
_arch: InlineAsmArch,
|
_arch: InlineAsmArch,
|
||||||
_ty: InlineAsmType,
|
_ty: InlineAsmType,
|
||||||
) -> Option<(char, &'static str)> {
|
) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use super::{InlineAsmArch, InlineAsmType};
|
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||||
use rustc_macros::HashStable_Generic;
|
use rustc_macros::HashStable_Generic;
|
||||||
use rustc_span::Symbol;
|
use rustc_span::Symbol;
|
||||||
|
|
||||||
|
@ -23,11 +23,11 @@ impl NvptxInlineAsmRegClass {
|
||||||
self,
|
self,
|
||||||
_arch: InlineAsmArch,
|
_arch: InlineAsmArch,
|
||||||
_ty: InlineAsmType,
|
_ty: InlineAsmType,
|
||||||
) -> Option<(char, &'static str)> {
|
) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use super::{InlineAsmArch, InlineAsmType};
|
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||||
use rustc_macros::HashStable_Generic;
|
use rustc_macros::HashStable_Generic;
|
||||||
use rustc_span::Symbol;
|
use rustc_span::Symbol;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
@ -26,11 +26,11 @@ impl PowerPCInlineAsmRegClass {
|
||||||
self,
|
self,
|
||||||
_arch: InlineAsmArch,
|
_arch: InlineAsmArch,
|
||||||
_ty: InlineAsmType,
|
_ty: InlineAsmType,
|
||||||
) -> Option<(char, &'static str)> {
|
) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use super::{InlineAsmArch, InlineAsmType};
|
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||||
use crate::spec::{RelocModel, Target};
|
use crate::spec::{RelocModel, Target};
|
||||||
use rustc_data_structures::fx::FxIndexSet;
|
use rustc_data_structures::fx::FxIndexSet;
|
||||||
use rustc_macros::HashStable_Generic;
|
use rustc_macros::HashStable_Generic;
|
||||||
|
@ -26,11 +26,11 @@ impl RiscVInlineAsmRegClass {
|
||||||
self,
|
self,
|
||||||
_arch: InlineAsmArch,
|
_arch: InlineAsmArch,
|
||||||
_ty: InlineAsmType,
|
_ty: InlineAsmType,
|
||||||
) -> Option<(char, &'static str)> {
|
) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use super::{InlineAsmArch, InlineAsmType};
|
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||||
use rustc_macros::HashStable_Generic;
|
use rustc_macros::HashStable_Generic;
|
||||||
use rustc_span::Symbol;
|
use rustc_span::Symbol;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
@ -24,11 +24,11 @@ impl S390xInlineAsmRegClass {
|
||||||
self,
|
self,
|
||||||
_arch: InlineAsmArch,
|
_arch: InlineAsmArch,
|
||||||
_ty: InlineAsmType,
|
_ty: InlineAsmType,
|
||||||
) -> Option<(char, &'static str)> {
|
) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use super::{InlineAsmArch, InlineAsmType};
|
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||||
use rustc_macros::HashStable_Generic;
|
use rustc_macros::HashStable_Generic;
|
||||||
use rustc_span::Symbol;
|
use rustc_span::Symbol;
|
||||||
|
|
||||||
|
@ -21,11 +21,11 @@ impl SpirVInlineAsmRegClass {
|
||||||
self,
|
self,
|
||||||
_arch: InlineAsmArch,
|
_arch: InlineAsmArch,
|
||||||
_ty: InlineAsmType,
|
_ty: InlineAsmType,
|
||||||
) -> Option<(char, &'static str)> {
|
) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use super::{InlineAsmArch, InlineAsmType};
|
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||||
use rustc_macros::HashStable_Generic;
|
use rustc_macros::HashStable_Generic;
|
||||||
use rustc_span::Symbol;
|
use rustc_span::Symbol;
|
||||||
|
|
||||||
|
@ -21,11 +21,11 @@ impl WasmInlineAsmRegClass {
|
||||||
self,
|
self,
|
||||||
_arch: InlineAsmArch,
|
_arch: InlineAsmArch,
|
||||||
_ty: InlineAsmType,
|
_ty: InlineAsmType,
|
||||||
) -> Option<(char, &'static str)> {
|
) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use super::{InlineAsmArch, InlineAsmType};
|
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||||
use crate::spec::{RelocModel, Target};
|
use crate::spec::{RelocModel, Target};
|
||||||
use rustc_data_structures::fx::FxIndexSet;
|
use rustc_data_structures::fx::FxIndexSet;
|
||||||
use rustc_macros::HashStable_Generic;
|
use rustc_macros::HashStable_Generic;
|
||||||
|
@ -53,32 +53,28 @@ impl X86InlineAsmRegClass {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn suggest_modifier(
|
pub fn suggest_modifier(self, arch: InlineAsmArch, ty: InlineAsmType) -> Option<ModifierInfo> {
|
||||||
self,
|
|
||||||
arch: InlineAsmArch,
|
|
||||||
ty: InlineAsmType,
|
|
||||||
) -> Option<(char, &'static str)> {
|
|
||||||
match self {
|
match self {
|
||||||
Self::reg => match ty.size().bits() {
|
Self::reg => match ty.size().bits() {
|
||||||
16 => Some(('x', "ax")),
|
16 => Some(('x', "ax", 16).into()),
|
||||||
32 if arch == InlineAsmArch::X86_64 => Some(('e', "eax")),
|
32 if arch == InlineAsmArch::X86_64 => Some(('e', "eax", 32).into()),
|
||||||
_ => None,
|
_ => None,
|
||||||
},
|
},
|
||||||
Self::reg_abcd => match ty.size().bits() {
|
Self::reg_abcd => match ty.size().bits() {
|
||||||
16 => Some(('x', "ax")),
|
16 => Some(('x', "ax", 16).into()),
|
||||||
32 if arch == InlineAsmArch::X86_64 => Some(('e', "eax")),
|
32 if arch == InlineAsmArch::X86_64 => Some(('e', "eax", 32).into()),
|
||||||
_ => None,
|
_ => None,
|
||||||
},
|
},
|
||||||
Self::reg_byte => None,
|
Self::reg_byte => None,
|
||||||
Self::xmm_reg => None,
|
Self::xmm_reg => None,
|
||||||
Self::ymm_reg => match ty.size().bits() {
|
Self::ymm_reg => match ty.size().bits() {
|
||||||
256 => None,
|
256 => None,
|
||||||
_ => Some(('x', "xmm0")),
|
_ => Some(('x', "xmm0", 128).into()),
|
||||||
},
|
},
|
||||||
Self::zmm_reg => match ty.size().bits() {
|
Self::zmm_reg => match ty.size().bits() {
|
||||||
512 => None,
|
512 => None,
|
||||||
256 => Some(('y', "ymm0")),
|
256 => Some(('y', "ymm0", 256).into()),
|
||||||
_ => Some(('x', "xmm0")),
|
_ => Some(('x', "xmm0", 128).into()),
|
||||||
},
|
},
|
||||||
Self::kreg | Self::kreg0 => None,
|
Self::kreg | Self::kreg0 => None,
|
||||||
Self::mmx_reg | Self::x87_reg => None,
|
Self::mmx_reg | Self::x87_reg => None,
|
||||||
|
@ -86,19 +82,19 @@ impl X86InlineAsmRegClass {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_modifier(self, arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
pub fn default_modifier(self, arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||||
match self {
|
match self {
|
||||||
Self::reg | Self::reg_abcd => {
|
Self::reg | Self::reg_abcd => {
|
||||||
if arch == InlineAsmArch::X86_64 {
|
if arch == InlineAsmArch::X86_64 {
|
||||||
Some(('r', "rax"))
|
Some(('r', "rax", 64).into())
|
||||||
} else {
|
} else {
|
||||||
Some(('e', "eax"))
|
Some(('e', "eax", 32).into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Self::reg_byte => None,
|
Self::reg_byte => None,
|
||||||
Self::xmm_reg => Some(('x', "xmm0")),
|
Self::xmm_reg => Some(('x', "xmm0", 128).into()),
|
||||||
Self::ymm_reg => Some(('y', "ymm0")),
|
Self::ymm_reg => Some(('y', "ymm0", 256).into()),
|
||||||
Self::zmm_reg => Some(('z', "zmm0")),
|
Self::zmm_reg => Some(('z', "zmm0", 512).into()),
|
||||||
Self::kreg | Self::kreg0 => None,
|
Self::kreg | Self::kreg0 => None,
|
||||||
Self::mmx_reg | Self::x87_reg => None,
|
Self::mmx_reg | Self::x87_reg => None,
|
||||||
Self::tmm_reg => None,
|
Self::tmm_reg => None,
|
||||||
|
|
|
@ -4,8 +4,8 @@ warning: formatting may not be suitable for sub-register argument
|
||||||
LL | asm!("{}", in(reg) 0u8);
|
LL | asm!("{}", in(reg) 0u8);
|
||||||
| ^^ --- for this argument
|
| ^^ --- for this argument
|
||||||
|
|
|
|
||||||
= help: use `{0:w}` to have the register formatted as `w0`
|
= help: use `{0:w}` to have the register formatted as `w0` (for 32-bit values)
|
||||||
= help: or use `{0:x}` to keep the default formatting of `x0`
|
= help: or use `{0:x}` to keep the default formatting of `x0` (for 64-bit values)
|
||||||
= note: `#[warn(asm_sub_register)]` on by default
|
= note: `#[warn(asm_sub_register)]` on by default
|
||||||
|
|
||||||
warning: formatting may not be suitable for sub-register argument
|
warning: formatting may not be suitable for sub-register argument
|
||||||
|
@ -14,8 +14,8 @@ warning: formatting may not be suitable for sub-register argument
|
||||||
LL | asm!("{}", in(reg) 0u16);
|
LL | asm!("{}", in(reg) 0u16);
|
||||||
| ^^ ---- for this argument
|
| ^^ ---- for this argument
|
||||||
|
|
|
|
||||||
= help: use `{0:w}` to have the register formatted as `w0`
|
= help: use `{0:w}` to have the register formatted as `w0` (for 32-bit values)
|
||||||
= help: or use `{0:x}` to keep the default formatting of `x0`
|
= help: or use `{0:x}` to keep the default formatting of `x0` (for 64-bit values)
|
||||||
|
|
||||||
warning: formatting may not be suitable for sub-register argument
|
warning: formatting may not be suitable for sub-register argument
|
||||||
--> $DIR/type-check-3.rs:52:15
|
--> $DIR/type-check-3.rs:52:15
|
||||||
|
@ -23,8 +23,8 @@ warning: formatting may not be suitable for sub-register argument
|
||||||
LL | asm!("{}", in(reg) 0i32);
|
LL | asm!("{}", in(reg) 0i32);
|
||||||
| ^^ ---- for this argument
|
| ^^ ---- for this argument
|
||||||
|
|
|
|
||||||
= help: use `{0:w}` to have the register formatted as `w0`
|
= help: use `{0:w}` to have the register formatted as `w0` (for 32-bit values)
|
||||||
= help: or use `{0:x}` to keep the default formatting of `x0`
|
= help: or use `{0:x}` to keep the default formatting of `x0` (for 64-bit values)
|
||||||
|
|
||||||
warning: formatting may not be suitable for sub-register argument
|
warning: formatting may not be suitable for sub-register argument
|
||||||
--> $DIR/type-check-3.rs:54:15
|
--> $DIR/type-check-3.rs:54:15
|
||||||
|
@ -32,8 +32,8 @@ warning: formatting may not be suitable for sub-register argument
|
||||||
LL | asm!("{}", in(reg) 0f32);
|
LL | asm!("{}", in(reg) 0f32);
|
||||||
| ^^ ---- for this argument
|
| ^^ ---- for this argument
|
||||||
|
|
|
|
||||||
= help: use `{0:w}` to have the register formatted as `w0`
|
= help: use `{0:w}` to have the register formatted as `w0` (for 32-bit values)
|
||||||
= help: or use `{0:x}` to keep the default formatting of `x0`
|
= help: or use `{0:x}` to keep the default formatting of `x0` (for 64-bit values)
|
||||||
|
|
||||||
warning: formatting may not be suitable for sub-register argument
|
warning: formatting may not be suitable for sub-register argument
|
||||||
--> $DIR/type-check-3.rs:57:15
|
--> $DIR/type-check-3.rs:57:15
|
||||||
|
@ -41,8 +41,8 @@ warning: formatting may not be suitable for sub-register argument
|
||||||
LL | asm!("{}", in(vreg) 0i16);
|
LL | asm!("{}", in(vreg) 0i16);
|
||||||
| ^^ ---- for this argument
|
| ^^ ---- for this argument
|
||||||
|
|
|
|
||||||
= help: use `{0:h}` to have the register formatted as `h0`
|
= help: use `{0:h}` to have the register formatted as `h0` (for 16-bit values)
|
||||||
= help: or use `{0:v}` to keep the default formatting of `v0`
|
= help: or use `{0:v}` to keep the default formatting of `v0` (for 128-bit values)
|
||||||
|
|
||||||
warning: formatting may not be suitable for sub-register argument
|
warning: formatting may not be suitable for sub-register argument
|
||||||
--> $DIR/type-check-3.rs:59:15
|
--> $DIR/type-check-3.rs:59:15
|
||||||
|
@ -50,8 +50,8 @@ warning: formatting may not be suitable for sub-register argument
|
||||||
LL | asm!("{}", in(vreg) 0f32);
|
LL | asm!("{}", in(vreg) 0f32);
|
||||||
| ^^ ---- for this argument
|
| ^^ ---- for this argument
|
||||||
|
|
|
|
||||||
= help: use `{0:s}` to have the register formatted as `s0`
|
= help: use `{0:s}` to have the register formatted as `s0` (for 32-bit values)
|
||||||
= help: or use `{0:v}` to keep the default formatting of `v0`
|
= help: or use `{0:v}` to keep the default formatting of `v0` (for 128-bit values)
|
||||||
|
|
||||||
warning: formatting may not be suitable for sub-register argument
|
warning: formatting may not be suitable for sub-register argument
|
||||||
--> $DIR/type-check-3.rs:61:15
|
--> $DIR/type-check-3.rs:61:15
|
||||||
|
@ -59,8 +59,8 @@ warning: formatting may not be suitable for sub-register argument
|
||||||
LL | asm!("{}", in(vreg) 0f64);
|
LL | asm!("{}", in(vreg) 0f64);
|
||||||
| ^^ ---- for this argument
|
| ^^ ---- for this argument
|
||||||
|
|
|
|
||||||
= help: use `{0:d}` to have the register formatted as `d0`
|
= help: use `{0:d}` to have the register formatted as `d0` (for 64-bit values)
|
||||||
= help: or use `{0:v}` to keep the default formatting of `v0`
|
= help: or use `{0:v}` to keep the default formatting of `v0` (for 128-bit values)
|
||||||
|
|
||||||
warning: formatting may not be suitable for sub-register argument
|
warning: formatting may not be suitable for sub-register argument
|
||||||
--> $DIR/type-check-3.rs:63:15
|
--> $DIR/type-check-3.rs:63:15
|
||||||
|
@ -68,8 +68,8 @@ warning: formatting may not be suitable for sub-register argument
|
||||||
LL | asm!("{}", in(vreg_low16) 0f64);
|
LL | asm!("{}", in(vreg_low16) 0f64);
|
||||||
| ^^ ---- for this argument
|
| ^^ ---- for this argument
|
||||||
|
|
|
|
||||||
= help: use `{0:d}` to have the register formatted as `d0`
|
= help: use `{0:d}` to have the register formatted as `d0` (for 64-bit values)
|
||||||
= help: or use `{0:v}` to keep the default formatting of `v0`
|
= help: or use `{0:v}` to keep the default formatting of `v0` (for 128-bit values)
|
||||||
|
|
||||||
warning: formatting may not be suitable for sub-register argument
|
warning: formatting may not be suitable for sub-register argument
|
||||||
--> $DIR/type-check-3.rs:66:15
|
--> $DIR/type-check-3.rs:66:15
|
||||||
|
@ -77,8 +77,8 @@ warning: formatting may not be suitable for sub-register argument
|
||||||
LL | asm!("{0} {0}", in(reg) 0i16);
|
LL | asm!("{0} {0}", in(reg) 0i16);
|
||||||
| ^^^ ^^^ ---- for this argument
|
| ^^^ ^^^ ---- for this argument
|
||||||
|
|
|
|
||||||
= help: use `{0:w}` to have the register formatted as `w0`
|
= help: use `{0:w}` to have the register formatted as `w0` (for 32-bit values)
|
||||||
= help: or use `{0:x}` to keep the default formatting of `x0`
|
= help: or use `{0:x}` to keep the default formatting of `x0` (for 64-bit values)
|
||||||
|
|
||||||
warning: formatting may not be suitable for sub-register argument
|
warning: formatting may not be suitable for sub-register argument
|
||||||
--> $DIR/type-check-3.rs:68:15
|
--> $DIR/type-check-3.rs:68:15
|
||||||
|
@ -86,8 +86,8 @@ warning: formatting may not be suitable for sub-register argument
|
||||||
LL | asm!("{0} {0:x}", in(reg) 0i16);
|
LL | asm!("{0} {0:x}", in(reg) 0i16);
|
||||||
| ^^^ ---- for this argument
|
| ^^^ ---- for this argument
|
||||||
|
|
|
|
||||||
= help: use `{0:w}` to have the register formatted as `w0`
|
= help: use `{0:w}` to have the register formatted as `w0` (for 32-bit values)
|
||||||
= help: or use `{0:x}` to keep the default formatting of `x0`
|
= help: or use `{0:x}` to keep the default formatting of `x0` (for 64-bit values)
|
||||||
|
|
||||||
error: type `i128` cannot be used with this register class
|
error: type `i128` cannot be used with this register class
|
||||||
--> $DIR/type-check-3.rs:73:28
|
--> $DIR/type-check-3.rs:73:28
|
||||||
|
|
|
@ -194,8 +194,8 @@ warning: formatting may not be suitable for sub-register argument
|
||||||
LL | asm!("{:foo}", in(reg) foo);
|
LL | asm!("{:foo}", in(reg) foo);
|
||||||
| ^^^^^^ --- for this argument
|
| ^^^^^^ --- for this argument
|
||||||
|
|
|
|
||||||
= help: use `{0:w}` to have the register formatted as `w0`
|
= help: use `{0:w}` to have the register formatted as `w0` (for 32-bit values)
|
||||||
= help: or use `{0:x}` to keep the default formatting of `x0`
|
= help: or use `{0:x}` to keep the default formatting of `x0` (for 64-bit values)
|
||||||
= note: `#[warn(asm_sub_register)]` on by default
|
= note: `#[warn(asm_sub_register)]` on by default
|
||||||
|
|
||||||
error: aborting due to 21 previous errors; 1 warning emitted
|
error: aborting due to 21 previous errors; 1 warning emitted
|
||||||
|
|
|
@ -194,8 +194,8 @@ warning: formatting may not be suitable for sub-register argument
|
||||||
LL | asm!("{:foo}", in(reg) foo);
|
LL | asm!("{:foo}", in(reg) foo);
|
||||||
| ^^^^^^ --- for this argument
|
| ^^^^^^ --- for this argument
|
||||||
|
|
|
|
||||||
= help: use `{0:e}` to have the register formatted as `eax`
|
= help: use `{0:e}` to have the register formatted as `eax` (for 32-bit values)
|
||||||
= help: or use `{0:r}` to keep the default formatting of `rax`
|
= help: or use `{0:r}` to keep the default formatting of `rax` (for 64-bit values)
|
||||||
= note: `#[warn(asm_sub_register)]` on by default
|
= note: `#[warn(asm_sub_register)]` on by default
|
||||||
|
|
||||||
error: aborting due to 21 previous errors; 1 warning emitted
|
error: aborting due to 21 previous errors; 1 warning emitted
|
||||||
|
|
|
@ -44,8 +44,8 @@ warning: formatting may not be suitable for sub-register argument
|
||||||
LL | asm!("{0} {0}", in(reg) 0i16);
|
LL | asm!("{0} {0}", in(reg) 0i16);
|
||||||
| ^^^ ^^^ ---- for this argument
|
| ^^^ ^^^ ---- for this argument
|
||||||
|
|
|
|
||||||
= help: use `{0:x}` to have the register formatted as `ax`
|
= help: use `{0:x}` to have the register formatted as `ax` (for 16-bit values)
|
||||||
= help: or use `{0:r}` to keep the default formatting of `rax`
|
= help: or use `{0:r}` to keep the default formatting of `rax` (for 64-bit values)
|
||||||
= note: `#[warn(asm_sub_register)]` on by default
|
= note: `#[warn(asm_sub_register)]` on by default
|
||||||
|
|
||||||
warning: formatting may not be suitable for sub-register argument
|
warning: formatting may not be suitable for sub-register argument
|
||||||
|
@ -54,8 +54,8 @@ warning: formatting may not be suitable for sub-register argument
|
||||||
LL | asm!("{0} {0:x}", in(reg) 0i16);
|
LL | asm!("{0} {0:x}", in(reg) 0i16);
|
||||||
| ^^^ ---- for this argument
|
| ^^^ ---- for this argument
|
||||||
|
|
|
|
||||||
= help: use `{0:x}` to have the register formatted as `ax`
|
= help: use `{0:x}` to have the register formatted as `ax` (for 16-bit values)
|
||||||
= help: or use `{0:r}` to keep the default formatting of `rax`
|
= help: or use `{0:r}` to keep the default formatting of `rax` (for 64-bit values)
|
||||||
|
|
||||||
warning: formatting may not be suitable for sub-register argument
|
warning: formatting may not be suitable for sub-register argument
|
||||||
--> $DIR/type-check-3.rs:38:15
|
--> $DIR/type-check-3.rs:38:15
|
||||||
|
@ -63,8 +63,8 @@ warning: formatting may not be suitable for sub-register argument
|
||||||
LL | asm!("{}", in(reg) 0i32);
|
LL | asm!("{}", in(reg) 0i32);
|
||||||
| ^^ ---- for this argument
|
| ^^ ---- for this argument
|
||||||
|
|
|
|
||||||
= help: use `{0:e}` to have the register formatted as `eax`
|
= help: use `{0:e}` to have the register formatted as `eax` (for 32-bit values)
|
||||||
= help: or use `{0:r}` to keep the default formatting of `rax`
|
= help: or use `{0:r}` to keep the default formatting of `rax` (for 64-bit values)
|
||||||
|
|
||||||
warning: formatting may not be suitable for sub-register argument
|
warning: formatting may not be suitable for sub-register argument
|
||||||
--> $DIR/type-check-3.rs:41:15
|
--> $DIR/type-check-3.rs:41:15
|
||||||
|
@ -72,8 +72,8 @@ warning: formatting may not be suitable for sub-register argument
|
||||||
LL | asm!("{}", in(ymm_reg) 0i64);
|
LL | asm!("{}", in(ymm_reg) 0i64);
|
||||||
| ^^ ---- for this argument
|
| ^^ ---- for this argument
|
||||||
|
|
|
|
||||||
= help: use `{0:x}` to have the register formatted as `xmm0`
|
= help: use `{0:x}` to have the register formatted as `xmm0` (for 128-bit values)
|
||||||
= help: or use `{0:y}` to keep the default formatting of `ymm0`
|
= help: or use `{0:y}` to keep the default formatting of `ymm0` (for 256-bit values)
|
||||||
|
|
||||||
error: type `i8` cannot be used with this register class
|
error: type `i8` cannot be used with this register class
|
||||||
--> $DIR/type-check-3.rs:52:28
|
--> $DIR/type-check-3.rs:52:28
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue