parent
d561a84d48
commit
9aac0c9ae3
19 changed files with 100 additions and 92 deletions
|
@ -1,4 +1,4 @@
|
|||
use super::{InlineAsmArch, InlineAsmType};
|
||||
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||
use crate::spec::{RelocModel, Target};
|
||||
use rustc_data_structures::fx::FxIndexSet;
|
||||
use rustc_macros::HashStable_Generic;
|
||||
|
@ -27,32 +27,28 @@ impl AArch64InlineAsmRegClass {
|
|||
None
|
||||
}
|
||||
|
||||
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::reg => match ty.size().bits() {
|
||||
64 => None,
|
||||
_ => Some(('w', "w0")),
|
||||
_ => Some(('w', "w0", 32).into()),
|
||||
},
|
||||
Self::vreg | Self::vreg_low16 => match ty.size().bits() {
|
||||
8 => Some(('b', "b0")),
|
||||
16 => Some(('h', "h0")),
|
||||
32 => Some(('s', "s0")),
|
||||
64 => Some(('d', "d0")),
|
||||
128 => Some(('q', "q0")),
|
||||
8 => Some(('b', "b0", 8).into()),
|
||||
16 => Some(('h', "h0", 16).into()),
|
||||
32 => Some(('s', "s0", 32).into()),
|
||||
64 => Some(('d', "d0", 64).into()),
|
||||
128 => Some(('q', "q0", 128).into()),
|
||||
_ => 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 {
|
||||
Self::reg => Some(('x', "x0")),
|
||||
Self::vreg | Self::vreg_low16 => Some(('v', "v0")),
|
||||
Self::reg => Some(('x', "x0", 64).into()),
|
||||
Self::vreg | Self::vreg_low16 => Some(('v', "v0", 128).into()),
|
||||
Self::preg => None,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use super::{InlineAsmArch, InlineAsmType};
|
||||
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||
use crate::spec::{RelocModel, Target};
|
||||
use rustc_data_structures::fx::FxIndexSet;
|
||||
use rustc_macros::HashStable_Generic;
|
||||
|
@ -35,11 +35,11 @@ impl ArmInlineAsmRegClass {
|
|||
self,
|
||||
_arch: InlineAsmArch,
|
||||
_ty: InlineAsmType,
|
||||
) -> Option<(char, &'static str)> {
|
||||
) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use super::{InlineAsmArch, InlineAsmType};
|
||||
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||
use rustc_macros::HashStable_Generic;
|
||||
use rustc_span::Symbol;
|
||||
use std::fmt;
|
||||
|
@ -29,11 +29,11 @@ impl AvrInlineAsmRegClass {
|
|||
self,
|
||||
_arch: InlineAsmArch,
|
||||
_ty: InlineAsmType,
|
||||
) -> Option<(char, &'static str)> {
|
||||
) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use super::{InlineAsmArch, InlineAsmType};
|
||||
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||
use rustc_macros::HashStable_Generic;
|
||||
use rustc_span::Symbol;
|
||||
use std::fmt;
|
||||
|
@ -23,11 +23,11 @@ impl BpfInlineAsmRegClass {
|
|||
self,
|
||||
_arch: InlineAsmArch,
|
||||
_ty: InlineAsmType,
|
||||
) -> Option<(char, &'static str)> {
|
||||
) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use super::{InlineAsmArch, InlineAsmType};
|
||||
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||
use rustc_macros::HashStable_Generic;
|
||||
use rustc_span::Symbol;
|
||||
use std::fmt;
|
||||
|
@ -23,11 +23,11 @@ impl CSKYInlineAsmRegClass {
|
|||
self,
|
||||
_arch: InlineAsmArch,
|
||||
_ty: InlineAsmType,
|
||||
) -> Option<(char, &'static str)> {
|
||||
) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use super::{InlineAsmArch, InlineAsmType};
|
||||
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||
use rustc_macros::HashStable_Generic;
|
||||
use rustc_span::Symbol;
|
||||
use std::fmt;
|
||||
|
@ -22,11 +22,11 @@ impl HexagonInlineAsmRegClass {
|
|||
self,
|
||||
_arch: InlineAsmArch,
|
||||
_ty: InlineAsmType,
|
||||
) -> Option<(char, &'static str)> {
|
||||
) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use super::{InlineAsmArch, InlineAsmType};
|
||||
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||
use rustc_macros::HashStable_Generic;
|
||||
use rustc_span::Symbol;
|
||||
use std::fmt;
|
||||
|
@ -23,11 +23,11 @@ impl LoongArchInlineAsmRegClass {
|
|||
self,
|
||||
_arch: InlineAsmArch,
|
||||
_ty: InlineAsmType,
|
||||
) -> Option<(char, &'static str)> {
|
||||
) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use super::{InlineAsmArch, InlineAsmType};
|
||||
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||
use rustc_macros::HashStable_Generic;
|
||||
use rustc_span::Symbol;
|
||||
use std::fmt;
|
||||
|
@ -24,11 +24,11 @@ impl M68kInlineAsmRegClass {
|
|||
self,
|
||||
_arch: InlineAsmArch,
|
||||
_ty: InlineAsmType,
|
||||
) -> Option<(char, &'static str)> {
|
||||
) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use super::{InlineAsmArch, InlineAsmType};
|
||||
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||
use rustc_macros::HashStable_Generic;
|
||||
use rustc_span::Symbol;
|
||||
use std::fmt;
|
||||
|
@ -23,11 +23,11 @@ impl MipsInlineAsmRegClass {
|
|||
self,
|
||||
_arch: InlineAsmArch,
|
||||
_ty: InlineAsmType,
|
||||
) -> Option<(char, &'static str)> {
|
||||
) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use super::{InlineAsmArch, InlineAsmType};
|
||||
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||
use rustc_macros::HashStable_Generic;
|
||||
use rustc_span::Symbol;
|
||||
use std::fmt;
|
||||
|
@ -22,11 +22,11 @@ impl Msp430InlineAsmRegClass {
|
|||
self,
|
||||
_arch: InlineAsmArch,
|
||||
_ty: InlineAsmType,
|
||||
) -> Option<(char, &'static str)> {
|
||||
) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use super::{InlineAsmArch, InlineAsmType};
|
||||
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||
use rustc_macros::HashStable_Generic;
|
||||
use rustc_span::Symbol;
|
||||
|
||||
|
@ -23,11 +23,11 @@ impl NvptxInlineAsmRegClass {
|
|||
self,
|
||||
_arch: InlineAsmArch,
|
||||
_ty: InlineAsmType,
|
||||
) -> Option<(char, &'static str)> {
|
||||
) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use super::{InlineAsmArch, InlineAsmType};
|
||||
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||
use rustc_macros::HashStable_Generic;
|
||||
use rustc_span::Symbol;
|
||||
use std::fmt;
|
||||
|
@ -26,11 +26,11 @@ impl PowerPCInlineAsmRegClass {
|
|||
self,
|
||||
_arch: InlineAsmArch,
|
||||
_ty: InlineAsmType,
|
||||
) -> Option<(char, &'static str)> {
|
||||
) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use super::{InlineAsmArch, InlineAsmType};
|
||||
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||
use crate::spec::{RelocModel, Target};
|
||||
use rustc_data_structures::fx::FxIndexSet;
|
||||
use rustc_macros::HashStable_Generic;
|
||||
|
@ -26,11 +26,11 @@ impl RiscVInlineAsmRegClass {
|
|||
self,
|
||||
_arch: InlineAsmArch,
|
||||
_ty: InlineAsmType,
|
||||
) -> Option<(char, &'static str)> {
|
||||
) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use super::{InlineAsmArch, InlineAsmType};
|
||||
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||
use rustc_macros::HashStable_Generic;
|
||||
use rustc_span::Symbol;
|
||||
use std::fmt;
|
||||
|
@ -24,11 +24,11 @@ impl S390xInlineAsmRegClass {
|
|||
self,
|
||||
_arch: InlineAsmArch,
|
||||
_ty: InlineAsmType,
|
||||
) -> Option<(char, &'static str)> {
|
||||
) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use super::{InlineAsmArch, InlineAsmType};
|
||||
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||
use rustc_macros::HashStable_Generic;
|
||||
use rustc_span::Symbol;
|
||||
|
||||
|
@ -21,11 +21,11 @@ impl SpirVInlineAsmRegClass {
|
|||
self,
|
||||
_arch: InlineAsmArch,
|
||||
_ty: InlineAsmType,
|
||||
) -> Option<(char, &'static str)> {
|
||||
) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use super::{InlineAsmArch, InlineAsmType};
|
||||
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||
use rustc_macros::HashStable_Generic;
|
||||
use rustc_span::Symbol;
|
||||
|
||||
|
@ -21,11 +21,11 @@ impl WasmInlineAsmRegClass {
|
|||
self,
|
||||
_arch: InlineAsmArch,
|
||||
_ty: InlineAsmType,
|
||||
) -> Option<(char, &'static str)> {
|
||||
) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
|
||||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<ModifierInfo> {
|
||||
None
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use super::{InlineAsmArch, InlineAsmType};
|
||||
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
|
||||
use crate::spec::{RelocModel, Target};
|
||||
use rustc_data_structures::fx::FxIndexSet;
|
||||
use rustc_macros::HashStable_Generic;
|
||||
|
@ -53,32 +53,28 @@ impl X86InlineAsmRegClass {
|
|||
}
|
||||
}
|
||||
|
||||
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::reg => match ty.size().bits() {
|
||||
16 => Some(('x', "ax")),
|
||||
32 if arch == InlineAsmArch::X86_64 => Some(('e', "eax")),
|
||||
16 => Some(('x', "ax", 16).into()),
|
||||
32 if arch == InlineAsmArch::X86_64 => Some(('e', "eax", 32).into()),
|
||||
_ => None,
|
||||
},
|
||||
Self::reg_abcd => match ty.size().bits() {
|
||||
16 => Some(('x', "ax")),
|
||||
32 if arch == InlineAsmArch::X86_64 => Some(('e', "eax")),
|
||||
16 => Some(('x', "ax", 16).into()),
|
||||
32 if arch == InlineAsmArch::X86_64 => Some(('e', "eax", 32).into()),
|
||||
_ => None,
|
||||
},
|
||||
Self::reg_byte => None,
|
||||
Self::xmm_reg => None,
|
||||
Self::ymm_reg => match ty.size().bits() {
|
||||
256 => None,
|
||||
_ => Some(('x', "xmm0")),
|
||||
_ => Some(('x', "xmm0", 128).into()),
|
||||
},
|
||||
Self::zmm_reg => match ty.size().bits() {
|
||||
512 => None,
|
||||
256 => Some(('y', "ymm0")),
|
||||
_ => Some(('x', "xmm0")),
|
||||
256 => Some(('y', "ymm0", 256).into()),
|
||||
_ => Some(('x', "xmm0", 128).into()),
|
||||
},
|
||||
Self::kreg | Self::kreg0 => 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 {
|
||||
Self::reg | Self::reg_abcd => {
|
||||
if arch == InlineAsmArch::X86_64 {
|
||||
Some(('r', "rax"))
|
||||
Some(('r', "rax", 64).into())
|
||||
} else {
|
||||
Some(('e', "eax"))
|
||||
Some(('e', "eax", 32).into())
|
||||
}
|
||||
}
|
||||
Self::reg_byte => None,
|
||||
Self::xmm_reg => Some(('x', "xmm0")),
|
||||
Self::ymm_reg => Some(('y', "ymm0")),
|
||||
Self::zmm_reg => Some(('z', "zmm0")),
|
||||
Self::xmm_reg => Some(('x', "xmm0", 128).into()),
|
||||
Self::ymm_reg => Some(('y', "ymm0", 256).into()),
|
||||
Self::zmm_reg => Some(('z', "zmm0", 512).into()),
|
||||
Self::kreg | Self::kreg0 => None,
|
||||
Self::mmx_reg | Self::x87_reg => None,
|
||||
Self::tmm_reg => None,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue