diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:29 +0000 |
commit | 631cd5845e8de329d0e227aaa707d7ea228b8f8f (patch) | |
tree | a1b87c8f8cad01cf18f7c5f57a08f102771ed303 /compiler/rustc_target/src/asm | |
parent | Adding debian version 1.69.0+dfsg1-1. (diff) | |
download | rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.tar.xz rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.zip |
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_target/src/asm')
-rw-r--r-- | compiler/rustc_target/src/asm/aarch64.rs | 4 | ||||
-rw-r--r-- | compiler/rustc_target/src/asm/arm.rs | 12 | ||||
-rw-r--r-- | compiler/rustc_target/src/asm/m68k.rs | 81 | ||||
-rw-r--r-- | compiler/rustc_target/src/asm/mod.rs | 45 | ||||
-rw-r--r-- | compiler/rustc_target/src/asm/riscv.rs | 4 | ||||
-rw-r--r-- | compiler/rustc_target/src/asm/x86.rs | 10 |
6 files changed, 131 insertions, 25 deletions
diff --git a/compiler/rustc_target/src/asm/aarch64.rs b/compiler/rustc_target/src/asm/aarch64.rs index 28493c770..97132311a 100644 --- a/compiler/rustc_target/src/asm/aarch64.rs +++ b/compiler/rustc_target/src/asm/aarch64.rs @@ -1,6 +1,6 @@ use super::{InlineAsmArch, InlineAsmType}; use crate::spec::{RelocModel, Target}; -use rustc_data_structures::fx::FxHashSet; +use rustc_data_structures::fx::FxIndexSet; use rustc_macros::HashStable_Generic; use rustc_span::Symbol; use std::fmt; @@ -80,7 +80,7 @@ pub fn target_reserves_x18(target: &Target) -> bool { fn reserved_x18( _arch: InlineAsmArch, _reloc_model: RelocModel, - _target_features: &FxHashSet<Symbol>, + _target_features: &FxIndexSet<Symbol>, target: &Target, _is_clobber: bool, ) -> Result<(), &'static str> { diff --git a/compiler/rustc_target/src/asm/arm.rs b/compiler/rustc_target/src/asm/arm.rs index ec7429a30..514e30ae0 100644 --- a/compiler/rustc_target/src/asm/arm.rs +++ b/compiler/rustc_target/src/asm/arm.rs @@ -1,6 +1,6 @@ use super::{InlineAsmArch, InlineAsmType}; use crate::spec::{RelocModel, Target}; -use rustc_data_structures::fx::FxHashSet; +use rustc_data_structures::fx::FxIndexSet; use rustc_macros::HashStable_Generic; use rustc_span::{sym, Symbol}; use std::fmt; @@ -64,14 +64,14 @@ impl ArmInlineAsmRegClass { } // This uses the same logic as useR7AsFramePointer in LLVM -fn frame_pointer_is_r7(target_features: &FxHashSet<Symbol>, target: &Target) -> bool { +fn frame_pointer_is_r7(target_features: &FxIndexSet<Symbol>, target: &Target) -> bool { target.is_like_osx || (!target.is_like_windows && target_features.contains(&sym::thumb_mode)) } fn frame_pointer_r11( arch: InlineAsmArch, reloc_model: RelocModel, - target_features: &FxHashSet<Symbol>, + target_features: &FxIndexSet<Symbol>, target: &Target, is_clobber: bool, ) -> Result<(), &'static str> { @@ -87,7 +87,7 @@ fn frame_pointer_r11( fn frame_pointer_r7( _arch: InlineAsmArch, _reloc_model: RelocModel, - target_features: &FxHashSet<Symbol>, + target_features: &FxIndexSet<Symbol>, target: &Target, _is_clobber: bool, ) -> Result<(), &'static str> { @@ -101,7 +101,7 @@ fn frame_pointer_r7( fn not_thumb1( _arch: InlineAsmArch, _reloc_model: RelocModel, - target_features: &FxHashSet<Symbol>, + target_features: &FxIndexSet<Symbol>, _target: &Target, is_clobber: bool, ) -> Result<(), &'static str> { @@ -118,7 +118,7 @@ fn not_thumb1( fn reserved_r9( arch: InlineAsmArch, reloc_model: RelocModel, - target_features: &FxHashSet<Symbol>, + target_features: &FxIndexSet<Symbol>, target: &Target, is_clobber: bool, ) -> Result<(), &'static str> { diff --git a/compiler/rustc_target/src/asm/m68k.rs b/compiler/rustc_target/src/asm/m68k.rs new file mode 100644 index 000000000..8c857550c --- /dev/null +++ b/compiler/rustc_target/src/asm/m68k.rs @@ -0,0 +1,81 @@ +use super::{InlineAsmArch, InlineAsmType}; +use rustc_macros::HashStable_Generic; +use rustc_span::Symbol; +use std::fmt; + +def_reg_class! { + M68k M68kInlineAsmRegClass { + reg, + reg_addr, + reg_data, + } +} + +impl M68kInlineAsmRegClass { + pub fn valid_modifiers(self, _arch: super::InlineAsmArch) -> &'static [char] { + &[] + } + + pub fn suggest_class(self, _arch: InlineAsmArch, _ty: InlineAsmType) -> Option<Self> { + None + } + + pub fn suggest_modifier( + self, + _arch: InlineAsmArch, + _ty: InlineAsmType, + ) -> Option<(char, &'static str)> { + None + } + + pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> { + None + } + + pub fn supported_types( + self, + _arch: InlineAsmArch, + ) -> &'static [(InlineAsmType, Option<Symbol>)] { + match self { + Self::reg => types! { _: I16, I32; }, + Self::reg_data => types! { _: I8, I16, I32; }, + Self::reg_addr => types! { _: I16, I32; }, + } + } +} + +def_regs! { + M68k M68kInlineAsmReg M68kInlineAsmRegClass { + d0: reg, reg_data = ["d0"], + d1: reg, reg_data = ["d1"], + d2: reg, reg_data = ["d2"], + d3: reg, reg_data = ["d3"], + d4: reg, reg_data = ["d4"], + d5: reg, reg_data = ["d5"], + d6: reg, reg_data = ["d6"], + d7: reg, reg_data = ["d7"], + a0: reg, reg_addr = ["a0"], + a1: reg, reg_addr = ["a1"], + a2: reg, reg_addr = ["a2"], + a3: reg, reg_addr = ["a3"], + #error = ["a4"] => + "a4 is used internally by LLVM and cannot be used as an operand for inline asm", + #error = ["a5", "bp"] => + "a5 is used internally by LLVM and cannot be used as an operand for inline asm", + #error = ["a6", "fp"] => + "a6 is used internally by LLVM and cannot be used as an operand for inline asm", + #error = ["a7", "sp", "usp", "ssp", "isp"] => + "the stack pointer cannot be used as an operand for inline asm", + } +} + +impl M68kInlineAsmReg { + pub fn emit( + self, + out: &mut dyn fmt::Write, + _arch: InlineAsmArch, + _modifier: Option<char>, + ) -> fmt::Result { + out.write_str(self.name()) + } +} diff --git a/compiler/rustc_target/src/asm/mod.rs b/compiler/rustc_target/src/asm/mod.rs index 70cd883be..3f9c850b3 100644 --- a/compiler/rustc_target/src/asm/mod.rs +++ b/compiler/rustc_target/src/asm/mod.rs @@ -1,6 +1,6 @@ use crate::spec::Target; use crate::{abi::Size, spec::RelocModel}; -use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_data_structures::fx::{FxHashMap, FxIndexSet}; use rustc_macros::HashStable_Generic; use rustc_span::Symbol; use std::fmt; @@ -37,13 +37,14 @@ macro_rules! def_reg_class { pub(super) fn regclass_map() -> rustc_data_structures::fx::FxHashMap< super::InlineAsmRegClass, - rustc_data_structures::fx::FxHashSet<super::InlineAsmReg>, + rustc_data_structures::fx::FxIndexSet<super::InlineAsmReg>, > { - use rustc_data_structures::fx::{FxHashMap, FxHashSet}; + use rustc_data_structures::fx::FxHashMap; + use rustc_data_structures::fx::FxIndexSet; use super::InlineAsmRegClass; let mut map = FxHashMap::default(); $( - map.insert(InlineAsmRegClass::$arch($arch_regclass::$class), FxHashSet::default()); + map.insert(InlineAsmRegClass::$arch($arch_regclass::$class), FxIndexSet::default()); )* map } @@ -94,7 +95,7 @@ macro_rules! def_regs { pub fn validate(self, _arch: super::InlineAsmArch, _reloc_model: crate::spec::RelocModel, - _target_features: &rustc_data_structures::fx::FxHashSet<Symbol>, + _target_features: &rustc_data_structures::fx::FxIndexSet<Symbol>, _target: &crate::spec::Target, _is_clobber: bool, ) -> Result<(), &'static str> { @@ -118,11 +119,11 @@ macro_rules! def_regs { pub(super) fn fill_reg_map( _arch: super::InlineAsmArch, _reloc_model: crate::spec::RelocModel, - _target_features: &rustc_data_structures::fx::FxHashSet<Symbol>, + _target_features: &rustc_data_structures::fx::FxIndexSet<Symbol>, _target: &crate::spec::Target, _map: &mut rustc_data_structures::fx::FxHashMap< super::InlineAsmRegClass, - rustc_data_structures::fx::FxHashSet<super::InlineAsmReg>, + rustc_data_structures::fx::FxIndexSet<super::InlineAsmReg>, >, ) { #[allow(unused_imports)] @@ -167,6 +168,7 @@ mod arm; mod avr; mod bpf; mod hexagon; +mod m68k; mod mips; mod msp430; mod nvptx; @@ -182,6 +184,7 @@ pub use arm::{ArmInlineAsmReg, ArmInlineAsmRegClass}; pub use avr::{AvrInlineAsmReg, AvrInlineAsmRegClass}; pub use bpf::{BpfInlineAsmReg, BpfInlineAsmRegClass}; pub use hexagon::{HexagonInlineAsmReg, HexagonInlineAsmRegClass}; +pub use m68k::{M68kInlineAsmReg, M68kInlineAsmRegClass}; pub use mips::{MipsInlineAsmReg, MipsInlineAsmRegClass}; pub use msp430::{Msp430InlineAsmReg, Msp430InlineAsmRegClass}; pub use nvptx::{NvptxInlineAsmReg, NvptxInlineAsmRegClass}; @@ -213,6 +216,7 @@ pub enum InlineAsmArch { Bpf, Avr, Msp430, + M68k, } impl FromStr for InlineAsmArch { @@ -239,6 +243,7 @@ impl FromStr for InlineAsmArch { "bpf" => Ok(Self::Bpf), "avr" => Ok(Self::Avr), "msp430" => Ok(Self::Msp430), + "m68k" => Ok(Self::M68k), _ => Err(()), } } @@ -261,6 +266,7 @@ pub enum InlineAsmReg { Bpf(BpfInlineAsmReg), Avr(AvrInlineAsmReg), Msp430(Msp430InlineAsmReg), + M68k(M68kInlineAsmReg), // Placeholder for invalid register constraints for the current target Err, } @@ -279,6 +285,7 @@ impl InlineAsmReg { Self::Bpf(r) => r.name(), Self::Avr(r) => r.name(), Self::Msp430(r) => r.name(), + Self::M68k(r) => r.name(), Self::Err => "<reg>", } } @@ -296,6 +303,7 @@ impl InlineAsmReg { Self::Bpf(r) => InlineAsmRegClass::Bpf(r.reg_class()), Self::Avr(r) => InlineAsmRegClass::Avr(r.reg_class()), Self::Msp430(r) => InlineAsmRegClass::Msp430(r.reg_class()), + Self::M68k(r) => InlineAsmRegClass::M68k(r.reg_class()), Self::Err => InlineAsmRegClass::Err, } } @@ -327,6 +335,7 @@ impl InlineAsmReg { InlineAsmArch::Bpf => Self::Bpf(BpfInlineAsmReg::parse(name)?), InlineAsmArch::Avr => Self::Avr(AvrInlineAsmReg::parse(name)?), InlineAsmArch::Msp430 => Self::Msp430(Msp430InlineAsmReg::parse(name)?), + InlineAsmArch::M68k => Self::M68k(M68kInlineAsmReg::parse(name)?), }) } @@ -334,7 +343,7 @@ impl InlineAsmReg { self, arch: InlineAsmArch, reloc_model: RelocModel, - target_features: &FxHashSet<Symbol>, + target_features: &FxIndexSet<Symbol>, target: &Target, is_clobber: bool, ) -> Result<(), &'static str> { @@ -350,6 +359,7 @@ impl InlineAsmReg { Self::Bpf(r) => r.validate(arch, reloc_model, target_features, target, is_clobber), Self::Avr(r) => r.validate(arch, reloc_model, target_features, target, is_clobber), Self::Msp430(r) => r.validate(arch, reloc_model, target_features, target, is_clobber), + Self::M68k(r) => r.validate(arch, reloc_model, target_features, target, is_clobber), Self::Err => unreachable!(), } } @@ -374,6 +384,7 @@ impl InlineAsmReg { Self::Bpf(r) => r.emit(out, arch, modifier), Self::Avr(r) => r.emit(out, arch, modifier), Self::Msp430(r) => r.emit(out, arch, modifier), + Self::M68k(r) => r.emit(out, arch, modifier), Self::Err => unreachable!("Use of InlineAsmReg::Err"), } } @@ -391,6 +402,7 @@ impl InlineAsmReg { Self::Bpf(r) => r.overlapping_regs(|r| cb(Self::Bpf(r))), Self::Avr(r) => r.overlapping_regs(|r| cb(Self::Avr(r))), Self::Msp430(_) => cb(self), + Self::M68k(_) => cb(self), Self::Err => unreachable!("Use of InlineAsmReg::Err"), } } @@ -413,6 +425,7 @@ pub enum InlineAsmRegClass { Bpf(BpfInlineAsmRegClass), Avr(AvrInlineAsmRegClass), Msp430(Msp430InlineAsmRegClass), + M68k(M68kInlineAsmRegClass), // Placeholder for invalid register constraints for the current target Err, } @@ -434,6 +447,7 @@ impl InlineAsmRegClass { Self::Bpf(r) => r.name(), Self::Avr(r) => r.name(), Self::Msp430(r) => r.name(), + Self::M68k(r) => r.name(), Self::Err => rustc_span::symbol::sym::reg, } } @@ -457,6 +471,7 @@ impl InlineAsmRegClass { Self::Bpf(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::Bpf), Self::Avr(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::Avr), Self::Msp430(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::Msp430), + Self::M68k(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::M68k), Self::Err => unreachable!("Use of InlineAsmRegClass::Err"), } } @@ -487,6 +502,7 @@ impl InlineAsmRegClass { Self::Bpf(r) => r.suggest_modifier(arch, ty), Self::Avr(r) => r.suggest_modifier(arch, ty), Self::Msp430(r) => r.suggest_modifier(arch, ty), + Self::M68k(r) => r.suggest_modifier(arch, ty), Self::Err => unreachable!("Use of InlineAsmRegClass::Err"), } } @@ -513,6 +529,7 @@ impl InlineAsmRegClass { Self::Bpf(r) => r.default_modifier(arch), Self::Avr(r) => r.default_modifier(arch), Self::Msp430(r) => r.default_modifier(arch), + Self::M68k(r) => r.default_modifier(arch), Self::Err => unreachable!("Use of InlineAsmRegClass::Err"), } } @@ -538,6 +555,7 @@ impl InlineAsmRegClass { Self::Bpf(r) => r.supported_types(arch), Self::Avr(r) => r.supported_types(arch), Self::Msp430(r) => r.supported_types(arch), + Self::M68k(r) => r.supported_types(arch), Self::Err => unreachable!("Use of InlineAsmRegClass::Err"), } } @@ -568,6 +586,7 @@ impl InlineAsmRegClass { InlineAsmArch::Bpf => Self::Bpf(BpfInlineAsmRegClass::parse(name)?), InlineAsmArch::Avr => Self::Avr(AvrInlineAsmRegClass::parse(name)?), InlineAsmArch::Msp430 => Self::Msp430(Msp430InlineAsmRegClass::parse(name)?), + InlineAsmArch::M68k => Self::M68k(M68kInlineAsmRegClass::parse(name)?), }) } @@ -589,6 +608,7 @@ impl InlineAsmRegClass { Self::Bpf(r) => r.valid_modifiers(arch), Self::Avr(r) => r.valid_modifiers(arch), Self::Msp430(r) => r.valid_modifiers(arch), + Self::M68k(r) => r.valid_modifiers(arch), Self::Err => unreachable!("Use of InlineAsmRegClass::Err"), } } @@ -701,9 +721,9 @@ impl fmt::Display for InlineAsmType { pub fn allocatable_registers( arch: InlineAsmArch, reloc_model: RelocModel, - target_features: &FxHashSet<Symbol>, + target_features: &FxIndexSet<Symbol>, target: &crate::spec::Target, -) -> FxHashMap<InlineAsmRegClass, FxHashSet<InlineAsmReg>> { +) -> FxHashMap<InlineAsmRegClass, FxIndexSet<InlineAsmReg>> { match arch { InlineAsmArch::X86 | InlineAsmArch::X86_64 => { let mut map = x86::regclass_map(); @@ -775,6 +795,11 @@ pub fn allocatable_registers( msp430::fill_reg_map(arch, reloc_model, target_features, target, &mut map); map } + InlineAsmArch::M68k => { + let mut map = m68k::regclass_map(); + m68k::fill_reg_map(arch, reloc_model, target_features, target, &mut map); + map + } } } diff --git a/compiler/rustc_target/src/asm/riscv.rs b/compiler/rustc_target/src/asm/riscv.rs index e41bdc9a5..dea6d50fe 100644 --- a/compiler/rustc_target/src/asm/riscv.rs +++ b/compiler/rustc_target/src/asm/riscv.rs @@ -1,6 +1,6 @@ use super::{InlineAsmArch, InlineAsmType}; use crate::spec::{RelocModel, Target}; -use rustc_data_structures::fx::FxHashSet; +use rustc_data_structures::fx::FxIndexSet; use rustc_macros::HashStable_Generic; use rustc_span::{sym, Symbol}; use std::fmt; @@ -55,7 +55,7 @@ impl RiscVInlineAsmRegClass { fn not_e( _arch: InlineAsmArch, _reloc_model: RelocModel, - target_features: &FxHashSet<Symbol>, + target_features: &FxIndexSet<Symbol>, _target: &Target, _is_clobber: bool, ) -> Result<(), &'static str> { diff --git a/compiler/rustc_target/src/asm/x86.rs b/compiler/rustc_target/src/asm/x86.rs index 5eae07f14..3902dac7f 100644 --- a/compiler/rustc_target/src/asm/x86.rs +++ b/compiler/rustc_target/src/asm/x86.rs @@ -1,6 +1,6 @@ use super::{InlineAsmArch, InlineAsmType}; use crate::spec::{RelocModel, Target}; -use rustc_data_structures::fx::FxHashSet; +use rustc_data_structures::fx::FxIndexSet; use rustc_macros::HashStable_Generic; use rustc_span::Symbol; use std::fmt; @@ -147,7 +147,7 @@ impl X86InlineAsmRegClass { fn x86_64_only( arch: InlineAsmArch, _reloc_model: RelocModel, - _target_features: &FxHashSet<Symbol>, + _target_features: &FxIndexSet<Symbol>, _target: &Target, _is_clobber: bool, ) -> Result<(), &'static str> { @@ -161,7 +161,7 @@ fn x86_64_only( fn high_byte( arch: InlineAsmArch, _reloc_model: RelocModel, - _target_features: &FxHashSet<Symbol>, + _target_features: &FxIndexSet<Symbol>, _target: &Target, _is_clobber: bool, ) -> Result<(), &'static str> { @@ -174,7 +174,7 @@ fn high_byte( fn rbx_reserved( arch: InlineAsmArch, _reloc_model: RelocModel, - _target_features: &FxHashSet<Symbol>, + _target_features: &FxIndexSet<Symbol>, _target: &Target, _is_clobber: bool, ) -> Result<(), &'static str> { @@ -190,7 +190,7 @@ fn rbx_reserved( fn esi_reserved( arch: InlineAsmArch, _reloc_model: RelocModel, - _target_features: &FxHashSet<Symbol>, + _target_features: &FxIndexSet<Symbol>, _target: &Target, _is_clobber: bool, ) -> Result<(), &'static str> { |